summaryrefslogtreecommitdiff
path: root/src
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
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')
-rw-r--r--src/CMakeLists.txt2163
-rw-r--r--src/Makefile.am2148
-rw-r--r--src/SDLMain.m385
-rw-r--r--src/actions/actiondef.h53
-rw-r--r--src/actions/actionfuncptr.h28
-rw-r--r--src/actions/actions.h127
-rw-r--r--src/actions/chat.h72
-rw-r--r--src/actions/commands.h170
-rw-r--r--src/actions/move.h47
-rw-r--r--src/actions/pets.h52
-rw-r--r--src/actions/statusbar.h52
-rw-r--r--src/actions/tabs.h42
-rw-r--r--src/actions/target.h42
-rw-r--r--src/actions/windows.h63
-rw-r--r--src/actormanager.cpp2265
-rw-r--r--src/actormanager.h454
-rw-r--r--src/avatar.cpp66
-rw-r--r--src/avatar.h207
-rw-r--r--src/being/actor.cpp87
-rw-r--r--src/being/actor.h146
-rw-r--r--src/being/actorsprite.cpp602
-rw-r--r--src/being/actorsprite.h274
-rw-r--r--src/being/being.cpp5470
-rw-r--r--src/being/being.h1375
-rw-r--r--src/being/beingcacheentry.h138
-rw-r--r--src/being/beingflag.h37
-rw-r--r--src/being/beingspeech.h37
-rw-r--r--src/being/castingeffect.cpp105
-rw-r--r--src/being/castingeffect.h75
-rw-r--r--src/being/compounditem.h46
-rw-r--r--src/being/compoundsprite.cpp566
-rw-r--r--src/being/compoundsprite.h143
-rw-r--r--src/being/crazymoves.cpp824
-rw-r--r--src/being/crazymoves.h62
-rw-r--r--src/being/flooritem.cpp225
-rw-r--r--src/being/flooritem.h153
-rw-r--r--src/being/homunculusinfo.h53
-rw-r--r--src/being/localplayer.cpp2816
-rw-r--r--src/being/localplayer.h533
-rw-r--r--src/being/mercenaryinfo.h46
-rw-r--r--src/being/petinfo.h57
-rw-r--r--src/being/playerignorestrategy.h58
-rw-r--r--src/being/playerinfo.cpp693
-rw-r--r--src/being/playerinfo.h313
-rw-r--r--src/being/playerrelation.cpp30
-rw-r--r--src/being/playerrelation.h57
-rw-r--r--src/being/playerrelations.cpp661
-rw-r--r--src/being/playerrelations.h213
-rw-r--r--src/beingequipbackend.cpp92
-rw-r--r--src/beingequipbackend.h53
-rw-r--r--src/chatlogger.cpp233
-rw-r--r--src/chatlogger.h88
-rw-r--r--src/client.h31
-rw-r--r--src/commandline.cpp293
-rw-r--r--src/commandline.h30
-rw-r--r--src/configmanager.cpp453
-rw-r--r--src/configmanager.h48
-rw-r--r--src/configuration.cpp969
-rw-r--r--src/configuration.h392
-rw-r--r--src/const/emoteshortcut.h26
-rw-r--r--src/const/equipment.h30
-rw-r--r--src/const/gui/chat.h32
-rw-r--r--src/const/gui/pages.h30
-rw-r--r--src/const/gui/theme.h32
-rw-r--r--src/const/itemshortcut.h30
-rw-r--r--src/const/net/inventory.h29
-rw-r--r--src/const/net/maxpacketversion.h32
-rw-r--r--src/const/net/net.h36
-rw-r--r--src/const/net/nostat.h28
-rw-r--r--src/const/net/skill.h57
-rw-r--r--src/const/render/graphics.h31
-rw-r--r--src/const/resources/currency.h28
-rw-r--r--src/const/resources/item/cards.h31
-rw-r--r--src/const/resources/item/itemoptions.h26
-rw-r--r--src/const/resources/map/map.h28
-rw-r--r--src/const/resources/skill.h27
-rw-r--r--src/const/resources/spriteaction.h74
-rw-r--r--src/const/sound.h37
-rw-r--r--src/const/spells.h32
-rw-r--r--src/const/utils/timer.h31
-rw-r--r--src/const/utils/utf8.h28
-rw-r--r--src/debug.h64
-rw-r--r--src/debug/mse/LICENSE_1_0.txt23
-rw-r--r--src/debug/mse/msemsevector.h2432
-rw-r--r--src/debug/mse/msemstdvector.h413
-rw-r--r--src/debug/mse/mseprimitives.h872
-rw-r--r--src/debug/mse/source.txt1
-rw-r--r--src/debug/nvwa/_nvwa.h112
-rw-r--r--src/debug/nvwa/c++11.h340
-rw-r--r--src/debug/nvwa/debug_new.cpp1197
-rw-r--r--src/debug/nvwa/debug_new.h207
-rw-r--r--src/debug/nvwa/fast_mutex.h427
-rw-r--r--src/debug/nvwa/source.txt1
-rw-r--r--src/debug/nvwa/static_assert.h62
-rw-r--r--src/debug/readme.txt2
-rw-r--r--src/defaults.cpp742
-rw-r--r--src/defaults.h47
-rw-r--r--src/dirs.cpp615
-rw-r--r--src/dirs.h67
-rw-r--r--src/dragdrop.h266
-rw-r--r--src/effectmanager.cpp270
-rw-r--r--src/effectmanager.h101
-rw-r--r--src/enums/being/actortype.h44
-rw-r--r--src/enums/being/attacktype.h48
-rw-r--r--src/enums/being/attributes.h119
-rw-r--r--src/enums/being/attributesstrings.cpp119
-rw-r--r--src/enums/being/attributesstrings.h36
-rw-r--r--src/enums/being/badgedrawtype.h35
-rw-r--r--src/enums/being/badgeindex.h42
-rw-r--r--src/enums/being/beingaction.h42
-rw-r--r--src/enums/being/beingdirection.h40
-rw-r--r--src/enums/being/cookingtype.h37
-rw-r--r--src/enums/being/gender.h37
-rw-r--r--src/enums/being/pickup.h45
-rw-r--r--src/enums/being/rank.h35
-rw-r--r--src/enums/being/reachable.h36
-rw-r--r--src/enums/being/relation.h40
-rw-r--r--src/enums/being/targetcursorsize.h36
-rw-r--r--src/enums/being/targetcursortype.h36
-rw-r--r--src/enums/being/visiblename.h34
-rw-r--r--src/enums/being/visiblenamepos.h33
-rw-r--r--src/enums/commandtarget.h34
-rw-r--r--src/enums/cutin.h36
-rw-r--r--src/enums/dragdropsource.h49
-rw-r--r--src/enums/emotetype.h35
-rw-r--r--src/enums/equipslot.h58
-rw-r--r--src/enums/events/keyeventtype.h76
-rw-r--r--src/enums/events/mousebutton.h79
-rw-r--r--src/enums/events/mouseeventtype.h84
-rw-r--r--src/enums/fs/fsentrytype.h33
-rw-r--r--src/enums/gui/chatmsgtype.h42
-rw-r--r--src/enums/gui/chattabtype.h51
-rw-r--r--src/enums/gui/colorname.h45
-rw-r--r--src/enums/gui/dialogtype.h38
-rw-r--r--src/enums/gui/gradienttype.h39
-rw-r--r--src/enums/gui/itemamountwindowusage.h44
-rw-r--r--src/enums/gui/layouttype.h42
-rw-r--r--src/enums/gui/linkhighlightmode.h42
-rw-r--r--src/enums/gui/npcactionstate.h46
-rw-r--r--src/enums/gui/npcinputstate.h40
-rw-r--r--src/enums/gui/orientation.h78
-rw-r--r--src/enums/gui/progresscolorid.h48
-rw-r--r--src/enums/gui/serverdialogdonwloadstatus.h40
-rw-r--r--src/enums/gui/shoplistboxtype.h34
-rw-r--r--src/enums/gui/slidergrid.h85
-rw-r--r--src/enums/gui/themecolorid.h258
-rw-r--r--src/enums/gui/updatedownloadstatus.h42
-rw-r--r--src/enums/gui/usercolorid.h100
-rw-r--r--src/enums/guildpositionflags.h38
-rw-r--r--src/enums/input/inputaction.h716
-rw-r--r--src/enums/input/inputcondition.h61
-rw-r--r--src/enums/input/inputgroup.h45
-rw-r--r--src/enums/input/inputtype.h43
-rw-r--r--src/enums/input/keyboardfocus.h34
-rw-r--r--src/enums/input/keyvalue.h131
-rw-r--r--src/enums/inventorytype.h43
-rw-r--r--src/enums/magicschool.h40
-rw-r--r--src/enums/net/auctionsearchtype.h37
-rw-r--r--src/enums/net/battlegroundtype.h35
-rw-r--r--src/enums/net/beingtype.h42
-rw-r--r--src/enums/net/deleteitemreason.h39
-rw-r--r--src/enums/net/downloadstatus.h38
-rw-r--r--src/enums/net/mailmessagetype.h39
-rw-r--r--src/enums/net/mailopentype.h34
-rw-r--r--src/enums/net/menutype.h48
-rw-r--r--src/enums/net/npcaction.h34
-rw-r--r--src/enums/net/packettype.h45
-rw-r--r--src/enums/net/partyshare.h37
-rw-r--r--src/enums/net/serverfreetype.h37
-rw-r--r--src/enums/net/servertype.h37
-rw-r--r--src/enums/net/storesearchtype.h33
-rw-r--r--src/enums/net/updatetype.h37
-rw-r--r--src/enums/particle/alivestatus.h40
-rw-r--r--src/enums/particle/particlechangefunc.h38
-rw-r--r--src/enums/particle/particlephysics.h34
-rw-r--r--src/enums/particle/particletype.h36
-rw-r--r--src/enums/render/blitmode.h35
-rw-r--r--src/enums/render/rendertype.h37
-rw-r--r--src/enums/resources/cursor.h45
-rw-r--r--src/enums/resources/displaytype.h33
-rw-r--r--src/enums/resources/frametype.h40
-rw-r--r--src/enums/resources/imageposition.h61
-rw-r--r--src/enums/resources/imagetype.h33
-rw-r--r--src/enums/resources/item/itemdbtype.h50
-rw-r--r--src/enums/resources/item/itemsoundevent.h47
-rw-r--r--src/enums/resources/item/itemtype.h44
-rw-r--r--src/enums/resources/mailqueuetype.h35
-rw-r--r--src/enums/resources/map/blockmask.h40
-rw-r--r--src/enums/resources/map/blocktype.h42
-rw-r--r--src/enums/resources/map/collisiontype.h41
-rw-r--r--src/enums/resources/map/mapitemtype.h47
-rw-r--r--src/enums/resources/map/maplayerposition.h37
-rw-r--r--src/enums/resources/map/maplayertype.h39
-rw-r--r--src/enums/resources/map/maptype.h40
-rw-r--r--src/enums/resources/notifyflags.h39
-rw-r--r--src/enums/resources/notifytypes.h255
-rw-r--r--src/enums/resources/questtype.h37
-rw-r--r--src/enums/resources/servercommandenable.h37
-rw-r--r--src/enums/resources/servercommandtype.h44
-rw-r--r--src/enums/resources/serverpermissiontype.h41
-rw-r--r--src/enums/resources/skill/casttype.h35
-rw-r--r--src/enums/resources/skill/skillowner.h35
-rw-r--r--src/enums/resources/skill/skillsettype.h33
-rw-r--r--src/enums/resources/skill/skilltype.h39
-rw-r--r--src/enums/resources/skill/skilltype2.h51
-rw-r--r--src/enums/resources/spritedirection.h43
-rw-r--r--src/enums/screendensity.h35
-rw-r--r--src/enums/simpletypes/advanced.h33
-rw-r--r--src/enums/simpletypes/allowquit.h33
-rw-r--r--src/enums/simpletypes/allowsort.h33
-rw-r--r--src/enums/simpletypes/allplayers.h33
-rw-r--r--src/enums/simpletypes/append.h33
-rw-r--r--src/enums/simpletypes/autorelease.h33
-rw-r--r--src/enums/simpletypes/autotarget.h33
-rw-r--r--src/enums/simpletypes/beingid.h34
-rw-r--r--src/enums/simpletypes/beingtypeid.h34
-rw-r--r--src/enums/simpletypes/booldefines.h53
-rw-r--r--src/enums/simpletypes/damaged.h33
-rw-r--r--src/enums/simpletypes/donotalign.h33
-rw-r--r--src/enums/simpletypes/enable.h33
-rw-r--r--src/enums/simpletypes/enumdefines.h62
-rw-r--r--src/enums/simpletypes/equipm.h33
-rw-r--r--src/enums/simpletypes/equipped.h33
-rw-r--r--src/enums/simpletypes/favorite.h33
-rw-r--r--src/enums/simpletypes/forcedisplay.h33
-rw-r--r--src/enums/simpletypes/forcequantity.h33
-rw-r--r--src/enums/simpletypes/identified.h33
-rw-r--r--src/enums/simpletypes/ignorerecord.h33
-rw-r--r--src/enums/simpletypes/intdefines.h51
-rw-r--r--src/enums/simpletypes/issell.h33
-rw-r--r--src/enums/simpletypes/isstart.h33
-rw-r--r--src/enums/simpletypes/itemcolor.h33
-rw-r--r--src/enums/simpletypes/keep.h33
-rw-r--r--src/enums/simpletypes/losefocusontab.h33
-rw-r--r--src/enums/simpletypes/mainconfig.h33
-rw-r--r--src/enums/simpletypes/modal.h33
-rw-r--r--src/enums/simpletypes/modifiable.h33
-rw-r--r--src/enums/simpletypes/move.h33
-rw-r--r--src/enums/simpletypes/notify.h33
-rw-r--r--src/enums/simpletypes/npcnames.h33
-rw-r--r--src/enums/simpletypes/online.h33
-rw-r--r--src/enums/simpletypes/onthefly.h33
-rw-r--r--src/enums/simpletypes/opaque.h33
-rw-r--r--src/enums/simpletypes/protected.h33
-rw-r--r--src/enums/simpletypes/separator.h33
-rw-r--r--src/enums/simpletypes/sfx.h33
-rw-r--r--src/enums/simpletypes/showcenter.h33
-rw-r--r--src/enums/simpletypes/showemptyrows.h33
-rw-r--r--src/enums/simpletypes/skiperror.h33
-rw-r--r--src/enums/simpletypes/speech.h33
-rw-r--r--src/enums/simpletypes/stringdefines.h51
-rw-r--r--src/enums/simpletypes/stringdefines2.h31
-rw-r--r--src/enums/simpletypes/trading.h33
-rw-r--r--src/enums/simpletypes/tryremovecolors.h33
-rw-r--r--src/enums/simpletypes/useargs.h33
-rw-r--r--src/enums/simpletypes/usebase64.h33
-rw-r--r--src/enums/simpletypes/usevirtfs.h33
-rw-r--r--src/enums/simpletypes/visible.h33
-rw-r--r--src/enums/state.h72
-rw-r--r--src/enums/textcommandtype.h33
-rw-r--r--src/equipment.h95
-rw-r--r--src/events/actionevent.h137
-rw-r--r--src/events/event.h113
-rw-r--r--src/events/inputevent.h75
-rw-r--r--src/events/inputguievent.h118
-rw-r--r--src/events/keyevent.h159
-rw-r--r--src/events/mouseevent.h199
-rw-r--r--src/events/selectionevent.h99
-rw-r--r--src/eventsmanager.cpp683
-rw-r--r--src/eventsmanager.h71
-rw-r--r--src/filefilter.txt21
-rw-r--r--src/filefilter_more.txt12
-rw-r--r--src/fs/files.cpp319
-rw-r--r--src/fs/files.h69
-rw-r--r--src/fs/mkdir.cpp166
-rw-r--r--src/fs/mkdir.h27
-rw-r--r--src/fs/paths.cpp279
-rw-r--r--src/fs/paths.h54
-rw-r--r--src/fs/specialfolder.cpp59
-rw-r--r--src/fs/specialfolder.h33
-rw-r--r--src/fs/virtfs/direntry.cpp45
-rw-r--r--src/fs/virtfs/direntry.h49
-rw-r--r--src/fs/virtfs/file.cpp56
-rw-r--r--src/fs/virtfs/file.h61
-rw-r--r--src/fs/virtfs/fileapi.h48
-rw-r--r--src/fs/virtfs/fs.cpp880
-rw-r--r--src/fs/virtfs/fs.h127
-rw-r--r--src/fs/virtfs/fsdir.cpp686
-rw-r--r--src/fs/virtfs/fsdir.h104
-rw-r--r--src/fs/virtfs/fsdirrwops.cpp269
-rw-r--r--src/fs/virtfs/fsdirrwops.h55
-rw-r--r--src/fs/virtfs/fsentry.cpp41
-rw-r--r--src/fs/virtfs/fsentry.h55
-rw-r--r--src/fs/virtfs/fsfuncs.h136
-rw-r--r--src/fs/virtfs/fszip.cpp705
-rw-r--r--src/fs/virtfs/fszip.h93
-rw-r--r--src/fs/virtfs/fsziprwops.cpp160
-rw-r--r--src/fs/virtfs/fsziprwops.h55
-rw-r--r--src/fs/virtfs/list.cpp37
-rw-r--r--src/fs/virtfs/list.h44
-rw-r--r--src/fs/virtfs/rwops.cpp149
-rw-r--r--src/fs/virtfs/rwops.h66
-rw-r--r--src/fs/virtfs/rwopstypes.h34
-rw-r--r--src/fs/virtfs/tools.cpp157
-rw-r--r--src/fs/virtfs/tools.h46
-rw-r--r--src/fs/virtfs/zipentry.cpp48
-rw-r--r--src/fs/virtfs/zipentry.h51
-rw-r--r--src/fs/virtfs/ziplocalheader.cpp40
-rw-r--r--src/fs/virtfs/ziplocalheader.h49
-rw-r--r--src/fs/virtfs/zipreader.cpp334
-rw-r--r--src/fs/virtfs/zipreader.h46
-rw-r--r--src/game.cpp1260
-rw-r--r--src/game.h159
-rw-r--r--src/gamemodifiers.cpp517
-rw-r--r--src/gamemodifiers.h79
-rw-r--r--src/graphicsmanager.cpp1724
-rw-r--r--src/graphicsmanager.h229
-rw-r--r--src/gui/browserlink.h53
-rw-r--r--src/gui/buttoninfo.h49
-rw-r--r--src/gui/buttontext.h45
-rw-r--r--src/gui/chatlog.h48
-rw-r--r--src/gui/cliprect.h129
-rw-r--r--src/gui/color.h253
-rw-r--r--src/gui/colorpair.h43
-rw-r--r--src/gui/dialogsmanager.cpp222
-rw-r--r--src/gui/dialogsmanager.h65
-rw-r--r--src/gui/focushandler.cpp621
-rw-r--r--src/gui/focushandler.h410
-rw-r--r--src/gui/fonts/font.cpp499
-rw-r--r--src/gui/fonts/font.h158
-rw-r--r--src/gui/fonts/textchunk.cpp203
-rw-r--r--src/gui/fonts/textchunk.h75
-rw-r--r--src/gui/fonts/textchunklist.cpp153
-rw-r--r--src/gui/fonts/textchunklist.h60
-rw-r--r--src/gui/fonts/textchunksmall.cpp83
-rw-r--r--src/gui/fonts/textchunksmall.h49
-rw-r--r--src/gui/gui.cpp1515
-rw-r--r--src/gui/gui.h527
-rw-r--r--src/gui/mailmessage.h59
-rw-r--r--src/gui/models/avatarlistmodel.h44
-rw-r--r--src/gui/models/beingslistmodel.h66
-rw-r--r--src/gui/models/colorlistmodel.h87
-rw-r--r--src/gui/models/colormodel.cpp97
-rw-r--r--src/gui/models/colormodel.h69
-rw-r--r--src/gui/models/extendedlistmodel.h40
-rw-r--r--src/gui/models/extendednamesmodel.cpp68
-rw-r--r--src/gui/models/extendednamesmodel.h62
-rw-r--r--src/gui/models/fontsizechoicelistmodel.h92
-rw-r--r--src/gui/models/fontsmodel.h44
-rw-r--r--src/gui/models/iconsmodel.h88
-rw-r--r--src/gui/models/ignorechoiceslistmodel.h64
-rw-r--r--src/gui/models/itemsmodel.h88
-rw-r--r--src/gui/models/keylistmodel.h88
-rw-r--r--src/gui/models/langlistmodel.h145
-rw-r--r--src/gui/models/listmodel.h108
-rw-r--r--src/gui/models/magicschoolmodel.h73
-rw-r--r--src/gui/models/modelistmodel.cpp101
-rw-r--r--src/gui/models/modelistmodel.h70
-rw-r--r--src/gui/models/namesmodel.cpp68
-rw-r--r--src/gui/models/namesmodel.h64
-rw-r--r--src/gui/models/opengllistmodel.h53
-rw-r--r--src/gui/models/playerrelationlistmodel.h75
-rw-r--r--src/gui/models/playertablemodel.cpp148
-rw-r--r--src/gui/models/playertablemodel.h68
-rw-r--r--src/gui/models/questsmodel.h40
-rw-r--r--src/gui/models/serverslistmodel.h119
-rw-r--r--src/gui/models/shopitems.cpp206
-rw-r--r--src/gui/models/shopitems.h170
-rw-r--r--src/gui/models/skillmodel.cpp62
-rw-r--r--src/gui/models/skillmodel.h58
-rw-r--r--src/gui/models/sortlistmodelbuy.h71
-rw-r--r--src/gui/models/sortlistmodelinv.h69
-rw-r--r--src/gui/models/soundsmodel.h49
-rw-r--r--src/gui/models/tablemodel.cpp182
-rw-r--r--src/gui/models/tablemodel.h153
-rw-r--r--src/gui/models/targettypemodel.h64
-rw-r--r--src/gui/models/themesmodel.h49
-rw-r--r--src/gui/models/touchactionmodel.cpp91
-rw-r--r--src/gui/models/touchactionmodel.h49
-rw-r--r--src/gui/models/typelistmodel.h74
-rw-r--r--src/gui/models/updatelistmodel.h79
-rw-r--r--src/gui/models/updatetypemodel.h63
-rw-r--r--src/gui/models/worldlistmodel.h68
-rw-r--r--src/gui/mouseoverlink.h51
-rw-r--r--src/gui/onlineplayer.h90
-rw-r--r--src/gui/palette.cpp199
-rw-r--r--src/gui/palette.h158
-rw-r--r--src/gui/popupmanager.cpp113
-rw-r--r--src/gui/popupmanager.h71
-rw-r--r--src/gui/popups/beingpopup.cpp337
-rw-r--r--src/gui/popups/beingpopup.h68
-rw-r--r--src/gui/popups/itempopup.cpp465
-rw-r--r--src/gui/popups/itempopup.h103
-rw-r--r--src/gui/popups/popupmenu.cpp3613
-rw-r--r--src/gui/popups/popupmenu.h321
-rw-r--r--src/gui/popups/skillpopup.cpp250
-rw-r--r--src/gui/popups/skillpopup.h84
-rw-r--r--src/gui/popups/speechbubble.cpp98
-rw-r--r--src/gui/popups/speechbubble.h67
-rw-r--r--src/gui/popups/spellpopup.cpp123
-rw-r--r--src/gui/popups/spellpopup.h71
-rw-r--r--src/gui/popups/statuspopup.cpp171
-rw-r--r--src/gui/popups/statuspopup.h72
-rw-r--r--src/gui/popups/textboxpopup.cpp83
-rw-r--r--src/gui/popups/textboxpopup.h64
-rw-r--r--src/gui/popups/textpopup.cpp112
-rw-r--r--src/gui/popups/textpopup.h83
-rw-r--r--src/gui/rect.h226
-rw-r--r--src/gui/sdlinput.cpp405
-rw-r--r--src/gui/sdlinput.h391
-rw-r--r--src/gui/setupactiondata.h52
-rw-r--r--src/gui/setupinputpages.cpp80
-rw-r--r--src/gui/setupinputpages.h32
-rw-r--r--src/gui/shortcut/dropshortcut.cpp171
-rw-r--r--src/gui/shortcut/dropshortcut.h69
-rw-r--r--src/gui/shortcut/emoteshortcut.cpp115
-rw-r--r--src/gui/shortcut/emoteshortcut.h133
-rw-r--r--src/gui/shortcut/itemshortcut.cpp289
-rw-r--r--src/gui/shortcut/itemshortcut.h183
-rw-r--r--src/gui/shortcut/shortcutbase.cpp128
-rw-r--r--src/gui/shortcut/shortcutbase.h141
-rw-r--r--src/gui/shortcut/spellshortcut.cpp63
-rw-r--r--src/gui/shortcut/spellshortcut.h88
-rw-r--r--src/gui/skin.cpp152
-rw-r--r--src/gui/skin.h135
-rw-r--r--src/gui/theme.cpp1283
-rw-r--r--src/gui/theme.h207
-rw-r--r--src/gui/themecolorsidoperators.cpp30
-rw-r--r--src/gui/themecolorsidoperators.h28
-rw-r--r--src/gui/themeinfo.h64
-rw-r--r--src/gui/touchactiondata.cpp38
-rw-r--r--src/gui/touchactiondata.h28
-rw-r--r--src/gui/userpalette.cpp649
-rw-r--r--src/gui/userpalette.h250
-rw-r--r--src/gui/viewport.h32
-rw-r--r--src/gui/widgets/attrs/attrdisplay.cpp67
-rw-r--r--src/gui/widgets/attrs/attrdisplay.h82
-rw-r--r--src/gui/widgets/attrs/changedisplay.cpp119
-rw-r--r--src/gui/widgets/attrs/changedisplay.h61
-rw-r--r--src/gui/widgets/attrs/derdisplay.cpp40
-rw-r--r--src/gui/widgets/attrs/derdisplay.h44
-rw-r--r--src/gui/widgets/avatarlistbox.cpp740
-rw-r--r--src/gui/widgets/avatarlistbox.h64
-rw-r--r--src/gui/widgets/basiccontainer.cpp439
-rw-r--r--src/gui/widgets/basiccontainer.h213
-rw-r--r--src/gui/widgets/basiccontainer2.cpp128
-rw-r--r--src/gui/widgets/basiccontainer2.h153
-rw-r--r--src/gui/widgets/browserbox.cpp936
-rw-r--r--src/gui/widgets/browserbox.h210
-rw-r--r--src/gui/widgets/browserbox.inc30
-rw-r--r--src/gui/widgets/button.cpp934
-rw-r--r--src/gui/widgets/button.h347
-rw-r--r--src/gui/widgets/characterdisplay.cpp160
-rw-r--r--src/gui/widgets/characterdisplay.h93
-rw-r--r--src/gui/widgets/characterviewbase.h63
-rw-r--r--src/gui/widgets/characterviewnormal.cpp121
-rw-r--r--src/gui/widgets/characterviewnormal.h50
-rw-r--r--src/gui/widgets/characterviewsmall.cpp136
-rw-r--r--src/gui/widgets/characterviewsmall.h54
-rw-r--r--src/gui/widgets/chatinput.h105
-rw-r--r--src/gui/widgets/checkbox.cpp338
-rw-r--r--src/gui/widgets/checkbox.h216
-rw-r--r--src/gui/widgets/colorpage.cpp124
-rw-r--r--src/gui/widgets/colorpage.h48
-rw-r--r--src/gui/widgets/container.cpp60
-rw-r--r--src/gui/widgets/container.h51
-rw-r--r--src/gui/widgets/containerplacer.cpp44
-rw-r--r--src/gui/widgets/containerplacer.h73
-rw-r--r--src/gui/widgets/createwidget.h41
-rw-r--r--src/gui/widgets/desktop.cpp229
-rw-r--r--src/gui/widgets/desktop.h88
-rw-r--r--src/gui/widgets/dropdown.cpp580
-rw-r--r--src/gui/widgets/dropdown.h166
-rw-r--r--src/gui/widgets/emotepage.cpp167
-rw-r--r--src/gui/widgets/emotepage.h67
-rw-r--r--src/gui/widgets/emoteshortcutcontainer.cpp297
-rw-r--r--src/gui/widgets/emoteshortcutcontainer.h92
-rw-r--r--src/gui/widgets/equipmentbox.h41
-rw-r--r--src/gui/widgets/equipmentpage.h53
-rw-r--r--src/gui/widgets/extendedlistbox.cpp257
-rw-r--r--src/gui/widgets/extendedlistbox.h61
-rw-r--r--src/gui/widgets/extendedlistboxitem.h49
-rw-r--r--src/gui/widgets/flowcontainer.cpp97
-rw-r--r--src/gui/widgets/flowcontainer.h75
-rw-r--r--src/gui/widgets/guitable.cpp675
-rw-r--r--src/gui/widgets/guitable.h207
-rw-r--r--src/gui/widgets/horizontcontainer.cpp66
-rw-r--r--src/gui/widgets/horizontcontainer.h62
-rw-r--r--src/gui/widgets/icon.cpp105
-rw-r--r--src/gui/widgets/icon.h83
-rw-r--r--src/gui/widgets/inttextfield.cpp148
-rw-r--r--src/gui/widgets/inttextfield.h85
-rw-r--r--src/gui/widgets/itemcontainer.cpp1322
-rw-r--r--src/gui/widgets/itemcontainer.h223
-rw-r--r--src/gui/widgets/itemlinkhandler.cpp223
-rw-r--r--src/gui/widgets/itemlinkhandler.h61
-rw-r--r--src/gui/widgets/itemshortcutcontainer.cpp650
-rw-r--r--src/gui/widgets/itemshortcutcontainer.h89
-rw-r--r--src/gui/widgets/label.cpp292
-rw-r--r--src/gui/widgets/label.h195
-rw-r--r--src/gui/widgets/layout.cpp46
-rw-r--r--src/gui/widgets/layout.h66
-rw-r--r--src/gui/widgets/layoutarray.cpp313
-rw-r--r--src/gui/widgets/layoutarray.h127
-rw-r--r--src/gui/widgets/layoutcell.cpp136
-rw-r--r--src/gui/widgets/layoutcell.h196
-rw-r--r--src/gui/widgets/layouthelper.cpp79
-rw-r--r--src/gui/widgets/layouthelper.h91
-rw-r--r--src/gui/widgets/linepart.cpp33
-rw-r--r--src/gui/widgets/linepart.h102
-rw-r--r--src/gui/widgets/linkhandler.h49
-rw-r--r--src/gui/widgets/listbox.cpp446
-rw-r--r--src/gui/widgets/listbox.h296
-rw-r--r--src/gui/widgets/passwordfield.cpp55
-rw-r--r--src/gui/widgets/passwordfield.h55
-rw-r--r--src/gui/widgets/playerbox.cpp190
-rw-r--r--src/gui/widgets/playerbox.h112
-rw-r--r--src/gui/widgets/popup.cpp273
-rw-r--r--src/gui/widgets/popup.h193
-rw-r--r--src/gui/widgets/popuplist.cpp188
-rw-r--r--src/gui/widgets/popuplist.h84
-rw-r--r--src/gui/widgets/progressbar.cpp376
-rw-r--r--src/gui/widgets/progressbar.h166
-rw-r--r--src/gui/widgets/progressindicator.cpp98
-rw-r--r--src/gui/widgets/progressindicator.h54
-rw-r--r--src/gui/widgets/radiobutton.cpp373
-rw-r--r--src/gui/widgets/radiobutton.h247
-rw-r--r--src/gui/widgets/radiogroup.cpp41
-rw-r--r--src/gui/widgets/radiogroup.h41
-rw-r--r--src/gui/widgets/scrollarea.cpp1460
-rw-r--r--src/gui/widgets/scrollarea.h598
-rw-r--r--src/gui/widgets/selldialog.cpp397
-rw-r--r--src/gui/widgets/selldialog.h156
-rw-r--r--src/gui/widgets/serverslistbox.h159
-rw-r--r--src/gui/widgets/setupbuttonitem.cpp95
-rw-r--r--src/gui/widgets/setupbuttonitem.h69
-rw-r--r--src/gui/widgets/setupitem.cpp1338
-rw-r--r--src/gui/widgets/setupitem.h613
-rw-r--r--src/gui/widgets/setupquickitem.cpp117
-rw-r--r--src/gui/widgets/setupquickitem.h80
-rw-r--r--src/gui/widgets/setuptouchitem.cpp132
-rw-r--r--src/gui/widgets/setuptouchitem.h67
-rw-r--r--src/gui/widgets/shoplistbox.cpp310
-rw-r--r--src/gui/widgets/shoplistbox.h113
-rw-r--r--src/gui/widgets/shortcutcontainer.cpp159
-rw-r--r--src/gui/widgets/shortcutcontainer.h120
-rw-r--r--src/gui/widgets/skilllistbox.h290
-rw-r--r--src/gui/widgets/skillrectanglelistbox.h418
-rw-r--r--src/gui/widgets/slider.cpp517
-rw-r--r--src/gui/widgets/slider.h337
-rw-r--r--src/gui/widgets/sliderlist.cpp240
-rw-r--r--src/gui/widgets/sliderlist.h89
-rw-r--r--src/gui/widgets/spellshortcutcontainer.cpp371
-rw-r--r--src/gui/widgets/spellshortcutcontainer.h86
-rw-r--r--src/gui/widgets/staticbrowserbox.cpp781
-rw-r--r--src/gui/widgets/staticbrowserbox.h194
-rw-r--r--src/gui/widgets/statspage.cpp88
-rw-r--r--src/gui/widgets/statspage.h61
-rw-r--r--src/gui/widgets/statspagebasic.cpp163
-rw-r--r--src/gui/widgets/statspagebasic.h67
-rw-r--r--src/gui/widgets/tabbedarea.cpp827
-rw-r--r--src/gui/widgets/tabbedarea.h299
-rw-r--r--src/gui/widgets/tabs/chat/battletab.cpp44
-rw-r--r--src/gui/widgets/tabs/chat/battletab.h43
-rw-r--r--src/gui/widgets/tabs/chat/channeltab.cpp77
-rw-r--r--src/gui/widgets/tabs/chat/channeltab.h51
-rw-r--r--src/gui/widgets/tabs/chat/chattab.cpp563
-rw-r--r--src/gui/widgets/tabs/chat/chattab.h216
-rw-r--r--src/gui/widgets/tabs/chat/emulateguildtab.cpp108
-rw-r--r--src/gui/widgets/tabs/chat/emulateguildtab.h59
-rw-r--r--src/gui/widgets/tabs/chat/gmtab.cpp57
-rw-r--r--src/gui/widgets/tabs/chat/gmtab.h49
-rw-r--r--src/gui/widgets/tabs/chat/guildtab.cpp125
-rw-r--r--src/gui/widgets/tabs/chat/guildtab.h56
-rw-r--r--src/gui/widgets/tabs/chat/langtab.cpp38
-rw-r--r--src/gui/widgets/tabs/chat/langtab.h39
-rw-r--r--src/gui/widgets/tabs/chat/partytab.cpp151
-rw-r--r--src/gui/widgets/tabs/chat/partytab.h58
-rw-r--r--src/gui/widgets/tabs/chat/tradetab.cpp50
-rw-r--r--src/gui/widgets/tabs/chat/tradetab.h46
-rw-r--r--src/gui/widgets/tabs/chat/whispertab.cpp130
-rw-r--r--src/gui/widgets/tabs/chat/whispertab.h73
-rw-r--r--src/gui/widgets/tabs/debugwindowtabs.cpp492
-rw-r--r--src/gui/widgets/tabs/debugwindowtabs.h129
-rw-r--r--src/gui/widgets/tabs/setup_audio.cpp214
-rw-r--r--src/gui/widgets/tabs/setup_audio.h47
-rw-r--r--src/gui/widgets/tabs/setup_chat.cpp347
-rw-r--r--src/gui/widgets/tabs/setup_chat.h40
-rw-r--r--src/gui/widgets/tabs/setup_colors.cpp491
-rw-r--r--src/gui/widgets/tabs/setup_colors.h91
-rw-r--r--src/gui/widgets/tabs/setup_input.cpp399
-rw-r--r--src/gui/widgets/tabs/setup_input.h105
-rw-r--r--src/gui/widgets/tabs/setup_joystick.cpp184
-rw-r--r--src/gui/widgets/tabs/setup_joystick.h62
-rw-r--r--src/gui/widgets/tabs/setup_misc.cpp518
-rw-r--r--src/gui/widgets/tabs/setup_misc.h52
-rw-r--r--src/gui/widgets/tabs/setup_mods.cpp129
-rw-r--r--src/gui/widgets/tabs/setup_mods.h50
-rw-r--r--src/gui/widgets/tabs/setup_perfomance.cpp209
-rw-r--r--src/gui/widgets/tabs/setup_perfomance.h46
-rw-r--r--src/gui/widgets/tabs/setup_players.cpp211
-rw-r--r--src/gui/widgets/tabs/setup_players.h49
-rw-r--r--src/gui/widgets/tabs/setup_quick.cpp118
-rw-r--r--src/gui/widgets/tabs/setup_quick.h45
-rw-r--r--src/gui/widgets/tabs/setup_relations.cpp266
-rw-r--r--src/gui/widgets/tabs/setup_relations.h79
-rw-r--r--src/gui/widgets/tabs/setup_theme.cpp415
-rw-r--r--src/gui/widgets/tabs/setup_theme.h113
-rw-r--r--src/gui/widgets/tabs/setup_touch.cpp134
-rw-r--r--src/gui/widgets/tabs/setup_touch.h44
-rw-r--r--src/gui/widgets/tabs/setup_video.cpp534
-rw-r--r--src/gui/widgets/tabs/setup_video.h88
-rw-r--r--src/gui/widgets/tabs/setup_visual.cpp252
-rw-r--r--src/gui/widgets/tabs/setup_visual.h51
-rw-r--r--src/gui/widgets/tabs/setuptab.cpp44
-rw-r--r--src/gui/widgets/tabs/setuptab.h74
-rw-r--r--src/gui/widgets/tabs/setuptabscroll.cpp163
-rw-r--r--src/gui/widgets/tabs/setuptabscroll.h81
-rw-r--r--src/gui/widgets/tabs/shortcuttab.h47
-rw-r--r--src/gui/widgets/tabs/skilltab.h88
-rw-r--r--src/gui/widgets/tabs/socialattacktab.h77
-rw-r--r--src/gui/widgets/tabs/socialfriendsfunctor.h59
-rw-r--r--src/gui/widgets/tabs/socialfriendstab.h127
-rw-r--r--src/gui/widgets/tabs/socialguildtab.h179
-rw-r--r--src/gui/widgets/tabs/socialguildtab2.h106
-rw-r--r--src/gui/widgets/tabs/socialnavigationtab.h308
-rw-r--r--src/gui/widgets/tabs/socialpartytab.h171
-rw-r--r--src/gui/widgets/tabs/socialpickuptab.h75
-rw-r--r--src/gui/widgets/tabs/socialplayerstab.h198
-rw-r--r--src/gui/widgets/tabs/socialtab.h143
-rw-r--r--src/gui/widgets/tabs/socialtabbase.h84
-rw-r--r--src/gui/widgets/tabs/tab.cpp488
-rw-r--r--src/gui/widgets/tabs/tab.h245
-rw-r--r--src/gui/widgets/tabstrip.cpp124
-rw-r--r--src/gui/widgets/tabstrip.h57
-rw-r--r--src/gui/widgets/textbox.cpp647
-rw-r--r--src/gui/widgets/textbox.h329
-rw-r--r--src/gui/widgets/textfield.cpp837
-rw-r--r--src/gui/widgets/textfield.h293
-rw-r--r--src/gui/widgets/textpreview.cpp151
-rw-r--r--src/gui/widgets/textpreview.h144
-rw-r--r--src/gui/widgets/vertcontainer.cpp89
-rw-r--r--src/gui/widgets/vertcontainer.h66
-rw-r--r--src/gui/widgets/virtshortcutcontainer.cpp383
-rw-r--r--src/gui/widgets/virtshortcutcontainer.h92
-rw-r--r--src/gui/widgets/widget.cpp526
-rw-r--r--src/gui/widgets/widget.h1181
-rw-r--r--src/gui/widgets/widget2.h117
-rw-r--r--src/gui/widgets/widgetgroup.cpp87
-rw-r--r--src/gui/widgets/widgetgroup.h69
-rw-r--r--src/gui/widgets/window.cpp1499
-rw-r--r--src/gui/widgets/window.h725
-rw-r--r--src/gui/widgets/windowcontainer.cpp105
-rw-r--r--src/gui/widgets/windowcontainer.h74
-rw-r--r--src/gui/windowmanager.cpp498
-rw-r--r--src/gui/windowmanager.h87
-rw-r--r--src/gui/windowmenu.cpp493
-rw-r--r--src/gui/windowmenu.h118
-rw-r--r--src/gui/windows/bankwindow.cpp102
-rw-r--r--src/gui/windows/bankwindow.h64
-rw-r--r--src/gui/windows/buydialog.cpp794
-rw-r--r--src/gui/windows/buydialog.h207
-rw-r--r--src/gui/windows/buyingstoreselldialog.cpp70
-rw-r--r--src/gui/windows/buyingstoreselldialog.h55
-rw-r--r--src/gui/windows/buyselldialog.cpp167
-rw-r--r--src/gui/windows/buyselldialog.h86
-rw-r--r--src/gui/windows/changeemaildialog.cpp186
-rw-r--r--src/gui/windows/changeemaildialog.h81
-rw-r--r--src/gui/windows/changepassworddialog.cpp177
-rw-r--r--src/gui/windows/changepassworddialog.h76
-rw-r--r--src/gui/windows/charcreatedialog.cpp885
-rw-r--r--src/gui/windows/charcreatedialog.h171
-rw-r--r--src/gui/windows/chardeleteconfirm.h65
-rw-r--r--src/gui/windows/charselectdialog.cpp644
-rw-r--r--src/gui/windows/charselectdialog.h136
-rw-r--r--src/gui/windows/chatwindow.cpp2181
-rw-r--r--src/gui/windows/chatwindow.h406
-rw-r--r--src/gui/windows/confirmdialog.cpp120
-rw-r--r--src/gui/windows/confirmdialog.h71
-rw-r--r--src/gui/windows/connectiondialog.cpp90
-rw-r--r--src/gui/windows/connectiondialog.h69
-rw-r--r--src/gui/windows/cutinwindow.cpp153
-rw-r--r--src/gui/windows/cutinwindow.h61
-rw-r--r--src/gui/windows/debugwindow.cpp173
-rw-r--r--src/gui/windows/debugwindow.h78
-rw-r--r--src/gui/windows/didyouknowwindow.cpp188
-rw-r--r--src/gui/windows/didyouknowwindow.h76
-rw-r--r--src/gui/windows/editdialog.cpp80
-rw-r--r--src/gui/windows/editdialog.h72
-rw-r--r--src/gui/windows/editserverdialog.cpp297
-rw-r--r--src/gui/windows/editserverdialog.h86
-rw-r--r--src/gui/windows/eggselectiondialog.cpp67
-rw-r--r--src/gui/windows/eggselectiondialog.h45
-rw-r--r--src/gui/windows/emotewindow.cpp278
-rw-r--r--src/gui/windows/emotewindow.h89
-rw-r--r--src/gui/windows/equipmentwindow.cpp848
-rw-r--r--src/gui/windows/equipmentwindow.h167
-rw-r--r--src/gui/windows/helpwindow.cpp220
-rw-r--r--src/gui/windows/helpwindow.h92
-rw-r--r--src/gui/windows/insertcarddialog.cpp79
-rw-r--r--src/gui/windows/insertcarddialog.h49
-rw-r--r--src/gui/windows/inventorywindow.cpp1083
-rw-r--r--src/gui/windows/inventorywindow.h210
-rw-r--r--src/gui/windows/itemamountwindow.cpp504
-rw-r--r--src/gui/windows/itemamountwindow.h123
-rw-r--r--src/gui/windows/killstats.cpp479
-rw-r--r--src/gui/windows/killstats.h116
-rw-r--r--src/gui/windows/logindialog.cpp402
-rw-r--r--src/gui/windows/logindialog.h113
-rw-r--r--src/gui/windows/maileditwindow.cpp278
-rw-r--r--src/gui/windows/maileditwindow.h92
-rw-r--r--src/gui/windows/mailviewwindow.cpp269
-rw-r--r--src/gui/windows/mailviewwindow.h80
-rw-r--r--src/gui/windows/mailwindow.cpp393
-rw-r--r--src/gui/windows/mailwindow.h108
-rw-r--r--src/gui/windows/minimap.cpp540
-rw-r--r--src/gui/windows/minimap.h95
-rw-r--r--src/gui/windows/ministatuswindow.cpp594
-rw-r--r--src/gui/windows/ministatuswindow.h151
-rw-r--r--src/gui/windows/npcdialog.cpp1395
-rw-r--r--src/gui/windows/npcdialog.h324
-rw-r--r--src/gui/windows/npcselldialog.cpp154
-rw-r--r--src/gui/windows/npcselldialog.h59
-rw-r--r--src/gui/windows/okdialog.cpp94
-rw-r--r--src/gui/windows/okdialog.h72
-rw-r--r--src/gui/windows/outfitwindow.cpp749
-rw-r--r--src/gui/windows/outfitwindow.h133
-rw-r--r--src/gui/windows/questswindow.cpp483
-rw-r--r--src/gui/windows/questswindow.h105
-rw-r--r--src/gui/windows/quitdialog.cpp260
-rw-r--r--src/gui/windows/quitdialog.h84
-rw-r--r--src/gui/windows/registerdialog.cpp317
-rw-r--r--src/gui/windows/registerdialog.h95
-rw-r--r--src/gui/windows/serverdialog.cpp902
-rw-r--r--src/gui/windows/serverdialog.h150
-rw-r--r--src/gui/windows/serverinfowindow.cpp184
-rw-r--r--src/gui/windows/serverinfowindow.h68
-rw-r--r--src/gui/windows/setupwindow.cpp335
-rw-r--r--src/gui/windows/setupwindow.h96
-rw-r--r--src/gui/windows/shopselldialog.cpp60
-rw-r--r--src/gui/windows/shopselldialog.h54
-rw-r--r--src/gui/windows/shopwindow.cpp1175
-rw-r--r--src/gui/windows/shopwindow.h207
-rw-r--r--src/gui/windows/shortcutwindow.cpp269
-rw-r--r--src/gui/windows/shortcutwindow.h100
-rw-r--r--src/gui/windows/skilldialog.cpp1432
-rw-r--r--src/gui/windows/skilldialog.h237
-rw-r--r--src/gui/windows/socialwindow.cpp659
-rw-r--r--src/gui/windows/socialwindow.h171
-rw-r--r--src/gui/windows/statuswindow.cpp652
-rw-r--r--src/gui/windows/statuswindow.h119
-rw-r--r--src/gui/windows/textcommandeditor.cpp344
-rw-r--r--src/gui/windows/textcommandeditor.h116
-rw-r--r--src/gui/windows/textdialog.cpp135
-rw-r--r--src/gui/windows/textdialog.h85
-rw-r--r--src/gui/windows/textselectdialog.cpp192
-rw-r--r--src/gui/windows/textselectdialog.h104
-rw-r--r--src/gui/windows/tradewindow.cpp553
-rw-r--r--src/gui/windows/tradewindow.h214
-rw-r--r--src/gui/windows/updaterwindow.cpp1217
-rw-r--r--src/gui/windows/updaterwindow.h252
-rw-r--r--src/gui/windows/whoisonline.cpp909
-rw-r--r--src/gui/windows/whoisonline.h182
-rw-r--r--src/gui/windows/worldselectdialog.cpp134
-rw-r--r--src/gui/windows/worldselectdialog.h77
-rw-r--r--src/guild.cpp389
-rw-r--r--src/guild.h224
-rw-r--r--src/input/inputactiondata.h52
-rw-r--r--src/input/inputactionmap.h5963
-rw-r--r--src/input/inputactionoperators.cpp42
-rw-r--r--src/input/inputactionoperators.h30
-rw-r--r--src/input/inputactionsortfunctor.h46
-rw-r--r--src/input/inputfunction.h37
-rw-r--r--src/input/inputitem.h47
-rw-r--r--src/input/inputmanager.cpp1096
-rw-r--r--src/input/inputmanager.h189
-rw-r--r--src/input/joystick.cpp446
-rw-r--r--src/input/joystick.h175
-rw-r--r--src/input/key.cpp111
-rw-r--r--src/input/key.h147
-rw-r--r--src/input/keyboardconfig.cpp307
-rw-r--r--src/input/keyboardconfig.h156
-rw-r--r--src/input/keyinput.h177
-rw-r--r--src/input/mouseinput.h219
-rw-r--r--src/input/pages/basic.cpp271
-rw-r--r--src/input/pages/basic.h31
-rw-r--r--src/input/pages/chat.cpp251
-rw-r--r--src/input/pages/chat.h28
-rw-r--r--src/input/pages/craft.cpp89
-rw-r--r--src/input/pages/craft.h28
-rw-r--r--src/input/pages/emotes.cpp655
-rw-r--r--src/input/pages/emotes.h31
-rw-r--r--src/input/pages/gui.cpp198
-rw-r--r--src/input/pages/gui.h28
-rw-r--r--src/input/pages/move.cpp404
-rw-r--r--src/input/pages/move.h31
-rw-r--r--src/input/pages/other.cpp465
-rw-r--r--src/input/pages/other.h31
-rw-r--r--src/input/pages/outfits.cpp374
-rw-r--r--src/input/pages/outfits.h31
-rw-r--r--src/input/pages/shortcuts.cpp176
-rw-r--r--src/input/pages/shortcuts.h31
-rw-r--r--src/input/pages/windows.cpp271
-rw-r--r--src/input/pages/windows.h31
-rw-r--r--src/input/touch/multitouchmanager.cpp88
-rw-r--r--src/input/touch/multitouchmanager.h72
-rw-r--r--src/input/touch/touchactions.cpp129
-rw-r--r--src/input/touch/touchactions.h39
-rw-r--r--src/input/touch/touchmanager.cpp709
-rw-r--r--src/input/touch/touchmanager.h204
-rw-r--r--src/itemcolormanager.cpp57
-rw-r--r--src/itemcolormanager.h42
-rw-r--r--src/itemsoundmanager.cpp68
-rw-r--r--src/itemsoundmanager.h50
-rw-r--r--src/listeners/actionlistener.h108
-rw-r--r--src/listeners/actorspritelistener.h51
-rw-r--r--src/listeners/arrowslistener.cpp38
-rw-r--r--src/listeners/arrowslistener.h40
-rw-r--r--src/listeners/assertlistener.cpp41
-rw-r--r--src/listeners/assertlistener.h47
-rw-r--r--src/listeners/attributelistener.cpp40
-rw-r--r--src/listeners/attributelistener.h46
-rw-r--r--src/listeners/awaylistener.cpp48
-rw-r--r--src/listeners/awaylistener.h39
-rw-r--r--src/listeners/banklistener.cpp38
-rw-r--r--src/listeners/banklistener.h40
-rw-r--r--src/listeners/baselistener.hpp70
-rw-r--r--src/listeners/buyingstoremodelistener.cpp38
-rw-r--r--src/listeners/buyingstoremodelistener.h40
-rw-r--r--src/listeners/buyingstoreslotslistener.cpp38
-rw-r--r--src/listeners/buyingstoreslotslistener.h40
-rw-r--r--src/listeners/charrenamelistener.cpp48
-rw-r--r--src/listeners/charrenamelistener.h54
-rw-r--r--src/listeners/configlistener.h57
-rw-r--r--src/listeners/debugmessagelistener.cpp38
-rw-r--r--src/listeners/debugmessagelistener.h42
-rw-r--r--src/listeners/errorlistener.cpp39
-rw-r--r--src/listeners/errorlistener.h44
-rw-r--r--src/listeners/focuslistener.h115
-rw-r--r--src/listeners/gamemodifierlistener.cpp38
-rw-r--r--src/listeners/gamemodifierlistener.h40
-rw-r--r--src/listeners/guiconfiglistener.h61
-rw-r--r--src/listeners/guitableactionlistener.cpp64
-rw-r--r--src/listeners/guitableactionlistener.h53
-rw-r--r--src/listeners/inputactionremotelistener.cpp50
-rw-r--r--src/listeners/inputactionremotelistener.h51
-rw-r--r--src/listeners/inputactionreplaylistener.cpp66
-rw-r--r--src/listeners/inputactionreplaylistener.h55
-rw-r--r--src/listeners/insertcardlistener.h54
-rw-r--r--src/listeners/inventorylistener.h45
-rw-r--r--src/listeners/keylistener.h118
-rw-r--r--src/listeners/mouselistener.h185
-rw-r--r--src/listeners/openurllistener.h52
-rw-r--r--src/listeners/pincodelistener.cpp40
-rw-r--r--src/listeners/pincodelistener.h42
-rw-r--r--src/listeners/playerdeathlistener.cpp38
-rw-r--r--src/listeners/playerdeathlistener.h40
-rw-r--r--src/listeners/playerlistener.cpp51
-rw-r--r--src/listeners/playerlistener.h56
-rw-r--r--src/listeners/playerpostdeathlistener.h65
-rw-r--r--src/listeners/playerrelationslistener.h47
-rw-r--r--src/listeners/renamelistener.cpp80
-rw-r--r--src/listeners/renamelistener.h51
-rw-r--r--src/listeners/requestadoptchildlistener.h46
-rw-r--r--src/listeners/requesttradelistener.h58
-rw-r--r--src/listeners/selectionlistener.h112
-rw-r--r--src/listeners/shoprenamelistener.cpp45
-rw-r--r--src/listeners/shoprenamelistener.h48
-rw-r--r--src/listeners/skillwarplistener.cpp48
-rw-r--r--src/listeners/skillwarplistener.h52
-rw-r--r--src/listeners/statlistener.cpp40
-rw-r--r--src/listeners/statlistener.h46
-rw-r--r--src/listeners/tablemodellistener.h54
-rw-r--r--src/listeners/textskilllistener.cpp63
-rw-r--r--src/listeners/textskilllistener.h55
-rw-r--r--src/listeners/tooltiplistener.cpp62
-rw-r--r--src/listeners/tooltiplistener.h51
-rw-r--r--src/listeners/updatestatuslistener.cpp38
-rw-r--r--src/listeners/updatestatuslistener.h40
-rw-r--r--src/listeners/uploadlistener.cpp32
-rw-r--r--src/listeners/uploadlistener.h44
-rw-r--r--src/listeners/vendingmodelistener.cpp38
-rw-r--r--src/listeners/vendingmodelistener.h40
-rw-r--r--src/listeners/vendingslotslistener.cpp38
-rw-r--r--src/listeners/vendingslotslistener.h40
-rw-r--r--src/listeners/weightlistener.h50
-rw-r--r--src/listeners/widgetdeathlistener.h105
-rw-r--r--src/listeners/widgetlistener.h135
-rw-r--r--src/listeners/wrongdatanoticelistener.cpp44
-rw-r--r--src/listeners/wrongdatanoticelistener.h49
-rw-r--r--src/localconsts.h393
-rw-r--r--src/logger.cpp493
-rw-r--r--src/logger.h225
-rw-r--r--src/main.cpp43
-rw-r--r--src/main.h180
-rw-r--r--src/maingui.cpp172
-rw-r--r--src/maingui.h30
-rw-r--r--src/manaplus.rc25
-rw-r--r--src/mumblemanager.cpp318
-rw-r--r--src/mumblemanager.h91
-rw-r--r--src/navigationmanager.cpp178
-rw-r--r--src/navigationmanager.h61
-rw-r--r--src/net/adminhandler.h192
-rw-r--r--src/net/auctionhandler.h76
-rw-r--r--src/net/bankhandler.h55
-rw-r--r--src/net/battlegroundhandler.h60
-rw-r--r--src/net/beinghandler.h58
-rw-r--r--src/net/buyingstorehandler.h67
-rw-r--r--src/net/buysellhandler.h66
-rw-r--r--src/net/cashshophandler.h67
-rw-r--r--src/net/character.h64
-rw-r--r--src/net/characters.h37
-rw-r--r--src/net/charserverhandler.cpp48
-rw-r--r--src/net/charserverhandler.h125
-rw-r--r--src/net/chathandler.h111
-rw-r--r--src/net/download.cpp643
-rw-r--r--src/net/download.h144
-rw-r--r--src/net/ea/adminhandler.cpp76
-rw-r--r--src/net/ea/adminhandler.h65
-rw-r--r--src/net/ea/adminrecv.cpp44
-rw-r--r--src/net/ea/adminrecv.h41
-rw-r--r--src/net/ea/beinghandler.cpp39
-rw-r--r--src/net/ea/beinghandler.h42
-rw-r--r--src/net/ea/beingrecv.cpp520
-rw-r--r--src/net/ea/beingrecv.h56
-rw-r--r--src/net/ea/buysellhandler.cpp44
-rw-r--r--src/net/ea/buysellhandler.h44
-rw-r--r--src/net/ea/buysellrecv.cpp92
-rw-r--r--src/net/ea/buysellrecv.h47
-rw-r--r--src/net/ea/charserverhandler.cpp82
-rw-r--r--src/net/ea/charserverhandler.h62
-rw-r--r--src/net/ea/charserverrecv.cpp143
-rw-r--r--src/net/ea/charserverrecv.h41
-rw-r--r--src/net/ea/chathandler.cpp63
-rw-r--r--src/net/ea/chathandler.h52
-rw-r--r--src/net/ea/chatrecv.cpp192
-rw-r--r--src/net/ea/chatrecv.h66
-rw-r--r--src/net/ea/eaprotocol.h57
-rw-r--r--src/net/ea/equipbackend.h109
-rw-r--r--src/net/ea/gamehandler.cpp62
-rw-r--r--src/net/ea/gamehandler.h52
-rw-r--r--src/net/ea/gamerecv.cpp80
-rw-r--r--src/net/ea/gamerecv.h48
-rw-r--r--src/net/ea/inventoryhandler.cpp128
-rw-r--r--src/net/ea/inventoryhandler.h72
-rw-r--r--src/net/ea/inventoryitem.h125
-rw-r--r--src/net/ea/inventoryrecv.cpp193
-rw-r--r--src/net/ea/inventoryrecv.h64
-rw-r--r--src/net/ea/itemhandler.cpp38
-rw-r--r--src/net/ea/itemhandler.h43
-rw-r--r--src/net/ea/itemrecv.cpp48
-rw-r--r--src/net/ea/itemrecv.h41
-rw-r--r--src/net/ea/loginhandler.cpp183
-rw-r--r--src/net/ea/loginhandler.h86
-rw-r--r--src/net/ea/loginrecv.cpp135
-rw-r--r--src/net/ea/loginrecv.h50
-rw-r--r--src/net/ea/maprecv.cpp59
-rw-r--r--src/net/ea/maprecv.h40
-rw-r--r--src/net/ea/network.cpp372
-rw-r--r--src/net/ea/network.h121
-rw-r--r--src/net/ea/npchandler.cpp43
-rw-r--r--src/net/ea/npchandler.h46
-rw-r--r--src/net/ea/npcrecv.cpp246
-rw-r--r--src/net/ea/npcrecv.h53
-rw-r--r--src/net/ea/partyhandler.cpp80
-rw-r--r--src/net/ea/partyhandler.h57
-rw-r--r--src/net/ea/partyrecv.cpp232
-rw-r--r--src/net/ea/partyrecv.h54
-rw-r--r--src/net/ea/playerhandler.cpp55
-rw-r--r--src/net/ea/playerhandler.h50
-rw-r--r--src/net/ea/playerrecv.cpp266
-rw-r--r--src/net/ea/playerrecv.h48
-rw-r--r--src/net/ea/skillhandler.cpp34
-rw-r--r--src/net/ea/skillhandler.h43
-rw-r--r--src/net/ea/skillrecv.cpp59
-rw-r--r--src/net/ea/skillrecv.h41
-rw-r--r--src/net/ea/token.h54
-rw-r--r--src/net/ea/tradehandler.cpp51
-rw-r--r--src/net/ea/tradehandler.h44
-rw-r--r--src/net/ea/traderecv.cpp184
-rw-r--r--src/net/ea/traderecv.h53
-rw-r--r--src/net/eathena/adminhandler.cpp379
-rw-r--r--src/net/eathena/adminhandler.h167
-rw-r--r--src/net/eathena/adminrecv.cpp81
-rw-r--r--src/net/eathena/adminrecv.h39
-rw-r--r--src/net/eathena/auctionhandler.cpp116
-rw-r--r--src/net/eathena/auctionhandler.h65
-rw-r--r--src/net/eathena/auctionrecv.cpp85
-rw-r--r--src/net/eathena/auctionrecv.h41
-rw-r--r--src/net/eathena/bankhandler.cpp86
-rw-r--r--src/net/eathena/bankhandler.h50
-rw-r--r--src/net/eathena/bankrecv.cpp65
-rw-r--r--src/net/eathena/bankrecv.h39
-rw-r--r--src/net/eathena/battlegroundhandler.cpp81
-rw-r--r--src/net/eathena/battlegroundhandler.h51
-rw-r--r--src/net/eathena/battlegroundrecv.cpp123
-rw-r--r--src/net/eathena/battlegroundrecv.h46
-rw-r--r--src/net/eathena/beinghandler.cpp109
-rw-r--r--src/net/eathena/beinghandler.h54
-rw-r--r--src/net/eathena/beingrecv.cpp2191
-rw-r--r--src/net/eathena/beingrecv.h136
-rw-r--r--src/net/eathena/buyingstorehandler.cpp112
-rw-r--r--src/net/eathena/buyingstorehandler.h54
-rw-r--r--src/net/eathena/buyingstorerecv.cpp238
-rw-r--r--src/net/eathena/buyingstorerecv.h55
-rw-r--r--src/net/eathena/buysellhandler.cpp77
-rw-r--r--src/net/eathena/buysellhandler.h59
-rw-r--r--src/net/eathena/buysellrecv.cpp141
-rw-r--r--src/net/eathena/buysellrecv.h41
-rw-r--r--src/net/eathena/cashshophandler.cpp160
-rw-r--r--src/net/eathena/cashshophandler.h57
-rw-r--r--src/net/eathena/cashshoprecv.cpp181
-rw-r--r--src/net/eathena/cashshoprecv.h45
-rw-r--r--src/net/eathena/charserverhandler.cpp248
-rw-r--r--src/net/eathena/charserverhandler.h88
-rw-r--r--src/net/eathena/charserverrecv.cpp570
-rw-r--r--src/net/eathena/charserverrecv.h68
-rw-r--r--src/net/eathena/chathandler.cpp338
-rw-r--r--src/net/eathena/chathandler.h103
-rw-r--r--src/net/eathena/chatrecv.cpp768
-rw-r--r--src/net/eathena/chatrecv.h78
-rw-r--r--src/net/eathena/elementalhandler.cpp39
-rw-r--r--src/net/eathena/elementalhandler.h40
-rw-r--r--src/net/eathena/elementalrecv.cpp73
-rw-r--r--src/net/eathena/elementalrecv.h38
-rw-r--r--src/net/eathena/familyhandler.cpp67
-rw-r--r--src/net/eathena/familyhandler.h44
-rw-r--r--src/net/eathena/familyrecv.cpp123
-rw-r--r--src/net/eathena/familyrecv.h45
-rw-r--r--src/net/eathena/friendshandler.cpp64
-rw-r--r--src/net/eathena/friendshandler.h49
-rw-r--r--src/net/eathena/friendsrecv.cpp76
-rw-r--r--src/net/eathena/friendsrecv.h41
-rw-r--r--src/net/eathena/gamehandler.cpp226
-rw-r--r--src/net/eathena/gamehandler.h60
-rw-r--r--src/net/eathena/gamerecv.cpp86
-rw-r--r--src/net/eathena/gamerecv.h42
-rw-r--r--src/net/eathena/generalhandler.cpp245
-rw-r--r--src/net/eathena/generalhandler.h134
-rw-r--r--src/net/eathena/generalrecv.cpp180
-rw-r--r--src/net/eathena/generalrecv.h40
-rw-r--r--src/net/eathena/guildhandler.cpp291
-rw-r--r--src/net/eathena/guildhandler.h104
-rw-r--r--src/net/eathena/guildrecv.cpp717
-rw-r--r--src/net/eathena/guildrecv.h77
-rw-r--r--src/net/eathena/homunculushandler.cpp141
-rw-r--r--src/net/eathena/homunculushandler.h59
-rw-r--r--src/net/eathena/homunculusrecv.cpp227
-rw-r--r--src/net/eathena/homunculusrecv.h42
-rw-r--r--src/net/eathena/inventoryhandler.cpp603
-rw-r--r--src/net/eathena/inventoryhandler.h97
-rw-r--r--src/net/eathena/inventoryrecv.cpp1441
-rw-r--r--src/net/eathena/inventoryrecv.h81
-rw-r--r--src/net/eathena/itemflags.h45
-rw-r--r--src/net/eathena/itemhandler.cpp35
-rw-r--r--src/net/eathena/itemhandler.h41
-rw-r--r--src/net/eathena/itemrecv.cpp178
-rw-r--r--src/net/eathena/itemrecv.h43
-rw-r--r--src/net/eathena/loginhandler.cpp167
-rw-r--r--src/net/eathena/loginhandler.h70
-rw-r--r--src/net/eathena/loginrecv.cpp294
-rw-r--r--src/net/eathena/loginrecv.h44
-rw-r--r--src/net/eathena/mail2handler.cpp285
-rw-r--r--src/net/eathena/mail2handler.h88
-rw-r--r--src/net/eathena/mail2recv.cpp526
-rw-r--r--src/net/eathena/mail2recv.h55
-rw-r--r--src/net/eathena/mailhandler.cpp109
-rw-r--r--src/net/eathena/mailhandler.h61
-rw-r--r--src/net/eathena/mailrecv.cpp251
-rw-r--r--src/net/eathena/mailrecv.h45
-rw-r--r--src/net/eathena/maphandler.cpp39
-rw-r--r--src/net/eathena/maphandler.h41
-rw-r--r--src/net/eathena/maprecv.cpp68
-rw-r--r--src/net/eathena/maprecv.h41
-rw-r--r--src/net/eathena/maptypeproperty2.h55
-rw-r--r--src/net/eathena/markethandler.cpp145
-rw-r--r--src/net/eathena/markethandler.h51
-rw-r--r--src/net/eathena/marketrecv.cpp108
-rw-r--r--src/net/eathena/marketrecv.h42
-rw-r--r--src/net/eathena/menu.cpp28
-rw-r--r--src/net/eathena/menu.h31
-rw-r--r--src/net/eathena/mercenaryhandler.cpp121
-rw-r--r--src/net/eathena/mercenaryhandler.h55
-rw-r--r--src/net/eathena/mercenaryrecv.cpp194
-rw-r--r--src/net/eathena/mercenaryrecv.h40
-rw-r--r--src/net/eathena/messagein.cpp178
-rw-r--r--src/net/eathena/messagein.h69
-rw-r--r--src/net/eathena/messageout.cpp150
-rw-r--r--src/net/eathena/messageout.h85
-rw-r--r--src/net/eathena/network.cpp255
-rw-r--r--src/net/eathena/network.h66
-rw-r--r--src/net/eathena/npchandler.cpp365
-rw-r--r--src/net/eathena/npchandler.h101
-rw-r--r--src/net/eathena/npcrecv.cpp132
-rw-r--r--src/net/eathena/npcrecv.h48
-rw-r--r--src/net/eathena/packetsin.inc972
-rw-r--r--src/net/eathena/packetsout.inc8044
-rw-r--r--src/net/eathena/partyhandler.cpp203
-rw-r--r--src/net/eathena/partyhandler.h69
-rw-r--r--src/net/eathena/partyrecv.cpp422
-rw-r--r--src/net/eathena/partyrecv.h54
-rw-r--r--src/net/eathena/pethandler.cpp126
-rw-r--r--src/net/eathena/pethandler.h64
-rw-r--r--src/net/eathena/petrecv.cpp181
-rw-r--r--src/net/eathena/petrecv.h43
-rw-r--r--src/net/eathena/playerhandler.cpp718
-rw-r--r--src/net/eathena/playerhandler.h82
-rw-r--r--src/net/eathena/playerrecv.cpp498
-rw-r--r--src/net/eathena/playerrecv.h60
-rw-r--r--src/net/eathena/protocolout.cpp32
-rw-r--r--src/net/eathena/protocolout.h40
-rw-r--r--src/net/eathena/questhandler.cpp50
-rw-r--r--src/net/eathena/questhandler.h44
-rw-r--r--src/net/eathena/questrecv.cpp205
-rw-r--r--src/net/eathena/questrecv.h45
-rw-r--r--src/net/eathena/recvpackets.inc32
-rw-r--r--src/net/eathena/roulettehandler.cpp39
-rw-r--r--src/net/eathena/roulettehandler.h40
-rw-r--r--src/net/eathena/rouletterecv.cpp79
-rw-r--r--src/net/eathena/rouletterecv.h40
-rw-r--r--src/net/eathena/searchstorehandler.cpp88
-rw-r--r--src/net/eathena/searchstorehandler.h53
-rw-r--r--src/net/eathena/searchstorerecv.cpp109
-rw-r--r--src/net/eathena/searchstorerecv.h40
-rw-r--r--src/net/eathena/serverfeatures.cpp153
-rw-r--r--src/net/eathena/serverfeatures.h86
-rw-r--r--src/net/eathena/skillhandler.cpp152
-rw-r--r--src/net/eathena/skillhandler.h70
-rw-r--r--src/net/eathena/skillrecv.cpp529
-rw-r--r--src/net/eathena/skillrecv.h56
-rw-r--r--src/net/eathena/sp.h271
-rw-r--r--src/net/eathena/sprite.h49
-rw-r--r--src/net/eathena/tradehandler.cpp107
-rw-r--r--src/net/eathena/tradehandler.h58
-rw-r--r--src/net/eathena/traderecv.cpp185
-rw-r--r--src/net/eathena/traderecv.h47
-rw-r--r--src/net/eathena/updateprotocol.cpp57
-rw-r--r--src/net/eathena/updateprotocol.h29
-rw-r--r--src/net/eathena/vendinghandler.cpp150
-rw-r--r--src/net/eathena/vendinghandler.h62
-rw-r--r--src/net/eathena/vendingrecv.cpp277
-rw-r--r--src/net/eathena/vendingrecv.h48
-rw-r--r--src/net/elementalhandler.h45
-rw-r--r--src/net/familyhandler.h51
-rw-r--r--src/net/friendshandler.h55
-rw-r--r--src/net/gamehandler.h71
-rw-r--r--src/net/generalhandler.h65
-rw-r--r--src/net/guildhandler.h106
-rw-r--r--src/net/homunculushandler.h69
-rw-r--r--src/net/hostsgroup.h42
-rw-r--r--src/net/inventoryhandler.h114
-rw-r--r--src/net/ipc.cpp226
-rw-r--r--src/net/ipc.h79
-rw-r--r--src/net/logindata.h110
-rw-r--r--src/net/loginhandler.h114
-rw-r--r--src/net/mail2handler.h100
-rw-r--r--src/net/mailhandler.h67
-rw-r--r--src/net/maphandler.h45
-rw-r--r--src/net/markethandler.h62
-rw-r--r--src/net/mercenaryhandler.h65
-rw-r--r--src/net/messagein.cpp332
-rw-r--r--src/net/messagein.h152
-rw-r--r--src/net/messageout.cpp175
-rw-r--r--src/net/messageout.h123
-rw-r--r--src/net/net.cpp194
-rw-r--r--src/net/net.h56
-rw-r--r--src/net/npchandler.h123
-rw-r--r--src/net/packetcounters.cpp137
-rw-r--r--src/net/packetcounters.h71
-rw-r--r--src/net/packetfunction.h33
-rw-r--r--src/net/packetinfo.h46
-rw-r--r--src/net/packetlimiter.cpp323
-rw-r--r--src/net/packetlimiter.h41
-rw-r--r--src/net/partyhandler.h90
-rw-r--r--src/net/pethandler.h68
-rw-r--r--src/net/playerhandler.h120
-rw-r--r--src/net/protocoloutdefine.h28
-rw-r--r--src/net/protocoloutinclude.h27
-rw-r--r--src/net/protocoloutupdate.h28
-rw-r--r--src/net/questhandler.h48
-rw-r--r--src/net/recvpacketdefine.h36
-rw-r--r--src/net/roulettehandler.h45
-rw-r--r--src/net/sdltcpnet.cpp197
-rw-r--r--src/net/sdltcpnet.h68
-rw-r--r--src/net/searchstorehandler.h60
-rw-r--r--src/net/serverfeatures.h90
-rw-r--r--src/net/serverinfo.h228
-rw-r--r--src/net/serverurlinfo.h49
-rw-r--r--src/net/skillhandler.h77
-rw-r--r--src/net/tmwa/adminhandler.cpp299
-rw-r--r--src/net/tmwa/adminhandler.h178
-rw-r--r--src/net/tmwa/auctionhandler.cpp81
-rw-r--r--src/net/tmwa/auctionhandler.h65
-rw-r--r--src/net/tmwa/bankhandler.cpp59
-rw-r--r--src/net/tmwa/bankhandler.h51
-rw-r--r--src/net/tmwa/battlegroundhandler.cpp58
-rw-r--r--src/net/tmwa/battlegroundhandler.h54
-rw-r--r--src/net/tmwa/beinghandler.cpp74
-rw-r--r--src/net/tmwa/beinghandler.h55
-rw-r--r--src/net/tmwa/beingrecv.cpp1517
-rw-r--r--src/net/tmwa/beingrecv.h78
-rw-r--r--src/net/tmwa/buyingstorehandler.cpp61
-rw-r--r--src/net/tmwa/buyingstorehandler.h56
-rw-r--r--src/net/tmwa/buysellhandler.cpp131
-rw-r--r--src/net/tmwa/buysellhandler.h59
-rw-r--r--src/net/tmwa/buysellrecv.cpp123
-rw-r--r--src/net/tmwa/buysellrecv.h41
-rw-r--r--src/net/tmwa/cashshophandler.cpp68
-rw-r--r--src/net/tmwa/cashshophandler.h58
-rw-r--r--src/net/tmwa/charserverhandler.cpp196
-rw-r--r--src/net/tmwa/charserverhandler.h91
-rw-r--r--src/net/tmwa/charserverrecv.cpp304
-rw-r--r--src/net/tmwa/charserverrecv.h47
-rw-r--r--src/net/tmwa/chathandler.cpp260
-rw-r--r--src/net/tmwa/chathandler.h109
-rw-r--r--src/net/tmwa/chatrecv.cpp377
-rw-r--r--src/net/tmwa/chatrecv.h50
-rw-r--r--src/net/tmwa/elementalhandler.cpp39
-rw-r--r--src/net/tmwa/elementalhandler.h39
-rw-r--r--src/net/tmwa/familyhandler.cpp47
-rw-r--r--src/net/tmwa/familyhandler.h46
-rw-r--r--src/net/tmwa/friendshandler.cpp53
-rw-r--r--src/net/tmwa/friendshandler.h49
-rw-r--r--src/net/tmwa/gamehandler.cpp135
-rw-r--r--src/net/tmwa/gamehandler.h60
-rw-r--r--src/net/tmwa/gamerecv.cpp63
-rw-r--r--src/net/tmwa/gamerecv.h39
-rw-r--r--src/net/tmwa/generalhandler.cpp245
-rw-r--r--src/net/tmwa/generalhandler.h133
-rw-r--r--src/net/tmwa/generalrecv.cpp85
-rw-r--r--src/net/tmwa/generalrecv.h39
-rw-r--r--src/net/tmwa/guildhandler.cpp142
-rw-r--r--src/net/tmwa/guildhandler.h102
-rw-r--r--src/net/tmwa/guildmanager.cpp543
-rw-r--r--src/net/tmwa/guildmanager.h106
-rw-r--r--src/net/tmwa/homunculushandler.cpp75
-rw-r--r--src/net/tmwa/homunculushandler.h62
-rw-r--r--src/net/tmwa/inventoryhandler.cpp196
-rw-r--r--src/net/tmwa/inventoryhandler.h91
-rw-r--r--src/net/tmwa/inventoryrecv.cpp563
-rw-r--r--src/net/tmwa/inventoryrecv.h52
-rw-r--r--src/net/tmwa/itemhandler.cpp35
-rw-r--r--src/net/tmwa/itemhandler.h41
-rw-r--r--src/net/tmwa/itemrecv.cpp89
-rw-r--r--src/net/tmwa/itemrecv.h40
-rw-r--r--src/net/tmwa/loginhandler.cpp142
-rw-r--r--src/net/tmwa/loginhandler.h72
-rw-r--r--src/net/tmwa/loginrecv.cpp175
-rw-r--r--src/net/tmwa/loginrecv.h41
-rw-r--r--src/net/tmwa/mail2handler.cpp118
-rw-r--r--src/net/tmwa/mail2handler.h88
-rw-r--r--src/net/tmwa/mailhandler.cpp77
-rw-r--r--src/net/tmwa/mailhandler.h62
-rw-r--r--src/net/tmwa/maphandler.cpp39
-rw-r--r--src/net/tmwa/maphandler.h41
-rw-r--r--src/net/tmwa/markethandler.cpp55
-rw-r--r--src/net/tmwa/markethandler.h50
-rw-r--r--src/net/tmwa/mercenaryhandler.cpp67
-rw-r--r--src/net/tmwa/mercenaryhandler.h58
-rw-r--r--src/net/tmwa/messagein.cpp168
-rw-r--r--src/net/tmwa/messagein.h68
-rw-r--r--src/net/tmwa/messageout.cpp132
-rw-r--r--src/net/tmwa/messageout.h82
-rw-r--r--src/net/tmwa/network.cpp183
-rw-r--r--src/net/tmwa/network.h63
-rw-r--r--src/net/tmwa/npchandler.cpp246
-rw-r--r--src/net/tmwa/npchandler.h102
-rw-r--r--src/net/tmwa/packetsin.inc147
-rw-r--r--src/net/tmwa/packetsout.inc110
-rw-r--r--src/net/tmwa/partyhandler.cpp162
-rw-r--r--src/net/tmwa/partyhandler.h70
-rw-r--r--src/net/tmwa/partyrecv.cpp304
-rw-r--r--src/net/tmwa/partyrecv.h44
-rw-r--r--src/net/tmwa/pethandler.cpp84
-rw-r--r--src/net/tmwa/pethandler.h67
-rw-r--r--src/net/tmwa/playerhandler.cpp422
-rw-r--r--src/net/tmwa/playerhandler.h92
-rw-r--r--src/net/tmwa/playerrecv.cpp165
-rw-r--r--src/net/tmwa/playerrecv.h40
-rw-r--r--src/net/tmwa/protocolout.cpp30
-rw-r--r--src/net/tmwa/protocolout.h40
-rw-r--r--src/net/tmwa/questhandler.cpp44
-rw-r--r--src/net/tmwa/questhandler.h45
-rw-r--r--src/net/tmwa/questrecv.cpp67
-rw-r--r--src/net/tmwa/questrecv.h38
-rw-r--r--src/net/tmwa/recvpackets.inc32
-rw-r--r--src/net/tmwa/roulettehandler.cpp39
-rw-r--r--src/net/tmwa/roulettehandler.h40
-rw-r--r--src/net/tmwa/searchstorehandler.cpp60
-rw-r--r--src/net/tmwa/searchstorehandler.h53
-rw-r--r--src/net/tmwa/serverfeatures.cpp151
-rw-r--r--src/net/tmwa/serverfeatures.h86
-rw-r--r--src/net/tmwa/skillhandler.cpp106
-rw-r--r--src/net/tmwa/skillhandler.h70
-rw-r--r--src/net/tmwa/skillrecv.cpp217
-rw-r--r--src/net/tmwa/skillrecv.h40
-rw-r--r--src/net/tmwa/sp.h80
-rw-r--r--src/net/tmwa/sprite.h45
-rw-r--r--src/net/tmwa/tradehandler.cpp103
-rw-r--r--src/net/tmwa/tradehandler.h58
-rw-r--r--src/net/tmwa/traderecv.cpp170
-rw-r--r--src/net/tmwa/traderecv.h42
-rw-r--r--src/net/tmwa/updateprotocol.cpp49
-rw-r--r--src/net/tmwa/updateprotocol.h29
-rw-r--r--src/net/tmwa/vendinghandler.cpp72
-rw-r--r--src/net/tmwa/vendinghandler.h63
-rw-r--r--src/net/tradehandler.h76
-rw-r--r--src/net/updatetypeoperators.cpp40
-rw-r--r--src/net/updatetypeoperators.h30
-rw-r--r--src/net/uploadcharinfo.h52
-rw-r--r--src/net/useragent.cpp42
-rw-r--r--src/net/useragent.h31
-rw-r--r--src/net/vendinghandler.h72
-rw-r--r--src/net/worldinfo.h60
-rw-r--r--src/notifymanager.cpp195
-rw-r--r--src/notifymanager.h34
-rw-r--r--src/options.h105
-rw-r--r--src/particle/animationparticle.cpp42
-rw-r--r--src/particle/animationparticle.h45
-rw-r--r--src/particle/imageparticle.cpp92
-rw-r--r--src/particle/imageparticle.h61
-rw-r--r--src/particle/particle.cpp590
-rw-r--r--src/particle/particle.h329
-rw-r--r--src/particle/particlecontainer.cpp55
-rw-r--r--src/particle/particlecontainer.h71
-rw-r--r--src/particle/particleemitter.cpp632
-rw-r--r--src/particle/particleemitter.h172
-rw-r--r--src/particle/particleemitterprop.h127
-rw-r--r--src/particle/particleengine.cpp343
-rw-r--r--src/particle/particleengine.h130
-rw-r--r--src/particle/particleinfo.h42
-rw-r--r--src/particle/particlelist.cpp106
-rw-r--r--src/particle/particlelist.h69
-rw-r--r--src/particle/particletimer.h43
-rw-r--r--src/particle/particlevector.cpp109
-rw-r--r--src/particle/particlevector.h71
-rw-r--r--src/particle/rotationalparticle.cpp43
-rw-r--r--src/particle/rotationalparticle.h44
-rw-r--r--src/particle/textparticle.cpp96
-rw-r--r--src/particle/textparticle.h69
-rw-r--r--src/party.cpp337
-rw-r--r--src/party.h182
-rw-r--r--src/position.cpp49
-rw-r--r--src/position.h63
-rw-r--r--src/progs/dyecmd/actions/actions.cpp120
-rw-r--r--src/progs/dyecmd/actions/chat.cpp69
-rw-r--r--src/progs/dyecmd/actions/commands.cpp167
-rw-r--r--src/progs/dyecmd/actions/move.cpp44
-rw-r--r--src/progs/dyecmd/actions/pets.cpp49
-rw-r--r--src/progs/dyecmd/actions/statusbar.cpp49
-rw-r--r--src/progs/dyecmd/actions/tabs.cpp39
-rw-r--r--src/progs/dyecmd/actions/target.cpp39
-rw-r--r--src/progs/dyecmd/actions/windows.cpp60
-rw-r--r--src/progs/dyecmd/client.cpp818
-rw-r--r--src/progs/dyecmd/client.h119
-rw-r--r--src/progs/dyecmd/dyemain.cpp119
-rw-r--r--src/progs/dyecmd/gui/viewport.cpp272
-rw-r--r--src/progs/dyecmd/gui/viewport.h213
-rw-r--r--src/progs/manaplus/actions/actions.cpp1918
-rw-r--r--src/progs/manaplus/actions/chat.cpp808
-rw-r--r--src/progs/manaplus/actions/commands.cpp2156
-rw-r--r--src/progs/manaplus/actions/move.cpp280
-rw-r--r--src/progs/manaplus/actions/pets.cpp248
-rw-r--r--src/progs/manaplus/actions/statusbar.cpp200
-rw-r--r--src/progs/manaplus/actions/tabs.cpp106
-rw-r--r--src/progs/manaplus/actions/target.cpp90
-rw-r--r--src/progs/manaplus/actions/windows.cpp383
-rw-r--r--src/progs/manaplus/client.cpp1991
-rw-r--r--src/progs/manaplus/client.h167
-rw-r--r--src/progs/manaplus/gui/viewport.cpp1148
-rw-r--r--src/progs/manaplus/gui/viewport.h249
-rw-r--r--src/render/graphics.cpp775
-rw-r--r--src/render/graphics.h557
-rw-r--r--src/render/graphics_calcImageRect.hpp94
-rw-r--r--src/render/graphics_drawImageRect.hpp83
-rw-r--r--src/render/graphicsdef.hpp154
-rw-r--r--src/render/imagegraphics.cpp64
-rw-r--r--src/render/imagegraphics.h208
-rw-r--r--src/render/mobileopengl2graphics.cpp1389
-rw-r--r--src/render/mobileopengl2graphics.h164
-rw-r--r--src/render/mobileopenglgraphics.cpp1385
-rw-r--r--src/render/mobileopenglgraphics.h115
-rw-r--r--src/render/modernopenglgraphics.cpp1403
-rw-r--r--src/render/modernopenglgraphics.h159
-rw-r--r--src/render/nacl/naclfunctions.h35
-rw-r--r--src/render/nacl/naclgles.cpp55
-rw-r--r--src/render/nacl/naclgles.h32
-rw-r--r--src/render/normalopenglgraphics.cpp1782
-rw-r--r--src/render/normalopenglgraphics.h133
-rw-r--r--src/render/nullopenglgraphics.cpp1251
-rw-r--r--src/render/nullopenglgraphics.h111
-rw-r--r--src/render/opengl/mgl.cpp34
-rw-r--r--src/render/opengl/mgl.h38
-rw-r--r--src/render/opengl/mgl.hpp144
-rw-r--r--src/render/opengl/mglcheck.h30
-rw-r--r--src/render/opengl/mgldefines.h136
-rw-r--r--src/render/opengl/mglemu.cpp54
-rw-r--r--src/render/opengl/mglemu.h41
-rw-r--r--src/render/opengl/mglfunctions.h101
-rw-r--r--src/render/opengl/mgltypes.h226
-rw-r--r--src/render/opengl/naclglfunctions.h322
-rw-r--r--src/render/opengl/opengldebug.h38
-rw-r--r--src/render/openglgraphicsdef.hpp58
-rw-r--r--src/render/openglgraphicsdef1.hpp30
-rw-r--r--src/render/openglgraphicsdefadvanced.hpp43
-rw-r--r--src/render/openglx/mglx.cpp34
-rw-r--r--src/render/openglx/mglx.h35
-rw-r--r--src/render/openglx/mglx.hpp29
-rw-r--r--src/render/openglx/mglxinit.cpp42
-rw-r--r--src/render/openglx/mglxinit.h32
-rw-r--r--src/render/openglx/mglxtypes.h41
-rw-r--r--src/render/renderers.cpp117
-rw-r--r--src/render/renderers.h32
-rw-r--r--src/render/rendererslistsdl.h176
-rw-r--r--src/render/rendererslistsdl2.h184
-rw-r--r--src/render/safeopenglgraphics.cpp763
-rw-r--r--src/render/safeopenglgraphics.h80
-rw-r--r--src/render/sdl2graphics.cpp789
-rw-r--r--src/render/sdl2graphics.h116
-rw-r--r--src/render/sdl2softwaregraphics.cpp1530
-rw-r--r--src/render/sdl2softwaregraphics.h89
-rw-r--r--src/render/sdlgraphics.cpp1518
-rw-r--r--src/render/sdlgraphics.h75
-rw-r--r--src/render/shaders/shader.cpp41
-rw-r--r--src/render/shaders/shader.h45
-rw-r--r--src/render/shaders/shaderprogram.cpp54
-rw-r--r--src/render/shaders/shaderprogram.h51
-rw-r--r--src/render/shaders/shadersmanager.cpp146
-rw-r--r--src/render/shaders/shadersmanager.h57
-rw-r--r--src/render/softwaregraphicsdef.hpp27
-rw-r--r--src/render/surfacegraphics.cpp156
-rw-r--r--src/render/surfacegraphics.h218
-rw-r--r--src/render/vertexes/imagecollection.cpp52
-rw-r--r--src/render/vertexes/imagecollection.h52
-rw-r--r--src/render/vertexes/imagevertexes.cpp41
-rw-r--r--src/render/vertexes/imagevertexes.h59
-rw-r--r--src/render/vertexes/openglgraphicsvertexes.cpp225
-rw-r--r--src/render/vertexes/openglgraphicsvertexes.h109
-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
-rw-r--r--src/sdl2gfx/SDL2_framerate.cpp211
-rw-r--r--src/sdl2gfx/SDL2_framerate.h110
-rw-r--r--src/sdl2gfx/SDL2_rotozoom.cpp1944
-rw-r--r--src/sdl2gfx/SDL2_rotozoom.h131
-rw-r--r--src/sdlshared.h66
-rw-r--r--src/settings.cpp39
-rw-r--r--src/settings.h168
-rw-r--r--src/soundmanager.cpp589
-rw-r--r--src/soundmanager.h177
-rw-r--r--src/spellmanager.cpp449
-rw-r--r--src/spellmanager.h90
-rw-r--r--src/statuseffect.cpp100
-rw-r--r--src/statuseffect.h91
-rw-r--r--src/test/testlauncher.cpp835
-rw-r--r--src/test/testlauncher.h92
-rw-r--r--src/test/testmain.cpp431
-rw-r--r--src/test/testmain.h93
-rw-r--r--src/text.cpp206
-rw-r--r--src/text.h138
-rw-r--r--src/textcommand.cpp141
-rw-r--r--src/textcommand.h180
-rw-r--r--src/textmanager.cpp195
-rw-r--r--src/textmanager.h82
-rw-r--r--src/unittests/catch.hpp10502
-rw-r--r--src/unittests/configuration.cc293
-rw-r--r--src/unittests/doctest.h5613
-rw-r--r--src/unittests/endian.cc60
-rw-r--r--src/unittests/enums/enums.cc35
-rw-r--r--src/unittests/enums/render/mockdrawtype.h35
-rw-r--r--src/unittests/fs/files.cc207
-rw-r--r--src/unittests/fs/virtfs/throw.cc225
-rw-r--r--src/unittests/fs/virtfs/virtfs.cc996
-rw-r--r--src/unittests/fs/virtfs/virtfs1_basic.cc46
-rw-r--r--src/unittests/fs/virtfs/virtfs1_enumerate.cc410
-rw-r--r--src/unittests/fs/virtfs/virtfs1_exists.cc154
-rw-r--r--src/unittests/fs/virtfs/virtfs1_getrealdir.cc202
-rw-r--r--src/unittests/fs/virtfs/virtfs1_mountdir1.cc195
-rw-r--r--src/unittests/fs/virtfs/virtfs1_mountdir2.cc315
-rw-r--r--src/unittests/fs/virtfs/virtfs1_mountzip1.cc173
-rw-r--r--src/unittests/fs/virtfs/virtfs1_mountzip2.cc202
-rw-r--r--src/unittests/fs/virtfs/virtfs1_unmount.cc377
-rw-r--r--src/unittests/fs/virtfs/virtfs2.cc1643
-rw-r--r--src/unittests/fs/virtfs/zip.cc283
-rw-r--r--src/unittests/gui/fonts/textchunklist.cc548
-rw-r--r--src/unittests/gui/widgets/browserbox.cc191
-rw-r--r--src/unittests/gui/windowmanager.cc991
-rw-r--r--src/unittests/integrity.cc360
-rw-r--r--src/unittests/render/mockdrawitem.h60
-rw-r--r--src/unittests/render/mockgraphics.cc302
-rw-r--r--src/unittests/render/mockgraphics.h55
-rw-r--r--src/unittests/resources/dye/dye.cc2014
-rw-r--r--src/unittests/resources/dye/dyepalette.cc400
-rw-r--r--src/unittests/resources/map/maplayer/draw.cc580
-rw-r--r--src/unittests/resources/map/maplayer/drawfringenormal.cc529
-rw-r--r--src/unittests/resources/map/maplayer/drawfringesimple.cc507
-rw-r--r--src/unittests/resources/map/maplayer/drawspeciallayer1.cc396
-rw-r--r--src/unittests/resources/map/maplayer/drawspeciallayer2.cc402
-rw-r--r--src/unittests/resources/map/maplayer/getemptytiledrawwidth.cc162
-rw-r--r--src/unittests/resources/map/maplayer/gettiledrawwidth.cc399
-rw-r--r--src/unittests/resources/map/maplayer/updatecache.cc399
-rw-r--r--src/unittests/resources/map/maplayer/updateconditiontiles.cc231
-rw-r--r--src/unittests/resources/map/speciallayer.cc288
-rw-r--r--src/unittests/resources/mstack.cc165
-rw-r--r--src/unittests/resources/resourcemanager/resourcemanager.cc693
-rw-r--r--src/unittests/resources/sdlimagehelper.cc559
-rw-r--r--src/unittests/resources/sprite/animatedsprite.cc198
-rw-r--r--src/unittests/sdl.cc405
-rw-r--r--src/unittests/unittests.h52
-rw-r--r--src/unittests/utils/chatutils.cc265
-rw-r--r--src/unittests/utils/checkutils.cc174
-rw-r--r--src/unittests/utils/dumplibs.cc138
-rw-r--r--src/unittests/utils/langs.cc115
-rw-r--r--src/unittests/utils/mathutils.cc102
-rw-r--r--src/unittests/utils/parameters.cc327
-rw-r--r--src/unittests/utils/stringutils.cc1715
-rw-r--r--src/unittests/utils/timer.cc88
-rw-r--r--src/unittests/utils/translation/poparser.cc136
-rw-r--r--src/unittests/utils/xml.cc393
-rw-r--r--src/unittests/utils/xmlutils.cc225
-rw-r--r--src/utils/base64.cpp214
-rw-r--r--src/utils/base64.h46
-rw-r--r--src/utils/booleanoptions.h32
-rw-r--r--src/utils/browserboxtools.cpp169
-rw-r--r--src/utils/browserboxtools.h39
-rw-r--r--src/utils/buildhex.h48
-rw-r--r--src/utils/cast.h35
-rw-r--r--src/utils/chatutils.cpp201
-rw-r--r--src/utils/chatutils.h36
-rw-r--r--src/utils/checkutils.cpp76
-rw-r--r--src/utils/checkutils.h261
-rw-r--r--src/utils/copynpaste.cpp522
-rw-r--r--src/utils/copynpaste.h42
-rw-r--r--src/utils/cpu.cpp178
-rw-r--r--src/utils/cpu.h48
-rw-r--r--src/utils/delete2.h36
-rw-r--r--src/utils/dtor.h60
-rw-r--r--src/utils/dumplibs.cpp169
-rw-r--r--src/utils/dumplibs.h28
-rw-r--r--src/utils/dumpsizes.cpp40
-rw-r--r--src/utils/dumpsizes.h28
-rw-r--r--src/utils/env.cpp73
-rw-r--r--src/utils/env.h30
-rw-r--r--src/utils/foreach.h36
-rw-r--r--src/utils/fuzzer.cpp60
-rw-r--r--src/utils/fuzzer.h34
-rw-r--r--src/utils/gettext.h55
-rw-r--r--src/utils/gettexthelper.cpp156
-rw-r--r--src/utils/gettexthelper.h45
-rw-r--r--src/utils/glxhelper.cpp142
-rw-r--r--src/utils/glxhelper.h42
-rw-r--r--src/utils/gmfunctions.cpp122
-rw-r--r--src/utils/gmfunctions.h43
-rw-r--r--src/utils/intmap.h30
-rw-r--r--src/utils/langs.cpp123
-rw-r--r--src/utils/langs.h41
-rw-r--r--src/utils/likely.h32
-rw-r--r--src/utils/mathutils.h251
-rw-r--r--src/utils/mrand.cpp45
-rw-r--r--src/utils/mrand.h30
-rw-r--r--src/utils/mutex.h110
-rw-r--r--src/utils/naclmessages.cpp109
-rw-r--r--src/utils/naclmessages.h41
-rw-r--r--src/utils/parameters.cpp119
-rw-r--r--src/utils/parameters.h33
-rw-r--r--src/utils/perfomance.cpp100
-rw-r--r--src/utils/perfomance.h83
-rw-r--r--src/utils/pnglib.cpp113
-rw-r--r--src/utils/pnglib.h38
-rw-r--r--src/utils/process.cpp328
-rw-r--r--src/utils/process.h37
-rw-r--r--src/utils/sdl2helper.cpp271
-rw-r--r--src/utils/sdl2helper.h84
-rw-r--r--src/utils/sdl2logger.cpp161
-rw-r--r--src/utils/sdl2logger.h36
-rw-r--r--src/utils/sdlcheckutils.cpp201
-rw-r--r--src/utils/sdlcheckutils.h78
-rw-r--r--src/utils/sdlhelper.cpp217
-rw-r--r--src/utils/sdlhelper.h85
-rw-r--r--src/utils/sdlmemoryobject.h55
-rw-r--r--src/utils/sdlpixel.h254
-rw-r--r--src/utils/sdlsharedhelper.cpp55
-rw-r--r--src/utils/sdlsharedhelper.h31
-rw-r--r--src/utils/stdmove.h30
-rw-r--r--src/utils/stringmap.h31
-rw-r--r--src/utils/stringutils.cpp1238
-rw-r--r--src/utils/stringutils.h288
-rw-r--r--src/utils/stringvector.h32
-rw-r--r--src/utils/timer.cpp124
-rw-r--r--src/utils/timer.h44
-rw-r--r--src/utils/translation/podict.cpp61
-rw-r--r--src/utils/translation/podict.h73
-rw-r--r--src/utils/translation/poparser.cpp286
-rw-r--r--src/utils/translation/poparser.h87
-rw-r--r--src/utils/translation/translationmanager.cpp154
-rw-r--r--src/utils/translation/translationmanager.h58
-rw-r--r--src/utils/vector.h32
-rw-r--r--src/utils/x11logger.cpp213
-rw-r--r--src/utils/x11logger.h36
-rw-r--r--src/utils/xml.h34
-rw-r--r--src/utils/xml.inc30
-rw-r--r--src/utils/xml/libxml.cpp346
-rw-r--r--src/utils/xml/libxml.h164
-rw-r--r--src/utils/xml/libxml.inc73
-rw-r--r--src/utils/xml/pugixml.cpp352
-rw-r--r--src/utils/xml/pugixml.h166
-rw-r--r--src/utils/xml/pugixml.inc58
-rw-r--r--src/utils/xml/pugixmlwriter.cpp74
-rw-r--r--src/utils/xml/pugixmlwriter.h65
-rw-r--r--src/utils/xml/tinyxml2.cpp323
-rw-r--r--src/utils/xml/tinyxml2.h168
-rw-r--r--src/utils/xml/tinyxml2.inc77
-rw-r--r--src/utils/xmlutils.cpp185
-rw-r--r--src/utils/xmlutils.h57
-rw-r--r--src/utils/xmlwriter.h28
-rw-r--r--src/variabledata.h132
-rw-r--r--src/vector.cpp31
-rw-r--r--src/vector.h216
-rw-r--r--src/winver.h26
-rw-r--r--src/winver.h.in26
1896 files changed, 0 insertions, 364314 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
deleted file mode 100644
index e64b6cf4f..000000000
--- a/src/CMakeLists.txt
+++ /dev/null
@@ -1,2163 +0,0 @@
-FIND_PACKAGE(SDL REQUIRED)
-FIND_PACKAGE(SDL_image REQUIRED)
-FIND_PACKAGE(SDL_mixer REQUIRED)
-FIND_PACKAGE(SDL_net REQUIRED)
-FIND_PACKAGE(SDL_ttf REQUIRED)
-FIND_PACKAGE(SDL_gfx REQUIRED)
-FIND_PACKAGE(CURL REQUIRED)
-FIND_PACKAGE(LibXml2 REQUIRED)
-FIND_PACKAGE(PNG REQUIRED)
-FIND_PACKAGE(Gettext REQUIRED)
-FIND_PACKAGE(ZLIB REQUIRED)
-
-IF (POLICY CMP0015)
- CMAKE_POLICY(SET CMP0015 OLD)
-ENDIF()
-
-SET(FLAGS "-DPACKAGE_VERSION=\\\"${VERSION}\\\"")
-SET(FLAGS "${FLAGS} -DPKG_DATADIR=\\\"${PKG_DATADIR}/\\\"")
-SET(FLAGS "${FLAGS} -DLOCALEDIR=\\\"${LOCALEDIR}/\\\"")
-SET(DYE_FLAGS "-DPACKAGE_VERSION=\\\"${VERSION}\\\" -DDYECMD")
-SET(DYE_FLAGS "${DYE_FLAGS} -DPKG_DATADIR=\\\"${PKG_DATADIR}/\\\"")
-SET(DYE_FLAGS "${DYE_FLAGS} -DLOCALEDIR=\\\"${LOCALEDIR}/\\\"")
-
-IF (ENABLE_NLS)
- SET(FLAGS "${FLAGS} -DENABLE_NLS=1")
-ENDIF()
-
-IF (ENABLE_TMWA)
- SET(FLAGS "${FLAGS} -DTMWA_SUPPORT=1")
-ENDIF()
-
-SET(FLAGS "${FLAGS} -DENABLE_LIBXML -DENABLE_ASSERTS")
-
-IF (CMAKE_BUILD_TYPE)
- STRING(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_TOLOWER)
- IF(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug OR
- CMAKE_BUILD_TYPE_TOLOWER MATCHES relwithdebinfo)
- SET(FLAGS "${FLAGS} -DDEBUG")
- SET(DYE_FLAGS "${DYE_FLAGS} -DDEBUG")
- ENDIF()
-ENDIF()
-
-IF (WIN32)
- SET(EXTRA_LIBRARIES ws2_32 winmm)
- FIND_PACKAGE(LibIntl REQUIRED)
-ELSEIF (CMAKE_SYSTEM_NAME STREQUAL "Darwin" OR BEOS)
- FIND_PACKAGE(LibIntl REQUIRED)
-ELSEIF (CMAKE_SYSTEM_NAME STREQUAL SunOS)
- # explicit linking to libintl is required on Solaris
- SET(EXTRA_LIBRARIES intl)
-ELSEIF (CMAKE_SYSTEM_NAME STREQUAL Linux)
- #some distros need this explicitly linked
- SET(EXTRA_LIBRARIES rt)
-ENDIF()
-
-SET(FLAGS "${FLAGS} -DUSE_MUMBLE")
-
-IF (WITH_OPENGL)
- FIND_PACKAGE(OpenGL REQUIRED)
- INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR})
- SET(FLAGS "${FLAGS} -DUSE_OPENGL")
-ENDIF (WITH_OPENGL)
-
-IF (USE_X11)
- FIND_PACKAGE(X11 REQUIRED)
- INCLUDE_DIRECTORIES(${X11_INCLUDE_DIR})
- SET(FLAGS "${FLAGS} -DUSE_X11")
-ENDIF (USE_X11)
-
-INCLUDE_DIRECTORIES(
- ${CMAKE_CURRENT_SOURCE_DIR}
- ${SDL_INCLUDE_DIR}
- ${SDLIMAGE_INCLUDE_DIR}
- ${SDLMIXER_INCLUDE_DIR}
- ${SDLNET_INCLUDE_DIR}
- ${SDLTTF_INCLUDE_DIR}
- ${SDLGFX_INCLUDE_DIR}
- ${PNG_INCLUDE_DIR}
- ${CURL_INCLUDE_DIR}
- ${LIBXML2_INCLUDE_DIR}
- )
-
-# enable rc-handling with mingw
-# most likely this part can be kicked out with some later cmake version
-IF (MINGW)
- FIND_PATH(MINGW_INCLUDE_DIR windows.h $ENV{INCLUDE})
- IF (MINGW_INCLUDE_DIR)
- MESSAGE(STATUS "Found mingw headers: ${MINGW_INCLUDE_DIR}")
- INCLUDE_DIRECTORIES(${MINGW_INCLUDE_DIR})
- ELSE()
- MESSAGE(FATAL_ERROR "Unable to find mingw headers. Required for windres")
- ENDIF()
- SET(CMAKE_RC_COMPILER_INIT windres)
- ENABLE_LANGUAGE(RC)
- SET(CMAKE_RC_COMPILE_OBJECT
- "<CMAKE_RC_COMPILER> <FLAGS> <DEFINES> -O coff -o <OBJECT> <SOURCE>")
-ENDIF()
-
-# Fix some stuff that gets not hidden by mainline modules
-MARK_AS_ADVANCED(SDLIMAGE_INCLUDE_DIR)
-MARK_AS_ADVANCED(SDLIMAGE_LIBRARY)
-MARK_AS_ADVANCED(SDLMAIN_LIBRARY)
-MARK_AS_ADVANCED(SDLMIXER_INCLUDE_DIR)
-MARK_AS_ADVANCED(SDLMIXER_LIBRARY)
-MARK_AS_ADVANCED(SDLNET_INCLUDE_DIR)
-MARK_AS_ADVANCED(SDLNET_LIBRARY)
-MARK_AS_ADVANCED(SDL_INCLUDE_DIR)
-MARK_AS_ADVANCED(SDL_LIBRARY)
-
-SET(SRCS
- gui/widgets/avatarlistbox.cpp
- gui/widgets/avatarlistbox.h
- gui/models/avatarlistmodel.h
- gui/models/beingslistmodel.h
- gui/models/colorlistmodel.h
- gui/widgets/tabs/chat/battletab.cpp
- gui/widgets/tabs/chat/battletab.h
- gui/widgets/tabs/chat/channeltab.cpp
- gui/widgets/tabs/chat/channeltab.h
- gui/widgets/browserbox.cpp
- gui/widgets/browserbox.h
- gui/widgets/browserbox.inc
- gui/widgets/button.cpp
- gui/widgets/button.h
- gui/widgets/characterdisplay.cpp
- gui/widgets/characterdisplay.h
- gui/widgets/characterviewbase.h
- gui/widgets/characterviewnormal.cpp
- gui/widgets/characterviewnormal.h
- gui/widgets/characterviewsmall.cpp
- gui/widgets/characterviewsmall.h
- gui/widgets/attrs/attrdisplay.cpp
- gui/widgets/attrs/attrdisplay.h
- gui/widgets/attrs/changedisplay.cpp
- gui/widgets/attrs/changedisplay.h
- gui/widgets/attrs/derdisplay.cpp
- gui/widgets/attrs/derdisplay.h
- gui/widgets/tabs/debugwindowtabs.cpp
- gui/widgets/tabs/debugwindowtabs.h
- gui/widgets/tabs/chat/chattab.cpp
- gui/widgets/tabs/chat/chattab.h
- gui/widgets/chatinput.h
- gui/widgets/checkbox.cpp
- gui/widgets/checkbox.h
- gui/models/colormodel.cpp
- gui/models/colormodel.h
- gui/widgets/colorpage.cpp
- gui/widgets/colorpage.h
- gui/widgets/container.cpp
- gui/widgets/container.h
- gui/widgets/containerplacer.cpp
- gui/widgets/containerplacer.h
- gui/widgets/createwidget.h
- gui/widgets/desktop.cpp
- gui/widgets/desktop.h
- gui/widgets/dropdown.cpp
- gui/widgets/dropdown.h
- gui/widgets/emoteshortcutcontainer.cpp
- gui/widgets/emoteshortcutcontainer.h
- gui/widgets/equipmentbox.h
- gui/widgets/equipmentpage.h
- gui/widgets/extendedlistbox.cpp
- gui/widgets/extendedlistbox.h
- gui/widgets/extendedlistboxitem.h
- gui/models/extendedlistmodel.h
- gui/models/extendednamesmodel.cpp
- gui/models/extendednamesmodel.h
- gui/models/fontsizechoicelistmodel.h
- gui/models/fontsmodel.h
- gui/models/iconsmodel.h
- gui/models/ignorechoiceslistmodel.h
- gui/models/itemsmodel.h
- gui/models/keylistmodel.h
- gui/models/langlistmodel.h
- gui/widgets/flowcontainer.cpp
- gui/widgets/flowcontainer.h
- gui/widgets/tabs/chat/gmtab.cpp
- gui/widgets/tabs/chat/gmtab.h
- gui/widgets/tabs/chat/guildtab.cpp
- gui/widgets/tabs/chat/guildtab.h
- gui/widgets/tabs/chat/partytab.cpp
- gui/widgets/tabs/chat/partytab.h
- gui/widgets/horizontcontainer.cpp
- gui/widgets/horizontcontainer.h
- gui/widgets/icon.cpp
- gui/widgets/icon.h
- gui/widgets/inttextfield.cpp
- gui/widgets/inttextfield.h
- gui/widgets/itemcontainer.cpp
- gui/widgets/itemcontainer.h
- gui/widgets/itemlinkhandler.cpp
- gui/widgets/itemlinkhandler.h
- gui/widgets/virtshortcutcontainer.cpp
- gui/widgets/virtshortcutcontainer.h
- gui/widgets/emotepage.cpp
- gui/widgets/emotepage.h
- gui/widgets/itemshortcutcontainer.cpp
- gui/widgets/itemshortcutcontainer.h
- gui/widgets/spellshortcutcontainer.cpp
- gui/widgets/spellshortcutcontainer.h
- gui/widgets/staticbrowserbox.cpp
- gui/widgets/staticbrowserbox.h
- gui/widgets/statspage.cpp
- gui/widgets/statspage.h
- gui/widgets/statspagebasic.cpp
- gui/widgets/statspagebasic.h
- gui/widgets/label.cpp
- gui/widgets/label.h
- gui/widgets/tabs/chat/langtab.cpp
- gui/widgets/tabs/chat/langtab.h
- gui/widgets/layout.cpp
- gui/widgets/layout.h
- gui/widgets/layoutarray.cpp
- gui/widgets/layoutarray.h
- gui/widgets/layoutcell.cpp
- gui/widgets/layoutcell.h
- gui/widgets/layouthelper.cpp
- gui/widgets/layouthelper.h
- enums/gui/layouttype.h
- enums/gui/linkhighlightmode.h
- enums/gui/npcactionstate.h
- enums/gui/npcinputstate.h
- gui/widgets/linepart.cpp
- gui/widgets/linepart.h
- gui/widgets/linkhandler.h
- gui/widgets/listbox.cpp
- gui/widgets/listbox.h
- gui/models/modelistmodel.cpp
- gui/models/modelistmodel.h
- gui/models/namesmodel.cpp
- gui/models/namesmodel.h
- gui/models/opengllistmodel.h
- gui/models/playerrelationlistmodel.h
- gui/models/playertablemodel.cpp
- gui/models/playertablemodel.h
- gui/models/questsmodel.h
- gui/models/serverslistmodel.h
- gui/widgets/passwordfield.cpp
- gui/widgets/passwordfield.h
- gui/widgets/playerbox.cpp
- gui/widgets/playerbox.h
- gui/widgets/popup.cpp
- gui/widgets/popup.h
- gui/widgets/popuplist.cpp
- gui/widgets/popuplist.h
- gui/widgets/progressbar.cpp
- gui/widgets/progressbar.h
- gui/widgets/progressindicator.cpp
- gui/widgets/progressindicator.h
- gui/widgets/radiobutton.cpp
- gui/widgets/radiobutton.h
- gui/widgets/radiogroup.cpp
- gui/widgets/radiogroup.h
- gui/widgets/scrollarea.cpp
- gui/widgets/scrollarea.h
- gui/widgets/serverslistbox.h
- gui/widgets/setupbuttonitem.cpp
- gui/widgets/setupbuttonitem.h
- gui/widgets/setupitem.cpp
- gui/widgets/setupitem.h
- gui/widgets/setupquickitem.cpp
- gui/widgets/setupquickitem.h
- gui/widgets/tabs/setuptab.cpp
- gui/widgets/tabs/setuptab.h
- gui/widgets/tabs/setuptabscroll.cpp
- gui/widgets/tabs/setuptabscroll.h
- gui/widgets/setuptouchitem.cpp
- gui/widgets/setuptouchitem.h
- gui/models/shopitems.cpp
- gui/models/shopitems.h
- gui/widgets/shoplistbox.cpp
- gui/widgets/shoplistbox.h
- gui/widgets/shortcutcontainer.cpp
- gui/widgets/shortcutcontainer.h
- resources/skill/skilldata.cpp
- resources/skill/skilldata.h
- resources/skill/skillinfo.cpp
- resources/skill/skillinfo.h
- gui/widgets/skilllistbox.h
- gui/widgets/skillrectanglelistbox.h
- gui/models/skillmodel.cpp
- gui/models/skillmodel.h
- gui/models/sortlistmodelbuy.h
- gui/models/sortlistmodelinv.h
- gui/models/soundsmodel.h
- gui/widgets/slider.cpp
- gui/widgets/slider.h
- gui/widgets/sliderlist.cpp
- gui/widgets/sliderlist.h
- gui/widgets/tabs/shortcuttab.h
- gui/widgets/tabs/skilltab.h
- gui/widgets/tabs/socialattacktab.h
- gui/widgets/tabs/socialfriendsfunctor.h
- gui/widgets/tabs/socialfriendstab.h
- gui/widgets/tabs/socialguildtab.h
- gui/widgets/tabs/socialnavigationtab.h
- gui/widgets/tabs/socialpartytab.h
- gui/widgets/tabs/socialpickuptab.h
- gui/widgets/tabs/socialplayerstab.h
- gui/widgets/tabs/socialtab.h
- gui/widgets/tabs/socialtabbase.h
- gui/widgets/tabs/tab.cpp
- gui/widgets/tabs/tab.h
- gui/widgets/tabbedarea.cpp
- gui/widgets/tabbedarea.h
- gui/widgets/guitable.cpp
- gui/widgets/guitable.h
- gui/models/tablemodel.cpp
- gui/models/tablemodel.h
- gui/models/targettypemodel.h
- gui/models/touchactionmodel.cpp
- gui/models/touchactionmodel.h
- gui/models/typelistmodel.h
- gui/models/updatetypemodel.h
- gui/models/updatelistmodel.h
- gui/models/worldlistmodel.h
- gui/models/themesmodel.h
- gui/widgets/tabstrip.cpp
- gui/widgets/tabstrip.h
- gui/widgets/textbox.cpp
- gui/widgets/textbox.h
- gui/widgets/textfield.cpp
- gui/widgets/textfield.h
- gui/widgets/textpreview.cpp
- gui/widgets/textpreview.h
- gui/widgets/tabs/chat/tradetab.cpp
- gui/widgets/tabs/chat/tradetab.h
- gui/widgets/vertcontainer.cpp
- gui/widgets/vertcontainer.h
- gui/widgets/tabs/chat/whispertab.cpp
- gui/widgets/tabs/chat/whispertab.h
- gui/widgets/widget2.h
- gui/widgets/widgetgroup.cpp
- gui/widgets/widgetgroup.h
- gui/widgets/window.cpp
- gui/widgets/window.h
- gui/widgets/windowcontainer.cpp
- gui/widgets/windowcontainer.h
- gui/popups/beingpopup.cpp
- gui/popups/beingpopup.h
- gui/windows/buydialog.cpp
- gui/windows/buydialog.h
- gui/windows/buyselldialog.cpp
- gui/windows/buyselldialog.h
- gui/windows/changeemaildialog.cpp
- gui/windows/changeemaildialog.h
- gui/windows/changepassworddialog.cpp
- gui/windows/changepassworddialog.h
- gui/windows/charselectdialog.cpp
- gui/windows/charselectdialog.h
- gui/windows/charcreatedialog.cpp
- gui/windows/charcreatedialog.h
- gui/windows/chardeleteconfirm.h
- gui/windows/chatwindow.cpp
- gui/windows/chatwindow.h
- gui/windows/confirmdialog.cpp
- gui/windows/confirmdialog.h
- gui/windows/connectiondialog.cpp
- gui/windows/connectiondialog.h
- gui/windows/cutinwindow.cpp
- gui/windows/cutinwindow.h
- gui/windows/debugwindow.cpp
- gui/windows/debugwindow.h
- gui/windows/didyouknowwindow.cpp
- gui/windows/didyouknowwindow.h
- gui/windows/editdialog.cpp
- gui/windows/editdialog.h
- gui/windows/editserverdialog.cpp
- gui/windows/editserverdialog.h
- gui/windows/emotewindow.cpp
- gui/windows/emotewindow.h
- gui/windows/equipmentwindow.cpp
- gui/windows/equipmentwindow.h
- gui/focushandler.cpp
- gui/focushandler.h
- gui/gui.cpp
- gui/gui.h
- gui/mailmessage.h
- gui/mouseoverlink.h
- gui/windows/helpwindow.cpp
- gui/windows/helpwindow.h
- gui/windows/insertcarddialog.cpp
- gui/windows/insertcarddialog.h
- gui/windows/inventorywindow.cpp
- gui/windows/inventorywindow.h
- gui/windows/itemamountwindow.cpp
- gui/windows/itemamountwindow.h
- gui/popups/itempopup.cpp
- gui/popups/itempopup.h
- gui/popups/spellpopup.cpp
- gui/popups/spellpopup.h
- gui/popups/statuspopup.cpp
- gui/popups/statuspopup.h
- gui/popups/textboxpopup.cpp
- gui/popups/textboxpopup.h
- gui/windows/killstats.cpp
- gui/windows/killstats.h
- gui/windows/logindialog.cpp
- gui/windows/logindialog.h
- gui/windows/minimap.cpp
- gui/windows/minimap.h
- gui/windows/ministatuswindow.cpp
- gui/windows/ministatuswindow.h
- gui/windows/npcdialog.cpp
- gui/windows/npcdialog.h
- gui/windows/npcselldialog.cpp
- gui/windows/npcselldialog.h
- gui/windows/okdialog.cpp
- gui/windows/okdialog.h
- gui/windows/outfitwindow.cpp
- gui/windows/outfitwindow.h
- gui/windows/textcommandeditor.cpp
- gui/windows/textcommandeditor.h
- gui/onlineplayer.h
- gui/palette.cpp
- gui/palette.h
- gui/popupmanager.cpp
- gui/popupmanager.h
- gui/popups/popupmenu.cpp
- gui/popups/popupmenu.h
- gui/popups/skillpopup.cpp
- gui/popups/skillpopup.h
- gui/windows/questswindow.cpp
- gui/windows/questswindow.h
- gui/windows/quitdialog.cpp
- gui/windows/quitdialog.h
- gui/windows/registerdialog.cpp
- gui/windows/registerdialog.h
- gui/sdlinput.cpp
- gui/sdlinput.h
- gui/widgets/selldialog.cpp
- gui/widgets/selldialog.h
- gui/windows/serverdialog.cpp
- gui/windows/serverdialog.h
- gui/windows/serverinfowindow.cpp
- gui/windows/serverinfowindow.h
- gui/windows/setupwindow.cpp
- gui/windows/setupwindow.h
- gui/widgets/tabs/setup_audio.cpp
- gui/widgets/tabs/setup_audio.h
- gui/widgets/tabs/setup_colors.cpp
- gui/widgets/tabs/setup_colors.h
- gui/widgets/tabs/setup_joystick.cpp
- gui/widgets/tabs/setup_joystick.h
- gui/widgets/tabs/setup_misc.cpp
- gui/widgets/tabs/setup_misc.h
- gui/widgets/tabs/setup_mods.cpp
- gui/widgets/tabs/setup_mods.h
- gui/widgets/tabs/setup_theme.cpp
- gui/widgets/tabs/setup_theme.h
- gui/widgets/tabs/setup_touch.cpp
- gui/widgets/tabs/setup_touch.h
- gui/widgets/tabs/setup_chat.cpp
- gui/widgets/tabs/setup_chat.h
- gui/widgets/tabs/setup_input.cpp
- gui/widgets/tabs/setup_input.h
- gui/widgets/tabs/setup_perfomance.cpp
- gui/widgets/tabs/setup_perfomance.h
- gui/widgets/tabs/setup_relations.cpp
- gui/widgets/tabs/setup_relations.h
- gui/widgets/tabs/setup_players.cpp
- gui/widgets/tabs/setup_players.h
- gui/widgets/tabs/setup_quick.cpp
- gui/widgets/tabs/setup_quick.h
- gui/widgets/tabs/setup_video.cpp
- gui/widgets/tabs/setup_video.h
- gui/widgets/tabs/setup_visual.cpp
- gui/widgets/tabs/setup_visual.h
- gui/setupactiondata.h
- gui/setupinputpages.cpp
- gui/setupinputpages.h
- input/pages/basic.cpp
- input/pages/basic.h
- input/pages/chat.cpp
- input/pages/chat.h
- input/pages/craft.cpp
- input/pages/craft.h
- input/pages/emotes.cpp
- input/pages/emotes.h
- input/pages/gui.cpp
- input/pages/gui.h
- input/pages/move.cpp
- input/pages/move.h
- input/pages/other.cpp
- input/pages/other.h
- input/pages/outfits.cpp
- input/pages/outfits.h
- input/pages/shortcuts.cpp
- input/pages/shortcuts.h
- input/pages/windows.cpp
- input/pages/windows.h
- gui/fonts/font.cpp
- gui/fonts/font.h
- gui/fonts/textchunk.cpp
- gui/fonts/textchunk.h
- gui/fonts/textchunklist.cpp
- gui/fonts/textchunklist.h
- gui/fonts/textchunksmall.cpp
- gui/fonts/textchunksmall.h
- gui/windows/shopwindow.cpp
- gui/windows/shopwindow.h
- gui/windows/shortcutwindow.cpp
- gui/windows/shortcutwindow.h
- gui/windows/skilldialog.cpp
- gui/windows/skilldialog.h
- gui/windows/socialwindow.cpp
- gui/windows/socialwindow.h
- gui/popups/speechbubble.cpp
- gui/popups/speechbubble.h
- gui/windows/statuswindow.cpp
- gui/windows/statuswindow.h
- gui/windows/textdialog.cpp
- gui/windows/textdialog.h
- gui/windows/textselectdialog.cpp
- gui/windows/textselectdialog.h
- gui/popups/textpopup.cpp
- gui/popups/textpopup.h
- gui/skin.cpp
- gui/skin.h
- gui/theme.cpp
- gui/theme.h
- gui/themecolorsidoperators.cpp
- gui/themecolorsidoperators.h
- gui/themeinfo.h
- gui/touchactiondata.cpp
- gui/touchactiondata.h
- gui/windows/tradewindow.cpp
- gui/windows/tradewindow.h
- gui/windows/updaterwindow.cpp
- gui/windows/updaterwindow.h
- gui/userpalette.cpp
- gui/userpalette.h
- progs/manaplus/gui/viewport.cpp
- progs/manaplus/gui/viewport.h
- gui/viewport.h
- gui/windowmanager.cpp
- gui/windowmanager.h
- gui/windows/whoisonline.cpp
- gui/windows/whoisonline.h
- gui/windowmenu.cpp
- gui/windowmenu.h
- gui/windows/worldselectdialog.cpp
- gui/windows/worldselectdialog.h
- net/adminhandler.h
- net/character.h
- net/characters.h
- net/charserverhandler.cpp
- net/charserverhandler.h
- net/chathandler.h
- net/download.cpp
- net/download.h
- enums/net/auctionsearchtype.h
- enums/net/battlegroundtype.h
- enums/net/deleteitemreason.h
- enums/net/downloadstatus.h
- enums/net/mailmessagetype.h
- enums/net/mailopentype.h
- enums/net/npcaction.h
- enums/net/packettype.h
- net/gamehandler.h
- net/generalhandler.h
- net/guildhandler.h
- net/inventoryhandler.h
- net/ipc.cpp
- net/ipc.h
- net/ea/inventoryitem.h
- net/logindata.h
- net/loginhandler.h
- net/messagein.cpp
- net/messagein.h
- net/messageout.cpp
- net/messageout.h
- net/npchandler.h
- net/net.cpp
- net/net.h
- const/net/inventory.h
- const/net/maxpacketversion.h
- const/net/net.h
- const/net/nostat.h
- net/partyhandler.h
- enums/net/partyshare.h
- enums/net/serverfreetype.h
- enums/net/servertype.h
- enums/net/storesearchtype.h
- net/pethandler.h
- net/playerhandler.h
- net/sdltcpnet.cpp
- net/sdltcpnet.h
- net/serverfeatures.h
- net/serverinfo.h
- net/serverurlinfo.h
- net/skillhandler.h
- net/tradehandler.h
- net/updatetypeoperators.cpp
- net/updatetypeoperators.h
- enums/net/updatetype.h
- net/uploadcharinfo.h
- net/useragent.cpp
- net/useragent.h
- net/worldinfo.h
- net/packetcounters.cpp
- net/packetcounters.h
- net/packetfunction.h
- net/packetinfo.h
- net/packetlimiter.cpp
- net/packetlimiter.h
- net/protocoloutdefine.h
- net/protocoloutinclude.h
- net/protocoloutupdate.h
- net/recvpacketdefine.h
- resources/action.cpp
- resources/action.h
- resources/ambientlayer.cpp
- resources/ambientlayer.h
- resources/animation/animation.cpp
- resources/animation/animation.h
- resources/atlas/atlasitem.h
- resources/atlas/atlasmanager.cpp
- resources/atlas/atlasmanager.h
- resources/atlas/atlasresource.cpp
- resources/atlas/atlasresource.h
- resources/rect/doublerect.h
- resources/attack.h
- resources/db/avatardb.cpp
- resources/db/avatardb.h
- resources/db/badgesdb.cpp
- resources/db/badgesdb.h
- resources/beingcommon.cpp
- resources/beingcommon.h
- resources/beinginfo.cpp
- resources/beinginfo.h
- resources/beingmenuitem.h
- resources/beingslot.cpp
- resources/beingslot.h
- resources/chatobject.cpp
- resources/chatobject.h
- resources/db/chardb.cpp
- resources/db/chardb.h
- resources/db/colordb.cpp
- resources/db/colordb.h
- resources/db/commandsdb.cpp
- resources/db/commandsdb.h
- resources/cursors.cpp
- resources/cursors.h
- resources/dbmanager.cpp
- resources/dbmanager.h
- resources/delayedmanager.cpp
- resources/delayedmanager.h
- resources/db/deaddb.cpp
- resources/db/deaddb.h
- resources/db/elementaldb.cpp
- resources/db/elementaldb.h
- resources/dye/dye.cpp
- resources/dye/dye.h
- resources/dye/dyecolor.h
- resources/dye/dyepalette.cpp
- resources/dye/dyepalette.h
- resources/dye/dyepalette_replaceacolor.cpp
- resources/dye/dyepalette_replaceaoglcolor.cpp
- resources/dye/dyepalette_replacescolor.cpp
- resources/dye/dyepalette_replacesoglcolor.cpp
- resources/dye/dyepaletteptr.h
- resources/effectdescription.h
- resources/emoteinfo.h
- resources/emotesprite.h
- resources/equipmentslots.h
- resources/db/emotedb.cpp
- resources/db/emotedb.h
- resources/db/groupdb.cpp
- resources/db/groupdb.h
- resources/db/homunculusdb.cpp
- resources/db/homunculusdb.h
- resources/db/horsedb.cpp
- resources/db/horsedb.h
- resources/fboinfo.h
- resources/frame.h
- resources/groupinfo.cpp
- resources/groupinfo.h
- resources/horseinfo.h
- resources/horseoffset.h
- resources/image/image.cpp
- resources/image/image.h
- resources/imagehelper.cpp
- resources/imagehelper.h
- resources/imagerect.h
- resources/imageset.h
- resources/imageset.cpp
- resources/itemcolordata.h
- resources/db/itemdb.cpp
- resources/db/itemdb.h
- resources/basicstat.h
- resources/db/itemfielddb.cpp
- resources/db/itemfielddb.h
- resources/db/itemoptiondb.cpp
- resources/db/itemoptiondb.h
- resources/db/languagedb.cpp
- resources/db/languagedb.h
- resources/iteminfo.h
- resources/iteminfo.cpp
- resources/itemmenuitem.h
- enums/resources/cursor.h
- enums/resources/displaytype.h
- enums/resources/frametype.h
- enums/resources/imageposition.h
- enums/resources/imagetype.h
- enums/resources/mailqueuetype.h
- enums/resources/map/maplayertype.h
- enums/resources/item/itemdbtype.h
- enums/resources/item/itemsoundevent.h
- enums/resources/item/itemtype.h
- resources/itemtypemap.h
- resources/itemtypemapdata.h
- resources/mailqueue.h
- resources/db/mapdb.cpp
- resources/db/mapdb.h
- resources/db/mercenarydb.cpp
- resources/db/mercenarydb.h
- resources/db/moddb.cpp
- resources/db/moddb.h
- resources/mapinfo.h
- enums/resources/map/mapitemtype.h
- enums/resources/map/maplayerposition.h
- resources/mapreader.cpp
- resources/mapreader.h
- resources/memorycounter.cpp
- resources/memorycounter.h
- resources/memorymanager.cpp
- resources/memorymanager.h
- resources/missileinfo.h
- resources/mobileopenglscreenshothelper.cpp
- resources/mobileopenglscreenshothelper.h
- resources/modinfo.cpp
- resources/modinfo.h
- resources/mstack.h
- resources/notificationinfo.h
- resources/notifications.h
- resources/npcbuttoninfo.h
- resources/npcdialoginfo.h
- resources/npcdialogmenuinfo.h
- resources/npcimageinfo.h
- resources/npcinventoryinfo.h
- resources/npctextinfo.h
- enums/resources/notifyflags.h
- enums/resources/notifytypes.h
- resources/db/monsterdb.cpp
- resources/db/monsterdb.h
- resources/db/networkdb.cpp
- resources/db/networkdb.h
- resources/db/npcdb.cpp
- resources/db/npcdb.h
- resources/db/npcdialogdb.cpp
- resources/db/npcdialogdb.h
- resources/openglimagehelper.cpp
- resources/openglimagehelper.h
- resources/openglscreenshothelper.cpp
- resources/openglscreenshothelper.h
- resources/questeffect.h
- resources/questitem.h
- resources/questitemtext.h
- resources/questvar.h
- enums/resources/questtype.h
- enums/resources/servercommandenable.h
- enums/resources/servercommandtype.h
- enums/resources/serverpermissiontype.h
- resources/db/palettedb.cpp
- resources/db/palettedb.h
- resources/db/petdb.cpp
- resources/db/petdb.h
- resources/db/questdb.cpp
- resources/db/questdb.h
- resources/db/skillunitdb.cpp
- resources/db/skillunitdb.h
- resources/resource.cpp
- resources/resource.h
- resources/resourcefunctiontypes.h
- resources/resourcetypes.h
- resources/loaders/atlasloader.cpp
- resources/loaders/atlasloader.h
- resources/loaders/emptyatlasloader.cpp
- resources/loaders/emptyatlasloader.h
- resources/loaders/imageloader.cpp
- resources/loaders/imageloader.h
- resources/loaders/imagesetloader.cpp
- resources/loaders/imagesetloader.h
- resources/loaders/musicloader.cpp
- resources/loaders/musicloader.h
- resources/loaders/rescaledloader.cpp
- resources/loaders/rescaledloader.h
- resources/loaders/shaderloader.cpp
- resources/loaders/shaderloader.h
- resources/loaders/shaderprogramloader.cpp
- resources/loaders/shaderprogramloader.h
- resources/loaders/soundloader.cpp
- resources/loaders/soundloader.h
- resources/loaders/spritedefloader.cpp
- resources/loaders/spritedefloader.h
- resources/loaders/subimageloader.cpp
- resources/loaders/subimageloader.h
- resources/loaders/subimagesetloader.cpp
- resources/loaders/subimagesetloader.h
- resources/loaders/walklayerloader.cpp
- resources/loaders/walklayerloader.h
- resources/loaders/xmlloader.cpp
- resources/loaders/xmlloader.h
- resources/resourcemanager/resourcemanager.cpp
- resources/resourcemanager/resourcemanager.h
- resources/safeopenglimagehelper.cpp
- resources/safeopenglimagehelper.h
- resources/screenshothelper.h
- resources/sdl2imagehelper.cpp
- resources/sdl2imagehelper.h
- resources/sdl2softwareimagehelper.cpp
- resources/sdl2softwareimagehelper.h
- resources/sdl2softwarescreenshothelper.cpp
- resources/sdl2softwarescreenshothelper.h
- resources/sdlgfxblitfunc.cpp
- resources/sdlgfxblitfunc.h
- resources/sdlimagehelper.cpp
- resources/sdlimagehelper.h
- resources/sdlmusic.cpp
- resources/sdlmusic.h
- resources/sdlscreenshothelper.cpp
- resources/sdlscreenshothelper.h
- resources/skill/skilltypeentry.h
- resources/skill/skilltypelist.h
- const/net/skill.h
- const/resources/currency.h
- const/resources/skill.h
- enums/resources/skill/skillowner.h
- enums/resources/skill/skillsettype.h
- enums/resources/skill/skilltype.h
- enums/resources/skill/skilltype2.h
- resources/db/sounddb.cpp
- resources/db/sounddb.h
- resources/db/statdb.cpp
- resources/db/statdb.h
- resources/db/statuseffectdb.cpp
- resources/db/statuseffectdb.h
- resources/db/textdb.cpp
- resources/db/textdb.h
- resources/db/unitsdb.cpp
- resources/db/unitsdb.h
- resources/db/weaponsdb.cpp
- resources/db/weaponsdb.h
- resources/servercommands.inc
- resources/serverpermissions.inc
- resources/soundeffect.cpp
- resources/soundeffect.h
- resources/soundinfo.h
- const/resources/spriteaction.h
- resources/sprite/spritedef.h
- resources/sprite/spritedef.cpp
- enums/resources/spritedirection.h
- resources/sprite/spritedisplay.h
- resources/sprite/spritereference.h
- resources/image/subimage.cpp
- resources/image/subimage.h
- resources/surfaceimagehelper.cpp
- resources/surfaceimagehelper.h
- resources/atlas/textureatlas.h
- resources/updatefile.h
- resources/wallpaper.cpp
- resources/wallpaper.h
- resources/wallpaperdata.h
- utils/translation/podict.cpp
- utils/translation/podict.h
- utils/translation/poparser.cpp
- utils/translation/poparser.h
- utils/translation/translationmanager.cpp
- utils/translation/translationmanager.h
- utils/base64.cpp
- utils/base64.h
- utils/booleanoptions.h
- utils/browserboxtools.cpp
- utils/browserboxtools.h
- utils/buildhex.h
- utils/cast.h
- utils/chatutils.cpp
- utils/chatutils.h
- utils/checkutils.cpp
- utils/checkutils.h
- utils/copynpaste.cpp
- utils/copynpaste.h
- utils/cpu.cpp
- utils/cpu.h
- utils/delete2.h
- utils/dtor.h
- utils/dumplibs.cpp
- utils/dumplibs.h
- utils/dumpsizes.cpp
- utils/dumpsizes.h
- utils/env.cpp
- utils/env.h
- utils/foreach.h
- fs/files.cpp
- fs/files.h
- utils/fuzzer.cpp
- utils/fuzzer.h
- utils/gettext.h
- utils/gettexthelper.cpp
- utils/gettexthelper.h
- utils/glxhelper.cpp
- utils/glxhelper.h
- utils/gmfunctions.cpp
- utils/gmfunctions.h
- utils/intmap.h
- utils/langs.cpp
- utils/langs.h
- utils/likely.h
- utils/mathutils.h
- utils/parameters.cpp
- utils/parameters.h
- fs/paths.cpp
- fs/paths.h
- utils/perfomance.cpp
- utils/perfomance.h
- utils/pnglib.cpp
- utils/pnglib.h
- fs/virtfs/fsfuncs.h
- fs/virtfs/rwops.cpp
- fs/virtfs/rwops.h
- fs/virtfs/tools.cpp
- fs/virtfs/tools.h
- fs/virtfs/list.cpp
- fs/virtfs/list.h
- fs/virtfs/fs.cpp
- fs/virtfs/fs.h
- fs/virtfs/rwopstypes.h
- fs/virtfs/direntry.cpp
- fs/virtfs/direntry.h
- fs/virtfs/fsdir.cpp
- fs/virtfs/fsdir.h
- fs/virtfs/fsdirrwops.cpp
- fs/virtfs/fsdirrwops.h
- fs/virtfs/fsentry.cpp
- fs/virtfs/fsentry.h
- fs/virtfs/fszip.cpp
- fs/virtfs/fszip.h
- fs/virtfs/fsziprwops.cpp
- fs/virtfs/fsziprwops.h
- fs/virtfs/zipentry.cpp
- fs/virtfs/zipentry.h
- fs/virtfs/zipreader.cpp
- fs/virtfs/zipreader.h
- fs/virtfs/ziplocalheader.cpp
- fs/virtfs/ziplocalheader.h
- utils/process.cpp
- utils/process.h
- utils/sdl2helper.cpp
- utils/sdl2helper.h
- utils/sdl2logger.cpp
- utils/sdl2logger.h
- utils/sdlcheckutils.cpp
- utils/sdlcheckutils.h
- utils/sdlhelper.cpp
- utils/sdlhelper.h
- utils/sdlmemoryobject.h
- utils/stringmap.h
- utils/stringutils.cpp
- utils/stringutils.h
- utils/stringvector.h
- utils/timer.cpp
- utils/timer.h
- utils/vector.h
- utils/x11logger.cpp
- utils/x11logger.h
- fs/virtfs/file.cpp
- fs/virtfs/file.h
- utils/mutex.h
- utils/naclmessages.cpp
- utils/naclmessages.h
- fs/mkdir.cpp
- fs/mkdir.h
- utils/mrand.cpp
- utils/mrand.h
- utils/xml.h
- utils/xml.inc
- utils/xmlutils.cpp
- utils/xmlutils.h
- utils/xmlwriter.h
- utils/xml/libxml.cpp
- utils/xml/libxml.h
- utils/xml/libxml.inc
- test/testlauncher.cpp
- test/testlauncher.h
- test/testmain.cpp
- test/testmain.h
- actions/actiondef.h
- actions/actionfuncptr.h
- progs/manaplus/actions/actions.cpp
- actions/actions.h
- progs/manaplus/actions/chat.cpp
- actions/chat.h
- progs/manaplus/actions/commands.cpp
- actions/commands.h
- progs/manaplus/actions/move.cpp
- actions/move.h
- progs/manaplus/actions/pets.cpp
- actions/pets.h
- progs/manaplus/actions/statusbar.cpp
- actions/statusbar.h
- progs/manaplus/actions/tabs.cpp
- actions/tabs.h
- progs/manaplus/actions/target.cpp
- actions/target.h
- progs/manaplus/actions/windows.cpp
- actions/windows.h
- being/actor.cpp
- being/actor.h
- being/actorsprite.cpp
- being/actorsprite.h
- enums/being/actortype.h
- enums/being/attacktype.h
- enums/being/attributes.h
- enums/being/attributesstrings.cpp
- enums/being/attributesstrings.h
- enums/being/badgedrawtype.h
- enums/being/badgeindex.h
- listeners/actorspritelistener.h
- listeners/arrowslistener.cpp
- listeners/arrowslistener.h
- listeners/assertlistener.cpp
- listeners/assertlistener.h
- listeners/attributelistener.cpp
- listeners/attributelistener.h
- listeners/awaylistener.cpp
- listeners/awaylistener.h
- listeners/baselistener.hpp
- listeners/charrenamelistener.cpp
- listeners/charrenamelistener.h
- actormanager.cpp
- actormanager.h
- resources/sprite/animatedsprite.cpp
- resources/sprite/animatedsprite.h
- resources/sprite/animationdelayload.cpp
- resources/sprite/animationdelayload.h
- particle/animationparticle.cpp
- particle/animationparticle.h
- avatar.cpp
- avatar.h
- being/being.cpp
- being/being.h
- enums/being/beingaction.h
- being/beingcacheentry.h
- enums/being/beingdirection.h
- being/beingflag.h
- being/beingspeech.h
- being/castingeffect.cpp
- being/castingeffect.h
- beingequipbackend.cpp
- beingequipbackend.h
- spellmanager.cpp
- spellmanager.h
- chatlogger.cpp
- chatlogger.h
- progs/manaplus/client.cpp
- progs/manaplus/client.h
- client.h
- commandline.cpp
- commandline.h
- configmanager.cpp
- configmanager.h
- being/compounditem.h
- being/compoundsprite.cpp
- being/compoundsprite.h
- being/crazymoves.cpp
- being/crazymoves.h
- enums/being/cookingtype.h
- enums/being/gender.h
- being/homunculusinfo.h
- listeners/configlistener.h
- listeners/debugmessagelistener.cpp
- listeners/debugmessagelistener.h
- configuration.cpp
- configuration.h
- debug.h
- defaults.cpp
- defaults.h
- dirs.cpp
- dirs.h
- dragdrop.h
- effectmanager.cpp
- effectmanager.h
- gui/shortcut/emoteshortcut.cpp
- gui/shortcut/emoteshortcut.h
- const/emoteshortcut.h
- equipment.h
- eventsmanager.cpp
- eventsmanager.h
- being/flooritem.cpp
- being/flooritem.h
- game.cpp
- game.h
- gamemodifiers.cpp
- gamemodifiers.h
- const/equipment.h
- const/itemshortcut.h
- const/spells.h
- const/utils/timer.h
- const/utils/utf8.h
- const/gui/chat.h
- const/gui/pages.h
- const/gui/theme.h
- const/render/graphics.h
- render/graphics.cpp
- render/graphics.h
- graphicsmanager.cpp
- graphicsmanager.h
- render/vertexes/imagecollection.cpp
- render/vertexes/imagecollection.h
- render/vertexes/imagevertexes.cpp
- render/vertexes/imagevertexes.h
- render/vertexes/openglgraphicsvertexes.cpp
- render/vertexes/openglgraphicsvertexes.h
- guild.cpp
- guild.h
- enums/commandtarget.h
- enums/cutin.h
- enums/dragdropsource.h
- enums/emotetype.h
- enums/equipslot.h
- enums/guildpositionflags.h
- enums/inventorytype.h
- enums/magicschool.h
- particle/imageparticle.cpp
- particle/imageparticle.h
- resources/sprite/imagesprite.cpp
- resources/sprite/imagesprite.h
- resources/inventory/complexinventory.cpp
- resources/inventory/complexinventory.h
- resources/inventory/inventory.cpp
- resources/inventory/inventory.h
- resources/item/cardslist.cpp
- resources/item/cardslist.h
- resources/item/complexitem.cpp
- resources/item/complexitem.h
- resources/item/item.cpp
- resources/item/item.h
- resources/item/itemfieldtype.h
- resources/item/itemoption.h
- resources/item/itemoptionslist.h
- itemcolormanager.cpp
- itemcolormanager.h
- gui/shortcut/itemshortcut.cpp
- gui/shortcut/itemshortcut.h
- itemsoundmanager.cpp
- itemsoundmanager.h
- gui/shortcut/dropshortcut.cpp
- gui/shortcut/dropshortcut.h
- gui/shortcut/spellshortcut.cpp
- gui/shortcut/spellshortcut.h
- textcommand.cpp
- textcommand.h
- enums/input/inputaction.h
- enums/input/inputgroup.h
- input/inputactiondata.h
- input/inputactionmap.h
- input/inputactionoperators.cpp
- input/inputactionoperators.h
- input/inputactionsortfunctor.h
- enums/input/inputcondition.h
- input/inputfunction.h
- input/inputitem.h
- input/inputmanager.cpp
- input/inputmanager.h
- enums/input/inputtype.h
- enums/input/keyboardfocus.h
- enums/input/keyvalue.h
- events/inputevent.h
- input/joystick.cpp
- input/joystick.h
- input/keyboardconfig.cpp
- input/keyboardconfig.h
- input/keyinput.h
- input/touch/multitouchmanager.cpp
- input/touch/multitouchmanager.h
- localconsts.h
- being/localplayer.cpp
- being/localplayer.h
- being/mercenaryinfo.h
- being/petinfo.h
- enums/being/pickup.h
- logger.cpp
- logger.h
- main.cpp
- main.h
- maingui.cpp
- maingui.h
- enums/resources/map/blockmask.h
- enums/resources/map/blocktype.h
- enums/resources/map/collisiontype.h
- enums/resources/skill/casttype.h
- resources/map/location.h
- resources/map/map.cpp
- resources/map/map.h
- const/resources/item/cards.h
- const/resources/item/itemoptions.h
- const/resources/map/map.h
- resources/map/mapheights.cpp
- resources/map/mapheights.h
- resources/map/mapitem.cpp
- resources/map/mapitem.h
- resources/map/maplayer.cpp
- resources/map/maplayer.h
- resources/map/mapobject.h
- resources/map/mapobjectlist.h
- resources/map/maprowvertexes.h
- enums/resources/map/maptype.h
- resources/map/metatile.h
- resources/map/objectslayer.cpp
- resources/map/objectslayer.h
- render/opengl/mgl.cpp
- render/opengl/mgl.h
- render/opengl/mgl.hpp
- render/opengl/mglcheck.h
- render/opengl/mgldefines.h
- render/opengl/mglemu.cpp
- render/opengl/mglemu.h
- render/opengl/mglfunctions.h
- render/opengl/mgltypes.h
- render/openglx/mglx.cpp
- render/openglx/mglx.h
- render/openglx/mglx.hpp
- render/openglx/mglxinit.cpp
- render/openglx/mglxinit.h
- render/openglx/mglxtypes.h
- render/mobileopengl2graphics.cpp
- render/mobileopengl2graphics.h
- render/mobileopenglgraphics.cpp
- render/mobileopenglgraphics.h
- render/modernopenglgraphics.cpp
- render/modernopenglgraphics.h
- render/nacl/naclfunctions.h
- render/nacl/naclgles.cpp
- render/nacl/naclgles.h
- input/mouseinput.h
- mumblemanager.cpp
- mumblemanager.h
- navigationmanager.cpp
- navigationmanager.h
- render/opengl/naclglfunctions.h
- render/normalopenglgraphics.cpp
- render/normalopenglgraphics.h
- notifymanager.cpp
- notifymanager.h
- options.h
- render/graphicsdef.hpp
- render/imagegraphics.cpp
- render/imagegraphics.h
- render/graphics_calcImageRect.hpp
- render/graphics_drawImageRect.hpp
- render/nullopenglgraphics.cpp
- render/nullopenglgraphics.h
- render/opengl/opengldebug.h
- render/openglgraphicsdef.hpp
- render/openglgraphicsdef1.hpp
- render/openglgraphicsdefadvanced.hpp
- render/renderers.cpp
- render/renderers.h
- render/rendererslistsdl.h
- render/rendererslistsdl2.h
- enums/particle/alivestatus.h
- enums/particle/particlechangefunc.h
- enums/particle/particlephysics.h
- enums/particle/particletype.h
- enums/render/rendertype.h
- particle/particle.cpp
- particle/particle.h
- particle/particlecontainer.cpp
- particle/particlecontainer.h
- particle/particleemitter.cpp
- particle/particleemitter.h
- particle/particleemitterprop.h
- particle/particleengine.cpp
- particle/particleengine.h
- particle/particleinfo.h
- particle/particlelist.cpp
- particle/particlelist.h
- particle/particletimer.h
- particle/particlevector.cpp
- particle/particlevector.h
- party.cpp
- party.h
- being/playerignorestrategy.h
- being/playerinfo.cpp
- being/playerinfo.h
- being/playerrelation.cpp
- being/playerrelation.h
- being/playerrelations.cpp
- being/playerrelations.h
- enums/being/rank.h
- enums/being/reachable.h
- enums/being/relation.h
- enums/being/targetcursorsize.h
- enums/being/targetcursortype.h
- enums/being/visiblename.h
- enums/being/visiblenamepos.h
- listeners/playerrelationslistener.h
- listeners/renamelistener.cpp
- listeners/renamelistener.h
- listeners/requestadoptchildlistener.h
- listeners/requesttradelistener.h
- position.cpp
- position.h
- resources/map/properties.h
- resources/map/speciallayer.cpp
- resources/map/speciallayer.h
- resources/map/tileanimation.cpp
- resources/map/tileanimation.h
- particle/rotationalparticle.cpp
- particle/rotationalparticle.h
- render/safeopenglgraphics.cpp
- render/safeopenglgraphics.h
- render/sdl2graphics.cpp
- render/sdl2graphics.h
- render/sdl2softwaregraphics.cpp
- render/sdl2softwaregraphics.h
- render/sdlgraphics.cpp
- render/sdlgraphics.h
- render/softwaregraphicsdef.hpp
- sdlshared.h
- settings.cpp
- settings.h
- resources/item/shopitem.cpp
- resources/item/shopitem.h
- gui/shortcut/shortcutbase.cpp
- gui/shortcut/shortcutbase.h
- resources/animation/simpleanimation.cpp
- resources/animation/simpleanimation.h
- const/sound.h
- soundmanager.cpp
- soundmanager.h
- resources/sprite/sprite.h
- enums/screendensity.h
- enums/state.h
- enums/textcommandtype.h
- enums/simpletypes/advanced.h
- enums/simpletypes/allowquit.h
- enums/simpletypes/allowsort.h
- enums/simpletypes/allplayers.h
- enums/simpletypes/append.h
- enums/simpletypes/autorelease.h
- enums/simpletypes/autotarget.h
- enums/simpletypes/beingid.h
- enums/simpletypes/beingtypeid.h
- enums/simpletypes/booldefines.h
- enums/simpletypes/damaged.h
- enums/simpletypes/donotalign.h
- enums/simpletypes/enable.h
- enums/simpletypes/enumdefines.h
- enums/simpletypes/equipm.h
- enums/simpletypes/equipped.h
- enums/simpletypes/favorite.h
- enums/simpletypes/forcedisplay.h
- enums/simpletypes/forcequantity.h
- enums/simpletypes/identified.h
- enums/simpletypes/ignorerecord.h
- enums/simpletypes/intdefines.h
- enums/simpletypes/issell.h
- enums/simpletypes/isstart.h
- enums/simpletypes/itemcolor.h
- enums/simpletypes/keep.h
- enums/simpletypes/losefocusontab.h
- enums/simpletypes/mainconfig.h
- enums/simpletypes/modal.h
- enums/simpletypes/modifiable.h
- enums/simpletypes/move.h
- enums/simpletypes/notify.h
- enums/simpletypes/npcnames.h
- enums/simpletypes/online.h
- enums/simpletypes/onthefly.h
- enums/simpletypes/opaque.h
- enums/simpletypes/protected.h
- enums/simpletypes/separator.h
- enums/simpletypes/sfx.h
- enums/simpletypes/showcenter.h
- enums/simpletypes/showemptyrows.h
- enums/simpletypes/skiperror.h
- enums/simpletypes/speech.h
- enums/simpletypes/stringdefines.h
- enums/simpletypes/stringdefines2.h
- enums/simpletypes/trading.h
- enums/simpletypes/tryremovecolors.h
- enums/simpletypes/useargs.h
- enums/simpletypes/usebase64.h
- enums/simpletypes/usevirtfs.h
- enums/simpletypes/visible.h
- statuseffect.cpp
- statuseffect.h
- render/surfacegraphics.cpp
- render/surfacegraphics.h
- render/shaders/shader.cpp
- render/shaders/shader.h
- render/shaders/shaderprogram.cpp
- render/shaders/shaderprogram.h
- render/shaders/shadersmanager.cpp
- render/shaders/shadersmanager.h
- text.cpp
- text.h
- textmanager.cpp
- textmanager.h
- particle/textparticle.cpp
- particle/textparticle.h
- resources/map/tileinfo.h
- resources/map/tileset.h
- input/touch/touchactions.cpp
- input/touch/touchactions.h
- input/touch/touchmanager.cpp
- input/touch/touchmanager.h
- variabledata.h
- vector.cpp
- vector.h
- resources/map/walklayer.cpp
- resources/map/walklayer.h
- events/actionevent.h
- listeners/actionlistener.h
- gui/widgets/basiccontainer.h
- gui/browserlink.h
- gui/buttoninfo.h
- gui/buttontext.h
- const/gui/chat.h
- gui/chatlog.h
- enums/gui/chatmsgtype.h
- enums/gui/chattabtype.h
- enums/gui/colorname.h
- gui/cliprect.h
- gui/color.h
- gui/colorpair.h
- enums/gui/dialogtype.h
- enums/gui/gradienttype.h
- enums/gui/itemamountwindowusage.h
- enums/gui/orientation.h
- enums/gui/progresscolorid.h
- enums/gui/serverdialogdonwloadstatus.h
- enums/gui/shoplistboxtype.h
- enums/gui/slidergrid.h
- enums/gui/themecolorid.h
- enums/gui/updatedownloadstatus.h
- enums/gui/usercolorid.h
- listeners/errorlistener.cpp
- listeners/errorlistener.h
- listeners/widgetdeathlistener.h
- events/event.h
- listeners/focuslistener.h
- listeners/gamemodifierlistener.cpp
- listeners/gamemodifierlistener.h
- listeners/guiconfiglistener.h
- listeners/guitableactionlistener.cpp
- listeners/guitableactionlistener.h
- listeners/inputactionremotelistener.cpp
- listeners/inputactionremotelistener.h
- listeners/inputactionreplaylistener.cpp
- listeners/inputactionreplaylistener.h
- listeners/insertcardlistener.h
- listeners/inventorylistener.h
- events/inputguievent.h
- input/key.h
- events/keyevent.h
- enums/events/keyeventtype.h
- listeners/keylistener.h
- gui/models/listmodel.h
- gui/models/magicschoolmodel.h
- events/mouseevent.h
- enums/events/mousebutton.h
- enums/events/mouseeventtype.h
- listeners/mouselistener.h
- listeners/openurllistener.h
- listeners/playerdeathlistener.cpp
- listeners/playerdeathlistener.h
- listeners/playerpostdeathlistener.h
- listeners/playerlistener.cpp
- listeners/playerlistener.h
- gui/rect.h
- events/selectionevent.h
- listeners/selectionlistener.h
- listeners/statlistener.cpp
- listeners/statlistener.h
- listeners/tablemodellistener.h
- listeners/textskilllistener.cpp
- listeners/textskilllistener.h
- listeners/tooltiplistener.cpp
- listeners/tooltiplistener.h
- listeners/updatestatuslistener.cpp
- listeners/updatestatuslistener.h
- listeners/uploadlistener.cpp
- listeners/uploadlistener.h
- utils/sdlpixel.h
- utils/sdlsharedhelper.cpp
- utils/sdlsharedhelper.h
- utils/stdmove.h
- gui/widgets/widget.h
- listeners/weightlistener.h
- listeners/widgetlistener.h
- listeners/wrongdatanoticelistener.cpp
- listeners/wrongdatanoticelistener.h
- gui/widgets/basiccontainer2.h
- gui/widgets/basiccontainer.cpp
- gui/dialogsmanager.cpp
- gui/dialogsmanager.h
- input/key.cpp
- gui/widgets/widget.cpp
- gui/widgets/basiccontainer2.cpp
- gui/windows/bankwindow.cpp
- gui/windows/bankwindow.h
- gui/windows/buyingstoreselldialog.cpp
- gui/windows/buyingstoreselldialog.h
- gui/windows/eggselectiondialog.cpp
- gui/windows/eggselectiondialog.h
- gui/windows/maileditwindow.cpp
- gui/windows/maileditwindow.h
- gui/windows/mailviewwindow.cpp
- gui/windows/mailviewwindow.h
- gui/windows/mailwindow.cpp
- gui/windows/mailwindow.h
- listeners/banklistener.cpp
- listeners/banklistener.h
- listeners/buyingstoremodelistener.cpp
- listeners/buyingstoremodelistener.h
- listeners/buyingstoreslotslistener.cpp
- listeners/buyingstoreslotslistener.h
- listeners/pincodelistener.cpp
- listeners/pincodelistener.h
- listeners/shoprenamelistener.cpp
- listeners/shoprenamelistener.h
- listeners/skillwarplistener.cpp
- listeners/skillwarplistener.h
- listeners/vendingmodelistener.cpp
- listeners/vendingmodelistener.h
- listeners/vendingslotslistener.cpp
- listeners/vendingslotslistener.h
- net/auctionhandler.h
- net/bankhandler.h
- net/battlegroundhandler.h
- net/buyingstorehandler.h
- net/cashshophandler.h
- net/elementalhandler.h
- net/familyhandler.h
- net/friendshandler.h
- net/homunculushandler.h
- net/hostsgroup.h
- net/mailhandler.h
- net/mail2handler.h
- net/maphandler.h
- net/markethandler.h
- net/mercenaryhandler.h
- net/roulettehandler.h
- net/searchstorehandler.h
- net/vendinghandler.h
- net/eathena/adminrecv.cpp
- net/eathena/adminrecv.h
- net/eathena/adminhandler.cpp
- net/eathena/adminhandler.h
- net/eathena/auctionrecv.cpp
- net/eathena/auctionrecv.h
- net/eathena/auctionhandler.cpp
- net/eathena/auctionhandler.h
- net/eathena/bankrecv.cpp
- net/eathena/bankrecv.h
- net/eathena/bankhandler.cpp
- net/eathena/bankhandler.h
- net/eathena/battlegroundrecv.cpp
- net/eathena/battlegroundrecv.h
- net/eathena/battlegroundhandler.cpp
- net/eathena/battlegroundhandler.h
- net/eathena/cashshophandler.cpp
- net/eathena/cashshophandler.h
- net/eathena/cashshoprecv.cpp
- net/eathena/cashshoprecv.h
- net/eathena/beingrecv.cpp
- net/eathena/beingrecv.h
- net/eathena/beinghandler.cpp
- net/eathena/beinghandler.h
- net/eathena/buyingstorehandler.cpp
- net/eathena/buyingstorehandler.h
- net/eathena/buyingstorerecv.cpp
- net/eathena/buyingstorerecv.h
- enums/net/beingtype.h
- net/eathena/buysellhandler.cpp
- net/eathena/buysellhandler.h
- net/eathena/buysellrecv.cpp
- net/eathena/buysellrecv.h
- net/eathena/charserverhandler.cpp
- net/eathena/charserverhandler.h
- net/eathena/charserverrecv.cpp
- net/eathena/charserverrecv.h
- net/eathena/chathandler.cpp
- net/eathena/chathandler.h
- net/eathena/chatrecv.cpp
- net/eathena/chatrecv.h
- net/eathena/elementalhandler.cpp
- net/eathena/elementalhandler.h
- net/eathena/elementalrecv.cpp
- net/eathena/elementalrecv.h
- net/eathena/familyhandler.cpp
- net/eathena/familyhandler.h
- net/eathena/familyrecv.cpp
- net/eathena/familyrecv.h
- net/eathena/friendshandler.cpp
- net/eathena/friendshandler.h
- net/eathena/friendsrecv.cpp
- net/eathena/friendsrecv.h
- net/eathena/gamehandler.cpp
- net/eathena/gamehandler.h
- net/eathena/gamerecv.cpp
- net/eathena/gamerecv.h
- net/eathena/generalhandler.cpp
- net/eathena/generalhandler.h
- net/eathena/generalrecv.cpp
- net/eathena/generalrecv.h
- net/eathena/guildhandler.cpp
- net/eathena/guildhandler.h
- net/eathena/guildrecv.cpp
- net/eathena/guildrecv.h
- net/eathena/homunculushandler.cpp
- net/eathena/homunculushandler.h
- net/eathena/homunculusrecv.cpp
- net/eathena/homunculusrecv.h
- net/eathena/inventoryhandler.cpp
- net/eathena/inventoryhandler.h
- net/eathena/inventoryrecv.cpp
- net/eathena/inventoryrecv.h
- net/eathena/itemflags.h
- net/eathena/itemhandler.cpp
- net/eathena/itemhandler.h
- net/eathena/itemrecv.cpp
- net/eathena/itemrecv.h
- net/eathena/loginhandler.cpp
- net/eathena/loginhandler.h
- net/eathena/loginrecv.cpp
- net/eathena/loginrecv.h
- net/eathena/mail2recv.cpp
- net/eathena/mail2recv.h
- net/eathena/mail2handler.cpp
- net/eathena/mail2handler.h
- net/eathena/mailhandler.cpp
- net/eathena/mailhandler.h
- net/eathena/mailrecv.cpp
- net/eathena/mailrecv.h
- net/eathena/maphandler.cpp
- net/eathena/maphandler.h
- net/eathena/maprecv.cpp
- net/eathena/maprecv.h
- net/eathena/maptypeproperty2.h
- net/eathena/markethandler.cpp
- net/eathena/markethandler.h
- net/eathena/marketrecv.cpp
- net/eathena/marketrecv.h
- net/eathena/menu.cpp
- net/eathena/menu.h
- enums/net/menutype.h
- net/eathena/mercenaryhandler.cpp
- net/eathena/mercenaryhandler.h
- net/eathena/mercenaryrecv.cpp
- net/eathena/mercenaryrecv.h
- net/eathena/messagein.cpp
- net/eathena/messagein.h
- net/eathena/messageout.cpp
- net/eathena/messageout.h
- net/eathena/network.cpp
- net/eathena/network.h
- net/eathena/npchandler.cpp
- net/eathena/npchandler.h
- net/eathena/npcrecv.cpp
- net/eathena/npcrecv.h
- net/eathena/packetsin.inc
- net/eathena/packetsout.inc
- net/eathena/partyhandler.cpp
- net/eathena/partyhandler.h
- net/eathena/partyrecv.cpp
- net/eathena/partyrecv.h
- net/eathena/pethandler.cpp
- net/eathena/pethandler.h
- net/eathena/petrecv.cpp
- net/eathena/petrecv.h
- net/eathena/playerhandler.cpp
- net/eathena/playerhandler.h
- net/eathena/playerrecv.cpp
- net/eathena/playerrecv.h
- net/eathena/protocolout.cpp
- net/eathena/protocolout.h
- net/eathena/questhandler.cpp
- net/eathena/questhandler.h
- net/eathena/questrecv.cpp
- net/eathena/questrecv.h
- net/eathena/recvpackets.inc
- net/eathena/roulettehandler.cpp
- net/eathena/roulettehandler.h
- net/eathena/rouletterecv.cpp
- net/eathena/rouletterecv.h
- net/eathena/searchstorehandler.cpp
- net/eathena/searchstorehandler.h
- net/eathena/searchstorerecv.cpp
- net/eathena/searchstorerecv.h
- net/eathena/serverfeatures.cpp
- net/eathena/serverfeatures.h
- net/eathena/skillhandler.cpp
- net/eathena/skillhandler.h
- net/eathena/skillrecv.cpp
- net/eathena/skillrecv.h
- net/eathena/sp.h
- net/eathena/sprite.h
- net/eathena/tradehandler.cpp
- net/eathena/tradehandler.h
- net/eathena/traderecv.cpp
- net/eathena/traderecv.h
- net/eathena/updateprotocol.cpp
- net/eathena/updateprotocol.h
- net/eathena/vendinghandler.cpp
- net/eathena/vendinghandler.h
- net/eathena/vendingrecv.cpp
- net/eathena/vendingrecv.h
- )
-
-SET(DYE_CMD_SRCS
- gui/cliprect.cpp
- gui/rect.cpp
- events/actionevent.h
- gui/cliprect.h
- gui/color.h
- events/event.h
- gui/rect.h
- progs/dyecmd/dyemain.cpp
- resources/sprite/animatedsprite.cpp
- resources/sprite/animatedsprite.h
- resources/sprite/animationdelayload.cpp
- resources/sprite/animationdelayload.h
- configuration.cpp
- configuration.h
- graphicsmanager.cpp
- graphicsmanager.h
- render/vertexes/imagecollection.cpp
- render/vertexes/imagecollection.h
- render/vertexes/imagevertexes.cpp
- render/vertexes/imagevertexes.h
- render/vertexes/openglgraphicsvertexes.cpp
- render/vertexes/openglgraphicsvertexes.h
- logger.cpp
- logger.h
- navigationmanager.cpp
- navigationmanager.h
- settings.cpp
- settings.h
- listeners/debugmessagelistener.cpp
- listeners/debugmessagelistener.h
- resources/map/walklayer.cpp
- resources/map/walklayer.h
- render/graphics.cpp
- render/graphics.h
- render/renderers.cpp
- render/renderers.h
- render/sdl2softwaregraphics.cpp
- render/sdl2softwaregraphics.h
- render/sdl2graphics.cpp
- render/sdl2graphics.h
- render/sdlgraphics.cpp
- render/sdlgraphics.h
- render/softwaregraphicsdef.hpp
- render/mgltypes.h
- resources/action.cpp
- resources/action.h
- resources/animation/animation.cpp
- resources/animation/animation.h
- resources/db/palettedb.cpp
- resources/db/palettedb.h
- resources/delayedmanager.cpp
- resources/delayedmanager.h
- resources/dye/dye.cpp
- resources/dye/dye.h
- resources/dye/dyepalette.cpp
- resources/dye/dyepalette.h
- resources/effectdescription.h
- resources/emoteinfo.h
- resources/emotesprite.h
- resources/image/image.cpp
- resources/image/image.h
- resources/imagehelper.cpp
- resources/imagehelper.h
- resources/imagerect.h
- resources/imageset.cpp
- resources/imageset.h
- resources/itemcolordata.h
- resources/resource.cpp
- resources/resource.h
- resources/resourcefunctiontypes.h
- resources/resourcetypes.h
- resources/loaders/atlasloader.cpp
- resources/loaders/atlasloader.h
- resources/loaders/emptyatlasloader.cpp
- resources/loaders/emptyatlasloader.h
- resources/loaders/imageloader.cpp
- resources/loaders/imageloader.h
- resources/loaders/imagesetloader.cpp
- resources/loaders/imagesetloader.h
- resources/loaders/musicloader.cpp
- resources/loaders/musicloader.h
- resources/loaders/rescaledloader.cpp
- resources/loaders/rescaledloader.h
- resources/loaders/shaderloader.cpp
- resources/loaders/shaderloader.h
- resources/loaders/shaderprogramloader.cpp
- resources/loaders/shaderprogramloader.h
- resources/loaders/spritedefloader.cpp
- resources/loaders/spritedefloader.h
- resources/loaders/subimageloader.cpp
- resources/loaders/subimageloader.h
- resources/loaders/subimagesetloader.cpp
- resources/loaders/subimagesetloader.h
- resources/loaders/walklayerloader.cpp
- resources/loaders/walklayerloader.h
- resources/resourcemanager/resourcemanager.cpp
- resources/resourcemanager/resourcemanager.h
- resources/sdl2softwareimagehelper.cpp
- resources/sdl2softwareimagehelper.h
- resources/sdl2imagehelper.cpp
- resources/sdl2imagehelper.h
- resources/sdlgfxblitfunc.cpp
- resources/sdlgfxblitfunc.h
- resources/sdlimagehelper.cpp
- resources/sdlimagehelper.h
- resources/sdlmusic.cpp
- resources/sdlmusic.h
- resources/skillconsts.h
- resources/servercommands.inc
- resources/serverpermissions.inc
- resources/soundeffect.cpp
- resources/soundeffect.h
- resources/image/subimage.cpp
- resources/image/subimage.h
- resources/surfaceimagehelper.cpp
- resources/surfaceimagehelper.h
- resources/atlas/textureatlas.h
- resources/updatefile.h
- resources/sprite/spritedef.cpp
- resources/sprite/spritedef.h
- resources/sprite/spritedisplay.h
- resources/sprite/spritereference.h
- fs/files.cpp
- fs/files.h
- fs/mkdir.cpp
- fs/mkdir.h
- utils/mrand.cpp
- utils/mrand.h
- fs/paths.cpp
- fs/paths.h
- utils/perfomance.cpp
- utils/perfomance.h
- utils/pnglib.cpp
- utils/pnglib.h
- fs/virtfs/fsfuncs.h
- fs/virtfs/rwops.cpp
- fs/virtfs/rwops.h
- fs/virtfs/tools.cpp
- fs/virtfs/tools.h
- fs/virtfs/list.cpp
- fs/virtfs/list.h
- fs/virtfs/fs.cpp
- fs/virtfs/fs.h
- fs/virtfs/rwopstypes.h
- fs/virtfs/direntry.cpp
- fs/virtfs/direntry.h
- fs/virtfs/fsdir.cpp
- fs/virtfs/fsdir.h
- fs/virtfs/fsdirrwops.cpp
- fs/virtfs/fsdirrwops.h
- fs/virtfs/fsentry.cpp
- fs/virtfs/fsentry.h
- fs/virtfs/fszip.cpp
- fs/virtfs/fszip.h
- fs/virtfs/fsziprwops.cpp
- fs/virtfs/fsziprwops.h
- fs/virtfs/zipentry.cpp
- fs/virtfs/zipentry.h
- fs/virtfs/zipreader.cpp
- fs/virtfs/zipreader.h
- fs/virtfs/ziplocalheader.cpp
- fs/virtfs/ziplocalheader.h
- utils/sdl2helper.cpp
- utils/sdl2helper.h
- utils/sdl2logger.cpp
- utils/sdl2logger.h
- utils/sdlcheckutils.cpp
- utils/sdlcheckutils.h
- utils/sdlhelper.cpp
- utils/sdlhelper.h
- utils/sdlmemoryobject.h
- utils/stringutils.cpp
- utils/stringutils.h
- utils/timer.cpp
- utils/timer.h
- utils/vector.h
- utils/x11logger.cpp
- utils/x11logger.h
- fs/virtfs/virtfile.cpp
- fs/virtfs/virtfile.h
- utils/xml.cpp
- utils/xml.h
- utils/xml.inc
- utils/xmlutils.cpp
- utils/xmlutils.h
- utils/translation/podict.cpp
- utils/translation/podict.h
-)
-
-SET(SRCS_EVOL
- net/ea/adminrecv.cpp
- net/ea/adminrecv.h
- net/ea/adminhandler.cpp
- net/ea/adminhandler.h
- net/ea/beingrecv.cpp
- net/ea/beingrecv.h
- net/ea/beinghandler.cpp
- net/ea/beinghandler.h
- net/ea/buysellhandler.cpp
- net/ea/buysellhandler.h
- net/ea/buysellrecv.cpp
- net/ea/buysellrecv.h
- net/ea/charserverhandler.cpp
- net/ea/charserverhandler.h
- net/ea/charserverrecv.cpp
- net/ea/charserverrecv.h
- net/ea/chathandler.cpp
- net/ea/chathandler.h
- net/ea/chatrecv.cpp
- net/ea/chatrecv.h
- net/ea/eaprotocol.h
- net/ea/equipbackend.h
- net/ea/gamehandler.cpp
- net/ea/gamehandler.h
- net/ea/gamerecv.cpp
- net/ea/gamerecv.h
- net/ea/inventoryhandler.cpp
- net/ea/inventoryhandler.h
- net/ea/inventoryrecv.cpp
- net/ea/inventoryrecv.h
- net/ea/itemhandler.cpp
- net/ea/itemhandler.h
- net/ea/itemrecv.cpp
- net/ea/itemrecv.h
- net/ea/loginhandler.cpp
- net/ea/loginhandler.h
- net/ea/loginrecv.cpp
- net/ea/loginrecv.h
- net/ea/network.cpp
- net/ea/network.h
- net/ea/maprecv.cpp
- net/ea/maprecv.h
- net/ea/npchandler.cpp
- net/ea/npchandler.h
- net/ea/npcrecv.cpp
- net/ea/npcrecv.h
- net/ea/partyhandler.cpp
- net/ea/partyhandler.h
- net/ea/partyrecv.cpp
- net/ea/partyrecv.h
- net/ea/playerhandler.cpp
- net/ea/playerhandler.h
- net/ea/playerrecv.cpp
- net/ea/playerrecv.h
- net/ea/skillhandler.cpp
- net/ea/skillhandler.h
- net/ea/skillrecv.cpp
- net/ea/skillrecv.h
- net/ea/token.h
- net/ea/tradehandler.cpp
- net/ea/tradehandler.h
- net/ea/traderecv.cpp
- net/ea/traderecv.h
- )
-
-SET(SRCS_TMWA
- gui/widgets/tabs/chat/emulateguildtab.cpp
- gui/widgets/tabs/chat/emulateguildtab.h
- gui/windows/shopselldialog.cpp
- gui/windows/shopselldialog.h
- net/tmwa/adminhandler.cpp
- net/tmwa/adminhandler.h
- net/tmwa/beingrecv.cpp
- net/tmwa/beingrecv.h
- net/tmwa/beinghandler.cpp
- net/tmwa/beinghandler.h
- net/tmwa/buysellhandler.cpp
- net/tmwa/buysellhandler.h
- net/tmwa/buysellrecv.cpp
- net/tmwa/buysellrecv.h
- net/tmwa/charserverhandler.cpp
- net/tmwa/charserverhandler.h
- net/tmwa/charserverrecv.cpp
- net/tmwa/charserverrecv.h
- net/tmwa/chathandler.cpp
- net/tmwa/chathandler.h
- net/tmwa/chatrecv.cpp
- net/tmwa/chatrecv.h
- net/tmwa/gamehandler.cpp
- net/tmwa/gamehandler.h
- net/tmwa/gamerecv.cpp
- net/tmwa/gamerecv.h
- net/tmwa/generalhandler.cpp
- net/tmwa/generalhandler.h
- net/tmwa/generalrecv.cpp
- net/tmwa/generalrecv.h
- net/tmwa/guildhandler.cpp
- net/tmwa/guildhandler.h
- net/tmwa/guildmanager.cpp
- net/tmwa/guildmanager.h
- net/tmwa/inventoryhandler.cpp
- net/tmwa/inventoryhandler.h
- net/tmwa/inventoryrecv.cpp
- net/tmwa/inventoryrecv.h
- net/tmwa/itemhandler.cpp
- net/tmwa/itemhandler.h
- net/tmwa/itemrecv.cpp
- net/tmwa/itemrecv.h
- net/tmwa/loginhandler.cpp
- net/tmwa/loginhandler.h
- net/tmwa/loginrecv.cpp
- net/tmwa/loginrecv.h
- net/tmwa/messagein.cpp
- net/tmwa/messagein.h
- net/tmwa/messageout.cpp
- net/tmwa/messageout.h
- net/tmwa/network.cpp
- net/tmwa/network.h
- net/tmwa/npchandler.cpp
- net/tmwa/npchandler.h
- net/tmwa/packetsin.inc
- net/tmwa/packetsout.inc
- net/tmwa/partyhandler.cpp
- net/tmwa/partyhandler.h
- net/tmwa/partyrecv.cpp
- net/tmwa/partyrecv.h
- net/tmwa/pethandler.cpp
- net/tmwa/pethandler.h
- net/tmwa/playerhandler.cpp
- net/tmwa/playerhandler.h
- net/tmwa/playerrecv.cpp
- net/tmwa/playerrecv.h
- net/tmwa/protocolout.cpp
- net/tmwa/protocolout.h
- net/tmwa/questhandler.cpp
- net/tmwa/questhandler.h
- net/tmwa/questrecv.cpp
- net/tmwa/questrecv.h
- net/tmwa/recvpackets.inc
- net/tmwa/serverfeatures.cpp
- net/tmwa/serverfeatures.h
- net/tmwa/skillhandler.cpp
- net/tmwa/skillhandler.h
- net/tmwa/skillrecv.cpp
- net/tmwa/skillrecv.h
- net/tmwa/sp.h
- net/tmwa/sprite.h
- net/tmwa/tradehandler.cpp
- net/tmwa/tradehandler.h
- net/tmwa/traderecv.cpp
- net/tmwa/traderecv.h
- net/tmwa/updateprotocol.cpp
- net/tmwa/updateprotocol.h
- net/tmwa/auctionhandler.cpp
- net/tmwa/auctionhandler.h
- net/tmwa/bankhandler.cpp
- net/tmwa/bankhandler.h
- net/tmwa/battlegroundhandler.cpp
- net/tmwa/battlegroundhandler.h
- net/tmwa/buyingstorehandler.cpp
- net/tmwa/buyingstorehandler.h
- net/tmwa/cashshophandler.cpp
- net/tmwa/cashshophandler.h
- net/tmwa/elementalhandler.cpp
- net/tmwa/elementalhandler.h
- net/tmwa/familyhandler.cpp
- net/tmwa/familyhandler.h
- net/tmwa/friendshandler.cpp
- net/tmwa/friendshandler.h
- net/tmwa/homunculushandler.cpp
- net/tmwa/homunculushandler.h
- net/tmwa/mailhandler.cpp
- net/tmwa/mailhandler.h
- net/tmwa/mail2handler.cpp
- net/tmwa/mail2handler.h
- net/tmwa/maphandler.cpp
- net/tmwa/maphandler.h
- net/tmwa/markethandler.cpp
- net/tmwa/markethandler.h
- net/tmwa/mercenaryhandler.cpp
- net/tmwa/mercenaryhandler.h
- net/tmwa/roulettehandler.cpp
- net/tmwa/roulettehandler.h
- net/tmwa/searchstorehandler.cpp
- net/tmwa/searchstorehandler.h
- net/tmwa/vendinghandler.cpp
- net/tmwa/vendinghandler.h
- gui/widgets/tabs/socialguildtab2.h
- )
-
-IF (WIN32)
- SET(SRCS
- ${SRCS}
- fs/specialfolder.cpp
- fs/specialfolder.h
- manaplus.rc
- )
- SET(DYE_CMD_SRCS
- ${DYE_CMD_SRCS}
- fs/specialfolder.cpp
- fs/specialfolder.h
- manaplus.rc
- )
-ENDIF ()
-
-#SET (PROGRAMS manaplus dyecmd)
-SET (PROGRAMS manaplus)
-
-IF (ENABLE_TMWA)
- SET(SRCS ${SRCS} ${SRCS_TMWA})
-ELSE()
- SET(SRCS ${SRCS})
-ENDIF(ENABLE_TMWA)
-
-ADD_EXECUTABLE(manaplus WIN32 ${SRCS} ${SRCS_EVOL})
-#ADD_EXECUTABLE(dyecmd WIN32 ${DYE_CMD_SRCS})
-
-TARGET_LINK_LIBRARIES(manaplus
- ${X11_LIBRARIES}
- ${SDLGFX_LIBRARIES}
- ${SDL_LIBRARY}
- ${SDLIMAGE_LIBRARY}
- ${SDLMIXER_LIBRARY}
- ${SDLNET_LIBRARY}
- ${SDLTTF_LIBRARY}
- ${PNG_LIBRARIES}
- ${ZLIB_LIBRARIES}
- ${CURL_LIBRARIES}
- ${LIBXML2_LIBRARIES}
- ${OPENGL_LIBRARIES}
- ${LIBINTL_LIBRARIES}
- ${EXTRA_LIBRARIES})
-INSTALL(TARGETS manaplus RUNTIME DESTINATION ${PKG_BINDIR})
-
-#TARGET_LINK_LIBRARIES(dyecmd
-# ${SDLGFX_LIBRARIES}
-# ${SDL_LIBRARY}
-# ${SDLIMAGE_LIBRARY}
-# ${SDLMIXER_LIBRARY}
-# ${SDLNET_LIBRARY}
-# ${SDLTTF_LIBRARY}
-# ${PNG_LIBRARIES}
-# ${ZLIB_LIBRARIES}
-# ${CURL_LIBRARIES}
-# ${LIBXML2_LIBRARIES}
-# ${OPENGL_LIBRARIES}
-# ${LIBINTL_LIBRARIES}
-# ${EXTRA_LIBRARIES})
-#INSTALL(TARGETS dyecmd RUNTIME DESTINATION ${PKG_BINDIR})
-
-IF (CMAKE_SYSTEM_NAME STREQUAL SunOS)
- # we expect the SMCgtxt package to be present on Solaris;
- # the Solaris gettext is not API-compatible to GNU gettext
- SET_TARGET_PROPERTIES(manaplus PROPERTIES LINK_FLAGS "-L/usr/local/lib")
-# SET_TARGET_PROPERTIES(dyecmd PROPERTIES LINK_FLAGS "-L/usr/local/lib")
-ENDIF()
-
-SET_TARGET_PROPERTIES(manaplus PROPERTIES COMPILE_FLAGS "${FLAGS}")
-#SET_TARGET_PROPERTIES(dyecmd PROPERTIES COMPILE_FLAGS "${DYE_FLAGS}")
diff --git a/src/Makefile.am b/src/Makefile.am
deleted file mode 100644
index 7f22f0507..000000000
--- a/src/Makefile.am
+++ /dev/null
@@ -1,2148 +0,0 @@
-AUTOMAKE_OPTIONS = subdir-objects
-
-.rc.o:
- ${WINDRES} -o $@ $<
-
-# this need for enable asan in tests
-#AM_TESTS_ENVIRONMENT = \
-# ASAN_OPTIONS=detect_leaks=1
-
-if ENABLE_MANAPLUSGAME
-if ENABLE_DYECMD
-bin_PROGRAMS = manaplus dyecmd
-else
-bin_PROGRAMS = manaplus
-endif
-else
-if ENABLE_DYECMD
-bin_PROGRAMS = dyecmd
-else
-bin_PROGRAMS =
-endif
-endif
-if ENABLE_UNITTESTSBIN
-bin_PROGRAMS += manaplustests
-endif
-
-manaplustests_CXXFLAGS =
-if ENABLE_UNITTESTS_CATCH
-manaplustests_CXXFLAGS += -DUNITTESTS_CATCH
-endif
-if ENABLE_UNITTESTSBIN_CATCH
-manaplustests_CXXFLAGS += -DUNITTESTS_CATCH
-endif
-if ENABLE_UNITTESTS_DOCTEST
-manaplustests_CXXFLAGS += -DUNITTESTS_DOCTEST
-endif
-if ENABLE_UNITTESTSBIN_DOCTEST
-manaplustests_CXXFLAGS += -DUNITTESTS_DOCTEST
-endif
-
-dyecmd_CXXFLAGS = -DPKG_DATADIR=\""$(pkgdatadir)/"\" \
- -DLOCALEDIR=\""$(localedir)"\" \
- -Wall
-manaplus_CXXFLAGS = -DPKG_DATADIR=\""$(pkgdatadir)/"\" \
- -DLOCALEDIR=\""$(localedir)"\" \
- -Wall
-
-if ENABLE_WERROR
-manaplus_CXXFLAGS += -Werror
-dyecmd_CXXFLAGS += -Werror
-endif
-
-if ENABLE_GLIBCDEBUG
-manaplus_CXXFLAGS += -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC
-dyecmd_CXXFLAGS += -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC
-endif
-
-if USE_X11
-manaplus_CXXFLAGS += -DUSE_X11
-dyecmd_CXXFLAGS += -DUSE_X11
-endif
-
-if ENABLE_ASSERTS
-manaplus_CXXFLAGS += -DENABLE_ASSERTS
-dyecmd_CXXFLAGS += -DENABLE_ASSERTS
-if HAVE_RDYNAMIC
-manaplus_LDFLAGS = -rdynamic
-dyecmd_LDFLAGS = -rdynamic
-endif
-endif
-
-if HAVE_EXECINFO
-manaplus_CXXFLAGS += -DHAVE_EXECINFO
-dyecmd_CXXFLAGS += -DHAVE_EXECINFO
-endif
-
-if ENABLE_PUGIXML
-manaplus_CXXFLAGS += -DENABLE_PUGIXML
-dyecmd_CXXFLAGS += -DENABLE_PUGIXML
-endif
-if ENABLE_LIBXML
-manaplus_CXXFLAGS += -DENABLE_LIBXML
-dyecmd_CXXFLAGS += -DENABLE_LIBXML
-endif
-if ENABLE_TINYXML2
-manaplus_CXXFLAGS += -DENABLE_TINYXML2
-dyecmd_CXXFLAGS += -DENABLE_TINYXML2
-endif
-
-if ENABLE_PORTABLE
-dyecmd_CXXFLAGS += -DENABLE_PORTABLE
-manaplus_CXXFLAGS += -DENABLE_PORTABLE
-endif
-
-if ENABLE_CUSTOMNLS
-dyecmd_CXXFLAGS += -DENABLE_CUSTOMNLS
-manaplus_CXXFLAGS += -DENABLE_CUSTOMNLS
-endif
-
-if ENABLE_CHECKPLUGIN
-dyecmd_CXXFLAGS += -DENABLE_CHECKPLUGIN -fplugin=../build/checkplugin.so -fplugin-arg-checkplugin-command=detectnullpointers
-manaplus_CXXFLAGS += -DENABLE_CHECKPLUGIN -fplugin=../build/checkplugin.so -fplugin-arg-checkplugin-command=detectnullpointers
-endif
-
-if USE_OPENGL
-dyecmd_CXXFLAGS += -DUSE_OPENGL
-manaplus_CXXFLAGS += -DUSE_OPENGL
-endif
-if ENABLE_OPENGLERRORS
-dyecmd_CXXFLAGS += -DOPENGLERRORS
-manaplus_CXXFLAGS += -DOPENGLERRORS
-endif
-
-if ENABLE_MEM_DEBUG
-dyecmd_CXXFLAGS += -DENABLE_MEM_DEBUG -DDEBUG_DUMP_LEAKS
-manaplus_CXXFLAGS += -DENABLE_MEM_DEBUG -DDEBUG_DUMP_LEAKS
-
-manaplus_SOURCES = debug/nvwa/_nvwa.h \
- debug/nvwa/c++11.h \
- debug/nvwa/debug_new.cpp \
- debug/nvwa/debug_new.h \
- debug/nvwa/fast_mutex.h \
- debug/nvwa/static_assert.h
-dyecmd_SOURCES = debug/nvwa/_nvwa.h \
- debug/nvwa/c++11.h \
- debug/nvwa/debug_new.cpp \
- debug/nvwa/debug_new.h \
- debug/nvwa/fast_mutex.h \
- debug/nvwa/static_assert.h
-else
-manaplus_SOURCES =
-dyecmd_SOURCES =
-endif
-
-if ENABLE_STLDEBUG
-dyecmd_CXXFLAGS += -DENABLE_STLDEBUG
-manaplus_CXXFLAGS += -DENABLE_STLDEBUG
-
-manaplus_SOURCES += debug/mse/msemsevector.h \
- debug/mse/msemstdvector.h \
- debug/mse/mseprimitives.h
-dyecmd_SOURCES += debug/mse/msemsevector.h \
- debug/mse/msemstdvector.h \
- debug/mse/mseprimitives.h
-endif
-
-if MINGW
-manaplus_SOURCES += manaplus.rc
-dyecmd_SOURCES += manaplus.rc
-endif
-
-if ENABLE_CILKPLUS
-dyecmd_CXXFLAGS += -DENABLE_CILKPLUS -fcilkplus -lcilkrts
-manaplus_CXXFLAGS += -DENABLE_CILKPLUS -fcilkplus -lcilkrts
-endif
-
-dyecmd_CXXFLAGS += -DDYECMD
-dyecmd_SOURCES += progs/dyecmd/dyemain.cpp
-
-if USE_MUMBLE
-manaplus_CXXFLAGS += -DUSE_MUMBLE
-endif
-
-if ENABLE_CHECKS
-dyecmd_CXXFLAGS += -DENABLE_CHECKS
-manaplus_CXXFLAGS += -DENABLE_CHECKS
-endif
-
-BASE_SRC =
-
-if USE_SDL2
-if USE_INTERNALSDLGFX
-dyecmd_CXXFLAGS += -I$(srcdir)/sdl2gfx -DUSE_SDL2
-manaplus_CXXFLAGS += -I$(srcdir)/sdl2gfx -DUSE_SDL2
-BASE_SRC += sdl2gfx/SDL2_framerate.cpp \
- sdl2gfx/SDL2_framerate.h \
- sdl2gfx/SDL2_rotozoom.cpp \
- sdl2gfx/SDL2_rotozoom.h
-else
-dyecmd_CXXFLAGS += -DUSE_SDL2
-manaplus_CXXFLAGS += -DUSE_SDL2
-endif
-endif
-
-BASE_SRC += client.h \
- events/actionevent.h \
- listeners/actionlistener.h \
- listeners/attributelistener.cpp \
- listeners/attributelistener.h \
- gui/widgets/basiccontainer.h \
- gui/browserlink.h \
- gui/buttoninfo.h \
- gui/buttontext.h \
- const/gui/chat.h \
- const/gui/pages.h \
- gui/chatlog.h \
- enums/gui/chatmsgtype.h \
- enums/gui/chattabtype.h \
- enums/gui/colorname.h \
- gui/cliprect.h \
- gui/color.h \
- enums/gui/dialogtype.h \
- enums/gui/gradienttype.h \
- enums/gui/itemamountwindowusage.h \
- enums/gui/orientation.h \
- enums/gui/progresscolorid.h \
- enums/gui/serverdialogdonwloadstatus.h \
- enums/gui/shoplistboxtype.h \
- enums/gui/slidergrid.h \
- enums/gui/themecolorid.h \
- enums/gui/updatedownloadstatus.h \
- enums/gui/usercolorid.h \
- listeners/errorlistener.cpp \
- listeners/errorlistener.h \
- listeners/widgetdeathlistener.h \
- events/event.h \
- listeners/focuslistener.h \
- listeners/gamemodifierlistener.cpp \
- listeners/gamemodifierlistener.h \
- listeners/guiconfiglistener.h \
- listeners/debugmessagelistener.cpp \
- listeners/debugmessagelistener.h \
- listeners/guitableactionlistener.cpp \
- listeners/guitableactionlistener.h \
- listeners/tooltiplistener.cpp \
- listeners/tooltiplistener.h \
- events/inputguievent.h \
- input/key.h \
- events/keyevent.h \
- enums/events/keyeventtype.h \
- listeners/keylistener.h \
- gui/models/listmodel.h \
- events/mouseevent.h \
- enums/events/mousebutton.h \
- enums/events/mouseeventtype.h \
- listeners/mouselistener.h \
- listeners/openurllistener.h \
- listeners/playerdeathlistener.cpp \
- listeners/playerdeathlistener.h \
- gui/rect.h \
- events/selectionevent.h \
- listeners/selectionlistener.h \
- listeners/statlistener.cpp \
- listeners/statlistener.h \
- listeners/tablemodellistener.h \
- utils/sdlpixel.h \
- utils/sdlsharedhelper.cpp \
- utils/sdlsharedhelper.h \
- utils/stdmove.h \
- gui/widgets/widget.h \
- listeners/weightlistener.h \
- listeners/widgetlistener.h \
- listeners/wrongdatanoticelistener.cpp \
- listeners/wrongdatanoticelistener.h \
- gui/viewport.h \
- gui/widgets/basiccontainer2.h \
- gui/widgets/basiccontainer.cpp \
- gui/colorpair.h \
- gui/dialogsmanager.cpp \
- gui/dialogsmanager.h \
- input/key.cpp \
- gui/widgets/widget.cpp \
- gui/widgets/basiccontainer2.cpp \
- gui/models/colorlistmodel.h \
- gui/widgets/browserbox.cpp \
- gui/widgets/browserbox.h \
- gui/widgets/browserbox.inc \
- gui/widgets/staticbrowserbox.cpp \
- gui/widgets/staticbrowserbox.h \
- gui/widgets/button.cpp \
- gui/widgets/button.h \
- gui/widgets/chatinput.h \
- gui/widgets/checkbox.cpp \
- gui/widgets/checkbox.h \
- gui/models/colormodel.cpp \
- gui/models/colormodel.h \
- gui/widgets/colorpage.cpp \
- gui/widgets/colorpage.h \
- gui/widgets/container.cpp \
- gui/widgets/container.h \
- gui/widgets/containerplacer.cpp \
- gui/widgets/containerplacer.h \
- gui/widgets/createwidget.h \
- gui/widgets/desktop.cpp \
- gui/widgets/desktop.h \
- gui/widgets/dropdown.cpp \
- gui/widgets/dropdown.h \
- gui/widgets/equipmentbox.h \
- gui/widgets/equipmentpage.h \
- gui/widgets/extendedlistbox.cpp \
- gui/widgets/extendedlistbox.h \
- gui/widgets/extendedlistboxitem.h \
- gui/models/extendedlistmodel.h \
- gui/models/extendednamesmodel.cpp \
- gui/models/extendednamesmodel.h \
- gui/models/fontsizechoicelistmodel.h \
- gui/models/fontsmodel.h \
- gui/models/iconsmodel.h \
- gui/models/ignorechoiceslistmodel.h \
- gui/models/itemsmodel.h \
- gui/models/keylistmodel.h \
- gui/models/langlistmodel.h \
- gui/widgets/flowcontainer.cpp \
- gui/widgets/flowcontainer.h \
- gui/widgets/guitable.cpp \
- gui/widgets/guitable.h \
- gui/widgets/horizontcontainer.cpp \
- gui/widgets/horizontcontainer.h \
- gui/widgets/icon.cpp \
- gui/widgets/icon.h \
- gui/widgets/inttextfield.cpp \
- gui/widgets/inttextfield.h \
- gui/widgets/label.cpp \
- gui/widgets/label.h \
- gui/widgets/layout.cpp \
- gui/widgets/layout.h \
- gui/widgets/layoutarray.cpp \
- gui/widgets/layoutarray.h \
- gui/widgets/layoutcell.cpp \
- gui/widgets/layoutcell.h \
- gui/widgets/layouthelper.cpp \
- gui/widgets/layouthelper.h \
- enums/gui/layouttype.h \
- enums/gui/linkhighlightmode.h \
- enums/gui/npcactionstate.h \
- enums/gui/npcinputstate.h \
- gui/widgets/linepart.cpp \
- gui/widgets/linepart.h \
- gui/widgets/linkhandler.h \
- gui/widgets/listbox.cpp \
- gui/widgets/listbox.h \
- gui/models/modelistmodel.cpp \
- gui/models/modelistmodel.h \
- gui/models/namesmodel.cpp \
- gui/models/namesmodel.h \
- gui/models/serverslistmodel.h \
- gui/widgets/passwordfield.cpp \
- gui/widgets/passwordfield.h \
- gui/widgets/popup.cpp \
- gui/widgets/popup.h \
- gui/widgets/popuplist.cpp \
- gui/widgets/popuplist.h \
- gui/widgets/progressbar.cpp \
- gui/widgets/progressbar.h \
- gui/widgets/progressindicator.cpp \
- gui/widgets/progressindicator.h \
- gui/widgets/radiobutton.cpp \
- gui/widgets/radiobutton.h \
- gui/widgets/radiogroup.cpp \
- gui/widgets/radiogroup.h \
- gui/widgets/scrollarea.cpp \
- gui/widgets/scrollarea.h \
- gui/models/soundsmodel.h \
- gui/widgets/slider.cpp \
- gui/widgets/slider.h \
- gui/widgets/sliderlist.cpp \
- gui/widgets/sliderlist.h \
- gui/widgets/tabs/tab.cpp \
- gui/widgets/tabs/tab.h \
- gui/widgets/tabbedarea.cpp \
- gui/widgets/tabbedarea.h \
- gui/models/tablemodel.cpp \
- gui/models/tablemodel.h \
- gui/models/targettypemodel.h \
- gui/models/typelistmodel.h \
- gui/models/themesmodel.h \
- gui/widgets/tabstrip.cpp \
- gui/widgets/tabstrip.h \
- gui/widgets/textbox.cpp \
- gui/widgets/textbox.h \
- gui/widgets/textfield.cpp \
- gui/widgets/textfield.h \
- gui/widgets/textpreview.cpp \
- gui/widgets/textpreview.h \
- gui/widgets/vertcontainer.cpp \
- gui/widgets/vertcontainer.h \
- gui/widgets/widget2.h \
- gui/widgets/widgetgroup.cpp \
- gui/widgets/widgetgroup.h \
- gui/widgets/window.cpp \
- gui/widgets/window.h \
- gui/widgets/windowcontainer.cpp \
- gui/widgets/windowcontainer.h \
- gui/windows/confirmdialog.cpp \
- gui/windows/confirmdialog.h \
- gui/focushandler.cpp \
- gui/focushandler.h \
- gui/gui.cpp \
- gui/gui.h \
- gui/mailmessage.h \
- gui/mouseoverlink.h \
- gui/windows/okdialog.cpp \
- gui/windows/okdialog.h \
- gui/onlineplayer.h \
- gui/palette.cpp \
- gui/palette.h \
- gui/sdlinput.cpp \
- gui/sdlinput.h \
- gui/windows/editdialog.cpp \
- gui/windows/editdialog.h \
- gui/setupactiondata.h \
- gui/fonts/font.cpp \
- gui/fonts/font.h \
- gui/fonts/textchunk.cpp \
- gui/fonts/textchunk.h \
- gui/fonts/textchunklist.cpp \
- gui/fonts/textchunklist.h \
- gui/fonts/textchunksmall.cpp \
- gui/fonts/textchunksmall.h \
- gui/skin.cpp \
- gui/skin.h \
- gui/theme.cpp \
- gui/theme.h \
- gui/themecolorsidoperators.cpp \
- gui/themecolorsidoperators.h \
- gui/themeinfo.h \
- gui/userpalette.cpp \
- gui/userpalette.h \
- gui/windowmanager.cpp \
- gui/windowmanager.h \
- enums/net/auctionsearchtype.h \
- enums/net/battlegroundtype.h \
- enums/net/deleteitemreason.h \
- enums/net/downloadstatus.h \
- enums/net/mailmessagetype.h \
- enums/net/mailopentype.h \
- enums/net/npcaction.h \
- enums/net/packettype.h \
- enums/net/partyshare.h \
- enums/net/serverfreetype.h \
- enums/net/servertype.h \
- enums/net/storesearchtype.h \
- enums/net/updatetype.h \
- resources/action.cpp \
- resources/action.h \
- resources/ambientlayer.cpp \
- resources/ambientlayer.h \
- resources/atlas/atlasitem.h \
- resources/atlas/atlasmanager.cpp \
- resources/atlas/atlasmanager.h \
- resources/atlas/atlasresource.cpp \
- resources/atlas/atlasresource.h \
- resources/rect/doublerect.h \
- resources/attack.h \
- resources/cursors.cpp \
- resources/cursors.h \
- resources/dye/dye.cpp \
- resources/dye/dye.h \
- resources/dye/dyecolor.h \
- resources/dye/dyepalette.cpp \
- resources/dye/dyepalette.h \
- resources/dye/dyepalette_replaceacolor.cpp \
- resources/dye/dyepalette_replaceaoglcolor.cpp \
- resources/dye/dyepalette_replacescolor.cpp \
- resources/dye/dyepalette_replacesoglcolor.cpp \
- resources/dye/dyepaletteptr.h \
- resources/fboinfo.h \
- resources/frame.h \
- resources/groupinfo.cpp \
- resources/groupinfo.h \
- resources/image/image.cpp \
- resources/image/image.h \
- resources/imagehelper.cpp \
- resources/imagehelper.h \
- resources/imageset.cpp \
- resources/imageset.h \
- resources/itemcolordata.h \
- resources/mstack.h \
- resources/notificationinfo.h \
- resources/notifications.h \
- resources/npcbuttoninfo.h \
- resources/npcdialoginfo.h \
- resources/npcdialogmenuinfo.h \
- resources/npcimageinfo.h \
- resources/npcinventoryinfo.h \
- resources/npctextinfo.h \
- enums/resources/notifyflags.h \
- enums/resources/notifytypes.h \
- resources/imagerect.h \
- resources/openglimagehelper.cpp \
- resources/openglimagehelper.h \
- resources/openglscreenshothelper.cpp \
- resources/openglscreenshothelper.h \
- resources/mobileopenglscreenshothelper.cpp \
- resources/mobileopenglscreenshothelper.h \
- resources/questeffect.h \
- resources/questitem.h \
- resources/questitemtext.h \
- resources/questvar.h \
- enums/resources/questtype.h \
- enums/resources/servercommandenable.h \
- enums/resources/servercommandtype.h \
- enums/resources/serverpermissiontype.h \
- resources/resource.cpp \
- resources/resource.h \
- resources/resourcefunctiontypes.h \
- resources/resourcetypes.h \
- resources/loaders/atlasloader.cpp \
- resources/loaders/atlasloader.h \
- resources/loaders/emptyatlasloader.cpp \
- resources/loaders/emptyatlasloader.h \
- resources/loaders/imageloader.cpp \
- resources/loaders/imageloader.h \
- resources/loaders/imagesetloader.cpp \
- resources/loaders/imagesetloader.h \
- resources/loaders/musicloader.cpp \
- resources/loaders/musicloader.h \
- resources/loaders/rescaledloader.cpp \
- resources/loaders/rescaledloader.h \
- resources/loaders/shaderloader.cpp \
- resources/loaders/shaderloader.h \
- resources/loaders/shaderprogramloader.cpp \
- resources/loaders/shaderprogramloader.h \
- resources/loaders/soundloader.cpp \
- resources/loaders/soundloader.h \
- resources/loaders/spritedefloader.cpp \
- resources/loaders/spritedefloader.h \
- resources/loaders/subimageloader.cpp \
- resources/loaders/subimageloader.h \
- resources/loaders/subimagesetloader.cpp \
- resources/loaders/subimagesetloader.h \
- resources/loaders/walklayerloader.cpp \
- resources/loaders/walklayerloader.h \
- resources/loaders/xmlloader.cpp \
- resources/loaders/xmlloader.h \
- resources/resourcemanager/resourcemanager.cpp \
- resources/resourcemanager/resourcemanager.h \
- resources/safeopenglimagehelper.cpp \
- resources/safeopenglimagehelper.h \
- resources/screenshothelper.h \
- resources/sdl2imagehelper.cpp \
- resources/sdl2imagehelper.h \
- resources/sdl2softwareimagehelper.cpp \
- resources/sdl2softwareimagehelper.h \
- resources/sdl2softwarescreenshothelper.cpp \
- resources/sdl2softwarescreenshothelper.h \
- resources/sdlgfxblitfunc.cpp \
- resources/sdlgfxblitfunc.h \
- resources/sdlimagehelper.cpp \
- resources/sdlimagehelper.h \
- resources/sdlmusic.cpp \
- resources/sdlmusic.h \
- resources/sdlscreenshothelper.cpp \
- resources/sdlscreenshothelper.h \
- resources/skill/skilltypeentry.h \
- resources/skill/skilltypelist.h \
- const/net/skill.h \
- const/resources/currency.h \
- const/resources/skill.h \
- enums/resources/skill/skillowner.h \
- enums/resources/skill/skillsettype.h \
- enums/resources/skill/skilltype.h \
- enums/resources/skill/skilltype2.h \
- resources/servercommands.inc \
- resources/serverpermissions.inc \
- resources/soundeffect.cpp \
- resources/soundeffect.h \
- resources/soundinfo.h \
- const/resources/spriteaction.h \
- resources/sprite/spritedef.cpp \
- resources/sprite/spritedef.h \
- enums/resources/spritedirection.h \
- resources/image/subimage.cpp \
- resources/image/subimage.h \
- resources/surfaceimagehelper.cpp \
- resources/surfaceimagehelper.h \
- resources/wallpaper.cpp \
- resources/wallpaper.h \
- resources/wallpaperdata.h \
- utils/translation/podict.cpp \
- utils/translation/podict.h \
- utils/translation/poparser.cpp \
- utils/translation/poparser.h \
- utils/translation/translationmanager.cpp \
- utils/translation/translationmanager.h \
- utils/base64.cpp \
- utils/base64.h \
- utils/booleanoptions.h \
- utils/browserboxtools.cpp \
- utils/browserboxtools.h \
- utils/buildhex.h \
- utils/cast.h \
- utils/checkutils.cpp \
- utils/checkutils.h \
- utils/copynpaste.cpp \
- utils/copynpaste.h \
- utils/cpu.cpp \
- utils/cpu.h \
- utils/delete2.h \
- utils/dtor.h \
- utils/dumplibs.cpp \
- utils/dumplibs.h \
- utils/dumpsizes.cpp \
- utils/dumpsizes.h \
- utils/env.cpp \
- utils/env.h \
- utils/foreach.h \
- fs/files.cpp \
- fs/files.h \
- utils/fuzzer.cpp \
- utils/fuzzer.h \
- utils/gettext.h \
- utils/gettexthelper.cpp \
- utils/gettexthelper.h \
- utils/glxhelper.cpp \
- utils/glxhelper.h \
- utils/intmap.h \
- utils/langs.cpp \
- utils/langs.h \
- utils/likely.h \
- utils/mathutils.h \
- fs/mkdir.cpp \
- fs/mkdir.h \
- utils/mrand.cpp \
- utils/mrand.h \
- utils/parameters.cpp \
- utils/parameters.h \
- fs/paths.cpp \
- fs/paths.h \
- utils/perfomance.cpp \
- utils/perfomance.h \
- utils/pnglib.cpp \
- utils/pnglib.h \
- fs/virtfs/fsfuncs.h \
- fs/virtfs/rwops.cpp \
- fs/virtfs/rwops.h \
- fs/virtfs/tools.cpp \
- fs/virtfs/tools.h \
- fs/virtfs/list.cpp \
- fs/virtfs/list.h \
- utils/process.cpp \
- utils/process.h \
- utils/sdl2helper.cpp \
- utils/sdl2helper.h \
- utils/sdl2logger.cpp \
- utils/sdl2logger.h \
- utils/sdlcheckutils.cpp \
- utils/sdlcheckutils.h \
- utils/sdlhelper.cpp \
- utils/sdlhelper.h \
- utils/sdlmemoryobject.h \
- fs/specialfolder.cpp \
- fs/specialfolder.h \
- utils/stringmap.h \
- utils/stringutils.cpp \
- utils/stringutils.h \
- utils/stringvector.h \
- utils/timer.cpp \
- utils/timer.h \
- utils/vector.h \
- utils/x11logger.cpp \
- utils/x11logger.h \
- fs/virtfs/file.cpp \
- fs/virtfs/file.h \
- utils/mutex.h \
- utils/naclmessages.cpp \
- utils/naclmessages.h \
- utils/xml.h \
- utils/xml.inc \
- utils/xmlutils.cpp \
- utils/xmlutils.h \
- utils/xmlwriter.h \
- test/testlauncher.cpp \
- test/testlauncher.h \
- test/testmain.cpp \
- test/testmain.h \
- actions/actiondef.h \
- actions/actionfuncptr.h \
- actions/actions.h \
- actions/chat.h \
- actions/commands.h \
- actions/move.h \
- actions/pets.h \
- actions/statusbar.h \
- actions/tabs.h \
- actions/target.h \
- actions/windows.h \
- listeners/baselistener.hpp \
- commandline.cpp \
- commandline.h \
- configmanager.cpp \
- configmanager.h \
- listeners/configlistener.h \
- configuration.cpp \
- configuration.h \
- debug.h \
- defaults.cpp \
- defaults.h \
- dirs.cpp \
- dirs.h \
- eventsmanager.cpp \
- eventsmanager.h \
- const/equipment.h \
- const/itemshortcut.h \
- const/spells.h \
- const/utils/timer.h \
- const/utils/utf8.h \
- const/gui/chat.h \
- const/gui/theme.h \
- const/render/graphics.h \
- render/graphics.cpp \
- render/graphics.h \
- graphicsmanager.cpp \
- graphicsmanager.h \
- render/vertexes/imagecollection.cpp \
- render/vertexes/imagecollection.h \
- render/vertexes/imagevertexes.cpp \
- render/vertexes/imagevertexes.h \
- render/vertexes/openglgraphicsvertexes.cpp \
- render/vertexes/openglgraphicsvertexes.h \
- events/inputevent.h \
- input/inputactiondata.h \
- input/inputactionoperators.cpp \
- input/inputactionoperators.h \
- input/inputactionsortfunctor.h \
- enums/input/inputcondition.h \
- input/inputfunction.h \
- input/inputitem.h \
- input/inputmanager.cpp \
- input/inputmanager.h \
- enums/input/inputtype.h \
- enums/input/keyboardfocus.h \
- enums/input/keyvalue.h \
- input/joystick.cpp \
- input/joystick.h \
- input/keyboardconfig.cpp \
- input/keyboardconfig.h \
- input/keyinput.h \
- input/touch/multitouchmanager.cpp \
- input/touch/multitouchmanager.h \
- localconsts.h \
- logger.cpp \
- logger.h \
- maingui.cpp \
- maingui.h \
- render/opengl/mgl.cpp \
- render/opengl/mgl.h \
- render/opengl/mgl.hpp \
- render/opengl/mglcheck.h \
- render/opengl/mgldefines.h \
- render/opengl/mglemu.cpp \
- render/opengl/mglemu.h \
- render/opengl/mglfunctions.h \
- render/opengl/mgltypes.h \
- render/openglx/mglx.cpp \
- render/openglx/mglx.h \
- render/openglx/mglx.hpp \
- render/openglx/mglxinit.cpp \
- render/openglx/mglxinit.h \
- render/openglx/mglxtypes.h \
- render/mobileopengl2graphics.cpp \
- render/mobileopengl2graphics.h \
- render/mobileopenglgraphics.cpp \
- render/mobileopenglgraphics.h \
- render/modernopenglgraphics.cpp \
- render/modernopenglgraphics.h \
- render/nacl/naclfunctions.h \
- render/nacl/naclgles.cpp \
- render/nacl/naclgles.h \
- render/opengl/naclglfunctions.h \
- render/normalopenglgraphics.cpp \
- render/normalopenglgraphics.h \
- input/mouseinput.h \
- options.h \
- render/graphicsdef.hpp \
- render/imagegraphics.cpp \
- render/imagegraphics.h \
- render/graphics_calcImageRect.hpp \
- render/graphics_drawImageRect.hpp \
- render/nullopenglgraphics.cpp \
- render/nullopenglgraphics.h \
- render/opengl/opengldebug.h \
- render/openglgraphicsdef.hpp \
- render/openglgraphicsdef1.hpp \
- render/openglgraphicsdefadvanced.hpp \
- render/renderers.cpp \
- render/renderers.h \
- render/rendererslistsdl.h \
- render/rendererslistsdl2.h \
- enums/particle/alivestatus.h \
- enums/particle/particlechangefunc.h \
- enums/particle/particlephysics.h \
- enums/particle/particletype.h \
- enums/render/blitmode.h \
- enums/render/rendertype.h \
- being/playerignorestrategy.h \
- enums/being/rank.h \
- enums/being/reachable.h \
- enums/being/relation.h \
- enums/being/targetcursorsize.h \
- enums/being/targetcursortype.h \
- enums/being/visiblename.h \
- enums/being/visiblenamepos.h \
- position.cpp \
- position.h \
- render/safeopenglgraphics.cpp\
- render/safeopenglgraphics.h \
- render/sdl2graphics.cpp \
- render/sdl2graphics.h \
- render/sdl2softwaregraphics.cpp \
- render/sdl2softwaregraphics.h \
- render/sdlgraphics.cpp \
- render/sdlgraphics.h \
- render/softwaregraphicsdef.hpp \
- sdlshared.h \
- settings.cpp \
- settings.h \
- enums/screendensity.h \
- enums/state.h \
- enums/textcommandtype.h \
- enums/simpletypes/advanced.h \
- enums/simpletypes/allowquit.h \
- enums/simpletypes/allowsort.h \
- enums/simpletypes/allplayers.h \
- enums/simpletypes/append.h \
- enums/simpletypes/autorelease.h \
- enums/simpletypes/autotarget.h \
- enums/simpletypes/beingid.h \
- enums/simpletypes/beingtypeid.h \
- enums/simpletypes/booldefines.h \
- enums/simpletypes/damaged.h \
- enums/simpletypes/donotalign.h \
- enums/simpletypes/enable.h \
- enums/simpletypes/enumdefines.h \
- enums/simpletypes/equipm.h \
- enums/simpletypes/equipped.h \
- enums/simpletypes/favorite.h \
- enums/simpletypes/forcedisplay.h \
- enums/simpletypes/forcequantity.h \
- enums/simpletypes/identified.h \
- enums/simpletypes/ignorerecord.h \
- enums/simpletypes/intdefines.h \
- enums/simpletypes/issell.h \
- enums/simpletypes/isstart.h \
- enums/simpletypes/itemcolor.h \
- enums/simpletypes/keep.h \
- enums/simpletypes/losefocusontab.h \
- enums/simpletypes/mainconfig.h \
- enums/simpletypes/modal.h \
- enums/simpletypes/modifiable.h \
- enums/simpletypes/move.h \
- enums/simpletypes/notify.h \
- enums/simpletypes/npcnames.h \
- enums/simpletypes/online.h \
- enums/simpletypes/onthefly.h \
- enums/simpletypes/opaque.h \
- enums/simpletypes/protected.h \
- enums/simpletypes/separator.h \
- enums/simpletypes/sfx.h \
- enums/simpletypes/showcenter.h \
- enums/simpletypes/showemptyrows.h \
- enums/simpletypes/skiperror.h \
- enums/simpletypes/speech.h \
- enums/simpletypes/stringdefines.h \
- enums/simpletypes/stringdefines2.h \
- enums/simpletypes/trading.h \
- enums/simpletypes/tryremovecolors.h \
- enums/simpletypes/useargs.h \
- enums/simpletypes/usebase64.h \
- enums/simpletypes/usevirtfs.h \
- enums/simpletypes/visible.h \
- render/surfacegraphics.cpp \
- render/surfacegraphics.h \
- render/shaders/shader.cpp \
- render/shaders/shader.h \
- render/shaders/shaderprogram.cpp \
- render/shaders/shaderprogram.h \
- render/shaders/shadersmanager.cpp \
- render/shaders/shadersmanager.h \
- resources/animation/animation.cpp \
- resources/animation/animation.h \
- resources/animation/simpleanimation.cpp \
- resources/animation/simpleanimation.h \
- resources/sprite/sprite.h \
- const/sound.h \
- soundmanager.cpp \
- soundmanager.h \
- text.cpp \
- text.h \
- textmanager.cpp \
- textmanager.h \
- input/touch/touchactions.cpp \
- input/touch/touchactions.h \
- input/touch/touchmanager.cpp \
- input/touch/touchmanager.h \
- variabledata.h \
- vector.cpp \
- vector.h \
- net/ipc.cpp \
- net/ipc.h \
- net/sdltcpnet.cpp \
- net/sdltcpnet.h \
- gui/popups/textboxpopup.cpp \
- gui/popups/textboxpopup.h \
- gui/popups/textpopup.cpp \
- gui/popups/textpopup.h \
- gui/popupmanager.cpp \
- gui/popupmanager.h \
- enums/input/inputaction.h \
- enums/input/inputgroup.h \
- input/inputactionmap.h \
- resources/memorycounter.cpp \
- resources/memorycounter.h \
- resources/memorymanager.cpp \
- resources/memorymanager.h \
- resources/missileinfo.h \
- winver.h \
- enums/fs/fsentrytype.h \
- fs/virtfs/fileapi.h \
- fs/virtfs/rwopstypes.h \
- fs/virtfs/direntry.cpp \
- fs/virtfs/direntry.h \
- fs/virtfs/fs.cpp \
- fs/virtfs/fs.h \
- fs/virtfs/fsdir.cpp \
- fs/virtfs/fsdir.h \
- fs/virtfs/fsdirrwops.cpp \
- fs/virtfs/fsdirrwops.h \
- fs/virtfs/fsentry.cpp \
- fs/virtfs/fsentry.h \
- fs/virtfs/fszip.cpp \
- fs/virtfs/fszip.h \
- fs/virtfs/fsziprwops.cpp \
- fs/virtfs/fsziprwops.h \
- fs/virtfs/zipentry.cpp \
- fs/virtfs/zipentry.h \
- fs/virtfs/zipreader.cpp \
- fs/virtfs/zipreader.h \
- fs/virtfs/ziplocalheader.cpp \
- fs/virtfs/ziplocalheader.h
-
-if ENABLE_PUGIXML
-BASE_SRC += utils/xml/pugixml.cpp \
- utils/xml/pugixml.h \
- utils/xml/pugixml.inc \
- utils/xml/pugixmlwriter.cpp \
- utils/xml/pugixmlwriter.h
-endif
-if ENABLE_LIBXML
-BASE_SRC += utils/xml/libxml.cpp \
- utils/xml/libxml.h \
- utils/xml/libxml.inc
-endif
-if ENABLE_TINYXML2
-BASE_SRC += utils/xml/tinyxml2.cpp \
- utils/xml/tinyxml2.h \
- utils/xml/tinyxml2.inc
-endif
-
-dyecmd_SOURCES += ${BASE_SRC}
-
-SRC = ${BASE_SRC} \
- main.cpp \
- main.h \
- avatar.cpp \
- avatar.h \
- actormanager.cpp \
- actormanager.h \
- resources/sprite/animatedsprite.cpp \
- resources/sprite/animatedsprite.h \
- resources/sprite/animationdelayload.cpp \
- resources/sprite/animationdelayload.h \
- resources/dbmanager.cpp \
- resources/dbmanager.h \
- resources/sprite/imagesprite.cpp \
- resources/sprite/imagesprite.h \
- resources/inventory/inventory.cpp \
- resources/inventory/inventory.h \
- textcommand.cpp \
- textcommand.h \
- resources/item/cardslist.cpp \
- resources/item/cardslist.h \
- resources/item/complexitem.cpp \
- resources/item/complexitem.h \
- resources/item/item.cpp \
- resources/item/item.h \
- resources/item/itemfieldtype.h \
- resources/item/itemoption.h \
- resources/item/itemoptionslist.h \
- itemcolormanager.cpp \
- itemcolormanager.h \
- gui/shortcut/itemshortcut.cpp \
- gui/shortcut/itemshortcut.h \
- itemsoundmanager.cpp \
- itemsoundmanager.h \
- enums/commandtarget.h \
- enums/dragdropsource.h \
- enums/emotetype.h \
- enums/equipslot.h \
- enums/guildpositionflags.h \
- enums/inventorytype.h \
- gui/shortcut/spellshortcut.cpp \
- gui/shortcut/spellshortcut.h \
- statuseffect.cpp \
- statuseffect.h \
- particle/animationparticle.cpp \
- particle/animationparticle.h \
- being/being.cpp \
- being/being.h \
- enums/being/beingaction.h \
- being/beingcacheentry.h \
- enums/being/beingdirection.h \
- being/beingflag.h \
- being/beingspeech.h \
- being/castingeffect.cpp \
- being/castingeffect.h \
- being/localplayer.cpp \
- being/localplayer.h \
- being/mercenaryinfo.h \
- being/petinfo.h \
- being/compounditem.h \
- being/compoundsprite.cpp \
- being/compoundsprite.h \
- being/crazymoves.cpp \
- being/crazymoves.h \
- enums/being/cookingtype.h \
- enums/being/gender.h \
- being/homunculusinfo.h \
- enums/being/pickup.h \
- beingequipbackend.cpp \
- beingequipbackend.h \
- resources/item/shopitem.cpp \
- resources/item/shopitem.h \
- being/flooritem.cpp \
- being/flooritem.h \
- game.cpp \
- game.h \
- gamemodifiers.cpp \
- gamemodifiers.h \
- guild.cpp \
- guild.h \
- spellmanager.cpp \
- spellmanager.h \
- chatlogger.cpp \
- chatlogger.h \
- gui/shortcut/shortcutbase.cpp \
- gui/shortcut/shortcutbase.h \
- being/playerinfo.cpp \
- being/playerinfo.h \
- being/playerrelation.cpp \
- being/playerrelation.h \
- being/playerrelations.cpp \
- being/playerrelations.h \
- gui/touchactiondata.cpp \
- gui/touchactiondata.h \
- gui/models/avatarlistmodel.h \
- gui/models/beingslistmodel.h \
- gui/models/opengllistmodel.h \
- gui/models/playerrelationlistmodel.h \
- gui/models/playertablemodel.cpp \
- gui/models/playertablemodel.h \
- gui/models/questsmodel.h \
- being/actor.cpp \
- being/actor.h \
- being/actorsprite.cpp \
- being/actorsprite.h \
- enums/being/actortype.h \
- enums/being/attacktype.h \
- enums/being/attributes.h \
- enums/being/attributesstrings.cpp \
- enums/being/attributesstrings.h \
- enums/being/badgedrawtype.h \
- enums/being/badgeindex.h \
- dragdrop.h \
- gui/shortcut/dropshortcut.cpp \
- gui/shortcut/dropshortcut.h \
- effectmanager.cpp \
- effectmanager.h \
- gui/shortcut/emoteshortcut.cpp \
- gui/shortcut/emoteshortcut.h \
- const/emoteshortcut.h \
- equipment.h \
- listeners/actorspritelistener.h \
- listeners/arrowslistener.cpp \
- listeners/arrowslistener.h \
- listeners/assertlistener.cpp \
- listeners/assertlistener.h \
- listeners/awaylistener.cpp \
- listeners/awaylistener.h \
- listeners/charrenamelistener.cpp \
- listeners/charrenamelistener.h \
- gui/popups/itempopup.cpp \
- gui/popups/itempopup.h \
- gui/popups/spellpopup.cpp \
- gui/popups/spellpopup.h \
- gui/popups/statuspopup.cpp \
- gui/popups/statuspopup.h \
- gui/popups/popupmenu.cpp \
- gui/popups/popupmenu.h \
- gui/popups/skillpopup.cpp \
- gui/popups/skillpopup.h \
- gui/popups/speechbubble.cpp \
- gui/popups/speechbubble.h \
- gui/popups/beingpopup.cpp \
- gui/popups/beingpopup.h \
- gui/widgets/itemcontainer.cpp \
- gui/widgets/itemcontainer.h \
- gui/widgets/tabs/chat/battletab.cpp \
- gui/widgets/tabs/chat/battletab.h \
- gui/widgets/tabs/chat/channeltab.cpp \
- gui/widgets/tabs/chat/channeltab.h \
- gui/widgets/attrs/attrdisplay.cpp \
- gui/widgets/attrs/attrdisplay.h \
- gui/widgets/attrs/changedisplay.cpp \
- gui/widgets/attrs/changedisplay.h \
- gui/widgets/attrs/derdisplay.cpp \
- gui/widgets/attrs/derdisplay.h \
- gui/widgets/tabs/debugwindowtabs.cpp \
- gui/widgets/tabs/debugwindowtabs.h \
- gui/widgets/tabs/chat/chattab.cpp \
- gui/widgets/tabs/chat/chattab.h \
- gui/widgets/tabs/chat/gmtab.cpp \
- gui/widgets/tabs/chat/gmtab.h \
- gui/widgets/tabs/chat/langtab.cpp \
- gui/widgets/tabs/chat/langtab.h \
- gui/widgets/tabs/chat/tradetab.cpp \
- gui/widgets/tabs/chat/tradetab.h \
- gui/widgets/tabs/chat/whispertab.cpp \
- gui/widgets/tabs/chat/whispertab.h \
- gui/widgets/tabs/chat/guildtab.cpp \
- gui/widgets/tabs/chat/guildtab.h \
- gui/widgets/tabs/chat/partytab.cpp \
- gui/widgets/tabs/chat/partytab.h \
- gui/widgets/avatarlistbox.cpp \
- gui/widgets/avatarlistbox.h \
- gui/widgets/characterdisplay.cpp \
- gui/widgets/characterdisplay.h \
- gui/widgets/characterviewbase.h \
- gui/widgets/characterviewnormal.cpp \
- gui/widgets/characterviewnormal.h \
- gui/widgets/characterviewsmall.cpp \
- gui/widgets/characterviewsmall.h \
- gui/widgets/itemlinkhandler.cpp \
- gui/widgets/itemlinkhandler.h \
- gui/widgets/emoteshortcutcontainer.cpp \
- gui/widgets/emoteshortcutcontainer.h \
- gui/widgets/virtshortcutcontainer.cpp \
- gui/widgets/virtshortcutcontainer.h \
- gui/widgets/emotepage.cpp \
- gui/widgets/emotepage.h \
- gui/widgets/itemshortcutcontainer.cpp \
- gui/widgets/itemshortcutcontainer.h \
- gui/widgets/spellshortcutcontainer.cpp \
- gui/widgets/spellshortcutcontainer.h \
- gui/widgets/statspage.cpp \
- gui/widgets/statspage.h \
- gui/widgets/statspagebasic.cpp \
- gui/widgets/statspagebasic.h \
- gui/widgets/selldialog.cpp \
- gui/widgets/selldialog.h \
- gui/widgets/tabs/setup_audio.cpp \
- gui/widgets/tabs/setup_audio.h \
- gui/widgets/tabs/setup_colors.cpp \
- gui/widgets/tabs/setup_colors.h \
- gui/widgets/tabs/setup_joystick.cpp \
- gui/widgets/tabs/setup_joystick.h \
- gui/widgets/tabs/setup_misc.cpp \
- gui/widgets/tabs/setup_misc.h \
- gui/widgets/tabs/setup_mods.cpp \
- gui/widgets/tabs/setup_mods.h \
- gui/widgets/tabs/setup_theme.cpp \
- gui/widgets/tabs/setup_theme.h \
- gui/widgets/tabs/setup_touch.cpp \
- gui/widgets/tabs/setup_touch.h \
- gui/widgets/tabs/setup_chat.cpp \
- gui/widgets/tabs/setup_chat.h \
- gui/widgets/tabs/setup_input.cpp \
- gui/widgets/tabs/setup_input.h \
- gui/widgets/tabs/setup_perfomance.cpp \
- gui/widgets/tabs/setup_perfomance.h \
- gui/widgets/tabs/setup_players.cpp \
- gui/widgets/tabs/setup_players.h \
- gui/widgets/tabs/setup_quick.cpp \
- gui/widgets/tabs/setup_quick.h \
- gui/widgets/tabs/setup_relations.cpp \
- gui/widgets/tabs/setup_relations.h \
- gui/widgets/tabs/setup_video.cpp \
- gui/widgets/tabs/setup_video.h \
- gui/widgets/tabs/setup_visual.cpp \
- gui/widgets/tabs/setup_visual.h \
- gui/widgets/serverslistbox.h \
- gui/widgets/setupbuttonitem.cpp \
- gui/widgets/setupbuttonitem.h \
- gui/widgets/setupitem.cpp \
- gui/widgets/setupitem.h \
- gui/widgets/setupquickitem.cpp \
- gui/widgets/setupquickitem.h \
- gui/widgets/tabs/setuptab.cpp \
- gui/widgets/tabs/setuptab.h \
- gui/widgets/tabs/setuptabscroll.cpp \
- gui/widgets/tabs/setuptabscroll.h \
- gui/widgets/setuptouchitem.cpp \
- gui/widgets/setuptouchitem.h \
- gui/widgets/playerbox.cpp \
- gui/widgets/playerbox.h \
- gui/models/shopitems.cpp \
- gui/models/shopitems.h \
- gui/widgets/shoplistbox.cpp \
- gui/widgets/shoplistbox.h \
- gui/widgets/shortcutcontainer.cpp \
- gui/widgets/shortcutcontainer.h \
- resources/skill/skilldata.cpp \
- resources/skill/skilldata.h \
- resources/skill/skillinfo.cpp \
- resources/skill/skillinfo.h \
- gui/widgets/skilllistbox.h \
- gui/widgets/skillrectanglelistbox.h \
- gui/widgets/tabs/shortcuttab.h \
- gui/widgets/tabs/skilltab.h \
- gui/widgets/tabs/socialattacktab.h \
- gui/widgets/tabs/socialfriendsfunctor.h \
- gui/widgets/tabs/socialfriendstab.h \
- gui/widgets/tabs/socialguildtab.h \
- gui/widgets/tabs/socialnavigationtab.h \
- gui/widgets/tabs/socialpartytab.h \
- gui/widgets/tabs/socialpickuptab.h \
- gui/widgets/tabs/socialplayerstab.h \
- gui/widgets/tabs/socialtab.h \
- gui/widgets/tabs/socialtabbase.h \
- gui/models/skillmodel.cpp \
- gui/models/skillmodel.h \
- gui/models/sortlistmodelbuy.h \
- gui/models/sortlistmodelinv.h \
- gui/models/touchactionmodel.cpp \
- gui/models/touchactionmodel.h \
- gui/models/updatetypemodel.h \
- gui/models/updatelistmodel.h \
- gui/models/worldlistmodel.h \
- gui/windowmenu.cpp \
- gui/windowmenu.h \
- gui/windows/tradewindow.cpp \
- gui/windows/tradewindow.h \
- gui/windows/updaterwindow.cpp \
- gui/windows/updaterwindow.h \
- gui/windows/whoisonline.cpp \
- gui/windows/whoisonline.h \
- gui/windows/worldselectdialog.cpp \
- gui/windows/worldselectdialog.h \
- gui/windows/shopwindow.cpp \
- gui/windows/shopwindow.h \
- gui/windows/shortcutwindow.cpp \
- gui/windows/shortcutwindow.h \
- gui/windows/skilldialog.cpp \
- gui/windows/skilldialog.h \
- gui/windows/socialwindow.cpp \
- gui/windows/socialwindow.h \
- gui/windows/statuswindow.cpp \
- gui/windows/statuswindow.h \
- gui/windows/textdialog.cpp \
- gui/windows/textdialog.h \
- gui/windows/textselectdialog.cpp \
- gui/windows/textselectdialog.h \
- gui/windows/setupwindow.cpp \
- gui/windows/setupwindow.h \
- gui/windows/serverdialog.cpp \
- gui/windows/serverdialog.h \
- gui/windows/serverinfowindow.cpp \
- gui/windows/serverinfowindow.h \
- gui/windows/quitdialog.cpp \
- gui/windows/quitdialog.h \
- gui/windows/questswindow.cpp \
- gui/windows/questswindow.h \
- gui/windows/registerdialog.cpp \
- gui/windows/registerdialog.h \
- gui/windows/buydialog.cpp \
- gui/windows/buydialog.h \
- gui/windows/buyselldialog.cpp \
- gui/windows/buyselldialog.h \
- gui/windows/changeemaildialog.cpp \
- gui/windows/changeemaildialog.h \
- gui/windows/changepassworddialog.cpp \
- gui/windows/changepassworddialog.h \
- gui/windows/charselectdialog.cpp \
- gui/windows/charselectdialog.h \
- gui/windows/charcreatedialog.cpp \
- gui/windows/charcreatedialog.h \
- gui/windows/chardeleteconfirm.h \
- gui/windows/chatwindow.cpp \
- gui/windows/chatwindow.h \
- gui/windows/connectiondialog.cpp \
- gui/windows/connectiondialog.h \
- gui/windows/debugwindow.cpp \
- gui/windows/debugwindow.h \
- gui/windows/didyouknowwindow.cpp \
- gui/windows/didyouknowwindow.h \
- gui/windows/editserverdialog.cpp \
- gui/windows/editserverdialog.h \
- gui/windows/emotewindow.cpp \
- gui/windows/emotewindow.h \
- gui/windows/equipmentwindow.cpp \
- gui/windows/equipmentwindow.h \
- gui/windows/helpwindow.cpp \
- gui/windows/helpwindow.h \
- gui/windows/inventorywindow.cpp \
- gui/windows/inventorywindow.h \
- gui/windows/itemamountwindow.cpp \
- gui/windows/itemamountwindow.h \
- gui/windows/killstats.cpp \
- gui/windows/killstats.h \
- gui/windows/logindialog.cpp \
- gui/windows/logindialog.h \
- gui/windows/minimap.cpp \
- gui/windows/minimap.h \
- gui/windows/ministatuswindow.cpp \
- gui/windows/ministatuswindow.h \
- gui/windows/npcdialog.cpp \
- gui/windows/npcdialog.h \
- gui/windows/npcselldialog.cpp \
- gui/windows/npcselldialog.h \
- gui/windows/outfitwindow.cpp \
- gui/windows/outfitwindow.h \
- gui/windows/textcommandeditor.cpp \
- gui/windows/textcommandeditor.h \
- gui/setupinputpages.cpp \
- gui/setupinputpages.h \
- input/pages/basic.cpp \
- input/pages/basic.h \
- input/pages/chat.cpp \
- input/pages/chat.h \
- input/pages/craft.cpp \
- input/pages/craft.h \
- input/pages/emotes.cpp \
- input/pages/emotes.h \
- input/pages/gui.cpp \
- input/pages/gui.h \
- input/pages/move.cpp \
- input/pages/move.h \
- input/pages/other.cpp \
- input/pages/other.h \
- input/pages/outfits.cpp \
- input/pages/outfits.h \
- input/pages/shortcuts.cpp \
- input/pages/shortcuts.h \
- input/pages/windows.cpp \
- input/pages/windows.h \
- listeners/playerpostdeathlistener.h \
- listeners/inputactionremotelistener.cpp \
- listeners/inputactionremotelistener.h \
- listeners/inputactionreplaylistener.cpp \
- listeners/inputactionreplaylistener.h \
- listeners/insertcardlistener.h \
- listeners/inventorylistener.h \
- listeners/updatestatuslistener.cpp \
- listeners/updatestatuslistener.h \
- listeners/uploadlistener.cpp \
- listeners/uploadlistener.h \
- listeners/playerlistener.cpp \
- listeners/playerlistener.h \
- listeners/playerrelationslistener.h \
- listeners/renamelistener.cpp \
- listeners/renamelistener.h \
- listeners/requesttradelistener.h \
- listeners/textskilllistener.cpp \
- listeners/textskilllistener.h \
- particle/rotationalparticle.cpp \
- particle/rotationalparticle.h \
- navigationmanager.cpp \
- navigationmanager.h \
- notifymanager.cpp \
- notifymanager.h \
- particle/imageparticle.cpp \
- particle/imageparticle.h \
- particle/particle.cpp \
- particle/particle.h \
- particle/particlecontainer.cpp \
- particle/particlecontainer.h \
- particle/particleemitter.cpp \
- particle/particleemitter.h \
- particle/particleemitterprop.h \
- particle/particleengine.cpp \
- particle/particleengine.h \
- particle/particleinfo.h \
- particle/particlelist.cpp \
- particle/particlelist.h \
- particle/particletimer.h \
- particle/particlevector.cpp \
- particle/particlevector.h \
- party.cpp \
- party.h \
- utils/chatutils.cpp \
- utils/chatutils.h \
- utils/gmfunctions.cpp \
- utils/gmfunctions.h \
- resources/db/avatardb.cpp \
- resources/db/avatardb.h \
- resources/db/badgesdb.cpp \
- resources/db/badgesdb.h \
- resources/db/chardb.cpp \
- resources/db/chardb.h \
- resources/db/colordb.cpp \
- resources/db/colordb.h \
- resources/db/commandsdb.cpp \
- resources/db/commandsdb.h \
- resources/db/deaddb.cpp \
- resources/db/deaddb.h \
- resources/db/elementaldb.cpp \
- resources/db/elementaldb.h \
- resources/db/emotedb.cpp \
- resources/db/emotedb.h \
- resources/db/groupdb.cpp \
- resources/db/groupdb.h \
- resources/db/homunculusdb.cpp \
- resources/db/homunculusdb.h \
- resources/db/horsedb.cpp \
- resources/db/horsedb.h \
- resources/db/itemdb.cpp \
- resources/db/itemdb.h \
- resources/basicstat.h \
- resources/db/itemfielddb.cpp \
- resources/db/itemfielddb.h \
- resources/db/itemoptiondb.cpp \
- resources/db/itemoptiondb.h \
- resources/db/languagedb.cpp \
- resources/db/languagedb.h \
- resources/db/mapdb.cpp \
- resources/db/mapdb.h \
- resources/db/mercenarydb.cpp \
- resources/db/mercenarydb.h \
- resources/db/moddb.cpp \
- resources/db/moddb.h \
- resources/db/monsterdb.cpp \
- resources/db/monsterdb.h \
- resources/db/networkdb.cpp \
- resources/db/networkdb.h \
- resources/db/npcdb.cpp \
- resources/db/npcdb.h \
- resources/db/npcdialogdb.cpp \
- resources/db/npcdialogdb.h \
- resources/db/palettedb.cpp \
- resources/db/palettedb.h \
- resources/db/petdb.cpp \
- resources/db/petdb.h \
- resources/db/questdb.cpp \
- resources/db/questdb.h \
- resources/db/skillunitdb.cpp \
- resources/db/skillunitdb.h \
- resources/db/sounddb.cpp \
- resources/db/sounddb.h \
- resources/db/statdb.cpp \
- resources/db/statdb.h \
- resources/db/statuseffectdb.cpp \
- resources/db/statuseffectdb.h \
- resources/db/textdb.cpp \
- resources/db/textdb.h \
- resources/db/unitsdb.cpp \
- resources/db/unitsdb.h \
- resources/db/weaponsdb.cpp \
- resources/db/weaponsdb.h \
- resources/iteminfo.h \
- resources/iteminfo.cpp \
- resources/itemmenuitem.h \
- enums/resources/cursor.h \
- enums/resources/displaytype.h \
- enums/resources/frametype.h \
- enums/resources/imageposition.h \
- enums/resources/imagetype.h \
- enums/resources/mailqueuetype.h \
- enums/resources/map/maplayertype.h \
- enums/resources/item/itemdbtype.h \
- enums/resources/item/itemsoundevent.h \
- enums/resources/item/itemtype.h \
- resources/itemtypemap.h \
- resources/itemtypemapdata.h \
- resources/mailqueue.h \
- resources/mapinfo.h \
- enums/resources/map/mapitemtype.h \
- enums/resources/map/maplayerposition.h \
- resources/mapreader.cpp \
- resources/mapreader.h \
- resources/modinfo.cpp \
- resources/modinfo.h \
- resources/beingcommon.cpp \
- resources/beingcommon.h \
- resources/beinginfo.cpp \
- resources/beinginfo.h \
- resources/beingmenuitem.h \
- resources/beingslot.cpp \
- resources/beingslot.h \
- resources/chatobject.cpp \
- resources/chatobject.h \
- resources/delayedmanager.cpp \
- resources/delayedmanager.h \
- resources/effectdescription.h \
- resources/emoteinfo.h \
- resources/emotesprite.h \
- resources/equipmentslots.h \
- resources/horseinfo.h \
- resources/horseoffset.h \
- resources/sprite/spritedisplay.h \
- resources/sprite/spritereference.h \
- resources/atlas/textureatlas.h \
- resources/updatefile.h \
- enums/resources/map/blockmask.h \
- enums/resources/map/blocktype.h \
- enums/resources/map/collisiontype.h \
- enums/resources/skill/casttype.h \
- resources/map/location.h \
- resources/map/map.cpp \
- resources/map/map.h \
- const/resources/item/cards.h \
- const/resources/item/itemoptions.h \
- const/resources/map/map.h \
- resources/map/mapheights.cpp \
- resources/map/mapheights.h \
- resources/map/mapitem.cpp \
- resources/map/mapitem.h \
- resources/map/maplayer.cpp \
- resources/map/maplayer.h \
- resources/map/mapobject.h \
- resources/map/mapobjectlist.h \
- resources/map/maprowvertexes.h \
- enums/resources/map/maptype.h \
- resources/map/metatile.h \
- resources/map/objectslayer.cpp \
- resources/map/objectslayer.h \
- particle/textparticle.cpp \
- particle/textparticle.h \
- resources/map/properties.h \
- resources/map/speciallayer.cpp \
- resources/map/speciallayer.h \
- resources/map/tileanimation.cpp \
- resources/map/tileanimation.h \
- resources/map/tileinfo.h \
- resources/map/tileset.h \
- resources/map/walklayer.cpp \
- resources/map/walklayer.h \
- net/adminhandler.h \
- net/beinghandler.h \
- net/buysellhandler.h \
- net/character.h \
- net/characters.h \
- net/charserverhandler.cpp \
- net/charserverhandler.h \
- net/chathandler.h \
- net/download.cpp \
- net/download.h \
- net/gamehandler.h \
- net/generalhandler.h \
- net/guildhandler.h \
- net/inventoryhandler.h \
- net/ea/inventoryitem.h \
- net/logindata.h \
- net/loginhandler.h \
- net/messagein.cpp \
- net/messagein.h \
- net/messageout.cpp \
- net/messageout.h \
- net/net.cpp \
- net/net.h \
- const/net/inventory.h \
- const/net/maxpacketversion.h \
- const/net/net.h \
- const/net/nostat.h \
- net/npchandler.h \
- net/partyhandler.h \
- net/pethandler.h \
- net/playerhandler.h \
- net/questhandler.h \
- net/recvpacketdefine.h \
- net/serverfeatures.h \
- net/serverinfo.h \
- net/serverurlinfo.h \
- net/skillhandler.h \
- net/tradehandler.h \
- net/updatetypeoperators.cpp \
- net/updatetypeoperators.h \
- net/uploadcharinfo.h \
- net/useragent.cpp \
- net/useragent.h \
- net/worldinfo.h \
- net/packetcounters.cpp \
- net/packetcounters.h \
- net/packetfunction.h \
- net/packetinfo.h \
- net/packetlimiter.cpp \
- net/packetlimiter.h \
- net/protocoloutdefine.h \
- net/protocoloutinclude.h \
- net/protocoloutupdate.h \
- net/ea/adminrecv.cpp \
- net/ea/adminrecv.h \
- net/ea/adminhandler.cpp \
- net/ea/adminhandler.h \
- net/ea/beingrecv.cpp \
- net/ea/beingrecv.h \
- net/ea/beinghandler.cpp \
- net/ea/beinghandler.h \
- net/ea/buysellhandler.cpp \
- net/ea/buysellhandler.h \
- net/ea/buysellrecv.cpp \
- net/ea/buysellrecv.h \
- net/ea/charserverhandler.cpp \
- net/ea/charserverhandler.h \
- net/ea/charserverrecv.cpp \
- net/ea/charserverrecv.h \
- net/ea/chathandler.cpp \
- net/ea/chathandler.h \
- net/ea/chatrecv.cpp \
- net/ea/chatrecv.h \
- net/ea/eaprotocol.h \
- net/ea/equipbackend.h \
- net/ea/gamehandler.cpp \
- net/ea/gamehandler.h \
- net/ea/gamerecv.cpp \
- net/ea/gamerecv.h \
- net/ea/inventoryhandler.cpp \
- net/ea/inventoryhandler.h \
- net/ea/inventoryrecv.cpp \
- net/ea/inventoryrecv.h \
- net/ea/itemhandler.cpp \
- net/ea/itemhandler.h \
- net/ea/itemrecv.cpp \
- net/ea/itemrecv.h \
- net/ea/loginhandler.cpp \
- net/ea/loginhandler.h \
- net/ea/loginrecv.cpp \
- net/ea/loginrecv.h \
- net/ea/network.cpp \
- net/ea/network.h \
- net/ea/maprecv.cpp \
- net/ea/maprecv.h \
- net/ea/npchandler.cpp \
- net/ea/npchandler.h \
- net/ea/npcrecv.cpp \
- net/ea/npcrecv.h \
- net/ea/partyhandler.cpp \
- net/ea/partyhandler.h \
- net/ea/partyrecv.cpp \
- net/ea/partyrecv.h \
- net/ea/playerhandler.cpp \
- net/ea/playerhandler.h \
- net/ea/playerrecv.cpp \
- net/ea/playerrecv.h \
- net/ea/skillhandler.cpp \
- net/ea/skillhandler.h \
- net/ea/skillrecv.cpp \
- net/ea/skillrecv.h \
- net/ea/token.h \
- net/ea/tradehandler.cpp \
- net/ea/tradehandler.h \
- net/ea/traderecv.cpp \
- net/ea/traderecv.h \
- progs/manaplus/actions/actions.cpp \
- progs/manaplus/actions/chat.cpp \
- progs/manaplus/actions/commands.cpp \
- progs/manaplus/actions/move.cpp \
- progs/manaplus/actions/pets.cpp \
- progs/manaplus/actions/statusbar.cpp \
- progs/manaplus/actions/tabs.cpp \
- progs/manaplus/actions/target.cpp \
- progs/manaplus/actions/windows.cpp \
- progs/manaplus/client.cpp \
- progs/manaplus/client.h \
- progs/manaplus/gui/viewport.cpp \
- progs/manaplus/gui/viewport.h
-
-if ENABLE_TMWA
-manaplus_CXXFLAGS += -DTMWA_SUPPORT
-SRC += \
- enums/magicschool.h \
- gui/models/magicschoolmodel.h \
- gui/widgets/tabs/socialguildtab2.h \
- gui/widgets/tabs/chat/emulateguildtab.cpp \
- gui/widgets/tabs/chat/emulateguildtab.h \
- gui/windows/shopselldialog.cpp \
- gui/windows/shopselldialog.h \
- net/tmwa/adminhandler.cpp \
- net/tmwa/adminhandler.h \
- net/tmwa/beingrecv.cpp \
- net/tmwa/beingrecv.h \
- net/tmwa/beinghandler.cpp \
- net/tmwa/beinghandler.h \
- net/tmwa/buysellhandler.cpp \
- net/tmwa/buysellhandler.h \
- net/tmwa/buysellrecv.cpp \
- net/tmwa/buysellrecv.h \
- net/tmwa/charserverhandler.cpp \
- net/tmwa/charserverhandler.h \
- net/tmwa/charserverrecv.cpp \
- net/tmwa/charserverrecv.h \
- net/tmwa/chathandler.cpp \
- net/tmwa/chathandler.h \
- net/tmwa/chatrecv.cpp \
- net/tmwa/chatrecv.h \
- net/tmwa/gamehandler.cpp \
- net/tmwa/gamehandler.h \
- net/tmwa/gamerecv.cpp \
- net/tmwa/gamerecv.h \
- net/tmwa/generalhandler.cpp \
- net/tmwa/generalhandler.h \
- net/tmwa/generalrecv.cpp \
- net/tmwa/generalrecv.h \
- net/tmwa/guildhandler.cpp \
- net/tmwa/guildhandler.h \
- net/tmwa/guildmanager.cpp \
- net/tmwa/guildmanager.h \
- net/tmwa/inventoryhandler.cpp \
- net/tmwa/inventoryhandler.h \
- net/tmwa/inventoryrecv.cpp \
- net/tmwa/inventoryrecv.h \
- net/tmwa/itemhandler.cpp \
- net/tmwa/itemhandler.h \
- net/tmwa/itemrecv.cpp \
- net/tmwa/itemrecv.h \
- net/tmwa/loginhandler.cpp \
- net/tmwa/loginhandler.h \
- net/tmwa/loginrecv.cpp \
- net/tmwa/loginrecv.h \
- net/tmwa/messagein.cpp \
- net/tmwa/messagein.h \
- net/tmwa/messageout.cpp \
- net/tmwa/messageout.h \
- net/tmwa/network.cpp \
- net/tmwa/network.h \
- net/tmwa/npchandler.cpp \
- net/tmwa/npchandler.h \
- net/tmwa/packetsin.inc \
- net/tmwa/packetsout.inc \
- net/tmwa/partyhandler.cpp \
- net/tmwa/partyhandler.h \
- net/tmwa/partyrecv.cpp \
- net/tmwa/partyrecv.h \
- net/tmwa/pethandler.cpp \
- net/tmwa/pethandler.h \
- net/tmwa/playerhandler.cpp \
- net/tmwa/playerhandler.h \
- net/tmwa/playerrecv.cpp \
- net/tmwa/playerrecv.h \
- net/tmwa/protocolout.cpp \
- net/tmwa/protocolout.h \
- net/tmwa/questhandler.cpp \
- net/tmwa/questhandler.h \
- net/tmwa/questrecv.cpp \
- net/tmwa/questrecv.h \
- net/tmwa/recvpackets.inc \
- net/tmwa/serverfeatures.cpp \
- net/tmwa/serverfeatures.h \
- net/tmwa/skillhandler.cpp \
- net/tmwa/skillhandler.h \
- net/tmwa/skillrecv.cpp \
- net/tmwa/skillrecv.h \
- net/tmwa/sp.h \
- net/tmwa/sprite.h \
- net/tmwa/tradehandler.cpp \
- net/tmwa/tradehandler.h \
- net/tmwa/traderecv.cpp \
- net/tmwa/traderecv.h \
- net/tmwa/updateprotocol.cpp \
- net/tmwa/updateprotocol.h \
- net/tmwa/auctionhandler.cpp \
- net/tmwa/auctionhandler.h \
- net/tmwa/bankhandler.cpp \
- net/tmwa/bankhandler.h \
- net/tmwa/battlegroundhandler.cpp \
- net/tmwa/battlegroundhandler.h \
- net/tmwa/buyingstorehandler.cpp \
- net/tmwa/buyingstorehandler.h \
- net/tmwa/cashshophandler.cpp \
- net/tmwa/cashshophandler.h \
- net/tmwa/elementalhandler.cpp \
- net/tmwa/elementalhandler.h \
- net/tmwa/familyhandler.cpp \
- net/tmwa/familyhandler.h \
- net/tmwa/friendshandler.cpp \
- net/tmwa/friendshandler.h \
- net/tmwa/homunculushandler.cpp \
- net/tmwa/homunculushandler.h \
- net/tmwa/mailhandler.cpp \
- net/tmwa/mailhandler.h \
- net/tmwa/mail2handler.cpp \
- net/tmwa/mail2handler.h \
- net/tmwa/maphandler.cpp \
- net/tmwa/maphandler.h \
- net/tmwa/markethandler.cpp \
- net/tmwa/markethandler.h \
- net/tmwa/mercenaryhandler.cpp \
- net/tmwa/mercenaryhandler.h \
- net/tmwa/roulettehandler.cpp \
- net/tmwa/roulettehandler.h \
- net/tmwa/searchstorehandler.cpp \
- net/tmwa/searchstorehandler.h \
- net/tmwa/vendinghandler.cpp \
- net/tmwa/vendinghandler.h
-endif
-
-SRC += gui/windows/bankwindow.cpp \
- gui/windows/bankwindow.h \
- gui/windows/buyingstoreselldialog.cpp \
- gui/windows/buyingstoreselldialog.h \
- gui/windows/cutinwindow.cpp \
- gui/windows/cutinwindow.h \
- gui/windows/eggselectiondialog.cpp \
- gui/windows/eggselectiondialog.h \
- gui/windows/insertcarddialog.cpp \
- gui/windows/insertcarddialog.h \
- gui/windows/maileditwindow.cpp \
- gui/windows/maileditwindow.h \
- gui/windows/mailviewwindow.cpp \
- gui/windows/mailviewwindow.h \
- gui/windows/mailwindow.cpp \
- gui/windows/mailwindow.h \
- enums/cutin.h \
- listeners/banklistener.cpp \
- listeners/banklistener.h \
- listeners/buyingstoremodelistener.cpp \
- listeners/buyingstoremodelistener.h \
- listeners/buyingstoreslotslistener.cpp \
- listeners/buyingstoreslotslistener.h \
- listeners/pincodelistener.cpp \
- listeners/pincodelistener.h \
- listeners/requestadoptchildlistener.h \
- listeners/shoprenamelistener.cpp \
- listeners/shoprenamelistener.h \
- listeners/skillwarplistener.cpp \
- listeners/skillwarplistener.h \
- listeners/vendingmodelistener.cpp \
- listeners/vendingmodelistener.h \
- listeners/vendingslotslistener.cpp \
- listeners/vendingslotslistener.h \
- resources/inventory/complexinventory.cpp \
- resources/inventory/complexinventory.h \
- net/auctionhandler.h \
- net/bankhandler.h \
- net/battlegroundhandler.h \
- net/buyingstorehandler.h \
- net/cashshophandler.h \
- net/elementalhandler.h \
- net/familyhandler.h \
- net/friendshandler.h \
- net/homunculushandler.h \
- net/hostsgroup.h \
- net/mailhandler.h \
- net/mail2handler.h \
- net/maphandler.h \
- net/markethandler.h \
- net/mercenaryhandler.h \
- net/roulettehandler.h \
- net/searchstorehandler.h \
- net/vendinghandler.h \
- net/eathena/adminrecv.cpp \
- net/eathena/adminrecv.h \
- net/eathena/adminhandler.cpp \
- net/eathena/adminhandler.h \
- net/eathena/auctionrecv.cpp \
- net/eathena/auctionrecv.h \
- net/eathena/auctionhandler.cpp \
- net/eathena/auctionhandler.h \
- net/eathena/bankrecv.cpp \
- net/eathena/bankrecv.h \
- net/eathena/bankhandler.cpp \
- net/eathena/bankhandler.h \
- net/eathena/battlegroundrecv.cpp \
- net/eathena/battlegroundrecv.h \
- net/eathena/battlegroundhandler.cpp \
- net/eathena/battlegroundhandler.h \
- net/eathena/cashshophandler.cpp \
- net/eathena/cashshophandler.h \
- net/eathena/cashshoprecv.cpp \
- net/eathena/cashshoprecv.h \
- net/eathena/beingrecv.cpp \
- net/eathena/beingrecv.h \
- net/eathena/beinghandler.cpp \
- net/eathena/beinghandler.h \
- net/eathena/buyingstorehandler.cpp \
- net/eathena/buyingstorehandler.h \
- net/eathena/buyingstorerecv.cpp \
- net/eathena/buyingstorerecv.h \
- enums/net/beingtype.h \
- net/eathena/buysellhandler.cpp \
- net/eathena/buysellhandler.h \
- net/eathena/buysellrecv.cpp \
- net/eathena/buysellrecv.h \
- net/eathena/charserverhandler.cpp \
- net/eathena/charserverhandler.h \
- net/eathena/charserverrecv.cpp \
- net/eathena/charserverrecv.h \
- net/eathena/chathandler.cpp \
- net/eathena/chathandler.h \
- net/eathena/chatrecv.cpp \
- net/eathena/chatrecv.h \
- net/eathena/elementalhandler.cpp \
- net/eathena/elementalhandler.h \
- net/eathena/elementalrecv.cpp \
- net/eathena/elementalrecv.h \
- net/eathena/familyhandler.cpp \
- net/eathena/familyhandler.h \
- net/eathena/familyrecv.cpp \
- net/eathena/familyrecv.h \
- net/eathena/friendshandler.cpp \
- net/eathena/friendshandler.h \
- net/eathena/friendsrecv.cpp \
- net/eathena/friendsrecv.h \
- net/eathena/gamehandler.cpp \
- net/eathena/gamehandler.h \
- net/eathena/gamerecv.cpp \
- net/eathena/gamerecv.h \
- net/eathena/generalhandler.cpp \
- net/eathena/generalhandler.h \
- net/eathena/generalrecv.cpp \
- net/eathena/generalrecv.h \
- net/eathena/guildhandler.cpp \
- net/eathena/guildhandler.h \
- net/eathena/guildrecv.cpp \
- net/eathena/guildrecv.h \
- net/eathena/homunculushandler.cpp \
- net/eathena/homunculushandler.h \
- net/eathena/homunculusrecv.cpp \
- net/eathena/homunculusrecv.h \
- net/eathena/inventoryhandler.cpp \
- net/eathena/inventoryhandler.h \
- net/eathena/inventoryrecv.cpp \
- net/eathena/inventoryrecv.h \
- net/eathena/itemflags.h \
- net/eathena/itemhandler.cpp \
- net/eathena/itemhandler.h \
- net/eathena/itemrecv.cpp \
- net/eathena/itemrecv.h \
- net/eathena/loginhandler.cpp \
- net/eathena/loginhandler.h \
- net/eathena/loginrecv.cpp \
- net/eathena/loginrecv.h \
- net/eathena/mail2handler.cpp \
- net/eathena/mail2handler.h \
- net/eathena/mail2recv.cpp \
- net/eathena/mail2recv.h \
- net/eathena/mailhandler.cpp \
- net/eathena/mailhandler.h \
- net/eathena/mailrecv.cpp \
- net/eathena/mailrecv.h \
- net/eathena/maphandler.cpp \
- net/eathena/maphandler.h \
- net/eathena/maprecv.cpp \
- net/eathena/maprecv.h \
- net/eathena/maptypeproperty2.h \
- net/eathena/markethandler.cpp \
- net/eathena/markethandler.h \
- net/eathena/marketrecv.cpp \
- net/eathena/marketrecv.h \
- net/eathena/menu.cpp \
- net/eathena/menu.h \
- enums/net/menutype.h \
- net/eathena/mercenaryhandler.cpp \
- net/eathena/mercenaryhandler.h \
- net/eathena/mercenaryrecv.cpp \
- net/eathena/mercenaryrecv.h \
- net/eathena/messagein.cpp \
- net/eathena/messagein.h \
- net/eathena/messageout.cpp \
- net/eathena/messageout.h \
- net/eathena/network.cpp \
- net/eathena/network.h \
- net/eathena/npchandler.cpp \
- net/eathena/npchandler.h \
- net/eathena/npcrecv.cpp \
- net/eathena/npcrecv.h \
- net/eathena/packetsin.inc \
- net/eathena/packetsout.inc \
- net/eathena/partyhandler.cpp \
- net/eathena/partyhandler.h \
- net/eathena/partyrecv.cpp \
- net/eathena/partyrecv.h \
- net/eathena/pethandler.cpp \
- net/eathena/pethandler.h \
- net/eathena/petrecv.cpp \
- net/eathena/petrecv.h \
- net/eathena/playerhandler.cpp \
- net/eathena/playerhandler.h \
- net/eathena/playerrecv.cpp \
- net/eathena/playerrecv.h \
- net/eathena/protocolout.cpp \
- net/eathena/protocolout.h \
- net/eathena/questhandler.cpp \
- net/eathena/questhandler.h \
- net/eathena/questrecv.cpp \
- net/eathena/questrecv.h \
- net/eathena/recvpackets.inc \
- net/eathena/roulettehandler.cpp \
- net/eathena/roulettehandler.h \
- net/eathena/rouletterecv.cpp \
- net/eathena/rouletterecv.h \
- net/eathena/searchstorehandler.cpp \
- net/eathena/searchstorehandler.h \
- net/eathena/searchstorerecv.cpp \
- net/eathena/searchstorerecv.h \
- net/eathena/serverfeatures.cpp \
- net/eathena/serverfeatures.h \
- net/eathena/skillhandler.cpp \
- net/eathena/skillhandler.h \
- net/eathena/skillrecv.cpp \
- net/eathena/skillrecv.h \
- net/eathena/sp.h \
- net/eathena/sprite.h \
- net/eathena/tradehandler.cpp \
- net/eathena/tradehandler.h \
- net/eathena/traderecv.cpp \
- net/eathena/traderecv.h \
- net/eathena/updateprotocol.cpp \
- net/eathena/updateprotocol.h \
- net/eathena/vendinghandler.cpp \
- net/eathena/vendinghandler.h \
- net/eathena/vendingrecv.cpp \
- net/eathena/vendingrecv.h
-
-SRC += \
- mumblemanager.cpp \
- mumblemanager.h
-
-dyecmd_SOURCES += progs/dyecmd/gui/viewport.cpp \
- progs/dyecmd/gui/viewport.h \
- progs/dyecmd/client.cpp \
- progs/dyecmd/client.h \
- progs/dyecmd/actions/actions.cpp \
- progs/dyecmd/actions/chat.cpp \
- progs/dyecmd/actions/commands.cpp \
- progs/dyecmd/actions/move.cpp \
- progs/dyecmd/actions/pets.cpp \
- progs/dyecmd/actions/statusbar.cpp \
- progs/dyecmd/actions/tabs.cpp \
- progs/dyecmd/actions/target.cpp \
- progs/dyecmd/actions/windows.cpp
-
-if ENABLE_MANAPLUSGAME
-manaplus_SOURCES += ${SRC}
-endif
-
-manaplustests_CXXFLAGS += ${manaplus_CXXFLAGS} \
- -DUNITTESTS
-manaplustests_LDFLAGS =
-if ENABLE_PUGIXML
-manaplustests_CXXFLAGS += -DENABLE_PUGIXML
-endif
-if ENABLE_LIBXML
-manaplustests_CXXFLAGS += -DENABLE_LIBXML
-endif
-if ENABLE_TINYXML2
-manaplustests_CXXFLAGS += -DENABLE_TINYXML2
-endif
-if USE_SDL2
-manaplustests_CXXFLAGS += -DUSE_SDL2
-endif
-if ENABLE_WERROR
-manaplustests_CXXFLAGS += -Werror
-endif
-if ENABLE_ASSERTS
-manaplustests_CXXFLAGS += -DENABLE_ASSERTS
-if HAVE_RDYNAMIC
-manaplustests_LDFLAGS += -rdynamic
-endif
-endif
-if HAVE_EXECINFO
-manaplustests_CXXFLAGS += -DHAVE_EXECINFO
-endif
-if ENABLE_GLIBCDEBUG
-manaplustests_CXXFLAGS += -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC
-endif
-if USE_X11
-manaplustests_CXXFLAGS += -DUSE_X11
-endif
-if ENABLE_OPENGLERRORS
-manaplustests_CXXFLAGS += -DOPENGLERRORS
-endif
-
-manaplustests_SOURCES = \
- unittests/unittests.h \
- unittests/enums/render/mockdrawtype.h \
- unittests/render/mockdrawitem.h \
- unittests/render/mockgraphics.cc \
- unittests/render/mockgraphics.h \
- unittests/endian.cc \
- unittests/enums/enums.cc \
- unittests/sdl.cc \
- unittests/utils/dumplibs.cc \
- unittests/utils/checkutils.cc
-
-if ENABLE_UNITTESTS_CATCH
-manaplustests_SOURCES += \
- unittests/catch.hpp
-endif
-if ENABLE_UNITTESTS_DOCTEST
-manaplustests_SOURCES += \
- unittests/doctest.h
-endif
-
-if MINGW
-manaplustests_SOURCES += manaplus.rc
-manaplustests_LDFLAGS += -mconsole
-endif
-
-manaplustests_SOURCES += \
- unittests/fs/virtfs/virtfs1_basic.cc \
- unittests/fs/virtfs/virtfs1_enumerate.cc \
- unittests/fs/virtfs/virtfs1_exists.cc \
- unittests/fs/virtfs/virtfs1_getrealdir.cc \
- unittests/fs/virtfs/virtfs1_mountdir1.cc \
- unittests/fs/virtfs/virtfs1_mountdir2.cc \
- unittests/fs/virtfs/virtfs1_mountzip1.cc \
- unittests/fs/virtfs/virtfs1_mountzip2.cc \
- unittests/fs/virtfs/virtfs1_unmount.cc \
- unittests/fs/virtfs/virtfs2.cc \
- unittests/fs/virtfs/zip.cc \
- unittests/fs/virtfs/virtfs.cc \
- unittests/fs/virtfs/throw.cc \
- unittests/utils/xml.cc \
- unittests/configuration.cc \
- unittests/utils/timer.cc \
- unittests/utils/xmlutils.cc \
- unittests/utils/mathutils.cc \
- unittests/fs/files.cc \
- unittests/utils/stringutils.cc \
- unittests/utils/parameters.cc \
- unittests/resources/mstack.cc \
- unittests/utils/translation/poparser.cc \
- unittests/utils/langs.cc \
- unittests/resources/sprite/animatedsprite.cc \
- unittests/gui/fonts/textchunklist.cc \
- unittests/gui/widgets/browserbox.cc \
- unittests/resources/dye/dye.cc \
- unittests/resources/dye/dyepalette.cc \
- unittests/integrity.cc \
- unittests/utils/chatutils.cc \
- unittests/resources/map/speciallayer.cc \
- unittests/resources/map/maplayer/draw.cc \
- unittests/resources/map/maplayer/drawfringenormal.cc \
- unittests/resources/map/maplayer/drawfringesimple.cc \
- unittests/resources/map/maplayer/drawspeciallayer1.cc \
- unittests/resources/map/maplayer/drawspeciallayer2.cc \
- unittests/resources/map/maplayer/getemptytiledrawwidth.cc \
- unittests/resources/map/maplayer/gettiledrawwidth.cc \
- unittests/resources/map/maplayer/updatecache.cc \
- unittests/resources/map/maplayer/updateconditiontiles.cc \
- unittests/resources/resourcemanager/resourcemanager.cc \
- unittests/resources/sdlimagehelper.cc \
- unittests/gui/windowmanager.cc
-
-manaplustests_SOURCES += ${SRC}
-
-if ENABLE_UNITTESTS
-TESTS = manaplustests
-check_PROGRAMS = manaplustests
-endif
-
-EXTRA_DIST = CMakeLists.txt \
- winver.h.in \
- manaplus.rc \
- SDLMain.m
-
-# set the include path found by configure
-AM_CPPFLAGS = $(all_includes)
diff --git a/src/SDLMain.m b/src/SDLMain.m
deleted file mode 100644
index d7e9273bc..000000000
--- a/src/SDLMain.m
+++ /dev/null
@@ -1,385 +0,0 @@
-/* SDLMain.m - main entry point for our Cocoa-ized SDL app
- Initial Version: Darrell Walisser <dwaliss1@purdue.edu>
- Non-NIB-Code & other changes: Max Horn <max@quendi.de>
-
- Feel free to customize this file to suit your needs
- */
-
-#import "SDL.h"
-#import "SDLMain.h"
-#import <sys/param.h> /* for MAXPATHLEN */
-#import <unistd.h>
-
-/* For some reaon, Apple removed setAppleMenu from the headers in 10.4,
- but the method still is there and works. To avoid warnings, we declare
- it ourselves here. */
-@interface NSApplication(SDL_Missing_Methods)
-- (void)setAppleMenu:(NSMenu *)menu;
-@end
-
-/* Use this flag to determine whether we use SDLMain.nib or not */
-#define SDL_USE_NIB_FILE 0
-
-/* Use this flag to determine whether we use CPS (docking) or not */
-#define SDL_USE_CPS 1
-#ifdef SDL_USE_CPS
-/* Portions of CPS.h */
-typedef struct CPSProcessSerNum
- {
- UInt32 lo;
- UInt32 hi;
- } CPSProcessSerNum;
-
-extern OSErr CPSGetCurrentProcess( CPSProcessSerNum *psn);
-extern OSErr CPSEnableForegroundOperation( CPSProcessSerNum *psn, UInt32 _arg2, UInt32 _arg3, UInt32 _arg4, UInt32 _arg5);
-extern OSErr CPSSetFrontProcess( CPSProcessSerNum *psn);
-
-#endif /* SDL_USE_CPS */
-
-static int gArgc;
-static char **gArgv;
-static BOOL gFinderLaunch;
-static BOOL gCalledAppMainline = FALSE;
-
-static NSString *getApplicationName(void)
-{
- NSDictionary *dict;
- NSString *appName = 0;
-
- /* Determine the application name */
- dict = (NSDictionary *)CFBundleGetInfoDictionary(CFBundleGetMainBundle());
- if (dict)
- appName = [dict objectForKey: @"CFBundleName"];
-
- if (![appName length])
- appName = [[NSProcessInfo processInfo] processName];
-
- return appName;
-}
-
-#if SDL_USE_NIB_FILE
-/* A helper category for NSString */
-@interface NSString (ReplaceSubString)
-- (NSString *)stringByReplacingRange:(NSRange)aRange with:(NSString *)aString;
-@end
-#endif
-
-@interface SDLApplication : NSApplication
-@end
-
-@implementation SDLApplication
-/* Invoked from the Quit menu item */
-- (void)terminate:(id)sender
-{
- /* Post a SDL_QUIT event */
- SDL_Event event;
- event.type = SDL_QUIT;
- SDL_PushEvent(&event);
-}
-@end
-
-/* The main class of the application, the application's delegate */
-@implementation SDLMain
-
-/* Set the working directory to the .app's parent directory */
-- (void) setupWorkingDirectory:(BOOL)shouldChdir
-{
- if (shouldChdir)
- {
- char parentdir[MAXPATHLEN];
- CFURLRef url = CFBundleCopyBundleURL(CFBundleGetMainBundle());
- CFURLRef url2 = CFURLCreateCopyDeletingLastPathComponent(0, url);
- if (CFURLGetFileSystemRepresentation(url2, true, (UInt8 *)parentdir, MAXPATHLEN)) {
- assert ( chdir (parentdir) == 0 ); /* chdir to the binary app's parent */
- }
- CFRelease(url);
- CFRelease(url2);
- }
-
-}
-
-#if SDL_USE_NIB_FILE
-
-/* Fix menu to contain the real app name instead of "SDL App" */
-- (void)fixMenu:(NSMenu *)aMenu withAppName:(NSString *)appName
-{
- NSRange aRange;
- NSEnumerator *enumerator;
- NSMenuItem *menuItem;
-
- aRange = [[aMenu title] rangeOfString:@"SDL App"];
- if (aRange.length != 0)
- [aMenu setTitle: [[aMenu title] stringByReplacingRange:aRange with:appName]];
-
- enumerator = [[aMenu itemArray] objectEnumerator];
- while ((menuItem = [enumerator nextObject]))
- {
- aRange = [[menuItem title] rangeOfString:@"SDL App"];
- if (aRange.length != 0)
- [menuItem setTitle: [[menuItem title] stringByReplacingRange:aRange with:appName]];
- if ([menuItem hasSubmenu])
- [self fixMenu:[menuItem submenu] withAppName:appName];
- }
- [ aMenu sizeToFit ];
-}
-
-#else
-
-static void setApplicationMenu(void)
-{
- /* warning: this code is very odd */
- NSMenu *appleMenu;
- NSMenuItem *menuItem;
- NSString *title;
- NSString *appName;
-
- appName = getApplicationName();
- appleMenu = [[NSMenu alloc] initWithTitle:@""];
-
- /* Add menu items */
- title = [@"About " stringByAppendingString:appName];
- [appleMenu addItemWithTitle:title action:@selector(orderFrontStandardAboutPanel:) keyEquivalent:@""];
-
- [appleMenu addItem:[NSMenuItem separatorItem]];
-
- title = [@"Hide " stringByAppendingString:appName];
- [appleMenu addItemWithTitle:title action:@selector(hide:) keyEquivalent:@"h"];
-
- menuItem = (NSMenuItem *)[appleMenu addItemWithTitle:@"Hide Others" action:@selector(hideOtherApplications:) keyEquivalent:@"h"];
- [menuItem setKeyEquivalentModifierMask:(NSAlternateKeyMask|NSCommandKeyMask)];
-
- [appleMenu addItemWithTitle:@"Show All" action:@selector(unhideAllApplications:) keyEquivalent:@""];
-
- [appleMenu addItem:[NSMenuItem separatorItem]];
-
- title = [@"Quit " stringByAppendingString:appName];
- [appleMenu addItemWithTitle:title action:@selector(terminate:) keyEquivalent:@"q"];
-
-
- /* Put menu into the menubar */
- menuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""];
- [menuItem setSubmenu:appleMenu];
- [[NSApp mainMenu] addItem:menuItem];
-
- /* Tell the application object that this is now the application menu */
- [NSApp setAppleMenu:appleMenu];
-
- /* Finally give up our references to the objects */
- [appleMenu release];
- [menuItem release];
-}
-
-/* Create a window menu */
-static void setupWindowMenu(void)
-{
- NSMenu *windowMenu;
- NSMenuItem *windowMenuItem;
- NSMenuItem *menuItem;
-
- windowMenu = [[NSMenu alloc] initWithTitle:@"Window"];
-
- /* "Minimize" item */
- menuItem = [[NSMenuItem alloc] initWithTitle:@"Minimize" action:@selector(performMiniaturize:) keyEquivalent:@"m"];
- [windowMenu addItem:menuItem];
- [menuItem release];
-
- /* Put menu into the menubar */
- windowMenuItem = [[NSMenuItem alloc] initWithTitle:@"Window" action:nil keyEquivalent:@""];
- [windowMenuItem setSubmenu:windowMenu];
- [[NSApp mainMenu] addItem:windowMenuItem];
-
- /* Tell the application object that this is now the window menu */
- [NSApp setWindowsMenu:windowMenu];
-
- /* Finally give up our references to the objects */
- [windowMenu release];
- [windowMenuItem release];
-}
-
-/* Replacement for NSApplicationMain */
-static void CustomApplicationMain (int argc, char **argv)
-{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- SDLMain *sdlMain;
-
- /* Ensure the application object is initialised */
- [SDLApplication sharedApplication];
-
-#ifdef SDL_USE_CPS
- {
- CPSProcessSerNum PSN;
- /* Tell the dock about us */
- if (!CPSGetCurrentProcess(&PSN))
- if (!CPSEnableForegroundOperation(&PSN,0x03,0x3C,0x2C,0x1103))
- if (!CPSSetFrontProcess(&PSN))
- [SDLApplication sharedApplication];
- }
-#endif /* SDL_USE_CPS */
-
- /* Set up the menubar */
- [NSApp setMainMenu:[[NSMenu alloc] init]];
- setApplicationMenu();
- setupWindowMenu();
-
- /* Create SDLMain and make it the app delegate */
- sdlMain = [[SDLMain alloc] init];
- [NSApp setDelegate:sdlMain];
-
- /* Start the main event loop */
- [NSApp run];
-
- [sdlMain release];
- [pool release];
-}
-
-#endif
-
-
-/*
- * Catch document open requests...this lets us notice files when the app
- * was launched by double-clicking a document, or when a document was
- * dragged/dropped on the app's icon. You need to have a
- * CFBundleDocumentsType section in your Info.plist to get this message,
- * apparently.
- *
- * Files are added to gArgv, so to the app, they'll look like command line
- * arguments. Previously, apps launched from the finder had nothing but
- * an argv[0].
- *
- * This message may be received multiple times to open several docs on launch.
- *
- * This message is ignored once the app's mainline has been called.
- */
-- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
-{
- const char *temparg;
- size_t arglen;
- char *arg;
- char **newargv;
-
- if (!gFinderLaunch) /* MacOS is passing command line args. */
- return FALSE;
-
- if (gCalledAppMainline) /* app has started, ignore this document. */
- return FALSE;
-
- temparg = [filename UTF8String];
- arglen = SDL_strlen(temparg) + 1;
- arg = (char *) SDL_malloc(arglen);
- if (arg == NULL)
- return FALSE;
-
- newargv = (char **) realloc(gArgv, sizeof (char *) * (gArgc + 2));
- if (newargv == NULL)
- {
- SDL_free(arg);
- return FALSE;
- }
- gArgv = newargv;
-
- SDL_strlcpy(arg, temparg, arglen);
- gArgv[gArgc++] = arg;
- gArgv[gArgc] = NULL;
- return TRUE;
-}
-
-
-/* Called when the internal event loop has just started running */
-- (void) applicationDidFinishLaunching: (NSNotification *) note
-{
- int status;
-
- /* Set the working directory to the .app's parent directory */
- [self setupWorkingDirectory:gFinderLaunch];
-
-#if SDL_USE_NIB_FILE
- /* Set the main menu to contain the real app name instead of "SDL App" */
- [self fixMenu:[NSApp mainMenu] withAppName:getApplicationName()];
-#endif
-
- /* Hand off to main application code */
- gCalledAppMainline = TRUE;
- status = SDL_main (gArgc, gArgv);
-
- /* We're done, thank you for playing */
- exit(status);
-}
-@end
-
-
-@implementation NSString (ReplaceSubString)
-
-- (NSString *)stringByReplacingRange:(NSRange)aRange with:(NSString *)aString
-{
- unsigned int bufferSize;
- unsigned int selfLen = [self length];
- unsigned int aStringLen = [aString length];
- unichar *buffer;
- NSRange localRange;
- NSString *result;
-
- bufferSize = selfLen + aStringLen - aRange.length;
- buffer = NSAllocateMemoryPages(bufferSize*sizeof(unichar));
-
- /* Get first part into buffer */
- localRange.location = 0;
- localRange.length = aRange.location;
- [self getCharacters:buffer range:localRange];
-
- /* Get middle part into buffer */
- localRange.location = 0;
- localRange.length = aStringLen;
- [aString getCharacters:(buffer+aRange.location) range:localRange];
-
- /* Get last part into buffer */
- localRange.location = aRange.location + aRange.length;
- localRange.length = selfLen - localRange.location;
- [self getCharacters:(buffer+aRange.location+aStringLen) range:localRange];
-
- /* Build output string */
- result = [NSString stringWithCharacters:buffer length:bufferSize];
-
- NSDeallocateMemoryPages(buffer, bufferSize);
-
- return result;
-}
-
-@end
-
-
-
-#ifdef main
-# undef main
-#endif
-
-
-/* Main entry point to executable - should *not* be SDL_main! */
-int main (int argc, char **argv)
-{
- /* Copy the arguments into a global variable */
- /* This is passed if we are launched by double-clicking */
- if ( argc >= 2 && strncmp (argv[1], "-psn", 4) == 0 ) {
- gArgv = (char **) SDL_malloc(sizeof (char *) * 2);
- gArgv[0] = argv[0];
- gArgv[1] = NULL;
- gArgc = 1;
- gFinderLaunch = YES;
- }
- else
- {
- int i;
- gArgc = argc;
- gArgv = (char **) SDL_malloc(sizeof (char *) * (argc+1));
- for (i = 0; i <= argc; i++)
- gArgv[i] = argv[i];
- gFinderLaunch = NO;
- }
-
-#if SDL_USE_NIB_FILE
- [SDLApplication poseAsClass:[NSApplication class]];
- NSApplicationMain (argc, argv);
-#else
- CustomApplicationMain (argc, argv);
-#endif
- return 0;
-}
diff --git a/src/actions/actiondef.h b/src/actions/actiondef.h
deleted file mode 100644
index 7465b8521..000000000
--- a/src/actions/actiondef.h
+++ /dev/null
@@ -1,53 +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 ACTIONS_ACTIONDEF_H
-#define ACTIONS_ACTIONDEF_H
-
-#include "gamemodifiers.h"
-#include "settings.h"
-GAMEMODIFIERS_H
-SETTINGS_H
-
-#include "input/inputmanager.h"
-INPUT_INPUTMANAGER_H
-
-#define impHandler(name) bool name(InputEvent &event)
-#define impHandler0(name) bool name(InputEvent &event A_UNUSED)
-#define impHandlerVoid(name) bool name(InputEvent &event A_UNUSED) \
- { \
- return false; \
- }
-
-#define callYellowBar(name) \
- GameModifiers::name(!inputManager.isActionActive( \
- InputAction::STOP_ATTACK)); \
- return true;
-
-#define callYellowBarCond(name) \
- if (!settings.disableGameModifiers) \
- { \
- GameModifiers::name(!inputManager.isActionActive( \
- InputAction::STOP_ATTACK)); \
- return true; \
- } \
- return false;
-
-#endif // ACTIONS_ACTIONDEF_H
diff --git a/src/actions/actionfuncptr.h b/src/actions/actionfuncptr.h
deleted file mode 100644
index c68c66a57..000000000
--- a/src/actions/actionfuncptr.h
+++ /dev/null
@@ -1,28 +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 ACTIONS_ACTIONFUNCPTR_H
-#define ACTIONS_ACTIONFUNCPTR_H
-
-#include "events/inputevent.h"
-
-typedef bool (*ActionFuncPtr) (InputEvent &event);
-
-#endif // ACTIONS_ACTIONFUNCPTR_H
diff --git a/src/actions/actions.h b/src/actions/actions.h
deleted file mode 100644
index 83072680c..000000000
--- a/src/actions/actions.h
+++ /dev/null
@@ -1,127 +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 ACTIONS_ACTIONS_H
-#define ACTIONS_ACTIONS_H
-
-#include "localconsts.h"
-
-#define decHandler(name) bool name(InputEvent &event)
-
-struct InputEvent;
-
-namespace Actions
-{
- decHandler(emote);
- decHandler(outfit);
- decHandler(mouseClick);
- decHandler(ok);
- decHandler(shortcut);
- decHandler(quit);
- decHandler(dropItem0);
- decHandler(dropItem);
- decHandler(dropItemId);
- decHandler(dropItemInv);
- decHandler(dropItemIdAll);
- decHandler(dropItemInvAll);
- decHandler(heal);
- decHandler(healmd);
- decHandler(itenplz);
- decHandler(setHome);
- decHandler(magicAttack);
- decHandler(copyEquippedToOutfit);
- decHandler(pickup);
- decHandler(sit);
- decHandler(screenshot);
- decHandler(ignoreInput);
- decHandler(talk);
- decHandler(buy);
- decHandler(sell);
- decHandler(stopAttack);
- decHandler(untarget);
- decHandler(attack);
- decHandler(targetAttack);
- decHandler(safeVideoMode);
- decHandler(stopSit);
- decHandler(showKeyboard);
- decHandler(showWindows);
- decHandler(openTrade);
- decHandler(ipcToggle);
- decHandler(where);
- decHandler(who);
- decHandler(cleanGraphics);
- decHandler(cleanFonts);
- decHandler(attackHuman);
- decHandler(trade);
- decHandler(priceLoad);
- decHandler(priceSave);
- decHandler(cacheInfo);
- decHandler(disconnect);
- decHandler(undress);
- decHandler(dirs);
- decHandler(uptime);
- decHandler(dump);
- decHandler(serverIgnoreAll);
- decHandler(serverUnIgnoreAll);
- decHandler(error)
-#ifndef BAD_CILKPLUS
- __attribute__ ((noreturn))
-#endif // BAD_CILKPLUS
- ;
- decHandler(dumpGraphics);
- decHandler(dumpEnvironment);
- decHandler(dumpTests);
- decHandler(dumpOGL);
- decHandler(dumpGL);
- decHandler(dumpMods);
-#if defined USE_OPENGL && defined DEBUG_SDLFONT
- decHandler(testSdlFont);
-#endif // defined USE_OPENGL && defined DEBUG_SDLFONT
-
- decHandler(createItems);
- decHandler(createItem);
- decHandler(uploadConfig);
- decHandler(uploadServerConfig);
- decHandler(uploadLog);
- decHandler(mercenaryFire);
- decHandler(mercenaryToMaster);
- decHandler(homunculusToMaster);
- decHandler(homunculusFeed);
- decHandler(useItem);
- decHandler(useItemInv);
- decHandler(invToStorage);
- decHandler(tradeAdd);
- decHandler(storageToInv);
- decHandler(protectItem);
- decHandler(unprotectItem);
- decHandler(kick);
- decHandler(clearDrop);
- decHandler(testInfo);
- decHandler(craftKey);
- decHandler(resetGameModifiers);
- decHandler(barToChat);
- decHandler(seen);
- decHandler(dumpMemoryUsage);
- decHandler(setEmoteType);
-} // namespace Actions
-
-#undef decHandler
-
-#endif // ACTIONS_ACTIONS_H
diff --git a/src/actions/chat.h b/src/actions/chat.h
deleted file mode 100644
index 0e3c362a7..000000000
--- a/src/actions/chat.h
+++ /dev/null
@@ -1,72 +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 ACTIONS_CHAT_H
-#define ACTIONS_CHAT_H
-
-#define decHandler(name) bool name(InputEvent &event)
-
-struct InputEvent;
-
-namespace Actions
-{
- decHandler(toggleChat);
- decHandler(prevChatTab);
- decHandler(nextChatTab);
- decHandler(closeChatTab);
- decHandler(closeAllChatTabs);
- decHandler(ignoreAllWhispers);
- decHandler(scrollChatUp);
- decHandler(scrollChatDown);
- decHandler(msg);
- decHandler(msgText);
- decHandler(msg2);
- decHandler(query);
- decHandler(clearChatTab);
- decHandler(createParty);
- decHandler(createGuild);
- decHandler(party);
- decHandler(guild);
- decHandler(me);
- decHandler(toggle);
- decHandler(kickParty);
- decHandler(kickGuild);
- decHandler(addText);
- decHandler(clearChat);
- decHandler(chatGeneralTab);
- decHandler(chatDebugTab);
- decHandler(chatBattleTab);
- decHandler(chatTradeTab);
- decHandler(chatLangTab);
- decHandler(chatGmTab);
- decHandler(chatPartyTab);
- decHandler(chatGuildTab);
- decHandler(hat);
- decHandler(chatClipboard);
- decHandler(guildNotice);
- decHandler(translate);
- decHandler(sendGuiKey);
- decHandler(sendMouseKey);
- decHandler(sendChars);
-} // namespace Actions
-
-#undef decHandler
-
-#endif // ACTIONS_CHAT_H
diff --git a/src/actions/commands.h b/src/actions/commands.h
deleted file mode 100644
index 414e20658..000000000
--- a/src/actions/commands.h
+++ /dev/null
@@ -1,170 +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 ACTIONS_COMMANDS_H
-#define ACTIONS_COMMANDS_H
-
-#define decHandler(name) bool name(InputEvent &event)
-
-struct InputEvent;
-
-namespace Actions
-{
- decHandler(chatAnnounce);
- decHandler(chatIgnore);
- decHandler(chatUnignore);
- decHandler(chatFriend);
- decHandler(chatDisregard);
- decHandler(chatNeutral);
- decHandler(chatBlackList);
- decHandler(chatEnemy);
- decHandler(chatErase);
- decHandler(chatNuke);
- decHandler(chatAdd);
- decHandler(present);
- decHandler(printAll);
- decHandler(move);
- decHandler(setTarget);
- decHandler(commandOutfit);
- decHandler(commandEmote);
- decHandler(awayMessage);
- decHandler(pseudoAway);
- decHandler(follow);
- decHandler(navigate);
- decHandler(navigateTo);
- decHandler(moveCamera);
- decHandler(restoreCamera);
- decHandler(imitation);
- decHandler(sendMail);
- decHandler(info);
- decHandler(wait);
- decHandler(addPriorityAttack);
- decHandler(addAttack);
- decHandler(removeAttack);
- decHandler(addIgnoreAttack);
- decHandler(setDrop);
- decHandler(url);
- decHandler(openUrl);
- decHandler(execute);
- decHandler(enableHighlight);
- decHandler(disableHighlight);
- decHandler(dontRemoveName);
- decHandler(removeName);
- decHandler(disableAway);
- decHandler(enableAway);
- decHandler(testParticle);
- decHandler(talkRaw);
- decHandler(gm);
- decHandler(hack);
- decHandler(debugSpawn);
- decHandler(serverIgnoreWhisper);
- decHandler(serverUnIgnoreWhisper);
- decHandler(setHomunculusName);
- decHandler(fireHomunculus);
- decHandler(leaveParty);
- decHandler(leaveGuild);
- decHandler(warp);
- decHandler(homunTalk);
- decHandler(homunEmote);
- decHandler(commandHomunEmote);
- decHandler(createPublicChatRoom);
- decHandler(joinChatRoom);
- decHandler(leaveChatRoom);
- decHandler(confSet);
- decHandler(serverConfSet);
- decHandler(confGet);
- decHandler(serverConfGet);
- decHandler(slide);
- decHandler(selectSkillLevel);
- decHandler(skill);
- decHandler(craft);
- decHandler(npcClipboard);
- decHandler(clipboardCopy);
- decHandler(addPickup);
- decHandler(removePickup);
- decHandler(ignorePickup);
- decHandler(monsterInfo);
- decHandler(itemInfo);
- decHandler(whoDrops);
- decHandler(mobSearch);
- decHandler(mobSpawnSearch);
- decHandler(playerGmCommands);
- decHandler(playerCharGmCommands);
- decHandler(commandShowLevel);
- decHandler(commandShowStats);
- decHandler(commandShowStorage);
- decHandler(commandShowCart);
- decHandler(commandShowInventory);
- decHandler(locatePlayer);
- decHandler(commandShowAccountInfo);
- decHandler(commandSpawn);
- decHandler(commandSpawnSlave);
- decHandler(commandSpawnClone);
- decHandler(commandSpawnSlaveClone);
- decHandler(commandSpawnEvilClone);
- decHandler(commandSavePosition);
- decHandler(commandLoadPosition);
- decHandler(commandRandomWarp);
- decHandler(commandGotoNpc);
- decHandler(commandGotoPc);
- decHandler(commandRecallPc);
- decHandler(commandIpCheck);
- decHandler(commandKiller);
- decHandler(commandKillable);
- decHandler(commandHeal);
- decHandler(commandAlive);
- decHandler(commandDisguise);
- decHandler(commandImmortal);
- decHandler(commandHide);
- decHandler(commandNuke);
- decHandler(commandKill);
- decHandler(commandJail);
- decHandler(commandUnjail);
- decHandler(commandNpcMove);
- decHandler(commandNpcHide);
- decHandler(commandNpcShow);
- decHandler(commandChangePartyLeader);
- decHandler(commandPartyRecall);
- decHandler(commandBreakGuild);
- decHandler(commandGuildRecall);
- decHandler(mailTo);
- decHandler(adoptChild);
- decHandler(showSkillLevels);
- decHandler(showSkillType);
- decHandler(selectSkillType);
- decHandler(showSkillOffsetX);
- decHandler(showSkillOffsetY);
- decHandler(setSkillOffsetX);
- decHandler(setSkillOffsetY);
- decHandler(partyItemShare);
- decHandler(partyExpShare);
- decHandler(partyAutoItemShare);
- decHandler(outfitToChat);
- decHandler(outfitClear);
- decHandler(moveAttackUp);
- decHandler(moveAttackDown);
- decHandler(movePriorityAttackUp);
- decHandler(movePriorityAttackDown);
- decHandler(addSkillShortcut);
-} // namespace Actions
-
-#undef decHandler
-
-#endif // ACTIONS_COMMANDS_H
diff --git a/src/actions/move.h b/src/actions/move.h
deleted file mode 100644
index 362cc254e..000000000
--- a/src/actions/move.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 ACTIONS_MOVE_H
-#define ACTIONS_MOVE_H
-
-#define decHandler(name) bool name(InputEvent &event)
-
-struct InputEvent;
-
-namespace Actions
-{
- decHandler(moveUp);
- decHandler(moveDown);
- decHandler(moveLeft);
- decHandler(moveRight);
- decHandler(moveForward);
- decHandler(moveToPoint);
- decHandler(crazyMoves);
- decHandler(moveToTarget);
- decHandler(moveToHome);
- decHandler(directUp);
- decHandler(directDown);
- decHandler(directLeft);
- decHandler(directRight);
-} // namespace Actions
-
-#undef decHandler
-
-#endif // ACTIONS_MOVE_H
diff --git a/src/actions/pets.h b/src/actions/pets.h
deleted file mode 100644
index 5bc3bd5a9..000000000
--- a/src/actions/pets.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 ACTIONS_PETS_H
-#define ACTIONS_PETS_H
-
-#define decHandler(name) bool name(InputEvent &event)
-
-struct InputEvent;
-
-namespace Actions
-{
- decHandler(commandEmotePet);
- decHandler(talkPet);
- decHandler(setPetName);
- decHandler(petEmote);
- decHandler(catchPet);
- decHandler(petMoveUp);
- decHandler(petMoveDown);
- decHandler(petMoveLeft);
- decHandler(petMoveRight);
- decHandler(petDirectUp);
- decHandler(petDirectDown);
- decHandler(petDirectLeft);
- decHandler(petDirectRight);
- decHandler(petMove);
- decHandler(petFeed);
- decHandler(petDropLoot);
- decHandler(petReturnToEgg);
- decHandler(petUnequip);
-} // namespace Actions
-
-#undef decHandler
-
-#endif // ACTIONS_PETS_H
diff --git a/src/actions/statusbar.h b/src/actions/statusbar.h
deleted file mode 100644
index 093aefd04..000000000
--- a/src/actions/statusbar.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 ACTIONS_STATUSBAR_H
-#define ACTIONS_STATUSBAR_H
-
-#define decHandler(name) bool name(InputEvent &event)
-
-struct InputEvent;
-
-namespace Actions
-{
- decHandler(switchQuickDrop);
- decHandler(changeCrazyMove);
- decHandler(changePickupType);
- decHandler(changeMoveType);
- decHandler(changeAttackWeaponType);
- decHandler(changeAttackType);
- decHandler(changeTargetingType);
- decHandler(changeFollowMode);
- decHandler(changeImitationMode);
- decHandler(changeMagicAttackType);
- decHandler(changePvpMode);
- decHandler(changeMoveToTarget);
- decHandler(changeGameModifier);
- decHandler(changeAudio);
- decHandler(away);
- decHandler(camera);
- decHandler(changeMapMode);
- decHandler(changeTrade);
-} // namespace Actions
-
-#undef decHandler
-
-#endif // ACTIONS_STATUSBAR_H
diff --git a/src/actions/tabs.h b/src/actions/tabs.h
deleted file mode 100644
index f7edb1c8c..000000000
--- a/src/actions/tabs.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 ACTIONS_TABS_H
-#define ACTIONS_TABS_H
-
-#define decHandler(name) bool name(InputEvent &event)
-
-struct InputEvent;
-
-namespace Actions
-{
- decHandler(prevSocialTab);
- decHandler(nextSocialTab);
- decHandler(nextShortcutsTab);
- decHandler(prevShortcutsTab);
- decHandler(nextCommandsTab);
- decHandler(prevCommandsTab);
- decHandler(nextInvTab);
- decHandler(prevInvTab);
-} // namespace Actions
-
-#undef decHandler
-
-#endif // ACTIONS_TABS_H
diff --git a/src/actions/target.h b/src/actions/target.h
deleted file mode 100644
index cf5bacf26..000000000
--- a/src/actions/target.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 ACTIONS_TARGET_H
-#define ACTIONS_TARGET_H
-
-#define decHandler(name) bool name(InputEvent &event)
-
-struct InputEvent;
-
-namespace Actions
-{
- decHandler(targetPlayer);
- decHandler(targetMonster);
- decHandler(targetClosestMonster);
- decHandler(targetNPC);
- decHandler(targetMercenary);
- decHandler(targetPet);
- decHandler(targetSkillUnit);
- decHandler(contextMenu);
-} // namespace Actions
-
-#undef decHandler
-
-#endif // ACTIONS_TARGET_H
diff --git a/src/actions/windows.h b/src/actions/windows.h
deleted file mode 100644
index 8b6311281..000000000
--- a/src/actions/windows.h
+++ /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/>.
- */
-
-#ifndef ACTIONS_WINDOWS_H
-#define ACTIONS_WINDOWS_H
-
-#define decHandler(name) bool name(InputEvent &event)
-
-struct InputEvent;
-
-namespace Actions
-{
- decHandler(hideWindows);
- decHandler(helpWindowShow);
- decHandler(aboutWindowShow);
- decHandler(setupWindowShow);
- decHandler(statusWindowShow);
- decHandler(inventoryWindowShow);
- decHandler(equipmentWindowShow);
- decHandler(skillDialogShow);
- decHandler(minimapWindowShow);
- decHandler(chatWindowShow);
- decHandler(shortcutWindowShow);
- decHandler(debugWindowShow);
- decHandler(socialWindowShow);
- decHandler(emoteShortcutWindowShow);
- decHandler(outfitWindowShow);
- decHandler(shopWindowShow);
- decHandler(dropShortcutWindowShow);
- decHandler(killStatsWindowShow);
- decHandler(spellShortcutWindowShow);
- decHandler(whoIsOnlineWindowShow);
- decHandler(didYouKnowWindowShow);
- decHandler(questsWindowShow);
- decHandler(updaterWindowShow);
- decHandler(bankWindowShow);
- decHandler(cartWindowShow);
- decHandler(quickWindowShow);
- decHandler(mailWindowShow);
- decHandler(serverInfoWindowShow);
- decHandler(showItems);
-} // namespace Actions
-
-#undef decHandler
-
-#endif // ACTIONS_WINDOWS_H
diff --git a/src/actormanager.cpp b/src/actormanager.cpp
deleted file mode 100644
index c4079f776..000000000
--- a/src/actormanager.cpp
+++ /dev/null
@@ -1,2265 +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 "actormanager.h"
-
-#include "game.h"
-#include "configuration.h"
-#include "settings.h"
-
-#include "being/localplayer.h"
-#include "being/playerrelations.h"
-
-#include "gui/sdlinput.h"
-#include "gui/viewport.h"
-
-#include "gui/widgets/tabs/chat/chattab.h"
-
-#include "gui/windows/equipmentwindow.h"
-#include "gui/windows/socialwindow.h"
-#include "gui/windows/questswindow.h"
-
-#include "fs/files.h"
-
-#include "input/inputmanager.h"
-
-#include "utils/checkutils.h"
-#include "utils/foreach.h"
-#include "utils/mathutils.h"
-#include "utils/gettext.h"
-
-#include "net/beinghandler.h"
-#include "net/charserverhandler.h"
-#include "net/packetlimiter.h"
-#include "net/playerhandler.h"
-#include "net/serverfeatures.h"
-
-#include "resources/chatobject.h"
-#include "resources/iteminfo.h"
-
-#include "resources/map/map.h"
-
-#include "resources/db/itemdb.h"
-
-#ifdef TMWA_SUPPORT
-#include "being/playerinfo.h"
-
-#include "gui/windows/chatwindow.h"
-
-#include "net/net.h"
-#endif // TMWA_SUPPORT
-
-#include <algorithm>
-
-#include "debug.h"
-
-#define for_actors for (ActorSpritesConstIterator it = mActors.begin(), \
- it_fend = mActors.end(); it != it_fend; ++it)
-
-#define for_actorsm for (ActorSpritesIterator it = mActors.begin(), \
- it_fend = mActors.end(); it != it_fend; ++it)
-
-ActorManager *actorManager = nullptr;
-
-class FindBeingFunctor final
-{
- public:
- A_DEFAULT_COPY(FindBeingFunctor)
-
- bool operator() (const ActorSprite *const actor) const
- {
- if ((actor == nullptr)
- || actor->getType() == ActorType::FloorItem
- || actor->getType() == ActorType::Portal)
- {
- return false;
- }
- const Being *const b = static_cast<const Being *>(actor);
-
- const unsigned other_y = y
- + ((b->getType() == ActorType::Npc) ? 1 : 0);
- const Vector &pos = b->getPixelPositionF();
- // +++ probably here need use int positions and not float?
- // but for now correct int positions only in Being
- return CAST_U32(pos.x) / mapTileSize == x &&
- (CAST_U32(pos.y) / mapTileSize == y
- || CAST_U32(pos.y) / mapTileSize == other_y) &&
- b->isAlive() && (type == ActorType::Unknown
- || b->getType() == type);
- }
-
- uint16_t x, y;
- ActorTypeT type;
-} beingActorFinder;
-
-class FindBeingEqualFunctor final
-{
- public:
- A_DEFAULT_COPY(FindBeingEqualFunctor)
-
- bool operator() (const Being *const being) const
- {
- if ((being == nullptr) || (findBeing == nullptr))
- return false;
- return being->getId() == findBeing->getId();
- }
-
- Being *findBeing;
-} beingEqualActorFinder;
-
-class SortBeingFunctor final
-{
- public:
- A_DEFAULT_COPY(SortBeingFunctor)
-
- bool operator() (const Being *const being1,
- const Being *const being2) const
- {
- if ((being1 == nullptr) || (being2 == nullptr))
- return false;
-
- if (priorityBeings != nullptr)
- {
- int w1 = defaultPriorityIndex;
- int w2 = defaultPriorityIndex;
- const StringIntMapCIter it1 = priorityBeings->find(
- being1->getName());
- const StringIntMapCIter it2 = priorityBeings->find(
- being2->getName());
- if (it1 != priorityBeings->end())
- w1 = (*it1).second;
- if (it2 != priorityBeings->end())
- w2 = (*it2).second;
-
- if (w1 != w2)
- return w1 < w2;
- }
- if (being1->getDistance() != being2->getDistance())
- {
- if (specialDistance && being1->getDistance() <= 2
- && being2->getDistance() <= attackRange
- && being2->getDistance() > 2)
- {
- return false;
- }
- else if (specialDistance && being2->getDistance() <= 2
- && being1->getDistance() <= attackRange
- && being1->getDistance() > 2)
- {
- return true;
- }
- return being1->getDistance() < being2->getDistance();
- }
-
- const int d1 = abs(being1->getTileX() - x)
- + abs(being1->getTileY() - y);
- const int d2 = abs(being2->getTileX() - x)
- + abs(being2->getTileY() - y);
-
- if (d1 != d2)
- return d1 < d2;
- if (attackBeings != nullptr)
- {
- int w1 = defaultAttackIndex;
- int w2 = defaultAttackIndex;
- const StringIntMapCIter it1 = attackBeings->find(
- being1->getName());
- const StringIntMapCIter it2 = attackBeings->find(
- being2->getName());
- if (it1 != attackBeings->end())
- w1 = (*it1).second;
- if (it2 != attackBeings->end())
- w2 = (*it2).second;
-
- if (w1 != w2)
- return w1 < w2;
- }
-
- return being1->getName() < being2->getName();
- }
- StringIntMap *attackBeings;
- StringIntMap *priorityBeings;
- int x;
- int y;
- int defaultAttackIndex;
- int defaultPriorityIndex;
- int attackRange;
- bool specialDistance;
-} beingActorSorter;
-
-ActorManager::ActorManager() :
- mActors(),
- mDeleteActors(),
- mActorsIdMap(),
- mIdName(),
- mBlockedBeings(),
- mChars(),
- mMap(nullptr),
-#ifdef TMWA_SUPPORT
- mSpellHeal1(serverConfig.getValue("spellHeal1", "#lum")),
- mSpellHeal2(serverConfig.getValue("spellHeal2", "#inma")),
- mSpellItenplz(serverConfig.getValue("spellItenplz", "#itenplz")),
-#endif // TMWA_SUPPORT
- mTargetDeadPlayers(config.getBoolValue("targetDeadPlayers")),
- mTargetOnlyReachable(config.getBoolValue("targetOnlyReachable")),
- mCyclePlayers(config.getBoolValue("cyclePlayers")),
- mCycleMonsters(config.getBoolValue("cycleMonsters")),
- mCycleNPC(config.getBoolValue("cycleNPC")),
- mExtMouseTargeting(config.getBoolValue("extMouseTargeting")),
- mEnableIdCollecting(config.getBoolValue("enableIdCollecting")),
- mPriorityAttackMobs(),
- mPriorityAttackMobsSet(),
- mPriorityAttackMobsMap(),
- mAttackMobs(),
- mAttackMobsSet(),
- mAttackMobsMap(),
- mIgnoreAttackMobs(),
- mIgnoreAttackMobsSet(),
- mPickupItems(),
- mPickupItemsSet(),
- mPickupItemsMap(),
- mIgnorePickupItems(),
- mIgnorePickupItemsSet()
-{
- config.addListener("targetDeadPlayers", this);
- config.addListener("targetOnlyReachable", this);
- config.addListener("cyclePlayers", this);
- config.addListener("cycleMonsters", this);
- config.addListener("cycleNPC", this);
- config.addListener("extMouseTargeting", this);
- config.addListener("showBadges", this);
- config.addListener("enableIdCollecting", this);
- config.addListener("visiblenamespos", this);
-
- loadAttackList();
-}
-
-ActorManager::~ActorManager()
-{
- config.removeListeners(this);
- CHECKLISTENERS
- storeAttackList();
- clear();
-}
-
-void ActorManager::setMap(Map *const map)
-{
- mMap = map;
-
- if (localPlayer != nullptr)
- localPlayer->setMap(map);
-}
-
-void ActorManager::setPlayer(LocalPlayer *const player)
-{
- localPlayer = player;
- mActors.insert(player);
- mActorsIdMap[player->getId()] = player;
- if (socialWindow != nullptr)
- socialWindow->updateAttackFilter();
- if (socialWindow != nullptr)
- socialWindow->updatePickupFilter();
-}
-
-Being *ActorManager::createBeing(const BeingId id,
- const ActorTypeT type,
- const BeingTypeId subtype)
-{
- Being *const being = Being::createBeing(id,
- type,
- subtype,
- mMap);
-
- mActors.insert(being);
-
- mActorsIdMap[being->getId()] = being;
-
- switch (type)
- {
- case ActorType::Player:
- case ActorType::Mercenary:
- case ActorType::Pet:
- case ActorType::Homunculus:
- case ActorType::Npc:
- being->updateFromCache();
- if (beingHandler != nullptr)
- beingHandler->requestNameById(id);
- if (localPlayer != nullptr)
- localPlayer->checkNewName(being);
- break;
- case ActorType::Monster:
-#ifdef TMWA_SUPPORT
- if (Net::getNetworkType() != ServerType::TMWATHENA)
-#endif // TMWA_SUPPORT
- {
- beingHandler->requestNameById(id);
- }
- break;
- case ActorType::Portal:
- if ((beingHandler != nullptr) &&
- (serverFeatures != nullptr) &&
- serverFeatures->haveServerWarpNames())
- {
- beingHandler->requestNameById(id);
- }
- break;
- case ActorType::Elemental:
- if (beingHandler != nullptr)
- beingHandler->requestNameById(id);
- break;
- case ActorType::SkillUnit:
- break;
- default:
- case ActorType::FloorItem:
- case ActorType::Avatar:
- case ActorType::Unknown:
- reportAlways("CreateBeing for unknown type %d", CAST_S32(type));
- break;
- }
-
- if (type == ActorType::Player)
- {
- if (socialWindow != nullptr)
- socialWindow->updateActiveList();
- }
- else if (type == ActorType::Npc)
- {
- if (questsWindow != nullptr)
- questsWindow->addEffect(being);
- }
- return being;
-}
-
-FloorItem *ActorManager::createItem(const BeingId id,
- const int itemId,
- const int x, const int y,
- const ItemTypeT itemType,
- const int amount,
- const int refine,
- const ItemColor color,
- const Identified identified,
- const Damaged damaged,
- const int subX, const int subY,
- const int *const cards)
-{
- FloorItem *const floorItem = new FloorItem(id,
- itemId,
- x, y,
- itemType,
- amount,
- refine,
- color,
- identified,
- damaged,
- cards);
- floorItem->postInit(mMap, subX, subY);
-
- if (!checkForPickup(floorItem))
- floorItem->disableHightlight();
- mActors.insert(floorItem);
- mActorsIdMap[floorItem->getId()] = floorItem;
- return floorItem;
-}
-
-void ActorManager::destroy(ActorSprite *const actor)
-{
- returnNullptrV(actor);
-
- if (actor == localPlayer)
- return;
-
- mDeleteActors.insert(actor);
-}
-
-void ActorManager::erase(ActorSprite *const actor)
-{
- returnNullptrV(actor);
-
- if (actor == localPlayer)
- return;
-
- mActors.erase(actor);
- const ActorSpritesMapIterator it = mActorsIdMap.find(actor->getId());
- if (it != mActorsIdMap.end() && (*it).second == actor)
- mActorsIdMap.erase(it);
-}
-
-void ActorManager::undelete(const ActorSprite *const actor)
-{
- returnNullptrV(actor);
-
- if (actor == localPlayer)
- return;
-
- FOR_EACH (ActorSpritesConstIterator, it, mDeleteActors)
- {
- if (*it == actor)
- {
- mDeleteActors.erase(*it);
- return;
- }
- }
-}
-
-Being *ActorManager::findBeing(const BeingId id) const
-{
- const ActorSpritesMapConstIterator it = mActorsIdMap.find(id);
- if (it != mActorsIdMap.end())
- {
- ActorSprite *const actor = (*it).second;
- if ((actor != nullptr) &&
- actor->getId() == id &&
- actor->getType() != ActorType::FloorItem)
- {
- return static_cast<Being*>(actor);
- }
- }
- return nullptr;
-}
-
-ActorSprite *ActorManager::findActor(const BeingId id) const
-{
- const ActorSpritesMapConstIterator it = mActorsIdMap.find(id);
- if (it != mActorsIdMap.end())
- {
- ActorSprite *const actor = (*it).second;
- if ((actor != nullptr) &&
- actor->getId() == id)
- {
- return actor;
- }
- }
- return nullptr;
-}
-
-Being *ActorManager::findBeing(const int x, const int y,
- const ActorTypeT type) const
-{
- beingActorFinder.x = CAST_U16(x);
- beingActorFinder.y = CAST_U16(y);
- beingActorFinder.type = type;
-
- const ActorSpritesConstIterator it = std::find_if(
- mActors.begin(), mActors.end(), beingActorFinder);
-
- return (it == mActors.end()) ? nullptr : static_cast<Being*>(*it);
-}
-
-Being *ActorManager::findBeingByPixel(const int x, const int y,
- const AllPlayers allPlayers) const
-{
- if (mMap == nullptr)
- return nullptr;
-
- const bool targetDead = mTargetDeadPlayers;
- const bool modActive = inputManager.isActionActive(
- InputAction::STOP_ATTACK);
-
- if (mExtMouseTargeting)
- {
- Being *tempBeing = nullptr;
- bool noBeing(false);
-
- for_actorsm
- {
-// disabled for performance
-// if (reportTrue(*it == nullptr))
-// continue;
-
- if ((*it)->getType() == ActorType::Portal)
- continue;
-
- if ((*it)->getType() == ActorType::FloorItem)
- {
- if (!noBeing)
- {
- const FloorItem *const floor
- = static_cast<const FloorItem*>(*it);
- const int px = floor->getPixelX();
- const int py = floor->getPixelY();
- if ((px - mapTileSize <= x) &&
- (px + mapTileSize > x) &&
- (py - mapTileSize * 2 <= y) &&
- (py + mapTileSize / 2 > y))
- {
- noBeing = true;
- }
- }
- continue;
- }
-
- Being *const being = static_cast<Being*>(*it);
-
- if (being->getInfo() != nullptr &&
- !(being->getInfo()->isTargetSelection() || modActive))
- {
- continue;
- }
-
- if ((being->mAction != BeingAction::DEAD ||
- (targetDead && being->getType() == ActorType::Player)) &&
- (allPlayers == AllPlayers_true || being != localPlayer))
- {
- const int px = being->getPixelX();
- const int py = being->getPixelY();
- if ((px - mapTileSize / 2 <= x) &&
- (px + mapTileSize / 2 > x) &&
- (py - mapTileSize <= y) &&
- (py > y))
- {
- return being;
- }
- else if (!noBeing &&
- (px - mapTileSize <= x) &&
- (px + mapTileSize > x) &&
- (py - mapTileSize * 2 <= y) &&
- (py + mapTileSize / 2 > y))
- {
- if (tempBeing != nullptr)
- noBeing = true;
- else
- tempBeing = being;
- }
- }
- }
-
- if (noBeing)
- return nullptr;
- return tempBeing;
- }
- for_actorsm
- {
-// disabled for performance
-// if (reportTrue(*it == nullptr))
-// continue;
-
- if ((*it)->getType() == ActorType::Portal ||
- (*it)->getType() == ActorType::FloorItem)
- {
- continue;
- }
-
- Being *const being = static_cast<Being*>(*it);
-
- if (being->getInfo() != nullptr &&
- !(being->getInfo()->isTargetSelection() || modActive))
- {
- continue;
- }
-
- const int px = being->getPixelX();
- const int py = being->getPixelY();
- if ((px - mapTileSize / 2 <= x) &&
- (px + mapTileSize / 2 > x) &&
- (py - mapTileSize <= y) &&
- (py > y))
- {
- return being;
- }
- }
- return nullptr;
-}
-
-void ActorManager::findBeingsByPixel(STD_VECTOR<ActorSprite*> &beings,
- const int x, const int y,
- const AllPlayers allPlayers) const
-{
- if (mMap == nullptr)
- return;
-
- const int xtol = mapTileSize / 2;
- const int uptol = mapTileSize;
- const bool modActive = inputManager.isActionActive(
- InputAction::STOP_ATTACK);
-
- for_actors
- {
- ActorSprite *const actor = *it;
-
-// disabled for performance
-// if (reportTrue(actor == nullptr))
-// continue;
-
- const ActorTypeT actorType = actor->getType();
- switch (actorType)
- {
- default:
- case ActorType::Unknown:
- case ActorType::Avatar:
- case ActorType::Portal:
- break;
- case ActorType::FloorItem:
- if ((actor->getPixelX() - xtol <= x) &&
- (actor->getPixelX() + xtol > x) &&
- (actor->getPixelY() - uptol <= y) &&
- (actor->getPixelY() > y))
- {
- beings.push_back(actor);
- }
- break;
- case ActorType::Player:
- case ActorType::Npc:
- case ActorType::Monster:
- case ActorType::Pet:
- case ActorType::Mercenary:
- case ActorType::Homunculus:
- case ActorType::SkillUnit:
- case ActorType::Elemental:
- {
- const Being *const being = static_cast<const Being*>(*it);
- if (being == nullptr)
- continue;
- if ((being->getInfo() != nullptr) &&
- !(being->getInfo()->isTargetSelection() || modActive))
- {
- continue;
- }
- if ((being->isAlive() ||
- (mTargetDeadPlayers &&
- actorType == ActorType::Player)) &&
- (allPlayers == AllPlayers_true ||
- being != localPlayer))
- {
- if ((actor->getPixelX() - xtol <= x) &&
- (actor->getPixelX() + xtol > x) &&
- (actor->getPixelY() - uptol <= y) &&
- (actor->getPixelY() > y))
- {
- beings.push_back(actor);
- }
- }
- break;
- }
- }
- }
-}
-
-Being *ActorManager::findPortalByTile(const int x, const int y) const
-{
- if (mMap == nullptr)
- return nullptr;
-
- for_actorsm
- {
-// disabled for performance
-// if (reportTrue(*it == nullptr))
-// continue;
-
- if ((*it)->getType() != ActorType::Portal)
- continue;
-
- Being *const being = static_cast<Being*>(*it);
-
- if (being->getTileX() == x && being->getTileY() == y)
- return being;
- }
-
- return nullptr;
-}
-
-FloorItem *ActorManager::findItem(const BeingId id) const
-{
- const ActorSpritesMapConstIterator it = mActorsIdMap.find(id);
- if (it != mActorsIdMap.end())
- {
- ActorSprite *const actor = (*it).second;
- returnNullptr(nullptr, actor);
- if (actor->getId() == id &&
- actor->getType() == ActorType::FloorItem)
- {
- return static_cast<FloorItem*>(actor);
- }
- }
- return nullptr;
-}
-
-FloorItem *ActorManager::findItem(const int x, const int y) const
-{
- for_actorsm
- {
-// disabled for performance
-// if (reportTrue(*it == nullptr))
-// continue;
-
- if ((*it)->getTileX() == x && (*it)->getTileY() == y &&
- (*it)->getType() == ActorType::FloorItem)
- {
- return static_cast<FloorItem*>(*it);
- }
- }
-
- return nullptr;
-}
-
-bool ActorManager::pickUpAll(const int x1, const int y1,
- const int x2, const int y2,
- const bool serverBuggy) const
-{
- if (localPlayer == nullptr)
- return false;
-
- bool finded(false);
- const bool allowAll = mPickupItemsSet.find("") != mPickupItemsSet.end();
- if (!serverBuggy)
- {
- for_actorsm
- {
-// disabled for performance
-// if (reportTrue(*it == nullptr))
-// continue;
-
- if ((*it)->getType() == ActorType::FloorItem
- && ((*it)->getTileX() >= x1 && (*it)->getTileX() <= x2)
- && ((*it)->getTileY() >= y1 && (*it)->getTileY() <= y2))
- {
- FloorItem *const item = static_cast<FloorItem*>(*it);
- if (allowAll)
- {
- if (mIgnorePickupItemsSet.find(item->getName())
- == mIgnorePickupItemsSet.end())
- {
- if (localPlayer->pickUp(item))
- finded = true;
- }
- }
- else
- {
- if (mPickupItemsSet.find(item->getName())
- != mPickupItemsSet.end())
- {
- if (localPlayer->pickUp(item))
- finded = true;
- }
- }
- }
- }
- }
- else if (PacketLimiter::checkPackets(PacketType::PACKET_PICKUP))
- {
- FloorItem *item = nullptr;
- unsigned cnt = 65535;
- for_actorsm
- {
-// disabled for performance
-// if (reportTrue(*it == nullptr))
-// continue;
-
- if ((*it)->getType() == ActorType::FloorItem
- && ((*it)->getTileX() >= x1 && (*it)->getTileX() <= x2)
- && ((*it)->getTileY() >= y1 && (*it)->getTileY() <= y2))
- {
- FloorItem *const tempItem = static_cast<FloorItem*>(*it);
- if (tempItem->getPickupCount() < cnt)
- {
- if (allowAll)
- {
- if (mIgnorePickupItemsSet.find(tempItem->getName())
- == mIgnorePickupItemsSet.end())
- {
- item = tempItem;
- cnt = item->getPickupCount();
- if (cnt == 0)
- {
- item->incrementPickup();
- localPlayer->pickUp(item);
- return true;
- }
- }
- }
- else
- {
- if (mPickupItemsSet.find(tempItem->getName())
- != mPickupItemsSet.end())
- {
- item = tempItem;
- cnt = item->getPickupCount();
- if (cnt == 0)
- {
- item->incrementPickup();
- localPlayer->pickUp(item);
- return true;
- }
- }
- }
- }
- }
- }
- if ((item != nullptr) && localPlayer->pickUp(item))
- finded = true;
- }
- return finded;
-}
-
-bool ActorManager::pickUpNearest(const int x, const int y,
- int maxdist) const
-{
- if (localPlayer == nullptr)
- return false;
-
- maxdist = maxdist * maxdist;
- FloorItem *closestItem = nullptr;
- int dist = 0;
- const bool allowAll = mPickupItemsSet.find("") != mPickupItemsSet.end();
-
- for_actorsm
- {
-// disabled for performance
-// if (reportTrue(*it == nullptr))
-// continue;
-
- if ((*it)->getType() == ActorType::FloorItem)
- {
- FloorItem *const item = static_cast<FloorItem*>(*it);
-
- const int d = (item->getTileX() - x) * (item->getTileX() - x)
- + (item->getTileY() - y) * (item->getTileY() - y);
-
- if ((d < dist || closestItem == nullptr) &&
- (!mTargetOnlyReachable || localPlayer->isReachable(
- item->getTileX(), item->getTileY(),
- false)))
- {
- if (allowAll)
- {
- if (mIgnorePickupItemsSet.find(item->getName())
- == mIgnorePickupItemsSet.end())
- {
- dist = d;
- closestItem = item;
- }
- }
- else
- {
- if (mPickupItemsSet.find(item->getName())
- != mPickupItemsSet.end())
- {
- dist = d;
- closestItem = item;
- }
- }
- }
- }
- }
- if ((closestItem != nullptr) && dist <= maxdist)
- return localPlayer->pickUp(closestItem);
-
- return false;
-}
-
-Being *ActorManager::findBeingByName(const std::string &name,
- const ActorTypeT type) const
-{
- for_actorsm
- {
-// disabled for performance
-// if (reportTrue(*it == nullptr))
-// continue;
-
- if ((*it)->getType() == ActorType::FloorItem
- || (*it)->getType() == ActorType::Portal)
- {
- continue;
- }
-
- Being *const being = static_cast<Being*>(*it);
- if (being->getName() == name &&
- (type == ActorType::Unknown || type == being->getType()))
- {
- return being;
- }
- }
- return nullptr;
-}
-
-Being *ActorManager::findNearestByName(const std::string &name,
- const ActorTypeT &type) const
-{
- if (localPlayer == nullptr)
- return nullptr;
-
- int dist = 0;
- Being* closestBeing = nullptr;
- int x, y;
-
- x = localPlayer->getTileX();
- y = localPlayer->getTileY();
-
- for_actorsm
- {
-// disabled for performance
-// if (reportTrue(*it == nullptr))
-// continue;
-
- if ((*it)->getType() == ActorType::FloorItem
- || (*it)->getType() == ActorType::Portal)
- {
- continue;
- }
-
- Being *const being = static_cast<Being*>(*it);
-
- if ((being != nullptr) && being->getName() == name &&
- (type == ActorType::Unknown || type == being->getType()))
- {
- if (being->getType() == ActorType::Player)
- {
- return being;
- }
- const int d = (being->getTileX() - x) * (being->getTileX() - x)
- + (being->getTileY() - y) * (being->getTileY() - y);
-
- if (validateBeing(nullptr, being, type, nullptr, 50)
- && (d < dist || closestBeing == nullptr))
- {
- dist = d;
- closestBeing = being;
- }
- }
- }
- return closestBeing;
-}
-
-const ActorSprites &ActorManager::getAll() const
-{
- return mActors;
-}
-
-void ActorManager::logic()
-{
- BLOCK_START("ActorManager::logic")
- for_actors
- {
-// disabled for performance
-// if (reportFalse(*it))
- (*it)->logic();
- }
-
- if (mDeleteActors.empty())
- {
- BLOCK_END("ActorManager::logic")
- return;
- }
-
- BLOCK_START("ActorManager::logic 1")
- FOR_EACH (ActorSpritesConstIterator, it, mDeleteActors)
- {
- const ActorSprite *const actor = *it;
- const ActorTypeT &type = actor->getType();
- if (type == ActorType::Player)
- {
- const Being *const being = static_cast<const Being*>(actor);
- being->addToCache();
- if (beingEquipmentWindow != nullptr)
- beingEquipmentWindow->resetBeing(being);
- }
- if (localPlayer != nullptr)
- {
- if (localPlayer->getTarget() == actor)
- localPlayer->setTarget(nullptr);
- if (localPlayer->getPickUpTarget() == actor)
- localPlayer->unSetPickUpTarget();
- }
- if (viewport != nullptr)
- viewport->clearHover(*it);
- }
-
- FOR_EACH (ActorSpritesConstIterator, it, mDeleteActors)
- {
- ActorSprite *actor = *it;
- mActors.erase(actor);
-
- if (actor != nullptr)
- {
- const ActorSpritesMapIterator itr = mActorsIdMap.find(
- actor->getId());
- if (itr != mActorsIdMap.end() && (*itr).second == actor)
- mActorsIdMap.erase(itr);
-
- delete actor;
- }
- }
-
- mDeleteActors.clear();
- BLOCK_END("ActorManager::logic 1")
- BLOCK_END("ActorManager::logic")
-}
-
-void ActorManager::clear()
-{
- if (beingEquipmentWindow != nullptr)
- beingEquipmentWindow->setBeing(nullptr);
-
- if (localPlayer != nullptr)
- {
- localPlayer->setTarget(nullptr);
- localPlayer->unSetPickUpTarget();
- mActors.erase(localPlayer);
- }
-
- for_actors
- delete *it;
- mActors.clear();
- mDeleteActors.clear();
- mActorsIdMap.clear();
-
- if (localPlayer != nullptr)
- {
- mActors.insert(localPlayer);
- mActorsIdMap[localPlayer->getId()] = localPlayer;
- }
-
- mChars.clear();
-}
-
-Being *ActorManager::findNearestPvpPlayer() const
-{
- if (localPlayer == nullptr)
- return nullptr;
-
- // don't attack players
- if (settings.pvpAttackType == 3)
- return nullptr;
-
- const Game *const game = Game::instance();
- if (game == nullptr)
- return nullptr;
-
- const Map *const map = game->getCurrentMap();
- if (map == nullptr)
- return nullptr;
-
- const int mapPvpMode = map->getPvpMode();
- Being *target = nullptr;
- int minDistSquared = 20000;
-
- for_actors
- {
- if ((*it)->getType() != ActorType::Player)
- continue;
-
- Being *const being = static_cast<Being*>(*it);
-
- if (reportTrue(being == nullptr) ||
- !being->isAlive() ||
- localPlayer == being)
- {
- continue;
- }
-
- const int teamId = being->getTeamId();
- // this condition is very TMW-specific
- if (!((mapPvpMode != 0) || (teamId != 0)))
- continue;
-
- if (!LocalPlayer::checAttackPermissions(being))
- continue;
-
- const int dx = being->getTileX() - localPlayer->getTileX();
- const int dy = being->getTileY() - localPlayer->getTileY();
- const int distSquared = dx * dx + dy * dy;
- if (distSquared < minDistSquared)
- {
- minDistSquared = distSquared;
- target = being;
- }
- }
-
- return target;
-}
-
-
-Being *ActorManager::findNearestLivingBeing(const int x, const int y,
- const int maxTileDist,
- const ActorTypeT type,
- const Being *const excluded) const
-{
- const int maxDist = maxTileDist * mapTileSize;
-
- return findNearestLivingBeing(nullptr, maxDist,
- type,
- x, y,
- excluded,
- AllowSort_true);
-}
-
-Being *ActorManager::findNearestLivingBeing(const Being *const aroundBeing,
- const int maxDist,
- const ActorTypeT type,
- const AllowSort allowSort) const
-{
- if (aroundBeing == nullptr)
- return nullptr;
-
- return findNearestLivingBeing(aroundBeing,
- maxDist,
- type,
- aroundBeing->getTileX(),
- aroundBeing->getTileY(),
- aroundBeing,
- allowSort);
-}
-
-Being *ActorManager::findNearestLivingBeing(const Being *const aroundBeing,
- int maxDist,
- const ActorTypeT &type,
- const int x, const int y,
- const Being *const excluded,
- const AllowSort allowSort) const
-{
- if ((aroundBeing == nullptr) || (localPlayer == nullptr))
- return nullptr;
-
- std::set<std::string> attackMobs;
- std::set<std::string> priorityMobs;
- std::set<std::string> ignoreAttackMobs;
- StringIntMap attackMobsMap;
- StringIntMap priorityMobsMap;
- int defaultAttackIndex = 10000;
- int defaultPriorityIndex = 10000;
- const int attackRange = localPlayer->getAttackRange();
-
- bool specialDistance = false;
- if (settings.moveToTargetType == 11
- && localPlayer->getAttackRange() > 2)
- {
- specialDistance = true;
- }
-
- maxDist = maxDist * maxDist;
-
- const bool cycleSelect = allowSort == AllowSort_true
- && ((mCyclePlayers && type == ActorType::Player)
- || (mCycleMonsters && type == ActorType::Monster)
- || (mCycleNPC && type == ActorType::Npc));
-
- const bool filtered = allowSort == AllowSort_true
- && config.getBoolValue("enableAttackFilter")
- && type == ActorType::Monster;
- const bool modActive = inputManager.isActionActive(
- InputAction::STOP_ATTACK);
-
- bool ignoreDefault = false;
- if (filtered)
- {
- attackMobs = mAttackMobsSet;
- priorityMobs = mPriorityAttackMobsSet;
- ignoreAttackMobs = mIgnoreAttackMobsSet;
- attackMobsMap = mAttackMobsMap;
- priorityMobsMap = mPriorityAttackMobsMap;
- beingActorSorter.attackBeings = &attackMobsMap;
- beingActorSorter.priorityBeings = &priorityMobsMap;
- beingActorSorter.specialDistance = specialDistance;
- beingActorSorter.attackRange = attackRange;
- if (ignoreAttackMobs.find("") != ignoreAttackMobs.end())
- ignoreDefault = true;
- StringIntMapCIter itr = attackMobsMap.find("");
- if (itr != attackMobsMap.end())
- defaultAttackIndex = (*itr).second;
- itr = priorityMobsMap.find("");
- if (itr != priorityMobsMap.end())
- defaultPriorityIndex = (*itr).second;
- }
-
- if (cycleSelect)
- {
- STD_VECTOR<Being*> sortedBeings;
-
- FOR_EACH (ActorSprites::iterator, i, mActors)
- {
-// disabled for performance
-// if (reportTrue(*i == nullptr))
-// continue;
-
- if ((*i)->getType() == ActorType::FloorItem
- || (*i)->getType() == ActorType::Portal)
- {
- continue;
- }
-
- Being *const being = static_cast<Being*>(*i);
-
- if (filtered)
- {
- if (ignoreAttackMobs.find(being->getName())
- != ignoreAttackMobs.end())
- {
- continue;
- }
- if (ignoreDefault && attackMobs.find(being->getName())
- == attackMobs.end() && priorityMobs.find(being->getName())
- == priorityMobs.end())
- {
- continue;
- }
- }
-
- if ((being->getInfo() != nullptr)
- && !(being->getInfo()->isTargetSelection() || modActive))
- {
- continue;
- }
-
- if (validateBeing(aroundBeing, being, type, nullptr, maxDist))
- {
- if (being != excluded)
- sortedBeings.push_back(being);
- }
- }
-
- // no selectable beings
- if (sortedBeings.empty())
- return nullptr;
-
- beingActorSorter.x = x;
- beingActorSorter.y = y;
- if (filtered)
- {
- beingActorSorter.attackBeings = &attackMobsMap;
- beingActorSorter.defaultAttackIndex = defaultAttackIndex;
- beingActorSorter.priorityBeings = &priorityMobsMap;
- beingActorSorter.defaultPriorityIndex = defaultPriorityIndex;
- }
- else
- {
- beingActorSorter.attackBeings = nullptr;
- beingActorSorter.priorityBeings = nullptr;
- }
- std::sort(sortedBeings.begin(), sortedBeings.end(), beingActorSorter);
- if (filtered)
- {
- beingActorSorter.attackBeings = nullptr;
- beingActorSorter.priorityBeings = nullptr;
- }
-
- if (localPlayer->getTarget() == nullptr)
- {
- Being *const target = sortedBeings.at(0);
-
- if (specialDistance && target->getType() == ActorType::Monster
- && target->getDistance() <= 2)
- {
- return nullptr;
- }
- // if no selected being in vector, return first nearest being
- return target;
- }
-
- beingEqualActorFinder.findBeing = localPlayer->getTarget();
- STD_VECTOR<Being*>::const_iterator i = std::find_if(
- sortedBeings.begin(), sortedBeings.end(), beingEqualActorFinder);
-
- if (i == sortedBeings.end() || ++i == sortedBeings.end())
- {
- // if no selected being in vector, return first nearest being
- return sortedBeings.at(0);
- }
-
- // we find next being after target
- return *i;
- }
-
- int dist = 0;
- int index = defaultPriorityIndex;
- Being *closestBeing = nullptr;
-
- FOR_EACH (ActorSprites::iterator, i, mActors)
- {
-// disabled for performance
-// if (reportTrue(*i == nullptr))
-// continue;
-
- if ((*i)->getType() == ActorType::FloorItem ||
- (*i)->getType() == ActorType::Portal)
- {
- continue;
- }
- Being *const being = static_cast<Being*>(*i);
-
- if (filtered)
- {
- if (ignoreAttackMobs.find(being->getName())
- != ignoreAttackMobs.end())
- {
- continue;
- }
- if (ignoreDefault && attackMobs.find(being->getName())
- == attackMobs.end() && priorityMobs.find(being->getName())
- == priorityMobs.end())
- {
- continue;
- }
- }
-
- if ((being->getInfo() != nullptr)
- && !(being->getInfo()->isTargetSelection() || modActive))
- {
- continue;
- }
-
- const bool valid = validateBeing(aroundBeing, being,
- type, excluded, 50);
- int d = being->getDistance();
- if (being->getType() != ActorType::Monster
- || !mTargetOnlyReachable)
- { // if distance not calculated, use old distance
- d = (being->getTileX() - x) * (being->getTileX() - x)
- + (being->getTileY() - y) * (being->getTileY() - y);
- }
-
- if (!valid)
- continue;
-
- if (specialDistance && being->getDistance() <= 2
- && being->getType() == type)
- {
- continue;
- }
-
-// logger->log("being name:" + being->getName());
-// logger->log("index:" + toString(index));
-// logger->log("d:" + toString(d));
-
- if (!filtered && (d <= dist || (closestBeing == nullptr)))
- {
- dist = d;
- closestBeing = being;
- }
- else if (filtered)
- {
- int w2 = defaultPriorityIndex;
- if (closestBeing != nullptr)
- {
- const StringIntMapCIter it2 = priorityMobsMap.find(
- being->getName());
- if (it2 != priorityMobsMap.end())
- w2 = (*it2).second;
-
- if (w2 < index)
- {
- dist = d;
- closestBeing = being;
- index = w2;
- continue;
- }
- if (w2 == index && d <= dist)
- {
- dist = d;
- closestBeing = being;
- index = w2;
- continue;
- }
- }
-
- if (closestBeing == nullptr)
- {
- dist = d;
- closestBeing = being;
- const StringIntMapCIter it1 = priorityMobsMap.find(
- being->getName());
- if (it1 != priorityMobsMap.end())
- index = (*it1).second;
- else
- index = defaultPriorityIndex;
- }
- }
- }
- return (maxDist >= dist) ? closestBeing : nullptr;
-}
-
-bool ActorManager::validateBeing(const Being *const aroundBeing,
- Being *const being,
- const ActorTypeT &type,
- const Being* const excluded,
- const int maxCost) const
-{
- if (localPlayer == nullptr)
- return false;
- return (being != nullptr) && ((being->getType() == type
- || type == ActorType::Unknown) && (being->isAlive()
- || (mTargetDeadPlayers && type == ActorType::Player))
- && being != aroundBeing) && being != excluded
- && (type != ActorType::Monster || !mTargetOnlyReachable
- || localPlayer->isReachable(being, maxCost));
-}
-
-#ifdef TMWA_SUPPORT
-void ActorManager::healTarget() const
-{
- if (localPlayer == nullptr)
- return;
-
- heal(localPlayer->getTarget());
-}
-
-void ActorManager::heal(const Being *const target) const
-{
- if (Net::getNetworkType() != ServerType::TMWATHENA)
- return;
-
- if (localPlayer == nullptr ||
- chatWindow == nullptr ||
- !localPlayer->isAlive() ||
- !playerHandler->canUseMagic())
- {
- return;
- }
-
- // self
- if (target != nullptr &&
- localPlayer->getName() == target->getName())
- {
- if (PlayerInfo::getAttribute(Attributes::PLAYER_MP) >= 6
- && PlayerInfo::getAttribute(Attributes::PLAYER_HP)
- != PlayerInfo::getAttribute(Attributes::PLAYER_MAX_HP))
- {
- if (!PacketLimiter::limitPackets(PacketType::PACKET_CHAT))
- return;
- chatWindow->localChatInput(mSpellHeal1);
- }
- }
- // magic levels < 2
- else if (PlayerInfo::getSkillLevel(340) < 2 ||
- PlayerInfo::getSkillLevel(341) < 2)
- {
- if (PlayerInfo::getAttribute(Attributes::PLAYER_MP) >= 6)
- {
- if (target != nullptr &&
- target->getType() != ActorType::Monster)
- {
- if (!PacketLimiter::limitPackets(PacketType::PACKET_CHAT))
- return;
- chatWindow->localChatInput(mSpellHeal1 + " "
- + target->getName());
- }
- else if (PlayerInfo::getAttribute(Attributes::PLAYER_HP)
- != PlayerInfo::getAttribute(Attributes::PLAYER_MAX_HP))
- {
- if (!PacketLimiter::limitPackets(PacketType::PACKET_CHAT))
- return;
- chatWindow->localChatInput(mSpellHeal1);
- }
- }
- }
- // magic level >= 2 and not self
- else
- {
- // mp > 10 and target not monster
- if (PlayerInfo::getAttribute(Attributes::PLAYER_MP) >= 10 &&
- target != nullptr &&
- target->getType() != ActorType::Monster)
- {
- // target not enemy
- if (playerRelations.getRelation(target->getName()) !=
- Relation::ENEMY2)
- {
- if (!PacketLimiter::limitPackets(PacketType::PACKET_CHAT))
- return;
- chatWindow->localChatInput(mSpellHeal2 + " "
- + target->getName());
- }
- // target enemy
- else
- {
- if (!PacketLimiter::limitPackets(PacketType::PACKET_CHAT))
- return;
- chatWindow->localChatInput(mSpellHeal1);
- }
- }
- // heal self if selected monster or selection empty
- else if ((target == nullptr || target->getType() == ActorType::Monster)
- && PlayerInfo::getAttribute(Attributes::PLAYER_MP) >= 6
- && PlayerInfo::getAttribute(Attributes::PLAYER_HP)
- != PlayerInfo::getAttribute(Attributes::PLAYER_MAX_HP))
- {
- if (!PacketLimiter::limitPackets(PacketType::PACKET_CHAT))
- return;
- chatWindow->localChatInput(mSpellHeal1);
- }
- }
-}
-#endif // TMWA_SUPPORT
-
-Being* ActorManager::findMostDamagedPlayer(const int maxTileDist) const
-{
- if (localPlayer == nullptr)
- return nullptr;
-
- int maxDamageTaken = 0;
- Being *target = nullptr;
-
- for_actors
- {
- if ((*it)->getType() != ActorType::Player)
- continue;
-
- Being *const being = static_cast<Being*>(*it);
-
- if ((being == nullptr) || !being->isAlive() || // don't heal dead
- playerRelations.getRelation(being->getName()) ==
- Relation::ENEMY2 || // don't heal enemy
- localPlayer == being) // don't heal self
- {
- continue;
- }
-
- const int dx = being->getTileX() - localPlayer->getTileX();
- const int dy = being->getTileY() - localPlayer->getTileY();
- const int distance = fastSqrtInt(dx * dx + dy * dy);
-
- if (distance > maxTileDist)
- continue;
-
- if (being->getDamageTaken() > maxDamageTaken)
- {
- maxDamageTaken = being->getDamageTaken();
- target = being;
- }
- }
-
- return target;
-}
-
-#ifdef TMWA_SUPPORT
-void ActorManager::itenplz() const
-{
- if (Net::getNetworkType() != ServerType::TMWATHENA)
- return;
- if (localPlayer == nullptr ||
- chatWindow == nullptr ||
- !localPlayer->isAlive() ||
- !playerHandler->canUseMagic())
- {
- return;
- }
-
- if (!PacketLimiter::limitPackets(PacketType::PACKET_CHAT))
- return;
-
- chatWindow->localChatInput(mSpellItenplz);
-}
-#endif // TMWA_SUPPORT
-
-bool ActorManager::hasActorSprite(const ActorSprite *const actor) const
-{
- for_actors
- {
- if (actor == *it)
- return true;
- }
-
- return false;
-}
-
-void ActorManager::addBlock(const BeingId id)
-{
- mBlockedBeings.insert(id);
-}
-
-void ActorManager::deleteBlock(const BeingId id)
-{
- mBlockedBeings.erase(id);
-}
-
-bool ActorManager::isBlocked(const BeingId id) const
-{
- return mBlockedBeings.find(id) != mBlockedBeings.end();
-}
-
-void ActorManager::printAllToChat()
-{
- // TRANSLATORS: visible beings on map
- printBeingsToChat(_("Visible on map"));
-}
-
-void ActorManager::printBeingsToChat(const std::string &header) const
-{
- if (debugChatTab == nullptr)
- return;
-
- debugChatTab->chatLog("---------------------------------------",
- ChatMsgType::BY_SERVER);
- debugChatTab->chatLog(header, ChatMsgType::BY_SERVER);
- for_actors
- {
-// disabled for performance
-// if (reportTrue(*it == nullptr))
-// continue;
-
- if ((*it)->getType() == ActorType::FloorItem)
- continue;
-
- const Being *const being = static_cast<const Being*>(*it);
-
- debugChatTab->chatLog(strprintf("%s (%d,%d) %d",
- being->getName().c_str(), being->getTileX(), being->getTileY(),
- toInt(being->getSubType(), int)), ChatMsgType::BY_SERVER);
- if (mActorsIdMap.find(being->getId()) == mActorsIdMap.end())
- {
- debugChatTab->chatLog("missing in id map: %s",
- being->getName().c_str());
- }
- }
- debugChatTab->chatLog("---------------------------------------",
- ChatMsgType::BY_SERVER);
- FOR_EACH (ActorSpritesMapConstIterator, itr, mActorsIdMap)
- {
- const ActorSprite *const actor = (*itr).second;
- if (actor == nullptr)
- continue;
- if (actor->getId() != (*itr).first)
- debugChatTab->chatLog("Actor with wrong key in map", "");
-
- bool found(false);
-
- for_actors
- {
-// disabled for performance
-// if (!*it)
-// continue;
-
- if ((*it)->getId() == actor->getId())
- {
- found = true;
- break;
- }
- }
- if (!found)
- debugChatTab->chatLog("Actor present in map but not in set", "");
- }
-}
-
-void ActorManager::printBeingsToChat(const STD_VECTOR<Being*> &beings,
- const std::string &header)
-{
- if (debugChatTab == nullptr)
- return;
-
- debugChatTab->chatLog("---------------------------------------",
- ChatMsgType::BY_SERVER);
- debugChatTab->chatLog(header, ChatMsgType::BY_SERVER);
-
- FOR_EACH (STD_VECTOR<Being*>::const_iterator, i, beings)
- {
- if (*i == nullptr)
- continue;
-
- const Being *const being = *i;
-
- debugChatTab->chatLog(strprintf("%s (%d,%d) %d",
- being->getName().c_str(), being->getTileX(), being->getTileY(),
- toInt(being->getSubType(), int)), ChatMsgType::BY_SERVER);
- }
- debugChatTab->chatLog("---------------------------------------",
- ChatMsgType::BY_SERVER);
-}
-
-void ActorManager::getPlayerNames(StringVect &names,
- const NpcNames npcNames) const
-{
- names.clear();
-
- for_actors
- {
-// disabled for performance
-// if (reportTrue(*it == nullptr))
-// continue;
-
- if ((*it)->getType() == ActorType::FloorItem ||
- (*it)->getType() == ActorType::Portal)
- {
- continue;
- }
-
- const Being *const being = static_cast<const Being*>(*it);
- if ((being->getType() == ActorType::Player ||
- (being->getType() == ActorType::Npc &&
- npcNames == NpcNames_true)) &&
- !being->getName().empty())
- {
- names.push_back(being->getName());
- }
- }
-}
-
-void ActorManager::getMobNames(StringVect &names) const
-{
- names.clear();
-
- for_actors
- {
-// disabled for performance
-// if (reportTrue(*it == nullptr))
-// continue;
-
- if ((*it)->getType() == ActorType::FloorItem
- || (*it)->getType() == ActorType::Portal)
- {
- continue;
- }
-
- const Being *const being = static_cast<const Being*>(*it);
- if (being->getType() == ActorType::Monster &&
- !being->getName().empty())
- {
- names.push_back(being->getName());
- }
- }
-}
-
-void ActorManager::updatePlayerNames() const
-{
- for_actorsm
- {
-// disabled for performance
-// if (reportTrue(*it == nullptr))
-// continue;
-
- if ((*it)->getType() == ActorType::FloorItem
- || (*it)->getType() == ActorType::Portal)
- {
- continue;
- }
-
- Being *const being = static_cast<Being*>(*it);
- being->setGoodStatus(-1);
- if (being->getType() == ActorType::Player && !being->getName().empty())
- being->updateName();
- }
-}
-
-void ActorManager::updatePlayerColors() const
-{
- for_actorsm
- {
-// disabled for performance
-// if (reportTrue(*it == nullptr))
-// continue;
-
- if ((*it)->getType() == ActorType::FloorItem
- || (*it)->getType() == ActorType::Portal)
- {
- continue;
- }
-
- Being *const being = static_cast<Being*>(*it);
- if (being->getType() == ActorType::Player && !being->getName().empty())
- being->updateColors();
- }
-}
-
-void ActorManager::updatePlayerGuild() const
-{
- for_actorsm
- {
-// disabled for performance
-// if (reportTrue(*it == nullptr))
-// continue;
-
- if ((*it)->getType() == ActorType::FloorItem
- || (*it)->getType() == ActorType::Portal)
- {
- continue;
- }
-
- Being *const being = static_cast<Being*>(*it);
- if (being->getType() == ActorType::Player && !being->getName().empty())
- being->updateGuild();
- }
-}
-
-#ifdef TMWA_SUPPORT
-void ActorManager::parseLevels(std::string levels) const
-{
- levels.append(", ");
- size_t f = 0;
- const std::string brkEnd("), ");
- size_t pos = levels.find(brkEnd, f);
-
- while (pos != std::string::npos)
- {
- std::string part = levels.substr(f, pos - f);
- if (part.empty())
- break;
- const size_t bktPos = part.rfind('(');
- if (bktPos != std::string::npos)
- {
- Being *const being = findBeingByName(part.substr(0, bktPos),
- ActorType::Player);
- if (being != nullptr)
- {
- being->setLevel(atoi(part.substr(bktPos + 1).c_str()));
- being->addToCache();
- }
- }
- f = CAST_SIZE(pos + brkEnd.length());
- pos = levels.find(brkEnd, f);
- }
- updatePlayerNames();
-}
-#endif // TMWA_SUPPORT
-
-void ActorManager::optionChanged(const std::string &name)
-{
- if (name == "targetDeadPlayers")
- mTargetDeadPlayers = config.getBoolValue("targetDeadPlayers");
- else if (name == "targetOnlyReachable")
- mTargetOnlyReachable = config.getBoolValue("targetOnlyReachable");
- else if (name == "cyclePlayers")
- mCyclePlayers = config.getBoolValue("cyclePlayers");
- else if (name == "cycleMonsters")
- mCycleMonsters = config.getBoolValue("cycleMonsters");
- else if (name == "cycleNPC")
- mCycleNPC = config.getBoolValue("cycleNPC");
- else if (name == "extMouseTargeting")
- mExtMouseTargeting = config.getBoolValue("extMouseTargeting");
- else if (name == "showBadges")
- updateBadges();
- else if (name == "visiblenamespos")
- updateBadges();
- else if (name == "enableIdCollecting")
- mEnableIdCollecting = config.getBoolValue("enableIdCollecting");
-}
-
-void ActorManager::removeAttackMob(const std::string &name)
-{
- mPriorityAttackMobs.remove(name);
- mAttackMobs.remove(name);
- mIgnoreAttackMobs.remove(name);
- mPriorityAttackMobsSet.erase(name);
- mAttackMobsSet.erase(name);
- mIgnoreAttackMobsSet.erase(name);
- rebuildAttackMobs();
- rebuildPriorityAttackMobs();
- storeAttackList();
-}
-
-void ActorManager::removePickupItem(const std::string &name)
-{
- mPickupItems.remove(name);
- mPickupItemsSet.erase(name);
- mIgnorePickupItems.remove(name);
- mIgnorePickupItemsSet.erase(name);
- rebuildPickupItems();
- storeAttackList();
-}
-
-#define addMobToList(name, mob) \
-{\
- const int sz = get##mob##sSize();\
- if (sz > 0)\
- {\
- const int idx = get##mob##Index("");\
- if (idx + 1 == sz)\
- {\
- std::list<std::string>::iterator itr = m##mob##s.end();\
- -- itr;\
- m##mob##s.insert(itr, name);\
- }\
- else\
- {\
- m##mob##s.push_back(name);\
- }\
- }\
- else\
- {\
- m##mob##s.push_back(name);\
- }\
- m##mob##sSet.insert(name);\
- rebuild##mob##s();\
-}
-
-#define rebuildMobsList(mob) \
-{\
- m##mob##sMap.clear();\
- std::list<std::string>::const_iterator i = m##mob##s.begin();\
- int cnt = 0;\
- while (i != m##mob##s.end())\
- {\
- m##mob##sMap[*i] = cnt;\
- ++ i;\
- ++ cnt;\
- }\
-}
-
-void ActorManager::addAttackMob(const std::string &name)
-{
- addMobToList(name, AttackMob);
- rebuildPriorityAttackMobs();
- storeAttackList();
-}
-
-void ActorManager::addPriorityAttackMob(const std::string &name)
-{
- addMobToList(name, PriorityAttackMob);
- storeAttackList();
-}
-
-void ActorManager::addIgnoreAttackMob(const std::string &name)
-{
- mIgnoreAttackMobs.push_back(name);
- mIgnoreAttackMobsSet.insert(name);
- rebuildAttackMobs();
- rebuildPriorityAttackMobs();
- storeAttackList();
-}
-
-void ActorManager::addPickupItem(const std::string &name)
-{
- addMobToList(name, PickupItem);
- rebuildPickupItems();
- storeAttackList();
-}
-
-void ActorManager::addIgnorePickupItem(const std::string &name)
-{
- mIgnorePickupItems.push_back(name);
- mIgnorePickupItemsSet.insert(name);
- rebuildPickupItems();
- storeAttackList();
-}
-
-void ActorManager::rebuildPriorityAttackMobs()
-{
- rebuildMobsList(PriorityAttackMob);
-}
-
-void ActorManager::rebuildAttackMobs()
-{
- rebuildMobsList(AttackMob);
-}
-
-void ActorManager::rebuildPickupItems()
-{
- rebuildMobsList(PickupItem);
-}
-
-int ActorManager::getIndexByName(const std::string &name,
- const StringIntMap &map)
-{
- const StringIntMapCIter i = map.find(name);
- if (i == map.end())
- return -1;
-
- return (*i).second;
-}
-
-int ActorManager::getPriorityAttackMobIndex(const std::string &name) const
-{
- return getIndexByName(name, mPriorityAttackMobsMap);
-}
-
-int ActorManager::getAttackMobIndex(const std::string &name) const
-{
- return getIndexByName(name, mAttackMobsMap);
-}
-
-int ActorManager::getPickupItemIndex(const std::string &name) const
-{
- return getIndexByName(name, mPickupItemsMap);
-}
-
-#define loadList(key, mob) \
-{\
- list = unpackList(serverConfig.getValue(key, ""));\
- i = list.begin();\
- i_end = list.end();\
- while (i != i_end)\
- {\
- if ((*i).empty())\
- empty = true;\
- m##mob##s.push_back(*i);\
- m##mob##sSet.insert(*i);\
- ++ i;\
- }\
-}
-
-void ActorManager::loadAttackList()
-{
- bool empty = false;
- std::list<std::string> list;
- std::list<std::string>::const_iterator i;
- std::list<std::string>::const_iterator i_end;
-
- loadList("attackPriorityMobs", PriorityAttackMob);
- loadList("attackMobs", AttackMob);
- loadList("ignoreAttackMobs", IgnoreAttackMob);
- if (!empty)
- {
- mAttackMobs.push_back("");
- mAttackMobsSet.insert("");
- }
- empty = false;
-
- loadList("pickupItems", PickupItem);
- loadList("ignorePickupItems", IgnorePickupItem);
- if (!empty)
- {
- mPickupItems.push_back("");
- mPickupItemsSet.insert("");
- }
-
- rebuildAttackMobs();
- rebuildPriorityAttackMobs();
- rebuildPickupItems();
-}
-
-void ActorManager::storeAttackList() const
-{
- serverConfig.setValue("attackPriorityMobs", packList(mPriorityAttackMobs));
- serverConfig.setValue("attackMobs", packList(mAttackMobs));
- serverConfig.setValue("ignoreAttackMobs", packList(mIgnoreAttackMobs));
-
- serverConfig.setValue("pickupItems", packList(mPickupItems));
- serverConfig.setValue("ignorePickupItems", packList(mIgnorePickupItems));
-}
-
-bool ActorManager::checkForPickup(const FloorItem *const item) const
-{
- if (mPickupItemsSet.find("") != mPickupItemsSet.end())
- {
- if (mIgnorePickupItemsSet.find(item->getName())
- == mIgnorePickupItemsSet.end())
- {
- return true;
- }
- }
- else if ((item != nullptr) && mPickupItemsSet.find(item->getName())
- != mPickupItemsSet.end())
- {
- return true;
- }
- return false;
-}
-
-bool ActorManager::checkDefaultPickup() const
-{
- return mPickupItemsSet.find("") != mPickupItemsSet.end();
-}
-
-void ActorManager::updateEffects(const std::map<BeingTypeId, int> &addEffects,
- const std::set<BeingTypeId> &removeEffects)
- const
-{
- for_actorsm
- {
-// disabled for performance
-// if (reportTrue(*it == nullptr))
-// continue;
- if ((*it)->getType() != ActorType::Npc)
- continue;
- Being *const being = static_cast<Being*>(*it);
- const BeingTypeId type = being->getSubType();
- if (removeEffects.find(type) != removeEffects.end())
- being->removeSpecialEffect();
- const std::map<BeingTypeId, int>::const_iterator
- idAdd = addEffects.find(type);
- if (idAdd != addEffects.end())
- being->addSpecialEffect((*idAdd).second);
- }
-}
-
-Being *ActorManager::cloneBeing(const Being *const srcBeing,
- const int dx, const int dy,
- const int id)
-{
- returnNullptr(nullptr, srcBeing);
- Being *const dstBeing = actorManager->createBeing(fromInt(
- toInt(srcBeing->getId(), int) + id, BeingId),
- ActorType::Player,
- srcBeing->getSubType());
- if (dstBeing == nullptr)
- return nullptr;
- dstBeing->setGender(srcBeing->getGender());
- dstBeing->setAction(srcBeing->getCurrentAction(), 0);
- dstBeing->setTileCoords(srcBeing->getTileX() + dx,
- srcBeing->getTileY() + dy);
- dstBeing->setName(srcBeing->getName());
- dstBeing->setDirection(srcBeing->getDirection());
- const int sz = CAST_S32(srcBeing->mSprites.size());
- for (int slot = 0; slot < sz; slot ++)
- {
- const int spriteId = srcBeing->getSpriteID(slot);
- const ItemColor color = srcBeing->getSpriteColor(slot);
- dstBeing->setSpriteColorId(slot,
- spriteId,
- color);
- }
- const int hairSlot = charServerHandler->hairSprite();
- const int hairStyle = -srcBeing->getSpriteID(hairSlot);
- const ItemColor hairColor = srcBeing->getHairColor();
- if (hairStyle != 0)
- {
- dstBeing->setSpriteColor(hairSlot,
- hairStyle * -1,
- ItemDB::get(-hairStyle).getDyeColorsString(hairColor));
- }
- else
- {
- dstBeing->unSetSprite(hairSlot);
- }
- dstBeing->setHairColor(hairColor);
- return dstBeing;
-}
-
-void ActorManager::updateBadges() const
-{
- const BadgeDrawType::Type showBadges = static_cast<BadgeDrawType::Type>(
- config.getIntValue("showBadges"));
- Being::mShowBadges = showBadges;
- Being::mVisibleNamePos = static_cast<VisibleNamePos::Type>(
- config.getIntValue("visiblenamespos"));
-
- for_actors
- {
- ActorSprite *const actor = *it;
- if (actor->getType() == ActorType::Player)
- {
- Being *const being = static_cast<Being*>(actor);
- being->showBadges(showBadges != BadgeDrawType::Hide);
- }
- }
-}
-
-void ActorManager::updateNameId(const std::string &name,
- const BeingId beingId)
-{
- if (!mEnableIdCollecting)
- return;
- const int id = CAST_S32(beingId);
- if ((id != 0) &&
- (id < 2000000 ||
- id >= 110000000))
- {
- return;
- }
-
- if (mIdName.find(beingId) == mIdName.end() ||
- mIdName[beingId].find(name) == mIdName[beingId].end())
- {
- mIdName[beingId].insert(name);
- const std::string idStr = toString(id);
- const std::string dateStr = getDateTimeString();
- std::string dir;
- if (beingId != BeingId_zero)
- {
- dir = pathJoin(settings.usersIdDir,
- idStr,
- stringToHexPath(name));
- Files::saveTextFile(dir,
- "info.txt",
- (name + "\n").append(dateStr));
- }
-
- dir = settings.usersDir;
- dir.append(stringToHexPath(name));
- Files::saveTextFile(dir,
- "seen.txt",
- (name + "\n").append(idStr).append("\n").append(dateStr));
- }
-}
-
-void ActorManager::updateSeenPlayers(const std::set<std::string>
- &onlinePlayers)
-{
- if (!mEnableIdCollecting)
- return;
-
- FOR_EACH (std::set<std::string>::const_iterator, it, onlinePlayers)
- {
- const std::string name = *it;
- if (findBeingByName(name, ActorType::Player) == nullptr)
- updateNameId(name, BeingId_zero);
- }
-}
-
-std::string ActorManager::getSeenPlayerById(const BeingId id) const
-{
- if (!mEnableIdCollecting)
- return std::string();
-
- const IdNameMappingCIter it = mIdName.find(id);
- if (it != mIdName.end())
- {
- if (!it->second.empty())
- return *(it->second.begin());
- }
- return std::string();
-}
-
-void ActorManager::removeRoom(const int chatId)
-{
- for_actors
- {
- ActorSprite *const actor = *it;
- if (actor->getType() == ActorType::Npc)
- {
- Being *const being = static_cast<Being*>(actor);
- const ChatObject *const chat = being->getChat();
- if ((chat != nullptr) && chat->chatId == chatId)
- {
- being->setChat(nullptr);
- }
- }
- }
-}
-
-void ActorManager::updateRoom(const ChatObject *const newChat)
-{
- if (newChat == nullptr)
- return;
-
- for_actors
- {
- const ActorSprite *const actor = *it;
- if (actor->getType() == ActorType::Npc)
- {
- const Being *const being = static_cast<const Being*>(actor);
- ChatObject *const chat = being->getChat();
- if ((chat != nullptr) && chat->chatId == newChat->chatId)
- {
- chat->ownerId = newChat->ownerId;
- chat->maxUsers = newChat->maxUsers;
- chat->type = newChat->type;
- chat->title = newChat->title;
- }
- }
- }
-}
-
-std::string ActorManager::findCharById(const int32_t id)
-{
- const std::map<int32_t, std::string>::const_iterator it = mChars.find(id);
- if (it == mChars.end())
- return std::string();
- return (*it).second;
-}
-
-void ActorManager::addChar(const int32_t id,
- const std::string &name)
-{
- mChars[id] = name;
-
- if (guiInput == nullptr)
- return;
-
- guiInput->simulateMouseMove();
-}
diff --git a/src/actormanager.h b/src/actormanager.h
deleted file mode 100644
index 6fdf8d64c..000000000
--- a/src/actormanager.h
+++ /dev/null
@@ -1,454 +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 ACTORMANAGER_H
-#define ACTORMANAGER_H
-
-#include "enums/being/actortype.h"
-
-#include "enums/resources/item/itemtype.h"
-
-#include "enums/simpletypes/allowsort.h"
-#include "enums/simpletypes/allplayers.h"
-#include "enums/simpletypes/beingid.h"
-#include "enums/simpletypes/beingtypeid.h"
-#include "enums/simpletypes/damaged.h"
-#include "enums/simpletypes/identified.h"
-#include "enums/simpletypes/itemcolor.h"
-#include "enums/simpletypes/npcnames.h"
-
-#include "listeners/configlistener.h"
-
-#include "utils/cast.h"
-#include "utils/stringmap.h"
-#include "utils/stringvector.h"
-
-#include <list>
-#include <set>
-
-#include "localconsts.h"
-
-class ActorSprite;
-class Being;
-class FloorItem;
-class LocalPlayer;
-class Map;
-
-struct ChatObject;
-
-typedef std::set<ActorSprite*> ActorSprites;
-typedef ActorSprites::iterator ActorSpritesIterator;
-typedef ActorSprites::const_iterator ActorSpritesConstIterator;
-typedef std::map<BeingId, ActorSprite*> ActorSpritesMap;
-typedef ActorSpritesMap::iterator ActorSpritesMapIterator;
-typedef ActorSpritesMap::const_iterator ActorSpritesMapConstIterator;
-
-typedef std::map<BeingId, std::set<std::string> > IdNameMapping;
-typedef IdNameMapping::const_iterator IdNameMappingCIter;
-
-class ActorManager final: public ConfigListener
-{
- public:
- ActorManager();
-
- A_DELETE_COPY(ActorManager)
-
- ~ActorManager();
-
- /**
- * Sets the map on which ActorSprites are created.
- */
- void setMap(Map *const map);
-
- /**
- * Sets the current player.
- */
- void setPlayer(LocalPlayer *const player) A_NONNULL(2);
-
- /**
- * Create a Being and add it to the list of ActorSprites.
- */
- Being *createBeing(const BeingId id,
- const ActorTypeT type,
- const BeingTypeId subtype) A_WARN_UNUSED;
-
- static Being *cloneBeing(const Being *const srcBeing,
- const int dx, const int dy,
- const int id);
-
- /**
- * Create a FloorItem and add it to the list of ActorSprites.
- */
- FloorItem *createItem(const BeingId id,
- const int itemId,
- const int x, const int y,
- const ItemTypeT itemType,
- const int amount,
- const int refine,
- const ItemColor color,
- const Identified identified,
- const Damaged damaged,
- const int subX, const int subY,
- const int *const cards);
-
- /**
- * Destroys the given ActorSprite at the end of
- * ActorManager::logic.
- */
- void destroy(ActorSprite *const actor);
-
- void erase(ActorSprite *const actor);
-
- void undelete(const ActorSprite *const actor);
-
- /**
- * Returns a specific Being, by id;
- */
- Being *findBeing(const BeingId id) const A_WARN_UNUSED;
-
- ActorSprite *findActor(const BeingId id) const A_WARN_UNUSED;
-
- /**
- * Returns a being at specific coordinates.
- */
- Being *findBeing(const int x, const int y, const ActorTypeT
- type = ActorType::Unknown) const A_WARN_UNUSED;
-
- /**
- * Returns a being at the specific pixel.
- */
- Being *findBeingByPixel(const int x, const int y,
- const AllPlayers allPlayers = AllPlayers_false)
- const A_WARN_UNUSED;
-
- /**
- * Returns a beings at the specific pixel.
- */
- void findBeingsByPixel(STD_VECTOR<ActorSprite*> &beings,
- const int x, const int y,
- const AllPlayers allPlayers) const;
-
- /**
- * Returns a portal at the specific tile.
- */
- Being *findPortalByTile(const int x, const int y) const A_WARN_UNUSED;
-
- /**
- * Returns a specific FloorItem, by id.
- */
- FloorItem *findItem(const BeingId id) const A_WARN_UNUSED;
-
- /**
- * Returns a FloorItem at specific coordinates.
- */
- FloorItem *findItem(const int x, const int y) const A_WARN_UNUSED;
-
- /**
- * Returns a being nearest to specific coordinates.
- *
- * @param x X coordinate in pixels.
- * @param y Y coordinate in pixels.
- * @param maxTileDist Maximal distance in tiles. If minimal distance is
- * larger, no being is returned.
- * @param type The type of being to look for.
- */
- Being *findNearestLivingBeing(const int x, const int y,
- int maxTileDist,
- const ActorTypeT type,
- const Being *const excluded)
- const A_WARN_UNUSED;
-
- /**
- * Returns a being nearest to another being.
- *
- * @param aroundBeing The being to search around.
- * @param maxTileDist Maximal distance in tiles. If minimal distance is
- * larger, no being is returned.
- * @param type The type of being to look for.
- */
- Being *findNearestLivingBeing(const Being *const aroundBeing,
- const int maxTileDist,
- const ActorTypeT type,
- const AllowSort allowSort)
- const A_WARN_UNUSED;
-
- /**
- * Finds a being by name and (optionally) by type.
- */
- Being *findBeingByName(const std::string &name,
- const ActorTypeT
- type = ActorType::Unknown)
- const A_WARN_UNUSED;
-
- /**
- * Finds a nearest being by name and (optionally) by type.
- */
- Being *findNearestByName(const std::string &name,
- const ActorTypeT &type
- = ActorType::Unknown) const A_WARN_UNUSED;
-
- /**
- * Finds most damaged player, non-enemy and alive
- * \param maxTileDist maximal distance.
- */
- Being *findMostDamagedPlayer(const int maxTileDist)
- const A_WARN_UNUSED;
-
- /**
- * Finds the nearest player who has PVP on,
- * or just the nearest player if map pvp is on
- */
- Being *findNearestPvpPlayer() const A_WARN_UNUSED;
-
-#ifdef TMWA_SUPPORT
- /**
- * Heal all players in distance.
- *
- * \param maxdist maximal distance. If minimal distance is larger,
- * no being is returned
- */
-// void HealAllTargets(Being *aroundBeing, int maxdist,
-// ActorTypeT type) const;
-
- void healTarget() const;
-
- void heal(const Being *const target) const;
-
- void itenplz() const;
-#endif // TMWA_SUPPORT
-
- /**
- * Returns the whole list of beings.
- */
- const ActorSprites &getAll() const A_CONST;
-
- /**
- * Returns true if the given ActorSprite is in the manager's list,
- * false otherwise.
- *
- * \param actor the ActorSprite to search for
- */
- bool hasActorSprite(const ActorSprite *const actor)
- const A_WARN_UNUSED;
-
- /**
- * Performs ActorSprite logic and deletes ActorSprite scheduled to be
- * deleted.
- */
- void logic();
-
- /**
- * Destroys all ActorSprites except the local player
- */
- void clear();
-
- void addBlock(const BeingId id);
-
- void deleteBlock(const BeingId id);
-
- bool isBlocked(const BeingId id) const;
-
- void printAllToChat();
-
- void printBeingsToChat(const std::string &header) const;
-
- static void printBeingsToChat(const STD_VECTOR<Being*> &beings,
- const std::string &header);
-
- void getPlayerNames(StringVect &names,
- const NpcNames npcNames) const;
-
- void getMobNames(StringVect &names) const;
-
- void updatePlayerNames() const;
-
- void updatePlayerColors() const;
-
- void updatePlayerGuild() const;
-
-#ifdef TMWA_SUPPORT
- void parseLevels(std::string levels) const;
-#endif // TMWA_SUPPORT
-
- bool pickUpAll(const int x1,
- const int y1,
- const int x2,
- const int y2,
- const bool serverBuggy = false) const;
-
- bool pickUpNearest(const int x, const int y, int maxdist) const;
-
- void optionChanged(const std::string &name) override final;
-
- void removeAttackMob(const std::string &name);
-
- void removePickupItem(const std::string &name);
-
- void addPriorityAttackMob(const std::string &name);
-
- void addAttackMob(const std::string &name);
-
- void addIgnoreAttackMob(const std::string &name);
-
- void addPickupItem(const std::string &name);
-
- void addIgnorePickupItem(const std::string &name);
-
- void setPriorityAttackMobs(const std::list<std::string> &mobs)
- { mPriorityAttackMobs = mobs; }
-
- void setAttackMobs(const std::list<std::string> &mobs)
- { mAttackMobs = mobs; }
-
- int getPriorityAttackMobsSize() const noexcept2 A_WARN_UNUSED
- { return CAST_S32(mPriorityAttackMobs.size()); }
-
- int getAttackMobsSize() const noexcept2 A_WARN_UNUSED
- { return CAST_S32(mAttackMobs.size()); }
-
- int getPickupItemsSize() const noexcept2 A_WARN_UNUSED
- { return CAST_S32(mPickupItems.size()); }
-
-#define defList(list1, mob) \
- bool isIn##list1##List(const std::string &name) const A_WARN_UNUSED\
- { return m##list1##mob##Set.find(name) != m##list1##mob##Set.end(); }\
- void rebuild##list1##mob();\
- std::set<std::string> get##list1##mob##Set() const noexcept2\
- A_WARN_UNUSED\
- { return m##list1##mob##Set; }\
- std::list<std::string> get##list1##mob() const noexcept2 A_WARN_UNUSED\
- { return m##list1##mob; }
-
- defList(Attack, Mobs)
- defList(PriorityAttack, Mobs)
- defList(IgnoreAttack, Mobs)
- defList(Pickup, Items)
- defList(IgnorePickup, Items)
-
- const StringIntMap &getAttackMobsMap() const noexcept2 A_WARN_UNUSED
- { return mAttackMobsMap; }
-
- const StringIntMap &getPriorityAttackMobsMap() const noexcept2
- A_WARN_UNUSED
- { return mPriorityAttackMobsMap; }
-
- int getAttackMobIndex(const std::string &name) const A_WARN_UNUSED;
-
- int getPriorityAttackMobIndex(const std::string &name)
- const A_WARN_UNUSED;
-
- int getPickupItemIndex(const std::string &name) const A_WARN_UNUSED;
-
- static int getIndexByName(const std::string &name,
- const StringIntMap &map)
- A_WARN_UNUSED;
-
- bool checkForPickup(const FloorItem *const item) const A_WARN_UNUSED;
-
- bool checkDefaultPickup() const A_WARN_UNUSED;
-
- void updateEffects(const std::map<BeingTypeId, int> &addEffects,
- const std::set<BeingTypeId> &removeEffects) const;
-
- void updateBadges() const;
-
- void updateNameId(const std::string &name,
- const BeingId beingId);
-
- void updateSeenPlayers(const std::set<std::string> &onlinePlayers);
-
- std::string getSeenPlayerById(const BeingId id) const;
-
- size_t size() const
- { return mActors.size(); }
-
- void removeRoom(const int chatId);
-
- void updateRoom(const ChatObject *const newChat);
-
- std::string findCharById(const int32_t id);
-
- void addChar(const int32_t id,
- const std::string &name);
-
-#ifndef UNITTESTS
- protected:
-#endif // UNITTESTS
- bool validateBeing(const Being *const aroundBeing,
- Being *const being,
- const ActorTypeT &type,
- const Being *const excluded = nullptr,
- const int maxCost = 20) const A_WARN_UNUSED;
-
- Being *findNearestLivingBeing(const Being *const aroundBeing,
- const int maxdist,
- const ActorTypeT &type,
- const int x, const int y,
- const Being *const excluded,
- const AllowSort allowSort)
- const A_WARN_UNUSED;
-
- void loadAttackList();
-
- void storeAttackList() const;
-
- ActorSprites mActors;
- ActorSprites mDeleteActors;
- ActorSpritesMap mActorsIdMap;
- IdNameMapping mIdName;
- std::set<BeingId> mBlockedBeings;
- std::map<int32_t, std::string> mChars;
- Map *mMap;
-#ifdef TMWA_SUPPORT
- std::string mSpellHeal1;
- std::string mSpellHeal2;
- std::string mSpellItenplz;
-#endif // TMWA_SUPPORT
-
- bool mTargetDeadPlayers;
- bool mTargetOnlyReachable;
- bool mCyclePlayers;
- bool mCycleMonsters;
- bool mCycleNPC;
- bool mExtMouseTargeting;
- bool mEnableIdCollecting;
-
-#define defVarsP(mob) \
- std::list<std::string> mPriority##mob;\
- std::set<std::string> mPriority##mob##Set;\
- StringIntMap mPriority##mob##Map;
-
-#define defVars(mob) \
- std::list<std::string> m##mob;\
- std::set<std::string> m##mob##Set;\
- StringIntMap m##mob##Map;\
- std::list<std::string> mIgnore##mob;\
- std::set<std::string> mIgnore##mob##Set;
-
- defVarsP(AttackMobs)
- defVars(AttackMobs)
- defVars(PickupItems)
-};
-
-extern ActorManager *actorManager;
-
-#endif // ACTORMANAGER_H
diff --git a/src/avatar.cpp b/src/avatar.cpp
deleted file mode 100644
index e3975a3d7..000000000
--- a/src/avatar.cpp
+++ /dev/null
@@ -1,66 +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 "avatar.h"
-
-#include "debug.h"
-
-Avatar::Avatar(const std::string &name) :
- mId(BeingId_zero),
- mCharId(0),
- mName(name),
- mOriginalName(name),
- mHp(0),
- mMaxHp(0),
- mDamageHp(0),
- mLevel(1),
- mMap(),
- mX(-1),
- mY(-1),
- mType(AVATAR_PLAYER),
- mExp(0),
- mGender(Gender::UNSPECIFIED),
- mRace(-1),
- mIp(),
- mOnline(false),
- mDisplayBold(false),
- mPoison(false)
-{
-}
-
-std::string Avatar::getComplexName() const
-{
- if (mName == mOriginalName ||
- mOriginalName.empty())
- {
- return mName;
- }
- return std::string(mName).append("(").append(
- mOriginalName).append(")");
-}
-
-std::string Avatar::getAdditionString() const
-{
- if (!getIp().empty())
- return " - " + getIp();
- return "";
-}
diff --git a/src/avatar.h b/src/avatar.h
deleted file mode 100644
index 3db83de12..000000000
--- a/src/avatar.h
+++ /dev/null
@@ -1,207 +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 AVATAR_H
-#define AVATAR_H
-
-#include "enums/being/gender.h"
-
-#include "enums/simpletypes/beingid.h"
-
-#include <string>
-
-#include "localconsts.h"
-
-enum AvatarType
-{
- AVATAR_PLAYER = 0
-};
-
-class Avatar notfinal
-{
- public:
- explicit Avatar(const std::string &name = "");
-
- A_DELETE_COPY(Avatar)
-
- virtual ~Avatar()
- { }
-
- /**
- * Returns the avatar's name.
- */
- std::string getName() const noexcept2 A_WARN_UNUSED
- { return mName; }
-
- /**
- * Set the avatar's name.
- */
- void setName(const std::string &name)
- { mName = name; }
-
- /**
- * Returns the avatar's original name.
- */
- std::string getOriginalName() const noexcept2 A_WARN_UNUSED
- { return mOriginalName; }
-
- std::string getComplexName() const A_WARN_UNUSED;
-
- virtual std::string getAdditionString() const A_WARN_UNUSED;
-
- /**
- * Set the avatar's original name.
- */
- void setOriginalName(const std::string &name)
- { mOriginalName = name; }
-
- /**
- * Returns the avatar's online status.
- */
- bool getOnline() const noexcept2 A_WARN_UNUSED
- { return mOnline; }
-
- /**
- * Set the avatar's online status.
- */
- void setOnline(const bool online)
- { mOnline = online; }
-
- int getHp() const noexcept2 A_WARN_UNUSED
- { return mHp; }
-
- void setHp(const int hp)
- { mHp = hp; }
-
- int getMaxHp() const noexcept2 A_WARN_UNUSED
- { return mMaxHp; }
-
- void setMaxHp(const int maxHp)
- { mMaxHp = maxHp; }
-
- int getDamageHp() const noexcept2 A_WARN_UNUSED
- { return mDamageHp; }
-
- void setDamageHp(const int damageHp)
- { mDamageHp = damageHp; }
-
- bool getDisplayBold() const noexcept2 A_WARN_UNUSED
- { return mDisplayBold; }
-
- void setDisplayBold(const bool displayBold)
- { mDisplayBold = displayBold; }
-
- int getLevel() const noexcept2 A_WARN_UNUSED
- { return mLevel; }
-
- void setLevel(const int level)
- { mLevel = level; }
-
- std::string getMap() const noexcept2 A_WARN_UNUSED
- { return mMap; }
-
- void setMap(const std::string &map)
- { mMap = map; }
-
- int getX() const noexcept2 A_WARN_UNUSED
- { return mX; }
-
- void setX(const int x)
- { mX = x; }
-
- int getY() const noexcept2 A_WARN_UNUSED
- { return mY; }
-
- void setY(const int y)
- { mY = y; }
-
- int getType() const noexcept2 A_WARN_UNUSED
- { return mType; }
-
- void setType(const int n)
- { mType = n; }
-
- int getExp() const noexcept2 A_WARN_UNUSED
- { return mExp; }
-
- void setExp(const int n)
- { mExp = n; }
-
- BeingId getID() const noexcept2 A_WARN_UNUSED
- { return mId; }
-
- void setID(const BeingId id)
- { mId = id; }
-
- int getCharId() const noexcept2 A_WARN_UNUSED
- { return mCharId; }
-
- void setCharId(const int id)
- { mCharId = id; }
-
- GenderT getGender() const noexcept2 A_WARN_UNUSED
- { return mGender; }
-
- void setGender(const GenderT g)
- { mGender = g; }
-
- int getRace() const noexcept2 A_WARN_UNUSED
- { return mRace; }
-
- void setRace(const int r)
- { mRace = r; }
-
- const std::string &getIp() const noexcept2 A_WARN_UNUSED
- { return mIp; }
-
- void setIp(const std::string &ip)
- { mIp = ip; }
-
- bool getPoison() const noexcept2 A_WARN_UNUSED
- { return mPoison; }
-
- void setPoison(const bool b)
- { mPoison = b; }
-
- protected:
- BeingId mId;
- int mCharId;
- std::string mName;
- std::string mOriginalName;
- int mHp;
- int mMaxHp;
- int mDamageHp;
- int mLevel;
- std::string mMap;
- int mX;
- int mY;
- int mType;
- int mExp;
- GenderT mGender;
- int mRace;
- std::string mIp;
- bool mOnline;
- bool mDisplayBold;
- bool mPoison;
-};
-
-#endif // AVATAR_H
diff --git a/src/being/actor.cpp b/src/being/actor.cpp
deleted file mode 100644
index a881c005e..000000000
--- a/src/being/actor.cpp
+++ /dev/null
@@ -1,87 +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 "being/actor.h"
-
-#include "resources/map/map.h"
-
-#include "debug.h"
-
-Actor::Actor() :
- mPixelX(0),
- mPixelY(0),
- mMap(nullptr),
- mPos(),
- mYDiff(0),
- mMapActor()
-{
-}
-
-Actor::~Actor()
-{
- if (mMap != nullptr)
- {
- mMap->removeActor(mMapActor);
- mMap = nullptr;
- }
-}
-
-void Actor::setMap(Map *const map)
-{
- // Remove Actor from potential previous map
- if (mMap != nullptr)
- mMap->removeActor(mMapActor);
-
- mMap = map;
-
- // Add Actor to potential new map
- if (mMap != nullptr)
- mMapActor = mMap->addActor(this);
-}
-
-int Actor::getTileX() const
-{
- if (mMap == nullptr ||
- mMap->getTileWidth() == 0)
- {
- return 0;
- }
-
- return getPixelX() / mMap->getTileWidth();
-}
-
-int Actor::getTileY() const
-{
- if (mMap == nullptr ||
- mMap->getTileHeight() == 0)
- {
- return 0;
- }
-
- return getPixelY() / mMap->getTileHeight();
-}
-
-void Actor::setPixelPositionF(const Vector &restrict pos) restrict2
-{
- mPos = pos;
- mPixelX = CAST_S32(mPos.x);
- mPixelY = CAST_S32(mPos.y);
-}
diff --git a/src/being/actor.h b/src/being/actor.h
deleted file mode 100644
index 50a9dca24..000000000
--- a/src/being/actor.h
+++ /dev/null
@@ -1,146 +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 BEING_ACTOR_H
-#define BEING_ACTOR_H
-
-#include "vector.h"
-
-#include "utils/cast.h"
-
-#include <list>
-
-#include "localconsts.h"
-
-class Actor;
-class Graphics;
-class Map;
-
-typedef std::list<Actor*> Actors;
-typedef Actors::const_iterator ActorsCIter;
-
-class Actor notfinal
-{
- public:
- A_DELETE_COPY(Actor)
-
- virtual ~Actor();
-
- /**
- * Draws the Actor to the given graphics context.
- *
- * Note: this function could be simplified if the graphics context
- * would support setting a translation offset. It already does this
- * partly with the clipping rectangle support.
- */
- virtual void draw(Graphics *const graphics,
- const int offsetX,
- const int offsetY) const A_NONNULL(2) = 0;
-
- /**
- * Returns the horizontal size of the actors graphical representation
- * in pixels or 0 when it is undefined.
- */
- virtual int getWidth() const A_WARN_UNUSED
- { return 0; }
-
- /**
- * Returns the vertical size of the actors graphical representation
- * in pixels or 0 when it is undefined.
- */
- virtual int getHeight() const A_WARN_UNUSED
- { return 0; }
-
- /**
- * Returns the pixel position of this actor.
- */
- const Vector &getPixelPositionF() const noexcept2 A_WARN_UNUSED
- { return mPos; }
-
- /**
- * Sets the pixel position of this actor.
- */
- virtual void setPixelPositionF(const Vector &restrict pos) restrict2;
-
- /**
- * Returns the pixels X coordinate of the actor.
- */
- int getPixelX() const noexcept2 A_WARN_UNUSED
- { return CAST_S32(mPos.x); }
-
- /**
- * Returns the pixel Y coordinate of the actor.
- */
- virtual int getPixelY() const A_WARN_UNUSED
- { return CAST_S32(mPos.y); }
-
- /**
- * Returns the pixel Y coordinate of the actor for sorting only.
- */
- virtual int getSortPixelY() const A_WARN_UNUSED
- { return CAST_S32(mPos.y) - mYDiff; }
-
- /**
- * Returns the x coordinate in tiles of the actor.
- */
- virtual int getTileX() const A_WARN_UNUSED;
-
- /**
- * Returns the y coordinate in tiles of the actor.
- */
- virtual int getTileY() const A_WARN_UNUSED;
-
- /**
- * Returns the number of Image layers used to draw the actor.
- */
- virtual int getNumberOfLayers() const A_WARN_UNUSED
- { return 0; }
-
- /**
- * Returns the current alpha value used to draw the actor.
- */
- virtual float getAlpha() const A_WARN_UNUSED = 0;
-
- /**
- * Sets the alpha value used to draw the actor.
- */
- virtual void setAlpha(float alpha) = 0;
-
- virtual void setMap(Map *const map);
-
- const Map* getMap() const noexcept2 A_WARN_UNUSED
- { return mMap; }
-
- int mPixelX;
- int mPixelY;
-
- protected:
- Actor();
-
- Map *mMap;
- Vector mPos; /**< Position in pixels relative to map. */
- int mYDiff;
-
- private:
- Actors::iterator mMapActor;
-};
-
-#endif // BEING_ACTOR_H
diff --git a/src/being/actorsprite.cpp b/src/being/actorsprite.cpp
deleted file mode 100644
index 6594c7e3c..000000000
--- a/src/being/actorsprite.cpp
+++ /dev/null
@@ -1,602 +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 "being/actorsprite.h"
-
-#include "configuration.h"
-#include "settings.h"
-#include "statuseffect.h"
-
-#include "being/localplayer.h"
-
-#include "const/utils/timer.h"
-
-#include "gui/theme.h"
-
-#include "listeners/debugmessagelistener.h"
-
-#include "particle/particle.h"
-
-#include "resources/db/statuseffectdb.h"
-
-#include "resources/loaders/imageloader.h"
-
-#include "resources/sprite/animatedsprite.h"
-#include "resources/sprite/imagesprite.h"
-#include "resources/sprite/spritereference.h"
-
-#include "utils/checkutils.h"
-#include "utils/delete2.h"
-#include "utils/foreach.h"
-#include "utils/timer.h"
-
-#include "debug.h"
-
-#define for_each_cursors() \
- for (int size = CAST_S32(TargetCursorSize::SMALL); \
- size < CAST_S32(TargetCursorSize::NUM_TC); \
- size ++) \
- { \
- for (int type = CAST_S32(TargetCursorType::NORMAL); \
- type < CAST_S32(TargetCursorType::NUM_TCT); \
- type ++) \
-
-#define end_foreach }
-
-static const unsigned int STATUS_EFFECTS = 32;
-
-AnimatedSprite *ActorSprite::targetCursor
- [CAST_SIZE(TargetCursorType::NUM_TCT)]
- [CAST_SIZE(TargetCursorSize::NUM_TC)];
-bool ActorSprite::loaded = false;
-
-ActorSprite::ActorSprite(const BeingId id) :
- CompoundSprite(),
- Actor(),
- mStatusEffects(),
- mStatusParticleEffects(),
- mChildParticleEffects(&mStatusParticleEffects, false),
- mHorseId(0),
- mId(id),
- mUsedTargetCursor(nullptr),
- mActorSpriteListeners(),
- mCursorPaddingX(0),
- mCursorPaddingY(0),
- mMustResetParticles(false),
- mPoison(false),
- mHaveCart(false),
- mTrickDead(false)
-{
-}
-
-ActorSprite::~ActorSprite()
-{
- mChildParticleEffects.clear();
- mMustResetParticles = true;
-
- mUsedTargetCursor = nullptr;
-
- if (localPlayer != nullptr &&
- localPlayer != this &&
- localPlayer->getTarget() == this)
- {
- localPlayer->setTarget(nullptr);
- }
-
- // Notify listeners of the destruction.
- FOR_EACH (ActorSpriteListenerIterator, iter, mActorSpriteListeners)
- {
- if (reportFalse(*iter))
- (*iter)->actorSpriteDestroyed(*this);
- }
-}
-
-void ActorSprite::logic()
-{
- BLOCK_START("ActorSprite::logic")
- // Update sprite animations
- update(tick_time * MILLISECONDS_IN_A_TICK);
-
- // Restart status/particle effects, if needed
- if (mMustResetParticles)
- {
- mMustResetParticles = false;
- FOR_EACH (std::set<int32_t>::const_iterator, it, mStatusEffects)
- {
- const StatusEffect *const effect
- = StatusEffectDB::getStatusEffect(*it, Enable_true);
- if (effect != nullptr &&
- effect->mIsPersistent)
- {
- updateStatusEffect(*it,
- Enable_true,
- IsStart_false);
- }
- }
- }
-
- // Update particle effects
- mChildParticleEffects.moveTo(mPos.x, mPos.y);
- BLOCK_END("ActorSprite::logic")
-}
-
-void ActorSprite::setMap(Map *const map)
-{
- Actor::setMap(map);
-
- // Clear particle effect list because child particles became invalid
- mChildParticleEffects.clear();
- mMustResetParticles = true; // Reset status particles on next redraw
-}
-
-void ActorSprite::controlAutoParticle(Particle *const particle)
-{
- if (particle != nullptr)
- {
- particle->setActor(mId);
- mChildParticleEffects.addLocally(particle);
- }
-}
-
-void ActorSprite::controlCustomParticle(Particle *const particle)
-{
- if (particle != nullptr)
- {
- // The effect may not die without the beings permission or we segfault
- particle->disableAutoDelete();
- mChildParticleEffects.addLocally(particle);
- }
-}
-
-void ActorSprite::controlParticleDeleted(const Particle *const particle)
-{
- if (particle != nullptr)
- mChildParticleEffects.removeLocally(particle);
-}
-
-void ActorSprite::setTargetType(const TargetCursorTypeT type)
-{
- if (type == TargetCursorType::NONE)
- {
- untarget();
- }
- else
- {
- const size_t sz = CAST_SIZE(getTargetCursorSize());
- mUsedTargetCursor = targetCursor[CAST_S32(type)][sz];
- if (mUsedTargetCursor != nullptr)
- {
- static const int targetWidths[CAST_SIZE(
- TargetCursorSize::NUM_TC)]
- = {0, 0, 0};
- static const int targetHeights[CAST_SIZE(
- TargetCursorSize::NUM_TC)]
- = {-mapTileSize / 2, -mapTileSize / 2, -mapTileSize};
-
- mCursorPaddingX = CAST_S32(targetWidths[sz]);
- mCursorPaddingY = CAST_S32(targetHeights[sz]);
- }
- }
-}
-
-void ActorSprite::setStatusEffect(const int32_t index,
- const Enable active,
- const IsStart start)
-{
- const Enable wasActive = fromBool(
- mStatusEffects.find(index) != mStatusEffects.end(), Enable);
-
- if (active != wasActive)
- {
- updateStatusEffect(index, active, start);
- if (active == Enable_true)
- {
- mStatusEffects.insert(index);
- }
- else
- {
- mStatusEffects.erase(index);
- }
- }
-}
-
-// function for legacy configs only. Must be removed in future
-void ActorSprite::setStatusEffectBlock(const int offset,
- const uint16_t newEffects)
-{
- for (unsigned i = 0; i < STATUS_EFFECTS; i++)
- {
- const bool val = (newEffects & (1 << i)) > 0;
- const int32_t index = StatusEffectDB::blockIdToId(
- offset + i); // block-id (offset + i) to id (index)
-
- if (index != -1)
- {
- setStatusEffect(index,
- fromBool(val, Enable),
- IsStart_true);
- }
- else if (val && config.getBoolValue("unimplimentedLog"))
- {
- const std::string str = strprintf(
- "Error: unknown effect by block-index. "
- "Offset: %d, effect int: %d, i: %u",
- offset, CAST_S32(newEffects), i);
- logger->log(str);
- DebugMessageListener::distributeEvent(str);
- }
- }
-}
-
-static void applyEffectByOption(ActorSprite *const actor,
- uint32_t option,
- const char *const name,
- const OptionsMap& options)
-{
- FOR_EACH (OptionsMapCIter, it, options)
- {
- const uint32_t opt = (*it).first;
- const int32_t id = (*it).second;
- const Enable enable = (opt & option) != 0 ? Enable_true : Enable_false;
- option |= opt;
- option ^= opt;
- actor->setStatusEffect(id,
- enable,
- IsStart_false);
- }
- if (option != 0U &&
- config.getBoolValue("unimplimentedLog"))
- {
- const std::string str = strprintf(
- "Error: unknown effect by %s. "
- "Left value: %u",
- name,
- option);
- logger->log(str);
- DebugMessageListener::distributeEvent(str);
- }
-}
-
-static void applyEffectByOption1(ActorSprite *const actor,
- uint32_t option,
- const char *const name,
- const OptionsMap& options)
-{
- FOR_EACH (OptionsMapCIter, it, options)
- {
- const uint32_t opt = (*it).first;
- const int32_t id = (*it).second;
- if (opt == option)
- {
- actor->setStatusEffect(id,
- Enable_true,
- IsStart_false);
- option = 0U;
- }
- else
- {
- actor->setStatusEffect(id,
- Enable_false,
- IsStart_false);
- }
- }
- if (option != 0 &&
- config.getBoolValue("unimplimentedLog"))
- {
- const std::string str = strprintf(
- "Error: unknown effect by %s. "
- "Left value: %u",
- name,
- option);
- logger->log(str);
- DebugMessageListener::distributeEvent(str);
- }
-}
-
-void ActorSprite::setStatusEffectOpitons(const uint32_t option,
- const uint32_t opt1,
- const uint32_t opt2,
- const uint32_t opt3)
-{
- if (settings.legacyEffects == false)
- {
- applyEffectByOption(this, option, "option",
- StatusEffectDB::getOptionMap());
- applyEffectByOption1(this, opt1, "opt1",
- StatusEffectDB::getOpt1Map());
- applyEffectByOption(this, opt2, "opt2",
- StatusEffectDB::getOpt2Map());
- applyEffectByOption(this, opt3, "opt3",
- StatusEffectDB::getOpt3Map());
- }
- else
- {
- uint32_t statusEffects = opt2;
- statusEffects |= option << 16;
- setStatusEffectBlock(0,
- CAST_U16((statusEffects >> 16) & 0xffffU));
- setStatusEffectBlock(16,
- CAST_U16(statusEffects & 0xffffU));
- setStatusEffectBlock(32,
- CAST_U16(opt3));
- }
-}
-
-void ActorSprite::setStatusEffectOpitons(const uint32_t option,
- const uint32_t opt1,
- const uint32_t opt2)
-{
- if (settings.legacyEffects == false)
- {
- applyEffectByOption(this, option, "option",
- StatusEffectDB::getOptionMap());
- applyEffectByOption1(this, opt1, "opt1",
- StatusEffectDB::getOpt1Map());
- applyEffectByOption(this, opt2, "opt2",
- StatusEffectDB::getOpt2Map());
- }
- else
- {
- uint32_t statusEffects = opt2;
- statusEffects |= option << 16;
- setStatusEffectBlock(0,
- CAST_U16((statusEffects >> 16) & 0xffffU));
- setStatusEffectBlock(16,
- CAST_U16(statusEffects & 0xffffU));
- }
-}
-
-void ActorSprite::setStatusEffectOpiton0(const uint32_t option)
-{
- if (settings.legacyEffects == false)
- {
- applyEffectByOption(this, option, "option",
- StatusEffectDB::getOptionMap());
- }
- else
- {
- const uint32_t statusEffects = option << 16;
- setStatusEffectBlock(0,
- CAST_U16((statusEffects >> 16) & 0xffff));
- }
-}
-
-void ActorSprite::updateStatusEffect(const int32_t index,
- const Enable newStatus,
- const IsStart start)
-{
- StatusEffect *const effect = StatusEffectDB::getStatusEffect(
- index, newStatus);
- if (effect == nullptr)
- return;
- if (effect->mIsPoison && getType() == ActorType::Player)
- setPoison(newStatus == Enable_true);
- else if (effect->mIsCart && localPlayer == this)
- setHaveCart(newStatus == Enable_true);
- else if (effect->mIsRiding)
- setRiding(newStatus == Enable_true);
- else if (effect->mIsTrickDead)
- setTrickDead(newStatus == Enable_true);
- else if (effect->mIsPostDelay)
- stopCast(newStatus == Enable_true);
- handleStatusEffect(effect, index, newStatus, start);
-}
-
-void ActorSprite::handleStatusEffect(const StatusEffect *const effect,
- const int32_t effectId,
- const Enable newStatus,
- const IsStart start)
-{
- if (effect == nullptr)
- return;
-
- if (newStatus == Enable_true)
- {
- if (effectId >= 0)
- {
- Particle *particle = nullptr;
- if (start == IsStart_true)
- particle = effect->getStartParticle();
- if (particle == nullptr)
- particle = effect->getParticle();
- if (particle != nullptr)
- mStatusParticleEffects.setLocally(effectId, particle);
- }
- }
- else
- {
- mStatusParticleEffects.delLocally(effectId);
- }
-}
-
-void ActorSprite::setupSpriteDisplay(const SpriteDisplay &display,
- const ForceDisplay forceDisplay,
- const DisplayTypeT displayType,
- const std::string &color)
-{
- clear();
-
- FOR_EACH (SpriteRefs, it, display.sprites)
- {
- if (*it == nullptr)
- continue;
- const std::string file = pathJoin(paths.getStringValue("sprites"),
- combineDye3((*it)->sprite, color));
-
- const int variant = (*it)->variant;
- addSprite(AnimatedSprite::delayedLoad(file, variant));
- }
-
- // Ensure that something is shown, if desired
- if (mSprites.empty() && forceDisplay == ForceDisplay_true)
- {
- if (display.image.empty())
- {
- addSprite(AnimatedSprite::delayedLoad(pathJoin(
- paths.getStringValue("sprites"),
- paths.getStringValue("spriteErrorFile"))));
- }
- else
- {
- std::string imagePath;
- switch (displayType)
- {
- case DisplayType::Item:
- default:
- imagePath = pathJoin(paths.getStringValue("itemIcons"),
- display.image);
- break;
- case DisplayType::Floor:
- imagePath = pathJoin(paths.getStringValue("itemIcons"),
- display.floor);
- break;
- }
- imagePath = combineDye2(imagePath, color);
- Image *img = Loader::getImage(imagePath);
-
- if (img == nullptr)
- img = Theme::getImageFromTheme("unknown-item.png");
-
- addSprite(new ImageSprite(img));
- if (img != nullptr)
- img->decRef();
- }
- }
-
- mChildParticleEffects.clear();
-
- // setup particle effects
- if (ParticleEngine::enabled && (particleEngine != nullptr))
- {
- FOR_EACH (StringVectCIter, itr, display.particles)
- {
- Particle *const p = particleEngine->addEffect(*itr, 0, 0);
- controlAutoParticle(p);
- }
- }
-
- mMustResetParticles = true;
-}
-
-void ActorSprite::load()
-{
- if (loaded)
- unload();
-
- initTargetCursor();
-
- loaded = true;
-}
-
-void ActorSprite::unload()
-{
- if (reportTrue(!loaded))
- return;
-
- cleanupTargetCursors();
- loaded = false;
-}
-
-void ActorSprite::addActorSpriteListener(ActorSpriteListener *const listener)
-{
- mActorSpriteListeners.push_front(listener);
-}
-
-void ActorSprite::removeActorSpriteListener(ActorSpriteListener *const
- listener)
-{
- mActorSpriteListeners.remove(listener);
-}
-
-static const char *cursorType(const TargetCursorTypeT type)
-{
- switch (type)
- {
- case TargetCursorType::IN_RANGE:
- return "in-range";
- default:
- case TargetCursorType::NONE:
- case TargetCursorType::NUM_TCT:
- case TargetCursorType::NORMAL:
- return "normal";
- }
-}
-
-static const char *cursorSize(const TargetCursorSizeT size)
-{
- switch (size)
- {
- case TargetCursorSize::LARGE:
- return "l";
- case TargetCursorSize::MEDIUM:
- return "m";
- default:
- case TargetCursorSize::NUM_TC:
- case TargetCursorSize::SMALL:
- return "s";
- }
-}
-
-void ActorSprite::initTargetCursor()
-{
- static const std::string targetCursorFile("target-cursor-%s-%s.xml");
-
- // Load target cursors
- for_each_cursors()
- {
- targetCursor[type][size] = AnimatedSprite::load(
- Theme::resolveThemePath(strprintf(
- targetCursorFile.c_str(),
- cursorType(static_cast<TargetCursorTypeT>(type)),
- cursorSize(static_cast<TargetCursorSizeT>(size)))));
- }
- end_foreach
-}
-
-void ActorSprite::cleanupTargetCursors()
-{
- for_each_cursors()
- {
- delete2(targetCursor[type][size])
- }
- end_foreach
-}
-
-std::string ActorSprite::getStatusEffectsString() const
-{
- std::string effectsStr;
- if (!mStatusEffects.empty())
- {
- FOR_EACH (std::set<int32_t>::const_iterator, it, mStatusEffects)
- {
- const StatusEffect *const effect =
- StatusEffectDB::getStatusEffect(
- *it,
- Enable_true);
- if (effect == nullptr)
- continue;
- if (!effectsStr.empty())
- effectsStr.append(", ");
- effectsStr.append(effect->mName);
- }
- }
- return effectsStr;
-}
diff --git a/src/being/actorsprite.h b/src/being/actorsprite.h
deleted file mode 100644
index db912e059..000000000
--- a/src/being/actorsprite.h
+++ /dev/null
@@ -1,274 +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 BEING_ACTORSPRITE_H
-#define BEING_ACTORSPRITE_H
-
-#include "being/actor.h"
-#include "being/compoundsprite.h"
-
-#include "const/resources/map/map.h"
-
-#include "enums/being/actortype.h"
-#include "enums/being/targetcursorsize.h"
-#include "enums/being/targetcursortype.h"
-
-#include "enums/simpletypes/beingid.h"
-#include "enums/simpletypes/enable.h"
-#include "enums/simpletypes/forcedisplay.h"
-#include "enums/simpletypes/isstart.h"
-
-#include "enums/resources/displaytype.h"
-
-#include "enums/resources/map/blocktype.h"
-
-#include "particle/particlelist.h"
-#include "particle/particlevector.h"
-
-#include "localconsts.h"
-
-class AnimatedSprite;
-class StatusEffect;
-class ActorSpriteListener;
-
-struct SpriteDisplay;
-
-class ActorSprite notfinal : public CompoundSprite, public Actor
-{
- public:
- explicit ActorSprite(const BeingId id);
-
- A_DELETE_COPY(ActorSprite)
-
- virtual ~ActorSprite();
-
- BeingId getId() const noexcept2 A_WARN_UNUSED
- { return mId; }
-
- void setId(const BeingId id) noexcept2
- { mId = id; }
-
- /**
- * Returns the type of the ActorSprite.
- */
- virtual ActorTypeT getType() const noexcept2 A_WARN_UNUSED
- { return ActorType::Unknown; }
-
- virtual void logic();
-
- void setMap(Map *const map) override;
-
- /**
- * Gets the way the object blocks pathfinding for other objects
- */
- virtual BlockTypeT getBlockType() const A_WARN_UNUSED
- { return BlockType::NONE; }
-
- /**
- * Take control of a particle. Particle can be auto deleted.
- */
- void controlAutoParticle(Particle *const particle);
-
- /**
- * Take control of a particle. Owner must remove particle by self.
- */
- void controlCustomParticle(Particle *const particle);
-
- /**
- * Returns the required size of a target cursor for this being.
- */
- virtual TargetCursorSizeT getTargetCursorSize() const A_WARN_UNUSED
- { return TargetCursorSize::MEDIUM; }
-
- virtual int getTargetOffsetX() const A_WARN_UNUSED
- { return 0; }
-
- virtual int getTargetOffsetY() const A_WARN_UNUSED
- { return 0; }
-
- /**
- * Sets the target animation for this actor.
- */
- void setTargetType(const TargetCursorTypeT type);
-
- /**
- * Untargets the actor.
- */
- void untarget()
- { mUsedTargetCursor = nullptr; }
-
- void setStatusEffect(const int32_t index,
- const Enable active,
- const IsStart start);
-
- void setStatusEffectOpitons(const uint32_t option,
- const uint32_t opt1,
- const uint32_t opt2,
- const uint32_t opt3);
-
- void setStatusEffectOpitons(const uint32_t option,
- const uint32_t opt1,
- const uint32_t opt2);
-
- void setStatusEffectOpiton0(const uint32_t option);
-
- void setAlpha(const float alpha) override final
- { CompoundSprite::setAlpha(alpha); }
-
- float getAlpha() const override final A_WARN_UNUSED
- { return CompoundSprite::getAlpha(); }
-
- int getWidth() const override A_WARN_UNUSED
- { return CompoundSprite::getWidth(); }
-
- int getHeight() const override A_WARN_UNUSED
- { return CompoundSprite::getHeight(); }
-
- static void load();
-
- static void unload();
-
- /**
- * Add an ActorSprite listener.
- */
- void addActorSpriteListener(ActorSpriteListener *const listener);
-
- /**
- * Remove an ActorSprite listener.
- */
- void removeActorSpriteListener(ActorSpriteListener *const listener);
-
- int getActorX() const A_WARN_UNUSED
- { return getPixelX() - mapTileSize / 2; }
-
- int getActorY() const A_WARN_UNUSED
- { return getPixelY() - mapTileSize; }
-
- void setPoison(const bool b)
- { mPoison = b; }
-
- bool getPoison() const A_WARN_UNUSED
- { return mPoison; }
-
- void setHaveCart(const bool b)
- { mHaveCart = b; }
-
- bool getHaveCart() const A_WARN_UNUSED
- { return mHaveCart; }
-
- virtual void setRiding(const bool b)
- { mHorseId = b ? 1 : 0; }
-
- virtual void setTrickDead(const bool b)
- { mTrickDead = b; }
-
- bool isTrickDead() const A_WARN_UNUSED
- { return mTrickDead; }
-
- const std::set<int32_t> &getStatusEffects() const A_WARN_UNUSED
- { return mStatusEffects; }
-
- std::string getStatusEffectsString() const;
-
- virtual void stopCast(const bool b A_UNUSED)
- { }
-
- size_t getParticlesCount() const
- {
- return mStatusParticleEffects.usedSize() +
- mChildParticleEffects.size();
- }
-
- void controlParticleDeleted(const Particle *const particle);
-
- protected:
- /**
- * A status effect block is a 16 bit mask of status effects. We assign
- * each such flag a block ID of offset + bitnr.
- *
- * These are NOT the same as the status effect indices.
- */
- void setStatusEffectBlock(const int offset,
- const uint16_t newEffects);
-
- /**
- * Notify self that a status effect has flipped.
- * The new flag is passed.
- */
- virtual void updateStatusEffect(const int32_t index,
- const Enable newStatus,
- const IsStart start);
-
- /**
- * Handle an update to a status or stun effect
- *
- * \param The StatusEffect to effect
- * \param effectId -1 for stun, otherwise the effect index
- */
- virtual void handleStatusEffect(const StatusEffect *const effect,
- const int32_t effectId,
- const Enable newStatus,
- const IsStart start);
-
- void setupSpriteDisplay(const SpriteDisplay &display,
- const ForceDisplay forceDisplay,
- const DisplayTypeT displayType,
- const std::string &color);
-
- /** Load the target cursors into memory */
- static void initTargetCursor();
-
- /** Remove the target cursors from memory */
- static void cleanupTargetCursors();
-
- /** Animated target cursors. */
- static AnimatedSprite *targetCursor
- [CAST_SIZE(TargetCursorType::NUM_TCT)]
- [CAST_SIZE(TargetCursorSize::NUM_TC)];
-
- static bool loaded;
-
- /**< set of active status effects */
- std::set<int32_t> mStatusEffects;
-
- ParticleVector mStatusParticleEffects;
- ParticleList mChildParticleEffects;
- int mHorseId;
- BeingId mId;
-
- /** Target cursor being used */
- AnimatedSprite *mUsedTargetCursor;
-
- typedef std::list<ActorSpriteListener*> ActorSpriteListeners;
- typedef ActorSpriteListeners::iterator ActorSpriteListenerIterator;
- ActorSpriteListeners mActorSpriteListeners;
-
- int mCursorPaddingX;
- int mCursorPaddingY;
-
- /** Reset particle status effects on next redraw? */
- bool mMustResetParticles;
- bool mPoison;
- bool mHaveCart;
- bool mTrickDead;
-};
-
-#endif // BEING_ACTORSPRITE_H
diff --git a/src/being/being.cpp b/src/being/being.cpp
deleted file mode 100644
index 6bbf50a48..000000000
--- a/src/being/being.cpp
+++ /dev/null
@@ -1,5470 +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 "being/being.h"
-
-#include "actormanager.h"
-#include "beingequipbackend.h"
-#include "configuration.h"
-#include "effectmanager.h"
-#include "guild.h"
-#include "itemcolormanager.h"
-#include "party.h"
-#include "settings.h"
-#include "soundmanager.h"
-#include "text.h"
-
-#include "being/beingcacheentry.h"
-#include "being/beingflag.h"
-#include "being/beingspeech.h"
-#include "being/castingeffect.h"
-#include "being/localplayer.h"
-#include "being/playerinfo.h"
-#include "being/playerrelations.h"
-#include "being/homunculusinfo.h"
-#include "being/mercenaryinfo.h"
-
-#include "const/utils/timer.h"
-
-#include "const/resources/spriteaction.h"
-
-#include "enums/being/beingdirection.h"
-
-#include "enums/resources/map/blockmask.h"
-
-#include "fs/files.h"
-
-#include "gui/gui.h"
-#include "gui/userpalette.h"
-
-#include "gui/fonts/font.h"
-
-#include "gui/popups/speechbubble.h"
-
-#include "gui/windows/chatwindow.h"
-#include "gui/windows/equipmentwindow.h"
-#include "gui/windows/skilldialog.h"
-#include "gui/windows/socialwindow.h"
-
-#include "net/charserverhandler.h"
-#include "net/gamehandler.h"
-#include "net/homunculushandler.h"
-#include "net/mercenaryhandler.h"
-#include "net/net.h"
-#include "net/npchandler.h"
-#include "net/packetlimiter.h"
-#include "net/playerhandler.h"
-#include "net/serverfeatures.h"
-
-#include "particle/particleinfo.h"
-
-#include "resources/attack.h"
-#include "resources/chatobject.h"
-#include "resources/emoteinfo.h"
-#include "resources/emotesprite.h"
-#include "resources/horseinfo.h"
-#include "resources/iteminfo.h"
-
-#include "resources/db/avatardb.h"
-#include "resources/db/badgesdb.h"
-#include "resources/db/groupdb.h"
-#include "resources/db/elementaldb.h"
-#include "resources/db/emotedb.h"
-#include "resources/db/homunculusdb.h"
-#include "resources/db/horsedb.h"
-#include "resources/db/languagedb.h"
-#include "resources/db/mercenarydb.h"
-#include "resources/db/monsterdb.h"
-#include "resources/db/npcdb.h"
-#include "resources/db/petdb.h"
-#include "resources/db/skillunitdb.h"
-
-#include "resources/image/image.h"
-
-#include "resources/item/item.h"
-
-#include "resources/map/map.h"
-
-#include "resources/skill/skilldata.h"
-#include "resources/skill/skillinfo.h"
-
-#include "resources/sprite/animatedsprite.h"
-
-#include "gui/widgets/createwidget.h"
-
-#include "gui/widgets/tabs/chat/langtab.h"
-
-#include "utils/checkutils.h"
-#include "utils/delete2.h"
-#include "utils/foreach.h"
-#include "utils/gettext.h"
-#include "utils/likely.h"
-#include "utils/stdmove.h"
-#include "utils/timer.h"
-
-#include "debug.h"
-
-const unsigned int CACHE_SIZE = 50;
-
-time_t Being::mUpdateConfigTime = 0;
-unsigned int Being::mConfLineLim = 0;
-int Being::mSpeechType = 0;
-bool Being::mHighlightMapPortals = false;
-bool Being::mHighlightMonsterAttackRange = false;
-bool Being::mLowTraffic = true;
-bool Being::mDrawHotKeys = true;
-bool Being::mShowBattleEvents = false;
-bool Being::mShowMobHP = false;
-bool Being::mShowOwnHP = false;
-bool Being::mShowGender = false;
-bool Being::mShowLevel = false;
-bool Being::mShowPlayersStatus = false;
-bool Being::mEnableReorderSprites = true;
-bool Being::mHideErased = false;
-Move Being::mMoveNames = Move_false;
-bool Being::mUseDiagonal = true;
-BadgeDrawType::Type Being::mShowBadges = BadgeDrawType::Top;
-int Being::mAwayEffect = -1;
-VisibleNamePos::Type Being::mVisibleNamePos = VisibleNamePos::Bottom;
-
-std::list<BeingCacheEntry*> beingInfoCache;
-typedef std::map<int, Guild*>::const_iterator GuildsMapCIter;
-typedef std::map<int, int>::const_iterator IntMapCIter;
-
-static const unsigned int SPEECH_TIME = 500;
-static const unsigned int SPEECH_MIN_TIME = 200;
-static const unsigned int SPEECH_MAX_TIME = 800;
-
-#define for_each_badges() \
- for (int f = 0; f < BadgeIndex::BadgeIndexSize; f++)
-
-#define for_each_horses(name) \
- FOR_EACH (STD_VECTOR<AnimatedSprite*>::const_iterator, it, name)
-
-Being::Being(const BeingId id,
- const ActorTypeT type) :
- ActorSprite(id),
- mNextSound(),
- mInfo(BeingInfo::unknown),
- mEmotionSprite(nullptr),
- mAnimationEffect(nullptr),
- mCastingEffect(nullptr),
- mBadges(),
- mSpriteAction(SpriteAction::STAND),
- mName(),
- mExtName(),
- mRaceName(),
- mPartyName(),
- mGuildName(),
- mSpeech(),
- mDispName(nullptr),
- mNameColor(nullptr),
- mEquippedWeapon(nullptr),
- mPath(),
- mText(nullptr),
- mTextColor(nullptr),
- mDest(),
- mSlots(),
- mSpriteParticles(),
- mGuilds(),
- mParty(nullptr),
- mActionTime(0),
- mEmotionTime(0),
- mSpeechTime(0),
- mAttackSpeed(350),
- mLevel(0),
- mGroupId(0),
- mAttackRange(1),
- mLastAttackX(0),
- mLastAttackY(0),
- mPreStandTime(0),
- mGender(Gender::UNSPECIFIED),
- mAction(BeingAction::STAND),
- mSubType(fromInt(0xFFFF, BeingTypeId)),
- mDirection(BeingDirection::DOWN),
- mDirectionDelayed(0),
- mSpriteDirection(SpriteDirection::DOWN),
- mShowName(false),
- mIsGM(false),
- mType(type),
- mSpeechBubble(nullptr),
- mWalkSpeed(playerHandler != nullptr ?
- playerHandler->getDefaultWalkSpeed() : 1),
- mSpeed(playerHandler != nullptr ?
- playerHandler->getDefaultWalkSpeed() : 1),
- mIp(),
- mSpriteRemap(new int[20]),
- mSpriteHide(new int[20]),
- mSpriteDraw(new int[20]),
- mComment(),
- mBuyBoard(),
- mSellBoard(),
- mOwner(nullptr),
- mSpecialParticle(nullptr),
- mChat(nullptr),
- mHorseInfo(nullptr),
- mDownHorseSprites(),
- mUpHorseSprites(),
- mSpiritParticles(),
- mX(0),
- mY(0),
- mCachedX(0),
- mCachedY(0),
- mSortOffsetY(0),
- mPixelOffsetY(0),
- mFixedOffsetY(0),
- mOldHeight(0),
- mDamageTaken(0),
- mHP(0),
- mMaxHP(0),
- mDistance(0),
- mReachable(Reachable::REACH_UNKNOWN),
- mGoodStatus(-1),
- mMoveTime(0),
- mAttackTime(0),
- mTalkTime(0),
- mOtherTime(0),
- mTestTime(cur_time),
- mAttackDelay(0),
- mMinHit(0),
- mMaxHit(0),
- mCriticalHit(0),
- mPvpRank(0),
- mNumber(100),
- mSpiritBalls(0U),
- mUsageCounter(1),
- mKarma(0),
- mManner(0),
- mAreaSize(11),
- mCastEndTime(0),
- mLanguageId(-1),
- mBadgesX(0),
- mBadgesY(0),
- mCreatorId(BeingId_zero),
- mTeamId(0U),
- mLook(0U),
- mBadgesCount(0U),
- mHairColor(ItemColor_zero),
- mErased(false),
- mEnemy(false),
- mGotComment(false),
- mAdvanced(false),
- mShop(false),
- mAway(false),
- mInactive(false),
- mNeedPosUpdate(true),
- mBotAi(true)
-{
- for (int f = 0; f < 20; f ++)
- {
- mSpriteRemap[f] = f;
- mSpriteHide[f] = 0;
- mSpriteDraw[f] = 0;
- }
-
- for_each_badges()
- mBadges[f] = nullptr;
-}
-
-void Being::postInit(const BeingTypeId subtype,
- Map *const map)
-{
- setMap(map);
- setSubtype(subtype, 0);
-
- VisibleName::Type showName1 = VisibleName::Hide;
-
- switch (mType)
- {
- case ActorType::Player:
- case ActorType::Mercenary:
- case ActorType::Pet:
- case ActorType::Homunculus:
- case ActorType::Elemental:
- showName1 = static_cast<VisibleName::Type>(
- config.getIntValue("visiblenames"));
- break;
- case ActorType::Portal:
- case ActorType::SkillUnit:
- showName1 = VisibleName::Hide;
- break;
- default:
- case ActorType::Unknown:
- case ActorType::Npc:
- case ActorType::Monster:
- case ActorType::FloorItem:
- case ActorType::Avatar:
- break;
- }
-
- if (mType != ActorType::Npc)
- mGotComment = true;
-
- config.addListener("visiblenames", this);
-
- reReadConfig();
-
- if (mType == ActorType::Npc ||
- showName1 == VisibleName::Show)
- {
- setShowName(true);
- }
-
- updateColors();
- updatePercentHP();
-}
-
-Being::~Being()
-{
- config.removeListener("visiblenames", this);
- CHECKLISTENERS
-
- delete [] mSpriteRemap;
- mSpriteRemap = nullptr;
- delete [] mSpriteHide;
- mSpriteHide = nullptr;
- delete [] mSpriteDraw;
- mSpriteDraw = nullptr;
-
- for_each_badges()
- delete2(mBadges[f]);
-
- delete2(mSpeechBubble);
- delete2(mDispName);
- delete2(mText);
- delete2(mEmotionSprite);
- delete2(mAnimationEffect);
- delete2(mCastingEffect);
- mBadgesCount = 0;
- delete2(mChat);
- removeHorse();
-
- removeAllItemsParticles();
- mSpiritParticles.clear();
-}
-
-void Being::createSpeechBubble() restrict2
-{
- CREATEWIDGETV0(mSpeechBubble, SpeechBubble);
-}
-
-void Being::setSubtype(const BeingTypeId subtype,
- const uint16_t look) restrict2
-{
- if (mInfo == nullptr)
- return;
-
- if (subtype == mSubType && mLook == look)
- return;
-
- mSubType = subtype;
- mLook = look;
-
- switch (mType)
- {
- case ActorType::Monster:
- mInfo = MonsterDB::get(mSubType);
- if (mInfo != nullptr)
- {
- setName(mInfo->getName());
- setupSpriteDisplay(mInfo->getDisplay(),
- ForceDisplay_true,
- DisplayType::Item,
- mInfo->getColor(fromInt(mLook, ItemColor)));
- mYDiff = mInfo->getSortOffsetY();
- }
- break;
- case ActorType::Pet:
- mInfo = PETDB::get(mSubType);
- if (mInfo != nullptr)
- {
- setName(mInfo->getName());
- setupSpriteDisplay(mInfo->getDisplay(),
- ForceDisplay_true,
- DisplayType::Item,
- mInfo->getColor(fromInt(mLook, ItemColor)));
- mYDiff = mInfo->getSortOffsetY();
- }
- break;
- case ActorType::Mercenary:
- mInfo = MercenaryDB::get(mSubType);
- if (mInfo != nullptr)
- {
- setName(mInfo->getName());
- setupSpriteDisplay(mInfo->getDisplay(),
- ForceDisplay_true,
- DisplayType::Item,
- mInfo->getColor(fromInt(mLook, ItemColor)));
- mYDiff = mInfo->getSortOffsetY();
- }
- break;
- case ActorType::Homunculus:
- mInfo = HomunculusDB::get(mSubType);
- if (mInfo != nullptr)
- {
- setName(mInfo->getName());
- setupSpriteDisplay(mInfo->getDisplay(),
- ForceDisplay_true,
- DisplayType::Item,
- mInfo->getColor(fromInt(mLook, ItemColor)));
- mYDiff = mInfo->getSortOffsetY();
- }
- break;
- case ActorType::SkillUnit:
- mInfo = SkillUnitDb::get(mSubType);
- if (mInfo != nullptr)
- {
- setName(mInfo->getName());
- setupSpriteDisplay(mInfo->getDisplay(),
- ForceDisplay_false,
- DisplayType::Item,
- mInfo->getColor(fromInt(mLook, ItemColor)));
- mYDiff = mInfo->getSortOffsetY();
- }
- break;
- case ActorType::Elemental:
- mInfo = ElementalDb::get(mSubType);
- if (mInfo != nullptr)
- {
- setName(mInfo->getName());
- setupSpriteDisplay(mInfo->getDisplay(),
- ForceDisplay_false,
- DisplayType::Item,
- mInfo->getColor(fromInt(mLook, ItemColor)));
- mYDiff = mInfo->getSortOffsetY();
- }
- break;
- case ActorType::Npc:
- mInfo = NPCDB::get(mSubType);
- if (mInfo != nullptr)
- {
- setupSpriteDisplay(mInfo->getDisplay(),
- ForceDisplay_false,
- DisplayType::Item,
- std::string());
- mYDiff = mInfo->getSortOffsetY();
- }
- break;
- case ActorType::Avatar:
- mInfo = AvatarDB::get(mSubType);
- if (mInfo != nullptr)
- {
- setupSpriteDisplay(mInfo->getDisplay(),
- ForceDisplay_false,
- DisplayType::Item,
- std::string());
- }
- break;
- case ActorType::Player:
- {
- int id = -100 - toInt(subtype, int);
- // Prevent showing errors when sprite doesn't exist
- if (!ItemDB::exists(id))
- {
- id = -100;
- // TRANSLATORS: default race name
- setRaceName(_("Human"));
- if (charServerHandler != nullptr)
- {
- setSpriteId(charServerHandler->baseSprite(),
- id);
- }
- }
- else
- {
- const ItemInfo &restrict info = ItemDB::get(id);
- setRaceName(info.getName());
- if (charServerHandler != nullptr)
- {
- setSpriteColor(charServerHandler->baseSprite(),
- id,
- info.getColor(fromInt(mLook, ItemColor)));
- }
- }
- break;
- }
- case ActorType::Portal:
- break;
- case ActorType::Unknown:
- case ActorType::FloorItem:
- default:
- reportAlways("Wrong being type %d in setSubType",
- CAST_S32(mType));
- break;
- }
-}
-
-TargetCursorSizeT Being::getTargetCursorSize() const restrict2
-{
- if (mInfo == nullptr)
- return TargetCursorSize::SMALL;
-
- return mInfo->getTargetCursorSize();
-}
-
-void Being::setPixelPositionF(const Vector &restrict pos) restrict2
-{
- Actor::setPixelPositionF(pos);
-
- updateCoords();
-
- if (mText != nullptr)
- {
- mText->adviseXY(CAST_S32(pos.x),
- CAST_S32(pos.y) - getHeight() - mText->getHeight() - 9,
- mMoveNames);
- }
-}
-
-void Being::setDestination(const int dstX,
- const int dstY) restrict2
-{
- if (mMap == nullptr)
- return;
-
- setPath(mMap->findPath(mX, mY, dstX, dstY, getBlockWalkMask()));
-}
-
-void Being::clearPath() restrict2
-{
- mPath.clear();
-}
-
-void Being::setPath(const Path &restrict path) restrict2
-{
- mPath = path;
- if (mPath.empty())
- return;
-
- if (mAction != BeingAction::MOVE && mAction != BeingAction::DEAD)
- {
- nextTile();
- mActionTime = tick_time;
- }
-}
-
-void Being::setSpeech(const std::string &restrict text,
- const std::string &restrict channel,
- int time) restrict2
-{
- if (userPalette == nullptr)
- return;
-
- if (!channel.empty() &&
- ((langChatTab == nullptr) || langChatTab->getChannelName() != channel))
- {
- return;
- }
-
- // Remove colors
- mSpeech = removeColors(text);
-
- // Trim whitespace
- trim(mSpeech);
-
- const unsigned int lineLim = mConfLineLim;
- if (lineLim > 0 && mSpeech.length() > lineLim)
- mSpeech = mSpeech.substr(0, lineLim);
-
- trim(mSpeech);
- if (mSpeech.empty())
- return;
-
- if (time == 0)
- {
- const size_t sz = mSpeech.size();
- if (sz < 200)
- time = CAST_S32(SPEECH_TIME - 300 + (3 * sz));
- }
-
- if (time < CAST_S32(SPEECH_MIN_TIME))
- time = CAST_S32(SPEECH_MIN_TIME);
-
- // Check for links
- size_t start = mSpeech.find('[');
- size_t e = mSpeech.find(']', start);
-
- while (start != std::string::npos && e != std::string::npos)
- {
- // Catch multiple embeds and ignore them so it doesn't crash the client.
- while ((mSpeech.find('[', start + 1) != std::string::npos) &&
- (mSpeech.find('[', start + 1) < e))
- {
- start = mSpeech.find('[', start + 1);
- }
-
- size_t position = mSpeech.find('|');
- if (mSpeech[start + 1] == '@' && mSpeech[start + 2] == '@')
- {
- mSpeech.erase(e, 1);
- mSpeech.erase(start, (position - start) + 1);
- }
- position = mSpeech.find("@@");
-
- while (position != std::string::npos)
- {
- mSpeech.erase(position, 2);
- position = mSpeech.find('@');
- }
-
- start = mSpeech.find('[', start + 1);
- e = mSpeech.find(']', start);
- }
-
- if (!mSpeech.empty())
- {
- mSpeechTime = time <= CAST_S32(SPEECH_MAX_TIME)
- ? time : CAST_S32(SPEECH_MAX_TIME);
- }
-
- const int speech = mSpeechType;
- if (speech == BeingSpeech::TEXT_OVERHEAD)
- {
- delete mText;
- mText = nullptr;
- mText = new Text(mSpeech,
- mPixelX,
- mPixelY - getHeight(),
- Graphics::CENTER,
- &userPalette->getColor(UserColorId::PARTICLE),
- Speech_true);
- mText->adviseXY(mPixelX,
- (mY + 1) * mapTileSize - getHeight() - mText->getHeight() - 9,
- mMoveNames);
- }
- else
- {
- const bool isShowName = (speech == BeingSpeech::NAME_IN_BUBBLE);
- if (mSpeechBubble == nullptr)
- createSpeechBubble();
- if (mSpeechBubble != nullptr)
- {
- mSpeechBubble->setCaption(isShowName ? mName : "");
- mSpeechBubble->setText(mSpeech, isShowName);
- }
- }
-}
-
-void Being::takeDamage(Being *restrict const attacker,
- const int amount,
- const AttackTypeT type,
- const int attackId,
- const int level) restrict2
-{
- if (userPalette == nullptr || attacker == nullptr)
- return;
-
- BLOCK_START("Being::takeDamage1")
-
- Font *font = nullptr;
- const Color *color;
-
- if (gui != nullptr)
- font = gui->getInfoParticleFont();
-
- // Selecting the right color
- if (type == AttackType::CRITICAL || type == AttackType::FLEE)
- {
- if (type == AttackType::CRITICAL)
- attacker->setCriticalHit(amount);
-
- if (attacker == localPlayer)
- {
- color = &userPalette->getColor(
- UserColorId::HIT_LOCAL_PLAYER_CRITICAL);
- }
- else
- {
- color = &userPalette->getColor(UserColorId::HIT_CRITICAL);
- }
- }
- else if (amount == 0)
- {
- if (attacker == localPlayer)
- {
- // This is intended to be the wrong direction to visually
- // differentiate between hits and misses
- color = &userPalette->getColor(UserColorId::HIT_LOCAL_PLAYER_MISS);
- }
- else
- {
- color = &userPalette->getColor(UserColorId::MISS);
- }
- }
- else if (mType == ActorType::Monster ||
- mType == ActorType::Mercenary ||
- mType == ActorType::Pet ||
- mType == ActorType::Homunculus ||
- mType == ActorType::SkillUnit)
- {
- if (attacker == localPlayer)
- {
- color = &userPalette->getColor(
- UserColorId::HIT_LOCAL_PLAYER_MONSTER);
- }
- else
- {
- color = &userPalette->getColor(
- UserColorId::HIT_PLAYER_MONSTER);
- }
- }
- else if (mType == ActorType::Player &&
- attacker != localPlayer &&
- this == localPlayer)
- {
- // here player was attacked by other player. mark him as enemy.
- color = &userPalette->getColor(UserColorId::HIT_PLAYER_PLAYER);
- attacker->setEnemy(true);
- attacker->updateColors();
- }
- else
- {
- color = &userPalette->getColor(UserColorId::HIT_MONSTER_PLAYER);
- }
-
- if (chatWindow != nullptr && mShowBattleEvents)
- {
- if (this == localPlayer)
- {
- if (attacker->mType == ActorType::Player || (amount != 0))
- {
- ChatWindow::battleChatLog(strprintf("%s : Hit you -%d",
- attacker->getName().c_str(), amount),
- ChatMsgType::BY_OTHER);
- }
- }
- else if (attacker == localPlayer && (amount != 0))
- {
- ChatWindow::battleChatLog(strprintf("%s : You hit %s -%d",
- attacker->mName.c_str(),
- mName.c_str(),
- amount),
- ChatMsgType::BY_PLAYER);
- }
- }
- if (font != nullptr && particleEngine != nullptr)
- {
- const std::string damage = amount != 0 ? toString(amount) :
- // TRANSLATORS: dodge or miss message in attacks
- type == AttackType::FLEE ? _("dodge") : _("miss");
- // Show damage number
- particleEngine->addTextSplashEffect(damage,
- mPixelX,
- mPixelY - 16,
- color,
- font,
- true);
- }
- BLOCK_END("Being::takeDamage1")
- BLOCK_START("Being::takeDamage2")
-
- if (type != AttackType::SKILL)
- attacker->updateHit(amount);
-
- if (amount > 0)
- {
- if ((localPlayer != nullptr) && localPlayer == this)
- localPlayer->setLastHitFrom(attacker->mName);
-
- mDamageTaken += amount;
- if (mInfo != nullptr)
- {
- playSfx(mInfo->getSound(ItemSoundEvent::HURT),
- this,
- false,
- mX,
- mY);
-
- if (!mInfo->isStaticMaxHP())
- {
- if ((mHP == 0) && mInfo->getMaxHP() < mDamageTaken)
- mInfo->setMaxHP(mDamageTaken);
- }
- }
- if ((mHP != 0) && isAlive())
- {
- mHP -= amount;
- if (mHP < 0)
- mHP = 0;
- }
-
- if (mType == ActorType::Monster)
- {
- updatePercentHP();
- updateName();
- }
- else if (mType == ActorType::Player &&
- (socialWindow != nullptr) &&
- !mName.empty())
- {
- socialWindow->updateAvatar(mName);
- }
-
- if (effectManager != nullptr)
- {
- const int hitEffectId = getHitEffect(attacker,
- type,
- attackId,
- level);
- if (hitEffectId >= 0)
- effectManager->trigger(hitEffectId, this);
- }
- }
- else
- {
- if (effectManager != nullptr)
- {
- int hitEffectId = -1;
- if (type == AttackType::SKILL)
- {
- hitEffectId = getHitEffect(attacker,
- AttackType::SKILLMISS,
- attackId,
- level);
- }
- else
- {
- hitEffectId = getHitEffect(attacker,
- AttackType::MISS,
- attackId,
- level);
- }
- if (hitEffectId >= 0)
- effectManager->trigger(hitEffectId, this);
- }
- }
- BLOCK_END("Being::takeDamage2")
-}
-
-int Being::getHitEffect(const Being *restrict const attacker,
- const AttackTypeT type,
- const int attackId,
- const int level) const restrict2
-{
- if (effectManager == nullptr)
- return 0;
-
- BLOCK_START("Being::getHitEffect")
- // Init the particle effect path based on current
- // weapon or default.
- int hitEffectId = 0;
- if (type == AttackType::SKILL || type == AttackType::SKILLMISS)
- {
- const SkillData *restrict const data =
- skillDialog->getSkillDataByLevel(attackId, level);
- if (data == nullptr)
- return -1;
- if (type == AttackType::SKILL)
- {
- hitEffectId = data->hitEffectId;
- if (hitEffectId == -1)
- hitEffectId = paths.getIntValue("skillHitEffectId");
- }
- else
- {
- hitEffectId = data->missEffectId;
- if (hitEffectId == -1)
- hitEffectId = paths.getIntValue("skillMissEffectId");
- }
- }
- else
- {
- if (attacker != nullptr)
- {
- const ItemInfo *restrict const attackerWeapon
- = attacker->getEquippedWeapon();
- if (attackerWeapon != nullptr &&
- attacker->getType() == ActorType::Player)
- {
- if (type == AttackType::MISS)
- hitEffectId = attackerWeapon->getMissEffectId();
- else if (type != AttackType::CRITICAL)
- hitEffectId = attackerWeapon->getHitEffectId();
- else
- hitEffectId = attackerWeapon->getCriticalHitEffectId();
- }
- else if (attacker->getType() == ActorType::Monster)
- {
- const BeingInfo *restrict const info = attacker->getInfo();
- if (info != nullptr)
- {
- const Attack *restrict const atk =
- info->getAttack(attackId);
- if (atk != nullptr)
- {
- if (type == AttackType::MISS)
- hitEffectId = atk->mMissEffectId;
- else if (type != AttackType::CRITICAL)
- hitEffectId = atk->mHitEffectId;
- else
- hitEffectId = atk->mCriticalHitEffectId;
- }
- else
- {
- hitEffectId = getDefaultEffectId(type);
- }
- }
- }
- else
- {
- hitEffectId = getDefaultEffectId(type);
- }
- }
- else
- {
- hitEffectId = getDefaultEffectId(type);
- }
- }
- BLOCK_END("Being::getHitEffect")
- return hitEffectId;
-}
-
-int Being::getDefaultEffectId(const AttackTypeT &restrict type)
-{
- if (type == AttackType::MISS)
- return paths.getIntValue("missEffectId");
- else if (type != AttackType::CRITICAL)
- return paths.getIntValue("hitEffectId");
- else
- return paths.getIntValue("criticalHitEffectId");
-}
-
-void Being::handleAttack(Being *restrict const victim,
- const int damage,
- const int attackId) restrict2
-{
- if ((victim == nullptr) || (mInfo == nullptr))
- return;
-
- BLOCK_START("Being::handleAttack")
-
- if (this != localPlayer)
- setAction(BeingAction::ATTACK, attackId);
-
- mLastAttackX = victim->mX;
- mLastAttackY = victim->mY;
-
- if (mType == ActorType::Player && (mEquippedWeapon != nullptr))
- fireMissile(victim, mEquippedWeapon->getMissileConst());
- else if (mInfo->getAttack(attackId) != nullptr)
- fireMissile(victim, mInfo->getAttack(attackId)->mMissile);
-
- reset();
- mActionTime = tick_time;
-
- if (Net::getNetworkType() == ServerType::TMWATHENA &&
- this != localPlayer)
- {
- const uint8_t dir = calcDirection(victim->mX,
- victim->mY);
- if (dir != 0u)
- setDirection(dir);
- }
-
- if ((damage != 0) && victim->mType == ActorType::Player
- && victim->mAction == BeingAction::SIT)
- {
- victim->setAction(BeingAction::STAND, 0);
- }
-
- if (mType == ActorType::Player)
- {
- if (mSlots.size() >= 10)
- {
- // here 10 is weapon slot
- int weaponId = mSlots[10].spriteId;
- if (weaponId == 0)
- weaponId = -100 - toInt(mSubType, int);
- const ItemInfo &info = ItemDB::get(weaponId);
- playSfx(info.getSound(
- (damage > 0) ? ItemSoundEvent::HIT : ItemSoundEvent::MISS),
- victim,
- true,
- mX, mY);
- }
- }
- else
- {
- playSfx(mInfo->getSound((damage > 0) ?
- ItemSoundEvent::HIT : ItemSoundEvent::MISS), victim, true, mX, mY);
- }
- BLOCK_END("Being::handleAttack")
-}
-
-void Being::handleSkillCasting(Being *restrict const victim,
- const int skillId,
- const int skillLevel) restrict2
-{
- if ((victim == nullptr) || (mInfo == nullptr) || (skillDialog == nullptr))
- return;
-
- setAction(BeingAction::CAST, skillId);
-
- const SkillData *restrict const data = skillDialog->getSkillDataByLevel(
- skillId,
- skillLevel);
-
- if (data != nullptr)
- {
- effectManager->triggerDefault(data->castingSrcEffectId,
- this,
- paths.getIntValue("skillCastingSrcEffectId"));
- effectManager->triggerDefault(data->castingDstEffectId,
- victim,
- paths.getIntValue("skillCastingDstEffectId"));
- fireMissile(victim, data->castingMissile);
- }
-}
-
-void Being::handleSkill(Being *restrict const victim,
- const int damage,
- const int skillId,
- const int skillLevel) restrict2
-{
- if ((victim == nullptr) || (mInfo == nullptr) || (skillDialog == nullptr))
- return;
-
- const SkillInfo *restrict const skill = skillDialog->getSkill(skillId);
- const SkillData *restrict const data = skill != nullptr
- ? skill->getData1(skillLevel) : nullptr;
- if (data != nullptr)
- {
- effectManager->triggerDefault(data->srcEffectId,
- this,
- paths.getIntValue("skillSrcEffectId"));
- effectManager->triggerDefault(data->dstEffectId,
- victim,
- paths.getIntValue("skillDstEffectId"));
- fireMissile(victim, data->missile);
- }
-
- if (this != localPlayer && (skill != nullptr))
- {
- const SkillType::SkillType type = skill->type;
- if ((type & SkillType::Attack) != 0 ||
- (type & SkillType::Ground) != 0)
- {
- setAction(BeingAction::ATTACK, 1);
- }
- else
- {
- setAction(BeingAction::STAND, 1);
- }
- }
-
- reset();
- mActionTime = tick_time;
-
- if (Net::getNetworkType() == ServerType::TMWATHENA &&
- this != localPlayer)
- {
- const uint8_t dir = calcDirection(victim->mX,
- victim->mY);
- if (dir != 0u)
- setDirection(dir);
- }
- if ((damage != 0) && victim->mType == ActorType::Player
- && victim->mAction == BeingAction::SIT)
- {
- victim->setAction(BeingAction::STAND, 0);
- }
- if (data != nullptr)
- {
- if (damage > 0)
- playSfx(data->soundHit, victim, true, mX, mY);
- else
- playSfx(data->soundMiss, victim, true, mX, mY);
- }
- else
- {
- playSfx(mInfo->getSound((damage > 0) ?
- ItemSoundEvent::HIT : ItemSoundEvent::MISS),
- victim,
- true,
- mX, mY);
- }
-}
-
-void Being::showNameBadge(const bool show) restrict2
-{
- delete2(mBadges[BadgeIndex::Name]);
- if (show &&
- !mName.empty() &&
- mShowBadges != BadgeDrawType::Hide)
- {
- const std::string badge = BadgesDB::getNameBadge(mName);
- if (!badge.empty())
- {
- mBadges[BadgeIndex::Name] = AnimatedSprite::load(
- paths.getStringValue("badges") + badge);
- }
- }
-}
-
-void Being::setName(const std::string &restrict name) restrict2
-{
- mExtName = name;
- if (mType == ActorType::Npc)
- {
- mName = name.substr(0, name.find('#', 0));
- showName();
- }
- else if (mType == ActorType::Player)
- {
- if (mName != name)
- {
- mName = name;
- showNameBadge(!mName.empty());
- }
- if (getShowName())
- showName();
- }
- else
- {
- if (mType == ActorType::Portal)
- mName = name.substr(0, name.find('#', 0));
- else
- mName = name;
-
- if (getShowName())
- showName();
- }
-}
-
-void Being::setShowName(const bool doShowName) restrict2
-{
- if (mShowName == doShowName)
- return;
-
- mShowName = doShowName;
-
- if (doShowName)
- showName();
- else
- delete2(mDispName)
-}
-
-void Being::showGuildBadge(const bool show) restrict2
-{
- delete2(mBadges[BadgeIndex::Guild]);
- if (show &&
- !mGuildName.empty() &&
- mShowBadges != BadgeDrawType::Hide)
- {
- const std::string badge = BadgesDB::getGuildBadge(mGuildName);
- if (!badge.empty())
- {
- mBadges[BadgeIndex::Guild] = AnimatedSprite::load(
- paths.getStringValue("badges") + badge);
- }
- }
-}
-
-void Being::setGuildName(const std::string &restrict name) restrict2
-{
- if (mGuildName != name)
- {
- mGuildName = name;
- showGuildBadge(!mGuildName.empty());
- updateBadgesCount();
- }
-}
-
-void Being::setGuildPos(const std::string &restrict pos A_UNUSED) restrict2
-{
-}
-
-void Being::addGuild(Guild *restrict const guild) restrict2
-{
- if (guild == nullptr)
- return;
-
- mGuilds[guild->getId()] = guild;
-
- if (this == localPlayer && (socialWindow != nullptr))
- socialWindow->addTab(guild);
-}
-
-void Being::removeGuild(const int id) restrict2
-{
- if (this == localPlayer && (socialWindow != nullptr))
- socialWindow->removeTab(mGuilds[id]);
-
- if (mGuilds[id] != nullptr)
- mGuilds[id]->removeMember(mName);
- mGuilds.erase(id);
-}
-
-const Guild *Being::getGuild(const std::string &restrict guildName) const
- restrict2
-{
- FOR_EACH (GuildsMapCIter, itr, mGuilds)
- {
- const Guild *restrict const guild = itr->second;
- if ((guild != nullptr) && guild->getName() == guildName)
- return guild;
- }
-
- return nullptr;
-}
-
-const Guild *Being::getGuild(const int id) const restrict2
-{
- const std::map<int, Guild*>::const_iterator itr = mGuilds.find(id);
- if (itr != mGuilds.end())
- return itr->second;
-
- return nullptr;
-}
-
-Guild *Being::getGuild() const restrict2
-{
- const std::map<int, Guild*>::const_iterator itr = mGuilds.begin();
- if (itr != mGuilds.end())
- return itr->second;
-
- return nullptr;
-}
-
-void Being::clearGuilds() restrict2
-{
- FOR_EACH (GuildsMapCIter, itr, mGuilds)
- {
- Guild *const guild = itr->second;
-
- if (guild != nullptr)
- {
- if (this == localPlayer && (socialWindow != nullptr))
- socialWindow->removeTab(guild);
-
- guild->removeMember(mId);
- }
- }
-
- mGuilds.clear();
-}
-
-void Being::setParty(Party *restrict const party) restrict2
-{
- if (party == mParty)
- return;
-
- Party *const old = mParty;
- mParty = party;
-
- if (old != nullptr)
- old->removeMember(mId);
-
- if (party != nullptr)
- party->addMember(mId, mName);
-
- updateColors();
-
- if (this == localPlayer && (socialWindow != nullptr))
- {
- if (old != nullptr)
- socialWindow->removeTab(old);
-
- if (party != nullptr)
- socialWindow->addTab(party);
- }
-}
-
-void Being::updateGuild() restrict2
-{
- if (localPlayer == nullptr)
- return;
-
- Guild *restrict const guild = localPlayer->getGuild();
- if (guild == nullptr)
- {
- clearGuilds();
- updateColors();
- return;
- }
- if (guild->getMember(mName) != nullptr)
- {
- setGuild(guild);
- if (!guild->getName().empty())
- setGuildName(guild->getName());
- }
- updateColors();
-}
-
-void Being::setGuild(Guild *restrict const guild) restrict2
-{
- Guild *restrict const old = getGuild();
- if (guild == old)
- return;
-
- clearGuilds();
- addGuild(guild);
-
- if (old != nullptr)
- old->removeMember(mName);
-
- updateColors();
-
- if (this == localPlayer && (socialWindow != nullptr))
- {
- if (old != nullptr)
- socialWindow->removeTab(old);
-
- if (guild != nullptr)
- socialWindow->addTab(guild);
- }
-}
-
-void Being::fireMissile(Being *restrict const victim,
- const MissileInfo &restrict missile) const restrict2
-{
- BLOCK_START("Being::fireMissile")
-
- if (victim == nullptr ||
- missile.particle.empty() ||
- particleEngine == nullptr)
- {
- BLOCK_END("Being::fireMissile")
- return;
- }
-
- Particle *restrict const target = particleEngine->createChild();
-
- if (target == nullptr)
- {
- BLOCK_END("Being::fireMissile")
- return;
- }
-
- Particle *restrict const missileParticle = target->addEffect(
- missile.particle,
- mPixelX,
- mPixelY);
-
- target->moveBy(Vector(0.0F, 0.0F, missile.z));
- target->setLifetime(missile.lifeTime);
- victim->controlAutoParticle(target);
-
- if (missileParticle != nullptr)
- {
- missileParticle->setDestination(target, missile.speed, 0.0F);
- missileParticle->setDieDistance(missile.dieDistance);
- missileParticle->setLifetime(missile.lifeTime);
- }
- BLOCK_END("Being::fireMissile")
-}
-
-std::string Being::getSitAction() const restrict2
-{
- if (mHorseId != 0)
- return SpriteAction::SITRIDE;
- if (mMap != nullptr)
- {
- const unsigned char mask = mMap->getBlockMask(mX, mY);
- if ((mask & BlockMask::GROUNDTOP) != 0)
- return SpriteAction::SITTOP;
- else if ((mask & BlockMask::AIR) != 0)
- return SpriteAction::SITSKY;
- else if ((mask & BlockMask::WATER) != 0)
- return SpriteAction::SITWATER;
- }
- return SpriteAction::SIT;
-}
-
-
-std::string Being::getMoveAction() const restrict2
-{
- if (mHorseId != 0)
- return SpriteAction::RIDE;
- if (mMap != nullptr)
- {
- const unsigned char mask = mMap->getBlockMask(mX, mY);
- if ((mask & BlockMask::AIR) != 0)
- return SpriteAction::FLY;
- else if ((mask & BlockMask::WATER) != 0)
- return SpriteAction::SWIM;
- }
- return SpriteAction::MOVE;
-}
-
-std::string Being::getWeaponAttackAction(const ItemInfo *restrict const weapon)
- const restrict2
-{
- if (weapon == nullptr)
- return getAttackAction();
-
- if (mHorseId != 0)
- return weapon->getRideAttackAction();
- if (mMap != nullptr)
- {
- const unsigned char mask = mMap->getBlockMask(mX, mY);
- if ((mask & BlockMask::AIR) != 0)
- return weapon->getSkyAttackAction();
- else if ((mask & BlockMask::WATER) != 0)
- return weapon->getWaterAttackAction();
- }
- return weapon->getAttackAction();
-}
-
-std::string Being::getAttackAction(const Attack *restrict const attack1) const
- restrict2
-{
- if (attack1 == nullptr)
- return getAttackAction();
-
- if (mHorseId != 0)
- return attack1->mRideAction;
- if (mMap != nullptr)
- {
- const unsigned char mask = mMap->getBlockMask(mX, mY);
- if ((mask & BlockMask::AIR) != 0)
- return attack1->mSkyAction;
- else if ((mask & BlockMask::WATER) != 0)
- return attack1->mWaterAction;
- }
- return attack1->mAction;
-}
-
-std::string Being::getCastAction(const SkillInfo *restrict const skill) const
- restrict2
-{
- if (skill == nullptr)
- return getCastAction();
-
- if (mHorseId != 0)
- return skill->castingRideAction;
- if (mMap != nullptr)
- {
- const unsigned char mask = mMap->getBlockMask(mX, mY);
- if ((mask & BlockMask::AIR) != 0)
- return skill->castingSkyAction;
- else if ((mask & BlockMask::WATER) != 0)
- return skill->castingWaterAction;
- }
- return skill->castingAction;
-}
-
-#define getSpriteAction(func, action) \
- std::string Being::get##func##Action() const restrict2\
-{ \
- if (mHorseId != 0) \
- return SpriteAction::action##RIDE; \
- if (mMap) \
- { \
- const unsigned char mask = mMap->getBlockMask(mX, mY); \
- if (mask & BlockMask::AIR) \
- return SpriteAction::action##SKY; \
- else if (mask & BlockMask::WATER) \
- return SpriteAction::action##WATER; \
- } \
- return SpriteAction::action; \
-}
-
-getSpriteAction(Attack, ATTACK)
-getSpriteAction(Cast, CAST)
-getSpriteAction(Dead, DEAD)
-getSpriteAction(Spawn, SPAWN)
-
-std::string Being::getStandAction() const restrict2
-{
- if (mHorseId != 0)
- return SpriteAction::STANDRIDE;
- if (mMap != nullptr)
- {
- const unsigned char mask = mMap->getBlockMask(mX, mY);
- if (mTrickDead)
- {
- if ((mask & BlockMask::AIR) != 0)
- return SpriteAction::DEADSKY;
- else if ((mask & BlockMask::WATER) != 0)
- return SpriteAction::DEADWATER;
- else
- return SpriteAction::DEAD;
- }
- if ((mask & BlockMask::AIR) != 0)
- return SpriteAction::STANDSKY;
- else if ((mask & BlockMask::WATER) != 0)
- return SpriteAction::STANDWATER;
- }
- return SpriteAction::STAND;
-}
-
-void Being::setAction(const BeingActionT &restrict action,
- const int attackId) restrict2
-{
- std::string currentAction = SpriteAction::INVALID;
-
- switch (action)
- {
- case BeingAction::MOVE:
- if (mInfo != nullptr)
- {
- playSfx(mInfo->getSound(
- ItemSoundEvent::MOVE), nullptr, true, mX, mY);
- }
- currentAction = getMoveAction();
- // Note: When adding a run action,
- // Differentiate walk and run with action name,
- // while using only the ACTION_MOVE.
- break;
- case BeingAction::SIT:
- currentAction = getSitAction();
- if (mInfo != nullptr)
- {
- ItemSoundEvent::Type event;
- if (currentAction == SpriteAction::SITTOP)
- event = ItemSoundEvent::SITTOP;
- else
- event = ItemSoundEvent::SIT;
- playSfx(mInfo->getSound(event), nullptr, true, mX, mY);
- }
- break;
- case BeingAction::ATTACK:
- if (mEquippedWeapon != nullptr)
- {
- currentAction = getWeaponAttackAction(mEquippedWeapon);
- reset();
- }
- else
- {
- if (mInfo == nullptr || mInfo->getAttack(attackId) == nullptr)
- break;
-
- currentAction = getAttackAction(mInfo->getAttack(attackId));
- reset();
-
- // attack particle effect
- if (ParticleEngine::enabled && (effectManager != nullptr))
- {
- const int effectId = mInfo->getAttack(attackId)->mEffectId;
- if (effectId >= 0)
- {
- effectManager->triggerDirection(effectId,
- this,
- mSpriteDirection);
- }
- }
- }
- break;
- case BeingAction::CAST:
- if (skillDialog != nullptr)
- {
- const SkillInfo *restrict const info =
- skillDialog->getSkill(attackId);
- currentAction = getCastAction(info);
- }
- break;
- case BeingAction::HURT:
- if (mInfo != nullptr)
- {
- playSfx(mInfo->getSound(ItemSoundEvent::HURT),
- this, false, mX, mY);
- }
- break;
- case BeingAction::DEAD:
- currentAction = getDeadAction();
- if (mInfo != nullptr)
- {
- playSfx(mInfo->getSound(ItemSoundEvent::DIE),
- this,
- false,
- mX, mY);
- if (mType == ActorType::Monster ||
- mType == ActorType::Npc ||
- mType == ActorType::SkillUnit)
- {
- mYDiff = mInfo->getDeadSortOffsetY();
- }
- }
- break;
- case BeingAction::STAND:
- currentAction = getStandAction();
- break;
- case BeingAction::SPAWN:
- if (mInfo != nullptr)
- {
- playSfx(mInfo->getSound(ItemSoundEvent::SPAWN),
- nullptr, true, mX, mY);
- }
- currentAction = getSpawnAction();
- break;
- case BeingAction::PRESTAND:
- break;
- default:
- logger->log("Being::setAction unknown action: "
- + toString(CAST_U32(action)));
- break;
- }
-
- if (currentAction != SpriteAction::INVALID)
- {
- mSpriteAction = currentAction;
- play(currentAction);
- if (mEmotionSprite != nullptr)
- mEmotionSprite->play(currentAction);
- if (mAnimationEffect != nullptr)
- mAnimationEffect->play(currentAction);
- for_each_badges()
- {
- AnimatedSprite *const sprite = mBadges[f];
- if (sprite != nullptr)
- sprite->play(currentAction);
- }
- for_each_horses(mDownHorseSprites)
- (*it)->play(currentAction);
- for_each_horses(mUpHorseSprites)
- (*it)->play(currentAction);
- mAction = action;
- }
-
- if (currentAction != SpriteAction::MOVE
- && currentAction != SpriteAction::FLY
- && currentAction != SpriteAction::SWIM)
- {
- mActionTime = tick_time;
- }
-}
-
-void Being::setDirection(const uint8_t direction) restrict2
-{
- if (mDirection == direction)
- return;
-
- mDirection = direction;
-
- mDirectionDelayed = 0;
-
- // if the direction does not change much, keep the common component
- int mFaceDirection = mDirection & direction;
- if (mFaceDirection == 0)
- mFaceDirection = direction;
-
- SpriteDirection::Type dir;
- if ((mFaceDirection & BeingDirection::UP) != 0)
- {
- if ((mFaceDirection & BeingDirection::LEFT) != 0)
- dir = SpriteDirection::UPLEFT;
- else if ((mFaceDirection & BeingDirection::RIGHT) != 0)
- dir = SpriteDirection::UPRIGHT;
- else
- dir = SpriteDirection::UP;
- }
- else if ((mFaceDirection & BeingDirection::DOWN) != 0)
- {
- if ((mFaceDirection & BeingDirection::LEFT) != 0)
- dir = SpriteDirection::DOWNLEFT;
- else if ((mFaceDirection & BeingDirection::RIGHT) != 0)
- dir = SpriteDirection::DOWNRIGHT;
- else
- dir = SpriteDirection::DOWN;
- }
- else if ((mFaceDirection & BeingDirection::RIGHT) != 0)
- {
- dir = SpriteDirection::RIGHT;
- }
- else
- {
- dir = SpriteDirection::LEFT;
- }
- mSpriteDirection = dir;
-
- CompoundSprite::setSpriteDirection(dir);
- if (mEmotionSprite != nullptr)
- mEmotionSprite->setSpriteDirection(dir);
- if (mAnimationEffect != nullptr)
- mAnimationEffect->setSpriteDirection(dir);
-
- for_each_badges()
- {
- AnimatedSprite *const sprite = mBadges[f];
- if (sprite != nullptr)
- sprite->setSpriteDirection(dir);
- }
-
- for_each_horses(mDownHorseSprites)
- (*it)->setSpriteDirection(dir);
- for_each_horses(mUpHorseSprites)
- (*it)->setSpriteDirection(dir);
- recalcSpritesOrder();
-}
-
-uint8_t Being::calcDirection() const restrict2
-{
- uint8_t dir = 0;
- if (mDest.x > mX)
- dir |= BeingDirection::RIGHT;
- else if (mDest.x < mX)
- dir |= BeingDirection::LEFT;
- if (mDest.y > mY)
- dir |= BeingDirection::DOWN;
- else if (mDest.y < mY)
- dir |= BeingDirection::UP;
- return dir;
-}
-
-uint8_t Being::calcDirection(const int dstX,
- const int dstY) const restrict2
-{
- uint8_t dir = 0;
- if (dstX > mX)
- dir |= BeingDirection::RIGHT;
- else if (dstX < mX)
- dir |= BeingDirection::LEFT;
- if (dstY > mY)
- dir |= BeingDirection::DOWN;
- else if (dstY < mY)
- dir |= BeingDirection::UP;
- return dir;
-}
-
-void Being::nextTile() restrict2
-{
- if (mPath.empty())
- {
- mAction = BeingAction::PRESTAND;
- mPreStandTime = tick_time;
- return;
- }
-
- const Position pos = mPath.front();
- mPath.pop_front();
-
- const uint8_t dir = calcDirection(pos.x, pos.y);
- if (dir != 0u)
- setDirection(dir);
-
- if (mMap == nullptr ||
- !mMap->getWalk(pos.x, pos.y, getBlockWalkMask()))
- {
- setAction(BeingAction::STAND, 0);
- return;
- }
-
- mActionTime += mSpeed / 10;
- if ((mType != ActorType::Player || mUseDiagonal)
- && mX != pos.x && mY != pos.y)
- {
- mSpeed = mWalkSpeed * 14 / 10;
- }
- else
- {
- mSpeed = mWalkSpeed;
- }
-
- if (mX != pos.x || mY != pos.y)
- {
- mOldHeight = mMap->getHeightOffset(mX, mY);
- if (mReachable == Reachable::REACH_NO &&
- mMap->getBlockMask(mX, mY) != mMap->getBlockMask(pos.x, pos.y))
- {
- mReachable = Reachable::REACH_UNKNOWN;
- }
- }
- mX = pos.x;
- mY = pos.y;
- const uint8_t height = mMap->getHeightOffset(mX, mY);
- mPixelOffsetY = height - mOldHeight;
- mFixedOffsetY = height;
- mNeedPosUpdate = true;
- setAction(BeingAction::MOVE, 0);
-}
-
-void Being::logic() restrict2
-{
- BLOCK_START("Being::logic")
- if (A_UNLIKELY(mSpeechTime != 0))
- {
- mSpeechTime--;
- if (mSpeechTime == 0 && mText != nullptr)
- delete2(mText)
- }
-
- if (A_UNLIKELY(mOwner != nullptr))
- {
- if (mType == ActorType::Homunculus ||
- mType == ActorType::Mercenary)
- {
- botLogic();
- }
- }
-
- const int time = tick_time * MILLISECONDS_IN_A_TICK;
- if (mEmotionSprite != nullptr)
- mEmotionSprite->update(time);
- for_each_horses(mDownHorseSprites)
- (*it)->update(time);
- for_each_horses(mUpHorseSprites)
- (*it)->update(time);
-
- if (A_UNLIKELY(mCastEndTime != 0 && mCastEndTime < tick_time))
- {
- mCastEndTime = 0;
- delete2(mCastingEffect);
- }
-
- if (A_UNLIKELY(mAnimationEffect))
- {
- mAnimationEffect->update(time);
- if (mAnimationEffect->isTerminated())
- delete2(mAnimationEffect)
- }
- if (A_UNLIKELY(mCastingEffect))
- {
- mCastingEffect->update(time);
- if (mCastingEffect->isTerminated())
- delete2(mCastingEffect)
- }
- for_each_badges()
- {
- AnimatedSprite *restrict const sprite = mBadges[f];
- if (sprite != nullptr)
- sprite->update(time);
- }
-
- int frameCount = CAST_S32(getFrameCount());
-
- switch (mAction)
- {
- case BeingAction::STAND:
- case BeingAction::SIT:
- case BeingAction::DEAD:
- case BeingAction::HURT:
- case BeingAction::SPAWN:
- case BeingAction::CAST:
- default:
- break;
-
- case BeingAction::MOVE:
- {
- if (get_elapsed_time(mActionTime) >= mSpeed)
- nextTile();
- break;
- }
-
- case BeingAction::ATTACK:
- {
- if (mActionTime == 0)
- break;
-
- int curFrame = 0;
- if (mAttackSpeed != 0)
- {
- curFrame = (get_elapsed_time(mActionTime) * frameCount)
- / mAttackSpeed;
- }
-
- if (this == localPlayer && curFrame >= frameCount)
- nextTile();
-
- break;
- }
-
- case BeingAction::PRESTAND:
- {
- if (get_elapsed_time1(mPreStandTime) > 10)
- setAction(BeingAction::STAND, 0);
- break;
- }
- }
-
- if (mAction == BeingAction::MOVE || mNeedPosUpdate)
- {
- const int xOffset = getOffset<BeingDirection::LEFT,
- BeingDirection::RIGHT>();
- const int yOffset = getOffset<BeingDirection::UP,
- BeingDirection::DOWN>();
- int offset = xOffset;
- if (offset == 0)
- offset = yOffset;
-
- if ((xOffset == 0) && (yOffset == 0))
- mNeedPosUpdate = false;
-
- const int halfTile = mapTileSize / 2;
- const float offset2 = static_cast<float>(
- mPixelOffsetY * abs(offset)) / 2;
-// mSortOffsetY = (mOldHeight - mFixedOffsetY + mPixelOffsetY)
-// * halfTile - offset2;
- mSortOffsetY = 0;
- const float yOffset3 = (mY + 1) * mapTileSize + yOffset
- - (mOldHeight + mPixelOffsetY) * halfTile + offset2;
-
- // Update pixel coordinates
- setPixelPositionF(static_cast<float>(mX * mapTileSize
- + mapTileSize / 2 + xOffset), yOffset3);
- }
-
- if (A_UNLIKELY(mEmotionSprite))
- {
- mEmotionTime--;
- if (mEmotionTime == 0)
- delete2(mEmotionSprite)
- }
-
- ActorSprite::logic();
-
- if (frameCount < 10)
- frameCount = 10;
-
- if (A_UNLIKELY(!isAlive() &&
- mSpeed != 0 &&
- gameHandler->removeDeadBeings() &&
- get_elapsed_time(mActionTime) / mSpeed >= frameCount))
- {
- if (mType != ActorType::Player && (actorManager != nullptr))
- actorManager->destroy(this);
- }
-
- const SoundInfo *restrict const sound = mNextSound.sound;
- if (A_UNLIKELY(sound))
- {
- const int time2 = tick_time;
- if (time2 > mNextSound.time)
- {
- soundManager.playSfx(sound->sound, mNextSound.x, mNextSound.y);
-
- mNextSound.sound = nullptr;
- mNextSound.time = time2 + sound->delay;
- }
- }
-
- BLOCK_END("Being::logic")
-}
-
-void Being::botLogic() restrict2
-{
- if ((mOwner == nullptr) || (mMap == nullptr) || (mInfo == nullptr))
- return;
-
- const int time = tick_time;
- const int thinkTime = mInfo->getThinkTime();
- if (abs(CAST_S32(mMoveTime) - time) < thinkTime)
- return;
-
- mMoveTime = time;
-
- int dstX = mOwner->mX;
- int dstY = mOwner->mY;
- const int warpDist = mInfo->getWarpDist();
- const int divX = abs(dstX - mX);
- const int divY = abs(dstY - mY);
-
- if (divX >= warpDist || divY >= warpDist)
- {
- if (mType == ActorType::Homunculus)
- homunculusHandler->moveToMaster();
- else
- mercenaryHandler->moveToMaster();
- mBotAi = true;
- return;
- }
- if (!mBotAi)
- return;
- if (mAction == BeingAction::MOVE)
- {
- if (mOwner->mAction == BeingAction::MOVE)
- {
- updateBotFollow(dstX, dstY,
- divX, divY);
- }
- return;
- }
-
- switch (mOwner->mAction)
- {
- case BeingAction::MOVE:
- case BeingAction::PRESTAND:
- updateBotFollow(dstX, dstY,
- divX, divY);
- break;
- case BeingAction::STAND:
- case BeingAction::SPAWN:
- botFixOffset(dstX, dstY);
- moveBotTo(dstX, dstY);
- break;
- case BeingAction::ATTACK:
- {
- const Being *const target = localPlayer->getTarget();
- if (target == nullptr)
- return;
- const BeingId targetId = target->getId();
- if (mType == ActorType::Homunculus)
- {
- homunculusHandler->attack(targetId,
- Keep_true);
- }
- else
- {
- mercenaryHandler->attack(targetId,
- Keep_true);
- }
- break;
- }
- case BeingAction::SIT:
- botFixOffset(dstX, dstY);
- moveBotTo(dstX, dstY);
- break;
- case BeingAction::DEAD:
- botFixOffset(dstX, dstY);
- moveBotTo(dstX, dstY);
- break;
- case BeingAction::CAST:
- case BeingAction::HURT:
- default:
- break;
- }
-}
-
-void Being::botFixOffset(int &restrict dstX,
- int &restrict dstY) const
-{
- if ((mInfo == nullptr) || (mOwner == nullptr))
- return;
-
- int offsetX1;
- int offsetY1;
- switch (mOwner->getCurrentAction())
- {
- case BeingAction::SIT:
- offsetX1 = mInfo->getSitOffsetX();
- offsetY1 = mInfo->getSitOffsetY();
- break;
-
- case BeingAction::MOVE:
- offsetX1 = mInfo->getMoveOffsetX();
- offsetY1 = mInfo->getMoveOffsetY();
- break;
-
- case BeingAction::DEAD:
- offsetX1 = mInfo->getDeadOffsetX();
- offsetY1 = mInfo->getDeadOffsetY();
- break;
-
- case BeingAction::ATTACK:
- offsetX1 = mInfo->getAttackOffsetX();
- offsetY1 = mInfo->getAttackOffsetY();
- break;
-
- case BeingAction::SPAWN:
- case BeingAction::HURT:
- case BeingAction::STAND:
- case BeingAction::PRESTAND:
- case BeingAction::CAST:
- default:
- offsetX1 = mInfo->getTargetOffsetX();
- offsetY1 = mInfo->getTargetOffsetY();
- break;
- }
-
- int offsetX = offsetX1;
- int offsetY = offsetY1;
- switch (mOwner->mDirection)
- {
- case BeingDirection::LEFT:
- offsetX = -offsetY1;
- offsetY = offsetX1;
- break;
- case BeingDirection::RIGHT:
- offsetX = offsetY1;
- offsetY = -offsetX1;
- break;
- case BeingDirection::UP:
- offsetY = -offsetY;
- offsetX = -offsetX;
- break;
- default:
- case BeingDirection::DOWN:
- break;
- }
- dstX += offsetX;
- dstY += offsetY;
- if (mMap != nullptr)
- {
- if (!mMap->getWalk(dstX, dstY, getBlockWalkMask()))
- {
- dstX = mOwner->mX;
- dstY = mOwner->mY;
- }
- }
-}
-
-void Being::updateBotFollow(int dstX,
- int dstY,
- const int divX,
- const int divY)
-{
- const int followDist = mInfo->getStartFollowDist();
- const int dist = mInfo->getFollowDist();
- if (divX > followDist || divY > followDist)
- {
- if (dist > 0)
- {
- if (divX > followDist)
- {
- if (dstX > mX + dist)
- dstX -= dist;
- else if (dstX + dist <= mX)
- dstX += dist;
- }
- else
- {
- dstX = mX;
- }
- if (divY > followDist)
- {
- if (dstY > mY + dist)
- dstY -= dist;
- else if (dstX + dist <= mX)
- dstY += dist;
- }
- else
- {
- dstY = mY;
- }
- }
- botFixOffset(dstX, dstY);
- moveBotTo(dstX, dstY);
- }
-}
-
-void Being::moveBotTo(int dstX,
- int dstY)
-{
- const int dstX0 = mOwner->mX;
- const int dstY0 = mOwner->mY;
- const unsigned char blockWalkMask = getBlockWalkMask();
- if (!mMap->getWalk(dstX, dstY, blockWalkMask))
- {
- if (dstX != dstX0)
- {
- dstX = dstX0;
- if (!mMap->getWalk(dstX, dstY, blockWalkMask))
- dstY = dstY0;
- }
- else if (dstY != dstY0)
- {
- dstY = dstY0;
- if (!mMap->getWalk(dstX, dstY, blockWalkMask))
- dstX = dstX0;
- }
- }
- if (mX != dstX || mY != dstY)
- {
- if (mType == ActorType::Homunculus)
- homunculusHandler->move(dstX, dstY);
- else
- mercenaryHandler->move(dstX, dstY);
- return;
- }
- updateBotDirection(dstX, dstY);
-}
-
-void Being::updateBotDirection(const int dstX,
- const int dstY)
-{
- int directionType = 0;
- switch (mOwner->getCurrentAction())
- {
- case BeingAction::STAND:
- case BeingAction::MOVE:
- case BeingAction::HURT:
- case BeingAction::SPAWN:
- case BeingAction::CAST:
- case BeingAction::PRESTAND:
- default:
- directionType = mInfo->getDirectionType();
- break;
- case BeingAction::SIT:
- directionType = mInfo->getSitDirectionType();
- break;
- case BeingAction::DEAD:
- directionType = mInfo->getDeadDirectionType();
- break;
- case BeingAction::ATTACK:
- directionType = mInfo->getAttackDirectionType();
- break;
- }
-
- uint8_t newDir = 0;
- switch (directionType)
- {
- case 0:
- default:
- return;
-
- case 1:
- newDir = mOwner->mDirection;
- break;
-
- case 2:
- {
- const int dstX0 = mOwner->mX;
- const int dstY0 = mOwner->mY;
- if (dstX > dstX0)
- newDir |= BeingDirection::LEFT;
- else if (dstX < dstX0)
- newDir |= BeingDirection::RIGHT;
- if (dstY > dstY0)
- newDir |= BeingDirection::UP;
- else if (dstY < dstY0)
- newDir |= BeingDirection::DOWN;
- break;
- }
- case 3:
- {
- const int dstX0 = mOwner->mX;
- const int dstY0 = mOwner->mY;
- if (dstX > dstX0)
- newDir |= BeingDirection::RIGHT;
- else if (dstX < dstX0)
- newDir |= BeingDirection::LEFT;
- if (dstY > dstY0)
- newDir |= BeingDirection::DOWN;
- else if (dstY < dstY0)
- newDir |= BeingDirection::UP;
- break;
- }
- case 4:
- {
- const int dstX2 = mOwner->getLastAttackX();
- const int dstY2 = mOwner->getLastAttackY();
- if (dstX > dstX2)
- newDir |= BeingDirection::LEFT;
- else if (dstX < dstX2)
- newDir |= BeingDirection::RIGHT;
- if (dstY > dstY2)
- newDir |= BeingDirection::UP;
- else if (dstY < dstY2)
- newDir |= BeingDirection::DOWN;
- break;
- }
- }
- if ((newDir != 0u) && newDir != mDirection)
- {
- if (mType == ActorType::Homunculus)
- homunculusHandler->setDirection(newDir);
- else
- mercenaryHandler->setDirection(newDir);
- }
-}
-
-void Being::updateBadgesPosition()
-{
- const int px = mPixelX - mapTileSize / 2;
- const int py = mPixelY - mapTileSize * 2 - mapTileSize;
- if (mShowBadges != BadgeDrawType::Hide &&
- mBadgesCount != 0u)
- {
- if (mDispName != nullptr &&
- gui != nullptr)
- {
- if (mShowBadges == BadgeDrawType::Right)
- {
- const Font *restrict const font = gui->getFont();
- mBadgesX = mDispName->getX() + mDispName->getWidth();
- mBadgesY = mDispName->getY() - font->getHeight();
- }
- else if (mShowBadges == BadgeDrawType::Bottom)
- {
- mBadgesX = px + 8 - mBadgesCount * 8;
- if (mVisibleNamePos == VisibleNamePos::Bottom)
- {
- mBadgesY = mDispName->getY();
- }
- else
- {
- mBadgesY = py + settings.playerNameOffset + 16;
- }
- }
- else
- {
- mBadgesX = px + 8 - mBadgesCount * 8;
- if (mVisibleNamePos == VisibleNamePos::Top)
- mBadgesY = py - mDispName->getHeight();
- else
- mBadgesY = py;
- }
- }
- else
- {
- if (mShowBadges == BadgeDrawType::Right)
- {
- mBadgesX = px + settings.playerBadgeAtRightOffset;
- mBadgesY = py;
- }
- else if (mShowBadges == BadgeDrawType::Bottom)
- {
- mBadgesX = px + 8 - mBadgesCount * 8;
- const int height = settings.playerNameOffset;
- if (mVisibleNamePos == VisibleNamePos::Bottom)
- mBadgesY = py + height;
- else
- mBadgesY = py + height + 16;
- }
- else
- {
- mBadgesX = px + 8 - mBadgesCount * 8;
- mBadgesY = py;
- }
- }
- }
-}
-
-void Being::drawEmotion(Graphics *restrict const graphics,
- const int offsetX,
- const int offsetY) const restrict2
-{
- if (mErased)
- return;
-
- const int px = mPixelX - offsetX - mapTileSize / 2;
- const int py = mPixelY - offsetY - mapTileSize * 2 - mapTileSize;
- if (mAnimationEffect != nullptr)
- mAnimationEffect->draw(graphics, px, py);
- if (mShowBadges != BadgeDrawType::Hide &&
- mBadgesCount != 0u)
- {
- int x = mBadgesX - offsetX;
- const int y = mBadgesY - offsetY;
- for_each_badges()
- {
- const AnimatedSprite *restrict const sprite = mBadges[f];
- if (sprite != nullptr)
- {
- sprite->draw(graphics, x, y);
- x += 16;
- }
- }
- }
- if (mEmotionSprite != nullptr)
- mEmotionSprite->draw(graphics, px, py);
-}
-
-void Being::drawSpeech(const int offsetX,
- const int offsetY) restrict2
-{
- if (mErased)
- return;
- if (mSpeech.empty())
- return;
-
- const int px = mPixelX - offsetX;
- const int py = mPixelY - offsetY;
- const int speech = mSpeechType;
-
- // Draw speech above this being
- if (mSpeechTime == 0)
- {
- if (mSpeechBubble != nullptr &&
- mSpeechBubble->mVisible == Visible_true)
- {
- mSpeechBubble->setVisible(Visible_false);
- }
- mSpeech.clear();
- }
- else if (mSpeechTime > 0 && (speech == BeingSpeech::NAME_IN_BUBBLE ||
- speech == BeingSpeech::NO_NAME_IN_BUBBLE))
- {
- delete2(mText)
-
- if (mSpeechBubble != nullptr)
- {
- mSpeechBubble->setPosition(px - (mSpeechBubble->getWidth() / 2),
- py - getHeight() - (mSpeechBubble->getHeight()));
- mSpeechBubble->setVisible(Visible_true);
- mSpeechBubble->requestMoveToBackground();
- }
- }
- else if (mSpeechTime > 0 && speech == BeingSpeech::TEXT_OVERHEAD)
- {
- if (mSpeechBubble != nullptr)
- mSpeechBubble->setVisible(Visible_false);
-
- if ((mText == nullptr) && (userPalette != nullptr))
- {
- mText = new Text(mSpeech,
- mPixelX,
- mPixelY - getHeight(),
- Graphics::CENTER,
- &theme->getColor(ThemeColorId::BUBBLE_TEXT, 255),
- Speech_true);
- mText->adviseXY(mPixelX,
- (mY + 1) * mapTileSize - getHeight() - mText->getHeight() - 9,
- mMoveNames);
- }
- }
- else if (speech == BeingSpeech::NO_SPEECH)
- {
- if (mSpeechBubble != nullptr)
- mSpeechBubble->setVisible(Visible_false);
- delete2(mText)
- }
-}
-
-template<signed char pos, signed char neg>
-int Being::getOffset() const restrict2
-{
- // Check whether we're walking in the requested direction
- if (mAction != BeingAction::MOVE || !(mDirection & (pos | neg)))
- return 0;
-
- int offset = 0;
-
- if (mMap && mSpeed)
- {
- const int time = get_elapsed_time(mActionTime);
- offset = (pos == BeingDirection::LEFT &&
- neg == BeingDirection::RIGHT) ?
- (time * mMap->getTileWidth() / mSpeed)
- : (time * mMap->getTileHeight() / mSpeed);
- }
-
- // We calculate the offset _from_ the _target_ location
- offset -= mapTileSize;
- if (offset > 0)
- offset = 0;
-
- // Going into negative direction? Invert the offset.
- if (mDirection & pos)
- offset = -offset;
-
- if (offset > mapTileSize)
- offset = mapTileSize;
- if (offset < -mapTileSize)
- offset = -mapTileSize;
-
- return offset;
-}
-
-void Being::updateCoords() restrict2
-{
- if (mDispName != nullptr)
- {
- int offsetX = mPixelX;
- int offsetY = mPixelY;
- if (mInfo != nullptr)
- {
- offsetX += mInfo->getNameOffsetX();
- offsetY += mInfo->getNameOffsetY();
- }
- // Monster names show above the sprite instead of below it
- if (mType == ActorType::Monster ||
- mVisibleNamePos == VisibleNamePos::Top)
- {
- offsetY += - settings.playerNameOffset - mDispName->getHeight();
- }
- mDispName->adviseXY(offsetX, offsetY, mMoveNames);
- }
- updateBadgesPosition();
-}
-
-void Being::optionChanged(const std::string &restrict value) restrict2
-{
- if (mType == ActorType::Player && value == "visiblenames")
- {
- setShowName(config.getIntValue("visiblenames") == VisibleName::Show);
- updateBadgesPosition();
- }
-}
-
-void Being::flashName(const int time) restrict2
-{
- if (mDispName != nullptr)
- mDispName->flash(time);
-}
-
-std::string Being::getGenderSignWithSpace() const restrict2
-{
- const std::string &restrict str = getGenderSign();
- if (str.empty())
- return str;
- else
- return std::string(" ").append(str);
-}
-
-std::string Being::getGenderSign() const restrict2
-{
- std::string str;
- if (mShowGender)
- {
- if (getGender() == Gender::FEMALE)
- str = "\u2640";
- else if (getGender() == Gender::MALE)
- str = "\u2642";
- }
- if (mShowPlayersStatus &&
- mShowBadges == BadgeDrawType::Hide)
- {
- if (mShop)
- str.append("$");
- if (mAway)
- {
- // TRANSLATORS: this away status writed in player nick
- str.append(_("A"));
- }
- else if (mInactive)
- {
- // TRANSLATORS: this inactive status writed in player nick
- str.append(_("I"));
- }
- }
- return str;
-}
-
-void Being::showName() restrict2
-{
- if (mName.empty())
- return;
-
- delete2(mDispName);
-
- if (mHideErased && playerRelations.getRelation(mName) == Relation::ERASED)
- return;
-
- std::string displayName(mName);
-
- if (mType != ActorType::Monster && (mShowGender || mShowLevel))
- {
- displayName.append(" ");
- if (mShowLevel && getLevel() != 0)
- displayName.append(toString(getLevel()));
-
- displayName.append(getGenderSign());
- }
-
- if (mType == ActorType::Monster)
- {
- if (config.getBoolValue("showMonstersTakedDamage"))
- displayName.append(", ").append(toString(getDamageTaken()));
- }
-
- Font *font = nullptr;
- if ((localPlayer != nullptr) && localPlayer->getTarget() == this
- && mType != ActorType::Monster)
- {
- font = boldFont;
- }
- else if (mType == ActorType::Player
- && !playerRelations.isGoodName(this) && (gui != nullptr))
- {
- font = gui->getSecureFont();
- }
-
- if (mInfo != nullptr)
- {
- mDispName = new FlashText(displayName,
- mPixelX + mInfo->getNameOffsetX(),
- mPixelY + mInfo->getNameOffsetY(),
- Graphics::CENTER,
- mNameColor,
- font);
- }
- else
- {
- mDispName = new FlashText(displayName,
- mPixelX,
- mPixelY,
- Graphics::CENTER,
- mNameColor,
- font);
- }
-
- updateCoords();
-}
-
-void Being::setDefaultNameColor(const UserColorIdT defaultColor) restrict2
-{
- switch (mTeamId)
- {
- case 0:
- default:
- mNameColor = &userPalette->getColor(defaultColor);
- break;
- case 1:
- mNameColor = &userPalette->getColor(UserColorId::TEAM1);
- break;
- case 2:
- mNameColor = &userPalette->getColor(UserColorId::TEAM2);
- break;
- case 3:
- mNameColor = &userPalette->getColor(UserColorId::TEAM3);
- break;
- }
-}
-
-void Being::updateColors()
-{
- if (userPalette != nullptr)
- {
- if (mType == ActorType::Monster)
- {
- setDefaultNameColor(UserColorId::MONSTER);
- mTextColor = &userPalette->getColor(UserColorId::MONSTER);
- }
- else if (mType == ActorType::Npc)
- {
- setDefaultNameColor(UserColorId::NPC);
- mTextColor = &userPalette->getColor(UserColorId::NPC);
- }
- else if (mType == ActorType::Pet)
- {
- setDefaultNameColor(UserColorId::PET);
- mTextColor = &userPalette->getColor(UserColorId::PET);
- }
- else if (mType == ActorType::Homunculus)
- {
- setDefaultNameColor(UserColorId::HOMUNCULUS);
- mTextColor = &userPalette->getColor(UserColorId::HOMUNCULUS);
- }
- else if (mType == ActorType::SkillUnit)
- {
- setDefaultNameColor(UserColorId::SKILLUNIT);
- mTextColor = &userPalette->getColor(UserColorId::SKILLUNIT);
- }
- else if (this == localPlayer)
- {
- mNameColor = &userPalette->getColor(UserColorId::SELF);
- mTextColor = &theme->getColor(ThemeColorId::PLAYER, 255);
- }
- else
- {
- mTextColor = &theme->getColor(ThemeColorId::PLAYER, 255);
-
- if (playerRelations.getRelation(mName) != Relation::ERASED)
- mErased = false;
- else
- mErased = true;
-
- if (mIsGM)
- {
- mTextColor = &userPalette->getColor(UserColorId::GM);
- mNameColor = &userPalette->getColor(UserColorId::GM);
- }
- else if (mEnemy)
- {
- mNameColor = &userPalette->getColor(UserColorId::ENEMY);
- }
- else if ((mParty != nullptr) && (localPlayer != nullptr)
- && mParty == localPlayer->getParty())
- {
- mNameColor = &userPalette->getColor(UserColorId::PARTY);
- }
- else if ((localPlayer != nullptr) && (getGuild() != nullptr)
- && getGuild() == localPlayer->getGuild())
- {
- mNameColor = &userPalette->getColor(UserColorId::GUILD);
- }
- else if (playerRelations.getRelation(mName) == Relation::FRIEND)
- {
- mNameColor = &userPalette->getColor(UserColorId::FRIEND);
- }
- else if (playerRelations.getRelation(mName) ==
- Relation::DISREGARDED
- || playerRelations.getRelation(mName) ==
- Relation::BLACKLISTED)
- {
- mNameColor = &userPalette->getColor(UserColorId::DISREGARDED);
- }
- else if (playerRelations.getRelation(mName)
- == Relation::IGNORED ||
- playerRelations.getRelation(mName) == Relation::ENEMY2)
- {
- mNameColor = &userPalette->getColor(UserColorId::IGNORED);
- }
- else if (playerRelations.getRelation(mName) == Relation::ERASED)
- {
- mNameColor = &userPalette->getColor(UserColorId::ERASED);
- }
- else
- {
- setDefaultNameColor(UserColorId::PC);
- }
- }
-
- if (mDispName != nullptr)
- mDispName->setColor(mNameColor);
- }
-}
-
-void Being::updateSprite(const unsigned int slot,
- const int id,
- const std::string &restrict color) restrict2
-{
- if (charServerHandler == nullptr || slot >= charServerHandler->maxSprite())
- return;
-
- if (slot >= CAST_U32(mSlots.size()))
- mSlots.resize(slot + 1, BeingSlot());
-
- if ((slot != 0u) && mSlots[slot].spriteId == id)
- return;
- setSpriteColor(slot,
- id,
- color);
-}
-
-// set sprite id, reset colors, reset cards
-void Being::setSpriteId(const unsigned int slot,
- const int id) restrict2
-{
- if (charServerHandler == nullptr || slot >= charServerHandler->maxSprite())
- return;
-
- if (slot >= CAST_U32(mSprites.size()))
- ensureSize(slot + 1);
-
- if (slot >= CAST_U32(mSlots.size()))
- mSlots.resize(slot + 1, BeingSlot());
-
- // id = 0 means unequip
- if (id == 0)
- {
- removeSprite(slot);
- mSpriteDraw[slot] = 0;
-
- const int id1 = mSlots[slot].spriteId;
- if (id1 != 0)
- removeItemParticles(id1);
- }
- else
- {
- const ItemInfo &info = ItemDB::get(id);
- const std::string &restrict filename = info.getSprite(
- mGender, mSubType);
- int lastTime = 0;
- int startTime = 0;
- AnimatedSprite *restrict equipmentSprite = nullptr;
-
- if (!filename.empty())
- {
- equipmentSprite = AnimatedSprite::delayedLoad(
- pathJoin(paths.getStringValue("sprites"), filename));
- }
-
- if (equipmentSprite != nullptr)
- {
- equipmentSprite->setSpriteDirection(getSpriteDirection());
- startTime = getStartTime();
- lastTime = getLastTime();
- }
-
- CompoundSprite::setSprite(slot, equipmentSprite);
- mSpriteDraw[slot] = id;
-
- addItemParticles(id, info.getDisplay());
-
- setAction(mAction, 0);
- if (equipmentSprite != nullptr)
- {
- if (lastTime > 0)
- {
- equipmentSprite->setLastTime(startTime);
- equipmentSprite->update(lastTime);
- }
- }
- }
-
- BeingSlot &beingSlot = mSlots[slot];
- beingSlot.spriteId = id;
- beingSlot.color.clear();
- beingSlot.colorId = ItemColor_one;
- beingSlot.cardsId = CardsList(nullptr);
- recalcSpritesOrder();
- if (beingEquipmentWindow != nullptr)
- beingEquipmentWindow->updateBeing(this);
-}
-
-// reset sprite id, reset colors, reset cards
-void Being::unSetSprite(const unsigned int slot) restrict2
-{
- if (charServerHandler == nullptr || slot >= charServerHandler->maxSprite())
- return;
-
- if (slot >= CAST_U32(mSprites.size()))
- ensureSize(slot + 1);
-
- if (slot >= CAST_U32(mSlots.size()))
- mSlots.resize(slot + 1, BeingSlot());
-
- removeSprite(slot);
- mSpriteDraw[slot] = 0;
-
- BeingSlot &beingSlot = mSlots[slot];
- const int id1 = beingSlot.spriteId;
- if (id1 != 0)
- removeItemParticles(id1);
-
- beingSlot.spriteId = 0;
- beingSlot.color.clear();
- beingSlot.colorId = ItemColor_one;
- beingSlot.cardsId = CardsList(nullptr);
- recalcSpritesOrder();
- if (beingEquipmentWindow != nullptr)
- beingEquipmentWindow->updateBeing(this);
-}
-
-// set sprite id, use color string, reset cards
-void Being::setSpriteColor(const unsigned int slot,
- const int id,
- const std::string &color) restrict2
-{
- if (charServerHandler == nullptr || slot >= charServerHandler->maxSprite())
- return;
-
- if (slot >= CAST_U32(mSprites.size()))
- ensureSize(slot + 1);
-
- if (slot >= CAST_U32(mSlots.size()))
- mSlots.resize(slot + 1, BeingSlot());
-
- // disabled for now, because it may broke replace/reorder sprites logic
-// if (slot && mSlots[slot].spriteId == id)
-// return;
-
- // id = 0 means unequip
- if (id == 0)
- {
- removeSprite(slot);
- mSpriteDraw[slot] = 0;
-
- const int id1 = mSlots[slot].spriteId;
- if (id1 != 0)
- removeItemParticles(id1);
- }
- else
- {
- const ItemInfo &info = ItemDB::get(id);
- const std::string &restrict filename = info.getSprite(
- mGender, mSubType);
- int lastTime = 0;
- int startTime = 0;
- AnimatedSprite *restrict equipmentSprite = nullptr;
-
- if (!filename.empty())
- {
- equipmentSprite = AnimatedSprite::delayedLoad(
- pathJoin(paths.getStringValue("sprites"),
- combineDye(filename, color)));
- }
-
- if (equipmentSprite != nullptr)
- {
- equipmentSprite->setSpriteDirection(getSpriteDirection());
- startTime = getStartTime();
- lastTime = getLastTime();
- }
-
- CompoundSprite::setSprite(slot, equipmentSprite);
- mSpriteDraw[slot] = id;
-
- addItemParticles(id, info.getDisplay());
-
- setAction(mAction, 0);
- if (equipmentSprite != nullptr)
- {
- if (lastTime > 0)
- {
- equipmentSprite->setLastTime(startTime);
- equipmentSprite->update(lastTime);
- }
- }
- }
-
- BeingSlot &beingSlot = mSlots[slot];
- beingSlot.spriteId = id;
- beingSlot.color = color;
- beingSlot.colorId = ItemColor_one;
- beingSlot.cardsId = CardsList(nullptr);
- recalcSpritesOrder();
- if (beingEquipmentWindow != nullptr)
- beingEquipmentWindow->updateBeing(this);
-}
-
-// set sprite id, use color id, reset cards
-void Being::setSpriteColorId(const unsigned int slot,
- const int id,
- ItemColor colorId) restrict2
-{
- if (charServerHandler == nullptr || slot >= charServerHandler->maxSprite())
- return;
-
- if (slot >= CAST_U32(mSprites.size()))
- ensureSize(slot + 1);
-
- if (slot >= CAST_U32(mSlots.size()))
- mSlots.resize(slot + 1, BeingSlot());
-
- // disabled for now, because it may broke replace/reorder sprites logic
-// if (slot && mSlots[slot].spriteId == id)
-// return;
-
- std::string color;
-
- // id = 0 means unequip
- if (id == 0)
- {
- removeSprite(slot);
- mSpriteDraw[slot] = 0;
-
- const int id1 = mSlots[slot].spriteId;
- if (id1 != 0)
- removeItemParticles(id1);
- }
- else
- {
- const ItemInfo &info = ItemDB::get(id);
- const std::string &restrict filename = info.getSprite(
- mGender, mSubType);
- int lastTime = 0;
- int startTime = 0;
- AnimatedSprite *restrict equipmentSprite = nullptr;
-
- if (!filename.empty())
- {
- color = info.getDyeColorsString(colorId);
- equipmentSprite = AnimatedSprite::delayedLoad(
- pathJoin(paths.getStringValue("sprites"),
- combineDye(filename, color)));
- }
-
- if (equipmentSprite != nullptr)
- {
- equipmentSprite->setSpriteDirection(getSpriteDirection());
- startTime = getStartTime();
- lastTime = getLastTime();
- }
-
- CompoundSprite::setSprite(slot, equipmentSprite);
- mSpriteDraw[slot] = id;
-
- addItemParticles(id, info.getDisplay());
-
- setAction(mAction, 0);
- if (equipmentSprite != nullptr)
- {
- if (lastTime > 0)
- {
- equipmentSprite->setLastTime(startTime);
- equipmentSprite->update(lastTime);
- }
- }
- }
-
- BeingSlot &beingSlot = mSlots[slot];
- beingSlot.spriteId = id;
- beingSlot.color = STD_MOVE(color);
- beingSlot.colorId = colorId;
- beingSlot.cardsId = CardsList(nullptr);
- recalcSpritesOrder();
- if (beingEquipmentWindow != nullptr)
- beingEquipmentWindow->updateBeing(this);
-}
-
-// set sprite id, colors from cards, cards
-void Being::setSpriteCards(const unsigned int slot,
- const int id,
- const CardsList &cards) restrict2
-{
- if (charServerHandler == nullptr || slot >= charServerHandler->maxSprite())
- return;
-
- if (slot >= CAST_U32(mSprites.size()))
- ensureSize(slot + 1);
-
- if (slot >= CAST_U32(mSlots.size()))
- mSlots.resize(slot + 1, BeingSlot());
-
- // disabled for now, because it may broke replace/reorder sprites logic
-// if (slot && mSlots[slot].spriteId == id)
-// return;
-
- ItemColor colorId = ItemColor_one;
- std::string color;
-
- // id = 0 means unequip
- if (id == 0)
- {
- removeSprite(slot);
- mSpriteDraw[slot] = 0;
-
- const int id1 = mSlots[slot].spriteId;
- if (id1 != 0)
- removeItemParticles(id1);
- }
- else
- {
- const ItemInfo &info = ItemDB::get(id);
- const std::string &restrict filename = info.getSprite(
- mGender, mSubType);
- int lastTime = 0;
- int startTime = 0;
- AnimatedSprite *restrict equipmentSprite = nullptr;
-
- if (!cards.isEmpty())
- colorId = ItemColorManager::getColorFromCards(cards);
-
- if (!filename.empty())
- {
- if (color.empty())
- color = info.getDyeColorsString(colorId);
-
- equipmentSprite = AnimatedSprite::delayedLoad(
- pathJoin(paths.getStringValue("sprites"),
- combineDye(filename, color)));
- }
-
- if (equipmentSprite != nullptr)
- {
- equipmentSprite->setSpriteDirection(getSpriteDirection());
- startTime = getStartTime();
- lastTime = getLastTime();
- }
-
- CompoundSprite::setSprite(slot, equipmentSprite);
- mSpriteDraw[slot] = id;
-
- addItemParticlesCards(id,
- info.getDisplay(),
- cards);
-
- setAction(mAction, 0);
- if (equipmentSprite != nullptr)
- {
- if (lastTime > 0)
- {
- equipmentSprite->setLastTime(startTime);
- equipmentSprite->update(lastTime);
- }
- }
- }
-
- BeingSlot &beingSlot = mSlots[slot];
- beingSlot.spriteId = id;
- beingSlot.color = STD_MOVE(color);
- beingSlot.colorId = colorId;
- beingSlot.cardsId = CardsList(cards);
- recalcSpritesOrder();
- if (beingEquipmentWindow != nullptr)
- beingEquipmentWindow->updateBeing(this);
-}
-
-void Being::setWeaponId(const int id) restrict2
-{
- if (id == 0)
- mEquippedWeapon = nullptr;
- else
- mEquippedWeapon = &ItemDB::get(id);
-}
-
-void Being::setTempSprite(const unsigned int slot,
- const int id) restrict2
-{
- if (charServerHandler == nullptr || slot >= charServerHandler->maxSprite())
- return;
-
- if (slot >= CAST_U32(mSprites.size()))
- ensureSize(slot + 1);
-
- if (slot >= CAST_U32(mSlots.size()))
- mSlots.resize(slot + 1, BeingSlot());
-
- BeingSlot &beingSlot = mSlots[slot];
-
- // id = 0 means unequip
- if (id == 0)
- {
- removeSprite(slot);
- mSpriteDraw[slot] = 0;
-
- const int id1 = beingSlot.spriteId;
- if (id1 != 0)
- removeItemParticles(id1);
- }
- else
- {
- const ItemInfo &info = ItemDB::get(id);
- const std::string &restrict filename = info.getSprite(
- mGender, mSubType);
- int lastTime = 0;
- int startTime = 0;
-
- AnimatedSprite *restrict equipmentSprite = nullptr;
-
- if (!filename.empty())
- {
- ItemColor colorId = ItemColor_one;
- const CardsList &cards = beingSlot.cardsId;
- if (!cards.isEmpty())
- colorId = ItemColorManager::getColorFromCards(cards);
- std::string color = beingSlot.color;
- if (color.empty())
- color = info.getDyeColorsString(colorId);
-
- equipmentSprite = AnimatedSprite::delayedLoad(
- pathJoin(paths.getStringValue("sprites"),
- combineDye(filename, color)));
- }
-
- if (equipmentSprite != nullptr)
- {
- equipmentSprite->setSpriteDirection(getSpriteDirection());
- startTime = getStartTime();
- lastTime = getLastTime();
- }
-
- CompoundSprite::setSprite(slot, equipmentSprite);
- mSpriteDraw[slot] = id;
-
- // +++ here probably need use existing cards
- addItemParticles(id, info.getDisplay());
-
- setAction(mAction, 0);
- if (equipmentSprite != nullptr)
- {
- if (lastTime > 0)
- {
- equipmentSprite->setLastTime(startTime);
- equipmentSprite->update(lastTime);
- }
- }
- }
-}
-
-void Being::setHairTempSprite(const unsigned int slot,
- const int id) restrict2
-{
- if (charServerHandler == nullptr || slot >= charServerHandler->maxSprite())
- return;
-
- if (slot >= CAST_U32(mSprites.size()))
- ensureSize(slot + 1);
-
- if (slot >= CAST_U32(mSlots.size()))
- mSlots.resize(slot + 1, BeingSlot());
-
- const CardsList &cards = mSlots[slot].cardsId;
-
- // id = 0 means unequip
- if (id == 0)
- {
- removeSprite(slot);
- mSpriteDraw[slot] = 0;
-
- const int id1 = mSlots[slot].spriteId;
- if (id1 != 0)
- removeItemParticles(id1);
- }
- else
- {
- const ItemInfo &info = ItemDB::get(id);
- const std::string &restrict filename = info.getSprite(
- mGender, mSubType);
- int lastTime = 0;
- int startTime = 0;
- AnimatedSprite *restrict equipmentSprite = nullptr;
-
- if (!filename.empty())
- {
- ItemColor colorId = ItemColor_one;
- if (!cards.isEmpty())
- colorId = ItemColorManager::getColorFromCards(cards);
-
- std::string color = info.getDyeColorsString(mHairColor);
- if (color.empty())
- color = info.getDyeColorsString(colorId);
-
- equipmentSprite = AnimatedSprite::delayedLoad(
- pathJoin(paths.getStringValue("sprites"),
- combineDye(filename, color)));
- }
-
- if (equipmentSprite != nullptr)
- {
- equipmentSprite->setSpriteDirection(getSpriteDirection());
- startTime = getStartTime();
- lastTime = getLastTime();
- }
-
- CompoundSprite::setSprite(slot, equipmentSprite);
- mSpriteDraw[slot] = id;
-
- addItemParticles(id, info.getDisplay());
-
- setAction(mAction, 0);
- if (equipmentSprite != nullptr)
- {
- if (lastTime > 0)
- {
- equipmentSprite->setLastTime(startTime);
- equipmentSprite->update(lastTime);
- }
- }
- }
-}
-
-void Being::setHairColorSpriteID(const unsigned int slot,
- const int id) restrict2
-{
- BeingSlot &beingSlot = mSlots[slot];
- setSpriteColor(slot,
- id,
- beingSlot.color);
-}
-
-void Being::setSpriteColor(const unsigned int slot,
- const std::string &restrict color) restrict2
-{
- if (charServerHandler == nullptr || slot >= charServerHandler->maxSprite())
- return;
-
- if (slot >= CAST_U32(mSprites.size()))
- ensureSize(slot + 1);
-
- if (slot >= CAST_U32(mSlots.size()))
- mSlots.resize(slot + 1, BeingSlot());
-
- // disabled for now, because it may broke replace/reorder sprites logic
-// if (slot && mSlots[slot].spriteId == id)
-// return;
-
- BeingSlot &beingSlot = mSlots[slot];
- const int id = beingSlot.spriteId;
-
- // id = 0 means unequip
- if (id != 0)
- {
- const ItemInfo &info = ItemDB::get(id);
- const std::string &restrict filename = info.getSprite(
- mGender, mSubType);
- int lastTime = 0;
- int startTime = 0;
- AnimatedSprite *restrict equipmentSprite = nullptr;
-
- if (!filename.empty())
- {
- equipmentSprite = AnimatedSprite::delayedLoad(
- pathJoin(paths.getStringValue("sprites"),
- combineDye(filename, color)));
- }
-
- if (equipmentSprite != nullptr)
- {
- equipmentSprite->setSpriteDirection(getSpriteDirection());
- startTime = getStartTime();
- lastTime = getLastTime();
- }
-
- CompoundSprite::setSprite(slot, equipmentSprite);
-
- setAction(mAction, 0);
- if (equipmentSprite != nullptr)
- {
- if (lastTime > 0)
- {
- equipmentSprite->setLastTime(startTime);
- equipmentSprite->update(lastTime);
- }
- }
- }
-
- beingSlot.color = color;
- beingSlot.colorId = ItemColor_one;
- if (beingEquipmentWindow != nullptr)
- beingEquipmentWindow->updateBeing(this);
-}
-
-void Being::setHairStyle(const unsigned int slot,
- const int id) restrict2
-{
- if (id != 0)
- {
- setSpriteColor(slot,
- id,
- ItemDB::get(id).getDyeColorsString(mHairColor));
- }
- else
- {
- setSpriteColor(slot,
- 0,
- std::string());
- }
-}
-
-void Being::setHairColor(const unsigned int slot,
- const ItemColor color) restrict2
-{
- mHairColor = color;
- BeingSlot &beingSlot = mSlots[slot];
- const int id = beingSlot.spriteId;
- if (id != 0)
- {
- setSpriteColor(slot,
- id,
- ItemDB::get(id).getDyeColorsString(color));
- }
-}
-
-void Being::setSpriteSlot(const unsigned int slot,
- const BeingSlot &beingSlot)
-{
- mSlots[slot] = beingSlot;
-}
-
-void Being::dumpSprites() const restrict2
-{
- STD_VECTOR<BeingSlot>::const_iterator it1 = mSlots.begin();
- const STD_VECTOR<BeingSlot>::const_iterator it1_end = mSlots.end();
-
- logger->log("sprites");
- for (; it1 != it1_end;
- ++ it1)
- {
- logger->log("%d,%s,%d",
- (*it1).spriteId,
- (*it1).color.c_str(),
- toInt((*it1).colorId, int));
- }
-}
-
-void Being::updateName() restrict2
-{
- if (mShowName)
- showName();
-}
-
-void Being::reReadConfig()
-{
- BLOCK_START("Being::reReadConfig")
- if (mUpdateConfigTime + 1 < cur_time)
- {
- mAwayEffect = paths.getIntValue("afkEffectId");
- mHighlightMapPortals = config.getBoolValue("highlightMapPortals");
- mConfLineLim = config.getIntValue("chatMaxCharLimit");
- mSpeechType = config.getIntValue("speech");
- mHighlightMonsterAttackRange =
- config.getBoolValue("highlightMonsterAttackRange");
- mLowTraffic = config.getBoolValue("lowTraffic");
- mDrawHotKeys = config.getBoolValue("drawHotKeys");
- mShowBattleEvents = config.getBoolValue("showBattleEvents");
- mShowMobHP = config.getBoolValue("showMobHP");
- mShowOwnHP = config.getBoolValue("showOwnHP");
- mShowGender = config.getBoolValue("showgender");
- mShowLevel = config.getBoolValue("showlevel");
- mShowPlayersStatus = config.getBoolValue("showPlayersStatus");
- mEnableReorderSprites = config.getBoolValue("enableReorderSprites");
- mHideErased = config.getBoolValue("hideErased");
- mMoveNames = fromBool(config.getBoolValue("moveNames"), Move);
- mUseDiagonal = config.getBoolValue("useDiagonalSpeed");
- mShowBadges = static_cast<BadgeDrawType::Type>(
- config.getIntValue("showBadges"));
- mVisibleNamePos = static_cast<VisibleNamePos::Type>(
- config.getIntValue("visiblenamespos"));
-
- mUpdateConfigTime = cur_time;
- }
- BLOCK_END("Being::reReadConfig")
-}
-
-bool Being::updateFromCache() restrict2
-{
- const BeingCacheEntry *restrict const entry =
- Being::getCacheEntry(getId());
-
- if ((entry != nullptr) && entry->getTime() + 120 >= cur_time)
- {
- if (!entry->getName().empty())
- setName(entry->getName());
- setPartyName(entry->getPartyName());
- setGuildName(entry->getGuildName());
- setLevel(entry->getLevel());
- setPvpRank(entry->getPvpRank());
- setIp(entry->getIp());
- setTeamId(entry->getTeamId());
-
- mAdvanced = entry->isAdvanced();
- if (mAdvanced)
- {
- const int flags = entry->getFlags();
- if ((serverFeatures != nullptr) &&
- Net::getNetworkType() == ServerType::TMWATHENA)
- {
- mShop = ((flags & BeingFlag::SHOP) != 0);
- }
- mAway = ((flags & BeingFlag::AWAY) != 0);
- mInactive = ((flags & BeingFlag::INACTIVE) != 0);
- if (mShop || mAway || mInactive)
- updateName();
- }
- else
- {
- if (Net::getNetworkType() == ServerType::TMWATHENA)
- mShop = false;
- mAway = false;
- mInactive = false;
- }
-
- showShopBadge(mShop);
- showInactiveBadge(mInactive);
- showAwayBadge(mAway);
- updateAwayEffect();
- if (mType == ActorType::Player || (mTeamId != 0u))
- updateColors();
- return true;
- }
- return false;
-}
-
-void Being::addToCache() const restrict2
-{
- if (localPlayer == this)
- return;
-
- BeingCacheEntry *entry = Being::getCacheEntry(getId());
- if (entry == nullptr)
- {
- entry = new BeingCacheEntry(getId());
- beingInfoCache.push_front(entry);
-
- if (beingInfoCache.size() >= CACHE_SIZE)
- {
- delete beingInfoCache.back();
- beingInfoCache.pop_back();
- }
- }
- if (!mLowTraffic)
- return;
-
- entry->setName(mName);
- entry->setLevel(getLevel());
- entry->setPartyName(getPartyName());
- entry->setGuildName(getGuildName());
- entry->setTime(cur_time);
- entry->setPvpRank(getPvpRank());
- entry->setIp(getIp());
- entry->setAdvanced(isAdvanced());
- entry->setTeamId(getTeamId());
- if (isAdvanced())
- {
- int flags = 0;
- if (Net::getNetworkType() == ServerType::TMWATHENA && mShop)
- flags += BeingFlag::SHOP;
- if (mAway)
- flags += BeingFlag::AWAY;
- if (mInactive)
- flags += BeingFlag::INACTIVE;
- entry->setFlags(flags);
- }
- else
- {
- entry->setFlags(0);
- }
-}
-
-BeingCacheEntry* Being::getCacheEntry(const BeingId id)
-{
- FOR_EACH (std::list<BeingCacheEntry*>::iterator, i, beingInfoCache)
- {
- if (*i == nullptr)
- continue;
-
- if (id == (*i)->getId())
- {
- // Raise priority: move it to front
- if ((*i)->getTime() + 120 < cur_time)
- {
- beingInfoCache.splice(beingInfoCache.begin(),
- beingInfoCache, i);
- }
- return *i;
- }
- }
- return nullptr;
-}
-
-
-void Being::setGender(const GenderT gender) restrict2
-{
- if (charServerHandler == nullptr)
- return;
-
- if (gender != mGender)
- {
- mGender = gender;
-
- const unsigned int sz = CAST_U32(mSlots.size());
-
- if (sz > CAST_U32(mSprites.size()))
- ensureSize(sz);
-
- // Reload all subsprites
- for (unsigned int i = 0;
- i < sz;
- i++)
- {
- BeingSlot &beingSlot = mSlots[i];
- const int id = beingSlot.spriteId;
- if (id != 0)
- {
- const ItemInfo &info = ItemDB::get(id);
- const std::string &restrict filename = info.getSprite(
- mGender, mSubType);
- int lastTime = 0;
- int startTime = 0;
- AnimatedSprite *restrict equipmentSprite = nullptr;
-
- if (!filename.empty())
- {
- equipmentSprite = AnimatedSprite::delayedLoad(
- pathJoin(paths.getStringValue("sprites"),
- combineDye(filename, beingSlot.color)));
- }
-
- if (equipmentSprite != nullptr)
- {
- equipmentSprite->setSpriteDirection(getSpriteDirection());
- startTime = getStartTime();
- lastTime = getLastTime();
- }
-
- CompoundSprite::setSprite(i, equipmentSprite);
- setAction(mAction, 0);
- if (equipmentSprite != nullptr)
- {
- if (lastTime > 0)
- {
- equipmentSprite->setLastTime(startTime);
- equipmentSprite->update(lastTime);
- }
- }
-
- if (beingEquipmentWindow != nullptr)
- beingEquipmentWindow->updateBeing(this);
- }
- }
-
- updateName();
- }
-}
-
-void Being::showGmBadge(const bool show) restrict2
-{
- delete2(mBadges[BadgeIndex::Gm]);
- if (show &&
- mIsGM &&
- mShowBadges != BadgeDrawType::Hide &&
- GroupDb::getShowBadge(mGroupId))
- {
- const std::string &gmBadge = GroupDb::getBadge(mGroupId);
- if (!gmBadge.empty())
- {
- mBadges[BadgeIndex::Gm] = AnimatedSprite::load(
- paths.getStringValue("badges") + gmBadge);
- }
- }
- updateBadgesCount();
- updateBadgesPosition();
-}
-
-void Being::setGM(const bool gm) restrict2
-{
- if (mIsGM != gm)
- {
- mIsGM = gm;
-
- showGmBadge(mIsGM);
- updateColors();
- }
-}
-
-void Being::talkTo() const restrict2
-{
- if (npcHandler == nullptr)
- return;
-
- if (!PacketLimiter::limitPackets(PacketType::PACKET_NPC_TALK))
- {
- // using workaround...
- if ((playerHandler != nullptr) &&
- PacketLimiter::limitPackets(PacketType::PACKET_ATTACK))
- {
- playerHandler->attack(mId, Keep_false);
- }
- return;
- }
-
- npcHandler->talk(this);
-}
-
-void Being::drawPlayer(Graphics *restrict const graphics,
- const int offsetX,
- const int offsetY) const restrict2
-{
- if (!mErased)
- {
- // getActorX() + offsetX;
- const int px = mPixelX - mapTileSize / 2 + offsetX;
- // getActorY() + offsetY;
- const int py = mPixelY - mapTileSize + offsetY;
- if (mHorseInfo != nullptr)
- {
- HorseOffset &offset = mHorseInfo->offsets[mSpriteDirection];
- for_each_horses(mDownHorseSprites)
- {
- (*it)->draw(graphics,
- px + offset.downOffsetX,
- py + offset.downOffsetY);
- }
-
- drawBeingCursor(graphics, px, py);
- drawPlayerSpriteAt(graphics,
- px + offset.riderOffsetX,
- py + offset.riderOffsetY);
-
- for_each_horses(mUpHorseSprites)
- {
- (*it)->draw(graphics,
- px + offset.upOffsetX,
- py + offset.upOffsetY);
- }
- }
- else
- {
- drawBeingCursor(graphics, px, py);
- drawPlayerSpriteAt(graphics, px, py);
- }
- }
-}
-
-void Being::drawBeingCursor(Graphics *const graphics,
- const int offsetX,
- const int offsetY) const
-{
- if (mUsedTargetCursor != nullptr)
- {
- mUsedTargetCursor->update(tick_time * MILLISECONDS_IN_A_TICK);
- if (mInfo == nullptr)
- {
- mUsedTargetCursor->draw(graphics,
- offsetX - mCursorPaddingX,
- offsetY - mCursorPaddingY);
- }
- else
- {
- mUsedTargetCursor->draw(graphics,
- offsetX + mInfo->getTargetOffsetX() - mCursorPaddingX,
- offsetY + mInfo->getTargetOffsetY() - mCursorPaddingY);
- }
- }
-}
-
-void Being::drawOther(Graphics *restrict const graphics,
- const int offsetX,
- const int offsetY) const restrict2
-{
- // getActorX() + offsetX;
- const int px = mPixelX - mapTileSize / 2 + offsetX;
- // getActorY() + offsetY;
- const int py = mPixelY - mapTileSize + offsetY;
- drawBeingCursor(graphics, px, py);
- drawOtherSpriteAt(graphics, px, py);
-}
-
-void Being::drawMonster(Graphics *restrict const graphics,
- const int offsetX,
- const int offsetY) const restrict2
-{
- // getActorX() + offsetX;
- const int px = mPixelX - mapTileSize / 2 + offsetX;
- // getActorY() + offsetY;
- const int py = mPixelY - mapTileSize + offsetY;
- drawBeingCursor(graphics, px, py);
- drawMonsterSpriteAt(graphics, px, py);
-}
-
-void Being::drawHomunculus(Graphics *restrict const graphics,
- const int offsetX,
- const int offsetY) const restrict2
-{
- // getActorX() + offsetX;
- const int px = mPixelX - mapTileSize / 2 + offsetX;
- // getActorY() + offsetY;
- const int py = mPixelY - mapTileSize + offsetY;
- drawBeingCursor(graphics, px, py);
- drawHomunculusSpriteAt(graphics, px, py);
-}
-
-void Being::drawMercenary(Graphics *restrict const graphics,
- const int offsetX,
- const int offsetY) const restrict2
-{
- // getActorX() + offsetX;
- const int px = mPixelX - mapTileSize / 2 + offsetX;
- // getActorY() + offsetY;
- const int py = mPixelY - mapTileSize + offsetY;
- drawBeingCursor(graphics, px, py);
- drawMercenarySpriteAt(graphics, px, py);
-}
-
-void Being::drawElemental(Graphics *restrict const graphics,
- const int offsetX,
- const int offsetY) const restrict2
-{
- // getActorX() + offsetX;
- const int px = mPixelX - mapTileSize / 2 + offsetX;
- // getActorY() + offsetY;
- const int py = mPixelY - mapTileSize + offsetY;
- drawBeingCursor(graphics, px, py);
- drawElementalSpriteAt(graphics, px, py);
-}
-
-void Being::drawPortal(Graphics *restrict const graphics,
- const int offsetX,
- const int offsetY) const restrict2
-{
- // getActorX() + offsetX;
- const int px = mPixelX - mapTileSize / 2 + offsetX;
- // getActorY() + offsetY;
- const int py = mPixelY - mapTileSize + offsetY;
- drawPortalSpriteAt(graphics, px, py);
-}
-
-void Being::draw(Graphics *restrict const graphics,
- const int offsetX,
- const int offsetY) const restrict2
-{
- switch (mType)
- {
- case ActorType::Player:
- drawPlayer(graphics,
- offsetX,
- offsetY);
- break;
- case ActorType::Portal:
- drawPortal(graphics,
- offsetX,
- offsetY);
- break;
- case ActorType::Homunculus:
- drawHomunculus(graphics,
- offsetX,
- offsetY);
- break;
- case ActorType::Mercenary:
- drawMercenary(graphics,
- offsetX,
- offsetY);
- break;
- case ActorType::Elemental:
- drawElemental(graphics,
- offsetX,
- offsetY);
- break;
- case ActorType::Monster:
- drawMonster(graphics,
- offsetX,
- offsetY);
- break;
- case ActorType::Pet:
- case ActorType::SkillUnit:
- case ActorType::Unknown:
- case ActorType::Npc:
- case ActorType::FloorItem:
- case ActorType::Avatar:
- default:
- drawOther(graphics,
- offsetX,
- offsetY);
- break;
- }
-}
-
-void Being::drawPlayerSprites(Graphics *restrict const graphics,
- const int posX,
- const int posY) const restrict2
-{
- const int sz = CompoundSprite::getNumberOfLayers();
- for (int f = 0; f < sz; f ++)
- {
- const int rSprite = mSpriteHide[mSpriteRemap[f]];
- if (rSprite == 1)
- continue;
-
- Sprite *restrict const sprite = mSprites[mSpriteRemap[f]];
- if (sprite != nullptr)
- {
- sprite->setAlpha(mAlpha);
- sprite->draw(graphics, posX, posY);
- }
- }
-}
-
-void Being::drawSpritesSDL(Graphics *restrict const graphics,
- const int posX,
- const int posY) const restrict2
-{
- const size_t sz = mSprites.size();
- for (size_t f = 0; f < sz; f ++)
- {
- const int rSprite = mSpriteHide[mSpriteRemap[f]];
- if (rSprite == 1)
- continue;
-
- const Sprite *restrict const sprite = mSprites[mSpriteRemap[f]];
- if (sprite != nullptr)
- sprite->draw(graphics, posX, posY);
- }
-}
-
-void Being::drawBasic(Graphics *restrict const graphics,
- const int x,
- const int y) const restrict2
-{
- drawCompound(graphics, x, y);
-}
-
-void Being::drawCompound(Graphics *const graphics,
- const int posX,
- const int posY) const
-{
- FUNC_BLOCK("CompoundSprite::draw", 1)
- if (mNeedsRedraw)
- updateImages();
-
- if (mSprites.empty()) // Nothing to draw
- return;
-
- if (mAlpha == 1.0F && (mImage != nullptr))
- {
- graphics->drawImage(mImage,
- posX + mOffsetX,
- posY + mOffsetY);
- }
- else if ((mAlpha != 0.0f) && (mAlphaImage != nullptr))
- {
- mAlphaImage->setAlpha(mAlpha);
- graphics->drawImage(mAlphaImage,
- posX + mOffsetX,
- posY + mOffsetY);
- }
- else
- {
- Being::drawPlayerSprites(graphics, posX, posY);
- }
-}
-
-void Being::drawPlayerSpriteAt(Graphics *restrict const graphics,
- const int x,
- const int y) const restrict2
-{
- drawCompound(graphics, x, y);
-
- if (mShowOwnHP &&
- (mInfo != nullptr) &&
- localPlayer == this &&
- mAction != BeingAction::DEAD)
- {
- drawHpBar(graphics,
- PlayerInfo::getAttribute(Attributes::PLAYER_MAX_HP),
- PlayerInfo::getAttribute(Attributes::PLAYER_HP),
- 0,
- UserColorId::PLAYER_HP,
- UserColorId::PLAYER_HP2,
- x - 50 + mapTileSize / 2 + mInfo->getHpBarOffsetX(),
- y + mapTileSize - 6 + mInfo->getHpBarOffsetY(),
- 2 * 50,
- 4);
- }
-}
-
-void Being::drawOtherSpriteAt(Graphics *restrict const graphics,
- const int x,
- const int y) const restrict2
-{
- CompoundSprite::drawSimple(graphics, x, y);
-}
-
-void Being::drawMonsterSpriteAt(Graphics *restrict const graphics,
- const int x,
- const int y) const restrict2
-{
- if (mHighlightMonsterAttackRange &&
- mType == ActorType::Monster &&
- mAction != BeingAction::DEAD)
- {
- if (userPalette == nullptr)
- {
- CompoundSprite::drawSimple(graphics, x, y);
- return;
- }
-
- int attackRange;
- if (mAttackRange != 0)
- attackRange = mapTileSize * mAttackRange;
- else
- attackRange = mapTileSize;
-
- graphics->setColor(userPalette->getColorWithAlpha(
- UserColorId::MONSTER_ATTACK_RANGE));
-
- graphics->fillRectangle(Rect(
- x - attackRange, y - attackRange,
- 2 * attackRange + mapTileSize, 2 * attackRange + mapTileSize));
- }
-
- CompoundSprite::drawSimple(graphics, x, y);
-
- if (mShowMobHP &&
- (mInfo != nullptr) &&
- (localPlayer != nullptr) &&
- localPlayer->getTarget() == this &&
- mType == ActorType::Monster)
- {
- // show hp bar here
- int maxHP = mMaxHP;
- if (maxHP == 0)
- maxHP = mInfo->getMaxHP();
-
- drawHpBar(graphics,
- maxHP,
- mHP,
- mDamageTaken,
- UserColorId::MONSTER_HP,
- UserColorId::MONSTER_HP2,
- x - 50 + mapTileSize / 2 + mInfo->getHpBarOffsetX(),
- y + mapTileSize - 6 + mInfo->getHpBarOffsetY(),
- 2 * 50,
- 4);
- }
-}
-
-void Being::drawHomunculusSpriteAt(Graphics *restrict const graphics,
- const int x,
- const int y) const restrict2
-{
- if (mHighlightMonsterAttackRange &&
- mAction != BeingAction::DEAD)
- {
- if (userPalette == nullptr)
- {
- CompoundSprite::drawSimple(graphics, x, y);
- return;
- }
-
- int attackRange;
- if (mAttackRange != 0)
- attackRange = mapTileSize * mAttackRange;
- else
- attackRange = mapTileSize;
-
- graphics->setColor(userPalette->getColorWithAlpha(
- UserColorId::MONSTER_ATTACK_RANGE));
-
- graphics->fillRectangle(Rect(
- x - attackRange, y - attackRange,
- 2 * attackRange + mapTileSize, 2 * attackRange + mapTileSize));
- }
-
- CompoundSprite::drawSimple(graphics, x, y);
-
- if (mShowMobHP &&
- (mInfo != nullptr))
- {
- const HomunculusInfo *const info = PlayerInfo::getHomunculus();
- if ((info != nullptr) &&
- mId == info->id)
- {
- // show hp bar here
- int maxHP = PlayerInfo::getStatBase(Attributes::HOMUN_MAX_HP);
- if (maxHP == 0)
- maxHP = mInfo->getMaxHP();
-
- drawHpBar(graphics,
- maxHP,
- PlayerInfo::getStatBase(Attributes::HOMUN_HP),
- mDamageTaken,
- UserColorId::HOMUN_HP,
- UserColorId::HOMUN_HP2,
- x - 50 + mapTileSize / 2 + mInfo->getHpBarOffsetX(),
- y + mapTileSize - 6 + mInfo->getHpBarOffsetY(),
- 2 * 50,
- 4);
- }
- }
-}
-
-void Being::drawMercenarySpriteAt(Graphics *restrict const graphics,
- const int x,
- const int y) const restrict2
-{
- if (mHighlightMonsterAttackRange &&
- mAction != BeingAction::DEAD)
- {
- if (userPalette == nullptr)
- {
- CompoundSprite::drawSimple(graphics, x, y);
- return;
- }
-
- int attackRange;
- if (mAttackRange != 0)
- attackRange = mapTileSize * mAttackRange;
- else
- attackRange = mapTileSize;
-
- graphics->setColor(userPalette->getColorWithAlpha(
- UserColorId::MONSTER_ATTACK_RANGE));
-
- graphics->fillRectangle(Rect(
- x - attackRange, y - attackRange,
- 2 * attackRange + mapTileSize, 2 * attackRange + mapTileSize));
- }
-
- CompoundSprite::drawSimple(graphics, x, y);
-
- if (mShowMobHP &&
- (mInfo != nullptr))
- {
- const MercenaryInfo *const info = PlayerInfo::getMercenary();
- if ((info != nullptr) &&
- mId == info->id)
- {
- // show hp bar here
- int maxHP = PlayerInfo::getStatBase(Attributes::MERC_MAX_HP);
- if (maxHP == 0)
- maxHP = mInfo->getMaxHP();
-
- drawHpBar(graphics,
- maxHP,
- PlayerInfo::getStatBase(Attributes::MERC_HP),
- mDamageTaken,
- UserColorId::MERC_HP,
- UserColorId::MERC_HP2,
- x - 50 + mapTileSize / 2 + mInfo->getHpBarOffsetX(),
- y + mapTileSize - 6 + mInfo->getHpBarOffsetY(),
- 2 * 50,
- 4);
- }
- }
-}
-
-void Being::drawElementalSpriteAt(Graphics *restrict const graphics,
- const int x,
- const int y) const restrict2
-{
- if (mHighlightMonsterAttackRange &&
- mAction != BeingAction::DEAD)
- {
- if (userPalette == nullptr)
- {
- CompoundSprite::drawSimple(graphics, x, y);
- return;
- }
-
- int attackRange;
- if (mAttackRange != 0)
- attackRange = mapTileSize * mAttackRange;
- else
- attackRange = mapTileSize;
-
- graphics->setColor(userPalette->getColorWithAlpha(
- UserColorId::MONSTER_ATTACK_RANGE));
-
- graphics->fillRectangle(Rect(
- x - attackRange, y - attackRange,
- 2 * attackRange + mapTileSize, 2 * attackRange + mapTileSize));
- }
-
- CompoundSprite::drawSimple(graphics, x, y);
-
- if (mShowMobHP &&
- (mInfo != nullptr))
- {
- if (mId == PlayerInfo::getElementalId())
- {
- // show hp bar here
- int maxHP = PlayerInfo::getStatBase(Attributes::ELEMENTAL_MAX_HP);
- if (maxHP == 0)
- maxHP = mInfo->getMaxHP();
-
- drawHpBar(graphics,
- maxHP,
- PlayerInfo::getStatBase(Attributes::ELEMENTAL_HP),
- mDamageTaken,
- UserColorId::ELEMENTAL_HP,
- UserColorId::ELEMENTAL_HP2,
- x - 50 + mapTileSize / 2 + mInfo->getHpBarOffsetX(),
- y + mapTileSize - 6 + mInfo->getHpBarOffsetY(),
- 2 * 50,
- 4);
- }
- }
-}
-
-void Being::drawPortalSpriteAt(Graphics *restrict const graphics,
- const int x,
- const int y) const restrict2
-{
- if (mHighlightMapPortals &&
- (mMap != nullptr) &&
- !mMap->getHasWarps())
- {
- if (userPalette == nullptr)
- {
- CompoundSprite::drawSimple(graphics, x, y);
- return;
- }
-
- graphics->setColor(userPalette->
- getColorWithAlpha(UserColorId::PORTAL_HIGHLIGHT));
-
- graphics->fillRectangle(Rect(x, y,
- mapTileSize, mapTileSize));
-
- if (mDrawHotKeys && !mName.empty())
- {
- const Color &color = userPalette->getColor(UserColorId::BEING);
- gui->getFont()->drawString(graphics, color, color, mName, x, y);
- }
- }
-
- CompoundSprite::drawSimple(graphics, x, y);
-}
-
-void Being::drawHpBar(Graphics *restrict const graphics,
- const int maxHP,
- const int hp,
- const int damage,
- const UserColorIdT color1,
- const UserColorIdT color2,
- const int x,
- const int y,
- const int width,
- const int height) const restrict2
-{
- if (maxHP <= 0 || (userPalette == nullptr))
- return;
-
- float p;
-
- if (hp != 0)
- {
- p = static_cast<float>(maxHP) / static_cast<float>(hp);
- }
- else if (maxHP != damage)
- {
- p = static_cast<float>(maxHP)
- / static_cast<float>(maxHP - damage);
- }
- else
- {
- p = 1;
- }
-
- if (p <= 0 || p > width)
- return;
-
- const int dx = static_cast<int>(static_cast<float>(width) / p);
-
-#ifdef TMWA_SUPPORT
- if (!serverFeatures->haveServerHp())
- { // old servers
- if ((damage == 0 && (this != localPlayer || hp == maxHP))
- || (hp == 0 && maxHP == damage))
- {
- graphics->setColor(userPalette->getColorWithAlpha(color1));
- graphics->fillRectangle(Rect(
- x, y, dx, height));
- return;
- }
- else if (width - dx <= 0)
- {
- graphics->setColor(userPalette->getColorWithAlpha(color2));
- graphics->fillRectangle(Rect(
- x, y, width, height));
- return;
- }
- }
- else
-#endif // TMWA_SUPPORT
- {
- if (hp == maxHP)
- {
- graphics->setColor(userPalette->getColorWithAlpha(color1));
- graphics->fillRectangle(Rect(
- x, y, dx, height));
- return;
- }
- else if (width - dx <= 0)
- {
- graphics->setColor(userPalette->getColorWithAlpha(color2));
- graphics->fillRectangle(Rect(
- x, y, width, height));
- return;
- }
- }
-
- graphics->setColor(userPalette->getColorWithAlpha(color1));
- graphics->fillRectangle(Rect(
- x, y, dx, height));
-
- graphics->setColor(userPalette->getColorWithAlpha(color2));
- graphics->fillRectangle(Rect(x + dx, y, width - dx, height));
-}
-
-void Being::setHP(const int hp) restrict2
-{
- mHP = hp;
- if (mMaxHP < mHP)
- mMaxHP = mHP;
- if (mType == ActorType::Monster)
- updatePercentHP();
-}
-
-void Being::setMaxHP(const int hp) restrict2
-{
- mMaxHP = hp;
- if (mMaxHP < mHP)
- mMaxHP = mHP;
-}
-
-void Being::resetCounters() restrict2
-{
- mMoveTime = 0;
- mAttackTime = 0;
- mTalkTime = 0;
- mOtherTime = 0;
- mTestTime = cur_time;
-}
-
-void Being::recalcSpritesOrder() restrict2
-{
- if (!mEnableReorderSprites)
- return;
-
-// logger->log("recalcSpritesOrder");
- const size_t sz = mSprites.size();
- if (sz < 1)
- return;
-
- STD_VECTOR<int> slotRemap;
- IntMap itemSlotRemap;
-
- STD_VECTOR<int>::iterator it;
- int oldHide[20];
- bool updatedSprite[20];
- int dir = mSpriteDirection;
- if (dir < 0 || dir >= 9)
- dir = 0;
- // hack for allow different logic in dead player
- if (mAction == BeingAction::DEAD)
- dir = 9;
-
- const unsigned int hairSlot = charServerHandler->hairSprite();
-
- for (size_t slot = sz; slot < 20; slot ++)
- {
- oldHide[slot] = 0;
- updatedSprite[slot] = false;
- }
-
- for (size_t slot = 0; slot < sz; slot ++)
- {
- oldHide[slot] = mSpriteHide[slot];
- mSpriteHide[slot] = 0;
- updatedSprite[slot] = false;
- }
-
- size_t spriteIdSize = mSlots.size();
- if (reportTrue(spriteIdSize > 20))
- spriteIdSize = 20;
-
- for (size_t slot = 0; slot < sz; slot ++)
- {
- slotRemap.push_back(CAST_S32(slot));
-
- if (spriteIdSize <= slot)
- continue;
-
- const int id = mSlots[slot].spriteId;
- if (id == 0)
- continue;
-
- const ItemInfo &info = ItemDB::get(id);
-
- if (info.isRemoveSprites())
- {
- const SpriteToItemMap *restrict const spriteToItems
- = info.getSpriteToItemReplaceMap(dir);
-
- if (spriteToItems != nullptr)
- {
- FOR_EACHP (SpriteToItemMapCIter, itr, spriteToItems)
- {
- const int remSprite = itr->first;
- const IntMap &restrict itemReplacer = itr->second;
- if (remSprite >= 0)
- { // slot known
- if (itemReplacer.empty())
- {
- mSpriteHide[remSprite] = 1;
- }
- else if (mSpriteHide[remSprite] != 1)
- {
- IntMapCIter repIt = itemReplacer.find(
- mSlots[remSprite].spriteId);
- if (repIt == itemReplacer.end())
- {
- repIt = itemReplacer.find(0);
- if (repIt->second == 0)
- repIt = itemReplacer.end();
- }
- if (repIt != itemReplacer.end())
- {
- mSpriteHide[remSprite] = repIt->second;
- if (repIt->second != 1)
- {
- if (CAST_U32(remSprite)
- != hairSlot)
- {
- setTempSprite(remSprite,
- repIt->second);
- }
- else
- {
- setHairTempSprite(remSprite,
- repIt->second);
- }
- updatedSprite[remSprite] = true;
- }
- }
- }
- }
- else
- { // slot unknown. Search for real slot, this can be slow
- FOR_EACH (IntMapCIter, repIt, itemReplacer)
- {
- for (unsigned int slot2 = 0; slot2 < sz; slot2 ++)
- {
- if (mSlots[slot2].spriteId == repIt->first)
- {
- mSpriteHide[slot2] = repIt->second;
- if (repIt->second != 1)
- {
- if (slot2 != hairSlot)
- {
- setTempSprite(slot2,
- repIt->second);
- }
- else
- {
- setHairTempSprite(slot2,
- repIt->second);
- }
- updatedSprite[slot2] = true;
- }
- }
- }
- }
- }
- }
- }
- }
-
- if (info.mDrawBefore[dir] > 0)
- {
- const int id2 = mSlots[info.mDrawBefore[dir]].spriteId;
- if (itemSlotRemap.find(id2) != itemSlotRemap.end())
- {
-// logger->log("found duplicate (before)");
- const ItemInfo &info2 = ItemDB::get(id2);
- if (info.mDrawPriority[dir] < info2.mDrawPriority[dir])
- {
-// logger->log("old more priority");
- continue;
- }
- else
- {
-// logger->log("new more priority");
- itemSlotRemap.erase(id2);
- }
- }
-
- itemSlotRemap[id] = -info.mDrawBefore[dir];
- }
- else if (info.mDrawAfter[dir] > 0)
- {
- const int id2 = mSlots[info.mDrawAfter[dir]].spriteId;
- if (itemSlotRemap.find(id2) != itemSlotRemap.end())
- {
- const ItemInfo &info2 = ItemDB::get(id2);
- if (info.mDrawPriority[dir] < info2.mDrawPriority[dir])
- {
-// logger->log("old more priority");
- continue;
- }
- else
- {
-// logger->log("new more priority");
- itemSlotRemap.erase(id2);
- }
- }
-
- itemSlotRemap[id] = info.mDrawAfter[dir];
-// logger->log("item slot->slot %d %d->%d", id, slot, itemSlotRemap[id]);
- }
- }
-// logger->log("preparation end");
-
- int lastRemap = 0;
- unsigned cnt = 0;
-
- while (cnt < 15 && lastRemap >= 0)
- {
- lastRemap = -1;
- cnt ++;
-// logger->log("iteration");
-
- for (unsigned int slot0 = 0; slot0 < sz; slot0 ++)
- {
- const int slot = searchSlotValue(slotRemap, slot0);
- const int val = slotRemap.at(slot);
- int id = 0;
-
- if (CAST_S32(spriteIdSize) > val)
- id = mSlots[val].spriteId;
-
- int idx = -1;
- int idx1 = -1;
-// logger->log("item %d, id=%d", slot, id);
- int reorder = 0;
- const IntMapCIter orderIt = itemSlotRemap.find(id);
- if (orderIt != itemSlotRemap.end())
- reorder = orderIt->second;
-
- if (reorder < 0)
- {
-// logger->log("move item %d before %d", slot, -reorder);
- searchSlotValueItr(it, idx, slotRemap, -reorder);
- if (it == slotRemap.end())
- return;
- searchSlotValueItr(it, idx1, slotRemap, val);
- if (it == slotRemap.end())
- return;
- lastRemap = idx1;
- if (idx1 + 1 != idx)
- {
- slotRemap.erase(it);
- searchSlotValueItr(it, idx, slotRemap, -reorder);
- slotRemap.insert(it, val);
- }
- }
- else if (reorder > 0)
- {
-// logger->log("move item %d after %d", slot, reorder);
- searchSlotValueItr(it, idx, slotRemap, reorder);
- searchSlotValueItr(it, idx1, slotRemap, val);
- if (it == slotRemap.end())
- return;
- lastRemap = idx1;
- if (idx1 != idx + 1)
- {
- slotRemap.erase(it);
- searchSlotValueItr(it, idx, slotRemap, reorder);
- if (it != slotRemap.end())
- {
- ++ it;
- if (it != slotRemap.end())
- slotRemap.insert(it, val);
- else
- slotRemap.push_back(val);
- }
- else
- {
- slotRemap.push_back(val);
- }
- }
- }
- }
- }
-
-// logger->log("after remap");
- for (unsigned int slot = 0; slot < sz; slot ++)
- {
- mSpriteRemap[slot] = slotRemap[slot];
- if (mSpriteHide[slot] == 0)
- {
- if (oldHide[slot] != 0 && oldHide[slot] != 1)
- {
- const BeingSlot &beingSlot = mSlots[slot];
- const int id = beingSlot.spriteId;
- if (id == 0)
- continue;
-
- updatedSprite[slot] = true;
- setTempSprite(slot,
- id);
- }
- }
- }
- for (size_t slot = 0; slot < spriteIdSize; slot ++)
- {
- if (mSpriteHide[slot] == 0)
- {
- const BeingSlot &beingSlot = mSlots[slot];
- const int id = beingSlot.spriteId;
- if (updatedSprite[slot] == false &&
- mSpriteDraw[slot] != id)
- {
- setTempSprite(static_cast<unsigned int>(slot),
- id);
- }
- }
- }
-}
-
-int Being::searchSlotValue(const STD_VECTOR<int> &restrict slotRemap,
- const int val) const restrict2
-{
- const size_t sz = mSprites.size();
- for (size_t slot = 0; slot < sz; slot ++)
- {
- if (slotRemap[slot] == val)
- return CAST_S32(slot);
- }
- return CompoundSprite::getNumberOfLayers() - 1;
-}
-
-void Being::searchSlotValueItr(STD_VECTOR<int>::iterator &restrict it,
- int &restrict idx,
- STD_VECTOR<int> &restrict slotRemap,
- const int val)
-{
-// logger->log("searching %d", val);
- it = slotRemap.begin();
- const STD_VECTOR<int>::iterator it_end = slotRemap.end();
- idx = 0;
- while (it != it_end)
- {
-// logger->log("testing %d", *it);
- if (*it == val)
- {
-// logger->log("found at %d", idx);
- return;
- }
- ++ it;
- idx ++;
- }
-// logger->log("not found");
- idx = -1;
-}
-
-void Being::updateHit(const int amount) restrict2
-{
- if (amount > 0)
- {
- if ((mMinHit == 0) || amount < mMinHit)
- mMinHit = amount;
- if (amount != mCriticalHit && ((mMaxHit == 0) || amount > mMaxHit))
- mMaxHit = amount;
- }
-}
-
-Equipment *Being::getEquipment() restrict2
-{
- Equipment *restrict const eq = new Equipment;
- Equipment::Backend *restrict const bk = new BeingEquipBackend(this);
- eq->setBackend(bk);
- return eq;
-}
-
-void Being::undressItemById(const int id) restrict2
-{
- const size_t sz = mSlots.size();
-
- for (size_t f = 0; f < sz; f ++)
- {
- if (id == mSlots[f].spriteId)
- {
- unSetSprite(CAST_U32(f));
- break;
- }
- }
-}
-
-void Being::clearCache()
-{
- delete_all(beingInfoCache);
- beingInfoCache.clear();
-}
-
-void Being::updateComment() restrict2
-{
- if (mGotComment || mName.empty())
- return;
-
- mGotComment = true;
- mComment = loadComment(mName, mType);
-}
-
-std::string Being::loadComment(const std::string &restrict name,
- const ActorTypeT &restrict type)
-{
- std::string str;
- switch (type)
- {
- case ActorType::Player:
- str = settings.usersDir;
- break;
- case ActorType::Npc:
- str = settings.npcsDir;
- break;
- case ActorType::Unknown:
- case ActorType::Monster:
- case ActorType::FloorItem:
- case ActorType::Portal:
- case ActorType::Avatar:
- case ActorType::Mercenary:
- case ActorType::Homunculus:
- case ActorType::Pet:
- case ActorType::SkillUnit:
- case ActorType::Elemental:
- default:
- return "";
- }
-
- str = pathJoin(str, stringToHexPath(name), "comment.txt");
- if (Files::existsLocal(str))
- {
- StringVect lines;
- Files::loadTextFileLocal(str, lines);
- if (lines.size() >= 2)
- return lines[1];
- }
- return std::string();
-}
-
-void Being::saveComment(const std::string &restrict name,
- const std::string &restrict comment,
- const ActorTypeT &restrict type)
-{
- std::string dir;
- switch (type)
- {
- case ActorType::Player:
- dir = settings.usersDir;
- break;
- case ActorType::Npc:
- dir = settings.npcsDir;
- break;
- case ActorType::Monster:
- case ActorType::FloorItem:
- case ActorType::Portal:
- case ActorType::Avatar:
- case ActorType::Unknown:
- case ActorType::Pet:
- case ActorType::Mercenary:
- case ActorType::Homunculus:
- case ActorType::SkillUnit:
- case ActorType::Elemental:
- default:
- return;
- }
- dir = pathJoin(dir, stringToHexPath(name));
- Files::saveTextFile(dir,
- "comment.txt",
- (name + "\n").append(comment));
-}
-
-void Being::setState(const uint8_t state) restrict2
-{
- const bool shop = ((state & BeingFlag::SHOP) != 0);
- const bool away = ((state & BeingFlag::AWAY) != 0);
- const bool inactive = ((state & BeingFlag::INACTIVE) != 0);
- const bool needUpdate = (shop != mShop || away != mAway
- || inactive != mInactive);
-
- if (Net::getNetworkType() == ServerType::TMWATHENA)
- mShop = shop;
- mAway = away;
- mInactive = inactive;
- updateAwayEffect();
- showShopBadge(mShop);
- showInactiveBadge(mInactive);
- showAwayBadge(mAway);
-
- if (needUpdate)
- {
- if (shop || away || inactive)
- mAdvanced = true;
- updateName();
- addToCache();
- }
-}
-
-void Being::setEmote(const uint8_t emotion,
- const int emote_time) restrict2
-{
- if ((emotion & BeingFlag::SPECIAL) == BeingFlag::SPECIAL)
- {
- setState(emotion);
- mAdvanced = true;
- }
- else
- {
- const int emotionIndex = emotion - 1;
- if (emotionIndex >= 0 && emotionIndex <= EmoteDB::getLast())
- {
- delete2(mEmotionSprite)
- const EmoteInfo *const info = EmoteDB::get2(emotionIndex, true);
- if (info != nullptr)
- {
- const EmoteSprite *restrict const sprite =
- info->sprites.front();
- if (sprite != nullptr)
- {
- mEmotionSprite = AnimatedSprite::clone(sprite->sprite);
- if (mEmotionSprite != nullptr)
- mEmotionTime = info->time;
- else
- mEmotionTime = emote_time;
- }
- const int effectId = info->effectId;
- if (effectId >= 0)
- {
- effectManager->trigger(effectId, this);
- }
- }
- }
-
- if (mEmotionSprite != nullptr)
- {
- mEmotionSprite->play(mSpriteAction);
- mEmotionSprite->setSpriteDirection(mSpriteDirection);
- }
- else
- {
- mEmotionTime = 0;
- }
- }
-}
-
-void Being::updatePercentHP() restrict2
-{
- if (mMaxHP == 0)
- return;
- BLOCK_START("Being::updatePercentHP")
- if (mHP != 0)
- {
- const unsigned num = mHP * 100 / mMaxHP;
- if (num != mNumber)
- {
- mNumber = num;
- if (updateNumber(mNumber))
- setAction(mAction, 0);
- }
- }
- BLOCK_END("Being::updatePercentHP")
-}
-
-int Being::getSpriteID(const int slot) const restrict2
-{
- if (slot < 0 || CAST_SIZE(slot) >= mSlots.size())
- return -1;
-
- return mSlots[slot].spriteId;
-}
-
-const BeingSlot &Being::getSpriteSlot(const int slot) const restrict2
-{
- if (slot < 0 || CAST_SIZE(slot) >= mSlots.size())
- return *emptyBeingSlot;
-
- return mSlots[slot];
-}
-
-ItemColor Being::getSpriteColor(const int slot) const restrict2
-{
- if (slot < 0 || CAST_SIZE(slot) >= mSlots.size())
- return ItemColor_one;
-
- return mSlots[slot].colorId;
-}
-
-void Being::addAfkEffect() restrict2
-{
- addSpecialEffect(mAwayEffect);
-}
-
-void Being::removeAfkEffect() restrict2
-{
- removeSpecialEffect();
-}
-
-void Being::addSpecialEffect(const int effect) restrict2
-{
- if ((effectManager != nullptr) &&
- ParticleEngine::enabled &&
- (mSpecialParticle == nullptr) &&
- effect != -1)
- {
- mSpecialParticle = effectManager->triggerReturn(effect, this);
- }
-}
-
-void Being::removeSpecialEffect() restrict2
-{
- if ((effectManager != nullptr) && (mSpecialParticle != nullptr))
- {
- mChildParticleEffects.removeLocally(mSpecialParticle);
- mSpecialParticle = nullptr;
- }
- delete2(mAnimationEffect);
-}
-
-void Being::updateAwayEffect() restrict2
-{
- if (mAway)
- addAfkEffect();
- else
- removeAfkEffect();
-}
-
-void Being::addEffect(const std::string &restrict name) restrict2
-{
- delete mAnimationEffect;
- mAnimationEffect = AnimatedSprite::load(
- paths.getStringValue("sprites") + name);
-}
-
-void Being::playSfx(const SoundInfo &sound,
- Being *const being,
- const bool main,
- const int x, const int y) const restrict2
-{
- BLOCK_START("Being::playSfx")
-
- if (being != nullptr)
- {
- // here need add timer and delay sound
- const int time = tick_time;
- if (main)
- {
- being->mNextSound.sound = nullptr;
- being->mNextSound.time = time + sound.delay;
- soundManager.playSfx(sound.sound, x, y);
- }
- else if (mNextSound.time <= time)
- { // old event sound time is gone. we can play new sound
- being->mNextSound.sound = nullptr;
- being->mNextSound.time = time + sound.delay;
- soundManager.playSfx(sound.sound, x, y);
- }
- else
- { // old event sound in progress. need save sound and wait
- being->mNextSound.sound = &sound;
- being->mNextSound.x = x;
- being->mNextSound.y = y;
- }
- }
- else
- {
- soundManager.playSfx(sound.sound, x, y);
- }
- BLOCK_END("Being::playSfx")
-}
-
-void Being::setLook(const uint16_t look) restrict2
-{
- if (mType == ActorType::Player)
- setSubtype(mSubType, look);
-}
-
-void Being::setTileCoords(const int x, const int y) restrict2
-{
- mX = x;
- mY = y;
- if (mMap != nullptr)
- {
- mPixelOffsetY = 0;
- mFixedOffsetY = mPixelOffsetY;
- mOldHeight = mMap->getHeightOffset(mX, mY);
- mNeedPosUpdate = true;
- }
-}
-
-void Being::setMap(Map *restrict const map) restrict2
-{
- mCastEndTime = 0;
- delete2(mCastingEffect);
- ActorSprite::setMap(map);
- if (mMap != nullptr)
- {
- mPixelOffsetY = mMap->getHeightOffset(mX, mY);
- mFixedOffsetY = mPixelOffsetY;
- mOldHeight = 0;
- mNeedPosUpdate = true;
- }
-}
-
-void Being::removeAllItemsParticles() restrict2
-{
- FOR_EACH (SpriteParticleInfoIter, it, mSpriteParticles)
- delete (*it).second;
- mSpriteParticles.clear();
-}
-
-void Being::addItemParticles(const int id,
- const SpriteDisplay &restrict display) restrict2
-{
- const SpriteParticleInfoIter it = mSpriteParticles.find(id);
- ParticleInfo *restrict pi = nullptr;
- if (it == mSpriteParticles.end())
- {
- pi = new ParticleInfo;
- mSpriteParticles[id] = pi;
- }
- else
- {
- pi = (*it).second;
- }
-
- if ((pi == nullptr) || !pi->particles.empty())
- return;
-
- // setup particle effects
- if (ParticleEngine::enabled &&
- (particleEngine != nullptr))
- {
- FOR_EACH (StringVectCIter, itr, display.particles)
- {
- Particle *const p = particleEngine->addEffect(*itr, 0, 0);
- controlCustomParticle(p);
- pi->files.push_back(*itr);
- pi->particles.push_back(p);
- }
- }
- else
- {
- FOR_EACH (StringVectCIter, itr, display.particles)
- pi->files.push_back(*itr);
- }
-}
-
-void Being::addItemParticlesCards(const int id,
- const SpriteDisplay &restrict display,
- const CardsList &cards) restrict2
-{
- const SpriteParticleInfoIter it = mSpriteParticles.find(id);
- ParticleInfo *restrict pi = nullptr;
- if (it == mSpriteParticles.end())
- {
- pi = new ParticleInfo;
- mSpriteParticles[id] = pi;
- }
- else
- {
- pi = (*it).second;
- }
-
- if ((pi == nullptr) || !pi->particles.empty())
- return;
-
- // setup particle effects
- if (ParticleEngine::enabled &&
- (particleEngine != nullptr))
- {
- FOR_EACH (StringVectCIter, itr, display.particles)
- {
- Particle *const p = particleEngine->addEffect(*itr, 0, 0);
- controlCustomParticle(p);
- pi->files.push_back(*itr);
- pi->particles.push_back(p);
- }
- for (int f = 0; f < maxCards; f ++)
- {
- const int cardId = cards.cards[f];
- if (!Item::isItem(cardId))
- continue;
- const ItemInfo &info = ItemDB::get(cardId);
- const SpriteDisplay &restrict display2 = info.getDisplay();
- FOR_EACH (StringVectCIter, itr, display2.particles)
- {
- Particle *const p = particleEngine->addEffect(*itr, 0, 0);
- controlCustomParticle(p);
- pi->files.push_back(*itr);
- pi->particles.push_back(p);
- }
- }
- }
- else
- {
- FOR_EACH (StringVectCIter, itr, display.particles)
- {
- pi->files.push_back(*itr);
- }
- for (int f = 0; f < maxCards; f ++)
- {
- const int cardId = cards.cards[f];
- if (!Item::isItem(cardId))
- continue;
- const ItemInfo &info = ItemDB::get(cardId);
- const SpriteDisplay &restrict display2 = info.getDisplay();
- FOR_EACH (StringVectCIter, itr, display2.particles)
- {
- pi->files.push_back(*itr);
- }
- }
- }
-}
-
-void Being::removeItemParticles(const int id) restrict2
-{
- const SpriteParticleInfoIter it = mSpriteParticles.find(id);
- if (it == mSpriteParticles.end())
- return;
- ParticleInfo *restrict const pi = (*it).second;
- if (pi != nullptr)
- {
- FOR_EACH (STD_VECTOR<Particle*>::const_iterator, itp, pi->particles)
- mChildParticleEffects.removeLocally(*itp);
- delete pi;
- }
- mSpriteParticles.erase(it);
-}
-
-void Being::recreateItemParticles() restrict2
-{
- FOR_EACH (SpriteParticleInfoIter, it, mSpriteParticles)
- {
- ParticleInfo *restrict const pi = (*it).second;
- if ((pi != nullptr) && !pi->files.empty())
- {
- FOR_EACH (STD_VECTOR<Particle*>::const_iterator,
- itp, pi->particles)
- {
- mChildParticleEffects.removeLocally(*itp);
- }
-
- FOR_EACH (STD_VECTOR<std::string>::const_iterator, str, pi->files)
- {
- Particle *const p = particleEngine->addEffect(
- *str, 0, 0);
- controlCustomParticle(p);
- pi->particles.push_back(p);
- }
- }
- }
-}
-
-void Being::setTeamId(const uint16_t teamId) restrict2
-{
- if (mTeamId != teamId)
- {
- mTeamId = teamId;
- showTeamBadge(mTeamId != 0);
- updateColors();
- }
-}
-
-void Being::showTeamBadge(const bool show) restrict2
-{
- delete2(mBadges[BadgeIndex::Team]);
- if (show &&
- mTeamId != 0u &&
- mShowBadges != BadgeDrawType::Hide)
- {
- const std::string name = paths.getStringValue("badges") +
- paths.getStringValue(strprintf("team%dbadge",
- mTeamId));
- if (!name.empty())
- mBadges[BadgeIndex::Team] = AnimatedSprite::load(name);
- }
- updateBadgesCount();
- updateBadgesPosition();
-}
-
-void Being::showBadges(const bool show) restrict2
-{
- showTeamBadge(show);
- showGuildBadge(show);
- showGmBadge(show);
- showPartyBadge(show);
- showNameBadge(show);
- showShopBadge(show);
- showInactiveBadge(show);
- showAwayBadge(show);
-}
-
-void Being::showPartyBadge(const bool show) restrict2
-{
- delete2(mBadges[BadgeIndex::Party]);
- if (show &&
- !mPartyName.empty() &&
- mShowBadges != BadgeDrawType::Hide)
- {
- const std::string badge = BadgesDB::getPartyBadge(mPartyName);
- if (!badge.empty())
- {
- mBadges[BadgeIndex::Party] = AnimatedSprite::load(
- paths.getStringValue("badges") + badge);
- }
- }
- updateBadgesCount();
- updateBadgesPosition();
-}
-
-
-void Being::setPartyName(const std::string &restrict name) restrict2
-{
- if (mPartyName != name)
- {
- mPartyName = name;
- showPartyBadge(!mPartyName.empty());
- }
-}
-
-void Being::showShopBadge(const bool show) restrict2
-{
- delete2(mBadges[BadgeIndex::Shop]);
- if (show &&
- mShop &&
- mShowBadges != BadgeDrawType::Hide)
- {
- const std::string badge = paths.getStringValue("shopbadge");
- if (!badge.empty())
- {
- mBadges[BadgeIndex::Shop] = AnimatedSprite::load(
- paths.getStringValue("badges") + badge);
- }
- }
- updateBadgesCount();
- updateBadgesPosition();
-}
-
-void Being::showInactiveBadge(const bool show) restrict2
-{
- delete2(mBadges[BadgeIndex::Inactive]);
- if (show &&
- mInactive &&
- mShowBadges != BadgeDrawType::Hide)
- {
- const std::string badge = paths.getStringValue("inactivebadge");
- if (!badge.empty())
- {
- mBadges[BadgeIndex::Inactive] = AnimatedSprite::load(
- paths.getStringValue("badges") + badge);
- }
- }
- updateBadgesCount();
- updateBadgesPosition();
-}
-
-void Being::showAwayBadge(const bool show) restrict2
-{
- delete2(mBadges[BadgeIndex::Away]);
- if (show &&
- mAway &&
- mShowBadges != BadgeDrawType::Hide)
- {
- const std::string badge = paths.getStringValue("awaybadge");
- if (!badge.empty())
- {
- mBadges[BadgeIndex::Away] = AnimatedSprite::load(
- paths.getStringValue("badges") + badge);
- }
- }
- updateBadgesCount();
- updateBadgesPosition();
-}
-
-void Being::updateBadgesCount() restrict2
-{
- mBadgesCount = 0;
- for_each_badges()
- {
- if (mBadges[f] != nullptr)
- mBadgesCount ++;
- }
-}
-
-void Being::setChat(ChatObject *restrict const obj) restrict2
-{
- delete mChat;
- mChat = obj;
-}
-
-void Being::setSellBoard(const std::string &restrict text) restrict2
-{
- mShop = !text.empty() || !mBuyBoard.empty();
- mSellBoard = text;
- updateName();
- showShopBadge(mShop);
-}
-
-void Being::setBuyBoard(const std::string &restrict text) restrict2
-{
- mShop = !text.empty() || !mSellBoard.empty();
- mBuyBoard = text;
- updateName();
- showShopBadge(mShop);
-}
-
-void Being::enableShop(const bool b) restrict2
-{
- mShop = b;
- updateName();
- showShopBadge(mShop);
-}
-
-bool Being::isBuyShopEnabled() const restrict2
-{
- return mShop && (Net::getNetworkType() == ServerType::TMWATHENA ||
- !mBuyBoard.empty());
-}
-
-bool Being::isSellShopEnabled() const restrict2
-{
- return mShop && (Net::getNetworkType() == ServerType::TMWATHENA ||
- !mSellBoard.empty());
-}
-
-void Being::serverRemove() restrict2 noexcept2
-{
- // remove some flags what can survive player remove and next visible
- mTrickDead = false;
-}
-
-void Being::addCast(const int dstX,
- const int dstY,
- const int skillId,
- const int skillLevel,
- const int range,
- const int waitTimeTicks)
-{
- if (waitTimeTicks <= 0)
- {
- mCastEndTime = 0;
- return;
- }
- mCastEndTime = tick_time + waitTimeTicks;
- SkillData *const data = skillDialog->getSkillDataByLevel(
- skillId,
- skillLevel);
- delete2(mCastingEffect);
- if (data != nullptr)
- {
- const std::string castingAnimation = data->castingAnimation;
- mCastingEffect = new CastingEffect(skillId,
- skillLevel,
- castingAnimation,
- dstX,
- dstY,
- range);
- mCastingEffect->setMap(mMap);
- }
- else
- {
- reportAlways("Want to draw casting for unknown skill %d",
- skillId);
- }
-}
-
-void Being::removeHorse() restrict2
-{
- delete_all(mUpHorseSprites);
- mUpHorseSprites.clear();
- delete_all(mDownHorseSprites);
- mDownHorseSprites.clear();
-}
-
-void Being::setRiding(const bool b) restrict2
-{
- if (serverFeatures->haveExtendedRiding())
- return;
-
- if (b == (mHorseId != 0))
- return;
- if (b)
- setHorse(1);
- else
- setHorse(0);
-}
-
-void Being::setHorse(const int horseId) restrict2
-{
- if (mHorseId == horseId)
- return;
- mHorseId = horseId;
- setAction(mAction, 0);
- removeHorse();
- if (mHorseId != 0)
- {
- mHorseInfo = HorseDB::get(horseId);
- if (mHorseInfo != nullptr)
- {
- FOR_EACH (SpriteRefs, it, mHorseInfo->downSprites)
- {
- const SpriteReference *restrict const ref = *it;
- AnimatedSprite *const sprite = AnimatedSprite::load(
- ref->sprite,
- ref->variant);
- mDownHorseSprites.push_back(sprite);
- sprite->play(mSpriteAction);
- sprite->setSpriteDirection(mSpriteDirection);
- }
- FOR_EACH (SpriteRefs, it, mHorseInfo->upSprites)
- {
- const SpriteReference *restrict const ref = *it;
- AnimatedSprite *const sprite = AnimatedSprite::load(
- ref->sprite,
- ref->variant);
- mUpHorseSprites.push_back(sprite);
- sprite->play(mSpriteAction);
- sprite->setSpriteDirection(mSpriteDirection);
- }
- }
- }
- else
- {
- mHorseInfo = nullptr;
- }
-}
-
-void Being::setTrickDead(const bool b) restrict2
-{
- if (b != mTrickDead)
- {
- mTrickDead = b;
- setAction(mAction, 0);
- }
-}
-
-void Being::setSpiritBalls(const unsigned int balls) restrict2
-{
- if (!ParticleEngine::enabled)
- {
- mSpiritBalls = balls;
- return;
- }
-
- if (balls > mSpiritBalls)
- {
- const int effectId = paths.getIntValue("spiritEffectId");
- if (effectId != -1)
- addSpiritBalls(balls - mSpiritBalls, effectId);
- }
- else if (balls < mSpiritBalls)
- {
- removeSpiritBalls(mSpiritBalls - balls);
- }
- mSpiritBalls = balls;
-}
-
-void Being::addSpiritBalls(const unsigned int balls,
- const int effectId) restrict2
-{
- if (effectManager == nullptr)
- return;
- for (unsigned int f = 0; f < balls; f ++)
- {
- Particle *const particle = effectManager->triggerReturn(
- effectId,
- this);
- mSpiritParticles.push_back(particle);
- }
-}
-
-void Being::removeSpiritBalls(const unsigned int balls) restrict2
-{
- if (particleEngine == nullptr)
- return;
- for (unsigned int f = 0; f < balls && !mSpiritParticles.empty(); f ++)
- {
- const Particle *restrict const particle = mSpiritParticles.back();
- mChildParticleEffects.removeLocally(particle);
- mSpiritParticles.pop_back();
- }
-}
-
-void Being::stopCast(const bool b)
-{
- if (b && mAction == BeingAction::CAST)
- setAction(BeingAction::STAND, 0);
-}
-
-void Being::fixDirectionOffsets(int &offsetX,
- int &offsetY) const
-{
- const uint8_t dir = mDirection;
- if ((dir & BeingDirection::DOWN) != 0)
- {
- // do nothing
- }
- else if ((dir & BeingDirection::UP) != 0)
- {
- offsetX = -offsetX;
- offsetY = -offsetY;
- }
- else if ((dir & BeingDirection::LEFT) != 0)
- {
- const int tmp = offsetY;
- offsetY = offsetX;
- offsetX = -tmp;
- }
- else if ((dir & BeingDirection::RIGHT) != 0)
- {
- const int tmp = offsetY;
- offsetY = -offsetX;
- offsetX = tmp;
- }
-}
-
-void Being::setLanguageId(const int lang) restrict2 noexcept2
-{
- if (lang != mLanguageId)
- {
- delete2(mBadges[BadgeIndex::Lang]);
- const std::string &badge = LanguageDb::getIcon(lang);
- if (!badge.empty())
- {
- mBadges[BadgeIndex::Lang] = AnimatedSprite::load(pathJoin(
- paths.getStringValue("languageIcons"),
- badge));
- }
-
- mLanguageId = lang;
- }
- updateBadgesCount();
- updateBadgesPosition();
-}
-
-Being *Being::createBeing(const BeingId id,
- const ActorTypeT type,
- const BeingTypeId subType,
- Map *const map)
-{
- Being *const being = new Being(id,
- type);
- being->postInit(subType,
- map);
- return being;
-}
diff --git a/src/being/being.h b/src/being/being.h
deleted file mode 100644
index 0ca1ce780..000000000
--- a/src/being/being.h
+++ /dev/null
@@ -1,1375 +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 BEING_BEING_H
-#define BEING_BEING_H
-
-#include "position.h"
-
-#include "enums/being/badgeindex.h"
-#include "enums/being/reachable.h"
-
-#include "enums/gui/usercolorid.h"
-
-#include "enums/simpletypes/move.h"
-
-#include "enums/being/visiblenamepos.h"
-
-#include "resources/beinginfo.h"
-#include "resources/beingslot.h"
-
-#include "being/actorsprite.h"
-
-#include "enums/being/attacktype.h"
-#include "enums/being/badgedrawtype.h"
-#include "enums/being/beingaction.h"
-#include "enums/being/gender.h"
-
-#include "listeners/configlistener.h"
-
-#include "localconsts.h"
-
-static const int DEFAULT_BEING_WIDTH = 32;
-static const int DEFAULT_BEING_HEIGHT = 32;
-
-class AnimatedSprite;
-class BeingCacheEntry;
-class CastingEffect;
-class Color;
-class Equipment;
-class FlashText;
-class Guild;
-class ItemInfo;
-class Particle;
-class Party;
-class SpeechBubble;
-class Text;
-
-struct ChatObject;
-struct HorseInfo;
-struct MissileInfo;
-struct SkillInfo;
-struct ParticleInfo;
-
-extern volatile time_t cur_time;
-
-struct NextSoundInfo final
-{
- NextSoundInfo() noexcept2 :
- sound(nullptr),
- x(0),
- y(0),
- time(0)
- {
- }
-
- A_DELETE_COPY(NextSoundInfo)
-
- const SoundInfo *sound;
- int x;
- int y;
- int time;
-};
-
-class Being notfinal : public ActorSprite,
- public ConfigListener
-{
- public:
- friend class ActorManager;
- friend class BeingEquipBackend;
- friend class LocalPlayer;
-
- /**
- * Constructor.
- *
- * @param id a unique being id
- * @param subtype partly determines the type of the being
- * @param map the map the being is on
- */
- Being(const BeingId id,
- const ActorTypeT type);
-
- A_DELETE_COPY(Being)
-
- virtual ~Being();
-
- ActorTypeT getType() const restrict2 noexcept2 override final
- A_WARN_UNUSED
- { return mType; }
-
- /**
- * Removes all path nodes from this being.
- */
- void clearPath() restrict2;
-
- /**
- * Returns the time spent in the current action.
- */
- int getActionTime() const restrict2 noexcept2 A_WARN_UNUSED
- { return mActionTime; }
-
- /**
- * Set the current action time.
- * @see Ea::BeingHandler that set it to tick time.
- */
- void setActionTime(const int actionTime) restrict2 noexcept2
- { mActionTime = actionTime; }
-
- /**
- * Makes this being take the next tile of its path.
- */
- virtual void nextTile() restrict2;
-
- /**
- * Creates a path for the being from current position to ex and ey
- */
- void setDestination(const int dstX,
- const int dstY) restrict2;
-
- void setCachedDestination(const int dstX,
- const int dstY) restrict2 noexcept2
- { mCachedX = dstX; mCachedY = dstY; }
-
- int getCachedX() const noexcept2 A_WARN_UNUSED
- { return mCachedX; }
-
- int getCachedY() const noexcept2 A_WARN_UNUSED
- { return mCachedY; }
-
- /**
- * Returns the destination for this being.
- */
- const Vector &getDestination() const restrict2 noexcept2 A_WARN_UNUSED
- { return mDest; }
-
- /**
- * Returns the tile x coord
- */
- int getTileX() const restrict2 noexcept2 override A_WARN_UNUSED
- { return mX; }
-
- /**
- * Returns the tile y coord
- */
- int getTileY() const restrict2 noexcept2 override A_WARN_UNUSED
- { return mY; }
-
- /**
- * Sets the tile x and y coord
- */
- void setTileCoords(const int x, const int y) restrict2;
-
- /**
- * Puts a "speech balloon" above this being for the specified amount
- * of time.
- *
- * @param text The text that should appear.
- * @param time The amount of time the text should stay in milliseconds.
- */
- void setSpeech(const std::string &restrict text,
- const std::string &restrict channel = "",
- int time = 0) restrict2;
-
- /**
- * Puts a damage bubble above this being.
- *
- * @param attacker the attacking being
- * @param amount the amount of damage recieved (0 means miss)
- * @param type the attack type
- * @param attackId the attack id
- * @param level the skill level
- */
- void takeDamage(Being *restrict const attacker,
- const int amount,
- const AttackTypeT type,
- const int attackId = 1,
- const int level = 1) restrict2;
-
- /**
- * Handles an attack of another being by this being.
- *
- * @param victim the victim being
- * @param damage the amount of damage dealt (0 means miss)
- * @param attackId the attack id
- */
- void handleAttack(Being *restrict const victim,
- const int damage,
- const int attackId = 1) restrict2;
-
- void handleSkillCasting(Being *restrict const victim,
- const int skillId,
- const int skillLevel) restrict2;
-
- void handleSkill(Being *restrict const victim,
- const int damage,
- const int skillId,
- const int skillLevel) restrict2;
-
- const ItemInfo *getEquippedWeapon() const restrict2 A_WARN_UNUSED
- { return mEquippedWeapon; }
-
- /**
- * Returns the name of the being.
- */
- const std::string &getName() const restrict2 noexcept2 A_WARN_UNUSED
- { return mName; }
-
- const std::string &getExtName() const restrict2 noexcept2 A_WARN_UNUSED
- { return mExtName; }
-
- /**
- * Sets the name for the being.
- *
- * @param name The name that should appear.
- */
- void setName(const std::string &restrict name) restrict2;
-
- bool getShowName() const noexcept2 A_WARN_UNUSED
- { return mShowName; }
-
- void setShowName(const bool doShowName) restrict2;
-
- /**
- * Sets the name of the party the being is in. Shown in BeingPopup.
- */
- void setPartyName(const std::string &restrict name) restrict2;
-
- const std::string &getPartyName() const restrict2 noexcept2
- A_WARN_UNUSED
- { return mPartyName; }
-
- const std::string &getGuildName() const restrict2 noexcept2
- A_WARN_UNUSED
- { return mGuildName; }
-
- /**
- * Sets the name of the primary guild the being is in. Shown in
- * BeingPopup (eventually).
- */
- void setGuildName(const std::string &restrict name) restrict2;
-
- void setGuildPos(const std::string &restrict pos) restrict2 A_CONST;
-
- /**
- * Adds a guild to the being.
- */
- void addGuild(Guild *restrict const guild) restrict2;
-
- /**
- * Removers a guild from the being.
- */
- void removeGuild(const int id) restrict2;
-
- /**
- * Returns a pointer to the specified guild that the being is in.
- */
- const Guild *getGuild(const std::string &restrict guildName)
- const restrict2 A_WARN_UNUSED;
-
- /**
- * Returns a pointer to the specified guild that the being is in.
- */
- const Guild *getGuild(const int id) const restrict2 A_WARN_UNUSED;
-
- /**
- * Returns a pointer to the specified guild that the being is in.
- */
- Guild *getGuild() const restrict2 A_WARN_UNUSED;
-
- /**
- * Returns all guilds the being is in.
- */
- const std::map<int, Guild*> &getGuilds() const restrict2 noexcept2
- A_WARN_UNUSED
- { return mGuilds; }
-
- /**
- * Removes all guilds the being is in.
- */
- void clearGuilds() restrict2;
-
- /**
- * Get number of guilds the being belongs to.
- */
- int16_t getNumberOfGuilds() const restrict2 A_WARN_UNUSED
- { return CAST_S16(mGuilds.size()); }
-
- bool isInParty() const restrict2 noexcept2 A_WARN_UNUSED
- { return mParty != nullptr; }
-
- void setParty(Party *restrict const party) restrict2;
-
- void setGuild(Guild *restrict const guild) restrict2;
-
- void updateGuild() restrict2;
-
- Party *getParty() const restrict2 noexcept2 A_WARN_UNUSED
- { return mParty; }
-
- void setSprite(const unsigned int slot,
- const int id,
- std::string color,
- ItemColor colorId) restrict2;
-
- void setSpriteColor(const unsigned int slot,
- const int id,
- const std::string &color) restrict2;
-
- void setSpriteColorId(const unsigned int slot,
- const int id,
- ItemColor colorId) restrict2;
-
- void setSpriteCards(const unsigned int slot,
- const int id,
- const CardsList &restrict cards) restrict2;
-
- void setSpriteId(const unsigned int slot,
- const int id) restrict2;
-
- void unSetSprite(const unsigned int slot) restrict2;
-
- void setWeaponId(const int id) restrict2;
-
- void setTempSprite(const unsigned int slot,
- const int id) restrict2;
-
- void setHairTempSprite(const unsigned int slot,
- const int id) restrict2;
-
- void updateSprite(const unsigned int slot,
- const int id,
- const std::string &restrict color = "")
- restrict2;
-
- void setHairColorSpriteID(const unsigned int slot,
- const int id) restrict2;
-
- void setSpriteColor(const unsigned int slot,
- const std::string &restrict color = "") restrict2;
-
- /**
- * Get the number of layers used to draw the being
- */
- int getNumberOfLayers() const restrict2 override A_WARN_UNUSED
- { return CompoundSprite::getNumberOfLayers(); }
-
- /**
- * Performs being logic.
- */
- void logic() restrict2 override;
-
- void botLogic() restrict2;
-
- /**
- * Draws the speech text above the being.
- */
- void drawSpeech(const int offsetX,
- const int offsetY) restrict2;
-
- /**
- * Draws the emotion picture above the being.
- */
- void drawEmotion(Graphics *restrict const graphics,
- const int offsetX,
- const int offsetY) const restrict2 A_NONNULL(2);
-
- BeingTypeId getSubType() const restrict2 noexcept2 A_WARN_UNUSED
- { return mSubType; }
-
- /**
- * Set Being's subtype (mostly for view for monsters and NPCs)
- */
- void setSubtype(const BeingTypeId subtype,
- const uint16_t look) restrict2;
-
- const BeingInfo *getInfo() const restrict2 noexcept2 A_WARN_UNUSED
- { return mInfo; }
-
- TargetCursorSizeT getTargetCursorSize() const restrict2 override final
- A_WARN_UNUSED;
-
- int getTargetOffsetX() const restrict2 override A_WARN_UNUSED
- {
- if (mInfo == nullptr)
- return 0;
- return mInfo->getTargetOffsetX();
- }
-
- int getTargetOffsetY() const restrict2 override A_WARN_UNUSED
- {
- if (mInfo == nullptr)
- return 0;
- return mInfo->getTargetOffsetY();
- }
-
- /**
- * Gets the way the object is blocked by other objects.
- */
- virtual unsigned char getBlockWalkMask() const restrict2 A_WARN_UNUSED
- {
- if (mInfo == nullptr)
- return 0;
- return mInfo->getBlockWalkMask();
- }
-
- /**
- * Gets the way the monster blocks pathfinding for other objects
- */
- BlockTypeT getBlockType() const restrict2 override A_WARN_UNUSED
- {
- if (mInfo == nullptr)
- return BlockType::NONE;
- return mInfo->getBlockType();
- }
-
- /**
- * Sets the walk speed in pixels per second.
- */
- void setWalkSpeed(const int speed) restrict2
- { mWalkSpeed = speed; mSpeed = speed; }
-
- /**
- * Gets the walk speed in pixels per second.
- */
- int getWalkSpeed() const restrict2 noexcept2 A_WARN_UNUSED
- { return mWalkSpeed; }
-
- /**
- * Sets the attack speed.
- */
- void setAttackSpeed(const int speed) restrict2 noexcept2
- { mAttackSpeed = speed; }
-
- /**
- * Gets the attack speed.
- */
- int getAttackSpeed() const restrict2 noexcept2 A_WARN_UNUSED
- { return mAttackSpeed; }
-
- /**
- * Sets the current action.
- */
- virtual void setAction(const BeingActionT &restrict action,
- const int attackId) restrict2;
-
- /**
- * Get the being's action currently performed.
- */
- BeingActionT getCurrentAction() const restrict2 noexcept2 A_WARN_UNUSED
- { return mAction; }
-
- /**
- * Returns whether this being is still alive.
- */
- bool isAlive() const restrict2 noexcept2 A_WARN_UNUSED
- { return mAction != BeingAction::DEAD; }
-
- /**
- * Returns the current direction.
- */
- uint8_t getDirection() const restrict2 noexcept2 A_WARN_UNUSED
- { return mDirection; }
-
- /**
- * Sets the current direction.
- */
- virtual void setDirection(const uint8_t direction) restrict2;
-
- void setDirectionDelayed(const uint8_t direction) restrict2 noexcept2
- { mDirectionDelayed = direction; }
-
- uint8_t getDirectionDelayed() const restrict2 noexcept2 A_WARN_UNUSED
- { return mDirectionDelayed; }
-
- /**
- * Returns the direction the being is facing.
- */
- SpriteDirection::Type getSpriteDirection() const restrict2 noexcept2
- A_WARN_UNUSED
- { return mSpriteDirection; }
-
- void setPixelPositionF(const Vector &restrict pos) restrict2 override;
-
- /**
- * Overloaded method provided for convenience.
- *
- * @see setPosition(const Vector &pos)
- */
- inline void setPixelPositionF(const float x,
- const float y,
- const float z = 0.0F) restrict2 A_INLINE
- { setPixelPositionF(Vector(x, y, z)); }
-
- /**
- * Returns the horizontal size of the current base sprite of the being.
- */
- int getWidth() const restrict2 override final A_WARN_UNUSED
- { return std::max(CompoundSprite::getWidth(), DEFAULT_BEING_WIDTH); }
-
- /**
- * Returns the vertical size of the current base sprite of the being.
- */
- int getHeight() const restrict2 override final A_WARN_UNUSED
- { return std::max(CompoundSprite::getHeight(), DEFAULT_BEING_HEIGHT); }
-
- /**
- * Shoots a missile particle from this being, to target being
- */
- void fireMissile(Being *restrict const victim,
- const MissileInfo &restrict missile) const restrict2;
-
- /**
- * Returns the path this being is following. An empty path is returned
- * when this being isn't following any path currently.
- */
- const Path &getPath() const restrict2 noexcept2 A_WARN_UNUSED
- { return mPath; }
-
- int getDistance() const restrict2 noexcept2 A_WARN_UNUSED
- { return mDistance; }
-
- void setDistance(const int n) restrict2 noexcept2
- { mDistance = n; }
-
- /**
- * Set the Emoticon type and time displayed above
- * the being.
- */
- void setEmote(const uint8_t emotion,
- const int emote_time) restrict2;
-
- void setState(const uint8_t state) restrict2;
-
- void drawPlayerSprites(Graphics *restrict const graphics,
- const int posX,
- const int posY) const
- restrict2 A_NONNULL(2);
-
- void drawSpritesSDL(Graphics *restrict const graphics,
- const int posX,
- const int posY) const
- restrict2 override final A_NONNULL(2);
-
- void drawHpBar(Graphics *restrict const graphics,
- const int maxHP,
- const int hp,
- const int damage,
- const UserColorIdT color1,
- const UserColorIdT color2,
- const int x,
- const int y,
- const int width,
- const int height) const restrict2 A_NONNULL(2);
-
- void optionChanged(const std::string &restrict value)
- restrict2 override;
-
- void flashName(const int time) restrict2;
-
- int getDamageTaken() const restrict2 noexcept2 A_WARN_UNUSED
- { return mDamageTaken; }
-
- void setDamageTaken(const int damage) restrict2 noexcept2
- { mDamageTaken = damage; }
-
- void updateName() restrict2;
-
- void setLevel(const int n) restrict2 noexcept2
- { mLevel = n; }
-
- virtual int getLevel() const restrict2 A_WARN_UNUSED
- { return mLevel; }
-
- void setReachable(const ReachableT n) restrict2 noexcept2
- { mReachable = n; }
-
- ReachableT getReachable() const restrict2 noexcept2 A_WARN_UNUSED
- { return mReachable; }
-
- static void reReadConfig();
-
- static BeingCacheEntry* getCacheEntry(const BeingId id) A_WARN_UNUSED;
-
- void addToCache() const restrict2;
-
- bool updateFromCache() restrict2;
-
- /**
- * Sets the gender of this being.
- */
- virtual void setGender(const GenderT gender) restrict2;
-
- GenderT getGender() const restrict2 noexcept2 A_WARN_UNUSED
- { return mGender; }
-
- /**
- * Return sprite sit action for current environment.
- */
- std::string getSitAction() const restrict2 A_WARN_UNUSED;
-
- std::string getCastAction() const restrict2 A_WARN_UNUSED;
-
- std::string getCastAction(const SkillInfo *restrict const skill) const
- restrict2 A_WARN_UNUSED;
-
- std::string getMoveAction() const restrict2 A_WARN_UNUSED;
-
- std::string getDeadAction() const restrict2 A_WARN_UNUSED;
-
- std::string getStandAction() const restrict2 A_WARN_UNUSED;
-
- std::string getSpawnAction() const restrict2 A_WARN_UNUSED;
-
- std::string getWeaponAttackAction(const ItemInfo *restrict const
- weapon) const
- restrict2 A_WARN_UNUSED;
-
- std::string getAttackAction() const restrict2 A_WARN_UNUSED;
-
- std::string getAttackAction(const Attack *restrict const attack1) const
- restrict2 A_WARN_UNUSED;
-
- /**
- * Whether or not this player is a GM.
- */
- bool isGM() const restrict2 noexcept2 A_WARN_UNUSED
- { return mIsGM; }
-
- /**
- * Triggers whether or not to show the name as a GM name.
- */
- void setGM(const bool gm) restrict2;
-
- bool canTalk() const restrict2 noexcept2 A_WARN_UNUSED
- { return mType == ActorType::Npc; }
-
- void talkTo() const restrict2;
-
- void draw(Graphics *restrict const graphics,
- const int offsetX,
- const int offsetY) const
- restrict2 override final A_NONNULL(2);
-
- void drawPlayer(Graphics *restrict const graphics,
- const int offsetX,
- const int offsetY) const
- restrict2 A_NONNULL(2);
-
- void drawOther(Graphics *restrict const graphics,
- const int offsetX,
- const int offsetY) const
- restrict2 A_NONNULL(2);
-
- void drawMonster(Graphics *restrict const graphics,
- const int offsetX,
- const int offsetY) const
- restrict2 A_NONNULL(2);
-
- void drawPortal(Graphics *restrict const graphics,
- const int offsetX,
- const int offsetY) const
- restrict2 A_NONNULL(2);
-
- void drawBasic(Graphics *restrict const graphics,
- const int x,
- const int y) const restrict2 A_NONNULL(2);
-
- void setMoveTime() restrict2 noexcept2
- { mMoveTime = cur_time; }
-
- void setAttackTime() restrict2 noexcept2
- { mAttackTime = cur_time; }
-
- void setTalkTime() restrict2 noexcept2
- { mTalkTime = cur_time; }
-
- void setTestTime() restrict2 noexcept2
- { mTestTime = cur_time; }
-
- void setOtherTime() restrict2 noexcept2
- { mOtherTime = cur_time; }
-
- time_t getMoveTime() const restrict2 noexcept2
- { return mMoveTime; }
-
- time_t getAttackTime() const restrict2 noexcept2
- { return mAttackTime; }
-
- time_t getTalkTime() const restrict2 noexcept2
- { return mTalkTime; }
-
- time_t getTestTime() const restrict2 noexcept2
- { return mTestTime; }
-
- time_t getOtherTime() const restrict2 noexcept2
- { return mOtherTime; }
-
- void resetCounters() restrict2;
-
- void updateColors() restrict2;
-
- void setEnemy(const bool n) restrict2 noexcept2
- { mEnemy = n; }
-
- const std::string &getIp() const restrict2 noexcept2 A_WARN_UNUSED
- { return mIp; }
-
- void setIp(const std::string &restrict ip) restrict2 noexcept2
- { mIp = ip; }
-
- unsigned int getPvpRank() const restrict2 noexcept2 A_WARN_UNUSED
- { return mPvpRank; }
-
- void setPvpRank(const unsigned int rank) restrict2 noexcept2
- { mPvpRank = rank; }
-
- void setHP(const int hp) restrict2;
-
- void setMaxHP(const int hp) restrict2;
-
- int getHP() const restrict2 noexcept2 A_WARN_UNUSED
- { return mHP; }
-
- int getMaxHP() const restrict2 noexcept2 A_WARN_UNUSED
- { return mMaxHP; }
-
- uint8_t calcDirection(const int dstX,
- const int dstY) const restrict2 A_WARN_UNUSED;
-
- uint8_t calcDirection() const restrict2 A_WARN_UNUSED;
-
- void setAttackDelay(const int n) restrict2 noexcept2
- { mAttackDelay = n; }
-
- int getAttackDelay() const restrict2 noexcept2 A_WARN_UNUSED
- { return mAttackDelay; }
-
- int getMinHit() const restrict2 noexcept2 A_WARN_UNUSED
- { return mMinHit; }
-
- void setMinHit(const int n) restrict2 noexcept2
- { mMinHit = n; }
-
- int getMaxHit() const restrict2 noexcept2 A_WARN_UNUSED
- { return mMaxHit; }
-
- void setMaxHit(const int n) restrict2 noexcept2
- { mMaxHit = n; }
-
- int getCriticalHit() const restrict2 A_WARN_UNUSED
- { return mCriticalHit; }
-
- void setCriticalHit(const int n) restrict2 noexcept2
- { mCriticalHit = n; }
-
- void updateHit(const int amount) restrict2;
-
- Equipment *getEquipment() restrict2 A_WARN_UNUSED;
-
- void undressItemById(const int id) restrict2;
-
- int getGoodStatus() const restrict2 noexcept2 A_WARN_UNUSED
- { return mGoodStatus; }
-
- void setGoodStatus(const int n) restrict2 noexcept2
- { mGoodStatus = n; }
-
- std::string getGenderSign() const restrict2 A_WARN_UNUSED;
-
- std::string getGenderSignWithSpace() const restrict2 A_WARN_UNUSED;
-
- void updateComment() restrict2;
-
- const std::string getComment() const restrict2 noexcept2 A_WARN_UNUSED
- { return mComment; }
-
- void setComment(const std::string &restrict n) restrict2 noexcept2
- { mComment = n; }
-
- static void clearCache();
-
- static std::string loadComment(const std::string &restrict name,
- const ActorTypeT &restrict type)
- A_WARN_UNUSED;
-
- static void saveComment(const std::string &restrict name,
- const std::string &restrict comment,
- const ActorTypeT &restrict type);
-
- bool isAdvanced() const restrict2 noexcept2 A_WARN_UNUSED
- { return mAdvanced; }
-
- void setAdvanced(const bool n) restrict2
- { mAdvanced = n; addToCache(); }
-
- bool isBuyShopEnabled() const restrict2 A_WARN_UNUSED;
-
- bool isSellShopEnabled() const restrict2 A_WARN_UNUSED;
-
- void enableShop(const bool b) restrict2;
-
- /**
- * Sets the attack range.
- */
- void setAttackRange(const int range) restrict2 noexcept2
- { mAttackRange = range; }
-
-/*
- void attack(Being *restrict target = nullptr,
- bool keep = false,
- bool dontChangeEquipment = false) restrict2;
-
- void attack2(Being *restrict target = nullptr,
- bool keep = false,
- bool dontChangeEquipment = false) restrict2;
-*/
-
- void updatePercentHP() restrict2;
-
- void setRaceName(const std::string &restrict name) restrict2 noexcept2
- { mRaceName = name; }
-
- std::string getRaceName() const restrict2 noexcept2 A_WARN_UNUSED
- { return mRaceName; }
-
- int getSpriteID(const int slot) const restrict2 A_WARN_UNUSED;
-
- const BeingSlot &getSpriteSlot(const int slot) const
- restrict2 A_WARN_UNUSED;
-
- ItemColor getSpriteColor(const int slot) const restrict2 A_WARN_UNUSED;
-
- void setHairStyle(const unsigned int slot,
- const int id) restrict2;
-
- void setHairColor(const unsigned int slot,
- const ItemColor color) restrict2;
-
- void setHairColor(const ItemColor color) restrict2 noexcept2
- { mHairColor = color; }
-
- void setSpriteSlot(const unsigned int slot,
- const BeingSlot &beingSlot);
-
- ItemColor getHairColor() const noexcept2 A_WARN_UNUSED
- { return mHairColor; }
-
- void recalcSpritesOrder() restrict2;
-
- int getHitEffect(const Being *restrict const attacker,
- const AttackTypeT type,
- const int attackId,
- const int level) const restrict2 A_WARN_UNUSED;
-
- CursorT getHoverCursor() const restrict2 A_WARN_UNUSED
- {
- return mInfo != nullptr ?
- mInfo->getHoverCursor() : Cursor::CURSOR_POINTER;
- }
-
- void addAfkEffect() restrict2;
-
- void removeAfkEffect() restrict2;
-
- void updateAwayEffect() restrict2;
-
- void addSpecialEffect(const int effect) restrict2;
-
- void removeSpecialEffect() restrict2;
-
- void addEffect(const std::string &restrict name) restrict2;
-
- void setOwner(Being *restrict const owner) restrict2 noexcept2
- { mOwner = owner; }
-
- Being *getOwner() const restrict2 noexcept2
- { return mOwner; }
-
- void playSfx(const SoundInfo &sound,
- Being *const being,
- const bool main,
- const int x, const int y) const restrict2;
-
- uint16_t getLook() const restrict2 noexcept2
- { return mLook; }
-
- void setLook(const uint16_t look) restrict2;
-
- constexpr2 static uint8_t genderToInt(const GenderT sex)
- A_CONST A_WARN_UNUSED
- {
- switch (sex)
- {
- case Gender::FEMALE:
- case Gender::UNSPECIFIED:
- default:
- return 0;
- case Gender::MALE:
- return 1;
- case Gender::OTHER:
- return 3;
- }
- }
-
- constexpr2 static GenderT intToGender(const uint8_t sex)
- A_CONST A_WARN_UNUSED
- {
- switch (sex)
- {
- case 0:
- default:
- return Gender::FEMALE;
- case 1:
- return Gender::MALE;
- case 3:
- return Gender::OTHER;
- }
- }
-
- NextSoundInfo mNextSound;
-
- /**
- * Sets the new path for this being.
- */
- void setPath(const Path &restrict path) restrict2;
-
- int getSortPixelY() const restrict2 override A_WARN_UNUSED
- { return CAST_S32(mPos.y) - mYDiff - mSortOffsetY; }
-
- void setMap(Map *restrict const map) restrict2 override;
-
- void recreateItemParticles() restrict2;
-
- void incUsage() restrict2 noexcept2
- { mUsageCounter ++; }
-
- int decUsage() restrict2 noexcept2
- { return --mUsageCounter; }
-
- virtual int getLastAttackX() const restrict2
- { return mLastAttackX; }
-
- virtual int getLastAttackY() const restrict2
- { return mLastAttackY; }
-
- void drawHomunculus(Graphics *restrict const graphics,
- const int offsetX,
- const int offsetY) const
- restrict2 A_NONNULL(2);
-
- void drawMercenary(Graphics *restrict const graphics,
- const int offsetX,
- const int offsetY) const
- restrict2 A_NONNULL(2);
-
- void drawElemental(Graphics *restrict const graphics,
- const int offsetX,
- const int offsetY) const
- restrict2 A_NONNULL(2);
-
- void setTrickDead(const bool b) restrict2 override final;
-
- void setChat(ChatObject *restrict const obj) restrict2;
-
- ChatObject *getChat() const restrict2 noexcept2
- { return mChat; }
-
- void setRiding(const bool b) restrict2 override final;
-
- void setHorse(const int horseId) restrict2;
-
- void removeHorse() restrict2;
-
- void setSellBoard(const std::string &restrict text) restrict2;
-
- std::string getSellBoard() const restrict2 noexcept2 A_WARN_UNUSED
- { return mSellBoard; }
-
- void setBuyBoard(const std::string &restrict text) restrict2;
-
- std::string getBuyBoard() const restrict2 noexcept2 A_WARN_UNUSED
- { return mBuyBoard; }
-
- void setSpiritBalls(const unsigned int balls) restrict2;
-
- unsigned int getSpiritBalls() const restrict2 noexcept2 A_WARN_UNUSED
- { return mSpiritBalls; }
-
- void stopCast(const bool b) override final;
-
- void setCreatorId(const BeingId id)
- { mCreatorId = id; }
-
- BeingId getCreatorId() const noexcept2 A_WARN_UNUSED
- { return mCreatorId; }
-
- void setKarma(const int karma) restrict2 noexcept2
- { mKarma = karma; }
-
- int getKarma() const restrict2 noexcept2 A_WARN_UNUSED
- { return mKarma; }
-
- void setManner(const int manner) restrict2 noexcept2
- { mManner = manner; }
-
- int getManner() const restrict2 noexcept2 A_WARN_UNUSED
- { return mManner; }
-
- void disableBotAi() restrict2 noexcept2
- { mBotAi = false; }
-
- void enableBotAi() restrict2 noexcept2
- { mBotAi = true; }
-
- int getAreaSize() const restrict2 noexcept2 A_WARN_UNUSED
- { return mAreaSize; }
-
- void setAreaSize(const int areaSize) restrict2 noexcept2
- { mAreaSize = areaSize; }
-
- void setTeamId(const uint16_t teamId) restrict2;
-
- void showTeamBadge(const bool show) restrict2;
-
- void showGuildBadge(const bool show) restrict2;
-
- void showGmBadge(const bool show) restrict2;
-
- void showPartyBadge(const bool show) restrict2;
-
- void showNameBadge(const bool show) restrict2;
-
- void showShopBadge(const bool show) restrict2;
-
- void showInactiveBadge(const bool show) restrict2;
-
- void showAwayBadge(const bool show) restrict2;
-
- void showBadges(const bool show) restrict2;
-
- void setLanguageId(const int lang) restrict2 noexcept2;
-
- int getLanguageId() restrict2 noexcept2 A_WARN_UNUSED
- { return mLanguageId; }
-
- uint16_t getTeamId() const restrict2 noexcept2 A_WARN_UNUSED
- { return mTeamId; }
-
- virtual void setGroupId(const int id)
- { mGroupId = id; }
-
- int getGroupId() const noexcept2 A_WARN_UNUSED
- { return mGroupId; }
-
- void serverRemove() restrict2 noexcept2;
-
- void addCast(const int dstX,
- const int dstY,
- const int skillId,
- const int skillLevel,
- const int range,
- const int waitTimeTicks);
-
- void fixDirectionOffsets(int &offsetX,
- int &offsetY) const;
-
- static Being *createBeing(const BeingId id,
- const ActorTypeT type,
- const BeingTypeId subtype,
- Map *const map);
-
- protected:
- void drawPlayerSpriteAt(Graphics *restrict const graphics,
- const int x,
- const int y) const restrict2 A_NONNULL(2);
-
- void drawOtherSpriteAt(Graphics *restrict const graphics,
- const int x,
- const int y) const restrict2 A_NONNULL(2);
-
- void drawPortalSpriteAt(Graphics *restrict const graphics,
- const int x,
- const int y) const restrict2 A_NONNULL(2);
-
- void drawMonsterSpriteAt(Graphics *restrict const graphics,
- const int x,
- const int y) const restrict2 A_NONNULL(2);
-
- void drawHomunculusSpriteAt(Graphics *restrict const graphics,
- const int x,
- const int y) const restrict2 A_NONNULL(2);
-
- void drawMercenarySpriteAt(Graphics *restrict const graphics,
- const int x,
- const int y) const restrict2 A_NONNULL(2);
-
- void drawElementalSpriteAt(Graphics *restrict const graphics,
- const int x,
- const int y) const restrict2 A_NONNULL(2);
-
- void drawCompound(Graphics *const graphics,
- const int posX,
- const int posY) const A_NONNULL(2);
-
- /**
- * Updates name's location.
- */
- virtual void updateCoords() restrict2;
-
- void showName() restrict2;
-
- void addItemParticles(const int id,
- const SpriteDisplay &restrict display) restrict2;
-
- void addItemParticlesCards(const int id,
- const SpriteDisplay &restrict display,
- const CardsList &restrict cards) restrict2;
-
- void removeAllItemsParticles() restrict2;
-
- void removeItemParticles(const int id) restrict2;
-
- void createSpeechBubble() restrict2;
-
- void setDefaultNameColor(const UserColorIdT defaultColor) restrict2;
-
- void updateBadgesCount() restrict2;
-
- static int getDefaultEffectId(const AttackTypeT &restrict type);
-
- BeingInfo *restrict mInfo;
- AnimatedSprite *restrict mEmotionSprite;
- AnimatedSprite *restrict mAnimationEffect;
- CastingEffect *restrict mCastingEffect;
- AnimatedSprite *restrict mBadges[BadgeIndex::BadgeIndexSize];
-
- std::string mSpriteAction;
- std::string mName; /**< Name of being */
- std::string mExtName; /**< Full name of being */
- std::string mRaceName;
- std::string mPartyName;
- std::string mGuildName;
- std::string mSpeech;
-
- /**
- * Holds a text object when the being displays it's name, 0 otherwise
- */
- FlashText *restrict mDispName;
- const Color *restrict mNameColor;
-
- /** Engine-related infos about weapon. */
- const ItemInfo *restrict mEquippedWeapon;
-
- Path mPath;
- Text *restrict mText;
- const Color *restrict mTextColor;
-
- Vector mDest; /**< destination coordinates. */
-
- typedef std::map<int, ParticleInfo*> SpriteParticleInfo;
- typedef SpriteParticleInfo::iterator SpriteParticleInfoIter;
-
- STD_VECTOR<BeingSlot> mSlots;
- SpriteParticleInfo mSpriteParticles;
-
- // Character guild information
- std::map<int, Guild*> mGuilds;
- Party *mParty;
-
- int mActionTime; /**< Time spent in current action */
- int mEmotionTime; /**< Time until emotion disappears */
-
- /** Time until the last speech sentence disappears */
- int mSpeechTime;
- int mAttackSpeed; /**< Attack speed */
-
- int mLevel;
- int mGroupId;
- int mAttackRange;
- int mLastAttackX;
- int mLastAttackY;
-
- int mPreStandTime;
-
- GenderT mGender;
- BeingActionT mAction;
- BeingTypeId mSubType; /**< Subtype (graphical view, basically) */
- uint8_t mDirection; /**< Facing direction */
- uint8_t mDirectionDelayed; /**< Facing direction */
- SpriteDirection::Type mSpriteDirection; /**< Facing direction */
- bool mShowName;
- bool mIsGM;
-
- protected:
- void postInit(const BeingTypeId subType,
- Map *const map);
-
- void updateBadgesPosition();
-
- /**
- * Calculates the offset in the given directions.
- * If walking in direction 'neg' the value is negated.
- */
- template<signed char pos, signed char neg>
- int getOffset() const restrict2 A_WARN_UNUSED;
-
- int searchSlotValue(const STD_VECTOR<int> &restrict slotRemap,
- const int val) const restrict2 A_WARN_UNUSED;
-
- static void searchSlotValueItr(STD_VECTOR<int>::iterator &restrict it,
- int &idx,
- STD_VECTOR<int> &restrict slotRemap,
- const int val);
-
- void addSpiritBalls(const unsigned int balls,
- const int effectId) restrict2;
-
- void removeSpiritBalls(const unsigned int balls) restrict2;
-
- void dumpSprites() const restrict2;
-
- void drawBeingCursor(Graphics *const graphics,
- const int offsetX,
- const int offsetY) const A_NONNULL(2);
-
- void drawCasting(Graphics *const graphics,
- const int offsetX,
- const int offsetY) const A_NONNULL(2);
-
- void updateBotFollow(int dstX,
- int dstY,
- const int divX,
- const int divY);
-
- void moveBotTo(int dstX,
- int dstY);
-
- void updateBotDirection(const int dstX,
- const int dstY);
-
- void botFixOffset(int &restrict dstX,
- int &restrict dstY) const;
-
- const ActorTypeT mType;
-
- /** Speech Bubble components */
- SpeechBubble *restrict mSpeechBubble;
-
- /**
- * Walk speed for x and y movement values.
- * In pixels per second.
- * @see MILLISECONDS_IN_A_TICK
- */
- int mWalkSpeed;
- int mSpeed;
- std::string mIp;
- int *restrict mSpriteRemap A_NONNULLPOINTER;
- int *restrict mSpriteHide A_NONNULLPOINTER;
- int *restrict mSpriteDraw A_NONNULLPOINTER;
- std::string mComment;
- std::string mBuyBoard;
- std::string mSellBoard;
- Being *restrict mOwner;
- Particle *restrict mSpecialParticle;
- ChatObject *restrict mChat;
- HorseInfo *restrict mHorseInfo;
- STD_VECTOR<AnimatedSprite*> mDownHorseSprites;
- STD_VECTOR<AnimatedSprite*> mUpHorseSprites;
- STD_VECTOR<Particle*> mSpiritParticles;
-
- int mX; // position in tiles
- int mY; // position in tiles
- int mCachedX;
- int mCachedY;
- int mSortOffsetY; // caculated offset in pixels based on mPixelOffsetY
- int mPixelOffsetY; // tile height offset in pixels
- // calculated between tiles
- int mFixedOffsetY; // fixed tile height offset in pixels for tile
- uint8_t mOldHeight;
-
- int mDamageTaken;
- int mHP;
- int mMaxHP;
- int mDistance;
- ReachableT mReachable;
- int mGoodStatus;
-
- static time_t mUpdateConfigTime;
- static unsigned int mConfLineLim;
- static int mSpeechType;
- static bool mHighlightMapPortals;
- static bool mHighlightMonsterAttackRange;
- static bool mLowTraffic;
- static bool mDrawHotKeys;
- static bool mShowBattleEvents;
- static bool mShowMobHP;
- static bool mShowOwnHP;
- static bool mShowGender;
- static bool mShowLevel;
- static bool mShowPlayersStatus;
- static bool mEnableReorderSprites;
- static bool mHideErased;
- static Move mMoveNames;
- static bool mUseDiagonal;
- static BadgeDrawType::Type mShowBadges;
- static int mAwayEffect;
- static VisibleNamePos::Type mVisibleNamePos;
-
- time_t mMoveTime;
- time_t mAttackTime;
- time_t mTalkTime;
- time_t mOtherTime;
- time_t mTestTime;
- int mAttackDelay;
- int mMinHit;
- int mMaxHit;
- int mCriticalHit;
- unsigned int mPvpRank;
- unsigned int mNumber;
- unsigned int mSpiritBalls;
- int mUsageCounter;
- int mKarma;
- int mManner;
- int mAreaSize;
- int mCastEndTime;
- int mLanguageId;
- int mBadgesX;
- int mBadgesY;
- BeingId mCreatorId;
- uint16_t mTeamId;
- uint16_t mLook;
- uint16_t mBadgesCount;
- ItemColor mHairColor;
- bool mErased;
- bool mEnemy;
- bool mGotComment;
- bool mAdvanced;
- bool mShop;
- bool mAway;
- bool mInactive;
- bool mNeedPosUpdate;
- bool mBotAi;
-};
-
-extern std::list<BeingCacheEntry*> beingInfoCache;
-
-#endif // BEING_BEING_H
diff --git a/src/being/beingcacheentry.h b/src/being/beingcacheentry.h
deleted file mode 100644
index 4cfc6f64b..000000000
--- a/src/being/beingcacheentry.h
+++ /dev/null
@@ -1,138 +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 BEING_BEINGCACHEENTRY_H
-#define BEING_BEINGCACHEENTRY_H
-
-#include "enums/simpletypes/beingid.h"
-
-#include "localconsts.h"
-
-#include <string>
-
-class BeingCacheEntry final
-{
- public:
- explicit BeingCacheEntry(const BeingId id) :
- mName(),
- mPartyName(),
- mGuildName(),
- mIp(),
- mId(id),
- mLevel(0),
- mPvpRank(0),
- mTime(0),
- mFlags(0),
- mTeamId(0U),
- mIsAdvanced(false)
- {
- }
-
- A_DELETE_COPY(BeingCacheEntry)
-
- BeingId getId() const
- { return mId; }
-
- /**
- * Returns the name of the being.
- */
- const std::string &getName() const
- { return mName; }
-
- /**
- * Sets the name for the being.
- *
- * @param name The name that should appear.
- */
- void setName(const std::string &name)
- { mName = name; }
-
- /**
- * Following are set from the server (mainly for players)
- */
- void setPartyName(const std::string &name)
- { mPartyName = name; }
-
- void setGuildName(const std::string &name)
- { mGuildName = name; }
-
- const std::string &getPartyName() const
- { return mPartyName; }
-
- const std::string &getGuildName() const
- { return mGuildName; }
-
- void setLevel(const int n)
- { mLevel = n; }
-
- int getLevel() const
- { return mLevel; }
-
- void setTime(const time_t n)
- { mTime = n; }
-
- time_t getTime() const
- { return mTime; }
-
- unsigned getPvpRank() const
- { return mPvpRank; }
-
- void setPvpRank(const int r)
- { mPvpRank = r; }
-
- std::string getIp() const
- { return mIp; }
-
- void setIp(const std::string &ip)
- { mIp = ip; }
-
- bool isAdvanced() const
- { return mIsAdvanced; }
-
- void setAdvanced(const bool a)
- { mIsAdvanced = a; }
-
- int getFlags() const
- { return mFlags; }
-
- void setFlags(const int flags)
- { mFlags = flags; }
-
- uint16_t getTeamId() const
- { return mTeamId; }
-
- void setTeamId(const uint16_t teamId)
- { mTeamId = teamId; }
-
- protected:
- std::string mName; /**< Name of character */
- std::string mPartyName;
- std::string mGuildName;
- std::string mIp;
- BeingId mId; /**< Unique sprite id */
- int mLevel;
- unsigned int mPvpRank;
- time_t mTime;
- int mFlags;
- uint16_t mTeamId;
- bool mIsAdvanced;
-};
-
-#endif // BEING_BEINGCACHEENTRY_H
diff --git a/src/being/beingflag.h b/src/being/beingflag.h
deleted file mode 100644
index 0669f78bf..000000000
--- a/src/being/beingflag.h
+++ /dev/null
@@ -1,37 +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 BEING_BEINGFLAG_H
-#define BEING_BEINGFLAG_H
-
-namespace BeingFlag
-{
- enum
- {
- SHOP = 1,
- AWAY = 2,
- INACTIVE = 4,
- GENDER_OTHER = 32,
- GM = 64,
- GENDER_MALE = 128,
- SPECIAL = 128 + 64
- };
-} // namespace BeingFlag
-#endif // BEING_BEINGFLAG_H
diff --git a/src/being/beingspeech.h b/src/being/beingspeech.h
deleted file mode 100644
index 869d1b665..000000000
--- a/src/being/beingspeech.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 BEING_BEINGSPEECH_H
-#define BEING_BEINGSPEECH_H
-
-namespace BeingSpeech
-{
- enum
- {
- NO_SPEECH = 0,
- TEXT_OVERHEAD,
- NO_NAME_IN_BUBBLE,
- NAME_IN_BUBBLE
- };
-} // namespace BeingSpeech
-
-#endif // BEING_BEINGSPEECH_H
diff --git a/src/being/castingeffect.cpp b/src/being/castingeffect.cpp
deleted file mode 100644
index 872743f82..000000000
--- a/src/being/castingeffect.cpp
+++ /dev/null
@@ -1,105 +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 "being/castingeffect.h"
-
-#include "configuration.h"
-
-#include "const/resources/map/map.h"
-
-#include "gui/userpalette.h"
-
-#include "render/graphics.h"
-
-#include "resources/sprite/animatedsprite.h"
-
-#include "utils/checkutils.h"
-#include "utils/delete2.h"
-
-#include "debug.h"
-
-CastingEffect::CastingEffect(const int skillId,
- const int skillLevel,
- const std::string &animation,
- const int x,
- const int y,
- const int range) :
- Actor(),
- mSprite(animation.empty() ? nullptr :
- AnimatedSprite::load(paths.getStringValue("sprites") + animation)),
- mRectX((x - range) * mapTileSize),
- mRectY((y - range) * mapTileSize),
- mRectSize(range * mapTileSize * 2 + mapTileSize),
- mAnimationX(mRectX + (mRectSize - (mSprite != nullptr ?
- mSprite->getWidth() : 0)) / 2),
- mAnimationY(mRectY + (mRectSize - (mSprite != nullptr ?
- mSprite->getHeight() : 0)) / 2)
-{
- mPixelX = x * mapTileSize;
- mPixelY = y * mapTileSize;
- mYDiff = range * mapTileSize + 31;
- if (mSprite == nullptr)
- {
- reportAlways("Skill %d/%d casting animation '%s' load failed",
- skillId,
- skillLevel,
- animation.c_str());
- }
-}
-
-CastingEffect::~CastingEffect()
-{
- delete2(mSprite);
-}
-
-void CastingEffect::draw(Graphics *const graphics,
- const int offsetX,
- const int offsetY) const
-{
- graphics->setColor(userPalette->getColorWithAlpha(
- UserColorId::ATTACK_RANGE_BORDER));
-
- graphics->drawRectangle(Rect(
- mRectX + offsetX,
- mRectY + offsetY,
- mRectSize,
- mRectSize));
- if (mSprite != nullptr)
- {
- mSprite->drawRescaled(graphics,
- mRectX + offsetX,
- mRectY + offsetY,
- mRectSize,
- mRectSize);
- }
-}
-
-void CastingEffect::update(const int time)
-{
- if (mSprite != nullptr)
- mSprite->update(time);
-}
-
-bool CastingEffect::isTerminated() const
-{
- if (mSprite != nullptr)
- return mSprite->isTerminated();
- return false;
-}
diff --git a/src/being/castingeffect.h b/src/being/castingeffect.h
deleted file mode 100644
index 3a1d1a6b7..000000000
--- a/src/being/castingeffect.h
+++ /dev/null
@@ -1,75 +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 BEING_CASTINGEFFECT_H
-#define BEING_CASTINGEFFECT_H
-
-#include "being/actor.h"
-
-#include "enums/being/actortype.h"
-
-#include "localconsts.h"
-
-class AnimatedSprite;
-
-class CastingEffect final : public Actor
-{
- public:
- CastingEffect(const int skillId,
- const int skillLevel,
- const std::string &animation,
- const int x,
- const int y,
- const int range);
-
- A_DELETE_COPY(CastingEffect)
-
- virtual ~CastingEffect();
-
- virtual ActorTypeT getType() const noexcept2 A_WARN_UNUSED
- { return ActorType::Unknown; }
-
- void draw(Graphics *const graphics,
- const int offsetX,
- const int offsetY) const override final A_NONNULL(2);
-
- int getSortPixelY() const restrict2 override A_WARN_UNUSED
- { return mPixelY - mYDiff; }
-
- void update(const int time);
-
- bool isTerminated() const;
-
- float getAlpha() const override final A_WARN_UNUSED
- { return 1.0f; }
-
- void setAlpha(const float alpha A_UNUSED) override final
- { }
-
- protected:
- AnimatedSprite *mSprite;
- int mRectX;
- int mRectY;
- int mRectSize;
- int mAnimationX;
- int mAnimationY;
-};
-
-#endif // BEING_CASTINGEFFECT_H
diff --git a/src/being/compounditem.h b/src/being/compounditem.h
deleted file mode 100644
index 541623ceb..000000000
--- a/src/being/compounditem.h
+++ /dev/null
@@ -1,46 +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 BEING_COMPOUNDITEM_H
-#define BEING_COMPOUNDITEM_H
-
-#include <list>
-
-#include "localconsts.h"
-
-class Image;
-
-typedef std::list <const void*> VectorPointers;
-
-class CompoundItem final
-{
- public:
- CompoundItem();
-
- A_DELETE_COPY(CompoundItem)
-
- ~CompoundItem();
-
- VectorPointers data;
- Image *image;
- Image *alphaImage;
-};
-
-#endif // BEING_COMPOUNDITEM_H
diff --git a/src/being/compoundsprite.cpp b/src/being/compoundsprite.cpp
deleted file mode 100644
index a32b7db1b..000000000
--- a/src/being/compoundsprite.cpp
+++ /dev/null
@@ -1,566 +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 "being/compoundsprite.h"
-
-#include "configuration.h"
-
-#include "sdlshared.h"
-
-#include "being/compounditem.h"
-
-#include "render/surfacegraphics.h"
-
-#if defined(USE_OPENGL) || !defined(USE_SDL2)
-#include "resources/imagehelper.h"
-#endif // USE_OPENGL
-#include "resources/image/image.h"
-
-#include "utils/delete2.h"
-#include "utils/dtor.h"
-#include "utils/foreach.h"
-#include "utils/likely.h"
-#include "utils/sdlcheckutils.h"
-
-#ifndef USE_SDL2
-#include "game.h"
-
-#include "const/resources/map/map.h"
-
-#include "resources/map/map.h"
-
-#include "utils/timer.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)
-#endif // USE_SDL2
-
-#include "debug.h"
-
-#ifndef USE_SDL2
-static const int BUFFER_WIDTH = 100;
-static const int BUFFER_HEIGHT = 100;
-static const unsigned cache_max_size = 10;
-static const unsigned cache_clean_part = 3;
-#endif // USE_SDL2
-
-bool CompoundSprite::mEnableDelay = true;
-
-CompoundSprite::CompoundSprite() :
- Sprite(),
- mSprites(),
- imagesCache(),
- mCacheItem(nullptr),
- mImage(nullptr),
- mAlphaImage(nullptr),
- mOffsetX(0),
- mOffsetY(0),
- mStartTime(0),
- mLastTime(0),
-#ifndef USE_SDL2
- mNextRedrawTime(0),
-#endif // USE_SDL2
- mNeedsRedraw(false),
- mEnableAlphaFix(config.getBoolValue("enableAlphaFix")),
- mDisableAdvBeingCaching(config.getBoolValue("disableAdvBeingCaching")),
- mDisableBeingCaching(config.getBoolValue("disableBeingCaching"))
-{
- mAlpha = 1.0F;
-}
-
-CompoundSprite::~CompoundSprite()
-{
- clear();
- mImage = nullptr;
- mAlphaImage = nullptr;
-}
-
-bool CompoundSprite::reset()
-{
- bool ret = false;
- FOR_EACH (SpriteIterator, it, mSprites)
- {
- if (*it != nullptr)
- ret |= (*it)->reset();
- }
- if (ret)
- mLastTime = 0;
- mNeedsRedraw |= ret;
- return ret;
-}
-
-bool CompoundSprite::play(const std::string &action)
-{
- bool ret = false;
- bool ret2 = true;
- FOR_EACH (SpriteIterator, it, mSprites)
- {
- if (*it != nullptr)
- {
- const bool tmpVal = (*it)->play(action);
- ret |= tmpVal;
- ret2 &= tmpVal;
- }
- }
- mNeedsRedraw |= ret;
- if (ret2)
- mLastTime = 0;
- return ret;
-}
-
-bool CompoundSprite::update(const int time)
-{
- bool ret = false;
- if (A_UNLIKELY(mLastTime == 0))
- mStartTime = time;
- mLastTime = time;
- FOR_EACH (SpriteIterator, it, mSprites)
- {
- if (*it != nullptr)
- ret |= (*it)->update(time);
- }
- mNeedsRedraw |= ret;
- return ret;
-}
-
-void CompoundSprite::drawSimple(Graphics *const graphics,
- const int posX,
- const int posY) const
-{
- FUNC_BLOCK("CompoundSprite::draw", 1)
- if (mNeedsRedraw)
- updateImages();
-
- if (mSprites.empty()) // Nothing to draw
- return;
-
- if (mAlpha == 1.0F && (mImage != nullptr))
- {
- graphics->drawImage(mImage, posX + mOffsetX, posY + mOffsetY);
- }
- else if ((mAlpha != 0.0f) && (mAlphaImage != nullptr))
- {
- mAlphaImage->setAlpha(mAlpha);
- graphics->drawImage(mAlphaImage,
- posX + mOffsetX, posY + mOffsetY);
- }
- else
- {
- CompoundSprite::drawSprites(graphics, posX, posY);
- }
-}
-
-void CompoundSprite::drawSprites(Graphics *const graphics,
- const int posX,
- const int posY) const
-{
- FOR_EACH (SpriteConstIterator, it, mSprites)
- {
- if (*it != nullptr)
- {
- (*it)->setAlpha(mAlpha);
- (*it)->draw(graphics, posX, posY);
- }
- }
-}
-
-void CompoundSprite::drawSpritesSDL(Graphics *const graphics,
- const int posX,
- const int posY) const
-{
- FOR_EACH (SpriteConstIterator, it, mSprites)
- {
- if (*it != nullptr)
- (*it)->draw(graphics, posX, posY);
- }
-}
-
-int CompoundSprite::getWidth() const
-{
- FOR_EACH (SpriteConstIterator, it, mSprites)
- {
- const Sprite *const base = *it;
- if (base != nullptr)
- return base->getWidth();
- }
-
- return 0;
-}
-
-int CompoundSprite::getHeight() const
-{
- FOR_EACH (SpriteConstIterator, it, mSprites)
- {
- const Sprite *const base = *it;
- if (base != nullptr)
- return base->getHeight();
- }
-
- return 0;
-}
-
-const Image *CompoundSprite::getImage() const
-{
- return mImage;
-}
-
-bool CompoundSprite::setSpriteDirection(const SpriteDirection::Type direction)
-{
- bool ret = false;
- FOR_EACH (SpriteIterator, it, mSprites)
- {
- if (*it != nullptr)
- ret |= (*it)->setSpriteDirection(direction);
- }
- if (ret)
- mLastTime = 0;
- mNeedsRedraw |= ret;
- return ret;
-}
-
-int CompoundSprite::getNumberOfLayers() const
-{
- if ((mImage != nullptr) || (mAlphaImage != nullptr))
- return 1;
- return CAST_S32(mSprites.size());
-}
-
-unsigned int CompoundSprite::getCurrentFrame() const
-{
- FOR_EACH (SpriteConstIterator, it, mSprites)
- {
- if (*it != nullptr)
- return (*it)->getCurrentFrame();
- }
- return 0;
-}
-
-unsigned int CompoundSprite::getFrameCount() const
-{
- FOR_EACH (SpriteConstIterator, it, mSprites)
- {
- if (*it != nullptr)
- return (*it)->getFrameCount();
- }
- return 0;
-}
-
-void CompoundSprite::addSprite(Sprite *const sprite)
-{
- mSprites.push_back(sprite);
- mNeedsRedraw = true;
-}
-
-void CompoundSprite::setSprite(const size_t layer, Sprite *const sprite)
-{
- // Skip if it won't change anything
- if (mSprites[layer] == sprite)
- return;
-
- delete mSprites[layer];
- mSprites[layer] = sprite;
- mNeedsRedraw = true;
-}
-
-void CompoundSprite::removeSprite(const int layer)
-{
- // Skip if it won't change anything
- if (mSprites[layer] == nullptr)
- return;
-
- delete2(mSprites[layer]);
- mNeedsRedraw = true;
-}
-
-void CompoundSprite::clear()
-{
- // Skip if it won't change anything
- if (!mSprites.empty())
- {
- delete_all(mSprites);
- mSprites.clear();
- }
- mNeedsRedraw = true;
- delete_all(imagesCache);
- imagesCache.clear();
- delete2(mCacheItem);
- mLastTime = 0;
-}
-
-void CompoundSprite::ensureSize(const size_t layerCount)
-{
- // Skip if it won't change anything
- if (mSprites.size() >= layerCount)
- return;
-
-// resize(layerCount, nullptr);
- mSprites.resize(layerCount);
-}
-
-void CompoundSprite::redraw() const
-{
-#ifndef USE_SDL2
-
-#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
-
- SDL_Surface *const surface = MSDL_CreateRGBSurface(SDL_HWSURFACE,
- BUFFER_WIDTH, BUFFER_HEIGHT, 32, rmask, gmask, bmask, amask);
-
- if (surface == nullptr)
- return;
-
- SurfaceGraphics *graphics = new SurfaceGraphics;
- graphics->setBlitMode(BlitMode::BLIT_GFX);
- graphics->setTarget(surface);
- graphics->beginDraw();
-
- int tileX = mapTileSize / 2;
- int tileY = mapTileSize;
-
- const Game *const game = Game::instance();
- if (game != nullptr)
- {
- const Map *const map = game->getCurrentMap();
- if (map != nullptr)
- {
- tileX = map->getTileWidth() / 2;
- tileY = map->getTileWidth();
- }
- }
-
- const int posX = BUFFER_WIDTH / 2 - tileX;
- const int posY = BUFFER_HEIGHT - tileY;
-
- mOffsetX = tileX - BUFFER_WIDTH / 2;
- mOffsetY = tileY - BUFFER_HEIGHT;
-
- drawSpritesSDL(graphics, posX, posY);
-
- delete2(graphics);
-
- SDL_SetAlpha(surface, 0, SDL_ALPHA_OPAQUE);
-
- delete mAlphaImage;
-
- if (ImageHelper::mEnableAlpha)
- {
- SDL_Surface *const surfaceA = MSDL_CreateRGBSurface(SDL_HWSURFACE,
- BUFFER_WIDTH, BUFFER_HEIGHT, 32, rmask, gmask, bmask, amask);
- SDL_BlitSurface(surface, nullptr, surfaceA, nullptr);
- mAlphaImage = imageHelper->loadSurface(surfaceA);
- MSDL_FreeSurface(surfaceA);
- }
- else
- {
- mAlphaImage = nullptr;
- }
-
- delete mImage;
- mImage = imageHelper->loadSurface(surface);
- MSDL_FreeSurface(surface);
-#endif // USE_SDL2
-}
-
-void CompoundSprite::setAlpha(float alpha)
-{
- if (alpha != mAlpha)
- {
- if (mEnableAlphaFix &&
-#ifdef USE_OPENGL
- imageHelper->useOpenGL() == RENDER_SOFTWARE &&
-#endif // USE_OPENGL
- mSprites.size() > 3U)
- {
- FOR_EACH (SpriteConstIterator, it, mSprites)
- {
- if (*it != nullptr)
- (*it)->setAlpha(alpha);
- }
- }
- mAlpha = alpha;
- }
-}
-
-void CompoundSprite::updateImages() const
-{
-#ifndef USE_SDL2
-#ifdef USE_OPENGL
- if (imageHelper->useOpenGL() != RENDER_SOFTWARE)
- return;
-#endif // USE_OPENGL
-
- if (mEnableDelay)
- {
- if (get_elapsed_time1(mNextRedrawTime) < 10)
- return;
- mNextRedrawTime = tick_time;
- }
- mNeedsRedraw = false;
-
- if (!mDisableBeingCaching)
- {
- if (mSprites.size() <= 3U)
- return;
-
- if (!mDisableAdvBeingCaching)
- {
- if (updateFromCache())
- return;
-
- redraw();
-
- if (mImage != nullptr)
- initCurrentCacheItem();
- }
- else
- {
- redraw();
- }
- }
-#endif // USE_SDL2
-}
-
-bool CompoundSprite::updateFromCache() const
-{
-#ifndef USE_SDL2
-// static int hits = 0;
-// static int miss = 0;
-
- if ((mCacheItem != nullptr) && (mCacheItem->image != nullptr))
- {
- imagesCache.push_front(mCacheItem);
- mCacheItem = nullptr;
- if (imagesCache.size() > cache_max_size)
- {
- for (unsigned f = 0; f < cache_clean_part; f ++)
- {
- CompoundItem *item = imagesCache.back();
- imagesCache.pop_back();
- delete item;
- }
- }
- }
-
-// logger->log("cache size: %d, hit %d, miss %d",
-// (int)imagesCache.size(), hits, miss);
-
- const size_t sz = mSprites.size();
- FOR_EACH (ImagesCache::iterator, it, imagesCache)
- {
- CompoundItem *const ic = *it;
- if ((ic != nullptr) && ic->data.size() == sz)
- {
- bool fail(false);
- VectorPointers::const_iterator it2 = ic->data.begin();
- const VectorPointers::const_iterator it2_end = ic->data.end();
-
- for (SpriteConstIterator it1 = mSprites.begin(),
- it1_end = mSprites.end();
- it1 != it1_end && it2 != it2_end;
- ++ it1, ++ it2)
- {
- const void *ptr1 = nullptr;
- const void *ptr2 = nullptr;
- if (*it1 != nullptr)
- ptr1 = (*it1)->getHash();
- if (*it2 != nullptr)
- ptr2 = *it2;
- if (ptr1 != ptr2)
- {
- fail = true;
- break;
- }
- }
- if (!fail)
- {
-// hits ++;
- mImage = (*it)->image;
- mAlphaImage = (*it)->alphaImage;
- imagesCache.erase(it);
- mCacheItem = ic;
- return true;
- }
- }
- }
- mImage = nullptr;
- mAlphaImage = nullptr;
-// miss++;
-#endif // USE_SDL2
- return false;
-}
-
-void CompoundSprite::initCurrentCacheItem() const
-{
- delete mCacheItem;
- mCacheItem = new CompoundItem;
- mCacheItem->image = mImage;
- mCacheItem->alphaImage = mAlphaImage;
-// mCacheItem->alpha = mAlpha;
-
- FOR_EACH (SpriteConstIterator, it, mSprites)
- {
- if (*it != nullptr)
- mCacheItem->data.push_back((*it)->getHash());
- else
- mCacheItem->data.push_back(nullptr);
- }
-}
-
-bool CompoundSprite::updateNumber(const unsigned num)
-{
- bool res(false);
- FOR_EACH (SpriteConstIterator, it, mSprites)
- {
- if (*it != nullptr)
- {
- if ((*it)->updateNumber(num))
- res = true;
- }
- }
- return res;
-}
-
-CompoundItem::CompoundItem() :
- data(),
- image(nullptr),
- alphaImage(nullptr)
-{
-}
-
-CompoundItem::~CompoundItem()
-{
- delete image;
- delete alphaImage;
-}
diff --git a/src/being/compoundsprite.h b/src/being/compoundsprite.h
deleted file mode 100644
index bf6679963..000000000
--- a/src/being/compoundsprite.h
+++ /dev/null
@@ -1,143 +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 BEING_COMPOUNDSPRITE_H
-#define BEING_COMPOUNDSPRITE_H
-
-#include "resources/sprite/sprite.h"
-
-#include "utils/vector.h"
-
-#include <list>
-
-#include "localconsts.h"
-
-class CompoundItem;
-class Image;
-
-class CompoundSprite notfinal : public Sprite
-{
- public:
- typedef STD_VECTOR<Sprite*>::iterator SpriteIterator;
- typedef STD_VECTOR<Sprite*>::const_iterator SpriteConstIterator;
-
- CompoundSprite();
-
- A_DELETE_COPY(CompoundSprite)
-
- virtual ~CompoundSprite();
-
- bool reset() override final;
-
- bool play(const std::string &action) override final;
-
- bool update(const int time) override final;
-
- void drawSimple(Graphics *const graphics,
- const int posX,
- const int posY) const A_NONNULL(2);
-
- /**
- * Gets the width in pixels of the first sprite in the list.
- */
- int getWidth() const override A_WARN_UNUSED;
-
- /**
- * Gets the height in pixels of the first sprite in the list.
- */
- int getHeight() const override A_WARN_UNUSED;
-
- const Image *getImage() const override final A_WARN_UNUSED;
-
- bool setSpriteDirection(const SpriteDirection::Type direction)
- override final;
-
- int getNumberOfLayers() const A_WARN_UNUSED;
-
- unsigned int getCurrentFrame() const override final A_WARN_UNUSED;
-
- unsigned int getFrameCount() const override final A_WARN_UNUSED;
-
- void addSprite(Sprite *const sprite);
-
- void setSprite(const size_t layer, Sprite *const sprite);
-
- void removeSprite(const int layer);
-
- void clear();
-
- void ensureSize(const size_t layerCount);
-
- void drawSprites(Graphics *const graphics,
- const int posX,
- const int posY) const;
-
- virtual void drawSpritesSDL(Graphics *const graphics,
- const int posX,
- const int posY) const;
-
- void setAlpha(float alpha) override;
-
- bool updateNumber(const unsigned num) override final;
-
- constexpr2 static void setEnableDelay(bool b) noexcept2
- { mEnableDelay = b; }
-
- int getLastTime() const noexcept2 A_WARN_UNUSED
- { return mLastTime; }
-
- int getStartTime() const noexcept2 A_WARN_UNUSED
- { return mStartTime; }
-
- STD_VECTOR<Sprite*> mSprites;
-
- protected:
- void redraw() const;
-
- void updateImages() const;
-
- bool updateFromCache() const;
-
- void initCurrentCacheItem() const;
-
- typedef std::list<CompoundItem*> ImagesCache;
- mutable ImagesCache imagesCache;
- mutable CompoundItem *mCacheItem;
-
- mutable Image *mImage;
- mutable Image *mAlphaImage;
-
- mutable int mOffsetX;
- mutable int mOffsetY;
- int mStartTime;
- int mLastTime;
-#ifndef USE_SDL2
- mutable int mNextRedrawTime;
-#endif // USE_SDL2
-
- static bool mEnableDelay;
- mutable bool mNeedsRedraw;
- bool mEnableAlphaFix;
- bool mDisableAdvBeingCaching;
- bool mDisableBeingCaching;
-};
-
-#endif // BEING_COMPOUNDSPRITE_H
diff --git a/src/being/crazymoves.cpp b/src/being/crazymoves.cpp
deleted file mode 100644
index 5fb093d9d..000000000
--- a/src/being/crazymoves.cpp
+++ /dev/null
@@ -1,824 +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 "being/crazymoves.h"
-
-#include "configuration.h"
-#include "settings.h"
-
-#include "being/localplayer.h"
-
-#include "enums/being/beingdirection.h"
-
-#include "gui/shortcut/dropshortcut.h"
-
-#include "gui/windows/outfitwindow.h"
-
-#include "net/packetlimiter.h"
-#include "net/pethandler.h"
-#include "net/playerhandler.h"
-
-#include "resources/db/emotedb.h"
-
-#include "resources/map/map.h"
-
-#include "utils/timer.h"
-
-#include "debug.h"
-
-CrazyMoves *crazyMoves = nullptr;
-
-CrazyMoves::CrazyMoves() :
- mMoveProgram(),
- mDisableCrazyMove(false)
-{
-}
-
-void CrazyMoves::crazyMove()
-{
- const bool oldDisableCrazyMove = mDisableCrazyMove;
- mDisableCrazyMove = true;
- switch (settings.crazyMoveType)
- {
- case 1:
- crazyMove1();
- break;
- case 2:
- crazyMove2();
- break;
- case 3:
- crazyMove3();
- break;
- case 4:
- crazyMove4();
- break;
- case 5:
- crazyMove5();
- break;
- case 6:
- crazyMove6();
- break;
- case 7:
- crazyMove7();
- break;
- case 8:
- crazyMove8();
- break;
- case 9:
- crazyMove9();
- break;
- case 10:
- crazyMoveA();
- break;
- default:
- break;
- }
- mDisableCrazyMove = oldDisableCrazyMove;
-}
-
-void CrazyMoves::crazyMove1()
-{
- if ((localPlayer == nullptr) ||
- (playerHandler == nullptr) ||
- localPlayer->getCurrentAction() == BeingAction::MOVE)
- {
- return;
- }
-
-// if (!PacketLimiter::limitPackets(PacketType::PACKET_DIRECTION))
-// return;
-
- switch (localPlayer->getDirection())
- {
- case BeingDirection::UP:
- localPlayer->setWalkingDir(BeingDirection::UP);
- localPlayer->setDirection(BeingDirection::LEFT);
- playerHandler->setDirection(BeingDirection::LEFT);
- break;
- case BeingDirection::LEFT:
- localPlayer->setWalkingDir(BeingDirection::LEFT);
- localPlayer->setDirection(BeingDirection::DOWN);
- playerHandler->setDirection(BeingDirection::DOWN);
- break;
- case BeingDirection::DOWN:
- localPlayer->setWalkingDir(BeingDirection::DOWN);
- localPlayer->setDirection(BeingDirection::RIGHT);
- playerHandler->setDirection(BeingDirection::RIGHT);
- break;
- case BeingDirection::RIGHT:
- localPlayer->setWalkingDir(BeingDirection::RIGHT);
- localPlayer->setDirection(BeingDirection::UP);
- playerHandler->setDirection(BeingDirection::UP);
- break;
- default:
- break;
- }
-}
-
-void CrazyMoves::crazyMove2()
-{
- if ((localPlayer == nullptr) ||
- (playerHandler == nullptr) ||
- localPlayer->getCurrentAction() == BeingAction::MOVE)
- {
- return;
- }
-
-// if (!PacketLimiter::limitPackets(PacketType::PACKET_DIRECTION))
-// return;
-
- switch (localPlayer->getDirection())
- {
- case BeingDirection::UP:
- localPlayer->setWalkingDir(BeingDirection::UP |
- BeingDirection::LEFT);
- localPlayer->setDirection(BeingDirection::RIGHT);
- playerHandler->setDirection(
- BeingDirection::DOWN | BeingDirection::RIGHT);
- break;
-
- case BeingDirection::RIGHT:
- localPlayer->setWalkingDir(BeingDirection::UP |
- BeingDirection::RIGHT);
- localPlayer->setDirection(BeingDirection::DOWN);
- playerHandler->setDirection(
- BeingDirection::DOWN | BeingDirection::LEFT);
- break;
-
- case BeingDirection::DOWN:
- localPlayer->setWalkingDir(BeingDirection::DOWN |
- BeingDirection::RIGHT);
- localPlayer->setDirection(BeingDirection::LEFT);
- playerHandler->setDirection(
- BeingDirection::UP | BeingDirection::LEFT);
- break;
-
- case BeingDirection::LEFT:
- localPlayer->setWalkingDir(BeingDirection::DOWN |
- BeingDirection::LEFT);
- localPlayer->setDirection(BeingDirection::UP);
- playerHandler->setDirection(
- BeingDirection::UP | BeingDirection::RIGHT);
- break;
-
- default:
- break;
- }
-}
-
-void CrazyMoves::crazyMove3()
-{
- if ((localPlayer == nullptr) ||
- (playerHandler == nullptr) ||
- localPlayer->getCurrentAction() == BeingAction::MOVE)
- {
- return;
- }
-
- switch (settings.crazyMoveState)
- {
- case 0:
- localPlayer->move(1, 1);
- settings.crazyMoveState = 1;
- break;
- case 1:
- localPlayer->move(1, -1);
- settings.crazyMoveState = 2;
- break;
- case 2:
- localPlayer->move(-1, -1);
- settings.crazyMoveState = 3;
- break;
- case 3:
- localPlayer->move(-1, 1);
- settings.crazyMoveState = 0;
- break;
- default:
- break;
- }
-
-// if (!PacketLimiter::limitPackets(PacketType::PACKET_DIRECTION))
-// return;
-
- localPlayer->setDirection(BeingDirection::DOWN);
- playerHandler->setDirection(BeingDirection::DOWN);
-}
-
-void CrazyMoves::crazyMove4()
-{
- if ((localPlayer == nullptr) ||
- localPlayer->getCurrentAction() == BeingAction::MOVE)
- {
- return;
- }
-
- switch (settings.crazyMoveState)
- {
- case 0:
- localPlayer->move(7, 0);
- settings.crazyMoveState = 1;
- break;
- case 1:
- localPlayer->move(-7, 0);
- settings.crazyMoveState = 0;
- break;
- default:
- break;
- }
-}
-
-void CrazyMoves::crazyMove5()
-{
- if ((localPlayer == nullptr) ||
- localPlayer->getCurrentAction() == BeingAction::MOVE)
- {
- return;
- }
-
- switch (settings.crazyMoveState)
- {
- case 0:
- localPlayer->move(0, 7);
- settings.crazyMoveState = 1;
- break;
- case 1:
- localPlayer->move(0, -7);
- settings.crazyMoveState = 0;
- break;
- default:
- break;
- }
-}
-
-void CrazyMoves::crazyMove6()
-{
- if ((localPlayer == nullptr) ||
- localPlayer->getCurrentAction() == BeingAction::MOVE)
- {
- return;
- }
-
- switch (settings.crazyMoveState)
- {
- case 0:
- localPlayer->move(3, 0);
- settings.crazyMoveState = 1;
- break;
- case 1:
- localPlayer->move(2, -2);
- settings.crazyMoveState = 2;
- break;
- case 2:
- localPlayer->move(0, -3);
- settings.crazyMoveState = 3;
- break;
- case 3:
- localPlayer->move(-2, -2);
- settings.crazyMoveState = 4;
- break;
- case 4:
- localPlayer->move(-3, 0);
- settings.crazyMoveState = 5;
- break;
- case 5:
- localPlayer->move(-2, 2);
- settings.crazyMoveState = 6;
- break;
- case 6:
- localPlayer->move(0, 3);
- settings.crazyMoveState = 7;
- break;
- case 7:
- localPlayer->move(2, 2);
- settings.crazyMoveState = 0;
- break;
- default:
- break;
- }
-}
-
-void CrazyMoves::crazyMove7()
-{
- if ((localPlayer == nullptr) ||
- localPlayer->getCurrentAction() == BeingAction::MOVE)
- {
- return;
- }
-
- switch (settings.crazyMoveState)
- {
- case 0:
- localPlayer->move(1, 1);
- settings.crazyMoveState = 1;
- break;
- case 1:
- localPlayer->move(-1, 1);
- settings.crazyMoveState = 2;
- break;
- case 2:
- localPlayer->move(-1, -1);
- settings.crazyMoveState = 3;
- break;
- case 3:
- localPlayer->move(1, -1);
- settings.crazyMoveState = 0;
- break;
- default:
- break;
- }
-}
-
-void CrazyMoves::crazyMove8()
-{
- if (localPlayer == nullptr ||
- localPlayer->getCurrentAction() == BeingAction::MOVE)
- {
- return;
- }
- const Map *const map = localPlayer->getMap();
- if (map == nullptr)
- return;
- const int x = localPlayer->getTileX();
- const int y = localPlayer->getTileY();
- int idx = 0;
- const int dist = 1;
-
-// look
-// up, ri,do,le
- static const int movesX[][4] =
- {
- {-1, 0, 1, 0}, // move left
- { 0, 1, 0, -1}, // move up
- { 1, 0, -1, 0}, // move right
- { 0, -1, 0, 1} // move down
- };
-
-// look
-// up, ri,do,le
- static const int movesY[][4] =
- {
- { 0, -1, 0, 1}, // move left
- {-1, 0, 1, 0}, // move up
- { 0, 1, 0, -1}, // move right
- { 1, 0, -1, 0} // move down
- };
-
- switch (localPlayer->getDirection())
- {
- case BeingDirection::UP:
- idx = 0;
- break;
-
- case BeingDirection::RIGHT:
- idx = 1;
- break;
-
- case BeingDirection::DOWN:
- idx = 2;
- break;
-
- case BeingDirection::LEFT:
- idx = 3;
- break;
-
- default:
- break;
- }
-
- int mult = 1;
- const unsigned char blockWalkMask = localPlayer->getBlockWalkMask();
- if (map->getWalk(x + movesX[idx][0],
- y + movesY[idx][0], blockWalkMask))
- {
- while (map->getWalk(x + movesX[idx][0] * mult,
- y + movesY[idx][0] * mult,
- blockWalkMask) && mult <= dist)
- {
- mult ++;
- }
- localPlayer->move(movesX[idx][0] * (mult - 1),
- movesY[idx][0] * (mult - 1));
- }
- else if (map->getWalk(x + movesX[idx][1],
- y + movesY[idx][1], blockWalkMask))
- {
- while (map->getWalk(x + movesX[idx][1] * mult,
- y + movesY[idx][1] * mult,
- blockWalkMask) && mult <= dist)
- {
- mult ++;
- }
- localPlayer->move(movesX[idx][1] * (mult - 1),
- movesY[idx][1] * (mult - 1));
- }
- else if (map->getWalk(x + movesX[idx][2],
- y + movesY[idx][2], blockWalkMask))
- {
- while (map->getWalk(x + movesX[idx][2] * mult,
- y + movesY[idx][2] * mult,
- blockWalkMask) && mult <= dist)
- {
- mult ++;
- }
- localPlayer->move(movesX[idx][2] * (mult - 1),
- movesY[idx][2] * (mult - 1));
- }
- else if (map->getWalk(x + movesX[idx][3],
- y + movesY[idx][3], blockWalkMask))
- {
- while (map->getWalk(x + movesX[idx][3] * mult,
- y + movesY[idx][3] * mult,
- blockWalkMask) && mult <= dist)
- {
- mult ++;
- }
- localPlayer->move(movesX[idx][3] * (mult - 1),
- movesY[idx][3] * (mult - 1));
- }
-}
-
-void CrazyMoves::crazyMove9()
-{
- int dx = 0;
- int dy = 0;
-
- if (localPlayer == nullptr ||
- localPlayer->getCurrentAction() == BeingAction::MOVE)
- {
- return;
- }
-
- switch (settings.crazyMoveState)
- {
- case 0:
- switch (localPlayer->getDirection())
- {
- case BeingDirection::UP : dy = -1; break;
- case BeingDirection::DOWN : dy = 1; break;
- case BeingDirection::LEFT : dx = -1; break;
- case BeingDirection::RIGHT: dx = 1; break;
- default: break;
- }
- localPlayer->move(dx, dy);
- settings.crazyMoveState = 1;
- break;
- case 1:
- settings.crazyMoveState = 2;
- if (!localPlayer->allowAction())
- return;
- if (playerHandler != nullptr)
- playerHandler->changeAction(BeingAction::SIT);
- break;
- case 2:
- settings.crazyMoveState = 3;
- break;
- case 3:
- settings.crazyMoveState = 0;
- break;
- default:
- break;
- }
-}
-
-void CrazyMoves::crazyMoveAm() const
-{
- if (localPlayer == nullptr)
- return;
-
- settings.crazyMoveState ++;
- if (settings.crazyMoveState < mMoveProgram.length())
- {
- int dx = 0;
- int dy = 0;
-
- signed char param = mMoveProgram[settings.crazyMoveState++];
- if (param == '?')
- {
- const char cmd[] = {'l', 'r', 'u', 'd', 'L', 'R', 'U', 'D'};
- srand(tick_time);
- param = cmd[rand() % 8];
- }
- switch (param)
- {
- case 'd':
- localPlayer->move(0, 1);
- break;
- case 'u':
- localPlayer->move(0, -1);
- break;
- case 'l':
- localPlayer->move(-1, 0);
- break;
- case 'r':
- localPlayer->move(1, 0);
- break;
- case 'D':
- localPlayer->move(1, 1);
- break;
- case 'U':
- localPlayer->move(-1, -1);
- break;
- case 'L':
- localPlayer->move(-1, 1);
- break;
- case 'R':
- localPlayer->move(1, -1);
- break;
- case 'f':
- {
- const uint8_t dir = localPlayer->getDirection();
- if ((dir & BeingDirection::UP) != 0)
- dy = -1;
- else if ((dir & BeingDirection::DOWN) != 0)
- dy = 1;
- if ((dir & BeingDirection::LEFT) != 0)
- dx = -1;
- else if ((dir & BeingDirection::RIGHT) != 0)
- dx = 1;
- localPlayer->move(dx, dy);
- break;
- }
- case 'b':
- {
- const uint8_t dir = localPlayer->getDirection();
- if ((dir & BeingDirection::UP) != 0)
- dy = 1;
- else if ((dir & BeingDirection::DOWN) != 0)
- dy = -1;
- if ((dir & BeingDirection::LEFT) != 0)
- dx = 1;
- else if ((dir & BeingDirection::RIGHT) != 0)
- dx = -1;
- localPlayer->move(dx, dy);
- break;
- }
- default:
- break;
- }
- }
-}
-
-void CrazyMoves::crazyMoveAd() const
-{
- settings.crazyMoveState ++;
-
- if (settings.crazyMoveState < mMoveProgram.length())
- {
- signed char param = mMoveProgram[settings.crazyMoveState++];
- if (param == '?')
- {
- const char cmd[] = {'l', 'r', 'u', 'd'};
- srand(tick_time);
- param = cmd[rand() % 4];
- }
- switch (param)
- {
- case 'd':
-// if (PacketLimiter::limitPackets(PacketType::PACKET_DIRECTION))
- {
- localPlayer->setDirection(BeingDirection::DOWN);
- playerHandler->setDirection(
- BeingDirection::DOWN);
- }
- break;
- case 'u':
-// if (PacketLimiter::limitPackets(PacketType::PACKET_DIRECTION))
- {
- localPlayer->setDirection(BeingDirection::UP);
- playerHandler->setDirection(
- BeingDirection::UP);
- }
- break;
- case 'l':
-// if (PacketLimiter::limitPackets(PacketType::PACKET_DIRECTION))
- {
- localPlayer->setDirection(BeingDirection::LEFT);
- playerHandler->setDirection(
- BeingDirection::LEFT);
- }
- break;
- case 'r':
-// if (PacketLimiter::limitPackets(PacketType::PACKET_DIRECTION))
- {
- localPlayer->setDirection(BeingDirection::RIGHT);
- playerHandler->setDirection(
- BeingDirection::RIGHT);
- }
- break;
- case 'L':
-// if (PacketLimiter::limitPackets(PacketType::PACKET_DIRECTION))
- {
- uint8_t dir = 0;
- switch (localPlayer->getDirection())
- {
- case BeingDirection::UP:
- dir = BeingDirection::LEFT;
- break;
- case BeingDirection::DOWN:
- dir = BeingDirection::RIGHT;
- break;
- case BeingDirection::LEFT:
- dir = BeingDirection::DOWN;
- break;
- case BeingDirection::RIGHT:
- dir = BeingDirection::UP;
- break;
- default:
- break;
- }
- localPlayer->setDirection(dir);
- playerHandler->setDirection(dir);
- }
- break;
- case 'R':
-// if (PacketLimiter::limitPackets(PacketType::PACKET_DIRECTION))
- {
- uint8_t dir = 0;
- switch (localPlayer->getDirection())
- {
- case BeingDirection::UP:
- dir = BeingDirection::RIGHT;
- break;
- case BeingDirection::DOWN:
- dir = BeingDirection::LEFT;
- break;
- case BeingDirection::LEFT:
- dir = BeingDirection::UP;
- break;
- case BeingDirection::RIGHT:
- dir = BeingDirection::DOWN;
- break;
- default:
- break;
- }
- localPlayer->setDirection(dir);
- playerHandler->setDirection(dir);
- }
- break;
- case 'b':
-// if (PacketLimiter::limitPackets(PacketType::PACKET_DIRECTION))
- {
- uint8_t dir = 0;
- switch (localPlayer->getDirection())
- {
- case BeingDirection::UP:
- dir = BeingDirection::DOWN;
- break;
- case BeingDirection::DOWN:
- dir = BeingDirection::UP;
- break;
- case BeingDirection::LEFT:
- dir = BeingDirection::RIGHT;
- break;
- case BeingDirection::RIGHT:
- dir = BeingDirection::LEFT;
- break;
- default:
- break;
- }
- localPlayer->setDirection(dir);
- playerHandler->setDirection(dir);
- }
- break;
- case '0':
- dropShortcut->dropFirst();
- break;
- case 'a':
- dropShortcut->dropItems();
- break;
- default:
- break;
- }
- }
-}
-
-void CrazyMoves::crazyMoveAs()
-{
- settings.crazyMoveState ++;
- if (localPlayer->toggleSit())
- settings.crazyMoveState ++;
-}
-
-void CrazyMoves::crazyMoveAo() const
-{
- settings.crazyMoveState ++;
- if (settings.crazyMoveState < mMoveProgram.length())
- {
- // wear next outfit
- if (mMoveProgram[settings.crazyMoveState] == 'n')
- {
- settings.crazyMoveState ++;
- outfitWindow->wearNextOutfit();
- }
- // wear previous outfit
- else if (mMoveProgram[settings.crazyMoveState] == 'p')
- {
- settings.crazyMoveState ++;
- outfitWindow->wearPreviousOutfit();
- }
- }
-}
-
-void CrazyMoves::crazyMoveAe() const
-{
- settings.crazyMoveState ++;
- const signed char emo = mMoveProgram[settings.crazyMoveState];
- unsigned char emoteId = 0;
- if (emo == '?')
- {
- srand(tick_time);
- emoteId = CAST_U8(
- 1 + (rand() % EmoteDB::size()));
- }
- else
- {
- if (emo >= '0' && emo <= '9')
- emoteId = CAST_U8(emo - '0' + 1);
- else if (emo >= 'a' && emo <= 'z')
- emoteId = CAST_U8(emo - 'a' + 11);
- else if (emo >= 'A' && emo <= 'Z')
- emoteId = CAST_U8(emo - 'A' + 37);
- }
- if (mMoveProgram[settings.crazyMoveState - 1] == 'e')
- LocalPlayer::emote(emoteId);
- else if (PacketLimiter::limitPackets(PacketType::PACKET_CHAT))
- petHandler->emote(emoteId);
-
- settings.crazyMoveState ++;
-}
-
-void CrazyMoves::crazyMoveA()
-{
- mMoveProgram = config.getStringValue("crazyMoveProgram");
-
- if (localPlayer->getCurrentAction() == BeingAction::MOVE)
- return;
-
- if (mMoveProgram.empty())
- return;
-
- if (settings.crazyMoveState >= mMoveProgram.length())
- settings.crazyMoveState = 0;
-
- // move command
- if (mMoveProgram[settings.crazyMoveState] == 'm')
- {
- crazyMoveAm();
- }
- // direction command
- else if (mMoveProgram[settings.crazyMoveState] == 'd')
- {
- crazyMoveAd();
- }
- // sit command
- else if (mMoveProgram[settings.crazyMoveState] == 's')
- {
- crazyMoveAs();
- }
- // wear outfits
- else if (mMoveProgram[settings.crazyMoveState] == 'o')
- {
- crazyMoveAo();
- }
- // pause
- else if (mMoveProgram[settings.crazyMoveState] == 'w')
- {
- settings.crazyMoveState ++;
- }
- // pick up
- else if (mMoveProgram[settings.crazyMoveState] == 'p')
- {
- settings.crazyMoveState ++;
- localPlayer->pickUpItems();
- }
- // emote
- else if (mMoveProgram[settings.crazyMoveState] == 'e'
- || mMoveProgram[settings.crazyMoveState] == 'E')
- {
- crazyMoveAe();
- }
- else
- {
- settings.crazyMoveState ++;
- }
-
- if (settings.crazyMoveState >= mMoveProgram.length())
- settings.crazyMoveState = 0;
-}
diff --git a/src/being/crazymoves.h b/src/being/crazymoves.h
deleted file mode 100644
index 4c812c5f0..000000000
--- a/src/being/crazymoves.h
+++ /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/>.
- */
-
-#ifndef BEING_CRAZYMOVES_H
-#define BEING_CRAZYMOVES_H
-
-#include <string>
-
-#include "localconsts.h"
-
-class CrazyMoves final
-{
- public:
- CrazyMoves();
- A_DELETE_COPY(CrazyMoves)
- void crazyMove();
-
- protected:
- static void crazyMove1();
- static void crazyMove2();
- static void crazyMove3();
- static void crazyMove4();
- static void crazyMove5();
- static void crazyMove6();
- static void crazyMove7();
- static void crazyMove8();
- static void crazyMove9();
- void crazyMoveA();
- void crazyMoveAd() const;
- void crazyMoveAe() const;
- void crazyMoveAm() const;
- void crazyMoveAo() const;
- static void crazyMoveAs();
-
- std::string mMoveProgram;
-
- // temporary disable crazy moves in moves
- bool mDisableCrazyMove;
-};
-
-extern CrazyMoves *crazyMoves;
-
-#endif // BEING_CRAZYMOVES_H
diff --git a/src/being/flooritem.cpp b/src/being/flooritem.cpp
deleted file mode 100644
index 041531e86..000000000
--- a/src/being/flooritem.cpp
+++ /dev/null
@@ -1,225 +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 "being/flooritem.h"
-
-#include "configuration.h"
-
-#include "render/graphics.h"
-
-#include "gui/gui.h"
-#include "gui/userpalette.h"
-
-#include "gui/fonts/font.h"
-
-#include "resources/iteminfo.h"
-
-#include "resources/db/itemdb.h"
-
-#include "resources/map/map.h"
-
-#ifdef TMWA_SUPPORT
-#include "net/net.h"
-#endif // TMWA_SUPPORT
-#include "net/serverfeatures.h"
-
-#include "debug.h"
-
-extern volatile time_t cur_time;
-
-FloorItem::FloorItem(const BeingId id,
- const int itemId,
- const int x, const int y,
- const ItemTypeT itemType,
- const int amount,
- const int refine,
- const ItemColor color,
- const Identified identified,
- const Damaged damaged,
- const int *const cards) :
- ActorSprite(id),
- mCards(),
- mItemId(itemId),
- mX(x),
- mY(y),
- mDropTime(cur_time),
- mAmount(amount),
- mRefine(refine),
- mHeightPosDiff(0),
- mItemType(itemType),
- mPickupCount(0),
- mCursor(Cursor::CURSOR_PICKUP),
- mColor(color),
- mIdentified(identified),
- mDamaged(damaged),
- mShowMsg(true),
- mHighlight(config.getBoolValue("floorItemsHighlight"))
-{
- setCards(cards, maxCards);
-}
-
-void FloorItem::postInit(Map *const map, int subX, int subY)
-{
- setMap(map);
- const ItemInfo &info = ItemDB::get(mItemId);
- if (map != nullptr)
- {
- const int maxX = info.getMaxFloorOffsetX();
- const int maxY = info.getMaxFloorOffsetY();
-
- if (!serverFeatures->haveExtendedDropsPosition())
- {
- if (subX > maxX)
- subX = maxX;
- else if (subX < -maxX)
- subX = -maxX;
- if (subY > maxY)
- subY = maxY;
- else if (subY < -maxY)
- subY = -maxY;
-
- subX -= 8;
- subY -= 8;
- }
-
- mHeightPosDiff = map->getHeightOffset(mX, mY) * 16;
- mPixelX = mX * map->getTileWidth()
- + subX + mapTileSize / 2;
- mPixelY = mY * map->getTileHeight()
- + subY + mapTileSize - mHeightPosDiff;
- mPos.x = static_cast<float>(mPixelX);
- mPos.y = static_cast<float>(mPixelY);
- mYDiff = 31 - mHeightPosDiff;
- }
- else
- {
- mPixelX = 0;
- mPixelY = 0;
- mPos.x = 0;
- mPos.y = 0;
- mYDiff = 31;
- }
-
- mCursor = info.getPickupCursor();
- setupSpriteDisplay(info.getDisplay(),
- ForceDisplay_true,
- DisplayType::Floor,
- info.getDyeIconColorsString(mColor));
-}
-
-void FloorItem::setCards(const int *const cards,
- int sz)
-{
- if (sz < 0 || cards == nullptr)
- return;
- if (sz > maxCards)
- sz = maxCards;
- for (int f = 0; f < sz; f ++)
- mCards[f] = cards[f];
-}
-
-const ItemInfo &FloorItem::getInfo() const
-{
- return ItemDB::get(mItemId);
-}
-
-std::string FloorItem::getName() const
-{
- const ItemInfo &info = ItemDB::get(mItemId);
-#ifdef TMWA_SUPPORT
- if (Net::getNetworkType() == ServerType::TMWATHENA)
- {
- return info.getName();
- }
-#endif // TMWA_SUPPORT
-
- return info.getName(mColor);
-}
-
-void FloorItem::draw(Graphics *const graphics,
- const int offsetX, const int offsetY) const
-{
- if (mMap == nullptr)
- return;
-
- BLOCK_START("FloorItem::draw")
- const int x = mX * mMap->getTileWidth() + offsetX;
- const int y = mY * mMap->getTileHeight() + offsetY - mHeightPosDiff;
- Font *font = nullptr;
-
- if (mHighlight)
- {
- const time_t curTime = cur_time;
- font = gui->getFont();
- if (mDropTime < curTime)
- {
- const int dx = mapTileSize;
- const int dy = mapTileSize;
-
- if (curTime > mDropTime + 28 && curTime < mDropTime + 50)
- {
- graphics->setColor(Color(80, 200, 20, 200));
- graphics->fillRectangle(Rect(
- x, y, dx, dy));
- }
- else if (curTime > mDropTime + 19
- && curTime < mDropTime + 28)
- {
- graphics->setColor(Color(200, 80, 20,
- 80 + 10 * CAST_S32(curTime - mDropTime - 18)));
- graphics->fillRectangle(Rect(
- x, y, dx, dy));
- }
- else if (curTime > mDropTime && curTime < mDropTime + 20)
- {
- graphics->setColor(Color(20, 20, 255,
- 7 * CAST_S32(curTime - mDropTime)));
- graphics->fillRectangle(Rect(x, y, dx, dy));
- }
- }
- }
-
- const int px = getActorX() + offsetX;
- const int py = getActorY() + offsetY;
- CompoundSprite::drawSimple(graphics, px, py);
-
- if (mHighlight)
- {
- if (font != nullptr && mAmount > 1)
- {
- const Color &color = userPalette->getColor(
- UserColorId::FLOOR_ITEM_TEXT);
- font->drawString(graphics,
- color, color,
- toString(mAmount),
- x, y);
- }
- }
- BLOCK_END("FloorItem::draw")
-}
-
-int FloorItem::getCard(const int index) const
-{
- if (index < 0 || index >= maxCards)
- return 0;
- return mCards[index];
-}
diff --git a/src/being/flooritem.h b/src/being/flooritem.h
deleted file mode 100644
index 700ce7d15..000000000
--- a/src/being/flooritem.h
+++ /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/>.
- */
-
-#ifndef BEING_FLOORITEM_H
-#define BEING_FLOORITEM_H
-
-#include "const/resources/item/cards.h"
-
-#include "enums/resources/cursor.h"
-
-#include "enums/resources/item/itemtype.h"
-
-#include "enums/simpletypes/damaged.h"
-#include "enums/simpletypes/identified.h"
-#include "enums/simpletypes/itemcolor.h"
-
-#include "being/actorsprite.h"
-
-class ItemInfo;
-
-/**
- * An item lying on the floor.
- */
-class FloorItem final : public ActorSprite
-{
- public:
- /**
- * Constructor.
- *
- * @param id the unique ID of this item instance
- * @param itemId the item ID
- * @param x the x position in tiles
- * @param y the y position in tiles
- * @param amount the item amount
- * @param color the item color
- */
- FloorItem(const BeingId id,
- const int itemId,
- const int x, const int y,
- const ItemTypeT itemType,
- const int amount,
- const int refine,
- const ItemColor color,
- const Identified identified,
- const Damaged damaged,
- const int *const cards);
-
- A_DELETE_COPY(FloorItem)
-
- void postInit(Map *const map, int subX, int subY);
-
- ActorTypeT getType() const noexcept2 override final A_WARN_UNUSED
- { return ActorType::FloorItem; }
-
- void draw(Graphics *const graphics,
- const int offsetX, const int offsetY)
- const override final A_NONNULL(2);
-
- /**
- * Returns the item ID.
- */
- int getItemId() const noexcept2 A_WARN_UNUSED
- { return mItemId; }
-
- /**
- * Returns the item info for this floor item. Useful for adding an item
- * link for the floor item to chat.
- */
- const ItemInfo &getInfo() const A_WARN_UNUSED;
-
- std::string getName() const A_WARN_UNUSED;
-
- int getTileX() const override final A_WARN_UNUSED
- { return mX; }
-
- int getTileY() const override final A_WARN_UNUSED
- { return mY; }
-
- void incrementPickup() noexcept2
- { mPickupCount ++; }
-
- unsigned getPickupCount() const noexcept2 A_WARN_UNUSED
- { return mPickupCount; }
-
- ItemColor getColor() const noexcept2 A_WARN_UNUSED
- { return mColor; }
-
- bool getShowMsg() const noexcept2 A_WARN_UNUSED
- { return mShowMsg; }
-
- void setShowMsg(const bool n) noexcept2
- { mShowMsg = n; }
-
- void disableHightlight() noexcept2
- { mHighlight = false; }
-
- CursorT getHoverCursor() const noexcept2 A_WARN_UNUSED
- { return mCursor; }
-
- void setCards(const int *const cards, int sz);
-
- int getCard(const int index) const;
-
- int getRefine() const noexcept2 A_WARN_UNUSED
- { return mRefine; }
-
- ItemTypeT getItemType() const noexcept2 A_WARN_UNUSED
- { return mItemType; }
-
- Identified getIdentified() const noexcept2 A_WARN_UNUSED
- { return mIdentified; }
-
- Damaged getDamaged() const noexcept2 A_WARN_UNUSED
- { return mDamaged; }
-
- private:
- int mCards[maxCards];
- int mItemId;
- int mX, mY;
- time_t mDropTime;
- int mAmount;
- int mRefine;
- int mHeightPosDiff;
- ItemTypeT mItemType;
- unsigned int mPickupCount;
- CursorT mCursor;
- ItemColor mColor;
- Identified mIdentified;
- Damaged mDamaged;
- bool mShowMsg;
- bool mHighlight;
-};
-
-#endif // BEING_FLOORITEM_H
diff --git a/src/being/homunculusinfo.h b/src/being/homunculusinfo.h
deleted file mode 100644
index 1488af9e8..000000000
--- a/src/being/homunculusinfo.h
+++ /dev/null
@@ -1,53 +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 BEING_HOMUNCULUSINFO_H
-#define BEING_HOMUNCULUSINFO_H
-
-#include "enums/simpletypes/beingid.h"
-
-#include <string>
-
-#include "localconsts.h"
-
-struct HomunculusInfo final
-{
- HomunculusInfo() :
- name(),
- id(BeingId_zero),
- level(0),
- range(0),
- hungry(0),
- intimacy(0),
- equip(0)
- { }
-
- A_DELETE_COPY(HomunculusInfo)
-
- std::string name;
- BeingId id;
- int level;
- int range;
- int hungry;
- int intimacy;
- int equip;
-};
-
-#endif // BEING_HOMUNCULUSINFO_H
diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp
deleted file mode 100644
index 1a12a3808..000000000
--- a/src/being/localplayer.cpp
+++ /dev/null
@@ -1,2816 +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 "being/localplayer.h"
-
-#include "actormanager.h"
-#include "configuration.h"
-#include "gamemodifiers.h"
-#include "guild.h"
-#include "party.h"
-#include "settings.h"
-#include "soundmanager.h"
-#include "statuseffect.h"
-
-#include "being/beingflag.h"
-#include "being/crazymoves.h"
-#include "being/playerinfo.h"
-#include "being/playerrelations.h"
-
-#include "const/sound.h"
-
-#include "enums/equipslot.h"
-
-#include "enums/being/beingdirection.h"
-
-#include "enums/resources/map/blockmask.h"
-#include "enums/resources/map/mapitemtype.h"
-
-#include "particle/particleengine.h"
-
-#include "input/keyboardconfig.h"
-
-#include "gui/gui.h"
-#include "gui/userpalette.h"
-#include "gui/popupmanager.h"
-
-#include "gui/windows/chatwindow.h"
-#include "gui/windows/ministatuswindow.h"
-#include "gui/windows/okdialog.h"
-#include "gui/windows/outfitwindow.h"
-#include "gui/windows/shopwindow.h"
-#include "gui/windows/socialwindow.h"
-#include "gui/windows/statuswindow.h"
-#include "gui/windows/updaterwindow.h"
-
-#include "gui/widgets/tabs/chat/whispertab.h"
-
-#include "listeners/awaylistener.h"
-
-#include "net/beinghandler.h"
-#include "net/chathandler.h"
-#include "net/inventoryhandler.h"
-#include "net/net.h"
-#include "net/packetlimiter.h"
-#include "net/playerhandler.h"
-#include "net/serverfeatures.h"
-
-#include "resources/iteminfo.h"
-
-#include "resources/db/weaponsdb.h"
-
-#include "resources/item/item.h"
-
-#include "resources/map/map.h"
-#include "resources/map/mapitem.h"
-#include "resources/map/speciallayer.h"
-#include "resources/map/walklayer.h"
-
-#include "resources/sprite/animatedsprite.h"
-
-#include "utils/delete2.h"
-#include "utils/foreach.h"
-#include "utils/gettext.h"
-#include "utils/timer.h"
-
-#ifdef USE_MUMBLE
-#include "mumblemanager.h"
-#endif // USE_MUMBLE
-
-#include <climits>
-
-#include "debug.h"
-
-static const int16_t awayLimitTimer = 60;
-static const int MAX_TICK_VALUE = INT_MAX / 2;
-
-typedef std::map<int, Guild*>::const_iterator GuildMapCIter;
-
-LocalPlayer *localPlayer = nullptr;
-
-extern OkDialog *weightNotice;
-extern time_t weightNoticeTime;
-
-LocalPlayer::LocalPlayer(const BeingId id,
- const BeingTypeId subType) :
- Being(id, ActorType::Player),
- ActorSpriteListener(),
- AttributeListener(),
- PlayerDeathListener(),
- mMoveState(0),
- mLastTargetX(0),
- mLastTargetY(0),
- mHomes(),
- mTarget(nullptr),
- mPlayerFollowed(),
- mPlayerImitated(),
- mNextDestX(0),
- mNextDestY(0),
- mPickUpTarget(nullptr),
- mLastAction(-1),
- mStatusEffectIcons(),
- mMessages(),
- mMessageTime(0),
- mAwayListener(new AwayListener),
- mAwayDialog(nullptr),
- mPingSendTick(0),
- mPingTime(0),
- mAfkTime(0),
- mActivityTime(0),
- mNavigateX(0),
- mNavigateY(0),
- mNavigateId(BeingId_zero),
- mCrossX(0),
- mCrossY(0),
- mOldX(0),
- mOldY(0),
- mOldTileX(0),
- mOldTileY(0),
- mNavigatePath(),
- mLastHitFrom(),
- mWaitFor(),
- mAdvertTime(0),
- mTestParticle(nullptr),
- mTestParticleName(),
- mTestParticleTime(0),
- mTestParticleHash(0L),
- mSyncPlayerMoveDistance(config.getIntValue("syncPlayerMoveDistance")),
- mUnfreezeTime(0),
- mWalkingDir(0),
- mUpdateName(true),
- mBlockAdvert(false),
- mTargetDeadPlayers(config.getBoolValue("targetDeadPlayers")),
- mServerAttack(fromBool(config.getBoolValue("serverAttack"), Keep)),
- mVisibleNames(static_cast<VisibleName::Type>(
- config.getIntValue("visiblenames"))),
- mEnableAdvert(config.getBoolValue("enableAdvert")),
- mTradebot(config.getBoolValue("tradebot")),
- mTargetOnlyReachable(config.getBoolValue("targetOnlyReachable")),
- mIsServerBuggy(serverConfig.getValueBool("enableBuggyServers", true)),
- mSyncPlayerMove(config.getBoolValue("syncPlayerMove")),
- mDrawPath(config.getBoolValue("drawPath")),
- mAttackMoving(config.getBoolValue("attackMoving")),
- mAttackNext(config.getBoolValue("attackNext")),
- mShowJobExp(config.getBoolValue("showJobExp")),
- mShowServerPos(config.getBoolValue("showserverpos")),
- mNextStep(false),
- mGoingToTarget(false),
- mKeepAttacking(false),
- mPathSetByMouse(false),
- mWaitPing(false),
- mShowNavigePath(false),
- mAllowRename(false),
- mFreezed(false)
-{
- logger->log1("LocalPlayer::LocalPlayer");
-
- postInit(subType, nullptr);
- mAttackRange = 0;
- mLevel = 1;
- mAdvanced = true;
- mTextColor = &theme->getColor(ThemeColorId::PLAYER, 255);
- if (userPalette != nullptr)
- mNameColor = &userPalette->getColor(UserColorId::SELF);
- else
- mNameColor = nullptr;
-
- PlayerInfo::setStatBase(Attributes::PLAYER_WALK_SPEED,
- getWalkSpeed());
- PlayerInfo::setStatMod(Attributes::PLAYER_WALK_SPEED, 0);
-
- loadHomes();
-
- config.addListener("showownname", this);
- config.addListener("targetDeadPlayers", this);
- serverConfig.addListener("enableBuggyServers", this);
- config.addListener("syncPlayerMove", this);
- config.addListener("syncPlayerMoveDistance", this);
- config.addListener("drawPath", this);
- config.addListener("serverAttack", this);
- config.addListener("attackMoving", this);
- config.addListener("attackNext", this);
- config.addListener("showJobExp", this);
- config.addListener("enableAdvert", this);
- config.addListener("tradebot", this);
- config.addListener("targetOnlyReachable", this);
- config.addListener("showserverpos", this);
- config.addListener("visiblenames", this);
- setShowName(config.getBoolValue("showownname"));
-}
-
-LocalPlayer::~LocalPlayer()
-{
- logger->log1("LocalPlayer::~LocalPlayer");
-
- config.removeListeners(this);
- serverConfig.removeListener("enableBuggyServers", this);
-
- navigateClean();
- mCrossX = 0;
- mCrossY = 0;
-
- updateNavigateList();
-
- if (mAwayDialog != nullptr)
- {
- soundManager.volumeRestore();
- delete2(mAwayDialog)
- }
- delete2(mAwayListener);
-}
-
-void LocalPlayer::logic()
-{
- BLOCK_START("LocalPlayer::logic")
-#ifdef USE_MUMBLE
- if (mumbleManager)
- mumbleManager->setPos(mX, mY, mDirection);
-#endif // USE_MUMBLE
-
- // Actions are allowed once per second
- if (get_elapsed_time(mLastAction) >= 1000)
- mLastAction = -1;
-
- if (mActivityTime == 0 || mLastAction != -1)
- mActivityTime = cur_time;
-
- if (mUnfreezeTime > 0 &&
- mUnfreezeTime <= tick_time)
- {
- mUnfreezeTime = 0;
- mFreezed = false;
- }
-
- if ((mAction != BeingAction::MOVE || mNextStep) && !mNavigatePath.empty())
- {
- mNextStep = false;
- int dist = 5;
- if (!mSyncPlayerMove)
- dist = 20;
-
- if (((mNavigateX != 0) || (mNavigateY != 0)) &&
- ((mCrossX + dist >= mX && mCrossX <= mX + dist
- && mCrossY + dist >= mY && mCrossY <= mY + dist)
- || ((mCrossX == 0) && (mCrossY == 0))))
- {
- const Path::const_iterator i = mNavigatePath.begin();
- if ((*i).x == mX && (*i).y == mY)
- mNavigatePath.pop_front();
- else
- setDestination((*i).x, (*i).y);
- }
- }
-
- // Show XP messages
- if (!mMessages.empty())
- {
- if (mMessageTime == 0)
- {
- const MessagePair info = mMessages.front();
-
- if ((particleEngine != nullptr) && (gui != nullptr))
- {
- particleEngine->addTextRiseFadeOutEffect(
- info.first,
- mPixelX,
- mPixelY - 48,
- &userPalette->getColor(info.second),
- gui->getInfoParticleFont(),
- true);
- }
-
- mMessages.pop_front();
- mMessageTime = 30;
- }
- mMessageTime--;
- }
-
- if (mTarget != nullptr)
- {
- if (mTarget->getType() == ActorType::Npc)
- {
- // NPCs are always in range
- mTarget->setTargetType(TargetCursorType::IN_RANGE);
- }
- else
- {
- // Find whether target is in range
- const int rangeX = CAST_S32(
- abs(mTarget->mX - mX));
- const int rangeY = CAST_S32(
- abs(mTarget->mY - mY));
- const int attackRange = getAttackRange();
- const TargetCursorTypeT targetType
- = rangeX > attackRange || rangeY > attackRange
- ? TargetCursorType::NORMAL : TargetCursorType::IN_RANGE;
- mTarget->setTargetType(targetType);
-
- if (!mTarget->isAlive() && (!mTargetDeadPlayers
- || mTarget->getType() != ActorType::Player))
- {
- stopAttack(true);
- }
-
- if (mKeepAttacking && (mTarget != nullptr))
- attack(mTarget, true);
- }
- }
-
- Being::logic();
- BLOCK_END("LocalPlayer::logic")
-}
-
-void LocalPlayer::slowLogic()
-{
- BLOCK_START("LocalPlayer::slowLogic")
- const time_t time = cur_time;
- if ((weightNotice != nullptr) && weightNoticeTime < time)
- {
- weightNotice->scheduleDelete();
- weightNotice = nullptr;
- weightNoticeTime = 0;
- }
-
- if ((serverFeatures != nullptr) &&
- !serverFeatures->havePlayerStatusUpdate() &&
- mEnableAdvert &&
- !mBlockAdvert &&
- mAdvertTime < cur_time)
- {
- uint8_t smile = BeingFlag::SPECIAL;
- if (mTradebot &&
- shopWindow != nullptr &&
- !shopWindow->isShopEmpty())
- {
- smile |= BeingFlag::SHOP;
- }
-
- if (settings.awayMode || settings.pseudoAwayMode)
- smile |= BeingFlag::AWAY;
-
- if (mInactive)
- smile |= BeingFlag::INACTIVE;
-
- if (emote(smile))
- mAdvertTime = time + 60;
- else
- mAdvertTime = time + 30;
- }
-
- if (mTestParticleTime != time && !mTestParticleName.empty())
- {
- const unsigned long hash = UpdaterWindow::getFileHash(
- mTestParticleName);
- if (hash != mTestParticleHash)
- {
- setTestParticle(mTestParticleName, false);
- mTestParticleHash = hash;
- }
- mTestParticleTime = time;
- }
-
- BLOCK_END("LocalPlayer::slowLogic")
-}
-
-void LocalPlayer::setAction(const BeingActionT &action,
- const int attackId)
-{
- if (action == BeingAction::DEAD)
- {
- if (!mLastHitFrom.empty() &&
- !serverFeatures->haveKillerId())
- {
- // TRANSLATORS: chat message after death
- debugMsg(strprintf(_("You were killed by %s."),
- mLastHitFrom.c_str()));
- mLastHitFrom.clear();
- }
- setTarget(nullptr);
- }
-
- Being::setAction(action,
- attackId);
-#ifdef USE_MUMBLE
- if (mumbleManager)
- mumbleManager->setAction(CAST_S32(action));
-#endif // USE_MUMBLE
-}
-
-void LocalPlayer::setGroupId(const int id)
-{
- Being::setGroupId(id);
-
- if (id > 0)
- {
- setGM(true);
- if (chatWindow != nullptr)
- {
- chatWindow->loadGMCommands();
- chatWindow->showGMTab();
- }
- }
- else
- {
- setGM(false);
- }
- if (statusWindow != nullptr)
- statusWindow->updateLevelLabel();
-}
-
-void LocalPlayer::nextTile(unsigned char dir A_UNUSED = 0)
-{
- const Party *const party = Party::getParty(1);
- if (party != nullptr)
- {
- PartyMember *const pm = party->getMember(mName);
- if (pm != nullptr)
- {
- pm->setX(mX);
- pm->setY(mY);
- }
- }
-
- if (mPath.empty())
- {
- if (mPickUpTarget != nullptr)
- pickUp(mPickUpTarget);
-
- if (mWalkingDir != 0u)
- startWalking(mWalkingDir);
- }
- else if (mPath.size() == 1)
- {
- if (mPickUpTarget != nullptr)
- pickUp(mPickUpTarget);
- }
-
- if (mGoingToTarget && (mTarget != nullptr) && withinAttackRange(mTarget))
- {
- mAction = BeingAction::STAND;
- attack(mTarget, true);
- mGoingToTarget = false;
- mPath.clear();
- return;
- }
- else if (mGoingToTarget && (mTarget == nullptr))
- {
- mGoingToTarget = false;
- mPath.clear();
- }
-
- if (mPath.empty())
- {
- if (mNavigatePath.empty() || mAction != BeingAction::MOVE)
- setAction(BeingAction::STAND, 0);
- else
- mNextStep = true;
- }
- else
- {
- Being::nextTile();
- }
-}
-
-bool LocalPlayer::pickUp(FloorItem *const item)
-{
- if (item == nullptr)
- return false;
-
- if (!PacketLimiter::limitPackets(PacketType::PACKET_PICKUP))
- return false;
-
- const int dx = item->getTileX() - mX;
- const int dy = item->getTileY() - mY;
- int dist = 6;
-
- const unsigned int pickUpType = settings.pickUpType;
- if (pickUpType >= 4 && pickUpType <= 6)
- dist = 4;
-
- if (dx * dx + dy * dy < dist)
- {
- if ((actorManager != nullptr) && actorManager->checkForPickup(item))
- {
- PlayerInfo::pickUpItem(item, Sfx_true);
- mPickUpTarget = nullptr;
- }
- }
- else if (pickUpType >= 4 && pickUpType <= 6)
- {
- const Path debugPath = mMap->findPath(
- (mPixelX - mapTileSize / 2) / mapTileSize,
- (mPixelY - mapTileSize) / mapTileSize,
- item->getTileX(),
- item->getTileY(),
- getBlockWalkMask(),
- 0);
- if (!debugPath.empty())
- navigateTo(item->getTileX(), item->getTileY());
- else
- setDestination(item->getTileX(), item->getTileY());
-
- mPickUpTarget = item;
- mPickUpTarget->addActorSpriteListener(this);
- }
- return true;
-}
-
-void LocalPlayer::actorSpriteDestroyed(const ActorSprite &actorSprite)
-{
- if (mPickUpTarget == &actorSprite)
- mPickUpTarget = nullptr;
-}
-
-Being *LocalPlayer::getTarget() const
-{
- return mTarget;
-}
-
-void LocalPlayer::setTarget(Being *const target)
-{
- if (target == this && (target != nullptr))
- return;
-
- if (target == mTarget)
- return;
-
- Being *oldTarget = nullptr;
- if (mTarget != nullptr)
- {
- mTarget->untarget();
- oldTarget = mTarget;
- }
-
- if (mTarget != nullptr)
- {
- if (mTarget->getType() == ActorType::Monster)
- mTarget->setShowName(false);
- }
-
- mTarget = target;
-
- if (oldTarget != nullptr)
- oldTarget->updateName();
-
- if (target != nullptr)
- {
- mLastTargetX = target->mX;
- mLastTargetY = target->mY;
- target->updateName();
- if (mVisibleNames == VisibleName::ShowOnSelection)
- target->setShowName(true);
- }
- if (oldTarget != nullptr && mVisibleNames == VisibleName::ShowOnSelection)
- oldTarget->setShowName(false);
- if (target != nullptr && target->getType() == ActorType::Monster)
- target->setShowName(true);
-}
-
-Being *LocalPlayer::setNewTarget(const ActorTypeT type,
- const AllowSort allowSort)
-{
- if (actorManager != nullptr)
- {
- Being *const target = actorManager->findNearestLivingBeing(
- localPlayer, 20, type, allowSort);
-
- if ((target != nullptr) && target != mTarget)
- setTarget(target);
-
- return target;
- }
- return nullptr;
-}
-
-void LocalPlayer::setDestination(const int x, const int y)
-{
- mActivityTime = cur_time;
-
- if (settings.attackType == 0 || !mAttackMoving)
- mKeepAttacking = false;
-
- // Only send a new message to the server when destination changes
- if (x != mDest.x || y != mDest.y)
- {
- if (settings.moveType != 1)
- {
- playerHandler->setDestination(x, y, mDirection);
- Being::setDestination(x, y);
- }
- else
- {
- uint8_t newDir = 0;
- if ((mDirection & BeingDirection::UP) != 0)
- newDir |= BeingDirection::DOWN;
- if ((mDirection & BeingDirection::LEFT) != 0)
- newDir |= BeingDirection::RIGHT;
- if ((mDirection & BeingDirection::DOWN) != 0)
- newDir |= BeingDirection::UP;
- if ((mDirection & BeingDirection::RIGHT) != 0)
- newDir |= BeingDirection::LEFT;
-
- playerHandler->setDestination(x, y, newDir);
-
-// if (PacketLimiter::limitPackets(PacketType::PACKET_DIRECTION))
- {
- setDirection(newDir);
- playerHandler->setDirection(newDir);
- }
-
- Being::setDestination(x, y);
- playerHandler->setDestination(x, y, mDirection);
- }
- }
-}
-
-void LocalPlayer::setWalkingDir(const unsigned char dir)
-{
- // This function is called by Game::handleInput()
- mWalkingDir = dir;
-
- // If we're not already walking, start walking.
- if (mAction != BeingAction::MOVE && (dir != 0u))
- startWalking(dir);
-}
-
-void LocalPlayer::startWalking(const unsigned char dir)
-{
- // This function is called by setWalkingDir(),
- // but also by nextTile() for TMW-Athena...
- if ((mMap == nullptr) || (dir == 0u))
- return;
-
- mPickUpTarget = nullptr;
- if (mAction == BeingAction::MOVE && !mPath.empty())
- {
- // Just finish the current action, otherwise we get out of sync
- Being::setDestination(mX, mY);
- return;
- }
-
- int dx = 0, dy = 0;
- if ((dir & BeingDirection::UP) != 0)
- dy--;
- if ((dir & BeingDirection::DOWN) != 0)
- dy++;
- if ((dir & BeingDirection::LEFT) != 0)
- dx--;
- if ((dir & BeingDirection::RIGHT) != 0)
- dx++;
-
- const unsigned char blockWalkMask = getBlockWalkMask();
- // Prevent skipping corners over colliding tiles
- if ((dx != 0) && !mMap->getWalk(mX + dx, mY, blockWalkMask))
- dx = 0;
- if ((dy != 0) && !mMap->getWalk(mX, mY + dy, blockWalkMask))
- dy = 0;
-
- // Choose a straight direction when diagonal target is blocked
- if (dx != 0 && dy != 0 && !mMap->getWalk(mX + dx, mY + dy, blockWalkMask))
- dx = 0;
-
- // Walk to where the player can actually go
- if ((dx != 0 || dy != 0) && mMap->getWalk(mX + dx, mY + dy, blockWalkMask))
- {
- setDestination(mX + dx, mY + dy);
- }
- else if (dir != mDirection)
- {
- // If the being can't move, just change direction
-
-// if (PacketLimiter::limitPackets(PacketType::PACKET_DIRECTION))
- {
- playerHandler->setDirection(dir);
- setDirection(dir);
- }
- }
-}
-
-void LocalPlayer::stopWalking(const bool sendToServer)
-{
- if (mAction == BeingAction::MOVE && (mWalkingDir != 0u))
- {
- mWalkingDir = 0;
- mPickUpTarget = nullptr;
- setDestination(mPixelX,
- mPixelY);
- if (sendToServer)
- {
- playerHandler->setDestination(
- mPixelX,
- mPixelY,
- -1);
- }
- setAction(BeingAction::STAND, 0);
- }
-
- // No path set anymore, so we reset the path by mouse flag
- mPathSetByMouse = false;
-
- clearPath();
- navigateClean();
-}
-
-bool LocalPlayer::toggleSit() const
-{
- if (!PacketLimiter::limitPackets(PacketType::PACKET_SIT))
- return false;
-
- BeingActionT newAction;
- switch (mAction)
- {
- case BeingAction::STAND:
- case BeingAction::PRESTAND:
- case BeingAction::SPAWN:
- newAction = BeingAction::SIT;
- break;
- case BeingAction::SIT:
- newAction = BeingAction::STAND;
- break;
- case BeingAction::MOVE:
- case BeingAction::ATTACK:
- case BeingAction::DEAD:
- case BeingAction::HURT:
- case BeingAction::CAST:
- default:
- return true;
- }
-
- playerHandler->changeAction(newAction);
- return true;
-}
-
-bool LocalPlayer::updateSit() const
-{
- if (!PacketLimiter::limitPackets(PacketType::PACKET_SIT))
- return false;
-
- playerHandler->changeAction(mAction);
- return true;
-}
-
-bool LocalPlayer::emote(const uint8_t emotion)
-{
- if (!PacketLimiter::limitPackets(PacketType::PACKET_EMOTE))
- return false;
-
- playerHandler->emote(emotion);
- return true;
-}
-
-void LocalPlayer::attack(Being *const target, const bool keep,
- const bool dontChangeEquipment)
-{
- mKeepAttacking = keep;
-
- if ((target == nullptr) || target->getType() == ActorType::Npc)
- return;
-
- if (mTarget != target)
- setTarget(target);
-
- // Must be standing or sitting or casting to attack
- if (mAction != BeingAction::STAND &&
- mAction != BeingAction::SIT &&
- mAction != BeingAction::CAST)
- {
- return;
- }
-
-#ifdef TMWA_SUPPORT
- const int dist_x = target->mX - mX;
- const int dist_y = target->mY - mY;
-
- if (Net::getNetworkType() == ServerType::TMWATHENA)
- {
- if (abs(dist_y) >= abs(dist_x))
- {
- if (dist_y > 0)
- setDirection(BeingDirection::DOWN);
- else
- setDirection(BeingDirection::UP);
- }
- else
- {
- if (dist_x > 0)
- setDirection(BeingDirection::RIGHT);
- else
- setDirection(BeingDirection::LEFT);
- }
- }
-#endif // TMWA_SUPPORT
-
- mActionTime = tick_time;
-
- if (target->getType() != ActorType::Player
- || checAttackPermissions(target))
- {
- setAction(BeingAction::ATTACK, 0);
-
- if (!PacketLimiter::limitPackets(PacketType::PACKET_ATTACK))
- return;
-
- if (!dontChangeEquipment)
- changeEquipmentBeforeAttack(target);
-
- const BeingId targetId = target->getId();
- playerHandler->attack(targetId, mServerAttack);
- PlayerInfo::updateAttackAi(targetId, mServerAttack);
- }
-
- if (!keep)
- stopAttack();
-}
-
-void LocalPlayer::stopAttack(const bool keepAttack)
-{
- if (!PacketLimiter::limitPackets(PacketType::PACKET_STOPATTACK))
- return;
-
- if (mServerAttack == Keep_true && mAction == BeingAction::ATTACK)
- playerHandler->stopAttack();
-
- untarget();
- if (!keepAttack || !mAttackNext)
- mKeepAttacking = false;
-}
-
-void LocalPlayer::untarget()
-{
- if (mAction == BeingAction::ATTACK)
- setAction(BeingAction::STAND, 0);
-
- if (mTarget != nullptr)
- setTarget(nullptr);
-}
-
-void LocalPlayer::pickedUp(const ItemInfo &itemInfo,
- const int amount,
- const ItemColor color,
- const BeingId floorItemId,
- const PickupT fail)
-{
- if (fail != Pickup::OKAY)
- {
- if ((actorManager != nullptr) && floorItemId != BeingId_zero)
- {
- FloorItem *const item = actorManager->findItem(floorItemId);
- if (item != nullptr)
- {
- if (!item->getShowMsg())
- return;
- item->setShowMsg(false);
- }
- }
- const char* msg = nullptr;
- switch (fail)
- {
- case Pickup::BAD_ITEM:
- // TRANSLATORS: pickup error message
- msg = N_("Tried to pick up nonexistent item.");
- break;
- case Pickup::TOO_HEAVY:
- // TRANSLATORS: pickup error message
- msg = N_("Item is too heavy.");
- break;
- case Pickup::TOO_FAR:
- // TRANSLATORS: pickup error message
- msg = N_("Item is too far away.");
- break;
- case Pickup::INV_FULL:
- // TRANSLATORS: pickup error message
- msg = N_("Inventory is full.");
- break;
- case Pickup::STACK_FULL:
- // TRANSLATORS: pickup error message
- msg = N_("Stack is too big.");
- break;
- case Pickup::DROP_STEAL:
- // TRANSLATORS: pickup error message
- msg = N_("Item belongs to someone else.");
- break;
- case Pickup::MAX_AMOUNT:
- // TRANSLATORS: pickup error message
- msg = N_("You can't pickup this amount of items.");
- break;
- case Pickup::STACK_AMOUNT:
- // TRANSLATORS: pickup error message
- msg = N_("Your item stack has max amount.");
- break;
- case Pickup::OKAY:
- break;
- default:
- case Pickup::UNKNOWN:
- // TRANSLATORS: pickup error message
- msg = N_("Unknown problem picking up item.");
- break;
- }
- if ((localChatTab != nullptr) && config.getBoolValue("showpickupchat"))
- localChatTab->chatLog(gettext(msg), ChatMsgType::BY_SERVER);
-
- if ((mMap != nullptr) && config.getBoolValue("showpickupparticle"))
- {
- // Show pickup notification
- addMessageToQueue(gettext(msg), UserColorId::PICKUP_INFO);
- }
- }
- else
- {
- std::string str;
-#ifdef TMWA_SUPPORT
- if (Net::getNetworkType() == ServerType::TMWATHENA)
- {
- str = itemInfo.getName();
- }
- else
-#endif // TMWA_SUPPORT
- {
- str = itemInfo.getName(color);
- }
-
- if (config.getBoolValue("showpickupchat") && (localChatTab != nullptr))
- {
- // TRANSLATORS: %d is number,
- // [@@%d|%s@@] - here player can see link to item
- localChatTab->chatLog(strprintf(ngettext("You picked up %d "
- "[@@%d|%s@@].", "You picked up %d [@@%d|%s@@].", amount),
- amount, itemInfo.getId(), str.c_str()),
- ChatMsgType::BY_SERVER);
- }
-
- if ((mMap != nullptr) && config.getBoolValue("showpickupparticle"))
- {
- // Show pickup notification
- if (amount > 1)
- {
- addMessageToQueue(strprintf("%d x %s", amount,
- str.c_str()), UserColorId::PICKUP_INFO);
- }
- else
- {
- addMessageToQueue(str, UserColorId::PICKUP_INFO);
- }
- }
- }
-}
-
-int LocalPlayer::getAttackRange() const
-{
- if (mAttackRange > -1)
- {
- return mAttackRange;
- }
-
- const Item *const weapon = PlayerInfo::getEquipment(
- EquipSlot::FIGHT1_SLOT);
- if (weapon != nullptr)
- {
- const ItemInfo &info = weapon->getInfo();
- return info.getAttackRange();
- }
- return 48; // unarmed range
-}
-
-bool LocalPlayer::withinAttackRange(const Being *const target,
- const bool fixDistance,
- const int addRange) const
-{
- if (target == nullptr)
- return false;
-
- int range = getAttackRange() + addRange;
- int dx;
- int dy;
-
- if (fixDistance && range == 1)
- range = 2;
-
- dx = CAST_S32(abs(target->mX - mX));
- dy = CAST_S32(abs(target->mY - mY));
- return !(dx > range || dy > range);
-}
-
-void LocalPlayer::setGotoTarget(Being *const target)
-{
- if (target == nullptr)
- return;
-
- mPickUpTarget = nullptr;
- setTarget(target);
- mGoingToTarget = true;
- navigateTo(target->mX,
- target->mY);
-}
-
-void LocalPlayer::handleStatusEffect(const StatusEffect *const effect,
- const int32_t effectId,
- const Enable newStatus,
- const IsStart start)
-{
- Being::handleStatusEffect(effect,
- effectId,
- newStatus,
- start);
-
- if (effect != nullptr)
- {
- effect->deliverMessage();
- effect->playSFX();
-
- AnimatedSprite *const sprite = effect->getIcon();
-
- if (sprite == nullptr)
- {
- // delete sprite, if necessary
- for (size_t i = 0; i < mStatusEffectIcons.size(); )
- {
- if (mStatusEffectIcons[i] == effectId)
- {
- mStatusEffectIcons.erase(mStatusEffectIcons.begin() + i);
- if (miniStatusWindow != nullptr)
- miniStatusWindow->eraseIcon(CAST_S32(i));
- }
- else
- {
- i++;
- }
- }
- }
- else
- {
- // replace sprite or append
- bool found = false;
- const size_t sz = mStatusEffectIcons.size();
- for (size_t i = 0; i < sz; i++)
- {
- if (mStatusEffectIcons[i] == effectId)
- {
- if (miniStatusWindow != nullptr)
- miniStatusWindow->setIcon(CAST_S32(i), sprite);
- found = true;
- break;
- }
- }
-
- if (!found)
- { // add new
- const int offset = CAST_S32(mStatusEffectIcons.size());
- if (miniStatusWindow != nullptr)
- miniStatusWindow->setIcon(offset, sprite);
- mStatusEffectIcons.push_back(effectId);
- }
- }
- }
-}
-
-void LocalPlayer::addMessageToQueue(const std::string &message,
- const UserColorIdT color)
-{
- if (mMessages.size() < 20)
- mMessages.push_back(MessagePair(message, color));
-}
-
-void LocalPlayer::optionChanged(const std::string &value)
-{
- if (value == "showownname")
- {
- setShowName(config.getBoolValue("showownname"));
- }
- else if (value == "targetDeadPlayers")
- {
- mTargetDeadPlayers = config.getBoolValue("targetDeadPlayers");
- }
- else if (value == "enableBuggyServers")
- {
- mIsServerBuggy = serverConfig.getBoolValue("enableBuggyServers");
- }
- else if (value == "syncPlayerMove")
- {
- mSyncPlayerMove = config.getBoolValue("syncPlayerMove");
- }
- else if (value == "syncPlayerMoveDistance")
- {
- mSyncPlayerMoveDistance = config.getIntValue("syncPlayerMoveDistance");
- }
- else if (value == "drawPath")
- {
- mDrawPath = config.getBoolValue("drawPath");
- }
- else if (value == "serverAttack")
- {
- mServerAttack = fromBool(config.getBoolValue("serverAttack"), Keep);
- }
- else if (value == "attackMoving")
- {
- mAttackMoving = config.getBoolValue("attackMoving");
- }
- else if (value == "attackNext")
- {
- mAttackNext = config.getBoolValue("attackNext");
- }
- else if (value == "showJobExp")
- {
- mShowJobExp = config.getBoolValue("showJobExp");
- }
- else if (value == "enableAdvert")
- {
- mEnableAdvert = config.getBoolValue("enableAdvert");
- }
- else if (value == "tradebot")
- {
- mTradebot = config.getBoolValue("tradebot");
- }
- else if (value == "targetOnlyReachable")
- {
- mTargetOnlyReachable = config.getBoolValue("targetOnlyReachable");
- }
- else if (value == "showserverpos")
- {
- mShowServerPos = config.getBoolValue("showserverpos");
- }
- else if (value == "visiblenames")
- {
- mVisibleNames = static_cast<VisibleName::Type>(
- config.getIntValue("visiblenames"));
- }
-}
-
-void LocalPlayer::addJobMessage(const int change)
-{
- if (change != 0 && mMessages.size() < 20)
- {
- if (!mMessages.empty())
- {
- MessagePair pair = mMessages.back();
- // TRANSLATORS: this is normal experience
- if (pair.first.find(strprintf(" %s", _("xp"))) ==
- // TRANSLATORS: this is normal experience
- pair.first.size() - strlen(_("xp")) - 1)
- {
- mMessages.pop_back();
- // TRANSLATORS: this is job experience
- pair.first.append(strprintf(", %d %s", change, _("job")));
- mMessages.push_back(pair);
- }
- else
- {
- // TRANSLATORS: this is job experience
- addMessageToQueue(strprintf("%d %s", change, _("job")));
- }
- }
- else
- {
- // TRANSLATORS: this is job experience
- addMessageToQueue(strprintf("%d %s", change, _("job")));
- }
- }
-}
-
-void LocalPlayer::addXpMessage(const int change)
-{
- if (change != 0 && mMessages.size() < 20)
- {
- // TRANSLATORS: get xp message
- addMessageToQueue(strprintf("%d %s", change, _("xp")));
- }
-}
-
-void LocalPlayer::addHomunXpMessage(const int change)
-{
- if (change != 0 && mMessages.size() < 20)
- {
- addMessageToQueue(strprintf("%s %d %s",
- // TRANSLATORS: get homunculus xp message
- _("Homun"),
- change,
- // TRANSLATORS: get xp message
- _("xp")));
- }
-}
-
-void LocalPlayer::addHpMessage(const int change)
-{
- if (change != 0 && mMessages.size() < 20)
- {
- // TRANSLATORS: get hp message
- addMessageToQueue(strprintf("%d %s", change, _("hp")));
- }
-}
-
-void LocalPlayer::addSpMessage(const int change)
-{
- if (change != 0 && mMessages.size() < 20)
- {
- // TRANSLATORS: get hp message
- addMessageToQueue(strprintf("%d %s", change, _("mana")));
- }
-}
-
-void LocalPlayer::attributeChanged(const AttributesT id,
- const int64_t oldVal,
- const int64_t newVal)
-{
- PRAGMA45(GCC diagnostic push)
- PRAGMA45(GCC diagnostic ignored "-Wswitch-enum")
- switch (id)
- {
- case Attributes::PLAYER_EXP:
- {
- if (Net::getNetworkType() != ServerType::TMWATHENA)
- break;
- if (oldVal > newVal)
- break;
-
- const int change = CAST_S32(newVal - oldVal);
- addXpMessage(change);
- break;
- }
- case Attributes::PLAYER_BASE_LEVEL:
- mLevel = CAST_S32(newVal);
- break;
- case Attributes::PLAYER_HP:
- if (oldVal != 0 && newVal == 0)
- PlayerDeathListener::distributeEvent();
- break;
- case Attributes::PLAYER_JOB_EXP:
- {
- if (!mShowJobExp ||
- Net::getNetworkType() != ServerType::TMWATHENA)
- {
- return;
- }
- if (oldVal > newVal ||
- PlayerInfo::getAttribute(
- Attributes::PLAYER_JOB_EXP_NEEDED) == 0)
- {
- return;
- }
- const int32_t change = CAST_S32(newVal - oldVal);
- addJobMessage(change);
- break;
- }
- default:
- break;
- }
- PRAGMA45(GCC diagnostic pop)
-}
-
-void LocalPlayer::move(const int dX, const int dY)
-{
- mPickUpTarget = nullptr;
- setDestination(mX + dX, mY + dY);
-}
-
-void LocalPlayer::moveToTarget(int dist)
-{
- bool gotPos(false);
- Path debugPath;
-
- size_t limit(0);
-
- if (dist == -1)
- {
- dist = settings.moveToTargetType;
- if (dist != 0)
- {
- const bool broken = (Net::getNetworkType() ==
- ServerType::TMWATHENA);
- switch (dist)
- {
- case 10:
- dist = mAttackRange;
- if (dist == 1 && broken)
- dist = 2;
- break;
- case 11:
- dist = mAttackRange - 1;
- if (dist < 1)
- dist = 1;
- if (dist == 1 && broken)
- dist = 2;
- break;
- default:
- break;
- }
- }
- }
-
- if (mTarget != nullptr)
- {
- if (mMap != nullptr)
- {
- debugPath = mMap->findPath(
- (mPixelX - mapTileSize / 2) / mapTileSize,
- (mPixelY - mapTileSize) / mapTileSize,
- mTarget->mX,
- mTarget->mY,
- getBlockWalkMask(),
- 0);
- }
-
- const size_t sz = debugPath.size();
- if (sz < CAST_SIZE(dist))
- return;
- limit = CAST_S32(sz) - dist;
- gotPos = true;
- }
- else if ((mNavigateX != 0) || (mNavigateY != 0))
- {
- debugPath = mNavigatePath;
- limit = dist;
- gotPos = true;
- }
-
- if (gotPos)
- {
- if (dist == 0)
- {
- if (mTarget != nullptr)
- navigateTo(mTarget->mX, mTarget->mY);
- }
- else
- {
- Position pos(0, 0);
- size_t f = 0;
-
- for (Path::const_iterator i = debugPath.begin(),
- i_fend = debugPath.end();
- i != i_fend && f < limit; ++i, f++)
- {
- pos = (*i);
- }
- navigateTo(pos.x, pos.y);
- }
- }
- else if ((mLastTargetX != 0) || (mLastTargetY != 0))
- {
- navigateTo(mLastTargetX, mLastTargetY);
- }
-}
-
-void LocalPlayer::moveToHome()
-{
- mPickUpTarget = nullptr;
- if ((mX != mCrossX || mY != mCrossY) && (mCrossX != 0) && (mCrossY != 0))
- {
- setDestination(mCrossX, mCrossY);
- }
- else if (mMap != nullptr)
- {
- const std::map<std::string, Vector>::const_iterator iter =
- mHomes.find(mMap->getProperty("_realfilename"));
-
- if (iter != mHomes.end())
- {
- const Vector pos = mHomes[(*iter).first];
- if (mX == pos.x && mY == pos.y)
- {
- playerHandler->setDestination(
- CAST_S32(pos.x),
- CAST_S32(pos.y),
- CAST_S32(mDirection));
- }
- else
- {
- navigateTo(CAST_S32(pos.x), CAST_S32(pos.y));
- }
- }
- }
-}
-
-void LocalPlayer::changeEquipmentBeforeAttack(const Being *const target) const
-{
- if (settings.attackWeaponType == 1
- || (target == nullptr)
- || (PlayerInfo::getInventory() == nullptr))
- {
- return;
- }
-
- bool allowSword = false;
- const int dx = target->mX - mX;
- const int dy = target->mY - mY;
- const Item *item = nullptr;
-
- if (dx * dx + dy * dy > 80)
- return;
-
- if (dx * dx + dy * dy < 8)
- allowSword = true;
-
- const Inventory *const inv = PlayerInfo::getInventory();
- if (inv == nullptr)
- return;
-
- // if attack distance for sword
- if (allowSword)
- {
- // searching swords
- const WeaponsInfos &swords = WeaponsDB::getSwords();
- FOR_EACH (WeaponsInfosIter, it, swords)
- {
- item = inv->findItem(*it, ItemColor_zero);
- if (item != nullptr)
- break;
- }
-
- // no swords
- if (item == nullptr)
- return;
-
- // if sword not equiped
- if (item->isEquipped() == Equipped_false)
- PlayerInfo::equipItem(item, Sfx_true);
-
- // if need equip shield too
- if (settings.attackWeaponType == 3)
- {
- // searching shield
- const WeaponsInfos &shields = WeaponsDB::getShields();
- FOR_EACH (WeaponsInfosIter, it, shields)
- {
- item = inv->findItem(*it, ItemColor_zero);
- if (item != nullptr)
- break;
- }
- if ((item != nullptr) && item->isEquipped() == Equipped_false)
- PlayerInfo::equipItem(item, Sfx_true);
- }
- }
- // big distance. allowed only bow
- else
- {
- // searching bow
- const WeaponsInfos &bows = WeaponsDB::getBows();
- FOR_EACH (WeaponsInfosIter, it, bows)
- {
- item = inv->findItem(*it, ItemColor_zero);
- if (item != nullptr)
- break;
- }
-
- // no bow
- if (item == nullptr)
- return;
-
- if (item->isEquipped() == Equipped_false)
- PlayerInfo::equipItem(item, Sfx_true);
- }
-}
-
-bool LocalPlayer::isReachable(Being *const being,
- const int maxCost)
-{
- if ((being == nullptr) || (mMap == nullptr))
- return false;
-
- if (being->getReachable() == Reachable::REACH_NO)
- return false;
-
- if (being->mX == mX &&
- being->mY == mY)
- {
- being->setDistance(0);
- being->setReachable(Reachable::REACH_YES);
- return true;
- }
- else if (being->mX - 1 <= mX &&
- being->mX + 1 >= mX &&
- being->mY - 1 <= mY &&
- being->mY + 1 >= mY)
- {
- being->setDistance(1);
- being->setReachable(Reachable::REACH_YES);
- return true;
- }
-
- const Path debugPath = mMap->findPath(
- (mPixelX - mapTileSize / 2) / mapTileSize,
- (mPixelY - mapTileSize) / mapTileSize,
- being->mX,
- being->mY,
- getBlockWalkMask(),
- maxCost);
-
- being->setDistance(CAST_S32(debugPath.size()));
- if (!debugPath.empty())
- {
- being->setReachable(Reachable::REACH_YES);
- return true;
- }
- being->setReachable(Reachable::REACH_NO);
- return false;
-}
-
-bool LocalPlayer::isReachable(const int x, const int y,
- const bool allowCollision) const
-{
- const WalkLayer *const walk = mMap->getWalkLayer();
- if (walk == nullptr)
- return false;
- int num = walk->getDataAt(x, y);
- if (allowCollision && num < 0)
- num = -num;
-
- return walk->getDataAt(mX, mY) == num;
-}
-
-bool LocalPlayer::pickUpItems(int pickUpType)
-{
- if (actorManager == nullptr)
- return false;
-
- bool status = false;
- int x = mX;
- int y = mY;
-
- // first pick up item on player position
- FloorItem *item =
- actorManager->findItem(x, y);
- if (item != nullptr)
- status = pickUp(item);
-
- if (pickUpType == 0)
- pickUpType = settings.pickUpType;
-
- if (pickUpType == 0)
- return status;
-
- int x1, y1, x2, y2;
- switch (pickUpType)
- {
- case 1:
- switch (mDirection)
- {
- case BeingDirection::UP : --y; break;
- case BeingDirection::DOWN : ++y; break;
- case BeingDirection::LEFT : --x; break;
- case BeingDirection::RIGHT: ++x; break;
- default: break;
- }
- item = actorManager->findItem(x, y);
- if (item != nullptr)
- status = pickUp(item);
- break;
- case 2:
- switch (mDirection)
- {
- case BeingDirection::UP:
- x1 = x - 1; y1 = y - 1; x2 = x + 1; y2 = y; break;
- case BeingDirection::DOWN:
- x1 = x - 1; y1 = y; x2 = x + 1; y2 = y + 1; break;
- case BeingDirection::LEFT:
- x1 = x - 1; y1 = y - 1; x2 = x; y2 = y + 1; break;
- case BeingDirection::RIGHT:
- x1 = x; y1 = y - 1; x2 = x + 1; y2 = y + 1; break;
- default:
- x1 = x; x2 = x; y1 = y; y2 = y; break;
- }
- if (actorManager->pickUpAll(x1, y1, x2, y2))
- status = true;
- break;
- case 3:
- if (actorManager->pickUpAll(x - 1, y - 1, x + 1, y + 1))
- status = true;
- break;
-
- case 4:
- if (!actorManager->pickUpAll(x - 1, y - 1, x + 1, y + 1))
- {
- if (actorManager->pickUpNearest(x, y, 4))
- status = true;
- }
- else
- {
- status = true;
- }
- break;
-
- case 5:
- if (!actorManager->pickUpAll(x - 1, y - 1, x + 1, y + 1))
- {
- if (actorManager->pickUpNearest(x, y, 8))
- status = true;
- }
- else
- {
- status = true;
- }
- break;
-
- case 6:
- if (!actorManager->pickUpAll(x - 1, y - 1, x + 1, y + 1))
- {
- if (actorManager->pickUpNearest(x, y, 90))
- status = true;
- }
- else
- {
- status = true;
- }
- break;
-
- default:
- break;
- }
- return status;
-}
-
-
-void LocalPlayer::moveByDirection(const unsigned char dir)
-{
- int dx = 0, dy = 0;
- if ((dir & BeingDirection::UP) != 0)
- dy--;
- if ((dir & BeingDirection::DOWN) != 0)
- dy++;
- if ((dir & BeingDirection::LEFT) != 0)
- dx--;
- if ((dir & BeingDirection::RIGHT) != 0)
- dx++;
- move(dx, dy);
-}
-
-void LocalPlayer::specialMove(const unsigned char direction)
-{
- if ((direction != 0u) && ((mNavigateX != 0) || (mNavigateY != 0)))
- navigateClean();
-
- if ((direction != 0u) && (settings.moveType >= 2
- && settings.moveType <= 4))
- {
- if (mAction == BeingAction::MOVE)
- return;
-
- unsigned int max;
-
- if (settings.moveType == 2)
- max = 5;
- else if (settings.moveType == 4)
- max = 1;
- else
- max = 3;
-
- if (getMoveState() < max)
- {
- moveByDirection(direction);
- mMoveState ++;
- }
- else
- {
- mMoveState = 0;
- crazyMoves->crazyMove();
- }
- }
- else
- {
- setWalkingDir(direction);
- }
-}
-
-#ifdef TMWA_SUPPORT
-void LocalPlayer::magicAttack() const
-{
- if (Net::getNetworkType() != ServerType::TMWATHENA)
- return;
- if (chatWindow == nullptr ||
- !isAlive() ||
- !playerHandler->canUseMagic())
- {
- return;
- }
-
- switch (settings.magicAttackType)
- {
- // flar W00
- case 0:
- tryMagic("#flar", 1, 0, 10);
- break;
- // chiza W01
- case 1:
- tryMagic("#chiza", 1, 0, 9);
- break;
- // ingrav W10
- case 2:
- tryMagic("#ingrav", 2, 2, 20);
- break;
- // frillyar W11
- case 3:
- tryMagic("#frillyar", 2, 2, 25);
- break;
- // upmarmu W12
- case 4:
- tryMagic("#upmarmu", 2, 2, 20);
- break;
- default:
- break;
- }
-}
-
-void LocalPlayer::tryMagic(const std::string &spell, const int baseMagic,
- const int schoolMagic, const int mana)
-{
- if (chatWindow == nullptr)
- return;
-
- if (PlayerInfo::getSkillLevel(340) >= baseMagic
- && PlayerInfo::getSkillLevel(342) >= schoolMagic)
- {
- if (PlayerInfo::getAttribute(Attributes::PLAYER_MP) >= mana)
- {
- if (!PacketLimiter::limitPackets(PacketType::PACKET_CHAT))
- return;
-
- chatWindow->localChatInput(spell);
- }
- }
-}
-#endif // TMWA_SUPPORT
-
-void LocalPlayer::loadHomes()
-{
- std::string buf;
- std::stringstream ss(serverConfig.getValue("playerHomes", ""));
-
- while (ss >> buf)
- {
- Vector pos;
- ss >> pos.x;
- ss >> pos.y;
- mHomes[buf] = pos;
- }
-}
-
-void LocalPlayer::setMap(Map *const map)
-{
- BLOCK_START("LocalPlayer::setMap")
- if (map != nullptr)
- {
- if (socialWindow != nullptr)
- socialWindow->updateActiveList();
- }
- navigateClean();
- mCrossX = 0;
- mCrossY = 0;
-
- Being::setMap(map);
- updateNavigateList();
- BLOCK_END("LocalPlayer::setMap")
-}
-
-void LocalPlayer::setHome()
-{
- if ((mMap == nullptr) || (socialWindow == nullptr))
- return;
-
- SpecialLayer *const specialLayer = mMap->getSpecialLayer();
-
- if (specialLayer == nullptr)
- return;
-
- const std::string key = mMap->getProperty("_realfilename");
- Vector pos = mHomes[key];
-
- if (mAction == BeingAction::SIT)
- {
- const std::map<std::string, Vector>::const_iterator
- iter = mHomes.find(key);
-
- if (iter != mHomes.end())
- {
- socialWindow->removePortal(CAST_S32(pos.x),
- CAST_S32(pos.y));
- }
-
- if (iter != mHomes.end() && mX == CAST_S32(pos.x)
- && mY == CAST_S32(pos.y))
- {
- mMap->updatePortalTile("", MapItemType::EMPTY,
- CAST_S32(pos.x), CAST_S32(pos.y));
-
- mHomes.erase(key);
- socialWindow->removePortal(CAST_S32(pos.x),
- CAST_S32(pos.y));
- }
- else
- {
- if (iter != mHomes.end())
- {
- specialLayer->setTile(CAST_S32(pos.x),
- CAST_S32(pos.y), MapItemType::EMPTY);
- specialLayer->updateCache();
- }
-
- pos.x = static_cast<float>(mX);
- pos.y = static_cast<float>(mY);
- mHomes[key] = pos;
- mMap->updatePortalTile("home", MapItemType::HOME,
- mX, mY);
- socialWindow->addPortal(mX, mY);
- }
- MapItem *const mapItem = specialLayer->getTile(mX, mY);
- if (mapItem != nullptr)
- {
- const int idx = socialWindow->getPortalIndex(mX, mY);
- mapItem->setName(KeyboardConfig::getKeyShortString(
- OutfitWindow::keyName(idx)));
- }
- saveHomes();
- }
- else
- {
- MapItem *mapItem = specialLayer->getTile(mX, mY);
- int type = 0;
-
- const std::map<std::string, Vector>::iterator iter = mHomes.find(key);
- if (iter != mHomes.end() && mX == pos.x && mY == pos.y)
- {
- mHomes.erase(key);
- saveHomes();
- }
-
- if ((mapItem == nullptr) || mapItem->getType() == MapItemType::EMPTY)
- {
- if ((mDirection & BeingDirection::UP) != 0)
- type = MapItemType::ARROW_UP;
- else if ((mDirection & BeingDirection::LEFT) != 0)
- type = MapItemType::ARROW_LEFT;
- else if ((mDirection & BeingDirection::DOWN) != 0)
- type = MapItemType::ARROW_DOWN;
- else if ((mDirection & BeingDirection::RIGHT) != 0)
- type = MapItemType::ARROW_RIGHT;
- }
- else
- {
- type = MapItemType::EMPTY;
- }
- mMap->updatePortalTile("", type, mX, mY);
-
- if (type != MapItemType::EMPTY)
- {
- socialWindow->addPortal(mX, mY);
- mapItem = specialLayer->getTile(mX, mY);
- if (mapItem != nullptr)
- {
- const int idx = socialWindow->getPortalIndex(mX, mY);
- mapItem->setName(KeyboardConfig::getKeyShortString(
- OutfitWindow::keyName(idx)));
- }
- }
- else
- {
- specialLayer->setTile(mX, mY, MapItemType::EMPTY);
- specialLayer->updateCache();
- socialWindow->removePortal(mX, mY);
- }
- }
-}
-
-void LocalPlayer::saveHomes()
-{
- std::stringstream ss;
-
- for (std::map<std::string, Vector>::const_iterator iter = mHomes.begin(),
- iter_fend = mHomes.end();
- iter != iter_fend;
- ++iter)
- {
- const Vector &pos = (*iter).second;
-
- if (iter != mHomes.begin())
- ss << " ";
- ss << (*iter).first << " " << pos.x << " " << pos.y;
- }
-
- serverConfig.setValue("playerHomes", ss.str());
-}
-
-void LocalPlayer::pingRequest()
-{
- const int time = tick_time;
- if (mWaitPing == true && mPingSendTick != 0)
- {
- if (time >= mPingSendTick && (time - mPingSendTick) > 1000)
- return;
- }
-
- mPingSendTick = time;
- mWaitPing = true;
- beingHandler->requestNameById(getId());
-}
-
-std::string LocalPlayer::getPingTime() const
-{
- std::string str;
- if (!mWaitPing)
- {
- if (mPingTime == 0)
- str = "?";
- else
- str = toString(CAST_S32(mPingTime));
- }
- else
- {
- time_t time = tick_time;
- if (time > mPingSendTick)
- time -= mPingSendTick;
- else
- time += MAX_TICK_VALUE - mPingSendTick;
- if (time <= mPingTime)
- time = mPingTime;
- if (mPingTime != time)
- str = strprintf("%d (%d)", CAST_S32(mPingTime), CAST_S32(time));
- else
- str = toString(CAST_S32(time));
- }
- return str;
-}
-
-void LocalPlayer::pingResponse()
-{
- if (mWaitPing == true && mPingSendTick > 0)
- {
- mWaitPing = false;
- const int time = tick_time;
- if (time < mPingSendTick)
- {
- mPingSendTick = 0;
- mPingTime = 0;
- }
- else
- {
- mPingTime = (time - mPingSendTick) * 10;
- }
- }
-}
-
-void LocalPlayer::tryPingRequest()
-{
- if (mPingSendTick == 0 || tick_time < mPingSendTick
- || (tick_time - mPingSendTick) > 200)
- {
- pingRequest();
- }
-}
-
-
-void LocalPlayer::setAway(const std::string &message) const
-{
- setAfkMessage(message);
- GameModifiers::changeAwayMode(true);
- updateStatus();
-}
-
-void LocalPlayer::setAfkMessage(std::string message)
-{
- if (!message.empty())
- {
- if (message.size() > 4 && message.substr(0, 4) == "/me ")
- {
- message = message.substr(4);
- config.setValue("afkFormat", 1);
- }
- else
- {
- config.setValue("afkFormat", 0);
- }
- serverConfig.setValue("afkMessage", message);
- }
-}
-
-void LocalPlayer::setPseudoAway(const std::string &message)
-{
- setAfkMessage(message);
- settings.pseudoAwayMode = !settings.pseudoAwayMode;
-}
-
-void LocalPlayer::afkRespond(ChatTab *const tab, const std::string &nick)
-{
- if (settings.awayMode)
- {
- const time_t time = cur_time;
- if (mAfkTime == 0 || time < mAfkTime
- || time - mAfkTime > awayLimitTimer)
- {
- std::string str(serverConfig.getValue("afkMessage",
- "I am away from keyboard."));
- if (str.find("'NAME'") != std::string::npos)
- replaceAll(str, "'NAME'", nick);
-
- std::string msg("*AFK*: " + str);
-
- if (config.getIntValue("afkFormat") == 1)
- msg = "*" + msg + "*";
-
- if (tab == nullptr)
- {
- chatHandler->privateMessage(nick, msg);
- if (localChatTab != nullptr)
- {
- localChatTab->chatLog(std::string(mName).append(
- " : ").append(msg),
- ChatMsgType::ACT_WHISPER,
- IgnoreRecord_false);
- }
- }
- else
- {
- if (tab->getNoAway())
- return;
- chatHandler->privateMessage(nick, msg);
- tab->chatLog(mName, msg);
- }
- mAfkTime = time;
- }
- }
-}
-
-bool LocalPlayer::navigateTo(const int x, const int y)
-{
- if (mMap == nullptr)
- return false;
-
- SpecialLayer *const tmpLayer = mMap->getTempLayer();
- if (tmpLayer == nullptr)
- return false;
-
- mShowNavigePath = true;
- mOldX = mPixelX;
- mOldY = mPixelY;
- mOldTileX = mX;
- mOldTileY = mY;
- mNavigateX = x;
- mNavigateY = y;
- mNavigateId = BeingId_zero;
-
- mNavigatePath = mMap->findPath(
- (mPixelX - mapTileSize / 2) / mapTileSize,
- (mPixelY - mapTileSize) / mapTileSize,
- x,
- y,
- getBlockWalkMask(),
- 0);
-
- if (mDrawPath)
- tmpLayer->addRoad(mNavigatePath);
- return !mNavigatePath.empty();
-}
-
-void LocalPlayer::navigateClean()
-{
- if (mMap == nullptr)
- return;
-
- mShowNavigePath = false;
- mOldX = 0;
- mOldY = 0;
- mOldTileX = 0;
- mOldTileY = 0;
- mNavigateX = 0;
- mNavigateY = 0;
- mNavigateId = BeingId_zero;
-
- mNavigatePath.clear();
-
- SpecialLayer *const tmpLayer = mMap->getTempLayer();
- if (tmpLayer == nullptr)
- return;
-
- tmpLayer->clean();
-}
-
-void LocalPlayer::updateMusic() const
-{
- if (mMap != nullptr)
- {
- std::string str = mMap->getObjectData(mX, mY, MapItemType::MUSIC);
- if (str.empty())
- str = mMap->getMusicFile();
- if (str != soundManager.getCurrentMusicFile())
- {
- if (str.empty())
- soundManager.fadeOutMusic();
- else
- soundManager.fadeOutAndPlayMusic(str);
- }
- }
-}
-
-void LocalPlayer::updateCoords()
-{
- Being::updateCoords();
-
- // probably map not loaded.
- if ((mPixelX == 0) || (mPixelY == 0))
- return;
-
- if (mX != mOldTileX || mY != mOldTileY)
- {
- if (socialWindow != nullptr)
- socialWindow->updatePortals();
- PopupManager::hideBeingPopup();
- updateMusic();
- }
-
- if ((mMap != nullptr) && (mX != mOldTileX || mY != mOldTileY))
- {
- SpecialLayer *const tmpLayer = mMap->getTempLayer();
- if (tmpLayer == nullptr)
- return;
-
- const int x = (mPixelX - mapTileSize / 2) / mapTileSize;
- const int y = (mPixelY - mapTileSize) / mapTileSize;
- if (mNavigateId != BeingId_zero)
- {
- if (actorManager == nullptr)
- {
- navigateClean();
- return;
- }
-
- const Being *const being = actorManager
- ->findBeing(mNavigateId);
- if (being == nullptr)
- {
- navigateClean();
- return;
- }
- mNavigateX = being->mX;
- mNavigateY = being->mY;
- }
-
- if (mNavigateX == x && mNavigateY == y)
- {
- navigateClean();
- return;
- }
- for (Path::const_iterator i = mNavigatePath.begin(),
- i_fend = mNavigatePath.end();
- i != i_fend;
- ++i)
- {
- if ((*i).x == mX && (*i).y == mY)
- {
- mNavigatePath.pop_front();
- fixPos();
- break;
- }
- }
- if (mDrawPath && mShowNavigePath)
- {
- tmpLayer->clean();
- tmpLayer->addRoad(mNavigatePath);
- }
- }
- mOldX = mPixelX;
- mOldY = mPixelY;
- mOldTileX = mX;
- mOldTileY = mY;
-}
-
-void LocalPlayer::targetMoved() const
-{
-/*
- if (mKeepAttacking)
- {
- if (mTarget && mServerAttack == Keep_true)
- {
- logger->log("LocalPlayer::targetMoved0");
- if (!PacketLimiter::limitPackets(PacketType::PACKET_ATTACK))
- return;
- logger->log("LocalPlayer::targetMoved");
- playerHandler->attack(mTarget->getId(), mServerAttack);
- }
- }
-*/
-}
-
-int LocalPlayer::getPathLength(const Being *const being) const
-{
- if ((mMap == nullptr) || (being == nullptr))
- return 0;
-
- if (being->mX == mX && being->mY == mY)
- return 0;
-
- if (being->mX - 1 <= mX &&
- being->mX + 1 >= mX &&
- being->mY - 1 <= mY &&
- being->mY + 1 >= mY)
- {
- return 1;
- }
-
- if (mTargetOnlyReachable)
- {
- const Path debugPath = mMap->findPath(
- (mPixelX - mapTileSize / 2) / mapTileSize,
- (mPixelY - mapTileSize) / mapTileSize,
- being->mX,
- being->mY,
- getBlockWalkMask(),
- 0);
- return CAST_S32(debugPath.size());
- }
-
- const int dx = CAST_S32(abs(being->mX - mX));
- const int dy = CAST_S32(abs(being->mY - mY));
- if (dx > dy)
- return dx;
- return dy;
-}
-
-int LocalPlayer::getAttackRange2() const
-{
- int range = getAttackRange();
- if (range == 1)
- range = 2;
- return range;
-}
-
-void LocalPlayer::attack2(Being *const target, const bool keep,
- const bool dontChangeEquipment)
-{
- if (!dontChangeEquipment && (target != nullptr))
- changeEquipmentBeforeAttack(target);
-
- const bool broken = (Net::getNetworkType() == ServerType::TMWATHENA);
-
- // probably need cache getPathLength(target)
- if ((target == nullptr ||
- settings.attackType == 0 ||
- settings.attackType == 3) ||
- (withinAttackRange(target, broken, broken ? 1 : 0) &&
- getPathLength(target) <= getAttackRange2()))
- {
- attack(target, keep);
- if (settings.attackType == 2)
- {
- if (target == nullptr)
- {
- if (pickUpItems())
- return;
- }
- else
- {
- pickUpItems(3);
- }
- }
- }
- else if (mPickUpTarget == nullptr)
- {
- if (settings.attackType == 2)
- {
- if (pickUpItems())
- return;
- }
- setTarget(target);
- if (target->getType() != ActorType::Npc)
- {
- mKeepAttacking = true;
- moveToTarget();
- }
- }
-}
-
-void LocalPlayer::setFollow(const std::string &player)
-{
- mPlayerFollowed = player;
- if (!mPlayerFollowed.empty())
- {
- // TRANSLATORS: follow command message
- std::string msg = strprintf(_("Follow: %s"), player.c_str());
- debugMsg(msg);
- }
- else
- {
- // TRANSLATORS: follow command message
- debugMsg(_("Follow canceled"));
- }
-}
-
-void LocalPlayer::setImitate(const std::string &player)
-{
- mPlayerImitated = player;
- if (!mPlayerImitated.empty())
- {
- // TRANSLATORS: imitate command message
- std::string msg = strprintf(_("Imitation: %s"), player.c_str());
- debugMsg(msg);
- }
- else
- {
- // TRANSLATORS: imitate command message
- debugMsg(_("Imitation canceled"));
- }
-}
-
-void LocalPlayer::cancelFollow()
-{
- if (!mPlayerFollowed.empty())
- {
- // TRANSLATORS: cancel follow message
- debugMsg(_("Follow canceled"));
- }
- if (!mPlayerImitated.empty())
- {
- // TRANSLATORS: cancel follow message
- debugMsg(_("Imitation canceled"));
- }
- mPlayerFollowed.clear();
- mPlayerImitated.clear();
-}
-
-void LocalPlayer::imitateEmote(const Being *const being,
- const unsigned char action) const
-{
- if (being == nullptr)
- return;
-
- std::string player_imitated = getImitate();
- if (!player_imitated.empty() && being->mName == player_imitated)
- emote(action);
-}
-
-void LocalPlayer::imitateAction(const Being *const being,
- const BeingActionT &action)
-{
- if (being == nullptr)
- return;
-
- if (!mPlayerImitated.empty() && being->mName == mPlayerImitated)
- {
- setAction(action, 0);
- playerHandler->changeAction(action);
- }
-}
-
-void LocalPlayer::imitateDirection(const Being *const being,
- const unsigned char dir)
-{
- if (being == nullptr)
- return;
-
- if (!mPlayerImitated.empty() && being->mName == mPlayerImitated)
- {
- if (!PacketLimiter::limitPackets(PacketType::PACKET_DIRECTION))
- return;
-
- if (settings.followMode == 2)
- {
- uint8_t dir2 = 0;
- if ((dir & BeingDirection::LEFT) != 0)
- dir2 |= BeingDirection::RIGHT;
- else if ((dir & BeingDirection::RIGHT) != 0)
- dir2 |= BeingDirection::LEFT;
- if ((dir & BeingDirection::UP) != 0)
- dir2 |= BeingDirection::DOWN;
- else if ((dir & BeingDirection::DOWN) != 0)
- dir2 |= BeingDirection::UP;
-
- setDirection(dir2);
- playerHandler->setDirection(dir2);
- }
- else
- {
- setDirection(dir);
- playerHandler->setDirection(dir);
- }
- }
-}
-
-void LocalPlayer::imitateOutfit(const Being *const player,
- const int sprite) const
-{
- if (player == nullptr)
- return;
-
- if (settings.imitationMode == 1 &&
- !mPlayerImitated.empty() &&
- player->mName == mPlayerImitated)
- {
- if (sprite < 0 || sprite >= player->getNumberOfLayers())
- return;
-
- const AnimatedSprite *const equipmentSprite
- = dynamic_cast<const AnimatedSprite *>(
- player->mSprites[sprite]);
-
- if (equipmentSprite != nullptr)
- {
-// logger->log("have equipmentSprite");
- const Inventory *const inv = PlayerInfo::getInventory();
- if (inv == nullptr)
- return;
-
- const std::string &path = equipmentSprite->getIdPath();
- if (path.empty())
- return;
-
-// logger->log("idPath: " + path);
- const Item *const item = inv->findItemBySprite(path,
- player->getGender(), player->getSubType());
- if ((item != nullptr) && item->isEquipped() == Equipped_false)
- PlayerInfo::equipItem(item, Sfx_false);
- }
- else
- {
-// logger->log("have unequip %d", sprite);
- const int equipmentSlot = inventoryHandler
- ->convertFromServerSlot(sprite);
-// logger->log("equipmentSlot: " + toString(equipmentSlot));
- if (equipmentSlot == inventoryHandler->getProjectileSlot())
- return;
-
- const Item *const item = PlayerInfo::getEquipment(equipmentSlot);
- if (item != nullptr)
- {
-// logger->log("unequiping");
- PlayerInfo::unequipItem(item, Sfx_false);
- }
- }
- }
-}
-
-void LocalPlayer::followMoveTo(const Being *const being,
- const int x, const int y)
-{
- if ((being != nullptr) &&
- !mPlayerFollowed.empty() &&
- being->mName == mPlayerFollowed)
- {
- mPickUpTarget = nullptr;
- navigateTo(x, y);
- }
-}
-
-void LocalPlayer::followMoveTo(const Being *const being,
- const int x1, const int y1,
- const int x2, const int y2)
-{
- if (being == nullptr)
- return;
-
- mPickUpTarget = nullptr;
- if (!mPlayerFollowed.empty() &&
- being->mName == mPlayerFollowed)
- {
- switch (settings.followMode)
- {
- case 0:
- navigateTo(x1, y1);
- setNextDest(x2, y2);
- break;
- case 1:
- if (x1 != x2 || y1 != y2)
- {
- navigateTo(mX + x2 - x1, mY + y2 - y1);
- setNextDest(mX + x2 - x1, mY + y2 - y1);
- }
- break;
- case 2:
- if (x1 != x2 || y1 != y2)
- {
- navigateTo(mX + x1 - x2, mY + y1 - y2);
- setNextDest(mX + x1 - x2, mY + y1 - y2);
- }
- break;
- case 3:
- if (mTarget == nullptr ||
- mTarget->mName != mPlayerFollowed)
- {
- if (actorManager != nullptr)
- {
- Being *const b = actorManager->findBeingByName(
- mPlayerFollowed, ActorType::Player);
- setTarget(b);
- }
- }
- moveToTarget();
- setNextDest(x2, y2);
- break;
- default:
- break;
- }
- }
-}
-
-void LocalPlayer::setNextDest(const int x, const int y)
-{
- mNextDestX = x;
- mNextDestY = y;
-}
-
-bool LocalPlayer::allowAction()
-{
- if (mIsServerBuggy)
- {
- if (mLastAction != -1)
- return false;
- mLastAction = tick_time;
- }
- return true;
-}
-
-void LocalPlayer::fixPos()
-{
- if ((mCrossX == 0) && (mCrossY == 0))
- return;
-
- const int dx = abs(mX - mCrossX);
- const int dy = abs(mY - mCrossY);
- const int dist = dx > dy ? dx : dy;
- const time_t time = cur_time;
- const int maxDist = mSyncPlayerMove ? mSyncPlayerMoveDistance : 7;
-
- if (dist > maxDist)
- {
- mActivityTime = time;
- setTileCoords(mCrossX, mCrossY);
-// alternative way to fix, move to real position
-// setDestination(mCrossX, mCrossY);
- }
-}
-
-void LocalPlayer::setRealPos(const int x, const int y)
-{
- if (mMap == nullptr)
- return;
-
- SpecialLayer *const layer = mMap->getTempLayer();
- if (layer != nullptr)
- {
- bool cacheUpdated(false);
- if (((mCrossX != 0) || (mCrossY != 0)) &&
- (layer->getTile(mCrossX, mCrossY) != nullptr) &&
- layer->getTile(mCrossX, mCrossY)->getType() == MapItemType::CROSS)
- {
- layer->setTile(mCrossX, mCrossY, MapItemType::EMPTY);
- layer->updateCache();
- cacheUpdated = true;
- }
-
- if (mShowServerPos)
- {
- const MapItem *const mapItem = layer->getTile(x, y);
-
- if (mapItem == nullptr ||
- mapItem->getType() == MapItemType::EMPTY)
- {
- if (mX != x && mY != y)
- {
- layer->setTile(x, y, MapItemType::CROSS);
- if (cacheUpdated == false)
- layer->updateCache();
- }
- }
- }
-
- if (mCrossX != x || mCrossY != y)
- {
- mCrossX = x;
- mCrossY = y;
- }
- }
- if (mMap->isCustom())
- mMap->setWalk(x, y);
-}
-void LocalPlayer::fixAttackTarget()
-{
- if ((mMap == nullptr) || (mTarget == nullptr))
- return;
-
- if (settings.moveToTargetType == 11 || (settings.attackType == 0u)
- || !config.getBoolValue("autofixPos"))
- {
- return;
- }
-
- const Path debugPath = mMap->findPath(
- (mPixelX - mapTileSize / 2) / mapTileSize,
- (mPixelY - mapTileSize) / mapTileSize,
- mTarget->mX,
- mTarget->mY,
- getBlockWalkMask(),
- 0);
-
- if (!debugPath.empty())
- {
- const Path::const_iterator i = debugPath.begin();
- setDestination((*i).x, (*i).y);
- }
-}
-
-void LocalPlayer::respawn()
-{
- navigateClean();
-}
-
-int LocalPlayer::getLevel() const
-{
- return PlayerInfo::getAttribute(Attributes::PLAYER_BASE_LEVEL);
-}
-
-void LocalPlayer::updateNavigateList()
-{
- if (mMap != nullptr)
- {
- const std::map<std::string, Vector>::const_iterator iter =
- mHomes.find(mMap->getProperty("_realfilename"));
-
- if (iter != mHomes.end())
- {
- const Vector &pos = mHomes[(*iter).first];
- if ((pos.x != 0.0f) && (pos.y != 0.0f))
- {
- mMap->addPortalTile("home", MapItemType::HOME,
- CAST_S32(pos.x), CAST_S32(pos.y));
- }
- }
- }
-}
-
-void LocalPlayer::failMove(const int x A_UNUSED,
- const int y A_UNUSED)
-{
-}
-
-void LocalPlayer::waitFor(const std::string &nick)
-{
- mWaitFor = nick;
-}
-
-void LocalPlayer::checkNewName(Being *const being)
-{
- if (being == nullptr)
- return;
-
- const std::string &nick = being->mName;
- if (being->getType() == ActorType::Player)
- {
- const Guild *const guild = getGuild();
- if (guild != nullptr)
- {
- const GuildMember *const gm = guild->getMember(nick);
- if (gm != nullptr)
- {
- const int level = gm->getLevel();
- if (level > 1 && being->getLevel() != level)
- {
- being->setLevel(level);
- being->updateName();
- }
- }
- }
- if (chatWindow != nullptr)
- {
- WhisperTab *const tab = chatWindow->getWhisperTab(nick);
- if (tab != nullptr)
- tab->setWhisperTabColors();
- }
- }
-
- if (!mWaitFor.empty() && mWaitFor == nick)
- {
- // TRANSLATORS: wait player/monster message
- debugMsg(strprintf(_("You see %s"), mWaitFor.c_str()));
- soundManager.playGuiSound(SOUND_INFO);
- mWaitFor.clear();
- }
-}
-
-unsigned char LocalPlayer::getBlockWalkMask() const
-{
- // for now blocking all types of collisions
- return BlockMask::WALL |
- BlockMask::AIR |
- BlockMask::WATER |
- BlockMask::PLAYERWALL;
-}
-
-void LocalPlayer::removeHome()
-{
- if (mMap == nullptr)
- return;
-
- const std::string key = mMap->getProperty("_realfilename");
- const std::map<std::string, Vector>::iterator iter = mHomes.find(key);
-
- if (iter != mHomes.end())
- mHomes.erase(key);
-}
-
-void LocalPlayer::stopAdvert()
-{
- mBlockAdvert = true;
-}
-
-bool LocalPlayer::checAttackPermissions(const Being *const target)
-{
- if (target == nullptr)
- return false;
-
- switch (settings.pvpAttackType)
- {
- case 0:
- return true;
- case 1:
- return !(playerRelations.getRelation(target->mName)
- == Relation::FRIEND);
- case 2:
- return playerRelations.checkBadRelation(target->mName);
- default:
- case 3:
- return false;
- }
-}
-
-void LocalPlayer::updateStatus() const
-{
- if (serverFeatures->havePlayerStatusUpdate() && mEnableAdvert)
- {
- uint8_t status = 0;
- if (Net::getNetworkType() == ServerType::TMWATHENA)
- {
- if (mTradebot &&
- shopWindow != nullptr &&
- !shopWindow->isShopEmpty())
- {
- status |= BeingFlag::SHOP;
- }
- }
- if (settings.awayMode || settings.pseudoAwayMode)
- status |= BeingFlag::AWAY;
-
- if (mInactive)
- status |= BeingFlag::INACTIVE;
-
- playerHandler->updateStatus(status);
- }
-}
-
-void LocalPlayer::setTestParticle(const std::string &fileName,
- const bool updateHash)
-{
- mTestParticleName = fileName;
- mTestParticleTime = cur_time;
- if (mTestParticle != nullptr)
- {
- mChildParticleEffects.removeLocally(mTestParticle);
- mTestParticle = nullptr;
- }
- if (!fileName.empty())
- {
- mTestParticle = particleEngine->addEffect(fileName, 0, 0, 0);
- controlCustomParticle(mTestParticle);
- if (updateHash)
- mTestParticleHash = UpdaterWindow::getFileHash(mTestParticleName);
- }
-}
-
-void LocalPlayer::playerDeath()
-{
- if (mAction != BeingAction::DEAD)
- {
- setAction(BeingAction::DEAD, 0);
- recalcSpritesOrder();
- }
-}
-
-bool LocalPlayer::canMove() const
-{
- return !mFreezed &&
- mAction != BeingAction::DEAD &&
- (serverFeatures->haveMoveWhileSit() ||
- mAction != BeingAction::SIT);
-}
-
-void LocalPlayer::freezeMoving(const int timeWaitTicks)
-{
- if (timeWaitTicks <= 0)
- return;
- const int nextTime = tick_time + timeWaitTicks;
- if (mUnfreezeTime < nextTime)
- mUnfreezeTime = nextTime;
- if (mUnfreezeTime > 0)
- mFreezed = true;
-}
diff --git a/src/being/localplayer.h b/src/being/localplayer.h
deleted file mode 100644
index 897e4dc00..000000000
--- a/src/being/localplayer.h
+++ /dev/null
@@ -1,533 +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 BEING_LOCALPLAYER_H
-#define BEING_LOCALPLAYER_H
-
-#include "being/being.h"
-
-#include "enums/being/pickup.h"
-#include "enums/being/visiblename.h"
-
-#include "enums/simpletypes/allowsort.h"
-#include "enums/simpletypes/keep.h"
-
-#include "listeners/actorspritelistener.h"
-#include "listeners/attributelistener.h"
-#include "listeners/playerdeathlistener.h"
-
-#include "localconsts.h"
-
-class AwayListener;
-class ChatTab;
-class FloorItem;
-class Map;
-class OkDialog;
-
-/**
- * The local player character.
- */
-class LocalPlayer final : public Being,
- public ActorSpriteListener,
- public AttributeListener,
- public PlayerDeathListener
-{
- public:
- /**
- * Constructor.
- */
- explicit LocalPlayer(const BeingId id,
- const BeingTypeId subType = BeingTypeId_zero);
-
- A_DELETE_COPY(LocalPlayer)
-
- /**
- * Destructor.
- */
- ~LocalPlayer();
-
- void logic() override final;
-
- void slowLogic();
-
- void setAction(const BeingActionT &action,
- const int attackId) override final;
-
- /**
- * Compute the next pathnode location when walking using keyboard.
- * used by nextTile().
- */
- Position getNextWalkPosition(const unsigned char dir)
- const A_WARN_UNUSED;
-
- /**
- * Adds a new tile to the path when walking.
- * @note Eathena
- * Also, when specified, it picks up an item at the end of a path
- * or attack target.
- */
- void nextTile() override final
- { nextTile(0); }
-
- void nextTile(unsigned char dir);
-
- bool pickUp(FloorItem *const item);
-
- /**
- * Called when an ActorSprite has been destroyed.
- * @param actorSprite the ActorSprite being destroyed.
- */
- void actorSpriteDestroyed(const ActorSprite &actorSprite)
- override final;
-
- /**
- * Gets the attack range.
- */
- int getAttackRange() const A_WARN_UNUSED;
-
- int getAttackRange2() const A_WARN_UNUSED;
-
- void attack(Being *const target = nullptr, const bool keep = false,
- const bool dontChangeEquipment = false);
-
- void attack2(Being *const target = nullptr, const bool keep = false,
- const bool dontChangeEquipment = false);
-
- void setGroupId(const int id) override final;
-
- void stopAttack(const bool keepAttack = false);
-
- void untarget();
-
- /**
- * Returns the current target of the player. Returns 0 if no being is
- * currently targeted.
- */
- Being *getTarget() const A_WARN_UNUSED;
-
- /**
- * Sets the target being of the player.
- */
- void setTarget(Being *const target);
-
- Being *setNewTarget(const ActorTypeT type,
- const AllowSort allowSort);
-
- /**
- * Sets a new destination for this being to walk to.
- */
- void setDestination(const int x, const int y);
-
- /**
- * Sets a new direction to keep walking in.
- */
- void setWalkingDir(const unsigned char dir);
-
- /**
- * Gets the walking direction
- */
- unsigned char getWalkingDir() const noexcept2 A_WARN_UNUSED
- { return mWalkingDir; }
-
- /**
- * Sets going to being to attack
- */
- void setGotoTarget(Being *const target);
-
- /**
- * Returns whether the target is in range to attack
- */
- bool withinAttackRange(const Being *const target,
- const bool fixDistance = false,
- const int addRange = 0) const A_WARN_UNUSED;
-
- /**
- * Stops the player dead in his tracks
- */
- void stopWalking(const bool sendToServer = true);
-
- bool toggleSit() const;
-
- bool updateSit() const;
-
- static bool emote(const uint8_t emotion);
-
- /**
- * Shows item pickup notifications.
- */
- void pickedUp(const ItemInfo &itemInfo,
- const int amount,
- const ItemColor color,
- const BeingId floorItemId,
- const PickupT fail);
-
- int getLevel() const override final A_WARN_UNUSED;
-
- /** Tells that the path has been set by mouse. */
- void pathSetByMouse()
- { mPathSetByMouse = true; }
-
- /** Tells if the path has been set by mouse. */
- bool isPathSetByMouse() const noexcept2 A_WARN_UNUSED
- { return mPathSetByMouse; }
-
- unsigned int getMoveState() const noexcept2 A_WARN_UNUSED
- { return mMoveState; }
-
- void setMoveState(const unsigned int n) noexcept2
- { mMoveState = n; }
-
- std::string getPingTime() const A_WARN_UNUSED;
-
- void tryPingRequest();
-
-#ifdef TMWA_SUPPORT
- void magicAttack() const;
-#endif // TMWA_SUPPORT
-
- void specialMove(const unsigned char direction);
-
- void moveByDirection(const unsigned char dir);
-
- bool pickUpItems(int pickUpType = 0);
-
- void move(const int dX, const int dY);
-
- void moveToTarget(int dist = -1);
-
- void moveToHome();
-
- bool isReachable(Being *const being,
- const int maxCost = 0) A_WARN_UNUSED;
-
- bool isReachable(const int x, const int y,
- const bool allowCollision) const A_WARN_UNUSED;
-
- void setHome();
-
- void pingRequest();
-
- void pingResponse();
-
- void setAway(const std::string &message) const;
-
- static void setPseudoAway(const std::string &message);
-
- void setHalfAway(const bool n)
- { mInactive = n; }
-
- bool getHalfAway() const noexcept2 A_WARN_UNUSED
- { return mInactive; }
-
- void afkRespond(ChatTab *const tab, const std::string &nick);
-
- static void setAfkMessage(std::string message);
-
- bool navigateTo(const int x, const int y);
-
- void navigateClean();
-
- void imitateEmote(const Being *const being,
- const unsigned char action) const;
-
- void imitateAction(const Being *const being,
- const BeingActionT &action);
-
- void imitateDirection(const Being *const being,
- const unsigned char dir);
-
- void imitateOutfit(const Being *const player,
- const int sprite = -1) const;
-
- void followMoveTo(const Being *const being, const int x, const int y);
-
- void followMoveTo(const Being *const being, const int x1, const int y1,
- const int x2, const int y2);
-
- bool allowAction() A_WARN_UNUSED;
-
- void setRealPos(const int x, const int y);
-
- bool isServerBuggy() const noexcept2 A_WARN_UNUSED
- { return mIsServerBuggy; }
-
- void fixPos();
-
- /**
- * Sets the map the being is on
- */
- void setMap(Map *const map) override final;
-
- void addMessageToQueue(const std::string &message,
- const UserColorIdT color
- = UserColorId::EXP_INFO);
-
- /**
- * Called when a option (set with config.addListener()) is changed
- */
- void optionChanged(const std::string &value) override final;
-
- void playerDeath() override final;
-
- /**
- * set a following player.
- */
- void setFollow(const std::string &player);
-
- /**
- * set an imitation player.
- */
- void setImitate(const std::string &player);
-
- /**
- * setting the next destination of the following, in case of warp
- */
- void setNextDest(const int x, const int y);
-
- int getNextDestX() const noexcept2 A_WARN_UNUSED
- { return mNextDestX; }
-
- int getNextDestY() const noexcept2 A_WARN_UNUSED
- { return mNextDestY; }
-
- void respawn();
-
- const FloorItem *getPickUpTarget() const noexcept2 A_WARN_UNUSED
- { return mPickUpTarget; }
-
- void unSetPickUpTarget()
- { mPickUpTarget = nullptr; }
-
- /**
- * Stop following a player.
- */
- void cancelFollow();
-
- /**
- * Get the playername followed by the current player.
- */
- const std::string &getFollow() const noexcept2 A_WARN_UNUSED
- { return mPlayerFollowed; }
-
- /**
- * Get the playername imitated by the current player.
- */
- const std::string &getImitate() const noexcept2 A_WARN_UNUSED
- { return mPlayerImitated; }
-
- /**
- * Tells the engine whether to check
- * if the Player Name is to be displayed.
- */
- void setCheckNameSetting(const bool checked)
- { mUpdateName = checked; }
-
- /**
- * Gets if the engine has to check
- * if the Player Name is to be displayed.
- */
- bool getCheckNameSetting() const noexcept2 A_WARN_UNUSED
- { return mUpdateName; }
-
- void fixAttackTarget();
-
- void updateNavigateList();
-
- int getPathLength(const Being *const being) const A_WARN_UNUSED;
-
- void targetMoved() const A_CONST;
-
- void setLastHitFrom(const std::string &n)
- { mLastHitFrom = n; }
-
- void waitFor(const std::string &nick);
-
- void checkNewName(Being *const being);
-
- unsigned char getBlockWalkMask() const override final
- A_CONST A_WARN_UNUSED;
-
- void saveHomes();
-
- void removeHome();
-
- void stopAdvert();
-
- void addXpMessage(const int change);
-
- void addHomunXpMessage(const int change);
-
- void addJobMessage(const int change);
-
- void addHpMessage(const int change);
-
- void addSpMessage(const int change);
-
- static bool checAttackPermissions(const Being *const target)
- A_WARN_UNUSED;
-
- void updateStatus() const;
-
- void setTestParticle(const std::string &fileName,
- const bool updateHash = true);
-
- int getLastAttackX() const override final
- { return mTarget != nullptr ? mTarget->mX : mLastAttackX; }
-
- int getLastAttackY() const override final
- { return mTarget != nullptr ? mTarget->mY : mLastAttackY; }
-
- void attributeChanged(const AttributesT id,
- const int64_t oldVal,
- const int64_t newVal) override final;
-
- void updateMusic() const;
-
- void setAfkTime(const int v) noexcept2
- { mAfkTime = v; }
-
- void setAwayDialog(OkDialog *const dialog)
- { mAwayDialog = dialog; }
-
- AwayListener *getAwayListener() const noexcept2 A_WARN_UNUSED
- { return mAwayListener; }
-
- void setRename(const bool r) noexcept2
- { mAllowRename = r; }
-
- bool getRename() const noexcept2
- { return mAllowRename; }
-
- bool canMove() const;
-
- void freezeMoving(const int timeWaitTicks);
-
- void failMove(const int x,
- const int y);
-
- protected:
- void updateCoords() override final;
-
- void handleStatusEffect(const StatusEffect *const effect,
- const int32_t effectId,
- const Enable newStatus,
- const IsStart start) override final;
-
- void startWalking(const unsigned char dir);
-
- void changeEquipmentBeforeAttack(const Being *const target) const;
-
-#ifdef TMWA_SUPPORT
- static void tryMagic(const std::string &spell,
- const int baseMagic,
- const int schoolMagic,
- const int mana);
-#endif // TMWA_SUPPORT
-
- void loadHomes();
-
- // move state. used if mMoveType == 2
- unsigned int mMoveState;
-
- int mLastTargetX;
- int mLastTargetY;
-
- std::map<std::string, Vector> mHomes;
-
- Being *mTarget;
-
- /** Follow system **/
- std::string mPlayerFollowed;
- std::string mPlayerImitated;
- int mNextDestX;
- int mNextDestY;
-
- FloorItem *mPickUpTarget;
-
- int mLastAction; // Time stamp of the last action, -1 if none.
-
- STD_VECTOR<int32_t> mStatusEffectIcons;
-
- typedef std::pair<std::string, UserColorIdT> MessagePair;
- /** Queued messages*/
- std::list<MessagePair> mMessages;
- int mMessageTime;
- AwayListener *mAwayListener;
- OkDialog *mAwayDialog;
-
- int mPingSendTick;
- time_t mPingTime;
- time_t mAfkTime;
- time_t mActivityTime;
- int mNavigateX;
- int mNavigateY;
- BeingId mNavigateId;
- int mCrossX;
- int mCrossY;
- int mOldX;
- int mOldY;
- int mOldTileX;
- int mOldTileY;
- Path mNavigatePath;
-
- std::string mLastHitFrom;
- std::string mWaitFor;
- time_t mAdvertTime;
- Particle *mTestParticle;
- std::string mTestParticleName;
- time_t mTestParticleTime;
- unsigned long mTestParticleHash;
- int mSyncPlayerMoveDistance;
- int mUnfreezeTime;
- unsigned char mWalkingDir; // The direction the player is walking in.
- /** Whether or not the name settings have changed */
- bool mUpdateName;
- bool mBlockAdvert;
- bool mTargetDeadPlayers;
- Keep mServerAttack;
- VisibleName::Type mVisibleNames;
- bool mEnableAdvert;
- bool mTradebot;
- bool mTargetOnlyReachable;
- bool mIsServerBuggy;
- bool mSyncPlayerMove;
- bool mDrawPath;
- bool mAttackMoving;
- bool mAttackNext;
- bool mShowJobExp;
- bool mShowServerPos;
- bool mNextStep;
- // temporary disable crazy moves in moves
- bool mGoingToTarget;
- // Whether or not to continue to attack
- bool mKeepAttacking;
- // Tells if the path was set using mouse
- bool mPathSetByMouse;
- bool mWaitPing;
- bool mShowNavigePath;
- bool mAllowRename;
- bool mFreezed;
-};
-
-extern LocalPlayer *localPlayer;
-
-#endif // BEING_LOCALPLAYER_H
diff --git a/src/being/mercenaryinfo.h b/src/being/mercenaryinfo.h
deleted file mode 100644
index c25eeef49..000000000
--- a/src/being/mercenaryinfo.h
+++ /dev/null
@@ -1,46 +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 BEING_MERCENARYINFO_H
-#define BEING_MERCENARYINFO_H
-
-#include "enums/simpletypes/beingid.h"
-#include <string>
-
-#include "localconsts.h"
-
-struct MercenaryInfo final
-{
- MercenaryInfo() :
- name(),
- id(BeingId_zero),
- level(0),
- range(0)
- { }
-
- A_DELETE_COPY(MercenaryInfo)
-
- std::string name;
- BeingId id;
- int level;
- int range;
-};
-
-#endif // BEING_MERCENARYINFO_H
diff --git a/src/being/petinfo.h b/src/being/petinfo.h
deleted file mode 100644
index 5ede2cfb2..000000000
--- a/src/being/petinfo.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 BEING_PETINFO_H
-#define BEING_PETINFO_H
-
-#include "enums/simpletypes/beingid.h"
-
-#include <string>
-
-#include "localconsts.h"
-
-struct PetInfo final
-{
- PetInfo() :
- name(),
- id(BeingId_zero),
- level(0),
- hungry(0),
- intimacy(0),
- race(0),
- performance(0),
- hairStyle(0),
- equip(0)
- { }
-
- A_DELETE_COPY(PetInfo)
-
- std::string name;
- BeingId id;
- int level;
- int hungry;
- int intimacy;
- int race;
- int performance;
- int hairStyle;
- int equip;
-};
-
-#endif // BEING_PETINFO_H
diff --git a/src/being/playerignorestrategy.h b/src/being/playerignorestrategy.h
deleted file mode 100644
index fb5dd5ebb..000000000
--- a/src/being/playerignorestrategy.h
+++ /dev/null
@@ -1,58 +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 BEING_PLAYERIGNORESTRATEGY_H
-#define BEING_PLAYERIGNORESTRATEGY_H
-
-#include <string>
-
-#include "localconsts.h"
-
-class Being;
-
-/**
- * Ignore strategy: describes how we should handle ignores.
- */
-class PlayerIgnoreStrategy notfinal
-{
- public:
- std::string mDescription;
- std::string mShortName;
-
- A_DELETE_COPY(PlayerIgnoreStrategy)
-
- virtual ~PlayerIgnoreStrategy()
- { }
-
- /**
- * Handle the ignoring of the indicated action by the indicated player.
- */
- virtual void ignore(Being *const being,
- const unsigned int flags) const = 0;
- protected:
- PlayerIgnoreStrategy() :
- mDescription(),
- mShortName()
- {
- }
-};
-#endif // BEING_PLAYERIGNORESTRATEGY_H
diff --git a/src/being/playerinfo.cpp b/src/being/playerinfo.cpp
deleted file mode 100644
index 0a89bd7e1..000000000
--- a/src/being/playerinfo.cpp
+++ /dev/null
@@ -1,693 +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 "being/playerinfo.h"
-
-#include "configuration.h"
-#include "itemsoundmanager.h"
-
-#include "being/localplayer.h"
-
-#include "being/homunculusinfo.h"
-#include "being/mercenaryinfo.h"
-#include "being/petinfo.h"
-
-#include "gui/windows/inventorywindow.h"
-#include "gui/windows/npcdialog.h"
-
-#include "listeners/statlistener.h"
-
-#include "net/homunculushandler.h"
-#include "net/inventoryhandler.h"
-#include "net/mercenaryhandler.h"
-#include "net/playerhandler.h"
-
-#include "resources/item/item.h"
-
-#include "utils/delete2.h"
-
-#include "utils/translation/translationmanager.h"
-
-#include "debug.h"
-
-namespace PlayerInfo
-{
-
-PlayerInfoBackend mData;
-int mCharId = 0;
-
-Inventory *mInventory = nullptr;
-Inventory *mCartInventory = nullptr;
-MercenaryInfo *mMercenary = nullptr;
-HomunculusInfo *mHomunculus = nullptr;
-PetInfo *mPet = nullptr;
-std::string mRoomName;
-Equipment *mEquipment = nullptr;
-BeingId mPetBeingId = BeingId_zero;
-GuildPositionFlags::Type mGuildPositionFlags = GuildPositionFlags::None;
-BeingId mElementalId = BeingId_zero;
-
-Trading mTrading = Trading_false;
-bool mVending = false;
-int mLevelProgress = 0;
-int mServerLanguage = -1;
-std::set<int> mProtectedItems;
-
-// --- Triggers ---------------------------------------------------------------
-
-void triggerAttr(const AttributesT id,
- const int64_t old)
-{
- AttributeListener::distributeEvent(id, old,
- mData.mAttributes.find(id)->second);
-}
-
-void triggerStat(const AttributesT id,
- const int old1,
- const int old2)
-{
- StatListener::distributeEvent(id, old1, old2);
-}
-
-// --- Attributes -------------------------------------------------------------
-
-int64_t getAttribute64(const AttributesT id)
-{
- const AtrIntMap::const_iterator it = mData.mAttributes.find(id);
- if (it != mData.mAttributes.end())
- return it->second;
- return 0;
-}
-
-int32_t getAttribute(const AttributesT id)
-{
- const AtrIntMap::const_iterator it = mData.mAttributes.find(id);
- if (it != mData.mAttributes.end())
- return CAST_S32(it->second);
- return 0;
-}
-
-void setAttribute(const AttributesT id,
- const int64_t value,
- const Notify notify)
-{
- const int64_t old = mData.mAttributes[id];
- mData.mAttributes[id] = value;
- if (notify == Notify_true)
- triggerAttr(id, old);
-}
-
-int getSkillLevel(const int id)
-{
- const IntMap::const_iterator it = mData.mSkills.find(id);
- if (it != mData.mSkills.end())
- return it->second;
- return 0;
-}
-
-void setSkillLevel(const int id, const int value)
-{
- mData.mSkills[id] = value;
-}
-
-// --- Stats ------------------------------------------------------------------
-
-int getStatBase(const AttributesT id)
-{
- const StatMap::const_iterator it = mData.mStats.find(id);
- if (it != mData.mStats.end())
- return it->second.base;
- return 0;
-}
-
-void setStatBase(const AttributesT id, const int value, const Notify notify)
-{
- const int old = mData.mStats[id].base;
- mData.mStats[id].base = value;
- if (notify == Notify_true)
- triggerStat(id, old, 0);
-}
-
-int getStatMod(const AttributesT id)
-{
- const StatMap::const_iterator it = mData.mStats.find(id);
- if (it != mData.mStats.end())
- return it->second.mod;
- return 0;
-}
-
-void setStatMod(const AttributesT id, const int value, const Notify notify)
-{
- const int old = mData.mStats[id].mod;
- mData.mStats[id].mod = value;
- if (notify == Notify_true)
- triggerStat(id, old, 0);
-}
-
-int getStatEffective(const AttributesT id)
-{
- const StatMap::const_iterator it = mData.mStats.find(id);
- if (it != mData.mStats.end())
- return it->second.base + it->second.mod;
- return 0;
-}
-
-const std::pair<int, int> getStatExperience(const AttributesT id)
-{
- const StatMap::const_iterator it = mData.mStats.find(id);
- int a, b;
- if (it != mData.mStats.end())
- {
- a = it->second.exp;
- b = it->second.expNeed;
- }
- else
- {
- a = 0;
- b = 0;
- }
- return std::pair<int, int>(a, b);
-}
-
-void setStatExperience(const AttributesT id,
- const int have,
- const int need,
- const Notify notify)
-{
- Stat &stat = mData.mStats[id];
-
- const int oldExp = stat.exp;
- const int oldExpNeed = stat.expNeed;
- stat.exp = have;
- stat.expNeed = need;
- if (notify == Notify_true)
- triggerStat(id, oldExp, oldExpNeed);
-}
-
-// --- Inventory / Equipment --------------------------------------------------
-
-Inventory *getInventory()
-{
- return mInventory;
-}
-
-Inventory *getStorageInventory()
-{
- if (inventoryHandler != nullptr)
- return inventoryHandler->getStorage();
- return nullptr;
-}
-
-Inventory *getCartInventory()
-{
- return mCartInventory;
-}
-
-void clearInventory()
-{
- if (mEquipment != nullptr)
- mEquipment->clear();
- if (mInventory != nullptr)
- mInventory->clear();
-}
-
-Equipment *getEquipment()
-{
- return mEquipment;
-}
-
-const Item *getEquipment(const unsigned int slot)
-{
- if (mEquipment != nullptr)
- return mEquipment->getEquipment(slot);
- return nullptr;
-}
-
-void setEquipmentBackend(Equipment::Backend *const backend)
-{
- if (mEquipment != nullptr)
- mEquipment->setBackend(backend);
-}
-
-void equipItem(const Item *const item, const Sfx sfx)
-{
- if (sfx == Sfx_true)
- ItemSoundManager::playSfx(item, ItemSoundEvent::EQUIP);
- if (inventoryHandler != nullptr)
- inventoryHandler->equipItem(item);
-}
-
-void unequipItem(const Item *const item, const Sfx sfx)
-{
- if (sfx == Sfx_true)
- ItemSoundManager::playSfx(item, ItemSoundEvent::UNEQUIP);
- if (inventoryHandler != nullptr)
- inventoryHandler->unequipItem(item);
-}
-
-void useItem(const Item *const item, const Sfx sfx)
-{
- if (sfx == Sfx_true)
- ItemSoundManager::playSfx(item, ItemSoundEvent::USE);
- if (inventoryHandler != nullptr)
- inventoryHandler->useItem(item);
-}
-
-void useEquipItem(const Item *const item,
- const int16_t useType,
- const Sfx sfx)
-{
- if (item != nullptr)
- {
- if (item->getType() == ItemType::Card)
- {
- if (mProtectedItems.find(item->getId()) == mProtectedItems.end())
- {
- if (inventoryHandler != nullptr)
- inventoryHandler->useCard(item);
- if (sfx == Sfx_true)
- ItemSoundManager::playSfx(item, ItemSoundEvent::USECARD);
- }
- }
- else if (item->isEquipment() == Equipm_true)
- {
- if (item->isEquipped() == Equipped_true)
- {
- if (sfx == Sfx_true)
- ItemSoundManager::playSfx(item, ItemSoundEvent::UNEQUIP);
- if (inventoryHandler != nullptr)
- inventoryHandler->unequipItem(item);
- }
- else
- {
- if (sfx == Sfx_true)
- ItemSoundManager::playSfx(item, ItemSoundEvent::EQUIP);
- if (inventoryHandler != nullptr)
- inventoryHandler->equipItem(item);
- }
- }
- else
- {
- if (mProtectedItems.find(item->getId()) == mProtectedItems.end())
- {
- if (inventoryHandler != nullptr)
- {
- if (useType == 0)
- inventoryHandler->useItem(item);
- else
- inventoryHandler->useItem(item, useType);
- }
- if (sfx == Sfx_true)
- ItemSoundManager::playSfx(item, ItemSoundEvent::USE);
- }
- }
- }
-}
-
-void useEquipItem2(const Item *const item,
- const int16_t useType,
- const Sfx sfx)
-{
- if (item != nullptr)
- {
- if (item->isEquipment() == Equipm_false)
- {
- if (item->isEquipped() == Equipped_true)
- {
- if (sfx == Sfx_true)
- ItemSoundManager::playSfx(item, ItemSoundEvent::UNEQUIP);
- if (inventoryHandler != nullptr)
- inventoryHandler->unequipItem(item);
- }
- else
- {
- if (sfx == Sfx_true)
- ItemSoundManager::playSfx(item, ItemSoundEvent::EQUIP);
- if (inventoryHandler != nullptr)
- inventoryHandler->equipItem(item);
- }
- }
- else
- {
- if (mProtectedItems.find(item->getId()) == mProtectedItems.end())
- {
- if (sfx == Sfx_true)
- ItemSoundManager::playSfx(item, ItemSoundEvent::USE);
- if (inventoryHandler != nullptr)
- {
- if (useType == 0)
- inventoryHandler->useItem(item);
- else
- inventoryHandler->useItem(item, useType);
- }
- }
- }
- }
-}
-
-void dropItem(const Item *const item, const int amount, const Sfx sfx)
-{
- if (item != nullptr &&
- mProtectedItems.find(item->getId()) == mProtectedItems.end())
- {
- if (sfx == Sfx_true)
- ItemSoundManager::playSfx(item, ItemSoundEvent::DROP);
- if (inventoryHandler != nullptr)
- inventoryHandler->dropItem(item, amount);
- }
-}
-
-void pickUpItem(const FloorItem *const item, const Sfx sfx)
-{
- if (sfx == Sfx_true)
- ItemSoundManager::playSfx(item, ItemSoundEvent::PICKUP);
- if (playerHandler != nullptr)
- playerHandler->pickUp(item);
-}
-
-// --- Misc -------------------------------------------------------------------
-
-void setBackend(const PlayerInfoBackend &backend)
-{
- mData = backend;
-}
-
-void setCharId(const int charId)
-{
- mCharId = charId;
-}
-
-int getCharId()
-{
- return mCharId;
-}
-
-Trading isTrading()
-{
- return mTrading;
-}
-
-void setTrading(const Trading trading)
-{
- mTrading = trading;
-}
-
-#define updateAttackStat(atk, delay, speed) \
- attackDelay = getStatBase(delay); \
- if (attackDelay != 0) \
- { \
- setStatBase(speed, \
- getStatBase(atk) * 1000 / attackDelay, \
- Notify_false); \
- setStatMod(speed, \
- getStatMod(atk) * 1000 / attackDelay, \
- Notify_true); \
- } \
- else \
- { \
- setStatBase(speed, 0, \
- Notify_false); \
- setStatMod(speed, 0, \
- Notify_true); \
- }
-
-void updateAttrs()
-{
- int attackDelay;
- updateAttackStat(Attributes::PLAYER_ATK,
- Attributes::PLAYER_ATTACK_DELAY,
- Attributes::PLAYER_ATTACK_SPEED)
- updateAttackStat(Attributes::HOMUN_ATK,
- Attributes::HOMUN_ATTACK_DELAY,
- Attributes::HOMUN_ATTACK_SPEED)
- updateAttackStat(Attributes::MERC_ATK,
- Attributes::MERC_ATTACK_DELAY,
- Attributes::MERC_ATTACK_SPEED)
-}
-
-void init()
-{
-}
-
-void deinit()
-{
- clearInventory();
- delete2(mMercenary);
- mPetBeingId = BeingId_zero;
-}
-
-void loadData()
-{
- mProtectedItems.clear();
- splitToIntSet(mProtectedItems,
- serverConfig.getStringValue("protectedItems"), ',');
-}
-
-void clear()
-{
- mData.mSkills.clear();
- mPetBeingId = BeingId_zero;
-}
-
-bool isTalking()
-{
- return NpcDialog::isActive() || InventoryWindow::isStorageActive();
-}
-
-void gameDestroyed()
-{
- delete2(mInventory);
- delete2(mEquipment);
- delete2(mCartInventory);
-}
-
-void stateChange(const StateT state)
-{
- if (state == State::GAME)
- {
- if (mInventory == nullptr)
- {
- mInventory = new Inventory(InventoryType::Inventory);
- mEquipment = new Equipment;
- mCartInventory = new Inventory(InventoryType::Cart);
- }
- }
-}
-
-static void saveProtectedItems()
-{
- std::string str;
- std::set<int>::const_iterator it = mProtectedItems.begin();
- std::set<int>::const_iterator it_end = mProtectedItems.end();
- if (it != it_end)
- {
- str.append(toString(*it));
- ++ it;
- }
- while (it != it_end)
- {
- str.append(",").append(toString(*it));
- ++ it;
- }
- serverConfig.setValue("protectedItems", str);
- serverConfig.write();
-}
-
-void protectItem(const int id)
-{
- mProtectedItems.insert(id);
- saveProtectedItems();
-}
-
-void unprotectItem(const int id)
-{
- mProtectedItems.erase(id);
- saveProtectedItems();
-}
-
-bool isItemProtected(const int id)
-{
- return mProtectedItems.find(id) != mProtectedItems.end();
-}
-
-void setMercenary(MercenaryInfo *const info)
-{
- delete mMercenary;
- mMercenary = info;
-}
-
-void setMercenaryBeing(Being *const being)
-{
- if (being == nullptr ||
- mMercenary == nullptr)
- {
- return;
- }
- being->setName(mMercenary->name);
- being->setOwner(localPlayer);
- being->setLevel(mMercenary->level);
- being->setAttackRange(mMercenary->range);
-}
-
-void setElemental(const BeingId id)
-{
- mElementalId = id;
-}
-
-BeingId getElementalId()
-{
- return mElementalId;
-}
-
-MercenaryInfo *getMercenary()
-{
- return mMercenary;
-}
-
-void setPet(PetInfo *const info)
-{
- delete mPet;
- mPet = info;
-}
-
-void setPetBeing(Being *const being)
-{
- if (being != nullptr)
- mPetBeingId = being->getId();
- else
- mPetBeingId = BeingId_zero;
- if (being == nullptr ||
- mPet == nullptr)
- {
- return;
- }
- being->setName(mPet->name);
- being->setOwner(localPlayer);
- being->setLevel(mPet->level);
-}
-
-PetInfo *getPet()
-{
- return mPet;
-}
-
-BeingId getPetBeingId()
-{
- return mPetBeingId;
-}
-
-void setHomunculus(HomunculusInfo *const info)
-{
- delete mHomunculus;
- mHomunculus = info;
-}
-
-void setHomunculusBeing(Being *const being)
-{
- if (being == nullptr ||
- mHomunculus == nullptr)
- {
- return;
- }
- being->setName(mHomunculus->name);
- being->setOwner(localPlayer);
-}
-
-HomunculusInfo *getHomunculus()
-{
- return mHomunculus;
-}
-
-BeingId getHomunculusId()
-{
- return mHomunculus != nullptr ? mHomunculus->id : BeingId_zero;
-}
-
-BeingId getMercenaryId()
-{
- return mMercenary != nullptr ? mMercenary->id : BeingId_zero;
-}
-
-void updateAttackAi(const BeingId targetId,
- const Keep keep)
-{
- if (mMercenary != nullptr &&
- mercenaryHandler != nullptr)
- {
- mercenaryHandler->attack(targetId, keep);
- }
- if (mHomunculus != nullptr &&
- homunculusHandler != nullptr)
- {
- homunculusHandler->attack(targetId, keep);
- }
-}
-
-std::string getRoomName()
-{
- return mRoomName;
-}
-
-void setRoomName(const std::string &name)
-{
- mRoomName = name;
-}
-
-bool isInRoom()
-{
- return !mRoomName.empty();
-}
-
-void setGuildPositionFlags(const GuildPositionFlags::Type pos)
-{
- mGuildPositionFlags = pos;
-}
-
-GuildPositionFlags::Type getGuildPositionFlags()
-{
- return mGuildPositionFlags;
-}
-
-void enableVending(const bool b)
-{
- mVending = b;
-}
-
-bool isVending()
-{
- return mVending;
-}
-
-void setServerLanguage(const int lang)
-{
- if (lang != mServerLanguage)
- {
- mServerLanguage = lang;
- TranslationManager::loadDictionaryLang();
- }
-}
-
-int getServerLanguage()
-{
- return mServerLanguage;
-}
-
-} // namespace PlayerInfo
diff --git a/src/being/playerinfo.h b/src/being/playerinfo.h
deleted file mode 100644
index 5528a1c3d..000000000
--- a/src/being/playerinfo.h
+++ /dev/null
@@ -1,313 +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 BEING_PLAYERINFO_H
-#define BEING_PLAYERINFO_H
-
-#include "equipment.h"
-
-#include "enums/guildpositionflags.h"
-#include "enums/state.h"
-
-#include "enums/being/attributes.h"
-
-#include "enums/simpletypes/beingid.h"
-#include "enums/simpletypes/keep.h"
-#include "enums/simpletypes/notify.h"
-#include "enums/simpletypes/sfx.h"
-#include "enums/simpletypes/trading.h"
-
-#include "utils/intmap.h"
-
-#include <string>
-
-/**
- * Stat information storage structure.
- */
-struct Stat final
-{
- A_DEFAULT_COPY(Stat)
-
- int base;
- int mod;
- int exp;
- int expNeed;
-};
-
-typedef std::map<AttributesT, int64_t> AtrIntMap;
-typedef std::map<AttributesT, Stat> StatMap;
-
-/**
- * Backend for core player information.
- */
-struct PlayerInfoBackend final
-{
- PlayerInfoBackend() :
- mAttributes(),
- mStats(),
- mSkills()
- {
- }
-
- A_DEFAULT_COPY(PlayerInfoBackend)
-
- AtrIntMap mAttributes;
- StatMap mStats;
- IntMap mSkills;
-};
-
-class Being;
-class FloorItem;
-class Inventory;
-class Item;
-
-struct HomunculusInfo;
-struct MercenaryInfo;
-struct PetInfo;
-
-/**
- * A database like namespace which holds global info about the localplayer
- *
- */
-namespace PlayerInfo
-{
-// --- Attributes -------------------------------------------------------------
-
- /**
- * Returns the value of the given attribute.
- */
- int64_t getAttribute64(const AttributesT id) A_WARN_UNUSED;
-
- int32_t getAttribute(const AttributesT id) A_WARN_UNUSED;
-
- /**
- * Changes the value of the given attribute.
- */
- void setAttribute(const AttributesT id,
- const int64_t value,
- const Notify notify = Notify_true);
-
- int getSkillLevel(const int id) A_WARN_UNUSED;
-
- void setSkillLevel(const int id, const int value);
-
-// --- Stats ------------------------------------------------------------------
-
- /**
- * Returns the base value of the given stat.
- */
- int getStatBase(const AttributesT id) A_WARN_UNUSED;
-
- /**
- * Changes the base value of the given stat.
- */
- void setStatBase(const AttributesT id,
- const int value,
- const Notify notify = Notify_true);
-
- /**
- * Returns the modifier for the given stat.
- */
- int getStatMod(const AttributesT id) A_WARN_UNUSED;
-
- /**
- * Changes the modifier for the given stat.
- */
- void setStatMod(const AttributesT id,
- const int value,
- const Notify notify = Notify_true);
-
- /**
- * Returns the current effective value of the given stat. Effective is base
- * + mod
- */
- int getStatEffective(const AttributesT id) A_WARN_UNUSED;
-
- /**
- * Changes the level of the given stat.
- */
- void setStatLevel(AttributesT id, int value, Notify notify = Notify_true);
-
- /**
- * Returns the experience of the given stat.
- */
- const std::pair<int, int> getStatExperience(const AttributesT id)
- A_WARN_UNUSED;
-
- /**
- * Changes the experience of the given stat.
- */
- void setStatExperience(const AttributesT id,
- const int have,
- const int need,
- const Notify notify = Notify_true);
-
-// --- Inventory / Equipment --------------------------------------------------
-
- /**
- * Returns the player's inventory.
- */
- Inventory *getInventory() A_WARN_UNUSED;
-
- Inventory *getStorageInventory() A_WARN_UNUSED;
-
- Inventory *getCartInventory() A_WARN_UNUSED;
-
- /**
- * Clears the player's inventory and equipment.
- */
- void clearInventory();
-
- void clear();
-
- /**
- * Returns the player's equipment.
- */
- Equipment *getEquipment() A_WARN_UNUSED;
-
- /**
- * Returns the player's equipment at the given slot.
- */
- const Item *getEquipment(const unsigned int slot) A_WARN_UNUSED;
-
-// --- Misc -------------------------------------------------------------------
-
- /**
- * Changes the internal PlayerInfoBackend reference;
- */
- void setBackend(const PlayerInfoBackend &backend);
-
- void setCharId(const int charId);
-
- int getCharId();
-
- /**
- * Returns true if the player is involved in a trade at the moment, false
- * otherwise.
- */
- Trading isTrading();
-
- /**
- * Sets whether the player is currently involved in trade or not.
- */
- void setTrading(const Trading trading);
-
- void updateAttrs();
-
- /**
- * Initializes some internals.
- */
- void init() A_CONST;
-
- void deinit();
-
- void loadData();
-
- bool isTalking();
-
- void gameDestroyed();
-
- void stateChange(const StateT state);
-
- void triggerAttr(const AttributesT id,
- const int64_t old);
-
- void triggerStat(const AttributesT id,
- const int old1,
- const int old2);
-
- void setEquipmentBackend(Equipment::Backend *const backend);
-
- void equipItem(const Item *const item, const Sfx sfx);
-
- void unequipItem(const Item *const item, const Sfx sfx);
-
- void useItem(const Item *const item, const Sfx sfx);
-
- void useEquipItem(const Item *const item,
- const int16_t useType,
- const Sfx sfx);
-
- void useEquipItem2(const Item *const item,
- const int16_t useType,
- const Sfx sfx);
-
- void dropItem(const Item *const item, const int amount, const Sfx sfx);
-
- void pickUpItem(const FloorItem *const item, const Sfx sfx);
-
- void protectItem(const int id);
-
- void unprotectItem(const int id);
-
- bool isItemProtected(const int id);
-
- MercenaryInfo *getMercenary();
-
- void setMercenary(MercenaryInfo *const info);
-
- void setMercenaryBeing(Being *const being);
-
- PetInfo *getPet();
-
- void setPet(PetInfo *const info);
-
- void setPetBeing(Being *const being);
-
- BeingId getPetBeingId();
-
- HomunculusInfo *getHomunculus();
-
- void setHomunculus(HomunculusInfo *const info);
-
- void setHomunculusBeing(Being *const being);
-
- void setElemental(const BeingId id);
-
- BeingId getHomunculusId();
-
- BeingId getMercenaryId();
-
- BeingId getElementalId();
-
- void updateAttackAi(const BeingId targetId,
- const Keep keep);
-
- std::string getRoomName();
-
- void setRoomName(const std::string &name);
-
- bool isInRoom();
-
- void setGuildPositionFlags(const GuildPositionFlags::Type pos);
-
- GuildPositionFlags::Type getGuildPositionFlags();
-
- void enableVending(const bool b);
-
- bool isVending() A_WARN_UNUSED;
-
- void setServerLanguage(const int lang);
-
- int getServerLanguage() A_WARN_UNUSED;
-} // namespace PlayerInfo
-
-#endif // BEING_PLAYERINFO_H
diff --git a/src/being/playerrelation.cpp b/src/being/playerrelation.cpp
deleted file mode 100644
index 0b4627089..000000000
--- a/src/being/playerrelation.cpp
+++ /dev/null
@@ -1,30 +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 "being/playerrelation.h"
-
-#include "debug.h"
-
-PlayerRelation::PlayerRelation(const RelationT relation) :
- mRelation(relation)
-{
-}
diff --git a/src/being/playerrelation.h b/src/being/playerrelation.h
deleted file mode 100644
index bc96c9bcd..000000000
--- a/src/being/playerrelation.h
+++ /dev/null
@@ -1,57 +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 BEING_PLAYERRELATION_H
-#define BEING_PLAYERRELATION_H
-
-#include "enums/being/relation.h"
-
-#include "localconsts.h"
-
-struct PlayerRelation final
-{
- static const unsigned int EMOTE = (1U << 0);
- static const unsigned int SPEECH_FLOAT = (1U << 1);
- static const unsigned int SPEECH_LOG = (1U << 2);
- static const unsigned int WHISPER = (1U << 3);
- static const unsigned int TRADE = (1U << 4);
- static const unsigned int INVISIBLE = (1U << 5);
- static const unsigned int BLACKLIST = (1U << 6);
- static const unsigned int ENEMY = (1U << 7);
-
- static const unsigned int RELATIONS_NR = 7;
- static const unsigned int RELATION_PERMISSIONS[RELATIONS_NR];
-
- static const unsigned int DEFAULT = EMOTE
- | SPEECH_FLOAT
- | SPEECH_LOG
- | WHISPER
- | TRADE;
-
- explicit PlayerRelation(const RelationT relation);
-
- A_DELETE_COPY(PlayerRelation)
-
- RelationT mRelation; // bitmask for all of the above
-};
-
-#endif // BEING_PLAYERRELATION_H
diff --git a/src/being/playerrelations.cpp b/src/being/playerrelations.cpp
deleted file mode 100644
index fe774432b..000000000
--- a/src/being/playerrelations.cpp
+++ /dev/null
@@ -1,661 +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 "being/playerrelations.h"
-
-#include "actormanager.h"
-#include "configuration.h"
-#include "logger.h"
-
-#include "being/localplayer.h"
-#include "being/playerignorestrategy.h"
-#include "being/playerrelation.h"
-
-#include "utils/dtor.h"
-#include "utils/foreach.h"
-#include "utils/gettext.h"
-
-#include "listeners/playerrelationslistener.h"
-
-#include "debug.h"
-
-static const unsigned int FIRST_IGNORE_EMOTE = 14;
-
-typedef std::map<std::string, PlayerRelation *> PlayerRelations;
-typedef PlayerRelations::const_iterator PlayerRelationsCIter;
-typedef std::list<PlayerRelationsListener *> PlayerRelationListeners;
-typedef PlayerRelationListeners::const_iterator PlayerRelationListenersCIter;
-
-static const char *const PLAYER_IGNORE_STRATEGY_NOP = "nop";
-static const char *const PLAYER_IGNORE_STRATEGY_EMOTE0 = "emote0";
-static const char *const DEFAULT_IGNORE_STRATEGY =
- PLAYER_IGNORE_STRATEGY_EMOTE0;
-
-static const char *const NAME = "name";
-static const char *const RELATION = "relation";
-
-static const unsigned int IGNORE_EMOTE_TIME = 100;
-
-namespace
-{
- class SortPlayersFunctor final
- {
- public:
- SortPlayersFunctor()
- { }
-
- A_DEFAULT_COPY(SortPlayersFunctor)
-
- bool operator() (const std::string &str1,
- const std::string &str2) const
- {
- std::string s1 = str1;
- std::string s2 = str2;
- toLower(s1);
- toLower(s2);
- if (s1 == s2)
- return str1 < str2;
- return s1 < s2;
- }
- } playersRelSorter;
-
- // (De)serialisation class
- class PlayerConfSerialiser final :
- public ConfigurationListManager<std::pair<std::string,
- PlayerRelation *>, std::map<std::string, PlayerRelation *> *>
- {
- public:
- PlayerConfSerialiser()
- { }
-
- A_DELETE_COPY(PlayerConfSerialiser)
-
- ConfigurationObject *writeConfigItem(
- const std::pair<std::string, PlayerRelation *> &value,
- ConfigurationObject *const cobj) const override final
- {
- if (cobj == nullptr ||
- value.second == nullptr)
- {
- return nullptr;
- }
- cobj->setValue(NAME, value.first);
- cobj->setValue(RELATION, toString(
- CAST_S32(value.second->mRelation)));
-
- return cobj;
- }
-
- std::map<std::string, PlayerRelation *> *
- readConfigItem(const ConfigurationObject *const cobj,
- std::map<std::string, PlayerRelation *>
- *const container) const override final
- {
- if (cobj == nullptr ||
- container == nullptr)
- {
- return container;
- }
- const std::string name = cobj->getValue(NAME, "");
- if (name.empty())
- return container;
-
- if ((*container)[name] == nullptr)
- {
- const int v = cobj->getValueInt(RELATION,
- CAST_S32(Relation::NEUTRAL));
-
- (*container)[name] = new PlayerRelation(
- static_cast<RelationT>(v));
- }
- // otherwise ignore the duplicate entry
-
- return container;
- }
- };
-} // namespace
-
-static PlayerConfSerialiser player_conf_serialiser; // stateless singleton
-
-const unsigned int PlayerRelation::RELATION_PERMISSIONS[RELATIONS_NR] =
-{
- /* NEUTRAL */ 0, // we always fall back to the defaults anyway
- /* FRIEND */ EMOTE | SPEECH_FLOAT | SPEECH_LOG | WHISPER | TRADE,
- /* DISREGARDED*/ EMOTE | SPEECH_FLOAT,
- /* IGNORED */ 0,
- /* ERASED */ INVISIBLE,
- /* BLACKLISTED */ SPEECH_LOG | WHISPER,
- /* ENEMY2 */ EMOTE | SPEECH_FLOAT | SPEECH_LOG | WHISPER | TRADE
-};
-
-PlayerRelationsManager::PlayerRelationsManager() :
- mPersistIgnores(false),
- mDefaultPermissions(PlayerRelation::DEFAULT),
- mIgnoreStrategy(nullptr),
- mRelations(),
- mListeners(),
- mIgnoreStrategies()
-{
-}
-
-PlayerRelationsManager::~PlayerRelationsManager()
-{
- delete_all(mIgnoreStrategies);
-
- FOR_EACH (PlayerRelationsCIter, it, mRelations)
- delete it->second;
- mRelations.clear();
-}
-
-void PlayerRelationsManager::clear()
-{
- StringVect *const names = getPlayers();
- FOR_EACHP (StringVectCIter, it, names)
- removePlayer(*it);
- delete names;
-}
-
-static const char *const PERSIST_IGNORE_LIST = "persistent-player-list";
-static const char *const PLAYER_IGNORE_STRATEGY = "player-ignore-strategy";
-static const char *const DEFAULT_PERMISSIONS = "default-player-permissions";
-
-int PlayerRelationsManager::getPlayerIgnoreStrategyIndex(
- const std::string &name)
-{
- const STD_VECTOR<PlayerIgnoreStrategy *> *const strategies
- = getPlayerIgnoreStrategies();
-
- if (strategies == nullptr)
- return -1;
-
- const size_t sz = strategies->size();
- for (size_t i = 0; i < sz; i++)
- {
- if ((*strategies)[i]->mShortName == name)
- return CAST_S32(i);
- }
-
- return -1;
-}
-
-void PlayerRelationsManager::load()
-{
- Configuration *const cfg = &serverConfig;
- clear();
-
- mPersistIgnores = (cfg->getValue(PERSIST_IGNORE_LIST, 1) != 0);
- mDefaultPermissions = CAST_S32(cfg->getValue(DEFAULT_PERMISSIONS,
- mDefaultPermissions));
-
- const std::string ignore_strategy_name = cfg->getValue(
- PLAYER_IGNORE_STRATEGY, DEFAULT_IGNORE_STRATEGY);
- const int ignore_strategy_index = getPlayerIgnoreStrategyIndex(
- ignore_strategy_name);
-
- if (ignore_strategy_index >= 0)
- {
- setPlayerIgnoreStrategy((*getPlayerIgnoreStrategies())
- [ignore_strategy_index]);
- }
-
- cfg->getList<std::pair<std::string, PlayerRelation *>,
- std::map<std::string, PlayerRelation *> *>
- ("player", &(mRelations), &player_conf_serialiser);
-}
-
-
-void PlayerRelationsManager::init()
-{
- load();
-
- if (!mPersistIgnores)
- {
- clear(); // Yes, we still keep them around in the config file
- // until the next update.
- }
-
- FOR_EACH (PlayerRelationListenersCIter, it, mListeners)
- (*it)->updateAll();
-}
-
-void PlayerRelationsManager::store() const
-{
- serverConfig.setList<std::map<std::string,
- PlayerRelation *>::const_iterator,
- std::pair<std::string, PlayerRelation *>,
- std::map<std::string, PlayerRelation *> *>
- ("player", mRelations.begin(), mRelations.end(),
- &player_conf_serialiser);
-
- serverConfig.setValue(DEFAULT_PERMISSIONS, mDefaultPermissions);
- serverConfig.setValue(PERSIST_IGNORE_LIST, mPersistIgnores);
- serverConfig.setValue(PLAYER_IGNORE_STRATEGY,
- mIgnoreStrategy != nullptr ? mIgnoreStrategy->mShortName :
- DEFAULT_IGNORE_STRATEGY);
-
- serverConfig.write();
-}
-
-void PlayerRelationsManager::signalUpdate(const std::string &name)
-{
- FOR_EACH (PlayerRelationListenersCIter, it, mListeners)
- (*it)->updatedPlayer(name);
-
- if (actorManager != nullptr)
- {
- Being *const being = actorManager->findBeingByName(
- name, ActorType::Player);
-
- if (being != nullptr &&
- being->getType() == ActorType::Player)
- {
- being->updateColors();
- }
- }
-}
-
-unsigned int PlayerRelationsManager::checkPermissionSilently(
- const std::string &player_name, const unsigned int flags) const
-{
- const std::map<std::string, PlayerRelation *>::const_iterator
- it = mRelations.find(player_name);
- if (it == mRelations.end())
- {
- return mDefaultPermissions & flags;
- }
-
- const PlayerRelation *const r = (*it).second;
- unsigned int permissions = PlayerRelation::RELATION_PERMISSIONS[
- CAST_S32(r->mRelation)];
-
- switch (r->mRelation)
- {
- case Relation::NEUTRAL:
- permissions = mDefaultPermissions;
- break;
-
- case Relation::FRIEND:
- permissions |= mDefaultPermissions; // widen
- break;
-
- case Relation::DISREGARDED:
- case Relation::IGNORED:
- case Relation::ERASED:
- case Relation::BLACKLISTED:
- case Relation::ENEMY2:
- default:
- permissions &= mDefaultPermissions; // narrow
- break;
- }
-
- return permissions & flags;
-}
-
-bool PlayerRelationsManager::hasPermission(const Being *const being,
- const unsigned int flags) const
-{
- if (being == nullptr)
- return false;
-
- if (being->getType() == ActorType::Player)
- {
- return static_cast<unsigned int>(hasPermission(
- being->getName(), flags)) == flags;
- }
- return true;
-}
-
-bool PlayerRelationsManager::hasPermission(const std::string &name,
- const unsigned int flags) const
-{
- if (actorManager == nullptr)
- return false;
-
- const unsigned int rejections = flags
- & ~checkPermissionSilently(name, flags);
- const bool permitted = (rejections == 0);
-
- if (!permitted)
- {
- // execute `ignore' strategy, if possible
- if (mIgnoreStrategy != nullptr)
- {
- Being *const b = actorManager->findBeingByName(
- name, ActorType::Player);
-
- if ((b != nullptr) && b->getType() == ActorType::Player)
- mIgnoreStrategy->ignore(b, rejections);
- }
- }
-
- return permitted;
-}
-
-void PlayerRelationsManager::setRelation(const std::string &player_name,
- const RelationT relation)
-{
- if (localPlayer == nullptr ||
- (relation != Relation::NEUTRAL &&
- localPlayer->getName() == player_name))
- {
- return;
- }
-
- PlayerRelation *const r = mRelations[player_name];
- if (r == nullptr)
- mRelations[player_name] = new PlayerRelation(relation);
- else
- r->mRelation = relation;
-
- signalUpdate(player_name);
- store();
-}
-
-StringVect *PlayerRelationsManager::getPlayers() const
-{
- StringVect *const retval = new StringVect;
-
- FOR_EACH (PlayerRelationsCIter, it, mRelations)
- {
- if (it->second != nullptr)
- retval->push_back(it->first);
- }
-
- std::sort(retval->begin(), retval->end(), playersRelSorter);
-
- return retval;
-}
-
-StringVect *PlayerRelationsManager::getPlayersByRelation(
- const RelationT rel) const
-{
- StringVect *const retval = new StringVect;
-
- FOR_EACH (PlayerRelationsCIter, it, mRelations)
- {
- if ((it->second != nullptr) &&
- it->second->mRelation == rel)
- {
- retval->push_back(it->first);
- }
- }
-
- std::sort(retval->begin(), retval->end(), playersRelSorter);
-
- return retval;
-}
-
-void PlayerRelationsManager::removePlayer(const std::string &name)
-{
- delete mRelations[name];
- mRelations.erase(name);
- signalUpdate(name);
-}
-
-
-RelationT PlayerRelationsManager::getRelation(
- const std::string &name) const
-{
- const std::map<std::string, PlayerRelation *>::const_iterator
- it = mRelations.find(name);
- if (it != mRelations.end())
- return (*it).second->mRelation;
-
- return Relation::NEUTRAL;
-}
-
-////////////////////////////////////////
-// defaults
-
-unsigned int PlayerRelationsManager::getDefault() const
-{
- return mDefaultPermissions;
-}
-
-void PlayerRelationsManager::setDefault(const unsigned int permissions)
-{
- mDefaultPermissions = permissions;
-
- store();
- signalUpdate("");
-}
-
-void PlayerRelationsManager::ignoreTrade(const std::string &name) const
-{
- if (name.empty())
- return;
-
- const RelationT relation = getRelation(name);
-
- if (relation == Relation::IGNORED ||
- relation == Relation::DISREGARDED ||
- relation == Relation::BLACKLISTED ||
- relation == Relation::ERASED)
- {
- return;
- }
- playerRelations.setRelation(name, Relation::BLACKLISTED);
-}
-
-bool PlayerRelationsManager::checkBadRelation(const std::string &name) const
-{
- if (name.empty())
- return true;
-
- const RelationT relation = getRelation(name);
-
- if (relation == Relation::IGNORED ||
- relation == Relation::DISREGARDED ||
- relation == Relation::BLACKLISTED ||
- relation == Relation::ERASED ||
- relation == Relation::ENEMY2)
- {
- return true;
- }
- return false;
-}
-
-////////////////////////////////////////
-// ignore strategies
-
-
-class PIS_nothing final : public PlayerIgnoreStrategy
-{
- public:
- PIS_nothing() :
- PlayerIgnoreStrategy()
- {
- // TRANSLATORS: ignore/unignore action
- mDescription = _("Completely ignore");
- mShortName = PLAYER_IGNORE_STRATEGY_NOP;
- }
-
- A_DELETE_COPY(PIS_nothing)
-
- void ignore(Being *const being A_UNUSED,
- const unsigned int flags A_UNUSED) const override final
- {
- }
-};
-
-class PIS_dotdotdot final : public PlayerIgnoreStrategy
-{
- public:
- PIS_dotdotdot() :
- PlayerIgnoreStrategy()
- {
- // TRANSLATORS: ignore/unignore action
- mDescription = _("Print '...'");
- mShortName = "dotdotdot";
- }
-
- A_DELETE_COPY(PIS_dotdotdot)
-
- void ignore(Being *const being,
- const unsigned int flags A_UNUSED) const override final
- {
- if (being == nullptr)
- return;
-
- logger->log("ignoring: " + being->getName());
- being->setSpeech("...");
- }
-};
-
-
-class PIS_blinkname final : public PlayerIgnoreStrategy
-{
- public:
- PIS_blinkname() :
- PlayerIgnoreStrategy()
- {
- // TRANSLATORS: ignore/unignore action
- mDescription = _("Blink name");
- mShortName = "blinkname";
- }
-
- A_DELETE_COPY(PIS_blinkname)
-
- void ignore(Being *const being,
- const unsigned int flags A_UNUSED) const override final
- {
- if (being == nullptr)
- return;
-
- logger->log("ignoring: " + being->getName());
- being->flashName(200);
- }
-};
-
-class PIS_emote final : public PlayerIgnoreStrategy
-{
- public:
- PIS_emote(const uint8_t emote_nr,
- const std::string &description,
- const std::string &shortname) :
- PlayerIgnoreStrategy(),
- mEmotion(emote_nr)
- {
- mDescription = description;
- mShortName = shortname;
- }
-
- A_DELETE_COPY(PIS_emote)
-
- void ignore(Being *const being,
- const unsigned int flags A_UNUSED) const override final
- {
- if (being == nullptr)
- return;
-
- being->setEmote(mEmotion, IGNORE_EMOTE_TIME);
- }
- uint8_t mEmotion;
-};
-
-STD_VECTOR<PlayerIgnoreStrategy *> *
-PlayerRelationsManager::getPlayerIgnoreStrategies()
-{
- if (mIgnoreStrategies.empty())
- {
- // not initialised yet?
- mIgnoreStrategies.push_back(new PIS_emote(FIRST_IGNORE_EMOTE,
- // TRANSLATORS: ignore strategi
- _("Floating '...' bubble"),
- PLAYER_IGNORE_STRATEGY_EMOTE0));
- mIgnoreStrategies.push_back(new PIS_emote(FIRST_IGNORE_EMOTE + 1,
- // TRANSLATORS: ignore strategi
- _("Floating bubble"),
- "emote1"));
- mIgnoreStrategies.push_back(new PIS_nothing);
- mIgnoreStrategies.push_back(new PIS_dotdotdot);
- mIgnoreStrategies.push_back(new PIS_blinkname);
- }
- return &mIgnoreStrategies;
-}
-
-bool PlayerRelationsManager::isGoodName(const std::string &name) const
-{
- const size_t size = name.size();
-
- if (size < 3)
- return true;
-
- const std::map<std::string, PlayerRelation *>::const_iterator
- it = mRelations.find(name);
- if (it != mRelations.end())
- return true;
-
- return checkName(name);
-}
-
-bool PlayerRelationsManager::isGoodName(Being *const being) const
-{
- if (being == nullptr)
- return false;
- if (being->getGoodStatus() != -1)
- return being->getGoodStatus() == 1;
-
- const std::string &name = being->getName();
- const size_t size = name.size();
-
- if (size < 3)
- return true;
-
- const std::map<std::string, PlayerRelation *>::const_iterator
- it = mRelations.find(name);
- if (it != mRelations.end())
- return true;
-
- const bool status = checkName(name);
- being->setGoodStatus(status ? 1 : 0);
- return status;
-}
-
-bool PlayerRelationsManager::checkName(const std::string &name)
-{
- const size_t size = name.size();
- const std::string check = config.getStringValue("unsecureChars");
- const std::string lastChar = name.substr(size - 1, 1);
-
- if (name.substr(0, 1) == " " ||
- lastChar == " " ||
- lastChar == "." ||
- name.find(" ") != std::string::npos)
- {
- return false;
- }
- else if (check.empty())
- {
- return true;
- }
- else if (name.find_first_of(check) != std::string::npos)
- {
- return false;
- }
- else
- {
- return true;
- }
-}
-
-PlayerRelationsManager playerRelations;
diff --git a/src/being/playerrelations.h b/src/being/playerrelations.h
deleted file mode 100644
index d1db4a003..000000000
--- a/src/being/playerrelations.h
+++ /dev/null
@@ -1,213 +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 BEING_PLAYERRELATIONS_H
-#define BEING_PLAYERRELATIONS_H
-
-#include "utils/stringvector.h"
-
-#include "enums/being/relation.h"
-
-#include <list>
-#include <map>
-
-#include "localconsts.h"
-
-class Being;
-class PlayerIgnoreStrategy;
-class PlayerRelationsListener;
-
-struct PlayerRelation;
-
-/**
- * Player relations class, represents any particular relations and/or
- * preferences the user of the local client has wrt other players (identified
- * by std::string).
- */
-class PlayerRelationsManager final
-{
- public:
- PlayerRelationsManager();
-
- A_DELETE_COPY(PlayerRelationsManager)
-
- ~PlayerRelationsManager();
-
- /**
- * Initialise player relations manager (load config file etc.)
- */
- void init();
-
- /**
- * Load configuration from our config file, or substitute defaults.
- */
- void load();
-
- /**
- * Save configuration to our config file.
- */
- void store() const;
-
- /**
- * Determines whether the player in question is being ignored, filtered by
- * the specified flags.
- */
- unsigned int checkPermissionSilently(const std::string &player_name,
- const unsigned int flags)
- const A_WARN_UNUSED;
-
- /**
- * Tests whether the player in question is being ignored for any of the
- * actions in the specified flags. If so, trigger appropriate side effects
- * if requested by the player.
- */
- bool hasPermission(const Being *const being,
- const unsigned int flags) const A_WARN_UNUSED;
-
- bool hasPermission(const std::string &being,
- const unsigned int flags) const A_WARN_UNUSED;
-
- /**
- * Updates the relationship with this player.
- */
- void setRelation(const std::string &name,
- const RelationT relation);
-
- /**
- * Updates the relationship with this player.
- */
- RelationT getRelation(const std::string &name) const A_WARN_UNUSED;
-
- /**
- * Deletes the information recorded for a player.
- */
- void removePlayer(const std::string &name);
-
- /**
- * Retrieves the default permissions.
- */
- unsigned int getDefault() const A_WARN_UNUSED;
-
- /**
- * Sets the default permissions.
- */
- void setDefault(const unsigned int permissions);
-
- /**
- * Retrieves all known player ignore strategies.
- *
- * The player ignore strategies are allocated statically and must
- * not be deleted.
- */
- STD_VECTOR<PlayerIgnoreStrategy *> *getPlayerIgnoreStrategies()
- A_WARN_UNUSED;
-
- /**
- * Return the current player ignore strategy.
- *
- * \return A player ignore strategy, or nullptr
- */
- const PlayerIgnoreStrategy *getPlayerIgnoreStrategy() const
- noexcept2
- A_WARN_UNUSED
- { return mIgnoreStrategy; }
-
- /**
- * Sets the strategy to call when ignoring players.
- */
- void setPlayerIgnoreStrategy(PlayerIgnoreStrategy *const strategy)
- noexcept2
- { mIgnoreStrategy = strategy; }
-
- /**
- * For a given ignore strategy short name, find the appropriate index
- * in the ignore strategies vector.
- *
- * \param The short name of the ignore strategy to look up
- * \return The appropriate index, or -1
- */
- int getPlayerIgnoreStrategyIndex(const std::string &shortname)
- A_WARN_UNUSED;
-
- /**
- * Retrieves a sorted vector of all players for which we have any
- * relations recorded.
- */
- StringVect *getPlayers() const RETURNS_NONNULL A_WARN_UNUSED;
-
- StringVect *getPlayersByRelation(const RelationT rel)
- const A_WARN_UNUSED;
-
- /**
- * Removes all recorded player info.
- */
- void clear();
-
- /**
- * Do we persist our `ignore' setup?
- */
- bool getPersistIgnores() const noexcept2 A_WARN_UNUSED
- { return mPersistIgnores; }
-
- void ignoreTrade(const std::string &name) const;
-
- bool isGoodName(Being *const being) const A_WARN_UNUSED;
-
- bool isGoodName(const std::string &name) const A_WARN_UNUSED;
-
- /**
- * Change the `ignore persist' flag.
- *
- * @param value Whether to persist ignores
- */
- void setPersistIgnores(const bool value) noexcept2
- { mPersistIgnores = value; }
-
- void addListener(PlayerRelationsListener *const listener)
- { mListeners.push_back(listener); }
-
- void removeListener(PlayerRelationsListener *const listener)
- { mListeners.remove(listener); }
-
- bool checkBadRelation(const std::string &name) const A_WARN_UNUSED;
-
- private:
- void signalUpdate(const std::string &name);
-
- bool mPersistIgnores; // If NOT set, we delete the
- // ignored data upon reloading
- unsigned int mDefaultPermissions;
-
- static bool checkName(const std::string &name) A_WARN_UNUSED;
-
- PlayerIgnoreStrategy *mIgnoreStrategy;
- std::map<std::string, PlayerRelation *> mRelations;
- std::list<PlayerRelationsListener *> mListeners;
- STD_VECTOR<PlayerIgnoreStrategy *> mIgnoreStrategies;
-};
-
-
-extern PlayerRelationsManager playerRelations; // singleton representation
- // of player relations
-
-
-#endif // BEING_PLAYERRELATIONS_H
diff --git a/src/beingequipbackend.cpp b/src/beingequipbackend.cpp
deleted file mode 100644
index afe73342e..000000000
--- a/src/beingequipbackend.cpp
+++ /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/>.
- */
-
-#include "beingequipbackend.h"
-
-#include "being/being.h"
-
-#include "net/inventoryhandler.h"
-
-#include "resources/item/item.h"
-
-#include "utils/delete2.h"
-
-#include "debug.h"
-
-BeingEquipBackend::BeingEquipBackend(Being *const being) :
- Equipment::Backend(),
- mEquipment()
-{
- memset(mEquipment, 0, sizeof(mEquipment));
- if (being != nullptr)
- {
- const size_t sz = being->mSprites.size();
-
- for (size_t f = 0; f < sz; f ++)
- {
- const int idx = inventoryHandler->
- convertFromServerSlot(CAST_S32(f));
- const BeingSlot &slot = being->mSlots[f];
- const int id = slot.spriteId;
- if (id > 0 && idx >= 0 && idx < EQUIPMENT_SIZE)
- {
- Item *const item = new Item(id,
- ItemType::Unknown,
- 1,
- 0,
- slot.colorId,
- Identified_true,
- Damaged_false,
- Favorite_false,
- Equipm_true,
- Equipped_true);
- const CardsList &cards = slot.cardsId;
- if (!cards.isEmpty())
- item->setCards(&cards.cards[0], maxCards);
- mEquipment[idx] = item;
- }
- }
- }
-}
-
-BeingEquipBackend::~BeingEquipBackend()
-{
- for (int i = 0; i < EQUIPMENT_SIZE; i++)
- delete2(mEquipment[i])
-}
-
-void BeingEquipBackend::clear()
-{
- for (int i = 0; i < EQUIPMENT_SIZE; i++)
- delete2(mEquipment[i])
-}
-
-void BeingEquipBackend::setEquipment(const int index,
- const Item *const item)
-{
- mEquipment[index] = item;
-}
-
-const Item *BeingEquipBackend::getEquipment(const int index) const
-{
- if (index < 0 || index >= EQUIPMENT_SIZE)
- return nullptr;
- return mEquipment[index];
-}
diff --git a/src/beingequipbackend.h b/src/beingequipbackend.h
deleted file mode 100644
index 6778ac710..000000000
--- a/src/beingequipbackend.h
+++ /dev/null
@@ -1,53 +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 BEINGEQUIPBACKEND_H
-#define BEINGEQUIPBACKEND_H
-
-#include "equipment.h"
-
-#include "const/equipment.h"
-
-#include "localconsts.h"
-
-class Being;
-
-class BeingEquipBackend final : public Equipment::Backend
-{
- public:
- explicit BeingEquipBackend(Being *const being);
-
- A_DELETE_COPY(BeingEquipBackend)
-
- ~BeingEquipBackend();
-
- const Item *getEquipment(const int index) const override final
- A_WARN_UNUSED;
-
- void clear() override final;
-
- void setEquipment(const int index,
- const Item *const item);
-
- private:
- const Item *mEquipment[EQUIPMENT_SIZE];
-};
-
-#endif // BEINGEQUIPBACKEND_H
diff --git a/src/chatlogger.cpp b/src/chatlogger.cpp
deleted file mode 100644
index d6376f504..000000000
--- a/src/chatlogger.cpp
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2009-2010 Andrei Karas
- * 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 "chatlogger.h"
-
-#include "configuration.h"
-
-#include "fs/mkdir.h"
-
-#include "utils/cast.h"
-
-#include <iostream>
-#include <dirent.h>
-
-#ifdef WIN32
-#include <windows.h>
-#include <sys/time.h>
-#elif defined __APPLE__
-#include <Carbon/Carbon.h>
-#endif // WIN32
-
-#include "debug.h"
-
-ChatLogger *chatLogger = nullptr;
-
-ChatLogger::ChatLogger() :
- mLogFile(),
- mLogDir(),
- mBaseLogDir(),
- mServerName(),
- mLogFileName()
-{
-}
-
-ChatLogger::~ChatLogger()
-{
- if (mLogFile.is_open())
- mLogFile.close();
-}
-
-void ChatLogger::setLogFile(const std::string &logFilename)
-{
- if (mLogFile.is_open())
- mLogFile.close();
-
- mLogFile.open(logFilename.c_str(),
- std::ios_base::app);
- mLogFileName = logFilename;
-
- if (!mLogFile.is_open())
- {
- std::cout << "Warning: error while opening " <<
- logFilename <<
- " for writing.\n";
- }
-}
-
-void ChatLogger::setLogDir(const std::string &logDir)
-{
- mLogDir = logDir;
-
- if (mLogFile.is_open())
- mLogFile.close();
-
- DIR *const dir = opendir(mLogDir.c_str());
- if (dir == nullptr)
- mkdir_r(mLogDir.c_str());
- else
- closedir(dir);
-}
-
-void ChatLogger::log(std::string str)
-{
- const std::string &dateStr = getDir();
- const std::string logFileName = strprintf(
- "%s/#General.log", dateStr.c_str());
- if (!mLogFile.is_open() ||
- logFileName != mLogFileName)
- {
- setLogDir(dateStr);
- setLogFile(logFileName);
- }
-
- str = removeColors(str);
- writeTo(mLogFile, str);
-}
-
-void ChatLogger::log(std::string name,
- std::string str)
-{
- const std::string &dateStr = getDir();
- const std::string logFileName = strprintf("%s/%s.log",
- dateStr.c_str(), secureName(name).c_str());
-
- if (!mLogFile.is_open() || logFileName != mLogFileName)
- {
- setLogDir(dateStr);
- setLogFile(logFileName);
- }
-
- str = removeColors(str);
- writeTo(mLogFile, str);
-}
-
-std::string ChatLogger::getDir() const
-{
- std::string date;
-
- time_t rawtime;
- char buffer [81];
-
- time(&rawtime);
- struct tm *const timeinfo = localtime(&rawtime);
-
- strftime(buffer, 79, "%Y-%m/%d", timeinfo);
-
- date = strprintf("%s/%s/%s",
- mBaseLogDir.c_str(),
- mServerName.c_str(),
- buffer);
-
- return date;
-}
-
-std::string ChatLogger::secureName(std::string &name)
-{
- const size_t sz = name.length();
- for (size_t f = 0; f < sz; f ++)
- {
- const unsigned char ch = name[f];
- if ((ch < '0' || ch > '9') &&
- (ch < 'a' || ch > 'z') &&
- (ch < 'A' || ch > 'Z') &&
- ch != '-' &&
- ch != '+' &&
- ch != '=' &&
- ch != '.' &&
- ch != ',' &&
- ch != ')' &&
- ch != '(' &&
- ch != '[' &&
- ch != ']' &&
- ch != '#')
- {
- name[f] = '_';
- }
- }
- return name;
-}
-
-void ChatLogger::writeTo(std::ofstream &file,
- const std::string &str)
-{
- file << str << std::endl;
-}
-
-void ChatLogger::setServerName(const std::string &serverName)
-{
- mServerName = serverName;
- if (mServerName.empty())
- mServerName = config.getStringValue("MostUsedServerName0");
-
- if (mLogFile.is_open())
- mLogFile.close();
-
- secureName(mServerName);
- if (!mLogDir.empty())
- {
- const std::string name = pathJoin(mLogDir, mServerName);
- DIR *const dir = opendir(name.c_str());
- if (dir == nullptr)
- mkdir_r(name.c_str());
- else
- closedir(dir);
- }
-}
-
-void ChatLogger::loadLast(std::string name,
- std::list<std::string> &list,
- const unsigned int n) const
-{
- std::ifstream logFile;
- std::string fileName = strprintf("%s/%s.log",
- getDir().c_str(),
- secureName(name).c_str());
-
- logFile.open(fileName.c_str(), std::ios::in);
-
- if (!logFile.is_open())
- return;
-
- char line[710];
- unsigned sz = CAST_U32(list.size());
- while (logFile.getline(line, 700))
- {
- list.push_back(line);
- sz ++;
- if (sz > n)
- {
- list.pop_front();
- sz --;
- }
- }
-
- if (logFile.is_open())
- logFile.close();
-}
-
-void ChatLogger::clear()
-{
- mLogDir.clear();
- mServerName.clear();
- mLogFileName.clear();
-}
diff --git a/src/chatlogger.h b/src/chatlogger.h
deleted file mode 100644
index 0f9563096..000000000
--- a/src/chatlogger.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- * Copyright (C) 2009-2010 Andrei Karas
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * 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 CHATLOGGER_H
-#define CHATLOGGER_H
-
-#include <fstream>
-#include <list>
-
-#include "localconsts.h"
-
-class ChatLogger final
-{
- public:
- /**
- * Constructor.
- */
- ChatLogger();
-
- A_DELETE_COPY(ChatLogger)
-
- /**
- * Destructor, closes log file.
- */
- ~ChatLogger();
-
- /**
- * Enters a message in the log. The message will be timestamped.
- */
- void log(std::string str);
-
- void log(std::string name, std::string str);
-
- void loadLast(std::string name,
- std::list<std::string> &list,
- const unsigned int n) const;
-
- std::string getDir() const A_WARN_UNUSED;
-
- static std::string secureName(std::string &str);
-
- void setServerName(const std::string &serverName);
-
- void setBaseLogDir(const std::string &logDir)
- { mBaseLogDir = logDir; }
-
- void clear();
-
- private:
- /**
- * Sets the file to log to and opens it
- */
- void setLogFile(const std::string &logFilename);
-
- void setLogDir(const std::string &logDir);
-
- static void writeTo(std::ofstream &file,
- const std::string &str);
-
- std::ofstream mLogFile;
- std::string mLogDir;
- std::string mBaseLogDir;
- std::string mServerName;
- std::string mLogFileName;
-};
-
-extern ChatLogger *chatLogger;
-
-#endif // CHATLOGGER_H
diff --git a/src/client.h b/src/client.h
deleted file mode 100644
index e896bb1e5..000000000
--- a/src/client.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 CLIENT_H
-#define CLIENT_H
-
-#ifdef DYECMD
-#include "progs/dyecmd/client.h"
-PROGS_DYECMD_CLIENT_H
-#else // DYECMD
-#include "progs/manaplus/client.h"
-PROGS_MANAPLUS_CLIENT_H
-#endif // DYECMD
-#endif // CLIENT_H
diff --git a/src/commandline.cpp b/src/commandline.cpp
deleted file mode 100644
index e1f7ebc20..000000000
--- a/src/commandline.cpp
+++ /dev/null
@@ -1,293 +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 "commandline.h"
-
-#include "main.h"
-#include "settings.h"
-
-#include "fs/paths.h"
-
-#include "utils/cast.h"
-#include "utils/gettext.h"
-#include "utils/stringutils.h"
-
-#include <getopt.h>
-#include <iostream>
-#include <unistd.h>
-
-#include "debug.h"
-
-static void printHelp()
-{
- std::cout <<
- // TRANSLATORS: command line help
- _("manaplus [options] [manaplus-file]") <<
- std::endl << std::endl <<
- // TRANSLATORS: command line help
- _("[manaplus-file] : The manaplus file is an XML file (.manaplus)") <<
- std::endl <<
- // TRANSLATORS: command line help
- _(" used to set custom parameters") <<
- std::endl <<
- // TRANSLATORS: command line help
- _(" to the manaplus client.") <<
- std::endl << std::endl <<
- // TRANSLATORS: command line help
- _("Options:") <<
- std::endl <<
- // TRANSLATORS: command line help
- _(" -l --log-file : Log file to use") << std::endl <<
- // TRANSLATORS: command line help
- _(" -a --chat-log-dir : Chat log dir to use") << std::endl <<
- // TRANSLATORS: command line help
- _(" -v --version : Display the version") << std::endl <<
- // TRANSLATORS: command line help
- _(" -h --help : Display this help") << std::endl <<
- // TRANSLATORS: command line help
- _(" -C --config-dir : Configuration directory to use") <<
- std::endl <<
- // TRANSLATORS: command line help
- _(" -U --username : Login with this username") <<
- std::endl <<
- // TRANSLATORS: command line help
- _(" -P --password : Login with this password") <<
- std::endl <<
- // TRANSLATORS: command line help
- _(" -c --character : Login with this character") <<
- std::endl <<
- // TRANSLATORS: command line help
- _(" -s --server : Login server name or IP") <<
- std::endl <<
- // TRANSLATORS: command line help
- _(" -y --server-type : Login server type") <<
- std::endl <<
- // TRANSLATORS: command line help
- _(" -p --port : Login server port") <<
- std::endl <<
- // TRANSLATORS: command line help
- _(" -H --update-host : Use this update host") <<
- std::endl <<
- // TRANSLATORS: command line help
- _(" -D --default : Choose default character server and "
- "character") <<
- std::endl <<
- // TRANSLATORS: command line help
- _(" -u --skip-update : Skip the update downloads") <<
- std::endl <<
- // TRANSLATORS: command line help
- _(" -d --data : Directory to load game data from") <<
- std::endl <<
- // TRANSLATORS: command line help
- _(" -L --localdata-dir : Directory to use as local "
- "data directory") <<
- std::endl <<
- // TRANSLATORS: command line help
- _(" --screenshot-dir : Directory to store screenshots") <<
- std::endl <<
- // TRANSLATORS: command line help
- _(" --safemode : Start game in safe mode") <<
- std::endl <<
- // TRANSLATORS: command line help
- _(" --renderer : Set renderer type") <<
- std::endl <<
- // TRANSLATORS: command line help
- _(" -T --tests : Start testing drivers and "
- "auto configuring") <<
- std::endl <<
- // TRANSLATORS: command line help
- _(" -V --validate : Start validating client data") <<
- std::endl
-#ifdef USE_OPENGL
- <<
- // TRANSLATORS: command line help
- _(" -O --no-opengl : Disable OpenGL for this session") <<
- std::endl
-#endif // USE_OPENGL
- ;
-}
-
-static void printVersion()
-{
- std::cout <<
- strprintf("ManaPlus client %s", FULL_VERSION) <<
- std::endl;
-}
-
-void parseOptions(const int argc, char *const argv[])
-{
- const char *const optstring = "hvud:U:P:Dc:p:y:l:L:C:s:t:T:a:r:e:V";
-
- const struct option long_options[] =
- {
- { "config-dir", required_argument, nullptr, 'C' },
- { "data", required_argument, nullptr, 'd' },
- { "default", no_argument, nullptr, 'D' },
- { "password", required_argument, nullptr, 'P' },
- { "character", required_argument, nullptr, 'c' },
- { "help", no_argument, nullptr, 'h' },
- { "localdata-dir", required_argument, nullptr, 'L' },
- { "update-host", required_argument, nullptr, 'H' },
- { "port", required_argument, nullptr, 'p' },
- { "server", required_argument, nullptr, 's' },
- { "skip-update", no_argument, nullptr, 'u' },
- { "username", required_argument, nullptr, 'U' },
- { "no-opengl", no_argument, nullptr, 'O' },
- { "chat-log-dir", required_argument, nullptr, 'a' },
- { "version", no_argument, nullptr, 'v' },
- { "log-file", required_argument, nullptr, 'l' },
- { "screenshot-dir", required_argument, nullptr, 'i' },
- { "safemode", no_argument, nullptr, 'm' },
- { "tests", no_argument, nullptr, 'T' },
- { "test", required_argument, nullptr, 't' },
- { "renderer", required_argument, nullptr, 'r' },
- { "server-type", required_argument, nullptr, 'y' },
- { "enable-ipc", no_argument, nullptr, 'I' },
- { "hide-cursor", no_argument, nullptr, 'q' },
- { "error", no_argument, nullptr, 'e' },
- { "validate", no_argument, nullptr, 'V' },
- { nullptr, 0, nullptr, 0 }
- };
-
- Options &options = settings.options;
-
- while (optind < argc)
- {
- const int result = getopt_long(argc,
- argv,
- optstring,
- long_options,
- nullptr);
-
- if (result == -1)
- break;
-
- switch (result)
- {
- case 'C':
- options.configDir = optarg;
- break;
- case 'd':
- options.dataPath = optarg;
- break;
- case 'D':
- options.chooseDefault = true;
- break;
- case '?': // Unknown option
- case ':': // Missing argument
- case 'h':
- options.printHelp = true;
- break;
- case 'H':
- if (checkPath(optarg))
- options.updateHost = optarg;
- else
- options.updateHost.clear();
- break;
- case 'c':
- options.character = optarg;
- break;
- case 'P':
- options.password = optarg;
- break;
- case 's':
- options.serverName = optarg;
- break;
- case 'p':
- options.serverPort = CAST_U16(atoi(optarg));
- break;
- case 'u':
- options.skipUpdate = true;
- break;
- case 'U':
- options.username = optarg;
- break;
- case 'v':
- options.printVersion = true;
- break;
- case 'L':
- options.localDataDir = optarg;
- break;
- case 'O':
- options.noOpenGL = true;
- break;
- case 'l':
- options.logFileName = std::string(optarg);
- break;
- case 'a':
- options.chatLogDir = std::string(optarg);
- break;
- case 'i':
- options.screenshotDir = optarg;
- break;
- case 'm':
- options.safeMode = true;
- break;
- case 'T':
- options.testMode = true;
- options.test.clear();
- break;
- case 't':
- options.testMode = true;
- options.test = std::string(optarg);
- break;
- case 'r':
- options.renderer = CAST_S32(atoi(optarg));
- break;
- case 'y':
- options.serverType = optarg;
- break;
- case 'I':
- options.ipc = true;
- break;
- case 'q':
- options.hideCursor = true;
- break;
- case 'e':
- options.error = true;
- break;
- case 'V':
- options.validate = true;
- break;
- default:
- break;
- }
- }
-
- // when there are still options left use the last
- // one as branding file
- if (optind < argc)
- {
- options.brandingPath = argv[optind];
- }
-
- if (settings.options.printHelp)
- {
- printHelp();
- _exit(0);
- }
- else if (settings.options.printVersion)
- {
- printVersion();
- _exit(0);
- }
-}
diff --git a/src/commandline.h b/src/commandline.h
deleted file mode 100644
index 774a4ee91..000000000
--- a/src/commandline.h
+++ /dev/null
@@ -1,30 +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 COMMANDLINE_H
-#define COMMANDLINE_H
-
-#include "localconsts.h"
-
-void parseOptions(const int argc, char *const argv[]);
-
-#endif // COMMANDLINE_H
diff --git a/src/configmanager.cpp b/src/configmanager.cpp
deleted file mode 100644
index 13f917d1e..000000000
--- a/src/configmanager.cpp
+++ /dev/null
@@ -1,453 +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 "configmanager.h"
-
-#include "client.h"
-#include "configuration.h"
-#include "settings.h"
-
-#include "being/beingspeech.h"
-
-#include "fs/files.h"
-#include "fs/mkdir.h"
-#include "fs/paths.h"
-
-#include "utils/cast.h"
-#include "utils/checkutils.h"
-#include "utils/gettext.h"
-
-#include "render/renderers.h"
-
-#include "debug.h"
-
-static void setDefaultOption(const char *const name,
- const bool def)
-{
- const int val = serverConfig.getValue(name, -1);
- if (val == -1)
- serverConfig.setValue(name, def);
-}
-
-/**
- * Initializes the home directory. On UNIX and FreeBSD, ~/.mana is used. On
- * Windows and other systems we use the current working directory.
- */
-void ConfigManager::initServerConfig(const std::string &serverName)
-{
- settings.serverConfigDir = pathJoin(settings.configDir, serverName);
-
- if (mkdir_r(settings.serverConfigDir.c_str()) != 0)
- {
- // TRANSLATORS: directory creation error
- logger->error(strprintf(_("%s doesn't exist and can't be created! "
- "Exiting."), settings.serverConfigDir.c_str()));
- }
- const std::string configPath = settings.serverConfigDir + "/config.xml";
- FILE *configFile = fopen(configPath.c_str(), "r");
- if (configFile == nullptr)
- {
- configFile = fopen(configPath.c_str(), "wb");
- logger->log("Creating new server config: " + configPath);
- if (configFile != nullptr)
- {
- fputs("<?xml version=\"1.0\"?>\n", configFile);
- fputs("<configuration>\n", configFile);
- fputs("</configuration>\n", configFile);
- }
- }
- if (configFile != nullptr)
- {
- fclose(configFile);
- serverConfig.init(configPath);
- setConfigDefaults(serverConfig);
- logger->log("serverConfigPath: " + configPath);
- }
- else
- {
- reportAlways("Error creating server config: %s",
- configPath.c_str());
- }
-
- const bool val = Client::isTmw();
- setDefaultOption("enableManaMarketBot", val);
- setDefaultOption("enableRemoteCommands", !val);
-}
-
-void ConfigManager::initConfiguration()
-{
-#ifdef DEBUG_CONFIG
- config.setIsMain(true);
-#endif // DEBUG_CONFIG
-
- // Fill configuration with defaults
- config.setValue("hwaccel", false);
-#ifdef USE_OPENGL
-#if (defined __APPLE__)
- config.setValue("opengl", CAST_S32(RENDER_NORMAL_OPENGL));
-#elif (defined ANDROID)
- config.setValue("opengl", CAST_S32(RENDER_GLES_OPENGL));
-#elif (defined WIN32)
- config.setValue("opengl", CAST_S32(RENDER_SAFE_OPENGL));
-#else // (defined __APPLE__)
-
- config.setValue("opengl", CAST_S32(RENDER_SOFTWARE));
-#endif // (defined __APPLE__)
-#else // USE_OPENGL
-
- config.setValue("opengl", CAST_S32(RENDER_SOFTWARE));
-#endif // USE_OPENGL
-
- config.setValue("screen", false);
- config.setValue("sound", true);
- config.setValue("guialpha", 0.8F);
-// config.setValue("remember", true);
- config.setValue("sfxVolume", 100);
- config.setValue("musicVolume", 60);
- config.setValue("fpslimit", 60);
- std::string defaultUpdateHost = branding.getValue("defaultUpdateHost", "");
- if (!checkPath(defaultUpdateHost))
- defaultUpdateHost.clear();
- config.setValue("updatehost", defaultUpdateHost);
- config.setValue("useScreenshotDirectorySuffix", true);
- config.setValue("ChatLogLength", 128);
-
- std::string configPath;
-
-#ifndef UNITTESTS
- if (settings.options.test.empty())
- configPath = settings.configDir + "/config.xml";
- else
- configPath = settings.configDir + "/test.xml";
-#else // UNITTESTS
-
- configPath = settings.configDir + "/unittestconfig.xml";
-#endif // UNITTESTS
-
- FILE *configFile = fopen(configPath.c_str(), "r");
- if (configFile == nullptr)
- {
- configFile = fopen(configPath.c_str(), "wb");
- logger->log1("Creating new config");
- if (configFile != nullptr)
- {
- fputs("<?xml version=\"1.0\"?>\n", configFile);
- fputs("<configuration>\n", configFile);
- fputs("</configuration>\n", configFile);
- }
- }
- if (configFile == nullptr)
- {
- reportAlways("Can't create %s. Using defaults.",
- configPath.c_str());
- }
- else
- {
- fclose(configFile);
- config.init(configPath);
- logger->log1("init 3");
- setConfigDefaults(config);
- setConfigDefaults(serverConfig);
- logger->log("configuration file: " + configPath);
- }
-}
-
-void ConfigManager::backupConfig(const std::string &name)
-{
- const std::string fileName3 = pathJoin(settings.configDir, name);
- StringVect arr;
- if (Files::existsLocal(fileName3) == false)
- {
- logger->log("Config %s not exists, backup skipped.",
- name.c_str());
- return;
- }
- if (Files::loadTextFileLocal(fileName3, arr) == true)
- {
- if (arr.empty())
- return;
-
- arr.clear();
- const std::string tmpName = pathJoin(settings.configDir,
- name).append(".tmp");
- Files::copyFile(fileName3, tmpName);
- if (Files::loadTextFileLocal(tmpName, arr) == false ||
- arr.empty())
- {
- logger->safeError("Error backuping configs. "
- "Probably no free space on disk.");
- }
- arr.clear();
- }
-
- const std::string confName = pathJoin(settings.configDir,
- name).append(".bak");
- const int maxFileIndex = 5;
- ::remove((confName + toString(maxFileIndex)).c_str());
- for (int f = maxFileIndex; f > 1; f --)
- {
- const std::string fileName1 = confName + toString(f - 1);
- const std::string fileName2 = confName + toString(f);
- Files::renameFile(fileName1, fileName2);
- }
- const std::string fileName4 = confName + toString(1);
- Files::copyFile(fileName3, fileName4);
-}
-
-#ifdef __native_client__
-void ConfigManager::storeSafeParameters()
-{
- RenderType tmpOpengl;
-
- isSafeMode = config.getBoolValue("safemode");
- if (isSafeMode)
- logger->log1("Run in safe mode");
-
- tmpOpengl = intToRenderType(config.getIntValue("opengl"));
-
- config.setValue("opengl", CAST_S32(RENDER_SOFTWARE));
-
- config.write();
-
- if (settings.options.safeMode)
- {
- isSafeMode = true;
- return;
- }
-
- config.setValue("safemode", false);
- config.setValue("opengl", CAST_S32(tmpOpengl));
-}
-#elif !defined(ANDROID)
-void ConfigManager::storeSafeParameters()
-{
- bool tmpHwaccel;
- RenderType tmpOpengl;
- int tmpFpslimit;
- int tmpAltFpslimit;
- bool tmpSound;
- int width;
- int height;
- std::string font;
- std::string bFont;
- std::string particleFont;
- std::string helpFont;
- std::string secureFont;
- std::string npcFont;
- std::string japanFont;
- std::string chinaFont;
- bool showBackground;
- bool enableMumble;
- bool enableMapReduce;
-
- isSafeMode = config.getBoolValue("safemode");
- if (isSafeMode)
- logger->log1("Run in safe mode");
-
- tmpOpengl = intToRenderType(config.getIntValue("opengl"));
-
- width = config.getIntValue("screenwidth");
- height = config.getIntValue("screenheight");
- tmpHwaccel = config.getBoolValue("hwaccel");
-
- tmpFpslimit = config.getIntValue("fpslimit");
- tmpAltFpslimit = config.getIntValue("altfpslimit");
- tmpSound = config.getBoolValue("sound");
-
- font = config.getStringValue("font");
- bFont = config.getStringValue("boldFont");
- particleFont = config.getStringValue("particleFont");
- helpFont = config.getStringValue("helpFont");
- secureFont = config.getStringValue("secureFont");
- npcFont = config.getStringValue("npcFont");
- japanFont = config.getStringValue("japanFont");
- chinaFont = config.getStringValue("chinaFont");
-
- showBackground = config.getBoolValue("showBackground");
- enableMumble = config.getBoolValue("enableMumble");
- enableMapReduce = config.getBoolValue("enableMapReduce");
-
- if (!settings.options.safeMode && tmpOpengl == RENDER_SOFTWARE)
- {
- // if video mode configured reset most settings to safe
- config.setValue("hwaccel", false);
- config.setValue("altfpslimit", 3);
- config.setValue("sound", false);
- config.setValue("safemode", true);
- config.setValue("screenwidth", 640);
- config.setValue("screenheight", 480);
- config.setValue("font", "fonts/dejavusans.ttf");
- config.setValue("boldFont", "fonts/dejavusans-bold.ttf");
- config.setValue("particleFont", "fonts/dejavusans.ttf");
- config.setValue("helpFont", "fonts/dejavusansmono.ttf");
- config.setValue("secureFont", "fonts/dejavusansmono.ttf");
- config.setValue("npcFont", "fonts/dejavusans.ttf");
- config.setValue("japanFont", "fonts/mplus-1p-regular.ttf");
- config.setValue("chinaFont", "fonts/wqy-microhei.ttf");
- config.setValue("showBackground", false);
- config.setValue("enableMumble", false);
- config.setValue("enableMapReduce", false);
- }
- else
- {
- // if video mode not configured reset only video mode to safe
- config.setValue("screenwidth", 640);
- config.setValue("screenheight", 480);
- }
-#if defined(__APPLE__)
- config.setValue("opengl", CAST_S32(RENDER_NORMAL_OPENGL));
-#else // defined(__APPLE__)
-
- config.setValue("opengl", CAST_S32(RENDER_SOFTWARE));
-#endif // defined(__APPLE__)
-
- config.write();
-
- if (settings.options.safeMode)
- {
- isSafeMode = true;
- return;
- }
-
- config.setValue("safemode", false);
- if (tmpOpengl == RENDER_SOFTWARE)
- {
- config.setValue("hwaccel", tmpHwaccel);
- config.setValue("opengl", CAST_S32(tmpOpengl));
- config.setValue("fpslimit", tmpFpslimit);
- config.setValue("altfpslimit", tmpAltFpslimit);
- config.setValue("sound", tmpSound);
- config.setValue("screenwidth", width);
- config.setValue("screenheight", height);
- config.setValue("font", font);
- config.setValue("boldFont", bFont);
- config.setValue("particleFont", particleFont);
- config.setValue("helpFont", helpFont);
- config.setValue("secureFont", secureFont);
- config.setValue("npcFont", npcFont);
- config.setValue("japanFont", japanFont);
- config.setValue("chinaFont", chinaFont);
- config.setValue("showBackground", showBackground);
- config.setValue("enableMumble", enableMumble);
- config.setValue("enableMapReduce", enableMapReduce);
- }
- else
- {
- config.setValue("opengl", CAST_S32(tmpOpengl));
- config.setValue("screenwidth", width);
- config.setValue("screenheight", height);
- }
-}
-#endif // __native_client__
-
-#define unassignKey(key, value) \
- if (config.getStringValue(prefix + key) == value) \
- config.setValue(key, "-1");
-
-void ConfigManager::checkConfigVersion()
-{
- const int version = config.getIntValue("cfgver");
- if (version < 1)
- {
- if (config.getIntValue("fontSize") == 11)
- config.deleteKey("fontSize");
- if (config.getIntValue("npcfontSize") == 13)
- config.deleteKey("npcfontSize");
- }
- if (version < 2)
- {
- if (config.getIntValue("screenButtonsSize") == 1)
- config.deleteKey("screenButtonsSize");
- if (config.getIntValue("screenJoystickSize") == 1)
- config.deleteKey("screenJoystickSize");
- }
- if (version < 3)
- {
- config.setValue("audioFrequency", 44100);
-#ifdef ANDROID
- config.setValue("customcursor", false);
-#endif // ANDROID
- }
-#ifdef ANDROID
- if (version < 4)
- {
- config.setValue("showDidYouKnow", false);
- }
-#endif // ANDROID
-
- if (version < 5)
- {
- if (config.getIntValue("speech") == BeingSpeech::TEXT_OVERHEAD)
- {
- config.setValue("speech", CAST_S32(
- BeingSpeech::NO_NAME_IN_BUBBLE));
- }
- }
- if (version < 6)
- config.setValue("blur", false);
-
- if (version < 7)
- config.setValue("download-music", true);
-
- if (version < 9)
- {
- config.deleteKey("videodetected");
- config.setValue("moveToTargetType", 10);
- }
- if (version < 10)
- config.setValue("enableLazyScrolling", false);
-
- if (version < 11)
- {
-#ifdef USE_SDL2
- const std::string prefix = std::string("sdl2");
-#else // USE_SDL2
-
- const std::string prefix = std::string();
-#endif // USE_SDL2
-
- unassignKey("keyDirectUp", "k108");
- unassignKey("keyDirectDown", "k59");
- unassignKey("keyDirectLeft", "k107");
- unassignKey("keyDirectRight", "k39");
- }
- if (version < 12)
- {
-#ifdef USE_SDL2
- const std::string prefix = std::string("sdl2");
-#else // USE_SDL2
-
- const std::string prefix = std::string();
-#endif // USE_SDL2
-
- unassignKey("keyAttack", "k120");
- }
-
- if (version < 13)
- config.setValue("keyWindowBotChecker", -1);
-
- if (version < 14 && config.getIntValue("syncPlayerMoveDistance") == 2)
- config.setValue("syncPlayerMoveDistance", 5);
- config.setValue("cfgver", 14);
-}
-
-#undef unassignKey
diff --git a/src/configmanager.h b/src/configmanager.h
deleted file mode 100644
index 16e72d558..000000000
--- a/src/configmanager.h
+++ /dev/null
@@ -1,48 +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 CONFIGMANAGER_H
-#define CONFIGMANAGER_H
-
-#include <string>
-
-#include "localconsts.h"
-
-class ConfigManager final
-{
- public:
- A_DELETE_COPY(ConfigManager)
-
- static void initConfiguration();
-
- static void initServerConfig(const std::string &serverName);
-
-#ifndef ANDROID
- static void storeSafeParameters();
-#endif // ANDROID
-
- static void backupConfig(const std::string &name);
-
- static void checkConfigVersion();
-};
-
-#endif // CONFIGMANAGER_H
diff --git a/src/configuration.cpp b/src/configuration.cpp
deleted file mode 100644
index d3c514c67..000000000
--- a/src/configuration.cpp
+++ /dev/null
@@ -1,969 +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 "configuration.h"
-
-#include "variabledata.h"
-
-#include "fs/files.h"
-#include "fs/paths.h"
-
-#include "fs/virtfs/fs.h"
-
-#include "listeners/configlistener.h"
-
-#include "utils/cast.h"
-#include "utils/checkutils.h"
-#include "utils/foreach.h"
-#ifdef DEBUG_CONFIG
-#include "utils/stringmap.h"
-#endif // DEBUG_CONFIG
-
-#include "debug.h"
-
-#ifdef DEBUG_CONFIG
-StringIntMap optionsCount;
-#define GETLOG() if (logger) {logger->log("config get: " + key); \
- if (mIsMain) optionsCount[key] = 1; }
-#else // DEBUG_CONFIG
-#define GETLOG()
-#endif // DEBUG_CONFIG
-
-Configuration config; // XML file configuration reader
-Configuration serverConfig; // XML file server configuration reader
-Configuration features; // XML file features
-Configuration branding; // XML branding information reader
-Configuration paths; // XML default paths information reader
-
-const std::string unusedKeys[] =
-{
- "BotCheckerWindowSticky",
- "afkmessage",
- "BotCheckerWindowVisible",
- "BotCheckerWindowWinX",
- "BotCheckerWindowWinY",
- "hideShield",
- "AttackRange",
- "emoteshortcut0",
- "screenshotDirectory2",
- "AttackRangeBorder",
- "AttackRangeBorderDelay",
- "AttackRangeBorderGradient",
- "AttackRangeDelay",
- "AttackRangeGradient",
- "Being",
- "BeingDelay",
- "BeingGradient",
- "BeingPopupSkin",
- "BotCheckerWindowSkin",
- "BuySellSkin",
- "BuySkin",
- "ChatSkin",
- "CollisionHighlight",
- "CollisionHighlightDelay",
- "CollisionHighlightGradient",
- "ColorCross",
- "ColorCrossDelay",
- "ColorCrossGradient",
- "ColorExperience",
- "ColorExperienceGradient",
- "ColorPickup",
- "ColorPickupGradient",
- "DebugSkin",
- "DropShortcutSkin",
- "EmoteShortcutSkin",
- "EquipmentSkin",
- "ExpInfo",
- "ExpInfoDelay",
- "ExpInfoGradient",
- "Experience",
- "ExperienceGradient",
- "GM",
- "GMDelay",
- "GMGradient",
- "Guild",
- "GuildDelay",
- "GuildGradient",
- "GuildSkin",
- "HelpSkin",
- "Hit CriticalDelay",
- "Hit CriticalGradient",
- "Hit Monster Player",
- "Hit Monster PlayerGradient",
- "Hit Player Monster",
- "Hit Player MonsterGradient",
- "HitCriticalDelay",
- "HitCriticalGradient",
- "HitLocalPlayerCriticalDelay",
- "HitLocalPlayerCriticalGradient",
- "HitLocalPlayerMiss",
- "HitLocalPlayerMissDelay",
- "HitLocalPlayerMissGradient",
- "HitLocalPlayerMonster",
- "HitLocalPlayerMonsterDelay",
- "HitLocalPlayerMonsterGradient",
- "HitMonsterPlayer",
- "HitMonsterPlayerDelay",
- "HitMonsterPlayerGradient",
- "HitPlayerMonster",
- "HitPlayerMonsterDelay",
- "HitPlayerMonsterGradient",
- "HomePlace",
- "HomePlaceBorder",
- "HomePlaceBorderDelay",
- "HomePlaceBorderGradient",
- "HomePlaceDelay",
- "HomePlaceGradient",
- "InventorySkin",
- "ItemPopupSkin",
- "ItemShortcutSkin",
- "Kill statsSkin",
- "MiniStatusSkin",
- "MinimapSkin",
- "Miss",
- "MissDelay",
- "MissGradient",
- "Monster",
- "MonsterAttackRange",
- "MonsterAttackRangeDelay",
- "MonsterAttackRangeGradient",
- "MonsterDelay",
- "MonsterGradient",
- "NPC",
- "NPCDelay",
- "NPCGradient",
- "NpcTextSkin",
- "OutfitsSkin",
- "Particle",
- "ParticleDelay",
- "ParticleGradient",
- "PartyDelay",
- "PartyGradient",
- "PartySkin",
- "Personal ShopSkin",
- "Pickup",
- "PickupGradient",
- "Player",
- "PlayerDelay",
- "PlayerGradient",
- "PopupMenuSkin",
- "PortalHighlight",
- "PortalHighlightDelay",
- "PortalHighlightGradient",
- "RecorderSkin",
- "RecorderWinX",
- "RecorderWinY",
- "RoadPoint",
- "RoadPointDelay",
- "RoadPointGradient",
- "Self",
- "SelfDelay",
- "SelfGradient",
- "SellSkin",
- "ServerDialogSkin",
- "ShopSkin",
- "SkillsSkin",
- "SocialCreatePopupSkin",
- "SocialSkin",
- "SpecialsSkin",
- "SpeechSkin",
- "SpellPopupSkin",
- "SpellShortcutSkin",
- "StatusPopupSkin",
- "StatusSkin",
- "StorageSkin",
- "TextCommandEditorSkin",
- "TextPopupSkin",
- "TradeSkin",
- "WhoIsOnlineSkin",
- "emoteshortcut1",
- "emoteshortcut2",
- "emoteshortcut3",
- "emoteshortcut4",
- "emoteshortcut5",
- "emoteshortcut6",
- "emoteshortcut7",
- "emoteshortcut8",
- "emoteshortcut9",
- "emoteshortcut10",
- "emoteshortcut11",
- "emoteshortcut12",
- "emoteshortcut13",
- "fastOpenGL",
- "keyAutoCompleteChat",
- "keyDeActivateChat",
- "keyTargetClosest",
- "keyWindowParty",
- "mapalpha",
- "port",
- "shopBuyList",
- "shopSellList",
- "OutfitAwayIndex",
- "playerHomes",
- "remember",
- "screenshotDirectory",
- ""
-};
-
-void ConfigurationObject::setValue(const std::string &key,
- const std::string &value)
-{
- mOptions[key] = value;
-}
-
-void ConfigurationObject::deleteKey(const std::string &key)
-{
- mOptions.erase(key);
-}
-
-void Configuration::setValue(const std::string &key,
- const std::string &value)
-{
- ConfigurationObject::setValue(key, value);
- mUpdated = true;
-
- // Notify listeners
- const ListenerMapIterator list = mListenerMap.find(key);
- if (list != mListenerMap.end())
- {
- Listeners listeners = list->second;
- FOR_EACH (ListenerIterator, i, listeners)
- (*i)->optionChanged(key);
- }
-}
-
-void Configuration::incValue(const std::string &key)
-{
- GETLOG();
- const Options::const_iterator iter = mOptions.find(key);
- setValue(key, (iter != mOptions.end())
- ? atoi(iter->second.c_str()) + 1 : 1);
-}
-
-void Configuration::setSilent(const std::string &key,
- const std::string &value)
-{
- ConfigurationObject::setValue(key, value);
-}
-
-std::string ConfigurationObject::getValue(const std::string &key,
- const std::string &deflt) const
-{
- GETLOG();
- const Options::const_iterator iter = mOptions.find(key);
- return ((iter != mOptions.end()) ? iter->second : deflt);
-}
-
-int ConfigurationObject::getValue(const std::string &key,
- const int deflt) const
-{
- GETLOG();
- const Options::const_iterator iter = mOptions.find(key);
- return (iter != mOptions.end()) ? atoi(iter->second.c_str()) : deflt;
-}
-
-int ConfigurationObject::getValueInt(const std::string &key,
- const int deflt) const
-{
- GETLOG();
- const Options::const_iterator iter = mOptions.find(key);
- return (iter != mOptions.end()) ? atoi(iter->second.c_str()) : deflt;
-}
-
-bool ConfigurationObject::getValueBool(const std::string &key,
- const bool deflt) const
-{
- GETLOG();
- const Options::const_iterator iter = mOptions.find(key);
- if (iter != mOptions.end())
- return atoi(iter->second.c_str()) != 0 ? true : false;
- return deflt;
-}
-
-unsigned ConfigurationObject::getValue(const std::string &key,
- const unsigned deflt) const
-{
- GETLOG();
- const Options::const_iterator iter = mOptions.find(key);
- return (iter != mOptions.end()) ? CAST_U32(
- atol(iter->second.c_str())) : deflt;
-}
-
-double ConfigurationObject::getValue(const std::string &key,
- const double deflt) const
-{
- GETLOG();
- const Options::const_iterator iter = mOptions.find(key);
- return (iter != mOptions.end()) ? atof(iter->second.c_str()) : deflt;
-}
-
-void ConfigurationObject::deleteList(const std::string &name)
-{
- for (ConfigurationList::const_iterator
- it = mContainerOptions[name].begin();
- it != mContainerOptions[name].end(); ++it)
- {
- delete *it;
- }
-
- mContainerOptions[name].clear();
-}
-
-void ConfigurationObject::clear()
-{
- for (std::map<std::string, ConfigurationList>::const_iterator
- it = mContainerOptions.begin();
- it != mContainerOptions.end(); ++it)
- {
- deleteList(it->first);
- }
- mOptions.clear();
- mContainerOptions.clear();
-}
-
-ConfigurationObject::ConfigurationObject() :
- mOptions(),
-#ifdef DEBUG_CONFIG
- mContainerOptions(),
- mLogKeys(false),
- mIsMain(false)
-#else // DEBUG_CONFIG
-
- mContainerOptions()
-#endif // DEBUG_CONFIG
-{
-}
-
-ConfigurationObject::~ConfigurationObject()
-{
- clear();
-}
-
-Configuration::Configuration() :
- ConfigurationObject(),
- mListenerMap(),
- mConfigPath(),
- mDefaultsData(),
- mDirectory(),
- mFilename(),
- mUseResManager(UseVirtFs_false),
- mUpdated(false)
-{
-#ifdef DEBUG_CONFIG
- mLogKeys = false;
- mIsMain = false;
-#endif // DEBUG_CONFIG
-}
-
-void Configuration::cleanDefaults()
-{
- for (DefaultsData::const_iterator iter = mDefaultsData.begin();
- iter != mDefaultsData.end();
- ++iter)
- {
- delete iter->second;
- }
- mDefaultsData.clear();
-}
-
-Configuration::~Configuration()
-{
- cleanDefaults();
-}
-
-void Configuration::unload()
-{
- cleanDefaults();
- mConfigPath.clear();
- mDirectory.clear();
- mFilename.clear();
- mUseResManager = UseVirtFs_false;
- ConfigurationObject::clear();
-}
-
-int Configuration::getIntValue(const std::string &key) const
-{
- GETLOG();
- int defaultValue = 0;
- const Options::const_iterator iter = mOptions.find(key);
- if (iter == mOptions.end())
- {
- const DefaultsData::const_iterator itdef
- = mDefaultsData.find(key);
-
- if (itdef != mDefaultsData.end() && (itdef->second != nullptr))
- {
- const VariableData *const data = itdef->second;
- const VariableData::DataType type = static_cast<
- VariableData::DataType>(data->getType());
- if (type == VariableData::DATA_INT)
- {
- defaultValue = (static_cast<const IntData*>(
- data))->getData();
- }
- else if (type == VariableData::DATA_STRING)
- {
- defaultValue = atoi((static_cast<const StringData*>(
- data))->getData().c_str());
- }
- else if (type == VariableData::DATA_BOOL)
- {
- if ((static_cast<const BoolData*>(data))->getData())
- defaultValue = 1;
- else
- defaultValue = 0;
- }
- else if (type == VariableData::DATA_FLOAT)
- {
- defaultValue = CAST_S32(
- (static_cast<const FloatData*>(data))->getData());
- }
- }
- else
- {
- reportAlways(
- "%s: No integer value in registry for key %s",
- mConfigPath.c_str(),
- key.c_str());
- }
- }
- else
- {
- defaultValue = atoi(iter->second.c_str());
- }
- return defaultValue;
-}
-
-int Configuration::resetIntValue(const std::string &key)
-{
- GETLOG();
- int defaultValue = 0;
- const DefaultsData::const_iterator itdef = mDefaultsData.find(key);
- if (itdef == mDefaultsData.end())
- {
- reportAlways("%s: No integer value in registry for key %s",
- mConfigPath.c_str(),
- key.c_str());
- }
- else
- {
- const VariableData *const data = itdef->second;
- if (data != nullptr &&
- data->getType() == VariableData::DATA_INT)
- {
- defaultValue = (static_cast<const IntData*>(
- data))->getData();
- }
- else
- {
- reportAlways("%s: No integer value in registry for key %s",
- mConfigPath.c_str(),
- key.c_str());
- }
- }
- setValue(key, defaultValue);
- return defaultValue;
-}
-
-std::string Configuration::getStringValue(const std::string &key) const
-{
- GETLOG();
- std::string defaultValue;
- const Options::const_iterator iter = mOptions.find(key);
- if (iter == mOptions.end())
- {
- const DefaultsData::const_iterator
- itdef = mDefaultsData.find(key);
-
- if (itdef != mDefaultsData.end() &&
- (itdef->second != nullptr))
- {
- const VariableData *const data = itdef->second;
- const VariableData::DataType type = static_cast<
- VariableData::DataType>(data->getType());
- if (type == VariableData::DATA_STRING)
- {
- defaultValue = (static_cast<const StringData*>(
- data))->getData();
- }
- else if (type == VariableData::DATA_BOOL)
- {
- if ((static_cast<const BoolData*>(data))->getData())
- defaultValue = "1";
- else
- defaultValue = "0";
- }
- else if (type == VariableData::DATA_INT)
- {
- defaultValue = toString((static_cast<const IntData*>(
- data))->getData());
- }
- else if (type == VariableData::DATA_FLOAT)
- {
- defaultValue = toString((static_cast<const FloatData*>(
- data))->getData());
- }
- }
- else
- {
- reportAlways("%s: No string value in registry for key %s",
- mConfigPath.c_str(),
- key.c_str());
- }
- }
- else
- {
- defaultValue = iter->second;
- }
- return defaultValue;
-}
-
-
-float Configuration::getFloatValue(const std::string &key) const
-{
- GETLOG();
- float defaultValue = 0.0F;
- const Options::const_iterator iter = mOptions.find(key);
- if (iter == mOptions.end())
- {
- const DefaultsData::const_iterator itdef
- = mDefaultsData.find(key);
-
- if (itdef != mDefaultsData.end() &&
- (itdef->second != nullptr))
- {
- const VariableData *const data = itdef->second;
- const VariableData::DataType type = static_cast<
- VariableData::DataType>(data->getType());
- if (type == VariableData::DATA_FLOAT)
- {
- defaultValue = static_cast<float>(
- (static_cast<const FloatData*>(data))->getData());
- }
- else if (type == VariableData::DATA_STRING)
- {
- defaultValue = static_cast<float>(atof((
- static_cast<const StringData*>(
- data))->getData().c_str()));
- }
- else if (type == VariableData::DATA_BOOL)
- {
- if ((static_cast<const BoolData*>(data))->getData())
- defaultValue = 1;
- else
- defaultValue = 0;
- }
- else if (type == VariableData::DATA_INT)
- {
- defaultValue = static_cast<float>((
- static_cast<const IntData*>(
- data))->getData());
- }
- }
- else
- {
- reportAlways("%s: No float value in registry for key %s",
- mConfigPath.c_str(),
- key.c_str());
- }
- }
- else
- {
- defaultValue = static_cast<float>(atof(iter->second.c_str()));
- }
- return defaultValue;
-}
-
-bool Configuration::getBoolValue(const std::string &key) const
-{
- GETLOG();
- bool defaultValue = false;
- const Options::const_iterator iter = mOptions.find(key);
- if (iter == mOptions.end())
- {
- const DefaultsData::const_iterator itdef
- = mDefaultsData.find(key);
-
- if (itdef != mDefaultsData.end() &&
- (itdef->second != nullptr))
- {
- const VariableData *const data = itdef->second;
- const VariableData::DataType type = static_cast<
- VariableData::DataType>(data->getType());
- if (type == VariableData::DATA_BOOL)
- {
- defaultValue = (static_cast<const BoolData*>(
- data))->getData();
- }
- else if (type == VariableData::DATA_INT)
- {
- if ((static_cast<const IntData*>(data))->getData() != 0)
- defaultValue = true;
- else
- defaultValue = false;
- }
- else if (type == VariableData::DATA_STRING)
- {
- if ((static_cast<const StringData*>(
- data))->getData() != "0")
- {
- defaultValue = true;
- }
- else
- {
- defaultValue = false;
- }
- }
- if (type == VariableData::DATA_FLOAT)
- {
- if (CAST_S32((static_cast<const FloatData*>(
- data))->getData()) != 0)
- {
- defaultValue = true;
- }
- else
- {
- defaultValue = false;
- }
- }
- }
- else
- {
- reportAlways(
- "%s: No boolean value in registry for key %s",
- mConfigPath.c_str(),
- key.c_str());
- }
- }
- else
- {
- defaultValue = getBoolFromString(iter->second);
- }
-
- return defaultValue;
-}
-
-bool Configuration::resetBoolValue(const std::string &key)
-{
- GETLOG();
- bool defaultValue = false;
- const DefaultsData::const_iterator itdef = mDefaultsData.find(key);
-
- if (itdef == mDefaultsData.end())
- {
- reportAlways("%s: No boolean value in registry for key %s",
- mConfigPath.c_str(),
- key.c_str());
- }
- else
- {
- const VariableData *const data = itdef->second;
- if (data != nullptr &&
- data->getType() == VariableData::DATA_BOOL)
- {
- defaultValue = (static_cast<const BoolData*>(data))->getData();
- }
- else
- {
- reportAlways("%s: No boolean value in registry for key %s",
- mConfigPath.c_str(),
- key.c_str());
- }
- }
-
- setValue(key, defaultValue);
- return defaultValue;
-}
-
-
-void ConfigurationObject::initFromXML(XmlNodeConstPtrConst parentNode)
-{
- clear();
-
- if (parentNode == nullptr)
- return;
-
- for_each_xml_child_node(node, parentNode)
- {
- if (xmlNameEqual(node, "list"))
- {
- // list option handling
- const std::string name = XML::getProperty(node,
- "name", std::string());
-
- for_each_xml_child_node(subnode, node)
- {
- if (xmlNameEqual(subnode, name.c_str()) &&
- xmlTypeEqual(subnode, XML_ELEMENT_NODE))
- {
- ConfigurationObject *const cobj = new ConfigurationObject;
- cobj->initFromXML(subnode); // recurse
- mContainerOptions[name].push_back(cobj);
- }
- }
- }
- else if (xmlNameEqual(node, "option"))
- {
- // single option handling
- const std::string name = XML::getProperty(node,
- "name", std::string());
- if (!name.empty())
- {
- mOptions[name] = XML::getProperty(node,
- "value", std::string());
- }
- } // otherwise ignore
- }
-}
-
-void Configuration::init(const std::string &filename,
- const UseVirtFs useResManager,
- const SkipError skipError)
-{
- cleanDefaults();
- clear();
- mFilename = filename;
- mUseResManager = useResManager;
-
- if (useResManager == UseVirtFs_true)
- {
- mConfigPath = "virtfs://" + filename;
- mDirectory.clear();
- if (VirtFs::exists(filename) == false)
- {
- logger->log("Warning: No configuration file (%s)",
- filename.c_str());
- return;
- }
- }
- else
- {
- mConfigPath = filename;
- logger->log1("init 1");
- mDirectory = getRealPath(getFileDir(filename));
- if (Files::existsLocal(filename) == false)
- {
- logger->log("Warning: No configuration file (%s)",
- filename.c_str());
- return;
- }
- }
-
- XML::Document doc(filename,
- useResManager,
- skipError);
- logger->log1("init 2");
- if (doc.rootNode() == nullptr)
- {
- logger->log("Couldn't open configuration file: %s", filename.c_str());
- return;
- }
-
- XmlNodeConstPtrConst rootNode = doc.rootNode();
-
- if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "configuration"))
- {
- logger->log("Warning: No configuration file (%s)", filename.c_str());
- return;
- }
-
- initFromXML(rootNode);
-}
-
-void Configuration::reInit()
-{
- XML::Document doc(mFilename, mUseResManager, SkipError_false);
- if (doc.rootNode() == nullptr)
- {
- logger->log("Couldn't open configuration file: %s", mFilename.c_str());
- return;
- }
-
- XmlNodeConstPtrConst rootNode = doc.rootNode();
-
- if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "configuration"))
- {
- logger->log("Warning: No configuration file (%s)", mFilename.c_str());
- return;
- }
-
- initFromXML(rootNode);
-}
-
-void ConfigurationObject::writeToXML(XmlTextWriterPtr writer)
-{
- FOR_EACH (Options::const_iterator, i, mOptions)
- {
-#ifdef DEBUG_CONFIG
- if (mLogKeys)
- {
- if (optionsCount.find(i->first) == optionsCount.end())
- logger->log("unused configuration option: " + i->first);
- }
-#endif // DEBUG_CONFIG
-
- XmlTextWriterStartElement(writer, "option");
- XmlTextWriterWriteAttribute(writer, "name", i->first.c_str());
- XmlTextWriterWriteAttribute(writer, "value", i->second.c_str());
- XmlTextWriterEndElement(writer);
- }
-
- for (std::map<std::string, ConfigurationList>::const_iterator
- it = mContainerOptions.begin(), it_fend = mContainerOptions.end();
- it != it_fend; ++ it)
- {
- const char *const name = it->first.c_str();
-
- XmlTextWriterStartElement(writer, "list");
- XmlTextWriterWriteAttribute(writer, "name", name);
-
- // recurse on all elements
- FOR_EACH (ConfigurationList::const_iterator, elt_it, it->second)
- {
- XmlTextWriterStartElement(writer, name);
- if (*elt_it != nullptr)
- (*elt_it)->writeToXML(writer);
- XmlTextWriterEndElement(writer);
- }
-
- XmlTextWriterEndElement(writer);
- }
-}
-
-void Configuration::writeUpdated()
-{
- if (mUpdated)
- write();
-}
-
-void Configuration::write()
-{
- BLOCK_START("Configuration::write")
- if (mConfigPath.empty())
- {
- BLOCK_END("Configuration::write")
- return;
- }
-
- mUpdated = false;
- // Do not attempt to write to file that cannot be opened for writing
- FILE *const testFile = fopen(mConfigPath.c_str(), "w");
- if (testFile == nullptr)
- {
- reportAlways("Configuration::write() couldn't open %s for writing",
- mConfigPath.c_str());
- BLOCK_END("Configuration::write")
- return;
- }
- fclose(testFile);
-
- XmlTextWriterPtr writer = XmlNewTextWriterFilename(
- mConfigPath.c_str(), 0);
-
- if (writer == nullptr)
- {
- logger->log1("Configuration::write() error while creating writer");
- BLOCK_END("Configuration::write")
- return;
- }
-
- logger->log1("Configuration::write() writing configuration...");
-
- XmlTextWriterSetIndent(writer, 1);
- XmlTextWriterStartDocument(writer, nullptr, nullptr, nullptr);
-// xmlTextWriterStartDocument(writer, nullptr, "utf8", nullptr);
- XmlTextWriterStartRootElement(writer, "configuration");
-
- writeToXML(writer);
-
- XmlTextWriterEndDocument(writer);
- XmlSaveTextWriterFilename(writer,
- mConfigPath.c_str());
- XmlFreeTextWriter(writer);
- BLOCK_END("Configuration::write")
-}
-
-void Configuration::addListener(const std::string &key,
- ConfigListener *const listener)
-{
- mListenerMap[key].push_front(listener);
-}
-
-void Configuration::removeListener(const std::string &key,
- ConfigListener *const listener)
-{
- mListenerMap[key].remove(listener);
-}
-
-#ifdef ENABLE_CHECKS
-void Configuration::checkListeners(ConfigListener *const listener,
- const char *const file,
- const unsigned line)
-{
- FOR_EACH (ListenerMapIterator, it, mListenerMap)
- {
- Listeners listeners = it->second;
- FOR_EACH (ListenerIterator, it2, listeners)
- {
- if (*it2 == listener)
- {
- logger->log("detected not cleaned listener: %p, %s:%u",
- static_cast<void*>(listener), file, line);
- exit(1);
- }
- }
- }
-}
-#endif // ENABLE_CHECKS
-
-void Configuration::removeListeners(ConfigListener *const listener)
-{
- FOR_EACH (ListenerMapIterator, it, mListenerMap)
- (it->second).remove(listener);
-}
-
-void Configuration::removeOldKeys()
-{
- if (mOptions.find(unusedKeys[0]) != mOptions.end() ||
- mOptions.find(unusedKeys[1]) != mOptions.end() ||
- mOptions.find(unusedKeys[2]) != mOptions.end())
- {
- int f = 0;
- while (!unusedKeys[f].empty())
- {
- deleteKey(unusedKeys[f]);
- logger->log("remove unused key: " + unusedKeys[f]);
- f ++;
- }
- for (f = 0; f < 80; f ++)
- {
- const std::string str = toString(f);
- deleteKey("Outfit" + str);
- deleteKey("OutfitUnequip" + str);
- deleteKey("commandShortcutCmd" + str);
- deleteKey("commandShortcutFlags" + str);
- deleteKey("commandShortcutSymbol" + str);
- deleteKey("drop" + str);
- deleteKey("shortcut" + str);
- }
- }
-}
diff --git a/src/configuration.h b/src/configuration.h
deleted file mode 100644
index dae353143..000000000
--- a/src/configuration.h
+++ /dev/null
@@ -1,392 +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 CONFIGURATION_H
-#define CONFIGURATION_H
-
-#include "utils/stringutils.h"
-#ifdef ENABLE_PUGIXML
-#include "utils/xmlwriter.h"
-#else
-#include "utils/xml.h"
-#endif // ENABLE_PUGIXML
-
-#include "defaults.h"
-#include "localconsts.h"
-
-class ConfigListener;
-class ConfigurationObject;
-
-/**
- * Configuration list manager interface; responsible for
- * serializing/deserializing configuration choices in containers.
- *
- * \param T Type of the container elements to serialise
- * \param CONT Type of the container we (de)serialise
- */
-template <class T, class CONT>
-class ConfigurationListManager notfinal
-{
- public:
- ConfigurationListManager()
- { }
-
- A_DELETE_COPY(ConfigurationListManager)
-
- /**
- * Writes a value into a configuration object
- *
- * \param value The value to write out
- * \param obj The configuation object to write to
- * \return obj, or otherwise NULL to indicate that this option should
- * be skipped
- */
- virtual ConfigurationObject *writeConfigItem(const T &value,
- ConfigurationObject
- *const obj) const = 0;
-
- /**
- * Reads a value from a configuration object
- *
- * \param obj The configuration object to read from
- * \param container The container to insert the object to
- */
- virtual CONT readConfigItem(const ConfigurationObject *const obj,
- CONT container)
- const A_WARN_UNUSED = 0;
-
- virtual ~ConfigurationListManager()
- { }
-};
-
-/**
- * Configuration object, mapping values to names and possibly containing
- * lists of further configuration objects
- *
- * \ingroup CORE
- */
-class ConfigurationObject notfinal
-{
- friend class Configuration;
-
- public:
- A_DELETE_COPY(ConfigurationObject)
-
- virtual ~ConfigurationObject();
-
- /**
- * Sets an option using a string value.
- *
- * \param key Option identifier.
- * \param value Value.
- */
- virtual void setValue(const std::string &key,
- const std::string &value);
-
- void deleteKey(const std::string &key);
-
- /**
- * Gets a value as string.
- *
- * \param key Option identifier.
- * \param deflt Default option if not there or error.
- */
- std::string getValue(const std::string &key,
- const std::string &deflt) const A_WARN_UNUSED;
-
- int getValue(const std::string &key,
- const int deflt) const A_WARN_UNUSED;
-
- int getValueInt(const std::string &key,
- const int deflt) const A_WARN_UNUSED;
-
- bool getValueBool(const std::string &key,
- const bool deflt) const A_WARN_UNUSED;
-
- unsigned getValue(const std::string &key,
- const unsigned deflt) const A_WARN_UNUSED;
-
- double getValue(const std::string &key,
- const double deflt) const A_WARN_UNUSED;
-
- /**
- * Re-sets all data in the configuration
- */
- void clear();
-
- /**
- * Serialises a container into a list of configuration options
- *
- * \param name Name of the list the elements should be stored under
- * \param begin Iterator start
- * \param end Iterator end
- * \param manager An object capable of serialising T items
- */
- template <class IT, class T, class CONT>
- void setList(const std::string &name, IT begin, IT end,
- ConfigurationListManager<T, CONT> *manager)
- {
- if (!manager)
- return;
-
- ConfigurationObject *nextobj = new ConfigurationObject;
- deleteList(name);
- ConfigurationList *list = &(mContainerOptions[name]);
-
- for (IT it = begin; it != end; it++)
- {
- ConfigurationObject *const wrobj
- = manager->writeConfigItem(*it, nextobj);
- if (wrobj)
- { // wrote something
- nextobj = new ConfigurationObject;
- list->push_back(wrobj);
- }
- else
- {
- nextobj->clear(); // you never know...
- }
- }
-
- delete nextobj;
- }
-
- /**
- * Serialises a container into a list of configuration options
- *
- * \param name Name of the list the elements should be read from under
- * \param empty Initial (empty) container to write to
- * \param manager An object capable of deserialising items into CONT
- */
- template<class T, class CONT>
- CONT getList(const std::string &name, CONT empty,
- ConfigurationListManager<T, CONT> *manager)
- {
- ConfigurationList *const list = &(mContainerOptions[name]);
- CONT container = empty;
-
- if (!manager)
- return container;
-
- for (ConfigurationList::const_iterator it = list->begin();
- it != list->end();
- ++ it)
- {
- container = manager->readConfigItem(*it, container);
- }
-
- return container;
- }
-
-#ifdef DEBUG_CONFIG
- void enableKeyLogging()
- { mLogKeys = true; }
-
- void setIsMain(bool b)
- { mIsMain = b; }
-#endif // DEBUG_CONFIG
-
- protected:
- ConfigurationObject();
-
- virtual void initFromXML(XmlNodeConstPtrConst parentNode);
- virtual void writeToXML(XmlTextWriterPtr writer);
-
- void deleteList(const std::string &name);
-
- typedef std::map<std::string, std::string> Options;
- Options mOptions;
-
- typedef std::list<ConfigurationObject *> ConfigurationList;
- std::map<std::string, ConfigurationList> mContainerOptions;
-
-#ifdef DEBUG_CONFIG
- bool mLogKeys;
- bool mIsMain;
-#endif // DEBUG_CONFIG
-};
-
-#define valTest(num) mStatsRe##num
-
-/**
- * Configuration handler for reading (and writing).
- *
- * \ingroup CORE
- */
-class Configuration final : public ConfigurationObject
-{
- public:
- Configuration();
-
- A_DELETE_COPY(Configuration)
-
- ~Configuration();
-
- /**
- * Reads config file and parse all options into memory.
- *
- * @param filename path to config file
- * @param useResManager Make use of the resource manager.
- */
- void init(const std::string &filename,
- const UseVirtFs useResManager = UseVirtFs_false,
- const SkipError skipError = SkipError_false);
-
- void reInit();
-
- void unload();
-
- DefaultsData &getDefaultValues()
- { return mDefaultsData; }
-
- /**
- * Writes the current settings back to the config file.
- */
- void write();
-
- /**
- * Adds a listener to the listen list of the specified config option.
- */
- void addListener(const std::string &key,
- ConfigListener *const listener);
-
- /**
- * Removes a listener from the listen list of the specified config
- * option.
- */
- void removeListener(const std::string &key,
- ConfigListener *const listener);
-
- void removeListeners(ConfigListener *const listener);
-
-#ifdef ENABLE_CHECKS
- void checkListeners(ConfigListener *const listener,
- const char *const file,
- const unsigned line);
-#endif // ENABLE_CHECKS
-
- void setValue(const std::string &key,
- const std::string &value) override;
-
- void incValue(const std::string &key);
-
- void setSilent(const std::string &key,
- const std::string &value);
-
- inline void setValue(const std::string &key,
- const char *const value)
- { if (value != nullptr) setValue(key, std::string(value)); }
-
- inline void setSilent(const std::string &key,
- const char *const value)
- { if (value != nullptr) setSilent(key, std::string(value)); }
-
- inline void setValue(const std::string &key,
- const float value)
- { setValue(key, toString(value)); }
-
- inline void setValue(const std::string &key,
- const double value)
- { setValue(key, toString(value)); }
-
- inline void setValue(const std::string &key,
- const int value)
- { setValue(key, toString(value)); }
-
- inline void setValueInt(const std::string &key,
- const int value)
- { setValue(key, toString(value)); }
-
- inline void setValue(const std::string &key,
- const unsigned value)
- { setValue(key, toString(value)); }
-
- inline void setValue(const std::string &key,
- const bool value)
- { setValue(key, value ? "1" : "0"); }
-
- inline void setSilent(const std::string &key,
- const bool value)
- { setSilent(key, value ? "1" : "0"); }
-
- int resetIntValue(const std::string &key);
-
- bool resetBoolValue(const std::string &key);
-
- const std::string &getConfigPath() const noexcept2 A_WARN_UNUSED
- { return mConfigPath; }
-
- /**
- * returns a value corresponding to the given key.
- * The default value returned in based on fallbacks registry.
- * @see defaults.h
- */
- int getIntValue(const std::string &key) const A_WARN_UNUSED_NON_TESTS;
-
- float getFloatValue(const std::string &key) const
- A_WARN_UNUSED_NON_TESTS;
-
- std::string getStringValue(const std::string &key) const
- A_WARN_UNUSED_NON_TESTS;
-
- bool getBoolValue(const std::string &key) const
- A_WARN_UNUSED_NON_TESTS;
-
- std::string getDirectory() const noexcept2 A_WARN_UNUSED
- { return mDirectory; }
-
- void removeOldKeys();
-
- std::string getFileName() const noexcept2 A_WARN_UNUSED
- { return mFilename; }
-
- void writeUpdated();
-
- /**
- * Clean up the default values member.
- */
- void cleanDefaults();
-
- private:
- typedef std::list<ConfigListener*> Listeners;
- typedef Listeners::iterator ListenerIterator;
- typedef std::map<std::string, Listeners> ListenerMap;
- typedef ListenerMap::iterator ListenerMapIterator;
- ListenerMap mListenerMap;
-
- // Location of config file
- std::string mConfigPath;
- /// Defaults of value for a given key
- DefaultsData mDefaultsData;
- std::string mDirectory;
- std::string mFilename;
- UseVirtFs mUseResManager;
- bool mUpdated;
-};
-
-extern Configuration branding;
-extern Configuration config;
-extern Configuration serverConfig;
-extern Configuration paths;
-extern Configuration features;
-
-#endif // CONFIGURATION_H
diff --git a/src/const/emoteshortcut.h b/src/const/emoteshortcut.h
deleted file mode 100644
index cf0ca44ee..000000000
--- a/src/const/emoteshortcut.h
+++ /dev/null
@@ -1,26 +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 CONST_EMOTESHORTCUT_H
-#define CONST_EMOTESHORTCUT_H
-
-static const int SHORTCUT_EMOTES = 48;
-
-#endif // CONST_EMOTESHORTCUT_H
diff --git a/src/const/equipment.h b/src/const/equipment.h
deleted file mode 100644
index 284157e97..000000000
--- a/src/const/equipment.h
+++ /dev/null
@@ -1,30 +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 CONST_EQUIPMENT_H
-#define CONST_EQUIPMENT_H
-
-#include "localconsts.h"
-
-static const int EQUIPMENT_SIZE = 27;
-
-#endif // CONST_EQUIPMENT_H
diff --git a/src/const/gui/chat.h b/src/const/gui/chat.h
deleted file mode 100644
index a39516e13..000000000
--- a/src/const/gui/chat.h
+++ /dev/null
@@ -1,32 +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 CONST_GUI_CHAT_H
-#define CONST_GUI_CHAT_H
-
-#include <string>
-
-const std::string GENERAL_CHANNEL;
-const std::string GM_CHANNEL = "#gm";
-const std::string TRADE_CHANNEL = "#trade";
-
-#endif // CONST_GUI_CHAT_H
diff --git a/src/const/gui/pages.h b/src/const/gui/pages.h
deleted file mode 100644
index 218518bdd..000000000
--- a/src/const/gui/pages.h
+++ /dev/null
@@ -1,30 +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 CONST_GUI_PAGES_H
-#define CONST_GUI_PAGES_H
-
-#include "localconsts.h"
-
-const int SETUP_PAGES = 10;
-
-#endif // CONST_GUI_PAGES_H
diff --git a/src/const/gui/theme.h b/src/const/gui/theme.h
deleted file mode 100644
index 0ec96bf78..000000000
--- a/src/const/gui/theme.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 The Legend of Mazzeroth Development Team
- * Copyright (C) 2009 Aethyra Development Team
- * 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 CONST_GUI_THEME_H
-#define CONST_GUI_THEME_H
-
-#include "localconsts.h"
-
-const int THEME_PALETTES = 5;
-
-#endif // CONST_GUI_THEME_H
diff --git a/src/const/itemshortcut.h b/src/const/itemshortcut.h
deleted file mode 100644
index 002181657..000000000
--- a/src/const/itemshortcut.h
+++ /dev/null
@@ -1,30 +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 CONST_ITEMSHORTCUT_H
-#define CONST_ITEMSHORTCUT_H
-
-#include "localconsts.h"
-
-const unsigned int SHORTCUT_ITEMS = 20;
-const unsigned int SHORTCUT_TABS = 5;
-const size_t SHORTCUT_AUTO_TAB = 4;
-
-#endif // CONST_ITEMSHORTCUT_H
diff --git a/src/const/net/inventory.h b/src/const/net/inventory.h
deleted file mode 100644
index a3729bb4c..000000000
--- a/src/const/net/inventory.h
+++ /dev/null
@@ -1,29 +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 CONST_NET_INVENTORY_H
-#define CONST_NET_INVENTORY_H
-
-static const int INVENTORY_OFFSET = 2;
-static const int STORAGE_OFFSET = 1;
-
-#endif // CONST_NET_INVENTORY_H
diff --git a/src/const/net/maxpacketversion.h b/src/const/net/maxpacketversion.h
deleted file mode 100644
index efc38463a..000000000
--- a/src/const/net/maxpacketversion.h
+++ /dev/null
@@ -1,32 +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 CONST_NET_MAXPACKETVERSION_H
-#define CONST_NET_MAXPACKETVERSION_H
-
-#if defined(__GXX_EXPERIMENTAL_CXX0X__)
-#include <cstdint>
-#else // defined(__GXX_EXPERIMENTAL_CXX0X__)
-#include <stdint.h>
-#endif // defined(__GXX_EXPERIMENTAL_CXX0X__)
-
-static const uint32_t maxPacketVersion = 20170517;
-
-#endif // CONST_NET_MAXPACKETVERSION_H
diff --git a/src/const/net/net.h b/src/const/net/net.h
deleted file mode 100644
index f4797e5c9..000000000
--- a/src/const/net/net.h
+++ /dev/null
@@ -1,36 +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 CONST_NET_NET_H
-#define CONST_NET_NET_H
-
-#if defined(__GXX_EXPERIMENTAL_CXX0X__)
-#include <cstdint>
-#else // defined(__GXX_EXPERIMENTAL_CXX0X__)
-#include <stdint.h>
-#endif // defined(__GXX_EXPERIMENTAL_CXX0X__)
-
-#ifdef TMWA_SUPPORT
-static const uint16_t DEFAULT_PORT = 6901;
-#else // TMWA_SUPPORT
-
-static const uint16_t DEFAULT_PORT = 6900;
-#endif // TMWA_SUPPORT
-#endif // CONST_NET_NET_H
diff --git a/src/const/net/nostat.h b/src/const/net/nostat.h
deleted file mode 100644
index 721db244c..000000000
--- a/src/const/net/nostat.h
+++ /dev/null
@@ -1,28 +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 CONST_NET_NOSTAT_H
-#define CONST_NET_NOSTAT_H
-
-#include <climits>
-
-static const int NoStat = INT_MAX;
-
-#endif // CONST_NET_NOSTAT_H
diff --git a/src/const/net/skill.h b/src/const/net/skill.h
deleted file mode 100644
index da1f685d6..000000000
--- a/src/const/net/skill.h
+++ /dev/null
@@ -1,57 +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 CONST_NET_SKILL_H
-#define CONST_NET_SKILL_H
-
-#include "localconsts.h"
-
-/** job dependend identifiers (?) */
-static const unsigned int SKILL_BASIC = 0x0001;
-static const unsigned int SKILL_WARP = 0x001b;
-static const unsigned int SKILL_STEAL = 0x0032;
-static const unsigned int SKILL_ENVENOM = 0x0034;
-
-/** basic skills identifiers */
-static const unsigned int BSKILL_TRADE = 0x0000;
-static const unsigned int BSKILL_EMOTE = 0x0001;
-static const unsigned int BSKILL_SIT = 0x0002;
-static const unsigned int BSKILL_CREATECHAT = 0x0003;
-static const unsigned int BSKILL_JOINPARTY = 0x0004;
-static const unsigned int BSKILL_SHOUT = 0x0005;
-
-/** reasons why action failed */
-static const unsigned int RFAIL_SKILLDEP = 0x00;
-static const unsigned int RFAIL_INSUFSP = 0x01;
-static const unsigned int RFAIL_INSUFHP = 0x02;
-static const unsigned int RFAIL_NOMEMO = 0x03;
-static const unsigned int RFAIL_SKILLDELAY = 0x04;
-static const unsigned int RFAIL_ZENY = 0x05;
-static const unsigned int RFAIL_WEAPON = 0x06;
-static const unsigned int RFAIL_REDGEM = 0x07;
-static const unsigned int RFAIL_BLUEGEM = 0x08;
-static const unsigned int RFAIL_OVERWEIGHT = 0x09;
-
-/** should always be zero if failed */
-static const unsigned int SKILL_FAILED = 0x00;
-
-#endif // CONST_NET_SKILL_H
diff --git a/src/const/render/graphics.h b/src/const/render/graphics.h
deleted file mode 100644
index 29e4864fe..000000000
--- a/src/const/render/graphics.h
+++ /dev/null
@@ -1,31 +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 CONST_RENDER_GRAPHICS_H
-#define CONST_RENDER_GRAPHICS_H
-
-#include "localconsts.h"
-
-static const int defaultScreenWidth = 800;
-static const int defaultScreenHeight = 600;
-
-#endif // CONST_RENDER_GRAPHICS_H
diff --git a/src/const/resources/currency.h b/src/const/resources/currency.h
deleted file mode 100644
index e5f6cfccf..000000000
--- a/src/const/resources/currency.h
+++ /dev/null
@@ -1,28 +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 CONST_RESOURCES_SKILL_H
-#define CONST_RESOURCES_SKILL_H
-
-#include <string>
-
-const std::string DEFAULT_CURRENCY = "default";
-
-#endif // CONST_RESOURCES_SKILL_H
diff --git a/src/const/resources/item/cards.h b/src/const/resources/item/cards.h
deleted file mode 100644
index bcd999433..000000000
--- a/src/const/resources/item/cards.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 CONST_RESOURCES_ITEM_CARDS_H
-#define CONST_RESOURCES_ITEM_CARDS_H
-
-#define maxCards 4
-#define maxMailCards 4
-
-#define CARD0_FORGE 0x00FF
-#define CARD0_CREATE 0x00FE
-#define CARD0_PET static_cast<uint16_t>(0xFF00)
-
-#endif // CONST_RESOURCES_ITEM_CARDS_H
diff --git a/src/const/resources/item/itemoptions.h b/src/const/resources/item/itemoptions.h
deleted file mode 100644
index 3c028ea64..000000000
--- a/src/const/resources/item/itemoptions.h
+++ /dev/null
@@ -1,26 +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 CONST_RESOURCES_ITEM_ITEMOPTIONS_H
-#define CONST_RESOURCES_ITEM_ITEMOPTIONS_H
-
-#define maxItemOptions 5
-
-#endif // CONST_RESOURCES_ITEM_ITEMOPTIONS_H
diff --git a/src/const/resources/map/map.h b/src/const/resources/map/map.h
deleted file mode 100644
index 25727acfd..000000000
--- a/src/const/resources/map/map.h
+++ /dev/null
@@ -1,28 +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 CONST_RESOURCES_MAP_MAP_H
-#define CONST_RESOURCES_MAP_MAP_H
-
-static const int mapTileSize = 32;
-
-#endif // CONST_RESOURCES_MAP_MAP_H
diff --git a/src/const/resources/skill.h b/src/const/resources/skill.h
deleted file mode 100644
index 68ec3a56c..000000000
--- a/src/const/resources/skill.h
+++ /dev/null
@@ -1,27 +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 CONST_RESOURCES_SKILL_H
-#define CONST_RESOURCES_SKILL_H
-
-const int SKILL_MIN_ID = 200000;
-const unsigned int SKILL_VAR_MIN_ID = 1000000;
-
-#endif // CONST_RESOURCES_SKILL_H
diff --git a/src/const/resources/spriteaction.h b/src/const/resources/spriteaction.h
deleted file mode 100644
index da865d3df..000000000
--- a/src/const/resources/spriteaction.h
+++ /dev/null
@@ -1,74 +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 CONST_RESOURCES_SPRITEACTION_H
-#define CONST_RESOURCES_SPRITEACTION_H
-
-#include <string>
-
-/*
- * Remember those are the main action.
- * Action subtypes, e.g.: "attack_bow" are to be passed by items.xml after
- * an ACTION_ATTACK call.
- * Which special to be use to to be passed with the USE_SPECIAL call.
- * Running, walking, ... is a sub-type of moving.
- * ...
- * Please don't add hard-coded subtypes here!
- */
-namespace SpriteAction
-{
- static const std::string DEFAULT("stand");
- static const std::string STAND("stand");
- static const std::string SIT("sit");
- static const std::string SITTOP("sittop");
- static const std::string DEAD("dead");
- static const std::string MOVE("walk");
- static const std::string ATTACK("attack");
- static const std::string SPAWN("spawn");
- static const std::string CAST("cast");
-
- static const std::string FLY("fly");
- static const std::string SWIM("swim");
- static const std::string RIDE("ride");
- static const std::string STANDSKY("standsky");
- static const std::string STANDWATER("standwater");
- static const std::string STANDRIDE("standride");
- static const std::string SITSKY("sitsky");
- static const std::string SITWATER("sitwater");
- static const std::string SITRIDE("sitride");
- static const std::string ATTACKSKY("attacksky");
- static const std::string ATTACKWATER("attackwater");
- static const std::string ATTACKRIDE("attackride");
- static const std::string CASTSKY("castsky");
- static const std::string CASTWATER("castwater");
- static const std::string CASTRIDE("castride");
- static const std::string SPAWNSKY("spawnsky");
- static const std::string SPAWNWATER("spawnwater");
- static const std::string SPAWNRIDE("spawnride");
- static const std::string DEADSKY("deadsky");
- static const std::string DEADWATER("deadwater");
- static const std::string DEADRIDE("deadride");
-
- static const std::string INVALID;
-} // namespace SpriteAction
-
-#endif // CONST_RESOURCES_SPRITEACTION_H
diff --git a/src/const/sound.h b/src/const/sound.h
deleted file mode 100644
index ccb96b523..000000000
--- a/src/const/sound.h
+++ /dev/null
@@ -1,37 +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 CONST_SOUND_H
-#define CONST_SOUND_H
-
-#include <string>
-
-static const std::string SOUND_INFO = "soundinfo";
-static const std::string SOUND_ERROR = "sounderror";
-static const std::string SOUND_REQUEST = "soundrequest";
-static const std::string SOUND_TRADE = "soundtrade";
-static const std::string SOUND_WHISPER = "soundwhisper";
-static const std::string SOUND_HIGHLIGHT = "soundhighlight";
-static const std::string SOUND_GLOBAL = "soundglobal";
-static const std::string SOUND_GUILD = "soundguild";
-static const std::string SOUND_SHOW_WINDOW = "soundshowwindow";
-static const std::string SOUND_HIDE_WINDOW = "soundhidewindow";
-
-#endif // CONST_SOUND_H
diff --git a/src/const/spells.h b/src/const/spells.h
deleted file mode 100644
index 96eea8f92..000000000
--- a/src/const/spells.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009-2010 Andrei Karas
- * 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 CONST_SPELLS_H
-#define CONST_SPELLS_H
-
-#include "localconsts.h"
-
-const int SPELL_MIN_ID = 100000;
-const unsigned int SPELL_SHORTCUT_ITEMS = 49;
-const unsigned int SPELL_SHORTCUT_TABS = 5;
-const unsigned int SPELLS_SIZE = SPELL_SHORTCUT_ITEMS * SPELL_SHORTCUT_TABS;
-
-#endif // CONST_SPELLS_H
diff --git a/src/const/utils/timer.h b/src/const/utils/timer.h
deleted file mode 100644
index a4873ffeb..000000000
--- a/src/const/utils/timer.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 CONST_UTILS_TIMER_H
-#define CONST_UTILS_TIMER_H
-
-#include "localconsts.h"
-
-/**
- * Set the milliseconds value of a tick time.
- */
-static const int MILLISECONDS_IN_A_TICK = 10;
-
-#endif // CONST_UTILS_TIMER_H
diff --git a/src/const/utils/utf8.h b/src/const/utils/utf8.h
deleted file mode 100644
index d7042f958..000000000
--- a/src/const/utils/utf8.h
+++ /dev/null
@@ -1,28 +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 CONST_UTILS_UTF8_H
-#define CONST_UTILS_UTF8_H
-
-#include "localconsts.h"
-
-static const size_t UTF8_MAX_SIZE = 10;
-
-#endif // CONST_UTILS_UTF8_H
diff --git a/src/debug.h b/src/debug.h
deleted file mode 100644
index 307766806..000000000
--- a/src/debug.h
+++ /dev/null
@@ -1,64 +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 "localconsts.h"
-
-// #define DEBUG_JOYSTICK 1
-
-#ifdef ENABLE_MEM_DEBUG
-
-// #define _DEBUG_NEW_EMULATE_MALLOC 1
-#include "debug/nvwa/debug_new.h"
-
-#endif // ENABLE_MEM_DEBUG
-
-#ifdef DEBUG_SDL_SURFACES
-
-#define MIMG_LoadPNG_RW(src) FakeIMG_LoadPNG_RW(src, __FILE__, __LINE__)
-#define MIMG_LoadJPG_RW(src) FakeIMG_LoadJPG_RW(src, __FILE__, __LINE__)
-#define MSDL_FreeSurface(s) FakeSDL_FreeSurface(s, __FILE__, __LINE__)
-#define MSDL_CreateRGBSurface(flags, w, h, d, r, g, b, a) \
- FakeSDL_CreateRGBSurface(flags, w, h, d, r, g, b, a, __FILE__, __LINE__)
-#define MSDL_ConvertSurface(src, fmt, flags) \
- FakeSDL_ConvertSurface(src, fmt, flags, __FILE__, __LINE__)
-#define MTTF_RenderUTF8_Blended(font, text, fg) \
- FakeTTF_RenderUTF8_Blended(font, text, fg, __FILE__, __LINE__)
-#define MIMG_Load(file) FakeIMG_Load(file, __FILE__, __LINE__)
-#define MSDL_DisplayFormatAlpha(surface) \
- FakeSDL_DisplayFormatAlpha(surface, __FILE__, __LINE__)
-#define MSDL_DisplayFormat(surface) \
- FakeSDL_DisplayFormat(surface, __FILE__, __LINE__)
-
-#else // ENABLE_SDL_DEBUG
-
-#define MIMG_LoadPNG_RW(src) IMG_LoadPNG_RW(src)
-#define MIMG_LoadJPG_RW(src) IMG_LoadJPG_RW(src)
-#define MSDL_FreeSurface(surface) SDL_FreeSurface(surface)
-#define MSDL_CreateRGBSurface(flags, w, h, d, r, g, b, a) \
- SDL_CreateRGBSurface(flags, w, h, d, r, g, b, a)
-#define MSDL_ConvertSurface(src, fmt, flags) \
- SDL_ConvertSurface(src, fmt, flags)
-#define MTTF_RenderUTF8_Blended(font, text, fg) \
- TTF_RenderUTF8_Blended(font, text, fg)
-#define MIMG_Load(file) IMG_Load(file)
-#define MSDL_DisplayFormatAlpha(surface) SDL_DisplayFormatAlpha(surface)
-#define MSDL_DisplayFormat(surface) SDL_DisplayFormat(surface)
-
-#endif // ENABLE_SDL_DEBUG
diff --git a/src/debug/mse/LICENSE_1_0.txt b/src/debug/mse/LICENSE_1_0.txt
deleted file mode 100644
index 664c26753..000000000
--- a/src/debug/mse/LICENSE_1_0.txt
+++ /dev/null
@@ -1,23 +0,0 @@
-Boost Software License - Version 1.0 - August 17th, 2003
-
-Permission is hereby granted, free of charge, to any person or organization
-obtaining a copy of the software and accompanying documentation covered by
-this license (the "Software") to use, reproduce, display, distribute,
-execute, and transmit the Software, and to prepare derivative works of the
-Software, and to permit third-parties to whom the Software is furnished to
-do so, all subject to the following:
-
-The copyright notices in the Software and this entire statement, including
-the above license grant, this restriction and the following disclaimer,
-must be included in all copies of the Software, in whole or in part, and
-all derivative works of the Software, unless such copies or derivative
-works are solely in the form of machine-executable object code generated by
-a source language processor.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
-SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
-FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
-ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-DEALINGS IN THE SOFTWARE.
diff --git a/src/debug/mse/msemsevector.h b/src/debug/mse/msemsevector.h
deleted file mode 100644
index e0046ca5c..000000000
--- a/src/debug/mse/msemsevector.h
+++ /dev/null
@@ -1,2432 +0,0 @@
-
-// Copyright (c) 2015 Noah Lopez
-// Use, modification, and distribution is subject to the Boost Software
-// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-
-#ifndef MSEMSEVECTOR_H
-#define MSEMSEVECTOR_H
-
-/*compiler specific defines*/
-#ifdef _MSC_VER
-#if (1700 > _MSC_VER)
-#define MSVC2010_COMPATIBLE 1
-#endif /*(1700 > _MSC_VER)*/
-#if (1900 > _MSC_VER)
-#define MSVC2013_COMPATIBLE 1
-#endif /*(1900 > _MSC_VER)*/
-#else /*_MSC_VER*/
-#if (defined(__GNUC__) || defined(__GNUG__))
-#define GPP_COMPATIBLE 1
-#if ((5 > __GNUC__) && (!defined(__clang__)))
-#define GPP4P8_COMPATIBLE 1
-#endif /*((5 > __GNUC__) && (!defined(__clang__)))*/
-#endif
-#endif /*_MSC_VER*/
-
-//define MSE_MSEVECTOR_USE_MSE_PRIMITIVES 1
-#ifdef MSE_MSEVECTOR_USE_MSE_PRIMITIVES
-#include "debug/mse/mseprimitives.h"
-#endif // MSE_MSEVECTOR_USE_MSE_PRIMITIVES
-
-#include <vector>
-#include <assert.h>
-#include <memory>
-#include <unordered_map>
-#include <functional>
-#include <climits> // ULONG_MAX
-#include <stdexcept>
-
-#ifdef MSE_CUSTOM_THROW_DEFINITION
-#include <iostream>
-#define MSE_THROW(x) MSE_CUSTOM_THROW_DEFINITION(x)
-#else // MSE_CUSTOM_THROW_DEFINITION
-#define MSE_THROW(x) throw(x)
-#endif // MSE_CUSTOM_THROW_DEFINITION
-
-namespace mse {
-
-#ifdef MSE_MSEVECTOR_USE_MSE_PRIMITIVES
- typedef mse::CSize_t msev_size_t;
- typedef mse::CInt msev_int;
- typedef bool msev_bool; // no added safety benefit to using mse::CBool in this case
- #define msev_as_a_size_t as_a_size_t
-#else // MSE_MSEVECTOR_USE_MSE_PRIMITIVES
-#if SIZE_MAX <= ULONG_MAX
-#define MSE_MSEVECTOR_BASE_INTEGER_TYPE long int
-#else // SIZE_MAX <= ULONG_MAX
-#define MSE_MSEVECTOR_BASE_INTEGER_TYPE long long int
-#endif // SIZE_MAX <= ULONG_MAX
-
- typedef size_t msev_size_t;
- typedef MSE_MSEVECTOR_BASE_INTEGER_TYPE msev_int;
- typedef bool msev_bool;
- typedef size_t msev_as_a_size_t;
-#endif // MSE_MSEVECTOR_USE_MSE_PRIMITIVES
-
-
- class msevector_range_error : public std::range_error { public:
- using std::range_error::range_error;
- };
- class msevector_null_dereference_error : public std::logic_error { public:
- using std::logic_error::logic_error;
- };
-
- /* msev_pointer behaves similar to native pointers. It's a bit safer in that it initializes to
- nullptr by default and checks for attempted dereference of null pointers. */
- template<typename _Ty>
- class msev_pointer {
- public:
- msev_pointer() : m_ptr(nullptr) {}
- msev_pointer(_Ty* ptr) : m_ptr(ptr) {}
- msev_pointer(const msev_pointer<_Ty>& src) : m_ptr(src.m_ptr) {}
-
- _Ty& operator*() const {
-#ifndef MSE_DISABLE_MSEAR_POINTER_CHECKS
- if (nullptr == m_ptr) { MSE_THROW(msevector_null_dereference_error("attempt to dereference null pointer - mse::msev_pointer")); }
-#endif /*MSE_DISABLE_MSEAR_POINTER_CHECKS*/
- return (*m_ptr);
- }
- _Ty* operator->() const {
-#ifndef MSE_DISABLE_MSEAR_POINTER_CHECKS
- if (nullptr == m_ptr) { MSE_THROW(msevector_null_dereference_error("attempt to dereference null pointer - mse::msev_pointer")); }
-#endif /*MSE_DISABLE_MSEAR_POINTER_CHECKS*/
- return m_ptr;
- }
- msev_pointer<_Ty>& operator=(_Ty* ptr) {
- m_ptr = ptr;
- return (*this);
- }
- bool operator==(const msev_pointer _Right_cref) const { return (_Right_cref.m_ptr == m_ptr); }
- bool operator!=(const msev_pointer _Right_cref) const { return (!((*this) == _Right_cref)); }
- bool operator==(const _Ty* _Right_cref) const { return (_Right_cref == m_ptr); }
- bool operator!=(const _Ty* _Right_cref) const { return (!((*this) == _Right_cref)); }
-
- bool operator!() const { return (!m_ptr); }
- operator bool() const { return (m_ptr != nullptr); }
-
- operator _Ty*() const { return m_ptr; }
-
- _Ty* m_ptr;
- };
-
-#ifndef _XSTD
-#define _XSTD ::std::
-#endif /*_XSTD*/
-
- template<class _Ty, _Ty _Val>
- struct integral_constant
- { // convenient template for integral constant types
- static const _Ty value = _Val;
-
- typedef _Ty value_type;
- typedef integral_constant<_Ty, _Val> type;
-
- operator value_type() const
- { // return stored value
- return (value);
- }
- };
-
- template<class _Iter>
- struct _mse_Is_iterator
- : public integral_constant<bool, !std::is_integral<_Iter>::value>
- { // tests for reasonable iterator candidate
- };
- template<typename _InIter>
- using _mse_RequireInputIter = typename std::enable_if<
- std::is_convertible<typename std::iterator_traits<_InIter>::iterator_category, std::input_iterator_tag>::value
- //_mse_Is_iterator<_InIter>::value
- >::type;
-
- /* Note that, at the moment, msevector inherits publicly from std::vector. This is not intended to be a permanent
- characteristic of msevector and any reference to, or interpretation of, an msevector as an std::vector is (and has
- always been) depricated. msevector endeavors to support the subset of the std::vector interface that is compatible
- with the security/safety goals of msevector. (The remaining part of the std::vector interface may be supported, as a
- user option, for compatibility.)
- In particular, keep in mind that std::vector does not have a virtual destructor, so deallocating an msevector as an
- std::vector would result in memory leaks. */
- template<class _Ty, class _A = std::allocator<_Ty> >
- class msevector : public std::vector<_Ty, _A> {
- public:
- typedef std::vector<_Ty, _A> base_class;
- typedef msevector<_Ty, _A> _Myt;
-
- typedef typename base_class::value_type value_type;
- //typedef typename base_class::size_type size_type;
- typedef msev_size_t size_type;
- //typedef typename base_class::difference_type difference_type;
- typedef msev_int difference_type;
- typedef typename base_class::pointer pointer;
- typedef typename base_class::const_pointer const_pointer;
- typedef typename base_class::reference reference;
- typedef typename base_class::const_reference const_reference;
-
- explicit msevector(const _A& _Al = _A())
- : base_class(_Al), m_mmitset(*this) {
- /*m_debug_size = size();*/
- }
- explicit msevector(size_type _N)
- : base_class(msev_as_a_size_t(_N)), m_mmitset(*this) {
- /*m_debug_size = size();*/
- }
- explicit msevector(size_type _N, const _Ty& _V, const _A& _Al = _A())
- : base_class(msev_as_a_size_t(_N), _V, _Al), m_mmitset(*this) {
- /*m_debug_size = size();*/
- }
- msevector(base_class&& _X) : base_class(std::move(_X)), m_mmitset(*this) { /*m_debug_size = size();*/ }
- msevector(const base_class& _X) : base_class(_X), m_mmitset(*this) { /*m_debug_size = size();*/ }
- msevector(_Myt&& _X) : base_class(std::move(_X)), m_mmitset(*this) { /*m_debug_size = size();*/ }
- msevector(const _Myt& _X) : base_class(_X), m_mmitset(*this) { /*m_debug_size = size();*/ }
- typedef typename base_class::const_iterator _It;
- /* Note that safety cannot be guaranteed when using these constructors that take unsafe typename base_class::iterator and/or pointer parameters. */
- msevector(_It _F, _It _L, const _A& _Al = _A()) : base_class(_F, _L, _Al), m_mmitset(*this) { /*m_debug_size = size();*/ }
- msevector(const _Ty* _F, const _Ty* _L, const _A& _Al = _A()) : base_class(_F, _L, _Al), m_mmitset(*this) { /*m_debug_size = size();*/ }
- template<class _Iter
- //, class = typename std::enable_if<_mse_Is_iterator<_Iter>::value, void>::type
- , class = _mse_RequireInputIter<_Iter> >
- msevector(_Iter _First, _Iter _Last) : base_class(_First, _Last), m_mmitset(*this) { /*m_debug_size = size();*/ }
- template<class _Iter
- //, class = typename std::enable_if<_mse_Is_iterator<_Iter>::value, void>::type
- , class = _mse_RequireInputIter<_Iter> >
- //msevector(_Iter _First, _Iter _Last, const typename base_class::_Alloc& _Al) : base_class(_First, _Last, _Al), m_mmitset(*this) { /*m_debug_size = size();*/ }
- msevector(_Iter _First, _Iter _Last, const _A& _Al) : base_class(_First, _Last, _Al), m_mmitset(*this) { /*m_debug_size = size();*/ }
- _Myt& operator=(const base_class& _X) {
- base_class::operator =(_X);
- /*m_debug_size = size();*/
- m_mmitset.reset();
- return (*this);
- }
- _Myt& operator=(_Myt&& _X) {
- operator=(std::move(static_cast<base_class&>(_X)));
- m_mmitset.reset();
- return (*this);
- }
- _Myt& operator=(const _Myt& _X) {
- operator=(static_cast<const base_class&>(_X));
- m_mmitset.reset();
- return (*this);
- }
- void reserve(size_type _Count)
- { // determine new minimum length of allocated storage
- auto original_capacity = msev_size_t((*this).capacity());
-
- base_class::reserve(msev_as_a_size_t(_Count));
-
- auto new_capacity = msev_size_t((*this).capacity());
- bool realloc_occured = (new_capacity != original_capacity);
- if (realloc_occured) {
- m_mmitset.sync_iterators_to_index();
- }
- }
- void shrink_to_fit() { // reduce capacity
- auto original_capacity = msev_size_t((*this).capacity());
-
- base_class::shrink_to_fit();
-
- auto new_capacity = msev_size_t((*this).capacity());
- bool realloc_occured = (new_capacity != original_capacity);
- if (realloc_occured) {
- m_mmitset.sync_iterators_to_index();
- }
- }
- void resize(size_type _N, const _Ty& _X = _Ty()) {
- auto original_size = msev_size_t((*this).size());
- auto original_capacity = msev_size_t((*this).capacity());
- bool shrinking = (_N < original_size);
-
- base_class::resize(msev_as_a_size_t(_N), _X);
- /*m_debug_size = size();*/
-
- if (shrinking) {
- m_mmitset.invalidate_inclusive_range(_N, msev_size_t(original_size - 1));
- }
- m_mmitset.shift_inclusive_range(original_size, original_size, msev_size_t(_N) - original_size); /*shift the end markers*/
- auto new_capacity = msev_size_t((*this).capacity());
- bool realloc_occured = (new_capacity != original_capacity);
- if (realloc_occured) {
- m_mmitset.sync_iterators_to_index();
- }
- }
- typename base_class::const_reference operator[](size_type _P) const {
- return (*this).at(msev_as_a_size_t(_P));
- }
- typename base_class::reference operator[](size_type _P) {
- return (*this).at(msev_as_a_size_t(_P));
- }
- typename base_class::reference front() { // return first element of mutable sequence
- if (0 == (*this).size()) { MSE_THROW(msevector_range_error("front() on empty - typename base_class::reference front() - msevector")); }
- return base_class::front();
- }
- typename base_class::const_reference front() const { // return first element of nonmutable sequence
- if (0 == (*this).size()) { MSE_THROW(msevector_range_error("front() on empty - typename base_class::const_reference front() - msevector")); }
- return base_class::front();
- }
- typename base_class::reference back() { // return last element of mutable sequence
- if (0 == (*this).size()) { MSE_THROW(msevector_range_error("back() on empty - typename base_class::reference back() - msevector")); }
- return base_class::back();
- }
- typename base_class::const_reference back() const { // return last element of nonmutable sequence
- if (0 == (*this).size()) { MSE_THROW(msevector_range_error("back() on empty - typename base_class::const_reference back() - msevector")); }
- return base_class::back();
- }
- void push_back(_Ty&& _X) {
- if (m_mmitset.is_empty()) {
- base_class::push_back(std::move(_X));
- }
- else {
- auto original_size = msev_size_t((*this).size());
- auto original_capacity = msev_size_t((*this).capacity());
-
- base_class::push_back(std::move(_X));
- /*m_debug_size = size();*/
-
- assert((original_size + 1) == msev_size_t((*this).size()));
- m_mmitset.shift_inclusive_range(original_size, original_size, 1); /*shift the end markers*/
- auto new_capacity = msev_size_t((*this).capacity());
- bool realloc_occured = (new_capacity != original_capacity);
- if (realloc_occured) {
- m_mmitset.sync_iterators_to_index();
- }
- }
- }
- void push_back(const _Ty& _X) {
- if (m_mmitset.is_empty()) {
- base_class::push_back(_X);
- }
- else {
- auto original_size = msev_size_t((*this).size());
- auto original_capacity = msev_size_t((*this).capacity());
-
- base_class::push_back(_X);
- /*m_debug_size = size();*/
-
- assert((original_size + 1) == msev_size_t((*this).size()));
- m_mmitset.shift_inclusive_range(original_size, original_size, 1); /*shift the end markers*/
- auto new_capacity = msev_size_t((*this).capacity());
- bool realloc_occured = (new_capacity != original_capacity);
- if (realloc_occured) {
- m_mmitset.sync_iterators_to_index();
- }
- }
- }
- void pop_back() {
- if (m_mmitset.is_empty()) {
- base_class::pop_back();
- }
- else {
- auto original_size = msev_size_t((*this).size());
- auto original_capacity = msev_size_t((*this).capacity());
-
- if (0 == original_size) { MSE_THROW(msevector_range_error("pop_back() on empty - void pop_back() - msevector")); }
- base_class::pop_back();
- /*m_debug_size = size();*/
-
- assert((original_size - 1) == msev_size_t((*this).size()));
- m_mmitset.invalidate_inclusive_range(msev_size_t(original_size - 1), msev_size_t(original_size - 1));
- m_mmitset.shift_inclusive_range(original_size, original_size, -1); /*shift the end markers*/
- auto new_capacity = msev_size_t((*this).capacity());
- bool realloc_occured = (new_capacity != original_capacity);
- if (realloc_occured) {
- m_mmitset.sync_iterators_to_index();
- }
- }
- }
- void assign(_It _F, _It _L) {
- base_class::assign(_F, _L);
- /*m_debug_size = size();*/
- m_mmitset.reset();
- }
- template<class _Iter>
- void assign(_Iter _First, _Iter _Last) { // assign [_First, _Last)
- base_class::assign(_First, _Last);
- /*m_debug_size = size();*/
- m_mmitset.reset();
- }
- void assign(size_type _N, const _Ty& _X = _Ty()) {
- base_class::assign(msev_as_a_size_t(_N), _X);
- /*m_debug_size = size();*/
- m_mmitset.reset();
- }
- typename base_class::iterator insert(typename base_class::const_iterator _P, _Ty&& _X) {
- return (emplace(_P, std::move(_X)));
- }
- typename base_class::iterator insert(typename base_class::const_iterator _P, const _Ty& _X = _Ty()) {
- if (m_mmitset.is_empty()) {
- typename base_class::iterator retval = base_class::insert(_P, _X);
- /*m_debug_size = size();*/
- return retval;
- }
- else {
- msev_int di = std::distance(base_class::cbegin(), _P);
- msev_size_t d = msev_size_t(di);
- if ((0 > di) || (msev_size_t((*this).size()) < di)) { MSE_THROW(msevector_range_error("index out of range - typename base_class::iterator insert() - msevector")); }
-
- auto original_size = msev_size_t((*this).size());
- auto original_capacity = msev_size_t((*this).capacity());
-
- typename base_class::iterator retval = base_class::insert(_P, _X);
- /*m_debug_size = size();*/
-
- assert((original_size + 1) == msev_size_t((*this).size()));
- assert(di == std::distance(base_class::begin(), retval));
- m_mmitset.shift_inclusive_range(d, original_size, 1);
- auto new_capacity = msev_size_t((*this).capacity());
- bool realloc_occured = (new_capacity != original_capacity);
- if (realloc_occured) {
- m_mmitset.sync_iterators_to_index();
- }
- return retval;
- }
- }
-
-#if !(defined(GPP4P8_COMPATIBLE))
- typename base_class::iterator insert(typename base_class::const_iterator _P, size_type _M, const _Ty& _X) {
- if (m_mmitset.is_empty()) {
- typename base_class::iterator retval = base_class::insert(_P, msev_as_a_size_t(_M), _X);
- /*m_debug_size = size();*/
- return retval;
- }
- else {
- msev_int di = std::distance(base_class::cbegin(), _P);
- msev_size_t d = msev_size_t(di);
- if ((0 > di) || ((*this).size() < msev_size_t(di))) { MSE_THROW(msevector_range_error("index out of range - typename base_class::iterator insert() - msevector")); }
-
- auto original_size = msev_size_t((*this).size());
- auto original_capacity = msev_size_t((*this).capacity());
-
- typename base_class::iterator retval = base_class::insert(_P, msev_as_a_size_t(_M), _X);
- /*m_debug_size = size();*/
-
- assert((original_size + _M) == msev_size_t((*this).size()));
- assert(di == std::distance(base_class::begin(), retval));
- m_mmitset.shift_inclusive_range(d, original_size, msev_int(_M));
- auto new_capacity = msev_size_t((*this).capacity());
- bool realloc_occured = (new_capacity != original_capacity);
- if (realloc_occured) {
- m_mmitset.sync_iterators_to_index();
- }
- return retval;
- }
- }
- template<class _Iter
- //>typename std::enable_if<_mse_Is_iterator<_Iter>::value, typename base_class::iterator>::type
- , class = _mse_RequireInputIter<_Iter> >
- typename base_class::iterator insert(typename base_class::const_iterator _Where, _Iter _First, _Iter _Last) { // insert [_First, _Last) at _Where
- if (m_mmitset.is_empty()) {
- auto retval = base_class::insert(_Where, _First, _Last);
- /*m_debug_size = size();*/
- return retval;
- }
- else {
- msev_int di = std::distance(base_class::cbegin(), _Where);
- msev_size_t d = msev_size_t(di);
- if ((0 > di) || ((*this).size() < msev_size_t(di))) { MSE_THROW(msevector_range_error("index out of range - typename base_class::iterator insert() - msevector")); }
-
- auto _M = msev_int(std::distance(_First, _Last));
- auto original_size = msev_size_t((*this).size());
- auto original_capacity = msev_size_t((*this).capacity());
-
- //if (0 > _M) { MSE_THROW(msevector_range_error("invalid argument - typename base_class::iterator insert() - msevector")); }
- auto retval = base_class::insert(_Where, _First, _Last);
- /*m_debug_size = size();*/
-
- assert((original_size + _M) == msev_size_t((*this).size()));
- assert(di == std::distance(base_class::begin(), retval));
- m_mmitset.shift_inclusive_range(d, original_size, _M);
- auto new_capacity = msev_size_t((*this).capacity());
- bool realloc_occured = (new_capacity != original_capacity);
- if (realloc_occured) {
- m_mmitset.sync_iterators_to_index();
- }
- return retval;
- }
- }
-
-#else /*!(defined(GPP4P8_COMPATIBLE))*/
-
- /*typename base_class::iterator*/
- void
- /* g++4.8 seems to be using the c++98 version of this insert function instead of the c++11 version. */
- insert(typename base_class::/*const_*/iterator _P, size_t _M, const _Ty& _X) {
- msev_int di = std::distance(base_class::/*c*/begin(), _P);
- msev_size_t d = msev_size_t(di);
- if ((0 > di) || (msev_size_t((*this).size()) < di)) { MSE_THROW(msevector_range_error("index out of range - typename base_class::iterator insert() - msevector")); }
-
- auto original_size = msev_size_t((*this).size());
- auto original_capacity = msev_size_t((*this).capacity());
-
- /*typename base_class::iterator retval =*/
- base_class::insert(_P, _M, _X);
- /*m_debug_size = size();*/
-
- assert((original_size + _M) == msev_size_t((*this).size()));
- /*assert(di == std::distance(base_class::begin(), retval));*/
- m_mmitset.shift_inclusive_range(d, original_size, _M);
- auto new_capacity = msev_size_t((*this).capacity());
- bool realloc_occured = (new_capacity != original_capacity);
- if (realloc_occured) {
- m_mmitset.sync_iterators_to_index();
- }
- /*return retval;*/
- }
- template<class _Iter
- //>typename std::enable_if<_mse_Is_iterator<_Iter>::value, void>::type
- , class = _mse_RequireInputIter<_Iter> > void
- insert(typename base_class::/*const_*/iterator _Where, _Iter _First, _Iter _Last) { // insert [_First, _Last) at _Where
- msev_int di = std::distance(base_class::/*c*/begin(), _Where);
- msev_size_t d = msev_size_t(di);
- if ((0 > di) || (msev_size_t((*this).size()) < di)) { MSE_THROW(msevector_range_error("index out of range - typename base_class::iterator insert() - msevector")); }
-
- auto _M = msev_int(std::distance(_First, _Last));
- auto original_size = msev_size_t((*this).size());
- auto original_capacity = msev_size_t((*this).capacity());
-
- //if (0 > _M) { MSE_THROW(msevector_range_error("invalid argument - typename base_class::iterator insert() - msevector")); }
- /*auto retval =*/
- base_class::insert(_Where, _First, _Last);
- /*m_debug_size = size();*/
-
- assert((original_size + _M) == msev_size_t((*this).size()));
- /*assert(di == std::distance(base_class::begin(), retval));*/
- m_mmitset.shift_inclusive_range(d, original_size, _M);
- auto new_capacity = msev_size_t((*this).capacity());
- bool realloc_occured = (new_capacity != original_capacity);
- if (realloc_occured) {
- m_mmitset.sync_iterators_to_index();
- }
- /*return retval;*/
- }
-#endif /*!(defined(GPP4P8_COMPATIBLE))*/
-
- template<class ..._Valty>
- void emplace_back(_Valty&& ..._Val)
- { // insert by moving into element at end
- if (m_mmitset.is_empty()) {
- base_class::emplace_back(std::forward<_Valty>(_Val)...);
- /*m_debug_size = size();*/
- }
- else {
- auto original_size = msev_size_t((*this).size());
- auto original_capacity = msev_size_t((*this).capacity());
-
- base_class::emplace_back(std::forward<_Valty>(_Val)...);
- /*m_debug_size = size();*/
-
- assert((original_size + 1) == msev_size_t((*this).size()));
- m_mmitset.shift_inclusive_range(original_size, original_size, 1); /*shift the end markers*/
- auto new_capacity = msev_size_t((*this).capacity());
- bool realloc_occured = (new_capacity != original_capacity);
- if (realloc_occured) {
- m_mmitset.sync_iterators_to_index();
- }
- }
- }
- template<class ..._Valty>
-#if !(defined(GPP4P8_COMPATIBLE))
- typename base_class::iterator emplace(typename base_class::const_iterator _Where, _Valty&& ..._Val)
- { // insert by moving _Val at _Where
-#else /*!(defined(GPP4P8_COMPATIBLE))*/
- typename base_class::iterator emplace(typename base_class::/*const_*/iterator _Where, _Valty&& ..._Val)
- { // insert by moving _Val at _Where
-#endif /*!(defined(GPP4P8_COMPATIBLE))*/
-
- if (m_mmitset.is_empty()) {
- auto retval = base_class::emplace(_Where, std::forward<_Valty>(_Val)...);
- /*m_debug_size = size();*/
- return retval;
- }
- else {
-
-#if !(defined(GPP4P8_COMPATIBLE))
- msev_int di = std::distance(base_class::cbegin(), _Where);
-#else /*!(defined(GPP4P8_COMPATIBLE))*/
- msev_int di = std::distance(base_class::/*c*/begin(), _Where);
-#endif /*!(defined(GPP4P8_COMPATIBLE))*/
-
- msev_size_t d = msev_size_t(di);
- if ((0 > di) || ((*this).size() < msev_size_t(di))) { MSE_THROW(msevector_range_error("index out of range - typename base_class::iterator emplace() - msevector")); }
-
- auto original_size = msev_size_t((*this).size());
- auto original_capacity = msev_size_t((*this).capacity());
-
- auto retval = base_class::emplace(_Where, std::forward<_Valty>(_Val)...);
- /*m_debug_size = size();*/
-
- assert((original_size + 1) == msev_size_t((*this).size()));
- assert(di == std::distance(base_class::begin(), retval));
- m_mmitset.shift_inclusive_range(d, original_size, 1);
- auto new_capacity = msev_size_t((*this).capacity());
- bool realloc_occured = (new_capacity != original_capacity);
- if (realloc_occured) {
- m_mmitset.sync_iterators_to_index();
- }
- return retval;
- }
- }
- typename base_class::iterator erase(typename base_class::const_iterator _P) {
- if (m_mmitset.is_empty()) {
- typename base_class::iterator retval = base_class::erase(_P);
- /*m_debug_size = size();*/
- return retval;
- }
- else {
- msev_int di = std::distance(base_class::cbegin(), _P);
- msev_size_t d = msev_size_t(di);
- if ((0 > di) || ((*this).size() < msev_size_t(di))) { MSE_THROW(msevector_range_error("index out of range - typename base_class::iterator erase() - msevector")); }
-
- auto original_size = msev_size_t((*this).size());
- auto original_capacity = msev_size_t((*this).capacity());
-
- if (base_class::end() == _P) { MSE_THROW(msevector_range_error("invalid argument - typename base_class::iterator erase(typename base_class::const_iterator _P) - msevector")); }
- typename base_class::iterator retval = base_class::erase(_P);
- /*m_debug_size = size();*/
-
- assert((original_size - 1) == msev_size_t((*this).size()));
- assert(di == std::distance(base_class::begin(), retval));
- {
- m_mmitset.invalidate_inclusive_range(d, d);
- m_mmitset.shift_inclusive_range(msev_size_t(d + 1), original_size, -1);
- }
- auto new_capacity = msev_size_t((*this).capacity());
- bool realloc_occured = (new_capacity != original_capacity);
- if (realloc_occured) {
- m_mmitset.sync_iterators_to_index();
- }
- return retval;
- }
- }
- typename base_class::iterator erase(typename base_class::const_iterator _F, typename base_class::const_iterator _L) {
- if (m_mmitset.is_empty()) {
- typename base_class::iterator retval = base_class::erase(_F, _L);
- /*m_debug_size = size();*/
- return retval;
- }
- else {
- msev_int di = std::distance(base_class::cbegin(), _F);
- msev_size_t d = msev_size_t(di);
- if ((0 > di) || ((*this).size() < msev_size_t(di))) { MSE_THROW(msevector_range_error("index out of range - typename base_class::iterator erase() - msevector")); }
- msev_int di2 = std::distance(base_class::cbegin(), _L);
- msev_size_t d2 = msev_size_t(di2);
- if ((0 > di2) || ((*this).size() < msev_size_t(di2))) { MSE_THROW(msevector_range_error("index out of range - typename base_class::iterator erase() - msevector")); }
-
- auto _M = msev_int(std::distance(_F, _L));
- auto original_size = msev_size_t((*this).size());
- auto original_capacity = msev_size_t((*this).capacity());
-
- if ((base_class::end() == _F)/* || (0 > _M)*/) { MSE_THROW(msevector_range_error("invalid argument - typename base_class::iterator erase(typename base_class::iterator _F, typename base_class::iterator _L) - msevector")); }
- typename base_class::iterator retval = base_class::erase(_F, _L);
- /*m_debug_size = size();*/
-
- assert((original_size - _M) == msev_size_t((*this).size()));
- assert(di == std::distance(base_class::begin(), retval));
- {
- if (1 <= _M) {
- m_mmitset.invalidate_inclusive_range(d, msev_size_t(d + _M - 1));
- }
- m_mmitset.shift_inclusive_range(msev_size_t(d + _M), original_size, -_M);
- }
- auto new_capacity = msev_size_t((*this).capacity());
- bool realloc_occured = (new_capacity != original_capacity);
- if (realloc_occured) {
- m_mmitset.sync_iterators_to_index();
- }
- return retval;
- }
- }
- void clear() {
- base_class::clear();
- /*m_debug_size = size();*/
- m_mmitset.reset();
- }
- void swap(base_class& _X) {
- base_class::swap(_X);
- /*m_debug_size = size();*/
- m_mmitset.reset();
- }
- void swap(_Myt& _X) {
- swap(static_cast<base_class&>(_X));
- m_mmitset.reset();
- }
-
- msevector(_XSTD initializer_list<typename base_class::value_type> _Ilist,
- const _A& _Al = _A())
- : base_class(_Ilist, _Al), m_mmitset(*this) { // construct from initializer_list
- /*m_debug_size = size();*/
- }
- _Myt& operator=(_XSTD initializer_list<typename base_class::value_type> _Ilist) { // assign initializer_list
- operator=(static_cast<base_class>(_Ilist));
- m_mmitset.reset();
- return (*this);
- }
- void assign(_XSTD initializer_list<typename base_class::value_type> _Ilist) { // assign initializer_list
- base_class::assign(_Ilist);
- /*m_debug_size = size();*/
- m_mmitset.reset();
- }
-#if defined(GPP4P8_COMPATIBLE)
- /* g++4.8 seems to be (incorrectly) using the c++98 version of this insert function instead of the c++11 version. */
- /*typename base_class::iterator*/void insert(typename base_class::/*const_*/iterator _Where, _XSTD initializer_list<typename base_class::value_type> _Ilist) { // insert initializer_list
- msev_int di = std::distance(base_class::/*c*/begin(), _Where);
- msev_size_t d = msev_size_t(di);
- if ((0 > di) || (msev_size_t((*this).size()) < di)) { MSE_THROW(msevector_range_error("index out of range - typename base_class::iterator insert() - msevector")); }
-
- auto _M = _Ilist.size();
- auto original_size = msev_size_t((*this).size());
- auto original_capacity = msev_size_t((*this).capacity());
-
- /*auto retval = */base_class::insert(_Where, _Ilist);
- /*m_debug_size = size();*/
-
- assert((original_size + _M) == msev_size_t((*this).size()));
- /*assert(di == std::distance(base_class::begin(), retval));*/
- m_mmitset.shift_inclusive_range(d, original_size, _M);
- auto new_capacity = msev_size_t((*this).capacity());
- bool realloc_occured = (new_capacity != original_capacity);
- if (realloc_occured) {
- m_mmitset.sync_iterators_to_index();
- }
- /*return retval;*/
- }
-#else /*defined(GPP4P8_COMPATIBLE)*/
- typename base_class::iterator insert(typename base_class::const_iterator _Where, _XSTD initializer_list<typename base_class::value_type> _Ilist) { // insert initializer_list
- if (m_mmitset.is_empty()) {
- auto retval = base_class::insert(_Where, _Ilist);
- /*m_debug_size = size();*/
- return retval;
- }
- else {
- msev_int di = std::distance(base_class::cbegin(), _Where);
- msev_size_t d = msev_size_t(di);
- if ((0 > di) || ((*this).size() < msev_size_t(di))) { MSE_THROW(msevector_range_error("index out of range - typename base_class::iterator insert() - msevector")); }
-
- auto _M = _Ilist.size();
- auto original_size = msev_size_t((*this).size());
- auto original_capacity = msev_size_t((*this).capacity());
-
- auto retval = base_class::insert(_Where, _Ilist);
- /*m_debug_size = size();*/
-
- assert((original_size + _M) == msev_size_t((*this).size()));
- assert(di == std::distance(base_class::begin(), retval));
- m_mmitset.shift_inclusive_range(d, original_size, msev_int(_M));
- auto new_capacity = msev_size_t((*this).capacity());
- bool realloc_occured = (new_capacity != original_capacity);
- if (realloc_occured) {
- m_mmitset.sync_iterators_to_index();
- }
- return retval;
- }
- }
-#endif /*defined(GPP4P8_COMPATIBLE)*/
-
- //size_t m_debug_size;
-
- class random_access_const_iterator_base : public std::iterator<std::random_access_iterator_tag, value_type, difference_type, const_pointer, const_reference> {};
- class random_access_iterator_base : public std::iterator<std::random_access_iterator_tag, value_type, difference_type, pointer, reference> {};
-
- /* mm_const_iterator_type acts much like a list iterator. */
- class mm_const_iterator_type : public random_access_const_iterator_base {
- public:
- typedef typename base_class::const_iterator::iterator_category iterator_category;
- typedef typename base_class::const_iterator::value_type value_type;
- //typedef typename base_class::const_iterator::difference_type difference_type;
- typedef msev_int difference_type;
- typedef difference_type distance_type; // retained
- typedef typename base_class::const_iterator::pointer pointer;
- typedef typename base_class::const_iterator::pointer const_pointer;
- typedef typename base_class::const_iterator::reference reference;
- typedef typename base_class::const_reference const_reference;
-
- void reset() { set_to_end_marker(); }
- bool points_to_an_item() const {
- if (m_points_to_an_item) { assert((1 <= m_owner_cptr->size()) && (m_index < m_owner_cptr->size())); return true; }
- else { assert(!((1 <= m_owner_cptr->size()) && (m_index < m_owner_cptr->size()))); return false; }
- }
- bool points_to_end_marker() const {
- if (false == points_to_an_item()) { assert(m_index == m_owner_cptr->size()); return true; }
- else { return false; }
- }
- bool points_to_beginning() const {
- if (0 == m_index) { return true; }
- else { return false; }
- }
- /* has_next_item_or_end_marker() is just an alias for points_to_an_item(). */
- bool has_next_item_or_end_marker() const { return points_to_an_item(); } //his is
- /* has_next() is just an alias for points_to_an_item() that's familiar to java programmers. */
- bool has_next() const { return has_next_item_or_end_marker(); }
- bool has_previous() const { return (!points_to_beginning()); }
- void set_to_beginning() {
- m_index = 0;
- if (1 <= m_owner_cptr->size()) {
- m_points_to_an_item = true;
- }
- else { assert(false == m_points_to_an_item); }
- }
- void set_to_end_marker() {
- m_index = m_owner_cptr->size();
- m_points_to_an_item = false;
- }
- void set_to_next() {
- if (points_to_an_item()) {
- m_index += 1;
- if (m_owner_cptr->size() <= m_index) {
- (*this).m_points_to_an_item = false;
- if (m_owner_cptr->size() < m_index) { assert(false); reset(); }
- }
- }
- else {
- MSE_THROW(msevector_range_error("attempt to use invalid const_item_pointer - void set_to_next() - mm_const_iterator_type - msevector"));
- }
- }
- void set_to_previous() {
- if (has_previous()) {
- m_index -= 1;
- (*this).m_points_to_an_item = true;
- }
- else {
- MSE_THROW(msevector_range_error("attempt to use invalid const_item_pointer - void set_to_previous() - mm_const_iterator_type - msevector"));
- }
- }
- mm_const_iterator_type& operator ++() { (*this).set_to_next(); return (*this); }
- mm_const_iterator_type operator++(int) { mm_const_iterator_type _Tmp = *this; ++*this; return (_Tmp); }
- mm_const_iterator_type& operator --() { (*this).set_to_previous(); return (*this); }
- mm_const_iterator_type operator--(int) { mm_const_iterator_type _Tmp = *this; --*this; return (_Tmp); }
- void advance(difference_type n) {
- auto new_index = msev_int(m_index) + n;
- if ((0 > new_index) || (m_owner_cptr->size() < msev_size_t(new_index))) {
- MSE_THROW(msevector_range_error("index out of range - void advance(difference_type n) - mm_const_iterator_type - msevector"));
- }
- else {
- m_index = msev_size_t(new_index);
- if (m_owner_cptr->size() <= m_index) {
- (*this).m_points_to_an_item = false;
- }
- else {
- (*this).m_points_to_an_item = true;
- }
- }
- }
- void regress(difference_type n) { advance(-n); }
- mm_const_iterator_type& operator +=(difference_type n) { (*this).advance(n); return (*this); }
- mm_const_iterator_type& operator -=(difference_type n) { (*this).regress(n); return (*this); }
- mm_const_iterator_type operator+(difference_type n) const {
- mm_const_iterator_type retval(*this);
- retval = (*this);
- retval.advance(n);
- return retval;
- }
- mm_const_iterator_type operator-(difference_type n) const { return ((*this) + (-n)); }
- difference_type operator-(const mm_const_iterator_type &rhs) const {
- if ((rhs.m_owner_cptr) != ((*this).m_owner_cptr)) { MSE_THROW(msevector_range_error("invalid argument - difference_type operator-(const mm_const_iterator_type &rhs) const - msevector::mm_const_iterator_type")); }
- auto retval = difference_type((*this).m_index) - difference_type(rhs.m_index);
- assert(difference_type(m_owner_cptr->size()) >= retval);
- return retval;
- }
- const_reference operator*() const {
- return m_owner_cptr->at(msev_as_a_size_t(m_index));
- }
- const_reference item() const { return operator*(); }
- const_reference previous_item() const {
- return m_owner_cptr->at(msev_as_a_size_t(m_index - 1));
- }
- const_pointer operator->() const {
- return &(m_owner_cptr->at(msev_as_a_size_t(m_index)));
- }
- const_reference operator[](difference_type _Off) const { return (*m_owner_cptr).at(msev_as_a_size_t(difference_type(m_index) + _Off)); }
- /*
- mm_const_iterator_type& operator=(const typename base_class::const_iterator& _Right_cref)
- {
- msev_int d = std::distance<typename base_class::iterator>(m_owner_cptr->cbegin(), _Right_cref);
- if ((0 <= d) && (m_owner_cptr->size() >= d)) {
- if (m_owner_cptr->size() == d) {
- assert(m_owner_cptr->cend() == _Right_cref);
- m_points_to_an_item = false;
- } else {
- m_points_to_an_item = true;
- }
- m_index = msev_size_t(d);
- base_class::const_iterator::operator=(_Right_cref);
- }
- else {
- MSE_THROW(msevector_range_error("doesn't seem to be a valid assignment value - mm_const_iterator_type& operator=(const typename base_class::const_iterator& _Right_cref) - mm_const_iterator_type - msevector"));
- }
- return (*this);
- }
- */
- mm_const_iterator_type& operator=(const mm_const_iterator_type& _Right_cref)
- {
- if (((*this).m_owner_cptr) == (_Right_cref.m_owner_cptr)) {
- assert((*this).m_owner_cptr->size() >= _Right_cref.m_index);
- (*this).m_points_to_an_item = _Right_cref.m_points_to_an_item;
- (*this).m_index = _Right_cref.m_index;
- }
- else {
- MSE_THROW(msevector_range_error("doesn't seem to be a valid assignment value - mm_const_iterator_type& operator=(const typename base_class::iterator& _Right_cref) - mm_const_iterator_type - msevector"));
- }
- return (*this);
- }
- bool operator==(const mm_const_iterator_type& _Right_cref) const {
- if (((*this).m_owner_cptr) != (_Right_cref.m_owner_cptr)) { MSE_THROW(msevector_range_error("invalid argument - mm_const_iterator_type& operator==(const mm_const_iterator_type& _Right) - mm_const_iterator_type - msevector")); }
- return (_Right_cref.m_index == m_index);
- }
- bool operator!=(const mm_const_iterator_type& _Right_cref) const { return (!(_Right_cref == (*this))); }
- bool operator<(const mm_const_iterator_type& _Right) const {
- if (((*this).m_owner_cptr) != (_Right.m_owner_cptr)) { MSE_THROW(msevector_range_error("invalid argument - mm_const_iterator_type& operator<(const mm_const_iterator_type& _Right) - mm_const_iterator_type - msevector")); }
- return (m_index < _Right.m_index);
- }
- bool operator<=(const mm_const_iterator_type& _Right) const { return (((*this) < _Right) || (_Right == (*this))); }
- bool operator>(const mm_const_iterator_type& _Right) const { return (!((*this) <= _Right)); }
- bool operator>=(const mm_const_iterator_type& _Right) const { return (!((*this) < _Right)); }
- void set_to_const_item_pointer(const mm_const_iterator_type& _Right_cref) {
- (*this) = _Right_cref;
- }
- void invalidate_inclusive_range(msev_size_t index_of_first, msev_size_t index_of_last) {
- if ((index_of_first <= (*this).m_index) && (index_of_last >= (*this).m_index)) {
- (*this).reset();
- }
- }
- void shift_inclusive_range(msev_size_t index_of_first, msev_size_t index_of_last, msev_int shift) {
- if ((index_of_first <= (*this).m_index) && (index_of_last >= (*this).m_index)) {
- auto new_index = (*this).m_index + shift;
- if ((0 > new_index) || (m_owner_cptr->size() < new_index)) {
- MSE_THROW(msevector_range_error("void shift_inclusive_range() - mm_const_iterator_type - msevector"));
- }
- else {
- (*this).m_index = msev_size_t(new_index);
- (*this).sync_const_iterator_to_index();
- }
- }
- }
- msev_size_t position() const {
- return m_index;
- }
- operator typename base_class::const_iterator() const {
- typename base_class::const_iterator retval = (*m_owner_cptr).cbegin();
- retval += msev_as_a_size_t(m_index);
- return retval;
- }
-
- /* We actually want to make this constructor private, but doing so seems to break std::make_shared<mm_const_iterator_type>. */
- mm_const_iterator_type(const _Myt& owner_cref) : m_owner_cptr(&owner_cref) { set_to_beginning(); }
- private:
- mm_const_iterator_type(const mm_const_iterator_type& src_cref) : m_owner_cptr(src_cref.m_owner_cptr) { (*this) = src_cref; }
- void sync_const_iterator_to_index() {
- assert(m_owner_cptr->size() >= (*this).m_index);
- }
- msev_bool m_points_to_an_item = false;
- msev_size_t m_index = 0;
- const _Myt* m_owner_cptr = nullptr;
- friend class mm_iterator_set_type;
- friend class /*_Myt*/msevector<_Ty, _A>;
- friend class mm_iterator_type;
- };
- /* mm_iterator_type acts much like a list iterator. */
- class mm_iterator_type : random_access_iterator_base {
- public:
- typedef typename base_class::iterator::iterator_category iterator_category;
- typedef typename base_class::iterator::value_type value_type;
- //typedef typename base_class::iterator::difference_type difference_type;
- typedef msev_int difference_type;
- typedef difference_type distance_type; // retained
- typedef typename base_class::iterator::pointer pointer;
- typedef typename base_class::iterator::reference reference;
-
- void reset() { set_to_end_marker(); }
- bool points_to_an_item() const {
- if (m_points_to_an_item) { assert((1 <= m_owner_ptr->size()) && (m_index < m_owner_ptr->size())); return true; }
- else { assert(!((1 <= m_owner_ptr->size()) && (m_index < m_owner_ptr->size()))); return false; }
- }
- bool points_to_end_marker() const {
- if (false == points_to_an_item()) { assert(m_index == m_owner_ptr->size()); return true; }
- else { return false; }
- }
- bool points_to_beginning() const {
- if (0 == m_index) { return true; }
- else { return false; }
- }
- /* has_next_item_or_end_marker() is just an alias for points_to_an_item(). */
- bool has_next_item_or_end_marker() const { return points_to_an_item(); }
- /* has_next() is just an alias for points_to_an_item() that's familiar to java programmers. */
- bool has_next() const { return has_next_item_or_end_marker(); }
- bool has_previous() const { return (!points_to_beginning()); }
- void set_to_beginning() {
- m_index = 0;
- if (1 <= m_owner_ptr->size()) {
- m_points_to_an_item = true;
- }
- else { assert(false == m_points_to_an_item); }
- }
- void set_to_end_marker() {
- m_index = m_owner_ptr->size();
- m_points_to_an_item = false;
- }
- void set_to_next() {
- if (points_to_an_item()) {
- m_index += 1;
- if (m_owner_ptr->size() <= m_index) {
- (*this).m_points_to_an_item = false;
- if (m_owner_ptr->size() < m_index) { assert(false); reset(); }
- }
- }
- else {
- MSE_THROW(msevector_range_error("attempt to use invalid item_pointer - void set_to_next() - mm_const_iterator_type - msevector"));
- }
- }
- void set_to_previous() {
- if (has_previous()) {
- m_index -= 1;
- (*this).m_points_to_an_item = true;
- }
- else {
- MSE_THROW(msevector_range_error("attempt to use invalid item_pointer - void set_to_previous() - mm_iterator_type - msevector"));
- }
- }
- mm_iterator_type& operator ++() { (*this).set_to_next(); return (*this); }
- mm_iterator_type operator++(int) { mm_iterator_type _Tmp = *this; ++*this; return (_Tmp); }
- mm_iterator_type& operator --() { (*this).set_to_previous(); return (*this); }
- mm_iterator_type operator--(int) { mm_iterator_type _Tmp = *this; --*this; return (_Tmp); }
- void advance(difference_type n) {
- auto new_index = msev_int(m_index) + n;
- if ((0 > new_index) || (m_owner_ptr->size() < msev_size_t(new_index))) {
- MSE_THROW(msevector_range_error("index out of range - void advance(difference_type n) - mm_iterator_type - msevector"));
- }
- else {
- m_index = msev_size_t(new_index);
- if (m_owner_ptr->size() <= m_index) {
- (*this).m_points_to_an_item = false;
- }
- else {
- (*this).m_points_to_an_item = true;
- }
- }
- }
- void regress(int n) { advance(-n); }
- mm_iterator_type& operator +=(difference_type n) { (*this).advance(n); return (*this); }
- mm_iterator_type& operator -=(difference_type n) { (*this).regress(n); return (*this); }
- mm_iterator_type operator+(difference_type n) const {
- mm_iterator_type retval(*this);
- retval = (*this);
- retval.advance(n);
- return retval;
- }
- mm_iterator_type operator-(difference_type n) const { return ((*this) + (-n)); }
- difference_type operator-(const mm_iterator_type& rhs) const {
- if ((rhs.m_owner_ptr) != ((*this).m_owner_ptr)) { MSE_THROW(msevector_range_error("invalid argument - difference_type operator-(const mm_iterator_type& rhs) const - msevector::mm_iterator_type")); }
- auto retval = difference_type((*this).m_index) - difference_type(rhs.m_index);
- assert(difference_type(m_owner_ptr->size()) >= retval);
- return retval;
- }
- reference operator*() const {
- return m_owner_ptr->at(msev_as_a_size_t(m_index));
- }
- reference item() const { return operator*(); }
- reference previous_item() const {
- return m_owner_ptr->at(msev_as_a_size_t(m_index - 1));
- }
- pointer operator->() const {
- return &(m_owner_ptr->at(msev_as_a_size_t(m_index)));
- }
- reference operator[](difference_type _Off) const { return (*m_owner_ptr).at(msev_as_a_size_t(difference_type(m_index) + _Off)); }
- /*
- mm_iterator_type& operator=(const typename base_class::iterator& _Right_cref)
- {
- msev_int d = std::distance<typename base_class::iterator>(m_owner_ptr->begin(), _Right_cref);
- if ((0 <= d) && (m_owner_ptr->size() >= d)) {
- if (m_owner_ptr->size() == d) {
- assert(m_owner_ptr->end() == _Right_cref);
- m_points_to_an_item = false;
- } else {
- m_points_to_an_item = true;
- }
- m_index = msev_size_t(d);
- base_class::iterator::operator=(_Right_cref);
- }
- else {
- MSE_THROW(msevector_range_error("doesn't seem to be a valid assignment value - mm_iterator_type& operator=(const typename base_class::iterator& _Right_cref) - mm_const_iterator_type - msevector"));
- }
- return (*this);
- }
- */
- mm_iterator_type& operator=(const mm_iterator_type& _Right_cref)
- {
- if (((*this).m_owner_ptr) == (_Right_cref.m_owner_ptr)) {
- assert((*this).m_owner_ptr->size() >= _Right_cref.m_index);
- (*this).m_points_to_an_item = _Right_cref.m_points_to_an_item;
- (*this).m_index = _Right_cref.m_index;
- }
- else {
- MSE_THROW(msevector_range_error("doesn't seem to be a valid assignment value - mm_iterator_type& operator=(const typename base_class::iterator& _Right_cref) - mm_const_iterator_type - msevector"));
- }
- return (*this);
- }
- bool operator==(const mm_iterator_type& _Right_cref) const {
- if (((*this).m_owner_ptr) != (_Right_cref.m_owner_ptr)) { MSE_THROW(msevector_range_error("invalid argument - mm_iterator_type& operator==(const typename base_class::iterator& _Right) - mm_iterator_type - msevector")); }
- return (_Right_cref.m_index == m_index);
- }
- bool operator!=(const mm_iterator_type& _Right_cref) const { return (!(_Right_cref == (*this))); }
- bool operator<(const mm_iterator_type& _Right) const {
- if (((*this).m_owner_ptr) != (_Right.m_owner_ptr)) { MSE_THROW(msevector_range_error("invalid argument - mm_iterator_type& operator<(const typename base_class::iterator& _Right) - mm_iterator_type - msevector")); }
- return (m_index < _Right.m_index);
- }
- bool operator<=(const mm_iterator_type& _Right) const { return (((*this) < _Right) || (_Right == (*this))); }
- bool operator>(const mm_iterator_type& _Right) const { return (!((*this) <= _Right)); }
- bool operator>=(const mm_iterator_type& _Right) const { return (!((*this) < _Right)); }
- void set_to_item_pointer(const mm_iterator_type& _Right_cref) {
- (*this) = _Right_cref;
- }
- void invalidate_inclusive_range(msev_size_t index_of_first, msev_size_t index_of_last) {
- if ((index_of_first <= (*this).m_index) && (index_of_last >= (*this).m_index)) {
- (*this).reset();
- }
- }
- void shift_inclusive_range(msev_size_t index_of_first, msev_size_t index_of_last, msev_int shift) {
- if ((index_of_first <= (*this).m_index) && (index_of_last >= (*this).m_index)) {
- auto new_index = (*this).m_index + shift;
- if ((0 > new_index) || (m_owner_ptr->size() < new_index)) {
- MSE_THROW(msevector_range_error("void shift_inclusive_range() - mm_iterator_type - msevector"));
- }
- else {
- (*this).m_index = msev_size_t(new_index);
- (*this).sync_iterator_to_index();
- }
- }
- }
- msev_size_t position() const {
- return m_index;
- }
- operator mm_const_iterator_type() const {
- mm_const_iterator_type retval(*m_owner_ptr);
- retval.set_to_beginning();
- retval.advance(msev_int(m_index));
- return retval;
- }
- /* We actually want to make this constructor private, but doing so seems to break std::make_shared<mm_iterator_type>. */
- mm_iterator_type(_Myt& owner_ref) : m_owner_ptr(&owner_ref) { set_to_beginning(); }
- private:
- mm_iterator_type(const mm_iterator_type& src_cref) : m_owner_ptr(src_cref.m_owner_ptr) { (*this) = src_cref; }
- void sync_iterator_to_index() {
- assert(m_owner_ptr->size() >= (*this).m_index);
- }
- msev_bool m_points_to_an_item = false;
- msev_size_t m_index = 0;
- _Myt* m_owner_ptr = nullptr;
- friend class mm_iterator_set_type;
- friend class /*_Myt*/msevector<_Ty, _A>;
- };
-
- private:
- typedef std::size_t CHashKey1;
- class mm_const_iterator_handle_type {
- public:
- mm_const_iterator_handle_type(const CHashKey1& key_cref, const std::shared_ptr<mm_const_iterator_type>& shptr_cref) : m_shptr(shptr_cref), m_key(key_cref) {}
- private:
- std::shared_ptr<mm_const_iterator_type> m_shptr;
- CHashKey1 m_key;
- friend class /*_Myt*/msevector<_Ty, _A>;
- friend class mm_iterator_set_type;
- };
- class mm_iterator_handle_type {
- public:
- mm_iterator_handle_type(const CHashKey1& key_cref, const std::shared_ptr<mm_iterator_type>& shptr_ref) : m_shptr(shptr_ref), m_key(key_cref) {}
- private:
- std::shared_ptr<mm_iterator_type> m_shptr;
- CHashKey1 m_key;
- friend class /*_Myt*/msevector<_Ty, _A>;
- friend class mm_iterator_set_type;
- };
-
- class mm_iterator_set_type {
- public:
- class CMMConstIterators : public std::unordered_map<CHashKey1, std::shared_ptr<mm_const_iterator_type>> {};
- class CMMIterators : public std::unordered_map<CHashKey1, std::shared_ptr<mm_iterator_type>> {};
-
- class assignable_CMMConstIterators_value_type : public std::pair<CHashKey1, std::shared_ptr<mm_const_iterator_type>> {
- public:
- assignable_CMMConstIterators_value_type() {}
- assignable_CMMConstIterators_value_type(const typename CMMConstIterators::value_type& src) : std::pair<CHashKey1, std::shared_ptr<mm_iterator_type>>(src.first, src.second) {}
- assignable_CMMConstIterators_value_type& operator=(const typename CMMConstIterators::value_type& rhs) { (*this).first = rhs.first; (*this).second = rhs.second; return (*this); }
- operator typename CMMConstIterators::value_type() const { return CMMConstIterators::value_type((*this).first, (*this).second); }
- };
- class assignable_CMMIterators_value_type : public std::pair<CHashKey1, std::shared_ptr<mm_iterator_type>> {
- public:
- assignable_CMMIterators_value_type() {}
- assignable_CMMIterators_value_type(const typename CMMIterators::value_type& src) : std::pair<CHashKey1, std::shared_ptr<mm_iterator_type>>(src.first, src.second) {}
- assignable_CMMIterators_value_type& operator=(const typename CMMIterators::value_type& rhs) { (*this).first = rhs.first; (*this).second = rhs.second; return (*this); }
- operator typename CMMIterators::value_type() const { return CMMIterators::value_type((*this).first, (*this).second); }
- };
-
- ~mm_iterator_set_type() {
- if (!mm_const_fast_mode1()) {
- delete m_aux_mm_const_iterator_shptrs_ptr;
- }
- if (!mm_fast_mode1()) {
- delete m_aux_mm_iterator_shptrs_ptr;
- }
- }
-
- void apply_to_all_mm_const_iterator_shptrs(const std::function<void(std::shared_ptr<mm_const_iterator_type>&)>& func_obj_ref) {
- if (!mm_const_fast_mode1()) {
- for (auto it = (*m_aux_mm_const_iterator_shptrs_ptr).begin(); (*m_aux_mm_const_iterator_shptrs_ptr).end() != it; it++) {
- func_obj_ref((*it).second);
- }
- }
- else {
- for (int i = 0; i < m_fm1_num_mm_const_iterators; i += 1) {
- func_obj_ref(m_fm1_key_mm_const_it_array[i].second);
- }
- }
- }
- void apply_to_all_mm_iterator_shptrs(const std::function<void(std::shared_ptr<mm_iterator_type>&)>& func_obj_ref) {
- if (!mm_fast_mode1()) {
- for (auto it = (*m_aux_mm_iterator_shptrs_ptr).begin(); (*m_aux_mm_iterator_shptrs_ptr).end() != it; it++) {
- func_obj_ref((*it).second);
- }
- }
- else {
- for (int i = 0; i < m_fm1_num_mm_iterators; i += 1) {
- func_obj_ref(m_fm1_key_mm_it_array[i].second);
- }
- }
- }
- mm_iterator_set_type(_Myt& owner_ref) : m_next_available_key(0), m_owner_ptr(&owner_ref) {}
- void reset() {
- /* We can use "static" here because the lambda function does not capture any parameters. */
- static const std::function<void(std::shared_ptr<mm_const_iterator_type>&)> cit_func_obj = [](std::shared_ptr<mm_const_iterator_type>& a) { a->reset(); };
- apply_to_all_mm_const_iterator_shptrs(cit_func_obj);
- static const std::function<void(std::shared_ptr<mm_iterator_type>&)> it_func_obj = [](std::shared_ptr<mm_iterator_type>& a) { a->reset(); };
- apply_to_all_mm_iterator_shptrs(it_func_obj);
- }
- void sync_iterators_to_index() {
- /* No longer used. Relic from when mm_iterator_type contained a "native" iterator. */
- /* We can use "static" here because the lambda function does not capture any parameters. */
- /*
- static const std::function<void(std::shared_ptr<mm_const_iterator_type>&)> cit_func_obj = [](std::shared_ptr<mm_const_iterator_type>& a) { a->sync_const_iterator_to_index(); };
- apply_to_all_mm_const_iterator_shptrs(cit_func_obj);
- static const std::function<void(std::shared_ptr<mm_iterator_type>&)> it_func_obj = [](std::shared_ptr<mm_iterator_type>& a) { a->sync_iterator_to_index(); };
- apply_to_all_mm_iterator_shptrs(it_func_obj);
- */
- }
- void invalidate_inclusive_range(msev_size_t start_index, msev_size_t end_index) {
- const std::function<void(std::shared_ptr<mm_const_iterator_type>&)> cit_func_obj = [start_index, end_index](std::shared_ptr<mm_const_iterator_type>& a) { a->invalidate_inclusive_range(start_index, end_index); };
- apply_to_all_mm_const_iterator_shptrs(cit_func_obj);
- const std::function<void(std::shared_ptr<mm_iterator_type>&)> it_func_obj = [start_index, end_index](std::shared_ptr<mm_iterator_type>& a) { a->invalidate_inclusive_range(start_index, end_index); };
- apply_to_all_mm_iterator_shptrs(it_func_obj);
- }
- void shift_inclusive_range(msev_size_t start_index, msev_size_t end_index, msev_int shift) {
- const std::function<void(std::shared_ptr<mm_const_iterator_type>&)> cit_func_obj = [start_index, end_index, shift](std::shared_ptr<mm_const_iterator_type>& a) { a->shift_inclusive_range(start_index, end_index, shift); };
- apply_to_all_mm_const_iterator_shptrs(cit_func_obj);
- const std::function<void(std::shared_ptr<mm_iterator_type>&)> it_func_obj = [start_index, end_index, shift](std::shared_ptr<mm_iterator_type>& a) { a->shift_inclusive_range(start_index, end_index, shift); };
- apply_to_all_mm_iterator_shptrs(it_func_obj);
- }
- bool is_empty() const {
- if (mm_const_fast_mode1()) {
- if (1 <= m_fm1_num_mm_const_iterators) {
- return false;
- }
- }
- else {
- if (1 <= m_aux_mm_const_iterator_shptrs_ptr->size()) {
- return false;
- }
- }
- if (mm_fast_mode1()) {
- if (1 <= m_fm1_num_mm_iterators) {
- return false;
- }
- }
- else {
- if (1 <= m_aux_mm_iterator_shptrs_ptr->size()) {
- return false;
- }
- }
- return true;
- }
-
- mm_const_iterator_handle_type allocate_new_const_item_pointer() {
- //auto shptr = std::shared_ptr<mm_const_iterator_type>(new mm_const_iterator_type(*m_owner_ptr));
- auto shptr = std::make_shared<mm_const_iterator_type>(*m_owner_ptr);
- auto key = m_next_available_key; m_next_available_key++;
- mm_const_iterator_handle_type retval(key, shptr);
- typename CMMConstIterators::value_type new_item(key, shptr);
- if (!mm_const_fast_mode1()) {
- (*m_aux_mm_const_iterator_shptrs_ptr).insert(new_item);
- } else {
- if (sc_fm1_max_mm_iterators == m_fm1_num_mm_const_iterators) {
- /* Too many items. Initiate and switch to slow mode. */
- /* Initialize slow storage. */
- m_aux_mm_const_iterator_shptrs_ptr = new CMMConstIterators();
- /* First copy the items from fast storage to slow storage. */
- for (int i = 0; i < sc_fm1_max_mm_iterators; i += 1) {
- (*m_aux_mm_const_iterator_shptrs_ptr).insert(m_fm1_key_mm_const_it_array[i]);
- }
- /* Add the new items to slow storage. */
- (*m_aux_mm_const_iterator_shptrs_ptr).insert(new_item);
- }
- else {
- m_fm1_key_mm_const_it_array[m_fm1_num_mm_const_iterators] = new_item;
- m_fm1_num_mm_const_iterators += 1;
- }
- }
- return retval;
- }
- void release_const_item_pointer(mm_const_iterator_handle_type handle) {
- if (!mm_const_fast_mode1()) {
- auto it = (*m_aux_mm_const_iterator_shptrs_ptr).find(handle.m_key);
- if ((*m_aux_mm_const_iterator_shptrs_ptr).end() != it) {
- (*m_aux_mm_const_iterator_shptrs_ptr).erase(it);
- }
- else {
- /* Do we need to throw here? */
- MSE_THROW(msevector_range_error("invalid handle - void release_aux_mm_const_iterator(mm_const_iterator_handle_type handle) - msevector::mm_iterator_set_type"));
- }
- }
- else {
- int found_index = -1;
- for (int i = 0; i < m_fm1_num_mm_const_iterators; i += 1) {
- if (handle.m_key == m_fm1_key_mm_const_it_array[i].first) {
- found_index = i;
- break;
- }
- }
- if (0 <= found_index) {
- m_fm1_num_mm_const_iterators -= 1;
- assert(0 <= m_fm1_num_mm_const_iterators);
- for (int j = found_index; j < m_fm1_num_mm_const_iterators; j += 1) {
- m_fm1_key_mm_const_it_array[j] = m_fm1_key_mm_const_it_array[j + 1];
- }
- }
- else {
- /* Do we need to throw here? */
- MSE_THROW(msevector_range_error("invalid handle - void release_aux_mm_const_iterator(mm_const_iterator_handle_type handle) - msevector::mm_iterator_set_type"));
- }
- }
- }
-
- mm_iterator_handle_type allocate_new_item_pointer() {
- //auto shptr = std::shared_ptr<mm_iterator_type>(new mm_iterator_type(*m_owner_ptr));
- auto shptr = std::make_shared<mm_iterator_type>(*m_owner_ptr);
- auto key = m_next_available_key; m_next_available_key++;
- mm_iterator_handle_type retval(key, shptr);
- typename CMMIterators::value_type new_item(key, shptr);
- if (!mm_fast_mode1()) {
- (*m_aux_mm_iterator_shptrs_ptr).insert(new_item);
- }
- else {
- if (sc_fm1_max_mm_iterators == m_fm1_num_mm_iterators) {
- /* Too many items. Initiate and switch to slow mode. */
- /* Initialize slow storage. */
- m_aux_mm_iterator_shptrs_ptr = new CMMIterators();
- /* First copy the items from fast storage to slow storage. */
- for (int i = 0; i < sc_fm1_max_mm_iterators; i += 1) {
- (*m_aux_mm_iterator_shptrs_ptr).insert(m_fm1_key_mm_it_array[i]);
- }
- /* Add the new items to slow storage. */
- (*m_aux_mm_iterator_shptrs_ptr).insert(new_item);
- }
- else {
- m_fm1_key_mm_it_array[m_fm1_num_mm_iterators] = new_item;
- m_fm1_num_mm_iterators += 1;
- }
- }
- return retval;
- }
- void release_item_pointer(mm_iterator_handle_type handle) {
- if (!mm_fast_mode1()) {
- auto it = (*m_aux_mm_iterator_shptrs_ptr).find(handle.m_key);
- if ((*m_aux_mm_iterator_shptrs_ptr).end() != it) {
- (*m_aux_mm_iterator_shptrs_ptr).erase(it);
- }
- else {
- /* Do we need to throw here? */
- MSE_THROW(msevector_range_error("invalid handle - void release_aux_mm_iterator(mm_iterator_handle_type handle) - msevector::mm_iterator_set_type"));
- }
- }
- else {
- int found_index = -1;
- for (int i = 0; i < m_fm1_num_mm_iterators; i += 1) {
- if (handle.m_key == m_fm1_key_mm_it_array[i].first) {
- found_index = i;
- break;
- }
- }
- if (0 <= found_index) {
- m_fm1_num_mm_iterators -= 1;
- assert(0 <= m_fm1_num_mm_iterators);
- for (int j = found_index; j < m_fm1_num_mm_iterators; j += 1) {
- m_fm1_key_mm_it_array[j] = m_fm1_key_mm_it_array[j + 1];
- }
- }
- else {
- /* Do we need to throw here? */
- MSE_THROW(msevector_range_error("invalid handle - void release_aux_mm_iterator(mm_iterator_handle_type handle) - msevector::mm_iterator_set_type"));
- }
- }
- }
- void release_all_item_pointers() {
- if (!mm_fast_mode1()) {
- (*m_aux_mm_iterator_shptrs_ptr).clear();
- }
- else {
- for (int i = 0; i < m_fm1_num_mm_iterators; i += 1) {
- m_fm1_key_mm_it_array[i] = assignable_CMMIterators_value_type();
- }
- m_fm1_num_mm_iterators = 0;
- }
- }
- mm_const_iterator_type &const_item_pointer(mm_const_iterator_handle_type handle) const {
- return (*(handle.m_shptr));
- }
- mm_iterator_type &item_pointer(mm_iterator_handle_type handle) {
- return (*(handle.m_shptr));
- }
-
- private:
- void release_all_const_item_pointers() {
- if (!mm_const_fast_mode1()) {
- (*m_aux_mm_const_iterator_shptrs_ptr).clear();
- }
- else {
- for (int i = 0; i < m_fm1_num_mm_const_iterators; i += 1) {
- m_fm1_key_mm_const_it_array[i] = assignable_CMMConstIterators_value_type();
- }
- m_fm1_num_mm_const_iterators = 0;
- }
- }
-
- mm_iterator_set_type& operator=(const mm_iterator_set_type& src_cref) {
- /* This is a special type of class. The state (i.e. member values) of an object of this class is specific to (and only
- valid for) the particular instance of the object (or the object of which it is a member). So the correct state of a new
- copy of this type of object is not a copy of the state, but rather the state of a new object (which is just the default
- initialization state). */
- (*this).reset();
- return (*this);
- }
- mm_iterator_set_type& operator=(mm_iterator_set_type&& src) { /* see above */ (*this).reset(); return (*this); }
- mm_iterator_set_type(const mm_iterator_set_type& src) { /* see above */ }
- mm_iterator_set_type(const mm_iterator_set_type&& src) { /* see above */ }
-
- CHashKey1 m_next_available_key = 0;
-
- static const int sc_fm1_max_mm_iterators = 6/*arbitrary*/;
-
- bool mm_const_fast_mode1() const { return (nullptr == m_aux_mm_const_iterator_shptrs_ptr); }
- int m_fm1_num_mm_const_iterators = 0;
- assignable_CMMConstIterators_value_type m_fm1_key_mm_const_it_array[sc_fm1_max_mm_iterators];
- CMMConstIterators* m_aux_mm_const_iterator_shptrs_ptr = nullptr;
-
- bool mm_fast_mode1() const { return (nullptr == m_aux_mm_iterator_shptrs_ptr); }
- int m_fm1_num_mm_iterators = 0;
- assignable_CMMIterators_value_type m_fm1_key_mm_it_array[sc_fm1_max_mm_iterators];
- CMMIterators* m_aux_mm_iterator_shptrs_ptr = nullptr;
-
- _Myt* m_owner_ptr = nullptr;
-
- friend class /*_Myt*/msevector<_Ty, _A>;
- };
- mutable mm_iterator_set_type m_mmitset;
-
- public:
- mm_const_iterator_type &const_item_pointer(mm_const_iterator_handle_type handle) const {
- return m_mmitset.const_item_pointer(handle);
- }
- mm_iterator_type &item_pointer(mm_iterator_handle_type handle) {
- return m_mmitset.item_pointer(handle);
- }
-
- private:
- mm_const_iterator_handle_type allocate_new_const_item_pointer() const { return m_mmitset.allocate_new_const_item_pointer(); }
- void release_const_item_pointer(mm_const_iterator_handle_type handle) const { m_mmitset.release_const_item_pointer(handle); }
- void release_all_const_item_pointers() const { m_mmitset.release_all_const_item_pointers(); }
- mm_iterator_handle_type allocate_new_item_pointer() const { return m_mmitset.allocate_new_item_pointer(); }
- void release_item_pointer(mm_iterator_handle_type handle) const { m_mmitset.release_item_pointer(handle); }
- void release_all_item_pointers() const { m_mmitset.release_all_item_pointers(); }
-
- public:
- class cipointer : public random_access_const_iterator_base {
- public:
- typedef typename mm_const_iterator_type::iterator_category iterator_category;
- typedef typename mm_const_iterator_type::value_type value_type;
- typedef typename mm_const_iterator_type::difference_type difference_type;
- typedef difference_type distance_type; // retained
- typedef typename mm_const_iterator_type::pointer pointer;
- typedef typename mm_const_iterator_type::const_pointer const_pointer;
- typedef typename mm_const_iterator_type::reference reference;
- typedef typename mm_const_iterator_type::const_reference const_reference;
-
- cipointer(const _Myt& owner_cref) : m_owner_cptr(&owner_cref) {
- mm_const_iterator_handle_type handle = m_owner_cptr->allocate_new_const_item_pointer();
- m_handle_shptr = std::make_shared<mm_const_iterator_handle_type>(handle);
- }
- cipointer(const cipointer& src_cref) : m_owner_cptr(src_cref.m_owner_cptr) {
- mm_const_iterator_handle_type handle = m_owner_cptr->allocate_new_const_item_pointer();
- m_handle_shptr = std::make_shared<mm_const_iterator_handle_type>(handle);
- const_item_pointer() = src_cref.const_item_pointer();
- }
- ~cipointer() {
- m_owner_cptr->release_const_item_pointer(*m_handle_shptr);
- }
- mm_const_iterator_type& const_item_pointer() const { return m_owner_cptr->const_item_pointer(*m_handle_shptr); }
- mm_const_iterator_type& cip() const { return const_item_pointer(); }
- //const mm_const_iterator_handle_type& handle() const { return (*m_handle_shptr); }
-
- void reset() { const_item_pointer().reset(); }
- bool points_to_an_item() const { return const_item_pointer().points_to_an_item(); }
- bool points_to_end_marker() const { return const_item_pointer().points_to_end_marker(); }
- bool points_to_beginning() const { return const_item_pointer().points_to_beginning(); }
- /* has_next_item_or_end_marker() is just an alias for points_to_an_item(). */
- bool has_next_item_or_end_marker() const { return const_item_pointer().has_next_item_or_end_marker(); }
- /* has_next() is just an alias for points_to_an_item() that's familiar to java programmers. */
- bool has_next() const { return const_item_pointer().has_next(); }
- bool has_previous() const { return const_item_pointer().has_previous(); }
- void set_to_beginning() { const_item_pointer().set_to_beginning(); }
- void set_to_end_marker() { const_item_pointer().set_to_end_marker(); }
- void set_to_next() { const_item_pointer().set_to_next(); }
- void set_to_previous() { const_item_pointer().set_to_previous(); }
- cipointer& operator ++() { const_item_pointer().operator ++(); return (*this); }
- cipointer operator++(int) { cipointer _Tmp = *this; ++*this; return (_Tmp); }
- cipointer& operator --() { const_item_pointer().operator --(); return (*this); }
- cipointer operator--(int) { cipointer _Tmp = *this; --*this; return (_Tmp); }
- void advance(difference_type n) { const_item_pointer().advance(n); }
- void regress(difference_type n) { const_item_pointer().regress(n); }
- cipointer& operator +=(difference_type n) { const_item_pointer().operator +=(n); return (*this); }
- cipointer& operator -=(difference_type n) { const_item_pointer().operator -=(n); return (*this); }
- cipointer operator+(difference_type n) const { auto retval = (*this); retval += n; return retval; }
- cipointer operator-(difference_type n) const { return ((*this) + (-n)); }
- difference_type operator-(const cipointer& _Right_cref) const { return const_item_pointer() - (_Right_cref.const_item_pointer()); }
- const_reference operator*() const { return const_item_pointer().operator*(); }
- const_reference item() const { return operator*(); }
- const_reference previous_item() const { return const_item_pointer().previous_item(); }
- const_pointer operator->() const { return const_item_pointer().operator->(); }
- const_reference operator[](difference_type _Off) const { return const_item_pointer()[_Off]; }
- cipointer& operator=(const cipointer& _Right_cref) { const_item_pointer().operator=(_Right_cref.const_item_pointer()); return (*this); }
- bool operator==(const cipointer& _Right_cref) const { return const_item_pointer().operator==(_Right_cref.const_item_pointer()); }
- bool operator!=(const cipointer& _Right_cref) const { return (!(_Right_cref == (*this))); }
- bool operator<(const cipointer& _Right) const { return (const_item_pointer() < _Right.const_item_pointer()); }
- bool operator<=(const cipointer& _Right) const { return (const_item_pointer() <= _Right.const_item_pointer()); }
- bool operator>(const cipointer& _Right) const { return (const_item_pointer() > _Right.const_item_pointer()); }
- bool operator>=(const cipointer& _Right) const { return (const_item_pointer() >= _Right.const_item_pointer()); }
- void set_to_const_item_pointer(const cipointer& _Right_cref) { const_item_pointer().set_to_const_item_pointer(_Right_cref.const_item_pointer()); }
- msev_size_t position() const { return const_item_pointer().position(); }
- private:
- const _Myt* m_owner_cptr = nullptr;
- std::shared_ptr<mm_const_iterator_handle_type> m_handle_shptr;
- friend class /*_Myt*/msevector<_Ty, _A>;
- };
- class ipointer : public random_access_iterator_base {
- public:
- typedef typename mm_iterator_type::iterator_category iterator_category;
- typedef typename mm_iterator_type::value_type value_type;
- typedef typename mm_iterator_type::difference_type difference_type;
- typedef difference_type distance_type; // retained
- typedef typename mm_iterator_type::pointer pointer;
- typedef typename mm_iterator_type::reference reference;
-
- ipointer(_Myt& owner_ref) : m_owner_ptr(&owner_ref) {
- mm_iterator_handle_type handle = m_owner_ptr->allocate_new_item_pointer();
- m_handle_shptr = std::make_shared<mm_iterator_handle_type>(handle);
- }
- ipointer(const ipointer& src_cref) : m_owner_ptr(src_cref.m_owner_ptr) {
- mm_iterator_handle_type handle = m_owner_ptr->allocate_new_item_pointer();
- m_handle_shptr = std::make_shared<mm_iterator_handle_type>(handle);
- item_pointer() = src_cref.item_pointer();
- }
- ~ipointer() {
- m_owner_ptr->release_item_pointer(*m_handle_shptr);
- }
- mm_iterator_type& item_pointer() const { return m_owner_ptr->item_pointer(*m_handle_shptr); }
- mm_iterator_type& ip() const { return item_pointer(); }
- //const mm_iterator_handle_type& handle() const { return (*m_handle_shptr); }
- operator cipointer() const {
- cipointer retval(*m_owner_ptr);
- retval.const_item_pointer().set_to_beginning();
- retval.const_item_pointer().advance(msev_int(item_pointer().position()));
- return retval;
- }
-
- void reset() { item_pointer().reset(); }
- bool points_to_an_item() const { return item_pointer().points_to_an_item(); }
- bool points_to_end_marker() const { return item_pointer().points_to_end_marker(); }
- bool points_to_beginning() const { return item_pointer().points_to_beginning(); }
- /* has_next_item_or_end_marker() is just an alias for points_to_an_item(). */
- bool has_next_item_or_end_marker() const { return item_pointer().has_next_item_or_end_marker(); }
- /* has_next() is just an alias for points_to_an_item() that's familiar to java programmers. */
- bool has_next() const { return item_pointer().has_next(); }
- bool has_previous() const { return item_pointer().has_previous(); }
- void set_to_beginning() { item_pointer().set_to_beginning(); }
- void set_to_end_marker() { item_pointer().set_to_end_marker(); }
- void set_to_next() { item_pointer().set_to_next(); }
- void set_to_previous() { item_pointer().set_to_previous(); }
- ipointer& operator ++() { item_pointer().operator ++(); return (*this); }
- ipointer operator++(int) { ipointer _Tmp = *this; ++*this; return (_Tmp); }
- ipointer& operator --() { item_pointer().operator --(); return (*this); }
- ipointer operator--(int) { ipointer _Tmp = *this; --*this; return (_Tmp); }
- void advance(difference_type n) { item_pointer().advance(n); }
- void regress(difference_type n) { item_pointer().regress(n); }
- ipointer& operator +=(difference_type n) { item_pointer().operator +=(n); return (*this); }
- ipointer& operator -=(difference_type n) { item_pointer().operator -=(n); return (*this); }
- ipointer operator+(difference_type n) const { auto retval = (*this); retval += n; return retval; }
- ipointer operator-(difference_type n) const { return ((*this) + (-n)); }
- difference_type operator-(const ipointer& _Right_cref) const { return item_pointer() - (_Right_cref.item_pointer()); }
- reference operator*() const { return item_pointer().operator*(); }
- reference item() const { return operator*(); }
- reference previous_item() const { return item_pointer().previous_item(); }
- pointer operator->() const { return item_pointer().operator->(); }
- reference operator[](difference_type _Off) const { return item_pointer()[_Off]; }
- ipointer& operator=(const ipointer& _Right_cref) { item_pointer().operator=(_Right_cref.item_pointer()); return (*this); }
- bool operator==(const ipointer& _Right_cref) const { return item_pointer().operator==(_Right_cref.item_pointer()); }
- bool operator!=(const ipointer& _Right_cref) const { return (!(_Right_cref == (*this))); }
- bool operator<(const ipointer& _Right) const { return (item_pointer() < _Right.item_pointer()); }
- bool operator<=(const ipointer& _Right) const { return (item_pointer() <= _Right.item_pointer()); }
- bool operator>(const ipointer& _Right) const { return (item_pointer() > _Right.item_pointer()); }
- bool operator>=(const ipointer& _Right) const { return (item_pointer() >= _Right.item_pointer()); }
- void set_to_item_pointer(const ipointer& _Right_cref) { item_pointer().set_to_item_pointer(_Right_cref.item_pointer()); }
- msev_size_t position() const { return item_pointer().position(); }
- private:
- _Myt* m_owner_ptr = nullptr;
- std::shared_ptr<mm_iterator_handle_type> m_handle_shptr;
- friend class /*_Myt*/msevector<_Ty, _A>;
- };
-
- ipointer ibegin() { // return ipointer for beginning of mutable sequence
- ipointer retval(*this);
- retval.set_to_beginning();
- return retval;
- }
- cipointer ibegin() const { // return ipointer for beginning of nonmutable sequence
- cipointer retval(*this);
- retval.set_to_beginning();
- return retval;
- }
- ipointer iend() { // return ipointer for end of mutable sequence
- ipointer retval(*this);
- retval.set_to_end_marker();
- return retval;
- }
- cipointer iend() const { // return ipointer for end of nonmutable sequence
- cipointer retval(*this);
- retval.set_to_end_marker();
- return retval;
- }
- cipointer cibegin() const { // return ipointer for beginning of nonmutable sequence
- cipointer retval(*this);
- retval.set_to_beginning();
- return retval;
- }
- cipointer ciend() const { // return ipointer for end of nonmutable sequence
- cipointer retval(*this);
- retval.set_to_end_marker();
- return retval;
- }
-
- msevector(const cipointer &start, const cipointer &end, const _A& _Al = _A())
- : base_class(_Al), m_mmitset(*this) {
- /*m_debug_size = size();*/
- assign(start, end);
- }
- void assign(const mm_const_iterator_type &start, const mm_const_iterator_type &end) {
- if (start.m_owner_cptr != end.m_owner_cptr) { MSE_THROW(msevector_range_error("invalid arguments - void assign(const mm_const_iterator_type &start, const mm_const_iterator_type &end) - msevector")); }
- if (start > end) { MSE_THROW(msevector_range_error("invalid arguments - void assign(const mm_const_iterator_type &start, const mm_const_iterator_type &end) - msevector")); }
- typename base_class::const_iterator _F = start;
- typename base_class::const_iterator _L = end;
- (*this).assign(_F, _L);
- }
- void assign_inclusive(const mm_const_iterator_type &first, const mm_const_iterator_type &last) {
- auto end = last;
- end++; // this should include some checks
- (*this).assign(first, end);
- }
- void assign(const cipointer &start, const cipointer &end) {
- assign(start.const_item_pointer(), end.const_item_pointer());
- }
- void assign_inclusive(const cipointer &first, const cipointer &last) {
- assign_inclusive(first.const_item_pointer(), last.const_item_pointer());
- }
- void insert_before(const mm_const_iterator_type &pos, size_type _M, const _Ty& _X) {
- if (pos.m_owner_cptr != this) { MSE_THROW(msevector_range_error("invalid arguments - void insert_before() - msevector")); }
- typename base_class::const_iterator _P = pos;
- (*this).insert(_P, _M, _X);
- }
- void insert_before(const mm_const_iterator_type &pos, _Ty&& _X) {
- if (pos.m_owner_cptr != this) { MSE_THROW(msevector_range_error("invalid arguments - void insert_before() - msevector")); }
- typename base_class::const_iterator _P = pos;
- (*this).insert(_P, 1, std::move(_X));
- }
- void insert_before(const mm_const_iterator_type &pos, const _Ty& _X = _Ty()) { (*this).insert(pos, 1, _X); }
- template<class _Iter
- //>typename std::enable_if<_mse_Is_iterator<_Iter>::value, typename base_class::iterator>::type
- , class = _mse_RequireInputIter<_Iter> >
- void insert_before(const mm_const_iterator_type &pos, const _Iter &start, const _Iter &end) {
- if (pos.m_owner_cptr != this) { MSE_THROW(msevector_range_error("invalid arguments - void insert_before() - msevector")); }
- //if (start.m_owner_cptr != end.m_owner_cptr) { MSE_THROW(msevector_range_error("invalid arguments - void insert_before(const mm_const_iterator_type &pos, const mm_const_iterator_type &start, const mm_const_iterator_type &end) - msevector")); }
- typename base_class::const_iterator _P = pos;
- (*this).insert(_P, start, end);
- }
- template<class _Iter
- //>typename std::enable_if<_mse_Is_iterator<_Iter>::value, typename base_class::iterator>::type
- , class = _mse_RequireInputIter<_Iter> >
- void insert_before_inclusive(const mm_const_iterator_type &pos, const _Iter &first, const _Iter &last) {
- if (pos.m_owner_cptr != this) { MSE_THROW(msevector_range_error("invalid arguments - void insert_before() - msevector")); }
- if (first.m_owner_cptr != last.m_owner_cptr) { MSE_THROW(msevector_range_error("invalid arguments - void insert_before_inclusive(const mm_const_iterator_type &pos, const mm_const_iterator_type &first, const mm_const_iterator_type &last) - msevector")); }
- if (!(last.points_to_item())) { MSE_THROW(msevector_range_error("invalid argument - void insert_before_inclusive(const mm_const_iterator_type &pos, const mm_const_iterator_type &first, const mm_const_iterator_type &last) - msevector")); }
- typename base_class::const_iterator _P = pos;
- auto _L = last;
- _L++;
- (*this).insert(_P, first, _L);
- }
- void insert_before(const mm_const_iterator_type &pos, _XSTD initializer_list<typename base_class::value_type> _Ilist) { // insert initializer_list
- if (pos.m_owner_cptr != this) { MSE_THROW(msevector_range_error("invalid arguments - void insert_before() - msevector")); }
- typename base_class::const_iterator _P = pos;
- (*this).insert(_P, _Ilist);
- }
- ipointer insert_before(const cipointer &pos, size_type _M, const _Ty& _X) {
- msev_size_t original_pos = pos.position();
- insert_before(pos.const_item_pointer(), _M, _X);
- ipointer retval(*this); retval.advance(msev_int(original_pos));
- return retval;
- }
- ipointer insert_before(const cipointer &pos, _Ty&& _X) {
- msev_size_t original_pos = pos.position();
- insert_before(pos.const_item_pointer(), std::move(_X));
- ipointer retval(*this); retval.advance(msev_int(original_pos));
- return retval;
- }
- ipointer insert_before(const cipointer &pos, const _Ty& _X = _Ty()) { return insert_before(pos, 1, _X); }
- template<class _Iter
- //>typename std::enable_if<_mse_Is_iterator<_Iter>::value, typename base_class::iterator>::type
- , class = _mse_RequireInputIter<_Iter> >
- ipointer insert_before(const cipointer &pos, const _Iter &start, const _Iter &end) {
- msev_size_t original_pos = pos.position();
- insert_before(pos.const_item_pointer(), start, end);
- ipointer retval(*this); retval.advance(msev_int(original_pos));
- return retval;
- }
- template<class _Iter
- //>typename std::enable_if<_mse_Is_iterator<_Iter>::value, typename base_class::iterator>::type
- , class = _mse_RequireInputIter<_Iter> >
- ipointer insert_before_inclusive(const cipointer &pos, const _Iter &first, const _Iter &last) {
- auto end = last; end++;
- return insert_before(pos, first, end);
- }
- ipointer insert_before(const cipointer &pos, _XSTD initializer_list<typename base_class::value_type> _Ilist) { // insert initializer_list
- msev_size_t original_pos = pos.position();
- (*this).insert_before(pos.const_item_pointer(), _Ilist);
- ipointer retval(*this); retval.advance(msev_int(original_pos));
- return retval;
- }
- void insert_before(msev_size_t pos, _Ty&& _X) {
- typename base_class::const_iterator _P = (*this).begin() + msev_as_a_size_t(pos);
- (*this).insert(_P, std::move(_X));
- }
- void insert_before(msev_size_t pos, const _Ty& _X = _Ty()) {
- typename base_class::const_iterator _P = (*this).begin() + msev_as_a_size_t(pos);
- (*this).insert(_P, _X);
- }
- void insert_before(msev_size_t pos, size_t _M, const _Ty& _X) {
- typename base_class::const_iterator _P = (*this).begin() + msev_as_a_size_t(pos);
- (*this).insert(_P, _M, _X);
- }
- void insert_before(msev_size_t pos, _XSTD initializer_list<typename base_class::value_type> _Ilist) { // insert initializer_list
- typename base_class::const_iterator _P = (*this).begin() + msev_as_a_size_t(pos);
- (*this).insert(_P, _Ilist);
- }
- /* These insert() functions are just aliases for their corresponding insert_before() functions. */
- ipointer insert(const cipointer &pos, size_type _M, const _Ty& _X) { return insert_before(pos, _M, _X); }
- ipointer insert(const cipointer &pos, _Ty&& _X) { return insert_before(pos, std::move(_X)); }
- ipointer insert(const cipointer &pos, const _Ty& _X = _Ty()) { return insert_before(pos, _X); }
- template<class _Iter
- //>typename std::enable_if<_mse_Is_iterator<_Iter>::value, typename base_class::iterator>::type
- , class = _mse_RequireInputIter<_Iter> >
- ipointer insert(const cipointer &pos, const _Iter &start, const _Iter &end) { return insert_before(pos, start, end); }
- ipointer insert(const cipointer &pos, _XSTD initializer_list<typename base_class::value_type> _Ilist) { return insert_before(pos, _Ilist); }
- template<class ..._Valty>
-#if !(defined(GPP4P8_COMPATIBLE))
- void emplace(const mm_const_iterator_type &pos, _Valty&& ..._Val)
- { // insert by moving _Val at pos
-#else /*!(defined(GPP4P8_COMPATIBLE))*/
- void emplace(const mm_iterator_type &pos, _Valty&& ..._Val)
- { // insert by moving _Val at pos
-#endif /*!(defined(GPP4P8_COMPATIBLE))*/
- if (pos.m_owner_cptr != this) { MSE_THROW(msevector_range_error("invalid arguments - void emplace() - msevector")); }
- typename base_class::const_iterator _P = pos;
- auto retval = base_class::emplace(_P, std::forward<_Valty>(_Val)...);
- }
- template<class ..._Valty>
-#if !(defined(GPP4P8_COMPATIBLE))
- ipointer emplace(const cipointer &pos, _Valty&& ..._Val)
- { // insert by moving _Val at pos
-#else /*!(defined(GPP4P8_COMPATIBLE))*/
- ipointer emplace(const ipointer &pos, _Valty&& ..._Val)
- { // insert by moving _Val at pos
-#endif /*!(defined(GPP4P8_COMPATIBLE))*/
- msev_size_t original_pos = pos.position();
- (*this).emplace(pos.const_item_pointer(), std::forward<_Valty>(_Val)...);
- ipointer retval(*this); retval.advance(msev_int(original_pos));
- return retval;
- }
- void erase(const mm_const_iterator_type &pos) {
- if (pos.m_owner_cptr != this) { MSE_THROW(msevector_range_error("invalid arguments - void erase() - msevector")); }
- typename base_class::const_iterator _P = pos;
- (*this).erase(_P);
- }
- void erase(const mm_const_iterator_type &start, const mm_const_iterator_type &end) {
- if (start.m_owner_cptr != this) { MSE_THROW(msevector_range_error("invalid arguments - void erase() - msevector")); }
- if (end.m_owner_cptr != this) { MSE_THROW(msevector_range_error("invalid arguments - void erase() - msevector")); }
- typename base_class::const_iterator _F = start;
- typename base_class::const_iterator _L = end;
- (*this).erase(_F, _L);
- }
- void erase_inclusive(const mm_const_iterator_type &first, const mm_const_iterator_type &last) {
- if (first.m_owner_cptr != this) { MSE_THROW(msevector_range_error("invalid arguments - void erase_inclusive() - msevector")); }
- if (last.m_owner_cptr != this) { MSE_THROW(msevector_range_error("invalid arguments - void erase_inclusive() - msevector")); }
- if (!(last.points_to_item())) { MSE_THROW(msevector_range_error("invalid argument - void erase_inclusive() - msevector")); }
- typename base_class::const_iterator _F = first;
- typename base_class::const_iterator _L = last;
- _L++;
- (*this).erase(_F, _L);
- }
- ipointer erase(const cipointer &pos) {
- auto retval_pos = pos;
- retval_pos.set_to_next();
- erase(pos.const_item_pointer());
- ipointer retval = (*this).ibegin();
- retval.advance(msev_int(retval_pos.position()));
- return retval;
- }
- ipointer erase(const cipointer &start, const cipointer &end) {
- auto retval_pos = end;
- retval_pos.set_to_next();
- erase(start.const_item_pointer(), end.const_item_pointer());
- ipointer retval = (*this).ibegin();
- retval.advance(msev_int(retval_pos.position()));
- return retval;
- }
- ipointer erase_inclusive(const cipointer &first, const cipointer &last) {
- auto end = last; end.set_to_next();
- return erase(first, end);
- }
- void erase_previous_item(const mm_const_iterator_type &pos) {
- if (pos.m_owner_cptr != this) { MSE_THROW(msevector_range_error("invalid arguments - void erase_previous_item() - msevector")); }
- if (!(pos.has_previous())) { MSE_THROW(msevector_range_error("invalid arguments - void erase_previous_item() - msevector")); }
- typename base_class::const_iterator _P = pos;
- _P--;
- (*this).erase(_P);
- }
- ipointer erase_previous_item(const cipointer &pos) {
- erase_previous_item(pos.const_item_pointer());
- ipointer retval = (*this).ibegin();
- retval.advance(pos.position());
- return retval;
- }
-
-
- /* ss_const_iterator_type is a bounds checked iterator. */
- class ss_const_iterator_type : public random_access_const_iterator_base {
- public:
- typedef typename base_class::const_iterator::iterator_category iterator_category;
- typedef typename base_class::const_iterator::value_type value_type;
- //typedef typename base_class::const_iterator::difference_type difference_type;
- typedef typename _Myt::difference_type difference_type;
- typedef difference_type distance_type; // retained
- typedef typename base_class::const_iterator::pointer pointer;
- typedef typename base_class::const_pointer const_pointer;
- typedef typename base_class::const_iterator::reference reference;
- typedef typename base_class::const_reference const_reference;
-
- ss_const_iterator_type() {}
- void assert_valid_index() const {
- if (m_owner_cptr->size() < m_index) { MSE_THROW(msevector_range_error("invalid index - void assert_valid_index() const - ss_const_iterator_type - msevector")); }
- }
- void reset() { set_to_end_marker(); }
- bool points_to_an_item() const {
- if (m_owner_cptr->size() > m_index) { return true; }
- else {
- if (m_index == m_owner_cptr->size()) { return false; }
- else { MSE_THROW(msevector_range_error("attempt to use invalid ss_const_iterator_type - bool points_to_an_item() const - ss_const_iterator_type - msevector")); }
- }
- }
- bool points_to_end_marker() const {
- if (false == points_to_an_item()) {
- assert(m_index == m_owner_cptr->size());
- return true;
- }
- else { return false; }
- }
- bool points_to_beginning() const {
- if (0 == m_index) { return true; }
- else { return false; }
- }
- /* has_next_item_or_end_marker() is just an alias for points_to_an_item(). */
- bool has_next_item_or_end_marker() const { return points_to_an_item(); }
- /* has_next() is just an alias for points_to_an_item() that's familiar to java programmers. */
- bool has_next() const { return has_next_item_or_end_marker(); }
- bool has_previous() const {
- if (m_owner_cptr->size() < m_index) {
- MSE_THROW(msevector_range_error("attempt to use invalid ss_const_iterator_type - bool has_previous() const - ss_const_iterator_type - msevector"));
- }
- else if (1 <= m_index) {
- return true;
- }
- else {
- return false;
- }
- }
- void set_to_beginning() {
- m_index = 0;
- }
- void set_to_end_marker() {
- m_index = m_owner_cptr->size();
- }
- void set_to_next() {
- if (points_to_an_item()) {
- m_index += 1;
- }
- else {
- MSE_THROW(msevector_range_error("attempt to use invalid const_item_pointer - void set_to_next() - ss_const_iterator_type - msevector"));
- }
- }
- void set_to_previous() {
- if (has_previous()) {
- m_index -= 1;
- }
- else {
- MSE_THROW(msevector_range_error("attempt to use invalid const_item_pointer - void set_to_previous() - ss_const_iterator_type - msevector"));
- }
- }
- ss_const_iterator_type& operator ++() { (*this).set_to_next(); return (*this); }
- ss_const_iterator_type operator++(int) { ss_const_iterator_type _Tmp = *this; (*this).set_to_next(); return (_Tmp); }
- ss_const_iterator_type& operator --() { (*this).set_to_previous(); return (*this); }
- ss_const_iterator_type operator--(int) { ss_const_iterator_type _Tmp = *this; (*this).set_to_previous(); return (_Tmp); }
- void advance(difference_type n) {
- auto new_index = msev_int(m_index) + n;
- if ((0 > new_index) || (m_owner_cptr->size() < msev_size_t(new_index))) {
- MSE_THROW(msevector_range_error("index out of range - void advance(difference_type n) - ss_const_iterator_type - msevector"));
- }
- else {
- m_index = msev_size_t(new_index);
- }
- }
- void regress(difference_type n) { advance(-n); }
- ss_const_iterator_type& operator +=(difference_type n) { (*this).advance(n); return (*this); }
- ss_const_iterator_type& operator -=(difference_type n) { (*this).regress(n); return (*this); }
- ss_const_iterator_type operator+(difference_type n) const {
- ss_const_iterator_type retval; retval.m_owner_cptr = m_owner_cptr;
- retval = (*this);
- retval.advance(n);
- return retval;
- }
- ss_const_iterator_type operator-(difference_type n) const { return ((*this) + (-n)); }
- difference_type operator-(const ss_const_iterator_type &rhs) const {
- if (rhs.m_owner_cptr != (*this).m_owner_cptr) { MSE_THROW(msevector_range_error("invalid argument - difference_type operator-(const ss_const_iterator_type &rhs) const - msevector::ss_const_iterator_type")); }
- auto retval = difference_type((*this).m_index) - difference_type(rhs.m_index);
- assert(difference_type((*m_owner_cptr).size()) >= retval);
- return retval;
- }
- const_reference operator*() const {
- return (*m_owner_cptr).at(msev_as_a_size_t((*this).m_index));
- }
- const_reference item() const { return operator*(); }
- const_reference previous_item() const {
- return m_owner_cptr->at(msev_as_a_size_t(m_index - 1));
- }
- const_pointer operator->() const {
- return &((*m_owner_cptr).at(msev_as_a_size_t((*this).m_index)));
- }
- const_reference operator[](difference_type _Off) const { return (*m_owner_cptr).at(msev_as_a_size_t(difference_type(m_index) + _Off)); }
- /*
- ss_const_iterator_type& operator=(const typename base_class::const_iterator& _Right_cref)
- {
- msev_int d = std::distance<typename base_class::iterator>(m_owner_cptr->cbegin(), _Right_cref);
- if ((0 <= d) && (m_owner_cptr->size() >= d)) {
- if (m_owner_cptr->size() == d) {
- assert(m_owner_cptr->cend() == _Right_cref);
- }
- m_index = msev_size_t(d);
- base_class::const_iterator::operator=(_Right_cref);
- }
- else {
- MSE_THROW(msevector_range_error("doesn't seem to be a valid assignment value - ss_const_iterator_type& operator=(const typename base_class::const_iterator& _Right_cref) - ss_const_iterator_type - msevector"));
- }
- return (*this);
- }
- */
- ss_const_iterator_type& operator=(const ss_const_iterator_type& _Right_cref) {
- ((*this).m_owner_cptr) = _Right_cref.m_owner_cptr;
- (*this).m_index = _Right_cref.m_index;
- return (*this);
- }
- bool operator==(const ss_const_iterator_type& _Right_cref) const {
- if (this->m_owner_cptr != _Right_cref.m_owner_cptr) { MSE_THROW(msevector_range_error("invalid argument - ss_const_iterator_type& operator==(const ss_const_iterator_type& _Right) - ss_const_iterator_type - msevector")); }
- return (_Right_cref.m_index == m_index);
- }
- bool operator!=(const ss_const_iterator_type& _Right_cref) const { return (!(_Right_cref == (*this))); }
- bool operator<(const ss_const_iterator_type& _Right) const {
- if (this->m_owner_cptr != _Right.m_owner_cptr) { MSE_THROW(msevector_range_error("invalid argument - ss_const_iterator_type& operator<(const ss_const_iterator_type& _Right) - ss_const_iterator_type - msevector")); }
- return (m_index < _Right.m_index);
- }
- bool operator<=(const ss_const_iterator_type& _Right) const { return (((*this) < _Right) || (_Right == (*this))); }
- bool operator>(const ss_const_iterator_type& _Right) const { return (!((*this) <= _Right)); }
- bool operator>=(const ss_const_iterator_type& _Right) const { return (!((*this) < _Right)); }
- void set_to_const_item_pointer(const ss_const_iterator_type& _Right_cref) {
- (*this) = _Right_cref;
- }
- void invalidate_inclusive_range(msev_size_t index_of_first, msev_size_t index_of_last) {
- if ((index_of_first <= (*this).m_index) && (index_of_last >= (*this).m_index)) {
- (*this).reset();
- }
- }
- void shift_inclusive_range(msev_size_t index_of_first, msev_size_t index_of_last, msev_int shift) {
- if ((index_of_first <= (*this).m_index) && (index_of_last >= (*this).m_index)) {
- auto new_index = (*this).m_index + shift;
- if ((0 > new_index) || (m_owner_cptr->size() < new_index)) {
- MSE_THROW(msevector_range_error("void shift_inclusive_range() - ss_const_iterator_type - msevector"));
- }
- else {
- (*this).m_index = msev_size_t(new_index);
- (*this).sync_const_iterator_to_index();
- }
- }
- }
- msev_size_t position() const {
- return m_index;
- }
- operator typename base_class::const_iterator() const {
- typename base_class::const_iterator retval = (*m_owner_cptr).cbegin();
- retval += msev_as_a_size_t(m_index);
- return retval;
- }
- private:
- void sync_const_iterator_to_index() {
- assert(m_owner_cptr->size() >= (*this).m_index);
- //base_class::const_iterator::operator=(m_owner_cptr->cbegin());
- //base_class::const_iterator::operator+=(msev_as_a_size_t(m_index));
- }
- msev_size_t m_index = 0;
- msev_pointer<const _Myt> m_owner_cptr = nullptr;
- friend class /*_Myt*/msevector<_Ty, _A>;
- };
- /* ss_iterator_type is a bounds checked iterator. */
- class ss_iterator_type : public random_access_iterator_base {
- public:
- typedef typename base_class::iterator::iterator_category iterator_category;
- typedef typename base_class::iterator::value_type value_type;
- //typedef typename base_class::iterator::difference_type difference_type;
- typedef typename _Myt::difference_type difference_type;
- typedef difference_type distance_type; // retained
- typedef typename base_class::iterator::pointer pointer;
- typedef typename base_class::iterator::reference reference;
-
- ss_iterator_type() {}
- void reset() { set_to_end_marker(); }
- bool points_to_an_item() const {
- if (m_owner_ptr->size() > m_index) { return true; }
- else {
- if (m_index == m_owner_ptr->size()) { return false; }
- else { MSE_THROW(msevector_range_error("attempt to use invalid ss_iterator_type - bool points_to_an_item() const - ss_iterator_type - msevector")); }
- }
- }
- bool points_to_end_marker() const {
- if (false == points_to_an_item()) {
- assert(m_index == m_owner_ptr->size());
- return true;
- }
- else { return false; }
- }
- bool points_to_beginning() const {
- if (0 == m_index) { return true; }
- else { return false; }
- }
- /* has_next_item_or_end_marker() is just an alias for points_to_an_item(). */
- bool has_next_item_or_end_marker() const { return points_to_an_item(); }
- /* has_next() is just an alias for points_to_an_item() that's familiar to java programmers. */
- bool has_next() const { return has_next_item_or_end_marker(); }
- bool has_previous() const {
- if (m_owner_ptr->size() < m_index) {
- MSE_THROW(msevector_range_error("attempt to use invalid ss_iterator_type - bool has_previous() const - ss_iterator_type - msevector"));
- } else if (1 <= m_index) {
- return true;
- }
- else {
- return false;
- }
- }
- void set_to_beginning() {
- m_index = 0;
- }
- void set_to_end_marker() {
- m_index = m_owner_ptr->size();
- }
- void set_to_next() {
- if (points_to_an_item()) {
- m_index += 1;
- }
- else {
- MSE_THROW(msevector_range_error("attempt to use invalid item_pointer - void set_to_next() - ss_const_iterator_type - msevector"));
- }
- }
- void set_to_previous() {
- if (has_previous()) {
- m_index -= 1;
- }
- else {
- MSE_THROW(msevector_range_error("attempt to use invalid item_pointer - void set_to_previous() - ss_iterator_type - msevector"));
- }
- }
- ss_iterator_type& operator ++() { (*this).set_to_next(); return (*this); }
- ss_iterator_type operator++(int) { ss_iterator_type _Tmp = *this; (*this).set_to_next(); return (_Tmp); }
- ss_iterator_type& operator --() { (*this).set_to_previous(); return (*this); }
- ss_iterator_type operator--(int) { ss_iterator_type _Tmp = *this; (*this).set_to_previous(); return (_Tmp); }
- void advance(difference_type n) {
- auto new_index = msev_int(m_index) + n;
- if ((0 > new_index) || (m_owner_ptr->size() < msev_size_t(new_index))) {
- MSE_THROW(msevector_range_error("index out of range - void advance(difference_type n) - ss_iterator_type - msevector"));
- }
- else {
- m_index = msev_size_t(new_index);
- }
- }
- void regress(difference_type n) { advance(-n); }
- ss_iterator_type& operator +=(difference_type n) { (*this).advance(n); return (*this); }
- ss_iterator_type& operator -=(difference_type n) { (*this).regress(n); return (*this); }
- ss_iterator_type operator+(difference_type n) const {
- ss_iterator_type retval; retval.m_owner_ptr = m_owner_ptr;
- retval = (*this);
- retval.advance(n);
- return retval;
- }
- ss_iterator_type operator-(difference_type n) const { return ((*this) + (-n)); }
- difference_type operator-(const ss_iterator_type& rhs) const {
- if (rhs.m_owner_ptr != (*this).m_owner_ptr) { MSE_THROW(msevector_range_error("invalid argument - difference_type operator-(const ss_iterator_type& rhs) const - msevector::ss_iterator_type")); }
- auto retval = difference_type((*this).m_index) - difference_type(rhs.m_index);
- assert(int((*m_owner_ptr).size()) >= retval);
- return retval;
- }
- reference operator*() const {
- return (*m_owner_ptr).at(msev_as_a_size_t((*this).m_index));
- }
- reference item() const { return operator*(); }
- reference previous_item() const {
- return m_owner_ptr->at(msev_as_a_size_t(m_index - 1));
- }
- pointer operator->() const {
- return &((*m_owner_ptr).at(msev_as_a_size_t((*this).m_index)));
- }
- reference operator[](difference_type _Off) const { return (*m_owner_ptr).at(msev_as_a_size_t(difference_type(m_index) + _Off)); }
- /*
- ss_iterator_type& operator=(const typename base_class::iterator& _Right_cref)
- {
- msev_int d = std::distance<typename base_class::iterator>(m_owner_ptr->begin(), _Right_cref);
- if ((0 <= d) && (m_owner_ptr->size() >= d)) {
- if (m_owner_ptr->size() == d) {
- assert(m_owner_ptr->end() == _Right_cref);
- }
- m_index = msev_size_t(d);
- base_class::iterator::operator=(_Right_cref);
- }
- else {
- MSE_THROW(msevector_range_error("doesn't seem to be a valid assignment value - ss_iterator_type& operator=(const typename base_class::iterator& _Right_cref) - ss_const_iterator_type - msevector"));
- }
- return (*this);
- }
- */
- ss_iterator_type& operator=(const ss_iterator_type& _Right_cref) {
- ((*this).m_owner_ptr) = _Right_cref.m_owner_ptr;
- (*this).m_index = _Right_cref.m_index;
- return (*this);
- }
- bool operator==(const ss_iterator_type& _Right_cref) const {
- if (this->m_owner_ptr != _Right_cref.m_owner_ptr) { MSE_THROW(msevector_range_error("invalid argument - ss_iterator_type& operator==(const ss_iterator_type& _Right) - ss_iterator_type - msevector")); }
- return (_Right_cref.m_index == m_index);
- }
- bool operator!=(const ss_iterator_type& _Right_cref) const { return (!(_Right_cref == (*this))); }
- bool operator<(const ss_iterator_type& _Right) const {
- if (this->m_owner_ptr != _Right.m_owner_ptr) { MSE_THROW(msevector_range_error("invalid argument - ss_iterator_type& operator<(const ss_iterator_type& _Right) - ss_iterator_type - msevector")); }
- return (m_index < _Right.m_index);
- }
- bool operator<=(const ss_iterator_type& _Right) const { return (((*this) < _Right) || (_Right == (*this))); }
- bool operator>(const ss_iterator_type& _Right) const { return (!((*this) <= _Right)); }
- bool operator>=(const ss_iterator_type& _Right) const { return (!((*this) < _Right)); }
- void set_to_item_pointer(const ss_iterator_type& _Right_cref) {
- (*this) = _Right_cref;
- }
- void invalidate_inclusive_range(msev_size_t index_of_first, msev_size_t index_of_last) {
- if ((index_of_first <= (*this).m_index) && (index_of_last >= (*this).m_index)) {
- (*this).reset();
- }
- }
- void shift_inclusive_range(msev_size_t index_of_first, msev_size_t index_of_last, msev_int shift) {
- if ((index_of_first <= (*this).m_index) && (index_of_last >= (*this).m_index)) {
- auto new_index = (*this).m_index + shift;
- if ((0 > new_index) || (m_owner_ptr->size() < new_index)) {
- MSE_THROW(msevector_range_error("void shift_inclusive_range() - ss_iterator_type - msevector"));
- }
- else {
- (*this).m_index = msev_size_t(new_index);
- (*this).sync_iterator_to_index();
- }
- }
- }
- msev_size_t position() const {
- return m_index;
- }
- operator ss_const_iterator_type() const {
- ss_const_iterator_type retval;
- if (nullptr != m_owner_ptr) {
- retval = m_owner_ptr->ss_cbegin();
- retval.advance(msev_int(m_index));
- }
- return retval;
- }
- operator typename base_class::iterator() const {
- typename base_class::iterator retval = (*m_owner_ptr).begin();
- retval += msev_as_a_size_t(m_index);
- return retval;
- }
-
- private:
- void sync_iterator_to_index() {
- assert(m_owner_ptr->size() >= (*this).m_index);
- //base_class::iterator::operator=(m_owner_ptr->begin());
- //base_class::iterator::operator+=(msev_as_a_size_t(m_index));
- }
- msev_size_t m_index = 0;
- msev_pointer<_Myt> m_owner_ptr = nullptr;
- friend class /*_Myt*/msevector<_Ty, _A>;
- };
- typedef std::reverse_iterator<ss_iterator_type> ss_reverse_iterator_type;
- typedef std::reverse_iterator<ss_const_iterator_type> ss_const_reverse_iterator_type;
-
- ss_iterator_type ss_begin()
- { // return base_class::iterator for beginning of mutable sequence
- ss_iterator_type retval; retval.m_owner_ptr = this;
- retval.set_to_beginning();
- return retval;
- }
-
- ss_const_iterator_type ss_begin() const
- { // return base_class::iterator for beginning of nonmutable sequence
- ss_const_iterator_type retval; retval.m_owner_cptr = this;
- retval.set_to_beginning();
- return retval;
- }
-
- ss_iterator_type ss_end()
- { // return base_class::iterator for end of mutable sequence
- ss_iterator_type retval; retval.m_owner_ptr = this;
- retval.set_to_end_marker();
- return retval;
- }
-
- ss_const_iterator_type ss_end() const
- { // return base_class::iterator for end of nonmutable sequence
- ss_const_iterator_type retval; retval.m_owner_cptr = this;
- retval.set_to_end_marker();
- return retval;
- }
-
- ss_const_iterator_type ss_cbegin() const
- { // return base_class::iterator for beginning of nonmutable sequence
- ss_const_iterator_type retval; retval.m_owner_cptr = this;
- retval.set_to_beginning();
- return retval;
- }
-
- ss_const_iterator_type ss_cend() const
- { // return base_class::iterator for end of nonmutable sequence
- ss_const_iterator_type retval; retval.m_owner_cptr = this;
- retval.set_to_end_marker();
- return retval;
- }
-
- ss_const_reverse_iterator_type ss_crbegin() const
- { // return base_class::iterator for beginning of reversed nonmutable sequence
- return (ss_rbegin());
- }
-
- ss_const_reverse_iterator_type ss_crend() const
- { // return base_class::iterator for end of reversed nonmutable sequence
- return (ss_rend());
- }
-
- ss_reverse_iterator_type ss_rbegin()
- { // return base_class::iterator for beginning of reversed mutable sequence
- return (reverse_iterator(ss_end()));
- }
-
- ss_const_reverse_iterator_type ss_rbegin() const
- { // return base_class::iterator for beginning of reversed nonmutable sequence
- return (const_reverse_iterator(ss_end()));
- }
-
- ss_reverse_iterator_type ss_rend()
- { // return base_class::iterator for end of reversed mutable sequence
- return (reverse_iterator(ss_begin()));
- }
-
- ss_const_reverse_iterator_type ss_rend() const
- { // return base_class::iterator for end of reversed nonmutable sequence
- return (const_reverse_iterator(ss_begin()));
- }
-
- msevector(const ss_const_iterator_type &start, const ss_const_iterator_type &end, const _A& _Al = _A())
- : base_class(_Al), m_mmitset(*this) {
- /*m_debug_size = size();*/
- assign(start, end);
- }
- void assign(const ss_const_iterator_type &start, const ss_const_iterator_type &end) {
- if (start.m_owner_cptr != end.m_owner_cptr) { MSE_THROW(msevector_range_error("invalid arguments - void assign(const ss_const_iterator_type &start, const ss_const_iterator_type &end) - msevector")); }
- if (start > end) { MSE_THROW(msevector_range_error("invalid arguments - void assign(const ss_const_iterator_type &start, const ss_const_iterator_type &end) - msevector")); }
- typename base_class::const_iterator _F = start;
- typename base_class::const_iterator _L = end;
- (*this).assign(_F, _L);
- }
- void assign_inclusive(const ss_const_iterator_type &first, const ss_const_iterator_type &last) {
- auto end = last;
- end++; // this should include some checks
- (*this).assign(first, end);
- }
- ss_iterator_type insert_before(const ss_const_iterator_type &pos, size_type _M, const _Ty& _X) {
- if (pos.m_owner_cptr != this) { MSE_THROW(msevector_range_error("invalid argument - void insert_before() - msevector")); }
- pos.assert_valid_index();
- msev_size_t original_pos = pos.position();
- typename base_class::const_iterator _P = pos;
- (*this).insert(_P, _M, _X);
- ss_iterator_type retval = ss_begin();
- retval.advance(msev_int(original_pos));
- return retval;
- }
- ss_iterator_type insert_before(const ss_const_iterator_type &pos, _Ty&& _X) {
- if (pos.m_owner_cptr != this) { MSE_THROW(msevector_range_error("invalid argument - void insert_before() - msevector")); }
- pos.assert_valid_index();
- msev_size_t original_pos = pos.position();
- typename base_class::const_iterator _P = pos;
- (*this).insert(_P, std::move(_X));
- ss_iterator_type retval = ss_begin();
- retval.advance(msev_int(original_pos));
- return retval;
- }
- ss_iterator_type insert_before(const ss_const_iterator_type &pos, const _Ty& _X = _Ty()) { return (*this).insert(pos, 1, _X); }
- template<class _Iter
- //>typename std::enable_if<_mse_Is_iterator<_Iter>::value, typename base_class::iterator>::type
- , class = _mse_RequireInputIter<_Iter> >
- ss_iterator_type insert_before(const ss_const_iterator_type &pos, const _Iter &start, const _Iter &end) {
- if (pos.m_owner_cptr != this) { MSE_THROW(msevector_range_error("invalid argument - ss_iterator_type insert_before() - msevector")); }
- //if (start.m_owner_cptr != end.m_owner_cptr) { MSE_THROW(msevector_range_error("invalid arguments - void insert_before(const ss_const_iterator_type &pos, const ss_const_iterator_type &start, const ss_const_iterator_type &end) - msevector")); }
- pos.assert_valid_index();
- msev_size_t original_pos = pos.position();
- typename base_class::const_iterator _P = pos;
- (*this).insert(_P, start, end);
- ss_iterator_type retval = ss_begin();
- retval.advance(msev_int(original_pos));
- return retval;
- }
- ss_iterator_type insert_before(const ss_const_iterator_type &pos, const ss_const_iterator_type& start, const ss_const_iterator_type &end) {
- if (start.m_owner_cptr != end.m_owner_cptr) { MSE_THROW(msevector_range_error("invalid arguments - void insert_before(const ss_const_iterator_type &pos, const ss_const_iterator_type &start, const ss_const_iterator_type &end) - msevector")); }
- end.assert_valid_index();
- if (start > end) { MSE_THROW(msevector_range_error("invalid arguments - void insert_before(const ss_const_iterator_type &pos, const ss_const_iterator_type &start, const ss_const_iterator_type &end) - msevector")); }
- typename base_class::const_iterator _S = start;
- typename base_class::const_iterator _E = end;
- return (*this).insert_before(pos, _S, _E);
- }
- ss_iterator_type insert_before(const ss_const_iterator_type &pos, const _Ty* start, const _Ty* end) {
- if (pos.m_owner_cptr != this) { MSE_THROW(msevector_range_error("invalid arguments - ss_iterator_type insert_before() - msevector")); }
- //if (start.m_owner_cptr != end.m_owner_cptr) { MSE_THROW(msevector_range_error("invalid arguments - void insert_before(const ss_const_iterator_type &pos, const ss_const_iterator_type &start, const ss_const_iterator_type &end) - msevector")); }
- if (start > end) { MSE_THROW(msevector_range_error("invalid arguments - ss_iterator_type insert_before() - msevector")); }
- pos.assert_valid_index();
- msev_size_t original_pos = pos.position();
- typename base_class::const_iterator _P = pos;
- (*this).insert(_P, start, end);
- ss_iterator_type retval = ss_begin();
- retval.advance(msev_int(original_pos));
- return retval;
- }
- template<class _Iter
- //>typename std::enable_if<_mse_Is_iterator<_Iter>::value, typename base_class::iterator>::type
- , class = _mse_RequireInputIter<_Iter> >
- ss_iterator_type insert_before_inclusive(const ss_iterator_type &pos, const _Iter &first, const _Iter &last) {
- auto end = last;
- end++; // this may include some checks
- return (*this).insert_before(pos, first, end);
- }
- ss_iterator_type insert_before(const ss_const_iterator_type &pos, _XSTD initializer_list<typename base_class::value_type> _Ilist) { // insert initializer_list
- if (pos.m_owner_ptr != this) { MSE_THROW(msevector_range_error("invalid arguments - void insert_before() - msevector")); }
- pos.assert_valid_index();
- msev_size_t original_pos = pos.position();
- typename base_class::const_iterator _P = pos;
- (*this).insert(_P, _Ilist);
- ss_iterator_type retval = ss_begin();
- retval.advance(msev_int(original_pos));
- return retval;
- }
- /* These insert() functions are just aliases for their corresponding insert_before() functions. */
- ss_iterator_type insert(const ss_const_iterator_type &pos, size_type _M, const _Ty& _X) { return insert_before(pos, _M, _X); }
- ss_iterator_type insert(const ss_const_iterator_type &pos, _Ty&& _X) { return insert_before(pos, std::move(_X)); }
- ss_iterator_type insert(const ss_const_iterator_type &pos, const _Ty& _X = _Ty()) { return insert_before(pos, _X); }
- template<class _Iter
- //>typename std::enable_if<_mse_Is_iterator<_Iter>::value, typename base_class::iterator>::type
- , class = _mse_RequireInputIter<_Iter> >
- ss_iterator_type insert(const ss_const_iterator_type &pos, const _Iter &start, const _Iter &end) { return insert_before(pos, start, end); }
- ss_iterator_type insert(const ss_const_iterator_type &pos, const _Ty* start, const _Ty* &end) { return insert_before(pos, start, end); }
- ss_iterator_type insert(const ss_const_iterator_type &pos, _XSTD initializer_list<typename base_class::value_type> _Ilist) { return insert_before(pos, _Ilist); }
- template<class ..._Valty>
-#if !(defined(GPP4P8_COMPATIBLE))
- ss_iterator_type emplace(const ss_const_iterator_type &pos, _Valty&& ..._Val)
- { // insert by moving _Val at pos
- if (pos.m_owner_cptr != this) { MSE_THROW(msevector_range_error("invalid arguments - void emplace() - msevector")); }
-#else /*!(defined(GPP4P8_COMPATIBLE))*/
- ipointer emplace(const ipointer &pos, _Valty&& ..._Val)
- { // insert by moving _Val at pos
- if (pos.m_owner_ptr != this) { MSE_THROW(msevector_range_error("invalid arguments - void emplace() - msevector")); }
-#endif /*!(defined(GPP4P8_COMPATIBLE))*/
- pos.assert_valid_index();
- msev_size_t original_pos = pos.position();
- typename base_class::const_iterator _P = pos;
- (*this).emplace(_P, std::forward<_Valty>(_Val)...);
- ss_iterator_type retval = ss_begin();
- retval.advance(msev_int(original_pos));
- return retval;
- }
- ss_iterator_type erase(const ss_const_iterator_type &pos) {
- if (pos.m_owner_cptr != this) { MSE_THROW(msevector_range_error("invalid arguments - void erase() - msevector")); }
- if (!pos.points_to_an_item()) { MSE_THROW(msevector_range_error("invalid arguments - void erase() - msevector")); }
- auto pos_index = pos.position();
-
- typename base_class::const_iterator _P = pos;
- (*this).erase(_P);
-
- ss_iterator_type retval = (*this).ss_begin();
- retval.advance(typename ss_const_iterator_type::difference_type(pos_index));
- return retval;
- }
- ss_iterator_type erase(const ss_const_iterator_type &start, const ss_const_iterator_type &end) {
- if (start.m_owner_cptr != this) { MSE_THROW(msevector_range_error("invalid arguments - void erase() - msevector")); }
- if (end.m_owner_cptr != this) { MSE_THROW(msevector_range_error("invalid arguments - void erase() - msevector")); }
- if (start.position() > end.position()) { MSE_THROW(msevector_range_error("invalid arguments - void erase() - msevector")); }
- auto pos_index = start.position();
-
- typename base_class::const_iterator _F = start;
- typename base_class::const_iterator _L = end;
- (*this).erase(_F, _L);
-
- ss_iterator_type retval = (*this).ss_begin();
- retval.advance(typename ss_const_iterator_type::difference_type(pos_index));
- return retval;
- }
- ss_iterator_type erase_inclusive(const ss_const_iterator_type &first, const ss_const_iterator_type &last) {
- auto end = last; end.set_to_next();
- return erase(first, end);
- }
- void erase_previous_item(const ss_const_iterator_type &pos) {
- if (pos.m_owner_cptr != this) { MSE_THROW(msevector_range_error("invalid arguments - void erase_previous_item() - msevector")); }
- if (!(pos.has_previous())) { MSE_THROW(msevector_range_error("invalid arguments - void erase_previous_item() - msevector")); }
- typename base_class::const_iterator _P = pos;
- _P--;
- (*this).erase(_P);
- }
- };
-
-}
-
-#undef MSE_THROW
-
-#endif /*ndef MSEMSEVECTOR_H*/
diff --git a/src/debug/mse/msemstdvector.h b/src/debug/mse/msemstdvector.h
deleted file mode 100644
index fa7d848bc..000000000
--- a/src/debug/mse/msemstdvector.h
+++ /dev/null
@@ -1,413 +0,0 @@
-
-// Copyright (c) 2015 Noah Lopez
-// Use, modification, and distribution is subject to the Boost Software
-// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-
-#ifndef MSEMSTDVECTOR_H
-#define MSEMSTDVECTOR_H
-
-#include "debug/mse/msemsevector.h"
-
-#ifdef MSE_SAFER_SUBSTITUTES_DISABLED
-#define MSE_MSTDVECTOR_DISABLED
-#endif /*MSE_SAFER_SUBSTITUTES_DISABLED*/
-
-namespace mse {
-
- namespace mstd {
-
-#ifdef MSE_MSTDVECTOR_DISABLED
- template<class _Ty, class _A = std::allocator<_Ty> > using vector = std::vector<_Ty, _A>;
-
-#else /*MSE_MSTDVECTOR_DISABLED*/
-
-#ifndef _NOEXCEPT
-#define _NOEXCEPT
-#endif /*_NOEXCEPT*/
-
- template<class _Ty, class _A = std::allocator<_Ty> >
- class vector {
- public:
- typedef mse::mstd::vector<_Ty, _A> _Myt;
- typedef mse::msevector<_Ty, _A> _MV;
-
- typedef typename _MV::allocator_type allocator_type;
- typedef typename _MV::value_type value_type;
- typedef typename _MV::size_type size_type;
- typedef typename _MV::difference_type difference_type;
- typedef typename _MV::pointer pointer;
- typedef typename _MV::const_pointer const_pointer;
- typedef typename _MV::reference reference;
- typedef typename _MV::const_reference const_reference;
-
- const _MV& msevector() const { return (*m_shptr); }
- _MV& msevector() { return (*m_shptr); }
- operator const _MV() const { return msevector(); }
- operator _MV() { return msevector(); }
-
- explicit vector(const _A& _Al = _A()) : m_shptr(std::make_shared<_MV>(_Al)) {}
- explicit vector(size_type _N) : m_shptr(std::make_shared<_MV>(_N)) {}
- explicit vector(size_type _N, const _Ty& _V, const _A& _Al = _A()) : m_shptr(std::make_shared<_MV>(_N, _V, _Al)) {}
- vector(_Myt&& _X) : m_shptr(std::make_shared<_MV>(std::move(_X.msevector()))) {}
- vector(const _Myt& _X) : m_shptr(std::make_shared<_MV>(_X.msevector())) {}
- vector(_MV&& _X) : m_shptr(std::make_shared<_MV>(std::move(_X))) {}
- vector(const _MV& _X) : m_shptr(std::make_shared<_MV>(_X)) {}
- vector(std::vector<_Ty>&& _X) : m_shptr(std::make_shared<_MV>(std::move(_X))) {}
- vector(const std::vector<_Ty>& _X) : m_shptr(std::make_shared<_MV>(_X)) {}
- typedef typename _MV::const_iterator _It;
- vector(_It _F, _It _L, const _A& _Al = _A()) : m_shptr(std::make_shared<_MV>(_F, _L, _Al)) {}
- vector(const _Ty* _F, const _Ty* _L, const _A& _Al = _A()) : m_shptr(std::make_shared<_MV>(_F, _L, _Al)) {}
- template<class _Iter, class = typename std::enable_if<_mse_Is_iterator<_Iter>::value, void>::type>
- vector(_Iter _First, _Iter _Last) : m_shptr(std::make_shared<_MV>(_First, _Last)) {}
- template<class _Iter, class = typename std::enable_if<_mse_Is_iterator<_Iter>::value, void>::type>
- vector(_Iter _First, _Iter _Last, const _A& _Al) : m_shptr(std::make_shared<_MV>(_First, _Last, _Al)) {}
-
- _Myt& operator=(_MV&& _X) { m_shptr->operator=(std::move(_X)); return (*this); }
- _Myt& operator=(const _MV& _X) { m_shptr->operator=(_X); return (*this); }
- _Myt& operator=(_Myt&& _X) { m_shptr->operator=(std::move(_X.msevector())); return (*this); }
- _Myt& operator=(const _Myt& _X) { m_shptr->operator=(_X.msevector()); return (*this); }
- void reserve(size_type _Count) { m_shptr->reserve(_Count); }
- void resize(size_type _N, const _Ty& _X = _Ty()) { m_shptr->resize(_N, _X); }
- typename _MV::const_reference operator[](size_type _P) const { return m_shptr->operator[](_P); }
- typename _MV::reference operator[](size_type _P) { return m_shptr->operator[](_P); }
- void push_back(_Ty&& _X) { m_shptr->push_back(std::move(_X)); }
- void push_back(const _Ty& _X) { m_shptr->push_back(_X); }
- void pop_back() { m_shptr->pop_back(); }
- void assign(_It _F, _It _L) { m_shptr->assign(_F, _L); }
- void assign(size_type _N, const _Ty& _X = _Ty()) { m_shptr->assign(_N, _X); }
- template<class ..._Valty>
- void emplace_back(_Valty&& ..._Val) { m_shptr->emplace_back(std::forward<_Valty>(_Val)...); }
- void clear() { m_shptr->clear(); }
- void swap(_MV& _X) { m_shptr->swap(_X); }
- void swap(_Myt& _X) { m_shptr->swap(_X.msevector()); }
-
- vector(_XSTD initializer_list<typename _MV::value_type> _Ilist, const _A& _Al = _A()) : m_shptr(std::make_shared<_MV>(_Ilist, _Al)) {}
- _Myt& operator=(_XSTD initializer_list<typename _MV::value_type> _Ilist) { m_shptr->operator=(_Ilist); return (*this); }
- void assign(_XSTD initializer_list<typename _MV::value_type> _Ilist) { m_shptr->assign(_Ilist); }
-
- size_type capacity() const _NOEXCEPT{ return m_shptr->capacity(); }
- void shrink_to_fit() { m_shptr->shrink_to_fit(); }
- size_type size() const _NOEXCEPT{ return m_shptr->size(); }
- size_type max_size() const _NOEXCEPT{ return m_shptr->max_size(); }
- bool empty() const _NOEXCEPT{ return m_shptr->empty(); }
- _A get_allocator() const _NOEXCEPT{ return m_shptr->get_allocator(); }
- typename _MV::const_reference at(size_type _Pos) const { return m_shptr->at(_Pos); }
- typename _MV::reference at(size_type _Pos) { return m_shptr->at(_Pos); }
- typename _MV::reference front() { return m_shptr->front(); }
- typename _MV::const_reference front() const { return m_shptr->front(); }
- typename _MV::reference back() { return m_shptr->back(); }
- typename _MV::const_reference back() const { return m_shptr->back(); }
-
- /* Try to avoid using these whenever possible. */
- value_type *data() _NOEXCEPT {
- return m_shptr->data();
- }
- const value_type *data() const _NOEXCEPT {
- return m_shptr->data();
- }
-
-
- class const_iterator : public _MV::random_access_const_iterator_base {
- public:
- typedef typename _MV::ss_const_iterator_type::iterator_category iterator_category;
- typedef typename _MV::ss_const_iterator_type::value_type value_type;
- typedef typename _MV::ss_const_iterator_type::difference_type difference_type;
- typedef typename _MV::difference_type distance_type; // retained
- typedef typename _MV::ss_const_iterator_type::pointer pointer;
- typedef typename _MV::ss_const_iterator_type::reference reference;
-
- const_iterator() {}
- const_iterator(const const_iterator& src_cref) : m_msevector_cshptr(src_cref.m_msevector_cshptr) {
- (*this) = src_cref;
- }
- ~const_iterator() {}
- const typename _MV::ss_const_iterator_type& msevector_ss_const_iterator_type() const { return m_ss_const_iterator; }
- typename _MV::ss_const_iterator_type& msevector_ss_const_iterator_type() { return m_ss_const_iterator; }
- const typename _MV::ss_const_iterator_type& mvssci() const { return msevector_ss_const_iterator_type(); }
- typename _MV::ss_const_iterator_type& mvssci() { return msevector_ss_const_iterator_type(); }
-
- void reset() { msevector_ss_const_iterator_type().reset(); }
- bool points_to_an_item() const { return msevector_ss_const_iterator_type().points_to_an_item(); }
- bool points_to_end_marker() const { return msevector_ss_const_iterator_type().points_to_end_marker(); }
- bool points_to_beginning() const { return msevector_ss_const_iterator_type().points_to_beginning(); }
- /* has_next_item_or_end_marker() is just an alias for points_to_an_item(). */
- bool has_next_item_or_end_marker() const { return msevector_ss_const_iterator_type().has_next_item_or_end_marker(); }
- /* has_next() is just an alias for points_to_an_item() that's familiar to java programmers. */
- bool has_next() const { return msevector_ss_const_iterator_type().has_next(); }
- bool has_previous() const { return msevector_ss_const_iterator_type().has_previous(); }
- void set_to_beginning() { msevector_ss_const_iterator_type().set_to_beginning(); }
- void set_to_end_marker() { msevector_ss_const_iterator_type().set_to_end_marker(); }
- void set_to_next() { msevector_ss_const_iterator_type().set_to_next(); }
- void set_to_previous() { msevector_ss_const_iterator_type().set_to_previous(); }
- const_iterator& operator ++() { msevector_ss_const_iterator_type().operator ++(); return (*this); }
- const_iterator operator++(int) { const_iterator _Tmp = *this; ++*this; return (_Tmp); }
- const_iterator& operator --() { msevector_ss_const_iterator_type().operator --(); return (*this); }
- const_iterator operator--(int) { const_iterator _Tmp = *this; --*this; return (_Tmp); }
- void advance(typename _MV::difference_type n) { msevector_ss_const_iterator_type().advance(n); }
- void regress(typename _MV::difference_type n) { msevector_ss_const_iterator_type().regress(n); }
- const_iterator& operator +=(difference_type n) { msevector_ss_const_iterator_type().operator +=(n); return (*this); }
- const_iterator& operator -=(difference_type n) { msevector_ss_const_iterator_type().operator -=(n); return (*this); }
- const_iterator operator+(difference_type n) const { auto retval = (*this); retval += n; return retval; }
- const_iterator operator-(difference_type n) const { return ((*this) + (-n)); }
- typename _MV::difference_type operator-(const const_iterator& _Right_cref) const { return msevector_ss_const_iterator_type() - (_Right_cref.msevector_ss_const_iterator_type()); }
- typename _MV::const_reference operator*() const { return msevector_ss_const_iterator_type().operator*(); }
- typename _MV::const_reference item() const { return operator*(); }
- typename _MV::const_reference previous_item() const { return msevector_ss_const_iterator_type().previous_item(); }
- typename _MV::const_pointer operator->() const { return msevector_ss_const_iterator_type().operator->(); }
- typename _MV::const_reference operator[](typename _MV::difference_type _Off) const { return (*(*this + _Off)); }
- bool operator==(const const_iterator& _Right_cref) const { return msevector_ss_const_iterator_type().operator==(_Right_cref.msevector_ss_const_iterator_type()); }
- bool operator!=(const const_iterator& _Right_cref) const { return (!(_Right_cref == (*this))); }
- bool operator<(const const_iterator& _Right) const { return (msevector_ss_const_iterator_type() < _Right.msevector_ss_const_iterator_type()); }
- bool operator<=(const const_iterator& _Right) const { return (msevector_ss_const_iterator_type() <= _Right.msevector_ss_const_iterator_type()); }
- bool operator>(const const_iterator& _Right) const { return (msevector_ss_const_iterator_type() > _Right.msevector_ss_const_iterator_type()); }
- bool operator>=(const const_iterator& _Right) const { return (msevector_ss_const_iterator_type() >= _Right.msevector_ss_const_iterator_type()); }
- void set_to_const_item_pointer(const const_iterator& _Right_cref) { msevector_ss_const_iterator_type().set_to_const_item_pointer(_Right_cref.msevector_ss_const_iterator_type()); }
- msev_size_t position() const { return msevector_ss_const_iterator_type().position(); }
- private:
- const_iterator(std::shared_ptr<_MV> msevector_shptr) : m_msevector_cshptr(msevector_shptr) {
- m_ss_const_iterator = msevector_shptr->ss_cbegin();
- }
- std::shared_ptr<const _MV> m_msevector_cshptr;
- /* m_ss_const_iterator needs to be declared after m_msevector_cshptr so that it's destructor will be called first. */
- typename _MV::ss_const_iterator_type m_ss_const_iterator;
- friend class /*_Myt*/vector<_Ty, _A>;
- friend class iterator;
- };
- class iterator : public _MV::random_access_iterator_base {
- public:
- typedef typename _MV::ss_iterator_type::iterator_category iterator_category;
- typedef typename _MV::ss_iterator_type::value_type value_type;
- typedef typename _MV::ss_iterator_type::difference_type difference_type;
- typedef typename _MV::difference_type distance_type; // retained
- typedef typename _MV::ss_iterator_type::pointer pointer;
- typedef typename _MV::ss_iterator_type::reference reference;
-
- iterator() {}
- iterator(const iterator& src_cref) : m_msevector_shptr(src_cref.m_msevector_shptr) {
- (*this) = src_cref;
- }
- ~iterator() {}
- const typename _MV::ss_iterator_type& msevector_ss_iterator_type() const { return m_ss_iterator; }
- typename _MV::ss_iterator_type& msevector_ss_iterator_type() { return m_ss_iterator; }
- const typename _MV::ss_iterator_type& mvssi() const { return msevector_ss_iterator_type(); }
- typename _MV::ss_iterator_type& mvssi() { return msevector_ss_iterator_type(); }
- operator const_iterator() const {
- const_iterator retval(m_msevector_shptr);
- if (m_msevector_shptr) {
- retval.msevector_ss_const_iterator_type().set_to_beginning();
- retval.msevector_ss_const_iterator_type().advance(msev_int(msevector_ss_iterator_type().position()));
- }
- return retval;
- }
-
- void reset() { msevector_ss_iterator_type().reset(); }
- bool points_to_an_item() const { return msevector_ss_iterator_type().points_to_an_item(); }
- bool points_to_end_marker() const { return msevector_ss_iterator_type().points_to_end_marker(); }
- bool points_to_beginning() const { return msevector_ss_iterator_type().points_to_beginning(); }
- /* has_next_item_or_end_marker() is just an alias for points_to_an_item(). */
- bool has_next_item_or_end_marker() const { return msevector_ss_iterator_type().has_next_item_or_end_marker(); }
- /* has_next() is just an alias for points_to_an_item() that's familiar to java programmers. */
- bool has_next() const { return msevector_ss_iterator_type().has_next(); }
- bool has_previous() const { return msevector_ss_iterator_type().has_previous(); }
- void set_to_beginning() { msevector_ss_iterator_type().set_to_beginning(); }
- void set_to_end_marker() { msevector_ss_iterator_type().set_to_end_marker(); }
- void set_to_next() { msevector_ss_iterator_type().set_to_next(); }
- void set_to_previous() { msevector_ss_iterator_type().set_to_previous(); }
- iterator& operator ++() { msevector_ss_iterator_type().operator ++(); return (*this); }
- iterator operator++(int) { iterator _Tmp = *this; ++*this; return (_Tmp); }
- iterator& operator --() { msevector_ss_iterator_type().operator --(); return (*this); }
- iterator operator--(int) { iterator _Tmp = *this; --*this; return (_Tmp); }
- void advance(typename _MV::difference_type n) { msevector_ss_iterator_type().advance(n); }
- void regress(typename _MV::difference_type n) { msevector_ss_iterator_type().regress(n); }
- iterator& operator +=(difference_type n) { msevector_ss_iterator_type().operator +=(n); return (*this); }
- iterator& operator -=(difference_type n) { msevector_ss_iterator_type().operator -=(n); return (*this); }
- iterator operator+(difference_type n) const { auto retval = (*this); retval += n; return retval; }
- iterator operator-(difference_type n) const { return ((*this) + (-n)); }
- typename _MV::difference_type operator-(const iterator& _Right_cref) const { return msevector_ss_iterator_type() - (_Right_cref.msevector_ss_iterator_type()); }
- typename _MV::reference operator*() const { return msevector_ss_iterator_type().operator*(); }
- typename _MV::reference item() const { return operator*(); }
- typename _MV::reference previous_item() const { return msevector_ss_iterator_type().previous_item(); }
- typename _MV::pointer operator->() const { return msevector_ss_iterator_type().operator->(); }
- typename _MV::reference operator[](typename _MV::difference_type _Off) const { return (*(*this + _Off)); }
- bool operator==(const iterator& _Right_cref) const { return msevector_ss_iterator_type().operator==(_Right_cref.msevector_ss_iterator_type()); }
- bool operator!=(const iterator& _Right_cref) const { return (!(_Right_cref == (*this))); }
- bool operator<(const iterator& _Right) const { return (msevector_ss_iterator_type() < _Right.msevector_ss_iterator_type()); }
- bool operator<=(const iterator& _Right) const { return (msevector_ss_iterator_type() <= _Right.msevector_ss_iterator_type()); }
- bool operator>(const iterator& _Right) const { return (msevector_ss_iterator_type() > _Right.msevector_ss_iterator_type()); }
- bool operator>=(const iterator& _Right) const { return (msevector_ss_iterator_type() >= _Right.msevector_ss_iterator_type()); }
- void set_to_item_pointer(const iterator& _Right_cref) { msevector_ss_iterator_type().set_to_item_pointer(_Right_cref.msevector_ss_iterator_type()); }
- msev_size_t position() const { return msevector_ss_iterator_type().position(); }
- private:
- std::shared_ptr<_MV> m_msevector_shptr;
- /* m_ss_iterator needs to be declared after m_msevector_shptr so that it's destructor will be called first. */
- typename _MV::ss_iterator_type m_ss_iterator;
- friend class /*_Myt*/vector<_Ty, _A>;
- };
-
- iterator begin() { // return iterator for beginning of mutable sequence
- iterator retval; retval.m_msevector_shptr = this->m_shptr;
- (retval.m_ss_iterator) = m_shptr->ss_begin();
- return retval;
- }
- const_iterator begin() const { // return iterator for beginning of nonmutable sequence
- const_iterator retval; retval.m_msevector_cshptr = this->m_shptr;
- (retval.m_ss_const_iterator) = m_shptr->ss_begin();
- return retval;
- }
- iterator end() { // return iterator for end of mutable sequence
- iterator retval; retval.m_msevector_shptr = this->m_shptr;
- (retval.m_ss_iterator) = m_shptr->ss_end();
- return retval;
- }
- const_iterator end() const { // return iterator for end of nonmutable sequence
- const_iterator retval; retval.m_msevector_cshptr = this->m_shptr;
- (retval.m_ss_const_iterator) = m_shptr->ss_end();
- return retval;
- }
- const_iterator cbegin() const { // return iterator for beginning of nonmutable sequence
- const_iterator retval; retval.m_msevector_cshptr = this->m_shptr;
- (retval.m_ss_const_iterator) = m_shptr->ss_cbegin();
- return retval;
- }
- const_iterator cend() const { // return iterator for end of nonmutable sequence
- const_iterator retval; retval.m_msevector_cshptr = this->m_shptr;
- (retval.m_ss_const_iterator) = m_shptr->ss_cend();
- return retval;
- }
-
- typedef std::reverse_iterator<iterator> reverse_iterator;
- typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
-
- reverse_iterator rbegin() { // return iterator for beginning of reversed mutable sequence
- return (reverse_iterator(end()));
- }
- const_reverse_iterator rbegin() const { // return iterator for beginning of reversed nonmutable sequence
- return (const_reverse_iterator(end()));
- }
- reverse_iterator rend() { // return iterator for end of reversed mutable sequence
- return (reverse_iterator(begin()));
- }
- const_reverse_iterator rend() const { // return iterator for end of reversed nonmutable sequence
- return (const_reverse_iterator(begin()));
- }
- const_reverse_iterator crbegin() const { // return iterator for beginning of reversed nonmutable sequence
- return (rbegin());
- }
- const_reverse_iterator crend() const { // return iterator for end of reversed nonmutable sequence
- return (rend());
- }
-
-
- vector(const const_iterator &start, const const_iterator &end, const _A& _Al = _A())
- : m_shptr(std::make_shared<_MV>(start.msevector_ss_const_iterator_type(), end.msevector_ss_const_iterator_type(), _Al)) {}
- void assign(const const_iterator &start, const const_iterator &end) {
- m_shptr->assign(start.msevector_ss_const_iterator_type(), end.msevector_ss_const_iterator_type());
- }
- void assign_inclusive(const const_iterator &first, const const_iterator &last) {
- m_shptr->assign_inclusive(first.msevector_ss_const_iterator_type(), last.msevector_ss_const_iterator_type());
- }
- iterator insert_before(const const_iterator &pos, size_type _M, const _Ty& _X) {
- auto res = m_shptr->insert_before(pos.msevector_ss_const_iterator_type(), _M, _X);
- iterator retval = begin(); retval.msevector_ss_iterator_type() = res;
- return retval;
- }
- iterator insert_before(const const_iterator &pos, _Ty&& _X) {
- auto res = m_shptr->insert_before(pos.msevector_ss_const_iterator_type(), std::move(_X));
- iterator retval = begin(); retval.msevector_ss_iterator_type() = res;
- return retval;
- }
- iterator insert_before(const const_iterator &pos, const _Ty& _X = _Ty()) { return insert_before(pos, 1, _X); }
- template<class _Iter
- //>typename std::enable_if<_mse_Is_iterator<_Iter>::value, typename base_class::iterator>::type
- , class = _mse_RequireInputIter<_Iter> >
- iterator insert_before(const const_iterator &pos, const _Iter &start, const _Iter &end) {
- auto res = m_shptr->insert_before(pos.msevector_ss_const_iterator_type(), start, end);
- iterator retval = begin(); retval.msevector_ss_iterator_type() = res;
- return retval;
- }
- template<class _Iter
- //>typename std::enable_if<_mse_Is_iterator<_Iter>::value, typename base_class::iterator>::type
- , class = _mse_RequireInputIter<_Iter> >
- iterator insert_before_inclusive(const const_iterator &pos, const _Iter &first, const _Iter &last) {
- auto end = last; end++;
- return insert_before(pos, first, end);
- }
- iterator insert_before(const const_iterator &pos, _XSTD initializer_list<typename _MV::value_type> _Ilist) { // insert initializer_list
- auto res = m_shptr->insert_before(pos.msevector_ss_const_iterator_type(), _Ilist);
- iterator retval = begin(); retval.msevector_ss_iterator_type() = res;
- return retval;
- }
- void insert_before(msev_size_t pos, const _Ty& _X = _Ty()) {
- m_shptr->insert_before(pos, _X);
- }
- void insert_before(msev_size_t pos, size_type _M, const _Ty& _X) {
- m_shptr->insert_before(pos, _M, _X);
- }
- void insert_before(msev_size_t pos, _XSTD initializer_list<typename _MV::value_type> _Ilist) { // insert initializer_list
- m_shptr->insert_before(pos, _Ilist);
- }
- /* These insert() functions are just aliases for their corresponding insert_before() functions. */
- iterator insert(const const_iterator &pos, size_type _M, const _Ty& _X) { return insert_before(pos, _M, _X); }
- iterator insert(const const_iterator &pos, _Ty&& _X) { return insert_before(pos, std::move(_X)); }
- iterator insert(const const_iterator &pos, const _Ty& _X = _Ty()) { return insert_before(pos, _X); }
- template<class _Iter
- //>typename std::enable_if<_mse_Is_iterator<_Iter>::value, typename base_class::iterator>::type
- , class = _mse_RequireInputIter<_Iter> >
- iterator insert(const const_iterator &pos, const _Iter &start, const _Iter &end) { return insert_before(pos, start, end); }
- iterator insert(const const_iterator &pos, const _Ty* start, const _Ty* end) { return insert_before(pos, start, end); }
- iterator insert(const const_iterator &pos, _XSTD initializer_list<typename _MV::value_type> _Ilist) { return insert_before(pos, _Ilist); }
- template<class ..._Valty>
- iterator emplace(const const_iterator &pos, _Valty&& ..._Val) {
- auto res = m_shptr->emplace(pos.msevector_ss_const_iterator_type(), std::forward<_Valty>(_Val)...);
- iterator retval = begin(); retval.msevector_ss_iterator_type() = res;
- return retval;
- }
- iterator erase(const const_iterator &pos) {
- auto res = m_shptr->erase(pos.msevector_ss_const_iterator_type());
- iterator retval = begin(); retval.msevector_ss_iterator_type() = res;
- return retval;
- }
- iterator erase(const const_iterator &start, const const_iterator &end) {
- auto res = m_shptr->erase(start.msevector_ss_const_iterator_type(), end.msevector_ss_const_iterator_type());
- iterator retval = begin(); retval.msevector_ss_iterator_type() = res;
- return retval;
- }
- iterator erase_inclusive(const const_iterator &first, const const_iterator &last) {
- auto end = last; end.set_to_next();
- return erase_inclusive(first, end);
- }
- bool operator==(const _Myt& _Right) const { // test for vector equality
- return ((*(_Right.m_shptr)) == (*m_shptr));
- }
- bool operator<(const _Myt& _Right) const { // test if _Left < _Right for vectors
- return ((*m_shptr) < (*(_Right.m_shptr)));
- }
-
- private:
- std::shared_ptr<_MV> m_shptr;
- };
-
- template<class _Ty, class _Alloc> inline bool operator!=(const vector<_Ty, _Alloc>& _Left,
- const vector<_Ty, _Alloc>& _Right) { // test for vector inequality
- return (!(_Left == _Right));
- }
-
- template<class _Ty, class _Alloc> inline bool operator>(const vector<_Ty, _Alloc>& _Left,
- const vector<_Ty, _Alloc>& _Right) { // test if _Left > _Right for vectors
- return (_Right < _Left);
- }
-
- template<class _Ty, class _Alloc> inline bool operator<=(const vector<_Ty, _Alloc>& _Left,
- const vector<_Ty, _Alloc>& _Right) { // test if _Left <= _Right for vectors
- return (!(_Right < _Left));
- }
-
- template<class _Ty, class _Alloc> inline bool operator>=(const vector<_Ty, _Alloc>& _Left,
- const vector<_Ty, _Alloc>& _Right) { // test if _Left >= _Right for vectors
- return (!(_Left < _Right));
- }
-#endif /*MSE_MSTDVECTOR_DISABLED*/
- }
-}
-#endif /*ndef MSEMSTDVECTOR_H*/
diff --git a/src/debug/mse/mseprimitives.h b/src/debug/mse/mseprimitives.h
deleted file mode 100644
index 951577834..000000000
--- a/src/debug/mse/mseprimitives.h
+++ /dev/null
@@ -1,872 +0,0 @@
-
-// Copyright (c) 2015 Noah Lopez
-// Use, modification, and distribution is subject to the Boost Software
-// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-
-#ifndef MSEPRIMITIVES_H
-#define MSEPRIMITIVES_H
-
-#include <assert.h>
-#include <climits> // ULONG_MAX
-#include <limits> // std::numeric_limits
-#include <stdexcept> // primitives_range_error
-
-/*compiler specific defines*/
-#ifdef _MSC_VER
-#if (1700 > _MSC_VER)
-#define MSVC2010_COMPATIBLE 1
-#endif /*(1700 > _MSC_VER)*/
-#if (1900 > _MSC_VER)
-#define MSVC2013_COMPATIBLE 1
-#endif /*(1900 > _MSC_VER)*/
-#if (2000 > _MSC_VER)
-#define MSVC2015_COMPATIBLE 1
-#endif /*(1900 > _MSC_VER)*/
-#else /*_MSC_VER*/
-#if (defined(__GNUC__) || defined(__GNUG__))
-#define GPP_COMPATIBLE 1
-#if ((5 > __GNUC__) && (!defined(__clang__)))
-#define GPP4P8_COMPATIBLE 1
-#endif /*((5 > __GNUC__) && (!defined(__clang__)))*/
-#endif /*(defined(__GNUC__) || defined(__GNUG__))*/
-#endif /*_MSC_VER*/
-
-#ifdef MSE_SAFER_SUBSTITUTES_DISABLED
-#define MSE_PRIMITIVES_DISABLED
-#endif /*MSE_SAFER_SUBSTITUTES_DISABLED*/
-
-#if defined(MSVC2013_COMPATIBLE) || defined(MSVC2010_COMPATIBLE)
-#define MSE_CONSTEXPR
-#else // defined(MSVC2013_COMPATIBLE) || defined(MSVC2010_COMPATIBLE)
-#define MSE_CONSTEXPR constexpr
-#endif // defined(MSVC2013_COMPATIBLE) || defined(MSVC2010_COMPATIBLE)
-
-#ifdef MSVC2015_COMPATIBLE
-#ifndef MSE_FORCE_PRIMITIVE_ASSIGN_RANGE_CHECK_ENABLED
-/* msvc2015's incomplete support for "constexpr" means that range checks that should be done at compile time would
-be done at run time, at significant cost. So by default we disable range checks upon assignment. */
-#define MSE_PRIMITIVE_ASSIGN_RANGE_CHECK_DISABLED 1
-#endif // !MSE_FORCE_PRIMITIVE_ASSIGN_RANGE_CHECK_ENABLED
-#endif // MSVC2015_COMPATIBLE
-
-
-#ifdef MSE_CUSTOM_THROW_DEFINITION
-#include <iostream>
-#define MSE_THROW(x) MSE_CUSTOM_THROW_DEFINITION(x)
-#else // MSE_CUSTOM_THROW_DEFINITION
-#define MSE_THROW(x) throw(x)
-#endif // MSE_CUSTOM_THROW_DEFINITION
-
-
-#ifndef MSE_CINT_BASE_INTEGER_TYPE
-#if SIZE_MAX <= ULONG_MAX
-#define MSE_CINT_BASE_INTEGER_TYPE long int
-#else // SIZE_MAX <= ULONG_MAX
-#define MSE_CINT_BASE_INTEGER_TYPE long long int
-#endif // SIZE_MAX <= ULONG_MAX
-#endif // !MSE_CINT_BASE_INTEGER_TYPE
-
-
-namespace mse {
-
- class primitives_range_error : public std::range_error {
- public:
- using std::range_error::range_error;
- };
-
- /* When the mse primitive replacements are "disabled" they lose their default initialization and may cause problems for
- code that relies on it. */
-#ifdef MSE_PRIMITIVES_DISABLED
- typedef bool CBool;
- typedef MSE_CINT_BASE_INTEGER_TYPE CInt;
- typedef size_t CSize_t;
- static size_t as_a_size_t(CSize_t n) { return (n); }
-#else /*MSE_PRIMITIVES_DISABLED*/
-
-#ifndef NDEBUG
-#ifndef MSE_SUPPRESS_CHECK_USE_BEFORE_SET
-#define MSE_CHECK_USE_BEFORE_SET
-#endif // !MSE_SUPPRESS_CHECK_USE_BEFORE_SET
-#endif // !NDEBUG
-
- /* This class is just meant to act like the "bool" type, except that it has a default intialization value (false). */
- class CBool {
- public:
- // Constructs zero.
- CBool() : m_val(false) {}
-
- // Copy constructor
- CBool(const CBool &x) : m_val(x.m_val) { note_value_assignment(); };
-
- // Assignment operator
- CBool& operator=(const CBool &x) { note_value_assignment(); m_val = x.m_val; return (*this); }
-
- // Constructors from primitive boolean types
- CBool(bool x) { note_value_assignment(); m_val = x; }
-
- // Casts to primitive boolean types
- operator bool() const { assert_initialized(); return m_val; }
-
- CBool& operator |=(const CBool &x) { assert_initialized(); m_val |= x.m_val; return (*this); }
- CBool& operator &=(const CBool &x) { assert_initialized(); m_val &= x.m_val; return (*this); }
- CBool& operator ^=(const CBool &x) { assert_initialized(); m_val ^= x.m_val; return (*this); }
-
- bool m_val;
-
-#ifdef MSE_CHECK_USE_BEFORE_SET
- void note_value_assignment() { m_initialized = true; }
- void assert_initialized() const { assert(m_initialized); }
- bool m_initialized = false;
-#else // MSE_CHECK_USE_BEFORE_SET
- void note_value_assignment() {}
- void assert_initialized() const {}
-#endif // MSE_CHECK_USE_BEFORE_SET
- };
-
-
- template<typename _TDestination, typename _TSource>
- MSE_CONSTEXPR static bool sg_can_exceed_upper_bound() {
- return (
- ((std::numeric_limits<_TSource>::is_signed == std::numeric_limits<_TDestination>::is_signed)
- && (std::numeric_limits<_TSource>::digits > std::numeric_limits<_TDestination>::digits))
- || ((std::numeric_limits<_TSource>::is_signed != std::numeric_limits<_TDestination>::is_signed)
- && ((std::numeric_limits<_TSource>::is_signed && (std::numeric_limits<_TSource>::digits > (1 + std::numeric_limits<_TDestination>::digits)))
- || ((!std::numeric_limits<_TSource>::is_signed) && ((1 + std::numeric_limits<_TSource>::digits) > std::numeric_limits<_TDestination>::digits))
- )
- )
- );
- }
- template<typename _TDestination, typename _TSource>
- MSE_CONSTEXPR static bool sg_can_exceed_lower_bound() {
- return (
- (std::numeric_limits<_TSource>::is_signed && (!std::numeric_limits<_TDestination>::is_signed))
- || (std::numeric_limits<_TSource>::is_signed && (std::numeric_limits<_TSource>::digits > std::numeric_limits<_TDestination>::digits))
- );
- }
-
- template<typename _TDestination, typename _TSource>
- void g_assign_check_range(const _TSource &x) {
-#ifndef MSE_PRIMITIVE_ASSIGN_RANGE_CHECK_DISABLED
- /* This probably needs to be cleaned up. But at the moment this should be mostly compile time complexity. And
- as is it avoids "signed/unsigned" mismatch warnings. */
- MSE_CONSTEXPR const bool rhs_can_exceed_upper_bound = sg_can_exceed_upper_bound<_TDestination, _TSource>();
- MSE_CONSTEXPR const bool rhs_can_exceed_lower_bound = sg_can_exceed_lower_bound<_TDestination, _TSource>();
- MSE_CONSTEXPR const bool can_exceed_bounds = rhs_can_exceed_upper_bound || rhs_can_exceed_lower_bound;
- if (can_exceed_bounds) {
- if (rhs_can_exceed_upper_bound) {
- if (x > _TSource(std::numeric_limits<_TDestination>::max())) {
- MSE_THROW(primitives_range_error("range error - value to be assigned is out of range of the target (integer) type"));
- }
- }
- if (rhs_can_exceed_lower_bound) {
- /* We're assuming that std::numeric_limits<>::lowest() will never be greater than zero. */
- if (0 > x) {
- if (0 == std::numeric_limits<_TDestination>::lowest()) {
- MSE_THROW(primitives_range_error("range error - value to be assigned is out of range of the target (integer) type"));
- }
- else if (x < _TSource(std::numeric_limits<_TDestination>::lowest())) {
- MSE_THROW(primitives_range_error("range error - value to be assigned is out of range of the target (integer) type"));
- }
- }
- }
- }
-#endif // !MSE_PRIMITIVE_ASSIGN_RANGE_CHECK_DISABLED
- }
-
- /* The CInt and CSize_t classes are meant to substitute for standard "int" and "size_t" types. The differences between
- the standard types and these classes are that the classes have a default intialization value (zero), and the
- classes, as much as possible, try to prevent the problematic behaviour of (possibly negative) signed integers
- being cast (inadvertently) to the unsigned size_t type. For example, the expression (0 > (int)5 - (size_t)7) evaluates
- (unintuitively) to false, whereas the expression (0 > (CInt)5 - (CSize_t)7) evaluates to true. Also, the classes do
- some range checking. For example, the code "CSize_t s = -2;" will throw an exception. */
- template<typename _Ty>
- class TIntBase1 {
- public:
- // Constructs zero.
- TIntBase1() : m_val(0) {}
-
- // Copy constructor
- TIntBase1(const TIntBase1 &x) : m_val(x.m_val) { note_value_assignment(); };
-
- // Constructors from primitive integer types
- explicit TIntBase1(_Ty x) { note_value_assignment(); m_val = x; }
-
- template<typename _Tz>
- void assign_check_range(const _Tz &x) {
- note_value_assignment();
- g_assign_check_range<_Ty, _Tz>(x);
- }
-
- _Ty m_val;
-
-#ifdef MSE_CHECK_USE_BEFORE_SET
- void note_value_assignment() { m_initialized = true; }
- void assert_initialized() const { assert(m_initialized); }
- bool m_initialized = false;
-#else // MSE_CHECK_USE_BEFORE_SET
- void note_value_assignment() {}
- void assert_initialized() const {}
-#endif // MSE_CHECK_USE_BEFORE_SET
- };
-
- class CInt : public TIntBase1<MSE_CINT_BASE_INTEGER_TYPE> {
- public:
- typedef MSE_CINT_BASE_INTEGER_TYPE _Ty;
- typedef TIntBase1<_Ty> _Myt;
-
- // Constructs zero.
- CInt() : _Myt() {}
-
- // Copy constructor
- CInt(const CInt &x) : _Myt(x) {};
- CInt(const _Myt &x) : _Myt(x) {};
-
- // Assignment operator
- CInt& operator=(const CInt &x) { (*this).note_value_assignment(); m_val = x.m_val; return (*this); }
- //CInt& operator=(const _Ty &x) { (*this).note_value_assignment(); m_val = x; return (*this); }
-
- CInt& operator=(long long x) { assign_check_range<long long>(x); m_val = static_cast<_Ty>(x); return (*this); }
- CInt& operator=(long x) { assign_check_range<long>(x); m_val = static_cast<_Ty>(x); return (*this); }
- CInt& operator=(int x) { assign_check_range<int>(x); m_val = static_cast<_Ty>(x); return (*this); }
- CInt& operator=(short x) { assign_check_range<short>(x); m_val = static_cast<_Ty>(x); return (*this); }
- CInt& operator=(char x) { assign_check_range<char>(x); m_val = static_cast<_Ty>(x); return (*this); }
- CInt& operator=(size_t x) { assign_check_range<size_t>(x); m_val = static_cast<_Ty>(x); return (*this); }
- //CInt& operator=(CSize_t x) { assign_check_range<size_t>(x.as_a_size_t()); m_val = x.as_a_size_t(); return (*this); }
- /* We would have liked to have assignment operators for the unsigned primitive integer types, but one of them could
- potentially clash with the size_t assignment operator. */
- //CInt& operator=(unsigned long long x) { assign_check_range<unsigned long long>(x); m_val = static_cast<_Ty>(x); return (*this); }
- //CInt& operator=(unsigned long x) { assign_check_range<unsigned long>(x); m_val = static_cast<_Ty>(x); return (*this); }
- //CInt& operator=(unsigned int x) { assign_check_range<unsigned int>(x); m_val = static_cast<_Ty>(x); return (*this); }
- //CInt& operator=(unsigned short x) { assign_check_range<unsigned short>(x); m_val = static_cast<_Ty>(x); return (*this); }
- //CInt& operator=(unsigned char x) { assign_check_range<unsigned char>(x); m_val = static_cast<_Ty>(x); return (*this); }
-
- // Constructors from primitive integer types
- //CInt(_Ty x) { m_val = x; }
- CInt(long long x) { assign_check_range<long long>(x); m_val = static_cast<_Ty>(x); }
- CInt(long x) { assign_check_range< long>(x); m_val = static_cast<_Ty>(x); }
- CInt(int x) { assign_check_range<int>(x); m_val = static_cast<_Ty>(x); }
- CInt(short x) { assign_check_range<short>(x); m_val = static_cast<_Ty>(x); }
- CInt(char x) { assign_check_range<char>(x); m_val = static_cast<_Ty>(x); }
- CInt(size_t x) { assign_check_range<size_t>(x); m_val = static_cast<_Ty>(x); }
- //CInt(CSize_t x) { assign_check_range<size_t>(x.as_a_size_t()); m_val = x.as_a_size_t(); }
- /* We would have liked to have constructors for the unsigned primitive integer types, but one of them could
- potentially clash with the size_t constructor. */
- //CInt(unsigned long long x) { assign_check_range<unsigned long long>(x); m_val = static_cast<_Ty>(x); }
- //CInt(unsigned long x) { assign_check_range<unsigned long>(x); m_val = static_cast<_Ty>(x); }
- //CInt(unsigned int x) { assign_check_range<unsigned int>(x); m_val = static_cast<_Ty>(x); }
- //CInt(unsigned short x) { assign_check_range<unsigned short>(x); m_val = static_cast<_Ty>(x); }
- //CInt(unsigned char x) { assign_check_range<unsigned char>(x); m_val = static_cast<_Ty>(x); }
-
- // Casts to primitive integer types
- operator _Ty() const { (*this).assert_initialized(); return m_val; }
-
- CInt operator ~() const { (*this).assert_initialized(); return CInt(~m_val); }
- CInt& operator |=(const CInt &x) { (*this).assert_initialized(); m_val |= x.m_val; return (*this); }
- CInt& operator &=(const CInt &x) { (*this).assert_initialized(); m_val &= x.m_val; return (*this); }
- CInt& operator ^=(const CInt &x) { (*this).assert_initialized(); m_val ^= x.m_val; return (*this); }
-
- CInt operator -() const { (*this).assert_initialized(); return CInt(-m_val); }
- CInt& operator +=(const CInt &x) { (*this).assert_initialized(); m_val += x.m_val; return (*this); }
- CInt& operator -=(const CInt &x) { (*this).assert_initialized(); m_val -= x.m_val; return (*this); }
- CInt& operator *=(const CInt &x) { (*this).assert_initialized(); m_val *= x.m_val; return (*this); }
- CInt& operator /=(const CInt &x) { (*this).assert_initialized(); m_val /= x.m_val; return (*this); }
- CInt& operator %=(const CInt &x) { (*this).assert_initialized(); m_val %= x.m_val; return (*this); }
- CInt& operator >>=(const CInt &x) { (*this).assert_initialized(); m_val >>= x.m_val; return (*this); }
- CInt& operator <<=(const CInt &x) { (*this).assert_initialized(); m_val <<= x.m_val; return (*this); }
-
- CInt operator +(const CInt &x) const { (*this).assert_initialized(); return CInt(m_val + x.m_val); }
- CInt operator +(long long x) const { (*this).assert_initialized(); return ((*this) + CInt(x)); }
- CInt operator +(long x) const { (*this).assert_initialized(); return ((*this) + CInt(x)); }
- CInt operator +(int x) const { (*this).assert_initialized(); return ((*this) + CInt(x)); }
- CInt operator +(short x) const { (*this).assert_initialized(); return ((*this) + CInt(x)); }
- CInt operator +(char x) const { (*this).assert_initialized(); return ((*this) + CInt(x)); }
- CInt operator +(size_t x) const { (*this).assert_initialized(); return ((*this) + CInt(x)); }
- //CInt operator +(CSize_t x) const { (*this).assert_initialized(); return ((*this) + CInt(x)); }
-
- CInt operator -(const CInt &x) const { (*this).assert_initialized(); return CInt(m_val - x.m_val); }
- CInt operator -(long long x) const { (*this).assert_initialized(); return ((*this) - CInt(x)); }
- CInt operator -(long x) const { (*this).assert_initialized(); return ((*this) - CInt(x)); }
- CInt operator -(int x) const { (*this).assert_initialized(); return ((*this) - CInt(x)); }
- CInt operator -(short x) const { (*this).assert_initialized(); return ((*this) - CInt(x)); }
- CInt operator -(char x) const { (*this).assert_initialized(); return ((*this) - CInt(x)); }
- CInt operator -(size_t x) const { (*this).assert_initialized(); return ((*this) - CInt(x)); }
- //CInt operator -(CSize_t x) const { (*this).assert_initialized(); return ((*this) - CInt(x)); }
-
- CInt operator *(const CInt &x) const { (*this).assert_initialized(); return CInt(m_val * x.m_val); }
- CInt operator *(long long x) const { (*this).assert_initialized(); return ((*this) * CInt(x)); }
- CInt operator *(long x) const { (*this).assert_initialized(); return ((*this) * CInt(x)); }
- CInt operator *(int x) const { (*this).assert_initialized(); return ((*this) * CInt(x)); }
- CInt operator *(short x) const { (*this).assert_initialized(); return ((*this) * CInt(x)); }
- CInt operator *(char x) const { (*this).assert_initialized(); return ((*this) * CInt(x)); }
- CInt operator *(size_t x) const { (*this).assert_initialized(); return ((*this) * CInt(x)); }
- //CInt operator *(CSize_t x) const { (*this).assert_initialized(); return ((*this) * CInt(x)); }
-
- CInt operator /(const CInt &x) const { (*this).assert_initialized(); return CInt(m_val / x.m_val); }
- CInt operator /(long long x) const { (*this).assert_initialized(); return ((*this) / CInt(x)); }
- CInt operator /(long x) const { (*this).assert_initialized(); return ((*this) / CInt(x)); }
- CInt operator /(int x) const { (*this).assert_initialized(); return ((*this) / CInt(x)); }
- CInt operator /(short x) const { (*this).assert_initialized(); return ((*this) / CInt(x)); }
- CInt operator /(char x) const { (*this).assert_initialized(); return ((*this) / CInt(x)); }
- CInt operator /(size_t x) const { (*this).assert_initialized(); return ((*this) / CInt(x)); }
- //CInt operator /(CSize_t x) const { (*this).assert_initialized(); return ((*this) / CInt(x)); }
-
- bool operator <(const CInt &x) const { (*this).assert_initialized(); return (m_val < x.m_val); }
- bool operator <(long long x) const { (*this).assert_initialized(); return ((*this) < CInt(x)); }
- bool operator <(long x) const { (*this).assert_initialized(); return ((*this) < CInt(x)); }
- bool operator <(int x) const { (*this).assert_initialized(); return ((*this) < CInt(x)); }
- bool operator <(short x) const { (*this).assert_initialized(); return ((*this) < CInt(x)); }
- bool operator <(char x) const { (*this).assert_initialized(); return ((*this) < CInt(x)); }
- bool operator <(size_t x) const { (*this).assert_initialized(); return ((*this) < CInt(x)); }
- //bool operator <(CSize_t x) const { (*this).assert_initialized(); return ((*this) < CInt(x)); }
-
- bool operator >(const CInt &x) const { (*this).assert_initialized(); return (m_val > x.m_val); }
- bool operator >(long long x) const { (*this).assert_initialized(); return ((*this) > CInt(x)); }
- bool operator >(long x) const { (*this).assert_initialized(); return ((*this) > CInt(x)); }
- bool operator >(int x) const { (*this).assert_initialized(); return ((*this) > CInt(x)); }
- bool operator >(short x) const { (*this).assert_initialized(); return ((*this) > CInt(x)); }
- bool operator >(char x) const { (*this).assert_initialized(); return ((*this) > CInt(x)); }
- bool operator >(size_t x) const { (*this).assert_initialized(); return ((*this) > CInt(x)); }
- //bool operator >(CSize_t x) const { (*this).assert_initialized(); return ((*this) > CInt(x)); }
-
- bool operator <=(const CInt &x) const { (*this).assert_initialized(); return (m_val <= x.m_val); }
- bool operator <=(long long x) const { (*this).assert_initialized(); return ((*this) <= CInt(x)); }
- bool operator <=(long x) const { (*this).assert_initialized(); return ((*this) <= CInt(x)); }
- bool operator <=(int x) const { (*this).assert_initialized(); return ((*this) <= CInt(x)); }
- bool operator <=(short x) const { (*this).assert_initialized(); return ((*this) <= CInt(x)); }
- bool operator <=(char x) const { (*this).assert_initialized(); return ((*this) <= CInt(x)); }
- bool operator <=(size_t x) const { (*this).assert_initialized(); return ((*this) <= CInt(x)); }
- //bool operator <=(CSize_t x) const { (*this).assert_initialized(); return ((*this) <= CInt(x)); }
-
- bool operator >=(const CInt &x) const { (*this).assert_initialized(); return (m_val >= x.m_val); }
- bool operator >=(long long x) const { (*this).assert_initialized(); return ((*this) >= CInt(x)); }
- bool operator >=(long x) const { (*this).assert_initialized(); return ((*this) >= CInt(x)); }
- bool operator >=(int x) const { (*this).assert_initialized(); return ((*this) >= CInt(x)); }
- bool operator >=(short x) const { (*this).assert_initialized(); return ((*this) >= CInt(x)); }
- bool operator >=(char x) const { (*this).assert_initialized(); return ((*this) >= CInt(x)); }
- bool operator >=(size_t x) const { (*this).assert_initialized(); return ((*this) >= CInt(x)); }
- //bool operator >=(CSize_t x) const { (*this).assert_initialized(); return ((*this) >= CInt(x)); }
-
- bool operator ==(const CInt &x) const { (*this).assert_initialized(); return (m_val == x.m_val); }
- bool operator ==(long long x) const { (*this).assert_initialized(); return ((*this) == CInt(x)); }
- bool operator ==(long x) const { (*this).assert_initialized(); return ((*this) == CInt(x)); }
- bool operator ==(int x) const { (*this).assert_initialized(); return ((*this) == CInt(x)); }
- bool operator ==(short x) const { (*this).assert_initialized(); return ((*this) == CInt(x)); }
- bool operator ==(char x) const { (*this).assert_initialized(); return ((*this) == CInt(x)); }
- bool operator ==(size_t x) const { (*this).assert_initialized(); return ((*this) == CInt(x)); }
- //bool operator ==(CSize_t x) const { (*this).assert_initialized(); return ((*this) == CInt(x)); }
-
- bool operator !=(const CInt &x) const { (*this).assert_initialized(); return (m_val != x.m_val); }
- bool operator !=(long long x) const { (*this).assert_initialized(); return ((*this) != CInt(x)); }
- bool operator !=(long x) const { (*this).assert_initialized(); return ((*this) != CInt(x)); }
- bool operator !=(int x) const { (*this).assert_initialized(); return ((*this) != CInt(x)); }
- bool operator !=(short x) const { (*this).assert_initialized(); return ((*this) != CInt(x)); }
- bool operator !=(char x) const { (*this).assert_initialized(); return ((*this) != CInt(x)); }
- bool operator !=(size_t x) const { (*this).assert_initialized(); return ((*this) != CInt(x)); }
- //bool operator !=(CSize_t x) const { (*this).assert_initialized(); return ((*this) != CInt(x)); }
-
- // INCREMENT/DECREMENT OPERATORS
- CInt& operator ++() { (*this).assert_initialized(); m_val++; return (*this); }
- CInt operator ++(int) {
- (*this).assert_initialized();
- CInt tmp(*this); // copy
- operator++(); // pre-increment
- return tmp; // return old value
- }
- CInt& operator --() {
- (*this).assert_initialized();
- if (0 <= std::numeric_limits<_Ty>::lowest()) {
- (*this).assert_initialized();
- (*this) = (*this) - 1; return (*this);
- }
- else {
- (*this).assert_initialized();
- m_val--; return (*this);
- }
- }
- CInt operator --(int) {
- (*this).assert_initialized();
- CInt tmp(*this); // copy
- operator--(); // pre-decrement
- return tmp; // return old value
- }
-
- //_Ty m_val;
- };
-}
-
-namespace std {
-#ifndef _THROW0
-#define _THROW0()
-#endif // !_THROW0
-#ifndef _STCONS
-#define _STCONS(ty, name, val) static constexpr ty name = static_cast<ty>(val)
-#endif // !_STCONS
-
- template<> class numeric_limits<mse::CInt> { // limits for type int
- public:
- typedef MSE_CINT_BASE_INTEGER_TYPE _Ty;
-
- static constexpr _Ty(min)() _THROW0()
- { // return minimum value
- return numeric_limits<MSE_CINT_BASE_INTEGER_TYPE>::min();
- }
- static constexpr _Ty(max)() _THROW0()
- { // return maximum value
- return numeric_limits<MSE_CINT_BASE_INTEGER_TYPE>::max();
- }
- static constexpr _Ty lowest() _THROW0()
- { // return most negative value
- return numeric_limits<MSE_CINT_BASE_INTEGER_TYPE>::lowest();
- }
- static constexpr _Ty epsilon() _THROW0()
- { // return smallest effective increment from 1.0
- return numeric_limits<MSE_CINT_BASE_INTEGER_TYPE>::epsilon();
- }
- static constexpr _Ty round_error() _THROW0()
- { // return largest rounding error
- return numeric_limits<MSE_CINT_BASE_INTEGER_TYPE>::round_error();
- }
- static constexpr _Ty denorm_min() _THROW0()
- { // return minimum denormalized value
- return numeric_limits<MSE_CINT_BASE_INTEGER_TYPE>::denorm_min();
- }
- static constexpr _Ty infinity() _THROW0()
- { // return positive infinity
- return numeric_limits<MSE_CINT_BASE_INTEGER_TYPE>::infinity();
- }
- static constexpr _Ty quiet_NaN() _THROW0()
- { // return non-signaling NaN
- return numeric_limits<MSE_CINT_BASE_INTEGER_TYPE>::quiet_NaN();
- }
- static constexpr _Ty signaling_NaN() _THROW0()
- { // return signaling NaN
- return numeric_limits<MSE_CINT_BASE_INTEGER_TYPE>::signaling_NaN();
- }
- _STCONS(float_denorm_style, has_denorm, numeric_limits<MSE_CINT_BASE_INTEGER_TYPE>::has_denorm);
- _STCONS(bool, has_denorm_loss, numeric_limits<MSE_CINT_BASE_INTEGER_TYPE>::has_denorm_loss);
- _STCONS(bool, has_infinity, numeric_limits<MSE_CINT_BASE_INTEGER_TYPE>::has_infinity);
- _STCONS(bool, has_quiet_NaN, numeric_limits<MSE_CINT_BASE_INTEGER_TYPE>::has_quiet_NaN);
- _STCONS(bool, has_signaling_NaN, numeric_limits<MSE_CINT_BASE_INTEGER_TYPE>::has_signaling_NaN);
- _STCONS(bool, is_bounded, numeric_limits<MSE_CINT_BASE_INTEGER_TYPE>::is_bounded);
- _STCONS(bool, is_exact, numeric_limits<MSE_CINT_BASE_INTEGER_TYPE>::is_exact);
- _STCONS(bool, is_iec559, numeric_limits<MSE_CINT_BASE_INTEGER_TYPE>::is_iec559);
- _STCONS(bool, is_integer, numeric_limits<MSE_CINT_BASE_INTEGER_TYPE>::is_integer);
- _STCONS(bool, is_modulo, numeric_limits<MSE_CINT_BASE_INTEGER_TYPE>::is_modulo);
- _STCONS(bool, is_signed, numeric_limits<MSE_CINT_BASE_INTEGER_TYPE>::is_signed);
- _STCONS(bool, is_specialized, numeric_limits<MSE_CINT_BASE_INTEGER_TYPE>::is_specialized);
- _STCONS(bool, tinyness_before, numeric_limits<MSE_CINT_BASE_INTEGER_TYPE>::tinyness_before);
- _STCONS(bool, traps, numeric_limits<MSE_CINT_BASE_INTEGER_TYPE>::traps);
- _STCONS(float_round_style, round_style, numeric_limits<MSE_CINT_BASE_INTEGER_TYPE>::round_style);
- _STCONS(int, digits, numeric_limits<MSE_CINT_BASE_INTEGER_TYPE>::digits);
- _STCONS(int, digits10, numeric_limits<MSE_CINT_BASE_INTEGER_TYPE>::digits10);
- _STCONS(int, max_digits10, numeric_limits<MSE_CINT_BASE_INTEGER_TYPE>::max_digits10);
- _STCONS(int, max_exponent, numeric_limits<MSE_CINT_BASE_INTEGER_TYPE>::max_exponent);
- _STCONS(int, max_exponent10, numeric_limits<MSE_CINT_BASE_INTEGER_TYPE>::max_exponent10);
- _STCONS(int, min_exponent, numeric_limits<MSE_CINT_BASE_INTEGER_TYPE>::min_exponent);
- _STCONS(int, min_exponent10, numeric_limits<MSE_CINT_BASE_INTEGER_TYPE>::min_exponent10);
- _STCONS(int, radix, numeric_limits<MSE_CINT_BASE_INTEGER_TYPE>::radix);
- };
-}
-
-namespace mse {
- class CSize_t;
- static size_t as_a_size_t(CSize_t n);
-
- /* Note that CSize_t does not have a default conversion to size_t. This is by design. Use the as_a_size_t() member
- function to get a size_t when necessary. */
- class CSize_t : public TIntBase1<size_t> {
- public:
- typedef size_t _Ty;
- typedef int _T_signed_primitive_integer_type;
- typedef TIntBase1<_Ty> _Myt;
-
- // Constructs zero.
- CSize_t() : _Myt() {}
-
- // Copy constructor
- CSize_t(const CSize_t &x) : _Myt(x) {};
- CSize_t(const _Myt &x) : _Myt(x) {};
-
- // Assignment operator
- CSize_t& operator=(const CSize_t &x) { m_val = x.m_val; return (*this); }
- //CSize_t& operator=(const _Ty &x) { m_val = x; return (*this); }
-
- CSize_t& operator=(long long x) { assign_check_range<long long>(x); m_val = static_cast<_Ty>(x); return (*this); }
- CSize_t& operator=(long x) { assign_check_range<long>(x); m_val = static_cast<_Ty>(x); return (*this); }
- CSize_t& operator=(int x) { assign_check_range<int>(x); m_val = static_cast<_Ty>(x); return (*this); }
- CSize_t& operator=(short x) { assign_check_range<short>(x); m_val = static_cast<_Ty>(x); return (*this); }
- CSize_t& operator=(char x) { assign_check_range<char>(x); m_val = static_cast<_Ty>(x); return (*this); }
- CSize_t& operator=(size_t x) { assign_check_range<size_t>(x); m_val = static_cast<_Ty>(x); return (*this); }
- CSize_t& operator=(CInt x) { assign_check_range<MSE_CINT_BASE_INTEGER_TYPE>(x); m_val = static_cast<_Ty>(x); return (*this); }
- /* We would have liked to have assignment operators for the unsigned primitive integer types, but one of them could
- potentially clash with the size_t assignment operator. */
- //CSize_t& operator=(unsigned long long x) { assign_check_range<unsigned long long>(x); m_val = static_cast<_Ty>(x); return (*this); }
- //CSize_t& operator=(unsigned long x) { assign_check_range<unsigned long>(x); m_val = static_cast<_Ty>(x); return (*this); }
- //CSize_t& operator=(unsigned int x) { assign_check_range<unsigned int>(x); m_val = static_cast<_Ty>(x); return (*this); }
- //CSize_t& operator=(unsigned short x) { assign_check_range<unsigned short>(x); m_val = static_cast<_Ty>(x); return (*this); }
- //CSize_t& operator=(unsigned char x) { assign_check_range<unsigned char>(x); m_val = static_cast<_Ty>(x); return (*this); }
-
- // Constructors from primitive integer types
- //explicit CSize_t(_Ty x) { m_val = x; }
- explicit CSize_t(long long x) { assign_check_range<long long>(x); m_val = static_cast<_Ty>(x); }
- explicit CSize_t(long x) { assign_check_range< long>(x); m_val = static_cast<_Ty>(x); }
- explicit CSize_t(int x) { assign_check_range<int>(x); m_val = static_cast<_Ty>(x); }
- explicit CSize_t(short x) { assign_check_range<short>(x); m_val = static_cast<_Ty>(x); }
- explicit CSize_t(char x) { assign_check_range<char>(x); m_val = static_cast<_Ty>(x); }
- CSize_t(size_t x) { assign_check_range<size_t>(x); m_val = static_cast<_Ty>(x); }
- /*explicit */CSize_t(CInt x) { assign_check_range<MSE_CINT_BASE_INTEGER_TYPE>(x); m_val = static_cast<_Ty>(x); }
- /* We would have liked to have constructors for the unsigned primitive integer types, but one of them could
- potentially clash with the size_t constructor. */
- //explicit CSize_t(unsigned long long x) { assign_check_range<unsigned long long>(x); m_val = static_cast<_Ty>(x); }
- //explicit CSize_t(unsigned long x) { assign_check_range<unsigned long>(x); m_val = static_cast<_Ty>(x); }
- //explicit CSize_t(unsigned int x) { assign_check_range<unsigned int>(x); m_val = static_cast<_Ty>(x); }
- //explicit CSize_t(unsigned short x) { assign_check_range<unsigned short>(x); m_val = static_cast<_Ty>(x); }
- //explicit CSize_t(unsigned char x) { assign_check_range<unsigned char>(x); m_val = static_cast<_Ty>(x); }
-
- // Casts to primitive integer types
- operator CInt() const { (*this).assert_initialized(); return CInt(m_val); }
-#ifndef MSVC2010_COMPATIBLE
- explicit operator size_t() const { (*this).assert_initialized(); return (m_val); }
-#endif /*MSVC2010_COMPATIBLE*/
- //size_t as_a_size_t() const { (*this).assert_initialized(); return m_val; }
-
- CSize_t operator ~() const { (*this).assert_initialized(); return (~m_val); }
- CSize_t& operator |=(const CSize_t &x) { (*this).assert_initialized(); m_val |= x.m_val; return (*this); }
- CSize_t& operator &=(const CSize_t &x) { (*this).assert_initialized(); m_val &= x.m_val; return (*this); }
- CSize_t& operator ^=(const CSize_t &x) { (*this).assert_initialized(); m_val ^= x.m_val; return (*this); }
-
- CInt operator -() const { (*this).assert_initialized(); /* Should unsigned types even support this opperator? */
- return (-(CInt(m_val)));
- }
- CSize_t& operator +=(const CSize_t &x) { (*this).assert_initialized(); m_val += x.m_val; return (*this); }
- CSize_t& operator -=(const CSize_t &x) {
- (*this).assert_initialized();
- //assert(0 <= std::numeric_limits<_Ty>::lowest());
- if (x.m_val > m_val) {
- MSE_THROW(primitives_range_error("range error - value to be assigned is out of range of the target (integer) type"));
- }
- m_val -= x.m_val; return (*this);
- }
- CSize_t& operator *=(const CSize_t &x) { (*this).assert_initialized(); m_val *= x.m_val; return (*this); }
- CSize_t& operator /=(const CSize_t &x) { (*this).assert_initialized(); m_val /= x.m_val; return (*this); }
- CSize_t& operator %=(const CSize_t &x) { (*this).assert_initialized(); m_val %= x.m_val; return (*this); }
- CSize_t& operator >>=(const CSize_t &x) { (*this).assert_initialized(); m_val >>= x.m_val; return (*this); }
- CSize_t& operator <<=(const CSize_t &x) { (*this).assert_initialized(); m_val <<= x.m_val; return (*this); }
-
- CSize_t operator +(const CSize_t &x) const { (*this).assert_initialized(); return (m_val + x.m_val); }
- CInt operator +(const CInt &x) const { (*this).assert_initialized(); return (CInt(m_val) + x); }
- CInt operator +(long long x) const { (*this).assert_initialized(); return ((*this) + CInt(x)); }
- CInt operator +(long x) const { (*this).assert_initialized(); return ((*this) + CInt(x)); }
- CInt operator +(int x) const { (*this).assert_initialized(); return ((*this) + CInt(x)); }
- CInt operator +(short x) const { (*this).assert_initialized(); return ((*this) + CInt(x)); }
- CInt operator +(char x) const { (*this).assert_initialized(); return ((*this) + CInt(x)); }
- CSize_t operator +(size_t x) const { (*this).assert_initialized(); return ((*this) + CSize_t(x)); }
-
- CInt operator -(const CSize_t &x) const { (*this).assert_initialized(); return (CInt(m_val) - CInt(x.m_val)); }
- CInt operator -(const CInt &x) const { (*this).assert_initialized(); return (CInt(m_val) - x); }
- CInt operator -(long long x) const { (*this).assert_initialized(); return ((*this) - CInt(x)); }
- CInt operator -(long x) const { (*this).assert_initialized(); return ((*this) - CInt(x)); }
- CInt operator -(int x) const { (*this).assert_initialized(); return ((*this) - CInt(x)); }
- CInt operator -(short x) const { (*this).assert_initialized(); return ((*this) - CInt(x)); }
- CInt operator -(char x) const { (*this).assert_initialized(); return ((*this) - CInt(x)); }
- CInt operator -(size_t x) const { (*this).assert_initialized(); return ((*this) - CSize_t(x)); }
-
- CSize_t operator *(const CSize_t &x) const { (*this).assert_initialized(); return (m_val * x.m_val); }
- CInt operator *(const CInt &x) const { (*this).assert_initialized(); return (CInt(m_val) * x); }
- CInt operator *(long long x) const { (*this).assert_initialized(); return ((*this) * CInt(x)); }
- CInt operator *(long x) const { (*this).assert_initialized(); return ((*this) * CInt(x)); }
- CInt operator *(int x) const { (*this).assert_initialized(); return ((*this) * CInt(x)); }
- CInt operator *(short x) const { (*this).assert_initialized(); return ((*this) * CInt(x)); }
- CInt operator *(char x) const { (*this).assert_initialized(); return ((*this) * CInt(x)); }
- CSize_t operator *(size_t x) const { (*this).assert_initialized(); return ((*this) * CSize_t(x)); }
-
- CSize_t operator /(const CSize_t &x) const { (*this).assert_initialized(); return (m_val / x.m_val); }
- CInt operator /(const CInt &x) const { (*this).assert_initialized(); return (CInt(m_val) / x); }
- CInt operator /(long long x) const { (*this).assert_initialized(); return ((*this) / CInt(x)); }
- CInt operator /(long x) const { (*this).assert_initialized(); return ((*this) / CInt(x)); }
- CInt operator /(int x) const { (*this).assert_initialized(); return ((*this) / CInt(x)); }
- CInt operator /(short x) const { (*this).assert_initialized(); return ((*this) / CInt(x)); }
- CInt operator /(char x) const { (*this).assert_initialized(); return ((*this) / CInt(x)); }
- CSize_t operator /(size_t x) const { (*this).assert_initialized(); return ((*this) / CSize_t(x)); }
-
- bool operator <(const CSize_t &x) const { (*this).assert_initialized(); return (m_val < x.m_val); }
- bool operator <(const CInt &x) const { (*this).assert_initialized(); return (CInt(m_val) < x); }
- bool operator <(long long x) const { (*this).assert_initialized(); return ((*this) < CInt(x)); }
- bool operator <(long x) const { (*this).assert_initialized(); return ((*this) < CInt(x)); }
- bool operator <(int x) const { (*this).assert_initialized(); return ((*this) < CInt(x)); }
- bool operator <(short x) const { (*this).assert_initialized(); return ((*this) < CInt(x)); }
- bool operator <(char x) const { (*this).assert_initialized(); return ((*this) < CInt(x)); }
- bool operator <(size_t x) const { (*this).assert_initialized(); return ((*this) < CSize_t(x)); }
-
- bool operator >(const CSize_t &x) const { (*this).assert_initialized(); return (m_val > x.m_val); }
- bool operator >(const CInt &x) const { (*this).assert_initialized(); return (CInt(m_val) > x); }
- bool operator >(long long x) const { (*this).assert_initialized(); return ((*this) > CInt(x)); }
- bool operator >(long x) const { (*this).assert_initialized(); return ((*this) > CInt(x)); }
- bool operator >(int x) const { (*this).assert_initialized(); return ((*this) > CInt(x)); }
- bool operator >(short x) const { (*this).assert_initialized(); return ((*this) > CInt(x)); }
- bool operator >(char x) const { (*this).assert_initialized(); return ((*this) > CInt(x)); }
- bool operator >(size_t x) const { (*this).assert_initialized(); return ((*this) > CSize_t(x)); }
-
- bool operator <=(const CSize_t &x) const { (*this).assert_initialized(); return (m_val <= x.m_val); }
- bool operator <=(const CInt &x) const { (*this).assert_initialized(); return (CInt(m_val) <= x); }
- bool operator <=(long long x) const { (*this).assert_initialized(); return ((*this) <= CInt(x)); }
- bool operator <=(long x) const { (*this).assert_initialized(); return ((*this) <= CInt(x)); }
- bool operator <=(int x) const { (*this).assert_initialized(); return ((*this) <= CInt(x)); }
- bool operator <=(short x) const { (*this).assert_initialized(); return ((*this) <= CInt(x)); }
- bool operator <=(char x) const { (*this).assert_initialized(); return ((*this) <= CInt(x)); }
- bool operator <=(size_t x) const { (*this).assert_initialized(); return ((*this) <= CSize_t(x)); }
-
- bool operator >=(const CSize_t &x) const { (*this).assert_initialized(); return (m_val >= x.m_val); }
- bool operator >=(const CInt &x) const { (*this).assert_initialized(); return (CInt(m_val) >= x); }
- bool operator >=(long long x) const { (*this).assert_initialized(); return ((*this) >= CInt(x)); }
- bool operator >=(long x) const { (*this).assert_initialized(); return ((*this) >= CInt(x)); }
- bool operator >=(int x) const { (*this).assert_initialized(); return ((*this) >= CInt(x)); }
- bool operator >=(short x) const { (*this).assert_initialized(); return ((*this) >= CInt(x)); }
- bool operator >=(char x) const { (*this).assert_initialized(); return ((*this) >= CInt(x)); }
- bool operator >=(size_t x) const { (*this).assert_initialized(); return ((*this) >= CSize_t(x)); }
-
- bool operator ==(const CSize_t &x) const { (*this).assert_initialized(); return (m_val == x.m_val); }
- bool operator ==(const CInt &x) const { (*this).assert_initialized(); return (CInt(m_val) == x); }
- bool operator ==(long long x) const { (*this).assert_initialized(); return ((*this) == CInt(x)); }
- bool operator ==(long x) const { (*this).assert_initialized(); return ((*this) == CInt(x)); }
- bool operator ==(int x) const { (*this).assert_initialized(); return ((*this) == CInt(x)); }
- bool operator ==(short x) const { (*this).assert_initialized(); return ((*this) == CInt(x)); }
- bool operator ==(char x) const { (*this).assert_initialized(); return ((*this) == CInt(x)); }
- bool operator ==(size_t x) const { (*this).assert_initialized(); return ((*this) == CSize_t(x)); }
-
- bool operator !=(const CSize_t &x) const { (*this).assert_initialized(); return (m_val != x.m_val); }
- bool operator !=(const CInt &x) const { (*this).assert_initialized(); return (CInt(m_val) != x); }
- bool operator !=(long long x) const { (*this).assert_initialized(); return ((*this) != CInt(x)); }
- bool operator !=(long x) const { (*this).assert_initialized(); return ((*this) != CInt(x)); }
- bool operator !=(int x) const { (*this).assert_initialized(); return ((*this) != CInt(x)); }
- bool operator !=(short x) const { (*this).assert_initialized(); return ((*this) != CInt(x)); }
- bool operator !=(char x) const { (*this).assert_initialized(); return ((*this) != CInt(x)); }
- bool operator !=(size_t x) const { (*this).assert_initialized(); return ((*this) != CSize_t(x)); }
-
- // INCREMENT/DECREMENT OPERATORS
- CSize_t& operator ++() { (*this).assert_initialized(); m_val++; return (*this); }
- CSize_t operator ++(int) { (*this).assert_initialized();
- CSize_t tmp(*this); // copy
- operator++(); // pre-increment
- return tmp; // return old value
- }
- CSize_t& operator --() { (*this).assert_initialized();
- if (0 <= std::numeric_limits<_Ty>::lowest()) { (*this).assert_initialized();
- (*this) = (*this) - 1; return (*this);
- }
- else { (*this).assert_initialized();
- m_val--; return (*this);
- }
- }
- CSize_t operator --(int) { (*this).assert_initialized();
- CSize_t tmp(*this); // copy
- operator--(); // pre-decrement
- return tmp; // return old value
- }
-
- //_Ty m_val;
-
- friend size_t as_a_size_t(CSize_t n);
- };
- size_t as_a_size_t(CSize_t n) { n.assert_initialized(); return n.m_val; }
-}
-
-namespace std {
-#ifndef _THROW0
-#define _THROW0()
-#endif // !_THROW0
-#ifndef _STCONS
-#define _STCONS(ty, name, val) static constexpr ty name = (ty)(val)
-#endif // !_STCONS
-
- template<> class numeric_limits<mse::CSize_t> { // limits for type int
- public:
- typedef size_t _Ty;
-
- static constexpr _Ty(min)() _THROW0()
- { // return minimum value
- return numeric_limits<size_t>::min();
- }
- static constexpr _Ty(max)() _THROW0()
- { // return maximum value
- return numeric_limits<size_t>::max();
- }
- static constexpr _Ty lowest() _THROW0()
- { // return most negative value
- return numeric_limits<size_t>::lowest();
- }
- static constexpr _Ty epsilon() _THROW0()
- { // return smallest effective increment from 1.0
- return numeric_limits<size_t>::epsilon();
- }
- static constexpr _Ty round_error() _THROW0()
- { // return largest rounding error
- return numeric_limits<size_t>::round_error();
- }
- static constexpr _Ty denorm_min() _THROW0()
- { // return minimum denormalized value
- return numeric_limits<size_t>::denorm_min();
- }
- static constexpr _Ty infinity() _THROW0()
- { // return positive infinity
- return numeric_limits<size_t>::infinity();
- }
- static constexpr _Ty quiet_NaN() _THROW0()
- { // return non-signaling NaN
- return numeric_limits<size_t>::quiet_NaN();
- }
- static constexpr _Ty signaling_NaN() _THROW0()
- { // return signaling NaN
- return numeric_limits<size_t>::signaling_NaN();
- }
- _STCONS(float_denorm_style, has_denorm, numeric_limits<size_t>::has_denorm);
- _STCONS(bool, has_denorm_loss, numeric_limits<size_t>::has_denorm_loss);
- _STCONS(bool, has_infinity, numeric_limits<size_t>::has_infinity);
- _STCONS(bool, has_quiet_NaN, numeric_limits<size_t>::has_quiet_NaN);
- _STCONS(bool, has_signaling_NaN, numeric_limits<size_t>::has_signaling_NaN);
- _STCONS(bool, is_bounded, numeric_limits<size_t>::is_bounded);
- _STCONS(bool, is_exact, numeric_limits<size_t>::is_exact);
- _STCONS(bool, is_iec559, numeric_limits<size_t>::is_iec559);
- _STCONS(bool, is_integer, numeric_limits<size_t>::is_integer);
- _STCONS(bool, is_modulo, numeric_limits<size_t>::is_modulo);
- _STCONS(bool, is_signed, numeric_limits<size_t>::is_signed);
- _STCONS(bool, is_specialized, numeric_limits<size_t>::is_specialized);
- _STCONS(bool, tinyness_before, numeric_limits<size_t>::tinyness_before);
- _STCONS(bool, traps, numeric_limits<size_t>::traps);
- _STCONS(float_round_style, round_style, numeric_limits<size_t>::round_style);
- _STCONS(int, digits, numeric_limits<size_t>::digits);
- _STCONS(int, digits10, numeric_limits<size_t>::digits10);
- _STCONS(int, max_digits10, numeric_limits<size_t>::max_digits10);
- _STCONS(int, max_exponent, numeric_limits<size_t>::max_exponent);
- _STCONS(int, max_exponent10, numeric_limits<size_t>::max_exponent10);
- _STCONS(int, min_exponent, numeric_limits<size_t>::min_exponent);
- _STCONS(int, min_exponent10, numeric_limits<size_t>::min_exponent10);
- _STCONS(int, radix, numeric_limits<size_t>::radix);
- };
-}
-
-namespace mse {
-
- inline CInt operator+(size_t lhs, const CInt &rhs) { rhs.assert_initialized(); rhs.assert_initialized(); return CSize_t(lhs) + rhs; }
- inline CSize_t operator+(size_t lhs, const CSize_t &rhs) { rhs.assert_initialized(); return CSize_t(lhs) + rhs; }
- inline CInt operator+(int lhs, const CInt &rhs) { rhs.assert_initialized(); return CInt(lhs) + rhs; }
- inline CInt operator+(int lhs, const CSize_t &rhs) { rhs.assert_initialized(); return CInt(lhs) + as_a_size_t(rhs); }
- inline CInt operator+(const CInt &lhs, const CSize_t &rhs) { rhs.assert_initialized(); return lhs + as_a_size_t(rhs); }
- inline CInt operator-(size_t lhs, const CInt &rhs) { rhs.assert_initialized(); return CSize_t(lhs) - rhs; }
- inline CInt operator-(size_t lhs, const CSize_t &rhs) { rhs.assert_initialized(); return CSize_t(lhs) - rhs; }
- inline CInt operator-(int lhs, const CInt &rhs) { rhs.assert_initialized(); return CInt(lhs) - rhs; }
- inline CInt operator-(int lhs, const CSize_t &rhs) { rhs.assert_initialized(); return CInt(lhs) - as_a_size_t(rhs); }
- inline CInt operator-(const CInt &lhs, const CSize_t &rhs) { rhs.assert_initialized(); return lhs - as_a_size_t(rhs); }
- inline CInt operator*(size_t lhs, const CInt &rhs) { rhs.assert_initialized(); return CSize_t(lhs) * rhs; }
- inline CSize_t operator*(size_t lhs, const CSize_t &rhs) { rhs.assert_initialized(); return CSize_t(lhs) * rhs; }
- inline CInt operator*(int lhs, const CInt &rhs) { rhs.assert_initialized(); return CInt(lhs) * rhs; }
- inline CInt operator*(int lhs, const CSize_t &rhs) { rhs.assert_initialized(); return CInt(lhs) * as_a_size_t(rhs); }
- inline CInt operator*(const CInt &lhs, const CSize_t &rhs) { rhs.assert_initialized(); return lhs * as_a_size_t(rhs); }
- inline CInt operator/(size_t lhs, const CInt &rhs) { rhs.assert_initialized(); return CSize_t(lhs) / rhs; }
- inline CSize_t operator/(size_t lhs, const CSize_t &rhs) { rhs.assert_initialized(); return CSize_t(lhs) / rhs; }
- inline CInt operator/(int lhs, const CInt &rhs) { rhs.assert_initialized(); return CInt(lhs) / rhs; }
- inline CInt operator/(int lhs, const CSize_t &rhs) { rhs.assert_initialized(); return CInt(lhs) / as_a_size_t(rhs); }
- inline CInt operator/(const CInt &lhs, const CSize_t &rhs) { rhs.assert_initialized(); return lhs / as_a_size_t(rhs); }
-
- inline bool operator<(size_t lhs, const CInt &rhs) { rhs.assert_initialized(); return CSize_t(lhs) < rhs; }
- inline bool operator<(size_t lhs, const CSize_t &rhs) { rhs.assert_initialized(); return CSize_t(lhs) < rhs; }
- inline bool operator<(int lhs, const CInt &rhs) { rhs.assert_initialized(); return CInt(lhs) < rhs; }
- inline bool operator<(int lhs, const CSize_t &rhs) { rhs.assert_initialized(); return CInt(lhs) < as_a_size_t(rhs); }
- inline bool operator<(long long lhs, const CInt &rhs) { rhs.assert_initialized(); return CInt(lhs) < rhs; }
- inline bool operator<(long long lhs, const CSize_t &rhs) { rhs.assert_initialized(); return CInt(lhs) < as_a_size_t(rhs); }
- inline bool operator<(const CInt &lhs, const CSize_t &rhs) { rhs.assert_initialized(); return lhs < as_a_size_t(rhs); }
- inline bool operator>(size_t lhs, const CInt &rhs) { rhs.assert_initialized(); return CSize_t(lhs) > rhs; }
- inline bool operator>(size_t lhs, const CSize_t &rhs) { rhs.assert_initialized(); return CSize_t(lhs) > rhs; }
- inline bool operator>(int lhs, const CInt &rhs) { rhs.assert_initialized(); return CInt(lhs) > rhs; }
- inline bool operator>(int lhs, const CSize_t &rhs) { rhs.assert_initialized(); return CInt(lhs) > as_a_size_t(rhs); }
- inline bool operator>(long long lhs, const CInt &rhs) { rhs.assert_initialized(); return CInt(lhs) > rhs; }
- inline bool operator>(long long lhs, const CSize_t &rhs) { rhs.assert_initialized(); return CInt(lhs) > as_a_size_t(rhs); }
- inline bool operator>(const CInt &lhs, const CSize_t &rhs) { rhs.assert_initialized(); return lhs > as_a_size_t(rhs); }
- inline bool operator<=(size_t lhs, const CInt &rhs) { rhs.assert_initialized(); return CSize_t(lhs) <= rhs; }
- inline bool operator<=(size_t lhs, const CSize_t &rhs) { rhs.assert_initialized(); return CSize_t(lhs) <= rhs; }
- inline bool operator<=(int lhs, const CInt &rhs) { rhs.assert_initialized(); return CInt(lhs) <= rhs; }
- inline bool operator<=(int lhs, const CSize_t &rhs) { rhs.assert_initialized(); return CInt(lhs) <= as_a_size_t(rhs); }
- inline bool operator<=(long long lhs, const CInt &rhs) { rhs.assert_initialized(); return CInt(lhs) <= rhs; }
- inline bool operator<=(long long lhs, const CSize_t &rhs) { rhs.assert_initialized(); return CInt(lhs) <= as_a_size_t(rhs); }
- inline bool operator<=(const CInt &lhs, const CSize_t &rhs) { rhs.assert_initialized(); return lhs <= as_a_size_t(rhs); }
- inline bool operator>=(size_t lhs, const CInt &rhs) { rhs.assert_initialized(); return CSize_t(lhs) >= rhs; }
- inline bool operator>=(size_t lhs, const CSize_t &rhs) { rhs.assert_initialized(); return CSize_t(lhs) >= rhs; }
- inline bool operator>=(int lhs, const CInt &rhs) { rhs.assert_initialized(); return CInt(lhs) >= rhs; }
- inline bool operator>=(int lhs, const CSize_t &rhs) { rhs.assert_initialized(); return CInt(lhs) >= as_a_size_t(rhs); }
- inline bool operator>=(long long lhs, const CInt &rhs) { rhs.assert_initialized(); return CInt(lhs) >= rhs; }
- inline bool operator>=(long long lhs, const CSize_t &rhs) { rhs.assert_initialized(); return CInt(lhs) >= as_a_size_t(rhs); }
- inline bool operator>=(const CInt &lhs, const CSize_t &rhs) { rhs.assert_initialized(); return lhs >= as_a_size_t(rhs); }
- inline bool operator==(size_t lhs, const CInt &rhs) { rhs.assert_initialized(); return CSize_t(lhs) == rhs; }
- inline bool operator==(size_t lhs, const CSize_t &rhs) { rhs.assert_initialized(); return CSize_t(lhs) == rhs; }
- inline bool operator==(int lhs, const CInt &rhs) { rhs.assert_initialized(); return CInt(lhs) == rhs; }
- inline bool operator==(int lhs, const CSize_t &rhs) { rhs.assert_initialized(); return CInt(lhs) == as_a_size_t(rhs); }
- inline bool operator==(long long lhs, const CInt &rhs) { rhs.assert_initialized(); return CInt(lhs) == rhs; }
- inline bool operator==(long long lhs, const CSize_t &rhs) { rhs.assert_initialized(); return CInt(lhs) == as_a_size_t(rhs); }
- inline bool operator==(const CInt &lhs, const CSize_t &rhs) { rhs.assert_initialized(); return lhs == as_a_size_t(rhs); }
- inline bool operator!=(size_t lhs, const CInt &rhs) { rhs.assert_initialized(); return CSize_t(lhs) != rhs; }
- inline bool operator!=(size_t lhs, const CSize_t &rhs) { rhs.assert_initialized(); return CSize_t(lhs) != rhs; }
- inline bool operator!=(int lhs, const CInt &rhs) { rhs.assert_initialized(); return CInt(lhs) != rhs; }
- inline bool operator!=(int lhs, const CSize_t &rhs) { rhs.assert_initialized(); return CInt(lhs) != as_a_size_t(rhs); }
- inline bool operator!=(long long lhs, const CInt &rhs) { rhs.assert_initialized(); return CInt(lhs) != rhs; }
- inline bool operator!=(long long lhs, const CSize_t &rhs) { rhs.assert_initialized(); return CInt(lhs) != as_a_size_t(rhs); }
- inline bool operator!=(const CInt &lhs, const CSize_t &rhs) { rhs.assert_initialized(); return lhs != as_a_size_t(rhs); }
-#endif /*MSE_PRIMITIVES_DISABLED*/
-
- static void s_type_test1() {
-#ifdef MSE_SELF_TESTS
- CInt i1(3);
- CInt i2 = 5;
- CInt i3;
- i3 = 7;
- CInt i4 = i1 + i2;
- i4 = i1 + 17;
- i4 = 19 + i1;
- i4 += i2;
- i4 -= 23;
- i4++;
- CBool b1 = (i1 < i2);
- b1 = (i1 < 17);
- b1 = (19 < i1);
- b1 = (i1 == i2);
- b1 = (i1 == 17);
- b1 = (19 == i1);
-
- CSize_t szt1(3);
- CSize_t szt2 = 5;
- CSize_t szt3;
- szt3 = 7;
- CSize_t szt4 = szt1 + szt2;
- szt4 = szt1 + 17;
- szt4 = 19 + szt1;
- CInt i11 = 19 + szt1;
- szt4 += szt2;
- szt4 -= 23;
- szt4++;
-#ifndef MSVC2010_COMPATIBLE
- size_t szt5 = size_t(szt4);
-#endif /*MSVC2010_COMPATIBLE*/
- bool b3 = (szt1 < szt2);
- b3 = (szt1 < 17);
- b3 = (19 < szt1);
- CBool b2 = (19 < szt1);
- b3 = (szt1 == szt2);
- b3 = (szt1 == 17);
- b3 = (19 == szt1);
- CBool b4 = (b1 < b2);
- b4 = (b1 == b2);
- b4 = (b1 > b3);
- b4 = (b3 >= b1);
- b4 = (b3 == b1);
- b4 = (b1 && b2);
- b4 = (b1 || b3);
- b4 = (b3 && b1);
- b4 |= b1;
- b4 &= b3;
-#endif // MSE_SELF_TESTS
- }
-}
-
-#undef MSE_THROW
-
-#endif /*ndef MSEPRIMITIVES_H*/
diff --git a/src/debug/mse/source.txt b/src/debug/mse/source.txt
deleted file mode 100644
index 00dc79b25..000000000
--- a/src/debug/mse/source.txt
+++ /dev/null
@@ -1 +0,0 @@
-https://github.com/duneroadrunner/SaferCPlusPlus
diff --git a/src/debug/nvwa/_nvwa.h b/src/debug/nvwa/_nvwa.h
deleted file mode 100644
index 096893c59..000000000
--- a/src/debug/nvwa/_nvwa.h
+++ /dev/null
@@ -1,112 +0,0 @@
-// -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
-// vim:tabstop=4:shiftwidth=4:expandtab:
-
-/*
- * Copyright (C) 2013-2015 Wu Yongwei <adah at users dot sourceforge dot net>
- *
- * This software is provided 'as-is', without any express or implied
- * warranty. In no event will the authors be held liable for any
- * damages arising from the use of this software.
- *
- * Permission is granted to anyone to use this software for any purpose,
- * including commercial applications, and to alter it and redistribute
- * it freely, subject to the following restrictions:
- *
- * 1. The origin of this software must not be misrepresented; you must
- * not claim that you wrote the original software. If you use this
- * software in a product, an acknowledgement in the product
- * documentation would be appreciated but is not required.
- * 2. Altered source versions must be plainly marked as such, and must
- * not be misrepresented as being the original software.
- * 3. This notice may not be removed or altered from any source
- * distribution.
- *
- * This file is part of Stones of Nvwa:
- * http://sourceforge.net/projects/nvwa
- *
- */
-
-/**
- * @file _nvwa.h
- *
- * Common definitions for preprocessing.
- *
- * @date 2015-10-28
- */
-
-#ifndef NVWA_NVWA_H
-#define NVWA_NVWA_H
-
-/**
- * @namespace nvwa
- * Namespace of the nvwa project. Most functions and global variables
- * are defined in this namespace.
- */
-
-#ifndef NVWA_USE_NAMESPACE
-#ifdef __cplusplus
-#define NVWA_USE_NAMESPACE 1
-#else
-#define NVWA_USE_NAMESPACE 0
-#endif // __cplusplus
-#endif // NVWA_USE_NAMESPACE
-
-#if NVWA_USE_NAMESPACE
-#define NVWA_NAMESPACE_BEGIN namespace nvwa {
-#define NVWA_NAMESPACE_END }
-#define NVWA nvwa
-#else // NVWA_USE_NAMESPACE
-#define NVWA_NAMESPACE_BEGIN
-#define NVWA_NAMESPACE_END
-#define NVWA
-#endif // NVWA_USE_NAMESPACE
-
-#ifndef NVWA_APPLE
-#if defined(__APPLE__) && defined(__MACH__)
-#define NVWA_APPLE 1
-#else
-#define NVWA_APPLE 0
-#endif
-#endif // NVWA_APPLE
-
-#ifndef NVWA_CYGWIN
-#if defined(__CYGWIN__)
-#define NVWA_CYGWIN 1
-#else
-#define NVWA_CYGWIN 0
-#endif
-#endif // NVWA_CYGWIN
-
-#ifndef NVWA_LINUX
-#if defined(__linux__) || defined(__linux)
-#define NVWA_LINUX 1
-#else
-#define NVWA_LINUX 0
-#endif
-#endif // NVWA_LINUX
-
-#ifndef NVWA_UNIX
-#if defined(__unix__) || defined(__unix) || NVWA_APPLE
-#define NVWA_UNIX 1
-#else
-#define NVWA_UNIX 0
-#endif
-#endif // NVWA_UNIX
-
-#ifndef NVWA_WIN32
-#if defined(_WIN32)
-#define NVWA_WIN32 1
-#else
-#define NVWA_WIN32 0
-#endif
-#endif // NVWA_WIN32
-
-#ifndef NVWA_WINDOWS
-#if NVWA_CYGWIN || NVWA_WIN32
-#define NVWA_WINDOWS 1
-#else
-#define NVWA_WINDOWS 0
-#endif
-#endif // NVWA_WINDOWS
-
-#endif // NVWA_NVWA_H
diff --git a/src/debug/nvwa/c++11.h b/src/debug/nvwa/c++11.h
deleted file mode 100644
index 8d8e2d8af..000000000
--- a/src/debug/nvwa/c++11.h
+++ /dev/null
@@ -1,340 +0,0 @@
-// -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
-// vim:tabstop=4:shiftwidth=4:expandtab:
-
-/*
- * Copyright (C) 2013-2017 Wu Yongwei <adah at users dot sourceforge dot net>
- *
- * This software is provided 'as-is', without any express or implied
- * warranty. In no event will the authors be held liable for any
- * damages arising from the use of this software.
- *
- * Permission is granted to anyone to use this software for any purpose,
- * including commercial applications, and to alter it and redistribute
- * it freely, subject to the following restrictions:
- *
- * 1. The origin of this software must not be misrepresented; you must
- * not claim that you wrote the original software. If you use this
- * software in a product, an acknowledgement in the product
- * documentation would be appreciated but is not required.
- * 2. Altered source versions must be plainly marked as such, and must
- * not be misrepresented as being the original software.
- * 3. This notice may not be removed or altered from any source
- * distribution.
- *
- * This file is part of Stones of Nvwa:
- * http://sourceforge.net/projects/nvwa
- *
- */
-
-/**
- * @file c++11.h
- *
- * C++11 feature detection macros and workarounds.
- *
- * @date 2017-04-03
- */
-
-#ifndef NVWA_CXX11_H
-#define NVWA_CXX11_H
-
-// Only Clang provides these macros; they need to be defined as follows
-// to get a valid expression in preprocessing by other compilers.
-#ifndef __has_extension
-#define __has_extension(x) 0
-#endif
-#ifndef __has_feature
-#define __has_feature(x) 0
-#endif
-#ifndef __has_include
-#define __has_include(x) 0
-#endif
-
-// Detect whether C++11 mode is on (for GCC and Clang). MSVC does not
-// have a special C++11 mode, so it is always on for Visual C++ 2010 and
-// later.
-#if __cplusplus >= 201103L || \
- defined(__GXX_EXPERIMENTAL_CXX0X__) || \
- (defined(_MSC_VER) && _MSC_VER >= 1600)
-#define NVWA_CXX11_MODE 1
-#else
-#define NVWA_CXX11_MODE 0
-#endif
-
-
-/* Feature checks */
-
-#if !defined(HAVE_CXX11_ATOMIC)
-#if NVWA_CXX11_MODE && \
- ((__has_include(<atomic>) && !defined(__MINGW32__)) || \
- (defined(_MSC_VER) && _MSC_VER >= 1700) || \
- (((defined(__GNUC__) && __GNUC__ * 100 + __GNUC_MINOR__ >= 405) || \
- defined(__clang__)) && \
- (!defined(__MINGW32__) || defined(_POSIX_THREADS))))
-// Note: MinGW GCC, unless built with POSIX threads (as in
-// MinGW-builds), does not support atomics as of 4.8.
-#define HAVE_CXX11_ATOMIC 1
-#else
-#define HAVE_CXX11_ATOMIC 0
-#endif
-#endif
-
-#if !defined(HAVE_CXX11_AUTO_TYPE)
-#if NVWA_CXX11_MODE && \
- (__has_feature(cxx_auto_type) || \
- (defined(_MSC_VER) && _MSC_VER >= 1600) || \
- (defined(__GNUC__) && __GNUC__ * 100 + __GNUC_MINOR__ >= 404))
-#define HAVE_CXX11_AUTO_TYPE 1
-#else
-#define HAVE_CXX11_AUTO_TYPE 0
-#endif
-#endif
-
-#if !defined(HAVE_CXX11_DELETED_FUNCTION)
-#if NVWA_CXX11_MODE && \
- (__has_feature(cxx_deleted_functions) || \
- (defined(_MSC_VER) && _MSC_VER >= 1800) || \
- (defined(__GNUC__) && __GNUC__ * 100 + __GNUC_MINOR__ >= 404))
-#define HAVE_CXX11_DELETED_FUNCTION 1
-#else
-#define HAVE_CXX11_DELETED_FUNCTION 0
-#endif
-#endif
-
-#if !defined(HAVE_CXX11_EXPLICIT_CONVERSION)
-#if NVWA_CXX11_MODE && \
- (__has_feature(cxx_explicit_conversions) || \
- (defined(_MSC_VER) && _MSC_VER >= 1900) || \
- (defined(__GNUC__) && __GNUC__ * 100 + __GNUC_MINOR__ >= 405))
-#define HAVE_CXX11_EXPLICIT_CONVERSION 1
-#else
-#define HAVE_CXX11_EXPLICIT_CONVERSION 0
-#endif
-#endif
-
-#if !defined(HAVE_CXX11_FINAL)
-#if NVWA_CXX11_MODE && \
- (__has_feature(cxx_override_control) || \
- (defined(_MSC_VER) && _MSC_VER >= 1700) || \
- (defined(__GNUC__) && __GNUC__ * 100 + __GNUC_MINOR__ >= 407))
-#define HAVE_CXX11_FINAL 1
-#else
-#define HAVE_CXX11_FINAL 0
-#endif
-#endif
-
-#if !defined(HAVE_CXX11_FUTURE)
-#if NVWA_CXX11_MODE && \
- ((__has_include(<future>) && !defined(__MINGW32__)) || \
- (defined(_MSC_VER) && _MSC_VER >= 1700) || \
- (((defined(__GNUC__) && __GNUC__ * 100 + __GNUC_MINOR__ >= 405) || \
- defined(__clang__)) && \
- (!defined(__MINGW32__) || defined(_POSIX_THREADS))))
-// Note: MinGW GCC, unless built with POSIX threads (as in
-// MinGW-builds), does not support futures as of 4.8.
-#define HAVE_CXX11_FUTURE 1
-#else
-#define HAVE_CXX11_FUTURE 0
-#endif
-#endif
-
-#if !defined(HAVE_CXX11_GENERALIZED_INITIALIZER)
-#if NVWA_CXX11_MODE && \
- (__has_feature(cxx_generalized_initializers) || \
- (defined(_MSC_VER) && _MSC_VER >= 1800) || \
- (defined(__GNUC__) && __GNUC__ * 100 + __GNUC_MINOR__ >= 404))
-#define HAVE_CXX11_GENERALIZED_INITIALIZER 1
-#else
-#define HAVE_CXX11_GENERALIZED_INITIALIZER 0
-#endif
-#endif
-
-#if !defined(HAVE_CXX11_LAMBDA)
-#if NVWA_CXX11_MODE && \
- (__has_feature(cxx_lambdas) || \
- (defined(_MSC_VER) && _MSC_VER >= 1600) || \
- (defined(__GNUC__) && __GNUC__ * 100 + __GNUC_MINOR__ >= 405))
-#define HAVE_CXX11_LAMBDA 1
-#else
-#define HAVE_CXX11_LAMBDA 0
-#endif
-#endif
-
-#if !defined(HAVE_CXX11_MUTEX)
-#if NVWA_CXX11_MODE && \
- ((__has_include(<mutex>) && !defined(__MINGW32__)) || \
- (defined(_MSC_VER) && _MSC_VER >= 1700) || \
- (((defined(__GNUC__) && __GNUC__ * 100 + __GNUC_MINOR__ >= 403) || \
- defined(__clang__)) && \
- (!defined(__MINGW32__) || defined(_POSIX_THREADS))))
-// Note: MinGW GCC, unless built with POSIX threads (as in
-// MinGW-builds), does not support std::mutex as of 4.8.
-#define HAVE_CXX11_MUTEX 1
-#else
-#define HAVE_CXX11_MUTEX 0
-#endif
-#endif
-
-#if !defined(HAVE_CXX11_NOEXCEPT)
-#if NVWA_CXX11_MODE && \
- (__has_feature(cxx_noexcept) || \
- (defined(_MSC_VER) && _MSC_VER >= 1900) || \
- (defined(__GNUC__) && __GNUC__ * 100 + __GNUC_MINOR__ >= 406))
-#define HAVE_CXX11_NOEXCEPT 1
-#else
-#define HAVE_CXX11_NOEXCEPT 0
-#endif
-#endif
-
-#if !defined(HAVE_CXX11_NULLPTR)
-#if NVWA_CXX11_MODE && \
- (__has_feature(cxx_nullptr) || \
- (defined(_MSC_VER) && _MSC_VER >= 1600) || \
- (defined(__GNUC__) && __GNUC__ * 100 + __GNUC_MINOR__ >= 406))
-#define HAVE_CXX11_NULLPTR 1
-#else
-#define HAVE_CXX11_NULLPTR 0
-#endif
-#endif
-
-#if !defined(HAVE_CXX11_OVERRIDE)
-#if NVWA_CXX11_MODE && \
- (__has_feature(cxx_override_control) || \
- (defined(_MSC_VER) && _MSC_VER >= 1600) || \
- (defined(__GNUC__) && __GNUC__ * 100 + __GNUC_MINOR__ >= 407))
-#define HAVE_CXX11_OVERRIDE 1
-#else
-#define HAVE_CXX11_OVERRIDE 0
-#endif
-#endif
-
-#if !defined(HAVE_CXX11_RANGE_FOR)
-#if NVWA_CXX11_MODE && \
- (__has_feature(cxx_range_for) || \
- (defined(_MSC_VER) && _MSC_VER >= 1700) || \
- (defined(__GNUC__) && __GNUC__ * 100 + __GNUC_MINOR__ >= 406))
-#define HAVE_CXX11_RANGE_FOR 1
-#else
-#define HAVE_CXX11_RANGE_FOR 0
-#endif
-#endif
-
-#if !defined(HAVE_CXX11_RVALUE_REFERENCE)
-#if NVWA_CXX11_MODE && \
- (__has_feature(cxx_rvalue_references) || \
- (defined(_MSC_VER) && _MSC_VER >= 1600) || \
- (defined(__GNUC__) && __GNUC__ * 100 + __GNUC_MINOR__ >= 405))
-#define HAVE_CXX11_RVALUE_REFERENCE 1
-#else
-#define HAVE_CXX11_RVALUE_REFERENCE 0
-#endif
-#endif
-
-#if !defined(HAVE_CXX11_STATIC_ASSERT)
-#if NVWA_CXX11_MODE && \
- (__has_feature(cxx_static_assert) || \
- (defined(_MSC_VER) && _MSC_VER >= 1600) || \
- (defined(__GNUC__) && __GNUC__ * 100 + __GNUC_MINOR__ >= 403))
-#define HAVE_CXX11_STATIC_ASSERT 1
-#else
-#define HAVE_CXX11_STATIC_ASSERT 0
-#endif
-#endif
-
-#if !defined(HAVE_CXX11_THREAD)
-#if NVWA_CXX11_MODE && \
- ((__has_include(<thread>) && !defined(__MINGW32__)) || \
- (defined(_MSC_VER) && _MSC_VER >= 1700) || \
- (((defined(__GNUC__) && __GNUC__ * 100 + __GNUC_MINOR__ >= 404) || \
- defined(__clang__)) && \
- (!defined(__MINGW32__) || defined(_POSIX_THREADS))))
-// Note: MinGW GCC, unless built with POSIX threads (as in
-// MinGW-builds), does not support std::thread as of 4.8.
-#define HAVE_CXX11_THREAD 1
-#else
-#define HAVE_CXX11_THREAD 0
-#endif
-#endif
-
-#if !defined(HAVE_CXX11_THREAD_LOCAL)
-#if NVWA_CXX11_MODE && \
- (__has_feature(cxx_thread_local) || \
- (defined(_MSC_VER) && _MSC_VER >= 1900) || \
- (defined(__GNUC__) && __GNUC__ * 100 + __GNUC_MINOR__ >= 408))
-#define HAVE_CXX11_THREAD_LOCAL 1
-#else
-#define HAVE_CXX11_THREAD_LOCAL 0
-#endif
-#endif
-
-#if !defined(HAVE_CXX11_TYPE_TRAITS)
-#if NVWA_CXX11_MODE && \
- (__has_include(<type_traits>) || \
- (defined(_MSC_VER) && _MSC_VER >= 1600) || \
- (defined(__GNUC__) && __GNUC__ * 100 + __GNUC_MINOR__ >= 403))
-#define HAVE_CXX11_TYPE_TRAITS 1
-#else
-#define HAVE_CXX11_TYPE_TRAITS 0
-#endif
-#endif
-
-#if !defined(HAVE_CXX11_UNICODE_LITERAL)
-#if NVWA_CXX11_MODE && \
- (__has_feature(cxx_unicode_literals) || \
- (defined(_MSC_VER) && _MSC_VER >= 1900) || \
- (defined(__GNUC__) && __GNUC__ * 100 + __GNUC_MINOR__ >= 405))
-#define HAVE_CXX11_UNICODE_LITERAL 1
-#else
-#define HAVE_CXX11_UNICODE_LITERAL 0
-#endif
-#endif
-
-
-/* Workarounds */
-
-#if HAVE_CXX11_DELETED_FUNCTION
-#define _DELETED = delete
-#else
-#define _DELETED
-#endif
-
-#if HAVE_CXX11_FINAL
-#define _FINAL final
-#else
-#define _FINAL
-#endif
-
-#if HAVE_CXX11_OVERRIDE
-#define _OVERRIDE override
-#else
-#define _OVERRIDE
-#endif
-
-#if HAVE_CXX11_NOEXCEPT
-#define _NOEXCEPT noexcept
-#define _NOEXCEPT_(x) noexcept(x)
-#else
-#ifdef _MSC_VER
-#define _NOEXCEPT throw ()
-#else
-#define _NOEXCEPT throw()
-#endif
-#define _NOEXCEPT_(x)
-#endif
-
-#if HAVE_CXX11_NULLPTR
-#define _NULLPTR nullptr
-#else
-#define _NULLPTR NULL
-#endif
-
-#if HAVE_CXX11_THREAD_LOCAL
-#define _THREAD_LOCAL thread_local
-#else
-#ifdef _MSC_VER
-#define _THREAD_LOCAL __declspec(thread)
-#else
-#define _THREAD_LOCAL __thread
-#endif
-#endif
-
-#endif // NVWA_CXX11_H
diff --git a/src/debug/nvwa/debug_new.cpp b/src/debug/nvwa/debug_new.cpp
deleted file mode 100644
index 77ef8f17e..000000000
--- a/src/debug/nvwa/debug_new.cpp
+++ /dev/null
@@ -1,1197 +0,0 @@
-// -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
-// vim:tabstop=4:shiftwidth=4:expandtab:
-
-/*
- * Copyright (C) 2004-2016 Wu Yongwei <adah at users dot sourceforge dot net>
- *
- * This software is provided 'as-is', without any express or implied
- * warranty. In no event will the authors be held liable for any
- * damages arising from the use of this software.
- *
- * Permission is granted to anyone to use this software for any purpose,
- * including commercial applications, and to alter it and redistribute
- * it freely, subject to the following restrictions:
- *
- * 1. The origin of this software must not be misrepresented; you must
- * not claim that you wrote the original software. If you use this
- * software in a product, an acknowledgement in the product
- * documentation would be appreciated but is not required.
- * 2. Altered source versions must be plainly marked as such, and must
- * not be misrepresented as being the original software.
- * 3. This notice may not be removed or altered from any source
- * distribution.
- *
- * This file is part of Stones of Nvwa:
- * http://sourceforge.net/projects/nvwa
- *
- */
-
-/**
- * @file debug_new.cpp
- *
- * Implementation of debug versions of new and delete to check leakage.
- *
- * @date 2016-10-14
- */
-
-#include "localconsts.h"
-
-PRAGMACLANG6GCC(GCC diagnostic push)
-PRAGMACLANG6GCC(GCC diagnostic ignored "-Wold-style-cast")
-
-PRAGMA45(GCC diagnostic push)
-PRAGMA45(GCC diagnostic ignored "-Wcast-qual")
-
-#include <new> // std::bad_alloc/nothrow_t
-#include <assert.h> // assert
-#include <stdio.h> // fprintf/stderr
-#include <stdlib.h> // abort
-#include <string.h> // strcpy/strncpy/sprintf
-#include "debug/nvwa/_nvwa.h" // NVWA macros
-
-#if NVWA_UNIX
-#include <alloca.h> // alloca
-#endif
-#if NVWA_WIN32
-#include <malloc.h> // alloca
-#endif
-
-#if NVWA_LINUX || NVWA_APPLE
-#include <execinfo.h> // backtrace
-#endif
-
-#if NVWA_WINDOWS
-#ifndef WIN32_LEAN_AND_MEAN
-#define WIN32_LEAN_AND_MEAN
-#endif
-#include <windows.h> // CaptureStackBackTrace
-#endif
-
-#include "debug/nvwa/c++11.h" // _NOEXCEPT/_NULLPTR
-#include "debug/nvwa/fast_mutex.h" // nvwa::fast_mutex
-#include "debug/nvwa/static_assert.h" // STATIC_ASSERT
-
-#undef _DEBUG_NEW_EMULATE_MALLOC
-#undef _DEBUG_NEW_REDEFINE_NEW
-/**
- * Macro to indicate whether redefinition of \c new is wanted. Here it
- * is defined to \c 0 to disable the redefinition of \c new.
- */
-#define _DEBUG_NEW_REDEFINE_NEW 0
-#include "debug/nvwa/debug_new.h"
-
-#if !_FAST_MUTEX_CHECK_INITIALIZATION && !defined(_NOTHREADS)
-#error "_FAST_MUTEX_CHECK_INITIALIZATION not set: check_leaks may not work"
-#endif
-
-/**
- * @def _DEBUG_NEW_ALIGNMENT
- *
- * The alignment requirement of allocated memory blocks. It must be a
- * power of two.
- */
-#ifndef _DEBUG_NEW_ALIGNMENT
-#define _DEBUG_NEW_ALIGNMENT 16
-#endif
-
-/**
- * @def _DEBUG_NEW_CALLER_ADDRESS
- *
- * The expression to return the caller address. nvwa#print_position will
- * later on use this address to print the position information of memory
- * operation points.
- */
-#ifndef _DEBUG_NEW_CALLER_ADDRESS
-#ifdef __GNUC__
-#define _DEBUG_NEW_CALLER_ADDRESS __builtin_return_address(0)
-#else
-#define _DEBUG_NEW_CALLER_ADDRESS _NULLPTR
-#endif
-#endif
-
-/**
- * @def _DEBUG_NEW_ERROR_ACTION
- *
- * The action to take when an error occurs. The default behaviour is to
- * call \e abort, unless \c _DEBUG_NEW_ERROR_CRASH is defined, in which
- * case a segmentation fault will be triggered instead (which can be
- * useful on platforms like Windows that do not generate a core dump
- * when \e abort is called).
- */
-#ifndef _DEBUG_NEW_ERROR_ACTION
-#ifndef _DEBUG_NEW_ERROR_CRASH
-#define _DEBUG_NEW_ERROR_ACTION abort()
-#else
-#define _DEBUG_NEW_ERROR_ACTION do { *((char*)0) = 0; abort(); } while (0)
-#endif
-#endif
-
-/**
- * @def _DEBUG_NEW_FILENAME_LEN
- *
- * The length of file name stored if greater than zero. If it is zero,
- * only a const char pointer will be stored. Currently the default
- * value is non-zero (thus to copy the file name) on non-Windows
- * platforms, because I once found that the exit leakage check could not
- * access the address of the file name on Linux (in my case, a core dump
- * occurred when check_leaks tried to access the file name in a shared
- * library after a \c SIGINT). This value makes the size of
- * new_ptr_list_t \c 64 on non-Windows 32-bit platforms (w/o stack
- * backtrace).
- */
-#ifndef _DEBUG_NEW_FILENAME_LEN
-#if NVWA_WINDOWS
-#define _DEBUG_NEW_FILENAME_LEN 0
-#else
-#define _DEBUG_NEW_FILENAME_LEN 44
-#endif
-#endif
-
-/**
- * @def _DEBUG_NEW_PROGNAME
- *
- * The program (executable) name to be set at compile time. It is
- * better to assign the full program path to nvwa#new_progname in \e main
- * (at run time) than to use this (compile-time) macro, but this macro
- * serves well as a quick hack. Note also that double quotation marks
- * need to be used around the program name, i.e., one should specify a
- * command-line option like <code>-D_DEBUG_NEW_PROGNAME=\\"a.out\"</code>
- * in \e bash, or <code>-D_DEBUG_NEW_PROGNAME=\\"a.exe\"</code> in the
- * Windows command prompt.
- */
-#ifndef _DEBUG_NEW_PROGNAME
-#define _DEBUG_NEW_PROGNAME _NULLPTR
-#endif
-
-/**
- * @def _DEBUG_NEW_REMEMBER_STACK_TRACE
- *
- * Macro to indicate whether stack traces of allocations should be
- * included in NVWA allocation information and be printed while leaks
- * are reported. Useful to pinpoint leaks caused by strdup and other
- * custom allocation functions. It is also very helpful in filtering
- * out false positives caused by internal STL/C runtime operations. It
- * is off by default because it is quite memory heavy. Set it to \c 1
- * to make all allocations have stack trace attached, or set to \c 2 to
- * make only allocations that lack calling source code information (file
- * and line) have the stack trace attached.
- */
-#ifndef _DEBUG_NEW_REMEMBER_STACK_TRACE
-#define _DEBUG_NEW_REMEMBER_STACK_TRACE 0
-#endif
-
-/**
- * @def _DEBUG_NEW_STD_OPER_NEW
- *
- * Macro to indicate whether the standard-conformant behaviour of
- * <code>operator new</code> is wanted. It is on by default now, but
- * the user may set it to \c 0 to revert to the old behaviour.
- */
-#ifndef _DEBUG_NEW_STD_OPER_NEW
-#define _DEBUG_NEW_STD_OPER_NEW 1
-#endif
-
-/**
- * @def _DEBUG_NEW_TAILCHECK
- *
- * Macro to indicate whether a writing-past-end check will be performed.
- * Define it to a positive integer as the number of padding bytes at the
- * end of a memory block for checking.
- */
-#ifndef _DEBUG_NEW_TAILCHECK
-#define _DEBUG_NEW_TAILCHECK 0
-#endif
-
-/**
- * @def _DEBUG_NEW_TAILCHECK_CHAR
- *
- * Value of the padding bytes at the end of a memory block.
- */
-//#ifndef _DEBUG_NEW_TAILCHECK_CHAR
-//#define _DEBUG_NEW_TAILCHECK_CHAR 0xCC
-//#endif
-
-/**
- * @def _DEBUG_NEW_USE_ADDR2LINE
- *
- * Whether to use \e addr2line to convert a caller address to file/line
- * information. Defining it to a non-zero value will enable the
- * conversion (automatically done if GCC is detected). Defining it to
- * zero will disable the conversion.
- */
-#ifndef _DEBUG_NEW_USE_ADDR2LINE
-#ifdef __GNUC__
-#define _DEBUG_NEW_USE_ADDR2LINE 1
-#else
-#define _DEBUG_NEW_USE_ADDR2LINE 0
-#endif
-#endif
-
-#ifdef _MSC_VER
-#pragma warning(disable: 4074) // #pragma init_seg(compiler) used
-#pragma warning(disable: 4290) // C++ exception specification ignored
-#if _MSC_VER >= 1400 // Visual Studio 2005 or later
-#pragma warning(disable: 4996) // Use the `unsafe' strncpy
-#endif
-#pragma init_seg(compiler)
-#endif
-
-/**
- * Gets the aligned value of memory block size.
- */
-#define ALIGN(s) \
- (((s) + _DEBUG_NEW_ALIGNMENT - 1) & ~(_DEBUG_NEW_ALIGNMENT - 1))
-
-NVWA_NAMESPACE_BEGIN
-
-/**
- * The platform memory alignment. The current value works well in
- * platforms I have tested: Windows XP, Windows 7 x64, and Mac OS X
- * Leopard. It may be smaller than the real alignment, but must be
- * bigger than \c sizeof(size_t) for it work. nvwa#debug_new_recorder
- * uses it to detect misaligned pointer returned by `<code>new
- * NonPODType[size]</code>'.
- */
-const size_t PLATFORM_MEM_ALIGNMENT = sizeof(size_t) * 2;
-
-/**
- * Structure to store the position information where \c new occurs.
- */
-struct new_ptr_list_t
-{
- new_ptr_list_t* next; ///< Pointer to the next memory block
- new_ptr_list_t* prev; ///< Pointer to the previous memory block
- size_t size; ///< Size of the memory block
- union
- {
-#if _DEBUG_NEW_FILENAME_LEN == 0
- const char* file; ///< Pointer to the file name of the caller
-#else
- char file[_DEBUG_NEW_FILENAME_LEN]; ///< File name of the caller
-#endif
- void* addr; ///< Address of the caller to \e new
- };
- unsigned line :31; ///< Line number of the caller; or \c 0
- unsigned is_array:1; ///< Non-zero iff <em>new[]</em> is used
-#if _DEBUG_NEW_REMEMBER_STACK_TRACE
- void** stacktrace; ///< Pointer to stack trace information
-#endif
- unsigned magic; ///< Magic number for error detection
-};
-
-/**
- * Definition of the constant magic number used for error detection.
- */
-static const unsigned DEBUG_NEW_MAGIC = 0x4442474E;
-
-/**
- * The extra memory allocated by <code>operator new</code>.
- */
-static const int ALIGNED_LIST_ITEM_SIZE = ALIGN(sizeof(new_ptr_list_t));
-
-/**
- * List of all new'd pointers.
- */
-static new_ptr_list_t new_ptr_list = {
- &new_ptr_list,
- &new_ptr_list,
- 0,
- {
-#if _DEBUG_NEW_FILENAME_LEN == 0
- _NULLPTR
-#else
- ""
-#endif
- },
- 0,
- 0,
-#if _DEBUG_NEW_REMEMBER_STACK_TRACE
- _NULLPTR,
-#endif
- DEBUG_NEW_MAGIC
-};
-
-/**
- * The mutex guard to protect simultaneous access to the pointer list.
- */
-static fast_mutex new_ptr_lock;
-
-/**
- * The mutex guard to protect simultaneous output to #new_output_fp.
- */
-static fast_mutex new_output_lock;
-
-/**
- * Total memory allocated in bytes.
- */
-static size_t total_mem_alloc = 0;
-
-/**
- * Flag to control whether nvwa#check_leaks will be automatically called
- * on program exit.
- */
-bool new_autocheck_flag = true;
-
-/**
- * Flag to control whether verbose messages are output.
- */
-bool new_verbose_flag = false;
-
-/**
- * Pointer to the output stream. The default output is \e stderr, and
- * one may change it to a user stream if needed (say, #new_verbose_flag
- * is \c true and there are a lot of (de)allocations).
- */
-FILE* new_output_fp = stderr;
-
-/**
- * Pointer to the program name. Its initial value is the macro
- * #_DEBUG_NEW_PROGNAME. You should try to assign the program path to
- * it early in your application. Assigning <code>argv[0]</code> to it
- * in \e main is one way. If you use \e bash or \e ksh (or similar),
- * the following statement is probably what you want:
- * `<code>new_progname = getenv("_");</code>'.
- */
-const char* new_progname = _DEBUG_NEW_PROGNAME;
-
-/**
- * Pointer to the callback used to print the stack backtrace in case of
- * a memory problem. A null value causes the default stack trace
- * printing routine to be used.
- */
-stacktrace_print_callback_t stacktrace_print_callback = _NULLPTR;
-
-/**
- * Pointer to the callback used to filter out false positives from leak
- * reports. A null value means the lack of filtering.
- */
-leak_whitelist_callback_t leak_whitelist_callback = _NULLPTR;
-
-#if _DEBUG_NEW_USE_ADDR2LINE
-/**
- * Tries printing the position information from an instruction address.
- * This is the version that uses \e addr2line.
- *
- * @param addr the instruction address to convert and print
- * @return \c true if the address is converted successfully (and
- * the result is printed); \c false if no useful
- * information is got (and nothing is printed)
- */
-static bool print_position_from_addr(const void* addr)
-{
- static const void* last_addr = _NULLPTR;
- static char last_info[256] = "";
- if (addr == last_addr)
- {
- if (last_info[0] == '\0')
- return false;
- fprintf(new_output_fp, "%s", last_info);
- return true;
- }
- if (new_progname)
- {
-#if NVWA_APPLE
- const char addr2line_cmd[] = "atos -o ";
-#else
- const char addr2line_cmd[] = "addr2line -e ";
-#endif
-
-#if NVWA_WINDOWS
- const int exeext_len = 4;
-#else
- const int exeext_len = 0;
-#endif
-
-#if NVWA_UNIX && !NVWA_CYGWIN
- const char ignore_err[] = " 2>/dev/null";
-#elif NVWA_CYGWIN || \
- (NVWA_WIN32 && defined(WINVER) && WINVER >= 0x0500)
- const char ignore_err[] = " 2>nul";
-#else
- const char ignore_err[] = "";
-#endif
- char* cmd = (char*)alloca(strlen(new_progname)
- + exeext_len
- + sizeof addr2line_cmd - 1
- + sizeof ignore_err - 1
- + sizeof(void*) * 2
- + 4 /* SP + "0x" + null */);
- strcpy(cmd, addr2line_cmd);
- strcpy(cmd + sizeof addr2line_cmd - 1, new_progname);
- size_t len = strlen(cmd);
-#if NVWA_WINDOWS
- if (len <= 4
- || (strcmp(cmd + len - 4, ".exe") != 0 &&
- strcmp(cmd + len - 4, ".EXE") != 0))
- {
- strcpy(cmd + len, ".exe");
- len += 4;
- }
-#endif
- sprintf(cmd + len, " %p%s", addr, ignore_err);
- FILE* fp = popen(cmd, "r");
- if (fp)
- {
- char buffer[sizeof last_info] = "";
- len = 0;
- if (fgets(buffer, sizeof buffer, fp))
- {
- len = strlen(buffer);
- if (buffer[len - 1] == '\n')
- buffer[--len] = '\0';
- }
- int res = pclose(fp);
- // Display the file/line information only if the command
- // is executed successfully and the output points to a
- // valid position, but the result will be cached if only
- // the command is executed successfully.
- if (res == 0 && len > 0)
- {
- last_addr = addr;
- if (buffer[len - 1] == '0' && buffer[len - 2] == ':')
- last_info[0] = '\0';
- else
- {
- fprintf(new_output_fp, "%s", buffer);
- strcpy(last_info, buffer);
- return true;
- }
- }
- }
- }
- return false;
-}
-#else
-/**
- * Tries printing the position information from an instruction address.
- * This is the stub version that does nothing at all.
- *
- * @return \c false always
- */
-static bool print_position_from_addr(const void*)
-{
- return false;
-}
-#endif // _DEBUG_NEW_USE_ADDR2LINE
-
-/**
- * Prints the position information of a memory operation point. When \c
- * _DEBUG_NEW_USE_ADDR2LINE is defined to a non-zero value, this
- * function will try to convert a given caller address to file/line
- * information with \e addr2line.
- *
- * @param ptr source file name if \e line is non-zero; caller address
- * otherwise
- * @param line source line number if non-zero; indication that \e ptr
- * is the caller address otherwise
- */
-static void print_position(const void* ptr, int line)
-{
- if (line != 0) // Is file/line information present?
- {
- fprintf(new_output_fp, "%s:%d", (const char*)ptr, line);
- }
- else if (ptr != _NULLPTR) // Is caller address present?
- {
- if (!print_position_from_addr(ptr)) // Fail to get source position?
- fprintf(new_output_fp, "%p", ptr);
- }
- else // No information is present
- {
- fprintf(new_output_fp, "<Unknown>");
- }
-}
-
-#if _DEBUG_NEW_REMEMBER_STACK_TRACE
-/**
- * Prints the stack backtrace.
- *
- * When nvwa#stacktrace_print_callback is not null, it is used for
- * printing the stacktrace items. Default implementation of call stack
- * printing is very spartan&mdash;only stack frame pointers are
- * printed&mdash;but even that output is still useful. Just do address
- * lookup in LLDB etc.
- *
- * @param stacktrace pointer to the stack trace array
- */
-static void print_stacktrace(void** stacktrace)
-{
- if (stacktrace_print_callback == _NULLPTR)
- {
- fprintf(new_output_fp, "Stack backtrace:\n");
- for (size_t i = 0; stacktrace[i] != _NULLPTR; ++i)
- fprintf(new_output_fp, "%p\n", stacktrace[i]);
- }
- else
- {
- stacktrace_print_callback(new_output_fp, stacktrace);
- }
-}
-#endif
-
-/**
- * Checks whether a leak should be ignored. Its runtime performance
- * depends on the callback nvwa#leak_whitelist_callback.
- *
- * @param ptr pointer to a new_ptr_list_t struct
- * @return \c true if the leak should be whitelisted; \c false
- * otherwise
- */
-static bool is_leak_whitelisted(new_ptr_list_t* ptr)
-{
- if (leak_whitelist_callback == _NULLPTR)
- return false;
-
- char const* file = ptr->line != 0 ? ptr->file : _NULLPTR;
- int line = ptr->line;
- void* addr = ptr->line == 0 ? ptr->addr : _NULLPTR;
-#if _DEBUG_NEW_REMEMBER_STACK_TRACE
- void** stacktrace = ptr->stacktrace;
-#else
- void** stacktrace = _NULLPTR;
-#endif
-
- return leak_whitelist_callback(file, line, addr, stacktrace);
-}
-
-#if _DEBUG_NEW_TAILCHECK
-/**
- * Checks whether the padding bytes at the end of a memory block is
- * tampered with.
- *
- * @param ptr pointer to a new_ptr_list_t struct
- * @return \c true if the padding bytes are untouched; \c false
- * otherwise
- */
-static bool check_tail(new_ptr_list_t* ptr)
-{
- const unsigned char* const tail_ptr = (unsigned char*)ptr +
- ALIGNED_LIST_ITEM_SIZE + ptr->size;
- for (int i = 0; i < _DEBUG_NEW_TAILCHECK; ++i)
- if (tail_ptr[i] != _DEBUG_NEW_TAILCHECK_CHAR)
- return false;
- return true;
-}
-#endif
-
-/**
- * Allocates memory and initializes control data.
- *
- * @param size size of the required memory block
- * @param file null-terminated string of the file name
- * @param line line number
- * @param is_array boolean value whether this is an array operation
- * @return pointer to the user-requested memory area; null if
- * memory allocation is not successful
- */
-static void* alloc_mem(size_t size, const char* file, int line, bool is_array)
-{
- assert(line >= 0);
-#if _DEBUG_NEW_TYPE == 1
- STATIC_ASSERT(_DEBUG_NEW_ALIGNMENT >= PLATFORM_MEM_ALIGNMENT,
- Alignment_too_small);
-#endif
- STATIC_ASSERT((_DEBUG_NEW_ALIGNMENT & (_DEBUG_NEW_ALIGNMENT - 1)) == 0,
- Alignment_must_be_power_of_two);
- STATIC_ASSERT(_DEBUG_NEW_TAILCHECK >= 0, Invalid_tail_check_length);
- size_t s = size + ALIGNED_LIST_ITEM_SIZE + _DEBUG_NEW_TAILCHECK;
- new_ptr_list_t* ptr = (new_ptr_list_t*)malloc(s);
- if (ptr == _NULLPTR)
- {
-#if _DEBUG_NEW_STD_OPER_NEW
- return _NULLPTR;
-#else
- fast_mutex_autolock lock(new_output_lock);
- fprintf(new_output_fp,
- "Out of memory when allocating %lu bytes\n",
- (unsigned long)size);
- fflush(new_output_fp);
- _DEBUG_NEW_ERROR_ACTION;
-#endif
- }
- void* usr_ptr = (char*)ptr + ALIGNED_LIST_ITEM_SIZE;
-#if _DEBUG_NEW_FILENAME_LEN == 0
- ptr->file = file;
-#else
- if (line)
- strncpy(ptr->file, file, _DEBUG_NEW_FILENAME_LEN - 1)
- [_DEBUG_NEW_FILENAME_LEN - 1] = '\0';
- else
- ptr->addr = (void*)file;
-#endif
- ptr->line = line;
-#if _DEBUG_NEW_REMEMBER_STACK_TRACE
- ptr->stacktrace = _NULLPTR;
-
-#if _DEBUG_NEW_REMEMBER_STACK_TRACE == 2
- if (line == 0)
-#endif
- {
- void* buffer [255];
- size_t buffer_length = sizeof(buffer) / sizeof(*buffer);
-
-#if NVWA_UNIX
- int stacktrace_length = backtrace(buffer, int(buffer_length));
-#endif
-
-#if NVWA_WINDOWS
- USHORT stacktrace_length = CaptureStackBackTrace(
- 0, DWORD(buffer_length), buffer, _NULLPTR);
-#endif
-
- size_t stacktrace_size = stacktrace_length * sizeof(void*);
- ptr->stacktrace = (void**)malloc(stacktrace_size + sizeof(void*));
-
- if (ptr->stacktrace != _NULLPTR)
- {
- memcpy(ptr->stacktrace, buffer, stacktrace_size);
- ptr->stacktrace[stacktrace_length] = _NULLPTR;
- }
- }
-#endif
- ptr->is_array = is_array;
- ptr->size = size;
- ptr->magic = DEBUG_NEW_MAGIC;
- {
- fast_mutex_autolock lock(new_ptr_lock);
- ptr->prev = new_ptr_list.prev;
- ptr->next = &new_ptr_list;
- new_ptr_list.prev->next = ptr;
- new_ptr_list.prev = ptr;
- }
-#if _DEBUG_NEW_TAILCHECK
- memset((char*)usr_ptr + size, _DEBUG_NEW_TAILCHECK_CHAR,
- _DEBUG_NEW_TAILCHECK);
-#endif
- if (new_verbose_flag)
- {
- fast_mutex_autolock lock(new_output_lock);
- fprintf(new_output_fp,
- "new%s: allocated %p (size %lu, ",
- is_array ? "[]" : "",
- usr_ptr, (unsigned long)size);
- if (line != 0)
- print_position(ptr->file, ptr->line);
- else
- print_position(ptr->addr, ptr->line);
- fprintf(new_output_fp, ")\n");
- }
- total_mem_alloc += size;
- return usr_ptr;
-}
-
-/**
- * Frees memory and adjusts pointers.
- *
- * @param usr_ptr pointer to the previously allocated memory
- * @param addr pointer to the caller
- * @param is_array flag indicating whether it is invoked by a
- * <code>delete[]</code> call
- */
-static void free_pointer(void* usr_ptr, void* addr, bool is_array)
-{
- if (usr_ptr == _NULLPTR)
- return;
- new_ptr_list_t* ptr =
- (new_ptr_list_t*)((char*)usr_ptr - ALIGNED_LIST_ITEM_SIZE);
- if (ptr->magic != DEBUG_NEW_MAGIC)
- {
- {
- fast_mutex_autolock lock(new_output_lock);
- fprintf(new_output_fp, "delete%s: invalid pointer %p (",
- is_array ? "[]" : "", usr_ptr);
- print_position(addr, 0);
- fprintf(new_output_fp, ")\n");
- }
- check_mem_corruption();
- fflush(new_output_fp);
- _DEBUG_NEW_ERROR_ACTION;
- }
- if (is_array != ptr->is_array)
- {
- const char* msg;
- if (is_array)
- msg = "delete[] after new";
- else
- msg = "delete after new[]";
- fast_mutex_autolock lock(new_output_lock);
- fprintf(new_output_fp,
- "%s: pointer %p (size %lu)\n\tat ",
- msg,
- (char*)ptr + ALIGNED_LIST_ITEM_SIZE,
- (unsigned long)ptr->size);
- print_position(addr, 0);
- fprintf(new_output_fp, "\n\toriginally allocated at ");
- if (ptr->line != 0)
- print_position(ptr->file, ptr->line);
- else
- print_position(ptr->addr, ptr->line);
- fprintf(new_output_fp, "\n");
- fflush(new_output_fp);
- _DEBUG_NEW_ERROR_ACTION;
- }
-#if _DEBUG_NEW_TAILCHECK
- if (!check_tail(ptr))
- {
- check_mem_corruption();
- fflush(new_output_fp);
- _DEBUG_NEW_ERROR_ACTION;
- }
-#endif
- {
- fast_mutex_autolock lock(new_ptr_lock);
- total_mem_alloc -= ptr->size;
- ptr->magic = 0;
- ptr->prev->next = ptr->next;
- ptr->next->prev = ptr->prev;
- }
- if (new_verbose_flag)
- {
- fast_mutex_autolock lock(new_output_lock);
- fprintf(new_output_fp,
- "delete%s: freed %p (size %lu, %lu bytes still allocated)\n",
- is_array ? "[]" : "",
- (char*)ptr + ALIGNED_LIST_ITEM_SIZE,
- (unsigned long)ptr->size, (unsigned long)total_mem_alloc);
- }
-#if _DEBUG_NEW_REMEMBER_STACK_TRACE
- free(ptr->stacktrace);
-#endif
- free(ptr);
- return;
-}
-
-/**
- * Checks for memory leaks.
- *
- * @return zero if no leakage is found; the number of leaks otherwise
- */
-int check_leaks()
-{
- int leak_cnt = 0;
- int whitelisted_leak_cnt = 0;
- fast_mutex_autolock lock_ptr(new_ptr_lock);
- fast_mutex_autolock lock_output(new_output_lock);
- new_ptr_list_t* ptr = new_ptr_list.next;
-
- while (ptr != &new_ptr_list)
- {
- const char* const usr_ptr = (char*)ptr + ALIGNED_LIST_ITEM_SIZE;
- if (ptr->magic != DEBUG_NEW_MAGIC)
- {
- fprintf(new_output_fp,
- "warning: heap data corrupt near %p\n",
- usr_ptr);
- }
-#if _DEBUG_NEW_TAILCHECK
- if (!check_tail(ptr))
- {
- fprintf(new_output_fp,
- "warning: overwritten past end of object at %p\n",
- usr_ptr);
- }
-#endif
-
- if (is_leak_whitelisted(ptr))
- {
- ++whitelisted_leak_cnt;
- }
- else
- {
- fprintf(new_output_fp,
- "Leaked object at %p (size %lu, ",
- usr_ptr,
- (unsigned long)ptr->size);
-
- if (ptr->line != 0)
- print_position(ptr->file, ptr->line);
- else
- print_position(ptr->addr, ptr->line);
-
- fprintf(new_output_fp, ")\n");
-
-#if _DEBUG_NEW_REMEMBER_STACK_TRACE
- if (ptr->stacktrace != _NULLPTR)
- print_stacktrace(ptr->stacktrace);
-#endif
- }
-
- ptr = ptr->next;
- ++leak_cnt;
- }
- if (new_verbose_flag || leak_cnt)
- {
- if (whitelisted_leak_cnt > 0)
- {
- fprintf(new_output_fp, "*** %d leaks found (%d whitelisted)\n",
- leak_cnt, whitelisted_leak_cnt);
- }
- else
- {
- fprintf(new_output_fp, "*** %d leaks found\n", leak_cnt);
- }
- }
-
- return leak_cnt;
-}
-
-/**
- * Checks for heap corruption.
- *
- * @return zero if no problem is found; the number of found memory
- * corruptions otherwise
- */
-int check_mem_corruption()
-{
- int corrupt_cnt = 0;
- fast_mutex_autolock lock_ptr(new_ptr_lock);
- fast_mutex_autolock lock_output(new_output_lock);
- fprintf(new_output_fp, "*** Checking for memory corruption: START\n");
- for (new_ptr_list_t* ptr = new_ptr_list.next;
- ptr != &new_ptr_list;
- ptr = ptr->next)
- {
- const char* const usr_ptr = (char*)ptr + ALIGNED_LIST_ITEM_SIZE;
- if (ptr->magic == DEBUG_NEW_MAGIC
-#if _DEBUG_NEW_TAILCHECK
- && check_tail(ptr)
-#endif
- )
- continue;
-#if _DEBUG_NEW_TAILCHECK
- if (ptr->magic != DEBUG_NEW_MAGIC)
- {
-#endif
- fprintf(new_output_fp,
- "Heap data corrupt near %p (size %lu, ",
- usr_ptr,
- (unsigned long)ptr->size);
-#if _DEBUG_NEW_TAILCHECK
- }
- else
- {
- fprintf(new_output_fp,
- "Overwritten past end of object at %p (size %lu, ",
- usr_ptr,
- (unsigned long)ptr->size);
- }
-#endif
- if (ptr->line != 0)
- print_position(ptr->file, ptr->line);
- else
- print_position(ptr->addr, ptr->line);
- fprintf(new_output_fp, ")\n");
-
-#if _DEBUG_NEW_REMEMBER_STACK_TRACE
- if (ptr->stacktrace != _NULLPTR)
- print_stacktrace(ptr->stacktrace);
-#endif
-
- ++corrupt_cnt;
- }
- fprintf(new_output_fp, "*** Checking for memory corruption: %d FOUND\n",
- corrupt_cnt);
- return corrupt_cnt;
-}
-
-/**
- * Processes the allocated memory and inserts file/line informatin.
- * It will only be done when it can ensure the memory is allocated by
- * one of our operator new variants.
- *
- * @param usr_ptr pointer returned by a new-expression
- */
-void debug_new_recorder::_M_process(void* usr_ptr)
-{
- if (usr_ptr == _NULLPTR)
- return;
-
- // In an expression `new NonPODType[size]', the pointer returned is
- // not the pointer returned by operator new[], but offset by size_t
- // to leave room for the size. It needs to be compensated here.
- size_t offset = (char*)usr_ptr - (char*)_NULLPTR;
- if (offset % PLATFORM_MEM_ALIGNMENT != 0) {
- offset -= sizeof(size_t);
- if (offset % PLATFORM_MEM_ALIGNMENT != 0) {
- fast_mutex_autolock lock(new_output_lock);
- fprintf(new_output_fp,
- "warning: memory unaligned; skipping processing (%s:%d)\n",
- _M_file, _M_line);
- return;
- }
- usr_ptr = (char*)usr_ptr - sizeof(size_t);
- }
-
- new_ptr_list_t* ptr =
- (new_ptr_list_t*)((char*)usr_ptr - ALIGNED_LIST_ITEM_SIZE);
- if (ptr->magic != DEBUG_NEW_MAGIC || ptr->line != 0)
- {
- fast_mutex_autolock lock(new_output_lock);
- fprintf(new_output_fp,
- "warning: debug_new used with placement new (%s:%d)\n",
- _M_file, _M_line);
- return;
- }
- if (new_verbose_flag) {
- fast_mutex_autolock lock(new_output_lock);
- fprintf(new_output_fp,
- "info: pointer %p allocated from %s:%d\n",
- usr_ptr, _M_file, _M_line);
- }
-#if _DEBUG_NEW_FILENAME_LEN == 0
- ptr->file = _M_file;
-#else
- strncpy(ptr->file, _M_file, _DEBUG_NEW_FILENAME_LEN - 1)
- [_DEBUG_NEW_FILENAME_LEN - 1] = '\0';
-#endif
- ptr->line = _M_line;
-#if _DEBUG_NEW_REMEMBER_STACK_TRACE == 2
- free(ptr->stacktrace);
- ptr->stacktrace = _NULLPTR;
-#endif
-}
-
-/**
- * Count of source files that use debug_new.
- */
-int debug_new_counter::_S_count = 0;
-
-/**
- * Constructor to increment the count.
- */
-debug_new_counter::debug_new_counter()
-{
- ++_S_count;
-}
-
-/**
- * Destructor to decrement the count. When the count is zero,
- * nvwa#check_leaks will be called.
- */
-debug_new_counter::~debug_new_counter()
-{
- if (--_S_count == 0 && new_autocheck_flag)
- if (check_leaks())
- {
- new_verbose_flag = true;
-#if defined(__GNUC__) && __GNUC__ == 3
- if (!getenv("GLIBCPP_FORCE_NEW") && !getenv("GLIBCXX_FORCE_NEW"))
- fprintf(new_output_fp,
-"*** WARNING: GCC 3 is detected, please make sure the environment\n"
-" variable GLIBCPP_FORCE_NEW (GCC 3.2 and 3.3) or GLIBCXX_FORCE_NEW\n"
-" (GCC 3.4) is defined. Check the README file for details.\n");
-#endif
- }
-}
-
-NVWA_NAMESPACE_END
-
-#if NVWA_USE_NAMESPACE
-using namespace nvwa;
-#endif // NVWA_USE_NAMESPACE
-
-/**
- * Allocates memory with file/line information.
- *
- * @param size size of the required memory block
- * @param file null-terminated string of the file name
- * @param line line number
- * @return pointer to the memory allocated; or null if memory is
- * insufficient (#_DEBUG_NEW_STD_OPER_NEW is 0)
- * @throw bad_alloc memory is insufficient (#_DEBUG_NEW_STD_OPER_NEW is 1)
- */
-void* operator new(size_t size, const char* file, int line)
-{
- void* ptr = alloc_mem(size, file, line, false);
-#if _DEBUG_NEW_STD_OPER_NEW
- if (ptr)
- return ptr;
- else
- throw std::bad_alloc();
-#else
- return ptr;
-#endif
-}
-
-/**
- * Allocates array memory with file/line information.
- *
- * @param size size of the required memory block
- * @param file null-terminated string of the file name
- * @param line line number
- * @return pointer to the memory allocated; or null if memory is
- * insufficient (#_DEBUG_NEW_STD_OPER_NEW is 0)
- * @throw bad_alloc memory is insufficient (#_DEBUG_NEW_STD_OPER_NEW is 1)
- */
-void* operator new[](size_t size, const char* file, int line)
-{
- void* ptr = alloc_mem(size, file, line, true);
-#if _DEBUG_NEW_STD_OPER_NEW
- if (ptr)
- return ptr;
- else
- throw std::bad_alloc();
-#else
- return ptr;
-#endif
-}
-
-/**
- * Allocates memory without file/line information.
- *
- * @param size size of the required memory block
- * @return pointer to the memory allocated; or null if memory is
- * insufficient (#_DEBUG_NEW_STD_OPER_NEW is 0)
- * @throw bad_alloc memory is insufficient (#_DEBUG_NEW_STD_OPER_NEW is 1)
- */
-void* operator new(size_t size)
-{
- return operator new(size, (char*)_DEBUG_NEW_CALLER_ADDRESS, 0);
-}
-
-/**
- * Allocates array memory without file/line information.
- *
- * @param size size of the required memory block
- * @return pointer to the memory allocated; or null if memory is
- * insufficient (#_DEBUG_NEW_STD_OPER_NEW is 0)
- * @throw bad_alloc memory is insufficient (#_DEBUG_NEW_STD_OPER_NEW is 1)
- */
-void* operator new[](size_t size)
-{
- return operator new[](size, (char*)_DEBUG_NEW_CALLER_ADDRESS, 0);
-}
-
-/**
- * Allocates memory with no-throw guarantee.
- *
- * @param size size of the required memory block
- * @return pointer to the memory allocated; or null if memory is
- * insufficient
- */
-void* operator new(size_t size, const std::nothrow_t&) _NOEXCEPT
-{
- return alloc_mem(size, (char*)_DEBUG_NEW_CALLER_ADDRESS, 0, false);
-}
-
-/**
- * Allocates array memory with no-throw guarantee.
- *
- * @param size size of the required memory block
- * @return pointer to the memory allocated; or null if memory is
- * insufficient
- */
-void* operator new[](size_t size, const std::nothrow_t&) _NOEXCEPT
-{
- return alloc_mem(size, (char*)_DEBUG_NEW_CALLER_ADDRESS, 0, true);
-}
-
-/**
- * Deallocates memory.
- *
- * @param ptr pointer to the previously allocated memory
- */
-void operator delete(void* ptr) _NOEXCEPT
-{
- free_pointer(ptr, _DEBUG_NEW_CALLER_ADDRESS, false);
-}
-
-/**
- * Deallocates array memory.
- *
- * @param ptr pointer to the previously allocated memory
- */
-void operator delete[](void* ptr) _NOEXCEPT
-{
- free_pointer(ptr, _DEBUG_NEW_CALLER_ADDRESS, true);
-}
-
-#if __cplusplus >= 201402L
-// GCC under C++14 wants these definitions
-
-void operator delete(void* ptr, size_t) _NOEXCEPT
-{
- free_pointer(ptr, _DEBUG_NEW_CALLER_ADDRESS, false);
-}
-
-void operator delete[](void* ptr, size_t) _NOEXCEPT
-{
- free_pointer(ptr, _DEBUG_NEW_CALLER_ADDRESS, true);
-}
-#endif
-
-/**
- * Placement deallocation function. For details, please check Section
- * 5.3.4 of the C++ 1998 or 2011 Standard.
- *
- * @param ptr pointer to the previously allocated memory
- * @param file null-terminated string of the file name
- * @param line line number
- *
- * @see http://www.csci.csusb.edu/dick/c++std/cd2/expr.html#expr.new
- * @see http://wyw.dcweb.cn/leakage.htm
- */
-void operator delete(void* ptr, const char* file, int line) _NOEXCEPT
-{
- if (new_verbose_flag)
- {
- fast_mutex_autolock lock(new_output_lock);
- fprintf(new_output_fp,
- "info: exception thrown on initializing object at %p (",
- ptr);
- print_position(file, line);
- fprintf(new_output_fp, ")\n");
- }
- operator delete(ptr);
-}
-
-/**
- * Placement deallocation function. For details, please check Section
- * 5.3.4 of the C++ 1998 or 2011 Standard.
- *
- * @param ptr pointer to the previously allocated memory
- * @param file null-terminated string of the file name
- * @param line line number
- */
-void operator delete[](void* ptr, const char* file, int line) _NOEXCEPT
-{
- if (new_verbose_flag)
- {
- fast_mutex_autolock lock(new_output_lock);
- fprintf(new_output_fp,
- "info: exception thrown on initializing objects at %p (",
- ptr);
- print_position(file, line);
- fprintf(new_output_fp, ")\n");
- }
- operator delete[](ptr);
-}
-
-/**
- * Placement deallocation function. For details, please check Section
- * 5.3.4 of the C++ 1998 or 2011 Standard.
- *
- * @param ptr pointer to the previously allocated memory
- */
-void operator delete(void* ptr, const std::nothrow_t&) _NOEXCEPT
-{
- operator delete(ptr, (char*)_DEBUG_NEW_CALLER_ADDRESS, 0);
-}
-
-/**
- * Placement deallocation function. For details, please check Section
- * 5.3.4 of the C++ 1998 or 2011 Standard.
- *
- * @param ptr pointer to the previously allocated memory
- */
-void operator delete[](void* ptr, const std::nothrow_t&) _NOEXCEPT
-{
- operator delete[](ptr, (char*)_DEBUG_NEW_CALLER_ADDRESS, 0);
-}
-
-// This is to make Doxygen happy
-#undef _DEBUG_NEW_REMEMBER_STACK_TRACE
-//#define _DEBUG_NEW_REMEMBER_STACK_TRACE 0
-
-PRAGMA45(GCC diagnostic pop)
-PRAGMACLANG6GCC(GCC diagnostic pop)
diff --git a/src/debug/nvwa/debug_new.h b/src/debug/nvwa/debug_new.h
deleted file mode 100644
index 50b168c2e..000000000
--- a/src/debug/nvwa/debug_new.h
+++ /dev/null
@@ -1,207 +0,0 @@
-// -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
-// vim:tabstop=4:shiftwidth=4:expandtab:
-
-/*
- * Copyright (C) 2004-2015 Wu Yongwei <adah at users dot sourceforge dot net>
- *
- * This software is provided 'as-is', without any express or implied
- * warranty. In no event will the authors be held liable for any
- * damages arising from the use of this software.
- *
- * Permission is granted to anyone to use this software for any purpose,
- * including commercial applications, and to alter it and redistribute
- * it freely, subject to the following restrictions:
- *
- * 1. The origin of this software must not be misrepresented; you must
- * not claim that you wrote the original software. If you use this
- * software in a product, an acknowledgement in the product
- * documentation would be appreciated but is not required.
- * 2. Altered source versions must be plainly marked as such, and must
- * not be misrepresented as being the original software.
- * 3. This notice may not be removed or altered from any source
- * distribution.
- *
- * This file is part of Stones of Nvwa:
- * http://sourceforge.net/projects/nvwa
- *
- */
-
-/**
- * @file debug_new.h
- *
- * Header file for checking leaks caused by unmatched new/delete.
- *
- * @date 2015-10-25
- */
-
-#ifndef NVWA_DEBUG_NEW_H
-#define NVWA_DEBUG_NEW_H
-
-#include <new> // size_t/std::bad_alloc
-#include <stdio.h> // FILE
-#include "debug/nvwa/_nvwa.h" // NVWA_NAMESPACE_*
-#include "debug/nvwa/c++11.h" // _NOEXCEPT
-
-/* Special allocation/deallocation functions in the global scope */
-void* operator new(size_t size, const char* file, int line);
-void* operator new[](size_t size, const char* file, int line);
-void operator delete(void* ptr, const char* file, int line) _NOEXCEPT;
-void operator delete[](void* ptr, const char* file, int line) _NOEXCEPT;
-
-NVWA_NAMESPACE_BEGIN
-
-/**
- * @def _DEBUG_NEW_REDEFINE_NEW
- *
- * Macro to indicate whether redefinition of \c new is wanted. If one
- * wants to define one's own <code>operator new</code>, or to call
- * <code>operator new</code> directly, it should be defined to \c 0 to
- * alter the default behaviour. Unless, of course, one is willing to
- * take the trouble to write something like:
- * @code
- * # ifdef new
- * # define _NEW_REDEFINED
- * # undef new
- * # endif
- *
- * // Code that uses new is here
- *
- * # ifdef _NEW_REDEFINED
- * # ifdef DEBUG_NEW
- * # define new DEBUG_NEW
- * # endif
- * # undef _NEW_REDEFINED
- * # endif
- * @endcode
- */
-#ifndef _DEBUG_NEW_REDEFINE_NEW
-#define _DEBUG_NEW_REDEFINE_NEW 1
-#endif
-
-/**
- * @def _DEBUG_NEW_TYPE
- *
- * Macro to indicate which variant of #DEBUG_NEW is wanted. The
- * default value \c 1 allows the use of placement new (like
- * <code>%new(std::nothrow)</code>), but the verbose output (when
- * nvwa#new_verbose_flag is \c true) looks worse than some older
- * versions (no file/line information for allocations). Define it
- * to \c 2 to revert to the old behaviour that records file and line
- * information directly on the call to <code>operator new</code>.
- */
-#ifndef _DEBUG_NEW_TYPE
-#define _DEBUG_NEW_TYPE 1
-#endif
-
-/**
- * Callback type for stack trace printing.
- *
- * @param fp pointer to the output stream
- * @param stacktrace pointer to the stack trace array (null-terminated)
- */
-typedef void (*stacktrace_print_callback_t)(FILE* fp, void** stacktrace);
-
-/**
- * Callback type for the leak whitelist function. \a file, \a address,
- * and \a backtrace might be null depending on library configuration,
- * platform, and amount of runtime information available. \a line can
- * be 0 when line number info is not available at runtime.
- *
- * @param file null-terminated string of the file name
- * @param line line number
- * @param addr address of code where leakage happens
- * @param stacktrace pointer to the stack trace array (null-terminated)
- * @return \c true if the leak should be whitelisted;
- * \c false otherwise
- */
-typedef bool (*leak_whitelist_callback_t)(char const* file, int line,
- void* addr, void** stacktrace);
-
-/* Prototypes */
-int check_leaks();
-int check_mem_corruption();
-
-/* Control variables */
-extern bool new_autocheck_flag; // default to true: call check_leaks() on exit
-extern bool new_verbose_flag; // default to false: no verbose information
-extern FILE* new_output_fp; // default to stderr: output to console
-extern const char* new_progname;// default to null; should be assigned argv[0]
-extern stacktrace_print_callback_t stacktrace_print_callback;// default to null
-extern leak_whitelist_callback_t leak_whitelist_callback; // default to null
-
-/**
- * @def DEBUG_NEW
- *
- * Macro to catch file/line information on allocation. If
- * #_DEBUG_NEW_REDEFINE_NEW is \c 0, one can use this macro directly;
- * otherwise \c new will be defined to it, and one must use \c new
- * instead.
- */
-# if _DEBUG_NEW_TYPE == 1
-# define DEBUG_NEW NVWA::debug_new_recorder(__FILE__, __LINE__) ->* new
-# else
-# define DEBUG_NEW new(__FILE__, __LINE__)
-# endif
-
-# if _DEBUG_NEW_REDEFINE_NEW
-# define new DEBUG_NEW
-# endif
-# ifdef _DEBUG_NEW_EMULATE_MALLOC
-# include <stdlib.h>
-# ifdef new
-# define malloc(s) ((void*)(new char[s]))
-# else
-# define malloc(s) ((void*)(DEBUG_NEW char[s]))
-# endif
-# define free(p) delete[] (char*)(p)
-# endif
-
-/**
- * Recorder class to remember the call context.
- *
- * The idea comes from <a href="http://groups.google.com/group/comp.lang.c++.moderated/browse_thread/thread/7089382e3bc1c489/85f9107a1dc79ee9?#85f9107a1dc79ee9">Greg Herlihy's post</a> in comp.lang.c++.moderated.
- */
-class debug_new_recorder
-{
- const char* _M_file;
- const int _M_line;
- void _M_process(void* ptr);
-public:
- /**
- * Constructor to remember the call context. The information will
- * be used in debug_new_recorder::operator->*.
- */
- debug_new_recorder(const char* file, int line)
- : _M_file(file), _M_line(line) {}
- /**
- * Operator to write the context information to memory.
- * <code>operator->*</code> is chosen because it has the right
- * precedence, it is rarely used, and it looks good: so people can
- * tell the special usage more quickly.
- */
- template <class _Tp> _Tp* operator->*(_Tp* ptr)
- { _M_process(ptr); return ptr; }
-private:
- debug_new_recorder(const debug_new_recorder&);
- debug_new_recorder& operator=(const debug_new_recorder&);
-};
-
-/**
- * Counter class for on-exit leakage check.
- *
- * This technique is learnt from <em>The C++ Programming Language</em> by
- * Bjarne Stroustup.
- */
-class debug_new_counter
-{
- static int _S_count;
-public:
- debug_new_counter();
- ~debug_new_counter();
-};
-/** Counting object for each file including debug_new.h. */
-static debug_new_counter __debug_new_count;
-
-NVWA_NAMESPACE_END
-
-#endif // NVWA_DEBUG_NEW_H
diff --git a/src/debug/nvwa/fast_mutex.h b/src/debug/nvwa/fast_mutex.h
deleted file mode 100644
index faccc4893..000000000
--- a/src/debug/nvwa/fast_mutex.h
+++ /dev/null
@@ -1,427 +0,0 @@
-// -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
-// vim:tabstop=4:shiftwidth=4:expandtab:
-
-/*
- * Copyright (C) 2004-2015 Wu Yongwei <adah at users dot sourceforge dot net>
- *
- * This software is provided 'as-is', without any express or implied
- * warranty. In no event will the authors be held liable for any
- * damages arising from the use of this software.
- *
- * Permission is granted to anyone to use this software for any purpose,
- * including commercial applications, and to alter it and redistribute
- * it freely, subject to the following restrictions:
- *
- * 1. The origin of this software must not be misrepresented; you must
- * not claim that you wrote the original software. If you use this
- * software in a product, an acknowledgement in the product
- * documentation would be appreciated but is not required.
- * 2. Altered source versions must be plainly marked as such, and must
- * not be misrepresented as being the original software.
- * 3. This notice may not be removed or altered from any source
- * distribution.
- *
- * This file is part of Stones of Nvwa:
- * http://sourceforge.net/projects/nvwa
- *
- */
-
-/**
- * @file fast_mutex.h
- *
- * A fast mutex implementation for POSIX, Win32, and modern C++.
- *
- * @date 2015-05-19
- */
-
-#ifndef NVWA_FAST_MUTEX_H
-#define NVWA_FAST_MUTEX_H
-
-#include "debug/nvwa/_nvwa.h" // NVWA_NAMESPACE_*
-#include "debug/nvwa/c++11.h" // HAVE_CXX11_MUTEX
-
-# if !defined(_NOTHREADS)
-# if !defined(NVWA_USE_CXX11_MUTEX) && HAVE_CXX11_MUTEX != 0 && \
- !defined(_WIN32THREADS) && !defined(NVWA_WIN32THREADS) && \
- !defined(NVWA_PTHREADS) && !defined(NVWA_NOTHREADS) && \
- defined(_WIN32) && defined(_MT) && \
- (!defined(_MSC_VER) || defined(_DLL))
-// Prefer using std::mutex on Windows to avoid the namespace
-// pollution caused by <windows.h>. However, MSVC has a re-entry
-// issue with its std::mutex implementation, and std::mutex should
-// not be used unless /MD or /MDd is used. For more information,
-// check out:
-//
-// https://connect.microsoft.com/VisualStudio/feedback/details/776596/std-mutex-not-a-constexpr-with-mtd-compiler-flag
-// http://stackoverflow.com/questions/14319344/stdmutex-lock-hangs-when-overriding-the-new-operator
-//
-# define NVWA_USE_CXX11_MUTEX 1
-# endif
-
-# if !defined(_WIN32THREADS) && \
- (defined(_WIN32) && defined(_MT))
-// Automatically use _WIN32THREADS when specifying -MT/-MD in MSVC,
-// or -mthreads in MinGW GCC.
-# define _WIN32THREADS
-# elif !defined(_PTHREADS) && \
- defined(_REENTRANT)
-// Automatically use _PTHREADS when specifying -pthread in GCC or Clang.
-# define _PTHREADS
-# endif
-# endif
-
-# ifndef NVWA_USE_CXX11_MUTEX
-# if HAVE_CXX11_MUTEX != 0 && \
- !defined(_NOTHREADS) && !defined(NVWA_NOTHREADS) && \
- !defined(_PTHREADS) && !defined(NVWA_PTHREADS) && \
- !defined(_WIN32THREADS) && !defined(NVWA_WIN32THREADS)
-# define NVWA_USE_CXX11_MUTEX 1
-# else
-# define NVWA_USE_CXX11_MUTEX 0
-# endif
-# endif
-
-# if !defined(_PTHREADS) && !defined(_WIN32THREADS) && \
- !defined(_NOTHREADS) && NVWA_USE_CXX11_MUTEX == 0
-# define _NOTHREADS
-# endif
-
-# if defined(_NOTHREADS)
-# if defined(_PTHREADS) || defined(_WIN32THREADS) || \
- NVWA_USE_CXX11_MUTEX != 0
-# undef _NOTHREADS
-# error "Cannot define multi-threaded mode with -D_NOTHREADS"
-# endif
-# endif
-
-# if defined(__MINGW32__) && defined(_WIN32THREADS) && !defined(_MT)
-# error "Be sure to specify -mthreads with -D_WIN32THREADS"
-# endif
-
-// With all the heuristics above, things may still go wrong, maybe even
-// due to a specific inclusion order. So they may be overridden by
-// manually defining the NVWA_* macros below.
-# if NVWA_USE_CXX11_MUTEX == 0 && \
- !defined(NVWA_WIN32THREADS) && \
- !defined(NVWA_PTHREADS) && \
- !defined(NVWA_NOTHREADS)
-// _WIN32THREADS takes precedence, as some C++ libraries have _PTHREADS
-// defined even on Win32 platforms.
-# if defined(_WIN32THREADS)
-# define NVWA_WIN32THREADS
-# elif defined(_PTHREADS)
-# define NVWA_PTHREADS
-# else
-# define NVWA_NOTHREADS
-# endif
-# endif
-
-# ifndef _FAST_MUTEX_CHECK_INITIALIZATION
-/**
- * Macro to control whether to check for initialization status for each
- * lock/unlock operation. Defining it to a non-zero value will enable
- * the check, so that the construction/destruction of a static object
- * using a static fast_mutex not yet constructed or already destroyed
- * will work (with lock/unlock operations ignored). Defining it to zero
- * will disable to check.
- */
-# define _FAST_MUTEX_CHECK_INITIALIZATION 1
-# endif
-
-# ifdef _DEBUG
-# include <stdio.h>
-# include <stdlib.h>
-/** Macro for fast_mutex assertions. Real version (for debug mode). */
-# define _FAST_MUTEX_ASSERT(_Expr, _Msg) \
- if (!(_Expr)) { \
- fprintf(stderr, "fast_mutex::%s\n", _Msg); \
- abort(); \
- }
-# else
-/** Macro for fast_mutex assertions. Fake version (for release mode). */
-# define _FAST_MUTEX_ASSERT(_Expr, _Msg) \
- ((void)0)
-# endif
-
-# if NVWA_USE_CXX11_MUTEX != 0
-# include <mutex>
-NVWA_NAMESPACE_BEGIN
-/**
- * Macro alias to `volatile' semantics. Here it is truly volatile since
- * it is in a multi-threaded (C++11) environment.
- */
-# define __VOLATILE volatile
- /**
- * Class for non-reentrant fast mutexes. This is the implementation
- * using the C++11 mutex.
- */
- class fast_mutex
- {
- std::mutex _M_mtx_impl;
-# if _FAST_MUTEX_CHECK_INITIALIZATION
- bool _M_initialized;
-# endif
-# ifdef _DEBUG
- bool _M_locked;
-# endif
- public:
- fast_mutex()
-# ifdef _DEBUG
- : _M_locked(false)
-# endif
- {
-# if _FAST_MUTEX_CHECK_INITIALIZATION
- _M_initialized = true;
-# endif
- }
- ~fast_mutex()
- {
- _FAST_MUTEX_ASSERT(!_M_locked, "~fast_mutex(): still locked");
-# if _FAST_MUTEX_CHECK_INITIALIZATION
- _M_initialized = false;
-# endif
- }
- void lock()
- {
-# if _FAST_MUTEX_CHECK_INITIALIZATION
- if (!_M_initialized)
- return;
-# endif
- _M_mtx_impl.lock();
-# ifdef _DEBUG
- _FAST_MUTEX_ASSERT(!_M_locked, "lock(): already locked");
- _M_locked = true;
-# endif
- }
- void unlock()
- {
-# if _FAST_MUTEX_CHECK_INITIALIZATION
- if (!_M_initialized)
- return;
-# endif
-# ifdef _DEBUG
- _FAST_MUTEX_ASSERT(_M_locked, "unlock(): not locked");
- _M_locked = false;
-# endif
- _M_mtx_impl.unlock();
- }
- private:
- fast_mutex(const fast_mutex&);
- fast_mutex& operator=(const fast_mutex&);
- };
-NVWA_NAMESPACE_END
-# elif defined(NVWA_PTHREADS)
-# include <pthread.h>
-NVWA_NAMESPACE_BEGIN
-/**
- * Macro alias to `volatile' semantics. Here it is truly volatile since
- * it is in a multi-threaded (POSIX threads) environment.
- */
-# define __VOLATILE volatile
- /**
- * Class for non-reentrant fast mutexes. This is the implementation
- * for POSIX threads.
- */
- class fast_mutex
- {
- pthread_mutex_t _M_mtx_impl;
-# if _FAST_MUTEX_CHECK_INITIALIZATION
- bool _M_initialized;
-# endif
-# ifdef _DEBUG
- bool _M_locked;
-# endif
- public:
- fast_mutex()
-# ifdef _DEBUG
- : _M_locked(false)
-# endif
- {
- ::pthread_mutex_init(&_M_mtx_impl, _NULLPTR);
-# if _FAST_MUTEX_CHECK_INITIALIZATION
- _M_initialized = true;
-# endif
- }
- ~fast_mutex()
- {
- _FAST_MUTEX_ASSERT(!_M_locked, "~fast_mutex(): still locked");
-# if _FAST_MUTEX_CHECK_INITIALIZATION
- _M_initialized = false;
-# endif
- ::pthread_mutex_destroy(&_M_mtx_impl);
- }
- void lock()
- {
-# if _FAST_MUTEX_CHECK_INITIALIZATION
- if (!_M_initialized)
- return;
-# endif
- ::pthread_mutex_lock(&_M_mtx_impl);
-# ifdef _DEBUG
- // The following assertion should _always_ be true for a
- // real `fast' pthread_mutex. However, this assertion can
- // help sometimes, when people forget to use `-lpthread' and
- // glibc provides an empty implementation. Having this
- // assertion is also more consistent.
- _FAST_MUTEX_ASSERT(!_M_locked, "lock(): already locked");
- _M_locked = true;
-# endif
- }
- void unlock()
- {
-# if _FAST_MUTEX_CHECK_INITIALIZATION
- if (!_M_initialized)
- return;
-# endif
-# ifdef _DEBUG
- _FAST_MUTEX_ASSERT(_M_locked, "unlock(): not locked");
- _M_locked = false;
-# endif
- ::pthread_mutex_unlock(&_M_mtx_impl);
- }
- private:
- fast_mutex(const fast_mutex&);
- fast_mutex& operator=(const fast_mutex&);
- };
-NVWA_NAMESPACE_END
-# elif defined(NVWA_WIN32THREADS)
-# ifndef WIN32_LEAN_AND_MEAN
-# define WIN32_LEAN_AND_MEAN
-# endif /* WIN32_LEAN_AND_MEAN */
-# include <windows.h>
-NVWA_NAMESPACE_BEGIN
-/**
- * Macro alias to `volatile' semantics. Here it is truly volatile since
- * it is in a multi-threaded (Win32 threads) environment.
- */
-# define __VOLATILE volatile
- /**
- * Class for non-reentrant fast mutexes. This is the implementation
- * for Win32 threads.
- */
- class fast_mutex
- {
- CRITICAL_SECTION _M_mtx_impl;
-# if _FAST_MUTEX_CHECK_INITIALIZATION
- bool _M_initialized;
-# endif
-# ifdef _DEBUG
- bool _M_locked;
-# endif
- public:
- fast_mutex()
-# ifdef _DEBUG
- : _M_locked(false)
-# endif
- {
- ::InitializeCriticalSection(&_M_mtx_impl);
-# if _FAST_MUTEX_CHECK_INITIALIZATION
- _M_initialized = true;
-# endif
- }
- ~fast_mutex()
- {
- _FAST_MUTEX_ASSERT(!_M_locked, "~fast_mutex(): still locked");
-# if _FAST_MUTEX_CHECK_INITIALIZATION
- _M_initialized = false;
-# endif
- ::DeleteCriticalSection(&_M_mtx_impl);
- }
- void lock()
- {
-# if _FAST_MUTEX_CHECK_INITIALIZATION
- if (!_M_initialized)
- return;
-# endif
- ::EnterCriticalSection(&_M_mtx_impl);
-# ifdef _DEBUG
- _FAST_MUTEX_ASSERT(!_M_locked, "lock(): already locked");
- _M_locked = true;
-# endif
- }
- void unlock()
- {
-# if _FAST_MUTEX_CHECK_INITIALIZATION
- if (!_M_initialized)
- return;
-# endif
-# ifdef _DEBUG
- _FAST_MUTEX_ASSERT(_M_locked, "unlock(): not locked");
- _M_locked = false;
-# endif
- ::LeaveCriticalSection(&_M_mtx_impl);
- }
- private:
- fast_mutex(const fast_mutex&);
- fast_mutex& operator=(const fast_mutex&);
- };
-NVWA_NAMESPACE_END
-# elif defined(NVWA_NOTHREADS)
-NVWA_NAMESPACE_BEGIN
-/**
- * Macro alias to `volatile' semantics. Here it is not truly volatile
- * since it is in a single-threaded environment.
- */
-# define __VOLATILE
- /**
- * Class for non-reentrant fast mutexes. This is the null
- * implementation for single-threaded environments.
- */
- class fast_mutex
- {
-# ifdef _DEBUG
- bool _M_locked;
-# endif
- public:
- fast_mutex()
-# ifdef _DEBUG
- : _M_locked(false)
-# endif
- {
- }
- ~fast_mutex()
- {
- _FAST_MUTEX_ASSERT(!_M_locked, "~fast_mutex(): still locked");
- }
- void lock()
- {
-# ifdef _DEBUG
- _FAST_MUTEX_ASSERT(!_M_locked, "lock(): already locked");
- _M_locked = true;
-# endif
- }
- void unlock()
- {
-# ifdef _DEBUG
- _FAST_MUTEX_ASSERT(_M_locked, "unlock(): not locked");
- _M_locked = false;
-# endif
- }
- private:
- fast_mutex(const fast_mutex&);
- fast_mutex& operator=(const fast_mutex&);
- };
-NVWA_NAMESPACE_END
-# endif // Definition of class fast_mutex
-
-NVWA_NAMESPACE_BEGIN
-/** RAII lock class for fast_mutex. */
-class fast_mutex_autolock
-{
- fast_mutex& _M_mtx;
-public:
- explicit fast_mutex_autolock(fast_mutex& mtx) : _M_mtx(mtx)
- {
- _M_mtx.lock();
- }
- ~fast_mutex_autolock()
- {
- _M_mtx.unlock();
- }
-private:
- fast_mutex_autolock(const fast_mutex_autolock&);
- fast_mutex_autolock& operator=(const fast_mutex_autolock&);
-};
-NVWA_NAMESPACE_END
-
-#endif // NVWA_FAST_MUTEX_H
diff --git a/src/debug/nvwa/source.txt b/src/debug/nvwa/source.txt
deleted file mode 100644
index 93a15332c..000000000
--- a/src/debug/nvwa/source.txt
+++ /dev/null
@@ -1 +0,0 @@
-https://github.com/adah1972/nvwa
diff --git a/src/debug/nvwa/static_assert.h b/src/debug/nvwa/static_assert.h
deleted file mode 100644
index 877ef0f97..000000000
--- a/src/debug/nvwa/static_assert.h
+++ /dev/null
@@ -1,62 +0,0 @@
-// -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
-// vim:tabstop=4:shiftwidth=4:expandtab:
-
-/*
- * Copyright (C) 2004-2013 Wu Yongwei <adah at users dot sourceforge dot net>
- *
- * This software is provided 'as-is', without any express or implied
- * warranty. In no event will the authors be held liable for any
- * damages arising from the use of this software.
- *
- * Permission is granted to anyone to use this software for any purpose,
- * including commercial applications, and to alter it and redistribute
- * it freely, subject to the following restrictions:
- *
- * 1. The origin of this software must not be misrepresented; you must
- * not claim that you wrote the original software. If you use this
- * software in a product, an acknowledgement in the product
- * documentation would be appreciated but is not required.
- * 2. Altered source versions must be plainly marked as such, and must
- * not be misrepresented as being the original software.
- * 3. This notice may not be removed or altered from any source
- * distribution.
- *
- * This file is part of Stones of Nvwa:
- * http://sourceforge.net/projects/nvwa
- *
- */
-
-/**
- * @file static_assert.h
- *
- * Template class to check validity duing compile time (adapted from Loki).
- *
- * @date 2013-09-07
- */
-
-#ifndef STATIC_ASSERT
-
-#include "debug/nvwa/c++11.h"
-
-#if HAVE_CXX11_STATIC_ASSERT
-
-#define STATIC_ASSERT(_Expr, _Msg) static_assert(_Expr, #_Msg)
-
-#else
-
-namespace nvwa {
-
-template <bool> struct compile_time_error;
-template <> struct compile_time_error<true> {};
-
-#define STATIC_ASSERT(_Expr, _Msg) \
- { \
- nvwa::compile_time_error<((_Expr) != 0)> ERROR_##_Msg; \
- (void)ERROR_##_Msg; \
- }
-
-}
-
-#endif // HAVE_CXX11_STATIC_ASSERT
-
-#endif // STATIC_ASSERT
diff --git a/src/debug/readme.txt b/src/debug/readme.txt
deleted file mode 100644
index bee507459..000000000
--- a/src/debug/readme.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-mse and nvwa libraries not used by default.
-For enable it, see configure flags.
diff --git a/src/defaults.cpp b/src/defaults.cpp
deleted file mode 100644
index 1dae4ed29..000000000
--- a/src/defaults.cpp
+++ /dev/null
@@ -1,742 +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 "defaults.h"
-
-#include "configuration.h"
-#include "graphicsmanager.h"
-#include "variabledata.h"
-
-#include "being/beingspeech.h"
-
-#include "const/render/graphics.h"
-
-#include "enums/screendensity.h"
-
-#include "enums/being/badgedrawtype.h"
-#include "enums/being/visiblename.h"
-#include "enums/being/visiblenamepos.h"
-
-#include "enums/input/inputaction.h"
-
-#include "enums/particle/particlephysics.h"
-
-#include "render/graphics.h"
-
-#include "const/net/net.h"
-
-#ifndef USE_SDL2
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_keyboard.h>
-PRAGMA48(GCC diagnostic pop)
-#endif // USE_SDL2
-
-#include "debug.h"
-
-VariableData* createData(const int defData)
-{
- return new IntData(defData);
-}
-
-VariableData* createData(const double defData)
-{
- return new FloatData(defData);
-}
-
-VariableData* createData(const float defData)
-{
- return new FloatData(defData);
-}
-
-VariableData* createData(const std::string &defData)
-{
- return new StringData(defData);
-}
-
-VariableData* createData(const char *const defData)
-{
- return new StringData(defData);
-}
-
-VariableData* createData(const bool defData)
-{
- return new BoolData(defData);
-}
-
-#define AddDEF(key, value) \
- configData.insert(std::pair<std::string, VariableData*> \
- (key, createData(value)));
-
-void setConfigDefaults(Configuration &cfg)
-{
- logger->log("Set config default values to configuration %s",
- cfg.getFileName().c_str());
- cfg.cleanDefaults();
- DefaultsData &configData = cfg.getDefaultValues();
- AddDEF("OverlayDetail", 2);
- AddDEF("speechBubbleAlpha", 1.0F);
- AddDEF("MostUsedServerName0", "server.themanaworld.org");
- AddDEF("visiblenames", VisibleName::Show);
- AddDEF("visiblenamespos", VisibleNamePos::Bottom);
- AddDEF("speech", CAST_S32(BeingSpeech::NO_NAME_IN_BUBBLE));
- AddDEF("showgender", true);
- AddDEF("showlevel", false);
- AddDEF("showMonstersTakedDamage", true);
- AddDEF("highlightAttackRange", false);
- AddDEF("highlightMapPortals", true);
- AddDEF("highlightMonsterAttackRange", false);
- AddDEF("chatMaxCharLimit", 512);
- AddDEF("lowTraffic", true);
- AddDEF("invertMoveDirection", 0);
- AddDEF("crazyMoveType", 1);
- AddDEF("attackWeaponType", 1);
- AddDEF("quickDropCounter", 1);
- AddDEF("pickUpType", 5);
- AddDEF("magicAttackType", 0);
- AddDEF("attackType", 2);
- AddDEF("targetingType", 0);
- AddDEF("followMode", 0);
- AddDEF("imitationMode", 0);
- AddDEF("syncPlayerMove", true);
- AddDEF("syncPlayerMoveDistance", 5);
- AddDEF("drawPath", false);
- AddDEF("moveToTargetType", 10);
- AddDEF("crazyMoveProgram", "mumrsonmdmlon");
- AddDEF("disableGameModifiers", true);
- AddDEF("targetDeadPlayers", false);
- AddDEF("afkMessage", "I am away from keyboard.");
- AddDEF("afkFormat", 0);
- AddDEF("particleMaxCount", 3000);
- AddDEF("particleFastPhysics", CAST_S32(ParticlePhysics::Normal));
- AddDEF("particleEmitterSkip", 1);
- AddDEF("particleeffects", true);
- AddDEF("mapparticleeffects", true);
- AddDEF("opengl", 0);
-#ifdef ANDROID
- AddDEF("screenwidth", 0);
- AddDEF("screenheight", 0);
- AddDEF("showScreenJoystick", true);
- AddDEF("showScreenButtons", true);
- AddDEF("showBeingPopup", false);
- AddDEF("mouseDirectionMove", true);
- AddDEF("showScreenKeyboard", true);
- AddDEF("fpslimit", 100);
- AddDEF("showChatColorsList", false);
- AddDEF("customcursor", false);
- AddDEF("showDidYouKnow", false);
- AddDEF("longmouseclick", true);
-#else // ANDROID
-
- AddDEF("screenwidth", defaultScreenWidth);
- AddDEF("screenheight", defaultScreenHeight);
- AddDEF("showScreenJoystick", false);
- AddDEF("showScreenButtons", false);
- AddDEF("showBeingPopup", true);
- AddDEF("mouseDirectionMove", false);
- AddDEF("showScreenKeyboard", false);
- AddDEF("fpslimit", 60);
- AddDEF("showChatColorsList", true);
- AddDEF("customcursor", true);
- AddDEF("showDidYouKnow", true);
- AddDEF("longmouseclick", false);
-#endif // ANDROID
-
- AddDEF("theme", "jewelry");
- AddDEF("showEmotesButton", true);
- AddDEF("screen", false);
- AddDEF("hwaccel", false);
- AddDEF("sound", false);
- AddDEF("sfxVolume", 100);
- AddDEF("musicVolume", 60);
- AddDEF("remember", false);
- AddDEF("username", "");
- AddDEF("lastCharacter", "");
- AddDEF("altfpslimit", 5);
- AddDEF("updatehost", "");
- AddDEF("screenshotDirectory3", "");
- AddDEF("useScreenshotDirectorySuffix", true);
- AddDEF("screenshotDirectorySuffix", "");
- AddDEF("EnableSync", false);
- AddDEF("joystickEnabled", false);
- AddDEF("upTolerance", 100);
- AddDEF("downTolerance", 100);
- AddDEF("leftTolerance", 100);
- AddDEF("rightTolerance", 100);
- AddDEF("logNpcInGui", true);
- AddDEF("download-music", true);
- AddDEF("guialpha", 0.8F);
- AddDEF("ChatLogLength", 0);
- AddDEF("enableChatLog", true);
- AddDEF("whispertab", true);
- AddDEF("showownname", true);
- AddDEF("showpickupparticle", true);
- AddDEF("showpickupchat", true);
- AddDEF("ReturnToggles", false);
- AddDEF("ScrollLaziness", 16);
- AddDEF("ScrollRadius", 0);
- AddDEF("ScrollCenterOffsetX", 0);
- AddDEF("ScrollCenterOffsetY", 0);
- AddDEF("enableMumble", false);
- AddDEF("playBattleSound", true);
- AddDEF("playGuiSound", true);
- AddDEF("playMusic", true);
- AddDEF("packetcounters", true);
- AddDEF("safemode", false);
- AddDEF("font", "fonts/dejavusans.ttf");
- AddDEF("boldFont", "fonts/dejavusans-bold.ttf");
- AddDEF("particleFont", "fonts/dejavusans.ttf");
- AddDEF("helpFont", "fonts/dejavusansmono.ttf");
- AddDEF("secureFont", "fonts/dejavusansmono.ttf");
- AddDEF("japanFont", "fonts/mplus-1p-regular.ttf");
- AddDEF("chinaFont", "fonts/wqy-microhei.ttf");
- AddDEF("npcFont", "fonts/dejavusans.ttf");
- AddDEF("showBackground", true);
- AddDEF("enableTradeTab", true);
- AddDEF("cyclePlayers", true);
- AddDEF("cycleMonsters", true);
- AddDEF("cycleNPC", true);
- AddDEF("floorItemsHighlight", true);
- AddDEF("enableBotCheker", true);
- AddDEF("removeColors", true);
- AddDEF("showMagicInDebug", true);
- AddDEF("allowCommandsInChatTabs", true);
- AddDEF("serverMsgInDebug", true);
- AddDEF("hideShopMessages", true);
- AddDEF("showChatHistory", true);
- AddDEF("chatMaxLinesLimit", 40);
- AddDEF("chatColor", 0);
- AddDEF("showJob", true);
- AddDEF("updateOnlineList", true);
- AddDEF("targetOnlyReachable", true);
- AddDEF("errorsInDebug", true);
- AddDEF("tradebot", true);
- AddDEF("debugLog", false);
- AddDEF("unimplimentedLog", false);
- AddDEF("drawHotKeys", true);
- AddDEF("serverAttack", true);
- AddDEF("autofixPos", false);
- AddDEF("alphaCache", true);
- AddDEF("attackMoving", true);
- AddDEF("attackNext", false);
- AddDEF("quickStats", true);
- AddDEF("warpParticle", false);
- AddDEF("autoShop", false);
- AddDEF("enableBattleTab", false);
- AddDEF("showBattleEvents", false);
- AddDEF("showMobHP", true);
- AddDEF("showOwnHP", true);
- AddDEF("usePersistentIP", true);
- AddDEF("showJobExp", true);
- AddDEF("showExtMinimaps", false);
- AddDEF("hideChatInput", true);
- AddDEF("enableAttackFilter", true);
- AddDEF("enablePickupFilter", true);
- AddDEF("securetrades", true);
- AddDEF("unsecureChars", "IO0@#$");
- AddDEF("currentTip", 0);
- AddDEF("useLocalTime", false);
- AddDEF("enableAdvert", true);
- AddDEF("enableMapReduce", true);
- AddDEF("showPlayersStatus", true);
- AddDEF("beingopacity", false);
- AddDEF("adjustPerfomance", true);
- AddDEF("enableAlphaFix", false);
- AddDEF("disableAdvBeingCaching", true);
- AddDEF("disableBeingCaching", false);
- AddDEF("enableReorderSprites", true);
- AddDEF("showip", false);
- AddDEF("seflMouseHeal", true);
- AddDEF("enableLazyScrolling", false);
- AddDEF("extMouseTargeting", true);
- AddDEF("showMVP", false);
- AddDEF("pvpAttackType", 0);
- AddDEF("lang", "");
- AddDEF("selectedJoystick", 0);
- AddDEF("useInactiveJoystick", false);
- AddDEF("testInfo", "");
- AddDEF("enableresize", true);
- AddDEF("noframe", false);
- AddDEF("groupFriends", true);
- AddDEF("grabinput", false);
- AddDEF("usefbo", false);
- AddDEF("gamma", 1);
- AddDEF("vsync", 0);
- AddDEF("enableBuggyServers", true);
- AddDEF("soundwhisper", "newmessage");
- AddDEF("soundhighlight", "reminder");
- AddDEF("soundglobal", "email");
- AddDEF("sounderror", "error");
- AddDEF("soundtrade", "start");
- AddDEF("soundinfo", "notify");
- AddDEF("soundrequest", "attention");
- AddDEF("soundguild", "newmessage");
- AddDEF("soundshowwindow", "page");
- AddDEF("soundhidewindow", "book");
- AddDEF("autohideButtons", true);
- AddDEF("autohideChat", false);
- AddDEF("downloadProxy", "");
- AddDEF("downloadProxyType", 0);
- AddDEF("downloadProxyTunnel", false);
- AddDEF("blur", false);
-#if defined(WIN32) || defined(__APPLE__)
- AddDEF("centerwindow", true);
-#else // defined(WIN32) || defined(__APPLE__)
-
- AddDEF("centerwindow", false);
-#endif // defined(WIN32) || defined(__APPLE__)
-
- AddDEF("audioFrequency", 44100);
- AddDEF("audioChannels", 2);
-#ifdef USE_SDL2
- AddDEF("repeateDelay", 500);
- AddDEF("repeateInterval", 30);
- AddDEF("repeateInterval2", 500);
-#else // USE_SDL2
-
- AddDEF("repeateDelay", SDL_DEFAULT_REPEAT_DELAY);
- AddDEF("repeateInterval", SDL_DEFAULT_REPEAT_INTERVAL);
- AddDEF("repeateInterval2", SDL_DEFAULT_REPEAT_DELAY);
-#endif // USE_SDL2
-
- AddDEF("compresstextures", 0);
- AddDEF("rectangulartextures", false);
- AddDEF("networksleep", 0);
- AddDEF("newtextures", true);
- AddDEF("videodetected", false);
- AddDEF("hideErased", false);
- AddDEF("enableDelayedAnimations", true);
- AddDEF("enableCompoundSpriteDelay", true);
-#ifdef ANDROID
- AddDEF("useAtlases", false);
-#else // ANDROID
-
- AddDEF("useAtlases", true);
-#endif // ANDROID
-
- AddDEF("useTextureSampler", false);
- AddDEF("ministatussaved", 0);
- AddDEF("allowscreensaver", false);
- AddDEF("debugOpenGL", 0);
- AddDEF("protectChatFocus", true);
-#if defined(__APPLE__)
- AddDEF("enableGamma", false);
-#else // defined(__APPLE__)
-
- AddDEF("enableGamma", true);
-#endif // defined(__APPLE__)
-
- AddDEF("logInput", false);
- AddDEF("highlightWords", "");
- AddDEF("globalsFilter", "Sagatha");
- AddDEF("selfMouseHeal", true);
- AddDEF("serverslistupdate", "");
- AddDEF("fadeoutmusic", true);
- AddDEF("screenActionKeyboard", CAST_S32(
- InputAction::SHOW_KEYBOARD));
- AddDEF("screenActionButton0", CAST_S32(InputAction::TALK));
- AddDEF("screenActionButton1", CAST_S32(
- InputAction::TARGET_ATTACK));
- AddDEF("screenActionButton2", CAST_S32(InputAction::PICKUP));
- AddDEF("screenActionButton3", CAST_S32(InputAction::STOP_SIT));
- AddDEF("screenActionButton4", CAST_S32(InputAction::TARGET_NPC));
- AddDEF("screenActionButton5", CAST_S32(
- InputAction::WINDOW_STATUS));
- AddDEF("screenActionButton6", CAST_S32(
- InputAction::WINDOW_INVENTORY));
- AddDEF("screenActionButton7", CAST_S32(InputAction::WINDOW_SKILL));
- AddDEF("screenActionButton8", CAST_S32(
- InputAction::WINDOW_SOCIAL));
- AddDEF("screenActionButton9", CAST_S32(InputAction::WINDOW_DEBUG));
- AddDEF("screenActionButton10", CAST_S32(
- InputAction::CHANGE_TRADE));
- AddDEF("screenActionButton11", CAST_S32(InputAction::DIRECT_DOWN));
- AddDEF("screenButtonsFormat", 0);
- AddDEF("autoresizeminimaps", false);
- AddDEF("showGuildOnline", false);
- AddDEF("showPartyOnline", false);
- AddDEF("enableGmTab", true);
- AddDEF("gamecount", 0);
- AddDEF("rated", false);
- AddDEF("weightMsg", true);
- AddDEF("enableLangTab", true);
- AddDEF("showAllLang", false);
- AddDEF("moveNames", false);
- AddDEF("uselonglivesprites", false);
- AddDEF("uselonglivesounds", true);
- AddDEF("screenDensity", 0);
- AddDEF("cfgver", 14);
- AddDEF("enableDebugLog", false);
- AddDEF("doubleClick", true);
- AddDEF("useDiagonalSpeed", true);
- AddDEF("protectedItems", "");
- AddDEF("inventorySortOrder", 0);
- AddDEF("storageSortOrder", 0);
- AddDEF("cartSortOrder", 0);
- AddDEF("buySortOrder", 0);
- AddDEF("showmotd", false);
- AddDEF("playMapAnimations", true);
- AddDEF("usepets", true);
- AddDEF("scale", 1);
- AddDEF("addwatermark", true);
- AddDEF("hidesupport", false);
- AddDEF("showserverpos", false);
- AddDEF("textureSize", "1024,1024,1024,1024,1024,1024");
- AddDEF("ignorelogpackets", "");
- AddDEF("disableLoggingInGame", false);
- AddDEF("sellShopName", "unnamed");
- AddDEF("showBadges", BadgeDrawType::Top);
- AddDEF("tradescreenshot", false);
- AddDEF("skillAutotarget", true);
- AddDEF("logPlayerActions", false);
- AddDEF("enableGuiOpacity", true);
- AddDEF("enableTradeFilter", true);
- AddDEF("enableIdCollecting", false);
- AddDEF("checkOpenGLVersion", true);
- AddDEF("openglContext", false);
- AddDEF("allowMoveByMouse", true);
- AddDEF("enableDSA", true);
- AddDEF("blockAltTab", true);
- AddDEF("sdlLogLevel", 0);
- AddDEF("allowHighDPI", false);
- AddDEF("sdlDriver", "");
- AddDEF("parallelAudioChannels", 16);
-}
-
-void setConfigDefaults2(Configuration &cfg)
-{
- logger->log("Add config default values to configuration %s",
- cfg.getFileName().c_str());
- DefaultsData &configData = cfg.getDefaultValues();
- const int density = graphicsManager.getDensity();
- int size = 12;
- int buttonSize = 1;
- switch (density)
- {
- case DENSITY_LOW:
- case DENSITY_MEDIUM:
- buttonSize = 1;
- break;
- case DENSITY_TV:
- size = 14;
- buttonSize = 1;
- break;
- case DENSITY_HIGH:
- size = 16;
- buttonSize = 2;
- break;
- case DENSITY_XHIGH:
- size = 18;
- buttonSize = 3;
- break;
- case DENSITY_XXHIGH:
- size = 20;
- buttonSize = 3;
- break;
- default:
- break;
- }
- AddDEF("fontSize", size);
- AddDEF("npcfontSize", size + 1);
- if (mainGraphics->getHeight() < 480)
- {
- AddDEF("screenButtonsSize", 0);
- AddDEF("screenJoystickSize", 0);
- }
- else
- {
- AddDEF("screenButtonsSize", buttonSize);
- AddDEF("screenJoystickSize", buttonSize);
- }
-}
-
-void setBrandingDefaults(Configuration &cfg)
-{
- logger->log("Set branding default values to configuration %s",
- cfg.getFileName().c_str());
- cfg.cleanDefaults();
- DefaultsData &configData = cfg.getDefaultValues();
- AddDEF("wallpapersPath", "");
- AddDEF("wallpapersFile", "");
- AddDEF("appName", "ManaPlus");
- AddDEF("appIcon", "icons/manaplus");
- AddDEF("loginMusic", "keprohm.ogg");
- AddDEF("defaultServer", "");
- AddDEF("defaultPort", DEFAULT_PORT);
- AddDEF("defaultServerType", "tmwathena");
- AddDEF("onlineServerList",
- "http://manaplus.org/serverlist.xml");
- AddDEF("onlineServerList2",
- "http://www.manaplus.org/serverlist.xml");
- AddDEF("onlineServerFile", "serverlistplus.xml");
- AddDEF("appShort", "mana");
- AddDEF("screenshots", "ManaPlus");
- AddDEF("defaultUpdateHost", "");
- AddDEF("helpPath", "");
- AddDEF("tagsPath", "");
- AddDEF("theme", "");
- AddDEF("font", "fonts/dejavusans.ttf");
- AddDEF("boldFont", "fonts/dejavusans-bold.ttf");
- AddDEF("particleFont", "fonts/dejavusans.ttf");
- AddDEF("helpFont", "fonts/dejavusansmono.ttf");
- AddDEF("secureFont", "fonts/dejavusansmono.ttf");
- AddDEF("npcFont", "fonts/dejavusans.ttf");
- AddDEF("japanFont", "fonts/mplus-1p-regular.ttf");
- AddDEF("chinaFont", "fonts/wqy-microhei.ttf");
-
- AddDEF("guiPath", "graphics/gui/");
- AddDEF("guiThemePath", "themes/");
- AddDEF("fontsPath", "fonts/");
-
- AddDEF("systemsounds", "sfx/system/");
-
- AddDEF("wallpaperFile", "");
- AddDEF("dataPath", "");
-
- AddDEF("androidDownloadUrl", "https://play.google.com/store/apps/details"
- "?id=org.evolonline.beta.manaplus");
- AddDEF("androidDownloadText", "Google Play");
- AddDEF("otherDownloadUrl", "http://manaplus.org/");
- AddDEF("otherDownloadText", "http://manaplus.org/");
- AddDEF("windowsDownloadUrl", "http://download.manaplus.org/"
- "manaplus/download/manaplus-win32.exe");
- AddDEF("windowsDownloadText", "download here");
- AddDEF("updateMirror1", "http://manaplus.org/update/");
- AddDEF("updateMirror2", "http://www.manaplus.org/update/");
- AddDEF("updateMirror3", "http://www2.manaplus.org/update/");
- AddDEF("updateMirror4", "http://www3.manaplus.org/update/");
- AddDEF("updateMirror5", "");
- AddDEF("updateMirror6", "");
- AddDEF("updateMirror7", "");
-}
-
-void setPathsDefaults(Configuration &cfg)
-{
- logger->log("Set path default values to configuration %s",
- cfg.getFileName().c_str());
- cfg.cleanDefaults();
- DefaultsData &configData = cfg.getDefaultValues();
- AddDEF("itemIcons", "graphics/items/");
- AddDEF("unknownItemFile", "unknown-item.png");
- AddDEF("sprites", "graphics/sprites/");
- AddDEF("spriteErrorFile", "error.xml");
- AddDEF("guiIcons", "graphics/guiicons/");
- AddDEF("shaders", "graphics/shaders/");
- AddDEF("help", "help/");
- AddDEF("tags", "help/idx/");
- AddDEF("badges", "graphics/badges/");
-
- AddDEF("simpleVertexShader", "simple_vertex.glsl");
- AddDEF("simpleFragmentShader", "simple_frag.glsl");
- AddDEF("gles2VertexShader", "gles2_vertex.glsl");
- AddDEF("gles2FragmentShader", "gles2_frag.glsl");
-
- AddDEF("particles", "graphics/particles/");
- AddDEF("portalEffectFile", "warparea.particle.xml");
- AddDEF("effectId", -1);
- AddDEF("hitEffectId", 26);
- AddDEF("missEffectId", -1);
- AddDEF("criticalHitEffectId", 28);
- AddDEF("afkEffectId", -1);
- AddDEF("newQuestEffectId", -1);
- AddDEF("completeQuestEffectId", -1);
- AddDEF("skillLevelUpEffectId", -1);
- AddDEF("skillRemoveEffectId", -1);
- AddDEF("skillSrcEffectId", -1);
- AddDEF("skillDstEffectId", -1);
- AddDEF("skillCastingSrcEffectId", -1);
- AddDEF("skillCastingDstEffectId", -1);
- AddDEF("skillCastingGroundEffectId", -1);
- AddDEF("skillHitEffectId", -1);
- AddDEF("skillMissEffectId", -1);
-
- AddDEF("spiritEffectId", -1);
-
- AddDEF("minimaps", "graphics/minimaps/");
- AddDEF("maps", "maps/");
- AddDEF("sfx", "sfx/");
- AddDEF("music", "music/");
-
- AddDEF("wallpapers", "graphics/images/");
- AddDEF("wallpaperFile", "login_wallpaper.png");
-
- AddDEF("statusEffectsFile", "status-effects.xml");
- AddDEF("statusEffectsPatchFile", "status-effects_patch.xml");
- AddDEF("statusEffectsPatchDir", "status-effects.d");
- AddDEF("effectsFile", "effects.xml");
- AddDEF("effectsPatchFile", "effects_patch.xml");
- AddDEF("effectsPatchDir", "effects.d");
- AddDEF("unitsFile", "units.xml");
- AddDEF("unitsPatchFile", "units_patch.xml");
- AddDEF("unitsPatchDir", "units.d");
- AddDEF("featuresFile", "features.xml");
- AddDEF("questsFile", "quests.xml");
- AddDEF("questsPatchFile", "quests_patch.xml");
- AddDEF("questsPatchDir", "quests.d");
- AddDEF("skillsFile", "skills.xml");
- AddDEF("skillsPatchFile", "skills_patch.xml");
- AddDEF("skillsPatchDir", "skills.d");
- AddDEF("skillsFile2", "ea-skills.xml");
- AddDEF("equipmentWindowFile", "equipmentwindow.xml");
- AddDEF("emotesFile", "emotes.xml");
- AddDEF("emotesPatchFile", "emotes_patch.xml");
- AddDEF("emotesPatchDir", "emotes.d");
- AddDEF("hairColorFile", "hair.xml");
- AddDEF("hairColorPatchFile", "hair_patch.xml");
- AddDEF("hairColorPatchDir", "hair.d");
- AddDEF("horsesFile", "horses.xml");
- AddDEF("horsesPatchFile", "horses_patch.xml");
- AddDEF("horsesPatchDir", "horses.d");
- AddDEF("itemColorsFile", "itemcolors.xml");
- AddDEF("itemColorsPatchFile", "itemcolors_patch.xml");
- AddDEF("itemColorsPatchDir", "itemcolors.d");
- AddDEF("charCreationFile", "charcreation.xml");
- AddDEF("soundsFile", "sounds.xml");
- AddDEF("soundsPatchFile", "sounds_patch.xml");
- AddDEF("soundsPatchDir", "sounds.d");
- AddDEF("itemsFile", "items.xml");
- AddDEF("itemsPatchFile", "items_patch.xml");
- AddDEF("itemsPatchDir", "items.d");
- AddDEF("itemFieldsFile", "itemfields.xml");
- AddDEF("itemFieldsPatchFile", "itemfields_patch.xml");
- AddDEF("itemFieldsPatchDir", "itemfields.d");
- AddDEF("itemOptionsFile", "itemoptions.xml");
- AddDEF("itemOptionsPatchFile", "itemoptions_patch.xml");
- AddDEF("itemOptionsPatchDir", "itemoptions.d");
- AddDEF("avatarsFile", "avatars.xml");
- AddDEF("avatarsPatchFile", "avatars_patch.xml");
- AddDEF("avatarsPatchDir", "avatars.d");
- AddDEF("modsFile", "mods.xml");
- AddDEF("modsPatchFile", "mods_patch.xml");
- AddDEF("modsPatchDir", "mods.d");
- AddDEF("npcsFile", "npcs.xml");
- AddDEF("npcsPatchFile", "npcs_patch.xml");
- AddDEF("npcsPatchDir", "npcs.d");
- AddDEF("petsFile", "pets.xml");
- AddDEF("petsPatchFile", "pets_patch.xml");
- AddDEF("petsPatchDir", "pets.d");
- AddDEF("monstersFile", "monsters.xml");
- AddDEF("monstersPatchFile", "monsters_patch.xml");
- AddDEF("monstersPatchDir", "monsters.d");
- AddDEF("mercenariesFile", "mercenaries.xml");
- AddDEF("mercenariesPatchFile", "mercenaries_patch.xml");
- AddDEF("mercenariesPatchDir", "mercenaries.d");
- AddDEF("homunculusesFile", "homunculuses.xml");
- AddDEF("homunculusesPatchFile", "homunculuses_patch.xml");
- AddDEF("homunculusesPatchDir", "homunculuses.d");
- AddDEF("skillUnitsFile", "skillunits.xml");
- AddDEF("skillUnitsPatchFile", "skillunits_patch.xml");
- AddDEF("skillUnitsPatchDir", "skillunits.d");
- AddDEF("elementalsFile", "elementals.xml");
- AddDEF("elementalsPatchFile", "elementals_patch.xml");
- AddDEF("elementalsPatchDir", "elementals.d");
- AddDEF("mapsRemapFile", "maps/remap.xml");
- AddDEF("mapsRemapPatchFile", "maps/remap_patch.xml");
- AddDEF("mapsRemapPatchDir", "maps/remap.d");
- AddDEF("mapsFile", "maps.xml");
- AddDEF("mapsPatchFile", "maps_patch.xml");
- AddDEF("mapsPatchDir", "maps.d");
- AddDEF("npcDialogsFile", "npcdialogs.xml");
- AddDEF("npcDialogsPatchFile", "npcdialogs_patch.xml");
- AddDEF("npcDialogsPatchDir", "npcdialogs.d");
- AddDEF("deadMessagesFile", "deadmessages.xml");
- AddDEF("deadMessagesPatchFile", "deadmessages_patch.xml");
- AddDEF("deadMessagesPatchDir", "deadmessages.d");
- AddDEF("defaultCommandsFile", "defaultcommands.xml");
- AddDEF("defaultCommandsPatchFile", "defaultcommands_patch.xml");
- AddDEF("defaultCommandsPatchDir", "defaultcommands.d");
- AddDEF("badgesFile", "badges.xml");
- AddDEF("badgesPatchFile", "badges_patch.xml");
- AddDEF("badgesPatchDir", "badges.d");
- AddDEF("languagesFile", "languages.xml");
- AddDEF("languagesPatchFile", "languages_patch.xml");
- AddDEF("languagesPatchDir", "languages.d");
- AddDEF("textsFile", "texts.xml");
- AddDEF("textsPatchFile", "texts_patch.xml");
- AddDEF("textsPatchDir", "texts.d");
- AddDEF("networkFile", "network.xml");
- AddDEF("networkPatchFile", "network_patch.xml");
- AddDEF("networkPatchDir", "network.d");
- AddDEF("statFile", "stats.xml");
- AddDEF("statPatchFile", "stats_patch.xml");
- AddDEF("statPatchDir", "stats.d");
- AddDEF("groupsFile", "groups.xml");
- AddDEF("groupsPatchFile", "groups_patch.xml");
- AddDEF("groupsPatchDir", "groups.d");
- AddDEF("equipmentSlotsFile", "equipmentslots.xml");
- AddDEF("weaponsFile", "weapons.xml");
- AddDEF("poisonEffectName", "poison");
- AddDEF("cartEffectName", "cart");
- AddDEF("ridingEffectName", "riding");
- AddDEF("trickDeadEffectName", "trick dead");
- AddDEF("postDelayName", "post delay");
- AddDEF("gmTabMinimalLevel", "2");
- AddDEF("team1badge", "team1.xml");
- AddDEF("team2badge", "team2.xml");
- AddDEF("team3badge", "team3.xml");
- AddDEF("gmbadge", "gm.xml");
- AddDEF("shopbadge", "shop.xml");
- AddDEF("inactivebadge", "inactive.xml");
- AddDEF("awaybadge", "away.xml");
- AddDEF("cutInsDir", "graphics/cutins");
- AddDEF("gmCommandSymbol", "@");
- AddDEF("gmCharCommandSymbol", "#");
- AddDEF("linkCommandSymbol", "=");
- AddDEF("emptyAtlasName", "ignored");
- AddDEF("skillCastingAnimation", "");
- AddDEF("languageIcons", "graphics/badges/flags");
- AddDEF("palettesDir", "");
- AddDEF("defaultPaletteFile", "palette.gpl");
- AddDEF("unknownSkillIcon", "graphics/sprites/error.png");
- AddDEF("attackSkillIcon", "graphics/sprites/error.png");
- AddDEF("groundSkillIcon", "graphics/sprites/error.png");
- AddDEF("selfSkillIcon", "graphics/sprites/error.png");
- AddDEF("unusedSkillIcon", "graphics/sprites/error.png");
- AddDEF("supportSkillIcon", "graphics/sprites/error.png");
- AddDEF("trapSkillIcon", "graphics/sprites/error.png");
- AddDEF("missingSkillIcon", "graphics/sprites/error.png");
- AddDEF("unknownSkillsAutoTab", true);
-
- AddDEF("overweightPercent", 50);
- AddDEF("playerNameOffset", 64);
- AddDEF("playerBadgeAtRightOffset", 32);
-
-#ifdef TMWA_SUPPORT
- AddDEF("gmDefaultLevel", 60);
-#endif // TMWA_SUPPORT
-
- AddDEF("enableNewMailSystem", true);
-}
-
-void setFeaturesDefaults(Configuration &cfg)
-{
- logger->log("Set features default values to configuration %s",
- cfg.getFileName().c_str());
- cfg.cleanDefaults();
- DefaultsData &configData = cfg.getDefaultValues();
- AddDEF("languageTab", false);
- AddDEF("allowFollow", true);
- AddDEF("fixDeadAnimation", true);
- AddDEF("forceAccountGender", -1);
- AddDEF("forceCharGender", -1);
-}
-
-#undef AddDEF
diff --git a/src/defaults.h b/src/defaults.h
deleted file mode 100644
index f38c13ee1..000000000
--- a/src/defaults.h
+++ /dev/null
@@ -1,47 +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 DEFAULTS_H
-#define DEFAULTS_H
-
-#include <map>
-#include <string>
-
-#include "localconsts.h"
-
-class Configuration;
-class VariableData;
-
-typedef std::map<std::string, VariableData*> DefaultsData;
-
-VariableData* createData(const int defData) A_WARN_UNUSED;
-VariableData* createData(const double defData) A_WARN_UNUSED;
-VariableData* createData(const float defData) A_WARN_UNUSED;
-VariableData* createData(const std::string &defData) A_WARN_UNUSED;
-VariableData* createData(const char *const defData) A_WARN_UNUSED;
-VariableData* createData(const bool defData) A_WARN_UNUSED;
-void setConfigDefaults(Configuration &cfg);
-void setConfigDefaults2(Configuration &cfg);
-void setBrandingDefaults(Configuration &cfg);
-void setPathsDefaults(Configuration &cfg);
-void setFeaturesDefaults(Configuration &cfg);
-
-#endif // DEFAULTS_H
diff --git a/src/dirs.cpp b/src/dirs.cpp
deleted file mode 100644
index 004e1fdb4..000000000
--- a/src/dirs.cpp
+++ /dev/null
@@ -1,615 +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 "dirs.h"
-
-#include "client.h"
-#include "configuration.h"
-#include "logger.h"
-#include "main.h"
-#include "settings.h"
-
-#include "fs/mkdir.h"
-#include "fs/paths.h"
-
-#include "fs/virtfs/fs.h"
-
-#include "utils/base64.h"
-#if defined(__native_client__) || (defined(ANDROID) && defined(USE_SDL2))
-#include "fs/files.h"
-#endif // defined(__native_client__) || (defined(ANDROID) &&
- // defined(USE_SDL2))
-
-#include "utils/cast.h"
-#include "utils/gettext.h"
-
-#ifdef ANDROID
-#ifdef USE_SDL2
-#include "main.h"
-
-#include "render/graphics.h"
-#endif // USE_SDL2
-#endif // ANDROID
-
-#ifdef __APPLE__
-#include <CoreFoundation/CFBundle.h>
-#endif // __APPLE__
-
-#ifdef WIN32
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_syswm.h>
-PRAGMA48(GCC diagnostic pop)
-#include "fs/specialfolder.h"
-#undef ERROR
-#endif // WIN32
-
-#include <sys/stat.h>
-
-#include <sstream>
-
-#include "debug.h"
-
-#if defined __native_client__
-#define _nacl_dir std::string("/persistent/manaplus")
-#endif // defined __native_client__
-
-#ifdef ANDROID
-#ifdef USE_SDL2
-
-int loadingProgressCounter = 1;
-
-static void updateProgress(int cnt)
-{
- const int progress = cnt + loadingProgressCounter;
- const int h = mainGraphics->mHeight;
- mainGraphics->setColor(Color(255, 255, 255));
- const int maxSize = mainGraphics->mWidth - 100;
- const int width = maxSize * progress / 50;
- mainGraphics->fillRectangle(Rect(50, h - 100, width, 50));
- mainGraphics->updateScreen();
-}
-
-void Dirs::setProgress()
-{
- loadingProgressCounter++;
- updateProgress(loadingProgressCounter);
-}
-
-static void resetProgress()
-{
- loadingProgressCounter = 0;
- updateProgress(loadingProgressCounter);
-}
-
-void extractAssets()
-{
- if (!getenv("APPDIR"))
- {
- logger->log("error: APPDIR is not set!");
- return;
- }
- const std::string fileName = pathJoin(getenv("APPDIR"),
- "data.zip");
- logger->log("Extracting asset into: " + fileName);
- uint8_t *buf = new uint8_t[1000000];
-
- FILE *const file = fopen(fileName.c_str(), "w");
- for (int f = 0; f < 100; f ++)
- {
- std::string part = strprintf("manaplus-data.zip%u%u",
- CAST_U32(f / 10),
- CAST_U32(f % 10));
- logger->log("testing asset: " + part);
- SDL_RWops *const rw = SDL_RWFromFile(part.c_str(), "r");
- if (rw)
- {
- const int size = SDL_RWsize(rw);
- int size2 = SDL_RWread(rw, buf, 1, size);
- logger->log("asset size: %d", size2);
- fwrite(buf, 1, size2, file);
- SDL_RWclose(rw);
- Dirs::setProgress();
- }
- else
- {
- break;
- }
- }
- fclose(file);
-
- const std::string fileName2 = pathJoin(getenv("APPDIR"),
- "locale.zip");
- FILE *const file2 = fopen(fileName2.c_str(), "w");
- SDL_RWops *const rw = SDL_RWFromFile("manaplus-locale.zip", "r");
- if (rw)
- {
- const int size = SDL_RWsize(rw);
- int size2 = SDL_RWread(rw, buf, 1, size);
- fwrite(buf, 1, size2, file2);
- SDL_RWclose(rw);
- Dirs::setProgress();
- }
- fclose(file2);
-
- delete [] buf;
-}
-
-#endif // USE_SDL2
-#endif // ANDROID
-
-void Dirs::updateDataPath()
-{
- if (settings.options.dataPath.empty()
- && !branding.getStringValue("dataPath").empty())
- {
- if (isRealPath(branding.getStringValue("dataPath")))
- {
- settings.options.dataPath = branding.getStringValue("dataPath");
- }
- else
- {
- settings.options.dataPath = pathJoin(branding.getDirectory(),
- branding.getStringValue("dataPath"));
- }
- settings.options.skipUpdate = true;
- }
-}
-
-void Dirs::extractDataDir()
-{
-#if defined(ANDROID) && defined(USE_SDL2)
- Files::setCopyCallBack(&updateProgress);
- resetProgress();
- extractAssets();
-
- const std::string zipName = pathJoin(getenv("APPDIR"), "data.zip");
- const std::string dirName = pathJoin(getenv("APPDIR"), "data");
- VirtFs::mountZip2(zipName,
- "data",
- Append_false);
- VirtFs::mountZip2(zipName,
- "data/perserver/default",
- Append_false);
- Files::extractLocale();
-#endif // defined(ANDROID) && defined(USE_SDL2)
-}
-
-void Dirs::mountDataDir()
-{
- VirtFs::mountDirSilent(PKG_DATADIR "data/perserver/default",
- Append_false);
- VirtFs::mountDirSilent("data/perserver/default",
- Append_false);
-
-#if defined __APPLE__
- CFBundleRef mainBundle = CFBundleGetMainBundle();
- CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(mainBundle);
- char path[PATH_MAX];
- if (!CFURLGetFileSystemRepresentation(resourcesURL,
- TRUE,
- reinterpret_cast<uint8_t*>(path),
- PATH_MAX))
- {
- fprintf(stderr, "Can't find Resources directory\n");
- }
- CFRelease(resourcesURL);
- std::string path2 = pathJoin(path, "data");
- VirtFs::mountDir(pathJoin(path2, "perserver/default"), Append_false);
- VirtFs::mountDir(path2, Append_false);
-// possible this need for support run client from dmg images.
-// mPackageDir = path;
-#endif // defined __APPLE__
-
- VirtFs::mountDirSilent(PKG_DATADIR "data", Append_false);
- setPackageDir(PKG_DATADIR "data");
- VirtFs::mountDirSilent("data", Append_false);
-
-#ifdef ANDROID
-#ifdef USE_SDL2
- if (getenv("APPDIR"))
- {
- const std::string appDir = getenv("APPDIR");
- VirtFs::mountDir(appDir + "/data", Append_false);
- VirtFs::mountDir(appDir + "/data/perserver/default",
- Append_false);
- }
-#endif // USE_SDL2
-#endif // ANDROID
-
-#if defined __native_client__
- VirtFs::mountZip("/http/data.zip", Append_false);
- VirtFs::mountZip2("/http/data.zip",
- "perserver/default",
- Append_false);
-#endif // defined __native_client__
-
-#ifndef WIN32
- // Add branding/data to VirtFS search path
- if (!settings.options.brandingPath.empty())
- {
- std::string path = settings.options.brandingPath;
-
- // Strip blah.manaplus from the path
- const int loc = CAST_S32(path.find_last_of('/'));
-
- if (loc > 0)
- {
- VirtFs::mountDir(path.substr(
- 0, loc + 1).append("data"),
- Append_false);
- }
- }
-#endif // WIN32
-}
-
-void Dirs::initRootDir()
-{
- settings.rootDir = VirtFs::getBaseDir();
- const std::string portableName = settings.rootDir + "portable.xml";
- struct stat statbuf;
-
- if (stat(portableName.c_str(), &statbuf) == 0 &&
- S_ISREG(statbuf.st_mode))
- {
- std::string dir;
- Configuration portable;
- portable.init(portableName);
-
- if (settings.options.brandingPath.empty())
- {
- branding.init(portableName);
- setBrandingDefaults(branding);
- }
-
- logger->log("Portable file: %s", portableName.c_str());
-
- if (settings.options.localDataDir.empty())
- {
- dir = portable.getValue("dataDir", "");
- if (!dir.empty())
- {
- settings.options.localDataDir = settings.rootDir + dir;
- logger->log("Portable data dir: %s",
- settings.options.localDataDir.c_str());
- }
- }
-
- if (settings.options.configDir.empty())
- {
- dir = portable.getValue("configDir", "");
- if (!dir.empty())
- {
- settings.options.configDir = settings.rootDir + dir;
- logger->log("Portable config dir: %s",
- settings.options.configDir.c_str());
- }
- }
-
- if (settings.options.screenshotDir.empty())
- {
- dir = portable.getValue("screenshotDir", "");
- if (!dir.empty())
- {
- settings.options.screenshotDir = settings.rootDir + dir;
- logger->log("Portable screenshot dir: %s",
- settings.options.screenshotDir.c_str());
- }
- }
- }
-}
-
-/**
- * Initializes the home directory. On UNIX and FreeBSD, ~/.mana is used. On
- * Windows and other systems we use the current working directory.
- */
-void Dirs::initHomeDir()
-{
- initLocalDataDir();
- initTempDir();
- initConfigDir();
-}
-
-void Dirs::initLocalDataDir()
-{
- settings.localDataDir = settings.options.localDataDir;
-
- if (settings.localDataDir.empty())
- {
-#ifdef __APPLE__
- // Use Application Directory instead of .mana
- settings.localDataDir = pathJoin(VirtFs::getUserDir(),
- "Library/Application Support",
- branding.getValue("appName", "ManaPlus"));
-#elif defined __HAIKU__
- settings.localDataDir = pathJoin(VirtFs::getUserDir(),
- "config/data/Mana");
-#elif defined WIN32
- settings.localDataDir = getSpecialFolderLocation(CSIDL_LOCAL_APPDATA);
- if (settings.localDataDir.empty())
- settings.localDataDir = VirtFs::getUserDir();
- settings.localDataDir = pathJoin(settings.localDataDir,
- "Mana");
-#elif defined __ANDROID__
- settings.localDataDir = pathJoin(getSdStoragePath(),
- branding.getValue("appShort", "ManaPlus"),
- "local");
-#elif defined __native_client__
- settings.localDataDir = pathJoin(_nacl_dir, "local");
-#else // __APPLE__
-
- settings.localDataDir = pathJoin(VirtFs::getUserDir(),
- ".local/share/mana");
-#endif // __APPLE__
- }
-
- if (mkdir_r(settings.localDataDir.c_str()) != 0)
- {
- // TRANSLATORS: directory creation error
- logger->error(strprintf(_("%s doesn't exist and can't be created! "
- "Exiting."), settings.localDataDir.c_str()));
- }
-#ifdef USE_PROFILER
- Perfomance::init(pathJoin(settings.localDataDir, "profiler.log"));
-#endif // USE_PROFILER
-}
-
-void Dirs::initTempDir()
-{
- settings.tempDir = pathJoin(settings.localDataDir, "temp");
-
- if (mkdir_r(settings.tempDir.c_str()) != 0)
- {
- // TRANSLATORS: directory creation error
- logger->error(strprintf(_("%s doesn't exist and can't be created! "
- "Exiting."), settings.tempDir.c_str()));
- }
-// ResourceManager::deleteFilesInDirectory(settings.tempDir);
-}
-
-void Dirs::initConfigDir()
-{
- settings.configDir = settings.options.configDir;
-
- if (settings.configDir.empty())
- {
-#ifdef __APPLE__
- settings.configDir = pathJoin(settings.localDataDir,
- branding.getValue("appShort", "mana"));
-#elif defined __HAIKU__
- settings.configDir = pathJoin(VirtFs::getUserDir(),
- "config/settings/Mana",
- branding.getValue("appName", "ManaPlus"));
-#elif defined WIN32
- settings.configDir = getSpecialFolderLocation(CSIDL_APPDATA);
- if (settings.configDir.empty())
- {
- settings.configDir = settings.localDataDir;
- }
- else
- {
- settings.configDir = pathJoin(settings.configDir,
- "mana",
- branding.getValue("appShort", "mana"));
- }
-#elif defined __ANDROID__
- settings.configDir = pathJoin(getSdStoragePath(),
- branding.getValue("appShort", "ManaPlus"),
- "config");
-#elif defined __native_client__
- settings.configDir = pathJoin(_nacl_dir, "config");
-#else // __APPLE__
-
- settings.configDir = pathJoin(VirtFs::getUserDir(),
- ".config/mana",
- branding.getValue("appShort", "mana"));
-#endif // __APPLE__
-
- logger->log("Generating config dir: " + settings.configDir);
- }
-
- if (mkdir_r(settings.configDir.c_str()) != 0)
- {
- // TRANSLATORS: directory creation error
- logger->error(strprintf(_("%s doesn't exist and can't be created! "
- "Exiting."), settings.configDir.c_str()));
- }
-}
-
-/**
- * Parse the update host and determine the updates directory
- * Then verify that the directory exists (creating if needed).
- */
-void Dirs::initUpdatesDir()
-{
- std::stringstream updates;
-
- // If updatesHost is currently empty, fill it from config file
- if (settings.updateHost.empty())
- settings.updateHost = config.getStringValue("updatehost");
- if (!checkPath(settings.updateHost))
- return;
-
- // Don't go out of range int he next check
- if (settings.updateHost.length() < 2)
- {
- if (settings.updatesDir.empty())
- settings.updatesDir = pathJoin("updates", settings.serverName);
- return;
- }
-
- const size_t sz = settings.updateHost.size();
- // Remove any trailing slash at the end of the update host
- if (settings.updateHost.at(sz - 1) == '/')
- settings.updateHost.resize(sz - 1);
-
- // Parse out any "http://" or "https://", and set the updates directory
- const size_t pos = settings.updateHost.find("://");
- if (pos != std::string::npos)
- {
- if (pos + 3 < settings.updateHost.length()
- && !settings.updateHost.empty())
- {
- updates << "updates/" << settings.updateHost.substr(pos + 3);
- settings.updatesDir = updates.str();
- }
- else
- {
- logger->log("Error: Invalid update host: %s",
- settings.updateHost.c_str());
- // TRANSLATORS: update server initialisation error
- errorMessage = strprintf(_("Invalid update host: %s."),
- settings.updateHost.c_str());
- client->setState(State::ERROR);
- }
- }
- else
- {
- logger->log1("Warning: no protocol was specified for the update host");
- updates << "updates/" << settings.updateHost;
- settings.updatesDir = updates.str();
- }
-
-#ifdef WIN32
- if (settings.updatesDir.find(":") != std::string::npos)
- replaceAll(settings.updatesDir, ":", "_");
-#endif // WIN32
-
- const std::string updateDir("/" + settings.updatesDir);
-
- // Verify that the updates directory exists. Create if necessary.
- if (!VirtFs::isDirectory(updateDir))
- {
- if (!VirtFs::mkdir(updateDir))
- {
-#if defined WIN32
- std::string newDir = pathJoin(settings.localDataDir,
- settings.updatesDir);
- if (!CreateDirectory(newDir.c_str(), nullptr) &&
- GetLastError() != ERROR_ALREADY_EXISTS)
- {
- logger->log("Error: %s can't be made, but doesn't exist!",
- newDir.c_str());
- // TRANSLATORS: update server initialisation error
- errorMessage = _("Error creating updates directory!");
- client->setState(State::ERROR);
- }
-#else // defined WIN32
-
- logger->log("Error: %s/%s can't be made, but doesn't exist!",
- settings.localDataDir.c_str(),
- settings.updatesDir.c_str());
- // TRANSLATORS: update server initialisation error
- errorMessage = _("Error creating updates directory!");
- client->setState(State::ERROR);
-#endif // defined WIN32
- }
- }
- const std::string updateLocal = pathJoin(updateDir, "local");
- const std::string updateFix = pathJoin(updateDir, "fix");
- if (!VirtFs::isDirectory(updateLocal))
- VirtFs::mkdir(updateLocal);
- if (!VirtFs::isDirectory(updateFix))
- VirtFs::mkdir(updateFix);
-}
-
-void Dirs::initScreenshotDir()
-{
- if (!settings.options.screenshotDir.empty())
- {
- settings.screenshotDir = settings.options.screenshotDir;
- if (mkdir_r(settings.screenshotDir.c_str()) != 0)
- {
- logger->log(strprintf(
- // TRANSLATORS: directory creation error
- _("Error: %s doesn't exist and can't be created! "
- "Exiting."), settings.screenshotDir.c_str()));
- }
- }
- else if (settings.screenshotDir.empty())
- {
-#ifdef __native_client__
- settings.screenshotDir = pathJoin(_nacl_dir, "screenshots/");
-#else // __native_client__
- settings.screenshotDir = decodeBase64String(
- config.getStringValue("screenshotDirectory3"));
- if (settings.screenshotDir.empty())
- {
-#ifdef __ANDROID__
- settings.screenshotDir = getSdStoragePath()
- + std::string("/images");
-
- if (mkdir_r(settings.screenshotDir.c_str()))
- {
- logger->log(strprintf(
- // TRANSLATORS: directory creation error
- _("Error: %s doesn't exist and can't be created! "
- "Exiting."), settings.screenshotDir.c_str()));
- }
-#else // ANDROID
- settings.screenshotDir = getPicturesDir();
-#endif // ANDROID
- if (config.getBoolValue("useScreenshotDirectorySuffix"))
- {
- const std::string configScreenshotSuffix =
- branding.getValue("screenshots", "ManaPlus");
-
- if (!configScreenshotSuffix.empty())
- {
- settings.screenshotDir = pathJoin(settings.screenshotDir,
- configScreenshotSuffix);
- }
- }
- config.setValue("screenshotDirectory3",
- encodeBase64String(settings.screenshotDir));
- }
-#endif // __native_client__
- }
- logger->log("screenshotDirectory: " + settings.screenshotDir);
-}
-
-void Dirs::initUsersDir()
-{
- settings.usersDir = settings.serverConfigDir + "/users/";
- if (mkdir_r(settings.usersDir.c_str()) != 0)
- {
- // TRANSLATORS: directory creation error
- logger->error(strprintf(_("%s doesn't exist and can't be created!"),
- settings.usersDir.c_str()));
- }
-
- settings.npcsDir = settings.serverConfigDir + "/npcs/";
- if (mkdir_r(settings.npcsDir.c_str()) != 0)
- {
- // TRANSLATORS: directory creation error
- logger->error(strprintf(_("%s doesn't exist and can't be created!"),
- settings.npcsDir.c_str()));
- }
-
- settings.usersIdDir = settings.serverConfigDir + "/usersid/";
- if (mkdir_r(settings.usersIdDir.c_str()) != 0)
- {
- // TRANSLATORS: directory creation error
- logger->error(strprintf(_("%s doesn't exist and can't be created!"),
- settings.usersIdDir.c_str()));
- }
-}
diff --git a/src/dirs.h b/src/dirs.h
deleted file mode 100644
index aa43f34d0..000000000
--- a/src/dirs.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 DIRS_H
-#define DIRS_H
-
-#include "localconsts.h"
-
-class Dirs final
-{
- public:
- A_DELETE_COPY(Dirs)
-
- static void initUsersDir();
-
- static void updateDataPath();
-
-#if defined(ANDROID) && defined(USE_SDL2)
- static void extractDataDir();
-#else // defined(ANDROID) && defined(USE_SDL2)
-
- static void extractDataDir() A_CONST;
-#endif // defined(ANDROID) && defined(USE_SDL2)
-
- static void mountDataDir();
-
- static void initRootDir();
-
- static void initHomeDir();
-
- static void initLocalDataDir();
-
- static void initTempDir();
-
- static void initConfigDir();
-
- static void initUpdatesDir();
-
- static void initScreenshotDir();
-
-#ifdef ANDROID
-#ifdef USE_SDL2
- static void setProgress();
-#endif // USE_SDL2
-#endif // ANDROID
-};
-
-#endif // DIRS_H
diff --git a/src/dragdrop.h b/src/dragdrop.h
deleted file mode 100644
index 76d0c35ce..000000000
--- a/src/dragdrop.h
+++ /dev/null
@@ -1,266 +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 DRAGDROP_H
-#define DRAGDROP_H
-
-#include "resources/item/item.h"
-
-#include "itemsoundmanager.h"
-#include "textcommand.h"
-
-#include "enums/dragdropsource.h"
-
-#include "resources/image/image.h"
-
-#include "resources/skill/skilldata.h"
-#include "resources/skill/skillinfo.h"
-
-#include "localconsts.h"
-
-class DragDrop final
-{
- public:
- DragDrop(Item *const item,
- const DragDropSourceT source) :
- mItemImage(item != nullptr ? item->getImage() : nullptr),
- mText(),
- mItemData(),
- mSource(source),
- mItem(item != nullptr ? item->getId() : 0),
- mSelItem(0),
- mTag(-1),
- mItemColor(item != nullptr ? item->getColor() : ItemColor_one),
- mSelItemColor(ItemColor_one)
- {
- if (mItemImage != nullptr)
- mItemImage->incRef();
- }
-
- A_DELETE_COPY(DragDrop)
-
- ~DragDrop()
- {
- if (mItemImage != nullptr)
- mItemImage->decRef();
- }
-
- int getItem() const
- { return mItem; }
-
- ItemColor getItemColor() const
- { return mItemColor; }
-
- void setItemColor(const ItemColor color)
- { mItemColor = color; }
-
- Image *getItemImage()
- { return mItemImage; }
-
- void setItemData(const std::string &data)
- { mItemData = data; }
-
- std::string getItemData()
- { return mItemData; }
-
- DragDropSourceT getSource() const
- { return mSource; }
-
- void dragItem(const Item *const item,
- const DragDropSourceT source,
- const int tag = 0)
- {
- if (mItemImage != nullptr)
- mItemImage->decRef();
-
- mItemData.clear();
- mText.clear();
- if (item != nullptr)
- {
- mItem = item->getId();
- mItemColor = item->getColor();
- mItemImage = item->getImage();
- if (mItemImage != nullptr)
- mItemImage->incRef();
- mSource = source;
- mTag = tag;
- ItemSoundManager::playSfx(item, ItemSoundEvent::TAKE);
- }
- else
- {
- mItem = 0;
- mItemColor = ItemColor_one;
- mItemImage = nullptr;
- mSource = DragDropSource::Empty;
- mTag = -1;
- }
- }
-
- void dragCommand(const TextCommand *const command,
- const DragDropSourceT source,
- const int tag = 0)
- {
- if (mItemImage != nullptr)
- mItemImage->decRef();
- mItem = 0;
- mItemColor = ItemColor_one;
- mItemData.clear();
-
- if (command != nullptr)
- {
- mText = command->getSymbol();
- mItemImage = command->getImage();
- if (mItemImage != nullptr)
- {
- mItemImage->incRef();
- }
- else if (mText.empty())
- {
- mSource = source;
- mTag = -1;
- return;
- }
- mItem = command->getId();
- }
- else
- {
- mText.clear();
- mItemImage = nullptr;
- }
- mSource = source;
- mTag = tag;
- }
-
- void dragSkill(const SkillInfo *const info,
- const DragDropSourceT source,
- const int tag = 0)
- {
- if (mItemImage != nullptr)
- mItemImage->decRef();
- mItem = 0;
- mItemColor = ItemColor_zero;
- mText.clear();
- mItemImage = nullptr;
- mSource = DragDropSource::Empty;
- mTag = -1;
- mItemData.clear();
- if (info != nullptr)
- {
- const SkillData *const data = info->data;
- if (data != nullptr)
- {
- mText = data->name;
- mItemImage = data->icon;
- if (mItemImage != nullptr)
- mItemImage->incRef();
- mSource = source;
- mTag = tag;
- }
- mItem = info->id;
- mItemColor = fromInt(info->customSelectedLevel,
- ItemColor);
- }
- }
-
- void clear()
- {
- if (mItemImage != nullptr)
- mItemImage->decRef();
- mItem = 0;
- mItemColor = ItemColor_one;
- mItemImage = nullptr;
- mSource = DragDropSource::Empty;
- mText.clear();
- mItemData.clear();
- mTag = -1;
- }
-
- bool isEmpty() const
- { return mSource == DragDropSource::Empty; }
-
- void select(const Item *const item)
- {
- if (item != nullptr)
- {
- mSelItem = item->getId();
- mSelItemColor = item->getColor();
- }
- else
- {
- mSelItem = 0;
- mSelItemColor = ItemColor_one;
- }
- }
-
- void deselect()
- {
- mSelItem = 0;
- mSelItemColor = ItemColor_one;
- }
-
- int getSelected() const
- { return mSelItem; }
-
- ItemColor getSelectedColor() const
- { return mSelItemColor; }
-
- bool isSelected() const
- { return mSelItem > 0; }
-
- void clearItem(const Item *const item A_UNUSED)
- {
- }
-
- const std::string &getText() const
- { return mText; }
-
- int getTag() const
- { return mTag; }
-
- void setItem(const int item)
- { mItem = item; }
-
- bool isSourceItemContainer() const
- {
- return mSource == DragDropSource::Inventory
- || mSource == DragDropSource::Storage
- || mSource == DragDropSource::Cart
- || mSource == DragDropSource::Craft
- || mSource == DragDropSource::Trade
- || mSource == DragDropSource::Outfit
- || mSource == DragDropSource::Ground
- || mSource == DragDropSource::Drop;
- }
-
- private:
- Image *mItemImage;
- std::string mText;
- std::string mItemData;
- DragDropSourceT mSource;
- int mItem;
- int mSelItem;
- int mTag;
- ItemColor mItemColor;
- ItemColor mSelItemColor;
-};
-
-extern DragDrop dragDrop;
-
-#endif // DRAGDROP_H
diff --git a/src/effectmanager.cpp b/src/effectmanager.cpp
deleted file mode 100644
index 79886293f..000000000
--- a/src/effectmanager.cpp
+++ /dev/null
@@ -1,270 +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/>.
- */
-
-#include "effectmanager.h"
-
-#include "configuration.h"
-#include "soundmanager.h"
-
-#include "being/being.h"
-
-#include "utils/checkutils.h"
-
-#include "particle/particle.h"
-
-#include "resources/beingcommon.h"
-
-#include "debug.h"
-
-EffectManager *effectManager = nullptr;
-
-EffectManager::EffectManager() :
- mEffects(),
- mTimers()
-{
- logger->log1("Effects are now loading");
- loadXmlFile(paths.getStringValue("effectsFile"), SkipError_false);
- loadXmlFile(paths.getStringValue("effectsPatchFile"), SkipError_true);
- loadXmlDir("effectsPatchDir", loadXmlFile);
-}
-
-void EffectManager::loadXmlFile(const std::string &fileName,
- const SkipError skipError)
-{
- XML::Document doc(fileName, UseVirtFs_true, skipError);
- XmlNodeConstPtrConst root = doc.rootNode();
-
- if ((root == nullptr) ||
- !xmlNameEqual(root, "being-effects"))
- {
- logger->log("Error loading being effects file: " + fileName);
- 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, "effect"))
- {
- mEffects.push_back(EffectDescription(
- XML::getProperty(node, "id", -1),
- XML::getProperty(node, "particle", ""),
- XML::getProperty(node, "audio", ""),
- XML::getProperty(node, "sprite", "")));
- }
- }
-}
-
-EffectManager::~EffectManager()
-{
-}
-
-bool EffectManager::triggerDirection(const int id,
- Being *const being,
- const SpriteDirection::Type &direction)
-{
- int rotation;
- switch (direction)
- {
- case SpriteDirection::DOWN:
- case SpriteDirection::DOWNRIGHT:
- case SpriteDirection::DOWNLEFT:
- case SpriteDirection::DEFAULT:
- case SpriteDirection::INVALID:
- default:
- rotation = 0;
- break;
- case SpriteDirection::LEFT:
- rotation = 90;
- break;
- case SpriteDirection::UP:
- case SpriteDirection::UPRIGHT:
- case SpriteDirection::UPLEFT:
- rotation = 180;
- break;
- case SpriteDirection::RIGHT:
- rotation = 270;
- break;
- }
-
- return trigger(id, being, rotation);
-}
-
-bool EffectManager::trigger(const int id,
- Being *const being,
- const int rotation)
-{
- if ((being == nullptr) || (particleEngine == nullptr) || id == -1)
- return false;
-
- BLOCK_START("EffectManager::trigger")
- bool rValue = false;
- FOR_EACH (STD_VECTOR<EffectDescription>::const_iterator, i, mEffects)
- {
- const EffectDescription &effect = *i;
- if (effect.id == id)
- {
- rValue = true;
- if (!effect.gfx.empty())
- {
- Particle *const selfFX = particleEngine->addEffect(
- effect.gfx, 0, 0, rotation);
- being->controlAutoParticle(selfFX);
- }
- if (!effect.sfx.empty())
- soundManager.playSfx(effect.sfx);
- if (!effect.sprite.empty())
- being->addEffect(effect.sprite);
- return rValue;
- }
- }
- reportAlways("Missing effect %d", id);
- BLOCK_END("EffectManager::trigger")
- return rValue;
-}
-
-Particle *EffectManager::triggerReturn(const int id,
- Being *const being,
- const int rotation)
-{
- if ((being == nullptr) || (particleEngine == nullptr) || id == -1)
- return nullptr;
-
- Particle *rValue = nullptr;
- FOR_EACH (STD_VECTOR<EffectDescription>::const_iterator, i, mEffects)
- {
- const EffectDescription &effect = *i;
- if (effect.id == id)
- {
- if (!effect.gfx.empty())
- {
- rValue = particleEngine->addEffect(
- effect.gfx, 0, 0, rotation);
- being->controlCustomParticle(rValue);
- }
- if (!effect.sfx.empty())
- soundManager.playSfx(effect.sfx);
- if (!effect.sprite.empty())
- being->addEffect(effect.sprite);
- return rValue;
- }
- }
- reportAlways("Missing effect %d", id);
- return rValue;
-}
-
-bool EffectManager::trigger(const int id,
- const int x, const int y,
- const time_t endTime,
- const int rotation)
-{
- if ((particleEngine == nullptr) || id == -1)
- return false;
-
- bool rValue = false;
- FOR_EACH (STD_VECTOR<EffectDescription>::const_iterator, i, mEffects)
- {
- const EffectDescription &effect = *i;
- if (effect.id == id)
- {
- rValue = true;
- if (!effect.gfx.empty())
- {
- Particle *const particle = particleEngine->addEffect(
- effect.gfx,
- x, y,
- rotation);
- if (particle != nullptr)
- mTimers.push_back(ParticleTimer(particle, endTime));
- }
- if (!effect.sfx.empty())
- soundManager.playSfx(effect.sfx);
- return rValue;
- }
- }
- reportAlways("Missing effect %d", id);
- return rValue;
-}
-
-void EffectManager::triggerDefault(int effectId,
- Being *const being,
- const int defaultEffectId)
-{
- if (effectId == -1)
- effectId = defaultEffectId;
- if (effectId == -1)
- return;
- trigger(effectId, being);
-}
-
-void EffectManager::triggerDefault(int effectId,
- const int x,
- const int y,
- const time_t endTime,
- const int defaultEffectId)
-{
- if (effectId == -1)
- effectId = defaultEffectId;
- if (effectId == -1)
- return;
- trigger(effectId, x, y, endTime);
-}
-
-void EffectManager::logic()
-{
- const time_t time = cur_time;
- bool found(true);
- while (found)
- {
- found = false;
- FOR_EACH (std::list<ParticleTimer>::iterator, it, mTimers)
- {
- const ParticleTimer &timer = *it;
- if (timer.endTime < time)
- {
- found = true;
- Particle *const particle = timer.particle;
- if (particle != nullptr)
- particle->kill();
- mTimers.erase(it);
- break;
- }
- }
- }
-}
-
-void EffectManager::clear()
-{
- FOR_EACH (std::list<ParticleTimer>::iterator, it, mTimers)
- {
- Particle *const particle = (*it).particle;
- if (particle != nullptr)
- particle->kill();
- }
- mTimers.clear();
-}
diff --git a/src/effectmanager.h b/src/effectmanager.h
deleted file mode 100644
index 5882e6933..000000000
--- a/src/effectmanager.h
+++ /dev/null
@@ -1,101 +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 EFFECTMANAGER_H
-#define EFFECTMANAGER_H
-
-#include "enums/resources/spritedirection.h"
-
-#include "enums/simpletypes/skiperror.h"
-
-#include "utils/vector.h"
-
-#include "particle/particletimer.h"
-
-#include "resources/effectdescription.h"
-
-#include <list>
-
-#include "localconsts.h"
-
-class Being;
-class Particle;
-
-class EffectManager final
-{
- public:
- EffectManager();
-
- A_DELETE_COPY(EffectManager)
-
- ~EffectManager();
-
- void loadXmlFile(const std::string &fileName,
- const SkipError skipError);
-
- /**
- * Triggers a effect with the id, at
- * the specified being.
- */
- bool trigger(const int id,
- Being *const being,
- const int rotation = 0);
-
- bool triggerDirection(const int id,
- Being *const being,
- const SpriteDirection::Type &direction);
-
- Particle *triggerReturn(const int id,
- Being *const being,
- const int rotation = 0);
-
- /**
- * Triggers a effect with the id, at
- * the specified x and y coordinate.
- */
- bool trigger(const int id,
- const int x, const int y,
- const time_t endTime,
- const int rotation = 0);
-
- void triggerDefault(int effectId,
- Being *const being,
- const int defaultEffectId);
-
- void triggerDefault(int effectId,
- const int x,
- const int y,
- const time_t endTime,
- const int defaultEffectId);
-
- void logic();
-
- void clear();
-
- private:
- STD_VECTOR<EffectDescription> mEffects;
- std::list<ParticleTimer> mTimers;
-};
-
-extern EffectManager *effectManager;
-
-#endif // EFFECTMANAGER_H
diff --git a/src/enums/being/actortype.h b/src/enums/being/actortype.h
deleted file mode 100644
index f820902be..000000000
--- a/src/enums/being/actortype.h
+++ /dev/null
@@ -1,44 +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 ENUMS_BEING_ACTORTYPE_H
-#define ENUMS_BEING_ACTORTYPE_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(ActorType)
-{
- Unknown = 0,
- Player,
- Npc,
- Monster,
- FloorItem,
- Portal,
- Avatar,
- Pet,
- Mercenary,
- Homunculus,
- SkillUnit,
- Elemental
-}
-enumEnd(ActorType);
-
-#endif // ENUMS_BEING_ACTORTYPE_H
diff --git a/src/enums/being/attacktype.h b/src/enums/being/attacktype.h
deleted file mode 100644
index ad07f531a..000000000
--- a/src/enums/being/attacktype.h
+++ /dev/null
@@ -1,48 +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 ENUMS_BEING_ATTACKTYPE_H
-#define ENUMS_BEING_ATTACKTYPE_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(AttackType)
-{
- HIT = 0,
- PICKUP = 1,
- SIT = 2,
- STAND = 3,
- REFLECT = 4,
- SPLASH = 5,
- SKILL = 6,
- REPEATE = 7,
- MULTI = 8,
- MULTI_REFLECT = 9,
- CRITICAL = 10,
- FLEE = 11,
- TOUCH_SKILL = 12,
- MISS = 0xffff, // pseudo value for miss attacks
- SKILLMISS // pseudo value for skill miss attacks
-}
-enumEnd(AttackType);
-
-#endif // ENUMS_BEING_ATTACKTYPE_H
diff --git a/src/enums/being/attributes.h b/src/enums/being/attributes.h
deleted file mode 100644
index bb9432137..000000000
--- a/src/enums/being/attributes.h
+++ /dev/null
@@ -1,119 +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 ENUMS_BEING_ATTRIBUTES_H
-#define ENUMS_BEING_ATTRIBUTES_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(Attributes)
-{
- // player attributes
- PLAYER_BASE_LEVEL = 0,
- PLAYER_HP,
- PLAYER_MAX_HP,
- PLAYER_MP,
- PLAYER_MAX_MP,
- PLAYER_EXP,
- PLAYER_EXP_NEEDED,
- MONEY,
- TOTAL_WEIGHT,
- MAX_WEIGHT,
- PLAYER_JOB_LEVEL = 10,
- PLAYER_STR = 13,
- PLAYER_AGI = 14,
- PLAYER_VIT = 15,
- PLAYER_INT = 16,
- PLAYER_DEX = 17,
- PLAYER_LUK = 18,
- PLAYER_SKILL_POINTS,
- PLAYER_CHAR_POINTS,
- PLAYER_CORR_POINTS,
- PLAYER_ATTACK_DELAY = 100,
- PLAYER_ATTACK_RANGE = 101,
- PLAYER_WALK_SPEED = 102,
- PLAYER_ATTACK_SPEED = 103,
- PLAYER_KARMA,
- PLAYER_MANNER,
- PLAYER_CRIT,
- PLAYER_FLEE,
- PLAYER_HIT,
- PLAYER_MDEF,
- PLAYER_MATK,
- PLAYER_DEF,
- PLAYER_ATK,
- CART_TOTAL_WEIGHT = 1000,
- CART_MAX_WEIGHT,
- PLAYER_JOB_EXP,
- PLAYER_JOB_EXP_NEEDED,
-
- // homunculus attributes
- HOMUN_LEVEL,
- HOMUN_HP,
- HOMUN_MAX_HP,
- HOMUN_MP,
- HOMUN_MAX_MP,
- HOMUN_EXP,
- HOMUN_EXP_NEEDED,
- HOMUN_SKILL_POINTS,
- HOMUN_ATTACK_DELAY,
- HOMUN_ATTACK_RANGE,
- HOMUN_ATTACK_SPEED,
- HOMUN_CRIT,
- HOMUN_FLEE,
- HOMUN_HIT,
- HOMUN_MDEF,
- HOMUN_MATK,
- HOMUN_DEF,
- HOMUN_ATK,
-
- // mercenary attributes
- MERC_LEVEL,
- MERC_HP,
- MERC_MAX_HP,
- MERC_MP,
- MERC_MAX_MP,
- MERC_ATTACK_DELAY,
- MERC_ATTACK_RANGE,
- MERC_ATTACK_SPEED,
- MERC_CRIT,
- MERC_FLEE,
- MERC_HIT,
- MERC_MDEF,
- MERC_MATK,
- MERC_DEF,
- MERC_ATK,
- MERC_EXPIRE,
- MERC_FAITH,
- MERC_CALLS,
- MERC_KILLS,
-
- // elemental attributes
- ELEMENTAL_HP,
- ELEMENTAL_MAX_HP,
- ELEMENTAL_MP,
- ELEMENTAL_MAX_MP,
-
- MAX_ATTRIBUTE
-}
-enumEnd(Attributes);
-
-#endif // ENUMS_BEING_ATTRIBUTES_H
diff --git a/src/enums/being/attributesstrings.cpp b/src/enums/being/attributesstrings.cpp
deleted file mode 100644
index b9cd6659a..000000000
--- a/src/enums/being/attributesstrings.cpp
+++ /dev/null
@@ -1,119 +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 "enums/being/attributesstrings.h"
-
-#include "enums/simpletypes/stringdefines.h"
-
-#include <map>
-
-#include "debug.h"
-
-namespace AttributesEnum
-{
- stringEnumStart(AttributesT)
- // player attributes
- strEnumDef2(Attributes, PLAYER_BASE_LEVEL, "PLAYER_LEVEL")
- strEnumDef(Attributes, PLAYER_HP)
- strEnumDef(Attributes, PLAYER_MAX_HP)
- strEnumDef(Attributes, PLAYER_MP)
- strEnumDef(Attributes, PLAYER_MAX_MP)
- strEnumDef(Attributes, PLAYER_EXP)
- strEnumDef(Attributes, PLAYER_EXP_NEEDED)
- strEnumDef(Attributes, MONEY)
- strEnumDef(Attributes, TOTAL_WEIGHT)
- strEnumDef(Attributes, MAX_WEIGHT)
- strEnumDef2(Attributes, PLAYER_JOB_LEVEL, "PLAYER_JOB")
- strEnumDef(Attributes, PLAYER_JOB_EXP)
- strEnumDef(Attributes, PLAYER_JOB_EXP_NEEDED)
- strEnumDef(Attributes, PLAYER_STR)
- strEnumDef(Attributes, PLAYER_AGI)
- strEnumDef(Attributes, PLAYER_VIT)
- strEnumDef(Attributes, PLAYER_INT)
- strEnumDef(Attributes, PLAYER_DEX)
- strEnumDef(Attributes, PLAYER_LUK)
- strEnumDef(Attributes, PLAYER_SKILL_POINTS)
- strEnumDef(Attributes, PLAYER_CHAR_POINTS)
- strEnumDef(Attributes, PLAYER_CORR_POINTS)
- strEnumDef(Attributes, PLAYER_ATTACK_DELAY)
- strEnumDef(Attributes, PLAYER_ATTACK_RANGE)
- strEnumDef(Attributes, PLAYER_WALK_SPEED)
- strEnumDef(Attributes, PLAYER_ATTACK_SPEED)
- strEnumDef(Attributes, PLAYER_KARMA)
- strEnumDef(Attributes, PLAYER_MANNER)
- strEnumDef(Attributes, PLAYER_CRIT)
- strEnumDef(Attributes, PLAYER_FLEE)
- strEnumDef(Attributes, PLAYER_HIT)
- strEnumDef(Attributes, PLAYER_MDEF)
- strEnumDef(Attributes, PLAYER_MATK)
- strEnumDef(Attributes, PLAYER_DEF)
- strEnumDef(Attributes, PLAYER_ATK)
- strEnumDef(Attributes, CART_TOTAL_WEIGHT)
- strEnumDef(Attributes, CART_MAX_WEIGHT)
-
- // homunculus attributes
- strEnumDef(Attributes, HOMUN_LEVEL)
- strEnumDef(Attributes, HOMUN_HP)
- strEnumDef(Attributes, HOMUN_MAX_HP)
- strEnumDef(Attributes, HOMUN_MP)
- strEnumDef(Attributes, HOMUN_MAX_MP)
- strEnumDef(Attributes, HOMUN_EXP)
- strEnumDef(Attributes, HOMUN_EXP_NEEDED)
- strEnumDef(Attributes, HOMUN_SKILL_POINTS)
- strEnumDef(Attributes, HOMUN_ATTACK_DELAY)
- strEnumDef(Attributes, HOMUN_ATTACK_RANGE)
- strEnumDef(Attributes, HOMUN_ATTACK_SPEED)
- strEnumDef(Attributes, HOMUN_CRIT)
- strEnumDef(Attributes, HOMUN_FLEE)
- strEnumDef(Attributes, HOMUN_HIT)
- strEnumDef(Attributes, HOMUN_MDEF)
- strEnumDef(Attributes, HOMUN_MATK)
- strEnumDef(Attributes, HOMUN_DEF)
- strEnumDef(Attributes, HOMUN_ATK)
-
- // mercenary attributes
- strEnumDef(Attributes, MERC_LEVEL)
- strEnumDef(Attributes, MERC_HP)
- strEnumDef(Attributes, MERC_MAX_HP)
- strEnumDef(Attributes, MERC_MP)
- strEnumDef(Attributes, MERC_MAX_MP)
- strEnumDef(Attributes, MERC_ATTACK_DELAY)
- strEnumDef(Attributes, MERC_ATTACK_RANGE)
- strEnumDef(Attributes, MERC_ATTACK_SPEED)
- strEnumDef(Attributes, MERC_CRIT)
- strEnumDef(Attributes, MERC_FLEE)
- strEnumDef(Attributes, MERC_HIT)
- strEnumDef(Attributes, MERC_MDEF)
- strEnumDef(Attributes, MERC_MATK)
- strEnumDef(Attributes, MERC_DEF)
- strEnumDef(Attributes, MERC_ATK)
- strEnumDef(Attributes, MERC_EXPIRE)
- strEnumDef(Attributes, MERC_FAITH)
- strEnumDef(Attributes, MERC_CALLS)
- strEnumDef(Attributes, MERC_KILLS)
-
- // elemental attributes
- strEnumDef(Attributes, ELEMENTAL_HP)
- strEnumDef(Attributes, ELEMENTAL_MAX_HP)
- strEnumDef(Attributes, ELEMENTAL_MP)
- strEnumDef(Attributes, ELEMENTAL_MAX_MP)
- stringEnumEnd
-} // namespace AttributesEnum
diff --git a/src/enums/being/attributesstrings.h b/src/enums/being/attributesstrings.h
deleted file mode 100644
index 501e76dcf..000000000
--- a/src/enums/being/attributesstrings.h
+++ /dev/null
@@ -1,36 +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 ENUMS_BEING_ATTRIBUTESSTRINGS_H
-#define ENUMS_BEING_ATTRIBUTESSTRINGS_H
-
-#include "enums/being/attributes.h"
-
-#include "enums/simpletypes/stringdefines2.h"
-
-#include <string>
-
-namespace AttributesEnum
-{
- stringEnumDef(AttributesT)
-} // namespace AttributesEnum
-
-#endif // ENUMS_BEING_ATTRIBUTESSTRINGS_H
diff --git a/src/enums/being/badgedrawtype.h b/src/enums/being/badgedrawtype.h
deleted file mode 100644
index 50804c20c..000000000
--- a/src/enums/being/badgedrawtype.h
+++ /dev/null
@@ -1,35 +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 ENUMS_BEING_BADGEDRAWTYPE_H
-#define ENUMS_BEING_BADGEDRAWTYPE_H
-
-namespace BadgeDrawType
-{
- enum Type
- {
- Hide = 0,
- Top = 1,
- Right = 2,
- Bottom = 3
- };
-} // namespace BadgeDrawType
-
-#endif // ENUMS_BEING_BADGEDRAWTYPE_H
diff --git a/src/enums/being/badgeindex.h b/src/enums/being/badgeindex.h
deleted file mode 100644
index 2b70382f5..000000000
--- a/src/enums/being/badgeindex.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 ENUMS_BEING_BADGEINDEX_H
-#define ENUMS_BEING_BADGEINDEX_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enum2Start(BadgeIndex)
-{
- Lang = 0,
- Away = 1,
- Inactive = 2,
- Team = 3,
- Shop = 4,
- Gm = 5,
- Guild = 6,
- Party = 7,
- Name = 8,
-
- BadgeIndexSize
-}
-enum2End(BadgeIndex);
-
-#endif // ENUMS_BEING_BADGEINDEX_H
diff --git a/src/enums/being/beingaction.h b/src/enums/being/beingaction.h
deleted file mode 100644
index 3703db1a2..000000000
--- a/src/enums/being/beingaction.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 ENUMS_BEING_BEINGACTION_H
-#define ENUMS_BEING_BEINGACTION_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(BeingAction)
-{
- STAND = 0,
- MOVE = 1,
- ATTACK = 2,
- CAST = 3,
- SIT = 4,
- DEAD = 5,
- HURT = 6,
- SPAWN = 7,
- PRESTAND
-}
-enumEnd(BeingAction);
-
-#endif // ENUMS_BEING_BEINGACTION_H
diff --git a/src/enums/being/beingdirection.h b/src/enums/being/beingdirection.h
deleted file mode 100644
index 7f9311ec8..000000000
--- a/src/enums/being/beingdirection.h
+++ /dev/null
@@ -1,40 +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 ENUMS_BEING_BEINGDIRECTION_H
-#define ENUMS_BEING_BEINGDIRECTION_H
-
-namespace BeingDirection
-{
- /**
- * Directions, to be used as bitmask values
- */
- enum Type
- {
- DOWN = 1,
- LEFT = 2,
- UP = 4,
- RIGHT = 8
- };
-} // namespace BeingDirection
-
-#endif // ENUMS_BEING_BEINGDIRECTION_H
diff --git a/src/enums/being/cookingtype.h b/src/enums/being/cookingtype.h
deleted file mode 100644
index 376187365..000000000
--- a/src/enums/being/cookingtype.h
+++ /dev/null
@@ -1,37 +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 ENUMS_BEING_COOKINGTYPE_H
-#define ENUMS_BEING_COOKINGTYPE_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(CookingType)
-{
- Cooking = 1,
- Arrow = 2,
- Elemental = 3,
- MixCooking = 4,
- MakeBomb = 5,
- Pharmacy = 6
-}
-enumEnd(CookingType);
-
-#endif // ENUMS_BEING_COOKINGTYPE_H
diff --git a/src/enums/being/gender.h b/src/enums/being/gender.h
deleted file mode 100644
index be1ad09f7..000000000
--- a/src/enums/being/gender.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 ENUMS_BEING_GENDER_H
-#define ENUMS_BEING_GENDER_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(Gender)
-{
- MALE = 0,
- FEMALE = 1,
- UNSPECIFIED = 2,
- OTHER = 3
-}
-enumEnd(Gender);
-
-#endif // ENUMS_BEING_GENDER_H
diff --git a/src/enums/being/pickup.h b/src/enums/being/pickup.h
deleted file mode 100644
index 96030161d..000000000
--- a/src/enums/being/pickup.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 ENUMS_BEING_PICKUP_H
-#define ENUMS_BEING_PICKUP_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-#include "localconsts.h"
-
-enumStart(Pickup)
-{
- OKAY = 0,
- UNKNOWN,
- BAD_ITEM,
- TOO_HEAVY,
- TOO_FAR,
- INV_FULL,
- STACK_FULL,
- DROP_STEAL,
- MAX_AMOUNT,
- STACK_AMOUNT
-}
-enumEnd(Pickup);
-
-#endif // ENUMS_BEING_PICKUP_H
diff --git a/src/enums/being/rank.h b/src/enums/being/rank.h
deleted file mode 100644
index 05edf3053..000000000
--- a/src/enums/being/rank.h
+++ /dev/null
@@ -1,35 +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 ENUMS_BEING_RANK_H
-#define ENUMS_BEING_RANK_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(Rank)
-{
- Blacksmith = 0,
- Alchemist = 1,
- Taekwon = 2,
- Pk = 3
-}
-enumEnd(Rank);
-
-#endif // ENUMS_BEING_RANK_H
diff --git a/src/enums/being/reachable.h b/src/enums/being/reachable.h
deleted file mode 100644
index 4176ca555..000000000
--- a/src/enums/being/reachable.h
+++ /dev/null
@@ -1,36 +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 ENUMS_BEING_REACHABLE_H
-#define ENUMS_BEING_REACHABLE_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(Reachable)
-{
- REACH_UNKNOWN = 0,
- REACH_YES = 1,
- REACH_NO = 2
-}
-enumEnd(Reachable);
-
-#endif // ENUMS_BEING_REACHABLE_H
diff --git a/src/enums/being/relation.h b/src/enums/being/relation.h
deleted file mode 100644
index 547ed930c..000000000
--- a/src/enums/being/relation.h
+++ /dev/null
@@ -1,40 +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 ENUMS_BEING_RELATION_H
-#define ENUMS_BEING_RELATION_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(Relation)
-{
- NEUTRAL = 0,
- FRIEND = 1,
- DISREGARDED = 2,
- IGNORED = 3,
- ERASED = 4,
- BLACKLISTED = 5,
- ENEMY2 = 6
-}
-enumEnd(Relation);
-
-#endif // ENUMS_BEING_RELATION_H
diff --git a/src/enums/being/targetcursorsize.h b/src/enums/being/targetcursorsize.h
deleted file mode 100644
index 81f8f5936..000000000
--- a/src/enums/being/targetcursorsize.h
+++ /dev/null
@@ -1,36 +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 ENUMS_BEING_TARGETCURSORSIZE_H
-#define ENUMS_BEING_TARGETCURSORSIZE_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(TargetCursorSize)
-{
- SMALL = 0,
- MEDIUM,
- LARGE,
- NUM_TC
-}
-enumEnd(TargetCursorSize);
-
-#endif // ENUMS_BEING_TARGETCURSORSIZE_H
diff --git a/src/enums/being/targetcursortype.h b/src/enums/being/targetcursortype.h
deleted file mode 100644
index 3bec32307..000000000
--- a/src/enums/being/targetcursortype.h
+++ /dev/null
@@ -1,36 +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 ENUMS_BEING_TARGETCURSORTYPE_H
-#define ENUMS_BEING_TARGETCURSORTYPE_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(TargetCursorType)
-{
- NONE = -1,
- NORMAL = 0,
- IN_RANGE,
- NUM_TCT
-}
-enumEnd(TargetCursorType);
-
-#endif // ENUMS_BEING_TARGETCURSORTYPE_H
diff --git a/src/enums/being/visiblename.h b/src/enums/being/visiblename.h
deleted file mode 100644
index ec7ec3271..000000000
--- a/src/enums/being/visiblename.h
+++ /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/>.
- */
-
-#ifndef ENUMS_BEING_VISIBLENAME_H
-#define ENUMS_BEING_VISIBLENAME_H
-
-namespace VisibleName
-{
- enum Type
- {
- Hide = 0,
- Show = 1,
- ShowOnSelection = 2
- };
-} // namespace VisibleName
-
-#endif // ENUMS_BEING_VISIBLENAME_H
diff --git a/src/enums/being/visiblenamepos.h b/src/enums/being/visiblenamepos.h
deleted file mode 100644
index 884c4eebe..000000000
--- a/src/enums/being/visiblenamepos.h
+++ /dev/null
@@ -1,33 +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 ENUMS_BEING_VISIBLENAMEPOS_H
-#define ENUMS_BEING_VISIBLENAMEPOS_H
-
-namespace VisibleNamePos
-{
- enum Type
- {
- Top = 0,
- Bottom = 1
- };
-} // namespace VisibleNamePos
-
-#endif // ENUMS_BEING_VISIBLENAMEPOS_H
diff --git a/src/enums/commandtarget.h b/src/enums/commandtarget.h
deleted file mode 100644
index bf0fb5c45..000000000
--- a/src/enums/commandtarget.h
+++ /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/>.
- */
-
-#ifndef ENUMS_COMMANDTARGET_H
-#define ENUMS_COMMANDTARGET_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(CommandTarget)
-{
- NoTarget = 0,
- AllowTarget = 1,
- NeedTarget = 2
-}
-enumEnd(CommandTarget);
-
-#endif // ENUMS_COMMANDTARGET_H
diff --git a/src/enums/cutin.h b/src/enums/cutin.h
deleted file mode 100644
index 6cd5d3ce9..000000000
--- a/src/enums/cutin.h
+++ /dev/null
@@ -1,36 +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 ENUMS_CUTIN_H
-#define ENUMS_CUTIN_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(CutIn)
-{
- BottomLeft = 0,
- BottomCenter = 1,
- BottomRight = 2,
- Movable = 3,
- MovableClose = 4
-}
-enumEnd(CutIn);
-
-#endif // ENUMS_CUTIN_H
diff --git a/src/enums/dragdropsource.h b/src/enums/dragdropsource.h
deleted file mode 100644
index 98c4cef7e..000000000
--- a/src/enums/dragdropsource.h
+++ /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/>.
- */
-
-#ifndef ENUMS_DRAGDROPSOURCE_H
-#define ENUMS_DRAGDROPSOURCE_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(DragDropSource)
-{
- Empty = 0,
- Inventory,
- Storage,
- Trade,
- Outfit,
- Spells,
- Skills,
- Ground,
- Drop,
- Shortcuts,
- Npc,
- Equipment,
- Cart,
- MailEdit,
- MailView,
- Craft,
- ShopBuy,
- ShopSell
-}
-enumEnd(DragDropSource);
-
-#endif // ENUMS_DRAGDROPSOURCE_H
diff --git a/src/enums/emotetype.h b/src/enums/emotetype.h
deleted file mode 100644
index 6ea47a35e..000000000
--- a/src/enums/emotetype.h
+++ /dev/null
@@ -1,35 +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 ENUMS_EMOTETYPE_H
-#define ENUMS_EMOTETYPE_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(EmoteType)
-{
- Player = 0,
- Homunculus,
- Mercenary,
- Pet
-}
-enumEnd(EmoteType);
-
-#endif // ENUMS_EMOTETYPE_H
diff --git a/src/enums/equipslot.h b/src/enums/equipslot.h
deleted file mode 100644
index 077e0e470..000000000
--- a/src/enums/equipslot.h
+++ /dev/null
@@ -1,58 +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 ENUMS_EQUIPSLOT_H
-#define ENUMS_EQUIPSLOT_H
-
-#include "localconsts.h"
-
-namespace EquipSlot
-{
- enum Type
- {
- TORSO_SLOT = 0,
- GLOVES_SLOT = 1,
- HEAD_SLOT = 2,
- LEGS_SLOT = 3,
- FEET_SLOT = 4,
- RING1_SLOT = 5,
- RING2_SLOT = 6,
- NECK_SLOT = 7,
- FIGHT1_SLOT = 8,
- FIGHT2_SLOT = 9,
- PROJECTILE_SLOT = 10,
- EVOL_RING1_SLOT = 11,
- EVOL_RING2_SLOT = 12,
- COSTUME_ROBE_SLOT = 13,
- MISSING1_SLOT = 14,
- MISSING2_SLOT = 15,
- SHADOW_ARMOR_SLOT = 16,
- SHADOW_WEAPON_SLOT = 17,
- SHADOW_SHIELD_SLOT = 18,
- SHADOW_SHOES_SLOT = 19,
- SHADOW_ACCESSORY1_SLOT = 20,
- SHADOW_ACCESSORY2_SLOT = 21,
- VECTOREND
- };
-} // namespace EquipSlot
-
-#endif // ENUMS_EQUIPSLOT_H
diff --git a/src/enums/events/keyeventtype.h b/src/enums/events/keyeventtype.h
deleted file mode 100644
index 416866333..000000000
--- a/src/enums/events/keyeventtype.h
+++ /dev/null
@@ -1,76 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ENUMS_EVENTS_KEYEVENTTYPE_H
-#define ENUMS_EVENTS_KEYEVENTTYPE_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(KeyEventType)
-{
- PRESSED = 0,
- RELEASED
-}
-enumEnd(KeyEventType);
-
-#endif // ENUMS_EVENTS_KEYEVENTTYPE_H
diff --git a/src/enums/events/mousebutton.h b/src/enums/events/mousebutton.h
deleted file mode 100644
index a60f88f43..000000000
--- a/src/enums/events/mousebutton.h
+++ /dev/null
@@ -1,79 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ENUMS_EVENTS_MOUSEBUTTON_H
-#define ENUMS_EVENTS_MOUSEBUTTON_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(MouseButton)
-{
- WHEEL = -1,
- EMPTY = 0,
- LEFT,
- RIGHT,
- MIDDLE
-}
-enumEnd(MouseButton);
-
-#endif // ENUMS_EVENTS_MOUSEBUTTON_H
diff --git a/src/enums/events/mouseeventtype.h b/src/enums/events/mouseeventtype.h
deleted file mode 100644
index b0db0a863..000000000
--- a/src/enums/events/mouseeventtype.h
+++ /dev/null
@@ -1,84 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ENUMS_EVENTS_MOUSEEVENTTYPE_H
-#define ENUMS_EVENTS_MOUSEEVENTTYPE_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(MouseEventType)
-{
- MOVED = 0,
- PRESSED,
- RELEASED,
- WHEEL_MOVED_DOWN,
- WHEEL_MOVED_UP,
- CLICKED,
- ENTERED,
- EXITED,
- DRAGGED,
- RELEASED2 = 100
-}
-enumEnd(MouseEventType);
-
-#endif // ENUMS_EVENTS_MOUSEEVENTTYPE_H
diff --git a/src/enums/fs/fsentrytype.h b/src/enums/fs/fsentrytype.h
deleted file mode 100644
index 35b97164b..000000000
--- a/src/enums/fs/fsentrytype.h
+++ /dev/null
@@ -1,33 +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 ENUMS_FS_FSENTRYTYPE_H
-#define ENUMS_FS_FSENTRYTYPE_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(FsEntryType)
-{
- Dir = 0,
- Zip = 1
-}
-enumEnd(FsEntryType);
-
-#endif // ENUMS_FS_FSENTRYTYPE_H
diff --git a/src/enums/gui/chatmsgtype.h b/src/enums/gui/chatmsgtype.h
deleted file mode 100644
index 968935d0f..000000000
--- a/src/enums/gui/chatmsgtype.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 ENUMS_GUI_CHATMSGTYPE_H
-#define ENUMS_GUI_CHATMSGTYPE_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(ChatMsgType)
-{
- BY_GM = 0,
- BY_PLAYER,
- BY_OTHER,
- BY_SERVER,
- BY_CHANNEL,
- ACT_WHISPER, // getting whispered at
- ACT_IS, // equivalent to "/me" on IRC
- BY_LOGGER,
- BY_UNKNOWN = -1
-}
-enumEnd(ChatMsgType);
-
-#endif // ENUMS_GUI_CHATMSGTYPE_H
diff --git a/src/enums/gui/chattabtype.h b/src/enums/gui/chattabtype.h
deleted file mode 100644
index f37a98db6..000000000
--- a/src/enums/gui/chattabtype.h
+++ /dev/null
@@ -1,51 +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 ENUMS_GUI_CHATTABTYPE_H
-#define ENUMS_GUI_CHATTABTYPE_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-#ifdef INPUT
-#undef INPUT
-#endif // INPUT
-
-PRAGMAMINGW(GCC diagnostic push)
-PRAGMAMINGW(GCC diagnostic ignored "-Wshadow")
-
-enumStart(ChatTabType)
-{
- UNKNOWN = 0,
- INPUT,
- WHISPER,
- PARTY,
- GUILD,
- DEBUG,
- TRADE,
- BATTLE,
- LANG,
- GM,
- CHANNEL
-}
-enumEnd(ChatTabType);
-
-PRAGMAMINGW(GCC diagnostic pop)
-
-#endif // ENUMS_GUI_CHATTABTYPE_H
diff --git a/src/enums/gui/colorname.h b/src/enums/gui/colorname.h
deleted file mode 100644
index 3e45fcb66..000000000
--- a/src/enums/gui/colorname.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
- * Copyright (C) 2009 Aethyra Development Team
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * 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 ENUMS_GUI_COLORNAME_H
-#define ENUMS_GUI_COLORNAME_H
-
-namespace ColorName
-{
- enum Type
- {
- RED = 0,
- BLACK,
- GREEN,
- BLUE,
- ORANGE,
- YELLOW,
- PINK,
- PURPLE,
- GRAY,
- BROWN,
- COLORS_MAX
- };
-} // namespace ColorName
-
-#endif // ENUMS_GUI_COLORNAME_H
diff --git a/src/enums/gui/dialogtype.h b/src/enums/gui/dialogtype.h
deleted file mode 100644
index eede88ddf..000000000
--- a/src/enums/gui/dialogtype.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 ENUMS_GUI_DIALOGTYPE_H
-#define ENUMS_GUI_DIALOGTYPE_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-#undef ERROR
-
-enumStart(DialogType)
-{
- OK = 0,
- ERROR,
- SILENCE
-}
-enumEnd(DialogType);
-
-#endif // ENUMS_GUI_DIALOGTYPE_H
diff --git a/src/enums/gui/gradienttype.h b/src/enums/gui/gradienttype.h
deleted file mode 100644
index 963813558..000000000
--- a/src/enums/gui/gradienttype.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 Douglas Boffey <dougaboffey@netscape.net>
- * 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 ENUMS_GUI_GRADIENTTYPE_H
-#define ENUMS_GUI_GRADIENTTYPE_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(GradientType)
-{
- STATIC = 0,
- PULSE,
- SPECTRUM,
- RAINBOW,
- LABEL
-}
-enumEnd(GradientType);
-
-#endif // ENUMS_GUI_GRADIENTTYPE_H
diff --git a/src/enums/gui/itemamountwindowusage.h b/src/enums/gui/itemamountwindowusage.h
deleted file mode 100644
index aac1be73b..000000000
--- a/src/enums/gui/itemamountwindowusage.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 ENUMS_GUI_ITEMAMOUNTWINDOWUSAGE_H
-#define ENUMS_GUI_ITEMAMOUNTWINDOWUSAGE_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(ItemAmountWindowUsage)
-{
- TradeAdd = 0,
- ItemDrop,
- StoreAdd,
- StoreRemove,
- CartAdd,
- CartRemove,
- ItemSplit,
- ShopBuyAdd,
- ShopSellAdd,
- CraftAdd,
- MailAdd
-}
-enumEnd(ItemAmountWindowUsage);
-
-#endif // ENUMS_GUI_ITEMAMOUNTWINDOWUSAGE_H
diff --git a/src/enums/gui/layouttype.h b/src/enums/gui/layouttype.h
deleted file mode 100644
index 65e07cb05..000000000
--- a/src/enums/gui/layouttype.h
+++ /dev/null
@@ -1,42 +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 ENUMS_GUI_WIDGETS_LAYOUTTYPE_H
-#define ENUMS_GUI_WIDGETS_LAYOUTTYPE_H
-
-#include "localconsts.h"
-
-namespace LayoutType
-{
- /**
- * When the minimum size of the layout is less than the available size,
- * the remaining pixels are equally split amongst the FILL items.
- */
- enum Type
- {
- DEF = -42, /**< Default value, behaves like AUTO_ADD. */
- SET = -43, /**< Uses the share as the new size. */
- ADD = -44 /**< Adds the share to the current size. */
- };
-} // namespace LayoutType
-
-#endif // ENUMS_GUI_WIDGETS_LAYOUTTYPE_H
diff --git a/src/enums/gui/linkhighlightmode.h b/src/enums/gui/linkhighlightmode.h
deleted file mode 100644
index 04e14c947..000000000
--- a/src/enums/gui/linkhighlightmode.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
- * Copyright (C) 2009 Aethyra Development Team
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * 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 ENUMS_GUI_LINKHIGHLIGHTMODE_H
-#define ENUMS_GUI_LINKHIGHLIGHTMODE_H
-
-#include "localconsts.h"
-
-namespace LinkHighlightMode
-{
- /**
- * Highlight modes for links.
- * This can be used for a bitmask.
- */
- enum Type
- {
- UNDERLINE = 1,
- BACKGROUND = 2
- };
-} // namespace LinkHighlightMode
-
-#endif // ENUMS_GUI_LINKHIGHLIGHTMODE_H
diff --git a/src/enums/gui/npcactionstate.h b/src/enums/gui/npcactionstate.h
deleted file mode 100644
index d541b3013..000000000
--- a/src/enums/gui/npcactionstate.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 ENUMS_GUI_NPCACTIONSTATE_H
-#define ENUMS_GUI_NPCACTIONSTATE_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-#ifdef INPUT
-#undef INPUT
-#endif // INPUT
-
-PRAGMAMINGW(GCC diagnostic push)
-PRAGMAMINGW(GCC diagnostic ignored "-Wshadow")
-
-enumStart(NpcActionState)
-{
- WAIT = 0,
- NEXT,
- INPUT,
- CLOSE
-}
-enumEnd(NpcActionState);
-
-PRAGMAMINGW(GCC diagnostic pop)
-
-#endif // ENUMS_GUI_NPCACTIONSTATE_H
diff --git a/src/enums/gui/npcinputstate.h b/src/enums/gui/npcinputstate.h
deleted file mode 100644
index eea8ff14f..000000000
--- a/src/enums/gui/npcinputstate.h
+++ /dev/null
@@ -1,40 +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 ENUMS_GUI_NPCINPUTSTATE_H
-#define ENUMS_GUI_NPCINPUTSTATE_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(NpcInputState)
-{
- NONE = 0,
- LIST,
- STRING,
- INTEGER,
- ITEM,
- ITEM_INDEX,
- ITEM_CRAFT
-}
-enumEnd(NpcInputState);
-
-#endif // ENUMS_GUI_NPCINPUTSTATE_H
diff --git a/src/enums/gui/orientation.h b/src/enums/gui/orientation.h
deleted file mode 100644
index 5a816f5e6..000000000
--- a/src/enums/gui/orientation.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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ENUMS_GUI_ORIENTATION_H
-#define ENUMS_GUI_ORIENTATION_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(Orientation)
-{
- HORIZONTAL = 0,
- VERTICAL
-}
-enumEnd(Orientation);
-
-#endif // ENUMS_GUI_ORIENTATION_H
diff --git a/src/enums/gui/progresscolorid.h b/src/enums/gui/progresscolorid.h
deleted file mode 100644
index 0929b37c8..000000000
--- a/src/enums/gui/progresscolorid.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 The Legend of Mazzeroth Development Team
- * Copyright (C) 2009 Aethyra Development Team
- * 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 ENUMS_GUI_PROGRESSCOLORID_H
-#define ENUMS_GUI_PROGRESSCOLORID_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(ProgressColorId)
-{
- PROG_HP = 0,
- PROG_HP_POISON,
- PROG_MP,
- PROG_NO_MP,
- PROG_EXP,
- PROG_INVY_SLOTS,
- PROG_WEIGHT,
- PROG_JOB,
- PROG_UPDATE,
- PROG_MONEY,
- PROG_ARROWS,
- PROG_STATUS,
- THEME_PROG_END
-}
-enumEnd(ProgressColorId);
-
-#endif // ENUMS_GUI_PROGRESSCOLORID_H
diff --git a/src/enums/gui/serverdialogdonwloadstatus.h b/src/enums/gui/serverdialogdonwloadstatus.h
deleted file mode 100644
index c6eebbd07..000000000
--- a/src/enums/gui/serverdialogdonwloadstatus.h
+++ /dev/null
@@ -1,40 +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 ENUMS_GUI_SERVERDIALOGDOWNLOADSTATUS_H
-#define ENUMS_GUI_SERVERDIALOGDOWNLOADSTATUS_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(ServerDialogDownloadStatus)
-{
- UNKNOWN = 0,
- ERROR,
- PREPARING,
- IDLE,
- IN_PROGRESS,
- COMPLETE,
- OVER
-}
-enumEnd(ServerDialogDownloadStatus);
-
-#endif // ENUMS_GUI_SERVERDIALOGDOWNLOADSTATUS_H
diff --git a/src/enums/gui/shoplistboxtype.h b/src/enums/gui/shoplistboxtype.h
deleted file mode 100644
index 9be128d65..000000000
--- a/src/enums/gui/shoplistboxtype.h
+++ /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/>.
- */
-
-#ifndef ENUMS_GUI_SHOPLISTBOXTYPE_H
-#define ENUMS_GUI_SHOPLISTBOXTYPE_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(ShopListBoxType)
-{
- Unknown = 0,
- BuyShop = 1,
- SellShop = 2
-}
-enumEnd(ShopListBoxType);
-
-#endif // ENUMS_GUI_SHOPLISTBOXTYPE_H
diff --git a/src/enums/gui/slidergrid.h b/src/enums/gui/slidergrid.h
deleted file mode 100644
index 790fa5878..000000000
--- a/src/enums/gui/slidergrid.h
+++ /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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ENUMS_GUI_SLIDERGRID_H
-#define ENUMS_GUI_SLIDERGRID_H
-
-namespace SliderGrid
-{
- enum Type
- {
- HSTART = 0,
- HMID,
- HEND,
- HGRIP,
- VSTART,
- VMID,
- VEND,
- VGRIP,
- SLIDER_MAX
- };
-} // namespace SliderGrid
-
-#endif // ENUMS_GUI_SLIDERGRID_H
diff --git a/src/enums/gui/themecolorid.h b/src/enums/gui/themecolorid.h
deleted file mode 100644
index d4ab954a9..000000000
--- a/src/enums/gui/themecolorid.h
+++ /dev/null
@@ -1,258 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 The Legend of Mazzeroth Development Team
- * Copyright (C) 2009 Aethyra Development Team
- * 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 ENUMS_GUI_THEMECOLORID_H
-#define ENUMS_GUI_THEMECOLORID_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(ThemeColorId)
-{
- BROWSERBOX = 0,
- BROWSERBOX_OUTLINE,
- SELFNICK,
- SELFNICK_OUTLINE,
- TEXT,
- TEXT_OUTLINE,
- CARET,
- SHADOW,
- OUTLINE,
- BORDER,
- PROGRESS_BAR,
- PROGRESS_BAR_OUTLINE,
- BUTTON,
- BUTTON_OUTLINE,
- BUTTON_DISABLED,
- BUTTON_DISABLED_OUTLINE,
- BUTTON_HIGHLIGHTED,
- BUTTON_HIGHLIGHTED_OUTLINE,
- BUTTON_PRESSED,
- BUTTON_PRESSED_OUTLINE,
- CHECKBOX,
- CHECKBOX_OUTLINE,
- DROPDOWN,
- DROPDOWN_OUTLINE,
- LABEL,
- LABEL_OUTLINE,
- LISTBOX,
- LISTBOX_OUTLINE,
- LISTBOX_SELECTED,
- LISTBOX_SELECTED_OUTLINE,
- RADIOBUTTON,
- RADIOBUTTON_OUTLINE,
- POPUP,
- POPUP_OUTLINE,
- TAB,
- TAB_OUTLINE,
- TAB_HIGHLIGHTED,
- TAB_HIGHLIGHTED_OUTLINE,
- TAB_SELECTED,
- TAB_SELECTED_OUTLINE,
- TEXTBOX,
- TEXTFIELD,
- TEXTFIELD_OUTLINE,
- WINDOW,
- WINDOW_OUTLINE,
- BATTLE_CHAT_TAB,
- BATTLE_CHAT_TAB_OUTLINE,
- CHANNEL_CHAT_TAB,
- CHANNEL_CHAT_TAB_OUTLINE,
- PARTY_CHAT_TAB,
- PARTY_CHAT_TAB_OUTLINE,
- PARTY_SOCIAL_TAB,
- PARTY_SOCIAL_TAB_OUTLINE,
- GUILD_CHAT_TAB,
- GUILD_CHAT_TAB_OUTLINE,
- GUILD_SOCIAL_TAB,
- GUILD_SOCIAL_TAB_OUTLINE,
- GM_CHAT_TAB,
- GM_CHAT_TAB_OUTLINE,
- BATTLE_CHAT_TAB_HIGHLIGHTED,
- BATTLE_CHAT_TAB_HIGHLIGHTED_OUTLINE,
- CHANNEL_CHAT_TAB_HIGHLIGHTED,
- CHANNEL_CHAT_TAB_HIGHLIGHTED_OUTLINE,
- PARTY_CHAT_TAB_HIGHLIGHTED,
- PARTY_CHAT_TAB_HIGHLIGHTED_OUTLINE,
- PARTY_SOCIAL_TAB_HIGHLIGHTED,
- PARTY_SOCIAL_TAB_HIGHLIGHTED_OUTLINE,
- GUILD_CHAT_TAB_HIGHLIGHTED,
- GUILD_CHAT_TAB_HIGHLIGHTED_OUTLINE,
- GUILD_SOCIAL_TAB_HIGHLIGHTED,
- GUILD_SOCIAL_TAB_HIGHLIGHTED_OUTLINE,
- GM_CHAT_TAB_HIGHLIGHTED,
- GM_CHAT_TAB_HIGHLIGHTED_OUTLINE,
- BATTLE_CHAT_TAB_SELECTED,
- BATTLE_CHAT_TAB_SELECTED_OUTLINE,
- CHANNEL_CHAT_TAB_SELECTED,
- CHANNEL_CHAT_TAB_SELECTED_OUTLINE,
- PARTY_CHAT_TAB_SELECTED,
- PARTY_CHAT_TAB_SELECTED_OUTLINE,
- PARTY_SOCIAL_TAB_SELECTED,
- PARTY_SOCIAL_TAB_SELECTED_OUTLINE,
- GUILD_CHAT_TAB_SELECTED,
- GUILD_CHAT_TAB_SELECTED_OUTLINE,
- GUILD_SOCIAL_TAB_SELECTED,
- GUILD_SOCIAL_TAB_SELECTED_OUTLINE,
- GM_CHAT_TAB_SELECTED,
- GM_CHAT_TAB_SELECTED_OUTLINE,
- BACKGROUND,
- BACKGROUND_GRAY,
- SCROLLBAR_GRAY,
- DROPDOWN_SHADOW,
- HIGHLIGHT,
- HIGHLIGHT_OUTLINE,
- TAB_FLASH,
- TAB_FLASH_OUTLINE,
- TAB_PLAYER_FLASH,
- TAB_PLAYER_FLASH_OUTLINE,
- SHOP_WARNING,
- ITEM_EQUIPPED,
- ITEM_EQUIPPED_OUTLINE,
- ITEM_NOT_EQUIPPED,
- ITEM_NOT_EQUIPPED_OUTLINE,
- CHAT,
- CHAT_OUTLINE,
- GM,
- GM_OUTLINE,
- GLOBAL,
- GLOBAL_OUTLINE,
- PLAYER,
- PLAYER_OUTLINE,
- WHISPER_TAB,
- WHISPER_TAB_OUTLINE,
- WHISPER_TAB_OFFLINE,
- WHISPER_TAB_OFFLINE_OUTLINE,
- WHISPER_TAB_HIGHLIGHTED,
- WHISPER_TAB_HIGHLIGHTED_OUTLINE,
- WHISPER_TAB_OFFLINE_HIGHLIGHTED,
- WHISPER_TAB_OFFLINE_HIGHLIGHTED_OUTLINE,
- WHISPER_TAB_SELECTED,
- WHISPER_TAB_SELECTED_OUTLINE,
- WHISPER_TAB_OFFLINE_SELECTED,
- WHISPER_TAB_OFFLINE_SELECTED_OUTLINE,
- IS,
- IS_OUTLINE,
- SERVER,
- SERVER_OUTLINE,
- LOGGER,
- LOGGER_OUTLINE,
- HYPERLINK,
- HYPERLINK_OUTLINE,
- UNKNOWN_ITEM,
- UNKNOWN_ITEM_OUTLINE,
- GENERIC,
- GENERIC_OUTLINE,
- HEAD,
- HEAD_OUTLINE,
- USABLE,
- USABLE_OUTLINE,
- TORSO,
- TORSO_OUTLINE,
- ONEHAND,
- ONEHAND_OUTLINE,
- LEGS,
- LEGS_OUTLINE,
- FEET,
- FEET_OUTLINE,
- TWOHAND,
- TWOHAND_OUTLINE,
- SHIELD,
- SHIELD_OUTLINE,
- RING,
- RING_OUTLINE,
- NECKLACE,
- NECKLACE_OUTLINE,
- ARMS,
- ARMS_OUTLINE,
- AMMO,
- AMMO_OUTLINE,
- SERVER_VERSION_NOT_SUPPORTED,
- SERVER_VERSION_NOT_SUPPORTED_OUTLINE,
- WARNING,
- WARNING_OUTLINE,
- CHARM,
- CHARM_OUTLINE,
- CARD,
- CARD_OUTLINE,
- PLAYER_ADVANCED,
- PLAYER_ADVANCED_OUTLINE,
- BUBBLE_NAME,
- BUBBLE_NAME_OUTLINE,
- BUBBLE_TEXT,
- BUBBLE_TEXT_OUTLINE,
- BLACK,
- BLACK_OUTLINE,
- RED,
- RED_OUTLINE,
- GREEN,
- GREEN_OUTLINE,
- BLUE,
- BLUE_OUTLINE,
- ORANGE,
- ORANGE_OUTLINE,
- YELLOW,
- YELLOW_OUTLINE,
- PINK,
- PINK_OUTLINE,
- PURPLE,
- PURPLE_OUTLINE,
- GRAY,
- GRAY_OUTLINE,
- BROWN,
- BROWN_OUTLINE,
- STATUSBAR_ON,
- STATUSBAR_OFF,
- TABLE_BACKGROUND,
- SLOTS_BAR,
- SLOTS_BAR_OUTLINE,
- HP_BAR,
- HP_BAR_OUTLINE,
- MP_BAR,
- MP_BAR_OUTLINE,
- NO_MP_BAR,
- NO_MP_BAR_OUTLINE,
- XP_BAR,
- XP_BAR_OUTLINE,
- WEIGHT_BAR,
- WEIGHT_BAR_OUTLINE,
- MONEY_BAR,
- MONEY_BAR_OUTLINE,
- ARROWS_BAR,
- ARROWS_BAR_OUTLINE,
- STATUS_BAR,
- STATUS_BAR_OUTLINE,
- JOB_BAR,
- JOB_BAR_OUTLINE,
- OLDCHAT,
- OLDCHAT_OUTLINE,
- AWAYCHAT,
- AWAYCHAT_OUTLINE,
- SKILL_COOLDOWN,
- TEXT_DISABLED,
- TEXT_DISABLED_OUTLINE,
- THEME_COLORS_END
-}
-enumEnd(ThemeColorId);
-
-#endif // ENUMS_GUI_THEMECOLORID_H
diff --git a/src/enums/gui/updatedownloadstatus.h b/src/enums/gui/updatedownloadstatus.h
deleted file mode 100644
index 7209cc66e..000000000
--- a/src/enums/gui/updatedownloadstatus.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) 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 ENUMS_GUI_UPDATEDOWNLOADSTATUS_H
-#define ENUMS_GUI_UPDATEDOWNLOADSTATUS_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(UpdateDownloadStatus)
-{
- UPDATE_ERROR = 0,
- UPDATE_IDLE,
- UPDATE_LIST,
- UPDATE_COMPLETE,
- UPDATE_NEWS,
- UPDATE_RESOURCES,
- UPDATE_PATCH,
- UPDATE_LIST2,
- UPDATE_RESOURCES2
-}
-enumEnd(UpdateDownloadStatus);
-
-#endif // ENUMS_GUI_UPDATEDOWNLOADSTATUS_H
diff --git a/src/enums/gui/usercolorid.h b/src/enums/gui/usercolorid.h
deleted file mode 100644
index bb3feab0f..000000000
--- a/src/enums/gui/usercolorid.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 Douglas Boffey <dougaboffey@netscape.net>
- * 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 ENUMS_GUI_USERCOLORID_H
-#define ENUMS_GUI_USERCOLORID_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(UserColorId)
-{
- NO_COLOR = -1,
- LABEL_BEING = 0,
- BEING,
- FRIEND,
- DISREGARDED,
- IGNORED,
- ERASED,
- ENEMY,
- PC,
- SELF,
- GM,
- NPC,
- MONSTER,
- PET,
- MERCENARY,
- HOMUNCULUS,
- SKILLUNIT,
- PARTY,
- GUILD,
- TEAM1,
- TEAM2,
- TEAM3,
- LABEL_PARTICLES,
- PARTICLE,
- PICKUP_INFO,
- EXP_INFO,
- LABEL_HP,
- PLAYER_HP,
- PLAYER_HP2,
- MONSTER_HP,
- MONSTER_HP2,
- HOMUN_HP,
- HOMUN_HP2,
- MERC_HP,
- MERC_HP2,
- ELEMENTAL_HP,
- ELEMENTAL_HP2,
- LABEL_HITS,
- HIT_PLAYER_MONSTER,
- HIT_MONSTER_PLAYER,
- HIT_PLAYER_PLAYER,
- HIT_CRITICAL,
- HIT_LOCAL_PLAYER_MONSTER,
- HIT_LOCAL_PLAYER_CRITICAL,
- HIT_LOCAL_PLAYER_MISS,
- MISS,
- LABEL_TILES,
- PORTAL_HIGHLIGHT,
- COLLISION_HIGHLIGHT,
- AIR_COLLISION_HIGHLIGHT,
- WATER_COLLISION_HIGHLIGHT,
- MONSTER_COLLISION_HIGHLIGHT,
- GROUNDTOP_COLLISION_HIGHLIGHT,
- WALKABLE_HIGHLIGHT,
- NET,
- LABEL_RANGES,
- ATTACK_RANGE,
- ATTACK_RANGE_BORDER,
- MONSTER_ATTACK_RANGE,
- SKILL_ATTACK_RANGE,
- LABEL_OTHER,
- FLOOR_ITEM_TEXT,
- HOME_PLACE,
- HOME_PLACE_BORDER,
- ROAD_POINT,
- USER_COLOR_LAST
-}
-enumEnd(UserColorId);
-
-#endif // ENUMS_GUI_USERCOLORID_H
diff --git a/src/enums/guildpositionflags.h b/src/enums/guildpositionflags.h
deleted file mode 100644
index 180545103..000000000
--- a/src/enums/guildpositionflags.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 ENUMS_GUILDPOSITIONFLAGS_H
-#define ENUMS_GUILDPOSITIONFLAGS_H
-
-class Guild;
-
-namespace GuildPositionFlags
-{
- enum Type
- {
- None = 0x00,
- Invite = 0x01,
- Expel = 0x10
- };
-} // namespace GuildPositionFlags
-
-#endif // ENUMS_GUILDPOSITIONFLAGS_H
diff --git a/src/enums/input/inputaction.h b/src/enums/input/inputaction.h
deleted file mode 100644
index dc09b8f3a..000000000
--- a/src/enums/input/inputaction.h
+++ /dev/null
@@ -1,716 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2007 Joshua Langley <joshlangley@optusnet.com.au>
- * 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 ENUMS_INPUT_INPUTACTION_H
-#define ENUMS_INPUT_INPUTACTION_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-#ifdef WIN32
-#undef ERROR
-#undef IGNORE
-#endif // WIN32
-
-/**
- * All the key functions.
- * KEY_NO_VALUE is used in initialization, and should be unchanged.
- * KEY_TOTAL should always be last (used as a conditional in loops).
- * The key assignment view gets arranged according to the order of
- * these values.
- */
-enumStart(InputAction)
-{
- UNDEFINED_VALUE = -2,
- NO_VALUE = -1,
- MOVE_UP,
- MOVE_DOWN,
- MOVE_LEFT,
- MOVE_RIGHT,
- ATTACK,
- TARGET_ATTACK,
- MOVE_TO_TARGET,
- CHANGE_MOVE_TO_TARGET,
- MOVE_TO_HOME,
- SET_HOME,
- MOVE_TO_POINT,
- TALK,
- STOP_ATTACK,
- UNTARGET,
- TARGET_MONSTER,
- TARGET_NPC,
- TARGET_PLAYER,
- PICKUP,
- CHANGE_PICKUP_TYPE,
- HIDE_WINDOWS,
- SIT,
- SCREENSHOT,
- CHANGE_TRADE,
- PATHFIND,
- OK,
- QUIT,
- SHORTCUTS_KEY,
- SHORTCUT_1,
- SHORTCUT_2,
- SHORTCUT_3,
- SHORTCUT_4,
- SHORTCUT_5,
- SHORTCUT_6,
- SHORTCUT_7,
- SHORTCUT_8,
- SHORTCUT_9,
- SHORTCUT_10,
- SHORTCUT_11,
- SHORTCUT_12,
- SHORTCUT_13,
- SHORTCUT_14,
- SHORTCUT_15,
- SHORTCUT_16,
- SHORTCUT_17,
- SHORTCUT_18,
- SHORTCUT_19,
- SHORTCUT_20,
- WINDOW_HELP,
- WINDOW_STATUS,
- WINDOW_INVENTORY,
- WINDOW_EQUIPMENT,
- WINDOW_SKILL,
- WINDOW_MINIMAP,
- WINDOW_CHAT,
- WINDOW_SHORTCUT,
- WINDOW_SETUP,
- WINDOW_DEBUG,
- WINDOW_SOCIAL,
- WINDOW_EMOTE_SHORTCUT,
- WINDOW_OUTFIT,
- WINDOW_SHOP,
- WINDOW_DROP,
- WINDOW_KILLS,
- WINDOW_SPELLS,
- UNUSED1,
- WINDOW_ONLINE,
- WINDOW_DIDYOUKNOW,
- WINDOW_QUESTS,
- PREV_SOCIAL_TAB,
- NEXT_SOCIAL_TAB,
- EMOTE,
- EMOTE_1,
- EMOTE_2,
- EMOTE_3,
- EMOTE_4,
- EMOTE_5,
- EMOTE_6,
- EMOTE_7,
- EMOTE_8,
- EMOTE_9,
- EMOTE_10,
- EMOTE_11,
- EMOTE_12,
- EMOTE_13,
- EMOTE_14,
- EMOTE_15,
- EMOTE_16,
- EMOTE_17,
- EMOTE_18,
- EMOTE_19,
- EMOTE_20,
- EMOTE_21,
- EMOTE_22,
- EMOTE_23,
- EMOTE_24,
- EMOTE_25,
- EMOTE_26,
- EMOTE_27,
- EMOTE_28,
- EMOTE_29,
- EMOTE_30,
- EMOTE_31,
- EMOTE_32,
- EMOTE_33,
- EMOTE_34,
- EMOTE_35,
- EMOTE_36,
- EMOTE_37,
- EMOTE_38,
- EMOTE_39,
- EMOTE_40,
- EMOTE_41,
- EMOTE_42,
- EMOTE_43,
- EMOTE_44,
- EMOTE_45,
- EMOTE_46,
- EMOTE_47,
- EMOTE_48,
- WEAR_OUTFIT,
- COPY_OUTFIT,
- COPY_EQUIPED_OUTFIT,
- OUTFIT_1,
- OUTFIT_2,
- OUTFIT_3,
- OUTFIT_4,
- OUTFIT_5,
- OUTFIT_6,
- OUTFIT_7,
- OUTFIT_8,
- OUTFIT_9,
- OUTFIT_10,
- OUTFIT_11,
- OUTFIT_12,
- OUTFIT_13,
- OUTFIT_14,
- OUTFIT_15,
- OUTFIT_16,
- OUTFIT_17,
- OUTFIT_18,
- OUTFIT_19,
- OUTFIT_20,
- OUTFIT_21,
- OUTFIT_22,
- OUTFIT_23,
- OUTFIT_24,
- OUTFIT_25,
- OUTFIT_26,
- OUTFIT_27,
- OUTFIT_28,
- OUTFIT_29,
- OUTFIT_30,
- OUTFIT_31,
- OUTFIT_32,
- OUTFIT_33,
- OUTFIT_34,
- OUTFIT_35,
- OUTFIT_36,
- OUTFIT_37,
- OUTFIT_38,
- OUTFIT_39,
- OUTFIT_40,
- OUTFIT_41,
- OUTFIT_42,
- OUTFIT_43,
- OUTFIT_44,
- OUTFIT_45,
- OUTFIT_46,
- OUTFIT_47,
- OUTFIT_48,
- MOVE_TO_POINT_1,
- MOVE_TO_POINT_2,
- MOVE_TO_POINT_3,
- MOVE_TO_POINT_4,
- MOVE_TO_POINT_5,
- MOVE_TO_POINT_6,
- MOVE_TO_POINT_7,
- MOVE_TO_POINT_8,
- MOVE_TO_POINT_9,
- MOVE_TO_POINT_10,
- MOVE_TO_POINT_11,
- MOVE_TO_POINT_12,
- MOVE_TO_POINT_13,
- MOVE_TO_POINT_14,
- MOVE_TO_POINT_15,
- MOVE_TO_POINT_16,
- MOVE_TO_POINT_17,
- MOVE_TO_POINT_18,
- MOVE_TO_POINT_19,
- MOVE_TO_POINT_20,
- MOVE_TO_POINT_21,
- MOVE_TO_POINT_22,
- MOVE_TO_POINT_23,
- MOVE_TO_POINT_24,
- MOVE_TO_POINT_25,
- MOVE_TO_POINT_26,
- MOVE_TO_POINT_27,
- MOVE_TO_POINT_28,
- MOVE_TO_POINT_29,
- MOVE_TO_POINT_30,
- MOVE_TO_POINT_31,
- MOVE_TO_POINT_32,
- MOVE_TO_POINT_33,
- MOVE_TO_POINT_34,
- MOVE_TO_POINT_35,
- MOVE_TO_POINT_36,
- MOVE_TO_POINT_37,
- MOVE_TO_POINT_38,
- MOVE_TO_POINT_39,
- MOVE_TO_POINT_40,
- MOVE_TO_POINT_41,
- MOVE_TO_POINT_42,
- MOVE_TO_POINT_43,
- MOVE_TO_POINT_44,
- MOVE_TO_POINT_45,
- MOVE_TO_POINT_46,
- MOVE_TO_POINT_47,
- MOVE_TO_POINT_48,
- TOGGLE_CHAT,
- SCROLL_CHAT_UP,
- SCROLL_CHAT_DOWN,
- PREV_CHAT_TAB,
- NEXT_CHAT_TAB,
- CLOSE_CHAT_TAB,
- CHAT_PREV_HISTORY,
- CHAT_NEXT_HISTORY,
- IGNORE_INPUT_1,
- IGNORE_INPUT_2,
- DIRECT_UP,
- DIRECT_DOWN,
- DIRECT_LEFT,
- DIRECT_RIGHT,
- CRAZY_MOVES,
- CHANGE_CRAZY_MOVES_TYPE,
- QUICK_DROP,
- QUICK_DROPN,
- SWITCH_QUICK_DROP,
- MAGIC_INMA1,
- MAGIC_ITENPLZ,
- MAGIC_ATTACK,
- SWITCH_MAGIC_ATTACK,
- SWITCH_PVP_ATTACK,
- INVERT_DIRECTION,
- CHANGE_ATTACK_WEAPON_TYPE,
- CHANGE_ATTACK_TYPE,
- CHANGE_FOLLOW_MODE,
- CHANGE_IMITATION_MODE,
- DISABLE_GAME_MODIFIERS,
- CHANGE_AUDIO,
- AWAY,
- RIGHT_CLICK,
- CAMERA,
- RESERVED1,
- GUI_UP,
- GUI_DOWN,
- GUI_LEFT,
- GUI_RIGHT,
- GUI_SELECT,
- GUI_SELECT2,
- GUI_CANCEL,
- GUI_HOME,
- GUI_END,
- GUI_DELETE,
- GUI_BACKSPACE,
- GUI_TAB,
- GUI_PAGE_UP,
- GUI_PAGE_DOWN,
- GUI_INSERT,
- GUI_MOD,
- SAFE_VIDEO,
- STOP_SIT,
- SHOW_KEYBOARD,
- SHOW_WINDOWS,
- CHAT_MOD,
- MOVE_FORWARD,
- GUI_CTRL,
- GUI_B,
- GUI_C,
- GUI_D,
- GUI_E,
- GUI_F,
- GUI_H,
- GUI_K,
- GUI_U,
- GUI_V,
- GUI_W,
- PREV_SHORTCUTS_TAB,
- NEXT_SHORTCUTS_TAB,
- PREV_COMMANDS_TAB,
- NEXT_COMMANDS_TAB,
- OPEN_TRADE,
- GUI_F1,
- GUI_F2,
- GUI_F3,
- GUI_F4,
- GUI_F5,
- GUI_F6,
- GUI_F7,
- GUI_F8,
- GUI_F9,
- GUI_F10,
- GUI_F11,
- GUI_F12,
- WINDOW_ABOUT,
- WINDOW_UPDATER,
- TARGET_CLOSEST_MONSTER,
- CLOSE_ALL_CHAT_TABS,
- IGNORE_ALL_WHISPERS,
- CHAT_ANNOUNCE,
- IPC_TOGGLE,
- WHERE,
- WHO,
- WHISPER,
- QUERY,
- CLEAR_CHAT_TAB,
- IGNORE,
- UNIGNORE,
- FRIEND,
- DISREGARD,
- NEUTRAL,
- BLACKLIST,
- ENEMY,
- ERASE,
- CLEAN_GRAPHICS,
- CLEAN_FONTS,
- CREATE_PARTY,
- CREATE_GUILD,
- PARTY,
- ME,
- TOGGLE,
- PRESENT,
- PRINT_ALL,
- MOVE,
- TARGET,
- ATTACK_HUMAN,
- COMMAMD_OUTFIT,
- COMMAMD_EMOTE,
- COMMAND_EMOTE_PET,
- AWAY_MESSAGE,
- PSEUDO_AWAY,
- FOLLOW,
- NAVIGATE,
- IMITATION,
- SEND_MAIL,
- TRADE,
- PRICE_LOAD,
- PRICE_SAVE,
- CACHE_INFO,
- DISCONNECT,
- UNDRESS,
- DIRS,
- INFO,
- WAIT,
- UPTIME,
- ADD_PRIORITY_ATTACK,
- ADD_ATTACK,
- REMOVE_ATTACK,
- ADD_IGNORE_ATTACK,
- DUMP,
- SERVER_IGNORE_ALL,
- SERVER_UNIGNORE_ALL,
- SET_DROP,
- ERROR,
- DUMP_GRAPHICS,
- DUMP_ENVIRONMENT,
- DUMP_TESTS,
- DUMP_OGL,
- DUMP_GL,
- DUMP_MODS,
- URL,
- OPEN_URL,
- EXECUTE,
- TEST_SDL_FONT,
- ENABLE_HIGHLIGHT,
- DISABLE_HIGHLIGHT,
- DONT_REMOVE_NAME,
- REMOVE_NAME,
- DISABLE_AWAY,
- ENABLE_AWAY,
- TEST_PARTICLE,
- CREATE_ITEMS,
- TALK_RAW,
- TALK_PET,
- UPLOAD_CONFIG,
- UPLOAD_SERVER_CONFIG,
- UPLOAD_LOG,
- GM,
- HACK,
- DEBUG_SPAWN,
- PET_EMOTE,
- PET_EMOTE_1,
- PET_EMOTE_2,
- PET_EMOTE_3,
- PET_EMOTE_4,
- PET_EMOTE_5,
- PET_EMOTE_6,
- PET_EMOTE_7,
- PET_EMOTE_8,
- PET_EMOTE_9,
- PET_EMOTE_10,
- PET_EMOTE_11,
- PET_EMOTE_12,
- PET_EMOTE_13,
- PET_EMOTE_14,
- PET_EMOTE_15,
- PET_EMOTE_16,
- PET_EMOTE_17,
- PET_EMOTE_18,
- PET_EMOTE_19,
- PET_EMOTE_20,
- PET_EMOTE_21,
- PET_EMOTE_22,
- PET_EMOTE_23,
- PET_EMOTE_24,
- PET_EMOTE_25,
- PET_EMOTE_26,
- PET_EMOTE_27,
- PET_EMOTE_28,
- PET_EMOTE_29,
- PET_EMOTE_30,
- PET_EMOTE_31,
- PET_EMOTE_32,
- PET_EMOTE_33,
- PET_EMOTE_34,
- PET_EMOTE_35,
- PET_EMOTE_36,
- PET_EMOTE_37,
- PET_EMOTE_38,
- PET_EMOTE_39,
- PET_EMOTE_40,
- PET_EMOTE_41,
- PET_EMOTE_42,
- PET_EMOTE_43,
- PET_EMOTE_44,
- PET_EMOTE_45,
- PET_EMOTE_46,
- PET_EMOTE_47,
- PET_EMOTE_48,
- CATCH_PET,
- IGNORE_WHISPER,
- UNIGNORE_WHISPER,
- MERCENARY_FIRE,
- TARGET_MERCENARY,
- TARGET_PET,
- PET_SET_NAME,
- HOMUNCULUS_SET_NAME,
- HOMUNCULUS_FIRE,
- WINDOW_BANK,
- PREV_INV_TAB,
- NEXT_INV_TAB,
- CONTEXT_MENU,
- BUY,
- SELL,
- WHISPER2,
- GUILD,
- NUKE,
- USE,
- CHAT_ADD,
- WHISPER_TEXT,
- NAVIGATE_TO,
- CAMERA_MOVE,
- DROP_ITEM,
- DROP_ITEM_ALL,
- DROP_INV,
- DROP_INV_ALL,
- USE_INV,
- INV_TO_STORAGE,
- TRADE_ADD,
- STORAGE_TO_INV,
- ITEM_PROTECT,
- ITEM_UNPROTECT,
- KICK_PARTY,
- ADD_TEXT,
- KICK,
- LEAVE_PARTY,
- WARP,
- CLEAR_CHAT,
- PET_MOVE_UP,
- PET_MOVE_DOWN,
- PET_MOVE_LEFT,
- PET_MOVE_RIGHT,
- PET_DIRECT_UP,
- PET_DIRECT_DOWN,
- PET_DIRECT_LEFT,
- PET_DIRECT_RIGHT,
- PET_AI_START,
- PET_AI_STOP,
- CHAT_GENERAL_TAB,
- CHAT_DEBUG_TAB,
- CHAT_BATTLE_TAB,
- CHAT_TRADE_TAB,
- CHAT_LANG_TAB,
- CHAT_GM_TAB,
- CHAT_PARTY_TAB,
- CHAT_GUILD_TAB,
- DROP_CLEAR,
- WINDOW_CART,
- HEAL_MOST_DAMAGED,
- PET_MOVE,
- HOMUN_TALK,
- HOMUN_SMILE,
- HOMUN_EMOTE,
- HOMUN_EMOTE_1,
- HOMUN_EMOTE_2,
- HOMUN_EMOTE_3,
- HOMUN_EMOTE_4,
- HOMUN_EMOTE_5,
- HOMUN_EMOTE_6,
- HOMUN_EMOTE_7,
- HOMUN_EMOTE_8,
- HOMUN_EMOTE_9,
- HOMUN_EMOTE_10,
- HOMUN_EMOTE_11,
- HOMUN_EMOTE_12,
- HOMUN_EMOTE_13,
- HOMUN_EMOTE_14,
- HOMUN_EMOTE_15,
- HOMUN_EMOTE_16,
- HOMUN_EMOTE_17,
- HOMUN_EMOTE_18,
- HOMUN_EMOTE_19,
- HOMUN_EMOTE_20,
- HOMUN_EMOTE_21,
- HOMUN_EMOTE_22,
- HOMUN_EMOTE_23,
- HOMUN_EMOTE_24,
- HOMUN_EMOTE_25,
- HOMUN_EMOTE_26,
- HOMUN_EMOTE_27,
- HOMUN_EMOTE_28,
- HOMUN_EMOTE_29,
- HOMUN_EMOTE_30,
- HOMUN_EMOTE_31,
- HOMUN_EMOTE_32,
- HOMUN_EMOTE_33,
- HOMUN_EMOTE_34,
- HOMUN_EMOTE_35,
- HOMUN_EMOTE_36,
- HOMUN_EMOTE_37,
- HOMUN_EMOTE_38,
- HOMUN_EMOTE_39,
- HOMUN_EMOTE_40,
- HOMUN_EMOTE_41,
- HOMUN_EMOTE_42,
- HOMUN_EMOTE_43,
- HOMUN_EMOTE_44,
- HOMUN_EMOTE_45,
- HOMUN_EMOTE_46,
- HOMUN_EMOTE_47,
- HOMUN_EMOTE_48,
- KICK_GUILD,
- HAT,
- CREATE_PUBLIC_ROOM,
- JOIN_ROOM,
- LEAVE_ROOM,
- WINDOW_QUICK_SETTINGS,
- WINDOW_MAIL,
- CONF_SET,
- SERVER_CONF_SET,
- CONG_GET,
- SERVER_CONG_GET,
- CHANGE_TARGETING_TYPE,
- TEST_INFO,
- SLIDE,
- SELECT_SKILL_LEVEL,
- SKILL,
- CRAFT_1,
- CRAFT_2,
- CRAFT_3,
- CRAFT_4,
- CRAFT_5,
- CRAFT_6,
- CRAFT_7,
- CRAFT_8,
- CRAFT_9,
- CRAFT,
- CHAT_CLIPBOARD,
- NPC_CLIPBOARD,
- ADD_PICKUP,
- REMOVE_PICKUP,
- IGNORE_PICKUP,
- RESET_MODIFIERS,
- BAR_TO_CHAT,
- SEEN,
- TARGET_SKILL_UNIT,
- MONSTER_INFO,
- ITEM_INFO,
- WHO_DROPS,
- MOB_SEARCH,
- MOB_SPAWN_SEARCH,
- PLAYER_GM_COMMANDS,
- PLAYER_CHAR_GM_COMMANDS,
- COMMAND_SHOW_LEVEL,
- COMMAND_SHOW_STATS,
- COMMAND_SHOW_STORAGE,
- COMMAND_SHOW_CART,
- COMMAND_SHOW_INVENTORY,
- LOCATE_PLAYER,
- COMMAND_SHOW_ACCOUNT_INFO,
- COMMAND_SPAWN,
- COMMAND_SPAWN_SLAVE,
- COMMAND_SPAWN_CLONE,
- COMMAND_SPAWN_SLAVE_CLONE,
- COMMAND_SPAWN_EVIL_CLONE,
- COMMAND_SAVE_POSITION,
- COMMAND_LOAD_POSITION,
- COMMAND_RANDOM_WARP,
- COMMAND_GOTO_NPC,
- COMMAND_KILLER,
- COMMAND_KILLABLE,
- COMMAND_HEAL,
- COMMAND_ALIVE,
- COMMAND_DISGUISE,
- COMMAND_IMMORTAL,
- COMMAND_HIDE,
- COMMAND_NUKE,
- COMMAND_KILL,
- COMMAND_JAIL,
- COMMAND_UNJAIL,
- COMMAND_NPC_MOVE,
- COMMAND_NPC_HIDE,
- COMMAND_NPC_SHOW,
- COMMAND_CHANGE_PARTY_LEADER,
- COMMAND_PARTY_RECALL,
- COMMAND_BREAK_GUILD,
- COMMAND_GUILD_RECALL,
- MAIL_TO,
- ADOPT_CHILD,
- DUMP_MEMORY_USAGE,
- SET_EMOTE_TYPE,
- CAMERA_RESTORE,
- SHOW_SKILL_LEVELS,
- SHOW_SKILL_TYPE,
- SELECT_SKILL_TYPE,
- SHOW_SKILL_OFFSET_X,
- SHOW_SKILL_OFFSET_Y,
- SET_SKILL_OFFSET_X,
- SET_SKILL_OFFSET_Y,
- LEAVE_GUILD,
- GUILD_NOTICE,
- PARTY_ITEM_SHARE,
- PARTY_EXP_SHARE,
- PARTY_AUTO_ITEM_SHARE,
- CREATE_ITEM,
- COPY_OUTFIT_TO_CHAT,
- COMMAND_TRANSLATE,
- COMMAND_SEND_GUI_KEY,
- MOVE_ATTACK_UP,
- MOVE_ATTACK_DOWN,
- MOVE_PRIORITY_ATTACK_UP,
- MOVE_PRIORITY_ATTACK_DOWN,
- SHOW_ITEMS,
- COMMAND_SEND_MOUSE_KEY,
- COMMAND_SEND_CHARS,
- CLEAR_OUTFIT,
- CLIPBOARD_COPY,
- COMMAND_GOTO_PC,
- COMMAND_RECALL_PC,
- COMMAND_IP_CHECK,
- WINDOW_SERVER_INFO,
- MERCENARY_TO_MASTER,
- HOMUNCULUS_TO_MASTER,
- HOMUNCULUS_FEED,
- PET_FEED,
- PET_DROP_LOOT,
- PET_RETURN_TO_EGG,
- PET_UNEQUIP,
- ADD_SKILL_SHORTCUT,
- TOTAL
-}
-enumEnd(InputAction);
-
-#endif // ENUMS_INPUT_INPUTACTION_H
diff --git a/src/enums/input/inputcondition.h b/src/enums/input/inputcondition.h
deleted file mode 100644
index a53aec86c..000000000
--- a/src/enums/input/inputcondition.h
+++ /dev/null
@@ -1,61 +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 ENUMS_INPUT_INPUTCONDITION_H
-#define ENUMS_INPUT_INPUTCONDITION_H
-
-namespace InputCondition
-{
- enum Type
- {
- DEFAULT = 1, // default condition
- ENABLED = 2, // keyboard must be enabled
- NOINPUT = 4, // input items must be unfocused
- NOAWAY = 8, // player not in away mode
- NOSETUP = 16, // setup window is hidde
- VALIDSPEED = 32, // valid speed
- NOMODAL = 64, // modal windows inactive
- NONPCINPUT = 128, // npc input field inactive
- EMODS = 256, // game modifiers enabled
- NOTARGET = 512, // no target/untarget keys
- // pressed
- NOFOLLOW = 1024, // follow mode disabled
- INGAME = 2048, // game must be started
- NOBUYSELL = 4096, // no active buy or sell dialogs
- NONPCDIALOG = 8192, // no active npc dialog or
- // dialog almost closed
- NOTALKING = 16384, // player have no opened
- // dialogs what prevent moving
- ALIVE = 32768, // player alive
- NOVENDING = 65536, // vending disabled
- NOROOM = 131072, // not joined room
- NOBLOCK = 262144, // no blocked move (trick dead)
- KEY_DOWN = 524288, // key press allowed
- KEY_UP = 1048576, // key release allowed
- SHORTCUT = 2 + 4 + 16 + 512 + 2048, // flags for shortcut keys
- SHORTCUT0 = 2 + 4 + 16 + 512, // flags for shortcut keys
- GAME = 2 + 4 + 8 + 16 + 64 + 2048, // main game key
- GAME2 = 2 + 8 + 16 + 64 + 2048,
- ARROWKEYS = 2 + 4 + 8 + 16 + 64 + 2048 + 4096 +
- 16384 + 65536 + 131072 + 262144
- };
-} // namespace InputCondition
-
-#endif // ENUMS_INPUT_INPUTCONDITION_H
diff --git a/src/enums/input/inputgroup.h b/src/enums/input/inputgroup.h
deleted file mode 100644
index 5fc3c93af..000000000
--- a/src/enums/input/inputgroup.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2007 Joshua Langley <joshlangley@optusnet.com.au>
- * 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 ENUMS_INPUT_INPUTGROUP_H
-#define ENUMS_INPUT_INPUTGROUP_H
-
-#include "localconsts.h"
-
-namespace Input
-{
- enum InputGroup
- {
- GRP_DEFAULT = 1, // default game key
- GRP_CHAT = 2, // chat key
- GRP_EMOTION = 4, // emotions key
- GRP_OUTFIT = 8, // outfit key
- GRP_GUI = 16, // gui key
- GRP_MOVETOPOINT = 32, // move to point key
- GRP_GUICHAN = 64, // for guichan based controls
- GRP_REPEAT = 128, // repeat emulation keys
- GRP_PET_EMOTION = 256, // pet emotions key
- GRP_HOMUN_EMOTION = 512 // homunculus/mercenary emotetions key
- };
-} // namespace Input
-
-#endif // ENUMS_INPUT_INPUTGROUP_H
diff --git a/src/enums/input/inputtype.h b/src/enums/input/inputtype.h
deleted file mode 100644
index 865d5581a..000000000
--- a/src/enums/input/inputtype.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 ENUMS_INPUT_INPUTTYPE_H
-#define ENUMS_INPUT_INPUTTYPE_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-// hack to avoid conflicts with windows headers.
-#ifdef KEYBOARD
-#undef KEYBOARD
-#endif // KEYBOARD
-#ifdef MOUSE
-#undef MOUSE
-#endif // MOUSE
-
-enumStart(InputType)
-{
- UNKNOWN = 0,
- KEYBOARD = 1,
- MOUSE = 2,
- JOYSTICK = 3
-}
-enumEnd(InputType);
-
-#endif // ENUMS_INPUT_INPUTTYPE_H
diff --git a/src/enums/input/keyboardfocus.h b/src/enums/input/keyboardfocus.h
deleted file mode 100644
index 9b80f7f20..000000000
--- a/src/enums/input/keyboardfocus.h
+++ /dev/null
@@ -1,34 +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 ENUMS_INPUT_KEYBOARDFOCUS_H
-#define ENUMS_INPUT_KEYBOARDFOCUS_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(KeyboardFocus)
-{
- Unfocused = 0,
- Focused = 1,
- Focused2 = 2
-}
-enumEnd(KeyboardFocus);
-
-#endif // ENUMS_INPUT_KEYBOARDFOCUS_H
diff --git a/src/enums/input/keyvalue.h b/src/enums/input/keyvalue.h
deleted file mode 100644
index 9b83e9666..000000000
--- a/src/enums/input/keyvalue.h
+++ /dev/null
@@ -1,131 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ENUMS_INPUT_KEYVALUE_H
-#define ENUMS_INPUT_KEYVALUE_H
-
-#include "localconsts.h"
-
-// windows.h defines DELETE which breaks this file as we have a constant named
-// DELETE, hence we undefine DELETE if it is defined and hope people don't use
-// that windows define with Guichan.
-#if defined (_WIN32) && defined(DELETE)
-#undef DELETE
-#endif // defined (_WIN32) && defined(DELETE)
-
-namespace KeyValue
-{
- enum
- {
- SPACE = ' ',
- TAB = '\t',
- ENTER = '\n',
- // Negative values, to avoid conflicts with higher character codes.
- LEFT_ALT = -1000,
- RIGHT_ALT = -999,
- LEFT_SHIFT = -998,
- RIGHT_SHIFT = -997,
- LEFT_CONTROL = -996,
- RIGHT_CONTROL = -995,
- LEFT_META = -994,
- RIGHT_META = -993,
- LEFT_SUPER = -992,
- RIGHT_SUPER = -991,
- INSERT = -990,
- HOME = -989,
- PAGE_UP = -988,
- DELETE_ = -987,
- END = -986,
- PAGE_DOWN = -985,
- ESCAPE = -984,
- CAPS_LOCK = -983,
- BACKSPACE = -982,
- F1 = -981,
- F2 = -980,
- F3 = -979,
- F4 = -978,
- F5 = -977,
- F6 = -978,
- F7 = -977,
- F8 = -976,
- F9 = -975,
- F10 = -974,
- F11 = -973,
- F12 = -972,
- F13 = -971,
- F14 = -970,
- F15 = -969,
- PRINT_SCREEN = -968,
- SCROLL_LOCK = -967,
- PAUSE = -966,
- NUM_LOCK = -965,
- ALT_GR = -964,
- LEFT = -963,
- RIGHT = -962,
- UP = -961,
- DOWN = -960,
- TEXTINPUT = -959
- };
-} // namespace KeyValue
-
-#endif // ENUMS_INPUT_KEYVALUE_H
diff --git a/src/enums/inventorytype.h b/src/enums/inventorytype.h
deleted file mode 100644
index 91d473f78..000000000
--- a/src/enums/inventorytype.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 ENUMS_INVENTORYTYPE_H
-#define ENUMS_INVENTORYTYPE_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(InventoryType)
-{
- Inventory = 0,
- Storage,
- Trade,
- Npc,
- Cart,
- Vending,
- MailEdit,
- MailView,
- Craft,
- TypeEnd
-}
-enumEnd(InventoryType);
-
-#endif // ENUMS_INVENTORYTYPE_H
diff --git a/src/enums/magicschool.h b/src/enums/magicschool.h
deleted file mode 100644
index 6c1f92c7b..000000000
--- a/src/enums/magicschool.h
+++ /dev/null
@@ -1,40 +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 ENUMS_MAGICSCHOOL_H
-#define ENUMS_MAGICSCHOOL_H
-
-#ifdef TMWA_SUPPORT
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(MagicSchool)
-{
- SkillMagic = 340,
- SkillMagicLife = 341,
- SkillMagicWar = 342,
- SkillMagicTransmute = 343,
- SkillMagicNature = 344,
- SkillMagicAstral = 345
-}
-enumEnd(MagicSchool);
-
-#endif // TMWA_SUPPORT
-#endif // ENUMS_MAGICSCHOOL_H
diff --git a/src/enums/net/auctionsearchtype.h b/src/enums/net/auctionsearchtype.h
deleted file mode 100644
index a21e0226e..000000000
--- a/src/enums/net/auctionsearchtype.h
+++ /dev/null
@@ -1,37 +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 ENUMS_NET_AUCTIONSEARCHTYPE_H
-#define ENUMS_NET_AUCTIONSEARCHTYPE_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(AuctionSearchType)
-{
- Armor = 0,
- Weapon = 1,
- Card = 2,
- Misc = 3,
- Name = 4,
- AuctionId = 5
-}
-enumEnd(AuctionSearchType);
-
-#endif // ENUMS_NET_AUCTIONSEARCHTYPE_H
diff --git a/src/enums/net/battlegroundtype.h b/src/enums/net/battlegroundtype.h
deleted file mode 100644
index de7f91fa9..000000000
--- a/src/enums/net/battlegroundtype.h
+++ /dev/null
@@ -1,35 +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 ENUMS_NET_BATTLEGROUNDTYPE_H
-#define ENUMS_NET_BATTLEGROUNDTYPE_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(BattleGroundType)
-{
- Invalid = 0,
- Individual = 1,
- Party = 2,
- Guild = 4
-}
-enumEnd(BattleGroundType);
-
-#endif // ENUMS_NET_BATTLEGROUNDTYPE_H
diff --git a/src/enums/net/beingtype.h b/src/enums/net/beingtype.h
deleted file mode 100644
index cc1f39889..000000000
--- a/src/enums/net/beingtype.h
+++ /dev/null
@@ -1,42 +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 ENUMS_NET_BEINGTYPE_H
-#define ENUMS_NET_BEINGTYPE_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(BeingType)
-{
- PC = 0,
- NPC = 1,
- ITEM = 2,
- SKILL = 3,
- CHAT = 4,
- MONSTER = 5,
- NPC_EVENT = 6,
- PET = 7,
- HOMUN = 8,
- MERSOL = 9,
- ELEMENTAL = 10
-}
-enumEnd(BeingType);
-
-#endif // ENUMS_NET_BEINGTYPE_H
diff --git a/src/enums/net/deleteitemreason.h b/src/enums/net/deleteitemreason.h
deleted file mode 100644
index fcab0cb95..000000000
--- a/src/enums/net/deleteitemreason.h
+++ /dev/null
@@ -1,39 +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 ENUMS_NET_DELETEITEMREASON_H
-#define ENUMS_NET_DELETEITEMREASON_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(DeleteItemReason)
-{
- Normal = 0,
- SkillUse = 1,
- FailRefine = 2,
- MaterialChange = 3,
- ToStorage = 4,
- ToCart = 5,
- Sold = 6,
- Analysis = 7
-}
-enumEnd(DeleteItemReason);
-
-#endif // ENUMS_NET_DELETEITEMREASON_H
diff --git a/src/enums/net/downloadstatus.h b/src/enums/net/downloadstatus.h
deleted file mode 100644
index 511997dd3..000000000
--- a/src/enums/net/downloadstatus.h
+++ /dev/null
@@ -1,38 +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 ENUMS_NET_DOWNLOADSTATUS_H
-#define ENUMS_NET_DOWNLOADSTATUS_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(DownloadStatus)
-{
- Cancelled = -3,
- ThreadError = -2,
- Error = -1,
- Starting = 0,
- Idle = 1,
- Complete = 2
-}
-enumEnd(DownloadStatus);
-
-#endif // ENUMS_NET_DOWNLOADSTATUS_H
diff --git a/src/enums/net/mailmessagetype.h b/src/enums/net/mailmessagetype.h
deleted file mode 100644
index 8679c31ee..000000000
--- a/src/enums/net/mailmessagetype.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 ENUMS_NET_MAILMESSAGETYPE_H
-#define ENUMS_NET_MAILMESSAGETYPE_H
-
-#include "localconsts.h"
-
-namespace MailMessageType
-{
- enum Type
- {
- Text = 0,
- Money = 2,
- Item = 4,
- Npc = 8
- };
-} // namespace MailMessageType
-
-#endif // ENUMS_NET_MAILMESSAGETYPE_H
diff --git a/src/enums/net/mailopentype.h b/src/enums/net/mailopentype.h
deleted file mode 100644
index ad62a0252..000000000
--- a/src/enums/net/mailopentype.h
+++ /dev/null
@@ -1,34 +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 NET_EATHENA_MAILOPENTYPE_H
-#define NET_EATHENA_MAILOPENTYPE_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStartT(MailOpenType, int8_t)
-{
- Mail = 0,
- Account = 1,
- Return = 2
-}
-enumEnd(MailOpenType);
-
-#endif // NET_EATHENA_MAILOPENTYPE_H
diff --git a/src/enums/net/menutype.h b/src/enums/net/menutype.h
deleted file mode 100644
index 2c4106c05..000000000
--- a/src/enums/net/menutype.h
+++ /dev/null
@@ -1,48 +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 NET_EATHENA_MENUTYPE_H
-#define NET_EATHENA_MENUTYPE_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(MenuType)
-{
- Unknown = 0,
- Analysis,
- AutoSpell,
- AutoShadowSpell,
- ChangeMaterial,
- CreateConvert,
- Eggs,
- Feel,
- Identify,
- MagicDecoy,
- MakingArrows,
- PoisoningWeapon,
- ReadingSpellBook,
- RepairWespon,
- Teleport,
- Warp,
- WeaponeRefine
-}
-enumEnd(MenuType);
-
-#endif // NET_EATHENA_MENUTYPE_H
diff --git a/src/enums/net/npcaction.h b/src/enums/net/npcaction.h
deleted file mode 100644
index c000ad17a..000000000
--- a/src/enums/net/npcaction.h
+++ /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/>.
- */
-
-#ifndef ENUMS_NET_NPCACTION_H
-#define ENUMS_NET_NPCACTION_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(NpcAction)
-{
- Next = 0,
- Close = 1,
- Other = 2
-}
-enumEnd(NpcAction);
-
-#endif // ENUMS_NET_NPCACTION_H
diff --git a/src/enums/net/packettype.h b/src/enums/net/packettype.h
deleted file mode 100644
index 793bee477..000000000
--- a/src/enums/net/packettype.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 ENUMS_NET_PACKETTYPE_H
-#define ENUMS_NET_PACKETTYPE_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(PacketType)
-{
- PACKET_CHAT = 0,
- PACKET_PICKUP = 1,
- PACKET_DROP = 2,
- PACKET_NPC_NEXT = 3,
- PACKET_NPC_TALK = 4,
- PACKET_NPC_INPUT = 5,
- PACKET_EMOTE = 6,
- PACKET_SIT = 7,
- PACKET_DIRECTION = 8,
- PACKET_ATTACK = 9,
- PACKET_STOPATTACK = 10,
- PACKET_ONLINELIST = 11,
- PACKET_WHISPER = 12,
- PACKET_SIZE
-}
-enumEnd(PacketType);
-
-#endif // ENUMS_NET_PACKETTYPE_H
diff --git a/src/enums/net/partyshare.h b/src/enums/net/partyshare.h
deleted file mode 100644
index c98027e6f..000000000
--- a/src/enums/net/partyshare.h
+++ /dev/null
@@ -1,37 +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 ENUMS_NET_PARTYSHARE_H
-#define ENUMS_NET_PARTYSHARE_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(PartyShare)
-{
- UNKNOWN = -1,
- NO,
- YES,
- NOT_POSSIBLE = 2
-}
-enumEnd(PartyShare);
-
-#endif // ENUMS_NET_PARTYSHARE_H
diff --git a/src/enums/net/serverfreetype.h b/src/enums/net/serverfreetype.h
deleted file mode 100644
index 0819f10f1..000000000
--- a/src/enums/net/serverfreetype.h
+++ /dev/null
@@ -1,37 +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 ENUMS_NET_SERVERFREETYPE_H
-#define ENUMS_NET_SERVERFREETYPE_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(ServerFreeType)
-{
- Unknown = 0,
- NotSet = 1,
- Free = 2,
- NonFree = 3
-}
-enumEnd(ServerFreeType);
-
-#endif // ENUMS_NET_SERVERFREETYPE_H
diff --git a/src/enums/net/servertype.h b/src/enums/net/servertype.h
deleted file mode 100644
index d369ac7b1..000000000
--- a/src/enums/net/servertype.h
+++ /dev/null
@@ -1,37 +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 ENUMS_NET_SERVERTYPE_H
-#define ENUMS_NET_SERVERTYPE_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(ServerType)
-{
- UNKNOWN = 0,
- TMWATHENA,
- EATHENA,
- EVOL2
-}
-enumEnd(ServerType);
-
-#endif // ENUMS_NET_SERVERTYPE_H
diff --git a/src/enums/net/storesearchtype.h b/src/enums/net/storesearchtype.h
deleted file mode 100644
index e7e0ba210..000000000
--- a/src/enums/net/storesearchtype.h
+++ /dev/null
@@ -1,33 +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 ENUMS_NET_STORESEARCHTYPE_H
-#define ENUMS_NET_STORESEARCHTYPE_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(StoreSearchType)
-{
- Vending = 0,
- BuingStore = 1
-}
-enumEnd(StoreSearchType);
-
-#endif // ENUMS_NET_STORESEARCHTYPE_H
diff --git a/src/enums/net/updatetype.h b/src/enums/net/updatetype.h
deleted file mode 100644
index a6aa4918e..000000000
--- a/src/enums/net/updatetype.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 ENUMS_NET_UPDATETYPE_H
-#define ENUMS_NET_UPDATETYPE_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(UpdateType)
-{
- Normal = 0,
- Close = 1,
- Skip = 2,
- Custom = 4
-}
-enumEnd(UpdateType);
-
-#endif // ENUMS_NET_UPDATETYPE_H
diff --git a/src/enums/particle/alivestatus.h b/src/enums/particle/alivestatus.h
deleted file mode 100644
index 93b2cdd71..000000000
--- a/src/enums/particle/alivestatus.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2006-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 ENUMS_PARTICLE_ALIVESTATUS_H
-#define ENUMS_PARTICLE_ALIVESTATUS_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(AliveStatus)
-{
- ALIVE = 0,
- DEAD_TIMEOUT = 1,
- DEAD_FLOOR = 2,
- DEAD_SKY = 4,
- DEAD_IMPACT = 8,
- DEAD_OTHER = 16,
- DEAD_LONG_AGO = 128
-}
-enumEnd(AliveStatus);
-
-#endif // ENUMS_PARTICLE_ALIVESTATUS_H
diff --git a/src/enums/particle/particlechangefunc.h b/src/enums/particle/particlechangefunc.h
deleted file mode 100644
index 9a0502d8c..000000000
--- a/src/enums/particle/particlechangefunc.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2006-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 ENUMS_PARTICLE_PARTICLECHANGEFUNC_H
-#define ENUMS_PARTICLE_PARTICLECHANGEFUNC_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(ParticleChangeFunc)
-{
- FUNC_NONE = 0,
- FUNC_SINE,
- FUNC_SAW,
- FUNC_TRIANGLE,
- FUNC_SQUARE
-}
-enumEnd(ParticleChangeFunc);
-
-#endif // ENUMS_PARTICLE_PARTICLECHANGEFUNC_H
diff --git a/src/enums/particle/particlephysics.h b/src/enums/particle/particlephysics.h
deleted file mode 100644
index 961bc15d4..000000000
--- a/src/enums/particle/particlephysics.h
+++ /dev/null
@@ -1,34 +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 ENUMS_PARTICLE_PARTICLEPHYSICS_H
-#define ENUMS_PARTICLE_PARTICLEPHYSICS_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(ParticlePhysics)
-{
- Best = 0,
- Normal = 1,
- Fast = 2
-}
-enumEnd(ParticlePhysics);
-
-#endif // ENUMS_PARTICLE_PARTICLEPHYSICS_H
diff --git a/src/enums/particle/particletype.h b/src/enums/particle/particletype.h
deleted file mode 100644
index 03ed9334e..000000000
--- a/src/enums/particle/particletype.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 ENUMS_PARTICLE_PARTICLETYPE_H
-#define ENUMS_PARTICLE_PARTICLETYPE_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(ParticleType)
-{
- Normal = 0,
- Animation = 1,
- Image = 2,
- Rotational = 3,
- Text = 4
-}
-enumEnd(ParticleType);
-
-#endif // ENUMS_PARTICLE_PARTICLETYPE_H
diff --git a/src/enums/render/blitmode.h b/src/enums/render/blitmode.h
deleted file mode 100644
index 362d17053..000000000
--- a/src/enums/render/blitmode.h
+++ /dev/null
@@ -1,35 +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 ENUMS_RENDER_BLITMODE_H
-#define ENUMS_RENDER_BLITMODE_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(BlitMode)
-{
- BLIT_NORMAL = 0,
- BLIT_GFX
-}
-enumEnd(BlitMode);
-
-#endif // ENUMS_RENDER_BLITMODE_H
diff --git a/src/enums/render/rendertype.h b/src/enums/render/rendertype.h
deleted file mode 100644
index 579fe3d09..000000000
--- a/src/enums/render/rendertype.h
+++ /dev/null
@@ -1,37 +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 ENUMS_RENDER_RENDERTYPE_H
-#define ENUMS_RENDER_RENDERTYPE_H
-
-enum RenderType
-{
- RENDER_SOFTWARE = 0,
- RENDER_NORMAL_OPENGL = 1,
- RENDER_SAFE_OPENGL = 2,
- RENDER_GLES_OPENGL = 3,
- RENDER_SDL2_DEFAULT = 4,
- RENDER_MODERN_OPENGL = 5,
- RENDER_GLES2_OPENGL = 6,
- RENDER_NULL = 7,
- RENDER_LAST
-};
-
-#endif // ENUMS_RENDER_RENDERTYPE_H
diff --git a/src/enums/resources/cursor.h b/src/enums/resources/cursor.h
deleted file mode 100644
index eda0907af..000000000
--- a/src/enums/resources/cursor.h
+++ /dev/null
@@ -1,45 +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 ENUMS_RESOURCES_CURSOR_H
-#define ENUMS_RESOURCES_CURSOR_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(Cursor)
-{
- CURSOR_POINTER = 0,
- CURSOR_RESIZE_ACROSS,
- CURSOR_RESIZE_DOWN,
- CURSOR_RESIZE_DOWN_LEFT,
- CURSOR_RESIZE_DOWN_RIGHT,
- CURSOR_FIGHT,
- CURSOR_PICKUP,
- CURSOR_TALK,
- CURSOR_ACTION,
- CURSOR_LEFT,
- CURSOR_UP,
- CURSOR_RIGHT,
- CURSOR_DOWN,
- CURSOR_TOTAL
-}
-enumEnd(Cursor);
-
-#endif // ENUMS_RESOURCES_CURSOR_H
diff --git a/src/enums/resources/displaytype.h b/src/enums/resources/displaytype.h
deleted file mode 100644
index a5aff2244..000000000
--- a/src/enums/resources/displaytype.h
+++ /dev/null
@@ -1,33 +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 ENUMS_RESOURCES_DISPLAYTYPE_H
-#define ENUMS_RESOURCES_DISPLAYTYPE_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(DisplayType)
-{
- Item = 0,
- Floor = 1
-}
-enumEnd(DisplayType);
-
-#endif // ENUMS_RESOURCES_DISPLAYTYPE_H
diff --git a/src/enums/resources/frametype.h b/src/enums/resources/frametype.h
deleted file mode 100644
index 9fafa2073..000000000
--- a/src/enums/resources/frametype.h
+++ /dev/null
@@ -1,40 +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 ENUMS_RESOURCES_FRAMETYPE_H
-#define ENUMS_RESOURCES_FRAMETYPE_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-#include "localconsts.h"
-
-enumStart(FrameType)
-{
- ANIMATION = 0,
- JUMP,
- GOTO,
- LABEL,
- PAUSE
-}
-enumEnd(FrameType);
-
-#endif // ENUMS_RESOURCES_FRAMETYPE_H
diff --git a/src/enums/resources/imageposition.h b/src/enums/resources/imageposition.h
deleted file mode 100644
index 88b7fae69..000000000
--- a/src/enums/resources/imageposition.h
+++ /dev/null
@@ -1,61 +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 ENUMS_RESOURCES_IMAGEPOSITION_H
-#define ENUMS_RESOURCES_IMAGEPOSITION_H
-
-#include "localconsts.h"
-
-/**
- * 9 images defining a rectangle. 4 corners, 4 sides and a middle area. The
- * topology is as follows:
- *
- * <pre>
- * !-----!-----------------!-----!
- * ! 0 ! 1 ! 2 !
- * !-----!-----------------!-----!
- * ! 3 ! 4 ! 5 !
- * !-----!-----------------!-----!
- * ! 6 ! 7 ! 8 !
- * !-----!-----------------!-----!
- * </pre>
- *
- * Sections 0, 2, 6 and 8 will remain as is. 1, 3, 4, 5 and 7 will be
- * repeated to fit the size of the widget.
- */
-namespace ImagePosition
-{
- enum Type
- {
- UPPER_LEFT = 0,
- UPPER_CENTER = 1,
- UPPER_RIGHT = 2,
- LEFT = 3,
- CENTER = 4,
- RIGHT = 5,
- LOWER_LEFT = 6,
- LOWER_CENTER = 7,
- LOWER_RIGHT = 8
- };
-} // namespace ImagePosition
-
-#endif // ENUMS_RESOURCES_IMAGEPOSITION_H
diff --git a/src/enums/resources/imagetype.h b/src/enums/resources/imagetype.h
deleted file mode 100644
index 145debd7b..000000000
--- a/src/enums/resources/imagetype.h
+++ /dev/null
@@ -1,33 +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 ENUMS_RESOURCES_IMAGETYPE_H
-#define ENUMS_RESOURCES_IMAGETYPE_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(ImageType)
-{
- Image = 0,
- SubImage = 1
-}
-enumEnd(ImageType);
-
-#endif // ENUMS_RESOURCES_IMAGETYPE_H
diff --git a/src/enums/resources/item/itemdbtype.h b/src/enums/resources/item/itemdbtype.h
deleted file mode 100644
index da35c921e..000000000
--- a/src/enums/resources/item/itemdbtype.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 ENUMS_RESOURCES_ITEM_ITEMDBTYPE_H
-#define ENUMS_RESOURCES_ITEM_ITEMDBTYPE_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(ItemDbType)
-{
- UNUSABLE = 0,
- USABLE,
- EQUIPMENT_ONE_HAND_WEAPON,
- EQUIPMENT_TWO_HANDS_WEAPON,
- EQUIPMENT_TORSO,
- EQUIPMENT_ARMS, // 5
- CARD,
- EQUIPMENT_HEAD,
- EQUIPMENT_LEGS,
- EQUIPMENT_SHIELD,
- EQUIPMENT_RING,
- EQUIPMENT_NECKLACE, // 10
- EQUIPMENT_FEET,
- EQUIPMENT_AMMO,
- EQUIPMENT_CHARM,
- SPRITE_RACE,
- SPRITE_HAIR // 15
-}
-enumEnd(ItemDbType);
-
-#endif // ENUMS_RESOURCES_ITEM_ITEMDBTYPE_H
diff --git a/src/enums/resources/item/itemsoundevent.h b/src/enums/resources/item/itemsoundevent.h
deleted file mode 100644
index 636159835..000000000
--- a/src/enums/resources/item/itemsoundevent.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 ENUMS_RESOURCES_ITEM_ITEMSOUNDEVENT_H
-#define ENUMS_RESOURCES_ITEM_ITEMSOUNDEVENT_H
-
-namespace ItemSoundEvent
-{
- enum Type
- {
- HIT = 0,
- MISS,
- HURT,
- DIE,
- MOVE,
- SIT,
- SITTOP,
- SPAWN,
- DROP,
- PICKUP,
- TAKE, // take from container
- PUT, // put into container
- EQUIP,
- UNEQUIP,
- USE,
- USECARD
- };
-} // namespace ItemSoundEvent
-
-#endif // ENUMS_RESOURCES_ITEM_ITEMSOUNDEVENT_H
diff --git a/src/enums/resources/item/itemtype.h b/src/enums/resources/item/itemtype.h
deleted file mode 100644
index be71e613a..000000000
--- a/src/enums/resources/item/itemtype.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 ENUMS_RESOURCES_ITEM_ITEMTYPE_H
-#define ENUMS_RESOURCES_ITEM_ITEMTYPE_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(ItemType)
-{
- Healing = 0,
- Unknown = 1,
- Usable = 2,
- Etc = 3,
- Weapon = 4,
- Armor = 5,
- Card = 6,
- PetEgg = 7,
- PetArmor = 8,
- Unknown2 = 9,
- Ammon = 10,
- DelayConsume = 11,
- Cash = 18
-}
-enumEnd(ItemType);
-
-#endif // ENUMS_RESOURCES_ITEM_ITEMTYPE_H
diff --git a/src/enums/resources/mailqueuetype.h b/src/enums/resources/mailqueuetype.h
deleted file mode 100644
index bb953f37e..000000000
--- a/src/enums/resources/mailqueuetype.h
+++ /dev/null
@@ -1,35 +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 ENUMS_RESOURCES_MAILQUEUETYPE_H
-#define ENUMS_RESOURCES_MAILQUEUETYPE_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(MailQueueType)
-{
- Unknown = 0,
- SendMail = 1,
- EditMail = 2,
- ValidateTo = 3
-}
-enumEnd(MailQueueType);
-
-#endif // ENUMS_RESOURCES_MAILQUEUETYPE_H
diff --git a/src/enums/resources/map/blockmask.h b/src/enums/resources/map/blockmask.h
deleted file mode 100644
index 09559bfbf..000000000
--- a/src/enums/resources/map/blockmask.h
+++ /dev/null
@@ -1,40 +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 ENUMS_RESOURCES_MAP_BLOCKMASK_H
-#define ENUMS_RESOURCES_MAP_BLOCKMASK_H
-
-namespace BlockMask
-{
- enum BlockMask
- {
- WALL = 0x80, // 1000 0000
- AIR = 0x04, // 0000 0100
- WATER = 0x08, // 0000 1000
- GROUND = 0x10, // 0001 0000
- GROUNDTOP = 0x20, // 0010 0000
- PLAYERWALL = 0x40, // 0100 0000
- MONSTERWALL = 0x02 // 0000 0010
- };
-} // namespace BlockMask
-
-#endif // ENUMS_RESOURCES_MAP_BLOCKMASK_H
diff --git a/src/enums/resources/map/blocktype.h b/src/enums/resources/map/blocktype.h
deleted file mode 100644
index 83fe65637..000000000
--- a/src/enums/resources/map/blocktype.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 ENUMS_RESOURCES_MAP_BLOCKTYPE_H
-#define ENUMS_RESOURCES_MAP_BLOCKTYPE_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(BlockType)
-{
- NONE = -1,
- GROUND = 0,
- WALL = 1,
- AIR = 2,
- WATER = 3,
- GROUNDTOP = 4,
- PLAYERWALL = 5,
- MONSTERWALL = 6,
- NB_BLOCKTYPES
-}
-enumEnd(BlockType);
-
-#endif // ENUMS_RESOURCES_MAP_BLOCKTYPE_H
diff --git a/src/enums/resources/map/collisiontype.h b/src/enums/resources/map/collisiontype.h
deleted file mode 100644
index 6ce50f2f8..000000000
--- a/src/enums/resources/map/collisiontype.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 ENUMS_RESOURCES_MAP_COLLISIONTYPE_H
-#define ENUMS_RESOURCES_MAP_COLLISIONTYPE_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(CollisionType)
-{
- COLLISION_EMPTY = 0, // no collision
- COLLISION_WALL = 1, // full collison
- COLLISION_AIR = 2, // air units can walk
- COLLISION_WATER = 3, // water units can walk
- COLLISION_GROUNDTOP = 4, // no collision (chair, bed, etc)
- COLLISION_PLAYER_WALL = 5, // full collision for player
- COLLISION_MONSTER_WALL = 6, // full collision for monster
- COLLISION_MAX = 7 // count index
-}
-enumEnd(CollisionType);
-
-#endif // ENUMS_RESOURCES_MAP_COLLISIONTYPE_H
diff --git a/src/enums/resources/map/mapitemtype.h b/src/enums/resources/map/mapitemtype.h
deleted file mode 100644
index 5d9b1734a..000000000
--- a/src/enums/resources/map/mapitemtype.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 ENUMS_RESOURCES_MAP_MAPITEMTYPE_H
-#define ENUMS_RESOURCES_MAP_MAPITEMTYPE_H
-
-namespace MapItemType
-{
- enum Type
- {
- EMPTY = 0,
- HOME = 1,
- ROAD = 2,
- CROSS = 3,
- ARROW_UP = 4,
- ARROW_DOWN = 5,
- ARROW_LEFT = 6,
- ARROW_RIGHT = 7,
- PORTAL = 8,
- MUSIC = 9,
- ATTACK = 10,
- PRIORITY = 11,
- IGNORE_ = 12,
- PICKUP = 13,
- NOPICKUP = 14,
- SEPARATOR = 15
- };
-} // namespace MapItemType
-
-#endif // ENUMS_RESOURCES_MAP_MAPITEMTYPE_H
diff --git a/src/enums/resources/map/maplayerposition.h b/src/enums/resources/map/maplayerposition.h
deleted file mode 100644
index c1b89657f..000000000
--- a/src/enums/resources/map/maplayerposition.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 ENUMS_RESOURCES_MAP_MAPLAYERPOSITION_H
-#define ENUMS_RESOURCES_MAP_MAPLAYERPOSITION_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-#include "localconsts.h"
-
-enumStart(MapLayerPosition)
-{
- FOREGROUND_LAYERS = 0,
- BACKGROUND_LAYERS
-}
-enumEnd(MapLayerPosition);
-
-#endif // ENUMS_RESOURCES_MAP_MAPLAYERPOSITION_H
diff --git a/src/enums/resources/map/maplayertype.h b/src/enums/resources/map/maplayertype.h
deleted file mode 100644
index 1c2edbbd6..000000000
--- a/src/enums/resources/map/maplayertype.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 ENUMS_RESOURCES_MAP_MAPLAYERTYPE_H
-#define ENUMS_RESOURCES_MAP_MAPLAYERTYPE_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-#include "localconsts.h"
-
-enumStart(MapLayerType)
-{
- TILES = 0,
- COLLISION,
- HEIGHTS,
- ACTIONS
-}
-enumEnd(MapLayerType);
-
-#endif // ENUMS_RESOURCES_MAP_MAPLAYERTYPE_H
diff --git a/src/enums/resources/map/maptype.h b/src/enums/resources/map/maptype.h
deleted file mode 100644
index f9c095ffe..000000000
--- a/src/enums/resources/map/maptype.h
+++ /dev/null
@@ -1,40 +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 ENUMS_RESOURCES_MAP_MAPTYPE_H
-#define ENUMS_RESOURCES_MAP_MAPTYPE_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(MapType)
-{
- NORMAL = 0,
- DEBUGTYPE = 1,
- SPECIAL = 2,
- SPECIAL2 = 3,
- SPECIAL3 = 4,
- SPECIAL4 = 5,
- BLACKWHITE = 6
-}
-enumEnd(MapType);
-
-#endif // ENUMS_RESOURCES_MAP_MAPTYPE_H
diff --git a/src/enums/resources/notifyflags.h b/src/enums/resources/notifyflags.h
deleted file mode 100644
index 50dedf459..000000000
--- a/src/enums/resources/notifyflags.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 ENUMS_RESOURCES_NOTIFYFLAGS_H
-#define ENUMS_RESOURCES_NOTIFYFLAGS_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(NotifyFlags)
-{
- EMPTY = 0,
- INT,
- STRING,
- GUILD,
- GUILD_STRING,
- PARTY,
- PARTY_STRING,
- SPEECH
-}
-enumEnd(NotifyFlags);
-
-#endif // ENUMS_RESOURCES_NOTIFYFLAGS_H
diff --git a/src/enums/resources/notifytypes.h b/src/enums/resources/notifytypes.h
deleted file mode 100644
index 1c2dee843..000000000
--- a/src/enums/resources/notifytypes.h
+++ /dev/null
@@ -1,255 +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 ENUMS_RESOURCES_NOTIFYTYPES_H
-#define ENUMS_RESOURCES_NOTIFYTYPES_H
-
-#include "localconsts.h"
-
-namespace NotifyTypes
-{
- enum Type
- {
- NONE = 0,
- BUY_DONE,
- BUY_FAILED,
- BUY_FAILED_NO_MONEY,
- BUY_FAILED_OVERWEIGHT,
- BUY_FAILED_TOO_MANY_ITEMS,
- SELL_LIST_EMPTY,
- SOLD,
- SELL_FAILED,
- SELL_TRADE_FAILED,
- SELL_UNSELLABLE_FAILED,
- ONLINE_USERS,
- GUILD_CREATED,
- GUILD_ALREADY,
- GUILD_EMPERIUM_CHECK_FAILED,
- GUILD_ERROR,
- GUILD_LEFT,
- GUILD_INVITE_FAILED,
- GUILD_INVITE_REJECTED,
- GUILD_INVITE_JOINED,
- GUILD_INVITE_FULL,
- GUILD_INVITE_ERROR,
- GUILD_USER_LEFT,
- GUILD_KICKED,
- GUILD_USER_KICKED,
- USE_FAILED,
- EQUIP_FAILED,
- EQUIP_FAILED_LEVEL,
- UNEQUIP_FAILED,
- PARTY_CREATE_FAILED,
- PARTY_CREATED,
- PARTY_LEFT,
- PARTY_LEFT_DENY,
- PARTY_KICKED,
- PARTY_KICK_DENY,
- PARTY_USER_JOINED,
- PARTY_INVITE_ALREADY_MEMBER,
- PARTY_INVITE_REFUSED,
- PARTY_INVITE_DONE,
- PARTY_INVITE_PARTY_FULL,
- PARTY_INVITE_ERROR,
- PARTY_EXP_SHARE_ON,
- PARTY_EXP_SHARE_OFF,
- PARTY_EXP_SHARE_ERROR,
- PARTY_ITEM_SHARE_ON,
- PARTY_ITEM_SHARE_OFF,
- PARTY_ITEM_SHARE_ERROR,
- PARTY_USER_LEFT,
- PARTY_USER_LEFT_DENY,
- PARTY_USER_KICKED,
- PARTY_USER_KICK_DENY,
- PARTY_UNKNOWN_USER_MSG,
- PARTY_USER_NOT_IN_PARTY,
- MONEY_GET,
- MONEY_SPENT,
- SKILL_RAISE_ERROR,
- ARROWS_EQUIP_NEEDED,
- TRADE_FAIL_FAR_AWAY,
- TRADE_FAIL_CHAR_NOT_EXISTS,
- TRADE_CANCELLED_ERROR,
- TRADE_CANCELLED_NAME,
- TRADE_CANCELLED_BUSY,
- TRADE_ERROR_UNKNOWN,
- TRADE_ADD_PARTNER_OVER_WEIGHT,
- TRADE_ADD_PARTNER_NO_SLOTS,
- TRADE_ADD_UNTRADABLE_ITEM,
- TRADE_ADD_ERROR,
- TRADE_CANCELLED,
- TRADE_COMPLETE,
- KICK_FAIL,
- KICK_SUCCEED,
- MVP_PLAYER,
- WHISPERS_IGNORED,
- WHISPERS_IGNORE_FAILED,
- WHISPERS_UNIGNORED,
- WHISPERS_UNIGNORE_FAILED,
- SKILL_FAIL_MESSAGE,
- PVP_OFF_GVG_OFF,
- PVP_ON,
- GVG_ON,
- PVP_ON_GVG_ON,
- PVP_UNKNOWN,
- PARTY_INVITE_PARTY_SAME_ACCOUNT,
- PARTY_INVITE_PARTY_BLOCKED_INVITE,
- PARTY_INVITE_PARTY_NOT_ONLINE,
- PET_CATCH_FAILED,
- PET_CATCH_SUCCESS,
- PET_CATCH_UNKNOWN,
- MERCENARY_EXPIRED,
- MERCENARY_KILLED,
- MERCENARY_FIRED,
- MERCENARY_RUN,
- MERCENARY_UNKNOWN,
- HOMUNCULUS_FEED_OK,
- HOMUNCULUS_FEED_FAIL,
- CARD_INSERT_FAILED,
- CARD_INSERT_SUCCESS,
- BANK_DEPOSIT_FAILED,
- BANK_WITHDRAW_FAILED,
- BUYING_STORE_CREATE_FAILED,
- BUYING_STORE_CREATE_FAILED_WEIGHT,
- BUYING_STORE_CREATE_EMPTY,
- BUYING_STORE_SELL_FAILED_MONEY_LIMIT,
- BUYING_STORE_SELL_FAILED_EMPTY,
- BUYING_STORE_SELL_FAILED,
- BUYING_STORE_SELLER_SELL_FAILED_DEAL,
- BUYING_STORE_SELLER_SELL_FAILED_AMOUNT,
- BUYING_STORE_SELLER_SELL_FAILED_BALANCE,
- BUYING_STORE_SELLER_SELL_FAILED,
- SEARCH_STORE_FAILED,
- SEARCH_STORE_FAILED_NO_STORES,
- SEARCH_STORE_FAILED_MANY_RESULTS,
- SEARCH_STORE_FAILED_CANT_SEARCH_ANYMORE,
- SEARCH_STORE_FAILED_CANT_SEARCH_YET,
- SEARCH_STORE_FAILED_NO_INFORMATION,
- PET_FEED_OK,
- PET_FEED_ERROR,
- MANNER_CHANGED,
- MANNER_POSITIVE_POINTS,
- MANNER_NEGATIVE_POINTS,
- ROOM_LIMIT_EXCEEDED,
- ROOM_ALREADY_EXISTS,
- ROOM_JOINED,
- ROOM_LEAVE,
- ROOM_KICKED,
- ROOM_ROLE_OWNER,
- ROOM_ERROR_FULL,
- ROOM_ERROR_WRONG_PASSWORD,
- ROOM_ERROR_KICKED,
- ROOM_ERROR_ZENY,
- ROOM_ERROR_LOW_LEVEL,
- ROOM_ERROR_HIGH_LEVEL,
- ROOM_ERROR_RACE,
- USE_ITEM_WAIT,
- MAIL_SEND_OK,
- MAIL_SEND_ERROR,
- MAIL_ATTACH_ITEM_ERROR,
- MAIL_ATTACH_MONEY_ERROR,
- MAIL_RETURN_ERROR,
- MAIL_RETURN_OK,
- MAIL_DELETE_ERROR,
- MAIL_DELETE_OK,
- MAIL_GET_ATTACH_OK,
- MAIL_GET_ATTACH_ERROR,
- MAIL_GET_ATTACH_TOO_MANY_ITEMS,
- NEW_MAIL,
- MAP_TYPE_BATTLEFIELD,
- RENTAL_TIME_LEFT,
- RENTAL_TIME_EXPIRED,
- REFINE_SUCCESS,
- REFINE_FAILURE,
- REFINE_DOWNGRADE,
- REFINE_UNKNOWN,
- CART_ADD_WEIGHT_ERROR,
- CART_ADD_COUNT_ERROR,
- BOUND_ITEM,
- SKILL_END_ALL_NEGATIVE_STATUS,
- SKILL_IMMUNITY_TO_ALL_STATUSES,
- SKILL_MAX_HP,
- SKILL_MAX_SP,
- SKILL_ALL_STATUS_PLUS_20,
- SKILL_ENCHANT_WEAPON_HOLY,
- SKILL_ENCHANT_ARMOR_HOLY,
- SKILL_DEF_PLUS_25,
- SKILL_ATTACK_PLUS_100,
- SKILL_FLEE_PLUS_50,
- SKILL_FULL_STRIP_FAILED,
- SKILL_MESSAGE_UNKNOWN,
- IGNORE_PLAYER_SUCCESS,
- IGNORE_PLAYER_FAILURE,
- IGNORE_PLAYER_TOO_MANY,
- IGNORE_PLAYER_UNKNOWN,
- UNIGNORE_PLAYER_SUCCESS,
- UNIGNORE_PLAYER_FAILURE,
- UNIGNORE_PLAYER_UNKNOWN,
- IGNORE_PLAYER_TYPE_UNKNOWN,
- PET_CATCH_PROCESS,
- DELETE_ITEM_NORMAL,
- DELETE_ITEM_SKILL_USE,
- DELETE_ITEM_FAIL_REFINE,
- DELETE_ITEM_MATERIAL_CHANGE,
- DELETE_ITEM_TO_STORAGE,
- DELETE_ITEM_TO_CART,
- DELETE_ITEM_SOLD,
- DELETE_ITEM_ANALYSIS,
- DELETE_ITEM_UNKNOWN,
- DELETE_ITEM_DROPPED,
- BEING_REMOVE_DIED,
- BEING_REMOVE_LOGGED_OUT,
- BEING_REMOVE_WARPED,
- BEING_REMOVE_TRICK_DEAD,
- BEING_REMOVE_UNKNOWN,
- DIVORCED,
- CALLED_PARTNER,
- CALLING_PARTNER,
- ADOPT_CHILD_ERROR_HAVE_BABY,
- ADOPT_CHILD_ERROR_LEVEL,
- ADOPT_CHILD_ERROR_BABY_MARRIED,
- SKILL_MEMO_SAVED,
- SKILL_MEMO_ERROR_LEVEL,
- SKILL_MEMO_ERROR_SKILL,
- BUY_TRADE_FAILED,
- VENDING_SOLD_ITEM,
- BUY_FAILED_NPC_NOT_FOUND,
- BUY_FAILED_SYSTEM_ERROR,
- BUY_FAILED_WRONG_ITEM,
- MAIL_NAME_VALIDATION_ERROR,
- MAIL_ATTACH_ITEM_WEIGHT_ERROR,
- MAIL_ATTACH_ITEM_FATAL_ERROR,
- MAIL_ATTACH_ITEM_NO_SPACE,
- MAIL_ATTACH_ITEM_NOT_TRADEABLE,
- MAIL_ATTACH_ITEM_UNKNOWN_ERROR,
- MAIL_REMOVE_ITEM_ERROR,
- MAIL_SEND_FATAL_ERROR,
- MAIL_SEND_COUNT_ERROR,
- MAIL_SEND_ITEM_ERROR,
- MAIL_SEND_RECEIVER_ERROR,
- MAIL_GET_ATTACH_FULL_ERROR,
- MAIL_GET_MONEY_OK,
- MAIL_GET_MONEY_ERROR,
- MAIL_GET_MONEY_LIMIT_ERROR,
-
- TYPE_END
- };
-} // namespace NotifyTypes
-#endif // ENUMS_RESOURCES_NOTIFYTYPES_H
diff --git a/src/enums/resources/questtype.h b/src/enums/resources/questtype.h
deleted file mode 100644
index 2140d040a..000000000
--- a/src/enums/resources/questtype.h
+++ /dev/null
@@ -1,37 +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 ENUMS_RESOURCES_QUESTTYPE_H
-#define ENUMS_RESOURCES_QUESTTYPE_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(QuestType)
-{
- TEXT = 0,
- NAME = 1,
- REWARD = 2,
- GIVER = 3,
- COORDINATES = 4,
- NPC = 5
-}
-enumEnd(QuestType);
-
-#endif // ENUMS_RESOURCES_QUESTTYPE_H
diff --git a/src/enums/resources/servercommandenable.h b/src/enums/resources/servercommandenable.h
deleted file mode 100644
index 4541eea75..000000000
--- a/src/enums/resources/servercommandenable.h
+++ /dev/null
@@ -1,37 +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 ENUMS_RESOURCES_SERVERCOMMANDENABLE_H
-#define ENUMS_RESOURCES_SERVERCOMMANDENABLE_H
-
-#include "localconsts.h"
-
-namespace ServerCommandEnable
-{
- enum Type
- {
- No = 0,
- Self = 1,
- Other = 2,
- Both = 3
- };
-} // namespace ServerCommandEnable
-
-#endif // ENUMS_RESOURCES_SERVERCOMMANDENABLE_H
diff --git a/src/enums/resources/servercommandtype.h b/src/enums/resources/servercommandtype.h
deleted file mode 100644
index 2b20c296f..000000000
--- a/src/enums/resources/servercommandtype.h
+++ /dev/null
@@ -1,44 +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 ENUMS_RESOURCES_SERVERCOMMANDTYPE_H
-#define ENUMS_RESOURCES_SERVERCOMMANDTYPE_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-#define servercommandFirst(name) name = 0,
-#define servercommand(name) name,
-#define servercommand2(name1, name2) name1,
-
-enumStart(ServerCommandType)
-{
-#include "resources/servercommands.inc"
- Max
-}
-enumEnd(ServerCommandType);
-
-#undef servercommandFirst
-#undef servercommand
-#undef servercommand2
-
-SERVERCOMMANDS_VOID
-#undef SERVERCOMMANDS_VOID
-
-#endif // ENUMS_RESOURCES_SERVERCOMMANDTYPE_H
diff --git a/src/enums/resources/serverpermissiontype.h b/src/enums/resources/serverpermissiontype.h
deleted file mode 100644
index 2de362ce9..000000000
--- a/src/enums/resources/serverpermissiontype.h
+++ /dev/null
@@ -1,41 +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 ENUMS_RESOURCES_SERVERPERMISSIONTYPE_H
-#define ENUMS_RESOURCES_SERVERPERMISSIONTYPE_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-#define serverpermissionFirst(name) name = 0,
-#define serverpermission(name) name,
-
-enumStart(ServerPermissionType)
-{
-#include "resources/serverpermissions.inc"
- Max
-}
-enumEnd(ServerPermissionType);
-
-#undef serverpermissionFirst
-#undef serverpermission
-
-SERVERPERMISSION_VOID
-#undef SERVERPERMISSION_VOID
-#endif // ENUMS_RESOURCES_SERVERPERMISSIONTYPE_H
diff --git a/src/enums/resources/skill/casttype.h b/src/enums/resources/skill/casttype.h
deleted file mode 100644
index b73cd138d..000000000
--- a/src/enums/resources/skill/casttype.h
+++ /dev/null
@@ -1,35 +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 ENUMS_RESOURCES_CASTTYPE_H
-#define ENUMS_RESOURCES_CASTTYPE_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(CastType)
-{
- Default = 0,
- Target = 1,
- Position = 2,
- Self = 3
-}
-enumEnd(CastType);
-
-#endif // ENUMS_RESOURCES_CASTTYPE_H
diff --git a/src/enums/resources/skill/skillowner.h b/src/enums/resources/skill/skillowner.h
deleted file mode 100644
index 01938bb30..000000000
--- a/src/enums/resources/skill/skillowner.h
+++ /dev/null
@@ -1,35 +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 ENUMS_RESOURCES_SKILL_SKILLOWNER_H
-#define ENUMS_RESOURCES_SKILL_SKILLOWNER_H
-
-namespace SkillOwner
-{
- enum Type
- {
- Player = 0,
- Mercenary = 1,
- Homunculus = 2,
- Guild = 3
- };
-} // namespace SkillOwner
-
-#endif // ENUMS_RESOURCES_SKILL_SKILLOWNER_H
diff --git a/src/enums/resources/skill/skillsettype.h b/src/enums/resources/skill/skillsettype.h
deleted file mode 100644
index d574f6cbe..000000000
--- a/src/enums/resources/skill/skillsettype.h
+++ /dev/null
@@ -1,33 +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 ENUMS_RESOURCES_SKILL_SKILLSETTYPE_H
-#define ENUMS_RESOURCES_SKILL_SKILLSETTYPE_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(SkillSetType)
-{
- VerticalList = 0,
- Rectangle = 1
-}
-enumEnd(SkillSetType);
-
-#endif // ENUMS_RESOURCES_SKILL_SKILLSETTYPE_H
diff --git a/src/enums/resources/skill/skilltype.h b/src/enums/resources/skill/skilltype.h
deleted file mode 100644
index 3818adec6..000000000
--- a/src/enums/resources/skill/skilltype.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 ENUMS_RESOURCES_SKILL_SKILLTYPE_H
-#define ENUMS_RESOURCES_SKILL_SKILLTYPE_H
-
-// aka inf
-namespace SkillType
-{
- enum SkillType
- {
- Unknown = 0,
- Attack = 1,
- Ground = 2,
- Self = 4,
- Unused = 8,
- Support = 16,
- TargetTrap = 32
- };
-} // namespace SkillType
-
-#endif // ENUMS_RESOURCES_SKILL_SKILLTYPE_H
diff --git a/src/enums/resources/skill/skilltype2.h b/src/enums/resources/skill/skilltype2.h
deleted file mode 100644
index 07f392b48..000000000
--- a/src/enums/resources/skill/skilltype2.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 ENUMS_RESOURCES_SKILL_SKILLTYPE2_H
-#define ENUMS_RESOURCES_SKILL_SKILLTYPE2_H
-
-// aka inf2
-namespace SkillType2
-{
- enum SkillType2
- {
- Unknown = 0,
- Quest = 1,
- Npc = 2,
- Wedding = 4,
- Spirit = 8,
- Guild = 16,
- SongDance = 32,
- Ensemble = 64,
- Trap = 128,
- TargetSelf = 256,
- NoTargetSelf = 512,
- PartyOnly = 1024,
- GuildOnly = 2048,
- NoEnemy = 4096,
- NoLandProtector = 8192,
- Chorus = 16384,
- FreeCastNormal = 32768,
- FreeCastReduced = 65536,
- FreeCastAny = 98304
- };
-} // namespace SkillType2
-
-#endif // ENUMS_RESOURCES_SKILL_SKILLTYPE2_H
diff --git a/src/enums/resources/spritedirection.h b/src/enums/resources/spritedirection.h
deleted file mode 100644
index 935c05bd6..000000000
--- a/src/enums/resources/spritedirection.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 ENUMS_RESOURCES_SPRITEDIRECTION_H
-#define ENUMS_RESOURCES_SPRITEDIRECTION_H
-
-namespace SpriteDirection
-{
- enum Type
- {
- DEFAULT = 0,
- UP = 1,
- DOWN = 2,
- LEFT = 3,
- RIGHT = 4,
- UPLEFT = 5,
- UPRIGHT = 6,
- DOWNLEFT = 7,
- DOWNRIGHT = 8,
- INVALID
- };
-} // namespace SpriteDirection
-
-#endif // ENUMS_RESOURCES_SPRITEDIRECTION_H
diff --git a/src/enums/screendensity.h b/src/enums/screendensity.h
deleted file mode 100644
index 42e8f277d..000000000
--- a/src/enums/screendensity.h
+++ /dev/null
@@ -1,35 +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 ENUMS_SCREENDENSITY_H
-#define ENUMS_SCREENDENSITY_H
-
-enum ScreenDensity
-{
- DENSITY_UNKNOWN = -1,
- DENSITY_LOW = 0,
- DENSITY_MEDIUM = 1,
- DENSITY_TV = 2,
- DENSITY_HIGH = 3,
- DENSITY_XHIGH = 4,
- DENSITY_XXHIGH = 5
-};
-
-#endif // ENUMS_SCREENDENSITY_H
diff --git a/src/enums/simpletypes/advanced.h b/src/enums/simpletypes/advanced.h
deleted file mode 100644
index 65533c1a9..000000000
--- a/src/enums/simpletypes/advanced.h
+++ /dev/null
@@ -1,33 +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 ENUMS_SIMPLETYPES_ADVANCED_H
-#define ENUMS_SIMPLETYPES_ADVANCED_H
-
-#include "enums/simpletypes/booldefines.h"
-
-PRAGMA6(GCC diagnostic push)
-PRAGMA6(GCC diagnostic ignored "-Wunused-const-variable")
-
-defBoolEnum(Advanced);
-
-PRAGMA6(GCC diagnostic pop)
-
-#endif // ENUMS_SIMPLETYPES_ADVANCED_H
diff --git a/src/enums/simpletypes/allowquit.h b/src/enums/simpletypes/allowquit.h
deleted file mode 100644
index c18b87461..000000000
--- a/src/enums/simpletypes/allowquit.h
+++ /dev/null
@@ -1,33 +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 ENUMS_SIMPLETYPES_ALLOWQUIT_H
-#define ENUMS_SIMPLETYPES_ALLOWQUIT_H
-
-#include "enums/simpletypes/booldefines.h"
-
-PRAGMA6(GCC diagnostic push)
-PRAGMA6(GCC diagnostic ignored "-Wunused-const-variable")
-
-defBoolEnum(AllowQuit);
-
-PRAGMA6(GCC diagnostic pop)
-
-#endif // ENUMS_SIMPLETYPES_ALLOWQUIT_H
diff --git a/src/enums/simpletypes/allowsort.h b/src/enums/simpletypes/allowsort.h
deleted file mode 100644
index b6785c364..000000000
--- a/src/enums/simpletypes/allowsort.h
+++ /dev/null
@@ -1,33 +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 ENUMS_SIMPLETYPES_ALLOWSORT_H
-#define ENUMS_SIMPLETYPES_ALLOWSORT_H
-
-#include "enums/simpletypes/booldefines.h"
-
-PRAGMA6(GCC diagnostic push)
-PRAGMA6(GCC diagnostic ignored "-Wunused-const-variable")
-
-defBoolEnum(AllowSort);
-
-PRAGMA6(GCC diagnostic pop)
-
-#endif // ENUMS_SIMPLETYPES_ALLOWSORT_H
diff --git a/src/enums/simpletypes/allplayers.h b/src/enums/simpletypes/allplayers.h
deleted file mode 100644
index 343018808..000000000
--- a/src/enums/simpletypes/allplayers.h
+++ /dev/null
@@ -1,33 +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 ENUMS_SIMPLETYPES_ALLPLAYERS_H
-#define ENUMS_SIMPLETYPES_ALLPLAYERS_H
-
-#include "enums/simpletypes/booldefines.h"
-
-PRAGMA6(GCC diagnostic push)
-PRAGMA6(GCC diagnostic ignored "-Wunused-const-variable")
-
-defBoolEnum(AllPlayers);
-
-PRAGMA6(GCC diagnostic pop)
-
-#endif // ENUMS_SIMPLETYPES_ALLPLAYERS_H
diff --git a/src/enums/simpletypes/append.h b/src/enums/simpletypes/append.h
deleted file mode 100644
index 14c078d07..000000000
--- a/src/enums/simpletypes/append.h
+++ /dev/null
@@ -1,33 +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 ENUMS_SIMPLETYPES_APPEND_H
-#define ENUMS_SIMPLETYPES_APPEND_H
-
-#include "enums/simpletypes/booldefines.h"
-
-PRAGMA6(GCC diagnostic push)
-PRAGMA6(GCC diagnostic ignored "-Wunused-const-variable")
-
-defBoolEnum(Append);
-
-PRAGMA6(GCC diagnostic pop)
-
-#endif // ENUMS_SIMPLETYPES_APPEND_H
diff --git a/src/enums/simpletypes/autorelease.h b/src/enums/simpletypes/autorelease.h
deleted file mode 100644
index aabb53fdd..000000000
--- a/src/enums/simpletypes/autorelease.h
+++ /dev/null
@@ -1,33 +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 ENUMS_SIMPLETYPES_AUTORELEASE_H
-#define ENUMS_SIMPLETYPES_AUTORELEASE_H
-
-#include "enums/simpletypes/booldefines.h"
-
-PRAGMA6(GCC diagnostic push)
-PRAGMA6(GCC diagnostic ignored "-Wunused-const-variable")
-
-defBoolEnum(AutoRelease);
-
-PRAGMA6(GCC diagnostic pop)
-
-#endif // ENUMS_SIMPLETYPES_AUTORELEASE_H
diff --git a/src/enums/simpletypes/autotarget.h b/src/enums/simpletypes/autotarget.h
deleted file mode 100644
index f1e4c8f9b..000000000
--- a/src/enums/simpletypes/autotarget.h
+++ /dev/null
@@ -1,33 +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 ENUMS_SIMPLETYPES_AUTOTARGET_H
-#define ENUMS_SIMPLETYPES_AUTOTARGET_H
-
-#include "enums/simpletypes/booldefines.h"
-
-PRAGMA6(GCC diagnostic push)
-PRAGMA6(GCC diagnostic ignored "-Wunused-const-variable")
-
-defBoolEnum(AutoTarget);
-
-PRAGMA6(GCC diagnostic pop)
-
-#endif // ENUMS_SIMPLETYPES_AUTOTARGET_H
diff --git a/src/enums/simpletypes/beingid.h b/src/enums/simpletypes/beingid.h
deleted file mode 100644
index 5fda30b8f..000000000
--- a/src/enums/simpletypes/beingid.h
+++ /dev/null
@@ -1,34 +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 ENUMS_SIMPLETYPES_BEINGID_H
-#define ENUMS_SIMPLETYPES_BEINGID_H
-
-#include "enums/simpletypes/intdefines.h"
-
-PRAGMA6(GCC diagnostic push)
-PRAGMA6(GCC diagnostic ignored "-Wunused-const-variable")
-
-defIntEnum(BeingId, int);
-defIntEnumNeg(BeingId);
-
-PRAGMA6(GCC diagnostic pop)
-
-#endif // ENUMS_SIMPLETYPES_BEINGID_H
diff --git a/src/enums/simpletypes/beingtypeid.h b/src/enums/simpletypes/beingtypeid.h
deleted file mode 100644
index 1294048c0..000000000
--- a/src/enums/simpletypes/beingtypeid.h
+++ /dev/null
@@ -1,34 +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 ENUMS_SIMPLETYPES_BEINGTYPEID_H
-#define ENUMS_SIMPLETYPES_BEINGTYPEID_H
-
-#include "enums/simpletypes/intdefines.h"
-
-PRAGMA6(GCC diagnostic push)
-PRAGMA6(GCC diagnostic ignored "-Wunused-const-variable")
-
-defIntEnum(BeingTypeId, int);
-defIntEnumNeg(BeingTypeId);
-
-PRAGMA6(GCC diagnostic pop)
-
-#endif // ENUMS_SIMPLETYPES_BEINGTYPEID_H
diff --git a/src/enums/simpletypes/booldefines.h b/src/enums/simpletypes/booldefines.h
deleted file mode 100644
index 52aa81fd5..000000000
--- a/src/enums/simpletypes/booldefines.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 ENUMS_SIMPLETYPES_BOOLDEFINES_H
-#define ENUMS_SIMPLETYPES_BOOLDEFINES_H
-
-#include "localconsts.h"
-
-
-
-#ifdef ADVGCC
-
-#define defBoolEnum(name) \
- enum class name : bool \
- { \
- MFalse = false, \
- MTrue = true \
- }; \
- const name name##_true = name::MTrue; \
- const name name##_false = name::MFalse \
-
-#define fromBool(val, name) \
- (val) ? name::MTrue : name::MFalse
-
-#else // ADVGCC
-
-#define defBoolEnum(name) \
- const bool name##_true = true; \
- const bool name##_false = false; \
- typedef bool name
-#define fromBool(val, name) \
- (val) ? true : false
-
-#endif // ADVGCC
-
-#endif // ENUMS_SIMPLETYPES_BOOLDEFINES_H
diff --git a/src/enums/simpletypes/damaged.h b/src/enums/simpletypes/damaged.h
deleted file mode 100644
index 2cda3d2a0..000000000
--- a/src/enums/simpletypes/damaged.h
+++ /dev/null
@@ -1,33 +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 ENUMS_SIMPLETYPES_DAMAGED_H
-#define ENUMS_SIMPLETYPES_DAMAGED_H
-
-#include "enums/simpletypes/booldefines.h"
-
-PRAGMA6(GCC diagnostic push)
-PRAGMA6(GCC diagnostic ignored "-Wunused-const-variable")
-
-defBoolEnum(Damaged);
-
-PRAGMA6(GCC diagnostic pop)
-
-#endif // ENUMS_SIMPLETYPES_DAMAGED_H
diff --git a/src/enums/simpletypes/donotalign.h b/src/enums/simpletypes/donotalign.h
deleted file mode 100644
index fd0030de0..000000000
--- a/src/enums/simpletypes/donotalign.h
+++ /dev/null
@@ -1,33 +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 ENUMS_SIMPLETYPES_DONOTALIGN_H
-#define ENUMS_SIMPLETYPES_DONOTALIGN_H
-
-#include "enums/simpletypes/booldefines.h"
-
-PRAGMA6(GCC diagnostic push)
-PRAGMA6(GCC diagnostic ignored "-Wunused-const-variable")
-
-defBoolEnum(DoNotAlign);
-
-PRAGMA6(GCC diagnostic pop)
-
-#endif // ENUMS_SIMPLETYPES_DONOTALIGN_H
diff --git a/src/enums/simpletypes/enable.h b/src/enums/simpletypes/enable.h
deleted file mode 100644
index 47e70bae5..000000000
--- a/src/enums/simpletypes/enable.h
+++ /dev/null
@@ -1,33 +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 ENUMS_SIMPLETYPES_ENABLE_H
-#define ENUMS_SIMPLETYPES_ENABLE_H
-
-#include "enums/simpletypes/booldefines.h"
-
-PRAGMA6(GCC diagnostic push)
-PRAGMA6(GCC diagnostic ignored "-Wunused-const-variable")
-
-defBoolEnum(Enable);
-
-PRAGMA6(GCC diagnostic pop)
-
-#endif // ENUMS_SIMPLETYPES_ENABLE_H
diff --git a/src/enums/simpletypes/enumdefines.h b/src/enums/simpletypes/enumdefines.h
deleted file mode 100644
index a1b5401ff..000000000
--- a/src/enums/simpletypes/enumdefines.h
+++ /dev/null
@@ -1,62 +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 ENUMS_SIMPLETYPES_ENUMDEFINES_H
-#define ENUMS_SIMPLETYPES_ENUMDEFINES_H
-
-#include "localconsts.h"
-
-#ifdef ADVGCC
-
-#define enumStart(name) enum class name
-#define enumStartT(name, type) enum class name : type
-#define enumEnd(name) ; \
- typedef name name##T
-
-#else // ADVGCC
-
-#define enumStart(name) \
- namespace name \
- { \
- enum T
-
-#define enumStartT(name, type) \
- namespace name \
- { \
- enum T
-
-#define enumEnd(name) \
- ;\
- } \
- typedef name::T name##T
-
-#endif // ADVGCC
-
-#define enum2Start(name) \
- namespace name \
- { \
- enum T
-
-#define enum2End(name) \
- ;\
- } \
- typedef name::T name##T
-
-#endif // ENUMS_SIMPLETYPES_ENUMDEFINES_H
diff --git a/src/enums/simpletypes/equipm.h b/src/enums/simpletypes/equipm.h
deleted file mode 100644
index fcdd503d1..000000000
--- a/src/enums/simpletypes/equipm.h
+++ /dev/null
@@ -1,33 +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 ENUMS_SIMPLETYPES_EQUIPM_H
-#define ENUMS_SIMPLETYPES_EQUIPM_H
-
-#include "enums/simpletypes/booldefines.h"
-
-PRAGMA6(GCC diagnostic push)
-PRAGMA6(GCC diagnostic ignored "-Wunused-const-variable")
-
-defBoolEnum(Equipm);
-
-PRAGMA6(GCC diagnostic pop)
-
-#endif // ENUMS_SIMPLETYPES_EQUIPM_H
diff --git a/src/enums/simpletypes/equipped.h b/src/enums/simpletypes/equipped.h
deleted file mode 100644
index 7aea246d6..000000000
--- a/src/enums/simpletypes/equipped.h
+++ /dev/null
@@ -1,33 +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 ENUMS_SIMPLETYPES_EQUIPPED_H
-#define ENUMS_SIMPLETYPES_EQUIPPED_H
-
-#include "enums/simpletypes/booldefines.h"
-
-PRAGMA6(GCC diagnostic push)
-PRAGMA6(GCC diagnostic ignored "-Wunused-const-variable")
-
-defBoolEnum(Equipped);
-
-PRAGMA6(GCC diagnostic pop)
-
-#endif // ENUMS_SIMPLETYPES_EQUIPPED_H
diff --git a/src/enums/simpletypes/favorite.h b/src/enums/simpletypes/favorite.h
deleted file mode 100644
index 8748461f7..000000000
--- a/src/enums/simpletypes/favorite.h
+++ /dev/null
@@ -1,33 +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 ENUMS_SIMPLETYPES_FAVORITE_H
-#define ENUMS_SIMPLETYPES_FAVORITE_H
-
-#include "enums/simpletypes/booldefines.h"
-
-PRAGMA6(GCC diagnostic push)
-PRAGMA6(GCC diagnostic ignored "-Wunused-const-variable")
-
-defBoolEnum(Favorite);
-
-PRAGMA6(GCC diagnostic pop)
-
-#endif // ENUMS_SIMPLETYPES_FAVORITE_H
diff --git a/src/enums/simpletypes/forcedisplay.h b/src/enums/simpletypes/forcedisplay.h
deleted file mode 100644
index be3943b04..000000000
--- a/src/enums/simpletypes/forcedisplay.h
+++ /dev/null
@@ -1,33 +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 ENUMS_SIMPLETYPES_FORCEDISPLAY_H
-#define ENUMS_SIMPLETYPES_FORCEDISPLAY_H
-
-#include "enums/simpletypes/booldefines.h"
-
-PRAGMA6(GCC diagnostic push)
-PRAGMA6(GCC diagnostic ignored "-Wunused-const-variable")
-
-defBoolEnum(ForceDisplay);
-
-PRAGMA6(GCC diagnostic pop)
-
-#endif // ENUMS_SIMPLETYPES_FORCEDISPLAY_H
diff --git a/src/enums/simpletypes/forcequantity.h b/src/enums/simpletypes/forcequantity.h
deleted file mode 100644
index 7363c7070..000000000
--- a/src/enums/simpletypes/forcequantity.h
+++ /dev/null
@@ -1,33 +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 ENUMS_SIMPLETYPES_FORCEQUANTITY_H
-#define ENUMS_SIMPLETYPES_FORCEQUANTITY_H
-
-#include "enums/simpletypes/booldefines.h"
-
-PRAGMA6(GCC diagnostic push)
-PRAGMA6(GCC diagnostic ignored "-Wunused-const-variable")
-
-defBoolEnum(ForceQuantity);
-
-PRAGMA6(GCC diagnostic pop)
-
-#endif // ENUMS_SIMPLETYPES_FORCEQUANTITY_H
diff --git a/src/enums/simpletypes/identified.h b/src/enums/simpletypes/identified.h
deleted file mode 100644
index 6067655bf..000000000
--- a/src/enums/simpletypes/identified.h
+++ /dev/null
@@ -1,33 +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 ENUMS_SIMPLETYPES_IDENTIFIED_H
-#define ENUMS_SIMPLETYPES_IDENTIFIED_H
-
-#include "enums/simpletypes/booldefines.h"
-
-PRAGMA6(GCC diagnostic push)
-PRAGMA6(GCC diagnostic ignored "-Wunused-const-variable")
-
-defBoolEnum(Identified);
-
-PRAGMA6(GCC diagnostic pop)
-
-#endif // ENUMS_SIMPLETYPES_IDENTIFIED_H
diff --git a/src/enums/simpletypes/ignorerecord.h b/src/enums/simpletypes/ignorerecord.h
deleted file mode 100644
index b781116d4..000000000
--- a/src/enums/simpletypes/ignorerecord.h
+++ /dev/null
@@ -1,33 +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 ENUMS_SIMPLETYPES_IGNORERECORD_H
-#define ENUMS_SIMPLETYPES_IGNORERECORD_H
-
-#include "enums/simpletypes/booldefines.h"
-
-PRAGMA6(GCC diagnostic push)
-PRAGMA6(GCC diagnostic ignored "-Wunused-const-variable")
-
-defBoolEnum(IgnoreRecord);
-
-PRAGMA6(GCC diagnostic pop)
-
-#endif // ENUMS_SIMPLETYPES_IGNORERECORD_H
diff --git a/src/enums/simpletypes/intdefines.h b/src/enums/simpletypes/intdefines.h
deleted file mode 100644
index 2bae4b02c..000000000
--- a/src/enums/simpletypes/intdefines.h
+++ /dev/null
@@ -1,51 +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 ENUMS_SIMPLETYPES_INTDEFINES_H
-#define ENUMS_SIMPLETYPES_INTDEFINES_H
-
-#include "localconsts.h"
-
-#ifdef ADVGCC
-
-#define defIntEnum(name, type) \
- enum class name : type \
- { \
- }; \
- const name name##_zero = static_cast<name>(0); \
- const name name##_one = static_cast<name>(1)
-
-#define fromInt(val, name) static_cast<name>(val)
-#define toInt(val, name) static_cast<name>(val)
-#define defIntEnumNeg(name) const name name##_negOne = static_cast<name>(-1)
-
-#else // ADVGCC
-
-#define defIntEnum(name, type) \
- typedef type name; \
- const name name##_zero = 0; \
- const name name##_one = 1
-#define fromInt(val, name) static_cast<name>(val)
-#define toInt(val, name) (val)
-#define defIntEnumNeg(name) const name name##_negOne = -1
-
-#endif // ADVGCC
-
-#endif // ENUMS_SIMPLETYPES_INTDEFINES_H
diff --git a/src/enums/simpletypes/issell.h b/src/enums/simpletypes/issell.h
deleted file mode 100644
index ba4c9a9cc..000000000
--- a/src/enums/simpletypes/issell.h
+++ /dev/null
@@ -1,33 +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 ENUMS_SIMPLETYPES_ISSELL_H
-#define ENUMS_SIMPLETYPES_ISSELL_H
-
-#include "enums/simpletypes/booldefines.h"
-
-PRAGMA6(GCC diagnostic push)
-PRAGMA6(GCC diagnostic ignored "-Wunused-const-variable")
-
-defBoolEnum(IsSell);
-
-PRAGMA6(GCC diagnostic pop)
-
-#endif // ENUMS_SIMPLETYPES_ISSELL_H
diff --git a/src/enums/simpletypes/isstart.h b/src/enums/simpletypes/isstart.h
deleted file mode 100644
index 7b133173d..000000000
--- a/src/enums/simpletypes/isstart.h
+++ /dev/null
@@ -1,33 +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 ENUMS_SIMPLETYPES_ISSTART_H
-#define ENUMS_SIMPLETYPES_ISSTART_H
-
-#include "enums/simpletypes/booldefines.h"
-
-PRAGMA6(GCC diagnostic push)
-PRAGMA6(GCC diagnostic ignored "-Wunused-const-variable")
-
-defBoolEnum(IsStart);
-
-PRAGMA6(GCC diagnostic pop)
-
-#endif // ENUMS_SIMPLETYPES_ISSTART_H
diff --git a/src/enums/simpletypes/itemcolor.h b/src/enums/simpletypes/itemcolor.h
deleted file mode 100644
index d47d30fb1..000000000
--- a/src/enums/simpletypes/itemcolor.h
+++ /dev/null
@@ -1,33 +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 ENUMS_SIMPLETYPES_ITEMCOLOR_H
-#define ENUMS_SIMPLETYPES_ITEMCOLOR_H
-
-#include "enums/simpletypes/intdefines.h"
-
-PRAGMA6(GCC diagnostic push)
-PRAGMA6(GCC diagnostic ignored "-Wunused-const-variable")
-
-defIntEnum(ItemColor, uint16_t);
-
-PRAGMA6(GCC diagnostic pop)
-
-#endif // ENUMS_SIMPLETYPES_ITEMCOLOR_H
diff --git a/src/enums/simpletypes/keep.h b/src/enums/simpletypes/keep.h
deleted file mode 100644
index 6be7a9800..000000000
--- a/src/enums/simpletypes/keep.h
+++ /dev/null
@@ -1,33 +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 ENUMS_SIMPLETYPES_KEEP_H
-#define ENUMS_SIMPLETYPES_KEEP_H
-
-#include "enums/simpletypes/booldefines.h"
-
-PRAGMA6(GCC diagnostic push)
-PRAGMA6(GCC diagnostic ignored "-Wunused-const-variable")
-
-defBoolEnum(Keep);
-
-PRAGMA6(GCC diagnostic pop)
-
-#endif // ENUMS_SIMPLETYPES_KEEP_H
diff --git a/src/enums/simpletypes/losefocusontab.h b/src/enums/simpletypes/losefocusontab.h
deleted file mode 100644
index 5068631a0..000000000
--- a/src/enums/simpletypes/losefocusontab.h
+++ /dev/null
@@ -1,33 +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 ENUMS_SIMPLETYPES_LOSEFOCUSONTAB_H
-#define ENUMS_SIMPLETYPES_LOSEFOCUSONTAB_H
-
-#include "enums/simpletypes/booldefines.h"
-
-PRAGMA6(GCC diagnostic push)
-PRAGMA6(GCC diagnostic ignored "-Wunused-const-variable")
-
-defBoolEnum(LoseFocusOnTab);
-
-PRAGMA6(GCC diagnostic pop)
-
-#endif // ENUMS_SIMPLETYPES_LOSEFOCUSONTAB_H
diff --git a/src/enums/simpletypes/mainconfig.h b/src/enums/simpletypes/mainconfig.h
deleted file mode 100644
index 03ef60113..000000000
--- a/src/enums/simpletypes/mainconfig.h
+++ /dev/null
@@ -1,33 +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 ENUMS_SIMPLETYPES_MAINCONFIG_H
-#define ENUMS_SIMPLETYPES_MAINCONFIG_H
-
-#include "enums/simpletypes/booldefines.h"
-
-PRAGMA6(GCC diagnostic push)
-PRAGMA6(GCC diagnostic ignored "-Wunused-const-variable")
-
-defBoolEnum(MainConfig);
-
-PRAGMA6(GCC diagnostic pop)
-
-#endif // ENUMS_SIMPLETYPES_MAINCONFIG_H
diff --git a/src/enums/simpletypes/modal.h b/src/enums/simpletypes/modal.h
deleted file mode 100644
index 04026ac85..000000000
--- a/src/enums/simpletypes/modal.h
+++ /dev/null
@@ -1,33 +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 ENUMS_SIMPLETYPES_MODAL_H
-#define ENUMS_SIMPLETYPES_MODAL_H
-
-#include "enums/simpletypes/booldefines.h"
-
-PRAGMA6(GCC diagnostic push)
-PRAGMA6(GCC diagnostic ignored "-Wunused-const-variable")
-
-defBoolEnum(Modal);
-
-PRAGMA6(GCC diagnostic pop)
-
-#endif // ENUMS_SIMPLETYPES_MODAL_H
diff --git a/src/enums/simpletypes/modifiable.h b/src/enums/simpletypes/modifiable.h
deleted file mode 100644
index 9ec47f1b7..000000000
--- a/src/enums/simpletypes/modifiable.h
+++ /dev/null
@@ -1,33 +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 ENUMS_SIMPLETYPES_MODIFIABLE_H
-#define ENUMS_SIMPLETYPES_MODIFIABLE_H
-
-#include "enums/simpletypes/booldefines.h"
-
-PRAGMA6(GCC diagnostic push)
-PRAGMA6(GCC diagnostic ignored "-Wunused-const-variable")
-
-defBoolEnum(Modifiable);
-
-PRAGMA6(GCC diagnostic pop)
-
-#endif // ENUMS_SIMPLETYPES_MODIFIABLE_H
diff --git a/src/enums/simpletypes/move.h b/src/enums/simpletypes/move.h
deleted file mode 100644
index 32044e94b..000000000
--- a/src/enums/simpletypes/move.h
+++ /dev/null
@@ -1,33 +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 ENUMS_SIMPLETYPES_MOVE_H
-#define ENUMS_SIMPLETYPES_MOVE_H
-
-#include "enums/simpletypes/booldefines.h"
-
-PRAGMA6(GCC diagnostic push)
-PRAGMA6(GCC diagnostic ignored "-Wunused-const-variable")
-
-defBoolEnum(Move);
-
-PRAGMA6(GCC diagnostic pop)
-
-#endif // ENUMS_SIMPLETYPES_MOVE_H
diff --git a/src/enums/simpletypes/notify.h b/src/enums/simpletypes/notify.h
deleted file mode 100644
index 8244bb297..000000000
--- a/src/enums/simpletypes/notify.h
+++ /dev/null
@@ -1,33 +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 ENUMS_SIMPLETYPES_NOTIFY_H
-#define ENUMS_SIMPLETYPES_NOTIFY_H
-
-#include "enums/simpletypes/booldefines.h"
-
-PRAGMA6(GCC diagnostic push)
-PRAGMA6(GCC diagnostic ignored "-Wunused-const-variable")
-
-defBoolEnum(Notify);
-
-PRAGMA6(GCC diagnostic pop)
-
-#endif // ENUMS_SIMPLETYPES_NOTIFY_H
diff --git a/src/enums/simpletypes/npcnames.h b/src/enums/simpletypes/npcnames.h
deleted file mode 100644
index 0135a131a..000000000
--- a/src/enums/simpletypes/npcnames.h
+++ /dev/null
@@ -1,33 +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 ENUMS_SIMPLETYPES_NPCNAMES_H
-#define ENUMS_SIMPLETYPES_NPCNAMES_H
-
-#include "enums/simpletypes/booldefines.h"
-
-PRAGMA6(GCC diagnostic push)
-PRAGMA6(GCC diagnostic ignored "-Wunused-const-variable")
-
-defBoolEnum(NpcNames);
-
-PRAGMA6(GCC diagnostic pop)
-
-#endif // ENUMS_SIMPLETYPES_NPCNAMES_H
diff --git a/src/enums/simpletypes/online.h b/src/enums/simpletypes/online.h
deleted file mode 100644
index 9c182c1a5..000000000
--- a/src/enums/simpletypes/online.h
+++ /dev/null
@@ -1,33 +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 ENUMS_SIMPLETYPES_ONLINE_H
-#define ENUMS_SIMPLETYPES_ONLINE_H
-
-#include "enums/simpletypes/booldefines.h"
-
-PRAGMA6(GCC diagnostic push)
-PRAGMA6(GCC diagnostic ignored "-Wunused-const-variable")
-
-defBoolEnum(Online);
-
-PRAGMA6(GCC diagnostic pop)
-
-#endif // ENUMS_SIMPLETYPES_ONLINE_H
diff --git a/src/enums/simpletypes/onthefly.h b/src/enums/simpletypes/onthefly.h
deleted file mode 100644
index 9fff4b144..000000000
--- a/src/enums/simpletypes/onthefly.h
+++ /dev/null
@@ -1,33 +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 ENUMS_SIMPLETYPES_ONTHEFLY_H
-#define ENUMS_SIMPLETYPES_ONTHEFLY_H
-
-#include "enums/simpletypes/booldefines.h"
-
-PRAGMA6(GCC diagnostic push)
-PRAGMA6(GCC diagnostic ignored "-Wunused-const-variable")
-
-defBoolEnum(OnTheFly);
-
-PRAGMA6(GCC diagnostic pop)
-
-#endif // ENUMS_SIMPLETYPES_ONTHEFLY_H
diff --git a/src/enums/simpletypes/opaque.h b/src/enums/simpletypes/opaque.h
deleted file mode 100644
index 1df5d3796..000000000
--- a/src/enums/simpletypes/opaque.h
+++ /dev/null
@@ -1,33 +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 ENUMS_SIMPLETYPES_OPAQUE_H
-#define ENUMS_SIMPLETYPES_OPAQUE_H
-
-#include "enums/simpletypes/booldefines.h"
-
-PRAGMA6(GCC diagnostic push)
-PRAGMA6(GCC diagnostic ignored "-Wunused-const-variable")
-
-defBoolEnum(Opaque);
-
-PRAGMA6(GCC diagnostic pop)
-
-#endif // ENUMS_SIMPLETYPES_OPAQUE_H
diff --git a/src/enums/simpletypes/protected.h b/src/enums/simpletypes/protected.h
deleted file mode 100644
index d14db96c8..000000000
--- a/src/enums/simpletypes/protected.h
+++ /dev/null
@@ -1,33 +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 ENUMS_SIMPLETYPES_PROTECTED_H
-#define ENUMS_SIMPLETYPES_PROTECTED_H
-
-#include "enums/simpletypes/booldefines.h"
-
-PRAGMA6(GCC diagnostic push)
-PRAGMA6(GCC diagnostic ignored "-Wunused-const-variable")
-
-defBoolEnum(Protected);
-
-PRAGMA6(GCC diagnostic pop)
-
-#endif // ENUMS_SIMPLETYPES_PROTECTED_H
diff --git a/src/enums/simpletypes/separator.h b/src/enums/simpletypes/separator.h
deleted file mode 100644
index 2969d03e9..000000000
--- a/src/enums/simpletypes/separator.h
+++ /dev/null
@@ -1,33 +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 ENUMS_SIMPLETYPES_SEPARATOR_H
-#define ENUMS_SIMPLETYPES_SEPARATOR_H
-
-#include "enums/simpletypes/booldefines.h"
-
-PRAGMA6(GCC diagnostic push)
-PRAGMA6(GCC diagnostic ignored "-Wunused-const-variable")
-
-defBoolEnum(Separator);
-
-PRAGMA6(GCC diagnostic pop)
-
-#endif // ENUMS_SIMPLETYPES_SEPARATOR_H
diff --git a/src/enums/simpletypes/sfx.h b/src/enums/simpletypes/sfx.h
deleted file mode 100644
index c46fb67b8..000000000
--- a/src/enums/simpletypes/sfx.h
+++ /dev/null
@@ -1,33 +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 ENUMS_SIMPLETYPES_SFX_H
-#define ENUMS_SIMPLETYPES_SFX_H
-
-#include "enums/simpletypes/booldefines.h"
-
-PRAGMA6(GCC diagnostic push)
-PRAGMA6(GCC diagnostic ignored "-Wunused-const-variable")
-
-defBoolEnum(Sfx);
-
-PRAGMA6(GCC diagnostic pop)
-
-#endif // ENUMS_SIMPLETYPES_SFX_H
diff --git a/src/enums/simpletypes/showcenter.h b/src/enums/simpletypes/showcenter.h
deleted file mode 100644
index bbf5206eb..000000000
--- a/src/enums/simpletypes/showcenter.h
+++ /dev/null
@@ -1,33 +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 ENUMS_SIMPLETYPES_SHOWCENTER_H
-#define ENUMS_SIMPLETYPES_SHOWCENTER_H
-
-#include "enums/simpletypes/booldefines.h"
-
-PRAGMA6(GCC diagnostic push)
-PRAGMA6(GCC diagnostic ignored "-Wunused-const-variable")
-
-defBoolEnum(ShowCenter);
-
-PRAGMA6(GCC diagnostic pop)
-
-#endif // ENUMS_SIMPLETYPES_SHOWCENTER_H
diff --git a/src/enums/simpletypes/showemptyrows.h b/src/enums/simpletypes/showemptyrows.h
deleted file mode 100644
index 98feb22ae..000000000
--- a/src/enums/simpletypes/showemptyrows.h
+++ /dev/null
@@ -1,33 +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 ENUMS_SIMPLETYPES_SHOWEMPTYROWS_H
-#define ENUMS_SIMPLETYPES_SHOWEMPTYROWS_H
-
-#include "enums/simpletypes/booldefines.h"
-
-PRAGMA6(GCC diagnostic push)
-PRAGMA6(GCC diagnostic ignored "-Wunused-const-variable")
-
-defBoolEnum(ShowEmptyRows);
-
-PRAGMA6(GCC diagnostic pop)
-
-#endif // ENUMS_SIMPLETYPES_SHOWEMPTYROWS_H
diff --git a/src/enums/simpletypes/skiperror.h b/src/enums/simpletypes/skiperror.h
deleted file mode 100644
index bf281582d..000000000
--- a/src/enums/simpletypes/skiperror.h
+++ /dev/null
@@ -1,33 +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 ENUMS_SIMPLETYPES_SKIPERROR_H
-#define ENUMS_SIMPLETYPES_SKIPERROR_H
-
-#include "enums/simpletypes/booldefines.h"
-
-PRAGMA6(GCC diagnostic push)
-PRAGMA6(GCC diagnostic ignored "-Wunused-const-variable")
-
-defBoolEnum(SkipError);
-
-PRAGMA6(GCC diagnostic pop)
-
-#endif // ENUMS_SIMPLETYPES_SKIPERROR_H
diff --git a/src/enums/simpletypes/speech.h b/src/enums/simpletypes/speech.h
deleted file mode 100644
index 3ee3bee93..000000000
--- a/src/enums/simpletypes/speech.h
+++ /dev/null
@@ -1,33 +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 ENUMS_SIMPLETYPES_SPEECH_H
-#define ENUMS_SIMPLETYPES_SPEECH_H
-
-#include "enums/simpletypes/booldefines.h"
-
-PRAGMA6(GCC diagnostic push)
-PRAGMA6(GCC diagnostic ignored "-Wunused-const-variable")
-
-defBoolEnum(Speech);
-
-PRAGMA6(GCC diagnostic pop)
-
-#endif // ENUMS_SIMPLETYPES_SPEECH_H
diff --git a/src/enums/simpletypes/stringdefines.h b/src/enums/simpletypes/stringdefines.h
deleted file mode 100644
index 6cdebf7c0..000000000
--- a/src/enums/simpletypes/stringdefines.h
+++ /dev/null
@@ -1,51 +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 ENUMS_SIMPLETYPES_STRINGDEFINES_H
-#define ENUMS_SIMPLETYPES_STRINGDEFINES_H
-
-#include "localconsts.h"
-
-#define stringEnumStart(type) \
- std::map<std::string, type> mStringsArray; \
- bool find(const std::string &key) \
- { \
- return mStringsArray.find(key) != mStringsArray.end(); \
- } \
- type get(const std::string &key) \
- { \
- return mStringsArray[key]; \
- } \
- void init() \
- { \
- mStringsArray.clear();
-
-#define strEnumDef(prefix, name) \
- mStringsArray[#name] = prefix::name; \
-
-#define strEnumDef2(prefix, name, str) \
- mStringsArray[#name] = prefix::name; \
- mStringsArray[str] = prefix::name;
-
-#define stringEnumEnd \
- }
-
-
-#endif // ENUMS_SIMPLETYPES_STRINGDEFINES_H
diff --git a/src/enums/simpletypes/stringdefines2.h b/src/enums/simpletypes/stringdefines2.h
deleted file mode 100644
index f518ea799..000000000
--- a/src/enums/simpletypes/stringdefines2.h
+++ /dev/null
@@ -1,31 +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 ENUMS_SIMPLETYPES_STRINGDEFINES2_H
-#define ENUMS_SIMPLETYPES_STRINGDEFINES2_H
-
-#include "localconsts.h"
-
-#define stringEnumDef(type) \
- bool find(const std::string &key); \
- type get(const std::string &key); \
- void init();
-
-#endif // ENUMS_SIMPLETYPES_STRINGDEFINES2_H
diff --git a/src/enums/simpletypes/trading.h b/src/enums/simpletypes/trading.h
deleted file mode 100644
index dffdc49be..000000000
--- a/src/enums/simpletypes/trading.h
+++ /dev/null
@@ -1,33 +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 ENUMS_SIMPLETYPES_TRADING_H
-#define ENUMS_SIMPLETYPES_TRADING_H
-
-#include "enums/simpletypes/booldefines.h"
-
-PRAGMA6(GCC diagnostic push)
-PRAGMA6(GCC diagnostic ignored "-Wunused-const-variable")
-
-defBoolEnum(Trading);
-
-PRAGMA6(GCC diagnostic pop)
-
-#endif // ENUMS_SIMPLETYPES_TRADING_H
diff --git a/src/enums/simpletypes/tryremovecolors.h b/src/enums/simpletypes/tryremovecolors.h
deleted file mode 100644
index 4721cc9be..000000000
--- a/src/enums/simpletypes/tryremovecolors.h
+++ /dev/null
@@ -1,33 +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 ENUMS_SIMPLETYPES_TRYREMOVECOLORS_H
-#define ENUMS_SIMPLETYPES_TRYREMOVECOLORS_H
-
-#include "enums/simpletypes/booldefines.h"
-
-PRAGMA6(GCC diagnostic push)
-PRAGMA6(GCC diagnostic ignored "-Wunused-const-variable")
-
-defBoolEnum(TryRemoveColors);
-
-PRAGMA6(GCC diagnostic pop)
-
-#endif // ENUMS_SIMPLETYPES_TRYREMOVECOLORS_H
diff --git a/src/enums/simpletypes/useargs.h b/src/enums/simpletypes/useargs.h
deleted file mode 100644
index ddd05dd8d..000000000
--- a/src/enums/simpletypes/useargs.h
+++ /dev/null
@@ -1,33 +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 ENUMS_SIMPLETYPES_USEARGS_H
-#define ENUMS_SIMPLETYPES_USEARGS_H
-
-#include "enums/simpletypes/booldefines.h"
-
-PRAGMA6(GCC diagnostic push)
-PRAGMA6(GCC diagnostic ignored "-Wunused-const-variable")
-
-defBoolEnum(UseArgs);
-
-PRAGMA6(GCC diagnostic pop)
-
-#endif // ENUMS_SIMPLETYPES_USEARGS_H
diff --git a/src/enums/simpletypes/usebase64.h b/src/enums/simpletypes/usebase64.h
deleted file mode 100644
index b6fecf7e0..000000000
--- a/src/enums/simpletypes/usebase64.h
+++ /dev/null
@@ -1,33 +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 ENUMS_SIMPLETYPES_USEBASE64_H
-#define ENUMS_SIMPLETYPES_USEBASE64_H
-
-#include "enums/simpletypes/booldefines.h"
-
-PRAGMA6(GCC diagnostic push)
-PRAGMA6(GCC diagnostic ignored "-Wunused-const-variable")
-
-defBoolEnum(UseBase64);
-
-PRAGMA6(GCC diagnostic pop)
-
-#endif // ENUMS_SIMPLETYPES_USEBASE64_H
diff --git a/src/enums/simpletypes/usevirtfs.h b/src/enums/simpletypes/usevirtfs.h
deleted file mode 100644
index f76e3e55b..000000000
--- a/src/enums/simpletypes/usevirtfs.h
+++ /dev/null
@@ -1,33 +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 ENUMS_SIMPLETYPES_USERESMAN_H
-#define ENUMS_SIMPLETYPES_USERESMAN_H
-
-#include "enums/simpletypes/booldefines.h"
-
-PRAGMA6(GCC diagnostic push)
-PRAGMA6(GCC diagnostic ignored "-Wunused-const-variable")
-
-defBoolEnum(UseVirtFs);
-
-PRAGMA6(GCC diagnostic pop)
-
-#endif // ENUMS_SIMPLETYPES_USERESMAN_H
diff --git a/src/enums/simpletypes/visible.h b/src/enums/simpletypes/visible.h
deleted file mode 100644
index c21809711..000000000
--- a/src/enums/simpletypes/visible.h
+++ /dev/null
@@ -1,33 +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 ENUMS_SIMPLETYPES_VISIBLE_H
-#define ENUMS_SIMPLETYPES_VISIBLE_H
-
-#include "enums/simpletypes/booldefines.h"
-
-PRAGMA6(GCC diagnostic push)
-PRAGMA6(GCC diagnostic ignored "-Wunused-const-variable")
-
-defBoolEnum(Visible);
-
-PRAGMA6(GCC diagnostic pop)
-
-#endif // ENUMS_SIMPLETYPES_VISIBLE_H
diff --git a/src/enums/state.h b/src/enums/state.h
deleted file mode 100644
index b261ea226..000000000
--- a/src/enums/state.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 ENUMS_STATE_H
-#define ENUMS_STATE_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-#ifdef WIN32
-#undef ERROR
-#endif // WIN32
-
-enumStart(State)
-{
- ERROR = -1,
- START = 0,
- CHOOSE_SERVER,
- CONNECT_SERVER,
- PRE_LOGIN,
- LOGIN,
- LOGIN_ATTEMPT,
- WORLD_SELECT, // 5
- WORLD_SELECT_ATTEMPT,
- UPDATE,
- LOAD_DATA,
- GET_CHARACTERS,
- CHAR_SELECT, // 10
- CONNECT_GAME,
- GAME,
- CHANGE_MAP, // Switch map-server/gameserver
- LOGIN_ERROR,
- ACCOUNTCHANGE_ERROR, // 15
- REGISTER_PREP,
- REGISTER,
- REGISTER_ATTEMPT,
- CHANGEPASSWORD,
- CHANGEPASSWORD_ATTEMPT, // 20
- CHANGEPASSWORD_SUCCESS,
- CHANGEEMAIL,
- CHANGEEMAIL_ATTEMPT,
- CHANGEEMAIL_SUCCESS,
- SWITCH_SERVER,
- SWITCH_LOGIN,
- SWITCH_CHARACTER, // 30
- LOGOUT_ATTEMPT,
- WAIT,
- EXIT,
- FORCE_QUIT,
- AUTORECONNECT_SERVER = 1000
-}
-enumEnd(State);
-
-#endif // ENUMS_STATE_H
diff --git a/src/enums/textcommandtype.h b/src/enums/textcommandtype.h
deleted file mode 100644
index 669a87e4a..000000000
--- a/src/enums/textcommandtype.h
+++ /dev/null
@@ -1,33 +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 ENUMS_TEXTCOMMANDTYPE_H
-#define ENUMS_TEXTCOMMANDTYPE_H
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(TextCommandType)
-{
- Magic = 0,
- Text = 1
-}
-enumEnd(TextCommandType);
-
-#endif // ENUMS_TEXTCOMMANDTYPE_H
diff --git a/src/equipment.h b/src/equipment.h
deleted file mode 100644
index eb0235a47..000000000
--- a/src/equipment.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 EQUIPMENT_H
-#define EQUIPMENT_H
-
-#include "localconsts.h"
-
-class Item;
-
-class Equipment final
-{
- public:
- /**
- * Constructor.
- */
- Equipment() :
- mBackend(nullptr)
- { }
-
- A_DELETE_COPY(Equipment)
-
- /**
- * Destructor.
- */
- ~Equipment()
- { mBackend = nullptr; }
-
- class Backend notfinal
- {
- public:
- Backend()
- { }
-
- A_DELETE_COPY(Backend)
-
- virtual const Item *getEquipment(const int index)
- const A_WARN_UNUSED = 0;
-
- virtual void clear() = 0;
-
- virtual ~Backend()
- { }
- };
-
- /**
- * Get equipment at the given slot.
- */
- const Item *getEquipment(const int index) const A_WARN_UNUSED
- {
- return mBackend != nullptr ?
- mBackend->getEquipment(index) : nullptr;
- }
-
- /**
- * Clears equipment.
- */
- void clear()
- { if (mBackend != nullptr) mBackend->clear(); }
-
- /**
- * Set equipment at the given slot.
- */
- void setEquipment(int index, int id, int quantity = 0);
-
- void setBackend(Backend *const backend)
- { mBackend = backend; }
-
- const Backend *getBackend() const noexcept2 A_WARN_UNUSED
- { return mBackend; }
-
- private:
- Backend *mBackend;
-};
-
-#endif // EQUIPMENT_H
diff --git a/src/events/actionevent.h b/src/events/actionevent.h
deleted file mode 100644
index 11655fa03..000000000
--- a/src/events/actionevent.h
+++ /dev/null
@@ -1,137 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef EVENTS_ACTIONEVENT_H
-#define EVENTS_ACTIONEVENT_H
-
-#include "events/event.h"
-
-#include <string>
-
-#include "localconsts.h"
-
-class Widget;
-
-/**
- * Represents an action event. An action event is an event
- * that can be fired by a widget whenever an action has occured.
- * What exactly an action is is up to the widget that fires
- * the action event. An example is a Button which fires an action
- * event as soon as the Button is clicked, another example is
- * TextField which fires an action event as soon as the enter
- * key is pressed.
- *
- * Any object can listen for actions from widgets by implementing
- * the ActionListener interface.
- *
- * If you have implement a widget of your own it's a good idea to
- * let the widget fire action events whenever you feel an action
- * has occured so action listeners of the widget can be informed
- * of the state of the widget.
- *
- * @see Widget::addActionListener, Widget::removeActionListener,
- * Widget::distributeActionEvent
- * @author Olof Naessén
- */
-class ActionEvent final : public Event
-{
- public:
- /**
- * Constructor.
- *
- * @param source The source widget of the event.
- * @param id An identifier of the event.
- */
- ActionEvent(Widget *const source, const std::string &id) :
- Event(source),
- mId(id)
- {
- }
-
- A_DELETE_COPY(ActionEvent)
-
- /**
- * Destructor.
- */
- virtual ~ActionEvent()
- { }
-
- /**
- * Gets the identifier of the event. An identifier can
- * be used to distinguish from two actions from the same
- * widget or to let many widgets fire the same widgets
- * that should be treated equally.
- *
- * @return The identifier of the event.
- */
- const std::string &getId() const noexcept2 A_WARN_UNUSED
- { return mId; }
-
- protected:
- /**
- * Holds the identifier of the event.
- */
- std::string mId;
-};
-
-#endif // EVENTS_ACTIONEVENT_H
diff --git a/src/events/event.h b/src/events/event.h
deleted file mode 100644
index 78a7b7ada..000000000
--- a/src/events/event.h
+++ /dev/null
@@ -1,113 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef EVENTS_EVENT_H
-#define EVENTS_EVENT_H
-
-#include "localconsts.h"
-
-class Widget;
-
-/**
- * Base class for all events. All events in Guichan should
- * inherit from this class.
- *
- * @author Olof Naessén
- */
-class Event notfinal
-{
- public:
- /**
- * Constructor.
- *
- * @param source The source widget of the event.
- */
- explicit Event(Widget *const source) :
- mSource(source)
- { }
-
- A_DELETE_COPY(Event)
-
- /**
- * Destructor.
- */
- virtual ~Event()
- { }
-
- /**
- * Gets the source widget of the event. The function
- * is used to tell which widget fired an event.
- *
- * @return The source widget of the event.
- */
- Widget* getSource() const noexcept2 A_WARN_UNUSED
- { return mSource; }
-
- protected:
- /**
- * Holds the source widget of the event.
- */
- Widget* mSource;
-};
-
-#endif // EVENTS_EVENT_H
diff --git a/src/events/inputevent.h b/src/events/inputevent.h
deleted file mode 100644
index 68600143b..000000000
--- a/src/events/inputevent.h
+++ /dev/null
@@ -1,75 +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 EVENTS_INPUTEVENT_H
-#define EVENTS_INPUTEVENT_H
-
-#include "enums/input/inputaction.h"
-
-#include "utils/vector.h"
-
-#include <map>
-#include <string>
-
-#include "localconsts.h"
-
-class ChatTab;
-
-typedef STD_VECTOR<InputActionT> KeysVector;
-typedef KeysVector::iterator KeysVectorIter;
-typedef KeysVector::const_iterator KeysVectorCIter;
-
-typedef std::map<int, KeysVector> KeyToActionMap;
-typedef KeyToActionMap::iterator KeyToActionMapIter;
-
-typedef std::map<int, InputActionT> KeyToIdMap;
-typedef KeyToIdMap::iterator KeyToIdMapIter;
-
-typedef std::map<int, int> KeyTimeMap;
-typedef KeyTimeMap::iterator KeyTimeMapIter;
-
-struct InputEvent final
-{
- InputEvent(const InputActionT action0,
- const int mask0) :
- args(),
- tab(nullptr),
- action(action0),
- mask(mask0)
- { }
-
- InputEvent(const std::string &args0,
- ChatTab *const tab0,
- const int mask0) :
- args(args0),
- tab(tab0),
- action(InputAction::NO_VALUE),
- mask(mask0)
- { }
-
- A_DELETE_COPY(InputEvent)
-
- const std::string args;
- ChatTab *const tab;
- const InputActionT action;
- const int mask;
-};
-
-#endif // EVENTS_INPUTEVENT_H
diff --git a/src/events/inputguievent.h b/src/events/inputguievent.h
deleted file mode 100644
index 2a702db91..000000000
--- a/src/events/inputguievent.h
+++ /dev/null
@@ -1,118 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef EVENTS_INPUTGUIEVENT_H
-#define EVENTS_INPUTGUIEVENT_H
-
-#include "events/event.h"
-
-/**
- * Base class for all events concerning input.
- *
- * @author Olof Naessén
- */
-class InputGuiEvent: public Event
-{
- public:
- /**
- * Constructor.
- *
- * @param source The source widget of the event.
- */
- explicit InputGuiEvent(Widget *const source) :
- Event(source),
- mIsConsumed(false)
- { }
-
- /**
- * Marks the event as consumed. Input event listeners may discard
- * consumed input or act on consumed input. An example of a widget
- * that discards consumed input is the ScrollArea widget that
- * discards consumed mouse wheel events so the ScrollArea will not
- * scroll if for instance a Slider's value inside the ScrollArea was
- * changed with the mouse wheel.
- *
- * @see isConsumed
- */
- void consume()
- { mIsConsumed = true; }
-
- /**
- * Checks if the input event is consumed.
- *
- * @return True if the input event is consumed,
- * false otherwise.
- * @see consume
- */
- bool isConsumed() const noexcept2 A_WARN_UNUSED
- { return mIsConsumed; }
-
- protected:
- /**
- * True if the input event is consumed,
- * false otherwise.
- */
- bool mIsConsumed;
-};
-
-#endif // EVENTS_INPUTGUIEVENT_H
diff --git a/src/events/keyevent.h b/src/events/keyevent.h
deleted file mode 100644
index 191bc1849..000000000
--- a/src/events/keyevent.h
+++ /dev/null
@@ -1,159 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef EVENTS_KEYEVENT_H
-#define EVENTS_KEYEVENT_H
-
-#include "enums/events/keyeventtype.h"
-
-#include "enums/input/inputaction.h"
-
-#include "events/inputguievent.h"
-
-#include "input/key.h"
-
-#ifdef USE_SDL2
-#include <string>
-#endif // USE_SDL2
-
-class Widget;
-
-/**
- * Represents a key event.
- */
-class KeyEvent: public InputGuiEvent
-{
- public:
- /**
- * Constructor.
- *
- * @param source The source widget of the event.
- * @param type The type of the event. A value from KeyEventType.
- * false otherwise.
- * @param key The key of the event.
- */
- KeyEvent(Widget *const source,
- KeyEventTypeT type,
- const InputActionT actionId,
- const Key &key) :
- InputGuiEvent(source),
- mKey(key),
-#ifdef USE_SDL2
- mText(),
-#endif // USE_SDL2
- mType(type),
- mActionId(actionId)
- { }
-
- /**
- * Destructor.
- */
- virtual ~KeyEvent()
- { }
-
- /**
- * Gets the type of the event.
- *
- * @return The type of the event.
- */
- KeyEventTypeT getType() const noexcept2 A_WARN_UNUSED
- { return mType; }
-
- /**
- * Gets the key of the event.
- *
- * @return The key of the event.
- */
- const Key &getKey() const noexcept2 A_WARN_UNUSED
- { return mKey; }
-
- InputActionT getActionId() const noexcept2 A_WARN_UNUSED
- { return mActionId; }
-
-#ifdef USE_SDL2
- void setText(const std::string &text)
- { mText = text; }
-
- std::string getText() const
- { return mText; }
-#endif // USE_SDL2
-
- protected:
- /**
- * Holds the key of the key event.
- */
- Key mKey;
-
-#ifdef USE_SDL2
- std::string mText;
-#endif // USE_SDL2
-
- /**
- * Holds the type of the key event.
- */
- KeyEventTypeT mType;
-
- InputActionT mActionId;
-};
-
-#endif // EVENTS_KEYEVENT_H
diff --git a/src/events/mouseevent.h b/src/events/mouseevent.h
deleted file mode 100644
index 3a3a70f0a..000000000
--- a/src/events/mouseevent.h
+++ /dev/null
@@ -1,199 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef EVENTS_MOUSEEVENT_H
-#define EVENTS_MOUSEEVENT_H
-
-#include "events/inputguievent.h"
-
-#include "enums/events/mousebutton.h"
-#include "enums/events/mouseeventtype.h"
-
-class Widget;
-
-/**
- * Represents a mouse event.
- *
- * @author Olof Naessén
- */
-class MouseEvent: public InputGuiEvent
-{
- public:
- /**
- * Constructor.
- *
- * @param source The source widget of the mouse event.
- * @param type The type of the mouse event.
- * @param button The button of the mouse event.
- * @param x The x coordinate of the event relative to the source widget.
- * @param y The y coordinate of the event relative the source widget.
- * @param clickCount The number of clicks generated with the same button.
- * It's set to zero if another button is used.
- */
- MouseEvent(Widget *const source,
- const MouseEventTypeT type,
- const MouseButtonT button,
- const int x,
- const int y,
- const int clickCount) :
- InputGuiEvent(source),
- mType(type),
- mButton(button),
- mX(x),
- mY(y),
- mClickCount(clickCount)
- {
- }
-
- /**
- * Gets the button of the mouse event.
- *
- * @return The button of the mouse event.
- */
- MouseButtonT getButton() const noexcept2 A_WARN_UNUSED
- { return mButton; }
-
- /**
- * Gets the x coordinate of the mouse event.
- * The coordinate relative to widget the mouse listener
- * receiving the events have registered to.
- *
- * @return The x coordinate of the mouse event.
- * @see Widget::addMouseListener, Widget::removeMouseListener
- */
- int getX() const noexcept2 A_WARN_UNUSED
- { return mX; }
-
- /**
- * Gets the y coordinate of the mouse event.
- * The coordinate relative to widget the mouse listener
- * receiving the events have registered to.
- *
- * @return The y coordinate of the mouse event.
- * @see Widget::addMouseListener, Widget::removeMouseListener
- */
- int getY() const noexcept2 A_WARN_UNUSED
- { return mY; }
-
- /**
- * Gets the number of clicks generated with the same button.
- * It's set to zero if another button is used.
- *
- * @return The number of clicks generated with the same button.
- */
- int getClickCount() const noexcept2 A_WARN_UNUSED
- { return mClickCount; }
-
- /**
- * Gets the type of the event.
- *
- * @return The type of the event.
- */
- MouseEventTypeT getType() const noexcept2 A_WARN_UNUSED
- { return mType; }
-
- void setX(int n)
- { mX = n; }
-
- void setY(int n)
- { mY = n; }
-
- protected:
- /**
- * Holds the type of the mouse event.
- */
- MouseEventTypeT mType;
-
- /**
- * Holds the button of the mouse event.
- */
- MouseButtonT mButton;
-
- /**
- * Holds the x-coordinate of the mouse event.
- */
- int mX;
-
- /**
- * Holds the y-coordinate of the mouse event.
- */
- int mY;
-
- /**
- * The number of clicks generated with the same button.
- * It's set to zero if another button is used.
- */
- int mClickCount;
-
- /**
- * Gui is a friend of this class in order to be able to manipulate
- * the protected member variables of this class and at the same time
- * keep the MouseEvent class as const as possible. Gui needs to
- * update the x och y coordinates for the coordinates to be relative
- * to widget the mouse listener receiving the events have registered
- * to.
- */
- friend class Gui;
-};
-
-#endif // EVENTS_MOUSEEVENT_H
diff --git a/src/events/selectionevent.h b/src/events/selectionevent.h
deleted file mode 100644
index 02682af07..000000000
--- a/src/events/selectionevent.h
+++ /dev/null
@@ -1,99 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef EVENTS_SELECTIONEVENT_H
-#define EVENTS_SELECTIONEVENT_H
-
-#include "events/event.h"
-
-#include "localconsts.h"
-
-class Widget;
-
-/**
- * Represents a selection event.
- *
- * @author Olof Naessén
- */
-class SelectionEvent final: public Event
-{
- public:
- /**
- * Constructor.
- *
- * @param source source The widget of the selection event.
- */
- explicit SelectionEvent(Widget *const source) :
- Event(source)
- { }
-
- A_DELETE_COPY(SelectionEvent)
-
- /**
- * Destructor.
- */
- virtual ~SelectionEvent()
- { }
-};
-
-#endif // EVENTS_SELECTIONEVENT_H
diff --git a/src/eventsmanager.cpp b/src/eventsmanager.cpp
deleted file mode 100644
index f1acd698c..000000000
--- a/src/eventsmanager.cpp
+++ /dev/null
@@ -1,683 +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 "eventsmanager.h"
-
-#include "configuration.h"
-#include "client.h"
-#ifndef DYECMD
-#include "game.h"
-#endif // DYECMD
-#ifdef USE_MUMBLE
-#include "mumblemanager.h"
-#endif // USE_MUMBLE
-#include "sdlshared.h"
-#include "settings.h"
-
-#include "gui/windowmanager.h"
-
-#include "being/localplayer.h"
-
-#include "input/inputmanager.h"
-
-#ifdef USE_SDL2
-#include "render/graphics.h"
-#else // USE_SDL2
-#include "logger.h"
-#endif // USE_SDL2
-
-#include "utils/process.h"
-#include "utils/sdlhelper.h"
-#ifdef USE_X11
-#include "utils/x11logger.h"
-#endif // USE_X11
-
-#include "debug.h"
-
-EventsManager eventsManager;
-
-EventsManager::EventsManager() :
- ConfigListener(),
- mLogInput(false)
-{
-}
-
-EventsManager::~EventsManager()
-{
- CHECKLISTENERS
-}
-
-void EventsManager::init()
-{
- mLogInput = config.getBoolValue("logInput");
- config.addListener("logInput", this);
-}
-
-void EventsManager::enableEvents()
-{
- // disable unused SDL events
-#ifndef USE_SDL2
- SDL_EventState(SDL_VIDEOEXPOSE, SDL_IGNORE);
-#endif // USE_SDL2
-
- SDL_EventState(SDL_SYSWMEVENT, mLogInput ? SDL_ENABLE : SDL_IGNORE);
- SDL_EventState(SDL_USEREVENT, SDL_IGNORE);
-}
-
-void EventsManager::shutdown()
-{
- config.removeListeners(this);
-}
-
-bool EventsManager::handleCommonEvents(const SDL_Event &event) const
-{
- BLOCK_START("EventsManager::handleCommonEvents")
- if (mLogInput)
- logEvent(event);
-
- switch (event.type)
- {
- case SDL_QUIT:
- client->setState(State::EXIT);
- logger->log1("force exit");
- BLOCK_END("EventsManager::handleCommonEvents")
- return true;
-#ifdef USE_SDL2
- case SDL_WINDOWEVENT:
- handleSDL2WindowEvent(event);
- BLOCK_END("EventsManager::handleCommonEvents")
- return true;
-#else // USE_SDL2
- case SDL_VIDEORESIZE:
- WindowManager::resizeVideo(event.resize.w,
- event.resize.h,
- false);
- BLOCK_END("EventsManager::handleCommonEvents")
- return true;
- case SDL_ACTIVEEVENT:
- handleActive(event);
- BLOCK_END("EventsManager::handleCommonEvents")
- return true;
-#ifdef ANDROID
- case SDL_KEYBOARDSHOW:
- WindowManager::updateScreenKeyboard(event.user.code);
- BLOCK_END("EventsManager::handleCommonEvents")
- return true;
- case SDL_ACCELEROMETER:
- break;
-#endif // ANDROID
-#endif // USE_SDL2
- default:
- break;
- }
-
- if (inputManager.handleEvent(event))
- {
- BLOCK_END("EventsManager::handleCommonEvents")
- return true;
- }
-
- BLOCK_END("EventsManager::handleCommonEvents")
- return false;
-}
-
-bool EventsManager::handleEvents() const
-{
- BLOCK_START("EventsManager::handleEvents")
-#ifndef DYECMD
- if (Game::instance() != nullptr)
- {
- // Let the game handle the events while it is active
- Game::instance()->handleInput();
- }
- else
-#endif // DYECMD
- {
- SDL_Event event;
- // Handle SDL events
- while (SDL::PollEvent(&event))
- {
- if (!handleCommonEvents(event))
- {
- switch (event.type)
- {
-#ifdef ANDROID
-#ifndef USE_SDL2
- case SDL_ACTIVEEVENT:
- if ((event.active.state & SDL_APPACTIVE)
- && !event.active.gain)
- {
- client->setState(State::EXIT);
- logger->log1("exit on lost focus");
- }
- break;
-
-#endif // USE_SDL2
-#endif // ANDROID
- default:
- break;
- }
- }
-
-#ifdef USE_MUMBLE
- if (localPlayer && mumbleManager)
- {
- mumbleManager->setPos(localPlayer->getTileX(),
- localPlayer->getTileY(), localPlayer->getDirection());
- }
-#endif // USE_MUMBLE
- }
- if (client->getState() == State::EXIT)
- {
- BLOCK_END("EventsManager::handleEvents")
- return true;
- }
- }
- BLOCK_END("EventsManager::handleEvents")
- return false;
-}
-
-void EventsManager::handleGameEvents() const
-{
- BLOCK_START("EventsManager::handleGameEvents")
-#ifndef DYECMD
- Game *const game = Game::instance();
-
- // Events
- SDL_Event event;
- while (SDL::PollEvent(&event))
- {
- if (event.type == SDL_KEYDOWN || event.type == SDL_KEYUP)
- game->updateHistory(event);
- game->checkKeys();
-
- if (handleCommonEvents(event))
- break;
- } // End while
-#endif // DYECMD
-
- BLOCK_END("EventsManager::handleGameEvents")
-}
-
-void EventsManager::optionChanged(const std::string &name)
-{
- if (name == "logInput")
- mLogInput = config.getBoolValue("logInput");
-}
-
-void EventsManager::logEvent(const SDL_Event &event)
-{
- switch (event.type)
- {
-#ifdef USE_SDL2
-#define winEventLog(name, name2) \
- case name: \
- str = name2; \
- break
-
- case SDL_MOUSEMOTION:
- logger->log("event: SDL_MOUSEMOTION: %u, %d,%d, %d,%d",
- event.motion.state,
- event.motion.x,
- event.motion.y,
- event.motion.xrel,
- event.motion.yrel);
- break;
- case SDL_FINGERDOWN:
- {
- const SDL_TouchFingerEvent &touch = event.tfinger;
- const int w = mainGraphics->mWidth;
- const int h = mainGraphics->mHeight;
- logger->log("event: SDL_FINGERDOWN: %u,%u (%f,%f) (%f,%f) %f",
- CAST_U32(touch.touchId),
- CAST_U32(touch.fingerId),
- touch.x * w, touch.y * w,
- touch.dx * w, touch.dy * h,
- touch.pressure);
- break;
- }
- case SDL_FINGERUP:
- {
- const SDL_TouchFingerEvent &touch = event.tfinger;
- const int w = mainGraphics->mWidth;
- const int h = mainGraphics->mHeight;
- logger->log("event: SDL_FINGERUP: %u,%u (%f,%f) (%f,%f) %f",
- CAST_U32(touch.touchId),
- CAST_U32(touch.fingerId),
- touch.x * w, touch.y * w,
- touch.dx * w, touch.dy * h,
- touch.pressure);
- break;
- }
- case SDL_FINGERMOTION:
- {
- const SDL_TouchFingerEvent &touch = event.tfinger;
- const int w = mainGraphics->mWidth;
- const int h = mainGraphics->mHeight;
- logger->log("event: SDL_FINGERMOTION: %u,%u (%f,%f) (%f,%f) %f",
- CAST_U32(touch.touchId),
- CAST_U32(touch.fingerId),
- touch.x * w, touch.y * h,
- touch.dx * w, touch.dy * h,
- touch.pressure);
- break;
- }
- case SDL_MULTIGESTURE:
- {
- const SDL_MultiGestureEvent &gesture = event.mgesture;
- const int w = mainGraphics->mWidth;
- const int h = mainGraphics->mHeight;
- logger->log("event: SDL_MULTIGESTURE: %u %f,%f (%f,%f) %d",
- CAST_U32(gesture.touchId),
- gesture.dTheta, gesture.dDist,
- gesture.x * w, gesture.y * h,
- CAST_S32(gesture.numFingers));
- break;
- }
- case SDL_KEYDOWN:
- logger->log("event: SDL_KEYDOWN: %s(%d) %s(%d) %d,%d,%u",
- SDL_GetScancodeName(event.key.keysym.scancode),
- event.key.keysym.scancode,
- SDL_GetKeyName(event.key.keysym.sym),
- event.key.keysym.sym,
- event.key.state,
- event.key.repeat,
- CAST_U32(event.key.keysym.mod));
- break;
- case SDL_KEYUP:
- logger->log("event: SDL_KEYUP: %s(%d) %s(%d) %d,%d,%u",
- SDL_GetScancodeName(event.key.keysym.scancode),
- event.key.keysym.scancode,
- SDL_GetKeyName(event.key.keysym.sym),
- event.key.keysym.sym,
- event.key.state,
- event.key.repeat,
- CAST_U32(event.key.keysym.mod));
- break;
- case SDL_WINDOWEVENT:
- {
- const int data1 = event.window.data1;
- const int data2 = event.window.data2;
- std::string str;
- switch (event.window.event)
- {
- winEventLog(SDL_WINDOWEVENT_NONE, "SDL_WINDOWEVENT_NONE");
- winEventLog(SDL_WINDOWEVENT_SHOWN, "SDL_WINDOWEVENT_SHOWN");
- winEventLog(SDL_WINDOWEVENT_HIDDEN, "SDL_WINDOWEVENT_HIDDEN");
- winEventLog(SDL_WINDOWEVENT_EXPOSED,
- "SDL_WINDOWEVENT_EXPOSED");
- winEventLog(SDL_WINDOWEVENT_MOVED, "SDL_WINDOWEVENT_MOVED");
- winEventLog(SDL_WINDOWEVENT_RESIZED,
- "SDL_WINDOWEVENT_RESIZED");
- winEventLog(SDL_WINDOWEVENT_SIZE_CHANGED,
- "SDL_WINDOWEVENT_SIZE_CHANGED");
- winEventLog(SDL_WINDOWEVENT_MINIMIZED,
- "SDL_WINDOWEVENT_MINIMIZED");
- winEventLog(SDL_WINDOWEVENT_MAXIMIZED,
- "SDL_WINDOWEVENT_MAXIMIZED");
- winEventLog(SDL_WINDOWEVENT_RESTORED,
- "SDL_WINDOWEVENT_RESTORED");
- winEventLog(SDL_WINDOWEVENT_ENTER, "SDL_WINDOWEVENT_ENTER");
- winEventLog(SDL_WINDOWEVENT_LEAVE, "SDL_WINDOWEVENT_LEAVE");
- winEventLog(SDL_WINDOWEVENT_FOCUS_GAINED,
- "SDL_WINDOWEVENT_FOCUS_GAINED");
- winEventLog(SDL_WINDOWEVENT_FOCUS_LOST,
- "SDL_WINDOWEVENT_FOCUS_LOST");
- winEventLog(SDL_WINDOWEVENT_CLOSE, "SDL_WINDOWEVENT_CLOSE");
-#if SDL_VERSION_ATLEAST(2, 0, 5)
- winEventLog(SDL_WINDOWEVENT_TAKE_FOCUS,
- "SDL_WINDOWEVENT_TAKE_FOCUS");
- winEventLog(SDL_WINDOWEVENT_HIT_TEST,
- "SDL_WINDOWEVENT_HIT_TEST");
-#endif // SDL_VERSION_ATLEAST(2, 0, 5)
- default:
- str = strprintf("unknown: %d",
- event.window.event);
- break;
- }
- logger->log("event: SDL_WINDOWEVENT: %s: %d,%d",
- str.c_str(), data1, data2);
- break;
- }
- case SDL_TEXTINPUT:
- {
- const char *const text = event.text.text;
- logger->log("event: SDL_TEXTINPUT: %s", text);
- const size_t sz = strlen(event.text.text);
- for (size_t f = 0; f < sz; f ++)
- logger->log("dec: %d", text[f]);
- break;
- }
- case SDL_APP_TERMINATING:
- logger->log("SDL_APP_TERMINATING");
- break;
- case SDL_APP_LOWMEMORY:
- logger->log("SDL_APP_LOWMEMORY");
- break;
- case SDL_APP_WILLENTERBACKGROUND:
- logger->log("SDL_APP_WILLENTERBACKGROUND");
- break;
- case SDL_APP_WILLENTERFOREGROUND:
- logger->log("SDL_APP_WILLENTERFOREGROUND");
- break;
- case SDL_APP_DIDENTERFOREGROUND:
- logger->log("SDL_APP_DIDENTERFOREGROUND");
- break;
- case SDL_APP_DIDENTERBACKGROUND:
- logger->log("SDL_APP_DIDENTERBACKGROUND");
- break;
- case SDL_MOUSEWHEEL:
-#if SDL_VERSION_ATLEAST(2, 0, 4)
- logger->log("event: SDL_MOUSEWHEEL: %u,%u, %d,%d, %u",
- event.wheel.windowID,
- event.wheel.which,
- event.wheel.x,
- event.wheel.y,
- event.wheel.direction);
-#else // SDL_VERSION_ATLEAST(2, 0, 4)
-
- logger->log("event: SDL_MOUSEWHEEL: %u,%u, %d,%d",
- event.wheel.windowID,
- event.wheel.which,
- event.wheel.x,
- event.wheel.y);
-#endif // SDL_VERSION_ATLEAST(2, 0, 4)
- break;
-#if SDL_VERSION_ATLEAST(2, 0, 4)
- case SDL_AUDIODEVICEADDED:
- logger->log("event: SDL_AUDIODEVICEADDED: %u,%u",
- event.adevice.which,
- event.adevice.iscapture);
- break;
- case SDL_KEYMAPCHANGED:
- logger->log("event: SDL_KEYMAPCHANGED");
- break;
-#endif // SDL_VERSION_ATLEAST(2, 0, 4)
- case SDL_MOUSEBUTTONDOWN:
- logger->log("event: SDL_MOUSEBUTTONDOWN: %u,%u,%u, %d,%d",
- event.button.which,
- CAST_U32(event.button.button),
- CAST_U32(event.button.state),
- event.button.x,
- event.button.y);
- break;
- case SDL_MOUSEBUTTONUP:
- logger->log("event: SDL_MOUSEBUTTONUP: %u,%u,%u, %d,%d",
- event.button.which,
- CAST_U32(event.button.button),
- CAST_U32(event.button.state),
- event.button.x,
- event.button.y);
- break;
- case SDL_JOYDEVICEADDED:
- logger->log("event: SDL_JOYDEVICEADDED: %d",
- event.jdevice.which);
- break;
- case SDL_JOYDEVICEREMOVED:
- logger->log("event: SDL_JOYDEVICEREMOVED: %d",
- event.jdevice.which);
- break;
-#else // USE_SDL2
-
- case SDL_MOUSEMOTION:
- logger->log("event: SDL_MOUSEMOTION: %u,%d,%d",
- event.motion.state, event.motion.x, event.motion.y);
- break;
- case SDL_KEYDOWN:
- logger->log("event: SDL_KEYDOWN: %s(%d),%d,%d,%d",
- SDL_GetKeyName(event.key.keysym.sym),
- event.key.keysym.sym,
- event.key.keysym.scancode,
- event.key.state,
- event.key.keysym.unicode);
- break;
- case SDL_KEYUP:
- logger->log("event: SDL_KEYUP: %s(%d),%d,%d,%d",
- SDL_GetKeyName(event.key.keysym.sym),
- event.key.keysym.sym,
- event.key.keysym.scancode,
- event.key.state,
- event.key.keysym.unicode);
- break;
- case SDL_VIDEORESIZE:
- logger->log("event: SDL_VIDEORESIZE");
- break;
- case SDL_VIDEOEXPOSE:
- logger->log("event: SDL_VIDEOEXPOSE");
- break;
- case SDL_ACTIVEEVENT:
- logger->log("event: SDL_ACTIVEEVENT: %d %d",
- event.active.state, event.active.gain);
- break;
- case SDL_MOUSEBUTTONDOWN:
- logger->log("event: SDL_MOUSEBUTTONDOWN: %d,%d, %d,%d",
- event.button.button,
- event.button.state,
- event.button.x,
- event.button.y);
- break;
- case SDL_MOUSEBUTTONUP:
- logger->log("event: SDL_MOUSEBUTTONUP: %d,%d,%d,%d",
- event.button.button,
- event.button.state,
- event.button.x,
- event.button.y);
- break;
-#endif // USE_SDL2
-
- case SDL_JOYAXISMOTION:
- logger->log("event: SDL_JOYAXISMOTION: %d,%d,%d",
- event.jaxis.which, event.jaxis.axis, event.jaxis.value);
- break;
- case SDL_JOYBALLMOTION:
- logger->log("event: SDL_JOYBALLMOTION: %d,%d,%d,%d",
- event.jball.which, event.jball.ball,
- event.jball.xrel, event.jball.yrel);
- break;
- case SDL_JOYHATMOTION:
- logger->log("event: SDL_JOYHATMOTION: %d,%d,%d", event.jhat.which,
- event.jhat.hat, event.jhat.value);
- break;
- case SDL_JOYBUTTONDOWN:
- logger->log("event: SDL_JOYBUTTONDOWN: %d,%d,%d",
- event.jbutton.which, event.jbutton.button,
- event.jbutton.state);
- break;
- case SDL_JOYBUTTONUP:
- logger->log("event: SDL_JOYBUTTONUP: %d,%d,%d",
- event.jbutton.which, event.jbutton.button,
- event.jbutton.state);
- break;
- case SDL_QUIT:
- logger->log("event: SDL_QUIT");
- break;
- case SDL_SYSWMEVENT:
- {
-#ifdef USE_X11
- const bool res = X11Logger::logEvent(event);
- if (res == false)
- logger->assertLog("event: SDL_SYSWMEVENT: not supported:");
-#else // USE_X11
-
- logger->assertLog("event: SDL_SYSWMEVENT: not supported:");
-#endif // USE_X11
-
- break;
- }
- case SDL_USEREVENT:
- logger->log("event: SDL_USEREVENT: %d",
- event.user.code);
- break;
-#ifdef ANDROID
-#ifndef USE_SDL2
- case SDL_ACCELEROMETER:
- logger->log("event: SDL_ACCELEROMETER");
- break;
-#endif // USE_SDL2
-#endif // ANDROID
-
- default:
- logger->assertLog("event: other: %u",
- CAST_U32(event.type));
- break;
- };
-}
-
-#ifdef USE_SDL2
-void EventsManager::handleSDL2WindowEvent(const SDL_Event &event)
-{
-#ifndef DYECMD
- int fpsLimit = 0;
-#endif // DYECMD
-
- const int eventType = event.window.event;
- const bool inGame = (client->getState() == State::GAME);
- switch (eventType)
- {
- case SDL_WINDOWEVENT_RESIZED:
- WindowManager::resizeVideo(event.window.data1,
- event.window.data2,
- false);
- break;
- case SDL_WINDOWEVENT_ENTER:
- settings.mouseFocused = true;
- break;
- case SDL_WINDOWEVENT_LEAVE:
- settings.mouseFocused = false;
- break;
- case SDL_WINDOWEVENT_FOCUS_GAINED:
- settings.inputFocused = KeyboardFocus::Focused;
- break;
-#if SDL_VERSION_ATLEAST(2, 0, 5)
- case SDL_WINDOWEVENT_TAKE_FOCUS:
- settings.inputFocused = KeyboardFocus::Focused2;
- break;
-#endif // SDL_VERSION_ATLEAST(2, 0, 5)
-
- case SDL_WINDOWEVENT_FOCUS_LOST:
- settings.inputFocused = KeyboardFocus::Unfocused;
- break;
- case SDL_WINDOWEVENT_MINIMIZED:
- WindowManager::setIsMinimized(true);
-#ifndef DYECMD
- fpsLimit = config.getIntValue("altfpslimit");
- if (localPlayer)
- localPlayer->setHalfAway(true);
-#endif // DYECMD
-
- setPriority(false);
- break;
- case SDL_WINDOWEVENT_RESTORED:
- case SDL_WINDOWEVENT_MAXIMIZED:
- WindowManager::setIsMinimized(false);
-#ifndef DYECMD
- fpsLimit = config.getIntValue("fpslimit");
- if (localPlayer)
- localPlayer->setHalfAway(false);
-#endif // DYECMD
-
- setPriority(true);
- break;
- default:
- break;
- }
-
- if (!inGame)
- return;
-
-#ifndef DYECMD
- if (eventType == SDL_WINDOWEVENT_MINIMIZED
- || eventType == SDL_WINDOWEVENT_RESTORED
- || eventType == SDL_WINDOWEVENT_MAXIMIZED)
- {
- if (localPlayer)
- {
- localPlayer->updateStatus();
- localPlayer->updateName();
- }
- Game::instance()->updateFrameRate(fpsLimit);
- }
-#endif // DYECMD
-}
-#else // USE_SDL2
-
-void EventsManager::handleActive(const SDL_Event &event)
-{
-#ifndef DYECMD
- int fpsLimit = 0;
- const bool inGame = (client->getState() == State::GAME);
-#endif // DYECMD
-
- if ((event.active.state & SDL_APPACTIVE) != 0)
- {
- if (event.active.gain != 0u)
- { // window restore
- WindowManager::setIsMinimized(false);
-#ifndef DYECMD
- if (localPlayer != nullptr)
- {
- if (!settings.awayMode)
- fpsLimit = config.getIntValue("fpslimit");
- localPlayer->setHalfAway(false);
- }
-#endif // DYECMD
-
- setPriority(true);
- }
- else
- { // window minimization
-#ifdef ANDROID
- client->setState(State::EXIT);
-#else // ANDROID
- WindowManager::setIsMinimized(true);
-#ifndef DYECMD
- if (localPlayer != nullptr && !settings.awayMode)
- {
- fpsLimit = config.getIntValue("altfpslimit");
- localPlayer->setHalfAway(true);
- }
-#endif // DYECMD
-
- setPriority(false);
-#endif // ANDROID
- }
-#ifndef DYECMD
- if (inGame && (localPlayer != nullptr))
- localPlayer->updateStatus();
-#endif // DYECMD
- }
-#ifndef DYECMD
- if (inGame && (localPlayer != nullptr))
- localPlayer->updateName();
-#endif // DYECMD
-
- if ((event.active.state & SDL_APPINPUTFOCUS) != 0)
- {
- settings.inputFocused = (event.active.gain != 0u) ?
- KeyboardFocus::Focused : KeyboardFocus::Unfocused;
- }
- if ((event.active.state & SDL_APPMOUSEFOCUS) != 0)
- settings.mouseFocused = (event.active.gain != 0u);
-#ifndef DYECMD
- if (inGame)
- Game::instance()->updateFrameRate(fpsLimit);
-#endif // DYECMD
-}
-#endif // USE_SDL2
diff --git a/src/eventsmanager.h b/src/eventsmanager.h
deleted file mode 100644
index 725040ca4..000000000
--- a/src/eventsmanager.h
+++ /dev/null
@@ -1,71 +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 EVENTSMANAGER_H
-#define EVENTSMANAGER_H
-
-#include "listeners/configlistener.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_events.h>
-PRAGMA48(GCC diagnostic pop)
-
-#include "localconsts.h"
-
-class EventsManager final : public ConfigListener
-{
- public:
- EventsManager();
-
- A_DELETE_COPY(EventsManager)
-
- virtual ~EventsManager();
-
- void init();
-
- void enableEvents();
-
- void shutdown();
-
- bool handleEvents() const;
-
- bool handleCommonEvents(const SDL_Event &event) const;
-
- void handleGameEvents() const;
-
-#ifdef USE_SDL2
- static void handleSDL2WindowEvent(const SDL_Event &event);
-#else // USE_SDL2
-
- static void handleActive(const SDL_Event &event);
-#endif // USE_SDL2
-
- void optionChanged(const std::string &name) override final;
-
- static void logEvent(const SDL_Event &event);
-
- protected:
- bool mLogInput;
-};
-
-extern EventsManager eventsManager;
-
-#endif // EVENTSMANAGER_H
diff --git a/src/filefilter.txt b/src/filefilter.txt
deleted file mode 100644
index 37988ae54..000000000
--- a/src/filefilter.txt
+++ /dev/null
@@ -1,21 +0,0 @@
-~ RULE_3_1_A_do_not_start_filename_with_underbar
-~ RULE_3_2_CD_do_not_use_special_characters_in_filename
-~ RULE_3_2_H_do_not_use_uppercase_for_c_filename
-~ RULE_4_1_A_B_use_space_for_indentation
-~ RULE_4_1_B_indent_each_enum_item_in_enum_block
-~ RULE_4_1_B_locate_each_enum_item_in_seperate_line
-~ RULE_4_1_C_align_long_function_parameter_list
-~ RULE_4_1_E_align_conditions
-~ RULE_4_2_A_A_space_around_operator
-~ RULE_4_2_A_B_space_around_word
-~ RULE_4_4_A_do_not_write_over_80_columns_per_line
-~ RULE_4_5_A_brace_for_namespace_should_be_located_in_seperate_line
-~ RULE_4_5_A_braces_for_type_definition_should_be_located_in_seperate_line
-~ RULE_4_5_A_indent_blocks_inside_of_function
-~ RULE_4_5_A_matching_braces_inside_of_function_should_be_located_same_column
-~ RULE_6_1_A_do_not_omit_function_parameter_names
-~ RULE_6_4_B_initialize_first_item_of_enum
-~ RULE_7_2_B_do_not_use_goto_statement
-~ RULE_8_1_A_provide_file_info_comment
-~ RULE_9_1_A_do_not_use_hardcorded_include_path
-
diff --git a/src/filefilter_more.txt b/src/filefilter_more.txt
deleted file mode 100644
index f0f37e03a..000000000
--- a/src/filefilter_more.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-~ RULE_6_2_A_do_not_use_system_dependent_type
-~ RULE_3_2_F_use_representitive_classname_for_cpp_filename
-~ RULE_6_5_B_do_not_use_macro_for_constants
-~ RULE_A_3_avoid_too_deep_blocks
-~ RULE_6_1_G_write_less_than_200_lines_for_function
-
-~ RULE_5_2_C_provide_doxygen_class_comment_on_class_def
-~ RULE_5_2_C_provide_doxygen_namespace_comment_on_namespace_def
-~ RULE_5_2_C_provide_doxygen_struct_comment_on_struct_def
-~ RULE_5_3_A_provide_doxygen_function_comment_on_function_in_header
-~ RULE_5_3_A_provide_doxygen_function_comment_on_function_in_impl
-~ RULE_6_1_E_do_not_use_more_than_5_paramters_in_function
diff --git a/src/fs/files.cpp b/src/fs/files.cpp
deleted file mode 100644
index d5c600fb9..000000000
--- a/src/fs/files.cpp
+++ /dev/null
@@ -1,319 +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 "fs/files.h"
-
-#include "fs/mkdir.h"
-#if defined(ANDROID) || defined(__native_client__)
-#include "fs/paths.h"
-
-#include "fs/virtfs/fs.h"
-#include "fs/virtfs/tools.h"
-#include "fs/virtfs/list.h"
-#endif // defined(ANDROID) || defined(__native_client__)
-
-#if defined(ANDROID) || defined(__native_client__)
-#include "utils/foreach.h"
-#endif // defined(ANDROID) || defined(__native_client__)
-
-#include "utils/checkutils.h"
-#include "utils/stringutils.h"
-
-#include <dirent.h>
-#include <sys/stat.h>
-
-#include "debug.h"
-
-extern const char *dirSeparator;
-
-#ifdef ANDROID
-void Files::extractLocale()
-{
- // in future need also remove all locales in local dir
-
- const std::string fileName2 = pathJoin(getenv("APPDIR"), "locale.zip");
- VirtFs::mountZip(fileName2, Append_false);
-
- const std::string localDir = std::string(getenv("APPDIR"));
- VirtFs::List *const rootDirs = VirtFs::enumerateFiles("locale");
- FOR_EACH (StringVectCIter, i, rootDirs->names)
- {
- const std::string dir = pathJoin("locale", *i);
- if (VirtFs::isDirectory(dir))
- {
- const std::string moFile = dir + "/LC_MESSAGES/manaplus.mo";
- if (VirtFs::exists((moFile)))
- {
- const std::string localFile = pathJoin(localDir, moFile);
- const std::string localDir2 = pathJoin(localDir,
- dir,
- "LC_MESSAGES");
- mkdir_r(localDir2.c_str());
- copyVirtFsFile(moFile, localFile);
- }
- }
- }
- VirtFs::freeList(rootDirs);
- VirtFs::unmountZip(fileName2);
- remove(fileName2.c_str());
-}
-#endif // ANDROID
-
-#if defined(ANDROID) || defined(__native_client__)
-
-namespace
-{
-#ifdef ANDROID
- int mFilesCount = 0;
-#endif // ANDROID
-
- Files::CopyFileCallbackPtr mCallbackPtr = nullptr;
-} // namespace
-
-void Files::setCopyCallBack(Files::CopyFileCallbackPtr callback)
-{
- mCallbackPtr = callback;
-}
-
-void Files::copyVirtFsFile(const std::string &restrict inFile,
- const std::string &restrict outFile)
-{
- int size = 0;
- const char *const buf = VirtFs::loadFile(inFile, size);
- FILE *const file = fopen(outFile.c_str(), "w");
- fwrite(buf, 1, size, file);
- fclose(file);
- delete [] buf;
-#ifdef ANDROID
- if (mCallbackPtr)
- {
- mCallbackPtr(mFilesCount);
- mFilesCount ++;
- }
-#endif // ANDROID
-}
-
-void Files::copyVirtFsDir(const std::string &restrict inDir,
- const std::string &restrict outDir)
-{
- mkdir_r(outDir.c_str());
- VirtFs::List *const files = VirtFs::enumerateFiles(inDir);
- FOR_EACH (StringVectCIter, i, files->names)
- {
- const std::string file = pathJoin(inDir, *i);
- const std::string outDir2 = pathJoin(outDir, *i);
- if (VirtFs::isDirectory(file))
- copyVirtFsDir(file, outDir2);
- else
- copyVirtFsFile(file, outDir2);
- }
- VirtFs::freeList(files);
-}
-
-#endif // ANDROID __native_client__
-
-int Files::renameFile(const std::string &restrict srcName,
- const std::string &restrict dstName)
-{
-#if defined __native_client__
- FILE *srcFile = fopen(srcName.c_str(), "rb");
- if (srcFile == nullptr)
- return -1;
- FILE *dstFile = fopen(dstName.c_str(), "w+b");
- if (dstFile == nullptr)
- {
- fclose(srcFile);
- return -1;
- }
-
- const int chunkSize = 500000;
- char *buf = new char[chunkSize];
- size_t sz = 0;
- while ((sz = fread(buf, 1, chunkSize, srcFile)))
- {
- if (fwrite(buf, 1, sz, dstFile) != sz)
- {
- delete [] buf;
- fclose(srcFile);
- fclose(dstFile);
- ::remove(dstName.c_str());
- return -1;
- }
- }
-
- delete [] buf;
- fclose(srcFile);
- fclose(dstFile);
- if (!::remove(srcName.c_str()))
- return 0;
-
- return -1;
-#else // defined __native_client__
-
- return ::rename(srcName.c_str(), dstName.c_str());
-#endif // defined __native_client__
-}
-
-int Files::copyFile(const std::string &restrict srcName,
- const std::string &restrict dstName)
-{
- FILE *srcFile = fopen(srcName.c_str(), "rb");
- if (srcFile == nullptr)
- return -1;
- FILE *dstFile = fopen(dstName.c_str(), "w+b");
- if (dstFile == nullptr)
- {
- fclose(srcFile);
- return -1;
- }
-
- const int chunkSize = 512000;
- char *buf = new char[chunkSize];
- size_t sz = 0;
- while ((sz = fread(buf, 1, chunkSize, srcFile)) != 0u)
- {
- if (fwrite(buf, 1, sz, dstFile) != sz)
- {
- delete [] buf;
- fclose(srcFile);
- fclose(dstFile);
- return -1;
- }
- }
-
- delete [] buf;
- fclose(srcFile);
- fclose(dstFile);
- return 0;
-}
-
-bool Files::existsLocal(const std::string &path)
-{
- struct stat statbuf;
-#ifdef WIN32
- // in windows path\file.ext\ by default detected as exists
- // if file.ext is not directory, need return false
- const bool res = (stat(path.c_str(), &statbuf) == 0);
- if (res == false)
- return false;
- if ((findLast(path, "/") == true || findLast(path, "\\") == true) &&
- S_ISDIR(statbuf.st_mode) == 0)
- {
- return false;
- }
- return true;
-#else // WIN32
- return stat(path.c_str(), &statbuf) == 0;
-#endif // WIN32
-}
-
-bool Files::loadTextFileLocal(const std::string &fileName,
- StringVect &lines)
-{
- std::ifstream file;
- char line[501];
-
- file.open(fileName.c_str(), std::ios::in);
-
- if (!file.is_open())
- {
- reportAlways("Couldn't load text file: %s",
- fileName.c_str());
- return false;
- }
-
- while (file.getline(line, 500))
- lines.push_back(line);
-
- return true;
-}
-
-void Files::saveTextFile(const std::string &path,
- const std::string &restrict name,
- const std::string &restrict text)
-{
- if (mkdir_r(path.c_str()) == 0)
- {
- std::ofstream file;
- std::string fileName = pathJoin(path, name);
- file.open(fileName.c_str(), std::ios::out);
- if (file.is_open())
- {
- file << text << std::endl;
- }
- else
- {
- reportAlways("Error opening file for writing: %s",
- fileName.c_str());
- }
- file.close();
- }
-}
-
-void Files::deleteFilesInDirectory(std::string path)
-{
- path = pathJoin(path, dirSeparator);
- const struct dirent *next_file = nullptr;
- DIR *const dir = opendir(path.c_str());
-
- if (dir != nullptr)
- {
- while ((next_file = readdir(dir)) != nullptr)
- {
- const std::string file = next_file->d_name;
- if (file != "." && file != "..")
- remove((path + file).c_str());
- }
- closedir(dir);
- }
-}
-
-void Files::enumFiles(StringVect &files,
- std::string path,
- const bool skipSymlinks A_WIN_UNUSED)
-{
- if (findLast(path, dirSeparator) == false)
- path += dirSeparator;
- DIR *const dir = opendir(path.c_str());
-
- if (dir != nullptr)
- {
- const struct dirent *next_file = nullptr;
- while ((next_file = readdir(dir)) != nullptr)
- {
- const std::string file = next_file->d_name;
- if (file == "." || file == "..")
- continue;
-#ifndef WIN32
- if (skipSymlinks == true)
- {
- struct stat statbuf;
- if (lstat(path.c_str(), &statbuf) == 0 &&
- S_ISLNK(statbuf.st_mode) != 0)
- {
- continue;
- }
- }
-#endif // WIN32
- files.push_back(file);
- }
- closedir(dir);
- }
-}
diff --git a/src/fs/files.h b/src/fs/files.h
deleted file mode 100644
index 146a85ff1..000000000
--- a/src/fs/files.h
+++ /dev/null
@@ -1,69 +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 UTILS_FILES_H
-#define UTILS_FILES_H
-
-#include "utils/stringvector.h"
-
-#include "localconsts.h"
-
-namespace Files
-{
-#ifdef ANDROID
- void extractLocale();
-#endif // ANDROID
-
-#if defined(ANDROID) || defined(__native_client__)
- typedef void (*CopyFileCallbackPtr) (int cnt);
-
- void setCopyCallBack(CopyFileCallbackPtr callback);
-
- void copyVirtFsFile(const std::string &restrict inFile,
- const std::string &restrict outFile);
-
- void copyVirtFsDir(const std::string &restrict inDir,
- const std::string &restrict outDir);
-
-#endif // ANDROID __native_client__
-
- int renameFile(const std::string &restrict pFrom,
- const std::string &restrict pTo);
-
- int copyFile(const std::string &restrict pFrom,
- const std::string &restrict pTo);
-
- bool existsLocal(const std::string &path);
-
- bool loadTextFileLocal(const std::string &fileName,
- StringVect &lines);
-
- void saveTextFile(const std::string &path,
- const std::string &restrict name,
- const std::string &restrict text);
-
- void deleteFilesInDirectory(std::string path);
-
- void enumFiles(StringVect &files,
- std::string path,
- const bool skipSymlinks);
-} // namespace Files
-
-#endif // UTILS_FILES_H
diff --git a/src/fs/mkdir.cpp b/src/fs/mkdir.cpp
deleted file mode 100644
index 341f138da..000000000
--- a/src/fs/mkdir.cpp
+++ /dev/null
@@ -1,166 +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 "fs/mkdir.h"
-
-#include "utils/cast.h"
-
-#if defined WIN32
-#include <limits.h>
-#include <windows.h>
-#endif // defined WIN32
-
-#include <sys/stat.h>
-
-#include "debug.h"
-
-#if defined WIN32
-int mkdir_r(const char *const pathname)
-{
- if (!pathname)
- return -1;
-
- char tmp[PATH_MAX];
- char tmp2[PATH_MAX];
- char *p;
-
- if (strlen(pathname) >= PATH_MAX - 2)
- return -1;
-
- strncpy(tmp, pathname, sizeof(tmp) - 1);
- tmp[PATH_MAX - 1] = '\0';
-
- const int len = CAST_S32(strlen(tmp));
-
- if (len < 1 || len >= INT_MAX)
- return -1;
-
- // terminate the pathname with '/'
- if (tmp[len - 1] != '/')
- {
- tmp[len] = '/';
- tmp[len + 1] = '\0';
- }
-
- for (p = tmp; *p; p++)
- {
- if (*p == '/' || *p == '\\')
- {
- *p = '\0';
- // ignore a slash at the beginning of a path
- if (tmp[0] == 0)
- {
- *p = '/';
- continue;
- }
-
- strcpy(tmp2, tmp);
- char *p2 = tmp2 + strlen(tmp2) - 1;
- if (*p2 == '/' || *p2 == '\\')
- *p2 = 0;
- // check if the name already exists, but not as directory
- struct stat statbuf;
- if (!stat(tmp2, &statbuf))
- {
- if (S_ISDIR(statbuf.st_mode))
- {
- *p = '/';
- continue;
- }
- else
- return -1;
- }
-
- if (!CreateDirectory(tmp2, nullptr))
- {
- // hack, hack. just assume that x: might be a drive
- // letter, and try again
- if (!(strlen(tmp2) == 2 && !strcmp(tmp2 + 1, ":")))
- return -1;
- }
-
- *p = '/';
- }
- }
- return 0;
-}
-#else // WIN32
-
-/// Create a directory, making leading components first if necessary
-int mkdir_r(const char *const pathname)
-{
- if (pathname == nullptr)
- return -1;
-
- const size_t len = CAST_SIZE(strlen(pathname));
- char *tmp = new char[len + 2];
- char *p = nullptr;
-
- strcpy(tmp, pathname);
-
- // terminate the pathname with '/'
- if (tmp[len - 1] != '/')
- {
- tmp[len] = '/';
- tmp[len + 1] = '\0';
- }
-
- for (p = tmp; *p != 0; p++)
- {
- if (*p == '/')
- {
- *p = '\0';
- // ignore a slash at the beginning of a path
- if (tmp[0] == 0)
- {
- *p = '/';
- continue;
- }
-
- // check if the name already exists, but not as directory
- struct stat statbuf;
- if (stat(tmp, &statbuf) == 0)
- {
- if (S_ISDIR(statbuf.st_mode))
- {
- *p = '/';
- continue;
- }
- else
- {
- delete []tmp;
- return -1;
- }
- }
-
- if (mkdir(tmp, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0)
- {
- delete []tmp;
- return -1;
- }
-
- *p = '/';
- }
- }
- delete []tmp;
- return 0;
-}
-#endif // WIN32
diff --git a/src/fs/mkdir.h b/src/fs/mkdir.h
deleted file mode 100644
index a662daca3..000000000
--- a/src/fs/mkdir.h
+++ /dev/null
@@ -1,27 +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 UTILS_MKDIR_H
-#define UTILS_MKDIR_H
-
-int mkdir_r(const char *const pathname);
-
-#endif // UTILS_MKDIR_H
diff --git a/src/fs/paths.cpp b/src/fs/paths.cpp
deleted file mode 100644
index 5698ffa7d..000000000
--- a/src/fs/paths.cpp
+++ /dev/null
@@ -1,279 +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 _MSC_VER
-# include "msvc/config.h"
-#elif defined(HAVE_CONFIG_H)
-#include "config.h"
-#endif // _MSC_VER
-
-#include "fs/paths.h"
-
-#include "fs/virtfs/fs.h"
-
-#include "utils/checkutils.h"
-#include "utils/stringutils.h"
-
-#ifdef USE_X11
-#include "fs/files.h"
-
-#include "utils/foreach.h"
-#endif // USE_X11
-
-#ifdef __native_client__
-#include <limits.h>
-#define realpath(N, R) strcpy(R, N)
-#endif // __native_client__
-
-#ifdef WIN32
-#include "fs/specialfolder.h"
-#define realpath(N, R) _fullpath((R), (N), _MAX_PATH)
-#elif defined __OpenBSD__
-#include <limits>
-#elif defined __native_client__
-#include <limits.h>
-#endif // WIN32
-
-#ifndef WIN32
-#include <unistd.h>
-#include <sys/types.h>
-#include <pwd.h>
-#endif // WIN32
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#ifdef ANDROID
-#ifdef USE_SDL2
-#include <SDL_system.h>
-#endif // USE_SDL2
-#endif // ANDROID
-PRAGMA48(GCC diagnostic pop)
-
-#include "debug.h"
-
-namespace
-{
- std::string mPackageDir;
-} // namespace
-
-std::string getRealPath(const std::string &str)
-{
-#if defined(__OpenBSD__) || defined(__ANDROID__) || defined(__native_client__)
- char *realPath = reinterpret_cast<char*>(calloc(PATH_MAX, sizeof(char)));
- if (!realPath)
- return "";
- realpath(str.c_str(), realPath);
-#else // defined(__OpenBSD__) || defined(__ANDROID__) ||
- // defined(__native_client__)
-
- char *realPath = realpath(str.c_str(), nullptr);
- if (realPath == nullptr)
- return "";
-#endif // defined(__OpenBSD__) || defined(__ANDROID__) ||
- // defined(__native_client__)
-
- std::string path = realPath;
- free(realPath);
- return path;
-}
-
-bool isRealPath(const std::string &str)
-{
- return str == getRealPath(str);
-}
-
-bool checkPath(const std::string &path)
-{
- if (path.empty())
- return true;
- return path.find("../") == std::string::npos
- && path.find("..\\") == std::string::npos
- && path.find("/..") == std::string::npos
- && path.find("\\..") == std::string::npos;
-}
-
-void prepareFsPath(std::string &path)
-{
-#ifdef DEBUGFS
- std::string path2 = path;
-#endif
- sanitizePath(path);
-// can be enabled for debugging
-#ifdef DEBUGFS
- if (path != path2)
- {
- reportAlways("Path can be improved: '%s' -> '%s'",
- path2.c_str(),
- path.c_str());
- }
-#endif
-}
-
-std::string &fixDirSeparators(std::string &str)
-{
-#ifdef WIN32
- return replaceAll(str, "/", "\\");
-#else
- return str;
-#endif
-}
-
-std::string removeLast(const std::string &str)
-{
- size_t pos2 = str.rfind('/');
- const size_t pos3 = str.rfind('\\');
- if (pos3 != std::string::npos)
- {
- if (pos2 == std::string::npos || pos3 > pos2)
- pos2 = pos3;
- }
- if (pos2 != std::string::npos)
- return str.substr(0, pos2);
- return str;
-}
-
-#ifdef WIN32
-std::string getSelfName()
-{
- return "manaplus.exe";
-}
-
-#elif defined(__APPLE__)
-std::string getSelfName()
-{
- return "manaplus.exe";
-}
-
-#elif defined __linux__ || defined __linux
-
-std::string getSelfName()
-{
- char buf[257];
- const ssize_t sz = readlink("/proc/self/exe", buf, 256);
- if (sz > 0 && sz < 256)
- {
- buf[sz] = 0;
- return buf;
- }
- return "";
-}
-
-#else // WIN32
-
-std::string getSelfName()
-{
- return "";
-}
-
-#endif // WIN32
-
-std::string getPicturesDir()
-{
-#ifdef WIN32
- std::string dir = getSpecialFolderLocation(CSIDL_MYPICTURES);
- if (dir.empty())
- dir = getSpecialFolderLocation(CSIDL_DESKTOP);
- return dir;
-#elif defined USE_X11
- char *xdg = getenv("XDG_CONFIG_HOME");
- std::string file;
- if (!xdg)
- {
- file = pathJoin(VirtFs::getUserDir(),
- ".config/user-dirs.dirs");
- }
- else
- {
- file = pathJoin(xdg, "user-dirs.dirs");
- }
-
- if (Files::existsLocal(file))
- {
- StringVect arr;
- Files::loadTextFileLocal(file, arr);
- FOR_EACH (StringVectCIter, it, arr)
- {
- std::string str = *it;
- if (findCutFirst(str, "XDG_PICTURES_DIR=\""))
- {
- str = str.substr(0, str.size() - 1);
- // use hack to replace $HOME var.
- // if in string other vars, fallback to default path
- replaceAll(str, "$HOME/", VirtFs::getUserDir());
- str = getRealPath(str);
- if (str.empty())
- str = pathJoin(VirtFs::getUserDir(), "Desktop");
- return str;
- }
- }
- }
-#endif // WIN32
-
- return pathJoin(VirtFs::getUserDir(), "Desktop");
-}
-
-std::string getHomePath()
-{
-#if defined(UNITTESTS) && defined(UNITESTSDIR)
- std::string dir = UNITESTSDIR;
- if (findLast(dir, std::string(dirSeparator)) == false)
- dir += dirSeparator;
- return dir;
-#else // defined(UNITTESTS) && defined(UNITESTSDIR)
-#ifdef WIN32
- return getSpecialFolderLocation(CSIDL_LOCAL_APPDATA);
-#else
- const char *path = getenv("HOME");
- if (path == nullptr)
- {
- const uid_t uid = getuid();
- const struct passwd *const pw = getpwuid(uid);
- if (pw != nullptr &&
- pw->pw_dir != nullptr)
- {
- path = pw->pw_dir;
- }
- if (path == nullptr)
- return dirSeparator;
- }
- std::string dir = path;
- if (findLast(dir, std::string(dirSeparator)) == false)
- dir += dirSeparator;
- return dir;
-#endif // WIN32
-#endif // defined(UNITTESTS) && defined(UNITESTSDIR)
-}
-
-#ifdef ANDROID
-std::string getSdStoragePath()
-{
- return getenv("DATADIR2");
-}
-#endif // ANDROID
-
-std::string getPackageDir()
-{
- return mPackageDir;
-}
-
-void setPackageDir(const std::string &dir)
-{
- mPackageDir = dir;
-}
diff --git a/src/fs/paths.h b/src/fs/paths.h
deleted file mode 100644
index be431f9c3..000000000
--- a/src/fs/paths.h
+++ /dev/null
@@ -1,54 +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 UTILS_PATHS_H
-#define UTILS_PATHS_H
-
-#include <string>
-
-#include "localconsts.h"
-
-std::string getRealPath(const std::string &str) A_WARN_UNUSED;
-
-bool isRealPath(const std::string &str) A_WARN_UNUSED;
-
-bool checkPath(const std::string &path) A_WARN_UNUSED;
-
-void prepareFsPath(std::string &path);
-
-std::string &fixDirSeparators(std::string &str);
-
-std::string removeLast(const std::string &str) A_WARN_UNUSED;
-
-std::string getSelfName() A_WARN_UNUSED;
-
-std::string getPicturesDir() A_WARN_UNUSED;
-
-#ifdef ANDROID
-std::string getSdStoragePath() A_WARN_UNUSED;
-#endif // ANDROID
-
-std::string getPackageDir() A_WARN_UNUSED;
-
-void setPackageDir(const std::string &dir);
-
-std::string getHomePath();
-
-#endif // UTILS_PATHS_H
diff --git a/src/fs/specialfolder.cpp b/src/fs/specialfolder.cpp
deleted file mode 100644
index ee27dab4b..000000000
--- a/src/fs/specialfolder.cpp
+++ /dev/null
@@ -1,59 +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/>.
- */
-
-#ifdef WIN32
-#include "fs/specialfolder.h"
-#include <windows.h>
-
-#include "debug.h"
-
-/*
- * Retrieve the pathname of special folders on win32, or an empty string
- * on error / if the folder does not exist.
- * See http://msdn.microsoft.com/en-us/library/bb762494(VS.85).aspx for
- * a list of folder ids
- */
-std::string getSpecialFolderLocation(const int folderId)
-{
- std::string ret;
- LPITEMIDLIST pItemIdList;
- LPMALLOC pMalloc;
- char szPath[_MAX_PATH];
-
- // get the item ID list for folderId
- HRESULT hr = SHGetSpecialFolderLocation(nullptr, folderId, &pItemIdList);
- if (hr != S_OK)
- return ret;
-
- // convert the ID list into a file system path
- if (SHGetPathFromIDList(pItemIdList, szPath) == FALSE)
- return ret;
-
- // get the IMalloc pointer and free all resources we used
- hr = SHGetMalloc(&pMalloc);
- pMalloc->Free(pItemIdList);
- pMalloc->Release();
-
- ret = szPath;
- return ret;
-}
-
-#endif // WIN32
diff --git a/src/fs/specialfolder.h b/src/fs/specialfolder.h
deleted file mode 100644
index f2cc93c9b..000000000
--- a/src/fs/specialfolder.h
+++ /dev/null
@@ -1,33 +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 UTILS_SPECIALFOLDER_H
-#define UTILS_SPECIALFOLDER_H
-
-#ifdef WIN32
-#include <shlobj.h>
-#include <string>
-
-#include "localconsts.h"
-std::string getSpecialFolderLocation(const int folderId) A_WARN_UNUSED;
-#endif // WIN32
-
-#endif // UTILS_SPECIALFOLDER_H
diff --git a/src/fs/virtfs/direntry.cpp b/src/fs/virtfs/direntry.cpp
deleted file mode 100644
index c178d4c88..000000000
--- a/src/fs/virtfs/direntry.cpp
+++ /dev/null
@@ -1,45 +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 "fs/virtfs/direntry.h"
-
-#include "debug.h"
-
-namespace VirtFs
-{
-
-DirEntry::DirEntry(const std::string &userDir0,
- const std::string &rootDir,
- const std::string &subDir0,
- const std::string &rootSubDir0,
- FsFuncs *restrict const funcs0) :
- FsEntry(FsEntryType::Dir, funcs0),
- userDir(userDir0),
- rootSubDir(rootSubDir0)
-{
- root = rootDir;
- subDir = subDir0;
-}
-
-DirEntry::~DirEntry()
-{
-}
-
-} // namespace VirtFs
diff --git a/src/fs/virtfs/direntry.h b/src/fs/virtfs/direntry.h
deleted file mode 100644
index 18e700a6a..000000000
--- a/src/fs/virtfs/direntry.h
+++ /dev/null
@@ -1,49 +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 UTILS_VIRTDIRENTRY_H
-#define UTILS_VIRTDIRENTRY_H
-
-#include "fs/virtfs/fsentry.h"
-
-#include "localconsts.h"
-
-namespace VirtFs
-{
-
-struct DirEntry final : public FsEntry
-{
- DirEntry(const std::string &userDir0,
- const std::string &rootDir,
- const std::string &subDir0,
- const std::string &rootSubDir0,
- FsFuncs *restrict const funcs0);
-
- A_DELETE_COPY(DirEntry)
-
- virtual ~DirEntry();
-
- std::string userDir;
- std::string rootSubDir;
-};
-
-} // namespace VirtFs
-
-#endif // UTILS_VIRTDIRENTRY_H
diff --git a/src/fs/virtfs/file.cpp b/src/fs/virtfs/file.cpp
deleted file mode 100644
index fb7fcee11..000000000
--- a/src/fs/virtfs/file.cpp
+++ /dev/null
@@ -1,56 +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 "fs/virtfs/file.h"
-
-#include "debug.h"
-
-namespace VirtFs
-{
-
-File::File(const FsFuncs *restrict const funcs0,
- const uint8_t *restrict const buf,
- const size_t sz) :
- funcs(funcs0),
- mBuf(buf),
- mPos(0U),
- mSize(sz),
- mFd(FILEHDEFAULT)
-{
-}
-
-File::File(const FsFuncs *restrict const funcs0,
- FILEHTYPE fd) :
- funcs(funcs0),
- mBuf(nullptr),
- mPos(0U),
- mSize(0U),
- mFd(fd)
-{
-}
-
-File::~File()
-{
- if (mFd != FILEHDEFAULT)
- FILECLOSE(mFd);
- delete [] mBuf;
-}
-
-} // namespace VirtFs
diff --git a/src/fs/virtfs/file.h b/src/fs/virtfs/file.h
deleted file mode 100644
index c564bade4..000000000
--- a/src/fs/virtfs/file.h
+++ /dev/null
@@ -1,61 +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 UTILS_VIRTFILE_H
-#define UTILS_VIRTFILE_H
-
-#include "localconsts.h"
-
-#include "fs/virtfs/fileapi.h"
-
-namespace VirtFs
-{
-
-struct FsFuncs;
-
-struct File final
-{
- File(const FsFuncs *restrict const funcs0,
- const uint8_t *restrict const buf,
- const size_t sz);
-
- File(const FsFuncs *restrict const funcs0,
- FILEHTYPE fd);
-
- A_DELETE_COPY(File)
-
- ~File();
-
- const FsFuncs *funcs;
-
- // zipfs fields
- const uint8_t *mBuf;
-
- // zipfs fields
- size_t mPos;
- size_t mSize;
-
- // dirfs fields
- FILEHTYPE mFd;
-};
-
-} // namespace VirtFs
-
-#endif // UTILS_VIRTFILE_H
diff --git a/src/fs/virtfs/fileapi.h b/src/fs/virtfs/fileapi.h
deleted file mode 100644
index 14e7b8204..000000000
--- a/src/fs/virtfs/fileapi.h
+++ /dev/null
@@ -1,48 +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 UTILS_VIRTFS_FILEAPI_H
-#define UTILS_VIRTFS_FILEAPI_H
-
-#include "localconsts.h"
-
-#ifdef USE_FILE_FOPEN
-#define FILEHTYPE FILE *const
-#define FILEMTYPE char *
-#define FILEHDEFAULT nullptr
-#define FILEOPEN(path, mode) fopen(path, mode)
-#define FILECLOSE fclose
-#define FILESEEK fseek
-#define FILEOPEN_FLAG_READ "rb"
-#define FILEOPEN_FLAG_WRITE "wb"
-#define FILEOPEN_FLAG_APPEND "ab"
-#else // USE_FILE_FOPEN
-#define FILEHTYPE const int
-#define FILEMTYPE int
-#define FILEHDEFAULT -1
-#define FILEOPEN(path, mode) open(path, mode, S_IRUSR | S_IWUSR)
-#define FILECLOSE close
-#define FILESEEK lseek
-#define FILEOPEN_FLAG_READ O_RDONLY
-#define FILEOPEN_FLAG_WRITE O_WRONLY | O_CREAT | O_TRUNC
-#define FILEOPEN_FLAG_APPEND O_WRONLY | O_CREAT | O_APPEND
-#endif // USE_FILE_FOPEN
-
-#endif // UTILS_VIRTFS_FILEAPI_H
diff --git a/src/fs/virtfs/fs.cpp b/src/fs/virtfs/fs.cpp
deleted file mode 100644
index 2ec75ac05..000000000
--- a/src/fs/virtfs/fs.cpp
+++ /dev/null
@@ -1,880 +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 "fs/virtfs/fs.h"
-
-#include "fs/files.h"
-#include "fs/paths.h"
-
-#include "fs/virtfs/direntry.h"
-#include "fs/virtfs/file.h"
-#include "fs/virtfs/fsdir.h"
-#include "fs/virtfs/fsfuncs.h"
-#include "fs/virtfs/fszip.h"
-#include "fs/virtfs/list.h"
-#include "fs/virtfs/zipentry.h"
-#include "fs/virtfs/zipreader.h"
-
-#include "utils/checkutils.h"
-#include "utils/foreach.h"
-#include "utils/stdmove.h"
-#include "utils/stringutils.h"
-
-#include "debug.h"
-
-const char *dirSeparator = nullptr;
-
-#ifdef UNITTESTS
-#define reportNonTests logger->log
-#else // UNITTESTS
-#define reportNonTests reportAlways
-#endif // UNITTESTS
-
-namespace VirtFs
-{
- namespace
- {
- STD_VECTOR<FsEntry*> mEntries;
- } // namespace
-
- void init(const std::string &restrict name)
- {
- updateDirSeparator();
- FsDir::init(name);
- FsZip::init();
- }
-
- void updateDirSeparator()
- {
-#ifdef WIN32
- dirSeparator = "\\";
-#else // WIN32
- dirSeparator = "/";
-#endif // WIN32
- }
-
- const char *getDirSeparator()
- {
- return dirSeparator;
- }
-
- const char *getBaseDir()
- {
- return FsDir::getBaseDir();
- }
-
- const char *getUserDir()
- {
- return FsDir::getUserDir();
- }
-
- STD_VECTOR<FsEntry*> &getEntries()
- {
- return mEntries;
- }
-
- FsEntry *searchByRootInternal(const std::string &restrict root,
- const std::string &restrict subDir)
- {
- FOR_EACH (STD_VECTOR<FsEntry*>::const_iterator, it, mEntries)
- {
- const FsEntry *const entry = *it;
- if (entry->root == root &&
- entry->subDir == subDir)
- {
- return *it;
- }
- }
- return nullptr;
- }
-
- FsEntry *searchByTypeInternal(const std::string &restrict root,
- const FsEntryTypeT type)
- {
- FOR_EACH (STD_VECTOR<FsEntry*>::const_iterator, it, mEntries)
- {
- const FsEntry *const entry = *it;
- if (entry->root == root &&
- entry->type == type)
- {
- return *it;
- }
- }
- return nullptr;
- }
-
- bool exists(std::string name)
- {
- prepareFsPath(name);
- if (checkPath(name) == false)
- {
- reportAlways("FsDir::exists invalid path: %s",
- name.c_str());
- return false;
- }
-
- std::string rootDir = name;
- if (findLast(rootDir, std::string(dirSeparator)) == false)
- rootDir += dirSeparator;
-
- FOR_EACH (STD_VECTOR<FsEntry*>::const_iterator, it, mEntries)
- {
- FsEntry *const entry = *it;
- if (entry->funcs->exists(entry, name, rootDir) == true)
- return true;
- }
- return false;
- }
-
- List *enumerateFiles(std::string dirName)
- {
- List *const list = new List;
- prepareFsPath(dirName);
- if (checkPath(dirName) == false)
- {
- reportAlways("VirtFs::enumerateFiles invalid path: %s",
- dirName.c_str());
- return list;
- }
-
- std::string rootDir = STD_MOVE(dirName);
- if (findLast(rootDir, std::string(dirSeparator)) == false)
- rootDir += dirSeparator;
- StringVect &names = list->names;
-
- FOR_EACH (STD_VECTOR<FsEntry*>::const_iterator, it, mEntries)
- {
- FsEntry *const entry = *it;
- entry->funcs->enumerate(entry, rootDir, names);
- }
-
- return list;
- }
-
- void getFiles(std::string dirName,
- StringVect &list)
- {
- prepareFsPath(dirName);
- if (checkPath(dirName) == false)
- {
- reportAlways("VirtFs::enumerateFiles invalid path: %s",
- dirName.c_str());
- return;
- }
-
- std::string rootDir = STD_MOVE(dirName);
- if (findLast(rootDir, std::string(dirSeparator)) == false)
- rootDir += dirSeparator;
-
- FOR_EACH (STD_VECTOR<FsEntry*>::const_iterator, it, mEntries)
- {
- FsEntry *const entry = *it;
- entry->funcs->getFiles(entry, rootDir, list);
- }
- }
-
- void getFilesWithDir(std::string dirName,
- StringVect &list)
- {
- prepareFsPath(dirName);
- if (checkPath(dirName) == false)
- {
- reportAlways("VirtFs::enumerateFiles invalid path: %s",
- dirName.c_str());
- return;
- }
-
- std::string rootDir = STD_MOVE(dirName);
- if (findLast(rootDir, std::string(dirSeparator)) == false)
- rootDir += dirSeparator;
-
- FOR_EACH (STD_VECTOR<FsEntry*>::const_iterator, it, mEntries)
- {
- FsEntry *const entry = *it;
- entry->funcs->getFilesWithDir(entry, rootDir, list);
- }
- }
-
-
- void getDirs(std::string dirName,
- StringVect &list)
- {
- prepareFsPath(dirName);
- if (checkPath(dirName) == false)
- {
- reportAlways("VirtFs::enumerateFiles invalid path: %s",
- dirName.c_str());
- return;
- }
-
- std::string rootDir = STD_MOVE(dirName);
- if (findLast(rootDir, std::string(dirSeparator)) == false)
- rootDir += dirSeparator;
-
- FOR_EACH (STD_VECTOR<FsEntry*>::const_iterator, it, mEntries)
- {
- FsEntry *const entry = *it;
- entry->funcs->getDirs(entry, rootDir, list);
- }
- }
-
- bool isDirectory(std::string name)
- {
- prepareFsPath(name);
- if (checkPath(name) == false)
- {
- reportAlways("VirtFs::isDirectory invalid path: %s",
- name.c_str());
- return false;
- }
- std::string dirName = STD_MOVE(name);
- if (findLast(dirName, std::string(dirSeparator)) == false)
- dirName += dirSeparator;
-
- FOR_EACH (STD_VECTOR<FsEntry*>::const_iterator, it, mEntries)
- {
- FsEntry *const entry = *it;
- bool isDirFlag(false);
- if (entry->funcs->isDirectory(entry, dirName, isDirFlag) == true)
- {
- return isDirFlag;
- }
- }
- return false;
- }
-
- bool isSymbolicLink(const std::string &restrict name)
- {
- return FsDir::isSymbolicLink(name);
- }
-
- void freeList(List *restrict const handle)
- {
- delete handle;
- }
-
- File *openRead(std::string filename)
- {
- prepareFsPath(filename);
- if (checkPath(filename) == false)
- {
- reportAlways("VirtFs::openRead invalid path: %s",
- filename.c_str());
- return nullptr;
- }
- FOR_EACH (STD_VECTOR<FsEntry*>::const_iterator, it, mEntries)
- {
- FsEntry *const entry = *it;
- File *const file = entry->funcs->openRead(entry, filename);
- if (file != nullptr)
- return file;
- }
- return nullptr;
- }
-
- File *openWrite(std::string filename)
- {
- prepareFsPath(filename);
- if (checkPath(filename) == false)
- {
- reportAlways("VirtFs::openWrite invalid path: %s",
- filename.c_str());
- return nullptr;
- }
- FOR_EACH (STD_VECTOR<FsEntry*>::const_iterator, it, mEntries)
- {
- FsEntry *const entry = *it;
- File *const file = entry->funcs->openWrite(entry, filename);
- if (file != nullptr)
- return file;
- }
- return nullptr;
- }
-
- File *openAppend(std::string filename)
- {
- prepareFsPath(filename);
- if (checkPath(filename) == false)
- {
- reportAlways("VirtFs::openAppend invalid path: %s",
- filename.c_str());
- return nullptr;
- }
- FOR_EACH (STD_VECTOR<FsEntry*>::const_iterator, it, mEntries)
- {
- FsEntry *const entry = *it;
- File *const file = entry->funcs->openAppend(entry, filename);
- if (file != nullptr)
- return file;
- }
- return nullptr;
- }
-
- bool setWriteDir(const std::string &restrict newDir)
- {
- return FsDir::setWriteDir(newDir);
- }
-
- void addEntry(FsEntry *const entry,
- const Append append)
- {
- if (append == Append_true)
- mEntries.push_back(entry);
- else
- mEntries.insert(mEntries.begin(), entry);
- }
-
- bool mountDirInternal(const std::string &restrict newDir,
- std::string subDir,
- const Append append)
- {
- if (newDir.find(".zip") != std::string::npos)
- {
- reportAlways("Called FsDir::mount with zip archive");
- return false;
- }
- std::string rootDir = newDir;
- if (findLast(rootDir, std::string(dirSeparator)) == false)
- rootDir += dirSeparator;
- if (subDir == dirSeparator)
- {
- subDir.clear();
- }
- else if (!subDir.empty() &&
- findLast(subDir, std::string(dirSeparator)) == false)
- {
- subDir += dirSeparator;
- }
- const FsEntry *const entry = searchByRootInternal(rootDir, subDir);
- if (entry != nullptr)
- {
- reportAlways("VirtFs::mount already exists: %s",
- newDir.c_str());
- return false;
- }
- if (subDir.empty())
- {
- logger->log("Add virtual directory: " + newDir);
- }
- else
- {
- logger->log("Add virtual directory: %s with dir %s",
- newDir.c_str(),
- subDir.c_str());
- }
-
- addEntry(new DirEntry(newDir,
- rootDir,
- subDir,
- rootDir + subDir,
- FsDir::getFuncs()),
- append);
- return true;
- }
-
- bool mountDir(std::string newDir,
- const Append append)
- {
- prepareFsPath(newDir);
- if (Files::existsLocal(newDir) == false)
- {
- reportNonTests("VirtFs::mount directory not exists: %s",
- newDir.c_str());
- return false;
- }
- return mountDirInternal(newDir, dirSeparator, append);
- }
-
- bool mountDir2(std::string newDir,
- std::string subDir,
- const Append append)
- {
- prepareFsPath(newDir);
- prepareFsPath(subDir);
- if (Files::existsLocal(newDir) == false)
- {
- reportNonTests("VirtFs::mount directory not exists: %s",
- newDir.c_str());
- return false;
- }
- return mountDirInternal(newDir, subDir, append);
- }
-
- bool mountDirSilent(std::string newDir,
- const Append append)
- {
- prepareFsPath(newDir);
- if (Files::existsLocal(newDir) == false)
- {
- logger->log("VirtFs::mount directory not exists: %s",
- newDir.c_str());
- return false;
- }
- return mountDirInternal(newDir, std::string(), append);
- }
-
- bool mountDirSilent2(std::string newDir,
- std::string subDir,
- const Append append)
- {
- prepareFsPath(newDir);
- prepareFsPath(subDir);
- if (Files::existsLocal(newDir) == false)
- {
- logger->log("VirtFs::mount directory not exists: %s",
- newDir.c_str());
- return false;
- }
- return mountDirInternal(newDir, subDir, append);
- }
-
-#ifdef UNITTESTS
- bool mountDirSilentTest(std::string newDir,
- const Append append)
- {
- prepareFsPath(newDir);
- if (Files::existsLocal(newDir) == false)
- {
- logger->log("VirtFs::mount directory not exists: %s",
- newDir.c_str());
- }
- return mountDirInternal(newDir, std::string(), append);
- }
-
- bool mountDirSilentTest2(std::string newDir,
- std::string subDir,
- const Append append)
- {
- prepareFsPath(newDir);
- prepareFsPath(subDir);
- if (Files::existsLocal(newDir) == false)
- {
- logger->log("VirtFs::mount directory not exists: %s",
- newDir.c_str());
- }
- return mountDirInternal(newDir, subDir, append);
- }
-#endif // UNITTESTS
-
- bool unmountDirInternal(std::string oldDir,
- std::string subDir)
- {
- if (findLast(oldDir, std::string(dirSeparator)) == false)
- oldDir += dirSeparator;
- if (subDir == dirSeparator)
- {
- subDir.clear();
- }
- else if (!subDir.empty() &&
- findLast(subDir, std::string(dirSeparator)) == false)
- {
- subDir += dirSeparator;
- }
- FOR_EACH (STD_VECTOR<FsEntry*>::iterator, it, mEntries)
- {
- FsEntry *const entry = *it;
- if (entry->root == oldDir &&
- entry->type == FsEntryType::Dir &&
- entry->subDir == subDir)
- {
- DirEntry *const dirEntry = static_cast<DirEntry*>(
- entry);
- if (subDir.empty())
- {
- logger->log("Remove virtual directory: " + oldDir);
- }
- else
- {
- logger->log("Remove virtual directory: %s with dir %s",
- oldDir.c_str(),
- subDir.c_str());
- }
- mEntries.erase(it);
- delete dirEntry;
- return true;
- }
- }
- return false;
- }
-
- bool unmountDir(std::string oldDir)
- {
- prepareFsPath(oldDir);
- if (oldDir.find(".zip") != std::string::npos)
- {
- reportAlways("Called unmount with zip archive");
- return false;
- }
- if (unmountDirInternal(oldDir, std::string()) == false)
- {
- reportAlways("VirtFs::unmountDir not exists: %s",
- oldDir.c_str());
- return false;
- }
- return true;
- }
-
- bool unmountDir2(std::string oldDir,
- std::string subDir)
- {
- prepareFsPath(oldDir);
- if (oldDir.find(".zip") != std::string::npos)
- {
- reportAlways("Called unmount with zip archive");
- return false;
- }
- prepareFsPath(subDir);
- if (unmountDirInternal(oldDir, subDir) == false)
- {
- reportAlways("VirtFs::unmountDir not exists: %s",
- oldDir.c_str());
- return false;
- }
- return true;
- }
-
- bool unmountDirSilent(std::string oldDir)
- {
- prepareFsPath(oldDir);
- if (oldDir.find(".zip") != std::string::npos)
- {
- reportAlways("Called unmount with zip archive");
- return false;
- }
- if (unmountDirInternal(oldDir, std::string()) == false)
- {
- logger->log("VirtFs::unmountDir not exists: %s",
- oldDir.c_str());
- return false;
- }
- return true;
- }
-
- bool unmountDirSilent2(std::string oldDir,
- std::string subDir)
- {
- prepareFsPath(oldDir);
- if (oldDir.find(".zip") != std::string::npos)
- {
- reportAlways("Called unmount with zip archive");
- return false;
- }
- prepareFsPath(subDir);
- if (unmountDirInternal(oldDir, subDir) == false)
- {
- logger->log("VirtFs::unmountDir not exists: %s",
- oldDir.c_str());
- return false;
- }
- return true;
- }
-
- bool mountZip(std::string newDir,
- const Append append)
- {
- prepareFsPath(newDir);
- if (Files::existsLocal(newDir) == false)
- {
- reportNonTests("FsZip::mount file not exists: %s",
- newDir.c_str());
- return false;
- }
- if (findLast(newDir, ".zip") == false)
- {
- reportAlways("Called VirtFs::mount without "
- "zip archive");
- return false;
- }
- if (searchByRootInternal(newDir, std::string()) != nullptr)
- {
- reportAlways("FsZip::mount already exists: %s",
- newDir.c_str());
- return false;
- }
- ZipEntry *const entry = new ZipEntry(newDir,
- std::string(),
- FsZip::getFuncs());
- if (ZipReader::readArchiveInfo(entry) == false)
- {
- delete entry;
- return false;
- }
-
- logger->log("Add virtual zip: " + newDir);
- addEntry(entry, append);
- return true;
- }
-
- bool mountZip2(std::string newDir,
- std::string subDir,
- const Append append)
- {
- prepareFsPath(newDir);
- if (Files::existsLocal(newDir) == false)
- {
- reportNonTests("FsZip::mount file not exists: %s",
- newDir.c_str());
- return false;
- }
- if (findLast(newDir, ".zip") == false)
- {
- reportAlways("Called VirtFs::mount without "
- "zip archive");
- return false;
- }
- prepareFsPath(subDir);
- if (subDir == dirSeparator)
- {
- subDir.clear();
- }
- else if (!subDir.empty() &&
- findLast(subDir, std::string(dirSeparator)) == false)
- {
- subDir += dirSeparator;
- }
- if (searchByRootInternal(newDir, subDir) != nullptr)
- {
- reportAlways("FsZip::mount already exists: %s",
- newDir.c_str());
- return false;
- }
- ZipEntry *const entry = new ZipEntry(newDir,
- subDir,
- FsZip::getFuncs());
- if (ZipReader::readArchiveInfo(entry) == false)
- {
- delete entry;
- return false;
- }
-
- logger->log("Add virtual zip: %s with dir %s",
- newDir.c_str(),
- subDir.c_str());
- addEntry(entry, append);
- return true;
- }
-
- bool unmountZip(std::string oldDir)
- {
- prepareFsPath(oldDir);
- if (findLast(oldDir, ".zip") == false)
- {
- reportAlways("Called unmount without zip archive");
- return false;
- }
- FOR_EACH (STD_VECTOR<FsEntry*>::iterator, it, mEntries)
- {
- FsEntry *const entry = *it;
- if (entry->root == oldDir &&
- entry->type == FsEntryType::Zip &&
- entry->subDir.empty())
- {
- ZipEntry *const zipEntry = static_cast<ZipEntry*>(
- entry);
- logger->log("Remove virtual zip: " + oldDir);
- mEntries.erase(it);
- delete zipEntry;
- return true;
- }
- }
-
- reportAlways("VirtFs::unmountZip not exists: %s",
- oldDir.c_str());
- return false;
- }
-
- bool unmountZip2(std::string oldDir,
- std::string subDir)
- {
- prepareFsPath(oldDir);
- if (findLast(oldDir, ".zip") == false)
- {
- reportAlways("Called unmount without zip archive");
- return false;
- }
- prepareFsPath(subDir);
- if (subDir == dirSeparator)
- {
- subDir.clear();
- }
- else if (!subDir.empty() &&
- findLast(subDir, std::string(dirSeparator)) == false)
- {
- subDir += dirSeparator;
- }
- FOR_EACH (STD_VECTOR<FsEntry*>::iterator, it, mEntries)
- {
- FsEntry *const entry = *it;
- if (entry->root == oldDir &&
- entry->type == FsEntryType::Zip &&
- entry->subDir == subDir)
- {
- ZipEntry *const zipEntry = static_cast<ZipEntry*>(
- entry);
- logger->log("Remove virtual zip: %s with dir %s",
- oldDir.c_str(),
- subDir.c_str());
- mEntries.erase(it);
- delete zipEntry;
- return true;
- }
- }
-
- reportAlways("VirtFs::unmountZip not exists: %s",
- oldDir.c_str());
- return false;
- }
-
- std::string getRealDir(std::string fileName)
- {
- prepareFsPath(fileName);
- if (checkPath(fileName) == false)
- {
- reportAlways("FsDir::getRealDir invalid path: %s",
- fileName.c_str());
- return std::string();
- }
-
- std::string rootDir = fileName;
- if (findLast(rootDir, std::string(dirSeparator)) == false)
- rootDir += dirSeparator;
-
- FOR_EACH (STD_VECTOR<FsEntry*>::const_iterator, it, mEntries)
- {
- FsEntry *const entry = *it;
- std::string realDir;
- if (entry->funcs->getRealDir(entry,
- fileName,
- rootDir,
- realDir) == true)
- {
- return realDir;
- }
- }
- return std::string();
- }
-
- bool mkdir(const std::string &restrict dirname)
- {
- return FsDir::mkdir(dirname);
- }
-
- bool remove(const std::string &restrict filename)
- {
- return FsDir::remove(filename);
- }
-
- bool deinit()
- {
- FsDir::deinit();
- FsZip::deinit();
- FOR_EACH (STD_VECTOR<FsEntry*>::iterator, it, mEntries)
- {
- FsEntry *const entry = *it;
- if (entry->type == FsEntryType::Dir)
- delete static_cast<DirEntry*>(entry);
- else if (entry->type == FsEntryType::Zip)
- delete static_cast<ZipEntry*>(entry);
- else
- delete entry;
- }
- mEntries.clear();
- return true;
- }
-
- void permitLinks(const bool val)
- {
- FsDir::permitLinks(val);
- }
-
- int close(File *restrict const file)
- {
- if (file == nullptr)
- return 0;
- return file->funcs->close(file);
- }
-
- int64_t read(File *restrict const file,
- void *restrict const buffer,
- const uint32_t objSize,
- const uint32_t objCount)
- {
- return file->funcs->read(file,
- buffer,
- objSize,
- objCount);
- }
-
- int64_t write(File *restrict const file,
- const void *restrict const buffer,
- const uint32_t objSize,
- const uint32_t objCount)
- {
- return file->funcs->write(file,
- buffer,
- objSize,
- objCount);
- }
-
- int64_t fileLength(File *restrict const file)
- {
- return file->funcs->fileLength(file);
- }
-
- int64_t tell(File *restrict const file)
- {
- return file->funcs->tell(file);
- }
-
- int seek(File *restrict const file,
- const uint64_t pos)
- {
- return file->funcs->seek(file,
- pos);
- }
-
- int eof(File *restrict const file)
- {
- return file->funcs->eof(file);
- }
-
- const char *loadFile(std::string filename,
- int &restrict fileSize)
- {
- prepareFsPath(filename);
- if (checkPath(filename) == false)
- {
- reportAlways("VirtFs::loadFile invalid path: %s",
- filename.c_str());
- return nullptr;
- }
- FOR_EACH (STD_VECTOR<FsEntry*>::const_iterator, it, mEntries)
- {
- FsEntry *const entry = *it;
- const char *const buf = entry->funcs->loadFile(entry,
- filename,
- fileSize);
- if (buf != nullptr)
- return buf;
- }
- return nullptr;
- }
-
-} // namespace VirtFs
diff --git a/src/fs/virtfs/fs.h b/src/fs/virtfs/fs.h
deleted file mode 100644
index 326a88d90..000000000
--- a/src/fs/virtfs/fs.h
+++ /dev/null
@@ -1,127 +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 FS_VIRTFS_H
-#define FS_VIRTFS_H
-
-#include "enums/fs/fsentrytype.h"
-
-#include "enums/simpletypes/append.h"
-
-#include "utils/stringvector.h"
-
-#include "localconsts.h"
-
-namespace VirtFs
-{
- struct File;
- struct FsEntry;
- struct List;
-
- void init(const std::string &restrict name);
- void updateDirSeparator();
- const char *getDirSeparator();
- const char *getBaseDir();
- const char *getUserDir();
- bool exists(std::string name);
- List *enumerateFiles(std::string dir) RETURNS_NONNULL;
- bool isDirectory(std::string name);
- bool isSymbolicLink(const std::string &restrict name);
- void freeList(List *restrict const handle);
- File *openRead(std::string filename);
- File *openWrite(std::string filename);
- File *openAppend(std::string filename);
- bool setWriteDir(const std::string &restrict newDir);
- bool mountDir(std::string newDir,
- const Append append);
- bool mountDir2(std::string newDir,
- std::string subDir,
- const Append append);
- bool mountDirSilent(std::string newDir,
- const Append append);
- bool mountDirSilent2(std::string newDir,
- std::string subDir,
- const Append append);
- bool unmountDir(std::string oldDir);
- bool unmountDir2(std::string oldDir,
- std::string subDir);
- bool unmountDirSilent(std::string oldDir);
- bool unmountDirSilent2(std::string oldDir,
- std::string subDir);
- bool mountZip(std::string newDir,
- const Append append);
- bool mountZip2(std::string newDir,
- std::string subDir,
- const Append append);
- bool unmountZip(std::string oldDir);
- bool unmountZip2(std::string oldDir,
- std::string subDir);
- std::string getRealDir(std::string filename);
- bool mkdir(const std::string &restrict dirName);
- bool remove(const std::string &restrict filename);
- bool deinit();
- void permitLinks(const bool val);
- int64_t read(File *restrict const handle,
- void *restrict const buffer,
- const uint32_t objSize,
- const uint32_t objCount);
- int64_t write(File *restrict const file,
- const void *restrict const buffer,
- const uint32_t objSize,
- const uint32_t objCount);
- int close(File *restrict const file);
- int64_t fileLength(File *restrict const file);
- int64_t tell(File *restrict const file);
- int seek(File *restrict const file,
- const uint64_t pos);
- int eof(File *restrict const file);
-
- bool mountDirInternal(const std::string &restrict newDir,
- std::string subDir,
- const Append append);
- bool unmountDirInternal(std::string oldDir,
- std::string subDir);
- STD_VECTOR<FsEntry*> &getEntries();
- FsEntry *searchByRootInternal(const std::string &restrict root,
- const std::string &restrict subDir);
- FsEntry *searchByTypeInternal(const std::string &restrict root,
- const FsEntryTypeT type);
- void addEntry(FsEntry *const entry,
- const Append append);
-#ifdef UNITTESTS
- bool mountDirSilentTest(std::string newDir,
- const Append append);
- bool mountDirSilentTest2(std::string newDir,
- std::string subDir,
- const Append append);
-#endif // UNITTESTS
- const char *loadFile(std::string filename,
- int &restrict fileSize);
- void getFiles(std::string dirName,
- StringVect &list);
- void getFilesWithDir(std::string dirName,
- StringVect &list);
- void getDirs(std::string dirName,
- StringVect &list);
-} // namespace VirtFs
-
-extern const char *dirSeparator;
-
-#endif // FS_VIRTFS_H
diff --git a/src/fs/virtfs/fsdir.cpp b/src/fs/virtfs/fsdir.cpp
deleted file mode 100644
index f32cbba4b..000000000
--- a/src/fs/virtfs/fsdir.cpp
+++ /dev/null
@@ -1,686 +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 "fs/virtfs/fsdir.h"
-
-#include "fs/files.h"
-#include "fs/mkdir.h"
-#include "fs/paths.h"
-
-#include "fs/virtfs/direntry.h"
-#include "fs/virtfs/file.h"
-#include "fs/virtfs/fsdirrwops.h"
-#include "fs/virtfs/fsfuncs.h"
-#include "fs/virtfs/list.h"
-
-#include "utils/cast.h"
-#include "utils/checkutils.h"
-#include "utils/foreach.h"
-#include "utils/stdmove.h"
-#include "utils/stringutils.h"
-
-#include <dirent.h>
-#include <unistd.h>
-
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#include "debug.h"
-
-extern const char *dirSeparator;
-
-namespace VirtFs
-{
-
-namespace
-{
- std::string mWriteDir;
- std::string mBaseDir;
- std::string mUserDir;
- bool mPermitLinks = false;
- FsFuncs funcs;
-} // namespace
-
-namespace FsDir
-{
- File *openInternal(FsEntry *restrict const entry,
- const std::string &filename,
- const FILEMTYPE mode)
- {
- const std::string path = static_cast<DirEntry*>(entry)->rootSubDir +
- filename;
- if (Files::existsLocal(path) == false)
- return nullptr;
- FILEHTYPE fd = FILEOPEN(path.c_str(),
- mode);
- if (fd == FILEHDEFAULT)
- {
- reportAlways("VirtFs::open file open error: %s",
- filename.c_str());
- return nullptr;
- }
- return new File(&funcs, fd);
- }
-
- File *openRead(FsEntry *restrict const entry,
- std::string filename)
- {
- return openInternal(entry, filename, FILEOPEN_FLAG_READ);
- }
-
- File *openWrite(FsEntry *restrict const entry,
- const std::string &filename)
- {
- return openInternal(entry, filename, FILEOPEN_FLAG_WRITE);
- }
-
- File *openAppend(FsEntry *restrict const entry,
- const std::string &filename)
- {
- return openInternal(entry, filename, FILEOPEN_FLAG_APPEND);
- }
-
- void deinit()
- {
- }
-
-#if defined(__native_client__)
- void init(const std::string &restrict name A_UNUSED)
- {
- mBaseDir = "/";
-#elif defined(ANDROID)
- void init(const std::string &restrict name A_UNUSED)
- {
- mBaseDir = getRealPath(".");
-#else // defined(__native_client__)
-
- void init(const std::string &restrict name)
- {
- mBaseDir = getRealPath(getFileDir(name));
-#endif // defined(__native_client__)
-
- prepareFsPath(mBaseDir);
- mUserDir = getHomePath();
- prepareFsPath(mUserDir);
- initFuncs(&funcs);
- }
-
- void initFuncs(FsFuncs *restrict const ptr)
- {
- ptr->close = &FsDir::close;
- ptr->read = &FsDir::read;
- ptr->write = &FsDir::write;
- ptr->fileLength = &FsDir::fileLength;
- ptr->tell = &FsDir::tell;
- ptr->seek = &FsDir::seek;
- ptr->eof = &FsDir::eof;
- ptr->exists = &FsDir::exists;
- ptr->getRealDir = &FsDir::getRealDir;
- ptr->enumerate = &FsDir::enumerate;
- ptr->isDirectory = &FsDir::isDirectory;
- ptr->openRead = &FsDir::openRead;
- ptr->openWrite = &FsDir::openWrite;
- ptr->openAppend = &FsDir::openAppend;
- ptr->loadFile = &FsDir::loadFile;
- ptr->getFiles = &FsDir::getFiles;
- ptr->getFilesWithDir = &FsDir::getFilesWithDir;
- ptr->getDirs = &FsDir::getDirs;
- ptr->rwops_seek = &FsDir::rwops_seek;
- ptr->rwops_read = &FsDir::rwops_read;
- ptr->rwops_write = &FsDir::rwops_write;
- ptr->rwops_close = &FsDir::rwops_close;
-#ifdef USE_SDL2
- ptr->rwops_size = &FsDir::rwops_size;
-#endif // USE_SDL2
- }
-
- FsFuncs *getFuncs()
- {
- return &funcs;
- }
-
- const char *getBaseDir()
- {
- return mBaseDir.c_str();
- }
-
- const char *getUserDir()
- {
- return mUserDir.c_str();
- }
-
- bool getRealDir(FsEntry *restrict const entry,
- std::string filename,
- std::string dirName A_UNUSED,
- std::string &realDir)
- {
- const DirEntry *const dirEntry = static_cast<const DirEntry*>(entry);
- if (Files::existsLocal(dirEntry->rootSubDir + filename))
- {
- realDir = dirEntry->userDir;
- return true;
- }
- return false;
- }
-
- bool exists(FsEntry *restrict const entry,
- std::string fileName,
- std::string dirName A_UNUSED)
- {
- return Files::existsLocal(static_cast<DirEntry*>(entry)->rootSubDir +
- fileName);
- }
-
- void enumerate(FsEntry *restrict const entry,
- std::string dirName,
- StringVect &names)
- {
- const std::string path = static_cast<DirEntry*>(entry)->rootSubDir +
- dirName;
- const struct dirent *next_file = nullptr;
- DIR *const dir = opendir(path.c_str());
- if (dir != nullptr)
- {
- while ((next_file = readdir(dir)) != nullptr)
- {
- const std::string file = next_file->d_name;
- if (file == "." || file == "..")
- continue;
-#ifndef WIN32
- if (mPermitLinks == false)
- {
- struct stat statbuf;
- if (lstat(path.c_str(), &statbuf) == 0 &&
- S_ISLNK(statbuf.st_mode) != 0)
- {
- continue;
- }
- }
-#endif // WIN32
-
- bool found(false);
- FOR_EACH (StringVectCIter, itn, names)
- {
- if (*itn == file)
- {
- found = true;
- break;
- }
- }
- if (found == false)
- names.push_back(file);
- }
- closedir(dir);
- }
- }
-
- bool isDirectory(FsEntry *restrict const entry,
- std::string dirName,
- bool &isDirFlag)
- {
- std::string path = static_cast<DirEntry*>(entry)->rootSubDir + dirName;
-
- struct stat statbuf;
- if (stat(path.c_str(), &statbuf) == 0)
- {
- isDirFlag = (S_ISDIR(statbuf.st_mode) != 0);
- return true;
- }
- return false;
- }
-
- bool isSymbolicLink(std::string name)
- {
- prepareFsPath(name);
- if (checkPath(name) == false)
- {
- reportAlways("FsDir::isSymbolicLink invalid path: %s",
- name.c_str());
- return false;
- }
-#ifndef WIN32
- if (mPermitLinks == false)
- return false;
-
- struct stat statbuf;
- return lstat(name.c_str(), &statbuf) == 0 &&
- S_ISLNK(statbuf.st_mode) != 0;
-#else
- return false;
-#endif // WIN32
- }
-
- void freeList(List *restrict const handle)
- {
- delete handle;
- }
-
- bool setWriteDir(std::string newDir)
- {
- prepareFsPath(newDir);
- mWriteDir = STD_MOVE(newDir);
- if (findLast(mWriteDir, std::string(dirSeparator)) == false)
- mWriteDir += dirSeparator;
- return true;
- }
-
- bool mkdir(std::string dirname)
- {
- prepareFsPath(dirname);
- if (mWriteDir.empty())
- {
- reportAlways("FsDir::mkdir write dir is empty");
- return false;
- }
- return mkdir_r((mWriteDir + dirname).c_str()) != -1;
- }
-
- bool remove(std::string filename)
- {
- prepareFsPath(filename);
- if (mWriteDir.empty())
- {
- reportAlways("FsDir::remove write dir is empty");
- return false;
- }
- return ::remove((mWriteDir + filename).c_str()) != 0;
- }
-
- void permitLinks(const bool val)
- {
- mPermitLinks = val;
- }
-
- int close(File *restrict const file)
- {
- if (file == nullptr)
- return 0;
- delete file;
- return 1;
- }
-
- int64_t read(File *restrict const file,
- void *restrict const buffer,
- const uint32_t objSize,
- const uint32_t objCount)
- {
- if (file == nullptr)
- return 0;
- FILEHTYPE fd = file->mFd;
- if (fd == FILEHDEFAULT)
- {
- reportAlways("FsDir::read file not opened.");
- return 0;
- }
-#ifdef USE_FILE_FOPEN
- return fread(buffer, objSize, objCount, fd);
-#else // USE_FILE_FOPEN
- int max = objSize * objCount;
- int cnt = ::read(fd, buffer, max);
- if (cnt <= 0)
- return cnt;
- return cnt / objSize;
-#endif // USE_FILE_FOPEN
- }
-
- int64_t write(File *restrict const file,
- const void *restrict const buffer,
- const uint32_t objSize,
- const uint32_t objCount)
- {
- if (file == nullptr)
- return 0;
- FILEHTYPE fd = file->mFd;
- if (fd == FILEHDEFAULT)
- {
- reportAlways("FsDir::write file not opened.");
- return 0;
- }
-#ifdef USE_FILE_FOPEN
- return fwrite(buffer, objSize, objCount, fd);
-#else // USE_FILE_FOPEN
- int max = objSize * objCount;
- int cnt = ::write(fd, buffer, max);
- if (cnt <= 0)
- return cnt;
- return cnt / objSize;
-#endif // USE_FILE_FOPEN
- }
-
- int64_t fileLength(File *restrict const file)
- {
- if (file == nullptr)
- return -1;
- FILEHTYPE fd = file->mFd;
- if (fd == FILEHDEFAULT)
- {
- reportAlways("FsDir::fileLength file not opened.");
- return 0;
- }
-#ifdef USE_FILE_FOPEN
- const long pos = ftell(fd);
- if (pos < 0)
- {
- reportAlways("FsDir::fileLength ftell error.");
- return -1;
- }
- fseek(fd, 0, SEEK_END);
- const long sz = ftell(fd);
- fseek(fd, pos, SEEK_SET);
- return sz;
-#else // USE_FILE_FOPEN
- struct stat statbuf;
- if (fstat(fd, &statbuf) == -1)
- {
- reportAlways("FsDir::fileLength error.");
- return -1;
- }
- return static_cast<int64_t>(statbuf.st_size);
-#endif // USE_FILE_FOPEN
- }
-
- int64_t tell(File *restrict const file)
- {
- if (file == nullptr)
- return -1;
-
- FILEHTYPE fd = file->mFd;
- if (fd == FILEHDEFAULT)
- {
- reportAlways("FsDir::tell file not opened.");
- return 0;
- }
-#ifdef USE_FILE_FOPEN
- return ftell(fd);
-#else // USE_FILE_FOPEN
- return lseek(fd, 0, SEEK_CUR);
-#endif // USE_FILE_FOPEN
- }
-
- int seek(File *restrict const file,
- const uint64_t pos)
- {
- if (file == nullptr)
- return 0;
-
- FILEHTYPE fd = file->mFd;
- if (fd == FILEHDEFAULT)
- {
- reportAlways("FsDir::seek file not opened.");
- return 0;
- }
- const int64_t res = FILESEEK(fd, pos, SEEK_SET);
- if (res == -1)
- return 0;
- return 1;
- }
-
- int eof(File *restrict const file)
- {
- if (file == nullptr)
- return -1;
-
- FILEHTYPE fd = file->mFd;
- if (fd == FILEHDEFAULT)
- {
- reportAlways("FsDir::eof file not opened.");
- return 0;
- }
-#ifdef USE_FILE_FOPEN
- const int flag = feof(fd);
- if (flag != 0)
- return 1;
- const int64_t pos = ftell(fd);
- const int64_t len = fileLength(file);
-#else // USE_FILE_FOPEN
- const int64_t pos = lseek(fd, 0, SEEK_CUR);
- struct stat statbuf;
- if (fstat(fd, &statbuf) == -1)
- {
- reportAlways("FsDir::fileLength error.");
- return -1;
- }
- const int64_t len = static_cast<int64_t>(statbuf.st_size);
-#endif // USE_FILE_FOPEN
- return static_cast<int>(pos < 0 || len < 0 || pos >= len);
- }
-
- const char *loadFile(FsEntry *restrict const entry,
- std::string filename,
- int &restrict fileSize)
- {
- const DirEntry *const dirEntry = static_cast<DirEntry*>(entry);
- const std::string path = dirEntry->rootSubDir + filename;
- if (Files::existsLocal(path) == false)
- return nullptr;
- FILEHTYPE fd = FILEOPEN(path.c_str(),
- FILEOPEN_FLAG_READ);
- if (fd == FILEHDEFAULT)
- {
- reportAlways("VirtFs::loadFile file open error: %s",
- filename.c_str());
- return nullptr;
- }
-
- logger->log("Loaded %s/%s",
- dirEntry->userDir.c_str(),
- filename.c_str());
-
-#ifdef USE_FILE_FOPEN
- fseek(fd, 0, SEEK_END);
- const long sz = ftell(fd);
- if (sz < 0)
- {
- reportAlways("FsDir::fileLength ftell error.");
- if (fd != FILEHDEFAULT)
- FILECLOSE(fd);
- return nullptr;
- }
- fseek(fd, 0, SEEK_SET);
- fileSize = static_cast<int>(sz);
-#else // USE_FILE_FOPEN
- struct stat statbuf;
- if (fstat(fd, &statbuf) == -1)
- {
- reportAlways("FsDir::fileLength error.");
- if (fd != FILEHDEFAULT)
- FILECLOSE(fd);
- return nullptr;
- }
- fileSize = static_cast<int>(statbuf.st_size);
-#endif // USE_FILE_FOPEN
-
- // Allocate memory and load the file
- char *restrict const buffer = new char[CAST_SIZE(fileSize)];
- if (fileSize > 0)
- buffer[fileSize - 1] = 0;
-
-#ifdef USE_FILE_FOPEN
- const int cnt = CAST_S32(fread(buffer, 1, fileSize, fd));
-#else // USE_FILE_FOPEN
- const int cnt = ::read(fd, buffer, fileSize);
-#endif // USE_FILE_FOPEN
-
- if (cnt <= 0)
- {
- delete [] buffer;
- if (fd != FILEHDEFAULT)
- FILECLOSE(fd);
- return nullptr;
- }
-
- if (fd != FILEHDEFAULT)
- FILECLOSE(fd);
-
- return buffer;
- }
-
- void getFiles(FsEntry *restrict const entry,
- std::string dirName,
- StringVect &names)
- {
- const std::string path = static_cast<DirEntry*>(entry)->rootSubDir +
- dirName;
- const struct dirent *next_file = nullptr;
- DIR *const dir = opendir(path.c_str());
- if (dir != nullptr)
- {
- while ((next_file = readdir(dir)) != nullptr)
- {
- struct stat statbuf;
- const std::string file = next_file->d_name;
- if (file == "." || file == "..")
- continue;
-#ifndef WIN32
- if (mPermitLinks == false)
- {
- if (lstat(path.c_str(), &statbuf) == 0 &&
- S_ISLNK(statbuf.st_mode) != 0)
- {
- continue;
- }
- }
-#endif // WIN32
-
- const std::string filePath = pathJoin(path, file);
- if (stat(filePath.c_str(), &statbuf) == 0)
- {
- if (S_ISDIR(statbuf.st_mode) != 0)
- continue;
- }
-
- bool found(false);
- FOR_EACH (StringVectCIter, itn, names)
- {
- if (*itn == file)
- {
- found = true;
- break;
- }
- }
- if (found == false)
- names.push_back(file);
- }
- closedir(dir);
- }
- }
-
- void getFilesWithDir(FsEntry *restrict const entry,
- const std::string &dirName,
- StringVect &names)
- {
- const std::string path = static_cast<DirEntry*>(entry)->rootSubDir +
- dirName;
- const struct dirent *next_file = nullptr;
- DIR *const dir = opendir(path.c_str());
- if (dir != nullptr)
- {
- while ((next_file = readdir(dir)) != nullptr)
- {
- struct stat statbuf;
- const std::string file = next_file->d_name;
- if (file == "." || file == "..")
- continue;
-#ifndef WIN32
- if (mPermitLinks == false)
- {
- if (lstat(path.c_str(), &statbuf) == 0 &&
- S_ISLNK(statbuf.st_mode) != 0)
- {
- continue;
- }
- }
-#endif // WIN32
-
- const std::string filePath = pathJoin(path, file);
- if (stat(filePath.c_str(), &statbuf) == 0)
- {
- if (S_ISDIR(statbuf.st_mode) != 0)
- continue;
- }
-
- bool found(false);
- FOR_EACH (StringVectCIter, itn, names)
- {
- if (*itn == file)
- {
- found = true;
- break;
- }
- }
- if (found == false)
- names.push_back(pathJoin(dirName, file));
- }
- closedir(dir);
- }
- }
-
- void getDirs(FsEntry *restrict const entry,
- std::string dirName,
- StringVect &names)
- {
- const std::string path = static_cast<DirEntry*>(entry)->rootSubDir +
- dirName;
- const struct dirent *next_file = nullptr;
- DIR *const dir = opendir(path.c_str());
- if (dir != nullptr)
- {
- while ((next_file = readdir(dir)) != nullptr)
- {
- struct stat statbuf;
- const std::string file = next_file->d_name;
- if (file == "." || file == "..")
- continue;
-#ifndef WIN32
- if (mPermitLinks == false)
- {
- if (lstat(path.c_str(), &statbuf) == 0 &&
- S_ISLNK(statbuf.st_mode) != 0)
- {
- continue;
- }
- }
-#endif // WIN32
-
- const std::string filePath = pathJoin(path, file);
- if (stat(filePath.c_str(), &statbuf) == 0)
- {
- if (S_ISDIR(statbuf.st_mode) == 0)
- continue;
- }
-
- bool found(false);
- FOR_EACH (StringVectCIter, itn, names)
- {
- if (*itn == file)
- {
- found = true;
- break;
- }
- }
- if (found == false)
- names.push_back(file);
- }
- closedir(dir);
- }
- }
-} // namespace FsDir
-
-} // namespace VirtFs
diff --git a/src/fs/virtfs/fsdir.h b/src/fs/virtfs/fsdir.h
deleted file mode 100644
index 0c19fee2f..000000000
--- a/src/fs/virtfs/fsdir.h
+++ /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/>.
- */
-
-#ifndef UTILS_VIRTFSDIR_H
-#define UTILS_VIRTFSDIR_H
-
-#include "fs/virtfs/fileapi.h"
-
-#include "utils/stringvector.h"
-
-#include "localconsts.h"
-
-namespace VirtFs
-{
-
-struct File;
-struct FsEntry;
-struct FsFuncs;
-struct List;
-
-namespace FsDir
-{
- File *openInternal(FsEntry *restrict const entry,
- const std::string &filename,
- const FILEMTYPE mode);
- File *openRead(FsEntry *restrict const entry,
- std::string filename);
- File *openWrite(FsEntry *restrict const entry,
- const std::string &filename);
- File *openAppend(FsEntry *restrict const entry,
- const std::string &filename);
- const char *getBaseDir();
- const char *getUserDir();
- FsFuncs *getFuncs();
- void init(const std::string &restrict name);
- void initFuncs(FsFuncs *restrict const ptr);
- void deinit();
- bool exists(FsEntry *restrict const entry,
- std::string fileName,
- std::string dirName);
- void enumerate(FsEntry *restrict const entry,
- std::string dirName,
- StringVect &names);
- void getFiles(FsEntry *restrict const entry,
- std::string dirName,
- StringVect &names);
- void getFilesWithDir(FsEntry *restrict const entry,
- const std::string &dirName,
- StringVect &names);
- void getDirs(FsEntry *restrict const entry,
- std::string dirName,
- StringVect &names);
- bool isDirectory(FsEntry *restrict const entry,
- std::string dirName,
- bool &isDirFlag);
- bool isSymbolicLink(std::string name);
- void freeList(List *restrict const handle);
- bool setWriteDir(std::string newDir);
- bool getRealDir(FsEntry *restrict const entry,
- std::string filename,
- std::string dirName,
- std::string &realDir);
- bool mkdir(std::string dirName);
- bool remove(std::string filename);
- void permitLinks(const bool val);
- int64_t read(File *restrict const handle,
- void *restrict const buffer,
- const uint32_t objSize,
- const uint32_t objCount);
- int64_t write(File *restrict const file,
- const void *restrict const buffer,
- const uint32_t objSize,
- const uint32_t objCount);
- int close(File *restrict const file);
- int64_t fileLength(File *restrict const file);
- int64_t tell(File *restrict const file);
- int seek(File *restrict const file,
- const uint64_t pos);
- int eof(File *restrict const file);
- const char *loadFile(FsEntry *restrict const entry,
- std::string fileName,
- int &restrict fileSize);
-} // namespace FsDir
-
-} // namespace VirtFs
-
-#endif // UTILS_VIRTFSDIR_H
diff --git a/src/fs/virtfs/fsdirrwops.cpp b/src/fs/virtfs/fsdirrwops.cpp
deleted file mode 100644
index 47497a9d3..000000000
--- a/src/fs/virtfs/fsdirrwops.cpp
+++ /dev/null
@@ -1,269 +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 "fs/virtfs/fsdirrwops.h"
-
-#include "fs/virtfs/file.h"
-
-#include "utils/cast.h"
-#include "utils/checkutils.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_rwops.h>
-PRAGMA48(GCC diagnostic pop)
-
-#include "debug.h"
-
-namespace VirtFs
-{
-
-namespace FsDir
-{
- RWOPSINT rwops_seek(SDL_RWops *const rw,
- const RWOPSINT offset,
- const int whence)
- {
- if (rw == nullptr)
- return -1;
- File *const handle = static_cast<File *>(
- rw->hidden.unknown.data1);
- FILEHTYPE fd = handle->mFd;
- RWOPSINT pos = 0;
-
- if (whence == SEEK_SET)
- {
- pos = offset;
- }
- else if (whence == SEEK_CUR)
- {
-#ifdef USE_FILE_FOPEN
- const int64_t current = ftell(fd);
-#else // USE_FILE_FOPEN
- const int64_t current = lseek(fd, 0, SEEK_CUR);
-#endif // USE_FILE_FOPEN
-
- if (current == -1)
- {
- logger->assertLog(
- "VirtFs::rwops_seek: Can't find position in file.");
- return -1;
- }
-
- pos = CAST_S32(current);
- if (static_cast<int64_t>(pos) != current)
- {
- logger->assertLog("VirtFs::rwops_seek: "
- "Can't fit current file position in an int!");
- return -1;
- }
-
- if (offset == 0) /* this is a "tell" call. We're done. */
- return pos;
-
- pos += offset;
- }
- else if (whence == SEEK_END)
- {
- int64_t len = 0;
-#ifdef USE_FILE_FOPEN
- const long curpos = ftell(fd);
- if (curpos < 0)
- {
- reportAlways("FsDir::fileLength ftell error.");
- return -1;
- }
- fseek(fd, 0, SEEK_END);
- len = ftell(fd);
-// fseek(fd, curpos, SEEK_SET);
-#else // USE_FILE_FOPEN
- struct stat statbuf;
- if (fstat(fd, &statbuf) == -1)
- {
- reportAlways("FsDir::fileLength error.");
- len = -1;
- }
- else
- {
- len = static_cast<int64_t>(statbuf.st_size);
- }
-#endif // USE_FILE_FOPEN
-
- if (len == -1)
- {
-#ifdef USE_FILE_FOPEN
- if (fseek(fd, curpos, SEEK_SET) < 0)
- {
- reportAlways("FsDir::fileLength fseek error.");
- }
-#endif // USE_FILE_FOPEN
- logger->assertLog(
- "VirtFs::rwops_seek:Can't find end of file.");
- return -1;
- }
-
- pos = static_cast<RWOPSINT>(len);
- if (static_cast<int64_t>(pos) != len)
- {
-#ifdef USE_FILE_FOPEN
- fseek(fd, curpos, SEEK_SET);
-#endif // USE_FILE_FOPEN
- logger->assertLog("VirtFs::rwops_seek: "
- "Can't fit end-of-file position in an int!");
- return -1;
- }
-
- pos += offset;
- }
- else
- {
- logger->assertLog(
- "VirtFs::rwops_seek: Invalid 'whence' parameter.");
- return -1;
- }
-
- if (pos < 0)
- {
- logger->assertLog("VirtFs::rwops_seek: "
- "Attempt to seek past start of file.");
- return -1;
- }
-
- const int64_t res = FILESEEK(fd, pos, SEEK_SET);
- if (res == -1)
- {
- logger->assertLog("VirtFs::rwops_seek: seek error.");
- return -1;
- }
-
- return pos;
- }
-
- RWOPSSIZE rwops_read(SDL_RWops *const rw,
- void *const ptr,
- const RWOPSSIZE size,
- const RWOPSSIZE maxnum)
- {
- if (rw == nullptr)
- return 0;
- File *const handle = static_cast<File *>(
- rw->hidden.unknown.data1);
- FILEHTYPE fd = handle->mFd;
-
-#ifdef USE_FILE_FOPEN
- const int64_t rc = fread(ptr, size, maxnum, fd);
-#else // USE_FILE_FOPEN
- int max = size * maxnum;
- int cnt = ::read(fd, ptr, max);
- if (cnt <= 0)
- return cnt;
- const int64_t rc = cnt / size;
-#endif // USE_FILE_FOPEN
-
-#ifndef USE_FILE_FOPEN
- if (rc != static_cast<int64_t>(maxnum))
- {
- const int64_t pos = lseek(fd, 0, SEEK_CUR);
- struct stat statbuf;
- if (fstat(fd, &statbuf) == -1)
- {
- reportAlways("FsDir::fileLength error.");
- return CAST_S32(rc);
- }
- }
-#endif // USE_FILE_FOPEN
- return CAST_S32(rc);
- }
-
- RWOPSSIZE rwops_write(SDL_RWops *const rw,
- const void *const ptr,
- const RWOPSSIZE size,
- const RWOPSSIZE maxnum)
- {
- if (rw == nullptr)
- return 0;
- File *const handle = static_cast<File *>(
- rw->hidden.unknown.data1);
- FILEHTYPE fd = handle->mFd;
-
-#ifdef USE_FILE_FOPEN
- const int64_t rc = fwrite(ptr, size, maxnum, fd);
-#else // USE_FILE_FOPEN
- int max = size * maxnum;
- int cnt = ::write(fd, ptr, max);
- if (cnt <= 0)
- return cnt;
- const int64_t rc = cnt / size;
-#endif // USE_FILE_FOPEN
-
-#ifndef USE_FILE_FOPEN
- if (rc != static_cast<int64_t>(maxnum))
- {
- const int64_t pos = lseek(fd, 0, SEEK_CUR);
- struct stat statbuf;
- if (fstat(fd, &statbuf) == -1)
- {
- reportAlways("FsDir::fileLength error.");
- return CAST_S32(rc);
- }
- }
-#endif // USE_FILE_FOPEN
-
- return CAST_S32(rc);
- }
-
- int rwops_close(SDL_RWops *const rw)
- {
- if (rw == nullptr)
- return 0;
- File *const handle = static_cast<File*>(
- rw->hidden.unknown.data1);
- delete handle;
- SDL_FreeRW(rw);
- return 0;
- }
-
-#ifdef USE_SDL2
- RWOPSINT rwops_size(SDL_RWops *const rw)
- {
- File *const handle = static_cast<File *>(
- rw->hidden.unknown.data1);
- FILEHTYPE fd = handle->mFd;
-#ifdef USE_FILE_FOPEN
- const long pos = ftell(fd);
- fseek(fd, 0, SEEK_END);
- const long sz = ftell(fd);
- fseek(fd, pos, SEEK_SET);
- return sz;
-#else // USE_FILE_FOPEN
- struct stat statbuf;
- if (fstat(fd, &statbuf) == -1)
- {
- reportAlways("FsDir::fileLength error.");
- return -1;
- }
- return static_cast<int64_t>(statbuf.st_size);
-#endif // USE_FILE_FOPEN
- }
-#endif // USE_SDL2
-
-} // namespace FsDir
-
-} // namespace VirtFs
diff --git a/src/fs/virtfs/fsdirrwops.h b/src/fs/virtfs/fsdirrwops.h
deleted file mode 100644
index 1f20d97df..000000000
--- a/src/fs/virtfs/fsdirrwops.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 UTILS_VIRTFS_VIRTFSDIRRWOPS_H
-#define UTILS_VIRTFS_VIRTFSDIRRWOPS_H
-
-#include "fs/virtfs/rwopstypes.h"
-
-struct SDL_RWops;
-
-#include "localconsts.h"
-
-namespace VirtFs
-{
-
-namespace FsDir
-{
- RWOPSINT rwops_seek(SDL_RWops *const rw,
- const RWOPSINT offset,
- const int whence);
- RWOPSSIZE rwops_read(SDL_RWops *const rw,
- void *const ptr,
- const RWOPSSIZE size,
- const RWOPSSIZE maxnum);
- RWOPSSIZE rwops_write(SDL_RWops *const rw,
- const void *const ptr,
- const RWOPSSIZE size,
- const RWOPSSIZE maxnum);
- int rwops_close(SDL_RWops *const rw);
-#ifdef USE_SDL2
- RWOPSINT rwops_size(SDL_RWops *const rw);
-#endif // USE_SDL2
-
-} // namespace FsDir
-
-} // namespace VirtFs
-
-#endif // UTILS_VIRTFS_VIRTFSDIRRWOPS_H
diff --git a/src/fs/virtfs/fsentry.cpp b/src/fs/virtfs/fsentry.cpp
deleted file mode 100644
index 7078fdbc4..000000000
--- a/src/fs/virtfs/fsentry.cpp
+++ /dev/null
@@ -1,41 +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 "fs/virtfs/fsentry.h"
-
-#include "debug.h"
-
-namespace VirtFs
-{
-
-FsEntry::FsEntry(const FsEntryTypeT &type0,
- FsFuncs *restrict const funcs0) :
- root(),
- subDir(),
- type(type0),
- funcs(funcs0)
-{
-}
-
-FsEntry::~FsEntry()
-{
-}
-
-} // namespace VirtFs
diff --git a/src/fs/virtfs/fsentry.h b/src/fs/virtfs/fsentry.h
deleted file mode 100644
index 09ca136b0..000000000
--- a/src/fs/virtfs/fsentry.h
+++ /dev/null
@@ -1,55 +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 UTILS_VIRTFSENTRY_H
-#define UTILS_VIRTFSENTRY_H
-
-#include "enums/fs/fsentrytype.h"
-
-#include <string>
-
-#include "localconsts.h"
-
-namespace VirtFs
-{
-
-struct FsFuncs;
-
-struct FsEntry notfinal
-{
- FsEntry(const FsEntryTypeT &type0,
- FsFuncs *restrict const funcs);
-
- A_DELETE_COPY(FsEntry)
-
- virtual ~FsEntry();
-
- std::string root;
-
- std::string subDir;
-
- FsEntryTypeT type;
-
- FsFuncs *funcs;
-};
-
-} // namespace VirtFs
-
-#endif // UTILS_VIRTFSENTRY_H
diff --git a/src/fs/virtfs/fsfuncs.h b/src/fs/virtfs/fsfuncs.h
deleted file mode 100644
index 49d10e12f..000000000
--- a/src/fs/virtfs/fsfuncs.h
+++ /dev/null
@@ -1,136 +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 UTILS_VIRTFSFUNCS_H
-#define UTILS_VIRTFSFUNCS_H
-
-#include "fs/virtfs/rwopstypes.h"
-
-#include "utils/stringvector.h"
-
-#include "localconsts.h"
-
-struct SDL_RWops;
-
-namespace VirtFs
-{
-
-struct File;
-struct FsEntry;
-
-struct FsFuncs final
-{
- FsFuncs() :
- close(nullptr),
- read(nullptr),
- write(nullptr),
- fileLength(nullptr),
- tell(nullptr),
- seek(nullptr),
- exists(nullptr),
- getRealDir(nullptr),
- enumerate(nullptr),
- getFiles(nullptr),
- getFilesWithDir(nullptr),
- getDirs(nullptr),
- isDirectory(nullptr),
- openRead(nullptr),
- openWrite(nullptr),
- openAppend(nullptr),
- eof(nullptr),
- loadFile(nullptr),
- rwops_seek(nullptr),
- rwops_read(nullptr),
- rwops_write(nullptr),
-#ifdef USE_SDL2
- rwops_size(nullptr),
-#endif // USE_SDL2
- rwops_close(nullptr)
- {
- }
-
- A_DELETE_COPY(FsFuncs)
-
- int (*close) (File *restrict const file);
- int64_t (*read) (File *restrict const file,
- void *restrict const buffer,
- const uint32_t objSize,
- const uint32_t objCount);
- int64_t (*write) (File *restrict const file,
- const void *restrict const buffer,
- const uint32_t objSize,
- const uint32_t objCount);
- int64_t (*fileLength) (File *restrict const file);
- int64_t (*tell) (File *restrict const file);
- int (*seek) (File *restrict const file,
- const uint64_t pos);
- bool (*exists) (FsEntry *restrict const entry,
- std::string filename,
- std::string dirName);
- bool (*getRealDir) (FsEntry *restrict const entry,
- std::string filename,
- std::string dirName,
- std::string &realDir);
- void (*enumerate) (FsEntry *restrict const entry,
- std::string dirName,
- StringVect &names);
- void (*getFiles) (FsEntry *restrict const entry,
- std::string dirName,
- StringVect &names);
- void (*getFilesWithDir) (FsEntry *restrict const entry,
- const std::string &dirName,
- StringVect &names);
- void (*getDirs) (FsEntry *restrict const entry,
- std::string dirName,
- StringVect &names);
- bool (*isDirectory) (FsEntry *restrict const entry,
- std::string dirName,
- bool &isDirFlag);
- File *(*openRead) (FsEntry *restrict const entry,
- std::string filename);
- File *(*openWrite) (FsEntry *restrict const entry,
- const std::string &filename);
- File *(*openAppend) (FsEntry *restrict const entry,
- const std::string &filename);
- int (*eof) (File *restrict const file);
- const char *(*loadFile) (FsEntry *restrict const entry,
- std::string fileName,
- int &restrict fileSize);
-
- RWOPSINT (*rwops_seek) (SDL_RWops *const rw,
- const RWOPSINT offset,
- const int whence);
- RWOPSSIZE (*rwops_read) (SDL_RWops *const rw,
- void *const ptr,
- const RWOPSSIZE size,
- const RWOPSSIZE maxnum);
- RWOPSSIZE (*rwops_write) (SDL_RWops *const rw,
- const void *const ptr,
- const RWOPSSIZE size,
- const RWOPSSIZE num);
-#ifdef USE_SDL2
- RWOPSINT (*rwops_size) (SDL_RWops *const rw);
-#endif // USE_SDL2
- int (*rwops_close) (SDL_RWops *const rw);
-};
-
-} // namespace VirtFs
-
-#endif // UTILS_VIRTFSFUNCS_H
diff --git a/src/fs/virtfs/fszip.cpp b/src/fs/virtfs/fszip.cpp
deleted file mode 100644
index fcb726173..000000000
--- a/src/fs/virtfs/fszip.cpp
+++ /dev/null
@@ -1,705 +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 "fs/virtfs/fszip.h"
-
-#include "fs/virtfs/file.h"
-#include "fs/virtfs/fsfuncs.h"
-#include "fs/virtfs/fsziprwops.h"
-#include "fs/virtfs/list.h"
-#include "fs/virtfs/zipentry.h"
-#include "fs/virtfs/zipreader.h"
-#include "fs/virtfs/ziplocalheader.h"
-
-#include "utils/cast.h"
-#include "utils/checkutils.h"
-#include "utils/foreach.h"
-#include "utils/stringutils.h"
-
-#include "debug.h"
-
-extern const char *dirSeparator;
-
-namespace
-{
- VirtFs::FsFuncs funcs;
-} // namespace
-
-namespace VirtFs
-{
-
-namespace FsZip
-{
- FsFuncs *getFuncs()
- {
- return &funcs;
- }
-
- void deinit()
- {
- }
-
- void init()
- {
- initFuncs(&funcs);
- }
-
- void initFuncs(FsFuncs *restrict const ptr)
- {
- ptr->close = &FsZip::close;
- ptr->read = &FsZip::read;
- ptr->write = &FsZip::write;
- ptr->fileLength = &FsZip::fileLength;
- ptr->tell = &FsZip::tell;
- ptr->seek = &FsZip::seek;
- ptr->eof = &FsZip::eof;
- ptr->exists = &FsZip::exists;
- ptr->getRealDir = &FsZip::getRealDir;
- ptr->enumerate = &FsZip::enumerate;
- ptr->isDirectory = &FsZip::isDirectory;
- ptr->openRead = &FsZip::openRead;
- ptr->openWrite = &FsZip::openWrite;
- ptr->openAppend = &FsZip::openAppend;
- ptr->loadFile = &FsZip::loadFile;
- ptr->getFiles = &FsZip::getFiles;
- ptr->getFilesWithDir = &FsZip::getFilesWithDir;
- ptr->getDirs = &FsZip::getDirs;
- ptr->rwops_seek = &FsZip::rwops_seek;
- ptr->rwops_read = &FsZip::rwops_read;
- ptr->rwops_write = &FsZip::rwops_write;
- ptr->rwops_close = &FsZip::rwops_close;
-#ifdef USE_SDL2
- ptr->rwops_size = &FsZip::rwops_size;
-#endif // USE_SDL2
- }
-
- bool getRealDir(FsEntry *restrict const entry,
- std::string filename,
- std::string dirName,
- std::string &realDir)
- {
- ZipEntry *const zipEntry = static_cast<ZipEntry*>(entry);
- std::string subDir = zipEntry->subDir;
- if (!subDir.empty())
- {
- filename = pathJoin(subDir, filename);
- dirName = pathJoin(subDir, dirName);
- }
- FOR_EACH (STD_VECTOR<ZipLocalHeader*>::const_iterator,
- it2,
- zipEntry->mHeaders)
- {
- if ((*it2)->fileName == filename)
- {
- realDir = entry->root;
- return true;
- }
- }
- FOR_EACH (STD_VECTOR<std::string>::const_iterator,
- it2,
- zipEntry->mDirs)
- {
- if (*it2 == dirName)
- {
- realDir = entry->root;
- return true;
- }
- }
- return false;
- }
-
- bool exists(FsEntry *restrict const entry,
- std::string filename,
- std::string dirName)
- {
- ZipEntry *const zipEntry = static_cast<ZipEntry*>(entry);
- std::string subDir = zipEntry->subDir;
- if (!subDir.empty())
- {
- filename = pathJoin(subDir, filename);
- dirName = pathJoin(subDir, dirName);
- }
- FOR_EACH (STD_VECTOR<ZipLocalHeader*>::const_iterator,
- it2,
- zipEntry->mHeaders)
- {
- if ((*it2)->fileName == filename)
- return true;
- }
- FOR_EACH (STD_VECTOR<std::string>::const_iterator,
- it2,
- zipEntry->mDirs)
- {
- if (*it2 == dirName)
- return true;
- }
- return false;
- }
-
- void enumerate(FsEntry *restrict const entry,
- std::string dirName,
- StringVect &names)
- {
- ZipEntry *const zipEntry = static_cast<ZipEntry*>(entry);
- const std::string subDir = zipEntry->subDir;
- if (!subDir.empty())
- dirName = pathJoin(subDir, dirName);
- if (dirName == dirSeparator)
- {
- FOR_EACH (STD_VECTOR<ZipLocalHeader*>::const_iterator,
- it2,
- zipEntry->mHeaders)
- {
- ZipLocalHeader *const header = *it2;
- std::string fileName = header->fileName;
- // skip subdirs from enumeration
- const size_t idx = fileName.find(dirSeparator);
- if (idx != std::string::npos)
- fileName.erase(idx);
- bool found(false);
- FOR_EACH (StringVectCIter, itn, names)
- {
- if (*itn == fileName)
- {
- found = true;
- break;
- }
- }
- if (found == false)
- names.push_back(fileName);
- }
- }
- else
- {
- FOR_EACH (STD_VECTOR<ZipLocalHeader*>::const_iterator,
- it2,
- zipEntry->mHeaders)
- {
- ZipLocalHeader *const header = *it2;
- std::string fileName = header->fileName;
- if (findCutFirst(fileName, dirName) == true)
- {
- // skip subdirs from enumeration
- const size_t idx = fileName.find(dirSeparator);
- if (idx != std::string::npos)
- fileName.erase(idx);
- bool found(false);
- FOR_EACH (StringVectCIter, itn, names)
- {
- if (*itn == fileName)
- {
- found = true;
- break;
- }
- }
- if (found == false)
- names.push_back(fileName);
- }
- }
- }
- }
-
- void getFiles(FsEntry *restrict const entry,
- std::string dirName,
- StringVect &names)
- {
- ZipEntry *const zipEntry = static_cast<ZipEntry*>(entry);
- const std::string subDir = zipEntry->subDir;
- if (!subDir.empty())
- dirName = pathJoin(subDir, dirName);
- if (dirName == dirSeparator)
- {
- FOR_EACH (STD_VECTOR<ZipLocalHeader*>::const_iterator,
- it2,
- zipEntry->mHeaders)
- {
- ZipLocalHeader *const header = *it2;
- std::string fileName = header->fileName;
- // skip subdirs from enumeration
- const size_t idx = fileName.find(dirSeparator);
- if (idx != std::string::npos)
- fileName.erase(idx);
- bool found(false);
- FOR_EACH (StringVectCIter, itn, names)
- {
- if (*itn == fileName)
- {
- found = true;
- break;
- }
- }
- if (found == false)
- {
- std::string dirName2 = pathJoin(dirName, fileName);
- if (findLast(dirName2, std::string(dirSeparator)) == false)
- dirName2 += dirSeparator;
- FOR_EACH (STD_VECTOR<std::string>::const_iterator,
- it,
- zipEntry->mDirs)
- {
- if (*it == dirName2)
- {
- found = true;
- break;
- }
- }
- if (found == false)
- names.push_back(fileName);
- }
- }
- }
- else
- {
- FOR_EACH (STD_VECTOR<ZipLocalHeader*>::const_iterator,
- it2,
- zipEntry->mHeaders)
- {
- ZipLocalHeader *const header = *it2;
- std::string fileName = header->fileName;
- if (findCutFirst(fileName, dirName) == true)
- {
- // skip subdirs from enumeration
- const size_t idx = fileName.find(dirSeparator);
- if (idx != std::string::npos)
- fileName.erase(idx);
- bool found(false);
- FOR_EACH (StringVectCIter, itn, names)
- {
- if (*itn == fileName)
- {
- found = true;
- break;
- }
- }
- if (found == false)
- {
- std::string dirName2 = pathJoin(dirName, fileName);
- if (findLast(dirName2, std::string(dirSeparator)) ==
- false)
- {
- dirName2 += dirSeparator;
- }
- FOR_EACH (STD_VECTOR<std::string>::const_iterator,
- it,
- zipEntry->mDirs)
- {
- if (*it == dirName2)
- {
- found = true;
- break;
- }
- }
- if (found == false)
- names.push_back(fileName);
- }
- }
- }
- }
- }
-
- void getFilesWithDir(FsEntry *restrict const entry,
- const std::string &dirName,
- StringVect &names)
- {
- ZipEntry *const zipEntry = static_cast<ZipEntry*>(entry);
- const std::string subDir = zipEntry->subDir;
- std::string dirNameFull;
- if (!subDir.empty())
- dirNameFull = pathJoin(subDir, dirName);
- else
- dirNameFull = dirName;
- if (dirNameFull == dirSeparator)
- {
- FOR_EACH (STD_VECTOR<ZipLocalHeader*>::const_iterator,
- it2,
- zipEntry->mHeaders)
- {
- ZipLocalHeader *const header = *it2;
- std::string fileName = header->fileName;
- // skip subdirs from enumeration
- const size_t idx = fileName.find(dirSeparator);
- if (idx != std::string::npos)
- fileName.erase(idx);
- bool found(false);
- FOR_EACH (StringVectCIter, itn, names)
- {
- if (*itn == fileName)
- {
- found = true;
- break;
- }
- }
- if (found == false)
- {
- std::string dirName2 = pathJoin(dirNameFull, fileName);
- if (findLast(dirName2, std::string(dirSeparator)) == false)
- dirName2 += dirSeparator;
- FOR_EACH (STD_VECTOR<std::string>::const_iterator,
- it,
- zipEntry->mDirs)
- {
- if (*it == dirName2)
- {
- found = true;
- break;
- }
- }
- if (found == false)
- names.push_back(pathJoin(dirName, fileName));
- }
- }
- }
- else
- {
- FOR_EACH (STD_VECTOR<ZipLocalHeader*>::const_iterator,
- it2,
- zipEntry->mHeaders)
- {
- ZipLocalHeader *const header = *it2;
- std::string fileName = header->fileName;
- if (findCutFirst(fileName, dirNameFull) == true)
- {
- // skip subdirs from enumeration
- const size_t idx = fileName.find(dirSeparator);
- if (idx != std::string::npos)
- fileName.erase(idx);
- bool found(false);
- FOR_EACH (StringVectCIter, itn, names)
- {
- if (*itn == fileName)
- {
- found = true;
- break;
- }
- }
- if (found == false)
- {
- std::string dirName2 = pathJoin(dirNameFull, fileName);
- if (findLast(dirName2, std::string(dirSeparator)) ==
- false)
- {
- dirName2 += dirSeparator;
- }
- FOR_EACH (STD_VECTOR<std::string>::const_iterator,
- it,
- zipEntry->mDirs)
- {
- if (*it == dirName2)
- {
- found = true;
- break;
- }
- }
- if (found == false)
- names.push_back(pathJoin(dirName, fileName));
- }
- }
- }
- }
- }
-
- void getDirs(FsEntry *restrict const entry,
- std::string dirName,
- StringVect &names)
- {
- ZipEntry *const zipEntry = static_cast<ZipEntry*>(entry);
- const std::string subDir = zipEntry->subDir;
- if (!subDir.empty())
- dirName = pathJoin(subDir, dirName);
- if (dirName == dirSeparator)
- {
- FOR_EACH (STD_VECTOR<ZipLocalHeader*>::const_iterator,
- it2,
- zipEntry->mHeaders)
- {
- ZipLocalHeader *const header = *it2;
- std::string fileName = header->fileName;
- // skip subdirs from enumeration
- const size_t idx = fileName.find(dirSeparator);
- if (idx != std::string::npos)
- fileName.erase(idx);
- bool found(false);
- FOR_EACH (StringVectCIter, itn, names)
- {
- if (*itn == fileName)
- {
- found = true;
- break;
- }
- }
- if (found == false)
- {
- std::string dirName2 = pathJoin(dirName, fileName);
- if (findLast(dirName2, std::string(dirSeparator)) == false)
- dirName2 += dirSeparator;
- FOR_EACH (STD_VECTOR<std::string>::const_iterator,
- it,
- zipEntry->mDirs)
- {
- if (*it == dirName2)
- {
- found = true;
- break;
- }
- }
- if (found == true)
- names.push_back(fileName);
- }
- }
- }
- else
- {
- FOR_EACH (STD_VECTOR<ZipLocalHeader*>::const_iterator,
- it2,
- zipEntry->mHeaders)
- {
- ZipLocalHeader *const header = *it2;
- std::string fileName = header->fileName;
- if (findCutFirst(fileName, dirName) == true)
- {
- // skip subdirs from enumeration
- const size_t idx = fileName.find(dirSeparator);
- if (idx != std::string::npos)
- fileName.erase(idx);
- bool found(false);
- FOR_EACH (StringVectCIter, itn, names)
- {
- if (*itn == fileName)
- {
- found = true;
- break;
- }
- }
- if (found == false)
- {
- std::string dirName2 = pathJoin(dirName, fileName);
- if (findLast(dirName2, std::string(dirSeparator)) ==
- false)
- {
- dirName2 += dirSeparator;
- }
- FOR_EACH (STD_VECTOR<std::string>::const_iterator,
- it,
- zipEntry->mDirs)
- {
- if (*it == dirName2)
- {
- found = true;
- break;
- }
- }
- if (found == true)
- names.push_back(fileName);
- }
- }
- }
- }
- }
-
- bool isDirectory(FsEntry *restrict const entry,
- std::string dirName,
- bool &isDirFlag)
- {
- ZipEntry *const zipEntry = static_cast<ZipEntry*>(entry);
- std::string subDir = zipEntry->subDir;
- if (!subDir.empty())
- dirName = pathJoin(subDir, dirName);
- FOR_EACH (STD_VECTOR<std::string>::const_iterator,
- it2,
- zipEntry->mDirs)
- {
- if (*it2 == dirName)
- {
- isDirFlag = true;
- return true;
- }
- }
- return false;
- }
-
- void freeList(List *restrict const handle)
- {
- delete handle;
- }
-
- File *openRead(FsEntry *restrict const entry,
- std::string filename)
- {
- ZipEntry *const zipEntry = static_cast<ZipEntry*>(entry);
- std::string subDir = zipEntry->subDir;
- if (!subDir.empty())
- filename = pathJoin(subDir, filename);
- FOR_EACH (STD_VECTOR<ZipLocalHeader*>::const_iterator,
- it2,
- zipEntry->mHeaders)
- {
- const ZipLocalHeader *restrict const header = *it2;
- if (header->fileName == filename)
- {
- const uint8_t *restrict const buf =
- ZipReader::readFile(header);
- if (buf == nullptr)
- return nullptr;
- return new File(&funcs,
- buf,
- header->uncompressSize);
- }
- }
- return nullptr;
- }
-
- File *openWrite(FsEntry *restrict const entry A_UNUSED,
- const std::string &filename A_UNUSED)
- {
- reportAlways("VirtFs::openWrite for zip not implemented.");
- return nullptr;
- }
-
- File *openAppend(FsEntry *restrict const entry A_UNUSED,
- const std::string &filename A_UNUSED)
- {
- reportAlways("VirtFs::openAppend for zip not implemented.");
- return nullptr;
- }
-
- int close(File *restrict const file)
- {
- if (file == nullptr)
- return 0;
- delete file;
- return 1;
- }
-
- int64_t read(File *restrict const file,
- void *restrict const buffer,
- const uint32_t objSize,
- const uint32_t objCount)
- {
- if (file == nullptr ||
- objSize == 0 ||
- objCount == 0)
- {
- return 0;
- }
- if (buffer == nullptr)
- {
- reportAlways("FsZip::read buffer is null");
- return 0;
- }
- const size_t pos = file->mPos;
- const size_t sz = file->mSize;
- // if outside of buffer, return
- if (pos >= sz)
- return 0;
- // pointer to start for buffer ready to read
- const uint8_t *restrict const memPtr = file->mBuf + pos;
- // left buffer size from pos to end
- const uint32_t memSize = CAST_U32(sz - pos);
- // number of objects possible to read
- uint32_t memCount = memSize / objSize;
- if (memCount == 0)
- return 0;
- // limit number of possible objects to read to objCount
- if (memCount > objCount)
- memCount = objCount;
- // number of bytes to read from buffer
- const size_t memEnd = memCount * objSize;
- memcpy(buffer, memPtr, memEnd);
- file->mPos += memEnd;
- return memCount;
- }
-
- int64_t write(File *restrict const file A_UNUSED,
- const void *restrict const buffer A_UNUSED,
- const uint32_t objSize A_UNUSED,
- const uint32_t objCount A_UNUSED)
- {
- return 0;
- }
-
- int64_t fileLength(File *restrict const file)
- {
- if (file == nullptr)
- return -1;
-
- return file->mSize;
- }
-
- int64_t tell(File *restrict const file)
- {
- if (file == nullptr)
- return -1;
-
- return file->mPos;
- }
-
- int seek(File *restrict const file,
- const uint64_t pos)
- {
- if (file == nullptr)
- return 0;
-
- if (pos > file->mSize)
- return 0;
- file->mPos = pos;
- return 1;
- }
-
- int eof(File *restrict const file)
- {
- if (file == nullptr)
- return -1;
-
- return static_cast<int>(file->mPos >= file->mSize);
- }
-
- const char *loadFile(FsEntry *restrict const entry,
- std::string filename,
- int &restrict fileSize)
- {
- ZipEntry *const zipEntry = static_cast<ZipEntry*>(entry);
- const std::string subDir = zipEntry->subDir;
- if (!subDir.empty())
- filename = pathJoin(subDir, filename);
- FOR_EACH (STD_VECTOR<ZipLocalHeader*>::const_iterator,
- it2,
- zipEntry->mHeaders)
- {
- const ZipLocalHeader *restrict const header = *it2;
- if (header->fileName == filename)
- {
- const uint8_t *restrict const buf =
- ZipReader::readFile(header);
- if (buf == nullptr)
- return nullptr;
-
- logger->log("Loaded %s/%s",
- entry->root.c_str(),
- filename.c_str());
-
- fileSize = header->uncompressSize;
- return reinterpret_cast<const char*>(buf);
- }
- }
- return nullptr;
- }
-} // namespace FsZip
-
-} // namespace VirtFs
diff --git a/src/fs/virtfs/fszip.h b/src/fs/virtfs/fszip.h
deleted file mode 100644
index 92cfd0ab6..000000000
--- a/src/fs/virtfs/fszip.h
+++ /dev/null
@@ -1,93 +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 UTILS_VIRTFSZIP_H
-#define UTILS_VIRTFSZIP_H
-
-#include "utils/stringvector.h"
-
-#include "localconsts.h"
-
-namespace VirtFs
-{
-
-struct File;
-struct List;
-struct FsFuncs;
-struct FsEntry;
-
-namespace FsZip
-{
- FsFuncs *getFuncs();
- void init();
- void initFuncs(FsFuncs *restrict const ptr);
- void deinit();
- bool exists(FsEntry *restrict const entry,
- std::string filename,
- std::string dirName);
- void enumerate(FsEntry *restrict const entry,
- std::string dirName,
- StringVect &names);
- void getFiles(FsEntry *restrict const entry,
- std::string dirName,
- StringVect &names);
- void getFilesWithDir(FsEntry *restrict const entry,
- const std::string &dirName,
- StringVect &names);
- void getDirs(FsEntry *restrict const entry,
- std::string dirName,
- StringVect &names);
- bool isDirectory(FsEntry *restrict const entry,
- std::string dirName,
- bool &isDirFlag);
- void freeList(List *restrict const handle);
- File *openRead(FsEntry *restrict const entry,
- std::string filename);
- File *openWrite(FsEntry *restrict const entry,
- const std::string &filename);
- File *openAppend(FsEntry *restrict const entry,
- const std::string &filename);
- File *openReadInternal(const std::string &filename);
- bool getRealDir(FsEntry *restrict const entry,
- std::string filename,
- std::string dirName,
- std::string &realDir);
- int64_t read(File *restrict const handle,
- void *restrict const buffer,
- const uint32_t objSize,
- const uint32_t objCount);
- int64_t write(File *restrict const file,
- const void *restrict const buffer,
- const uint32_t objSize,
- const uint32_t objCount);
- int close(File *restrict const file);
- int64_t fileLength(File *restrict const file);
- int64_t tell(File *restrict const file);
- int seek(File *restrict const file,
- const uint64_t pos);
- int eof(File *restrict const file);
- const char *loadFile(FsEntry *restrict const entry,
- std::string fileName,
- int &restrict fileSize);
-} // namespace FsZip
-
-} // namespace VirtFs
-
-#endif // UTILS_VIRTFSZIP_H
diff --git a/src/fs/virtfs/fsziprwops.cpp b/src/fs/virtfs/fsziprwops.cpp
deleted file mode 100644
index e9f72c469..000000000
--- a/src/fs/virtfs/fsziprwops.cpp
+++ /dev/null
@@ -1,160 +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 "fs/virtfs/fsziprwops.h"
-
-#include "logger.h"
-
-#include "fs/virtfs/file.h"
-#include "fs/virtfs/fsfuncs.h"
-
-#include "utils/cast.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_rwops.h>
-PRAGMA48(GCC diagnostic pop)
-
-#include "debug.h"
-
-namespace VirtFs
-{
-
-namespace FsZip
-{
- RWOPSINT rwops_seek(SDL_RWops *const rw,
- const RWOPSINT offset,
- const int whence)
- {
- if (rw == nullptr)
- return -1;
- File *const handle = static_cast<File *>(
- rw->hidden.unknown.data1);
- size_t mPos = handle->mPos;
- size_t mSize = handle->mSize;
-
- RWOPSINT pos = 0;
-
- if (whence == SEEK_SET)
- {
- pos = offset;
- }
- else if (whence == SEEK_CUR)
- {
- const int64_t current = mPos;
- if (current == -1)
- {
- logger->assertLog(
- "VirtFs::rwops_seek: Can't find position in file.");
- return -1;
- }
-
- pos = CAST_S32(current);
- if (static_cast<int64_t>(pos) != current)
- {
- logger->assertLog("VirtFs::rwops_seek: "
- "Can't fit current file position in an int!");
- return -1;
- }
-
- if (offset == 0) /* this is a "tell" call. We're done. */
- return pos;
-
- pos += offset;
- }
- else if (whence == SEEK_END)
- {
- pos = static_cast<RWOPSINT>(mSize + offset);
- }
- else
- {
- logger->assertLog(
- "VirtFs::rwops_seek: Invalid 'whence' parameter.");
- return -1;
- }
-
- if (pos < 0)
- {
- logger->assertLog("VirtFs::rwops_seek: "
- "Attempt to seek past start of file.");
- return -1;
- }
-
- handle->mPos = pos;
-
- if (pos > static_cast<RWOPSINT>(mSize))
- {
- logger->assertLog("VirtFs::rwops_seek: seek error.");
- return -1;
- }
-
- return pos;
- }
-
- RWOPSSIZE rwops_read(SDL_RWops *const rw,
- void *const ptr,
- const RWOPSSIZE size,
- const RWOPSSIZE maxnum)
- {
- if (rw == nullptr)
- return 0;
- File *const handle = static_cast<File *>(
- rw->hidden.unknown.data1);
-
- const int64_t rc = handle->funcs->read(handle,
- ptr,
- CAST_U32(size),
- CAST_U32(maxnum));
- return CAST_S32(rc);
- }
-
- RWOPSSIZE rwops_write(SDL_RWops *const rw A_UNUSED,
- const void *const ptr A_UNUSED,
- const RWOPSSIZE size A_UNUSED,
- const RWOPSSIZE num A_UNUSED)
- {
- return 0;
- }
-
- int rwops_close(SDL_RWops *const rw)
- {
- if (rw == nullptr)
- return 0;
- File *const handle = static_cast<File*>(
- rw->hidden.unknown.data1);
- delete handle;
- SDL_FreeRW(rw);
- return 0;
- }
-
-#ifdef USE_SDL2
- RWOPSINT rwops_size(SDL_RWops *const rw)
- {
- if (!rw)
- return 0;
- File *const handle = static_cast<File *>(
- rw->hidden.unknown.data1);
- return handle->mSize;
- }
-#endif // USE_SDL2
-
-} // namespace FsZip
-
-} // namespace VirtFs
diff --git a/src/fs/virtfs/fsziprwops.h b/src/fs/virtfs/fsziprwops.h
deleted file mode 100644
index 508b2213c..000000000
--- a/src/fs/virtfs/fsziprwops.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 UTILS_VIRTFS_VIRTFSZIPRWOPS_H
-#define UTILS_VIRTFS_VIRTFSZIPRWOPS_H
-
-#include "fs/virtfs/rwopstypes.h"
-
-#include "localconsts.h"
-
-struct SDL_RWops;
-
-namespace VirtFs
-{
-
-namespace FsZip
-{
- RWOPSINT rwops_seek(SDL_RWops *const rw,
- const RWOPSINT offset,
- const int whence);
- RWOPSSIZE rwops_read(SDL_RWops *const rw,
- void *const ptr,
- const RWOPSSIZE size,
- const RWOPSSIZE maxnum);
- RWOPSSIZE rwops_write(SDL_RWops *const rw,
- const void *const ptr,
- const RWOPSSIZE size,
- const RWOPSSIZE num);
- int rwops_close(SDL_RWops *const rw);
-#ifdef USE_SDL2
- RWOPSINT rwops_size(SDL_RWops *const rw);
-#endif // USE_SDL2
-
-} // namespace FsZip
-
-} // namespace VirtFs
-
-#endif // UTILS_VIRTFS_VIRTFSZIPRWOPS_H
diff --git a/src/fs/virtfs/list.cpp b/src/fs/virtfs/list.cpp
deleted file mode 100644
index 2f0a23d66..000000000
--- a/src/fs/virtfs/list.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 "fs/virtfs/list.h"
-
-#include "debug.h"
-
-namespace VirtFs
-{
-
-List::List() :
- names()
-{
-}
-
-List::~List()
-{
-}
-
-} // namespace VirtFs
diff --git a/src/fs/virtfs/list.h b/src/fs/virtfs/list.h
deleted file mode 100644
index 9dcb9e269..000000000
--- a/src/fs/virtfs/list.h
+++ /dev/null
@@ -1,44 +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 UTILS_VIRTLIST_H
-#define UTILS_VIRTLIST_H
-
-#include "utils/stringvector.h"
-
-#include "localconsts.h"
-
-namespace VirtFs
-{
-
-struct List final
-{
- List();
-
- A_DELETE_COPY(List)
-
- ~List();
-
- StringVect names;
-};
-
-} // namespace VirtFs
-
-#endif // UTILS_VIRTLIST_H
diff --git a/src/fs/virtfs/rwops.cpp b/src/fs/virtfs/rwops.cpp
deleted file mode 100644
index e6a7a5914..000000000
--- a/src/fs/virtfs/rwops.cpp
+++ /dev/null
@@ -1,149 +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/>.
- */
-
-/*
- * This code provides a glue layer between PhysicsFS and Simple Directmedia
- * Layer's (SDL) RWops i/o abstraction.
- *
- * License: this code is public domain. I make no warranty that it is useful,
- * correct, harmless, or environmentally safe.
- *
- * This particular file may be used however you like, including copying it
- * verbatim into a closed-source project, exploiting it commercially, and
- * removing any trace of my name from the source (although I hope you won't
- * do that). I welcome enhancements and corrections to this file, but I do
- * not require you to send me patches if you make changes. This code has
- * NO WARRANTY.
- *
- * Unless otherwise stated, the rest of PhysicsFS falls under the zlib license.
- * Please see LICENSE.txt in the root of the source tree.
- *
- * SDL falls under the LGPL license. You can get SDL at http://www.libsdl.org/
- *
- * This file was written by Ryan C. Gordon. (icculus@icculus.org).
- *
- * Copyright (C) 2012-2017 The ManaPlus Developers
- */
-
-#include "fs/virtfs/rwops.h"
-
-#include "logger.h"
-
-#include "fs/virtfs/file.h"
-#include "fs/virtfs/fs.h"
-#include "fs/virtfs/fsfuncs.h"
-
-#include "utils/fuzzer.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_rwops.h>
-PRAGMA48(GCC diagnostic pop)
-
-#include "debug.h"
-
-namespace VirtFs
-{
-
-SDL_RWops *create_rwops(File *const file)
-{
- SDL_RWops *retval = nullptr;
-
- if (file == nullptr)
- {
- logger->assertLog("VirtFs::rwops_seek: create rwops error.");
- }
- else
- {
- retval = SDL_AllocRW();
- if (retval != nullptr)
- {
-#ifdef USE_SDL2
- retval->size = file->funcs->rwops_size;
-#endif // USE_SDL2
-
- retval->seek = file->funcs->rwops_seek;
- retval->read = file->funcs->rwops_read;
- retval->write = file->funcs->rwops_write;
- retval->close = file->funcs->rwops_close;
- retval->hidden.unknown.data1 = file;
- } /* if */
- } /* else */
-
- return retval;
-} /* VirtFs::create_rwops */
-
-#ifdef __APPLE__
-static bool checkFilePath(const std::string &restrict fname)
-{
- if (fname.empty())
- return false;
- if (!exists(fname) || isDirectory(fname))
- return false;
- return true;
-}
-#endif // __APPLE__
-
-SDL_RWops *rwopsOpenRead(const std::string &restrict fname)
-{
- BLOCK_START("RWopsopenRead")
-#ifdef __APPLE__
- if (!checkFilePath(fname))
- return nullptr;
-#endif // __APPLE__
-#ifdef USE_FUZZER
- if (Fuzzer::conditionTerminate(fname))
- return nullptr;
-#endif // USE_FUZZER
-#ifdef USE_PROFILER
-
- SDL_RWops *const ret = create_rwops(openRead(fname));
-
- BLOCK_END("RWopsopenRead")
- return ret;
-#else // USE_PROFILER
-
- return create_rwops(openRead(fname));
-#endif // USE_PROFILER
-} /* RWopsopenRead */
-
-SDL_RWops *rwopsOpenWrite(const std::string &restrict fname)
-{
-#ifdef __APPLE__
- if (!checkFilePath(fname))
- return nullptr;
-#endif // __APPLE__
-
- return create_rwops(openWrite(fname));
-} /* RWopsopenWrite */
-
-SDL_RWops *rwopsOpenAppend(const std::string &restrict fname)
-{
-#ifdef __APPLE__
- if (!checkFilePath(fname))
- return nullptr;
-#endif // __APPLE__
-
- return create_rwops(openAppend(fname));
-} /* RWopsopenAppend */
-
-} // namespace VirtFs
-
-/* end of virtfsrwops.c ... */
diff --git a/src/fs/virtfs/rwops.h b/src/fs/virtfs/rwops.h
deleted file mode 100644
index 7be265ad2..000000000
--- a/src/fs/virtfs/rwops.h
+++ /dev/null
@@ -1,66 +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/>.
- */
-
-/*
- * This code provides a glue layer between PhysicsFS and Simple Directmedia
- * Layer's (SDL) RWops i/o abstraction.
- *
- * License: this code is public domain. I make no warranty that it is useful,
- * correct, harmless, or environmentally safe.
- *
- * This particular file may be used however you like, including copying it
- * verbatim into a closed-source project, exploiting it commercially, and
- * removing any trace of my name from the source (although I hope you won't
- * do that). I welcome enhancements and corrections to this file, but I do
- * not require you to send me patches if you make changes. This code has
- * NO WARRANTY.
- *
- * Unless otherwise stated, the rest of PhysicsFS falls under the zlib license.
- * Please see LICENSE.txt in the root of the source tree.
- *
- * SDL falls under the LGPL license. You can get SDL at http://www.libsdl.org/
- *
- * This file was written by Ryan C. Gordon. (icculus@icculus.org).
- *
- * Copyright (C) 2012-2017 The ManaPlus Developers
- */
-
-#ifndef SRC_FS_VIRTFSRWOPS_H
-#define SRC_FS_VIRTFSRWOPS_H
-
-#include "localconsts.h"
-
-#include <string>
-
-struct SDL_RWops;
-
-namespace VirtFs
-{
- struct File;
-
- SDL_RWops *create_rwops(File *const file);
-
- SDL_RWops *rwopsOpenRead(const std::string &restrict fname);
- SDL_RWops *rwopsOpenWrite(const std::string &restrict fname) A_WARN_UNUSED;
- SDL_RWops *rwopsOpenAppend(const std::string &restrict fname)
- A_WARN_UNUSED;
-} // namespace VirtFs
-
-#endif // SRC_FS_VIRTFSRWOPS_H
diff --git a/src/fs/virtfs/rwopstypes.h b/src/fs/virtfs/rwopstypes.h
deleted file mode 100644
index 36a87e5a4..000000000
--- a/src/fs/virtfs/rwopstypes.h
+++ /dev/null
@@ -1,34 +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 SRC_FS_VIRTFS_RWOPSTYPES_H
-#define SRC_FS_VIRTFS_RWOPSTYPES_H
-
-#include "localconsts.h"
-
-#ifdef USE_SDL2
-#define RWOPSINT int64_t
-#define RWOPSSIZE size_t
-#else // USE_SDL2
-#define RWOPSINT int32_t
-#define RWOPSSIZE int
-#endif // USE_SDL2
-
-#endif // SRC_FS_VIRTFS_RWOPSTYPES_H
diff --git a/src/fs/virtfs/tools.cpp b/src/fs/virtfs/tools.cpp
deleted file mode 100644
index 64153fc52..000000000
--- a/src/fs/virtfs/tools.cpp
+++ /dev/null
@@ -1,157 +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 "fs/virtfs/tools.h"
-
-#include "logger.h"
-
-#include "fs/paths.h"
-
-#include "fs/virtfs/fs.h"
-#include "fs/virtfs/list.h"
-
-#include "utils/foreach.h"
-#include "utils/stringutils.h"
-
-#include <algorithm>
-#include <sstream>
-
-#include "debug.h"
-
-namespace VirtFs
-{
- void searchAndAddArchives(const std::string &restrict path,
- const std::string &restrict ext,
- const Append append)
- {
- List *const list = VirtFs::enumerateFiles(path);
- FOR_EACH (StringVectCIter, i, list->names)
- {
- const std::string str = *i;
- const size_t len = str.size();
-
- if (len > ext.length() &&
- ext == str.substr(len - ext.length()))
- {
- const std::string file = path + str;
- const std::string realPath = VirtFs::getRealDir(file);
- VirtFs::mountZip(pathJoin(realPath, file), append);
- }
- }
- VirtFs::freeList(list);
- }
-
- void searchAndRemoveArchives(const std::string &restrict path,
- const std::string &restrict ext)
- {
- List *const list = VirtFs::enumerateFiles(path);
- FOR_EACH (StringVectCIter, i, list->names)
- {
- const std::string str = *i;
- const size_t len = str.size();
- if (len > ext.length() &&
- ext == str.substr(len - ext.length()))
- {
- const std::string file = path + str;
- const std::string realPath = VirtFs::getRealDir(file);
- VirtFs::unmountZip(pathJoin(realPath, file));
- }
- }
- VirtFs::freeList(list);
- }
-
- void getFilesInDir(const std::string &dir,
- StringVect &list,
- const std::string &ext)
- {
- const std::string &path = dir;
- StringVect tempList;
- VirtFs::getFilesWithDir(path, tempList);
- FOR_EACH (StringVectCIter, it, tempList)
- {
- const std::string &str = *it;
- if (findLast(str, ext))
- list.push_back(str);
- }
- std::sort(list.begin(), list.end());
- }
-
- std::string getPath(const std::string &file)
- {
- // get the real path to the file
- const std::string tmp = VirtFs::getRealDir(file);
- std::string path;
-
- // if the file is not in the search path, then its empty
- if (!tmp.empty())
- {
- path = pathJoin(tmp, file);
-#if defined __native_client__
- std::string dataZip = "/http/data.zip/";
- if (path.substr(0, dataZip.length()) == dataZip)
- path = path.replace(0, dataZip.length(), "/http/data/");
-#endif // defined __native_client__
- }
- else
- {
- // if not found in search path return the default path
- path = pathJoin(getPackageDir(), file);
- }
-
- return path;
- }
-
- std::string loadTextFileString(const std::string &fileName)
- {
- int contentsLength;
- const char *fileContents = VirtFs::loadFile(fileName, contentsLength);
-
- if (fileContents == nullptr)
- {
- logger->log("Couldn't load text file: %s", fileName.c_str());
- return std::string();
- }
- const std::string str = std::string(fileContents, contentsLength);
- delete [] fileContents;
- return str;
- }
-
- bool loadTextFile(const std::string &fileName,
- StringVect &lines)
- {
- int contentsLength;
- const char *fileContents = VirtFs::loadFile(fileName, contentsLength);
-
- if (fileContents == nullptr)
- {
- logger->log("Couldn't load text file: %s", fileName.c_str());
- return false;
- }
-
- std::istringstream iss(std::string(fileContents, contentsLength));
- std::string line;
-
- while (getline(iss, line))
- lines.push_back(line);
-
- delete [] fileContents;
- return true;
- }
-} // namespace VirtFs
diff --git a/src/fs/virtfs/tools.h b/src/fs/virtfs/tools.h
deleted file mode 100644
index f00a976bb..000000000
--- a/src/fs/virtfs/tools.h
+++ /dev/null
@@ -1,46 +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 UTILS_VIRTFSTOOLS_H
-#define UTILS_VIRTFSTOOLS_H
-
-#include "enums/simpletypes/append.h"
-
-#include "utils/stringvector.h"
-
-#include "localconsts.h"
-
-namespace VirtFs
-{
- void searchAndAddArchives(const std::string &restrict path,
- const std::string &restrict ext,
- const Append append);
- void searchAndRemoveArchives(const std::string &restrict path,
- const std::string &restrict ext);
- void getFilesInDir(const std::string &dir,
- StringVect &list,
- const std::string &ext);
- std::string getPath(const std::string &file);
- bool loadTextFile(const std::string &fileName,
- StringVect &lines);
- std::string loadTextFileString(const std::string &fileName);
-} // namespace VirtFs
-
-#endif // UTILS_VIRTFSTOOLS_H
diff --git a/src/fs/virtfs/zipentry.cpp b/src/fs/virtfs/zipentry.cpp
deleted file mode 100644
index d8440833b..000000000
--- a/src/fs/virtfs/zipentry.cpp
+++ /dev/null
@@ -1,48 +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 "fs/virtfs/zipentry.h"
-
-#include "fs/virtfs/ziplocalheader.h"
-
-#include "utils/dtor.h"
-
-#include "debug.h"
-
-namespace VirtFs
-{
-
-ZipEntry::ZipEntry(const std::string &restrict archiveName,
- const std::string &subDir0,
- FsFuncs *restrict const funcs0) :
- FsEntry(FsEntryType::Zip, funcs0),
- mHeaders(),
- mDirs()
-{
- root = archiveName;
- subDir = subDir0;
-}
-
-ZipEntry::~ZipEntry()
-{
- delete_all(mHeaders);
-}
-
-} // namespace VirtFs
diff --git a/src/fs/virtfs/zipentry.h b/src/fs/virtfs/zipentry.h
deleted file mode 100644
index eaf77889d..000000000
--- a/src/fs/virtfs/zipentry.h
+++ /dev/null
@@ -1,51 +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 UTILS_VIRTZIPENTRY_H
-#define UTILS_VIRTZIPENTRY_H
-
-#include "fs/virtfs/fsentry.h"
-
-#include "utils/vector.h"
-
-#include "localconsts.h"
-
-namespace VirtFs
-{
-
-struct ZipLocalHeader;
-
-struct ZipEntry final : public FsEntry
-{
- ZipEntry(const std::string &restrict archiveName,
- const std::string &subDir0,
- FsFuncs *restrict const funcs);
-
- A_DELETE_COPY(ZipEntry)
-
- virtual ~ZipEntry();
-
- STD_VECTOR<ZipLocalHeader*> mHeaders;
- STD_VECTOR<std::string> mDirs;
-};
-
-} // namespace VirtFs
-
-#endif // UTILS_VIRTZIPENTRY_H
diff --git a/src/fs/virtfs/ziplocalheader.cpp b/src/fs/virtfs/ziplocalheader.cpp
deleted file mode 100644
index 437140d07..000000000
--- a/src/fs/virtfs/ziplocalheader.cpp
+++ /dev/null
@@ -1,40 +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 "fs/virtfs/ziplocalheader.h"
-
-#include "localconsts.h"
-
-#include "debug.h"
-
-namespace VirtFs
-{
-
-ZipLocalHeader::ZipLocalHeader() :
- fileName(),
- zipEntry(nullptr),
- dataOffset(0U),
- compressSize(0U),
- uncompressSize(0U),
- compressed(false)
-{
-}
-
-} // namespace VirtFs
diff --git a/src/fs/virtfs/ziplocalheader.h b/src/fs/virtfs/ziplocalheader.h
deleted file mode 100644
index 88bfc2458..000000000
--- a/src/fs/virtfs/ziplocalheader.h
+++ /dev/null
@@ -1,49 +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 UTILS_ZIPLOCALHEADER_H
-#define UTILS_ZIPLOCALHEADER_H
-
-#include "localconsts.h"
-
-#include <string>
-
-namespace VirtFs
-{
-
-struct ZipEntry;
-
-struct ZipLocalHeader final
-{
- ZipLocalHeader();
-
- A_DELETE_COPY(ZipLocalHeader)
-
- std::string fileName;
- ZipEntry *zipEntry;
- uint32_t dataOffset;
- uint32_t compressSize;
- uint32_t uncompressSize;
- bool compressed;
-};
-
-} // namespace VirtFs
-
-#endif // UTILS_ZIPLOCALHEADER_H
diff --git a/src/fs/virtfs/zipreader.cpp b/src/fs/virtfs/zipreader.cpp
deleted file mode 100644
index 2d473bec7..000000000
--- a/src/fs/virtfs/zipreader.cpp
+++ /dev/null
@@ -1,334 +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 "fs/virtfs/zipreader.h"
-
-#include "fs/paths.h"
-
-#include "fs/virtfs/zipentry.h"
-#include "fs/virtfs/ziplocalheader.h"
-
-#include "utils/cast.h"
-#include "utils/checkutils.h"
-#include "utils/delete2.h"
-#include "utils/stringutils.h"
-
-#include <zlib.h>
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_endian.h>
-PRAGMA48(GCC diagnostic pop)
-
-#include "debug.h"
-
-#ifndef SDL_BIG_ENDIAN
-#error missing SDL_endian.h
-#endif // SDL_BYTEORDER
-
-// #define DEBUG_ZIP
-
-extern const char *dirSeparator;
-
-#define readVal(val, sz, msg) \
- cnt = fread(static_cast<void*>(val), 1, sz, arcFile); \
- if (cnt != sz) \
- { \
- reportAlways("Error reading " msg " in file %s", \
- archiveName.c_str()); \
- delete2(header); \
- delete [] buf; \
- fclose(arcFile); \
- return false; \
- }
-
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
-#define swapVal16(val) val = __builtin_bswap16(val);
-#define swapVal32(val) val = __builtin_bswap32(val);
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-#define swapVal16(val)
-#define swapVal32(val)
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
-namespace VirtFs
-{
-
-namespace ZipReader
-{
- bool readArchiveInfo(ZipEntry *const entry)
- {
- if (entry == nullptr)
- {
- reportAlways("Entry is null.");
- return false;
- }
- const std::string archiveName = entry->root;
- STD_VECTOR<ZipLocalHeader*> &restrict headers = entry->mHeaders;
- STD_VECTOR<std::string> &restrict dirs = entry->mDirs;
- FILE *restrict const arcFile = fopen(archiveName.c_str(),
- "rb");
- if (arcFile == nullptr)
- {
- reportAlways("Can't open zip file %s",
- archiveName.c_str());
- return false;
- }
- uint8_t *const buf = new uint8_t[65535 + 10];
- uint16_t val16 = 0U;
- uint16_t method = 0U;
- ZipLocalHeader *header = nullptr;
-
-#ifdef DEBUG_ZIP
- logger->log("Read archive: %s", archiveName.c_str());
-#endif // DEBUG_ZIP
-
- // format source https://en.wikipedia.org/wiki/Zip_%28file_format%29
- while (feof(arcFile) == 0)
- {
- size_t cnt = 0U;
- // file header pointer on 0
- // read file header signature
- readVal(buf, 4, "zip file header"); // + 4
- // pointer on 4
-
- if (buf[0] == 0x50 &&
- buf[1] == 0x4B &&
- buf[2] == 0x03 &&
- buf[3] == 0x04)
- { // local file header
- header = new ZipLocalHeader;
- header->zipEntry = entry;
- // skip useless fields
- fseek(arcFile, 4, SEEK_CUR); // + 4
- // file header pointer on 8
- readVal(&method, 2, "compression method") // + 2
- swapVal16(method)
- header->compressed = (method != 0);
- // file header pointer on 10
- fseek(arcFile, 8, SEEK_CUR); // + 8
- // file header pointer on 18
- readVal(&header->compressSize, 4,
- "zip compressed size") // + 4
- swapVal32(header->compressSize)
- // file header pointer on 22
- readVal(&header->uncompressSize, 4,
- "zip uncompressed size") // + 4
- swapVal32(header->uncompressSize)
- // file header pointer on 26
- readVal(&val16, 2, "file name length") // + 2
- swapVal16(val16)
- // file header pointer on 28
- const uint32_t fileNameLen = CAST_U32(val16);
- if (fileNameLen > 1000)
- {
- reportAlways("Error too long file name in file %s",
- archiveName.c_str());
- delete header;
- delete [] buf;
- fclose(arcFile);
- return false;
- }
- readVal(&val16, 2, "extra field length") // + 2
- swapVal16(val16)
- // file header pointer on 30
- const uint32_t extraFieldLen = CAST_U32(val16);
- readVal(buf, fileNameLen, "file name");
- // file header pointer on 30 + fileNameLen
- buf[fileNameLen] = 0;
- header->fileName = std::string(
- reinterpret_cast<char*>(buf));
- prepareFsPath(header->fileName);
- header->dataOffset = CAST_S32(ftell(arcFile) + extraFieldLen);
- fseek(arcFile, extraFieldLen + header->compressSize, SEEK_CUR);
- // pointer on 30 + fileNameLen + extraFieldLen + compressSize
- if (findLast(header->fileName, dirSeparator) == false)
- {
- headers.push_back(header);
-#ifdef DEBUG_ZIP
- logger->log(" file name: %s",
- header->fileName.c_str());
- logger->log(" compression method: %u",
- CAST_U32(method));
- logger->log(" compressed size: %u",
- header->compressSize);
- logger->log(" uncompressed size: %u",
- header->uncompressSize);
-#endif // DEBUG_ZIP
- }
- else
- {
-#ifdef DEBUG_ZIP
- logger->log(" dir name: %s",
- header->fileName.c_str());
-#endif // DEBUG_ZIP
- dirs.push_back(header->fileName);
- delete header;
- }
- }
- else if (buf[0] == 0x50 &&
- buf[1] == 0x4B &&
- buf[2] == 0x01 &&
- buf[3] == 0x02)
- { // central directory file header
- // !!! This is quick way for read zip archives. !!!
- // !!! It ignore modified files in archive. !!!
- // ignoring central directory entries
- break;
- }
- else if (buf[0] == 0x50 &&
- buf[1] == 0x4B &&
- buf[2] == 0x05 &&
- buf[3] == 0x06)
- { // end of central directory
- // !!! This is quick way for read zip archives. !!!
- // !!! It ignore modified files in archive. !!!
- // ignoring end of central directory
- break;
- }
- else
- {
- reportAlways("Error in header signature (0x%02x%02x%02x%02x)"
- " in file %s",
- buf[0],
- buf[1],
- buf[2],
- buf[3],
- archiveName.c_str());
- delete [] buf;
- fclose(arcFile);
- return false;
- }
- }
- delete [] buf;
- fclose(arcFile);
- return true;
- }
-
- void reportZlibError(const std::string &text,
- const int err)
- {
- reportAlways("Zlib error: '%s' in %s",
- text.c_str(),
- getZlibError(err).c_str());
- }
-
- std::string getZlibError(const int err)
- {
- switch (err)
- {
- case Z_OK:
- return std::string();
- default:
- return "unknown zlib error";
- }
- }
-
- uint8_t *readCompressedFile(const ZipLocalHeader *restrict const header)
- {
- if (header == nullptr)
- {
- reportAlways("ZipReader::readCompressedFile: header is null");
- return nullptr;
- }
- FILE *restrict const arcFile = fopen(
- header->zipEntry->root.c_str(),
- "rb");
- if (arcFile == nullptr)
- {
- reportAlways("Can't open zip file %s",
- header->zipEntry->root.c_str());
- return nullptr;
- }
-
- fseek(arcFile, header->dataOffset, SEEK_SET);
- const uint32_t compressSize = header->compressSize;
- uint8_t *const buf = new uint8_t[compressSize];
- if (fread(static_cast<void*>(buf), 1, compressSize, arcFile) !=
- compressSize)
- {
- reportAlways("Read zip compressed file error from archive: %s",
- header->zipEntry->root.c_str());
- fclose(arcFile);
- delete [] buf;
- return nullptr;
- }
- fclose(arcFile);
- return buf;
- }
-
- const uint8_t *readFile(const ZipLocalHeader *restrict const header)
- {
- if (header == nullptr)
- {
- reportAlways("Open zip file error. header is null.");
- return nullptr;
- }
- uint8_t *restrict const in = readCompressedFile(header);
- if (in == nullptr)
- return nullptr;
- if (header->compressed == false)
- return in; // return as is if data not compressed
- const size_t outSize = header->uncompressSize;
- uint8_t *restrict const out = new uint8_t[outSize];
- if (outSize == 0)
- {
- delete [] in;
- return out;
- }
-
- z_stream strm;
- strm.zalloc = nullptr;
- strm.zfree = nullptr;
- strm.opaque = nullptr;
- strm.next_in = in;
- strm.avail_in = header->compressSize;
- strm.next_out = out;
- strm.avail_out = CAST_U32(outSize);
-
-PRAGMACLANG6GCC(GCC diagnostic push)
-PRAGMACLANG6GCC(GCC diagnostic ignored "-Wold-style-cast")
- int ret = inflateInit2(&strm, -MAX_WBITS);
-PRAGMACLANG6GCC(GCC diagnostic pop)
-
- if (ret != Z_OK)
- {
- reportZlibError(header->zipEntry->root, ret);
- delete [] in;
- delete [] out;
- return nullptr;
- }
- ret = inflate(&strm, Z_FINISH);
-// ret = inflate(&strm, Z_SYNC_FLUSH);
- if (ret != Z_OK &&
- ret != Z_STREAM_END)
- {
- reportZlibError("file decompression error",
- ret);
- inflateEnd(&strm);
- delete [] in;
- delete [] out;
- return nullptr;
- }
- inflateEnd(&strm);
- delete [] in;
- return out;
- }
-} // namespace ZipReader
-
-} // namespace VirtFs
diff --git a/src/fs/virtfs/zipreader.h b/src/fs/virtfs/zipreader.h
deleted file mode 100644
index cf7a85033..000000000
--- a/src/fs/virtfs/zipreader.h
+++ /dev/null
@@ -1,46 +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 UTILS_ZIP_H
-#define UTILS_ZIP_H
-
-#include "localconsts.h"
-
-#include <string>
-
-namespace VirtFs
-{
-
-struct ZipEntry;
-struct ZipLocalHeader;
-
-namespace ZipReader
-{
- bool readArchiveInfo(ZipEntry *const entry);
- std::string getZlibError(const int err);
- void reportZlibError(const std::string &text,
- const int err);
- uint8_t *readCompressedFile(const ZipLocalHeader *restrict const header);
- const uint8_t *readFile(const ZipLocalHeader *restrict const header);
-} // namespace ZipReader
-
-} // namespace VirtFs
-
-#endif // UTILS_ZIP_H
diff --git a/src/game.cpp b/src/game.cpp
deleted file mode 100644
index e09e6c92f..000000000
--- a/src/game.cpp
+++ /dev/null
@@ -1,1260 +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 "game.h"
-
-#include "actormanager.h"
-#include "client.h"
-#include "configuration.h"
-#include "effectmanager.h"
-#include "eventsmanager.h"
-#include "gamemodifiers.h"
-#include "soundmanager.h"
-#include "settings.h"
-
-#include "being/crazymoves.h"
-#include "being/localplayer.h"
-#include "being/playerinfo.h"
-
-#include "const/itemshortcut.h"
-#include "const/spells.h"
-
-#include "const/gui/chat.h"
-
-#include "enums/being/beingdirection.h"
-
-#include "fs/mkdir.h"
-
-#include "fs/virtfs/fs.h"
-
-#include "gui/dialogsmanager.h"
-#include "gui/gui.h"
-#include "gui/popupmanager.h"
-#include "gui/viewport.h"
-#include "gui/windowmanager.h"
-#include "gui/windowmenu.h"
-
-#include "gui/fonts/font.h"
-
-#include "gui/shortcut/dropshortcut.h"
-#include "gui/shortcut/emoteshortcut.h"
-
-#include "gui/popups/popupmenu.h"
-
-#include "gui/windows/bankwindow.h"
-#include "gui/windows/cutinwindow.h"
-#include "gui/windows/mailwindow.h"
-#include "gui/windows/chatwindow.h"
-#include "gui/windows/debugwindow.h"
-#include "gui/windows/didyouknowwindow.h"
-#include "gui/windows/emotewindow.h"
-#include "gui/windows/equipmentwindow.h"
-#include "gui/windows/inventorywindow.h"
-#include "gui/windows/killstats.h"
-#include "gui/windows/minimap.h"
-#include "gui/windows/ministatuswindow.h"
-#include "gui/windows/npcdialog.h"
-#include "gui/windows/outfitwindow.h"
-#include "gui/windows/setupwindow.h"
-#include "gui/windows/shopwindow.h"
-#include "gui/windows/shortcutwindow.h"
-#include "gui/windows/skilldialog.h"
-#include "gui/windows/socialwindow.h"
-#include "gui/windows/statuswindow.h"
-#include "gui/windows/tradewindow.h"
-#include "gui/windows/questswindow.h"
-#include "gui/windows/whoisonline.h"
-
-#include "gui/widgets/tabs/chat/battletab.h"
-
-#include "gui/widgets/createwidget.h"
-#include "gui/widgets/emoteshortcutcontainer.h"
-#include "gui/widgets/itemshortcutcontainer.h"
-#include "gui/widgets/spellshortcutcontainer.h"
-#include "gui/widgets/virtshortcutcontainer.h"
-
-#include "gui/widgets/tabs/chat/gmtab.h"
-#include "gui/widgets/tabs/chat/langtab.h"
-#include "gui/widgets/tabs/chat/tradetab.h"
-
-#include "input/inputmanager.h"
-#include "input/joystick.h"
-#include "input/keyboardconfig.h"
-
-#include "input/touch/touchmanager.h"
-
-#include "net/generalhandler.h"
-#include "net/gamehandler.h"
-#include "net/net.h"
-#include "net/packetcounters.h"
-
-#include "particle/particleengine.h"
-
-#include "resources/delayedmanager.h"
-#include "resources/mapreader.h"
-#include "resources/screenshothelper.h"
-
-#include "resources/db/mapdb.h"
-
-#include "resources/map/map.h"
-
-#include "resources/resourcemanager/resourcemanager.h"
-
-#include "resources/sprite/animatedsprite.h"
-
-#include "utils/delete2.h"
-#include "utils/foreach.h"
-#include "utils/gettext.h"
-#include "utils/pnglib.h"
-#include "utils/sdlcheckutils.h"
-#include "utils/timer.h"
-
-#ifdef __native_client__
-#include "utils/naclmessages.h"
-#endif // __native_client__
-
-#include "listeners/assertlistener.h"
-#include "listeners/errorlistener.h"
-
-#ifdef TMWA_SUPPORT
-#include "net/tmwa/guildmanager.h"
-#endif // TMWA_SUPPORT
-
-#ifdef USE_MUMBLE
-#include "mumblemanager.h"
-#endif // USE_MUMBLE
-
-#ifdef WIN32
-#include <sys/time.h>
-#undef ERROR
-#endif // WIN32
-
-#include "debug.h"
-
-QuitDialog *quitDialog = nullptr;
-Window *disconnectedDialog = nullptr;
-
-bool mStatsReUpdated = false;
-const time_t adjustDelay = 10;
-
-/**
- * Initialize every game sub-engines in the right order
- */
-static void initEngines()
-{
- actorManager = new ActorManager;
- effectManager = new EffectManager;
-#ifdef TMWA_SUPPORT
- GuildManager::init();
-#endif // TMWA_SUPPORT
-
- crazyMoves = new CrazyMoves;
-
- particleEngine = new ParticleEngine;
- particleEngine->setMap(nullptr);
- particleEngine->setupEngine();
- BeingInfo::init();
-
- if (gameHandler != nullptr)
- gameHandler->initEngines();
-
- keyboard.update();
- if (joystick != nullptr)
- joystick->update();
-
- UpdateStatusListener::distributeEvent();
-}
-
-/**
- * Create all the various globally accessible gui windows
- */
-static void createGuiWindows()
-{
- if (setupWindow != nullptr)
- setupWindow->clearWindowsForReset();
-
- if (emoteShortcut != nullptr)
- emoteShortcut->load();
-
- GameModifiers::init();
-
- // Create dialogs
- CREATEWIDGETV0(emoteWindow, EmoteWindow);
- delete2(debugChatTab)
- if (chatWindow != nullptr)
- {
- chatWindow->scheduleDelete();
- chatWindow = nullptr;
- }
- CREATEWIDGETV(chatWindow, ChatWindow,
- "Chat");
- CREATEWIDGETV0(tradeWindow, TradeWindow);
- CREATEWIDGETV(equipmentWindow, EquipmentWindow,
- PlayerInfo::getEquipment(),
- localPlayer);
- CREATEWIDGETV(beingEquipmentWindow, EquipmentWindow,
- nullptr, nullptr, true);
- beingEquipmentWindow->setVisible(Visible_false);
- CREATEWIDGETV0(statusWindow, StatusWindow);
- CREATEWIDGETV0(miniStatusWindow, MiniStatusWindow);
- CREATEWIDGETV(inventoryWindow, InventoryWindow,
- PlayerInfo::getInventory());
- if (Net::getNetworkType() != ServerType::TMWATHENA)
- {
- CREATEWIDGETV(cartWindow, InventoryWindow,
- PlayerInfo::getCartInventory());
- }
- CREATEWIDGETV0(cutInWindow, CutInWindow);
- CREATEWIDGETV0(shopWindow, ShopWindow);
- CREATEWIDGETV0(skillDialog, SkillDialog);
- CREATEWIDGETV0(minimap, Minimap);
- if (debugWindow != nullptr)
- {
- debugWindow->scheduleDelete();
- debugWindow = nullptr;
- }
- CREATEWIDGETV(debugWindow, DebugWindow,
- "Debug");
- CREATEWIDGETV(itemShortcutWindow, ShortcutWindow,
- "ItemShortcut", "items.xml", 83, 460);
-
- for (unsigned f = 0; f < SHORTCUT_TABS - 1; f ++)
- {
- itemShortcutWindow->addTab(toString(f + 1),
- new ItemShortcutContainer(nullptr, f));
- }
- if (Net::getNetworkType() != ServerType::TMWATHENA)
- {
- itemShortcutWindow->addTab("A",
- new ItemShortcutContainer(nullptr, SHORTCUT_TABS - 1));
- }
- if (config.getBoolValue("showDidYouKnow"))
- {
- didYouKnowWindow->setVisible(Visible_true);
- didYouKnowWindow->loadData();
- }
-
- CREATEWIDGETV(emoteShortcutWindow, ShortcutWindow,
- "EmoteShortcut",
- new EmoteShortcutContainer(nullptr),
- "emotes.xml",
- 130, 480);
- CREATEWIDGETV0(outfitWindow, OutfitWindow);
- CREATEWIDGETV(dropShortcutWindow, ShortcutWindow,
- "DropShortcut",
- new VirtShortcutContainer(nullptr, dropShortcut),
- "drops.xml");
- CREATEWIDGETV(spellShortcutWindow, ShortcutWindow,
- "SpellShortcut",
- "spells.xml",
- 265, 328);
- for (unsigned f = 0; f < SPELL_SHORTCUT_TABS; f ++)
- {
- spellShortcutWindow->addTab(toString(f + 1),
- new SpellShortcutContainer(nullptr, f));
- }
-
- CREATEWIDGETV0(bankWindow, BankWindow);
- CREATEWIDGETV0(mailWindow, MailWindow);
- CREATEWIDGETV0(whoIsOnline, WhoIsOnline);
- CREATEWIDGETV0(killStats, KillStats);
- CREATEWIDGETV0(socialWindow, SocialWindow);
- CREATEWIDGETV0(questsWindow, QuestsWindow);
-
- // TRANSLATORS: chat tab header
- localChatTab = new ChatTab(chatWindow, _("General"),
- GENERAL_CHANNEL, "#General", ChatTabType::INPUT);
- localChatTab->setAllowHighlight(false);
- if (config.getBoolValue("showChatHistory"))
- localChatTab->loadFromLogFile("#General");
-
- // TRANSLATORS: chat tab header
- debugChatTab = new ChatTab(chatWindow, _("Debug"), "",
- "#Debug", ChatTabType::DEBUG);
- debugChatTab->setAllowHighlight(false);
-
- if (assertListener != nullptr)
- {
- const StringVect &messages = assertListener->getMessages();
- FOR_EACH (StringVectCIter, it, messages)
- debugChatTab->chatLog(*it, ChatMsgType::BY_SERVER);
- delete2(assertListener);
- }
- if (config.getBoolValue("enableTradeTab"))
- chatWindow->addSpecialChannelTab(TRADE_CHANNEL, false);
- else
- tradeChatTab = nullptr;
-
- if (config.getBoolValue("enableBattleTab"))
- {
- battleChatTab = new BattleTab(chatWindow);
- battleChatTab->setAllowHighlight(false);
- }
- else
- {
- battleChatTab = nullptr;
- }
-
- chatWindow->showGMTab();
- if (!isSafeMode)
- chatWindow->loadState();
-
- if (setupWindow != nullptr)
- setupWindow->externalUpdate();
-
- if (localPlayer != nullptr)
- localPlayer->updateStatus();
-
- if (generalHandler != nullptr)
- generalHandler->gameStarted();
-}
-
-/**
- * Destroy all the globally accessible gui windows
- */
-static void destroyGuiWindows()
-{
- if (generalHandler != nullptr)
- generalHandler->gameEnded();
-
- if (whoIsOnline != nullptr)
- whoIsOnline->setAllowUpdate(false);
-
-#ifdef TMWA_SUPPORT
- GuildManager::clear();
-#endif // TMWA_SUPPORT
-
- delete2(windowMenu);
- delete2(localChatTab) // Need to do this first, so it can remove itself
- delete2(debugChatTab)
- delete2(tradeChatTab)
- delete2(battleChatTab)
- delete2(langChatTab)
- delete2(gmChatTab);
-#ifdef TMWA_SUPPORT
- if (guildManager != nullptr && GuildManager::getEnableGuildBot())
- guildManager->reload();
-#endif // TMWA_SUPPORT
-
- logger->log("start deleting");
- delete2(emoteWindow);
- delete2(chatWindow)
- logger->log("end deleting");
- delete2(statusWindow)
- delete2(miniStatusWindow)
- delete2(inventoryWindow)
- delete2(cartWindow)
- delete2(shopWindow)
- delete2(skillDialog)
- delete2(minimap)
- delete2(equipmentWindow)
- delete2(beingEquipmentWindow)
- delete2(tradeWindow)
- delete2(debugWindow)
- delete2(itemShortcutWindow)
- delete2(emoteShortcutWindow)
- delete2(outfitWindow)
- delete2(socialWindow)
- delete2(dropShortcutWindow);
- delete2(spellShortcutWindow);
- delete2(bankWindow);
- delete2(cutInWindow);
- delete2(mailWindow);
- delete2(questsWindow);
- delete2(whoIsOnline);
- delete2(killStats);
-}
-
-Game *Game::mInstance = nullptr;
-
-Game::Game() :
- mCurrentMap(nullptr),
- mMapName(""),
- mValidSpeed(true),
- mNextAdjustTime(cur_time + adjustDelay),
- mAdjustLevel(0),
- mAdjustPerfomance(config.getBoolValue("adjustPerfomance")),
- mLowerCounter(0),
- mPing(0),
- mTime(cur_time + 1),
- mTime2(cur_time + 10)
-{
- touchManager.setInGame(true);
-
-// assert(!mInstance);
- if (mInstance != nullptr)
- logger->log("error: double game creation");
- mInstance = this;
-
- config.incValue("gamecount");
-
- disconnectedDialog = nullptr;
-
- // Create the viewport
- viewport = new Viewport;
- viewport->setSize(mainGraphics->mWidth, mainGraphics->mHeight);
- PlayerInfo::clear();
-
- emptyBeingSlot = new BeingSlot;
-
- BasicContainer2 *const top = static_cast<BasicContainer2*>(gui->getTop());
- if (top != nullptr)
- top->add(viewport);
- viewport->requestMoveToBottom();
-
- AnimatedSprite::setEnableCache(
- mainGraphics->getOpenGL() != RENDER_SOFTWARE &&
- config.getBoolValue("enableDelayedAnimations"));
-
- CompoundSprite::setEnableDelay(
- config.getBoolValue("enableCompoundSpriteDelay"));
-
- createGuiWindows();
- windowMenu = new WindowMenu(nullptr);
-
- if (windowContainer != nullptr)
- windowContainer->add(windowMenu);
-
-#ifdef USE_OPENGL
- MapReader::loadEmptyAtlas();
-#endif // USE_OPENGL
-
- initEngines();
-
- chatWindow->postConnection();
- mailWindow->postConnection();
-
- // Initialize beings
- if (actorManager != nullptr)
- actorManager->setPlayer(localPlayer);
-
- gameHandler->ping(tick_time);
-
- if (setupWindow != nullptr)
- setupWindow->setInGame(true);
- clearKeysArray();
-
-#ifdef TMWA_SUPPORT
- if (guildManager != nullptr && GuildManager::getEnableGuildBot())
- guildManager->requestGuildInfo();
-#endif // TMWA_SUPPORT
-
- settings.disableLoggingInGame = config.getBoolValue(
- "disableLoggingInGame");
-}
-
-Game::~Game()
-{
-#ifdef USE_OPENGL
- MapReader::unloadEmptyAtlas();
-#endif // USE_OPENGL
-
- settings.disableLoggingInGame = false;
- touchManager.setInGame(false);
- config.write();
- serverConfig.write();
- resetAdjustLevel();
- destroyGuiWindows();
-
- AnimatedSprite::setEnableCache(false);
-
- delete2(actorManager)
- if (client->getState() != State::CHANGE_MAP)
- delete2(localPlayer)
- if (effectManager != nullptr)
- effectManager->clear();
- delete2(effectManager)
- delete2(particleEngine)
- delete2(viewport)
- delete2(mCurrentMap)
-#ifdef TMWA_SUPPORT
- delete2(guildManager)
-#endif // TMWA_SUPPORT
-#ifdef USE_MUMBLE
- delete2(mumbleManager)
-#endif // USE_MUMBLE
-
- delete2(crazyMoves);
- delete2(emptyBeingSlot);
-
- Being::clearCache();
- mInstance = nullptr;
- PlayerInfo::gameDestroyed();
-}
-
-void Game::addWatermark()
-{
- if ((boldFont == nullptr) || !config.getBoolValue("addwatermark"))
- return;
-
- const Color &color1 = theme->getColor(ThemeColorId::TEXT, 255);
- const Color &color2 = theme->getColor(ThemeColorId::TEXT_OUTLINE, 255);
-
- boldFont->drawString(mainGraphics,
- color1,
- color2,
- settings.serverName,
- 100, 50);
-}
-
-bool Game::createScreenshot(const std::string &prefix)
-{
- if ((mainGraphics == nullptr) || (screenshortHelper == nullptr))
- return false;
-
- SDL_Surface *screenshot = nullptr;
-
- if (!config.getBoolValue("showip") && (gui != nullptr))
- {
- mainGraphics->setSecure(true);
- screenshortHelper->prepare();
- gui->draw();
- addWatermark();
- screenshot = screenshortHelper->getScreenshot();
- mainGraphics->setSecure(false);
- }
- else
- {
- addWatermark();
- screenshot = screenshortHelper->getScreenshot();
- }
-
- if (screenshot == nullptr)
- return false;
-
- return saveScreenshot(screenshot, prefix);
-}
-
-bool Game::saveScreenshot(SDL_Surface *const screenshot,
- const std::string &prefix)
-{
- std::string screenshotDirectory = settings.screenshotDir;
- if (mkdir_r(screenshotDirectory.c_str()) != 0)
- {
- logger->log("Directory %s doesn't exist and can't be created! "
- "Setting screenshot directory to home.",
- screenshotDirectory.c_str());
- screenshotDirectory = std::string(VirtFs::getUserDir());
- }
-
- // Search for an unused screenshot name
- std::stringstream filename;
- std::fstream testExists;
-
- time_t rawtime;
- char buffer [100];
- time(&rawtime);
- struct tm *const timeinfo = localtime(&rawtime);
- strftime(buffer, 99, "%Y-%m-%d_%H-%M-%S", timeinfo);
-
- const std::string serverName = settings.serverName;
- std::string screenShortStr;
- if (prefix.empty())
- {
- if (serverName.empty())
- {
- screenShortStr = strprintf("%s_Screenshot_%s_",
- branding.getValue("appName", "ManaPlus").c_str(),
- buffer);
- }
- else
- {
- screenShortStr = strprintf("%s_Screenshot_%s_%s_",
- branding.getValue("appName", "ManaPlus").c_str(),
- serverName.c_str(), buffer);
- }
-
- bool found = false;
- static unsigned int screenshotCount = 0;
- do
- {
- screenshotCount++;
- filename.str("");
- filename << screenshotDirectory << "/";
- filename << screenShortStr << screenshotCount << ".png";
- testExists.open(filename.str().c_str(), std::ios::in);
- found = !testExists.is_open();
- testExists.close();
- }
- while (!found);
- }
- else
- {
- screenShortStr = prefix;
- filename.str("");
- filename << screenshotDirectory << "/";
- filename << screenShortStr;
- }
-
- const std::string fileNameStr = filename.str();
- const bool success = PngLib::writePNG(screenshot, fileNameStr);
-#ifdef __native_client__
- std::string nacScreenshotlDir = fileNameStr;
- cutFirst(nacScreenshotlDir, "/persistent");
- naclPostMessage("copy-from-persistent", nacScreenshotlDir);
- logger->log("nacl screenshot path: " + nacScreenshotlDir);
-#endif // __native_client__
-
- if (success)
- {
- if (localChatTab != nullptr)
- {
- // TRANSLATORS: save file message
- std::string str = strprintf(_("Screenshot saved as %s"),
- fileNameStr.c_str());
- localChatTab->chatLog(str, ChatMsgType::BY_SERVER);
- }
- }
- else
- {
- if (localChatTab != nullptr)
- {
- // TRANSLATORS: save file message
- localChatTab->chatLog(_("Saving screenshot failed!"),
- ChatMsgType::BY_SERVER);
- }
- logger->log1("Error: could not save screenshot.");
- }
-
- MSDL_FreeSurface(screenshot);
- return success;
-}
-
-void Game::logic()
-{
- BLOCK_START("Game::logic")
- handleInput();
-
- // Handle all necessary game logic
- if (actorManager != nullptr)
- actorManager->logic();
- if (particleEngine != nullptr)
- particleEngine->update();
- if (mCurrentMap != nullptr)
- mCurrentMap->update();
-
- BLOCK_END("Game::logic")
-}
-
-void Game::slowLogic()
-{
- BLOCK_START("Game::slowLogic")
- if (localPlayer != nullptr)
- localPlayer->slowLogic();
- const time_t time = cur_time;
- if (mTime != time)
- {
- if (valTest(Updated))
- mValidSpeed = false;
-
- mTime = time + 1;
- if (debugWindow != nullptr)
- debugWindow->slowLogic();
- if (killStats != nullptr)
- killStats->update();
- if (socialWindow != nullptr)
- socialWindow->slowLogic();
- if (whoIsOnline != nullptr)
- whoIsOnline->slowLogic();
- Being::reReadConfig();
- if (killStats != nullptr)
- cilk_spawn killStats->recalcStats();
-
- if (time > mTime2 || mTime2 - time > 10)
- {
- mTime2 = time + 10;
- config.writeUpdated();
- serverConfig.writeUpdated();
- }
- if (effectManager != nullptr)
- effectManager->logic();
- }
-
- if (mainGraphics->getOpenGL() != RENDER_SOFTWARE)
- DelayedManager::delayedLoad();
-
-#ifdef TMWA_SUPPORT
- if (shopWindow != nullptr)
- cilk_spawn shopWindow->updateTimes();
- if (guildManager != nullptr)
- guildManager->slowLogic();
-#endif // TMWA_SUPPORT
-
- if (skillDialog != nullptr)
- cilk_spawn skillDialog->slowLogic();
-
- cilk_spawn PacketCounters::update();
-
- // Handle network stuff
- if (!gameHandler->isConnected())
- {
- if (client->getState() == State::CHANGE_MAP)
- return; // Not a problem here
-
- if (client->getState() != State::ERROR)
- {
- if (disconnectedDialog == nullptr)
- {
- // TRANSLATORS: error message text
- errorMessage = _("The connection to the server was lost.");
- disconnectedDialog = DialogsManager::openErrorDialog(
- // TRANSLATORS: error message header
- _("Network Error"),
- errorMessage,
- Modal_false);
- disconnectedDialog->addActionListener(&errorListener);
- disconnectedDialog->requestMoveToTop();
- }
- }
-
- if ((viewport != nullptr) && !errorMessage.empty())
- {
- const Map *const map = viewport->getMap();
- if (map != nullptr)
- map->saveExtraLayer();
- }
- DialogsManager::closeDialogs();
- WindowManager::setFramerate(config.getIntValue("fpslimit"));
- mNextAdjustTime = cur_time + adjustDelay;
- if (client->getState() != State::ERROR)
- errorMessage.clear();
- }
- else
- {
- if (gameHandler->mustPing()
- && get_elapsed_time1(mPing) > 3000)
- {
- mPing = tick_time;
- gameHandler->ping(tick_time);
- }
-
- if (mAdjustPerfomance)
- adjustPerfomance();
- if (disconnectedDialog != nullptr)
- {
- disconnectedDialog->scheduleDelete();
- disconnectedDialog = nullptr;
- }
- }
- BLOCK_END("Game::slowLogic")
-}
-
-void Game::adjustPerfomance()
-{
- FUNC_BLOCK("Game::adjustPerfomance", 1)
- const time_t time = cur_time;
- if (mNextAdjustTime <= adjustDelay)
- {
- mNextAdjustTime = time + adjustDelay;
- }
- else if (mNextAdjustTime < time)
- {
- mNextAdjustTime = time + adjustDelay;
-
- if (mAdjustLevel > 3 ||
- localPlayer == nullptr ||
- localPlayer->getHalfAway() ||
- settings.awayMode)
- {
- return;
- }
-
- int maxFps = WindowManager::getFramerate();
- if (maxFps != config.getIntValue("fpslimit"))
- return;
-
- if (maxFps == 0)
- maxFps = 30;
- else if (maxFps < 10)
- return;
-
- if (fps < maxFps - 10)
- {
- if (mLowerCounter < 2)
- {
- mLowerCounter ++;
- mNextAdjustTime = cur_time + 1;
- return;
- }
- mLowerCounter = 0;
- mAdjustLevel ++;
- switch (mAdjustLevel)
- {
- case 1:
- {
- if (config.getBoolValue("beingopacity"))
- {
- config.setValue("beingopacity", false);
- config.setSilent("beingopacity", true);
- if (localChatTab != nullptr)
- {
- localChatTab->chatLog("Auto disable Show "
- "beings transparency", ChatMsgType::BY_SERVER);
- }
- }
- else
- {
- mNextAdjustTime = time + 1;
- mLowerCounter = 2;
- }
- break;
- }
- case 2:
- if (ParticleEngine::emitterSkip < 4)
- {
- ParticleEngine::emitterSkip = 4;
- if (localChatTab != nullptr)
- {
- localChatTab->chatLog("Auto lower Particle "
- "effects", ChatMsgType::BY_SERVER);
- }
- }
- else
- {
- mNextAdjustTime = time + 1;
- mLowerCounter = 2;
- }
- break;
- case 3:
- if (!config.getBoolValue("alphaCache"))
- {
- config.setValue("alphaCache", true);
- config.setSilent("alphaCache", false);
- if (localChatTab != nullptr)
- {
- localChatTab->chatLog("Auto enable opacity cache",
- ChatMsgType::BY_SERVER);
- }
- }
- break;
- default:
- break;
- }
- }
- }
-}
-
-void Game::resetAdjustLevel()
-{
- if (!mAdjustPerfomance)
- return;
-
- mNextAdjustTime = cur_time + adjustDelay;
- switch (mAdjustLevel)
- {
- case 1:
- config.setValue("beingopacity",
- config.getBoolValue("beingopacity"));
- break;
- case 2:
- config.setValue("beingopacity",
- config.getBoolValue("beingopacity"));
- ParticleEngine::emitterSkip = config.getIntValue(
- "particleEmitterSkip") + 1;
- break;
- default:
- case 3:
- config.setValue("beingopacity",
- config.getBoolValue("beingopacity"));
- ParticleEngine::emitterSkip = config.getIntValue(
- "particleEmitterSkip") + 1;
- config.setValue("alphaCache",
- config.getBoolValue("alphaCache"));
- break;
- }
- mAdjustLevel = 0;
-}
-
-void Game::handleMove()
-{
- BLOCK_START("Game::handleMove")
- if (localPlayer == nullptr)
- {
- BLOCK_END("Game::handleMove")
- return;
- }
-
- // Moving player around
- if ((chatWindow != nullptr) &&
- (quitDialog == nullptr) &&
- localPlayer->canMove() &&
- !chatWindow->isInputFocused() &&
- !InventoryWindow::isAnyInputFocused() &&
- !popupMenu->isPopupVisible())
- {
- NpcDialog *const dialog = NpcDialog::getActive();
- if (dialog != nullptr)
- {
- BLOCK_END("Game::handleMove")
- return;
- }
-
- // Ignore input if either "ignore" key is pressed
- // Stops the character moving about if the user's window manager
- // uses "ignore+arrow key" to switch virtual desktops.
- if (inputManager.isActionActive(InputAction::IGNORE_INPUT_1) ||
- inputManager.isActionActive(InputAction::IGNORE_INPUT_2))
- {
- BLOCK_END("Game::handleMove")
- return;
- }
-
- unsigned char direction = 0;
-
- // Translate pressed keys to movement and direction
- if (inputManager.isActionActive(InputAction::MOVE_UP) ||
- ((joystick != nullptr) && joystick->isUp()))
- {
- direction |= BeingDirection::UP;
- setValidSpeed();
- localPlayer->cancelFollow();
- }
- else if (inputManager.isActionActive(InputAction::MOVE_DOWN) ||
- ((joystick != nullptr) && joystick->isDown()))
- {
- direction |= BeingDirection::DOWN;
- setValidSpeed();
- localPlayer->cancelFollow();
- }
-
- if (inputManager.isActionActive(InputAction::MOVE_LEFT) ||
- ((joystick != nullptr) && joystick->isLeft()))
- {
- direction |= BeingDirection::LEFT;
- setValidSpeed();
- localPlayer->cancelFollow();
- }
- else if (inputManager.isActionActive(InputAction::MOVE_RIGHT) ||
- ((joystick != nullptr) && joystick->isRight()))
- {
- direction |= BeingDirection::RIGHT;
- setValidSpeed();
- localPlayer->cancelFollow();
- }
- else if (inputManager.isActionActive(InputAction::MOVE_FORWARD))
- {
- direction = localPlayer->getDirection();
- setValidSpeed();
- localPlayer->cancelFollow();
- }
-
- if ((!inputManager.isActionActive(InputAction::EMOTE)
- && !inputManager.isActionActive(InputAction::PET_EMOTE)
- && !inputManager.isActionActive(InputAction::HOMUN_EMOTE)
- && !inputManager.isActionActive(InputAction::STOP_ATTACK))
- || direction == 0)
- {
- moveInDirection(direction);
- }
- }
- BLOCK_END("Game::handleMove")
-}
-
-void Game::moveInDirection(const unsigned char direction)
-{
- if (viewport == nullptr)
- return;
-
- if (settings.cameraMode == 0u)
- {
- if (localPlayer != nullptr)
- localPlayer->specialMove(direction);
- }
- else
- {
- int dx = 0;
- int dy = 0;
- if ((direction & BeingDirection::LEFT) != 0)
- dx = -5;
- else if ((direction & BeingDirection::RIGHT) != 0)
- dx = 5;
-
- if ((direction & BeingDirection::UP) != 0)
- dy = -5;
- else if ((direction & BeingDirection::DOWN) != 0)
- dy = 5;
- viewport->moveCamera(dx, dy);
- }
-}
-
-void Game::updateFrameRate(int fpsLimit)
-{
- if (fpsLimit == 0)
- {
- if (settings.awayMode)
- {
- if (settings.inputFocused != KeyboardFocus::Unfocused ||
- settings.mouseFocused)
- {
- fpsLimit = config.getIntValue("fpslimit");
- }
- else
- {
- fpsLimit = config.getIntValue("altfpslimit");
- }
- }
- else
- {
- fpsLimit = config.getIntValue("fpslimit");
- }
- }
- WindowManager::setFramerate(fpsLimit);
- mNextAdjustTime = cur_time + adjustDelay;
-}
-
-/**
- * The huge input handling method.
- */
-void Game::handleInput()
-{
- BLOCK_START("Game::handleInput 1")
- if (joystick != nullptr)
- joystick->logic();
-
- eventsManager.handleGameEvents();
-
- // If the user is configuring the keys then don't respond.
- if (!keyboard.isEnabled() || settings.awayMode)
- {
- BLOCK_END("Game::handleInput 1")
- return;
- }
-
- // If pressed outfits keys, stop processing keys.
- if (inputManager.isActionActive(InputAction::WEAR_OUTFIT)
- || inputManager.isActionActive(InputAction::COPY_OUTFIT)
- || ((setupWindow != nullptr) && setupWindow->isWindowVisible()))
- {
- BLOCK_END("Game::handleInput 1")
- return;
- }
-
- handleMove();
- InputManager::handleRepeat();
- BLOCK_END("Game::handleInput 1")
-}
-
-/**
- * Changes the currently active map. Should only be called while the game is
- * running.
- */
-void Game::changeMap(const std::string &mapPath)
-{
- BLOCK_START("Game::changeMap")
-
- resetAdjustLevel();
- ResourceManager::cleanProtected();
-
- PopupManager::clearPopup();
- PopupManager::closePopupMenu();
-
- // Clean up floor items, beings and particles
- if (actorManager != nullptr)
- actorManager->clear();
-
- // Close the popup menu on map change so that invalid options can't be
- // executed.
- if (viewport != nullptr)
- viewport->cleanHoverItems();
-
- // Unset the map of the player so that its particles are cleared before
- // being deleted in the next step
- if (localPlayer != nullptr)
- localPlayer->setMap(nullptr);
-
- if (particleEngine != nullptr)
- particleEngine->clear();
-
- mMapName = mapPath;
-
- std::string fullMap = pathJoin(paths.getValue("maps", "maps/"),
- mMapName).append(".tmx");
- std::string realFullMap = pathJoin(paths.getValue("maps", "maps/"),
- MapDB::getMapName(mMapName)).append(".tmx");
-
- if (!VirtFs::exists(realFullMap))
- realFullMap.append(".gz");
-
- // Attempt to load the new map
- Map *const newMap = MapReader::readMap(fullMap, realFullMap);
-
- if (mCurrentMap != nullptr)
- mCurrentMap->saveExtraLayer();
-
- if (newMap != nullptr)
- newMap->addExtraLayer();
-
- if (socialWindow != nullptr)
- socialWindow->setMap(newMap);
-
- // Notify the minimap and actorManager about the map change
- if (minimap != nullptr)
- minimap->setMap(newMap);
- if (actorManager != nullptr)
- actorManager->setMap(newMap);
- if (particleEngine != nullptr)
- particleEngine->setMap(newMap);
- if (viewport != nullptr)
- viewport->setMap(newMap);
-
- // Initialize map-based particle effects
- if (newMap != nullptr)
- newMap->initializeParticleEffects();
-
- // Start playing new music file when necessary
- const std::string oldMusic = mCurrentMap != nullptr
- ? mCurrentMap->getMusicFile() : "";
- const std::string newMusic = newMap != nullptr ?
- newMap->getMusicFile() : "";
- if (newMusic != oldMusic)
- {
- if (newMusic.empty())
- soundManager.fadeOutMusic();
- else
- soundManager.fadeOutAndPlayMusic(newMusic);
- }
-
- if (mCurrentMap != nullptr)
- mCurrentMap->saveExtraLayer();
-
- delete mCurrentMap;
- mCurrentMap = newMap;
-
- if (questsWindow != nullptr)
- questsWindow->setMap(mCurrentMap);
-
-#ifdef USE_MUMBLE
- if (mumbleManager)
- mumbleManager->setMap(mapPath);
-#endif // USE_MUMBLE
-
- if (localPlayer != nullptr)
- localPlayer->recreateItemParticles();
-
- gameHandler->mapLoadedEvent();
- BLOCK_END("Game::changeMap")
-}
-
-void Game::updateHistory(const SDL_Event &event)
-{
- if ((localPlayer == nullptr) || (settings.attackType == 0u))
- return;
-
- if (CAST_S32(event.key.keysym.sym) != -1)
- {
- bool old = false;
-
- const InputActionT key = KeyboardConfig::getKeyIndex(event);
- const time_t time = cur_time;
- int idx = -1;
- for (int f = 0; f < MAX_LASTKEYS; f ++)
- {
- LastKey &lastKey = mLastKeys[f];
- if (lastKey.key == key)
- {
- idx = f;
- old = true;
- break;
- }
- else if (idx >= 0 && lastKey.time < mLastKeys[idx].time)
- {
- idx = f;
- }
- }
- if (idx < 0)
- {
- idx = 0;
- for (int f = 0; f < MAX_LASTKEYS; f ++)
- {
- LastKey &lastKey = mLastKeys[f];
- if (lastKey.key == InputAction::NO_VALUE ||
- lastKey.time < mLastKeys[idx].time)
- {
- idx = f;
- }
- }
- }
-
- if (idx < 0)
- idx = 0;
-
- LastKey &keyIdx = mLastKeys[idx];
- if (!old)
- {
- keyIdx.time = time;
- keyIdx.key = key;
- keyIdx.cnt = 0;
- }
- else
- {
- keyIdx.cnt++;
- }
- }
-}
-
-void Game::checkKeys()
-{
- const int timeRange = 120;
- const int cntInTime = 130;
-
- if ((localPlayer == nullptr) || (settings.attackType == 0u))
- return;
-
- const time_t time = cur_time;
- for (int f = 0; f < MAX_LASTKEYS; f ++)
- {
- LastKey &lastKey = mLastKeys[f];
- if (lastKey.key != InputAction::NO_VALUE)
- {
- if (lastKey.time + timeRange < time)
- {
- if (lastKey.cnt > cntInTime)
- mValidSpeed = false;
- lastKey.key = InputAction::NO_VALUE;
- }
- }
- }
-}
-
-void Game::setValidSpeed()
-{
- clearKeysArray();
- mValidSpeed = true;
-}
-
-void Game::clearKeysArray()
-{
- for (int f = 0; f < MAX_LASTKEYS; f ++)
- {
- mLastKeys[f].time = 0;
- mLastKeys[f].key = InputAction::NO_VALUE;
- mLastKeys[f].cnt = 0;
- }
-}
-
-void Game::videoResized(const int width, const int height)
-{
- if (viewport != nullptr)
- viewport->setSize(width, height);
- if (windowMenu != nullptr)
- windowMenu->setPosition(width - windowMenu->getWidth(), 0);
-}
diff --git a/src/game.h b/src/game.h
deleted file mode 100644
index 53b417a5d..000000000
--- a/src/game.h
+++ /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/>.
- */
-
-#ifndef GAME_H
-#define GAME_H
-
-#include "enums/input/inputaction.h"
-
-#include <string>
-
-#include "localconsts.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_events.h>
-PRAGMA48(GCC diagnostic pop)
-
-static const int MAX_LASTKEYS = 10;
-
-extern volatile time_t cur_time;
-
-class Map;
-
-struct LastKey final
-{
- A_DELETE_COPY(LastKey)
-
- LastKey() :
- time(0),
- key(InputAction::NO_VALUE),
- cnt(0)
- { }
-
- time_t time;
- InputActionT key;
- int cnt;
-};
-
-/**
- * The main class responsible for running the game. The game starts after you
- * have selected your character.
- */
-class Game final
-{
- public:
- /**
- * Constructs the game, creating all the managers, handlers, engines
- * and GUI windows that make up the game.
- */
- Game();
-
- A_DELETE_COPY(Game)
-
- /**
- * Destructor, cleans up the game.
- */
- ~Game();
-
- /**
- * Provides access to the game instance.
- */
- static Game *instance() A_WARN_UNUSED
- { return mInstance; }
-
- constexpr2 static void clearInstance() noexcept2
- { mInstance = nullptr; }
-
- /**
- * This method takes the game a small step further. It is called 100
- * times per second.
- */
- void logic();
-
- void slowLogic();
-
- void handleInput();
-
- void handleMove();
-
- void changeMap(const std::string &mapName);
-
- void updateFrameRate(int fpsLimit);
-
- /**
- * Returns the currently active map.
- */
- Map *getCurrentMap() const noexcept2 A_WARN_UNUSED
- { return mCurrentMap; }
-
- const std::string &getCurrentMapName() const noexcept2 A_WARN_UNUSED
- { return mMapName; }
-
- void setValidSpeed();
-
- void adjustPerfomance();
-
- void resetAdjustLevel();
-
- void setAdjustLevel(const int n)
- { mAdjustLevel = n; }
-
- static void videoResized(const int width, const int height);
-
- bool getValidSpeed() const noexcept2 A_WARN_UNUSED
- { return mValidSpeed; }
-
- static void moveInDirection(const unsigned char direction);
-
- static bool createScreenshot(const std::string &prefix);
-
- static void addWatermark();
-
- static bool saveScreenshot(SDL_Surface *const screenshot,
- const std::string &prefix);
-
- void updateHistory(const SDL_Event &event);
-
- void checkKeys();
-
- private:
- void clearKeysArray();
-
- Map *mCurrentMap;
- std::string mMapName;
- bool mValidSpeed;
- LastKey mLastKeys[MAX_LASTKEYS];
- time_t mNextAdjustTime;
- int mAdjustLevel;
- bool mAdjustPerfomance;
- int mLowerCounter;
- int mPing;
- time_t mTime;
- time_t mTime2;
-
- static Game *mInstance;
-};
-
-extern bool mStatsReUpdated;
-
-#endif // GAME_H
diff --git a/src/gamemodifiers.cpp b/src/gamemodifiers.cpp
deleted file mode 100644
index bed509dae..000000000
--- a/src/gamemodifiers.cpp
+++ /dev/null
@@ -1,517 +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 "gamemodifiers.h"
-
-#include "configuration.h"
-#include "game.h"
-#include "settings.h"
-#include "soundmanager.h"
-
-#include "being/localplayer.h"
-
-#include "gui/viewport.h"
-
-#include "gui/windows/chatwindow.h"
-#include "gui/windows/okdialog.h"
-#include "gui/windows/outfitwindow.h"
-
-#include "gui/widgets/createwidget.h"
-
-#include "gui/widgets/tabs/chat/chattab.h"
-
-#include "listeners/gamemodifierlistener.h"
-
-#include "resources/map/map.h"
-
-#include "listeners/awaylistener.h"
-#include "listeners/updatestatuslistener.h"
-
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-#define addModifier(name1, name2, sz, ...) \
- const unsigned GameModifiers::m##name1##Size = sz; \
- const char *const GameModifiers::m##name1##Strings[] = \
- __VA_ARGS__; \
- std::string GameModifiers::get##name1##String() \
- { \
- return gettext(getVarItem(&m##name1##Strings[0], \
- CAST_U32(settings.name2), m##name1##Size)); \
- }
-
-#define addModifier2(name1, name2, str, sz, ...) \
- const unsigned GameModifiers::m##name1##Size = sz; \
- const char *const GameModifiers::m##name1##Strings[] = \
- __VA_ARGS__; \
- void GameModifiers::change##name1(const bool forward) \
- { \
- changeMode(&settings.name2, m##name1##Size, str, \
- &GameModifiers::get##name1##String, 0, true, forward); \
- } \
- std::string GameModifiers::get##name1##String() \
- { \
- return gettext(getVarItem(&m##name1##Strings[0], \
- settings.name2, m##name1##Size)); \
- }
-
-#define changeMethod(name1, name2, str) \
- void GameModifiers::change##name1(const bool forward) \
- { \
- changeMode(&settings.name2, m##name1##Size, str, \
- &GameModifiers::get##name1##String, 0, true, forward); \
- }
-
-void GameModifiers::init()
-{
- settings.crazyMoveType = config.getIntValue("crazyMoveType");
- settings.moveToTargetType = config.getIntValue("moveToTargetType");
- settings.followMode = config.getIntValue("followMode");
- settings.attackWeaponType = config.getIntValue("attackWeaponType");
- settings.attackType = config.getIntValue("attackType");
- settings.targetingType = config.getIntValue("targetingType");
- settings.quickDropCounter = config.getIntValue("quickDropCounter");
- settings.pickUpType = config.getIntValue("pickUpType");
- settings.magicAttackType = config.getIntValue("magicAttackType");
- settings.pvpAttackType = config.getIntValue("pvpAttackType");
- settings.imitationMode = config.getIntValue("imitationMode");
- settings.disableGameModifiers = config.getBoolValue(
- "disableGameModifiers");
- settings.awayMode = false;
- settings.mapDrawType = MapType::NORMAL;
-// UpdateStatusListener::distributeEvent();
-}
-
-void GameModifiers::changeMode(unsigned *restrict const var,
- const unsigned limit,
- const char *restrict const conf,
- std::string (*const func)(),
- const unsigned def,
- const bool save,
- const bool forward)
-{
- if (var == nullptr)
- return;
-
- if (forward)
- {
- (*var) ++;
- if (*var >= limit)
- *var = def;
- }
- else
- {
- if (*var == 0u)
- *var = limit - 1;
- else
- (*var) --;
- }
-
- if (save)
- config.setValue(conf, *var);
- UpdateStatusListener::distributeEvent();
- GameModifierListener::distributeEvent();
- const std::string str = (*func)();
- if (str.size() > 4)
- debugMsg(str.substr(4));
-}
-
-const char *GameModifiers::getVarItem(const char *const *const arr,
- const unsigned index,
- const unsigned sz)
-{
- if (index < sz)
- return arr[index];
- return arr[sz];
-}
-
-addModifier(MoveType, moveType, 5,
-{
- // TRANSLATORS: move type in status bar
- N_("(D) default moves"),
- // TRANSLATORS: move type in status bar
- N_("(I) invert moves"),
- // TRANSLATORS: move type in status bar
- N_("(c) moves with some crazy moves"),
- // TRANSLATORS: move type in status bar
- N_("(C) moves with crazy moves"),
- // TRANSLATORS: move type in status bar
- N_("(d) double normal + crazy"),
- // TRANSLATORS: move type in status bar
- N_("(?) unknown move")
-})
-
-void GameModifiers::changeMoveType(const bool forward)
-{
- localPlayer->setMoveState(0);
- changeMode(&settings.moveType, mMoveTypeSize, "invertMoveDirection",
- &GameModifiers::getMoveTypeString, 0, false, forward);
-}
-
-const unsigned GameModifiers::mCrazyMoveTypeSize = 11;
-
-void GameModifiers::changeCrazyMoveType(const bool forward)
-{
- settings.crazyMoveState = 0U;
- changeMode(&settings.crazyMoveType, mCrazyMoveTypeSize, "crazyMoveType",
- &GameModifiers::getCrazyMoveTypeString, 1, true, forward);
-}
-
-std::string GameModifiers::getCrazyMoveTypeString()
-{
- const unsigned int crazyMoveType = settings.crazyMoveType;
- if (crazyMoveType < mCrazyMoveTypeSize - 1)
- {
- // TRANSLATORS: crazy move type in status bar
- return strprintf(_("(%u) crazy move number %u"),
- crazyMoveType, crazyMoveType);
- }
- else if (crazyMoveType == mCrazyMoveTypeSize - 1)
- {
- // TRANSLATORS: crazy move type in status bar
- return _("(a) custom crazy move");
- }
- else
- {
- // TRANSLATORS: crazy move type in status bar
- return _("(?) crazy move");
- }
-}
-
-addModifier2(MoveToTargetType, moveToTargetType, "moveToTargetType", 13,
-{
- // TRANSLATORS: move to target type in status bar
- N_("(0) default moves to target"),
- // TRANSLATORS: move to target type in status bar
- N_("(1) moves to target in distance 1"),
- // TRANSLATORS: move to target type in status bar
- N_("(2) moves to target in distance 2"),
- // TRANSLATORS: move to target type in status bar
- N_("(3) moves to target in distance 3"),
- // TRANSLATORS: move to target type in status bar
- N_("(4) moves to target in distance 4"),
- // TRANSLATORS: move to target type in status bar
- N_("(5) moves to target in distance 5"),
- // TRANSLATORS: move to target type in status bar
- N_("(6) moves to target in distance 6"),
- // TRANSLATORS: move to target type in status bar
- N_("(7) moves to target in distance 7"),
- // TRANSLATORS: move to target type in status bar
- N_("(8) moves to target in distance 8"),
- // TRANSLATORS: move to target type in status bar
- N_("(9) moves to target in distance 9"),
- // TRANSLATORS: move to target type in status bar
- N_("(A) moves to target in attack range"),
- // TRANSLATORS: move to target type in status bar
- N_("(a) archer attack range"),
- // TRANSLATORS: move to target type in status bar
- N_("(B) moves to target in attack range - 1"),
- // TRANSLATORS: move to target type in status bar
- N_("(?) move to target")
-})
-
-addModifier2(FollowMode, followMode, "followMode", 4,
-{
- // TRANSLATORS: folow mode in status bar
- N_("(D) default follow"),
- // TRANSLATORS: folow mode in status bar
- N_("(R) relative follow"),
- // TRANSLATORS: folow mode in status bar
- N_("(M) mirror follow"),
- // TRANSLATORS: folow mode in status bar
- N_("(P) pet follow"),
- // TRANSLATORS: folow mode in status bar
- N_("(?) unknown follow")
-})
-
-addModifier2(AttackWeaponType, attackWeaponType, "attackWeaponType", 4,
-{
- // TRANSLATORS: switch attack type in status bar
- N_("(?) attack"),
- // TRANSLATORS: switch attack type in status bar
- N_("(D) default attack"),
- // TRANSLATORS: switch attack type in status bar
- N_("(s) switch attack without shield"),
- // TRANSLATORS: switch attack type in status bar
- N_("(S) switch attack with shield"),
- // TRANSLATORS: switch attack type in status bar
- N_("(?) attack")
-})
-
-addModifier2(AttackType, attackType, "attackType", 4,
-{
- // TRANSLATORS: attack type in status bar
- N_("(D) default attack"),
- // TRANSLATORS: attack type in status bar
- N_("(G) go and attack"),
- // TRANSLATORS: attack type in status bar
- N_("(A) go, attack, pickup"),
- // TRANSLATORS: attack type in status bar
- N_("(d) without auto attack"),
- // TRANSLATORS: attack type in status bar
- N_("(?) attack")
-})
-
-addModifier2(TargetingType, targetingType, "targetingType", 2,
-{
- // TRANSLATORS: targeting type in status bar
- N_("(D) don't switch target"),
- // TRANSLATORS: targeting type in status bar
- N_("(C) always attack closest"),
- // TRANSLATORS: targeting type in status bar
- N_("(?) targeting")
-})
-
-const unsigned GameModifiers::mQuickDropCounterSize = 31;
-
-changeMethod(QuickDropCounter, quickDropCounter, "quickDropCounter")
-
-std::string GameModifiers::getQuickDropCounterString()
-{
- const unsigned int cnt = settings.quickDropCounter;
- if (cnt > 9)
- {
- return strprintf("(%c) drop counter %u", CAST_S8(
- 'a' + cnt - 10), cnt);
- }
- return strprintf("(%u) drop counter %u", cnt, cnt);
-}
-
-void GameModifiers::setQuickDropCounter(const int n)
-{
- if (n < 1 || n >= CAST_S32(mQuickDropCounterSize))
- return;
- settings.quickDropCounter = n;
- config.setValue("quickDropCounter", n);
- UpdateStatusListener::distributeEvent();
- GameModifierListener::distributeEvent();
-}
-
-addModifier2(PickUpType, pickUpType, "pickUpType", 7,
-{
- // TRANSLATORS: pickup size in status bar
- N_("(S) small pick up 1x1 cells"),
- // TRANSLATORS: pickup size in status bar
- N_("(D) default pick up 2x1 cells"),
- // TRANSLATORS: pickup size in status bar
- N_("(F) forward pick up 2x3 cells"),
- // TRANSLATORS: pickup size in status bar
- N_("(3) pick up 3x3 cells"),
- // TRANSLATORS: pickup size in status bar
- N_("(g) go and pick up in distance 4"),
- // TRANSLATORS: pickup size in status bar
- N_("(G) go and pick up in distance 8"),
- // TRANSLATORS: pickup size in status bar
- N_("(A) go and pick up in max distance"),
- // TRANSLATORS: pickup size in status bar
- N_("(?) pick up")
-})
-
-addModifier2(MagicAttackType, magicAttackType, "magicAttackType", 5,
-{
- // TRANSLATORS: magic attack in status bar
- N_("(f) use #flar for magic attack"),
- // TRANSLATORS: magic attack in status bar
- N_("(c) use #chiza for magic attack"),
- // TRANSLATORS: magic attack in status bar
- N_("(I) use #ingrav for magic attack"),
- // TRANSLATORS: magic attack in status bar
- N_("(F) use #frillyar for magic attack"),
- // TRANSLATORS: magic attack in status bar
- N_("(U) use #upmarmu for magic attack"),
- // TRANSLATORS: magic attack in status bar
- N_("(?) magic attack")
-})
-
-addModifier2(PvpAttackType, pvpAttackType, "pvpAttackType", 4,
-{
- // TRANSLATORS: player attack type in status bar
- N_("(a) attack all players"),
- // TRANSLATORS: player attack type in status bar
- N_("(f) attack all except friends"),
- // TRANSLATORS: player attack type in status bar
- N_("(b) attack bad relations"),
- // TRANSLATORS: player attack type in status bar
- N_("(d) don't attack players"),
- // TRANSLATORS: player attack type in status bar
- N_("(?) pvp attack")
-})
-
-addModifier2(ImitationMode, imitationMode, "imitationMode", 2,
-{
- // TRANSLATORS: imitation type in status bar
- N_("(D) default imitation"),
- // TRANSLATORS: imitation type in status bar
- N_("(O) outfits imitation"),
- // TRANSLATORS: imitation type in status bar
- N_("(?) imitation")
-})
-
-addModifier(GameModifiers, disableGameModifiers, 2,
-{
- // TRANSLATORS: game modifiers state in status bar
- N_("Game modifiers are enabled"),
- // TRANSLATORS: game modifiers state in status bar
- N_("Game modifiers are disabled"),
- // TRANSLATORS: game modifiers state in status bar
- N_("Game modifiers are unknown")
-})
-
-void GameModifiers::changeGameModifiers(const bool forward A_UNUSED)
-{
- settings.disableGameModifiers = !settings.disableGameModifiers;
- config.setValue("disableGameModifiers", settings.disableGameModifiers);
- UpdateStatusListener::distributeEvent();
- GameModifierListener::distributeEvent();
-}
-
-addModifier(MapDrawType, mapDrawType, 7,
-{
- // TRANSLATORS: map view type in status bar
- N_("(N) normal map view"),
- // TRANSLATORS: map view type in status bar
- N_("(D) debug map view"),
- // TRANSLATORS: map view type in status bar
- N_("(u) ultra map view"),
- // TRANSLATORS: map view type in status bar
- N_("(U) ultra map view 2"),
- // TRANSLATORS: map view type in status bar
- N_("(e) empty map view with collision"),
- // TRANSLATORS: map view type in status bar
- N_("(E) empty map view"),
- // TRANSLATORS: map view type in status bar
- N_("(b) black & white map view"),
- // TRANSLATORS: pickup size in status bar
- N_("(?) map view")
-})
-
-void GameModifiers::changeMapDrawType(const bool forward A_UNUSED)
-{
- if (viewport != nullptr)
- viewport->toggleMapDrawType();
-}
-
-addModifier(AwayMode, awayMode, 2,
-{
- // TRANSLATORS: away type in status bar
- N_("(O) on keyboard"),
- // TRANSLATORS: away type in status bar
- N_("(A) away"),
- // TRANSLATORS: away type in status bar
- N_("(?) away")
-})
-
-void GameModifiers::changeAwayMode(const bool forward A_UNUSED)
-{
- if (localPlayer == nullptr)
- return;
-
- settings.awayMode = !settings.awayMode;
- localPlayer->setAfkTime(0);
- localPlayer->setHalfAway(false);
- localPlayer->updateName();
- Game::instance()->updateFrameRate(0);
- UpdateStatusListener::distributeEvent();
- GameModifierListener::distributeEvent();
- if (settings.awayMode)
- {
- if (chatWindow != nullptr)
- chatWindow->clearAwayLog();
-
- localPlayer->cancelFollow();
- localPlayer->navigateClean();
- if (outfitWindow != nullptr)
- outfitWindow->wearAwayOutfit();
- OkDialog *const dialog = CREATEWIDGETR(OkDialog,
- // TRANSLATORS: away message box header
- _("Away"),
- serverConfig.getValue("afkMessage", "I am away from keyboard."),
- // TRANSLATORS: ok dialog button
- _("OK"),
- DialogType::SILENCE,
- Modal_true,
- ShowCenter_false,
- nullptr,
- 260);
- localPlayer->setAwayDialog(dialog);
- dialog->addActionListener(localPlayer->getAwayListener());
- soundManager.volumeOff();
- localPlayer->addAfkEffect();
- }
- else
- {
- localPlayer->setAwayDialog(nullptr);
- soundManager.volumeRestore();
- if (chatWindow != nullptr)
- {
- chatWindow->displayAwayLog();
- chatWindow->clearAwayLog();
- }
- localPlayer->removeAfkEffect();
- }
-}
-
-addModifier(CameraMode, cameraMode, 2,
-{
- // TRANSLATORS: camera mode in status bar
- N_("(G) game camera mode"),
- // TRANSLATORS: camera mode in status bar
- N_("(F) free camera mode"),
- // TRANSLATORS: camera mode in status bar
- N_("(?) away")
-})
-
-
-void GameModifiers::changeCameraMode(const bool forward A_UNUSED)
-{
- if (viewport != nullptr)
- viewport->toggleCameraMode();
-}
-
-void GameModifiers::resetModifiers()
-{
- settings.moveType = 0;
- settings.crazyMoveType = config.resetIntValue("crazyMoveType");
- settings.moveToTargetType = config.resetIntValue("moveToTargetType");
- settings.followMode = config.resetIntValue("followMode");
- settings.attackWeaponType = config.resetIntValue("attackWeaponType");
- settings.attackType = config.resetIntValue("attackType");
- settings.magicAttackType = config.resetIntValue("magicAttackType");
- settings.pvpAttackType = config.resetIntValue("pvpAttackType");
- settings.quickDropCounter = config.resetIntValue("quickDropCounter");
- settings.pickUpType = config.resetIntValue("pickUpType");
- settings.targetingType = config.resetIntValue("targetingType");
- settings.mapDrawType = MapType::NORMAL;
- if (viewport != nullptr)
- {
- if (settings.cameraMode != 0u)
- viewport->toggleCameraMode();
- Map *const map = viewport->getMap();
- if (map != nullptr)
- map->setDrawLayersFlags(MapType::NORMAL);
- }
- settings.imitationMode = config.resetIntValue("imitationMode");
- settings.disableGameModifiers = config.resetBoolValue(
- "disableGameModifiers");
-
- UpdateStatusListener::distributeEvent();
- GameModifierListener::distributeEvent();
-}
diff --git a/src/gamemodifiers.h b/src/gamemodifiers.h
deleted file mode 100644
index 3730b9e13..000000000
--- a/src/gamemodifiers.h
+++ /dev/null
@@ -1,79 +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 GAMEMODIFIERS_H
-#define GAMEMODIFIERS_H
-
-#include <string>
-
-#include "localconsts.h"
-
-#define declModifier(name1) \
- static void change##name1(const bool forward); \
- static std::string get##name1##String(); \
- static const unsigned m##name1##Size; \
- static const char *const m##name1##Strings[];
-
-class GameModifiers final
-{
- public:
- A_DELETE_COPY(GameModifiers)
-
- static void init();
-
- static void changeMode(unsigned *restrict const var,
- const unsigned limit,
- const char *restrict const conf,
- std::string (*const func)(),
- const unsigned def,
- const bool save,
- const bool forward);
-
- declModifier(MoveType)
- declModifier(CrazyMoveType)
- declModifier(MoveToTargetType)
- declModifier(FollowMode)
- declModifier(AttackWeaponType)
- declModifier(AttackType)
- declModifier(TargetingType)
- declModifier(QuickDropCounter)
- declModifier(PickUpType)
- declModifier(MagicAttackType)
- declModifier(PvpAttackType)
- declModifier(ImitationMode)
- declModifier(GameModifiers)
- declModifier(MapDrawType)
- declModifier(CameraMode)
- declModifier(AwayMode)
-
- static void setQuickDropCounter(const int n);
-
- static void resetModifiers();
-
- protected:
- static const char *getVarItem(const char *const *const arr,
- const unsigned index,
- const unsigned sz)
- A_WARN_UNUSED A_NONNULL(1);
-};
-
-#undef declModifier
-
-#endif // GAMEMODIFIERS_H
diff --git a/src/graphicsmanager.cpp b/src/graphicsmanager.cpp
deleted file mode 100644
index 108facc73..000000000
--- a/src/graphicsmanager.cpp
+++ /dev/null
@@ -1,1724 +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 "graphicsmanager.h"
-
-#ifdef USE_OPENGL
-#ifndef WIN32
-
-#ifdef ANDROID
-#include <GLES2/gl2.h>
-#include <GLES/glext.h>
-#include <EGL/egl.h>
-
-#ifndef USE_SDL2
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_android.h>
-PRAGMA48(GCC diagnostic pop)
-#endif // USE_SDL2
-#elif defined(__native_client__)
-#include <GL/Regal.h>
-#include "render/opengl/naclglfunctions.h"
-#else // ANDROID
-#ifdef USE_X11
-#include <GL/glx.h>
-#endif // USE_X11
-#endif // ANDROID
-#endif // WIN32
-#endif // USE_OPENGL
-
-#include "settings.h"
-
-#ifdef USE_OPENGL
-#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 "render/opengl/mglemu.h"
-#endif // USE_OPENGL
-
-#include "render/sdlgraphics.h"
-
-#ifdef USE_OPENGL
-#include "resources/openglimagehelper.h"
-#include "resources/openglscreenshothelper.h"
-#ifndef ANDROID
-#include "resources/mobileopenglscreenshothelper.h"
-#include "resources/safeopenglimagehelper.h"
-#endif // ANDROID
-#include "render/opengl/mglfunctions.h"
-#endif // USE_OPENGL
-
-#include "resources/sdlimagehelper.h"
-#include "resources/sdlscreenshothelper.h"
-
-#ifdef USE_SDL2
-#include "render/sdl2softwaregraphics.h"
-
-#include "resources/sdl2softwareimagehelper.h"
-#include "resources/sdl2softwarescreenshothelper.h"
-#include "resources/surfaceimagehelper.h"
-#endif // USE_SDL2
-
-#include "utils/delete2.h"
-#include "utils/sdlhelper.h"
-
-#ifdef USE_OPENGL
-#include "test/testmain.h"
-#else // USE_OPENGL
-#include "configuration.h"
-
-#include "render/renderers.h"
-#endif // USE_OPENGL
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_syswm.h>
-PRAGMA48(GCC diagnostic pop)
-
-#include "debug.h"
-
-#ifdef USE_OPENGL
-#ifndef GL_MAX_RENDERBUFFER_SIZE
-#define GL_MAX_RENDERBUFFER_SIZE 0x84E8
-#endif // GL_MAX_RENDERBUFFER_SIZE
-#define useCompression(name) \
- OpenGLImageHelper::setInternalTextureType(name); \
- logger->log("using " #name " texture compression");
-#endif // USE_OPENGL
-
-GraphicsManager graphicsManager;
-
-RenderType openGLMode = RENDER_SOFTWARE;
-
-ScreenshotHelper *screenshortHelper = nullptr;
-
-const int densitySize = 6;
-
-const std::string densityNames[] =
-{
- "low",
- "medium",
- "tv",
- "high",
- "xhigh",
- "xxhigh"
-};
-
-#ifdef USE_OPENGL
-GLenum GraphicsManager::mLastError(GL_NO_ERROR);
-#endif // USE_OPENGL
-
-GraphicsManager::GraphicsManager() :
- mExtensions(),
- mPlatformExtensions(),
- mGlVersionString(),
- mGlVendor(),
- mGlRenderer(),
- mGlShaderVersionString(),
- mMinor(0),
- mMajor(0),
- mSLMinor(0),
- mSLMajor(0),
- mPlatformMinor(0),
- mPlatformMajor(0),
- mMaxVertices(500),
- mMaxFboSize(0),
- mMaxWidth(0),
- mMaxHeight(0),
- mWidthMM(0),
- mHeightMM(0),
- mDensity(-1),
-#ifdef USE_OPENGL
- mUseTextureSampler(true),
- mTextureSampler(0),
- mSupportDebug(0),
- mSupportModernOpengl(false),
- mGles(false),
-#endif // USE_OPENGL
- mUseAtlases(false)
-{
-}
-
-GraphicsManager::~GraphicsManager()
-{
-#ifdef USE_OPENGL
- if (isGLNotNull(mglGenSamplers) && mTextureSampler)
- mglDeleteSamplers(1, &mTextureSampler);
-#endif // USE_OPENGL
-}
-
-#ifdef USE_OPENGL
-TestMain *GraphicsManager::startDetection()
-{
- TestMain *const test = new TestMain;
- test->exec(false);
- return test;
-}
-
-int GraphicsManager::detectGraphics()
-{
- logger->log1("start detecting best mode...");
- logger->log1("enable opengl mode");
- int textureSampler = 0;
- int compressTextures = 0;
-#if !defined(ANDROID) && !defined(__native_client__)
- mainGraphics = new NormalOpenGLGraphics;
-#endif // !defined(ANDROID) && !defined(__native_client__)
-
- SDL_Window *const window = createWindow(100, 100, 0,
- SDL_ANYFORMAT | SDL_OPENGL);
- mainGraphics->setWindow(window, 100, 100);
- mainGraphics->createGLContext(false);
-
- initOpenGL();
- logVersion();
-
- RenderType mode = RENDER_NORMAL_OPENGL;
-
- // detecting features by known renderers or vendors
- if (findI(mGlRenderer, "gdi generic") != std::string::npos)
- {
- // windows gdi OpenGL emulation
- logger->log("detected gdi drawing");
- logger->log("disable OpenGL");
- mode = RENDER_SOFTWARE;
- }
- else if (findI(mGlRenderer, "Software Rasterizer") != std::string::npos)
- {
- // software OpenGL emulation
- logger->log("detected software drawing");
- logger->log("disable OpenGL");
- mode = RENDER_SOFTWARE;
- }
- else if (findI(mGlRenderer, "Indirect") != std::string::npos)
- {
- // indirect OpenGL drawing
- logger->log("detected indirect drawing");
- logger->log("disable OpenGL");
- mode = RENDER_SOFTWARE;
- }
- else if (findI(mGlVendor, "VMWARE") != std::string::npos)
- {
- // vmware emulation
- logger->log("detected VMWARE driver");
- logger->log("disable OpenGL");
- mode = RENDER_SOFTWARE;
- }
- else if (findI(mGlVendor, "NVIDIA") != std::string::npos)
- {
- // hope it can work well
- logger->log("detected NVIDIA driver");
- config.setValue("useTextureSampler", true);
- textureSampler = 1;
- mode = RENDER_NORMAL_OPENGL;
- }
-
- // detecting feature based on OpenGL version
- if (!checkGLVersion(1, 1))
- {
- // very old OpenGL version
- logger->log("OpenGL version too old");
- mode = RENDER_SOFTWARE;
- }
-
- if (mode != RENDER_SOFTWARE && findI(mGlVersionString, "Mesa")
- != std::string::npos)
- {
- // Mesa detected. In latest Mesa look like compression broken.
- config.setValue("compresstextures", false);
- compressTextures = 0;
- }
-
- config.setValue("opengl", CAST_S32(mode));
- config.setValue("videoconfigured", true);
- config.write();
-
- logger->log("detection complete");
- return CAST_U32(mode)
- | (1024 * textureSampler) | (2048 * compressTextures);
-}
-
-#ifdef USE_SDL2
-#define RENDER_SOFTWARE_INIT \
- imageHelper = new SDL2SoftwareImageHelper; \
- surfaceImageHelper = new SurfaceImageHelper; \
- mainGraphics = new SDL2SoftwareGraphics; \
- screenshortHelper = new Sdl2SoftwareScreenshotHelper;
-#define RENDER_SDL2_DEFAULT_INIT \
- imageHelper = new SDLImageHelper; \
- surfaceImageHelper = new SurfaceImageHelper; \
- mainGraphics = new SDLGraphics; \
- screenshortHelper = new SdlScreenshotHelper; \
- mainGraphics->setRendererFlags(SDL_RENDERER_ACCELERATED); \
- mUseTextureSampler = false;
-#else // USE_SDL2
-#define RENDER_SOFTWARE_INIT \
- imageHelper = new SDLImageHelper; \
- surfaceImageHelper = imageHelper; \
- mainGraphics = new SDLGraphics; \
- screenshortHelper = new SdlScreenshotHelper;
-#define RENDER_SDL2_DEFAULT_INIT
-#endif // USE_SDL2
-
-#if defined(ANDROID) || defined(__native_client__)
-#define RENDER_NORMAL_OPENGL_INIT
-#define RENDER_MODERN_OPENGL_INIT
-#else // defined(ANDROID) || defined(__native_client__)
-#define RENDER_NORMAL_OPENGL_INIT \
- imageHelper = new OpenGLImageHelper; \
- surfaceImageHelper = new SurfaceImageHelper; \
- mainGraphics = new NormalOpenGLGraphics; \
- screenshortHelper = new OpenGLScreenshotHelper; \
- mUseTextureSampler = true;
-#define RENDER_MODERN_OPENGL_INIT \
- imageHelper = new OpenGLImageHelper; \
- surfaceImageHelper = new SurfaceImageHelper; \
- mainGraphics = new ModernOpenGLGraphics; \
- screenshortHelper = new OpenGLScreenshotHelper; \
- mUseTextureSampler = true;
-#endif // defined(ANDROID) || defined(__native_client__)
-
-#if defined(ANDROID)
-#define RENDER_SAFE_OPENGL_INIT
-#define RENDER_GLES2_OPENGL_INIT
-#else // defined(ANDROID)
-#define RENDER_SAFE_OPENGL_INIT \
- imageHelper = new SafeOpenGLImageHelper; \
- surfaceImageHelper = new SurfaceImageHelper; \
- mainGraphics = new SafeOpenGLGraphics; \
- screenshortHelper = new OpenGLScreenshotHelper; \
- mUseTextureSampler = false;
-#define RENDER_GLES2_OPENGL_INIT \
- imageHelper = new OpenGLImageHelper; \
- surfaceImageHelper = new SurfaceImageHelper; \
- mainGraphics = new MobileOpenGL2Graphics; \
- screenshortHelper = new MobileOpenGLScreenshotHelper; \
- mUseTextureSampler = false;
-#endif // defined(ANDROID)
-
-#if defined(__native_client__)
-#define RENDER_GLES_OPENGL_INIT
-#else // defined(__native_client__)
-#define RENDER_GLES_OPENGL_INIT \
- imageHelper = new OpenGLImageHelper; \
- surfaceImageHelper = new SurfaceImageHelper; \
- mainGraphics = new MobileOpenGLGraphics; \
- screenshortHelper = new OpenGLScreenshotHelper; \
- mUseTextureSampler = false;
-#endif // defined(__native_client__)
-
-void GraphicsManager::createRenderers()
-{
- RenderType useOpenGL = RENDER_SOFTWARE;
- if (!settings.options.noOpenGL)
- {
- if (settings.options.renderer < 0)
- {
- useOpenGL = intToRenderType(config.getIntValue("opengl"));
- settings.options.renderer = CAST_S32(useOpenGL);
- }
- else
- {
- useOpenGL = intToRenderType(settings.options.renderer);
- }
- }
-
- // Setup image loading for the right image format
- ImageHelper::setOpenGlMode(useOpenGL);
-
- // Create the graphics context
- switch (useOpenGL)
- {
- case RENDER_SOFTWARE:
- RENDER_SOFTWARE_INIT
- mUseTextureSampler = false;
- break;
- case RENDER_LAST:
- case RENDER_NULL:
- default:
- break;
- case RENDER_NORMAL_OPENGL:
- RENDER_NORMAL_OPENGL_INIT
- break;
- case RENDER_SAFE_OPENGL:
- RENDER_SAFE_OPENGL_INIT
- break;
- case RENDER_MODERN_OPENGL:
- RENDER_MODERN_OPENGL_INIT
- break;
- case RENDER_GLES2_OPENGL:
- RENDER_GLES2_OPENGL_INIT
- break;
- case RENDER_GLES_OPENGL:
- RENDER_GLES_OPENGL_INIT
- break;
- case RENDER_SDL2_DEFAULT:
- RENDER_SDL2_DEFAULT_INIT
- break;
- };
- mUseAtlases = (useOpenGL == RENDER_NORMAL_OPENGL ||
- useOpenGL == RENDER_SAFE_OPENGL ||
- useOpenGL == RENDER_MODERN_OPENGL ||
- useOpenGL == RENDER_GLES_OPENGL ||
- useOpenGL == RENDER_GLES2_OPENGL) &&
- config.getBoolValue("useAtlases");
-
-#else // USE_OPENGL
-
-void GraphicsManager::createRenderers()
-{
- RenderType useOpenGL = RENDER_SOFTWARE;
- if (!settings.options.noOpenGL)
- useOpenGL = intToRenderType(config.getIntValue("opengl"));
-
- // Setup image loading for the right image format
- ImageHelper::setOpenGlMode(useOpenGL);
-
- // Create the graphics context
- switch (useOpenGL)
- {
- case RENDER_SOFTWARE:
- case RENDER_SAFE_OPENGL:
- case RENDER_GLES_OPENGL:
- case RENDER_GLES2_OPENGL:
- case RENDER_MODERN_OPENGL:
- case RENDER_NORMAL_OPENGL:
- case RENDER_NULL:
- case RENDER_LAST:
- default:
-#ifndef USE_SDL2
- case RENDER_SDL2_DEFAULT:
- imageHelper = new SDLImageHelper;
- surfaceImageHelper = imageHelper;
- mainGraphics = new SDLGraphics;
- screenshortHelper = new SdlScreenshotHelper;
-#else // USE_SDL2
-
- imageHelper = new SDL2SoftwareImageHelper;
- surfaceImageHelper = new SurfaceImageHelper;
- mainGraphics = new SDL2SoftwareGraphics;
- screenshortHelper = new Sdl2SoftwareScreenshotHelper;
-
-#endif // USE_SDL2
-
- break;
-#ifdef USE_SDL2
- case RENDER_SDL2_DEFAULT:
- imageHelper = new SDLImageHelper;
- surfaceImageHelper = new SurfaceImageHelper;
- mainGraphics = new SDLGraphics;
- mainGraphics->setRendererFlags(SDL_RENDERER_ACCELERATED);
- screenshortHelper = new SdlScreenshotHelper;
- break;
-#endif // USE_SDL2
- };
-#endif // USE_OPENGL
-}
-
-void GraphicsManager::deleteRenderers()
-{
- delete2(mainGraphics);
- if (imageHelper != surfaceImageHelper)
- delete surfaceImageHelper;
- surfaceImageHelper = nullptr;
- delete2(imageHelper);
-}
-
-void GraphicsManager::setVideoMode()
-{
- const int bpp = 0;
- const bool fullscreen = config.getBoolValue("screen");
- const bool hwaccel = config.getBoolValue("hwaccel");
- const bool enableResize = config.getBoolValue("enableresize");
- const bool noFrame = config.getBoolValue("noframe");
- const bool allowHighDPI = config.getBoolValue("allowHighDPI");
-
-#ifdef ANDROID
-// int width = config.getValue("screenwidth", 0);
-// int height = config.getValue("screenheight", 0);
- StringVect videoModes;
- SDL::getAllVideoModes(videoModes);
- if (videoModes.empty())
- logger->error("no video modes detected");
- STD_VECTOR<int> res;
- splitToIntVector(res, videoModes[0], 'x');
- if (res.size() != 2)
- logger->error("no video modes detected");
-
- int width = res[0];
- int height = res[1];
-#elif defined __native_client__
-#ifdef USE_SDL2
- // not implemented
-#else // USE_SDL2
-
- const SDL_VideoInfo* info = SDL_GetVideoInfo();
- int width = info->current_w;
- int height = info->current_h;
-#endif // USE_SDL2
-#else // defined __native_client__
-
- int width = config.getIntValue("screenwidth");
- int height = config.getIntValue("screenheight");
-#endif // defined __native_client__
-
- const int scale = config.getIntValue("scale");
-
- // Try to set the desired video mode
- if (!mainGraphics->setVideoMode(width, height, scale, bpp,
- fullscreen, hwaccel, enableResize, noFrame, allowHighDPI))
- {
- logger->log(strprintf("Couldn't set %dx%dx%d video mode: %s",
- width, height, bpp, SDL_GetError()));
-
- const int oldWidth = config.getValueInt("oldscreenwidth", -1);
- const int oldHeight = config.getValueInt("oldscreenheight", -1);
- const int oldFullscreen = config.getValueInt("oldscreen", -1);
- if (oldWidth != -1 && oldHeight != -1 && oldFullscreen != -1)
- {
- config.deleteKey("oldscreenwidth");
- config.deleteKey("oldscreenheight");
- config.deleteKey("oldscreen");
-
- config.setValueInt("screenwidth", oldWidth);
- config.setValueInt("screenheight", oldHeight);
- config.setValue("screen", oldFullscreen == 1);
- if (!mainGraphics->setVideoMode(oldWidth, oldHeight,
- scale,
- bpp,
- oldFullscreen != 0,
- hwaccel,
- enableResize,
- noFrame,
- allowHighDPI))
- {
- logger->safeError(strprintf("Couldn't restore %dx%dx%d "
- "video mode: %s", oldWidth, oldHeight, bpp,
- SDL_GetError()));
- }
- }
- }
-}
-
-void GraphicsManager::initGraphics()
-{
- openGLMode = intToRenderType(config.getIntValue("opengl"));
-#ifdef USE_OPENGL
- OpenGLImageHelper::setBlur(config.getBoolValue("blur"));
-#ifndef ANDROID
- SafeOpenGLImageHelper::setBlur(config.getBoolValue("blur"));
-#endif // ANDROID
- SurfaceImageHelper::SDLSetEnableAlphaCache(
- config.getBoolValue("alphaCache") &&
- openGLMode == RENDER_SOFTWARE);
- ImageHelper::setEnableAlpha((config.getFloatValue("guialpha") != 1.0F ||
- openGLMode != RENDER_SOFTWARE) &&
- config.getBoolValue("enableGuiOpacity"));
-#else // USE_OPENGL
- SurfaceImageHelper::SDLSetEnableAlphaCache(
- config.getBoolValue("alphaCache"));
- ImageHelper::setEnableAlpha(config.getFloatValue("guialpha") != 1.0F &&
- config.getBoolValue("enableGuiOpacity"));
-#endif // USE_OPENGL
- createRenderers();
- setVideoMode();
- detectPixelSize();
-#ifdef USE_OPENGL
- if (config.getBoolValue("checkOpenGLVersion") == true)
- {
- const RenderType oldOpenGLMode = openGLMode;
- if (openGLMode == RENDER_MODERN_OPENGL)
- {
- if (!mSupportModernOpengl || !checkGLVersion(3, 0))
- {
- logger->log("Fallback to normal OpenGL mode");
- openGLMode = RENDER_NORMAL_OPENGL;
- }
- }
- if (openGLMode == RENDER_NORMAL_OPENGL)
- {
- if (!checkGLVersion(2, 0))
- {
- logger->log("Fallback to safe OpenGL mode");
- openGLMode = RENDER_SAFE_OPENGL;
- }
- }
- if (openGLMode == RENDER_GLES_OPENGL)
- {
- if (!checkGLVersion(2, 0) && !checkGLesVersion(1, 0))
- {
- logger->log("Fallback to safe OpenGL mode");
- openGLMode = RENDER_SAFE_OPENGL;
- }
- }
- if (openGLMode == RENDER_GLES2_OPENGL)
- {
- // +++ here need check also not implemented gles flag
- if (!checkGLVersion(2, 0))
- {
- logger->log("Fallback to software mode");
- openGLMode = RENDER_SOFTWARE;
- }
- }
-
- if (openGLMode != oldOpenGLMode)
- {
- deleteRenderers();
- settings.options.renderer = CAST_S32(openGLMode);
- config.setValue("opengl", settings.options.renderer);
- createRenderers();
- setVideoMode();
- detectPixelSize();
- }
- }
-#if !defined(ANDROID) && !defined(__APPLE__)
- const std::string str = config.getStringValue("textureSize");
- STD_VECTOR<int> sizes;
- splitToIntVector(sizes, str, ',');
- const size_t pos = CAST_SIZE(openGLMode);
- if (sizes.size() <= pos)
- settings.textureSize = 1024;
- else
- settings.textureSize = sizes[pos];
- logger->log("Detected max texture size: %u", settings.textureSize);
-#endif // !defined(ANDROID) && !defined(__APPLE__)
-#endif // USE_OPENGL
-}
-
-#ifdef USE_SDL2
-SDL_Window *GraphicsManager::createWindow(const int w, const int h,
- const int bpp A_UNUSED,
- const int flags)
-{
- return SDL_CreateWindow("ManaPlus", SDL_WINDOWPOS_UNDEFINED,
- SDL_WINDOWPOS_UNDEFINED, w, h, flags);
-}
-
-SDL_Renderer *GraphicsManager::createRenderer(SDL_Window *const window,
- const int flags)
-{
- SDL::setRendererHint(config.getStringValue("sdlDriver"));
- SDL_Renderer *const renderer = SDL_CreateRenderer(window, -1, flags);
- SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND);
- return renderer;
-}
-#else // USE_SDL2
-
-SDL_Window *GraphicsManager::createWindow(const int w, const int h,
- const int bpp, const int flags)
-{
- return SDL_SetVideoMode(w, h, bpp, flags);
-}
-#endif // USE_SDL2
-
-#ifdef USE_OPENGL
-void GraphicsManager::updateExtensions()
-{
- mExtensions.clear();
- logger->log1("opengl extensions: ");
- if (checkGLVersion(3, 0))
- { // get extensions in new way
- assignFunction2(glGetStringi, "glGetStringi");
- std::string extList;
- int num = 0;
- glGetIntegerv(GL_NUM_EXTENSIONS, &num);
- for (int f = 0; f < num; f ++)
- {
- std::string str = reinterpret_cast<const char*>(
- mglGetStringi(GL_EXTENSIONS, f));
- mExtensions.insert(str);
- extList.append(str).append(" ");
- }
- logger->log1(extList.c_str());
- }
- else
- { // get extensions in old way
- char const *extensions = reinterpret_cast<char const *>(
- mglGetString(GL_EXTENSIONS));
- if (extensions)
- {
- logger->log1(extensions);
- splitToStringSet(mExtensions, extensions, ' ');
- }
- }
-}
-
-void GraphicsManager::updatePlanformExtensions()
-{
- SDL_SysWMinfo info;
- SDL_VERSION(&info.version);
- if (SDL::getWindowWMInfo(mainGraphics->getWindow(), &info))
- {
-#ifdef WIN32
- if (!mwglGetExtensionsString)
- return;
-
- HDC hdc = GetDC(info.window);
- if (hdc)
- {
- const char *const extensions = mwglGetExtensionsString(hdc);
- if (extensions)
- {
- logger->log1("wGL extensions:");
- logger->log1(extensions);
- splitToStringSet(mPlatformExtensions, extensions, ' ');
- }
- }
-#elif defined USE_X11
- Display *const display = info.info.x11.display;
- if (display)
- {
- Screen *const screen = XDefaultScreenOfDisplay(display);
- if (!screen)
- return;
-
- const int screenNum = XScreenNumberOfScreen(screen);
- const char *const extensions = glXQueryExtensionsString(
- display, screenNum);
- if (extensions)
- {
- logger->log1("glx extensions:");
- logger->log1(extensions);
- splitToStringSet(mPlatformExtensions, extensions, ' ');
- }
- glXQueryVersion(display, &mPlatformMajor, &mPlatformMinor);
- if (checkPlatformVersion(1, 1))
- {
- const char *const vendor1 = glXQueryServerString(
- display, screenNum, GLX_VENDOR);
- if (vendor1)
- logger->log("glx server vendor: %s", vendor1);
- const char *const version1 = glXQueryServerString(
- display, screenNum, GLX_VERSION);
- if (version1)
- logger->log("glx server version: %s", version1);
- const char *const extensions1 = glXQueryServerString(
- display, screenNum, GLX_EXTENSIONS);
- if (extensions1)
- {
- logger->log1("glx server extensions:");
- logger->log1(extensions1);
- }
-
- const char *const vendor2 = glXGetClientString(
- display, GLX_VENDOR);
- if (vendor2)
- logger->log("glx client vendor: %s", vendor2);
- const char *const version2 = glXGetClientString(
- display, GLX_VERSION);
- if (version2)
- logger->log("glx client version: %s", version2);
- const char *const extensions2 = glXGetClientString(
- display, GLX_EXTENSIONS);
- if (extensions2)
- {
- logger->log1("glx client extensions:");
- logger->log1(extensions2);
- }
- }
- logger->log("width=%d", DisplayWidth(display, screenNum));
- }
-#endif // WIN32
- }
-}
-
-bool GraphicsManager::supportExtension(const std::string &ext) const
-{
- return mExtensions.find(ext) != mExtensions.end();
-}
-
-void GraphicsManager::updateTextureCompressionFormat() const
-{
- const int compressionFormat = config.getIntValue("compresstextures");
- // using extensions if can
- if (checkGLVersion(3, 1) ||
- checkGLesVersion(2, 0) ||
- supportExtension("GL_ARB_texture_compression"))
- {
- GLint num = 0;
- mglGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &num);
- logger->log("support %d compressed formats", num);
- GLint *const formats = new GLint[num > 10
- ? CAST_SIZE(num) : 10];
- mglGetIntegerv(GL_COMPRESSED_TEXTURE_FORMATS, formats);
- for (int f = 0; f < num; f ++)
- logger->log(" 0x%x", CAST_U32(formats[f]));
-
- if (compressionFormat)
- {
- for (int f = 0; f < num; f ++)
- {
- switch (formats[f])
- {
- case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
- if (compressionFormat == 1)
- {
- delete []formats;
- useCompression(GL_COMPRESSED_RGBA_S3TC_DXT5_EXT);
- return;
- }
- break;
- case GL_COMPRESSED_RGBA_FXT1_3DFX:
- if (compressionFormat == 2)
- {
- delete []formats;
- useCompression(GL_COMPRESSED_RGBA_FXT1_3DFX);
- return;
- }
- break;
- case GL_COMPRESSED_RGBA_BPTC_UNORM_ARB:
- if (compressionFormat == 4)
- {
- delete []formats;
- useCompression(GL_COMPRESSED_RGBA_BPTC_UNORM_ARB);
- return;
- }
- break;
- default:
- break;
- }
- }
- if (compressionFormat == 3)
- {
- delete []formats;
- useCompression(GL_COMPRESSED_RGBA_ARB);
- return;
- }
-
- // workaround for MESA bptc compression detection
- if (compressionFormat == 4
- && supportExtension("GL_ARB_texture_compression_bptc"))
- {
- delete []formats;
- useCompression(GL_COMPRESSED_RGBA_BPTC_UNORM_ARB);
- return;
- }
- }
- delete []formats;
- if (compressionFormat)
- logger->log1("no correct compression format found");
- }
- else
- {
- if (compressionFormat)
- logger->log1("no correct compression format found");
- }
-}
-
-void GraphicsManager::updateTextureFormat()
-{
- const int renderer = settings.options.renderer;
-
- // using default formats
- if (renderer == RENDER_MODERN_OPENGL ||
- renderer == RENDER_GLES_OPENGL ||
- renderer == RENDER_GLES2_OPENGL ||
- config.getBoolValue("newtextures"))
- {
- OpenGLImageHelper::setInternalTextureType(GL_RGBA);
-#ifndef ANDROID
- SafeOpenGLImageHelper::setInternalTextureType(GL_RGBA);
-#endif // ANDROID
-
- logger->log1("using RGBA texture format");
- }
- else
- {
- OpenGLImageHelper::setInternalTextureType(4);
-#ifndef ANDROID
- SafeOpenGLImageHelper::setInternalTextureType(4);
-#endif // ANDROID
-
- logger->log1("using 4 texture format");
- }
-}
-
-void GraphicsManager::logString(const char *const format, const int num)
-{
- const char *str = reinterpret_cast<const char*>(mglGetString(num));
- if (!str)
- logger->log(format, "?");
- else
- logger->log(format, str);
-}
-
-std::string GraphicsManager::getGLString(const int num)
-{
- const char *str = reinterpret_cast<const char*>(mglGetString(num));
- return str ? str : "";
-}
-
-void GraphicsManager::setGLVersion()
-{
- mGlVersionString = getGLString(GL_VERSION);
- std::string version = mGlVersionString;
- if (findCutFirst(version, "OpenGL ES "))
- mGles = true;
- sscanf(version.c_str(), "%5d.%5d", &mMajor, &mMinor);
- logger->log("Detected gl version: %d.%d", mMajor, mMinor);
- mGlVendor = getGLString(GL_VENDOR);
- mGlRenderer = getGLString(GL_RENDERER);
- mGlShaderVersionString = getGLString(GL_SHADING_LANGUAGE_VERSION);
- version = mGlShaderVersionString;
- cutFirst(version, "OpenGL ES GLSL ES ");
- cutFirst(version, "OpenGL ES GLSL ");
- cutFirst(version, "OpenGL ES ");
- sscanf(version.c_str(), "%5d.%5d", &mSLMajor, &mSLMinor);
- logger->log("Detected glsl version: %d.%d", mSLMajor, mSLMinor);
-#ifdef ANDROID
- if (!mMajor && !mMinor)
- {
- logger->log("Overriding detected OpenGL version on Android to 1.0");
- mGles = true;
- mMajor = 1;
- mMinor = 0;
- }
-#endif // ANDROID
-}
-
-void GraphicsManager::logVersion() const
-{
- logger->log("gl vendor: " + mGlVendor);
- logger->log("gl renderer: " + mGlRenderer);
- logger->log("gl version: " + mGlVersionString);
- logger->log("glsl version: " + mGlShaderVersionString);
-}
-
-bool GraphicsManager::checkGLVersion(const int major, const int minor) const
-{
- return mMajor > major || (mMajor == major && mMinor >= minor);
-}
-
-bool GraphicsManager::checkSLVersion(const int major, const int minor) const
-{
- return mSLMajor > major || (mSLMajor == major && mSLMinor >= minor);
-}
-
-bool GraphicsManager::checkGLesVersion(const int major, const int minor) const
-{
- return mGles && (mMajor > major || (mMajor == major && mMinor >= minor));
-}
-
-bool GraphicsManager::checkPlatformVersion(const int major,
- const int minor) const
-{
- return mPlatformMajor > major || (mPlatformMajor == major
- && mPlatformMinor >= minor);
-}
-
-void GraphicsManager::createFBO(const int width, const int height,
- FBOInfo *const fbo)
-{
- if (!fbo)
- return;
-
- // create a texture object
- glGenTextures(1, &fbo->textureId);
- glBindTexture(OpenGLImageHelper::mTextureType, fbo->textureId);
- glTexParameterf(OpenGLImageHelper::mTextureType,
- GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameterf(OpenGLImageHelper::mTextureType,
- GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameterf(OpenGLImageHelper::mTextureType,
- GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameterf(OpenGLImageHelper::mTextureType,
- GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- glTexImage2D(OpenGLImageHelper::mTextureType, 0, GL_RGBA8, width, height,
- 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
- glBindTexture(OpenGLImageHelper::mTextureType, 0);
-
- // create a renderbuffer object to store depth info
- mglGenRenderbuffers(1, &fbo->rboId);
- mglBindRenderbuffer(GL_RENDERBUFFER, fbo->rboId);
- mglRenderbufferStorage(GL_RENDERBUFFER,
- GL_DEPTH_COMPONENT, width, height);
- mglBindRenderbuffer(GL_RENDERBUFFER, 0);
-
- // create a framebuffer object
- mglGenFramebuffers(1, &fbo->fboId);
- mglBindFramebuffer(GL_FRAMEBUFFER, fbo->fboId);
-
- // attach the texture to FBO color attachment point
- mglFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
- OpenGLImageHelper::mTextureType, fbo->textureId, 0);
-
- // attach the renderbuffer to depth attachment point
- mglFramebufferRenderbuffer(GL_FRAMEBUFFER,
- GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, fbo->rboId);
-
- mglBindFramebuffer(GL_FRAMEBUFFER, fbo->fboId);
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-}
-
-void GraphicsManager::deleteFBO(FBOInfo *const fbo)
-{
- if (!fbo)
- return;
-
- mglBindFramebuffer(GL_FRAMEBUFFER, 0);
- if (fbo->fboId)
- {
- mglDeleteFramebuffers(1, &fbo->fboId);
- fbo->fboId = 0;
- }
- mglBindRenderbuffer(GL_RENDERBUFFER, 0);
- if (fbo->rboId)
- {
- mglDeleteRenderbuffers(1, &fbo->rboId);
- fbo->rboId = 0;
- }
- if (fbo->textureId)
- {
- glDeleteTextures(1, &fbo->textureId);
- fbo->textureId = 0;
- }
-}
-
-void GraphicsManager::initOpenGLFunctions()
-{
-#ifdef __native_client__
- emulateFunction(glTextureSubImage2DEXT);
-#else // __native_client__
-
- const bool is10 = checkGLVersion(1, 0);
- const bool is11 = checkGLVersion(1, 1);
- const bool is12 = checkGLVersion(1, 2);
- const bool is13 = checkGLVersion(1, 3);
- const bool is15 = checkGLVersion(1, 5);
- const bool is20 = checkGLVersion(2, 0);
- const bool is21 = checkGLVersion(2, 1);
- const bool is30 = checkGLVersion(3, 0);
- const bool is33 = checkGLVersion(3, 3);
- const bool is41 = checkGLVersion(4, 1);
- const bool is42 = checkGLVersion(4, 2);
- const bool is43 = checkGLVersion(4, 3);
- const bool is44 = checkGLVersion(4, 4);
- const bool is45 = checkGLVersion(4, 5);
- mSupportModernOpengl = true;
-
- // Texture sampler
- if (is10 && (is33 || supportExtension("GL_ARB_sampler_objects")))
- {
- logger->log1("found GL_ARB_sampler_objects");
- assignFunction(glGenSamplers);
- assignFunction(glDeleteSamplers);
- assignFunction(glBindSampler);
- assignFunction(glSamplerParameteri);
- if (isGLNotNull(mglGenSamplers)
- && config.getBoolValue("useTextureSampler"))
- {
- mUseTextureSampler &= true;
- }
- else
- {
- mUseTextureSampler = false;
- }
- }
- else
- {
- logger->log1("texture sampler not found");
- mUseTextureSampler = false;
- }
-
- if (!is11)
- {
- mSupportModernOpengl = false;
- emulateFunction(glTextureSubImage2DEXT);
- return;
- }
-
-/*
- if (findI(mGlVendor, "NVIDIA") != std::string::npos ||
- mGlVersionString.find("Mesa 10.6.") != std::string::npos ||
- mGlVersionString.find("Mesa 11.1.1") != std::string::npos ||
- mGlVersionString.find("Mesa 11.1.2") != std::string::npos ||
- mGlVersionString.find("Mesa 11.1.3") != std::string::npos ||
- mGlVersionString.find("Mesa 11.2") != std::string::npos ||
- (findI(mGlRenderer, "AMD Radeon HD") != std::string::npos &&
- (mGlVersionString.find(
- "Compatibility Profile Context 14.") != std::string::npos ||
- mGlVersionString.find(
- "Compatibility Profile Context 15.") != std::string::npos)))
- {
- logger->log1("Not checked for DSA because on "
- "NVIDIA or AMD or in Mesa it broken");
- emulateFunction(glTextureSubImage2DEXT);
- }
- else
-*/
- { // not for NVIDIA. in NVIDIA atleast in windows drivers DSA is broken
- // Mesa 10.6.3 show support for DSA, but it broken. Works in 10.7 dev
- if (config.getBoolValue("enableDSA") == true)
- {
- if (is45)
- {
- logger->log1("found GL_EXT_direct_state_access");
- assignFunction(glTextureSubImage2D);
- }
- else if (supportExtension("GL_EXT_direct_state_access"))
- {
- logger->log1("found GL_EXT_direct_state_access");
- assignFunctionEmu2(glTextureSubImage2DEXT,
- "glTextureSubImage2DEXT");
- }
- else if (supportExtension("GL_ARB_direct_state_access"))
- {
- logger->log1("found GL_ARB_direct_state_access");
- logger->log1("GL_EXT_direct_state_access not found");
- assignFunction(glTextureSubImage2D);
- }
- else
- {
- logger->log1("GL_EXT_direct_state_access not found");
- logger->log1("GL_ARB_direct_state_access not found");
- emulateFunction(glTextureSubImage2DEXT);
- }
- }
- else
- {
- logger->log1("Direct state access disabled in settings");
- emulateFunction(glTextureSubImage2DEXT);
- }
- }
-
- if (is12 && (is42 || supportExtension("GL_ARB_texture_storage")))
- {
- logger->log1("found GL_ARB_texture_storage");
- assignFunction(glTexStorage2D);
- }
- else
- {
- logger->log1("GL_ARB_texture_storage not found");
- }
-
- if (is13 || supportExtension("GL_ARB_multitexture"))
- {
- logger->log1("found GL_ARB_multitexture or OpenGL 1.3");
- assignFunction(glActiveTexture);
- }
- else
- {
- emulateFunction(glActiveTexture);
- logger->log1("GL_ARB_multitexture not found");
- }
-
- if (is20 || supportExtension("GL_ARB_explicit_attrib_location"))
- {
- logger->log1("found GL_ARB_explicit_attrib_location or OpenGL 2.0");
- assignFunction(glBindAttribLocation);
- }
- else
- {
- logger->log1("GL_ARB_explicit_attrib_location not found");
- }
-
- if (is30 || supportExtension("GL_ARB_framebuffer_object"))
- { // frame buffer supported
- logger->log1("found GL_ARB_framebuffer_object");
- assignFunction(glGenRenderbuffers);
- assignFunction(glBindRenderbuffer);
- assignFunction(glRenderbufferStorage);
- assignFunction(glGenFramebuffers);
- assignFunction(glBindFramebuffer);
- assignFunction(glFramebufferTexture2D);
- assignFunction(glFramebufferRenderbuffer);
- assignFunction(glDeleteFramebuffers);
- assignFunction(glDeleteRenderbuffers);
- assignFunction(glCheckFramebufferStatus);
- }
- else if (supportExtension("GL_EXT_framebuffer_object"))
- { // old frame buffer extension
- logger->log1("found GL_EXT_framebuffer_object");
- assignFunctionEXT(glGenRenderbuffers);
- assignFunctionEXT(glBindRenderbuffer);
- assignFunctionEXT(glRenderbufferStorage);
- assignFunctionEXT(glGenFramebuffers);
- assignFunctionEXT(glBindFramebuffer);
- assignFunctionEXT(glFramebufferTexture2D);
- assignFunctionEXT(glFramebufferRenderbuffer);
- assignFunctionEXT(glDeleteFramebuffers);
- assignFunctionEXT(glDeleteRenderbuffers);
- }
- else
- { // no frame buffer support
- logger->log1("GL_ARB_framebuffer_object or "
- "GL_EXT_framebuffer_object not found");
- config.setValue("usefbo", false);
- }
-
- // debug extensions
- if (is43 || supportExtension("GL_KHR_debug"))
- {
- logger->log1("found GL_KHR_debug");
- assignFunction(glDebugMessageControl);
- assignFunction(glDebugMessageCallback);
- assignFunction(glPushDebugGroup);
- assignFunction(glPopDebugGroup);
- assignFunction(glObjectLabel);
- mSupportDebug = 2;
- }
- else if (supportExtension("GL_ARB_debug_output"))
- {
- logger->log1("found GL_ARB_debug_output");
- assignFunctionARB(glDebugMessageControl);
- assignFunctionARB(glDebugMessageCallback);
- mSupportDebug = 1;
- }
- else
- {
- logger->log1("debug extensions not found");
- mSupportDebug = 0;
- }
-
- if (supportExtension("GL_GREMEDY_frame_terminator"))
- {
- logger->log1("found GL_GREMEDY_frame_terminator");
- assignFunction2(glFrameTerminator, "glFrameTerminatorGREMEDY");
- }
- else
- {
- logger->log1("GL_GREMEDY_frame_terminator not found");
- }
- if (is44 || supportExtension("GL_EXT_debug_label"))
- {
- logger->log1("found GL_EXT_debug_label");
- assignFunction2(glLabelObject, "glObjectLabel");
- if (isGLNull(mglLabelObject))
- assignFunctionEXT(glLabelObject);
- assignFunctionEXT(glGetObjectLabel);
- }
- else
- {
- logger->log1("GL_EXT_debug_label not found");
- }
- if (supportExtension("GL_GREMEDY_string_marker"))
- {
- logger->log1("found GL_GREMEDY_string_marker");
- assignFunction2(glPushGroupMarker, "glStringMarkerGREMEDY");
- }
- else
- {
- logger->log1("GL_GREMEDY_string_marker not found");
- }
- if (supportExtension("GL_EXT_debug_marker"))
- {
- logger->log1("found GL_EXT_debug_marker");
- assignFunctionEXT(glInsertEventMarker);
- assignFunctionEXT(glPushGroupMarker);
- assignFunctionEXT(glPopGroupMarker);
- }
- else
- {
- logger->log1("GL_EXT_debug_marker not found");
- }
- if (is15 && (is30 || supportExtension("GL_EXT_timer_query")))
- {
- logger->log1("found GL_EXT_timer_query");
- assignFunction(glGenQueries);
- assignFunction(glBeginQuery);
- assignFunction(glEndQuery);
- assignFunction(glDeleteQueries);
- assignFunction(glGetQueryObjectiv);
- assignFunctionEXT(glGetQueryObjectui64v);
- }
- else
- {
- logger->log1("GL_EXT_timer_query not supported");
- }
- if (is20 && (is43 || supportExtension("GL_ARB_invalidate_subdata")))
- {
- logger->log1("found GL_ARB_invalidate_subdata");
- assignFunction(glInvalidateTexImage);
- }
- else
- {
- logger->log1("GL_ARB_invalidate_subdata not supported");
- }
- if (is21 && (is30 || supportExtension("GL_ARB_vertex_array_object")))
- {
- logger->log1("found GL_ARB_vertex_array_object");
- assignFunction(glGenVertexArrays);
- assignFunction(glBindVertexArray);
- assignFunction(glDeleteVertexArrays);
- assignFunction(glVertexAttribPointer);
- assignFunction(glEnableVertexAttribArray);
- assignFunction(glDisableVertexAttribArray);
- assignFunction(glVertexAttribIPointer);
- }
- else
- {
- mSupportModernOpengl = false;
- logger->log1("GL_ARB_vertex_array_object not found");
- }
- if (is20 || supportExtension("GL_ARB_vertex_buffer_object"))
- {
- assignFunction(glGenBuffers);
- assignFunction(glDeleteBuffers);
- assignFunction(glBindBuffer);
- assignFunction(glBufferData);
- assignFunction(glIsBuffer);
- }
- else
- {
- mSupportModernOpengl = false;
- logger->log1("buffers extension not found");
- }
- if (is43 || supportExtension("GL_ARB_copy_image"))
- {
- logger->log1("found GL_ARB_copy_image");
- assignFunction(glCopyImageSubData);
- }
- else
- {
- logger->log1("GL_ARB_copy_image not found");
- }
- if (is44 || supportExtension("GL_ARB_clear_texture"))
- {
- logger->log1("found GL_ARB_clear_texture");
- assignFunction(glClearTexImage);
- assignFunction(glClearTexSubImage);
- }
- else
- {
- logger->log1("GL_ARB_clear_texture not found");
- }
- if (is20 || supportExtension("GL_ARB_shader_objects"))
- {
- logger->log1("found GL_ARB_shader_objects");
- assignFunction(glCreateShader);
- assignFunction(glDeleteShader);
- assignFunction(glGetShaderiv);
- assignFunction(glGetShaderInfoLog);
- assignFunction(glGetShaderSource);
- assignFunction(glShaderSource);
- assignFunction(glCompileShader);
- assignFunction(glLinkProgram);
- assignFunction(glGetProgramInfoLog);
- assignFunction(glDeleteProgram);
- assignFunction(glCreateProgram);
- assignFunction(glAttachShader);
- assignFunction(glDetachShader);
- assignFunction(glGetAttachedShaders);
- assignFunction(glGetUniformLocation);
- assignFunction(glGetActiveUniform);
- assignFunction(glGetProgramiv);
- assignFunction(glUseProgram);
- assignFunction(glValidateProgram);
- assignFunction(glGetAttribLocation);
- assignFunction(glUniform1f);
- assignFunction(glUniform2f);
- assignFunction(glUniform3f);
- assignFunction(glUniform4f);
-
- if (is30 || supportExtension("GL_EXT_gpu_shader4"))
- {
- logger->log1("found GL_EXT_gpu_shader4");
- assignFunction(glBindFragDataLocation);
- }
- else
- {
- mSupportModernOpengl = false;
- logger->log1("GL_EXT_gpu_shader4 not supported");
- }
- if (is41 || supportExtension("GL_ARB_separate_shader_objects"))
- {
- logger->log1("found GL_ARB_separate_shader_objects");
- assignFunction(glProgramUniform1f);
- assignFunction(glProgramUniform2f);
- assignFunction(glProgramUniform3f);
- assignFunction(glProgramUniform4f);
- }
- else
- {
- logger->log1("GL_ARB_separate_shader_objects not supported");
- }
- if (is43 || supportExtension("GL_ARB_vertex_attrib_binding"))
- {
- logger->log1("found GL_ARB_vertex_attrib_binding");
- assignFunction(glBindVertexBuffer);
- assignFunction(glVertexAttribBinding);
- assignFunction(glVertexAttribFormat);
- assignFunction(glVertexAttribIFormat);
- }
- else
- {
- mSupportModernOpengl = false;
- logger->log1("GL_ARB_vertex_attrib_binding not supported");
- }
- if (is44 || supportExtension("GL_ARB_multi_bind"))
- {
- logger->log1("found GL_ARB_multi_bind");
- assignFunction(glBindVertexBuffers);
- }
- else
- {
- logger->log1("GL_ARB_multi_bind not supported");
- }
- }
- else
- {
- mSupportModernOpengl = false;
- logger->log1("shaders not supported");
- }
-
-#ifdef WIN32
- assignFunctionARB(wglGetExtensionsString);
-#endif // WIN32
-#endif // __native_client__
-}
-
-void GraphicsManager::updateLimits()
-{
- GLint value = 0;
-#ifdef __native_client__
- mMaxVertices = 500;
-#else // __native_client__
-
- glGetIntegerv(GL_MAX_ELEMENTS_VERTICES, &value);
- logger->log("GL_MAX_ELEMENTS_VERTICES: %d", value);
-
- mMaxVertices = value;
-
- value = 0;
- glGetIntegerv(GL_MAX_ELEMENTS_INDICES, &value);
- logger->log("GL_MAX_ELEMENTS_INDICES: %d", value);
- if (value < mMaxVertices)
- mMaxVertices = value;
- if (!mMaxVertices)
- {
- logger->log("Got 0 max amount of vertices or indicies. "
- "Overriding to 500");
- mMaxVertices = 500;
- }
-#endif // __native_client__
-
- value = 0;
- glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE, &value);
- logger->log("Max FBO size: %d", value);
- mMaxFboSize = value;
-}
-
-void GraphicsManager::initOpenGL()
-{
- setGLVersion();
- updateExtensions();
- initOpenGLFunctions();
- updatePlanformExtensions();
- updateDebugLog();
- createTextureSampler();
- updateLimits();
-}
-
-void GraphicsManager::createTextureSampler()
-{
- GLenum err = getLastError();
- if (err)
- logger->log(errorToString(err));
- if (mUseTextureSampler)
- {
- logger->log1("using texture sampler");
- mglGenSamplers(1, &mTextureSampler);
- if (getLastError() != GL_NO_ERROR)
- {
- mUseTextureSampler = false;
- logger->log1("texture sampler error");
- OpenGLImageHelper::setUseTextureSampler(mUseTextureSampler);
- return;
- }
- OpenGLImageHelper::initTextureSampler(mTextureSampler);
- mglBindSampler(0, mTextureSampler);
- if (getLastError() != GL_NO_ERROR)
- {
- mUseTextureSampler = false;
- logger->log1("texture sampler error");
- }
- }
- OpenGLImageHelper::setUseTextureSampler(mUseTextureSampler);
-#ifndef ANDROID
- SafeOpenGLImageHelper::setUseTextureSampler(false);
-#endif // ANDROID
-}
-
-GLenum GraphicsManager::getLastError()
-{
- GLenum tmp = glGetError();
- GLenum error = GL_NO_ERROR;
- while (tmp != GL_NO_ERROR)
- {
- error = tmp;
- mLastError = tmp;
- tmp = glGetError();
- }
- return error;
-}
-
-std::string GraphicsManager::errorToString(const GLenum error)
-{
- if (error)
- {
- std::string errmsg("Unknown error");
- switch (error)
- {
- case GL_INVALID_ENUM:
- errmsg = "GL_INVALID_ENUM";
- break;
- case GL_INVALID_VALUE:
- errmsg = "GL_INVALID_VALUE";
- break;
- case GL_INVALID_OPERATION:
- errmsg = "GL_INVALID_OPERATION";
- break;
- case GL_STACK_OVERFLOW:
- errmsg = "GL_STACK_OVERFLOW";
- break;
- case GL_STACK_UNDERFLOW:
- errmsg = "GL_STACK_UNDERFLOW";
- break;
- case GL_OUT_OF_MEMORY:
- errmsg = "GL_OUT_OF_MEMORY";
- break;
- default:
- break;
- }
- return "OpenGL error: " + errmsg;
- }
- return "";
-}
-
-void GraphicsManager::logError()
-{
- const GLenum error = GraphicsManager::getLastError();
- if (error != GL_NO_ERROR)
- logger->log(errorToString(error));
-}
-
-void GraphicsManager::detectVideoSettings()
-{
- config.setValue("videodetected", true);
- TestMain *const test = startDetection();
-
- if (test)
- {
- const Configuration &conf = test->getConfig();
- int val = conf.getValueInt("opengl", -1);
- if (val >= 0 && val < CAST_S32(RENDER_LAST))
- {
- config.setValue("opengl", val);
- val = conf.getValue("useTextureSampler", -1);
- if (val != -1)
- config.setValue("useTextureSampler", val);
- val = conf.getValue("compresstextures", -1);
- if (val != -1)
- config.setValue("compresstextures", val);
- }
- config.setValue("textureSize", conf.getValue("textureSize",
- "1024,1024,1024,1024,1024,1024"));
- config.setValue("testInfo", conf.getValue("testInfo", ""));
- config.setValue("sound", conf.getValue("sound", 0));
- delete test;
- }
-}
-
-static CALLBACK void debugCallback(GLenum source, GLenum type, GLuint id,
- GLenum severity, GLsizei length,
- const GLchar *text, GLvoid *userParam A_UNUSED)
-{
- std::string message("OPENGL:");
- switch (source)
- {
- case GL_DEBUG_SOURCE_API:
- message.append(" API");
- break;
- case GL_DEBUG_SOURCE_WINDOW_SYSTEM:
- message.append(" WM");
- break;
- case GL_DEBUG_SOURCE_SHADER_COMPILER:
- message.append(" SHADERS");
- break;
- case GL_DEBUG_SOURCE_THIRD_PARTY:
- message.append(" THIRD_PARTY");
- break;
- case GL_DEBUG_SOURCE_APPLICATION:
- message.append(" APP");
- break;
- case GL_DEBUG_SOURCE_OTHER:
- message.append(" OTHER");
- break;
- default:
- message.append(" ?").append(toString(source));
- break;
- }
- switch (type)
- {
- case GL_DEBUG_TYPE_ERROR:
- message.append(" ERROR");
- break;
- case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR:
- message.append(" DEPRECATED");
- break;
- case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR:
- message.append(" UNDEFINED");
- break;
- case GL_DEBUG_TYPE_PORTABILITY:
- message.append(" PORTABILITY");
- break;
- case GL_DEBUG_TYPE_PERFORMANCE:
- message.append(" PERFORMANCE");
- break;
- case GL_DEBUG_TYPE_OTHER:
- message.append(" OTHER");
- break;
- case GL_DEBUG_TYPE_MARKER:
- message.append(" MARKER");
- break;
- case GL_DEBUG_TYPE_PUSH_GROUP:
- message.append(" PUSH GROUP");
- break;
- case GL_DEBUG_TYPE_POP_GROUP:
- message.append(" POP GROUP");
- break;
- default:
- message.append(" ?").append(toString(type));
- break;
- }
- message.append(" ").append(toString(id));
- switch (severity)
- {
- case GL_DEBUG_SEVERITY_NOTIFICATION:
- message.append(" N");
- break;
- case GL_DEBUG_SEVERITY_HIGH:
- message.append(" H");
- break;
- case GL_DEBUG_SEVERITY_MEDIUM:
- message.append(" M");
- break;
- case GL_DEBUG_SEVERITY_LOW:
- message.append(" L");
- break;
- default:
- message.append(" ?").append(toString(type));
- break;
- }
- char *const buf = new char[CAST_SIZE(length + 1)];
- memcpy(buf, text, length);
- buf[length] = 0;
- message.append(" ").append(buf);
- delete [] buf;
- logger->log(message);
-}
-
-void GraphicsManager::updateDebugLog() const
-{
- if (mSupportDebug && config.getIntValue("debugOpenGL"))
- {
- logger->log1("Enable OpenGL debug log");
- glEnable(GL_DEBUG_OUTPUT);
- glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
-
- mglDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE,
- 0, nullptr, GL_TRUE);
- mglDebugMessageCallback(&debugCallback, this);
- }
-}
-#endif // USE_OPENGL
-
-void GraphicsManager::detectPixelSize()
-{
- SDL_SysWMinfo info;
- SDL_VERSION(&info.version);
- if (SDL::getWindowWMInfo(mainGraphics->getWindow(), &info))
- {
-#ifdef WIN32
- HDC hdc = GetDC(info.window);
- if (hdc)
- {
-// SetProcessDPIAware();
- mMaxWidth = GetDeviceCaps(hdc, HORZRES);
- mMaxHeight = GetDeviceCaps(hdc, VERTRES);
- mWidthMM = GetDeviceCaps(hdc, HORZSIZE);
- mHeightMM = GetDeviceCaps(hdc, VERTSIZE);
- }
-#elif defined USE_X11
- Display *const display = info.info.x11.display;
- if (display)
- {
- Screen *const screen = XDefaultScreenOfDisplay(display);
- if (!screen)
- return;
-
- const int screenNum = XScreenNumberOfScreen(screen);
- mMaxWidth = DisplayWidth(display, screenNum);
- mMaxHeight = DisplayHeight(display, screenNum);
- mWidthMM = DisplayWidthMM(display, screenNum);
- mHeightMM = DisplayHeightMM(display, screenNum);
- }
-#endif // WIN32
- }
-#if defined ANDROID
-#ifdef USE_SDL2
- const int dpi = atoi(getenv("DISPLAY_DPI"));
- if (dpi <= 120)
- mDensity = 0;
- else if (dpi <= 160)
- mDensity = 1;
- else if (dpi <= 213)
- mDensity = 2;
- else if (dpi <= 240)
- mDensity = 3;
- else if (dpi <= 320)
- mDensity = 4;
-// else if (dpi <= 480)
- else
- mDensity = 5;
- mMaxWidth = atoi(getenv("DISPLAY_RESOLUTION_WIDTH"));
- mMaxHeight = atoi(getenv("DISPLAY_RESOLUTION_HEIGHT"));
- mWidthMM = atoi(getenv("DISPLAY_WIDTH_MM"));
- mHeightMM = atoi(getenv("DISPLAY_HEIGHT_MM"));
-#else // USE_SDL2
-
- SDL_ANDROID_GetMetrics(&mMaxWidth, &mMaxHeight,
- &mWidthMM, &mHeightMM, &mDensity);
-#endif // USE_SDL2
-#endif // defined ANDROID
-
- logger->log("screen size in pixels: %ux%u", mMaxWidth, mMaxHeight);
- logger->log("screen size in millimeters: %ux%u", mWidthMM, mHeightMM);
- logger->log("actual screen density: " + getDensityString());
- const int density = config.getIntValue("screenDensity");
- if (density > 0 && density <= densitySize)
- {
- mDensity = density - 1;
- logger->log("selected screen density: " + getDensityString());
- }
-}
-
-std::string GraphicsManager::getDensityString() const
-{
- if (mDensity >= 0 && mDensity < densitySize)
- return densityNames[mDensity];
- return "";
-}
diff --git a/src/graphicsmanager.h b/src/graphicsmanager.h
deleted file mode 100644
index 6d0777d27..000000000
--- a/src/graphicsmanager.h
+++ /dev/null
@@ -1,229 +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 GRAPHICSMANAGER_H
-#define GRAPHICSMANAGER_H
-
-#include "localconsts.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)
-// hack to hide warnings
-#undef GL_GLEXT_VERSION
-#undef GL_GLEXT_PROTOTYPES
-#endif // ANDROID
-
-#endif // USE_OPENGL
-
-#include "sdlshared.h"
-
-#include "utils/stringvector.h"
-
-#include <set>
-
-class TestMain;
-
-struct FBOInfo;
-#ifdef USE_SDL2
-struct SDL_Renderer;
-#endif // USE_SDL2
-struct SDL_Window;
-
-class GraphicsManager final
-{
- public:
- GraphicsManager();
-
- A_DELETE_COPY(GraphicsManager)
-
- ~GraphicsManager();
-
- void createRenderers();
-
- static void deleteRenderers();
-
- void initGraphics();
-
- static void setVideoMode();
-
- SDL_Window *createWindow(const int w, const int h,
- const int bpp, const int flags);
-
-#ifdef USE_SDL2
- SDL_Renderer *createRenderer(SDL_Window *const window,
- const int flags);
-#endif // USE_SDL2
-
- bool getAllVideoModes(StringVect &modeList);
-
- void detectPixelSize();
-
- std::string getDensityString() const;
-
- int getDensity() const
- { return mDensity; }
-
-#ifdef USE_OPENGL
- TestMain *startDetection() A_WARN_UNUSED;
-
- int detectGraphics() A_WARN_UNUSED;
-
- bool supportExtension(const std::string &ext) const A_WARN_UNUSED;
-
- static void updateTextureFormat();
-
- void updateTextureCompressionFormat() const;
-
- bool checkGLVersion(const int major, const int minor)
- const A_WARN_UNUSED;
-
- bool checkGLesVersion(const int major, const int minor)
- const A_WARN_UNUSED;
-
- bool checkSLVersion(const int major, const int minor)
- const A_WARN_UNUSED;
-
- bool checkPlatformVersion(const int major, const int minor)
- const A_WARN_UNUSED;
-
- static void createFBO(const int width, const int height,
- FBOInfo *const fbo);
-
- static void deleteFBO(FBOInfo *const fbo);
-
- void initOpenGLFunctions();
-
- void updateExtensions();
-
- void updatePlanformExtensions();
-
- void initOpenGL();
-
- void updateLimits();
-
- int getMaxVertices() const noexcept2 A_WARN_UNUSED
- { return mMaxVertices; }
-
- bool getUseAtlases() const noexcept2 A_WARN_UNUSED
- { return mUseAtlases; }
-
- void logVersion() const;
-
- void setGLVersion();
-
- static std::string getGLString(const int num) A_WARN_UNUSED;
-
- static void logString(const char *const format,
- const int num) A_NONNULL(1);
-
- void detectVideoSettings();
-
- void createTextureSampler();
-
- bool isUseTextureSampler() const noexcept2 A_WARN_UNUSED
- { return mUseTextureSampler; }
-
- static GLenum getLastError();
-
- static std::string errorToString(const GLenum error) A_WARN_UNUSED;
-
- static void logError();
-
- void updateDebugLog() const;
-
- std::string getGLVersion() const
- { return mGlVersionString; }
-
- static GLenum getLastErrorCached()
- { return mLastError; }
-
- constexpr2 static void resetCachedError() noexcept2
- { mLastError = GL_NO_ERROR; }
-#endif // USE_OPENGL
-
- private:
- std::set<std::string> mExtensions;
-
- std::set<std::string> mPlatformExtensions;
-
- std::string mGlVersionString;
-
- std::string mGlVendor;
-
- std::string mGlRenderer;
-
- std::string mGlShaderVersionString;
-#ifdef USE_OPENGL
- static GLenum mLastError;
-#endif // USE_OPENGL
-
- int mMinor;
-
- int mMajor;
-
- int mSLMinor;
-
- int mSLMajor;
-
- int mPlatformMinor;
-
- int mPlatformMajor;
-
- int mMaxVertices;
-
- int mMaxFboSize;
-
- uint32_t mMaxWidth;
-
- uint32_t mMaxHeight;
-
- uint32_t mWidthMM;
-
- uint32_t mHeightMM;
-
- int32_t mDensity;
-
-#ifdef USE_OPENGL
- bool mUseTextureSampler;
-
- GLuint mTextureSampler;
-
- int mSupportDebug;
-
- bool mSupportModernOpengl;
-
- bool mGles;
-#endif // USE_OPENGL
-
- bool mUseAtlases;
-};
-
-extern GraphicsManager graphicsManager;
-
-#endif // GRAPHICSMANAGER_H
diff --git a/src/gui/browserlink.h b/src/gui/browserlink.h
deleted file mode 100644
index a8dc0cb6f..000000000
--- a/src/gui/browserlink.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
- * Copyright (C) 2009 Aethyra Development Team
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * 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_BROWSERLINK_H
-#define GUI_BROWSERLINK_H
-
-#include <string>
-
-#include "localconsts.h"
-
-struct BrowserLink final
-{
- BrowserLink() :
- x1(0),
- x2(0),
- y1(0),
- y2(0),
- link(),
- caption()
- {
- }
-
- A_DEFAULT_COPY(BrowserLink)
-
- int x1;
- int x2;
- int y1;
- int y2;
- std::string link;
- std::string caption;
-};
-
-#endif // GUI_BROWSERLINK_H
diff --git a/src/gui/buttoninfo.h b/src/gui/buttoninfo.h
deleted file mode 100644
index d6039e08f..000000000
--- a/src/gui/buttoninfo.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 GUI_BUTTONINFO_H
-#define GUI_BUTTONINFO_H
-
-#include "enums/input/inputaction.h"
-
-#include "enums/simpletypes/visible.h"
-
-#include "localconsts.h"
-
-class Button;
-
-struct ButtonInfo final
-{
- ButtonInfo(Button *const button0,
- const InputActionT key0,
- const Visible visible0) :
- button(button0),
- key(key0),
- visible(visible0)
- {
- }
-
- A_DELETE_COPY(ButtonInfo)
-
- Button *button;
- InputActionT key;
- Visible visible;
-};
-#endif // GUI_BUTTONINFO_H
diff --git a/src/gui/buttontext.h b/src/gui/buttontext.h
deleted file mode 100644
index f827859b6..000000000
--- a/src/gui/buttontext.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 GUI_BUTTONTEXT_H
-#define GUI_BUTTONTEXT_H
-
-#include "enums/input/inputaction.h"
-
-#include "localconsts.h"
-
-#include <string>
-
-struct ButtonText final
-{
- ButtonText(const std::string &text0,
- const InputActionT key0) :
- text(text0),
- key(key0)
- {
- }
-
- A_DELETE_COPY(ButtonText)
-
- std::string text;
- InputActionT key;
-};
-
-#endif // GUI_BUTTONTEXT_H
diff --git a/src/gui/chatlog.h b/src/gui/chatlog.h
deleted file mode 100644
index 20820ad13..000000000
--- a/src/gui/chatlog.h
+++ /dev/null
@@ -1,48 +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_CHATLOG_H
-#define GUI_CHATLOG_H
-
-#include "enums/gui/chatmsgtype.h"
-
-#include <string>
-
-#include "localconsts.h"
-
-/** One item in the chat log */
-struct CHATLOG final
-{
- CHATLOG() :
- nick(),
- text(),
- own(ChatMsgType::BY_UNKNOWN)
- {
- }
-
- A_DELETE_COPY(CHATLOG)
-
- std::string nick;
- std::string text;
- ChatMsgTypeT own;
-};
-#endif // GUI_CHATLOG_H
diff --git a/src/gui/cliprect.h b/src/gui/cliprect.h
deleted file mode 100644
index 149420b8c..000000000
--- a/src/gui/cliprect.h
+++ /dev/null
@@ -1,129 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GUI_CLIPRECT_H
-#define GUI_CLIPRECT_H
-
-#include "gui/rect.h"
-
-#include "localconsts.h"
-
-/**
- * A rectangle used when dealing with clipping. A clip rectangle is
- * a regular rectangle extended with variables for x offsets and y
- * offsets. The offsets are used for calculations from relative
- * screen coordinates to actual screen coordinates.
- */
-class ClipRect final : public Rect
-{
- public:
- /**
- * Constructor.
- */
- ClipRect() :
- Rect(0, 0, 0, 0),
- xOffset(0),
- yOffset(0)
- {
- }
-
- /**
- * Constructor.
- *
- * @param x0 The rectangle x coordinate.
- * @param y0 The rectangle y coordinate.
- * @param width0 The rectangle width.
- * @param height0 The rectangle height.
- * @param xOffset0 The offset of the x coordinate. Used to for
- * calculating the actual screen coordinate from
- * the relative screen coordinate.
- * @param yOffset0 The offset of the y coordinate. Used to for
- * calculating the actual screen coordinate from
- * the relative screen coordinate.
- */
- ClipRect(const int x0,
- const int y0,
- const int width0,
- const int height0,
- const int xOffset0,
- const int yOffset0) :
- Rect(x0, y0, width0, height0),
- xOffset(xOffset0),
- yOffset(yOffset0)
- {
- }
-
- A_DELETE_COPY(ClipRect)
-
- /**
- * Holds the x offset of the x coordinate.
- */
- int xOffset;
-
- /**
- * Holds the y offset of the y coordinate.
- */
- int yOffset;
-};
-
-#endif // GUI_CLIPRECT_H
diff --git a/src/gui/color.h b/src/gui/color.h
deleted file mode 100644
index c4a1aab01..000000000
--- a/src/gui/color.h
+++ /dev/null
@@ -1,253 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GUI_COLOR_H
-#define GUI_COLOR_H
-
-#include "utils/cast.h"
-
-#include "localconsts.h"
-
-/**
- * Represents a color with red, green, blue and alpha components.
- */
-class Color final
-{
- public:
- /**
- * Constructor. Initializes the color to black.
- */
- constexpr Color() :
- r(0U),
- g(0U),
- b(0U),
- a(255U)
- {
- }
-
- /**
- * Constructor. Constructs a color from the bytes in an integer.
- * Call it with a hexadecimal constant for HTML-style color
- * representation.
- * The alpha component is 255 by default.
- *
- * EXAMPLE: Color(0xff50a0) constructs a very nice pinkish color.
- *
- * NOTE: Because of this constructor, integers will be automatically
- * casted to a color by your compiler.
- *
- * @param color The color to initialise the object with.
- */
- explicit constexpr Color(const unsigned int color) :
- r((color >> 16) & 0xFFU),
- g((color >> 8) & 0xFFU),
- b(color & 0xFFU),
- a(255U)
- {
- }
-
- /**
- * Constructor. The default alpha value is 255.
- *
- * @param ar Red color component (range 0-255).
- * @param ag Green color component (range 0-255).
- * @param ab Blue color component (range 0-255).
- * @param aa Alpha, used for transparency. A value of 0 means
- * totaly transparent, 255 is totaly opaque.
- */
- constexpr Color(const unsigned int ar,
- const unsigned int ag,
- const unsigned int ab,
- const unsigned int aa = 255) :
- r(ar),
- g(ag),
- b(ab),
- a(aa)
- {
- }
-
-
- A_DEFAULT_COPY(Color)
-
- /**
- * Adds the RGB values of two colors together. The values will be
- * clamped if they go out of range.
- *
- * WARNING: This function will reset the alpha value of the
- * returned color to 255.
- *
- * @param color A color to add to this color.
- * @return The added colors with an alpha value set to 255.
- */
- constexpr2 Color operator+(const Color& color) const
- {
- Color result(r + color.r,
- g + color.g,
- b + color.b,
- 255U);
-
- result.r = (result.r > 255U ? 255U : result.r);
- result.g = (result.g > 255U ? 255U : result.g);
- result.b = (result.b > 255U ? 255U : result.b);
-
- return result;
- }
-
- /**
- * Subtracts the RGB values of one color from another.
- * The values will be clamped if they go out of range.
- *
- * WARNING: This function will reset the alpha value of the
- * returned color to 255.
- *
- * @param color A color to subtract from this color.
- * @return The subtracted colors with an alpha value set to 255.
- */
- constexpr2 Color operator-(const Color& color) const
- {
- Color result(r - color.r,
- g - color.g,
- b - color.b,
- 255U);
-
- result.r = (result.r > 255U ? 255U : result.r);
- result.g = (result.g > 255U ? 255U : result.g);
- result.b = (result.b > 255U ? 255U : result.b);
-
- return result;
- }
-
- /**
- * Multiplies the RGB values of a color with a float value.
- * The values will be clamped if they go out of range.
- *
- * @param value The value to multiply the color with.
- * @return The multiplied colors. The alpha value will, unlike
- * the add and subtract operations, be multiplied as
- * well.
- */
- constexpr2 Color operator*(const float value) const
- {
- Color result(CAST_U32(static_cast<float>(r) * value),
- CAST_U32(static_cast<float>(g) * value),
- CAST_U32(static_cast<float>(b) * value),
- a);
-
- result.r = (result.r > 255U ? 255U : result.r);
- result.g = (result.g > 255U ? 255U : result.g);
- result.b = (result.b > 255U ? 255U : result.b);
-
- return result;
- }
-
- /**
- * Compares two colors.
- *
- * @return True if the two colors have the same RGBA components
- * false otherwise.
- */
- constexpr bool operator==(const Color& color) const
- {
- return r == color.r &&
- g == color.g &&
- b == color.b &&
- a == color.a;
- }
-
- /**
- * Compares two colors.
- *
- * @return True if the two colors have different RGBA components,
- * false otherwise.
- */
- constexpr bool operator!=(const Color& color) const
- {
- return !(r == color.r &&
- g == color.g &&
- b == color.b &&
- a == color.a);
- }
-
- /**
- * Holds the red color component (range 0-255).
- */
- unsigned int r;
-
- /**
- * Holds the green color component (range 0-255).
- */
- unsigned int g;
-
- /**
- * Holds the blue color component (range 0-255).
- */
- unsigned int b;
-
- /**
- * Holds the alpha color component. A value of 0 means totally
- * transparent while a value of 255 is considered opaque.
- */
- unsigned int a;
-};
-
-#endif // GUI_COLOR_H
diff --git a/src/gui/colorpair.h b/src/gui/colorpair.h
deleted file mode 100644
index f3089868e..000000000
--- a/src/gui/colorpair.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 GUI_COLORPAIR_H
-#define GUI_COLORPAIR_H
-
-#include "localconsts.h"
-
-class Color;
-
-struct ColorPair final
-{
- constexpr ColorPair(const Color *const c1,
- const Color *const c2) :
- color1(c1),
- color2(c2)
- {
- }
-
- A_DEFAULT_COPY(ColorPair)
-
- const Color *color1;
- const Color *color2;
-};
-
-#endif // GUI_COLORPAIR_H
diff --git a/src/gui/dialogsmanager.cpp b/src/gui/dialogsmanager.cpp
deleted file mode 100644
index f24352a43..000000000
--- a/src/gui/dialogsmanager.cpp
+++ /dev/null
@@ -1,222 +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 "gui/dialogsmanager.h"
-
-#include "configuration.h"
-#include "settings.h"
-
-#include "being/playerinfo.h"
-
-#include "gui/widgets/createwidget.h"
-
-#include "gui/windows/confirmdialog.h"
-
-#ifndef DYECMD
-#include "gui/widgets/selldialog.h"
-
-#include "gui/windows/buyselldialog.h"
-#include "gui/windows/buydialog.h"
-#include "gui/windows/updaterwindow.h"
-
-#include "listeners/playerpostdeathlistener.h"
-#endif // DYECMD
-
-#include "listeners/weightlistener.h"
-
-#include "net/inventoryhandler.h"
-
-#include "resources/db/deaddb.h"
-
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-#ifdef WIN32
-#undef ERROR
-#endif // WIN32
-
-OkDialog *deathNotice = nullptr;
-DialogsManager *dialogsManager = nullptr;
-OkDialog *weightNotice = nullptr;
-time_t weightNoticeTime = 0;
-
-#ifndef DYECMD
-namespace
-{
- PlayerPostDeathListener postDeathListener;
- WeightListener weightListener;
-} // namespace
-#endif // DYECMD
-
-DialogsManager::DialogsManager() :
- AttributeListener(),
- PlayerDeathListener()
-{
-}
-
-void DialogsManager::closeDialogs()
-{
-#ifndef DYECMD
- NpcDialog::clearDialogs();
- BuyDialog::closeAll();
- BuySellDialog::closeAll();
- NpcDialog::closeAll();
- SellDialog::closeAll();
- if (inventoryHandler != nullptr)
- inventoryHandler->destroyStorage();
-#endif // DYECMD
-
- if (deathNotice != nullptr)
- {
- deathNotice->scheduleDelete();
- deathNotice = nullptr;
- }
-}
-
-void DialogsManager::createUpdaterWindow()
-{
-#ifndef DYECMD
- CREATEWIDGETV(updaterWindow, UpdaterWindow,
- settings.updateHost,
- settings.oldUpdates,
- false,
- UpdateType::Normal);
-#endif // DYECMD
-}
-
-Window *DialogsManager::openErrorDialog(const std::string &header,
- const std::string &message,
- const Modal modal)
-{
- if (settings.supportUrl.empty() || config.getBoolValue("hidesupport"))
- {
- OkDialog *const dialog = CREATEWIDGETR(OkDialog,
- header,
- message,
- // TRANSLATORS: ok dialog button
- _("Close"),
- DialogType::ERROR,
- modal,
- ShowCenter_true,
- nullptr,
- 260);
- return dialog;
- }
- ConfirmDialog *const dialog = CREATEWIDGETR(ConfirmDialog,
- header,
- strprintf("%s %s", message.c_str(),
- // TRANSLATORS: error message question
- _("Do you want to open support page?")),
- SOUND_ERROR,
- false,
- modal);
- return dialog;
-}
-
-void DialogsManager::playerDeath()
-{
-#ifndef DYECMD
- if (deathNotice == nullptr)
- {
- CREATEWIDGETV(deathNotice, OkDialog,
- // TRANSLATORS: message header
- _("Message"),
- DeadDB::getRandomString(),
- // TRANSLATORS: ok dialog button
- _("Revive"),
- DialogType::OK,
- Modal_false,
- ShowCenter_true,
- nullptr,
- 260);
- deathNotice->addActionListener(&postDeathListener);
- }
-#endif // DYECMD
-}
-
-#ifndef DYECMD
-void DialogsManager::attributeChanged(const AttributesT id,
- const int64_t oldVal,
- const int64_t newVal)
-{
- if (id == Attributes::TOTAL_WEIGHT)
- {
- if ((weightNotice == nullptr) && config.getBoolValue("weightMsg"))
- {
- int percent = settings.overweightPercent;
- if (percent < 1)
- percent = 50;
- const int max = PlayerInfo::getAttribute(
- Attributes::MAX_WEIGHT) * percent / 100;
- const int total = CAST_S32(oldVal);
- if (newVal >= max && total < max)
- {
- weightNoticeTime = cur_time + 5;
- CREATEWIDGETV(weightNotice, OkDialog,
- // TRANSLATORS: message header
- _("Message"),
- // TRANSLATORS: weight message
- _("You are carrying more than "
- "half your weight. You are "
- "unable to regain health."),
- // TRANSLATORS: ok dialog button
- _("OK"),
- DialogType::OK,
- Modal_false,
- ShowCenter_true,
- nullptr,
- 260);
- weightNotice->addActionListener(
- &weightListener);
- }
- else if (newVal < max && total >= max)
- {
- weightNoticeTime = cur_time + 5;
- CREATEWIDGETV(weightNotice, OkDialog,
- // TRANSLATORS: message header
- _("Message"),
- // TRANSLATORS: weight message
- _("You are carrying less than "
- "half your weight. You "
- "can regain health."),
- // TRANSLATORS: ok dialog button
- _("OK"),
- DialogType::OK,
- Modal_false,
- ShowCenter_true,
- nullptr,
- 260);
- weightNotice->addActionListener(
- &weightListener);
- }
- }
- }
-}
-#else // DYECMD
-
-void DialogsManager::attributeChanged(const AttributesT id A_UNUSED,
- const int64_t oldVal A_UNUSED,
- const int64_t newVal A_UNUSED)
-{
-}
-#endif // DYECMD
diff --git a/src/gui/dialogsmanager.h b/src/gui/dialogsmanager.h
deleted file mode 100644
index 04ace68e2..000000000
--- a/src/gui/dialogsmanager.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 GUI_DIALOGSMANAGER_H
-#define GUI_DIALOGSMANAGER_H
-
-#include "enums/simpletypes/modal.h"
-
-#include "listeners/attributelistener.h"
-#include "listeners/playerdeathlistener.h"
-
-#include <string>
-
-#include "localconsts.h"
-
-class Window;
-
-class DialogsManager final : public AttributeListener,
- public PlayerDeathListener
-{
- public:
- DialogsManager();
-
- virtual ~DialogsManager()
- { }
-
- A_DELETE_COPY(DialogsManager)
-
- static void closeDialogs();
-
- static void createUpdaterWindow();
-
- static Window *openErrorDialog(const std::string &header,
- const std::string &message,
- const Modal modal) RETURNS_NONNULL;
-
- void playerDeath() override final;
-
- void attributeChanged(const AttributesT id,
- const int64_t oldVal,
- const int64_t newVal) override final;
-};
-
-extern DialogsManager *dialogsManager;
-
-#endif // GUI_DIALOGSMANAGER_H
diff --git a/src/gui/focushandler.cpp b/src/gui/focushandler.cpp
deleted file mode 100644
index ebfc988ac..000000000
--- a/src/gui/focushandler.cpp
+++ /dev/null
@@ -1,621 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "gui/focushandler.h"
-
-#include "gui/gui.h"
-
-#include "gui/widgets/window.h"
-
-#include "listeners/focuslistener.h"
-
-#include "utils/foreach.h"
-
-#include "debug.h"
-
-FocusHandler::FocusHandler() :
- mWidgets(),
- mFocusedWidget(nullptr),
- mModalFocusedWidget(nullptr),
- mModalMouseInputFocusedWidget(nullptr),
- mDraggedWidget(nullptr),
- mLastWidgetWithMouse(nullptr),
- mLastWidgetWithModalFocus(nullptr),
- mLastWidgetWithModalMouseInputFocus(nullptr),
- mLastWidgetPressed(nullptr),
- mModalStack()
-{
-}
-
-void FocusHandler::requestModalFocus(Widget *const widget)
-{
- /* If there is another widget with modal focus, remove its modal focus
- * and put it on the modal widget stack.
- */
- if ((mModalFocusedWidget != nullptr) && mModalFocusedWidget != widget)
- {
- mModalStack.push_front(mModalFocusedWidget);
- mModalFocusedWidget = nullptr;
- }
-
- mModalFocusedWidget = widget;
- if ((mFocusedWidget != nullptr) && !mFocusedWidget->isModalFocused())
- focusNone();
-}
-
-void FocusHandler::releaseModalFocus(Widget *const widget)
-{
- mModalStack.remove(widget);
-
- if (mModalFocusedWidget == widget)
- {
- mModalFocusedWidget = nullptr;
-
- /* Check if there were any previously modal widgets that'd still like
- * to regain their modal focus.
- */
- if (!mModalStack.empty())
- {
- requestModalFocus(mModalStack.front());
- mModalStack.pop_front();
- }
- }
-}
-
-void FocusHandler::remove(Widget *const widget)
-{
- releaseModalFocus(widget);
-
- if (isFocused(widget))
- mFocusedWidget = nullptr;
-
- FOR_EACH (WidgetIterator, iter, mWidgets)
- {
- if ((*iter) == widget)
- {
- mWidgets.erase(iter);
- break;
- }
- }
-
- if (mDraggedWidget == widget)
- {
- mDraggedWidget = nullptr;
- return;
- }
-
- if (mLastWidgetWithMouse == widget)
- {
- mLastWidgetWithMouse = nullptr;
- return;
- }
-
- if (mLastWidgetWithModalFocus == widget)
- {
- mLastWidgetWithModalFocus = nullptr;
- return;
- }
-
- if (mLastWidgetWithModalMouseInputFocus == widget)
- {
- mLastWidgetWithModalMouseInputFocus = nullptr;
- return;
- }
-
- if (mLastWidgetPressed == widget)
- {
- mLastWidgetPressed = nullptr;
- return;
- }
-}
-
-void FocusHandler::tabNext()
-{
- if (mFocusedWidget != nullptr)
- {
- if (!mFocusedWidget->isTabOutEnabled())
- return;
- }
-
- if (mWidgets.empty())
- {
- mFocusedWidget = nullptr;
- return;
- }
-
- int i;
- int focusedWidget = -1;
- const int sz = CAST_S32(mWidgets.size());
- for (i = 0; i < sz; ++ i)
- {
- if (mWidgets[i] == mFocusedWidget)
- focusedWidget = i;
- }
- const int focused = focusedWidget;
- bool done = false;
-
- // i is a counter that ensures that the following loop
- // won't get stuck in an infinite loop
- i = sz;
- do
- {
- ++ focusedWidget;
-
- if (i == 0)
- {
- focusedWidget = -1;
- break;
- }
-
- -- i;
-
- if (focusedWidget >= sz)
- focusedWidget = 0;
-
- if (focusedWidget == focused)
- return;
-
- const Widget *const widget = mWidgets.at(focusedWidget);
- if (widget->isFocusable() && widget->isTabInEnabled() &&
- ((mModalFocusedWidget == nullptr) || widget->isModalFocused()))
- {
- done = true;
- }
- }
- while (!done);
-
- if (focusedWidget >= 0)
- {
- mFocusedWidget = mWidgets.at(focusedWidget);
- Event focusEvent(mFocusedWidget);
- distributeFocusGainedEvent(focusEvent);
- }
-
- if (focused >= 0)
- {
- Event focusEvent(mWidgets.at(focused));
- distributeFocusLostEvent(focusEvent);
- }
-
- checkForWindow();
-}
-
-void FocusHandler::tabPrevious()
-{
- if (mFocusedWidget != nullptr)
- {
- if (!mFocusedWidget->isTabOutEnabled())
- return;
- }
-
- if (mWidgets.empty())
- {
- mFocusedWidget = nullptr;
- return;
- }
-
- int i;
- int focusedWidget = -1;
- const int sz = CAST_S32(mWidgets.size());
- for (i = 0; i < sz; ++ i)
- {
- if (mWidgets[i] == mFocusedWidget)
- focusedWidget = i;
- }
- const int focused = focusedWidget;
- bool done = false;
-
- // i is a counter that ensures that the following loop
- // won't get stuck in an infinite loop
- i = sz;
- do
- {
- -- focusedWidget;
-
- if (i == 0)
- {
- focusedWidget = -1;
- break;
- }
-
- -- i;
-
- if (focusedWidget <= 0)
- focusedWidget = sz - 1;
-
- if (focusedWidget == focused)
- return;
-
- const Widget *const widget = mWidgets.at(focusedWidget);
- if (widget->isFocusable() && widget->isTabInEnabled() &&
- ((mModalFocusedWidget == nullptr) || widget->isModalFocused()))
- {
- done = true;
- }
- }
- while (!done);
-
- if (focusedWidget >= 0)
- {
- mFocusedWidget = mWidgets.at(focusedWidget);
- Event focusEvent(mFocusedWidget);
- distributeFocusGainedEvent(focusEvent);
- }
-
- if (focused >= 0)
- {
- Event focusEvent(mWidgets.at(focused));
- distributeFocusLostEvent(focusEvent);
- }
-
- checkForWindow();
-}
-
-void FocusHandler::checkForWindow() const
-{
- if (mFocusedWidget != nullptr)
- {
- Widget *widget = mFocusedWidget->getParent();
-
- while (widget != nullptr)
- {
- Window *const window = dynamic_cast<Window*>(widget);
-
- if (window != nullptr)
- {
- window->requestMoveToTop();
- break;
- }
-
- widget = widget->getParent();
- }
- }
-}
-
-void FocusHandler::distributeFocusGainedEvent(const Event &focusEvent)
-{
- if (gui != nullptr)
- gui->distributeGlobalFocusGainedEvent(focusEvent);
-
- const Widget *const sourceWidget = focusEvent.getSource();
-
- if (sourceWidget == nullptr)
- return;
- std::list<FocusListener*> focusListeners
- = sourceWidget->getFocusListeners();
-
- // Send the event to all focus listeners of the widget.
- for (std::list<FocusListener*>::const_iterator
- it = focusListeners.begin();
- it != focusListeners.end();
- ++ it)
- {
- (*it)->focusGained(focusEvent);
- }
-}
-
-void FocusHandler::requestFocus(const Widget *const widget)
-{
- if ((widget == nullptr) || widget == mFocusedWidget)
- return;
-
- int toBeFocusedIndex = -1;
- for (unsigned int i = 0, fsz = CAST_U32(
- mWidgets.size()); i < fsz; ++i)
- {
- if (mWidgets[i] == widget)
- {
- toBeFocusedIndex = i;
- break;
- }
- }
-
- if (toBeFocusedIndex < 0)
- return;
-
- Widget *const oldFocused = mFocusedWidget;
-
- if (oldFocused != widget)
- {
- mFocusedWidget = mWidgets.at(toBeFocusedIndex);
-
- if (oldFocused != nullptr)
- {
- Event focusEvent(oldFocused);
- distributeFocusLostEvent(focusEvent);
- }
-
- Event focusEvent(mWidgets.at(toBeFocusedIndex));
- distributeFocusGainedEvent(focusEvent);
- }
-}
-
-void FocusHandler::requestModalMouseInputFocus(Widget *const widget)
-{
- if ((mModalMouseInputFocusedWidget != nullptr)
- && mModalMouseInputFocusedWidget != widget)
- {
- return;
- }
-
- mModalMouseInputFocusedWidget = widget;
-}
-
-void FocusHandler::releaseModalMouseInputFocus(const Widget *const widget)
-{
- if (mModalMouseInputFocusedWidget == widget)
- mModalMouseInputFocusedWidget = nullptr;
-}
-
-Widget* FocusHandler::getFocused() const
-{
- return mFocusedWidget;
-}
-
-Widget* FocusHandler::getModalFocused() const
-{
- return mModalFocusedWidget;
-}
-
-Widget* FocusHandler::getModalMouseInputFocused() const
-{
- return mModalMouseInputFocusedWidget;
-}
-
-void FocusHandler::focusNext()
-{
- int i;
- int focusedWidget = -1;
- const int sz = CAST_S32(mWidgets.size());
- for (i = 0; i < sz; ++i)
- {
- if (mWidgets[i] == mFocusedWidget)
- focusedWidget = i;
- }
- const int focused = focusedWidget;
-
- // i is a counter that ensures that the following loop
- // won't get stuck in an infinite loop
- i = sz;
- do
- {
- ++ focusedWidget;
-
- if (i == 0)
- {
- focusedWidget = -1;
- break;
- }
-
- -- i;
-
- if (focusedWidget >= sz)
- focusedWidget = 0;
-
- if (focusedWidget == focused)
- return;
- }
- while (!mWidgets.at(focusedWidget)->isFocusable());
-
- if (focusedWidget >= 0)
- {
- mFocusedWidget = mWidgets.at(focusedWidget);
-
- Event focusEvent(mFocusedWidget);
- distributeFocusGainedEvent(focusEvent);
- }
-
- if (focused >= 0)
- {
- Event focusEvent(mWidgets.at(focused));
- distributeFocusLostEvent(focusEvent);
- }
-}
-
-void FocusHandler::focusPrevious()
-{
- if (mWidgets.empty())
- {
- mFocusedWidget = nullptr;
- return;
- }
-
- int i;
- int focusedWidget = -1;
- const int sz = CAST_S32(mWidgets.size());
- for (i = 0; i < sz; ++ i)
- {
- if (mWidgets[i] == mFocusedWidget)
- focusedWidget = i;
- }
- const int focused = focusedWidget;
-
- // i is a counter that ensures that the following loop
- // won't get stuck in an infinite loop
- i = sz;
- do
- {
- -- focusedWidget;
-
- if (i == 0)
- {
- focusedWidget = -1;
- break;
- }
-
- -- i;
-
- if (focusedWidget <= 0)
- focusedWidget = sz - 1;
-
- if (focusedWidget == focused)
- return;
- }
- while (!mWidgets.at(focusedWidget)->isFocusable());
-
- if (focusedWidget >= 0)
- {
- mFocusedWidget = mWidgets.at(focusedWidget);
- Event focusEvent(mFocusedWidget);
- distributeFocusGainedEvent(focusEvent);
- }
-
- if (focused >= 0)
- {
- Event focusEvent(mWidgets.at(focused));
- distributeFocusLostEvent(focusEvent);
- }
-}
-
-bool FocusHandler::isFocused(const Widget *const widget) const
-{
- return mFocusedWidget == widget;
-}
-
-void FocusHandler::add(Widget *const widget)
-{
- mWidgets.push_back(widget);
-}
-
-void FocusHandler::focusNone()
-{
- if (mFocusedWidget != nullptr)
- {
- Widget *const focused = mFocusedWidget;
- mFocusedWidget = nullptr;
-
- Event focusEvent(focused);
- distributeFocusLostEvent(focusEvent);
- }
-}
-
-void FocusHandler::distributeFocusLostEvent(const Event& focusEvent)
-{
- const Widget *const sourceWidget = focusEvent.getSource();
- if (sourceWidget == nullptr)
- return;
-
- std::list<FocusListener*> focusListeners
- = sourceWidget->getFocusListeners();
-
- // Send the event to all focus listeners of the widget.
- for (std::list<FocusListener*>::const_iterator
- it = focusListeners.begin();
- it != focusListeners.end();
- ++ it)
- {
- (*it)->focusLost(focusEvent);
- }
-}
-
-Widget* FocusHandler::getDraggedWidget() const
-{
- return mDraggedWidget;
-}
-
-void FocusHandler::setDraggedWidget(Widget *const draggedWidget)
-{
- mDraggedWidget = draggedWidget;
-}
-
-Widget* FocusHandler::getLastWidgetWithMouse() const
-{
- return mLastWidgetWithMouse;
-}
-
-void FocusHandler::setLastWidgetWithMouse(Widget *const lastWidgetWithMouse)
-{
- mLastWidgetWithMouse = lastWidgetWithMouse;
-}
-
-Widget* FocusHandler::getLastWidgetWithModalFocus() const
-{
- return mLastWidgetWithModalFocus;
-}
-
-void FocusHandler::setLastWidgetWithModalFocus(Widget *const widget)
-{
- mLastWidgetWithModalFocus = widget;
-}
-
-Widget* FocusHandler::getLastWidgetWithModalMouseInputFocus() const
-{
- return mLastWidgetWithModalMouseInputFocus;
-}
-
-void FocusHandler::setLastWidgetWithModalMouseInputFocus(Widget *const widget)
-{
- mLastWidgetWithModalMouseInputFocus = widget;
-}
-
-Widget* FocusHandler::getLastWidgetPressed() const
-{
- return mLastWidgetPressed;
-}
-
-void FocusHandler::setLastWidgetPressed(Widget *const lastWidgetPressed)
-{
- mLastWidgetPressed = lastWidgetPressed;
-}
diff --git a/src/gui/focushandler.h b/src/gui/focushandler.h
deleted file mode 100644
index 248ae8f71..000000000
--- a/src/gui/focushandler.h
+++ /dev/null
@@ -1,410 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GUI_FOCUSHANDLER_H
-#define GUI_FOCUSHANDLER_H
-
-#include "utils/vector.h"
-
-#include <list>
-
-#include "localconsts.h"
-
-class Event;
-class Widget;
-
-/**
- * The focus handler. This focus handler does exactly the same as the Guichan
- * focus handler, but keeps a stack of modal widgets to be able to handle
- * multiple modal focus requests.
- */
-class FocusHandler final
-{
- public:
- FocusHandler();
-
- A_DELETE_COPY(FocusHandler)
-
- /**
- * Requests focus for a widget. Focus will only be granted to a widget
- * if it's focusable and if no other widget has modal focus.
- * If a widget receives focus a focus event will be sent to the
- * focus listeners of the widget.
- *
- * @param widget The widget to request focus for.
- * @see isFocused, Widget::requestFocus
- */
- void requestFocus(const Widget *const widget);
-
- /**
- * Requests modal focus for a widget. Focus will only be granted
- * to a widget if it's focusable and if no other widget has modal
- * focus.
- *
- * @param widget The widget to request modal focus for.
- * @throws Exception when another widget already has modal focus.
- * @see releaseModalFocus, Widget::requestModalFocus
- */
- void requestModalFocus(Widget *const widget);
-
- /**
- * Requests modal mouse input focus for a widget. Focus will only
- * be granted to a widget if it's focusable and if no other widget
- * has modal mouse input focus.
- *
- * Modal mouse input focus means no other widget then the widget with
- * modal mouse input focus will receive mouse input. The widget with
- * modal mouse input focus will also receive mouse input no matter what
- * the mouse input is or where the mouse input occurs.
- *
- * @param widget The widget to focus for modal mouse input focus.
- * @throws Exception when another widget already has modal mouse input
- * focus.
- * @see releaseModalMouseInputFocus, Widget::requestModalMouseInputFocus
- */
- void requestModalMouseInputFocus(Widget *const widget);
-
- /**
- * Releases modal focus if the widget has modal focus.
- * If the widget doesn't have modal focus no relase will occur.
- *
- * @param widget The widget to release modal focus for.
- * @see reuqestModalFocus, Widget::releaseModalFocus
- */
- void releaseModalFocus(Widget *const widget);
-
- /**
- * Releases modal mouse input focus if the widget has modal mouse input
- * focus. If the widget doesn't have modal mouse input focus no relase
- * will occur.
- *
- * @param widget the widget to release modal mouse input focus for.
- * @see requestModalMouseInputFocus, Widget::releaseModalMouseInputFocus
- */
- void releaseModalMouseInputFocus(const Widget *const widget);
-
- /**
- * Checks if a widget is focused.
- *
- * @param widget The widget to check.
- * @return True if the widget is focused, false otherwise.
- * @see Widget::isFocused
- */
- bool isFocused(const Widget *const widget) const;
-
- /**
- * Gets the widget with focus.
- *
- * @return The widget with focus. NULL if no widget has focus.
- */
- Widget* getFocused() const A_WARN_UNUSED;
-
- /**
- * Gets the widget with modal focus.
- *
- * @return The widget with modal focus. NULL if no widget has
- * modal focus.
- */
- Widget* getModalFocused() const A_WARN_UNUSED;
-
- /**
- * Gets the widget with modal mouse input focus.
- *
- * @return The widget with modal mouse input focus. NULL if
- * no widget has modal mouse input focus.
- */
- Widget* getModalMouseInputFocused() const A_WARN_UNUSED;
-
- /**
- * Focuses the next widget added to a conainer.
- * If no widget has focus the first widget gets focus. The order
- * in which the widgets are focused is determined by the order
- * they were added to a container.
- *
- * @see focusPrevious
- */
- void focusNext();
-
- /**
- * Focuses the previous widget added to a contaienr.
- * If no widget has focus the first widget gets focus. The order
- * in which the widgets are focused is determined by the order
- * they were added to a container.
- *
- * @see focusNext
- */
- void focusPrevious();
-
- /**
- * Adds a widget to by handles by the focus handler.
- *
- * @param widget The widget to add.
- * @see remove
- */
- void add(Widget *const widget);
-
- /**
- * Removes a widget from the focus handler.
- *
- * @param widget The widget to remove.
- * @see add
- */
- void remove(Widget *const widget);
-
- /**
- * Focuses nothing. A focus event will also be sent to the
- * focused widget's focus listeners if a widget has focus.
- */
- void focusNone();
-
- /**
- * Focuses the next widget which allows tabbing in unless
- * the current focused Widget disallows tabbing out.
- *
- * @see tabPrevious
- */
- void tabNext();
-
- /**
- * Focuses the previous widget which allows tabbing in unless
- * current focused widget disallows tabbing out.
- *
- * @see tabNext
- */
- void tabPrevious();
-
- /**
- * Gets the widget being dragged. Used by the Gui class to
- * keep track of the dragged widget.
- *
- * @return the widget being dragged.
- * @see setDraggedWidget
- */
- Widget* getDraggedWidget() const A_WARN_UNUSED;
-
- /**
- * Sets the widget being dragged. Used by the Gui class to
- * keep track of the dragged widget.
- *
- * @param draggedWidget The widget being dragged.
- * @see getDraggedWidget
- */
- void setDraggedWidget(Widget *const draggedWidget);
-
- /**
- * Gets the last widget with the mouse. Used by the Gui class
- * to keep track the last widget with the mouse.
- *
- * @return The last widget with the mouse.
- * @see setLastWidgetWithMouse
- */
- Widget* getLastWidgetWithMouse() const A_WARN_UNUSED;
-
- /**
- * Sets the last widget with the mouse. Used by the Gui class
- * to keep track the last widget with the mouse.
- *
- * @param lastWidgetWithMouse The last widget with the mouse.
- * @see getLastWidgetWithMouse
- */
- void setLastWidgetWithMouse(Widget *const lastWidgetWithMouse);
-
- /**
- * Gets the last widget with modal focus.
- *
- * @return The last widget with modal focus.
- * @see setLastWidgetWithModalFocus
- */
- Widget* getLastWidgetWithModalFocus() const A_WARN_UNUSED;
-
- /**
- * Sets the last widget with modal focus.
- *
- * @param widget The last widget with modal focus.
- * @see getLastWidgetWithModalFocus
- */
- void setLastWidgetWithModalFocus(Widget *const widget);
-
- /**
- * Gets the last widget with modal mouse input focus.
- *
- * @return The last widget with modal mouse input focus.
- * @see setLastWidgetWithModalMouseInputFocus
- */
- Widget* getLastWidgetWithModalMouseInputFocus() const A_WARN_UNUSED;
-
- /**
- * Sets the last widget with modal mouse input focus.
- *
- * @param widget The last widget with modal mouse input focus.
- * @see getLastWidgetWithModalMouseInputFocus
- */
- void setLastWidgetWithModalMouseInputFocus(Widget *const widget);
-
- /**
- * Gets the last widget pressed. Used by the Gui class to keep track
- * of pressed widgets.
- *
- * @return The last widget pressed.
- * @see setLastWidgetPressed
- */
- Widget* getLastWidgetPressed() const A_WARN_UNUSED;
-
- /**
- * Sets the last widget pressed. Used by the Gui class to keep track
- * of pressed widgets.
- *
- * @param lastWidgetPressed The last widget pressed.
- * @see getLastWidgetPressed
- */
- void setLastWidgetPressed(Widget *const lastWidgetPressed);
-
- private:
- /**
- * Checks to see if the widget tabbed to is in a window, and if it is,
- * it requests the window be moved to the top.
- */
- void checkForWindow() const;
-
- /**
- * Distributes a focus lost event.
- *
- * @param focusEvent the event to distribute.
- */
- static void distributeFocusLostEvent(const Event& focusEvent);
-
- /**
- * Distributes a focus gained event.
- *
- * @param focusEvent the event to distribute.
- */
- static void distributeFocusGainedEvent(const Event& focusEvent);
-
- /**
- * Typedef.
- */
- typedef STD_VECTOR<Widget*> WidgetVector;
-
- /**
- * Typedef.
- */
- typedef WidgetVector::iterator WidgetIterator;
-
- /**
- * Holds the widgets currently being handled by the
- * focus handler.
- */
- WidgetVector mWidgets;
-
- /**
- * Holds the focused widget. NULL if no widget has focus.
- */
- Widget* mFocusedWidget;
-
- /**
- * Holds the modal focused widget. NULL if no widget has
- * modal focused.
- */
- Widget* mModalFocusedWidget;
-
- /**
- * Holds the modal mouse input focused widget. NULL if no widget
- * is being dragged.
- */
- Widget* mModalMouseInputFocusedWidget;
-
- /**
- * Holds the dragged widget. NULL if no widget is
- * being dragged.
- */
- Widget* mDraggedWidget;
-
- /**
- * Holds the last widget with the mouse.
- */
- Widget* mLastWidgetWithMouse;
-
- /**
- * Holds the last widget with modal focus.
- */
- Widget* mLastWidgetWithModalFocus;
-
- /**
- * Holds the last widget with modal mouse input focus.
- */
- Widget* mLastWidgetWithModalMouseInputFocus;
-
- /**
- * Holds the last widget pressed.
- */
- Widget* mLastWidgetPressed;
-
- /**
- * Stack of widgets that have requested modal forcus.
- */
- std::list<Widget*> mModalStack;
-};
-
-#endif // GUI_FOCUSHANDLER_H
diff --git a/src/gui/fonts/font.cpp b/src/gui/fonts/font.cpp
deleted file mode 100644
index 2ac2bcb4a..000000000
--- a/src/gui/fonts/font.cpp
+++ /dev/null
@@ -1,499 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * 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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "gui/fonts/font.h"
-
-#include "fs/files.h"
-#include "fs/paths.h"
-
-#include "fs/virtfs/tools.h"
-#ifdef USE_SDL2
-#include "fs/virtfs/rwops.h"
-#endif // USE_SDL2
-
-#include "gui/fonts/textchunk.h"
-
-#include "render/graphics.h"
-
-#include "resources/imagehelper.h"
-
-#include "resources/image/image.h"
-
-#include "utils/checkutils.h"
-#include "utils/delete2.h"
-#include "utils/sdlcheckutils.h"
-#include "utils/stringutils.h"
-#include "utils/timer.h"
-
-#include "debug.h"
-
-const unsigned int CACHE_SIZE = 256;
-const unsigned int CACHE_SIZE_SMALL1 = 2;
-const unsigned int CACHE_SIZE_SMALL2 = 50;
-const unsigned int CACHE_SIZE_SMALL3 = 170;
-const unsigned int CLEAN_TIME = 7;
-
-bool Font::mSoftMode(false);
-
-extern char *strBuf;
-
-static int fontCounter;
-
-Font::Font(std::string filename,
- int size,
- const int style) :
- mFont(nullptr),
- mCreateCounter(0),
- mDeleteCounter(0),
- mCleanTime(cur_time + CLEAN_TIME)
-{
- if (fontCounter == 0)
- {
- mSoftMode = imageHelper->useOpenGL() == RENDER_SOFTWARE;
- if (TTF_Init() == -1)
- {
- logger->error("Unable to initialize SDL_ttf: " +
- std::string(SDL_GetError()));
- }
- }
-
- if (size < 4)
- {
- reportAlways("Error: requested load font %s with size %d",
- filename.c_str(),
- size);
- size = 4;
- }
-
- if (fontCounter == 0)
- {
- strBuf = new char[65535];
- memset(strBuf, 0, 65535);
- }
-
- ++fontCounter;
-
- fixDirSeparators(filename);
- logger->log("Attempt to load font: %s",
- filename.c_str());
- mFont = openFont(filename.c_str(), size);
-
- if (mFont == nullptr)
- {
- logger->log("Error normal loading font " + filename);
-
- filename = "fonts/dejavusans.ttf";
- mFont = openFont(fixDirSeparators(filename).c_str(), size);
- if (mFont == nullptr)
- {
-#ifdef UNITTESTS
- reportAlways("Font load failed %s",
- filename.c_str());
-#endif // UNITTESTS
- logger->error("Font::Font: " +
- std::string(SDL_GetError()));
- }
- else
- {
- logger->log("Loaded fallback font %s, %d",
- filename.c_str(),
- size);
- }
- }
- else
- {
- logger->log("Loaded font %s, %d",
- filename.c_str(),
- size);
- }
-
- TTF_SetFontStyle(mFont, style);
-}
-
-Font::~Font()
-{
- TTF_CloseFont(mFont);
- mFont = nullptr;
- --fontCounter;
- clear();
-
- if (fontCounter == 0)
- {
- TTF_Quit();
- delete []strBuf;
- }
-}
-
-TTF_Font *Font::openFont(const char *const name,
- const int size)
-{
-#ifdef USE_SDL2
- SDL_RWops *const rw = VirtFs::rwopsOpenRead(name);
- if (rw)
- {
- logger->log("Loading virtfs font file: %s",
- name);
- return TTF_OpenFontIndexRW(rw, 1, size, 0);
- }
-#endif
- const std::string path = VirtFs::getPath(name);
- if (Files::existsLocal(path) == false)
- {
-#ifndef UNITTESTS
- // +++ in future need trigger assert in unit tests here too
- reportAlways("Font::openFont font not exists: %s",
- path.c_str());
-#endif // UNITTESTS
- return nullptr;
- }
- logger->log("Loading physical font file: %s",
- path.c_str());
- return TTF_OpenFontIndex(path.c_str(),
- size, 0);
-}
-
-void Font::loadFont(std::string filename,
- const int size,
- const int style)
-{
- if (fontCounter == 0 && TTF_Init() == -1)
- {
- logger->log("Unable to initialize SDL_ttf: " +
- std::string(SDL_GetError()));
- return;
- }
-
- fixDirSeparators(filename);
- TTF_Font *const font = openFont(filename.c_str(), size);
-
- if (font == nullptr)
- {
- logger->log("Font::Font: " +
- std::string(SDL_GetError()));
- return;
- }
-
- if (mFont != nullptr)
- TTF_CloseFont(mFont);
-
- mFont = font;
- TTF_SetFontStyle(mFont, style);
- clear();
-}
-
-void Font::clear()
-{
- for (size_t f = 0; f < CACHES_NUMBER; f ++)
- mCache[f].clear();
-}
-
-void Font::drawString(Graphics *const graphics,
- Color col,
- const Color &col2,
- const std::string &text,
- const int x, const int y)
-{
- BLOCK_START("Font::drawString")
- if (text.empty())
- {
- BLOCK_END("Font::drawString")
- return;
- }
-
-// Color col = graphics->getColor();
-// const Color &col2 = graphics->getColor2();
- const float alpha = static_cast<float>(col.a) / 255.0F;
-
- /* The alpha value is ignored at string generation so avoid caching the
- * same text with different alpha values.
- */
- col.a = 255;
-
- const unsigned char chr = text[0];
- TextChunkList *const cache = &mCache[chr];
-
- std::map<TextChunkSmall, TextChunk*> &search = cache->search;
- std::map<TextChunkSmall, TextChunk*>::iterator i
- = search.find(TextChunkSmall(text, col, col2));
- if (i != search.end())
- {
- TextChunk *const chunk2 = (*i).second;
- cache->moveToFirst(chunk2);
- Image *const image = chunk2->img;
- if (image != nullptr)
- {
- image->setAlpha(alpha);
- graphics->drawImage(image, x, y);
- }
- }
- else
- {
- if (cache->size >= CACHE_SIZE)
- {
-#ifdef DEBUG_FONT_COUNTERS
- mDeleteCounter ++;
-#endif // DEBUG_FONT_COUNTERS
-
- cache->removeBack();
- }
-#ifdef DEBUG_FONT_COUNTERS
- mCreateCounter ++;
-#endif // DEBUG_FONT_COUNTERS
-
- TextChunk *chunk2 = new TextChunk(text, col, col2, this);
-
- chunk2->generate(mFont, alpha);
- cache->insertFirst(chunk2);
-
- const Image *const image = chunk2->img;
- if (image != nullptr)
- graphics->drawImage(image, x, y);
- }
- BLOCK_END("Font::drawString")
-}
-
-void Font::slowLogic(const int rnd)
-{
- BLOCK_START("Font::slowLogic")
- if (mCleanTime == 0)
- {
- mCleanTime = cur_time + CLEAN_TIME + rnd;
- }
- else if (mCleanTime < cur_time)
- {
- doClean();
- mCleanTime = cur_time + CLEAN_TIME + rnd;
- }
- BLOCK_END("Font::slowLogic")
-}
-
-int Font::getWidth(const std::string &text) const
-{
- if (text.empty())
- return 0;
-
- const unsigned char chr = text[0];
- TextChunkList *const cache = &mCache[chr];
-
- std::map<std::string, TextChunk*> &search = cache->searchWidth;
- std::map<std::string, TextChunk*>::iterator i = search.find(text);
- if (i != search.end())
- {
- TextChunk *const chunk = (*i).second;
- cache->moveToFirst(chunk);
- const Image *const image = chunk->img;
- if (image != nullptr)
- return image->getWidth();
- return 0;
- }
-
- // if string was not drawed
- int w, h;
- getSafeUtf8String(text, strBuf);
- TTF_SizeUTF8(mFont, strBuf, &w, &h);
- return w;
-}
-
-int Font::getHeight() const
-{
- return TTF_FontHeight(mFont);
-}
-
-void Font::doClean()
-{
- for (unsigned int f = 0; f < CACHES_NUMBER; f ++)
- {
- TextChunkList *const cache = &mCache[f];
- const size_t size = CAST_SIZE(cache->size);
-#ifdef DEBUG_FONT_COUNTERS
- logger->log("ptr: %u, size: %ld", f, size);
-#endif // DEBUG_FONT_COUNTERS
-
- if (size > CACHE_SIZE_SMALL3)
- {
-#ifdef DEBUG_FONT_COUNTERS
- mDeleteCounter += 100;
-#endif // DEBUG_FONT_COUNTERS
-
- cache->removeBack(100);
-#ifdef DEBUG_FONT_COUNTERS
- logger->log("delete3");
-#endif // DEBUG_FONT_COUNTERS
- }
- else if (size > CACHE_SIZE_SMALL2)
- {
-#ifdef DEBUG_FONT_COUNTERS
- mDeleteCounter += 20;
-#endif // DEBUG_FONT_COUNTERS
-
- cache->removeBack(20);
-#ifdef DEBUG_FONT_COUNTERS
- logger->log("delete2");
-#endif // DEBUG_FONT_COUNTERS
- }
- else if (size > CACHE_SIZE_SMALL1)
- {
-#ifdef DEBUG_FONT_COUNTERS
- mDeleteCounter ++;
-#endif // DEBUG_FONT_COUNTERS
-
- cache->removeBack();
-#ifdef DEBUG_FONT_COUNTERS
- logger->log("delete1");
-#endif // DEBUG_FONT_COUNTERS
- }
- }
-}
-
-int Font::getStringIndexAt(const std::string& text, const int x) const
-{
- const size_t sz = text.size();
- for (size_t i = 0; i < sz; ++i)
- {
- if (getWidth(text.substr(0, i)) > x)
- return CAST_S32(i);
- }
-
- return CAST_S32(sz);
-}
-
-const TextChunkList *Font::getCache() const noexcept2
-{
- return mCache;
-}
-
-void Font::generate(TextChunk &chunk)
-{
- const std::string &text = chunk.text;
- if (text.empty())
- return;
-
- const unsigned char chr = text[0];
- TextChunkList *const cache = &mCache[chr];
- Color &col = chunk.color;
- Color &col2 = chunk.color2;
- const int oldAlpha = col.a;
- col.a = 255;
-
- TextChunkSmall key(text, col, col2);
- std::map<TextChunkSmall, TextChunk*> &search = cache->search;
- std::map<TextChunkSmall, TextChunk*>::iterator i = search.find(key);
- if (i != search.end())
- {
- TextChunk *const chunk2 = (*i).second;
- cache->moveToFirst(chunk2);
-// search.erase(key);
- cache->remove(chunk2);
- chunk.img = chunk2->img;
- chunk2->img = nullptr;
- delete chunk2;
-// logger->log("cached image: " + chunk.text);
- }
- else
- {
- if (cache->size >= CACHE_SIZE)
- {
-#ifdef DEBUG_FONT_COUNTERS
- mDeleteCounter ++;
-#endif // DEBUG_FONT_COUNTERS
-
- cache->removeBack();
- }
-#ifdef DEBUG_FONT_COUNTERS
- mCreateCounter ++;
-#endif // DEBUG_FONT_COUNTERS
-
- const float alpha = static_cast<float>(chunk.color.a) / 255.0F;
- chunk.generate(mFont, alpha);
-// logger->log("generate image: " + chunk.text);
- }
- col.a = oldAlpha;
-}
-
-void Font::insertChunk(TextChunk *const chunk)
-{
- if ((chunk == nullptr) || chunk->text.empty() || (chunk->img == nullptr))
- return;
-// logger->log("insert chunk: text=%s, color: %d,%d,%d",
-// chunk->text.c_str(), chunk->color.r, chunk->color.g, chunk->color.b);
- const unsigned char chr = chunk->text[0];
- TextChunkList *const cache = &mCache[chr];
-
- std::map<TextChunkSmall, TextChunk*> &search = cache->search;
- std::map<TextChunkSmall, TextChunk*>::iterator i
- = search.find(TextChunkSmall(chunk->text,
- chunk->color, chunk->color2));
- if (i != search.end())
- {
- delete2(chunk->img);
- return;
- }
-
- TextChunk *const chunk2 = new TextChunk(chunk->text,
- chunk->color, chunk->color2, chunk->textFont);
- chunk2->img = chunk->img;
- cache->insertFirst(chunk2);
-}
diff --git a/src/gui/fonts/font.h b/src/gui/fonts/font.h
deleted file mode 100644
index 4f3670374..000000000
--- a/src/gui/fonts/font.h
+++ /dev/null
@@ -1,158 +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
- * Copyright (C) 2009 Aethyra Development Team
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GUI_FONTS_FONT_H
-#define GUI_FONTS_FONT_H
-
-#include "gui/fonts/textchunklist.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_ttf.h>
-PRAGMA48(GCC diagnostic pop)
-
-#include "localconsts.h"
-
-class Graphics;
-
-const unsigned int CACHES_NUMBER = 256;
-
-/**
- * A wrapper around SDL_ttf for allowing the use of TrueType fonts.
- *
- * <b>NOTE:</b> This class initializes SDL_ttf as necessary.
- */
-class Font final
-{
- public:
- Font(std::string filename,
- int size,
- const int style);
-
- A_DELETE_COPY(Font)
-
- ~Font();
-
- void loadFont(std::string filename,
- const int size,
- const int style) restrict2;
-
- int getWidth(const std::string &text) const restrict2 A_WARN_UNUSED;
-
- int getHeight() const restrict2 A_WARN_UNUSED;
-
- const TextChunkList *getCache() const restrict2 noexcept2
- A_CONST A_WARN_UNUSED;
-
- /**
- * @see Font::drawString
- */
- void drawString(Graphics *restrict const graphics,
- Color col,
- const Color &restrict col2,
- const std::string &restrict text,
- const int x,
- const int y) restrict2 A_NONNULL(2);
-
- void clear() restrict2;
-
- void doClean() restrict2;
-
- void slowLogic(const int rnd) restrict2;
-
- unsigned int getCreateCounter() const restrict2 noexcept2 A_WARN_UNUSED
- { return mCreateCounter; }
-
- unsigned int getDeleteCounter() const restrict2 noexcept2 A_WARN_UNUSED
- { return mDeleteCounter; }
-
- int getStringIndexAt(const std::string &restrict text,
- const int x) const restrict2 A_WARN_UNUSED;
-
- void generate(TextChunk &restrict chunk) restrict2;
-
- void insertChunk(TextChunk *const chunk) restrict2;
-
- static bool mSoftMode;
-
- private:
- static TTF_Font *openFont(const char *restrict const name,
- const int size);
-
- TTF_Font *restrict mFont;
- unsigned int mCreateCounter;
- unsigned int mDeleteCounter;
-
- // Word surfaces cache
- time_t mCleanTime;
- mutable TextChunkList mCache[CACHES_NUMBER];
-};
-
-#ifdef UNITTESTS
-extern int textChunkCnt;
-#endif // UNITTESTS
-
-#endif // GUI_FONTS_FONT_H
diff --git a/src/gui/fonts/textchunk.cpp b/src/gui/fonts/textchunk.cpp
deleted file mode 100644
index 22dcd18dc..000000000
--- a/src/gui/fonts/textchunk.cpp
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * 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 "gui/fonts/textchunk.h"
-
-#include "sdlshared.h"
-
-#include "gui/fonts/font.h"
-
-#include "resources/surfaceimagehelper.h"
-
-#include "resources/image/image.h"
-
-#include "utils/delete2.h"
-#include "utils/sdlcheckutils.h"
-#include "utils/stringutils.h"
-
-#include "debug.h"
-
-namespace
-{
- const int OUTLINE_SIZE = 1;
-} // namespace
-
-char *restrict strBuf = nullptr;
-
-#ifdef UNITTESTS
-int textChunkCnt = 0;
-#endif // UNITTESTS
-
-TextChunk::TextChunk() :
- img(nullptr),
- textFont(nullptr),
- text(),
- color(),
- color2(),
- prev(nullptr),
- next(nullptr)
-{
-#ifdef UNITTESTS
- textChunkCnt ++;
-#endif // UNITTESTS
-}
-
-TextChunk::TextChunk(const std::string &restrict text0,
- const Color &restrict color0,
- const Color &restrict color1,
- Font *restrict const font) :
- img(nullptr),
- textFont(font),
- text(text0),
- color(color0),
- color2(color1),
- prev(nullptr),
- next(nullptr)
-{
-#ifdef UNITTESTS
- textChunkCnt ++;
-#endif // UNITTESTS
-}
-
-TextChunk::~TextChunk()
-{
- delete2(img);
-#ifdef UNITTESTS
- textChunkCnt --;
-#endif // UNITTESTS
-}
-
-bool TextChunk::operator==(const TextChunk &restrict chunk) const
-{
- return chunk.text == text && chunk.color == color
- && chunk.color2 == color2;
-}
-
-void TextChunk::generate(TTF_Font *restrict const font,
- const float alpha)
-{
- BLOCK_START("TextChunk::generate")
- SDL_Color sdlCol;
- sdlCol.b = CAST_U8(color.b);
- sdlCol.r = CAST_U8(color.r);
- sdlCol.g = CAST_U8(color.g);
-#ifdef USE_SDL2
- sdlCol.a = 255;
-#else // USE_SDL2
-
- sdlCol.unused = 0;
-#endif // USE_SDL2
-
- getSafeUtf8String(text, strBuf);
-
- SDL_Surface *surface = MTTF_RenderUTF8_Blended(
- font, strBuf, sdlCol);
-
- if (surface == nullptr)
- {
- img = nullptr;
- BLOCK_END("TextChunk::generate")
- return;
- }
-
- const int width = surface->w;
- const int height = surface->h;
-
- if (color.r != color2.r || color.g != color2.g
- || color.b != color2.b)
- { // outlining
- SDL_Color sdlCol2;
- SDL_Surface *const background = imageHelper->create32BitSurface(
- width, height);
- if (background == nullptr)
- {
- img = nullptr;
- MSDL_FreeSurface(surface);
- BLOCK_END("TextChunk::generate")
- return;
- }
- sdlCol2.b = CAST_U8(color2.b);
- sdlCol2.r = CAST_U8(color2.r);
- sdlCol2.g = CAST_U8(color2.g);
-#ifdef USE_SDL2
- sdlCol2.a = 255;
-#else // USE_SDL2
-
- sdlCol2.unused = 0;
-#endif // USE_SDL2
-
- SDL_Surface *const surface2 = MTTF_RenderUTF8_Blended(
- font, strBuf, sdlCol2);
- if (surface2 == nullptr)
- {
- img = nullptr;
- MSDL_FreeSurface(surface);
- BLOCK_END("TextChunk::generate")
- return;
- }
- SDL_Rect rect =
- {
- OUTLINE_SIZE,
- 0,
- static_cast<Uint16>(surface->w),
- static_cast<Uint16>(surface->h)
- };
- SurfaceImageHelper::combineSurface(surface2, nullptr,
- background, &rect);
- rect.x = -OUTLINE_SIZE;
- SurfaceImageHelper::combineSurface(surface2, nullptr,
- background, &rect);
- rect.x = 0;
- rect.y = -OUTLINE_SIZE;
- SurfaceImageHelper::combineSurface(surface2, nullptr,
- background, &rect);
- rect.y = OUTLINE_SIZE;
- SurfaceImageHelper::combineSurface(surface2, nullptr,
- background, &rect);
- rect.x = 0;
- rect.y = 0;
- SurfaceImageHelper::combineSurface(surface, nullptr,
- background, &rect);
- MSDL_FreeSurface(surface);
- MSDL_FreeSurface(surface2);
- surface = background;
- }
- img = imageHelper->createTextSurface(
- surface, width, height, alpha);
- MSDL_FreeSurface(surface);
-
- BLOCK_END("TextChunk::generate")
-}
-
-void TextChunk::deleteImage()
-{
- if (textFont != nullptr)
- {
- textFont->insertChunk(this);
- img = nullptr;
- }
- else
- {
- delete2(img);
- }
-}
diff --git a/src/gui/fonts/textchunk.h b/src/gui/fonts/textchunk.h
deleted file mode 100644
index bbd50fdff..000000000
--- a/src/gui/fonts/textchunk.h
+++ /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
- * Copyright (C) 2009 Aethyra Development Team
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * 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_FONTS_TEXTCHUNK_H
-#define GUI_FONTS_TEXTCHUNK_H
-
-#include "gui/color.h"
-
-#include <string>
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_ttf.h>
-PRAGMA48(GCC diagnostic pop)
-
-#include "localconsts.h"
-
-class Font;
-class Image;
-
-class TextChunk final
-{
- public:
- TextChunk();
-
- TextChunk(const std::string &restrict text0,
- const Color &restrict color0,
- const Color &restrict color1,
- Font *restrict const font);
-
- A_DELETE_COPY(TextChunk)
-
- ~TextChunk();
-
- bool operator==(const TextChunk &restrict chunk) const restrict2;
-
- void generate(TTF_Font *restrict const font,
- const float alpha) restrict2;
-
- void deleteImage() restrict2;
-
- Image *restrict img;
- Font *restrict textFont;
- std::string text;
- Color color;
- Color color2;
- TextChunk *restrict prev;
- TextChunk *restrict next;
-};
-
-#ifdef UNITTESTS
-extern int textChunkCnt;
-#endif // UNITTESTS
-
-#endif // GUI_FONTS_TEXTCHUNK_H
diff --git a/src/gui/fonts/textchunklist.cpp b/src/gui/fonts/textchunklist.cpp
deleted file mode 100644
index 4ce39406b..000000000
--- a/src/gui/fonts/textchunklist.cpp
+++ /dev/null
@@ -1,153 +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 "gui/fonts/textchunklist.h"
-
-#include "gui/fonts/textchunk.h"
-
-#include "debug.h"
-
-TextChunkList::TextChunkList() :
- start(nullptr),
- end(nullptr),
- size(0),
- search(),
- searchWidth()
-{
-}
-
-void TextChunkList::insertFirst(TextChunk *restrict const item)
-{
- TextChunk *restrict const oldFirst = start;
- if (start != nullptr)
- start->prev = item;
- item->prev = nullptr;
- if (oldFirst != nullptr)
- item->next = oldFirst;
- else
- end = item;
- start = item;
- size ++;
- search[TextChunkSmall(item->text, item->color, item->color2)] = item;
- searchWidth[item->text] = item;
-}
-
-void TextChunkList::moveToFirst(TextChunk *restrict const item)
-{
- if (item == start)
- return;
-
- TextChunk *restrict const oldPrev = item->prev;
- if (oldPrev != nullptr)
- oldPrev->next = item->next;
- TextChunk *restrict const oldNext = item->next;
- if (oldNext != nullptr)
- oldNext->prev = item->prev;
- else
- end = oldPrev;
- TextChunk *restrict const oldFirst = start;
- if (start != nullptr)
- start->prev = item;
- item->prev = nullptr;
- item->next = oldFirst;
- start = item;
-}
-
-void TextChunkList::remove(const TextChunk *restrict const item)
-{
- if (item == nullptr)
- return;
-
- TextChunk *restrict const oldPrev = item->prev;
- TextChunk *restrict const oldNext = item->next;
- if (oldPrev != nullptr)
- oldPrev->next = item->next;
- else
- start = oldNext;
- if (oldNext != nullptr)
- oldNext->prev = item->prev;
- else
- end = oldPrev;
-
- search.erase(TextChunkSmall(item->text,
- item->color, item->color2));
- searchWidth.erase(item->text);
- size --;
-}
-
-void TextChunkList::removeBack()
-{
- TextChunk *restrict oldEnd = end;
- if (oldEnd != nullptr)
- {
- end = oldEnd->prev;
- if (end != nullptr)
- end->next = nullptr;
- else
- start = nullptr;
- search.erase(TextChunkSmall(oldEnd->text,
- oldEnd->color, oldEnd->color2));
- searchWidth.erase(oldEnd->text);
- delete oldEnd;
- size --;
- }
-}
-
-void TextChunkList::removeBack(int n)
-{
- TextChunk *restrict item = end;
- while ((n != 0) && (item != nullptr))
- {
- n --;
- TextChunk *oldEnd = item;
- item = item->prev;
- search.erase(TextChunkSmall(oldEnd->text,
- oldEnd->color, oldEnd->color2));
- searchWidth.erase(oldEnd->text);
- delete oldEnd;
- size --;
- }
- if (item != nullptr)
- {
- item->next = nullptr;
- end = item;
- }
- else
- {
- start = nullptr;
- end = nullptr;
- }
-}
-
-void TextChunkList::clear()
-{
- search.clear();
- searchWidth.clear();
- TextChunk *restrict item = start;
- while (item != nullptr)
- {
- TextChunk *restrict const item2 = item->next;
- delete item;
- item = item2;
- }
- start = nullptr;
- end = nullptr;
- size = 0;
-}
diff --git a/src/gui/fonts/textchunklist.h b/src/gui/fonts/textchunklist.h
deleted file mode 100644
index fff198445..000000000
--- a/src/gui/fonts/textchunklist.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 GUI_FONTS_TEXTCHUNKLIST_H
-#define GUI_FONTS_TEXTCHUNKLIST_H
-
-#include "gui/fonts/textchunksmall.h"
-
-#include <map>
-
-#include "localconsts.h"
-
-class TextChunk;
-
-class TextChunkList final
-{
- public:
- TextChunkList();
-
- A_DELETE_COPY(TextChunkList)
-
- void insertFirst(TextChunk *restrict const item)
- restrict2 A_NONNULL(2);
-
- void moveToFirst(TextChunk *restrict const item)
- restrict2 A_NONNULL(2);
-
- void remove(const TextChunk *restrict const item) restrict2;
-
- void removeBack() restrict2;
-
- void removeBack(int n) restrict2;
-
- void clear() restrict2;
-
- TextChunk *restrict start;
- TextChunk *restrict end;
- uint32_t size;
- std::map<TextChunkSmall, TextChunk*> search;
- std::map<std::string, TextChunk*> searchWidth;
-};
-
-#endif // GUI_FONTS_TEXTCHUNKLIST_H
diff --git a/src/gui/fonts/textchunksmall.cpp b/src/gui/fonts/textchunksmall.cpp
deleted file mode 100644
index 73e8ad386..000000000
--- a/src/gui/fonts/textchunksmall.cpp
+++ /dev/null
@@ -1,83 +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 "gui/fonts/textchunksmall.h"
-
-#include "gui/fonts/font.h"
-
-#include "debug.h"
-
-TextChunkSmall::TextChunkSmall(const std::string &text0,
- const Color &color0,
- const Color &color1) :
- text(text0),
- color(color0),
- color2(color1)
-{
-}
-
-TextChunkSmall::TextChunkSmall(const TextChunkSmall &old) :
- text(old.text),
- color(old.color),
- color2(old.color2)
-{
-}
-
-TextChunkSmall &TextChunkSmall::operator=(const TextChunkSmall &chunk)
-{
- text = chunk.text;
- color = chunk.color;
- color2 = chunk.color2;
- return *this;
-}
-
-bool TextChunkSmall::operator==(const TextChunkSmall &chunk) const
-{
- return chunk.text == text &&
- chunk.color == color &&
- chunk.color2 == color2;
-}
-
-bool TextChunkSmall::operator<(const TextChunkSmall &chunk) const
-{
- if (chunk.text != text)
- return chunk.text > text;
-
- const Color &restrict c = chunk.color;
- if (c.r != color.r)
- return c.r > color.r;
- if (c.g != color.g)
- return c.g > color.g;
- if (c.b != color.b)
- return c.b > color.b;
-
- const Color &restrict c2 = chunk.color2;
- if (c2.r != color2.r)
- return c2.r > color2.r;
- if (c2.g != color2.g)
- return c2.g > color2.g;
- if (c2.b != color2.b)
- return c2.b > color2.b;
-
- if (c.a != color.a && Font::mSoftMode)
- return c.a > color.a;
-
- return false;
-}
diff --git a/src/gui/fonts/textchunksmall.h b/src/gui/fonts/textchunksmall.h
deleted file mode 100644
index 0896c3591..000000000
--- a/src/gui/fonts/textchunksmall.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 GUI_FONTS_TEXTCHUNKSMALL_H
-#define GUI_FONTS_TEXTCHUNKSMALL_H
-
-#include "gui/color.h"
-
-#include <string>
-
-#include "localconsts.h"
-
-class TextChunkSmall final
-{
- public:
- A_DEFAULT_COPY(TextChunkSmall)
-
- TextChunkSmall(const std::string &restrict text0,
- const Color &restrict color0,
- const Color &restrict color1);
-
- TextChunkSmall(const TextChunkSmall &restrict old);
-
- bool operator==(const TextChunkSmall &restrict chunk) const restrict2;
- bool operator<(const TextChunkSmall &restrict chunk) const restrict2;
- TextChunkSmall &operator=(const TextChunkSmall &restrict chunk)
- restrict2;
- std::string text;
- Color color;
- Color color2;
-};
-#endif // GUI_FONTS_TEXTCHUNKSMALL_H
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
deleted file mode 100644
index 3fab73d0a..000000000
--- a/src/gui/gui.cpp
+++ /dev/null
@@ -1,1515 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "gui/gui.h"
-
-#include "gui/focushandler.h"
-#include "gui/sdlinput.h"
-#include "gui/viewport.h"
-
-#include "gui/fonts/font.h"
-
-#include "gui/widgets/label.h"
-#include "gui/widgets/window.h"
-
-#include "gui/widgets/tabs/tab.h"
-
-#ifndef DYECMD
-#include "dragdrop.h"
-#else // DYECMD
-#include "resources/image/image.h"
-#endif // DYECMD
-#include "settings.h"
-
-#include "listeners/focuslistener.h"
-#include "listeners/guiconfiglistener.h"
-#include "listeners/keylistener.h"
-
-#include "input/inputmanager.h"
-
-#include "input/touch/touchmanager.h"
-
-#include "render/renderers.h"
-
-#include "resources/imageset.h"
-
-#include "resources/resourcemanager/resourcemanager.h"
-
-#include "utils/delete2.h"
-#include "utils/foreach.h"
-#include "utils/langs.h"
-#include "utils/sdlsharedhelper.h"
-#include "utils/timer.h"
-
-#include "net/ipc.h"
-
-#include "debug.h"
-
-Gui *gui = nullptr;
-Font *boldFont = nullptr;
-
-Gui::Gui() :
- mTop(nullptr),
- mGraphics(nullptr),
- mInput(nullptr),
- mFocusHandler(new FocusHandler),
- mKeyListeners(),
- mLastMousePressButton(MouseButton::EMPTY),
- mLastMousePressTimeStamp(0U),
- mLastMouseX(0),
- mLastMouseY(0),
- mClickCount(1),
- mLastMouseDragButton(MouseButton::EMPTY),
- mWidgetWithMouseQueue(),
- mConfigListener(new GuiConfigListener(this)),
- mGuiFont(nullptr),
- mInfoParticleFont(nullptr),
- mHelpFont(nullptr),
- mSecureFont(nullptr),
- mNpcFont(nullptr),
- mMouseCursors(nullptr),
- mMouseCursorAlpha(1.0F),
- mMouseInactivityTimer(0),
- mCursorType(Cursor::CURSOR_POINTER),
-#ifdef ANDROID
- mLastMouseRealX(0),
- mLastMouseRealY(0),
-#endif // ANDROID
- mFocusListeners(),
- mForegroundColor(theme->getColor(ThemeColorId::TEXT, 255)),
- mForegroundColor2(theme->getColor(ThemeColorId::TEXT_OUTLINE, 255)),
- mTime(0),
- mTime10(0),
- mCustomCursor(false),
- mDoubleClick(true)
-{
-}
-
-void Gui::postInit(Graphics *const graphics)
-{
- logger->log1("Initializing GUI...");
- // Set graphics
- setGraphics(graphics);
-
- // Set input
- guiInput = new SDLInput;
- setInput(guiInput);
-
- // Set focus handler
- delete mFocusHandler;
- mFocusHandler = new FocusHandler;
-
- // Initialize top GUI widget
- WindowContainer *const guiTop = new WindowContainer(nullptr);
- guiTop->setFocusable(true);
- guiTop->setSize(graphics->mWidth, graphics->mHeight);
- guiTop->setOpaque(Opaque_false);
- Window::setWindowContainer(guiTop);
- setTop(guiTop);
-
- const StringVect langs = getLang();
- const bool isJapan = (!langs.empty() && langs[0].size() > 3
- && langs[0].substr(0, 3) == "ja_");
- const bool isChinese = (!langs.empty() && langs[0].size() > 3
- && langs[0].substr(0, 3) == "zh_");
-
- // Set global font
- const int fontSize = config.getIntValue("fontSize");
- std::string fontFile = config.getValue("font", "");
- if (isJapan)
- {
- fontFile = config.getValue("japanFont", "");
- if (fontFile.empty())
- fontFile = branding.getStringValue("japanFont");
- }
- else if (isChinese)
- {
- fontFile = config.getValue("chinaFont", "");
- if (fontFile.empty())
- fontFile = branding.getStringValue("chinaFont");
- }
- if (fontFile.empty())
- fontFile = branding.getStringValue("font");
-
- mGuiFont = new Font(fontFile, fontSize, TTF_STYLE_NORMAL);
-
- // Set particle font
- fontFile = config.getValue("particleFont", "");
- if (isJapan)
- {
- fontFile = config.getValue("japanFont", "");
- if (fontFile.empty())
- fontFile = branding.getStringValue("japanFont");
- }
- else if (isChinese)
- {
- fontFile = config.getValue("chinaFont", "");
- if (fontFile.empty())
- fontFile = branding.getStringValue("chinaFont");
- }
- if (fontFile.empty())
- fontFile = branding.getStringValue("particleFont");
-
- mInfoParticleFont = new Font(fontFile, fontSize, TTF_STYLE_BOLD);
-
- // Set bold font
- fontFile = config.getValue("boldFont", "");
- if (fontFile.empty())
- fontFile = branding.getStringValue("boldFont");
-
- boldFont = new Font(fontFile, fontSize, TTF_STYLE_NORMAL);
-
- // Set help font
- fontFile = config.getValue("helpFont", "");
- if (fontFile.empty())
- fontFile = branding.getStringValue("helpFont");
-
- mHelpFont = new Font(fontFile, fontSize, TTF_STYLE_NORMAL);
-
- // Set secure font
- fontFile = config.getValue("secureFont", "");
- if (fontFile.empty())
- fontFile = branding.getStringValue("secureFont");
-
- mSecureFont = new Font(fontFile, fontSize, TTF_STYLE_NORMAL);
-
- // Set npc font
- const int npcFontSize = config.getIntValue("npcfontSize");
- fontFile = config.getValue("npcFont", "");
- if (isJapan)
- {
- fontFile = config.getValue("japanFont", "");
- if (fontFile.empty())
- fontFile = branding.getStringValue("japanFont");
- }
- else if (isChinese)
- {
- fontFile = config.getValue("chinaFont", "");
- if (fontFile.empty())
- fontFile = branding.getStringValue("chinaFont");
- }
- if (fontFile.empty())
- fontFile = branding.getStringValue("npcFont");
-
- mNpcFont = new Font(fontFile, npcFontSize, TTF_STYLE_NORMAL);
-
- Widget::setGlobalFont(mGuiFont);
-
- // Initialize mouse cursor and listen for changes to the option
- setUseCustomCursor(config.getBoolValue("customcursor"));
- setDoubleClick(config.getBoolValue("doubleClick"));
- config.addListener("customcursor", mConfigListener);
- config.addListener("doubleClick", mConfigListener);
-}
-
-Gui::~Gui()
-{
- config.removeListeners(mConfigListener);
- delete2(mConfigListener);
-
- if (mMouseCursors != nullptr)
- {
- mMouseCursors->decRef();
- mMouseCursors = nullptr;
- }
-
- if (windowContainer != nullptr)
- windowContainer->slowLogic();
- Widget *top = mTop;
- if (Widget::widgetExists(mTop))
- setTop(nullptr);
- Window::setWindowContainer(nullptr);
- delete top;
-
- delete2(mGuiFont);
- delete2(boldFont);
- delete2(mHelpFont);
- delete2(mSecureFont);
- delete2(mInfoParticleFont);
- delete2(mNpcFont);
- delete2(guiInput);
- delete2(theme);
-
- delete2(mFocusHandler);
- Label::finalCleanup();
- Tab::finalCleanup();
- Widget::cleanGlobalFont();
-}
-
-void Gui::logic()
-{
- BLOCK_START("Gui::logic")
- ResourceManager::clearScheduled();
-
- if (mTop == nullptr)
- {
- BLOCK_END("Gui::logic")
- return;
- }
-
- handleModalFocus();
- handleModalMouseInputFocus();
-
- if (guiInput != nullptr)
- handleMouseInput();
-
- mTop->logic();
- BLOCK_END("Gui::logic")
-}
-
-void Gui::slowLogic()
-{
- BLOCK_START("Gui::slowLogic")
- Palette::advanceGradients();
-
- // Fade out mouse cursor after extended inactivity
- if (mMouseInactivityTimer < 100 * 15)
- {
- ++mMouseInactivityTimer;
- mMouseCursorAlpha = std::min(1.0F, mMouseCursorAlpha + 0.05F);
- }
- else
- {
- mMouseCursorAlpha = std::max(0.0F, mMouseCursorAlpha - 0.005F);
- }
- if (mGuiFont != nullptr)
- mGuiFont->slowLogic(0);
- if (mInfoParticleFont != nullptr)
- mInfoParticleFont->slowLogic(1);
- if (mHelpFont != nullptr)
- mHelpFont->slowLogic(2);
- if (mSecureFont != nullptr)
- mSecureFont->slowLogic(3);
- if (boldFont != nullptr)
- boldFont->slowLogic(4);
- if (mNpcFont != nullptr)
- mNpcFont->slowLogic(5);
- if (windowContainer != nullptr)
- windowContainer->slowLogic();
-
- const time_t time = cur_time;
- if (mTime != time)
- {
- logger->flush();
- if (ipc != nullptr)
- ipc->flush();
- mTime = time;
-
- if (time > mTime10 || mTime10 - time > 10)
- {
- mTime10 = time + 10;
- ResourceManager::cleanOrphans();
- guiInput->simulateMouseMove();
- }
- }
-
- BLOCK_END("Gui::slowLogic")
-}
-
-void Gui::clearFonts()
-{
- if (mGuiFont != nullptr)
- mGuiFont->clear();
- if (mInfoParticleFont != nullptr)
- mInfoParticleFont->clear();
- if (mHelpFont != nullptr)
- mHelpFont->clear();
- if (mSecureFont != nullptr)
- mSecureFont->clear();
- if (boldFont != nullptr)
- boldFont->clear();
- if (mNpcFont != nullptr)
- mNpcFont->clear();
-}
-
-bool Gui::handleInput()
-{
- if (mInput != nullptr)
- return handleKeyInput();
- return false;
-}
-
-bool Gui::handleKeyInput()
-{
- if (guiInput == nullptr)
- return false;
-
- BLOCK_START("Gui::handleKeyInput")
- bool consumed(false);
-
- while (!mInput->isKeyQueueEmpty())
- {
- const KeyInput keyInput = guiInput->dequeueKeyInput();
-
- KeyEvent eventToGlobalKeyListeners(nullptr,
- keyInput.getType(),
- keyInput.getActionId(), keyInput.getKey());
-
-#ifdef USE_SDL2
- if (!keyInput.getText().empty())
- eventToGlobalKeyListeners.setText(keyInput.getText());
-#endif // USE_SDL2
-
- distributeKeyEventToGlobalKeyListeners(
- eventToGlobalKeyListeners);
-
- // If a global key listener consumes the event it will not be
- // sent further to the source of the event.
- if (eventToGlobalKeyListeners.isConsumed())
- {
- consumed = true;
- continue;
- }
-
- if (mFocusHandler != nullptr)
- {
- bool eventConsumed = false;
-
- // Send key inputs to the focused widgets
- if (mFocusHandler->getFocused() != nullptr)
- {
- KeyEvent event(getKeyEventSource(),
- keyInput.getType(),
- keyInput.getActionId(), keyInput.getKey());
-#ifdef USE_SDL2
- if (!keyInput.getText().empty())
- event.setText(keyInput.getText());
-#endif // USE_SDL2
-
- if (!mFocusHandler->getFocused()->isFocusable())
- mFocusHandler->focusNone();
- else
- distributeKeyEvent(event);
-
- eventConsumed = event.isConsumed();
- if (eventConsumed)
- consumed = true;
- }
-
- // If the key event hasn't been consumed and
- // tabbing is enable check for tab press and
- // change focus.
- if (!eventConsumed && keyInput.getActionId()
- == InputAction::GUI_TAB &&
- keyInput.getType() == KeyEventType::PRESSED)
- {
- if (inputManager.isActionActive(InputAction::GUI_MOD))
- mFocusHandler->tabPrevious();
- else
- mFocusHandler->tabNext();
- }
- }
- } // end while
- BLOCK_END("Gui::handleKeyInput")
- return consumed;
-}
-
-void Gui::draw()
-{
- BLOCK_START("Gui::draw 1")
- Widget *const top = getTop();
- if (top == nullptr)
- return;
- mGraphics->pushClipArea(top->getDimension());
-
- if (isBatchDrawRenders(openGLMode))
- {
- top->draw(mGraphics);
- touchManager.draw();
- }
- else
- {
- top->safeDraw(mGraphics);
- touchManager.safeDraw();
- }
-
- int mouseX;
- int mouseY;
- const MouseStateType button = getMouseState(mouseX, mouseY);
-
- if ((settings.mouseFocused ||
- ((button & SDL_BUTTON(1)) != 0)) &&
- mMouseCursors != nullptr &&
- mCustomCursor &&
- mMouseCursorAlpha > 0.0F)
- {
-#ifndef DYECMD
- const Image *const image = dragDrop.getItemImage();
- if (mGuiFont != nullptr)
- {
- const std::string &str = dragDrop.getText();
- if (!str.empty())
- {
- const int posX = mouseX - mGuiFont->getWidth(str) / 2;
- const int posY = mouseY +
- (image != nullptr ? image->mBounds.h / 2 : 0);
- mGuiFont->drawString(mGraphics,
- mForegroundColor, mForegroundColor2,
- str,
- posX, posY);
- }
- }
- if (image != nullptr)
- {
- const int posX = mouseX - (image->mBounds.w / 2);
- const int posY = mouseY - (image->mBounds.h / 2);
- mGraphics->drawImage(image, posX, posY);
- }
-#endif // DYECMD
-
- Image *const mouseCursor = mMouseCursors->get(
- CAST_SIZE(mCursorType));
- if (mouseCursor != nullptr)
- {
- mouseCursor->setAlpha(mMouseCursorAlpha);
- mGraphics->drawImage(mouseCursor, mouseX - 15, mouseY - 17);
- }
- }
-
- mGraphics->popClipArea();
- BLOCK_END("Gui::draw 1")
-}
-
-void Gui::videoResized() const
-{
- WindowContainer *const top = static_cast<WindowContainer *>(getTop());
-
- if (top != nullptr)
- {
- const int oldWidth = top->getWidth();
- const int oldHeight = top->getHeight();
-
- top->setSize(mainGraphics->mWidth, mainGraphics->mHeight);
- top->adjustAfterResize(oldWidth, oldHeight);
- }
-
- if (viewport != nullptr)
- viewport->videoResized();
- Widget::distributeWindowResizeEvent();
-}
-
-void Gui::setUseCustomCursor(const bool customCursor)
-{
- if (settings.options.hideCursor)
- {
- SDL::showCursor(false);
- return;
- }
- if (customCursor != mCustomCursor)
- {
- mCustomCursor = customCursor;
-
- if (mCustomCursor)
- {
- // Hide the SDL mouse cursor
- SDL::showCursor(false);
-
- // Load the mouse cursor
- if (mMouseCursors != nullptr)
- mMouseCursors->decRef();
- mMouseCursors = Theme::getImageSetFromTheme("mouse.png", 40, 40);
-
- if (mMouseCursors == nullptr)
- logger->log("Error: Unable to load mouse cursors.");
- }
- else
- {
- // Show the SDL mouse cursor
- SDL::showCursor(true);
-
- // Unload the mouse cursor
- if (mMouseCursors != nullptr)
- {
- mMouseCursors->decRef();
- mMouseCursors = nullptr;
- }
- }
- }
-}
-
-void Gui::handleMouseMoved(const MouseInput &mouseInput)
-{
- // Check if the mouse leaves the application window.
- if (mTop != nullptr &&
- !mWidgetWithMouseQueue.empty() &&
- (mouseInput.getX() < 0 ||
- mouseInput.getY() < 0 ||
- !mTop->getDimension().isPointInRect(mouseInput.getX(),
- mouseInput.getY())))
- {
- // Distribute an event to all widgets in the
- // "widget with mouse" queue.
- while (!mWidgetWithMouseQueue.empty())
- {
- Widget *const widget = mWidgetWithMouseQueue.front();
-
- if (Widget::widgetExists(widget))
- {
- distributeMouseEvent(widget,
- MouseEventType::EXITED,
- mouseInput.getButton(),
- mouseInput.getX(),
- mouseInput.getY(),
- true,
- true);
- }
-
- mWidgetWithMouseQueue.pop_front();
- }
-
- mMouseInactivityTimer = 0;
- return;
- }
-
- const int mouseX = mouseInput.getX();
- const int mouseY = mouseInput.getY();
- const MouseButtonT button = mouseInput.getButton();
-
- // Check if there is a need to send mouse exited events by
- // traversing the "widget with mouse" queue.
- bool widgetWithMouseQueueCheckDone = mWidgetWithMouseQueue.empty();
- while (!widgetWithMouseQueueCheckDone)
- {
- unsigned int iterations = 0;
- for (std::deque<Widget*>::iterator
- iter = mWidgetWithMouseQueue.begin();
- iter != mWidgetWithMouseQueue.end();
- ++ iter)
- {
- Widget *const widget = *iter;
-
- // If a widget in the "widget with mouse queue" doesn't
- // exists anymore it should be removed from the queue.
- if (!Widget::widgetExists(widget))
- {
- mWidgetWithMouseQueue.erase(iter);
- break;
- }
- else
- {
- int x;
- int y;
- widget->getAbsolutePosition(x, y);
-
- if (x > mouseX
- || y > mouseY
- || x + widget->getWidth() <= mouseX
- || y + widget->getHeight() <= mouseY
- || !widget->isVisible())
- {
- distributeMouseEvent(widget,
- MouseEventType::EXITED,
- button,
- mouseX,
- mouseY,
- true,
- true);
- mClickCount = 1;
- mLastMousePressTimeStamp = 0U;
- mWidgetWithMouseQueue.erase(iter);
- break;
- }
- }
-
- iterations++;
- }
-
- widgetWithMouseQueueCheckDone =
- (CAST_SIZE(iterations) == mWidgetWithMouseQueue.size());
- }
-
- // Check all widgets below the mouse to see if they are
- // present in the "widget with mouse" queue. If a widget
- // is not then it should be added and an entered event should
- // be sent to it.
- Widget* parent = getMouseEventSource(mouseX, mouseY);
- Widget* widget = parent;
-
- // If a widget has modal mouse input focus then it will
- // always be returned from getMouseEventSource, but we only wan't to
- // send mouse entered events if the mouse has actually entered the
- // widget with modal mouse input focus, hence we need to check if
- // that's the case. If it's not we should simply ignore to send any
- // mouse entered events.
- if ((mFocusHandler->getModalMouseInputFocused() != nullptr)
- && widget == mFocusHandler->getModalMouseInputFocused()
- && Widget::widgetExists(widget) &&
- (widget != nullptr))
- {
- int x, y;
- widget->getAbsolutePosition(x, y);
-
- if (x > mouseX || y > mouseY
- || x + widget->getWidth() <= mouseX
- || y + widget->getHeight() <= mouseY)
- {
- parent = nullptr;
- }
- }
-
- while (parent != nullptr)
- {
- parent = widget->getParent();
-
- // Check if the widget is present in the "widget with mouse" queue.
- bool widgetIsPresentInQueue = false;
- FOR_EACH (std::deque<Widget*>::const_iterator,
- iter, mWidgetWithMouseQueue)
- {
- if (*iter == widget)
- {
- widgetIsPresentInQueue = true;
- break;
- }
- }
-
- // Widget is not present, send an entered event and add
- // it to the "widget with mouse" queue.
- if (!widgetIsPresentInQueue
- && Widget::widgetExists(widget))
- {
- distributeMouseEvent(widget,
- MouseEventType::ENTERED,
- button,
- mouseX,
- mouseY,
- true,
- true);
- mWidgetWithMouseQueue.push_front(widget);
- }
-
- const Widget *const swap = widget;
- widget = parent;
- parent = swap->getParent();
- }
-
- if (mFocusHandler->getDraggedWidget() != nullptr)
- {
- distributeMouseEvent(mFocusHandler->getDraggedWidget(),
- MouseEventType::DRAGGED,
- mLastMouseDragButton,
- mouseX,
- mouseY);
- }
- else
- {
- Widget *const sourceWidget = getMouseEventSource(mouseX, mouseY);
- distributeMouseEvent(sourceWidget,
- MouseEventType::MOVED,
- button,
- mouseX,
- mouseY);
- }
- mMouseInactivityTimer = 0;
-}
-
-void Gui::handleMousePressed(const MouseInput &mouseInput)
-{
- const int x = mouseInput.getX();
- const int y = mouseInput.getY();
- const MouseButtonT button = mouseInput.getButton();
- const unsigned int timeStamp = mouseInput.getTimeStamp();
-
- Widget *sourceWidget = getMouseEventSource(x, y);
-
- if (mFocusHandler->getDraggedWidget() != nullptr)
- sourceWidget = mFocusHandler->getDraggedWidget();
-
- if (sourceWidget == nullptr)
- return;
- int sourceWidgetX;
- int sourceWidgetY;
- sourceWidget->getAbsolutePosition(sourceWidgetX, sourceWidgetY);
-
- if (((mFocusHandler->getModalFocused() != nullptr)
- && sourceWidget->isModalFocused())
- || (mFocusHandler->getModalFocused() == nullptr))
- {
- sourceWidget->requestFocus();
- }
-
- if (mDoubleClick &&
- timeStamp - mLastMousePressTimeStamp < 250U &&
- mLastMousePressButton == button)
- {
- mClickCount ++;
- }
- else
- {
- mClickCount = 1;
- }
-
- distributeMouseEvent(sourceWidget, MouseEventType::PRESSED, button, x, y);
- mFocusHandler->setLastWidgetPressed(sourceWidget);
- mFocusHandler->setDraggedWidget(sourceWidget);
- mLastMouseDragButton = button;
- mLastMousePressButton = button;
- mLastMousePressTimeStamp = timeStamp;
-}
-
-void Gui::updateFonts()
-{
- const int fontSize = config.getIntValue("fontSize");
- std::string fontFile = config.getValue("font", "");
- if (fontFile.empty())
- fontFile = branding.getStringValue("font");
-
- mGuiFont->loadFont(fontFile, fontSize, TTF_STYLE_NORMAL);
-
- fontFile = config.getValue("particleFont", "");
- if (fontFile.empty())
- fontFile = branding.getStringValue("particleFont");
-
- mInfoParticleFont->loadFont(fontFile, fontSize, TTF_STYLE_BOLD);
-
- fontFile = config.getValue("boldFont", "");
- if (fontFile.empty())
- fontFile = branding.getStringValue("boldFont");
-
- boldFont->loadFont(fontFile, fontSize, TTF_STYLE_NORMAL);
-
- const int npcFontSize = config.getIntValue("npcfontSize");
-
- fontFile = config.getValue("npcFont", "");
- if (fontFile.empty())
- fontFile = branding.getStringValue("npcFont");
-
- mNpcFont->loadFont(fontFile, npcFontSize, TTF_STYLE_NORMAL);
-}
-
-void Gui::distributeMouseEvent(Widget *const source,
- const MouseEventTypeT type,
- const MouseButtonT button,
- const int x, const int y,
- const bool force,
- const bool toSourceOnly)
-{
- if ((source == nullptr) || (mFocusHandler == nullptr))
- return;
-
- Widget *widget = source;
-
- if (!force)
- {
- if (mFocusHandler->getModalFocused() != nullptr
- && !widget->isModalFocused())
- {
- return;
- }
- if (mFocusHandler->getModalMouseInputFocused() != nullptr
- && !widget->isModalMouseInputFocused())
- {
- return;
- }
- }
-
- MouseEvent event(source,
- type, button,
- x, y, mClickCount);
-
- Widget* parent = source;
- while (parent != nullptr)
- {
- // If the widget has been removed due to input
- // cancel the distribution.
- if (!Widget::widgetExists(widget))
- break;
-
- parent = widget->getParent();
-
- if (widget->isEnabled() || force)
- {
- int widgetX;
- int widgetY;
- widget->getAbsolutePosition(widgetX, widgetY);
-
- event.setX(x - widgetX);
- event.setY(y - widgetY);
-
- std::list<MouseListener*> mouseListeners
- = widget->getMouseListeners();
-
- const MouseEventTypeT mouseType = event.getType();
- // Send the event to all mouse listeners of the widget.
- FOR_EACH (std::list<MouseListener*>::const_iterator,
- it, mouseListeners)
- {
- switch (mouseType)
- {
- case MouseEventType::ENTERED:
- (*it)->mouseEntered(event);
- break;
- case MouseEventType::EXITED:
- (*it)->mouseExited(event);
- break;
- case MouseEventType::MOVED:
- (*it)->mouseMoved(event);
- break;
- case MouseEventType::PRESSED:
- (*it)->mousePressed(event);
- break;
- case MouseEventType::RELEASED:
- case MouseEventType::RELEASED2:
- (*it)->mouseReleased(event);
- break;
- case MouseEventType::WHEEL_MOVED_UP:
- (*it)->mouseWheelMovedUp(event);
- break;
- case MouseEventType::WHEEL_MOVED_DOWN:
- (*it)->mouseWheelMovedDown(event);
- break;
- case MouseEventType::DRAGGED:
- (*it)->mouseDragged(event);
- break;
- case MouseEventType::CLICKED:
- (*it)->mouseClicked(event);
- break;
- default:
- break;
- }
- }
-
- if (toSourceOnly)
- break;
- }
-
- const Widget *const swap = widget;
- widget = parent;
- parent = swap->getParent();
-
-#ifndef DYECMD
- if (type == MouseEventType::RELEASED)
- dragDrop.clear();
-#endif // DYECMD
-
- if ((widget == nullptr) || event.isConsumed())
- break;
-
- // If a non modal focused widget has been reach
- // and we have modal focus cancel the distribution.
- if ((mFocusHandler->getModalFocused() != nullptr)
- && !widget->isModalFocused())
- {
- break;
- }
-
- // If a non modal mouse input focused widget has been reach
- // and we have modal mouse input focus cancel the distribution.
- if ((mFocusHandler->getModalMouseInputFocused() != nullptr)
- && !widget->isModalMouseInputFocused())
- {
- break;
- }
- }
-}
-
-void Gui::resetClickCount()
-{
- mClickCount = 1;
- mLastMousePressTimeStamp = 0;
-}
-
-MouseEvent *Gui::createMouseEvent(Window *const widget)
-{
- if ((viewport == nullptr) || (widget == nullptr))
- return nullptr;
-
- int x = 0;
- int y = 0;
- int mouseX = 0;
- int mouseY = 0;
-
- getAbsolutePosition(widget, x, y);
- getMouseState(mouseX, mouseY);
-
- return new MouseEvent(widget,
- MouseEventType::MOVED,
- MouseButton::EMPTY,
- mouseX - x,
- mouseY - y,
- mClickCount);
-}
-
-void Gui::getAbsolutePosition(Widget *restrict widget,
- int &restrict x,
- int &restrict y)
-{
- if (widget == nullptr)
- return;
- x = 0;
- y = 0;
- while (widget->getParent() != nullptr)
- {
- x += widget->getX();
- y += widget->getY();
- widget = widget->getParent();
- }
-}
-
-void Gui::handleMouseInput()
-{
- BLOCK_START("Gui::handleMouseInput")
- while (!mInput->isMouseQueueEmpty())
- {
- const MouseInput mouseInput = guiInput->dequeueMouseInput();
-
- if (touchManager.processEvent(mouseInput))
- {
-#ifdef ANDROID
-#ifndef USE_SDL2
- SDL_WarpMouse(mLastMouseX, mLastMouseY,
- mLastMouseRealX, mLastMouseRealY);
-#endif // USE_SDL2
-#endif // ANDROID
-
- mMouseInactivityTimer = 0;
- continue;
- }
-
- // Save the current mouse state. It will be needed if modal focus
- // changes or modal mouse input focus changes.
- mLastMouseX = mouseInput.getX();
- mLastMouseY = mouseInput.getY();
-#ifdef ANDROID
- mLastMouseRealX = mouseInput.getRealX();
- mLastMouseRealY = mouseInput.getRealY();
-#endif // ANDROID
-
- switch (mouseInput.getType())
- {
- case MouseEventType::PRESSED:
- handleMousePressed(mouseInput);
- break;
- case MouseEventType::RELEASED:
- handleMouseReleased(mouseInput);
- break;
- case MouseEventType::MOVED:
- handleMouseMoved(mouseInput);
- break;
- case MouseEventType::WHEEL_MOVED_DOWN:
- handleMouseWheelMovedDown(mouseInput);
- break;
- case MouseEventType::WHEEL_MOVED_UP:
- handleMouseWheelMovedUp(mouseInput);
- break;
- case MouseEventType::CLICKED:
- case MouseEventType::ENTERED:
- case MouseEventType::EXITED:
- case MouseEventType::DRAGGED:
- case MouseEventType::RELEASED2:
- default:
- break;
- }
- }
- BLOCK_END("Gui::handleMouseInput")
-}
-
-void Gui::handleMouseReleased(const MouseInput &mouseInput)
-{
- Widget *sourceWidget = getMouseEventSource(
- mouseInput.getX(), mouseInput.getY());
-
- int sourceWidgetX;
- int sourceWidgetY;
- if (mFocusHandler->getDraggedWidget() != nullptr)
- {
- if (sourceWidget != mFocusHandler->getLastWidgetPressed())
- mFocusHandler->setLastWidgetPressed(nullptr);
-
- Widget *const oldWidget = sourceWidget;
- sourceWidget = mFocusHandler->getDraggedWidget();
- if ((oldWidget != nullptr) && oldWidget != sourceWidget)
- {
- oldWidget->getAbsolutePosition(sourceWidgetX, sourceWidgetY);
- distributeMouseEvent(oldWidget,
- MouseEventType::RELEASED2,
- mouseInput.getButton(),
- mouseInput.getX(),
- mouseInput.getY());
- }
- }
-
- if (sourceWidget == nullptr)
- return;
- sourceWidget->getAbsolutePosition(sourceWidgetX, sourceWidgetY);
- distributeMouseEvent(sourceWidget,
- MouseEventType::RELEASED,
- mouseInput.getButton(),
- mouseInput.getX(),
- mouseInput.getY());
-
- if (mouseInput.getButton() == mLastMousePressButton
- && mFocusHandler->getLastWidgetPressed() == sourceWidget)
- {
- distributeMouseEvent(sourceWidget,
- MouseEventType::CLICKED,
- mouseInput.getButton(),
- mouseInput.getX(),
- mouseInput.getY());
-
- mFocusHandler->setLastWidgetPressed(nullptr);
- }
- else
- {
- mLastMousePressButton = MouseButton::EMPTY;
- mClickCount = 0;
- }
-
- if (mFocusHandler->getDraggedWidget() != nullptr)
- mFocusHandler->setDraggedWidget(nullptr);
-}
-
-void Gui::addGlobalFocusListener(FocusListener* focusListener)
-{
- mFocusListeners.push_back(focusListener);
-}
-
-void Gui::removeGlobalFocusListener(FocusListener* focusListener)
-{
- mFocusListeners.remove(focusListener);
-}
-
-void Gui::distributeGlobalFocusGainedEvent(const Event &focusEvent)
-{
- for (FocusListenerIterator iter = mFocusListeners.begin();
- iter != mFocusListeners.end();
- ++ iter)
- {
- (*iter)->focusGained(focusEvent);
- }
-}
-
-void Gui::removeDragged(const Widget *const widget)
-{
- if (mFocusHandler == nullptr)
- return;
-
- if (mFocusHandler->getDraggedWidget() == widget)
- mFocusHandler->setDraggedWidget(nullptr);
-}
-
-MouseStateType Gui::getMouseState(int &x, int &y)
-{
- const MouseStateType res = SDL_GetMouseState(&x, &y);
- const int scale = mainGraphics->getScale();
- x /= scale;
- y /= scale;
- return res;
-}
-
-void Gui::setTop(Widget *const top)
-{
- if (mTop != nullptr)
- mTop->setFocusHandler(nullptr);
- if (top != nullptr)
- top->setFocusHandler(mFocusHandler);
-
- mTop = top;
-}
-
-void Gui::setGraphics(Graphics *const graphics)
-{
- mGraphics = graphics;
-}
-
-Graphics* Gui::getGraphics() const
-{
- return mGraphics;
-}
-
-void Gui::setInput(SDLInput *const input)
-{
- mInput = input;
-}
-
-SDLInput* Gui::getInput() const
-{
- return mInput;
-}
-
-void Gui::addGlobalKeyListener(KeyListener *const keyListener)
-{
- mKeyListeners.push_back(keyListener);
-}
-
-void Gui::removeGlobalKeyListener(KeyListener *const keyListener)
-{
- mKeyListeners.remove(keyListener);
-}
-
-void Gui::handleMouseWheelMovedDown(const MouseInput& mouseInput)
-{
- Widget* sourceWidget = getMouseEventSource(
- mouseInput.getX(), mouseInput.getY());
-
- if (mFocusHandler->getDraggedWidget() != nullptr)
- sourceWidget = mFocusHandler->getDraggedWidget();
-
- if (sourceWidget != nullptr)
- {
- int sourceWidgetX = 0;
- int sourceWidgetY = 0;
-
- sourceWidget->getAbsolutePosition(sourceWidgetX, sourceWidgetY);
- distributeMouseEvent(sourceWidget,
- MouseEventType::WHEEL_MOVED_DOWN,
- mouseInput.getButton(),
- mouseInput.getX(),
- mouseInput.getY());
- }
-}
-
-void Gui::handleMouseWheelMovedUp(const MouseInput& mouseInput)
-{
- Widget* sourceWidget = getMouseEventSource(
- mouseInput.getX(), mouseInput.getY());
-
- if (mFocusHandler->getDraggedWidget() != nullptr)
- sourceWidget = mFocusHandler->getDraggedWidget();
-
- if (sourceWidget != nullptr)
- {
- int sourceWidgetX;
- int sourceWidgetY;
-
- sourceWidget->getAbsolutePosition(sourceWidgetX, sourceWidgetY);
- distributeMouseEvent(sourceWidget,
- MouseEventType::WHEEL_MOVED_UP,
- mouseInput.getButton(),
- mouseInput.getX(),
- mouseInput.getY());
- }
-}
-
-Widget* Gui::getWidgetAt(const int x, const int y) const
-{
- // If the widget's parent has no child then we have found the widget..
- Widget* parent = mTop;
- Widget* child = mTop;
- Widget* selectable = mTop;
-
- while (child != nullptr)
- {
- Widget *const swap = child;
- int parentX, parentY;
- parent->getAbsolutePosition(parentX, parentY);
- child = parent->getWidgetAt(x - parentX, y - parentY);
- parent = swap;
- if (parent->isSelectable())
- selectable = parent;
- }
-
- return selectable;
-}
-
-Widget* Gui::getMouseEventSource(const int x, const int y) const
-{
- Widget *const widget = getWidgetAt(x, y);
- if (widget == nullptr)
- return nullptr;
-
- if (mFocusHandler != nullptr &&
- mFocusHandler->getModalMouseInputFocused() != nullptr &&
- !widget->isModalMouseInputFocused())
- {
- return mFocusHandler->getModalMouseInputFocused();
- }
-
- return widget;
-}
-
-Widget* Gui::getKeyEventSource() const
-{
- Widget* widget = mFocusHandler->getFocused();
-
- while (widget != nullptr &&
- widget->getInternalFocusHandler() != nullptr &&
- widget->getInternalFocusHandler()->getFocused() != nullptr)
- {
- widget = widget->getInternalFocusHandler()->getFocused();
- }
-
- return widget;
-}
-
-void Gui::distributeKeyEvent(KeyEvent &event) const
-{
- Widget* parent = event.getSource();
- Widget* widget = parent;
-
- if (parent == nullptr)
- return;
- if (mFocusHandler->getModalFocused() != nullptr &&
- !widget->isModalFocused())
- {
- return;
- }
- if (mFocusHandler->getModalMouseInputFocused() != nullptr &&
- !widget->isModalMouseInputFocused())
- {
- return;
- }
-
- while (parent != nullptr)
- {
- // If the widget has been removed due to input
- // cancel the distribution.
- if (!Widget::widgetExists(widget))
- break;
-
- parent = widget->getParent();
-
- if (widget->isEnabled())
- {
- std::list<KeyListener*> keyListeners
- = widget->getKeyListeners();
-
- const KeyEventTypeT eventType = event.getType();
- // Send the event to all key listeners of the source widget.
- FOR_EACH (std::list<KeyListener*>::const_iterator,
- it, keyListeners)
- {
- switch (eventType)
- {
- case KeyEventType::PRESSED:
- (*it)->keyPressed(event);
- break;
- case KeyEventType::RELEASED:
- (*it)->keyReleased(event);
- break;
- default:
- break;
- }
- }
- }
-
- const Widget *const swap = widget;
- widget = parent;
- parent = swap->getParent();
-
- // If a non modal focused widget has been reach
- // and we have modal focus cancel the distribution.
- if ((widget != nullptr) &&
- (mFocusHandler->getModalFocused() != nullptr) &&
- !widget->isModalFocused())
- {
- break;
- }
- }
-}
-
-void Gui::distributeKeyEventToGlobalKeyListeners(KeyEvent& event)
-{
- BLOCK_START("Gui::distributeKeyEventToGlobalKeyListeners")
- const KeyEventTypeT eventType = event.getType();
- FOR_EACH (KeyListenerListIterator, it, mKeyListeners)
- {
- switch (eventType)
- {
- case KeyEventType::PRESSED:
- (*it)->keyPressed(event);
- break;
- case KeyEventType::RELEASED:
- (*it)->keyReleased(event);
- break;
- default:
- break;
- }
-
- if (event.isConsumed())
- break;
- }
- BLOCK_END("Gui::distributeKeyEventToGlobalKeyListeners")
-}
-
-void Gui::handleModalMouseInputFocus()
-{
- BLOCK_START("Gui::handleModalMouseInputFocus")
- Widget *const lastModalWidget
- = mFocusHandler->getLastWidgetWithModalMouseInputFocus();
- Widget *const modalWidget = mFocusHandler->getModalMouseInputFocused();
- if (lastModalWidget != modalWidget)
- {
- // Check if modal mouse input focus has been gained by a widget.
- if (lastModalWidget == nullptr)
- {
- handleModalFocusGained();
- mFocusHandler->setLastWidgetWithModalMouseInputFocus(modalWidget);
- }
- // Check if modal mouse input focus has been released.
- else
- {
- handleModalFocusReleased();
- mFocusHandler->setLastWidgetWithModalMouseInputFocus(nullptr);
- }
- }
- BLOCK_END("Gui::handleModalMouseInputFocus")
-}
-
-void Gui::handleModalFocus()
-{
- BLOCK_START("Gui::handleModalFocus")
- Widget *const lastModalWidget
- = mFocusHandler->getLastWidgetWithModalFocus();
- Widget *const modalWidget = mFocusHandler->getModalFocused();
-
- if (lastModalWidget != modalWidget)
- {
- // Check if modal focus has been gained by a widget.
- if (lastModalWidget == nullptr)
- {
- handleModalFocusGained();
- mFocusHandler->setLastWidgetWithModalFocus(modalWidget);
- }
- // Check if modal focus has been released.
- else
- {
- handleModalFocusReleased();
- mFocusHandler->setLastWidgetWithModalFocus(nullptr);
- }
- }
- BLOCK_END("Gui::handleModalFocus")
-}
-
-void Gui::handleModalFocusGained()
-{
- // Distribute an event to all widgets in the "widget with mouse" queue.
- while (!mWidgetWithMouseQueue.empty())
- {
- Widget *const widget = mWidgetWithMouseQueue.front();
-
- if (Widget::widgetExists(widget))
- {
- distributeMouseEvent(widget,
- MouseEventType::EXITED,
- mLastMousePressButton,
- mLastMouseX,
- mLastMouseY,
- true,
- true);
- }
-
- mWidgetWithMouseQueue.pop_front();
- }
-
- mFocusHandler->setLastWidgetWithModalMouseInputFocus(
- mFocusHandler->getModalMouseInputFocused());
-}
-
-void Gui::handleModalFocusReleased()
-{
- // Check all widgets below the mouse to see if they are
- // present in the "widget with mouse" queue. If a widget
- // is not then it should be added and an entered event should
- // be sent to it.
- Widget* widget = getMouseEventSource(mLastMouseX, mLastMouseY);
- Widget* parent = widget;
-
- while (parent != nullptr &&
- widget != nullptr)
- {
- parent = widget->getParent();
-
- // Check if the widget is present in the "widget with mouse" queue.
- bool widgetIsPresentInQueue = false;
- FOR_EACH (std::deque<Widget*>::const_iterator,
- iter, mWidgetWithMouseQueue)
- {
- if (*iter == widget)
- {
- widgetIsPresentInQueue = true;
- break;
- }
- }
-
- // Widget is not present, send an entered event and add
- // it to the "widget with mouse" queue.
- if (!widgetIsPresentInQueue && Widget::widgetExists(widget))
- {
- distributeMouseEvent(widget,
- MouseEventType::ENTERED,
- mLastMousePressButton,
- mLastMouseX,
- mLastMouseY,
- false,
- true);
- mWidgetWithMouseQueue.push_front(widget);
- }
-
- const Widget *const swap = widget;
- widget = parent;
- parent = swap->getParent();
- }
-}
-
-int Gui::getMousePressLength() const
-{
- if (mLastMousePressTimeStamp == 0u)
- return 0;
- unsigned int ticks = SDL_GetTicks();
- if (ticks > mLastMousePressTimeStamp)
- return ticks - mLastMousePressTimeStamp;
- return mLastMousePressTimeStamp - ticks;
-}
diff --git a/src/gui/gui.h b/src/gui/gui.h
deleted file mode 100644
index a846f1a5d..000000000
--- a/src/gui/gui.h
+++ /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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GUI_GUI_H
-#define GUI_GUI_H
-
-#include "gui/color.h"
-
-#include "enums/events/mousebutton.h"
-#include "enums/events/mouseeventtype.h"
-
-#include "enums/resources/cursor.h"
-
-#include <deque>
-#include <list>
-
-#include "localconsts.h"
-
-class Event;
-class FocusHandler;
-class FocusListener;
-class Graphics;
-class GuiConfigListener;
-class ImageSet;
-class KeyEvent;
-class KeyListener;
-class MouseEvent;
-class MouseInput;
-class Font;
-class SDLInput;
-class Widget;
-class Window;
-
-#ifdef USE_SDL2
-#define MouseStateType uint32_t
-#else // USE_SDL2
-#define MouseStateType uint8_t
-#endif // USE_SDL2
-
-/**
- * \defgroup GUI Core GUI related classes (widgets)
- */
-
-/**
- * \defgroup Interface User interface related classes (windows, dialogs)
- */
-
-/**
- * Main GUI class.
- *
- * \ingroup GUI
- */
-class Gui final
-{
- public:
- /**
- * Constructor.
- */
- Gui();
-
- A_DELETE_COPY(Gui)
-
- /**
- * Destructor.
- */
- ~Gui();
-
- void postInit(Graphics *const graphics) A_NONNULL(2);
-
- /**
- * Performs logic of the GUI. Overridden to track mouse pointer
- * activity.
- */
- void logic();
-
- void slowLogic();
-
- void clearFonts();
-
- /**
- * Draws the whole Gui by calling draw functions down in the
- * Gui hierarchy. It also draws the mouse pointer.
- */
- void draw();
-
- /**
- * Called when the application window has been resized.
- */
- void videoResized() const;
-
- FocusHandler *getFocusHandler() const noexcept2 A_WARN_UNUSED
- { return mFocusHandler; }
-
- /**
- * Return game font.
- */
- Font *getFont() const RETURNS_NONNULL A_WARN_UNUSED
- { return mGuiFont; }
-
- /**
- * Return help font.
- */
- Font *getHelpFont() const RETURNS_NONNULL A_WARN_UNUSED
- { return mHelpFont; }
-
- /**
- * Return secure font.
- */
- Font *getSecureFont() const RETURNS_NONNULL A_WARN_UNUSED
- { return mSecureFont; }
-
- /**
- * Return npc font.
- */
- Font *getNpcFont() const RETURNS_NONNULL A_WARN_UNUSED
- { return mNpcFont; }
-
- /**
- * Return the Font used for "Info Particles", i.e. ones showing, what
- * you picked up, etc.
- */
- Font *getInfoParticleFont() const RETURNS_NONNULL A_WARN_UNUSED
- { return mInfoParticleFont; }
-
- /**
- * Sets whether a custom cursor should be rendered.
- */
- void setUseCustomCursor(const bool customCursor);
-
- /**
- * Sets which cursor should be used.
- */
- void setCursorType(const CursorT index)
- { mCursorType = index; }
-
- void setDoubleClick(const bool b)
- { mDoubleClick = b; }
-
- void updateFonts();
-
- bool handleInput();
-
- bool handleKeyInput();
-
- void resetClickCount();
-
- MouseEvent *createMouseEvent(Window *const widget) A_WARN_UNUSED;
-
- static void getAbsolutePosition(Widget *restrict widget,
- int &restrict x,
- int &restrict y);
-
- void addGlobalFocusListener(FocusListener* focusListener);
-
- void removeGlobalFocusListener(FocusListener* focusListener);
-
- void distributeGlobalFocusGainedEvent(const Event &focusEvent);
-
- void removeDragged(const Widget *const widget);
-
- int getLastMouseX() const
- { return mLastMouseX; }
-
- int getLastMouseY() const
- { return mLastMouseY; }
-
- static MouseStateType getMouseState(int &x, int &y);
-
- /**
- * Sets the top widget. The top widget is the root widget
- * of the GUI. If you want a GUI to be able to contain more
- * than one widget the top widget should be a container.
- *
- * @param top The top widget.
- * @see Container
- */
- void setTop(Widget *const top);
-
- /**
- * Gets the top widget. The top widget is the root widget
- * of the GUI.
- *
- * @return The top widget. NULL if no top widget has been set.
- */
- Widget* getTop() const noexcept2 A_WARN_UNUSED
- { return mTop; }
-
- /**
- * Sets the graphics object to use for drawing.
- *
- * @param graphics The graphics object to use for drawing.
- * @see getGraphics, AllegroGraphics, HGEGraphics,
- * OpenLayerGraphics, OpenGLGraphics, SDLGraphics
- */
- void setGraphics(Graphics *const graphics) A_NONNULL(2);
-
- /**
- * Gets the graphics object used for drawing.
- *
- * @return The graphics object used for drawing. NULL if no
- * graphics object has been set.
- * @see setGraphics, AllegroGraphics, HGEGraphics,
- * OpenLayerGraphics, OpenGLGraphics, SDLGraphics
- */
- Graphics* getGraphics() const RETURNS_NONNULL A_WARN_UNUSED;
-
- /**
- * Sets the input object to use for input handling.
- *
- * @param input The input object to use for input handling.
- * @see getInput, AllegroInput, HGEInput, OpenLayerInput,
- * SDLInput
- */
- void setInput(SDLInput *const input) A_NONNULL(2);
-
- /**
- * Gets the input object being used for input handling.
- *
- * @return The input object used for handling input. NULL if no
- * input object has been set.
- * @see setInput, AllegroInput, HGEInput, OpenLayerInput,
- * SDLInput
- */
- SDLInput* getInput() const A_WARN_UNUSED;
-
- /**
- * Adds a global key listener to the Gui. A global key listener
- * will receive all key events generated from the GUI and global
- * key listeners will receive the events before key listeners
- * of widgets.
- *
- * @param keyListener The key listener to add.
- * @see removeGlobalKeyListener
- */
- void addGlobalKeyListener(KeyListener *const keyListener);
-
- /**
- * Removes global key listener from the Gui.
- *
- * @param keyListener The key listener to remove.
- * @throws Exception if the key listener hasn't been added.
- * @see addGlobalKeyListener
- */
- void removeGlobalKeyListener(KeyListener *const keyListener);
-
- bool isLongPress() const
- { return getMousePressLength() > 250; }
-
- int getMousePressLength() const;
-
- protected:
- void handleMouseMoved(const MouseInput &mouseInput);
-
- void handleMouseReleased(const MouseInput &mouseInput);
-
- void handleMousePressed(const MouseInput &mouseInput);
-
- void handleMouseInput();
-
- void distributeMouseEvent(Widget *const source,
- const MouseEventTypeT type,
- const MouseButtonT button,
- const int x, const int y,
- const bool force = false,
- const bool toSourceOnly = false);
-
- /**
- *
- * Handles mouse wheel moved down input.
- *
- * @param mouseInput The mouse input to handle.
- */
- void handleMouseWheelMovedDown(const MouseInput& mouseInput);
-
- /**
- * Handles mouse wheel moved up input.
- *
- * @param mouseInput The mouse input to handle.
- */
- void handleMouseWheelMovedUp(const MouseInput& mouseInput);
-
- /**
- * Gets the widget at a certain position.
- *
- * @return The widget at a certain position.
- */
- Widget* getWidgetAt(const int x, const int y) const A_WARN_UNUSED;
-
- /**
- * Gets the source of the mouse event.
- *
- * @return The source widget of the mouse event.
- */
- Widget* getMouseEventSource(const int x,
- const int y) const A_WARN_UNUSED;
-
- /**
- * Gets the source of the key event.
- *
- * @return The source widget of the key event.
- */
- Widget* getKeyEventSource() const A_WARN_UNUSED;
-
- /**
- * Distributes a key event.
- *
- * @param event The key event to distribute.
-
- */
- void distributeKeyEvent(KeyEvent &event) const;
-
- /**
- * Distributes a key event to the global key listeners.
- *
- * @param event The key event to distribute.
- *
- */
- void distributeKeyEventToGlobalKeyListeners(KeyEvent& event);
-
- /**
- * Handles modal mouse input focus. Modal mouse input focus needs
- * to be checked at each logic iteration as it might be necessary to
- * distribute mouse entered or mouse exited events.
- *
- */
- void handleModalMouseInputFocus();
-
- /**
- * Handles modal focus. Modal focus needs to be checked at
- * each logic iteration as it might be necessary to distribute
- * mouse entered or mouse exited events.
- *
- */
- void handleModalFocus();
-
- /**
- * Handles modal focus gained. If modal focus has been gained it might
- * be necessary to distribute mouse entered or mouse exited events.
- *
- */
- void handleModalFocusGained();
-
- /**
- * Handles modal mouse input focus gained. If modal focus has been
- * gained it might be necessary to distribute mouse entered or mouse
- * exited events.
- *
- */
- void handleModalFocusReleased();
-
- private:
- /**
- * Holds the top widget.
- */
- Widget* mTop;
-
- /**
- * Holds the graphics implementation used.
- */
- Graphics* mGraphics A_NONNULLPOINTER;
-
- /**
- * Holds the input implementation used.
- */
- SDLInput* mInput A_NONNULLPOINTER;
-
- /**
- * Holds the focus handler for the Gui.
- */
- FocusHandler* mFocusHandler A_NONNULLPOINTER;
-
- /**
- * Typedef.
- */
- typedef std::list<KeyListener*> KeyListenerList;
-
- /**
- * Typedef.
- */
- typedef KeyListenerList::iterator KeyListenerListIterator;
-
- /**
- * Holds the global key listeners of the Gui.
- */
- KeyListenerList mKeyListeners;
-
- /**
- * Holds the last mouse button pressed.
- */
- MouseButtonT mLastMousePressButton;
-
- /**
- * Holds the last mouse press time stamp.
- */
- unsigned int mLastMousePressTimeStamp;
-
- /**
- * Holds the last mouse x coordinate.
- */
- int mLastMouseX;
-
- /**
- * Holds the last mouse y coordinate.
- */
- int mLastMouseY;
-
- /**
- * Holds the current click count. Used to keep track
- * of clicks for a the last pressed button.
- */
- int mClickCount;
-
- /**
- * Holds the last button used when a drag of a widget
- * was initiated. Used to be able to release a drag
- * when the same button is released.
- */
- MouseButtonT mLastMouseDragButton;
-
- /**
- * Holds a stack with all the widgets with the mouse.
- * Used to properly distribute mouse events.
- */
- std::deque<Widget*> mWidgetWithMouseQueue;
-
- GuiConfigListener *mConfigListener;
- /** The global GUI font */
- Font *mGuiFont A_NONNULLPOINTER;
- /** Font for Info Particles */
- Font *mInfoParticleFont A_NONNULLPOINTER;
- /** Font for Help Window */
- Font *mHelpFont A_NONNULLPOINTER;
- /** Font for secure labels */
- Font *mSecureFont A_NONNULLPOINTER;
- /** Font for npc text */
- Font *mNpcFont A_NONNULLPOINTER;
- /** Mouse cursor images */
- ImageSet *mMouseCursors;
- float mMouseCursorAlpha;
- int mMouseInactivityTimer;
- CursorT mCursorType;
-#ifdef ANDROID
- uint16_t mLastMouseRealX;
- uint16_t mLastMouseRealY;
-#endif // ANDROID
-
- typedef std::list<FocusListener*> FocusListenerList;
- typedef FocusListenerList::iterator FocusListenerIterator;
- FocusListenerList mFocusListeners;
- Color mForegroundColor;
- Color mForegroundColor2;
- time_t mTime;
- time_t mTime10;
- bool mCustomCursor; /**< Show custom cursor */
- bool mDoubleClick;
-};
-
-extern Gui *gui; /**< The GUI system */
-
-/**
- * Bolded text font
- */
-extern Font *boldFont A_NONNULLPOINTER;
-
-#endif // GUI_GUI_H
diff --git a/src/gui/mailmessage.h b/src/gui/mailmessage.h
deleted file mode 100644
index f96a6d675..000000000
--- a/src/gui/mailmessage.h
+++ /dev/null
@@ -1,59 +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 GUI_MAILMESSAGE_H
-#define GUI_MAILMESSAGE_H
-
-#include "enums/net/mailmessagetype.h"
-
-#include <string>
-
-#include "localconsts.h"
-
-struct MailMessage final
-{
- MailMessage() :
- title(),
- sender(),
- strTime(),
- text(),
- id(0),
- time(0),
- expireTime(0),
- money(0),
- type(MailMessageType::Text),
- read(false)
- {
- }
-
- A_DELETE_COPY(MailMessage)
-
- std::string title;
- std::string sender;
- std::string strTime;
- std::string text;
- int64_t id;
- int time;
- int expireTime;
- int64_t money;
- MailMessageType::Type type;
- bool read;
-};
-#endif // GUI_MAILMESSAGE_H
diff --git a/src/gui/models/avatarlistmodel.h b/src/gui/models/avatarlistmodel.h
deleted file mode 100644
index 67ec6846a..000000000
--- a/src/gui/models/avatarlistmodel.h
+++ /dev/null
@@ -1,44 +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 GUI_MODELS_AVATARLISTMODEL_H
-#define GUI_MODELS_AVATARLISTMODEL_H
-
-#include "avatar.h"
-
-#include "gui/models/listmodel.h"
-
-class AvatarListModel notfinal : public ListModel
-{
- public:
- AvatarListModel() :
- ListModel()
- { }
-
- A_DELETE_COPY(AvatarListModel)
-
- virtual Avatar *getAvatarAt(const int i) A_WARN_UNUSED = 0;
-
- std::string getElementAt(int i) override final A_WARN_UNUSED
- { return getAvatarAt(i)->getName(); }
-};
-
-#endif // GUI_MODELS_AVATARLISTMODEL_H
diff --git a/src/gui/models/beingslistmodel.h b/src/gui/models/beingslistmodel.h
deleted file mode 100644
index a0a9d2920..000000000
--- a/src/gui/models/beingslistmodel.h
+++ /dev/null
@@ -1,66 +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 GUI_MODELS_BEINGSLISTMODEL_H
-#define GUI_MODELS_BEINGSLISTMODEL_H
-
-#include "gui/models/avatarlistmodel.h"
-
-#include "utils/cast.h"
-#include "utils/dtor.h"
-#include "utils/vector.h"
-
-class BeingsListModel final : public AvatarListModel
-{
- public:
- BeingsListModel() :
- AvatarListModel(),
- mMembers()
- {
- }
-
- A_DELETE_COPY(BeingsListModel)
-
- ~BeingsListModel()
- {
- delete_all(mMembers);
- mMembers.clear();
- }
-
- STD_VECTOR<Avatar*> *getMembers() RETURNS_NONNULL A_WARN_UNUSED
- {
- return &mMembers;
- }
-
- Avatar *getAvatarAt(int index) override final
- {
- return mMembers[index];
- }
-
- int getNumberOfElements() override final
- {
- return CAST_S32(mMembers.size());
- }
-
- STD_VECTOR<Avatar*> mMembers;
-};
-
-#endif // GUI_MODELS_BEINGSLISTMODEL_H
diff --git a/src/gui/models/colorlistmodel.h b/src/gui/models/colorlistmodel.h
deleted file mode 100644
index bb2d413c2..000000000
--- a/src/gui/models/colorlistmodel.h
+++ /dev/null
@@ -1,87 +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_MODELS_COLORLISTMODEL_H
-#define GUI_MODELS_COLORLISTMODEL_H
-
-#include "gui/models/listmodel.h"
-
-#include "utils/gettext.h"
-
-const char *COLOR_NAME[14] =
-{
- // TRANSLATORS: chat color
- N_("default"),
- // TRANSLATORS: chat color
- N_("black"),
- // TRANSLATORS: chat color
- N_("red"),
- // TRANSLATORS: chat color
- N_("green"),
- // TRANSLATORS: chat color
- N_("blue"),
- // TRANSLATORS: chat color
- N_("gold"),
- // TRANSLATORS: chat color
- N_("yellow"),
- // TRANSLATORS: chat color
- N_("pink"),
- // TRANSLATORS: chat color
- N_("purple"),
- // TRANSLATORS: chat color
- N_("grey"),
- // TRANSLATORS: chat color
- N_("brown"),
- // TRANSLATORS: chat color
- N_("rainbow 1"),
- // TRANSLATORS: chat color
- N_("rainbow 2"),
- // TRANSLATORS: chat color
- N_("rainbow 3"),
-};
-
-class ColorListModel final : public ListModel
-{
- public:
- ColorListModel() :
- ListModel()
- { }
-
- A_DELETE_COPY(ColorListModel)
-
- ~ColorListModel()
- { }
-
- int getNumberOfElements() override final
- {
- return 14;
- }
-
- std::string getElementAt(int i) override final
- {
- if (i >= getNumberOfElements() || i < 0)
- return "???";
- return gettext(COLOR_NAME[i]);
- }
-};
-
-#endif // GUI_MODELS_COLORLISTMODEL_H
diff --git a/src/gui/models/colormodel.cpp b/src/gui/models/colormodel.cpp
deleted file mode 100644
index 3bbded2e2..000000000
--- a/src/gui/models/colormodel.cpp
+++ /dev/null
@@ -1,97 +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 "gui/models/colormodel.h"
-
-#include "gui/widgets/widget2.h"
-
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-ColorModel::ColorModel() :
- ListModel(),
- mNames(),
- mColors()
-{
-}
-
-ColorModel::~ColorModel()
-{
-}
-
-int ColorModel::getNumberOfElements()
-{
- return CAST_S32(mNames.size());
-}
-
-std::string ColorModel::getElementAt(int i)
-{
- if (i >= getNumberOfElements() || i < 0)
- return "???";
- return mNames[CAST_SIZE(i)];
-}
-
-const ColorPair *ColorModel::getColorAt(const int i) const
-{
- if (i >= CAST_S32(mColors.size()) || i < 0)
- return &mColors[0];
-
- return &mColors[CAST_SIZE(i)];
-}
-
-void ColorModel::add(const std::string &name, const Color *const color1,
- const Color *const color2)
-{
- mNames.push_back(name);
- mColors.push_back(ColorPair(color1, color2));
-}
-
-#define addColor(name, color) \
- model->add(name, &widget->getThemeColor(ThemeColorId::color), \
- &widget->getThemeColor(ThemeColorId::color##_OUTLINE));
-
-ColorModel *ColorModel::createDefault(const Widget2 *const widget)
-{
- ColorModel *const model = new ColorModel;
- if (widget == nullptr)
- return model;
- // TRANSLATORS: color name
- addColor(_("black"), BLACK);
- // TRANSLATORS: color name
- addColor(_("red"), RED);
- // TRANSLATORS: color name
- addColor(_("green"), GREEN);
- // TRANSLATORS: color name
- addColor(_("blue"), BLUE);
- // TRANSLATORS: color name
- addColor(_("gold"), ORANGE);
- // TRANSLATORS: color name
- addColor(_("yellow"), YELLOW);
- // TRANSLATORS: color name
- addColor(_("pink"), PINK);
- // TRANSLATORS: color name
- addColor(_("purple"), PURPLE);
- // TRANSLATORS: color name
- addColor(_("grey"), GRAY);
- // TRANSLATORS: color name
- addColor(_("brown"), BROWN);
- return model;
-}
diff --git a/src/gui/models/colormodel.h b/src/gui/models/colormodel.h
deleted file mode 100644
index 9d621dfbe..000000000
--- a/src/gui/models/colormodel.h
+++ /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/>.
- */
-
-#ifndef GUI_MODELS_COLORMODEL_H
-#define GUI_MODELS_COLORMODEL_H
-
-#include "utils/stringvector.h"
-
-#include "gui/colorpair.h"
-
-#include "gui/models/listmodel.h"
-
-#include "localconsts.h"
-
-class Color;
-class Widget2;
-
-class ColorModel final : public ListModel
-{
- public:
- ColorModel();
-
- A_DELETE_COPY(ColorModel)
-
- virtual ~ColorModel();
-
- int getNumberOfElements() override final A_WARN_UNUSED;
-
- std::string getElementAt(int i) override final A_WARN_UNUSED;
-
- const ColorPair *getColorAt(const int i)
- const RETURNS_NONNULL A_WARN_UNUSED;
-
- StringVect &getNames() A_WARN_UNUSED
- { return mNames; }
-
- size_t size() A_WARN_UNUSED
- { return mNames.size(); }
-
- void add(const std::string &name,
- const Color *const color1,
- const Color *const color2);
-
- static ColorModel *createDefault(const Widget2 *const widget)
- RETURNS_NONNULL;
-
- protected:
- StringVect mNames;
- STD_VECTOR<ColorPair> mColors;
-};
-
-#endif // GUI_MODELS_COLORMODEL_H
diff --git a/src/gui/models/extendedlistmodel.h b/src/gui/models/extendedlistmodel.h
deleted file mode 100644
index 981a96897..000000000
--- a/src/gui/models/extendedlistmodel.h
+++ /dev/null
@@ -1,40 +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 GUI_MODELS_EXTENDEDLISTMODEL_H
-#define GUI_MODELS_EXTENDEDLISTMODEL_H
-
-#include "gui/models/listmodel.h"
-
-#include "resources/image/image.h"
-
-class ExtendedListModel notfinal : public ListModel
-{
- public:
- ExtendedListModel() :
- ListModel()
- { }
-
- A_DELETE_COPY(ExtendedListModel)
-
- virtual const Image *getImageAt(int i) A_WARN_UNUSED = 0;
-};
-
-#endif // GUI_MODELS_EXTENDEDLISTMODEL_H
diff --git a/src/gui/models/extendednamesmodel.cpp b/src/gui/models/extendednamesmodel.cpp
deleted file mode 100644
index 76191ae5a..000000000
--- a/src/gui/models/extendednamesmodel.cpp
+++ /dev/null
@@ -1,68 +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 "gui/models/extendednamesmodel.h"
-
-#include "utils/cast.h"
-#include "utils/foreach.h"
-
-#include "debug.h"
-
-ExtendedNamesModel::ExtendedNamesModel() :
- mNames(),
- mImages()
-{
-}
-
-ExtendedNamesModel::~ExtendedNamesModel()
-{
- clear();
-}
-
-int ExtendedNamesModel::getNumberOfElements()
-{
- return CAST_S32(mNames.size());
-}
-
-std::string ExtendedNamesModel::getElementAt(int i)
-{
- if (i >= getNumberOfElements() || i < 0)
- return "???";
- return mNames[CAST_SIZE(i)];
-}
-
-const Image *ExtendedNamesModel::getImageAt(int i)
-{
- if (i >= CAST_S32(mImages.size()) || i < 0)
- return nullptr;
-
- return mImages[CAST_SIZE(i)];
-}
-
-void ExtendedNamesModel::clear()
-{
- mNames.clear();
- FOR_EACH (STD_VECTOR<Image*>::iterator, it, mImages)
- {
- if (*it != nullptr)
- (*it)->decRef();
- }
- mImages.clear();
-}
diff --git a/src/gui/models/extendednamesmodel.h b/src/gui/models/extendednamesmodel.h
deleted file mode 100644
index 2e85a4b2b..000000000
--- a/src/gui/models/extendednamesmodel.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 GUI_MODELS_EXTENDEDNAMESMODEL_H
-#define GUI_MODELS_EXTENDEDNAMESMODEL_H
-
-#include "utils/stringvector.h"
-
-#include "gui/models/extendedlistmodel.h"
-
-class ExtendedNamesModel notfinal : public ExtendedListModel
-{
- public:
- ExtendedNamesModel();
-
- A_DELETE_COPY(ExtendedNamesModel)
-
- virtual ~ExtendedNamesModel();
-
- int getNumberOfElements() override final A_WARN_UNUSED;
-
- std::string getElementAt(int i) override final A_WARN_UNUSED;
-
- const Image *getImageAt(int i) override final A_WARN_UNUSED;
-
- StringVect &getNames() A_WARN_UNUSED
- { return mNames; }
-
- STD_VECTOR<Image*> &getImages() A_WARN_UNUSED
- { return mImages; }
-
- size_t size() A_WARN_UNUSED
- { return mNames.size(); }
-
- void add(const std::string &str)
- { mNames.push_back(str); }
-
- void clear();
-
- protected:
- StringVect mNames;
- STD_VECTOR<Image*> mImages;
-};
-
-#endif // GUI_MODELS_EXTENDEDNAMESMODEL_H
diff --git a/src/gui/models/fontsizechoicelistmodel.h b/src/gui/models/fontsizechoicelistmodel.h
deleted file mode 100644
index 79aecf2fb..000000000
--- a/src/gui/models/fontsizechoicelistmodel.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 GUI_MODELS_FONTSIZECHOICELISTMODEL_H
-#define GUI_MODELS_FONTSIZECHOICELISTMODEL_H
-
-#include "gui/models/listmodel.h"
-
-#include "utils/gettext.h"
-
-#include "localconsts.h"
-
-const int maxFontSizes = 16;
-
-const char *SIZE_NAME[maxFontSizes] =
-{
- // TRANSLATORS: font size
- N_("Very small (8)"),
- // TRANSLATORS: font size
- N_("Very small (9)"),
- // TRANSLATORS: font size
- N_("Tiny (10)"),
- // TRANSLATORS: font size
- N_("Small (11)"),
- // TRANSLATORS: font size
- N_("Medium (12)"),
- // TRANSLATORS: font size
- N_("Normal (13)"),
- // TRANSLATORS: font size
- N_("Large (14)"),
- // TRANSLATORS: font size
- N_("Large (15)"),
- // TRANSLATORS: font size
- N_("Large (16)"),
- // TRANSLATORS: font size
- N_("Big (17)"),
- // TRANSLATORS: font size
- N_("Big (18)"),
- // TRANSLATORS: font size
- N_("Big (19)"),
- // TRANSLATORS: font size
- N_("Very big (20)"),
- // TRANSLATORS: font size
- N_("Very big (21)"),
- // TRANSLATORS: font size
- N_("Very big (22)"),
- // TRANSLATORS: font size
- N_("Huge (23)")
-};
-
-class FontSizeChoiceListModel final : public ListModel
-{
- public:
- FontSizeChoiceListModel() :
- ListModel()
- { }
-
- A_DELETE_COPY(FontSizeChoiceListModel)
-
- ~FontSizeChoiceListModel()
- { }
-
- int getNumberOfElements() override final A_WARN_UNUSED
- { return maxFontSizes; }
-
- std::string getElementAt(int i) override final A_WARN_UNUSED
- {
- if (i >= getNumberOfElements() || i < 0)
- return "???";
-
- return gettext(SIZE_NAME[i]);
- }
-};
-
-#endif // GUI_MODELS_FONTSIZECHOICELISTMODEL_H
diff --git a/src/gui/models/fontsmodel.h b/src/gui/models/fontsmodel.h
deleted file mode 100644
index b7f5fc4be..000000000
--- a/src/gui/models/fontsmodel.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009-2010 Andrei Karas
- * 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_MODELS_FONTSMODEL_H
-#define GUI_MODELS_FONTSMODEL_H
-
-#include "gui/theme.h"
-
-#include "gui/models/namesmodel.h"
-
-#include "localconsts.h"
-
-class FontsModel final : public NamesModel
-{
- public:
- FontsModel() :
- NamesModel()
- { Theme::fillFontsList(mNames); }
-
- A_DELETE_COPY(FontsModel)
-
- ~FontsModel()
- { }
-};
-
-#endif // GUI_MODELS_FONTSMODEL_H
diff --git a/src/gui/models/iconsmodel.h b/src/gui/models/iconsmodel.h
deleted file mode 100644
index 4028895fb..000000000
--- a/src/gui/models/iconsmodel.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 Andrei Karas
- * 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_MODELS_ICONSMODEL_H
-#define GUI_MODELS_ICONSMODEL_H
-
-#include "gui/models/listmodel.h"
-
-#include "utils/foreach.h"
-
-#include "resources/iteminfo.h"
-
-#include "resources/db/itemdb.h"
-
-#include <list>
-
-#include "localconsts.h"
-
-class IconsModel final : public ListModel
-{
- public:
- IconsModel() :
- mStrings()
- {
- const std::map<int, ItemInfo*> &items = ItemDB::getItemInfos();
- std::list<std::string> tempStrings;
-
- for (std::map<int, ItemInfo*>::const_iterator
- i = items.begin(), i_end = items.end();
- i != i_end; ++i)
- {
- if (i->first < 0)
- continue;
-
- const ItemInfo &info = (*i->second);
- const std::string &name = info.getName();
- if (name != "unnamed" && !info.getName().empty()
- && info.getName() != "unnamed")
- {
- tempStrings.push_back(name);
- }
- }
- tempStrings.sort();
- mStrings.push_back("");
- FOR_EACH (std::list<std::string>::const_iterator, i, tempStrings)
- mStrings.push_back(*i);
- }
-
- A_DELETE_COPY(IconsModel)
-
- ~IconsModel()
- { }
-
- int getNumberOfElements() override final
- {
- return CAST_S32(mStrings.size());
- }
-
- std::string getElementAt(int i) override final
- {
- if (i < 0 || i >= getNumberOfElements())
- return "???";
- return mStrings.at(i);
- }
- private:
- StringVect mStrings;
-};
-
-#endif // GUI_MODELS_ICONSMODEL_H
diff --git a/src/gui/models/ignorechoiceslistmodel.h b/src/gui/models/ignorechoiceslistmodel.h
deleted file mode 100644
index 6cd8bbe87..000000000
--- a/src/gui/models/ignorechoiceslistmodel.h
+++ /dev/null
@@ -1,64 +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 GUI_MODELS_IGNORECHOICESLISTMODEL_H
-#define GUI_MODELS_IGNORECHOICESLISTMODEL_H
-
-#include "gui/models/playerrelationlistmodel.h"
-
-#include "being/playerignorestrategy.h"
-#include "being/playerrelations.h"
-
-#include "utils/cast.h"
-
-/**
- * Class for choosing one of the various `what to do when ignoring a player' options
- */
-class IgnoreChoicesListModel final : public ListModel
-{
- public:
- IgnoreChoicesListModel() :
- ListModel()
- { }
-
- A_DELETE_COPY(IgnoreChoicesListModel)
-
- ~IgnoreChoicesListModel()
- { }
-
- int getNumberOfElements() override final
- {
- return CAST_S32(playerRelations.
- getPlayerIgnoreStrategies()->size());
- }
-
- std::string getElementAt(int i) override final
- {
- if (i >= getNumberOfElements() || i < 0)
- return "???";
-
- return (*playerRelations.getPlayerIgnoreStrategies())
- [i]->mDescription;
- }
-};
-
-#endif // GUI_MODELS_IGNORECHOICESLISTMODEL_H
diff --git a/src/gui/models/itemsmodel.h b/src/gui/models/itemsmodel.h
deleted file mode 100644
index a49a7cfc5..000000000
--- a/src/gui/models/itemsmodel.h
+++ /dev/null
@@ -1,88 +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_MODELS_ITEMSMODEL_H
-#define GUI_MODELS_ITEMSMODEL_H
-
-#include "gui/models/listmodel.h"
-
-#include "resources/iteminfo.h"
-
-#include "resources/db/itemdb.h"
-
-#include "utils/foreach.h"
-
-#include <list>
-
-#include "localconsts.h"
-
-class ItemsModal final : public ListModel
-{
- public:
- ItemsModal() :
- mStrings()
- {
- const std::map<int, ItemInfo*> &items = ItemDB::getItemInfos();
- std::list<std::string> tempStrings;
-
- for (std::map<int, ItemInfo*>::const_iterator
- i = items.begin(), i_end = items.end();
- i != i_end; ++i)
- {
- if (i->first < 0)
- continue;
-
- const ItemInfo &info = *i->second;
- const std::string &name = info.getName();
- if (name != "unnamed" && !info.getName().empty()
- && info.getName() != "unnamed")
- {
- tempStrings.push_back(name);
- }
- }
- tempStrings.sort();
- FOR_EACH (std::list<std::string>::const_iterator, i, tempStrings)
- mStrings.push_back(*i);
- }
-
- A_DELETE_COPY(ItemsModal)
-
- ~ItemsModal()
- { }
-
- int getNumberOfElements() override final
- {
- return CAST_S32(mStrings.size());
- }
-
- std::string getElementAt(int i) override final
- {
- if (i < 0 || i >= getNumberOfElements())
- return "???";
- return mStrings.at(i);
- }
-
- private:
- StringVect mStrings;
-};
-
-#endif // GUI_MODELS_ITEMSMODEL_H
diff --git a/src/gui/models/keylistmodel.h b/src/gui/models/keylistmodel.h
deleted file mode 100644
index 601426f8a..000000000
--- a/src/gui/models/keylistmodel.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2007 Joshua Langley <joshlangley@optusnet.com.au>
- * 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 GUI_MODELS_KEYLISTMODEL_H
-#define GUI_MODELS_KEYLISTMODEL_H
-
-#include "gui/setupactiondata.h"
-
-#include "gui/models/listmodel.h"
-
-#include "localconsts.h"
-
-extern SetupActionData *const setupActionData[];
-
-/**
- * The list model for key function list.
- *
- * \ingroup Interface
- */
-class KeyListModel final : public ListModel
-{
- public:
- KeyListModel() :
- mDataNum(0),
- mSelectedData(0),
- mSize(0)
- {
- }
-
- A_DELETE_COPY(KeyListModel)
-
- /**
- * Returns the number of elements in container.
- */
- int getNumberOfElements() override final
- { return mSize; }
-
- /**
- * Returns element from container.
- */
- std::string getElementAt(int i) override final
- { return setupActionData[mSelectedData][i].text; }
-
- /**
- * Sets element from container.
- */
- void setElementAt(const int i, const std::string &caption)
- { setupActionData[mSelectedData][i].text = caption; }
-
- void setSize(const int size) noexcept2
- { mSize = size; }
-
- void setDataNum(const int num) noexcept2
- { mDataNum = num; }
-
- void setSelectedData(const int i) noexcept2
- { mSelectedData = i; }
-
- int getSelectedData() const noexcept2 A_WARN_UNUSED
- { return mSelectedData; }
-
- private:
- int mDataNum;
- int mSelectedData;
- int mSize;
-};
-
-#endif // GUI_MODELS_KEYLISTMODEL_H
diff --git a/src/gui/models/langlistmodel.h b/src/gui/models/langlistmodel.h
deleted file mode 100644
index f8c67ad30..000000000
--- a/src/gui/models/langlistmodel.h
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009-2010 Andrei Karas
- * 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_MODELS_LANGLISTMODEL_H
-#define GUI_MODELS_LANGLISTMODEL_H
-
-#include "gui/models/extendedlistmodel.h"
-
-#include "resources/loaders/imageloader.h"
-
-#include "utils/gettext.h"
-
-#include "localconsts.h"
-
-struct Language final
-{
- A_DEFAULT_COPY(Language)
-
- std::string name;
- std::string value;
- std::string icon;
-};
-
-const int langs_count = 22;
-
-const Language LANG_NAME[langs_count] =
-{
- // TRANSLATORS: language
- {N_("(default)"), "", ""},
- // TRANSLATORS: language
- {N_("Catalan"), "ca_ES", "ca.png"},
- // TRANSLATORS: language
- {N_("Chinese (China)"), "zh_CN", "cn.png"},
- // TRANSLATORS: language
- {N_("Chinese (Hong Kong)"), "zh_HK", "hk.png"},
- // TRANSLATORS: language
- {N_("Czech"), "cs_CZ", "cz.png"},
- // TRANSLATORS: language
- {N_("Dutch (Belgium/Flemish)"), "nl_BE", "nl_BE.png"},
- // TRANSLATORS: language
- {N_("English"), "C", "en.png"},
- // TRANSLATORS: language
- {N_("Finnish"), "fi_FI", "fi.png"},
- // TRANSLATORS: language
- {N_("French"), "fr_FR", "fr.png"},
- // TRANSLATORS: language
- {N_("German"), "de_DE", "de.png"},
- // TRANSLATORS: language
- {N_("Indonesian"), "id_ID", "id.png"},
- // TRANSLATORS: language
- {N_("Italian"), "it_IT", "it.png"},
- // TRANSLATORS: language
- {N_("Japanese"), "ja_JP", "jp.png"},
- // TRANSLATORS: language
- {N_("Polish"), "pl_PL", "pl.png"},
- // TRANSLATORS: language
- {N_("Portuguese"), "pt_PT", "pt.png"},
- // TRANSLATORS: language
- {N_("Portuguese (Brazilian)"), "pt_BR", "pt_BR.png"},
- // TRANSLATORS: language
- {N_("Russian"), "ru_RU", "ru.png"},
- // TRANSLATORS: language
- {N_("Spanish (Castilian)"), "es_ES", "es.png"},
- // TRANSLATORS: language
- {N_("Swedish (Sweden)"), "sv_SE", "se.png"},
- // TRANSLATORS: language
- {N_("Turkish"), "tr_TR", "tr.png"},
- // TRANSLATORS: language
- {N_("Ukrainian"), "uk_UA", "ua.png"},
- // TRANSLATORS: language
- {N_("Esperanto"), "eo", "eo.png"}
-};
-
-class LangListModel final : public ExtendedListModel
-{
- public:
- LangListModel()
- {
- for (int f = 0; f < langs_count; f ++)
- {
- const std::string icon = LANG_NAME[f].icon;
- if (!icon.empty())
- {
- mIcons[f] = Loader::getImage("graphics/flags/"
- + icon);
- }
- else
- {
- mIcons[f] = nullptr;
- }
- }
- }
-
- A_DELETE_COPY(LangListModel)
-
- ~LangListModel()
- {
- for (int f = 0; f < langs_count; f ++)
- {
- Image *const img = mIcons[f];
- if (img != nullptr)
- img->decRef();
- }
- }
-
- int getNumberOfElements() override final A_WARN_UNUSED
- { return langs_count; }
-
- std::string getElementAt(int i) override final A_WARN_UNUSED
- {
- if (i >= getNumberOfElements() || i < 0)
- return "???";
-
- return gettext(LANG_NAME[i].name.c_str());
- }
-
- const Image *getImageAt(int i) override final A_WARN_UNUSED
- {
- if (i >= getNumberOfElements() || i < 0)
- return nullptr;
- return mIcons[i];
- }
-
- Image *mIcons[langs_count] A_NONNULLPOINTER;
-};
-
-#endif // GUI_MODELS_LANGLISTMODEL_H
diff --git a/src/gui/models/listmodel.h b/src/gui/models/listmodel.h
deleted file mode 100644
index df8db8b54..000000000
--- a/src/gui/models/listmodel.h
+++ /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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GUI_MODELS_LISTMODEL_H
-#define GUI_MODELS_LISTMODEL_H
-
-#include <string>
-
-#include "localconsts.h"
-
-/**
- * An interface for a model that represents a list. It is
- * used in certain widgets, like the ListBox, to handle a
- * lists with string elements. If you want to use widgets
- * like ListBox, make a derived class from this class that
- * represents your list.
- */
-class ListModel notfinal
-{
- public:
- ListModel()
- { }
-
- A_DELETE_COPY(ListModel)
-
- /**
- * Destructor.
- */
- virtual ~ListModel()
- { }
-
- /**
- * Gets the number of elements in the list.
- *
- * @return The number of elements in the list
- */
- virtual int getNumberOfElements() A_WARN_UNUSED = 0;
-
- /**
- * Gets an element at a certain index in the list.
- *
- * @param i An index in the list.
- * @return An element as a string at the a certain index.
- */
- virtual std::string getElementAt(int i) A_WARN_UNUSED = 0;
-};
-
-#endif // GUI_MODELS_LISTMODEL_H
diff --git a/src/gui/models/magicschoolmodel.h b/src/gui/models/magicschoolmodel.h
deleted file mode 100644
index 2dcd01880..000000000
--- a/src/gui/models/magicschoolmodel.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 Andrei Karas
- * 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_MODELS_MAGICSCHOOLMODEL_H
-#define GUI_MODELS_MAGICSCHOOLMODEL_H
-
-#include "gui/models/listmodel.h"
-
-#include "utils/gettext.h"
-
-#include "localconsts.h"
-
-const char *MAGIC_SCHOOL_TEXT[6] =
-{
- // TRANSLATORS: magic school
- N_("General Magic"),
- // TRANSLATORS: magic school
- N_("Life Magic"),
- // TRANSLATORS: magic school
- N_("War Magic"),
- // TRANSLATORS: magic school
- N_("Transmute Magic"),
- // TRANSLATORS: magic school
- N_("Nature Magic"),
- // TRANSLATORS: magic school
- N_("Astral Magic")
-};
-
-class MagicSchoolModel final : public ListModel
-{
- public:
- MagicSchoolModel() :
- ListModel()
- { }
-
- A_DELETE_COPY(MagicSchoolModel)
-
- ~MagicSchoolModel()
- { }
-
- int getNumberOfElements() override final
- {
- return 6;
- }
-
- std::string getElementAt(int i) override final
- {
- if (i >= getNumberOfElements() || i < 0)
- return "???";
- return MAGIC_SCHOOL_TEXT[i];
- }
-};
-
-#endif // GUI_MODELS_MAGICSCHOOLMODEL_H
diff --git a/src/gui/models/modelistmodel.cpp b/src/gui/models/modelistmodel.cpp
deleted file mode 100644
index d1253b9f1..000000000
--- a/src/gui/models/modelistmodel.cpp
+++ /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/>.
- */
-
-#include "render/graphics.h"
-
-#include "utils/sdlhelper.h"
-#include "utils/stringutils.h"
-
-#include "gui/models/modelistmodel.h"
-
-#include <algorithm>
-
-#include "debug.h"
-
-#ifndef ANDROID
-static bool modeSorter(const std::string &mode1, const std::string &mode2)
-{
- const int width1 = atoi(mode1.substr(0, mode1.find('x')).c_str());
- const int height1 = atoi(mode1.substr(mode1.find('x') + 1).c_str());
- if ((width1 == 0) || (height1 == 0))
- return false;
-
- const int width2 = atoi(mode2.substr(0, mode2.find('x')).c_str());
- const int height2 = atoi(mode2.substr(mode2.find('x') + 1).c_str());
- if ((width2 == 0) || (height2 == 0))
- return false;
- if (width1 != width2)
- return width1 < width2;
-
- if (height1 != height2)
- return height1 < height2;
-
- return false;
-}
-#endif // ANDROID
-
-ModeListModel::ModeListModel() :
- ListModel(),
- mVideoModes()
-{
- SDL::getAllVideoModes(mVideoModes);
-#ifndef ANDROID
- addCustomMode("640x480");
- addCustomMode("800x600");
- addCustomMode("1024x768");
- addCustomMode("1280x1024");
- addCustomMode("1400x900");
- addCustomMode("1500x990");
- addCustomMode(toString(mainGraphics->mActualWidth).append("x")
- .append(toString(mainGraphics->mActualHeight)));
-
- std::sort(mVideoModes.begin(), mVideoModes.end(), &modeSorter);
- mVideoModes.push_back("custom");
-#endif // ANDROID
-}
-
-#ifndef ANDROID
-void ModeListModel::addCustomMode(const std::string &mode)
-{
- StringVectCIter it = mVideoModes.begin();
- const StringVectCIter it_end = mVideoModes.end();
- while (it != it_end)
- {
- if (*it == mode)
- return;
- ++ it;
- }
- mVideoModes.push_back(mode);
-}
-#endif // ANDROID
-
-int ModeListModel::getIndexOf(const std::string &widthXHeightMode)
-{
- std::string currentMode;
- for (int i = 0; i < getNumberOfElements(); i++)
- {
- currentMode = getElementAt(i);
- if (currentMode == widthXHeightMode)
- return i;
- }
- return -1;
-}
diff --git a/src/gui/models/modelistmodel.h b/src/gui/models/modelistmodel.h
deleted file mode 100644
index ed4d449d7..000000000
--- a/src/gui/models/modelistmodel.h
+++ /dev/null
@@ -1,70 +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_MODELS_MODELISTMODEL_H
-#define GUI_MODELS_MODELISTMODEL_H
-
-#include "gui/models/listmodel.h"
-
-#include "utils/cast.h"
-#include "utils/stringvector.h"
-
-#include "localconsts.h"
-
-class ModeListModel final : public ListModel
-{
- public:
- ModeListModel();
-
- A_DELETE_COPY(ModeListModel)
-
- ~ModeListModel()
- { }
-
- /**
- * Returns the number of elements in container.
- */
- int getNumberOfElements() override final
- { return CAST_S32(mVideoModes.size()); }
-
- /**
- * Returns element from container.
- */
- std::string getElementAt(int i) override final
- { return mVideoModes[CAST_SIZE(i)]; }
-
- /**
- * Returns the index corresponding to the given video mode.
- * E.g.: "800x600".
- * or -1 if not found.
- */
- int getIndexOf(const std::string &widthXHeightMode);
-
- private:
-#ifndef ANDROID
- void addCustomMode(const std::string &mode);
-#endif // ANDROID
-
- StringVect mVideoModes;
-};
-
-#endif // GUI_MODELS_MODELISTMODEL_H
diff --git a/src/gui/models/namesmodel.cpp b/src/gui/models/namesmodel.cpp
deleted file mode 100644
index 5344a7a7d..000000000
--- a/src/gui/models/namesmodel.cpp
+++ /dev/null
@@ -1,68 +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 "gui/models/namesmodel.h"
-
-#include "utils/cast.h"
-#include "utils/foreach.h"
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-NamesModel::NamesModel() :
- ListModel(),
- mNames()
-{
-}
-
-NamesModel::~NamesModel()
-{
-}
-
-int NamesModel::getNumberOfElements()
-{
- return CAST_S32(mNames.size());
-}
-
-std::string NamesModel::getElementAt(int i)
-{
- if (i >= getNumberOfElements() || i < 0)
- return "???";
- return mNames[CAST_SIZE(i)];
-}
-
-void NamesModel::fillFromArray(const char *const *const arr,
- const std::size_t sz)
-{
- if (arr == nullptr)
- return;
- for (size_t f = 0; f < sz; f ++)
- mNames.push_back(gettext(arr[f]));
-}
-
-void NamesModel::fillFromVector(const StringVect &vect)
-{
- FOR_EACH(StringVectCIter, it, vect)
- {
- const std::string str = *it;
- if (!str.empty())
- mNames.push_back(str);
- }
-}
diff --git a/src/gui/models/namesmodel.h b/src/gui/models/namesmodel.h
deleted file mode 100644
index a239bd9aa..000000000
--- a/src/gui/models/namesmodel.h
+++ /dev/null
@@ -1,64 +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 GUI_MODELS_NAMESMODEL_H
-#define GUI_MODELS_NAMESMODEL_H
-
-#include "utils/stringvector.h"
-
-#include "gui/models/listmodel.h"
-
-#include "localconsts.h"
-
-class NamesModel notfinal : public ListModel
-{
- public:
- NamesModel();
-
- A_DELETE_COPY(NamesModel)
-
- virtual ~NamesModel();
-
- int getNumberOfElements() override final A_WARN_UNUSED;
-
- std::string getElementAt(int i) override final A_WARN_UNUSED;
-
- StringVect &getNames() noexcept2 A_WARN_UNUSED
- { return mNames; }
-
- size_t size() const noexcept2 A_WARN_UNUSED
- { return mNames.size(); }
-
- void clear()
- { mNames.clear(); }
-
- void add(const std::string &str)
- { mNames.push_back(str); }
-
- void fillFromArray(const char *const *const arr,
- const std::size_t size);
-
- void fillFromVector(const StringVect &vect);
-
- protected:
- StringVect mNames;
-};
-
-#endif // GUI_MODELS_NAMESMODEL_H
diff --git a/src/gui/models/opengllistmodel.h b/src/gui/models/opengllistmodel.h
deleted file mode 100644
index 085dd17a5..000000000
--- a/src/gui/models/opengllistmodel.h
+++ /dev/null
@@ -1,53 +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 GUI_MODELS_OPENGLLISTMODEL_H
-#define GUI_MODELS_OPENGLLISTMODEL_H
-
-#include "gui/models/listmodel.h"
-
-#include "render/rendererslistsdl.h"
-
-#include "localconsts.h"
-
-class OpenGLListModel final : public ListModel
-{
- public:
- OpenGLListModel() :
- ListModel()
- { }
-
- A_DELETE_COPY(OpenGLListModel)
-
- ~OpenGLListModel()
- { }
-
- int getNumberOfElements() override final
- { return renderModesListSize; }
-
- std::string getElementAt(int i) override final
- {
- if (i >= getNumberOfElements() || i < 0)
- return "???";
- return gettext(OPENGL_NAME[i]);
- }
-};
-
-#endif // GUI_MODELS_OPENGLLISTMODEL_H
diff --git a/src/gui/models/playerrelationlistmodel.h b/src/gui/models/playerrelationlistmodel.h
deleted file mode 100644
index 5e58d4905..000000000
--- a/src/gui/models/playerrelationlistmodel.h
+++ /dev/null
@@ -1,75 +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 GUI_MODELS_PLAYERRELATIONLISTMODEL_H
-#define GUI_MODELS_PLAYERRELATIONLISTMODEL_H
-
-#include "being/playerrelation.h"
-
-#include "gui/models/listmodel.h"
-
-#include "utils/gettext.h"
-
-static const char *const RELATION_NAMES[PlayerRelation::RELATIONS_NR] =
-{
- // TRANSLATORS: relation type
- N_("Neutral"),
- // TRANSLATORS: relation type
- N_("Friend"),
- // TRANSLATORS: relation type
- N_("Disregarded"),
- // TRANSLATORS: relation type
- N_("Ignored"),
- // TRANSLATORS: relation type
- N_("Erased"),
- // TRANSLATORS: relation type
- N_("Blacklisted"),
- // TRANSLATORS: relation type
- N_("Enemy")
-};
-
-class PlayerRelationListModel final : public ListModel
-{
- public:
- PlayerRelationListModel() :
- ListModel()
- { }
-
- A_DELETE_COPY(PlayerRelationListModel)
-
- ~PlayerRelationListModel()
- { }
-
- int getNumberOfElements() override final
- {
- return PlayerRelation::RELATIONS_NR;
- }
-
- std::string getElementAt(int i) override final
- {
- if (i >= getNumberOfElements() || i < 0)
- return "";
- return gettext(RELATION_NAMES[i]);
- }
-};
-
-#endif // GUI_MODELS_PLAYERRELATIONLISTMODEL_H
diff --git a/src/gui/models/playertablemodel.cpp b/src/gui/models/playertablemodel.cpp
deleted file mode 100644
index 271b6a5bb..000000000
--- a/src/gui/models/playertablemodel.cpp
+++ /dev/null
@@ -1,148 +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 "gui/models/playertablemodel.h"
-
-#include "being/playerrelations.h"
-
-#include "gui/widgets/dropdown.h"
-#include "gui/widgets/label.h"
-
-#include "gui/models/playerrelationlistmodel.h"
-
-#include "utils/delete2.h"
-#include "utils/dtor.h"
-
-#include "debug.h"
-
-static const int COLUMNS_NR = 2; // name plus listbox
-static const int NAME_COLUMN = 0;
-static const unsigned int RELATION_CHOICE_COLUMN = 1;
-
-static const unsigned int ROW_HEIGHT = 12;
-// The following column widths really shouldn't be hardcoded
-// but should scale with the size of the widget... except
-// that, right now, the widget doesn't exactly scale either.
-static const unsigned int NAME_COLUMN_WIDTH = 230;
-static const unsigned int RELATION_CHOICE_COLUMN_WIDTH = 80;
-
-#define WIDGET_AT(row, column) (((row) * COLUMNS_NR) + column)
-
-PlayerTableModel::PlayerTableModel(const Widget2 *const widget) :
- Widget2(widget),
- TableModel(),
- mPlayers(nullptr),
- mWidgets(),
- mListModel(new PlayerRelationListModel)
-{
- playerRelationsUpdated();
-}
-
-PlayerTableModel::~PlayerTableModel()
-{
- freeWidgets();
- delete2(mListModel)
- delete2(mPlayers)
-}
-
-int PlayerTableModel::getRows() const
-{
- if (mPlayers != nullptr)
- return CAST_S32(mPlayers->size());
- return 0;
-}
-
-int PlayerTableModel::getColumns() const
-{
- return COLUMNS_NR;
-}
-
-int PlayerTableModel::getRowHeight() const
-{
- return ROW_HEIGHT;
-}
-
-int PlayerTableModel::getColumnWidth(const int index) const
-{
- if (index == NAME_COLUMN)
- return NAME_COLUMN_WIDTH;
- return RELATION_CHOICE_COLUMN_WIDTH;
-}
-
-void PlayerTableModel::playerRelationsUpdated()
-{
- signalBeforeUpdate();
-
- freeWidgets();
- StringVect *const player_names = playerRelations.getPlayers();
- delete mPlayers;
- mPlayers = player_names;
-
- // set up widgets
- for (unsigned int r = 0, fsz = CAST_U32(
- player_names->size()); r < fsz; ++r)
- {
- const std::string name = (*player_names)[r];
- Widget *const widget = new Label(this, name);
- mWidgets.push_back(widget);
-
- DropDown *const choicebox = new DropDown(this, mListModel);
- choicebox->setSelected(CAST_S32(
- playerRelations.getRelation(name)));
- mWidgets.push_back(choicebox);
- }
-
- signalAfterUpdate();
-}
-
-void PlayerTableModel::updateModelInRow(const int row) const
-{
- const DropDown *const choicebox = static_cast<DropDown *>(
- getElementAt(row, RELATION_CHOICE_COLUMN));
- if (choicebox == nullptr)
- return;
- playerRelations.setRelation(getPlayerAt(row),
- static_cast<RelationT>(
- choicebox->getSelected()));
-}
-
-Widget *PlayerTableModel::getElementAt(int row, int column) const
-{
- return mWidgets[WIDGET_AT(row, column)];
-}
-
-void PlayerTableModel::freeWidgets()
-{
- delete2(mPlayers)
- delete_all(mWidgets);
- mWidgets.clear();
-}
-
-std::string PlayerTableModel::getPlayerAt(const int index) const
-{
- if ((mPlayers == nullptr) || index < 0
- || index >= CAST_S32(mPlayers->size()))
- {
- return std::string();
- }
- return (*mPlayers)[index];
-}
diff --git a/src/gui/models/playertablemodel.h b/src/gui/models/playertablemodel.h
deleted file mode 100644
index dfb00eeb4..000000000
--- a/src/gui/models/playertablemodel.h
+++ /dev/null
@@ -1,68 +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 GUI_MODELS_PLAYERTABLEMODEL_H
-#define GUI_MODELS_PLAYERTABLEMODEL_H
-
-#include "gui/widgets/widget2.h"
-
-#include "gui/models/tablemodel.h"
-
-#include "localconsts.h"
-
-class PlayerRelationListModel;
-
-class PlayerTableModel final : public Widget2,
- public TableModel
-{
- public:
- explicit PlayerTableModel(const Widget2 *const widget);
-
- A_DELETE_COPY(PlayerTableModel)
-
- ~PlayerTableModel();
-
- int getRows() const override final;
-
- int getColumns() const override final A_CONST;
-
- int getRowHeight() const override final A_CONST;
-
- int getColumnWidth(const int index) const override final A_CONST;
-
- void playerRelationsUpdated();
-
- void updateModelInRow(const int row) const;
-
- Widget *getElementAt(int row, int column) const override final;
-
- void freeWidgets();
-
- std::string getPlayerAt(const int index) const;
-
- protected:
- StringVect *mPlayers;
- STD_VECTOR<Widget *> mWidgets;
- PlayerRelationListModel *mListModel;
-};
-
-#endif // GUI_MODELS_PLAYERTABLEMODEL_H
diff --git a/src/gui/models/questsmodel.h b/src/gui/models/questsmodel.h
deleted file mode 100644
index f80e7a32d..000000000
--- a/src/gui/models/questsmodel.h
+++ /dev/null
@@ -1,40 +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 GUI_MODELS_QUESTSMODEL_H
-#define GUI_MODELS_QUESTSMODEL_H
-
-#include "gui/models/extendednamesmodel.h"
-
-class QuestsModel final : public ExtendedNamesModel
-{
- public:
- QuestsModel() :
- ExtendedNamesModel()
- {
- }
-
- A_DELETE_COPY(QuestsModel)
-
- ~QuestsModel()
- { }
-};
-
-#endif // GUI_MODELS_QUESTSMODEL_H
diff --git a/src/gui/models/serverslistmodel.h b/src/gui/models/serverslistmodel.h
deleted file mode 100644
index 8e236ebe0..000000000
--- a/src/gui/models/serverslistmodel.h
+++ /dev/null
@@ -1,119 +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_MODELS_SERVERSLISTMODEL_H
-#define GUI_MODELS_SERVERSLISTMODEL_H
-
-#include "gui/gui.h"
-
-#include "gui/fonts/font.h"
-
-#include "gui/windows/serverdialog.h"
-
-#include "gui/models/listmodel.h"
-
-#include "utils/gettext.h"
-
-/**
- * Server and Port List Model
- */
-class ServersListModel final : public ListModel
-{
- public:
- typedef std::pair<int, std::string> VersionString;
-
- ServersListModel(ServerInfos *const servers,
- ServerDialog *const parent) :
- mServers(servers),
- mVersionStrings(servers != nullptr ? servers->size() : 0,
- VersionString(0, "")),
- mParent(parent)
- {
- }
-
- A_DELETE_COPY(ServersListModel)
-
- /**
- * Used to get number of line in the list
- */
- int getNumberOfElements() override final A_WARN_UNUSED
- {
- MutexLocker lock = mParent->lock();
- return CAST_S32(mServers->size());
- }
-
- /**
- * Used to get an element from the list
- */
- std::string getElementAt(int elementIndex)
- override final A_WARN_UNUSED
- {
- MutexLocker lock = mParent->lock();
- const ServerInfo &server = mServers->at(elementIndex);
- std::string myServer;
- if (server.freeType == ServerFreeType::NonFree)
- {
- // TRANSLATORS: server license comment
- myServer.append(_("(NON FREE)"));
- myServer.append(" ");
- }
- else if (server.freeType == ServerFreeType::Unknown)
- {
- // TRANSLATORS: server license comment
- myServer.append(_("(UNKNOWN)"));
- myServer.append(" ");
- }
- myServer.append(server.hostname);
- return myServer;
- }
-
- /**
- * Used to get the corresponding Server struct
- */
- const ServerInfo &getServer(const int elementIndex) const A_WARN_UNUSED
- { return mServers->at(elementIndex); }
-
- void setVersionString(const int index, const std::string &version)
- {
- if (index < 0 || index >= CAST_S32(mVersionStrings.size()))
- return;
-
- if (version.empty() || (gui == nullptr))
- {
- mVersionStrings[index] = VersionString(0, "");
- }
- else
- {
- mVersionStrings[index] = VersionString(
- gui->getFont()->getWidth(version), version);
- }
- }
-
- private:
- typedef STD_VECTOR<VersionString> VersionStrings;
-
- ServerInfos *mServers;
- VersionStrings mVersionStrings;
- ServerDialog *mParent;
-};
-
-#endif // GUI_MODELS_SERVERSLISTMODEL_H
diff --git a/src/gui/models/shopitems.cpp b/src/gui/models/shopitems.cpp
deleted file mode 100644
index 27e05ff12..000000000
--- a/src/gui/models/shopitems.cpp
+++ /dev/null
@@ -1,206 +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 "gui/models/shopitems.h"
-
-#include "resources/item/shopitem.h"
-
-#include "utils/dtor.h"
-#include "utils/foreach.h"
-
-#include "debug.h"
-
-ShopItems::ShopItems(const bool mergeDuplicates,
- const std::string &currency) :
- ListModel(),
- mAllShopItems(),
- mShopItems(),
- mCurrency(currency),
- mMergeDuplicates(mergeDuplicates)
-{
-}
-
-ShopItems::~ShopItems()
-{
- clear();
-}
-
-std::string ShopItems::getElementAt(int i)
-{
- if (i < 0 || CAST_U32(i)
- >= CAST_U32(mShopItems.size()) || (mShopItems.at(i) == nullptr))
- {
- return "";
- }
-
- return mShopItems.at(i)->getDisplayName();
-}
-
-ShopItem *ShopItems::addItem(const int id,
- const ItemTypeT type,
- const ItemColor color,
- const int amount,
- const int price)
-{
- ShopItem *const item = new ShopItem(-1,
- id,
- type,
- color,
- amount,
- price,
- mCurrency);
- mShopItems.push_back(item);
- mAllShopItems.push_back(item);
- return item;
-}
-
-ShopItem *ShopItems::addItemNoDup(const int id,
- const ItemTypeT type,
- const ItemColor color,
- const int amount,
- const int price)
-{
- ShopItem *item = findItem(id, color);
- if (item == nullptr)
- {
- item = new ShopItem(-1,
- id,
- type,
- color,
- amount,
- price,
- mCurrency);
- mShopItems.push_back(item);
- mAllShopItems.push_back(item);
- }
- return item;
-}
-
-ShopItem *ShopItems::addItem2(const int inventoryIndex,
- const int id,
- const ItemTypeT type,
- const ItemColor color,
- const int quantity,
- const int price)
-{
- ShopItem *item = nullptr;
- if (mMergeDuplicates)
- item = findItem(id, color);
-
- if (item != nullptr)
- {
- item->addDuplicate(inventoryIndex, quantity);
- }
- else
- {
- item = new ShopItem(inventoryIndex,
- id,
- type,
- color,
- quantity,
- price,
- mCurrency);
- mShopItems.push_back(item);
- mAllShopItems.push_back(item);
- }
- return item;
-}
-
-ShopItem *ShopItems::at(const size_t i) const
-{
- if (i >= mShopItems.size())
- return nullptr;
-
- return mShopItems.at(i);
-}
-
-bool ShopItems::findInAllItems(STD_VECTOR<ShopItem*>::iterator &it,
- const ShopItem *const item)
-{
- const STD_VECTOR<ShopItem*>::iterator it_end = mAllShopItems.end();
- for (it = mAllShopItems.begin(); it != it_end; ++ it)
- {
- if (*it == item)
- return true;
- }
- return false;
-}
-
-void ShopItems::erase(const unsigned int i)
-{
- if (i >= CAST_U32(mShopItems.size()))
- return;
-
- const ShopItem *const item = *(mShopItems.begin() + i);
- STD_VECTOR<ShopItem*>::iterator it;
- if (findInAllItems(it, item))
- mAllShopItems.erase(it);
- mShopItems.erase(mShopItems.begin() + i);
-}
-
-void ShopItems::del(const unsigned int i)
-{
- if (i >= CAST_U32(mShopItems.size()))
- return;
-
- ShopItem *item = *(mShopItems.begin() + i);
- STD_VECTOR<ShopItem*>::iterator it;
- if (findInAllItems(it, item))
- mAllShopItems.erase(it);
- mShopItems.erase(mShopItems.begin() + i);
- delete item;
-}
-
-void ShopItems::clear()
-{
- delete_all(mAllShopItems);
- mAllShopItems.clear();
- mShopItems.clear();
-}
-
-ShopItem *ShopItems::findItem(const int id,
- const ItemColor color) const
-{
- STD_VECTOR<ShopItem*>::const_iterator it = mShopItems.begin();
- const STD_VECTOR<ShopItem*>::const_iterator e = mShopItems.end();
- while (it != e)
- {
- ShopItem *const item = *it;
- if (item->getId() == id && item->getColor() == color)
- return item;
-
- ++it;
- }
-
- return nullptr;
-}
-
-void ShopItems::updateList()
-{
- mShopItems.clear();
- FOR_EACH (STD_VECTOR<ShopItem*>::iterator, it, mAllShopItems)
- {
- ShopItem *const item = *it;
- if ((item != nullptr) && item->isVisible())
- mShopItems.push_back(item);
- }
-}
diff --git a/src/gui/models/shopitems.h b/src/gui/models/shopitems.h
deleted file mode 100644
index 26c5a94e4..000000000
--- a/src/gui/models/shopitems.h
+++ /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/>.
- */
-
-#ifndef GUI_MODELS_SHOPITEMS_H
-#define GUI_MODELS_SHOPITEMS_H
-
-#include "enums/resources/item/itemtype.h"
-
-#include "enums/simpletypes/itemcolor.h"
-
-#include "gui/models/listmodel.h"
-
-#include "utils/cast.h"
-#include "utils/vector.h"
-
-#include "localconsts.h"
-
-class ShopItem;
-
-/**
- * This class handles the list of items available in a shop.
- *
- * The addItem routine can automatically check, if an item already exists and
- * only adds duplicates to the old item, if one is found. The original
- * distribution of the duplicates can be retrieved from the item.
- *
- * This functionality can be enabled in the constructor.
- */
-class ShopItems final : public ListModel
-{
- public:
- /**
- * Constructor.
- *
- * @param mergeDuplicates lets the Shop look for duplicate entries and
- * merges them to one item.
- */
- ShopItems(const bool mergeDuplicates,
- const std::string &currency);
-
- A_DELETE_COPY(ShopItems)
-
- ~ShopItems();
-
- /**
- * Adds an item to the list.
- */
- ShopItem *addItem(const int id,
- const ItemTypeT type,
- const ItemColor color,
- const int amount,
- const int price);
-
- /**
- * Adds an item to the list (used by sell dialog). Looks for
- * duplicate entries, if mergeDuplicates was turned on.
- *
- * @param inventoryIndex the inventory index of the item
- * @param id the id of the item
- * @param amount number of available copies of the item
- * @param price price of the item
- */
- ShopItem *addItem2(const int inventoryIndex,
- const int id,
- const ItemTypeT type,
- const ItemColor color,
- const int amount,
- const int price);
-
- ShopItem *addItemNoDup(const int id,
- const ItemTypeT type,
- const ItemColor color,
- const int amount,
- const int price);
-
- /**
- * Returns the number of items in the shop.
- */
- int getNumberOfElements() override final A_WARN_UNUSED
- { return CAST_S32(mShopItems.size()); }
-
- bool empty() const noexcept2 A_WARN_UNUSED
- { return mShopItems.empty(); }
-
- /**
- * Returns the name of item number i in the shop.
- *
- * @param i the index to retrieve
- */
- std::string getElementAt(int i) override final A_WARN_UNUSED;
-
- /**
- * Returns the item number i in the shop.
- */
- ShopItem *at(const size_t i) const A_WARN_UNUSED;
-
- /**
- * Removes an element from the shop.
- *
- * @param i index to remove
- */
- void erase(const unsigned int i);
-
- /**
- * Removes an element from the shop and destroy it.
- *
- * @param i index to remove
- */
- void del(const unsigned int i);
-
- /**
- * Clears the list of items in the shop.
- */
- void clear();
-
- STD_VECTOR<ShopItem*> &items() A_WARN_UNUSED
- { return mShopItems; }
-
- STD_VECTOR<ShopItem*> &allItems() A_WARN_UNUSED
- { return mAllShopItems; }
-
- void setMergeDuplicates(const bool b)
- { mMergeDuplicates = b; }
-
- void updateList();
-
- private:
- /**
- * Searches the current items in the shop for the specified
- * id and returns the item if found, or 0 else.
- *
- * @return the item found or 0
- */
- ShopItem *findItem(const int id,
- const ItemColor color) const A_WARN_UNUSED;
-
- bool findInAllItems(STD_VECTOR<ShopItem*>::iterator &it,
- const ShopItem *const item);
-
- /** The list of items in the shop. */
- STD_VECTOR<ShopItem*> mAllShopItems;
-
- STD_VECTOR<ShopItem*> mShopItems;
-
- std::string mCurrency;
-
- /** Look for duplicate entries on addition. */
- bool mMergeDuplicates;
-};
-
-#endif // GUI_MODELS_SHOPITEMS_H
diff --git a/src/gui/models/skillmodel.cpp b/src/gui/models/skillmodel.cpp
deleted file mode 100644
index 4d22280d8..000000000
--- a/src/gui/models/skillmodel.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 "gui/models/skillmodel.h"
-
-#include "utils/foreach.h"
-
-#include "resources/skill/skilldata.h"
-
-#include "debug.h"
-
-SkillModel::SkillModel() :
- ListModel(),
- mSkills(),
- mVisibleSkills()
-{
-}
-
-SkillInfo *SkillModel::getSkillAt(const int i) const
-{
- if (i < 0 || i >= CAST_S32(mVisibleSkills.size()))
- return nullptr;
- return mVisibleSkills.at(i);
-}
-
-std::string SkillModel::getElementAt(int i)
-{
- const SkillInfo *const info = getSkillAt(i);
- if (info != nullptr)
- return info->data->name;
- return std::string();
-}
-
-void SkillModel::updateVisibilities()
-{
- mVisibleSkills.clear();
-
- FOR_EACH (SkillList::const_iterator, it, mSkills)
- {
- if (((*it) != nullptr) && (*it)->visible == Visible_true)
- mVisibleSkills.push_back((*it));
- }
-}
diff --git a/src/gui/models/skillmodel.h b/src/gui/models/skillmodel.h
deleted file mode 100644
index 6c7792508..000000000
--- a/src/gui/models/skillmodel.h
+++ /dev/null
@@ -1,58 +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_MODELS_SKILLMODEL_H
-#define GUI_MODELS_SKILLMODEL_H
-
-#include "gui/models/listmodel.h"
-
-#include "utils/cast.h"
-
-#include "resources/skill/skillinfo.h"
-
-#include "localconsts.h"
-
-class SkillModel final : public ListModel
-{
- public:
- SkillModel();
-
- A_DELETE_COPY(SkillModel)
-
- SkillInfo *getSkillAt(const int i) const;
-
- std::string getElementAt(int i) override final;
-
- int getNumberOfElements() override final
- { return CAST_S32(mVisibleSkills.size()); }
-
- void addSkill(SkillInfo *const info)
- { mSkills.push_back(info); }
-
- void updateVisibilities();
-
- private:
- SkillList mSkills;
- SkillList mVisibleSkills;
-};
-
-#endif // GUI_MODELS_SKILLMODEL_H
diff --git a/src/gui/models/sortlistmodelbuy.h b/src/gui/models/sortlistmodelbuy.h
deleted file mode 100644
index 3af489222..000000000
--- a/src/gui/models/sortlistmodelbuy.h
+++ /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/>.
- */
-
-#ifndef GUI_MODELS_SORTLISTMODELBUY_H
-#define GUI_MODELS_SORTLISTMODELBUY_H
-
-#include "gui/models/listmodel.h"
-
-#include "utils/gettext.h"
-
-static const char *const SORT_NAME_BUY[7] =
-{
- // TRANSLATORS: buy dialog sort type.
- N_("unsorted"),
- // TRANSLATORS: buy dialog sort type.
- N_("by price"),
- // TRANSLATORS: buy dialog sort type.
- N_("by name"),
- // TRANSLATORS: buy dialog sort type.
- N_("by id"),
- // TRANSLATORS: buy dialog sort type.
- N_("by weight"),
- // TRANSLATORS: buy dialog sort type.
- N_("by amount"),
- // TRANSLATORS: buy dialog sort type.
- N_("by type")
-};
-
-class SortListModelBuy final : public ListModel
-{
- public:
- SortListModelBuy() :
- ListModel()
- { }
-
- A_DELETE_COPY(SortListModelBuy)
-
- ~SortListModelBuy()
- { }
-
- int getNumberOfElements() override final
- { return 7; }
-
- std::string getElementAt(int i) override final
- {
- if (i >= getNumberOfElements() || i < 0)
- return "???";
- return gettext(SORT_NAME_BUY[i]);
- }
-};
-
-#endif // GUI_MODELS_SORTLISTMODELBUY_H
diff --git a/src/gui/models/sortlistmodelinv.h b/src/gui/models/sortlistmodelinv.h
deleted file mode 100644
index 3561d2621..000000000
--- a/src/gui/models/sortlistmodelinv.h
+++ /dev/null
@@ -1,69 +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 GUI_MODELS_SORTLISTMODELINV_H
-#define GUI_MODELS_SORTLISTMODELINV_H
-
-#include "gui/models/listmodel.h"
-
-#include "utils/gettext.h"
-
-static const char *const SORT_NAME_INVENTORY[6] =
-{
- // TRANSLATORS: inventory sort mode
- N_("default"),
- // TRANSLATORS: inventory sort mode
- N_("by name"),
- // TRANSLATORS: inventory sort mode
- N_("by id"),
- // TRANSLATORS: inventory sort mode
- N_("by weight"),
- // TRANSLATORS: inventory sort mode
- N_("by amount"),
- // TRANSLATORS: inventory sort mode
- N_("by type")
-};
-
-class SortListModelInv final : public ListModel
-{
- public:
- SortListModelInv() :
- ListModel()
- { }
-
- A_DELETE_COPY(SortListModelInv)
-
- ~SortListModelInv()
- { }
-
- int getNumberOfElements() override final
- { return 6; }
-
- std::string getElementAt(int i) override final
- {
- if (i >= getNumberOfElements() || i < 0)
- return "???";
-
- return gettext(SORT_NAME_INVENTORY[i]);
- }
-};
-
-#endif // GUI_MODELS_SORTLISTMODELINV_H
diff --git a/src/gui/models/soundsmodel.h b/src/gui/models/soundsmodel.h
deleted file mode 100644
index ad66049a3..000000000
--- a/src/gui/models/soundsmodel.h
+++ /dev/null
@@ -1,49 +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 GUI_MODELS_SOUNDSMODEL_H
-#define GUI_MODELS_SOUNDSMODEL_H
-
-#include "gui/theme.h"
-
-#include "gui/models/namesmodel.h"
-
-#include "utils/gettext.h"
-
-#include "localconsts.h"
-
-class SoundsModel final : public NamesModel
-{
- public:
- SoundsModel() :
- NamesModel()
- {
- mNames.push_back(gettext("(no sound)"));
- Theme::fillSoundsList(mNames);
- }
-
- A_DELETE_COPY(SoundsModel)
-
- ~SoundsModel()
- { }
-};
-
-#endif // GUI_MODELS_SOUNDSMODEL_H
diff --git a/src/gui/models/tablemodel.cpp b/src/gui/models/tablemodel.cpp
deleted file mode 100644
index 08cfb6d83..000000000
--- a/src/gui/models/tablemodel.cpp
+++ /dev/null
@@ -1,182 +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 "gui/models/tablemodel.h"
-
-#include "utils/dtor.h"
-
-#include "gui/widgets/widget.h"
-
-#include "listeners/tablemodellistener.h"
-
-#include "debug.h"
-
-void TableModel::installListener(TableModelListener *const listener)
-{
- if (listener != nullptr)
- listeners.insert(listener);
-}
-
-void TableModel::removeListener(TableModelListener *const listener)
-{
- if (listener != nullptr)
- listeners.erase(listener);
-}
-
-void TableModel::signalBeforeUpdate()
-{
- for (std::set<TableModelListener *>::const_iterator it = listeners.begin();
- it != listeners.end(); ++it)
- {
- (*it)->modelUpdated(false);
- }
-}
-
-void TableModel::signalAfterUpdate()
-{
- for (std::set<TableModelListener *>::const_iterator it = listeners.begin();
- it != listeners.end(); ++it)
- {
- if (*it != nullptr)
- (*it)->modelUpdated(true);
- }
-}
-
-
-#define WIDGET_AT(row, column) (((row) * mColumns) + (column))
-#define DYN_SIZE(h) ((h) >= 0)
-
-StaticTableModel::StaticTableModel(const int row, const int column) :
- TableModel(),
- mRows(row),
- mColumns(column),
- mHeight(1),
- mTableModel(),
- mWidths()
-{
- mTableModel.resize(row * column, nullptr);
- mWidths.resize(column, 1);
-}
-
-StaticTableModel::~StaticTableModel()
-{
- delete_all(mTableModel);
- mTableModel.clear();
-}
-
-void StaticTableModel::resize()
-{
- mRows = getRows();
- mColumns = getColumns();
- mTableModel.resize(mRows * mColumns, nullptr);
-}
-
-void StaticTableModel::set(const int row, const int column,
- Widget *const widget)
-{
- if ((widget == nullptr) || row >= mRows || row < 0
- || column >= mColumns || column < 0)
- {
- // raise exn?
- return;
- }
-
- if (DYN_SIZE(mHeight)
- && widget->getHeight() > mHeight)
- {
- mHeight = widget->getHeight();
- }
-
- if (DYN_SIZE(mWidths[column])
- && widget->getWidth() > mWidths[column])
- {
- mWidths[column] = widget->getWidth();
- }
-
- signalBeforeUpdate();
-
- delete mTableModel[WIDGET_AT(row, column)];
-
- mTableModel[WIDGET_AT(row, column)] = widget;
-
- signalAfterUpdate();
-}
-
-Widget *StaticTableModel::getElementAt(const int row,
- const int column) const
-{
- return mTableModel[WIDGET_AT(row, column)];
-}
-
-void StaticTableModel::fixColumnWidth(const int column, const int width)
-{
- if (width < 0 || column < 0 || column >= mColumns)
- return;
-
- mWidths[column] = -width; // Negate to tag as fixed
-}
-
-void StaticTableModel::fixRowHeight(const int height)
-{
- if (height < 0)
- return;
-
- mHeight = -height;
-}
-
-int StaticTableModel::getRowHeight() const
-{
- return abs(mHeight);
-}
-
-int StaticTableModel::getColumnWidth(const int column) const
-{
- if (column < 0 || column >= mColumns)
- return 0;
-
- return abs(mWidths[column]);
-}
-
-int StaticTableModel::getRows() const
-{
- return mRows;
-}
-
-int StaticTableModel::getColumns() const
-{
- return mColumns;
-}
-
-int StaticTableModel::getWidth() const
-{
- int width = 0;
-
- for (size_t i = 0, sz = mWidths.size(); i < sz; i++)
- width += mWidths[i];
-
- return width;
-}
-
-int StaticTableModel::getHeight() const
-{
- return mColumns * mHeight;
-}
diff --git a/src/gui/models/tablemodel.h b/src/gui/models/tablemodel.h
deleted file mode 100644
index 23f286c2e..000000000
--- a/src/gui/models/tablemodel.h
+++ /dev/null
@@ -1,153 +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 GUI_MODELS_TABLEMODEL_H
-#define GUI_MODELS_TABLEMODEL_H
-
-#include "utils/vector.h"
-
-#include <set>
-
-#include "localconsts.h"
-
-class Widget;
-
-class TableModelListener;
-
-/**
- * A model for a regular table of widgets.
- */
-class TableModel notfinal
-{
- public:
- A_DELETE_COPY(TableModel)
-
- virtual ~TableModel()
- { }
-
- /**
- * Determines the number of rows (lines) in the table
- */
- virtual int getRows() const A_WARN_UNUSED = 0;
-
- /**
- * Determines the number of columns in each row
- */
- virtual int getColumns() const A_WARN_UNUSED = 0;
-
- /**
- * Determines the height for each row
- */
- virtual int getRowHeight() const A_WARN_UNUSED = 0;
-
- /**
- * Determines the width of each individual column
- */
- virtual int getColumnWidth(const int index) const A_WARN_UNUSED = 0;
-
- /**
- * Retrieves the widget stored at the specified location
- * within the table.
- */
- virtual Widget *getElementAt(const int row, const int column)
- const A_WARN_UNUSED = 0;
-
- virtual void installListener(TableModelListener *const listener);
-
- virtual void removeListener(TableModelListener *const listener);
-
- protected:
- TableModel() :
- listeners()
- {
- }
-
- /**
- * Tells all listeners that the table is about to see an update
- */
- virtual void signalBeforeUpdate();
-
- /**
- * Tells all listeners that the table has seen an update
- */
- virtual void signalAfterUpdate();
-
- private:
- std::set<TableModelListener *> listeners;
-};
-
-
-class StaticTableModel final : public TableModel
-{
- public:
- StaticTableModel(const int width, const int height);
-
- A_DELETE_COPY(StaticTableModel)
-
- ~StaticTableModel();
-
- /**
- * Inserts a widget into the table model.
- * The model is resized to accomodate the widget's width and height,
- * unless column width / row height have been fixed.
- */
- void set(const int row, const int column, Widget *const widget);
-
- /**
- * Fixes the column width for a given column; this overrides dynamic
- * width inference.
- *
- * Semantics are undefined for width 0.
- */
- void fixColumnWidth(const int column, const int width);
-
- /**
- * Fixes the row height; this overrides dynamic height inference.
- *
- * Semantics are undefined for width 0.
- */
- void fixRowHeight(const int height);
-
- /**
- * Resizes the table model
- */
- void resize();
-
- int getRows() const override final A_WARN_UNUSED;
- int getColumns() const override final A_WARN_UNUSED;
- int getRowHeight() const override final A_WARN_UNUSED;
- int getWidth() const A_WARN_UNUSED;
- int getHeight() const A_WARN_UNUSED;
- int getColumnWidth(const int index) const override final A_WARN_UNUSED;
- Widget *getElementAt(const int row,
- const int column) const override final
- A_WARN_UNUSED;
-
- protected:
- int mRows;
- int mColumns;
- int mHeight;
- STD_VECTOR<Widget *> mTableModel;
- STD_VECTOR<int> mWidths;
-};
-
-#endif // GUI_MODELS_TABLEMODEL_H
diff --git a/src/gui/models/targettypemodel.h b/src/gui/models/targettypemodel.h
deleted file mode 100644
index ec049bf66..000000000
--- a/src/gui/models/targettypemodel.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009-2010 Andrei Karas
- * 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_MODELS_TARGETTYPEMODEL_H
-#define GUI_MODELS_TARGETTYPEMODEL_H
-
-#include "gui/models/listmodel.h"
-
-#include "utils/gettext.h"
-
-const char *TARGET_TYPE_TEXT[3] =
-{
- // TRANSLATORS: target type
- N_("No Target"),
- // TRANSLATORS: target type
- N_("Allow Target"),
- // TRANSLATORS: target type
- N_("Need Target")
-};
-
-class TargetTypeModel final : public ListModel
-{
- public:
- TargetTypeModel() :
- ListModel()
- { }
-
- A_DELETE_COPY(TargetTypeModel)
-
- ~TargetTypeModel()
- { }
-
- int getNumberOfElements() override final
- {
- return 3;
- }
-
- std::string getElementAt(int i) override final
- {
- if (i >= getNumberOfElements() || i < 0)
- return "???";
- return TARGET_TYPE_TEXT[i];
- }
-};
-
-#endif // GUI_MODELS_TARGETTYPEMODEL_H
diff --git a/src/gui/models/themesmodel.h b/src/gui/models/themesmodel.h
deleted file mode 100644
index c68cc0a2f..000000000
--- a/src/gui/models/themesmodel.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009-2010 Andrei Karas
- * 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_MODELS_THEMESMODEL_H
-#define GUI_MODELS_THEMESMODEL_H
-
-#include "gui/theme.h"
-
-#include "gui/models/namesmodel.h"
-
-#include "utils/gettext.h"
-
-#include "localconsts.h"
-
-class ThemesModel final : public NamesModel
-{
- public:
- ThemesModel() :
- NamesModel()
- {
- mNames.push_back(gettext("(default)"));
- Theme::fillSkinsList(mNames);
- }
-
- A_DELETE_COPY(ThemesModel)
-
- ~ThemesModel()
- { }
-};
-
-#endif // GUI_MODELS_THEMESMODEL_H
diff --git a/src/gui/models/touchactionmodel.cpp b/src/gui/models/touchactionmodel.cpp
deleted file mode 100644
index 1998d2752..000000000
--- a/src/gui/models/touchactionmodel.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/>.
- */
-
-#include "gui/setupactiondata.h"
-#include "gui/touchactiondata.h"
-
-#include "gui/models/touchactionmodel.h"
-
-#include "utils/foreach.h"
-
-#include <algorithm>
-
-#include "debug.h"
-
-const int touchActionDataSize = 5;
-
-static class SortTouchActionFunctor final
-{
- public:
- A_DEFAULT_COPY(SortTouchActionFunctor)
-
- bool operator() (const SetupActionData *const data1,
- const SetupActionData *const data2) const
- {
- if ((data1 == nullptr) || (data2 == nullptr))
- return false;
- return data1->name < data2->name;
- }
-} touchActionSorter;
-
-TouchActionsModel::TouchActionsModel() :
- NamesModel(),
- mActionId(),
- mActionToSelection()
-{
- STD_VECTOR<SetupActionData*> data;
-
- for (int f = 0, fsz = touchActionDataSize; f < fsz; f ++)
- {
- int k = 0;
- while (!touchActionData[f][k].name.empty())
- {
- data.push_back(&touchActionData[f][k]);
- k ++;
- }
- }
-
- std::sort(data.begin(), data.end(), touchActionSorter);
- int cnt = 0;
- FOR_EACH (STD_VECTOR<SetupActionData*>::iterator, it, data)
- {
- const SetupActionData *const data1 = *it;
- mNames.push_back(data1->name);
- mActionId.push_back(data1->actionId);
- mActionToSelection[data1->actionId] = cnt;
- cnt ++;
- }
-}
-
-InputActionT TouchActionsModel::getActionFromSelection(const int sel) const
-{
- if (sel < 0 || sel > static_cast<signed int>(mActionId.size()))
- return InputAction::NO_VALUE;
- return mActionId[sel];
-}
-
-int TouchActionsModel::getSelectionFromAction(const InputActionT action) const
-{
- const std::map<InputActionT, int>::const_iterator it
- = mActionToSelection.find(action);
- if (it == mActionToSelection.end())
- return 0;
- return (*it).second;
-}
diff --git a/src/gui/models/touchactionmodel.h b/src/gui/models/touchactionmodel.h
deleted file mode 100644
index 2d8cff02a..000000000
--- a/src/gui/models/touchactionmodel.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 GUI_MODELS_TOUCHACTIONMODEL_H
-#define GUI_MODELS_TOUCHACTIONMODEL_H
-
-#include "enums/input/inputaction.h"
-
-#include "gui/models/namesmodel.h"
-
-#include <map>
-
-class TouchActionsModel final : public NamesModel
-{
- public:
- TouchActionsModel();
-
- A_DELETE_COPY(TouchActionsModel)
-
- ~TouchActionsModel()
- { }
-
- InputActionT getActionFromSelection(const int sel) const;
-
- int getSelectionFromAction(const InputActionT action) const;
-
- private:
- STD_VECTOR<InputActionT> mActionId;
- std::map<InputActionT, int> mActionToSelection;
-};
-
-#endif // GUI_MODELS_TOUCHACTIONMODEL_H
diff --git a/src/gui/models/typelistmodel.h b/src/gui/models/typelistmodel.h
deleted file mode 100644
index 681e019fc..000000000
--- a/src/gui/models/typelistmodel.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2012 The Mana Developers
- * 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 GUI_MODELS_TYPELISTMODEL_H
-#define GUI_MODELS_TYPELISTMODEL_H
-
-#include "gui/models/listmodel.h"
-
-/**
- * Server Type List Model
- */
-class TypeListModel final : public ListModel
-{
- public:
- TypeListModel() :
- ListModel()
- { }
-
- A_DELETE_COPY(TypeListModel)
-
- /**
- * Used to get number of line in the list
- */
- int getNumberOfElements() override final A_WARN_UNUSED
-#if defined(TMWA_SUPPORT)
- { return 3; }
-#else // defined(TMWA_SUPPORT)
- { return 2; }
-#endif // defined(TMWA_SUPPORT)
-
- /**
- * Used to get an element from the list
- */
- std::string getElementAt(int elementIndex)
- override final A_WARN_UNUSED
- {
-#ifdef TMWA_SUPPORT
- if (elementIndex == 0)
- return "TmwAthena";
- else if (elementIndex == 1)
- return "Hercules";
- else if (elementIndex == 2)
- return "Evol2";
- else
-#else // TMWA_SUPPORT
- if (elementIndex == 0)
- return "Hercules";
- else if (elementIndex == 1)
- return "Evol2";
- else
-#endif // TMWA_SUPPORT
- return "Unknown";
- }
-};
-
-#endif // GUI_MODELS_TYPELISTMODEL_H
diff --git a/src/gui/models/updatelistmodel.h b/src/gui/models/updatelistmodel.h
deleted file mode 100644
index cd4ba50c3..000000000
--- a/src/gui/models/updatelistmodel.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 GUI_MODELS_UPDATELISTMODEL_H
-#define GUI_MODELS_UPDATELISTMODEL_H
-
-#include "gui/models/listmodel.h"
-
-#include "net/serverinfo.h"
-
-#include "utils/cast.h"
-#include "utils/foreach.h"
-
-#include "localconsts.h"
-
-class UpdateListModel final : public ListModel
-{
- public:
- explicit UpdateListModel(ServerInfo *const server) :
- ListModel(),
- mNames(),
- mServer(server)
- {
- FOR_EACH(STD_VECTOR<HostsGroup>::const_iterator,
- it,
- server->updateHosts)
- {
- const HostsGroup &group = *it;
- mNames.push_back(group.name);
- }
- }
-
- A_DELETE_COPY(UpdateListModel)
-
- ~UpdateListModel()
- { }
-
- int getNumberOfElements() override final
- {
- return CAST_S32(mNames.size());
- }
-
- std::string getElementAt(int i) override final
- {
- if (i >= getNumberOfElements() || i < 0)
- return "???";
- return mNames[i];
- }
-
- bool empty() const
- {
- return mNames.empty();
- }
-
- protected:
- StringVect mNames;
- ServerInfo *mServer;
-};
-
-#endif // GUI_MODELS_UPDATELISTMODEL_H
diff --git a/src/gui/models/updatetypemodel.h b/src/gui/models/updatetypemodel.h
deleted file mode 100644
index 232be8223..000000000
--- a/src/gui/models/updatetypemodel.h
+++ /dev/null
@@ -1,63 +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 GUI_MODELS_UPDATETYPEMODEL_H
-#define GUI_MODELS_UPDATETYPEMODEL_H
-
-#include "utils/gettext.h"
-
-#include "gui/models/listmodel.h"
-
-const char *UPDATE_TYPE_TEXT[3] =
-{
- // TRANSLATORS: update type
- N_("Normal"),
- // TRANSLATORS: update type
- N_("Auto Close"),
- // TRANSLATORS: update type
- N_("Skip"),
-};
-
-class UpdateTypeModel final : public ListModel
-{
- public:
- UpdateTypeModel()
- { }
-
- A_DELETE_COPY(UpdateTypeModel)
-
- ~UpdateTypeModel()
- { }
-
- int getNumberOfElements() override final
- {
- return 3;
- }
-
- std::string getElementAt(int i) override final
- {
- if (i >= getNumberOfElements() || i < 0)
- return "???";
- return gettext(UPDATE_TYPE_TEXT[i]);
- }
-};
-
-#endif // GUI_MODELS_UPDATETYPEMODEL_H
diff --git a/src/gui/models/worldlistmodel.h b/src/gui/models/worldlistmodel.h
deleted file mode 100644
index 3be179c61..000000000
--- a/src/gui/models/worldlistmodel.h
+++ /dev/null
@@ -1,68 +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_MODELS_WORLDLISTMODEL_H
-#define GUI_MODELS_WORLDLISTMODEL_H
-
-#include "gui/models/listmodel.h"
-
-#include "utils/cast.h"
-#include "utils/stringutils.h"
-
-#include "net/worldinfo.h"
-
-/**
- * The list model for the server list.
- */
-class WorldListModel final : public ListModel
-{
- public:
- explicit WorldListModel(const Worlds &worlds) :
- mWorlds(worlds)
- {
- }
-
- A_DELETE_COPY(WorldListModel)
-
- ~WorldListModel()
- { }
-
- int getNumberOfElements() override final
- {
- return CAST_S32(mWorlds.size());
- }
-
- std::string getElementAt(int i) override final
- {
- const WorldInfo *const si = mWorlds[i];
- if (si != nullptr)
- {
- return std::string(si->name).append(" (").append(
- toString(si->online_users)).append(")");
- }
- return "???";
- }
- private:
- Worlds mWorlds;
-};
-
-#endif // GUI_MODELS_WORLDLISTMODEL_H
diff --git a/src/gui/mouseoverlink.h b/src/gui/mouseoverlink.h
deleted file mode 100644
index 758d02b6e..000000000
--- a/src/gui/mouseoverlink.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 GUI_MOUSEOVERLINK_H
-#define GUI_MOUSEOVERLINK_H
-
-#include "gui/browserlink.h"
-
-#include "localconsts.h"
-
-struct MouseOverLink final
-{
- MouseOverLink(const int x,
- const int y) :
- mX(x),
- mY(y)
- { }
-
- A_DEFAULT_COPY(MouseOverLink)
-
- bool operator() (const BrowserLink &link) const
- {
- return mX >= link.x1 &&
- mX < link.x2 &&
- mY >= link.y1 &&
- mY < link.y2;
- }
- const int mX;
- const int mY;
-};
-
-#endif // GUI_MOUSEOVERLINK_H
diff --git a/src/gui/onlineplayer.h b/src/gui/onlineplayer.h
deleted file mode 100644
index 43ebb5c5f..000000000
--- a/src/gui/onlineplayer.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009-2010 Andrei Karas
- * 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_ONLINEPLAYER_H
-#define GUI_ONLINEPLAYER_H
-
-#include "enums/being/gender.h"
-
-#include <string>
-
-#include "localconsts.h"
-
-class OnlinePlayer final
-{
- public:
- OnlinePlayer(const std::string &nick,
- const unsigned char status,
- const signed char level,
- const GenderT gender,
- const signed char version) :
- mNick(nick),
- mText(),
- mStatus(status),
- mLevel(level),
- mVersion(version),
- mGender(gender),
- mIsGM(false)
- {
- }
-
- A_DELETE_COPY(OnlinePlayer)
-
- const std::string getNick() const noexcept2 A_WARN_UNUSED
- { return mNick; }
-
- unsigned char getStaus() const noexcept2 A_WARN_UNUSED
- { return mStatus; }
-
- void setIsGM(const bool b)
- { mIsGM = b; }
-
- char getVersion() const noexcept2 A_WARN_UNUSED
- { return mVersion; }
-
- char getLevel() const noexcept2 A_WARN_UNUSED
- { return mLevel; }
-
- const std::string getText() const noexcept2 A_WARN_UNUSED
- { return mText; }
-
- void setText(std::string str);
-
- void setLevel(const char level) noexcept2
- { mLevel = level; }
-
- private:
- std::string mNick;
-
- std::string mText;
-
- unsigned char mStatus;
-
- signed char mLevel;
-
- signed char mVersion;
-
- GenderT mGender;
-
- bool mIsGM;
-};
-
-#endif // GUI_ONLINEPLAYER_H
diff --git a/src/gui/palette.cpp b/src/gui/palette.cpp
deleted file mode 100644
index 7fcf153fe..000000000
--- a/src/gui/palette.cpp
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 Douglas Boffey <dougaboffey@netscape.net>
- * 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 "gui/palette.h"
-
-#include "utils/foreach.h"
-#include "utils/timer.h"
-
-#ifndef USE_SDL2
-#include <cmath>
-#endif // USE_SDL2
-
-#include "debug.h"
-
-const Color Palette::BLACK = Color(0, 0, 0);
-Palette::Palettes Palette::mInstances;
-
-const Color Palette::RAINBOW_COLORS[7] =
-{
- Color(255, 0, 0),
- Color(255, 153, 0),
- Color(255, 255, 0),
- Color(0, 153, 0),
- Color(0, 204, 204),
- Color(51, 0, 153),
- Color(153, 0, 153)
-};
-
-const int Palette::RAINBOW_COLOR_COUNT = 7;
-
-Palette::Palette(const int size) :
- mRainbowTime(tick_time),
- mColors(Colors(size)),
- mCharColors(),
- mGradVector()
-{
- mInstances.insert(this);
-}
-
-Palette::~Palette()
-{
- mInstances.erase(this);
-}
-
-const Color& Palette::getCharColor(const signed char c, bool &valid) const
-{
- const CharColors::const_iterator it = mCharColors.find(c);
- if (it != mCharColors.end())
- {
- valid = true;
- return mColors[(*it).second].color;
- }
-
- valid = false;
- return BLACK;
-}
-
-void Palette::advanceGradients()
-{
- FOR_EACH (Palettes::const_iterator, it, mInstances)
- (*it)->advanceGradient();
-}
-
-void Palette::advanceGradient()
-{
- const int time = get_elapsed_time(mRainbowTime);
- if (time > 5)
- {
- // For slower systems, advance can be greater than one (advance > 1
- // skips advance-1 steps). Should make gradient look the same
- // independent of the framerate.
- const int advance = time / 5;
-
- for (size_t i = 0, sz = mGradVector.size(); i < sz; i++)
- {
- ColorElem *const elem A_NONNULLPOINTER = mGradVector[i];
- if (elem == nullptr)
- continue;
-
- int delay = elem->delay;
- const GradientTypeT &grad = elem->grad;
-
- if (grad == GradientType::PULSE)
- delay = delay / 20;
-
- const int numOfColors = (elem->grad == GradientType::SPECTRUM ? 6 :
- grad == GradientType::PULSE ? 127 :
- RAINBOW_COLOR_COUNT);
-
- elem->gradientIndex = (elem->gradientIndex + advance)
- % (delay * numOfColors);
-
- const int gradIndex = elem->gradientIndex;
- const int pos = delay != 0 ? (gradIndex % delay) : gradIndex;
- int colIndex;
- if (delay != 0)
- colIndex = gradIndex / delay;
- else
- colIndex = gradIndex;
-
- Color &color = elem->color;
- int colVal;
-
- if (grad == GradientType::PULSE)
- {
- colVal = CAST_S32(255.0 *
- sin(M_PI * colIndex / numOfColors));
-
- const Color &col = elem->testColor;
-
- color.r = ((colVal * col.r) / 255) % (col.r + 1);
- color.g = ((colVal * col.g) / 255) % (col.g + 1);
- color.b = ((colVal * col.b) / 255) % (col.b + 1);
- }
- else if (grad == GradientType::SPECTRUM)
- {
- if ((colIndex % 2) != 0)
- { // falling curve
- if (delay != 0)
- {
- colVal = CAST_S32(255.0 *
- (cos(M_PI * pos / delay) + 1) / 2);
- }
- else
- {
- colVal = CAST_S32(255.0 *
- (cos(M_PI * pos) + 1) / 2);
- }
- }
- else
- { // ascending curve
- if (delay != 0)
- {
- colVal = CAST_S32(255.0 * (cos(M_PI *
- (delay - pos) / delay) + 1) / 2);
- }
- else
- {
- colVal = CAST_S32(255.0 * (cos(M_PI *
- (delay - pos)) + 1) / 2);
- }
- }
-
- color.r = (colIndex == 0 || colIndex == 5) ? 255 :
- (colIndex == 1 || colIndex == 4) ? colVal : 0;
- color.g = (colIndex == 1 || colIndex == 2) ? 255 :
- (colIndex == 0 || colIndex == 3) ? colVal : 0;
- color.b = (colIndex == 3 || colIndex == 4) ? 255 :
- (colIndex == 2 || colIndex == 5) ? colVal : 0;
- }
- else if (elem->grad == GradientType::RAINBOW)
- {
- const Color &startCol = RAINBOW_COLORS[colIndex];
- const Color &destCol
- = RAINBOW_COLORS[(colIndex + 1) % numOfColors];
- double startColVal;
- double destColVal;
-
- if (delay != 0)
- startColVal = (cos(M_PI * pos / delay) + 1) / 2;
- else
- startColVal = 0;
-
- destColVal = 1 - startColVal;
-
- color.r = CAST_S32(startColVal
- * startCol.r + destColVal * destCol.r);
-
- color.g = CAST_S32(startColVal
- * startCol.g + destColVal * destCol.g);
-
- color.b = CAST_S32(startColVal
- * startCol.b + destColVal * destCol.b);
- }
- }
-
- mRainbowTime = tick_time;
- }
-}
diff --git a/src/gui/palette.h b/src/gui/palette.h
deleted file mode 100644
index 048dacf54..000000000
--- a/src/gui/palette.h
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 Douglas Boffey <dougaboffey@netscape.net>
- * 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 GUI_PALETTE_H
-#define GUI_PALETTE_H
-
-#include "enums/gui/gradienttype.h"
-
-#include "gui/color.h"
-
-#include "utils/vector.h"
-
-#include <map>
-#include <set>
-#include <string>
-
-// Default Gradient Delay
-#define GRADIENT_DELAY 40
-
-/**
- * Class controlling the game's color palette.
- */
-class Palette notfinal
-{
- public:
- /** Black Color Constant */
- static const Color BLACK;
-
- A_DELETE_COPY(Palette)
-
- /**
- * Returns the color associated with a character, if it exists. Returns
- * Palette::BLACK if the character is not found.
- *
- * @param c character requested
- * @param valid indicate whether character is known
- *
- * @return the requested color or Palette::BLACK
- */
- const Color &getCharColor(const signed char c,
- bool &valid) const A_WARN_UNUSED;
-
- /**
- * Get the character used by the specified color.
- *
- * @param type the color type of the color
- *
- * @return the color char of the color with the given index
- */
- inline char getColorChar(const int type) const A_WARN_UNUSED
- { return mColors[CAST_SIZE(type)].ch; }
-
- /**
- * Updates all colors, that are non-static.
- */
- static void advanceGradients();
-
- protected:
- /** Colors used for the rainbow gradient */
- static const Color RAINBOW_COLORS[7];
- static const int RAINBOW_COLOR_COUNT;
-
- /** Time tick, that gradient-type colors were updated the last time. */
- int mRainbowTime;
-
- typedef std::set<Palette*> Palettes;
- static Palettes mInstances;
-
- /**
- * Constructor
- */
- explicit Palette(const int size);
-
- /**
- * Destructor
- */
- virtual ~Palette();
-
- void advanceGradient();
-
- struct ColorElem final
- {
- ColorElem() :
- type(0),
- color(0),
- testColor(0),
- committedColor(0),
- text(),
- ch(0),
- grad(GradientType::STATIC),
- committedGrad(GradientType::STATIC),
- gradientIndex(0),
- delay(0),
- committedDelay(0)
- {
- }
-
- A_DEFAULT_COPY(ColorElem)
-
- int type;
- Color color;
- Color testColor;
- Color committedColor;
- std::string text;
- signed char ch;
- GradientTypeT grad;
- GradientTypeT committedGrad;
- int gradientIndex;
- int delay;
- int committedDelay;
-
- void set(const int type0,
- const Color &color0,
- const GradientTypeT grad0,
- const int delay0)
- {
- type = type0;
- color = color0;
- testColor = color0;
- grad = grad0;
- delay = delay0;
- gradientIndex = rand();
- }
-
- inline unsigned int getRGB() const noexcept2 A_WARN_UNUSED
- {
- return (committedColor.r << 16) | (committedColor.g << 8) |
- committedColor.b;
- }
- };
- typedef STD_VECTOR<ColorElem> Colors;
- typedef std::map<unsigned char, int> CharColors;
- Colors mColors;
- CharColors mCharColors;
- STD_VECTOR<ColorElem*> mGradVector;
-};
-
-#endif // GUI_PALETTE_H
diff --git a/src/gui/popupmanager.cpp b/src/gui/popupmanager.cpp
deleted file mode 100644
index 134aaac7b..000000000
--- a/src/gui/popupmanager.cpp
+++ /dev/null
@@ -1,113 +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 "gui/popupmanager.h"
-
-#include "sdlshared.h"
-
-#ifndef DYECMD
-#include "gui/popups/beingpopup.h"
-#include "gui/popups/itempopup.h"
-#include "gui/popups/popupmenu.h"
-#endif // DYECMD
-#include "gui/popups/textpopup.h"
-
-#include "debug.h"
-
-PopupManager *popupManager = nullptr;
-
-PopupManager::PopupManager()
-{
-}
-
-PopupManager::~PopupManager()
-{
-}
-
-void PopupManager::closePopupMenu()
-{
-#ifndef DYECMD
- if (popupMenu != nullptr)
- popupMenu->handleLink("cancel", nullptr);
-#endif // DYECMD
-}
-
-void PopupManager::hideBeingPopup()
-{
-#ifndef DYECMD
- if (beingPopup != nullptr)
- beingPopup->setVisible(Visible_false);
-#endif // DYECMD
-}
-
-void PopupManager::hideTextPopup()
-{
- if (textPopup != nullptr)
- textPopup->setVisible(Visible_false);
-}
-
-void PopupManager::hidePopupMenu()
-{
-#ifndef DYECMD
- if (popupMenu != nullptr)
- popupMenu->setVisible(Visible_false);
-#endif // DYECMD
-}
-
-void PopupManager::hideItemPopup()
-{
-#ifndef DYECMD
- if (itemPopup != nullptr)
- itemPopup->hide();
-#endif // DYECMD
-}
-
-bool PopupManager::isPopupMenuVisible()
-{
-#ifndef DYECMD
- return popupMenu != nullptr ? popupMenu->isPopupVisible() : false;
-#else
- return false;
-#endif // DYECMD
-}
-
-void PopupManager::clearPopup()
-{
-#ifndef DYECMD
- if (popupMenu != nullptr)
- popupMenu->clear();
-#endif // DYECMD
-}
-
-bool PopupManager::isTextPopupVisible()
-{
- return textPopup != nullptr ? textPopup->isPopupVisible() : false;
-}
-
-bool PopupManager::isBeingPopupVisible()
-{
-#ifndef DYECMD
- return beingPopup != nullptr ? beingPopup->isPopupVisible() : false;
-#else // DYECMD
- return false;
-#endif // DYECMD
-}
diff --git a/src/gui/popupmanager.h b/src/gui/popupmanager.h
deleted file mode 100644
index a3dd08a54..000000000
--- a/src/gui/popupmanager.h
+++ /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/>.
- */
-
-#ifndef GUI_POPUPMANAGER_H
-#define GUI_POPUPMANAGER_H
-
-#include "localconsts.h"
-
-class PopupManager final
-{
- public:
- /**
- * Constructor.
- */
- PopupManager() A_CONST;
-
- A_DELETE_COPY(PopupManager)
-
- /**
- * Destructor.
- */
- ~PopupManager() A_CONST;
-
- static bool isBeingPopupVisible() A_WARN_UNUSED;
-
- static bool isTextPopupVisible() A_WARN_UNUSED;
-
- /**
- * Closes the popup menu. Needed for when the player dies or switching
- * maps.
- */
- static void closePopupMenu();
-
- /**
- * Hides the BeingPopup.
- */
- static void hideBeingPopup();
-
- static void hideTextPopup();
-
- static void hideItemPopup();
-
- static bool isPopupMenuVisible() A_WARN_UNUSED;
-
- static void clearPopup();
-
- static void hidePopupMenu();
-};
-
-extern PopupManager *popupManager;
-
-#endif // GUI_POPUPMANAGER_H
diff --git a/src/gui/popups/beingpopup.cpp b/src/gui/popups/beingpopup.cpp
deleted file mode 100644
index 299683f6d..000000000
--- a/src/gui/popups/beingpopup.cpp
+++ /dev/null
@@ -1,337 +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 "gui/popups/beingpopup.h"
-
-#include "being/being.h"
-#include "being/homunculusinfo.h"
-#include "being/petinfo.h"
-#include "being/playerinfo.h"
-#include "being/playerrelations.h"
-
-#include "gui/gui.h"
-
-#include "gui/fonts/font.h"
-
-#include "gui/widgets/label.h"
-
-#include "resources/chatobject.h"
-
-#include "resources/db/groupdb.h"
-
-#include "utils/gettext.h"
-#include "utils/foreach.h"
-#include "utils/stringutils.h"
-
-#include "debug.h"
-
-BeingPopup *beingPopup = nullptr;
-
-BeingPopup::BeingPopup() :
- Popup("BeingPopup", "beingpopup.xml"),
- mBeingName(new Label(this, "A")),
- mLabels()
-{
- // Being Name
- mBeingName->setFont(boldFont);
- mBeingName->setPosition(0, 0);
-
- const int fontHeight = mBeingName->getHeight();
- setMinHeight(fontHeight);
- addLabels(fontHeight);
-}
-
-BeingPopup::~BeingPopup()
-{
-}
-
-void BeingPopup::postInit()
-{
- Popup::postInit();
- add(mBeingName);
- FOR_EACH (STD_VECTOR<Label*>::iterator, it, mLabels)
- {
- add(*it);
- }
-}
-
-void BeingPopup::addLabels(const int fontHeight)
-{
- for (int f = 0; f < 11; f ++)
- {
- Label *const label = new Label(this, "A");
- label->setPosition(0, fontHeight * (f + 1));
- label->setForegroundColorAll(getThemeColor(ThemeColorId::POPUP),
- getThemeColor(ThemeColorId::POPUP_OUTLINE));
- mLabels.push_back(label);
- }
-}
-
-void BeingPopup::show(const int x, const int y, Being *const b)
-{
- if (b == nullptr)
- {
- setVisible(Visible_false);
- return;
- }
-
- int num = 0;
- Label *ptr = nullptr;
- b->updateComment();
-
- if (b->getType() == ActorType::Npc && b->getComment().empty())
- {
- setVisible(Visible_false);
- return;
- }
-
- mBeingName->setCaption(b->getName() + b->getGenderSignWithSpace());
- if (gui != nullptr)
- {
- if (playerRelations.isGoodName(b))
- mBeingName->setFont(boldFont);
- else
- mBeingName->setFont(gui->getSecureFont());
- }
- if (b->isAdvanced())
- {
- mBeingName->setForegroundColorAll(getThemeColor(
- ThemeColorId::PLAYER_ADVANCED), getThemeColor(
- ThemeColorId::PLAYER_ADVANCED_OUTLINE));
- }
- else
- {
- mBeingName->setForegroundColorAll(getThemeColor(ThemeColorId::POPUP),
- getThemeColor(ThemeColorId::POPUP_OUTLINE));
- }
-
- mBeingName->adjustSize();
- FOR_EACH (STD_VECTOR<Label*>::iterator, it, mLabels)
- {
- (*it)->setCaption(std::string());
- }
-
- const ActorTypeT type = b->getType();
- if (type == ActorType::Pet)
- {
- const PetInfo *const info = PlayerInfo::getPet();
- if ((info != nullptr) && info->id == b->getId())
- {
- ptr = mLabels[num];
- // TRANSLATORS: being popup label
- ptr->setCaption(strprintf(_("Hungry: %d"),
- info->hungry));
- ptr->adjustSize();
- num ++;
- ptr = mLabels[num];
- // TRANSLATORS: being popup label
- ptr->setCaption(strprintf(_("Intimacy: %d"),
- info->intimacy));
- ptr->adjustSize();
- num ++;
- }
- }
- else if (type == ActorType::Homunculus)
- {
- const HomunculusInfo *const info = PlayerInfo::getHomunculus();
- if ((info != nullptr) && info->id == b->getId())
- {
- ptr = mLabels[num];
- // TRANSLATORS: being popup label
- ptr->setCaption(strprintf(_("Hungry: %d"),
- info->hungry));
- ptr->adjustSize();
- num ++;
- ptr = mLabels[num];
- // TRANSLATORS: being popup label
- ptr->setCaption(strprintf(_("Intimacy: %d"),
- info->intimacy));
- ptr->adjustSize();
- num ++;
- }
- }
- else
- {
- const int groupId = b->getGroupId();
- const std::string &groupName = GroupDb::getLongName(groupId);
- if (!groupName.empty())
- {
- ptr = mLabels[num];
- // TRANSLATORS: being popup label
- ptr->setCaption(strprintf(_("Group: %s (%d)"),
- groupName.c_str(),
- groupId));
- ptr->adjustSize();
- num ++;
- }
-
- if (!(b->getPartyName().empty()))
- {
- ptr = mLabels[num];
- // TRANSLATORS: being popup label
- ptr->setCaption(strprintf(_("Party: %s"),
- b->getPartyName().c_str()));
- ptr->adjustSize();
- num ++;
- }
-
- if (!(b->getGuildName().empty()))
- {
- ptr = mLabels[num];
- // TRANSLATORS: being popup label
- ptr->setCaption(strprintf(_("Guild: %s"),
- b->getGuildName().c_str()));
- ptr->adjustSize();
- num ++;
- }
-
- if (b->getPvpRank() > 0)
- {
- ptr = mLabels[num];
- // TRANSLATORS: being popup label
- ptr->setCaption(strprintf(_("Pvp rank: %u"),
- b->getPvpRank()));
- ptr->adjustSize();
- num ++;
- }
-
- if (!b->getBuyBoard().empty())
- {
- ptr = mLabels[num];
- // TRANSLATORS: being popup label
- ptr->setCaption(strprintf(_("Buy shop: %s"),
- b->getBuyBoard().c_str()));
- ptr->adjustSize();
- num ++;
- }
-
- if (!b->getSellBoard().empty())
- {
- ptr = mLabels[num];
- // TRANSLATORS: being popup label
- ptr->setCaption(strprintf(_("Sell shop: %s"),
- b->getSellBoard().c_str()));
- ptr->adjustSize();
- num ++;
- }
-
- if (!b->getComment().empty())
- {
- ptr = mLabels[num];
- // TRANSLATORS: being popup label
- ptr->setCaption(strprintf(_("Comment: %s"),
- b->getComment().c_str()));
- ptr->adjustSize();
- num ++;
- }
-
- const std::string effects = b->getStatusEffectsString();
- if (!effects.empty())
- {
- ptr = mLabels[num];
- // TRANSLATORS: being popup label
- ptr->setCaption(strprintf(_("Effects: %s"),
- effects.c_str()));
- ptr->adjustSize();
- num ++;
- }
-
- const ChatObject *const chat = b->getChat();
- if (chat != nullptr)
- {
- ptr = mLabels[num];
- // TRANSLATORS: being popup label
- ptr->setCaption(strprintf(_("Chat room: %s"),
- chat->title.c_str()));
- ptr->adjustSize();
- num ++;
- }
- }
-
- const int level = b->getLevel();
- if (level > 1)
- {
- ptr = mLabels[num];
- // TRANSLATORS: being popup label
- ptr->setCaption(strprintf(_("Level: %d"),
- level));
- ptr->adjustSize();
- num ++;
- }
-
- const int maxHp = b->getMaxHP();
- if (maxHp > 0)
- {
- int hp = b->getHP();
- if (hp == 0)
- hp = maxHp - b->getDamageTaken();
- if (hp > 0)
- {
- ptr = mLabels[num];
- // TRANSLATORS: being popup label
- ptr->setCaption(strprintf(_("Hp: %d/%d"),
- hp,
- maxHp));
- ptr->adjustSize();
- num ++;
- }
- }
-
- ptr = mLabels[num];
- // TRANSLATORS: being popup label
- ptr->setCaption(strprintf(_("Particles: %u"),
- CAST_U32(b->getParticlesCount())));
- ptr->adjustSize();
- num ++;
-
- const size_t sz = mLabels.size();
- for (size_t f = num; f < sz; f ++)
- {
- mLabels[f]->setCaption(std::string());
- }
-
- int minWidth = mBeingName->getWidth();
- const int height1 = getFont()->getHeight();
- int height = height1;
- FOR_EACH (STD_VECTOR<Label*>::iterator, it, mLabels)
- {
- const Label *const label = *it;
- if (label != nullptr)
- {
- if (label->getWidth() > minWidth)
- minWidth = label->getWidth();
- if (!label->getCaption().empty())
- height += height1;
- }
- }
-
- setContentSize(minWidth, height);
- position(x, y);
-}
-
-#ifdef USE_PROFILER
-void BeingPopup::logic()
-{
- BLOCK_START("BeingPopup::logic")
- logicChildren();
- BLOCK_END("BeingPopup::logic")
-}
-#endif // USE_PROFILER
diff --git a/src/gui/popups/beingpopup.h b/src/gui/popups/beingpopup.h
deleted file mode 100644
index a14f44568..000000000
--- a/src/gui/popups/beingpopup.h
+++ /dev/null
@@ -1,68 +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 GUI_POPUPS_BEINGPOPUP_H
-#define GUI_POPUPS_BEINGPOPUP_H
-
-#include "gui/widgets/popup.h"
-
-class Being;
-class Label;
-
-/**
- * A popup that displays information about a being.
- */
-class BeingPopup final : public Popup
-{
- public:
- /**
- * Constructor. Initializes the being popup.
- */
- BeingPopup();
-
- A_DELETE_COPY(BeingPopup)
-
- /**
- * Destructor. Cleans up the being popup on deletion.
- */
- ~BeingPopup();
-
- /**
- * Sets the info to be displayed given a particular player.
- */
- void show(const int x, const int y, Being *const b);
-
- void postInit() override final;
-
-#ifdef USE_PROFILER
- void logic();
-#endif // USE_PROFILER
-
- private:
- void addLabels(const int fontHeight);
-
- Label *mBeingName A_NONNULLPOINTER;
- STD_VECTOR<Label*> mLabels;
-};
-
-extern BeingPopup *beingPopup;
-
-#endif // GUI_POPUPS_BEINGPOPUP_H
diff --git a/src/gui/popups/itempopup.cpp b/src/gui/popups/itempopup.cpp
deleted file mode 100644
index 28de3b641..000000000
--- a/src/gui/popups/itempopup.cpp
+++ /dev/null
@@ -1,465 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 The Legend of Mazzeroth Development Team
- * 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 "gui/popups/itempopup.h"
-
-#include "actormanager.h"
-#include "configuration.h"
-
-#include "gui/gui.h"
-
-#include "gui/fonts/font.h"
-
-#include "gui/widgets/icon.h"
-#include "gui/widgets/label.h"
-#include "gui/widgets/textbox.h"
-
-#include "net/beinghandler.h"
-#ifdef TMWA_SUPPORT
-#include "net/net.h"
-#endif // TMWA_SUPPORT
-
-#include "utils/foreach.h"
-#include "utils/gettext.h"
-#include "utils/stdmove.h"
-
-#include "utils/translation/podict.h"
-
-#include "resources/iteminfo.h"
-
-#include "resources/db/itemoptiondb.h"
-#include "resources/db/unitsdb.h"
-
-#include "resources/image/image.h"
-
-#include "resources/item/item.h"
-#include "resources/item/itemfieldtype.h"
-#include "resources/item/itemoptionslist.h"
-
-#include "resources/loaders/imageloader.h"
-
-#include "debug.h"
-
-ItemPopup *itemPopup = nullptr;
-
-ItemPopup::ItemPopup() :
- Popup("ItemPopup", "itempopup.xml"),
- mItemName(new Label(this)),
- mItemDesc(new TextBox(this)),
- mItemEffect(new TextBox(this)),
- mItemWeight(new TextBox(this)),
- mItemCards(new TextBox(this)),
- mItemOptions(new TextBox(this)),
- mItemType(ItemDbType::UNUSABLE),
- mIcon(new Icon(this, nullptr)),
- mLastName(),
- mCardsStr(),
- mItemOptionsStr(),
- mLastId(0),
- mLastColor(ItemColor_one)
-{
- // Item name
- mItemName->setFont(boldFont);
- mItemName->setPosition(0, 0);
-
- const int fontHeight = getFont()->getHeight();
-
- // Item description
- mItemDesc->setEditable(false);
- mItemDesc->setPosition(0, fontHeight);
- mItemDesc->setForegroundColorAll(getThemeColor(ThemeColorId::POPUP),
- getThemeColor(ThemeColorId::POPUP_OUTLINE));
-
- // Item effect
- mItemEffect->setEditable(false);
- mItemEffect->setPosition(0, 2 * fontHeight);
- mItemEffect->setForegroundColorAll(getThemeColor(ThemeColorId::POPUP),
- getThemeColor(ThemeColorId::POPUP_OUTLINE));
-
- // Item weight
- mItemWeight->setEditable(false);
- mItemWeight->setPosition(0, 3 * fontHeight);
- mItemWeight->setForegroundColorAll(getThemeColor(ThemeColorId::POPUP),
- getThemeColor(ThemeColorId::POPUP_OUTLINE));
-
- // Item cards
- mItemCards->setEditable(false);
- mItemCards->setPosition(0, 4 * fontHeight);
- mItemCards->setForegroundColorAll(getThemeColor(ThemeColorId::POPUP),
- getThemeColor(ThemeColorId::POPUP_OUTLINE));
-
- // Item options
- mItemOptions->setEditable(false);
- mItemOptions->setPosition(0, 5 * fontHeight);
- mItemOptions->setForegroundColorAll(getThemeColor(ThemeColorId::POPUP),
- getThemeColor(ThemeColorId::POPUP_OUTLINE));
-}
-
-void ItemPopup::postInit()
-{
- Popup::postInit();
- add(mItemName);
- add(mItemDesc);
- add(mItemEffect);
- add(mItemWeight);
- add(mItemCards);
- add(mItemOptions);
- add(mIcon);
-
- addMouseListener(this);
-}
-
-ItemPopup::~ItemPopup()
-{
- if (mIcon != nullptr)
- {
- Image *const image = mIcon->getImage();
- if (image != nullptr)
- image->decRef();
- }
-}
-
-void ItemPopup::setItem(const Item *const item,
- const bool showImage)
-{
- if (item == nullptr)
- return;
-
- const ItemInfo &ii = item->getInfo();
- setItem(ii,
- item->getColor(),
- showImage,
- item->getId(),
- item->getCards(),
- item->getOptions());
- if (item->getRefine() > 0)
- {
- mLastName = ii.getName();
- mLastColor = item->getColor();
- mLastId = item->getId();
-#ifdef TMWA_SUPPORT
- if (Net::getNetworkType() == ServerType::TMWATHENA)
- {
- mItemName->setCaption(strprintf("%s (+%u), %d",
- ii.getName().c_str(),
- CAST_U32(item->getRefine()),
- ii.getId()));
- }
- else
-#endif // TMWA_SUPPORT
- {
- mItemName->setCaption(strprintf("%s (+%u), %d",
- ii.getName(item->getColor()).c_str(),
- CAST_U32(item->getRefine()),
- ii.getId()));
- }
- mItemName->adjustSize();
- const unsigned minWidth = mItemName->getWidth() + 8;
- if (CAST_U32(getWidth()) < minWidth)
- setWidth(minWidth);
- }
-}
-
-void ItemPopup::setItem(const ItemInfo &item,
- const ItemColor color,
- const bool showImage,
- int id,
- const int *const cards,
- const ItemOptionsList *const options)
-{
- if (mIcon == nullptr)
- return;
-
- std::string cardsStr;
- std::string optionsStr;
-
- if (item.getName() == mLastName &&
- color == mLastColor &&
- id == mLastId)
- {
- cardsStr = getCardsString(cards);
- optionsStr = getOptionsString(options);
- if (mItemOptionsStr == optionsStr &&
- mCardsStr == cardsStr)
- {
- return;
- }
- }
- else
- {
- cardsStr = getCardsString(cards);
- optionsStr = getOptionsString(options);
- }
- mItemOptionsStr = STD_MOVE(optionsStr);
- mCardsStr = STD_MOVE(cardsStr);
-
- if (id == -1)
- id = item.getId();
-
- int space = 0;
-
- Image *const oldImage = mIcon->getImage();
- if (oldImage != nullptr)
- oldImage->decRef();
-
- if (showImage)
- {
- Image *const image = Loader::getImage(combineDye2(
- pathJoin(paths.getStringValue("itemIcons"),
- item.getDisplay().image),
- item.getDyeIconColorsString(color)));
-
- mIcon->setImage(image);
- if (image != nullptr)
- {
- mIcon->setPosition(0, 0);
- space = mIcon->getWidth();
- }
- }
- else
- {
- mIcon->setImage(nullptr);
- }
-
- mItemType = item.getType();
-
- mLastName = item.getName();
- mLastColor = color;
- mLastId = id;
-
-#ifdef TMWA_SUPPORT
- if (Net::getNetworkType() == ServerType::TMWATHENA)
- {
- mItemName->setCaption(strprintf("%s, %d",
- item.getName().c_str(), id));
- mItemDesc->setTextWrapped(item.getDescription(), 196);
- }
- else
-#endif // TMWA_SUPPORT
- {
- mItemName->setCaption(strprintf("%s, %d",
- item.getName(color).c_str(), id));
- mItemDesc->setTextWrapped(item.getDescription(color), 196);
- }
-
- mItemName->adjustSize();
- setLabelColor(mItemName, mItemType);
- mItemName->setPosition(space, 0);
-
- mItemEffect->setTextWrapped(item.getEffect(), 196);
- // TRANSLATORS: popup label
- mItemWeight->setTextWrapped(strprintf(_("Weight: %s"),
- UnitsDb::formatWeight(item.getWeight()).c_str()), 196);
- mItemCards->setTextWrapped(mCardsStr, 196);
- mItemOptions->setTextWrapped(mItemOptionsStr, 196);
-
- int minWidth = mItemName->getWidth() + space;
-
- if (mItemName->getWidth() + space > minWidth)
- minWidth = mItemName->getWidth() + space;
- if (mItemDesc->getMinWidth() > minWidth)
- minWidth = mItemDesc->getMinWidth();
- if (mItemEffect->getMinWidth() > minWidth)
- minWidth = mItemEffect->getMinWidth();
- if (mItemWeight->getMinWidth() > minWidth)
- minWidth = mItemWeight->getMinWidth();
- if (mItemCards->getMinWidth() > minWidth)
- minWidth = mItemCards->getMinWidth();
- if (mItemOptions->getMinWidth() > minWidth)
- minWidth = mItemOptions->getMinWidth();
-
- const int numRowsDesc = mItemDesc->getNumberOfRows();
- const int numRowsEffect = mItemEffect->getNumberOfRows();
- const int numRowsWeight = mItemWeight->getNumberOfRows();
- const int numRowsCards = mItemCards->getNumberOfRows();
- const int numRowsOptions = mItemOptions->getNumberOfRows();
- const int height = getFont()->getHeight();
-
- if (item.getEffect().empty())
- {
- setContentSize(minWidth,
- (numRowsDesc + 2 + numRowsWeight + numRowsCards + numRowsOptions) *
- height);
- mItemWeight->setPosition(0, (numRowsDesc + 2) * height);
- mItemCards->setPosition(0, (numRowsDesc + numRowsWeight + 2) * height);
- mItemOptions->setPosition(0,
- (numRowsDesc + numRowsWeight + numRowsCards + 2) * height);
- }
- else
- {
- setContentSize(minWidth, (numRowsDesc + numRowsEffect + 2
- + numRowsWeight + numRowsCards + numRowsOptions) * height);
- mItemEffect->setPosition(0, (numRowsDesc + 2) * height);
- mItemWeight->setPosition(0, (numRowsDesc + numRowsEffect + 2)
- * height);
- mItemCards->setPosition(0, (numRowsDesc + numRowsEffect
- + numRowsWeight + 2) * height);
- mItemOptions->setPosition(0, (numRowsDesc + numRowsEffect
- + numRowsWeight + numRowsCards + 2) * height);
- }
-
- mItemDesc->setPosition(0, 2 * height);
-}
-
-std::string ItemPopup::getCardsString(const int *const cards)
-{
- if (cards == nullptr)
- return std::string();
-
- std::string label;
-
- switch (cards[0])
- {
- case 0xfe: // named item
- {
- const int32_t charId = cards[2] + 65536 * cards[3];
- std::string name = actorManager->findCharById(charId);
- if (name.empty())
- {
- name = toString(charId);
- beingHandler->requestNameByCharId(charId);
- mLastId = 0; // allow recreate popup with same data
- }
- // TRANSLATORS: named item description
- label.append(strprintf(_("Item named: %s"), name.c_str()));
- return label;
- }
- case 0x00FFU: // forged item
- {
- return label;
- }
- case 0xFF00U:
- {
- return label;
- }
- default:
- {
- for (int f = 0; f < maxCards; f ++)
- {
- const int id = cards[f];
- if (id != 0)
- {
- if (!label.empty())
- label.append(" / ");
- const ItemInfo &info = ItemDB::get(id);
- label.append(info.getName());
- }
- }
- if (label.empty())
- return label;
- // TRANSLATORS: popup label
- return _("Cards: ") + label;
- }
- }
-}
-
-std::string ItemPopup::getOptionsString(const ItemOptionsList *const options)
-{
- if (options == nullptr || translator == nullptr)
- return std::string();
- const size_t sz = options->size();
- std::string effect;
- for (size_t f = 0; f < sz; f ++)
- {
- const ItemOption &option = options->get(f);
- if (option.index == 0)
- continue;
- const STD_VECTOR<ItemFieldType*> &fields = ItemOptionDb::getFields(
- option.index);
- if (fields.empty())
- continue;
- const std::string valueStr = toString(option.value);
- FOR_EACH (STD_VECTOR<ItemFieldType*>::const_iterator, it, fields)
- {
- const ItemFieldType *const field = *it;
- std::string value = valueStr;
- if (!effect.empty())
- effect.append(" / ");
- if (field->sign && value[0] != '-')
- value = std::string("+").append(value);
- const std::string format = translator->getStr(field->description);
- effect.append(strprintf(format.c_str(),
- value.c_str()));
- }
- }
- if (effect.empty())
- return effect;
- // TRANSLATORS: popup label
- return _("Options: ") + effect;
-}
-
-#define caseSetColor(name1, name2) \
- case name1: \
- { \
- return label->setForegroundColorAll(getThemeColor(name2), \
- getThemeColor(name2##_OUTLINE)); \
- }
-void ItemPopup::setLabelColor(Label *label,
- const ItemDbTypeT type) const
-{
- switch (type)
- {
- caseSetColor(ItemDbType::UNUSABLE, ThemeColorId::GENERIC)
- caseSetColor(ItemDbType::USABLE, ThemeColorId::USABLE)
- caseSetColor(ItemDbType::EQUIPMENT_ONE_HAND_WEAPON,
- ThemeColorId::ONEHAND)
- caseSetColor(ItemDbType::EQUIPMENT_TWO_HANDS_WEAPON,
- ThemeColorId::TWOHAND)
- caseSetColor(ItemDbType::EQUIPMENT_TORSO, ThemeColorId::TORSO)
- caseSetColor(ItemDbType::EQUIPMENT_ARMS, ThemeColorId::ARMS)
- caseSetColor(ItemDbType::EQUIPMENT_HEAD, ThemeColorId::HEAD)
- caseSetColor(ItemDbType::EQUIPMENT_LEGS, ThemeColorId::LEGS)
- caseSetColor(ItemDbType::EQUIPMENT_SHIELD, ThemeColorId::SHIELD)
- caseSetColor(ItemDbType::EQUIPMENT_RING, ThemeColorId::RING)
- caseSetColor(ItemDbType::EQUIPMENT_NECKLACE, ThemeColorId::NECKLACE)
- caseSetColor(ItemDbType::EQUIPMENT_FEET, ThemeColorId::FEET)
- caseSetColor(ItemDbType::EQUIPMENT_AMMO, ThemeColorId::AMMO)
- caseSetColor(ItemDbType::EQUIPMENT_CHARM, ThemeColorId::CHARM)
- caseSetColor(ItemDbType::SPRITE_RACE, ThemeColorId::UNKNOWN_ITEM)
- caseSetColor(ItemDbType::SPRITE_HAIR, ThemeColorId::UNKNOWN_ITEM)
- caseSetColor(ItemDbType::CARD, ThemeColorId::CARD)
- default:
- {
- return label->setForegroundColorAll(getThemeColor(
- ThemeColorId::UNKNOWN_ITEM), getThemeColor(
- ThemeColorId::UNKNOWN_ITEM_OUTLINE));
- }
- }
-}
-#undef caseSetColor
-
-void ItemPopup::mouseMoved(MouseEvent &event)
-{
- Popup::mouseMoved(event);
-
- // When the mouse moved on top of the popup, hide it
- setVisible(Visible_false);
- resetPopup();
-}
-
-void ItemPopup::resetPopup()
-{
- mLastName.clear();
- mLastColor = ItemColor_one;
- mLastId = 0;
-}
diff --git a/src/gui/popups/itempopup.h b/src/gui/popups/itempopup.h
deleted file mode 100644
index fff3b817d..000000000
--- a/src/gui/popups/itempopup.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 The Legend of Mazzeroth Development Team
- * 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 GUI_POPUPS_ITEMPOPUP_H
-#define GUI_POPUPS_ITEMPOPUP_H
-
-#include "enums/resources/item/itemdbtype.h"
-
-#include "enums/simpletypes/itemcolor.h"
-
-#include "gui/widgets/popup.h"
-
-class Icon;
-class Item;
-class ItemInfo;
-class Label;
-class TextBox;
-
-struct ItemOptionsList;
-
-/**
- * A popup that displays information about an item.
- */
-class ItemPopup final : public Popup
-{
- public:
- /**
- * Constructor. Initializes the item popup.
- */
- ItemPopup();
-
- A_DELETE_COPY(ItemPopup)
-
- /**
- * Destructor. Cleans up the item popup on deletion.
- */
- ~ItemPopup();
-
- void postInit() override final;
-
- /**
- * Sets the info to be displayed given a particular item.
- */
- void setItem(const ItemInfo &item,
- const ItemColor color,
- const bool showImage,
- int id,
- const int *const cards,
- const ItemOptionsList *const options);
-
- void setItem(const Item *const item,
- const bool showImage);
-
- void mouseMoved(MouseEvent &event) override final;
-
- void resetPopup();
-
- private:
- std::string getCardsString(const int *const cards);
-
- std::string getOptionsString(const ItemOptionsList *const options);
-
- Label *mItemName A_NONNULLPOINTER;
- TextBox *mItemDesc A_NONNULLPOINTER;
- TextBox *mItemEffect A_NONNULLPOINTER;
- TextBox *mItemWeight A_NONNULLPOINTER;
- TextBox *mItemCards A_NONNULLPOINTER;
- TextBox *mItemOptions A_NONNULLPOINTER;
- ItemDbTypeT mItemType;
- Icon *mIcon A_NONNULLPOINTER;
- std::string mLastName;
- std::string mCardsStr;
- std::string mItemOptionsStr;
- int mLastId;
- ItemColor mLastColor;
-
- void setLabelColor(Label *label,
- const ItemDbTypeT type) const A_NONNULL(2);
-};
-
-extern ItemPopup *itemPopup;
-
-#endif // GUI_POPUPS_ITEMPOPUP_H
diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp
deleted file mode 100644
index 752caff72..000000000
--- a/src/gui/popups/popupmenu.cpp
+++ /dev/null
@@ -1,3613 +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 "gui/popups/popupmenu.h"
-
-#include "actormanager.h"
-#include "configuration.h"
-#include "party.h"
-#include "settings.h"
-
-#include "being/flooritem.h"
-#include "being/localplayer.h"
-#include "being/playerinfo.h"
-#include "being/playerrelation.h"
-#include "being/playerrelations.h"
-
-#include "const/spells.h"
-
-#include "enums/resources/map/mapitemtype.h"
-
-#include "input/inputmanager.h"
-
-#include "gui/buttontext.h"
-#include "gui/gui.h"
-#include "gui/popupmanager.h"
-#include "gui/viewport.h"
-#include "gui/windowmenu.h"
-
-#include "gui/windows/chatwindow.h"
-#include "gui/windows/inventorywindow.h"
-#include "gui/windows/minimap.h"
-#include "gui/windows/ministatuswindow.h"
-#include "gui/windows/npcdialog.h"
-#include "gui/windows/outfitwindow.h"
-#include "gui/windows/socialwindow.h"
-#include "gui/windows/textcommandeditor.h"
-#include "gui/windows/textdialog.h"
-#include "gui/windows/tradewindow.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/createwidget.h"
-#include "gui/widgets/progressbar.h"
-#include "gui/widgets/scrollarea.h"
-#include "gui/widgets/staticbrowserbox.h"
-#include "gui/widgets/textfield.h"
-
-#include "gui/widgets/tabs/chat/whispertab.h"
-
-#include "net/adminhandler.h"
-#include "net/chathandler.h"
-#include "net/guildhandler.h"
-#include "net/npchandler.h"
-#include "net/net.h"
-
-#ifdef TMWA_SUPPORT
-#include "net/tmwa/guildmanager.h"
-#endif // TMWA_SUPPORT
-
-#include "resources/chatobject.h"
-#include "resources/groupinfo.h"
-#include "resources/iteminfo.h"
-#include "resources/itemmenuitem.h"
-
-#include "resources/db/groupdb.h"
-#include "resources/db/npcdb.h"
-
-#include "resources/item/item.h"
-
-#include "resources/map/map.h"
-#include "resources/map/mapitem.h"
-#include "resources/map/speciallayer.h"
-
-#include "resources/skill/skillinfo.h"
-
-#include "utils/checkutils.h"
-#include "utils/foreach.h"
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-std::string tradePartnerName;
-
-PopupMenu *popupMenu = nullptr;
-
-PopupMenu::PopupMenu() :
- Popup("PopupMenu", "popupmenu.xml"),
- mBrowserBox(new StaticBrowserBox(this, Opaque_true,
- "popupbrowserbox.xml")),
- mScrollArea(nullptr),
- mBeingId(BeingId_zero),
- mFloorItemId(BeingId_zero),
- mItemId(0),
- mItemIndex(-1),
- mItemColor(ItemColor_one),
- mMapItem(nullptr),
- mTab(nullptr),
- mSpell(nullptr),
- mCallerWindow(nullptr),
- mRenameListener(),
- mPlayerListener(),
- mDialog(nullptr),
- mButton(nullptr),
- mGroup(nullptr),
- mName(),
- mExtName(),
- mTextField(nullptr),
- mType(ActorType::Unknown),
- mSubType(BeingTypeId_zero),
- mX(0),
- mY(0),
- mAllowCleanMenu(true)
-{
- mBrowserBox->setOpaque(Opaque_false);
- mBrowserBox->setLinkHandler(this);
- mRenameListener.setMapItem(nullptr);
- mRenameListener.setDialog(nullptr);
- mPlayerListener.setNick("");
- mPlayerListener.setDialog(nullptr);
- mPlayerListener.setType(ActorType::Unknown);
- mScrollArea = new ScrollArea(this, mBrowserBox, Opaque_false);
- mScrollArea->setVerticalScrollPolicy(ScrollArea::SHOW_AUTO);
- addMouseListener(this);
-}
-
-void PopupMenu::postInit()
-{
- Popup::postInit();
- add(mScrollArea);
-}
-
-void PopupMenu::initPopup()
-{
- if (localPlayer == nullptr)
- return;
- const int groupId = localPlayer->getGroupId();
- mGroup = GroupDb::getGroup(groupId);
-}
-
-bool PopupMenu::isAllowCommand(const ServerCommandTypeT command)
-{
- if (mGroup == nullptr)
- return false;
-#ifdef TMWA_SUPPORT
- // allow any commands for legacy if group > 0
- if (Net::getNetworkType() == ServerType::TMWATHENA &&
- localPlayer != nullptr &&
- localPlayer->isGM())
- {
- return true;
- }
-#endif
- if (mGroup->mPermissions[CAST_SIZE(ServerPermissionType::all_commands)] ==
- Enable_true)
- {
- return true;
- }
- const ServerCommandEnable::Type enabled =
- mGroup->mCommands[CAST_SIZE(command)];
- return (enabled & ServerCommandEnable::Self) != 0;
-}
-
-bool PopupMenu::isAllowOtherCommand(const ServerCommandTypeT command)
-{
- if (mGroup == nullptr ||
- localPlayer == nullptr)
- return false;
-#ifdef TMWA_SUPPORT
- // allow any commands for legacy if group > 0
- if (Net::getNetworkType() == ServerType::TMWATHENA &&
- localPlayer->isGM())
- {
- return true;
- }
-#endif
- const ServerCommandEnable::Type enabled =
- mGroup->mCommands[CAST_SIZE(command)];
- if (mName == localPlayer->getName())
- return (enabled & ServerCommandEnable::Self) != 0;
- return (enabled & ServerCommandEnable::Other) != 0;
-}
-
-void PopupMenu::showPopup(const int x, const int y, const Being *const being)
-{
- if (being == nullptr ||
- localPlayer == nullptr ||
- actorManager == nullptr)
- {
- return;
- }
-
- initPopup();
- mBeingId = being->getId();
- mName = being->getName();
- mExtName = being->getExtName();
- mType = being->getType();
- mSubType = being->getSubType();
- mBrowserBox->clearRows();
- mX = x;
- mY = y;
-
- const std::string &name = mName;
- if (being->getType() != ActorType::SkillUnit)
- {
- mBrowserBox->addRow(name + being->getGenderSignWithSpace());
- }
-
- switch (being->getType())
- {
- case ActorType::Player:
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: trade with player
- mBrowserBox->addRow("/trade 'NAME'", _("Trade"));
- // TRANSLATORS: popup menu item
- // TRANSLATORS: trade attack player
- mBrowserBox->addRow("/attack 'NAME'", _("Attack"));
- // TRANSLATORS: popup menu item
- // TRANSLATORS: send whisper to player
- mBrowserBox->addRow("/whispertext 'NAME'", _("Whisper"));
- addMailCommands();
- addGmCommands();
- mBrowserBox->addSeparator("##3---");
-
-#ifdef TMWA_SUPPORT
- if (Net::getNetworkType() == ServerType::TMWATHENA)
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: heal player
- mBrowserBox->addRow("/heal :'BEINGID'", _("Heal"));
- mBrowserBox->addSeparator("##3---");
- }
-#endif // TMWA_SUPPORT
-
- addPlayerRelation(name);
- mBrowserBox->addSeparator("##3---");
-
- addFollow();
- addPartyName(being->getPartyName());
-
- const Guild *const guild1 = being->getGuild();
- const Guild *const guild2 = localPlayer->getGuild();
- if (guild2 != nullptr)
- {
- if (guild1 != nullptr)
- {
- if (guild1->getId() == guild2->getId())
- {
- mBrowserBox->addRow("/kickguild 'NAME'",
- // TRANSLATORS: popup menu item
- // TRANSLATORS: kick player from guild
- _("Kick from guild"));
- if (guild2->getServerGuild())
- {
- mBrowserBox->addRow(strprintf(
- "@@guild-pos|%s >@@",
- // TRANSLATORS: popup menu item
- // TRANSLATORS: change player position in guild
- _("Change pos in guild")));
- }
- }
- }
- else if (guild2->getMember(mName) != nullptr)
- {
- mBrowserBox->addRow("/kickguild 'NAME'",
- // TRANSLATORS: popup menu item
- // TRANSLATORS: kick player from guild
- _("Kick from guild"));
- if (guild2->getServerGuild())
- {
- mBrowserBox->addRow(strprintf(
- "@@guild-pos|%s >@@",
- // TRANSLATORS: popup menu item
- // TRANSLATORS: change player position in guild
- _("Change pos in guild")));
- }
- }
- else
- {
-#ifdef TMWA_SUPPORT
- if (guild2->getServerGuild() ||
- (guildManager != nullptr && guildManager->havePower()))
-#endif // TMWA_SUPPORT
- {
- mBrowserBox->addRow("/guild 'NAME'",
- // TRANSLATORS: popup menu item
- // TRANSLATORS: invite player to guild
- _("Invite to guild"));
- }
- }
- }
-
- // TRANSLATORS: popup menu item
- // TRANSLATORS: set player invisible for self by id
- mBrowserBox->addRow("/nuke 'NAME'", _("Nuke"));
- // TRANSLATORS: popup menu item
- // TRANSLATORS: move to player location
- mBrowserBox->addRow("/navigateto 'NAME'", _("Move"));
- addPlayerMisc();
- addBuySell(being);
- addChat(being);
- break;
- }
-
- case ActorType::Npc:
- if (!addBeingMenu())
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: talk with npc
- mBrowserBox->addRow("/talk 'NAME'", _("Talk"));
-#ifdef TMWA_SUPPORT
- if (Net::getNetworkType() != ServerType::TMWATHENA)
-#endif
- {
- mBrowserBox->addRow("/whispertext NPC:'NAME'",
- // TRANSLATORS: popup menu item
- // TRANSLATORS: whisper to npc
- _("Whisper"));
- }
- // TRANSLATORS: popup menu item
- // TRANSLATORS: buy from npc
- mBrowserBox->addRow("/buy 'NAME'", _("Buy"));
- // TRANSLATORS: popup menu item
- // TRANSLATORS: sell to npc
- mBrowserBox->addRow("/sell 'NAME'", _("Sell"));
- }
-
- addGmCommands();
- mBrowserBox->addSeparator("##3---");
- // TRANSLATORS: popup menu item
- // TRANSLATORS: move to npc location
- mBrowserBox->addRow("/navigateto 'NAME'", _("Move"));
- // TRANSLATORS: popup menu item
- // TRANSLATORS: add comment to npc
- mBrowserBox->addRow("addcomment", _("Add comment"));
- addChat(being);
- break;
-
- case ActorType::Monster:
- {
- // Monsters can be attacked
- // TRANSLATORS: popup menu item
- // TRANSLATORS: attack monster
- mBrowserBox->addRow("/attack :'BEINGID'", _("Attack"));
- addCatchPetCommands();
- addGmCommands();
- mBrowserBox->addSeparator("##3---");
-
- if (config.getBoolValue("enableAttackFilter"))
- {
- mBrowserBox->addSeparator("##3---");
- if (actorManager->isInAttackList(name)
- || actorManager->isInIgnoreAttackList(name)
- || actorManager->isInPriorityAttackList(name))
- {
- mBrowserBox->addRow("/removeattack 'NAME'",
- // TRANSLATORS: remove monster from attack list
- // TRANSLATORS: popup menu item
- _("Remove from attack list"));
- }
- else
- {
- mBrowserBox->addRow("/addpriorityattack 'NAME'",
- // TRANSLATORS: popup menu item
- // TRANSLATORS: add monster to priotiry attack list
- _("Add to priority attack list"));
- mBrowserBox->addRow("/addattack 'NAME'",
- // TRANSLATORS: popup menu item
- // TRANSLATORS: add monster to attack list
- _("Add to attack list"));
- mBrowserBox->addRow("/addignoreattack 'NAME'",
- // TRANSLATORS: popup menu item
- // TRANSLATORS: add monster to ignore list
- _("Add to ignore list"));
- }
- }
- break;
- }
-
- case ActorType::Mercenary:
- // TRANSLATORS: popup menu item
- // TRANSLATORS: Mercenary move to master
- mBrowserBox->addRow("/mercenarytomaster", _("Move to master"));
- addGmCommands();
- mBrowserBox->addSeparator("##3---");
- // TRANSLATORS: popup menu item
- // TRANSLATORS: fire mercenary
- mBrowserBox->addRow("/firemercenary", _("Fire"));
- mBrowserBox->addSeparator("##3---");
- break;
-
- case ActorType::Homunculus:
- {
- const HomunculusInfo *const info = PlayerInfo::getHomunculus();
- if (info != nullptr)
- {
- mBrowserBox->addRow("/homunculustomaster",
- // TRANSLATORS: popup menu item
- // TRANSLATORS: homunculus move to master
- _("Move to master"));
- // TRANSLATORS: popup menu item
- // TRANSLATORS: feed homunculus
- mBrowserBox->addRow("/homunculusfeed", _("Feed"));
- mBrowserBox->addSeparator("##3---");
- // TRANSLATORS: popup menu item
- // TRANSLATORS: pet rename item
- mBrowserBox->addRow("/sethomunname", _("Rename"));
- mBrowserBox->addSeparator("##3---");
- // TRANSLATORS: popup menu item
- // TRANSLATORS: delete homunculus
- mBrowserBox->addRow("/homunculusfire", _("Kill"));
- mBrowserBox->addSeparator("##3---");
- }
- addGmCommands();
- break;
- }
- case ActorType::Pet:
- if (being->getOwner() == localPlayer)
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: feed pet
- mBrowserBox->addRow("/petfeed", _("Feed"));
- // TRANSLATORS: popup menu item
- // TRANSLATORS: pet drop loot
- mBrowserBox->addRow("/petdroploot", _("Drop loot"));
- // TRANSLATORS: popup menu item
- // TRANSLATORS: pet unequip item
- mBrowserBox->addRow("/petunequip", _("Unequip"));
- addGmCommands();
- mBrowserBox->addSeparator("##3---");
- // TRANSLATORS: popup menu item
- // TRANSLATORS: pet rename item
- mBrowserBox->addRow("/setpetname", _("Rename"));
- mBrowserBox->addSeparator("##3---");
- const BeingInfo *const info = being->getInfo();
- std::string msg;
- if (info != nullptr)
- msg = info->getString(0);
- if (!msg.empty())
- {
- mBrowserBox->addRow("/petreturnegg", msg.c_str());
- }
- else
- {
- mBrowserBox->addRow("/petreturnegg",
- // TRANSLATORS: popup menu item
- // TRANSLATORS: pet return to egg
- _("Return to egg"));
- }
- mBrowserBox->addSeparator("##3---");
- }
- else
- {
- addCatchPetCommands();
- }
- break;
- case ActorType::SkillUnit:
- {
- const BeingId id = being->getCreatorId();
- std::string creatorName;
- Being *const creator = actorManager->findBeing(id);
- if (creator != nullptr)
- creatorName = creator->getName();
- else
- creatorName = actorManager->getSeenPlayerById(id);
-
- if (creatorName.empty())
- creatorName = strprintf("?%d", CAST_S32(id));
-
- mBrowserBox->addRow(strprintf("%s, %d (%s)",
- name.c_str(),
- CAST_S32(being->getSubType()),
- creatorName.c_str()));
- break;
- }
- case ActorType::Avatar:
- case ActorType::Unknown:
- case ActorType::FloorItem:
- case ActorType::Portal:
- case ActorType::Elemental:
- default:
- break;
- }
- // TRANSLATORS: popup menu item
- // TRANSLATORS: add being name to chat
- mBrowserBox->addRow("/addtext 'NAME'", _("Add name to chat"));
- mBrowserBox->addSeparator("##3---");
-
- // TRANSLATORS: popup menu item
- // TRANSLATORS: close menu
- mBrowserBox->addRow("cancel", _("Cancel"));
-
- showPopup(x, y);
-}
-
-bool PopupMenu::addBeingMenu()
-{
- Being *being = actorManager->findBeing(mBeingId);
- if (being == nullptr)
- return false;
-
- BeingInfo *const info = NPCDB::get(fromInt(
- being->getSubType(), BeingTypeId));
- if (info == nullptr)
- return false;
-
- const STD_VECTOR<BeingMenuItem> &menu = info->getMenu();
- FOR_EACH (STD_VECTOR<BeingMenuItem>::const_iterator, it, menu)
- {
- const BeingMenuItem &item = *it;
- mBrowserBox->addRow("/" + item.command, item.name.c_str());
- }
- return true;
-}
-
-void PopupMenu::setMousePos()
-{
- if (viewport != nullptr)
- {
- mX = viewport->mMouseX;
- mY = viewport->mMouseY;
- }
- else
- {
- Gui::getMouseState(mX, mY);
- }
-}
-
-void PopupMenu::setMousePos2()
-{
- if (mX == 0 && mY == 0)
- {
- if (viewport != nullptr)
- {
- mX = viewport->mMouseX;
- mY = viewport->mMouseY;
- }
- else
- {
- Gui::getMouseState(mX, mY);
- }
- }
-}
-
-void PopupMenu::showPopup(const int x, const int y,
- const STD_VECTOR<ActorSprite*> &beings)
-{
- initPopup();
- mX = x;
- mY = y;
- mBrowserBox->clearRows();
- // TRANSLATORS: popup menu header
- mBrowserBox->addRow(_("Players"));
- FOR_EACH (STD_VECTOR<ActorSprite*>::const_iterator, it, beings)
- {
- const Being *const being = dynamic_cast<const Being*>(*it);
- const ActorSprite *const actor = *it;
- if ((being != nullptr) && !being->getName().empty())
- {
- mBrowserBox->addRow(strprintf("@@player_%u|%s >@@",
- CAST_U32(being->getId()), (being->getName()
- + being->getGenderSignWithSpace()).c_str()));
- }
- else if (actor->getType() == ActorType::FloorItem)
- {
- const FloorItem *const floorItem
- = static_cast<const FloorItem*>(actor);
- mBrowserBox->addRow(strprintf("@@flooritem_%u|%s >@@",
- CAST_U32(actor->getId()),
- floorItem->getName().c_str()));
- }
- }
- mBrowserBox->addSeparator("##3---");
- // TRANSLATORS: popup menu item
- // TRANSLATORS: close menu
- mBrowserBox->addRow("cancel", _("Cancel"));
- showPopup(x, y);
-}
-
-void PopupMenu::showPlayerPopup(const std::string &nick)
-{
- if (nick.empty() || (localPlayer == nullptr))
- return;
-
- initPopup();
- setMousePos();
- mName = nick;
- mExtName = nick;
- mBeingId = BeingId_zero;
- mType = ActorType::Player;
- mSubType = BeingTypeId_zero;
- mBrowserBox->clearRows();
-
- const std::string &name = mName;
-
- mBrowserBox->addRow(name);
-
- // TRANSLATORS: popup menu item
- // TRANSLATORS: send whisper to player
- mBrowserBox->addRow("/whispertext 'NAME'", _("Whisper"));
- addMailCommands();
- addGmCommands();
- mBrowserBox->addSeparator("##3---");
-
- addPlayerRelation(name);
- mBrowserBox->addSeparator("##3---");
-
- addFollow();
- // TRANSLATORS: popup menu item
- // TRANSLATORS: add comment to player
- mBrowserBox->addRow("addcomment", _("Add comment"));
-
- if (localPlayer->isInParty())
- {
- const Party *const party = localPlayer->getParty();
- if (party != nullptr)
- {
- const PartyMember *const member = party->getMember(mName);
- if (member != nullptr)
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: kick player from party
- mBrowserBox->addRow("/kickparty 'NAME'", _("Kick from party"));
- mBrowserBox->addSeparator("##3---");
- const PartyMember *const o = party->getMember(
- localPlayer->getName());
- showAdoptCommands();
- if ((o != nullptr) && member->getMap() == o->getMap())
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: move to player position
- mBrowserBox->addRow("/navigate 'X' 'Y'", _("Move"));
- }
- }
- }
- }
-
- const Guild *const guild2 = localPlayer->getGuild();
- if (guild2 != nullptr)
- {
- if (guild2->getMember(mName) != nullptr)
- {
-#ifdef TMWA_SUPPORT
- if (guild2->getServerGuild() || (guildManager != nullptr
- && guildManager->havePower()))
-#endif // TMWA_SUPPORT
- {
- mBrowserBox->addRow("/kickguild 'NAME'",
- // TRANSLATORS: popup menu item
- // TRANSLATORS: kick player from guild
- _("Kick from guild"));
- }
- if (guild2->getServerGuild())
- {
- mBrowserBox->addRow(strprintf(
- // TRANSLATORS: popup menu item
- // TRANSLATORS: change player position in guild
- "@@guild-pos|%s >@@", _("Change pos in guild")));
- }
- }
- else
- {
-#ifdef TMWA_SUPPORT
- if (guild2->getServerGuild() || (guildManager != nullptr
- && guildManager->havePower()))
-#endif // TMWA_SUPPORT
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: invite player to guild
- mBrowserBox->addRow("/guild 'NAME'", _("Invite to guild"));
- }
- }
- }
-
- addBuySellDefault();
- // TRANSLATORS: popup menu item
- // TRANSLATORS: add player name to chat
- mBrowserBox->addRow("/addtext 'NAME'", _("Add name to chat"));
- mBrowserBox->addSeparator("##3---");
- // TRANSLATORS: popup menu item
- // TRANSLATORS: close menu
- mBrowserBox->addRow("cancel", _("Cancel"));
-
- showPopup(mX, mY);
-}
-
-void PopupMenu::showPopup(const int x, const int y,
- const FloorItem *const floorItem)
-{
- if (floorItem == nullptr)
- return;
-
- initPopup();
- mX = x;
- mY = y;
- mFloorItemId = floorItem->getId();
- mItemId = floorItem->getItemId();
- mType = ActorType::FloorItem;
- mSubType = BeingTypeId_zero;
- for (int f = 0; f < maxCards; f ++)
- mItemCards[f] = floorItem->getCard(f);
- mBrowserBox->clearRows();
- const std::string name = floorItem->getName();
- mName = name;
- mExtName = name;
-
- mBrowserBox->addRow(name);
-
- if (config.getBoolValue("enablePickupFilter"))
- {
- if (actorManager->isInPickupList(name)
- || (actorManager->isInPickupList("")
- && !actorManager->isInIgnorePickupList(name)))
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: pickup item from ground
- mBrowserBox->addRow("/pickup 'FLOORID'", _("Pick up"));
- mBrowserBox->addSeparator("##3---");
- }
- addPickupFilter(name);
- }
- else
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: pickup item from ground
- mBrowserBox->addRow("/pickup 'FLOORID'", _("Pick up"));
- }
- addProtection();
- // TRANSLATORS: popup menu item
- // TRANSLATORS: add item name to chat
- mBrowserBox->addRow("/addchat 'FLOORID''CARDS'", _("Add to chat"));
- mBrowserBox->addSeparator("##3---");
- addGmCommands();
-
- // TRANSLATORS: popup menu item
- // TRANSLATORS: close menu
- mBrowserBox->addRow("cancel", _("Cancel"));
-
- showPopup(mX, mY);
-}
-
-void PopupMenu::showPopup(const int x, const int y, MapItem *const mapItem)
-{
- if (mapItem == nullptr)
- return;
-
- initPopup();
- mMapItem = mapItem;
- mX = x;
- mY = y;
-
- mBrowserBox->clearRows();
-
- // TRANSLATORS: popup menu header
- mBrowserBox->addRow(_("Map Item"));
- // TRANSLATORS: popup menu item
- // TRANSLATORS: rename map item
- mBrowserBox->addRow("rename map", _("Rename"));
- // TRANSLATORS: popup menu item
- // TRANSLATORS: remove map item
- mBrowserBox->addRow("remove map", _("Remove"));
-
- if (isAllowCommand(ServerCommandType::slide))
- {
- mBrowserBox->addSeparator("##3---");
- // TRANSLATORS: popup menu item
- // TRANSLATORS: warp to map item
- mBrowserBox->addRow("/slide 'MAPX' 'MAPY'", _("Warp"));
- }
- mBrowserBox->addSeparator("##3---");
- // TRANSLATORS: popup menu item
- // TRANSLATORS: close menu
- mBrowserBox->addRow("cancel", _("Cancel"));
-
- showPopup(x, y);
-}
-
-void PopupMenu::showMapPopup(const int x, const int y,
- const int x2, const int y2,
- const bool isMinimap)
-{
- initPopup();
- mX = x2;
- mY = y2;
-
- if (isMinimap)
- mCallerWindow = minimap;
-
- mBrowserBox->clearRows();
-
- // TRANSLATORS: popup menu header
- mBrowserBox->addRow(_("Map Item"));
-
- if (isAllowCommand(ServerCommandType::slide))
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: warp to map item
- mBrowserBox->addRow("/slide 'MAPX' 'MAPY'", _("Warp"));
- }
- // TRANSLATORS: popup menu item
- // TRANSLATORS: move to map item
- mBrowserBox->addRow("/navigate 'X' 'Y'", _("Move"));
- // TRANSLATORS: popup menu item
- // TRANSLATORS: move camera to map item
- mBrowserBox->addRow("/movecamera 'X' 'Y'", _("Move camera"));
- if (settings.cameraMode != 0)
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: restore camera to default view
- mBrowserBox->addRow("/restorecamera", _("Restore camera"));
- }
- mBrowserBox->addSeparator("##3---");
- if (isMinimap)
- {
- // TRANSLATORS: popup menu item
- mBrowserBox->addRow("window close", _("Close"));
- }
- mBrowserBox->addSeparator("##3---");
- // TRANSLATORS: popup menu item
- // TRANSLATORS: close menu
- mBrowserBox->addRow("cancel", _("Cancel"));
-
- showPopup(x, y);
-}
-
-void PopupMenu::showOutfitsWindowPopup(const int x, const int y)
-{
- initPopup();
- mX = x;
- mY = y;
- mCallerWindow = outfitWindow;
-
- mBrowserBox->clearRows();
-
- // TRANSLATORS: popup menu header
- mBrowserBox->addRow(_("Outfits"));
- // TRANSLATORS: popup menu item
- // TRANSLATORS: copy selected outfit to chat input
- mBrowserBox->addRow("/outfittochat", _("Add to chat"));
- mBrowserBox->addSeparator("##3---");
- // TRANSLATORS: popup menu item
- // TRANSLATORS: copy equipment from player to outfit
- mBrowserBox->addRow("/itemstooutfit", _("Copy from player"));
- mBrowserBox->addSeparator("##3---");
- // TRANSLATORS: popup menu item
- // TRANSLATORS: clear selected outfit
- mBrowserBox->addRow("/clearoutfit", _("Clear outfit"));
- mBrowserBox->addSeparator("##3---");
-
- addWindowMenu(outfitWindow);
- mBrowserBox->addSeparator("##3---");
-
- // TRANSLATORS: popup menu item
- // TRANSLATORS: close menu
- mBrowserBox->addRow("cancel", _("Cancel"));
-
- showPopup(x, y);
-}
-
-void PopupMenu::showSpellPopup(const int x, const int y,
- TextCommand *const cmd)
-{
- if (cmd == nullptr)
- return;
-
- initPopup();
- mBrowserBox->clearRows();
-
- mSpell = cmd;
- mX = x;
- mY = y;
-
- // TRANSLATORS: popup menu header
- mBrowserBox->addRow(_("Spells"));
- // TRANSLATORS: popup menu item
- // TRANSLATORS: edit selected spell
- mBrowserBox->addRow("edit spell", _("Edit spell"));
- mBrowserBox->addSeparator("##3---");
- // TRANSLATORS: popup menu item
- // TRANSLATORS: close menu
- mBrowserBox->addRow("cancel", _("Cancel"));
-
- showPopup(x, y);
-}
-
-void PopupMenu::showChatPopup(const int x, const int y, ChatTab *const tab)
-{
- if (tab == nullptr ||
- actorManager == nullptr ||
- localPlayer == nullptr)
- {
- return;
- }
-
- initPopup();
- mTab = tab;
- mX = x;
- mY = y;
- mCallerWindow = chatWindow;
-
- mBrowserBox->clearRows();
-
- const ChatTabTypeT &type = tab->getType();
- if (type == ChatTabType::WHISPER || type == ChatTabType::CHANNEL)
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: close chat tab
- mBrowserBox->addRow("/close", _("Close"));
- }
-
- // TRANSLATORS: popup menu item
- // TRANSLATORS: remove all text from chat tab
- mBrowserBox->addRow("/chatclear", _("Clear"));
- mBrowserBox->addSeparator("##3---");
-
- if (tab->getAllowHighlight())
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: disable chat tab highlight
- mBrowserBox->addRow("/disablehighlight", _("Disable highlight"));
- }
- else
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: enable chat tab highlight
- mBrowserBox->addRow("/enablehighlight", _("Enable highlight"));
- }
- if (tab->getRemoveNames())
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: do not remove player names from chat tab
- mBrowserBox->addRow("/dontremovename", _("Don't remove name"));
- }
- else
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: remove player names from chat tab
- mBrowserBox->addRow("/removename", _("Remove name"));
- }
- if (tab->getNoAway())
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: enable away messages in chat tab
- mBrowserBox->addRow("/enableaway", _("Enable away"));
- }
- else
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: disable away messages in chat tab
- mBrowserBox->addRow("/disableaway", _("Disable away"));
- }
- mBrowserBox->addSeparator("##3---");
- if (type == ChatTabType::PARTY)
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: enable away messages in chat tab
- mBrowserBox->addRow("/leaveparty", _("Leave"));
- mBrowserBox->addSeparator("##3---");
- }
- // TRANSLATORS: popup menu item
- // TRANSLATORS: copy selected text to clipboard
- mBrowserBox->addRow("/chatclipboard 'X' 'Y'", _("Copy to clipboard"));
- mBrowserBox->addSeparator("##3---");
-
- if (type == ChatTabType::WHISPER)
- {
- const WhisperTab *const wTab = static_cast<WhisperTab*>(tab);
- const std::string &name = wTab->getNick();
-
- const Being* const being = actorManager->findBeingByName(
- name, ActorType::Player);
-
- addGmCommands();
- if (being != nullptr)
- {
- mBeingId = being->getId();
- mName = being->getName();
- mExtName = being->getExtName();
- mType = being->getType();
- mSubType = being->getSubType();
-
- // TRANSLATORS: popup menu item
- // TRANSLATORS: trade with player
- mBrowserBox->addRow("/trade 'NAME'", _("Trade"));
- // TRANSLATORS: popup menu item
- // TRANSLATORS: attack player
- mBrowserBox->addRow("/attack 'NAME'", _("Attack"));
- addMailCommands();
- mBrowserBox->addSeparator("##3---");
- // TRANSLATORS: popup menu item
- // TRANSLATORS: heal player
- mBrowserBox->addRow("/heal :'BEINGID'", _("Heal"));
- mBrowserBox->addSeparator("##3---");
- addPlayerRelation(name);
- mBrowserBox->addSeparator("##3---");
- addFollow();
- // TRANSLATORS: popup menu item
- // TRANSLATORS: move to player position
- mBrowserBox->addRow("/navigateto 'NAME'", _("Move"));
- addPlayerMisc();
- addBuySell(being);
- mBrowserBox->addSeparator("##3---");
- addParty(wTab->getNick());
- const Guild *const guild1 = being->getGuild();
- const Guild *const guild2 = localPlayer->getGuild();
- if (guild2 != nullptr)
- {
- if (guild1 != nullptr)
- {
- if (guild1->getId() == guild2->getId())
- {
-#ifdef TMWA_SUPPORT
- if (guild2->getServerGuild() ||
- (guildManager != nullptr &&
- guildManager->havePower()))
-#endif // TMWA_SUPPORT
- {
- mBrowserBox->addRow("/kickguild 'NAME'",
- // TRANSLATORS: popup menu item
- // TRANSLATORS: kick player from guild
- _("Kick from guild"));
- }
- if (guild2->getServerGuild())
- {
- mBrowserBox->addRow(strprintf("@@guild-pos|%s >@@",
- // TRANSLATORS: popup menu item
- // TRANSLATORS: change player position in guild
- _("Change pos in guild")));
- }
- }
- }
- else
- {
-#ifdef TMWA_SUPPORT
- if (guild2->getServerGuild() || (guildManager != nullptr
- && guildManager->havePower()))
-#endif // TMWA_SUPPORT
- {
- mBrowserBox->addRow("/guild 'NAME'",
- // TRANSLATORS: popup menu item
- // TRANSLATORS: invite player to guild
- _("Invite to guild"));
- }
- }
- }
- }
- else
- {
- mBeingId = BeingId_zero;
- mName = name;
- mExtName = name;
- mType = ActorType::Player;
- mSubType = BeingTypeId_zero;
- addPlayerRelation(name);
- mBrowserBox->addSeparator("##3---");
- addMailCommands();
- addFollow();
-
- if (localPlayer->isInParty())
- {
- const Party *const party = localPlayer->getParty();
- if (party != nullptr)
- {
- const PartyMember *const m = party->getMember(mName);
- if (m != nullptr)
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: move to player location
- mBrowserBox->addRow("/navigateto 'NAME'", _("Move"));
- }
- }
- }
- addPlayerMisc();
- addBuySellDefault();
- if (Net::getNetworkType() != ServerType::TMWATHENA)
- addParty(wTab->getNick());
- mBrowserBox->addSeparator("##3---");
- }
- }
-
- addWindowMenu(chatWindow);
- // TRANSLATORS: popup menu item
- // TRANSLATORS: close menu
- mBrowserBox->addRow("cancel", _("Cancel"));
-
- showPopup(x, y);
-}
-
-void PopupMenu::showChangePos(const int x, const int y)
-{
- initPopup();
- mBrowserBox->clearRows();
- // TRANSLATORS: popup menu header
- mBrowserBox->addRow(_("Change guild position"));
-
- if (localPlayer == nullptr)
- return;
-
- mX = x;
- mY = y;
- const Guild *const guild = localPlayer->getGuild();
- if (guild != nullptr)
- {
- const PositionsMap &map = guild->getPositions();
- FOR_EACH (PositionsMap::const_iterator, itr, map)
- {
- mBrowserBox->addRow(strprintf("@@guild-pos-%u|%s@@",
- itr->first, itr->second.c_str()));
- }
- // TRANSLATORS: popup menu item
- // TRANSLATORS: close menu
- mBrowserBox->addRow("cancel", _("Cancel"));
-
- showPopup(x, y);
- }
- else
- {
- mBeingId = BeingId_zero;
- mFloorItemId = BeingId_zero;
- mItemIndex = -1;
- mItemId = 0;
- for (int f = 0; f < maxCards; f ++)
- mItemCards[f] = 0;
- mMapItem = nullptr;
- mName.clear();
- mExtName.clear();
- mType = ActorType::Unknown;
- mSubType = BeingTypeId_zero;
- mX = 0;
- mY = 0;
- setVisible(Visible_false);
- }
-}
-
-void PopupMenu::showWindowPopup(Window *const window)
-{
- if (window == nullptr)
- return;
-
- initPopup();
- setMousePos();
- mCallerWindow = window;
- mBrowserBox->clearRows();
- // TRANSLATORS: popup menu header
- mBrowserBox->addRow(_("window"));
-
- addWindowMenu(window);
-
- // TRANSLATORS: popup menu item
- // TRANSLATORS: close menu
- mBrowserBox->addRow("cancel", _("Cancel"));
-
- showPopup(mX, mY);
-}
-
-void PopupMenu::addWindowMenu(const Window *const window)
-{
- if (window == nullptr)
- return;
-
- initPopup();
- if (window->getAlowClose())
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: close window
- mBrowserBox->addRow("window close", _("Close"));
- }
-
- if (window->isStickyButtonLock())
- {
- if (window->isSticky())
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: unlock window
- mBrowserBox->addRow("window unlock", _("Unlock"));
- }
- else
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: lock window
- mBrowserBox->addRow("window lock", _("Lock"));
- }
- }
-}
-
-void PopupMenu::showEmoteType()
-{
- initPopup();
- setMousePos();
-
- mBrowserBox->clearRows();
- // TRANSLATORS: popup menu header
- mBrowserBox->addRow(_("Show emotes for:"));
-
- // TRANSLATORS: popup menu item
- // TRANSLATORS: show emotes for player
- mBrowserBox->addRow("/setemotetype player", _("Player"));
-
- // TRANSLATORS: popup menu item
- // TRANSLATORS: show emotes for pet
- mBrowserBox->addRow("/setemotetype pet", _("Pet"));
-
- if (Net::getNetworkType() == ServerType::EVOL2)
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: show emotes for homuncules
- mBrowserBox->addRow("/setemotetype homun", _("Homunculus"));
-
- // TRANSLATORS: popup menu item
- // TRANSLATORS: show emotes for mercenary
- mBrowserBox->addRow("/setemotetype merc", _("Mercenary"));
- }
- mBrowserBox->addSeparator("##3---");
-
- // TRANSLATORS: popup menu item
- // TRANSLATORS: close menu
- mBrowserBox->addRow("cancel", _("Cancel"));
-
- showPopup(mX, mY);
-}
-
-void PopupMenu::handleLink(const std::string &link,
- MouseEvent *event A_UNUSED)
-{
- Being *being = nullptr;
- if (actorManager != nullptr)
- being = actorManager->findBeing(mBeingId);
-
- mAllowCleanMenu = true;
-
- if (link == "remove map" && (mMapItem != nullptr))
- {
- if (viewport != nullptr)
- {
- const Map *const map = viewport->getMap();
- if (map != nullptr)
- {
- SpecialLayer *const specialLayer = map->getSpecialLayer();
- if (specialLayer != nullptr)
- {
- const bool isHome = (mMapItem->getType()
- == CAST_S32(MapItemType::HOME));
- const int x = static_cast<int>(mMapItem->getX());
- const int y = static_cast<int>(mMapItem->getY());
- specialLayer->setTile(x, y,
- CAST_S32(MapItemType::EMPTY));
- specialLayer->updateCache();
- if (socialWindow != nullptr)
- socialWindow->removePortal(x, y);
- if (isHome && (localPlayer != nullptr))
- {
- localPlayer->removeHome();
- localPlayer->saveHomes();
- }
- }
- }
- }
- }
- else if (link == "rename map" && (mMapItem != nullptr))
- {
- mRenameListener.setMapItem(mMapItem);
- CREATEWIDGETV(mDialog, TextDialog,
- // TRANSLATORS: dialog caption
- // TRANSLATORS: number of chars in string should be near original
- _("Rename map sign "),
- // TRANSLATORS: label
- // TRANSLATORS: number of chars in string should be near original
- _("Name: "));
- mRenameListener.setDialog(mDialog);
- mDialog->setText(mMapItem->getComment());
- mDialog->setActionEventId("ok");
- mDialog->addActionListener(&mRenameListener);
- }
- else if (link == "edit spell" && (mSpell != nullptr))
- {
- CREATEWIDGET(TextCommandEditor, mSpell);
- }
- else if (link == "addcomment" && !mName.empty())
- {
- TextDialog *const dialog = CREATEWIDGETR(TextDialog,
- // TRANSLATORS: dialog caption
- // TRANSLATORS: number of chars in string should be near original
- _("Player comment "),
- // TRANSLATORS: label
- // TRANSLATORS: number of chars in string should be near original
- _("Comment: "));
- mPlayerListener.setDialog(dialog);
- mPlayerListener.setNick(mName);
- mPlayerListener.setType(mType);
-
- if (being != nullptr)
- {
- being->updateComment();
- dialog->setText(being->getComment());
- }
- else
- {
- dialog->setText(Being::loadComment(mName,
- static_cast<ActorTypeT>(mType)));
- }
- dialog->setActionEventId("ok");
- dialog->addActionListener(&mPlayerListener);
- }
- else if (link == "guild-pos" && !mName.empty())
- {
- showChangePos(getX(), getY());
- return;
- }
- else if (link == "clipboard copy")
- {
- if (mTextField != nullptr)
- mTextField->handleCopy();
- }
- else if (link == "clipboard paste")
- {
- if (mTextField != nullptr)
- mTextField->handlePaste();
- }
- else if (link == "gm" && !mName.empty())
- {
- showGMPopup(mName);
- return;
- }
- else if (link == "mute" && !mName.empty())
- {
- showMuteCommands();
- return;
- }
- else if (link == "show" && !mName.empty())
- {
- showPlayerMenu();
- return;
- }
- else if (link == "window close" && (mCallerWindow != nullptr))
- {
- if (Widget::widgetExists(mCallerWindow))
- mCallerWindow->close();
- }
- else if (link == "window unlock" && (mCallerWindow != nullptr))
- {
- if (Widget::widgetExists(mCallerWindow))
- mCallerWindow->setSticky(false);
- }
- else if (link == "window lock" && (mCallerWindow != nullptr))
- {
- if (Widget::widgetExists(mCallerWindow))
- mCallerWindow->setSticky(true);
- }
- else if (link == "join chat" && (being != nullptr))
- {
- const ChatObject *const chat = being->getChat();
- if (chat != nullptr)
- chatHandler->joinChat(chat, "");
- }
- else if (link == "craftmenu")
- {
- showCraftPopup();
- return;
- }
- else if (link.compare(0, 10, "guild-pos-") == 0)
- {
- if (localPlayer != nullptr)
- {
- const int num = atoi(link.substr(10).c_str());
- const Guild *const guild = localPlayer->getGuild();
- if (guild != nullptr)
- {
- guildHandler->changeMemberPostion(
- guild->getMember(mName), num);
- }
- }
- }
- else if (link.compare(0, 7, "player_") == 0)
- {
- if (actorManager != nullptr)
- {
- mBeingId = fromInt(atoi(link.substr(7).c_str()), BeingId);
- being = actorManager->findBeing(mBeingId);
- if (being != nullptr)
- {
- showPopup(getX(), getY(), being);
- return;
- }
- }
- }
- else if (link.compare(0, 10, "flooritem_") == 0)
- {
- if (actorManager != nullptr)
- {
- const BeingId id = fromInt(atoi(
- link.substr(10).c_str()), BeingId);
- if (id != BeingId_zero)
- {
- const FloorItem *const item = actorManager->findItem(id);
- if (item != nullptr)
- {
- mFloorItemId = item->getId();
- mItemId = item->getItemId();
- for (int f = 0; f < maxCards; f ++)
- mItemCards[f] = item->getCard(f);
- showPopup(getX(), getY(), item);
- return;
- }
- }
- }
- }
- else if (link.compare(0, 12, "hide button_") == 0)
- {
- if (windowMenu != nullptr)
- windowMenu->showButton(link.substr(12), Visible_false);
- }
- else if (link.compare(0, 12, "show button_") == 0)
- {
- if (windowMenu != nullptr)
- windowMenu->showButton(link.substr(12), Visible_true);
- }
- else if (link.compare(0, 9, "hide bar_") == 0)
- {
- if (miniStatusWindow != nullptr)
- miniStatusWindow->showBar(link.substr(9), Visible_false);
- }
- else if (link.compare(0, 9, "show bar_") == 0)
- {
- if (miniStatusWindow != nullptr)
- miniStatusWindow->showBar(link.substr(9), Visible_true);
- }
- else if (link.compare(0, 12, "show window_") == 0)
- {
- const int id = atoi(link.substr(12).c_str());
- if (id >= 0)
- inputManager.executeAction(static_cast<InputActionT>(id));
- }
- else if (link.compare(0, 6, "mute_+") == 0)
- {
- if (being != nullptr)
- {
- const int time = atoi(link.substr(6).c_str());
- adminHandler->mute(being, 1, time);
- }
- }
- else if (link.compare(0, 6, "mute_-") == 0)
- {
- if (being != nullptr)
- {
- const int time = atoi(link.substr(6).c_str());
- adminHandler->mute(being, 0, time);
- }
- }
- else if (!link.empty() && link[0] == '/')
- {
- std::string cmd = link.substr(1);
- replaceAll(cmd, "'NAME'", mName);
- replaceAll(cmd, "'ENAME'", escapeString(mName));
- replaceAll(cmd, "'EXTNAME'", mExtName);
- replaceAll(cmd, "'EEXTNAME'", escapeString(mExtName));
- replaceAll(cmd, "'X'", toString(mX));
- replaceAll(cmd, "'Y'", toString(mY));
- replaceAll(cmd, "'BEINGID'", toString(toInt(mBeingId, int)));
- replaceAll(cmd, "'FLOORID'", toString(toInt(mFloorItemId, int)));
- replaceAll(cmd, "'ITEMID'", toString(mItemId));
- replaceAll(cmd, "'ITEMCOLOR'", toString(toInt(mItemColor, int)));
- replaceAll(cmd, "'BEINGTYPEID'", toString(CAST_S32(mType)));
- replaceAll(cmd, "'BEINGSUBTYPEID'", toString(CAST_S32(mSubType)));
- replaceAll(cmd, "'PLAYER'", localPlayer->getName());
- replaceAll(cmd, "'EPLAYER'", escapeString(localPlayer->getName()));
- replaceAll(cmd, "'PLAYERX'", toString(localPlayer->getTileX()));
- replaceAll(cmd, "'PLAYERY'", toString(localPlayer->getTileY()));
- if (mItemIndex >= 0)
- replaceAll(cmd, "'INVINDEX'", toString(mItemIndex));
- else
- replaceAll(cmd, "'INVINDEX'", "0");
- if (mMapItem != nullptr)
- {
- replaceAll(cmd, "'MAPX'", toString(mMapItem->getX()));
- replaceAll(cmd, "'MAPY'", toString(mMapItem->getY()));
- }
- else
- {
- replaceAll(cmd, "'MAPX'", toString(mX));
- replaceAll(cmd, "'MAPY'", toString(mY));
- }
-
- std::string cards;
- for (int f = 0; f < maxCards; f ++)
- {
- const int id = mItemCards[f];
- if (id != 0)
- {
- cards.append(",");
- cards.append(toString(id));
- }
- }
- replaceAll(cmd, "'CARDS'", cards);
- replaceAll(cmd, "'ECARDS'", escapeString(cards));
- if (actorManager != nullptr)
- {
- if (being == nullptr)
- {
- being = actorManager->findBeingByName(mName,
- ActorType::Player);
- }
- }
- if (being != nullptr)
- replaceAll(cmd, "'PARTY'", being->getPartyName());
- else
- replaceAll(cmd, "'PARTY'", "");
-
- const size_t pos = cmd.find(' ');
- const std::string type(cmd, 0, pos);
- std::string args(cmd, pos == std::string::npos ? cmd.size() : pos + 1);
- args = trim(args);
- inputManager.executeChatCommand(type, args, mTab);
- }
- // Unknown actions
- else if (link != "cancel")
- {
- reportAlways("PopupMenu: Warning, unknown action '%s'", link.c_str());
- }
-
- if (!mAllowCleanMenu)
- return;
-
- setVisible(Visible_false);
-
- mBeingId = BeingId_zero;
- mFloorItemId = BeingId_zero;
- mItemId = 0;
- mItemIndex = -1;
- for (int f = 0; f < maxCards; f ++)
- mItemCards[f] = 0;
- mItemColor = ItemColor_one;
- mMapItem = nullptr;
- mTab = nullptr;
- mSpell = nullptr;
- mCallerWindow = nullptr;
- mDialog = nullptr;
- mButton = nullptr;
- mName.clear();
- mExtName.clear();
- mTextField = nullptr;
- mType = ActorType::Unknown;
- mSubType = BeingTypeId_zero;
- mX = 0;
- mY = 0;
-}
-
-void PopupMenu::showPopup(Window *const parent,
- const int x, const int y,
- const Item *const item,
- const InventoryTypeT type)
-{
- if (item == nullptr)
- return;
-
- initPopup();
- mItemId = item->getId();
- mItemIndex = item->getInvIndex();
- for (int f = 0; f < maxCards; f ++)
- mItemCards[f] = item->getCard(f);
- mItemColor = item->getColor();
- mCallerWindow = parent;
- mX = x;
- mY = y;
- mName.clear();
- mExtName.clear();
- mBrowserBox->clearRows();
-
- const int cnt = item->getQuantity();
- const bool isProtected = PlayerInfo::isItemProtected(mItemId);
-
- switch (type)
- {
- case InventoryType::Inventory:
- if (tradeWindow != nullptr &&
- tradeWindow->isWindowVisible() &&
- !isProtected)
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: add item to trade
- mBrowserBox->addRow("/addtrade 'INVINDEX'", _("Add to trade"));
- if (cnt > 1)
- {
- if (cnt > 10)
- {
- mBrowserBox->addRow("/addtrade 'INVINDEX' 10",
- // TRANSLATORS: popup menu item
- // TRANSLATORS: add 10 item amount to trade
- _("Add to trade 10"));
- }
- mBrowserBox->addRow("/addtrade 'INVINDEX' /",
- // TRANSLATORS: popup menu item
- // TRANSLATORS: add half item amount to trade
- _("Add to trade half"));
- mBrowserBox->addRow("/addtrade 'INVINDEX' -1",
- // TRANSLATORS: popup menu item
- // TRANSLATORS: add all amount except one item to trade
- _("Add to trade all-1"));
- mBrowserBox->addRow("/addtrade 'INVINDEX' all",
- // TRANSLATORS: popup menu item
- // TRANSLATORS: add all amount item to trade
- _("Add to trade all"));
- }
- mBrowserBox->addSeparator("##3---");
- }
- if (InventoryWindow::isStorageActive())
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: add item to storage
- mBrowserBox->addRow("/invtostorage 'INVINDEX'", _("Store"));
- if (cnt > 1)
- {
- if (cnt > 10)
- {
- mBrowserBox->addRow("/invtostorage 'INVINDEX' 10",
- // TRANSLATORS: popup menu item
- // TRANSLATORS: add 10 item amount to storage
- _("Store 10"));
- }
- mBrowserBox->addRow("/invtostorage 'INVINDEX' /",
- // TRANSLATORS: popup menu item
- // TRANSLATORS: add half item amount to storage
- _("Store half"));
- mBrowserBox->addRow("/invtostorage 'INVINDEX' -1",
- // TRANSLATORS: popup menu item
- // TRANSLATORS: add all except one item to storage
- _("Store all-1"));
- mBrowserBox->addRow("/invtostorage 'INVINDEX' all",
- // TRANSLATORS: popup menu item
- // TRANSLATORS: add all item amount to storage
- _("Store all"));
- }
- mBrowserBox->addSeparator("##3---");
- }
- if (npcHandler != nullptr)
- {
- NpcDialog *const dialog = npcHandler->getCurrentNpcDialog();
- if ((dialog != nullptr) &&
- dialog->getInputState() == NpcInputState::ITEM_CRAFT)
- {
- mBrowserBox->addRow("craftmenu",
- // TRANSLATORS: popup menu item
- // TRANSLATORS: sub menu for craft
- _("Move to craft..."));
- }
- }
- addItemMenu(item, InventoryType::Inventory);
- addDrop(item, isProtected);
- break;
-
- case InventoryType::Storage:
- // TRANSLATORS: popup menu item
- // TRANSLATORS: get item from storage
- mBrowserBox->addRow("/storagetoinv 'INVINDEX'", _("Retrieve"));
- if (cnt > 1)
- {
- if (cnt > 10)
- {
- mBrowserBox->addRow("/storagetoinv 'INVINDEX' 10",
- // TRANSLATORS: popup menu item
- // TRANSLATORS: get 10 item amount from storage
- _("Retrieve 10"));
- }
- mBrowserBox->addRow("/storagetoinv 'INVINDEX' /",
- // TRANSLATORS: popup menu item
- // TRANSLATORS: get half item amount from storage
- _("Retrieve half"));
- mBrowserBox->addRow("/storagetoinv 'INVINDEX' -1",
- // TRANSLATORS: popup menu item
- // TRANSLATORS: get all except one item amount from storage
- _("Retrieve all-1"));
- mBrowserBox->addRow("/storagetoinv 'INVINDEX' all",
- // TRANSLATORS: popup menu item
- // TRANSLATORS: get all item amount from storage
- _("Retrieve all"));
- mBrowserBox->addSeparator("##3---");
- }
- addItemMenu(item, InventoryType::Storage);
- break;
- case InventoryType::Cart:
- addItemMenu(item, InventoryType::Cart);
- break;
-
- case InventoryType::Trade:
- case InventoryType::Npc:
- case InventoryType::Vending:
- case InventoryType::MailEdit:
- case InventoryType::MailView:
- case InventoryType::Craft:
- case InventoryType::TypeEnd:
- default:
- break;
- }
-
-
- addProtection();
- if (config.getBoolValue("enablePickupFilter"))
- {
- mName = item->getName();
- mExtName = mName;
- mBrowserBox->addSeparator("##3---");
- addPickupFilter(mName);
- }
- addGmCommands();
- // TRANSLATORS: popup menu item
- // TRANSLATORS: add item name to chat
- mBrowserBox->addRow("/addchat 'ITEMID''CARDS'", _("Add to chat"));
- mBrowserBox->addSeparator("##3---");
- // TRANSLATORS: popup menu item
- // TRANSLATORS: close menu
- mBrowserBox->addRow("cancel", _("Cancel"));
-
- showPopup(x, y);
-}
-
-void PopupMenu::showItemPopup(const int x, const int y,
- const int itemId,
- const ItemColor color)
-{
- const Inventory *const inv = PlayerInfo::getInventory();
- if (inv == nullptr)
- return;
-
- Item *const item = inv->findItem(itemId, color);
- if (item != nullptr)
- {
- showItemPopup(x, y, item);
- }
- else
- {
- initPopup();
- mItemId = itemId;
- mItemIndex = -1;
- mItemColor = color;
- for (int f = 0; f < maxCards; f ++)
- mItemCards[f] = 0;
- mX = x;
- mY = y;
- mBrowserBox->clearRows();
-
- if (!PlayerInfo::isItemProtected(mItemId))
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: use item
- mBrowserBox->addRow("/use 'ITEMID'", _("Use"));
- }
- addProtection();
- addGmCommands();
- mBrowserBox->addSeparator("##3---");
- // TRANSLATORS: popup menu item
- // TRANSLATORS: close menu
- mBrowserBox->addRow("cancel", _("Cancel"));
-
- showPopup(x, y);
- }
-}
-
-void PopupMenu::showItemPopup(const int x, const int y,
- const Item *const item)
-{
- initPopup();
- mX = x;
- mY = y;
- if (item != nullptr)
- {
- mItemId = item->getId();
- mItemColor = item->getColor();
- mItemIndex = item->getInvIndex();
- for (int f = 0; f < maxCards; f ++)
- mItemCards[f] = item->getCard(f);
- }
- else
- {
- mItemId = 0;
- mItemColor = ItemColor_one;
- mItemIndex = -1;
- for (int f = 0; f < maxCards; f ++)
- mItemCards[f] = 0;
- }
- mName.clear();
- mExtName.clear();
- mBrowserBox->clearRows();
-
- if (item != nullptr)
- {
- const bool isProtected = PlayerInfo::isItemProtected(mItemId);
- addUse(item);
- addDrop(item, isProtected);
- if (InventoryWindow::isStorageActive())
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: add item to storage
- mBrowserBox->addRow("/invtostorage 'INVINDEX'", _("Store"));
- }
- // TRANSLATORS: popup menu item
- // TRANSLATORS: add item name to chat
- mBrowserBox->addRow("/addchat 'ITEMID''CARDS'", _("Add to chat"));
-
- if (config.getBoolValue("enablePickupFilter"))
- {
- mName = item->getName();
- mExtName = mName;
- mBrowserBox->addSeparator("##3---");
- addPickupFilter(mName);
- }
- }
- addProtection();
- addGmCommands();
- mBrowserBox->addSeparator("##3---");
- // TRANSLATORS: popup menu item
- // TRANSLATORS: close menu
- mBrowserBox->addRow("cancel", _("Cancel"));
-
- showPopup(x, y);
-}
-
-void PopupMenu::showDropPopup(const int x,
- const int y,
- const Item *const item)
-{
- initPopup();
- mX = x;
- mY = y;
- mName.clear();
- mExtName.clear();
- mBrowserBox->clearRows();
-
- if (item != nullptr)
- {
- mItemId = item->getId();
- mItemColor = item->getColor();
- mItemIndex = item->getInvIndex();
- for (int f = 0; f < maxCards; f ++)
- mItemCards[f] = item->getCard(f);
- const bool isProtected = PlayerInfo::isItemProtected(mItemId);
- addUse(item);
- addDrop(item, isProtected);
- if (InventoryWindow::isStorageActive())
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: add item to storage
- mBrowserBox->addRow("/invtostorage 'INVINDEX'", _("Store"));
- }
- addProtection();
- // TRANSLATORS: popup menu item
- // TRANSLATORS: add item name to chat
- mBrowserBox->addRow("/addchat 'ITEMID''CARDS'", _("Add to chat"));
- if (config.getBoolValue("enablePickupFilter"))
- {
- mName = item->getName();
- mExtName = mName;
- mBrowserBox->addSeparator("##3---");
- addPickupFilter(mName);
- }
- }
- addGmCommands();
- mBrowserBox->addSeparator("##3---");
- // TRANSLATORS: popup menu item
- mBrowserBox->addRow("/cleardrops", _("Clear drop window"));
- mBrowserBox->addSeparator("##3---");
- // TRANSLATORS: popup menu item
- // TRANSLATORS: close menu
- mBrowserBox->addRow("cancel", _("Cancel"));
-
- showPopup(x, y);
-}
-
-void PopupMenu::showPopup(const int x, const int y, Button *const button)
-{
- if ((button == nullptr) || (windowMenu == nullptr))
- return;
-
- initPopup();
- mButton = button;
- mX = x;
- mY = y;
-
- mBrowserBox->clearRows();
- STD_VECTOR<Button *> names = windowMenu->getButtons();
- for (STD_VECTOR<Button *>::const_iterator it = names.begin(),
- it_end = names.end(); it != it_end; ++ it)
- {
- const Button *const btn = *it;
- if ((btn == nullptr) || btn->getActionEventId() == "SET")
- continue;
-
- if (btn->mVisible == Visible_true)
- {
- mBrowserBox->addRow(strprintf("@@hide button_%s|%s %s (%s)@@",
- // TRANSLATORS: popup menu item
- btn->getActionEventId().c_str(), _("Hide"),
- btn->getDescription().c_str(), btn->getCaption().c_str()));
- }
- else
- {
- mBrowserBox->addRow(strprintf("@@show button_%s|%s %s (%s)@@",
- // TRANSLATORS: popup menu item
- btn->getActionEventId().c_str(), _("Show"),
- btn->getDescription().c_str(), btn->getCaption().c_str()));
- }
- }
- mBrowserBox->addSeparator("##3---");
- // TRANSLATORS: popup menu item
- // TRANSLATORS: close menu
- mBrowserBox->addRow("cancel", _("Cancel"));
-
- showPopup(x, y);
-}
-
-void PopupMenu::showPopup(const int x, const int y, const ProgressBar *const b)
-{
- if ((b == nullptr) || (miniStatusWindow == nullptr))
- return;
-
- initPopup();
- mName = b->text();
- mExtName = mName;
- mX = x;
- mY = y;
-
- mBrowserBox->clearRows();
- STD_VECTOR <ProgressBar*> bars = miniStatusWindow->getBars();
- ProgressBar *onlyBar = nullptr;
- int cnt = 0;
-
- // search for alone visible bar
- for (STD_VECTOR <ProgressBar*>::const_iterator it = bars.begin(),
- it_end = bars.end(); it != it_end; ++it)
- {
- ProgressBar *const bar = *it;
- if (bar == nullptr)
- continue;
-
- if (bar->mVisible == Visible_true)
- {
- cnt ++;
- onlyBar = bar;
- }
- }
- if (cnt > 1)
- onlyBar = nullptr;
-
- for (STD_VECTOR <ProgressBar*>::const_iterator it = bars.begin(),
- it_end = bars.end(); it != it_end; ++it)
- {
- ProgressBar *const bar = *it;
- if ((bar == nullptr) || bar == onlyBar)
- continue;
-
- if (bar->mVisible == Visible_true)
- {
- mBrowserBox->addRow(strprintf("@@hide bar_%s|%s %s@@",
- // TRANSLATORS: popup menu item
- bar->getActionEventId().c_str(), _("Hide"),
- bar->getId().c_str()));
- }
- else
- {
- mBrowserBox->addRow(strprintf("@@show bar_%s|%s %s@@",
- // TRANSLATORS: popup menu item
- bar->getActionEventId().c_str(), _("Show"),
- bar->getId().c_str()));
- }
- }
-
- mBrowserBox->addSeparator("##3---");
- // TRANSLATORS: popup menu item
- mBrowserBox->addRow("/yellowbar", _("Open yellow bar settings"));
- // TRANSLATORS: popup menu item
- mBrowserBox->addRow("/resetmodifiers", _("Reset yellow bar"));
- mBrowserBox->addSeparator("##3---");
- // TRANSLATORS: popup menu item
- // TRANSLATORS: copy status to chat
- mBrowserBox->addRow("/bartochat 'NAME'", _("Copy to chat"));
- // TRANSLATORS: popup menu item
- // TRANSLATORS: close menu
- mBrowserBox->addRow("cancel", _("Cancel"));
-
- showPopup(x, y);
-}
-
-void PopupMenu::showAttackMonsterPopup(const int x, const int y,
- const std::string &name,
- const int type)
-{
- if ((localPlayer == nullptr) || (actorManager == nullptr))
- return;
-
- initPopup();
- mName = name;
- mExtName = name;
- mType = ActorType::Monster;
- mSubType = BeingTypeId_zero;
- mX = x;
- mY = y;
-
- mBrowserBox->clearRows();
-
- if (name.empty())
- {
- // TRANSLATORS: popup menu header
- mBrowserBox->addRow(_("(default)"));
- }
- else
- {
- mBrowserBox->addRow(name);
- }
- switch (type)
- {
- case MapItemType::ATTACK:
- {
- const int idx = actorManager->getAttackMobIndex(name);
- const int size = actorManager->getAttackMobsSize();
- if (idx > 0)
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: move attack target up
- mBrowserBox->addRow("/moveattackup 'NAME'", _("Move up"));
- }
- if (idx + 1 < size)
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: move attack target down
- mBrowserBox->addRow("/moveattackdown 'NAME'", _("Move down"));
- }
- break;
- }
- case MapItemType::PRIORITY:
- {
- const int idx = actorManager->
- getPriorityAttackMobIndex(name);
- const int size = actorManager->getPriorityAttackMobsSize();
- if (idx > 0)
- {
- mBrowserBox->addRow("/movepriorityattackup 'NAME'",
- // TRANSLATORS: popup menu item
- // TRANSLATORS: move attack target up
- _("Move up"));
- }
- if (idx + 1 < size)
- {
- mBrowserBox->addRow("/movepriorityattackdown 'NAME'",
- // TRANSLATORS: popup menu item
- // TRANSLATORS: move attack target down
- _("Move down"));
- }
- break;
- }
- case MapItemType::IGNORE_:
- break;
- default:
- break;
- }
-
- // TRANSLATORS: popup menu item
- // TRANSLATORS: remove attack target
- mBrowserBox->addRow("/removeattack 'NAME'", _("Remove"));
- mBrowserBox->addSeparator("##3---");
- // TRANSLATORS: popup menu item
- // TRANSLATORS: close menu
- mBrowserBox->addRow("cancel", _("Cancel"));
-
- showPopup(x, y);
-}
-
-void PopupMenu::showPickupItemPopup(const int x, const int y,
- const std::string &name)
-{
- if ((localPlayer == nullptr) || (actorManager == nullptr))
- return;
-
- initPopup();
- mName = name;
- mExtName = name;
- mType = ActorType::FloorItem;
- mSubType = BeingTypeId_zero;
- mX = x;
- mY = y;
-
- mBrowserBox->clearRows();
-
- if (name.empty())
- {
- // TRANSLATORS: popup menu header
- mBrowserBox->addRow(_("(default)"));
- }
- else
- {
- mBrowserBox->addRow(name);
- }
-
- // TRANSLATORS: popup menu item
- // TRANSLATORS: remove item from pickup filter
- mBrowserBox->addRow("/removepickup 'NAME'", _("Remove"));
- mBrowserBox->addSeparator("##3---");
- // TRANSLATORS: popup menu item
- // TRANSLATORS: close menu
- mBrowserBox->addRow("cancel", _("Cancel"));
-
- showPopup(x, y);
-}
-
-void PopupMenu::showUndressPopup(const int x, const int y,
- const Being *const being,
- const Item *const item)
-{
- if ((being == nullptr) || (item == nullptr))
- return;
-
- initPopup();
- mBeingId = being->getId();
- mItemId = item->getId();
- mItemColor = item->getColor();
- mItemIndex = item->getInvIndex();
- for (int f = 0; f < maxCards; f ++)
- mItemCards[f] = item->getCard(f);
- mX = x;
- mY = y;
-
- mBrowserBox->clearRows();
-
- // TRANSLATORS: popup menu item
- // TRANSLATORS: undress item from player
- mBrowserBox->addRow("/undress :'BEINGID' 'ITEMID'", _("Undress"));
- // TRANSLATORS: popup menu item
- // TRANSLATORS: add item name to chat
- mBrowserBox->addRow("/addchat 'ITEMID''CARDS'", _("Add to chat"));
- addGmCommands();
- mBrowserBox->addSeparator("##3---");
- // TRANSLATORS: popup menu item
- // TRANSLATORS: close menu
- mBrowserBox->addRow("cancel", _("Cancel"));
-
- showPopup(x, y);
-}
-
-void PopupMenu::showTextFieldPopup(TextField *const input)
-{
- initPopup();
- setMousePos();
- mTextField = input;
-
- mBrowserBox->clearRows();
-
- // TRANSLATORS: popup menu item
- // TRANSLATORS: copy text to clipboard
- mBrowserBox->addRow("clipboard copy", _("Copy"));
- // TRANSLATORS: popup menu item
- // TRANSLATORS: paste text from clipboard
- mBrowserBox->addRow("clipboard paste", _("Paste"));
- mBrowserBox->addSeparator("##3---");
- // TRANSLATORS: popup menu item
- // TRANSLATORS: close menu
- mBrowserBox->addRow("cancel", _("Cancel"));
-
- showPopup(mX, mY);
-}
-
-void PopupMenu::showLinkPopup(const std::string &link)
-{
- initPopup();
- setMousePos();
- mName = link;
- mExtName = link;
-
- mBrowserBox->clearRows();
-
- // TRANSLATORS: popup menu item
- // TRANSLATORS: open link in browser
- mBrowserBox->addRow("/open 'NAME'", _("Open link"));
- // TRANSLATORS: popup menu item
- // TRANSLATORS: copy link to clipboard
- mBrowserBox->addRow("/clipboardcopy 'NAME'", _("Copy to clipboard"));
- mBrowserBox->addSeparator("##3---");
- // TRANSLATORS: popup menu item
- // TRANSLATORS: close menu
- mBrowserBox->addRow("cancel", _("Cancel"));
-
- showPopup(mX, mY);
-}
-
-void PopupMenu::showWindowsPopup()
-{
- initPopup();
- setMousePos();
- mBrowserBox->clearRows();
- const STD_VECTOR<ButtonText*> &names = windowMenu->getButtonTexts();
- // TRANSLATORS: popup menu header
- mBrowserBox->addRow(_("Show window"));
-
- FOR_EACH (STD_VECTOR<ButtonText*>::const_iterator, it, names)
- {
- const ButtonText *const btn = *it;
- if (btn == nullptr)
- continue;
-
- mBrowserBox->addRow(strprintf("show window_%d",
- CAST_S32(btn->key)),
- btn->text.c_str());
- }
- mBrowserBox->addSeparator("##3---");
- // TRANSLATORS: popup menu item
- // TRANSLATORS: close menu
- mBrowserBox->addRow("cancel", _("Cancel"));
-
- showPopup(mX, mY);
-}
-
-void PopupMenu::showNpcDialogPopup(const BeingId npcId,
- const int x, const int y)
-{
- initPopup();
- mBeingId = npcId;
- mX = x;
- mY = y;
- mBrowserBox->clearRows();
- // TRANSLATORS: popup menu item
- // TRANSLATORS: copy npc text to clipboard
- mBrowserBox->addRow("/npcclipboard 'X' 'Y'", _("Copy to clipboard"));
- mBrowserBox->addSeparator("##3---");
- // TRANSLATORS: popup menu item
- // TRANSLATORS: close menu
- mBrowserBox->addRow("cancel", _("Cancel"));
-
- showPopup(x, y);
-}
-
-void PopupMenu::showSkillPopup(const SkillInfo *const info)
-{
- if (info == nullptr)
- return;
-
- initPopup();
- setMousePos();
-
- // using mItemId as skill id
- mItemId = info->id;
- // using mItemIndex as skill level
- mItemIndex = info->level;
- mBrowserBox->clearRows();
-
- // TRANSLATORS: popup menu header
- mBrowserBox->addRow(_("Skill"));
- mBrowserBox->addRow("/addskillshortcut 'ITEMID'",
- // TRANSLATORS: popup menu item
- // TRANSLATORS: add skill to shortcurs tab
- _("Add skill shortcut"));
- mBrowserBox->addSeparator("##3---");
- mBrowserBox->addRow("/showskilllevels 'ITEMID'",
- // TRANSLATORS: popup menu item
- // TRANSLATORS: set skill level
- _("Skill level..."));
- mBrowserBox->addRow("/showskilltypes 'ITEMID'",
- // TRANSLATORS: popup menu item
- // TRANSLATORS: set skill cast type
- _("Skill cast type..."));
- mBrowserBox->addRow("/showskilloffsetx 'ITEMID'",
- // TRANSLATORS: popup menu item
- // TRANSLATORS: set skill cast offset by x
- _("Skill offset by x..."));
- mBrowserBox->addRow("/showskilloffsety 'ITEMID'",
- // TRANSLATORS: popup menu item
- // TRANSLATORS: set skill cast offset by y
- _("Skill offset by y..."));
- // TRANSLATORS: popup menu item
- // TRANSLATORS: close menu
- mBrowserBox->addRow("cancel", _("Cancel"));
-
- showPopup(mX, mY);
-}
-
-void PopupMenu::showSkillOffsetPopup(const SkillInfo *const info,
- const bool isOffsetX)
-{
- if (info == nullptr)
- return;
-
- initPopup();
- setMousePos2();
-
- // using mItemId as skill id
- mItemId = info->id;
- // using mItemIndex as skill level
- mItemIndex = info->level;
- mBrowserBox->clearRows();
- char letter = ' ';
-
- if (isOffsetX)
- {
- // TRANSLATORS: popup menu header
- mBrowserBox->addRow(_("Skill cast offset by x"));
- letter = 'x';
- }
- else
- {
- // TRANSLATORS: popup menu header
- mBrowserBox->addRow(_("Skill cast offset by y"));
- letter = 'y';
- }
- for (int f = -9; f <= 9; f ++)
- {
- const std::string command = strprintf(
- "/setskilloffset%c 'ITEMID' %d", letter, f);
- if (f == 0)
- {
- mBrowserBox->addRow(command,
- strprintf("%d", f).c_str());
- }
- else
- {
- mBrowserBox->addRow(command,
- strprintf("%+d", f).c_str());
- }
- }
- // TRANSLATORS: popup menu item
- // TRANSLATORS: close menu
- mBrowserBox->addRow("cancel", _("Cancel"));
- showPopup(mX, mY);
-}
-
-void PopupMenu::showSkillLevelPopup(const SkillInfo *const info)
-{
- if (info == nullptr)
- return;
-
- initPopup();
- setMousePos2();
-
- // using mItemId as skill id
- mItemId = info->id;
- // using mItemIndex as skill level
- mItemIndex = info->level;
-
- for (int f = 0; f < maxCards; f ++)
- mItemCards[f] = 0;
- mBrowserBox->clearRows();
- // TRANSLATORS: popup menu item
- // TRANSLATORS: skill level header
- mBrowserBox->addRow(_("Select skill level"));
- for (int f = 1; f <= mItemIndex; f ++)
- {
- mBrowserBox->addRow(strprintf("/selectskilllevel %d %d", mItemId, f),
- // TRANSLATORS: popup menu item
- // TRANSLATORS: skill level
- strprintf(_("Level: %d"), f).c_str());
- }
- mBrowserBox->addRow(strprintf("/selectskilllevel %d 0", mItemId),
- // TRANSLATORS: popup menu item
- // TRANSLATORS: skill level
- _("Max level"));
- mBrowserBox->addSeparator("##3---");
- // TRANSLATORS: popup menu item
- // TRANSLATORS: close menu
- mBrowserBox->addRow("cancel", _("Cancel"));
-
- showPopup(mX, mY);
-}
-
-void PopupMenu::showSkillTypePopup(const SkillInfo *const info)
-{
- if (info == nullptr)
- return;
-
- initPopup();
- setMousePos2();
-
- // using mItemId as skill id
- mItemId = info->id;
- // using mItemIndex as skill level
- mItemIndex = info->level;
-
- for (int f = 0; f < maxCards; f ++)
- mItemCards[f] = 0;
- mBrowserBox->clearRows();
-
- // TRANSLATORS: popup menu item
- // TRANSLATORS: skill cast type header
- mBrowserBox->addRow(_("Select skill cast type"));
- mBrowserBox->addRow(strprintf("/selectskilltype %d 0", mItemId),
- // TRANSLATORS: popup menu item
- // TRANSLATORS: skill cast type
- _("Default"));
- mBrowserBox->addRow(strprintf("/selectskilltype %d 1", mItemId),
- // TRANSLATORS: popup menu item
- // TRANSLATORS: skill cast type
- _("Target"));
- mBrowserBox->addRow(strprintf("/selectskilltype %d 2", mItemId),
- // TRANSLATORS: popup menu item
- // TRANSLATORS: skill cast type
- _("Mouse position"));
- mBrowserBox->addRow(strprintf("/selectskilltype %d 3", mItemId),
- // TRANSLATORS: popup menu item
- // TRANSLATORS: skill cast type
- _("Self"));
- mBrowserBox->addSeparator("##3---");
- // TRANSLATORS: popup menu item
- // TRANSLATORS: close menu
- mBrowserBox->addRow("cancel", _("Cancel"));
-
- showPopup(mX, mY);
-}
-
-void PopupMenu::showPopup(int x, int y)
-{
- PopupManager::hideItemPopup();
- const int pad2 = 2 * mPadding;
- mBrowserBox->setPosition(mPadding, mPadding);
- mScrollArea->setPosition(mPadding, mPadding);
- mBrowserBox->updateHeight();
- // add padding to initial size before draw browserbox
- int height = mBrowserBox->getHeight();
- if (height + pad2 >= mainGraphics->getHeight())
- {
- height = mainGraphics->getHeight() - pad2;
- mBrowserBox->setWidth(mBrowserBox->getWidth() + 5);
- mScrollArea->setWidth(mBrowserBox->getWidth() + pad2 + 10);
- setContentSize(mBrowserBox->getWidth() + pad2 + 20,
- height + pad2);
- }
- else
- {
- mBrowserBox->setWidth(mBrowserBox->getWidth());
- mScrollArea->setWidth(mBrowserBox->getWidth() + pad2);
- setContentSize(mBrowserBox->getWidth() + pad2,
- height + pad2);
- }
- if (mainGraphics->mWidth < (x + getWidth() + 5))
- x = mainGraphics->mWidth - getWidth();
- if (mainGraphics->mHeight < (y + getHeight() + 5))
- y = mainGraphics->mHeight - getHeight();
- mScrollArea->setHeight(height);
- setPosition(x, y);
- setVisible(Visible_true);
- requestMoveToTop();
- mAllowCleanMenu = false;
-}
-
-void PopupMenu::addNormalRelations()
-{
- // TRANSLATORS: popup menu item
- // TRANSLATORS: add player to disregarded list
- mBrowserBox->addRow("/disregard 'NAME'", _("Disregard"));
- // TRANSLATORS: popup menu item
- // TRANSLATORS: add player to ignore list
- mBrowserBox->addRow("/ignore 'NAME'", _("Ignore"));
- // TRANSLATORS: popup menu item
- // TRANSLATORS: add player to black list
- mBrowserBox->addRow("/blacklist 'NAME'", _("Black list"));
- // TRANSLATORS: popup menu item
- // TRANSLATORS: add player to enemy list
- mBrowserBox->addRow("/enemy 'NAME'", _("Set as enemy"));
- // TRANSLATORS: popup menu item
- // TRANSLATORS: add player to erased list
- mBrowserBox->addRow("/erase 'NAME'", _("Erase"));
-}
-
-void PopupMenu::addPlayerRelation(const std::string &name)
-{
- switch (playerRelations.getRelation(name))
- {
- case Relation::NEUTRAL:
- // TRANSLATORS: popup menu item
- // TRANSLATORS: add player to friends list
- mBrowserBox->addRow("/friend 'NAME'", _("Be friend"));
- addNormalRelations();
- break;
-
- case Relation::FRIEND:
- addNormalRelations();
- break;
-
- case Relation::BLACKLISTED:
- // TRANSLATORS: popup menu item
- // TRANSLATORS: remove player from ignore list
- mBrowserBox->addRow("/unignore 'NAME'", _("Unignore"));
- // TRANSLATORS: popup menu item
- // TRANSLATORS: add player to disregarded list
- mBrowserBox->addRow("/disregard 'NAME'", _("Disregard"));
- // TRANSLATORS: popup menu item
- // TRANSLATORS: add player to ignore list
- mBrowserBox->addRow("/ignore 'NAME'", _("Ignore"));
- // TRANSLATORS: popup menu item
- // TRANSLATORS: add player to enemy list
- mBrowserBox->addRow("/enemy 'NAME'", _("Set as enemy"));
- // TRANSLATORS: popup menu item
- // TRANSLATORS: add player to erased list
- mBrowserBox->addRow("/erase 'NAME'", _("Erase"));
- break;
-
- case Relation::DISREGARDED:
- // TRANSLATORS: popup menu item
- // TRANSLATORS: remove player from ignore list
- mBrowserBox->addRow("/unignore 'NAME'", _("Unignore"));
- // TRANSLATORS: popup menu item
- // TRANSLATORS: add player to completle ignore list
- mBrowserBox->addRow("/ignore 'NAME'", _("Completely ignore"));
- // TRANSLATORS: popup menu item
- // TRANSLATORS: add player to erased list
- mBrowserBox->addRow("/erase 'NAME'", _("Erase"));
- break;
-
- case Relation::IGNORED:
- // TRANSLATORS: popup menu item
- // TRANSLATORS: remove player from ignore list
- mBrowserBox->addRow("/unignore 'NAME'", _("Unignore"));
- // TRANSLATORS: popup menu item
- // TRANSLATORS: add player to erased list
- mBrowserBox->addRow("/erase 'NAME'", _("Erase"));
- break;
-
- case Relation::ENEMY2:
- // TRANSLATORS: popup menu item
- // TRANSLATORS: remove player from ignore list
- mBrowserBox->addRow("/unignore 'NAME'", _("Unignore"));
- // TRANSLATORS: popup menu item
- // TRANSLATORS: add player to disregarded list
- mBrowserBox->addRow("/disregard 'NAME'", _("Disregard"));
- // TRANSLATORS: popup menu item
- // TRANSLATORS: add player to ignore list
- mBrowserBox->addRow("/ignore 'NAME'", _("Ignore"));
- // TRANSLATORS: popup menu item
- // TRANSLATORS: add player to black list
- mBrowserBox->addRow("/blacklist 'NAME'", _("Black list"));
- // TRANSLATORS: popup menu item
- // TRANSLATORS: add player to erased list
- mBrowserBox->addRow("/erase 'NAME'", _("Erase"));
- break;
-
- case Relation::ERASED:
- // TRANSLATORS: popup menu item
- // TRANSLATORS: remove player from ignore list
- mBrowserBox->addRow("/unignore 'NAME'", _("Unignore"));
- // TRANSLATORS: popup menu item
- // TRANSLATORS: add player to disregarded list
- mBrowserBox->addRow("/disregard 'NAME'", _("Disregard"));
- // TRANSLATORS: popup menu item
- // TRANSLATORS: add player to ignore list
- mBrowserBox->addRow("/ignore 'NAME'", _("Completely ignore"));
- break;
-
- default:
- break;
- }
-}
-
-void PopupMenu::addFollow()
-{
- if (features.getBoolValue("allowFollow"))
- {
- // TRANSLATORS: popup menu item
- mBrowserBox->addRow("/follow 'NAME'", _("Follow"));
- }
- // TRANSLATORS: popup menu item
- // TRANSLATORS: imitate player
- mBrowserBox->addRow("/imitation 'NAME'", _("Imitate"));
-}
-
-void PopupMenu::addBuySell(const Being *const being)
-{
- if ((playerRelations.getDefault() & PlayerRelation::TRADE) != 0u)
- {
- mBrowserBox->addSeparator("##3---");
- const bool haveVending =
- (Net::getNetworkType() != ServerType::TMWATHENA);
- if (being->isSellShopEnabled())
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: buy item
- mBrowserBox->addRow("/buy 'NAME'", _("Buy"));
- }
- else if (!haveVending)
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: buy item
- mBrowserBox->addRow("/buy 'NAME'", _("Buy (?)"));
- }
- if (being->isBuyShopEnabled())
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: sell item
- mBrowserBox->addRow("/sell 'NAME'", _("Sell"));
- }
- else if (!haveVending)
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: sell item
- mBrowserBox->addRow("/sell 'NAME'", _("Sell (?)"));
- }
- }
-}
-
-void PopupMenu::addBuySellDefault()
-{
- if ((playerRelations.getDefault() & PlayerRelation::TRADE) != 0u)
- {
- mBrowserBox->addSeparator("##3---");
- // TRANSLATORS: popup menu item
- // TRANSLATORS: buy item
- mBrowserBox->addRow("/buy 'NAME'", _("Buy (?)"));
- // TRANSLATORS: popup menu item
- // TRANSLATORS: sell item
- mBrowserBox->addRow("/sell 'NAME'", _("Sell (?)"));
- }
-}
-
-void PopupMenu::addPartyName(const std::string &partyName)
-{
- if (localPlayer->isInParty())
- {
- if (localPlayer->getParty() != nullptr)
- {
- if (localPlayer->getParty()->getName() != partyName)
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: invite player to party
- mBrowserBox->addRow("/party 'NAME'", _("Invite to party"));
- }
- else
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: kick player from party
- mBrowserBox->addRow("/kickparty 'NAME'", _("Kick from party"));
- showAdoptCommands();
- }
- mBrowserBox->addSeparator("##3---");
- }
- }
-}
-
-void PopupMenu::addParty(const std::string &nick)
-{
- if (localPlayer->isInParty())
- {
- const Party *const party = localPlayer->getParty();
- if (party != nullptr)
- {
- if (!party->isMember(nick))
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: invite player to party
- mBrowserBox->addRow("/party 'NAME'", _("Invite to party"));
- }
- else
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: kick player from party
- mBrowserBox->addRow("/kickparty 'NAME'", _("Kick from party"));
- showAdoptCommands();
- }
- mBrowserBox->addSeparator("##3---");
- }
- }
-}
-
-void PopupMenu::addChat(const Being *const being)
-{
- if (being == nullptr)
- return;
- const ChatObject *const chat = being->getChat();
- if (chat != nullptr)
- {
- mBrowserBox->addRow("join chat",
- // TRANSLATORS: popup menu item
- // TRANSLATORS: invite player to party
- strprintf(_("Join chat %s"), chat->title.c_str()).c_str());
- mBrowserBox->addSeparator("##3---");
- }
-}
-
-void PopupMenu::addPlayerMisc()
-{
- // TRANSLATORS: popup menu item
- mBrowserBox->addRow("/showitems :'BEINGID'", _("Show Items"));
- // TRANSLATORS: popup menu item
- // TRANSLATORS: undress player
- mBrowserBox->addRow("/undress :'BEINGID'", _("Undress"));
- // TRANSLATORS: popup menu item
- // TRANSLATORS: add comment to player
- mBrowserBox->addRow("addcomment", _("Add comment"));
-}
-
-void PopupMenu::addPickupFilter(const std::string &name)
-{
- if (actorManager->isInPickupList(name)
- || actorManager->isInIgnorePickupList(name))
- {
- mBrowserBox->addRow("/removepickup 'NAME'",
- // TRANSLATORS: popup menu item
- // TRANSLATORS: remove item from pickup list
- _("Remove from pickup list"));
- }
- else
- {
- mBrowserBox->addRow("/addpickup 'NAME'",
- // TRANSLATORS: popup menu item
- // TRANSLATORS: popup menu item
- _("Add to pickup list"));
- mBrowserBox->addRow("/ignorepickup 'NAME'",
- // TRANSLATORS: popup menu item
- // TRANSLATORS: add item to pickup list
- _("Add to ignore list"));
- }
-}
-
-void PopupMenu::showPopup(const int x, const int y,
- ListModel *const model)
-{
- if (model == nullptr)
- return;
-
- mBrowserBox->clearRows();
- for (int f = 0, sz = model->getNumberOfElements(); f < sz; f ++)
- {
- mBrowserBox->addRow(strprintf("dropdown_%d", f),
- model->getElementAt(f).c_str());
- }
- // TRANSLATORS: popup menu item
- // TRANSLATORS: close menu
- mBrowserBox->addRow("cancel", _("Cancel"));
- showPopup(x, y);
-}
-
-void PopupMenu::clear()
-{
- if (mDialog != nullptr)
- {
- mDialog->close();
- mDialog = nullptr;
- }
- mItemIndex = -1;
- mItemId = 0;
- for (int f = 0; f < maxCards; f ++)
- mItemCards[f] = 0;
- mMapItem = nullptr;
- mTab = nullptr;
- mSpell = nullptr;
- mCallerWindow = nullptr;
- mButton = nullptr;
- mTextField = nullptr;
-}
-
-void PopupMenu::addProtection()
-{
- if (PlayerInfo::isItemProtected(mItemId))
- {
- mBrowserBox->addSeparator("##3---");
- // TRANSLATORS: popup menu item
- // TRANSLATORS: remove protection from item
- mBrowserBox->addRow("/unprotectitem 'ITEMID'", _("Unprotect item"));
- }
- else
- {
- if (mItemId < SPELL_MIN_ID)
- {
- mBrowserBox->addSeparator("##3---");
- // TRANSLATORS: popup menu item
- // TRANSLATORS: add protection to item
- mBrowserBox->addRow("/protectitem 'ITEMID'", _("Protect item"));
- }
- }
-}
-
-void PopupMenu::addUse(const Item *const item)
-{
- const ItemInfo &info = item->getInfo();
- const std::string &str = (item->isEquipment() == Equipm_true
- && item->isEquipped() == Equipped_true)
- ? info.getUseButton2() : info.getUseButton();
-
- if (str.empty())
- {
- // TRANSLATORS: popup menu item
- mBrowserBox->addRow("/useinv 'INVINDEX'", _("Use"));
- }
- else
- {
- // TRANSLATORS: popup menu item
- mBrowserBox->addRow("/useinv 'INVINDEX'", str.c_str());
- }
-}
-
-void PopupMenu::addItemMenu(const Item *const item,
- const InventoryTypeT type)
-{
- const ItemInfo &info = item->getInfo();
- const STD_VECTOR<ItemMenuItem> *menu = nullptr;
- switch (type)
- {
- case InventoryType::Inventory:
- menu = &info.getInventoryMenuConst();
- break;
- case InventoryType::Storage:
- menu = &info.getStorageMenuConst();
- break;
- case InventoryType::Cart:
- menu = &info.getCartMenuConst();
- break;
- case InventoryType::Trade:
- case InventoryType::Npc:
- case InventoryType::Vending:
- case InventoryType::MailEdit:
- case InventoryType::MailView:
- case InventoryType::Craft:
- case InventoryType::TypeEnd:
- default:
- return;
- }
-
- const bool firstMode = (item->isEquipment() == Equipm_true ?
- (item->isEquipped() != Equipped_true) : (item->getQuantity() == 1));
-
- FOR_EACHP (STD_VECTOR<ItemMenuItem>::const_iterator, it, menu)
- {
- const ItemMenuItem &menuItem = *it;
- const std::string &name = firstMode ?
- menuItem.name1 : menuItem.name2;
- const std::string &command = firstMode ?
- menuItem.command1 : menuItem.command2;
- if (command.empty() ||
- name.empty())
- {
- continue;
- }
- mBrowserBox->addRow("/" + command, name.c_str());
- }
- mBrowserBox->addSeparator("##3---");
-}
-
-void PopupMenu::addDrop(const Item *const item,
- const bool isProtected)
-{
- if (!isProtected)
- {
- mBrowserBox->addSeparator("##3---");
- if (item->getQuantity() > 1)
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: drop item
- mBrowserBox->addRow("/dropinv 'INVINDEX'", _("Drop..."));
- // TRANSLATORS: popup menu item
- // TRANSLATORS: drop all item amount
- mBrowserBox->addRow("/dropinvall 'INVINDEX'", _("Drop all"));
- }
- else
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: drop item
- mBrowserBox->addRow("/dropinv 'INVINDEX'", _("Drop"));
- }
- }
-}
-
-void PopupMenu::addGmCommands()
-{
- if (localPlayer->isGM())
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: gm commands
- mBrowserBox->addRow("gm", _("GM..."));
- }
-}
-
-void PopupMenu::showPlayerMenu()
-{
- mBrowserBox->clearRows();
- // TRANSLATORS: popup menu header
- mBrowserBox->addRow(strprintf(_("Show %s"),
- mName.c_str()));
- if (isAllowCommand(ServerCommandType::accinfo))
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: show player account info
- mBrowserBox->addRow("/showaccountinfo 'NAME'", _("Account info"));
- }
- if (isAllowOtherCommand(ServerCommandType::exp))
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: show player level
- mBrowserBox->addRow("/showlevel 'NAME'", _("Level"));
- }
- if (isAllowOtherCommand(ServerCommandType::stats))
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: show player stats
- mBrowserBox->addRow("/showstats 'NAME'", _("Stats"));
- }
- if (isAllowOtherCommand(ServerCommandType::itemlist))
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: show player inventory list
- mBrowserBox->addRow("/showinventory 'NAME'", _("Inventory"));
- }
- if (isAllowOtherCommand(ServerCommandType::storagelist))
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: show player storage list
- mBrowserBox->addRow("/showstorage 'NAME'", _("Storage"));
- }
- if (isAllowOtherCommand(ServerCommandType::cartlist))
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: show player cart list
- mBrowserBox->addRow("/showcart 'NAME'", _("Cart"));
- }
- if (isAllowOtherCommand(ServerCommandType::commands))
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: gm commands
- mBrowserBox->addRow("/gmcommands 'NAME'", _("Commands"));
- }
- if (isAllowOtherCommand(ServerCommandType::charcommands))
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: gm char commands
- mBrowserBox->addRow("/gmcharcommands 'NAME'", _("Char commands"));
- }
- // TRANSLATORS: popup menu item
- // TRANSLATORS: back to gm menu
- mBrowserBox->addRow("gm", _("Back"));
- // TRANSLATORS: popup menu item
- // TRANSLATORS: close menu
- mBrowserBox->addRow("cancel", _("Cancel"));
- showPopup(getX(), getY());
-}
-
-void PopupMenu::showPlayerGMCommands(const std::string &name)
-{
- if (localPlayer == nullptr)
- return;
- const bool legacy = Net::getNetworkType() == ServerType::TMWATHENA;
- if (!legacy && isAllowCommand(ServerCommandType::where))
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: find player position
- mBrowserBox->addRow("/locateplayer 'NAME'", _("Locate"));
- }
- if (legacy)
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: check player ip
- mBrowserBox->addRow("/ipcheck 'NAME'", _("Check ip"));
- }
- if (isAllowCommand(ServerCommandType::jumpto))
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: go to player position
- mBrowserBox->addRow("/gotopc 'NAME'", _("Goto"));
- }
- if (isAllowCommand(ServerCommandType::recall))
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: recall player to current position
- mBrowserBox->addRow("/recallpc 'NAME'", _("Recall"));
- }
- if (isAllowOtherCommand(ServerCommandType::alive))
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: revive player
- mBrowserBox->addRow("/alive 'NAME'", _("Revive"));
- }
- if (!legacy)
- {
- Being *const being = actorManager->findBeingByName(name,
- ActorType::Player);
- if (being != nullptr && being == localPlayer)
- {
- if (!being->getPartyName().empty() &&
- isAllowCommand(ServerCommandType::partyrecall))
- {
- mBrowserBox->addRow("/partyrecall 'PARTY'",
- // TRANSLATORS: popup menu item
- // TRANSLATORS: recall all party members to player location
- _("Recall party"));
- }
- if (!being->getGuildName().empty() &&
- isAllowCommand(ServerCommandType::guildrecall))
- {
- mBrowserBox->addRow("/guildrecall 'PARTY'",
- // TRANSLATORS: popup menu item
- // TRANSLATORS: recall all guild members to player location
- _("Recall guild"));
- }
- }
- if (localPlayer->isInParty())
- {
- const Party *const party = localPlayer->getParty();
- if (party != nullptr &&
- party->isMember(name) &&
- isAllowCommand(ServerCommandType::changeleader))
- {
- mBrowserBox->addRow("/gmpartyleader 'NAME'",
- // TRANSLATORS: popup menu item
- // TRANSLATORS: give party leader status
- _("Give party leader"));
- }
- }
-
- if (isAllowCommand(ServerCommandType::nuke))
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: nuke player
- mBrowserBox->addRow("/gmnuke 'NAME'", _("Nuke"));
- }
- if (isAllowOtherCommand(ServerCommandType::kill))
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: kill player
- mBrowserBox->addRow("/kill 'NAME'", _("Kill"));
- }
- if (mBeingId != BeingId_zero)
- {
- mBrowserBox->addSeparator("##3---");
- // TRANSLATORS: popup menu item
- // TRANSLATORS: show menu
- mBrowserBox->addRow("show", _("Show..."));
- // TRANSLATORS: popup menu item
- // TRANSLATORS: mute menu
- mBrowserBox->addRow("mute", _("Mute..."));
- }
- }
- if (legacy)
- {
- if (localPlayer->getName() == mName)
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: hide player
- mBrowserBox->addRow("/hide", _("Hide"));
- mBrowserBox->addSeparator("##3---");
- }
- }
- else
- {
- if (isAllowOtherCommand(ServerCommandType::heal))
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: heal player
- mBrowserBox->addRow("/gmheal 'NAME'", _("Heal"));
- }
- if (isAllowOtherCommand(ServerCommandType::monsterignore))
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: enable immortal mode for player
- mBrowserBox->addRow("/immortal 'NAME'", _("Immortal"));
- }
- if (isAllowCommand(ServerCommandType::jail))
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: send player to jail
- mBrowserBox->addRow("/jail 'NAME'", _("Jail"));
- }
- if (isAllowCommand(ServerCommandType::unjail))
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: restore player from jail
- mBrowserBox->addRow("/unjail 'NAME'", _("Unjail"));
- }
- if (name == localPlayer->getName() &&
- isAllowCommand(ServerCommandType::hide))
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: hide player
- mBrowserBox->addRow("/hide 'NAME'", _("Hide"));
- }
- mBrowserBox->addSeparator("##3---");
- if (isAllowOtherCommand(ServerCommandType::killer))
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: set player as killer
- mBrowserBox->addRow("/killer 'NAME'", _("Killer"));
- }
- if (isAllowOtherCommand(ServerCommandType::killable))
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: set player as killable
- mBrowserBox->addRow("/killable 'NAME'", _("Killable"));
- }
- if (isAllowOtherCommand(ServerCommandType::save))
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: set player save position
- mBrowserBox->addRow("/savepos 'NAME'", _("Set save"));
- }
- if (isAllowOtherCommand(ServerCommandType::load))
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: warp player to save position
- mBrowserBox->addRow("/loadpos 'NAME'", _("Warp to save"));
- }
- if (isAllowOtherCommand(ServerCommandType::jump))
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: warp player to random position on same map
- mBrowserBox->addRow("/randomwarp 'NAME'", _("Warp to random"));
- }
- mBrowserBox->addSeparator("##3---");
- if (isAllowCommand(ServerCommandType::clone))
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: spawn player clone
- mBrowserBox->addRow("/spawnclone 'NAME'", _("Spawn clone"));
- }
- if (isAllowCommand(ServerCommandType::slaveclone))
- {
- mBrowserBox->addRow("/spawnslaveclone 'NAME'",
- // TRANSLATORS: popup menu item
- // TRANSLATORS: spawn slave player clone
- _("Spawn slave clone"));
- }
- if (isAllowCommand(ServerCommandType::evilclone))
- {
- mBrowserBox->addRow("/spawnevilclone 'NAME'",
- // TRANSLATORS: popup menu item
- // TRANSLATORS: spawn evil player clone
- _("Spawn evil clone"));
- }
- mBrowserBox->addSeparator("##3---");
- if (isAllowOtherCommand(ServerCommandType::breakguild))
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: break guild
- mBrowserBox->addRow("/gmbreakguild 'NAME'", _("Break guild"));
- }
- }
- if (mBeingId != BeingId_zero &&
- isAllowCommand(ServerCommandType::kick))
- {
- mBrowserBox->addSeparator("##3---");
- // TRANSLATORS: popup menu item
- // TRANSLATORS: kick player
- mBrowserBox->addRow("/kick :'BEINGID'", _("Kick"));
- }
-}
-
-void PopupMenu::showMuteCommands()
-{
- mBrowserBox->clearRows();
- // TRANSLATORS: popup menu header
- mBrowserBox->addRow(strprintf(_("Mute %s"),
- mName.c_str()));
- if (mBeingId != BeingId_zero &&
- Net::getNetworkType() != ServerType::TMWATHENA &&
- isAllowCommand(ServerCommandType::mute))
- {
- mBrowserBox->addRow("mute_+1",
- // TRANSLATORS: popup menu item
- // TRANSLATORS: mute player
- strprintf(_("Mute %d"), 1).c_str());
- mBrowserBox->addRow("mute_+5",
- // TRANSLATORS: popup menu item
- // TRANSLATORS: mute player
- strprintf(_("Mute %d"), 5).c_str());
- mBrowserBox->addRow("mute_+10",
- // TRANSLATORS: popup menu item
- // TRANSLATORS: mute player
- strprintf(_("Mute %d"), 10).c_str());
- mBrowserBox->addRow("mute_+15",
- // TRANSLATORS: popup menu item
- // TRANSLATORS: mute player
- strprintf(_("Mute %d"), 15).c_str());
- mBrowserBox->addRow("mute_+30",
- // TRANSLATORS: popup menu item
- // TRANSLATORS: mute player
- strprintf(_("Mute %d"), 30).c_str());
-
- mBrowserBox->addRow("mute_-1",
- // TRANSLATORS: popup menu item
- // TRANSLATORS: mute player
- strprintf(_("Unmute %d"), 1).c_str());
- mBrowserBox->addRow("mute_-5",
- // TRANSLATORS: popup menu item
- // TRANSLATORS: mute player
- strprintf(_("Unmute %d"), 5).c_str());
- mBrowserBox->addRow("mute_-10",
- // TRANSLATORS: popup menu item
- // TRANSLATORS: mute player
- strprintf(_("Unmute %d"), 10).c_str());
- mBrowserBox->addRow("mute_-15",
- // TRANSLATORS: popup menu item
- // TRANSLATORS: mute player
- strprintf(_("Unmute %d"), 15).c_str());
- mBrowserBox->addRow("mute_-30",
- // TRANSLATORS: popup menu item
- // TRANSLATORS: mute player
- strprintf(_("Unmute %d"), 30).c_str());
- mBrowserBox->addSeparator("##3---");
- }
- // TRANSLATORS: popup menu item
- // TRANSLATORS: back to gm menu
- mBrowserBox->addRow("gm", _("Back"));
- // TRANSLATORS: popup menu item
- // TRANSLATORS: close menu
- mBrowserBox->addRow("cancel", _("Cancel"));
- showPopup(getX(), getY());
-}
-
-void PopupMenu::showNpcGMCommands()
-{
- if (mBeingId != BeingId_zero)
- {
- if (isAllowCommand(ServerCommandType::kick))
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: kick player
- mBrowserBox->addRow("/kick :'BEINGID'", _("Kick"));
- }
- const bool legacy = Net::getNetworkType() == ServerType::TMWATHENA;
- if (!legacy)
- {
- if (isAllowCommand(ServerCommandType::hidenpc))
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: hide npc
- mBrowserBox->addRow("/hidenpc 'EXTNAME'", _("Hide"));
- }
- mBrowserBox->addSeparator("##3---");
- if (isAllowCommand(ServerCommandType::npcmove))
- {
- mBrowserBox->addRow("/npcmove 'EEXTNAME' 'PLAYERX' 'PLAYERY'",
- // TRANSLATORS: popup menu item
- // TRANSLATORS: warp npc to player location
- _("Recall"));
- }
- if (isAllowCommand(ServerCommandType::disguise))
- {
- mBrowserBox->addRow("/disguise 'BEINGSUBTYPEID'",
- // TRANSLATORS: popup menu item
- // TRANSLATORS: disguise to npc
- _("Disguise"));
- }
- if (isAllowCommand(ServerCommandType::tonpc))
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: warp to npc
- mBrowserBox->addRow("/gotonpc 'EXTNAME'", _("Goto"));
- }
- }
- }
-}
-
-void PopupMenu::showMonsterGMCommands()
-{
- if (mBeingId != BeingId_zero)
- {
- const bool legacy = Net::getNetworkType() == ServerType::TMWATHENA;
- if (isAllowCommand(ServerCommandType::kick))
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: kick monster
- mBrowserBox->addRow("/kick :'BEINGID'", _("Kick"));
- }
- if (isAllowCommand(ServerCommandType::monster))
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: spawn monster
- mBrowserBox->addRow("/spawn 'BEINGSUBTYPEID'", _("Spawn same"));
- }
- if (!legacy)
- {
- if (isAllowCommand(ServerCommandType::summon))
- {
- mBrowserBox->addRow("/spawnslave 'BEINGSUBTYPEID'",
- // TRANSLATORS: popup menu item
- // TRANSLATORS: spawn slave monster
- _("Spawn slave"));
- }
- if (isAllowCommand(ServerCommandType::disguise))
- {
- mBrowserBox->addRow("/disguise 'BEINGSUBTYPEID'",
- // TRANSLATORS: popup menu item
- // TRANSLATORS: disguise to monster
- _("Disguise"));
- }
- mBrowserBox->addSeparator("##3---");
- if (isAllowCommand(ServerCommandType::mobinfo))
- {
- mBrowserBox->addRow("/monsterinfo 'BEINGSUBTYPEID'",
- // TRANSLATORS: popup menu item
- // TRANSLATORS: show monster information
- _("Info"));
- }
- if (isAllowCommand(ServerCommandType::mobsearch))
- {
- mBrowserBox->addRow("/mobsearch 'BEINGSUBTYPEID'",
- // TRANSLATORS: popup menu item
- // TRANSLATORS: show selected monster in current map
- _("Search"));
- }
- if (isAllowCommand(ServerCommandType::whereis))
- {
- mBrowserBox->addRow("/mobspawnsearch 'BEINGSUBTYPEID'",
- // TRANSLATORS: popup menu item
- // TRANSLATORS: show selected monster spawns in all maps
- _("Search spawns"));
- }
- }
- }
-}
-
-void PopupMenu::showFloorItemGMCommands()
-{
- const bool legacy = Net::getNetworkType() == ServerType::TMWATHENA;
- if (legacy)
- return;
- if (isAllowCommand(ServerCommandType::iteminfo))
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: show item information
- mBrowserBox->addRow("/iteminfo 'ITEMID'", _("Info"));
- }
- if (isAllowCommand(ServerCommandType::whodrops))
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: show who drops item
- mBrowserBox->addRow("/whodrops 'ITEMID'", _("Who drops"));
- }
-}
-
-void PopupMenu::showItemGMCommands()
-{
- const bool legacy = Net::getNetworkType() == ServerType::TMWATHENA;
- if (legacy)
- return;
- if (isAllowCommand(ServerCommandType::iteminfo))
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: show item information
- mBrowserBox->addRow("/iteminfo 'ITEMID'", _("Info"));
- }
- if (isAllowCommand(ServerCommandType::whodrops))
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: show who drops item
- mBrowserBox->addRow("/whodrops 'ITEMID'", _("Who drops"));
- }
- mBrowserBox->addSeparator("##3---");
- if (isAllowCommand(ServerCommandType::item))
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: gm create item
- mBrowserBox->addRow("/createitem 'ITEMID' 1", _("Add 1"));
- // TRANSLATORS: popup menu item
- // TRANSLATORS: gm create item
- mBrowserBox->addRow("/createitem 'ITEMID' 5", _("Add 5"));
- // TRANSLATORS: popup menu item
- // TRANSLATORS: gm create item
- mBrowserBox->addRow("/createitem 'ITEMID' 10", _("Add 10"));
- // TRANSLATORS: popup menu item
- // TRANSLATORS: gm create item
- mBrowserBox->addRow("/createitem 'ITEMID' 100", _("Add 100"));
- // TRANSLATORS: popup menu item
- // TRANSLATORS: gm create item
- mBrowserBox->addRow("/createitem 'ITEMID' 1000", _("Add 1000"));
- // TRANSLATORS: popup menu item
- // TRANSLATORS: gm create item
- mBrowserBox->addRow("/createitem 'ITEMID' 10000", _("Add 10000"));
- }
-}
-
-void PopupMenu::showGMPopup(const std::string &name)
-{
- mBrowserBox->clearRows();
- // TRANSLATORS: popup menu header
- mBrowserBox->addRow(_("GM commands"));
- if (localPlayer->isGM())
- {
- switch (mType)
- {
- case ActorType::Player:
- showPlayerGMCommands(name);
- break;
- case ActorType::Npc:
- showNpcGMCommands();
- break;
- case ActorType::Monster:
- showMonsterGMCommands();
- break;
- case ActorType::FloorItem:
- showFloorItemGMCommands();
- break;
- case ActorType::Homunculus:
- showHomunGMCommands();
- break;
- case ActorType::Pet:
- showPetGMCommands();
- break;
- case ActorType::Mercenary:
- showMercenaryGMCommands();
- break;
- case ActorType::SkillUnit:
- break;
- default:
- case ActorType::Unknown:
- if (mItemId != 0)
- showItemGMCommands();
- break;
- case ActorType::Portal:
- case ActorType::Avatar:
- case ActorType::Elemental:
- break;
- }
- }
-
- mBrowserBox->addSeparator("##3---");
- // TRANSLATORS: popup menu item
- // TRANSLATORS: close menu
- mBrowserBox->addRow("cancel", _("Cancel"));
-
- showPopup(getX(), getY());
-}
-
-void PopupMenu::showHomunGMCommands()
-{
-}
-
-void PopupMenu::showPetGMCommands()
-{
-}
-
-void PopupMenu::showMercenaryGMCommands()
-{
-}
-
-void PopupMenu::showCraftPopup()
-{
- mBrowserBox->clearRows();
-
- for (int f = 0; f < 9; f ++)
- {
- const std::string cmd = strprintf("/craft %d", f);
- mBrowserBox->addRow(cmd,
- // TRANSLATORS: popup menu item
- // TRANSLATORS: move current item to craft slot
- strprintf(_("Move to craft %d"), f + 1).c_str());
- }
-
- // TRANSLATORS: popup menu item
- // TRANSLATORS: close menu
- mBrowserBox->addRow("cancel", _("Cancel"));
-
- showPopup(mX, mY);
-}
-
-void PopupMenu::addMailCommands()
-{
- if (Net::getNetworkType() == ServerType::TMWATHENA)
- return;
-
- // TRANSLATORS: popup menu item
- // TRANSLATORS: open mail dialog
- mBrowserBox->addRow("/mailto 'NAME'", _("Mail to..."));
-}
-
-void PopupMenu::addCatchPetCommands()
-{
- if (Net::getNetworkType() == ServerType::TMWATHENA)
- return;
- // TRANSLATORS: popup menu item
- // TRANSLATORS: catch pet command
- mBrowserBox->addRow("/catchpet :'BEINGID'", _("Taming pet"));
-}
-
-void PopupMenu::showAdoptCommands()
-{
- if (Net::getNetworkType() == ServerType::TMWATHENA)
- return;
- // TRANSLATORS: popup menu item
- // TRANSLATORS: adopt child command
- mBrowserBox->addRow("/adoptchild 'NAME'", _("Adopt child"));
-}
-
-void PopupMenu::addSocialMenu()
-{
- initPopup();
- mBrowserBox->clearRows();
- setMousePos();
- const Party *const party = localPlayer->getParty();
- if (party != nullptr)
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: leave party
- mBrowserBox->addRow("/leaveparty", _("Leave party"));
- }
- else
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: create party
- mBrowserBox->addRow("/createparty", _("Create party"));
- }
-
- if (Net::getNetworkType() != ServerType::TMWATHENA)
- {
- const Guild *const guild = localPlayer->getGuild();
- if (guild != nullptr)
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: leave guild
- mBrowserBox->addRow("/leaveguild", _("Leave guild"));
- }
- else
- {
- // TRANSLATORS: popup menu item
- // TRANSLATORS: create guild
- mBrowserBox->addRow("/createguild", _("Create guild"));
- }
- }
- mBrowserBox->addSeparator("##3---");
-}
-
-void PopupMenu::showPartyPopup()
-{
- addSocialMenu();
-
- // TRANSLATORS: popup menu item
- // TRANSLATORS: close menu
- mBrowserBox->addRow("cancel", _("Cancel"));
- showPopup(mX, mY);
-}
-
-void PopupMenu::showGuildPopup()
-{
- addSocialMenu();
-
- // TRANSLATORS: popup menu item
- // TRANSLATORS: change guild notice message
- mBrowserBox->addRow("/guildnotice", _("Change notice"));
-
- // TRANSLATORS: popup menu item
- // TRANSLATORS: close menu
- mBrowserBox->addRow("cancel", _("Cancel"));
- showPopup(mX, mY);
-}
-
-void PopupMenu::showAttackPopup()
-{
- addSocialMenu();
-
- // TRANSLATORS: popup menu item
- // TRANSLATORS: close menu
- mBrowserBox->addRow("cancel", _("Cancel"));
- showPopup(mX, mY);
-}
-
-void PopupMenu::showNavigationPopup()
-{
- addSocialMenu();
-
- // TRANSLATORS: popup menu item
- // TRANSLATORS: close menu
- mBrowserBox->addRow("cancel", _("Cancel"));
- showPopup(mX, mY);
-}
-
-void PopupMenu::showPickupPopup()
-{
- addSocialMenu();
-
- // TRANSLATORS: popup menu item
- // TRANSLATORS: close menu
- mBrowserBox->addRow("cancel", _("Cancel"));
- showPopup(mX, mY);
-}
-
-void PopupMenu::showPlayersPopup()
-{
- addSocialMenu();
-
- // TRANSLATORS: popup menu item
- // TRANSLATORS: close menu
- mBrowserBox->addRow("cancel", _("Cancel"));
- showPopup(mX, mY);
-}
-
-void PopupMenu::showFriendsPopup()
-{
- addSocialMenu();
-
- // TRANSLATORS: popup menu item
- // TRANSLATORS: close menu
- mBrowserBox->addRow("cancel", _("Cancel"));
- showPopup(mX, mY);
-}
-
-void PopupMenu::moveUp()
-{
- mBrowserBox->moveSelectionUp();
-}
-
-void PopupMenu::moveDown()
-{
- mBrowserBox->moveSelectionDown();
-}
-
-void PopupMenu::select()
-{
- mBrowserBox->selectSelection();
-}
diff --git a/src/gui/popups/popupmenu.h b/src/gui/popups/popupmenu.h
deleted file mode 100644
index 5b554e197..000000000
--- a/src/gui/popups/popupmenu.h
+++ /dev/null
@@ -1,321 +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_POPUPS_POPUPMENU_H
-#define GUI_POPUPS_POPUPMENU_H
-
-#ifndef DYECMD
-
-#include "const/resources/item/cards.h"
-
-#include "enums/inventorytype.h"
-
-#include "enums/resources/servercommandtype.h"
-
-#include "enums/simpletypes/beingid.h"
-#include "enums/simpletypes/beingtypeid.h"
-#include "enums/simpletypes/itemcolor.h"
-
-#include "gui/widgets/linkhandler.h"
-#include "gui/widgets/popup.h"
-
-#include "listeners/playerlistener.h"
-#include "listeners/renamelistener.h"
-
-#include "localconsts.h"
-
-class ActorSprite;
-class Being;
-class Button;
-class ChatTab;
-class FloorItem;
-class Item;
-class ListModel;
-class MapItem;
-class ProgressBar;
-class ScrollArea;
-class StaticBrowserBox;
-class TextCommand;
-class TextDialog;
-class TextField;
-class Window;
-
-struct GroupInfo;
-struct SkillInfo;
-
-/**
- * Window showing popup menu.
- */
-class PopupMenu final : public Popup, public LinkHandler
-{
- public:
- /**
- * Constructor.
- */
- PopupMenu();
-
- A_DELETE_COPY(PopupMenu)
-
- void postInit() override final;
-
- /**
- * Shows the being related popup menu at the specified mouse coords.
- */
- void showPopup(const int x, const int y, const Being *const being);
-
- /**
- * Shows the beings related popup menu at the specified mouse coords.
- */
- void showPopup(const int x, const int y,
- const STD_VECTOR<ActorSprite*> &beings);
-
- void showPlayerPopup(const std::string &nick);
-
- /**
- * Shows the floor item related popup menu at the specified
- * mouse coords.
- */
- void showPopup(const int x, const int y,
- const FloorItem *const floorItem);
-
- /**
- * Shows the related popup menu when right click on the inventory
- * at the specified mouse coordinates.
- */
- void showPopup(Window *const parent,
- const int x, const int y,
- const Item *const item,
- const InventoryTypeT type);
-
- void showPopup(const int x, const int y, Button *const button);
-
- void showPopup(const int x, const int y, const ProgressBar *const bar);
-
- void showPopup(const int x, const int y, MapItem *const mapItem);
-
- void showItemPopup(const int x,
- const int y,
- const Item *const item);
-
- void showItemPopup(const int x, const int y,
- const int itemId,
- const ItemColor color);
-
- void showDropPopup(const int x,
- const int y,
- const Item *const item);
-
- void showOutfitsWindowPopup(const int x, const int y);
-
- void showSpellPopup(const int x, const int y, TextCommand *const cmd);
-
- void showAttackMonsterPopup(const int x, const int y,
- const std::string &name,
- const int type);
-
- void showPickupItemPopup(const int x, const int y,
- const std::string &name);
-
- void showUndressPopup(const int x, const int y,
- const Being *const being,
- const Item *const item);
-
- void showMapPopup(const int x, const int y,
- const int x2, const int y2,
- const bool isMinimap);
-
- /**
- * Shows the related popup menu when right click on the chat
- * at the specified mouse coordinates.
- */
- void showChatPopup(const int x, const int y, ChatTab *const tab);
-
- void showChangePos(const int x, const int y);
-
- void showPopup(const int x, const int y, ListModel *const model);
-
- void showTextFieldPopup(TextField *const input);
-
- void showLinkPopup(const std::string &link);
-
- void showWindowsPopup();
-
- void showNpcDialogPopup(const BeingId npcId,
- const int x, const int y);
-
- void showWindowPopup(Window *const window);
-
- void showSkillPopup(const SkillInfo *const info);
-
- void showSkillLevelPopup(const SkillInfo *const info);
-
- void showSkillTypePopup(const SkillInfo *const info);
-
- void showSkillOffsetPopup(const SkillInfo *const info,
- const bool isOffsetX);
-
- void showCraftPopup();
-
- void showEmoteType();
-
- void showPartyPopup();
-
- void showGuildPopup();
-
- void showAttackPopup();
-
- void showNavigationPopup();
-
- void showPickupPopup();
-
- void showPlayersPopup();
-
- void showFriendsPopup();
-
- /**
- * Handles link action.
- */
- void handleLink(const std::string &link,
- MouseEvent *event A_UNUSED) override final;
-
- void clear() override final;
-
- void moveUp();
-
- void moveDown();
-
- void select();
-
- private:
- void initPopup();
-
- bool isAllowCommand(const ServerCommandTypeT command);
-
- bool isAllowOtherCommand(const ServerCommandTypeT command);
-
- void setMousePos();
-
- void setMousePos2();
-
- void addPlayerRelation(const std::string &name);
-
- void addFollow();
-
- void addBuySell(const Being *const being) A_NONNULL(2);
-
- void addParty(const std::string &nick);
-
- void addPartyName(const std::string &partyName);
-
- void addBuySellDefault();
-
- void addPlayerMisc();
-
- void addPickupFilter(const std::string &name);
-
- void addProtection();
-
- void addUse(const Item *const item) A_NONNULL(2);
-
- void addItemMenu(const Item *const item,
- const InventoryTypeT type) A_NONNULL(2);
-
- void addDrop(const Item *const item,
- const bool isProtected) A_NONNULL(2);
-
- void addGmCommands();
-
- void showMuteCommands();
-
- void showPlayerMenu();
-
- void showFloorItemGMCommands();
-
- void showItemGMCommands();
-
- void addNormalRelations();
-
- void addWindowMenu(const Window *const window);
-
- void showHomunGMCommands();
-
- void showPetGMCommands();
-
- void showMercenaryGMCommands();
-
- void addChat(const Being *const being);
-
- void addMailCommands();
-
- void addCatchPetCommands();
-
- void showGMPopup(const std::string &name);
-
- void showPlayerGMCommands(const std::string &name);
-
- void showNpcGMCommands();
-
- void showMonsterGMCommands();
-
- void showAdoptCommands();
-
- void addSocialMenu();
-
- bool addBeingMenu();
-
- StaticBrowserBox *mBrowserBox A_NONNULLPOINTER;
- ScrollArea *mScrollArea A_NONNULLPOINTER;
-
- BeingId mBeingId;
- BeingId mFloorItemId;
- int mItemId;
- int mItemIndex;
- int mItemCards[maxCards];
- ItemColor mItemColor;
- MapItem *mMapItem;
- ChatTab *mTab;
- TextCommand *mSpell;
- Window *mCallerWindow;
- RenameListener mRenameListener;
- PlayerListener mPlayerListener;
- TextDialog *mDialog;
- Button *mButton;
- const GroupInfo *mGroup;
- std::string mName;
- std::string mExtName;
- TextField *mTextField;
- ActorTypeT mType;
- BeingTypeId mSubType;
- int mX;
- int mY;
- bool mAllowCleanMenu;
-
- /**
- * Shared code for the various showPopup functions.
- */
- void showPopup(int x, int y);
-};
-
-extern PopupMenu *popupMenu;
-
-#endif // DYE_CMD
-#endif // GUI_POPUPS_POPUPMENU_H
diff --git a/src/gui/popups/skillpopup.cpp b/src/gui/popups/skillpopup.cpp
deleted file mode 100644
index c2a583e30..000000000
--- a/src/gui/popups/skillpopup.cpp
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 The Legend of Mazzeroth Development Team
- * 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 "gui/popups/skillpopup.h"
-
-#include "gui/gui.h"
-
-#include "gui/fonts/font.h"
-
-#include "gui/widgets/label.h"
-#include "gui/widgets/textbox.h"
-
-#include "utils/gettext.h"
-#include "utils/stringutils.h"
-
-#include "resources/skill/skilldata.h"
-#include "resources/skill/skillinfo.h"
-
-#include "debug.h"
-
-SkillPopup *skillPopup = nullptr;
-
-SkillPopup::SkillPopup() :
- Popup("SkillPopup", "skillpopup.xml"),
- mSkillName(new Label(this)),
- mSkillDesc(new TextBox(this)),
- mSkillEffect(new TextBox(this)),
- mSkillLevel(new TextBox(this)),
- mSkillCastType(new TextBox(this)),
- mCastType(CastType::Default),
- mLastId(0U),
- mLastLevel(-1),
- mOffsetX(0),
- mOffsetY(0)
-{
- mSkillName->setFont(boldFont);
- mSkillName->setPosition(0, 0);
- mSkillName->setForegroundColorAll(getThemeColor(ThemeColorId::POPUP),
- getThemeColor(ThemeColorId::POPUP_OUTLINE));
-
- const int fontHeight = getFont()->getHeight();
-
- mSkillDesc->setEditable(false);
- mSkillDesc->setPosition(0, fontHeight);
- mSkillDesc->setForegroundColorAll(getThemeColor(ThemeColorId::POPUP),
- getThemeColor(ThemeColorId::POPUP_OUTLINE));
-
- mSkillEffect->setEditable(false);
- mSkillEffect->setPosition(0, 2 * fontHeight);
- mSkillEffect->setForegroundColorAll(getThemeColor(ThemeColorId::POPUP),
- getThemeColor(ThemeColorId::POPUP_OUTLINE));
-
- mSkillLevel->setEditable(false);
- mSkillLevel->setPosition(0, 3 * fontHeight);
- mSkillLevel->setForegroundColorAll(getThemeColor(ThemeColorId::POPUP),
- getThemeColor(ThemeColorId::POPUP_OUTLINE));
-
- mSkillCastType->setEditable(false);
- mSkillCastType->setPosition(0, 4 * fontHeight);
- mSkillCastType->setForegroundColorAll(getThemeColor(ThemeColorId::POPUP),
- getThemeColor(ThemeColorId::POPUP_OUTLINE));
-}
-
-void SkillPopup::postInit()
-{
- Popup::postInit();
- add(mSkillName);
- add(mSkillDesc);
- add(mSkillEffect);
- add(mSkillLevel);
- add(mSkillCastType);
-
- addMouseListener(this);
-}
-
-SkillPopup::~SkillPopup()
-{
-}
-
-void SkillPopup::show(const SkillInfo *const skill,
- const int level,
- const CastTypeT castType,
- const int offsetX,
- const int offsetY)
-{
- if ((skill == nullptr) ||
- (skill->data == nullptr) ||
- (skill->id == mLastId &&
- level == mLastLevel &&
- castType == mCastType &&
- offsetX == mOffsetX &&
- offsetY == mOffsetY))
- {
- return;
- }
-
- mLastId = skill->id;
- mLastLevel = level;
- mCastType = castType;
- mOffsetX = offsetX;
- mOffsetY = offsetY;
-
- mSkillName->setCaption(skill->data->dispName);
- mSkillName->adjustSize();
- mSkillName->setPosition(0, 0);
-
- std::string description = skill->data->description;
- std::string effect = skill->skillEffect;
- if (description.empty())
- {
- description = effect;
- effect.clear();
- }
- mSkillDesc->setTextWrapped(description, 196);
- mSkillEffect->setTextWrapped(effect, 196);
- if (level != 0)
- {
- mSkillLevel->setTextWrapped(strprintf(
- // TRANSLATORS: skill level
- _("Level: %d / %d"), level, skill->level),
- 196);
- }
- else
- {
- if (skill->level != 0)
- {
- mSkillLevel->setTextWrapped(strprintf(
- // TRANSLATORS: skill level
- _("Level: %d"), skill->level),
- 196);
- }
- else
- {
- mSkillLevel->setTextWrapped(
- // TRANSLATORS: skill level for tmw fake skills
- _("Level: Unknown"),
- 196);
- }
- }
- std::string castStr;
- switch (castType)
- {
- case CastType::Default:
- default:
- // TRANSLATORS: skill cast type
- castStr = _("Default");
- break;
- case CastType::Target:
- // TRANSLATORS: skill cast type
- castStr = _("Target");
- break;
- case CastType::Position:
- // TRANSLATORS: skill cast type
- castStr = _("Mouse position");
- break;
- case CastType::Self:
- // TRANSLATORS: skill cast type
- castStr = _("Self position");
- break;
- }
- if (offsetX != 0 ||
- offsetY != 0)
- {
- castStr.append(strprintf(" (%+d,%+d)",
- offsetX,
- offsetY));
- }
- mSkillCastType->setTextWrapped(strprintf(
- // TRANSLATORS: skill cast type
- _("Cast type: %s"),
- castStr.c_str()), 196);
-
- int minWidth = mSkillName->getWidth();
-
- if (mSkillName->getWidth() > minWidth)
- minWidth = mSkillName->getWidth();
- if (mSkillDesc->getMinWidth() > minWidth)
- minWidth = mSkillDesc->getMinWidth();
- if (mSkillEffect->getMinWidth() > minWidth)
- minWidth = mSkillEffect->getMinWidth();
- if (mSkillLevel->getMinWidth() > minWidth)
- minWidth = mSkillLevel->getMinWidth();
- if (mSkillCastType->getMinWidth() > minWidth)
- minWidth = mSkillCastType->getMinWidth();
-
- const int numRowsDesc = mSkillDesc->getNumberOfRows();
- const int numRowsEffect = mSkillEffect->getNumberOfRows();
- const int numRowsLevel = mSkillLevel->getNumberOfRows();
- const int numRowsCast = mSkillCastType->getNumberOfRows();
- const int height = getFont()->getHeight();
-
- if (skill->skillEffect.empty())
- {
- setContentSize(minWidth,
- (numRowsDesc + numRowsLevel + numRowsCast + 1) * height);
- mSkillLevel->setPosition(0, (numRowsDesc + 1) * height);
- mSkillCastType->setPosition(0, (numRowsDesc + 2) * height);
- }
- else
- {
- setContentSize(minWidth,
- (numRowsDesc + numRowsLevel + numRowsEffect + numRowsCast + 1) *
- height);
- mSkillEffect->setPosition(0, (numRowsDesc + 1) * height);
- mSkillLevel->setPosition(0,
- (numRowsDesc + numRowsEffect + 1) * height);
- mSkillCastType->setPosition(0,
- (numRowsDesc + numRowsEffect + 2) * height);
- }
-
- mSkillDesc->setPosition(0, 1 * height);
-}
-
-void SkillPopup::mouseMoved(MouseEvent &event)
-{
- Popup::mouseMoved(event);
-
- // When the mouse moved on top of the popup, hide it
- setVisible(Visible_false);
- mLastId = 0;
-}
-
-void SkillPopup::reset()
-{
- mLastId = 0;
- mLastLevel = 0;
- mCastType = CastType::Default;
- mOffsetX = 0;
- mOffsetY = 0;
-}
diff --git a/src/gui/popups/skillpopup.h b/src/gui/popups/skillpopup.h
deleted file mode 100644
index d62916ed0..000000000
--- a/src/gui/popups/skillpopup.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 The Legend of Mazzeroth Development Team
- * 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 GUI_POPUPS_SKILLPOPUP_H
-#define GUI_POPUPS_SKILLPOPUP_H
-
-#include "gui/widgets/popup.h"
-
-#include "enums/resources/skill/casttype.h"
-
-class Label;
-class TextBox;
-
-struct SkillInfo;
-
-/**
- * A popup that displays information about an item.
- */
-class SkillPopup final : public Popup
-{
- public:
- /**
- * Constructor. Initializes the skill popup.
- */
- SkillPopup();
-
- A_DELETE_COPY(SkillPopup)
-
- /**
- * Destructor. Cleans up the skill popup on deletion.
- */
- ~SkillPopup();
-
- void postInit() override final;
-
- /**
- * Sets the info to be displayed given a particular item.
- */
- void show(const SkillInfo *const skill,
- const int level,
- const CastTypeT type,
- const int offsetX,
- const int offsetY);
-
- void mouseMoved(MouseEvent &event) override final;
-
- void reset();
-
- private:
- Label *mSkillName A_NONNULLPOINTER;
- TextBox *mSkillDesc A_NONNULLPOINTER;
- TextBox *mSkillEffect A_NONNULLPOINTER;
- TextBox *mSkillLevel A_NONNULLPOINTER;
- TextBox *mSkillCastType A_NONNULLPOINTER;
- CastTypeT mCastType;
- unsigned int mLastId;
- int mLastLevel;
- int mOffsetX;
- int mOffsetY;
-};
-
-extern SkillPopup *skillPopup;
-
-#endif // GUI_POPUPS_SKILLPOPUP_H
diff --git a/src/gui/popups/speechbubble.cpp b/src/gui/popups/speechbubble.cpp
deleted file mode 100644
index 1ae67fb99..000000000
--- a/src/gui/popups/speechbubble.cpp
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 The Legend of Mazzeroth Development Team
- * 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 "gui/popups/speechbubble.h"
-
-#include "gui/gui.h"
-#include "gui/skin.h"
-#include "gui/viewport.h"
-
-#include "gui/fonts/font.h"
-
-#include "gui/widgets/label.h"
-#include "gui/widgets/staticbrowserbox.h"
-
-#include "debug.h"
-
-SpeechBubble::SpeechBubble() :
- Popup("Speech", "speechbubble.xml"),
- mText(),
- mSpacing(mSkin != nullptr ? mSkin->getOption("spacing") : 2),
- mCaption(new Label(this)),
- mSpeechBox(new StaticBrowserBox(this, Opaque_true,
- "speechbrowserbox.xml"))
-{
- setContentSize(140, 46);
- setMinWidth(8);
- setMinHeight(8);
-
- mCaption->setFont(boldFont);
- mSpeechBox->setOpaque(Opaque_false);
- mSpeechBox->setForegroundColorAll(getThemeColor(ThemeColorId::BUBBLE_TEXT),
- getThemeColor(ThemeColorId::BUBBLE_TEXT_OUTLINE));
-}
-
-void SpeechBubble::postInit()
-{
- Popup::postInit();
- add(mCaption);
- add(mSpeechBox);
-}
-
-void SpeechBubble::setCaption(const std::string &name,
- const Color *const color1,
- const Color *const color2)
-{
- mCaption->setCaption(name);
- mCaption->adjustSize();
- mCaption->setForegroundColorAll(*color1, *color2);
-}
-
-void SpeechBubble::setText(const std::string &text, const bool showName)
-{
- if (text == mText && (mCaption->getWidth() <= mSpeechBox->getWidth()))
- return;
-
- mSpeechBox->setForegroundColorAll(getThemeColor(ThemeColorId::BUBBLE_TEXT),
- getThemeColor(ThemeColorId::BUBBLE_TEXT_OUTLINE));
-
- int width = mCaption->getWidth();
- mSpeechBox->clearRows();
- mSpeechBox->addRow(text);
- mSpeechBox->updateHeight();
-
- const int speechWidth = mSpeechBox->getWidth();
- const int nameHeight = showName ? mCaption->getHeight() + mSpacing : 0;
-
- if (width < speechWidth)
- width = speechWidth;
-
- setContentSize(width, getFont()->getHeight() + nameHeight);
- mCaption->setPosition(0, 0);
- mSpeechBox->setPosition(0, nameHeight);
-}
-
-void SpeechBubble::requestMoveToBackground()
-{
- windowContainer->moveWidgetAfter(viewport, this);
-}
diff --git a/src/gui/popups/speechbubble.h b/src/gui/popups/speechbubble.h
deleted file mode 100644
index 694a6eb2a..000000000
--- a/src/gui/popups/speechbubble.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 The Legend of Mazzeroth Development Team
- * 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 GUI_POPUPS_SPEECHBUBBLE_H
-#define GUI_POPUPS_SPEECHBUBBLE_H
-
-#include "gui/widgets/popup.h"
-
-class Label;
-class StaticBrowserBox;
-
-class SpeechBubble final : public Popup
-{
- public:
- /**
- * Constructor. Initializes the speech bubble.
- */
- SpeechBubble();
-
- A_DELETE_COPY(SpeechBubble)
-
- void postInit() override final;
-
- /**
- * Sets the name displayed for the speech bubble, and in what color.
- */
- void setCaption(const std::string &name,
- const Color *const color1 = &theme->getColor(
- ThemeColorId::BUBBLE_NAME, 255),
- const Color *const color2 = &theme->getColor(
- ThemeColorId::BUBBLE_NAME_OUTLINE, 255));
-
- /**
- * Sets the text to be displayed.
- */
- void setText(const std::string &text, const bool showName = true);
-
- void requestMoveToBackground();
-
- private:
- std::string mText;
- int mSpacing;
- Label *mCaption A_NONNULLPOINTER;
- StaticBrowserBox *mSpeechBox A_NONNULLPOINTER;
-};
-
-#endif // GUI_POPUPS_SPEECHBUBBLE_H
diff --git a/src/gui/popups/spellpopup.cpp b/src/gui/popups/spellpopup.cpp
deleted file mode 100644
index 16169d81e..000000000
--- a/src/gui/popups/spellpopup.cpp
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 The Legend of Mazzeroth Development Team
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 Andrei Karas
- * 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 "gui/popups/spellpopup.h"
-
-#include "textcommand.h"
-
-#include "gui/gui.h"
-
-#include "gui/widgets/label.h"
-
-#include "debug.h"
-
-SpellPopup *spellPopup = nullptr;
-
-SpellPopup::SpellPopup() :
- Popup("SpellPopup", "spellpopup.xml"),
- mItemName(new Label(this)),
- mItemComment(new Label(this))
-{
- mItemName->setFont(boldFont);
- mItemName->setForegroundColorAll(getThemeColor(ThemeColorId::POPUP),
- getThemeColor(ThemeColorId::POPUP_OUTLINE));
- mItemComment->setForegroundColorAll(getThemeColor(ThemeColorId::POPUP),
- getThemeColor(ThemeColorId::POPUP_OUTLINE));
-}
-
-void SpellPopup::postInit()
-{
- Popup::postInit();
- add(mItemName);
- add(mItemComment);
-
- addMouseListener(this);
-}
-
-SpellPopup::~SpellPopup()
-{
-}
-
-void SpellPopup::setItem(const TextCommand *const spell)
-{
- if (spell != nullptr)
- {
- mItemName->setCaption(spell->getName());
- mItemComment->setCaption(spell->getComment());
- }
- else
- {
- mItemName->setCaption("?");
- mItemComment->setCaption("");
- }
-
- mItemName->adjustSize();
- mItemComment->adjustSize();
- int minWidth = mItemName->getWidth();
- if (mItemComment->getWidth() > minWidth)
- minWidth = mItemComment->getWidth();
-
- mItemName->setPosition(0, 0);
- const int fontHeight = mItemName->getHeight();
- mItemComment->setPosition(0, fontHeight);
- if (!mItemComment->getCaption().empty())
- setContentSize(minWidth, 2 * fontHeight);
- else
- setContentSize(minWidth, fontHeight);
-}
-
-void SpellPopup::view(const int x, const int y)
-{
- const int distance = 20;
-
- int posX = std::max(0, x - getWidth() / 2);
- int posY = y + distance;
-
- const Rect &rect = mDimension;
- const int w = rect.width;
- const int h = rect.height;
- if (posX + w > mainGraphics->mWidth)
- {
- if (mainGraphics->mWidth > w)
- posX = mainGraphics->mWidth - w;
- else
- posX = 0;
- }
- if (posY + h > mainGraphics->mHeight)
- {
- if (y > h + distance)
- posY = y - h - distance;
- }
-
- setPosition(posX, posY);
- setVisible(Visible_true);
- requestMoveToTop();
-}
-
-void SpellPopup::mouseMoved(MouseEvent &event)
-{
- Popup::mouseMoved(event);
-
- // When the mouse moved on top of the popup, hide it
- setVisible(Visible_false);
-}
diff --git a/src/gui/popups/spellpopup.h b/src/gui/popups/spellpopup.h
deleted file mode 100644
index 6b9d84238..000000000
--- a/src/gui/popups/spellpopup.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 The Legend of Mazzeroth Development Team
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 Andrei Karas
- * 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_POPUPS_SPELLPOPUP_H
-#define GUI_POPUPS_SPELLPOPUP_H
-
-#include "gui/widgets/popup.h"
-
-class Label;
-class TextCommand;
-
-/**
- * A popup that displays information about an item.
- */
-class SpellPopup final : public Popup
-{
- public:
- /**
- * Constructor. Initializes the item popup.
- */
- SpellPopup();
-
- A_DELETE_COPY(SpellPopup)
-
- /**
- * Destructor. Cleans up the item popup on deletion.
- */
- ~SpellPopup();
-
- void postInit() override final;
-
- /**
- * Sets the info to be displayed given a particular item.
- */
- void setItem(const TextCommand *const spell);
-
- /**
- * Sets the location to display the item popup.
- */
- void view(const int x, const int y);
-
- void mouseMoved(MouseEvent &event) override final;
-
- private:
- Label *mItemName A_NONNULLPOINTER;
- Label *mItemComment A_NONNULLPOINTER;
-};
-
-extern SpellPopup *spellPopup;
-
-#endif // GUI_POPUPS_SPELLPOPUP_H
diff --git a/src/gui/popups/statuspopup.cpp b/src/gui/popups/statuspopup.cpp
deleted file mode 100644
index 544a37b56..000000000
--- a/src/gui/popups/statuspopup.cpp
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 The Legend of Mazzeroth Development Team
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 Andrei Karas
- * 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 "gui/popups/statuspopup.h"
-
-#include "gamemodifiers.h"
-
-#include "gui/widgets/label.h"
-
-#include "input/inputmanager.h"
-
-#include "utils/stringutils.h"
-
-#include "gui/fonts/font.h"
-
-#include "debug.h"
-
-#define addLabel(num) \
- { \
- Label *const label = mLabels[num]; \
- label->setPosition(0, y); \
- label->setForegroundColorAll(getThemeColor(ThemeColorId::POPUP), \
- getThemeColor(ThemeColorId::POPUP_OUTLINE)); \
- add(label); \
- y += fontHeight; \
- }
-
-StatusPopup::StatusPopup() :
- Popup("StatusPopup", "statuspopup.xml"),
- mLabels()
-{
- for (int f = 0; f < STATUSPOPUP_NUM_LABELS; f ++)
- mLabels[f] = new Label(this);
-}
-
-void StatusPopup::postInit()
-{
- Popup::postInit();
- const int fontHeight = getFont()->getHeight();
- int y = 0;
- addLabel(0);
- addLabel(1);
- addLabel(2);
- addLabel(3);
- y += 4;
- addLabel(4);
- addLabel(5);
- addLabel(9);
- addLabel(10);
- y += 4;
- addLabel(6);
- addLabel(7);
- y += 4;
- addLabel(8);
- y += 4;
- addLabel(12);
- addLabel(13);
- addLabel(14);
- addLabel(15);
- y += 4;
- addLabel(11);
-}
-
-StatusPopup::~StatusPopup()
-{
-}
-
-void StatusPopup::update()
-{
- updateLabels();
-
- int maxWidth = mLabels[0]->getWidth();
-
- for (int f = 0; f < STATUSPOPUP_NUM_LABELS; f ++)
- {
- const int width = mLabels[f]->getWidth();
- if (width > maxWidth)
- maxWidth = width;
- }
-
- const int pad2 = 2 * mPadding;
- maxWidth += pad2;
- setWidth(maxWidth);
- setHeight(mLabels[11]->getY()
- + mLabels[11]->getHeight() + pad2);
-}
-
-void StatusPopup::view(const int x, const int y)
-{
- const int distance = 20;
-
- int posX = std::max(0, x - getWidth() / 2);
- int posY = y + distance;
-
- if (posX + getWidth() > mainGraphics->mWidth)
- posX = mainGraphics->mWidth - getWidth();
- if (posY + getHeight() > mainGraphics->mHeight)
- posY = y - getHeight() - distance;
-
- update();
-
- setPosition(posX, posY);
- setVisible(Visible_true);
- requestMoveToTop();
-}
-
-void StatusPopup::setLabelText(const int num,
- const std::string &text,
- const InputActionT key) const
-{
- Label *const label = mLabels[num];
- label->setCaption(strprintf("%s %s", text.c_str(),
- inputManager.getKeyValueString(key).c_str()));
- label->adjustSize();
-}
-
-void StatusPopup::updateLabels() const
-{
- setLabelText(0, GameModifiers::getMoveTypeString(),
- InputAction::INVERT_DIRECTION);
- setLabelText(1, GameModifiers::getCrazyMoveTypeString(),
- InputAction::CHANGE_CRAZY_MOVES_TYPE);
- setLabelText(2, GameModifiers::getMoveToTargetTypeString(),
- InputAction::CHANGE_MOVE_TO_TARGET);
- setLabelText(3, GameModifiers::getFollowModeString(),
- InputAction::CHANGE_FOLLOW_MODE);
- setLabelText(4, GameModifiers::getAttackWeaponTypeString(),
- InputAction::CHANGE_ATTACK_WEAPON_TYPE);
- setLabelText(5, GameModifiers::getAttackTypeString(),
- InputAction::CHANGE_ATTACK_TYPE);
- setLabelText(6, GameModifiers::getQuickDropCounterString(),
- InputAction::SWITCH_QUICK_DROP);
- setLabelText(7, GameModifiers::getPickUpTypeString(),
- InputAction::CHANGE_PICKUP_TYPE);
- setLabelText(8, GameModifiers::getMapDrawTypeString(),
- InputAction::PATHFIND);
- setLabelText(9, GameModifiers::getMagicAttackTypeString(),
- InputAction::SWITCH_MAGIC_ATTACK);
- setLabelText(10, GameModifiers::getPvpAttackTypeString(),
- InputAction::SWITCH_PVP_ATTACK);
- setLabelText(11, GameModifiers::getGameModifiersString(),
- InputAction::DISABLE_GAME_MODIFIERS);
- setLabelText(12, GameModifiers::getImitationModeString(),
- InputAction::CHANGE_IMITATION_MODE);
- setLabelText(13, GameModifiers::getAwayModeString(),
- InputAction::AWAY);
- setLabelText(14, GameModifiers::getCameraModeString(),
- InputAction::CAMERA);
- setLabelText(15, GameModifiers::getTargetingTypeString(),
- InputAction::CHANGE_TARGETING_TYPE);
-}
diff --git a/src/gui/popups/statuspopup.h b/src/gui/popups/statuspopup.h
deleted file mode 100644
index 6ffff5799..000000000
--- a/src/gui/popups/statuspopup.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 The Legend of Mazzeroth Development Team
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 Andrei Karas
- * 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_POPUPS_STATUSPOPUP_H
-#define GUI_POPUPS_STATUSPOPUP_H
-
-#include "enums/input/inputaction.h"
-
-#include "gui/widgets/popup.h"
-
-class Label;
-
-const int STATUSPOPUP_NUM_LABELS = 16;
-
-/**
- * A popup that displays information about an item.
- */
-class StatusPopup final : public Popup
-{
- public:
- /**
- * Constructor. Initializes the item popup.
- */
- StatusPopup();
-
- A_DELETE_COPY(StatusPopup)
-
- void postInit() override final;
-
- /**
- * Destructor. Cleans up the item popup on deletion.
- */
- ~StatusPopup();
-
- /**
- * Sets the location to display the item popup.
- */
- void view(const int x, const int y);
-
- void update();
-
- private:
- void updateLabels() const;
-
- void setLabelText(const int num,
- const std::string &text,
- const InputActionT key) const;
-
- Label *mLabels[STATUSPOPUP_NUM_LABELS] A_NONNULLPOINTER;
-};
-
-#endif // GUI_POPUPS_STATUSPOPUP_H
diff --git a/src/gui/popups/textboxpopup.cpp b/src/gui/popups/textboxpopup.cpp
deleted file mode 100644
index 873d6018c..000000000
--- a/src/gui/popups/textboxpopup.cpp
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 The Legend of Mazzeroth Development Team
- * 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 "gui/popups/textboxpopup.h"
-
-#include "gui/widgets/textbox.h"
-
-#include "gui/fonts/font.h"
-
-#include "render/graphics.h"
-
-#include "debug.h"
-
-TextBoxPopup *textBoxPopup = nullptr;
-
-TextBoxPopup::TextBoxPopup() :
- Popup("TextBoxPopup", "textboxpopup.xml"),
- mTextBox(new TextBox(this))
-{
-}
-
-void TextBoxPopup::postInit()
-{
- Popup::postInit();
- const int fontHeight = getFont()->getHeight();
- setMinHeight(fontHeight);
- mTextBox->setEditable(false);
- mTextBox->setOpaque(Opaque_false);
- add(mTextBox);
- addMouseListener(this);
-}
-
-TextBoxPopup::~TextBoxPopup()
-{
-}
-
-void TextBoxPopup::show(const int x, const int y, const std::string &str)
-{
- mTextBox->setTextWrapped(str, 190);
- setContentSize(mTextBox->getWidth(), mTextBox->getHeight());
- const int distance = 20;
-
- const Rect &rect = mDimension;
- int posX = std::max(0, x - rect.width / 2);
- int posY = y + distance;
-
- if (posX + rect.width > mainGraphics->mWidth)
- posX = mainGraphics->mWidth - rect.width;
- if (posY + rect.height > mainGraphics->mHeight)
- posY = y - rect.height - distance;
-
- setPosition(posX, posY);
- setVisible(Visible_true);
- requestMoveToTop();
-}
-
-void TextBoxPopup::mouseMoved(MouseEvent &event)
-{
- Popup::mouseMoved(event);
-
- // When the mouse moved on top of the popup, hide it
- setVisible(Visible_false);
-}
diff --git a/src/gui/popups/textboxpopup.h b/src/gui/popups/textboxpopup.h
deleted file mode 100644
index 8316905ac..000000000
--- a/src/gui/popups/textboxpopup.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 The Legend of Mazzeroth Development Team
- * 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 GUI_POPUPS_TEXTBOXPOPUP_H
-#define GUI_POPUPS_TEXTBOXPOPUP_H
-
-#include "gui/widgets/popup.h"
-
-class TextBox;
-
-/**
- * A popup that displays information about an item.
- */
-class TextBoxPopup final : public Popup
-{
- public:
- /**
- * Constructor. Initializes the item popup.
- */
- TextBoxPopup();
-
- A_DELETE_COPY(TextBoxPopup)
-
- /**
- * Destructor. Cleans up the item popup on deletion.
- */
- ~TextBoxPopup();
-
- void postInit() override final;
-
- /**
- * Sets the text to be displayed.
- */
- void show(const int x, const int y, const std::string &str);
-
- void mouseMoved(MouseEvent &event) override final;
-
- private:
- TextBox *mTextBox A_NONNULLPOINTER;
-};
-
-extern TextBoxPopup *textBoxPopup;
-
-#endif // GUI_POPUPS_TEXTBOXPOPUP_H
diff --git a/src/gui/popups/textpopup.cpp b/src/gui/popups/textpopup.cpp
deleted file mode 100644
index c8b951aea..000000000
--- a/src/gui/popups/textpopup.cpp
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 The Legend of Mazzeroth Development Team
- * 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 "gui/popups/textpopup.h"
-
-#include "gui/widgets/label.h"
-
-#include "gui/fonts/font.h"
-
-#include "debug.h"
-
-TextPopup *textPopup = nullptr;
-
-TextPopup::TextPopup() :
- Popup("TextPopup", "textpopup.xml"),
- mText()
-{
-}
-
-void TextPopup::postInit()
-{
- Popup::postInit();
- const int fontHeight = getFont()->getHeight();
- int y = 0;
- for (int f = 0; f < TEXTPOPUPCOUNT; f ++)
- {
- Label *const label = new Label(this);
- mText[f] = label;
- label->setPosition(0, y);
- label->setForegroundColorAll(getThemeColor(ThemeColorId::POPUP),
- getThemeColor(ThemeColorId::POPUP_OUTLINE));
- add(label);
- y += fontHeight;
- }
- addMouseListener(this);
-}
-
-TextPopup::~TextPopup()
-{
-}
-
-void TextPopup::show(const int x, const int y, const std::string &str1,
- const std::string &str2, const std::string &str3)
-{
- mText[0]->setCaption(str1);
- mText[1]->setCaption(str2);
- mText[2]->setCaption(str3);
-
- int minWidth = 0;
- for (int f = 0; f < TEXTPOPUPCOUNT; f ++)
- {
- Label *const label = mText[f];
- label->adjustSize();
- const int width = label->getWidth();
- if (width > minWidth)
- minWidth = width;
- }
-
- const int pad2 = 2 * mPadding;
- minWidth += pad2;
- setWidth(minWidth);
-
- int cnt = 1;
- if (!str2.empty())
- cnt ++;
- if (!str3.empty())
- cnt ++;
-
- setHeight(pad2 + mText[0]->getFont()->getHeight() * cnt);
- const int distance = 20;
-
- const Rect &rect = mDimension;
- int posX = std::max(0, x - rect.width / 2);
- int posY = y + distance;
-
- if (posX + rect.width > mainGraphics->mWidth)
- posX = mainGraphics->mWidth - rect.width;
- if (posY + rect.height > mainGraphics->mHeight)
- posY = y - rect.height - distance;
-
- setPosition(posX, posY);
- setVisible(Visible_true);
- requestMoveToTop();
-}
-
-void TextPopup::mouseMoved(MouseEvent &event)
-{
- Popup::mouseMoved(event);
-
- // When the mouse moved on top of the popup, hide it
- setVisible(Visible_false);
-}
diff --git a/src/gui/popups/textpopup.h b/src/gui/popups/textpopup.h
deleted file mode 100644
index 8a67d5660..000000000
--- a/src/gui/popups/textpopup.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 The Legend of Mazzeroth Development Team
- * 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 GUI_POPUPS_TEXTPOPUP_H
-#define GUI_POPUPS_TEXTPOPUP_H
-
-#include "gui/widgets/popup.h"
-
-class Label;
-
-const int TEXTPOPUPCOUNT = 3;
-
-/**
- * A popup that displays information about an item.
- */
-class TextPopup final : public Popup
-{
- public:
- /**
- * Constructor. Initializes the item popup.
- */
- TextPopup();
-
- A_DELETE_COPY(TextPopup)
-
- /**
- * Destructor. Cleans up the item popup on deletion.
- */
- ~TextPopup();
-
- void postInit() override final;
-
- /**
- * Sets the text to be displayed.
- */
- void show(const int x, const int y, const std::string &str1)
- {
- show(x, y, str1, static_cast<const char*>(""),
- static_cast<const char*>(""));
- }
-
- /**
- * Sets the text to be displayed.
- */
- void show(const int x, const int y, const std::string &str1,
- const std::string &str2)
- { show(x, y, str1, str2, static_cast<const char*>("")); }
-
- /**
- * Sets the text to be displayed.
- */
- void show(const int x, const int y, const std::string &str1,
- const std::string &str2, const std::string &str3);
-
- void mouseMoved(MouseEvent &event) override final;
-
- private:
- Label *mText[TEXTPOPUPCOUNT];
-};
-
-extern TextPopup *textPopup;
-
-#endif // GUI_POPUPS_TEXTPOPUP_H
diff --git a/src/gui/rect.h b/src/gui/rect.h
deleted file mode 100644
index 0f72d2b6c..000000000
--- a/src/gui/rect.h
+++ /dev/null
@@ -1,226 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GUI_RECT_H
-#define GUI_RECT_H
-
-#include "localconsts.h"
-
-/**
- * Represents a rectangle.
- */
-class Rect notfinal
-{
- public:
- /**
- * Constructor. The default rectangle is an empty rectangle
- * at the coordinates (0,0).
- */
- constexpr Rect() :
- x(0),
- y(0),
- width(0),
- height(0)
- {
- }
-
- /**
- * Constructor.
- *
- * @param x_ The x coordinate of the rectangle.
- * @param y_ The y coordinate of the rectangle.
- * @param width_ The width of the rectangle.
- * @param height_ The height of the rectangle.
- */
- constexpr Rect(const int x_,
- const int y_,
- const int width_,
- const int height_) :
- x(x_),
- y(y_),
- width(width_),
- height(height_)
- {
- }
-
- constexpr Rect(const Rect &r) :
- x(r.x),
- y(r.y),
- width(r.width),
- height(r.height)
- {
- }
-
- A_DEFAULT_COPY(Rect)
-
- Rect &operator=(const Rect &r)
- {
- x = r.x;
- y = r.y;
- width = r.width;
- height = r.height;
- return *this;
- }
-
- virtual ~Rect()
- { }
-
- /**
- * Sets the dimension of a rectangle.
- *
- * @param x0 The x coordinate of the rectangle.
- * @param y0 The y coordinate of the rectangle.
- * @param width0 The width of the rectangle.
- * @param height0 The height of the rectangle.
- */
- void setAll(const int x0,
- const int y0,
- const int width0,
- const int height0)
- {
- x = x0;
- y = y0;
- width = width0;
- height = height0;
- }
-
- /**
- * Checks if another rectangle intersects with the rectangle.
- *
- * @param rectangle Another rectangle to check for intersection.
- * @return True if the rectangles intersect, false otherwise.
- */
- bool isIntersecting(const Rect& rectangle) const A_WARN_UNUSED
- {
- int x_ = x;
- int y_ = y;
- int width_ = width;
- int height_ = height;
-
- x_ -= rectangle.x;
- y_ -= rectangle.y;
-
- if (x_ < 0)
- {
- width_ += x_;
- }
- else if (x_ + width_ > rectangle.width)
- {
- width_ = rectangle.width - x_;
- }
-
- if (y_ < 0)
- {
- height_ += y_;
- }
- else if (y_ + height_ > rectangle.height)
- {
- height_ = rectangle.height - y_;
- }
-
- if (width_ <= 0 || height_ <= 0)
- {
- return false;
- }
-
- return true;
- }
-
- /**
- * Checks if a point is inside the rectangle
- *
- * @param x_ The x coordinate of the point.
- * @param y_ The y coordinate of the point.
- * @return True if the point is inside the rectangle.
- */
- bool isPointInRect(const int x_,
- const int y_) const A_WARN_UNUSED
- {
- return x_ >= x
- && y_ >= y
- && x_ < x + width
- && y_ < y + height;
- }
-
- /**
- * Holds the x coordinate of the rectangle.
- */
- int x;
-
- /**
- * Holds the x coordinate of the rectangle.
- */
- int y;
-
- /**
- * Holds the width of the rectangle.
- */
- int width;
-
- /**
- * Holds the height of the rectangle.
- */
- int height;
-};
-
-#endif // GUI_RECT_H
diff --git a/src/gui/sdlinput.cpp b/src/gui/sdlinput.cpp
deleted file mode 100644
index 3fd122002..000000000
--- a/src/gui/sdlinput.cpp
+++ /dev/null
@@ -1,405 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004, 2005, 2006, 2007 Olof Naessén and Per Larsson
- * Copyright (C) 2007-2010 The Mana World Development Team
- *
- * Js_./
- * Per Larsson a.k.a finalman _RqZ{a<^_aa
- * Olof Naessén a.k.a jansem/yakslem _asww7!uY`> )\a//
- * _Qhm`] _f "'c 1!5m
- * Visit: http://guichan.darkbits.org )Qk<P ` _: :+' .' "{[
- * .)j(] .d_/ '-( P . S
- * License: (BSD) <Td/Z <fP"5(\"??"\a. .L
- * Redistribution and use in source and _dV>ws?a-?' ._/L #'
- * binary forms, with or without )4d[#7r, . ' )d`)[
- * modification, are permitted provided _Q-5'5W..j/?' -?!\)cam'
- * that the following conditions are met: j<<WP+k/);. _W=j f
- * 1. Redistributions of source code must .$%w\/]Q . ."' . mj$
- * retain the above copyright notice, ]E.pYY(Q]>. a J@\
- * this list of conditions and the j(]1u<sE"L,. . ./^ ]{a
- * following disclaimer. 4'_uomm\. )L);-4 (3=
- * 2. Redistributions in binary form must )_]X{Z('a_"a7'<a"a, ]"[
- * reproduce the above copyright notice, #}<]m7`Za??4,P-"'7. ).m
- * this list of conditions and the ]d2e)Q(<Q( ?94 b- LQ/
- * following disclaimer in the <B!</]C)d_, '(<' .f. =C+m
- * documentation and/or other materials .Z!=J ]e []('-4f _ ) -.)m]'
- * provided with the distribution. .w[5]' _[ /.)_-"+? _/ <W"
- * 3. Neither the name of Guichan nor the :$we` _! + _/ . j?
- * names of its contributors may be used =3)= _f (_yQmWW$#( "
- * to endorse or promote products derived - W, sQQQQmZQ#Wwa]..
- * from this software without specific (js, \[QQW$QWW#?!V"".
- * prior written permission. ]y:.<\.. .
- * -]n w/ ' [.
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT )/ )/ !
- * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY < (; sac , '
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, ]^ .- %
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF c < r
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR aga< <La
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 5% )P'-3L
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR _bQf` y`..)a
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ,J?4P'.P"_(\?d'.,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES _Pa,)!f/<[]/ ?"
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT _2-..:. .r+_,.. .
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ?a.<%"' " -'.a_ _,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ^
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "sdlshared.h"
-
-#include "input/inputmanager.h"
-
-#include "gui/gui.h"
-#include "gui/sdlinput.h"
-
-#include "render/graphics.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_timer.h>
-PRAGMA48(GCC diagnostic pop)
-
-#include "debug.h"
-
-extern volatile time_t cur_time;
-
-SDLInput *guiInput = nullptr;
-
-SDLInput::SDLInput() :
- mKeyInputQueue(),
- mMouseInputQueue(),
- mMouseMoveTime(0),
- mMouseDown(false),
- mMouseInWindow(true)
-{
-}
-
-KeyInput SDLInput::dequeueKeyInput()
-{
- if (mKeyInputQueue.empty())
- return KeyInput();
-
- KeyInput keyInput = mKeyInputQueue.front();
- mKeyInputQueue.pop();
-
- return keyInput;
-}
-
-MouseInput SDLInput::dequeueMouseInput()
-{
- MouseInput mouseInput;
-
- if (mMouseInputQueue.empty())
- return MouseInput();
-
- mouseInput = mMouseInputQueue.front();
- mMouseInputQueue.pop();
-
- return mouseInput;
-}
-
-void SDLInput::pushInput(const SDL_Event &event)
-{
- BLOCK_START("SDLInput::pushInput")
- KeyInput keyInput;
- MouseInput mouseInput;
-
- switch (event.type)
- {
- case SDL_KEYDOWN:
- {
- keyInput.setType(KeyEventType::PRESSED);
- convertKeyEventToKey(event, keyInput);
- mKeyInputQueue.push(keyInput);
- break;
- }
-
- case SDL_KEYUP:
- {
- keyInput.setType(KeyEventType::RELEASED);
- convertKeyEventToKey(event, keyInput);
- mKeyInputQueue.push(keyInput);
- break;
- }
-
-#ifdef USE_SDL2
- case SDL_TEXTINPUT:
- keyInput.setType(KeyEventType::PRESSED);
- keyInput.setKey(Key(KeyValue::TEXTINPUT));
- keyInput.setText(event.text.text);
- mKeyInputQueue.push(keyInput);
- break;
-
- case SDL_MOUSEWHEEL:
- {
- const int y = event.wheel.y;
- if (y)
- {
- mouseInput.setX(gui->getLastMouseX());
- mouseInput.setY(gui->getLastMouseY());
-#ifdef ANDROID
- mouseInput.setReal(0, 0);
-#endif // ANDROID
-
- mouseInput.setButton(MouseButton::WHEEL);
- if (y > 0)
- mouseInput.setType(MouseEventType::WHEEL_MOVED_UP);
- else
- mouseInput.setType(MouseEventType::WHEEL_MOVED_DOWN);
- mouseInput.setTimeStamp(SDL_GetTicks());
- mMouseInputQueue.push(mouseInput);
- }
-
- break;
- }
-#endif // USE_SDL2
-
-#ifdef ANDROID
-#ifndef USE_SDL2
- case SDL_ACCELEROMETER:
- break;
-#endif // USE_SDL2
-#endif // ANDROID
-
- case SDL_MOUSEBUTTONDOWN:
- {
- mMouseDown = true;
- const int scale = mainGraphics->getScale();
- const int x = event.button.x / scale;
- const int y = event.button.y / scale;
- mouseInput.setX(x);
- mouseInput.setY(y);
-#ifdef ANDROID
-#ifdef USE_SDL2
- mouseInput.setReal(x, y);
-#else // USE_SDL2
-
- mouseInput.setReal(event.button.realx / scale,
- event.button.realy / scale);
-#endif // USE_SDL2
-#endif // ANDROID
-
- mouseInput.setButton(convertMouseButton(event.button.button));
-
-#ifndef USE_SDL2
- if (event.button.button == SDL_BUTTON_WHEELDOWN)
- mouseInput.setType(MouseEventType::WHEEL_MOVED_DOWN);
- else if (event.button.button == SDL_BUTTON_WHEELUP)
- mouseInput.setType(MouseEventType::WHEEL_MOVED_UP);
- else
-#endif // USE_SDL2
- mouseInput.setType(MouseEventType::PRESSED);
- mouseInput.setTimeStamp(SDL_GetTicks());
- mMouseInputQueue.push(mouseInput);
- break;
- }
- case SDL_MOUSEBUTTONUP:
- {
- mMouseDown = false;
- const int scale = mainGraphics->getScale();
- const int x = event.button.x / scale;
- const int y = event.button.y / scale;
- mouseInput.setX(x);
- mouseInput.setY(y);
-#ifdef ANDROID
-#ifdef USE_SDL2
- mouseInput.setReal(x, y);
-#else // USE_SDL2
-
- mouseInput.setReal(event.button.realx / scale,
- event.button.realy / scale);
-#endif // USE_SDL2
-#endif // ANDROID
-
- mouseInput.setButton(convertMouseButton(event.button.button));
- mouseInput.setType(MouseEventType::RELEASED);
- mouseInput.setTimeStamp(SDL_GetTicks());
- mMouseInputQueue.push(mouseInput);
- break;
- }
- case SDL_MOUSEMOTION:
- {
- const int scale = mainGraphics->getScale();
- const int x = event.motion.x / scale;
- const int y = event.motion.y / scale;
- mouseInput.setX(x);
- mouseInput.setY(y);
-#ifdef ANDROID
-#ifdef USE_SDL2
- mouseInput.setReal(x, y);
-#else // USE_SDL2
-
- mouseInput.setReal(event.motion.realx / scale,
- event.motion.realy / scale);
-#endif // USE_SDL2
-#endif // ANDROID
-
- mouseInput.setButton(MouseButton::EMPTY);
- mouseInput.setType(MouseEventType::MOVED);
- mouseInput.setTimeStamp(SDL_GetTicks());
- mMouseInputQueue.push(mouseInput);
- mMouseMoveTime = cur_time;
- break;
- }
-#ifndef USE_SDL2
- case SDL_ACTIVEEVENT:
- /*
- * This occurs when the mouse leaves the window and the Gui-chan
- * application loses its mousefocus.
- */
- if ((event.active.state & SDL_APPMOUSEFOCUS) != 0 &&
- event.active.gain == 0u)
- {
- mMouseInWindow = false;
-
- if (!mMouseDown)
- {
- mouseInput.setX(-1);
- mouseInput.setY(-1);
- mouseInput.setButton(MouseButton::EMPTY);
- mouseInput.setType(MouseEventType::MOVED);
- mMouseInputQueue.push(mouseInput);
- mMouseMoveTime = cur_time;
- }
- }
-
- if ((event.active.state & SDL_APPMOUSEFOCUS) != 0 &&
- event.active.gain != 0u)
- {
- mMouseInWindow = true;
- }
- break;
-#endif // USE_SDL2
-
- default:
- break;
- } // end switch
- BLOCK_END("SDLInput::pushInput")
-}
-
-void SDLInput::convertKeyEventToKey(const SDL_Event &event, KeyInput &keyInput)
-{
- keyInput.setKey(Key(convertKeyCharacter(event)));
- const InputActionT actionId = inputManager.getActionByKey(event);
- if (actionId > InputAction::NO_VALUE)
- keyInput.setActionId(actionId);
-}
-
-MouseButtonT SDLInput::convertMouseButton(const int button)
-{
- switch (button)
- {
- case SDL_BUTTON_LEFT:
- return MouseButton::LEFT;
- case SDL_BUTTON_RIGHT:
- return MouseButton::RIGHT;
- case SDL_BUTTON_MIDDLE:
- return MouseButton::MIDDLE;
-#ifndef USE_SDL2
- case SDL_BUTTON_WHEELUP:
- case SDL_BUTTON_WHEELDOWN:
- return MouseButton::EMPTY;
-#endif // USE_SDL2
-
- default:
- // We have an unknown mouse type which is ignored.
- logger->log("unknown button type: %d", button);
- return MouseButton::EMPTY;
- }
-}
-
-void SDLInput::simulateMouseClick(const int x, const int y,
- const MouseButtonT button)
-{
- MouseInput mouseInput;
- mouseInput.setX(x);
- mouseInput.setY(y);
- mouseInput.setReal(x, y);
- mouseInput.setButton(MouseButton::EMPTY);
- mouseInput.setType(MouseEventType::MOVED);
- mouseInput.setTimeStamp(SDL_GetTicks());
- mMouseInputQueue.push(mouseInput);
- mouseInput.setButton(button);
- mouseInput.setType(MouseEventType::PRESSED);
- mouseInput.setTimeStamp(SDL_GetTicks());
- mMouseInputQueue.push(mouseInput);
- mouseInput.setType(MouseEventType::RELEASED);
- mouseInput.setTimeStamp(SDL_GetTicks());
- mMouseInputQueue.push(mouseInput);
-}
-
-void SDLInput::simulateMouseMove()
-{
- if (gui == nullptr)
- return;
-
- if (mMouseMoveTime == cur_time)
- return;
-
- mMouseMoveTime = cur_time;
- int x, y;
- Gui::getMouseState(x, y);
-
- MouseInput mouseInput;
- mouseInput.setX(x);
- mouseInput.setY(y);
- mouseInput.setReal(x, y);
- mouseInput.setButton(MouseButton::EMPTY);
- mouseInput.setType(MouseEventType::MOVED);
- mouseInput.setTimeStamp(SDL_GetTicks());
- mMouseInputQueue.push(mouseInput);
-}
-
-void SDLInput::simulateKey(const int guiKey,
- const InputActionT actionId)
-{
- KeyInput keyInput;
- keyInput.setType(KeyEventType::PRESSED);
-#ifdef USE_SDL2
- char str[2];
- str[0] = CAST_S8(guiKey);
- str[1] = 0;
-
- keyInput.setKey(Key(KeyValue::TEXTINPUT));
- keyInput.setText(str);
- if (guiKey >= 32)
- mKeyInputQueue.push(keyInput);
-#endif // USE_SDL2
-
- keyInput.setKey(Key(guiKey));
- if (actionId > InputAction::NO_VALUE)
- keyInput.setActionId(actionId);
- mKeyInputQueue.push(keyInput);
- keyInput.setType(KeyEventType::RELEASED);
- mKeyInputQueue.push(keyInput);
-}
diff --git a/src/gui/sdlinput.h b/src/gui/sdlinput.h
deleted file mode 100644
index 5910911ef..000000000
--- a/src/gui/sdlinput.h
+++ /dev/null
@@ -1,391 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004, 2005, 2006, 2007 Olof Naessén and Per Larsson
- * Copyright (C) 2007-2010 The Mana World Development Team
- *
- * Js_./
- * Per Larsson a.k.a finalman _RqZ{a<^_aa
- * Olof Naessén a.k.a jansem/yakslem _asww7!uY`> )\a//
- * _Qhm`] _f "'c 1!5m
- * Visit: http://guichan.darkbits.org )Qk<P ` _: :+' .' "{[
- * .)j(] .d_/ '-( P . S
- * License: (BSD) <Td/Z <fP"5(\"??"\a. .L
- * Redistribution and use in source and _dV>ws?a-?' ._/L #'
- * binary forms, with or without )4d[#7r, . ' )d`)[
- * modification, are permitted provided _Q-5'5W..j/?' -?!\)cam'
- * that the following conditions are met: j<<WP+k/);. _W=j f
- * 1. Redistributions of source code must .$%w\/]Q . ."' . mj$
- * retain the above copyright notice, ]E.pYY(Q]>. a J@\
- * this list of conditions and the j(]1u<sE"L,. . ./^ ]{a
- * following disclaimer. 4'_uomm\. )L);-4 (3=
- * 2. Redistributions in binary form must )_]X{Z('a_"a7'<a"a, ]"[
- * reproduce the above copyright notice, #}<]m7`Za??4,P-"'7. ).m
- * this list of conditions and the ]d2e)Q(<Q( ?94 b- LQ/
- * following disclaimer in the <B!</]C)d_, '(<' .f. =C+m
- * documentation and/or other materials .Z!=J ]e []('-4f _ ) -.)m]'
- * provided with the distribution. .w[5]' _[ /.)_-"+? _/ <W"
- * 3. Neither the name of Guichan nor the :$we` _! + _/ . j?
- * names of its contributors may be used =3)= _f (_yQmWW$#( "
- * to endorse or promote products derived - W, sQQQQmZQ#Wwa]..
- * from this software without specific (js, \[QQW$QWW#?!V"".
- * prior written permission. ]y:.<\.. .
- * -]n w/ ' [.
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT )/ )/ !
- * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY < (; sac , '
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, ]^ .- %
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF c < r
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR aga< <La
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 5% )P'-3L
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR _bQf` y`..)a
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ,J?4P'.P"_(\?d'.,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES _Pa,)!f/<[]/ ?"
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT _2-..:. .r+_,.. .
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ?a.<%"' " -'.a_ _,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ^
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GUI_SDLINPUT_H
-#define GUI_SDLINPUT_H
-
-#include "enums/input/keyvalue.h"
-
-#include "input/keyinput.h"
-
-#include "utils/cast.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_events.h>
-PRAGMA48(GCC diagnostic pop)
-
-#ifdef USE_SDL2
-#include "sdlshared.h"
-#endif // USE_SDL2
-
-#include "input/mouseinput.h"
-
-#include <queue>
-
-/**
- * SDL implementation of SDLInput.
- */
-class SDLInput final
-{
- public:
- /**
- * Constructor.
- */
- SDLInput();
-
- A_DELETE_COPY(SDLInput)
-
- /**
- * Pushes an SDL event. It should be called at least once per frame to
- * update input with user input.
- *
- * @param event an event from SDL.
- */
- void pushInput(const SDL_Event &event);
-
- KeyInput dequeueKeyInput() A_WARN_UNUSED;
-
- bool isKeyQueueEmpty() const noexcept2 A_WARN_UNUSED
- { return mKeyInputQueue.empty(); }
-
- bool isMouseQueueEmpty() const noexcept2 A_WARN_UNUSED
- { return mMouseInputQueue.empty(); }
-
- MouseInput dequeueMouseInput() A_WARN_UNUSED;
-
- void simulateMouseClick(const int x, const int y,
- const MouseButtonT button);
-
- void simulateMouseMove();
-
- void simulateKey(const int guiKey,
- const InputActionT actionId);
-
- protected:
- /**
- * Converts a mouse button from SDL to a Guichan mouse button
- * representation.
- *
- * @param button an SDL mouse button.
- * @return a Guichan mouse button.
- */
- static MouseButtonT convertMouseButton(const int button) A_WARN_UNUSED;
-
- /**
- * Converts an SDL event key to a key value.
- *
- * @param event an SDL event with a key to convert.
- * @return a key value.
- * @see Key
- */
- constexpr2 static int convertKeyCharacter(const SDL_Event &event)
- A_WARN_UNUSED
- {
- const SDL_keysym keysym = event.key.keysym;
-#ifdef USE_SDL2
- int value = keysym.scancode;
-#else // USE_SDL2
-
- int value = keysym.unicode;
-#endif // USE_SDL2
-
- PRAGMA45(GCC diagnostic push)
- PRAGMA45(GCC diagnostic ignored "-Wswitch-enum")
- switch (keysym.sym)
- {
- case SDLK_TAB:
- value = KeyValue::TAB;
- break;
- case SDLK_LALT:
- value = KeyValue::LEFT_ALT;
- break;
- case SDLK_RALT:
- value = KeyValue::RIGHT_ALT;
- break;
- case SDLK_LSHIFT:
- value = KeyValue::LEFT_SHIFT;
- break;
- case SDLK_RSHIFT:
- value = KeyValue::RIGHT_SHIFT;
- break;
- case SDLK_LCTRL:
- value = KeyValue::LEFT_CONTROL;
- break;
- case SDLK_RCTRL:
- value = KeyValue::RIGHT_CONTROL;
- break;
- case SDLK_BACKSPACE:
- value = KeyValue::BACKSPACE;
- break;
- case SDLK_PAUSE:
- value = KeyValue::PAUSE;
- break;
- case SDLK_SPACE:
- // Special characters like ~ (tilde) ends up
- // with the keysym.sym SDLK_SPACE which
- // without this check would be lost. The check
- // is only valid on key down events in SDL.
-#ifndef USE_SDL2
- if (event.type == SDL_KEYUP ||
- keysym.unicode == ' ')
-#endif // USE_SDL2
- {
- value = KeyValue::SPACE;
- }
- break;
- case SDLK_ESCAPE:
-#ifdef USE_SDL2
- case SDLK_AC_BACK:
-#endif // USE_SDL2
- value = KeyValue::ESCAPE;
- break;
- case SDLK_DELETE:
- value = KeyValue::DELETE_;
- break;
- case SDLK_INSERT:
- value = KeyValue::INSERT;
- break;
- case SDLK_HOME:
- value = KeyValue::HOME;
- break;
- case SDLK_END:
- value = KeyValue::END;
- break;
- case SDLK_PAGEUP:
- value = KeyValue::PAGE_UP;
- break;
- case SDLK_PRINT:
- value = KeyValue::PRINT_SCREEN;
- break;
- case SDLK_PAGEDOWN:
- value = KeyValue::PAGE_DOWN;
- break;
- case SDLK_F1:
- value = KeyValue::F1;
- break;
- case SDLK_F2:
- value = KeyValue::F2;
- break;
- case SDLK_F3:
- value = KeyValue::F3;
- break;
- case SDLK_F4:
- value = KeyValue::F4;
- break;
- case SDLK_F5:
- value = KeyValue::F5;
- break;
- case SDLK_F6:
- value = KeyValue::F6;
- break;
- case SDLK_F7:
- value = KeyValue::F7;
- break;
- case SDLK_F8:
- value = KeyValue::F8;
- break;
- case SDLK_F9:
- value = KeyValue::F9;
- break;
- case SDLK_F10:
- value = KeyValue::F10;
- break;
- case SDLK_F11:
- value = KeyValue::F11;
- break;
- case SDLK_F12:
- value = KeyValue::F12;
- break;
- case SDLK_F13:
- value = KeyValue::F13;
- break;
- case SDLK_F14:
- value = KeyValue::F14;
- break;
- case SDLK_F15:
- value = KeyValue::F15;
- break;
- case SDLK_NUMLOCK:
- value = KeyValue::NUM_LOCK;
- break;
- case SDLK_CAPSLOCK:
- value = KeyValue::CAPS_LOCK;
- break;
- case SDLK_SCROLLOCK:
- value = KeyValue::SCROLL_LOCK;
- break;
- case SDLK_RMETA:
- value = KeyValue::RIGHT_META;
- break;
- case SDLK_LMETA:
- value = KeyValue::LEFT_META;
- break;
-#ifndef USE_SDL2
- case SDLK_LSUPER:
- value = KeyValue::LEFT_SUPER;
- break;
- case SDLK_RSUPER:
- value = KeyValue::RIGHT_SUPER;
- break;
-#endif // USE_SDL2
-
- case SDLK_MODE:
- value = KeyValue::ALT_GR;
- break;
- case SDLK_UP:
- value = KeyValue::UP;
- break;
- case SDLK_DOWN:
- value = KeyValue::DOWN;
- break;
- case SDLK_LEFT:
- value = KeyValue::LEFT;
- break;
- case SDLK_RIGHT:
- value = KeyValue::RIGHT;
- break;
- case SDLK_RETURN:
- value = KeyValue::ENTER;
- break;
- case SDLK_KP_ENTER:
- value = KeyValue::ENTER;
- break;
-
- default:
- break;
- }
- PRAGMA45(GCC diagnostic pop)
-
- if ((CAST_U32(keysym.mod) & KMOD_NUM) == 0u)
- {
- PRAGMA45(GCC diagnostic push)
- PRAGMA45(GCC diagnostic ignored "-Wswitch-enum")
- switch (keysym.sym)
- {
- case SDLK_KP0:
- value = KeyValue::INSERT;
- break;
- case SDLK_KP1:
- value = KeyValue::END;
- break;
- case SDLK_KP2:
- value = KeyValue::DOWN;
- break;
- case SDLK_KP3:
- value = KeyValue::PAGE_DOWN;
- break;
- case SDLK_KP4:
- value = KeyValue::LEFT;
- break;
- case SDLK_KP5:
- value = 0;
- break;
- case SDLK_KP6:
- value = KeyValue::RIGHT;
- break;
- case SDLK_KP7:
- value = KeyValue::HOME;
- break;
- case SDLK_KP8:
- value = KeyValue::UP;
- break;
- case SDLK_KP9:
- value = KeyValue::PAGE_UP;
- break;
- default:
- break;
- }
- PRAGMA45(GCC diagnostic pop)
- }
- return value;
- }
-
- static void convertKeyEventToKey(const SDL_Event &event,
- KeyInput &keyInput);
-
- std::queue<KeyInput> mKeyInputQueue;
- std::queue<MouseInput> mMouseInputQueue;
- time_t mMouseMoveTime;
-
- bool mMouseDown;
- bool mMouseInWindow;
-};
-
-extern SDLInput *guiInput; /**< GUI input */
-
-#endif // GUI_SDLINPUT_H
diff --git a/src/gui/setupactiondata.h b/src/gui/setupactiondata.h
deleted file mode 100644
index 4dd591e6b..000000000
--- a/src/gui/setupactiondata.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2007 Joshua Langley <joshlangley@optusnet.com.au>
- * 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 GUI_SETUPACTIONDATA_H
-#define GUI_SETUPACTIONDATA_H
-
-#include "enums/input/inputaction.h"
-
-#include <string>
-
-#include "localconsts.h"
-
-struct SetupActionData final
-{
-#ifdef ADVGCC
- SetupActionData(const std::string &name0,
- const InputActionT actionId0,
- const std::string &text0) :
- name(name0),
- actionId(actionId0),
- text(text0)
- { }
-
- A_DELETE_COPY(SetupActionData)
-#endif // ADVGCC
-
- std::string name;
- const InputActionT actionId;
- std::string text;
-};
-
-#endif // GUI_SETUPACTIONDATA_H
diff --git a/src/gui/setupinputpages.cpp b/src/gui/setupinputpages.cpp
deleted file mode 100644
index f9bb4764c..000000000
--- a/src/gui/setupinputpages.cpp
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2007 Joshua Langley <joshlangley@optusnet.com.au>
- * 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 "const/gui/pages.h"
-
-#include "gui/setupinputpages.h"
-
-#include "utils/gettext.h"
-
-#include "input/pages/basic.h"
-#include "input/pages/chat.h"
-#include "input/pages/craft.h"
-#include "input/pages/emotes.h"
-#include "input/pages/gui.h"
-#include "input/pages/move.h"
-#include "input/pages/other.h"
-#include "input/pages/outfits.h"
-#include "input/pages/shortcuts.h"
-#include "input/pages/windows.h"
-
-#include "debug.h"
-
-const char *const pages[SETUP_PAGES + 1] =
-{
- // TRANSLATORS: input tab sub tab name
- N_("Basic"),
- // TRANSLATORS: input tab sub tab name
- N_("Move"),
- // TRANSLATORS: input tab sub tab name
- N_("Shortcuts"),
- // TRANSLATORS: input tab sub tab name
- N_("Windows"),
- // TRANSLATORS: input tab sub tab name
- N_("Craft"),
- // TRANSLATORS: input tab sub tab name
- N_("Emotes"),
- // TRANSLATORS: input tab sub tab name
- N_("Outfits"),
- // TRANSLATORS: input tab sub tab name
- N_("Chat"),
- // TRANSLATORS: input tab sub tab name
- N_("Other"),
- // TRANSLATORS: input tab sub tab name
- N_("Gui"),
- nullptr
-};
-
-SetupActionData *const setupActionData[SETUP_PAGES] =
-{
- setupActionDataBasic,
- setupActionDataMove,
- setupActionDataShortcuts,
- setupActionDataWindows,
- setupActionDataCraft,
- setupActionDataEmotes,
- setupActionDataOutfits,
- setupActionDataChat,
- setupActionDataOther,
- setupActionDataGui
-};
diff --git a/src/gui/setupinputpages.h b/src/gui/setupinputpages.h
deleted file mode 100644
index 953837808..000000000
--- a/src/gui/setupinputpages.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2007 Joshua Langley <joshlangley@optusnet.com.au>
- * 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 GUI_SETUPINPUTPAGES_H
-#define GUI_SETUPINPUTPAGES_H
-
-struct SetupActionData;
-
-extern const char *const pages[];
-extern SetupActionData *const setupActionData[];
-
-#endif // GUI_SETUPINPUTPAGES_H
diff --git a/src/gui/shortcut/dropshortcut.cpp b/src/gui/shortcut/dropshortcut.cpp
deleted file mode 100644
index f9876ebee..000000000
--- a/src/gui/shortcut/dropshortcut.cpp
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 Andrei Karas
- * 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 "gui/shortcut/dropshortcut.h"
-
-#include "settings.h"
-
-#include "being/localplayer.h"
-#include "being/playerinfo.h"
-
-#include "resources/inventory/inventory.h"
-
-#include "resources/item/item.h"
-
-#include "net/packetlimiter.h"
-
-#include "debug.h"
-
-static const int DROP_SHORTCUT_ITEMS = 16;
-
-DropShortcut *dropShortcut = nullptr;
-
-DropShortcut::DropShortcut() :
- ShortcutBase("drop", "dropColor", DROP_SHORTCUT_ITEMS),
- mLastDropIndex(0)
-{
- clear(false);
- load();
-}
-
-DropShortcut::~DropShortcut()
-{
-}
-
-void DropShortcut::dropFirst() const
-{
- if (localPlayer == nullptr)
- return;
-
- if (!PacketLimiter::limitPackets(PacketType::PACKET_DROP))
- return;
-
- const int itemId = getItem(0);
- const ItemColor itemColor = getItemColor(0);
- if (PlayerInfo::isItemProtected(itemId))
- return;
-
- if (itemId > 0)
- {
- const Item *const item = PlayerInfo::getInventory()
- ->findItem(itemId, itemColor);
- if ((item != nullptr) && (item->getQuantity() != 0))
- {
- const int cnt = settings.quickDropCounter;
- if (localPlayer->isServerBuggy())
- {
- PlayerInfo::dropItem(item, cnt, Sfx_true);
- }
- else
- {
- for (int i = 0; i < cnt; i++)
- PlayerInfo::dropItem(item, 1, Sfx_false);
- }
- }
- }
-}
-
-void DropShortcut::dropItems(const int cnt)
-{
- if (localPlayer == nullptr)
- return;
-
- if (localPlayer->isServerBuggy())
- {
- dropItem(settings.quickDropCounter);
- return;
- }
-
- int n = 0;
- const int sz = settings.quickDropCounter;
- for (int f = 0; f < 9; f++)
- {
- for (int i = 0; i < sz; i++)
- {
- if (!PacketLimiter::limitPackets(PacketType::PACKET_DROP))
- return;
- if (dropItem())
- n++;
- }
- if (n >= cnt)
- break;
- }
-}
-
-bool DropShortcut::dropItem(const int cnt)
-{
- const Inventory *const inv = PlayerInfo::getInventory();
- if (inv == nullptr)
- return false;
-
- int itemId = 0;
- ItemColor itemColor = ItemColor_one;
- while (mLastDropIndex < DROP_SHORTCUT_ITEMS &&
- itemId < 1)
- {
- if (!PlayerInfo::isItemProtected(itemId))
- {
- itemId = getItem(mLastDropIndex);
- itemColor = getItemColor(mLastDropIndex);
- }
- mLastDropIndex ++;
- }
-
- if (itemId > 0)
- {
- const Item *const item = inv->findItem(itemId, itemColor);
- if ((item != nullptr) &&
- item->getQuantity() > 0)
- {
- PlayerInfo::dropItem(item, cnt, Sfx_true);
- return true;
- }
- }
- if (mLastDropIndex >= DROP_SHORTCUT_ITEMS)
- mLastDropIndex = 0;
-
- if (itemId < 1)
- {
- while (mLastDropIndex < DROP_SHORTCUT_ITEMS &&
- itemId < 1)
- {
- if (!PlayerInfo::isItemProtected(itemId))
- {
- itemId = getItem(mLastDropIndex);
- itemColor = getItemColor(mLastDropIndex);
- }
- mLastDropIndex++;
- }
- if (itemId > 0)
- {
- const Item *const item = inv->findItem(itemId, itemColor);
- if ((item != nullptr) && item->getQuantity() > 0)
- {
- PlayerInfo::dropItem(item, cnt, Sfx_true);
- return true;
- }
- }
- if (mLastDropIndex >= DROP_SHORTCUT_ITEMS)
- mLastDropIndex = 0;
- }
- return false;
-}
diff --git a/src/gui/shortcut/dropshortcut.h b/src/gui/shortcut/dropshortcut.h
deleted file mode 100644
index b3993b96e..000000000
--- a/src/gui/shortcut/dropshortcut.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 Andrei Karas
- * 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_SHORTCUT_DROPSHORTCUT_H
-#define GUI_SHORTCUT_DROPSHORTCUT_H
-
-#include "gui/shortcut/shortcutbase.h"
-
-#include "localconsts.h"
-
-/**
- * The class which keeps track of the item shortcuts.
- */
-class DropShortcut final : public ShortcutBase
-{
- public:
- /**
- * Constructor.
- */
- DropShortcut();
-
- A_DELETE_COPY(DropShortcut)
-
- /**
- * Destructor.
- */
- ~DropShortcut();
-
- /**
- * Drop first item.
- */
- void dropFirst() const;
-
- /**
- * Drop all items in cicle.
- */
- void dropItems(const int cnt = 1);
-
- private:
- /**
- * Drop item in cicle.
- */
- bool dropItem(const int cnt = 1);
-
- int mLastDropIndex;
-};
-
-extern DropShortcut *dropShortcut;
-
-#endif // GUI_SHORTCUT_DROPSHORTCUT_H
diff --git a/src/gui/shortcut/emoteshortcut.cpp b/src/gui/shortcut/emoteshortcut.cpp
deleted file mode 100644
index 8131a11a2..000000000
--- a/src/gui/shortcut/emoteshortcut.cpp
+++ /dev/null
@@ -1,115 +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 "gui/shortcut/emoteshortcut.h"
-
-#include "configuration.h"
-#include "settings.h"
-
-#include "being/localplayer.h"
-
-#include "net/homunculushandler.h"
-#include "net/mercenaryhandler.h"
-#include "net/pethandler.h"
-
-#include "resources/db/emotedb.h"
-
-#include "debug.h"
-
-EmoteShortcut *emoteShortcut = nullptr;
-
-EmoteShortcut::EmoteShortcut() :
- mEmoteSelected(0)
-{
- for (int i = 0; i < SHORTCUT_EMOTES; i++)
- mEmotes[i] = 0;
-}
-
-EmoteShortcut::~EmoteShortcut()
-{
- save();
-}
-
-void EmoteShortcut::load()
-{
- for (unsigned char i = 0, j = 0,
- fsz = CAST_U8(EmoteDB::getLast());
- i <= fsz && j < SHORTCUT_EMOTES;
- i++)
- {
- const EmoteSprite *const sprite = EmoteDB::getSprite(i, true);
- if (sprite != nullptr)
- {
- mEmotes[j] = CAST_U8(i + 1);
- j ++;
- }
- }
-}
-
-void EmoteShortcut::save() const
-{
- for (int i = 0; i < SHORTCUT_EMOTES; i++)
- {
- const unsigned char emoteId = mEmotes[i] != 0u ? mEmotes[i]
- : CAST_U8(0);
- serverConfig.setValue("emoteshortcut" + toString(i),
- CAST_U32(emoteId));
- }
-}
-
-void EmoteShortcut::useEmotePlayer(const size_t index) const
-{
- if (index <= CAST_SIZE(SHORTCUT_EMOTES))
- {
- if (mEmotes[index - 1] > 0)
- LocalPlayer::emote(mEmotes[index - 1]);
- }
-}
-
-void EmoteShortcut::useEmote(const size_t index) const
-{
- if (localPlayer == nullptr)
- return;
-
- if (index <= CAST_SIZE(SHORTCUT_EMOTES))
- {
- if (mEmotes[index - 1] > 0)
- {
- const uint8_t emote = mEmotes[index - 1];
- switch (settings.emoteType)
- {
- case EmoteType::Player:
- default:
- LocalPlayer::emote(emote);
- break;
- case EmoteType::Pet:
- petHandler->emote(emote);
- break;
- case EmoteType::Homunculus:
- homunculusHandler->emote(emote);
- break;
- case EmoteType::Mercenary:
- mercenaryHandler->emote(emote);
- break;
- }
- }
- }
-}
diff --git a/src/gui/shortcut/emoteshortcut.h b/src/gui/shortcut/emoteshortcut.h
deleted file mode 100644
index 2ecc2c1b7..000000000
--- a/src/gui/shortcut/emoteshortcut.h
+++ /dev/null
@@ -1,133 +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 GUI_SHORTCUT_EMOTESHORTCUT_H
-#define GUI_SHORTCUT_EMOTESHORTCUT_H
-
-#include "const/emoteshortcut.h"
-
-#include "utils/cast.h"
-
-#include "localconsts.h"
-
-/**
- * The class which keeps track of the emote shortcuts.
- */
-class EmoteShortcut final
-{
- public:
- /**
- * Constructor.
- */
- EmoteShortcut();
-
- A_DELETE_COPY(EmoteShortcut)
-
- /**
- * Destructor.
- */
- ~EmoteShortcut();
-
- /**
- * Load the configuration information.
- */
- void load();
-
- /**
- * Returns the shortcut Emote ID specified by the index.
- *
- * @param index Index of the shortcut Emote.
- */
- unsigned char getEmote(const size_t index) const A_WARN_UNUSED
- { return mEmotes[index]; }
-
- /**
- * Returns the amount of shortcut Emotes.
- */
- static unsigned int getEmoteCount() A_WARN_UNUSED
- { return SHORTCUT_EMOTES; }
-
- /**
- * Returns the emote ID that is currently selected.
- */
- unsigned char getEmoteSelected() const noexcept2 A_WARN_UNUSED
- { return mEmoteSelected; }
-
- /**
- * Adds the selected emote ID to the emotes specified by the index.
- *
- * @param index Index of the emotes.
- */
- void setEmote(const size_t index)
- { mEmotes[index] = mEmoteSelected; }
-
- /**
- * Adds a emoticon to the emotes store specified by the index.
- *
- * @param index Index of the emote.
- * @param emoteId ID of the emote.
- */
- void setEmotes(const size_t index,
- const unsigned char emoteId)
- { mEmotes[index] = emoteId; }
-
- /**
- * Set the Emote that is selected.
- *
- * @param emoteId The ID of the emote that is to be assigned.
- */
- void setEmoteSelected(const unsigned char emoteId)
- { mEmoteSelected = emoteId; }
-
- /**
- * A flag to check if the Emote is selected.
- */
- bool isEmoteSelected() const noexcept2 A_WARN_UNUSED
- { return mEmoteSelected != 0u; }
-
- /**
- * Remove a Emote from the shortcut.
- */
- void removeEmote(const size_t index)
- { if (index < CAST_SIZE(SHORTCUT_EMOTES)) mEmotes[index] = 0; }
-
- /**
- * Try to use the Emote specified by the index.
- *
- * @param index Index of the emote shortcut.
- */
- void useEmote(const size_t index) const;
-
- void useEmotePlayer(const size_t index) const;
-
- private:
- /**
- * Save the configuration information.
- */
- void save() const;
-
- unsigned char mEmotes[SHORTCUT_EMOTES]; // The emote stored.
- unsigned char mEmoteSelected; // The emote held by cursor.
-};
-
-extern EmoteShortcut *emoteShortcut;
-
-#endif // GUI_SHORTCUT_EMOTESHORTCUT_H
diff --git a/src/gui/shortcut/itemshortcut.cpp b/src/gui/shortcut/itemshortcut.cpp
deleted file mode 100644
index f47bfd296..000000000
--- a/src/gui/shortcut/itemshortcut.cpp
+++ /dev/null
@@ -1,289 +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 "gui/shortcut/itemshortcut.h"
-
-#include "configuration.h"
-#include "spellmanager.h"
-
-#include "being/playerinfo.h"
-
-#include "const/spells.h"
-
-#include "const/resources/skill.h"
-
-#include "gui/windows/skilldialog.h"
-
-#include "resources/inventory/inventory.h"
-
-#include "resources/item/item.h"
-
-#include "debug.h"
-
-ItemShortcut *itemShortcut[SHORTCUT_TABS];
-
-ItemShortcut::ItemShortcut(const size_t number) :
- mItems(),
- mItemColors(),
- mItemData(),
- mNumber(number),
- mItemSelected(-1),
- mItemColorSelected(ItemColor_one)
-{
- load();
-}
-
-ItemShortcut::~ItemShortcut()
-{
- logger->log1("ItemShortcut::~ItemShortcut");
-}
-
-void ItemShortcut::load()
-{
- std::string name;
- std::string color;
- std::string data;
- if (mNumber == SHORTCUT_AUTO_TAB)
- return;
-
- const Configuration *cfg = &serverConfig;
- if (mNumber != 0)
- {
- name = std::string("shortcut").append(
- toString(CAST_S32(mNumber))).append("_");
- color = std::string("shortcutColor").append(
- toString(CAST_U32(mNumber))).append("_");
- data = std::string("shortcutData").append(
- toString(CAST_U32(mNumber))).append("_");
- }
- else
- {
- name = "shortcut";
- color = "shortcutColor";
- data = "shortcutData";
- }
- for (unsigned int i = 0; i < SHORTCUT_ITEMS; i++)
- {
- const int itemId = cfg->getValue(name + toString(i), -1);
- const ItemColor itemColor = fromInt(
- cfg->getValue(color + toString(i), 1),
- ItemColor);
-
- mItems[i] = itemId;
- mItemColors[i] = itemColor;
- mItemData[i] = cfg->getValue(data + toString(i), std::string());
- }
-}
-
-void ItemShortcut::save() const
-{
- std::string name;
- std::string color;
- std::string data;
- if (mNumber == SHORTCUT_AUTO_TAB)
- return;
- if (mNumber != 0)
- {
- name = std::string("shortcut").append(
- toString(CAST_S32(mNumber))).append("_");
- color = std::string("shortcutColor").append(
- toString(CAST_U32(mNumber))).append("_");
- data = std::string("shortcutData").append(
- toString(CAST_U32(mNumber))).append("_");
- }
- else
- {
- name = "shortcut";
- color = "shortcutColor";
- data = "shortcutData";
- }
-
- for (unsigned int i = 0; i < SHORTCUT_ITEMS; i++)
- {
- const int itemId = mItems[i] != 0 ? mItems[i] : -1;
- const int itemColor = toInt(mItemColors[i], int);
- if (itemId != -1)
- {
- const std::string itemData = mItemData[i];
- serverConfig.setValue(name + toString(i), itemId);
- serverConfig.setValue(color + toString(i), itemColor);
- serverConfig.setValue(data + toString(i), itemData);
- }
- else
- {
- serverConfig.deleteKey(name + toString(i));
- serverConfig.deleteKey(color + toString(i));
- serverConfig.deleteKey(data + toString(i));
- }
- }
-}
-
-void ItemShortcut::clear()
-{
- for (size_t i = 0; i < SHORTCUT_ITEMS; i++)
- {
- mItems[i] = 0;
- mItemColors[i] = ItemColor_zero;
- mItemData[i].clear();
- }
-}
-
-void ItemShortcut::useItem(const size_t index) const
-{
- const Inventory *const inv = PlayerInfo::getInventory();
- if (inv == nullptr)
- return;
-
- const int itemId = mItems[index];
- const ItemColor itemColor = mItemColors[index];
- if (itemId >= 0)
- {
- if (itemId < SPELL_MIN_ID)
- {
- const Item *const item = inv->findItem(itemId, itemColor);
- if (item != nullptr && item->getQuantity() != 0)
- PlayerInfo::useEquipItem(item, 0, Sfx_true);
- }
- else if (itemId < SKILL_MIN_ID && (spellManager != nullptr))
- {
- spellManager->useItem(itemId);
- }
- else if (skillDialog != nullptr)
- {
- skillDialog->useItem(itemId,
- fromBool(config.getBoolValue("skillAutotarget"), AutoTarget),
- toInt(itemColor, int),
- mItemData[index]);
- }
- }
-}
-
-void ItemShortcut::equipItem(const size_t index) const
-{
- const Inventory *const inv = PlayerInfo::getInventory();
- if (inv == nullptr)
- return;
-
- const int itemId = mItems[index];
- if (itemId != 0)
- {
- const Item *const item = inv->findItem(itemId, mItemColors[index]);
- if ((item != nullptr) && (item->getQuantity() != 0))
- {
- if (item->isEquipment() == Equipm_true)
- {
- if (item->isEquipped() == Equipped_false)
- PlayerInfo::equipItem(item, Sfx_true);
- }
- }
- }
-}
-void ItemShortcut::unequipItem(const size_t index) const
-{
- const Inventory *const inv = PlayerInfo::getInventory();
- if (inv == nullptr)
- return;
-
- const int itemId = mItems[index];
- if (itemId != 0)
- {
- const Item *const item = inv->findItem(itemId, mItemColors[index]);
- if ((item != nullptr) && (item->getQuantity() != 0))
- {
- if (item->isEquipment() == Equipm_true)
- {
- if (item->isEquipped() == Equipped_true)
- PlayerInfo::unequipItem(item, Sfx_true);
- }
- }
- }
-}
-
-void ItemShortcut::setItemSelected(const Item *const item)
-{
- if (item != nullptr)
- {
- mItemSelected = item->getId();
- mItemColorSelected = item->getColor();
- }
- else
- {
- mItemSelected = -1;
- mItemColorSelected = ItemColor_one;
- }
-}
-
-void ItemShortcut::setItem(const size_t index)
-{
- mItems[index] = mItemSelected;
- mItemColors[index] = mItemColorSelected;
- save();
-}
-
-void ItemShortcut::setItem(const size_t index,
- const int item,
- const ItemColor color)
-{
- mItems[index] = item;
- mItemColors[index] = color;
- save();
-}
-
-void ItemShortcut::setItemFast(const size_t index,
- const int item,
- const ItemColor color)
-{
- mItems[index] = item;
- mItemColors[index] = color;
-}
-
-void ItemShortcut::swap(const size_t index1,
- const size_t index2)
-{
- if (CAST_U32(index1) >= SHORTCUT_ITEMS ||
- CAST_U32(index2) >= SHORTCUT_ITEMS)
- {
- return;
- }
-
- const int tmpItem = mItems[index1];
- mItems[index1] = mItems[index2];
- mItems[index2] = tmpItem;
- const ItemColor tmpColor = mItemColors[index1];
- mItemColors[index1] = mItemColors[index2];
- mItemColors[index2] = tmpColor;
-
- const std::string tmpData = mItemData[index1];
- mItemData[index1] = mItemData[index2];
- mItemData[index2] = tmpData;
- save();
-}
-
-size_t ItemShortcut::getFreeIndex() const
-{
- for (size_t i = 0; i < SHORTCUT_ITEMS; i++)
- {
- if (mItems[i] < 0)
- return i;
- }
- return SHORTCUT_ITEMS;
-}
diff --git a/src/gui/shortcut/itemshortcut.h b/src/gui/shortcut/itemshortcut.h
deleted file mode 100644
index 5e77e9152..000000000
--- a/src/gui/shortcut/itemshortcut.h
+++ /dev/null
@@ -1,183 +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 GUI_SHORTCUT_ITEMSHORTCUT_H
-#define GUI_SHORTCUT_ITEMSHORTCUT_H
-
-#include "const/itemshortcut.h"
-
-#include "enums/simpletypes/itemcolor.h"
-
-#include <string>
-
-#include "localconsts.h"
-
-class Item;
-
-/**
- * The class which keeps track of the item shortcuts.
- */
-class ItemShortcut final
-{
- public:
- /**
- * Constructor.
- */
- explicit ItemShortcut(const size_t number);
-
- A_DELETE_COPY(ItemShortcut)
-
- /**
- * Destructor.
- */
- ~ItemShortcut();
-
- /**
- * Load the configuration information.
- */
- void load();
-
- /**
- * Save the configuration information.
- */
- void save() const;
-
- /**
- * Returns the shortcut item ID specified by the index.
- *
- * @param index Index of the shortcut item.
- */
- int getItem(const size_t index) const A_WARN_UNUSED
- { return mItems[index]; }
-
- ItemColor getItemColor(const size_t index) const A_WARN_UNUSED
- { return mItemColors[index]; }
-
- void setItemData(const size_t index,
- const std::string &data)
- { mItemData[index] = data; }
-
- std::string getItemData(const size_t index) const A_WARN_UNUSED
- { return mItemData[index]; }
-
- /**
- * Returns the amount of shortcut items.
- */
- constexpr static int getItemCount() A_WARN_UNUSED
- { return SHORTCUT_ITEMS; }
-
- /**
- * Returns the item ID that is currently selected.
- */
- int getItemSelected() const noexcept2 A_WARN_UNUSED
- { return mItemSelected; }
-
- /**
- * Adds the selected item ID to the items specified by the index.
- *
- * @param index Index of the items.
- */
- void setItem(const size_t index);
-
- void setItem(const size_t index,
- const int item,
- const ItemColor color);
-
- void setItemFast(const size_t index,
- const int item,
- const ItemColor color);
-
- /**
- * Adds an item to the items store specified by the index.
- *
- * @param index Index of the item.
- * @param itemId ID of the item.
- */
- void setItems(const size_t index,
- const int itemId,
- const ItemColor color)
- { mItems[index] = itemId; mItemColors[index] = color; save(); }
-
- /**
- * Set the item that is selected.
- *
- * @param itemId The ID of the item that is to be assigned.
- */
- void setItemSelected(const int itemId)
- { mItemSelected = itemId; }
-
- void setItemSelected(const Item *const item);
-
- /**
- * Returns selected shortcut item ID.
- */
- int getSelectedItem() const noexcept2 A_WARN_UNUSED
- { return mItemSelected; }
-
- /**
- * A flag to check if the item is selected.
- */
- bool isItemSelected() const noexcept2 A_WARN_UNUSED
- { return mItemSelected > -1; }
-
- /**
- * Remove a item from the shortcut.
- */
- void removeItem(const size_t index)
- { mItems[index] = -1; save(); }
-
- /**
- * Try to use the item specified by the index.
- *
- * @param index Index of the item shortcut.
- */
- void useItem(const size_t index) const;
-
- /**
- * Equip a item from the shortcut.
- */
- void equipItem(const size_t index) const;
-
- /**
- * UnEquip a item from the shortcut.
- */
- void unequipItem(const size_t index) const;
-
- void swap(const size_t index1,
- const size_t index2);
-
- void clear();
-
- size_t getFreeIndex() const A_WARN_UNUSED;
-
- private:
- int mItems[SHORTCUT_ITEMS]; /**< The items. */
- ItemColor mItemColors[SHORTCUT_ITEMS]; /**< The item colors. */
- std::string mItemData[SHORTCUT_ITEMS];
- size_t mNumber;
- int mItemSelected;
- ItemColor mItemColorSelected;
-};
-
-extern ItemShortcut *itemShortcut[SHORTCUT_TABS];
-
-#endif // GUI_SHORTCUT_ITEMSHORTCUT_H
diff --git a/src/gui/shortcut/shortcutbase.cpp b/src/gui/shortcut/shortcutbase.cpp
deleted file mode 100644
index 489805517..000000000
--- a/src/gui/shortcut/shortcutbase.cpp
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 Andrei Karas
- * 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 "gui/shortcut/shortcutbase.h"
-
-#include "configuration.h"
-
-#include "resources/item/item.h"
-
-#include "debug.h"
-
-ShortcutBase::ShortcutBase(const std::string &itemName,
- const std::string &colorName,
- const int maxSize) :
- mItems(new int[maxSize]),
- mItemColors(new ItemColor[maxSize]),
- mItemName(itemName),
- mColorName(colorName),
- mMaxSize(maxSize),
- mItemSelected(-1),
- mItemColorSelected(ItemColor_one)
-{
- clear(false);
- load();
-}
-
-ShortcutBase::~ShortcutBase()
-{
- delete [] mItems;
- mItems = nullptr;
- delete [] mItemColors;
- mItemColors = nullptr;
-}
-
-void ShortcutBase::load()
-{
- const Configuration *cfg = &serverConfig;
-
- for (size_t i = 0; i < mMaxSize; i++)
- {
- const std::string num = toString(CAST_S32(i));
- const int itemId = cfg->getValue(mItemName + num, -1);
- const ItemColor itemColor = fromInt(
- cfg->getValue(mColorName + num, -1),
- ItemColor);
-
- if (itemId != -1)
- {
- mItems[i] = itemId;
- mItemColors[i] = itemColor;
- }
- }
-}
-
-void ShortcutBase::save() const
-{
- for (size_t i = 0; i < mMaxSize; i++)
- {
- const int itemId = mItems[i] != 0 ? mItems[i] : -1;
- const int itemColor = (mItemColors[i] != ItemColor_zero)
- ? toInt(mItemColors[i], int) : 1;
- const std::string num = toString(CAST_S32(i));
- if (itemId != -1)
- {
- serverConfig.setValue(mItemName + num, itemId);
- serverConfig.setValue(mColorName + num, itemColor);
- }
- else
- {
- serverConfig.deleteKey(mItemName + num);
- serverConfig.deleteKey(mColorName + num);
- }
- }
-}
-
-void ShortcutBase::setItemSelected(const Item *const item)
-{
- if (item != nullptr)
- {
- mItemSelected = item->getId();
- mItemColorSelected = item->getColor();
- }
- else
- {
- mItemSelected = -1;
- mItemColorSelected = ItemColor_one;
- }
-}
-
-void ShortcutBase::setItem(const size_t index)
-{
- if (index >= mMaxSize)
- return;
-
- mItems[index] = mItemSelected;
- mItemColors[index] = mItemColorSelected;
- save();
-}
-
-void ShortcutBase::clear(const bool isSave)
-{
- for (size_t i = 0; i < mMaxSize; i++)
- {
- mItems[i] = -1;
- mItemColors[i] = ItemColor_one;
- }
- if (isSave)
- save();
-}
diff --git a/src/gui/shortcut/shortcutbase.h b/src/gui/shortcut/shortcutbase.h
deleted file mode 100644
index 90ca41ee7..000000000
--- a/src/gui/shortcut/shortcutbase.h
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 Andrei Karas
- * 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_SHORTCUT_SHORTCUTBASE_H
-#define GUI_SHORTCUT_SHORTCUTBASE_H
-
-#include "enums/simpletypes/itemcolor.h"
-
-#include "utils/cast.h"
-
-#include <string>
-
-#include "localconsts.h"
-
-class Item;
-
-/**
- * The class which keeps track of the item shortcuts.
- */
-class ShortcutBase notfinal
-{
- public:
- /**
- * Constructor.
- */
- ShortcutBase(const std::string &itemName,
- const std::string &colorName,
- const int maxSize);
-
- A_DELETE_COPY(ShortcutBase)
-
- /**
- * Destructor.
- */
- virtual ~ShortcutBase();
-
- /**
- * Load the configuration information.
- */
- void load();
-
- /**
- * Save the configuration information.
- */
- void save() const;
-
- /**
- * Returns the shortcut item ID specified by the index.
- *
- * @param index Index of the shortcut item.
- */
- int getItem(const size_t index) const A_WARN_UNUSED
- { return mItems[index]; }
-
- ItemColor getItemColor(const size_t index) const A_WARN_UNUSED
- { return mItemColors[index]; }
-
- /**
- * Returns the amount of shortcut items.
- */
- int getItemCount() const noexcept2 A_WARN_UNUSED
- { return CAST_S32(mMaxSize); }
-
- /**
- * Returns the item ID that is currently selected.
- */
- int getItemSelected() const noexcept2 A_WARN_UNUSED
- { return mItemSelected; }
-
- /**
- * Adds the selected item ID to the items specified by the index.
- *
- * @param index Index of the items.
- */
- void setItem(const size_t index);
-
- /**
- * Adds an item to the items store specified by the index.
- *
- * @param index Index of the item.
- * @param itemId ID of the item.
- */
- void setItems(const size_t index,
- const int itemId,
- const ItemColor color)
- { mItems[index] = itemId; mItemColors[index] = color; save(); }
-
- /**
- * Set the item that is selected.
- *
- * @param itemId The ID of the item that is to be assigned.
- */
- void setItemSelected(const int itemId)
- { mItemSelected = itemId; }
-
- void setItemSelected(const Item *const item);
-
- /**
- * A flag to check if the item is selected.
- */
- bool isItemSelected() const noexcept2 A_WARN_UNUSED
- { return mItemSelected > -1; }
-
- /**
- * Remove a item from the shortcut.
- */
- void removeItem(const size_t index)
- { mItems[index] = -1; save(); }
-
- void clear(const bool isSave = true);
-
- private:
- int *mItems A_NONNULLPOINTER;
- ItemColor *mItemColors A_NONNULLPOINTER;
- std::string mItemName;
- std::string mColorName;
- size_t mMaxSize;
- int mItemSelected;
- ItemColor mItemColorSelected;
-};
-
-#endif // GUI_SHORTCUT_SHORTCUTBASE_H
diff --git a/src/gui/shortcut/spellshortcut.cpp b/src/gui/shortcut/spellshortcut.cpp
deleted file mode 100644
index 14eaa2f48..000000000
--- a/src/gui/shortcut/spellshortcut.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 Andrei Karas
- * 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 "gui/shortcut/spellshortcut.h"
-
-#include "spellmanager.h"
-#include "textcommand.h"
-
-#include "debug.h"
-
-SpellShortcut *spellShortcut = nullptr;
-
-SpellShortcut::SpellShortcut() :
- mItemSelected(-1)
-{
- load();
-}
-
-SpellShortcut::~SpellShortcut()
-{
-}
-
-void SpellShortcut::load()
-{
- for (unsigned f = 0; f < SPELLS_SIZE; f ++)
- mItems[f] = -1;
-
- if (spellManager == nullptr)
- return;
-
- const STD_VECTOR<TextCommand*> &spells = spellManager->getAll();
- unsigned k = 0;
-
- for (STD_VECTOR<TextCommand*>::const_iterator i = spells.begin(),
- i_end = spells.end(); i != i_end && k < SPELLS_SIZE; ++i)
- {
- mItems[k++] = (*i)->getId();
- }
-}
-
-unsigned int SpellShortcut::getSpellsCount() const
-{
- return SPELL_SHORTCUT_ITEMS;
-}
diff --git a/src/gui/shortcut/spellshortcut.h b/src/gui/shortcut/spellshortcut.h
deleted file mode 100644
index 4eab518a6..000000000
--- a/src/gui/shortcut/spellshortcut.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 Andrei Karas
- * 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_SHORTCUT_SPELLSHORTCUT_H
-#define GUI_SHORTCUT_SPELLSHORTCUT_H
-
-#include "const/spells.h"
-
-/**
- * The class which keeps track of the item shortcuts.
- */
-class SpellShortcut final
-{
- public:
- /**
- * Constructor.
- */
- SpellShortcut();
-
- A_DELETE_COPY(SpellShortcut)
-
- /**
- * Destructor.
- */
- ~SpellShortcut() A_CONST;
-
- /**
- * Load the configuration information.
- */
- void load();
-
- unsigned int getSpellsCount() const A_CONST A_WARN_UNUSED;
-
- /**
- * Set the item that is selected.
- *
- * @param itemId The ID of the item that is to be assigned.
- */
- void setItemSelected(const int itemId) noexcept2
- { mItemSelected = itemId; }
-
- /**
- * A flag to check if the item is selected.
- */
- bool isItemSelected() const noexcept2 A_WARN_UNUSED
- { return mItemSelected > -1; }
-
- /**
- * Returns selected shortcut item ID.
- */
- int getSelectedItem() const noexcept2 A_WARN_UNUSED
- { return mItemSelected; }
-
- /**
- * Returns the shortcut item ID specified by the index.
- *
- * @param index Index of the shortcut item.
- */
- int getItem(const size_t index) const
- { return mItems[index]; }
-
- private:
- int mItems[SPELLS_SIZE];
- int mItemSelected; /**< The item held by cursor. */
-};
-
-extern SpellShortcut *spellShortcut;
-
-#endif // GUI_SHORTCUT_SPELLSHORTCUT_H
diff --git a/src/gui/skin.cpp b/src/gui/skin.cpp
deleted file mode 100644
index 45317fa0d..000000000
--- a/src/gui/skin.cpp
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 The Legend of Mazzeroth Development Team
- * Copyright (C) 2009 Aethyra Development Team
- * 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 "gui/skin.h"
-
-#include "settings.h"
-
-#include "enums/resources/imageposition.h"
-
-#include "resources/imagerect.h"
-
-#include "resources/image/image.h"
-
-#include "utils/delete2.h"
-
-#include "debug.h"
-
-Skin::Skin(ImageRect *const restrict skin,
- const ImageRect *const restrict images,
- const std::string &filePath, const std::string &name,
- const int padding, const int titlePadding,
- StringIntMap *restrict const options) :
- instances(1),
- mFilePath(filePath),
- mName(name),
- mBorder(skin),
- mCloseImage(images != nullptr ? images->grid[0] : nullptr),
- mCloseImageHighlighted(images != nullptr ? images->grid[1] : nullptr),
- mStickyImageUp(images != nullptr ? images->grid[2] : nullptr),
- mStickyImageDown(images != nullptr ? images->grid[3] : nullptr),
- mPadding(padding),
- mTitlePadding(titlePadding),
- mOptions(options)
-{
- if (mCloseImageHighlighted == nullptr)
- {
- mCloseImageHighlighted = mCloseImage;
- if (mCloseImageHighlighted != nullptr)
- mCloseImageHighlighted->incRef();
- }
-}
-
-Skin::~Skin()
-{
- for (int i = 0; i < 9; i++)
- {
- if ((mBorder != nullptr) && (mBorder->grid[i] != nullptr))
- {
- mBorder->grid[i]->decRef();
- mBorder->grid[i] = nullptr;
- }
- }
-
- if (mCloseImage != nullptr)
- {
- mCloseImage->decRef();
- mCloseImage = nullptr;
- }
-
- if (mCloseImageHighlighted != nullptr)
- {
- mCloseImageHighlighted->decRef();
- mCloseImageHighlighted = nullptr;
- }
-
- if (mStickyImageUp != nullptr)
- {
- mStickyImageUp->decRef();
- mStickyImageUp = nullptr;
- }
-
- if (mStickyImageDown != nullptr)
- {
- mStickyImageDown->decRef();
- mStickyImageDown = nullptr;
- }
-
- delete2(mOptions);
- delete2(mBorder);
-}
-
-void Skin::updateAlpha(const float minimumOpacityAllowed)
-{
- const float alpha = static_cast<float>(
- std::max(static_cast<double>(minimumOpacityAllowed),
- static_cast<double>(settings.guiAlpha)));
-
- if (mBorder != nullptr)
- {
- for (int i = 0; i < 9; i++)
- {
- if (mBorder->grid[i] != nullptr)
- mBorder->grid[i]->setAlpha(alpha);
- }
- }
-
- if (mCloseImage != nullptr)
- mCloseImage->setAlpha(alpha);
- if (mCloseImageHighlighted != nullptr)
- mCloseImageHighlighted->setAlpha(alpha);
- if (mStickyImageUp != nullptr)
- mStickyImageUp->setAlpha(alpha);
- if (mStickyImageDown != nullptr)
- mStickyImageDown->setAlpha(alpha);
-}
-
-int Skin::getMinWidth() const
-{
- if ((mBorder == nullptr) ||
- (mBorder->grid[ImagePosition::UPPER_LEFT] == nullptr) ||
- (mBorder->grid[ImagePosition::UPPER_RIGHT] == nullptr))
- {
- return 1;
- }
-
- return mBorder->grid[ImagePosition::UPPER_LEFT]->getWidth() +
- mBorder->grid[ImagePosition::UPPER_RIGHT]->getWidth();
-}
-
-int Skin::getMinHeight() const
-{
- if ((mBorder == nullptr) ||
- (mBorder->grid[ImagePosition::UPPER_LEFT] == nullptr) ||
- (mBorder->grid[ImagePosition::LOWER_LEFT] == nullptr))
- {
- return 1;
- }
-
- return mBorder->grid[ImagePosition::UPPER_LEFT]->getHeight() +
- mBorder->grid[ImagePosition::LOWER_LEFT]->getHeight();
-}
diff --git a/src/gui/skin.h b/src/gui/skin.h
deleted file mode 100644
index acba303ac..000000000
--- a/src/gui/skin.h
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 The Legend of Mazzeroth Development Team
- * Copyright (C) 2009 Aethyra Development Team
- * 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 GUI_SKIN_H
-#define GUI_SKIN_H
-
-#include "utils/stringmap.h"
-
-#include "localconsts.h"
-
-class Image;
-class ImageRect;
-
-class Skin final
-{
- public:
- Skin(ImageRect *const restrict skin,
- const ImageRect *const restrict images,
- const std::string &filePath,
- const std::string &name,
- const int padding,
- const int titlePadding,
- StringIntMap *restrict const options) A_NONNULL(8);
-
- A_DELETE_COPY(Skin)
-
- ~Skin();
-
- /**
- * Returns the skin's name. Useful for giving a human friendly skin
- * name if a dialog for skin selection for a specific window type is
- * done.
- */
- const std::string &getName() const noexcept2 A_WARN_UNUSED
- { return mName; }
-
- /**
- * Returns the skin's xml file path.
- */
- const std::string &getFilePath() const noexcept2 A_WARN_UNUSED
- { return mFilePath; }
-
- /**
- * Returns the background skin.
- */
- const ImageRect &getBorder() const noexcept2 A_WARN_UNUSED
- { return *mBorder; }
-
- /**
- * Returns the image used by a close button for this skin.
- */
- const Image *getCloseImage(const bool state) const
- noexcept2 A_WARN_UNUSED
- { return state ? mCloseImageHighlighted : mCloseImage; }
-
- /**
- * Returns the image used by a sticky button for this skin.
- */
- const Image *getStickyImage(const bool state) const
- noexcept2 A_WARN_UNUSED
- { return state ? mStickyImageDown : mStickyImageUp; }
-
- /**
- * Returns the minimum width which can be used with this skin.
- */
- int getMinWidth() const A_WARN_UNUSED;
-
- /**
- * Returns the minimum height which can be used with this skin.
- */
- int getMinHeight() const A_WARN_UNUSED;
-
- /**
- * Updates the alpha value of the skin
- */
- void updateAlpha(const float minimumOpacityAllowed = 0.0F);
-
- int getPadding() const noexcept2 A_WARN_UNUSED
- { return mPadding; }
-
- int getTitlePadding() const noexcept2 A_WARN_UNUSED
- { return mTitlePadding; }
-
- int getOption(const std::string &name) const A_WARN_UNUSED
- {
- if (mOptions->find(name) != mOptions->end())
- return (*mOptions)[name];
- return 0;
- }
-
- int getOption(const std::string &name,
- const int def) const A_WARN_UNUSED
- {
- if (mOptions->find(name) != mOptions->end())
- return (*mOptions)[name];
- return def;
- }
-
- int instances;
-
- private:
- std::string mFilePath; /**< File name path for the skin */
- std::string mName; /**< Name of the skin to use */
- ImageRect *mBorder; /**< The window border and background */
- Image *mCloseImage; /**< Close Button Image */
- Image *mCloseImageHighlighted; /**< Highlighted close Button Image */
- Image *mStickyImageUp; /**< Sticky Button Image */
- Image *mStickyImageDown; /**< Sticky Button Image */
- int mPadding;
- int mTitlePadding;
- StringIntMap *mOptions A_NONNULLPOINTER;
-};
-
-#endif // GUI_SKIN_H
diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp
deleted file mode 100644
index cbc0d654c..000000000
--- a/src/gui/theme.cpp
+++ /dev/null
@@ -1,1283 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 The Legend of Mazzeroth Development Team
- * Copyright (C) 2009 Aethyra Development Team
- * 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 "gui/theme.h"
-
-#include "configuration.h"
-#include "graphicsmanager.h"
-
-#include "const/gui/theme.h"
-
-#include "fs/virtfs/fs.h"
-#include "fs/virtfs/list.h"
-
-#include "gui/skin.h"
-#include "gui/themeinfo.h"
-
-#include "resources/imagerect.h"
-
-#include "resources/dye/dyepalette.h"
-
-#include "resources/image/image.h"
-
-#include "resources/loaders/imageloader.h"
-#include "resources/loaders/imagesetloader.h"
-#include "resources/loaders/subimageloader.h"
-#include "resources/loaders/subimagesetloader.h"
-#include "resources/loaders/xmlloader.h"
-
-#include "utils/dtor.h"
-#include "utils/foreach.h"
-
-#include "debug.h"
-
-static std::string defaultThemePath;
-
-std::string Theme::mThemePath;
-std::string Theme::mThemeName;
-std::string Theme::mScreenDensity;
-
-Theme *theme = nullptr;
-
-// Set the theme path...
-static void initDefaultThemePath()
-{
- defaultThemePath = branding.getStringValue("guiThemePath");
-
- logger->log("defaultThemePath: " + defaultThemePath);
- if (!defaultThemePath.empty() &&
- VirtFs::isDirectory(defaultThemePath))
- {
- return;
- }
- defaultThemePath = "themes/";
-}
-
-Theme::Theme() :
- Palette(CAST_S32(ThemeColorId::THEME_COLORS_END) * THEME_PALETTES),
- mSkins(),
- mMinimumOpacity(-1.0F),
- mProgressColors(ProgressColors(CAST_SIZE(
- ProgressColorId::THEME_PROG_END)))
-{
- initDefaultThemePath();
-
- config.addListener("guialpha", this);
-
- mColors[CAST_SIZE(ThemeColorId::HIGHLIGHT)].ch = 'H';
- mColors[CAST_SIZE(ThemeColorId::CHAT)].ch = 'C';
- mColors[CAST_SIZE(ThemeColorId::GM)].ch = 'G';
- mColors[CAST_SIZE(ThemeColorId::GLOBAL)].ch = 'g';
- mColors[CAST_SIZE(ThemeColorId::PLAYER)].ch = 'Y';
- mColors[CAST_SIZE(ThemeColorId::WHISPER_TAB)].ch = 'W';
- mColors[CAST_SIZE(ThemeColorId::WHISPER_TAB_OFFLINE)].ch = 'w';
- mColors[CAST_SIZE(ThemeColorId::IS)].ch = 'I';
- mColors[CAST_SIZE(ThemeColorId::PARTY_CHAT_TAB)].ch = 'P';
- mColors[CAST_SIZE(ThemeColorId::GUILD_CHAT_TAB)].ch = 'U';
- mColors[CAST_SIZE(ThemeColorId::SERVER)].ch = 'S';
- mColors[CAST_SIZE(ThemeColorId::LOGGER)].ch = 'L';
- mColors[CAST_SIZE(ThemeColorId::HYPERLINK)].ch = '<';
- mColors[CAST_SIZE(ThemeColorId::SELFNICK)].ch = 's';
- mColors[CAST_SIZE(ThemeColorId::OLDCHAT)].ch = 'o';
- mColors[CAST_SIZE(ThemeColorId::AWAYCHAT)].ch = 'a';
- mCharColors['H'] = CAST_S32(ThemeColorId::HIGHLIGHT);
- mCharColors['C'] = CAST_S32(ThemeColorId::CHAT);
- mCharColors['G'] = CAST_S32(ThemeColorId::GM);
- mCharColors['g'] = CAST_S32(ThemeColorId::GLOBAL);
- mCharColors['Y'] = CAST_S32(ThemeColorId::PLAYER);
- mCharColors['W'] = CAST_S32(ThemeColorId::WHISPER_TAB);
- mCharColors['w'] = CAST_S32(ThemeColorId::WHISPER_TAB_OFFLINE);
- mCharColors['I'] = CAST_S32(ThemeColorId::IS);
- mCharColors['P'] = CAST_S32(ThemeColorId::PARTY_CHAT_TAB);
- mCharColors['U'] = CAST_S32(ThemeColorId::GUILD_CHAT_TAB);
- mCharColors['S'] = CAST_S32(ThemeColorId::SERVER);
- mCharColors['L'] = CAST_S32(ThemeColorId::LOGGER);
- mCharColors['<'] = CAST_S32(ThemeColorId::HYPERLINK);
- mCharColors['s'] = CAST_S32(ThemeColorId::SELFNICK);
- mCharColors['o'] = CAST_S32(ThemeColorId::OLDCHAT);
- mCharColors['a'] = CAST_S32(ThemeColorId::AWAYCHAT);
-
- // here need use outlined colors
- mCharColors['H' | 0x80]
- = CAST_S32(ThemeColorId::HIGHLIGHT_OUTLINE);
- mCharColors['C' | 0x80] = CAST_S32(ThemeColorId::CHAT_OUTLINE);
- mCharColors['G' | 0x80] = CAST_S32(ThemeColorId::GM_OUTLINE);
- mCharColors['g' | 0x80] = CAST_S32(ThemeColorId::GLOBAL_OUTLINE);
- mCharColors['Y' | 0x80] = CAST_S32(ThemeColorId::PLAYER_OUTLINE);
- mCharColors['W' | 0x80]
- = CAST_S32(ThemeColorId::WHISPER_TAB_OUTLINE);
- mCharColors['w' | 0x80]
- = CAST_S32(ThemeColorId::WHISPER_TAB_OFFLINE_OUTLINE);
- mCharColors['I' | 0x80] = CAST_S32(ThemeColorId::IS_OUTLINE);
- mCharColors['P' | 0x80]
- = CAST_S32(ThemeColorId::PARTY_CHAT_TAB_OUTLINE);
- mCharColors['U' | 0x80]
- = CAST_S32(ThemeColorId::GUILD_CHAT_TAB_OUTLINE);
- mCharColors['S' | 0x80] = CAST_S32(ThemeColorId::SERVER_OUTLINE);
- mCharColors['L' | 0x80] = CAST_S32(ThemeColorId::LOGGER_OUTLINE);
- mCharColors['<' | 0x80]
- = CAST_S32(ThemeColorId::HYPERLINK_OUTLINE);
- mCharColors['s' | 0x80] = CAST_S32(ThemeColorId::SELFNICK_OUTLINE);
- mCharColors['o' | 0x80] = CAST_S32(ThemeColorId::OLDCHAT_OUTLINE);
- mCharColors['a' | 0x80] = CAST_S32(ThemeColorId::AWAYCHAT_OUTLINE);
-}
-
-Theme::~Theme()
-{
- delete_all(mSkins);
- config.removeListener("guialpha", this);
- CHECKLISTENERS
- delete_all(mProgressColors);
-}
-
-Color Theme::getProgressColor(const ProgressColorIdT type,
- const float progress)
-{
- int color[3] = {0, 0, 0};
-
- if (theme != nullptr)
- {
- const DyePalette *const dye
- = theme->mProgressColors[CAST_SIZE(type)];
-
- if (dye != nullptr)
- {
- dye->getColor(progress, color);
- }
- else
- {
- logger->log("color not found: "
- + toString(CAST_S32(type)));
- }
- }
-
- return Color(color[0], color[1], color[2]);
-}
-
-Skin *Theme::load(const std::string &filename,
- const std::string &filename2,
- const bool full,
- const std::string &restrict defaultPath)
-{
- // Check if this skin was already loaded
-
- const SkinIterator skinIterator = mSkins.find(filename);
- if (mSkins.end() != skinIterator)
- {
- if (skinIterator->second != nullptr)
- skinIterator->second->instances++;
- return skinIterator->second;
- }
-
- Skin *skin = nullptr;
- if (mScreenDensity.empty())
- { // if no density detected
- skin = readSkin(filename, full);
- if ((skin == nullptr) && !filename2.empty() && filename2 != filename)
- skin = readSkin(filename2, full);
- if ((skin == nullptr) && filename2 != "window.xml")
- skin = readSkin("window.xml", full);
- }
- else
- { // first use correct density images
- const std::string endStr("_" + mScreenDensity + ".xml");
- std::string name = filename;
- if (findCutLast(name, ".xml"))
- skin = readSkin(name + endStr, full);
- if (skin == nullptr)
- skin = readSkin(filename, full);
- if ((skin == nullptr) && !filename2.empty() && filename2 != filename)
- {
- name = filename2;
- if (findCutLast(name, ".xml"))
- skin = readSkin(name + endStr, full);
- if (skin == nullptr)
- skin = readSkin(filename2, full);
- }
- if ((skin == nullptr) && filename2 != "window.xml")
- {
- skin = readSkin("window" + endStr, full);
- if (skin == nullptr)
- skin = readSkin("window.xml", full);
- }
- }
-
- if (skin == nullptr)
- {
- // Try falling back on the defaultPath if this makes sense
- if (filename != defaultPath)
- {
- logger->log("Error loading skin '%s', falling back on default.",
- filename.c_str());
-
- skin = readSkin(defaultPath, full);
- }
-
- if (skin == nullptr)
- {
- logger->log(strprintf("Error: Loading default skin '%s' failed. "
- "Make sure the skin file is valid.",
- defaultPath.c_str()));
- }
- }
-
- mSkins[filename] = skin;
- return skin;
-}
-
-void Theme::unload(Skin *const skin)
-{
- if (skin == nullptr)
- return;
- skin->instances --;
- if (skin->instances == 0)
- {
- SkinIterator it = mSkins.begin();
- const SkinIterator it_end = mSkins.end();
- while (it != it_end)
- {
- if (it->second == skin)
- {
- mSkins.erase(it);
- break;
- }
- ++ it;
- }
- delete skin;
- }
-}
-
-void Theme::setMinimumOpacity(const float minimumOpacity)
-{
- if (minimumOpacity > 1.0F)
- return;
-
- mMinimumOpacity = minimumOpacity;
- updateAlpha();
-}
-
-void Theme::updateAlpha()
-{
- FOR_EACH (SkinIterator, iter, mSkins)
- {
- Skin *const skin = iter->second;
- if (skin != nullptr)
- skin->updateAlpha(mMinimumOpacity);
- }
-}
-
-void Theme::optionChanged(const std::string &name A_UNUSED)
-{
- updateAlpha();
-}
-
-struct SkinParameter final
-{
- A_DEFAULT_COPY(SkinParameter)
- int index;
- std::string name;
-};
-
-static const SkinParameter skinParam[] =
-{
- {0, "top-left-corner"},
- {0, "standart"},
- {0, "up"},
- {0, "hstart"},
- {0, "in"},
- {0, "normal"},
- {1, "top-edge"},
- {1, "highlighted"},
- {1, "down"},
- {1, "hmiddle"},
- {1, "in-highlighted"},
- {1, "checked"},
- {2, "top-right-corner"},
- {2, "pressed"},
- {2, "left"},
- {2, "hend"},
- {2, "out"},
- {2, "disabled"},
- {3, "left-edge"},
- {3, "disabled"},
- {3, "right"},
- {3, "hgrip"},
- {3, "out-highlighted"},
- {3, "disabled-checked"},
- {4, "bg-quad"},
- {4, "vstart"},
- {4, "normal-highlighted"},
- {5, "right-edge"},
- {5, "vmiddle"},
- {5, "checked-highlighted"},
- {6, "bottom-left-corner"},
- {6, "vend"},
- {7, "bottom-edge"},
- {7, "vgrip"},
- {8, "bottom-right-corner"},
-};
-
-static const SkinParameter imageParam[] =
-{
- {0, "closeImage"},
- {1, "closeImageHighlighted"},
- {2, "stickyImageUp"},
- {3, "stickyImageDown"},
-};
-
-struct SkinHelper final
-{
- SkinHelper() :
- partType(),
- xPos(),
- yPos(),
- width(),
- height(),
- rect(),
- node(),
- image()
- {
- }
-
- A_DELETE_COPY(SkinHelper)
-
- std::string partType;
- int xPos;
- int yPos;
- int width;
- int height;
- ImageRect *rect;
- XmlNodePtr *node;
- Image *image;
-
- bool loadList(const SkinParameter *const params,
- const size_t size) A_NONNULL(2)
- {
- for (size_t f = 0; f < size; f ++)
- {
- const SkinParameter &param = params[f];
- if (partType == param.name)
- {
- rect->grid[param.index] = Loader::getSubImage(
- image,
- xPos, yPos,
- width, height);
- return true;
- }
- }
- return false;
- }
-};
-
-Skin *Theme::readSkin(const std::string &filename, const bool full)
-{
- if (filename.empty())
- return nullptr;
-
- const std::string path = resolveThemePath(filename);
- if (!VirtFs::exists(path))
- return nullptr;
- XML::Document *const doc = Loader::getXml(path,
- UseVirtFs_true,
- SkipError_true);
- if (doc == nullptr)
- return nullptr;
- XmlNodeConstPtr rootNode = doc->rootNode();
- if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "skinset"))
- {
- doc->decRef();
- return nullptr;
- }
-
- const std::string skinSetImage = XML::getProperty(rootNode, "image", "");
-
- if (skinSetImage.empty())
- {
- logger->log1("Theme::readSkin(): Skinset does not define an image!");
- doc->decRef();
- return nullptr;
- }
-
- Image *const dBorders = Theme::getImageFromTheme(skinSetImage);
- ImageRect *const border = new ImageRect;
- ImageRect *const images = new ImageRect;
- int padding = 3;
- int titlePadding = 4;
- int titlebarHeight = 0;
- int titlebarHeightRelative = 0;
- int closePadding = 3;
- int stickySpacing = 3;
- int stickyPadding = 3;
- int resizePadding = 2;
- StringIntMap *const mOptions = new StringIntMap;
-
- // iterate <widget>'s
- for_each_xml_child_node(widgetNode, rootNode)
- {
- if (!xmlNameEqual(widgetNode, "widget"))
- continue;
-
- const std::string widgetType =
- XML::getProperty(widgetNode, "type", "unknown");
- if (widgetType == "Window")
- {
- SkinHelper helper;
- const int globalXPos = XML::getProperty(widgetNode, "xpos", 0);
- const int globalYPos = XML::getProperty(widgetNode, "ypos", 0);
- for_each_xml_child_node(partNode, widgetNode)
- {
- if (xmlNameEqual(partNode, "part"))
- {
- helper.partType = XML::getProperty(
- partNode, "type", "unknown");
- helper.xPos = XML::getProperty(
- partNode, "xpos", 0) + globalXPos;
- helper.yPos = XML::getProperty(
- partNode, "ypos", 0) + globalYPos;
- helper.width = XML::getProperty(partNode, "width", 0);
- helper.height = XML::getProperty(partNode, "height", 0);
- if ((helper.width == 0) || (helper.height == 0))
- continue;
- helper.image = dBorders;
-
- helper.rect = border;
- if (!helper.loadList(skinParam,
- sizeof(skinParam) / sizeof(SkinParameter)))
- {
- helper.rect = images;
- helper.loadList(imageParam,
- sizeof(imageParam) / sizeof(SkinParameter));
- }
- }
- else if (full && xmlNameEqual(partNode, "option"))
- {
- const std::string name = XML::getProperty(
- partNode, "name", "");
- if (name == "padding")
- {
- padding = XML::getProperty(partNode, "value", 3);
- }
- else if (name == "titlePadding")
- {
- titlePadding = XML::getProperty(partNode, "value", 4);
- }
- else if (name == "closePadding")
- {
- closePadding = XML::getProperty(partNode, "value", 3);
- }
- else if (name == "stickySpacing")
- {
- stickySpacing = XML::getProperty(partNode, "value", 3);
- }
- else if (name == "stickyPadding")
- {
- stickyPadding = XML::getProperty(partNode, "value", 3);
- }
- else if (name == "titlebarHeight")
- {
- titlebarHeight = XML::getProperty(
- partNode, "value", 0);
- }
- else if (name == "titlebarHeightRelative")
- {
- titlebarHeightRelative = XML::getProperty(
- partNode, "value", 0);
- }
- else if (name == "resizePadding")
- {
- resizePadding = XML::getProperty(
- partNode, "value", 2);
- }
- else
- {
- (*mOptions)[name] = XML::getProperty(
- partNode, "value", 0);
- }
- }
- }
- }
- else
- {
- logger->log("Theme::readSkin(): Unknown widget type '%s'",
- widgetType.c_str());
- }
- }
-
- if (dBorders != nullptr)
- dBorders->decRef();
-
- (*mOptions)["closePadding"] = closePadding;
- (*mOptions)["stickyPadding"] = stickyPadding;
- (*mOptions)["stickySpacing"] = stickySpacing;
- (*mOptions)["titlebarHeight"] = titlebarHeight;
- (*mOptions)["titlebarHeightRelative"] = titlebarHeightRelative;
- (*mOptions)["resizePadding"] = resizePadding;
-
- Skin *const skin = new Skin(border, images, filename, "", padding,
- titlePadding, mOptions);
- delete images;
- skin->updateAlpha(mMinimumOpacity);
- doc->decRef();
- return skin;
-}
-
-bool Theme::tryThemePath(const std::string &themeName)
-{
- if (!themeName.empty())
- {
- const std::string path = defaultThemePath + themeName;
- if (VirtFs::exists(path))
- {
- mThemePath = path;
- mThemeName = themeName;
- if (theme != nullptr)
- theme->loadColors("");
- return true;
- }
- }
-
- return false;
-}
-
-void Theme::fillSkinsList(StringVect &list)
-{
- VirtFs::getDirs(branding.getStringValue("guiThemePath"), list);
- std::sort(list.begin(), list.end());
-}
-
-void Theme::fillFontsList(StringVect &list)
-{
- VirtFs::permitLinks(true);
- VirtFs::getFiles(branding.getStringValue("fontsPath"), list);
- std::sort(list.begin(), list.end());
- VirtFs::permitLinks(false);
-}
-
-void Theme::fillSoundsList(StringVect &list)
-{
- VirtFs::List *const skins = VirtFs::enumerateFiles(
- branding.getStringValue("systemsounds"));
-
- FOR_EACH (StringVectCIter, i, skins->names)
- {
- if (!VirtFs::isDirectory((branding.getStringValue(
- "systemsounds") + *i)))
- {
- std::string str = *i;
- if (findCutLast(str, ".ogg"))
- list.push_back(str);
- }
- }
-
- VirtFs::freeList(skins);
- std::sort(list.begin(), list.end());
-}
-
-void Theme::selectSkin()
-{
- prepareThemePath();
- mScreenDensity = graphicsManager.getDensityString();
-}
-
-void Theme::prepareThemePath()
-{
- initDefaultThemePath();
-
- mThemePath.clear();
- mThemeName.clear();
-
- // Try theme from settings
- if (tryThemePath(config.getStringValue("theme")))
- return;
-
- // Try theme from branding
- if (tryThemePath(branding.getStringValue("theme")))
- return;
-
- if (mThemePath.empty())
- mThemePath = "graphics/gui";
-
- theme->loadColors(mThemePath);
-
- logger->log("Selected Theme: " + mThemePath);
-}
-
-std::string Theme::resolveThemePath(const std::string &path)
-{
- // Need to strip off any dye info for the existence tests
- const int pos = CAST_S32(path.find('|'));
- std::string file;
- if (pos > 0)
- file = path.substr(0, pos);
- else
- file = path;
-
- // File with path
- if (file.find('/') != std::string::npos)
- {
- // Might be a valid path already
- if (VirtFs::exists(file))
- return path;
- }
-
- // Try the theme
- file = pathJoin(getThemePath(), file);
-
- if (VirtFs::exists(file))
- return pathJoin(getThemePath(), path);
-
- // Backup
- return pathJoin(branding.getStringValue("guiPath"), path);
-}
-
-Image *Theme::getImageFromTheme(const std::string &path)
-{
- return Loader::getImage(resolveThemePath(path));
-}
-
-ImageSet *Theme::getImageSetFromTheme(const std::string &path,
- const int w, const int h)
-{
- return Loader::getImageSet(resolveThemePath(path), w, h);
-}
-
-static int readColorType(const std::string &type)
-{
- static const std::string colors[CAST_SIZE(
- ThemeColorId::THEME_COLORS_END)] =
- {
- "BROWSERBOX",
- "BROWSERBOX_OUTLINE",
- "SELFNICK",
- "SELFNICK_OUTLINE",
- "TEXT",
- "TEXT_OUTLINE",
- "CARET",
- "SHADOW",
- "OUTLINE",
- "BORDER",
- "PROGRESS_BAR",
- "PROGRESS_BAR_OUTLINE",
- "BUTTON",
- "BUTTON_OUTLINE",
- "BUTTON_DISABLED",
- "BUTTON_DISABLED_OUTLINE",
- "BUTTON_HIGHLIGHTED",
- "BUTTON_HIGHLIGHTED_OUTLINE",
- "BUTTON_PRESSED",
- "BUTTON_PRESSED_OUTLINE",
- "CHECKBOX",
- "CHECKBOX_OUTLINE",
- "DROPDOWN",
- "DROPDOWN_OUTLINE",
- "LABEL",
- "LABEL_OUTLINE",
- "LISTBOX",
- "LISTBOX_OUTLINE",
- "LISTBOX_SELECTED",
- "LISTBOX_SELECTED_OUTLINE",
- "RADIOBUTTON",
- "RADIOBUTTON_OUTLINE",
- "POPUP",
- "POPUP_OUTLINE",
- "TAB",
- "TAB_OUTLINE",
- "TAB_HIGHLIGHTED",
- "TAB_HIGHLIGHTED_OUTLINE",
- "TAB_SELECTED",
- "TAB_SELECTED_OUTLINE",
- "TEXTBOX",
- "TEXTFIELD",
- "TEXTFIELD_OUTLINE",
- "WINDOW",
- "WINDOW_OUTLINE",
- "BATTLE_CHAT_TAB",
- "BATTLE_CHAT_TAB_OUTLINE",
- "CHANNEL_CHAT_TAB",
- "CHANNEL_CHAT_TAB_OUTLINE",
- "PARTY_CHAT_TAB",
- "PARTY_CHAT_TAB_OUTLINE",
- "PARTY_SOCIAL_TAB",
- "PARTY_SOCIAL_TAB_OUTLINE",
- "GUILD_CHAT_TAB",
- "GUILD_CHAT_TAB_OUTLINE",
- "GUILD_SOCIAL_TAB",
- "GUILD_SOCIAL_TAB_OUTLINE",
- "GM_CHAT_TAB",
- "GM_CHAT_TAB_OUTLINE",
- "BATTLE_CHAT_TAB_HIGHLIGHTED",
- "BATTLE_CHAT_TAB_HIGHLIGHTED_OUTLINE",
- "CHANNEL_CHAT_TAB_HIGHLIGHTED",
- "CHANNEL_CHAT_TAB_HIGHLIGHTED_OUTLINE",
- "PARTY_CHAT_TAB_HIGHLIGHTED",
- "PARTY_CHAT_TAB_HIGHLIGHTED_OUTLINE",
- "PARTY_SOCIAL_TAB_HIGHLIGHTED",
- "PARTY_SOCIAL_TAB_HIGHLIGHTED_OUTLINE",
- "GUILD_CHAT_TAB_HIGHLIGHTED",
- "GUILD_CHAT_TAB_HIGHLIGHTED_OUTLINE",
- "GUILD_SOCIAL_TAB_HIGHLIGHTED",
- "GUILD_SOCIAL_TAB_HIGHLIGHTED_OUTLINE",
- "GM_CHAT_TAB_HIGHLIGHTED",
- "GM_CHAT_TAB_HIGHLIGHTED_OUTLINE",
- "BATTLE_CHAT_TAB_SELECTED",
- "BATTLE_CHAT_TAB_SELECTED_OUTLINE",
- "CHANNEL_CHAT_TAB_SELECTED",
- "CHANNEL_CHAT_TAB_SELECTED_OUTLINE",
- "PARTY_CHAT_TAB_SELECTED",
- "PARTY_CHAT_TAB_SELECTED_OUTLINE",
- "PARTY_SOCIAL_TAB_SELECTED",
- "PARTY_SOCIAL_TAB_SELECTED_OUTLINE",
- "GUILD_CHAT_TAB_SELECTED",
- "GUILD_CHAT_TAB_SELECTED_OUTLINE",
- "GUILD_SOCIAL_TAB_SELECTED",
- "GUILD_SOCIAL_TAB_SELECTED_OUTLINE",
- "GM_CHAT_TAB_SELECTED",
- "GM_CHAT_TAB_SELECTED_OUTLINE",
- "BACKGROUND",
- "BACKGROUND_GRAY",
- "SCROLLBAR_GRAY",
- "DROPDOWN_SHADOW",
- "HIGHLIGHT",
- "HIGHLIGHT_OUTLINE",
- "TAB_FLASH",
- "TAB_FLASH_OUTLINE",
- "TAB_PLAYER_FLASH",
- "TAB_PLAYER_FLASH_OUTLINE",
- "SHOP_WARNING",
- "ITEM_EQUIPPED",
- "ITEM_EQUIPPED_OUTLINE",
- "ITEM_NOT_EQUIPPED",
- "ITEM_NOT_EQUIPPED_OUTLINE",
- "CHAT",
- "CHAT_OUTLINE",
- "GM",
- "GM_OUTLINE",
- "GLOBAL",
- "GLOBAL_OUTLINE",
- "PLAYER",
- "PLAYER_OUTLINE",
- "WHISPER_TAB",
- "WHISPER_TAB_OUTLINE",
- "WHISPER_TAB_OFFLINE",
- "WHISPER_TAB_OFFLINE_OUTLINE",
- "WHISPER_TAB_HIGHLIGHTED",
- "WHISPER_TAB_HIGHLIGHTED_OUTLINE",
- "WHISPER_TAB_OFFLINE_HIGHLIGHTED",
- "WHISPER_TAB_OFFLINE_HIGHLIGHTED_OUTLINE",
- "WHISPER_TAB_SELECTED",
- "WHISPER_TAB_SELECTED_OUTLINE",
- "WHISPER_TAB_OFFLINE_SELECTED",
- "WHISPER_TAB_OFFLINE_SELECTED_OUTLINE",
- "IS",
- "IS_OUTLINE",
- "SERVER",
- "SERVER_OUTLINE",
- "LOGGER",
- "LOGGER_OUTLINE",
- "HYPERLINK",
- "HYPERLINK_OUTLINE",
- "UNKNOWN_ITEM",
- "UNKNOWN_ITEM_OUTLINE",
- "GENERIC",
- "GENERIC_OUTLINE",
- "HEAD",
- "HEAD_OUTLINE",
- "USABLE",
- "USABLE_OUTLINE",
- "TORSO",
- "TORSO_OUTLINE",
- "ONEHAND",
- "ONEHAND_OUTLINE",
- "LEGS",
- "LEGS_OUTLINE",
- "FEET",
- "FEET_OUTLINE",
- "TWOHAND",
- "TWOHAND_OUTLINE",
- "SHIELD",
- "SHIELD_OUTLINE",
- "RING",
- "RING_OUTLINE",
- "NECKLACE",
- "NECKLACE_OUTLINE",
- "ARMS",
- "ARMS_OUTLINE",
- "AMMO",
- "AMMO_OUTLINE",
- "SERVER_VERSION_NOT_SUPPORTED",
- "SERVER_VERSION_NOT_SUPPORTED_OUTLINE",
- "WARNING",
- "WARNING_OUTLINE",
- "CHARM",
- "CHARM_OUTLINE",
- "CARD",
- "CARD_OUTLINE",
- "PLAYER_ADVANCED",
- "PLAYER_ADVANCED_OUTLINE",
- "BUBBLE_NAME",
- "BUBBLE_NAME_OUTLINE",
- "BUBBLE_TEXT",
- "BUBBLE_TEXT_OUTLINE",
- "BLACK",
- "BLACK_OUTLINE",
- "RED",
- "RED_OUTLINE",
- "GREEN",
- "GREEN_OUTLINE",
- "BLUE",
- "BLUE_OUTLINE",
- "ORANGE",
- "ORANGE_OUTLINE",
- "YELLOW",
- "YELLOW_OUTLINE",
- "PINK",
- "PINK_OUTLINE",
- "PURPLE",
- "PURPLE_OUTLINE",
- "GRAY",
- "GRAY_OUTLINE",
- "BROWN",
- "BROWN_OUTLINE",
- "STATUSBAR_ON",
- "STATUSBAR_OFF",
- "TABLE_BACKGROUND",
- "SLOTS_BAR",
- "SLOTS_BAR_OUTLINE",
- "HP_BAR",
- "HP_BAR_OUTLINE",
- "MP_BAR",
- "MP_BAR_OUTLINE",
- "NO_MP_BAR",
- "NO_MP_BAR_OUTLINE",
- "XP_BAR",
- "XP_BAR_OUTLINE",
- "WEIGHT_BAR",
- "WEIGHT_BAR_OUTLINE",
- "MONEY_BAR",
- "MONEY_BAR_OUTLINE",
- "ARROWS_BAR",
- "ARROWS_BAR_OUTLINE",
- "STATUS_BAR",
- "STATUS_BAR_OUTLINE",
- "JOB_BAR",
- "JOB_BAR_OUTLINE",
- "OLDCHAT",
- "OLDCHAT_OUTLINE",
- "AWAYCHAT",
- "AWAYCHAT_OUTLINE",
- "SKILL_COOLDOWN",
- "TEXT_DISABLED",
- "TEXT_DISABLED_OUTLINE"
- };
-
- if (type.empty())
- return -1;
-
- for (int i = 0; i < CAST_S32(ThemeColorId::THEME_COLORS_END); i++)
- {
- if (compareStrI(type, colors[i]) == 0)
- return i;
- }
-
- return -1;
-}
-
-static Color readColor(const std::string &description)
-{
- const int size = static_cast<int>(description.length());
- if (size < 7 || description[0] != '#')
- {
- logger->log("Error, invalid theme color palette: %s",
- description.c_str());
- return Palette::BLACK;
- }
-
- unsigned int v = 0;
- for (int i = 1; i < 7; ++i)
- {
- signed const char c = description[i];
- int n;
-
- if ('0' <= c && c <= '9')
- {
- n = c - '0';
- }
- else if ('A' <= c && c <= 'F')
- {
- n = c - 'A' + 10;
- }
- else if ('a' <= c && c <= 'f')
- {
- n = c - 'a' + 10;
- }
- else
- {
- logger->log("Error, invalid theme color palette: %s",
- description.c_str());
- return Palette::BLACK;
- }
-
- v = (v << 4) | n;
- }
-
- return Color(v);
-}
-
-static GradientTypeT readColorGradient(const std::string &grad)
-{
- static const std::string grads[] =
- {
- "STATIC",
- "PULSE",
- "SPECTRUM",
- "RAINBOW"
- };
-
- if (grad.empty())
- return GradientType::STATIC;
-
- for (int i = 0; i < 4; i++)
- {
- if (compareStrI(grad, grads[i]) != 0)
- return static_cast<GradientTypeT>(i);
- }
-
- return GradientType::STATIC;
-}
-
-static int readProgressType(const std::string &type)
-{
- static const std::string colors[CAST_SIZE(
- ProgressColorId::THEME_PROG_END)] =
- {
- "HP",
- "HP_POISON",
- "MP",
- "NO_MP",
- "EXP",
- "INVY_SLOTS",
- "WEIGHT",
- "JOB",
- "UPDATE",
- "MONEY",
- "ARROWS",
- "STATUS"
- };
-
- if (type.empty())
- return -1;
-
- for (int i = 0; i < CAST_S32(ProgressColorId::THEME_PROG_END); i++)
- {
- if (compareStrI(type, colors[i]) == 0)
- return i;
- }
-
- return -1;
-}
-
-void Theme::loadColors(std::string file)
-{
- if (file.empty())
- file = "colors.xml";
- else
- file = pathJoin(file, "colors.xml");
-
- XML::Document *const doc = Loader::getXml(resolveThemePath(file),
- UseVirtFs_true,
- SkipError_false);
- if (doc == nullptr)
- return;
- XmlNodeConstPtrConst root = doc->rootNode();
-
- if ((root == nullptr) || !xmlNameEqual(root, "colors"))
- {
- logger->log("Error loading colors file: %s", file.c_str());
- doc->decRef();
- return;
- }
-
- logger->log("Loading colors file: %s", file.c_str());
-
- for_each_xml_child_node(paletteNode, root)
- {
- if (xmlNameEqual(paletteNode, "progressbar"))
- {
- const int type = readProgressType(XML::getProperty(
- paletteNode, "id", ""));
- if (type < 0)
- continue;
-
- mProgressColors[type] = new DyePalette(XML::getProperty(
- paletteNode, "color", ""), 6);
- }
- else if (!xmlNameEqual(paletteNode, "palette"))
- {
- continue;
- }
-
- const int paletteId = XML::getProperty(paletteNode, "id", 1);
- if (paletteId < 0 || paletteId >= THEME_PALETTES)
- continue;
-
- for_each_xml_child_node(node, paletteNode)
- {
- if (xmlNameEqual(node, "color"))
- {
- const std::string id = XML::getProperty(node, "id", "");
- const int type = readColorType(id);
- if (type < 0)
- continue;
-
- const std::string temp = XML::getProperty(node, "color", "");
- if (temp.empty())
- continue;
-
- const Color color = readColor(temp);
- const GradientTypeT grad = readColorGradient(
- XML::getProperty(node, "effect", ""));
- mColors[paletteId * CAST_SIZE(
- ThemeColorId::THEME_COLORS_END) + type].set(
- type, color, grad, 10);
-
- if (!findLast(id, "_OUTLINE"))
- {
- const int type2 = readColorType(id + "_OUTLINE");
- if (type2 < 0)
- continue;
- const int idx = paletteId
- * CAST_S32(ThemeColorId::THEME_COLORS_END);
- mColors[idx + type2] = mColors[idx + type];
- }
- }
- }
- }
- doc->decRef();
-}
-
-#define loadGrid() \
- { \
- const ImageRect &rect = skin->getBorder(); \
- for (int f = start; f <= end; f ++) \
- { \
- if (rect.grid[f]) \
- { \
- image.grid[f] = rect.grid[f]; \
- image.grid[f]->incRef(); \
- } \
- } \
- }
-
-void Theme::loadRect(ImageRect &image,
- const std::string &name,
- const std::string &name2,
- const int start,
- const int end)
-{
- Skin *const skin = load(name, name2, false);
- if (skin != nullptr)
- {
- loadGrid();
- unload(skin);
- }
-}
-
-Skin *Theme::loadSkinRect(ImageRect &image,
- const std::string &name,
- const std::string &name2,
- const int start,
- const int end)
-{
- Skin *const skin = load(name, name2);
- if (skin != nullptr)
- loadGrid();
- return skin;
-}
-
-void Theme::unloadRect(const ImageRect &rect,
- const int start,
- const int end)
-{
- for (int f = start; f <= end; f ++)
- {
- if (rect.grid[f] != nullptr)
- rect.grid[f]->decRef();
- }
-}
-
-Image *Theme::getImageFromThemeXml(const std::string &name,
- const std::string &name2)
-{
- if (theme == nullptr)
- return nullptr;
-
- Skin *const skin = theme->load(name, name2, false);
- if (skin != nullptr)
- {
- const ImageRect &rect = skin->getBorder();
- if (rect.grid[0] != nullptr)
- {
- Image *const image = rect.grid[0];
- image->incRef();
- theme->unload(skin);
- return image;
- }
- theme->unload(skin);
- }
- return nullptr;
-}
-
-ImageSet *Theme::getImageSetFromThemeXml(const std::string &name,
- const std::string &name2,
- const int w, const int h)
-{
- if (theme == nullptr)
- return nullptr;
-
- Skin *const skin = theme->load(name, name2, false);
- if (skin != nullptr)
- {
- const ImageRect &rect = skin->getBorder();
- if (rect.grid[0] != nullptr)
- {
- Image *const image = rect.grid[0];
- const SDL_Rect &rect2 = image->mBounds;
- if ((rect2.w != 0u) && (rect2.h != 0u))
- {
- ImageSet *const imageSet = Loader::getSubImageSet(
- image, w, h);
- theme->unload(skin);
- return imageSet;
- }
- }
- theme->unload(skin);
- }
- return nullptr;
-}
-
-#define readValue(name) \
- { \
- tmpData = reinterpret_cast<XmlChar*>( \
- XmlNodeGetContent(infoNode)); \
- info->name = tmpData; \
- XmlFree(tmpData); \
- }
-
-#define readIntValue(name) \
- { \
- tmpData = reinterpret_cast<XmlChar*>( \
- XmlNodeGetContent(infoNode)); \
- info->name = atoi(tmpData); \
- XmlFree(tmpData); \
- }
-
-#define readFloatValue(name) \
- { \
- tmpData = reinterpret_cast<XmlChar*>( \
- XmlNodeGetContent(infoNode)); \
- info->name = static_cast<float>(atof(tmpData)); \
- XmlFree(tmpData); \
- }
-
-ThemeInfo *Theme::loadInfo(const std::string &themeName)
-{
- std::string path;
- if (themeName.empty())
- {
- path = "graphics/gui/info.xml";
- }
- else
- {
- path = pathJoin(defaultThemePath,
- themeName,
- "info.xml");
- }
- logger->log("loading: " + path);
- XML::Document *const doc = Loader::getXml(path,
- UseVirtFs_true,
- SkipError_false);
- if (doc == nullptr)
- return nullptr;
- XmlNodeConstPtrConst rootNode = doc->rootNode();
-
- if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "info"))
- {
- doc->decRef();
- return nullptr;
- }
-
- ThemeInfo *const info = new ThemeInfo;
-
- const std::string fontSize2("fontSize_" + mScreenDensity);
- const std::string npcfontSize2("npcfontSize_" + mScreenDensity);
- XmlChar *tmpData = nullptr;
- for_each_xml_child_node(infoNode, rootNode)
- {
- if (xmlNameEqual(infoNode, "name"))
- readValue(name)
- else if (xmlNameEqual(infoNode, "copyright"))
- readValue(copyright)
- else if (xmlNameEqual(infoNode, "font"))
- readValue(font)
- else if (xmlNameEqual(infoNode, "boldFont"))
- readValue(boldFont)
- else if (xmlNameEqual(infoNode, "particleFont"))
- readValue(particleFont)
- else if (xmlNameEqual(infoNode, "helpFont"))
- readValue(helpFont)
- else if (xmlNameEqual(infoNode, "secureFont"))
- readValue(secureFont)
- else if (xmlNameEqual(infoNode, "npcFont"))
- readValue(npcFont)
- else if (xmlNameEqual(infoNode, "japanFont"))
- readValue(japanFont)
- else if (xmlNameEqual(infoNode, "chinaFont"))
- readValue(chinaFont)
- else if (xmlNameEqual(infoNode, "fontSize"))
- readIntValue(fontSize)
- else if (xmlNameEqual(infoNode, "npcfontSize"))
- readIntValue(npcfontSize)
- else if (xmlNameEqual(infoNode, "guialpha"))
- readFloatValue(guiAlpha)
- else if (xmlNameEqual(infoNode, fontSize2.c_str()))
- readIntValue(fontSize)
- else if (xmlNameEqual(infoNode, npcfontSize2.c_str()))
- readIntValue(npcfontSize)
- }
- doc->decRef();
- return info;
-}
-
-ThemeColorIdT Theme::getIdByChar(const signed char c, bool &valid) const
-{
- const CharColors::const_iterator it = mCharColors.find(c);
- if (it != mCharColors.end())
- {
- valid = true;
- return static_cast<ThemeColorIdT>((*it).second);
- }
-
- valid = false;
- return ThemeColorId::BROWSERBOX;
-}
diff --git a/src/gui/theme.h b/src/gui/theme.h
deleted file mode 100644
index 8618468d9..000000000
--- a/src/gui/theme.h
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 The Legend of Mazzeroth Development Team
- * Copyright (C) 2009 Aethyra Development Team
- * 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 GUI_THEME_H
-#define GUI_THEME_H
-
-#include "logger.h"
-
-#include "enums/gui/progresscolorid.h"
-#include "enums/gui/themecolorid.h"
-
-#include "listeners/configlistener.h"
-
-#include "gui/palette.h"
-
-#include "utils/stringvector.h"
-
-#include "localconsts.h"
-
-class DyePalette;
-class Image;
-class ImageRect;
-class ImageSet;
-class Skin;
-class Theme;
-
-struct ThemeInfo;
-
-extern Theme *theme;
-
-class Theme final : public Palette,
- public ConfigListener
-{
- public:
- Theme();
-
- ~Theme();
-
- A_DELETE_COPY(Theme)
-
- static void prepareThemePath();
-
- static void selectSkin();
-
- static std::string getThemePath() A_WARN_UNUSED
- { return mThemePath; }
-
- static std::string getThemeName() A_WARN_UNUSED
- { return mThemeName; }
-
- static void fillSkinsList(StringVect &list);
-
- static void fillFontsList(StringVect &list);
-
- static void fillSoundsList(StringVect &list);
-
- /**
- * Returns the patch to the given gui resource relative to the theme
- * or, if it isn't in the theme, relative to 'graphics/gui'.
- */
- static std::string resolveThemePath(const std::string &path)
- A_WARN_UNUSED;
-
- static Image *getImageFromTheme(const std::string &path) A_WARN_UNUSED;
-
- static ImageSet *getImageSetFromTheme(const std::string &path,
- const int w,
- const int h) A_WARN_UNUSED;
-
- static ImageSet *getImageSetFromThemeXml(const std::string &name,
- const std::string &name2,
- const int w,
- const int h)A_WARN_UNUSED;
-
- static Color getProgressColor(const ProgressColorIdT type,
- const float progress) A_WARN_UNUSED;
-
- /**
- * Loads a skin.
- */
- Skin *load(const std::string &filename,
- const std::string &filename2,
- const bool full = true,
- const std::string
- &restrict defaultPath = getThemePath()) A_WARN_UNUSED;
-
- Skin *loadSkinRect(ImageRect &image,
- const std::string &name,
- const std::string &name2,
- const int start = 0,
- const int end = 8) A_WARN_UNUSED;
-
- void unload(Skin *const skin);
-
- /**
- * Updates the alpha values of all of the skins.
- */
- void updateAlpha();
-
- /**
- * Get the minimum opacity allowed to skins.
- */
- float getMinimumOpacity() const noexcept2 A_WARN_UNUSED
- { return mMinimumOpacity; }
-
- /**
- * Gets the color associated with the type. Sets the alpha channel
- * before returning.
- *
- * @param type the color type requested
- * @param alpha alpha channel to use
- *
- * @return the requested color
- */
- inline const Color &getColor(ThemeColorIdT type,
- const unsigned int alpha = 255U)
- A_WARN_UNUSED
- {
- if (CAST_SIZE(type) >= mColors.size())
- {
- logger->log("incorrect color request type: %d from %u",
- CAST_S32(type),
- CAST_U32(mColors.size()));
- type = ThemeColorId::BROWSERBOX;
- }
- Color *const col = &mColors[CAST_SIZE(type)].color;
- col->a = alpha;
- return *col;
- }
-
- ThemeColorIdT getIdByChar(const signed char c,
- bool &valid) const A_WARN_UNUSED;
-
- /**
- * Set the minimum opacity allowed to skins.
- * Set a negative value to free the minimum allowed.
- */
- void setMinimumOpacity(const float minimumOpacity);
-
- void optionChanged(const std::string &name) override final;
-
- void loadRect(ImageRect &image,
- const std::string &name,
- const std::string &name2,
- const int start = 0,
- const int end = 8);
-
- static void unloadRect(const ImageRect &rect,
- const int start = 0,
- const int end = 8);
-
- static Image *getImageFromThemeXml(const std::string &name,
- const std::string &name2)
- A_WARN_UNUSED;
-
- static ThemeInfo *loadInfo(const std::string &themeName) A_WARN_UNUSED;
-
- private:
- Skin *readSkin(const std::string &filename0,
- const bool full) A_WARN_UNUSED;
-
- // Map containing all window skins
- typedef std::map<std::string, Skin*> Skins;
- typedef Skins::iterator SkinIterator;
-
- Skins mSkins;
-
- static std::string mThemePath;
- static std::string mThemeName;
- static std::string mScreenDensity;
-
- static bool tryThemePath(const std::string &themePath) A_WARN_UNUSED;
-
- void loadColors(std::string file = "");
-
- /**
- * Tells if the current skins opacity
- * should not get less than the given value
- */
- float mMinimumOpacity;
-
- typedef STD_VECTOR<DyePalette*> ProgressColors;
- ProgressColors mProgressColors;
-};
-
-#endif // GUI_THEME_H
diff --git a/src/gui/themecolorsidoperators.cpp b/src/gui/themecolorsidoperators.cpp
deleted file mode 100644
index df3a7e65b..000000000
--- a/src/gui/themecolorsidoperators.cpp
+++ /dev/null
@@ -1,30 +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/>.
- */
-
-#include "gui/themecolorsidoperators.h"
-
-#include "utils/cast.h"
-
-#include "debug.h"
-
-ThemeColorIdT operator+(const ThemeColorIdT &id, const int& i)
-{
- return static_cast<ThemeColorIdT>(CAST_S32(id) + i);
-}
diff --git a/src/gui/themecolorsidoperators.h b/src/gui/themecolorsidoperators.h
deleted file mode 100644
index 7d7f13eca..000000000
--- a/src/gui/themecolorsidoperators.h
+++ /dev/null
@@ -1,28 +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 GUI_THEMECOLORSIDOPERATORS_H
-#define GUI_THEMECOLORSIDOPERATORS_H
-
-#include "enums/gui/themecolorid.h"
-
-ThemeColorIdT operator+(const ThemeColorIdT &id, const int& i);
-
-#endif // GUI_THEMECOLORSIDOPERATORS_H
diff --git a/src/gui/themeinfo.h b/src/gui/themeinfo.h
deleted file mode 100644
index 5514924a2..000000000
--- a/src/gui/themeinfo.h
+++ /dev/null
@@ -1,64 +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 GUI_THEMEINFO_H
-#define GUI_THEMEINFO_H
-
-#include <string>
-
-#include "localconsts.h"
-
-struct ThemeInfo final
-{
- ThemeInfo() :
- name(),
- copyright(),
- font(),
- boldFont(),
- particleFont(),
- helpFont(),
- secureFont(),
- npcFont(),
- japanFont(),
- chinaFont(),
- fontSize(0),
- npcfontSize(0),
- guiAlpha(0.0F)
- {
- }
-
- A_DELETE_COPY(ThemeInfo)
-
- std::string name;
- std::string copyright;
- std::string font;
- std::string boldFont;
- std::string particleFont;
- std::string helpFont;
- std::string secureFont;
- std::string npcFont;
- std::string japanFont;
- std::string chinaFont;
- int fontSize;
- int npcfontSize;
- float guiAlpha;
-};
-
-#endif // GUI_THEMEINFO_H
diff --git a/src/gui/touchactiondata.cpp b/src/gui/touchactiondata.cpp
deleted file mode 100644
index d8c42b6d9..000000000
--- a/src/gui/touchactiondata.cpp
+++ /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/>.
- */
-
-#include "gui/touchactiondata.h"
-
-#include "input/pages/basic.h"
-#include "input/pages/chat.h"
-#include "input/pages/other.h"
-#include "input/pages/shortcuts.h"
-#include "input/pages/windows.h"
-
-#include "debug.h"
-
-SetupActionData *const touchActionData[] =
-{
- setupActionDataBasic,
- setupActionDataWindows,
- setupActionDataChat,
- setupActionDataOther,
- setupActionDataShortcuts
-};
diff --git a/src/gui/touchactiondata.h b/src/gui/touchactiondata.h
deleted file mode 100644
index 99954d906..000000000
--- a/src/gui/touchactiondata.h
+++ /dev/null
@@ -1,28 +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 GUI_TOUCHACTIONDATA_H
-#define GUI_TOUCHACTIONDATA_H
-
-struct SetupActionData;
-
-extern SetupActionData *const touchActionData[];
-
-#endif // GUI_TOUCHACTIONDATA_H
diff --git a/src/gui/userpalette.cpp b/src/gui/userpalette.cpp
deleted file mode 100644
index 79e3758ac..000000000
--- a/src/gui/userpalette.cpp
+++ /dev/null
@@ -1,649 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 Douglas Boffey <dougaboffey@netscape.net>
- * 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 "gui/userpalette.h"
-
-#include "configuration.h"
-
-#include "utils/foreach.h"
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-UserPalette *userPalette = nullptr;
-
-const std::string ColorTypeNames[CAST_SIZE(
- UserColorId::USER_COLOR_LAST)] =
-{
- "",
- "ColorBeing",
- "ColorFriend",
- "ColorDisregarded",
- "ColorIgnored",
- "ColorErased",
- "ColorEnemy",
- "ColorPlayer",
- "ColorSelf",
- "ColorGM",
- "ColorNPC",
- "ColorMonster",
- "ColorPet",
- "ColorMercenary",
- "ColorHomunculus",
- "ColorSkillUnit",
- "ColorParty",
- "ColorGuild",
- "ColorTeam1",
- "ColorTeam2",
- "ColorTeam3",
- "",
- "ColorParticle",
- "ColorPickupInfo",
- "ColorExpInfo",
- "",
- "ColorPlayerHp",
- "ColorPlayerHp2",
- "ColorMonsterHp",
- "ColorMonsterHp2",
- "ColorHomunHp",
- "ColorHomunHp2",
- "ColorMercHp",
- "ColorMercHp2",
- "ColorElementalHp",
- "ColorElementalHp2",
- "",
- "ColorHitPlayerMonster",
- "ColorHitMonsterPlayer",
- "ColorHitPlayerPlayer",
- "ColorHitCritical",
- "ColorHitLocalPlayerMonster",
- "ColorHitLocalPlayerCritical",
- "ColorHitLocalPlayerMiss",
- "ColorMiss",
- "",
- "ColorPortalHighlight",
- "ColorCollisionHighlight",
- "ColorCollisionAirHighlight",
- "ColorCollisionWaterHighlight",
- "ColorCollisionMonsterHighlight",
- "ColorCollisionGroundtopHighlight",
- "ColorWalkableTileHighlight",
- "ColorNet",
- "",
- "ColorAttackRange",
- "ColorAttackRangeBorder",
- "ColorMonsterAttackRange",
- "ColorSkillAttackRange",
- "",
- "ColorFloorItemText",
- "ColorHomePlace",
- "ColorHomePlaceBorder",
- "ColorRoadPoint",
-};
-
-std::string UserPalette::getConfigName(const std::string &typeName)
-{
- std::string res("Color" + typeName);
- size_t pos = 5;
- for (size_t i = 0; i < typeName.length(); i++)
- {
- if (i == 0 || typeName[i] == '_')
- {
- if (i > 0)
- i++;
-
- res[pos] = typeName[i];
- }
- else
- {
- res[pos] = CAST_S8(tolower(typeName[i]));
- }
- pos ++;
- }
- res.erase(pos, res.length() - pos);
- return res;
-}
-
-UserPalette::UserPalette() :
- Palette(CAST_S32(UserColorId::USER_COLOR_LAST)),
- ListModel()
-{
- mColors[CAST_SIZE(UserColorId::BEING)] = ColorElem();
- mColors[CAST_SIZE(UserColorId::PC)] = ColorElem();
- mColors[CAST_SIZE(UserColorId::SELF)] = ColorElem();
- mColors[CAST_SIZE(UserColorId::GM)] = ColorElem();
- mColors[CAST_SIZE(UserColorId::NPC)] = ColorElem();
- mColors[CAST_SIZE(UserColorId::MONSTER)] = ColorElem();
-
- addLabel(UserColorId::LABEL_BEING,
- // TRANSLATORS: palette label
- _("Beings"));
- addColor(UserColorId::BEING,
- 0xffffff,
- GradientType::STATIC,
- // TRANSLATORS: palette color
- _("Being"));
- addColor(UserColorId::FRIEND,
- 0xb0ffb0,
- GradientType::STATIC,
- // TRANSLATORS: palette color
- _("Friend names"));
- addColor(UserColorId::DISREGARDED,
- 0xa00000,
- GradientType::STATIC,
- // TRANSLATORS: palette color
- _("Disregarded names"));
- addColor(UserColorId::IGNORED,
- 0xff0000,
- GradientType::STATIC,
- // TRANSLATORS: palette color
- _("Ignored names"));
- addColor(UserColorId::ERASED,
- 0xff0000,
- GradientType::STATIC,
- // TRANSLATORS: palette color
- _("Erased names"));
- addColor(UserColorId::ENEMY,
- 0xff4040,
- GradientType::STATIC,
- // TRANSLATORS: palette color
- _("Enemy"));
- addColor(UserColorId::PC,
- 0xffffff,
- GradientType::STATIC,
- // TRANSLATORS: palette color
- _("Other players names"));
- addColor(UserColorId::SELF,
- 0xff8040,
- GradientType::STATIC,
- // TRANSLATORS: palette color
- _("Own name"));
- addColor(UserColorId::GM,
- 0x00ff00,
- GradientType::STATIC,
- // TRANSLATORS: palette color
- _("GM names"));
- addColor(UserColorId::NPC,
- 0xc8c8ff,
- GradientType::STATIC,
- // TRANSLATORS: palette color
- _("NPCs"));
- addColor(UserColorId::MONSTER,
- 0xff4040,
- GradientType::STATIC,
- // TRANSLATORS: palette color
- _("Monsters"));
- addColor(UserColorId::PET,
- 0xffffff,
- GradientType::STATIC,
- // TRANSLATORS: palette color
- _("Pets"));
- addColor(UserColorId::MERCENARY,
- 0xffffff,
- GradientType::STATIC,
- // TRANSLATORS: palette color
- _("Mercenary"));
- addColor(UserColorId::HOMUNCULUS,
- 0xffffff,
- GradientType::STATIC,
- // TRANSLATORS: palette color
- _("Homunculus"));
- addColor(UserColorId::SKILLUNIT,
- 0xffffff,
- GradientType::STATIC,
- // TRANSLATORS: palette color
- _("Skill unit"));
- addColor(UserColorId::PARTY,
- 0xff00d8,
- GradientType::STATIC,
- // TRANSLATORS: palette color
- _("Party members"));
- addColor(UserColorId::GUILD,
- 0xff00d8,
- GradientType::STATIC,
- // TRANSLATORS: palette color
- _("Guild members"));
- addColor(UserColorId::TEAM1,
- 0x0000ff,
- GradientType::STATIC,
- // TRANSLATORS: palette color
- strprintf(_("Team %d"), 1));
- addColor(UserColorId::TEAM2,
- 0x00a020,
- GradientType::STATIC,
- // TRANSLATORS: palette color
- strprintf(_("Team %d"), 2));
- addColor(UserColorId::TEAM3,
- 0xffff20,
- GradientType::STATIC,
- // TRANSLATORS: palette color
- strprintf(_("Team %d"), 3));
- addLabel(UserColorId::LABEL_PARTICLES,
- // TRANSLATORS: palette label
- _("Particles"));
- addColor(UserColorId::PARTICLE,
- 0xffffff,
- GradientType::STATIC,
- // TRANSLATORS: palette color
- _("Particle effects"));
- addColor(UserColorId::PICKUP_INFO,
- 0x28dc28,
- GradientType::STATIC,
- // TRANSLATORS: palette color
- _("Pickup notification"));
- addColor(UserColorId::EXP_INFO,
- 0xffff00,
- GradientType::STATIC,
- // TRANSLATORS: palette color
- _("Exp notification"));
- addLabel(UserColorId::LABEL_HP,
- // TRANSLATORS: palette label
- _("Hp bars"));
- addColor(UserColorId::PLAYER_HP,
- 0x00ff00,
- GradientType::STATIC,
- // TRANSLATORS: palette color
- _("Player HP bar"), 50);
- addColor(UserColorId::PLAYER_HP2,
- 0xff0000,
- GradientType::STATIC,
- // TRANSLATORS: palette color
- _("Player HP bar (second color)"),
- 50);
- addColor(UserColorId::MONSTER_HP,
- 0x00ff00,
- GradientType::STATIC,
- // TRANSLATORS: palette color
- _("Monster HP bar"),
- 50);
- addColor(UserColorId::MONSTER_HP2,
- 0xff0000,
- GradientType::STATIC,
- // TRANSLATORS: palette color
- _("Monster HP bar (second color)"),
- 50);
- addColor(UserColorId::HOMUN_HP,
- 0x00ff00,
- GradientType::STATIC,
- // TRANSLATORS: palette color
- _("Homunculus HP bar"),
- 50);
- addColor(UserColorId::HOMUN_HP2,
- 0xff0000,
- GradientType::STATIC,
- // TRANSLATORS: palette color
- _("Homunculus HP bar (second color)"),
- 50);
- addColor(UserColorId::MERC_HP,
- 0x00ff00,
- GradientType::STATIC,
- // TRANSLATORS: palette color
- _("Mercenary HP bar"),
- 50);
- addColor(UserColorId::MERC_HP2,
- 0xff0000,
- GradientType::STATIC,
- // TRANSLATORS: palette color
- _("Mercenary HP bar (second color)"),
- 50);
-
- addColor(UserColorId::ELEMENTAL_HP,
- 0x00ff00,
- GradientType::STATIC,
- // TRANSLATORS: palette color
- _("Elemental HP bar"),
- 50);
- addColor(UserColorId::ELEMENTAL_HP2,
- 0xff0000,
- GradientType::STATIC,
- // TRANSLATORS: palette color
- _("Elemental HP bar (second color)"),
- 50);
- addLabel(UserColorId::LABEL_HITS,
- // TRANSLATORS: palette label
- _("Hits"));
- addColor(UserColorId::HIT_PLAYER_MONSTER,
- 0x0064ff,
- GradientType::STATIC,
- // TRANSLATORS: palette color
- _("Player hits monster"));
- addColor(UserColorId::HIT_MONSTER_PLAYER,
- 0xff3232,
- GradientType::STATIC,
- // TRANSLATORS: palette color
- _("Monster hits player"));
- addColor(UserColorId::HIT_PLAYER_PLAYER,
- 0xff5050,
- GradientType::STATIC,
- // TRANSLATORS: palette color
- _("Other player hits local player"));
- addColor(UserColorId::HIT_CRITICAL,
- 0xff0000,
- GradientType::RAINBOW,
- // TRANSLATORS: palette color
- _("Critical Hit"));
- addColor(UserColorId::HIT_LOCAL_PLAYER_MONSTER,
- 0x00ff00,
- GradientType::STATIC,
- // TRANSLATORS: palette color
- _("Local player hits monster"));
- addColor(UserColorId::HIT_LOCAL_PLAYER_CRITICAL,
- 0xff0000,
- GradientType::RAINBOW,
- // TRANSLATORS: palette color
- _("Local player critical hit"));
- addColor(UserColorId::HIT_LOCAL_PLAYER_MISS,
- 0x00ffa6,
- GradientType::STATIC,
- // TRANSLATORS: palette color
- _("Local player miss"));
- addColor(UserColorId::MISS, 0xffff00,
- GradientType::STATIC,
- // TRANSLATORS: palette color
- _("Misses"));
- addLabel(UserColorId::LABEL_TILES,
- // TRANSLATORS: palette label
- _("Tiles"));
- addColor(UserColorId::PORTAL_HIGHLIGHT,
- 0xC80000,
- GradientType::STATIC,
- // TRANSLATORS: palette color
- _("Portal highlight"));
- addColor(UserColorId::COLLISION_HIGHLIGHT,
- 0x0000C8,
- GradientType::STATIC,
- // TRANSLATORS: palette color
- _("Default collision highlight"),
- 64);
- addColor(UserColorId::AIR_COLLISION_HIGHLIGHT,
- 0xe0e0ff,
- GradientType::STATIC,
- // TRANSLATORS: palette color
- _("Air collision highlight"),
- 64);
- addColor(UserColorId::WATER_COLLISION_HIGHLIGHT,
- 0x2050e0,
- GradientType::STATIC,
- // TRANSLATORS: palette color
- _("Water collision highlight"),
- 64);
- addColor(UserColorId::MONSTER_COLLISION_HIGHLIGHT,
- 0x2050e0,
- GradientType::STATIC,
- // TRANSLATORS: palette color
- _("Monster collision highlight"),
- 64);
- addColor(UserColorId::GROUNDTOP_COLLISION_HIGHLIGHT,
- 0xffff00,
- GradientType::STATIC,
- // TRANSLATORS: palette color
- _("Special ground collision highlight"),
- 20);
- addColor(UserColorId::WALKABLE_HIGHLIGHT,
- 0x00D000,
- GradientType::STATIC,
- // TRANSLATORS: palette color
- _("Walkable highlight"),
- 255);
- addColor(UserColorId::NET,
- 0x000000,
- GradientType::STATIC,
- // TRANSLATORS: palette color
- _("Tiles border"), 64);
- addLabel(UserColorId::LABEL_RANGES,
- // TRANSLATORS: palette label
- _("Ranges"));
- addColor(UserColorId::ATTACK_RANGE,
- 0xffffff,
- GradientType::STATIC,
- // TRANSLATORS: palette color
- _("Local player attack range"),
- 5);
- addColor(UserColorId::ATTACK_RANGE_BORDER,
- 0x0,
- GradientType::STATIC,
- // TRANSLATORS: palette color
- _("Local player attack range border"),
- 76);
- addColor(UserColorId::MONSTER_ATTACK_RANGE,
- 0xff0000,
- GradientType::STATIC,
- // TRANSLATORS: palette color
- _("Monster attack range"),
- 20);
- addColor(UserColorId::SKILL_ATTACK_RANGE,
- 0x0,
- GradientType::STATIC,
- // TRANSLATORS: palette color
- _("Skill attack range border"),
- 76);
- addLabel(UserColorId::LABEL_OTHER,
- // TRANSLATORS: palette label
- _("Other"));
- addColor(UserColorId::FLOOR_ITEM_TEXT,
- 0xffffff,
- GradientType::STATIC,
- // TRANSLATORS: palette color
- _("Floor item amount color"),
- 100);
- addColor(UserColorId::HOME_PLACE,
- 0xffffff,
- GradientType::STATIC,
- // TRANSLATORS: palette color
- _("Home place"),
- 20);
- addColor(UserColorId::HOME_PLACE_BORDER,
- 0xffff00,
- GradientType::STATIC,
- // TRANSLATORS: palette color
- _("Home place border"),
- 200);
- addColor(UserColorId::ROAD_POINT,
- 0x000000,
- GradientType::STATIC,
- // TRANSLATORS: palette color
- _("Road point"), 100);
- commit(true);
-}
-
-UserPalette::~UserPalette()
-{
- FOR_EACH (Colors::const_iterator, col, mColors)
- {
- if (col->grad == GradientType::LABEL)
- continue;
- const std::string &configName = ColorTypeNames[col->type];
- config.setValue(configName + "Gradient",
- CAST_S32(col->committedGrad));
- config.setValue(configName + "Delay", col->delay);
-
- if (col->grad == GradientType::STATIC ||
- col->grad == GradientType::PULSE)
- {
- char buffer[20];
- snprintf(buffer, sizeof(buffer), "0x%06x", col->getRGB());
- buffer[19] = 0;
- config.setValue(configName, std::string(buffer));
- }
- }
-}
-
-void UserPalette::setColor(const UserColorIdT type,
- const int r,
- const int g,
- const int b)
-{
- Color &color = mColors[CAST_SIZE(type)].color;
- color.r = r;
- color.g = g;
- color.b = b;
-}
-
-void UserPalette::setGradient(const UserColorIdT type,
- const GradientTypeT grad)
-{
- ColorElem *const elem = &mColors[CAST_SIZE(type)];
-
- if (elem->grad != GradientType::STATIC && grad == GradientType::STATIC)
- {
- const size_t sz = mGradVector.size();
- for (size_t i = 0; i < sz; i++)
- {
- if (mGradVector[i] == elem)
- {
- mGradVector.erase(mGradVector.begin() + i);
- break;
- }
- }
- }
- else if (elem->grad == GradientType::STATIC &&
- grad != GradientType::STATIC)
- {
- mGradVector.push_back(elem);
- }
-
- if (elem->grad != grad)
- elem->grad = grad;
-}
-
-std::string UserPalette::getElementAt(int i)
-{
- if (i < 0 || i >= getNumberOfElements())
- return "";
-
- return mColors[i].text;
-}
-
-void UserPalette::commit(const bool commitNonStatic)
-{
- FOR_EACH (Colors::iterator, i, mColors)
- {
- i->committedGrad = i->grad;
- i->committedDelay = i->delay;
- if (commitNonStatic || i->grad == GradientType::STATIC)
- i->committedColor = i->color;
- else if (i->grad == GradientType::PULSE)
- i->committedColor = i->testColor;
- }
-}
-
-void UserPalette::rollback()
-{
- FOR_EACH (Colors::iterator, i, mColors)
- {
- if (i->grad != i->committedGrad)
- setGradient(static_cast<UserColorIdT>(i->type), i->committedGrad);
-
- const Color &committedColor = i->committedColor;
- setGradientDelay(static_cast<UserColorIdT>(i->type),
- i->committedDelay);
- setColor(static_cast<UserColorIdT>(i->type),
- committedColor.r,
- committedColor.g,
- committedColor.b);
-
- if (i->grad == GradientType::PULSE)
- {
- Color &testColor = i->testColor;
- testColor.r = committedColor.r;
- testColor.g = committedColor.g;
- testColor.b = committedColor.b;
- }
- }
-}
-
-int UserPalette::getColorTypeAt(const int i)
-{
- if (i < 0 || i >= getNumberOfElements())
- return 0;
-
- return mColors[i].type;
-}
-
-void UserPalette::addColor(const UserColorIdT type,
- const unsigned rgb,
- GradientTypeT grad,
- const std::string &text,
- int delay)
-{
- const unsigned maxType = sizeof(ColorTypeNames)
- / sizeof(ColorTypeNames[0]);
-
- if (CAST_U32(type) >= maxType)
- return;
-
- const std::string &configName = ColorTypeNames[CAST_SIZE(type)];
- char buffer[20];
- snprintf(buffer, sizeof(buffer), "0x%06x", rgb);
- buffer[19] = 0;
-
- const std::string rgbString = config.getValue(
- configName, std::string(buffer));
- unsigned int rgbValue = 0;
- if (rgbString.length() == 8 && rgbString[0] == '0' && rgbString[1] == 'x')
- rgbValue = atox(rgbString);
- else
- rgbValue = atoi(rgbString.c_str());
- const Color &trueCol = Color(rgbValue);
- grad = static_cast<GradientTypeT>(config.getValue(
- configName + "Gradient",
- CAST_S32(grad)));
- delay = config.getValueInt(configName + "Delay", delay);
- mColors[CAST_SIZE(type)].set(CAST_S32(type),
- trueCol, grad, delay);
- mColors[CAST_SIZE(type)].text = text;
-
- if (grad != GradientType::STATIC)
- mGradVector.push_back(&mColors[CAST_SIZE(type)]);
-}
-
-void UserPalette::addLabel(const UserColorIdT type,
- const std::string &text)
-{
- const unsigned maxType = sizeof(ColorTypeNames)
- / sizeof(ColorTypeNames[0]);
-
- if (CAST_U32(type) >= maxType)
- return;
-
-
- mColors[CAST_SIZE(type)] = ColorElem();
- const std::string str(" \342\200\225\342\200\225\342\200\225"
- "\342\200\225\342\200\225 ");
- mColors[CAST_SIZE(type)].grad = GradientType::LABEL;
- mColors[CAST_SIZE(type)].text =
- std::string(str).append(text).append(str);
-}
-
-int UserPalette::getIdByChar(const signed char c, bool &valid) const
-{
- const CharColors::const_iterator it = mCharColors.find(c);
- if (it != mCharColors.end())
- {
- valid = true;
- return (*it).second;
- }
-
- valid = false;
- return 0;
-}
diff --git a/src/gui/userpalette.h b/src/gui/userpalette.h
deleted file mode 100644
index 4f7e0e941..000000000
--- a/src/gui/userpalette.h
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 Douglas Boffey <dougaboffey@netscape.net>
- * 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 GUI_USERPALETTE_H
-#define GUI_USERPALETTE_H
-
-#include "logger.h"
-
-#include "enums/gui/usercolorid.h"
-
-#include "gui/palette.h"
-
-#include "gui/models/listmodel.h"
-
-/**
- * Class controlling the game's color palette.
- */
-class UserPalette final : public Palette, public ListModel
-{
- public:
- /**
- * Constructor
- */
- UserPalette();
-
- A_DELETE_COPY(UserPalette)
-
- /**
- * Destructor
- */
- ~UserPalette();
-
- /**
- * Gets the committed color associated with the specified type.
- *
- * @param type the color type requested
- *
- * @return the requested committed color
- */
- inline const Color &getCommittedColor(const UserColorIdT type)
- const A_WARN_UNUSED
- {
- return mColors[CAST_SIZE(type)].committedColor;
- }
-
- /**
- * Gets the test color associated with the specified type.
- *
- * @param type the color type requested
- *
- * @return the requested test color
- */
- inline const Color &getTestColor(const UserColorIdT type)
- const A_WARN_UNUSED
- { return mColors[CAST_SIZE(type)].testColor; }
-
- /**
- * Sets the test color associated with the specified type.
- *
- * @param type the color type requested
- * @param color the color that should be tested
- */
- inline void setTestColor(const UserColorIdT type,
- const Color &color)
- { mColors[CAST_SIZE(type)].testColor = color; }
-
- /**
- * Sets the color for the specified type.
- *
- * @param type color to be set
- * @param r red component
- * @param g green component
- * @param b blue component
- */
- void setColor(const UserColorIdT type,
- const int r,
- const int g,
- const int b);
-
- /**
- * Sets the gradient type for the specified color.
- *
- * @param grad gradient type to set
- */
- void setGradient(const UserColorIdT type,
- const GradientTypeT grad);
-
- void setGradientDelay(const UserColorIdT type,
- const int delay)
- { mColors[CAST_SIZE(type)].delay = delay; }
-
- /**
- * Returns the number of colors known.
- *
- * @return the number of colors known
- */
- inline int getNumberOfElements() override final A_WARN_UNUSED
- { return CAST_S32(mColors.size()); }
-
- /**
- * Returns the name of the ith color.
- *
- * @param i index of color interested in
- *
- * @return the name of the color
- */
- std::string getElementAt(int i) override final A_WARN_UNUSED;
-
- /**
- * Commit the colors
- */
- inline void commit()
- { commit(false); }
-
- /**
- * Rollback the colors
- */
- void rollback();
-
- /**
- * Gets the ColorType used by the color for the element at index i in
- * the current color model.
- *
- * @param i the index of the color
- *
- * @return the color type of the color with the given index
- */
- int getColorTypeAt(const int i) A_WARN_UNUSED;
-
- /**
- * Gets the color associated with the type. Sets the alpha channel
- * before returning.
- *
- * @param type the color type requested
- * @param alpha alpha channel to use
- *
- * @return the requested color
- */
- inline const Color &getColor(UserColorIdT type,
- const unsigned int alpha = 255U)
- A_WARN_UNUSED
- {
- if (CAST_SIZE(type) >= mColors.size())
- {
- logger->log("incorrect color request type: %d from %u",
- CAST_S32(type),
- CAST_U32(mColors.size()));
- type = UserColorId::BEING;
- }
- Color* col = &mColors[CAST_SIZE(type)].color;
- col->a = alpha;
- return *col;
- }
-
- int getIdByChar(const signed char c, bool &valid) const A_WARN_UNUSED;
-
- /**
- * Gets the GradientType associated with the specified type.
- *
- * @param type the color type of the color
- *
- * @return the gradient type of the color with the given index
- */
- inline GradientTypeT getGradientType(const UserColorIdT type)
- const A_WARN_UNUSED
- { return mColors[CAST_SIZE(type)].grad; }
-
- /**
- * Gets the gradient delay for the specified type.
- *
- * @param type the color type of the color
- *
- * @return the gradient delay of the color with the given index
- */
- inline int getGradientDelay(const UserColorIdT type)
- const A_WARN_UNUSED
- { return mColors[CAST_SIZE(type)].delay; }
-
- inline const Color &getColorWithAlpha(const UserColorIdT type)
- A_WARN_UNUSED
- {
- Color *const col = &mColors[CAST_SIZE(type)].color;
- col->a = CAST_U32(
- mColors[CAST_SIZE(type)].delay);
- return *col;
- }
-
- private:
- /**
- * Define a color replacement.
- *
- * @param i the index of the color to replace
- * @param r red component
- * @param g green component
- * @param b blue component
- */
- void setColorAt(int i, int r, int g, int b);
-
- /**
- * Commit the colors. Commit the non-static color values, if
- * commitNonStatic is true. Only needed in the constructor.
- */
- void commit(const bool commitNonStatic);
-
- /**
- * Prefixes the given string with "Color", lowercases all letters but
- * the first and all following a '_'. All '_'s will be removed.
- *
- * E.g.: HIT_PLAYER_MONSTER -> HitPlayerMonster
- *
- * @param typeName string to transform
- *
- * @return the transformed string
- */
- static std::string getConfigName(const std::string &typeName)
- A_WARN_UNUSED;
-
- void addColor(const UserColorIdT type,
- const unsigned rgb,
- GradientTypeT grad,
- const std::string &text,
- int delay = GRADIENT_DELAY);
-
- void addLabel(const UserColorIdT type,
- const std::string &text);
-};
-
-extern UserPalette *userPalette;
-
-#endif // GUI_USERPALETTE_H
diff --git a/src/gui/viewport.h b/src/gui/viewport.h
deleted file mode 100644
index 615e1d796..000000000
--- a/src/gui/viewport.h
+++ /dev/null
@@ -1,32 +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 GUI_VIEWPORT_H
-#define GUI_VIEWPORT_H
-
-#ifdef DYECMD
-#include "progs/dyecmd/gui/viewport.h"
-PROGS_DYECMD_GUI_VIEWPORT_H
-#else
-#include "progs/manaplus/gui/viewport.h"
-PROGS_MANAPLUS_GUI_VIEWPORT_H
-#endif // DYECMD
-
-#endif // GUI_VIEWPORT_H
diff --git a/src/gui/widgets/attrs/attrdisplay.cpp b/src/gui/widgets/attrs/attrdisplay.cpp
deleted file mode 100644
index 3b91fef9d..000000000
--- a/src/gui/widgets/attrs/attrdisplay.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 "gui/widgets/attrs/attrdisplay.h"
-
-#include "being/playerinfo.h"
-
-#include "gui/widgets/layouthelper.h"
-
-#include "utils/delete2.h"
-#include "utils/stringutils.h"
-
-#include "debug.h"
-
-AttrDisplay::AttrDisplay(const Widget2 *const widget,
- const AttributesT id,
- const std::string &restrict name,
- const std::string &restrict shortName) :
- Container(widget),
- mId(id),
- mName(name),
- mShortName(shortName),
- mLayout(new LayoutHelper(this)),
- mLabel(new Label(this, name)),
- mValue(new Label(this, "1 "))
-{
- setSize(100, 32);
-
- setSelectable(false);
- mLabel->setAlignment(Graphics::CENTER);
- mValue->setAlignment(Graphics::CENTER);
-}
-
-AttrDisplay::~AttrDisplay()
-{
- delete2(mLayout);
-}
-
-std::string AttrDisplay::update()
-{
- const int base = PlayerInfo::getStatBase(mId);
- const int bonus = PlayerInfo::getStatMod(mId);
- std::string value = toString(base + bonus);
- if (bonus != 0)
- value.append(strprintf("=%d%+d", base, bonus));
- mValue->setCaption(value);
- return mName;
-}
diff --git a/src/gui/widgets/attrs/attrdisplay.h b/src/gui/widgets/attrs/attrdisplay.h
deleted file mode 100644
index f682e41f5..000000000
--- a/src/gui/widgets/attrs/attrdisplay.h
+++ /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/>.
- */
-
-#ifndef GUI_WIDGETS_ATTRS_ATTRDISPLAY_H
-#define GUI_WIDGETS_ATTRS_ATTRDISPLAY_H
-
-#include "enums/being/attributes.h"
-
-#include "gui/widgets/container.h"
-
-#include "gui/widgets/label.h"
-
-#include "localconsts.h"
-
-class LayoutHelper;
-
-class AttrDisplay notfinal : public Container
-{
- public:
- enum Type
- {
- DERIVED = 0,
- CHANGEABLE,
- UNKNOWN
- };
-
- A_DELETE_COPY(AttrDisplay)
-
- virtual ~AttrDisplay();
-
- virtual std::string update();
-
- virtual Type getType() const
- { return UNKNOWN; }
-
- std::string getValue() const
- {
- if (mValue == nullptr)
- return "-";
- return mValue->getCaption();
- }
-
- const std::string &getShortName() const
- { return mShortName; }
-
- protected:
- AttrDisplay(const Widget2 *const widget,
- const AttributesT id,
- const std::string &restrict name,
- const std::string &restrict shortName);
-
- const AttributesT mId;
- const std::string mName;
- const std::string mShortName;
-
- LayoutHelper *mLayout;
- Label *mLabel;
- Label *mValue;
-};
-
-typedef std::map<AttributesT, AttrDisplay*> Attrs;
-
-#endif // GUI_WIDGETS_ATTRS_ATTRDISPLAY_H
diff --git a/src/gui/widgets/attrs/changedisplay.cpp b/src/gui/widgets/attrs/changedisplay.cpp
deleted file mode 100644
index e1af1eb76..000000000
--- a/src/gui/widgets/attrs/changedisplay.cpp
+++ /dev/null
@@ -1,119 +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 "gui/widgets/attrs/changedisplay.h"
-
-#include "configuration.h"
-
-#include "being/playerinfo.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/containerplacer.h"
-#include "gui/widgets/layouthelper.h"
-
-#include "net/net.h"
-#include "net/playerhandler.h"
-
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-ChangeDisplay::ChangeDisplay(const Widget2 *const widget,
- const AttributesT id,
- const std::string &restrict name,
- const std::string &restrict shortName) :
- AttrDisplay(widget, id, name, shortName),
- ActionListener(),
- mNeeded(1),
- // TRANSLATORS: status window label
- mPoints(new Label(this, _("Max"))),
- // TRANSLATORS: status window label (plus sign)
- mInc(new Button(this, _("+"), "inc", this))
-{
- // Do the layout
- ContainerPlacer place = mLayout->getPlacer(0, 0);
-
- place(0, 0, mLabel, 3);
- place(4, 0, mValue, 2);
- place(6, 0, mInc);
- place(7, 0, mPoints);
-}
-
-std::string ChangeDisplay::update()
-{
- if (mNeeded > 0)
- {
- mPoints->setCaption(toString(mNeeded));
- }
- else
- {
- // TRANSLATORS: status bar label
- mPoints->setCaption(_("Max"));
- }
-
- mInc->setEnabled(PlayerInfo::getAttribute(Attributes::PLAYER_CHAR_POINTS)
- >= mNeeded && mNeeded > 0);
-
- return AttrDisplay::update();
-}
-
-void ChangeDisplay::setPointsNeeded(const int needed)
-{
- mNeeded = needed;
- update();
-}
-
-void ChangeDisplay::action(const ActionEvent &event)
-{
- if (event.getSource() == mInc)
- {
- int cnt = 1;
- if (config.getBoolValue("quickStats"))
- {
- cnt = mInc->getClickCount();
- if (cnt > 10)
- cnt = 10;
- }
-
- const int newpoints = PlayerInfo::getAttribute(
- Attributes::PLAYER_CHAR_POINTS) - cnt;
- PlayerInfo::setAttribute(Attributes::PLAYER_CHAR_POINTS,
- newpoints);
-
- const int newbase = PlayerInfo::getStatBase(mId) + cnt;
- PlayerInfo::setStatBase(mId, newbase);
-
- if (Net::getNetworkType() != ServerType::TMWATHENA)
- {
- playerHandler->increaseAttribute(mId, cnt);
- }
- else
- {
- for (int f = 0; f < cnt; f ++)
- {
- playerHandler->increaseAttribute(mId, 1);
- if (cnt != 1)
- SDL_Delay(100);
- }
- }
- }
-}
diff --git a/src/gui/widgets/attrs/changedisplay.h b/src/gui/widgets/attrs/changedisplay.h
deleted file mode 100644
index 4e9d1076d..000000000
--- a/src/gui/widgets/attrs/changedisplay.h
+++ /dev/null
@@ -1,61 +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_ATTRS_CHANGEDISPLAY_H
-#define GUI_WIDGETS_ATTRS_CHANGEDISPLAY_H
-
-#include "gui/widgets/attrs/attrdisplay.h"
-
-#include "listeners/actionlistener.h"
-
-#include "localconsts.h"
-
-class Button;
-
-class ChangeDisplay final : public AttrDisplay,
- public ActionListener
-{
- public:
- ChangeDisplay(const Widget2 *const widget,
- const AttributesT id,
- const std::string &restrict name,
- const std::string &restrict shortName);
-
- A_DELETE_COPY(ChangeDisplay)
-
- std::string update() override final;
-
- Type getType() const override final
- { return CHANGEABLE; }
-
- void setPointsNeeded(const int needed);
-
- void action(const ActionEvent &event) override final;
-
- private:
- int mNeeded;
-
- Label *mPoints;
- Button *mInc;
-};
-
-#endif // GUI_WIDGETS_ATTRS_CHANGEDISPLAY_H
diff --git a/src/gui/widgets/attrs/derdisplay.cpp b/src/gui/widgets/attrs/derdisplay.cpp
deleted file mode 100644
index 2c20c3713..000000000
--- a/src/gui/widgets/attrs/derdisplay.cpp
+++ /dev/null
@@ -1,40 +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 "gui/widgets/attrs/derdisplay.h"
-
-#include "gui/widgets/containerplacer.h"
-#include "gui/widgets/layouthelper.h"
-
-#include "debug.h"
-
-DerDisplay::DerDisplay(const Widget2 *const widget,
- const AttributesT id,
- const std::string &restrict name,
- const std::string &restrict shortName) :
- AttrDisplay(widget, id, name, shortName)
-{
- ContainerPlacer place = mLayout->getPlacer(0, 0);
-
- place(0, 0, mLabel, 3);
- place(3, 0, mValue, 2);
-}
diff --git a/src/gui/widgets/attrs/derdisplay.h b/src/gui/widgets/attrs/derdisplay.h
deleted file mode 100644
index 8b841694e..000000000
--- a/src/gui/widgets/attrs/derdisplay.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 GUI_WIDGETS_ATTRS_DERDISPLAY_H
-#define GUI_WIDGETS_ATTRS_DERDISPLAY_H
-
-#include "gui/widgets/attrs/attrdisplay.h"
-
-#include "localconsts.h"
-
-class DerDisplay final : public AttrDisplay
-{
- public:
- DerDisplay(const Widget2 *const widget,
- const AttributesT id,
- const std::string &restrict name,
- const std::string &restrict shortName);
-
- A_DELETE_COPY(DerDisplay)
-
- Type getType() const override final
- { return DERIVED; }
-};
-
-#endif // GUI_WIDGETS_ATTRS_DERDISPLAY_H
diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp
deleted file mode 100644
index 383efb397..000000000
--- a/src/gui/widgets/avatarlistbox.cpp
+++ /dev/null
@@ -1,740 +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 "gui/widgets/avatarlistbox.h"
-
-#include "actormanager.h"
-#include "configuration.h"
-
-#include "being/localplayer.h"
-
-#include "enums/resources/map/mapitemtype.h"
-
-#include "gui/gui.h"
-#include "gui/popupmanager.h"
-#include "gui/skin.h"
-#include "gui/viewport.h"
-
-#include "gui/fonts/font.h"
-
-#include "gui/popups/popupmenu.h"
-
-#include "gui/models/avatarlistmodel.h"
-
-#include "gui/windows/chatwindow.h"
-
-#include "render/vertexes/imagecollection.h"
-
-#include "resources/image/image.h"
-
-#include "resources/map/map.h"
-
-#include "debug.h"
-
-int AvatarListBox::instances = 0;
-Image *AvatarListBox::onlineIcon = nullptr;
-Image *AvatarListBox::offlineIcon = nullptr;
-
-AvatarListBox::AvatarListBox(const Widget2 *const widget,
- AvatarListModel *const model) :
- ListBox(widget, model, "avatarlistbox.xml"),
- mImagePadding(mSkin != nullptr ? mSkin->getOption("imagePadding") : 0),
- mShowGender(config.getBoolValue("showgender")),
- mShowLevel(config.getBoolValue("showlevel"))
-{
- instances++;
-
- if (instances == 1)
- {
- onlineIcon = Theme::getImageFromThemeXml("circle-on.xml", "");
- offlineIcon = Theme::getImageFromThemeXml("circle-off.xml", "");
- }
-
- setWidth(200);
-
- config.addListener("showgender", this);
- config.addListener("showlevel", this);
-
- mForegroundColor = getThemeColor(ThemeColorId::TEXT);
- mForegroundColor2 = getThemeColor(ThemeColorId::TEXT_OUTLINE);
-}
-
-AvatarListBox::~AvatarListBox()
-{
- config.removeListeners(this);
- CHECKLISTENERS
-
- instances--;
-
- if (instances == 0)
- {
- if (onlineIcon != nullptr)
- {
- onlineIcon->decRef();
- onlineIcon = nullptr;
- }
- if (offlineIcon != nullptr)
- {
- offlineIcon->decRef();
- offlineIcon = nullptr;
- }
- }
-}
-
-void AvatarListBox::draw(Graphics *const graphics)
-{
- BLOCK_START("AvatarListBox::draw")
- if ((mListModel == nullptr) || (localPlayer == nullptr))
- {
- BLOCK_END("AvatarListBox::draw")
- return;
- }
-
- const Widget *const parent = mParent;
- if (parent == nullptr)
- return;
-
- AvatarListModel *const model = static_cast<AvatarListModel *>(
- mListModel);
- updateAlpha();
-
- Font *const font = getFont();
- const int fontHeight = font->getHeight();
- const int parentWidth = parent->getWidth();
- const std::string &name = localPlayer->getName();
-
- // Draw the list elements
- ImageCollection vertexes;
- const int num = model->getNumberOfElements();
- for (int i = 0, y = 0;
- i < num;
- ++i, y += fontHeight)
- {
- const Avatar *const a = model->getAvatarAt(i);
- if (a == nullptr)
- continue;
-
- const MapItemType::Type type = static_cast<MapItemType::Type>(
- a->getType());
- if (type != MapItemType::SEPARATOR)
- {
- // Draw online status
- const Image *const icon = a->getOnline()
- ? onlineIcon : offlineIcon;
- if (icon != nullptr)
- {
- graphics->calcTileCollection(&vertexes, icon,
- mImagePadding, y + mPadding);
- }
- }
- }
-
- graphics->finalize(&vertexes);
- graphics->drawTileCollection(&vertexes);
-
- for (int i = 0, y = 0;
- i < num;
- ++i, y += fontHeight)
- {
- const Avatar *const a = model->getAvatarAt(i);
- if (a == nullptr)
- continue;
-
- const MapItemType::Type type = static_cast<MapItemType::Type>(
- a->getType());
- std::string text;
-
- if (a->getMaxHp() > 0)
- {
- if (mShowLevel && a->getLevel() > 1)
- {
- text = strprintf("%s %d/%d (%d)", a->getComplexName().c_str(),
- a->getHp(), a->getMaxHp(), a->getLevel());
- }
- else
- {
- text = strprintf("%s %d/%d", a->getComplexName().c_str(),
- a->getHp(), a->getMaxHp());
- }
- const bool isPoison = a->getPoison();
- if (a->getMaxHp() != 0)
- {
- const ProgressColorIdT themeColor = (isPoison
- ? ProgressColorId::PROG_HP_POISON
- : ProgressColorId::PROG_HP);
- Color color = Theme::getProgressColor(
- themeColor, static_cast<float>(a->getHp())
- / static_cast<float>(a->getMaxHp()));
- color.a = 80;
- graphics->setColor(color);
- graphics->fillRectangle(Rect(mPadding, y + mPadding,
- parentWidth * a->getHp() / a->getMaxHp()
- - 2 * mPadding, fontHeight));
- }
- }
- else if (a->getDamageHp() != 0 && a->getName() != name)
- {
- if (mShowLevel && a->getLevel() > 1)
- {
- text = strprintf("%s -%d (%d)", a->getComplexName().c_str(),
- a->getDamageHp(), a->getLevel());
- }
- else
- {
- text = strprintf("%s -%d", a->getComplexName().c_str(),
- a->getDamageHp());
- }
-
- const ProgressColorIdT themeColor = (a->getPoison()
- ? ProgressColorId::PROG_HP_POISON : ProgressColorId::PROG_HP);
- Color color = Theme::getProgressColor(themeColor, 1);
- color.a = 80;
- graphics->setColor(color);
- graphics->fillRectangle(Rect(mPadding, y + mPadding,
- parentWidth * a->getDamageHp() / 1024
- - 2 * mPadding, fontHeight));
-
- if (a->getLevel() > 1)
- {
- graphics->setColor(mForegroundColor);
- int minHp = 40 + ((a->getLevel() - 1) * 5);
- if (minHp < 0)
- minHp = 40;
-
- graphics->drawLine(parentWidth * minHp / 1024
- + mPadding, y + mPadding,
- parentWidth * minHp / 1024, y + fontHeight);
- }
- }
- else
- {
- if (mShowLevel && a->getLevel() > 1)
- {
- text = strprintf("%s (%d)", a->getComplexName().c_str(),
- a->getLevel());
- }
- else
- {
- text = a->getComplexName();
- }
- }
-
- if (!a->getMap().empty())
- {
- if (a->getX() != -1)
- {
- text.append(strprintf(" [%d,%d %s]", a->getX(), a->getY(),
- a->getMap().c_str()));
- }
- else
- {
- text.append(strprintf(" [%s]", a->getMap().c_str()));
- }
- }
-
- if (graphics->getSecure())
- {
- if (mShowGender)
- {
- switch (a->getGender())
- {
- case Gender::FEMALE:
- text.append(" \u2640 ");
- break;
- case Gender::MALE:
- text.append(" \u2642 ");
- break;
- default:
- case Gender::UNSPECIFIED:
- case Gender::OTHER:
- break;
- }
- }
- }
- else
- {
- if (mShowGender)
- {
- switch (a->getGender())
- {
- case Gender::FEMALE:
- text.append(strprintf(" \u2640 %s",
- a->getAdditionString().c_str()));
- break;
- case Gender::MALE:
- text.append(strprintf(" \u2642 %s",
- a->getAdditionString().c_str()));
- break;
- default:
- case Gender::UNSPECIFIED:
- case Gender::OTHER:
- break;
- }
- }
- else
- {
- text.append(a->getAdditionString());
- }
- }
-
- // Draw Name
- if (a->getDisplayBold())
- {
- if (type == MapItemType::SEPARATOR)
- {
- boldFont->drawString(graphics,
- mForegroundColor,
- mForegroundColor,
- text,
- mImagePadding + mPadding,
- y + mPadding);
- }
- else
- {
- boldFont->drawString(graphics,
- mForegroundColor,
- mForegroundColor,
- text,
- 15 + mImagePadding + mPadding,
- y + mPadding);
- }
- }
- else
- {
- if (type == MapItemType::SEPARATOR)
- {
- font->drawString(graphics,
- mForegroundColor,
- mForegroundColor,
- text,
- mImagePadding + mPadding,
- y + mPadding);
- }
- else
- {
- font->drawString(graphics,
- mForegroundColor,
- mForegroundColor,
- text,
- 15 + mImagePadding + mPadding,
- y + mPadding);
- }
- }
- }
-
- setWidth(parentWidth - 10);
- BLOCK_END("AvatarListBox::draw")
-}
-
-void AvatarListBox::safeDraw(Graphics *const graphics)
-{
- BLOCK_START("AvatarListBox::draw")
- if ((mListModel == nullptr) || (localPlayer == nullptr))
- {
- BLOCK_END("AvatarListBox::draw")
- return;
- }
-
- const Widget *const parent = mParent;
- if (parent == nullptr)
- return;
-
- AvatarListModel *const model = static_cast<AvatarListModel *>(
- mListModel);
- updateAlpha();
-
- Font *const font = getFont();
- const int fontHeight = font->getHeight();
- const int parentWidth = parent->getWidth();
- const std::string &name = localPlayer->getName();
-
- // Draw the list elements
- const int num = model->getNumberOfElements();
- for (int i = 0, y = 0;
- i < num;
- ++i, y += fontHeight)
- {
- const Avatar *const a = model->getAvatarAt(i);
- if (a == nullptr)
- continue;
-
- const MapItemType::Type type = static_cast<MapItemType::Type>(
- a->getType());
- if (type != MapItemType::SEPARATOR)
- {
- // Draw online status
- const Image *const icon = a->getOnline()
- ? onlineIcon : offlineIcon;
- if (icon != nullptr)
- graphics->drawImage(icon, mImagePadding, y + mPadding);
- }
- }
-
- for (int i = 0, y = 0;
- i < model->getNumberOfElements();
- ++i, y += fontHeight)
- {
- const Avatar *const a = model->getAvatarAt(i);
- if (a == nullptr)
- continue;
-
- const MapItemType::Type type = static_cast<MapItemType::Type>(
- a->getType());
- std::string text;
-
- if (a->getMaxHp() > 0)
- {
- if (mShowLevel && a->getLevel() > 1)
- {
- text = strprintf("%s %d/%d (%d)", a->getComplexName().c_str(),
- a->getHp(), a->getMaxHp(), a->getLevel());
- }
- else
- {
- text = strprintf("%s %d/%d", a->getComplexName().c_str(),
- a->getHp(), a->getMaxHp());
- }
- const bool isPoison = a->getPoison();
- if (a->getMaxHp() != 0)
- {
- const ProgressColorIdT themeColor = (isPoison
- ? ProgressColorId::PROG_HP_POISON
- : ProgressColorId::PROG_HP);
- Color color = Theme::getProgressColor(
- themeColor, static_cast<float>(a->getHp())
- / static_cast<float>(a->getMaxHp()));
- color.a = 80;
- graphics->setColor(color);
- graphics->fillRectangle(Rect(mPadding, y + mPadding,
- parentWidth * a->getHp() / a->getMaxHp()
- - 2 * mPadding, fontHeight));
- }
- }
- else if (a->getDamageHp() != 0 && a->getName() != name)
- {
- if (mShowLevel && a->getLevel() > 1)
- {
- text = strprintf("%s -%d (%d)", a->getComplexName().c_str(),
- a->getDamageHp(), a->getLevel());
- }
- else
- {
- text = strprintf("%s -%d", a->getComplexName().c_str(),
- a->getDamageHp());
- }
-
- const ProgressColorIdT themeColor = (a->getPoison()
- ? ProgressColorId::PROG_HP_POISON : ProgressColorId::PROG_HP);
- Color color = Theme::getProgressColor(themeColor, 1);
- color.a = 80;
- graphics->setColor(color);
- graphics->fillRectangle(Rect(mPadding, y + mPadding,
- parentWidth * a->getDamageHp() / 1024
- - 2 * mPadding, fontHeight));
-
- if (a->getLevel() > 1)
- {
- graphics->setColor(mForegroundColor);
- int minHp = 40 + ((a->getLevel() - 1) * 5);
- if (minHp < 0)
- minHp = 40;
-
- graphics->drawLine(parentWidth * minHp / 1024
- + mPadding, y + mPadding,
- parentWidth * minHp / 1024, y + fontHeight);
- }
- }
- else
- {
- if (mShowLevel && a->getLevel() > 1)
- {
- text = strprintf("%s (%d)", a->getComplexName().c_str(),
- a->getLevel());
- }
- else
- {
- text = a->getComplexName();
- }
- }
-
- if (!a->getMap().empty())
- {
- if (a->getX() != -1)
- {
- text.append(strprintf(" [%d,%d %s]", a->getX(), a->getY(),
- a->getMap().c_str()));
- }
- else
- {
- text.append(strprintf(" [%s]", a->getMap().c_str()));
- }
- }
-
- if (graphics->getSecure())
- {
- if (mShowGender)
- {
- switch (a->getGender())
- {
- case Gender::FEMALE:
- text.append(" \u2640 ");
- break;
- case Gender::MALE:
- text.append(" \u2642 ");
- break;
- default:
- case Gender::UNSPECIFIED:
- case Gender::OTHER:
- break;
- }
- }
- }
- else
- {
- if (mShowGender)
- {
- switch (a->getGender())
- {
- case Gender::FEMALE:
- text.append(strprintf(" \u2640 %s",
- a->getAdditionString().c_str()));
- break;
- case Gender::MALE:
- text.append(strprintf(" \u2642 %s",
- a->getAdditionString().c_str()));
- break;
- default:
- case Gender::UNSPECIFIED:
- case Gender::OTHER:
- break;
- }
- }
- else
- {
- text.append(a->getAdditionString());
- }
- }
-
- // Draw Name
- if (a->getDisplayBold())
- {
- if (type == MapItemType::SEPARATOR)
- {
- boldFont->drawString(graphics,
- mForegroundColor,
- mForegroundColor,
- text,
- mImagePadding + mPadding,
- y + mPadding);
- }
- else
- {
- boldFont->drawString(graphics,
- mForegroundColor,
- mForegroundColor,
- text,
- 15 + mImagePadding + mPadding,
- y + mPadding);
- }
- }
- else
- {
- if (type == MapItemType::SEPARATOR)
- {
- font->drawString(graphics,
- mForegroundColor,
- mForegroundColor,
- text,
- mImagePadding + mPadding,
- y + mPadding);
- }
- else
- {
- font->drawString(graphics,
- mForegroundColor,
- mForegroundColor,
- text,
- 15 + mImagePadding + mPadding,
- y + mPadding);
- }
- }
- }
-
- setWidth(parentWidth - 10);
- BLOCK_END("AvatarListBox::draw")
-}
-
-void AvatarListBox::mousePressed(MouseEvent &event)
-{
- if (actorManager == nullptr ||
- localPlayer == nullptr ||
- popupManager == nullptr)
- {
- return;
- }
-
- const int height = getFont()->getHeight();
- if (height == 0)
- return;
-
- const int y = (event.getY() - mPadding) / height;
- if ((mListModel == nullptr) || y > mListModel->getNumberOfElements())
- return;
-
- setSelected(y);
- distributeActionEvent();
- const int selected = getSelected();
- AvatarListModel *const model = static_cast<AvatarListModel *>(
- mListModel);
- if (model == nullptr)
- return;
- const Avatar *ava = model->getAvatarAt(selected);
- if (ava == nullptr)
- return;
-
- const MapItemType::Type type = static_cast<MapItemType::Type>(
- ava->getType());
-
- event.consume();
- const MouseButtonT eventButton = event.getButton();
- if (eventButton == MouseButton::LEFT)
- {
-#ifdef TMWA_SUPPORT
- if (type == MapItemType::EMPTY)
- {
- const Being *const being = actorManager->findBeingByName(
- ava->getName(), ActorType::Player);
- if (being != nullptr)
- actorManager->heal(being);
- }
- else
-#endif // TMWA_SUPPORT
- {
- localPlayer->navigateTo(ava->getX(), ava->getY());
- }
- }
- else if (eventButton == MouseButton::RIGHT)
- {
- switch (type)
- {
- case MapItemType::EMPTY:
- {
- const Avatar *const avatar = model->getAvatarAt(selected);
- if (avatar != nullptr)
- {
- const Being *const being = actorManager->findBeingByName(
- avatar->getName(), ActorType::Player);
- if (being != nullptr)
- {
- popupMenu->showPopup(viewport->mMouseX,
- viewport->mMouseY,
- being);
- }
- else
- {
- popupMenu->showPlayerPopup(avatar->getName());
- }
- }
- break;
- }
- case MapItemType::ATTACK:
- case MapItemType::PRIORITY:
- case MapItemType::IGNORE_:
- {
- std::string name;
- if (model->getAvatarAt(selected)->getLevel() == 0)
- name.clear();
- else
- name = model->getAvatarAt(selected)->getName();
-
- popupMenu->showAttackMonsterPopup(viewport->mMouseX,
- viewport->mMouseY,
- name,
- model->getAvatarAt(selected)->getType());
- break;
- }
- case MapItemType::PICKUP:
- case MapItemType::NOPICKUP:
- {
- std::string name;
- if (model->getAvatarAt(selected)->getLevel() == 0)
- name.clear();
- else
- name = model->getAvatarAt(selected)->getName();
-
- popupMenu->showPickupItemPopup(viewport->mMouseX,
- viewport->mMouseY,
- name);
- break;
- }
- case MapItemType::HOME:
- case MapItemType::ROAD:
- case MapItemType::CROSS:
- case MapItemType::ARROW_UP:
- case MapItemType::ARROW_DOWN:
- case MapItemType::ARROW_LEFT:
- case MapItemType::ARROW_RIGHT:
- case MapItemType::PORTAL:
- case MapItemType::MUSIC:
- case MapItemType::SEPARATOR:
- {
- break;
- }
- default:
- {
- const Map *const map = viewport->getMap();
- ava = model->getAvatarAt(selected);
- if ((map != nullptr) && (ava != nullptr))
- {
- MapItem *const mapItem = map->findPortalXY(
- ava->getX(), ava->getY());
- popupMenu->showPopup(viewport->mMouseX,
- viewport->mMouseY,
- mapItem);
- }
- break;
- }
- }
- }
- else if (eventButton == MouseButton::MIDDLE)
- {
- if (type == MapItemType::EMPTY && (chatWindow != nullptr))
- {
- const std::string &name = model->getAvatarAt(selected)->getName();
- const WhisperTab *const tab = chatWindow->addWhisperTab(
- name, name, true);
- if (tab != nullptr)
- chatWindow->saveState();
- }
- }
-}
-
-void AvatarListBox::mouseReleased(MouseEvent &event A_UNUSED)
-{
-}
-
-void AvatarListBox::optionChanged(const std::string &value)
-{
- if (value == "showgender")
- mShowGender = config.getBoolValue("showgender");
- else if (value == "showlevel")
- mShowLevel = config.getBoolValue("showlevel");
-}
diff --git a/src/gui/widgets/avatarlistbox.h b/src/gui/widgets/avatarlistbox.h
deleted file mode 100644
index 8af27256b..000000000
--- a/src/gui/widgets/avatarlistbox.h
+++ /dev/null
@@ -1,64 +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 GUI_WIDGETS_AVATARLISTBOX_H
-#define GUI_WIDGETS_AVATARLISTBOX_H
-
-#include "gui/widgets/listbox.h"
-
-class AvatarListModel;
-class Image;
-
-class AvatarListBox final : public ListBox,
- public ConfigListener
-{
- public:
- AvatarListBox(const Widget2 *const widget,
- AvatarListModel *const model);
-
- A_DELETE_COPY(AvatarListBox)
-
- ~AvatarListBox();
-
- /**
- * Draws the list box.
- */
- void draw(Graphics *gcnGraphics) override final A_NONNULL(2);
-
- void safeDraw(Graphics *gcnGraphics) override final A_NONNULL(2);
-
- void mousePressed(MouseEvent &event) override final;
-
- void mouseReleased(MouseEvent &event A_UNUSED) override final A_CONST;
-
- void optionChanged(const std::string &value) override final;
-
- private:
- int mImagePadding;
- bool mShowGender;
- bool mShowLevel;
-
- static int instances;
- static Image *onlineIcon;
- static Image *offlineIcon;
-};
-
-#endif // GUI_WIDGETS_AVATARLISTBOX_H
diff --git a/src/gui/widgets/basiccontainer.cpp b/src/gui/widgets/basiccontainer.cpp
deleted file mode 100644
index 768733ae5..000000000
--- a/src/gui/widgets/basiccontainer.cpp
+++ /dev/null
@@ -1,439 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "gui/widgets/basiccontainer.h"
-
-#include "utils/foreach.h"
-
-#include "render/graphics.h"
-
-#include <algorithm>
-
-#include "debug.h"
-
-BasicContainer::~BasicContainer()
-{
- clear();
-}
-
-void BasicContainer::moveToTop(Widget *const widget) restrict2
-{
- FOR_EACH (WidgetListIterator, iter, mWidgets)
- {
- if (*iter == widget)
- {
- mWidgets.erase(iter);
- mWidgets.push_back(widget);
- break;
- }
- }
- FOR_EACH (WidgetListIterator, iter, mLogicWidgets)
- {
- if (*iter == widget)
- {
- mLogicWidgets.erase(iter);
- mLogicWidgets.push_back(widget);
- return;
- }
- }
-}
-
-void BasicContainer::moveToBottom(Widget *const widget) restrict2
-{
- const WidgetListIterator iter = std::find(mWidgets.begin(),
- mWidgets.end(), widget);
- if (iter != mWidgets.end())
- {
- mWidgets.erase(iter);
- mWidgets.insert(mWidgets.begin(), widget);
- }
-
- const WidgetListIterator iter2 = std::find(mLogicWidgets.begin(),
- mLogicWidgets.end(), widget);
- if (iter2 != mLogicWidgets.end())
- {
- mLogicWidgets.erase(iter2);
- mLogicWidgets.insert(mLogicWidgets.begin(), widget);
- }
-}
-
-void BasicContainer::death(const Event &restrict event) restrict2
-{
- const WidgetListIterator iter = std::find(mWidgets.begin(),
- mWidgets.end(), event.getSource());
- if (iter != mWidgets.end())
- mWidgets.erase(iter);
-
- const WidgetListIterator iter2 = std::find(mLogicWidgets.begin(),
- mLogicWidgets.end(), event.getSource());
- if (iter2 != mLogicWidgets.end())
- mLogicWidgets.erase(iter2);
-}
-
-Rect BasicContainer::getChildrenArea() restrict2
-{
- return Rect(0, 0, mDimension.width, mDimension.height);
-}
-
-void BasicContainer::focusNext() restrict2
-{
- WidgetListConstIterator it;
-
- for (it = mWidgets.begin(); it != mWidgets.end(); ++ it)
- {
- if ((*it)->isFocused())
- break;
- }
-
- const WidgetListConstIterator end = it;
-
- if (it == mWidgets.end())
- it = mWidgets.begin();
-
- ++ it;
-
- for ( ; it != end; ++ it)
- {
- if (it == mWidgets.end())
- it = mWidgets.begin();
-
- if ((*it)->isFocusable())
- {
- (*it)->requestFocus();
- return;
- }
- }
-}
-
-void BasicContainer::focusPrevious() restrict2
-{
- WidgetListReverseIterator it;
-
- for (it = mWidgets.rbegin(); it != mWidgets.rend(); ++ it)
- {
- if ((*it)->isFocused())
- break;
- }
-
- const WidgetListReverseIterator end = it;
-
- ++ it;
-
- if (it == mWidgets.rend())
- it = mWidgets.rbegin();
-
- for ( ; it != end; ++ it)
- {
- if (it == mWidgets.rend())
- it = mWidgets.rbegin();
-
- if ((*it)->isFocusable())
- {
- (*it)->requestFocus();
- return;
- }
- }
-}
-
-Widget *BasicContainer::getWidgetAt(int x, int y) restrict2
-{
- const Rect r = getChildrenArea();
-
- if (!r.isPointInRect(x, y))
- return nullptr;
-
- x -= r.x;
- y -= r.y;
-
- for (WidgetListReverseIterator it = mWidgets.rbegin();
- it != mWidgets.rend(); ++ it)
- {
- const Widget *restrict const widget = *it;
- if (widget->isVisible() &&
- widget->getDimension().isPointInRect(x, y))
- {
- return *it;
- }
- }
-
- return nullptr;
-}
-
-void BasicContainer::logic() restrict2
-{
- BLOCK_START("BasicContainer::logic")
- if (mVisible == Visible_false)
- {
- BLOCK_END("BasicContainer::logic")
- return;
- }
- logicChildren();
- BLOCK_END("BasicContainer::logic")
-}
-
-void BasicContainer::setFocusHandler(FocusHandler *restrict2 const
- focusHandler) restrict2
-{
- Widget::setFocusHandler(focusHandler);
-
- if (mInternalFocusHandler != nullptr)
- return;
-
- FOR_EACH (WidgetListConstIterator, iter, mWidgets)
- (*iter)->setFocusHandler(focusHandler);
-}
-
-void BasicContainer::add(Widget *const widget) restrict2
-{
- if (widget == nullptr)
- return;
- mWidgets.push_back(widget);
- if (widget->isAllowLogic())
- mLogicWidgets.push_back(widget);
-
- if (mInternalFocusHandler == nullptr)
- widget->setFocusHandler(getFocusHandler());
- else
- widget->setFocusHandler(mInternalFocusHandler);
-
- widget->setParent(this);
- widget->addDeathListener(this);
-}
-
-void BasicContainer::remove(Widget *const restrict widget) restrict2
-{
- if (widget == nullptr)
- return;
- FOR_EACH (WidgetListIterator, iter, mWidgets)
- {
- if (*iter == widget)
- {
- mWidgets.erase(iter);
- widget->setFocusHandler(nullptr);
- widget->setWindow(nullptr);
- widget->setParent(nullptr);
- widget->removeDeathListener(this);
- break;
- }
- }
- FOR_EACH (WidgetListIterator, iter, mLogicWidgets)
- {
- if (*iter == widget)
- {
- mLogicWidgets.erase(iter);
- return;
- }
- }
-}
-
-void BasicContainer::clear() restrict2
-{
- FOR_EACH (WidgetListConstIterator, iter, mWidgets)
- {
- Widget *restrict const widget = *iter;
- widget->setFocusHandler(nullptr);
- widget->setWindow(nullptr);
- widget->setParent(nullptr);
- widget->removeDeathListener(this);
- }
-
- mWidgets.clear();
- mLogicWidgets.clear();
-}
-
-void BasicContainer::drawChildren(Graphics *const restrict graphics) restrict2
-{
- BLOCK_START("BasicContainer::drawChildren")
- graphics->pushClipArea(getChildrenArea());
-
- FOR_EACH (WidgetListConstIterator, iter, mWidgets)
- {
- Widget *restrict const widget = *iter;
- if (widget->mVisible == Visible_true)
- {
- // If the widget has a frame,
- // draw it before drawing the widget
- if (widget->mFrameSize > 0)
- {
- Rect rec = widget->mDimension;
- const int frame = CAST_S32(widget->mFrameSize);
- const int frame2 = frame * 2;
- rec.x -= frame;
- rec.y -= frame;
- rec.width += frame2;
- rec.height += frame2;
- graphics->pushClipArea(rec);
- BLOCK_START("BasicContainer::drawChildren 1")
- widget->drawFrame(graphics);
- BLOCK_END("BasicContainer::drawChildren 1")
- graphics->popClipArea();
- }
-
- graphics->pushClipArea(widget->mDimension);
- BLOCK_START("BasicContainer::drawChildren 2")
- widget->draw(graphics);
- BLOCK_END("BasicContainer::drawChildren 2")
- graphics->popClipArea();
- }
- }
-
- graphics->popClipArea();
- BLOCK_END("BasicContainer::drawChildren")
-}
-
-void BasicContainer::safeDrawChildren(Graphics *const restrict graphics)
- restrict2
-{
- BLOCK_START("BasicContainer::drawChildren")
- graphics->pushClipArea(getChildrenArea());
-
- FOR_EACH (WidgetListConstIterator, iter, mWidgets)
- {
- Widget *restrict const widget = *iter;
- if (widget->mVisible == Visible_true)
- {
- // If the widget has a frame,
- // draw it before drawing the widget
- if (widget->mFrameSize > 0)
- {
- Rect rec = widget->mDimension;
- const int frame = CAST_S32(widget->mFrameSize);
- const int frame2 = frame * 2;
- rec.x -= frame;
- rec.y -= frame;
- rec.width += frame2;
- rec.height += frame2;
- graphics->pushClipArea(rec);
- BLOCK_START("BasicContainer::drawChildren 1")
- widget->safeDrawFrame(graphics);
- BLOCK_END("BasicContainer::drawChildren 1")
- graphics->popClipArea();
- }
-
- graphics->pushClipArea(widget->mDimension);
- BLOCK_START("BasicContainer::drawChildren 2")
- widget->safeDraw(graphics);
- BLOCK_END("BasicContainer::drawChildren 2")
- graphics->popClipArea();
- }
- }
-
- graphics->popClipArea();
- BLOCK_END("BasicContainer::drawChildren")
-}
-
-void BasicContainer::logicChildren() restrict2
-{
- BLOCK_START("BasicContainer::logicChildren")
- FOR_EACH (WidgetListConstIterator, iter, mLogicWidgets)
- (*iter)->logic();
- BLOCK_END("BasicContainer::logicChildren")
-}
-
-void BasicContainer::showWidgetPart(Widget *restrict const widget,
- const Rect &restrict area) restrict2
-{
- if (widget == nullptr)
- return;
-
- const Rect widgetArea = getChildrenArea();
-
- const int x = widget->mDimension.x;
- const int y = widget->mDimension.y;
- const int ax = area.x + x;
- const int ay = area.y + y;
-
- if (ax < 0)
- widget->setX(-area.x);
- else if (ax + area.width > widgetArea.width)
- widget->setX(widgetArea.width - area.x - area.width);
-
- if (ay < 0)
- widget->setY(-area.y);
- else if (ay + area.height > widgetArea.height)
- widget->setY(widgetArea.height - area.y - area.height);
-}
-
-void BasicContainer::setInternalFocusHandler(FocusHandler *const restrict
- focusHandler) restrict2
-{
- Widget::setInternalFocusHandler(focusHandler);
-
- FocusHandler *const restrict handler = mInternalFocusHandler != nullptr ?
- mInternalFocusHandler : getFocusHandler();
- FOR_EACH (WidgetListConstIterator, iter, mWidgets)
- {
- (*iter)->setFocusHandler(handler);
- }
-}
-
-Widget *BasicContainer::findFirstWidget(const std::set<Widget*> &restrict list)
- restrict2
-{
- FOR_EACHR (WidgetListReverseIterator, iter, mWidgets)
- {
- if (list.find(*iter) != list.end())
- return *iter;
- }
- return nullptr;
-}
diff --git a/src/gui/widgets/basiccontainer.h b/src/gui/widgets/basiccontainer.h
deleted file mode 100644
index 9ab658a76..000000000
--- a/src/gui/widgets/basiccontainer.h
+++ /dev/null
@@ -1,213 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GUI_WIDGETS_BASICCONTAINER_H
-#define GUI_WIDGETS_BASICCONTAINER_H
-
-#include "gui/widgets/widget.h"
-
-#include "listeners/widgetdeathlistener.h"
-
-/**
- * A base class for containers. The class implements the most
- * common things for a container. If you are implementing a
- * container, consider inheriting from this class.
- *
- * @see Container
- */
-class BasicContainer notfinal : public Widget,
- public WidgetDeathListener
-{
- public:
- explicit BasicContainer(const Widget2 *restrict const widget) :
- Widget(widget),
- WidgetDeathListener(),
- mWidgets(),
- mLogicWidgets()
- { }
-
- A_DELETE_COPY(BasicContainer)
-
- /**
- * Destructor
- */
- virtual ~BasicContainer();
-
- /**
- * Shows a certain part of a widget in the basic container.
- * Used when widgets want a specific part to be visible in
- * its parent. An example is a TextArea that wants a specific
- * part of its text to be visible when a TextArea is a child
- * of a ScrollArea.
- *
- * @param widget The widget whom wants a specific part of
- * itself to be visible.
- * @param area The rectangle to be visible.
- */
- void showWidgetPart(Widget *restrict const widget,
- const Rect &restrict area) restrict2 override;
-
- // Inherited from Widget
-
- void moveToTop(Widget *const widget) restrict2 override;
-
- void moveToBottom(Widget *const widget) restrict2 override;
-
- Rect getChildrenArea() restrict2 override A_WARN_UNUSED;
-
- void focusNext() restrict2 override;
-
- void focusPrevious() restrict2 override;
-
- void logic() restrict2 override;
-
- void setFocusHandler(FocusHandler *restrict const focusHandler)
- restrict2 override;
-
- void setInternalFocusHandler(FocusHandler *const restrict focusHandler)
- restrict2;
-
- Widget *getWidgetAt(int x, int y) restrict2 override A_WARN_UNUSED;
-
- // Inherited from WidgetDeathListener
-
- void death(const Event &restrict event) restrict2 override;
-
- Widget *findFirstWidget(const std::set<Widget*> &restrict list)
- restrict2;
-
- /**
- * Adds a widget to the basic container.
- *
- * @param widget The widget to add.
- * @see remove, clear
- */
- void add(Widget *const widget) restrict2;
-
- /**
- * Removes a widget from the basic container.
- *
- * @param widget The widget to remove.
- * @see add, clear
- */
- virtual void remove(Widget *const restrict widget) restrict2;
-
- /**
- * Clears the basic container from all widgets.
- *
- * @see remove, clear
- */
- virtual void clear() restrict2;
-
- protected:
- /**
- * Draws the children widgets of the basic container.
- *
- * @param graphics A graphics object to draw with.
- */
- virtual void drawChildren(Graphics *const restrict graphics)
- restrict2 A_NONNULL(2);
-
- virtual void safeDrawChildren(Graphics *const restrict graphics)
- restrict2 A_NONNULL(2);
-
- /**
- * Calls logic for the children widgets of the basic
- * container.
- */
- virtual void logicChildren() restrict2;
-
- /**
- * Typedef.
- */
- typedef STD_VECTOR<Widget *> WidgetList;
-
- /**
- * Typedef.
- */
- typedef WidgetList::iterator WidgetListIterator;
-
- /**
- * Typedef.
- */
- typedef WidgetList::const_iterator WidgetListConstIterator;
-
- /**
- * Typedef.
- */
- typedef WidgetList::reverse_iterator WidgetListReverseIterator;
-
- /**
- * Typedef.
- */
- typedef WidgetList::const_reverse_iterator WidgetListCReverseIterator;
-
- /**
- * Holds all widgets of the basic container.
- */
- WidgetList mWidgets;
-
- WidgetList mLogicWidgets;
-};
-
-#endif // GUI_WIDGETS_BASICCONTAINER_H
diff --git a/src/gui/widgets/basiccontainer2.cpp b/src/gui/widgets/basiccontainer2.cpp
deleted file mode 100644
index ad143010d..000000000
--- a/src/gui/widgets/basiccontainer2.cpp
+++ /dev/null
@@ -1,128 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * For comments regarding functions please see the header file.
- */
-
-#include "gui/widgets/basiccontainer2.h"
-
-#include "render/graphics.h"
-
-#include "debug.h"
-
-BasicContainer2::BasicContainer2(const Widget2 *const widget) :
- BasicContainer(widget),
- mOpaque(Opaque_true)
-{
-}
-
-BasicContainer2::~BasicContainer2()
-{
-}
-
-void BasicContainer2::draw(Graphics *const graphics)
-{
- BLOCK_START("BasicContainer2::draw")
- if (mOpaque == Opaque_true)
- {
- graphics->setColor(mBaseColor);
- graphics->fillRectangle(Rect(0, 0,
- mDimension.width, mDimension.height));
- }
-
- drawChildren(graphics);
- BLOCK_END("BasicContainer2::draw")
-}
-
-void BasicContainer2::safeDraw(Graphics *const graphics)
-{
- BLOCK_START("BasicContainer2::draw")
- if (mOpaque == Opaque_true)
- {
- graphics->setColor(mBaseColor);
- graphics->fillRectangle(Rect(0, 0,
- mDimension.width, mDimension.height));
- }
-
- safeDrawChildren(graphics);
- BLOCK_END("BasicContainer2::draw")
-}
-
-void BasicContainer2::add(Widget *const widget)
-{
- // +++ need move all add() calls from constructors
- // and after this method can be deleted
- // and virtual moved to basiccontainer
- BasicContainer::add(widget);
-}
-
-void BasicContainer2::addXY(Widget *const widget,
- const int x,
- const int y)
-{
- if (widget == nullptr)
- return;
- widget->setPosition(x, y);
- BasicContainer::add(widget);
-}
diff --git a/src/gui/widgets/basiccontainer2.h b/src/gui/widgets/basiccontainer2.h
deleted file mode 100644
index e26923d74..000000000
--- a/src/gui/widgets/basiccontainer2.h
+++ /dev/null
@@ -1,153 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GUI_WIDGETS_BASICCONTAINER2_H
-#define GUI_WIDGETS_BASICCONTAINER2_H
-
-#include "gui/widgets/basiccontainer.h"
-
-#include "enums/simpletypes/opaque.h"
-
-/**
- * An implementation of a container able to contain other widgets. A widget's
- * position in the container is relative to the container itself and not the screen.
- * A container is the most common widget to use as the Gui's top widget as makes the Gui
- * able to contain more than one widget.
- *
- * @see Gui::setTop
- */
-class BasicContainer2: public BasicContainer
-{
- public:
- /**
- * Constructor. A container is opauqe as default, if you want a
- * none opaque container call setQpaque(false).
- *
- * @see setOpaque, isOpaque
- */
- explicit BasicContainer2(const Widget2 *const widget);
-
- /**
- * Destructor.
- */
- virtual ~BasicContainer2();
-
- /**
- * Sets the container to be opaque or not. If the container
- * is opaque its background will be drawn, if it's not opaque
- * its background will not be drawn, and thus making the container
- * completely transparent.
- *
- * NOTE: This is not the same as to set visibility. A non visible
- * container will not itself nor will it draw its content.
- *
- * @param opaque True if the container should be opaque, false otherwise.
- * @see isOpaque
- */
- void setOpaque(Opaque opaque)
- { mOpaque = opaque; }
-
- /**
- * Checks if the container is opaque or not.
- *
- * @return True if the container is opaque, false otherwise.
- * @see setOpaque
- */
- bool isOpaque() const
- { return mOpaque == Opaque_true; }
-
- /**
- * Adds a widget to the container.
- *
- * @param widget The widget to add.
- * @see remove, clear
- */
- virtual void add(Widget *const widget);
-
- /**
- * Adds a widget to the container and also specifies the widget's
- * position in the container. The position is relative to the container
- * and not relative to the screen.
- *
- * @param widget The widget to add.
- * @param x The x coordinate for the widget.
- * @param y The y coordinate for the widget.
- * @see remove, clear
- */
- void addXY(Widget *const widget,
- const int x, const int y);
-
- // Inherited from Widget
-
- void draw(Graphics *const graphics) override A_NONNULL(2);
-
- void safeDraw(Graphics *const graphics) override A_NONNULL(2);
-
- protected:
- /**
- * True if the container is opaque, false otherwise.
- */
- Opaque mOpaque;
-};
-
-#endif // GUI_WIDGETS_BASICCONTAINER2_H
diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp
deleted file mode 100644
index 6d65a11cb..000000000
--- a/src/gui/widgets/browserbox.cpp
+++ /dev/null
@@ -1,936 +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
- * Copyright (C) 2009 Aethyra Development Team
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * 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 "gui/widgets/browserbox.h"
-
-#include "enums/gui/linkhighlightmode.h"
-
-#include "gui/gui.h"
-#include "gui/mouseoverlink.h"
-#include "gui/skin.h"
-
-#include "gui/fonts/font.h"
-
-#include "gui/widgets/browserbox.inc"
-#include "gui/widgets/linkhandler.h"
-
-#include "render/graphics.h"
-
-#include "resources/imageset.h"
-
-#include "resources/image/image.h"
-
-#include "resources/loaders/imageloader.h"
-#include "resources/loaders/imagesetloader.h"
-
-#include "utils/browserboxtools.h"
-#include "utils/checkutils.h"
-#include "utils/foreach.h"
-#include "utils/stringutils.h"
-#include "utils/timer.h"
-#include "utils/translation/podict.h"
-
-#include <algorithm>
-
-#include "debug.h"
-
-ImageSet *BrowserBox::mEmotes = nullptr;
-int BrowserBox::mInstances = 0;
-
-BrowserBox::BrowserBox(const Widget2 *const widget,
- const Opaque opaque,
- const std::string &skin) :
- Widget(widget),
- MouseListener(),
- WidgetListener(),
- mTextRows(),
- mTextRowLinksCount(),
- mLineParts(),
- mLinks(),
- mLinkHandler(nullptr),
- mSkin(nullptr),
- mHighlightMode(0),
- mSelectedLink(-1),
- mMaxRows(0),
- mHeight(0),
- mWidth(0),
- mYStart(0),
- mUpdateTime(-1),
- mPadding(0),
- mNewLinePadding(15U),
- mItemPadding(0),
- mDataWidth(0),
- mHighlightColor(getThemeColor(ThemeColorId::HIGHLIGHT)),
- mHyperLinkColor(getThemeColor(ThemeColorId::HYPERLINK)),
- mOpaque(opaque),
- mUseLinksAndUserColors(true),
- mUseEmotes(true),
- mAlwaysUpdate(true),
- mProcessVars(false),
- mEnableImages(false),
- mEnableKeys(false),
- mEnableTabs(false)
-{
- mAllowLogic = false;
-
- setFocusable(true);
- addMouseListener(this);
- addWidgetListener(this);
-
- mBackgroundColor = getThemeColor(ThemeColorId::BACKGROUND);
-
- if (theme != nullptr)
- mSkin = theme->load(skin, "browserbox.xml");
- if (mInstances == 0)
- {
- mEmotes = Loader::getImageSet(
- "graphics/sprites/chatemotes.png", 17, 18);
- }
- mInstances ++;
-
- if (mSkin != nullptr)
- {
- mPadding = mSkin->getPadding();
- mNewLinePadding = CAST_U32(
- mSkin->getOption("newLinePadding", 15));
- mItemPadding = mSkin->getOption("itemPadding");
- if (mSkin->getOption("highlightBackground") != 0)
- mHighlightMode |= LinkHighlightMode::BACKGROUND;
- if (mSkin->getOption("highlightUnderline") != 0)
- mHighlightMode |= LinkHighlightMode::UNDERLINE;
- }
-
- readColor(BLACK);
- readColor(RED);
- readColor(GREEN);
- readColor(BLUE);
- readColor(ORANGE);
- readColor(YELLOW);
- readColor(PINK);
- readColor(PURPLE);
- readColor(GRAY);
- readColor(BROWN);
-
- mForegroundColor = getThemeColor(ThemeColorId::BROWSERBOX);
- mForegroundColor2 = getThemeColor(ThemeColorId::BROWSERBOX_OUTLINE);
-}
-
-BrowserBox::~BrowserBox()
-{
- if (gui != nullptr)
- gui->removeDragged(this);
-
- if (theme != nullptr)
- {
- theme->unload(mSkin);
- mSkin = nullptr;
- }
-
- mInstances --;
- if (mInstances == 0)
- {
- if (mEmotes != nullptr)
- {
- mEmotes->decRef();
- mEmotes = nullptr;
- }
- }
-}
-
-void BrowserBox::setLinkHandler(LinkHandler* linkHandler)
-{
- mLinkHandler = linkHandler;
-}
-
-void BrowserBox::addRow(const std::string &row, const bool atTop)
-{
- std::string tmp = row;
- std::string newRow;
- const Font *const font = getFont();
- int linksCount = 0;
-
- if (getWidth() < 0)
- return;
-
- if (mProcessVars)
- {
- BrowserBoxTools::replaceVars(tmp);
- }
-
- // Use links and user defined colors
- if (mUseLinksAndUserColors)
- {
- BrowserLink bLink;
-
- // Check for links in format "@@link|Caption@@"
- const uint32_t sz = CAST_U32(mTextRows.size());
-
- if (mEnableKeys)
- {
- BrowserBoxTools::replaceKeys(tmp);
- }
-
- size_t idx1 = tmp.find("@@");
- while (idx1 != std::string::npos)
- {
- const size_t idx2 = tmp.find('|', idx1);
- const size_t idx3 = tmp.find("@@", idx2);
-
- if (idx2 == std::string::npos || idx3 == std::string::npos)
- break;
- bLink.link = tmp.substr(idx1 + 2, idx2 - (idx1 + 2));
- bLink.caption = tmp.substr(idx2 + 1, idx3 - (idx2 + 1));
- bLink.y1 = CAST_S32(sz) * font->getHeight();
- bLink.y2 = bLink.y1 + font->getHeight();
- if (bLink.caption.empty())
- {
- bLink.caption = BrowserBoxTools::replaceLinkCommands(
- bLink.link);
- if (translator != nullptr)
- bLink.caption = translator->getStr(bLink.caption);
- }
-
- newRow.append(tmp.substr(0, idx1));
-
- std::string tmp2 = newRow;
- idx1 = tmp2.find("##");
- while (idx1 != std::string::npos)
- {
- tmp2.erase(idx1, 3);
- idx1 = tmp2.find("##");
- }
- bLink.x1 = font->getWidth(tmp2) - 1;
- bLink.x2 = bLink.x1 + font->getWidth(bLink.caption) + 1;
-
- if (atTop)
- mLinks.insert(mLinks.begin(), bLink);
- else
- mLinks.push_back(bLink);
- linksCount ++;
-
- newRow.append("##<").append(bLink.caption);
-
- tmp.erase(0, idx3 + 2);
- if (!tmp.empty())
- newRow.append("##>");
-
- idx1 = tmp.find("@@");
- }
-
- newRow.append(tmp);
- }
- // Don't use links and user defined colors
- else
- {
- newRow = row;
- }
-
- if (mEnableTabs)
- {
- BrowserBoxTools::replaceTabs(newRow);
- }
-
- if (atTop)
- {
- mTextRows.push_front(newRow);
- mTextRowLinksCount.push_front(linksCount);
- }
- else
- {
- mTextRows.push_back(newRow);
- mTextRowLinksCount.push_back(linksCount);
- }
-
- // discard older rows when a row limit has been set
- if (mMaxRows > 0 && !mTextRows.empty())
- {
- while (mTextRows.size() > CAST_SIZE(mMaxRows))
- {
- mTextRows.pop_front();
- int cnt = mTextRowLinksCount.front();
- mTextRowLinksCount.pop_front();
-
- while ((cnt != 0) && !mLinks.empty())
- {
- mLinks.erase(mLinks.begin());
- cnt --;
- }
- }
- }
-
- const int fontHeight = font->getHeight();
- unsigned int y = 0;
- unsigned int nextChar;
- const char *const hyphen = "~";
- const unsigned int hyphenWidth = CAST_U32(
- font->getWidth(hyphen));
- unsigned int x = 0;
-
- FOR_EACH (TextRowCIter, i, mTextRows)
- {
- std::string tempRow = *i;
- for (uint32_t j = 0, sz = CAST_U32(tempRow.size());
- j < sz;
- j++)
- {
- const std::string character = tempRow.substr(j, 1);
- x += CAST_U32(font->getWidth(character));
- nextChar = j + 1;
-
- // Wraping between words (at blank spaces)
- if (nextChar < sz && tempRow.at(nextChar) == ' ')
- {
- int nextSpacePos = CAST_U32(
- tempRow.find(' ', (nextChar + 1)));
- if (nextSpacePos <= 0)
- nextSpacePos = CAST_U32(sz) - 1U;
-
- const unsigned int nextWordWidth =
- CAST_U32(font->getWidth(
- tempRow.substr(nextChar,
- (CAST_U32(nextSpacePos) - nextChar))));
-
- if ((x + nextWordWidth + 10)
- > CAST_U32(getWidth()))
- {
- x = mNewLinePadding; // Ident in new line
- y += 1;
- j ++;
- }
- }
- // Wrapping looong lines (brutal force)
- else if ((x + 2 * hyphenWidth)
- > CAST_U32(getWidth()))
- {
- x = mNewLinePadding; // Ident in new line
- y += 1;
- }
- }
- }
-
- setHeight(fontHeight * (CAST_S32(
- CAST_U32(mTextRows.size()) + y)));
- mUpdateTime = 0;
- updateHeight();
-}
-
-void BrowserBox::addRow(const std::string &cmd, const char *const text)
-{
- addRow(strprintf("@@%s|%s@@", encodeLinkText(cmd).c_str(),
- encodeLinkText(text).c_str()));
-}
-
-void BrowserBox::addImage(const std::string &path)
-{
- if (!mEnableImages)
- return;
-
- mTextRows.push_back("~~~" + path);
- mTextRowLinksCount.push_back(0);
-}
-
-void BrowserBox::clearRows()
-{
- mTextRows.clear();
- mTextRowLinksCount.clear();
- mLinks.clear();
- setWidth(0);
- setHeight(0);
- mSelectedLink = -1;
- mUpdateTime = 0;
- mDataWidth = 0;
- updateHeight();
-}
-
-void BrowserBox::mousePressed(MouseEvent &event)
-{
- if (mLinkHandler == nullptr)
- return;
-
- const LinkIterator i = std::find_if(mLinks.begin(), mLinks.end(),
- MouseOverLink(event.getX(), event.getY()));
-
- if (i != mLinks.end())
- {
- mLinkHandler->handleLink(i->link, &event);
- event.consume();
- }
-}
-
-void BrowserBox::mouseMoved(MouseEvent &event)
-{
- const LinkIterator i = std::find_if(mLinks.begin(), mLinks.end(),
- MouseOverLink(event.getX(), event.getY()));
-
- mSelectedLink = (i != mLinks.end())
- ? CAST_S32(i - mLinks.begin()) : -1;
-}
-
-void BrowserBox::mouseExited(MouseEvent &event A_UNUSED)
-{
- mSelectedLink = -1;
-}
-
-void BrowserBox::draw(Graphics *const graphics)
-{
- BLOCK_START("BrowserBox::draw")
- const ClipRect &cr = graphics->getTopClip();
- mYStart = cr.y - cr.yOffset;
- const int yEnd = mYStart + cr.height;
- if (mYStart < 0)
- mYStart = 0;
-
- if (mDimension.width != mWidth)
- {
- mWidth = mDimension.width;
- mHeight = calcHeight();
- setHeight(mHeight);
- mUpdateTime = cur_time;
- if (mDimension.width != mWidth)
- reportAlways("browserbox resize in draw");
- }
-
- if (mOpaque == Opaque_true)
- {
- graphics->setColor(mBackgroundColor);
- graphics->fillRectangle(Rect(0, 0,
- mDimension.width, mDimension.height));
- }
-
- if (mSelectedLink >= 0 &&
- mSelectedLink < CAST_S32(mLinks.size()))
- {
- if ((mHighlightMode & LinkHighlightMode::BACKGROUND) != 0u)
- {
- BrowserLink &link = mLinks[CAST_SIZE(mSelectedLink)];
- graphics->setColor(mHighlightColor);
- graphics->fillRectangle(Rect(
- link.x1,
- link.y1,
- link.x2 - link.x1,
- link.y2 - link.y1));
- }
-
- if ((mHighlightMode & LinkHighlightMode::UNDERLINE) != 0u)
- {
- BrowserLink &link = mLinks[CAST_SIZE(mSelectedLink)];
- graphics->setColor(mHyperLinkColor);
- graphics->drawLine(
- link.x1,
- link.y2,
- link.x2,
- link.y2);
- }
- }
-
- Font *const font = getFont();
-
- FOR_EACH (LinePartCIter, i, mLineParts)
- {
- const LinePart &part = *i;
- if (part.mY + 50 < mYStart)
- continue;
- if (part.mY > yEnd)
- break;
- if (part.mType == 0u)
- {
- if (part.mBold)
- {
- boldFont->drawString(graphics,
- part.mColor,
- part.mColor2,
- part.mText,
- part.mX, part.mY);
- }
- else
- {
- font->drawString(graphics,
- part.mColor,
- part.mColor2,
- part.mText,
- part.mX, part.mY);
- }
- }
- else if (part.mImage != nullptr)
- {
- graphics->drawImage(part.mImage, part.mX, part.mY);
- }
- }
-
- BLOCK_END("BrowserBox::draw")
-}
-
-void BrowserBox::safeDraw(Graphics *const graphics)
-{
- BrowserBox::draw(graphics);
-}
-
-int BrowserBox::calcHeight()
-{
- unsigned int y = CAST_U32(mPadding);
- int wrappedLines = 0;
- int moreHeight = 0;
- int maxWidth = mDimension.width - mPadding;
- int link = 0;
- bool bold = false;
- unsigned int wWidth = CAST_U32(maxWidth);
-
- if (maxWidth < 0)
- return 1;
-
- const Font *const font = getFont();
- const int fontHeight = font->getHeight() + 2 * mItemPadding;
- const int fontWidthMinus = font->getWidth("-");
- const char *const hyphen = "~";
- const int hyphenWidth = font->getWidth(hyphen);
-
- Color selColor[2] = {mForegroundColor, mForegroundColor2};
- const Color textColor[2] = {mForegroundColor, mForegroundColor2};
- mLineParts.clear();
-
- FOR_EACH (TextRowCIter, i, mTextRows)
- {
- unsigned int x = CAST_U32(mPadding);
- const std::string row = *(i);
- bool wrapped = false;
- int objects = 0;
-
- // Check for separator lines
- if (row.find("---", 0) == 0)
- {
- const int dashWidth = fontWidthMinus;
- for (x = CAST_U32(mPadding); x < wWidth; x ++)
- {
- mLineParts.push_back(LinePart(CAST_S32(x),
- CAST_S32(y) + mItemPadding,
- selColor[0], selColor[1], "-", false));
- x += CAST_U32(CAST_S32(
- dashWidth) - 2);
- }
-
- y += CAST_U32(fontHeight);
- continue;
- }
- else if (mEnableImages && row.find("~~~", 0) == 0)
- {
- std::string str = row.substr(3);
- const size_t sz = str.size();
- if (sz > 2 && str.substr(sz - 1) == "~")
- str = str.substr(0, sz - 1);
- Image *const img = Loader::getImage(str);
- if (img != nullptr)
- {
- img->incRef();
- mLineParts.push_back(LinePart(CAST_S32(x),
- CAST_S32(y) + mItemPadding,
- selColor[0], selColor[1], img));
- y += CAST_U32(img->getHeight() + 2);
- moreHeight += img->getHeight();
- if (img->getWidth() > maxWidth)
- maxWidth = img->getWidth() + 2;
- }
- continue;
- }
-
- Color prevColor[2];
- prevColor[0] = selColor[0];
- prevColor[1] = selColor[1];
- bold = false;
-
- const int xPadding = CAST_S32(mNewLinePadding) + mPadding;
-
- for (size_t start = 0, end = std::string::npos;
- start != std::string::npos;
- start = end, end = std::string::npos)
- {
- bool processed(false);
-
- // Wrapped line continuation shall be indented
- if (wrapped)
- {
- y += CAST_U32(fontHeight);
- x = CAST_U32(xPadding);
- wrapped = false;
- }
-
- size_t idx1 = end;
- size_t idx2 = end;
-
- // "Tokenize" the string at control sequences
- if (mUseLinksAndUserColors)
- idx1 = row.find("##", start + 1);
- if (start == 0 || mUseLinksAndUserColors)
- {
- // Check for color change in format "##x", x = [L,P,0..9]
- if (row.find("##", start) == start && row.size() > start + 2)
- {
- const signed char c = row.at(start + 2);
-
- bool valid(false);
- const Color col[2] =
- {
- getThemeCharColor(c, valid),
- getThemeCharColor(CAST_S8(
- c | 0x80), valid)
- };
-
- if (c == '>')
- {
- selColor[0] = prevColor[0];
- selColor[1] = prevColor[1];
- }
- else if (c == '<')
- {
- prevColor[0] = selColor[0];
- prevColor[1] = selColor[1];
- selColor[0] = col[0];
- selColor[1] = col[1];
- }
- else if (c == 'B')
- {
- bold = true;
- }
- else if (c == 'b')
- {
- bold = false;
- }
- else if (valid)
- {
- selColor[0] = col[0];
- selColor[1] = col[1];
- }
- else
- {
- switch (c)
- {
- case '0':
- selColor[0] = mColors[0][ColorName::BLACK];
- selColor[1] = mColors[1][ColorName::BLACK];
- break;
- case '1':
- selColor[0] = mColors[0][ColorName::RED];
- selColor[1] = mColors[1][ColorName::RED];
- break;
- case '2':
- selColor[0] = mColors[0][ColorName::GREEN];
- selColor[1] = mColors[1][ColorName::GREEN];
- break;
- case '3':
- selColor[0] = mColors[0][ColorName::BLUE];
- selColor[1] = mColors[1][ColorName::BLUE];
- break;
- case '4':
- selColor[0] = mColors[0][ColorName::ORANGE];
- selColor[1] = mColors[1][ColorName::ORANGE];
- break;
- case '5':
- selColor[0] = mColors[0][ColorName::YELLOW];
- selColor[1] = mColors[1][ColorName::YELLOW];
- break;
- case '6':
- selColor[0] = mColors[0][ColorName::PINK];
- selColor[1] = mColors[1][ColorName::PINK];
- break;
- case '7':
- selColor[0] = mColors[0][ColorName::PURPLE];
- selColor[1] = mColors[1][ColorName::PURPLE];
- break;
- case '8':
- selColor[0] = mColors[0][ColorName::GRAY];
- selColor[1] = mColors[1][ColorName::GRAY];
- break;
- case '9':
- selColor[0] = mColors[0][ColorName::BROWN];
- selColor[1] = mColors[1][ColorName::BROWN];
- break;
- default:
- selColor[0] = textColor[0];
- selColor[1] = textColor[1];
- break;
- }
- }
-
- if (c == '<' && link < CAST_S32(mLinks.size()))
- {
- int size;
- if (bold)
- {
- size = boldFont->getWidth(
- mLinks[CAST_SIZE(link)].caption) + 1;
- }
- else
- {
- size = font->getWidth(
- mLinks[CAST_SIZE(link)].caption) + 1;
- }
-
- BrowserLink &linkRef = mLinks[CAST_SIZE(
- link)];
- linkRef.x1 = CAST_S32(x);
- linkRef.y1 = CAST_S32(y);
- linkRef.x2 = linkRef.x1 + size;
- linkRef.y2 = CAST_S32(y) + fontHeight - 1;
- link++;
- }
-
- processed = true;
- start += 3;
- if (start == row.size())
- break;
- }
- }
- if (mUseEmotes)
- idx2 = row.find("%%", start + 1);
- if (idx1 < idx2)
- end = idx1;
- else
- end = idx2;
- if (mUseEmotes)
- {
- // check for emote icons
- if (row.size() > start + 2 && row.substr(start, 2) == "%%")
- {
- if (objects < 5)
- {
- const int cid = row.at(start + 2) - '0';
- if (cid >= 0)
- {
- if (mEmotes != nullptr)
- {
- const size_t sz = mEmotes->size();
- if (CAST_SIZE(cid) < sz)
- {
- Image *const img = mEmotes->get(
- CAST_SIZE(cid));
- if (img != nullptr)
- {
- mLineParts.push_back(LinePart(
- CAST_S32(x),
- CAST_S32(y) + mItemPadding,
- selColor[0], selColor[1], img));
- x += 18;
- }
- }
- }
- }
- objects ++;
- processed = true;
- }
-
- start += 3;
- if (start == row.size())
- {
- if (x > mDataWidth)
- mDataWidth = x;
- break;
- }
- }
- }
- const size_t len = (end == std::string::npos) ? end : end - start;
-
- if (start >= row.length())
- break;
-
- std::string part = row.substr(start, len);
- int width = 0;
- if (bold)
- width = boldFont->getWidth(part);
- else
- width = font->getWidth(part);
-
- // Auto wrap mode
- if (wWidth > 0 &&
- width > 0 &&
- (x + CAST_U32(width) + 10) > wWidth)
- {
- bool forced = false;
-
- /* FIXME: This code layout makes it easy to crash remote
- clients by talking garbage. Forged long utf-8 characters
- will cause either a buffer underflow in substr or an
- infinite loop in the main loop. */
- do
- {
- if (!forced)
- end = row.rfind(' ', end);
-
- // Check if we have to (stupidly) force-wrap
- if (end == std::string::npos || end <= start)
- {
- forced = true;
- end = row.size();
- x += CAST_U32(hyphenWidth);
- continue;
- }
-
- // Skip to the start of the current character
- while ((row[end] & 192) == 128)
- end--;
- end--; // And then to the last byte of the previous one
-
- part = row.substr(start, end - start + 1);
- if (bold)
- width = boldFont->getWidth(part);
- else
- width = font->getWidth(part);
- }
- while (end > start &&
- width > 0 &&
- (x + CAST_U32(width) + 10) > wWidth);
-
- if (forced)
- {
- x -= CAST_U32(hyphenWidth);
- mLineParts.push_back(LinePart(
- CAST_S32(wWidth) - hyphenWidth,
- CAST_S32(y) + mItemPadding,
- selColor[0], selColor[1], hyphen, bold));
- end++; // Skip to the next character
- }
- else
- {
- end += 2; // Skip to after the space
- }
-
- wrapped = true;
- wrappedLines++;
- }
-
- mLineParts.push_back(LinePart(CAST_S32(x),
- CAST_S32(y) + mItemPadding,
- selColor[0], selColor[1], part.c_str(), bold));
-
- if (bold)
- width = boldFont->getWidth(part);
- else
- width = font->getWidth(part);
-
- if (width == 0 && !processed)
- break;
-
- x += CAST_U32(width);
- if (x > mDataWidth)
- mDataWidth = x;
- }
- y += CAST_U32(fontHeight);
- }
- if (CAST_S32(wWidth) != maxWidth)
- setWidth(maxWidth);
-
- return (CAST_S32(mTextRows.size()) + wrappedLines)
- * fontHeight + moreHeight + 2 * mPadding;
-}
-
-void BrowserBox::updateHeight()
-{
- if (mAlwaysUpdate || mUpdateTime != cur_time
- || mTextRows.size() < 3 || (mUpdateTime == 0))
- {
- mWidth = mDimension.width;
- mHeight = calcHeight();
- setHeight(mHeight);
- mUpdateTime = cur_time;
- }
-}
-
-void BrowserBox::updateSize(const bool always)
-{
- if (always)
- mUpdateTime = 0;
- updateHeight();
-}
-
-std::string BrowserBox::getTextAtPos(const int x, const int y) const
-{
- int textX = 0;
- int textY = 0;
-
- getAbsolutePosition(textX, textY);
- if (x < textX || y < textY)
- return std::string();
-
- textY = y - textY;
- std::string str;
- int lastY = 0;
-
- FOR_EACH (LinePartCIter, i, mLineParts)
- {
- const LinePart &part = *i;
- if (part.mY + 50 < mYStart)
- continue;
- if (part.mY > textY)
- break;
-
- if (part.mY > lastY)
- {
- str = part.mText;
- lastY = part.mY;
- }
- else
- {
- str.append(part.mText);
- }
- }
-
- return str;
-}
-
-void BrowserBox::setForegroundColorAll(const Color &color1,
- const Color &color2)
-{
- mForegroundColor = color1;
- mForegroundColor2 = color2;
-}
-
-void BrowserBox::moveSelectionUp()
-{
- if (mSelectedLink <= 0)
- mSelectedLink = CAST_S32(mLinks.size()) - 1;
- else
- mSelectedLink --;
-}
-
-void BrowserBox::moveSelectionDown()
-{
- mSelectedLink ++;
- if (mSelectedLink >= static_cast<signed int>(mLinks.size()))
- mSelectedLink = 0;
-}
-
-void BrowserBox::selectSelection()
-{
- if ((mLinkHandler == nullptr) ||
- mSelectedLink < 0 ||
- mSelectedLink >= static_cast<signed int>(mLinks.size()))
- {
- return;
- }
-
- mLinkHandler->handleLink(mLinks[CAST_SIZE(mSelectedLink)].link,
- nullptr);
-}
-
-void BrowserBox::widgetResized(const Event &event A_UNUSED)
-{
- updateHeight();
-}
diff --git a/src/gui/widgets/browserbox.h b/src/gui/widgets/browserbox.h
deleted file mode 100644
index 45502ba5a..000000000
--- a/src/gui/widgets/browserbox.h
+++ /dev/null
@@ -1,210 +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
- * Copyright (C) 2009 Aethyra Development Team
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * 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_BROWSERBOX_H
-#define GUI_WIDGETS_BROWSERBOX_H
-
-#include "enums/simpletypes/opaque.h"
-
-#include "enums/gui/colorname.h"
-
-#include "gui/browserlink.h"
-
-#include "gui/widgets/linepart.h"
-#include "gui/widgets/widget.h"
-
-#include "listeners/mouselistener.h"
-#include "listeners/widgetlistener.h"
-
-#include "localconsts.h"
-
-class LinkHandler;
-
-/**
- * A simple browser box able to handle links and forward events to the
- * parent conteiner.
- */
-class BrowserBox final : public Widget,
- public MouseListener,
- public WidgetListener
-{
- public:
- /**
- * Constructor.
- */
- BrowserBox(const Widget2 *const widget,
- const Opaque opaque,
- const std::string &skin);
-
- A_DELETE_COPY(BrowserBox)
-
- /**
- * Destructor.
- */
- ~BrowserBox();
-
- /**
- * Sets the handler for links.
- */
- void setLinkHandler(LinkHandler *linkHandler);
-
- /**
- * Sets the BrowserBox opacity.
- */
- void setOpaque(Opaque opaque)
- { mOpaque = opaque; }
-
- /**
- * Sets the maximum numbers of rows in the browser box. 0 = no limit.
- */
- void setMaxRow(unsigned max)
- { mMaxRows = max; }
-
- /**
- * Adds a text row to the browser.
- */
- void addRow(const std::string &row, const bool atTop = false);
-
- /**
- * Adds a menu line to the browser.
- */
- void addRow(const std::string &cmd, const char *const text);
-
- void addImage(const std::string &path);
-
- /**
- * Remove all rows.
- */
- void clearRows();
-
- /**
- * Handles mouse actions.
- */
- void mousePressed(MouseEvent &event) override final;
-
- void mouseMoved(MouseEvent &event) override final;
-
- void mouseExited(MouseEvent& event) override final;
-
- /**
- * Draws the browser box.
- */
- void draw(Graphics *const graphics) override final A_NONNULL(2);
-
- void safeDraw(Graphics *const graphics) override final A_NONNULL(2);
-
- void updateHeight();
-
- void updateSize(const bool always);
-
- typedef std::list<std::string> TextRows;
-
- TextRows &getRows() noexcept2 A_WARN_UNUSED
- { return mTextRows; }
-
- bool hasRows() const noexcept2 A_WARN_UNUSED
- { return !mTextRows.empty(); }
-
- void setAlwaysUpdate(const bool n) noexcept2
- { mAlwaysUpdate = n; }
-
- void setProcessVars(const bool n) noexcept2
- { mProcessVars = n; }
-
- void setEnableImages(const bool n) noexcept2
- { mEnableImages = n; }
-
- void setEnableKeys(const bool n) noexcept2
- { mEnableKeys = n; }
-
- void setEnableTabs(const bool n) noexcept2
- { mEnableTabs = n; }
-
- std::string getTextAtPos(const int x, const int y) const A_WARN_UNUSED;
-
- int getPadding() const noexcept2 A_WARN_UNUSED
- { return mPadding; }
-
- void setForegroundColorAll(const Color &color1,
- const Color &color2);
-
- unsigned int getDataWidth() const noexcept2 A_WARN_UNUSED
- { return mDataWidth; }
-
- void moveSelectionUp();
-
- void moveSelectionDown();
-
- void selectSelection();
-
- void widgetResized(const Event &event) override final;
-
- private:
- int calcHeight() A_WARN_UNUSED;
-
- typedef TextRows::iterator TextRowIterator;
- typedef TextRows::const_iterator TextRowCIter;
- TextRows mTextRows;
- std::list<int> mTextRowLinksCount;
-
- typedef STD_VECTOR<LinePart> LinePartList;
- typedef LinePartList::iterator LinePartIterator;
- typedef LinePartList::const_iterator LinePartCIter;
- LinePartList mLineParts;
-
- typedef STD_VECTOR<BrowserLink> Links;
- typedef Links::iterator LinkIterator;
- Links mLinks;
-
- LinkHandler *mLinkHandler;
- Skin *mSkin;
- unsigned int mHighlightMode;
- int mSelectedLink;
- unsigned int mMaxRows;
- int mHeight;
- int mWidth;
- int mYStart;
- time_t mUpdateTime;
- int mPadding;
- unsigned int mNewLinePadding;
- int mItemPadding;
- unsigned int mDataWidth;
-
- Color mHighlightColor;
- Color mHyperLinkColor;
- Color mColors[2][ColorName::COLORS_MAX];
-
- Opaque mOpaque;
- bool mUseLinksAndUserColors;
- bool mUseEmotes;
- bool mAlwaysUpdate;
- bool mProcessVars;
- bool mEnableImages;
- bool mEnableKeys;
- bool mEnableTabs;
-
- static ImageSet *mEmotes;
- static int mInstances;
-};
-
-#endif // GUI_WIDGETS_BROWSERBOX_H
diff --git a/src/gui/widgets/browserbox.inc b/src/gui/widgets/browserbox.inc
deleted file mode 100644
index 25c8744c0..000000000
--- a/src/gui/widgets/browserbox.inc
+++ /dev/null
@@ -1,30 +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_BROWSERBOX_INC
-#define GUI_WIDGETS_BROWSERBOX_INC
-
-#define readColor(color) \
- mColors[0][ColorName::color] = getThemeColor(ThemeColorId::color); \
- mColors[1][ColorName::color] = getThemeColor(ThemeColorId::color##_OUTLINE)
-
-#endif // GUI_WIDGETS_BROWSERBOX_INC
diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp
deleted file mode 100644
index 0c2600583..000000000
--- a/src/gui/widgets/button.cpp
+++ /dev/null
@@ -1,934 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "gui/widgets/button.h"
-
-#include "settings.h"
-
-#include "resources/imageset.h"
-#include "resources/imagerect.h"
-
-#include "resources/image/image.h"
-
-#include "gui/gui.h"
-#include "gui/skin.h"
-
-#include "gui/fonts/font.h"
-
-#include "render/renderers.h"
-
-#include "render/vertexes/imagecollection.h"
-
-#include "utils/delete2.h"
-
-#include "debug.h"
-
-int Button::mInstances = 0;
-float Button::mAlpha = 1.0;
-
-static std::string const data[Button::BUTTON_COUNT] =
-{
- "button.xml",
- "button_highlighted.xml",
- "button_pressed.xml",
- "button_disabled.xml"
-};
-
-Skin *Button::button[BUTTON_COUNT];
-
-Button::Button(const Widget2 *const widget) :
- Widget(widget),
- MouseListener(),
- KeyListener(),
- FocusListener(),
- WidgetListener(),
- mCaption(),
- mDescription(),
- mTextChunk(),
- mVertexes2(new ImageCollection),
- mEnabledColor(getThemeColor(ThemeColorId::BUTTON)),
- mEnabledColor2(getThemeColor(ThemeColorId::BUTTON_OUTLINE)),
- mDisabledColor(getThemeColor(ThemeColorId::BUTTON_DISABLED)),
- mDisabledColor2(getThemeColor(ThemeColorId::BUTTON_DISABLED_OUTLINE)),
- mHighlightedColor(getThemeColor(ThemeColorId::BUTTON_HIGHLIGHTED)),
- mHighlightedColor2(getThemeColor(
- ThemeColorId::BUTTON_HIGHLIGHTED_OUTLINE)),
- mPressedColor(getThemeColor(ThemeColorId::BUTTON_PRESSED)),
- mPressedColor2(getThemeColor(ThemeColorId::BUTTON_PRESSED_OUTLINE)),
- mImages(nullptr),
- mImageSet(nullptr),
- mAlignment(Graphics::CENTER),
- mClickCount(0),
- mSpacing(),
- mTag(0),
- mMode(0),
- mXOffset(0),
- mYOffset(0),
- mImageWidth(0),
- mImageHeight(0),
- mHasMouse(false),
- mKeyPressed(false),
- mMousePressed(false),
- mStick(false),
- mPressed(false),
- mTextChanged(true)
-{
- init();
- adjustSize();
-}
-
-Button::Button(const Widget2 *const widget,
- const std::string &restrict caption,
- const std::string &restrict actionEventId,
- ActionListener *const listener) :
- Widget(widget),
- MouseListener(),
- KeyListener(),
- FocusListener(),
- WidgetListener(),
- mCaption(caption),
- mDescription(),
- mTextChunk(),
- mVertexes2(new ImageCollection),
- mEnabledColor(getThemeColor(ThemeColorId::BUTTON)),
- mEnabledColor2(getThemeColor(ThemeColorId::BUTTON_OUTLINE)),
- mDisabledColor(getThemeColor(ThemeColorId::BUTTON_DISABLED)),
- mDisabledColor2(getThemeColor(ThemeColorId::BUTTON_DISABLED_OUTLINE)),
- mHighlightedColor(getThemeColor(ThemeColorId::BUTTON_HIGHLIGHTED)),
- mHighlightedColor2(getThemeColor(
- ThemeColorId::BUTTON_HIGHLIGHTED_OUTLINE)),
- mPressedColor(getThemeColor(ThemeColorId::BUTTON_PRESSED)),
- mPressedColor2(getThemeColor(ThemeColorId::BUTTON_PRESSED_OUTLINE)),
- mImages(nullptr),
- mImageSet(nullptr),
- mAlignment(Graphics::CENTER),
- mClickCount(0),
- mSpacing(),
- mTag(0),
- mMode(0),
- mXOffset(0),
- mYOffset(0),
- mImageWidth(0),
- mImageHeight(0),
- mHasMouse(false),
- mKeyPressed(false),
- mMousePressed(false),
- mStick(false),
- mPressed(false),
- mTextChanged(true)
-{
- init();
- adjustSize();
- setActionEventId(actionEventId);
-
- if (listener != nullptr)
- addActionListener(listener);
-}
-
-Button::Button(const Widget2 *const widget,
- const std::string &restrict caption,
- const std::string &restrict imageName,
- const int imageWidth, const int imageHeight,
- const std::string &restrict actionEventId,
- ActionListener *const listener) :
- Widget(widget),
- MouseListener(),
- KeyListener(),
- FocusListener(),
- WidgetListener(),
- mCaption(caption),
- mDescription(),
- mTextChunk(),
- mVertexes2(new ImageCollection),
- mEnabledColor(getThemeColor(ThemeColorId::BUTTON)),
- mEnabledColor2(getThemeColor(ThemeColorId::BUTTON_OUTLINE)),
- mDisabledColor(getThemeColor(ThemeColorId::BUTTON_DISABLED)),
- mDisabledColor2(getThemeColor(ThemeColorId::BUTTON_DISABLED_OUTLINE)),
- mHighlightedColor(getThemeColor(ThemeColorId::BUTTON_HIGHLIGHTED)),
- mHighlightedColor2(getThemeColor(
- ThemeColorId::BUTTON_HIGHLIGHTED_OUTLINE)),
- mPressedColor(getThemeColor(ThemeColorId::BUTTON_PRESSED)),
- mPressedColor2(getThemeColor(ThemeColorId::BUTTON_PRESSED_OUTLINE)),
- mImages(nullptr),
- mImageSet(nullptr),
- mAlignment(Graphics::CENTER),
- mClickCount(0),
- mSpacing(),
- mTag(0),
- mMode(0),
- mXOffset(0),
- mYOffset(0),
- mImageWidth(imageWidth),
- mImageHeight(imageHeight),
- mHasMouse(false),
- mKeyPressed(false),
- mMousePressed(false),
- mStick(false),
- mPressed(false),
- mTextChanged(true)
-{
- init();
- loadImageSet(imageName);
- adjustSize();
- setActionEventId(actionEventId);
-
- if (listener != nullptr)
- addActionListener(listener);
-}
-
-Button::Button(const Widget2 *const widget,
- const std::string &restrict imageName,
- const int imageWidth, const int imageHeight,
- const std::string &restrict actionEventId,
- ActionListener *const listener) :
- Widget(widget),
- MouseListener(),
- KeyListener(),
- FocusListener(),
- WidgetListener(),
- mCaption(),
- mDescription(),
- mTextChunk(),
- mVertexes2(new ImageCollection),
- mEnabledColor(getThemeColor(ThemeColorId::BUTTON)),
- mEnabledColor2(getThemeColor(ThemeColorId::BUTTON_OUTLINE)),
- mDisabledColor(getThemeColor(ThemeColorId::BUTTON_DISABLED)),
- mDisabledColor2(getThemeColor(ThemeColorId::BUTTON_DISABLED_OUTLINE)),
- mHighlightedColor(getThemeColor(ThemeColorId::BUTTON_HIGHLIGHTED)),
- mHighlightedColor2(getThemeColor(
- ThemeColorId::BUTTON_HIGHLIGHTED_OUTLINE)),
- mPressedColor(getThemeColor(ThemeColorId::BUTTON_PRESSED)),
- mPressedColor2(getThemeColor(ThemeColorId::BUTTON_PRESSED_OUTLINE)),
- mImages(nullptr),
- mImageSet(nullptr),
- mAlignment(Graphics::CENTER),
- mClickCount(0),
- mSpacing(),
- mTag(0),
- mMode(0),
- mXOffset(0),
- mYOffset(0),
- mImageWidth(imageWidth),
- mImageHeight(imageHeight),
- mHasMouse(false),
- mKeyPressed(false),
- mMousePressed(false),
- mStick(false),
- mPressed(false),
- mTextChanged(true)
-{
- init();
- loadImageSet(imageName);
- adjustSize();
- setActionEventId(actionEventId);
-
- if (listener != nullptr)
- addActionListener(listener);
-}
-
-Button::Button(const Widget2 *const widget,
- const std::string &restrict caption,
- const std::string &restrict imageName,
- const std::string &restrict actionEventId,
- ActionListener *const listener) :
- Widget(widget),
- MouseListener(),
- KeyListener(),
- FocusListener(),
- WidgetListener(),
- mCaption(caption),
- mDescription(),
- mTextChunk(),
- mVertexes2(new ImageCollection),
- mEnabledColor(getThemeColor(ThemeColorId::BUTTON)),
- mEnabledColor2(getThemeColor(ThemeColorId::BUTTON_OUTLINE)),
- mDisabledColor(getThemeColor(ThemeColorId::BUTTON_DISABLED)),
- mDisabledColor2(getThemeColor(ThemeColorId::BUTTON_DISABLED_OUTLINE)),
- mHighlightedColor(getThemeColor(ThemeColorId::BUTTON_HIGHLIGHTED)),
- mHighlightedColor2(getThemeColor(
- ThemeColorId::BUTTON_HIGHLIGHTED_OUTLINE)),
- mPressedColor(getThemeColor(ThemeColorId::BUTTON_PRESSED)),
- mPressedColor2(getThemeColor(ThemeColorId::BUTTON_PRESSED_OUTLINE)),
- mImages(nullptr),
- mImageSet(nullptr),
- mAlignment(Graphics::CENTER),
- mClickCount(0),
- mSpacing(),
- mTag(0),
- mMode(0),
- mXOffset(0),
- mYOffset(0),
- mImageWidth(0),
- mImageHeight(0),
- mHasMouse(false),
- mKeyPressed(false),
- mMousePressed(false),
- mStick(false),
- mPressed(false),
- mTextChanged(true)
-{
- init();
- loadImage(imageName);
- adjustSize();
- setActionEventId(actionEventId);
-
- if (listener != nullptr)
- addActionListener(listener);
-}
-
-void Button::init()
-{
- mAllowLogic = false;
- addMouseListener(this);
- addKeyListener(this);
- addFocusListener(this);
- addWidgetListener(this);
-
- setFocusable(true);
- setFrameSize(0);
-
- if (mInstances == 0)
- {
- if (theme != nullptr)
- {
- for (int mode = 0; mode < BUTTON_COUNT; mode ++)
- {
- Skin *const skin = theme->load(data[mode], "button.xml");
- if (skin != nullptr)
- {
- button[mode] = skin;
- mSpacing[mode] = skin->getOption("spacing");
- }
- }
- }
-
- updateAlpha();
- }
-
- mInstances++;
-}
-
-Button::~Button()
-{
- if (mWindow != nullptr)
- mWindow->removeWidgetListener(this);
-
- if (gui != nullptr)
- gui->removeDragged(this);
-
- mInstances--;
-
- if (mInstances == 0 && (theme != nullptr))
- {
- for (int mode = 0; mode < BUTTON_COUNT; mode ++)
- theme->unload(button[mode]);
- }
- delete2(mVertexes2);
- if (mImageSet != nullptr)
- {
- mImageSet->decRef();
- mImageSet = nullptr;
- }
- if (mImages != nullptr)
- {
- for (int f = 0; f < BUTTON_COUNT; f ++)
- mImages[f] = nullptr;
- delete [] mImages;
- mImages = nullptr;
- }
- mTextChunk.deleteImage();
-}
-
-void Button::loadImage(const std::string &imageName)
-{
- if (mImageSet != nullptr)
- {
- mImageSet->decRef();
- mImageSet = nullptr;
- }
- Image *const image = Theme::getImageFromThemeXml(imageName, "");
- mImages = new Image*[BUTTON_COUNT];
- for (int f = 0; f < BUTTON_COUNT; f ++)
- mImages[f] = image;
-}
-
-void Button::loadImageSet(const std::string &imageName)
-{
- if (mImageSet != nullptr)
- {
- mImageSet->decRef();
- mImageSet = nullptr;
- }
- mImageSet = Theme::getImageSetFromTheme(imageName,
- mImageWidth, mImageHeight);
- if (mImageSet == nullptr)
- return;
- mImages = new Image*[BUTTON_COUNT];
- mImages[0] = nullptr;
- for (size_t f = 0; f < BUTTON_COUNT; f ++)
- {
- Image *const img = mImageSet->get(f);
- if (img != nullptr)
- mImages[f] = img;
- else
- mImages[f] = mImages[0];
- }
-}
-
-void Button::updateAlpha()
-{
- const float alpha = std::max(settings.guiAlpha,
- theme->getMinimumOpacity());
-
- if (mAlpha != alpha)
- {
- mAlpha = alpha;
- for (int mode = 0; mode < BUTTON_COUNT; mode ++)
- {
- for (int a = 0; a < 9; a ++)
- {
- Skin *const skin = button[mode];
- if (skin != nullptr)
- {
- const ImageRect &rect = skin->getBorder();
- Image *const image = rect.grid[a];
- if (image != nullptr)
- image->setAlpha(mAlpha);
- }
- }
- }
- }
-}
-
-void Button::draw(Graphics *const graphics)
-{
- BLOCK_START("Button::draw")
- int mode;
-
- if (!isEnabled())
- mode = BUTTON_DISABLED;
- else if (isPressed2())
- mode = BUTTON_PRESSED;
- else if (mHasMouse)
- mode = BUTTON_HIGHLIGHTED;
- else
- mode = BUTTON_STANDARD;
-
- const Skin *const skin = button[mode];
- if (skin == nullptr)
- {
- BLOCK_END("Button::draw")
- return;
- }
-
- updateAlpha();
-
- bool recalc = false;
- if (mRedraw)
- {
- recalc = true;
- }
- else
- {
- // because we don't know where parent windows was moved,
- // need recalc vertexes
- ClipRect &rect = graphics->getTopClip();
- if (rect.xOffset != mXOffset || rect.yOffset != mYOffset)
- {
- recalc = true;
- mXOffset = rect.xOffset;
- mYOffset = rect.yOffset;
- }
- else if (mMode != mode)
- {
- recalc = true;
- mMode = mode;
- }
- else if (graphics->getRedraw())
- {
- recalc = true;
- }
- }
-
- const int padding = skin->getPadding();
- const int spacing = mSpacing[mode];
-
- if (recalc)
- mTextChanged = true;
-
- int imageX = 0;
- int imageY = 0;
- int textX = 0;
- const Rect &rect = mDimension;
- const int width = rect.width;
- const int height = rect.height;
- Font *const font = getFont();
- int textY = height / 2 - font->getHeight() / 2;
- if (mImages != nullptr)
- imageY = height / 2 - mImageHeight / 2;
-
-// need move calculation from draw!!!
-
- switch (mAlignment)
- {
- default:
- case Graphics::LEFT:
- {
- if (mImages != nullptr)
- {
- imageX = padding;
- textX = padding + mImageWidth + spacing;
- }
- else
- {
- textX = padding;
- }
- break;
- }
- case Graphics::CENTER:
- {
- const int width1 = font->getWidth(mCaption);
- if (mImages != nullptr)
- {
- const int w = width1 + mImageWidth + spacing;
- imageX = (width - w) / 2;
- textX = imageX + mImageWidth + spacing - width1 / 2;
- }
- else
- {
- textX = (width - width1) / 2;
- }
- break;
- }
- case Graphics::RIGHT:
- {
- const int width1 = font->getWidth(mCaption);
- textX = width - width1 - padding;
- imageX = textX - width1 - spacing;
- break;
- }
- }
-
- if (recalc)
- {
- mRedraw = false;
- mMode = mode;
- mVertexes2->clear();
- graphics->calcWindow(mVertexes2,
- 0, 0,
- width, height,
- skin->getBorder());
-
- if (mImages != nullptr)
- {
- if (isPressed())
- {
- graphics->calcTileCollection(mVertexes2,
- mImages[mode],
- imageX + 1, imageY + 1);
- }
- else
- {
- graphics->calcTileCollection(mVertexes2,
- mImages[mode],
- imageX, imageY);
- }
- }
- graphics->finalize(mVertexes2);
- }
- graphics->drawTileCollection(mVertexes2);
-
- if (isPressed())
- {
- textX ++;
- textY ++;
- }
-
- if (mTextChanged)
- {
- mTextChunk.textFont = font;
- mTextChunk.deleteImage();
- mTextChunk.text = mCaption;
- switch (mode)
- {
- case BUTTON_DISABLED:
- mTextChunk.color = mDisabledColor;
- mTextChunk.color2 = mDisabledColor2;
- break;
- case BUTTON_PRESSED:
- mTextChunk.color = mPressedColor;
- mTextChunk.color2 = mPressedColor2;
- break;
- case BUTTON_HIGHLIGHTED:
- mTextChunk.color = mHighlightedColor;
- mTextChunk.color2 = mHighlightedColor2;
- break;
- default:
- mTextChunk.color = mEnabledColor;
- mTextChunk.color2 = mEnabledColor2;
- break;
- }
- font->generate(mTextChunk);
- mTextChanged = false;
- }
-
- const Image *const image = mTextChunk.img;
- if (image != nullptr)
- graphics->drawImage(image, textX, textY);
-
- BLOCK_END("Button::draw")
-}
-
-void Button::safeDraw(Graphics *const graphics)
-{
- BLOCK_START("Button::safeDraw")
- int mode;
-
- if (!isEnabled())
- mode = BUTTON_DISABLED;
- else if (isPressed2())
- mode = BUTTON_PRESSED;
- else if (mHasMouse || isFocused())
- mode = BUTTON_HIGHLIGHTED;
- else
- mode = BUTTON_STANDARD;
-
- const Skin *const skin = button[mode];
- if (skin == nullptr)
- {
- BLOCK_END("Button::safeDraw")
- return;
- }
-
- updateAlpha();
-
- if (mMode != mode)
- {
- mTextChanged = true;
- mMode = mode;
- }
-
- const int padding = skin->getPadding();
- const int spacing = mSpacing[mode];
-
- int imageX = 0;
- int imageY = 0;
- int textX = 0;
- const Rect &rect = mDimension;
- const int width = rect.width;
- const int height = rect.height;
- Font *const font = getFont();
- int textY = height / 2 - font->getHeight() / 2;
- if (mImages != nullptr)
- imageY = height / 2 - mImageHeight / 2;
-
-// need move calculation from draw!!!
-
- switch (mAlignment)
- {
- default:
- case Graphics::LEFT:
- {
- if (mImages != nullptr)
- {
- imageX = padding;
- textX = padding + mImageWidth + spacing;
- }
- else
- {
- textX = padding;
- }
- break;
- }
- case Graphics::CENTER:
- {
- const int width1 = font->getWidth(mCaption);
- if (mImages != nullptr)
- {
- const int w = width1 + mImageWidth + spacing;
- imageX = (width - w) / 2;
- textX = imageX + mImageWidth + spacing - width1 / 2;
- }
- else
- {
- textX = (width - width1) / 2;
- }
- break;
- }
- case Graphics::RIGHT:
- {
- const int width1 = font->getWidth(mCaption);
- textX = width - width1 - padding;
- imageX = textX - width1 - spacing;
- break;
- }
- }
-
- graphics->drawImageRect(0, 0, width, height, skin->getBorder());
-
- if (mImages != nullptr)
- {
- if (isPressed())
- graphics->drawImage(mImages[mode], imageX + 1, imageY + 1);
- else
- graphics->drawImage(mImages[mode], imageX, imageY);
- }
-
- if (isPressed())
- {
- textX ++;
- textY ++;
- }
-
- if (mTextChanged)
- {
- mTextChunk.textFont = font;
- mTextChunk.deleteImage();
- mTextChunk.text = mCaption;
- switch (mode)
- {
- case BUTTON_DISABLED:
- mTextChunk.color = mDisabledColor;
- mTextChunk.color2 = mDisabledColor2;
- break;
- case BUTTON_PRESSED:
- mTextChunk.color = mPressedColor;
- mTextChunk.color2 = mPressedColor2;
- break;
- case BUTTON_HIGHLIGHTED:
- mTextChunk.color = mHighlightedColor;
- mTextChunk.color2 = mHighlightedColor2;
- break;
- default:
- mTextChunk.color = mEnabledColor;
- mTextChunk.color2 = mEnabledColor2;
- break;
- }
- font->generate(mTextChunk);
- mTextChanged = false;
- }
-
- const Image *const image = mTextChunk.img;
- if (image != nullptr)
- graphics->drawImage(image, textX, textY);
-
- BLOCK_END("Button::safeDraw")
-}
-
-void Button::mouseReleased(MouseEvent& event)
-{
- if (event.getButton() == MouseButton::LEFT)
- {
- if (mStick)
- mPressed = !mPressed;
-
- if (mMousePressed && mHasMouse)
- {
- mMousePressed = false;
- mClickCount = event.getClickCount();
- distributeActionEvent();
- }
- else
- {
- mMousePressed = false;
- mClickCount = 0;
- }
- event.consume();
- }
-}
-
-void Button::widgetResized(const Event &event A_UNUSED)
-{
- mRedraw = true;
-}
-
-void Button::widgetMoved(const Event &event A_UNUSED)
-{
- mRedraw = true;
-}
-
-void Button::widgetHidden(const Event &event A_UNUSED)
-{
- if (isBatchDrawRenders(openGLMode))
- mVertexes2->clear();
- mTextChunk.deleteImage();
- mRedraw = true;
- mTextChanged = true;
-}
-
-void Button::adjustSize()
-{
- const Font *const font = getFont();
- const Skin *const skin = button[BUTTON_STANDARD];
- if (skin == nullptr)
- return;
- const int padding = skin->getPadding();
-
- if (mImages != nullptr)
- {
- const int spacing = mSpacing[BUTTON_STANDARD];
- const int width = font->getWidth(mCaption);
- if (width != 0)
- setWidth(width + mImageWidth + spacing + 2 * padding);
- else
- setWidth(mImageWidth + 2 * padding);
- int height = font->getHeight();
- if (height < mImageHeight)
- height = mImageHeight;
- setHeight(height + 2 * padding);
- }
- else
- {
- setWidth(font->getWidth(mCaption) + 2 * padding);
- setHeight(font->getHeight() + 2 * padding);
- }
-}
-
-void Button::keyPressed(KeyEvent& event)
-{
- const InputActionT action = event.getActionId();
-
- if (action == InputAction::GUI_SELECT)
- {
- mKeyPressed = true;
- event.consume();
- }
-}
-
-void Button::keyReleased(KeyEvent& event)
-{
- const InputActionT action = event.getActionId();
-
- if (action == InputAction::GUI_SELECT && mKeyPressed)
- {
- mKeyPressed = false;
- if (mStick)
- mPressed = !mPressed;
- distributeActionEvent();
- event.consume();
- }
-}
-
-bool Button::isPressed2() const
-{
- return mPressed || isPressed();
-}
-
-bool Button::isPressed() const
-{
- if (mMousePressed)
- return mHasMouse;
- return mKeyPressed;
-}
-
-void Button::focusLost(const Event& event A_UNUSED)
-{
- mMousePressed = false;
- mKeyPressed = false;
-}
-
-void Button::mousePressed(MouseEvent& event)
-{
- if (event.getButton() == MouseButton::LEFT)
- {
- mMousePressed = true;
- event.consume();
- }
-}
-
-void Button::mouseEntered(MouseEvent& event A_UNUSED)
-{
- mHasMouse = true;
-}
-
-void Button::mouseExited(MouseEvent& event A_UNUSED)
-{
- mHasMouse = false;
-}
-
-void Button::mouseDragged(MouseEvent& event)
-{
- event.consume();
-}
-
-void Button::setParent(Widget *widget)
-{
- if (mWindow != nullptr)
- mWindow->addWidgetListener(this);
- Widget::setParent(widget);
-}
-
-void Button::setWindow(Widget *const widget)
-{
- if ((widget == nullptr) && (mWindow != nullptr))
- {
- mWindow->removeWidgetListener(this);
- mWindow = nullptr;
- }
- else
- {
- Widget2::setWindow(widget);
- }
-}
diff --git a/src/gui/widgets/button.h b/src/gui/widgets/button.h
deleted file mode 100644
index 4e6b5ba16..000000000
--- a/src/gui/widgets/button.h
+++ /dev/null
@@ -1,347 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GUI_WIDGETS_BUTTON_H
-#define GUI_WIDGETS_BUTTON_H
-
-#include "gui/fonts/textchunk.h"
-
-#include "gui/widgets/widget.h"
-
-#include "listeners/focuslistener.h"
-#include "listeners/keylistener.h"
-#include "listeners/mouselistener.h"
-#include "listeners/widgetlistener.h"
-
-#include "render/graphics.h"
-
-#include "localconsts.h"
-
-class Image;
-class ImageCollection;
-class ImageSet;
-class Skin;
-
-const std::string BUTTON_PLAY = "buttonplay.png";
-
-/**
- * Button widget. Same as the Guichan button but with custom look.
- *
- * \ingroup GUI
- */
-class Button final : public Widget,
- public MouseListener,
- public KeyListener,
- public FocusListener,
- public WidgetListener
-{
- public:
- /**
- * Default constructor.
- */
- explicit Button(const Widget2 *const widget);
-
- /**
- * Constructor, sets the caption of the button to the given string and
- * adds the given action listener.
- */
- Button(const Widget2 *const widget,
- const std::string &restrict caption,
- const std::string &restrict actionEventId,
- ActionListener *const listener);
-
- /**
- * Constructor, sets the caption of the button to the given string and
- * adds the given action listener.
- */
- Button(const Widget2 *const widget,
- const std::string &restrict caption,
- const std::string &restrict imageName,
- const int imageWidth, const int imageHeight,
- const std::string &actionEventId,
- ActionListener *const listener);
-
- /**
- * Constructor, sets the caption of the button to the given string and
- * adds the given action listener.
- */
- Button(const Widget2 *const widget,
- const std::string &restrict imageName,
- const int imageWidth, const int imageHeight,
- const std::string &restrict actionEventId,
- ActionListener *const listener);
-
- /**
- * Constructor, sets the caption of the button to the given string and
- * adds the given action listener.
- */
- Button(const Widget2 *const widget,
- const std::string &restrict imageName,
- const std::string &restrict caption,
- const std::string &restrict actionEventId,
- ActionListener *const listener);
-
- A_DELETE_COPY(Button)
-
- /**
- * Destructor.
- */
- ~Button();
-
- /**
- * Draws the button.
- */
- void draw(Graphics *const graphics) override final A_NONNULL(2);
-
- void safeDraw(Graphics *const graphics) override final A_NONNULL(2);
-
- /**
- * Update the alpha value to the button components.
- */
- static void updateAlpha();
-
- void mouseReleased(MouseEvent& event) override final;
-
- void setDescription(const std::string &text)
- { mDescription = text; }
-
- std::string getDescription() const noexcept2 A_WARN_UNUSED
- { return mDescription; }
-
- int getClickCount() const noexcept2 A_WARN_UNUSED
- { return mClickCount; }
-
- void setTag(int tag)
- { mTag = tag; }
-
- int getTag() const noexcept2 A_WARN_UNUSED
- { return mTag; }
-
- void setStick(bool b)
- { mStick = b; }
-
- void setPressed(bool b)
- { mPressed = b; }
-
- void widgetResized(const Event &event) override final;
-
- void widgetMoved(const Event &event) override final;
-
- void widgetHidden(const Event &event) override final;
-
- void loadImage(const std::string &imageName);
-
- void loadImageSet(const std::string &imageName);
-
- void adjustSize();
-
- void keyPressed(KeyEvent &event) override final;
-
- void keyReleased(KeyEvent &event) override final;
-
- bool isPressed2() const A_WARN_UNUSED;
-
- /**
- * Sets the caption of the button. It's advisable to call
- * adjustSize after setting of the caption to adjust the
- * button's size to fit the caption.
- *
- * @param caption The caption of the button.
- * @see getCaption, adjustSize
- */
- void setCaption(const std::string& caption)
- { mCaption = caption; mTextChanged = true; }
-
- /**
- * Gets the caption of the button.
- *
- * @return The caption of the button.
- */
- const std::string& getCaption() const noexcept2 A_WARN_UNUSED
- { return mCaption; }
-
- /**
- * Sets the alignment of the caption. The alignment is relative
- * to the center of the button.
- *
- * @param alignment The alignment of the caption.
- * @see getAlignment, Graphics
- */
- void setAlignment(Graphics::Alignment alignment) noexcept2
- { mAlignment = alignment; }
-
- /**
- * Gets the alignment of the caption.
- *
- * @return The alignment of the caption.
- * @see setAlignment, Graphics
- */
- Graphics::Alignment getAlignment() const noexcept2 A_WARN_UNUSED
- { return mAlignment; }
-
- void focusLost(const Event& event) override final;
-
- void mousePressed(MouseEvent& event) override final;
-
- void mouseEntered(MouseEvent& event) override final;
-
- void mouseExited(MouseEvent& event) override final;
-
- void mouseDragged(MouseEvent& event) override final;
-
- void setParent(Widget *widget) override final;
-
- void setWindow(Widget *const widget) override final;
-
- void setImageWidth(const int width) noexcept2
- { mImageWidth = width; }
-
- void setImageHeight(const int height) noexcept2
- { mImageHeight = height; }
-
- enum
- {
- BUTTON_STANDARD = 0, // 0
- BUTTON_HIGHLIGHTED, // 1
- BUTTON_PRESSED, // 2
- BUTTON_DISABLED, // 3
- BUTTON_COUNT // 4 - Must be last.
- };
-
- private:
- /**
- * Checks if the button is pressed. Convenient method to use
- * when overloading the draw method of the button.
- *
- * @return True if the button is pressed, false otherwise.
- */
- bool isPressed() const;
-
- void init();
-
- static Skin *button[BUTTON_COUNT]; /**< Button state graphics */
- static int mInstances; /**< Number of button instances */
- static float mAlpha;
-
- /**
- * Holds the caption of the button.
- */
- std::string mCaption;
-
- std::string mDescription;
-
- TextChunk mTextChunk;
-
- ImageCollection *mVertexes2 A_NONNULLPOINTER;
- Color mEnabledColor;
- Color mEnabledColor2;
- Color mDisabledColor;
- Color mDisabledColor2;
- Color mHighlightedColor;
- Color mHighlightedColor2;
- Color mPressedColor;
- Color mPressedColor2;
- Image **mImages;
- ImageSet *mImageSet;
-
- /**
- * Holds the alignment of the caption.
- */
- Graphics::Alignment mAlignment;
-
- int mClickCount;
-
- /**
- * Holds the spacing between the border and the caption.
- */
- int mSpacing[BUTTON_COUNT];
-
- int mTag;
- int mMode;
- int mXOffset;
- int mYOffset;
- int mImageWidth;
- int mImageHeight;
- /**
- * True if the mouse is ontop of the button, false otherwise.
- */
- bool mHasMouse;
-
- /**
- * True if a key has been pressed, false otherwise.
- */
- bool mKeyPressed;
-
- /**
- * True if a mouse has been pressed, false otherwise.
- */
- bool mMousePressed;
-
- bool mStick;
- bool mPressed;
- bool mTextChanged;
-};
-
-#endif // GUI_WIDGETS_BUTTON_H
diff --git a/src/gui/widgets/characterdisplay.cpp b/src/gui/widgets/characterdisplay.cpp
deleted file mode 100644
index e5743615a..000000000
--- a/src/gui/widgets/characterdisplay.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 "gui/widgets/characterdisplay.h"
-
-#include "gui/gui.h"
-
-#include "gui/windows/charselectdialog.h"
-
-#include "gui/popups/textpopup.h"
-
-#include "gui/widgets/containerplacer.h"
-#include "gui/widgets/label.h"
-#include "gui/widgets/layouthelper.h"
-
-#include "utils/gettext.h"
-#include "utils/stringutils.h"
-
-#include "resources/db/unitsdb.h"
-
-#include "net/character.h"
-
-#include "debug.h"
-
-CharacterDisplay::CharacterDisplay(const Widget2 *const widget,
- CharSelectDialog *const charSelectDialog) :
- Container(widget),
- MouseListener(),
- WidgetListener(),
- mCharacter(nullptr),
- mPlayerBox(new PlayerBox(nullptr)),
- mName(new Label(this, "wwwwwwwwwwwwwwwwwwwwwwww"))
-{
- mPlayerBox->setActionEventId("select");
- mPlayerBox->addActionListener(charSelectDialog);
- setActionEventId("use");
- addActionListener(charSelectDialog);
-
- LayoutHelper h(this);
- ContainerPlacer placer = h.getPlacer(0, 0);
-
- placer(0, 0, mPlayerBox, 3, 5);
- placer(0, 5, mName, 3);
-
- update();
-
- mName->setAlignment(Graphics::CENTER);
- mName->adjustSize();
-
- if (mainGraphics->getWidth() > 800)
- setWidth(120);
- else
- setWidth(80);
- setHeight(120);
- addMouseListener(this);
- addWidgetListener(this);
-}
-
-CharacterDisplay::~CharacterDisplay()
-{
-}
-
-void CharacterDisplay::setCharacter(Net::Character *const character)
-{
- if (mCharacter == character)
- return;
-
- mCharacter = character;
- mPlayerBox->setPlayer(character != nullptr ? character->dummy : nullptr);
- update();
-}
-
-void CharacterDisplay::requestFocus()
-{
-}
-
-void CharacterDisplay::setActive(const bool active A_UNUSED)
-{
-}
-
-void CharacterDisplay::update()
-{
- if (mCharacter != nullptr)
- mName->setCaption(mCharacter->dummy->getName());
- else
- mName->setCaption("");
- const int width = mPlayerBox->getWidth();
- mName->resizeTo(width, width);
-
- distributeResizedEvent();
-}
-
-void CharacterDisplay::widgetHidden(const Event &event A_UNUSED)
-{
- if (textPopup != nullptr)
- textPopup->setVisible(Visible_false);
-}
-
-void CharacterDisplay::mouseExited(MouseEvent &event A_UNUSED)
-{
- if (textPopup != nullptr)
- textPopup->setVisible(Visible_false);
-}
-
-void CharacterDisplay::mouseMoved(MouseEvent &event A_UNUSED)
-{
- if (gui == nullptr ||
- textPopup == nullptr ||
- mCharacter == nullptr)
- {
- return;
- }
-
- int mouseX = 0;
- int mouseY = 0;
- Gui::getMouseState(mouseX, mouseY);
- const std::string &name = mName->getCaption();
- if (!name.empty())
- {
- textPopup->show(mouseX, mouseY,
- name,
- // TRANSLATORS: character level
- strprintf(_("Level: %u"),
- CAST_U32(
- mCharacter->data.mAttributes[Attributes::PLAYER_BASE_LEVEL])),
- // TRANSLATORS: character money
- strprintf(_("Money: %s"), UnitsDb::formatCurrency64(
- mCharacter->data.mAttributes[Attributes::MONEY]).c_str()));
- }
- else
- {
- textPopup->setVisible(Visible_false);
- }
-}
-
-void CharacterDisplay::mousePressed(MouseEvent &event)
-{
- event.consume();
- if (event.getClickCount() == 2)
- distributeActionEvent();
-}
diff --git a/src/gui/widgets/characterdisplay.h b/src/gui/widgets/characterdisplay.h
deleted file mode 100644
index def986b2d..000000000
--- a/src/gui/widgets/characterdisplay.h
+++ /dev/null
@@ -1,93 +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_CHARACTERDISPLAY_H
-#define GUI_WIDGETS_CHARACTERDISPLAY_H
-
-#include "gui/widgets/container.h"
-#include "gui/widgets/playerbox.h"
-
-#include "listeners/widgetlistener.h"
-
-#include "localconsts.h"
-
-class CharSelectDialog;
-class Label;
-
-namespace Net
-{
- struct Character;
-} // namespace Net
-
-class CharacterDisplay final : public Container,
- public MouseListener,
- public WidgetListener
-{
- public:
- CharacterDisplay(const Widget2 *const widget,
- CharSelectDialog *const charSelectDialog);
-
- A_DELETE_COPY(CharacterDisplay)
-
- ~CharacterDisplay();
-
- void setCharacter(Net::Character *const character);
-
- Net::Character *getCharacter() const
- { return mCharacter; }
-
- void requestFocus() override final A_CONST;
-
- void setActive(const bool active) A_CONST;
-
- bool isSelectFocused() const
- { return false; }
-
- bool isDeleteFocused() const
- { return false; }
-
- void focusSelect()
- { }
-
- void focusDelete()
- { }
-
- void setSelect(bool b)
- { mPlayerBox->setSelected(b); }
-
- void widgetHidden(const Event &event) override final;
-
- void mouseExited(MouseEvent &event) override final;
-
- void mouseMoved(MouseEvent &event) override final;
-
- void mousePressed(MouseEvent &event) override final;
-
- void update();
-
- private:
- Net::Character *mCharacter;
- PlayerBox *mPlayerBox A_NONNULLPOINTER;
- Label *mName A_NONNULLPOINTER;
-};
-
-#endif // GUI_WIDGETS_CHARACTERDISPLAY_H
diff --git a/src/gui/widgets/characterviewbase.h b/src/gui/widgets/characterviewbase.h
deleted file mode 100644
index ad12efb26..000000000
--- a/src/gui/widgets/characterviewbase.h
+++ /dev/null
@@ -1,63 +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 GUI_WIDGETS_CHARACTERVIEWBASE_H
-#define GUI_WIDGETS_CHARACTERVIEWBASE_H
-
-#include "gui/windows/charselectdialog.h"
-
-#include "gui/widgets/container.h"
-
-#include "localconsts.h"
-
-class CharacterViewBase notfinal : public Container,
- public ActionListener
-{
- public:
- A_DELETE_COPY(CharacterViewBase)
-
- virtual ~CharacterViewBase()
- { }
-
- virtual void show(const int i) = 0;
-
- virtual void resize() = 0;
-
- int getSelected() const
- {
- return mSelected;
- }
-
- protected:
- CharacterViewBase(CharSelectDialog *const widget, const int padding) :
- Container(widget),
- ActionListener(),
- mParent(widget),
- mPadding(padding),
- mSelected(0)
- {
- }
-
- CharSelectDialog *mParent;
- int mPadding;
- int mSelected;
-};
-
-#endif // GUI_WIDGETS_CHARACTERVIEWBASE_H
diff --git a/src/gui/widgets/characterviewnormal.cpp b/src/gui/widgets/characterviewnormal.cpp
deleted file mode 100644
index c52616b85..000000000
--- a/src/gui/widgets/characterviewnormal.cpp
+++ /dev/null
@@ -1,121 +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 "gui/widgets/characterviewnormal.h"
-
-#include "configuration.h"
-
-#include "gui/widgets/characterdisplay.h"
-
-#include "utils/foreach.h"
-
-#include "debug.h"
-
-namespace
-{
- int perRowCount = 5;
-} // namespace
-
-CharacterViewNormal::CharacterViewNormal(CharSelectDialog *const widget,
- STD_VECTOR<CharacterDisplay*>
- *const entries,
- const int padding) :
- CharacterViewBase(widget, padding),
- mCharacterEntries(entries),
- mRows(2)
-{
- addKeyListener(widget);
- if (entries != nullptr)
- {
- FOR_EACHP (STD_VECTOR<CharacterDisplay*>::iterator,
- it, entries)
- {
- CharacterDisplay *const character = *it;
- add(character);
- character->setVisible(Visible_true);
- }
- const size_t sz = mCharacterEntries->size();
- if (mSelected >= 0 && mSelected < CAST_S32(sz))
- {
- CharacterDisplay *const display = (*mCharacterEntries)[mSelected];
- if (display != nullptr)
- display->setSelect(false);
- }
- if (sz > 0)
- {
- mSelected = 0;
- CharacterDisplay *const display = (*mCharacterEntries)[0];
- display->setSelect(true);
- setWidth(display->getWidth() * perRowCount + mPadding * 2);
- }
- else
- {
- mSelected = -1;
- }
- mRows = CAST_S32(sz / perRowCount);
-
- if (mRows * perRowCount != CAST_S32(sz))
- mRows ++;
- }
-
- setHeight((105 + config.getIntValue("fontSize")) * mRows);
-}
-
-CharacterViewNormal::~CharacterViewNormal()
-{
- removeKeyListener(mParent);
-}
-
-void CharacterViewNormal::show(const int i)
-{
- const int sz = CAST_S32(mCharacterEntries->size());
- if (i >= 0 && i < sz)
- {
- if (mSelected >= 0)
- (*mCharacterEntries)[mSelected]->setSelect(false);
- mSelected = i;
- (*mCharacterEntries)[i]->setSelect(true);
- }
-}
-
-void CharacterViewNormal::resize()
-{
- const size_t sz = mCharacterEntries->size();
- if (sz == 0)
- return;
- const CharacterDisplay *const firtChar = (*mCharacterEntries)[0];
- int y = 0;
- const int width = firtChar->getWidth();
- const int height = firtChar->getHeight();
- int x = 0;
- for (size_t f = 0; f < sz; f ++, x ++)
- {
- if (x >= perRowCount)
- {
- x = 0;
- y += height;
- }
- (*mCharacterEntries)[f]->setPosition(x * width, y);
- }
-}
-
-void CharacterViewNormal::action(const ActionEvent &event A_UNUSED)
-{
-}
diff --git a/src/gui/widgets/characterviewnormal.h b/src/gui/widgets/characterviewnormal.h
deleted file mode 100644
index 344549092..000000000
--- a/src/gui/widgets/characterviewnormal.h
+++ /dev/null
@@ -1,50 +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 GUI_WIDGETS_CHARACTERVIEWNORMAL_H
-#define GUI_WIDGETS_CHARACTERVIEWNORMAL_H
-
-#include "gui/widgets/characterviewbase.h"
-
-#include "localconsts.h"
-
-class CharacterViewNormal final : public CharacterViewBase
-{
- public:
- CharacterViewNormal(CharSelectDialog *const widget,
- STD_VECTOR<CharacterDisplay*> *const entries,
- const int padding);
-
- A_DELETE_COPY(CharacterViewNormal)
-
- ~CharacterViewNormal();
-
- void show(const int i) override final;
-
- void resize() override;
-
- void action(const ActionEvent &event A_UNUSED) override final A_CONST;
-
- private:
- STD_VECTOR<CharacterDisplay*> *mCharacterEntries;
- int mRows;
-};
-
-#endif // GUI_WIDGETS_CHARACTERVIEWNORMAL_H
diff --git a/src/gui/widgets/characterviewsmall.cpp b/src/gui/widgets/characterviewsmall.cpp
deleted file mode 100644
index a2fbdc8d4..000000000
--- a/src/gui/widgets/characterviewsmall.cpp
+++ /dev/null
@@ -1,136 +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 "gui/widgets/characterviewsmall.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/characterdisplay.h"
-#include "gui/widgets/label.h"
-
-#include "utils/foreach.h"
-#include "utils/stringutils.h"
-
-#include "debug.h"
-
-CharacterViewSmall::CharacterViewSmall(CharSelectDialog *const widget,
- STD_VECTOR<CharacterDisplay*>
- *const entries,
- const int padding) :
- CharacterViewBase(widget, padding),
- mSelectedEntry(nullptr),
- mPrevious(new Button(this, "<", "prev", this)),
- mNext(new Button(this, ">", "next", this)),
- mNumber(new Label(this, "??")),
- mCharacterEntries(entries)
-{
- addKeyListener(widget);
- if (entries != nullptr)
- {
- FOR_EACHP (STD_VECTOR<CharacterDisplay*>::iterator,
- it, entries)
- {
- add(*it);
- }
- const int sz = CAST_S32(mCharacterEntries->size());
- if (sz > 0)
- {
- mSelected = 0;
- mSelectedEntry = (*mCharacterEntries)[mSelected];
- mSelectedEntry->setVisible(Visible_true);
- mNumber->setCaption(strprintf("%d / %d", mSelected + 1, sz));
- mNumber->adjustSize();
- }
- else
- {
- mSelected = -1;
- mSelectedEntry = nullptr;
- mNumber->setCaption("0 / 0");
- mNumber->adjustSize();
- }
- }
- add(mPrevious);
- add(mNext);
- add(mNumber);
-
- setHeight(200);
-}
-
-CharacterViewSmall::~CharacterViewSmall()
-{
- removeKeyListener(mParent);
-}
-
-void CharacterViewSmall::show(const int i)
-{
- const int sz = CAST_S32(mCharacterEntries->size());
- if (sz <= 0)
- return;
- if (mSelectedEntry != nullptr)
- mSelectedEntry->setVisible(Visible_false);
- if (i >= sz)
- mSelected = 0;
- else if (i < 0)
- mSelected = sz - 1;
- else
- mSelected = i;
- mSelectedEntry = (*mCharacterEntries)[mSelected];
- mSelectedEntry->setVisible(Visible_true);
- mNumber->setCaption(strprintf("%d / %d", mSelected + 1, sz));
- mNumber->adjustSize();
-}
-
-void CharacterViewSmall::resize()
-{
- const int sz = CAST_S32(mCharacterEntries->size());
- if (sz <= 0)
- return;
- const CharacterDisplay *const firtChar = (*mCharacterEntries)[0];
- const int w = mDimension.width;
- const int h = mDimension.height;
- const int x = (w - firtChar->getWidth()) / 2;
- const int y = (h - firtChar->getHeight()) / 2;
- FOR_EACHP (STD_VECTOR<CharacterDisplay*>::iterator,
- it, mCharacterEntries)
- {
- (*it)->setPosition(x, y);
- }
- const int y2 = (h - mPrevious->getHeight()) / 2;
- const int y3 = y2 - 55;
- mPrevious->setPosition(x - mPrevious->getWidth() - 10, y3);
- mNext->setPosition(w - x + 10, y3);
- mNumber->setPosition(10, y2);
-}
-
-void CharacterViewSmall::action(const ActionEvent &event)
-{
- const std::string &eventId = event.getId();
- if (eventId == "next")
- {
- mSelected ++;
- show(mSelected);
- mParent->updateState();
- }
- else if (eventId == "prev")
- {
- mSelected --;
- show(mSelected);
- mParent->updateState();
- }
-}
diff --git a/src/gui/widgets/characterviewsmall.h b/src/gui/widgets/characterviewsmall.h
deleted file mode 100644
index f363c608e..000000000
--- a/src/gui/widgets/characterviewsmall.h
+++ /dev/null
@@ -1,54 +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 GUI_WIDGETS_CHARACTERVIEWSMALL_H
-#define GUI_WIDGETS_CHARACTERVIEWSMALL_H
-
-#include "gui/widgets/characterviewbase.h"
-
-#include "localconsts.h"
-
-class Label;
-
-class CharacterViewSmall final : public CharacterViewBase
-{
- public:
- CharacterViewSmall(CharSelectDialog *const widget,
- STD_VECTOR<CharacterDisplay*> *const entries,
- const int padding);
- A_DELETE_COPY(CharacterViewSmall)
-
- ~CharacterViewSmall();
-
- void show(const int i) override final;
-
- void resize() override final;
-
- void action(const ActionEvent &event) override final;
-
- private:
- CharacterDisplay *mSelectedEntry;
- Button *mPrevious;
- Button *mNext;
- Label *mNumber;
- STD_VECTOR<CharacterDisplay*> *mCharacterEntries;
-};
-
-#endif // GUI_WIDGETS_CHARACTERVIEWSMALL_H
diff --git a/src/gui/widgets/chatinput.h b/src/gui/widgets/chatinput.h
deleted file mode 100644
index 92c7dc341..000000000
--- a/src/gui/widgets/chatinput.h
+++ /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/>.
- */
-
-#ifndef GUI_WIDGETS_CHATINPUT_H
-#define GUI_WIDGETS_CHATINPUT_H
-
-#include "gui/windows/chatwindow.h"
-
-#include "configuration.h"
-
-#include "gui/windows/emotewindow.h"
-
-#include "gui/widgets/textfield.h"
-
-#include "localconsts.h"
-
-/**
- * The chat input hides when it loses focus. It is also invisible by default.
- */
-class ChatInput final : public TextField
-{
- public:
- explicit ChatInput(ChatWindow *const window) :
- TextField(window, "", LoseFocusOnTab_false),
- mWindow(window),
- mFocusGaining(false)
- {
- setVisible(Visible_false);
- addFocusListener(this);
- }
-
- A_DELETE_COPY(ChatInput)
-
- /**
- * Called if the chat input loses focus. It will set itself to
- * invisible as result.
- */
- void focusLost(const Event &event) override final
- {
- TextField::focusLost(event);
- if (mFocusGaining || !config.getBoolValue("protectChatFocus"))
- {
- processVisible(Visible_false);
- if (chatWindow != nullptr)
- chatWindow->updateVisibility();
- mFocusGaining = false;
- return;
- }
- mFocusGaining = true;
- requestFocus();
- mFocusGaining = false;
- }
-
- void processVisible(const Visible n)
- {
- if (mWindow == nullptr || isVisible() == (n == Visible_true))
- return;
-
- if (n == Visible_false)
- mFocusGaining = true;
- setVisible(n);
- if (config.getBoolValue("hideChatInput")
- || config.getBoolValue("showEmotesButton"))
- {
- mWindow->adjustTabSize();
- }
- if (emoteWindow != nullptr)
- {
- emoteWindow->hide();
- }
- }
-
- void unprotectFocus()
- { mFocusGaining = true; }
-
- void setVisible(Visible visible)
- {
- TextField::setVisible(visible);
- }
-
- private:
- ChatWindow *mWindow;
- bool mFocusGaining;
-};
-
-#endif // GUI_WIDGETS_CHATINPUT_H
diff --git a/src/gui/widgets/checkbox.cpp b/src/gui/widgets/checkbox.cpp
deleted file mode 100644
index ab1227b08..000000000
--- a/src/gui/widgets/checkbox.cpp
+++ /dev/null
@@ -1,338 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "gui/widgets/checkbox.h"
-
-#include "settings.h"
-
-#include "gui/gui.h"
-#include "gui/skin.h"
-
-#include "gui/fonts/font.h"
-
-#include "render/graphics.h"
-
-#include "resources/imagerect.h"
-
-#include "resources/image/image.h"
-
-#include "debug.h"
-
-int CheckBox::instances = 0;
-Skin *CheckBox::mSkin = nullptr;
-float CheckBox::mAlpha = 1.0;
-
-CheckBox::CheckBox(const Widget2 *const widget,
- const std::string &restrict caption,
- const bool selected,
- ActionListener *const listener,
- const std::string &restrict eventId) :
- Widget(widget),
- ToolTipListener(),
- KeyListener(),
- WidgetListener(),
- mSelected(selected),
- mCaption(),
- mTextChunk(),
- mPadding(0),
- mImagePadding(0),
- mImageSize(9),
- mSpacing(2),
- mTextX(0 + 9 + 2),
- mHasMouse(false),
- mDrawBox(true),
- mTextChanged(true)
-{
- setCaption(caption);
- mAllowLogic = false;
-
- setFocusable(true);
- addMouseListener(this);
- addKeyListener(this);
-
- mForegroundColor2 = getThemeColor(ThemeColorId::CHECKBOX_OUTLINE);
- if (instances == 0)
- {
- if (theme != nullptr)
- {
- mSkin = theme->load("checkbox.xml", "");
- updateAlpha();
- }
- }
-
- instances++;
-
- if (!eventId.empty())
- setActionEventId(eventId);
-
- if (listener != nullptr)
- addActionListener(listener);
-
- mForegroundColor = getThemeColor(ThemeColorId::CHECKBOX);
- if (mSkin != nullptr)
- {
- mPadding = mSkin->getPadding();
- mImagePadding = mSkin->getOption("imagePadding");
- mImageSize = mSkin->getOption("imageSize");
- mSpacing = mSkin->getOption("spacing");
- mDrawBox = (mSkin->getOption("drawBox", 1) != 0);
- mTextX = mPadding + mImageSize + mSpacing;
- }
- adjustSize();
-}
-
-CheckBox::~CheckBox()
-{
- if (mWindow != nullptr)
- mWindow->removeWidgetListener(this);
-
- if (gui != nullptr)
- gui->removeDragged(this);
-
- instances--;
-
- if (instances == 0)
- {
- if (theme != nullptr)
- theme->unload(mSkin);
- }
-}
-
-void CheckBox::draw(Graphics *const graphics)
-{
- BLOCK_START("CheckBox::draw")
- drawBox(graphics);
-
- Font *const font = getFont();
-
- if (mTextChanged)
- {
- mTextChunk.textFont = font;
- mTextChunk.deleteImage();
- mTextChunk.text = mCaption;
- mTextChunk.color = mForegroundColor;
- mTextChunk.color2 = mForegroundColor2;
- font->generate(mTextChunk);
- mTextChanged = false;
- }
-
- const Image *const image = mTextChunk.img;
- if (image != nullptr)
- graphics->drawImage(image, mTextX, mPadding);
-
- BLOCK_END("CheckBox::draw")
-}
-
-void CheckBox::safeDraw(Graphics *const graphics)
-{
- CheckBox::draw(graphics);
-}
-
-void CheckBox::updateAlpha()
-{
- const float alpha = std::max(settings.guiAlpha,
- theme->getMinimumOpacity());
-
- if (mAlpha != alpha)
- {
- mAlpha = alpha;
- if (mSkin != nullptr)
- {
- const ImageRect &rect = mSkin->getBorder();
- for (int a = 0; a < 6; a ++)
- {
- Image *const image = rect.grid[a];
- if (image != nullptr)
- image->setAlpha(mAlpha);
- }
- }
- }
-}
-
-void CheckBox::drawBox(Graphics *const graphics)
-{
- if ((mSkin == nullptr) || !mDrawBox)
- return;
-
- const ImageRect &rect = mSkin->getBorder();
- int index = 0;
-
- if (mEnabled && mVisible == Visible_true)
- {
- if (mSelected)
- {
- if (mHasMouse)
- index = 5;
- else
- index = 1;
- }
- else
- {
- if (mHasMouse)
- index = 4;
- else
- index = 0;
- }
- }
- else
- {
- if (mSelected)
- index = 3;
- else
- index = 2;
- }
- const Image *const box = rect.grid[index];
-
- updateAlpha();
-
- if (box != nullptr)
- {
- graphics->drawImage(box,
- mImagePadding,
- (getHeight() - mImageSize) / 2);
- }
-}
-
-void CheckBox::mouseEntered(MouseEvent& event A_UNUSED)
-{
- mHasMouse = true;
-}
-
-void CheckBox::mouseExited(MouseEvent& event)
-{
- mHasMouse = false;
- ToolTipListener::mouseExited(event);
-}
-
-void CheckBox::keyPressed(KeyEvent& event)
-{
- const InputActionT action = event.getActionId();
-
- if (action == InputAction::GUI_SELECT)
- {
- toggleSelected();
- event.consume();
- }
-}
-
-void CheckBox::adjustSize()
-{
- setHeight(getFont()->getHeight() + 2 * mPadding);
- setWidth(mImagePadding + mImageSize + mSpacing
- + getFont()->getWidth(mCaption) + mPadding);
-}
-
-void CheckBox::mouseClicked(MouseEvent& event)
-{
- if (event.getButton() == MouseButton::LEFT)
- {
- toggleSelected();
- event.consume();
- }
-}
-
-void CheckBox::mouseDragged(MouseEvent& event)
-{
- event.consume();
-}
-
-void CheckBox::toggleSelected()
-{
- mSelected = !mSelected;
- distributeActionEvent();
-}
-
-void CheckBox::setCaption(const std::string& caption)
-{
- if (caption != mCaption)
- mTextChanged = true;
- mCaption = caption;
-}
-
-void CheckBox::setParent(Widget *widget)
-{
- if (mWindow != nullptr)
- mWindow->addWidgetListener(this);
- Widget::setParent(widget);
-}
-
-void CheckBox::widgetHidden(const Event &event A_UNUSED)
-{
- mTextChanged = true;
- mTextChunk.deleteImage();
-}
-
-void CheckBox::setWindow(Widget *const widget)
-{
- if ((widget == nullptr) && (mWindow != nullptr))
- {
- mWindow->removeWidgetListener(this);
- mWindow = nullptr;
- }
- else
- {
- Widget2::setWindow(widget);
- }
-}
diff --git a/src/gui/widgets/checkbox.h b/src/gui/widgets/checkbox.h
deleted file mode 100644
index 27e0a118b..000000000
--- a/src/gui/widgets/checkbox.h
+++ /dev/null
@@ -1,216 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GUI_WIDGETS_CHECKBOX_H
-#define GUI_WIDGETS_CHECKBOX_H
-
-#include "listeners/keylistener.h"
-#include "listeners/tooltiplistener.h"
-
-#include "listeners/widgetlistener.h"
-
-#include "gui/fonts/textchunk.h"
-
-#include "gui/widgets/widget.h"
-
-#include "localconsts.h"
-
-class Skin;
-
-/**
- * Check box widget. Same as the Guichan check box but with custom look.
- *
- * \ingroup GUI
- */
-class CheckBox final : public Widget,
- public ToolTipListener,
- public KeyListener,
- public WidgetListener
-{
- public:
- /**
- * Constructor.
- */
- CheckBox(const Widget2 *const widget,
- const std::string &restrict caption,
- const bool selected = false,
- ActionListener *const listener = nullptr,
- const std::string &restrict eventId = "");
-
- A_DELETE_COPY(CheckBox)
-
- /**
- * Destructor.
- */
- ~CheckBox();
-
- /**
- * Draws the caption, then calls drawBox to draw the check box.
- */
- void draw(Graphics *const graphics) override final A_NONNULL(2);
-
- void safeDraw(Graphics *const graphics) override final A_NONNULL(2);
-
- /**
- * Update the alpha value to the checkbox components.
- */
- void updateAlpha();
-
- /**
- * Draws the check box, not the caption.
- */
- void drawBox(Graphics *const graphics) A_NONNULL(2);
-
- /**
- * Called when the mouse enteres the widget area.
- */
- void mouseEntered(MouseEvent& event) override final;
-
- /**
- * Called when the mouse leaves the widget area.
- */
- void mouseExited(MouseEvent& event) override final;
-
- void keyPressed(KeyEvent& event) override final;
-
- void adjustSize();
-
- /**
- * Checks if the check box is selected.
- *
- * @return True if the check box is selected, false otherwise.
- * @see setSelected
- */
- bool isSelected() const
- { return mSelected; }
-
- /**
- * Sets the check box to be selected or not.
- *
- * @param selected True if the check box should be set as selected.
- * @see isSelected
- */
- void setSelected(const bool selected)
- { mSelected = selected; }
-
- /**
- * Gets the caption of the check box.
- *
- * @return The caption of the check box.
- * @see setCaption
- */
- const std::string &getCaption() const
- { return mCaption; }
-
- /**
- * Sets the caption of the check box. It's advisable to call
- * adjustSize after setting of the caption to adjust the
- * check box's size to fit the caption.
- *
- * @param caption The caption of the check box.
- * @see getCaption, adjustSize
- */
- void setCaption(const std::string& caption);
-
- void mouseClicked(MouseEvent& event) override final;
-
- void mouseDragged(MouseEvent& event) override final;
-
- void setParent(Widget *widget) override final;
-
- void widgetHidden(const Event &event) override final;
-
- void setWindow(Widget *const widget) override final;
-
- private:
- void toggleSelected();
-
- /**
- * True if the check box is selected, false otherwise.
- */
- bool mSelected;
-
- /**
- * Holds the caption of the check box.
- */
- std::string mCaption;
-
- TextChunk mTextChunk;
-
- int mPadding;
- int mImagePadding;
- int mImageSize;
- int mSpacing;
- int mTextX;
- bool mHasMouse;
- bool mDrawBox;
- bool mTextChanged;
-
- static int instances;
- static Skin *mSkin;
- static float mAlpha;
-};
-
-#endif // GUI_WIDGETS_CHECKBOX_H
diff --git a/src/gui/widgets/colorpage.cpp b/src/gui/widgets/colorpage.cpp
deleted file mode 100644
index fa3099c2c..000000000
--- a/src/gui/widgets/colorpage.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 "gui/widgets/colorpage.h"
-
-#include "gui/skin.h"
-
-#include "gui/fonts/font.h"
-
-#include "gui/models/colormodel.h"
-
-#include "render/graphics.h"
-
-#include "debug.h"
-
-ColorPage::ColorPage(const Widget2 *const widget,
- ListModel *const listModel,
- const std::string &skin) :
- ListBox(widget, listModel, skin)
-{
- mItemPadding = mSkin != nullptr ? mSkin->getOption("itemPadding") : 1;
- const Font *const font = getFont();
- mRowHeight = CAST_U32(font->getHeight() +
- 2 * mItemPadding);
- if (mListModel != nullptr)
- {
- setHeight(CAST_S32(getRowHeight()) *
- mListModel->getNumberOfElements()
- + 2 * mPadding + 20);
- }
-}
-
-ColorPage::~ColorPage()
-{
-}
-
-void ColorPage::draw(Graphics *const graphics)
-{
- BLOCK_START("ColorPage::draw")
-
- const ColorModel *const model = static_cast<const ColorModel*>(
- mListModel);
-
- mHighlightColor.a = CAST_U32(mAlpha * 255.0F);
- updateAlpha();
- Font *const font = getFont();
-
- const int rowHeight = CAST_S32(getRowHeight());
- const int width = mDimension.width;
-
- if (mSelected >= 0)
- {
- graphics->setColor(mHighlightColor);
- graphics->fillRectangle(Rect(mPadding,
- rowHeight * mSelected + mPadding,
- mDimension.width - 2 * mPadding, rowHeight));
-
- const ColorPair *const colors = model->getColorAt(mSelected);
- const std::string str = mListModel->getElementAt(mSelected);
- font->drawString(graphics,
- *colors->color1,
- *colors->color2,
- str,
- (width - font->getWidth(str)) / 2,
- mSelected * rowHeight + mPadding);
- }
-
- const int sz = mListModel->getNumberOfElements();
- for (int i = 0, y = mPadding; i < sz; ++i, y += rowHeight)
- {
- if (i != mSelected)
- {
- const ColorPair *const colors = model->getColorAt(i);
- const std::string str = mListModel->getElementAt(i);
- font->drawString(graphics,
- *colors->color1,
- *colors->color2,
- str,
- (width - font->getWidth(str)) / 2,
- y);
- }
- }
-
- BLOCK_END("ColorPage::draw")
-}
-
-void ColorPage::safeDraw(Graphics *const graphics)
-{
- ColorPage::draw(graphics);
-}
-
-void ColorPage::resetAction()
-{
- setSelected(-1);
-}
-
-void ColorPage::adjustSize()
-{
- BLOCK_START("ColorPage::adjustSize")
- if (mListModel != nullptr)
- {
- setHeight(CAST_S32(getRowHeight()) *
- mListModel->getNumberOfElements() +
- 2 * mPadding + 20);
- }
- BLOCK_END("ColorPage::adjustSize")
-}
diff --git a/src/gui/widgets/colorpage.h b/src/gui/widgets/colorpage.h
deleted file mode 100644
index 6b0d4122b..000000000
--- a/src/gui/widgets/colorpage.h
+++ /dev/null
@@ -1,48 +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 GUI_WIDGETS_COLORPAGE_H
-#define GUI_WIDGETS_COLORPAGE_H
-
-#include "gui/widgets/listbox.h"
-
-#include "localconsts.h"
-
-class ColorPage final : public ListBox
-{
- public:
- ColorPage(const Widget2 *const widget,
- ListModel *const listModel,
- const std::string &skin);
-
- A_DELETE_COPY(ColorPage)
-
- ~ColorPage();
-
- void draw(Graphics *const graphics) override final A_NONNULL(2);
-
- void safeDraw(Graphics *const graphics) override final A_NONNULL(2);
-
- void resetAction();
-
- void adjustSize() override final;
-};
-
-#endif // GUI_WIDGETS_COLORPAGE_H
diff --git a/src/gui/widgets/container.cpp b/src/gui/widgets/container.cpp
deleted file mode 100644
index 2da444728..000000000
--- a/src/gui/widgets/container.cpp
+++ /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/>.
- */
-
-#include "gui/widgets/container.h"
-
-#include "gui/gui.h"
-
-#include "debug.h"
-
-Container::Container(const Widget2 *const widget) :
- BasicContainer2(widget)
-{
- setOpaque(Opaque_false);
-}
-
-Container::~Container()
-{
- if (gui != nullptr)
- gui->removeDragged(this);
- removeControls();
-}
-
-void Container::removeControls()
-{
- while (!mWidgets.empty())
- delete mWidgets.front();
-}
-
-bool Container::safeRemove(Widget *const widget)
-{
- for (WidgetListConstIterator iter = mWidgets.begin();
- iter != mWidgets.end(); ++iter)
- {
- if (*iter == widget)
- {
- remove(widget);
- return true;
- }
- }
- return false;
-}
diff --git a/src/gui/widgets/container.h b/src/gui/widgets/container.h
deleted file mode 100644
index 2d6e59001..000000000
--- a/src/gui/widgets/container.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 GUI_WIDGETS_CONTAINER_H
-#define GUI_WIDGETS_CONTAINER_H
-
-#include "gui/widgets/basiccontainer2.h"
-
-/**
- * A widget container.
- *
- * The main difference between the standard Guichan container and this one is
- * that childs added to this container are automatically deleted when the
- * container is deleted.
- *
- * This container is also non-opaque by default.
- */
-class Container notfinal : public BasicContainer2
-{
- public:
- explicit Container(const Widget2 *const widget);
-
- A_DELETE_COPY(Container)
-
- virtual ~Container();
-
- bool safeRemove(Widget *const widget);
-
- void removeControls();
-};
-
-#endif // GUI_WIDGETS_CONTAINER_H
diff --git a/src/gui/widgets/containerplacer.cpp b/src/gui/widgets/containerplacer.cpp
deleted file mode 100644
index 634a87fcd..000000000
--- a/src/gui/widgets/containerplacer.cpp
+++ /dev/null
@@ -1,44 +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 "gui/widgets/containerplacer.h"
-
-#include "gui/widgets/basiccontainer2.h"
-#include "gui/widgets/layoutcell.h"
-
-#include "debug.h"
-
-ContainerPlacer ContainerPlacer::at(const int x, const int y)
-{
- return ContainerPlacer(mContainer,
- mCell != nullptr ? &mCell->at(x, y) : nullptr);
-}
-
-LayoutCell &ContainerPlacer::operator()
- (const int x, const int y, Widget *const wg, const int w, const int h)
-{
- if (mContainer != nullptr)
- mContainer->add(wg);
- if (mCell != nullptr)
- return mCell->place(wg, x, y, w, h);
- return LayoutCell::emptyCell;
-}
diff --git a/src/gui/widgets/containerplacer.h b/src/gui/widgets/containerplacer.h
deleted file mode 100644
index cd1e0221e..000000000
--- a/src/gui/widgets/containerplacer.h
+++ /dev/null
@@ -1,73 +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 GUI_WIDGETS_CONTAINERPLACER_H
-#define GUI_WIDGETS_CONTAINERPLACER_H
-
-#include "localconsts.h"
-
-class BasicContainer2;
-class LayoutCell;
-class Widget;
-
-/**
- * This class is a helper for adding widgets to nested tables in a window.
- */
-class ContainerPlacer final
-{
- public:
- explicit ContainerPlacer(BasicContainer2 *const c = nullptr,
- LayoutCell *const lc = nullptr) :
- mContainer(c),
- mCell(lc)
- {}
-
- A_DEFAULT_COPY(ContainerPlacer)
-
- /**
- * Gets the pointed cell.
- */
- LayoutCell &getCell() A_WARN_UNUSED
- { return *mCell; }
-
- /**
- * Returns a placer for the same container but to an inner cell.
- */
- ContainerPlacer at(const int x,
- const int y) A_WARN_UNUSED;
-
- /**
- * Adds the given widget to the container and places it in the layout.
- * @see LayoutArray::place
- */
- LayoutCell &operator()(const int x,
- const int y,
- Widget *const wg,
- const int w = 1,
- const int h = 1);
-
- private:
- BasicContainer2 *mContainer;
- LayoutCell *mCell;
-};
-
-#endif // GUI_WIDGETS_CONTAINERPLACER_H
diff --git a/src/gui/widgets/createwidget.h b/src/gui/widgets/createwidget.h
deleted file mode 100644
index 5f5579d24..000000000
--- a/src/gui/widgets/createwidget.h
+++ /dev/null
@@ -1,41 +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 GUI_WIDGETS_CREATEWIDGET_H
-#define GUI_WIDGETS_CREATEWIDGET_H
-
-#define CREATEWIDGETV(var, type, ...) \
- var = new type(__VA_ARGS__); \
- var->postInit()
-
-#define CREATEWIDGET(type, ...) \
- (new type(__VA_ARGS__))->postInit()
-
-#define CREATEWIDGETV0(var, type) \
- var = new type; \
- var->postInit()
-
-#define CREATEWIDGETR(type, ...) \
- static_cast<type*>(Widget::callPostInit(new type(__VA_ARGS__)))
-
-#define CREATEWIDGETR0(type) \
- static_cast<type*>(Widget::callPostInit(new type))
-
-#endif // GUI_WIDGETS_CREATEWIDGET_H
diff --git a/src/gui/widgets/desktop.cpp b/src/gui/widgets/desktop.cpp
deleted file mode 100644
index 87eb14c48..000000000
--- a/src/gui/widgets/desktop.cpp
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009-2010 The Mana World 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 "gui/widgets/desktop.h"
-
-#include "configuration.h"
-#include "main.h"
-
-#include "gui/skin.h"
-
-#include "gui/widgets/staticbrowserbox.h"
-
-#include "input/inputmanager.h"
-
-#include "render/opengl/opengldebug.h"
-
-#include "resources/imagehelper.h"
-#include "resources/wallpaper.h"
-
-#include "resources/image/image.h"
-
-#include "resources/loaders/rescaledloader.h"
-
-#include "resources/resourcemanager/resourcemanager.h"
-
-#include "render/graphics.h"
-
-#include "debug.h"
-
-Desktop *desktop = nullptr;
-
-Desktop::Desktop(const Widget2 *const widget) :
- Container(widget),
- LinkHandler(),
- WidgetListener(),
- mWallpaper(nullptr),
- mVersionLabel(new StaticBrowserBox(this, Opaque_false,
- "browserbox.xml")),
- mSkin(nullptr),
- mBackgroundGrayColor(getThemeColor(ThemeColorId::BACKGROUND_GRAY)),
- mShowBackground(true)
-{
- mBackgroundColor = getThemeColor(ThemeColorId::BACKGROUND, 128);
-
- addWidgetListener(this);
-
- Wallpaper::loadWallpapers();
-
- if (theme != nullptr)
- mSkin = theme->load("desktop.xml", "");
-
- if (mSkin != nullptr)
- mShowBackground = (mSkin->getOption("showBackground") != 0);
-
- const std::string appName = branding.getValue("appName", std::string());
- if (appName.empty())
- {
- mVersionLabel->addRow(FULL_VERSION);
- }
- else
- {
- mVersionLabel->addRow(strprintf("%s (%s)", FULL_VERSION,
- appName.c_str()));
- }
- mVersionLabel->addRow("copyright",
- "(C) ManaPlus developers, http://manaplus.org");
- mVersionLabel->setLinkHandler(this);
- mVersionLabel->updateHeight();
-}
-
-Desktop::~Desktop()
-{
- if (mWallpaper != nullptr)
- {
- mWallpaper->decRef();
- mWallpaper = nullptr;
- }
- if (theme != nullptr)
- theme->unload(mSkin);
-}
-
-void Desktop::postInit()
-{
- if (mSkin != nullptr)
- {
- addXY(mVersionLabel,
- mSkin->getOption("versionX", 25),
- mSkin->getOption("versionY", 2));
- }
- else
- {
- addXY(mVersionLabel, 25, 2);
- }
-}
-
-void Desktop::reloadWallpaper()
-{
- Wallpaper::loadWallpapers();
- setBestFittingWallpaper();
-}
-
-void Desktop::widgetResized(const Event &event A_UNUSED)
-{
- mVersionLabel->setSize(getWidth(), getHeight());
- mVersionLabel->updateHeight();
- setBestFittingWallpaper();
-}
-
-void Desktop::draw(Graphics *const graphics)
-{
- BLOCK_START("Desktop::draw")
- GLDEBUG_START("Desktop::draw")
-
- const Rect &rect = mDimension;
- const int width = rect.width;
- const int height = rect.height;
- if (mWallpaper != nullptr)
- {
- const int wallpWidth = mWallpaper->getWidth();
- const int wallpHeight = mWallpaper->getHeight();
-
- if (width > wallpWidth || height > wallpHeight)
- {
- graphics->setColor(mBackgroundGrayColor);
- graphics->fillRectangle(Rect(0, 0, width, height));
- }
-
- if (imageHelper->useOpenGL() == RENDER_SOFTWARE)
- {
- graphics->drawImage(mWallpaper,
- (width - wallpWidth) / 2,
- (height - wallpHeight) / 2);
- }
- else
- {
- graphics->drawRescaledImage(mWallpaper, 0, 0, width, height);
- }
- }
- else
- {
- graphics->setColor(mBackgroundGrayColor);
- graphics->fillRectangle(Rect(0, 0, width, height));
- }
-
- Container::draw(graphics);
- GLDEBUG_END()
- BLOCK_END("Desktop::draw")
-}
-
-void Desktop::safeDraw(Graphics *const graphics)
-{
- Desktop::draw(graphics);
-}
-
-void Desktop::setBestFittingWallpaper()
-{
- if (!mShowBackground || !config.getBoolValue("showBackground"))
- return;
-
- const std::string wallpaperName =
- Wallpaper::getWallpaper(getWidth(), getHeight());
-
- Image *const nWallPaper = Theme::getImageFromTheme(wallpaperName);
-
- if (nWallPaper != nullptr)
- {
- if (mWallpaper != nullptr)
- {
- ResourceManager::decRefDelete(mWallpaper);
- mWallpaper = nullptr;
- }
-
- const Rect &rect = mDimension;
- const int width = rect.width;
- const int height = rect.height;
-
- if (imageHelper->useOpenGL() == RENDER_SOFTWARE &&
- (nWallPaper->getWidth() != width ||
- nWallPaper->getHeight() != height))
- {
- // We rescale to obtain a fullscreen wallpaper...
- Image *const newRsclWlPpr = Loader::getRescaled(
- nWallPaper, width, height);
-
- if (newRsclWlPpr != nullptr)
- {
- ResourceManager::decRefDelete(nWallPaper);
- // We replace the resource in the resource manager
- mWallpaper = newRsclWlPpr;
- }
- else
- {
- mWallpaper = nWallPaper;
- }
- }
- else
- {
- mWallpaper = nWallPaper;
- }
- }
- else
- {
- logger->log("Couldn't load %s as wallpaper", wallpaperName.c_str());
- }
-}
-
-void Desktop::handleLink(const std::string &link, MouseEvent *event A_UNUSED)
-{
- if (link == "copyright")
- inputManager.executeAction(InputAction::WINDOW_ABOUT);
-}
diff --git a/src/gui/widgets/desktop.h b/src/gui/widgets/desktop.h
deleted file mode 100644
index 8a655892d..000000000
--- a/src/gui/widgets/desktop.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009-2010 The Mana World 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 GUI_WIDGETS_DESKTOP_H
-#define GUI_WIDGETS_DESKTOP_H
-
-#include "gui/widgets/container.h"
-
-#include "gui/widgets/linkhandler.h"
-
-#include "listeners/widgetlistener.h"
-
-#include "localconsts.h"
-
-class StaticBrowserBox;
-class Image;
-class Skin;
-
-/**
- * Desktop widget, for drawing a background image and color.
- *
- * It picks the best fitting background image. If the image doesn't fit, a
- * background color is drawn and the image is centered.
- *
- * When the desktop widget is resized, the background image is automatically
- * updated.
- *
- * The desktop also displays the client version in the top-right corner.
- *
- * \ingroup GUI
- */
-class Desktop final : public Container,
- public LinkHandler,
- public WidgetListener
-{
- public:
- explicit Desktop(const Widget2 *const widget);
-
- A_DELETE_COPY(Desktop)
-
- ~Desktop();
-
- /**
- * Has to be called after updates have been loaded.
- */
- void reloadWallpaper();
-
- void widgetResized(const Event &event) override final;
-
- void draw(Graphics *const graphics) override final A_NONNULL(2);
-
- void safeDraw(Graphics *const graphics) override final A_NONNULL(2);
-
- void postInit() override final;
-
- void handleLink(const std::string &link,
- MouseEvent *event) override final;
- private:
- void setBestFittingWallpaper();
-
- Image *mWallpaper;
- StaticBrowserBox *mVersionLabel;
- Skin *mSkin;
- Color mBackgroundGrayColor;
- bool mShowBackground;
-};
-
-extern Desktop *desktop;
-
-#endif // GUI_WIDGETS_DESKTOP_H
diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp
deleted file mode 100644
index cb9eef73d..000000000
--- a/src/gui/widgets/dropdown.cpp
+++ /dev/null
@@ -1,580 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2006-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 "gui/widgets/dropdown.h"
-
-#include "settings.h"
-
-#include "gui/gui.h"
-#include "gui/skin.h"
-
-#include "gui/fonts/font.h"
-
-#include "gui/models/extendedlistmodel.h"
-
-#include "gui/widgets/createwidget.h"
-#include "gui/widgets/popuplist.h"
-
-#include "render/graphics.h"
-
-#include "resources/imagerect.h"
-
-#include "debug.h"
-
-int DropDown::instances = 0;
-Image *DropDown::buttons[2][2];
-ImageRect DropDown::skinRect;
-float DropDown::mAlpha = 1.0;
-Skin *DropDown::mSkin = nullptr;
-
-static std::string const dropdownFiles[2] =
-{
- "dropdown.xml",
- "dropdown_pressed.xml"
-};
-
-DropDown::DropDown(const Widget2 *const widget,
- ListModel *const listModel,
- const bool extended,
- const Modal modal,
- ActionListener *const listener,
- const std::string &eventId) :
- ActionListener(),
- BasicContainer(widget),
- KeyListener(),
- MouseListener(),
- FocusListener(),
- SelectionListener(),
- mPopup(CREATEWIDGETR(PopupList, this, listModel, extended, modal)),
- mShadowColor(getThemeColor(ThemeColorId::DROPDOWN_SHADOW)),
- mHighlightColor(getThemeColor(ThemeColorId::HIGHLIGHT)),
- mPadding(1),
- mImagePadding(2),
- mSpacing(0),
- mFoldedUpHeight(0),
- mSelectionListeners(),
- mExtended(extended),
- mDroppedDown(false),
- mPushed(false),
- mIsDragged(false)
-{
- mAllowLogic = false;
- mFrameSize = 2;
- mForegroundColor2 = getThemeColor(ThemeColorId::DROPDOWN_OUTLINE);
-
- mPopup->setHeight(100);
-
- // Initialize graphics
- if (instances == 0 && (theme != nullptr))
- {
- // Load the background skin
- for (int i = 0; i < 2; i ++)
- {
- Skin *const skin = theme->load(dropdownFiles[i], "dropdown.xml");
- if (skin != nullptr)
- {
- if (i == 0)
- mSkin = skin;
- const ImageRect &rect = skin->getBorder();
- for (int f = 0; f < 2; f ++)
- {
- if (rect.grid[f] != nullptr)
- {
- rect.grid[f]->incRef();
- buttons[f][i] = rect.grid[f];
- buttons[f][i]->setAlpha(mAlpha);
- }
- else
- {
- buttons[f][i] = nullptr;
- }
- }
- if (i != 0)
- theme->unload(skin);
- }
- else
- {
- for (int f = 0; f < 2; f ++)
- buttons[f][i] = nullptr;
- }
- }
-
- // get the border skin
- theme->loadRect(skinRect, "dropdown_background.xml", "");
- }
-
- instances++;
-
- setWidth(100);
- setFocusable(true);
- setListModel(listModel);
-
- if (mPopup->getSelected() < 0)
- mPopup->setSelected(0);
-
- addMouseListener(this);
- addKeyListener(this);
- addFocusListener(this);
-
- adjustHeight();
-// mPopup->setForegroundColorAll(getThemeColor(ThemeColorId::DROPDOWN),
-// getThemeColor(ThemeColorId::DROPDOWN_OUTLINE));
- mForegroundColor = getThemeColor(ThemeColorId::DROPDOWN);
- mForegroundColor2 = getThemeColor(ThemeColorId::DROPDOWN_OUTLINE);
-
- if (!eventId.empty())
- setActionEventId(eventId);
-
- if (listener != nullptr)
- addActionListener(listener);
-
- mPopup->adjustSize();
-
- if (mSkin != nullptr)
- {
- mSpacing = mSkin->getOption("spacing");
- mFrameSize = CAST_U32(mSkin->getOption("frameSize"));
- mPadding = mSkin->getPadding();
- mImagePadding = mSkin->getOption("imagePadding");
- }
- adjustHeight();
-}
-
-DropDown::~DropDown()
-{
- if (gui != nullptr)
- gui->removeDragged(this);
-
- instances--;
- if (instances == 0)
- {
- for (int f = 0; f < 2; f ++)
- {
- for (int i = 0; i < 2; i ++)
- {
- if (buttons[f][i] != nullptr)
- buttons[f][i]->decRef();
- }
- }
- if (theme != nullptr)
- {
- theme->unload(mSkin);
- Theme::unloadRect(skinRect);
- }
- }
-}
-
-void DropDown::updateAlpha()
-{
- const float alpha = std::max(settings.guiAlpha,
- theme->getMinimumOpacity());
-
- if (mAlpha != alpha)
- {
- mAlpha = alpha;
-
- if (buttons[0][0] != nullptr)
- buttons[0][0]->setAlpha(mAlpha);
- if (buttons[0][1] != nullptr)
- buttons[0][1]->setAlpha(mAlpha);
- if (buttons[1][0] != nullptr)
- buttons[1][0]->setAlpha(mAlpha);
- if (buttons[1][1] != nullptr)
- buttons[1][1]->setAlpha(mAlpha);
-
- for (int a = 0; a < 9; a++)
- {
- if (skinRect.grid[a] != nullptr)
- skinRect.grid[a]->setAlpha(mAlpha);
- }
- }
-}
-
-void DropDown::draw(Graphics *const graphics)
-{
- BLOCK_START("DropDown::draw")
- int h;
-
- if (mDroppedDown)
- h = mFoldedUpHeight;
- else
- h = mDimension.height;
-
- updateAlpha();
-
- const unsigned int alpha = CAST_U32(mAlpha * 255.0F);
- const int pad = 2 * mPadding;
- mHighlightColor.a = alpha;
- mShadowColor.a = alpha;
-
- ListModel *const model = mPopup->getListModel();
- if ((model != nullptr) && mPopup->getSelected() >= 0)
- {
- Font *const font = getFont();
- if (mExtended)
- {
- const int sel = mPopup->getSelected();
- ExtendedListModel *const model2
- = static_cast<ExtendedListModel *>(model);
- const Image *const image = model2->getImageAt(sel);
- if (image == nullptr)
- {
- font->drawString(graphics,
- mForegroundColor,
- mForegroundColor2,
- model->getElementAt(sel),
- mPadding, mPadding);
- }
- else
- {
- graphics->drawImage(image,
- mImagePadding,
- (mDimension.height - image->getHeight()) / 2 + mPadding);
- font->drawString(graphics,
- mForegroundColor,
- mForegroundColor2,
- model->getElementAt(sel),
- image->getWidth() + mImagePadding + mSpacing, mPadding);
- }
- }
- else
- {
- font->drawString(graphics,
- mForegroundColor,
- mForegroundColor2,
- model->getElementAt(mPopup->getSelected()),
- mPadding, mPadding);
- }
- }
-
- if (isFocused())
- {
- graphics->setColor(mHighlightColor);
- graphics->drawRectangle(Rect(mPadding, mPadding,
- mDimension.width - h - pad, h - pad));
- }
-
- drawButton(graphics);
-
- if (mDroppedDown)
- {
- // Draw two lines separating the ListBox with selected
- // element view.
- const int w = mDimension.width;
- graphics->setColor(mHighlightColor);
- graphics->drawLine(0, h, w, h);
- graphics->setColor(mShadowColor);
- graphics->drawLine(0, h + 1, w, h + 1);
- }
- BLOCK_END("DropDown::draw")
-}
-
-void DropDown::safeDraw(Graphics *const graphics)
-{
- DropDown::draw(graphics);
-}
-
-void DropDown::drawFrame(Graphics *const graphics)
-{
- BLOCK_START("DropDown::drawFrame")
- const int bs2 = CAST_S32(getFrameSize());
- const Rect &rect = mDimension;
- graphics->drawImageRect(0, 0,
- rect.width + bs2, rect.height + bs2,
- skinRect);
- BLOCK_END("DropDown::drawFrame")
-}
-
-void DropDown::safeDrawFrame(Graphics *const graphics)
-{
- BLOCK_START("DropDown::drawFrame")
- const int bs2 = CAST_S32(getFrameSize());
- const Rect &rect = mDimension;
- graphics->drawImageRect(0, 0,
- rect.width + bs2, rect.height + bs2,
- skinRect);
- BLOCK_END("DropDown::drawFrame")
-}
-
-void DropDown::drawButton(Graphics *const graphics)
-{
- const int height = mDroppedDown ? mFoldedUpHeight : mDimension.height;
-
- Image *image = buttons[mDroppedDown][mPushed];
- if (image != nullptr)
- {
- graphics->drawImage(image,
- mDimension.width - image->getWidth() - mImagePadding,
- (height - image->getHeight()) / 2);
- }
-}
-
-void DropDown::keyPressed(KeyEvent& event)
-{
- if (event.isConsumed())
- return;
-
- const InputActionT actionId = event.getActionId();
- PRAGMA45(GCC diagnostic push)
- PRAGMA45(GCC diagnostic ignored "-Wswitch-enum")
- switch (actionId)
- {
- case InputAction::GUI_SELECT:
- case InputAction::GUI_SELECT2:
- dropDown();
- break;
-
- case InputAction::GUI_UP:
- setSelected(getSelected() - 1);
- break;
-
- case InputAction::GUI_DOWN:
- setSelected(getSelected() + 1);
- break;
-
- case InputAction::GUI_HOME:
- setSelected(0);
- break;
-
- case InputAction::GUI_END:
- if (mPopup->getListModel() != nullptr)
- {
- setSelected(mPopup->getListModel()->
- getNumberOfElements() - 1);
- }
- break;
-
- default:
- return;
- }
- PRAGMA45(GCC diagnostic pop)
-
- event.consume();
-}
-
-void DropDown::hideDrop(bool event)
-{
- if (event)
- distributeActionEvent();
- mPopup->setVisible(Visible_false);
-}
-
-void DropDown::mousePressed(MouseEvent& event)
-{
- event.consume();
- // If we have a mouse press on the widget.
- if (event.getButton() == MouseButton::LEFT
- && !mDroppedDown && event.getSource() == this)
- {
- mPushed = true;
- dropDown();
- }
- else
- {
- mPushed = false;
- foldUp();
- hideDrop();
- }
-}
-
-void DropDown::mouseReleased(MouseEvent &event)
-{
- if (mIsDragged)
- mPushed = false;
-
- const MouseButtonT button = event.getButton();
- const int x = event.getX();
- const int y = event.getY();
- // Released outside of widget. Can happen when we have modal
- // input focus.
- if ((0 > y || y >= mDimension.height || x < 0 || x >= mDimension.width)
- && button == MouseButton::LEFT)
- {
- if (mIsDragged)
- foldUp();
- }
- else if (button == MouseButton::LEFT)
- {
- mPushed = false;
- }
-
- mIsDragged = false;
-}
-
-void DropDown::mouseDragged(MouseEvent &event)
-{
- mIsDragged = true;
- event.consume();
-}
-
-void DropDown::mouseWheelMovedUp(MouseEvent& event)
-{
- setSelected(getSelected() - 1);
- event.consume();
-}
-
-void DropDown::mouseWheelMovedDown(MouseEvent& event)
-{
- setSelected(getSelected() + 1);
- event.consume();
-}
-
-void DropDown::setSelectedString(const std::string &str)
-{
- ListModel *const listModel = mPopup->getListModel();
- if (listModel == nullptr)
- return;
-
- for (int f = 0; f < listModel->getNumberOfElements(); f ++)
- {
- if (listModel->getElementAt(f) == str)
- {
- setSelected(f);
- break;
- }
- }
-}
-
-std::string DropDown::getSelectedString() const
-{
- ListModel *const listModel = mPopup->getListModel();
- if (listModel == nullptr)
- return "";
-
- return listModel->getElementAt(getSelected());
-}
-
-void DropDown::adjustHeight()
-{
- setHeight(getFont()->getHeight() + 2 * mPadding);
-}
-
-void DropDown::dropDown()
-{
- if (!mDroppedDown)
- {
- if (mParent == nullptr)
- return;
- mDroppedDown = true;
- mFoldedUpHeight = getHeight();
- adjustHeight();
-
- int x = 0;
- int y = 0;
- getAbsolutePosition(x, y);
- const int frame = CAST_S32(mParent->getFrameSize());
- const int pad = mPopup->getPadding();
- const int pad2 = pad * 2;
-
- // here width should be adjusted on some other parameters
- mPopup->setWidth(mDimension.width - pad2 + 8);
- mPopup->show(x - mPadding - frame - 1, y + mDimension.height);
- mPopup->requestMoveToTop();
- mPopup->requestFocus();
- }
-}
-
-void DropDown::foldUp()
-{
- if (mDroppedDown)
- {
- mDroppedDown = false;
- adjustHeight();
- }
-}
-
-int DropDown::getSelected() const
-{
- return mPopup->getSelected();
-}
-
-void DropDown::setSelected(int selected)
-{
- if (selected >= 0)
- mPopup->setSelected(selected);
-}
-
-void DropDown::setListModel(ListModel *const listModel)
-{
- mPopup->setListModel(listModel);
-
- if (mPopup->getSelected() < 0)
- mPopup->setSelected(0);
-
- adjustHeight();
-}
-
-ListModel *DropDown::getListModel()
-{
- return mPopup->getListModel();
-}
-
-void DropDown::action(const ActionEvent &actionEvent A_UNUSED)
-{
- foldUp();
- distributeActionEvent();
-}
-
-Rect DropDown::getChildrenArea()
-{
- if (mDroppedDown)
- {
- // Calculate the children area (with the one pixel border in mind)
- return Rect(1, mFoldedUpHeight + 1,
- mDimension.width - 2, mDimension.height - mFoldedUpHeight - 2);
- }
-
- return Rect();
-}
-
-void DropDown::valueChanged(const SelectionEvent& event A_UNUSED)
-{
-}
-
-void DropDown::updateSelection()
-{
- mDroppedDown = false;
- mPushed = false;
- distributeActionEvent();
- distributeValueChangedEvent();
-}
-
-void DropDown::addSelectionListener(SelectionListener* selectionListener)
-{
- mSelectionListeners.push_back(selectionListener);
-}
-
-void DropDown::removeSelectionListener(SelectionListener* listener)
-{
- mSelectionListeners.remove(listener);
-}
-
-void DropDown::distributeValueChangedEvent()
-{
- for (SelectionListenerIterator iter = mSelectionListeners.begin();
- iter != mSelectionListeners.end();
- ++iter)
- {
- SelectionEvent event(this);
- (*iter)->valueChanged(event);
- }
-}
diff --git a/src/gui/widgets/dropdown.h b/src/gui/widgets/dropdown.h
deleted file mode 100644
index 029850766..000000000
--- a/src/gui/widgets/dropdown.h
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2006-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_DROPDOWN_H
-#define GUI_WIDGETS_DROPDOWN_H
-
-#include "enums/simpletypes/modal.h"
-
-#include "gui/widgets/basiccontainer.h"
-
-#include "listeners/actionlistener.h"
-#include "listeners/focuslistener.h"
-#include "listeners/keylistener.h"
-#include "listeners/mouselistener.h"
-#include "listeners/selectionlistener.h"
-
-#include "localconsts.h"
-
-class Image;
-class ListModel;
-class PopupList;
-class Skin;
-
-/**
- * A drop down box from which you can select different values.
- *
- * A ListModel provides the contents of the drop down. To be able to use
- * DropDown you must give DropDown an implemented ListModel which represents
- * your list.
- */
-class DropDown final : public ActionListener,
- public BasicContainer,
- public KeyListener,
- public MouseListener,
- public FocusListener,
- public SelectionListener
-{
- public:
- DropDown(const Widget2 *const widget,
- ListModel *const listModel,
- const bool extended = false,
- const Modal modal = Modal_false,
- ActionListener *const listener = nullptr,
- const std::string &eventId = "");
-
- A_DELETE_COPY(DropDown)
-
- ~DropDown();
-
- /**
- * Update the alpha value to the graphic components.
- */
- void updateAlpha();
-
- void draw(Graphics *const graphics) override final A_NONNULL(2);
-
- void safeDraw(Graphics *const graphics) override final A_NONNULL(2);
-
- void drawFrame(Graphics *const graphics) override final A_NONNULL(2);
-
- void safeDrawFrame(Graphics *const graphics) override final
- A_NONNULL(2);
-
- // Inherited from KeyListener
-
- void keyPressed(KeyEvent& event) override final;
-
- // Inherited from MouseListener
-
- void mousePressed(MouseEvent& event) override final;
-
- void mouseReleased(MouseEvent& event) override final;
-
- void mouseDragged(MouseEvent& event) override final;
-
- void mouseWheelMovedUp(MouseEvent& event) override final;
-
- void mouseWheelMovedDown(MouseEvent& event) override final;
-
- void setSelectedString(const std::string &str);
-
- std::string getSelectedString() const A_WARN_UNUSED;
-
- void valueChanged(const SelectionEvent& event) override final A_CONST;
-
- void updateSelection();
-
- void adjustHeight();
-
- void dropDown();
-
- void foldUp();
-
- void hideDrop(bool event = true);
-
- int getSelected() const;
-
- void setSelected(int selected);
-
- void setListModel(ListModel *const listModel);
-
- ListModel *getListModel();
-
- void addSelectionListener(SelectionListener* listener);
-
- void removeSelectionListener(SelectionListener* selectionListener);
-
- Rect getChildrenArea() override;
-
- void action(const ActionEvent &actionEvent) override;
-
- void distributeValueChangedEvent();
-
- protected:
- /**
- * Draws the button with the little down arrow.
- *
- * @param graphics a Graphics object to draw with.
- */
- void drawButton(Graphics *const graphics) A_NONNULL(2);
-
- PopupList *mPopup A_NONNULLPOINTER;
- Color mShadowColor;
- Color mHighlightColor;
- int mPadding;
- int mImagePadding;
- int mSpacing;
- int mFoldedUpHeight;
-
- typedef std::list<SelectionListener*> SelectionListenerList;
- SelectionListenerList mSelectionListeners;
- typedef SelectionListenerList::iterator SelectionListenerIterator;
-
- bool mExtended;
- bool mDroppedDown;
- bool mPushed;
- bool mIsDragged;
-
- // Add own Images.
- static int instances;
- static Image *buttons[2][2];
- static ImageRect skinRect;
- static float mAlpha;
- static Skin *mSkin;
-};
-
-#endif // GUI_WIDGETS_DROPDOWN_H
diff --git a/src/gui/widgets/emotepage.cpp b/src/gui/widgets/emotepage.cpp
deleted file mode 100644
index 27721a86c..000000000
--- a/src/gui/widgets/emotepage.cpp
+++ /dev/null
@@ -1,167 +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 "gui/widgets/emotepage.h"
-
-#include "render/graphics.h"
-
-#include "render/vertexes/imagecollection.h"
-
-#include "resources/imageset.h"
-
-#include "resources/loaders/imagesetloader.h"
-
-#include "utils/delete2.h"
-#include "utils/foreach.h"
-
-#include "debug.h"
-
-namespace
-{
- const unsigned int emoteWidth = 17;
- const unsigned int emoteHeight = 18;
-} // namespace
-
-EmotePage::EmotePage(const Widget2 *const widget) :
- Widget(widget),
- MouseListener(),
- WidgetListener(),
- mEmotes(Loader::getImageSet(
- "graphics/sprites/chatemotes.png", emoteWidth, emoteHeight)),
- mVertexes(new ImageCollection),
- mSelectedIndex(-1)
-{
- addMouseListener(this);
- addWidgetListener(this);
- mAllowLogic = false;
-}
-
-EmotePage::~EmotePage()
-{
- if (mEmotes != nullptr)
- {
- mEmotes->decRef();
- mEmotes = nullptr;
- }
- delete2(mVertexes);
-}
-
-void EmotePage::draw(Graphics *const graphics)
-{
- BLOCK_START("EmotePage::draw")
-
- if (mRedraw)
- {
- if (mEmotes == nullptr)
- return;
-
- const STD_VECTOR<Image*> &images = mEmotes->getImages();
-
- const unsigned int width = mDimension.width;
- unsigned int x = 0;
- unsigned int y = 0;
-
- mRedraw = false;
- mVertexes->clear();
- FOR_EACH (STD_VECTOR<Image*>::const_iterator, it, images)
- {
- const Image *const image = *it;
- if (image != nullptr)
- {
- graphics->calcTileCollection(mVertexes, image, x, y);
- x += emoteWidth;
- if (x + emoteWidth > width)
- {
- x = 0;
- y += emoteHeight;
- }
- }
- }
- graphics->finalize(mVertexes);
- }
- graphics->drawTileCollection(mVertexes);
-
- BLOCK_END("EmotePage::draw")
-}
-
-void EmotePage::safeDraw(Graphics *const graphics)
-{
- BLOCK_START("EmotePage::safeDraw")
-
- if (mEmotes == nullptr)
- return;
-
- const STD_VECTOR<Image*> &images = mEmotes->getImages();
-
- const unsigned int width = mDimension.width;
- unsigned int x = 0;
- unsigned int y = 0;
-
- FOR_EACH (STD_VECTOR<Image*>::const_iterator, it, images)
- {
- const Image *const image = *it;
- if (image != nullptr)
- {
- graphics->drawImage(image, x, y);
- x += emoteWidth;
- if (x + emoteWidth > width)
- {
- x = 0;
- y += emoteHeight;
- }
- }
- }
-
- BLOCK_END("EmotePage::safeDraw")
-}
-
-void EmotePage::mousePressed(MouseEvent &event)
-{
- mSelectedIndex = getIndexFromGrid(event.getX(), event.getY());
- event.consume();
- distributeActionEvent();
-}
-
-int EmotePage::getIndexFromGrid(const int x, const int y) const
-{
- const int width = mDimension.width;
- if (x < 0 || x > width || y < 0 || y > mDimension.height)
- return -1;
- const int cols = width / emoteWidth;
- const int index = (y / emoteHeight) * cols + (x / emoteWidth);
- if (index >= CAST_S32(mEmotes->size()))
- return -1;
- return index;
-}
-
-void EmotePage::resetAction()
-{
- mSelectedIndex = -1;
-}
-
-void EmotePage::widgetResized(const Event &event A_UNUSED)
-{
- mRedraw = true;
-}
-
-void EmotePage::widgetMoved(const Event &event A_UNUSED)
-{
- mRedraw = true;
-}
diff --git a/src/gui/widgets/emotepage.h b/src/gui/widgets/emotepage.h
deleted file mode 100644
index a833e569f..000000000
--- a/src/gui/widgets/emotepage.h
+++ /dev/null
@@ -1,67 +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 GUI_WIDGETS_EMOTEPAGE_H
-#define GUI_WIDGETS_EMOTEPAGE_H
-
-#include "listeners/mouselistener.h"
-#include "listeners/widgetlistener.h"
-
-#include "gui/widgets/widget.h"
-
-#include "localconsts.h"
-
-class ImageCollection;
-
-class EmotePage final : public Widget,
- public MouseListener,
- public WidgetListener
-{
- public:
- explicit EmotePage(const Widget2 *const widget);
-
- A_DELETE_COPY(EmotePage)
-
- ~EmotePage();
-
- void draw(Graphics *const graphics) override final A_NONNULL(2);
-
- void safeDraw(Graphics *const graphics) override final A_NONNULL(2);
-
- void mousePressed(MouseEvent &event) override final;
-
- int getIndexFromGrid(const int x, const int y) const;
-
- void widgetResized(const Event &event A_UNUSED) override final;
-
- void widgetMoved(const Event &event A_UNUSED) override final;
-
- void resetAction();
-
- int getSelectedIndex() const
- { return mSelectedIndex; }
-
- private:
- ImageSet *mEmotes;
- ImageCollection *mVertexes;
- int mSelectedIndex;
-};
-
-#endif // GUI_WIDGETS_EMOTEPAGE_H
diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp
deleted file mode 100644
index 37acf7263..000000000
--- a/src/gui/widgets/emoteshortcutcontainer.cpp
+++ /dev/null
@@ -1,297 +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 "gui/widgets/emoteshortcutcontainer.h"
-
-#include "settings.h"
-
-#include "input/inputmanager.h"
-
-#include "gui/viewport.h"
-
-#include "gui/fonts/font.h"
-
-#include "gui/shortcut/emoteshortcut.h"
-
-#include "gui/popups/popupmenu.h"
-#include "gui/popups/textpopup.h"
-
-#include "input/inputactionoperators.h"
-
-#include "resources/emotesprite.h"
-
-#include "resources/db/emotedb.h"
-
-#include "resources/image/image.h"
-
-#include "resources/sprite/animatedsprite.h"
-
-#include "utils/stringutils.h"
-
-#include "debug.h"
-
-static const int MAX_ITEMS = 48;
-
-EmoteShortcutContainer::EmoteShortcutContainer(Widget2 *restrict const
- widget) :
- ShortcutContainer(widget),
- mEmoteImg(),
- mEmoteClicked(false),
- mEmoteMoved(0)
-{
- if (mBackgroundImg != nullptr)
- mBackgroundImg->setAlpha(settings.guiAlpha);
-
- // Setup emote sprites
- for (int i = 0; i <= EmoteDB::getLast(); i++)
- {
- const EmoteSprite *const sprite = EmoteDB::getSprite(i, true);
- if ((sprite != nullptr) && (sprite->sprite != nullptr))
- mEmoteImg.push_back(sprite);
- }
-
- mMaxItems = MAX_ITEMS;
-}
-
-EmoteShortcutContainer::~EmoteShortcutContainer()
-{
-}
-
-void EmoteShortcutContainer::setWidget2(const Widget2 *restrict const widget)
- restrict2
-{
- Widget2::setWidget2(widget);
- mForegroundColor = getThemeColor(ThemeColorId::TEXT);
- mForegroundColor2 = getThemeColor(ThemeColorId::TEXT_OUTLINE);
-}
-
-void EmoteShortcutContainer::draw(Graphics *restrict graphics) restrict2
-{
- if (emoteShortcut == nullptr)
- return;
-
- BLOCK_START("EmoteShortcutContainer::draw")
- if (settings.guiAlpha != mAlpha)
- {
- if (mBackgroundImg != nullptr)
- mBackgroundImg->setAlpha(mAlpha);
- mAlpha = settings.guiAlpha;
- }
-
- Font *const font = getFont();
- drawBackground(graphics);
-
- unsigned sz = CAST_U32(mEmoteImg.size());
- if (sz > mMaxItems)
- sz = mMaxItems;
- for (unsigned i = 0; i < sz; i++)
- {
- const EmoteSprite *restrict const emoteImg = mEmoteImg[i];
- if (emoteImg != nullptr)
- {
- const AnimatedSprite *restrict const sprite = emoteImg->sprite;
- if (sprite != nullptr)
- {
- sprite->draw(graphics,
- (i % mGridWidth) * mBoxWidth + 2,
- (i / mGridWidth) * mBoxHeight + 10);
- }
- }
- }
- for (unsigned i = 0; i < mMaxItems; i++)
- {
- const int emoteX = (i % mGridWidth) * mBoxWidth;
- const int emoteY = (i / mGridWidth) * mBoxHeight;
-
- // Draw emote keyboard shortcut.
- const std::string key = inputManager.getKeyValueString(
- InputAction::EMOTE_1 + i);
-
- font->drawString(graphics,
- mForegroundColor,
- mForegroundColor2,
- key,
- emoteX + 2, emoteY + 2);
- }
-
- BLOCK_END("EmoteShortcutContainer::draw")
-}
-
-void EmoteShortcutContainer::safeDraw(Graphics *restrict graphics) restrict2
-{
- if (emoteShortcut == nullptr)
- return;
-
- BLOCK_START("EmoteShortcutContainer::draw")
- if (settings.guiAlpha != mAlpha)
- {
- if (mBackgroundImg != nullptr)
- mBackgroundImg->setAlpha(mAlpha);
- mAlpha = settings.guiAlpha;
- }
-
- Font *const font = getFont();
- safeDrawBackground(graphics);
-
- unsigned sz = CAST_U32(mEmoteImg.size());
- if (sz > mMaxItems)
- sz = mMaxItems;
- for (unsigned i = 0; i < sz; i++)
- {
- const EmoteSprite *restrict const emoteImg = mEmoteImg[i];
- if (emoteImg != nullptr)
- {
- const AnimatedSprite *restrict const sprite = emoteImg->sprite;
- if (sprite != nullptr)
- {
- sprite->draw(graphics,
- (i % mGridWidth) * mBoxWidth + 2,
- (i / mGridWidth) * mBoxHeight + 10);
- }
- }
- }
- for (unsigned i = 0; i < mMaxItems; i++)
- {
- const int emoteX = (i % mGridWidth) * mBoxWidth;
- const int emoteY = (i / mGridWidth) * mBoxHeight;
-
- // Draw emote keyboard shortcut.
- const std::string key = inputManager.getKeyValueString(
- InputAction::EMOTE_1 + i);
-
- font->drawString(graphics,
- mForegroundColor,
- mForegroundColor2,
- key,
- emoteX + 2, emoteY + 2);
- }
-
- BLOCK_END("EmoteShortcutContainer::draw")
-}
-
-void EmoteShortcutContainer::mouseDragged(MouseEvent &restrict event A_UNUSED)
- restrict2
-{
-}
-
-void EmoteShortcutContainer::mousePressed(MouseEvent &restrict event) restrict2
-{
- if (event.isConsumed())
- return;
-
- if (event.getButton() == MouseButton::LEFT)
- {
- if (emoteShortcut == nullptr)
- return;
-
- const int index = getIndexFromGrid(event.getX(), event.getY());
-
- if (index == -1)
- return;
-
- event.consume();
- // Stores the selected emote if there is one.
- if (emoteShortcut->isEmoteSelected())
- {
- emoteShortcut->setEmote(index);
- emoteShortcut->setEmoteSelected(0);
- }
- else if (emoteShortcut->getEmote(index) != 0u)
- {
- mEmoteClicked = true;
- }
- }
- else if (event.getButton() == MouseButton::RIGHT)
- {
- if (popupMenu != nullptr)
- {
- event.consume();
- popupMenu->showEmoteType();
- }
- }
-}
-
-void EmoteShortcutContainer::mouseReleased(MouseEvent &restrict event)
- restrict2
-{
- if (emoteShortcut == nullptr)
- return;
-
- if (event.getButton() == MouseButton::LEFT)
- {
- const int index = getIndexFromGrid(event.getX(), event.getY());
-
- if (emoteShortcut->isEmoteSelected())
- emoteShortcut->setEmoteSelected(0);
-
- if (index == -1)
- {
- mEmoteMoved = 0;
- return;
- }
-
- if (mEmoteMoved != 0u)
- {
- emoteShortcut->setEmotes(index, mEmoteMoved);
- mEmoteMoved = 0;
- }
- else if ((emoteShortcut->getEmote(index) != 0u) && mEmoteClicked)
- {
- emoteShortcut->useEmote(index + 1);
- }
-
- mEmoteClicked = false;
- }
-}
-
-void EmoteShortcutContainer::mouseMoved(MouseEvent &restrict event) restrict2
-{
- if ((emoteShortcut == nullptr) || (textPopup == nullptr))
- return;
-
- const int index = getIndexFromGrid(event.getX(), event.getY());
-
- if (index == -1)
- return;
-
- textPopup->setVisible(Visible_false);
-
- if (CAST_SIZE(index) < mEmoteImg.size() && (mEmoteImg[index] != nullptr))
- {
- const EmoteSprite *restrict const sprite = mEmoteImg[index];
- textPopup->show(viewport->mMouseX, viewport->mMouseY,
- strprintf("%s, %d", sprite->name.c_str(), sprite->id));
- }
-}
-
-void EmoteShortcutContainer::mouseExited(MouseEvent &restrict event A_UNUSED)
- restrict2
-{
- if (textPopup != nullptr)
- textPopup->setVisible(Visible_false);
-}
-
-void EmoteShortcutContainer::widgetHidden(const Event &restrict event A_UNUSED)
- restrict2
-{
- if (textPopup != nullptr)
- textPopup->setVisible(Visible_false);
-}
diff --git a/src/gui/widgets/emoteshortcutcontainer.h b/src/gui/widgets/emoteshortcutcontainer.h
deleted file mode 100644
index 14895d7a0..000000000
--- a/src/gui/widgets/emoteshortcutcontainer.h
+++ /dev/null
@@ -1,92 +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 GUI_WIDGETS_EMOTESHORTCUTCONTAINER_H
-#define GUI_WIDGETS_EMOTESHORTCUTCONTAINER_H
-
-#include "gui/widgets/shortcutcontainer.h"
-
-struct EmoteSprite;
-
-/**
- * An emote shortcut container. Used to quickly use emoticons.
- *
- * \ingroup GUI
- */
-class EmoteShortcutContainer final : public ShortcutContainer
-{
- public:
- /**
- * Constructor. Initializes the graphic.
- */
- explicit EmoteShortcutContainer(Widget2 *restrict const widget);
-
- A_DELETE_COPY(EmoteShortcutContainer)
-
- /**
- * Destructor.
- */
- ~EmoteShortcutContainer();
-
- /**
- * Draws the items.
- */
- void draw(Graphics *restrict graphics)
- restrict2 override final A_NONNULL(2);
-
- void safeDraw(Graphics *restrict graphics)
- restrict2 override final A_NONNULL(2);
-
- /**
- * Handles mouse when dragged.
- */
- void mouseDragged(MouseEvent &restrict event)
- restrict2 override final A_CONST;
-
- /**
- * Handles mouse when pressed.
- */
- void mousePressed(MouseEvent &restrict event) restrict2 override final;
-
- /**
- * Handles mouse release.
- */
- void mouseReleased(MouseEvent &restrict event)
- restrict2 override final;
-
- void mouseMoved(MouseEvent &restrict event) restrict2 override final;
-
- void mouseExited(MouseEvent &restrict event) restrict2 override final;
-
- void widgetHidden(const Event &restrict event)
- restrict2 override final;
-
- void setWidget2(const Widget2 *restrict const widget)
- restrict2 override final;
-
- private:
- STD_VECTOR<const EmoteSprite*> mEmoteImg;
-
- bool mEmoteClicked;
- unsigned char mEmoteMoved;
-};
-
-#endif // GUI_WIDGETS_EMOTESHORTCUTCONTAINER_H
diff --git a/src/gui/widgets/equipmentbox.h b/src/gui/widgets/equipmentbox.h
deleted file mode 100644
index 055332b2b..000000000
--- a/src/gui/widgets/equipmentbox.h
+++ /dev/null
@@ -1,41 +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 GUI_WIDGETS_EQUIPMENTBOX_H
-#define GUI_WIDGETS_EQUIPMENTBOX_H
-
-#include "localconsts.h"
-
-class Image;
-
-struct EquipmentBox final
-{
- EquipmentBox(const int x0, const int y0, Image *const img) :
- x(x0), y(y0), image(img)
- { }
-
- A_DELETE_COPY(EquipmentBox)
-
- int x;
- int y;
- Image *image;
-};
-
-#endif // GUI_WIDGETS_EQUIPMENTBOX_H
diff --git a/src/gui/widgets/equipmentpage.h b/src/gui/widgets/equipmentpage.h
deleted file mode 100644
index f868478fb..000000000
--- a/src/gui/widgets/equipmentpage.h
+++ /dev/null
@@ -1,53 +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 GUI_WIDGETS_EQUIPMENTPAGE_H
-#define GUI_WIDGETS_EQUIPMENTPAGE_H
-
-#include "utils/vector.h"
-
-#include "localconsts.h"
-
-class PlayerBox;
-
-struct EquipmentBox;
-
-struct EquipmentPage final
-{
- EquipmentPage() :
- boxes(),
- x(0),
- y(0),
- width(0),
- height(0),
- showPlayerBox(true)
- { }
-
- A_DELETE_COPY(EquipmentPage)
-
- STD_VECTOR<EquipmentBox*> boxes;
- int x;
- int y;
- int width;
- int height;
- bool showPlayerBox;
-};
-
-#endif // GUI_WIDGETS_EQUIPMENTPAGE_H
diff --git a/src/gui/widgets/extendedlistbox.cpp b/src/gui/widgets/extendedlistbox.cpp
deleted file mode 100644
index 271160726..000000000
--- a/src/gui/widgets/extendedlistbox.cpp
+++ /dev/null
@@ -1,257 +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 "gui/widgets/extendedlistbox.h"
-
-#include "gui/models/extendedlistmodel.h"
-
-#include "gui/skin.h"
-
-#include "gui/fonts/font.h"
-
-#include "render/graphics.h"
-
-#include "debug.h"
-
-ExtendedListBox::ExtendedListBox(const Widget2 *const widget,
- ListModel *const listModel,
- const std::string &skin,
- const unsigned int rowHeight) :
- ListBox(widget, listModel, skin),
- mImagePadding(mSkin != nullptr ? mSkin->getOption("imagePadding") : 0),
- mSpacing(mSkin != nullptr ? mSkin->getOption("spacing") : 0),
- mHeight(0),
- mListItems(),
- mSelectedItems()
-{
- if (rowHeight != 0u)
- mRowHeight = rowHeight;
-}
-
-ExtendedListBox::~ExtendedListBox()
-{
-}
-
-void ExtendedListBox::draw(Graphics *const graphics)
-{
- if (mListModel == nullptr)
- return;
-
- BLOCK_START("ExtendedListBox::draw")
- ExtendedListModel *const model = static_cast<ExtendedListModel *>(
- mListModel);
-
- updateAlpha();
- Font *const font = getFont();
-
- const int height = CAST_S32(mRowHeight);
- const int pad2 = 2 + mPadding;
- const int width = mDimension.width;
- int textPos = (height - font->getHeight()) / 2 + mPadding;
- if (textPos < 0)
- textPos = 0;
-
- const int sz = mListModel->getNumberOfElements();
- mListItems.clear();
- mSelectedItems.clear();
- int y = 0;
- const int insideWidth = width - pad2;
- for (int f = 0; f < sz; f ++)
- {
- int row = f;
- bool useImage = true;
- std::string str = mListModel->getElementAt(f);
- int strWidth = font->getWidth(str) + 8;
-
- const Image *const image = model->getImageAt(row);
- if (image != nullptr)
- strWidth += image->getWidth() + mImagePadding;
-
- STD_VECTOR<ExtendedListBoxItem> &list =
- row == mSelected ? mSelectedItems : mListItems;
-
- if (insideWidth < strWidth)
- {
- const size_t strSize = str.size();
- size_t divPos = strSize / 2;
- if (divPos > 0 && CAST_U8(
- str[divPos - 1]) >= 0xc0)
- {
- divPos --;
- }
- for (size_t d = divPos; d > 10; d --)
- {
- if (str[d] == 32)
- {
- divPos = d + 1;
- break;
- }
- }
- list.push_back(ExtendedListBoxItem(row,
- str.substr(0, divPos), useImage, y));
- str = str.substr(divPos);
- y += height;
- useImage = false;
- }
- list.push_back(ExtendedListBoxItem(row, str, useImage, y));
-
- y += height;
- }
- mHeight = y + height;
-
- const size_t itemsSz = mListItems.size();
- const size_t selSz = mSelectedItems.size();
- int minY = -1;
- int maxY = -1;
- for (size_t f = 0; f < selSz; f ++)
- {
- const ExtendedListBoxItem &item = mSelectedItems[f];
- const int y1 = item.y;
- if (minY == -1)
- minY = y1;
- if (maxY < y1)
- maxY = y1;
- }
-
- if (minY != -1)
- {
- mHighlightColor.a = CAST_U32(mAlpha * 255.0F);
- graphics->setColor(mHighlightColor);
- graphics->fillRectangle(Rect(mPadding, minY + mPadding,
- width - pad2, maxY - minY + height));
- }
-
- for (size_t f = 0; f < itemsSz; ++f)
- {
- const ExtendedListBoxItem &item = mListItems[f];
- const int row1 = item.row;
- if (item.image)
- {
- const Image *const image = model->getImageAt(row1);
- if (image != nullptr)
- {
- graphics->drawImage(image,
- mImagePadding,
- item.y + (height - image->getHeight()) / 2 + mPadding);
- }
- }
- }
-
- for (size_t f = 0; f < itemsSz; ++f)
- {
- const ExtendedListBoxItem &item = mListItems[f];
- const int row1 = item.row;
- const int y1 = item.y;
- const Image *const image = model->getImageAt(row1);
- if ((image == nullptr) || !item.image)
- {
- font->drawString(graphics,
- mForegroundColor, mForegroundColor2,
- item.text,
- mPadding, y1 + textPos);
- }
- else
- {
- font->drawString(graphics,
- mForegroundColor, mForegroundColor2,
- item.text,
- image->getWidth() + mImagePadding + mSpacing, y1 + textPos);
- }
- }
-
- for (size_t f = 0; f < selSz; ++f)
- {
- const ExtendedListBoxItem &item = mSelectedItems[f];
- const int row1 = item.row;
- const int y1 = item.y;
- const Image *const image = model->getImageAt(row1);
- if ((image == nullptr) || !item.image)
- {
- font->drawString(graphics,
- mForegroundSelectedColor, mForegroundSelectedColor2,
- item.text,
- mPadding, y1 + textPos);
- }
- else
- {
- font->drawString(graphics,
- mForegroundSelectedColor, mForegroundSelectedColor2,
- item.text,
- image->getWidth() + mImagePadding + mSpacing, y1 + textPos);
- }
- }
-
- for (size_t f = 0; f < selSz; ++f)
- {
- const ExtendedListBoxItem &item = mSelectedItems[f];
- const int row1 = item.row;
- if (item.image)
- {
- const Image *const image = model->getImageAt(row1);
- if (image != nullptr)
- {
- graphics->drawImage(image,
- mImagePadding,
- item.y + (height - image->getHeight()) / 2 + mPadding);
- }
- }
- }
-
- BLOCK_END("ExtendedListBox::draw")
-}
-
-void ExtendedListBox::safeDraw(Graphics *const graphics)
-{
- ExtendedListBox::draw(graphics);
-}
-
-void ExtendedListBox::adjustSize()
-{
- if (mHeight != 0)
- setHeight(mHeight + 2 * mPadding);
- else
- ListBox::adjustSize();
-}
-
-int ExtendedListBox::getSelectionByMouse(const int y) const
-{
- if (mListItems.empty() && mSelectedItems.empty())
- return ListBox::getSelectionByMouse(y);
-
- const int height = CAST_S32(mRowHeight);
- const size_t itemsSz = mListItems.size();
- for (size_t f = 0; f < itemsSz; f ++)
- {
- const ExtendedListBoxItem &item = mListItems[f];
- const int y2 = item.y + mPadding;
- if (y2 <= y && y2 + height > y)
- return item.row;
- }
-
- const size_t selSz = mSelectedItems.size();
- for (size_t f = 0; f < selSz; f ++)
- {
- const ExtendedListBoxItem &item = mSelectedItems[f];
- const int y2 = item.y + mPadding;
- if (y2 <= y && y2 + height > y)
- return item.row;
- }
- return 0;
-}
diff --git a/src/gui/widgets/extendedlistbox.h b/src/gui/widgets/extendedlistbox.h
deleted file mode 100644
index 6d97ee6d3..000000000
--- a/src/gui/widgets/extendedlistbox.h
+++ /dev/null
@@ -1,61 +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 GUI_WIDGETS_EXTENDEDLISTBOX_H
-#define GUI_WIDGETS_EXTENDEDLISTBOX_H
-
-#include "gui/widgets/extendedlistboxitem.h"
-#include "gui/widgets/listbox.h"
-
-class ExtendedListBox final : public ListBox
-{
- public:
- /**
- * Constructor.
- */
- ExtendedListBox(const Widget2 *const widget,
- ListModel *const listModel,
- const std::string &skin,
- const unsigned int rowHeight = 13);
-
- A_DELETE_COPY(ExtendedListBox)
-
- ~ExtendedListBox();
-
- /**
- * Draws the list box.
- */
- void draw(Graphics *const graphics) override final A_NONNULL(2);
-
- void safeDraw(Graphics *const graphics) override final A_NONNULL(2);
-
- void adjustSize() override;
-
- int getSelectionByMouse(const int y) const override final;
-
- protected:
- int mImagePadding;
- int mSpacing;
- int mHeight;
- STD_VECTOR<ExtendedListBoxItem> mListItems;
- STD_VECTOR<ExtendedListBoxItem> mSelectedItems;
-};
-
-#endif // GUI_WIDGETS_EXTENDEDLISTBOX_H
diff --git a/src/gui/widgets/extendedlistboxitem.h b/src/gui/widgets/extendedlistboxitem.h
deleted file mode 100644
index dc2d8b459..000000000
--- a/src/gui/widgets/extendedlistboxitem.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 GUI_WIDGETS_EXTENDEDLISTBOXITEM_H
-#define GUI_WIDGETS_EXTENDEDLISTBOXITEM_H
-
-#include <string>
-
-#include "localconsts.h"
-
-struct ExtendedListBoxItem final
-{
- ExtendedListBoxItem(const int row0,
- const std::string &text0,
- const bool image0,
- const int y0) :
- row(row0),
- text(text0),
- image(image0),
- y(y0)
- {
- }
-
- A_DEFAULT_COPY(ExtendedListBoxItem)
-
- int row;
- std::string text;
- bool image;
- int y;
-};
-
-#endif // GUI_WIDGETS_EXTENDEDLISTBOXITEM_H
diff --git a/src/gui/widgets/flowcontainer.cpp b/src/gui/widgets/flowcontainer.cpp
deleted file mode 100644
index ee3181636..000000000
--- a/src/gui/widgets/flowcontainer.cpp
+++ /dev/null
@@ -1,97 +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 "gui/widgets/flowcontainer.h"
-
-#include "debug.h"
-
-FlowContainer::FlowContainer(const Widget2 *const widget,
- const int boxWidth,
- const int boxHeight) :
- Container(widget),
- WidgetListener(),
- mBoxWidth(boxWidth),
- mBoxHeight(boxHeight),
- mGridWidth(1),
- mGridHeight(1)
-{
- addWidgetListener(this);
- if (mBoxWidth == 0)
- mBoxWidth = 1;
- if (mBoxHeight == 0)
- mBoxHeight = 1;
-}
-
-void FlowContainer::widgetResized(const Event &event A_UNUSED)
-{
- if (getWidth() < mBoxWidth)
- {
- setWidth(mBoxWidth);
- return;
- }
-
- const int itemCount = CAST_S32(mWidgets.size());
-
- if (mBoxWidth == 0)
- mGridWidth = getWidth();
- else
- mGridWidth = getWidth() / mBoxWidth;
-
- if (mGridWidth < 1)
- mGridWidth = 1;
-
- mGridHeight = itemCount / mGridWidth;
-
- if (itemCount % mGridWidth != 0 || mGridHeight < 1)
- ++mGridHeight;
-
- int height = mGridHeight * mBoxHeight;
-
- if (getHeight() != height)
- {
- setHeight(height);
- return;
- }
-
- int i = 0;
- height = 0;
- for (WidgetList::const_iterator it = mWidgets.begin();
- it != mWidgets.end(); ++it)
- {
- const int x = i % mGridWidth * mBoxWidth;
- (*it)->setPosition(x, height);
-
- i++;
-
- if (i % mGridWidth == 0)
- height += mBoxHeight;
- }
-}
-
-void FlowContainer::add(Widget *const widget)
-{
- if (widget == nullptr)
- return;
-
- Container::add(widget);
- widget->setSize(mBoxWidth, mBoxHeight);
- widgetResized(Event(nullptr));
-}
diff --git a/src/gui/widgets/flowcontainer.h b/src/gui/widgets/flowcontainer.h
deleted file mode 100644
index be91853a6..000000000
--- a/src/gui/widgets/flowcontainer.h
+++ /dev/null
@@ -1,75 +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 GUI_WIDGETS_FLOWCONTAINER_H
-#define GUI_WIDGETS_FLOWCONTAINER_H
-
-#include "gui/widgets/container.h"
-
-#include "listeners/widgetlistener.h"
-
-#include "localconsts.h"
-
-/**
- * A container that arranges its contents like words on a page.
- *
- * \ingroup GUI
- */
-class FlowContainer final : public Container,
- public WidgetListener
-{
- public:
- /**
- * Constructor. Initializes the shortcut container.
- */
- FlowContainer(const Widget2 *const widget,
- const int boxWidth,
- const int boxHeight);
-
- A_DELETE_COPY(FlowContainer)
-
- /**
- * Destructor.
- */
- ~FlowContainer()
- { }
-
- /**
- * Invoked when a widget changes its size. This is used to determine
- * the new height of the container.
- */
- void widgetResized(const Event &event) override final;
-
- int getBoxWidth() const noexcept2 A_WARN_UNUSED
- { return mBoxWidth; }
-
- int getBoxHeight() const noexcept2 A_WARN_UNUSED
- { return mBoxHeight; }
-
- void add(Widget *const widget) override final;
-
- private:
- int mBoxWidth;
- int mBoxHeight;
- int mGridWidth, mGridHeight;
-};
-
-#endif // GUI_WIDGETS_FLOWCONTAINER_H
diff --git a/src/gui/widgets/guitable.cpp b/src/gui/widgets/guitable.cpp
deleted file mode 100644
index 4a0f88246..000000000
--- a/src/gui/widgets/guitable.cpp
+++ /dev/null
@@ -1,675 +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 "gui/widgets/guitable.h"
-
-#include "settings.h"
-
-#include "gui/gui.h"
-
-#include "gui/models/tablemodel.h"
-
-#include "listeners/guitableactionlistener.h"
-
-#include "render/graphics.h"
-
-#include "utils/delete2.h"
-#include "utils/dtor.h"
-
-#include "debug.h"
-
-float GuiTable::mAlpha = 1.0;
-
-GuiTable::GuiTable(const Widget2 *const widget,
- TableModel *const initial_model,
- const Opaque opacity) :
- Widget(widget),
- MouseListener(),
- KeyListener(),
- TableModelListener(),
- mModel(nullptr),
- mTopWidget(nullptr),
- mActionListeners2(),
- mHighlightColor(getThemeColor(ThemeColorId::HIGHLIGHT)),
- mSelectedRow(-1),
- mSelectedColumn(-1),
- mLinewiseMode(false),
- mWrappingEnabled(false),
- mOpaque(opacity),
- mSelectableGui(true)
-{
- mAllowLogic = false;
- mBackgroundColor = getThemeColor(ThemeColorId::BACKGROUND);
-
- setModel(initial_model);
- setFocusable(true);
-
- addMouseListener(this);
- addKeyListener(this);
-}
-
-GuiTable::~GuiTable()
-{
- if (gui != nullptr)
- gui->removeDragged(this);
-
- uninstallActionListeners();
- delete2(mModel);
-}
-
-const TableModel *GuiTable::getModel() const
-{
- return mModel;
-}
-
-void GuiTable::setModel(TableModel *const new_model)
-{
- if (mModel != nullptr)
- {
- uninstallActionListeners();
- mModel->removeListener(this);
- }
-
- mModel = new_model;
- installActionListeners();
-
- new_model->installListener(this);
- recomputeDimensions();
-}
-
-void GuiTable::recomputeDimensions()
-{
- if (mModel == nullptr)
- return;
-
- const int rows_nr = mModel->getRows();
- const int columns_nr = mModel->getColumns();
- int width = 0;
-
- if (mSelectableGui)
- {
- if (mSelectedRow >= rows_nr)
- mSelectedRow = rows_nr - 1;
-
- if (mSelectedColumn >= columns_nr)
- mSelectedColumn = columns_nr - 1;
- }
-
- for (int i = 0; i < columns_nr; i++)
- width += getColumnWidth(i);
-
- setWidth(width);
- setHeight(getRowHeight() * rows_nr);
-}
-
-void GuiTable::setSelected(const int row, const int column)
-{
- mSelectedColumn = column;
- mSelectedRow = row;
-}
-
-int GuiTable::getSelectedRow() const
-{
- return mSelectedRow;
-}
-
-int GuiTable::getSelectedColumn() const
-{
- return mSelectedColumn;
-}
-
-int GuiTable::getRowHeight() const
-{
- return mModel->getRowHeight() + 4; // border
-}
-
-int GuiTable::getColumnWidth(const int i) const
-{
- return mModel->getColumnWidth(i) + 4; // border
-}
-
-void GuiTable::setSelectedRow(const int selected)
-{
- if (!mSelectableGui)
- {
- mSelectedRow = -1;
- }
- else
- {
- const int rows = mModel->getRows();
- if (selected < 0 && !mWrappingEnabled)
- {
- mSelectedRow = -1;
- }
- else if (selected >= rows && mWrappingEnabled)
- {
- mSelectedRow = 0;
- }
- else if ((selected >= rows && !mWrappingEnabled) ||
- (selected < 0 && mWrappingEnabled))
- {
- mSelectedRow = rows - 1;
- }
- else
- {
- mSelectedRow = selected;
- }
- }
-}
-
-void GuiTable::setSelectedColumn(const int selected)
-{
- const int columns = mModel->getColumns();
- if ((selected >= columns && mWrappingEnabled) ||
- (selected < 0 && !mWrappingEnabled))
- {
- mSelectedColumn = 0;
- }
- else if ((selected >= columns && !mWrappingEnabled) ||
- (selected < 0 && mWrappingEnabled))
- {
- mSelectedColumn = columns - 1;
- }
- else
- {
- mSelectedColumn = selected;
- }
-}
-
-void GuiTable::uninstallActionListeners()
-{
- delete_all(mActionListeners2);
- mActionListeners2.clear();
-}
-
-void GuiTable::installActionListeners()
-{
- const int rows = mModel->getRows();
- const int columns = mModel->getColumns();
-
- for (int row = 0; row < rows; ++row)
- {
- for (int column = 0; column < columns; ++column)
- {
- Widget *const widget = mModel->getElementAt(row, column);
- if (widget != nullptr)
- {
- mActionListeners2.push_back(new GuiTableActionListener(
- this, widget, row, column));
- }
- }
- }
-
- setFocusHandler(getFocusHandler());
-}
-
-// -- widget ops
-void GuiTable::draw(Graphics *const graphics)
-{
- if (getRowHeight() == 0)
- return;
-
- BLOCK_START("GuiTable::draw")
- if (settings.guiAlpha != mAlpha)
- mAlpha = settings.guiAlpha;
-
- const Rect &rect = mDimension;
- const int width = rect.width;
- const int height = rect.height;
- const int y = rect.y;
- if (mOpaque == Opaque_true)
- {
- mBackgroundColor.a = CAST_U32(mAlpha * 255.0F);
- graphics->setColor(mBackgroundColor);
- graphics->fillRectangle(Rect(0, 0, width, height));
- }
-
- // First, determine how many rows we need to draw,
- // and where we should start.
- int rHeight = getRowHeight();
- if (rHeight == 0)
- rHeight = 1;
- int first_row = -(y / rHeight);
-
- if (first_row < 0)
- first_row = 0;
-
- unsigned int rows_nr = CAST_U32(1 +
- height / rHeight); // May overestimate by one.
- unsigned int max_rows_nr;
- if (mModel->getRows() < first_row)
- {
- max_rows_nr = 0U;
- }
- else
- {
- max_rows_nr = CAST_U32(
- mModel->getRows() - first_row); // clip if neccessary:
- }
- if (max_rows_nr < rows_nr)
- rows_nr = max_rows_nr;
-
- // Now determine the first and last column
- // Take the easy way out; these are usually bounded and all visible.
- const unsigned first_column = 0;
- const unsigned last_column1 = CAST_U32(
- mModel->getColumns());
-
- int y_offset = first_row * rHeight;
-
- for (unsigned int r = CAST_U32(first_row);
- r < CAST_U32(first_row) + rows_nr;
- ++r)
- {
- int x_offset = 0;
-
- for (unsigned c = first_column; c + 1 <= last_column1; ++c)
- {
- Widget *const widget = mModel->getElementAt(CAST_S32(r),
- CAST_S32(c));
- const int cWidth = CAST_S32(getColumnWidth(
- CAST_S32(c)));
- if (widget != nullptr)
- {
- Rect bounds(x_offset, y_offset, cWidth, rHeight);
-
- if (widget == mTopWidget)
- {
- bounds.height = widget->getHeight();
- bounds.width = widget->getWidth();
- }
-
- widget->setDimension(bounds);
-
- if (mSelectedRow > -1)
- {
- mHighlightColor.a = CAST_U32(
- mAlpha * 255.0F);
- graphics->setColor(mHighlightColor);
-
- if (mLinewiseMode && r == CAST_U32(
- mSelectedRow) && c == 0)
- {
- graphics->fillRectangle(Rect(0, y_offset,
- width, rHeight));
- }
- else if (!mLinewiseMode && mSelectedColumn > 0
- && c == CAST_U32(mSelectedColumn)
- && r == CAST_U32(mSelectedRow))
- {
- graphics->fillRectangle(Rect(
- x_offset, y_offset, cWidth, rHeight));
- }
- }
- graphics->pushClipArea(bounds);
- widget->draw(graphics);
- graphics->popClipArea();
- }
-
- x_offset += cWidth;
- }
-
- y_offset += rHeight;
- }
-
- if (mTopWidget != nullptr)
- {
- const Rect &bounds = mTopWidget->getDimension();
- graphics->pushClipArea(bounds);
- mTopWidget->draw(graphics);
- graphics->popClipArea();
- }
- BLOCK_END("GuiTable::draw")
-}
-
-void GuiTable::safeDraw(Graphics *const graphics)
-{
- if (getRowHeight() == 0)
- return;
-
- BLOCK_START("GuiTable::draw")
- if (settings.guiAlpha != mAlpha)
- mAlpha = settings.guiAlpha;
-
- const Rect &rect = mDimension;
- const int width = rect.width;
- const int height = rect.height;
- const int y = rect.y;
- if (mOpaque == Opaque_true)
- {
- mBackgroundColor.a = CAST_U32(mAlpha * 255.0F);
- graphics->setColor(mBackgroundColor);
- graphics->fillRectangle(Rect(0, 0, width, height));
- }
-
- // First, determine how many rows we need to draw,
- // and where we should start.
- int rHeight = getRowHeight();
- if (rHeight == 0)
- rHeight = 1;
- int first_row = -(y / rHeight);
-
- if (first_row < 0)
- first_row = 0;
-
- unsigned int rows_nr = CAST_U32(
- 1 + height / rHeight); // May overestimate by one.
- unsigned int max_rows_nr;
- if (mModel->getRows() < first_row)
- {
- max_rows_nr = 0;
- }
- else
- {
- max_rows_nr = CAST_U32(
- mModel->getRows() - first_row); // clip if neccessary:
- }
- if (max_rows_nr < rows_nr)
- rows_nr = max_rows_nr;
-
- // Now determine the first and last column
- // Take the easy way out; these are usually bounded and all visible.
- const unsigned int first_column = 0;
- const unsigned int last_column1 = CAST_U32(
- mModel->getColumns());
-
- int y_offset = first_row * rHeight;
-
- for (unsigned int r = CAST_U32(first_row);
- r < CAST_U32(first_row + CAST_S32(rows_nr));
- ++r)
- {
- int x_offset = 0;
-
- for (unsigned c = first_column; c + 1 <= last_column1; ++c)
- {
- Widget *const widget = mModel->getElementAt(CAST_S32(r),
- CAST_S32(c));
- const int cWidth = CAST_S32(getColumnWidth(
- CAST_S32(c)));
- if (widget != nullptr)
- {
- Rect bounds(x_offset, y_offset, cWidth, rHeight);
-
- if (widget == mTopWidget)
- {
- bounds.height = widget->getHeight();
- bounds.width = widget->getWidth();
- }
-
- widget->setDimension(bounds);
-
- if (mSelectedRow > -1)
- {
- mHighlightColor.a = CAST_U32(
- mAlpha * 255.0F);
- graphics->setColor(mHighlightColor);
-
- if (mLinewiseMode && r == CAST_U32(
- mSelectedRow) && c == 0)
- {
- graphics->fillRectangle(Rect(0, y_offset,
- width, rHeight));
- }
- else if (!mLinewiseMode && mSelectedColumn > 0
- && c == CAST_U32(mSelectedColumn)
- && r == CAST_U32(mSelectedRow))
- {
- graphics->fillRectangle(Rect(
- x_offset, y_offset, cWidth, rHeight));
- }
- }
- graphics->pushClipArea(bounds);
- widget->safeDraw(graphics);
- graphics->popClipArea();
- }
-
- x_offset += cWidth;
- }
-
- y_offset += rHeight;
- }
-
- if (mTopWidget != nullptr)
- {
- const Rect &bounds = mTopWidget->getDimension();
- graphics->pushClipArea(bounds);
- mTopWidget->safeDraw(graphics);
- graphics->popClipArea();
- }
- BLOCK_END("GuiTable::draw")
-}
-
-void GuiTable::moveToTop(Widget *const widget)
-{
- Widget::moveToTop(widget);
- mTopWidget = widget;
-}
-
-void GuiTable::moveToBottom(Widget *const widget)
-{
- Widget::moveToBottom(widget);
- if (widget == mTopWidget)
- mTopWidget = nullptr;
-}
-
-Rect GuiTable::getChildrenArea()
-{
- return Rect(0, 0, mDimension.width, mDimension.height);
-}
-
-// -- KeyListener notifications
-void GuiTable::keyPressed(KeyEvent& event)
-{
- const InputActionT action = event.getActionId();
-
- if (action == InputAction::GUI_SELECT)
- {
- distributeActionEvent();
- event.consume();
- }
- else if (action == InputAction::GUI_UP)
- {
- setSelectedRow(mSelectedRow - 1);
- event.consume();
- }
- else if (action == InputAction::GUI_DOWN)
- {
- setSelectedRow(mSelectedRow + 1);
- event.consume();
- }
- else if (action == InputAction::GUI_LEFT)
- {
- setSelectedColumn(mSelectedColumn - 1);
- event.consume();
- }
- else if (action == InputAction::GUI_RIGHT)
- {
- setSelectedColumn(mSelectedColumn + 1);
- event.consume();
- }
- else if (action == InputAction::GUI_HOME)
- {
- setSelectedRow(0);
- setSelectedColumn(0);
- event.consume();
- }
- else if (action == InputAction::GUI_END && (mModel != nullptr))
- {
- setSelectedRow(mModel->getRows() - 1);
- setSelectedColumn(mModel->getColumns() - 1);
- event.consume();
- }
-}
-
-// -- MouseListener notifications
-void GuiTable::mousePressed(MouseEvent& event)
-{
- if (!mSelectableGui)
- return;
-
- if (event.getButton() == MouseButton::LEFT)
- {
- const int row = getRowForY(event.getY());
- const int column = getColumnForX(event.getX());
-
- if (row > -1 && column > -1 &&
- row < mModel->getRows() && column < mModel->getColumns())
- {
- mSelectedColumn = column;
- mSelectedRow = row;
- event.consume();
- }
-
- distributeActionEvent();
- }
-}
-
-void GuiTable::mouseWheelMovedUp(MouseEvent& event)
-{
- if (isFocused())
- {
- const int selRow = getSelectedRow();
- if (selRow > 0 || (selRow == 0 && mWrappingEnabled))
- setSelectedRow(selRow - 1);
- event.consume();
- }
-}
-
-void GuiTable::mouseWheelMovedDown(MouseEvent& event)
-{
- if (isFocused())
- {
- setSelectedRow(getSelectedRow() + 1);
- event.consume();
- }
-}
-
-void GuiTable::mouseDragged(MouseEvent& event)
-{
- if (event.getButton() != MouseButton::LEFT)
- return;
-
- // Make table selection update on drag
- const int x = std::max(0, event.getX());
- const int y = std::max(0, event.getY());
-
- setSelectedRow(getRowForY(y));
- setSelectedColumn(getColumnForX(x));
-}
-
-void GuiTable::modelUpdated(const bool completed)
-{
- if (completed)
- {
- recomputeDimensions();
- installActionListeners();
- }
- else
- { // before the update?
- mTopWidget = nullptr; // No longer valid in general
- uninstallActionListeners();
- }
-}
-
-Widget *GuiTable::getWidgetAt(int x, int y)
-{
- if (mModel == nullptr)
- return nullptr;
-
- const int row = getRowForY(y);
- const int column = getColumnForX(x);
-
- if (mTopWidget != nullptr &&
- mTopWidget->getDimension().isPointInRect(x, y))
- {
- return mTopWidget;
- }
-
- if (row > -1 && column > -1)
- {
- Widget *const w = mModel->getElementAt(row, column);
- if (w != nullptr && w->isFocusable())
- return w;
- }
- return nullptr;
-}
-
-int GuiTable::getRowForY(const int y) const
-{
- int row = -1;
-
- const int rowHeight = getRowHeight();
- if (rowHeight > 0)
- row = y / rowHeight;
-
- if (row < 0 || row >= mModel->getRows())
- return -1;
- return row;
-}
-
-int GuiTable::getColumnForX(const int x) const
-{
- int column;
- int delta = 0;
-
- const int colnum = mModel->getColumns();
- for (column = 0; column < colnum; column ++)
- {
- delta += getColumnWidth(column);
- if (x <= delta)
- break;
- }
-
- if (column < 0 || column >= colnum)
- return -1;
- return column;
-}
-
-void GuiTable::setFocusHandler(FocusHandler *const focusHandler)
-{
- // add check for focusHandler. may be need remove it?
-
- if (focusHandler == nullptr)
- return;
-
- Widget::setFocusHandler(focusHandler);
-
- const int rows = mModel->getRows();
- const int cols = mModel->getColumns();
- for (int r = 0; r < rows; ++r)
- {
- for (int c = 0; c < cols ; ++c)
- {
- Widget *const w = mModel->getElementAt(r, c);
- if (w != nullptr)
- w->setFocusHandler(focusHandler);
- }
- }
-}
-
-void GuiTable::requestFocus()
-{
- if (mFocusHandler == nullptr)
- return;
- Widget::requestFocus();
-}
diff --git a/src/gui/widgets/guitable.h b/src/gui/widgets/guitable.h
deleted file mode 100644
index 30eb73523..000000000
--- a/src/gui/widgets/guitable.h
+++ /dev/null
@@ -1,207 +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 GUI_WIDGETS_GUITABLE_H
-#define GUI_WIDGETS_GUITABLE_H
-
-#include "localconsts.h"
-
-#include "enums/simpletypes/opaque.h"
-
-#include "listeners/keylistener.h"
-#include "listeners/mouselistener.h"
-#include "listeners/tablemodellistener.h"
-
-#include "gui/widgets/widget.h"
-
-class GuiTableActionListener;
-class TableModel;
-
-/**
- * A table, with rows and columns made out of sub-widgets. Largely inspired by
- * (and can be thought of as a generalisation of) the guichan listbox
- * implementation.
- *
- * Normally you want this within a ScrollArea.
- *
- * \ingroup GUI
- */
-class GuiTable final : public Widget,
- public MouseListener,
- public KeyListener,
- public TableModelListener
-{
- // so that the action listener can call distributeActionEvent
- friend class GuiTableActionListener;
-
- public:
- GuiTable(const Widget2 *const widget,
- TableModel *const initial_model,
- const Opaque opacity = Opaque_true);
-
- A_DELETE_COPY(GuiTable)
-
- ~GuiTable();
-
- /**
- * Sets the table model
- *
- * Note that actions issued by widgets returned from the model will
- * update the table selection, but only AFTER any event handlers
- * installed within the widget have been triggered. To be notified
- * after such an update, add an action listener to the table instead.
- */
- void setModel(TableModel *const m);
-
- /**
- * Retrieves the active table model
- */
- const TableModel *getModel() const A_WARN_UNUSED RETURNS_NONNULL;
-
- void setSelected(const int row, const int column);
-
- int getSelectedRow() const A_WARN_UNUSED;
-
- int getSelectedColumn() const A_WARN_UNUSED;
-
- void setSelectedRow(const int selected);
-
- void setSelectedColumn(const int selected);
-
- bool isWrappingEnabled() const noexcept2 A_WARN_UNUSED
- { return mWrappingEnabled; }
-
- void setWrappingEnabled(bool wrappingEnabled)
- { mWrappingEnabled = wrappingEnabled; }
-
- Rect getChildrenArea() override final A_WARN_UNUSED;
-
- /**
- * Toggle whether to use linewise selection mode, in which the table
- * selects an entire line at a time, rather than a single cell.
- *
- * Note that column information is tracked even in linewise selection
- * mode;
- *
- * this mode therefore only affects visualisation.
- *
- * Disabled by default.
- *
- * \param linewise: Whether to enable linewise selection mode
- */
- void setLinewiseSelection(bool linewise)
- { mLinewiseMode = linewise; }
-
- // Inherited from Widget
- void draw(Graphics *const graphics) override final A_NONNULL(2);
-
- void safeDraw(Graphics *const graphics) override final A_NONNULL(2);
-
- Widget *getWidgetAt(int x, int y) override final A_WARN_UNUSED;
-
- void moveToTop(Widget *const widget) override final;
-
- void moveToBottom(Widget *const widget) override final;
-
- void setFocusHandler(FocusHandler *const focusHandler) override final;
-
- // Inherited from KeyListener
- void keyPressed(KeyEvent& event) override final;
-
- /**
- * Sets the table to be opaque, that is sets the table
- * to display its background.
- *
- * @param opaque True if the table should be opaque, false otherwise.
- */
- void setOpaque(Opaque opaque)
- { mOpaque = opaque; }
-
- /**
- * Checks if the table is opaque, that is if the table area displays
- * its background.
- *
- * @return True if the table is opaque, false otherwise.
- */
- bool isOpaque() const noexcept2 A_WARN_UNUSED
- { return mOpaque == Opaque_true; }
-
- // Inherited from MouseListener
- void mousePressed(MouseEvent& event) override final;
-
- void mouseWheelMovedUp(MouseEvent& event) override final;
-
- void mouseWheelMovedDown(MouseEvent& event) override final;
-
- void mouseDragged(MouseEvent& event) override final;
-
- // Constraints inherited from TableModelListener
- void modelUpdated(const bool completed) override final;
-
- void requestFocus() override;
-
- void setSelectableGui(bool b)
- { mSelectableGui = b; }
-
- protected:
- /** Frees all action listeners on inner widgets. */
- void uninstallActionListeners();
-
- /** Installs all action listeners on inner widgets. */
- void installActionListeners();
-
- int getRowHeight() const A_WARN_UNUSED;
-
- int getColumnWidth(const int i) const A_WARN_UNUSED;
-
- private:
- int getRowForY(const int y) const A_WARN_UNUSED; // -1 on error
-
- int getColumnForX(const int x) const A_WARN_UNUSED; // -1 on error
-
- void recomputeDimensions();
-
- static float mAlpha;
-
- TableModel *mModel A_NONNULLPOINTER;
-
- /** If someone moves a fresh widget to the top, we must display it. */
- Widget *mTopWidget;
-
- /** Vector for compactness; used as a list in practice. */
- STD_VECTOR<GuiTableActionListener *> mActionListeners2;
-
- /**
- * Holds the background color of the table.
- */
- Color mHighlightColor;
-
- int mSelectedRow;
- int mSelectedColumn;
-
- bool mLinewiseMode;
- bool mWrappingEnabled;
- Opaque mOpaque;
- bool mSelectableGui;
-};
-
-#endif // GUI_WIDGETS_GUITABLE_H
diff --git a/src/gui/widgets/horizontcontainer.cpp b/src/gui/widgets/horizontcontainer.cpp
deleted file mode 100644
index 8a026329a..000000000
--- a/src/gui/widgets/horizontcontainer.cpp
+++ /dev/null
@@ -1,66 +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 "gui/widgets/horizontcontainer.h"
-
-#include "debug.h"
-
-HorizontContainer::HorizontContainer(const Widget2 *const widget,
- const int height,
- const int spacing) :
- Container(widget),
- WidgetListener(),
- ToolTipListener(),
- mSpacing(spacing),
- mCount(0),
- mLastX(spacing)
-{
- setHeight(height);
- addWidgetListener(this);
- addMouseListener(this);
-}
-
-void HorizontContainer::add(Widget *const widget)
-{
- add(widget, mSpacing);
-}
-
-void HorizontContainer::add(Widget *const widget, const int spacing)
-{
- if (widget == nullptr)
- return;
-
- Container::add(widget);
- widget->setPosition(mLastX, spacing);
- mCount++;
- mLastX += widget->getWidth() + 2 * mSpacing;
-}
-
-void HorizontContainer::clear()
-{
- Container::clear();
-
- mCount = 0;
-}
-
-void HorizontContainer::widgetResized(const Event &event A_UNUSED)
-{
-}
diff --git a/src/gui/widgets/horizontcontainer.h b/src/gui/widgets/horizontcontainer.h
deleted file mode 100644
index a010f172e..000000000
--- a/src/gui/widgets/horizontcontainer.h
+++ /dev/null
@@ -1,62 +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 GUI_WIDGETS_HORIZONTCONTAINER_H
-#define GUI_WIDGETS_HORIZONTCONTAINER_H
-
-#include "gui/widgets/container.h"
-
-#include "listeners/tooltiplistener.h"
-#include "listeners/widgetlistener.h"
-
-#include "localconsts.h"
-
-/**
- * A widget container.
- *
- * This container places it's contents veritcally.
- */
-class HorizontContainer final : public Container,
- public WidgetListener,
- public ToolTipListener
-{
- public:
- HorizontContainer(const Widget2 *const widget,
- const int height,
- const int spacing);
-
- A_DELETE_COPY(HorizontContainer)
-
- void add(Widget *const widget) override final;
-
- void add(Widget *const widget, const int spacing);
-
- void clear() override;
-
- void widgetResized(const Event &event) override final A_CONST;
-
- protected:
- int mSpacing;
- int mCount;
- int mLastX;
-};
-
-#endif // GUI_WIDGETS_HORIZONTCONTAINER_H
diff --git a/src/gui/widgets/icon.cpp b/src/gui/widgets/icon.cpp
deleted file mode 100644
index dbe46a21a..000000000
--- a/src/gui/widgets/icon.cpp
+++ /dev/null
@@ -1,105 +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 "gui/widgets/icon.h"
-
-#include "gui/gui.h"
-
-#include "render/graphics.h"
-
-#include "resources/image/image.h"
-
-#include "resources/loaders/imageloader.h"
-
-#include "debug.h"
-
-Icon::Icon(const Widget2 *const widget,
- const std::string &file,
- const AutoRelease autoRelease) :
- Widget(widget),
- mImage(Loader::getImage(file)),
- mAutoRelease(autoRelease)
-{
- if (mImage != nullptr)
- {
- const SDL_Rect &bounds = mImage->mBounds;
- setSize(bounds.w, bounds.h);
- }
- mAllowLogic = false;
-}
-
-Icon::Icon(const Widget2 *const widget,
- Image *const image,
- const AutoRelease autoRelease) :
- Widget(widget),
- mImage(image),
- mAutoRelease(autoRelease)
-{
- if (mImage != nullptr)
- {
- const SDL_Rect &bounds = mImage->mBounds;
- setSize(bounds.w, bounds.h);
- }
- mAllowLogic = false;
-}
-
-Icon::~Icon()
-{
- if (gui != nullptr)
- gui->removeDragged(this);
- if ((mImage != nullptr) && mAutoRelease == AutoRelease_true)
- mImage->decRef();
-}
-
-void Icon::setImage(Image *const image)
-{
- mImage = image;
- if (mImage != nullptr)
- {
- const SDL_Rect &bounds = mImage->mBounds;
- setSize(bounds.w, bounds.h);
- }
-}
-
-void Icon::draw(Graphics *const graphics)
-{
- BLOCK_START("Icon::draw")
- if (mImage != nullptr)
- {
- graphics->drawImage(mImage,
- (mDimension.width - mImage->mBounds.w) / 2,
- (mDimension.height - mImage->mBounds.h) / 2);
- }
- BLOCK_END("Icon::draw")
-}
-
-void Icon::safeDraw(Graphics *const graphics)
-{
- BLOCK_START("Icon::draw")
- if (mImage != nullptr)
- {
- graphics->drawImage(mImage,
- (mDimension.width - mImage->mBounds.w) / 2,
- (mDimension.height - mImage->mBounds.h) / 2);
- }
- BLOCK_END("Icon::draw")
-}
diff --git a/src/gui/widgets/icon.h b/src/gui/widgets/icon.h
deleted file mode 100644
index f0849d505..000000000
--- a/src/gui/widgets/icon.h
+++ /dev/null
@@ -1,83 +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 GUI_WIDGETS_ICON_H
-#define GUI_WIDGETS_ICON_H
-
-#include "gui/widgets/widget.h"
-
-#include "enums/simpletypes/autorelease.h"
-
-#include "localconsts.h"
-
-class Image;
-
-/**
- * An icon.
- *
- * \ingroup GUI
- */
-class Icon final : public Widget
-{
- public:
- /**
- * Constructor.
- */
- Icon(const Widget2 *const widget,
- const std::string &filename,
- const AutoRelease autoRelease = AutoRelease_false);
-
- /**
- * Constructor, uses an existing Image.
- */
- Icon(const Widget2 *const widget,
- Image *const image,
- const AutoRelease autoRelease = AutoRelease_false);
-
- A_DELETE_COPY(Icon)
-
- ~Icon();
-
- /**
- * Gets the current Image.
- */
- Image *getImage() const noexcept2 A_WARN_UNUSED
- { return mImage; }
-
- /**
- * Sets the image to display.
- */
- void setImage(Image *const image);
-
- /**
- * Draws the Icon.
- */
- void draw(Graphics *const g) override final A_NONNULL(2);
-
- void safeDraw(Graphics *const g) override final A_NONNULL(2);
-
- private:
- Image *mImage;
- AutoRelease mAutoRelease;
-};
-
-#endif // GUI_WIDGETS_ICON_H
diff --git a/src/gui/widgets/inttextfield.cpp b/src/gui/widgets/inttextfield.cpp
deleted file mode 100644
index 41436d310..000000000
--- a/src/gui/widgets/inttextfield.cpp
+++ /dev/null
@@ -1,148 +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 "gui/widgets/inttextfield.h"
-
-#ifdef USE_SDL2
-#include "enums/input/keyvalue.h"
-#endif // USE_SDL2
-
-#include "utils/stringutils.h"
-
-#include <sstream>
-
-#include "debug.h"
-
-IntTextField::IntTextField(const Widget2 *const widget,
- const int def,
- const int min,
- const int max,
- const Enable enabled,
- const int width) :
- TextField(widget, toString(def)),
- mMin(0),
- mMax(0),
- mDefault(def),
- mValue(def)
-{
- if (min != 0 || max != 0)
- setRange(min, max);
-
- setEnabled(enabled == Enable_true);
- if (width != 0)
- setWidth(width);
-}
-
-void IntTextField::keyPressed(KeyEvent &event)
-{
- const InputActionT action = event.getActionId();
-
- if (action == InputAction::GUI_DELETE
- || action == InputAction::GUI_BACKSPACE)
- {
- setText(std::string());
- if (mSendAlwaysEvents)
- distributeActionEvent();
-
- event.consume();
- }
-
-#ifdef USE_SDL2
- const int val = event.getKey().getValue();
- if (val != KeyValue::TEXTINPUT)
- return;
-
- const std::string str = event.getText();
- if (str.empty())
- return;
- const size_t sz = str.size();
- for (size_t f = 0; f < sz; f ++)
- {
- const char chr = str[f];
- if (chr < '0' || chr > '9')
- return;
- }
-#else // USE_SDL2
-
- if (!event.getKey().isNumber())
- return;
-#endif // USE_SDL2
-
- TextField::keyPressed(event);
-
- std::istringstream s(getText());
- int i;
- s >> i;
- setValue(i);
- if (mSendAlwaysEvents)
- distributeActionEvent();
-}
-
-void IntTextField::setRange(const int min, const int max)
-{
- mMin = min;
- mMax = max;
-
- if (mValue < mMin)
- mValue = mMin;
- else if (mValue > mMax)
- mValue = mMax;
-
- if (mDefault < mMin)
- mDefault = mMin;
- else if (mDefault > mMax)
- mDefault = mMax;
-}
-
-int IntTextField::getValue() const
-{
- return getText().empty() ? mMin : mValue;
-}
-
-void IntTextField::setValue(const int i)
-{
- if (i < mMin)
- mValue = mMin;
- else if (i > mMax)
- mValue = mMax;
- else
- mValue = i;
-
- const std::string valStr = toString(mValue);
- setText(valStr);
- setCaretPosition(CAST_U32(valStr.length()) + 1);
-}
-
-void IntTextField::setDefaultValue(const int value)
-{
- if (value < mMin)
- mDefault = mMin;
- else if (value > mMax)
- mDefault = mMax;
- else
- mDefault = value;
-}
-
-void IntTextField::reset()
-{
- setValue(mDefault);
-}
diff --git a/src/gui/widgets/inttextfield.h b/src/gui/widgets/inttextfield.h
deleted file mode 100644
index b8ac8564f..000000000
--- a/src/gui/widgets/inttextfield.h
+++ /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/>.
- */
-
-#ifndef GUI_WIDGETS_INTTEXTFIELD_H
-#define GUI_WIDGETS_INTTEXTFIELD_H
-
-#include "enums/simpletypes/enable.h"
-
-#include "gui/widgets/textfield.h"
-
-/**
- * TextBox which only accepts numbers as input.
- */
-class IntTextField final : public TextField
-{
- public:
- /**
- * Constructor, sets default value.
- */
- explicit IntTextField(const Widget2 *const widget,
- const int def = 0,
- const int min = 0,
- const int max = 0,
- const Enable enabled = Enable_true,
- const int width = 0);
-
- A_DELETE_COPY(IntTextField)
-
- /**
- * Sets the minimum and maximum values of the text box.
- */
- void setRange(const int minimum, const int maximum);
-
- /**
- * Returns the value in the text box.
- */
- int getValue() const A_WARN_UNUSED;
-
- /**
- * Reset the field to the default value.
- */
- void reset();
-
- /**
- * Set the value of the text box to the specified value.
- */
- void setValue(const int value);
-
- /**
- * Set the default value of the text box to the specified value.
- */
- void setDefaultValue(const int value);
-
- /**
- * Responds to key presses.
- */
- void keyPressed(KeyEvent &event) override final;
-
- private:
- int mMin; /**< Minimum value */
- int mMax; /**< Maximum value */
- int mDefault; /**< Default value */
- int mValue; /**< Current value */
-};
-
-#endif // GUI_WIDGETS_INTTEXTFIELD_H
diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp
deleted file mode 100644
index b6ac3cff3..000000000
--- a/src/gui/widgets/itemcontainer.cpp
+++ /dev/null
@@ -1,1322 +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 "gui/widgets/itemcontainer.h"
-
-#include "dragdrop.h"
-#include "settings.h"
-
-#include "being/playerinfo.h"
-
-#include "gui/gui.h"
-#include "gui/skin.h"
-#include "gui/viewport.h"
-
-#include "gui/fonts/font.h"
-
-#include "gui/shortcut/itemshortcut.h"
-
-#include "gui/popups/itempopup.h"
-
-#include "gui/windows/chatwindow.h"
-#include "gui/windows/inventorywindow.h"
-#include "gui/windows/shopwindow.h"
-#include "gui/windows/shortcutwindow.h"
-#include "gui/windows/itemamountwindow.h"
-#include "gui/windows/maileditwindow.h"
-#include "gui/windows/npcdialog.h"
-
-#include "input/inputmanager.h"
-
-#include "net/inventoryhandler.h"
-#include "net/net.h"
-#include "net/mail2handler.h"
-#include "net/npchandler.h"
-#include "net/tradehandler.h"
-
-#include "utils/delete2.h"
-#include "utils/foreach.h"
-#include "utils/gettext.h"
-#include "utils/stringutils.h"
-
-#include "render/vertexes/imagecollection.h"
-
-#include "resources/iteminfo.h"
-
-#include <algorithm>
-
-#include "debug.h"
-
-namespace
-{
- class ItemIdPair final
- {
- public:
- A_DELETE_COPY(ItemIdPair)
-
- ItemIdPair(const int id, Item *const item) :
- mId(id), mItem(item)
- {
- }
-
- int mId;
- Item* mItem;
- };
-
- class SortItemAlphaFunctor final
- {
- public:
- A_DEFAULT_COPY(SortItemAlphaFunctor)
-
- bool operator() (const ItemIdPair *const pair1,
- const ItemIdPair *const pair2) const
- {
- const Item *const item1 = pair1->mItem;
- const Item *const item2 = pair2->mItem;
- if ((item1 == nullptr) || (item2 == nullptr))
- return false;
-
- const std::string name1 = item1->getInfo().getName(
- item1->getColor());
- const std::string name2 = item2->getInfo().getName(
- item2->getColor());
- if (name1 == name2)
- {
- return item1->getInvIndex() <
- item2->getInvIndex();
- }
- return name1 < name2;
- }
- } itemAlphaInvSorter;
-
- class SortItemIdFunctor final
- {
- public:
- A_DEFAULT_COPY(SortItemIdFunctor)
-
- bool operator() (const ItemIdPair *const pair1,
- const ItemIdPair *const pair2) const
- {
- if ((pair1->mItem == nullptr) || (pair2->mItem == nullptr))
- return false;
-
- const int id1 = pair1->mItem->getId();
- const int id2 = pair2->mItem->getId();
- if (id1 == id2)
- {
- return pair1->mItem->getInvIndex() <
- pair2->mItem->getInvIndex();
- }
- return id1 < id2;
- }
- } itemIdInvSorter;
-
- class SortItemWeightFunctor final
- {
- public:
- A_DEFAULT_COPY(SortItemWeightFunctor)
-
- bool operator() (const ItemIdPair *const pair1,
- const ItemIdPair *const pair2) const
- {
- if ((pair1->mItem == nullptr) || (pair2->mItem == nullptr))
- return false;
-
- const int w1 = pair1->mItem->getInfo().getWeight();
- const int w2 = pair2->mItem->getInfo().getWeight();
- if (w1 == w2)
- {
- const std::string name1 =
- pair1->mItem->getInfo().getName();
- const std::string name2 =
- pair2->mItem->getInfo().getName();
- if (name1 == name2)
- {
- return pair1->mItem->getInvIndex() <
- pair2->mItem->getInvIndex();
- }
- return name1 < name2;
- }
- return w1 < w2;
- }
- } itemWeightInvSorter;
-
- class SortItemAmountFunctor final
- {
- public:
- A_DEFAULT_COPY(SortItemAmountFunctor)
-
- bool operator() (const ItemIdPair *const pair1,
- const ItemIdPair *const pair2) const
- {
- if ((pair1->mItem == nullptr) || (pair2->mItem == nullptr))
- return false;
-
- const int c1 = pair1->mItem->getQuantity();
- const int c2 = pair2->mItem->getQuantity();
- if (c1 == c2)
- {
- const std::string name1 =
- pair1->mItem->getInfo().getName();
- const std::string name2 =
- pair2->mItem->getInfo().getName();
- if (name1 == name2)
- {
- return pair1->mItem->getInvIndex() <
- pair2->mItem->getInvIndex();
- }
- return name1 < name2;
- }
- return c1 < c2;
- }
- } itemAmountInvSorter;
-
- class SortItemTypeFunctor final
- {
- public:
- A_DEFAULT_COPY(SortItemTypeFunctor)
-
- bool operator() (const ItemIdPair *const pair1,
- const ItemIdPair *const pair2) const
- {
- if ((pair1->mItem == nullptr) || (pair2->mItem == nullptr))
- return false;
-
- const ItemInfo &info1 = pair1->mItem->getInfo();
- const ItemInfo &info2 = pair2->mItem->getInfo();
- const ItemDbTypeT t1 = info1.getType();
- const ItemDbTypeT t2 = info2.getType();
- if (t1 == t2)
- {
- const std::string &name1 = info1.getName();
- const std::string &name2 = info2.getName();
- if (name1 == name2)
- {
- return pair1->mItem->getInvIndex() <
- pair2->mItem->getInvIndex();
- }
- return name1 < name2;
- }
- return t1 < t2;
- }
- } itemTypeInvSorter;
-} // namespace
-
-ItemContainer::ItemContainer(const Widget2 *const widget,
- Inventory *const inventory,
- const int maxColumns,
- const ShowEmptyRows showEmptyRows,
- const ForceQuantity forceQuantity) :
- Widget(widget),
- KeyListener(),
- MouseListener(),
- WidgetListener(),
- mInventory(inventory),
- mSelImg(Theme::getImageFromThemeXml("item_selection.xml", "")),
- mProtectedImg(Theme::getImageFromTheme("lock.png")),
- mCellBackgroundImg(Theme::getImageFromThemeXml("inventory_cell.xml", "")),
- mName(),
- mShowMatrix(nullptr),
- mSkin(theme != nullptr ? theme->load("itemcontainer.xml", "") : nullptr),
- mVertexes(new ImageCollection),
- mEquipedColor(getThemeColor(ThemeColorId::ITEM_EQUIPPED)),
- mEquipedColor2(getThemeColor(ThemeColorId::ITEM_EQUIPPED_OUTLINE)),
- mUnEquipedColor(getThemeColor(ThemeColorId::ITEM_NOT_EQUIPPED)),
- mUnEquipedColor2(getThemeColor(ThemeColorId::ITEM_NOT_EQUIPPED_OUTLINE)),
- mSelectionListeners(),
- mGridColumns(1),
- mGridRows(1),
- mDrawRows(1),
- mSelectedIndex(-1),
- mLastUsedSlot(-1),
- mTag(0),
- mSortType(0),
- mClicks(1),
- mBoxWidth(mSkin != nullptr ? mSkin->getOption("boxWidth", 35) : 35),
- mBoxHeight(mSkin != nullptr ? mSkin->getOption("boxHeight", 43) : 43),
- mEquippedTextPadding(mSkin != nullptr ? mSkin->getOption(
- "equippedTextPadding", 29) : 29),
- mPaddingItemX(mSkin != nullptr ? mSkin->getOption("paddingItemX", 0) : 0),
- mPaddingItemY(mSkin != nullptr ? mSkin->getOption("paddingItemY", 0) : 0),
- mMaxColumns(maxColumns),
- mSelectionStatus(SEL_NONE),
- mForceQuantity(forceQuantity),
- mShowEmptyRows(showEmptyRows),
- mDescItems(false)
-{
- setFocusable(true);
- addKeyListener(this);
- addMouseListener(this);
- addWidgetListener(this);
- mAllowLogic = false;
-}
-
-ItemContainer::~ItemContainer()
-{
- if (gui != nullptr)
- gui->removeDragged(this);
-
- if (mSelImg != nullptr)
- {
- mSelImg->decRef();
- mSelImg = nullptr;
- }
- if (mProtectedImg != nullptr)
- {
- mProtectedImg->decRef();
- mProtectedImg = nullptr;
- }
- if (mCellBackgroundImg != nullptr)
- {
- mCellBackgroundImg->decRef();
- mCellBackgroundImg = nullptr;
- }
-
- if (theme != nullptr)
- theme->unload(mSkin);
-
- delete []mShowMatrix;
- delete2(mVertexes);
-}
-
-void ItemContainer::logic()
-{
- BLOCK_START("ItemContainer::logic")
- Widget::logic();
-
- if (mInventory == nullptr)
- {
- BLOCK_END("ItemContainer::logic")
- return;
- }
-
- const int lastUsedSlot = mInventory->getLastUsedSlot();
-
- if (lastUsedSlot != mLastUsedSlot)
- {
- mLastUsedSlot = lastUsedSlot;
- adjustHeight();
- }
- BLOCK_END("ItemContainer::logic")
-}
-
-void ItemContainer::draw(Graphics *const graphics)
-{
- if ((mInventory == nullptr) || (mShowMatrix == nullptr))
- return;
-
- BLOCK_START("ItemContainer::draw")
- Font *const font = getFont();
-
- if (mCellBackgroundImg != nullptr)
- {
- if (mRedraw || graphics->getRedraw())
- {
- mRedraw = false;
- mVertexes->clear();
-
- const int invSize = mInventory->getSize();
- const int maxRows = mShowEmptyRows == ShowEmptyRows_true ?
- std::max(invSize / mGridColumns, mGridRows) : mGridRows;
- const int maxColumns = mGridColumns > invSize ?
- invSize : mGridColumns;
- for (int j = 0; j < maxRows; j++)
- {
- const int intY0 = j * mBoxHeight;
- for (int i = 0; i < maxColumns; i++)
- {
- int itemX = i * mBoxWidth;
- int itemY = intY0;
- graphics->calcTileCollection(mVertexes,
- mCellBackgroundImg,
- itemX + mPaddingItemX,
- itemY + mPaddingItemY);
- }
- }
- graphics->finalize(mVertexes);
- }
- graphics->drawTileCollection(mVertexes);
- }
-
- for (int j = 0; j < mDrawRows; j++)
- {
- const int intY0 = j * mBoxHeight;
- int itemIndex = j * mGridColumns - 1;
- for (int i = 0; i < mGridColumns; i++)
- {
- int itemX = i * mBoxWidth;
- int itemY = intY0;
- itemIndex ++;
- if (mShowMatrix[itemIndex] < 0)
- continue;
-
- const Item *const item = mInventory->getItem(
- mShowMatrix[itemIndex]);
-
- if ((item == nullptr) || item->getId() == 0)
- continue;
-
- Image *const image = item->getImage();
- if (image != nullptr)
- {
- if (mShowMatrix[itemIndex] == mSelectedIndex)
- {
- if (mSelImg != nullptr)
- graphics->drawImage(mSelImg, itemX, itemY);
- }
- image->setAlpha(1.0F); // ensure the image if fully drawn...
- graphics->drawImage(image,
- itemX + mPaddingItemX,
- itemY + mPaddingItemY);
- if ((mProtectedImg != nullptr) && PlayerInfo::isItemProtected(
- item->getId()))
- {
- graphics->drawImage(mProtectedImg,
- itemX + mPaddingItemX,
- itemY + mPaddingItemY);
- }
- }
- }
- }
-
- for (int j = 0; j < mDrawRows; j++)
- {
- const int intY0 = j * mBoxHeight;
- int itemIndex = j * mGridColumns - 1;
- for (int i = 0; i < mGridColumns; i++)
- {
- int itemX = i * mBoxWidth;
- int itemY = intY0;
- itemIndex ++;
- if (mShowMatrix[itemIndex] < 0)
- continue;
-
- const Item *const item = mInventory->getItem(
- mShowMatrix[itemIndex]);
-
- if ((item == nullptr) || item->getId() == 0)
- continue;
-
- // Draw item caption
- std::string caption;
- if (item->getQuantity() > 1 ||
- mForceQuantity == ForceQuantity_true)
- {
- caption = toString(item->getQuantity());
- }
- else if (item->isEquipped() == Equipped_true)
- {
- // TRANSLATORS: Text under equipped items (should be small)
- caption = _("Eq.");
- }
-
- if (item->isEquipped() == Equipped_true)
- {
- font->drawString(graphics,
- mEquipedColor, mEquipedColor2,
- caption,
- itemX + (mBoxWidth - font->getWidth(caption)) / 2,
- itemY + mEquippedTextPadding);
- }
- else
- {
- font->drawString(graphics,
- mUnEquipedColor, mUnEquipedColor2,
- caption,
- itemX + (mBoxWidth - font->getWidth(caption)) / 2,
- itemY + mEquippedTextPadding);
- }
- }
- }
- BLOCK_END("ItemContainer::draw")
-}
-
-void ItemContainer::safeDraw(Graphics *const graphics)
-{
- if ((mInventory == nullptr) || (mShowMatrix == nullptr))
- return;
-
- BLOCK_START("ItemContainer::draw")
- Font *const font = getFont();
-
- if (mCellBackgroundImg != nullptr)
- {
- const int invSize = mInventory->getSize();
- const int maxRows = mShowEmptyRows == ShowEmptyRows_true ?
- std::max(invSize / mGridColumns, mGridRows) : mGridRows;
- const int maxColumns = mGridColumns > invSize ?
- invSize : mGridColumns;
- for (int j = 0; j < maxRows; j++)
- {
- const int intY0 = j * mBoxHeight;
- for (int i = 0; i < maxColumns; i++)
- {
- int itemX = i * mBoxWidth;
- int itemY = intY0;
- graphics->drawImage(mCellBackgroundImg,
- itemX + mPaddingItemX,
- itemY + mPaddingItemY);
- }
- }
- }
-
- for (int j = 0; j < mDrawRows; j++)
- {
- const int intY0 = j * mBoxHeight;
- int itemIndex = j * mGridColumns - 1;
- for (int i = 0; i < mGridColumns; i++)
- {
- int itemX = i * mBoxWidth;
- int itemY = intY0;
- itemIndex ++;
- if (mShowMatrix[itemIndex] < 0)
- continue;
-
- const Item *const item = mInventory->getItem(
- mShowMatrix[itemIndex]);
-
- if ((item == nullptr) || item->getId() == 0)
- continue;
-
- Image *const image = item->getImage();
- if (image != nullptr)
- {
- if (mShowMatrix[itemIndex] == mSelectedIndex)
- {
- if (mSelImg != nullptr)
- graphics->drawImage(mSelImg, itemX, itemY);
- }
- image->setAlpha(1.0F); // ensure the image if fully drawn...
- graphics->drawImage(image,
- itemX + mPaddingItemX,
- itemY + mPaddingItemY);
- if ((mProtectedImg != nullptr) && PlayerInfo::isItemProtected(
- item->getId()))
- {
- graphics->drawImage(mProtectedImg,
- itemX + mPaddingItemX,
- itemY + mPaddingItemY);
- }
- }
- }
- }
-
- for (int j = 0; j < mDrawRows; j++)
- {
- const int intY0 = j * mBoxHeight;
- int itemIndex = j * mGridColumns - 1;
- for (int i = 0; i < mGridColumns; i++)
- {
- int itemX = i * mBoxWidth;
- int itemY = intY0;
- itemIndex ++;
- if (mShowMatrix[itemIndex] < 0)
- continue;
-
- const Item *const item = mInventory->getItem(
- mShowMatrix[itemIndex]);
-
- if ((item == nullptr) || item->getId() == 0)
- continue;
-
- // Draw item caption
- std::string caption;
- if (item->getQuantity() > 1 ||
- mForceQuantity == ForceQuantity_true)
- {
- caption = toString(item->getQuantity());
- }
- else if (item->isEquipped() == Equipped_true)
- {
- // TRANSLATORS: Text under equipped items (should be small)
- caption = _("Eq.");
- }
-
- if (item->isEquipped() == Equipped_true)
- {
- font->drawString(graphics,
- mEquipedColor, mEquipedColor2,
- caption,
- itemX + (mBoxWidth - font->getWidth(caption)) / 2,
- itemY + mEquippedTextPadding);
- }
- else
- {
- font->drawString(graphics,
- mUnEquipedColor, mUnEquipedColor2,
- caption,
- itemX + (mBoxWidth - font->getWidth(caption)) / 2,
- itemY + mEquippedTextPadding);
- }
- }
- }
- BLOCK_END("ItemContainer::draw")
-}
-
-void ItemContainer::selectNone()
-{
- dragDrop.clear();
-
- setSelectedIndex(-1);
- mSelectionStatus = SEL_NONE;
-/*
- if (outfitWindow)
- outfitWindow->setItemSelected(-1);
- if (shopWindow)
- shopWindow->setItemSelected(-1);
-*/
-}
-
-void ItemContainer::setSelectedIndex(const int newIndex)
-{
- if (mSelectedIndex != newIndex)
- {
- mSelectedIndex = newIndex;
- distributeValueChangedEvent();
- }
-}
-
-Item *ItemContainer::getSelectedItem() const
-{
- if (mInventory != nullptr)
- return mInventory->getItem(mSelectedIndex);
- return nullptr;
-}
-
-void ItemContainer::distributeValueChangedEvent()
-{
- FOR_EACH (SelectionListenerIterator, i, mSelectionListeners)
- {
- if (*i != nullptr)
- {
- SelectionEvent event(this);
- (*i)->valueChanged(event);
- }
- }
-}
-
-void ItemContainer::keyPressed(KeyEvent &event A_UNUSED)
-{
-}
-
-void ItemContainer::keyReleased(KeyEvent &event A_UNUSED)
-{
-}
-
-void ItemContainer::mousePressed(MouseEvent &event)
-{
- if (mInventory == nullptr)
- return;
-
- const MouseButtonT button = event.getButton();
- mClicks = event.getClickCount();
-
- if (button == MouseButton::LEFT || button == MouseButton::RIGHT)
- {
- event.consume();
- const int index = getSlotIndex(event.getX(), event.getY());
- if (index == Inventory::NO_SLOT_INDEX)
- return;
-
- Item *const item = mInventory->getItem(index);
-
- // put item name into chat window
- if ((item != nullptr) && mDescItems && (chatWindow != nullptr))
- chatWindow->addItemText(item->getInfo().getName());
-
- DragDropSourceT src = DragDropSource::Empty;
- switch (mInventory->getType())
- {
- case InventoryType::Inventory:
- src = DragDropSource::Inventory;
- break;
- case InventoryType::Storage:
- src = DragDropSource::Storage;
- break;
- case InventoryType::Trade:
- src = DragDropSource::Trade;
- break;
- case InventoryType::Npc:
- src = DragDropSource::Npc;
- break;
- case InventoryType::Cart:
- src = DragDropSource::Cart;
- break;
- case InventoryType::MailEdit:
- src = DragDropSource::MailEdit;
- break;
- case InventoryType::MailView:
- src = DragDropSource::MailView;
- break;
- case InventoryType::Craft:
- src = DragDropSource::Craft;
- break;
- default:
- case InventoryType::Vending:
- case InventoryType::TypeEnd:
- break;
- }
- if (src == DragDropSource::MailView)
- return;
- if (mSelectedIndex == index && mClicks != 2)
- {
- dragDrop.dragItem(item, src, index);
- dragDrop.select(item);
- mSelectionStatus = SEL_DESELECTING;
- }
- else if ((item != nullptr) && (item->getId() != 0))
- {
- if (index >= 0)
- {
- dragDrop.dragItem(item, src, index);
- dragDrop.select(item);
- setSelectedIndex(index);
- mSelectionStatus = SEL_SELECTING;
-
- if (itemShortcutWindow != nullptr)
- {
- const int num = itemShortcutWindow->getTabIndex();
- if (num >= 0 && num < CAST_S32(SHORTCUT_TABS))
- {
- if (itemShortcut[num] != nullptr)
- itemShortcut[num]->setItemSelected(item);
- }
- }
- if (shopWindow != nullptr)
- shopWindow->setItemSelected(item->getId());
- }
- }
- else
- {
- dragDrop.deselect();
- selectNone();
- }
- }
-}
-
-void ItemContainer::mouseDragged(MouseEvent &event A_UNUSED)
-{
- if (mSelectionStatus != SEL_NONE)
- mSelectionStatus = SEL_DRAGGING;
-}
-
-void ItemContainer::mouseReleased(MouseEvent &event)
-{
- if (mClicks == 2 ||
- inventoryHandler == nullptr ||
- tradeHandler == nullptr)
- {
- return;
- }
-
- switch (mSelectionStatus)
- {
- case SEL_SELECTING:
- mSelectionStatus = SEL_SELECTED;
- break;
- case SEL_DESELECTING:
- selectNone();
- break;
- case SEL_DRAGGING:
- mSelectionStatus = SEL_SELECTED;
- break;
- case SEL_NONE:
- case SEL_SELECTED:
- default:
- break;
- };
-
- if (dragDrop.isEmpty())
- {
- const int index = getSlotIndex(event.getX(), event.getY());
- if (index == Inventory::NO_SLOT_INDEX)
- return;
- if (index == mSelectedIndex || mSelectedIndex == -1)
- return;
- inventoryHandler->moveItem(mSelectedIndex, index);
- selectNone();
- }
- else if (mInventory != nullptr)
- {
- const DragDropSourceT src = dragDrop.getSource();
- DragDropSourceT dst = DragDropSource::Empty;
- switch (mInventory->getType())
- {
- case InventoryType::Inventory:
- dst = DragDropSource::Inventory;
- break;
- case InventoryType::Storage:
- dst = DragDropSource::Storage;
- break;
- case InventoryType::Trade:
- dst = DragDropSource::Trade;
- break;
- case InventoryType::Npc:
- dst = DragDropSource::Npc;
- break;
- case InventoryType::MailEdit:
- dst = DragDropSource::MailEdit;
- break;
- case InventoryType::MailView:
- dst = DragDropSource::MailView;
- break;
- case InventoryType::Cart:
- dst = DragDropSource::Cart;
- break;
- case InventoryType::Craft:
- dst = DragDropSource::Craft;
- break;
- default:
- case InventoryType::Vending:
- case InventoryType::TypeEnd:
- break;
- }
- InventoryTypeT srcContainer = InventoryType::TypeEnd;
- InventoryTypeT dstContainer = InventoryType::TypeEnd;
- bool checkProtection(false);
- Inventory *inventory = nullptr;
- if (src == DragDropSource::Inventory
- && dst == DragDropSource::Storage)
- {
- srcContainer = InventoryType::Inventory;
- dstContainer = InventoryType::Storage;
- inventory = PlayerInfo::getInventory();
- }
- else if (src == DragDropSource::Storage
- && dst == DragDropSource::Inventory)
- {
- srcContainer = InventoryType::Storage;
- dstContainer = InventoryType::Inventory;
- inventory = PlayerInfo::getStorageInventory();
- }
- if (src == DragDropSource::Inventory
- && dst == DragDropSource::Cart)
- {
- srcContainer = InventoryType::Inventory;
- dstContainer = InventoryType::Cart;
- inventory = PlayerInfo::getInventory();
- }
- if (src == DragDropSource::Inventory
- && dst == DragDropSource::Inventory)
- {
- if (Net::getNetworkType() == ServerType::TMWATHENA)
- return;
- const int index = getSlotIndex(event.getX(), event.getY());
- if (index == Inventory::NO_SLOT_INDEX)
- return;
- if (index == mSelectedIndex || mSelectedIndex == -1)
- return;
- if (inventoryWindow != nullptr)
- inventoryWindow->combineItems(index, mSelectedIndex);
- return;
- }
- else if (src == DragDropSource::Cart
- && dst == DragDropSource::Inventory)
- {
- srcContainer = InventoryType::Cart;
- dstContainer = InventoryType::Inventory;
- inventory = PlayerInfo::getCartInventory();
- }
- else if (src == DragDropSource::Cart
- && dst == DragDropSource::Storage)
- {
- srcContainer = InventoryType::Cart;
- dstContainer = InventoryType::Storage;
- inventory = PlayerInfo::getCartInventory();
- }
- else if (src == DragDropSource::Storage
- && dst == DragDropSource::Cart)
- {
- srcContainer = InventoryType::Storage;
- dstContainer = InventoryType::Cart;
- inventory = PlayerInfo::getStorageInventory();
- }
- if (src == DragDropSource::Inventory
- && dst == DragDropSource::Trade)
- {
- checkProtection = true;
- inventory = PlayerInfo::getInventory();
- }
- else if (src == DragDropSource::Inventory &&
- dst == DragDropSource::Npc)
- {
- inventory = PlayerInfo::getInventory();
- if (inventory != nullptr)
- {
- Item *const item = inventory->getItem(dragDrop.getTag());
- if (mInventory->addVirtualItem(
- item,
- getSlotByXY(event.getX(), event.getY()),
- 1))
- {
- inventory->virtualRemove(item, 1);
- }
- }
- return;
- }
- else if (src == DragDropSource::Inventory &&
- dst == DragDropSource::MailEdit)
- {
- inventory = PlayerInfo::getInventory();
- if (inventory == nullptr)
- return;
- Item *const item = inventory->getItem(dragDrop.getTag());
- if (item == nullptr)
- return;
- if (settings.enableNewMailSystem)
- {
- if (item->getQuantity() > 1
- && !inputManager.isActionActive(InputAction::STOP_ATTACK))
- {
- ItemAmountWindow::showWindow(
- ItemAmountWindowUsage::MailAdd,
- mailEditWindow,
- item);
- }
- else
- {
- mail2Handler->addItem(item, 1);
- }
- }
- else
- {
- if (mInventory->addVirtualItem(
- item,
- getSlotByXY(event.getX(), event.getY()),
- 1))
- {
- inventory->virtualRemove(item, 1);
- }
- }
- return;
- }
- else if (src == DragDropSource::Npc)
- {
- inventory = PlayerInfo::getInventory();
- if (dst == DragDropSource::Npc)
- {
- const Item *const item = mInventory->getItem(
- dragDrop.getTag());
- const int index = getSlotByXY(event.getX(), event.getY());
- if (index == Inventory::NO_SLOT_INDEX)
- {
- if (inventory != nullptr)
- inventory->virtualRestore(item, 1);
- mInventory->removeItemAt(dragDrop.getTag());
- return;
- }
- mInventory->removeItemAt(index);
- mInventory->setItem(index,
- item->getId(),
- item->getType(),
- 1,
- 1,
- item->getColor(),
- item->getIdentified(),
- item->getDamaged(),
- item->getFavorite(),
- Equipm_false,
- Equipped_false);
- Item *const item2 = mInventory->getItem(index);
- if (item2 != nullptr)
- item2->setTag(item->getTag());
- mInventory->removeItemAt(dragDrop.getTag());
- }
- else
- {
- if (inventory != nullptr)
- {
- const Item *const item = inventory->getItem(
- dragDrop.getTag());
- if (item != nullptr)
- {
- inventory->virtualRestore(item, 1);
- mInventory->removeItemAt(dragDrop.getTag());
- }
- }
- return;
- }
- }
- else if (src == DragDropSource::Inventory &&
- dst == DragDropSource::Craft)
- {
- inventory = PlayerInfo::getInventory();
- if (inventory != nullptr)
- {
- Item *const item = inventory->getItem(dragDrop.getTag());
- if ((item == nullptr) || item->isEquipped() == Equipped_true)
- return;
- const int slot = getSlotByXY(event.getX(), event.getY());
- if (item->getQuantity() > 1
- && !inputManager.isActionActive(InputAction::STOP_ATTACK))
- {
- ItemAmountWindow::showWindow(
- ItemAmountWindowUsage::CraftAdd,
- npcHandler->getCurrentNpcDialog(),
- item,
- 0,
- slot);
- }
- else
- {
- if (mInventory->addVirtualItem(
- item,
- slot,
- 1))
- {
- inventory->virtualRemove(item, 1);
- }
- }
- }
- return;
- }
- else if (src == DragDropSource::Craft)
- {
- inventory = PlayerInfo::getInventory();
- if (dst == DragDropSource::Craft)
- {
- const Item *const item = mInventory->getItem(
- dragDrop.getTag());
- const int index = getSlotByXY(event.getX(), event.getY());
- if (index == Inventory::NO_SLOT_INDEX)
- {
- if (inventory != nullptr)
- {
- inventory->virtualRestore(item,
- item->getQuantity());
- mInventory->removeItemAt(dragDrop.getTag());
- }
- return;
- }
- mInventory->moveItem(index, dragDrop.getTag());
- }
- else
- {
- if (inventory != nullptr)
- {
- const Item *const item = inventory->getItem(
- dragDrop.getTag());
- if (item != nullptr)
- {
- inventory->virtualRestore(item,
- item->getQuantity());
- mInventory->removeItemAt(dragDrop.getTag());
- }
- }
- return;
- }
- }
- else if (src == DragDropSource::MailEdit)
- {
- if (event.getType() == MouseEventType::RELEASED2)
- return;
- if (settings.enableNewMailSystem)
- {
- if (mailEditWindow == nullptr)
- return;
- inventory = mailEditWindow->getInventory();
- if (inventory == nullptr)
- return;
- const Item *const item = inventory->getItem(dragDrop.getTag());
- if (item == nullptr)
- return;
- mail2Handler->removeItem(item->getTag(),
- item->getQuantity());
- }
- else
- {
- inventory = PlayerInfo::getInventory();
- if (inventory == nullptr)
- return;
- const Item *const item = inventory->getItem(dragDrop.getTag());
- if (item == nullptr)
- return;
- mInventory->removeItemAt(dragDrop.getTag());
- }
- return;
- }
-
- if (inventory != nullptr)
- {
- const Item *const item = inventory->getItem(dragDrop.getTag());
- if (item != nullptr)
- {
- if (srcContainer != InventoryType::TypeEnd)
- { // inventory <--> storage, cart
- inventoryHandler->moveItem2(srcContainer,
- item->getInvIndex(),
- item->getQuantity(),
- dstContainer);
- }
- else
- { // inventory --> trade
- if (!checkProtection || !PlayerInfo::isItemProtected(
- item->getId()))
- {
- tradeHandler->addItem(item, item->getQuantity());
- }
- }
- }
- }
- }
-}
-
-void ItemContainer::mouseMoved(MouseEvent &event)
-{
- if (mInventory == nullptr)
- return;
-
- const Item *const item = mInventory->getItem(
- getSlotIndex(event.getX(), event.getY()));
-
- if ((item != nullptr) && (viewport != nullptr))
- {
- itemPopup->setItem(item, false);
- itemPopup->position(viewport->mMouseX, viewport->mMouseY);
- }
- else
- {
- itemPopup->setVisible(Visible_false);
- }
-}
-
-void ItemContainer::mouseExited(MouseEvent &event A_UNUSED)
-{
- itemPopup->setVisible(Visible_false);
-}
-
-void ItemContainer::widgetResized(const Event &event A_UNUSED)
-{
- updateSize();
-}
-
-void ItemContainer::updateSize()
-{
- mGridColumns = std::min(mMaxColumns,
- std::max(1, mDimension.width / mBoxWidth));
- if (mGridColumns > mMaxColumns)
- mGridColumns = mMaxColumns;
- adjustHeight();
- mRedraw = true;
-}
-
-void ItemContainer::widgetMoved(const Event &event A_UNUSED)
-{
- mRedraw = true;
-}
-
-void ItemContainer::adjustHeight()
-{
- if (mGridColumns == 0)
- return;
-
- mGridRows = (mLastUsedSlot + 1) / mGridColumns;
- if (mGridRows == 0 || (mLastUsedSlot + 1) % mGridColumns > 0)
- ++mGridRows;
-
- const int invSize = mInventory->getSize();
- int maxRows = mShowEmptyRows == ShowEmptyRows_true ?
- std::max(invSize / mGridColumns, mGridRows) : mGridRows;
-
- if (mShowEmptyRows == ShowEmptyRows_true)
- {
- if (mGridColumns * maxRows < invSize)
- maxRows ++;
- mGridRows = maxRows;
- }
-
- const int num = updateMatrix();
- if (mShowEmptyRows == ShowEmptyRows_false)
- {
- mDrawRows = num / mGridColumns;
- if (mDrawRows == 0 || num % mGridColumns > 0)
- ++mDrawRows;
-
- maxRows = mDrawRows;
- }
- else
- {
- mDrawRows = mGridRows;
- }
- setHeight(maxRows * mBoxHeight);
-}
-
-int ItemContainer::updateMatrix()
-{
- if (mInventory == nullptr)
- return 0;
-
- mRedraw = true;
- delete []mShowMatrix;
- mShowMatrix = new int[CAST_SIZE(mGridRows * mGridColumns)];
-
- STD_VECTOR<ItemIdPair*> sortedItems;
- int i = 0;
- int j = 0;
-
- std::string temp = mName;
- toLower(temp);
-
- const unsigned int invSize = mInventory->getSize();
- for (unsigned int idx = 0; idx < invSize; idx ++)
- {
- Item *const item = mInventory->getItem(idx);
-
- if (item == nullptr ||
- item->getId() == 0 ||
- !item->isHaveTag(mTag) ||
- item->getQuantity() == 0)
- {
- if (mShowEmptyRows == ShowEmptyRows_true)
- sortedItems.push_back(new ItemIdPair(idx, nullptr));
- continue;
- }
-
- if (!item->isHaveTag(mTag))
- continue;
-
- if (mName.empty())
- {
- sortedItems.push_back(new ItemIdPair(idx, item));
- continue;
- }
- std::string name = item->getInfo().getName();
- toLower(name);
- if (name.find(temp) != std::string::npos)
- sortedItems.push_back(new ItemIdPair(idx, item));
- }
-
- switch (mSortType)
- {
- case 0:
- default:
- break;
- case 1:
- std::sort(sortedItems.begin(), sortedItems.end(),
- itemAlphaInvSorter);
- break;
- case 2:
- std::sort(sortedItems.begin(), sortedItems.end(), itemIdInvSorter);
- break;
- case 3:
- std::sort(sortedItems.begin(), sortedItems.end(),
- itemWeightInvSorter);
- break;
- case 4:
- std::sort(sortedItems.begin(), sortedItems.end(),
- itemAmountInvSorter);
- break;
- case 5:
- std::sort(sortedItems.begin(), sortedItems.end(),
- itemTypeInvSorter);
- break;
- }
-
- int jMult = j * mGridColumns;
- const int maxSize = mGridRows * mGridColumns;
- FOR_EACH (STD_VECTOR<ItemIdPair*>::const_iterator, iter, sortedItems)
- {
- if (jMult >= maxSize)
- break;
-
- mShowMatrix[jMult + i] = (*iter)->mId;
-
- i ++;
- if (i >= mGridColumns)
- {
- i = 0;
- j ++;
- jMult += mGridColumns;
- }
- }
-
- for (int idx = j * mGridColumns + i; idx < maxSize; idx ++)
- mShowMatrix[idx] = -1;
-
- const int num = CAST_S32(sortedItems.size());
- for (size_t idx = 0, sz = num; idx < sz; idx ++)
- delete sortedItems[idx];
- return num;
-}
-
-int ItemContainer::getSlotIndex(int x, int y) const
-{
- if (mShowMatrix == nullptr)
- return Inventory::NO_SLOT_INDEX;
-
- if (x < mDimension.width && y < mDimension.height && x >= 0 && y >= 0)
- {
- if (x > mBoxWidth * mGridColumns)
- return Inventory::NO_SLOT_INDEX;
- const int idx = (y / mBoxHeight) * mGridColumns + (x / mBoxWidth);
- if (idx >= 0 && idx < mGridRows * mGridColumns
- && mShowMatrix[idx] >= 0)
- {
- return mShowMatrix[idx];
- }
- }
-
- return Inventory::NO_SLOT_INDEX;
-}
-
-int ItemContainer::getSlotByXY(int x, int y) const
-{
- if (mShowMatrix == nullptr)
- return Inventory::NO_SLOT_INDEX;
-
- if (x < mDimension.width && y < mDimension.height && x >= 0 && y >= 0)
- {
- if (x > mBoxWidth * mGridColumns)
- return Inventory::NO_SLOT_INDEX;
- const int idx = (y / mBoxHeight) * mGridColumns + (x / mBoxWidth);
- if (idx >= 0 && idx < mGridRows * mGridColumns)
- return idx;
- }
-
- return Inventory::NO_SLOT_INDEX;
-}
-
-void ItemContainer::setFilter(const int tag)
-{
- mTag = tag;
- adjustHeight();
-}
-
-void ItemContainer::setSortType(const int sortType)
-{
- mSortType = sortType;
- updateMatrix();
-}
-
-void ItemContainer::setCellBackgroundImage(const std::string &xmlName)
-{
- if (mCellBackgroundImg != nullptr)
- mCellBackgroundImg->decRef();
- mCellBackgroundImg = Theme::getImageFromThemeXml(xmlName, "");
- mRedraw = true;
-}
-
-void ItemContainer::setMaxColumns(const int maxColumns)
-{
- mMaxColumns = maxColumns;
- updateSize();
-}
diff --git a/src/gui/widgets/itemcontainer.h b/src/gui/widgets/itemcontainer.h
deleted file mode 100644
index c992c43f5..000000000
--- a/src/gui/widgets/itemcontainer.h
+++ /dev/null
@@ -1,223 +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_ITEMCONTAINER_H
-#define GUI_WIDGETS_ITEMCONTAINER_H
-
-#include "listeners/keylistener.h"
-#include "listeners/mouselistener.h"
-#include "listeners/widgetlistener.h"
-
-#include "enums/simpletypes/forcequantity.h"
-#include "enums/simpletypes/showemptyrows.h"
-
-#include "gui/widgets/widget.h"
-
-#include "localconsts.h"
-
-class Image;
-class ImageCollection;
-class Inventory;
-class Item;
-class SelectionListener;
-
-/**
- * An item container. Used to show items in inventory and trade dialog.
- *
- * \ingroup GUI
- */
-class ItemContainer final : public Widget,
- public KeyListener,
- public MouseListener,
- public WidgetListener
-{
- public:
- ItemContainer(const Widget2 *const widget,
- Inventory *const inventory,
- const int maxColumns = 100000,
- const ShowEmptyRows showEmptyRows = ShowEmptyRows_false,
- const ForceQuantity forceQuantity = ForceQuantity_false);
-
- A_DELETE_COPY(ItemContainer)
-
- /**
- * Destructor.
- */
- ~ItemContainer();
-
- /**
- * Necessary for checking how full the inventory is.
- */
- void logic() override final;
-
- /**
- * Draws the items.
- */
- void draw(Graphics *const graphics) override final A_NONNULL(2);
-
- void safeDraw(Graphics *const graphics) override final A_NONNULL(2);
-
- // KeyListener
- void keyPressed(KeyEvent &event) override final A_CONST;
- void keyReleased(KeyEvent &event) override final A_CONST;
-
- // MouseListener
- void mousePressed(MouseEvent &event) override final;
- void mouseDragged(MouseEvent &event) override final;
- void mouseReleased(MouseEvent &event) override final;
- void mouseMoved(MouseEvent &event) override final;
- void mouseExited(MouseEvent &event) override final;
-
- // WidgetListener
- void widgetResized(const Event &event) override final;
-
- void widgetMoved(const Event &event) override final;
-
- /**
- * Returns the selected item.
- */
- Item *getSelectedItem() const A_WARN_UNUSED;
-
- /**
- * Sets selected item to NULL.
- */
- void selectNone();
-
- /**
- * Adds a listener to the list that's notified each time a change to
- * the selection occurs.
- */
- void addSelectionListener(SelectionListener *listener)
- { mSelectionListeners.push_back(listener); }
-
- /**
- * Removes a listener from the list that's notified each time a change
- * to the selection occurs.
- */
- void removeSelectionListener(SelectionListener *listener)
- { mSelectionListeners.remove(listener); }
-
- void setFilter(const int tag);
-
- void setSortType(const int sortType);
-
- void setName(const std::string &str)
- { mName = str; }
-
- int updateMatrix();
-
- bool getClickCount() const noexcept2 A_WARN_UNUSED
- { return mClicks != 0; }
-
- void unsetInventory() noexcept2
- { mInventory = nullptr; }
-
- void setInventory(Inventory *const inventory) noexcept2
- { mInventory = inventory; }
-
- void setCellBackgroundImage(const std::string &xmlName);
-
- void setMaxColumns(const int maxColumns);
-
- private:
- enum Direction
- {
- Left = 0,
- Right,
- Up,
- Down
- };
-
- enum SelectionState
- {
- SEL_NONE = 0,
- SEL_SELECTED,
- SEL_SELECTING,
- SEL_DESELECTING,
- SEL_DRAGGING
- };
-
- /**
- * Sets the currently selected item.
- */
- void setSelectedIndex(const int index);
-
- /**
- * Determine and set the height of the container.
- */
- void adjustHeight();
-
- /**
- * Sends out selection events to the list of selection listeners.
- */
- void distributeValueChangedEvent();
-
- void updateSize();
-
- /**
- * Gets the inventory slot index based on the cursor position.
- *
- * @param x The X coordinate position.
- * @param y The Y coordinate position.
- * @return The slot index on success, -1 on failure.
- */
- int getSlotIndex(int x, int y) const;
-
- int getSlotByXY(int x, int y) const;
-
- Inventory *mInventory;
- Image *mSelImg;
- Image *mProtectedImg;
- Image *mCellBackgroundImg;
- std::string mName;
-
- int *mShowMatrix;
- Skin *mSkin;
- ImageCollection *mVertexes;
- Color mEquipedColor;
- Color mEquipedColor2;
- Color mUnEquipedColor;
- Color mUnEquipedColor2;
- typedef std::list<SelectionListener*> SelectionListenerList;
- typedef SelectionListenerList::iterator SelectionListenerIterator;
- SelectionListenerList mSelectionListeners;
- int mGridColumns;
- int mGridRows;
- int mDrawRows;
- int mSelectedIndex;
- int mLastUsedSlot;
- int mTag;
- int mSortType;
- int mClicks;
- int mBoxWidth;
- int mBoxHeight;
- int mEquippedTextPadding;
- int mPaddingItemX;
- int mPaddingItemY;
- int mMaxColumns;
- SelectionState mSelectionStatus;
- ForceQuantity mForceQuantity;
- ShowEmptyRows mShowEmptyRows;
- bool mDescItems;
-};
-
-#endif // GUI_WIDGETS_ITEMCONTAINER_H
diff --git a/src/gui/widgets/itemlinkhandler.cpp b/src/gui/widgets/itemlinkhandler.cpp
deleted file mode 100644
index 403573daf..000000000
--- a/src/gui/widgets/itemlinkhandler.cpp
+++ /dev/null
@@ -1,223 +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 "gui/widgets/itemlinkhandler.h"
-
-#include "itemcolormanager.h"
-#include "settings.h"
-
-#include "gui/viewport.h"
-
-#include "gui/popups/itempopup.h"
-#include "gui/popups/popupmenu.h"
-
-#include "gui/widgets/createwidget.h"
-
-#include "gui/windows/confirmdialog.h"
-#include "gui/windows/helpwindow.h"
-#include "gui/windows/questswindow.h"
-
-#include "input/inputmanager.h"
-
-#include "utils/gettext.h"
-#include "utils/stringutils.h"
-
-#include "resources/db/itemdb.h"
-
-#include "listeners/inputactionremotelistener.h"
-#include "listeners/openurllistener.h"
-
-#include "debug.h"
-
-namespace
-{
- OpenUrlListener listener;
-} // namespace
-
-ItemLinkHandler::ItemLinkHandler() :
- LinkHandler(),
- mAllowCommands(true)
-{
-}
-
-ItemLinkHandler::~ItemLinkHandler()
-{
-}
-
-void ItemLinkHandler::handleCommandLink(const std::string &link,
- const std::string &prefix)
-{
- std::string cmd;
- std::string args;
-
- const std::string cmdStr = link.substr(prefix.size());
- if (!parse2Str(cmdStr, cmd, args))
- {
- cmd = cmdStr;
- args.clear();
- }
- if (mAllowCommands)
- {
- inputManager.executeRemoteChatCommand(cmd, args, nullptr);
- }
- else
- {
- inputActionRemoteListener.setCommand(cmd, args);
- ConfirmDialog *const confirmDlg = CREATEWIDGETR(ConfirmDialog,
- // TRANSLATORS: dialog message
- _("Run command"),
- strprintf("/%s %s", cmd.c_str(), args.c_str()),
- SOUND_REQUEST,
- false,
- Modal_true);
- confirmDlg->addActionListener(&inputActionRemoteListener);
- }
-}
-
-void ItemLinkHandler::handleHelpLink(const std::string &link)
-{
- if (helpWindow != nullptr)
- {
- helpWindow->loadHelp(link.substr(7));
- helpWindow->requestMoveToTop();
- }
-}
-
-void ItemLinkHandler::handleHttpLink(const std::string &link,
- const MouseEvent *const event)
-{
- if (event == nullptr)
- return;
- std::string url = link;
- replaceAll(url, " ", "");
- listener.url = url;
- const MouseButtonT button = event->getButton();
- if (button == MouseButton::LEFT)
- {
- ConfirmDialog *const confirmDlg = CREATEWIDGETR(ConfirmDialog,
- // TRANSLATORS: dialog message
- _("Open url"),
- url,
- SOUND_REQUEST,
- false,
- Modal_true);
- confirmDlg->addActionListener(&listener);
- }
- else if (button == MouseButton::RIGHT)
- {
- if (popupMenu != nullptr)
- popupMenu->showLinkPopup(url);
- }
-}
-
-void ItemLinkHandler::handleItemLink(const std::string &link)
-{
- if ((itemPopup == nullptr) || link.empty())
- return;
-
- const char ch = link[0];
- if (ch < '0' || ch > '9')
- return;
-
- STD_VECTOR<int> str;
- splitToIntVector(str, link, ',');
- if (str.empty())
- return;
-
- const int id = str[0];
-
- if (id > 0)
- {
- str.erase(str.begin());
- while (str.size() < maxCards)
- str.push_back(0);
- const ItemColor color =
- ItemColorManager::getColorFromCards(&str[0]);
-
- const ItemInfo &itemInfo = ItemDB::get(id);
- // +++ need add support for options.
- itemPopup->setItem(itemInfo, color, true, -1, &str[0], nullptr);
- if (itemPopup->isPopupVisible())
- {
- itemPopup->setVisible(Visible_false);
- }
- else if (viewport != nullptr)
- {
- itemPopup->position(viewport->mMouseX,
- viewport->mMouseY);
- }
- }
-}
-
-void ItemLinkHandler::handleSearchLink(const std::string &link)
-{
- if (helpWindow != nullptr)
- {
- helpWindow->search(link.substr(1));
- helpWindow->requestMoveToTop();
- }
-}
-
-void ItemLinkHandler::handleLink(const std::string &link,
- MouseEvent *const event)
-{
- if (link.empty())
- return;
-
- if (strStartWith(link, "http://") || strStartWith(link, "https://"))
- {
- handleHttpLink(link, event);
- }
- else if (link[0] == '?')
- {
- handleSearchLink(link);
- }
- else if (strStartWith(link, "help://"))
- {
- handleHelpLink(link);
- }
- else if (strStartWith(link, settings.linkCommandSymbol))
- {
- handleCommandLink(link, settings.linkCommandSymbol);
- }
- else if (strStartWith(link, "="))
- {
- handleCommandLink(link, "=");
- }
- else if (link == "news")
- {
- if (helpWindow != nullptr)
- helpWindow->loadHelpSimple("news");
- }
- else if (link == "copyright")
- {
- inputManager.executeAction(InputAction::WINDOW_ABOUT);
- }
- else if (link[0] == 'q')
- {
- questsWindow->selectQuest(atoi(link.substr(1).c_str()));
- }
- else
- {
- handleItemLink(link);
- }
-}
diff --git a/src/gui/widgets/itemlinkhandler.h b/src/gui/widgets/itemlinkhandler.h
deleted file mode 100644
index bc90f71d1..000000000
--- a/src/gui/widgets/itemlinkhandler.h
+++ /dev/null
@@ -1,61 +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 GUI_WIDGETS_ITEMLINKHANDLER_H
-#define GUI_WIDGETS_ITEMLINKHANDLER_H
-
-#include "gui/widgets/linkhandler.h"
-
-#include "localconsts.h"
-
-class ItemLinkHandler final : public LinkHandler
-{
- public:
- ItemLinkHandler();
-
- A_DELETE_COPY(ItemLinkHandler)
-
- ~ItemLinkHandler();
-
- void handleLink(const std::string &link,
- MouseEvent *event) override final;
-
- void setAllowCommands(const bool b)
- { mAllowCommands = b; }
-
- private:
- void handleCommandLink(const std::string &link,
- const std::string &prefix);
-
- static void handleHelpLink(const std::string &link);
-
- static void handleHttpLink(const std::string &link,
- const MouseEvent *const event);
-
- static void handleItemLink(const std::string &link);
-
- static void handleSearchLink(const std::string &link);
-
- bool mAllowCommands;
-};
-
-#endif // GUI_WIDGETS_ITEMLINKHANDLER_H
diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp
deleted file mode 100644
index 9f667caba..000000000
--- a/src/gui/widgets/itemshortcutcontainer.cpp
+++ /dev/null
@@ -1,650 +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 "gui/widgets/itemshortcutcontainer.h"
-
-#include "dragdrop.h"
-#include "settings.h"
-#include "spellmanager.h"
-
-#include "being/playerinfo.h"
-
-#include "input/inputmanager.h"
-
-#include "gui/viewport.h"
-
-#include "gui/fonts/font.h"
-
-#include "gui/shortcut/itemshortcut.h"
-#include "gui/shortcut/spellshortcut.h"
-
-#include "gui/popups/itempopup.h"
-#include "gui/popups/popupmenu.h"
-#include "gui/popups/skillpopup.h"
-#include "gui/popups/spellpopup.h"
-
-#include "gui/windows/inventorywindow.h"
-#include "gui/windows/skilldialog.h"
-
-#include "input/inputactionoperators.h"
-
-#include "const/resources/skill.h"
-
-#include "utils/stringutils.h"
-
-#include "debug.h"
-
-ItemShortcutContainer::ItemShortcutContainer(Widget2 *const widget,
- const unsigned number) :
- ShortcutContainer(widget),
- mItemClicked(false),
- mNumber(number),
- mEquipedColor(getThemeColor(ThemeColorId::ITEM_EQUIPPED)),
- mEquipedColor2(getThemeColor(ThemeColorId::ITEM_EQUIPPED_OUTLINE)),
- mUnEquipedColor(getThemeColor(ThemeColorId::ITEM_NOT_EQUIPPED)),
- mUnEquipedColor2(getThemeColor(ThemeColorId::ITEM_NOT_EQUIPPED_OUTLINE))
-{
- mMaxItems = ItemShortcut::getItemCount();
-}
-
-ItemShortcutContainer::~ItemShortcutContainer()
-{
-}
-
-void ItemShortcutContainer::setWidget2(const Widget2 *const widget)
-{
- Widget2::setWidget2(widget);
- mEquipedColor = getThemeColor(ThemeColorId::ITEM_EQUIPPED);
- mEquipedColor2 = getThemeColor(ThemeColorId::ITEM_EQUIPPED_OUTLINE);
- mUnEquipedColor = getThemeColor(ThemeColorId::ITEM_NOT_EQUIPPED);
- mUnEquipedColor2 = getThemeColor(ThemeColorId::ITEM_NOT_EQUIPPED_OUTLINE);
- mForegroundColor = getThemeColor(ThemeColorId::TEXT);
- mForegroundColor2 = getThemeColor(ThemeColorId::TEXT_OUTLINE);
-}
-
-void ItemShortcutContainer::draw(Graphics *const graphics)
-{
- BLOCK_START("ItemShortcutContainer::draw")
- const ItemShortcut *const selShortcut = itemShortcut[mNumber];
- if (selShortcut == nullptr)
- {
- BLOCK_END("ItemShortcutContainer::draw")
- return;
- }
-
- if (settings.guiAlpha != mAlpha)
- {
- if (mBackgroundImg != nullptr)
- mBackgroundImg->setAlpha(mAlpha);
- mAlpha = settings.guiAlpha;
- }
-
- Font *const font = getFont();
- drawBackground(graphics);
-
- const Inventory *const inv = PlayerInfo::getInventory();
- if (inv == nullptr)
- {
- BLOCK_END("ItemShortcutContainer::draw")
- return;
- }
-
- // +++ for future usage need reorder drawing images before text or back
- for (unsigned i = 0; i < mMaxItems; i++)
- {
- const int itemX = (i % mGridWidth) * mBoxWidth;
- const int itemY = (i / mGridWidth) * mBoxHeight;
-
- // Draw item keyboard shortcut.
- const std::string key = inputManager.getKeyValueString(
- InputAction::SHORTCUT_1 + i);
- font->drawString(graphics,
- mForegroundColor,
- mForegroundColor,
- key,
- itemX + 2, itemY + 2);
-
- const int itemId = selShortcut->getItem(i);
- const ItemColor itemColor = selShortcut->getItemColor(i);
-
- if (itemId < 0)
- continue;
-
- // this is item
- if (itemId < SPELL_MIN_ID)
- {
- const Item *const item = inv->findItem(itemId, itemColor);
- if (item != nullptr)
- {
- // Draw item icon.
- Image *const image = item->getImage();
- if (image != nullptr)
- {
- std::string caption;
- if (item->getQuantity() > 1)
- caption = toString(item->getQuantity());
- else if (item->isEquipped() == Equipped_true)
- caption = "Eq.";
-
- image->setAlpha(1.0F);
- graphics->drawImage(image, itemX, itemY);
- if (item->isEquipped() == Equipped_true)
- {
- font->drawString(graphics,
- mEquipedColor,
- mEquipedColor2,
- caption,
- itemX + (mBoxWidth - font->getWidth(caption)) / 2,
- itemY + mBoxHeight - 14);
- }
- else
- {
- font->drawString(graphics,
- mUnEquipedColor,
- mUnEquipedColor2,
- caption,
- itemX + (mBoxWidth - font->getWidth(caption)) / 2,
- itemY + mBoxHeight - 14);
- }
- }
- }
- }
- else if (itemId < SKILL_MIN_ID && (spellManager != nullptr))
- { // this is magic shortcut
- const TextCommand *const spell = spellManager
- ->getSpellByItem(itemId);
- if (spell != nullptr)
- {
- if (!spell->isEmpty())
- {
- Image *const image = spell->getImage();
-
- if (image != nullptr)
- {
- image->setAlpha(1.0F);
- graphics->drawImage(image, itemX, itemY);
- }
- }
-
- font->drawString(graphics,
- mForegroundColor,
- mForegroundColor,
- spell->getSymbol(),
- itemX + 2, itemY + mBoxHeight / 2);
- }
- }
- else if (skillDialog != nullptr)
- {
- const SkillInfo *const skill = skillDialog->getSkill(
- itemId - SKILL_MIN_ID);
- if (skill != nullptr)
- {
- Image *const image = skill->data->icon;
-
- if (image != nullptr)
- {
- image->setAlpha(1.0F);
- graphics->drawImage(image, itemX, itemY);
- }
- if (!skill->data->haveIcon)
- {
- font->drawString(graphics,
- mForegroundColor,
- mForegroundColor,
- skill->data->shortName,
- itemX + 2,
- itemY + mBoxHeight / 2);
- }
- }
- }
- }
- BLOCK_END("ItemShortcutContainer::draw")
-}
-
-void ItemShortcutContainer::safeDraw(Graphics *const graphics)
-{
- BLOCK_START("ItemShortcutContainer::draw")
- const ItemShortcut *const selShortcut = itemShortcut[mNumber];
- if (selShortcut == nullptr)
- {
- BLOCK_END("ItemShortcutContainer::draw")
- return;
- }
-
- if (settings.guiAlpha != mAlpha)
- {
- if (mBackgroundImg != nullptr)
- mBackgroundImg->setAlpha(mAlpha);
- mAlpha = settings.guiAlpha;
- }
-
- Font *const font = getFont();
- safeDrawBackground(graphics);
-
- const Inventory *const inv = PlayerInfo::getInventory();
- if (inv == nullptr)
- {
- BLOCK_END("ItemShortcutContainer::draw")
- return;
- }
-
- // +++ for future usage need reorder drawing images before text or back
- for (unsigned i = 0; i < mMaxItems; i++)
- {
- const int itemX = (i % mGridWidth) * mBoxWidth;
- const int itemY = (i / mGridWidth) * mBoxHeight;
-
- // Draw item keyboard shortcut.
- const std::string key = inputManager.getKeyValueString(
- InputAction::SHORTCUT_1 + i);
- font->drawString(graphics,
- mForegroundColor,
- mForegroundColor,
- key,
- itemX + 2, itemY + 2);
-
- const int itemId = selShortcut->getItem(i);
- const ItemColor itemColor = selShortcut->getItemColor(i);
-
- if (itemId < 0)
- continue;
-
- // this is item
- if (itemId < SPELL_MIN_ID)
- {
- const Item *const item = inv->findItem(itemId, itemColor);
- if (item != nullptr)
- {
- // Draw item icon.
- Image *const image = item->getImage();
- if (image != nullptr)
- {
- std::string caption;
- if (item->getQuantity() > 1)
- caption = toString(item->getQuantity());
- else if (item->isEquipped() == Equipped_true)
- caption = "Eq.";
-
- image->setAlpha(1.0F);
- graphics->drawImage(image, itemX, itemY);
- if (item->isEquipped() == Equipped_true)
- {
- font->drawString(graphics,
- mEquipedColor,
- mEquipedColor2,
- caption,
- itemX + (mBoxWidth - font->getWidth(caption)) / 2,
- itemY + mBoxHeight - 14);
- }
- else
- {
- font->drawString(graphics,
- mUnEquipedColor,
- mUnEquipedColor2,
- caption,
- itemX + (mBoxWidth - font->getWidth(caption)) / 2,
- itemY + mBoxHeight - 14);
- }
- }
- }
- }
- else if (itemId < SKILL_MIN_ID && (spellManager != nullptr))
- { // this is magic shortcut
- const TextCommand *const spell = spellManager
- ->getSpellByItem(itemId);
- if (spell != nullptr)
- {
- if (!spell->isEmpty())
- {
- Image *const image = spell->getImage();
-
- if (image != nullptr)
- {
- image->setAlpha(1.0F);
- graphics->drawImage(image, itemX, itemY);
- }
- }
-
- font->drawString(graphics,
- mForegroundColor,
- mForegroundColor,
- spell->getSymbol(),
- itemX + 2, itemY + mBoxHeight / 2);
- }
- }
- else if (skillDialog != nullptr)
- {
- const SkillInfo *const skill = skillDialog->getSkill(
- itemId - SKILL_MIN_ID);
- if (skill != nullptr)
- {
- Image *const image = skill->data->icon;
-
- if (image != nullptr)
- {
- image->setAlpha(1.0F);
- graphics->drawImage(image, itemX, itemY);
- }
- if (!skill->data->haveIcon)
- {
- font->drawString(graphics,
- mForegroundColor,
- mForegroundColor,
- skill->data->shortName,
- itemX + 2,
- itemY + mBoxHeight / 2);
- }
- }
- }
- }
- BLOCK_END("ItemShortcutContainer::draw")
-}
-
-void ItemShortcutContainer::mouseDragged(MouseEvent &event)
-{
- if (mNumber == SHORTCUT_AUTO_TAB)
- return;
- ItemShortcut *const selShortcut = itemShortcut[mNumber];
- if (selShortcut == nullptr)
- return;
-
- if (event.getButton() == MouseButton::LEFT)
- {
- if (dragDrop.isEmpty() && mItemClicked)
- {
- mItemClicked = false;
-
- const int index = getIndexFromGrid(event.getX(), event.getY());
- if (index == -1)
- return;
-
- const int itemId = selShortcut->getItem(index);
- const ItemColor itemColor = selShortcut->getItemColor(index);
-
- if (itemId < 0)
- return;
-
- event.consume();
- if (itemId < SPELL_MIN_ID)
- { // items
- if (PlayerInfo::getInventory() == nullptr)
- return;
-
- const Item *const item = PlayerInfo::getInventory()->findItem(
- itemId, itemColor);
-
- if (item != nullptr)
- {
- selShortcut->removeItem(index);
- dragDrop.dragItem(item, DragDropSource::Shortcuts, index);
- }
- else
- {
- dragDrop.clear();
- }
- }
- else if (itemId < SKILL_MIN_ID)
- { // spells/commands
- if (spellManager == nullptr)
- {
- dragDrop.clear();
- return;
- }
-
- const TextCommand *const spell = spellManager->getSpellByItem(
- itemId);
- if (spell != nullptr)
- {
- selShortcut->removeItem(index);
- dragDrop.dragCommand(spell,
- DragDropSource::Shortcuts, index);
- dragDrop.setItem(itemId);
- }
- else
- {
- dragDrop.clear();
- }
- }
- else
- { // skills
- if (skillDialog == nullptr)
- {
- dragDrop.clear();
- return;
- }
- const SkillInfo *const skill
- = skillDialog->getSkillByItem(itemId);
- if (skill != nullptr)
- {
- const std::string itemData = selShortcut->getItemData(
- index);
- selShortcut->removeItem(index);
- dragDrop.dragSkill(skill,
- DragDropSource::Shortcuts,
- index);
- dragDrop.setItem(itemId);
- dragDrop.setItemColor(itemColor);
- dragDrop.setItemData(itemData);
- }
- else
- {
- dragDrop.clear();
- }
- }
- }
- }
-}
-
-void ItemShortcutContainer::mousePressed(MouseEvent &event)
-{
- ItemShortcut *const selShortcut = itemShortcut[mNumber];
- if (selShortcut == nullptr)
- return;
-
- const int index = getIndexFromGrid(event.getX(), event.getY());
-
- if (index == -1)
- return;
-
- if (event.getButton() == MouseButton::LEFT)
- {
- event.consume();
- // Stores the selected item if theirs one.
- if (selShortcut->isItemSelected() && (inventoryWindow != nullptr) &&
- (inventoryWindow->isWindowVisible()
- || selShortcut->getSelectedItem() >= SPELL_MIN_ID))
- {
- selShortcut->setItem(index);
- selShortcut->setItemSelected(-1);
- if (spellShortcut != nullptr)
- spellShortcut->setItemSelected(-1);
- inventoryWindow->unselectItem();
- }
- else if (selShortcut->getItem(index) != 0)
- {
- mItemClicked = true;
- }
- }
- else if (event.getButton() == MouseButton::RIGHT)
- {
- event.consume();
- if (popupMenu != nullptr &&
- viewport != nullptr)
- {
- popupMenu->showItemPopup(viewport->mMouseX,
- viewport->mMouseY,
- selShortcut->getItem(index),
- selShortcut->getItemColor(index));
- }
- }
-}
-
-void ItemShortcutContainer::mouseReleased(MouseEvent &event)
-{
- ItemShortcut *const selShortcut = itemShortcut[mNumber];
- if (selShortcut == nullptr)
- return;
-
- if (event.getButton() == MouseButton::LEFT)
- {
- if (selShortcut->isItemSelected())
- selShortcut->setItemSelected(-1);
-
- const int index = getIndexFromGrid(event.getX(), event.getY());
- if (index == -1)
- return;
-
- if (dragDrop.isEmpty())
- {
- if ((selShortcut->getItem(index) != 0) && mItemClicked)
- selShortcut->useItem(index);
- }
- else
- {
- if (dragDrop.getSource() == DragDropSource::Shortcuts)
- {
- const int oldIndex = dragDrop.getTag();
- selShortcut->setItem(oldIndex, dragDrop.getItem(),
- dragDrop.getItemColor());
- selShortcut->swap(oldIndex, index);
- }
- else
- {
- selShortcut->setItemData(index,
- dragDrop.getItemData());
- selShortcut->setItem(index, dragDrop.getItem(),
- dragDrop.getItemColor());
- }
- dragDrop.clear();
- dragDrop.deselect();
- }
-
- mItemClicked = false;
- }
-}
-
-void ItemShortcutContainer::mouseMoved(MouseEvent &event)
-{
- const ItemShortcut *const selShortcut = itemShortcut[mNumber];
- if (selShortcut == nullptr)
- return;
-
- const int index = getIndexFromGrid(event.getX(), event.getY());
-
- if (index == -1)
- return;
-
- const int itemId = selShortcut->getItem(index);
- const ItemColor itemColor = selShortcut->getItemColor(index);
-
- if (itemId < 0)
- return;
-
- if (itemId < SPELL_MIN_ID)
- {
- skillPopup->setVisible(Visible_false);
- spellPopup->setVisible(Visible_false);
-
- Inventory *const inv = PlayerInfo::getInventory();
- if (inv == nullptr)
- return;
-
- const Item *const item = inv->findItem(itemId, itemColor);
- if ((item != nullptr) && (viewport != nullptr))
- {
- itemPopup->setItem(item, false);
- itemPopup->position(viewport->mMouseX, viewport->mMouseY);
- }
- else
- {
- itemPopup->setVisible(Visible_false);
- }
- }
- else if (itemId < SKILL_MIN_ID && (spellManager != nullptr))
- {
- skillPopup->setVisible(Visible_false);
- itemPopup->setVisible(Visible_false);
- const TextCommand *const spell = spellManager->getSpellByItem(itemId);
- if ((spell != nullptr) && (viewport != nullptr))
- {
- spellPopup->setItem(spell);
- spellPopup->view(viewport->mMouseX,
- viewport->mMouseY);
- }
- else
- {
- spellPopup->setVisible(Visible_false);
- }
- }
- else if (skillDialog != nullptr)
- {
- itemPopup->setVisible(Visible_false);
- spellPopup->setVisible(Visible_false);
- const SkillInfo *const skill = skillDialog->getSkillByItem(itemId);
- if (skill == nullptr)
- return;
-
- const std::string data = selShortcut->getItemData(index);
- CastTypeT castType = CastType::Default;
- int offsetX = 0;
- int offsetY = 0;
- if (!data.empty())
- {
- STD_VECTOR<int> vect;
- splitToIntVector(vect, data, ' ');
- const size_t sz = vect.size();
- if (sz > 0)
- castType = static_cast<CastTypeT>(vect[0]);
- if (sz > 2)
- {
- offsetX = vect[1];
- offsetY = vect[2];
- }
- }
- skillPopup->show(skill,
- toInt(itemColor, int),
- castType,
- offsetX,
- offsetY);
- skillPopup->position(viewport->mMouseX,
- viewport->mMouseY);
- }
-}
-
-// Hide ItemTooltip
-void ItemShortcutContainer::mouseExited(MouseEvent &event A_UNUSED)
-{
- if (itemPopup != nullptr)
- itemPopup->setVisible(Visible_false);
- if (spellPopup != nullptr)
- spellPopup->setVisible(Visible_false);
- if (skillPopup != nullptr)
- skillPopup->setVisible(Visible_false);
-}
-
-void ItemShortcutContainer::widgetHidden(const Event &event A_UNUSED)
-{
- if (itemPopup != nullptr)
- itemPopup->setVisible(Visible_false);
- if (spellPopup != nullptr)
- spellPopup->setVisible(Visible_false);
-}
diff --git a/src/gui/widgets/itemshortcutcontainer.h b/src/gui/widgets/itemshortcutcontainer.h
deleted file mode 100644
index 146834f4d..000000000
--- a/src/gui/widgets/itemshortcutcontainer.h
+++ /dev/null
@@ -1,89 +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 GUI_WIDGETS_ITEMSHORTCUTCONTAINER_H
-#define GUI_WIDGETS_ITEMSHORTCUTCONTAINER_H
-
-#include "gui/widgets/shortcutcontainer.h"
-
-/**
- * An item shortcut container. Used to quickly use items.
- *
- * \ingroup GUI
- */
-class ItemShortcutContainer final : public ShortcutContainer
-{
- public:
- /**
- * Constructor. Initializes the graphic.
- */
- ItemShortcutContainer(Widget2 *const widget,
- const unsigned number);
-
- A_DELETE_COPY(ItemShortcutContainer)
-
- /**
- * Destructor.
- */
- ~ItemShortcutContainer();
-
- /**
- * Draws the items.
- */
- void draw(Graphics *const graphics) override final A_NONNULL(2);
-
- void safeDraw(Graphics *const graphics) override final A_NONNULL(2);
-
- /**
- * Handles mouse when dragged.
- */
- void mouseDragged(MouseEvent &event) override final;
-
- /**
- * Handles mouse when pressed.
- */
- void mousePressed(MouseEvent &event) override final;
-
- /**
- * Handles mouse release.
- */
- void mouseReleased(MouseEvent &event) override final;
-
- void widgetHidden(const Event &event) override final;
-
- void mouseExited(MouseEvent &event) override final;
-
- void mouseMoved(MouseEvent &event) override final;
-
- void setWidget2(const Widget2 *const widget) override final;
-
- private:
- bool mItemClicked;
- unsigned mNumber;
-
- Color mEquipedColor;
- Color mEquipedColor2;
- Color mUnEquipedColor;
- Color mUnEquipedColor2;
-};
-
-#endif // GUI_WIDGETS_ITEMSHORTCUTCONTAINER_H
diff --git a/src/gui/widgets/label.cpp b/src/gui/widgets/label.cpp
deleted file mode 100644
index aeacddbdb..000000000
--- a/src/gui/widgets/label.cpp
+++ /dev/null
@@ -1,292 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "gui/widgets/label.h"
-
-#include "gui/gui.h"
-#include "gui/skin.h"
-
-#include "gui/fonts/font.h"
-
-#include "debug.h"
-
-Skin *Label::mSkin = nullptr;
-int Label::mInstances = 0;
-
-Label::Label(const Widget2 *const widget) :
- Widget(widget),
- WidgetListener(),
- ToolTipListener(),
- mCaption(),
- mTextChunk(),
- mAlignment(Graphics::LEFT),
- mPadding(0),
- mTextChanged(true)
-{
- init();
-}
-
-Label::Label(const Widget2 *const widget,
- const std::string &caption) :
- Widget(widget),
- WidgetListener(),
- ToolTipListener(),
- mCaption(caption),
- mTextChunk(),
- mAlignment(Graphics::LEFT),
- mPadding(0),
- mTextChanged(true)
-{
- const Font *const font = getFont();
- setWidth(font->getWidth(caption));
- setHeight(font->getHeight());
- init();
-}
-
-Label::~Label()
-{
- if (mWindow != nullptr)
- mWindow->removeWidgetListener(this);
-
- if (gui != nullptr)
- gui->removeDragged(this);
-
- mInstances --;
- if (mInstances == 0)
- {
- if (theme != nullptr)
- theme->unload(mSkin);
- }
- removeMouseListener(this);
- mTextChunk.deleteImage();
-}
-
-void Label::init()
-{
- addMouseListener(this);
- mAllowLogic = false;
- mForegroundColor = getThemeColor(ThemeColorId::LABEL);
- mForegroundColor2 = getThemeColor(ThemeColorId::LABEL_OUTLINE);
- if (mInstances == 0)
- {
- if (theme != nullptr)
- mSkin = theme->load("label.xml", "");
- }
- mInstances ++;
-
- if (mSkin != nullptr)
- mPadding = mSkin->getPadding();
- else
- mPadding = 0;
- setSelectable(false);
-}
-
-void Label::draw(Graphics *const graphics)
-{
- BLOCK_START("Label::draw")
- int textX;
- const Rect &rect = mDimension;
- const int textY = rect.height / 2 - getFont()->getHeight() / 2;
- Font *const font = getFont();
-
- switch (mAlignment)
- {
- case Graphics::LEFT:
- default:
- textX = mPadding;
- break;
- case Graphics::CENTER:
- textX = (rect.width - font->getWidth(mCaption)) / 2;
- break;
- case Graphics::RIGHT:
- if (rect.width > mPadding)
- textX = rect.width - mPadding - font->getWidth(mCaption);
- else
- textX = 0;
- break;
- }
-
- if (mTextChanged)
- {
- mTextChunk.textFont = font;
- mTextChunk.deleteImage();
- mTextChunk.text = mCaption;
- mTextChunk.color = mForegroundColor;
- mTextChunk.color2 = mForegroundColor2;
- font->generate(mTextChunk);
- mTextChanged = false;
- }
-
- const Image *const image = mTextChunk.img;
- if (image != nullptr)
- graphics->drawImage(image, textX, textY);
- BLOCK_END("Label::draw")
-}
-
-void Label::safeDraw(Graphics *const graphics)
-{
- Label::draw(graphics);
-}
-
-void Label::adjustSize()
-{
- const Font *const font = getFont();
- const int pad2 = 2 * mPadding;
- setWidth(font->getWidth(mCaption) + pad2);
- setHeight(font->getHeight() + pad2);
-}
-
-void Label::setForegroundColor(const Color &color)
-{
- if (mForegroundColor != color || mForegroundColor2 != color)
- mTextChanged = true;
-// logger->log("Label::setForegroundColor: " + mCaption);
- mForegroundColor = color;
- mForegroundColor2 = color;
-}
-
-void Label::setForegroundColorAll(const Color &color1,
- const Color &color2)
-{
- if (mForegroundColor != color1 || mForegroundColor2 != color2)
- mTextChanged = true;
-// logger->log("Label::setForegroundColorAll: " + mCaption);
- mForegroundColor = color1;
- mForegroundColor2 = color2;
-}
-
-void Label::resizeTo(const int maxSize, const int minSize)
-{
- const Font *const font = getFont();
- const int pad2 = 2 * mPadding;
- setHeight(font->getHeight() + pad2);
-
- if (font->getWidth(mCaption) + pad2 > maxSize)
- {
- const int dots = font->getWidth("...");
- if (dots > maxSize)
- {
- setWidth(maxSize);
- return;
- }
- const size_t szChars = mCaption.size();
- for (size_t f = 1; f < szChars - 1; f ++)
- {
- const std::string text = mCaption.substr(0, szChars - f);
- const int width = font->getWidth(text) + dots + pad2;
- if (width <= maxSize)
- {
- setCaption(text + "...");
- setWidth(width);
- return;
- }
- }
- setWidth(maxSize);
- }
- else
- {
- int sz = font->getWidth(mCaption) + pad2;
- if (sz < minSize)
- sz = minSize;
- setWidth(sz);
- }
-}
-
-void Label::setCaption(const std::string& caption)
-{
- if (caption != mCaption)
- mTextChanged = true;
- mCaption = caption;
-}
-
-void Label::setParent(Widget *const widget)
-{
- if (mWindow != nullptr)
- mWindow->addWidgetListener(this);
- Widget::setParent(widget);
-}
-
-void Label::setWindow(Widget *const widget)
-{
- if ((widget == nullptr) && (mWindow != nullptr))
- {
- mWindow->removeWidgetListener(this);
- mWindow = nullptr;
- }
- else
- {
- Widget2::setWindow(widget);
- }
-}
-
-void Label::widgetHidden(const Event &event A_UNUSED)
-{
- mTextChanged = true;
- mTextChunk.deleteImage();
-}
-
-void Label::finalCleanup()
-{
- mSkin = nullptr;
-}
diff --git a/src/gui/widgets/label.h b/src/gui/widgets/label.h
deleted file mode 100644
index 26790258c..000000000
--- a/src/gui/widgets/label.h
+++ /dev/null
@@ -1,195 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GUI_WIDGETS_LABEL_H
-#define GUI_WIDGETS_LABEL_H
-
-#include "gui/fonts/textchunk.h"
-
-#include "gui/widgets/widget.h"
-
-#include "listeners/tooltiplistener.h"
-#include "listeners/widgetlistener.h"
-
-#include "render/graphics.h"
-
-#include "localconsts.h"
-
-class Skin;
-
-/**
- * Label widget. Same as the Guichan label but modified to use the palette
- * system.
- *
- * \ingroup GUI
- */
-class Label final : public Widget,
- public WidgetListener,
- public ToolTipListener
-{
- public:
- /**
- * Constructor.
- */
- explicit Label(const Widget2 *const widget);
-
- /**
- * Constructor. This version of the constructor sets the label with an
- * inintialization string.
- */
- Label(const Widget2 *const widget,
- const std::string &caption);
-
- A_DELETE_COPY(Label)
-
- ~Label();
-
- void init();
-
- /**
- * Draws the label.
- */
- void draw(Graphics *const graphics) override final A_NONNULL(2);
-
- void safeDraw(Graphics *const graphics) override final A_NONNULL(2);
-
- void adjustSize();
-
- void setForegroundColor(const Color &color);
-
- void setForegroundColorAll(const Color &color1,
- const Color &color2);
-
- void resizeTo(const int maxSize, const int minSize);
-
- /**
- * Gets the caption of the label.
- *
- * @return The caption of the label.
- * @see setCaption
- */
- const std::string &getCaption() const
- { return mCaption; }
-
- /**
- * Sets the caption of the label. It's advisable to call
- * adjustSize after setting of the caption to adjust the
- * label's size to fit the caption.
- *
- * @param caption The caption of the label.
- * @see getCaption, adjustSize
- */
- void setCaption(const std::string& caption);
-
- /**
- * Sets the alignment of the caption. The alignment is relative
- * to the center of the label.
- *
- * @param alignment The alignment of the caption of the label.
- * @see getAlignment, Graphics
- */
- void setAlignment(Graphics::Alignment alignment)
- { mAlignment = alignment; }
-
- /**
- * Gets the alignment of the caption. The alignment is relative to
- * the center of the label.
- *
- * @return The alignment of caption of the label.
- * @see setAlignmentm Graphics
- */
- Graphics::Alignment getAlignment() const
- { return mAlignment; }
-
- void setParent(Widget *const widget) override final;
-
- void setWindow(Widget *const widget) override final;
-
- void widgetHidden(const Event &event) override final;
-
- static Skin *mSkin;
-
- static int mInstances;
-
- static void finalCleanup();
-
- private:
- /**
- * Holds the caption of the label.
- */
- std::string mCaption;
-
- TextChunk mTextChunk;
-
- /**
- * Holds the alignment of the caption.
- */
- Graphics::Alignment mAlignment;
-
- int mPadding;
-
- bool mTextChanged;
-};
-
-#endif // GUI_WIDGETS_LABEL_H
diff --git a/src/gui/widgets/layout.cpp b/src/gui/widgets/layout.cpp
deleted file mode 100644
index 0a9464dd2..000000000
--- a/src/gui/widgets/layout.cpp
+++ /dev/null
@@ -1,46 +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 "gui/widgets/layout.h"
-
-#include "debug.h"
-
-Layout::Layout() :
- LayoutCell(),
- mComputed(false)
-{
- getArray();
- setPadding(6);
-}
-
-void Layout::reflow(int &restrict nw, int &restrict nh)
-{
- if (!mComputed)
- {
- computeSizes();
- mComputed = true;
- }
-
- nw = (nw == 0 ? mSize[0] + 2 * mHPadding : nw);
- nh = (nh == 0 ? mSize[1] + 2 * mVPadding : nh);
- LayoutCell::reflow(0, 0, nw, nh);
-}
diff --git a/src/gui/widgets/layout.h b/src/gui/widgets/layout.h
deleted file mode 100644
index 4e9c8f8c3..000000000
--- a/src/gui/widgets/layout.h
+++ /dev/null
@@ -1,66 +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 GUI_WIDGETS_LAYOUT_H
-#define GUI_WIDGETS_LAYOUT_H
-
-#include "gui/widgets/layoutcell.h"
-
-#include "localconsts.h"
-
-/**
- * This class is an helper for setting the position of widgets. They are
- * positioned along the cells of some rectangular tables. The layout may either
- * be a single table or a tree of nested tables.
- *
- * The size of a given table column can either be set manually or be chosen
- * from the widest widget of the column. An empty column has a AUTO_DEF width,
- * which means it will be extended so that the layout fits its minimum width.
- *
- * The process is similar for table rows. By default, there is a spacing of 4
- * pixels between rows and between columns, and a margin of 6 pixels around the
- * whole layout.
- */
-class Layout final : public LayoutCell
-{
- public:
- Layout();
-
- A_DELETE_COPY(Layout)
-
- /**
- * Sets the margin around the layout.
- */
- void setMargin(int m)
- { setPadding(m); }
-
- /**
- * Sets the positions of all the widgets.
- * @see LayoutArray::reflow
- */
- void reflow(int &restrict nW, int &restrict nH);
-
- private:
- bool mComputed;
-};
-
-#endif // GUI_WIDGETS_LAYOUT_H
diff --git a/src/gui/widgets/layoutarray.cpp b/src/gui/widgets/layoutarray.cpp
deleted file mode 100644
index 6269d8b5b..000000000
--- a/src/gui/widgets/layoutarray.cpp
+++ /dev/null
@@ -1,313 +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 "gui/widgets/layoutarray.h"
-
-#include "enums/gui/layouttype.h"
-
-#include "gui/widgets/layoutcell.h"
-#include "gui/widgets/widget.h"
-
-#include <cassert>
-
-#include "debug.h"
-
-LayoutArray::LayoutArray() :
- mCells(),
- mSpacing(4)
-{
-}
-
-LayoutArray::~LayoutArray()
-{
- STD_VECTOR <STD_VECTOR <LayoutCell *> >::iterator
- i = mCells.begin();
- const STD_VECTOR <STD_VECTOR <LayoutCell *> >::iterator
- i_end = mCells.end();
- while (i != i_end)
- {
- STD_VECTOR< LayoutCell * >::iterator j = i->begin();
- const STD_VECTOR< LayoutCell * >::iterator j_end = i->end();
- while (j != j_end)
- {
- delete *j;
- ++j;
- }
- ++i;
- }
-}
-
-LayoutCell &LayoutArray::at(const int x, const int y,
- const int w, const int h)
-{
- resizeGrid(x + w, y + h);
- LayoutCell *&cell = mCells[CAST_SIZE(y)][static_cast<size_t>(x)];
- if (cell == nullptr)
- cell = new LayoutCell;
- return *cell;
-}
-
-void LayoutArray::resizeGrid(int w, const int h)
-{
- const bool extW = (w != 0) && w > CAST_S32(mSizes[0].size());
- const bool extH = (h != 0) && h > CAST_S32(mSizes[1].size());
-
- if (!extW && !extH)
- return;
-
- if (extH)
- {
- mSizes[1].resize(CAST_SIZE(h), LayoutType::DEF);
- mCells.resize(CAST_SIZE(h));
- if (!extW)
- w = CAST_S32(mSizes[0].size());
- }
-
- if (extW)
- mSizes[0].resize(CAST_SIZE(w), LayoutType::DEF);
-
- STD_VECTOR <STD_VECTOR <LayoutCell *> >::iterator
- i = mCells.begin();
- const STD_VECTOR <STD_VECTOR <LayoutCell *> >::iterator
- i_end = mCells.end();
- while (i != i_end)
- {
- i->resize(CAST_SIZE(w), nullptr);
- ++i;
- }
-}
-
-void LayoutArray::setColWidth(const int n, const int w)
-{
- resizeGrid(n + 1, 0);
- mSizes[0U][CAST_SIZE(n)] = w;
-}
-
-void LayoutArray::setRowHeight(const int n, const int h)
-{
- resizeGrid(0, n + 1);
- mSizes[1][CAST_SIZE(n)] = h;
-}
-
-void LayoutArray::matchColWidth(const int n1, const int n2)
-{
- resizeGrid(std::max(n1, n2) + 1, 0);
- const STD_VECTOR<int> widths = getSizes(0, LayoutType::DEF);
- const int s = std::max(widths[CAST_SIZE(n1)],
- widths[CAST_SIZE(n2)]);
- mSizes[0][CAST_SIZE(n1)] = s;
- mSizes[0][CAST_SIZE(n2)] = s;
-}
-
-void LayoutArray::extend(const int x, const int y, const int w, const int h)
-{
- LayoutCell &cell = at(x, y, w, h);
- cell.mExtent[0] = w;
- cell.mExtent[1] = h;
-}
-
-LayoutCell &LayoutArray::place(Widget *const widget, const int x,
- const int y, const int w, const int h)
-{
- LayoutCell &cell = at(x, y, w, h);
- assert(cell.mType == LayoutCell::NONE);
- cell.mType = LayoutCell::WIDGET;
- cell.mWidget = widget;
- if (widget != nullptr)
- {
- cell.mSize[0] = w == 1 ? widget->getWidth() : 0;
- cell.mSize[1] = h == 1 ? widget->getHeight() : 0;
- }
- else
- {
- cell.mSize[0] = 1;
- cell.mSize[1] = 1;
- }
- cell.mExtent[0] = w;
- cell.mExtent[1] = h;
- cell.mHPadding = 0;
- cell.mVPadding = 0;
- cell.mAlign[0] = LayoutCell::FILL;
- cell.mAlign[1] = LayoutCell::FILL;
- int &cs = mSizes[0][CAST_SIZE(x)];
- int &rs = mSizes[1][CAST_SIZE(y)];
- if (cs == LayoutType::DEF && w == 1)
- cs = 0;
- if (rs == LayoutType::DEF && h == 1)
- rs = 0;
- return cell;
-}
-
-void LayoutArray::align(int &restrict pos, int &restrict size, const int dim,
- LayoutCell const &restrict cell,
- const int *restrict const sizes,
- const int sizeCount) const
-{
- if (dim < 0 || dim >= 2)
- return;
- int size_max = sizes[0];
- int cnt = cell.mExtent[dim];
- if ((sizeCount != 0) && cell.mExtent[dim] > sizeCount)
- cnt = sizeCount;
-
- for (int i = 1; i < cnt; ++i)
- size_max += sizes[i] + mSpacing;
- size = std::min<int>(cell.mSize[dim], size_max);
-
- switch (cell.mAlign[dim])
- {
- case LayoutCell::LEFT:
- return;
- case LayoutCell::RIGHT:
- pos += size_max - size;
- return;
- case LayoutCell::CENTER:
- pos += (size_max - size) / 2;
- return;
- case LayoutCell::FILL:
- size = size_max;
- return;
- default:
- logger->log1("LayoutArray::align unknown layout");
- return;
- }
-}
-
-STD_VECTOR<int> LayoutArray::getSizes(const int dim, int upp) const
-{
- if (dim < 0 || dim >= 2)
- return mSizes[1];
-
- const int gridW = CAST_S32(mSizes[0].size());
- const int gridH = CAST_S32(mSizes[1].size());
- STD_VECTOR<int> sizes = mSizes[dim];
-
- // Compute minimum sizes.
- for (int gridY = 0; gridY < gridH; ++gridY)
- {
- for (int gridX = 0; gridX < gridW; ++gridX)
- {
- const LayoutCell *const cell = mCells[CAST_SIZE(gridY)]
- [CAST_SIZE(gridX)];
- if ((cell == nullptr) || cell->mType == LayoutCell::NONE)
- continue;
-
- if (cell->mExtent[dim] == 1)
- {
- const int n = (dim == 0 ? gridX : gridY);
- const int s = cell->mSize[dim] + cell->mVPadding * 2;
- if (s > sizes[CAST_SIZE(n)])
- sizes[CAST_SIZE(n)] = s;
- }
- }
- }
-
- if (upp == LayoutType::DEF)
- return sizes;
-
- // Compute the FILL sizes.
- const int nb = CAST_S32(sizes.size());
- int nbFill = 0;
- for (int i = 0; i < nb; ++i)
- {
- if (mSizes[CAST_SIZE(dim)][static_cast<size_t>(i)]
- <= LayoutType::DEF)
- {
- ++nbFill;
- if (mSizes[CAST_SIZE(dim)][static_cast<size_t>(i)] ==
- LayoutType::SET ||
- sizes[CAST_SIZE(i)] <= LayoutType::DEF)
- {
- sizes[CAST_SIZE(i)] = 0;
- }
- }
- upp -= sizes[CAST_SIZE(i)] + mSpacing;
- }
- upp = upp + mSpacing;
-
- if (nbFill == 0)
- return sizes;
-
- for (int i = 0; i < nb; ++i)
- {
- if (mSizes[CAST_SIZE(dim)][static_cast<size_t>(i)] >
- LayoutType::DEF)
- {
- continue;
- }
-
- const int s = upp / nbFill;
- sizes[CAST_SIZE(i)] += s;
- upp -= s;
- --nbFill;
- }
-
- return sizes;
-}
-
-int LayoutArray::getSize(const int dim) const
-{
- STD_VECTOR<int> sizes = getSizes(dim, LayoutType::DEF);
- int size = 0;
- const int nb = CAST_S32(sizes.size());
- for (int i = 0; i < nb; ++i)
- {
- if (sizes[CAST_SIZE(i)] > LayoutType::DEF)
- size += sizes[CAST_SIZE(i)];
- size += mSpacing;
- }
- return size - mSpacing;
-}
-
-void LayoutArray::reflow(const int nx, const int ny,
- const int nw, const int nh)
-{
- const int gridW = CAST_S32(mSizes[0].size());
- const int gridH = CAST_S32(mSizes[1].size());
-
- STD_VECTOR<int> widths = getSizes(0, nw);
- STD_VECTOR<int> heights = getSizes(1, nh);
-
- const int szW = CAST_S32(widths.size());
- const int szH = CAST_S32(heights.size());
- int y = ny;
- for (int gridY = 0; gridY < gridH; ++gridY)
- {
- int x = nx;
- for (int gridX = 0; gridX < gridW; ++gridX)
- {
- LayoutCell *const cell = mCells[CAST_SIZE(gridY)]
- [CAST_SIZE(gridX)];
- if ((cell != nullptr) && cell->mType != LayoutCell::NONE)
- {
- int dx = x, dy = y, dw = 0, dh = 0;
- align(dx, dw, 0, *cell,
- &widths[CAST_SIZE(gridX)], szW - gridX);
- align(dy, dh, 1, *cell,
- &heights[CAST_SIZE(gridY)], szH - gridY);
- cell->reflow(dx, dy, dw, dh);
- }
- x += widths[CAST_SIZE(gridX)] + mSpacing;
- }
- y += heights[CAST_SIZE(gridY)] + mSpacing;
- }
-}
diff --git a/src/gui/widgets/layoutarray.h b/src/gui/widgets/layoutarray.h
deleted file mode 100644
index cca05e091..000000000
--- a/src/gui/widgets/layoutarray.h
+++ /dev/null
@@ -1,127 +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 GUI_WIDGETS_LAYOUTARRAY_H
-#define GUI_WIDGETS_LAYOUTARRAY_H
-
-#include "utils/vector.h"
-
-#include "localconsts.h"
-
-class LayoutCell;
-class Widget;
-
-/**
- * This class contains a rectangular array of cells.
- */
-class LayoutArray final
-{
- friend class LayoutCell;
-
- public:
- LayoutArray();
-
- A_DEFAULT_COPY(LayoutArray)
-
- ~LayoutArray();
-
- /**
- * Returns a reference on the cell at given position.
- */
- LayoutCell &at(const int x, const int y,
- const int w = 1, const int h = 1) A_WARN_UNUSED;
-
- /**
- * Places a widget in a given cell.
- * @param w number of columns the widget spawns.
- * @param h number of rows the widget spawns.
- * @note When @a w is 1, the width of column @a x is reset to zero if
- * it was AUTO_DEF. Similarly for @a h.
- */
- LayoutCell &place(Widget *const widget, const int x, const int y,
- const int w = 1, const int h = 1);
-
- /**
- * Sets the minimum width of a column.
- */
- void setColWidth(const int n, const int w);
-
- /**
- * Sets the minimum height of a row.
- */
- void setRowHeight(const int n, const int h);
-
- /**
- * Sets the widths of two columns to the maximum of their widths.
- */
- void matchColWidth(const int n1, const int n2);
-
- /**
- * Spawns a cell over several columns/rows.
- */
- void extend(const int x, const int y, const int w, const int h);
-
- /**
- * Computes and sets the positions of all the widgets.
- * @param nW width of the array, used to resize the AUTO_ columns.
- * @param nH height of the array, used to resize the AUTO_ rows.
- */
- void reflow(const int nX, const int nY, const int nW, const int nH);
-
- private:
- // Copy not allowed, as the array owns all its cells.
- explicit LayoutArray(LayoutArray const &);
- LayoutArray &operator=(LayoutArray const &);
-
- /**
- * Gets the position and size of a widget along a given axis
- */
- void align(int &restrict pos,
- int &restrict size,
- const int dim,
- LayoutCell const &restrict cell,
- const int *restrict const sizes,
- const int sizeCount) const A_NONNULL(6);
-
- /**
- * Ensures the private vectors are large enough.
- */
- void resizeGrid(int w, const int h);
-
- /**
- * Gets the column/row sizes along a given axis.
- * @param upp target size for the array. Ignored if AUTO_DEF.
- */
- STD_VECTOR<int> getSizes(const int dim, int upp) const A_WARN_UNUSED;
-
- /**
- * Gets the total size along a given axis.
- */
- int getSize(const int dim) const A_WARN_UNUSED;
-
- STD_VECTOR<int> mSizes[2];
- STD_VECTOR< STD_VECTOR < LayoutCell * > > mCells;
-
- int mSpacing;
-};
-
-#endif // GUI_WIDGETS_LAYOUTARRAY_H
diff --git a/src/gui/widgets/layoutcell.cpp b/src/gui/widgets/layoutcell.cpp
deleted file mode 100644
index 7db5d0783..000000000
--- a/src/gui/widgets/layoutcell.cpp
+++ /dev/null
@@ -1,136 +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 "gui/widgets/layoutcell.h"
-
-#include "gui/widgets/layoutarray.h"
-#include "gui/widgets/widget.h"
-
-#include "utils/delete2.h"
-
-#include "debug.h"
-
-static LayoutArray tempArray;
-LayoutCell LayoutCell::emptyCell;
-
-LayoutCell::~LayoutCell()
-{
- if (mType == ARRAY)
- delete2(mArray)
-}
-
-LayoutArray &LayoutCell::getArray()
-{
- if (mType == WIDGET)
- return tempArray;
- if (mType == ARRAY)
- {
- if (mArray == nullptr)
- return tempArray;
- return *mArray;
- }
-
- mArray = new LayoutArray;
- mType = ARRAY;
- mExtent[0] = 1;
- mExtent[1] = 1;
- mHPadding = 0;
- mVPadding = 0;
- mAlign[0] = FILL;
- mAlign[1] = FILL;
- return *mArray;
-}
-
-void LayoutCell::reflow(int nx, int ny, int nw, int nh)
-{
- if (mType == NONE)
- return;
-
- nx += mHPadding;
- ny += mVPadding;
- nw -= 2 * mHPadding;
- nh -= 2 * mVPadding;
- if (mType == ARRAY)
- mArray->reflow(nx, ny, nw, nh);
- else
- mWidget->setDimension(Rect(nx, ny, nw, nh));
-}
-
-void LayoutCell::computeSizes()
-{
- if (mType != ARRAY)
- return;
-
- STD_VECTOR <STD_VECTOR <LayoutCell *> >::const_iterator
- i = mArray->mCells.begin();
- const STD_VECTOR <STD_VECTOR <LayoutCell *> >::const_iterator
- i_end = mArray->mCells.end();
- while (i != i_end)
- {
- STD_VECTOR <LayoutCell *>::const_iterator j = i->begin();
- while (j != i->end())
- {
- LayoutCell *const cell = *j;
- if ((cell != nullptr) && cell->mType == ARRAY)
- cell->computeSizes();
-
- ++j;
- }
- ++i;
- }
-
- mSize[0] = mArray->getSize(0);
- mSize[1] = mArray->getSize(1);
-}
-
-LayoutCell &LayoutCell::at(const int x, const int y)
-{
- return getArray().at(x, y);
-}
-
-LayoutCell &LayoutCell::place(Widget *const wg,
- const int x, const int y,
- const int w, const int h)
-{
- return getArray().place(wg, x, y, w, h);
-}
-
-void LayoutCell::matchColWidth(const int n1, const int n2)
-{
- getArray().matchColWidth(n1, n2);
-}
-
-void LayoutCell::setColWidth(const int n, const int w)
-{
- getArray().setColWidth(n, w);
-}
-
-void LayoutCell::setRowHeight(const int n, const int h)
-{
- getArray().setRowHeight(n, h);
-}
-
-void LayoutCell::extend(const int x, const int y,
- const int w, const int h)
-{
- getArray().extend(x, y, w, h);
-}
diff --git a/src/gui/widgets/layoutcell.h b/src/gui/widgets/layoutcell.h
deleted file mode 100644
index e6404cfde..000000000
--- a/src/gui/widgets/layoutcell.h
+++ /dev/null
@@ -1,196 +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 GUI_WIDGETS_LAYOUTCELL_H
-#define GUI_WIDGETS_LAYOUTCELL_H
-
-#include "localconsts.h"
-
-class LayoutArray;
-class Widget;
-
-/**
- * This class describes the formatting of a widget in the cell of a layout
- * table. Horizontally, a widget can either fill the width of the cell (minus
- * the cell padding), or it can retain its size and be flushed left, or flush
- * right, or centered in the cell. The process is similar for the vertical
- * alignment, except that top is represented by LEFT and bottom by RIGHT.
- */
-class LayoutCell notfinal
-{
- friend class Layout;
- friend class LayoutArray;
-
- public:
- A_DEFAULT_COPY(LayoutCell)
-
- enum Alignment
- {
- LEFT = 0,
- RIGHT,
- CENTER,
- FILL
- };
-
- virtual ~LayoutCell();
-
- /**
- * Sets the padding around the cell content.
- */
- LayoutCell &setPadding(int p)
- { mHPadding = p; mVPadding = p; return *this; }
-
- /**
- * Sets the vertical padding around the cell content.
- */
- LayoutCell &setVPadding(int p)
- { mVPadding = p; return *this; }
-
- /**
- * Sets the horisontal padding around the cell content.
- */
- LayoutCell &setHPadding(int p)
- { mHPadding = p; return *this; }
-
- /**
- * Sets the horizontal alignment of the cell content.
- */
- LayoutCell &setHAlign(const Alignment a)
- { mAlign[0] = a; return *this; }
-
- /**
- * Sets the vertical alignment of the cell content.
- */
- LayoutCell &setVAlign(const Alignment a)
- { mAlign[1] = a; return *this; }
-
- /**
- * @see LayoutArray::at
- */
- LayoutCell &at(const int x, const int y) A_WARN_UNUSED;
-
- /**
- * @see LayoutArray::place
- */
- LayoutCell &place(Widget *const wg,
- const int x, const int y,
- const int w = 1, const int h = 1);
-
- /**
- * @see LayoutArray::matchColWidth
- */
- void matchColWidth(const int n1, const int n2);
-
- /**
- * @see LayoutArray::setColWidth
- */
- void setColWidth(const int n, const int w);
-
- /**
- * @see LayoutArray::setRowHeight
- */
- void setRowHeight(const int n, const int h);
-
- /**
- * @see LayoutArray::extend.
- */
- void extend(const int x, const int y,
- const int w, const int h);
-
- /**
- * Sets the minimum widths and heights of this cell and of all the
- * inner cells.
- */
- void computeSizes();
-
- void setType(int t)
- { mType = t; }
-
- int getWidth() const noexcept2 A_WARN_UNUSED
- { return mExtent[0]; }
-
- int getHeight() const noexcept2 A_WARN_UNUSED
- { return mExtent[1]; }
-
- void setWidth(const int w) noexcept2
- { mExtent[0] = w; }
-
- void setHeight(const int h) noexcept2
- { mExtent[1] = h; }
-
- enum
- {
- NONE = 0,
- WIDGET,
- ARRAY
- };
-
- static LayoutCell emptyCell;
-
- private:
- LayoutCell() :
- mWidget(nullptr),
- mHPadding(0),
- mVPadding(0),
- mType(NONE)
- {
- mExtent[0] = 0;
- mExtent[1] = 0;
- mAlign[0] = LEFT;
- mAlign[1] = LEFT;
- mNbFill[0] = 0;
- mNbFill[1] = 0;
- mSize[0] = 0;
- mSize[1] = 0;
- }
-
- // Copy not allowed, as the cell may own an array.
- explicit LayoutCell(LayoutCell const &);
- LayoutCell &operator=(LayoutCell const &);
-
- union
- {
- Widget *mWidget;
- LayoutArray *mArray;
- };
-
- /**
- * Returns the embedded array. Creates it if the cell does not contain
- * anything yet. Aborts if it contains a widget.
- */
- LayoutArray &getArray();
-
- /**
- * @see LayoutArray::reflow
- */
- void reflow(int nx, int ny, int nw, int nh);
-
- int mSize[2];
- int mHPadding;
- int mVPadding;
- int mExtent[2];
- Alignment mAlign[2];
- int mNbFill[2];
- int mType;
-};
-
-#endif // GUI_WIDGETS_LAYOUTCELL_H
diff --git a/src/gui/widgets/layouthelper.cpp b/src/gui/widgets/layouthelper.cpp
deleted file mode 100644
index 19114c1ae..000000000
--- a/src/gui/widgets/layouthelper.cpp
+++ /dev/null
@@ -1,79 +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 "gui/widgets/layouthelper.h"
-
-#include "gui/widgets/basiccontainer2.h"
-#include "gui/widgets/containerplacer.h"
-
-#include "debug.h"
-
-LayoutHelper::LayoutHelper(BasicContainer2 *const container) :
- WidgetListener(),
- mLayout(),
- mContainer(container)
-{
- if (mContainer != nullptr)
- mContainer->addWidgetListener(this);
-}
-
-LayoutHelper::~LayoutHelper()
-{
- if (mContainer != nullptr)
- mContainer->removeWidgetListener(this);
-}
-
-const Layout &LayoutHelper::getLayout() const
-{
- return mLayout;
-}
-
-LayoutCell &LayoutHelper::place(const int x, const int y,
- Widget *const wg,
- const int w, const int h)
-{
- if (mContainer != nullptr)
- mContainer->add(wg);
- return mLayout.place(wg, x, y, w, h);
-}
-
-ContainerPlacer LayoutHelper::getPlacer(const int x, const int y)
-{
- return ContainerPlacer(mContainer, &mLayout.at(x, y));
-}
-
-void LayoutHelper::reflowLayout(int w, int h)
-{
- mLayout.reflow(w, h);
- if (mContainer != nullptr)
- mContainer->setSize(w, h);
-}
-
-void LayoutHelper::widgetResized(const Event &event A_UNUSED)
-{
- if (mContainer == nullptr)
- return;
- const Rect area = mContainer->getChildrenArea();
- int w = area.width;
- int h = area.height;
- mLayout.reflow(w, h);
-}
diff --git a/src/gui/widgets/layouthelper.h b/src/gui/widgets/layouthelper.h
deleted file mode 100644
index 0f84e280c..000000000
--- a/src/gui/widgets/layouthelper.h
+++ /dev/null
@@ -1,91 +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 GUI_WIDGETS_LAYOUTHELPER_H
-#define GUI_WIDGETS_LAYOUTHELPER_H
-
-#include "gui/widgets/layout.h"
-
-#include "listeners/widgetlistener.h"
-
-class BasicContainer2;
-class ContainerPlacer;
-
-/**
- * A helper class for adding a layout to a Guichan container widget. The layout
- * will register itself as a widget listener and relayout the widgets in the
- * container dynamically on resize.
- */
-class LayoutHelper final : public WidgetListener
-{
- public:
- /**
- * Constructor.
- */
- explicit LayoutHelper(BasicContainer2 *const container);
-
- A_DELETE_COPY(LayoutHelper)
-
- /**
- * Destructor.
- */
- ~LayoutHelper();
-
- /**
- * Gets the layout handler.
- */
- const Layout &getLayout() const A_WARN_UNUSED A_CONST;
-
- /**
- * Computes the position of the widgets according to the current
- * layout. Resizes the managed container so that the layout fits.
- *
- * @note This function is meant to be called with fixed-size
- * containers.
- *
- * @param w if non-zero, force the container to this width.
- * @param h if non-zero, force the container to this height.
- */
- void reflowLayout(int w = 0, int h = 0);
-
- /**
- * Adds a widget to the container and sets it at given cell.
- */
- LayoutCell &place(const int x, const int y, Widget *const wg,
- const int w = 1, const int h = 1);
-
- /**
- * Returns a proxy for adding widgets in an inner table of the layout.
- */
- ContainerPlacer getPlacer(const int x, const int y) A_WARN_UNUSED;
-
- /**
- * Called whenever the managed container changes size.
- */
- void widgetResized(const Event &event) override final;
-
- private:
- Layout mLayout; /**< Layout handler */
- BasicContainer2 *mContainer; /**< Managed container */
-};
-
-#endif // GUI_WIDGETS_LAYOUTHELPER_H
diff --git a/src/gui/widgets/linepart.cpp b/src/gui/widgets/linepart.cpp
deleted file mode 100644
index 2e1cab392..000000000
--- a/src/gui/widgets/linepart.cpp
+++ /dev/null
@@ -1,33 +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 "gui/widgets/linepart.h"
-
-#include "resources/image/image.h"
-
-#include "debug.h"
-
-LinePart::~LinePart()
-{
- if (mImage != nullptr)
- mImage->decRef();
- mImage = nullptr;
-}
diff --git a/src/gui/widgets/linepart.h b/src/gui/widgets/linepart.h
deleted file mode 100644
index d88a6543e..000000000
--- a/src/gui/widgets/linepart.h
+++ /dev/null
@@ -1,102 +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 GUI_WIDGETS_LINEPART_H
-#define GUI_WIDGETS_LINEPART_H
-
-#include "gui/color.h"
-
-#include <string>
-
-#include "localconsts.h"
-
-class Image;
-
-class LinePart final
-{
- public:
- LinePart(const int x, const int y, const Color &color,
- const Color &color2, const std::string &text,
- const bool bold) :
- mX(x),
- mY(y),
- mColor(color),
- mColor2(color2),
- mText(text),
- mType(0),
- mImage(nullptr),
- mBold(bold)
- {
- }
-
- LinePart(const int x, const int y, const Color &color,
- const Color &color2, Image *const image) :
- mX(x),
- mY(y),
- mColor(color),
- mColor2(color2),
- mText(),
- mType(1),
- mImage(image),
- mBold(false)
- {
- }
-
- LinePart(const LinePart &l) :
- mX(l.mX),
- mY(l.mY),
- mColor(l.mColor),
- mColor2(l.mColor2),
- mText(l.mText),
- mType(l.mType),
- mImage(l.mImage),
- mBold(l.mBold)
- {
- }
-
- LinePart &operator=(const LinePart &l)
- {
- mX = l.mX;
- mY = l.mY;
- mColor = l.mColor;
- mColor2 = l.mColor2;
- mText = l.mText;
- mType = l.mType;
- mImage = l.mImage;
- mBold = l.mBold;
- return *this;
- }
-
- A_DEFAULT_COPY(LinePart)
-
- ~LinePart();
-
- int mX;
- int mY;
- Color mColor;
- Color mColor2;
- std::string mText;
- unsigned char mType;
- Image *mImage;
- bool mBold;
-};
-
-#endif // GUI_WIDGETS_LINEPART_H
diff --git a/src/gui/widgets/linkhandler.h b/src/gui/widgets/linkhandler.h
deleted file mode 100644
index 3b46e9fd3..000000000
--- a/src/gui/widgets/linkhandler.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 GUI_WIDGETS_LINKHANDLER_H
-#define GUI_WIDGETS_LINKHANDLER_H
-
-#include <string>
-
-#include "listeners/mouselistener.h"
-
-/**
- * A simple interface to windows that need to handle links from BrowserBox
- * widget.
- */
-class LinkHandler notfinal
-{
- public:
- LinkHandler()
- { }
-
- A_DELETE_COPY(LinkHandler)
-
- virtual ~LinkHandler()
- { }
-
- virtual void handleLink(const std::string &link,
- MouseEvent *event) = 0;
-};
-
-#endif // GUI_WIDGETS_LINKHANDLER_H
diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp
deleted file mode 100644
index 0bf590f6b..000000000
--- a/src/gui/widgets/listbox.cpp
+++ /dev/null
@@ -1,446 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "gui/widgets/listbox.h"
-
-#include "settings.h"
-
-#include "gui/focushandler.h"
-#include "gui/gui.h"
-#include "gui/skin.h"
-
-#include "gui/fonts/font.h"
-
-#include "gui/models/listmodel.h"
-
-#include "listeners/selectionlistener.h"
-
-#include "utils/foreach.h"
-
-#include "render/graphics.h"
-
-#include "debug.h"
-
-float ListBox::mAlpha = 1.0;
-
-ListBox::ListBox(const Widget2 *const widget,
- ListModel *const listModel,
- const std::string &skin) :
- Widget(widget),
- MouseListener(),
- KeyListener(),
- mSelected(-1),
- mListModel(listModel),
- mWrappingEnabled(false),
- mSelectionListeners(),
- mHighlightColor(getThemeColor(ThemeColorId::HIGHLIGHT)),
- mForegroundSelectedColor(getThemeColor(ThemeColorId::LISTBOX_SELECTED)),
- mForegroundSelectedColor2(getThemeColor(
- ThemeColorId::LISTBOX_SELECTED_OUTLINE)),
- mOldSelected(-1),
- mPadding(0),
- mPressedIndex(-2),
- mRowHeight(0),
- mItemPadding(1),
- mSkin(nullptr),
- mDistributeMousePressed(true),
- mCenterText(false)
-{
- setWidth(100);
- setFocusable(true);
- addMouseListener(this);
- addKeyListener(this);
-
- mForegroundColor = getThemeColor(ThemeColorId::LISTBOX);
- mForegroundColor2 = getThemeColor(ThemeColorId::LISTBOX_OUTLINE);
-
- if (theme != nullptr)
- mSkin = theme->load(skin, "listbox.xml");
-
- if (mSkin != nullptr)
- {
- mPadding = mSkin->getPadding();
- mItemPadding = mSkin->getOption("itemPadding");
- }
-
- const Font *const font = getFont();
- mRowHeight = CAST_U32(
- font->getHeight() + 2 * mItemPadding);
-}
-
-void ListBox::postInit()
-{
- adjustSize();
-}
-
-ListBox::~ListBox()
-{
- if (gui != nullptr)
- gui->removeDragged(this);
-
- if (theme != nullptr)
- theme->unload(mSkin);
-}
-
-void ListBox::updateAlpha()
-{
- const float alpha = std::max(settings.guiAlpha,
- theme->getMinimumOpacity());
-
- if (mAlpha != alpha)
- mAlpha = alpha;
-}
-
-void ListBox::draw(Graphics *const graphics)
-{
- if (mListModel == nullptr)
- return;
-
- BLOCK_START("ListBox::draw")
- updateAlpha();
-
- mHighlightColor.a = CAST_U32(mAlpha * 255.0F);
- graphics->setColor(mHighlightColor);
- Font *const font = getFont();
- const int rowHeight = CAST_S32(getRowHeight());
- const int width = mDimension.width;
-
- if (mCenterText)
- {
- // Draw filled rectangle around the selected list element
- if (mSelected >= 0)
- {
- graphics->fillRectangle(Rect(mPadding,
- rowHeight * mSelected + mPadding,
- mDimension.width - 2 * mPadding, rowHeight));
-
- const std::string str = mListModel->getElementAt(mSelected);
- font->drawString(graphics,
- mForegroundSelectedColor,
- mForegroundSelectedColor2,
- str,
- (width - font->getWidth(str)) / 2,
- mSelected * rowHeight + mPadding + mItemPadding);
- }
- // Draw the list elements
- const int sz = mListModel->getNumberOfElements();
- for (int i = 0, y = mPadding + mItemPadding;
- i < sz; ++i, y += rowHeight)
- {
- if (i != mSelected)
- {
- const std::string str = mListModel->getElementAt(i);
- font->drawString(graphics,
- mForegroundColor,
- mForegroundColor2,
- str,
- (width - font->getWidth(str)) / 2, y);
- }
- }
- }
- else
- {
- // Draw filled rectangle around the selected list element
- if (mSelected >= 0)
- {
- graphics->fillRectangle(Rect(mPadding,
- rowHeight * mSelected + mPadding,
- mDimension.width - 2 * mPadding, rowHeight));
-
- const std::string str = mListModel->getElementAt(mSelected);
- font->drawString(graphics,
- mForegroundSelectedColor,
- mForegroundSelectedColor2,
- str,
- mPadding,
- mSelected * rowHeight + mPadding + mItemPadding);
- }
- // Draw the list elements
- const int sz = mListModel->getNumberOfElements();
- for (int i = 0, y = mPadding + mItemPadding; i < sz;
- ++i, y += rowHeight)
- {
- if (i != mSelected)
- {
- const std::string str = mListModel->getElementAt(i);
- font->drawString(graphics,
- mForegroundColor,
- mForegroundColor2,
- str,
- mPadding, y);
- }
- }
- }
- BLOCK_END("ListBox::draw")
-}
-
-void ListBox::keyPressed(KeyEvent &event)
-{
- const InputActionT action = event.getActionId();
- if (action == InputAction::GUI_SELECT)
- {
- distributeActionEvent();
- event.consume();
- }
- else if (action == InputAction::GUI_UP)
- {
- if (mSelected > 0)
- {
- setSelected(mSelected - 1);
- }
- else if (mSelected == 0 &&
- mWrappingEnabled &&
- getListModel() != nullptr)
- {
- setSelected(getListModel()->getNumberOfElements() - 1);
- }
- event.consume();
- }
- else if (action == InputAction::GUI_DOWN)
- {
- const int num = getListModel()->getNumberOfElements() - 1;
- if (mSelected < num)
- setSelected(mSelected + 1);
- else if (mSelected == num && mWrappingEnabled)
- setSelected(0);
- event.consume();
- }
- else if (action == InputAction::GUI_HOME)
- {
- setSelected(0);
- event.consume();
- }
- else if (action == InputAction::GUI_END && (getListModel() != nullptr))
- {
- setSelected(getListModel()->getNumberOfElements() - 1);
- event.consume();
- }
-}
-
-void ListBox::safeDraw(Graphics *const graphics)
-{
- ListBox::draw(graphics);
-}
-
-// Don't do anything on scrollwheel. ScrollArea will deal with that.
-
-void ListBox::mouseWheelMovedUp(MouseEvent &event A_UNUSED)
-{
-}
-
-void ListBox::mouseWheelMovedDown(MouseEvent &event A_UNUSED)
-{
-}
-
-void ListBox::mousePressed(MouseEvent &event)
-{
- mPressedIndex = getSelectionByMouse(event.getY());
- if (mMouseConsume && mPressedIndex != -1)
- event.consume();
-}
-
-void ListBox::mouseReleased(MouseEvent &event)
-{
- if (mPressedIndex != getSelectionByMouse(event.getY()))
- return;
-
- if (mDistributeMousePressed)
- {
- mouseReleased1(event);
- }
- else
- {
- switch (event.getClickCount())
- {
- case 1:
- mouseDragged(event);
- mOldSelected = mSelected;
- break;
- case 2:
- if (gui != nullptr)
- gui->resetClickCount();
- if (mOldSelected == mSelected)
- mouseReleased1(event);
- else
- mouseDragged(event);
- mOldSelected = mSelected;
- break;
- default:
- mouseDragged(event);
- mOldSelected = mSelected;
- break;
- }
- }
- mPressedIndex = -2;
-}
-
-void ListBox::mouseReleased1(const MouseEvent &event)
-{
- if (event.getButton() == MouseButton::LEFT)
- {
- setSelected(std::max(0, getSelectionByMouse(event.getY())));
- distributeActionEvent();
- }
-}
-
-void ListBox::mouseDragged(MouseEvent &event)
-{
- if (event.getButton() != MouseButton::LEFT || getRowHeight() == 0)
- return;
-
- // Make list selection update on drag, but guard against negative y
- if (getRowHeight() != 0u)
- setSelected(std::max(0, getSelectionByMouse(event.getY())));
-}
-
-void ListBox::refocus()
-{
- if (mFocusHandler == nullptr)
- return;
-
- if (isFocusable())
- mFocusHandler->requestFocus(this);
-}
-
-void ListBox::adjustSize()
-{
- BLOCK_START("ListBox::adjustSize")
- if (mListModel != nullptr)
- {
- setHeight(CAST_S32(getRowHeight()) *
- mListModel->getNumberOfElements() + 2 * mPadding);
- }
- BLOCK_END("ListBox::adjustSize")
-}
-
-void ListBox::logic()
-{
- BLOCK_START("ListBox::logic")
- adjustSize();
- BLOCK_END("ListBox::logic")
-}
-
-int ListBox::getSelectionByMouse(const int y) const
-{
- if (y < mPadding)
- return -1;
- return (y - mPadding) / CAST_S32(getRowHeight());
-}
-
-void ListBox::setSelected(const int selected)
-{
- if (mListModel == nullptr)
- {
- mSelected = -1;
- }
- else
- {
- if (selected < 0)
- mSelected = -1;
- else if (selected >= mListModel->getNumberOfElements())
- mSelected = mListModel->getNumberOfElements() - 1;
- else
- mSelected = selected;
- }
-
- Rect scroll;
-
- if (mSelected < 0)
- scroll.y = 0;
- else
- scroll.y = CAST_S32(getRowHeight()) * mSelected;
-
- scroll.height = CAST_S32(getRowHeight());
- showPart(scroll);
-
- distributeValueChangedEvent();
-}
-
-void ListBox::setListModel(ListModel *const listModel)
-{
- mSelected = -1;
- mListModel = listModel;
- adjustSize();
-}
-
-void ListBox::addSelectionListener(SelectionListener *const selectionListener)
-{
- mSelectionListeners.push_back(selectionListener);
-}
-
-void ListBox::removeSelectionListener(SelectionListener *const
- selectionListener)
-{
- mSelectionListeners.remove(selectionListener);
-}
-
-void ListBox::distributeValueChangedEvent()
-{
- FOR_EACH (SelectionListenerIterator, iter, mSelectionListeners)
- {
- SelectionEvent event(this);
- (*iter)->valueChanged(event);
- }
-}
diff --git a/src/gui/widgets/listbox.h b/src/gui/widgets/listbox.h
deleted file mode 100644
index 5c90058a8..000000000
--- a/src/gui/widgets/listbox.h
+++ /dev/null
@@ -1,296 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GUI_WIDGETS_LISTBOX_H
-#define GUI_WIDGETS_LISTBOX_H
-
-#include "gui/widgets/widget.h"
-
-#include "listeners/keylistener.h"
-#include "listeners/mouselistener.h"
-
-#include "localconsts.h"
-
-class Skin;
-class KeyEvent;
-class ListModel;
-class MouseEvent;
-class SelectionListener;
-class Widget2;
-
-/**
- * A list box, meant to be used inside a scroll area. Same as the Guichan list
- * box except this one doesn't have a background, instead completely relying
- * on the scroll area. It also adds selection listener functionality.
- *
- * \ingroup GUI
- */
-class ListBox notfinal : public Widget,
- public MouseListener,
- public KeyListener
-{
- public:
- /**
- * Constructor.
- */
- ListBox(const Widget2 *const widget,
- ListModel *const listModel,
- const std::string &skin);
-
- A_DELETE_COPY(ListBox)
-
- virtual ~ListBox();
-
- void postInit() override;
-
- /**
- * Draws the list box.
- */
- void draw(Graphics *const graphics) override A_NONNULL(2);
-
- void safeDraw(Graphics *const graphics) override A_NONNULL(2);
-
- /**
- * Update the alpha value to the graphic components.
- */
- void updateAlpha();
-
- // Inherited from KeyListener
-
- void keyPressed(KeyEvent& event) override final;
-
- // Inherited from MouseListener
-
- void mouseWheelMovedUp(MouseEvent& event) override final A_CONST;
-
- void mouseWheelMovedDown(MouseEvent& event) override final A_CONST;
-
- void mousePressed(MouseEvent &event) override;
-
- void mouseReleased(MouseEvent &event) override;
-
- void mouseReleased1(const MouseEvent &event);
-
- void mouseDragged(MouseEvent &event) override;
-
- void refocus();
-
- void setDistributeMousePressed(const bool b) noexcept2
- { mDistributeMousePressed = b; }
-
- virtual void adjustSize();
-
- void logic() override final;
-
- virtual int getSelectionByMouse(const int y) const;
-
- void setCenter(const bool b) noexcept2
- { mCenterText = b; }
-
- int getPressedIndex() const noexcept2 A_WARN_UNUSED
- { return mPressedIndex; }
-
- virtual unsigned int getRowHeight() const A_WARN_UNUSED
- { return mRowHeight; }
-
- void setRowHeight(unsigned int n) noexcept2
- { mRowHeight = n; }
-
- /**
- * Gets the selected item as an index in the list model.
- *
- * @return the selected item as an index in the list model.
- * @see setSelected
- */
- int getSelected() const noexcept2 A_WARN_UNUSED
- { return mSelected; }
-
- /**
- * Sets the selected item. The selected item is represented by
- * an index from the list model.
- *
- * @param selected the selected item as an index from the list model.
- * @see getSelected
- */
- void setSelected(const int selected);
-
- /**
- * Sets the list model to use.
- *
- * @param listModel the list model to use.
- * @see getListModel
- */
- void setListModel(ListModel *listModel);
-
- /**
- * Gets the list model used.
- *
- * @return the list model used.
- * @see setListModel
- */
- ListModel *getListModel() const noexcept2 A_WARN_UNUSED
- { return mListModel; }
-
- /**
- * Checks whether the list box wraps when selecting items with a
- * keyboard.
- *
- * Wrapping means that the selection of items will be wrapped. That is,
- * if the first item is selected and up is pressed, the last item will
- * get selected. If the last item is selected and down is pressed, the
- * first item will get selected.
- *
- * @return true if wrapping is enabled, fasle otherwise.
- * @see setWrappingEnabled
- */
- bool isWrappingEnabled() const noexcept2 A_WARN_UNUSED
- { return mWrappingEnabled; }
-
- /**
- * Sets the list box to wrap or not when selecting items with a
- * keyboard.
- *
- * Wrapping means that the selection of items will be wrapped. That is,
- * if the first item is selected and up is pressed, the last item will
- * get selected. If the last item is selected and down is pressed, the
- * first item will get selected.
- *
- * @see isWrappingEnabled
- */
- void setWrappingEnabled(const bool wrappingEnabled) noexcept2
- { mWrappingEnabled = wrappingEnabled; }
-
- /**
- * Adds a selection listener to the list box. When the selection
- * changes an event will be sent to all selection listeners of the
- * list box.
- *
- * If you delete your selection listener, be sure to also remove it
- * using removeSelectionListener().
- *
- * @param selectionListener The selection listener to add.
- */
- void addSelectionListener(SelectionListener *const selectionListener);
-
- /**
- * Removes a selection listener from the list box.
- *
- * @param selectionListener The selection listener to remove.
- */
- void removeSelectionListener(SelectionListener *const
- selectionListener);
-
- /**
- * Distributes a value changed event to all selection listeners
- * of the list box.
- */
- void distributeValueChangedEvent();
-
- protected:
- /**
- * The selected item as an index in the list model.
- */
- int mSelected;
-
- /**
- * The list model to use.
- */
- ListModel *mListModel;
-
- /**
- * True if wrapping is enabled, false otherwise.
- */
- bool mWrappingEnabled;
-
- /**
- * Typdef.
- */
- typedef std::list<SelectionListener*> SelectionListenerList;
-
- /**
- * The selection listeners of the list box.
- */
- SelectionListenerList mSelectionListeners;
-
- /**
- * Typedef.
- */
- typedef SelectionListenerList::iterator SelectionListenerIterator;
-
- Color mHighlightColor;
- Color mForegroundSelectedColor;
- Color mForegroundSelectedColor2;
- int mOldSelected;
- int mPadding;
- int mPressedIndex;
- unsigned int mRowHeight;
- int mItemPadding;
- Skin *mSkin;
- static float mAlpha;
- bool mDistributeMousePressed;
- bool mCenterText;
-};
-
-#endif // GUI_WIDGETS_LISTBOX_H
diff --git a/src/gui/widgets/passwordfield.cpp b/src/gui/widgets/passwordfield.cpp
deleted file mode 100644
index bc2ca4827..000000000
--- a/src/gui/widgets/passwordfield.cpp
+++ /dev/null
@@ -1,55 +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 "gui/widgets/passwordfield.h"
-
-#include "gui/skin.h"
-
-#include "debug.h"
-
-PasswordField::PasswordField(const Widget2 *const widget,
- const std::string &text) :
- TextField(widget, text),
- mPasswordChar(mSkin != nullptr ? CAST_8(
- mSkin->getOption("passwordChar", 42))
- : CAST_8(42))
-{
-}
-
-void PasswordField::draw(Graphics *const graphics)
-{
- BLOCK_START("PasswordField::draw")
- // std::string uses cow, thus cheap copy
- const std::string original = mText;
- if (mPasswordChar != 0)
- mText.assign(mText.length(), mPasswordChar);
- else
- mText.clear();
- TextField::draw(graphics);
- mText = original;
- BLOCK_END("PasswordField::draw")
-}
-
-void PasswordField::safeDraw(Graphics *const graphics)
-{
- PasswordField::draw(graphics);
-}
diff --git a/src/gui/widgets/passwordfield.h b/src/gui/widgets/passwordfield.h
deleted file mode 100644
index 93dded8d5..000000000
--- a/src/gui/widgets/passwordfield.h
+++ /dev/null
@@ -1,55 +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_PASSWORDFIELD_H
-#define GUI_WIDGETS_PASSWORDFIELD_H
-
-#include "gui/widgets/textfield.h"
-
-/**
- * A password field.
- *
- * \ingroup GUI
- */
-class PasswordField final : public TextField
-{
- public:
- /**
- * Constructor, initializes the password field with the given string.
- */
- explicit PasswordField(const Widget2 *const widget,
- const std::string &text = "");
-
- A_DELETE_COPY(PasswordField)
-
- /**
- * Draws the password field.
- */
- void draw(Graphics *const graphics) override final A_NONNULL(2);
-
- void safeDraw(Graphics *const graphics) override final A_NONNULL(2);
-
- protected:
- char mPasswordChar;
-};
-
-#endif // GUI_WIDGETS_PASSWORDFIELD_H
diff --git a/src/gui/widgets/playerbox.cpp b/src/gui/widgets/playerbox.cpp
deleted file mode 100644
index b6217383f..000000000
--- a/src/gui/widgets/playerbox.cpp
+++ /dev/null
@@ -1,190 +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 "gui/widgets/playerbox.h"
-
-#include "settings.h"
-
-#include "being/being.h"
-
-#include "gui/gui.h"
-#include "gui/skin.h"
-
-#include "render/graphics.h"
-
-#include "resources/image/image.h"
-
-#include "debug.h"
-
-PlayerBox::PlayerBox(Widget2 *const widget,
- Being *const being,
- const std::string &skin,
- const std::string &selectedSkin) :
- Widget(widget),
- MouseListener(),
- mBeing(being),
- mAlpha(1.0),
- mBackground(),
- mSelectedBackground(),
- mSkin(nullptr),
- mSelectedSkin(nullptr),
- mOffsetX(-mapTileSize / 2),
- mOffsetY(-mapTileSize),
- mDrawBackground(false),
- mSelected(false)
-{
- init(skin, selectedSkin);
-}
-
-PlayerBox::PlayerBox(Widget2 *const widget,
- const std::string &skin,
- const std::string &selectedSkin) :
- Widget(widget),
- MouseListener(),
- mBeing(nullptr),
- mAlpha(1.0),
- mBackground(),
- mSelectedBackground(),
- mSkin(nullptr),
- mSelectedSkin(nullptr),
- mOffsetX(-mapTileSize / 2),
- mOffsetY(-mapTileSize),
- mDrawBackground(false),
- mSelected(false)
-{
- init(skin, selectedSkin);
-}
-
-PlayerBox::~PlayerBox()
-{
- if (gui != nullptr)
- gui->removeDragged(this);
-
- Theme::unloadRect(mBackground);
- Theme::unloadRect(mSelectedBackground);
- mBeing = nullptr;
-}
-
-void PlayerBox::init(std::string name, std::string selectedName)
-{
- mAllowLogic = false;
- setFrameSize(2);
- addMouseListener(this);
-
- if (theme != nullptr)
- {
- if (name.empty())
- name = "playerbox.xml";
- mSkin = theme->loadSkinRect(mBackground,
- name, "playerbox_background.xml");
- if (mSkin != nullptr)
- {
- mDrawBackground = (mSkin->getOption("drawbackground") != 0);
- mOffsetX = mSkin->getOption("offsetX", -mapTileSize / 2);
- mOffsetY = mSkin->getOption("offsetY", -mapTileSize);
- mFrameSize = mSkin->getOption("frameSize", 2);
- }
- if (selectedName.empty())
- selectedName = "playerboxselected.xml";
- mSelectedSkin = theme->loadSkinRect(mSelectedBackground,
- selectedName, "playerbox_background.xml");
- }
- else
- {
- for (int f = 0; f < 9; f ++)
- mBackground.grid[f] = nullptr;
- for (int f = 0; f < 9; f ++)
- mSelectedBackground.grid[f] = nullptr;
- }
-}
-
-void PlayerBox::draw(Graphics *const graphics)
-{
- BLOCK_START("PlayerBox::draw")
- if (mBeing != nullptr)
- {
- const int bs = mFrameSize;
- const int x = mDimension.width / 2 + bs + mOffsetX;
- const int y = mDimension.height - bs + mOffsetY;
- mBeing->drawBasic(graphics, x, y);
- }
-
- if (settings.guiAlpha != mAlpha)
- {
- const float alpha = settings.guiAlpha;
- for (int a = 0; a < 9; a++)
- {
- if (mBackground.grid[a] != nullptr)
- mBackground.grid[a]->setAlpha(alpha);
- }
- }
- BLOCK_END("PlayerBox::draw")
-}
-
-void PlayerBox::safeDraw(Graphics *const graphics)
-{
- PlayerBox::draw(graphics);
-}
-
-void PlayerBox::drawFrame(Graphics *const graphics)
-{
- BLOCK_START("PlayerBox::drawFrame")
- if (mDrawBackground)
- {
- const int bs = mFrameSize * 2;
- const int w = mDimension.width + bs;
- const int h = mDimension.height + bs;
-
- if (!mSelected)
- graphics->drawImageRect(0, 0, w, h, mBackground);
- else
- graphics->drawImageRect(0, 0, w, h, mSelectedBackground);
- }
- BLOCK_END("PlayerBox::drawFrame")
-}
-
-void PlayerBox::safeDrawFrame(Graphics *const graphics)
-{
- BLOCK_START("PlayerBox::drawFrame")
- if (mDrawBackground)
- {
- const int bs = mFrameSize * 2;
- const int w = mDimension.width + bs;
- const int h = mDimension.height + bs;
-
- if (!mSelected)
- graphics->drawImageRect(0, 0, w, h, mBackground);
- else
- graphics->drawImageRect(0, 0, w, h, mSelectedBackground);
- }
- BLOCK_END("PlayerBox::drawFrame")
-}
-
-void PlayerBox::mouseReleased(MouseEvent& event)
-{
- if (event.getButton() == MouseButton::LEFT)
- {
- if (!mActionEventId.empty())
- distributeActionEvent();
- event.consume();
- }
-}
diff --git a/src/gui/widgets/playerbox.h b/src/gui/widgets/playerbox.h
deleted file mode 100644
index b223f1dcb..000000000
--- a/src/gui/widgets/playerbox.h
+++ /dev/null
@@ -1,112 +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_PLAYERBOX_H
-#define GUI_WIDGETS_PLAYERBOX_H
-
-#include "gui/widgets/widget.h"
-
-#include "listeners/mouselistener.h"
-
-#include "resources/imagerect.h"
-
-#include "localconsts.h"
-
-class Being;
-class Skin;
-
-/**
- * A box showing a player character.
- *
- * \ingroup GUI
- */
-class PlayerBox final : public Widget,
- public MouseListener
-{
- public:
- /**
- * Constructor. Takes the initial player character that this box should
- * display, which defaults to <code>NULL</code>.
- */
- PlayerBox(Widget2 *const widget,
- Being *const being,
- const std::string &skin = "",
- const std::string &selectedSkin = "");
-
- explicit PlayerBox(Widget2 *const widget,
- const std::string &skin = "",
- const std::string &selectedSkin = "");
-
- A_DELETE_COPY(PlayerBox)
-
- /**
- * Destructor.
- */
- ~PlayerBox();
-
- void init(std::string name, std::string selectedName);
-
- /**
- * Sets a new player character to be displayed by this box. Setting the
- * player to <code>NULL</code> causes the box not to draw any
- * character.
- */
- void setPlayer(Being *being)
- { mBeing = being; }
-
- /**
- * Draws the scroll area.
- */
- void draw(Graphics *const graphics) override final A_NONNULL(2);
-
- void safeDraw(Graphics *const graphics) override final A_NONNULL(2);
-
- /**
- * Draws the background and border of the scroll area.
- */
- void drawFrame(Graphics *const graphics) override final A_NONNULL(2);
-
- void safeDrawFrame(Graphics *const graphics) override final
- A_NONNULL(2);
-
- Being *getBeing() A_WARN_UNUSED
- { return mBeing; }
-
- void setSelected(bool b)
- { mSelected = b; }
-
- void mouseReleased(MouseEvent& event) override final;
-
- private:
- Being *mBeing;
- float mAlpha;
- ImageRect mBackground;
- ImageRect mSelectedBackground;
- Skin *mSkin;
- Skin *mSelectedSkin;
- int mOffsetX;
- int mOffsetY;
- bool mDrawBackground;
- bool mSelected;
-};
-
-#endif // GUI_WIDGETS_PLAYERBOX_H
diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp
deleted file mode 100644
index 0f5c5a31a..000000000
--- a/src/gui/widgets/popup.cpp
+++ /dev/null
@@ -1,273 +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
- * Copyright (C) 2009 Aethyra Development Team
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * 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 "gui/widgets/popup.h"
-
-#include "gui/popupmanager.h"
-#include "gui/skin.h"
-
-#include "gui/widgets/windowcontainer.h"
-
-#include "utils/delete2.h"
-
-#include "render/graphics.h"
-
-#include "render/vertexes/imagecollection.h"
-
-#include "debug.h"
-
-Popup::Popup(const std::string &name,
- std::string skin) :
- Container(nullptr),
- MouseListener(),
- WidgetListener(),
- mPadding(3),
- mSkin(nullptr),
- mPopupName(name),
- mVertexes(new ImageCollection),
- mMinWidth(100),
- mMinHeight(40),
- mMaxWidth(mainGraphics->mWidth),
- mMaxHeight(mainGraphics->mHeight),
- mInit(false)
-{
- logger->log("Popup::Popup(\"%s\")", name.c_str());
-
- mWindow = this;
-
- addWidgetListener(this);
-
- if (skin.empty())
- skin = "popup.xml";
-
- if (theme != nullptr)
- {
- mSkin = theme->load(skin, "popup.xml");
- if (mSkin != nullptr)
- {
- setPadding(mSkin->getPadding());
- setPalette(mSkin->getOption("palette"));
- }
- }
-
- if (windowContainer != nullptr)
- windowContainer->add(this);
-
- // Popups are invisible by default
- setVisible(Visible_false);
-}
-
-Popup::~Popup()
-{
- logger->log("Popup::~Popup(\"%s\")", mPopupName.c_str());
-
- delete2(mVertexes);
-
- if (mSkin != nullptr)
- {
- if (theme != nullptr)
- theme->unload(mSkin);
- mSkin = nullptr;
- }
-
- if (!mInit)
- {
- logger->log("error: Popup created without calling postInit(): "
- + mPopupName);
- }
-}
-
-void Popup::setWindowContainer(WindowContainer *const wc)
-{
- windowContainer = wc;
-}
-
-void Popup::draw(Graphics *const graphics)
-{
- BLOCK_START("Popup::draw")
-
- if (mSkin != nullptr)
- {
- if (mRedraw)
- {
- mRedraw = false;
- mVertexes->clear();
- graphics->calcWindow(mVertexes,
- 0, 0,
- mDimension.width, mDimension.height,
- mSkin->getBorder());
- }
- // need cache or remove calc call.
- graphics->finalize(mVertexes);
- graphics->drawTileCollection(mVertexes);
- }
-
- drawChildren(graphics);
- BLOCK_END("Popup::draw")
-}
-
-void Popup::safeDraw(Graphics *const graphics)
-{
- BLOCK_START("Popup::safeDraw")
-
- if (mSkin != nullptr)
- {
- graphics->drawImageRect(0, 0,
- mDimension.width, mDimension.height,
- mSkin->getBorder());
- }
-
- safeDrawChildren(graphics);
- BLOCK_END("Popup::safeDraw")
-}
-
-Rect Popup::getChildrenArea()
-{
- const int pad2 = mPadding * 2;
- return Rect(mPadding, mPadding,
- mDimension.width - pad2, mDimension.height - pad2);
-}
-
-void Popup::setContentSize(int width, int height)
-{
- const int pad2 = mPadding * 2;
- width += pad2;
- height += pad2;
-
- if (mMinWidth > width)
- width = mMinWidth;
- else if (mMaxWidth < width)
- width = mMaxWidth;
- if (mMinHeight > height)
- height = mMinHeight;
- else if (mMaxHeight < height)
- height = mMaxHeight;
-
- setSize(width, height);
- mRedraw = true;
-}
-
-void Popup::setLocationRelativeTo(const Widget *const widget)
-{
- if (widget == nullptr)
- return;
-
- int wx, wy;
- int x, y;
-
- widget->getAbsolutePosition(wx, wy);
- getAbsolutePosition(x, y);
-
- setPosition(mDimension.x + (wx + (widget->getWidth()
- - mDimension.width) / 2 - x),
- mDimension.y + (wy + (widget->getHeight()
- - mDimension.height) / 2 - y));
- mRedraw = true;
-}
-
-void Popup::setMinWidth(const int width)
-{
- if (mSkin != nullptr)
- {
- mMinWidth = width > mSkin->getMinWidth()
- ? width : mSkin->getMinWidth();
- }
- else
- {
- mMinWidth = width;
- }
-}
-
-void Popup::setMinHeight(const int height)
-{
- if (mSkin != nullptr)
- {
- mMinHeight = height > mSkin->getMinHeight() ?
- height : mSkin->getMinHeight();
- }
- else
- {
- mMinHeight = height;
- }
-}
-
-void Popup::setMaxWidth(const int width)
-{
- mMaxWidth = width;
-}
-
-void Popup::setMaxHeight(const int height)
-{
- mMaxHeight = height;
-}
-
-void Popup::scheduleDelete()
-{
- windowContainer->scheduleDelete(this);
-}
-
-void Popup::position(const int x, const int y)
-{
- const int distance = 20;
-
- const int width = mDimension.width;
- const int height = mDimension.height;
- int posX = std::max(0, x - width / 2);
- int posY = y + distance;
-
- if (posX + width > mainGraphics->mWidth)
- posX = mainGraphics->mWidth - width;
- if (posY + height > mainGraphics->mHeight)
- posY = y - height - distance;
-
- setPosition(posX, posY);
- setVisible(Visible_true);
- requestMoveToTop();
- mRedraw = true;
-}
-
-void Popup::mouseMoved(MouseEvent &event A_UNUSED)
-{
- if (popupManager != nullptr)
- {
- PopupManager::hideBeingPopup();
- PopupManager::hideTextPopup();
- }
- mRedraw = true;
-}
-
-void Popup::hide()
-{
- setVisible(Visible_false);
- mRedraw = true;
-}
-
-void Popup::widgetResized(const Event &event A_UNUSED)
-{
- mRedraw = true;
-}
-
-void Popup::widgetMoved(const Event &event A_UNUSED)
-{
- mRedraw = true;
-}
diff --git a/src/gui/widgets/popup.h b/src/gui/widgets/popup.h
deleted file mode 100644
index 92fbaf78a..000000000
--- a/src/gui/widgets/popup.h
+++ /dev/null
@@ -1,193 +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
- * Copyright (C) 2009 Aethyra Development Team
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * 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_POPUP_H
-#define GUI_WIDGETS_POPUP_H
-
-#include "gui/widgets/container.h"
-
-#include "listeners/mouselistener.h"
-#include "listeners/widgetlistener.h"
-
-class ImageCollection;
-class Skin;
-class WindowContainer;
-
-/**
- * A light version of the Window class. Particularly suited for popup type
- * functionality that doesn't need to be resized or moved around by the mouse
- * once created, but only needs to display some simple content, like a static
- * message.
- *
- * Popups, in general, shouldn't also need to update their content once
- * created, although this is not an explicit requirement to use the popup
- * class.
- *
- * \ingroup GUI
- */
-class Popup notfinal : public Container,
- public MouseListener,
- public WidgetListener
-{
- public:
- /**
- * Constructor. Initializes the title to the given text and hooks
- * itself into the popup container.
- *
- * @param name A human readable name for the popup. Only useful for
- * debugging purposes.
- * @param skin The location where the Popup's skin XML can be found.
- */
- explicit Popup(const std::string &name = "",
- std::string skin = "");
-
- A_DELETE_COPY(Popup)
-
- /**
- * Destructor. Deletes all the added widgets.
- */
- virtual ~Popup();
-
- /**
- * Sets the window container to be used by new popups.
- */
- static void setWindowContainer(WindowContainer *const windowContainer);
-
- /**
- * Draws the popup.
- */
- void draw(Graphics *const graphics) override A_NONNULL(2);
-
- void safeDraw(Graphics *const graphics) override A_NONNULL(2);
-
- /**
- * Sets the size of this popup.
- */
- void setContentSize(int width, int height);
-
- /**
- * Sets the location relative to the given widget.
- */
- void setLocationRelativeTo(const Widget *const widget);
-
- void mouseMoved(MouseEvent &event) override;
-
- /**
- * Sets the minimum width of the popup.
- */
- void setMinWidth(const int width);
-
- int getMinWidth() const noexcept2 A_WARN_UNUSED
- { return mMinWidth; }
-
- /**
- * Sets the minimum height of the popup.
- */
- void setMinHeight(const int height);
-
- int getMinHeight() const noexcept2 A_WARN_UNUSED
- { return mMinHeight; }
-
- /**
- * Sets the maximum width of the popup.
- */
- void setMaxWidth(const int width);
-
- int getMaxWidth() const noexcept2 A_WARN_UNUSED
- { return mMaxWidth; }
-
- /**
- * Sets the minimum height of the popup.
- */
- void setMaxHeight(const int height);
-
- int getMaxHeight() const noexcept2 A_WARN_UNUSED
- { return mMaxHeight; }
-
- /**
- * Gets the padding of the popup. The padding is the distance between
- * the popup border and the content.
- *
- * @return The padding of the popup.
- * @see setPadding
- */
- int getPadding() const noexcept2 A_WARN_UNUSED
- { return mPadding; }
-
- void setPadding(int padding) noexcept2
- { mPadding = padding; }
-
- /**
- * Sets the name of the popup. This is only useful for debug purposes.
- */
- void setPopupName(const std::string &name) noexcept2
- { mPopupName = name; }
-
- const std::string &getPopupName() const noexcept2
- { return mPopupName; }
-
- /**
- * Schedule this popup for deletion. It will be deleted at the start
- * of the next logic update.
- */
- void scheduleDelete();
-
- // Inherited from BasicContainer
-
- Rect getChildrenArea() override;
-
- /**
- * Sets the location to display the popup. Tries to horizontally center
- * the popup and provide a vertical buffer between the given point and
- * the popup. Prevents the popup from extending off-screen, if
- * possible.
- */
- void position(const int x, const int y);
-
- void hide();
-
- void widgetResized(const Event &event) override;
-
- void widgetMoved(const Event &event) override final;
-
- bool isPopupVisible() const noexcept2
- { return mVisible == Visible_true; }
-
- void postInit() override
- { mInit = true; }
-
- protected:
- int mPadding; /**< Holds the padding of the popup. */
- Skin *mSkin; /**< Skin in use by this popup */
-
- private:
- std::string mPopupName; /**< Name of the popup */
- ImageCollection *mVertexes A_NONNULLPOINTER;
- int mMinWidth; /**< Minimum popup width */
- int mMinHeight; /**< Minimum popup height */
- int mMaxWidth; /**< Maximum popup width */
- int mMaxHeight; /**< Maximum popup height */
- bool mInit;
-};
-
-#endif // GUI_WIDGETS_POPUP_H
diff --git a/src/gui/widgets/popuplist.cpp b/src/gui/widgets/popuplist.cpp
deleted file mode 100644
index 0260945ce..000000000
--- a/src/gui/widgets/popuplist.cpp
+++ /dev/null
@@ -1,188 +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 "gui/widgets/popuplist.h"
-
-#include "gui/gui.h"
-
-#include "gui/widgets/createwidget.h"
-#include "gui/widgets/dropdown.h"
-#include "gui/widgets/extendedlistbox.h"
-#include "gui/widgets/scrollarea.h"
-
-#include "render/graphics.h"
-
-#include "debug.h"
-
-PopupList::PopupList(DropDown *const widget,
- ListModel *const listModel,
- const bool extended,
- const Modal modal) :
- Popup("PopupList", "popuplist.xml"),
- FocusListener(),
- mListModel(listModel),
- mListBox(extended ? CREATEWIDGETR(ExtendedListBox,
- widget, listModel, "extendedlistbox.xml", 0) :
- CREATEWIDGETR(ListBox,
- widget, listModel, "popuplistbox.xml")),
- mScrollArea(new ScrollArea(this, mListBox, Opaque_false)),
- mDropDown(widget),
- mPressedIndex(-2),
- mModal(modal)
-{
- mListBox->setMouseConsume(false);
- mScrollArea->setMouseConsume(false);
- mAllowLogic = false;
- setFocusable(true);
-
- mListBox->setDistributeMousePressed(true);
- mScrollArea->setPosition(mPadding, mPadding);
-}
-
-void PopupList::postInit()
-{
- Popup::postInit();
- add(mScrollArea);
-
- if (gui != nullptr)
- gui->addGlobalFocusListener(this);
-
- addKeyListener(mDropDown);
- addMouseListener(this);
- adjustSize();
-}
-
-PopupList::~PopupList()
-{
- if (mParent != nullptr)
- mParent->removeFocusListener(this);
- if (gui != nullptr)
- gui->removeGlobalFocusListener(this);
- removeKeyListener(mDropDown);
-}
-
-void PopupList::show(int x, int y)
-{
- int len = mListBox->getHeight() + 8;
- if (len > 250)
- len = 250;
- setContentSize(mListBox->getWidth() + 8, len);
- const int width = mDimension.width;
- const int height = mDimension.height;
- if (mainGraphics->mWidth < (x + width + 5))
- x = mainGraphics->mWidth - width;
- if (mainGraphics->mHeight < (y + height + 5))
- y = mainGraphics->mHeight - height;
- setPosition(x, y);
- setVisible(Visible_true);
- requestMoveToTop();
- if (mModal == Modal_true)
- requestModalFocus();
-}
-
-void PopupList::widgetResized(const Event &event)
-{
- Popup::widgetResized(event);
- adjustSize();
-}
-
-void PopupList::setSelected(const int selected)
-{
- if (mListBox == nullptr)
- return;
-
- mListBox->setSelected(selected);
-}
-
-int PopupList::getSelected() const
-{
- if (mListBox == nullptr)
- return -1;
-
- return mListBox->getSelected();
-}
-
-void PopupList::setListModel(ListModel *const model)
-{
- if (mListBox != nullptr)
- mListBox->setListModel(model);
- mListModel = model;
-}
-
-void PopupList::adjustSize()
-{
- const int pad2 = 2 * mPadding;
- const int width = mDimension.width - pad2;
- mScrollArea->setWidth(width);
- mScrollArea->setHeight(mDimension.height - pad2);
- mListBox->adjustSize();
- mListBox->setWidth(width);
-}
-
-void PopupList::mousePressed(MouseEvent& event)
-{
- mPressedIndex = mListBox->getSelectionByMouse(
- event.getY() + mPadding);
- event.consume();
-}
-
-void PopupList::mouseReleased(MouseEvent& event)
-{
- if (mPressedIndex != mListBox->getSelectionByMouse(
- event.getY() + mPadding))
- {
- mPressedIndex = -2;
- return;
- }
-
- mPressedIndex = -2;
- if (event.getSource() == mScrollArea)
- return;
- if (mDropDown != nullptr)
- mDropDown->updateSelection();
- setVisible(Visible_false);
- if (mModal == Modal_true)
- releaseModalFocus();
-}
-
-void PopupList::focusGained(const Event& event)
-{
- const Widget *const source = event.getSource();
- if (mVisible == Visible_false ||
- source == this ||
- source == mListBox ||
- source == mScrollArea ||
- source == mDropDown)
- {
- return;
- }
-
- if (mDropDown != nullptr)
- mDropDown->updateSelection();
- setVisible(Visible_false);
- if (mModal == Modal_true)
- releaseModalFocus();
-}
-
-void PopupList::focusLost(const Event& event A_UNUSED)
-{
- if (mDropDown != nullptr)
- mDropDown->updateSelection();
-}
diff --git a/src/gui/widgets/popuplist.h b/src/gui/widgets/popuplist.h
deleted file mode 100644
index 02c38b4ed..000000000
--- a/src/gui/widgets/popuplist.h
+++ /dev/null
@@ -1,84 +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 GUI_WIDGETS_POPUPLIST_H
-#define GUI_WIDGETS_POPUPLIST_H
-
-#include "enums/simpletypes/modal.h"
-
-#include "gui/widgets/popup.h"
-
-#include "listeners/focuslistener.h"
-
-#include "localconsts.h"
-
-class DropDown;
-class ListBox;
-class ListModel;
-class ScrollArea;
-
-class PopupList final : public Popup,
- public FocusListener
-{
- public:
- PopupList(DropDown *const widget,
- ListModel *const listModel,
- const bool extended,
- const Modal modal = Modal_false);
-
- ~PopupList();
-
- A_DELETE_COPY(PopupList)
-
- void postInit() override final;
-
- void show(int x, int y);
-
- void widgetResized(const Event &event) override final;
-
- void setSelected(const int selected);
-
- int getSelected() const;
-
- void setListModel(ListModel *const model);
-
- ListModel *getListModel() const
- { return mListModel; }
-
- void adjustSize();
-
- void focusGained(const Event& event A_UNUSED) override final;
-
- void focusLost(const Event& event A_UNUSED) override final;
-
- void mousePressed(MouseEvent& event) override final;
-
- void mouseReleased(MouseEvent& event) override final;
-
- private:
- ListModel *mListModel;
- ListBox *mListBox A_NONNULLPOINTER;
- ScrollArea *mScrollArea A_NONNULLPOINTER;
- DropDown *mDropDown;
- int mPressedIndex;
- Modal mModal;
-};
-
-#endif // GUI_WIDGETS_POPUPLIST_H
diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp
deleted file mode 100644
index 7299140c6..000000000
--- a/src/gui/widgets/progressbar.cpp
+++ /dev/null
@@ -1,376 +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 "gui/widgets/progressbar.h"
-
-#include "settings.h"
-
-#include "gui/gui.h"
-#include "gui/skin.h"
-
-#include "gui/fonts/font.h"
-
-#include "utils/delete2.h"
-
-#include "render/graphics.h"
-
-#include "render/vertexes/imagecollection.h"
-
-#include "debug.h"
-
-int ProgressBar::mInstances = 0;
-float ProgressBar::mAlpha = 1.0;
-
-ProgressBar::ProgressBar(const Widget2 *const widget,
- float progress,
- const int width,
- const int height,
- const ProgressColorIdT backColor,
- const std::string &skin,
- const std::string &skinFill) :
- Widget(widget),
- WidgetListener(),
- mFillRect(),
- mTextChunk(),
- mSkin(nullptr),
- mProgress(progress),
- mProgressToGo(progress),
- mBackgroundColorToGo(),
- mText(),
- mVertexes(new ImageCollection),
- mProgressPalette(backColor),
- mPadding(2),
- mFillPadding(3),
- mFillImage(false),
- mSmoothProgress(true),
- mSmoothColorChange(true),
- mTextChanged(true)
-{
- mBackgroundColor = Theme::getProgressColor(
- backColor >= ProgressColorId::PROG_HP
- ? backColor : ProgressColorId::PROG_HP,
- mProgress);
- mBackgroundColorToGo = mBackgroundColor;
- mForegroundColor2 = getThemeColor(ThemeColorId::PROGRESS_BAR_OUTLINE);
-
- // The progress value is directly set at load time:
- if (mProgress > 1.0F || mProgress < 0.0F)
- mProgress = 1.0F;
-
- mForegroundColor = getThemeColor(ThemeColorId::PROGRESS_BAR);
- addWidgetListener(this);
- setSize(width, height);
-
- if (theme != nullptr)
- {
- mSkin = theme->load(skin, "progressbar.xml");
- if (mSkin != nullptr)
- {
- setPadding(mSkin->getPadding());
- mFillPadding = mSkin->getOption("fillPadding");
- mFillImage = mSkin->getOption("fillImage") != 0;
- if (mFillImage)
- theme->loadRect(mFillRect, skinFill, "progressbar_fill.xml");
- }
- setHeight(2 * mPadding + getFont()->getHeight() + 2);
- }
-
- mInstances++;
-}
-
-ProgressBar::~ProgressBar()
-{
- if (gui != nullptr)
- gui->removeDragged(this);
-
- mInstances--;
- if (mSkin != nullptr)
- {
- if (theme != nullptr)
- theme->unload(mSkin);
- mSkin = nullptr;
- }
- Theme::unloadRect(mFillRect);
- delete2(mVertexes);
- mTextChunk.deleteImage();
-}
-
-void ProgressBar::logic()
-{
- BLOCK_START("ProgressBar::logic")
- if (mSmoothColorChange && mBackgroundColorToGo != mBackgroundColor)
- {
- // Smoothly changing the color for a nicer effect.
- if (mBackgroundColorToGo.r > mBackgroundColor.r)
- mBackgroundColor.r++;
- if (mBackgroundColorToGo.g > mBackgroundColor.g)
- mBackgroundColor.g++;
- if (mBackgroundColorToGo.b > mBackgroundColor.b)
- mBackgroundColor.b++;
- if (mBackgroundColorToGo.r < mBackgroundColor.r)
- mBackgroundColor.r--;
- if (mBackgroundColorToGo.g < mBackgroundColor.g)
- mBackgroundColor.g--;
- if (mBackgroundColorToGo.b < mBackgroundColor.b)
- mBackgroundColor.b--;
- mRedraw = true;
- }
-
- if (mSmoothProgress && mProgressToGo != mProgress)
- {
- // Smoothly showing the progressbar changes.
- if (mProgressToGo > mProgress)
- mProgress = std::min(1.0F, mProgress + 0.005F);
- if (mProgressToGo < mProgress)
- mProgress = std::max(0.0F, mProgress - 0.005F);
- mRedraw = true;
- }
- BLOCK_END("ProgressBar::logic")
-}
-
-void ProgressBar::updateAlpha()
-{
- const float alpha = std::max(settings.guiAlpha,
- theme->getMinimumOpacity());
- mAlpha = alpha;
-}
-
-void ProgressBar::draw(Graphics *const graphics)
-{
- BLOCK_START("ProgressBar::draw")
- if (mSkin == nullptr)
- {
- BLOCK_END("ProgressBar::draw")
- return;
- }
-
- updateAlpha();
- mBackgroundColor.a = CAST_U32(mAlpha * 255);
-
- if (mRedraw || graphics->getRedraw())
- {
- mRedraw = false;
- mVertexes->clear();
- graphics->calcWindow(mVertexes, 0, 0,
- mDimension.width, mDimension.height, mSkin->getBorder());
- if (mFillImage)
- {
- const unsigned int pad = 2 * mFillPadding;
- const int maxWidth = mDimension.width - pad;
- int width = CAST_S32(mProgress
- * static_cast<float>(maxWidth));
- if (width > 0)
- {
- if (width > maxWidth)
- width = maxWidth;
- graphics->calcWindow(mVertexes, mFillPadding, mFillPadding,
- width, mDimension.height - pad, mFillRect);
- }
- }
- graphics->finalize(mVertexes);
- }
-
- graphics->drawTileCollection(mVertexes);
-
- // The bar
- if (!mFillImage && mProgress > 0)
- {
- graphics->setColor(mBackgroundColor);
- const unsigned int pad = 2 * mFillPadding;
- const int maxWidth = mDimension.width - pad;
- int width = CAST_S32(mProgress * static_cast<float>(maxWidth));
- if (width > 0)
- {
- if (width > maxWidth)
- width = maxWidth;
- graphics->fillRectangle(Rect(mFillPadding, mFillPadding,
- width, mDimension.height - pad));
- }
- }
-
- // The label
- if (!mText.empty())
- {
- Font *const font = gui->getFont();
- if (mTextChanged)
- {
- mTextChunk.textFont = font;
- mTextChunk.deleteImage();
- mTextChunk.text = mText;
- mTextChunk.color = mForegroundColor;
- mTextChunk.color2 = mForegroundColor2;
- font->generate(mTextChunk);
- mTextChanged = false;
- }
-
- const Image *const image = mTextChunk.img;
- if (image != nullptr)
- {
- const int textX = (mDimension.width - font->getWidth(mText)) / 2;
- const int textY = (mDimension.height - font->getHeight()) / 2;
- graphics->drawImage(image, textX, textY);
- }
- }
- BLOCK_END("ProgressBar::draw")
-}
-
-void ProgressBar::safeDraw(Graphics *const graphics)
-{
- BLOCK_START("ProgressBar::safeDraw")
- if (mSkin == nullptr)
- {
- BLOCK_END("ProgressBar::safeDraw")
- return;
- }
-
- updateAlpha();
- mBackgroundColor.a = CAST_U32(mAlpha * 255);
-
- graphics->drawImageRect(0, 0, mDimension.width, mDimension.height,
- mSkin->getBorder());
- if (mFillImage)
- {
- const unsigned int pad = 2 * mFillPadding;
- const int maxWidth = mDimension.width - pad;
- int width = CAST_S32(mProgress
- * static_cast<float>(maxWidth));
- if (width > 0)
- {
- if (width > maxWidth)
- width = maxWidth;
- graphics->drawImageRect(mFillPadding, mFillPadding,
- width, mDimension.height - pad, mFillRect);
- }
- }
-
- // The bar
- if (!mFillImage && mProgress > 0)
- {
- graphics->setColor(mBackgroundColor);
- const unsigned int pad = 2 * mFillPadding;
- const int maxWidth = mDimension.width - pad;
- int width = CAST_S32(mProgress * static_cast<float>(maxWidth));
- if (width > 0)
- {
- if (width > maxWidth)
- width = maxWidth;
- graphics->fillRectangle(Rect(mFillPadding, mFillPadding,
- width, mDimension.height - pad));
- }
- }
-
- // The label
- if (!mText.empty())
- {
- Font *const font = gui->getFont();
- if (mTextChanged)
- {
- mTextChunk.textFont = font;
- mTextChunk.deleteImage();
- mTextChunk.text = mText;
- mTextChunk.color = mForegroundColor;
- mTextChunk.color2 = mForegroundColor2;
- font->generate(mTextChunk);
- mTextChanged = false;
- }
-
- const Image *const image = mTextChunk.img;
- if (image != nullptr)
- {
- const int textX = (mDimension.width - font->getWidth(mText)) / 2;
- const int textY = (mDimension.height - font->getHeight()) / 2;
- graphics->drawImage(image, textX, textY);
- }
- }
- BLOCK_END("ProgressBar::safeDraw")
-}
-
-void ProgressBar::setProgress(const float progress)
-{
- const float p = std::min(1.0F, std::max(0.0F, progress));
- mProgressToGo = p;
- mRedraw = true;
-
- if (!mSmoothProgress)
- mProgress = p;
-
- if (mProgressPalette >= ProgressColorId::PROG_HP)
- {
- mBackgroundColorToGo = Theme::getProgressColor(
- mProgressPalette, progress);
- }
-}
-
-void ProgressBar::setProgressPalette(const ProgressColorIdT progressPalette)
-{
- const ProgressColorIdT oldPalette = mProgressPalette;
- mProgressPalette = progressPalette;
- mRedraw = true;
-
- if (mProgressPalette != oldPalette &&
- mProgressPalette >= ProgressColorId::PROG_HP)
- {
- mBackgroundColorToGo = Theme::getProgressColor(
- mProgressPalette, mProgressToGo);
- }
-}
-
-void ProgressBar::setBackgroundColor(const Color &color)
-{
- mRedraw = true;
- mBackgroundColorToGo = color;
-
- if (!mSmoothColorChange)
- mBackgroundColor = color;
-}
-
-void ProgressBar::setColor(const Color &color1, const Color &color2)
-{
- mForegroundColor = color1;
- mForegroundColor2 = color2;
- mTextChanged = true;
-}
-
-void ProgressBar::widgetResized(const Event &event A_UNUSED)
-{
- mRedraw = true;
-}
-
-void ProgressBar::widgetMoved(const Event &event A_UNUSED)
-{
- mRedraw = true;
-}
-
-void ProgressBar::setText(const std::string &str)
-{
- if (mText != str)
- {
- mText = str;
- mTextChanged = true;
- }
-}
-
-void ProgressBar::widgetHidden(const Event &event A_UNUSED)
-{
- mTextChanged = true;
- mTextChunk.deleteImage();
-}
diff --git a/src/gui/widgets/progressbar.h b/src/gui/widgets/progressbar.h
deleted file mode 100644
index 466f067b4..000000000
--- a/src/gui/widgets/progressbar.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 GUI_WIDGETS_PROGRESSBAR_H
-#define GUI_WIDGETS_PROGRESSBAR_H
-
-#include "gui/fonts/textchunk.h"
-
-#include "gui/widgets/widget.h"
-
-#include "listeners/widgetlistener.h"
-
-#include "resources/imagerect.h"
-
-#include "localconsts.h"
-
-class ImageCollection;
-class Skin;
-
-/**
- * A progress bar.
- *
- * \ingroup GUI
- */
-class ProgressBar final : public Widget,
- public WidgetListener
-{
- public:
- /**
- * Constructor, initializes the progress with the given value.
- */
- ProgressBar(const Widget2 *const widget,
- float progress,
- const int width,
- const int height,
- const ProgressColorIdT backColor,
- const std::string &skin,
- const std::string &skinFill);
-
- A_DELETE_COPY(ProgressBar)
-
- ~ProgressBar();
-
- /**
- * Performs progress bar logic (fading colors)
- */
- void logic() override final;
-
- /**
- * Update the alpha value to the graphic components.
- */
- void updateAlpha();
-
- /**
- * Draws the progress bar.
- */
- void draw(Graphics *const graphics) override final A_NONNULL(2);
-
- void safeDraw(Graphics *const graphics) override final A_NONNULL(2);
-
- /**
- * Sets the current progress.
- */
- void setProgress(const float progress);
-
- /**
- * Returns the current progress.
- */
- float getProgress() const noexcept2 A_WARN_UNUSED
- { return mProgress; }
-
- /**
- * Change the ProgressPalette for this ProgressBar to follow or -1 to
- * disable this and manage color manually.
- */
- void setProgressPalette(const ProgressColorIdT progressPalette);
-
- /**
- * Change the color of the progress bar.
- */
- void setBackgroundColor(const Color &color);
-
- void setColor(const Color &color1, const Color &color2);
-
- /**
- * Returns the color of the progress bar.
- */
- const Color &getBackgroundColor() const noexcept2 A_WARN_UNUSED
- { return mBackgroundColor; }
-
- /**
- * Sets the text shown on the progress bar.
- */
- void setText(const std::string &str);
-
- /**
- * Returns the text shown on the progress bar.
- */
- const std::string &text() const noexcept2 A_WARN_UNUSED
- { return mText; }
-
- /**
- * Set whether the progress is moved smoothly.
- */
- void setSmoothProgress(bool smoothProgress) noexcept2
- { mSmoothProgress = smoothProgress; }
-
- /**
- * Set whether the color changing is made smoothly.
- */
- void setSmoothColorChange(bool smoothColorChange) noexcept2
- { mSmoothColorChange = smoothColorChange; }
-
- void widgetResized(const Event &event) override final;
-
- void widgetMoved(const Event &event) override final;
-
- void widgetHidden(const Event &event) override final;
-
- void setPadding(unsigned int padding) noexcept2
- { mPadding = padding; }
-
- private:
- ImageRect mFillRect;
- TextChunk mTextChunk;
- Skin *mSkin;
- float mProgress;
- float mProgressToGo;
-
- Color mBackgroundColorToGo;
-
- std::string mText;
- ImageCollection *mVertexes A_NONNULLPOINTER;
- ProgressColorIdT mProgressPalette;
- unsigned int mPadding;
- unsigned int mFillPadding;
-
- static int mInstances;
- static float mAlpha;
-
- bool mFillImage;
- bool mSmoothProgress;
- bool mSmoothColorChange;
- bool mTextChanged;
-};
-
-#endif // GUI_WIDGETS_PROGRESSBAR_H
diff --git a/src/gui/widgets/progressindicator.cpp b/src/gui/widgets/progressindicator.cpp
deleted file mode 100644
index abeee678c..000000000
--- a/src/gui/widgets/progressindicator.cpp
+++ /dev/null
@@ -1,98 +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 "gui/widgets/progressindicator.h"
-
-#include "gui/gui.h"
-
-#include "resources/imageset.h"
-
-#include "resources/animation/animation.h"
-#include "resources/animation/simpleanimation.h"
-
-#include "utils/delete2.h"
-
-#include "debug.h"
-
-ProgressIndicator::ProgressIndicator(const Widget2 *const widget) :
- Widget(widget),
- mIndicator(nullptr)
-{
- ImageSet *const images = Theme::getImageSetFromTheme(
- "progress-indicator.png", 32, 32);
-
- if (images != nullptr)
- {
- Animation *const anim = new Animation("progress indicator");
- for (ImageSet::size_type i = 0, fsz = images->size();
- i < fsz;
- ++i)
- {
- anim->addFrame(images->get(i), 100, 0, 0, 100);
- }
- mIndicator = new SimpleAnimation(anim);
- images->decRef();
- }
-
- setSize(32, 32);
-}
-
-ProgressIndicator::~ProgressIndicator()
-{
- if (gui != nullptr)
- gui->removeDragged(this);
-
- delete2(mIndicator);
-}
-
-void ProgressIndicator::logic()
-{
- BLOCK_START("ProgressIndicator::logic")
- if (mIndicator != nullptr)
- mIndicator->update(10);
- BLOCK_END("ProgressIndicator::logic")
-}
-
-void ProgressIndicator::draw(Graphics *const graphics)
-{
- BLOCK_START("ProgressIndicator::draw")
- if (mIndicator != nullptr)
- {
- // Draw the indicator centered on the widget
- const int x = (mDimension.width - 32) / 2;
- const int y = (mDimension.height - 32) / 2;
- mIndicator->draw(graphics, x, y);
- }
- BLOCK_END("ProgressIndicator::draw")
-}
-
-void ProgressIndicator::safeDraw(Graphics *const graphics)
-{
- BLOCK_START("ProgressIndicator::draw")
- if (mIndicator != nullptr)
- {
- // Draw the indicator centered on the widget
- const int x = (mDimension.width - 32) / 2;
- const int y = (mDimension.height - 32) / 2;
- mIndicator->draw(graphics, x, y);
- }
- BLOCK_END("ProgressIndicator::draw")
-}
diff --git a/src/gui/widgets/progressindicator.h b/src/gui/widgets/progressindicator.h
deleted file mode 100644
index 6220a57c4..000000000
--- a/src/gui/widgets/progressindicator.h
+++ /dev/null
@@ -1,54 +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 GUI_WIDGETS_PROGRESSINDICATOR_H
-#define GUI_WIDGETS_PROGRESSINDICATOR_H
-
-#include "gui/widgets/widget.h"
-
-#include "localconsts.h"
-
-class SimpleAnimation;
-
-/**
- * A widget that indicates progress. Suitable to use instead of a progress bar
- * in cases where it is unknown how long something is going to take.
- */
-class ProgressIndicator final : public Widget
-{
- public:
- explicit ProgressIndicator(const Widget2 *const widget);
-
- A_DELETE_COPY(ProgressIndicator)
-
- ~ProgressIndicator();
-
- void logic() override final;
-
- void draw(Graphics *const graphics) override final A_NONNULL(2);
-
- void safeDraw(Graphics *const graphics) override final A_NONNULL(2);
-
- private:
- SimpleAnimation *mIndicator;
-};
-
-#endif // GUI_WIDGETS_PROGRESSINDICATOR_H
diff --git a/src/gui/widgets/radiobutton.cpp b/src/gui/widgets/radiobutton.cpp
deleted file mode 100644
index 71b7171ae..000000000
--- a/src/gui/widgets/radiobutton.cpp
+++ /dev/null
@@ -1,373 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "gui/widgets/radiobutton.h"
-
-#include "settings.h"
-
-#include "gui/gui.h"
-#include "gui/skin.h"
-
-#include "gui/fonts/font.h"
-
-#include "render/graphics.h"
-
-#include "resources/imagerect.h"
-
-#include "resources/image/image.h"
-
-#include "debug.h"
-
-int RadioButton::instances = 0;
-Skin *RadioButton::mSkin = nullptr;
-float RadioButton::mAlpha = 1.0;
-
-RadioButton::GroupMap RadioButton::mGroupMap;
-
-RadioButton::RadioButton(const Widget2 *const widget,
- const std::string &restrict caption,
- const std::string &restrict group,
- const bool marked) :
- Widget(widget),
- MouseListener(),
- KeyListener(),
- WidgetListener(),
- mSelected(false),
- mCaption(),
- mGroup(),
- mTextChunk(),
- mPadding(0),
- mImagePadding(0),
- mImageSize(9),
- mSpacing(2),
- mTextX(0 + 9 + 2),
- mHasMouse(false),
- mTextChanged(true)
-{
- mAllowLogic = false;
- setCaption(caption);
- setGroup(group);
- setSelected(marked);
-
- setFocusable(true);
- addMouseListener(this);
- addKeyListener(this);
-
- mForegroundColor = getThemeColor(ThemeColorId::RADIOBUTTON);
- mForegroundColor2 = getThemeColor(ThemeColorId::RADIOBUTTON_OUTLINE);
- if (instances == 0)
- {
- if (theme != nullptr)
- {
- mSkin = theme->load("radio.xml", "");
- updateAlpha();
- }
- }
-
- instances++;
-
- if (mSkin != nullptr)
- {
- mPadding = mSkin->getPadding();
- mImagePadding = mSkin->getOption("imagePadding");
- mImageSize = mSkin->getOption("imageSize");
- mSpacing = mSkin->getOption("spacing");
- mTextX = mPadding + mImageSize + mSpacing;
- }
-
- adjustSize();
-}
-
-RadioButton::~RadioButton()
-{
- if (mWindow != nullptr)
- mWindow->removeWidgetListener(this);
-
- setGroup(std::string());
-
- if (gui != nullptr)
- gui->removeDragged(this);
-
- instances--;
-
- if (instances == 0)
- {
- if (theme != nullptr)
- theme->unload(mSkin);
- }
-}
-
-void RadioButton::updateAlpha()
-{
- const float alpha = std::max(settings.guiAlpha,
- theme->getMinimumOpacity());
-
- if (mAlpha != alpha)
- {
- mAlpha = alpha;
- if (mSkin != nullptr)
- {
- const ImageRect &rect = mSkin->getBorder();
- for (int a = 0; a < 4; a ++)
- {
- Image *const image = rect.grid[a];
- if (image != nullptr)
- image->setAlpha(mAlpha);
- }
- }
- }
-}
-
-void RadioButton::drawBox(Graphics *const graphics)
-{
- if (mSkin == nullptr)
- return;
-
- const ImageRect &rect = mSkin->getBorder();
- int index = 0;
-
- if (mEnabled && mVisible == Visible_true)
- {
- if (mSelected)
- {
- if (mHasMouse)
- index = 1;
- else
- index = 0;
- }
- else
- {
- if (mHasMouse)
- index = 3;
- else
- index = 2;
- }
- }
- else
- {
- if (mSelected)
- index = 0;
- else
- index = 2;
- }
-
- const Image *const box = rect.grid[index];
-
- updateAlpha();
-
- if (box != nullptr)
- {
- graphics->drawImage(box,
- mImagePadding,
- (getHeight() - mImageSize) / 2);
- }
-}
-
-void RadioButton::draw(Graphics *const graphics)
-{
- BLOCK_START("RadioButton::draw")
- drawBox(graphics);
-
- Font *const font = getFont();
-
- if (mTextChanged)
- {
- mTextChunk.textFont = font;
- mTextChunk.deleteImage();
- mTextChunk.text = mCaption;
- mTextChunk.color = mForegroundColor;
- mTextChunk.color2 = mForegroundColor2;
- font->generate(mTextChunk);
- mTextChanged = false;
- }
-
- const Image *const image = mTextChunk.img;
- if (image != nullptr)
- graphics->drawImage(image, mTextX, mPadding);
-
- BLOCK_END("RadioButton::draw")
-}
-
-void RadioButton::safeDraw(Graphics *const graphics)
-{
- RadioButton::draw(graphics);
-}
-
-void RadioButton::mouseEntered(MouseEvent& event A_UNUSED)
-{
- mHasMouse = true;
-}
-
-void RadioButton::mouseExited(MouseEvent& event A_UNUSED)
-{
- mHasMouse = false;
-}
-
-void RadioButton::keyPressed(KeyEvent& event)
-{
- const InputActionT action = event.getActionId();
- if (action == InputAction::GUI_SELECT)
- {
- setSelected(true);
- distributeActionEvent();
- event.consume();
- }
-}
-
-void RadioButton::adjustSize()
-{
- Font *const font = getFont();
- setHeight(font->getHeight() + 2 * mPadding);
- setWidth(mImagePadding + mImageSize + mSpacing
- + font->getWidth(mCaption) + mPadding);
-}
-
-void RadioButton::setSelected(const bool selected)
-{
- if (selected && !mGroup.empty())
- {
- for (GroupIterator iter = mGroupMap.lower_bound(mGroup),
- iterEnd = mGroupMap.upper_bound(mGroup);
- iter != iterEnd;
- ++ iter)
- {
- if ((iter->second != nullptr) && iter->second->isSelected())
- iter->second->setSelected(false);
- }
- }
-
- mSelected = selected;
-}
-
-void RadioButton::mouseClicked(MouseEvent& event)
-{
- if (event.getButton() == MouseButton::LEFT)
- {
- setSelected(true);
- event.consume();
- distributeActionEvent();
- }
-}
-
-void RadioButton::mouseDragged(MouseEvent& event)
-{
- event.consume();
-}
-
-void RadioButton::setGroup(const std::string &group)
-{
- if (!mGroup.empty())
- {
- for (GroupIterator iter = mGroupMap.lower_bound(mGroup),
- iterEnd = mGroupMap.upper_bound(mGroup);
- iter != iterEnd;
- ++ iter)
- {
- if (iter->second == this)
- {
- mGroupMap.erase(iter);
- break;
- }
- }
- }
-
- if (!group.empty())
- mGroupMap.insert(std::pair<std::string, RadioButton *>(group, this));
-
- mGroup = group;
-}
-
-void RadioButton::setCaption(const std::string& caption)
-{
- if (caption != mCaption)
- mTextChanged = true;
- mCaption = caption;
-}
-
-void RadioButton::setParent(Widget *widget)
-{
- if (mWindow != nullptr)
- mWindow->addWidgetListener(this);
- Widget::setParent(widget);
-}
-
-void RadioButton::widgetHidden(const Event &event A_UNUSED)
-{
- mTextChanged = true;
- mTextChunk.deleteImage();
-}
-
-void RadioButton::setWindow(Widget *const widget)
-{
- if ((widget == nullptr) && (mWindow != nullptr))
- {
- mWindow->removeWidgetListener(this);
- mWindow = nullptr;
- }
- else
- {
- Widget2::setWindow(widget);
- }
-}
diff --git a/src/gui/widgets/radiobutton.h b/src/gui/widgets/radiobutton.h
deleted file mode 100644
index 37bafab29..000000000
--- a/src/gui/widgets/radiobutton.h
+++ /dev/null
@@ -1,247 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GUI_WIDGETS_RADIOBUTTON_H
-#define GUI_WIDGETS_RADIOBUTTON_H
-
-#include "listeners/keylistener.h"
-#include "listeners/mouselistener.h"
-#include "listeners/widgetlistener.h"
-
-#include "gui/fonts/textchunk.h"
-
-#include "gui/widgets/widget.h"
-
-#include "localconsts.h"
-
-class Skin;
-
-/**
- * Guichan based RadioButton with custom look
- */
-class RadioButton final : public Widget,
- public MouseListener,
- public KeyListener,
- public WidgetListener
-
-{
- public:
- /**
- * Constructor.
- */
- RadioButton(const Widget2 *const widget,
- const std::string &restrict caption,
- const std::string &restrict group,
- const bool marked = false);
-
- A_DELETE_COPY(RadioButton)
-
- /**
- * Destructor.
- */
- ~RadioButton();
-
- /**
- * Draws the radiobutton, not the caption.
- */
- void drawBox(Graphics *const graphics) A_NONNULL(2);
-
- /**
- * Implementation of the draw methods.
- * Thus, avoiding the rhomb around the radio button.
- */
- void draw(Graphics *const graphics) override final A_NONNULL(2);
-
- void safeDraw(Graphics *const graphics) override final A_NONNULL(2);
-
- /**
- * Called when the mouse enteres the widget area.
- */
- void mouseEntered(MouseEvent& event) override final;
-
- /**
- * Called when the mouse leaves the widget area.
- */
- void mouseExited(MouseEvent& event) override final;
-
- void keyPressed(KeyEvent& event) override final;
-
- void updateAlpha();
-
- void adjustSize();
-
- /**
- * Checks if the radio button is selected.
- *
- * @return True if the radio button is selecte, false otherwise.
- * @see setSelected
- */
- bool isSelected() const
- { return mSelected; }
-
- /**
- * Sets the radio button to selected or not.
- *
- * @param selected True if the radio button should be selected,
- * false otherwise.
- * @see isSelected
- */
- void setSelected(const bool selected);
-
- /**
- * Gets the caption of the radio button.
- *
- * @return The caption of the radio button.
- * @see setCaption
- */
- const std::string &getCaption() const
- { return mCaption; }
-
- /**
- * Sets the caption of the radio button. It's advisable to call
- * adjustSize after setting of the caption to adjust the
- * radio button's size to fit the caption.
- *
- * @param caption The caption of the radio button.
- * @see getCaption, adjustSize
- */
- void setCaption(const std::string &caption);
-
- void mouseClicked(MouseEvent& event) override final;
-
- void mouseDragged(MouseEvent& event) override final;
-
- /**
- * Sets the group the radio button should belong to. Note that
- * a radio button group is unique per application, not per Gui object
- * as the group is stored in a static map.
- *
- * @param group The name of the group.
- * @see getGroup
- */
- void setGroup(const std::string &group);
-
- /**
- * Gets the group the radio button belongs to.
- *
- * @return The group the radio button belongs to.
- * @see setGroup
- */
- const std::string &getGroup() const
- { return mGroup; }
-
- void setParent(Widget *widget) override final;
-
- void widgetHidden(const Event &event) override final;
-
- void setWindow(Widget *const widget) override final;
-
- private:
- static int instances;
- static Skin *mSkin;
- static float mAlpha;
-
- /**
- * True if the radio button is selected, false otherwise.
- */
- bool mSelected;
-
- /**
- * Holds the caption of the radio button.
- */
- std::string mCaption;
-
- /**
- * Holds the group of the radio button.
- */
- std::string mGroup;
-
- TextChunk mTextChunk;
-
- /**
- * Typdef.
- */
- typedef std::multimap<std::string, RadioButton *> GroupMap;
-
- /**
- * Typdef.
- */
- typedef GroupMap::iterator GroupIterator;
-
- /**
- * Holds all available radio button groups.
- */
- static GroupMap mGroupMap;
-
- int mPadding;
- int mImagePadding;
- int mImageSize;
- int mSpacing;
- int mTextX;
- bool mHasMouse;
- bool mTextChanged;
-};
-
-#endif // GUI_WIDGETS_RADIOBUTTON_H
diff --git a/src/gui/widgets/radiogroup.cpp b/src/gui/widgets/radiogroup.cpp
deleted file mode 100644
index 5e500c18f..000000000
--- a/src/gui/widgets/radiogroup.cpp
+++ /dev/null
@@ -1,41 +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 "gui/widgets/radiogroup.h"
-
-#include "gui/widgets/radiobutton.h"
-
-#include "debug.h"
-
-RadioGroup::RadioGroup(const Widget2 *const widget,
- const std::string &group, const int height,
- const int spacing) :
- WidgetGroup(widget, group, height, spacing)
-{
-}
-
-Widget *RadioGroup::createWidget(const std::string &text,
- const bool pressed A_UNUSED) const
-{
- RadioButton *const widget = new RadioButton(
- this, text, mGroup, mCount == 0);
- widget->adjustSize();
- return widget;
-}
diff --git a/src/gui/widgets/radiogroup.h b/src/gui/widgets/radiogroup.h
deleted file mode 100644
index 346efc754..000000000
--- a/src/gui/widgets/radiogroup.h
+++ /dev/null
@@ -1,41 +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 GUI_WIDGETS_RADIOGROUP_H
-#define GUI_WIDGETS_RADIOGROUP_H
-
-#include "gui/widgets/widgetgroup.h"
-
-class RadioGroup final : public WidgetGroup
-{
- public:
- RadioGroup(const Widget2 *const widget,
- const std::string &group,
- const int height,
- const int spacing);
-
- A_DELETE_COPY(RadioGroup)
-
- Widget *createWidget(const std::string &name,
- const bool pressed)
- const override final A_WARN_UNUSED;
-};
-
-#endif // GUI_WIDGETS_RADIOGROUP_H
diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp
deleted file mode 100644
index e22ecdcf3..000000000
--- a/src/gui/widgets/scrollarea.cpp
+++ /dev/null
@@ -1,1460 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "gui/widgets/scrollarea.h"
-
-#include "settings.h"
-
-#include "gui/gui.h"
-#include "gui/skin.h"
-
-#include "utils/delete2.h"
-#include "utils/stringutils.h"
-
-#include "render/graphics.h"
-
-#include "render/vertexes/imagecollection.h"
-
-#include "resources/imagerect.h"
-
-#include "resources/image/image.h"
-
-#include "debug.h"
-
-int ScrollArea::instances = 0;
-float ScrollArea::mAlpha = 1.0;
-bool ScrollArea::mShowButtons = true;
-int ScrollArea::mMarkerSize = 0;
-int ScrollArea::mScrollbarSize = 12;
-ImageRect ScrollArea::background;
-ImageRect ScrollArea::vMarker;
-ImageRect ScrollArea::vMarkerHi;
-ImageRect ScrollArea::vBackground;
-ImageRect ScrollArea::hBackground;
-Image *ScrollArea::buttons[4][2];
-
-static std::string const buttonFiles[2] =
-{
- "scrollbuttons.xml",
- "scrollbuttons_pressed.xml"
-};
-
-ScrollArea::ScrollArea(Widget2 *const widget2,
- Widget *const widget,
- const Opaque opaque,
- const std::string &skin) :
- BasicContainer(widget2),
- MouseListener(),
- WidgetListener(),
- mVertexes(new ImageCollection),
- mVertexes2(new ImageCollection),
- mHPolicy(SHOW_AUTO),
- mVPolicy(SHOW_AUTO),
- mVScroll(0),
- mHScroll(0),
- mScrollbarWidth(12),
- mUpButtonScrollAmount(10),
- mDownButtonScrollAmount(10),
- mLeftButtonScrollAmount(10),
- mRightButtonScrollAmount(10),
- mHorizontalMarkerDragOffset(0),
- mVerticalMarkerDragOffset(0),
- mX(0),
- mY(0),
- mClickX(0),
- mClickY(0),
- mXOffset(0),
- mYOffset(0),
- mDrawWidth(0),
- mDrawHeight(0),
- mVBarVisible(false),
- mHBarVisible(false),
- mUpButtonPressed(false),
- mDownButtonPressed(false),
- mLeftButtonPressed(false),
- mRightButtonPressed(false),
- mIsVerticalMarkerDragged(false),
- mIsHorizontalMarkerDragged(false),
- mOpaque(Opaque_true),
- mHasMouse(false)
-{
- setContent(widget);
- addMouseListener(this);
- mOpaque = opaque;
- init(skin);
-}
-
-ScrollArea::~ScrollArea()
-{
- if (gui != nullptr)
- gui->removeDragged(this);
-
- // Garbage collection
- delete getContent();
-
- instances--;
- if (instances == 0)
- {
- Theme::unloadRect(background);
- Theme::unloadRect(vMarker);
- Theme::unloadRect(vMarkerHi);
- Theme::unloadRect(vBackground);
- Theme::unloadRect(hBackground);
- for (int i = 0; i < 2; i ++)
- {
- for (int f = UP; f < BUTTONS_DIR; f ++)
- {
- if (buttons[f][i] != nullptr)
- buttons[f][i]->decRef();
- }
- }
- }
-
- delete2(mVertexes);
- delete2(mVertexes2);
-
- setContent(nullptr);
-}
-
-void ScrollArea::init(std::string skinName)
-{
- setOpaque(mOpaque);
-
- setUpButtonScrollAmount(2);
- setDownButtonScrollAmount(2);
- setLeftButtonScrollAmount(2);
- setRightButtonScrollAmount(2);
-
- if (instances == 0)
- {
- for (int f = 0; f < 9; f ++)
- {
- background.grid[f] = nullptr;
- vMarker.grid[f] = nullptr;
- vMarkerHi.grid[f] = nullptr;
- vBackground.grid[f] = nullptr;
- hBackground.grid[f] = nullptr;
- }
-
- // +++ here probably need move background from static
- if (skinName.empty())
- skinName = "scroll_background.xml";
- if (theme != nullptr)
- {
- theme->loadRect(background, skinName, "scroll_background.xml");
- theme->loadRect(vMarker, "scroll.xml", "");
- theme->loadRect(vMarkerHi, "scroll_highlighted.xml", "scroll.xml");
- theme->loadRect(vBackground, "scroll_vbackground.xml", "");
- theme->loadRect(hBackground, "scroll_hbackground.xml", "");
- }
-
- for (int i = 0; i < 2; i ++)
- {
- Skin *skin = nullptr;
- if (theme != nullptr)
- skin = theme->load(buttonFiles[i], "scrollbuttons.xml");
- if (skin != nullptr)
- {
- const ImageRect &rect = skin->getBorder();
- for (int f = UP; f < BUTTONS_DIR; f ++)
- {
- if (rect.grid[f] != nullptr)
- rect.grid[f]->incRef();
- buttons[f][i] = rect.grid[f];
- }
- if (i == 0)
- {
- mShowButtons = (skin->getOption("showbuttons", 1) == 1);
- mMarkerSize = skin->getOption("markersize", 0);
- mScrollbarSize = skin->getOption("scrollbarsize", 12);
- }
- }
- else
- {
- for (int f = UP; f < BUTTONS_DIR; f ++)
- buttons[f][i] = nullptr;
- }
- if (theme != nullptr)
- theme->unload(skin);
- }
- }
- mScrollbarWidth = mScrollbarSize;
- instances++;
-}
-
-void ScrollArea::logic()
-{
- BLOCK_START("ScrollArea::logic")
- if (!isVisible())
- {
- BLOCK_END("ScrollArea::logic")
- return;
- }
-
- checkPolicies();
-
- setVerticalScrollAmount(mVScroll);
- setHorizontalScrollAmount(mHScroll);
-
- Widget *const content = getContent();
- if (content != nullptr)
- {
- unsigned int frameSize = content->getFrameSize();
- content->setPosition(-mHScroll + frameSize, -mVScroll + frameSize);
- content->logic();
-
- // When no scrollbar in a certain direction,
- // adapt content size to match the content dimension exactly.
- frameSize = 2 * content->getFrameSize();
- if (mHPolicy == ScrollArea::SHOW_NEVER)
- {
- content->setWidth((mVBarVisible ? (mDimension.width
- - mScrollbarWidth) : mDimension.width) - frameSize);
- }
- if (mVPolicy == ScrollArea::SHOW_NEVER)
- {
- content->setHeight((mHBarVisible ? (mDimension.height
- - mScrollbarWidth) : mDimension.height) - frameSize);
- }
- }
-
- if (mUpButtonPressed)
- setVerticalScrollAmount(mVScroll - mUpButtonScrollAmount);
- else if (mDownButtonPressed)
- setVerticalScrollAmount(mVScroll + mDownButtonScrollAmount);
- else if (mLeftButtonPressed)
- setHorizontalScrollAmount(mHScroll - mLeftButtonScrollAmount);
- else if (mRightButtonPressed)
- setHorizontalScrollAmount(mHScroll + mRightButtonScrollAmount);
- BLOCK_END("ScrollArea::logic")
-}
-
-void ScrollArea::updateAlpha()
-{
- const float alpha = std::max(settings.guiAlpha,
- theme->getMinimumOpacity());
-
- if (alpha != mAlpha)
- {
- mAlpha = alpha;
- for (int a = 0; a < 9; a++)
- {
- if (background.grid[a] != nullptr)
- background.grid[a]->setAlpha(mAlpha);
- if (hBackground.grid[a] != nullptr)
- hBackground.grid[a]->setAlpha(mAlpha);
- if (vBackground.grid[a] != nullptr)
- vBackground.grid[a]->setAlpha(mAlpha);
- if (vMarker.grid[a] != nullptr)
- vMarker.grid[a]->setAlpha(mAlpha);
- if (vMarkerHi.grid[a] != nullptr)
- vMarkerHi.grid[a]->setAlpha(mAlpha);
- }
- }
-}
-
-void ScrollArea::draw(Graphics *const graphics)
-{
- BLOCK_START("ScrollArea::draw")
- if (mVBarVisible || mHBarVisible)
- {
- if (mOpaque == Opaque_false)
- updateCalcFlag(graphics);
- // need add caching or remove calc calls.
-// if (mRedraw)
- {
- mVertexes->clear();
- if (mVBarVisible)
- {
- if (mShowButtons)
- {
- calcButton(graphics, UP);
- calcButton(graphics, DOWN);
- }
- calcVBar(graphics);
- calcVMarker(graphics);
- }
-
- if (mHBarVisible)
- {
- if (mShowButtons)
- {
- calcButton(graphics, LEFT);
- calcButton(graphics, RIGHT);
- }
- calcHBar(graphics);
- calcHMarker(graphics);
- }
- graphics->finalize(mVertexes);
- }
- graphics->drawTileCollection(mVertexes);
- }
-
- updateAlpha();
-
- if (mRedraw)
- {
- const bool redraw = graphics->getRedraw();
- graphics->setRedraw(true);
- drawChildren(graphics);
- graphics->setRedraw(redraw);
- }
- else
- {
- drawChildren(graphics);
- }
- mRedraw = false;
- BLOCK_END("ScrollArea::draw")
-}
-
-void ScrollArea::safeDraw(Graphics *const graphics)
-{
- BLOCK_START("ScrollArea::draw")
- if (mVBarVisible)
- {
- if (mShowButtons)
- {
- drawButton(graphics, UP);
- drawButton(graphics, DOWN);
- }
- drawVBar(graphics);
- drawVMarker(graphics);
- }
-
- if (mHBarVisible)
- {
- if (mShowButtons)
- {
- drawButton(graphics, LEFT);
- drawButton(graphics, RIGHT);
- }
- drawHBar(graphics);
- drawHMarker(graphics);
- }
-
- updateAlpha();
-
- safeDrawChildren(graphics);
- mRedraw = false;
- BLOCK_END("ScrollArea::draw")
-}
-
-void ScrollArea::updateCalcFlag(const Graphics *const graphics)
-{
- if (!mRedraw)
- {
- // because we don't know where parent windows was moved,
- // need recalc vertexes
- const ClipRect &rect = graphics->getTopClip();
- if (rect.xOffset != mXOffset || rect.yOffset != mYOffset)
- {
- mRedraw = true;
- mXOffset = rect.xOffset;
- mYOffset = rect.yOffset;
- }
- else if (rect.width != mDrawWidth || rect.height != mDrawHeight)
- {
- mRedraw = true;
- mDrawWidth = rect.width;
- mDrawHeight = rect.height;
- }
- else if (graphics->getRedraw())
- {
- mRedraw = true;
- }
- }
-}
-
-void ScrollArea::drawFrame(Graphics *const graphics)
-{
- BLOCK_START("ScrollArea::drawFrame")
- if (mOpaque == Opaque_true)
- {
- const int bs = mFrameSize * 2;
- const int w = mDimension.width + bs;
- const int h = mDimension.height + bs;
-
- updateCalcFlag(graphics);
-
- if (mRedraw)
- {
- mVertexes2->clear();
- graphics->calcWindow(mVertexes2,
- 0, 0,
- w, h,
- background);
- graphics->finalize(mVertexes2);
- }
- graphics->drawTileCollection(mVertexes2);
- }
- BLOCK_END("ScrollArea::drawFrame")
-}
-
-void ScrollArea::safeDrawFrame(Graphics *const graphics)
-{
- BLOCK_START("ScrollArea::drawFrame")
- if (mOpaque == Opaque_true)
- {
- const int bs = mFrameSize * 2;
- const int w = mDimension.width + bs;
- const int h = mDimension.height + bs;
-
- updateCalcFlag(graphics);
- graphics->drawImageRect(0, 0,
- w, h,
- background);
- }
- BLOCK_END("ScrollArea::drawFrame")
-}
-
-void ScrollArea::setOpaque(Opaque opaque)
-{
- mOpaque = opaque;
- setFrameSize(mOpaque == Opaque_true ? 2 : 0);
-}
-
-Image *ScrollArea::getImageByState(Rect &dim, const BUTTON_DIR dir)
-{
- int state = 0;
-
- switch (dir)
- {
- case UP:
- state = mUpButtonPressed ? 1 : 0;
- dim = getUpButtonDimension();
- break;
- case DOWN:
- state = mDownButtonPressed ? 1 : 0;
- dim = getDownButtonDimension();
- break;
- case LEFT:
- state = mLeftButtonPressed ? 1 : 0;
- dim = getLeftButtonDimension();
- break;
- case RIGHT:
- state = mRightButtonPressed ? 1 : 0;
- dim = getRightButtonDimension();
- break;
- case BUTTONS_DIR:
- default:
- logger->log("ScrollArea::drawButton unknown dir: "
- + toString(CAST_U32(dir)));
- return nullptr;
- }
- return buttons[CAST_SIZE(dir)][state];
-}
-
-void ScrollArea::drawButton(Graphics *const graphics,
- const BUTTON_DIR dir)
-{
- Rect dim;
- const Image *const image = getImageByState(dim, dir);
-
- if (image != nullptr)
- graphics->drawImage(image, dim.x, dim.y);
-}
-
-void ScrollArea::calcButton(Graphics *const graphics,
- const BUTTON_DIR dir)
-{
- Rect dim;
- const Image *const image = getImageByState(dim, dir);
-
- if (image != nullptr)
- {
- static_cast<Graphics*>(graphics)->calcTileCollection(
- mVertexes, image, dim.x, dim.y);
- }
-}
-
-void ScrollArea::drawVBar(Graphics *const graphics) const
-{
- const Rect &dim = getVerticalBarDimension();
-
- if (vBackground.grid[4] != nullptr)
- {
- graphics->drawPattern(vBackground.grid[4],
- dim.x, dim.y, dim.width, dim.height);
- }
- if (vBackground.grid[1] != nullptr)
- {
- graphics->drawPattern(vBackground.grid[1],
- dim.x, dim.y,
- dim.width, vBackground.grid[1]->getHeight());
- }
- if (vBackground.grid[7] != nullptr)
- {
- graphics->drawPattern(vBackground.grid[7],
- dim.x, dim.height - vBackground.grid[7]->getHeight() + dim.y,
- dim.width, vBackground.grid[7]->getHeight());
- }
-}
-
-void ScrollArea::calcVBar(const Graphics *const graphics)
-{
- const Rect &dim = getVerticalBarDimension();
-
- if (vBackground.grid[4] != nullptr)
- {
- graphics->calcPattern(mVertexes,
- vBackground.grid[4],
- dim.x, dim.y,
- dim.width, dim.height);
- }
- if (vBackground.grid[1] != nullptr)
- {
- graphics->calcPattern(mVertexes,
- vBackground.grid[1],
- dim.x, dim.y,
- dim.width, vBackground.grid[1]->getHeight());
- }
- if (vBackground.grid[7] != nullptr)
- {
- graphics->calcPattern(mVertexes,
- vBackground.grid[7],
- dim.x, dim.height - vBackground.grid[7]->getHeight() + dim.y,
- dim.width, vBackground.grid[7]->getHeight());
- }
-}
-
-void ScrollArea::drawHBar(Graphics *const graphics) const
-{
- const Rect &dim = getHorizontalBarDimension();
-
- if (hBackground.grid[4] != nullptr)
- {
- graphics->drawPattern(hBackground.grid[4],
- dim.x, dim.y,
- dim.width, dim.height);
- }
-
- if (hBackground.grid[3] != nullptr)
- {
- graphics->drawPattern(hBackground.grid[3],
- dim.x, dim.y,
- hBackground.grid[3]->getWidth(), dim.height);
- }
-
- if (hBackground.grid[5] != nullptr)
- {
- graphics->drawPattern(hBackground.grid[5],
- dim.x + dim.width - hBackground.grid[5]->getWidth(),
- dim.y,
- hBackground.grid[5]->getWidth(),
- dim.height);
- }
-}
-
-void ScrollArea::calcHBar(const Graphics *const graphics)
-{
- const Rect &dim = getHorizontalBarDimension();
-
- if (hBackground.grid[4] != nullptr)
- {
- graphics->calcPattern(mVertexes,
- hBackground.grid[4],
- dim.x, dim.y,
- dim.width, dim.height);
- }
-
- if (hBackground.grid[3] != nullptr)
- {
- graphics->calcPattern(mVertexes,
- hBackground.grid[3],
- dim.x, dim.y,
- hBackground.grid[3]->getWidth(), dim.height);
- }
-
- if (hBackground.grid[5] != nullptr)
- {
- graphics->calcPattern(mVertexes,
- hBackground.grid[5],
- dim.x + dim.width - hBackground.grid[5]->getWidth(),
- dim.y,
- hBackground.grid[5]->getWidth(),
- dim.height);
- }
-}
-
-void ScrollArea::drawVMarker(Graphics *const graphics)
-{
- const Rect &dim = getVerticalMarkerDimension();
-
- if ((mHasMouse) && (mX > (mDimension.width - mScrollbarWidth)))
- {
- graphics->drawImageRect(dim.x, dim.y,
- dim.width, dim.height,
- vMarkerHi);
- }
- else
- {
- graphics->drawImageRect(dim.x, dim.y,
- dim.width, dim.height,
- vMarker);
- }
-}
-
-void ScrollArea::calcVMarker(Graphics *const graphics)
-{
- const Rect &dim = getVerticalMarkerDimension();
-
- if ((mHasMouse) && (mX > (mDimension.width - mScrollbarWidth)))
- {
- graphics->calcWindow(mVertexes,
- dim.x, dim.y,
- dim.width, dim.height,
- vMarkerHi);
- }
- else
- {
- graphics->calcWindow(mVertexes,
- dim.x, dim.y,
- dim.width, dim.height,
- vMarker);
- }
-}
-
-void ScrollArea::drawHMarker(Graphics *const graphics)
-{
- const Rect dim = getHorizontalMarkerDimension();
-
- if ((mHasMouse) && (mY > (mDimension.height - mScrollbarWidth)))
- {
- graphics->drawImageRect(dim.x, dim.y,
- dim.width, dim.height,
- vMarkerHi);
- }
- else
- {
- graphics->drawImageRect(
- dim.x, dim.y,
- dim.width, dim.height,
- vMarker);
- }
-}
-
-void ScrollArea::calcHMarker(Graphics *const graphics)
-{
- const Rect dim = getHorizontalMarkerDimension();
-
- if ((mHasMouse) && (mY > (mDimension.height - mScrollbarWidth)))
- {
- graphics->calcWindow(mVertexes,
- dim.x, dim.y,
- dim.width, dim.height,
- vMarkerHi);
- }
- else
- {
- graphics->calcWindow(mVertexes,
- dim.x, dim.y,
- dim.width, dim.height,
- vMarker);
- }
-}
-
-void ScrollArea::mouseMoved(MouseEvent& event)
-{
- mX = event.getX();
- mY = event.getY();
-}
-
-void ScrollArea::mouseEntered(MouseEvent& event A_UNUSED)
-{
- mHasMouse = true;
-}
-
-void ScrollArea::mouseExited(MouseEvent& event A_UNUSED)
-{
- mHasMouse = false;
-}
-
-void ScrollArea::widgetResized(const Event &event A_UNUSED)
-{
- mRedraw = true;
- const unsigned int frameSize = 2 * mFrameSize;
- Widget *const content = getContent();
- if (content != nullptr)
- {
- content->setSize(mDimension.width - frameSize,
- mDimension.height - frameSize);
- }
-}
-
-void ScrollArea::widgetMoved(const Event& event A_UNUSED)
-{
- mRedraw = true;
-}
-
-void ScrollArea::mousePressed(MouseEvent& event)
-{
- const int x = event.getX();
- const int y = event.getY();
-
- if (getUpButtonDimension().isPointInRect(x, y))
- {
- setVerticalScrollAmount(mVScroll
- - mUpButtonScrollAmount);
- mUpButtonPressed = true;
- event.consume();
- }
- else if (getDownButtonDimension().isPointInRect(x, y))
- {
- setVerticalScrollAmount(mVScroll
- + mDownButtonScrollAmount);
- mDownButtonPressed = true;
- event.consume();
- }
- else if (getLeftButtonDimension().isPointInRect(x, y))
- {
- setHorizontalScrollAmount(mHScroll
- - mLeftButtonScrollAmount);
- mLeftButtonPressed = true;
- event.consume();
- }
- else if (getRightButtonDimension().isPointInRect(x, y))
- {
- setHorizontalScrollAmount(mHScroll
- + mRightButtonScrollAmount);
- mRightButtonPressed = true;
- event.consume();
- }
- else if (getVerticalMarkerDimension().isPointInRect(x, y))
- {
- mIsHorizontalMarkerDragged = false;
- mIsVerticalMarkerDragged = true;
-
- mVerticalMarkerDragOffset = y - getVerticalMarkerDimension().y;
- event.consume();
- }
- else if (getVerticalBarDimension().isPointInRect(x, y))
- {
- if (y < getVerticalMarkerDimension().y)
- {
- setVerticalScrollAmount(mVScroll
- - CAST_S32(getChildrenArea().height * 0.1));
- }
- else
- {
- setVerticalScrollAmount(mVScroll
- + CAST_S32(getChildrenArea().height * 0.1));
- }
- event.consume();
- }
- else if (getHorizontalMarkerDimension().isPointInRect(x, y))
- {
- mIsHorizontalMarkerDragged = true;
- mIsVerticalMarkerDragged = false;
- mHorizontalMarkerDragOffset = x - getHorizontalMarkerDimension().x;
- event.consume();
- }
- else if (getHorizontalBarDimension().isPointInRect(x, y))
- {
- if (x < getHorizontalMarkerDimension().x)
- {
- setHorizontalScrollAmount(mHScroll
- - CAST_S32(getChildrenArea().width * 0.1));
- }
- else
- {
- setHorizontalScrollAmount(mHScroll
- + CAST_S32(getChildrenArea().width * 0.1));
- }
- event.consume();
- }
-
- if (event.getButton() == MouseButton::LEFT &&
- !event.isConsumed())
- {
- mClickX = event.getX();
- mClickY = event.getY();
- }
-}
-
-void ScrollArea::mouseReleased(MouseEvent& event)
-{
- if (event.getButton() == MouseButton::LEFT &&
- mClickX != 0 &&
- mClickY != 0)
- {
- if (!event.isConsumed())
- {
-#ifdef ANDROID
- int dx = mClickX - event.getX();
- int dy = mClickY - event.getY();
-#else // ANDROID
-
- int dx = event.getX() - mClickX;
- int dy = event.getY() - mClickY;
-#endif // ANDROID
-
- if ((dx < 20 && dx > 0) || (dx > -20 && dx < 0))
- dx = 0;
-
- if ((dy < 20 && dy > 0) || (dy > -20 && dy < 0))
- dy = 0;
-
- if (abs(dx) > abs(dy))
- {
- int s = mHScroll + dx;
- if (s < 0)
- {
- s = 0;
- }
- else
- {
- const int maxH = getHorizontalMaxScroll();
- if (s > maxH)
- s = maxH;
- }
-
- setHorizontalScrollAmount(s);
- }
- else if (dy != 0)
- {
- int s = mVScroll + dy;
- if (s < 0)
- {
- s = 0;
- }
- else
- {
- const int maxV = getVerticalMaxScroll();
- if (s > maxV)
- s = maxV;
- }
-
- setVerticalScrollAmount(s);
- }
- mClickX = 0;
- mClickY = 0;
- if (mMouseConsume && ((dx != 0) || (dy != 0)))
- event.consume();
- }
- }
- mUpButtonPressed = false;
- mDownButtonPressed = false;
- mLeftButtonPressed = false;
- mRightButtonPressed = false;
- mIsHorizontalMarkerDragged = false;
- mIsVerticalMarkerDragged = false;
- if (mMouseConsume)
- event.consume();
- mRedraw = true;
-}
-
-void ScrollArea::mouseDragged(MouseEvent &event)
-{
- if (mIsVerticalMarkerDragged)
- {
- const Rect barDim = getVerticalBarDimension();
-
- const int pos = event.getY() - barDim.y
- - mVerticalMarkerDragOffset;
- const int length = getVerticalMarkerDimension().height;
-
- if ((barDim.height - length) > 0)
- {
- setVerticalScrollAmount((getVerticalMaxScroll() * pos)
- / (barDim.height - length));
- }
- else
- {
- setVerticalScrollAmount(0);
- }
- }
-
- if (mIsHorizontalMarkerDragged)
- {
- const Rect barDim = getHorizontalBarDimension();
-
- const int pos = event.getX() - barDim.x
- - mHorizontalMarkerDragOffset;
- const int length = getHorizontalMarkerDimension().width;
-
- if ((barDim.width - length) > 0)
- {
- setHorizontalScrollAmount((getHorizontalMaxScroll() * pos)
- / (barDim.width - length));
- }
- else
- {
- setHorizontalScrollAmount(0);
- }
- }
-
- event.consume();
- mRedraw = true;
-}
-
-Rect ScrollArea::getVerticalBarDimension() const
-{
- if (!mVBarVisible)
- return Rect(0, 0, 0, 0);
-
- const int height = mShowButtons ? mScrollbarWidth : 0;
- if (mHBarVisible)
- {
- return Rect(mDimension.width - mScrollbarWidth,
- height,
- mScrollbarWidth,
- mDimension.height - 2 * height - mScrollbarWidth);
- }
-
- return Rect(mDimension.width - mScrollbarWidth,
- height,
- mScrollbarWidth,
- mDimension.height - 2 * height);
-}
-
-Rect ScrollArea::getHorizontalBarDimension() const
-{
- if (!mHBarVisible)
- return Rect(0, 0, 0, 0);
-
- const int width = mShowButtons ? mScrollbarWidth : 0;
- if (mVBarVisible)
- {
- return Rect(width,
- mDimension.height - mScrollbarWidth,
- mDimension.width - 2 * width - mScrollbarWidth,
- mScrollbarWidth);
- }
-
- return Rect(width,
- mDimension.height - mScrollbarWidth,
- mDimension.width - 2 * width,
- mScrollbarWidth);
-}
-
-Rect ScrollArea::getVerticalMarkerDimension()
-{
- if (!mVBarVisible)
- return Rect(0, 0, 0, 0);
-
- int length, pos;
- int height;
- const int h2 = mShowButtons
- ? mScrollbarWidth : mMarkerSize / 2;
- const Widget *content;
- if (!mWidgets.empty())
- content = *mWidgets.begin();
- else
- content = nullptr;
-
- if (mHBarVisible)
- height = mDimension.height - 2 * h2 - mScrollbarWidth;
- else
- height = mDimension.height - 2 * h2;
-
- const int maxV = getVerticalMaxScroll();
- if ((mMarkerSize != 0) && (maxV != 0))
- {
- pos = (mVScroll * height / maxV - mMarkerSize / 2);
- length = mMarkerSize;
- }
- else
- {
- if (content != nullptr)
- {
- const int h3 = content->getHeight();
- if (h3 != 0)
- length = (height * getChildrenArea().height) / h3;
- else
- length = height;
- }
- else
- {
- length = height;
- }
-
- if (length < mScrollbarWidth)
- length = mScrollbarWidth;
-
- if (length > height)
- length = height;
-
- const int maxScroll = getVerticalMaxScroll();
- if (maxScroll != 0)
- pos = ((height - length) * mVScroll) / maxScroll;
- else
- pos = 0;
- }
-
- return Rect(mDimension.width - mScrollbarWidth, h2 + pos,
- mScrollbarWidth, length);
-}
-
-Rect ScrollArea::getHorizontalMarkerDimension()
-{
- if (!mHBarVisible)
- return Rect(0, 0, 0, 0);
-
- int length, pos;
- int width;
- const int w2 = mShowButtons
- ? mScrollbarWidth : mMarkerSize / 2;
- const Widget *content;
- if (!mWidgets.empty())
- content = *mWidgets.begin();
- else
- content = nullptr;
-
- if (mVBarVisible)
- width = mDimension.width - 2 * w2 - mScrollbarWidth;
- else
- width = mDimension.width - w2 - mScrollbarWidth;
-
- const int maxH = getHorizontalMaxScroll();
- if ((mMarkerSize != 0) && (maxH != 0))
- {
- pos = (mHScroll * width / maxH - mMarkerSize / 2);
- length = mMarkerSize;
- }
- else
- {
- if (content != nullptr)
- {
- const int w3 = content->getWidth();
- if (w3 != 0)
- length = (width * getChildrenArea().width) / w3;
- else
- length = width;
- }
- else
- {
- length = width;
- }
-
- if (length < mScrollbarWidth)
- length = mScrollbarWidth;
-
- if (length > width)
- length = width;
-
- if (getHorizontalMaxScroll() != 0)
- {
- pos = ((width - length) * mHScroll)
- / getHorizontalMaxScroll();
- }
- else
- {
- pos = 0;
- }
- }
-
- return Rect(w2 + pos, mDimension.height - mScrollbarWidth,
- length, mScrollbarWidth);
-}
-
-Rect ScrollArea::getUpButtonDimension() const
-{
- if (!mVBarVisible || !mShowButtons)
- return Rect(0, 0, 0, 0);
-
- return Rect(mDimension.width - mScrollbarWidth, 0,
- mScrollbarWidth, mScrollbarWidth);
-}
-
-Rect ScrollArea::getDownButtonDimension() const
-{
- if (!mVBarVisible || !mShowButtons)
- return Rect(0, 0, 0, 0);
-
- if (mHBarVisible)
- {
- return Rect(mDimension.width - mScrollbarWidth,
- mDimension.height - mScrollbarWidth * 2,
- mScrollbarWidth,
- mScrollbarWidth);
- }
-
- return Rect(mDimension.width - mScrollbarWidth,
- mDimension.height - mScrollbarWidth,
- mScrollbarWidth,
- mScrollbarWidth);
-}
-
-Rect ScrollArea::getLeftButtonDimension() const
-{
- if (!mHBarVisible || !mShowButtons)
- return Rect(0, 0, 0, 0);
-
- return Rect(0, mDimension.height - mScrollbarWidth,
- mScrollbarWidth, mScrollbarWidth);
-}
-
-Rect ScrollArea::getRightButtonDimension() const
-{
- if (!mHBarVisible || !mShowButtons)
- return Rect(0, 0, 0, 0);
-
- if (mVBarVisible)
- {
- return Rect(mDimension.width - mScrollbarWidth*2,
- mDimension.height - mScrollbarWidth,
- mScrollbarWidth,
- mScrollbarWidth);
- }
-
- return Rect(mDimension.width - mScrollbarWidth,
- mDimension.height - mScrollbarWidth,
- mScrollbarWidth,
- mScrollbarWidth);
-}
-
-void ScrollArea::setContent(Widget* widget)
-{
- if (widget != nullptr)
- {
- clear();
- add(widget);
- widget->setPosition(0, 0);
- }
- else
- {
- clear();
- }
-
- checkPolicies();
-}
-
-Widget* ScrollArea::getContent()
-{
- if (!mWidgets.empty())
- return *mWidgets.begin();
-
- return nullptr;
-}
-
-void ScrollArea::setHorizontalScrollPolicy(const ScrollPolicy hPolicy)
-{
- mHPolicy = hPolicy;
- checkPolicies();
-}
-
-void ScrollArea::setVerticalScrollPolicy(const ScrollPolicy vPolicy)
-{
- mVPolicy = vPolicy;
- checkPolicies();
-}
-
-void ScrollArea::setScrollPolicy(const ScrollPolicy hPolicy,
- const ScrollPolicy vPolicy)
-{
- mHPolicy = hPolicy;
- mVPolicy = vPolicy;
- checkPolicies();
-}
-
-void ScrollArea::setVerticalScrollAmount(const int vScroll)
-{
- const int max = getVerticalMaxScroll();
-
- mVScroll = vScroll;
-
- if (vScroll > max)
- mVScroll = max;
-
- if (vScroll < 0)
- mVScroll = 0;
-}
-
-void ScrollArea::setHorizontalScrollAmount(int hScroll)
-{
- const int max = getHorizontalMaxScroll();
-
- mHScroll = hScroll;
-
- if (hScroll > max)
- mHScroll = max;
- else if (hScroll < 0)
- mHScroll = 0;
-}
-
-void ScrollArea::setScrollAmount(const int hScroll, const int vScroll)
-{
- setHorizontalScrollAmount(hScroll);
- setVerticalScrollAmount(vScroll);
-}
-
-int ScrollArea::getHorizontalMaxScroll()
-{
- checkPolicies();
-
- const Widget *const content = getContent();
- if (content == nullptr)
- return 0;
-
- const int value = content->getWidth() - getChildrenArea().width +
- 2 * content->getFrameSize();
-
- if (value < 0)
- return 0;
-
- return value;
-}
-
-int ScrollArea::getVerticalMaxScroll()
-{
- checkPolicies();
-
- const Widget *const content = getContent();
- if (content == nullptr)
- return 0;
-
- int value;
-
- value = content->getHeight() - getChildrenArea().height +
- 2 * content->getFrameSize();
-
- if (value < 0)
- return 0;
-
- return value;
-}
-
-void ScrollArea::setScrollbarWidth(const int width)
-{
- if (width > 0)
- mScrollbarWidth = width;
-}
-
-void ScrollArea::showWidgetPart(Widget *const widget, const Rect &area)
-{
- const Widget *const content = getContent();
- if (widget != content || (content == nullptr))
- return;
-
- BasicContainer::showWidgetPart(widget, area);
-
- setHorizontalScrollAmount(content->getFrameSize()
- - content->getX());
- setVerticalScrollAmount(content->getFrameSize()
- - content->getY());
-}
-
-Rect ScrollArea::getChildrenArea()
-{
- const Rect area = Rect(0, 0,
- mVBarVisible ? (getWidth() - mScrollbarWidth) : getWidth(),
- mHBarVisible ? (getHeight() - mScrollbarWidth) : getHeight());
-
- if (area.width < 0 || area.height < 0)
- return Rect();
-
- return area;
-}
-
-Widget *ScrollArea::getWidgetAt(int x, int y)
-{
- if (getChildrenArea().isPointInRect(x, y))
- return getContent();
-
- return nullptr;
-}
-
-void ScrollArea::setWidth(int width)
-{
- Widget::setWidth(width);
- checkPolicies();
-}
-
-void ScrollArea::setHeight(int height)
-{
- Widget::setHeight(height);
- checkPolicies();
-}
-
-void ScrollArea::setDimension(const Rect& dimension)
-{
- Widget::setDimension(dimension);
- checkPolicies();
-}
-
-void ScrollArea::mouseWheelMovedUp(MouseEvent& event)
-{
- if (event.isConsumed())
- return;
-
- setVerticalScrollAmount(mVScroll
- - getChildrenArea().height / 8);
-
- event.consume();
-}
-
-void ScrollArea::mouseWheelMovedDown(MouseEvent& event)
-{
- if (event.isConsumed())
- return;
-
- setVerticalScrollAmount(mVScroll
- + getChildrenArea().height / 8);
-
- event.consume();
-}
-
-void ScrollArea::checkPolicies()
-{
- const int w = getWidth();
- const int h = getHeight();
-
- mHBarVisible = false;
- mVBarVisible = false;
-
- const Widget *const content = getContent();
- if (content == nullptr)
- {
- mHBarVisible = (mHPolicy == SHOW_ALWAYS);
- mVBarVisible = (mVPolicy == SHOW_ALWAYS);
- return;
- }
-
- if (mHPolicy == SHOW_AUTO &&
- mVPolicy == SHOW_AUTO)
- {
- if (content->getWidth() <= w
- && content->getHeight() <= h)
- {
- mHBarVisible = false;
- mVBarVisible = false;
- }
-
- if (content->getWidth() > w)
- {
- mHBarVisible = true;
- }
-
- if ((content->getHeight() > h)
- || (mHBarVisible && content->getHeight()
- > h - mScrollbarWidth))
- {
- mVBarVisible = true;
- }
-
- if (mVBarVisible && content->getWidth() > w - mScrollbarWidth)
- mHBarVisible = true;
-
- return;
- }
-
- switch (mHPolicy)
- {
- case SHOW_NEVER:
- mHBarVisible = false;
- break;
-
- case SHOW_ALWAYS:
- mHBarVisible = true;
- break;
-
- case SHOW_AUTO:
- if (mVPolicy == SHOW_NEVER)
- {
- mHBarVisible = (content->getWidth() > w);
- }
- else // (mVPolicy == SHOW_ALWAYS)
- {
- mHBarVisible = (content->getWidth()
- > w - mScrollbarWidth);
- }
- break;
-
- default:
- break;
- }
-
- switch (mVPolicy)
- {
- case SHOW_NEVER:
- mVBarVisible = false;
- break;
-
- case SHOW_ALWAYS:
- mVBarVisible = true;
- break;
-
- case SHOW_AUTO:
- if (mHPolicy == SHOW_NEVER)
- {
- mVBarVisible = (content->getHeight() > h);
- }
- else // (mHPolicy == SHOW_ALWAYS)
- {
- mVBarVisible = (content->getHeight()
- > h - mScrollbarWidth);
- }
- break;
- default:
- break;
- }
-}
-
-bool ScrollArea::isSelectable() const noexcept2
-{
- if (mVBarVisible || mHBarVisible)
- return true;
- return Widget::isSelectable();
-}
diff --git a/src/gui/widgets/scrollarea.h b/src/gui/widgets/scrollarea.h
deleted file mode 100644
index 50b194d28..000000000
--- a/src/gui/widgets/scrollarea.h
+++ /dev/null
@@ -1,598 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GUI_WIDGETS_SCROLLAREA_H
-#define GUI_WIDGETS_SCROLLAREA_H
-
-#include "gui/widgets/basiccontainer.h"
-
-#include "enums/simpletypes/opaque.h"
-
-#include "listeners/mouselistener.h"
-#include "listeners/widgetlistener.h"
-
-#include "localconsts.h"
-
-class Image;
-class ImageCollection;
-
-/**
- * A scroll area.
- *
- * Contrary to Guichan's scroll area, this scroll area takes ownership over its
- * content. However, it won't delete a previously set content widget when
- * setContent is called!
- *
- * \ingroup GUI
- */
-class ScrollArea final : public BasicContainer,
- public MouseListener,
- public WidgetListener
-{
- public:
- /**
- * Scrollpolicies for the horizontal and vertical scrollbar.
- * The policies are:
- *
- * SHOW_ALWAYS - Always show the scrollbars no matter what.
- * SHOW_NEVER - Never show the scrollbars no matter waht.
- * SHOW_AUTO - Show the scrollbars only when needed. That is if the
- * content grows larger then the ScrollArea.
- */
- enum ScrollPolicy
- {
- SHOW_ALWAYS = 0,
- SHOW_NEVER,
- SHOW_AUTO
- };
-
- ScrollArea(Widget2 *const widget2,
- Widget *const widget,
- const Opaque opaque = Opaque_true,
- const std::string &skin = "");
-
- A_DELETE_COPY(ScrollArea)
-
- /**
- * Destructor. Also deletes the content.
- */
- ~ScrollArea();
-
- /**
- * Logic function optionally adapts width or height of contents. This
- * depends on the scrollbar settings.
- */
- void logic() override final;
-
- /**
- * Update the alpha value to the graphic components.
- */
- void updateAlpha();
-
- /**
- * Draws the scroll area.
- */
- void draw(Graphics *const graphics) override final A_NONNULL(2);
-
- void safeDraw(Graphics *const graphics) override final A_NONNULL(2);
-
- /**
- * Draws the background and border of the scroll area.
- */
- void drawFrame(Graphics *const graphics) override final A_NONNULL(2);
-
- void safeDrawFrame(Graphics *const graphics) override final
- A_NONNULL(2);
-
- /**
- * Sets whether the widget should draw its background or not.
- */
- void setOpaque(Opaque opaque);
-
- /**
- * Returns whether the widget draws its background or not.
- */
- bool isOpaque() const noexcept2 A_WARN_UNUSED
- { return mOpaque == Opaque_true; }
-
- /**
- * Called when the mouse moves in the widget area.
- */
- void mouseMoved(MouseEvent& event) override final;
-
- /**
- * Called when the mouse enteres the widget area.
- */
- void mouseEntered(MouseEvent& event) override final;
-
- /**
- * Called when the mouse leaves the widget area.
- */
- void mouseExited(MouseEvent& event) override final;
-
- void mousePressed(MouseEvent& event) override final;
-
- void mouseReleased(MouseEvent& event) override final;
-
- void mouseDragged(MouseEvent &event) override final;
-
- void widgetResized(const Event &event) override final;
-
- void widgetMoved(const Event &event) override final;
-
- Rect getVerticalBarDimension() const;
-
- Rect getHorizontalBarDimension() const;
-
- Rect getVerticalMarkerDimension();
-
- Rect getHorizontalMarkerDimension();
-
- Rect getUpButtonDimension() const;
-
- Rect getDownButtonDimension() const;
-
- Rect getLeftButtonDimension() const;
-
- Rect getRightButtonDimension() const;
-
- /**
- * Sets the content.
- *
- * @param widget The content of the scroll area.
- */
- void setContent(Widget* widget);
-
- /**
- * Gets the content.
- *
- * @return The content of the scroll area.
- */
- Widget* getContent();
-
- /**
- * Sets the horizontal scrollbar policy. See enum with policies.
- *
- * @param hPolicy The policy for the horizontal scrollbar.
- * @see getHorizontalScrollPolicy
- */
- void setHorizontalScrollPolicy(const ScrollPolicy hPolicy);
-
- /**
- * Gets the horizontal scrollbar policy. See enum with policies.
- *
- * @return The policy for the horizontal scrollbar policy.
- * @see setHorizontalScrollPolicy, setScrollPolicy
- */
- ScrollPolicy getHorizontalScrollPolicy() const
- { return mHPolicy; }
-
- /**
- * Sets the vertical scrollbar policy. See enum with policies.
- *
- * @param vPolicy The policy for the vertical scrollbar.
- * @see getVerticalScrollPolicy
- */
- void setVerticalScrollPolicy(const ScrollPolicy vPolicy);
-
- /**
- * Gets the vertical scrollbar policy. See enum with policies.
- *
- * @return The policy for the vertical scrollbar.
- * @see setVerticalScrollPolicy, setScrollPolicy
- */
- ScrollPolicy getVerticalScrollPolicy() const
- { return mVPolicy; }
-
- /**
- * Sets the horizontal and vertical scrollbar policy.
- *
- * @param hPolicy The policy for the horizontal scrollbar.
- * @param vPolicy The policy for the vertical scrollbar.
- * @see getVerticalScrollPolicy, getHorizontalScrollPolicy
- */
- void setScrollPolicy(const ScrollPolicy hPolicy,
- const ScrollPolicy vPolicy);
-
- /**
- * Sets the amount to scroll vertically.
- *
- * @param vScroll The amount to scroll.
- * @see getVerticalScrollAmount
- */
- void setVerticalScrollAmount(const int vScroll);
-
- /**
- * Gets the amount that is scrolled vertically.
- *
- * @return The scroll amount on vertical scroll.
- * @see setVerticalScrollAmount, setScrollAmount
- */
- int getVerticalScrollAmount() const
- { return mVScroll; }
-
- /**
- * Sets the amount to scroll horizontally.
- *
- * @param hScroll The amount to scroll.
- * @see getHorizontalScrollAmount
- */
- void setHorizontalScrollAmount(int hScroll);
-
- /**
- * Gets the amount that is scrolled horizontally.
- *
- * @return The scroll amount on horizontal scroll.
- * @see setHorizontalScrollAmount, setScrollAmount
- */
- int getHorizontalScrollAmount() const
- { return mHScroll; }
-
- /**
- * Sets the amount to scroll horizontally and vertically.
- *
- * @param hScroll The amount to scroll on horizontal scroll.
- * @param vScroll The amount to scroll on vertical scroll.
- * @see getHorizontalScrollAmount, getVerticalScrollAmount
- */
- void setScrollAmount(const int hScroll, const int vScroll);
-
- /**
- * Gets the maximum amount of horizontal scroll.
- *
- * @return The horizontal max scroll.
- */
- int getHorizontalMaxScroll();
-
- /**
- * Gets the maximum amount of vertical scroll.
- *
- * @return The vertical max scroll.
- */
- int getVerticalMaxScroll();
-
- /**
- * Sets the width of the scroll bars.
- *
- * @param width The width of the scroll bars.
- * @see getScrollbarWidth
- */
- void setScrollbarWidth(const int width);
-
- /**
- * Gets the width of the scroll bars.
- *
- * @return the width of the ScrollBar.
- * @see setScrollbarWidth
- */
- int getScrollbarWidth() const
- { return mScrollbarWidth; }
-
- /**
- * Sets the amount to scroll in pixels when the left scroll button is
- * pushed.
- *
- * @param amount The amount to scroll in pixels.
- * @see getLeftButtonScrollAmount
- */
- void setLeftButtonScrollAmount(const int amount)
- { mLeftButtonScrollAmount = amount; }
-
- /**
- * Sets the amount to scroll in pixels when the right scroll button is
- * pushed.
- *
- * @param amount The amount to scroll in pixels.
- * @see getRightButtonScrollAmount
- */
- void setRightButtonScrollAmount(const int amount)
- { mRightButtonScrollAmount = amount; }
-
- /**
- * Sets the amount to scroll in pixels when the up scroll button is
- * pushed.
- *
- * @param amount The amount to scroll in pixels.
- * @see getUpButtonScrollAmount
- */
- void setUpButtonScrollAmount(const int amount)
- { mUpButtonScrollAmount = amount; }
-
- /**
- * Sets the amount to scroll in pixels when the down scroll button is
- * pushed.
- *
- * @param amount The amount to scroll in pixels.
- * @see getDownButtonScrollAmount
- */
- void setDownButtonScrollAmount(const int amount)
- { mDownButtonScrollAmount = amount; }
-
- /**
- * Gets the amount to scroll in pixels when the left scroll button is
- * pushed.
- *
- * @return The amount to scroll in pixels.
- * @see setLeftButtonScrollAmount
- */
- int getLeftButtonScrollAmount() const
- { return mLeftButtonScrollAmount; }
-
- /**
- * Gets the amount to scroll in pixels when the right scroll button is
- * pushed.
- *
- * @return The amount to scroll in pixels.
- * @see setRightButtonScrollAmount
- */
- int getRightButtonScrollAmount() const
- { return mRightButtonScrollAmount; }
-
- /**
- * Gets the amount to scroll in pixels when the up scroll button is
- * pushed.
- *
- * @return The amount to scroll in pixels.
- * @see setUpButtonScrollAmount
- */
- int getUpButtonScrollAmount() const
- { return mUpButtonScrollAmount; }
-
- /**
- * Gets the amount to scroll in pixels when the down scroll button is
- * pushed.
- *
- * @return The amount to scroll in pixels.
- * @see setDownButtonScrollAmount
- */
- int getDownButtonScrollAmount() const
- { return mDownButtonScrollAmount; }
-
- void showWidgetPart(Widget *const widget,
- const Rect &area) override final;
-
- Rect getChildrenArea() override final;
-
- Widget *getWidgetAt(int x, int y) override final;
-
- void setWidth(int width);
-
- void setHeight(int height);
-
- void setDimension(const Rect& dimension);
-
- void mouseWheelMovedUp(MouseEvent& event) override final;
-
- void mouseWheelMovedDown(MouseEvent& event) override final;
-
- bool isSelectable() const noexcept2 override final A_WARN_UNUSED;
-
- protected:
- enum BUTTON_DIR
- {
- UP = 0,
- DOWN,
- LEFT,
- RIGHT,
- BUTTONS_DIR
- };
-
- /**
- * Initializes the scroll area.
- */
- void init(std::string skinName);
-
- /**
- * Checks the policies for the scroll bars.
- */
- void checkPolicies();
-
- void drawButton(Graphics *const graphics,
- const BUTTON_DIR dir) A_NONNULL(2);
- void calcButton(Graphics *const graphics,
- const BUTTON_DIR dir) A_NONNULL(2);
- void drawVBar(Graphics *const graphics) const A_NONNULL(2);
- void drawHBar(Graphics *const graphics) const A_NONNULL(2);
- void drawVMarker(Graphics *const graphics) A_NONNULL(2);
- void drawHMarker(Graphics *const graphics) A_NONNULL(2);
-
- void calcVBar(const Graphics *const graphics) A_NONNULL(2);
- void calcHBar(const Graphics *const graphics) A_NONNULL(2);
- void calcVMarker(Graphics *const graphics) A_NONNULL(2);
- void calcHMarker(Graphics *const graphics) A_NONNULL(2);
-
- Image *getImageByState(Rect &dim, const BUTTON_DIR dir);
-
- void updateCalcFlag(const Graphics *const graphics) A_NONNULL(2);
-
- static int instances;
- static float mAlpha;
- static bool mShowButtons;
- static int mMarkerSize;
- static int mScrollbarSize;
- static ImageRect background;
- static ImageRect vMarker;
- static ImageRect vMarkerHi;
- static ImageRect vBackground;
- static ImageRect hBackground;
- static Image *buttons[4][2];
-
- ImageCollection *mVertexes A_NONNULLPOINTER;
- ImageCollection *mVertexes2 A_NONNULLPOINTER;
-
- /**
- * Holds the horizontal scroll bar policy.
- */
- ScrollPolicy mHPolicy;
-
- /**
- * Holds the vertical scroll bar policy.
- */
- ScrollPolicy mVPolicy;
-
- /**
- * Holds the vertical scroll amount.
- */
- int mVScroll;
-
- /**
- * Holds the horizontal scroll amount.
- */
- int mHScroll;
-
- /**
- * Holds the width of the scroll bars.
- */
- int mScrollbarWidth;
-
- /**
- * Holds the up button scroll amount.
- */
- int mUpButtonScrollAmount;
-
- /**
- * Holds the down button scroll amount.
- */
- int mDownButtonScrollAmount;
-
- /**
- * Holds the left button scroll amount.
- */
- int mLeftButtonScrollAmount;
-
- /**
- * Holds the right button scroll amount.
- */
- int mRightButtonScrollAmount;
-
- /**
- * Holds the horizontal markers drag offset.
- */
- int mHorizontalMarkerDragOffset;
-
- /**
- * Holds the vertical markers drag offset.
- */
- int mVerticalMarkerDragOffset;
-
- int mX;
- int mY;
- int mClickX;
- int mClickY;
- int mXOffset;
- int mYOffset;
- int mDrawWidth;
- int mDrawHeight;
-
- /**
- * True if the vertical scroll bar is visible, false otherwise.
- */
- bool mVBarVisible;
-
- /**
- * True if the horizontal scroll bar is visible, false otherwise.
- */
- bool mHBarVisible;
-
- /**
- * True if the up button is pressed, false otherwise.
- */
- bool mUpButtonPressed;
-
- /**
- * True if the down button is pressed, false otherwise.
- */
- bool mDownButtonPressed;
-
- /**
- * True if the left button is pressed, false otherwise.
- */
- bool mLeftButtonPressed;
-
- /**
- * True if the right button is pressed, false otherwise.
- */
- bool mRightButtonPressed;
-
- /**
- * True if the vertical marked is dragged.
- */
- bool mIsVerticalMarkerDragged;
-
- /**
- * True if the horizontal marked is dragged.
- */
- bool mIsHorizontalMarkerDragged;
-
- /**
- * True if the scroll area should be opaque (that is
- * display its background), false otherwise.
- */
- Opaque mOpaque;
-
- bool mHasMouse;
-};
-
-#endif // GUI_WIDGETS_SCROLLAREA_H
diff --git a/src/gui/widgets/selldialog.cpp b/src/gui/widgets/selldialog.cpp
deleted file mode 100644
index 68b9a039f..000000000
--- a/src/gui/widgets/selldialog.cpp
+++ /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/>.
- */
-
-#include "gui/widgets/selldialog.h"
-
-#include "const/resources/currency.h"
-
-#include "enums/gui/layouttype.h"
-
-#include "gui/windows/setupwindow.h"
-
-#include "gui/models/shopitems.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/containerplacer.h"
-#include "gui/widgets/createwidget.h"
-#include "gui/widgets/label.h"
-#include "gui/widgets/layout.h"
-#include "gui/widgets/scrollarea.h"
-#include "gui/widgets/shoplistbox.h"
-#include "gui/widgets/slider.h"
-
-#include "utils/delete2.h"
-#include "utils/foreach.h"
-#include "utils/gettext.h"
-#include "utils/stringutils.h"
-
-#include "resources/db/unitsdb.h"
-
-#include "resources/item/shopitem.h"
-
-#include "debug.h"
-
-SellDialog::DialogList SellDialog::instances;
-
-SellDialog::SellDialog(const IsSell isSell,
- const Advanced advanced) :
- // TRANSLATORS: sell dialog name
- Window(_("Sell"), Modal_false, nullptr, "sell.xml"),
- ActionListener(),
- SelectionListener(),
- mSellButton(nullptr),
- mQuitButton(nullptr),
- mConfirmButton(nullptr),
- mAddMaxButton(nullptr),
- mIncreaseButton(nullptr),
- mDecreaseButton(nullptr),
- mShopItemList(nullptr),
- mScrollArea(nullptr),
- mMoneyLabel(nullptr),
- mQuantityLabel(nullptr),
- mSlider(nullptr),
- mShopItems(nullptr),
- mPlayerMoney(0),
- mMaxItems(0),
- mAmountItems(0),
- mIsSell(isSell),
- mAdvanced(advanced)
-{
-}
-
-void SellDialog::postInit()
-{
- Window::postInit();
- setWindowName("Sell");
- setResizable(true);
- setCloseButton(true);
- setStickyButtonLock(true);
- setMinWidth(260);
- setMinHeight(220);
- setDefaultSize(260, 230, ImagePosition::CENTER);
-
- if (setupWindow != nullptr)
- setupWindow->registerWindowForReset(this);
-
- // Create a ShopItems instance, that is aware of duplicate entries.
- mShopItems = new ShopItems(true,
- DEFAULT_CURRENCY);
-
- if (mAdvanced == Advanced_true)
- mShopItems->setMergeDuplicates(false);
-
- mShopItemList = CREATEWIDGETR(ShopListBox,
- this,
- mShopItems,
- mShopItems,
- ShopListBoxType::Unknown);
- mShopItemList->setProtectItems(true);
- mScrollArea = new ScrollArea(this, mShopItemList,
- fromBool(getOptionBool("showbackground"), Opaque),
- "sell_background.xml");
- mScrollArea->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
-
- mSellButton = new Button(this,
- // TRANSLATORS: sell dialog button
- mAdvanced == Advanced_true ? _("Add") : _("Sell"),
- "presell",
- this);
- // TRANSLATORS: sell dialog button
- mQuitButton = new Button(this, _("Quit"), "quit", this);
-
- initButtons();
-
- mSellButton->setEnabled(false);
-
- mShopItemList->setDistributeMousePressed(false);
- mShopItemList->setPriceCheck(false);
- mShopItemList->addSelectionListener(this);
- mShopItemList->setActionEventId("sell");
- mShopItemList->addActionListener(this);
-
- ContainerPlacer placer;
- placer = getPlacer(0, 0);
-
- if (mIsSell == IsSell_true)
- {
- // TRANSLATORS: sell dialog button
- mIncreaseButton = new Button(this, _("+"), "inc", this);
- // TRANSLATORS: sell dialog button
- mDecreaseButton = new Button(this, _("-"), "dec", this);
- // TRANSLATORS: sell dialog button
- mAddMaxButton = new Button(this, _("Max"), "max", this);
- mSlider = new Slider(this, 1.0, 1.0);
-
- mQuantityLabel = new Label(this, strprintf(
- "%d / %d", mAmountItems, mMaxItems));
- mQuantityLabel->setAlignment(Graphics::CENTER);
- // TRANSLATORS: sell dialog label
- mMoneyLabel = new Label(this, strprintf(_("Price: %s / Total: %s"),
- "", ""));
- if (mAdvanced == Advanced_true)
- {
- // TRANSLATORS: sell dialog button
- mConfirmButton = new Button(this, _("Sell"), "confirm", this);
- mConfirmButton->setEnabled(false);
- }
-
- mDecreaseButton->adjustSize();
- mDecreaseButton->setWidth(mIncreaseButton->getWidth());
- mIncreaseButton->setEnabled(false);
- mDecreaseButton->setEnabled(false);
- mSlider->setEnabled(false);
- mSlider->setActionEventId("slider");
- mSlider->addActionListener(this);
-
- placer(0, 0, mScrollArea, 8, 5).setPadding(3);
- placer(0, 5, mDecreaseButton);
- placer(1, 5, mSlider, 3);
- placer(4, 5, mIncreaseButton);
- placer(5, 5, mQuantityLabel, 2);
- placer(7, 5, mAddMaxButton);
- placer(0, 6, mMoneyLabel, 8);
- if (mAdvanced == Advanced_true)
- {
- placer(5, 7, mSellButton);
- placer(6, 7, mConfirmButton);
- }
- else
- {
- placer(6, 7, mSellButton);
- }
- placer(7, 7, mQuitButton);
- }
- else
- {
- placer(0, 0, mScrollArea, 8, 5).setPadding(3);
- placer(6, 5, mSellButton);
- placer(7, 5, mQuitButton);
- }
-
- Layout &layout = getLayout();
- layout.setRowHeight(0, LayoutType::SET);
-
- center();
- loadWindowState();
-
- instances.push_back(this);
- setVisible(Visible_true);
- enableVisibleSound(true);
-}
-
-SellDialog::~SellDialog()
-{
- delete2(mShopItems);
- instances.remove(this);
-}
-
-void SellDialog::reset()
-{
- mShopItems->clear();
- if (mSlider != nullptr)
- mSlider->setValue(0);
- mShopItemList->setSelected(-1);
- updateButtonsAndLabels();
-}
-
-void SellDialog::addItem(const Item *const item, const int price)
-{
- if (item == nullptr)
- return;
-
- mShopItems->addItem2(item->getInvIndex(),
- item->getId(),
- item->getType(),
- item->getColor(),
- item->getQuantity(),
- price);
-
- mShopItemList->adjustSize();
-}
-
-ShopItem *SellDialog::addItem(const int id,
- const ItemTypeT type,
- const ItemColor color,
- const int amount,
- const int price)
-{
- ShopItem *const item = mShopItems->addItem(id,
- type,
- color,
- amount,
- price);
- mShopItemList->adjustSize();
- return item;
-}
-
-
-void SellDialog::action(const ActionEvent &event)
-{
- const std::string &eventId = event.getId();
-
- if (eventId == "quit")
- {
- close();
- return;
- }
-
- const int selectedItem = mShopItemList->getSelected();
-
- // The following actions require a valid item selection
- if (selectedItem == -1
- || selectedItem >= mShopItems->getNumberOfElements())
- {
- return;
- }
-
- if (eventId == "slider")
- {
- if (mSlider != nullptr)
- {
- mAmountItems = CAST_S32(mSlider->getValue());
- updateButtonsAndLabels();
- }
- }
- else if (eventId == "inc" &&
- mSlider != nullptr &&
- mAmountItems < mMaxItems)
- {
- mAmountItems++;
- mSlider->setValue(mAmountItems);
- updateButtonsAndLabels();
- }
- else if (eventId == "dec" &&
- mSlider != nullptr &&
- mAmountItems > 1)
- {
- mAmountItems--;
- mSlider->setValue(mAmountItems);
- updateButtonsAndLabels();
- }
- else if (eventId == "max" &&
- mSlider != nullptr)
- {
- mAmountItems = mMaxItems;
- mSlider->setValue(mAmountItems);
- updateButtonsAndLabels();
- }
- else if (eventId == "presell" ||
- eventId == "sell" ||
- eventId == "yes" ||
- eventId == "confirm")
- {
- sellAction(event);
- }
-}
-
-void SellDialog::valueChanged(const SelectionEvent &event A_UNUSED)
-{
- // Reset amount of items and update labels
- mAmountItems = 1;
- if (mSlider != nullptr)
- {
- mSlider->setValue(0);
- mSlider->setScale(1, mMaxItems);
- }
- updateButtonsAndLabels();
-}
-
-void SellDialog::setMoney(const int amount)
-{
- mPlayerMoney = amount;
- mShopItemList->setPlayersMoney(amount);
-}
-
-void SellDialog::updateButtonsAndLabels()
-{
- const int selectedItem = mShopItemList->getSelected();
- int income = 0;
- ShopItem *item = nullptr;
-
- if (selectedItem > -1 && (mShopItems->at(selectedItem) != nullptr))
- {
- item = mShopItems->at(selectedItem);
- if (item != nullptr)
- {
- mMaxItems = item->getQuantity();
- if (mAmountItems > mMaxItems)
- mAmountItems = mMaxItems;
- income = mAmountItems * mShopItems->at(selectedItem)->getPrice();
- }
- else
- {
- mMaxItems = 0;
- mAmountItems = 0;
- }
- }
- else
- {
- mMaxItems = 0;
- mAmountItems = 0;
- }
-
- // Update Buttons and slider
- mSellButton->setEnabled(mAmountItems > 0);
- if (mDecreaseButton != nullptr)
- mDecreaseButton->setEnabled(mAmountItems > 1);
- if (mIncreaseButton != nullptr)
- mIncreaseButton->setEnabled(mAmountItems < mMaxItems);
- if (mSlider != nullptr)
- mSlider->setEnabled(mMaxItems > 1);
-
- if (mQuantityLabel != nullptr)
- {
- // Update the quantity and money labels
- mQuantityLabel->setCaption(strprintf("%d / %d",
- mAmountItems, mMaxItems));
- }
- if (mMoneyLabel != nullptr)
- {
- // TRANSLATORS: sell dialog label
- mMoneyLabel->setCaption(strprintf(_("Price: %s / Total: %s"),
- UnitsDb::formatCurrency(income).c_str(),
- UnitsDb::formatCurrency(mPlayerMoney + income).c_str()));
- }
- if (item != nullptr)
- item->update();
-}
-
-void SellDialog::setVisible(Visible visible)
-{
- Window::setVisible(visible);
-
- if (visible == Visible_true)
- {
- if (mShopItemList != nullptr)
- mShopItemList->requestFocus();
- }
- else
- {
- scheduleDelete();
- }
-}
-
-void SellDialog::closeAll()
-{
- FOR_EACH (DialogList::const_iterator, it, instances)
- (*it)->close();
-}
diff --git a/src/gui/widgets/selldialog.h b/src/gui/widgets/selldialog.h
deleted file mode 100644
index e17d3116a..000000000
--- a/src/gui/widgets/selldialog.h
+++ /dev/null
@@ -1,156 +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_SELLDIALOG_H
-#define GUI_WIDGETS_SELLDIALOG_H
-
-#include "enums/resources/item/itemtype.h"
-
-#include "enums/simpletypes/advanced.h"
-#include "enums/simpletypes/issell.h"
-#include "enums/simpletypes/itemcolor.h"
-
-#include "gui/widgets/window.h"
-
-#include "listeners/actionlistener.h"
-#include "listeners/selectionlistener.h"
-
-class Button;
-class Item;
-class Label;
-class ScrollArea;
-class ShopItem;
-class ShopItems;
-class ShopListBox;
-class Slider;
-
-/**
- * The sell dialog.
- *
- * \ingroup Interface
- */
-class SellDialog notfinal : public Window,
- public ActionListener,
- private SelectionListener
-{
- public:
- /**
- * Constructor.
- */
- SellDialog(const IsSell isSell,
- const Advanced advanced);
-
- A_DELETE_COPY(SellDialog)
-
- /**
- * Destructor
- */
- ~SellDialog();
-
- /**
- * Resets the dialog, clearing inventory.
- */
- void reset();
-
- /**
- * Adds an item to the inventory.
- */
- void addItem(const Item *const item,
- const int price);
-
- /**
- * Called when receiving actions from the widgets.
- */
- void action(const ActionEvent &event) override final;
-
- /**
- * Updates labels according to selected item.
- *
- * @see SelectionListener::selectionChanged
- */
- void valueChanged(const SelectionEvent &event) override final;
-
- /**
- * Gives Player's Money amount
- */
- void setMoney(const int amount);
-
- /**
- * Sets the visibility of this window.
- */
- void setVisible(Visible visible) override final;
-
- ShopItem *addItem(const int id,
- const ItemTypeT type,
- const ItemColor color,
- const int amount,
- const int price);
-
- /**
- * Returns true if any instances exist.
- */
- static bool isActive() A_WARN_UNUSED
- { return !instances.empty(); }
-
- /**
- * Closes all instances.
- */
- static void closeAll();
-
- void postInit() override;
-
- protected:
- typedef std::list<SellDialog*> DialogList;
- static DialogList instances;
-
- /**
- * Updates the state of buttons and labels.
- */
- void updateButtonsAndLabels();
-
- virtual void sellAction(const ActionEvent &event) = 0;
-
- virtual void initButtons()
- { }
-
- Button *mSellButton A_NONNULLPOINTER;
- Button *mQuitButton A_NONNULLPOINTER;
- Button *mConfirmButton A_NONNULLPOINTER;
- Button *mAddMaxButton;
- Button *mIncreaseButton;
- Button *mDecreaseButton;
- ShopListBox *mShopItemList A_NONNULLPOINTER;
- ScrollArea *mScrollArea A_NONNULLPOINTER;
- Label *mMoneyLabel;
- Label *mQuantityLabel;
- Slider *mSlider;
- ShopItems *mShopItems A_NONNULLPOINTER;
-
- int mPlayerMoney;
- int mMaxItems;
- int mAmountItems;
-
- IsSell mIsSell;
- Advanced mAdvanced;
-};
-
-#endif // GUI_WIDGETS_SELLDIALOG_H
diff --git a/src/gui/widgets/serverslistbox.h b/src/gui/widgets/serverslistbox.h
deleted file mode 100644
index 20d019f8d..000000000
--- a/src/gui/widgets/serverslistbox.h
+++ /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/>.
- */
-
-#ifndef GUI_WIDGETS_SERVERSLISTBOX_H
-#define GUI_WIDGETS_SERVERSLISTBOX_H
-
-#include "gui/widgets/listbox.h"
-
-#include "gui/models/serverslistmodel.h"
-
-#include "localconsts.h"
-
-class ServersListBox final : public ListBox
-{
- public:
- ServersListBox(const Widget2 *const widget,
- ServersListModel *const model) :
- ListBox(widget, model, "serverslistbox.xml"),
- mNotSupportedColor(getThemeColor(
- ThemeColorId::SERVER_VERSION_NOT_SUPPORTED)),
- mNotSupportedColor2(getThemeColor(
- ThemeColorId::SERVER_VERSION_NOT_SUPPORTED_OUTLINE))
- {
- mHighlightColor = getThemeColor(ThemeColorId::HIGHLIGHT);
- }
-
- A_DELETE_COPY(ServersListBox)
-
- void draw(Graphics *const graphics) override final A_NONNULL(2)
- {
- if (mListModel == nullptr)
- return;
-
- ServersListModel *const model
- = static_cast<ServersListModel *>(mListModel);
-
- updateAlpha();
-
- mHighlightColor.a = CAST_S32(mAlpha * 255.0F);
- graphics->setColor(mHighlightColor);
-
- const int height = getRowHeight();
- mNotSupportedColor.a = CAST_S32(mAlpha * 255.0F);
-
- // Draw filled rectangle around the selected list element
- if (mSelected >= 0)
- {
- graphics->fillRectangle(Rect(mPadding,
- height * mSelected + mPadding,
- getWidth() - 2 * mPadding,
- height));
- }
-
- Font *const font1 = boldFont;
- Font *const font2 = getFont();
- const int fontHeight = font1->getHeight();
- const int pad1 = fontHeight + mPadding;
- const int pad2 = height / 4 + mPadding;
- const int width = getWidth();
- // Draw the list elements
- for (int i = 0, y = 0; i < model->getNumberOfElements();
- ++i, y += height)
- {
- const ServerInfo &info = model->getServer(i);
-
- const Color *color1;
- const Color *color2;
- if (mSelected == i)
- {
- color1 = &mForegroundSelectedColor;
- color2 = &mForegroundSelectedColor2;
- }
- else
- {
- color1 = &mForegroundColor;
- color2 = &mForegroundColor2;
- }
-
- int top;
- int x = mPadding;
-
- if (!info.name.empty())
- {
- x += font1->getWidth(info.name) + 15;
- font1->drawString(graphics,
- *color1,
- *color2,
- info.name,
- mPadding,
- y + mPadding);
- top = y + pad1;
- }
- else
- {
- top = y + pad2;
- }
-
- if (!info.description.empty())
- {
- font2->drawString(graphics,
- *color1,
- *color2,
- info.description,
- x,
- y + mPadding);
- }
- font2->drawString(graphics,
- *color1,
- *color2,
- model->getElementAt(i),
- mPadding,
- top);
-
- if (info.version.first > 0)
- {
- font2->drawString(graphics,
- mNotSupportedColor,
- mNotSupportedColor2,
- info.version.second,
- width - info.version.first - mPadding,
- top);
- }
- }
- }
-
- void safeDraw(Graphics *const graphics) override final A_NONNULL(2)
- {
- ServersListBox::draw(graphics);
- }
-
- unsigned int getRowHeight() const override final
- {
- return 2 * getFont()->getHeight() + 5;
- }
- private:
- Color mNotSupportedColor;
- Color mNotSupportedColor2;
-};
-
-#endif // GUI_WIDGETS_SERVERSLISTBOX_H
diff --git a/src/gui/widgets/setupbuttonitem.cpp b/src/gui/widgets/setupbuttonitem.cpp
deleted file mode 100644
index 07612f08c..000000000
--- a/src/gui/widgets/setupbuttonitem.cpp
+++ /dev/null
@@ -1,95 +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 "gui/widgets/setupbuttonitem.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/horizontcontainer.h"
-#include "gui/widgets/vertcontainer.h"
-
-#include "gui/widgets/tabs/setuptabscroll.h"
-
-#include "debug.h"
-
-SetupButtonItem::SetupButtonItem(const std::string &restrict text,
- const std::string &restrict description,
- const std::string &restrict actionEventId,
- SetupTabScroll *restrict const parent,
- const std::string &restrict eventName,
- ActionListener *const listener) :
- SetupItem(text, description, "", parent, eventName, MainConfig_false),
- mHorizont(nullptr),
- mButton(nullptr)
-{
- mValueType = VSTR;
- mWidget = new Button(this, text, actionEventId, listener);
- createControls();
-}
-
-SetupButtonItem::~SetupButtonItem()
-{
- mHorizont = nullptr;
- mWidget = nullptr;
- mButton = nullptr;
-}
-
-void SetupButtonItem::save()
-{
-}
-
-void SetupButtonItem::cancel(const std::string &eventName A_UNUSED)
-{
-}
-
-void SetupButtonItem::externalUpdated(const std::string &eventName A_UNUSED)
-{
-}
-
-void SetupButtonItem::rereadValue()
-{
-}
-
-void SetupButtonItem::createControls()
-{
- mHorizont = new HorizontContainer(this, 32, 2);
-
- // TRANSLATORS: setup item button
- mHorizont->add(mWidget);
-
- mParent->getContainer()->add2(mHorizont, true, 4);
- mParent->addControl(this);
-// mWidget->addActionListener(this);
-}
-
-void SetupButtonItem::fromWidget()
-{
-}
-
-void SetupButtonItem::toWidget()
-{
-}
-
-void SetupButtonItem::action(const ActionEvent &event A_UNUSED)
-{
-}
-
-void SetupButtonItem::apply(const std::string &eventName A_UNUSED)
-{
-}
diff --git a/src/gui/widgets/setupbuttonitem.h b/src/gui/widgets/setupbuttonitem.h
deleted file mode 100644
index b4f99328b..000000000
--- a/src/gui/widgets/setupbuttonitem.h
+++ /dev/null
@@ -1,69 +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 GUI_WIDGETS_SETUPBUTTONITEM_H
-#define GUI_WIDGETS_SETUPBUTTONITEM_H
-
-#include "gui/widgets/setupitem.h"
-
-class Button;
-class HorizontContainer;
-class SetupTabScroll;
-
-class SetupButtonItem final : public SetupItem
-{
- public:
- SetupButtonItem(const std::string &restrict text,
- const std::string &restrict description,
- const std::string &restrict actionEventId,
- SetupTabScroll *restrict const parent,
- const std::string &restrict eventName,
- ActionListener *const listener);
-
- A_DELETE_COPY(SetupButtonItem)
-
- ~SetupButtonItem();
-
- void createControls();
-
- void fromWidget() override final A_CONST;
-
- void toWidget() override final A_CONST;
-
- void action(const ActionEvent &event) override final A_CONST;
-
- void apply(const std::string &eventName) override final A_CONST;
-
- void cancel(const std::string &eventName A_UNUSED)
- override final A_CONST;
-
- void externalUpdated(const std::string &eventName A_UNUSED)
- override final A_CONST;
-
- void rereadValue() override final A_CONST;
-
- void save() override final A_CONST;
-
- protected:
- HorizontContainer *mHorizont;
- Button *mButton;
-};
-
-#endif // GUI_WIDGETS_SETUPBUTTONITEM_H
diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp
deleted file mode 100644
index cc6ded02e..000000000
--- a/src/gui/widgets/setupitem.cpp
+++ /dev/null
@@ -1,1338 +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 "gui/widgets/setupitem.h"
-
-#include "configuration.h"
-#include "soundmanager.h"
-
-#include "gui/gui.h"
-
-#include "gui/fonts/font.h"
-
-#include "gui/models/listmodel.h"
-
-#include "gui/windows/editdialog.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/checkbox.h"
-#include "gui/widgets/createwidget.h"
-#include "gui/widgets/dropdown.h"
-#include "gui/widgets/horizontcontainer.h"
-#include "gui/widgets/inttextfield.h"
-#include "gui/widgets/label.h"
-#include "gui/widgets/slider.h"
-#include "gui/widgets/sliderlist.h"
-#include "gui/widgets/vertcontainer.h"
-
-#include "gui/widgets/tabs/setuptabscroll.h"
-
-#include "utils/base64.h"
-#include "utils/gettext.h"
-#include "utils/stdmove.h"
-#include "utils/mathutils.h"
-
-#include "debug.h"
-
-SetupItem::SetupItem(const std::string &restrict text,
- const std::string &restrict description,
- const std::string &restrict keyName,
- SetupTabScroll *restrict const parent,
- const std::string &restrict eventName,
- const MainConfig mainConfig) :
- ActionListener(),
- Widget2(parent),
- mText(text),
- mDescription(description),
- mKeyName(keyName),
- mParent(parent),
- mEventName(eventName),
- mValue(),
- mDefault(),
- mWidget(nullptr),
- mTempWidgets(),
- mValueType(VBOOL),
- mMainConfig(mainConfig),
- mUseDefault(false)
-{
-}
-
-SetupItem::SetupItem(const std::string &restrict text,
- const std::string &restrict description,
- const std::string &restrict keyName,
- SetupTabScroll *restrict const parent,
- const std::string &restrict eventName,
- const std::string &restrict def,
- const MainConfig mainConfig) :
- ActionListener(),
- Widget2(parent),
- mText(text),
- mDescription(description),
- mKeyName(keyName),
- mParent(parent),
- mEventName(eventName),
- mValue(),
- mDefault(def),
- mWidget(nullptr),
- mTempWidgets(),
- mValueType(VBOOL),
- mMainConfig(mainConfig),
- mUseDefault(true)
-{
-}
-
-SetupItem::~SetupItem()
-{
-}
-
-Configuration *SetupItem::getConfig() const
-{
- if (mMainConfig == MainConfig_true)
- return &config;
- return &serverConfig;
-}
-
-void SetupItem::load()
-{
- if (mKeyName.empty())
- return;
-
- const Configuration *const cfg = getConfig();
- if (mUseDefault)
- {
- mValue = cfg->getValue(mKeyName, mDefault);
- }
- else
- {
- switch (mValueType)
- {
- case VBOOL:
- if (cfg->getBoolValue(mKeyName))
- mValue = "1";
- else
- mValue = "0";
- break;
- case VSTR:
- default:
- mValue = cfg->getStringValue(mKeyName);
- break;
- case VINT:
- mValue = toString(cfg->getIntValue(mKeyName));
- break;
- case VNONE:
- break;
- }
- }
-}
-
-void SetupItem::save()
-{
- if (mKeyName.empty())
- return;
-
- Configuration *const cfg = getConfig();
- cfg->setValue(mKeyName, mValue);
-}
-
-std::string SetupItem::getActionEventId() const
-{
- if (mWidget == nullptr)
- return std::string();
-
- return mWidget->getActionEventId();
-}
-
-void SetupItem::action(const ActionEvent &event)
-{
- if (mWidget == nullptr)
- return;
-
- if (event.getId() == mWidget->getActionEventId())
- doAction();
-}
-
-void SetupItem::doAction()
-{
- fromWidget();
-}
-
-void SetupItem::apply(const std::string &eventName A_UNUSED)
-{
- save();
-}
-
-void SetupItem::cancel(const std::string &eventName A_UNUSED)
-{
- load();
- toWidget();
-}
-
-void SetupItem::externalUpdated(const std::string &eventName A_UNUSED)
-{
- load();
- toWidget();
-}
-
-void SetupItem::externalUnloaded(const std::string &eventName A_UNUSED)
-{
-}
-
-void SetupItem::fixFirstItemSize(Widget *const widget)
-{
- if (widget == nullptr)
- return;
- const int maxSize = mParent->getPreferredFirstItemSize();
- if (widget->getWidth() < maxSize)
- widget->setWidth(maxSize);
-}
-
-void SetupItem::rereadValue()
-{
- load();
- toWidget();
-}
-
-SetupItemCheckBox::SetupItemCheckBox(const std::string &restrict text,
- const std::string &restrict description,
- const std::string &restrict keyName,
- SetupTabScroll *restrict const parent,
- const std::string &restrict eventName,
- const MainConfig mainConfig) :
- SetupItem(text, description, keyName, parent, eventName, mainConfig),
- mCheckBox(nullptr)
-{
- createControls();
-}
-
-SetupItemCheckBox::SetupItemCheckBox(const std::string &restrict text,
- const std::string &restrict description,
- const std::string &restrict keyName,
- SetupTabScroll *restrict const parent,
- const std::string &restrict eventName,
- const std::string &restrict def,
- const MainConfig mainConfig) :
- SetupItem(text, description, keyName, parent, eventName, def, mainConfig),
- mCheckBox(nullptr)
-{
- createControls();
-}
-
-SetupItemCheckBox::~SetupItemCheckBox()
-{
- mWidget = nullptr;
-}
-
-void SetupItemCheckBox::createControls()
-{
- load();
- mCheckBox = new CheckBox(this, mText, mValue != "0", mParent, mEventName);
- mCheckBox->setToolTip(mDescription);
- mWidget = mCheckBox;
- mParent->getContainer()->add1(mWidget);
- mParent->addControl(this);
- mParent->addActionListener(this);
- mWidget->addActionListener(this);
-}
-
-void SetupItemCheckBox::fromWidget()
-{
- if (mCheckBox == nullptr)
- return;
-
- if (mCheckBox->isSelected())
- mValue = "1";
- else
- mValue = "0";
-}
-
-void SetupItemCheckBox::toWidget()
-{
- if (mCheckBox == nullptr)
- return;
-
- mCheckBox->setSelected(mValue != "0");
-}
-
-
-SetupItemTextField::SetupItemTextField(const std::string &restrict text,
- const std::string &restrict description,
- const std::string &restrict keyName,
- SetupTabScroll *restrict const parent,
- const std::string &restrict eventName,
- const MainConfig mainConfig,
- const UseBase64 useBase64) :
- SetupItem(text, description, keyName, parent, eventName, mainConfig),
- mHorizont(nullptr),
- mLabel(nullptr),
- mTextField(nullptr),
- mButton(nullptr),
- mEditDialog(nullptr),
- mUseBase64(useBase64)
-{
- mValueType = VSTR;
- createControls();
-}
-
-SetupItemTextField::SetupItemTextField(const std::string &restrict text,
- const std::string &restrict description,
- const std::string &restrict keyName,
- SetupTabScroll *restrict const parent,
- const std::string &restrict eventName,
- const std::string &restrict def,
- const MainConfig mainConfig,
- const UseBase64 useBase64) :
- SetupItem(text, description, keyName, parent, eventName, def, mainConfig),
- mHorizont(nullptr),
- mLabel(nullptr),
- mTextField(nullptr),
- mButton(nullptr),
- mEditDialog(nullptr),
- mUseBase64(useBase64)
-{
- mValueType = VSTR;
- createControls();
-}
-
-SetupItemTextField::~SetupItemTextField()
-{
- mHorizont = nullptr;
- mWidget = nullptr;
- mTextField = nullptr;
- mLabel = nullptr;
- mButton = nullptr;
-}
-
-void SetupItemTextField::save()
-{
- if (mUseBase64 == UseBase64_true)
- {
- std::string normalValue = mValue;
- mValue = encodeBase64String(mValue);
- SetupItem::save();
- mValue = STD_MOVE(normalValue);
- }
- else
- {
- SetupItem::save();
- }
-}
-
-void SetupItemTextField::cancel(const std::string &eventName A_UNUSED)
-{
- load();
- if (mUseBase64 == UseBase64_true)
- mValue = decodeBase64String(mValue);
- toWidget();
-}
-
-void SetupItemTextField::externalUpdated(const std::string &eventName A_UNUSED)
-{
- load();
- if (mUseBase64 == UseBase64_true)
- mValue = decodeBase64String(mValue);
- toWidget();
-}
-
-void SetupItemTextField::rereadValue()
-{
- load();
- if (mUseBase64 == UseBase64_true)
- mValue = decodeBase64String(mValue);
- toWidget();
-}
-
-void SetupItemTextField::createControls()
-{
- load();
- if (mUseBase64 == UseBase64_true)
- mValue = decodeBase64String(mValue);
- mHorizont = new HorizontContainer(this, 32, 2);
-
- mLabel = new Label(this, mText);
- mLabel->setToolTip(mDescription);
- mTextField = new TextField(this,
- mValue,
- LoseFocusOnTab_true,
- mParent,
- mEventName);
- // TRANSLATORS: setup item button
- mButton = new Button(this, _("Edit"), mEventName + "_EDIT", mParent);
- mWidget = mTextField;
- mTextField->setWidth(200);
- fixFirstItemSize(mLabel);
- mHorizont->add(mLabel);
- mHorizont->add(mTextField);
- mHorizont->add(mButton);
-
- mParent->getContainer()->add2(mHorizont, true, 4);
- mParent->addControl(this);
- mParent->addControl(this, mEventName + "_EDIT");
- mParent->addControl(this, mEventName + "_EDIT_OK");
- mParent->addActionListener(this);
- mWidget->addActionListener(this);
- mButton->addActionListener(this);
-}
-
-void SetupItemTextField::fromWidget()
-{
- if (mTextField == nullptr)
- return;
-
- mValue = mTextField->getText();
-}
-
-void SetupItemTextField::toWidget()
-{
- if (mTextField == nullptr)
- return;
-
- mTextField->setText(mValue);
-}
-
-void SetupItemTextField::action(const ActionEvent &event)
-{
- if (mTextField == nullptr)
- return;
-
- const std::string &eventId = event.getId();
- if ((mWidget != nullptr) && eventId == mWidget->getActionEventId())
- {
- fromWidget();
- }
- else if (eventId == mEventName + "_EDIT")
- {
- mEditDialog = CREATEWIDGETR(EditDialog,
- mText,
- mTextField->getText(),
- mEventName + "_EDIT_OK");
- mEditDialog->addActionListener(this);
- }
- else if (eventId == mEventName + "_EDIT_OK")
- {
- mTextField->setText(mEditDialog->getMsg());
- mEditDialog = nullptr;
- }
-}
-
-void SetupItemTextField::apply(const std::string &eventName)
-{
- if (eventName != mEventName)
- return;
-
- fromWidget();
- save();
-}
-
-SetupItemIntTextField::SetupItemIntTextField(const std::string &restrict text,
- const std::string &restrict
- description,
- const std::string &restrict
- keyName,
- SetupTabScroll *restrict
- const parent,
- const std::string &restrict
- eventName,
- const int min, const int max,
- const MainConfig mainConfig) :
- SetupItem(text, description, keyName, parent, eventName, mainConfig),
- mHorizont(nullptr),
- mLabel(nullptr),
- mTextField(nullptr),
- mButton(nullptr),
- mEditDialog(nullptr),
- mMin(min),
- mMax(max)
-{
- mValueType = VSTR;
- createControls();
-}
-
-SetupItemIntTextField::SetupItemIntTextField(const std::string &restrict text,
- const std::string &restrict
- description,
- const std::string &restrict
- keyName,
- SetupTabScroll *restrict
- const parent,
- const std::string &restrict
- eventName,
- const int min, const int max,
- const std::string &restrict def,
- const MainConfig mainConfig) :
- SetupItem(text, description, keyName, parent, eventName, def, mainConfig),
- mHorizont(nullptr),
- mLabel(nullptr),
- mTextField(nullptr),
- mButton(nullptr),
- mEditDialog(nullptr),
- mMin(min),
- mMax(max)
-{
- mValueType = VSTR;
- createControls();
-}
-
-SetupItemIntTextField::~SetupItemIntTextField()
-{
- mHorizont = nullptr;
- mWidget = nullptr;
- mTextField = nullptr;
- mLabel = nullptr;
- mButton = nullptr;
-}
-
-void SetupItemIntTextField::createControls()
-{
- load();
- mHorizont = new HorizontContainer(this, 32, 2);
-
- mLabel = new Label(this, mText);
- mLabel->setToolTip(mDescription);
- mTextField = new IntTextField(this, atoi(mValue.c_str()),
- mMin, mMax, Enable_true, 30);
- mTextField->setActionEventId(mEventName);
- mTextField->addActionListener(mParent);
-
- // TRANSLATORS: setup item button
- mButton = new Button(this, _("Edit"), mEventName + "_EDIT", mParent);
- mWidget = mTextField;
- mTextField->setWidth(50);
- fixFirstItemSize(mLabel);
- mHorizont->add(mLabel);
- mHorizont->add(mTextField);
- mHorizont->add(mButton);
-
- mParent->getContainer()->add2(mHorizont, true, 4);
- mParent->addControl(this);
- mParent->addControl(this, mEventName + "_EDIT");
- mParent->addControl(this, mEventName + "_EDIT_OK");
- mParent->addActionListener(this);
- mWidget->addActionListener(this);
- mButton->addActionListener(this);
-}
-
-void SetupItemIntTextField::fromWidget()
-{
- if (mTextField == nullptr)
- return;
-
- mValue = mTextField->getText();
-}
-
-void SetupItemIntTextField::toWidget()
-{
- if (mTextField == nullptr)
- return;
-
- mTextField->setText(mValue);
-}
-
-void SetupItemIntTextField::action(const ActionEvent &event)
-{
- if (mTextField == nullptr)
- return;
-
- const std::string &eventId = event.getId();
- if ((mWidget != nullptr) && eventId == mWidget->getActionEventId())
- {
- fromWidget();
- }
- else if (eventId == mEventName + "_EDIT")
- {
- mEditDialog = CREATEWIDGETR(EditDialog,
- mText,
- mTextField->getText(),
- mEventName + "_EDIT_OK");
- mEditDialog->addActionListener(this);
- }
- else if (eventId == mEventName + "_EDIT_OK")
- {
- mTextField->setValue(atoi(mEditDialog->getMsg().c_str()));
- mEditDialog = nullptr;
- }
-}
-
-void SetupItemIntTextField::apply(const std::string &eventName)
-{
- if (eventName != mEventName)
- return;
-
- fromWidget();
- save();
-}
-
-
-SetupItemLabel::SetupItemLabel(const std::string &restrict text,
- const std::string &restrict description,
- SetupTabScroll *restrict const parent,
- const Separator separator) :
- SetupItem(text, description, "", parent, "", "", MainConfig_true),
- mLabel(nullptr),
- mIsSeparator(separator)
-{
- mValueType = VNONE;
- createControls();
-}
-
-SetupItemLabel::~SetupItemLabel()
-{
- mWidget = nullptr;
- mLabel = nullptr;
-}
-
-void SetupItemLabel::createControls()
-{
- if (mIsSeparator == Separator_true)
- {
- const std::string str(" \342\200\225\342\200\225\342\200\225"
- "\342\200\225\342\200\225 ");
- mLabel = new Label(this, std::string(str).append(mText).append(str));
- }
- else
- {
- mLabel = new Label(this, mText);
- }
- mLabel->setToolTip(mDescription);
-
- mWidget = mLabel;
- mParent->getContainer()->add1(mWidget);
- mParent->addControl(this);
- mParent->addActionListener(this);
- mWidget->addActionListener(this);
-}
-
-void SetupItemLabel::fromWidget()
-{
-}
-
-void SetupItemLabel::toWidget()
-{
-}
-
-void SetupItemLabel::action(const ActionEvent &event A_UNUSED)
-{
-}
-
-void SetupItemLabel::apply(const std::string &eventName A_UNUSED)
-{
-}
-
-
-SetupItemDropDown::SetupItemDropDown(const std::string &restrict text,
- const std::string &restrict description,
- const std::string &restrict keyName,
- SetupTabScroll *restrict const parent,
- const std::string &restrict eventName,
- ListModel *restrict const model,
- const int width,
- const MainConfig mainConfig) :
- SetupItem(text, description, keyName, parent, eventName, mainConfig),
- mHorizont(nullptr),
- mLabel(nullptr),
- mModel(model),
- mDropDown(nullptr),
- mWidth(width)
-{
- mValueType = VSTR;
- createControls();
-}
-
-SetupItemDropDown::SetupItemDropDown(const std::string &restrict text,
- const std::string &restrict description,
- const std::string &restrict keyName,
- SetupTabScroll *restrict const parent,
- const std::string &restrict eventName,
- ListModel *restrict const model,
- const int width,
- const std::string &restrict def,
- const MainConfig mainConfig) :
- SetupItem(text, description, keyName, parent, eventName, def, mainConfig),
- mHorizont(nullptr),
- mLabel(nullptr),
- mModel(model),
- mDropDown(nullptr),
- mWidth(width)
-{
- mValueType = VSTR;
- createControls();
-}
-
-SetupItemDropDown::~SetupItemDropDown()
-{
- mHorizont = nullptr;
- mWidget = nullptr;
- mModel = nullptr;
- mDropDown = nullptr;
- mLabel = nullptr;
-}
-
-void SetupItemDropDown::createControls()
-{
- load();
- mHorizont = new HorizontContainer(this, 32, 2);
-
- mLabel = new Label(this, mText);
- mLabel->setToolTip(mDescription);
- mDropDown = new DropDown(this, mModel);
- mDropDown->setActionEventId(mEventName);
- mDropDown->addActionListener(mParent);
- mDropDown->setWidth(mWidth);
- mDropDown->setSelected(selectionByValue());
-
- mWidget = mDropDown;
- if (!mText.empty())
- fixFirstItemSize(mLabel);
- mHorizont->add(mLabel);
- mHorizont->add(mDropDown);
-
- mParent->getContainer()->add2(mHorizont, true, 4);
- mParent->addControl(this);
- mParent->addActionListener(this);
- mWidget->addActionListener(this);
-}
-
-int SetupItemDropDown::selectionByValue()
-{
- return atoi(mValue.c_str());
-}
-
-void SetupItemDropDown::fromWidget()
-{
- if (mDropDown == nullptr)
- return;
-
- mValue = toString(mDropDown->getSelected());
-}
-
-void SetupItemDropDown::toWidget()
-{
- if (mDropDown == nullptr)
- return;
-
- mDropDown->setSelected(selectionByValue());
-}
-
-
-SetupItemDropDownStr::SetupItemDropDownStr(const std::string &restrict text,
- const std::string &restrict
- description,
- const std::string &restrict keyName,
- SetupTabScroll *restrict const
- parent,
- const std::string &restrict
- eventName,
- ListModel *restrict const model,
- const int width,
- const MainConfig mainConfig) :
- SetupItem(text, description, keyName, parent, eventName, mainConfig),
- mHorizont(nullptr),
- mLabel(nullptr),
- mModel(model),
- mDropDown(nullptr),
- mWidth(width)
-{
- mValueType = VSTR;
- createControls();
-}
-
-SetupItemDropDownStr::SetupItemDropDownStr(const std::string &restrict text,
- const std::string &restrict
- description,
- const std::string &restrict keyName,
- SetupTabScroll *restrict const
- parent,
- const std::string &restrict
- eventName,
- ListModel *restrict const model,
- const int width,
- const std::string &restrict def,
- const MainConfig mainConfig) :
- SetupItem(text, description, keyName, parent, eventName, def, mainConfig),
- mHorizont(nullptr),
- mLabel(nullptr),
- mModel(model),
- mDropDown(nullptr),
- mWidth(width)
-{
- mValueType = VSTR;
- createControls();
-}
-
-SetupItemDropDownStr::~SetupItemDropDownStr()
-{
- mHorizont = nullptr;
- mWidget = nullptr;
- mModel = nullptr;
- mDropDown = nullptr;
- mLabel = nullptr;
-}
-
-void SetupItemDropDownStr::createControls()
-{
- load();
- mHorizont = new HorizontContainer(this, 32, 2);
-
- mLabel = new Label(this, mText);
- mLabel->setToolTip(mDescription);
- mDropDown = new DropDown(this, mModel);
- mDropDown->setActionEventId(mEventName);
- mDropDown->addActionListener(mParent);
- mDropDown->setWidth(mWidth);
- mDropDown->setSelected(selectionByValue());
-
- mWidget = mDropDown;
- if (!mText.empty())
- fixFirstItemSize(mLabel);
- mHorizont->add(mLabel);
- mHorizont->add(mDropDown);
-
- mParent->getContainer()->add2(mHorizont, true, 4);
- mParent->addControl(this);
- mParent->addActionListener(this);
- mWidget->addActionListener(this);
-}
-
-int SetupItemDropDownStr::selectionByValue()
-{
- const int sz = mModel->getNumberOfElements();
- for (int f = 0; f < sz; f ++)
- {
- if (mModel->getElementAt(f) == mValue)
- {
- return f;
- }
- }
- return 0;
-}
-
-void SetupItemDropDownStr::fromWidget()
-{
- if (mDropDown == nullptr)
- return;
-
- const int sel = mDropDown->getSelected();
- // use first element in model as empty string
- if (sel == 0 || sel >= mModel->getNumberOfElements())
- mValue.clear();
- else
- mValue = mModel->getElementAt(sel);
-}
-
-void SetupItemDropDownStr::toWidget()
-{
- if (mDropDown == nullptr)
- return;
-
- mDropDown->setSelected(selectionByValue());
-}
-
-
-SetupItemSlider::SetupItemSlider(const std::string &restrict text,
- const std::string &restrict description,
- const std::string &restrict keyName,
- SetupTabScroll *restrict const parent,
- const std::string &restrict eventName,
- const double min,
- const double max,
- const double step,
- const int width,
- const OnTheFly onTheFly,
- const MainConfig mainConfig) :
- SetupItem(text, description, keyName, parent, eventName, mainConfig),
- mHorizont(nullptr),
- mLabel(nullptr),
- mSlider(nullptr),
- mMin(min),
- mMax(max),
- mStep(step),
- mWidth(width),
- mOnTheFly(onTheFly)
-{
- mValueType = VSTR;
- createControls();
-}
-
-SetupItemSlider::SetupItemSlider(const std::string &restrict text,
- const std::string &restrict description,
- const std::string &restrict keyName,
- SetupTabScroll *restrict const parent,
- const std::string &restrict eventName,
- const double min,
- const double max,
- const double step,
- const std::string &restrict def,
- const int width,
- const OnTheFly onTheFly,
- const MainConfig mainConfig) :
- SetupItem(text, description, keyName, parent, eventName, def, mainConfig),
- mHorizont(nullptr),
- mLabel(nullptr),
- mSlider(nullptr),
- mMin(min),
- mMax(max),
- mStep(step),
- mWidth(width),
- mOnTheFly(onTheFly)
-{
- mValueType = VSTR;
- createControls();
-}
-
-SetupItemSlider::~SetupItemSlider()
-{
- mHorizont = nullptr;
- mWidget = nullptr;
- mSlider = nullptr;
- mLabel = nullptr;
-}
-
-void SetupItemSlider::createControls()
-{
- load();
- mHorizont = new HorizontContainer(this, 32, 2);
-
- mLabel = new Label(this, mText);
- mLabel->setToolTip(mDescription);
- mSlider = new Slider(this, mMin, mMax, mStep);
- mSlider->setActionEventId(mEventName);
- mSlider->addActionListener(mParent);
- mSlider->setValue(atof(mValue.c_str()));
- mSlider->setHeight(30);
-
- mWidget = mSlider;
- mSlider->setWidth(mWidth);
- mSlider->setHeight(40);
- fixFirstItemSize(mLabel);
- mHorizont->add(mLabel);
- mHorizont->add(mSlider, -10);
-
- mParent->getContainer()->add2(mHorizont, true, 4);
- mParent->addControl(this);
- mParent->addActionListener(this);
- mWidget->addActionListener(this);
-}
-
-void SetupItemSlider::fromWidget()
-{
- if (mSlider == nullptr)
- return;
-
- mValue = toString(mSlider->getValue());
-}
-
-void SetupItemSlider::toWidget()
-{
- if (mSlider == nullptr)
- return;
-
- mSlider->setValue(atof(mValue.c_str()));
-}
-
-void SetupItemSlider::action(const ActionEvent &event A_UNUSED)
-{
- fromWidget();
- if (mOnTheFly == OnTheFly_true)
- save();
-}
-
-void SetupItemSlider::apply(const std::string &eventName)
-{
- if (eventName != mEventName)
- return;
-
- fromWidget();
- save();
-}
-
-
-SetupItemSlider2::SetupItemSlider2(const std::string &restrict text,
- const std::string &restrict description,
- const std::string &restrict keyName,
- SetupTabScroll *restrict const parent,
- const std::string &restrict eventName,
- const int min,
- const int max,
- const int step,
- SetupItemNames *restrict const values,
- const OnTheFly onTheFly,
- const MainConfig mainConfig,
- const DoNotAlign doNotAlign) :
- SetupItem(text, description, keyName, parent, eventName, mainConfig),
- mHorizont(nullptr),
- mLabel(nullptr),
- mLabel2(nullptr),
- mSlider(nullptr),
- mValues(values),
- mMin(min),
- mMax(max),
- mStep(step),
- mInvertValue(0),
- mInvert(false),
- mOnTheFly(onTheFly),
- mDoNotAlign(doNotAlign)
-{
- mValueType = VSTR;
- createControls();
-}
-
-SetupItemSlider2::SetupItemSlider2(const std::string &restrict text,
- const std::string &restrict description,
- const std::string &restrict keyName,
- SetupTabScroll *restrict const parent,
- const std::string &restrict eventName,
- const int min,
- const int max,
- const int step,
- SetupItemNames *restrict const values,
- const std::string &restrict def,
- const OnTheFly onTheFly,
- const MainConfig mainConfig,
- const DoNotAlign doNotAlign) :
- SetupItem(text, description, keyName, parent, eventName, def, mainConfig),
- mHorizont(nullptr),
- mLabel(nullptr),
- mLabel2(nullptr),
- mSlider(nullptr),
- mValues(values),
- mMin(min),
- mMax(max),
- mStep(step),
- mInvertValue(0),
- mInvert(false),
- mOnTheFly(onTheFly),
- mDoNotAlign(doNotAlign)
-{
- mValueType = VSTR;
- createControls();
-}
-
-SetupItemSlider2::~SetupItemSlider2()
-{
- mHorizont = nullptr;
- mWidget = nullptr;
- mSlider = nullptr;
- mLabel = nullptr;
-}
-
-void SetupItemSlider2::createControls()
-{
- load();
- mHorizont = new HorizontContainer(this, 32, 2);
-
- const int width = getMaxWidth();
-
- mLabel = new Label(this, mText);
- mLabel->setToolTip(mDescription);
- mLabel2 = new Label(this, "");
- mLabel2->setWidth(width);
- mSlider = new Slider(this, mMin, mMax, mStep);
- mSlider->setActionEventId(mEventName);
- mSlider->addActionListener(mParent);
- mSlider->setValue(atof(mValue.c_str()));
- mSlider->setHeight(30);
-
- mWidget = mSlider;
- mSlider->setWidth(150);
- mSlider->setHeight(40);
- if (mDoNotAlign == DoNotAlign_false)
- fixFirstItemSize(mLabel);
- mHorizont->add(mLabel);
- mHorizont->add(mSlider, -10);
- mHorizont->add(mLabel2);
-
- mParent->getContainer()->add2(mHorizont, true, 4);
- mParent->addControl(this);
- mParent->addActionListener(this);
- mWidget->addActionListener(this);
- updateLabel();
-}
-
-int SetupItemSlider2::getMaxWidth()
-{
- if ((mValues == nullptr) || (gui == nullptr))
- return 1;
-
- int maxWidth = 0;
- SetupItemNamesConstIter it = mValues->begin();
- const SetupItemNamesConstIter it_end = mValues->end();
- const Font *const font = gui->getFont();
-
- while (it != it_end)
- {
- const int w = font->getWidth(*it);
- if (w > maxWidth)
- maxWidth = w;
-
- ++ it;
- }
- return maxWidth;
-}
-
-void SetupItemSlider2::fromWidget()
-{
- if (mSlider == nullptr)
- return;
-
- int val = roundDouble(mSlider->getValue());
- if (mInvert)
- val = mInvertValue - val;
- mValue = toString(val);
-}
-
-void SetupItemSlider2::toWidget()
-{
- if (mSlider == nullptr)
- return;
-
- int val = roundDouble(atof(mValue.c_str()));
- if (mInvert)
- val = mInvertValue - val;
- mSlider->setValue(val);
- updateLabel();
-}
-
-void SetupItemSlider2::action(const ActionEvent &event A_UNUSED)
-{
- fromWidget();
- updateLabel();
- if (mOnTheFly == OnTheFly_true)
- save();
-}
-
-void SetupItemSlider2::updateLabel()
-{
- int val = CAST_S32(mSlider->getValue()) - mMin;
- if (val < 0)
- {
- val = 0;
- }
- else
- {
- const int sz = CAST_S32(mValues->size());
- if (val >= sz)
- val = sz - 1;
- }
- std::string str = mValues->at(val);
- mLabel2->setCaption(str);
-}
-
-void SetupItemSlider2::apply(const std::string &eventName)
-{
- if (eventName != mEventName)
- return;
-
- fromWidget();
- save();
-}
-
-void SetupItemSlider2::setInvertValue(const int v)
-{
- mInvert = true;
- mInvertValue = v;
- toWidget();
-}
-
-
-SetupItemSliderList::SetupItemSliderList(const std::string &restrict text,
- const std::string &restrict
- description,
- const std::string &restrict keyName,
- SetupTabScroll *restrict const parent,
- const std::string &restrict eventName,
- ListModel *restrict const model,
- const int width,
- const OnTheFly onTheFly,
- const MainConfig mainConfig) :
- SetupItem(text, description, keyName, parent, eventName, mainConfig),
- mHorizont(nullptr),
- mLabel(nullptr),
- mSlider(nullptr),
- mModel(model),
- mWidth(width),
- mOnTheFly(onTheFly)
-{
- mValueType = VSTR;
-}
-
-SetupItemSliderList::SetupItemSliderList(const std::string &restrict text,
- const std::string &restrict
- description,
- const std::string &restrict keyName,
- SetupTabScroll *restrict const parent,
- const std::string &restrict eventName,
- ListModel *restrict const model,
- const std::string &restrict def,
- const int width,
- const OnTheFly onTheFly,
- const MainConfig mainConfig) :
- SetupItem(text, description, keyName, parent, eventName, def, mainConfig),
- mHorizont(nullptr),
- mLabel(nullptr),
- mSlider(nullptr),
- mModel(model),
- mWidth(width),
- mOnTheFly(onTheFly)
-{
- mValueType = VSTR;
-}
-
-SetupItemSliderList::~SetupItemSliderList()
-{
- mHorizont = nullptr;
- mWidget = nullptr;
- mSlider = nullptr;
- mLabel = nullptr;
-}
-
-void SetupItemSliderList::createControls()
-{
- load();
- mHorizont = new HorizontContainer(this, 32, 2);
-
- mLabel = new Label(this, mText);
- mLabel->setToolTip(mDescription);
- mSlider = new SliderList(this, mModel);
- mSlider->postInit2(mParent, mEventName);
- mSlider->setSelectedString(mValue);
- mSlider->adjustSize();
-
- mWidget = mSlider;
- fixFirstItemSize(mLabel);
- mHorizont->add(mLabel, 5);
- mHorizont->add(mSlider);
-
- addMoreControls();
-
- mParent->getContainer()->add2(mHorizont, true, 4);
- mParent->addControl(this);
- mParent->addActionListener(this);
- mWidget->addActionListener(this);
-}
-
-void SetupItemSliderList::fromWidget()
-{
- if (mSlider == nullptr)
- return;
-
- mValue = mSlider->getSelectedString();
-}
-
-void SetupItemSliderList::toWidget()
-{
- if (mSlider == nullptr)
- return;
-
- mSlider->setSelectedString(mValue);
-}
-
-void SetupItemSliderList::action(const ActionEvent &event A_UNUSED)
-{
- fromWidget();
- if (mOnTheFly == OnTheFly_true)
- save();
-}
-
-void SetupItemSliderList::apply(const std::string &eventName)
-{
- if (eventName != mEventName)
- return;
-
- fromWidget();
- save();
-}
-
-SetupItemSound::SetupItemSound(const std::string &restrict text,
- const std::string &restrict description,
- const std::string &restrict keyName,
- SetupTabScroll *restrict const parent,
- const std::string &restrict eventName,
- ListModel *restrict const model,
- const int width,
- const OnTheFly onTheFly,
- const MainConfig mainConfig) :
- SetupItemSliderList(text, description, keyName, parent, eventName,
- model, width, onTheFly, mainConfig),
- mButton(nullptr)
-{
- createControls();
-}
-
-void SetupItemSound::addMoreControls()
-{
- mButton = new Button(this, BUTTON_PLAY, 16, 16,
- mEventName + "_PLAY", this);
- if (mHorizont != nullptr)
- mHorizont->add(mButton);
-}
-
-void SetupItemSound::action(const ActionEvent &event)
-{
- if (event.getId() == mEventName + "_PLAY")
- {
- if ((mSlider != nullptr) && (mSlider->getSelected() != 0))
- {
- soundManager.playGuiSfx(pathJoin(branding.getStringValue(
- "systemsounds"),
- mSlider->getSelectedString()).append(".ogg"));
- }
- }
- else
- {
- SetupItemSliderList::action(event);
- }
-}
-
-SetupItemSliderInt::SetupItemSliderInt(const std::string &restrict text,
- const std::string &restrict description,
- const std::string &restrict keyName,
- SetupTabScroll *restrict const parent,
- const std::string &restrict eventName,
- ListModel *restrict const model,
- const int min,
- const int width,
- const OnTheFly onTheFly,
- const MainConfig mainConfig) :
- SetupItemSliderList(text, description, keyName, parent, eventName,
- model, width, onTheFly, mainConfig),
- mMin(min)
-{
- createControls();
-}
-
-void SetupItemSliderInt::addMoreControls()
-{
- toWidget();
-}
-
-void SetupItemSliderInt::fromWidget()
-{
- if (mSlider == nullptr)
- return;
-
- mValue = toString(mSlider->getSelected() + mMin);
-}
-
-void SetupItemSliderInt::toWidget()
-{
- if (mSlider == nullptr)
- return;
-
- mSlider->setSelected(atoi(mValue.c_str()) - mMin);
-}
diff --git a/src/gui/widgets/setupitem.h b/src/gui/widgets/setupitem.h
deleted file mode 100644
index eec63a4bc..000000000
--- a/src/gui/widgets/setupitem.h
+++ /dev/null
@@ -1,613 +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 GUI_WIDGETS_SETUPITEM_H
-#define GUI_WIDGETS_SETUPITEM_H
-
-#include "enums/simpletypes/donotalign.h"
-#include "enums/simpletypes/mainconfig.h"
-#include "enums/simpletypes/onthefly.h"
-#include "enums/simpletypes/usebase64.h"
-#include "enums/simpletypes/separator.h"
-
-#include "gui/widgets/widget2.h"
-
-#include "listeners/actionlistener.h"
-
-#include <list>
-
-class Button;
-class CheckBox;
-class Configuration;
-class DropDown;
-class EditDialog;
-class HorizontContainer;
-class IntTextField;
-class Label;
-class ListModel;
-class SetupTabScroll;
-class Slider;
-class SliderList;
-class TextField;
-
-class SetupItem notfinal : public ActionListener,
- public Widget2
-{
- public:
- enum
- {
- VBOOL = 0,
- VSTR,
- VINT,
- VNONE
- };
-
- A_DELETE_COPY(SetupItem)
-
- virtual ~SetupItem();
-
- void load();
-
- virtual void save();
-
- virtual void fromWidget() = 0;
-
- virtual void toWidget() = 0;
-
- void setWidget(Widget *widget)
- { mWidget = widget; }
-
- Widget *getWidget() const noexcept2 A_WARN_UNUSED
- { return mWidget; }
-
- Configuration *getConfig() const RETURNS_NONNULL A_WARN_UNUSED;
-
- virtual std::string getActionEventId() const A_WARN_UNUSED;
-
- void action(const ActionEvent &event) override;
-
- virtual void doAction();
-
- virtual void apply(const std::string &eventName);
-
- virtual void cancel(const std::string &eventName);
-
- virtual void externalUpdated(const std::string &eventName);
-
- virtual void externalUnloaded(const std::string &eventName) A_CONST;
-
- MainConfig isMainConfig() const noexcept2 A_WARN_UNUSED
- { return mMainConfig; }
-
- void fixFirstItemSize(Widget *const widget);
-
- virtual void rereadValue();
-
- void setValue(const std::string &str) noexcept2
- { mValue = str; }
-
- std::string getValue() const noexcept2
- { return mValue; }
-
- std::string getEventName() const noexcept2
- { return mEventName; }
-
- protected:
- SetupItem(const std::string &restrict text,
- const std::string &restrict description,
- const std::string &restrict keyName,
- SetupTabScroll *restrict const parent,
- const std::string &restrict eventName,
- const MainConfig mainConfig);
-
- SetupItem(const std::string &restrict text,
- const std::string &restrict description,
- const std::string &restrict keyName,
- SetupTabScroll *restrict const parent,
- const std::string &restrict eventName,
- const std::string &def,
- const MainConfig mainConfig);
-
- std::string mText;
-
- std::string mDescription;
-
- std::string mKeyName;
-
- SetupTabScroll *mParent;
-
- std::string mEventName;
-
- std::string mValue;
-
- std::string mDefault;
-
- Widget *mWidget;
-
- std::list<Widget*> mTempWidgets;
-
- int mValueType;
-
- MainConfig mMainConfig;
-
- bool mUseDefault;
-};
-
-class SetupItemCheckBox final : public SetupItem
-{
- public:
- SetupItemCheckBox(const std::string &restrict text,
- const std::string &restrict description,
- const std::string &restrict keyName,
- SetupTabScroll *restrict const parent,
- const std::string &restrict eventName,
- const MainConfig mainConfig = MainConfig_true);
-
- SetupItemCheckBox(const std::string &restrict text,
- const std::string &restrict description,
- const std::string &restrict keyName,
- SetupTabScroll *restrict const parent,
- const std::string &restrict eventName,
- const std::string &restrict def,
- const MainConfig mainConfig = MainConfig_true);
-
- A_DELETE_COPY(SetupItemCheckBox)
-
- ~SetupItemCheckBox();
-
- void createControls();
-
- void fromWidget() override final;
-
- void toWidget() override final;
-
- protected:
- CheckBox *mCheckBox;
-};
-
-class SetupItemTextField final : public SetupItem
-{
- public:
- SetupItemTextField(const std::string &restrict text,
- const std::string &restrict description,
- const std::string &restrict keyName,
- SetupTabScroll *restrict const parent,
- const std::string &restrict eventName,
- const MainConfig mainConfig = MainConfig_true,
- const UseBase64 useBase64 = UseBase64_false);
-
- SetupItemTextField(const std::string &restrict text,
- const std::string &restrict description,
- const std::string &restrict keyName,
- SetupTabScroll *restrict const parent,
- const std::string &restrict eventName,
- const std::string &restrict def,
- const MainConfig mainConfig = MainConfig_true,
- const UseBase64 useBase64 = UseBase64_false);
-
- A_DELETE_COPY(SetupItemTextField)
-
- ~SetupItemTextField();
-
- void createControls();
-
- void fromWidget() override final;
-
- void toWidget() override final;
-
- void action(const ActionEvent &event) override final;
-
- void apply(const std::string &eventName) override final;
-
- void cancel(const std::string &eventName A_UNUSED) override final;
-
- void externalUpdated(const std::string &eventName A_UNUSED)
- override final;
-
- void rereadValue() override final;
-
- void save() override final;
-
- void setUseBase64(const UseBase64 b)
- { mUseBase64 = b; }
-
- protected:
- HorizontContainer *mHorizont;
- Label *mLabel;
- TextField *mTextField;
- Button *mButton;
- EditDialog *mEditDialog;
- UseBase64 mUseBase64;
-};
-
-class SetupItemIntTextField final : public SetupItem
-{
- public:
- SetupItemIntTextField(const std::string &restrict text,
- const std::string &restrict description,
- const std::string &restrict keyName,
- SetupTabScroll *restrict const parent,
- const std::string &restrict eventName,
- const int min, const int max,
- const MainConfig mainConfig = MainConfig_true);
-
- SetupItemIntTextField(const std::string &restrict text,
- const std::string &restrict description,
- const std::string &restrict keyName,
- SetupTabScroll *restrict const parent,
- const std::string &restrict eventName,
- const int min, const int max,
- const std::string &restrict def,
- const MainConfig mainConfig = MainConfig_true);
-
- A_DELETE_COPY(SetupItemIntTextField)
-
- ~SetupItemIntTextField();
-
- void createControls();
-
- void fromWidget() override final;
-
- void toWidget() override final;
-
- void action(const ActionEvent &event) override final;
-
- void apply(const std::string &eventName) override final;
-
- protected:
- HorizontContainer *mHorizont;
- Label *mLabel;
- IntTextField *mTextField;
- Button *mButton;
- EditDialog *mEditDialog;
- int mMin;
- int mMax;
-};
-
-class SetupItemLabel final : public SetupItem
-{
- public:
- SetupItemLabel(const std::string &restrict text,
- const std::string &restrict description,
- SetupTabScroll *restrict const parent,
- const Separator separator = Separator_true);
-
- A_DELETE_COPY(SetupItemLabel)
-
- ~SetupItemLabel();
-
- void createControls();
-
- void fromWidget() override final A_CONST;
-
- void toWidget() override final A_CONST;
-
- void action(const ActionEvent &event) override final A_CONST;
-
- void apply(const std::string &eventName) override final A_CONST;
-
- protected:
- Label *mLabel;
- Separator mIsSeparator;
-};
-
-class SetupItemDropDown final : public SetupItem
-{
- public:
- SetupItemDropDown(const std::string &restrict text,
- const std::string &restrict description,
- const std::string &restrict keyName,
- SetupTabScroll *restrict const parent,
- const std::string &restrict eventName,
- ListModel *restrict const model,
- const int width,
- const MainConfig mainConfig = MainConfig_true);
-
- SetupItemDropDown(const std::string &restrict text,
- const std::string &restrict description,
- const std::string &restrict keyName,
- SetupTabScroll *restrict const parent,
- const std::string &restrict eventName,
- ListModel *restrict const model,
- const int width,
- const std::string &restrict def,
- const MainConfig mainConfig = MainConfig_true);
-
- A_DELETE_COPY(SetupItemDropDown)
-
- ~SetupItemDropDown();
-
- void createControls();
-
- void fromWidget() override final;
-
- void toWidget() override final;
-
- int selectionByValue();
-
- protected:
- HorizontContainer *mHorizont;
- Label *mLabel;
- ListModel *mModel;
- DropDown *mDropDown;
- int mWidth;
-};
-
-class SetupItemDropDownStr final : public SetupItem
-{
- public:
- SetupItemDropDownStr(const std::string &restrict text,
- const std::string &restrict description,
- const std::string &restrict keyName,
- SetupTabScroll *restrict const parent,
- const std::string &restrict eventName,
- ListModel *restrict const model,
- const int width,
- const MainConfig mainConfig = MainConfig_true);
-
- SetupItemDropDownStr(const std::string &restrict text,
- const std::string &restrict description,
- const std::string &restrict keyName,
- SetupTabScroll *restrict const parent,
- const std::string &restrict eventName,
- ListModel *restrict const model,
- const int width,
- const std::string &restrict def,
- const MainConfig mainConfig = MainConfig_true);
-
- A_DELETE_COPY(SetupItemDropDownStr)
-
- ~SetupItemDropDownStr();
-
- void createControls();
-
- void fromWidget() override final;
-
- void toWidget() override final;
-
- int selectionByValue();
-
- protected:
- HorizontContainer *mHorizont;
- Label *mLabel;
- ListModel *mModel;
- DropDown *mDropDown;
- int mWidth;
-};
-
-class SetupItemSlider final : public SetupItem
-{
- public:
- SetupItemSlider(const std::string &restrict text,
- const std::string &restrict description,
- const std::string &restrict keyName,
- SetupTabScroll *restrict const parent,
- const std::string &restrict eventName,
- const double min,
- const double max,
- const double step,
- const int width,
- const OnTheFly onTheFly,
- const MainConfig mainConfig);
-
- SetupItemSlider(const std::string &restrict text,
- const std::string &restrict description,
- const std::string &restrict keyName,
- SetupTabScroll *restrict const parent,
- const std::string &restrict eventName,
- const double min,
- const double max,
- const double step,
- const std::string &restrict def,
- const int width,
- const OnTheFly onTheFly,
- const MainConfig mainConfig);
-
- A_DELETE_COPY(SetupItemSlider)
-
- ~SetupItemSlider();
-
- void createControls();
-
- void fromWidget() override final;
-
- void toWidget() override final;
-
- void action(const ActionEvent &event) override final;
-
- void apply(const std::string &eventName) override final;
-
- void updateLabel();
-
- protected:
- HorizontContainer *mHorizont;
- Label *mLabel;
- Slider *mSlider;
- double mMin;
- double mMax;
- double mStep;
- int mWidth;
- OnTheFly mOnTheFly;
-};
-
-typedef STD_VECTOR<std::string> SetupItemNames;
-typedef SetupItemNames::iterator SetupItemNamesIter;
-typedef SetupItemNames::const_iterator SetupItemNamesConstIter;
-
-class SetupItemSlider2 final : public SetupItem
-{
- public:
- SetupItemSlider2(const std::string &restrict text,
- const std::string &restrict description,
- const std::string &restrict keyName,
- SetupTabScroll *restrict const parent,
- const std::string &restrict eventName,
- const int min, const int max, const int step,
- SetupItemNames *restrict const values,
- const OnTheFly onTheFly,
- const MainConfig mainConfig,
- const DoNotAlign doNotAlign);
-
- SetupItemSlider2(const std::string &restrict text,
- const std::string &restrict description,
- const std::string &restrict keyName,
- SetupTabScroll *restrict const parent,
- const std::string &restrict eventName,
- const int min, const int max, const int step,
- SetupItemNames *restrict const values,
- const std::string &restrict def,
- const OnTheFly onTheFly,
- const MainConfig mainConfig,
- const DoNotAlign doNotAlign);
-
- A_DELETE_COPY(SetupItemSlider2)
-
- ~SetupItemSlider2();
-
- void createControls();
-
- void fromWidget() override final;
-
- void toWidget() override final;
-
- void action(const ActionEvent &event) override final;
-
- void apply(const std::string &eventName) override final;
-
- void setInvertValue(const int v);
-
- protected:
- void updateLabel();
-
- int getMaxWidth();
-
- HorizontContainer *mHorizont;
- Label *mLabel;
- Label *mLabel2;
- Slider *mSlider;
- SetupItemNames *mValues;
- int mMin;
- int mMax;
- int mStep;
- int mInvertValue;
- bool mInvert;
- OnTheFly mOnTheFly;
- DoNotAlign mDoNotAlign;
-};
-
-class SetupItemSliderList notfinal : public SetupItem
-{
- public:
- A_DELETE_COPY(SetupItemSliderList)
-
- virtual ~SetupItemSliderList();
-
- void createControls();
-
- void fromWidget() override;
-
- void toWidget() override;
-
- void action(const ActionEvent &event) override;
-
- void apply(const std::string &eventName) override final;
-
- virtual void addMoreControls() = 0;
-
- protected:
- SetupItemSliderList(const std::string &restrict text,
- const std::string &restrict description,
- const std::string &restrict keyName,
- SetupTabScroll *restrict const parent,
- const std::string &restrict eventName,
- ListModel *restrict const model,
- const int width = 150,
- const OnTheFly onTheFly = OnTheFly_false,
- const MainConfig mainConfig = MainConfig_true);
-
- SetupItemSliderList(const std::string &restrict text,
- const std::string &restrict description,
- const std::string &restrict keyName,
- SetupTabScroll *restrict const parent,
- const std::string &restrict eventName,
- ListModel *restrict const model,
- const std::string &restrict def,
- const int width = 150,
- const OnTheFly onTheFly = OnTheFly_false,
- const MainConfig mainConfig = MainConfig_true);
-
- HorizontContainer *mHorizont;
- Label *mLabel;
- SliderList *mSlider;
- ListModel *mModel;
- int mWidth;
- OnTheFly mOnTheFly;
-};
-
-class SetupItemSound final : public SetupItemSliderList
-{
- public:
- SetupItemSound(const std::string &restrict text,
- const std::string &restrict description,
- const std::string &restrict keyName,
- SetupTabScroll *restrict const parent,
- const std::string &restrict eventName,
- ListModel *restrict const model,
- const int width = 150,
- const OnTheFly onTheFly = OnTheFly_false,
- const MainConfig mainConfig = MainConfig_true);
-
- A_DELETE_COPY(SetupItemSound)
-
- void action(const ActionEvent &event) override final;
-
- void addMoreControls() override final;
-
- protected:
- Button *mButton;
-};
-
-class SetupItemSliderInt final : public SetupItemSliderList
-{
- public:
- SetupItemSliderInt(const std::string &restrict text,
- const std::string &restrict description,
- const std::string &restrict keyName,
- SetupTabScroll *restrict const parent,
- const std::string &restrict eventName,
- ListModel *restrict const model,
- const int min,
- const int width = 150,
- const OnTheFly onTheFly = OnTheFly_false,
- const MainConfig mainConfig = MainConfig_true);
-
- A_DELETE_COPY(SetupItemSliderInt)
-
- void addMoreControls() override final;
-
- void fromWidget() override final;
-
- void toWidget() override final;
-
- protected:
- int mMin;
-};
-
-#endif // GUI_WIDGETS_SETUPITEM_H
diff --git a/src/gui/widgets/setupquickitem.cpp b/src/gui/widgets/setupquickitem.cpp
deleted file mode 100644
index 238a8a213..000000000
--- a/src/gui/widgets/setupquickitem.cpp
+++ /dev/null
@@ -1,117 +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 "gui/widgets/setupquickitem.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/horizontcontainer.h"
-#include "gui/widgets/label.h"
-#include "gui/widgets/vertcontainer.h"
-
-#include "gui/widgets/tabs/setuptabscroll.h"
-
-#include "debug.h"
-
-SetupQuickItem::SetupQuickItem(const std::string &restrict description,
- SetupTabScroll *restrict const parent,
- const std::string &restrict eventName,
- const ModifierGetFuncPtr getFunc,
- const ModifierChangeFuncPtr changeFunc) :
- SetupItem("", description, "", parent, eventName, MainConfig_false),
- GameModifierListener(),
- mHorizont(nullptr),
- mButton(nullptr),
- mLabel(nullptr),
- mGetFunc(getFunc),
- mChangeFunc(changeFunc)
-{
- mValueType = VSTR;
- createControls();
-}
-
-SetupQuickItem::~SetupQuickItem()
-{
- mHorizont = nullptr;
- mWidget = nullptr;
- mButton = nullptr;
-}
-
-void SetupQuickItem::save()
-{
-}
-
-void SetupQuickItem::cancel(const std::string &eventName A_UNUSED)
-{
-}
-
-void SetupQuickItem::externalUpdated(const std::string &eventName A_UNUSED)
-{
-}
-
-void SetupQuickItem::rereadValue()
-{
-}
-
-void SetupQuickItem::createControls()
-{
- mHorizont = new HorizontContainer(this, 32, 2);
-
- mWidget = new Button(this, ">", mEventName + "_CHANGE", nullptr);
- mLabel = new Label(this, std::string());
- mLabel->setToolTip(mDescription);
- mLabel->adjustSize();
-
- mHorizont->add(mWidget, 5);
- mHorizont->add(mLabel);
-
- mParent->getContainer()->add2(mHorizont, true, 4);
- mParent->addControl(this);
- mWidget->addActionListener(this);
- toWidget();
-}
-
-void SetupQuickItem::fromWidget()
-{
-}
-
-void SetupQuickItem::toWidget()
-{
- mLabel->setCaption(mGetFunc());
- mLabel->adjustSize();
-}
-
-void SetupQuickItem::action(const ActionEvent &event)
-{
- if (event.getId() == mEventName + "_CHANGE")
- {
- // need change game modifier
- mChangeFunc(true);
- toWidget();
- }
-}
-
-void SetupQuickItem::apply(const std::string &eventName A_UNUSED)
-{
-}
-
-void SetupQuickItem::gameModifiersChanged()
-{
- toWidget();
-}
diff --git a/src/gui/widgets/setupquickitem.h b/src/gui/widgets/setupquickitem.h
deleted file mode 100644
index 24a9507a4..000000000
--- a/src/gui/widgets/setupquickitem.h
+++ /dev/null
@@ -1,80 +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 GUI_WIDGETS_SETUPQUICKITEM_H
-#define GUI_WIDGETS_SETUPQUICKITEM_H
-
-#include "gui/widgets/setupitem.h"
-
-#include "listeners/gamemodifierlistener.h"
-
-class Button;
-class HorizontContainer;
-class Label;
-class SetupTabScroll;
-
-typedef std::string (*ModifierGetFuncPtr)();
-typedef void (*ModifierChangeFuncPtr)(const bool forward);
-
-class SetupQuickItem final : public SetupItem,
- public GameModifierListener
-{
- public:
- SetupQuickItem(const std::string &restrict description,
- SetupTabScroll *restrict const parent,
- const std::string &restrict eventName,
- ModifierGetFuncPtr getFunc,
- ModifierChangeFuncPtr changeFunc);
-
- A_DELETE_COPY(SetupQuickItem)
-
- ~SetupQuickItem();
-
- void createControls();
-
- void fromWidget() override final A_CONST;
-
- void toWidget() override final;
-
- void action(const ActionEvent &event) override final;
-
- void apply(const std::string &eventName) override final A_CONST;
-
- void cancel(const std::string &eventName A_UNUSED) override final
- A_CONST;
-
- void externalUpdated(const std::string &eventName A_UNUSED)
- override final A_CONST;
-
- void rereadValue() override final A_CONST;
-
- void save() override final A_CONST;
-
- void gameModifiersChanged() override final;
-
- protected:
- HorizontContainer *mHorizont;
- Button *mButton;
- Label *mLabel;
- ModifierGetFuncPtr mGetFunc;
- ModifierChangeFuncPtr mChangeFunc;
-};
-
-#endif // GUI_WIDGETS_SETUPQUICKITEM_H
diff --git a/src/gui/widgets/setuptouchitem.cpp b/src/gui/widgets/setuptouchitem.cpp
deleted file mode 100644
index 122853c7e..000000000
--- a/src/gui/widgets/setuptouchitem.cpp
+++ /dev/null
@@ -1,132 +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 "gui/widgets/setuptouchitem.h"
-
-#include "gui/models/touchactionmodel.h"
-
-#include "gui/widgets/dropdown.h"
-#include "gui/widgets/horizontcontainer.h"
-#include "gui/widgets/label.h"
-#include "gui/widgets/vertcontainer.h"
-
-#include "gui/widgets/tabs/setuptabscroll.h"
-
-#include "utils/stringutils.h"
-
-#include "debug.h"
-
-SetupActionDropDown::SetupActionDropDown(const std::string &restrict text,
- const std::string &restrict
- description,
- const std::string &restrict keyName,
- SetupTabScroll *restrict const parent,
- const std::string &restrict eventName,
- TouchActionsModel *restrict
- const model,
- const int width,
- const MainConfig mainConfig) :
- SetupItem(text, description, keyName, parent, eventName, mainConfig),
- mHorizont(nullptr),
- mLabel(nullptr),
- mModel(model),
- mDropDown(nullptr),
- mWidth(width)
-{
- mValueType = VSTR;
- createControls();
-}
-
-SetupActionDropDown::SetupActionDropDown(const std::string &restrict text,
- const std::string &restrict
- description,
- const std::string &restrict keyName,
- SetupTabScroll *restrict const parent,
- const std::string &restrict eventName,
- TouchActionsModel *restrict
- const model,
- const int width,
- const std::string &restrict def,
- const MainConfig mainConfig) :
- SetupItem(text, description, keyName, parent, eventName, def, mainConfig),
- mHorizont(nullptr),
- mLabel(nullptr),
- mModel(model),
- mDropDown(nullptr),
- mWidth(width)
-{
- mValueType = VSTR;
- createControls();
-}
-
-SetupActionDropDown::~SetupActionDropDown()
-{
- mHorizont = nullptr;
- mWidget = nullptr;
- mModel = nullptr;
- mDropDown = nullptr;
- mLabel = nullptr;
-}
-
-void SetupActionDropDown::createControls()
-{
- if (mModel == nullptr)
- return;
-
- load();
- mHorizont = new HorizontContainer(this, 32, 2);
-
- mLabel = new Label(this, mText);
- mLabel->setToolTip(mDescription);
- mDropDown = new DropDown(this, mModel);
- mDropDown->setActionEventId(mEventName);
- mDropDown->addActionListener(mParent);
- mDropDown->setWidth(mWidth);
- mDropDown->setSelected(mModel->getSelectionFromAction(
- static_cast<InputActionT>(atoi(mValue.c_str()))));
-
- mWidget = mDropDown;
- fixFirstItemSize(mLabel);
- mHorizont->add(mLabel);
- mHorizont->add(mDropDown);
-
- mParent->getContainer()->add2(mHorizont, true, 4);
- mParent->addControl(this);
- mParent->addActionListener(this);
- mWidget->addActionListener(this);
-}
-
-void SetupActionDropDown::fromWidget()
-{
- if ((mDropDown == nullptr) || (mModel == nullptr))
- return;
-
- mValue = toString(CAST_S32(mModel->getActionFromSelection(
- mDropDown->getSelected())));
-}
-
-void SetupActionDropDown::toWidget()
-{
- if ((mDropDown == nullptr) || (mModel == nullptr))
- return;
-
- mDropDown->setSelected(mModel->getSelectionFromAction(
- static_cast<InputActionT>(atoi(mValue.c_str()))));
-}
diff --git a/src/gui/widgets/setuptouchitem.h b/src/gui/widgets/setuptouchitem.h
deleted file mode 100644
index 55521b684..000000000
--- a/src/gui/widgets/setuptouchitem.h
+++ /dev/null
@@ -1,67 +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 GUI_WIDGETS_SETUPTOUCHITEM_H
-#define GUI_WIDGETS_SETUPTOUCHITEM_H
-
-#include "gui/widgets/setupitem.h"
-
-class TouchActionsModel;
-
-class SetupActionDropDown final : public SetupItem
-{
- public:
- SetupActionDropDown(const std::string &restrict text,
- const std::string &restrict description,
- const std::string &restrict keyName,
- SetupTabScroll *restrict const parent,
- const std::string &restrict eventName,
- TouchActionsModel *restrict const model,
- const int width,
- const MainConfig mainConfig = MainConfig_true);
-
- SetupActionDropDown(const std::string &restrict text,
- const std::string &restrict description,
- const std::string &restrict keyName,
- SetupTabScroll *restrict const parent,
- const std::string &restrict eventName,
- TouchActionsModel *restrict const model,
- const int width, const std::string &def,
- const MainConfig mainConfig = MainConfig_true);
-
- A_DELETE_COPY(SetupActionDropDown)
-
- ~SetupActionDropDown();
-
- void createControls();
-
- void fromWidget() override final;
-
- void toWidget() override final;
-
- protected:
- HorizontContainer *mHorizont;
- Label *mLabel;
- TouchActionsModel *mModel;
- DropDown *mDropDown;
- int mWidth;
-};
-
-#endif // GUI_WIDGETS_SETUPTOUCHITEM_H
diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp
deleted file mode 100644
index 3df46b854..000000000
--- a/src/gui/widgets/shoplistbox.cpp
+++ /dev/null
@@ -1,310 +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 "gui/widgets/shoplistbox.h"
-
-#include "dragdrop.h"
-#include "settings.h"
-
-#include "being/playerinfo.h"
-
-#include "gui/viewport.h"
-
-#include "gui/fonts/font.h"
-
-#include "gui/popups/itempopup.h"
-#include "gui/popups/popupmenu.h"
-
-#include "gui/models/shopitems.h"
-
-#include "gui/windows/itemamountwindow.h"
-
-#include "net/net.h"
-
-#include "resources/inventory/inventory.h"
-
-#include "resources/item/shopitem.h"
-
-#include "debug.h"
-
-const int ITEM_ICON_SIZE = 32;
-
-ShopListBox::ShopListBox(const Widget2 *const widget,
- ListModel *const listModel,
- const ShopListBoxTypeT type) :
- ListBox(widget, listModel, "shoplistbox.xml"),
- mPlayerMoney(0),
- mShopItems(nullptr),
- mWarningColor(getThemeColor(ThemeColorId::SHOP_WARNING)),
- mType(type),
- mPriceCheck(true),
- mProtectItems(false)
-{
- mRowHeight = getFont()->getHeight();
- mHighlightColor = getThemeColor(ThemeColorId::HIGHLIGHT);
- mForegroundColor = getThemeColor(ThemeColorId::LISTBOX);
- mBackgroundColor = getThemeColor(ThemeColorId::BACKGROUND);
-}
-
-ShopListBox::ShopListBox(const Widget2 *const widget,
- ListModel *const listModel,
- ShopItems *const shopListModel,
- const ShopListBoxTypeT type) :
- ListBox(widget, listModel, "shoplistbox.xml"),
- mPlayerMoney(0),
- mShopItems(shopListModel),
- mWarningColor(getThemeColor(ThemeColorId::SHOP_WARNING)),
- mType(type),
- mPriceCheck(true),
- mProtectItems(false)
-{
- mRowHeight = std::max(getFont()->getHeight(), ITEM_ICON_SIZE);
- mHighlightColor = getThemeColor(ThemeColorId::HIGHLIGHT);
- mForegroundColor = getThemeColor(ThemeColorId::LISTBOX);
- mBackgroundColor = getThemeColor(ThemeColorId::BACKGROUND);
-}
-
-void ShopListBox::setPlayersMoney(const int money)
-{
- mPlayerMoney = money;
-}
-
-void ShopListBox::draw(Graphics *const graphics)
-{
- BLOCK_START("ShopListBox::draw")
- if ((mListModel == nullptr) || (mShopItems == nullptr))
- {
- BLOCK_END("ShopListBox::draw")
- return;
- }
-
- if (settings.guiAlpha != mAlpha)
- mAlpha = settings.guiAlpha;
-
- const unsigned int alpha = CAST_U32(mAlpha * 255.0F);
- Font *const font = getFont();
-
- const int sz = mListModel->getNumberOfElements();
- const int fontHeigh = getFont()->getHeight();
- const int width = mDimension.width - 2 * mPadding;
- // Draw the list elements
- for (int i = 0, y = 0;
- i < sz;
- ++i, y += mRowHeight)
- {
- bool needDraw(false);
- Color temp;
- Color* backgroundColor = &mBackgroundColor;
-
- ShopItem *const item = mShopItems->at(i);
- if ((item != nullptr) &&
- (item->getDisabled() ||
- (mPlayerMoney < item->getPrice() && mPriceCheck) ||
- (mProtectItems && PlayerInfo::isItemProtected(item->getId()))))
- {
- if (i != mSelected)
- {
- backgroundColor = &mWarningColor;
- backgroundColor->a = alpha;
- }
- else
- {
- temp = mWarningColor;
- temp.r = (temp.r + mHighlightColor.r) / 2;
- temp.g = (temp.g + mHighlightColor.g) / 2;
- temp.b = (temp.b + mHighlightColor.b) / 2;
- temp.a = alpha;
- backgroundColor = &temp;
- }
- needDraw = true;
- }
- else if (i == mSelected)
- {
- mHighlightColor.a = alpha;
- backgroundColor = &mHighlightColor;
- needDraw = true;
- }
- else
- {
- mBackgroundColor.a = alpha;
- }
-
- if (needDraw)
- {
- graphics->setColor(*backgroundColor);
- graphics->fillRectangle(Rect(mPadding, y + mPadding,
- width, mRowHeight));
- }
-
- if ((mShopItems != nullptr) && (item != nullptr))
- {
- Image *const icon = item->getImage();
- if (icon != nullptr)
- {
- icon->setAlpha(1.0F);
- graphics->drawImage(icon, mPadding, y + mPadding);
- }
- }
- if (mSelected == i)
- {
- font->drawString(graphics,
- mForegroundSelectedColor,
- mForegroundSelectedColor2,
- mListModel->getElementAt(i),
- ITEM_ICON_SIZE + mPadding,
- y + (ITEM_ICON_SIZE - fontHeigh) / 2 + mPadding);
- }
- else
- {
- font->drawString(graphics,
- mForegroundColor,
- mForegroundColor2,
- mListModel->getElementAt(i),
- ITEM_ICON_SIZE + mPadding,
- y + (ITEM_ICON_SIZE - fontHeigh) / 2 + mPadding);
- }
- }
- BLOCK_END("ShopListBox::draw")
-}
-
-void ShopListBox::safeDraw(Graphics *const graphics)
-{
- ShopListBox::draw(graphics);
-}
-
-void ShopListBox::adjustSize()
-{
- BLOCK_START("ShopListBox::adjustSize")
- if (mListModel != nullptr)
- {
- setHeight(mRowHeight * mListModel->getNumberOfElements()
- + 2 * mPadding);
- }
- BLOCK_END("ShopListBox::adjustSize")
-}
-
-void ShopListBox::setPriceCheck(const bool check)
-{
- mPriceCheck = check;
-}
-
-void ShopListBox::mouseMoved(MouseEvent &event)
-{
- if ((itemPopup == nullptr) || (mRowHeight == 0u))
- return;
-
- if (mShopItems == nullptr)
- {
- itemPopup->hide();
- return;
- }
-
- const int index = (event.getY() - mPadding) / mRowHeight;
-
- if (index < 0 || index >= mShopItems->getNumberOfElements())
- {
- itemPopup->hide();
- }
- else
- {
- const Item *const item = mShopItems->at(index);
- if (item != nullptr)
- {
- itemPopup->setItem(item, false);
- itemPopup->position(viewport->mMouseX, viewport->mMouseY);
- }
- else
- {
- itemPopup->setVisible(Visible_false);
- }
- }
-}
-
-void ShopListBox::mouseReleased(MouseEvent& event)
-{
- ListBox::mouseReleased(event);
- if (event.getType() == MouseEventType::RELEASED2)
- {
- if (dragDrop.isEmpty())
- return;
- const DragDropSourceT src = dragDrop.getSource();
- if (mType != ShopListBoxType::SellShop &&
- mType != ShopListBoxType::BuyShop)
- {
- return;
- }
- if (mType == ShopListBoxType::SellShop &&
- Net::getNetworkType() != ServerType::TMWATHENA &&
- src != DragDropSource::Cart)
- {
- return;
- }
- Inventory *inventory;
- if (src == DragDropSource::Inventory)
- inventory = PlayerInfo::getInventory();
- else if (src == DragDropSource::Cart)
- inventory = PlayerInfo::getCartInventory();
- else
- return;
- if (inventory == nullptr)
- return;
- Item *const item = inventory->getItem(dragDrop.getTag());
- if (mType == ShopListBoxType::BuyShop)
- {
- ItemAmountWindow::showWindow(
- ItemAmountWindowUsage::ShopBuyAdd,
- nullptr,
- item);
- }
- else
- {
- ItemAmountWindow::showWindow(
- ItemAmountWindowUsage::ShopSellAdd,
- nullptr,
- item);
- }
- }
-
- if (event.getButton() == MouseButton::RIGHT)
- {
- setSelected(std::max(0, getSelectionByMouse(event.getY())));
-
- if (mSelected < 0 || mSelected >= mShopItems->getNumberOfElements())
- return;
-
- Item *const item = mShopItems->at(mSelected);
- if ((popupMenu != nullptr) && (viewport != nullptr))
- {
- popupMenu->showItemPopup(viewport->mMouseX,
- viewport->mMouseY,
- item);
- }
- }
-}
-
-void ShopListBox::mouseExited(MouseEvent& event A_UNUSED)
-{
- if (itemPopup == nullptr)
- return;
-
- itemPopup->hide();
-}
diff --git a/src/gui/widgets/shoplistbox.h b/src/gui/widgets/shoplistbox.h
deleted file mode 100644
index 2e79d16bb..000000000
--- a/src/gui/widgets/shoplistbox.h
+++ /dev/null
@@ -1,113 +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_SHOPLISTBOX_H
-#define GUI_WIDGETS_SHOPLISTBOX_H
-
-#include "gui/widgets/listbox.h"
-
-#include "enums/gui/shoplistboxtype.h"
-
-class ShopItems;
-
-/**
- * A list box, meant to be used inside a scroll area. Same as the Guichan list
- * box except this one doesn't have a background, instead completely relying
- * on the scroll area. It also adds selection listener functionality.
- *
- * \ingroup GUI
- */
-class ShopListBox final : public ListBox
-{
- public:
- /**
- * Constructor.
- */
- ShopListBox(const Widget2 *const widget,
- ListModel *const listModel,
- const ShopListBoxTypeT type);
-
- /**
- * Constructor with shopitems
- */
- ShopListBox(const Widget2 *const widget,
- ListModel *const listModel,
- ShopItems *const shopListModel,
- const ShopListBoxTypeT type);
-
- A_DELETE_COPY(ShopListBox)
-
- /**
- * Draws the list box.
- */
- void draw(Graphics *const graphics) override final A_NONNULL(2);
-
- void safeDraw(Graphics *const graphics) override final A_NONNULL(2);
-
- /**
- * gives information about the current player's money
- */
- void setPlayersMoney(const int money);
-
- /**
- * Adjust List draw size
- */
- void adjustSize() override final;
-
- /**
- * Set on/off the disabling of too expensive items.
- * (Good for selling mode.)
- */
- void setPriceCheck(const bool check);
-
- void mouseMoved(MouseEvent &event) override final;
-
- void mouseReleased(MouseEvent& event) override final;
-
- void mouseExited(MouseEvent& event) override final;
-
- void setProtectItems(bool p)
- { mProtectItems = p; }
-
- void setType(const ShopListBoxTypeT type)
- { mType = type; }
-
- ShopListBoxTypeT getType() const
- { return mType; }
-
- private:
- int mPlayerMoney;
-
- /**
- * Keeps another pointer to the same listModel, permitting to
- * use the ShopItems specific functions.
- */
- ShopItems *mShopItems;
-
- Color mWarningColor;
- ShopListBoxTypeT mType;
-
- bool mPriceCheck;
- bool mProtectItems;
-};
-
-#endif // GUI_WIDGETS_SHOPLISTBOX_H
diff --git a/src/gui/widgets/shortcutcontainer.cpp b/src/gui/widgets/shortcutcontainer.cpp
deleted file mode 100644
index a2b90514d..000000000
--- a/src/gui/widgets/shortcutcontainer.cpp
+++ /dev/null
@@ -1,159 +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 "gui/widgets/shortcutcontainer.h"
-
-#include "settings.h"
-
-#include "gui/gui.h"
-
-#include "utils/delete2.h"
-
-#include "resources/image/image.h"
-
-#include "render/graphics.h"
-
-#include "render/vertexes/imagecollection.h"
-
-#include "debug.h"
-
-float ShortcutContainer::mAlpha = 1.0;
-
-ShortcutContainer::ShortcutContainer(Widget2 *const widget) :
- Widget(widget),
- WidgetListener(),
- MouseListener(),
- mBackgroundImg(nullptr),
- mMaxItems(0),
- mBoxWidth(1),
- mBoxHeight(1),
- mGridWidth(1),
- mGridHeight(1),
- mVertexes(new ImageCollection)
-{
- mAllowLogic = false;
-
- addMouseListener(this);
- addWidgetListener(this);
-
- mForegroundColor = getThemeColor(ThemeColorId::TEXT);
- mForegroundColor2 = getThemeColor(ThemeColorId::TEXT_OUTLINE);
-
- mBackgroundImg = Theme::getImageFromThemeXml(
- "item_shortcut_background.xml", "background.xml");
-
- if (mBackgroundImg != nullptr)
- {
- mBackgroundImg->setAlpha(settings.guiAlpha);
- mBoxHeight = mBackgroundImg->getHeight();
- mBoxWidth = mBackgroundImg->getWidth();
- }
- else
- {
- mBoxHeight = 1;
- mBoxWidth = 1;
- }
-}
-
-ShortcutContainer::~ShortcutContainer()
-{
- if (mBackgroundImg != nullptr)
- {
- mBackgroundImg->decRef();
- mBackgroundImg = nullptr;
- }
-
- if (gui != nullptr)
- gui->removeDragged(this);
-
- delete2(mVertexes);
-}
-
-void ShortcutContainer::widgetResized(const Event &event A_UNUSED)
-{
- mGridWidth = mDimension.width / mBoxWidth;
-
- if (mGridWidth < 1)
- mGridWidth = 1;
-
- mGridHeight = mMaxItems / CAST_U32(mGridWidth);
-
- if (mMaxItems % mGridWidth != 0 || mGridHeight < 1)
- ++mGridHeight;
-
- setHeight(mGridHeight * mBoxHeight);
- mRedraw = true;
-}
-
-int ShortcutContainer::getIndexFromGrid(const int pointX,
- const int pointY) const
-{
- const Rect tRect = Rect(0, 0,
- mGridWidth * mBoxWidth, mGridHeight * mBoxHeight);
-
- int index = ((pointY / mBoxHeight) * mGridWidth) + pointX / mBoxWidth;
-
- if (!tRect.isPointInRect(pointX, pointY) ||
- index >= CAST_S32(mMaxItems) || index < 0)
- {
- index = -1;
- }
-
- return index;
-}
-
-void ShortcutContainer::drawBackground(Graphics *const g)
-{
- if (mBackgroundImg != nullptr)
- {
- if (mRedraw)
- {
- mRedraw = false;
- mVertexes->clear();
- for (unsigned i = 0; i < mMaxItems; i ++)
- {
- g->calcTileCollection(mVertexes, mBackgroundImg,
- (i % mGridWidth) * mBoxWidth,
- (i / mGridWidth) * mBoxHeight);
- }
- g->finalize(mVertexes);
- }
- g->drawTileCollection(mVertexes);
- }
-}
-
-void ShortcutContainer::safeDrawBackground(Graphics *const g)
-{
- if (mBackgroundImg != nullptr)
- {
- for (unsigned i = 0; i < mMaxItems; i ++)
- {
- g->drawImage(mBackgroundImg, (i % mGridWidth) * mBoxWidth,
- (i / mGridWidth) * mBoxHeight);
- }
- }
-}
-
-void ShortcutContainer::widgetMoved(const Event& event A_UNUSED)
-{
- mRedraw = true;
-}
diff --git a/src/gui/widgets/shortcutcontainer.h b/src/gui/widgets/shortcutcontainer.h
deleted file mode 100644
index b7076dfc2..000000000
--- a/src/gui/widgets/shortcutcontainer.h
+++ /dev/null
@@ -1,120 +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 GUI_WIDGETS_SHORTCUTCONTAINER_H
-#define GUI_WIDGETS_SHORTCUTCONTAINER_H
-
-#include "gui/widgets/widget.h"
-
-#include "listeners/mouselistener.h"
-#include "listeners/widgetlistener.h"
-
-class Image;
-class ImageCollection;
-
-/**
- * A generic shortcut container.
- *
- * \ingroup GUI
- */
-class ShortcutContainer notfinal : public Widget,
- public WidgetListener,
- public MouseListener
-{
- public:
- A_DELETE_COPY(ShortcutContainer)
-
- /**
- * Destructor.
- */
- virtual ~ShortcutContainer();
-
- /**
- * Invoked when a widget changes its size. This is used to determine
- * the new height of the container.
- */
- void widgetResized(const Event &event) override final;
-
- void widgetMoved(const Event& event) override final;
-
- /**
- * Handles mouse when dragged.
- */
- void mouseDragged(MouseEvent &event A_UNUSED) override
- {
- }
-
- /**
- * Handles mouse when pressed.
- */
- void mousePressed(MouseEvent &event A_UNUSED) override
- {
- }
-
- /**
- * Handles mouse release.
- */
- void mouseReleased(MouseEvent &event A_UNUSED) override
- {
- }
-
- int getMaxItems() const noexcept2 A_WARN_UNUSED
- { return mMaxItems; }
-
- int getBoxWidth() const noexcept2 A_WARN_UNUSED
- { return mBoxWidth; }
-
- int getBoxHeight() const noexcept2 A_WARN_UNUSED
- { return mBoxHeight; }
-
- void drawBackground(Graphics *const g) A_NONNULL(2);
-
- void safeDrawBackground(Graphics *const g) A_NONNULL(2);
-
- protected:
- /**
- * Constructor. Initializes the shortcut container.
- */
- explicit ShortcutContainer(Widget2 *const widget);
-
- /**
- * Gets the index from the grid provided the point is in an item box.
- *
- * @param pointX X coordinate of the point.
- * @param pointY Y coordinate of the point.
- * @return index on success, -1 on failure.
- */
- int getIndexFromGrid(const int pointX,
- const int pointY) const A_WARN_UNUSED;
-
- Image *mBackgroundImg;
- static float mAlpha;
-
- unsigned mMaxItems;
- int mBoxWidth;
- int mBoxHeight;
- int mGridWidth;
- int mGridHeight;
- ImageCollection *mVertexes;
-};
-
-#endif // GUI_WIDGETS_SHORTCUTCONTAINER_H
diff --git a/src/gui/widgets/skilllistbox.h b/src/gui/widgets/skilllistbox.h
deleted file mode 100644
index 4f7e2a61b..000000000
--- a/src/gui/widgets/skilllistbox.h
+++ /dev/null
@@ -1,290 +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_SKILLLISTBOX_H
-#define GUI_WIDGETS_SKILLLISTBOX_H
-
-#include "const/resources/skill.h"
-
-#include "dragdrop.h"
-
-#include "gui/skin.h"
-#include "gui/viewport.h"
-
-#include "gui/widgets/listbox.h"
-
-#include "gui/fonts/font.h"
-
-#include "gui/models/skillmodel.h"
-
-#include "gui/popups/popupmenu.h"
-#include "gui/popups/skillpopup.h"
-
-#include "utils/delete2.h"
-
-#include "render/graphics.h"
-
-#include "localconsts.h"
-
-class SkillModel;
-
-class SkillListBox final : public ListBox
-{
- public:
- SkillListBox(const Widget2 *const widget,
- SkillModel *const model) :
- ListBox(widget, model, "skilllistbox.xml"),
- mModel(model),
- mTextColor(getThemeColor(ThemeColorId::TEXT)),
- mTextColor2(getThemeColor(ThemeColorId::TEXT_OUTLINE)),
- mCooldownColor(getThemeColor(ThemeColorId::SKILL_COOLDOWN)),
- mTextPadding(mSkin != nullptr ?
- mSkin->getOption("textPadding", 34) : 34),
- mSpacing(mSkin != nullptr ? mSkin->getOption("spacing", 0) : 0),
- mSkillClicked(false)
- {
- mRowHeight = getFont()->getHeight() * 2 + mSpacing + 2 * mPadding;
- mHighlightColor = getThemeColor(ThemeColorId::HIGHLIGHT);
-
- if (mRowHeight < 34)
- mRowHeight = 34;
- }
-
- A_DELETE_COPY(SkillListBox)
-
- ~SkillListBox()
- {
- delete2(mModel)
- }
-
- SkillInfo *getSelectedInfo() const
- {
- const int selected = getSelected();
- if ((mListModel == nullptr) || selected < 0
- || selected > mListModel->getNumberOfElements())
- {
- return nullptr;
- }
-
- return static_cast<SkillModel*>(mListModel)->getSkillAt(selected);
- }
-
- void draw(Graphics *const graphics) override final A_NONNULL(2)
- {
- if (mListModel == nullptr)
- return;
-
- SkillModel *const model = static_cast<SkillModel*>(mListModel);
- updateAlpha();
-
- mHighlightColor.a = CAST_S32(mAlpha * 255.0F);
- graphics->setColor(mHighlightColor);
-
- const int width1 = getWidth();
- const int usableWidth = width1 - 2 * mPadding;
-
- // Draw filled rectangle around the selected list element
- if (mSelected >= 0)
- {
- graphics->fillRectangle(Rect(mPadding, getRowHeight()
- * mSelected + mPadding, usableWidth,
- getRowHeight()));
- }
-
- // Draw the list elements
- Font *const font = getFont();
- const int space = font->getHeight() + mSpacing;
- const int width2 = width1 - mPadding;
-
- graphics->setColor(mCooldownColor);
- for (int i = 0, y = 1 + mPadding;
- i < model->getNumberOfElements();
- ++i, y += getRowHeight())
- {
- SkillInfo *const e = model->getSkillAt(i);
- if (e != nullptr)
- {
- if (e->cooldown != 0)
- {
- graphics->fillRectangle(Rect(mPadding, y,
- usableWidth * 100 / e->cooldown, 10));
- }
- }
- }
-
- for (int i = 0, y = 1 + mPadding;
- i < model->getNumberOfElements();
- ++i, y += getRowHeight())
- {
- SkillInfo *const e = model->getSkillAt(i);
- if (e != nullptr)
- {
- const SkillData *const data = e->data;
- const std::string &description = data->description;
- graphics->drawImage(data->icon, mPadding, y);
- font->drawString(graphics,
- mTextColor,
- mTextColor2,
- data->name,
- mTextPadding, y);
- if (!description.empty())
- {
- font->drawString(graphics,
- mTextColor,
- mTextColor2,
- description,
- mTextPadding,
- y + space);
- }
-
- if (e->skillLevelWidth < 0)
- {
- // Add one for padding
- e->skillLevelWidth = font->getWidth(e->skillLevel) + 1;
- }
-
- font->drawString(graphics,
- mTextColor,
- mTextColor2,
- e->skillLevel,
- width2 - e->skillLevelWidth,
- y);
- }
- }
- }
-
- void safeDraw(Graphics *const graphics) override final A_NONNULL(2)
- {
- SkillListBox::draw(graphics);
- }
-
- unsigned int getRowHeight() const override final
- { return mRowHeight; }
-
- const SkillInfo *getSkillByEvent(const MouseEvent &event) const
- {
- const int y = (event.getY() + mPadding) / getRowHeight();
- if (mModel == nullptr || y >= mModel->getNumberOfElements())
- return nullptr;
- const SkillInfo *const skill = mModel->getSkillAt(y);
- if (skill == nullptr)
- return nullptr;
- return skill;
- }
-
- void mouseMoved(MouseEvent &event) override final
- {
- ListBox::mouseMoved(event);
- if ((viewport == nullptr) || !dragDrop.isEmpty())
- return;
-
- const SkillInfo *const skill = getSkillByEvent(event);
- if (skill == nullptr)
- return;
- skillPopup->show(skill,
- skill->customSelectedLevel,
- skill->customCastType,
- skill->customOffsetX,
- skill->customOffsetY);
- skillPopup->position(viewport->mMouseX,
- viewport->mMouseY);
- }
-
- void mouseDragged(MouseEvent &event) override final
- {
- if (event.getButton() == MouseButton::LEFT)
- {
- if (dragDrop.isEmpty())
- {
- if (mSkillClicked)
- {
- mSkillClicked = false;
- const SkillInfo *const skill = getSkillByEvent(event);
- if (skill == nullptr)
- return;
- dragDrop.dragSkill(skill, DragDropSource::Skills);
- dragDrop.setItem(skill->id + SKILL_MIN_ID);
- dragDrop.setItemData(skill->toDataStr());
- }
- ListBox::mouseDragged(event);
- }
- }
- else
- {
- ListBox::mouseDragged(event);
- }
- }
-
- void mousePressed(MouseEvent &event) override final
- {
- ListBox::mousePressed(event);
- const MouseButtonT button = event.getButton();
- if (button == MouseButton::LEFT ||
- button == MouseButton::RIGHT)
- {
- const SkillInfo *const skill = getSkillByEvent(event);
- if (skill == nullptr)
- return;
- event.consume();
- mSkillClicked = true;
- SkillModel *const model = static_cast<SkillModel*>(
- mListModel);
- if ((model != nullptr) &&
- mSelected >= 0 &&
- model->getSkillAt(mSelected) == skill)
- {
- skillPopup->hide();
- if (button == MouseButton::LEFT &&
- event.getX() >
- getWidth() - mPadding - skill->skillLevelWidth)
- {
- popupMenu->showSkillLevelPopup(skill);
- }
- else if (button == MouseButton::RIGHT)
- {
- popupMenu->showSkillPopup(skill);
- }
- }
- }
- }
-
- void mouseReleased(MouseEvent &event) override final
- {
- ListBox::mouseReleased(event);
- }
-
- void mouseExited(MouseEvent &event A_UNUSED) override final
- {
- skillPopup->hide();
- }
-
- private:
- SkillModel *mModel;
- Color mTextColor;
- Color mTextColor2;
- Color mCooldownColor;
- int mTextPadding;
- int mSpacing;
- bool mSkillClicked;
-};
-
-#endif // GUI_WIDGETS_SKILLLISTBOX_H
diff --git a/src/gui/widgets/skillrectanglelistbox.h b/src/gui/widgets/skillrectanglelistbox.h
deleted file mode 100644
index a3139260c..000000000
--- a/src/gui/widgets/skillrectanglelistbox.h
+++ /dev/null
@@ -1,418 +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 GUI_WIDGETS_SKILLRECTANGLELISTBOX_H
-#define GUI_WIDGETS_SKILLRECTANGLELISTBOX_H
-
-#include "const/resources/skill.h"
-
-#include "dragdrop.h"
-#include "settings.h"
-
-#include "gui/skin.h"
-#include "gui/viewport.h"
-
-#include "gui/fonts/font.h"
-
-#include "gui/models/skillmodel.h"
-
-#include "gui/popups/popupmenu.h"
-#include "gui/popups/skillpopup.h"
-
-#include "utils/delete2.h"
-
-#include "render/graphics.h"
-
-#include "localconsts.h"
-
-class SkillModel;
-
-class SkillRectangleListBox final : public Widget,
- public MouseListener
-{
- public:
- SkillRectangleListBox(const Widget2 *const widget,
- SkillModel *const model) :
- Widget(widget),
- MouseListener(),
- mHighlightColor(getThemeColor(ThemeColorId::HIGHLIGHT)),
- mTextColor(getThemeColor(ThemeColorId::TEXT)),
- mTextColor2(getThemeColor(ThemeColorId::TEXT_OUTLINE)),
- mCooldownColor(getThemeColor(ThemeColorId::SKILL_COOLDOWN)),
- mForegroundSelectedColor(getThemeColor(
- ThemeColorId::LISTBOX_SELECTED)),
- mForegroundSelectedColor2(getThemeColor(
- ThemeColorId::LISTBOX_SELECTED_OUTLINE)),
- mModel(model),
- mSkin(nullptr),
- mSelected(-1),
- mPadding(2),
- mBoxWidth(80),
- mBoxHeight(70),
- mIconXOffset(24),
- mIconYOffset(10),
- mTextXOffset(0),
- mTextYOffset(44),
- mSkillClicked(false)
- {
- if (theme != nullptr)
- {
- mSkin = theme->load("skillrectanglelistbox.xml",
- "listbox.xml");
- }
-
- if (mSkin != nullptr)
- {
- mPadding = mSkin->getPadding();
- mBoxWidth = mSkin->getOption("boxWidth", 80);
- mBoxHeight = mSkin->getOption("boxHeight", 70);
- mIconXOffset = mSkin->getOption("iconXOffset", 24);
- mIconYOffset = mSkin->getOption("iconYOffset", 10);
- mTextXOffset = mSkin->getOption("textXOffset", 0);
- mTextYOffset = mSkin->getOption("textYOffset", 44);
- }
- Font *const font = getFont();
- int minWidth = font->getWidth("Lvl: 10/10") + mTextXOffset + 2;
- int minHeight = font->getHeight() + mTextYOffset + 2;
- if (mBoxWidth < minWidth)
- mBoxWidth = minWidth;
- if (mBoxHeight < minHeight)
- mBoxHeight = minHeight;
- int maxX = 0;
- int maxY = 0;
- for (int i = 0;
- i < model->getNumberOfElements();
- ++i)
- {
- SkillInfo *const e = model->getSkillAt(i);
- if (e != nullptr)
- {
- if (e->x > maxX)
- maxX = e->x;
- if (e->y > maxY)
- maxY = e->y;
- }
- }
- maxX ++;
- maxY ++;
- setWidth(maxX * mBoxWidth);
- setHeight(maxY * mBoxHeight);
- addMouseListener(this);
- }
-
- A_DELETE_COPY(SkillRectangleListBox)
-
- ~SkillRectangleListBox()
- {
- delete2(mModel)
- }
-
- SkillInfo *getSelectedInfo() const
- {
- if (mModel == nullptr)
- return nullptr;
- const int selected = mSelected;
- if (selected < 0 ||
- selected > mModel->getNumberOfElements())
- {
- return nullptr;
- }
-
- return mModel->getSkillAt(selected);
- }
-
- void draw(Graphics *const graphics) override final A_NONNULL(2)
- {
- if (mModel == nullptr)
- return;
-
- SkillModel *const model = mModel;
- updateAlpha();
-
- int maxX = 0;
- int maxY = 0;
- mHighlightColor.a = CAST_S32(mAlpha * 255.0F);
- graphics->setColor(mHighlightColor);
- Font *const font = getFont();
- if (mSelected >= 0)
- {
- SkillInfo *const e = model->getSkillAt(mSelected);
- if (e != nullptr)
- {
- const int x = e->x * mBoxWidth + mPadding;
- const int y = e->y * mBoxHeight + mPadding;
-
- graphics->fillRectangle(Rect(x, y,
- mBoxWidth, mBoxHeight));
-
- const int xOffset = (mBoxWidth -
- font->getWidth(e->skillLevel)) / 2;
- font->drawString(graphics,
- mForegroundSelectedColor,
- mForegroundSelectedColor,
- e->skillLevel,
- x + mTextXOffset + xOffset,
- y + mTextYOffset);
- }
- }
-
- // +++ need split drawing icons and text
- for (int i = 0;
- i < model->getNumberOfElements();
- ++i)
- {
- SkillInfo *const e = model->getSkillAt(i);
- if (e != nullptr)
- {
- if (e->x > maxX)
- maxX = e->x;
- if (e->y > maxY)
- maxY = e->y;
- const SkillData *const data = e->data;
- const int x = e->x * mBoxWidth + mPadding;
- const int y = e->y * mBoxHeight + mPadding;
-
- graphics->drawImage(data->icon,
- x + mIconXOffset,
- y + mIconYOffset);
-
- if (i != mSelected)
- {
- const int width1 = font->getWidth(e->skillLevel);
- const int xOffset = (mBoxWidth -
- width1) / 2;
- font->drawString(graphics,
- mTextColor,
- mTextColor2,
- e->skillLevel,
- x + mTextXOffset + xOffset,
- y + mTextYOffset);
- if (e->skillLevelWidth < 0)
- {
- // Add one for padding
- e->skillLevelWidth = width1 + 1;
- }
- }
- else
- {
- if (e->skillLevelWidth < 0)
- {
- // Add one for padding
- e->skillLevelWidth = font->getWidth(
- e->skillLevel) + 1;
- }
- }
- }
- }
- maxX ++;
- maxY ++;
- setWidth(maxX * mBoxWidth);
- setHeight(maxY * mBoxHeight);
- }
-
- void safeDraw(Graphics *const graphics) override final A_NONNULL(2)
- {
- SkillRectangleListBox::draw(graphics);
- }
-
- const SkillInfo *getSkillByEvent(const MouseEvent &event) const
- {
- if (mModel == nullptr)
- return nullptr;
- const int posX = (event.getX() - mPadding) / mBoxWidth;
- const int posY = (event.getY() - mPadding) / mBoxHeight;
- for (int i = 0;
- i < mModel->getNumberOfElements();
- ++i)
- {
- SkillInfo *const e = mModel->getSkillAt(i);
- if (e != nullptr)
- {
- if (posX == e->x && posY == e->y)
- return e;
- }
- }
- return nullptr;
- }
-
- int getSelectionByEvent(const MouseEvent &event) const
- {
- if (mModel == nullptr)
- return -1;
- const int posX = (event.getX() - mPadding) / mBoxWidth;
- const int posY = (event.getY() - mPadding) / mBoxHeight;
- for (int i = 0;
- i < mModel->getNumberOfElements();
- ++i)
- {
- SkillInfo *const e = mModel->getSkillAt(i);
- if (e != nullptr)
- {
- if (posX == e->x && posY == e->y)
- return i;
- }
- }
- return -1;
- }
-
- void mouseMoved(MouseEvent &event) override final
- {
- if ((viewport == nullptr) || !dragDrop.isEmpty())
- return;
-
- const SkillInfo *const skill = getSkillByEvent(event);
- if (skill == nullptr)
- return;
- skillPopup->show(skill,
- skill->customSelectedLevel,
- skill->customCastType,
- skill->customOffsetX,
- skill->customOffsetY);
- skillPopup->position(viewport->mMouseX,
- viewport->mMouseY);
- }
-
- void mouseDragged(MouseEvent &event) override final
- {
- if (event.getButton() != MouseButton::LEFT)
- return;
- setSelected(std::max(0, getSelectionByEvent(event)));
-
- if (dragDrop.isEmpty())
- {
- if (mSkillClicked)
- {
- mSkillClicked = false;
- const SkillInfo *const skill = getSkillByEvent(event);
- if (skill == nullptr)
- return;
- dragDrop.dragSkill(skill, DragDropSource::Skills);
- dragDrop.setItem(skill->id + SKILL_MIN_ID);
- dragDrop.setItemData(skill->toDataStr());
- }
- }
- }
-
- void mousePressed(MouseEvent &event) override final
- {
- const MouseButtonT button = event.getButton();
- if (button == MouseButton::LEFT ||
- button == MouseButton::RIGHT)
- {
- const SkillInfo *const skill = getSkillByEvent(event);
- if (skill == nullptr)
- return;
- event.consume();
- mSkillClicked = true;
- SkillModel *const model = mModel;
- if ((model != nullptr) &&
- mSelected >= 0 &&
- model->getSkillAt(mSelected) == skill)
- {
- skillPopup->hide();
-
- const int x = skill->x * mBoxWidth + mPadding;
- const int y = skill->y * mBoxHeight + mPadding;
- Font *const font = getFont();
- const int height = font->getHeight();
- const int eventX = event.getX();
- const int eventY = event.getY() - mTextYOffset;
- if (button == MouseButton::LEFT)
- {
- if (eventX >= x + mTextXOffset &&
- eventX <= x + mBoxWidth - mTextXOffset &&
- eventY >= y &&
- eventY <= y + height)
- {
- popupMenu->showSkillLevelPopup(skill);
- }
- }
- else if (button == MouseButton::RIGHT)
- {
- popupMenu->showSkillPopup(skill);
- }
- }
- }
- }
-
- void mouseReleased(MouseEvent &event) override final
- {
- if (event.getButton() == MouseButton::LEFT)
- {
- setSelected(std::max(0, getSelectionByEvent(event)));
- distributeActionEvent();
- }
- }
-
- void mouseExited(MouseEvent &event A_UNUSED) override final
- {
- skillPopup->hide();
- }
-
- void updateAlpha()
- {
- const float alpha = std::max(settings.guiAlpha,
- theme->getMinimumOpacity());
-
- if (mAlpha != alpha)
- mAlpha = alpha;
- }
-
- void setSelected(const int selected)
- {
- if (mModel == nullptr)
- {
- mSelected = -1;
- }
- else
- {
- if (selected < 0)
- mSelected = -1;
- else if (selected >= mModel->getNumberOfElements())
- mSelected = mModel->getNumberOfElements() - 1;
- else
- mSelected = selected;
- }
- }
-
- private:
- Color mHighlightColor;
- Color mTextColor;
- Color mTextColor2;
- Color mCooldownColor;
- Color mForegroundSelectedColor;
- Color mForegroundSelectedColor2;
- SkillModel *mModel;
- Skin *mSkin;
- int mSelected;
- int mPadding;
- int mBoxWidth;
- int mBoxHeight;
- int mIconXOffset;
- int mIconYOffset;
- int mTextXOffset;
- int mTextYOffset;
- bool mSkillClicked;
- static float mAlpha;
-};
-
-float SkillRectangleListBox::mAlpha = 1.0;
-
-#endif // GUI_WIDGETS_SKILLRECTANGLELISTBOX_H
diff --git a/src/gui/widgets/slider.cpp b/src/gui/widgets/slider.cpp
deleted file mode 100644
index 0d25ad2c5..000000000
--- a/src/gui/widgets/slider.cpp
+++ /dev/null
@@ -1,517 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "gui/widgets/slider.h"
-
-#include "settings.h"
-
-#include "enums/gui/slidergrid.h"
-
-#include "gui/gui.h"
-
-#include "utils/delete2.h"
-
-#include "resources/imagerect.h"
-
-#include "resources/image/image.h"
-
-#include "render/graphics.h"
-
-#include "render/vertexes/imagecollection.h"
-
-#include "debug.h"
-
-ImageRect Slider::buttons[2];
-float Slider::mAlpha = 1.0;
-int Slider::mInstances = 0;
-
-static std::string const data[2] =
-{
- "slider.xml",
- "slider_highlighted.xml"
-};
-
-Slider::Slider(Widget2 *const widget,
- const double scaleEnd,
- const double stepLength) :
- Widget(widget),
- MouseListener(),
- KeyListener(),
- mValue(0),
- mStepLength(stepLength),
- mScaleStart(0),
- mScaleEnd(scaleEnd),
- mOrientation(Orientation::HORIZONTAL),
- mVertexes(new ImageCollection),
- mMarkerLength(10),
- mHasMouse(false)
-{
- init();
-}
-
-Slider::Slider(Widget2 *const widget,
- const double scaleStart,
- const double scaleEnd,
- const double stepLength) :
- Widget(widget),
- MouseListener(),
- KeyListener(),
- mValue(scaleStart),
- mStepLength(stepLength),
- mScaleStart(scaleStart),
- mScaleEnd(scaleEnd),
- mOrientation(Orientation::HORIZONTAL),
- mVertexes(new ImageCollection),
- mMarkerLength(10),
- mHasMouse(false)
-{
- init();
-}
-
-Slider::~Slider()
-{
- if (gui != nullptr)
- gui->removeDragged(this);
-
- delete2(mVertexes);
- mInstances--;
- if (mInstances == 0)
- {
- for (int mode = 0; mode < 2; mode ++)
- Theme::unloadRect(buttons[mode]);
- }
-}
-
-void Slider::init()
-{
- mAllowLogic = false;
- setFocusable(true);
- setFrameSize(1);
-
- addMouseListener(this);
- addKeyListener(this);
-
- setFrameSize(0);
-
- // Load resources
- if (mInstances == 0)
- {
- if (theme != nullptr)
- {
- for (int mode = 0; mode < 2; mode ++)
- theme->loadRect(buttons[mode], data[mode], "slider.xml", 0, 8);
- }
- updateAlpha();
- }
-
- mInstances++;
-
- if (buttons[0].grid[SliderGrid::HGRIP] != nullptr)
- setMarkerLength(buttons[0].grid[SliderGrid::HGRIP]->getWidth());
-}
-
-void Slider::updateAlpha()
-{
- const float alpha = std::max(settings.guiAlpha,
- theme->getMinimumOpacity());
-
- if (alpha != mAlpha)
- {
- mAlpha = alpha;
- for (int f = 0; f < 2; f ++)
- {
- for (int d = 0; d < SliderGrid::SLIDER_MAX; d ++)
- {
- if (buttons[f].grid[d] != nullptr)
- buttons[f].grid[d]->setAlpha(mAlpha);
- }
- }
- }
-}
-
-void Slider::draw(Graphics *const graphics)
-{
- BLOCK_START("Slider::draw")
- if ((buttons[0].grid[SliderGrid::HSTART] == nullptr) ||
- (buttons[1].grid[SliderGrid::HSTART] == nullptr) ||
- (buttons[0].grid[SliderGrid::HEND] == nullptr))
- {
- BLOCK_END("Slider::draw")
- return;
- }
-
- int w = getWidth();
- const int h = getHeight();
- const int y = mHasMouse ?
- (h - buttons[1].grid[SliderGrid::HSTART]->getHeight()) / 2 :
- (h - buttons[0].grid[SliderGrid::HSTART]->getHeight()) / 2;
-
- updateAlpha();
-
- if (mRedraw || graphics->getRedraw())
- {
- int x = 0;
- mRedraw = false;
- mVertexes->clear();
- if (!mHasMouse)
- {
- graphics->calcTileCollection(mVertexes,
- buttons[0].grid[SliderGrid::HSTART],
- x, y);
-
- const int width = buttons[0].grid[SliderGrid::HSTART]->getWidth();
- w -= width + buttons[0].grid[SliderGrid::HEND]->getWidth();
- x += width;
-
- if (buttons[0].grid[SliderGrid::HMID] != nullptr)
- {
- const Image *const hMid = buttons[0].grid[SliderGrid::HMID];
- graphics->calcPattern(mVertexes,
- hMid,
- x, y,
- w, hMid->getHeight());
- }
-
- x += w;
- graphics->calcTileCollection(mVertexes,
- buttons[0].grid[SliderGrid::HEND],
- x, y);
-
- const Image *const img = buttons[0].grid[SliderGrid::HGRIP];
- if (img != nullptr)
- {
- graphics->calcTileCollection(mVertexes,
- img,
- getMarkerPosition(),
- (mDimension.height - img->getHeight()) / 2);
- }
- }
- else
- {
- graphics->calcTileCollection(mVertexes,
- buttons[1].grid[SliderGrid::HSTART],
- x, y);
-
- const int width = buttons[1].grid[SliderGrid::HSTART]->getWidth();
- w -= width;
- if (buttons[1].grid[SliderGrid::HEND] != nullptr)
- w -= buttons[1].grid[SliderGrid::HEND]->getWidth();
- x += width;
-
- if (buttons[1].grid[SliderGrid::HMID] != nullptr)
- {
- const Image *const hMid = buttons[1].grid[SliderGrid::HMID];
- graphics->calcPattern(mVertexes,
- hMid,
- x, y,
- w, hMid->getHeight());
- }
-
- x += w;
- if (buttons[1].grid[SliderGrid::HEND] != nullptr)
- {
- graphics->calcTileCollection(mVertexes,
- buttons[1].grid[SliderGrid::HEND], x, y);
- }
-
- const Image *const img = buttons[1].grid[SliderGrid::HGRIP];
- if (img != nullptr)
- {
- graphics->calcTileCollection(mVertexes,
- img,
- getMarkerPosition(),
- (mDimension.height - img->getHeight()) / 2);
- }
- }
- graphics->finalize(mVertexes);
- }
- graphics->drawTileCollection(mVertexes);
-
- BLOCK_END("Slider::draw")
-}
-
-void Slider::safeDraw(Graphics *const graphics)
-{
- BLOCK_START("Slider::draw")
- if ((buttons[0].grid[SliderGrid::HSTART] == nullptr) ||
- (buttons[1].grid[SliderGrid::HSTART] == nullptr) ||
- (buttons[0].grid[SliderGrid::HEND] == nullptr))
- {
- BLOCK_END("Slider::draw")
- return;
- }
-
- int w = getWidth();
- const int h = getHeight();
- int x = 0;
- const int y = mHasMouse ?
- (h - buttons[1].grid[SliderGrid::HSTART]->getHeight()) / 2 :
- (h - buttons[0].grid[SliderGrid::HSTART]->getHeight()) / 2;
-
- updateAlpha();
-
- if (!mHasMouse)
- {
- graphics->drawImage(buttons[0].grid[SliderGrid::HSTART], x, y);
- const int width = buttons[0].grid[SliderGrid::HSTART]->getWidth();
- w -= width + buttons[0].grid[SliderGrid::HEND]->getWidth();
- x += width;
-
- if (buttons[0].grid[SliderGrid::HMID] != nullptr)
- {
- const Image *const hMid = buttons[0].grid[SliderGrid::HMID];
- graphics->drawPattern(hMid, x, y, w, hMid->getHeight());
- }
-
- x += w;
- graphics->drawImage(buttons[0].grid[SliderGrid::HEND], x, y);
-
- const Image *const img = buttons[0].grid[SliderGrid::HGRIP];
- if (img != nullptr)
- {
- graphics->drawImage(img, getMarkerPosition(),
- (mDimension.height - img->getHeight()) / 2);
- }
- }
- else
- {
- graphics->drawImage(buttons[1].grid[SliderGrid::HSTART], x, y);
-
- const int width = buttons[1].grid[SliderGrid::HSTART]->getWidth();
- w -= width;
- if (buttons[1].grid[SliderGrid::HEND] != nullptr)
- w -= buttons[1].grid[SliderGrid::HEND]->getWidth();
- x += width;
-
- if (buttons[1].grid[SliderGrid::HMID] != nullptr)
- {
- const Image *const hMid = buttons[1].grid[SliderGrid::HMID];
- graphics->drawPattern(hMid, x, y, w, hMid->getHeight());
- }
-
- x += w;
- if (buttons[1].grid[SliderGrid::HEND] != nullptr)
- graphics->drawImage(buttons[1].grid[SliderGrid::HEND], x, y);
-
- const Image *const img = buttons[1].grid[SliderGrid::HGRIP];
- if (img != nullptr)
- {
- graphics->drawImage(img, getMarkerPosition(),
- (mDimension.height - img->getHeight()) / 2);
- }
- }
-
- BLOCK_END("Slider::draw")
-}
-
-void Slider::mouseEntered(MouseEvent& event A_UNUSED)
-{
- mHasMouse = true;
- mRedraw = true;
-}
-
-void Slider::mouseExited(MouseEvent& event A_UNUSED)
-{
- mHasMouse = false;
- mRedraw = true;
-}
-
-void Slider::mousePressed(MouseEvent &event)
-{
- const int x = event.getX();
- const int y = event.getY();
- const int width = mDimension.width;
- const int height = mDimension.height;
-
- if (event.getButton() == MouseButton::LEFT
- && x >= 0 && x <= width && y >= 0 && y <= height)
- {
- event.consume();
- if (mOrientation == Orientation::HORIZONTAL)
- setValue(markerPositionToValue(x - mMarkerLength / 2));
- else
- setValue(markerPositionToValue(height - y - mMarkerLength / 2));
- distributeActionEvent();
- }
-}
-
-void Slider::mouseDragged(MouseEvent &event)
-{
- if (mOrientation == Orientation::HORIZONTAL)
- {
- setValue(markerPositionToValue(event.getX() - mMarkerLength / 2));
- }
- else
- {
- setValue(markerPositionToValue(
- mDimension.height - event.getY() - mMarkerLength / 2));
- }
-
- distributeActionEvent();
-
- event.consume();
-}
-
-void Slider::mouseWheelMovedUp(MouseEvent &event)
-{
- setValue(mValue + mStepLength);
- distributeActionEvent();
- event.consume();
-}
-
-void Slider::mouseWheelMovedDown(MouseEvent &event)
-{
- setValue(mValue - mStepLength);
- distributeActionEvent();
- event.consume();
-}
-
-void Slider::keyPressed(KeyEvent& event)
-{
- const InputActionT action = event.getActionId();
-
- if (mOrientation == Orientation::HORIZONTAL)
- {
- if (action == InputAction::GUI_RIGHT)
- {
- setValue(mValue + mStepLength);
- distributeActionEvent();
- event.consume();
- }
- else if (action == InputAction::GUI_LEFT)
- {
- setValue(mValue - mStepLength);
- distributeActionEvent();
- event.consume();
- }
- }
- else
- {
- if (action == InputAction::GUI_UP)
- {
- setValue(mValue + mStepLength);
- distributeActionEvent();
- event.consume();
- }
- else if (action == InputAction::GUI_DOWN)
- {
- setValue(mValue - mStepLength);
- distributeActionEvent();
- event.consume();
- }
- }
-}
-
-void Slider::setScale(const double scaleStart, const double scaleEnd)
-{
- mScaleStart = scaleStart;
- mScaleEnd = scaleEnd;
-}
-
-void Slider::setValue(const double value)
-{
- mRedraw = true;
- if (value > mScaleEnd)
- mValue = mScaleEnd;
- else if (value < mScaleStart)
- mValue = mScaleStart;
- else
- mValue = value;
- mValue = CAST_S32((mValue - mScaleStart) / mStepLength)
- * mStepLength + mScaleStart;
-}
-
-double Slider::markerPositionToValue(const int v) const
-{
- int w;
- if (mOrientation == Orientation::HORIZONTAL)
- w = mDimension.width;
- else
- w = mDimension.height;
-
- const double pos = v / (static_cast<double>(w) - mMarkerLength);
- return (1.0 - pos) * mScaleStart + pos * mScaleEnd;
-}
-
-int Slider::valueToMarkerPosition(const double value) const
-{
- int v;
- if (mOrientation == Orientation::HORIZONTAL)
- v = mDimension.width;
- else
- v = mDimension.height;
-
- const int w = CAST_S32((v - mMarkerLength)
- * (value - mScaleStart)
- / (mScaleEnd - mScaleStart));
-
- if (w < 0)
- return 0;
-
- if (w > v - mMarkerLength)
- return v - mMarkerLength;
-
- return w;
-}
diff --git a/src/gui/widgets/slider.h b/src/gui/widgets/slider.h
deleted file mode 100644
index 49acafc28..000000000
--- a/src/gui/widgets/slider.h
+++ /dev/null
@@ -1,337 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GUI_WIDGETS_SLIDER_H
-#define GUI_WIDGETS_SLIDER_H
-
-#include "enums/gui/orientation.h"
-
-#include "listeners/keylistener.h"
-#include "listeners/mouselistener.h"
-
-#include "gui/widgets/widget.h"
-
-#include "localconsts.h"
-
-class ImageCollection;
-
-/**
- * Slider widget. Same as the Guichan slider but with custom look.
- *
- * \ingroup GUI
- */
-class Slider final : public Widget,
- public MouseListener,
- public KeyListener
-{
- public:
- /**
- * Constructor with scale start equal to 0.
- */
- Slider(Widget2 *const widget,
- const double scaleEnd,
- const double stepLength);
-
- /**
- * Constructor.
- */
- Slider(Widget2 *const widget,
- const double scaleStart,
- const double scaleEnd,
- const double stepLength);
-
- A_DELETE_COPY(Slider)
-
- /**
- * Destructor.
- */
- ~Slider();
-
- /**
- * Update the alpha value to the graphic components.
- */
- void updateAlpha();
-
- /**
- * Draws the slider.
- */
- void draw(Graphics *const graphics) override final A_NONNULL(2);
-
- void safeDraw(Graphics *const graphics) override final A_NONNULL(2);
-
- /**
- * Called when the mouse enteres the widget area.
- */
- void mouseEntered(MouseEvent& event) override final;
-
- /**
- * Called when the mouse leaves the widget area.
- */
- void mouseExited(MouseEvent& event) override final;
-
- void mousePressed(MouseEvent &event) override final;
-
- void mouseDragged(MouseEvent &event) override final;
-
- void mouseWheelMovedUp(MouseEvent &event) override final;
-
- void mouseWheelMovedDown(MouseEvent &event) override final;
-
- void keyPressed(KeyEvent& event) override final;
-
- /**
- * Sets the scale of the slider.
- *
- * @param scaleStart The start value of the scale.
- * @param scaleEnd tThe end of value the scale.
- * @see getScaleStart, getScaleEnd
- */
- void setScale(const double scaleStart, const double scaleEnd);
-
- /**
- * Gets the start value of the scale.
- *
- * @return The start value of the scale.
- * @see setScaleStart, setScale
- */
- double getScaleStart() const
- { return mScaleStart; }
-
- /**
- * Sets the start value of the scale.
- *
- * @param scaleStart The start value of the scale.
- * @see getScaleStart
- */
- void setScaleStart(const double scaleStart)
- { mScaleStart = scaleStart; }
-
- /**
- * Gets the end value of the scale.
- *
- * @return The end value of the scale.
- * @see setScaleEnd, setScale
- */
- double getScaleEnd() const
- { return mScaleEnd; }
-
- /**
- * Sets the end value of the scale.
- *
- * @param scaleEnd The end value of the scale.
- * @see getScaleEnd
- */
- void setScaleEnd(const double scaleEnd)
- { mScaleEnd = scaleEnd; }
-
- /**
- * Sets the current selected value.
- *
- * @param value The current selected value.
- * @see getValue
- */
- void setValue(const double value);
-
- /**
- * Gets the current selected value.
- *
- * @return The current selected value.
- * @see setValue
- */
- double getValue() const
- { return mValue; }
-
- /**
- * Gets the length of the marker.
- *
- * @return The length of the marker.
- * @see setMarkerLength
- */
- int getMarkerLength() const
- { return mMarkerLength; }
-
- /**
- * Sets the length of the marker.
- *
- * @param length The length for the marker.
- * @see getMarkerLength
- */
- void setMarkerLength(const int length)
- { mMarkerLength = length; }
-
- /**
- * Sets the orientation of the slider. A slider can be drawn vertically
- * or horizontally.
- *
- * @param orientation The orientation of the slider.
- * @see getOrientation
- */
- void setOrientation(const OrientationT orientation)
- { mOrientation = orientation; }
-
- /**
- * Gets the orientation of the slider. A slider can be drawn vertically
- * or horizontally.
- *
- * @return The orientation of the slider.
- * @see setOrientation
- */
- OrientationT getOrientation() const
- { return mOrientation; }
-
- /**
- * Sets the step length. The step length is used when the keys LEFT
- * and RIGHT are pressed to step in the scale.
- *
- * @param length The step length.
- * @see getStepLength
- */
- void setStepLength(const double length)
- { mStepLength = length; }
-
- /**
- * Gets the step length. The step length is used when the keys LEFT
- * and RIGHT are pressed to step in the scale.
- *
- * @return the step length.
- * @see setStepLength
- */
- double getStepLength() const
- { return mStepLength; }
-
- private:
- /**
- * Used to initialize instances.
- */
- void init();
-
- /**
- * Converts a marker position to a value in the scale.
- *
- * @param position The position to convert.
- * @return A scale value corresponding to the position.
- * @see valueToMarkerPosition
- */
- double markerPositionToValue(const int position) const;
-
- /**
- * Converts a value to a marker position.
- *
- * @param value The value to convert.
- * @return A marker position corresponding to the value.
- * @see markerPositionToValue
- */
- int valueToMarkerPosition(const double value) const;
-
- /**
- * Gets the marker position of the current selected value.
- *
- * @return The marker position of the current selected value.
- */
- int getMarkerPosition() const
- { return valueToMarkerPosition(getValue()); }
-
- static ImageRect buttons[2];
- static float mAlpha;
- static int mInstances;
-
- /**
- * Holds the current selected value.
- */
- double mValue;
-
- /**
- * Holds the step length. The step length is used when the keys LEFT
- * and RIGHT are pressed to step in the scale.
- */
- double mStepLength;
-
- /**
- * Holds the start value of the scale.
- */
- double mScaleStart;
-
- /**
- * Holds the end value of the scale.
- */
- double mScaleEnd;
-
- /**
- * Holds the orientation of the slider. A slider can be drawn
- * vertically or horizontally.
- */
- OrientationT mOrientation;
-
- ImageCollection *mVertexes A_NONNULLPOINTER;
-
- /**
- * Holds the length of the marker.
- */
- int mMarkerLength;
-
- bool mHasMouse;
-};
-
-#endif // GUI_WIDGETS_SLIDER_H
diff --git a/src/gui/widgets/sliderlist.cpp b/src/gui/widgets/sliderlist.cpp
deleted file mode 100644
index edce0cf02..000000000
--- a/src/gui/widgets/sliderlist.cpp
+++ /dev/null
@@ -1,240 +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 "gui/widgets/sliderlist.h"
-
-#include "gui/gui.h"
-
-#include "gui/fonts/font.h"
-
-#include "gui/models/listmodel.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/label.h"
-
-#include "debug.h"
-
-static const int buttonWidth = 27;
-static const int buttonSpace = 30;
-static const int sliderHeight = 30;
-
-SliderList::SliderList(const Widget2 *const widget,
- ListModel *const listModel) :
- Container(widget),
- ActionListener(),
- MouseListener(),
- mButtons(),
- mLabel(new Label(this)),
- mListModel(listModel),
- mPrevEventId(),
- mNextEventId(),
- mOldWidth(0),
- mSelectedIndex(0)
-{
- mAllowLogic = false;
- setHeight(sliderHeight);
-}
-
-void SliderList::postInit2(ActionListener *const listener,
- const std::string &eventId)
-{
- mPrevEventId = eventId + "_prev";
- mNextEventId = eventId + "_next";
-
- mButtons[0] = new Button(this, "<", mPrevEventId, this);
- mButtons[1] = new Button(this, ">", mNextEventId, this);
-
- add(mButtons[0]);
- add(mLabel);
- add(mButtons[1]);
-
- if (!eventId.empty())
- setActionEventId(eventId);
-
- if (listener != nullptr)
- addActionListener(listener);
-
- updateLabel();
- addMouseListener(this);
-}
-
-SliderList::~SliderList()
-{
-}
-
-void SliderList::updateAlpha()
-{
- Button::updateAlpha();
-}
-
-void SliderList::mouseWheelMovedUp(MouseEvent& event)
-{
- setSelected(mSelectedIndex - 1);
- event.consume();
-}
-
-void SliderList::mouseWheelMovedDown(MouseEvent& event)
-{
- setSelected(mSelectedIndex + 1);
- event.consume();
-}
-
-void SliderList::resize()
-{
- const int width = getWidth();
-
- mButtons[0]->setWidth(buttonWidth);
- mLabel->setWidth(width - buttonSpace * 2);
- mButtons[1]->setPosition(width - buttonSpace + 3, 0);
- mButtons[1]->setWidth(buttonWidth);
- updateLabel();
-}
-
-void SliderList::draw(Graphics *const graphics)
-{
- BLOCK_START("SliderList::draw")
- const int width = mDimension.width;
- if (mOldWidth != width)
- {
- resize();
- mOldWidth = width;
- }
- Container::draw(graphics);
- BLOCK_END("SliderList::draw")
-}
-
-void SliderList::safeDraw(Graphics *const graphics)
-{
- BLOCK_START("SliderList::draw")
- const int width = mDimension.width;
- if (mOldWidth != width)
- {
- resize();
- mOldWidth = width;
- }
- Container::draw(graphics);
- BLOCK_END("SliderList::draw")
-}
-
-void SliderList::updateLabel()
-{
- if ((mListModel == nullptr) || mSelectedIndex < 0
- || mSelectedIndex >= mListModel->getNumberOfElements())
- {
- return;
- }
-
- mLabel->setCaption(mListModel->getElementAt(mSelectedIndex));
- mLabel->adjustSize();
- const int space = mDimension.width - buttonSpace * 2;
- const int labelWidth = mLabel->getWidth();
- int labelY = (mDimension.height - mLabel->getHeight()) / 2;
- if (labelY < 0)
- labelY = 0;
-
- if (space < 0 || space < labelWidth)
- mLabel->setPosition(buttonSpace, labelY);
- else
- mLabel->setPosition(buttonSpace + (space - labelWidth) / 2, labelY);
-}
-
-void SliderList::action(const ActionEvent &event)
-{
- if (mListModel == nullptr)
- return;
-
- const std::string &eventId = event.getId();
- if (eventId == mPrevEventId)
- {
- mSelectedIndex --;
- if (mSelectedIndex < 0)
- mSelectedIndex = mListModel->getNumberOfElements() - 1;
- }
- else if (eventId == mNextEventId)
- {
- mSelectedIndex ++;
- if (mSelectedIndex >= mListModel->getNumberOfElements())
- mSelectedIndex = 0;
- }
- updateLabel();
- distributeActionEvent();
-}
-
-void SliderList::setSelectedString(const std::string &str)
-{
- if (mListModel == nullptr)
- return;
-
- for (int f = 0; f < mListModel->getNumberOfElements(); f ++)
- {
- if (mListModel->getElementAt(f) == str)
- {
- setSelected(f);
- break;
- }
- }
-}
-
-std::string SliderList::getSelectedString() const
-{
- if (mListModel == nullptr)
- return std::string();
-
- return mListModel->getElementAt(mSelectedIndex);
-}
-
-void SliderList::setSelected(const int idx)
-{
- if (mListModel == nullptr)
- return;
-
- mSelectedIndex = idx;
- const int num = mListModel->getNumberOfElements();
- if (mSelectedIndex >= num)
- mSelectedIndex = 0;
- if (mSelectedIndex < 0)
- mSelectedIndex = num - 1;
- updateLabel();
-}
-
-void SliderList::adjustSize()
-{
- setWidth(getMaxLabelWidth() + 60);
- updateLabel();
-}
-
-int SliderList::getMaxLabelWidth() const
-{
- if ((mListModel == nullptr) || (gui == nullptr))
- return 1;
-
- int maxWidth = 0;
- const Font *const font = getFont();
-
- const int num = mListModel->getNumberOfElements();
- for (int f = 0; f < num; f ++)
- {
- const int w = font->getWidth(mListModel->getElementAt(f));
- if (w > maxWidth)
- maxWidth = w;
- }
-
- return maxWidth;
-}
diff --git a/src/gui/widgets/sliderlist.h b/src/gui/widgets/sliderlist.h
deleted file mode 100644
index 6f4336531..000000000
--- a/src/gui/widgets/sliderlist.h
+++ /dev/null
@@ -1,89 +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 GUI_WIDGETS_SLIDERLIST_H
-#define GUI_WIDGETS_SLIDERLIST_H
-
-#include "listeners/actionlistener.h"
-#include "listeners/mouselistener.h"
-
-#include "gui/widgets/container.h"
-
-#include "localconsts.h"
-
-class Button;
-class Label;
-class ListModel;
-
-class SliderList final : public Container,
- public ActionListener,
- public MouseListener
-{
- public:
- SliderList(const Widget2 *const widget,
- ListModel *const listModel);
-
- A_DELETE_COPY(SliderList)
-
- ~SliderList();
-
- void postInit2(ActionListener *const listener,
- const std::string &eventId);
-
- void updateAlpha();
-
- void mouseWheelMovedUp(MouseEvent& event) override final;
-
- void mouseWheelMovedDown(MouseEvent& event) override final;
-
- void resize();
-
- void draw(Graphics *const graphics) override final A_NONNULL(2);
-
- void safeDraw(Graphics *const graphics) override final A_NONNULL(2);
-
- void action(const ActionEvent &event) override final;
-
- void setSelectedString(const std::string &str);
-
- std::string getSelectedString() const A_WARN_UNUSED;
-
- void setSelected(const int idx);
-
- void adjustSize();
-
- int getSelected() const noexcept2 A_WARN_UNUSED
- { return mSelectedIndex; }
-
- protected:
- void updateLabel();
-
- int getMaxLabelWidth() const A_WARN_UNUSED;
-
- Button *mButtons[2] A_NONNULLPOINTER;
- Label *mLabel A_NONNULLPOINTER;
- ListModel *mListModel;
- std::string mPrevEventId;
- std::string mNextEventId;
- int mOldWidth;
- int mSelectedIndex;
-};
-
-#endif // GUI_WIDGETS_SLIDERLIST_H
diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp
deleted file mode 100644
index ffa23ffa1..000000000
--- a/src/gui/widgets/spellshortcutcontainer.cpp
+++ /dev/null
@@ -1,371 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 Andrei Karas
- * 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 "gui/widgets/spellshortcutcontainer.h"
-
-#include "dragdrop.h"
-#include "settings.h"
-#include "spellmanager.h"
-
-#include "gui/viewport.h"
-
-#include "gui/fonts/font.h"
-
-#include "gui/shortcut/itemshortcut.h"
-#include "gui/shortcut/spellshortcut.h"
-
-#include "gui/popups/popupmenu.h"
-#include "gui/popups/spellpopup.h"
-
-#include "gui/windows/shortcutwindow.h"
-
-#include "debug.h"
-
-SpellShortcutContainer::SpellShortcutContainer(Widget2 *const widget,
- const unsigned number) :
- ShortcutContainer(widget),
- mNumber(number),
- mSpellClicked(false)
-{
- if (spellShortcut != nullptr)
- mMaxItems = spellShortcut->getSpellsCount();
- else
- mMaxItems = 0;
-}
-
-SpellShortcutContainer::~SpellShortcutContainer()
-{
-}
-
-void SpellShortcutContainer::setWidget2(const Widget2 *const widget)
-{
- Widget2::setWidget2(widget);
- mForegroundColor = getThemeColor(ThemeColorId::TEXT);
- mForegroundColor2 = getThemeColor(ThemeColorId::TEXT_OUTLINE);
-}
-
-void SpellShortcutContainer::draw(Graphics *const graphics)
-{
- if (spellShortcut == nullptr)
- return;
-
- BLOCK_START("SpellShortcutContainer::draw")
- if (settings.guiAlpha != mAlpha)
- {
- mAlpha = settings.guiAlpha;
- if (mBackgroundImg != nullptr)
- mBackgroundImg->setAlpha(mAlpha);
- }
-
- Font *const font = getFont();
-
- const int selectedId = spellShortcut->getSelectedItem();
- graphics->setColor(mForegroundColor);
- drawBackground(graphics);
-
- // +++ in future need reorder images and string drawing.
- for (unsigned i = 0; i < mMaxItems; i++)
- {
- const int itemX = (i % mGridWidth) * mBoxWidth;
- const int itemY = (i / mGridWidth) * mBoxHeight;
-
- const int itemId = getItemByIndex(i);
- if (selectedId >= 0 && itemId == selectedId)
- {
- graphics->drawRectangle(Rect(itemX + 1, itemY + 1,
- mBoxWidth - 1, mBoxHeight - 1));
- }
-
- if (spellManager == nullptr)
- continue;
-
- const TextCommand *const spell = spellManager->getSpell(itemId);
- if (spell != nullptr)
- {
- if (!spell->isEmpty())
- {
- Image *const image = spell->getImage();
-
- if (image != nullptr)
- {
- image->setAlpha(1.0F);
- graphics->drawImage(image, itemX, itemY);
- }
- }
-
- font->drawString(graphics,
- mForegroundColor,
- mForegroundColor2,
- spell->getSymbol(),
- itemX + 2, itemY + mBoxHeight / 2);
- }
- }
-
- BLOCK_END("SpellShortcutContainer::draw")
-}
-
-void SpellShortcutContainer::safeDraw(Graphics *const graphics)
-{
- if (spellShortcut == nullptr)
- return;
-
- BLOCK_START("SpellShortcutContainer::draw")
- if (settings.guiAlpha != mAlpha)
- {
- mAlpha = settings.guiAlpha;
- if (mBackgroundImg != nullptr)
- mBackgroundImg->setAlpha(mAlpha);
- }
-
- Font *const font = getFont();
-
- const int selectedId = spellShortcut->getSelectedItem();
- graphics->setColor(mForegroundColor);
- safeDrawBackground(graphics);
-
- // +++ in future need reorder images and string drawing.
- for (unsigned i = 0; i < mMaxItems; i++)
- {
- const int itemX = (i % mGridWidth) * mBoxWidth;
- const int itemY = (i / mGridWidth) * mBoxHeight;
-
- const int itemId = getItemByIndex(i);
- if (selectedId >= 0 && itemId == selectedId)
- {
- graphics->drawRectangle(Rect(itemX + 1, itemY + 1,
- mBoxWidth - 1, mBoxHeight - 1));
- }
-
- if (spellManager == nullptr)
- continue;
-
- const TextCommand *const spell = spellManager->getSpell(itemId);
- if (spell != nullptr)
- {
- if (!spell->isEmpty())
- {
- Image *const image = spell->getImage();
-
- if (image != nullptr)
- {
- image->setAlpha(1.0F);
- graphics->drawImage(image, itemX, itemY);
- }
- }
-
- font->drawString(graphics,
- mForegroundColor,
- mForegroundColor2,
- spell->getSymbol(),
- itemX + 2, itemY + mBoxHeight / 2);
- }
- }
-
- BLOCK_END("SpellShortcutContainer::draw")
-}
-
-void SpellShortcutContainer::mouseDragged(MouseEvent &event)
-{
- if (event.getButton() == MouseButton::LEFT)
- {
- if (dragDrop.isEmpty() && mSpellClicked)
- {
- mSpellClicked = false;
- const int index = getIndexFromGrid(event.getX(), event.getY());
-
- if (index == -1)
- return;
-
- const int itemId = getItemByIndex(index);
- if (itemId < 0)
- return;
- event.consume();
- TextCommand *const spell = spellManager->getSpell(itemId);
- if (spell != nullptr)
- {
- dragDrop.dragCommand(spell, DragDropSource::Spells, index);
- dragDrop.setItem(spell->getId() + SPELL_MIN_ID);
- }
- else
- {
- dragDrop.clear();
- mSpellClicked = false;
- }
- }
- }
-}
-
-void SpellShortcutContainer::mousePressed(MouseEvent &event)
-{
- const int index = getIndexFromGrid(event.getX(), event.getY());
-
- if (index == -1)
- return;
-
- const MouseButtonT eventButton = event.getButton();
- if (eventButton == MouseButton::LEFT)
- {
- const int itemId = getItemByIndex(index);
- if (itemId > 0)
- mSpellClicked = true;
- event.consume();
- }
- else if (eventButton == MouseButton::MIDDLE)
- {
- if ((spellShortcut == nullptr) || (spellManager == nullptr))
- return;
-
- event.consume();
- const int itemId = getItemByIndex(index);
- spellManager->invoke(itemId);
- }
-}
-
-void SpellShortcutContainer::mouseReleased(MouseEvent &event)
-{
- if ((spellShortcut == nullptr) || (spellManager == nullptr))
- return;
-
- const int index = getIndexFromGrid(event.getX(), event.getY());
-
- if (index == -1)
- {
- dragDrop.clear();
- return;
- }
-
- const int itemId = getItemByIndex(index);
- const MouseButtonT eventButton = event.getButton();
-
- if (eventButton == MouseButton::LEFT)
- {
- mSpellClicked = false;
-
- if (itemId < 0)
- return;
-
- const int selectedId = spellShortcut->getSelectedItem();
- event.consume();
-
- if (!dragDrop.isEmpty())
- {
- if (dragDrop.getSource() == DragDropSource::Spells)
- {
- const int oldIndex = dragDrop.getTag();
- const int idx = mNumber * SPELL_SHORTCUT_ITEMS;
- spellManager->swap(idx + index, idx + oldIndex);
- spellManager->save();
- dragDrop.clear();
- dragDrop.deselect();
- }
- }
- else
- {
- if (selectedId != itemId)
- {
- const TextCommand *const
- spell = spellManager->getSpell(itemId);
- if ((spell != nullptr) && !spell->isEmpty())
- {
- const int num = itemShortcutWindow->getTabIndex();
- if (num >= 0 && num < CAST_S32(SHORTCUT_TABS)
- && (itemShortcut[num] != nullptr))
- {
- itemShortcut[num]->setItemSelected(
- spell->getId() + SPELL_MIN_ID);
- }
- spellShortcut->setItemSelected(spell->getId());
- }
- }
- else
- {
- const int num = itemShortcutWindow->getTabIndex();
- if (num >= 0 && num < CAST_S32(SHORTCUT_TABS)
- && (itemShortcut[num] != nullptr))
- {
- itemShortcut[num]->setItemSelected(-1);
- }
- spellShortcut->setItemSelected(-1);
- }
- }
- }
- else if (eventButton == MouseButton::RIGHT)
- {
- TextCommand *spell = nullptr;
- if (itemId >= 0)
- spell = spellManager->getSpell(itemId);
-
- if ((spell != nullptr) && (popupMenu != nullptr))
- {
- popupMenu->showSpellPopup(viewport->mMouseX,
- viewport->mMouseY,
- spell);
- }
- }
-}
-
-// Show ItemTooltip
-void SpellShortcutContainer::mouseMoved(MouseEvent &event)
-{
- if (spellPopup == nullptr ||
- spellShortcut == nullptr ||
- spellManager == nullptr)
- {
- return;
- }
-
- const int index = getIndexFromGrid(event.getX(), event.getY());
-
- if (index == -1)
- return;
-
- const int itemId = getItemByIndex(index);
- spellPopup->setVisible(Visible_false);
- const TextCommand *const spell = spellManager->getSpell(itemId);
- if ((spell != nullptr) && !spell->isEmpty())
- {
- spellPopup->setItem(spell);
- spellPopup->view(viewport->mMouseX, viewport->mMouseY);
- }
- else
- {
- spellPopup->setVisible(Visible_false);
- }
-}
-
-void SpellShortcutContainer::mouseExited(MouseEvent &event A_UNUSED)
-{
- if (spellPopup != nullptr)
- spellPopup->setVisible(Visible_false);
-}
-
-void SpellShortcutContainer::widgetHidden(const Event &event A_UNUSED)
-{
- if (spellPopup != nullptr)
- spellPopup->setVisible(Visible_false);
-}
-
-int SpellShortcutContainer::getItemByIndex(const int index) const
-{
- return spellShortcut->getItem(
- (mNumber * SPELL_SHORTCUT_ITEMS) + index);
-}
diff --git a/src/gui/widgets/spellshortcutcontainer.h b/src/gui/widgets/spellshortcutcontainer.h
deleted file mode 100644
index 872ca5e1a..000000000
--- a/src/gui/widgets/spellshortcutcontainer.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 Andrei Karas
- * 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_SPELLSHORTCUTCONTAINER_H
-#define GUI_WIDGETS_SPELLSHORTCUTCONTAINER_H
-
-#include "gui/widgets/shortcutcontainer.h"
-
-/**
- * An item shortcut container. Used to quickly use items.
- *
- * \ingroup GUI
- */
-class SpellShortcutContainer final : public ShortcutContainer
-{
- public:
- /**
- * Constructor. Initializes the graphic.
- */
- SpellShortcutContainer(Widget2 *const widget,
- const unsigned number);
-
- A_DELETE_COPY(SpellShortcutContainer)
-
- /**
- * Destructor.
- */
- ~SpellShortcutContainer();
-
- /**
- * Draws the items.
- */
- void draw(Graphics *const graphics) override final A_NONNULL(2);
-
- void safeDraw(Graphics *const graphics) override final A_NONNULL(2);
-
- /**
- * Handles mouse when dragged.
- */
- void mouseDragged(MouseEvent &event) override final;
-
- /**
- * Handles mouse when pressed.
- */
- void mousePressed(MouseEvent &event) override final;
-
- /**
- * Handles mouse release.
- */
- void mouseReleased(MouseEvent &event) override final;
-
- void widgetHidden(const Event &event) override final;
-
- void mouseExited(MouseEvent &event) override final;
-
- void mouseMoved(MouseEvent &event) override final;
-
- void setWidget2(const Widget2 *const widget) override final;
-
- int getItemByIndex(const int index) const A_WARN_UNUSED;
-
- private:
- unsigned int mNumber;
- bool mSpellClicked;
-};
-
-#endif // GUI_WIDGETS_SPELLSHORTCUTCONTAINER_H
diff --git a/src/gui/widgets/staticbrowserbox.cpp b/src/gui/widgets/staticbrowserbox.cpp
deleted file mode 100644
index de0d787a7..000000000
--- a/src/gui/widgets/staticbrowserbox.cpp
+++ /dev/null
@@ -1,781 +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
- * Copyright (C) 2009 Aethyra Development Team
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * 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 "gui/widgets/staticbrowserbox.h"
-
-#include "enums/gui/linkhighlightmode.h"
-
-#include "gui/gui.h"
-#include "gui/mouseoverlink.h"
-#include "gui/skin.h"
-
-#include "gui/fonts/font.h"
-
-#include "gui/widgets/browserbox.inc"
-#include "gui/widgets/linkhandler.h"
-
-#include "render/graphics.h"
-
-#include "resources/imageset.h"
-
-#include "resources/image/image.h"
-
-#include "resources/loaders/imageloader.h"
-#include "resources/loaders/imagesetloader.h"
-
-#include "utils/browserboxtools.h"
-#include "utils/checkutils.h"
-#include "utils/foreach.h"
-#include "utils/stdmove.h"
-#include "utils/stringutils.h"
-#include "utils/translation/podict.h"
-
-#include <algorithm>
-
-#include "debug.h"
-
-ImageSet *StaticBrowserBox::mEmotes = nullptr;
-int StaticBrowserBox::mInstances = 0;
-
-StaticBrowserBox::StaticBrowserBox(const Widget2 *const widget,
- const Opaque opaque,
- const std::string &skin) :
- Widget(widget),
- MouseListener(),
- mTextRows(),
- mTextRowLinksCount(),
- mLineParts(),
- mLinks(),
- mLinkHandler(nullptr),
- mSkin(nullptr),
- mHighlightMode(0),
- mSelectedLink(-1),
- mHeight(0),
- mWidth(0),
- mYStart(0),
- mPadding(0),
- mNewLinePadding(15U),
- mItemPadding(0),
- mHighlightColor(getThemeColor(ThemeColorId::HIGHLIGHT)),
- mHyperLinkColor(getThemeColor(ThemeColorId::HYPERLINK)),
- mOpaque(opaque),
- mUseLinksAndUserColors(true),
- mUseEmotes(true),
- mProcessVars(false),
- mEnableImages(false),
- mEnableKeys(false),
- mEnableTabs(false),
- mSeparator(false)
-{
- mAllowLogic = false;
-
- setFocusable(true);
- addMouseListener(this);
-
- mBackgroundColor = getThemeColor(ThemeColorId::BACKGROUND);
-
- if (theme != nullptr)
- mSkin = theme->load(skin, "browserbox.xml");
- if (mInstances == 0)
- {
- mEmotes = Loader::getImageSet(
- "graphics/sprites/chatemotes.png", 17, 18);
- }
- mInstances ++;
-
- if (mSkin != nullptr)
- {
- mPadding = mSkin->getPadding();
- mNewLinePadding = CAST_U32(
- mSkin->getOption("newLinePadding", 15));
- mItemPadding = mSkin->getOption("itemPadding");
- if (mSkin->getOption("highlightBackground") != 0)
- mHighlightMode |= LinkHighlightMode::BACKGROUND;
- if (mSkin->getOption("highlightUnderline") != 0)
- mHighlightMode |= LinkHighlightMode::UNDERLINE;
- }
-
- readColor(BLACK);
- readColor(RED);
- readColor(GREEN);
- readColor(BLUE);
- readColor(ORANGE);
- readColor(YELLOW);
- readColor(PINK);
- readColor(PURPLE);
- readColor(GRAY);
- readColor(BROWN);
-
- mForegroundColor = getThemeColor(ThemeColorId::BROWSERBOX);
- mForegroundColor2 = getThemeColor(ThemeColorId::BROWSERBOX_OUTLINE);
-}
-
-StaticBrowserBox::~StaticBrowserBox()
-{
- if (gui != nullptr)
- gui->removeDragged(this);
-
- if (theme != nullptr)
- {
- theme->unload(mSkin);
- mSkin = nullptr;
- }
-
- mInstances --;
- if (mInstances == 0)
- {
- if (mEmotes != nullptr)
- {
- mEmotes->decRef();
- mEmotes = nullptr;
- }
- }
-}
-
-void StaticBrowserBox::setLinkHandler(LinkHandler* linkHandler)
-{
- mLinkHandler = linkHandler;
-}
-
-void StaticBrowserBox::addSeparator(const std::string &row)
-{
- if (mSeparator)
- return;
- addRow(row, false);
- mSeparator = true;
-}
-
-void StaticBrowserBox::addRow(const std::string &row,
- const bool atTop)
-{
- std::string tmp = row;
- std::string newRow;
- size_t idx1;
- const Font *const font = getFont();
- int linksCount = 0;
-
- if (getWidth() < 0)
- return;
-
- mSeparator = false;
-
- if (mProcessVars)
- {
- BrowserBoxTools::replaceVars(tmp);
- }
-
- // Use links and user defined colors
- if (mUseLinksAndUserColors)
- {
- BrowserLink bLink;
-
- // Check for links in format "@@link|Caption@@"
- const uint32_t sz = CAST_U32(mTextRows.size());
-
- if (mEnableKeys)
- {
- BrowserBoxTools::replaceKeys(tmp);
- }
-
- idx1 = tmp.find("@@");
- while (idx1 != std::string::npos)
- {
- const size_t idx2 = tmp.find('|', idx1);
- const size_t idx3 = tmp.find("@@", idx2);
-
- if (idx2 == std::string::npos || idx3 == std::string::npos)
- break;
- bLink.link = tmp.substr(idx1 + 2, idx2 - (idx1 + 2));
- bLink.caption = tmp.substr(idx2 + 1, idx3 - (idx2 + 1));
- bLink.y1 = CAST_S32(sz) * font->getHeight();
- bLink.y2 = bLink.y1 + font->getHeight();
- if (bLink.caption.empty())
- {
- bLink.caption = BrowserBoxTools::replaceLinkCommands(
- bLink.link);
- if (translator != nullptr)
- bLink.caption = translator->getStr(bLink.caption);
- }
-
- newRow.append(tmp.substr(0, idx1));
-
- std::string tmp2 = newRow;
- idx1 = tmp2.find("##");
- while (idx1 != std::string::npos)
- {
- tmp2.erase(idx1, 3);
- idx1 = tmp2.find("##");
- }
- bLink.x1 = font->getWidth(tmp2) - 1;
- bLink.x2 = bLink.x1 + font->getWidth(bLink.caption) + 1;
-
- if (atTop)
- mLinks.insert(mLinks.begin(), bLink);
- else
- mLinks.push_back(bLink);
- linksCount ++;
-
- newRow.append("##<").append(bLink.caption);
-
- tmp.erase(0, idx3 + 2);
- if (!tmp.empty())
- newRow.append("##>");
-
- idx1 = tmp.find("@@");
- }
-
- newRow.append(tmp);
- }
- // Don't use links and user defined colors
- else
- {
- newRow = row;
- }
-
- if (mEnableTabs)
- {
- BrowserBoxTools::replaceTabs(newRow);
- }
-
- if (atTop)
- {
- mTextRows.push_front(newRow);
- mTextRowLinksCount.push_front(linksCount);
- }
- else
- {
- mTextRows.push_back(newRow);
- mTextRowLinksCount.push_back(linksCount);
- }
-
- std::string plain = STD_MOVE(newRow);
- // workaround if used only one string started from bold
- // width for this string can be calculated wrong
- // this workaround fix width if string start from bold sign
- const bool startBold = (plain.find("##B") == 0);
- for (idx1 = plain.find("##");
- idx1 != std::string::npos;
- idx1 = plain.find("##"))
- {
- plain.erase(idx1, 3);
- }
-
- // Adjust the StaticBrowserBox size. This need only for implementing "---"
- const int w = startBold ?
- boldFont->getWidth(plain) : font->getWidth(plain) + 2 * mPadding;
- if (w > getWidth())
- setWidth(w);
-}
-
-void StaticBrowserBox::addRow(const std::string &cmd,
- const char *const text)
-{
- addRow(strprintf("@@%s|%s@@", encodeLinkText(cmd).c_str(),
- encodeLinkText(text).c_str()));
-}
-
-void StaticBrowserBox::addImage(const std::string &path)
-{
- if (!mEnableImages)
- return;
-
- mTextRows.push_back("~~~" + path);
- mTextRowLinksCount.push_back(0);
-}
-
-void StaticBrowserBox::clearRows()
-{
- mTextRows.clear();
- mTextRowLinksCount.clear();
- mLinks.clear();
- setWidth(0);
- setHeight(0);
- mSelectedLink = -1;
-}
-
-void StaticBrowserBox::mousePressed(MouseEvent &event)
-{
- if (mLinkHandler == nullptr)
- return;
-
- const LinkIterator i = std::find_if(mLinks.begin(), mLinks.end(),
- MouseOverLink(event.getX(), event.getY()));
-
- if (i != mLinks.end())
- {
- mLinkHandler->handleLink(i->link, &event);
- event.consume();
- }
-}
-
-void StaticBrowserBox::mouseMoved(MouseEvent &event)
-{
- const LinkIterator i = std::find_if(mLinks.begin(), mLinks.end(),
- MouseOverLink(event.getX(), event.getY()));
-
- mSelectedLink = (i != mLinks.end())
- ? CAST_S32(i - mLinks.begin()) : -1;
-}
-
-void StaticBrowserBox::mouseExited(MouseEvent &event A_UNUSED)
-{
- mSelectedLink = -1;
-}
-
-void StaticBrowserBox::draw(Graphics *const graphics)
-{
- BLOCK_START("StaticBrowserBox::draw")
- const ClipRect &cr = graphics->getTopClip();
- mYStart = cr.y - cr.yOffset;
- const int yEnd = mYStart + cr.height;
- if (mYStart < 0)
- mYStart = 0;
-
- if (mDimension.width != mWidth)
- {
- updateHeight();
- reportAlways("browserbox resize in draw: %d, %d",
- mDimension.width,
- mWidth);
- }
-
- if (mOpaque == Opaque_true)
- {
- graphics->setColor(mBackgroundColor);
- graphics->fillRectangle(Rect(0, 0,
- mDimension.width, mDimension.height));
- }
-
- if (mSelectedLink >= 0 &&
- mSelectedLink < CAST_S32(mLinks.size()))
- {
- if ((mHighlightMode & LinkHighlightMode::BACKGROUND) != 0u)
- {
- BrowserLink &link = mLinks[CAST_SIZE(mSelectedLink)];
- graphics->setColor(mHighlightColor);
- graphics->fillRectangle(Rect(
- link.x1,
- link.y1,
- link.x2 - link.x1,
- link.y2 - link.y1));
- }
-
- if ((mHighlightMode & LinkHighlightMode::UNDERLINE) != 0u)
- {
- BrowserLink &link = mLinks[CAST_SIZE(mSelectedLink)];
- graphics->setColor(mHyperLinkColor);
- graphics->drawLine(
- link.x1,
- link.y2,
- link.x2,
- link.y2);
- }
- }
-
- Font *const font = getFont();
-
- FOR_EACH (LinePartCIter, i, mLineParts)
- {
- const LinePart &part = *i;
- if (part.mY + 50 < mYStart)
- continue;
- if (part.mY > yEnd)
- break;
- if (part.mType == 0u)
- {
- if (part.mBold)
- {
- boldFont->drawString(graphics,
- part.mColor,
- part.mColor2,
- part.mText,
- part.mX, part.mY);
- }
- else
- {
- font->drawString(graphics,
- part.mColor,
- part.mColor2,
- part.mText,
- part.mX, part.mY);
- }
- }
- else if (part.mImage != nullptr)
- {
- graphics->drawImage(part.mImage, part.mX, part.mY);
- }
- }
-
- BLOCK_END("StaticBrowserBox::draw")
-}
-
-void StaticBrowserBox::safeDraw(Graphics *const graphics)
-{
- StaticBrowserBox::draw(graphics);
-}
-
-void StaticBrowserBox::updateHeight()
-{
- unsigned int y = CAST_U32(mPadding);
- int moreHeight = 0;
- int link = 0;
- bool bold = false;
- const unsigned int wWidth = CAST_U32(mDimension.width - mPadding);
- const Font *const font = getFont();
- const int fontHeight = font->getHeight() + 2 * mItemPadding;
- const int fontWidthMinus = font->getWidth("-");
-
- Color selColor[2] = {mForegroundColor, mForegroundColor2};
- const Color textColor[2] = {mForegroundColor, mForegroundColor2};
- mLineParts.clear();
- uint32_t dataWidth = 0;
-
- if (mSeparator)
- {
- mSeparator = false;
- mTextRows.pop_back();
- }
-
- FOR_EACH (TextRowCIter, i, mTextRows)
- {
- unsigned int x = CAST_U32(mPadding);
- const std::string row = *(i);
- int objects = 0;
-
- // Check for separator lines
- if (row.find("---", 0) == 0)
- {
- const int dashWidth = fontWidthMinus;
- for (x = CAST_U32(mPadding); x < wWidth; x ++)
- {
- mLineParts.push_back(LinePart(CAST_S32(x),
- CAST_S32(y) + mItemPadding,
- selColor[0], selColor[1], "-", false));
- x += CAST_U32(CAST_S32(
- dashWidth) - 2);
- }
-
- y += CAST_U32(fontHeight);
- continue;
- }
- else if (mEnableImages && row.find("~~~", 0) == 0)
- {
- std::string str = row.substr(3);
- const size_t sz = str.size();
- if (sz > 2 && str.substr(sz - 1) == "~")
- str = str.substr(0, sz - 1);
- Image *const img = Loader::getImage(str);
- if (img != nullptr)
- {
- img->incRef();
- mLineParts.push_back(LinePart(CAST_S32(x),
- CAST_S32(y) + mItemPadding,
- selColor[0], selColor[1], img));
- y += CAST_U32(img->getHeight() + 2);
- moreHeight += img->getHeight();
- if (img->getWidth() + mPadding + 2 > CAST_S32(dataWidth))
- dataWidth = img->getWidth() + 2 + mPadding;
- }
- continue;
- }
-
- Color prevColor[2];
- prevColor[0] = selColor[0];
- prevColor[1] = selColor[1];
- bold = false;
-
- for (size_t start = 0, end = std::string::npos;
- start != std::string::npos;
- start = end, end = std::string::npos)
- {
- size_t idx1 = end;
- size_t idx2 = end;
-
- // "Tokenize" the string at control sequences
- if (mUseLinksAndUserColors)
- idx1 = row.find("##", start + 1);
- if (start == 0 || mUseLinksAndUserColors)
- {
- // Check for color change in format "##x", x = [L,P,0..9]
- if (row.find("##", start) == start && row.size() > start + 2)
- {
- const signed char c = row.at(start + 2);
-
- bool valid(false);
- const Color col[2] =
- {
- getThemeCharColor(c, valid),
- getThemeCharColor(CAST_S8(
- c | 0x80), valid)
- };
-
- if (c == '>')
- {
- selColor[0] = prevColor[0];
- selColor[1] = prevColor[1];
- }
- else if (c == '<')
- {
- prevColor[0] = selColor[0];
- prevColor[1] = selColor[1];
- selColor[0] = col[0];
- selColor[1] = col[1];
- }
- else if (c == 'B')
- {
- bold = true;
- }
- else if (c == 'b')
- {
- bold = false;
- }
- else if (valid)
- {
- selColor[0] = col[0];
- selColor[1] = col[1];
- }
- else
- {
- switch (c)
- {
- case '0':
- selColor[0] = mColors[0][ColorName::BLACK];
- selColor[1] = mColors[1][ColorName::BLACK];
- break;
- case '1':
- selColor[0] = mColors[0][ColorName::RED];
- selColor[1] = mColors[1][ColorName::RED];
- break;
- case '2':
- selColor[0] = mColors[0][ColorName::GREEN];
- selColor[1] = mColors[1][ColorName::GREEN];
- break;
- case '3':
- selColor[0] = mColors[0][ColorName::BLUE];
- selColor[1] = mColors[1][ColorName::BLUE];
- break;
- case '4':
- selColor[0] = mColors[0][ColorName::ORANGE];
- selColor[1] = mColors[1][ColorName::ORANGE];
- break;
- case '5':
- selColor[0] = mColors[0][ColorName::YELLOW];
- selColor[1] = mColors[1][ColorName::YELLOW];
- break;
- case '6':
- selColor[0] = mColors[0][ColorName::PINK];
- selColor[1] = mColors[1][ColorName::PINK];
- break;
- case '7':
- selColor[0] = mColors[0][ColorName::PURPLE];
- selColor[1] = mColors[1][ColorName::PURPLE];
- break;
- case '8':
- selColor[0] = mColors[0][ColorName::GRAY];
- selColor[1] = mColors[1][ColorName::GRAY];
- break;
- case '9':
- selColor[0] = mColors[0][ColorName::BROWN];
- selColor[1] = mColors[1][ColorName::BROWN];
- break;
- default:
- selColor[0] = textColor[0];
- selColor[1] = textColor[1];
- break;
- }
- }
-
- if (c == '<' && link < CAST_S32(mLinks.size()))
- {
- int size;
- if (bold)
- {
- size = boldFont->getWidth(
- mLinks[CAST_SIZE(link)].caption) + 1;
- }
- else
- {
- size = font->getWidth(
- mLinks[CAST_SIZE(link)].caption) + 1;
- }
-
- BrowserLink &linkRef = mLinks[CAST_SIZE(
- link)];
- linkRef.x1 = CAST_S32(x);
- linkRef.y1 = CAST_S32(y);
- linkRef.x2 = linkRef.x1 + size;
- linkRef.y2 = CAST_S32(y) + fontHeight - 1;
- link++;
- }
-
- start += 3;
- if (start == row.size())
- break;
- }
- }
- if (mUseEmotes)
- idx2 = row.find("%%", start + 1);
- if (idx1 < idx2)
- end = idx1;
- else
- end = idx2;
- if (mUseEmotes)
- {
- // check for emote icons
- if (row.size() > start + 2 && row.substr(start, 2) == "%%")
- {
- if (objects < 5)
- {
- const int cid = row.at(start + 2) - '0';
- if (cid >= 0)
- {
- if (mEmotes != nullptr)
- {
- const size_t sz = mEmotes->size();
- if (CAST_SIZE(cid) < sz)
- {
- Image *const img = mEmotes->get(
- CAST_SIZE(cid));
- if (img != nullptr)
- {
- mLineParts.push_back(LinePart(
- CAST_S32(x),
- CAST_S32(y) + mItemPadding,
- selColor[0], selColor[1], img));
- x += 18;
- }
- }
- }
- }
- objects ++;
- }
-
- start += 3;
- if (start == row.size())
- {
- if (x > dataWidth)
- dataWidth = x;
- break;
- }
- }
- }
- const size_t len = (end == std::string::npos) ? end : end - start;
-
- if (start >= row.length())
- break;
-
- std::string part = row.substr(start, len);
-
- mLineParts.push_back(LinePart(CAST_S32(x),
- CAST_S32(y) + mItemPadding,
- selColor[0], selColor[1], part.c_str(), bold));
-
- int width = 0;
- if (bold)
- width = boldFont->getWidth(part);
- else
- width = font->getWidth(part);
-
- x += CAST_U32(width);
- if (x > dataWidth)
- dataWidth = x;
- }
- y += CAST_U32(fontHeight);
- }
- mWidth = dataWidth + mPadding;
- mHeight = CAST_S32(mTextRows.size())
- * fontHeight + moreHeight + 2 * mPadding;
- setSize(mWidth,
- mHeight);
-}
-
-std::string StaticBrowserBox::getTextAtPos(const int x,
- const int y) const
-{
- int textX = 0;
- int textY = 0;
-
- getAbsolutePosition(textX, textY);
- if (x < textX || y < textY)
- return std::string();
-
- textY = y - textY;
- std::string str;
- int lastY = 0;
-
- FOR_EACH (LinePartCIter, i, mLineParts)
- {
- const LinePart &part = *i;
- if (part.mY + 50 < mYStart)
- continue;
- if (part.mY > textY)
- break;
-
- if (part.mY > lastY)
- {
- str = part.mText;
- lastY = part.mY;
- }
- else
- {
- str.append(part.mText);
- }
- }
-
- return str;
-}
-
-void StaticBrowserBox::setForegroundColorAll(const Color &color1,
- const Color &color2)
-{
- mForegroundColor = color1;
- mForegroundColor2 = color2;
-}
-
-void StaticBrowserBox::moveSelectionUp()
-{
- if (mSelectedLink <= 0)
- mSelectedLink = CAST_S32(mLinks.size()) - 1;
- else
- mSelectedLink --;
-}
-
-void StaticBrowserBox::moveSelectionDown()
-{
- mSelectedLink ++;
- if (mSelectedLink >= static_cast<signed int>(mLinks.size()))
- mSelectedLink = 0;
-}
-
-void StaticBrowserBox::selectSelection()
-{
- if ((mLinkHandler == nullptr) ||
- mSelectedLink < 0 ||
- mSelectedLink >= static_cast<signed int>(mLinks.size()))
- {
- return;
- }
-
- mLinkHandler->handleLink(mLinks[CAST_SIZE(mSelectedLink)].link,
- nullptr);
-}
diff --git a/src/gui/widgets/staticbrowserbox.h b/src/gui/widgets/staticbrowserbox.h
deleted file mode 100644
index ff5862577..000000000
--- a/src/gui/widgets/staticbrowserbox.h
+++ /dev/null
@@ -1,194 +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
- * Copyright (C) 2009 Aethyra Development Team
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * 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_STATICBROWSERBOX_H
-#define GUI_WIDGETS_STATICBROWSERBOX_H
-
-#include "enums/simpletypes/opaque.h"
-
-#include "enums/gui/colorname.h"
-
-#include "gui/browserlink.h"
-
-#include "gui/widgets/linepart.h"
-#include "gui/widgets/widget.h"
-
-#include "listeners/mouselistener.h"
-
-#include "localconsts.h"
-
-class LinkHandler;
-
-/**
- * A simple browser box able to handle links and forward events to the
- * parent conteiner.
- */
-class StaticBrowserBox final : public Widget,
- public MouseListener
-{
- public:
- /**
- * Constructor.
- */
- StaticBrowserBox(const Widget2 *const widget,
- const Opaque opaque,
- const std::string &skin);
-
- A_DELETE_COPY(StaticBrowserBox)
-
- /**
- * Destructor.
- */
- ~StaticBrowserBox();
-
- /**
- * Sets the handler for links.
- */
- void setLinkHandler(LinkHandler *linkHandler);
-
- /**
- * Sets the StaticBrowserBox opacity.
- */
- void setOpaque(Opaque opaque)
- { mOpaque = opaque; }
-
- void addSeparator(const std::string &row);
-
- /**
- * Adds a text row to the browser.
- */
- void addRow(const std::string &row,
- const bool atTop = false);
-
- /**
- * Adds a menu line to the browser.
- */
- void addRow(const std::string &cmd,
- const char *const text);
-
- void addImage(const std::string &path);
-
- /**
- * Remove all rows.
- */
- void clearRows();
-
- /**
- * Handles mouse actions.
- */
- void mousePressed(MouseEvent &event) override final;
-
- void mouseMoved(MouseEvent &event) override final;
-
- void mouseExited(MouseEvent& event) override final;
-
- /**
- * Draws the browser box.
- */
- void draw(Graphics *const graphics) override final A_NONNULL(2);
-
- void safeDraw(Graphics *const graphics) override final A_NONNULL(2);
-
- void updateHeight();
-
- void updateSize();
-
- typedef std::list<std::string> TextRows;
-
- TextRows &getRows() noexcept2 A_WARN_UNUSED
- { return mTextRows; }
-
- bool hasRows() const noexcept2 A_WARN_UNUSED
- { return !mTextRows.empty(); }
-
- void setProcessVars(const bool n) noexcept2
- { mProcessVars = n; }
-
- void setEnableImages(const bool n) noexcept2
- { mEnableImages = n; }
-
- void setEnableKeys(const bool n) noexcept2
- { mEnableKeys = n; }
-
- void setEnableTabs(const bool n) noexcept2
- { mEnableTabs = n; }
-
- std::string getTextAtPos(const int x,
- const int y) const A_WARN_UNUSED;
-
- int getPadding() const noexcept2 A_WARN_UNUSED
- { return mPadding; }
-
- void setForegroundColorAll(const Color &color1,
- const Color &color2);
-
- void moveSelectionUp();
-
- void moveSelectionDown();
-
- void selectSelection();
-
- private:
- typedef TextRows::iterator TextRowIterator;
- typedef TextRows::const_iterator TextRowCIter;
- TextRows mTextRows;
- std::list<int> mTextRowLinksCount;
-
- typedef STD_VECTOR<LinePart> LinePartList;
- typedef LinePartList::iterator LinePartIterator;
- typedef LinePartList::const_iterator LinePartCIter;
- LinePartList mLineParts;
-
- typedef STD_VECTOR<BrowserLink> Links;
- typedef Links::iterator LinkIterator;
- Links mLinks;
-
- LinkHandler *mLinkHandler;
- Skin *mSkin;
- unsigned int mHighlightMode;
- int mSelectedLink;
- int mHeight;
- int mWidth;
- int mYStart;
- int mPadding;
- unsigned int mNewLinePadding;
- int mItemPadding;
-
- Color mHighlightColor;
- Color mHyperLinkColor;
- Color mColors[2][ColorName::COLORS_MAX];
-
- Opaque mOpaque;
- bool mUseLinksAndUserColors;
- bool mUseEmotes;
- bool mProcessVars;
- bool mEnableImages;
- bool mEnableKeys;
- bool mEnableTabs;
- bool mSeparator;
-
- static ImageSet *mEmotes;
- static int mInstances;
-};
-
-#endif // GUI_WIDGETS_STATICBROWSERBOX_H
diff --git a/src/gui/widgets/statspage.cpp b/src/gui/widgets/statspage.cpp
deleted file mode 100644
index 0540b1a24..000000000
--- a/src/gui/widgets/statspage.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 "gui/widgets/statspage.h"
-
-#include "gui/widgets/scrollarea.h"
-#include "gui/widgets/vertcontainer.h"
-
-#include "gui/widgets/attrs/derdisplay.h"
-
-#include "utils/foreach.h"
-
-#include "resources/db/statdb.h"
-
-#include "debug.h"
-
-StatsPage::StatsPage(const Widget2 *const widget,
- const std::string &page) :
- Container(widget),
- WidgetListener(),
- AttributeListener(),
- StatListener(),
- mAttrs(),
- mAttrCont(new VertContainer(this, 32)),
- mAttrScroll(new ScrollArea(this, mAttrCont, Opaque_false))
-{
- addWidgetListener(this);
- setSelectable(false);
-
- mAttrScroll->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
- mAttrScroll->setVerticalScrollPolicy(ScrollArea::SHOW_AUTO);
- mAttrScroll->setSelectable(false);
- mAttrCont->setSelectable(false);
-
- add(mAttrScroll);
- const STD_VECTOR<BasicStat> &basicStats = StatDb::getStats(page);
- FOR_EACH (STD_VECTOR<BasicStat>::const_iterator, it, basicStats)
- {
- const BasicStat &stat = *it;
- AttrDisplay *disp = new DerDisplay(this,
- stat.attr,
- stat.name,
- stat.tag);
- disp->update();
- mAttrCont->add2(disp, true);
- mAttrs[stat.attr] = disp;
- }
-}
-
-void StatsPage::widgetResized(const Event &event A_UNUSED)
-{
- mAttrScroll->setSize(getWidth(), getHeight());
-}
-
-void StatsPage::attributeChanged(const AttributesT id,
- const int64_t oldVal A_UNUSED,
- const int64_t newVal A_UNUSED)
-{
- const Attrs::const_iterator it = mAttrs.find(id);
- if (it != mAttrs.end() && (it->second != nullptr))
- it->second->update();
-}
-
-void StatsPage::statChanged(const AttributesT id,
- const int oldVal1 A_UNUSED,
- const int oldVal2 A_UNUSED)
-{
- const Attrs::const_iterator it = mAttrs.find(id);
- if (it != mAttrs.end() && (it->second != nullptr))
- it->second->update();
-}
diff --git a/src/gui/widgets/statspage.h b/src/gui/widgets/statspage.h
deleted file mode 100644
index ad62aebeb..000000000
--- a/src/gui/widgets/statspage.h
+++ /dev/null
@@ -1,61 +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 GUI_WIDGETS_STATSPAGE_H
-#define GUI_WIDGETS_STATSPAGE_H
-
-#include "gui/widgets/attrs/attrdisplay.h"
-
-#include "listeners/attributelistener.h"
-#include "listeners/statlistener.h"
-
-#include "localconsts.h"
-
-class ScrollArea;
-class VertContainer;
-
-class StatsPage final : public Container,
- public WidgetListener,
- public AttributeListener,
- public StatListener
-{
- public:
- StatsPage(const Widget2 *const widget,
- const std::string &page);
-
- A_DELETE_COPY(StatsPage)
-
- void widgetResized(const Event &event) override final;
-
- void attributeChanged(const AttributesT id,
- const int64_t oldVal,
- const int64_t newVal) override final;
-
- void statChanged(const AttributesT id,
- const int oldVal1,
- const int oldVal2) override final;
-
- private:
- Attrs mAttrs;
- VertContainer *mAttrCont A_NONNULLPOINTER;
- ScrollArea *mAttrScroll A_NONNULLPOINTER;
-};
-
-#endif // GUI_WIDGETS_STATSPAGE_H
diff --git a/src/gui/widgets/statspagebasic.cpp b/src/gui/widgets/statspagebasic.cpp
deleted file mode 100644
index 249d4f337..000000000
--- a/src/gui/widgets/statspagebasic.cpp
+++ /dev/null
@@ -1,163 +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 "gui/widgets/statspagebasic.h"
-
-#include "being/playerinfo.h"
-
-#include "gui/widgets/scrollarea.h"
-#include "gui/widgets/vertcontainer.h"
-
-#include "gui/widgets/attrs/changedisplay.h"
-
-#include "utils/gettext.h"
-#include "utils/foreach.h"
-#include "utils/stringutils.h"
-
-#include "resources/db/statdb.h"
-
-#include "debug.h"
-
-StatsPageBasic::StatsPageBasic(const Widget2 *const widget) :
- Container(widget),
- WidgetListener(),
- AttributeListener(),
- StatListener(),
- mAttrs(),
- mAttrCont(new VertContainer(this, 32)),
- mAttrScroll(new ScrollArea(this, mAttrCont, Opaque_false)),
- mCharacterPointsLabel(new Label(this, "C"))
-{
- addWidgetListener(this);
- setSelectable(false);
-
- mAttrScroll->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
- mAttrScroll->setVerticalScrollPolicy(ScrollArea::SHOW_AUTO);
- mAttrScroll->setSelectable(false);
- mAttrCont->setSelectable(false);
-
- add(mAttrScroll);
- const STD_VECTOR<BasicStat> &basicStats = StatDb::getBasicStats();
- FOR_EACH (STD_VECTOR<BasicStat>::const_iterator, it, basicStats)
- {
- const BasicStat &stat = *it;
- AttrDisplay *disp = new ChangeDisplay(this,
- stat.attr,
- stat.name,
- stat.tag);
- disp->update();
- mAttrCont->add2(disp, true);
- mAttrs[stat.attr] = disp;
- }
-
- // TRANSLATORS: status window label
- mCharacterPointsLabel->setCaption(strprintf(_("Character points: %d"),
- PlayerInfo::getAttribute(Attributes::PLAYER_CHAR_POINTS)));
- mCharacterPointsLabel->adjustSize();
- mAttrCont->add1(mCharacterPointsLabel);
-}
-
-void StatsPageBasic::widgetResized(const Event &event A_UNUSED)
-{
- mAttrScroll->setSize(getWidth(), getHeight());
-}
-
-void StatsPageBasic::statChanged(const AttributesT id,
- const int oldVal1 A_UNUSED,
- const int oldVal2 A_UNUSED)
-{
- const Attrs::const_iterator it = mAttrs.find(id);
- if (it != mAttrs.end() && (it->second != nullptr))
- it->second->update();
-}
-
-void StatsPageBasic::attributeChanged(const AttributesT id,
- const int64_t oldVal A_UNUSED,
- const int64_t newVal)
-{
- PRAGMA45(GCC diagnostic push)
- PRAGMA45(GCC diagnostic ignored "-Wswitch-enum")
- switch (id)
- {
- case Attributes::PLAYER_CHAR_POINTS:
- mCharacterPointsLabel->setCaption(strprintf(
- // TRANSLATORS: status window label
- _("Character points: %d"), CAST_S32(newVal)));
-
- mCharacterPointsLabel->adjustSize();
- // Update all attributes
- for (Attrs::const_iterator it = mAttrs.begin();
- it != mAttrs.end(); ++it)
- {
- if (it->second != nullptr)
- it->second->update();
- }
- return;
-
- case Attributes::PLAYER_CORR_POINTS:
- // Update all attributes
- for (Attrs::const_iterator it = mAttrs.begin();
- it != mAttrs.end(); ++it)
- {
- if (it->second != nullptr)
- it->second->update();
- }
- return;
-
- default:
- break;
- }
- PRAGMA45(GCC diagnostic pop)
- const Attrs::const_iterator it = mAttrs.find(id);
- if (it != mAttrs.end() && (it->second != nullptr))
- it->second->update();
-}
-
-void StatsPageBasic::setPointsNeeded(const AttributesT id,
- const int needed)
-{
- const Attrs::const_iterator it = mAttrs.find(id);
-
- if (it != mAttrs.end())
- {
- AttrDisplay *const disp = it->second;
- if ((disp != nullptr) && disp->getType() == AttrDisplay::CHANGEABLE)
- static_cast<ChangeDisplay*>(disp)->setPointsNeeded(needed);
- }
-}
-
-std::string StatsPageBasic::getStatsStr() const
-{
- Attrs::const_iterator it = mAttrs.begin();
- const Attrs::const_iterator it_end = mAttrs.end();
- std::string str;
- while (it != it_end)
- {
- const ChangeDisplay *const attr = dynamic_cast<ChangeDisplay*>(
- (*it).second);
- if (attr != nullptr)
- {
- str.append(strprintf("%s:%s ", attr->getShortName().c_str(),
- attr->getValue().c_str()));
- }
- ++ it;
- }
- return str;
-}
diff --git a/src/gui/widgets/statspagebasic.h b/src/gui/widgets/statspagebasic.h
deleted file mode 100644
index d56b8aeff..000000000
--- a/src/gui/widgets/statspagebasic.h
+++ /dev/null
@@ -1,67 +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 GUI_WIDGETS_STATSPAGEBASIC_H
-#define GUI_WIDGETS_STATSPAGEBASIC_H
-
-#include "gui/widgets/attrs/attrdisplay.h"
-
-#include "listeners/attributelistener.h"
-#include "listeners/statlistener.h"
-
-#include "localconsts.h"
-
-class Label;
-class ScrollArea;
-class VertContainer;
-
-class StatsPageBasic final : public Container,
- public WidgetListener,
- public AttributeListener,
- public StatListener
-{
- public:
- explicit StatsPageBasic(const Widget2 *const widget);
-
- A_DELETE_COPY(StatsPageBasic)
-
- void widgetResized(const Event &event) override final;
-
- void attributeChanged(const AttributesT id,
- const int64_t oldVal,
- const int64_t newVal) override final;
-
- void statChanged(const AttributesT id,
- const int oldVal1,
- const int oldVal2) override final;
-
- void setPointsNeeded(const AttributesT id,
- const int needed);
-
- std::string getStatsStr() const;
-
- private:
- Attrs mAttrs;
- VertContainer *mAttrCont A_NONNULLPOINTER;
- ScrollArea *mAttrScroll A_NONNULLPOINTER;
- Label *mCharacterPointsLabel A_NONNULLPOINTER;
-};
-
-#endif // GUI_WIDGETS_STATSPAGEBASIC_H
diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp
deleted file mode 100644
index e89f60418..000000000
--- a/src/gui/widgets/tabbedarea.cpp
+++ /dev/null
@@ -1,827 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "gui/widgets/tabbedarea.h"
-
-#include "gui/gui.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/scrollarea.h"
-#include "gui/widgets/tabs/tab.h"
-
-#include "utils/delete2.h"
-#include "utils/foreach.h"
-
-#include "debug.h"
-
-TabbedArea::TabbedArea(const Widget2 *const widget) :
- ActionListener(),
- BasicContainer(widget),
- KeyListener(),
- MouseListener(),
- WidgetListener(),
- mArrowButton(),
- mSelectedTab(nullptr),
- mTabContainer(new BasicContainer2(widget)),
- mWidgetContainer(new BasicContainer2(widget)),
- mTabsToDelete(),
- mTabs(),
- mTabsWidth(0),
- mVisibleTabsWidth(0),
- mTabScrollIndex(0),
- mRightMargin(0),
- mOpaque(Opaque_false),
- mEnableScrollButtons(false),
- mFollowDownScroll(false),
- mBlockSwitching(true),
- mResizeHeight(true)
-{
- setFocusable(true);
- addKeyListener(this);
- addMouseListener(this);
-}
-
-void TabbedArea::postInit()
-{
- mTabContainer->setOpaque(Opaque_false);
-
- add(mTabContainer);
- add(mWidgetContainer);
-
- mWidgetContainer->setOpaque(Opaque_false);
- addWidgetListener(this);
-
- mArrowButton[0] = new Button(this, "<", "shift_left", this);
- mArrowButton[1] = new Button(this, ">", "shift_right", this);
-
- widgetResized(Event(nullptr));
-}
-
-TabbedArea::~TabbedArea()
-{
- if (gui != nullptr)
- gui->removeDragged(this);
-
- // +++ virtual method calls
- remove(mTabContainer);
- remove(mWidgetContainer);
-
- delete2(mTabContainer);
- delete2(mWidgetContainer);
-
- for (size_t i = 0, sz = mTabsToDelete.size(); i < sz; i++)
- delete2(mTabsToDelete[i])
-
- delete2(mArrowButton[0]);
- delete2(mArrowButton[1]);
-}
-
-void TabbedArea::enableScrollButtons(const bool enable)
-{
- if (mEnableScrollButtons && !enable)
- {
- if (mArrowButton[0] != nullptr)
- remove(mArrowButton[0]);
- if (mArrowButton[1] != nullptr)
- remove(mArrowButton[1]);
- }
- else if (!mEnableScrollButtons && enable)
- {
- if (mArrowButton[0] != nullptr)
- add(mArrowButton[0]);
- if (mArrowButton[1] != nullptr)
- add(mArrowButton[1]);
- }
- mEnableScrollButtons = enable;
-}
-
-int TabbedArea::getNumberOfTabs() const
-{
- return CAST_S32(mTabs.size());
-}
-
-Tab *TabbedArea::getTab(const std::string &name) const
-{
- TabContainer::const_iterator itr = mTabs.begin();
- const TabContainer::const_iterator itr_end = mTabs.end();
- while (itr != itr_end)
- {
- if ((*itr).first->getCaption() == name)
- return static_cast<Tab*>((*itr).first);
-
- ++itr;
- }
- return nullptr;
-}
-
-void TabbedArea::draw(Graphics *const graphics)
-{
- BLOCK_START("TabbedArea::draw")
- if (mTabs.empty())
- {
- BLOCK_END("TabbedArea::draw")
- return;
- }
-
- drawChildren(graphics);
- BLOCK_END("TabbedArea::draw")
-}
-
-void TabbedArea::safeDraw(Graphics *const graphics)
-{
- BLOCK_START("TabbedArea::draw")
- if (mTabs.empty())
- {
- BLOCK_END("TabbedArea::draw")
- return;
- }
-
- safeDrawChildren(graphics);
- BLOCK_END("TabbedArea::draw")
-}
-
-Widget *TabbedArea::getWidget(const std::string &name) const
-{
- TabContainer::const_iterator itr = mTabs.begin();
- const TabContainer::const_iterator itr_end = mTabs.end();
- while (itr != itr_end)
- {
- if ((*itr).first->getCaption() == name)
- return (*itr).second;
-
- ++itr;
- }
-
- return nullptr;
-}
-
-Widget *TabbedArea::getCurrentWidget() const
-{
- const Tab *const tab = getSelectedTab();
-
- if (tab != nullptr)
- return getWidget(tab->getCaption());
- return nullptr;
-}
-
-void TabbedArea::addTab(Tab *const tab,
- Widget *const widget)
-{
- if ((tab == nullptr) || (widget == nullptr))
- return;
-
- tab->setTabbedArea(this);
- tab->addActionListener(this);
-
- mTabContainer->add(tab);
- mTabs.push_back(std::pair<Tab*, Widget*>(tab, widget));
-
- if ((mSelectedTab == nullptr) && tab->mVisible == Visible_true)
- setSelectedTab(tab);
-
- adjustTabPositions();
- adjustSize();
-
- const int frameSize = 2 * mFrameSize;
- widget->setSize(getWidth() - frameSize,
- getHeight() - frameSize - mTabContainer->getHeight());
-
- widgetResized(Event(nullptr));
- updateTabsWidth();
- updateArrowEnableState();
-}
-
-void TabbedArea::adjustWidget(Widget *const widget) const
-{
- if (widget == nullptr)
- return;
- const int frameSize = 2 * mFrameSize;
- widget->setSize(getWidth() - frameSize,
- getHeight() - frameSize - mTabContainer->getHeight());
-}
-
-void TabbedArea::addTab(const std::string &caption, Widget *const widget)
-{
- Tab *const tab = new Tab(this);
- tab->setCaption(caption);
- mTabsToDelete.push_back(tab);
-
- addTab(tab, widget);
-}
-
-void TabbedArea::addTab(Image *const image, Widget *const widget)
-{
- Tab *const tab = new Tab(this);
- tab->setImage(image);
- mTabsToDelete.push_back(tab);
-
- addTab(tab, widget);
-}
-
-bool TabbedArea::isTabSelected(const size_t index) const
-{
- if (index >= mTabs.size())
- return false;
-
- return mSelectedTab == mTabs[index].first;
-}
-
-bool TabbedArea::isTabPresent(const Tab *const tab) const
-{
- FOR_EACH (TabContainer::const_iterator, it, mTabs)
- {
- if ((*it).first == tab || (*it).second == tab)
- return true;
- }
- return false;
-}
-
-bool TabbedArea::isTabSelected(const Tab *const tab) const
-{
- return mSelectedTab == tab;
-}
-
-void TabbedArea::setSelectedTabByIndex(const size_t index)
-{
- if (index >= mTabs.size())
- return;
-
- setSelectedTab(mTabs[index].first);
-}
-
-void TabbedArea::removeTab(Tab *const tab)
-{
- int tabIndexToBeSelected = -1;
-
- if (tab == mSelectedTab)
- {
- const int index = getSelectedTabIndex();
- const size_t sz = mTabs.size();
- if (index == CAST_S32(sz) - 1 && sz == 1)
- tabIndexToBeSelected = -1;
- else
- tabIndexToBeSelected = index - 1;
- }
-
- for (TabContainer::iterator iter = mTabs.begin();
- iter != mTabs.end(); ++iter)
- {
- if (iter->first == tab)
- {
- mTabContainer->remove(tab);
- mTabs.erase(iter);
- break;
- }
- }
-
- for (STD_VECTOR<Tab*>::iterator iter2 = mTabsToDelete.begin();
- iter2 != mTabsToDelete.end(); ++iter2)
- {
- if (*iter2 == tab)
- {
- mTabsToDelete.erase(iter2);
- delete tab;
- break;
- }
- }
-
- const int tabsSize = CAST_S32(mTabs.size());
- if (tabIndexToBeSelected >= tabsSize)
- tabIndexToBeSelected = tabsSize - 1;
- if (tabIndexToBeSelected < -1)
- tabIndexToBeSelected = -1;
-
- if (tabIndexToBeSelected == -1)
- {
- mSelectedTab = nullptr;
- mWidgetContainer->clear();
- }
- else
- {
- setSelectedTabByIndex(tabIndexToBeSelected);
- }
-
- adjustSize();
- updateTabsWidth();
- widgetResized(Event(nullptr));
-}
-
-void TabbedArea::logic()
-{
- BLOCK_START("TabbedArea::logic")
- logicChildren();
- BLOCK_END("TabbedArea::logic")
-}
-
-void TabbedArea::mousePressed(MouseEvent &event)
-{
- if (event.isConsumed())
- return;
-
- if (event.getButton() == MouseButton::LEFT)
- {
- Widget *const widget = mTabContainer->getWidgetAt(
- event.getX(), event.getY());
- Tab *const tab = dynamic_cast<Tab *>(widget);
-
- if (tab != nullptr)
- {
- event.consume();
- setSelectedTab(tab);
- requestFocus();
- }
- }
-}
-
-void TabbedArea::setSelectedTab(Tab *const tab)
-{
- for (size_t i = 0; i < mTabs.size(); i++)
- {
- if (mTabs[i].first == mSelectedTab)
- mWidgetContainer->remove(mTabs[i].second);
- }
-
- for (size_t i = 0; i < mTabs.size(); i++)
- {
- if (mTabs[i].first == tab)
- {
- mSelectedTab = tab;
- mWidgetContainer->add(mTabs[i].second);
- }
- }
-
- Tab *const newTab = tab;
-
- if (newTab != nullptr)
- newTab->setCurrent();
-
- widgetResized(Event(nullptr));
-}
-
-void TabbedArea::setSelectedTabDefault()
-{
- if (mSelectedTab == nullptr ||
- mSelectedTab->mVisible == Visible_false)
- {
- for (size_t i = 0; i < mTabs.size(); i++)
- {
- Tab *const tab = mTabs[i].first;
- if ((tab != nullptr) && tab->mVisible == Visible_true)
- {
- setSelectedTab(tab);
- return;
- }
- }
- }
-}
-
-int TabbedArea::getSelectedTabIndex() const
-{
- for (unsigned int i = 0, fsz = CAST_U32(mTabs.size());
- i < fsz;
- i++)
- {
- if (mTabs[i].first == mSelectedTab)
- return i;
- }
-
- return -1;
-}
-
-void TabbedArea::setSelectedTabByName(const std::string &name)
-{
- FOR_EACH (TabContainer::const_iterator, itr, mTabs)
- {
- if (((*itr).first != nullptr) && (*itr).first->getCaption() == name)
- {
- setSelectedTab((*itr).first);
- return;
- }
- }
-}
-
-void TabbedArea::widgetResized(const Event &event A_UNUSED)
-{
- adjustSize();
-
- const int frameSize = 2 * mFrameSize;
- const int widgetFrameSize = 2 * mWidgetContainer->getFrameSize();
- const int w1 = mDimension.width;
- const int h1 = mDimension.height;
- const int width = w1 - frameSize - widgetFrameSize;
- const int height = h1 - frameSize
- - mWidgetContainer->getY() - widgetFrameSize;
-
- Widget *const w = getCurrentWidget();
- ScrollArea *const scr = dynamic_cast<ScrollArea *>(w);
- if (scr != nullptr)
- {
- if (mFollowDownScroll && height != 0)
- {
- const Rect &rect = w->getDimension();
- if (rect.height != 0 && rect.height > height + 2)
- {
- if (scr->getVerticalScrollAmount()
- >= scr->getVerticalMaxScroll() - 2
- && scr->getVerticalScrollAmount()
- <= scr->getVerticalMaxScroll() + 2)
- {
- const int newScroll = scr->getVerticalScrollAmount()
- + rect.height - height;
- w->setSize(mWidgetContainer->getWidth() - frameSize,
- mWidgetContainer->getHeight() - frameSize);
- if (newScroll != 0)
- scr->setVerticalScrollAmount(newScroll);
- }
- }
- }
- }
-
- if (mArrowButton[1] != nullptr)
- {
- // Check whether there is room to show more tabs now.
- int innerWidth = w1 - 4 - mArrowButton[0]->getWidth()
- - mArrowButton[1]->getWidth() - mRightMargin;
- if (innerWidth < 0)
- innerWidth = 0;
-
- int newWidth = mVisibleTabsWidth;
- while ((mTabScrollIndex != 0u) && newWidth < innerWidth)
- {
- Tab *const tab = mTabs[mTabScrollIndex - 1].first;
- if ((tab != nullptr) && tab->mVisible == Visible_true)
- {
- newWidth += tab->getWidth();
- if (newWidth < innerWidth)
- --mTabScrollIndex;
- }
- }
-
- if (mArrowButton[1] != nullptr)
- {
- // Move the right arrow to fit the windows content.
- newWidth = width - mArrowButton[1]->getWidth() - mRightMargin;
- if (newWidth < 0)
- newWidth = 0;
- mArrowButton[1]->setPosition(newWidth, 0);
- }
- }
-
- updateArrowEnableState();
- adjustTabPositions();
-}
-
-void TabbedArea::updateTabsWidth()
-{
- mTabsWidth = 0;
- FOR_EACH (TabContainer::const_iterator, itr, mTabs)
- {
- Tab *const tab = (*itr).first;
- if ((tab != nullptr) && tab->mVisible == Visible_true)
- mTabsWidth += tab->getWidth();
- }
- updateVisibleTabsWidth();
-}
-
-void TabbedArea::updateVisibleTabsWidth()
-{
- mVisibleTabsWidth = 0;
- for (size_t i = mTabScrollIndex, sz = mTabs.size(); i < sz; ++i)
- {
- Tab *const tab = mTabs[i].first;
- if ((tab != nullptr) && tab->mVisible == Visible_true)
- mVisibleTabsWidth += CAST_S32(tab->getWidth());
- }
-}
-
-void TabbedArea::adjustSize()
-{
- int maxTabHeight = 0;
-
- const int width = mDimension.width;
- const int height = mDimension.height;
-
- for (size_t i = 0, sz = mTabs.size(); i < sz; i++)
- {
- if (mTabs[i].first->getHeight() > maxTabHeight)
- maxTabHeight = mTabs[i].first->getHeight();
- }
-
- mTabContainer->setSize(width - mRightMargin, maxTabHeight);
-
- mWidgetContainer->setPosition(0, maxTabHeight);
- mWidgetContainer->setSize(width, height - maxTabHeight);
- Widget *const w = getCurrentWidget();
- if (w != nullptr)
- {
- const int wFrameSize = w->getFrameSize();
- const int frame2 = 2 * wFrameSize;
-
- w->setPosition(wFrameSize, wFrameSize);
- if (mResizeHeight)
- {
- w->setSize(mWidgetContainer->getWidth() - frame2,
- mWidgetContainer->getHeight() - frame2);
- }
- else
- {
- w->setSize(mWidgetContainer->getWidth() - frame2,
- w->getHeight());
- }
- }
-}
-
-void TabbedArea::adjustTabPositions()
-{
- int maxTabHeight = 0;
- const size_t sz = mTabs.size();
- for (size_t i = 0; i < sz; ++i)
- {
- const Tab *const tab = mTabs[i].first;
- if ((tab != nullptr) &&
- tab->mVisible == Visible_true &&
- tab->getHeight() > maxTabHeight)
- {
- maxTabHeight = tab->getHeight();
- }
- }
-
- int x = (mEnableScrollButtons && mArrowButton[0]->mVisible == Visible_true)
- ? mArrowButton[0]->getWidth() : 0;
- for (size_t i = mTabScrollIndex; i < sz; ++i)
- {
- Tab *const tab = mTabs[i].first;
- if ((tab == nullptr) || tab->mVisible == Visible_false)
- continue;
- tab->setPosition(x, maxTabHeight - tab->getHeight());
- x += tab->getWidth();
- }
-
- // If the tabs are scrolled, we hide them away.
- if (mTabScrollIndex > 0)
- {
- x = 0;
- for (unsigned i = 0; i < mTabScrollIndex; ++i)
- {
- Tab *const tab = mTabs[i].first;
- if ((tab != nullptr) && tab->mVisible == Visible_true)
- {
- x -= tab->getWidth();
- tab->setPosition(x, maxTabHeight - tab->getHeight());
- }
- }
- }
-}
-
-void TabbedArea::action(const ActionEvent& actionEvent)
-{
- Widget *const source = actionEvent.getSource();
- Tab *const tab = dynamic_cast<Tab *>(source);
-
- if (tab != nullptr)
- {
- setSelectedTab(tab);
- }
- else
- {
- const std::string &eventId = actionEvent.getId();
- if (eventId == "shift_left")
- {
- if (mTabScrollIndex != 0u)
- --mTabScrollIndex;
- }
- else if (eventId == "shift_right")
- {
- if (CAST_SIZE(mTabScrollIndex) < mTabs.size() - 1)
- ++mTabScrollIndex;
- }
- adjustTabPositions();
- updateArrowEnableState();
- }
-}
-
-void TabbedArea::updateArrowEnableState()
-{
- updateTabsWidth();
- if ((mArrowButton[0] == nullptr) || (mArrowButton[1] == nullptr))
- return;
-
- const int width = mDimension.width;
- if (mTabsWidth > width - 4
- - mArrowButton[0]->getWidth()
- - mArrowButton[1]->getWidth() - mRightMargin)
- {
- mArrowButton[0]->setVisible(Visible_true);
- mArrowButton[1]->setVisible(Visible_true);
- }
- else
- {
- mArrowButton[0]->setVisible(Visible_false);
- mArrowButton[1]->setVisible(Visible_false);
- mTabScrollIndex = 0;
- }
-
- // Left arrow consistency check
- if (mTabScrollIndex == 0u)
- mArrowButton[0]->setEnabled(false);
- else
- mArrowButton[0]->setEnabled(true);
-
- // Right arrow consistency check
- if (mVisibleTabsWidth < width - 4
- - mArrowButton[0]->getWidth()
- - mArrowButton[1]->getWidth() - mRightMargin)
- {
- mArrowButton[1]->setEnabled(false);
- }
- else
- {
- mArrowButton[1]->setEnabled(true);
- }
-}
-
-Tab *TabbedArea::getTabByIndex(const int index) const
-{
- if (index < 0 || index >= CAST_S32(mTabs.size()))
- return nullptr;
- return static_cast<Tab*>(mTabs[index].first);
-}
-
-Widget *TabbedArea::getWidgetByIndex(const int index) const
-{
- if (index < 0 || index >= CAST_S32(mTabs.size()))
- return nullptr;
- return mTabs[index].second;
-}
-
-void TabbedArea::removeAll(const bool del)
-{
- if (getSelectedTabIndex() != -1)
- {
- setSelectedTabByIndex(CAST_U32(0));
- }
- while (getNumberOfTabs() > 0)
- {
- const int idx = getNumberOfTabs() - 1;
- Tab *tab = mTabs[idx].first;
- Widget *widget = mTabs[idx].second;
- removeTab(tab);
- if (del)
- {
- delete tab;
- delete widget;
- }
- }
-}
-
-void TabbedArea::setWidth(int width)
-{
- // +++ need use virtual
- Widget::setWidth(width);
- adjustSize();
-}
-
-void TabbedArea::setHeight(int height)
-{
- // +++ need use virtual
- Widget::setHeight(height);
- adjustSize();
-}
-
-void TabbedArea::setSize(int width, int height)
-{
- // +++ need use virtual
- Widget::setSize(width, height);
- adjustSize();
-}
-
-void TabbedArea::setDimension(const Rect &dimension)
-{
- // +++ need use virtual
- Widget::setDimension(dimension);
- adjustSize();
-}
-
-void TabbedArea::keyPressed(KeyEvent& event)
-{
- if (mBlockSwitching || event.isConsumed() || !isFocused())
- return;
-
- const InputActionT actionId = event.getActionId();
-
- if (actionId == InputAction::GUI_LEFT)
- {
- int index = getSelectedTabIndex();
- index--;
-
- if (index < 0)
- return;
-
- setSelectedTab(mTabs[index].first);
- event.consume();
- }
- else if (actionId == InputAction::GUI_RIGHT)
- {
- int index = getSelectedTabIndex();
- index++;
-
- if (index >= CAST_S32(mTabs.size()))
- return;
-
- setSelectedTab(mTabs[index].first);
- event.consume();
- }
-}
-
-void TabbedArea::death(const Event &event)
-{
- Tab *const tab = dynamic_cast<Tab*>(event.getSource());
-
- if (tab != nullptr)
- removeTab(tab);
- else
- BasicContainer::death(event);
-}
-
-void TabbedArea::selectNextTab()
-{
- int tab = getSelectedTabIndex();
- tab++;
- if (tab == CAST_S32(mTabs.size()))
- tab = 0;
- setSelectedTab(mTabs[tab].first);
-}
-
-void TabbedArea::selectPrevTab()
-{
- int tab = getSelectedTabIndex();
-
- if (tab == 0)
- tab = CAST_S32(mTabs.size());
- if (tab < 0)
- return;
- tab--;
- setSelectedTab(mTabs[tab].first);
-}
diff --git a/src/gui/widgets/tabbedarea.h b/src/gui/widgets/tabbedarea.h
deleted file mode 100644
index c971da391..000000000
--- a/src/gui/widgets/tabbedarea.h
+++ /dev/null
@@ -1,299 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GUI_WIDGETS_TABBEDAREA_H
-#define GUI_WIDGETS_TABBEDAREA_H
-
-#include "listeners/keylistener.h"
-#include "listeners/mouselistener.h"
-#include "listeners/widgetlistener.h"
-
-#include "gui/widgets/basiccontainer2.h"
-
-#include "listeners/actionlistener.h"
-
-class Button;
-class Image;
-class Tab;
-
-/**
- * A tabbed area, the same as the guichan tabbed area in 0.8, but extended
- */
-class TabbedArea final : public ActionListener,
- public BasicContainer,
- public KeyListener,
- public MouseListener,
- public WidgetListener
-{
- public:
- /**
- * Constructor.
- */
- explicit TabbedArea(const Widget2 *const widget);
-
- A_DELETE_COPY(TabbedArea)
-
- ~TabbedArea();
-
- void postInit() override final;
-
- /**
- * Draw the tabbed area.
- */
- void draw(Graphics *const graphics) override final A_NONNULL(2);
-
- void safeDraw(Graphics *const graphics) override final A_NONNULL(2);
-
- /**
- * Return how many tabs have been created.
- */
- int getNumberOfTabs() const A_WARN_UNUSED;
-
- /**
- * Return tab with specified name as caption.
- */
- Tab *getTab(const std::string &name) const A_WARN_UNUSED;
-
- Tab *getTabByIndex(const int index) const A_WARN_UNUSED;
-
- Widget *getWidgetByIndex(const int index) const A_WARN_UNUSED;
-
- /**
- * Returns the widget with the tab that has specified caption
- */
- Widget *getWidget(const std::string &name) const A_WARN_UNUSED;
-
- /**
- * Returns the widget for the current tab
- */
- Widget *getCurrentWidget() const A_WARN_UNUSED;
-
- /**
- * Add a tab. Overridden since it needs to size the widget.
- *
- * @param tab The tab widget for the tab.
- * @param widget The widget to view when the tab is selected.
- */
- void addTab(Tab *const tab, Widget *const widget);
-
- void addTab(const std::string &caption, Widget *const widget);
-
- void addTab(Image *const image, Widget *const widget);
-
- bool isTabSelected(const size_t index) const A_WARN_UNUSED;
-
- bool isTabSelected(const Tab *const tab) const A_WARN_UNUSED;
-
- bool isTabPresent(const Tab *const tab) const A_WARN_UNUSED;
-
- /**
- * Overload the remove tab function as it's broken in guichan 0.8.
- */
- void removeTab(Tab *const tab);
-
- void removeAll(const bool del = true);
-
- /**
- * Overload the logic function since it's broken in guichan 0.8.
- */
- void logic() override final;
-
- int getContainerHeight() const noexcept2 A_WARN_UNUSED
- { return mWidgetContainer->getHeight(); }
-
- void setSelectedTab(Tab *const tab);
-
- void setSelectedTabDefault();
-
- void setSelectedTabByIndex(const size_t index);
-
- int getSelectedTabIndex() const A_WARN_UNUSED;
-
- Tab* getSelectedTab() const noexcept2 A_WARN_UNUSED
- { return mSelectedTab; }
-
- void setOpaque(const Opaque opaque)
- { mOpaque = opaque; }
-
- bool isOpaque() const noexcept2 A_WARN_UNUSED
- { return mOpaque == Opaque_true; }
-
- void adjustSize();
-
- void setSelectedTabByName(const std::string &name);
-
- void widgetResized(const Event &event) override final;
-
-/*
- void moveLeft(Tab *tab);
-
- void moveRight(Tab *tab);
-*/
- void adjustTabPositions();
-
- void action(const ActionEvent& actionEvent) override final;
-
- // Inherited from MouseListener
-
- void mousePressed(MouseEvent &event) override final;
-
- void enableScrollButtons(const bool enable);
-
- void setRightMargin(const int n) noexcept2
- { mRightMargin = n; }
-
- int getRightMargin() const noexcept2 A_WARN_UNUSED
- { return mRightMargin; }
-
- void setFollowDownScroll(const bool n) noexcept2
- { mFollowDownScroll = n; }
-
- bool getFollowDownScroll() const noexcept2 A_WARN_UNUSED
- { return mFollowDownScroll; }
-
- void keyPressed(KeyEvent& event) override final;
-
- void setBlockSwitching(const bool b) noexcept2
- { mBlockSwitching = b; }
-
- void setWidth(int width);
-
- void setHeight(int height);
-
- void setSize(int width, int height);
-
- void setDimension(const Rect &dimension);
-
- void death(const Event &event) override final;
-
- void setResizeHeight(bool b) noexcept2
- { mResizeHeight = b; }
-
- void adjustWidget(Widget *const widget) const;
-
- void selectNextTab();
-
- void selectPrevTab();
-
- Widget *getTabContainer() const noexcept2 A_WARN_UNUSED
- { return mTabContainer; }
-
- Widget *getWidgetContainer() const noexcept2 A_WARN_UNUSED
- { return mWidgetContainer; }
-
- private:
- typedef STD_VECTOR <std::pair<Tab*, Widget*> > TabContainer;
-
- /** The tab arrows */
- Button *mArrowButton[2] A_NONNULLPOINTER;
-
- /** Check whether the arrow should be clickable */
- void updateArrowEnableState();
-
- /**
- * Update the overall width of all tab. Used to know whether the arrows
- * have to be drawn or not.
- */
- void updateTabsWidth();
-
- Tab* mSelectedTab;
- BasicContainer2* mTabContainer A_NONNULLPOINTER;
- BasicContainer2* mWidgetContainer A_NONNULLPOINTER;
- STD_VECTOR<Tab*> mTabsToDelete;
- TabContainer mTabs;
-
- /**
- * The overall width of all tab.
- */
- int mTabsWidth;
-
- /**
- * Update the overall width of visible tab. Used to know whether
- * the arrows have to be enable or not.
- */
- void updateVisibleTabsWidth();
-
- /**
- * The overall width of visible tab.
- */
- int mVisibleTabsWidth;
-
- /**
- * The tab scroll index. When scrolling with the arrows, the tabs
- * must be displayed according to the current index.
- * So the first tab displayed may not be the first in the list.
- * @note the index must start at 0.
- */
- unsigned int mTabScrollIndex;
- int mRightMargin;
-
- Opaque mOpaque;
- bool mEnableScrollButtons;
- bool mFollowDownScroll;
- bool mBlockSwitching;
- bool mResizeHeight;
-};
-
-#endif // GUI_WIDGETS_TABBEDAREA_H
diff --git a/src/gui/widgets/tabs/chat/battletab.cpp b/src/gui/widgets/tabs/chat/battletab.cpp
deleted file mode 100644
index fc45fd5e1..000000000
--- a/src/gui/widgets/tabs/chat/battletab.cpp
+++ /dev/null
@@ -1,44 +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 "gui/widgets/tabs/chat/battletab.h"
-
-#include "configuration.h"
-
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-BattleTab *battleChatTab = nullptr;
-
-BattleTab::BattleTab(const Widget2 *const widget) :
- // TRANSLATORS: battle chat tab name
- ChatTab(widget, _("Battle"), "", "#Battle", ChatTabType::BATTLE)
-{
- setTabColors(ThemeColorId::BATTLE_CHAT_TAB);
- if (config.getBoolValue("showChatHistory"))
- loadFromLogFile("#Battle");
-}
-
-BattleTab::~BattleTab()
-{
-}
diff --git a/src/gui/widgets/tabs/chat/battletab.h b/src/gui/widgets/tabs/chat/battletab.h
deleted file mode 100644
index 24f69c8b9..000000000
--- a/src/gui/widgets/tabs/chat/battletab.h
+++ /dev/null
@@ -1,43 +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 GUI_WIDGETS_TABS_CHAT_BATTLETAB_H
-#define GUI_WIDGETS_TABS_CHAT_BATTLETAB_H
-
-#include "gui/widgets/tabs/chat/chattab.h"
-
-/**
- * A tab for a party chat channel.
- */
-class BattleTab final : public ChatTab
-{
- public:
- explicit BattleTab(const Widget2 *const widget);
-
- A_DELETE_COPY(BattleTab)
-
- ~BattleTab();
-};
-
-extern BattleTab *battleChatTab;
-
-#endif // GUI_WIDGETS_TABS_CHAT_BATTLETAB_H
diff --git a/src/gui/widgets/tabs/chat/channeltab.cpp b/src/gui/widgets/tabs/chat/channeltab.cpp
deleted file mode 100644
index 37e6237a0..000000000
--- a/src/gui/widgets/tabs/chat/channeltab.cpp
+++ /dev/null
@@ -1,77 +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 "gui/widgets/tabs/chat/channeltab.h"
-
-#include "gui/widgets/windowcontainer.h"
-
-#include "gui/windows/chatwindow.h"
-
-#include "net/chathandler.h"
-
-#include "debug.h"
-
-ChannelTab::ChannelTab(const Widget2 *const widget,
- const std::string &channel) :
- ChatTab(widget, channel, channel, channel, ChatTabType::CHANNEL)
-{
- setTabColors(ThemeColorId::CHANNEL_CHAT_TAB);
-}
-
-ChannelTab::~ChannelTab()
-{
- if (chatWindow != nullptr)
- chatWindow->removeChannel(mChannelName);
-}
-
-void ChannelTab::handleInput(const std::string &msg)
-{
- std::string newMsg;
- newMsg = ChatWindow::doReplace(msg);
- chatHandler->channelMessage(mChannelName, newMsg);
-}
-
-bool ChannelTab::handleCommand(const std::string &restrict type,
- const std::string &restrict args A_UNUSED)
-{
- if (type == "close")
- {
- if (windowContainer != nullptr)
- windowContainer->scheduleDelete(this);
- else
- delete this;
- if (chatWindow != nullptr)
- chatWindow->defaultTab();
- }
- else
- {
- return false;
- }
-
- return true;
-}
-
-void ChannelTab::getAutoCompleteCommands(StringVect& commands) const
-{
- commands.push_back("/close");
- commands.push_back(mChannelName);
-}
diff --git a/src/gui/widgets/tabs/chat/channeltab.h b/src/gui/widgets/tabs/chat/channeltab.h
deleted file mode 100644
index 3ac51e59d..000000000
--- a/src/gui/widgets/tabs/chat/channeltab.h
+++ /dev/null
@@ -1,51 +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 GUI_WIDGETS_TABS_CHAT_CHANNELTAB_H
-#define GUI_WIDGETS_TABS_CHAT_CHANNELTAB_H
-
-#include "gui/widgets/tabs/chat/chattab.h"
-
-/**
- * A tab for a chat channel.
- */
-class ChannelTab final : public ChatTab
-{
- public:
- ChannelTab(const Widget2 *const widget,
- const std::string &channel);
-
- A_DELETE_COPY(ChannelTab)
-
- ~ChannelTab();
-
- protected:
- void handleInput(const std::string &msg) override final;
-
- bool handleCommand(const std::string &restrict type,
- const std::string &restrict args) override final;
-
- void getAutoCompleteCommands(StringVect& commands)
- const override final;
-};
-
-#endif // GUI_WIDGETS_TABS_CHAT_CHANNELTAB_H
diff --git a/src/gui/widgets/tabs/chat/chattab.cpp b/src/gui/widgets/tabs/chat/chattab.cpp
deleted file mode 100644
index e4f6d751a..000000000
--- a/src/gui/widgets/tabs/chat/chattab.cpp
+++ /dev/null
@@ -1,563 +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 "gui/widgets/tabs/chat/chattab.h"
-
-#include "chatlogger.h"
-#include "configuration.h"
-#include "settings.h"
-#include "soundmanager.h"
-
-#include "being/localplayer.h"
-
-#include "const/sound.h"
-
-#include "gui/chatlog.h"
-#include "gui/windowmanager.h"
-
-#include "gui/windows/chatwindow.h"
-#include "gui/windows/helpwindow.h"
-
-#include "gui/widgets/scrollarea.h"
-#include "gui/widgets/itemlinkhandler.h"
-#include "gui/widgets/tabbedarea.h"
-
-#include "input/inputmanager.h"
-
-#include "net/chathandler.h"
-#include "net/net.h"
-
-#include "utils/chatutils.h"
-#include "utils/delete2.h"
-#include "utils/gettext.h"
-
-#ifdef WIN32
-#include <sys/time.h>
-#endif // WIN32
-
-#include <sstream>
-
-#include "debug.h"
-
-ChatTab *localChatTab = nullptr;
-ChatTab *debugChatTab = nullptr;
-
-static const unsigned int MAX_WORD_SIZE = 50;
-
-ChatTab::ChatTab(const Widget2 *const widget,
- const std::string &name,
- const std::string &channel,
- const std::string &logName,
- const ChatTabTypeT &type) :
- Tab(widget),
- mTextOutput(new BrowserBox(this, Opaque_true,
- "browserbox.xml")),
- mScrollArea(new ScrollArea(this, mTextOutput, Opaque_false)),
- mChannelName(channel),
- mLogName(logName),
- mType(type),
- mAllowHightlight(true),
- mRemoveNames(false),
- mNoAway(false),
- mShowOnline(false)
-{
- setCaption(name);
-
- mTextOutput->setOpaque(Opaque_false);
- mTextOutput->setMaxRow(config.getIntValue("ChatLogLength"));
- if (chatWindow != nullptr)
- mTextOutput->setLinkHandler(chatWindow->mItemLinkHandler);
- mTextOutput->setAlwaysUpdate(false);
-
- mScrollArea->setScrollPolicy(ScrollArea::SHOW_NEVER,
- ScrollArea::SHOW_ALWAYS);
- mScrollArea->setScrollAmount(0, 1);
-
- if (chatWindow != nullptr)
- chatWindow->addTab(this);
- mTextOutput->updateSize(true);
-}
-
-ChatTab::~ChatTab()
-{
- if (chatWindow != nullptr)
- chatWindow->removeTab(this);
-
- delete2(mTextOutput);
- delete2(mScrollArea);
-}
-
-void ChatTab::chatLog(std::string line,
- ChatMsgTypeT own,
- const IgnoreRecord ignoreRecord,
- const TryRemoveColors tryRemoveColors)
-{
- // Trim whitespace
- trim(line);
-
- if (line.empty())
- return;
-
- if (tryRemoveColors == TryRemoveColors_true &&
- own == ChatMsgType::BY_OTHER &&
- config.getBoolValue("removeColors"))
- {
- line = removeColors(line);
- if (line.empty())
- return;
- }
-
- const unsigned lineLim = config.getIntValue("chatMaxCharLimit");
- if (lineLim > 0 && line.length() > lineLim)
- line = line.substr(0, lineLim);
-
- if (line.empty())
- return;
-
- CHATLOG tmp;
- tmp.own = own;
- tmp.nick.clear();
- tmp.text = line;
-
- const size_t pos = line.find(" : ");
- if (pos != std::string::npos)
- {
- if (line.length() <= pos + 3)
- return;
-
- tmp.nick = line.substr(0, pos);
- tmp.text = line.substr(pos + 3);
- }
- else
- {
- // Fix the owner of welcome message.
- if (line.length() > 7 && line.substr(0, 7) == "Welcome")
- own = ChatMsgType::BY_SERVER;
- }
-
- // *implements actions in a backwards compatible way*
- if ((own == ChatMsgType::BY_PLAYER || own == ChatMsgType::BY_OTHER) &&
- tmp.text.at(0) == '*' &&
- tmp.text.at(tmp.text.length()-1) == '*')
- {
- tmp.text[0] = ' ';
- tmp.text.erase(tmp.text.length() - 1);
- own = ChatMsgType::ACT_IS;
- }
-
- std::string lineColor("##C");
- switch (own)
- {
- case ChatMsgType::BY_GM:
- if (tmp.nick.empty())
- {
- // TRANSLATORS: chat message
- tmp.nick = std::string(_("Global announcement:")).append(" ");
- lineColor = "##G";
- }
- else
- {
- // TRANSLATORS: chat message
- tmp.nick = strprintf(_("Global announcement from %s:"),
- tmp.nick.c_str()).append(" ");
- lineColor = "##g"; // Equiv. to BrowserBox::RED
- }
- break;
- case ChatMsgType::BY_PLAYER:
- tmp.nick.append(": ");
- lineColor = "##Y";
- break;
- case ChatMsgType::BY_OTHER:
- case ChatMsgType::BY_UNKNOWN:
- tmp.nick.append(": ");
- lineColor = "##C";
- break;
- case ChatMsgType::BY_SERVER:
- // TRANSLATORS: chat message
- tmp.nick.clear();
- tmp.text = line;
- lineColor = "##S";
- break;
- case ChatMsgType::BY_CHANNEL:
- tmp.nick.clear();
- lineColor = "##2"; // Equiv. to BrowserBox::GREEN
- break;
- case ChatMsgType::ACT_WHISPER:
- // TRANSLATORS: chat message
- tmp.nick = strprintf(_("%s whispers: %s"), tmp.nick.c_str(), "");
- lineColor = "##W";
- break;
- case ChatMsgType::ACT_IS:
- lineColor = "##I";
- break;
- case ChatMsgType::BY_LOGGER:
- tmp.nick.clear();
- tmp.text = line;
- lineColor = "##L";
- break;
- default:
- break;
- }
-
- if (tmp.nick == ": ")
- {
- tmp.nick.clear();
- lineColor = "##S";
- }
-
- // if configured, move magic messages log to debug chat tab
- if (Net::getNetworkType() == ServerType::TMWATHENA
- && (localChatTab != nullptr) && this == localChatTab
- && ((config.getBoolValue("showMagicInDebug")
- && own == ChatMsgType::BY_PLAYER
- && tmp.text.length() > 1
- && tmp.text.at(0) == '#'
- && tmp.text.at(1) != '#')
- || (config.getBoolValue("serverMsgInDebug")
- && (own == ChatMsgType::BY_SERVER
- || tmp.nick.empty()))))
- {
- if (debugChatTab != nullptr)
- debugChatTab->chatLog(line, own, ignoreRecord, tryRemoveColors);
- return;
- }
-
- // Get the current system time
- time_t t;
- time(&t);
-
- if (config.getBoolValue("useLocalTime"))
- {
- const tm *const timeInfo = localtime(&t);
- if (timeInfo != nullptr)
- {
- line = strprintf("%s[%02d:%02d] %s%s", lineColor.c_str(),
- timeInfo->tm_hour, timeInfo->tm_min, tmp.nick.c_str(),
- tmp.text.c_str());
- }
- else
- {
- line = strprintf("%s %s%s", lineColor.c_str(),
- tmp.nick.c_str(), tmp.text.c_str());
- }
- }
- else
- {
- // Format the time string properly
- std::stringstream timeStr;
- timeStr << "[" << ((((t / 60) / 60) % 24 < 10) ? "0" : "")
- << CAST_S32(((t / 60) / 60) % 24)
- << ":" << (((t / 60) % 60 < 10) ? "0" : "")
- << CAST_S32((t / 60) % 60)
- << "] ";
- line = std::string(lineColor).append(timeStr.str()).append(
- tmp.nick).append(tmp.text);
- }
-
- if (config.getBoolValue("enableChatLog"))
- saveToLogFile(line);
-
- mTextOutput->setMaxRow(config.getIntValue("chatMaxLinesLimit"));
-
- // We look if the Vertical Scroll Bar is set at the max before
- // adding a row, otherwise the max will always be a row higher
- // at comparison.
- if (mScrollArea->getVerticalScrollAmount() + 2 >=
- mScrollArea->getVerticalMaxScroll())
- {
- addRow(line);
- mScrollArea->setVerticalScrollAmount(
- mScrollArea->getVerticalMaxScroll());
- }
- else
- {
- addRow(line);
- }
-
- if ((chatWindow != nullptr) && this == localChatTab)
- chatWindow->addToAwayLog(line);
-
- mScrollArea->logic();
- if (own != ChatMsgType::BY_PLAYER)
- {
- if (own == ChatMsgType::BY_SERVER &&
- (getType() == ChatTabType::PARTY ||
- getType() == ChatTabType::CHANNEL ||
- getType() == ChatTabType::GUILD))
- {
- return;
- }
-
- const TabbedArea *const tabArea = getTabbedArea();
- if (tabArea == nullptr)
- return;
-
- const bool notFocused = WindowManager::getIsMinimized() ||
- (!settings.mouseFocused &&
- settings.inputFocused == KeyboardFocus::Unfocused);
-
- if (this != tabArea->getSelectedTab() || notFocused)
- {
- if (getFlash() == 0)
- {
- if (chatWindow != nullptr &&
- chatWindow->findHighlight(tmp.text))
- {
- setFlash(2);
- soundManager.playGuiSound(SOUND_HIGHLIGHT);
- }
- else
- {
- setFlash(1);
- }
- }
- else if (getFlash() == 2)
- {
- if (chatWindow != nullptr &&
- chatWindow->findHighlight(tmp.text))
- {
- soundManager.playGuiSound(SOUND_HIGHLIGHT);
- }
- }
- }
-
- if ((getAllowHighlight() ||
- own == ChatMsgType::BY_GM) &&
- (this != tabArea->getSelectedTab() ||
- notFocused))
- {
- if (own == ChatMsgType::BY_GM)
- {
- if (chatWindow != nullptr)
- chatWindow->unHideWindow();
- soundManager.playGuiSound(SOUND_GLOBAL);
- }
- else if (own != ChatMsgType::BY_SERVER)
- {
- if (chatWindow != nullptr)
- chatWindow->unHideWindow();
- playNewMessageSound();
- }
- WindowManager::newChatMessage();
- }
- }
-}
-
-void ChatTab::chatLog(const std::string &nick, std::string msg)
-{
- if (localPlayer == nullptr)
- return;
-
- const ChatMsgTypeT byWho = (nick == localPlayer->getName()
- ? ChatMsgType::BY_PLAYER : ChatMsgType::BY_OTHER);
- if (byWho == ChatMsgType::BY_OTHER && config.getBoolValue("removeColors"))
- msg = removeColors(msg);
- chatLog(std::string(nick).append(" : ").append(msg),
- byWho,
- IgnoreRecord_false,
- TryRemoveColors_false);
-}
-
-void ChatTab::chatInput(const std::string &message)
-{
- std::string msg = message;
- trim(msg);
-
- if (msg.empty())
- return;
-
- replaceItemLinks(msg);
- replaceVars(msg);
-
- switch (msg[0])
- {
- case '/':
- handleCommandStr(std::string(msg, 1));
- break;
- case '?':
- if (msg.size() > 1 &&
- msg[1] != '!' &&
- msg[1] != '?' &&
- msg[1] != '.' &&
- msg[1] != ' ' &&
- msg[1] != ',')
- {
- handleHelp(std::string(msg, 1));
- }
- else
- {
- handleInput(msg);
- }
- break;
- default:
- handleInput(msg);
- break;
- }
-}
-
-void ChatTab::scroll(const int amount)
-{
- const int range = mScrollArea->getHeight() / 8 * amount;
- Rect scr;
- scr.y = mScrollArea->getVerticalScrollAmount() + range;
- scr.height = abs(range);
- mTextOutput->showPart(scr);
-}
-
-void ChatTab::clearText()
-{
- mTextOutput->clearRows();
-}
-
-void ChatTab::handleInput(const std::string &msg)
-{
- if (chatHandler)
- {
- chatHandler->talk(ChatWindow::doReplace(msg),
- mChannelName);
- }
-}
-
-void ChatTab::handleCommandStr(const std::string &msg)
-{
- const size_t pos = msg.find(' ');
- const std::string type(msg, 0, pos);
- std::string args(msg, pos == std::string::npos ? msg.size() : pos + 1);
-
- args = trim(args);
- if (!handleCommand(type, args))
- inputManager.executeChatCommand(type, args, this);
-}
-
-void ChatTab::handleHelp(const std::string &msg)
-{
- if (helpWindow != nullptr)
- {
- helpWindow->search(msg);
- helpWindow->requestMoveToTop();
- }
-}
-
-bool ChatTab::handleCommands(const std::string &type, const std::string &args)
-{
- // need split to commands and call each
-
- return handleCommand(type, args);
-}
-
-void ChatTab::saveToLogFile(const std::string &msg) const
-{
- if (chatLogger != nullptr)
- {
- if (getType() == ChatTabType::INPUT)
- {
- chatLogger->log(msg);
- }
- else if (getType() == ChatTabType::DEBUG)
- {
- if (config.getBoolValue("enableDebugLog"))
- chatLogger->log("#Debug", msg);
- }
- else if (!mLogName.empty())
- {
- chatLogger->log(mLogName, msg);
- }
- }
-}
-
-void ChatTab::addRow(std::string &line)
-{
- if (line.find("[@@http") == std::string::npos)
- {
- size_t idx = 0;
- for (size_t f = 0; f < line.length(); f++)
- {
- if (line.at(f) == ' ')
- {
- idx = f;
- }
- else if (f - idx > MAX_WORD_SIZE)
- {
- line.insert(f, " ");
- idx = f;
- }
- }
- }
- mTextOutput->addRow(line);
-}
-
-void ChatTab::loadFromLogFile(const std::string &name)
-{
- if (chatLogger != nullptr)
- {
- std::list<std::string> list;
- chatLogger->loadLast(name, list, 5);
- std::list<std::string>::const_iterator i = list.begin();
- while (i != list.end())
- {
- std::string line("##o" + *i);
- addRow(line);
- ++i;
- }
- }
-}
-
-void ChatTab::addNewRow(std::string &line)
-{
- if (mScrollArea->getVerticalScrollAmount() >=
- mScrollArea->getVerticalMaxScroll())
- {
- addRow(line);
- mScrollArea->setVerticalScrollAmount(
- mScrollArea->getVerticalMaxScroll());
- }
- else
- {
- addRow(line);
- }
- mScrollArea->logic();
-}
-
-void ChatTab::playNewMessageSound() const
-{
- soundManager.playGuiSound(SOUND_WHISPER);
-}
-
-void ChatTab::showOnline(const std::string &nick,
- const Online online)
-{
- if (!mShowOnline)
- return;
-
- if (online == Online_true)
- {
- // TRANSLATORS: chat message
- chatLog(strprintf(_("%s is now Online."), nick.c_str()),
- ChatMsgType::BY_SERVER);
- }
- else
- {
- // TRANSLATORS: chat message
- chatLog(strprintf(_("%s is now Offline."), nick.c_str()),
- ChatMsgType::BY_SERVER);
- }
-}
diff --git a/src/gui/widgets/tabs/chat/chattab.h b/src/gui/widgets/tabs/chat/chattab.h
deleted file mode 100644
index 440501af4..000000000
--- a/src/gui/widgets/tabs/chat/chattab.h
+++ /dev/null
@@ -1,216 +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 GUI_WIDGETS_TABS_CHAT_CHATTAB_H
-#define GUI_WIDGETS_TABS_CHAT_CHATTAB_H
-
-#include "enums/gui/chatmsgtype.h"
-#include "enums/gui/chattabtype.h"
-
-#include "enums/simpletypes/ignorerecord.h"
-#include "enums/simpletypes/online.h"
-#include "enums/simpletypes/tryremovecolors.h"
-
-#include "gui/widgets/browserbox.h"
-
-#include "gui/widgets/tabs/tab.h"
-
-#include "localconsts.h"
-
-class ScrollArea;
-
-#define debugMsg(str) \
- if (debugChatTab) \
- debugChatTab->chatLog(str, ChatMsgType::BY_SERVER);
-
-#define setTabColors(name) \
- setTabColor(&getThemeColor(name), \
- &getThemeColor(name##_OUTLINE)); \
- setHighlightedTabColor(&getThemeColor(name##_HIGHLIGHTED), \
- &getThemeColor(name##_HIGHLIGHTED_OUTLINE)); \
- setSelectedTabColor(&getThemeColor(name##_SELECTED), \
- &getThemeColor(name##_SELECTED_OUTLINE))
-
-/**
- * A tab for the chat window. This is special to ease chat handling.
- */
-class ChatTab notfinal : public Tab
-{
- public:
- /**
- * Constructor.
- */
- ChatTab(const Widget2 *const widget,
- const std::string &name,
- const std::string &channel,
- const std::string &logName,
- const ChatTabTypeT &type);
-
- A_DELETE_COPY(ChatTab)
-
- virtual ~ChatTab();
-
- /**
- * Adds a line of text to our message list. Parameters:
- *
- * @param line Text message.
- * @param own Type of message (usually the owner-type).
- * @param ignoreRecord should this not be recorded?
- * @param tryRemoveColors try remove color if configured
- */
- void chatLog(std::string line,
- ChatMsgTypeT own,
- const IgnoreRecord ignoreRecord = IgnoreRecord_false,
- const TryRemoveColors tryRemoveColors
- = TryRemoveColors_true);
-
- /**
- * Adds the text to the message list
- *
- * @param msg The message text which is to be sent.
- */
- void chatLog(const std::string &nick, std::string msg);
-
- /**
- * Determines whether the message is a command or message, then
- * sends the given message to the game server to be said, or to the
- * command handler
- *
- * @param msg The message text which is to be sent.
- */
- void chatInput(const std::string &msg);
-
- /**
- * Scrolls the chat window
- *
- * @param amount direction and amount to scroll. Negative numbers scroll
- * up, positive numbers scroll down. The absolute amount indicates the
- * amount of 1/8ths of chat window real estate that should be scrolled.
- */
- void scroll(const int amount);
-
- /**
- * Clears the text from the tab
- */
- void clearText();
-
- /**
- * Handle special commands. Allows a tab to handle commands it
- * defines itself.
- *
- * @returns true if the command was handled
- * false if the command was not handled
- */
- virtual bool handleCommand(const std::string &restrict type A_UNUSED,
- const std::string &restrict args A_UNUSED)
- { return false; }
-
- /**
- * Handle special commands. Allows a tab to handle commands it
- * defines itself.
- *
- * @returns true if the command was handled
- * false if the command was not handled
- */
- virtual bool handleCommands(const std::string &type,
- const std::string &args);
-
- /**
- * Returns type of the being.
- */
- ChatTabTypeT getType() const noexcept2 A_WARN_UNUSED
- { return mType; }
-
- void saveToLogFile(const std::string &msg) const;
-
- const std::list<std::string> &getRows() const A_WARN_UNUSED
- { return mTextOutput->getRows(); }
-
- bool hasRows() const A_WARN_UNUSED
- { return mTextOutput->hasRows(); }
-
- void loadFromLogFile(const std::string &name);
-
- bool getAllowHighlight() const noexcept2 A_WARN_UNUSED
- { return mAllowHightlight; }
-
- void setAllowHighlight(const bool n) noexcept2
- { mAllowHightlight = n; }
-
- bool getRemoveNames() const noexcept2 A_WARN_UNUSED
- { return mRemoveNames; }
-
- void setRemoveNames(const bool n) noexcept2
- { mRemoveNames = n; }
-
- bool getNoAway() const noexcept2 A_WARN_UNUSED
- { return mNoAway; }
-
- void setNoAway(const bool n) noexcept2
- { mNoAway = n; }
-
- void addNewRow(std::string &line);
-
- void showOnline(const std::string &nick,
- const Online online);
-
- virtual void playNewMessageSound() const;
-
- const std::string &getChannelName() const
- { return mChannelName; }
-
- protected:
- friend class ChatWindow;
- friend class WhisperWindow;
-
- void setCurrent() override final
- { setFlash(0); }
-
- virtual void handleInput(const std::string &msg);
-
- virtual void handleCommandStr(const std::string &msg);
-
- virtual void handleHelp(const std::string &msg);
-
- virtual void getAutoCompleteList(StringVect &names A_UNUSED) const
- {}
-
- virtual void getAutoCompleteCommands(StringVect &names A_UNUSED) const
- {}
-
- void addRow(std::string &line);
-
- BrowserBox *mTextOutput A_NONNULLPOINTER;
- ScrollArea *mScrollArea;
- std::string mChannelName;
- std::string mLogName;
- ChatTabTypeT mType;
- bool mAllowHightlight;
- bool mRemoveNames;
- bool mNoAway;
- bool mShowOnline;
-};
-
-extern ChatTab *localChatTab;
-extern ChatTab *debugChatTab;
-
-#endif // GUI_WIDGETS_TABS_CHAT_CHATTAB_H
diff --git a/src/gui/widgets/tabs/chat/emulateguildtab.cpp b/src/gui/widgets/tabs/chat/emulateguildtab.cpp
deleted file mode 100644
index 4e94bf11d..000000000
--- a/src/gui/widgets/tabs/chat/emulateguildtab.cpp
+++ /dev/null
@@ -1,108 +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/>.
- */
-
-#ifdef TMWA_SUPPORT
-
-#include "gui/widgets/tabs/chat/emulateguildtab.h"
-
-#include "configuration.h"
-#include "soundmanager.h"
-
-#include "const/sound.h"
-
-#include "gui/windows/chatwindow.h"
-
-#include "utils/gettext.h"
-
-#include "net/tmwa/guildmanager.h"
-
-#include "debug.h"
-
-EmulateGuildTab::EmulateGuildTab(const Widget2 *const widget) :
- // TRANSLATORS: guild chat tab name
- ChatTab(widget, _("Guild"), "", "#Guild", ChatTabType::GUILD),
- ConfigListener()
-{
- setTabColors(ThemeColorId::GUILD_CHAT_TAB);
- mShowOnline = config.getBoolValue("showGuildOnline");
- config.addListener("showGuildOnline", this);
-}
-
-EmulateGuildTab::~EmulateGuildTab()
-{
- config.removeListeners(this);
- CHECKLISTENERS
-}
-
-bool EmulateGuildTab::handleCommand(const std::string &restrict type,
- const std::string &restrict args)
-{
- if (type == "invite")
- GuildManager::invite(args);
- else if (type == "leave")
- GuildManager::leave();
- else if (type == "kick")
- GuildManager::kick(args);
- else if (type == "notice")
- GuildManager::notice(args);
- else
- return false;
-
- return true;
-}
-
-void EmulateGuildTab::handleInput(const std::string &msg)
-{
- if (guildManager == nullptr)
- return;
- guildManager->chat(ChatWindow::doReplace(msg));
-}
-
-void EmulateGuildTab::getAutoCompleteList(StringVect &names) const
-{
- if (guildManager == nullptr)
- return;
-
- guildManager->getNames(names);
-}
-
-void EmulateGuildTab::getAutoCompleteCommands(StringVect &names) const
-{
- names.push_back("/help");
- names.push_back("/invite ");
- names.push_back("/leave");
- names.push_back("/kick ");
- names.push_back("/notice ");
-}
-
-void EmulateGuildTab::playNewMessageSound() const
-{
- soundManager.playGuiSound(SOUND_GUILD);
-}
-
-void EmulateGuildTab::optionChanged(const std::string &value)
-{
- if (value == "showGuildOnline")
- mShowOnline = config.getBoolValue("showGuildOnline");
-}
-
-#endif // TMWA_SUPPORT
diff --git a/src/gui/widgets/tabs/chat/emulateguildtab.h b/src/gui/widgets/tabs/chat/emulateguildtab.h
deleted file mode 100644
index 3cf3a0e59..000000000
--- a/src/gui/widgets/tabs/chat/emulateguildtab.h
+++ /dev/null
@@ -1,59 +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 GUI_WIDGETS_TABS_CHAT_EMULATEGUILDTAB_H
-#define GUI_WIDGETS_TABS_CHAT_EMULATEGUILDTAB_H
-
-#ifdef TMWA_SUPPORT
-
-#include "gui/widgets/tabs/chat/chattab.h"
-
-/**
- * Emulate guild tab, because server not support normal guilds.
- */
-class EmulateGuildTab final : public ChatTab,
- public ConfigListener
-{
- public:
- explicit EmulateGuildTab(const Widget2 *const widget);
-
- A_DELETE_COPY(EmulateGuildTab)
-
- ~EmulateGuildTab();
-
- bool handleCommand(const std::string &restrict type,
- const std::string &restrict args) override final;
-
- void playNewMessageSound() const override final;
-
- void optionChanged(const std::string &value) override final;
-
- protected:
- void handleInput(const std::string &msg) override final;
-
- void getAutoCompleteList(StringVect &names) const override final;
-
- void getAutoCompleteCommands(StringVect &names) const override final;
-};
-
-#endif // TMWA_SUPPORT
-#endif // GUI_WIDGETS_TABS_CHAT_EMULATEGUILDTAB_H
diff --git a/src/gui/widgets/tabs/chat/gmtab.cpp b/src/gui/widgets/tabs/chat/gmtab.cpp
deleted file mode 100644
index 3a63cbd2d..000000000
--- a/src/gui/widgets/tabs/chat/gmtab.cpp
+++ /dev/null
@@ -1,57 +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 "gui/widgets/tabs/chat/gmtab.h"
-
-#include "const/gui/chat.h"
-
-#include "gui/windows/chatwindow.h"
-
-#include "utils/gettext.h"
-
-#include "net/chathandler.h"
-
-#include "debug.h"
-
-GmTab *gmChatTab = nullptr;
-
-GmTab::GmTab(const Widget2 *const widget) :
- // TRANSLATORS: gb tab name
- ChatTab(widget, _("GM"), GM_CHANNEL, "#GM", ChatTabType::GM)
-{
- setTabColors(ThemeColorId::GM_CHAT_TAB);
-}
-
-GmTab::~GmTab()
-{
-}
-
-void GmTab::handleInput(const std::string &msg)
-{
- chatHandler->channelMessage(mChannelName, ChatWindow::doReplace(msg));
-}
-
-void GmTab::handleCommandStr(const std::string &msg A_UNUSED)
-{
-}
-
-void GmTab::getAutoCompleteList(StringVect &names A_UNUSED) const
-{
-}
diff --git a/src/gui/widgets/tabs/chat/gmtab.h b/src/gui/widgets/tabs/chat/gmtab.h
deleted file mode 100644
index a8dd46fd3..000000000
--- a/src/gui/widgets/tabs/chat/gmtab.h
+++ /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/>.
- */
-
-#ifndef GUI_WIDGETS_TABS_CHAT_GMTAB_H
-#define GUI_WIDGETS_TABS_CHAT_GMTAB_H
-
-#include "gui/widgets/tabs/chat/chattab.h"
-
-/**
- * A tab for whispers from a single player.
- */
-class GmTab final : public ChatTab
-{
- public:
- explicit GmTab(const Widget2 *const widget);
-
- A_DELETE_COPY(GmTab)
-
- ~GmTab();
-
- protected:
- void getAutoCompleteList(StringVect &names) const
- override final A_CONST;
-
- void handleInput(const std::string &msg) override final;
-
- void handleCommandStr(const std::string &msg) override final A_CONST;
-};
-
-extern GmTab *gmChatTab;
-
-#endif // GUI_WIDGETS_TABS_CHAT_GMTAB_H
diff --git a/src/gui/widgets/tabs/chat/guildtab.cpp b/src/gui/widgets/tabs/chat/guildtab.cpp
deleted file mode 100644
index 51416b8ef..000000000
--- a/src/gui/widgets/tabs/chat/guildtab.cpp
+++ /dev/null
@@ -1,125 +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 "gui/widgets/tabs/chat/guildtab.h"
-
-#include "configuration.h"
-#include "soundmanager.h"
-
-#include "const/sound.h"
-
-#include "gui/windows/chatwindow.h"
-
-#include "input/inputmanager.h"
-
-#include "net/guildhandler.h"
-
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-namespace EAthena
-{
- extern Guild *taGuild;
-} // namespace EAthena
-
-GuildTab::GuildTab(const Widget2 *const widget) :
- // TRANSLATORS: guild chat tab name
- ChatTab(widget, _("Guild"), "", "#Guild", ChatTabType::GUILD)
-{
- setTabColors(ThemeColorId::GUILD_CHAT_TAB);
- mShowOnline = config.getBoolValue("showGuildOnline");
- config.addListener("showGuildOnline", this);
-}
-
-GuildTab::~GuildTab()
-{
- config.removeListeners(this);
- CHECKLISTENERS
-}
-
-bool GuildTab::handleCommand(const std::string &restrict type,
- const std::string &restrict args)
-{
- if (type == "invite" && (EAthena::taGuild != nullptr))
- {
- guildHandler->invite(args);
- }
- else if (type == "leave" && (EAthena::taGuild != nullptr))
- {
- inputManager.executeChatCommand(InputAction::LEAVE_GUILD,
- std::string(),
- this);
- }
- else if (type == "kick" && (EAthena::taGuild != nullptr))
- {
- inputManager.executeChatCommand(InputAction::KICK_GUILD,
- args,
- this);
- }
- else if (type == "notice" && (EAthena::taGuild != nullptr))
- {
- inputManager.executeChatCommand(InputAction::GUILD_NOTICE,
- args,
- this);
- }
- else
- {
- return false;
- }
-
- return true;
-}
-
-void GuildTab::handleInput(const std::string &msg)
-{
- if (EAthena::taGuild == nullptr)
- return;
-
- guildHandler->chat(ChatWindow::doReplace(msg));
-}
-
-void GuildTab::getAutoCompleteList(StringVect &names) const
-{
- if (EAthena::taGuild != nullptr)
- EAthena::taGuild->getNames(names);
-}
-
-void GuildTab::getAutoCompleteCommands(StringVect &names) const
-{
- names.push_back("/help");
- names.push_back("/invite ");
- names.push_back("/kick ");
- names.push_back("/notice ");
- names.push_back("/leave");
-}
-
-void GuildTab::playNewMessageSound() const
-{
- soundManager.playGuiSound(SOUND_GUILD);
-}
-
-void GuildTab::optionChanged(const std::string &value)
-{
- if (value == "showGuildOnline")
- mShowOnline = config.getBoolValue("showGuildOnline");
-}
diff --git a/src/gui/widgets/tabs/chat/guildtab.h b/src/gui/widgets/tabs/chat/guildtab.h
deleted file mode 100644
index 5aa540ecb..000000000
--- a/src/gui/widgets/tabs/chat/guildtab.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 GUI_WIDGETS_TABS_CHAT_GUILDTAB_H
-#define GUI_WIDGETS_TABS_CHAT_GUILDTAB_H
-
-#include "gui/widgets/tabs/chat/chattab.h"
-
-/**
- * A tab for a guild chat channel.
- */
-class GuildTab notfinal : public ChatTab,
- public ConfigListener
-{
- public:
- explicit GuildTab(const Widget2 *const widget);
-
- A_DELETE_COPY(GuildTab)
-
- virtual ~GuildTab();
-
- bool handleCommand(const std::string &restrict type,
- const std::string &restrict args) override final;
-
- void playNewMessageSound() const override final;
-
- void optionChanged(const std::string &value) override final;
-
- protected:
- void handleInput(const std::string &msg) override final;
-
- void getAutoCompleteList(StringVect &names) const override final;
-
- void getAutoCompleteCommands(StringVect &names) const override final;
-};
-
-#endif // GUI_WIDGETS_TABS_CHAT_GUILDTAB_H
diff --git a/src/gui/widgets/tabs/chat/langtab.cpp b/src/gui/widgets/tabs/chat/langtab.cpp
deleted file mode 100644
index ba1e21711..000000000
--- a/src/gui/widgets/tabs/chat/langtab.cpp
+++ /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/>.
- */
-
-#include "gui/widgets/tabs/chat/langtab.h"
-
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-LangTab *langChatTab = nullptr;
-
-LangTab::LangTab(const Widget2 *const widget,
- const std::string &lang) :
- // TRANSLATORS: lang chat tab name
- ChatTab(widget, _("Lang"), lang + " ", "#Lang", ChatTabType::LANG)
-{
-}
-
-LangTab::~LangTab()
-{
-}
diff --git a/src/gui/widgets/tabs/chat/langtab.h b/src/gui/widgets/tabs/chat/langtab.h
deleted file mode 100644
index 773431e85..000000000
--- a/src/gui/widgets/tabs/chat/langtab.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 GUI_WIDGETS_TABS_CHAT_LANGTAB_H
-#define GUI_WIDGETS_TABS_CHAT_LANGTAB_H
-
-#include "gui/widgets/tabs/chat/chattab.h"
-
-class LangTab final : public ChatTab
-{
- public:
- LangTab(const Widget2 *const widget,
- const std::string &lang);
-
- A_DELETE_COPY(LangTab)
-
- ~LangTab();
-};
-
-extern LangTab *langChatTab;
-
-#endif // GUI_WIDGETS_TABS_CHAT_LANGTAB_H
diff --git a/src/gui/widgets/tabs/chat/partytab.cpp b/src/gui/widgets/tabs/chat/partytab.cpp
deleted file mode 100644
index befbb0393..000000000
--- a/src/gui/widgets/tabs/chat/partytab.cpp
+++ /dev/null
@@ -1,151 +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 "gui/widgets/tabs/chat/partytab.h"
-
-#include "configuration.h"
-#include "party.h"
-#include "soundmanager.h"
-
-#include "being/localplayer.h"
-
-#include "const/sound.h"
-
-#include "gui/windows/chatwindow.h"
-
-#include "input/inputmanager.h"
-
-#include "net/net.h"
-#include "net/partyhandler.h"
-
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-PartyTab *partyTab = nullptr;
-
-PartyTab::PartyTab(const Widget2 *const widget) :
- // TRANSLATORS: party chat tab name
- ChatTab(widget, _("Party"), "", "#Party", ChatTabType::PARTY)
-{
- setTabColors(ThemeColorId::PARTY_CHAT_TAB);
- mShowOnline = config.getBoolValue("showPartyOnline");
- config.addListener("showPartyOnline", this);
-}
-
-PartyTab::~PartyTab()
-{
- config.removeListeners(this);
- CHECKLISTENERS
-}
-
-void PartyTab::handleInput(const std::string &msg)
-{
- partyHandler->chat(ChatWindow::doReplace(msg));
-}
-
-bool PartyTab::handleCommand(const std::string &restrict type,
- const std::string &restrict args)
-{
- if (type == "invite")
- {
- partyHandler->invite(args);
- }
- else if (type == "leave")
- {
- inputManager.executeChatCommand(InputAction::LEAVE_PARTY,
- args,
- this);
- }
- else if (type == "kick")
- {
- inputManager.executeChatCommand(InputAction::KICK_PARTY,
- args,
- this);
- }
- else if (type == "item")
- {
- inputManager.executeChatCommand(InputAction::PARTY_ITEM_SHARE,
- args,
- this);
- }
- else if (type == "autoitem")
- {
- inputManager.executeChatCommand(InputAction::PARTY_AUTO_ITEM_SHARE,
- args,
- this);
- }
- else if (type == "exp")
- {
- inputManager.executeChatCommand(InputAction::PARTY_EXP_SHARE,
- args,
- this);
- }
- else if (type == "setleader" &&
- Net::getNetworkType() != ServerType::TMWATHENA)
- {
- inputManager.executeChatCommand(
- InputAction::COMMAND_CHANGE_PARTY_LEADER,
- args,
- this);
- }
- else
- {
- return false;
- }
-
- return true;
-}
-
-void PartyTab::getAutoCompleteList(StringVect &names) const
-{
- if (localPlayer == nullptr)
- return;
-
- const Party *const p = localPlayer->getParty();
-
- if (p != nullptr)
- p->getNames(names);
-}
-
-void PartyTab::getAutoCompleteCommands(StringVect &names) const
-{
- names.push_back("/help");
- names.push_back("/invite ");
- names.push_back("/leave");
- names.push_back("/kick ");
- names.push_back("/item");
- names.push_back("/exp");
- if (Net::getNetworkType() != ServerType::TMWATHENA)
- names.push_back("/setleader ");
-}
-
-void PartyTab::playNewMessageSound() const
-{
- soundManager.playGuiSound(SOUND_GUILD);
-}
-
-void PartyTab::optionChanged(const std::string &value)
-{
- if (value == "showPartyOnline")
- mShowOnline = config.getBoolValue("showPartyOnline");
-}
diff --git a/src/gui/widgets/tabs/chat/partytab.h b/src/gui/widgets/tabs/chat/partytab.h
deleted file mode 100644
index a987c9362..000000000
--- a/src/gui/widgets/tabs/chat/partytab.h
+++ /dev/null
@@ -1,58 +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 GUI_WIDGETS_TABS_CHAT_PARTYTAB_H
-#define GUI_WIDGETS_TABS_CHAT_PARTYTAB_H
-
-#include "gui/widgets/tabs/chat/chattab.h"
-
-/**
- * A tab for a party chat channel.
- */
-class PartyTab notfinal : public ChatTab,
- public ConfigListener
-{
- public:
- explicit PartyTab(const Widget2 *const widget);
-
- A_DELETE_COPY(PartyTab)
-
- virtual ~PartyTab();
-
- bool handleCommand(const std::string &restrict type,
- const std::string &restrict args) override final;
-
- void playNewMessageSound() const override final;
-
- void optionChanged(const std::string &value) override final;
-
- protected:
- void handleInput(const std::string &msg) override final;
-
- void getAutoCompleteList(StringVect &names) const override final;
-
- void getAutoCompleteCommands(StringVect &names) const override final;
-};
-
-extern PartyTab *partyTab;
-
-#endif // GUI_WIDGETS_TABS_CHAT_PARTYTAB_H
diff --git a/src/gui/widgets/tabs/chat/tradetab.cpp b/src/gui/widgets/tabs/chat/tradetab.cpp
deleted file mode 100644
index e16e5c08b..000000000
--- a/src/gui/widgets/tabs/chat/tradetab.cpp
+++ /dev/null
@@ -1,50 +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 "gui/widgets/tabs/chat/tradetab.h"
-
-#include "const/gui/chat.h"
-
-#include "gui/windows/chatwindow.h"
-
-#include "net/chathandler.h"
-
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-TradeTab *tradeChatTab = nullptr;
-
-TradeTab::TradeTab(const Widget2 *const widget) :
- // TRANSLATORS: trade chat tab name
- ChatTab(widget, _("Trade"), TRADE_CHANNEL, "#Trade", ChatTabType::TRADE)
-{
-}
-
-TradeTab::~TradeTab()
-{
-}
-
-void TradeTab::handleInput(const std::string &msg)
-{
- chatHandler->channelMessage(mChannelName, ChatWindow::doReplace(msg));
-}
diff --git a/src/gui/widgets/tabs/chat/tradetab.h b/src/gui/widgets/tabs/chat/tradetab.h
deleted file mode 100644
index 26c9bf8f6..000000000
--- a/src/gui/widgets/tabs/chat/tradetab.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 GUI_WIDGETS_TABS_CHAT_TRADETAB_H
-#define GUI_WIDGETS_TABS_CHAT_TRADETAB_H
-
-#include "gui/widgets/tabs/chat/chattab.h"
-
-/**
- * A tab for a party chat channel.
- */
-class TradeTab final : public ChatTab
-{
- public:
- explicit TradeTab(const Widget2 *const widget);
-
- A_DELETE_COPY(TradeTab)
-
- ~TradeTab();
-
- protected:
- void handleInput(const std::string &msg) override final;
-};
-
-extern TradeTab *tradeChatTab;
-
-#endif // GUI_WIDGETS_TABS_CHAT_TRADETAB_H
diff --git a/src/gui/widgets/tabs/chat/whispertab.cpp b/src/gui/widgets/tabs/chat/whispertab.cpp
deleted file mode 100644
index 73b73a17c..000000000
--- a/src/gui/widgets/tabs/chat/whispertab.cpp
+++ /dev/null
@@ -1,130 +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 "gui/widgets/tabs/chat/whispertab.h"
-
-#include "being/localplayer.h"
-
-#include "net/chathandler.h"
-
-#include "gui/windows/chatwindow.h"
-
-#include "gui/widgets/windowcontainer.h"
-
-#include "utils/chatutils.h"
-
-#include "debug.h"
-
-WhisperTab::WhisperTab(const Widget2 *const widget,
- const std::string &caption,
- const std::string &nick) :
- ChatTab(widget, caption, nick, nick, ChatTabType::WHISPER),
- mNick(nick)
-{
- setWhisperTabColors();
-}
-
-WhisperTab::~WhisperTab()
-{
- if (chatWindow != nullptr)
- chatWindow->removeWhisper(mNick);
-}
-
-void WhisperTab::handleInput(const std::string &msg)
-{
- std::string newMsg;
- newMsg = ChatWindow::doReplace(msg);
- chatHandler->privateMessage(mNick, newMsg);
-
- if (localPlayer != nullptr)
- chatLog(localPlayer->getName(), newMsg);
- else
- chatLog("?", newMsg);
-}
-
-void WhisperTab::handleCommandStr(const std::string &msg)
-{
- if (msg == "close")
- {
- delete this;
- return;
- }
-
- const size_t pos = msg.find(' ');
- const std::string type(msg, 0, pos);
-
- if (type == "me")
- {
- const std::string args(msg, pos == std::string::npos
- ? msg.size() : pos + 1);
- std::string str = textToMe(args);
- chatHandler->privateMessage(mNick, str);
- if (localPlayer != nullptr)
- chatLog(localPlayer->getName(), str);
- else
- chatLog("?", str);
- }
- else
- {
- ChatTab::handleCommandStr(msg);
- }
-}
-
-bool WhisperTab::handleCommand(const std::string &restrict type,
- const std::string &restrict args A_UNUSED)
-{
- if (type == "close")
- {
- if (windowContainer != nullptr)
- windowContainer->scheduleDelete(this);
- else
- delete this;
- if (chatWindow != nullptr)
- chatWindow->defaultTab();
- }
- else
- {
- return false;
- }
-
- return true;
-}
-
-void WhisperTab::getAutoCompleteList(StringVect &names) const
-{
- names.push_back(mNick);
-}
-
-void WhisperTab::getAutoCompleteCommands(StringVect& commands) const
-{
- commands.push_back("/close");
-}
-
-void WhisperTab::setWhisperTabColors()
-{
- setTabColors(ThemeColorId::WHISPER_TAB);
-}
-
-void WhisperTab::setWhisperTabOfflineColors()
-{
- setTabColors(ThemeColorId::WHISPER_TAB_OFFLINE);
-}
diff --git a/src/gui/widgets/tabs/chat/whispertab.h b/src/gui/widgets/tabs/chat/whispertab.h
deleted file mode 100644
index 1d3c03857..000000000
--- a/src/gui/widgets/tabs/chat/whispertab.h
+++ /dev/null
@@ -1,73 +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 GUI_WIDGETS_TABS_CHAT_WHISPERTAB_H
-#define GUI_WIDGETS_TABS_CHAT_WHISPERTAB_H
-
-#include "gui/widgets/tabs/chat/chattab.h"
-
-/**
- * A tab for whispers from a single player.
- */
-class WhisperTab final : public ChatTab
-{
- public:
- A_DELETE_COPY(WhisperTab)
-
- const std::string &getNick() const noexcept2 A_WARN_UNUSED
- { return mNick; }
-
- bool handleCommand(const std::string &restrict type,
- const std::string &restrict args) override final;
-
- void setWhisperTabColors();
-
- void setWhisperTabOfflineColors();
-
- protected:
- friend class ChatWindow;
-
- void getAutoCompleteList(StringVect &names) const override final;
-
- void getAutoCompleteCommands(StringVect& commands)
- const override final;
-
- /**
- * Constructor.
- *
- * @param nick the name of the player this tab is whispering to
- */
- WhisperTab(const Widget2 *const widget,
- const std::string &caption,
- const std::string &nick);
-
- ~WhisperTab();
-
- void handleInput(const std::string &msg) override final;
-
- void handleCommandStr(const std::string &msg) override final;
-
- private:
- std::string mNick;
-};
-
-#endif // GUI_WIDGETS_TABS_CHAT_WHISPERTAB_H
diff --git a/src/gui/widgets/tabs/debugwindowtabs.cpp b/src/gui/widgets/tabs/debugwindowtabs.cpp
deleted file mode 100644
index 321c3bcad..000000000
--- a/src/gui/widgets/tabs/debugwindowtabs.cpp
+++ /dev/null
@@ -1,492 +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 "gui/widgets/tabs/debugwindowtabs.h"
-
-#include "game.h"
-
-#include "being/localplayer.h"
-
-#include "particle/particleengine.h"
-
-#include "gui/viewport.h"
-
-#include "gui/widgets/containerplacer.h"
-#include "gui/widgets/label.h"
-#include "gui/widgets/layouthelper.h"
-
-#ifdef USE_OPENGL
-#include "resources/imagehelper.h"
-#endif // USE_OPENGL
-
-#include "resources/map/map.h"
-
-#include "net/packetcounters.h"
-
-#include "utils/gettext.h"
-#include "utils/stringutils.h"
-#include "utils/timer.h"
-
-#include "debug.h"
-
-MapDebugTab::MapDebugTab(const Widget2 *const widget) :
- DebugTab(widget),
- // TRANSLATORS: debug window label
- mMusicFileLabel(new Label(this, _("Music:"))),
- // TRANSLATORS: debug window label
- mMapLabel(new Label(this, _("Map:"))),
- // TRANSLATORS: debug window label
- mMapNameLabel(new Label(this, _("Map name:"))),
- // TRANSLATORS: debug window label
- mMinimapLabel(new Label(this, _("Minimap:"))),
- mTileMouseLabel(new Label(this, strprintf("%s (%d, %d)",
- // TRANSLATORS: debug window label
- _("Cursor:"), 0, 0))),
- mParticleCountLabel(new Label(this, strprintf("%s %d",
- // TRANSLATORS: debug window label
- _("Particle count:"), 88888))),
- mMapActorCountLabel(new Label(this, strprintf("%s %d",
- // TRANSLATORS: debug window label
- _("Map actors count:"), 88888))),
- // TRANSLATORS: debug window label
- mXYLabel(new Label(this, strprintf("%s (?,?)", _("Player Position:")))),
- mTexturesLabel(nullptr),
- mUpdateTime(0),
-#ifdef DEBUG_DRAW_CALLS
- mDrawCallsLabel(new Label(this, strprintf("%s %s",
- // TRANSLATORS: debug window label
- _("Draw calls:"), "?"))),
-#endif // DEBUG_DRAW_CALLS
-#ifdef DEBUG_BIND_TEXTURE
- mBindsLabel(new Label(this, strprintf("%s %s",
- // TRANSLATORS: debug window label
- _("Texture binds:"), "?"))),
-#endif // DEBUG_BIND_TEXTURE
- // TRANSLATORS: debug window label, frames per second
- mFPSLabel(new Label(this, strprintf(_("%d FPS"), 0))),
- // TRANSLATORS: debug window label, logic per second
- mLPSLabel(new Label(this, strprintf(_("%d LPS"), 0))),
- mFPSText()
-{
- LayoutHelper h(this);
- ContainerPlacer place = h.getPlacer(0, 0);
-
-#ifdef USE_OPENGL
- switch (imageHelper->useOpenGL())
- {
- case RENDER_SOFTWARE:
- // TRANSLATORS: debug window label
- mFPSText = _("%d FPS (Software)");
- break;
- case RENDER_NORMAL_OPENGL:
- case RENDER_NULL:
- case RENDER_LAST:
- default:
- // TRANSLATORS: debug window label
- mFPSText = _("%d FPS (normal OpenGL)");
- break;
- case RENDER_SAFE_OPENGL:
- // TRANSLATORS: debug window label
- mFPSText = _("%d FPS (safe OpenGL)");
- break;
- case RENDER_GLES_OPENGL:
- // TRANSLATORS: debug window label
- mFPSText = _("%d FPS (mobile OpenGL ES)");
- break;
- case RENDER_GLES2_OPENGL:
- // TRANSLATORS: debug window label
- mFPSText = _("%d FPS (mobile OpenGL ES 2)");
- break;
- case RENDER_MODERN_OPENGL:
- // TRANSLATORS: debug window label
- mFPSText = _("%d FPS (modern OpenGL)");
- break;
- case RENDER_SDL2_DEFAULT:
- // TRANSLATORS: debug window label
- mFPSText = _("%d FPS (SDL2 default)");
- break;
- };
-#else // USE_OPENGL
-
- // TRANSLATORS: debug window label
- mFPSText = _("%d FPS (Software)");
-#endif // USE_OPENGL
-
- place(0, 0, mFPSLabel, 2);
- place(0, 1, mLPSLabel, 2);
- place(0, 2, mMusicFileLabel, 2);
- place(0, 3, mMapLabel, 2);
- place(0, 4, mMapNameLabel, 2);
- place(0, 5, mMinimapLabel, 2);
- place(0, 6, mXYLabel, 2);
- place(0, 7, mTileMouseLabel, 2);
- place(0, 8, mParticleCountLabel, 2);
- place(0, 9, mMapActorCountLabel, 2);
-#ifdef USE_OPENGL
-#if defined (DEBUG_OPENGL_LEAKS) || defined(DEBUG_DRAW_CALLS) \
- || defined(DEBUG_BIND_TEXTURE)
- int n = 10;
-#endif // defined (DEBUG_OPENGL_LEAKS) || defined(DEBUG_DRAW_CALLS)
- // || defined(DEBUG_BIND_TEXTURE)
-#ifdef DEBUG_OPENGL_LEAKS
- mTexturesLabel = new Label(this, strprintf("%s %s",
- // TRANSLATORS: debug window label
- _("Textures count:"), "?"));
- place(0, n, mTexturesLabel, 2);
- n ++;
-#endif // DEBUG_OPENGL_LEAKS
-#ifdef DEBUG_DRAW_CALLS
- place(0, n, mDrawCallsLabel, 2);
- n ++;
-#endif // DEBUG_DRAW_CALLS
-#ifdef DEBUG_BIND_TEXTURE
- place(0, n, mBindsLabel, 2);
-#endif // DEBUG_BIND_TEXTURE
-#endif // USE_OPENGL
-
- place.getCell().matchColWidth(0, 0);
- place = h.getPlacer(0, 1);
- setDimension(Rect(0, 0, 600, 300));
-}
-
-void MapDebugTab::logic()
-{
- BLOCK_START("MapDebugTab::logic")
- if (localPlayer != nullptr)
- {
- // TRANSLATORS: debug window label
- mXYLabel->setCaption(strprintf("%s (%d, %d)", _("Player Position:"),
- localPlayer->getTileX(), localPlayer->getTileY()));
- }
- else
- {
- // TRANSLATORS: debug window label
- mXYLabel->setCaption(strprintf("%s (?, ?)", _("Player Position:")));
- }
-
- Game *const game = Game::instance();
- const Map *const map = game != nullptr ? game->getCurrentMap() : nullptr;
- if (map != nullptr &&
- viewport != nullptr)
- {
- // Get the current mouse position
- const int mouseTileX = (viewport->mMouseX + viewport->getCameraX())
- / map->getTileWidth();
- const int mouseTileY = (viewport->mMouseY + viewport->getCameraY())
- / map->getTileHeight();
- mTileMouseLabel->setCaption(strprintf("%s (%d, %d)",
- // TRANSLATORS: debug window label
- _("Cursor:"), mouseTileX, mouseTileY));
-
- // TRANSLATORS: debug window label
- mMusicFileLabel->setCaption(strprintf("%s %s", _("Music:"),
- map->getProperty("music").c_str()));
- // TRANSLATORS: debug window label
- mMinimapLabel->setCaption(strprintf("%s %s", _("Minimap:"),
- map->getProperty("minimap").c_str()));
- // TRANSLATORS: debug window label
- mMapLabel->setCaption(strprintf("%s %s", _("Map:"),
- map->getProperty("_realfilename").c_str()));
- // TRANSLATORS: debug window label
- mMapNameLabel->setCaption(strprintf("%s %s", _("Map name:"),
- map->getProperty("name").c_str()));
-
- if (mUpdateTime != cur_time)
- {
- mUpdateTime = cur_time;
- // TRANSLATORS: debug window label
- mParticleCountLabel->setCaption(strprintf(_("Particle count: %d"),
- ParticleEngine::particleCount));
-
- mMapActorCountLabel->setCaption(
- // TRANSLATORS: debug window label
- strprintf("%s %d", _("Map actors count:"),
- map->getActorsCount()));
-#ifdef USE_OPENGL
-#ifdef DEBUG_OPENGL_LEAKS
- mTexturesLabel->setCaption(strprintf("%s %d",
- // TRANSLATORS: debug window label
- _("Textures count:"), textures_count));
-#endif // DEBUG_OPENGL_LEAKS
-#ifdef DEBUG_DRAW_CALLS
- if (mainGraphics)
- {
- mDrawCallsLabel->setCaption(strprintf("%s %d",
- // TRANSLATORS: debug window label
- _("Draw calls:"), mainGraphics->getDrawCalls()));
- }
-#endif // DEBUG_DRAW_CALLS
-#ifdef DEBUG_BIND_TEXTURE
- if (mainGraphics)
- {
- mBindsLabel->setCaption(strprintf("%s %d",
- // TRANSLATORS: debug window label
- _("Texture binds:"), mainGraphics->getBinds()));
- }
-#endif // DEBUG_BIND_TEXTURE
-#endif // USE_OPENGL
- }
- }
- else
- {
- // TRANSLATORS: debug window label
- mTileMouseLabel->setCaption(strprintf("%s (?, ?)", _("Cursor:")));
- // TRANSLATORS: debug window label
- mMusicFileLabel->setCaption(strprintf("%s ?", _("Music:")));
- // TRANSLATORS: debug window label
- mMinimapLabel->setCaption(strprintf("%s ?", _("Minimap:")));
- // TRANSLATORS: debug window label
- mMapLabel->setCaption(strprintf("%s ?", _("Map:")));
- // TRANSLATORS: debug window label
- mMapNameLabel->setCaption(strprintf("%s ?", _("Map name:")));
-
- mMapActorCountLabel->setCaption(
- // TRANSLATORS: debug window label
- strprintf("%s ?", _("Map actors count:")));
- }
-
- mMapActorCountLabel->adjustSize();
- mParticleCountLabel->adjustSize();
-
- mFPSLabel->setCaption(strprintf(mFPSText.c_str(), fps));
- // TRANSLATORS: debug window label, logic per second
- mLPSLabel->setCaption(strprintf(_("%d LPS"), lps));
- BLOCK_END("MapDebugTab::logic")
-}
-
-TargetDebugTab::TargetDebugTab(const Widget2 *const widget) :
- DebugTab(widget),
- // TRANSLATORS: debug window label
- mTargetLabel(new Label(this, strprintf("%s ?", _("Target:")))),
- // TRANSLATORS: debug window label
- mTargetIdLabel(new Label(this, strprintf("%s ? ", _("Target Id:")))),
- mTargetTypeLabel(new Label(this, strprintf(
- // TRANSLATORS: debug window label
- "%s ? ", _("Target type:")))),
- // TRANSLATORS: debug window label
- mTargetLevelLabel(new Label(this, strprintf("%s ?", _("Target level:")))),
- // TRANSLATORS: debug window label
- mTargetRaceLabel(new Label(this, strprintf("%s ?", _("Target race:")))),
- // TRANSLATORS: debug window label
- mTargetPartyLabel(new Label(this, strprintf("%s ?", _("Target party:")))),
- // TRANSLATORS: debug window label
- mTargetGuildLabel(new Label(this, strprintf("%s ?", _("Target guild:")))),
- // TRANSLATORS: debug window label
- mAttackDelayLabel(new Label(this, strprintf("%s ?", _("Attack delay:")))),
- // TRANSLATORS: debug window label
- mMinHitLabel(new Label(this, strprintf("%s ?", _("Minimal hit:")))),
- // TRANSLATORS: debug window label
- mMaxHitLabel(new Label(this, strprintf("%s ?", _("Maximum hit:")))),
- // TRANSLATORS: debug window label
- mCriticalHitLabel(new Label(this, strprintf("%s ?", _("Critical hit:")))),
- // TRANSLATORS: debug window label
- mKarmaLabel(new Label(this, strprintf("%s ?", _("Karma:")))),
- // TRANSLATORS: debug window label
- mMannerLabel(new Label(this, strprintf("%s ?", _("Manner:")))),
- // TRANSLATORS: debug window label
- mEffectsLabel(new Label(this, strprintf("%s ?", _("Effects:"))))
-{
- LayoutHelper h(this);
- ContainerPlacer place = h.getPlacer(0, 0);
-
- place(0, 0, mTargetLabel, 2);
- place(0, 1, mTargetIdLabel, 2);
- place(0, 2, mTargetTypeLabel, 2);
- place(0, 3, mTargetLevelLabel, 2);
- place(0, 4, mTargetRaceLabel, 2);
- place(0, 5, mAttackDelayLabel, 2);
- place(0, 6, mTargetPartyLabel, 2);
- place(0, 7, mTargetGuildLabel, 2);
- place(0, 8, mMinHitLabel, 2);
- place(0, 9, mMaxHitLabel, 2);
- place(0, 10, mCriticalHitLabel, 2);
- place(0, 11, mKarmaLabel, 2);
- place(0, 12, mMannerLabel, 2);
- place(0, 13, mEffectsLabel, 2);
-
- place.getCell().matchColWidth(0, 0);
- place = h.getPlacer(0, 1);
- setDimension(Rect(0, 0, 600, 300));
-}
-
-void TargetDebugTab::logic()
-{
- BLOCK_START("TargetDebugTab::logic")
- if ((localPlayer != nullptr) && (localPlayer->getTarget() != nullptr))
- {
- const Being *const target = localPlayer->getTarget();
-
- // TRANSLATORS: debug window label
- mTargetLabel->setCaption(strprintf("%s %s (%d, %d)", _("Target:"),
- target->getName().c_str(), target->getTileX(),
- target->getTileY()));
-
- mTargetIdLabel->setCaption(strprintf("%s %d",
- // TRANSLATORS: debug window label
- _("Target Id:"), toInt(target->getId(), int)));
- mTargetTypeLabel->setCaption(strprintf("%s %d",
- // TRANSLATORS: debug window label
- _("Target type:"), toInt(target->getSubType(), int)));
- if (target->getLevel() != 0)
- {
- mTargetLevelLabel->setCaption(strprintf("%s %d",
- // TRANSLATORS: debug window label
- _("Target Level:"), target->getLevel()));
- }
- else
- {
- mTargetLevelLabel->setCaption(strprintf("%s ?",
- // TRANSLATORS: debug window label
- _("Target Level:")));
- }
-
- mTargetRaceLabel->setCaption(strprintf("%s %s",
- // TRANSLATORS: debug window label
- _("Target race:"), target->getRaceName().c_str()));
-
- // TRANSLATORS: debug window label
- mTargetPartyLabel->setCaption(strprintf("%s %s", _("Target Party:"),
- target->getPartyName().c_str()));
-
- // TRANSLATORS: debug window label
- mTargetGuildLabel->setCaption(strprintf("%s %s", _("Target Guild:"),
- target->getGuildName().c_str()));
-
- mMinHitLabel->setCaption(strprintf("%s %d",
- // TRANSLATORS: debug window label
- _("Minimal hit:"), target->getMinHit()));
- mMaxHitLabel->setCaption(strprintf("%s %d",
- // TRANSLATORS: debug window label
- _("Maximum hit:"), target->getMaxHit()));
- mCriticalHitLabel->setCaption(strprintf("%s %d",
- // TRANSLATORS: debug window label
- _("Critical hit:"), target->getCriticalHit()));
- mKarmaLabel->setCaption(strprintf("%s %d",
- // TRANSLATORS: debug window label
- _("Karma:"), target->getKarma()));
- mMannerLabel->setCaption(strprintf("%s %d",
- // TRANSLATORS: debug window label
- _("Manner:"), target->getManner()));
- mEffectsLabel->setCaption(strprintf("%s %s",
- // TRANSLATORS: debug window label
- _("Effects:"), target->getStatusEffectsString().c_str()));
-
- const int delay = target->getAttackDelay();
- if (delay != 0)
- {
- mAttackDelayLabel->setCaption(strprintf("%s %d",
- // TRANSLATORS: debug window label
- _("Attack delay:"), delay));
- }
- else
- {
- mAttackDelayLabel->setCaption(strprintf(
- // TRANSLATORS: debug window label
- "%s ?", _("Attack delay:")));
- }
- }
- else
- {
- // TRANSLATORS: debug window label
- mTargetLabel->setCaption(strprintf("%s ?", _("Target:")));
- // TRANSLATORS: debug window label
- mTargetIdLabel->setCaption(strprintf("%s ?", _("Target Id:")));
- // TRANSLATORS: debug window label
- mTargetTypeLabel->setCaption(strprintf("%s ?", _("Target type:")));
- // TRANSLATORS: debug window label
- mTargetLevelLabel->setCaption(strprintf("%s ?", _("Target Level:")));
- // TRANSLATORS: debug window label
- mTargetPartyLabel->setCaption(strprintf("%s ?", _("Target Party:")));
- // TRANSLATORS: debug window label
- mTargetGuildLabel->setCaption(strprintf("%s ?", _("Target Guild:")));
- // TRANSLATORS: debug window label
- mAttackDelayLabel->setCaption(strprintf("%s ?", _("Attack delay:")));
- // TRANSLATORS: debug window label
- mMinHitLabel->setCaption(strprintf("%s ?", _("Minimal hit:")));
- // TRANSLATORS: debug window label
- mMaxHitLabel->setCaption(strprintf("%s ?", _("Maximum hit:")));
- // TRANSLATORS: debug window label
- mCriticalHitLabel->setCaption(strprintf("%s ?", _("Critical hit:")));
- // TRANSLATORS: debug window label
- mKarmaLabel->setCaption(strprintf("%s ?", _("Karma:")));
- // TRANSLATORS: debug window label
- mMannerLabel->setCaption(strprintf("%s ?", _("Manner:")));
- // TRANSLATORS: debug window label
- mEffectsLabel->setCaption(strprintf("%s ?", _("Effects:")));
- }
-
- mTargetLabel->adjustSize();
- mTargetIdLabel->adjustSize();
- mTargetTypeLabel->adjustSize();
- mTargetLevelLabel->adjustSize();
- mTargetPartyLabel->adjustSize();
- mTargetGuildLabel->adjustSize();
- mAttackDelayLabel->adjustSize();
- mMinHitLabel->adjustSize();
- mMaxHitLabel->adjustSize();
- mCriticalHitLabel->adjustSize();
- mKarmaLabel->adjustSize();
- mMannerLabel->adjustSize();
- mEffectsLabel->adjustSize();
- BLOCK_END("TargetDebugTab::logic")
-}
-
-NetDebugTab::NetDebugTab(const Widget2 *const widget) :
- DebugTab(widget),
- mPingLabel(new Label(this, " ")),
- mInPackets1Label(new Label(this, " ")),
- mOutPackets1Label(new Label(this, " "))
-{
- LayoutHelper h(this);
- ContainerPlacer place = h.getPlacer(0, 0);
-
- place(0, 0, mPingLabel, 2);
- place(0, 1, mInPackets1Label, 2);
- place(0, 2, mOutPackets1Label, 2);
-
- place.getCell().matchColWidth(0, 0);
- place = h.getPlacer(0, 1);
- setDimension(Rect(0, 0, 600, 300));
-}
-
-void NetDebugTab::logic()
-{
- BLOCK_START("NetDebugTab::logic")
- if (localPlayer != nullptr)
- {
- // TRANSLATORS: debug window label
- mPingLabel->setCaption(strprintf(_("Ping: %s ms"),
- localPlayer->getPingTime().c_str()));
- }
- else
- {
- // TRANSLATORS: debug window label
- mPingLabel->setCaption(strprintf(_("Ping: %s ms"), "0"));
- }
- // TRANSLATORS: debug window label
- mInPackets1Label->setCaption(strprintf(_("In: %d bytes/s"),
- PacketCounters::getInBytes()));
- // TRANSLATORS: debug window label
- mOutPackets1Label->setCaption(strprintf(_("Out: %d bytes/s"),
- PacketCounters::getOutBytes()));
- BLOCK_END("NetDebugTab::logic")
-}
diff --git a/src/gui/widgets/tabs/debugwindowtabs.h b/src/gui/widgets/tabs/debugwindowtabs.h
deleted file mode 100644
index 566987cd0..000000000
--- a/src/gui/widgets/tabs/debugwindowtabs.h
+++ /dev/null
@@ -1,129 +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_TABS_DEBUGWINDOWTABS_H
-#define GUI_WIDGETS_TABS_DEBUGWINDOWTABS_H
-
-#include "gui/widgets/container.h"
-
-class Label;
-
-class DebugTab notfinal : public Container
-{
- friend class DebugWindow;
-
- public:
- A_DELETE_COPY(DebugTab)
-
- void logic() override
- {
- }
-
- void resize(const int x, const int y)
- { setDimension(Rect(0, 0, x, y)); }
-
- protected:
- explicit DebugTab(const Widget2 *const widget) :
- Container(widget)
- { setSelectable(false); }
-};
-
-class MapDebugTab final : public DebugTab
-{
- friend class DebugWindow;
-
- public:
- explicit MapDebugTab(const Widget2 *const widget);
-
- A_DELETE_COPY(MapDebugTab)
-
- void logic() override final;
-
- private:
- Label *mMusicFileLabel A_NONNULLPOINTER;
- Label *mMapLabel A_NONNULLPOINTER;
- Label *mMapNameLabel A_NONNULLPOINTER;
- Label *mMinimapLabel A_NONNULLPOINTER;
- Label *mTileMouseLabel A_NONNULLPOINTER;
- Label *mParticleCountLabel A_NONNULLPOINTER;
- Label *mMapActorCountLabel A_NONNULLPOINTER;
- Label *mXYLabel A_NONNULLPOINTER;
- Label *mTexturesLabel A_NONNULLPOINTER;
- time_t mUpdateTime;
-#ifdef DEBUG_DRAW_CALLS
- Label *mDrawCallsLabel A_NONNULLPOINTER;
-#endif // DEBUG_DRAW_CALLS
-#ifdef DEBUG_BIND_TEXTURE
- Label *mBindsLabel A_NONNULLPOINTER;
-#endif // DEBUG_BIND_TEXTURE
-
- Label *mFPSLabel A_NONNULLPOINTER;
- Label *mLPSLabel A_NONNULLPOINTER;
- std::string mFPSText;
-};
-
-class TargetDebugTab final : public DebugTab
-{
- friend class DebugWindow;
-
- public:
- explicit TargetDebugTab(const Widget2 *const widget);
-
- A_DELETE_COPY(TargetDebugTab)
-
- void logic() override final;
-
- private:
- Label *mTargetLabel A_NONNULLPOINTER;
- Label *mTargetIdLabel A_NONNULLPOINTER;
- Label *mTargetTypeLabel A_NONNULLPOINTER;
- Label *mTargetLevelLabel A_NONNULLPOINTER;
- Label *mTargetRaceLabel A_NONNULLPOINTER;
- Label *mTargetPartyLabel A_NONNULLPOINTER;
- Label *mTargetGuildLabel A_NONNULLPOINTER;
- Label *mAttackDelayLabel A_NONNULLPOINTER;
- Label *mMinHitLabel A_NONNULLPOINTER;
- Label *mMaxHitLabel A_NONNULLPOINTER;
- Label *mCriticalHitLabel A_NONNULLPOINTER;
- Label *mKarmaLabel A_NONNULLPOINTER;
- Label *mMannerLabel A_NONNULLPOINTER;
- Label *mEffectsLabel A_NONNULLPOINTER;
-};
-
-class NetDebugTab final : public DebugTab
-{
- friend class DebugWindow;
-
- public:
- explicit NetDebugTab(const Widget2 *const widget);
-
- A_DELETE_COPY(NetDebugTab)
-
- void logic() override final;
-
- private:
- Label *mPingLabel A_NONNULLPOINTER;
- Label *mInPackets1Label A_NONNULLPOINTER;
- Label *mOutPackets1Label A_NONNULLPOINTER;
-};
-
-#endif // GUI_WIDGETS_TABS_DEBUGWINDOWTABS_H
diff --git a/src/gui/widgets/tabs/setup_audio.cpp b/src/gui/widgets/tabs/setup_audio.cpp
deleted file mode 100644
index 6275ff59a..000000000
--- a/src/gui/widgets/tabs/setup_audio.cpp
+++ /dev/null
@@ -1,214 +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 "gui/widgets/tabs/setup_audio.h"
-
-#include "resources/map/map.h"
-
-#include "configuration.h"
-#include "soundmanager.h"
-
-#include "gui/viewport.h"
-
-#include "gui/models/soundsmodel.h"
-
-#include "gui/widgets/containerplacer.h"
-#include "gui/widgets/layouthelper.h"
-#include "gui/widgets/scrollarea.h"
-
-#include "utils/delete2.h"
-
-#include "debug.h"
-
-Setup_Audio::Setup_Audio(const Widget2 *const widget) :
- SetupTabScroll(widget),
- mSoundModel(new SoundsModel),
- mChannelsList(new SetupItemNames)
-{
- // TRANSLATORS: audio tab in settings
- setName(_("Audio"));
-
- // Do the layout
- LayoutHelper h(this);
- ContainerPlacer place = h.getPlacer(0, 0);
- place(0, 0, mScroll, 10, 10);
-
- // TRANSLATORS: settings option
- new SetupItemLabel(_("Basic settings"), "", this);
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Enable Audio"), "", "sound", this, "soundEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Enable music"), "",
- "playMusic", this, "playMusicEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Enable game sfx"), "",
- "playBattleSound", this, "playBattleSoundEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Enable gui sfx"), "",
- "playGuiSound", this, "playGuiSoundEvent");
-
- // TRANSLATORS: settings option
- new SetupItemSlider(_("Sfx volume"), "", "sfxVolume",
- this, "sfxVolumeEvent", 0, SoundManager::getMaxVolume(), 1,
- 150,
- OnTheFly_true,
- MainConfig_true);
-
- // TRANSLATORS: settings option
- new SetupItemSlider(_("Music volume"), "", "musicVolume",
- this, "musicVolumeEvent", 0, SoundManager::getMaxVolume(), 1,
- 150,
- OnTheFly_true,
- MainConfig_true);
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Enable music fade out"), "",
- "fadeoutmusic", this, "fadeoutmusicEvent");
-
- // TRANSLATORS: settings option
- new SetupItemIntTextField(_("Audio frequency"), "",
- "audioFrequency", this, "audioFrequencyEvent", 14000, 192000);
-
- // TRANSLATORS: audio type
- mChannelsList->push_back(_("mono"));
- // TRANSLATORS: audio type
- mChannelsList->push_back(_("stereo"));
- // TRANSLATORS: audio type
- mChannelsList->push_back(_("surround"));
- // TRANSLATORS: audio type
- mChannelsList->push_back(_("surround+center+lfe"));
- // TRANSLATORS: settings option
- new SetupItemSlider2(_("Audio channels"), "", "audioChannels", this,
- "audioChannels", 1, 4, 1, mChannelsList,
- OnTheFly_false,
- MainConfig_true,
- DoNotAlign_false);
-
- // TRANSLATORS: settings option
- new SetupItemIntTextField(_("Parallel number of sounds"), "",
- "parallelAudioChannels", this, "parallelAudioChannelsEvent", 1, 1000);
-
-
- // TRANSLATORS: settings group
- new SetupItemLabel(_("Sound effects"), "", this);
-
- // TRANSLATORS: settings option
- new SetupItemSound(_("Information dialog sound"), "",
- "soundinfo", this, "soundinfoEvent", mSoundModel);
-
- // TRANSLATORS: settings option
- new SetupItemSound(_("Request dialog sound"), "",
- "soundrequest", this, "soundrequestEvent", mSoundModel);
-
- // TRANSLATORS: settings option
- new SetupItemSound(_("Whisper message sound"), "",
- "soundwhisper", this, "soundwhisperEvent", mSoundModel);
-
- // TRANSLATORS: settings option
- new SetupItemSound(_("Guild / Party message sound"), "",
- "soundguild", this, "soundguildEvent", mSoundModel);
-
- // TRANSLATORS: settings option
- new SetupItemSound(_("Highlight message sound"), "",
- "soundhighlight", this, "soundhighlightEvent", mSoundModel);
-
- // TRANSLATORS: settings option
- new SetupItemSound(_("Global message sound"), "",
- "soundglobal", this, "soundglobalEvent", mSoundModel);
-
- // TRANSLATORS: settings option
- new SetupItemSound(_("Error message sound"), "",
- "sounderror", this, "sounderrorEvent", mSoundModel);
-
- // TRANSLATORS: settings option
- new SetupItemSound(_("Trade request sound"), "",
- "soundtrade", this, "soundtradeEvent", mSoundModel);
-
- // TRANSLATORS: settings option
- new SetupItemSound(_("Show window sound"), "",
- "soundshowwindow", this, "soundshowwindowEvent", mSoundModel);
-
- // TRANSLATORS: settings option
- new SetupItemSound(_("Hide window sound"), "",
- "soundhidewindow", this, "soundhidewindowEvent", mSoundModel);
-
- // TRANSLATORS: settings group
- new SetupItemLabel(_("Other"), "", this);
-
-#ifdef USE_MUMBLE
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Enable mumble voice chat"), "",
- "enableMumble", this, "enableMumbleEvent");
-#endif // USE_MUMBLE
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Download music"), "",
- "download-music", this, "download-musicEvent");
-
- setDimension(Rect(0, 0, 550, 350));
-}
-
-Setup_Audio::~Setup_Audio()
-{
- delete2(mSoundModel);
- delete2(mChannelsList);
-}
-
-void Setup_Audio::apply()
-{
- SetupTabScroll::apply();
- if (config.getBoolValue("sound"))
- {
- soundManager.init();
- if (config.getBoolValue("playMusic"))
- {
- if (viewport != nullptr)
- { // in game
- const Map *const map = viewport->getMap();
- if (map != nullptr)
- {
- soundManager.playMusic(map->getMusicFile(),
- SkipError_false);
- }
- }
- else
- { // not in game
- soundManager.playMusic(branding.getValue(
- "loginMusic",
- "keprohm.ogg"),
- SkipError_true);
- }
- }
- else
- {
- soundManager.stopMusic();
- }
- }
- else
- {
- soundManager.close();
- }
-}
diff --git a/src/gui/widgets/tabs/setup_audio.h b/src/gui/widgets/tabs/setup_audio.h
deleted file mode 100644
index d76add16c..000000000
--- a/src/gui/widgets/tabs/setup_audio.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 GUI_WIDGETS_TABS_SETUP_AUDIO_H
-#define GUI_WIDGETS_TABS_SETUP_AUDIO_H
-
-#include "gui/widgets/setupitem.h"
-
-#include "gui/widgets/tabs/setuptabscroll.h"
-
-class Setup_Audio final : public SetupTabScroll
-{
- public:
- explicit Setup_Audio(const Widget2 *const widget);
-
- A_DELETE_COPY(Setup_Audio)
-
- ~Setup_Audio();
-
- void apply() override final;
-
- private:
- ListModel *mSoundModel;
-
- SetupItemNames *mChannelsList;
-};
-
-#endif // GUI_WIDGETS_TABS_SETUP_AUDIO_H
diff --git a/src/gui/widgets/tabs/setup_chat.cpp b/src/gui/widgets/tabs/setup_chat.cpp
deleted file mode 100644
index b27e1ec53..000000000
--- a/src/gui/widgets/tabs/setup_chat.cpp
+++ /dev/null
@@ -1,347 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 Andrei Karas
- * 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 "gui/widgets/tabs/setup_chat.h"
-
-#include "gui/windows/chatwindow.h"
-
-#include "gui/widgets/containerplacer.h"
-#include "gui/widgets/layouthelper.h"
-#include "gui/widgets/scrollarea.h"
-#include "gui/widgets/setupitem.h"
-
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-Setup_Chat::Setup_Chat(const Widget2 *const widget) :
- SetupTabScroll(widget)
-{
- // TRANSLATORS: settings tab name
- setName(_("Chat"));
-
- // Do the layout
- LayoutHelper h(this);
- ContainerPlacer place = h.getPlacer(0, 0);
- place(0, 0, mScroll, 10, 10);
-
- // TRANSLATORS: settings group
- new SetupItemLabel(_("Window"), "", this);
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Auto hide chat window"),
- // TRANSLATORS: settings description
- _("Chat window will be automatically hidden when not in use.\n\n"
- "Hit Enter or hover mouse to show chat again."),
- "autohideChat", this, "autohideChatEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Protect chat focus"),
- // TRANSLATORS: settings description
- _("Enables aggressive protection of input focus in chat window.\n\n"
- "Note: no other text inputs will be allowed to receive text input "
- "when you typing in chat window."),
- "protectChatFocus", this, "protectChatFocusEvent");
-
-
- // TRANSLATORS: settings group
- new SetupItemLabel(_("Colors"), "", this);
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Remove colors from received chat messages"),
- // TRANSLATORS: settings description
- _("Enable this setting to strip colors from incoming chat messages. "
- "All messages will use default chat text color if this enabled."),
- "removeColors", this, "removeColorsEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Show chat colors list"),
- // TRANSLATORS: settings description
- _("Enable this setting to show color selection drop-down in chat "
- "window. Chat window will display color selection drop-down.\n\n"
- "It allows one to select default color of outgoing chat messages "
- "easily, but also occupies some space in chat window."),
- "showChatColorsList", this, "showChatColorsListEvent");
-
-
- // TRANSLATORS: settings option
- new SetupItemLabel(_("Commands"), "", this);
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Allow magic and GM commands in all chat tabs"),
- // TRANSLATORS: settings description
- _("Enable this setting to be able to type spells and GM commands in "
- "any tab."),
- "allowCommandsInChatTabs", this, "allowCommandsInChatTabsEvent");
-
-
- // TRANSLATORS: settings group
- new SetupItemLabel(_("Limits"), "", this);
-
- // TRANSLATORS: settings option
- new SetupItemIntTextField(_("Limit max chars in chat line"),
- // TRANSLATORS: settings description
- _("Limits how many characters will be shown in longest lines "
- "of text displayed in chat.\n\n"
- "Note: long lines can make client slower. Lines longer than this "
- "limit will be truncated."),
- "chatMaxCharLimit", this, "chatMaxCharLimitEvent", 0, 500);
-
- // TRANSLATORS: settings option
- new SetupItemIntTextField(_("Limit max lines in chat"),
- // TRANSLATORS: settings description
- _("Limits how many lines chat will keep in scrollback buffer. Chat "
- "keeps specified number of last lines of text. Oldest lines exceeding "
- "this limit are discarded from scrollback buffer.\n\n"
- "Note: keeping too many lines in scroll buffer can slow client down."),
- "chatMaxLinesLimit", this, "chatMaxLinesLimitEvent", 0, 500);
-
-
- // TRANSLATORS: settings group
- new SetupItemLabel(_("Logs"), "", this);
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Enable chat Log"),
- // TRANSLATORS: settings description
- _("If you enable this setting, chat logs will be written to disk.\n\n"
- "Note: chat logs can take noticeable amount of disk space over time."),
- "enableChatLog", this, "enableChatLogEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Enable debug chat Log"),
- // TRANSLATORS: settings description
- _("If you enable this, debug chat tab also will be logged to disk."),
- "enableDebugLog", this, "enableDebugLogEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Show chat history"),
- // TRANSLATORS: settings description
- _("If this setting enabled, client will load old chat tabs content "
- "from logs on startup instead of starting with empty chat tabs."),
- "showChatHistory", this, "showChatHistoryEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Show party online messages"),
- // TRANSLATORS: settings description
- _("If this setting is enabled, online status changes of party members"
- " will be shown in party tab of chat.\n\nThis adds some extra noise "
- "to chat, but allows one to see when your buddies are coming online."),
- "showPartyOnline", this, "showPartyOnlineEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Show guild online messages"),
- // TRANSLATORS: settings description
- _("If this setting is enabled, online status changes of guild members"
- " will be shown in guild tab of chat.\n\nThis adds some extra noise "
- "to chat, but allows one to see when your buddies are coming online."),
- "showGuildOnline", this, "showGuildOnlineEvent");
-
-
- // TRANSLATORS: settings group
- new SetupItemLabel(_("Messages"), "", this);
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Hide shop messages"),
- // TRANSLATORS: settings description
- _("If this setting enabled, no messages related to built-in ManaPlus "
- "shop will be displayed in chat. Disable this setting if you want "
- "to see shop-related messages.\n\nNote: technically, ManaPlus shop "
- "implemented as usual private messages with special content. If you "
- "disable this setting, you will be able to see these messages and get "
- "idea when other players are looking at your shop."),
- "hideShopMessages", this, "hideShopMessagesEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Show MVP messages"),
- // TRANSLATORS: settings description
- _("Enable this setting to see MVP messages from server.\n\n"
- "Note: MVP messages are not used on TMW/Evol/etc servers, so this "
- "feature usually makes little difference."),
- "showMVP", this, "showMVPEvent");
-
-
- // TRANSLATORS: settings group
- new SetupItemLabel(_("Tabs"), "", this);
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Put all whispers in tabs"),
- // TRANSLATORS: settings description
- _("If this setting enabled, all whispers (private messages) will "
- "be placed in separate tabs, separate tab for each player. If this "
- "setting disabled, all whispers will appear in General tab.\n\n"
- "Note: putting all whispers to single General tab is known to be "
- "confusing. Think twice before disabling this feature."),
- "whispertab", this, "whispertabEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Log magic messages in debug tab"),
- // TRANSLATORS: settings description
- _("If this setting is enabled, spell invocation will be shown in "
- "Debug tab. If disabled, it will be shown in General tab instead.\n\n"
- "Note: it does not affects server replies related to spells."),
- "showMagicInDebug", this, "showMagicInDebugEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Show server messages in debug tab"),
- // TRANSLATORS: settings description
- _("If this setting is enabled, server messages will be shown in "
- "Debug tab of chat. If disabled, server messages will appear in "
- "General chat instead.\n\nNote: according to 4144, disabling this "
- "could also make you to lose some debug messages from client in "
- "Debug tab since these are fake server messages."),
- "serverMsgInDebug", this, "serverMsgInDebugEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Enable trade tab"),
- // TRANSLATORS: settings description
- _("Enables trade tab. Trade tab is basically some filter. Messages "
- "containing words typical for trades will go to Trade tab. This "
- "will make General tab less noisy. If this setting is disabled, all "
- "trade related players messages will stay in General tab."),
- "enableTradeTab", this, "enableTradeTabEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Enable gm tab"),
- // TRANSLATORS: settings description
- _("If enabled, GM tab will appear in chat. It displays text related "
- "GM activity.\n\nNote: this setting only makes difference for "
- "GMs (Game Masters) since this tab only appears for GMs."),
- "enableGmTab", this, "enableGmTabEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Enable language tab"),
- // TRANSLATORS: settings description
- _("If this feature enabled, language tab will appear if server "
- "supports this feature.\n\nNote: only supported by Evol server yet."),
- "enableLangTab", this, "enableLangTabEvent",
- MainConfig_false);
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Show all languages messages"),
- // TRANSLATORS: settings description
- _("If this setting enabled and server supports different chats "
- "for different languages, you will see messages for all languages, "
- "regardless of your language preferences.\n\nNote: it only works "
- "on servers supporting language tabs feature, like Evol."),
- "showAllLang", this, "showAllLangEvent",
- MainConfig_false);
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Enable battle tab"),
- // TRANSLATORS: settings description
- _("If this setting enabled, Battle tab will appear in chat. This "
- "tab will contain messages related to battles, like damage and "
- "experience gain, if battle messages are enabled.\n\n"
- "Note: client restart required to take effect."),
- "enableBattleTab", this, "enableBattleTabEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Show battle events"),
- // TRANSLATORS: settings description
- _("If this setting enabled, messages related to battle like damage "
- "or experience gain will be displayed in Debug or Battle tab. If "
- "disabled, no battle messages will be displayed."),
- "showBattleEvents", this, "showBattleEventsEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Resize chat tabs if need"),
- // TRANSLATORS: settings description
- _("If this feature enabled, text in chat will be automatically "
- "adjusted to adapt to appearance of chat input field when you "
- "typing message and when input field of chat disappears. If disabled, "
- "chat input area will always occupy its place, which could be "
- "otherwise usable for text.\n\n"
- "Note: its mostly about jumpy attitude vs "
- "less usable space for text."),
- "hideChatInput", this, "hideChatInputEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Enable trade spam filter"),
- "", "enableTradeFilter", this, "enableTradeFilterEvent");
-
-
- // TRANSLATORS: settings group
- new SetupItemLabel(_("Time"), "", this);
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Use local time"),
- // TRANSLATORS: settings description
- _("If this feature enabled, timestamps in chat will use local times. "
- "If disabled, server time will be used (often it is GMT+0)."),
- "useLocalTime", this, "useLocalTimeEvent");
-
- // TRANSLATORS: settings group
- new SetupItemLabel(_("Other"), "", this);
-
- // TRANSLATORS: settings option
- new SetupItemTextField(_("Highlight words (separated by comma)"),
- // TRANSLATORS: settings description
- _("Here you can specify some extra words which will also cause "
- "highlighting. Use comma to separate words.\n\nNote: frequent "
- "highlights are annoying - use it with caution."),
- "highlightWords", this, "highlightWordsEvent");
-
- // TRANSLATORS: settings option
- new SetupItemTextField(_("Globals ignore names (separated by comma)"),
- // TRANSLATORS: settings description
- _("This setting allows you to ignore some global messages if "
- "particular sender (NPC, GM) annoys you too much. Global will be "
- "moved to Debug instead.\n\nNote: careless use of this feature can "
- "make you to miss important announces!"),
- "globalsFilter", this, "globalsFilterEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Show emotes button in chat"),
- // TRANSLATORS: settings description
- _("If this setting enabled, button will appear near text input "
- "field. This button allows one to invoke composing window, which "
- "allows one to insert smiles and text formatting easily.\n\n"
- "Note: same window can also be invoked by hotkey when typing, usually "
- "F1 by default."),
- "showEmotesButton", this, "showEmotesButtonEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Show motd server message on start"),
- // TRANSLATORS: settings description
- _("If this setting enabled, client will display server MOTD (message"
- " of the day) once you connect to server. Disable it to hide MOTD."),
- "showmotd", this, "showmotdEvent");
-
- setDimension(Rect(0, 0, 550, 350));
-}
-
-void Setup_Chat::apply()
-{
- SetupTabScroll::apply();
-
- if (chatWindow != nullptr)
- {
- chatWindow->adjustTabSize();
- chatWindow->parseHighlights();
- }
-}
-
-void Setup_Chat::externalUpdated()
-{
- reread("enableLangTab");
- reread("showAllLang");
-}
diff --git a/src/gui/widgets/tabs/setup_chat.h b/src/gui/widgets/tabs/setup_chat.h
deleted file mode 100644
index 2b18b0489..000000000
--- a/src/gui/widgets/tabs/setup_chat.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 Andrei Karas
- * 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_TABS_SETUP_CHAT_H
-#define GUI_WIDGETS_TABS_SETUP_CHAT_H
-
-#include "gui/widgets/tabs/setuptabscroll.h"
-
-class Setup_Chat final : public SetupTabScroll
-{
- public:
- explicit Setup_Chat(const Widget2 *const widget);
-
- A_DELETE_COPY(Setup_Chat)
-
- void apply() override final;
-
- void externalUpdated() override final;
-};
-
-#endif // GUI_WIDGETS_TABS_SETUP_CHAT_H
diff --git a/src/gui/widgets/tabs/setup_colors.cpp b/src/gui/widgets/tabs/setup_colors.cpp
deleted file mode 100644
index 4f2b35113..000000000
--- a/src/gui/widgets/tabs/setup_colors.cpp
+++ /dev/null
@@ -1,491 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 Douglas Boffey <dougaboffey@netscape.net>
- * 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 "gui/widgets/tabs/setup_colors.h"
-
-#include "gui/gui.h"
-#include "gui/userpalette.h"
-
-#include "gui/fonts/font.h"
-
-#include "gui/widgets/browserbox.h"
-#include "gui/widgets/containerplacer.h"
-#include "gui/widgets/createwidget.h"
-#include "gui/widgets/label.h"
-#include "gui/widgets/layouthelper.h"
-#include "gui/widgets/listbox.h"
-#include "gui/widgets/scrollarea.h"
-#include "gui/widgets/slider.h"
-#include "gui/widgets/textfield.h"
-#include "gui/widgets/textpreview.h"
-
-#include "utils/delete2.h"
-#include "utils/gettext.h"
-#include "utils/stringutils.h"
-
-#include <cmath>
-
-#include "debug.h"
-
-const char *const Setup_Colors::rawmsg =
- // TRANSLATORS: color selection preview message
- N_("This is what the color looks like");
-
-Setup_Colors::Setup_Colors(const Widget2 *const widget) :
- SetupTab(widget),
- SelectionListener(),
- mColorBox(CREATEWIDGETR(ListBox, this, userPalette, "")),
- mScroll(new ScrollArea(this, mColorBox,
- Opaque_true, "setup_colors_background.xml")),
- mPreview(new BrowserBox(this, Opaque_true,
- "browserbox.xml")),
- mTextPreview(new TextPreview(this, gettext(rawmsg))),
- mPreviewBox(new ScrollArea(this, mPreview, Opaque_true,
- "setup_colors_preview_background.xml")),
- mSelected(-1),
- // TRANSLATORS: colors tab. label.
- mGradTypeLabel(new Label(this, _("Type:"))),
- mGradTypeSlider(new Slider(this, 0.0, 3.0, 1.0)),
- mGradTypeText(new Label(this)),
- // TRANSLATORS: colors tab. label.
- mGradDelayLabel(new Label(this, _("Delay:"))),
- mGradDelaySlider(new Slider(this, 20.0, 100.0, 1.0)),
- mGradDelayText(new TextField(this)),
- // TRANSLATORS: colors tab. label.
- mRedLabel(new Label(this, _("Red:"))),
- mRedSlider(new Slider(this, 0.0, 255.0, 1.0)),
- mRedText(new TextField(this)),
- // TRANSLATORS: colors tab. label.
- mGreenLabel(new Label(this, _("Green:"))),
- mGreenSlider(new Slider(this, 0.0, 255.0, 1.0)),
- mGreenText(new TextField(this)),
- // TRANSLATORS: colors tab. label.
- mBlueLabel(new Label(this, _("Blue:"))),
- mBlueSlider(new Slider(this, 0.0, 255.0, 1.0)),
- mBlueText(new TextField(this))
-{
- // TRANSLATORS: settings colors tab name
- setName(_("Colors"));
- mColorBox->addSelectionListener(this);
- mScroll->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
- mPreview->setOpaque(Opaque_false);
-
- // don't do anything with links
- mPreview->setLinkHandler(nullptr);
-
- mPreviewBox->setHeight(20);
- mPreviewBox->setScrollPolicy(ScrollArea::SHOW_NEVER,
- ScrollArea::SHOW_NEVER);
-
- mGradTypeSlider->setWidth(180);
- mGradTypeSlider->setActionEventId("slider_grad");
- mGradTypeSlider->setValue(0);
- mGradTypeSlider->addActionListener(this);
- mGradTypeSlider->setEnabled(false);
-
- // TRANSLATORS: color type
- std::string longText = _("Static");
-
- const Font *const font = getFont();
- // TRANSLATORS: color type
- if (getFont()->getWidth(_("Pulse")) > font->getWidth(longText))
- {
- // TRANSLATORS: color type
- longText = _("Pulse");
- }
- // TRANSLATORS: color type
- if (getFont()->getWidth(_("Rainbow")) > font->getWidth(longText))
- {
- // TRANSLATORS: color type
- longText = _("Rainbow");
- }
- // TRANSLATORS: color type
- if (getFont()->getWidth(_("Spectrum")) > font->getWidth(longText))
- {
- // TRANSLATORS: color type
- longText = _("Spectrum");
- }
-
- mGradTypeText->setCaption(longText);
-
- mGradDelayText->setWidth(40);
- mGradDelayText->setRange(20, 100);
- mGradDelayText->setNumeric(true);
- mGradDelayText->setEnabled(false);
-
- mGradDelaySlider->setWidth(180);
- mGradDelaySlider->setValue(mGradDelayText->getValue());
- mGradDelaySlider->setActionEventId("slider_graddelay");
- mGradDelaySlider->addActionListener(this);
- mGradDelaySlider->setEnabled(false);
-
- mRedText->setWidth(40);
- mRedText->setRange(0, 255);
- mRedText->setNumeric(true);
- mRedText->setEnabled(false);
-
- mRedSlider->setWidth(180);
- mRedSlider->setValue(mRedText->getValue());
- mRedSlider->setActionEventId("slider_red");
- mRedSlider->addActionListener(this);
- mRedSlider->setEnabled(false);
-
- mGreenText->setWidth(40);
- mGreenText->setRange(0, 255);
- mGreenText->setNumeric(true);
- mGreenText->setEnabled(false);
-
- mGreenSlider->setWidth(180);
- mGreenSlider->setValue(mGreenText->getValue());
- mGreenSlider->setActionEventId("slider_green");
- mGreenSlider->addActionListener(this);
- mGreenSlider->setEnabled(false);
-
- mBlueText->setWidth(40);
- mBlueText->setRange(0, 255);
- mBlueText->setNumeric(true);
- mBlueText->setEnabled(false);
-
- mBlueSlider->setWidth(180);
- mBlueSlider->setValue(mBlueText->getValue());
- mBlueSlider->setActionEventId("slider_blue");
- mBlueSlider->addActionListener(this);
- mBlueSlider->setEnabled(false);
-
- setOpaque(Opaque_false);
-
- // Do the layout
- LayoutHelper h(this);
- ContainerPlacer place = h.getPlacer(0, 0);
-
- place(0, 0, mScroll, 6, 6).setPadding(2);
- place(0, 6, mPreviewBox, 6).setPadding(2);
- place(0, 7, mGradTypeLabel, 3);
- place(3, 7, mGradTypeSlider);
- place(4, 7, mGradTypeText, 2).setPadding(1);
- place(0, 8, mRedLabel, 3);
- place(3, 8, mRedSlider);
- place(5, 8, mRedText).setPadding(1);
- place(0, 9, mGreenLabel, 3);
- place(3, 9, mGreenSlider);
- place(5, 9, mGreenText).setPadding(1);
- place(0, 10, mBlueLabel, 3);
- place(3, 10, mBlueSlider);
- place(5, 10, mBlueText).setPadding(1);
- place(0, 11, mGradDelayLabel, 3);
- place(3, 11, mGradDelaySlider);
- place(5, 11, mGradDelayText).setPadding(1);
-
- mGradTypeText->setCaption("");
-
- setDimension(Rect(0, 0, 365, 350));
-}
-
-Setup_Colors::~Setup_Colors()
-{
- if ((mPreviewBox != nullptr) && mPreviewBox->getContent() == mPreview)
- delete2(mTextPreview)
- else
- delete2(mPreview)
-}
-
-void Setup_Colors::action(const ActionEvent &event)
-{
- const std::string &eventId = event.getId();
- if (eventId == "slider_grad")
- {
- updateGradType();
- updateColor();
- return;
- }
-
- if (eventId == "slider_graddelay")
- {
- mGradDelayText->setText(toString(
- std::floor(mGradDelaySlider->getValue())));
- updateColor();
- return;
- }
- if (eventId == "slider_red")
- {
- mRedText->setText(toString(std::floor(mRedSlider->getValue())));
- updateColor();
- return;
- }
- if (eventId == "slider_green")
- {
- mGreenText->setText(toString(std::floor(mGreenSlider->getValue())));
- updateColor();
- return;
- }
- if (eventId == "slider_blue")
- {
- mBlueText->setText(toString(std::floor(mBlueSlider->getValue())));
- updateColor();
- return;
- }
-}
-
-void Setup_Colors::valueChanged(const SelectionEvent &event A_UNUSED)
-{
- if (userPalette == nullptr)
- return;
-
- mSelected = mColorBox->getSelected();
- const UserColorIdT type = static_cast<UserColorIdT>(
- userPalette->getColorTypeAt(mSelected));
- const Color *col = &userPalette->getColor(type);
- const GradientTypeT grad = userPalette->getGradientType(type);
- const int delay = userPalette->getGradientDelay(type);
- const Visible showControls = fromBool(grad != GradientType::LABEL,
- Visible);
- mPreview->setVisible(showControls);
- mPreviewBox->setVisible(showControls);
- mTextPreview->setVisible(showControls);
- mGradTypeLabel->setVisible(showControls);
- mGradTypeSlider->setVisible(showControls);
- mGradTypeText->setVisible(showControls);
- mGradDelayLabel->setVisible(showControls);
- mGradDelaySlider->setVisible(showControls);
- mGradDelayText->setVisible(showControls);
- mRedLabel->setVisible(showControls);
- mRedSlider->setVisible(showControls);
- mRedText->setVisible(showControls);
- mGreenLabel->setVisible(showControls);
- mGreenSlider->setVisible(showControls);
- mGreenText->setVisible(showControls);
- mBlueLabel->setVisible(showControls);
- mBlueSlider->setVisible(showControls);
- mBlueText->setVisible(showControls);
-
- mPreview->clearRows();
- mPreviewBox->setContent(mTextPreview);
- mTextPreview->setFont(boldFont);
- mTextPreview->setTextColor(col);
- mTextPreview->setTextBGColor(nullptr);
- mTextPreview->setOpaque(Opaque_false);
- mTextPreview->setShadow(true);
- mTextPreview->setOutline(true);
- mTextPreview->useTextAlpha(false);
-
-// probably need combite both switches and add all mssing color ids.
-
- PRAGMA45(GCC diagnostic push)
- PRAGMA45(GCC diagnostic ignored "-Wswitch-enum")
- switch (type)
- {
- case UserColorId::AIR_COLLISION_HIGHLIGHT:
- case UserColorId::WATER_COLLISION_HIGHLIGHT:
- case UserColorId::MONSTER_COLLISION_HIGHLIGHT:
- case UserColorId::GROUNDTOP_COLLISION_HIGHLIGHT:
- case UserColorId::COLLISION_HIGHLIGHT:
- case UserColorId::PORTAL_HIGHLIGHT:
- case UserColorId::HOME_PLACE:
- case UserColorId::ROAD_POINT:
- case UserColorId::NET:
- mTextPreview->setBGColor(col);
- mTextPreview->setOpaque(Opaque_true);
- mTextPreview->setOutline(false);
- mTextPreview->setShadow(false);
- break;
- case UserColorId::ATTACK_RANGE_BORDER:
- case UserColorId::HOME_PLACE_BORDER:
- if (gui != nullptr)
- mTextPreview->setFont(gui->getFont());
- mTextPreview->setTextColor(col);
- mTextPreview->setOutline(false);
- mTextPreview->setShadow(false);
- break;
- case UserColorId::PARTICLE:
- case UserColorId::EXP_INFO:
- case UserColorId::PICKUP_INFO:
- case UserColorId::HIT_PLAYER_MONSTER:
- case UserColorId::HIT_MONSTER_PLAYER:
- case UserColorId::HIT_CRITICAL:
- case UserColorId::MISS:
- case UserColorId::HIT_LOCAL_PLAYER_MONSTER:
- case UserColorId::HIT_LOCAL_PLAYER_CRITICAL:
- case UserColorId::HIT_LOCAL_PLAYER_MISS:
- case UserColorId::ATTACK_RANGE:
- case UserColorId::MONSTER_ATTACK_RANGE:
- case UserColorId::FLOOR_ITEM_TEXT:
- case UserColorId::SKILL_ATTACK_RANGE:
- mTextPreview->setShadow(false);
- break;
- default:
- break;
- }
-
- switch (type)
- {
- case UserColorId::PORTAL_HIGHLIGHT:
- case UserColorId::ATTACK_RANGE:
- case UserColorId::ATTACK_RANGE_BORDER:
- case UserColorId::MONSTER_ATTACK_RANGE:
- case UserColorId::SKILL_ATTACK_RANGE:
- case UserColorId::HOME_PLACE:
- case UserColorId::HOME_PLACE_BORDER:
- case UserColorId::AIR_COLLISION_HIGHLIGHT:
- case UserColorId::WATER_COLLISION_HIGHLIGHT:
- case UserColorId::MONSTER_COLLISION_HIGHLIGHT:
- case UserColorId::GROUNDTOP_COLLISION_HIGHLIGHT:
- case UserColorId::COLLISION_HIGHLIGHT:
- case UserColorId::WALKABLE_HIGHLIGHT:
- case UserColorId::ROAD_POINT:
- case UserColorId::MONSTER_HP:
- case UserColorId::MONSTER_HP2:
- case UserColorId::HOMUN_HP:
- case UserColorId::HOMUN_HP2:
- case UserColorId::MERC_HP:
- case UserColorId::MERC_HP2:
- case UserColorId::ELEMENTAL_HP:
- case UserColorId::ELEMENTAL_HP2:
- case UserColorId::PLAYER_HP:
- case UserColorId::PLAYER_HP2:
- case UserColorId::FLOOR_ITEM_TEXT:
- case UserColorId::NET:
- // TRANSLATORS: colors tab. label.
- mGradDelayLabel->setCaption(_("Alpha:"));
- mGradDelayText->setRange(0, 255);
- mGradDelaySlider->setScale(0, 255);
- break;
- default:
- // TRANSLATORS: colors tab. label.
- mGradDelayLabel->setCaption(_("Delay:"));
- mGradDelayText->setRange(20, 100);
- mGradDelaySlider->setScale(20, 100);
- break;
- }
- PRAGMA45(GCC diagnostic pop)
- if (grad != GradientType::STATIC && grad != GradientType::PULSE)
- { // If nonstatic color, don't display the current, but the committed
- // color at the sliders
- col = &userPalette->getCommittedColor(type);
- }
- else if (grad == GradientType::PULSE)
- {
- col = &userPalette->getTestColor(type);
- }
-
- setEntry(mGradDelaySlider, mGradDelayText, delay);
- setEntry(mRedSlider, mRedText, col->r);
- setEntry(mGreenSlider, mGreenText, col->g);
- setEntry(mBlueSlider, mBlueText, col->b);
-
- mGradTypeSlider->setValue(CAST_S32(grad));
- updateGradType();
- mGradTypeSlider->setEnabled(true);
-}
-
-void Setup_Colors::setEntry(Slider *const s, TextField *const t,
- const int value)
-{
- if (s != nullptr)
- s->setValue(value);
- if (t != nullptr)
- t->setText(toString(value));
-}
-
-void Setup_Colors::apply()
-{
- if (userPalette != nullptr)
- userPalette->commit();
-}
-
-void Setup_Colors::cancel()
-{
- if (userPalette == nullptr)
- return;
-
- userPalette->rollback();
- const UserColorIdT type = static_cast<UserColorIdT>(
- userPalette->getColorTypeAt(mSelected));
- const Color *const col = &userPalette->getColor(type);
- mGradTypeSlider->setValue(CAST_S32(
- userPalette->getGradientType(type)));
- const int delay = userPalette->getGradientDelay(type);
- setEntry(mGradDelaySlider, mGradDelayText, delay);
- setEntry(mRedSlider, mRedText, col->r);
- setEntry(mGreenSlider, mGreenText, col->g);
- setEntry(mBlueSlider, mBlueText, col->b);
-}
-
-void Setup_Colors::updateGradType()
-{
- if (mSelected == -1 || (userPalette == nullptr))
- return;
-
- mSelected = mColorBox->getSelected();
- const UserColorIdT type = static_cast<UserColorIdT>(
- userPalette->getColorTypeAt(mSelected));
- const GradientTypeT grad = userPalette->getGradientType(type);
-
- mGradTypeText->setCaption(
- // TRANSLATORS: color type
- (grad == GradientType::STATIC) ? _("Static") :
- // TRANSLATORS: color type
- (grad == GradientType::PULSE) ? _("Pulse") :
- // TRANSLATORS: color type
- (grad == GradientType::RAINBOW) ? _("Rainbow") : _("Spectrum"));
-
- const bool enable = (grad == GradientType::STATIC ||
- grad == GradientType::PULSE);
- const bool delayEnable = true;
-
- mGradDelayText->setEnabled(delayEnable);
- mGradDelaySlider->setEnabled(delayEnable);
-
- mRedText->setEnabled(enable);
- mRedSlider->setEnabled(enable);
- mGreenText->setEnabled(enable);
- mGreenSlider->setEnabled(enable);
- mBlueText->setEnabled(enable);
- mBlueSlider->setEnabled(enable);
-}
-
-void Setup_Colors::updateColor() const
-{
- if (mSelected == -1 || (userPalette == nullptr))
- return;
-
- const UserColorIdT type = static_cast<UserColorIdT>(
- userPalette->getColorTypeAt(mSelected));
- const GradientTypeT grad = static_cast<GradientTypeT>(
- CAST_S32(mGradTypeSlider->getValue()));
- const int delay = CAST_S32(mGradDelaySlider->getValue());
- userPalette->setGradient(type, grad);
- userPalette->setGradientDelay(type, delay);
-
- if (grad == GradientType::STATIC)
- {
- userPalette->setColor(type,
- CAST_S32(mRedSlider->getValue()),
- CAST_S32(mGreenSlider->getValue()),
- CAST_S32(mBlueSlider->getValue()));
- }
- else if (grad == GradientType::PULSE)
- {
- userPalette->setTestColor(type, Color(
- CAST_S32(mRedSlider->getValue()),
- CAST_S32(mGreenSlider->getValue()),
- CAST_S32(mBlueSlider->getValue())));
- }
-}
diff --git a/src/gui/widgets/tabs/setup_colors.h b/src/gui/widgets/tabs/setup_colors.h
deleted file mode 100644
index 1ba74f340..000000000
--- a/src/gui/widgets/tabs/setup_colors.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 Douglas Boffey <dougaboffey@netscape.net>
- * 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_TABS_SETUP_COLORS_H
-#define GUI_WIDGETS_TABS_SETUP_COLORS_H
-
-#include "gui/widgets/tabs/setuptab.h"
-
-#include "listeners/selectionlistener.h"
-
-class BrowserBox;
-class Label;
-class ListBox;
-class ScrollArea;
-class Slider;
-class TextField;
-class TextPreview;
-
-class Setup_Colors final : public SetupTab,
- public SelectionListener
-{
- public:
- explicit Setup_Colors(const Widget2 *const widget);
-
- A_DELETE_COPY(Setup_Colors)
-
- ~Setup_Colors();
-
- void apply() override final;
-
- void cancel() override final;
-
- void action(const ActionEvent &event) override final;
-
- void valueChanged(const SelectionEvent &event) override final;
-
- private:
- static const char *const rawmsg;
-
- ListBox *mColorBox A_NONNULLPOINTER;
- ScrollArea *mScroll A_NONNULLPOINTER;
- BrowserBox *mPreview A_NONNULLPOINTER;
- TextPreview *mTextPreview A_NONNULLPOINTER;
- ScrollArea *mPreviewBox A_NONNULLPOINTER;
- int mSelected;
-
- Label *mGradTypeLabel A_NONNULLPOINTER;
- Slider *mGradTypeSlider A_NONNULLPOINTER;
- Label *mGradTypeText A_NONNULLPOINTER;
-
- Label *mGradDelayLabel A_NONNULLPOINTER;
- Slider *mGradDelaySlider A_NONNULLPOINTER;
- TextField *mGradDelayText A_NONNULLPOINTER;
-
- Label *mRedLabel A_NONNULLPOINTER;
- Slider *mRedSlider A_NONNULLPOINTER;
- TextField *mRedText A_NONNULLPOINTER;
-
- Label *mGreenLabel A_NONNULLPOINTER;
- Slider *mGreenSlider A_NONNULLPOINTER;
- TextField *mGreenText A_NONNULLPOINTER;
-
- Label *mBlueLabel A_NONNULLPOINTER;
- Slider *mBlueSlider A_NONNULLPOINTER;
- TextField *mBlueText A_NONNULLPOINTER;
-
- static void setEntry(Slider *const s, TextField *const t,
- const int value);
- void updateColor() const;
- void updateGradType();
-};
-
-#endif // GUI_WIDGETS_TABS_SETUP_COLORS_H
diff --git a/src/gui/widgets/tabs/setup_input.cpp b/src/gui/widgets/tabs/setup_input.cpp
deleted file mode 100644
index dc1e531f8..000000000
--- a/src/gui/widgets/tabs/setup_input.cpp
+++ /dev/null
@@ -1,399 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2007 Joshua Langley <joshlangley@optusnet.com.au>
- * 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 "gui/widgets/tabs/setup_input.h"
-
-#include "configuration.h"
-
-#include "const/gui/pages.h"
-
-#include "input/inputactionoperators.h"
-#include "input/inputmanager.h"
-#include "input/keyboardconfig.h"
-
-#include "input/pages/craft.h"
-#include "input/pages/emotes.h"
-#include "input/pages/move.h"
-#include "input/pages/outfits.h"
-#include "input/pages/shortcuts.h"
-
-#include "gui/gui.h"
-#include "gui/setupinputpages.h"
-
-#include "gui/windows/okdialog.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/containerplacer.h"
-#include "gui/widgets/createwidget.h"
-#include "gui/widgets/layouthelper.h"
-#include "gui/widgets/listbox.h"
-#include "gui/widgets/scrollarea.h"
-#include "gui/widgets/tabstrip.h"
-
-#include "gui/models/keylistmodel.h"
-
-#include "utils/delete2.h"
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-Setup_Input::Setup_Input(const Widget2 *const widget) :
- SetupTab(widget),
- mKeyListModel(new KeyListModel),
- mKeyList(CREATEWIDGETR(ListBox, this, mKeyListModel, "")),
- // TRANSLATORS: button in input settings tab
- mAssignKeyButton(new Button(this, _("Assign"), "assign", this)),
- // TRANSLATORS: button in input settings tab
- mUnassignKeyButton(new Button(this, _("Unassign"), "unassign", this)),
- // TRANSLATORS: button in input settings tab
- mDefaultButton(new Button(this, _("Default"), "default", this)),
- // TRANSLATORS: button in input settings tab
- mResetKeysButton(new Button(this, _("Reset all keys"), "resetkeys", this)),
- mTabs(new TabStrip(this, config.getIntValue("fontSize") + 10)),
- mScrollArea(new ScrollArea(this, mKeyList,
- Opaque_true, "setup_input_background.xml")),
- mKeySetting(false),
- mActionDataSize(new int [SETUP_PAGES])
-{
- inputManager.setSetupInput(this);
- // TRANSLATORS: setting tab name
- setName(_("Input"));
-
- mKeyListModel->setSelectedData(0);
-
- for (int f = 0; f < SETUP_PAGES; f ++)
- {
- int cnt = 0;
- while (!setupActionData[f][cnt].name.empty())
- cnt ++;
- mActionDataSize[f] = cnt;
- }
-
- mKeyListModel->setSize(mActionDataSize[0]);
- refreshKeys();
- if (gui != nullptr)
- mKeyList->setFont(gui->getHelpFont());
- mKeyList->addActionListener(this);
-
- mScrollArea->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
- mAssignKeyButton->addActionListener(this);
- mAssignKeyButton->setEnabled(false);
- mUnassignKeyButton->addActionListener(this);
- mUnassignKeyButton->setEnabled(false);
- mResetKeysButton->addActionListener(this);
- mDefaultButton->addActionListener(this);
-
- mTabs->addActionListener(this);
- mTabs->setActionEventId("tabs_");
- int k = 0;
- while (pages[k] != nullptr)
- {
- mTabs->addButton(gettext(pages[k]), pages[k], false);
- k ++;
- }
-
- fixTranslations();
-
- // Do the layout
- LayoutHelper h(this);
- ContainerPlacer place = h.getPlacer(0, 0);
-
- place(0, 0, mTabs, 5);
- place(0, 1, mScrollArea, 5, 5).setPadding(2);
- place(0, 6, mResetKeysButton);
- place(2, 6, mAssignKeyButton);
- place(3, 6, mUnassignKeyButton);
- place(4, 6, mDefaultButton);
-
- int width = 600;
- if (config.getIntValue("screenwidth") >= 730)
- width += 100;
-
- setDimension(Rect(0, 0, width, 350));
-}
-
-Setup_Input::~Setup_Input()
-{
- delete2(mKeyList);
- delete2(mKeyListModel);
- delete2(mAssignKeyButton);
- delete2(mUnassignKeyButton);
- delete2(mResetKeysButton);
- delete [] mActionDataSize;
- mActionDataSize = nullptr;
- delete2(mScrollArea);
-}
-
-void Setup_Input::apply()
-{
- keyUnresolved();
- InputActionT key1, key2;
-
- if (inputManager.hasConflicts(key1, key2))
- {
- const std::string str1 = keyToString(key1);
- const std::string str2 = keyToString(key2);
-
- CREATEWIDGET(OkDialog,
- // TRANSLATORS: input settings error header
- _("Key Conflict(s) Detected."),
- // TRANSLATORS: input settings error
- strprintf(_("Conflict \"%s\" and \"%s\" keys. "
- "Resolve them, or gameplay may result in strange behaviour."),
- gettext(str1.c_str()), gettext(str2.c_str())),
- // TRANSLATORS: ok dialog button
- _("OK"),
- DialogType::ERROR,
- Modal_true,
- ShowCenter_true,
- nullptr,
- 260);
- }
- keyboard.setEnabled(true);
- inputManager.store();
-}
-
-void Setup_Input::cancel()
-{
- keyUnresolved();
- inputManager.retrieve();
- keyboard.setEnabled(true);
- refreshKeys();
-}
-
-void Setup_Input::action(const ActionEvent &event)
-{
- const std::string &id = event.getId();
- const int selectedData = mKeyListModel->getSelectedData();
-
- if (event.getSource() == mKeyList)
- {
- if (!mKeySetting)
- {
- const int i(mKeyList->getSelected());
- if (i >= 0 && i < mActionDataSize[selectedData])
- {
- if (setupActionData[selectedData][i].actionId
- == InputAction::NO_VALUE)
- {
- mAssignKeyButton->setEnabled(false);
- mUnassignKeyButton->setEnabled(false);
- }
- else
- {
- mAssignKeyButton->setEnabled(true);
- mUnassignKeyButton->setEnabled(true);
- }
- }
- }
- }
- else if (id == "assign")
- {
- mKeySetting = true;
- mAssignKeyButton->setEnabled(false);
- keyboard.setEnabled(false);
- const int i(mKeyList->getSelected());
- if (i >= 0 && i < mActionDataSize[selectedData])
- {
- const SetupActionData &key = setupActionData[selectedData][i];
- const InputActionT ik = key.actionId;
- inputManager.setNewKeyIndex(ik);
- mKeyListModel->setElementAt(i, std::string(
- gettext(key.name.c_str())).append(": ?"));
- }
- }
- else if (id == "unassign")
- {
- const int i(mKeyList->getSelected());
- if (i >= 0 && i < mActionDataSize[selectedData])
- {
- const SetupActionData &key = setupActionData[selectedData][i];
- const InputActionT ik = key.actionId;
- inputManager.setNewKeyIndex(ik);
- refreshAssignedKey(mKeyList->getSelected());
- inputManager.unassignKey();
- inputManager.setNewKeyIndex(InputAction::NO_VALUE);
- }
- mAssignKeyButton->setEnabled(true);
- }
- else if (id == "resetkeys")
- {
- inputManager.resetKeys();
- InputManager::update();
- refreshKeys();
- }
- else if (id == "default")
- {
- const int i(mKeyList->getSelected());
- if (i >= 0 && i < mActionDataSize[selectedData])
- {
- const SetupActionData &key = setupActionData[selectedData][i];
- const InputActionT ik = key.actionId;
- inputManager.makeDefault(ik);
- refreshKeys();
- }
- }
- else if (strStartWith(id, "tabs_"))
- {
- int k = 0;
- std::string str("tabs_");
- while (pages[k] != nullptr)
- {
- if (str + pages[k] == id)
- break;
- k ++;
- }
- if ((pages[k] != nullptr) && str + pages[k] == id)
- {
- mKeyListModel->setSelectedData(k);
- mKeyListModel->setSize(mActionDataSize[k]);
- refreshKeys();
- mKeyList->setSelected(0);
- }
- }
-}
-
-void Setup_Input::refreshAssignedKey(const int index)
-{
- const int selectedData = mKeyListModel->getSelectedData();
- const SetupActionData &key = setupActionData[selectedData][index];
- if (key.actionId == InputAction::NO_VALUE)
- {
- const std::string str(" \342\200\225\342\200\225\342\200\225"
- "\342\200\225\342\200\225 ");
- mKeyListModel->setElementAt(index,
- str + gettext(key.name.c_str()) + str);
- }
- else
- {
- std::string str = gettext(key.name.c_str());
- unsigned int sz = 20;
- if (mainGraphics->mWidth > 800)
- sz = 30;
- while (str.size() < sz)
- str.append(" ");
- mKeyListModel->setElementAt(index, strprintf("%s: %s", str.c_str(),
- inputManager.getKeyStringLong(key.actionId).c_str()));
- }
-}
-
-void Setup_Input::newKeyCallback(const InputActionT index)
-{
- mKeySetting = false;
- const int i = keyToSetupData(index);
- if (i >= 0)
- refreshAssignedKey(i);
- mAssignKeyButton->setEnabled(true);
-}
-
-int Setup_Input::keyToSetupData(const InputActionT index) const
-{
- const int selectedData = mKeyListModel->getSelectedData();
- for (int i = 0; i < mActionDataSize[selectedData]; i++)
- {
- const SetupActionData &key = setupActionData[selectedData][i];
- if (key.actionId == index)
- return i;
- }
- return -1;
-}
-
-std::string Setup_Input::keyToString(const InputActionT index) const
-{
- for (int f = 0; f < SETUP_PAGES; f ++)
- {
- for (int i = 0; i < mActionDataSize[f]; i++)
- {
- const SetupActionData &key = setupActionData[f][i];
- if (key.actionId == index)
- return key.name;
- }
- }
- // TRANSLATORS: unknown key name
- return _("unknown");
-}
-
-void Setup_Input::refreshKeys()
-{
- const int selectedData = mKeyListModel->getSelectedData();
- for (int i = 0; i < mActionDataSize[selectedData]; i++)
- refreshAssignedKey(i);
-}
-
-void Setup_Input::keyUnresolved()
-{
- if (mKeySetting)
- {
- newKeyCallback(inputManager.getNewKeyIndex());
- inputManager.setNewKeyIndex(InputAction::NO_VALUE);
- }
-}
-
-void Setup_Input::fixTranslation(SetupActionData *const actionDatas,
- const InputActionT actionStart,
- const InputActionT actionEnd,
- const std::string &text)
-{
- int k = 0;
-
- while (!actionDatas[k].name.empty())
- {
- SetupActionData &data = actionDatas[k];
-
- const InputActionT actionId = data.actionId;
- if (actionId >= actionStart && actionId <= actionEnd)
- {
- data.name = strprintf(gettext(text.c_str()),
- actionId - actionStart + 1);
- }
- k ++;
- }
-}
-
-void Setup_Input::fixTranslations()
-{
- fixTranslation(setupActionDataShortcuts,
- InputAction::SHORTCUT_1,
- InputAction::SHORTCUT_20,
- "Item Shortcut %d");
-
- fixTranslation(setupActionDataEmotes,
- InputAction::EMOTE_1,
- InputAction::EMOTE_48,
- "Emote Shortcut %d");
-
- fixTranslation(setupActionDataCraft,
- InputAction::CRAFT_1,
- InputAction::CRAFT_9,
- "Craft shortcut %d");
-
- fixTranslation(setupActionDataOutfits,
- InputAction::OUTFIT_1,
- InputAction::OUTFIT_48,
- "Outfit Shortcut %d");
-
- fixTranslation(setupActionDataMove,
- InputAction::MOVE_TO_POINT_1,
- InputAction::MOVE_TO_POINT_48,
- "Move to point Shortcut %d");
-}
diff --git a/src/gui/widgets/tabs/setup_input.h b/src/gui/widgets/tabs/setup_input.h
deleted file mode 100644
index 2da411b2c..000000000
--- a/src/gui/widgets/tabs/setup_input.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2007 Joshua Langley <joshlangley@optusnet.com.au>
- * 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 GUI_WIDGETS_TABS_SETUP_INPUT_H
-#define GUI_WIDGETS_TABS_SETUP_INPUT_H
-
-#include "enums/input/inputaction.h"
-
-#include "gui/widgets/tabs/setuptab.h"
-
-class Button;
-class ListBox;
-class KeyListModel;
-class ScrollArea;
-class TabStrip;
-
-struct SetupActionData;
-
-class Setup_Input final : public SetupTab
-{
- public:
- /**
- * Constructor
- */
- explicit Setup_Input(const Widget2 *const widget);
-
- A_DELETE_COPY(Setup_Input)
-
- /**
- * Destructor
- */
- ~Setup_Input();
-
- void apply() override final;
-
- void cancel() override final;
-
- void action(const ActionEvent &event) override final;
-
- /**
- * Get an update on the assigned key.
- */
- void refreshAssignedKey(const int index);
-
- /**
- * The callback function when a new key has been pressed.
- */
- void newKeyCallback(const InputActionT index);
-
- /**
- * Shorthand method to update all the keys.
- */
- void refreshKeys();
-
- /**
- * If a key function is unresolved, then this reverts it.
- */
- void keyUnresolved();
-
- int keyToSetupData(const InputActionT index) const A_WARN_UNUSED;
-
- std::string keyToString(const InputActionT index) const A_WARN_UNUSED;
-
- private:
- static void fixTranslations();
-
- static void fixTranslation(SetupActionData *const actionDatas,
- const InputActionT actionStart,
- const InputActionT actionEnd,
- const std::string &text) A_NONNULL(1);
-
- KeyListModel *mKeyListModel;
- ListBox *mKeyList;
-
- Button *mAssignKeyButton;
- Button *mUnassignKeyButton;
- Button *mDefaultButton;
- Button *mResetKeysButton;
- TabStrip *mTabs;
- ScrollArea *mScrollArea;
- bool mKeySetting; /**< flag to check if key being set. */
- int *mActionDataSize;
-};
-
-#endif // GUI_WIDGETS_TABS_SETUP_INPUT_H
diff --git a/src/gui/widgets/tabs/setup_joystick.cpp b/src/gui/widgets/tabs/setup_joystick.cpp
deleted file mode 100644
index 84cd60521..000000000
--- a/src/gui/widgets/tabs/setup_joystick.cpp
+++ /dev/null
@@ -1,184 +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 "gui/widgets/tabs/setup_joystick.h"
-
-#include "configuration.h"
-
-#include "input/joystick.h"
-
-#include "gui/models/namesmodel.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/checkbox.h"
-#include "gui/widgets/containerplacer.h"
-#include "gui/widgets/dropdown.h"
-#include "gui/widgets/label.h"
-#include "gui/widgets/layouthelper.h"
-
-#include "utils/delete2.h"
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-Setup_Joystick::Setup_Joystick(const Widget2 *const widget) :
- SetupTab(widget),
- mCalibrateLabel(new Label(this,
- // TRANSLATORS: joystick settings tab label
- _("Press the button to start calibration"))),
- // TRANSLATORS: joystick settings tab button
- mCalibrateButton(new Button(this, _("Calibrate"), "calibrate", this)),
- // TRANSLATORS: joystick settings tab button
- mDetectButton(new Button(this, _("Detect joysticks"), "detect", this)),
- // TRANSLATORS: joystick settings tab checkbox
- mJoystickEnabled(new CheckBox(this, _("Enable joystick"))),
- mNamesModel(new NamesModel),
- mNamesDropDown(new DropDown(this, mNamesModel)),
- // TRANSLATORS: joystick settings tab checkbox
- mUseInactiveCheckBox(new CheckBox(this, _("Use joystick if client "
- "window inactive"), config.getBoolValue("useInactiveJoystick"))),
- mOriginalJoystickEnabled(config.getBoolValue("joystickEnabled"))
-{
- // TRANSLATORS: joystick settings tab name
- setName(_("Joystick"));
-
- Joystick::getNames(mNamesModel->getNames());
-
- mJoystickEnabled->setSelected(mOriginalJoystickEnabled);
- mJoystickEnabled->setActionEventId("joystick");
- mJoystickEnabled->addActionListener(this);
- mCalibrateButton->setEnabled(mOriginalJoystickEnabled);
-
- mNamesDropDown->setActionEventId("name");
- mNamesDropDown->addActionListener(this);
-
- if (joystick != nullptr)
- {
- mNamesDropDown->setSelected(joystick->getNumber());
- }
- else
- {
- unsigned int sel = config.getIntValue("selectedJoystick");
- if (sel >= CAST_U32(mNamesModel->size()))
- sel = 0;
- mNamesDropDown->setSelected(sel);
- }
-
- // Do the layout
- LayoutHelper h(this);
- ContainerPlacer place = h.getPlacer(0, 0);
-
- place(0, 0, mJoystickEnabled);
- place(0, 1, mNamesDropDown);
- place(0, 2, mUseInactiveCheckBox);
- place(0, 3, mDetectButton);
- place(0, 4, mCalibrateLabel);
- place(0, 5, mCalibrateButton);
-
- setDimension(Rect(0, 0, 365, 75));
-}
-
-Setup_Joystick::~Setup_Joystick()
-{
- delete2(mNamesModel);
-}
-
-void Setup_Joystick::action(const ActionEvent &event)
-{
- const Widget *const source = event.getSource();
- if (source == mJoystickEnabled)
- {
- setTempEnabled(mJoystickEnabled->isSelected());
- }
- else if (source == mNamesDropDown)
- {
- if (joystick != nullptr)
- joystick->setNumber(mNamesDropDown->getSelected());
- }
- else if (source == mDetectButton)
- {
- if (joystick != nullptr)
- {
- joystick->reload();
- Joystick::getNames(mNamesModel->getNames());
- mNamesDropDown->setSelected(joystick->getNumber());
- }
- }
- else
- {
- if (joystick == nullptr)
- return;
-
- if (joystick->isCalibrating())
- {
- // TRANSLATORS: joystick settings tab button
- mCalibrateButton->setCaption(_("Calibrate"));
- mCalibrateLabel->setCaption
- // TRANSLATORS: joystick settings tab label
- (_("Press the button to start calibration"));
- joystick->finishCalibration();
- }
- else
- {
- // TRANSLATORS: joystick settings tab button
- mCalibrateButton->setCaption(_("Stop"));
- mCalibrateLabel->setCaption(
- // TRANSLATORS: joystick settings tab label
- _("Rotate the stick and don't press buttons"));
- joystick->startCalibration();
- }
- }
-}
-
-void Setup_Joystick::setTempEnabled(const bool sel)
-{
- Joystick::setEnabled(sel);
- mCalibrateButton->setEnabled(sel);
- if (joystick != nullptr)
- {
- if (sel)
- joystick->open();
- else
- joystick->close();
- }
-}
-
-void Setup_Joystick::cancel()
-{
- Joystick::setEnabled(mOriginalJoystickEnabled);
-
- if (mOriginalJoystickEnabled != mJoystickEnabled->isSelected())
- setTempEnabled(mOriginalJoystickEnabled);
-
- mJoystickEnabled->setSelected(mOriginalJoystickEnabled);
-}
-
-void Setup_Joystick::apply()
-{
- if (joystick == nullptr)
- return;
-
- config.setValue("joystickEnabled", Joystick::isEnabled());
-
- config.setValue("useInactiveJoystick", mUseInactiveCheckBox->isSelected());
- joystick->setUseInactive(mUseInactiveCheckBox->isSelected());
-}
diff --git a/src/gui/widgets/tabs/setup_joystick.h b/src/gui/widgets/tabs/setup_joystick.h
deleted file mode 100644
index c66ab8687..000000000
--- a/src/gui/widgets/tabs/setup_joystick.h
+++ /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/>.
- */
-
-#ifndef GUI_WIDGETS_TABS_SETUP_JOYSTICK_H
-#define GUI_WIDGETS_TABS_SETUP_JOYSTICK_H
-
-#include "gui/widgets/tabs/setuptab.h"
-
-class Button;
-class CheckBox;
-class DropDown;
-class Label;
-class NamesModel;
-
-class Setup_Joystick final : public SetupTab
-{
- public:
- explicit Setup_Joystick(const Widget2 *const widget);
-
- A_DELETE_COPY(Setup_Joystick)
-
- ~Setup_Joystick();
-
- void apply() override final;
-
- void cancel() override final;
-
- void action(const ActionEvent &event) override final;
-
- void setTempEnabled(const bool sel);
-
- private:
- Label *mCalibrateLabel A_NONNULLPOINTER;
- Button *mCalibrateButton A_NONNULLPOINTER;
- Button *mDetectButton A_NONNULLPOINTER;
- CheckBox *mJoystickEnabled A_NONNULLPOINTER;
- NamesModel *mNamesModel A_NONNULLPOINTER;
- DropDown *mNamesDropDown A_NONNULLPOINTER;
- CheckBox *mUseInactiveCheckBox A_NONNULLPOINTER;
- bool mOriginalJoystickEnabled A_NONNULLPOINTER;
-};
-
-#endif // GUI_WIDGETS_TABS_SETUP_JOYSTICK_H
diff --git a/src/gui/widgets/tabs/setup_misc.cpp b/src/gui/widgets/tabs/setup_misc.cpp
deleted file mode 100644
index 07b4c5193..000000000
--- a/src/gui/widgets/tabs/setup_misc.cpp
+++ /dev/null
@@ -1,518 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 Andrei Karas
- * 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 "gui/widgets/tabs/setup_misc.h"
-
-#include "configuration.h"
-
-#include "const/resources/map/map.h"
-
-#include "gui/models/namesmodel.h"
-
-#include "gui/widgets/containerplacer.h"
-#include "gui/widgets/layouthelper.h"
-#include "gui/widgets/setupbuttonitem.h"
-#include "gui/widgets/scrollarea.h"
-
-#include "listeners/uploadlistener.h"
-
-#include "net/net.h"
-
-#include "utils/delete2.h"
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-static const int shortcutsListSize = 3;
-
-static const char *const shortcutsList[] =
-{
- // TRANSLATORS: show buttons at top right corner type
- N_("Always show"),
- // TRANSLATORS: show buttons at top right corner type
- N_("Auto hide in small resolution"),
- // TRANSLATORS: show buttons at top right corner type
- N_("Always auto hide")
-};
-
-static const int proxyTypeListSize = 8;
-
-static const char *const proxyTypeList[] =
-{
- // TRANSLATORS: Proxy type selection
- N_("System proxy"),
- // TRANSLATORS: Proxy type selection
- N_("Direct connection"),
- "HTTP",
- "HTTP 1.0",
- "SOCKS4",
- "SOCKS4A",
- "SOCKS5",
- // TRANSLATORS: Proxy type selection
- N_("SOCKS5 hostname")
-};
-
-static const int densityListSize = 7;
-
-static const char *const densityList[] =
-{
- // TRANSLATORS: screen density type
- N_("default"),
- // TRANSLATORS: screen density type
- N_("low"),
- // TRANSLATORS: screen density type
- N_("medium"),
- // TRANSLATORS: screen density type
- N_("tv"),
- // TRANSLATORS: screen density type
- N_("high"),
- // TRANSLATORS: screen density type
- N_("xhigh"),
- // TRANSLATORS: screen density type
- N_("xxhigh")
-};
-
-#ifdef USE_SDL2
-static const int sdlLogListSize = 7;
-
-static const char *const sdlLogList[] =
-{
- // TRANSLATORS: sdl2 log level
- N_("default"),
- // TRANSLATORS: sdl2 log level
- N_("verbose"),
- // TRANSLATORS: sdl2 log level
- N_("debug"),
- // TRANSLATORS: sdl2 log level
- N_("info"),
- // TRANSLATORS: sdl2 log level
- N_("warn"),
- // TRANSLATORS: sdl2 log level
- N_("error"),
- // TRANSLATORS: sdl2 log level
- N_("critical")
-};
-#endif // USE_SDL2
-
-Setup_Misc::Setup_Misc(const Widget2 *const widget) :
- SetupTabScroll(widget),
- mProxyTypeList(new NamesModel),
- mShortcutsList(new NamesModel),
-#ifdef USE_SDL2
- mSdlLogList(new NamesModel),
-#endif // USE_SDL2
- mDensityList(new NamesModel)
-{
- // TRANSLATORS: misc tab in settings
- setName(_("Misc"));
-
- LayoutHelper h(this);
- ContainerPlacer place = h.getPlacer(0, 0);
- place(0, 0, mScroll, 10, 10);
-
- // TRANSLATORS: settings option
- new SetupItemLabel(_("Monsters"), "", this);
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Show damage inflicted to monsters"), "",
- "showMonstersTakedDamage", this, "showMonstersTakedDamageEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Auto target only reachable monsters"), "",
- "targetOnlyReachable", this, "targetOnlyReachableEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Select auto target for attack skills"), "",
- "skillAutotarget", this, "skillAutotargetEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Highlight monster attack range"), "",
- "highlightMonsterAttackRange", this,
- "highlightMonsterAttackRangeEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Show monster hp bar"), "",
- "showMobHP", this, "showMobHPEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Cycle monster targets"), "",
- "cycleMonsters", this, "cycleMonstersEvent");
-
-
- // TRANSLATORS: settings group
- new SetupItemLabel(_("Map"), "", this);
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Show warps particles"), "",
- "warpParticle", this, "warpParticleEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Highlight map portals"), "",
- "highlightMapPortals", this, "highlightMapPortalsEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Highlight floor items"), "",
- "floorItemsHighlight", this, "floorItemsHighlightEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Highlight player attack range"), "",
- "highlightAttackRange", this, "highlightAttackRangeEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Show extended minimaps"), "",
- "showExtMinimaps", this, "showExtMinimapsEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Draw path"), "", "drawPath",
- this, "drawPathEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Draw hotkeys on map"), "", "drawHotKeys",
- this, "drawHotKeysEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Enable lazy scrolling"), "",
- "enableLazyScrolling", this, "enableLazyScrollingEvent");
-
- // TRANSLATORS: settings option
- new SetupItemIntTextField(_("Scroll laziness"), "", "ScrollLaziness",
- this, "ScrollLazinessEvent", 1, 160);
-
- // TRANSLATORS: settings option
- new SetupItemIntTextField(_("Scroll radius"), "", "ScrollRadius",
- this, "ScrollRadiusEvent", 0, mapTileSize);
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Auto resize minimaps"), "", "autoresizeminimaps",
- this, "autoresizeminimapsEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Play map animations"), "", "playMapAnimations",
- this, "playMapAnimationsEvent");
-
-
- // TRANSLATORS: settings group
- new SetupItemLabel(_("Moving"), "", this);
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Auto fix position"), "",
- "autofixPos", this, "autofixPosEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Show server side position"), "",
- "showserverpos", this, "showserverposEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Attack while moving"), "",
- "attackMoving", this, "attackMovingEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Attack next target"), "",
- "attackNext", this, "attackNextEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Sync player move"), "", "syncPlayerMove",
- this, "syncPlayerMoveEvent");
-
- // TRANSLATORS: settings option
- new SetupItemIntTextField(_("Sync player move distance"), "",
- "syncPlayerMoveDistance",
- this, "syncPlayerMoveDistanceEvent", 1, 30);
-
- // TRANSLATORS: settings option
- new SetupItemTextField(_("Crazy move A program"), "",
- "crazyMoveProgram", this, "crazyMoveProgramEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Mouse relative moves "
- "(good for touch interfaces)"), "", "mouseDirectionMove",
- this, "mouseDirectionMoveEvent");
-
- // TRANSLATORS: settings group
- new SetupItemLabel(_("Player"), "", this);
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Show own hp bar"), "",
- "showOwnHP", this, "showOwnHPEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Enable quick stats"), "",
- "quickStats", this, "quickStatsEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Cycle player targets"), "",
- "cyclePlayers", this, "cyclePlayersEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Show job exp messages"), "",
- "showJobExp", this, "showJobExpEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Show players popups"), "",
- "showBeingPopup", this, "showBeingPopupEvent");
-
- // TRANSLATORS: settings option
- new SetupItemTextField(_("Afk message"), "",
- "afkMessage", this, "afkMessageEvent",
- MainConfig_false);
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Show job"), "", "showJob",
- this, "showJobEvent",
- MainConfig_false);
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Enable attack filter"), "",
- "enableAttackFilter", this, "enableAttackFilterEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Enable pickup filter"), "",
- "enablePickupFilter", this, "enablePickupFilterEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Enable advert protocol"), "",
- "enableAdvert", this, "enableAdvertEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Enabled pets support"),
- "", "usepets", this, "usepetsEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Enable weight notifications"), "",
- "weightMsg", this, "weightMsgEvent");
-
- // TRANSLATORS: settings group
- new SetupItemLabel(_("Shop"), "", this);
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Accept sell/buy requests"), "",
- "autoShop", this, "autoShopEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Enable shop mode"), "",
- "tradebot", this, "tradebotEvent");
-
-
- // TRANSLATORS: settings group
- new SetupItemLabel(_("NPC"), "", this);
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Cycle npc targets"), "",
- "cycleNPC", this, "cycleNPCEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Log NPC dialogue"), "", "logNpcInGui",
- this, "logNpcInGuiEvent");
-
-
- // TRANSLATORS: settings group
- new SetupItemLabel(_("Bots support"), "", this);
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Enable guild bot support and disable native "
- "guild support"), "", "enableGuildBot", this,
- "enableGuildBotEvent",
- "0",
- MainConfig_false);
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Enable manamarket bot support"),
- "", "enableManaMarketBot", this,
- "enableManaMarketBotEvent",
- "0",
- MainConfig_false);
-
-
- // TRANSLATORS: settings group
- new SetupItemLabel(_("Keyboard"), "", this);
-
- // TRANSLATORS: settings option
- new SetupItemIntTextField(_("Repeat delay"), "",
- "repeateDelay", this, "repeateDelayEvent", 0, 10000);
-
- // TRANSLATORS: settings option
- new SetupItemIntTextField(_("Repeat interval"), "",
- "repeateInterval", this, "repeateIntervalEvent", 0, 10000);
-
- // TRANSLATORS: settings option
- new SetupItemIntTextField(_("Custom repeat interval"), "",
- "repeateInterval2", this, "repeateInterval2Event", 0, 10000);
-
-#ifdef USE_SDL2
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Enable alt-tab workaround"), "",
- "blockAltTab", this, "blockAltTabEvent");
-#endif // USE_SDL2
-
-
- // TRANSLATORS: settings group
- new SetupItemLabel(_("Windows"), "", this);
-
- mShortcutsList->fillFromArray(&shortcutsList[0], shortcutsListSize);
- // TRANSLATORS: settings option
- new SetupItemDropDown(_("Shortcut buttons"), "", "autohideButtons", this,
- "autohideButtonsEvent", mShortcutsList, 200);
-
-
- // TRANSLATORS: settings group
- new SetupItemLabel(_("Proxy server"), "", this);
-
- mProxyTypeList->fillFromArray(&proxyTypeList[0], proxyTypeListSize);
- // TRANSLATORS: settings option
- new SetupItemDropDown(_("Proxy type"), "", "downloadProxyType", this,
- "downloadProxyTypeEvent", mProxyTypeList, 200);
-
- // TRANSLATORS: settings option
- new SetupItemTextField(_("Proxy address:port"), "",
- "downloadProxy", this, "downloadProxyEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Tunnel through HTTP proxy"), "",
- "downloadProxyTunnel", this, "downloadProxyTunnelEvent");
-
-
- // TRANSLATORS: settings group
- new SetupItemLabel(_("Logging"), "", this);
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Enable OpenGL version check "
- "(do not disable)"), "", "checkOpenGLVersion", this,
- "checkOpenGLVersionEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Enable debug log"), "",
- "debugLog", this, "debugLogEvent");
-
- // TRANSLATORS: settings option
- new SetupItemTextField(_("Ignore logging packets"), "",
- "ignorelogpackets", this, "ignorelogpacketsEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Log unimplemented packets"), "",
- "unimplimentedLog", this, "unimplimentedLogEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Enable OpenGL log"), "",
- "debugOpenGL", this, "debugOpenGLEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Enable input log"), "",
- "logInput", this, "logInputEvent");
-
-#ifdef USE_SDL2
- mSdlLogList->fillFromArray(&sdlLogList[0], sdlLogListSize);
- // TRANSLATORS: settings option
- new SetupItemDropDown(_("SDL logging level"), "",
- "sdlLogLevel", this, "sdlLogLevelEvent", mSdlLogList, 100);
-#endif // USE_SDL2
-
- // TRANSLATORS: settings option
- new SetupButtonItem(_("Upload log file"), "", "upload",
- this, "uploadLog", &uploadListener);
-
-
- // TRANSLATORS: settings group
- new SetupItemLabel(_("Other"), "", this);
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Enable server side attack"), "",
- "serverAttack", this, "serverAttackEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Hide support page link on error"), "",
- "hidesupport", this, "hidesupportEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Enable double clicks"), "",
- "doubleClick", this, "doubleClickEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Enable bot checker"), "",
- "enableBotCheker", this, "enableBotChekerEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Enable buggy servers protection "
- "(do not disable)"), "", "enableBuggyServers", this,
- "enableBuggyServersEvent",
- MainConfig_false);
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Low traffic mode"), "", "lowTraffic",
- this, "lowTrafficEvent");
-
-#ifndef ANDROID
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Use FBO for screenshots (only for opengl)"),
- "", "usefbo", this, "usefboEvent");
-#endif // ANDROID
-
-#ifndef WIN32
- // TRANSLATORS: settings option
- new SetupItemTextField(_("Screenshot directory"), "",
- "screenshotDirectory3", this, "screenshotDirectory3Event",
- MainConfig_true,
- UseBase64_true);
-#endif // WIN32
-
- // TRANSLATORS: settings option
- new SetupItemIntTextField(_("Network delay between sub servers"),
- "", "networksleep", this, "networksleepEvent", 0, 10000);
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Show background"), "", "showBackground",
- this, "showBackgroundEvent");
-
- mDensityList->fillFromArray(&densityList[0], densityListSize);
- // TRANSLATORS: settings option
- new SetupItemDropDown(_("Screen density override"), "",
- "screenDensity", this, "screenDensityEvent", mDensityList, 100);
-
- setDimension(Rect(0, 0, 550, 350));
-}
-
-Setup_Misc::~Setup_Misc()
-{
- delete2(mProxyTypeList);
- delete2(mShortcutsList);
- delete2(mDensityList);
-#ifdef USE_SDL2
- delete2(mSdlLogList);
-#endif // USE_SDL2
-}
-
-void Setup_Misc::apply()
-{
- SetupTabScroll::apply();
-
- logger->setDebugLog(config.getBoolValue("debugLog"));
- logger->setReportUnimplemented(config.getBoolValue("unimplimentedLog"));
- Net::loadIgnorePackets();
-}
-
-void Setup_Misc::externalUpdated()
-{
- reread("showJob");
- reread("enableGuildBot");
- reread("enableManaMarketBot");
- reread("enableBuggyServers");
- reread("afkMessage");
-}
diff --git a/src/gui/widgets/tabs/setup_misc.h b/src/gui/widgets/tabs/setup_misc.h
deleted file mode 100644
index 787f4c181..000000000
--- a/src/gui/widgets/tabs/setup_misc.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 Andrei Karas
- * 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_TABS_SETUP_MISC_H
-#define GUI_WIDGETS_TABS_SETUP_MISC_H
-
-#include "gui/widgets/tabs/setuptabscroll.h"
-
-class NamesModel;
-
-class Setup_Misc final : public SetupTabScroll
-{
- public:
- explicit Setup_Misc(const Widget2 *const widget);
-
- A_DELETE_COPY(Setup_Misc)
-
- ~Setup_Misc();
-
- void apply() override final;
-
- void externalUpdated() override final;
-
- protected:
- NamesModel *mProxyTypeList;
- NamesModel *mShortcutsList;
-#ifdef USE_SDL2
- NamesModel *mSdlLogList;
-#endif // USE_SDL2
- NamesModel *mDensityList;
-};
-
-#endif // GUI_WIDGETS_TABS_SETUP_MISC_H
diff --git a/src/gui/widgets/tabs/setup_mods.cpp b/src/gui/widgets/tabs/setup_mods.cpp
deleted file mode 100644
index c3ca23245..000000000
--- a/src/gui/widgets/tabs/setup_mods.cpp
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 Andrei Karas
- * 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 "gui/widgets/tabs/setup_mods.h"
-
-#include "configuration.h"
-
-#include "gui/widgets/containerplacer.h"
-#include "gui/widgets/layouthelper.h"
-#include "gui/widgets/setupitem.h"
-#include "gui/widgets/scrollarea.h"
-
-#include "resources/db/moddb.h"
-
-#include "utils/foreach.h"
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-Setup_Mods::Setup_Mods(const Widget2 *const widget) :
- SetupTabScroll(widget)
-{
- // TRANSLATORS: mods tab in settings
- setName(_("Mods"));
-
- LayoutHelper h(this);
- ContainerPlacer place = h.getPlacer(0, 0);
- place(0, 0, mScroll, 10, 10);
-
- setDimension(Rect(0, 0, 550, 350));
-}
-
-Setup_Mods::~Setup_Mods()
-{
-}
-
-void Setup_Mods::apply()
-{
- SetupTabScroll::apply();
- saveMods();
-}
-
-void Setup_Mods::externalUpdated()
-{
- clear();
- loadMods();
-}
-
-void Setup_Mods::loadMods()
-{
- std::string modsString = serverConfig.getValue("mods", "");
- std::set<std::string> modsList;
- splitToStringSet(modsList, modsString, '|');
-
- const ModInfos &mods = ModDB::getAll();
- if (mods.empty())
- {
- // TRANSLATORS: settings label
- new SetupItemLabel(_("No mods present"), "", this,
- Separator_false);
- return;
- }
-
- FOR_EACH (ModInfoCIterator, it, mods)
- {
- const ModInfo *const info = (*it).second;
- if (info == nullptr)
- continue;
-
- std::string name = info->getName();
- replaceAll(name, "|", "");
- SetupItem *const item = new SetupItemCheckBox(
- info->getDescription(), "", "", this, name);
- if (modsList.find(name) != modsList.end())
- item->setValue("1");
- else
- item->setValue("0");
- item->toWidget();
- }
-}
-
-void Setup_Mods::saveMods() const
-{
- const ModInfos &mods = ModDB::getAll();
- if (mods.empty())
- return;
-
- std::string modsString;
- const std::set<SetupItem*> &modsList = getAllItems();
- FOR_EACH (std::set<SetupItem*>::const_iterator, it, modsList)
- {
- const SetupItem *const item = *it;
- if (item == nullptr)
- continue;
- const std::string val = item->getValue();
- if (val == "1")
- {
- const std::string key = item->getEventName();
- if (!modsString.empty())
- modsString.append("|");
- modsString.append(key);
- }
- }
- serverConfig.setValue("mods", modsString);
-}
-
-void Setup_Mods::externalUnloaded()
-{
- clear();
-}
diff --git a/src/gui/widgets/tabs/setup_mods.h b/src/gui/widgets/tabs/setup_mods.h
deleted file mode 100644
index 488915d31..000000000
--- a/src/gui/widgets/tabs/setup_mods.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 Andrei Karas
- * 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_TABS_SETUP_MODS_H
-#define GUI_WIDGETS_TABS_SETUP_MODS_H
-
-#include "gui/widgets/tabs/setuptabscroll.h"
-
-class Setup_Mods final : public SetupTabScroll
-{
- public:
- explicit Setup_Mods(const Widget2 *const widget);
-
- A_DELETE_COPY(Setup_Mods)
-
- ~Setup_Mods();
-
- void apply() override final;
-
- void externalUpdated() override final;
-
- void externalUnloaded() override final;
-
- void loadMods();
-
- void saveMods() const;
-
- protected:
-};
-
-#endif // GUI_WIDGETS_TABS_SETUP_MODS_H
diff --git a/src/gui/widgets/tabs/setup_perfomance.cpp b/src/gui/widgets/tabs/setup_perfomance.cpp
deleted file mode 100644
index e12bd2872..000000000
--- a/src/gui/widgets/tabs/setup_perfomance.cpp
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 Andrei Karas
- * 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 "gui/widgets/tabs/setup_perfomance.h"
-
-#include "gui/models/namesmodel.h"
-
-#include "gui/widgets/containerplacer.h"
-#include "gui/widgets/layouthelper.h"
-#include "gui/widgets/scrollarea.h"
-#include "gui/widgets/setupitem.h"
-
-#include "utils/delete2.h"
-#include "utils/gettext.h"
-#ifdef USE_SDL2
-#include "configuration.h"
-#include "utils/sdlhelper.h"
-#endif // USE_SDL2
-
-#include "debug.h"
-
-static const int texturesListSize = 5;
-
-static const char *const texturesList[] =
-{
- // TRANSLATORS: texture compression type
- N_("No"),
- "s3tc",
- "fxt1",
- "ARB",
- "bptc"
-};
-
-Setup_Perfomance::Setup_Perfomance(const Widget2 *const widget) :
- SetupTabScroll(widget),
-#ifdef USE_SDL2
- mSdlDriversList(new NamesModel),
-#endif // USE_SDL2
- mTexturesList(new NamesModel)
-{
- // TRANSLATORS: settings tab name
- setName(_("Performance"));
-
- // Do the layout
- LayoutHelper h(this);
- ContainerPlacer place = h.getPlacer(0, 0);
- place(0, 0, mScroll, 10, 10);
-
-#ifdef USE_SDL2
- StringVect sdlDriversList;
- SDL::getRenderers(sdlDriversList,
- config.getStringValue("sdlDriver"));
- sdlDriversList.insert(sdlDriversList.begin(),
- // TRANSLATORS: sdl driver name
- N_("default"));
-#endif // USE_SDL2
-
- // TRANSLATORS: settings option
- new SetupItemLabel(_("Better performance (enable for better performance)"),
- "", this);
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Auto adjust performance"), "",
- "adjustPerfomance", this, "adjustPerfomanceEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Hw acceleration"), "",
- "hwaccel", this, "hwaccelEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Enable opacity cache (Software, can "
- "use much memory)"), "", "alphaCache", this, "alphaCacheEvent");
-
-#ifndef USE_SDL2
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Enable map reduce (Software)"), "",
- "enableMapReduce", this, "enableMapReduceEvent");
-#endif // USE_SDL2
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Enable compound sprite delay (Software)"), "",
- "enableCompoundSpriteDelay", this, "enableCompoundSpriteDelayEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Enable delayed images load (OpenGL)"), "",
- "enableDelayedAnimations", this, "enableDelayedAnimationsEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Enable texture sampler (OpenGL)"), "",
- "useTextureSampler", this, "useTextureSamplerEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Enable OpenGL context creation"),
- "", "openglContext", this, "openglContextEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Enable OpenGL direct state access"),
- "", "enableDSA", this, "enableDSAEvent");
-
-
- // TRANSLATORS: settings option
- new SetupItemLabel(_("Better quality (disable for better performance)"),
- "", this);
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Enable alpha channel fix (Software, can "
- "be very slow)"), "Can slow down drawing", "enableAlphaFix",
- this, "enableAlphaFixEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Show beings transparency"), "",
- "beingopacity", this, "beingopacityEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Enable reorder sprites (need for mods support)."),
- "", "enableReorderSprites", this, "enableReorderSpritesEvent");
-
-
-#ifndef USE_SDL2
- // TRANSLATORS: settings option
- new SetupItemLabel(_("Small memory (enable for lower memory usage)"),
- "", this);
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Disable advanced beings caching (Software)"), "",
- "disableAdvBeingCaching", this, "disableAdvBeingCachingEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Disable beings caching (Software)"), "",
- "disableBeingCaching", this, "disableBeingCachingEvent");
-#endif // USE_SDL2
-
-
- // TRANSLATORS: settings group
- new SetupItemLabel(_("Different options (enable or disable can "
- "improve performance)"), "", this);
-
-#ifdef USE_SDL2
- mSdlDriversList->fillFromVector(sdlDriversList);
- new SetupItemDropDownStr(
- // TRANSLATORS: settings option
- _("Try first sdl driver (only for SDL2 default mode)"),
- "", "sdlDriver", this, "sdlDriverEvent", mSdlDriversList, 100);
-#endif // USE_SDL2
-
- mTexturesList->fillFromArray(&texturesList[0], texturesListSize);
- // TRANSLATORS: settings option
- new SetupItemDropDown(_("Enable texture compression (OpenGL)"), "",
- "compresstextures", this, "compresstexturesEvent", mTexturesList, 100);
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Enable rectangular texture extension (OpenGL)"),
- "", "rectangulartextures", this, "rectangulartexturesEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Use new texture internal format (OpenGL)"),
- "", "newtextures", this, "newtexturesEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Enable texture atlases (OpenGL)"), "",
- "useAtlases", this, "useAtlasesEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Cache all sprites per map (can use "
- "additional memory)"), "", "uselonglivesprites", this,
- "uselonglivespritesEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Cache all sounds (can use additional memory)"),
- "", "uselonglivesounds", this,
- "uselonglivesoundsEvent");
-
- // TRANSLATORS: settings group
- new SetupItemLabel(_("Critical options (DO NOT change if you don't "
- "know what you're doing)"), "", this);
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Disable logging in game (do not enable)"),
- "", "disableLoggingInGame", this, "disableLoggingInGameEvent");
-
- setDimension(Rect(0, 0, 550, 350));
-}
-
-Setup_Perfomance::~Setup_Perfomance()
-{
- delete2(mTexturesList);
-#ifdef USE_SDL2
- delete2(mSdlDriversList);
-#endif // USE_SDL2
-}
diff --git a/src/gui/widgets/tabs/setup_perfomance.h b/src/gui/widgets/tabs/setup_perfomance.h
deleted file mode 100644
index 95030a8e5..000000000
--- a/src/gui/widgets/tabs/setup_perfomance.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 Andrei Karas
- * 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_TABS_SETUP_PERFOMANCE_H
-#define GUI_WIDGETS_TABS_SETUP_PERFOMANCE_H
-
-#include "gui/widgets/tabs/setuptabscroll.h"
-
-class NamesModel;
-
-class Setup_Perfomance final : public SetupTabScroll
-{
- public:
- explicit Setup_Perfomance(const Widget2 *const widget);
-
- A_DELETE_COPY(Setup_Perfomance)
-
- ~Setup_Perfomance();
-
- private:
-#ifdef USE_SDL2
- NamesModel *mSdlDriversList;
-#endif // USE_SDL2
- NamesModel *mTexturesList;
-};
-
-#endif // GUI_WIDGETS_TABS_SETUP_PERFOMANCE_H
diff --git a/src/gui/widgets/tabs/setup_players.cpp b/src/gui/widgets/tabs/setup_players.cpp
deleted file mode 100644
index 6d964799d..000000000
--- a/src/gui/widgets/tabs/setup_players.cpp
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 Andrei Karas
- * 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 "gui/widgets/tabs/setup_players.h"
-
-#include "configuration.h"
-#include "settings.h"
-
-#include "gui/models/namesmodel.h"
-
-#include "gui/widgets/containerplacer.h"
-#include "gui/widgets/layouthelper.h"
-#include "gui/widgets/scrollarea.h"
-#include "gui/widgets/setupitem.h"
-
-#include "utils/delete2.h"
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-static const int badgesListSize = 4;
-
-static const char *const badgesList[] =
-{
- // TRANSLATORS: screen badges type
- N_("hide"),
- // TRANSLATORS: screen badges type
- N_("show at top"),
- // TRANSLATORS: screen badges type
- N_("show at right"),
- // TRANSLATORS: screen badges type
- N_("show at bottom"),
-};
-
-static const int visibleNamesListSize = 3;
-
-static const char *const visibleNamesList[] =
-{
- // TRANSLATORS: visible name type
- N_("hide"),
- // TRANSLATORS: visible name type
- N_("show"),
- // TRANSLATORS: visible name type
- N_("show on selection")
-};
-
-static const int topDownListSize = 2;
-
-static const char *const topDownList[] =
-{
- // TRANSLATORS: show on top or down
- N_("top"),
- // TRANSLATORS: show on top or down
- N_("bottom")
-};
-
-Setup_Players::Setup_Players(const Widget2 *const widget) :
- SetupTabScroll(widget),
- mBadgesList(new NamesModel),
- mVisibleNamesList(new NamesModel),
- mVisibleNamesPosList(new NamesModel)
-{
- // TRANSLATORS: settings tab name
- setName(_("Players"));
-
- LayoutHelper h(this);
- ContainerPlacer place = h.getPlacer(0, 0);
- place(0, 0, mScroll, 10, 10);
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Show gender"), "",
- "showgender", this, "showgenderEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Show level"), "",
- "showlevel", this, "showlevelEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Show own name"), "",
- "showownname", this, "showownnameEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Enable extended mouse targeting"), "",
- "extMouseTargeting", this, "extMouseTargetingEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Target dead players"), "",
- "targetDeadPlayers", this, "targetDeadPlayersEvent");
-
- mVisibleNamesList->fillFromArray(&visibleNamesList[0],
- visibleNamesListSize);
- // TRANSLATORS: settings option
- new SetupItemDropDown(_("Show player names"), "",
- "visiblenames", this, "visiblenamesEvent",
- mVisibleNamesList, 150);
-
- mVisibleNamesPosList->fillFromArray(&topDownList[0],
- topDownListSize);
- // TRANSLATORS: settings option
- new SetupItemDropDown(_("Show player names at"), "",
- "visiblenamespos", this, "visiblenamesposEvent",
- mVisibleNamesPosList, 150);
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Auto move names"), "",
- "moveNames", this, "moveNamesEvent");
-
- mBadgesList->fillFromArray(&badgesList[0], badgesListSize);
- // TRANSLATORS: settings option
- new SetupItemDropDown(_("Badges"), "",
- "showBadges", this, "showBadgesEvent", mBadgesList, 150);
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Secure trades"), "",
- "securetrades", this, "securetradesEvent");
-
- // TRANSLATORS: settings option
- new SetupItemTextField(_("Unsecure chars in names"), "",
- "unsecureChars", this, "unsecureCharsEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Show statuses"), "",
- "showPlayersStatus", this, "showPlayersStatusEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Show ip addresses on screenshots"), "",
- "showip", this, "showipEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Allow self heal with mouse click"), "",
- "selfMouseHeal", this, "selfMouseHealEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Group friends in who is online window"), "",
- "groupFriends", this, "groupFriendsEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Hide erased players nicks"), "",
- "hideErased", this, "hideErasedEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Collect players id and seen log"),
- "", "enableIdCollecting", this, "enableIdCollectingEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Use special diagonal speed in players moving"),
- "", "useDiagonalSpeed", this, "useDiagonalSpeedEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Log players actions (for GM)"),
- "", "logPlayerActions", this, "logPlayerActionsEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Create screenshots for each complete trades"),
- "", "tradescreenshot", this, "tradescreenshotEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Emulate right mouse button by long mouse click"
- " (useful for touch interfaces)"),
- "", "longmouseclick", this, "longmouseclickEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Enable remote commands"),
- "", "enableRemoteCommands", this, "enableRemoteCommandsEvent",
- "1",
- MainConfig_false);
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Allow move character by mouse"),
- "", "allowMoveByMouse", this, "allowMoveByMouseEvent");
-
- setDimension(Rect(0, 0, 550, 350));
-}
-
-Setup_Players::~Setup_Players()
-{
- delete2(mBadgesList);
- delete2(mVisibleNamesList);
- delete2(mVisibleNamesPosList);
-}
-
-void Setup_Players::externalUpdated()
-{
- reread("enableRemoteCommands");
-}
-
-void Setup_Players::apply()
-{
- SetupTabScroll::apply();
- settings.enableRemoteCommands = (serverConfig.getValue(
- "enableRemoteCommands", 1) != 0);
-}
diff --git a/src/gui/widgets/tabs/setup_players.h b/src/gui/widgets/tabs/setup_players.h
deleted file mode 100644
index d29d41781..000000000
--- a/src/gui/widgets/tabs/setup_players.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 Andrei Karas
- * 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_TABS_SETUP_PLAYERS_H
-#define GUI_WIDGETS_TABS_SETUP_PLAYERS_H
-
-#include "gui/widgets/tabs/setuptabscroll.h"
-
-class NamesModel;
-
-class Setup_Players final : public SetupTabScroll
-{
- public:
- explicit Setup_Players(const Widget2 *const widget);
-
- ~Setup_Players();
-
- A_DELETE_COPY(Setup_Players)
-
- void apply() override final;
-
- void externalUpdated() override final;
-
- private:
- NamesModel *mBadgesList;
- NamesModel *mVisibleNamesList;
- NamesModel *mVisibleNamesPosList;
-};
-
-#endif // GUI_WIDGETS_TABS_SETUP_PLAYERS_H
diff --git a/src/gui/widgets/tabs/setup_quick.cpp b/src/gui/widgets/tabs/setup_quick.cpp
deleted file mode 100644
index f86707fe1..000000000
--- a/src/gui/widgets/tabs/setup_quick.cpp
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 Andrei Karas
- * 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 "gui/widgets/tabs/setup_quick.h"
-
-#include "gamemodifiers.h"
-
-#include "gui/models/namesmodel.h"
-
-#include "gui/widgets/containerplacer.h"
-#include "gui/widgets/layouthelper.h"
-#include "gui/widgets/setupquickitem.h"
-#include "gui/widgets/scrollarea.h"
-
-#include "utils/delete2.h"
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-Setup_Quick::Setup_Quick(const Widget2 *const widget) :
- SetupTabScroll(widget),
- mMoveTypeList(new NamesModel),
- mCrazyMoveTypeList(new NamesModel)
-{
- // TRANSLATORS: quick tab in settings
- setName(_("Quick"));
-
- LayoutHelper h(this);
- ContainerPlacer place = h.getPlacer(0, 0);
- place(0, 0, mScroll, 10, 10);
-
- new SetupQuickItem("", this, "moveTypeEvent",
- &GameModifiers::getMoveTypeString,
- &GameModifiers::changeMoveType);
-
- new SetupQuickItem("", this, "crazyMoveTypeEvent",
- &GameModifiers::getCrazyMoveTypeString,
- &GameModifiers::changeCrazyMoveType);
-
- new SetupQuickItem("", this, "moveToTargetTypeEvent",
- &GameModifiers::getMoveToTargetTypeString,
- &GameModifiers::changeMoveToTargetType);
-
- new SetupQuickItem("", this, "followModeEvent",
- &GameModifiers::getFollowModeString,
- &GameModifiers::changeFollowMode);
-
- new SetupQuickItem("", this, "attackWeaponTypeEvent",
- &GameModifiers::getAttackWeaponTypeString,
- &GameModifiers::changeAttackWeaponType);
-
- new SetupQuickItem("", this, "attackTypeEvent",
- &GameModifiers::getAttackTypeString,
- &GameModifiers::changeAttackType);
-
- new SetupQuickItem("", this, "magicAttackTypeEvent",
- &GameModifiers::getMagicAttackTypeString,
- &GameModifiers::changeMagicAttackType);
-
- new SetupQuickItem("", this, "pvpAttackTypeEvent",
- &GameModifiers::getPvpAttackTypeString,
- &GameModifiers::changePvpAttackType);
-
- new SetupQuickItem("", this, "quickDropCounterEvent",
- &GameModifiers::getQuickDropCounterString,
- &GameModifiers::changeQuickDropCounter);
-
- new SetupQuickItem("", this, "pickUpTypeEvent",
- &GameModifiers::getPickUpTypeString,
- &GameModifiers::changePickUpType);
-
- new SetupQuickItem("", this, "mapDrawTypeEvent",
- &GameModifiers::getMapDrawTypeString,
- &GameModifiers::changeMapDrawType);
-
- new SetupQuickItem("", this, "imitationModeEvent",
- &GameModifiers::getImitationModeString,
- &GameModifiers::changeImitationMode);
-
- new SetupQuickItem("", this, "CameraModeEvent",
- &GameModifiers::getCameraModeString,
- &GameModifiers::changeCameraMode);
-
- new SetupQuickItem("", this, "awayModeEvent",
- &GameModifiers::getAwayModeString,
- &GameModifiers::changeAwayMode);
-
- new SetupQuickItem("", this, "targetingTypeEvent",
- &GameModifiers::getTargetingTypeString,
- &GameModifiers::changeTargetingType);
-
- setDimension(Rect(0, 0, 550, 350));
-}
-
-Setup_Quick::~Setup_Quick()
-{
- delete2(mMoveTypeList);
- delete2(mCrazyMoveTypeList);
-}
diff --git a/src/gui/widgets/tabs/setup_quick.h b/src/gui/widgets/tabs/setup_quick.h
deleted file mode 100644
index f174153ee..000000000
--- a/src/gui/widgets/tabs/setup_quick.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 Andrei Karas
- * 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_TABS_SETUP_QUICK_H
-#define GUI_WIDGETS_TABS_SETUP_QUICK_H
-
-#include "gui/widgets/tabs/setuptabscroll.h"
-
-class NamesModel;
-
-class Setup_Quick final : public SetupTabScroll
-{
- public:
- explicit Setup_Quick(const Widget2 *const widget);
-
- A_DELETE_COPY(Setup_Quick)
-
- ~Setup_Quick();
-
- protected:
- NamesModel *mMoveTypeList;
-
- NamesModel *mCrazyMoveTypeList;
-};
-
-#endif // GUI_WIDGETS_TABS_SETUP_QUICK_H
diff --git a/src/gui/widgets/tabs/setup_relations.cpp b/src/gui/widgets/tabs/setup_relations.cpp
deleted file mode 100644
index 4cc81a300..000000000
--- a/src/gui/widgets/tabs/setup_relations.cpp
+++ /dev/null
@@ -1,266 +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 "gui/widgets/tabs/setup_relations.h"
-
-#include "actormanager.h"
-
-#include "being/localplayer.h"
-
-#include "gui/models/ignorechoiceslistmodel.h"
-#include "gui/models/playertablemodel.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/checkbox.h"
-#include "gui/widgets/containerplacer.h"
-#include "gui/widgets/dropdown.h"
-#include "gui/widgets/label.h"
-#include "gui/widgets/layouthelper.h"
-#include "gui/widgets/scrollarea.h"
-#include "gui/widgets/guitable.h"
-
-#include "utils/delete2.h"
-
-#include "debug.h"
-
-static const int COLUMNS_NR = 2; // name plus listbox
-static const int NAME_COLUMN = 0;
-static const unsigned int NAME_COLUMN_WIDTH = 230;
-static const unsigned int RELATION_CHOICE_COLUMN = 1;
-static const unsigned int RELATION_CHOICE_COLUMN_WIDTH = 80;
-
-static const std::string ACTION_DELETE("delete");
-static const std::string ACTION_TABLE("table");
-static const std::string ACTION_STRATEGY("strategy");
-
-static const char *const table_titles[COLUMNS_NR] =
-{
- // TRANSLATORS: relations table header
- N_("Name"),
- // TRANSLATORS: relations table header
- N_("Relation")
-};
-
-Setup_Relations::Setup_Relations(const Widget2 *const widget) :
- SetupTab(widget),
- PlayerRelationsListener(),
- mPlayerTableTitleModel(new StaticTableModel(1, COLUMNS_NR)),
- mPlayerTableModel(new PlayerTableModel(this)),
- mPlayerTable(new GuiTable(this, mPlayerTableModel)),
- mPlayerTitleTable(new GuiTable(this, mPlayerTableTitleModel)),
- mPlayerScrollArea(new ScrollArea(this, mPlayerTable)),
- // TRANSLATORS: relation dialog button
- mDefaultTrading(new CheckBox(this, _("Allow trading"),
- (playerRelations.getDefault() & PlayerRelation::TRADE) != 0u)),
- // TRANSLATORS: relation dialog button
- mDefaultWhisper(new CheckBox(this, _("Allow whispers"),
- (playerRelations.getDefault() & PlayerRelation::WHISPER) != 0u)),
- // TRANSLATORS: relation dialog button
- mDeleteButton(new Button(this, _("Delete"), ACTION_DELETE, this)),
- mIgnoreActionChoicesModel(new IgnoreChoicesListModel),
- mIgnoreActionChoicesBox(new DropDown(widget, mIgnoreActionChoicesModel))
-{
- // TRANSLATORS: relation dialog name
- setName(_("Relations"));
-
- mPlayerTable->setOpaque(Opaque_false);
-
- mPlayerTableTitleModel->fixColumnWidth(NAME_COLUMN, NAME_COLUMN_WIDTH);
- mPlayerTableTitleModel->fixColumnWidth(RELATION_CHOICE_COLUMN,
- RELATION_CHOICE_COLUMN_WIDTH);
- mPlayerTitleTable->setBackgroundColor(getThemeColor(
- ThemeColorId::TABLE_BACKGROUND));
- mPlayerTitleTable->setSelectableGui(false);
-
- for (int i = 0; i < COLUMNS_NR; i++)
- {
- mPlayerTableTitleModel->set(0, i, new Label(
- this, gettext(table_titles[i])));
- }
-
- mPlayerTitleTable->setLinewiseSelection(true);
-
- mPlayerScrollArea->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
- mPlayerTable->setActionEventId(ACTION_TABLE);
- mPlayerTable->setLinewiseSelection(true);
- mPlayerTable->addActionListener(this);
-
- // TRANSLATORS: relation dialog label
- Label *const ignore_action_label = new Label(this, _("When ignoring:"));
-
- mIgnoreActionChoicesBox->setActionEventId(ACTION_STRATEGY);
- mIgnoreActionChoicesBox->addActionListener(this);
-
- int ignore_strategy_index = 0; // safe default
-
- if (playerRelations.getPlayerIgnoreStrategy() != nullptr)
- {
- ignore_strategy_index = playerRelations.getPlayerIgnoreStrategyIndex(
- playerRelations.getPlayerIgnoreStrategy()->mShortName);
- if (ignore_strategy_index < 0)
- ignore_strategy_index = 0;
- }
- mIgnoreActionChoicesBox->setSelected(ignore_strategy_index);
- mIgnoreActionChoicesBox->adjustHeight();
-
- reset();
-
- // Do the layout
- LayoutHelper h(this);
- ContainerPlacer place = h.getPlacer(0, 0);
-
- place(0, 0, mPlayerTitleTable, 6);
- place(0, 1, mPlayerScrollArea, 6, 4).setPadding(2);
- place(0, 5, mDeleteButton);
- place(3, 5, ignore_action_label, 1);
- place(4, 5, mIgnoreActionChoicesBox, 2).setPadding(2);
- place(3, 6, mDefaultTrading, 3);
- place(3, 7, mDefaultWhisper, 3);
-
- playerRelations.addListener(this);
-
- setDimension(Rect(0, 0, 500, 350));
-}
-
-Setup_Relations::~Setup_Relations()
-{
- playerRelations.removeListener(this);
- delete2(mIgnoreActionChoicesModel);
-}
-
-
-void Setup_Relations::reset()
-{
- // We now have to search through the list of ignore choices to find the
- // current selection. We could use an index into the table of config
- // options in playerRelations instead of strategies to sidestep this.
- int selection = 0;
- for (size_t i = 0, sz = playerRelations.getPlayerIgnoreStrategies()
- ->size(); i < sz; ++ i)
- {
- if ((*playerRelations.getPlayerIgnoreStrategies())[i] ==
- playerRelations.getPlayerIgnoreStrategy())
- {
- selection = CAST_S32(i);
- break;
- }
- }
- mIgnoreActionChoicesBox->setSelected(selection);
-}
-
-void Setup_Relations::apply()
-{
- playerRelations.store();
-
- const unsigned int old_default_relations = playerRelations.getDefault() &
- ~(PlayerRelation::TRADE | PlayerRelation::WHISPER);
- playerRelations.setDefault(old_default_relations
- | (mDefaultTrading->isSelected() ? PlayerRelation::TRADE : 0)
- | (mDefaultWhisper->isSelected() ? PlayerRelation::WHISPER : 0));
-
- if (actorManager != nullptr)
- actorManager->updatePlayerNames();
-
- if (localPlayer != nullptr)
- localPlayer->setCheckNameSetting(true);
-}
-
-void Setup_Relations::cancel()
-{
-}
-
-void Setup_Relations::action(const ActionEvent &event)
-{
- const std::string &eventId = event.getId();
- if (eventId == ACTION_TABLE)
- {
- // temporarily eliminate ourselves: we are fully aware of this change,
- // so there is no need for asynchronous updates. (In fact, thouse
- // might destroy the widet that triggered them, which would be rather
- // embarrassing.)
- playerRelations.removeListener(this);
-
- const int row = mPlayerTable->getSelectedRow();
- if (row >= 0)
- mPlayerTableModel->updateModelInRow(row);
-
- playerRelations.addListener(this);
- }
- else if (eventId == ACTION_DELETE)
- {
- const int player_index = mPlayerTable->getSelectedRow();
-
- if (player_index < 0)
- return;
-
- playerRelations.removePlayer(mPlayerTableModel->getPlayerAt(
- player_index));
- }
- else if (eventId == ACTION_STRATEGY)
- {
- const int sel = mIgnoreActionChoicesBox->getSelected();
- if (sel < 0)
- return;
- PlayerIgnoreStrategy *const s =
- (*playerRelations.getPlayerIgnoreStrategies())[sel];
-
- playerRelations.setPlayerIgnoreStrategy(s);
- }
-}
-
-void Setup_Relations::updatedPlayer(const std::string &name A_UNUSED)
-{
- mPlayerTableModel->playerRelationsUpdated();
- mDefaultTrading->setSelected(
- (playerRelations.getDefault() & PlayerRelation::TRADE) != 0u);
- mDefaultWhisper->setSelected(
- (playerRelations.getDefault() & PlayerRelation::WHISPER) != 0u);
- if (localPlayer != nullptr)
- localPlayer->updateName();
-}
-
-void Setup_Relations::updateAll()
-{
- PlayerTableModel *const model = new PlayerTableModel(this);
- mPlayerTable->setModel(model);
- delete mPlayerTableModel;
- mPlayerTableModel = model;
- int ignore_strategy_index = 0; // safe default
-
- if (playerRelations.getPlayerIgnoreStrategy() != nullptr)
- {
- ignore_strategy_index = playerRelations.getPlayerIgnoreStrategyIndex(
- playerRelations.getPlayerIgnoreStrategy()->mShortName);
- if (ignore_strategy_index < 0)
- ignore_strategy_index = 0;
- }
- mIgnoreActionChoicesBox->setSelected(ignore_strategy_index);
- mIgnoreActionChoicesBox->adjustHeight();
- reset();
-}
-void Setup_Relations::externalUpdated()
-{
- mDefaultTrading->setSelected(
- (playerRelations.getDefault() & PlayerRelation::TRADE) != 0u);
- mDefaultWhisper->setSelected(
- (playerRelations.getDefault() & PlayerRelation::WHISPER) != 0u);
-}
diff --git a/src/gui/widgets/tabs/setup_relations.h b/src/gui/widgets/tabs/setup_relations.h
deleted file mode 100644
index 879450891..000000000
--- a/src/gui/widgets/tabs/setup_relations.h
+++ /dev/null
@@ -1,79 +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 GUI_WIDGETS_TABS_SETUP_RELATIONS_H
-#define GUI_WIDGETS_TABS_SETUP_RELATIONS_H
-
-#include "gui/widgets/tabs/setuptab.h"
-
-#include "listeners/playerrelationslistener.h"
-
-class Button;
-class CheckBox;
-class DropDown;
-class GuiTable;
-class ListModel;
-class PlayerTableModel;
-class ScrollArea;
-class StaticTableModel;
-
-class Setup_Relations final : public SetupTab,
- public PlayerRelationsListener
-{
- public:
- explicit Setup_Relations(const Widget2 *const widget);
-
- A_DELETE_COPY(Setup_Relations)
-
- ~Setup_Relations();
-
- void apply() override final;
-
- void cancel() override final A_CONST;
-
- void reset();
-
- void action(const ActionEvent &event) override final;
-
- void updatedPlayer(const std::string &name) override final;
-
- void updateAll() override final;
-
- void externalUpdated() override final;
-
- private:
- StaticTableModel *mPlayerTableTitleModel;
- PlayerTableModel *mPlayerTableModel;
- GuiTable *mPlayerTable;
- GuiTable *mPlayerTitleTable;
- ScrollArea *mPlayerScrollArea;
-
- CheckBox *mDefaultTrading;
- CheckBox *mDefaultWhisper;
-
- Button *mDeleteButton;
-
- ListModel *mIgnoreActionChoicesModel;
- DropDown *mIgnoreActionChoicesBox;
-};
-
-#endif // GUI_WIDGETS_TABS_SETUP_RELATIONS_H
diff --git a/src/gui/widgets/tabs/setup_theme.cpp b/src/gui/widgets/tabs/setup_theme.cpp
deleted file mode 100644
index 47cbb2b92..000000000
--- a/src/gui/widgets/tabs/setup_theme.cpp
+++ /dev/null
@@ -1,415 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 Andrei Karas
- * 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 "gui/widgets/tabs/setup_theme.h"
-
-#include "gui/gui.h"
-#include "gui/themeinfo.h"
-
-#include "gui/windows/okdialog.h"
-
-#include "gui/models/fontsizechoicelistmodel.h"
-#include "gui/models/fontsmodel.h"
-#include "gui/models/langlistmodel.h"
-#include "gui/models/themesmodel.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/containerplacer.h"
-#include "gui/widgets/createwidget.h"
-#include "gui/widgets/dropdown.h"
-#include "gui/widgets/label.h"
-#include "gui/widgets/layouthelper.h"
-
-#include "configuration.h"
-
-#include "utils/delete2.h"
-
-#include "debug.h"
-
-const char* ACTION_THEME = "theme";
-const char* ACTION_FONT = "font";
-const char* ACTION_LANG = "lang";
-const char* ACTION_BOLD_FONT = "bold font";
-const char* ACTION_PARTICLE_FONT = "particle font";
-const char* ACTION_HELP_FONT = "help font";
-const char* ACTION_SECURE_FONT = "secure font";
-const char* ACTION_NPC_FONT = "npc font";
-const char* ACTION_JAPAN_FONT = "japanese font";
-const char* ACTION_CHINA_FONT = "chinese font";
-const char* ACTION_INFO = "info";
-
-Setup_Theme::Setup_Theme(const Widget2 *const widget) :
- SetupTab(widget),
- // TRANSLATORS: theme settings label
- mThemeLabel(new Label(this, _("Gui theme"))),
- mThemesModel(new ThemesModel),
- mThemeDropDown(new DropDown(this, mThemesModel)),
- mTheme(config.getStringValue("theme")),
- mInfo(Theme::loadInfo(mTheme)),
- mFontsModel(new FontsModel),
- // TRANSLATORS: theme settings label
- mFontLabel(new Label(this, _("Main Font"))),
- mFontDropDown(new DropDown(this, mFontsModel)),
- mFont(config.getStringValue("font")),
- mLangListModel(new LangListModel),
- // TRANSLATORS: theme settings label
- mLangLabel(new Label(this, _("Language"))),
- mLangDropDown(new DropDown(this, mLangListModel, true)),
- mLang(config.getStringValue("lang")),
- // TRANSLATORS: theme settings label
- mBoldFontLabel(new Label(this, _("Bold font"))),
- mBoldFontDropDown(new DropDown(this, mFontsModel)),
- mBoldFont(config.getStringValue("boldFont")),
- // TRANSLATORS: theme settings label
- mParticleFontLabel(new Label(this, _("Particle font"))),
- mParticleFontDropDown(new DropDown(this, mFontsModel)),
- mParticleFont(config.getStringValue("particleFont")),
- // TRANSLATORS: theme settings label
- mHelpFontLabel(new Label(this, _("Help font"))),
- mHelpFontDropDown(new DropDown(this, mFontsModel)),
- mHelpFont(config.getStringValue("helpFont")),
- // TRANSLATORS: theme settings label
- mSecureFontLabel(new Label(this, _("Secure font"))),
- mSecureFontDropDown(new DropDown(this, mFontsModel)),
- mSecureFont(config.getStringValue("secureFont")),
- // TRANSLATORS: theme settings label
- mNpcFontLabel(new Label(this, _("Npc font"))),
- mNpcFontDropDown(new DropDown(this, mFontsModel)),
- mNpcFont(config.getStringValue("npcFont")),
- // TRANSLATORS: theme settings label
- mJapanFontLabel(new Label(this, _("Japanese font"))),
- mJapanFontDropDown(new DropDown(this, mFontsModel)),
- mJapanFont(config.getStringValue("japanFont")),
- // TRANSLATORS: theme settings label
- mChinaFontLabel(new Label(this, _("Chinese font"))),
- mChinaFontDropDown(new DropDown(this, mFontsModel)),
- mChinaFont(config.getStringValue("chinaFont")),
- mFontSizeListModel(new FontSizeChoiceListModel),
- // TRANSLATORS: theme settings label
- mFontSizeLabel(new Label(this, _("Font size"))),
- mFontSize(config.getIntValue("fontSize")),
- mFontSizeDropDown(new DropDown(this, mFontSizeListModel)),
- mNpcFontSizeListModel(new FontSizeChoiceListModel),
- // TRANSLATORS: theme settings label
- mNpcFontSizeLabel(new Label(this, _("Npc font size"))),
- mNpcFontSize(config.getIntValue("npcfontSize")),
- mNpcFontSizeDropDown(new DropDown(this, mNpcFontSizeListModel)),
- // TRANSLATORS: button name with information about selected theme
- mInfoButton(new Button(this, _("i"), ACTION_INFO, this)),
- mThemeInfo()
-{
- // TRANSLATORS: theme settings tab name
- setName(_("Theme"));
-
- mThemeDropDown->setActionEventId(ACTION_THEME);
- mThemeDropDown->addActionListener(this);
- mFontDropDown->setActionEventId(ACTION_FONT);
- mFontDropDown->addActionListener(this);
- mLangDropDown->setActionEventId(ACTION_LANG);
- mLangDropDown->addActionListener(this);
- mBoldFontDropDown->setActionEventId(ACTION_BOLD_FONT);
- mBoldFontDropDown->addActionListener(this);
- mParticleFontDropDown->setActionEventId(ACTION_PARTICLE_FONT);
- mParticleFontDropDown->addActionListener(this);
- mHelpFontDropDown->setActionEventId(ACTION_HELP_FONT);
- mHelpFontDropDown->addActionListener(this);
- mSecureFontDropDown->setActionEventId(ACTION_SECURE_FONT);
- mSecureFontDropDown->addActionListener(this);
- mNpcFontDropDown->setActionEventId(ACTION_NPC_FONT);
- mNpcFontDropDown->addActionListener(this);
- mJapanFontDropDown->setActionEventId(ACTION_JAPAN_FONT);
- mJapanFontDropDown->addActionListener(this);
- mChinaFontDropDown->setActionEventId(ACTION_CHINA_FONT);
- mChinaFontDropDown->addActionListener(this);
- mFontSizeDropDown->setSelected(mFontSize - 9);
- mFontSizeDropDown->adjustHeight();
- mNpcFontSizeDropDown->setSelected(mNpcFontSize - 9);
- mNpcFontSizeDropDown->adjustHeight();
-
- const std::string skin = Theme::getThemeName();
- if (!skin.empty())
- mThemeDropDown->setSelectedString(skin);
- else
- mThemeDropDown->setSelected(0);
-
- const std::string str = config.getStringValue("lang");
- for (int f = 0; f < langs_count; f ++)
- {
- if (LANG_NAME[f].value == str)
- {
- mLangDropDown->setSelected(f);
- break;
- }
- }
-
- mFontDropDown->setSelectedString(getFileName(
- config.getStringValue("font")));
- mBoldFontDropDown->setSelectedString(getFileName(
- config.getStringValue("boldFont")));
- mParticleFontDropDown->setSelectedString(getFileName(
- config.getStringValue("particleFont")));
- mHelpFontDropDown->setSelectedString(getFileName(
- config.getStringValue("helpFont")));
- mSecureFontDropDown->setSelectedString(getFileName(
- config.getStringValue("secureFont")));
- mNpcFontDropDown->setSelectedString(getFileName(
- config.getStringValue("npcFont")));
- mJapanFontDropDown->setSelectedString(getFileName(
- config.getStringValue("japanFont")));
- mChinaFontDropDown->setSelectedString(getFileName(
- config.getStringValue("chinaFont")));
-
- updateInfo();
-
- // Do the layout
- LayoutHelper h(this);
- ContainerPlacer place = h.getPlacer(0, 0);
-
- place(0, 0, mThemeLabel, 5);
- place(0, 1, mLangLabel, 5);
- place(0, 2, mFontSizeLabel, 5);
- place(0, 3, mNpcFontSizeLabel, 5);
- place(0, 4, mFontLabel, 5);
- place(0, 5, mBoldFontLabel, 5);
- place(0, 6, mParticleFontLabel, 5);
- place(0, 7, mHelpFontLabel, 5);
- place(0, 8, mSecureFontLabel, 5);
- place(0, 9, mNpcFontLabel, 5);
- place(0, 10, mJapanFontLabel, 5);
- place(0, 11, mChinaFontLabel, 5);
-
- place(6, 0, mThemeDropDown, 10);
- place(6, 1, mLangDropDown, 10);
- place(6, 2, mFontSizeDropDown, 10);
- place(6, 3, mNpcFontSizeDropDown, 10);
- place(6, 4, mFontDropDown, 10);
- place(6, 5, mBoldFontDropDown, 10);
- place(6, 6, mParticleFontDropDown, 10);
- place(6, 7, mHelpFontDropDown, 10);
- place(6, 8, mSecureFontDropDown, 10);
- place(6, 9, mNpcFontDropDown, 10);
- place(6, 10, mJapanFontDropDown, 10);
- place(6, 11, mChinaFontDropDown, 10);
-
- place(17, 0, mInfoButton, 1);
-
- int size = mainGraphics->mWidth - 10;
- const int maxWidth = mFontSize * 30 + 290;
- if (size < 465)
- size = 465;
- else if (size > maxWidth)
- size = maxWidth;
-
- setDimension(Rect(0, 0, size, 500));
-}
-
-Setup_Theme::~Setup_Theme()
-{
- delete2(mInfo);
- delete2(mThemesModel);
- delete2(mFontsModel);
- delete2(mFontSizeListModel);
- delete2(mNpcFontSizeListModel);
- delete2(mLangListModel);
- delete2(mInfo);
-}
-
-void Setup_Theme::updateInfo()
-{
- delete mInfo;
- mInfo = Theme::loadInfo(mTheme);
- if (mInfo != nullptr)
- {
- // TRANSLATORS: theme name
- mThemeInfo = std::string(_("Name: ")).append(mInfo->name)
- // TRANSLATORS: theme copyright
- .append("\n").append(_("Copyright:")).append("\n")
- .append(mInfo->copyright);
- }
- else
- {
- mThemeInfo.clear();
- }
- replaceAll(mThemeInfo, "\\n", "\n");
- mInfoButton->setEnabled(!mThemeInfo.empty());
-}
-
-void Setup_Theme::action(const ActionEvent &event)
-{
- const std::string &eventId = event.getId();
- if (eventId == ACTION_THEME)
- {
- if (mThemeDropDown->getSelected() == 0)
- mTheme.clear();
- else
- mTheme = mThemeDropDown->getSelectedString();
- updateInfo();
- }
- else if (eventId == ACTION_FONT)
- {
- mFont = mFontDropDown->getSelectedString();
- }
- else if (eventId == ACTION_LANG)
- {
- const int id = mLangDropDown->getSelected();
- if (id < 0 || id >= langs_count)
- mLang.clear();
- else
- mLang = LANG_NAME[id].value;
- }
- else if (eventId == ACTION_BOLD_FONT)
- {
- mBoldFont = mBoldFontDropDown->getSelectedString();
- }
- else if (eventId == ACTION_PARTICLE_FONT)
- {
- mParticleFont = mParticleFontDropDown->getSelectedString();
- }
- else if (eventId == ACTION_HELP_FONT)
- {
- mHelpFont = mHelpFontDropDown->getSelectedString();
- }
- else if (eventId == ACTION_SECURE_FONT)
- {
- mSecureFont = mSecureFontDropDown->getSelectedString();
- }
- else if (eventId == ACTION_NPC_FONT)
- {
- mNpcFont = mNpcFontDropDown->getSelectedString();
- }
- else if (eventId == ACTION_JAPAN_FONT)
- {
- mJapanFont = mJapanFontDropDown->getSelectedString();
- }
- else if (eventId == ACTION_CHINA_FONT)
- {
- mChinaFont = mChinaFontDropDown->getSelectedString();
- }
- else if (eventId == ACTION_INFO)
- {
- CREATEWIDGET(OkDialog,
- // TRANSLATORS: theme info dialog header
- _("Theme info"),
- mThemeInfo,
- // TRANSLATORS: ok dialog button
- _("OK"),
- DialogType::OK,
- Modal_true,
- ShowCenter_true,
- nullptr,
- 600);
- }
-}
-
-void Setup_Theme::cancel()
-{
- mTheme = config.getStringValue("theme");
- mLang = config.getStringValue("lang");
- mFont = getFileName(config.getStringValue("font"));
- mBoldFont = getFileName(config.getStringValue("boldFont"));
- mParticleFont = getFileName(config.getStringValue("particleFont"));
- mHelpFont = getFileName(config.getStringValue("helpFont"));
- mSecureFont = getFileName(config.getStringValue("secureFont"));
- mNpcFont = getFileName(config.getStringValue("npcFont"));
- mJapanFont = getFileName(config.getStringValue("japanFont"));
- mChinaFont = getFileName(config.getStringValue("chinaFont"));
-}
-
-#define updateField(name1, name2) if (!mInfo->name1.empty()) \
- name2 = mInfo->name1;
-
-void Setup_Theme::apply()
-{
- if (config.getStringValue("theme") != mTheme)
- {
- CREATEWIDGET(OkDialog,
- // TRANSLATORS: theme message dialog
- _("Theme Changed"),
- // TRANSLATORS: ok dialog message
- _("Restart your client for the change to take effect."),
- // TRANSLATORS: ok dialog button
- _("OK"),
- DialogType::OK,
- Modal_true,
- ShowCenter_true,
- nullptr,
- 260);
- }
-
- config.setValue("selectedSkin", "");
- if (config.getStringValue("theme") != mTheme && (mInfo != nullptr))
- {
- updateField(font, mFont);
- updateField(boldFont, mBoldFont);
- updateField(particleFont, mParticleFont);
- updateField(helpFont, mHelpFont);
- updateField(secureFont, mSecureFont);
- updateField(npcFont, mNpcFont);
- updateField(japanFont, mJapanFont);
- updateField(chinaFont, mChinaFont);
- if (mInfo->fontSize != 0)
- {
- const int size = mInfo->fontSize - 9;
- if (size >= 0)
- mFontSizeDropDown->setSelected(size);
- }
- if (mInfo->npcfontSize != 0)
- {
- const int size = mInfo->npcfontSize - 9;
- if (size >= 0)
- mNpcFontSizeDropDown->setSelected(size);
- }
- if (mInfo->guiAlpha > 0.01F)
- config.setValue("guialpha", mInfo->guiAlpha);
- }
- config.setValue("theme", mTheme);
- config.setValue("lang", mLang);
- if (config.getValue("font", "dejavusans.ttf") != mFont
- || config.getValue("boldFont", "dejavusans-bold.ttf") != mBoldFont
- || config.getValue("particleFont", "dejavusans.ttf") != mParticleFont
- || config.getValue("helpFont", "dejavusansmono.ttf") != mHelpFont
- || config.getValue("secureFont", "dejavusansmono.ttf") != mSecureFont
- || config.getValue("npcFont", "dejavusans.ttf") != mNpcFont
- || config.getValue("japanFont", "mplus-1p-regular.ttf") != mJapanFont
- || config.getValue("chinaFont", "fonts/wqy-microhei.ttf")
- != mChinaFont
- || config.getIntValue("fontSize")
- != CAST_S32(mFontSizeDropDown->getSelected()) + 9
- || config.getIntValue("npcfontSize")
- != CAST_S32(mNpcFontSizeDropDown->getSelected()) + 9)
- {
- config.setValue("font", "fonts/" + getFileName(mFont));
- config.setValue("boldFont", "fonts/" + getFileName(mBoldFont));
- config.setValue("particleFont", "fonts/" + getFileName(mParticleFont));
- config.setValue("helpFont", "fonts/" + getFileName(mHelpFont));
- config.setValue("secureFont", "fonts/" + getFileName(mSecureFont));
- config.setValue("npcFont", "fonts/" + getFileName(mNpcFont));
- config.setValue("japanFont", "fonts/" + getFileName(mJapanFont));
- config.setValue("chinaFont", "fonts/" + getFileName(mChinaFont));
- config.setValue("fontSize", mFontSizeDropDown->getSelected() + 9);
- config.setValue("npcfontSize",
- mNpcFontSizeDropDown->getSelected() + 9);
- gui->updateFonts();
- }
-}
-
-#undef updateField
diff --git a/src/gui/widgets/tabs/setup_theme.h b/src/gui/widgets/tabs/setup_theme.h
deleted file mode 100644
index 57798f243..000000000
--- a/src/gui/widgets/tabs/setup_theme.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 Andrei Karas
- * 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_TABS_SETUP_THEME_H
-#define GUI_WIDGETS_TABS_SETUP_THEME_H
-
-#include "gui/widgets/tabs/setuptab.h"
-
-class Button;
-class DropDown;
-class FontsModel;
-class FontSizeChoiceListModel;
-class Label;
-class LangListModel;
-class ThemesModel;
-
-class Setup_Theme final : public SetupTab
-{
- public:
- explicit Setup_Theme(const Widget2 *const widget);
-
- A_DELETE_COPY(Setup_Theme)
-
- ~Setup_Theme();
-
- void apply() override final;
-
- void cancel() override final;
-
- void action(const ActionEvent &event) override final;
-
- void updateInfo();
-
- private:
- Label *mThemeLabel;
- ThemesModel *mThemesModel A_NONNULLPOINTER;
- DropDown *mThemeDropDown;
- std::string mTheme;
- ThemeInfo *mInfo;
-
- FontsModel *mFontsModel A_NONNULLPOINTER;
- Label *mFontLabel A_NONNULLPOINTER;
- DropDown *mFontDropDown A_NONNULLPOINTER;
- std::string mFont;
-
- LangListModel *mLangListModel A_NONNULLPOINTER;
-
- Label *mLangLabel A_NONNULLPOINTER;
- DropDown *mLangDropDown A_NONNULLPOINTER;
- std::string mLang;
-
- Label *mBoldFontLabel A_NONNULLPOINTER;
- DropDown *mBoldFontDropDown A_NONNULLPOINTER;
- std::string mBoldFont;
-
- Label *mParticleFontLabel A_NONNULLPOINTER;
- DropDown *mParticleFontDropDown A_NONNULLPOINTER;
- std::string mParticleFont;
-
- Label *mHelpFontLabel A_NONNULLPOINTER;
- DropDown *mHelpFontDropDown A_NONNULLPOINTER;
- std::string mHelpFont;
-
- Label *mSecureFontLabel A_NONNULLPOINTER;
- DropDown *mSecureFontDropDown A_NONNULLPOINTER;
- std::string mSecureFont;
-
- Label *mNpcFontLabel A_NONNULLPOINTER;
- DropDown *mNpcFontDropDown A_NONNULLPOINTER;
- std::string mNpcFont;
-
- Label *mJapanFontLabel A_NONNULLPOINTER;
- DropDown *mJapanFontDropDown A_NONNULLPOINTER;
- std::string mJapanFont;
-
- Label *mChinaFontLabel A_NONNULLPOINTER;
- DropDown *mChinaFontDropDown A_NONNULLPOINTER;
- std::string mChinaFont;
-
- FontSizeChoiceListModel *mFontSizeListModel A_NONNULLPOINTER;
- Label *mFontSizeLabel;
- int mFontSize;
- DropDown *mFontSizeDropDown;
-
- FontSizeChoiceListModel *mNpcFontSizeListModel A_NONNULLPOINTER;
- Label *mNpcFontSizeLabel;
- int mNpcFontSize;
- DropDown *mNpcFontSizeDropDown A_NONNULLPOINTER;
-
- Button *mInfoButton A_NONNULLPOINTER;
- std::string mThemeInfo;
-};
-
-#endif // GUI_WIDGETS_TABS_SETUP_THEME_H
diff --git a/src/gui/widgets/tabs/setup_touch.cpp b/src/gui/widgets/tabs/setup_touch.cpp
deleted file mode 100644
index c8558fef9..000000000
--- a/src/gui/widgets/tabs/setup_touch.cpp
+++ /dev/null
@@ -1,134 +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 "gui/widgets/tabs/setup_touch.h"
-
-#include "gui/models/touchactionmodel.h"
-
-#include "gui/widgets/containerplacer.h"
-#include "gui/widgets/layouthelper.h"
-#include "gui/widgets/setuptouchitem.h"
-#include "gui/widgets/scrollarea.h"
-
-#include "utils/delete2.h"
-#include "utils/gettext.h"
-#include "utils/stringutils.h"
-
-#include "debug.h"
-
-static const int sizeListSize = 4;
-
-static const char *const sizeList[] =
-{
- // TRANSLATORS: onscreen button size
- N_("Small"),
- // TRANSLATORS: onscreen button size
- N_("Normal"),
- // TRANSLATORS: onscreen button size
- N_("Medium"),
- // TRANSLATORS: onscreen button size
- N_("Large")
-};
-
-static const int formatListSize = 6;
-
-static const char *const formatList[] =
-{
- "2x1",
- "2x2",
- "3x3",
- "4x2",
- "4x3",
- "3x2"
-};
-
-Setup_Touch::Setup_Touch(const Widget2 *const widget) :
- SetupTabScroll(widget),
- mSizeList(new NamesModel),
- mFormatList(new NamesModel),
- mActionsList(new TouchActionsModel)
-{
- // TRANSLATORS: touch settings tab
- setName(_("Touch"));
-
- LayoutHelper h(this);
- ContainerPlacer place = h.getPlacer(0, 0);
- place(0, 0, mScroll, 10, 10);
- mSizeList->fillFromArray(&sizeList[0], sizeListSize);
- mFormatList->fillFromArray(&formatList[0], formatListSize);
-
- // TRANSLATORS: settings option
- new SetupItemLabel(_("Onscreen keyboard"), "", this);
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Show onscreen keyboard icon"), "",
- "showScreenKeyboard", this, "showScreenKeyboardEvent");
-
- // TRANSLATORS: settings option
- new SetupActionDropDown(_("Keyboard icon action"), "",
- "screenActionKeyboard", this, "screenActionKeyboardEvent",
- mActionsList, 250);
-
-
- // TRANSLATORS: settings group
- new SetupItemLabel(_("Onscreen joystick"), "", this);
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Show onscreen joystick"), "",
- "showScreenJoystick", this, "showScreenJoystickEvent");
-
- // TRANSLATORS: settings option
- new SetupItemDropDown(_("Joystick size"), "", "screenJoystickSize", this,
- "screenJoystickEvent", mSizeList, 100);
-
-
- // TRANSLATORS: settings group
- new SetupItemLabel(_("Onscreen buttons"), "", this);
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Show onscreen buttons"), "",
- "showScreenButtons", this, "showScreenButtonsEvent");
-
- // TRANSLATORS: settings option
- new SetupItemDropDown(_("Buttons format"), "", "screenButtonsFormat", this,
- "screenButtonsFormatEvent", mFormatList, 100);
-
- // TRANSLATORS: settings option
- new SetupItemDropDown(_("Buttons size"), "", "screenButtonsSize", this,
- "screenButtonsSizeEvent", mSizeList, 100);
-
- for (unsigned int f = 0; f < 12; f ++)
- {
- std::string key = strprintf("screenActionButton%u", f);
- std::string event = strprintf("screenActionButton%uEvent", f);
- // TRANSLATORS: settings option
- new SetupActionDropDown(strprintf(_("Button %u action"), f + 1), "",
- key, this, event, mActionsList, 250);
- }
-
- setDimension(Rect(0, 0, 550, 350));
-}
-
-Setup_Touch::~Setup_Touch()
-{
- delete2(mSizeList);
- delete2(mFormatList);
- delete2(mActionsList);
-}
diff --git a/src/gui/widgets/tabs/setup_touch.h b/src/gui/widgets/tabs/setup_touch.h
deleted file mode 100644
index a87a46c77..000000000
--- a/src/gui/widgets/tabs/setup_touch.h
+++ /dev/null
@@ -1,44 +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 GUI_WIDGETS_TABS_SETUP_TOUCH_H
-#define GUI_WIDGETS_TABS_SETUP_TOUCH_H
-
-#include "gui/widgets/tabs/setuptabscroll.h"
-
-class NamesModel;
-class TouchActionsModel;
-
-class Setup_Touch final : public SetupTabScroll
-{
- public:
- explicit Setup_Touch(const Widget2 *const widget);
-
- A_DELETE_COPY(Setup_Touch)
-
- ~Setup_Touch();
-
- protected:
- NamesModel *mSizeList;
- NamesModel *mFormatList;
- TouchActionsModel *mActionsList;
-};
-
-#endif // GUI_WIDGETS_TABS_SETUP_TOUCH_H
diff --git a/src/gui/widgets/tabs/setup_video.cpp b/src/gui/widgets/tabs/setup_video.cpp
deleted file mode 100644
index b5b74e2b9..000000000
--- a/src/gui/widgets/tabs/setup_video.cpp
+++ /dev/null
@@ -1,534 +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 "gui/widgets/tabs/setup_video.h"
-
-#include "gui/windowmanager.h"
-
-#include "gui/windows/okdialog.h"
-#include "gui/windows/textdialog.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/checkbox.h"
-#include "gui/widgets/containerplacer.h"
-#include "gui/widgets/createwidget.h"
-#include "gui/widgets/label.h"
-#include "gui/widgets/layouthelper.h"
-#include "gui/widgets/listbox.h"
-#include "gui/widgets/scrollarea.h"
-#include "gui/widgets/slider.h"
-#include "gui/widgets/dropdown.h"
-
-#include "utils/delete2.h"
-
-#if defined(USE_OPENGL) && !defined(ANDROID) && !defined(__APPLE__)
-#include "graphicsmanager.h"
-
-#include "test/testmain.h"
-#endif // defined(USE_OPENGL) && !defined(ANDROID) && !defined(__APPLE__)
-
-#if defined(ANDROID) || defined(__APPLE__) || !defined(USE_OPENGL)
-#include "configuration.h"
-#endif // defined(ANDROID) || defined(__APPLE__) || !defined(USE_OPENGL)
-
-#if defined(ANDROID) || defined(__APPLE__)
-#include "utils/stringutils.h"
-#endif // defined(ANDROID) || defined(__APPLE__)
-
-#include "gui/models/modelistmodel.h"
-#include "gui/models/opengllistmodel.h"
-
-#include <sstream>
-
-#include "debug.h"
-
-Setup_Video::Setup_Video(const Widget2 *const widget) :
- SetupTab(widget),
- KeyListener(),
- mFullScreenEnabled(config.getBoolValue("screen")),
- mOpenGLEnabled(intToRenderType(config.getIntValue("opengl"))),
- mFps(config.getIntValue("fpslimit")),
- mAltFps(config.getIntValue("altfpslimit")),
- mModeListModel(new ModeListModel),
- mOpenGLListModel(new OpenGLListModel),
- mModeList(CREATEWIDGETR(ListBox, widget, mModeListModel, "")),
- // TRANSLATORS: video settings checkbox
- mFsCheckBox(new CheckBox(this, _("Full screen"), mFullScreenEnabled)),
- mOpenGLDropDown(new DropDown(widget, mOpenGLListModel)),
- // TRANSLATORS: video settings checkbox
- mFpsCheckBox(new CheckBox(this, _("FPS limit:"))),
- mFpsSlider(new Slider(this, 2.0, 160.0, 1.0)),
- mFpsLabel(new Label(this)),
- mAltFpsSlider(new Slider(this, 2.0, 160.0, 1.0)),
- // TRANSLATORS: video settings label
- mAltFpsLabel(new Label(this, _("Alt FPS limit: "))),
-#if !defined(ANDROID) && !defined(__APPLE__) && !defined(__native_client__)
- // TRANSLATORS: video settings button
- mDetectButton(new Button(this, _("Detect best mode"), "detect", this)),
-#endif // !defined(ANDROID) && !defined(__APPLE__) &&
- // !defined(__native_client__)
- mDialog(nullptr),
- mCustomCursorEnabled(config.getBoolValue("customcursor")),
- mEnableResize(config.getBoolValue("enableresize")),
- mNoFrame(config.getBoolValue("noframe")),
-#ifdef USE_SDL2
- mAllowHighDPI(config.getBoolValue("allowHighDPI")),
- // TRANSLATORS: video settings checkbox
- mAllowHighDPICheckBox(new CheckBox(this, _("High DPI"), mAllowHighDPI)),
-#endif // USE_SDL2
- mCustomCursorCheckBox(new CheckBox(this,
-#ifdef ANDROID
- // TRANSLATORS: video settings checkbox
- _("Show cursor"),
-#else // ANDROID
- // TRANSLATORS: video settings checkbox
- _("Custom cursor"),
-#endif // ANDROID
- mCustomCursorEnabled)),
- // TRANSLATORS: video settings checkbox
- mEnableResizeCheckBox(new CheckBox(this, _("Enable resize"),
- mEnableResize)),
- // TRANSLATORS: video settings checkbox
- mNoFrameCheckBox(new CheckBox(this, _("No frame"), mNoFrame))
-{
- // TRANSLATORS: video settings tab name
- setName(_("Video"));
-
- ScrollArea *const scrollArea = new ScrollArea(this, mModeList,
- Opaque_true, "setup_video_background.xml");
- scrollArea->setWidth(150);
- scrollArea->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
-
- mOpenGLDropDown->setSelected(renderToIndex[mOpenGLEnabled]);
-
- mModeList->setEnabled(true);
-
- // TRANSLATORS: video settings label
- mFpsLabel->setCaption(mFps > 0 ? toString(mFps) : _("None"));
- mFpsLabel->setWidth(60);
- // TRANSLATORS: video settings label
- mAltFpsLabel->setCaption(_("Alt FPS limit: ") + (mAltFps > 0 ?
- // TRANSLATORS: video settings label value
- toString(mAltFps) : _("None")));
- mAltFpsLabel->setWidth(150);
- mFpsSlider->setEnabled(mFps > 0);
- mFpsSlider->setValue(mFps);
- mAltFpsSlider->setEnabled(mAltFps > 0);
- mAltFpsSlider->setValue(mAltFps);
- mFpsCheckBox->setSelected(mFps > 0);
-
- // Pre-select the current video mode.
- const std::string videoMode = toString(
- mainGraphics->mActualWidth).append("x").append(
- toString(mainGraphics->mActualHeight));
- mModeList->setSelected(mModeListModel->getIndexOf(videoMode));
-
- mModeList->setActionEventId("videomode");
- mCustomCursorCheckBox->setActionEventId("customcursor");
- mFpsCheckBox->setActionEventId("fpslimitcheckbox");
- mFpsSlider->setActionEventId("fpslimitslider");
- mAltFpsSlider->setActionEventId("altfpslimitslider");
- mOpenGLDropDown->setActionEventId("opengl");
- mEnableResizeCheckBox->setActionEventId("enableresize");
- mNoFrameCheckBox->setActionEventId("noframe");
-#ifdef USE_SDL2
- mAllowHighDPICheckBox->setActionEventId("allowHighDPI");
- mAllowHighDPICheckBox->addActionListener(this);
-#endif // USE_SDL2
-
- mModeList->addActionListener(this);
- mCustomCursorCheckBox->addActionListener(this);
- mFpsCheckBox->addActionListener(this);
- mFpsSlider->addActionListener(this);
- mAltFpsSlider->addActionListener(this);
- mOpenGLDropDown->addActionListener(this);
- mEnableResizeCheckBox->addActionListener(this);
- mNoFrameCheckBox->addActionListener(this);
-
- // Do the layout
- LayoutHelper h(this);
- ContainerPlacer place = h.getPlacer(0, 0);
-
- place(0, 0, scrollArea, 1, 5).setPadding(2);
- place(0, 5, mOpenGLDropDown, 1);
-
- place(1, 0, mFsCheckBox, 2);
-
- place(1, 1, mCustomCursorCheckBox, 3);
-
- place(1, 2, mEnableResizeCheckBox, 2);
- place(1, 3, mNoFrameCheckBox, 2);
-#ifdef USE_SDL2
- place(1, 4, mAllowHighDPICheckBox, 2);
-#endif // USE_SDL2
-
- place(0, 6, mFpsSlider);
- place(1, 6, mFpsCheckBox).setPadding(3);
- place(2, 6, mFpsLabel).setPadding(1);
-
- place(0, 7, mAltFpsSlider);
- place(1, 7, mAltFpsLabel).setPadding(3);
-
-#if !defined(ANDROID) && !defined(__APPLE__) && !defined(__native_client__)
- place(0, 8, mDetectButton);
-#else // !defined(ANDROID) && !defined(__APPLE__) &&
- // !defined(__native_client__)
- mNoFrameCheckBox->setEnabled(false);
- mEnableResizeCheckBox->setEnabled(false);
-#ifndef __native_client__
- mFsCheckBox->setEnabled(false);
-#endif // __native_client__
-#endif // !defined(ANDROID) && !defined(__APPLE__) &&
- // !defined(__native_client__)
-
- int width = 600;
-
- if (config.getIntValue("screenwidth") >= 730)
- width += 100;
-
- setDimension(Rect(0, 0, width, 300));
-}
-
-Setup_Video::~Setup_Video()
-{
- delete2(mModeListModel);
- delete2(mModeList);
- delete2(mOpenGLListModel);
- delete2(mDialog);
-}
-
-void Setup_Video::apply()
-{
- // Full screen changes
- bool fullscreen = mFsCheckBox->isSelected();
- if (fullscreen != config.getBoolValue("screen"))
- {
- /* The OpenGL test is only necessary on Windows, since switching
- * to/from full screen works fine on Linux. On Windows we'd have to
- * reinitialize the OpenGL state and reload all textures.
- *
- * See http://libsdl.org/cgi/docwiki.cgi/SDL_SetVideoMode
- */
-
-#if defined(WIN32) || defined(__APPLE__) || defined(ANDROID)
- // checks for opengl usage
- if (intToRenderType(config.getIntValue("opengl")) == RENDER_SOFTWARE)
- {
-#endif // defined(WIN32) || defined(__APPLE__) || defined(ANDROID)
- if (!WindowManager::setFullScreen(fullscreen))
- {
- fullscreen = !fullscreen;
- if (!WindowManager::setFullScreen(fullscreen))
- {
- std::stringstream errorMsg;
- if (fullscreen)
- {
- // TRANSLATORS: video error message
- errorMsg << _("Failed to switch to windowed mode "
- "and restoration of old mode also "
- "failed!") << std::endl;
- }
- else
- {
- // TRANSLATORS: video error message
- errorMsg << _("Failed to switch to fullscreen mode"
- " and restoration of old mode also "
- "failed!") << std::endl;
- }
- logger->safeError(errorMsg.str());
- }
- }
-#if defined(WIN32) || defined(__APPLE__) || defined(ANDROID)
- }
- else
- {
- CREATEWIDGET(OkDialog,
- // TRANSLATORS: video settings warning
- _("Switching to Full Screen"),
- // TRANSLATORS: video settings warning
- _("Restart needed for changes to take effect."),
- // TRANSLATORS: ok dialog button
- _("OK"),
- DialogType::OK,
- Modal_true,
- ShowCenter_true,
- nullptr,
- 260);
- }
-#endif // defined(WIN32) || defined(__APPLE__) || defined(ANDROID)
-
- config.setValue("screen", fullscreen);
- }
-
- const int sel = mOpenGLDropDown->getSelected();
- RenderType mode = RENDER_SOFTWARE;
- if (sel >= 0 && CAST_U32(sel) < sizeof(indexToRender))
- mode = indexToRender[mOpenGLDropDown->getSelected()];
-
- // OpenGL change
- if (mode != mOpenGLEnabled)
- {
- config.setValue("opengl", CAST_S32(mode));
-
- // OpenGL can currently only be changed by restarting, notify user.
- CREATEWIDGET(OkDialog,
- // TRANSLATORS: video settings warning
- _("Changing to OpenGL"),
- // TRANSLATORS: video settings warning
- _("Applying change to OpenGL requires restart."),
- // TRANSLATORS: ok dialog button
- _("OK"),
- DialogType::OK,
- Modal_true,
- ShowCenter_true,
- nullptr,
- 260);
- }
-
- mFps = mFpsCheckBox->isSelected() ?
- CAST_S32(mFpsSlider->getValue()) : 0;
-
- mAltFps = CAST_S32(mAltFpsSlider->getValue());
-
- mFpsSlider->setEnabled(mFps > 0);
-
- mAltFpsSlider->setEnabled(mAltFps > 0);
-
- // FPS change
- config.setValue("fpslimit", mFps);
- config.setValue("altfpslimit", mAltFps);
-
- // We sync old and new values at apply time
- mFullScreenEnabled = config.getBoolValue("screen");
- mCustomCursorEnabled = config.getBoolValue("customcursor");
-
- mOpenGLEnabled = intToRenderType(config.getIntValue("opengl"));
- mEnableResize = config.getBoolValue("enableresize");
- mNoFrame = config.getBoolValue("noframe");
-#ifdef USE_SDL2
- mAllowHighDPI = config.getBoolValue("allowHighDPI");
-#endif // USE_SDL2
-}
-
-void Setup_Video::cancel()
-{
- mFpsCheckBox->setSelected(mFps > 0);
- mFsCheckBox->setSelected(mFullScreenEnabled);
- mOpenGLDropDown->setSelected(renderToIndex[mOpenGLEnabled]);
- mCustomCursorCheckBox->setSelected(mCustomCursorEnabled);
- mFpsSlider->setEnabled(mFps > 0);
- mFpsSlider->setValue(mFps);
- mAltFpsSlider->setEnabled(mAltFps > 0);
- mAltFpsSlider->setValue(mAltFps);
- mFpsLabel->setCaption(mFpsCheckBox->isSelected()
- // TRANSLATORS: video settings label
- ? toString(mFps) : _("None"));
- // TRANSLATORS: video settings label
- mAltFpsLabel->setCaption(_("Alt FPS limit: ") + toString(mAltFps));
- mEnableResizeCheckBox->setSelected(mEnableResize);
- mNoFrameCheckBox->setSelected(mNoFrame);
-#ifdef USE_SDL2
- mAllowHighDPICheckBox->setSelected(mAllowHighDPI);
-#endif // USE_SDL2
-
- config.setValue("screen", mFullScreenEnabled);
-
- // Set back to the current video mode.
- std::string videoMode = toString(mainGraphics->mActualWidth).append("x")
- .append(toString(mainGraphics->mActualHeight));
- mModeList->setSelected(mModeListModel->getIndexOf(videoMode));
- config.setValue("screenwidth", mainGraphics->mActualWidth);
- config.setValue("screenheight", mainGraphics->mActualHeight);
-
- config.setValue("customcursor", mCustomCursorEnabled);
- config.setValue("opengl", CAST_S32(mOpenGLEnabled));
- config.setValue("enableresize", mEnableResize);
-#ifdef USE_SDL2
- config.setValue("allowHighDPI", mAllowHighDPI);
-#endif // USE_SDL2
-}
-
-void Setup_Video::action(const ActionEvent &event)
-{
- const std::string &id = event.getId();
-
- if (id == "videomode")
- {
- std::string mode = mModeListModel->getElementAt(
- mModeList->getSelected());
-
- if (mode == "custom")
- {
- if (mDialog != nullptr)
- {
- mode = mDialog->getText();
- mDialog = nullptr;
- }
- else
- {
- CREATEWIDGETV(mDialog, TextDialog,
- // TRANSLATORS: resolution question dialog
- _("Custom resolution (example: 1024x768)"),
- // TRANSLATORS: resolution question dialog
- _("Enter new resolution: "));
- mDialog->setActionEventId("videomode");
- mDialog->addActionListener(this);
- return;
- }
- }
- const int width = atoi(mode.substr(0, mode.find('x')).c_str());
- const int height = atoi(mode.substr(mode.find('x') + 1).c_str());
- if ((width == 0) || (height == 0))
- return;
-
- if (width != mainGraphics->mActualWidth
- || height != mainGraphics->mActualHeight)
- {
-#if defined(WIN32) || defined(__APPLE__) || defined(ANDROID)
- if (intToRenderType(config.getIntValue("opengl"))
- == RENDER_SOFTWARE)
- {
- WindowManager::doResizeVideo(width, height, false);
- }
- else
- {
- if (width < mainGraphics->mActualWidth
- || height < mainGraphics->mActualHeight)
- {
- CREATEWIDGET(OkDialog,
- // TRANSLATORS: video settings warning
- _("Screen Resolution Changed"),
- // TRANSLATORS: video settings warning
- _("Restart your client for the change to take effect.")
- // TRANSLATORS: video settings warning
- + std::string("\n") + _("Some windows may be moved to "
- "fit the lowered resolution."),
- // TRANSLATORS: ok dialog button
- _("OK"),
- DialogType::OK,
- Modal_true,
- ShowCenter_true,
- nullptr,
- 260);
- }
- else
- {
- CREATEWIDGET(OkDialog,
- // TRANSLATORS: video settings warning
- _("Screen Resolution Changed"),
- // TRANSLATORS: video settings warning
- _("Restart your client for the change"
- " to take effect."),
- // TRANSLATORS: ok dialog button
- _("OK"),
- DialogType::OK,
- Modal_true,
- ShowCenter_true,
- nullptr,
- 260);
- }
- }
-#else // defined(WIN32) || defined(__APPLE__) || defined(ANDROID)
-
- mainGraphics->setWindowSize(width, height);
- WindowManager::doResizeVideo(width, height, false);
-#endif // defined(WIN32) || defined(__APPLE__) || defined(ANDROID)
- }
-
- config.setValue("oldscreen", config.getBoolValue("screen"));
- config.setValue("oldscreenwidth", mainGraphics->mActualWidth);
- config.setValue("oldscreenheight", mainGraphics->mActualHeight);
- config.setValue("screenwidth", width);
- config.setValue("screenheight", height);
- }
- if (id == "~videomode")
- {
- mDialog = nullptr;
- }
- else if (id == "customcursor")
- {
- config.setValue("customcursor", mCustomCursorCheckBox->isSelected());
- }
- else if (id == "fpslimitcheckbox" || id == "fpslimitslider")
- {
- int tempFps = CAST_S32(mFpsSlider->getValue());
- if (id == "fpslimitcheckbox" && !mFpsSlider->isEnabled())
- tempFps = 60;
- else
- tempFps = tempFps > 0 ? tempFps : 60;
- mFps = mFpsCheckBox->isSelected() ? tempFps : 0;
- // TRANSLATORS: video settings label
- const std::string text = mFps > 0 ? toString(mFps) : _("None");
-
- mFpsLabel->setCaption(text);
- mFpsSlider->setEnabled(mFps > 0);
- mFpsSlider->setValue(mFps);
- }
- else if (id == "altfpslimitslider")
- {
- int tempFps = CAST_S32(mAltFpsSlider->getValue());
- tempFps = tempFps > 0 ? tempFps : CAST_S32(
- mAltFpsSlider->getScaleStart());
- mAltFps = tempFps;
- // TRANSLATORS: video settings label
- const std::string text = mAltFps > 0 ? toString(mAltFps) : _("None");
-
- // TRANSLATORS: video settings label
- mAltFpsLabel->setCaption(_("Alt FPS limit: ") + text);
- mAltFpsSlider->setEnabled(mAltFps > 0);
- mAltFpsSlider->setValue(mAltFps);
- }
- else if (id == "enableresize")
- {
- config.setValue("enableresize", mEnableResizeCheckBox->isSelected());
- }
- else if (id == "noframe")
- {
- config.setValue("noframe", mNoFrameCheckBox->isSelected());
- }
-#ifdef USE_SDL2
- else if (id == "allowHighDPI")
- {
- config.setValue("allowHighDPI", mAllowHighDPICheckBox->isSelected());
- }
-#endif // USE_SDL2
-#if defined(USE_OPENGL) && !defined(ANDROID) && !defined(__APPLE__)
- else if (id == "detect")
- {
- TestMain *test = graphicsManager.startDetection();
- if (test != nullptr)
- {
- Configuration &conf = test->getConfig();
- const int val = conf.getValueInt("opengl", -1);
- if (val >= 0 && CAST_U32(val)
- < sizeof(renderToIndex) / sizeof(int))
- {
- mOpenGLDropDown->setSelected(renderToIndex[val]);
- }
- config.setValue("textureSize",
- conf.getValue("textureSize", "1024,1024,1024,1024,1024,1024"));
- config.setValue("testInfo", conf.getValue("testInfo", ""));
- delete test;
- }
- }
-#endif // defined(USE_OPENGL) && !defined(ANDROID) && !defined(__APPLE__)
-}
diff --git a/src/gui/widgets/tabs/setup_video.h b/src/gui/widgets/tabs/setup_video.h
deleted file mode 100644
index e327a29d8..000000000
--- a/src/gui/widgets/tabs/setup_video.h
+++ /dev/null
@@ -1,88 +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_TABS_SETUP_VIDEO_H
-#define GUI_WIDGETS_TABS_SETUP_VIDEO_H
-
-#include "gui/widgets/tabs/setuptab.h"
-
-#include "listeners/keylistener.h"
-
-class Button;
-class CheckBox;
-class DropDown;
-class Label;
-class ListBox;
-class ModeListModel;
-class OpenGLListModel;
-class Slider;
-class TextDialog;
-
-class Setup_Video final : public SetupTab,
- public KeyListener
-{
- public:
- explicit Setup_Video(const Widget2 *const widget);
-
- A_DELETE_COPY(Setup_Video)
-
- ~Setup_Video();
-
- void apply() override final;
-
- void cancel() override final;
-
- void action(const ActionEvent &event) override final;
-
- private:
- bool mFullScreenEnabled;
- RenderType mOpenGLEnabled;
- int mFps;
- int mAltFps;
- ModeListModel *mModeListModel;
- OpenGLListModel *mOpenGLListModel;
- ListBox *mModeList;
- CheckBox *mFsCheckBox;
- DropDown *mOpenGLDropDown;
- CheckBox *mFpsCheckBox;
- Slider *mFpsSlider;
- Label *mFpsLabel;
- Slider *mAltFpsSlider;
- Label *mAltFpsLabel;
-#if !defined(ANDROID) && !defined(__APPLE__) && !defined(__native_client__)
- Button *mDetectButton;
-#endif // !defined(ANDROID) && !defined(__APPLE__) &&
- // !defined(__native_client__)
- TextDialog *mDialog;
- bool mCustomCursorEnabled;
- bool mEnableResize;
- bool mNoFrame;
-#ifdef USE_SDL2
- bool mAllowHighDPI;
- CheckBox *mAllowHighDPICheckBox;
-#endif // USE_SDL2
- CheckBox *mCustomCursorCheckBox;
- CheckBox *mEnableResizeCheckBox;
- CheckBox *mNoFrameCheckBox;
-};
-
-#endif // GUI_WIDGETS_TABS_SETUP_VIDEO_H
diff --git a/src/gui/widgets/tabs/setup_visual.cpp b/src/gui/widgets/tabs/setup_visual.cpp
deleted file mode 100644
index de5cc8b3b..000000000
--- a/src/gui/widgets/tabs/setup_visual.cpp
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009-2010 Andrei Karas
- * 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 "gui/widgets/tabs/setup_visual.h"
-
-#include "gui/windowmanager.h"
-
-#include "gui/models/namesmodel.h"
-
-#include "gui/widgets/containerplacer.h"
-#include "gui/widgets/layouthelper.h"
-#include "gui/widgets/scrollarea.h"
-
-#include "utils/delete2.h"
-#include "utils/gettext.h"
-#include "utils/stringutils.h"
-
-#include "debug.h"
-
-static const int speachListSize = 4;
-
-static const char *const speachList[] =
-{
- // TRANSLATORS: speach type
- N_("No text"),
- // TRANSLATORS: speach type
- N_("Text"),
- // TRANSLATORS: speach type
- N_("Bubbles, no names"),
- // TRANSLATORS: speach type
- N_("Bubbles with names")
-};
-
-static const int ambientFxListSize = 3;
-
-static const char *const ambientFxList[] =
-{
- // TRANSLATORS: ambient effect type
- N_("off"),
- // TRANSLATORS: ambient effect type
- N_("low"),
- // TRANSLATORS: ambient effect type
- N_("high")
-};
-
-static const int particleTypeListSize = 3;
-
-static const char *const particleTypeList[] =
-{
- // TRANSLATORS: patricle effects type
- N_("best quality"),
- // TRANSLATORS: patricle effects type
- N_("normal"),
- // TRANSLATORS: patricle effects type
- N_("best performance")
-};
-
-static const int vSyncListSize = 3;
-
-static const char *const vSyncList[] =
-{
- // TRANSLATORS: vsync type
- N_("default"),
- // TRANSLATORS: vsync type
- N_("off"),
- // TRANSLATORS: vsync type
- N_("on")
-};
-
-Setup_Visual::Setup_Visual(const Widget2 *const widget) :
- SetupTabScroll(widget),
- mSpeachList(new NamesModel),
- mAmbientFxList(new NamesModel),
- mParticleList(new SetupItemNames),
- mParticleTypeList(new NamesModel),
- mVSyncList(new NamesModel),
- mScaleList(new NamesModel)
-{
- // TRANSLATORS: settings tab name
- setName(_("Visual"));
- // Do the layout
- LayoutHelper h(this);
- ContainerPlacer place = h.getPlacer(0, 0);
- place(0, 0, mScroll, 10, 10);
-
- mPreferredFirstItemSize = 150;
-
- // TRANSLATORS: settings option
- new SetupItemLabel(_("Scale"), "", this);
-
- for (int f = 1; f <= 7; f ++)
- {
- // TRANSLATORS: particle details
- mScaleList->add(toString(f) + "x");
- }
- // TRANSLATORS: settings option
- new SetupItemSliderInt(_("Scale"), "",
- "scale", this, "scaleEvent", mScaleList, 1);
-
- // TRANSLATORS: settings option
- new SetupItemLabel(_("Notifications"), "", this);
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Show pickup notifications in chat"), "",
- "showpickupchat", this, "showpickupchatEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Show pickup notifications as particle effects"),
- "", "showpickupparticle", this, "showpickupparticleEvent");
-
- // TRANSLATORS: settings option
- new SetupItemLabel(_("Effects"), "", this);
-
-#ifndef ANDROID
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Grab mouse and keyboard input"),
- "", "grabinput", this, "grabinputEvent");
-#endif // ANDROID
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Blurring textures (OpenGL)"),
- "", "blur", this, "blurEvent");
-
- // TRANSLATORS: settings option
- new SetupItemSlider(_("Gui opacity"), "", "guialpha",
- this, "guialphaEvent", 0.1, 1.01, 0.1, 150,
- OnTheFly_true,
- MainConfig_true);
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Enable gui opacity"),
- "", "enableGuiOpacity", this, "enableGuiOpacityEvent");
-
- mSpeachList->fillFromArray(&speachList[0], speachListSize);
- // TRANSLATORS: settings option
- new SetupItemDropDown(_("Overhead text"), "", "speech", this,
- "speechEvent", mSpeachList, 200);
-
- mAmbientFxList->fillFromArray(&ambientFxList[0], ambientFxListSize);
- // TRANSLATORS: settings option
- new SetupItemDropDown(_("Ambient FX"), "", "OverlayDetail", this,
- "OverlayDetailEvent", mAmbientFxList, 100);
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Show particle effects"), "",
- "particleeffects", this, "particleeffectsEvent");
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Show particle effects from maps"), "",
- "mapparticleeffects", this, "mapparticleeffectsEvent");
-
- // TRANSLATORS: particle details
- mParticleList->push_back(_("low"));
- // TRANSLATORS: particle details
- mParticleList->push_back(_("medium"));
- // TRANSLATORS: particle details
- mParticleList->push_back(_("high"));
- // TRANSLATORS: particle details
- mParticleList->push_back(_("max"));
- // TRANSLATORS: settings option
- (new SetupItemSlider2(_("Particle detail"), "", "particleEmitterSkip",
- this, "particleEmitterSkipEvent", 0, 3, 1, mParticleList,
- OnTheFly_true,
- MainConfig_true,
- DoNotAlign_false))->setInvertValue(3);
-
- mParticleTypeList->fillFromArray(&particleTypeList[0],
- particleTypeListSize);
- // TRANSLATORS: settings option
- new SetupItemDropDown(_("Particle physics"), "", "particleFastPhysics",
- this, "particleFastPhysicsEvent", mParticleTypeList, 200);
-
-
- // TRANSLATORS: settings group
- new SetupItemLabel(_("Gamma"), "", this);
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Enable gamma control"),
- "", "enableGamma", this, "enableGammaEvent");
-
- // TRANSLATORS: settings option
- new SetupItemSlider(_("Gamma"), "", "gamma",
- this, "gammeEvent", 1, 20, 1, 350,
- OnTheFly_true,
- MainConfig_true);
-
-
- // TRANSLATORS: settings group
- new SetupItemLabel(_("Other"), "", this);
-
- mVSyncList->fillFromArray(&vSyncList[0], vSyncListSize);
- // TRANSLATORS: settings option
- new SetupItemDropDown(_("Vsync"), "", "vsync", this,
- "vsyncEvent", mVSyncList, 100);
-
-#if defined(WIN32) || defined(__APPLE__)
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Center game window"),
- "", "centerwindow", this, "centerwindowEvent");
-#endif // defined(WIN32) || defined(__APPLE__)
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Allow screensaver to run"),
- "", "allowscreensaver", this, "allowscreensaverEvent");
-
-
- // TRANSLATORS: settings group
- new SetupItemLabel(_("Screenshots"), "", this);
-
- // TRANSLATORS: settings option
- new SetupItemCheckBox(_("Add water mark into screenshots"),
- "", "addwatermark", this, "addwatermarkEvent");
-
- setDimension(Rect(0, 0, 550, 350));
-}
-
-Setup_Visual::~Setup_Visual()
-{
- delete2(mSpeachList);
- delete2(mAmbientFxList);
- delete2(mParticleList);
- delete2(mParticleTypeList);
- delete2(mVSyncList);
- delete2(mScaleList);
-}
-
-void Setup_Visual::apply()
-{
- SetupTabScroll::apply();
- WindowManager::applyGrabMode();
-#ifndef WIN32
- WindowManager::applyScale();
-#endif // WIN32
-}
diff --git a/src/gui/widgets/tabs/setup_visual.h b/src/gui/widgets/tabs/setup_visual.h
deleted file mode 100644
index 08d1c7848..000000000
--- a/src/gui/widgets/tabs/setup_visual.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009-2010 Andrei Karas
- * 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_TABS_SETUP_VISUAL_H
-#define GUI_WIDGETS_TABS_SETUP_VISUAL_H
-
-#include "gui/widgets/setupitem.h"
-
-#include "gui/widgets/tabs/setuptabscroll.h"
-
-class NamesModel;
-
-class Setup_Visual final : public SetupTabScroll
-{
- public:
- explicit Setup_Visual(const Widget2 *const widget);
-
- A_DELETE_COPY(Setup_Visual)
-
- ~Setup_Visual();
-
- void apply() override final;
-
- private:
- NamesModel *mSpeachList;
- NamesModel *mAmbientFxList;
- SetupItemNames *mParticleList;
- NamesModel *mParticleTypeList;
- NamesModel *mVSyncList;
- NamesModel *mScaleList;
-};
-
-#endif // GUI_WIDGETS_TABS_SETUP_VISUAL_H
diff --git a/src/gui/widgets/tabs/setuptab.cpp b/src/gui/widgets/tabs/setuptab.cpp
deleted file mode 100644
index d5f43b4b8..000000000
--- a/src/gui/widgets/tabs/setuptab.cpp
+++ /dev/null
@@ -1,44 +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 "gui/widgets/tabs/setuptab.h"
-
-#include "debug.h"
-
-SetupTab::SetupTab(const Widget2 *const widget) :
- Container(widget),
- ActionListener(),
- WidgetListener(),
- mName()
-{
- setOpaque(Opaque_false);
- addWidgetListener(this);
- setSelectable(false);
-}
-
-void SetupTab::externalUpdated()
-{
-}
-
-void SetupTab::externalUnloaded()
-{
-}
diff --git a/src/gui/widgets/tabs/setuptab.h b/src/gui/widgets/tabs/setuptab.h
deleted file mode 100644
index 6b1082088..000000000
--- a/src/gui/widgets/tabs/setuptab.h
+++ /dev/null
@@ -1,74 +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_TABS_SETUPTAB_H
-#define GUI_WIDGETS_TABS_SETUPTAB_H
-
-#include "gui/widgets/container.h"
-
-#include "listeners/actionlistener.h"
-#include "listeners/widgetlistener.h"
-
-#include "localconsts.h"
-
-/**
- * A container for the contents of a tab in the setup window.
- */
-class SetupTab notfinal : public Container,
- public ActionListener,
- public WidgetListener
-{
- public:
- A_DELETE_COPY(SetupTab)
-
- const std::string &getName() const noexcept2 A_WARN_UNUSED
- { return mName; }
-
- /**
- * Called when the Apply button is pressed in the setup window.
- */
- virtual void apply() = 0;
-
- /**
- * Called when the Cancel button is pressed in the setup window.
- */
- virtual void cancel() = 0;
-
- virtual void externalUpdated() A_CONST;
-
- virtual void externalUnloaded() A_CONST;
-
- protected:
- explicit SetupTab(const Widget2 *const widget);
-
- /**
- * Sets the name displayed on the tab. Should be set in the
- * constructor of a subclass.
- */
- void setName(const std::string &name) noexcept2
- { mName = name; }
-
- private:
- std::string mName;
-};
-
-#endif // GUI_WIDGETS_TABS_SETUPTAB_H
diff --git a/src/gui/widgets/tabs/setuptabscroll.cpp b/src/gui/widgets/tabs/setuptabscroll.cpp
deleted file mode 100644
index 0cb623687..000000000
--- a/src/gui/widgets/tabs/setuptabscroll.cpp
+++ /dev/null
@@ -1,163 +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 "gui/widgets/tabs/setuptabscroll.h"
-
-#include "gui/widgets/scrollarea.h"
-#include "gui/widgets/setupitem.h"
-#include "gui/widgets/vertcontainer.h"
-
-#include "utils/delete2.h"
-
-#include "debug.h"
-
-SetupTabScroll::SetupTabScroll(const Widget2 *const widget) :
- SetupTab(widget),
- mContainer(new VertContainer(this, 25, false, 8)),
- mScroll(new ScrollArea(this, mContainer, Opaque_false)),
- mItems(),
- mAllItems(),
- mPreferredFirstItemSize(200)
-{
- mScroll->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
- mScroll->setVerticalScrollPolicy(ScrollArea::SHOW_AUTO);
- mScroll->setSelectable(false);
- mContainer->setSelectable(false);
-}
-
-SetupTabScroll::~SetupTabScroll()
-{
- mScroll = nullptr;
- delete2(mContainer);
- removeItems();
-}
-
-void SetupTabScroll::removeItems()
-{
- std::set<SetupItem*>::iterator it = mAllItems.begin();
- const std::set<SetupItem*>::iterator it_end = mAllItems.end();
- while (it != it_end)
- {
- delete *it;
- ++ it;
- }
- mAllItems.clear();
-
- mItems.clear();
-}
-
-void SetupTabScroll::clear()
-{
- removeItems();
- mContainer->removeControls();
- mContainer->clear();
-}
-
-void SetupTabScroll::addControl(SetupItem *const widget)
-{
- if (widget == nullptr)
- return;
- const std::string actionId = widget->getActionEventId();
- if (!actionId.empty())
- {
- const std::map<std::string, SetupItem*>::iterator iter
- = mItems.find(actionId);
- if (iter != mItems.end())
- {
- delete (*iter).second;
- mItems.erase(iter);
- }
- mItems[actionId] = widget;
- }
- mAllItems.insert(widget);
-}
-
-void SetupTabScroll::addControl(SetupItem *const widget,
- const std::string &event)
-{
- const std::map<std::string, SetupItem*>::iterator iter
- = mItems.find(event);
- if (iter != mItems.end())
- {
- delete (*iter).second;
- mItems.erase(iter);
- }
- mItems[event] = widget;
- mAllItems.insert(widget);
-}
-
-void SetupTabScroll::apply()
-{
- for (std::map<std::string, SetupItem*>::const_iterator
- iter = mItems.begin(), iter_end = mItems.end();
- iter != iter_end; ++ iter)
- {
- if ((*iter).second != nullptr)
- (*iter).second->apply((*iter).first);
- }
-}
-
-void SetupTabScroll::cancel()
-{
- for (std::map<std::string, SetupItem*>::const_iterator
- iter = mItems.begin(), iter_end = mItems.end();
- iter != iter_end; ++ iter)
- {
- if ((*iter).second != nullptr)
- (*iter).second->cancel((*iter).first);
- }
-}
-
-void SetupTabScroll::externalUpdated()
-{
- for (std::map<std::string, SetupItem*>::const_iterator
- iter = mItems.begin(), iter_end = mItems.end();
- iter != iter_end; ++ iter)
- {
- SetupItem *const widget = (*iter).second;
- if ((widget != nullptr) && widget->isMainConfig() == MainConfig_false)
- widget->externalUpdated((*iter).first);
- }
-}
-
-void SetupTabScroll::externalUnloaded()
-{
- for (std::map<std::string, SetupItem*>::const_iterator
- iter = mItems.begin(), iter_end = mItems.end();
- iter != iter_end; ++ iter)
- {
- SetupItem *const widget = (*iter).second;
- if ((widget != nullptr) && widget->isMainConfig() == MainConfig_false)
- widget->externalUnloaded((*iter).first);
- }
-}
-
-void SetupTabScroll::widgetResized(const Event &event A_UNUSED)
-{
- mScroll->setWidth(getWidth() - 12);
- mScroll->setHeight(getHeight() - 12 - 12);
-}
-
-void SetupTabScroll::reread(const std::string &name)
-{
- SetupItem *const item = mItems[name + "Event"];
- if (item != nullptr)
- item->rereadValue();
-}
diff --git a/src/gui/widgets/tabs/setuptabscroll.h b/src/gui/widgets/tabs/setuptabscroll.h
deleted file mode 100644
index 655b98c85..000000000
--- a/src/gui/widgets/tabs/setuptabscroll.h
+++ /dev/null
@@ -1,81 +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 GUI_WIDGETS_TABS_SETUPTABSCROLL_H
-#define GUI_WIDGETS_TABS_SETUPTABSCROLL_H
-
-#include "gui/widgets/tabs/setuptab.h"
-
-#include "localconsts.h"
-
-class SetupItem;
-class ScrollArea;
-class VertContainer;
-
-class SetupTabScroll notfinal : public SetupTab
-{
- public:
- explicit SetupTabScroll(const Widget2 *const widget);
-
- A_DELETE_COPY(SetupTabScroll)
-
- virtual ~SetupTabScroll();
-
- void addControl(SetupItem *const widget);
-
- void addControl(SetupItem *const widget, const std::string &event);
-
- VertContainer *getContainer() const noexcept2 A_WARN_UNUSED
- { return mContainer; }
-
- void apply() override;
-
- void cancel() override final;
-
- void externalUpdated() override;
-
- void externalUnloaded() override;
-
- void action(const ActionEvent &event A_UNUSED) override final
- { }
-
- int getPreferredFirstItemSize() const noexcept2 A_WARN_UNUSED
- { return mPreferredFirstItemSize; }
-
- void widgetResized(const Event &event) override final;
-
- void reread(const std::string &name);
-
- void clear() override final;
-
- const std::set<SetupItem*> &getAllItems() const noexcept2
- { return mAllItems; }
-
- protected:
- void removeItems();
-
- VertContainer *mContainer;
- ScrollArea *mScroll;
- std::map<std::string, SetupItem*> mItems;
- std::set<SetupItem*> mAllItems;
- int mPreferredFirstItemSize;
-};
-
-#endif // GUI_WIDGETS_TABS_SETUPTABSCROLL_H
diff --git a/src/gui/widgets/tabs/shortcuttab.h b/src/gui/widgets/tabs/shortcuttab.h
deleted file mode 100644
index 61652777f..000000000
--- a/src/gui/widgets/tabs/shortcuttab.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 GUI_WIDGETS_TABS_SHORTCUTTAB_H
-#define GUI_WIDGETS_TABS_SHORTCUTTAB_H
-
-#include "gui/widgets/tabs/tab.h"
-
-#include "localconsts.h"
-
-class ShortcutContainer;
-
-class ShortcutTab final : public Tab
-{
- public:
- ShortcutTab(const Widget2 *const widget,
- const std::string &name,
- ShortcutContainer *const content) :
- Tab(widget),
- mContent(content)
- {
- setCaption(name);
- }
-
- A_DELETE_COPY(ShortcutTab)
-
- ShortcutContainer* mContent;
-};
-
-#endif // GUI_WIDGETS_TABS_SHORTCUTTAB_H
diff --git a/src/gui/widgets/tabs/skilltab.h b/src/gui/widgets/tabs/skilltab.h
deleted file mode 100644
index 9086a4d0c..000000000
--- a/src/gui/widgets/tabs/skilltab.h
+++ /dev/null
@@ -1,88 +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_TABS_SKILLTAB_H
-#define GUI_WIDGETS_TABS_SKILLTAB_H
-
-#include "gui/windows/skilldialog.h"
-
-#include "gui/widgets/skilllistbox.h"
-#include "gui/widgets/skillrectanglelistbox.h"
-
-#include "gui/widgets/tabs/tab.h"
-
-#include "localconsts.h"
-
-class SkillTab final : public Tab
-{
- public:
- SkillTab(const Widget2 *const widget,
- const std::string &name,
- SkillListBox *const listBox) :
- Tab(widget),
- mListBox(listBox),
- mRectangleListBox(nullptr)
- {
- setCaption(name);
- }
-
- SkillTab(const Widget2 *const widget,
- const std::string &name,
- SkillRectangleListBox *const listBox) :
- Tab(widget),
- mListBox(nullptr),
- mRectangleListBox(listBox)
- {
- setCaption(name);
- }
-
- A_DELETE_COPY(SkillTab)
-
- ~SkillTab()
- {
- delete2(mListBox)
- delete2(mRectangleListBox)
- }
-
- SkillInfo *getSelectedInfo() const
- {
- if (mListBox != nullptr)
- return mListBox->getSelectedInfo();
- else if (mRectangleListBox != nullptr)
- return mRectangleListBox->getSelectedInfo();
- else
- return nullptr;
- }
-
- protected:
- void setCurrent() override
- {
- if (skillDialog != nullptr)
- skillDialog->updateTabSelection();
- }
-
- private:
- SkillListBox *mListBox;
- SkillRectangleListBox *mRectangleListBox;
-};
-
-#endif // GUI_WIDGETS_TABS_SKILLTAB_H
diff --git a/src/gui/widgets/tabs/socialattacktab.h b/src/gui/widgets/tabs/socialattacktab.h
deleted file mode 100644
index e876a60ae..000000000
--- a/src/gui/widgets/tabs/socialattacktab.h
+++ /dev/null
@@ -1,77 +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 GUI_WIDGETS_TABS_SOCIALATTACKTAB_H
-#define GUI_WIDGETS_TABS_SOCIALATTACKTAB_H
-
-#include "gui/widgets/tabs/socialtab.h"
-
-#include "being/localplayer.h"
-
-#include "gui/models/beingslistmodel.h"
-
-#include "gui/widgets/tabs/socialtabbase.h"
-
-#include "utils/delete2.h"
-#include "utils/gettext.h"
-
-#include "localconsts.h"
-
-class SocialAttackTab final : public SocialTab
-{
- public:
- SocialAttackTab(const Widget2 *const widget,
- const Opaque showBackground) :
- SocialTab(widget),
- mBeings(new BeingsListModel)
- {
- createControls(mBeings, showBackground);
-
- // TRANSLATORS: Attack filter tab name in social window.
- // TRANSLATORS: Should be small
- setCaption(_("Atk"));
- mMenuAction = "attack";
- }
-
- A_DELETE_COPY(SocialAttackTab)
-
- ~SocialAttackTab()
- {
- delete2(mList)
- delete2(mScroll)
- delete2(mBeings)
- }
-
- void updateList() override final
- {
- updateAtkListStart();
- // TRANSLATORS: mobs group name in social window
- addAvatars(PriorityAttackMob, _("Priority mobs"), PRIORITY);
- // TRANSLATORS: mobs group name in social window
- addAvatars(AttackMob, _("Attack mobs"), ATTACK);
- // TRANSLATORS: mobs group name in social window
- addAvatars(IgnoreAttackMob, _("Ignore mobs"), IGNORE_);
- }
-
- private:
- BeingsListModel *mBeings;
-};
-
-#endif // GUI_WIDGETS_TABS_SOCIALATTACKTAB_H
diff --git a/src/gui/widgets/tabs/socialfriendsfunctor.h b/src/gui/widgets/tabs/socialfriendsfunctor.h
deleted file mode 100644
index e68647a77..000000000
--- a/src/gui/widgets/tabs/socialfriendsfunctor.h
+++ /dev/null
@@ -1,59 +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 GUI_WIDGETS_TABS_SOCIALFRIENDSFUNCTOR_H
-#define GUI_WIDGETS_TABS_SOCIALFRIENDSFUNCTOR_H
-
-#include "avatar.h"
-
-#include "utils/stringutils.h"
-
-#include "localconsts.h"
-
-class SortFriendsFunctor final
-{
- public:
- A_DEFAULT_COPY(SortFriendsFunctor)
-
- bool operator() (const Avatar *const m1,
- const Avatar *const m2) const
- {
- if ((m1 == nullptr) || (m2 == nullptr))
- return false;
-
- if (m1->getOnline() != m2->getOnline())
- {
- return static_cast<int>(m1->getOnline()) >
- static_cast<int>(m2->getOnline());
- }
-
- if (m1->getName() != m2->getName())
- {
- std::string s1 = m1->getName();
- std::string s2 = m2->getName();
- toLower(s1);
- toLower(s2);
- return s1 < s2;
- }
- return false;
- }
-};
-
-#endif // GUI_WIDGETS_TABS_SOCIALFRIENDSFUNCTOR_H
diff --git a/src/gui/widgets/tabs/socialfriendstab.h b/src/gui/widgets/tabs/socialfriendstab.h
deleted file mode 100644
index d1cd942cd..000000000
--- a/src/gui/widgets/tabs/socialfriendstab.h
+++ /dev/null
@@ -1,127 +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 GUI_WIDGETS_TABS_SOCIALFRIENDSTAB_H
-#define GUI_WIDGETS_TABS_SOCIALFRIENDSTAB_H
-
-#include "gui/widgets/tabs/socialtab.h"
-
-#include "actormanager.h"
-
-#include "being/playerrelations.h"
-
-#include "gui/models/beingslistmodel.h"
-
-#include "gui/windows/whoisonline.h"
-
-#include "gui/widgets/tabs/socialfriendsfunctor.h"
-
-#include "utils/delete2.h"
-#include "utils/foreach.h"
-#include "utils/gettext.h"
-
-#include "localconsts.h"
-
-class SocialFriendsTab final : public SocialTab
-{
- public:
- SocialFriendsTab(const Widget2 *const widget,
- const std::string &name,
- const Opaque showBackground) :
- SocialTab(widget),
- mBeings(new BeingsListModel),
- mFriendSorter()
- {
- createControls(mBeings, showBackground);
-
- getPlayersAvatars();
- setCaption(name);
- mMenuAction = "friends";
- }
-
- A_DELETE_COPY(SocialFriendsTab)
-
- ~SocialFriendsTab()
- {
- delete2(mList)
- delete2(mScroll)
- delete2(mBeings)
- }
-
- void updateList() override final
- {
- getPlayersAvatars();
- }
-
- void getPlayersAvatars()
- {
- if (actorManager == nullptr)
- return;
-
- STD_VECTOR<Avatar*> *const avatars = mBeings->getMembers();
-
- STD_VECTOR<Avatar*>::iterator ia = avatars->begin();
- while (ia != avatars->end())
- {
- delete *ia;
- ++ ia;
- }
- avatars->clear();
-
- const StringVect *const players
- = playerRelations.getPlayersByRelation(Relation::FRIEND);
-
- const std::set<std::string> &players2
- = whoIsOnline->getOnlineNicks();
-
- if (players == nullptr)
- return;
-
- int online = 0;
- int total = 0;
-
- FOR_EACHP (StringVectCIter, it, players)
- {
- Avatar *const ava = new Avatar(*it);
- if (actorManager->findBeingByName(*it, ActorType::Player) !=
- nullptr || players2.find(*it) != players2.end())
- {
- ava->setOnline(true);
- online ++;
- }
- total ++;
- avatars->push_back(ava);
- }
- std::sort(avatars->begin(), avatars->end(), mFriendSorter);
- delete players;
-
- // TRANSLATORS: social window label
- mCounterString = strprintf(_("Friends: %u/%u"),
- CAST_U32(online),
- CAST_U32(total));
- updateCounter();
- }
-
- private:
- BeingsListModel *mBeings;
- SortFriendsFunctor mFriendSorter;
-};
-
-#endif // GUI_WIDGETS_TABS_SOCIALFRIENDSTAB_H
diff --git a/src/gui/widgets/tabs/socialguildtab.h b/src/gui/widgets/tabs/socialguildtab.h
deleted file mode 100644
index 8652a54fe..000000000
--- a/src/gui/widgets/tabs/socialguildtab.h
+++ /dev/null
@@ -1,179 +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 GUI_WIDGETS_TABS_SOCIALGUILDTAB_H
-#define GUI_WIDGETS_TABS_SOCIALGUILDTAB_H
-
-#include "gui/widgets/tabs/socialtab.h"
-
-#include "being/localplayer.h"
-
-#include "utils/delete2.h"
-#include "utils/foreach.h"
-#include "utils/gettext.h"
-#include "utils/stringutils.h"
-
-#include "net/guildhandler.h"
-
-#include "localconsts.h"
-
-class SocialGuildTab final : public SocialTab,
- public ActionListener
-{
- public:
- SocialGuildTab(const Widget2 *const widget,
- Guild *const guild,
- const Opaque showBackground) :
- SocialTab(widget),
- ActionListener(),
- mGuild(guild)
- {
- // TRANSLATORS: tab in social window
- setCaption(_("Guild"));
-
- setTabColor(&getThemeColor(ThemeColorId::GUILD_SOCIAL_TAB),
- &getThemeColor(ThemeColorId::GUILD_SOCIAL_TAB_OUTLINE));
- setHighlightedTabColor(&getThemeColor(
- ThemeColorId::GUILD_SOCIAL_TAB_HIGHLIGHTED), &getThemeColor(
- ThemeColorId::GUILD_SOCIAL_TAB_HIGHLIGHTED_OUTLINE));
- setSelectedTabColor(&getThemeColor(
- ThemeColorId::GUILD_SOCIAL_TAB_SELECTED),
- &getThemeColor(
- ThemeColorId::GUILD_SOCIAL_TAB_SELECTED_OUTLINE));
-
- createControls(guild, showBackground);
- mMenuAction = "guild";
- }
-
- A_DELETE_COPY(SocialGuildTab)
-
- ~SocialGuildTab()
- {
- delete2(mList)
- delete2(mScroll)
- }
-
- void action(const ActionEvent &event) override final
- {
- const std::string &eventId = event.getId();
- if (eventId == "do invite")
- {
- const std::string name = mInviteDialog->getText();
- guildHandler->invite(name);
-
- if (localChatTab != nullptr)
- {
- localChatTab->chatLog(strprintf(
- // TRANSLATORS: chat message
- _("Invited user %s to guild %s."),
- name.c_str(),
- mGuild->getName().c_str()),
- ChatMsgType::BY_SERVER);
- }
- mInviteDialog = nullptr;
- }
- else if (eventId == "~do invite")
- {
- mInviteDialog = nullptr;
- }
- else if (eventId == "yes")
- {
- guildHandler->leave(mGuild->getId());
- if (localChatTab != nullptr)
- {
- localChatTab->chatLog(strprintf(
- // TRANSLATORS: chat message
- _("Guild %s quit requested."),
- mGuild->getName().c_str()),
- ChatMsgType::BY_SERVER);
- }
- mConfirmDialog = nullptr;
- }
- else if (eventId == "~yes")
- {
- mConfirmDialog = nullptr;
- }
- }
-
- void invite() override final
- {
- CREATEWIDGETV(mInviteDialog, TextDialog,
- // TRANSLATORS: guild invite message
- _("Member Invite to Guild"),
- // TRANSLATORS: guild invite message
- strprintf(_("Who would you like to invite to guild %s?"),
- mGuild->getName().c_str()), socialWindow);
- mInviteDialog->setActionEventId("do invite");
- mInviteDialog->addActionListener(this);
- }
-
- void leave() override final
- {
- CREATEWIDGETV(mConfirmDialog, ConfirmDialog,
- // TRANSLATORS: guild leave message
- _("Leave Guild?"),
- // TRANSLATORS: guild leave message
- strprintf(_("Are you sure you want to leave guild %s?"),
- mGuild->getName().c_str()), SOUND_REQUEST, socialWindow);
- mConfirmDialog->addActionListener(this);
- }
-
- void buildCounter(const int online0, const int total0) override final
- {
- if ((online0 != 0) || (total0 != 0))
- {
- // TRANSLATORS: social window label
- mCounterString = strprintf(_("Members: %u/%u"),
- CAST_U32(online0),
- CAST_U32(total0));
- }
- else
- {
- if (localPlayer == nullptr)
- return;
-
- const Guild *const guild = localPlayer->getGuild();
- if (guild == nullptr)
- return;
-
- const Guild::MemberList *const members = guild->getMembers();
- int online = 0;
- int total = 0;
- FOR_EACHP (Guild::MemberList::const_iterator, it, members)
- {
- if ((*it)->getOnline())
- online ++;
- total ++;
- }
-
- // TRANSLATORS: social window label
- mCounterString = strprintf(_("Players: %u/%u"),
- CAST_U32(online),
- CAST_U32(total));
- }
- updateCounter();
- }
-
- private:
- Guild *mGuild;
-};
-
-#endif // GUI_WIDGETS_TABS_SOCIALGUILDTAB_H
diff --git a/src/gui/widgets/tabs/socialguildtab2.h b/src/gui/widgets/tabs/socialguildtab2.h
deleted file mode 100644
index ff8544232..000000000
--- a/src/gui/widgets/tabs/socialguildtab2.h
+++ /dev/null
@@ -1,106 +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 GUI_WIDGETS_TABS_SOCIALGUILDTAB2_H
-#define GUI_WIDGETS_TABS_SOCIALGUILDTAB2_H
-
-#include "gui/widgets/tabs/socialtab.h"
-
-#include "guild.h"
-
-#include "being/localplayer.h"
-
-#include "utils/delete2.h"
-#include "utils/foreach.h"
-#include "utils/gettext.h"
-#include "utils/stringutils.h"
-
-#include "localconsts.h"
-
-class SocialGuildTab2 final : public SocialTab,
- public ActionListener
-{
- public:
- SocialGuildTab2(const Widget2 *const widget,
- Guild *const guild,
- const Opaque showBackground) :
- SocialTab(widget),
- ActionListener()
- {
- // TRANSLATORS: tab in social window
- setCaption(_("Guild"));
-
- setTabColor(&getThemeColor(ThemeColorId::GUILD_SOCIAL_TAB),
- &getThemeColor(ThemeColorId::GUILD_SOCIAL_TAB_OUTLINE));
- setHighlightedTabColor(&getThemeColor(
- ThemeColorId::GUILD_SOCIAL_TAB_HIGHLIGHTED),
- &getThemeColor(
- ThemeColorId::GUILD_SOCIAL_TAB_HIGHLIGHTED_OUTLINE));
- setSelectedTabColor(&getThemeColor(
- ThemeColorId::GUILD_SOCIAL_TAB_SELECTED),
- &getThemeColor(
- ThemeColorId::GUILD_SOCIAL_TAB_SELECTED_OUTLINE));
-
- createControls(guild, showBackground);
- mMenuAction = "guild";
- }
-
- A_DELETE_COPY(SocialGuildTab2)
-
- ~SocialGuildTab2()
- {
- delete2(mList)
- delete2(mScroll)
- }
-
- void action(const ActionEvent &event A_UNUSED) override final
- {
- }
-
- void buildCounter(const int online0 A_UNUSED,
- const int total0 A_UNUSED) override final
- {
- if (localPlayer == nullptr)
- return;
-
- const Guild *const guild = localPlayer->getGuild();
- if (guild == nullptr)
- return;
-
- const Guild::MemberList *const members = guild->getMembers();
- int online = 0;
- int total = 0;
- FOR_EACHP (Guild::MemberList::const_iterator, it, members)
- {
- if ((*it)->getOnline())
- online ++;
- total ++;
- }
-
- // TRANSLATORS: social window label
- mCounterString = strprintf(_("Players: %u/%u"),
- CAST_U32(online),
- CAST_U32(total));
- updateCounter();
- }
-};
-
-#endif // GUI_WIDGETS_TABS_SOCIALGUILDTAB2_H
diff --git a/src/gui/widgets/tabs/socialnavigationtab.h b/src/gui/widgets/tabs/socialnavigationtab.h
deleted file mode 100644
index 1b049f055..000000000
--- a/src/gui/widgets/tabs/socialnavigationtab.h
+++ /dev/null
@@ -1,308 +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 GUI_WIDGETS_TABS_SOCIALNAVIGATIONTAB_H
-#define GUI_WIDGETS_TABS_SOCIALNAVIGATIONTAB_H
-
-#include "gui/widgets/tabs/socialtab.h"
-
-#include "actormanager.h"
-#include "configuration.h"
-
-#include "gui/models/beingslistmodel.h"
-
-#include "gui/windows/outfitwindow.h"
-
-#include "being/localplayer.h"
-
-#include "input/keyboardconfig.h"
-
-#include "utils/delete2.h"
-#include "utils/gettext.h"
-
-#include "resources/map/map.h"
-#include "resources/map/mapitem.h"
-#include "resources/map/speciallayer.h"
-
-#include "localconsts.h"
-
-class Avatar;
-
-class SocialNavigationTab final : public SocialTab
-{
- public:
- SocialNavigationTab(const Widget2 *const widget,
- const Opaque showBackground) :
- SocialTab(widget),
- mBeings(new BeingsListModel)
- {
- createControls(mBeings, showBackground);
-
- // TRANSLATORS: Navigation tab name in social window.
- // TRANSLATORS: Should be small
- setCaption(_("Nav"));
- mMenuAction = "navigation";
- }
-
- A_DELETE_COPY(SocialNavigationTab)
-
- ~SocialNavigationTab()
- {
- delete2(mList)
- delete2(mScroll)
- delete2(mBeings)
- }
-
- void updateList() override final
- {
- if ((socialWindow == nullptr) || (localPlayer == nullptr))
- return;
-
- const Map *const map = socialWindow->getMap();
- if ((map == nullptr) || map->empty())
- return;
-
- if (socialWindow->getProcessedPortals())
- return;
-
- STD_VECTOR<Avatar*> *const avatars = mBeings->getMembers();
- STD_VECTOR<MapItem*> portals = map->getPortals();
-
- STD_VECTOR<MapItem*>::const_iterator i = portals.begin();
- const SpecialLayer *const specialLayer = map->getSpecialLayer();
-
- STD_VECTOR<Avatar*>::iterator ia = avatars->begin();
-
- while (ia != avatars->end())
- {
- delete *ia;
- ++ ia;
- }
-
- avatars->clear();
-
- int online = 0;
- int total = 0;
-
- int idx = 0;
- while (i != portals.end())
- {
- MapItem *portal = *i;
- if (portal == nullptr)
- continue;
-
- const int x = portal->getX();
- const int y = portal->getY();
-
- const std::string name = strprintf("%s [%d %d]",
- portal->getComment().c_str(), x, y);
-
- Avatar *const ava = new Avatar(name);
- if (localPlayer != nullptr)
- ava->setOnline(localPlayer->isReachable(x, y, true));
- else
- ava->setOnline(false);
- ava->setLevel(-1);
- ava->setType(portal->getType());
- ava->setX(x);
- ava->setY(y);
- avatars->push_back(ava);
-
- if (ava->getOnline())
- online ++;
- total ++;
-
- if (config.getBoolValue("drawHotKeys")
- && idx < 80 && (outfitWindow != nullptr))
- {
- Being *const being = actorManager
- ->findPortalByTile(x, y);
- if (being != nullptr)
- {
- being->setName(KeyboardConfig::getKeyShortString(
- OutfitWindow::keyName(idx)));
- }
-
- if (specialLayer != nullptr)
- {
- portal = specialLayer->getTile(
- ava->getX(), ava->getY());
- if (portal != nullptr)
- {
- portal->setName(KeyboardConfig::getKeyShortString(
- OutfitWindow::keyName(idx)));
- }
- }
- }
-
- ++i;
- idx ++;
- }
- if (socialWindow != nullptr)
- socialWindow->setProcessedPortals(true);
-
- // TRANSLATORS: social window label
- mCounterString = strprintf(_("Portals: %u/%u"),
- CAST_U32(online),
- CAST_U32(total));
- updateCounter();
- }
-
- void selectIndex(const unsigned num) override final
- {
- if (localPlayer == nullptr)
- return;
-
- STD_VECTOR<Avatar*> *const avatars = mBeings->getMembers();
- if (avatars->size() <= CAST_SIZE(num))
- return;
-
- const Avatar *const ava = avatars->at(num);
- if ((ava != nullptr) && (localPlayer != nullptr))
- localPlayer->navigateTo(ava->getX(), ava->getY());
- }
-
- void updateNames()
- {
- if (socialWindow == nullptr)
- return;
-
- STD_VECTOR<Avatar*> *const avatars = mBeings->getMembers();
-
- const Map *const map = socialWindow->getMap();
- if (map == nullptr)
- return;
-
- STD_VECTOR<Avatar*>::const_iterator i = avatars->begin();
- const STD_VECTOR<Avatar*>::const_iterator i_end = avatars->end();
- while (i != i_end)
- {
- Avatar *const ava = *i;
- if (ava == nullptr)
- break;
-
- const MapItem *const item = map->findPortalXY(
- ava->getX(), ava->getY());
- if (item != nullptr)
- {
- const std::string name = strprintf("%s [%d %d]",
- item->getComment().c_str(),
- item->getX(), item->getY());
- ava->setName(name);
- ava->setOriginalName(name);
- }
-
- ++i;
- }
- }
-
- int getPortalIndex(const int x, const int y)
- {
- if (socialWindow == nullptr)
- return -1;
-
- STD_VECTOR<Avatar*> *const avatars = mBeings->getMembers();
- const Map *const map = socialWindow->getMap();
- if (map == nullptr)
- return -1;
-
- STD_VECTOR<Avatar*>::const_iterator i = avatars->begin();
- const STD_VECTOR<Avatar*>::const_iterator i_end = avatars->end();
- unsigned num = 0;
- while (i != i_end)
- {
- const Avatar *const ava = *i;
- if (ava == nullptr)
- break;
-
- if (ava->getX() == x && ava->getY() == y)
- return num;
-
- ++i;
- num ++;
- }
- return -1;
- }
-
- void addPortal(const int x, const int y)
- {
- if ((socialWindow == nullptr) || (localPlayer == nullptr))
- return;
-
- const Map *const map = socialWindow->getMap();
- if (map == nullptr)
- return;
-
- STD_VECTOR<Avatar*> *const avatars = mBeings->getMembers();
- const MapItem *const portal = map->findPortalXY(x, y);
- if (portal == nullptr)
- return;
-
- const std::string name = strprintf("%s [%d %d]",
- portal->getComment().c_str(), x, y);
-
- Avatar *const ava = new Avatar(name);
- if (localPlayer != nullptr)
- ava->setOnline(localPlayer->isReachable(x, y, true));
- else
- ava->setOnline(false);
- ava->setLevel(-1);
- ava->setType(portal->getType());
- ava->setX(x);
- ava->setY(y);
- avatars->push_back(ava);
- }
-
- void removePortal(const int x, const int y)
- {
- if ((socialWindow == nullptr) || (localPlayer == nullptr))
- return;
-
- const Map *const map = socialWindow->getMap();
- if (map == nullptr)
- return;
-
- STD_VECTOR<Avatar*> *const avatars = mBeings->getMembers();
- STD_VECTOR<Avatar*>::iterator i = avatars->begin();
- const STD_VECTOR<Avatar*>::iterator i_end = avatars->end();
-
- while (i != i_end)
- {
- Avatar *ava = (*i);
-
- if (ava == nullptr)
- break;
-
- if (ava->getX() == x && ava->getY() == y)
- {
- delete ava;
- avatars->erase(i);
- return;
- }
-
- ++ i;
- }
- }
-
- private:
- BeingsListModel *mBeings;
-};
-
-#endif // GUI_WIDGETS_TABS_SOCIALNAVIGATIONTAB_H
diff --git a/src/gui/widgets/tabs/socialpartytab.h b/src/gui/widgets/tabs/socialpartytab.h
deleted file mode 100644
index d7f22c1f7..000000000
--- a/src/gui/widgets/tabs/socialpartytab.h
+++ /dev/null
@@ -1,171 +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 GUI_WIDGETS_TABS_SOCIALPARTYTAB_H
-#define GUI_WIDGETS_TABS_SOCIALPARTYTAB_H
-
-#include "gui/widgets/tabs/socialtab.h"
-
-#include "party.h"
-
-#include "being/localplayer.h"
-
-#include "net/partyhandler.h"
-
-#include "utils/delete2.h"
-#include "utils/foreach.h"
-#include "utils/gettext.h"
-#include "utils/stringutils.h"
-
-#include "localconsts.h"
-
-class SocialPartyTab final : public SocialTab,
- public ActionListener
-{
- public:
- SocialPartyTab(const Widget2 *const widget,
- Party *const party,
- const Opaque showBackground) :
- SocialTab(widget),
- ActionListener(),
- mParty(party)
- {
- // TRANSLATORS: tab in social window
- setCaption(_("Party"));
-
- setTabColor(&getThemeColor(ThemeColorId::PARTY_SOCIAL_TAB),
- &getThemeColor(ThemeColorId::PARTY_SOCIAL_TAB_OUTLINE));
- setHighlightedTabColor(&getThemeColor(
- ThemeColorId::PARTY_SOCIAL_TAB_HIGHLIGHTED), &getThemeColor(
- ThemeColorId::PARTY_SOCIAL_TAB_HIGHLIGHTED_OUTLINE));
- setSelectedTabColor(&getThemeColor(
- ThemeColorId::PARTY_SOCIAL_TAB_SELECTED),
- &getThemeColor(
- ThemeColorId::PARTY_SOCIAL_TAB_SELECTED_OUTLINE));
-
- createControls(party, showBackground);
- mMenuAction = "party";
- }
-
- A_DELETE_COPY(SocialPartyTab)
-
- ~SocialPartyTab()
- {
- delete2(mList)
- delete2(mScroll)
- }
-
- void action(const ActionEvent &event) override final
- {
- const std::string &eventId = event.getId();
- if (eventId == "do invite")
- {
- const std::string name = mInviteDialog->getText();
- partyHandler->invite(name);
-
- if (localChatTab != nullptr)
- {
- localChatTab->chatLog(strprintf(
- // TRANSLATORS: chat message
- _("Invited user %s to party."),
- name.c_str()),
- ChatMsgType::BY_SERVER);
- }
- mInviteDialog = nullptr;
- }
- else if (eventId == "~do invite")
- {
- mInviteDialog = nullptr;
- }
- else if (eventId == "yes")
- {
- partyHandler->leave();
- if (localChatTab != nullptr)
- {
- localChatTab->chatLog(strprintf(
- // TRANSLATORS: tab in social window
- _("Party %s quit requested."),
- mParty->getName().c_str()),
- ChatMsgType::BY_SERVER);
- }
- mConfirmDialog = nullptr;
- }
- else if (eventId == "~yes")
- {
- mConfirmDialog = nullptr;
- }
- }
-
- void invite() override final
- {
- CREATEWIDGETV(mInviteDialog, TextDialog,
- // TRANSLATORS: party invite message
- _("Member Invite to Party"),
- // TRANSLATORS: party invite message
- strprintf(_("Who would you like to invite to party %s?"),
- mParty->getName().c_str()), socialWindow);
- mInviteDialog->setActionEventId("do invite");
- mInviteDialog->addActionListener(this);
- }
-
- void leave() override final
- {
- CREATEWIDGETV(mConfirmDialog, ConfirmDialog,
- // TRANSLATORS: party leave message
- _("Leave Party?"),
- // TRANSLATORS: party leave message
- strprintf(_("Are you sure you want to leave party %s?"),
- mParty->getName().c_str()), SOUND_REQUEST, socialWindow);
- mConfirmDialog->addActionListener(this);
- }
-
- void buildCounter(const int online0 A_UNUSED,
- const int total0 A_UNUSED) override final
- {
- if (localPlayer == nullptr)
- return;
-
- const Party *const party = localPlayer->getParty();
- if (party == nullptr)
- return;
-
- const Party::MemberList *const members = party->getMembers();
- int online = 0;
- int total = 0;
- FOR_EACHP (Party::MemberList::const_iterator, it, members)
- {
- if ((*it)->getOnline())
- online ++;
- total ++;
- }
-
- // TRANSLATORS: social window label
- mCounterString = strprintf(_("Players: %u/%u"),
- CAST_U32(online),
- CAST_U32(total));
- updateCounter();
- }
-
- private:
- Party *mParty;
-};
-
-#endif // GUI_WIDGETS_TABS_SOCIALPARTYTAB_H
diff --git a/src/gui/widgets/tabs/socialpickuptab.h b/src/gui/widgets/tabs/socialpickuptab.h
deleted file mode 100644
index 93d00e81a..000000000
--- a/src/gui/widgets/tabs/socialpickuptab.h
+++ /dev/null
@@ -1,75 +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 GUI_WIDGETS_TABS_SOCIALPICKUPTAB_H
-#define GUI_WIDGETS_TABS_SOCIALPICKUPTAB_H
-
-#include "gui/widgets/tabs/socialtab.h"
-
-#include "being/localplayer.h"
-
-#include "gui/models/beingslistmodel.h"
-
-#include "gui/widgets/tabs/socialtabbase.h"
-
-#include "utils/delete2.h"
-#include "utils/gettext.h"
-
-#include "localconsts.h"
-
-class SocialPickupTab final : public SocialTab
-{
- public:
- SocialPickupTab(const Widget2 *const widget,
- const Opaque showBackground) :
- SocialTab(widget),
- mBeings(new BeingsListModel)
- {
- createControls(mBeings, showBackground);
-
- // TRANSLATORS: Pickup filter tab name in social window.
- // TRANSLATORS: Should be small
- setCaption(_("Pik"));
- mMenuAction = "pickup";
- }
-
- A_DELETE_COPY(SocialPickupTab)
-
- ~SocialPickupTab()
- {
- delete2(mList)
- delete2(mScroll)
- delete2(mBeings)
- }
-
- void updateList() override final
- {
- updateAtkListStart();
- // TRANSLATORS: items group name in social window
- addAvatars(PickupItem, _("Pickup items"), PICKUP);
- // TRANSLATORS: items group name in social window
- addAvatars(IgnorePickupItem, _("Ignore items"), NOPICKUP);
- }
-
- private:
- BeingsListModel *mBeings;
-};
-
-#endif // GUI_WIDGETS_TABS_SOCIALPICKUPTAB_H
diff --git a/src/gui/widgets/tabs/socialplayerstab.h b/src/gui/widgets/tabs/socialplayerstab.h
deleted file mode 100644
index c43093fca..000000000
--- a/src/gui/widgets/tabs/socialplayerstab.h
+++ /dev/null
@@ -1,198 +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 GUI_WIDGETS_TABS_SOCIALPLAYERSTAB_H
-#define GUI_WIDGETS_TABS_SOCIALPLAYERSTAB_H
-
-#include "gui/widgets/tabs/socialtab.h"
-
-#include "actormanager.h"
-#include "party.h"
-
-#include "being/being.h"
-
-#include "gui/models/beingslistmodel.h"
-
-#include "utils/gettext.h"
-#include "utils/delete2.h"
-#include "utils/stringutils.h"
-
-#include "localconsts.h"
-
-class Avatar;
-class Being;
-
-class SocialPlayersTab final : public SocialTab
-{
- public:
- SocialPlayersTab(const Widget2 *const widget,
- const std::string &name,
- const Opaque showBackground) :
- SocialTab(widget),
- mBeings(new BeingsListModel)
- {
- createControls(mBeings, showBackground);
-
- getPlayersAvatars();
- setCaption(name);
- mMenuAction = "players";
- }
-
- A_DELETE_COPY(SocialPlayersTab)
-
- ~SocialPlayersTab()
- {
- delete2(mList)
- delete2(mScroll)
- delete2(mBeings)
- }
-
- void updateList() override final
- {
- getPlayersAvatars();
- }
-
- void updateAvatar(const std::string &name) override final
- {
- if (actorManager == nullptr)
- return;
-
- BLOCK_START("SocialPlayersTab::updateAvatar")
- Avatar *const avatar = findAvatarbyName(name);
- if (avatar == nullptr)
- return;
- if (Party::getParty(1) != nullptr)
- {
- const PartyMember *const
- pm = Party::getParty(1)->getMember(name);
- if ((pm != nullptr) && pm->getMaxHp() > 0)
- {
- avatar->setMaxHp(pm->getMaxHp());
- avatar->setHp(pm->getHp());
- }
- }
- const Being *const being = actorManager->findBeingByName(
- name, ActorType::Player);
- if (being != nullptr)
- {
- avatar->setDamageHp(being->getDamageTaken());
- avatar->setLevel(being->getLevel());
- avatar->setGender(being->getGender());
- avatar->setIp(being->getIp());
- avatar->setPoison(being->getPoison());
- }
- BLOCK_END("SocialPlayersTab::updateAvatar")
- }
-
- void resetDamage(const std::string &name) override final
- {
- if (actorManager == nullptr)
- return;
-
- Avatar *const avatar = findAvatarbyName(name);
- if (avatar == nullptr)
- return;
- avatar->setDamageHp(0);
- Being *const being = actorManager->findBeingByName(
- name, ActorType::Player);
-
- if (being != nullptr)
- being->setDamageTaken(0);
- }
-
- Avatar* findAvatarbyName(const std::string &name)
- {
- STD_VECTOR<Avatar*> *const avatars = mBeings->getMembers();
- Avatar *ava = nullptr;
- STD_VECTOR<Avatar*>::const_iterator i = avatars->begin();
- const STD_VECTOR<Avatar*>::const_iterator i_end = avatars->end();
- while (i != i_end)
- {
- ava = (*i);
- if ((ava != nullptr) && ava->getName() == name)
- return ava;
- ++i;
- }
- ava = new Avatar(name);
- ava->setOnline(true);
- avatars->push_back(ava);
- return ava;
- }
-
- void getPlayersAvatars()
- {
- STD_VECTOR<Avatar*> *const avatars = mBeings->getMembers();
- if (actorManager != nullptr)
- {
- StringVect names;
- actorManager->getPlayerNames(names, NpcNames_false);
-
- STD_VECTOR<Avatar*>::iterator ai = avatars->begin();
- while (ai != avatars->end())
- {
- bool finded = false;
- const Avatar *const ava = (*ai);
- if (ava == nullptr)
- break;
-
- StringVectCIter i = names.begin();
- const StringVectCIter i_end = names.end();
- while (i != i_end)
- {
- if (ava->getName() == (*i) && !(*i).empty())
- {
- finded = true;
- break;
- }
- ++i;
- }
-
- if (!finded)
- {
- delete *ai;
- ai = avatars->erase(ai);
- }
- else
- {
- ++ai;
- }
- }
-
- StringVectCIter i = names.begin();
- const StringVectCIter i_end = names.end();
-
- while (i != i_end)
- {
- if (!(*i).empty())
- updateAvatar(*i);
- ++i;
- }
- }
- // TRANSLATORS: social window label
- mCounterString = strprintf(_("Visible players: %d"),
- CAST_S32(avatars->size()));
- updateCounter();
- }
-
- private:
- BeingsListModel *mBeings;
-};
-
-#endif // GUI_WIDGETS_TABS_SOCIALPLAYERSTAB_H
diff --git a/src/gui/widgets/tabs/socialtab.h b/src/gui/widgets/tabs/socialtab.h
deleted file mode 100644
index 1c94aaede..000000000
--- a/src/gui/widgets/tabs/socialtab.h
+++ /dev/null
@@ -1,143 +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 GUI_WIDGETS_TABS_SOCIALTAB_H
-#define GUI_WIDGETS_TABS_SOCIALTAB_H
-
-#include "gui/windows/socialwindow.h"
-
-#include "gui/windows/confirmdialog.h"
-#include "gui/windows/textdialog.h"
-
-#include "gui/widgets/avatarlistbox.h"
-#include "gui/widgets/createwidget.h"
-#include "gui/widgets/scrollarea.h"
-
-#include "gui/widgets/tabs/tab.h"
-
-#include "localconsts.h"
-
-class AvatarListModel;
-
-class SocialTab notfinal : public Tab
-{
- public:
- A_DELETE_COPY(SocialTab)
-
- virtual void invite()
- {
- }
-
- virtual void leave()
- {
- }
-
- virtual void updateList()
- {
- }
-
- virtual void updateAvatar(const std::string &name A_UNUSED)
- {
- }
-
- virtual void resetDamage(const std::string &name A_UNUSED)
- {
- }
-
- virtual void selectIndex(const unsigned num A_UNUSED)
- {
- }
-
- virtual void buildCounter(const int online A_UNUSED,
- const int total A_UNUSED)
- {
- }
-
- protected:
- friend class SocialWindow;
-
- explicit SocialTab(const Widget2 *const widget) :
- Tab(widget),
- mInviteDialog(nullptr),
- mConfirmDialog(nullptr),
- mScroll(nullptr),
- mList(nullptr),
- mCounterString(),
- mMenuAction("menu")
- {
- }
-
- virtual ~SocialTab()
- {
- // Cleanup dialogs
- if (mInviteDialog != nullptr)
- {
- mInviteDialog->close();
- mInviteDialog->scheduleDelete();
- mInviteDialog = nullptr;
- }
-
- if (mConfirmDialog != nullptr)
- {
- mConfirmDialog->close();
- mConfirmDialog->scheduleDelete();
- mConfirmDialog = nullptr;
- }
- }
-
- void createControls(AvatarListModel *const listModel,
- const Opaque showBackground)
- {
- CREATEWIDGETV(mList, AvatarListBox, this, listModel);
- mScroll = new ScrollArea(this, mList, showBackground,
- "social_background.xml");
-
- mScroll->setHorizontalScrollPolicy(ScrollArea::SHOW_AUTO);
- mScroll->setVerticalScrollPolicy(ScrollArea::SHOW_ALWAYS);
- }
-
- void setCurrent() override final
- {
- updateCounter();
- updateMenu();
- }
-
- void updateCounter() const
- {
- if (socialWindow != nullptr)
- socialWindow->updateCounter(this, mCounterString);
- }
-
- void updateMenu() const
- {
- if (socialWindow != nullptr)
- socialWindow->updateMenu(this, mMenuAction);
- }
-
- TextDialog *mInviteDialog;
- ConfirmDialog *mConfirmDialog;
- ScrollArea *mScroll;
- AvatarListBox *mList;
- std::string mCounterString;
- std::string mMenuAction;
-};
-
-#endif // GUI_WIDGETS_TABS_SOCIALTAB_H
diff --git a/src/gui/widgets/tabs/socialtabbase.h b/src/gui/widgets/tabs/socialtabbase.h
deleted file mode 100644
index 03a02bb1f..000000000
--- a/src/gui/widgets/tabs/socialtabbase.h
+++ /dev/null
@@ -1,84 +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 GUI_WIDGETS_TABS_SOCIALTABBASE_H
-#define GUI_WIDGETS_TABS_SOCIALTABBASE_H
-
-#include "actormanager.h"
-
-ACTORMANAGER_H
-
-#include "enums/resources/map/mapitemtype.h"
-
-ENUMS_RESOURCES_MAP_MAPITEMTYPE_H
-
-#define addAvatars(mob, str, type) \
-{\
- ava = new Avatar(str);\
- ava->setOnline(false);\
- ava->setLevel(-1);\
- ava->setType(MapItemType::SEPARATOR);\
- ava->setX(0);\
- ava->setY(0);\
- avatars->push_back(ava);\
- mobs = actorManager->get##mob##s();\
- i = mobs.begin();\
- i_end = mobs.end();\
- while (i != i_end)\
- {\
- std::string name;\
- int level = -1;\
- if ((*i).empty())\
- {\
- name = _("(default)");\
- level = 0;\
- }\
- else\
- {\
- name = *i;\
- }\
- ava = new Avatar(name);\
- ava->setOnline(true);\
- ava->setLevel(level);\
- ava->setType(MapItemType::type);\
- ava->setX(0);\
- ava->setY(0);\
- avatars->push_back(ava);\
- ++ i;\
- }\
-}
-
-#define updateAtkListStart() \
- if (!socialWindow || !localPlayer || !actorManager)\
- return;\
- STD_VECTOR<Avatar*> *const avatars = mBeings->getMembers();\
- STD_VECTOR<Avatar*>::iterator ia = avatars->begin();\
- while (ia != avatars->end())\
- {\
- delete *ia;\
- ++ ia;\
- }\
- avatars->clear();\
- Avatar *ava = nullptr;\
- std::list<std::string> mobs;\
- std::list<std::string>::const_iterator i;\
- std::list<std::string>::const_iterator i_end;
-
-#endif // GUI_WIDGETS_TABS_SOCIALTABBASE_H
diff --git a/src/gui/widgets/tabs/tab.cpp b/src/gui/widgets/tabs/tab.cpp
deleted file mode 100644
index 36c2a3f40..000000000
--- a/src/gui/widgets/tabs/tab.cpp
+++ /dev/null
@@ -1,488 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "gui/widgets/tabs/tab.h"
-
-#include "settings.h"
-
-#include "gui/gui.h"
-#include "gui/skin.h"
-
-#include "gui/widgets/label.h"
-#include "gui/widgets/tabbedarea.h"
-
-#include "render/vertexes/imagecollection.h"
-
-#include "resources/imagerect.h"
-
-#include "resources/image/image.h"
-
-#include "utils/delete2.h"
-
-#include "debug.h"
-
-int Tab::mInstances = 0;
-float Tab::mAlpha = 1.0;
-
-namespace
-{
- std::string const data[Tab::TAB_COUNT] =
- {
- "tab.xml",
- "tab_highlighted.xml",
- "tab_selected.xml",
- "tab_unused.xml"
- };
-} // namespace
-
-Skin *Tab::tabImg[Tab::TAB_COUNT];
-
-Tab::Tab(const Widget2 *const widget) :
- BasicContainer(widget),
- MouseListener(),
- WidgetListener(),
- mLabel(new Label(this)),
- mTabbedArea(nullptr),
- mTabColor(&getThemeColor(ThemeColorId::TAB)),
- mTabOutlineColor(&getThemeColor(ThemeColorId::TAB_OUTLINE)),
- mTabHighlightedColor(&getThemeColor(ThemeColorId::TAB_HIGHLIGHTED)),
- mTabHighlightedOutlineColor(&getThemeColor(
- ThemeColorId::TAB_HIGHLIGHTED_OUTLINE)),
- mTabSelectedColor(&getThemeColor(ThemeColorId::TAB_SELECTED)),
- mTabSelectedOutlineColor(&getThemeColor(
- ThemeColorId::TAB_SELECTED_OUTLINE)),
- mFlashColor(&getThemeColor(ThemeColorId::TAB_FLASH)),
- mFlashOutlineColor(&getThemeColor(ThemeColorId::TAB_FLASH_OUTLINE)),
- mPlayerFlashColor(&getThemeColor(ThemeColorId::TAB_PLAYER_FLASH)),
- mPlayerFlashOutlineColor(&getThemeColor(
- ThemeColorId::TAB_PLAYER_FLASH_OUTLINE)),
- mFlash(0),
- mVertexes(new ImageCollection),
- mImage(nullptr),
- mMode(0),
- mLabelMode(-1),
- mHasMouse(false)
-{
- init();
-}
-
-Tab::~Tab()
-{
- if (gui != nullptr)
- gui->removeDragged(this);
-
- mInstances--;
- if (mInstances == 0 && (theme != nullptr))
- {
- for (int mode = 0; mode < TAB_COUNT; mode ++)
- theme->unload(tabImg[mode]);
- }
-
- delete2(mLabel);
-
- if (mImage != nullptr)
- {
- mImage->decRef();
- mImage = nullptr;
- }
- delete2(mVertexes);
-}
-
-void Tab::init()
-{
- addMouseListener(this);
- setFocusable(false);
- setFrameSize(0);
- mFlash = 0;
-
- addWidgetListener(this);
-
- if (mInstances == 0)
- {
- // Load the skin
- if (theme != nullptr)
- {
- for (int mode = 0; mode < TAB_COUNT; mode ++)
- tabImg[mode] = theme->load(data[mode], "tab.xml");
- }
- updateAlpha();
- }
- mInstances++;
-
- add(mLabel);
-
- const Skin *const skin = tabImg[TAB_STANDARD];
- if (skin == nullptr)
- return;
- const int padding = skin->getPadding();
-
- mLabel->setPosition(padding, padding);
-}
-
-void Tab::updateAlpha()
-{
- const float alpha = std::max(settings.guiAlpha,
- theme->getMinimumOpacity());
-
- if (alpha != mAlpha)
- {
- mAlpha = alpha;
- for (int a = 0; a < 9; a++)
- {
- for (int t = 0; t < TAB_COUNT; t++)
- {
- Skin *const skin = tabImg[t];
- if (skin != nullptr)
- {
- const ImageRect &rect = skin->getBorder();
- Image *const image = rect.grid[a];
- if (image != nullptr)
- image->setAlpha(mAlpha);
- }
- }
- }
- }
-}
-
-void Tab::draw(Graphics *const graphics)
-{
- BLOCK_START("Tab::draw")
- int mode = TAB_STANDARD;
-
- // check which type of tab to draw
- if (mTabbedArea != nullptr)
- {
- int labelMode = mFlash;
-
- if (mTabbedArea->isTabSelected(this))
- {
- labelMode = 3;
- mode = TAB_SELECTED;
- // if tab is selected, it doesnt need to highlight activity
- mFlash = 0;
- }
- else if (labelMode == 0)
- {
- if (mHasMouse)
- {
- labelMode = 4;
- mode = TAB_HIGHLIGHTED;
- }
- }
- else if (mHasMouse)
- {
- mode = TAB_HIGHLIGHTED;
- }
-
- // mRedraw need here because no other way to say label to change color
- // +++ text from label must be moved to tab itself
- if (labelMode != mLabelMode || mRedraw)
- {
- mLabelMode = labelMode;
- switch (labelMode)
- {
- case 0: // default state
- default:
- mLabel->setForegroundColorAll(*mTabColor,
- *mTabOutlineColor);
- break;
- case 1: // mFlash == 1
- mLabel->setForegroundColorAll(*mFlashColor,
- *mFlashOutlineColor);
- break;
- case 2: // mFlash == 2
- mLabel->setForegroundColorAll(*mPlayerFlashColor,
- *mPlayerFlashOutlineColor);
- break;
- case 3: // mTabbedArea->isTabSelected(this)
- mLabel->setForegroundColorAll(*mTabSelectedColor,
- *mTabSelectedOutlineColor);
- break;
- case 4: // mHasMouse
- mLabel->setForegroundColorAll(*mTabHighlightedColor,
- *mTabHighlightedOutlineColor);
- break;
- }
- }
- }
-
- const Skin *const skin = tabImg[mode];
- if (skin == nullptr)
- {
- BLOCK_END("Tab::draw")
- return;
- }
-
- updateAlpha();
-
- const ImageRect &rect = skin->getBorder();
- if (mRedraw || mode != mMode || graphics->getRedraw())
- {
- mMode = mode;
- mRedraw = false;
- mVertexes->clear();
- graphics->calcWindow(mVertexes,
- 0, 0,
- mDimension.width, mDimension.height,
- rect);
-
- if (mImage != nullptr)
- {
- const Skin *const skin1 = tabImg[TAB_STANDARD];
- if (skin1 != nullptr)
- {
- const int padding = skin1->getPadding();
- graphics->calcTileCollection(mVertexes,
- mImage,
- padding,
- padding);
- }
- }
- graphics->finalize(mVertexes);
- }
-
- graphics->drawTileCollection(mVertexes);
-
- drawChildren(graphics);
- BLOCK_END("Tab::draw")
-}
-
-void Tab::safeDraw(Graphics *const graphics)
-{
- BLOCK_START("Tab::draw")
- int mode = TAB_STANDARD;
-
- // check which type of tab to draw
- if (mTabbedArea != nullptr)
- {
- int labelMode = mFlash;
-
- if (mTabbedArea->isTabSelected(this))
- {
- labelMode = 3;
- mode = TAB_SELECTED;
- // if tab is selected, it doesnt need to highlight activity
- mFlash = 0;
- }
- else if (labelMode == 0)
- {
- if (mHasMouse)
- {
- labelMode = 4;
- mode = TAB_HIGHLIGHTED;
- }
- }
- else if (mHasMouse)
- {
- mode = TAB_HIGHLIGHTED;
- }
-
- if (labelMode != mLabelMode)
- {
- mLabelMode = labelMode;
- switch (labelMode)
- {
- case 0: // default state
- default:
- mLabel->setForegroundColorAll(*mTabColor,
- *mTabOutlineColor);
- break;
- case 1: // mFlash == 1
- mLabel->setForegroundColorAll(*mFlashColor,
- *mFlashOutlineColor);
- break;
- case 2: // mFlash == 2
- mLabel->setForegroundColorAll(*mPlayerFlashColor,
- *mPlayerFlashOutlineColor);
- break;
- case 3: // mTabbedArea->isTabSelected(this)
- mLabel->setForegroundColorAll(*mTabSelectedColor,
- *mTabSelectedOutlineColor);
- break;
- case 4: // mHasMouse
- mLabel->setForegroundColorAll(*mTabHighlightedColor,
- *mTabHighlightedOutlineColor);
- break;
- }
- }
- }
-
- const Skin *const skin = tabImg[mode];
- if (skin == nullptr)
- {
- BLOCK_END("Tab::draw")
- return;
- }
-
- updateAlpha();
-
- graphics->drawImageRect(0, 0,
- mDimension.width, mDimension.height,
- skin->getBorder());
- if (mImage != nullptr)
- {
- const Skin *const skin1 = tabImg[TAB_STANDARD];
- if (skin1 != nullptr)
- {
- const int padding = skin1->getPadding();
- graphics->drawImage(mImage, padding, padding);
- }
- }
-
- safeDrawChildren(graphics);
- BLOCK_END("Tab::draw")
-}
-
-void Tab::widgetResized(const Event &event A_UNUSED)
-{
- mRedraw = true;
-}
-
-void Tab::widgetMoved(const Event &event A_UNUSED)
-{
- mRedraw = true;
-}
-
-void Tab::setLabelFont(Font *const font)
-{
- if (mLabel == nullptr)
- return;
-
- mLabel->setFont(font);
- mLabel->adjustSize();
- adjustSize();
- mRedraw = true;
-}
-
-
-void Tab::adjustSize()
-{
- const Skin *const skin = tabImg[TAB_STANDARD];
- if (skin == nullptr)
- return;
- const int pad2 = skin->getPadding() * 2;
-
- if (mImage != nullptr)
- {
- const SDL_Rect &rect = mImage->mBounds;
- setSize(rect.w + pad2, rect.h + pad2);
- }
- else
- {
- setSize(mLabel->getWidth() + pad2,
- mLabel->getHeight() + pad2);
- }
-
- if (mTabbedArea != nullptr)
- mTabbedArea->adjustTabPositions();
-}
-
-void Tab::setTabbedArea(TabbedArea* tabbedArea)
-{
- mTabbedArea = tabbedArea;
-}
-
-TabbedArea* Tab::getTabbedArea() const
-{
- return mTabbedArea;
-}
-
-void Tab::setCaption(const std::string &caption)
-{
- mLabel->setCaption(caption);
- mLabel->adjustSize();
- adjustSize();
-}
-
-void Tab::setImage(Image *const image)
-{
- if (mImage != nullptr)
- mImage->decRef();
- mImage = image;
- adjustSize();
-}
-
-const std::string &Tab::getCaption() const
-{
- return mLabel->getCaption();
-}
-
-void Tab::mouseEntered(MouseEvent& event A_UNUSED)
-{
- mHasMouse = true;
-}
-
-void Tab::mouseExited(MouseEvent& event A_UNUSED)
-{
- mHasMouse = false;
-}
-
-void Tab::finalCleanup()
-{
- for (int f = 0; f < TAB_COUNT; f ++)
- {
- tabImg[f] = nullptr;
- }
-}
diff --git a/src/gui/widgets/tabs/tab.h b/src/gui/widgets/tabs/tab.h
deleted file mode 100644
index e6a816072..000000000
--- a/src/gui/widgets/tabs/tab.h
+++ /dev/null
@@ -1,245 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GUI_WIDGETS_TABS_TAB_H
-#define GUI_WIDGETS_TABS_TAB_H
-
-#include "gui/widgets/basiccontainer.h"
-
-#include "listeners/mouselistener.h"
-#include "listeners/widgetlistener.h"
-
-#include "localconsts.h"
-
-class ImageCollection;
-class Label;
-class Skin;
-class TabbedArea;
-
-/**
- * A tab, the same as the Guichan tab in 0.8, but extended
- */
-class Tab notfinal : public BasicContainer,
- public MouseListener,
- public WidgetListener
-{
- public:
- explicit Tab(const Widget2 *const widget);
-
- A_DELETE_COPY(Tab)
-
- virtual ~Tab();
-
- enum
- {
- TAB_STANDARD = 0,
- TAB_HIGHLIGHTED = 1,
- TAB_SELECTED = 2,
- TAB_UNUSED = 3,
- TAB_COUNT = 4 // Must be last
- };
-
- /**
- * Update the alpha value to the graphic components.
- */
- void updateAlpha();
-
- /**
- * Draw the tabbed area.
- */
- void draw(Graphics *const graphics) override final A_NONNULL(2);
-
- void safeDraw(Graphics *const graphics) override final A_NONNULL(2);
-
- /**
- * Set the normal color for the tab's text.
- */
- void setTabColor(const Color *const color1,
- const Color *const color2)
- {
- mTabColor = color1;
- mTabOutlineColor = color2;
- mRedraw = true;
- }
-
- /**
- * Set the highlighted color for the tab's text.
- */
- void setHighlightedTabColor(const Color *const color1,
- const Color *const color2)
- {
- mTabHighlightedColor = color1;
- mTabHighlightedOutlineColor = color2;
- mRedraw = true;
- }
-
- /**
- * Set the selected color for the tab's text.
- */
- void setSelectedTabColor(const Color *const color1,
- const Color *const color2)
- {
- mTabSelectedColor = color1;
- mTabSelectedOutlineColor = color2;
- mRedraw = true;
- }
-
- /**
- * Set the flash color for the tab's text.
- */
- void setFlashTabColor(const Color *const color1,
- const Color *const color2)
- {
- mFlashColor = color1;
- mFlashOutlineColor = color2;
- mRedraw = true;
- }
-
- /**
- * Set the player flash color for the tab's text.
- */
- void setPlayerFlashTabColor(const Color *const color1,
- const Color *const color2)
- {
- mPlayerFlashColor = color1;
- mPlayerFlashOutlineColor = color2;
- mRedraw = true;
- }
-
- /**
- * Set tab flashing state
- */
- void setFlash(const int flash)
- { mFlash = flash; mRedraw = true; }
-
- int getFlash() const noexcept2 A_WARN_UNUSED
- { return mFlash; }
-
- void widgetResized(const Event &event) override final;
-
- void widgetMoved(const Event &event) override final;
-
- void setLabelFont(Font *const font);
-
- Label *getLabel() const noexcept2 A_WARN_UNUSED
- { return mLabel; }
-
- void adjustSize();
-
- void setTabbedArea(TabbedArea* tabbedArea);
-
- TabbedArea* getTabbedArea() const A_WARN_UNUSED;
-
- void setCaption(const std::string& caption);
-
- const std::string &getCaption() const A_WARN_UNUSED;
-
- void mouseEntered(MouseEvent &event) override final;
-
- void mouseExited(MouseEvent &event) override final;
-
- void setImage(Image *const image);
-
- static void finalCleanup();
-
- protected:
- friend class TabbedArea;
-
- virtual void setCurrent()
- { }
-
- Label* mLabel A_NONNULLPOINTER;
-
- TabbedArea* mTabbedArea;
-
- private:
- /** Load images if no other instances exist yet */
- void init();
-
- static Skin *tabImg[TAB_COUNT]; /**< Tab state graphics */
- static int mInstances; /**< Number of tab instances */
- static float mAlpha;
-
- const Color *mTabColor;
- const Color *mTabOutlineColor;
- const Color *mTabHighlightedColor;
- const Color *mTabHighlightedOutlineColor;
- const Color *mTabSelectedColor;
- const Color *mTabSelectedOutlineColor;
- const Color *mFlashColor;
- const Color *mFlashOutlineColor;
- const Color *mPlayerFlashColor;
- const Color *mPlayerFlashOutlineColor;
- int mFlash;
- ImageCollection *mVertexes A_NONNULLPOINTER;
- Image *mImage;
- int mMode;
- int mLabelMode;
-
- protected:
- bool mHasMouse;
-};
-
-#endif // GUI_WIDGETS_TABS_TAB_H
diff --git a/src/gui/widgets/tabstrip.cpp b/src/gui/widgets/tabstrip.cpp
deleted file mode 100644
index 6b3dbe417..000000000
--- a/src/gui/widgets/tabstrip.cpp
+++ /dev/null
@@ -1,124 +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 "gui/widgets/tabstrip.h"
-
-#include "gui/widgets/button.h"
-
-#include "utils/foreach.h"
-
-#include "debug.h"
-
-TabStrip::TabStrip(const Widget2 *const widget,
- const std::string &group,
- const int height,
- const int spacing) :
- WidgetGroup(widget, group, height, spacing),
- mPressFirst(true)
-{
- mAllowLogic = false;
-}
-
-TabStrip::TabStrip(const Widget2 *const widget,
- const int height,
- const int spacing) :
- WidgetGroup(widget, "", height, spacing),
- mPressFirst(true)
-{
- mAllowLogic = false;
-}
-
-Widget *TabStrip::createWidget(const std::string &text,
- const bool pressed) const
-{
- Button *const widget = new Button(this);
- widget->setStick(true);
- widget->setCaption(text);
- widget->adjustSize();
- if (((mCount == 0) && mPressFirst) || pressed)
- widget->setPressed(true);
- widget->setTag(CAST_S32(mWidgets.size()));
- return widget;
-}
-
-void TabStrip::action(const ActionEvent &event)
-{
- WidgetGroup::action(event);
- if (event.getSource() != nullptr)
- {
- Widget *const widget = event.getSource();
- Button *const button = static_cast<Button*>(widget);
- if (button == nullptr)
- return;
- if (button->isPressed2())
- {
- FOR_EACH (WidgetListConstIterator, iter, mWidgets)
- {
- if (*iter != widget)
- {
- Button *const button2 = static_cast<Button*>(*iter);
- button2->setPressed(false);
- }
- }
- }
- else
- {
- button->setPressed(true);
- }
- }
-}
-
-void TabStrip::nextTab()
-{
- FOR_EACH (WidgetListConstIterator, iter, mWidgets)
- {
- Button *button = static_cast<Button*>(*iter);
- if (button->isPressed2())
- {
- button->setPressed(false);
- ++iter;
- if (iter == mWidgets.end())
- iter = mWidgets.begin();
- button = static_cast<Button*>(*iter);
- action(ActionEvent(button, button->getActionEventId()));
- return;
- }
- }
-}
-
-void TabStrip::prevTab()
-{
- FOR_EACH (WidgetListConstIterator, iter, mWidgets)
- {
- Button *button = static_cast<Button*>(*iter);
- if (button->isPressed2())
- {
- button->setPressed(false);
- if (iter == mWidgets.begin())
- iter = mWidgets.end();
- if (iter == mWidgets.begin())
- return;
- --iter;
- button = static_cast<Button*>(*iter);
- action(ActionEvent(button, button->getActionEventId()));
- return;
- }
- }
-}
diff --git a/src/gui/widgets/tabstrip.h b/src/gui/widgets/tabstrip.h
deleted file mode 100644
index e1e4ca486..000000000
--- a/src/gui/widgets/tabstrip.h
+++ /dev/null
@@ -1,57 +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 GUI_WIDGETS_TABSTRIP_H
-#define GUI_WIDGETS_TABSTRIP_H
-
-#include "gui/widgets/widgetgroup.h"
-
-class TabStrip final : public WidgetGroup
-{
- public:
- TabStrip(const Widget2 *const widget,
- const std::string &group,
- const int height,
- const int spacing = 0);
-
- TabStrip(const Widget2 *const widget,
- const int height,
- const int spacing = 0);
-
- A_DELETE_COPY(TabStrip)
-
- Widget *createWidget(const std::string &name,
- const bool pressed)
- const override final A_WARN_UNUSED;
-
- void action(const ActionEvent &event) override final;
-
- void nextTab();
-
- void prevTab();
-
- void setPressFirst(const bool press)
- { mPressFirst = press; }
-
- protected:
- bool mPressFirst;
-};
-
-#endif // GUI_WIDGETS_TABSTRIP_H
diff --git a/src/gui/widgets/textbox.cpp b/src/gui/widgets/textbox.cpp
deleted file mode 100644
index 5d1696835..000000000
--- a/src/gui/widgets/textbox.cpp
+++ /dev/null
@@ -1,647 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "gui/widgets/textbox.h"
-
-#include "gui/gui.h"
-
-#include "gui/fonts/font.h"
-
-#include "render/graphics.h"
-
-#include <sstream>
-
-#include "debug.h"
-
-TextBox::TextBox(const Widget2 *const widget) :
- Widget(widget),
- MouseListener(),
- KeyListener(),
- mTextRows(),
- mCaretColumn(0),
- mCaretRow(0),
- mMinWidth(getWidth()),
- mEditable(true),
- mOpaque(Opaque_true)
-{
- mAllowLogic = false;
- setText("");
- setFocusable(true);
-
- addMouseListener(this);
- addKeyListener(this);
- adjustSize();
-
- mForegroundColor = getThemeColor(ThemeColorId::TEXTBOX);
- setOpaque(Opaque_false);
- setFrameSize(0);
-}
-
-TextBox::~TextBox()
-{
- if (gui != nullptr)
- gui->removeDragged(this);
-}
-
-void TextBox::setTextWrapped(const std::string &text, const int minDimension)
-{
- // Make sure parent scroll area sets width of this widget
- if (getParent() != nullptr)
- getParent()->logic();
-
- // Take the supplied minimum dimension as a starting
- // point and try to beat it
- mMinWidth = minDimension;
-
- const size_t textSize = text.size();
- size_t spacePos = text.rfind(' ', textSize);
-
- if (spacePos != std::string::npos)
- {
- const std::string word = text.substr(spacePos + 1);
- const int length = getFont()->getWidth(word);
-
- if (length > mMinWidth)
- mMinWidth = length;
- }
-
- std::stringstream wrappedStream;
- size_t newlinePos;
- size_t lastNewlinePos = 0;
- int minWidth = 0;
- int xpos;
-
- do
- {
- // Determine next piece of string to wrap
- newlinePos = text.find('\n', lastNewlinePos);
-
- if (newlinePos == std::string::npos)
- newlinePos = textSize;
-
- std::string line =
- text.substr(lastNewlinePos, newlinePos - lastNewlinePos);
- size_t lastSpacePos = 0;
- xpos = 0;
- const Font *const font = getFont();
- const int spaceWidth = font->getWidth(" ");
- size_t sz = line.size();
-
- do
- {
- spacePos = line.find(' ', lastSpacePos);
-
- if (spacePos == std::string::npos)
- spacePos = sz;
-
- const std::string word =
- line.substr(lastSpacePos, spacePos - lastSpacePos);
-
- const int width = font->getWidth(word);
-
- if (xpos == 0 && width > mMinWidth)
- {
- mMinWidth = width;
- xpos = width;
- wrappedStream << word;
- }
- else if (xpos != 0 && xpos + spaceWidth + width <=
- mMinWidth)
- {
- xpos += spaceWidth + width;
- wrappedStream << " " << word;
- }
- else if (lastSpacePos == 0)
- {
- xpos += width;
- wrappedStream << word;
- }
- else
- {
- if (xpos > minWidth)
- minWidth = xpos;
-
- // The window wasn't big enough. Resize it and try again.
- if (minWidth > mMinWidth)
- {
- mMinWidth = minWidth;
- wrappedStream.clear();
- wrappedStream.str("");
- lastNewlinePos = 0;
- newlinePos = text.find('\n', lastNewlinePos);
- if (newlinePos == std::string::npos)
- newlinePos = textSize;
- line = text.substr(lastNewlinePos, newlinePos -
- lastNewlinePos);
- sz = line.size();
- break;
- }
- else
- {
- wrappedStream << "\n" << word;
- }
- xpos = width;
- }
- lastSpacePos = spacePos + 1;
- }
- while (spacePos != sz);
-
- if (text.find('\n', lastNewlinePos) != std::string::npos)
- wrappedStream << "\n";
-
- lastNewlinePos = newlinePos + 1;
- }
- while (newlinePos != textSize);
-
- if (xpos > minWidth)
- minWidth = xpos;
-
- mMinWidth = minWidth;
-
- setText(wrappedStream.str());
-}
-
-void TextBox::setText(const std::string& text)
-{
- mCaretColumn = 0;
- mCaretRow = 0;
-
- mTextRows.clear();
- if (text.empty())
- {
- adjustSize();
- return;
- }
-
- size_t pos;
- size_t lastPos = 0;
- int length;
- do
- {
- pos = text.find('\n', lastPos);
-
- if (pos != std::string::npos)
- length = CAST_S32(pos - lastPos);
- else
- length = CAST_S32(text.size() - lastPos);
- std::string sub = text.substr(lastPos, length);
- mTextRows.push_back(sub);
- lastPos = pos + 1;
- } while (pos != std::string::npos);
-
- adjustSize();
-}
-
-void TextBox::keyPressed(KeyEvent& event)
-{
- const Key &key = event.getKey();
- const InputActionT action = event.getActionId();
-
- PRAGMA45(GCC diagnostic push)
- PRAGMA45(GCC diagnostic ignored "-Wswitch-enum")
- switch (action)
- {
- case InputAction::GUI_LEFT:
- {
- --mCaretColumn;
- if (mCaretColumn < 0)
- {
- --mCaretRow;
-
- if (mCaretRow < 0)
- {
- mCaretRow = 0;
- mCaretColumn = 0;
- }
- else
- {
- mCaretColumn = CAST_S32(
- mTextRows[mCaretRow].size());
- }
- }
- break;
- }
-
- case InputAction::GUI_RIGHT:
- {
- ++mCaretColumn;
- if (mCaretColumn > CAST_S32(mTextRows[mCaretRow].size()))
- {
- ++ mCaretRow;
-
- const int sz = CAST_S32(mTextRows.size());
- if (mCaretRow >= sz)
- {
- mCaretRow = sz - 1;
- if (mCaretRow < 0)
- mCaretRow = 0;
-
- mCaretColumn = CAST_S32(
- mTextRows[mCaretRow].size());
- }
- else
- {
- mCaretColumn = 0;
- }
- }
- break;
- }
-
- case InputAction::GUI_DOWN:
- {
- setCaretRow(mCaretRow + 1);
- break;
- }
- case InputAction::GUI_UP:
- {
- setCaretRow(mCaretRow - 1);
- break;
- }
- case InputAction::GUI_HOME:
- {
- mCaretColumn = 0;
- break;
- }
- case InputAction::GUI_END:
- {
- mCaretColumn = CAST_S32(mTextRows[mCaretRow].size());
- break;
- }
-
- case InputAction::GUI_SELECT2:
- {
- if (mEditable)
- {
- mTextRows.insert(mTextRows.begin() + mCaretRow + 1,
- mTextRows[mCaretRow].substr(mCaretColumn,
- mTextRows[mCaretRow].size() - mCaretColumn));
- mTextRows[mCaretRow].resize(mCaretColumn);
- ++mCaretRow;
- mCaretColumn = 0;
- }
- break;
- }
-
- case InputAction::GUI_BACKSPACE:
- {
- if (mCaretColumn != 0 && mEditable)
- {
- mTextRows[mCaretRow].erase(mCaretColumn - 1, 1);
- --mCaretColumn;
- }
- else if (mCaretColumn == 0 && mCaretRow != 0 && mEditable)
- {
- mCaretColumn = CAST_S32(
- mTextRows[mCaretRow - 1].size());
- mTextRows[mCaretRow - 1] += mTextRows[mCaretRow];
- mTextRows.erase(mTextRows.begin() + mCaretRow);
- --mCaretRow;
- }
- break;
- }
-
- case InputAction::GUI_DELETE:
- {
- if (mCaretColumn < CAST_S32(
- mTextRows[mCaretRow].size()) && mEditable)
- {
- mTextRows[mCaretRow].erase(mCaretColumn, 1);
- }
- else if (mCaretColumn == CAST_S32(
- mTextRows[mCaretRow].size()) &&
- mCaretRow < (CAST_S32(mTextRows.size()) - 1) &&
- mEditable)
- {
- mTextRows[mCaretRow] += mTextRows[mCaretRow + 1];
- mTextRows.erase(mTextRows.begin() + mCaretRow + 1);
- }
- break;
- }
-
- case InputAction::GUI_PAGE_UP:
- {
- Widget *const par = getParent();
-
- if (par != nullptr)
- {
- const int rowsPerPage = par->getChildrenArea().height
- / getFont()->getHeight();
- mCaretRow -= rowsPerPage;
-
- if (mCaretRow < 0)
- mCaretRow = 0;
- }
- break;
- }
-
- case InputAction::GUI_PAGE_DOWN:
- {
- Widget *const par = getParent();
-
- if (par != nullptr)
- {
- const int rowsPerPage = par->getChildrenArea().height
- / getFont()->getHeight();
- mCaretRow += rowsPerPage;
-
- const int sz = CAST_S32(mTextRows.size());
- if (mCaretRow >= sz)
- mCaretRow = sz - 1;
- }
- break;
- }
-
- case InputAction::GUI_TAB:
- {
- if (mEditable)
- {
- mTextRows[mCaretRow].insert(mCaretColumn, std::string(" "));
- mCaretColumn += 4;
- }
- break;
- }
-
- default:
- {
- if (key.isCharacter() && mEditable)
- {
- mTextRows[mCaretRow].insert(mCaretColumn,
- std::string(1, CAST_S8(key.getValue())));
- ++ mCaretColumn;
- }
- break;
- }
- }
- PRAGMA45(GCC diagnostic pop)
-
- adjustSize();
- scrollToCaret();
-
- event.consume();
-}
-
-void TextBox::draw(Graphics *const graphics)
-{
- BLOCK_START("TextBox::draw")
- if (mOpaque == Opaque_true)
- {
- graphics->setColor(mBackgroundColor);
- graphics->fillRectangle(Rect(0, 0, getWidth(), getHeight()));
- }
-
- Font *const font = getFont();
- if (isFocused() && isEditable())
- {
- drawCaret(graphics, font->getWidth(
- mTextRows[mCaretRow].substr(0, mCaretColumn)),
- mCaretRow * font->getHeight());
- }
-
- const int fontHeight = font->getHeight();
-
- for (size_t i = 0, sz = mTextRows.size(); i < sz; i++)
- {
- // Move the text one pixel so we can have a caret before a letter.
- font->drawString(graphics,
- mForegroundColor,
- mForegroundColor2,
- mTextRows[i], 1,
- CAST_S32(i * CAST_SIZE(fontHeight)));
- }
- BLOCK_END("TextBox::draw")
-}
-
-void TextBox::safeDraw(Graphics *const graphics)
-{
- TextBox::draw(graphics);
-}
-
-void TextBox::setForegroundColor(const Color &color)
-{
- mForegroundColor = color;
- mForegroundColor2 = color;
-}
-
-void TextBox::setForegroundColorAll(const Color &color1,
- const Color &color2)
-{
- mForegroundColor = color1;
- mForegroundColor2 = color2;
-}
-
-std::string TextBox::getText() const
-{
- if (mTextRows.empty())
- return std::string();
-
- int i;
- std::string text;
-
- const int sz = CAST_S32(mTextRows.size());
- for (i = 0; i < sz - 1; ++ i)
- text.append(mTextRows[i]).append("\n");
- text.append(mTextRows[i]);
-
- return text;
-}
-
-void TextBox::setTextRow(const int row, const std::string& text)
-{
- mTextRows[row] = text;
-
- if (mCaretRow == row)
- setCaretColumn(mCaretColumn);
-
- adjustSize();
-}
-
-void TextBox::setCaretPosition(unsigned int position)
-{
- for (int row = 0, fsz = CAST_S32(mTextRows.size());
- row < fsz;
- row ++)
- {
- if (position <= mTextRows[row].size())
- {
- mCaretRow = row;
- mCaretColumn = position;
- return; // we are done
- }
-
- position--;
- }
-
- // position beyond end of text
- mCaretRow = CAST_S32(mTextRows.size() - 1);
- mCaretColumn = CAST_S32(mTextRows[mCaretRow].size());
-}
-
-void TextBox::setCaretRow(const int row)
-{
- mCaretRow = row;
-
- const int sz = CAST_S32(mTextRows.size());
- if (mCaretRow >= sz)
- mCaretRow = sz - 1;
-
- if (mCaretRow < 0)
- mCaretRow = 0;
-
- setCaretColumn(mCaretColumn);
-}
-
-unsigned int TextBox::getCaretPosition() const
-{
- int pos = 0, row;
-
- for (row = 0; row < mCaretRow; row++)
- pos += CAST_S32(mTextRows[row].size());
-
- return pos + mCaretColumn;
-}
-
-void TextBox::setCaretColumn(const int column)
-{
- mCaretColumn = column;
-
- const int sz = CAST_S32(mTextRows[mCaretRow].size());
- if (mCaretColumn > sz)
- mCaretColumn = sz;
-
- if (mCaretColumn < 0)
- mCaretColumn = 0;
-}
-
-void TextBox::setCaretRowColumn(const int row, const int column)
-{
- setCaretRow(row);
- setCaretColumn(column);
-}
-
-void TextBox::scrollToCaret()
-{
- const Font *const font = getFont();
- Rect scroll;
- scroll.x = font->getWidth(mTextRows[mCaretRow].substr(0, mCaretColumn));
- scroll.y = font->getHeight() * mCaretRow;
- scroll.width = font->getWidth(" ");
- // add 2 for some extra space
- scroll.height = font->getHeight() + 2;
- showPart(scroll);
-}
-
-void TextBox::addRow(const std::string &row)
-{
- mTextRows.push_back(row);
- adjustSize();
-}
-
-void TextBox::mousePressed(MouseEvent& event)
-{
- if (event.getButton() == MouseButton::LEFT)
- {
- const int height = getFont()->getHeight();
- if (height == 0)
- return;
-
- event.consume();
- mCaretRow = event.getY() / height;
-
- const int sz = CAST_S32(mTextRows.size());
- if (mCaretRow >= sz)
- mCaretRow = sz - 1;
-
- mCaretColumn = getFont()->getStringIndexAt(
- mTextRows[mCaretRow], event.getX());
- }
-}
-
-void TextBox::mouseDragged(MouseEvent& event)
-{
- event.consume();
-}
-
-void TextBox::drawCaret(Graphics *const graphics,
- const int x,
- const int y) const
-{
- graphics->setColor(mForegroundColor);
- graphics->drawLine(x, getFont()->getHeight() + y, x, y);
-}
-
-void TextBox::adjustSize()
-{
- int width = 0;
- const Font *const font = getFont();
- for (size_t i = 0, sz = mTextRows.size(); i < sz; ++i)
- {
- const int w = font->getWidth(mTextRows[i]);
- if (width < w)
- width = w;
- }
-
- setWidth(width + 1);
- setHeight(font->getHeight() * CAST_S32(mTextRows.size()));
-}
diff --git a/src/gui/widgets/textbox.h b/src/gui/widgets/textbox.h
deleted file mode 100644
index 6ce28ed4b..000000000
--- a/src/gui/widgets/textbox.h
+++ /dev/null
@@ -1,329 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GUI_WIDGETS_TEXTBOX_H
-#define GUI_WIDGETS_TEXTBOX_H
-
-#include "gui/widgets/widget.h"
-
-#include "enums/simpletypes/opaque.h"
-
-#include "listeners/keylistener.h"
-#include "listeners/mouselistener.h"
-
-#include "localconsts.h"
-
-/**
- * A text box, meant to be used inside a scroll area. Same as the Guichan text
- * box except this one doesn't have a background or border, instead completely
- * relying on the scroll area.
- *
- * \ingroup GUI
- */
-class TextBox final : public Widget,
- public MouseListener,
- public KeyListener
-{
- public:
- /**
- * Constructor.
- */
- explicit TextBox(const Widget2 *const widget);
-
- A_DELETE_COPY(TextBox)
-
- ~TextBox();
-
- /**
- * Sets the text after wrapping it to the current width of the widget.
- */
- void setTextWrapped(const std::string &text, const int minDimension);
-
- /**
- * Get the minimum text width for the text box.
- */
- int getMinWidth() const noexcept2 A_WARN_UNUSED
- { return mMinWidth; }
-
- void keyPressed(KeyEvent& event) override final;
-
- void draw(Graphics *const graphics) override final A_NONNULL(2);
-
- void safeDraw(Graphics *const graphics) override final A_NONNULL(2);
-
- void setForegroundColor(const Color &color);
-
- void setForegroundColorAll(const Color &color1,
- const Color &color2);
-
- /**
- * Sets the text of the text box.
- *
- * @param text The text of the text box.
- * @see getText
- */
- void setText(const std::string& text);
-
- /**
- * Gets the text of the text box.
- *
- * @return The text of the text box.
- * @see setText
- */
- std::string getText() const;
-
- /**
- * Gets a certain row from the text.
- *
- * @param row The number of the row to get from the text.
- * @return A row from the text of the text box.
- * @see setTextRow
- */
- const std::string& getTextRow(const int row) const
- { return mTextRows[row]; }
-
- /**
- * Sets the text of a certain row of the text.
- *
- * @param row The number of the row to set in the text.
- * @param text The text to set in the given row number.
- * @see getTextRow
- */
- void setTextRow(const int row, const std::string& text);
-
- /**
- * Gets the number of rows in the text.
- *
- * @return The number of rows in the text.
- */
- unsigned int getNumberOfRows() const
- { return CAST_S32(mTextRows.size()); }
-
- /**
- * Gets the caret position in the text.
- *
- * @return The caret position in the text.
- * @see setCaretPosition
- */
- unsigned int getCaretPosition() const;
-
- /**
- * Sets the position of the caret in the text.
- *
- * @param position the positon of the caret.
- * @see getCaretPosition
- */
- void setCaretPosition(unsigned int position);
-
- /**
- * Gets the row number where the caret is currently located.
- *
- * @return The row number where the caret is currently located.
- * @see setCaretRow
- */
- unsigned int getCaretRow() const
- { return mCaretRow; }
-
- /**
- * Sets the row where the caret should be currently located.
- *
- * @param The row where the caret should be currently located.
- * @see getCaretRow
- */
- void setCaretRow(const int row);
-
- /**
- * Gets the column where the caret is currently located.
- *
- * @return The column where the caret is currently located.
- * @see setCaretColumn
- */
- unsigned int getCaretColumn() const;
-
- /**
- * Sets the column where the caret should be currently located.
- *
- * @param The column where the caret should be currently located.
- * @see getCaretColumn
- */
- void setCaretColumn(const int column);
-
- /**
- * Sets the row and the column where the caret should be curretly
- * located.
- *
- * @param row The row where the caret should be currently located.
- * @param column The column where the caret should be currently located.
- * @see getCaretRow, getCaretColumn
- */
- void setCaretRowColumn(const int row, const int column);
-
- /**
- * Scrolls the text to the caret if the text box is in a scroll area.
- *
- * @see ScrollArea
- */
- void scrollToCaret();
-
- /**
- * Checks if the text box is editable.
- *
- * @return True it the text box is editable, false otherwise.
- * @see setEditable
- */
- bool isEditable() const
- { return mEditable; }
-
- /**
- * Sets the text box to be editable or not.
- *
- * @param editable True if the text box should be editable, false otherwise.
- */
- void setEditable(const bool editable)
- { mEditable = editable; }
-
- /**
- * Adds a row of text to the end of the text.
- *
- * @param row The row to add.
- */
- void addRow(const std::string &row);
-
- /**
- * Checks if the text box is opaque. An opaque text box will draw
- * it's background and it's text. A non opaque text box only draw it's
- * text making it transparent.
- *
- * @return True if the text box is opaque, false otherwise.
- * @see setOpaque
- */
- bool isOpaque() const noexcept2
- { return mOpaque == Opaque_true; }
-
- /**
- * Sets the text box to be opaque or not. An opaque text box will draw
- * it's background and it's text. A non opaque text box only draw it's
- * text making it transparent.
- *
- * @param opaque True if the text box should be opaque, false otherwise.
- * @see isOpaque
- */
- void setOpaque(const Opaque opaque) noexcept2
- { mOpaque = opaque; }
-
- void fontChanged() override final
- { adjustSize(); }
-
- void mousePressed(MouseEvent& event) override final;
-
- void mouseDragged(MouseEvent& event) override final;
-
- private:
- /**
- * Draws the caret. Overloaded this method if you want to
- * change the style of the caret.
- *
- * @param graphics a Graphics object to draw with.
- * @param x the x position.
- * @param y the y position.
- */
- void drawCaret(Graphics *const graphics,
- const int x,
- const int y) const A_NONNULL(2);
-
- /**
- * Adjusts the text box's size to fit the text.
- */
- void adjustSize();
-
- /**
- * Holds all the rows of the text.
- */
- STD_VECTOR<std::string> mTextRows;
-
- /**
- * Holds the current column of the caret.
- */
- int mCaretColumn;
-
- /**
- * Holds the current row of the caret.
- */
- int mCaretRow;
-
- int mMinWidth;
-
- /**
- * True if the text box is editable, false otherwise.
- */
- bool mEditable;
-
- /**
- * True if the text box is editable, false otherwise.
- */
- Opaque mOpaque;
-};
-
-#endif // GUI_WIDGETS_TEXTBOX_H
diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp
deleted file mode 100644
index e536b5b13..000000000
--- a/src/gui/widgets/textfield.cpp
+++ /dev/null
@@ -1,837 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "gui/widgets/textfield.h"
-
-#include "settings.h"
-
-#ifdef USE_SDL2
-#include "enums/input/keyvalue.h"
-#endif // USE_SDL2
-
-#include "gui/gui.h"
-#include "gui/skin.h"
-#ifdef ANDROID
-#include "gui/windowmanager.h"
-#endif // ANDROID
-
-#include "gui/fonts/font.h"
-
-#include "gui/popups/popupmenu.h"
-
-#include "input/inputmanager.h"
-
-#include "utils/copynpaste.h"
-#include "utils/stringutils.h"
-
-#ifndef USE_SDL2
-#include "utils/timer.h"
-#endif // USE_SDL2
-
-#include "render/graphics.h"
-
-#include "resources/imagerect.h"
-
-#include "resources/image/image.h"
-
-#undef DELETE // Win32 compatibility hack
-
-#include "debug.h"
-
-Skin *TextField::mSkin;
-int TextField::instances = 0;
-float TextField::mAlpha = 1.0;
-ImageRect TextField::skin;
-
-TextField::TextField(const Widget2 *restrict const widget,
- const std::string &restrict text,
- const LoseFocusOnTab loseFocusOnTab,
- ActionListener *restrict const listener,
- const std::string &restrict eventId,
- const bool sendAlwaysEvents) :
- Widget(widget),
- FocusListener(),
- KeyListener(),
- MouseListener(),
- WidgetListener(),
- mText(text),
- mTextChunk(),
- mCaretPosition(0),
- mXScroll(0),
- mCaretColor(&getThemeColor(ThemeColorId::CARET)),
- mMinimum(0),
- mMaximum(0),
- mLastEventPaste(0),
- mPadding(1),
- mNumeric(false),
- mLoseFocusOnTab(loseFocusOnTab),
- mAllowSpecialActions(true),
- mSendAlwaysEvents(sendAlwaysEvents),
- mTextChanged(true)
-{
- mAllowLogic = false;
- setFocusable(true);
- addMouseListener(this);
- addKeyListener(this);
-
- setFrameSize(2);
- mForegroundColor = getThemeColor(ThemeColorId::TEXTFIELD);
- mForegroundColor2 = getThemeColor(ThemeColorId::TEXTFIELD_OUTLINE);
-
- addFocusListener(this);
-
- if (instances == 0)
- {
- if (theme != nullptr)
- {
- mSkin = theme->loadSkinRect(skin, "textfield.xml",
- "textfield_background.xml");
- }
- }
-
- instances++;
-
- if (mSkin != nullptr)
- {
- mPadding = mSkin->getPadding();
- mFrameSize = mSkin->getOption("frameSize", 2);
- }
-
- adjustSize();
- if (!eventId.empty())
- setActionEventId(eventId);
-
- if (listener != nullptr)
- addActionListener(listener);
-}
-
-TextField::~TextField()
-{
- if (mWindow != nullptr)
- mWindow->removeWidgetListener(this);
-
- if (gui != nullptr)
- gui->removeDragged(this);
-
- instances--;
- if (instances == 0)
- {
- if (theme != nullptr)
- {
- theme->unload(mSkin);
- Theme::unloadRect(skin);
- }
- }
- mTextChunk.deleteImage();
-}
-
-void TextField::updateAlpha()
-{
- const float alpha = std::max(settings.guiAlpha,
- theme->getMinimumOpacity());
-
- if (alpha != mAlpha)
- {
- mAlpha = alpha;
- for (int a = 0; a < 9; a++)
- {
- if (skin.grid[a] != nullptr)
- skin.grid[a]->setAlpha(mAlpha);
- }
- }
-}
-
-void TextField::draw(Graphics *const graphics)
-{
- BLOCK_START("TextField::draw")
- updateAlpha();
-
- Font *const font = getFont();
- if (isFocused())
- {
- drawCaret(graphics,
- font->getWidth(mText.substr(0, mCaretPosition)) - mXScroll);
- }
-
- if (mTextChanged)
- {
- mTextChunk.textFont = font;
- mTextChunk.deleteImage();
- mTextChunk.text = mText;
- mTextChunk.color = mForegroundColor;
- mTextChunk.color2 = mForegroundColor2;
- font->generate(mTextChunk);
- mTextChanged = false;
- }
-
- const Image *const image = mTextChunk.img;
- if (image != nullptr)
- graphics->drawImage(image, mPadding - mXScroll, mPadding);
-
- BLOCK_END("TextField::draw")
-}
-
-void TextField::safeDraw(Graphics *const graphics)
-{
- TextField::draw(graphics);
-}
-
-void TextField::drawFrame(Graphics *const graphics)
-{
- BLOCK_START("TextField::drawFrame")
- const int bs = 2 * mFrameSize;
- graphics->drawImageRect(0,
- 0,
- mDimension.width + bs,
- mDimension.height + bs,
- skin);
- BLOCK_END("TextField::drawFrame")
-}
-
-void TextField::safeDrawFrame(Graphics *const graphics)
-{
- BLOCK_START("TextField::drawFrame")
- const int bs = 2 * mFrameSize;
- graphics->drawImageRect(0,
- 0,
- mDimension.width + bs,
- mDimension.height + bs,
- skin);
- BLOCK_END("TextField::drawFrame")
-}
-
-void TextField::setNumeric(const bool numeric)
-{
- mNumeric = numeric;
- if (!numeric)
- return;
-
- const char *const text = mText.c_str();
- for (const char *textPtr = text; *textPtr != 0; ++textPtr)
- {
- if (*textPtr < '0' || *textPtr > '9')
- {
- setText(mText.substr(0, textPtr - text));
- return;
- }
- }
-}
-
-int TextField::getValue() const
-{
- if (!mNumeric)
- return 0;
-
- const int value = atoi(mText.c_str());
- if (value < mMinimum)
- return mMinimum;
-
- if (value > mMaximum)
- return mMaximum;
-
- return value;
-}
-
-void TextField::keyPressed(KeyEvent &event)
-{
- const int val = event.getKey().getValue();
-
-#ifdef USE_SDL2
- if (val == KeyValue::TEXTINPUT)
- {
- std::string str = event.getText();
- mText.insert(mCaretPosition, str);
- mTextChanged = true;
- mCaretPosition += CAST_U32(str.size());
- event.consume();
- fixScroll();
- if (mSendAlwaysEvents)
- distributeActionEvent();
- return;
- }
- bool consumed(false);
-#else // USE_SDL2
-
- if (val >= 32)
- {
- if (mNumeric)
- {
- if ((val >= '0' && val <= '9') ||
- (val == '-' && mCaretPosition == 0u))
- {
- char buf[2];
- buf[0] = CAST_8(val);
- buf[1] = 0;
- mText.insert(mCaretPosition, std::string(buf));
- mTextChanged = true;
- mCaretPosition += 1;
- event.consume();
- fixScroll();
- if (mSendAlwaysEvents)
- distributeActionEvent();
- return;
- }
- }
- else if ((mMaximum == 0) ||
- CAST_S32(mText.size()) < mMaximum)
- {
- int len;
- if (val < 128)
- len = 1; // 0xxxxxxx
- else if (val < 0x800)
- len = 2; // 110xxxxx 10xxxxxx
- else if (val < 0x10000)
- len = 3; // 1110xxxx 10xxxxxx 10xxxxxx
- else
- len = 4; // 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
-
- char buf[4];
- for (int i = 0; i < len; ++ i)
- {
- buf[i] = CAST_8(val >> (6 * (len - i - 1)));
- if (i > 0)
- buf[i] = CAST_8((buf[i] & 63) | 128);
- }
-
- if (len > 1)
- buf[0] |= CAST_8(255U << (8 - len));
-
- mText.insert(mCaretPosition, std::string(buf, buf + len));
- mCaretPosition += len;
- mTextChanged = true;
- event.consume();
- fixScroll();
- if (mSendAlwaysEvents)
- distributeActionEvent();
- return;
- }
- }
-
- /* In UTF-8, 10xxxxxx is only used for inner parts of characters. So skip
- them when processing key presses. */
-
- // unblock past key
- if (val != 22)
- mLastEventPaste = 0;
-
- bool consumed(false);
-#endif // USE_SDL2
-
- const InputActionT action = event.getActionId();
- if (!inputManager.isActionActive(InputAction::GUI_CTRL))
- {
- if (!handleNormalKeys(action, consumed))
- {
- if (consumed)
- event.consume();
- return;
- }
- }
- else
- {
- handleCtrlKeys(action, consumed);
- }
-
- if (mSendAlwaysEvents)
- distributeActionEvent();
-
- if (consumed)
- event.consume();
- fixScroll();
-}
-
-bool TextField::handleNormalKeys(const InputActionT action, bool &consumed)
-{
- PRAGMA45(GCC diagnostic push)
- PRAGMA45(GCC diagnostic ignored "-Wswitch-enum")
- switch (action)
- {
- case InputAction::GUI_LEFT:
- {
- consumed = true;
- while (mCaretPosition > 0)
- {
- --mCaretPosition;
- if ((mText[mCaretPosition] & 192) != 128)
- break;
- }
- break;
- }
-
- case InputAction::GUI_RIGHT:
- {
- consumed = true;
- const unsigned sz = CAST_U32(mText.size());
- while (mCaretPosition < sz)
- {
- ++mCaretPosition;
- if (mCaretPosition == sz ||
- (mText[mCaretPosition] & 192) != 128)
- {
- break;
- }
- }
- break;
- }
-
- case InputAction::GUI_DELETE:
- {
- consumed = true;
- unsigned sz = CAST_U32(mText.size());
- while (mCaretPosition < sz)
- {
- --sz;
- mText.erase(mCaretPosition, 1);
- mTextChanged = true;
- if (mCaretPosition == sz ||
- (mText[mCaretPosition] & 192) != 128)
- {
- break;
- }
- }
- break;
- }
-
- case InputAction::GUI_BACKSPACE:
- consumed = true;
- deleteCharLeft(mText, &mCaretPosition);
- mTextChanged = true;
- break;
-
- case InputAction::GUI_SELECT2:
- distributeActionEvent();
- consumed = true;
- fixScroll();
- return false;
-
- case InputAction::GUI_HOME:
- mCaretPosition = 0;
- consumed = true;
- break;
-
- case InputAction::GUI_END:
- mCaretPosition = CAST_U32(mText.size());
- consumed = true;
- break;
-
- case InputAction::GUI_TAB:
- if (mLoseFocusOnTab == LoseFocusOnTab_true)
- return false;
- consumed = true;
- break;
-
- default:
- break;
- }
- PRAGMA45(GCC diagnostic pop)
- return true;
-}
-
-void TextField::handleCtrlKeys(const InputActionT action, bool &consumed)
-{
- PRAGMA45(GCC diagnostic push)
- PRAGMA45(GCC diagnostic ignored "-Wswitch-enum")
- switch (action)
- {
- case InputAction::GUI_LEFT:
- {
- moveCaretWordBack();
- consumed = true;
- break;
- }
- case InputAction::GUI_RIGHT:
- {
- moveCaretWordForward();
- consumed = true;
- break;
- }
- case InputAction::GUI_B:
- {
- if (mAllowSpecialActions)
- {
- moveCaretBack();
- consumed = true;
- }
- break;
- }
- case InputAction::GUI_F:
- {
- moveCaretForward();
- consumed = true;
- break;
- }
- case InputAction::GUI_D:
- {
- caretDelete();
- consumed = true;
- break;
- }
- case InputAction::GUI_E:
- {
- mCaretPosition = CAST_S32(mText.size());
- consumed = true;
- break;
- }
- case InputAction::GUI_H:
- {
- deleteCharLeft(mText, &mCaretPosition);
- mTextChanged = true;
- consumed = true;
- break;
- }
- case InputAction::GUI_K:
- {
- mText = mText.substr(0, mCaretPosition);
- mTextChanged = true;
- consumed = true;
- break;
- }
- case InputAction::GUI_U:
- {
- caretDeleteToStart();
- consumed = true;
- break;
- }
- case InputAction::GUI_C:
- {
- handleCopy();
- consumed = true;
- break;
- }
- case InputAction::GUI_V:
- {
-#ifdef USE_SDL2
- handlePaste();
-#else // USE_SDL2
-
- // hack to prevent paste key sticking
- if ((mLastEventPaste != 0) && mLastEventPaste > cur_time)
- break;
- handlePaste();
- mLastEventPaste = cur_time + 2;
-#endif // USE_SDL2
-
- consumed = true;
- break;
- }
- case InputAction::GUI_W:
- {
- caretDeleteWord();
- consumed = true;
- break;
- }
- default:
- break;
- }
- PRAGMA45(GCC diagnostic pop)
-}
-
-void TextField::moveCaretBack()
-{
- while (mCaretPosition > 0)
- {
- --mCaretPosition;
- if ((mText[mCaretPosition] & 192) != 128)
- break;
- }
-}
-
-void TextField::moveCaretForward()
-{
- const unsigned sz = CAST_U32(mText.size());
- while (mCaretPosition < sz)
- {
- ++mCaretPosition;
- if (mCaretPosition == sz || (mText[mCaretPosition] & 192) != 128)
- break;
- }
-}
-
-void TextField::caretDelete()
-{
- unsigned sz = CAST_U32(mText.size());
- while (mCaretPosition < sz)
- {
- --sz;
- mText.erase(mCaretPosition, 1);
- if (mCaretPosition == sz || (mText[mCaretPosition] & 192) != 128)
- break;
- }
- mTextChanged = true;
-}
-
-void TextField::handlePaste()
-{
- std::string text = getText();
- size_t caretPos = CAST_SIZE(getCaretPosition());
-
- if (retrieveBuffer(text, caretPos))
- {
- setText(text);
- setCaretPosition(CAST_U32(caretPos));
- }
-}
-
-void TextField::caretDeleteToStart()
-{
- if (mCaretPosition > 0)
- {
- mText = mText.substr(mCaretPosition);
- mCaretPosition = 0;
- }
- mTextChanged = true;
-}
-
-void TextField::moveCaretWordBack()
-{
- const unsigned int oldCaret = mCaretPosition;
- while (mCaretPosition > 0)
- {
- if (!isWordSeparator(mText[mCaretPosition - 1]))
- break;
- mCaretPosition --;
- }
- if (oldCaret != mCaretPosition)
- return;
- while (mCaretPosition > 0)
- {
- if (isWordSeparator(mText[mCaretPosition - 1]))
- break;
- mCaretPosition --;
- }
-}
-
-void TextField::moveCaretWordForward()
-{
- const unsigned sz = CAST_U32(mText.size());
- const unsigned int oldCaret = mCaretPosition;
- while (mCaretPosition < sz)
- {
- if (!isWordSeparator(mText[mCaretPosition]))
- break;
- mCaretPosition ++;
- }
- if (oldCaret != mCaretPosition)
- return;
- while (mCaretPosition < sz)
- {
- if (isWordSeparator(mText[mCaretPosition]))
- break;
- mCaretPosition ++;
- }
-}
-
-void TextField::caretDeleteWord()
-{
- while (mCaretPosition > 0)
- {
- deleteCharLeft(mText, &mCaretPosition);
- if (mCaretPosition > 0 && isWordSeparator(mText[mCaretPosition - 1]))
- break;
- }
- mTextChanged = true;
-}
-
-void TextField::handleCopy() const
-{
- std::string text = getText();
- sendBuffer(text);
-}
-
-void TextField::drawCaret(Graphics* graphics, int x)
-{
- const ClipRect &clipArea = graphics->getTopClip();
-
- graphics->setColor(*mCaretColor);
- graphics->drawLine(x + mPadding, clipArea.height - mPadding,
- x + mPadding, mPadding);
-}
-
-void TextField::adjustSize()
-{
- setWidth(getFont()->getWidth(mText) + 2 * mPadding + 1);
- adjustHeight();
-
- fixScroll();
-}
-
-void TextField::adjustHeight()
-{
- setHeight(getFont()->getHeight() + 2 * mPadding);
-}
-
-void TextField::fixScroll()
-{
- if (isFocused())
- {
- const int caretX = getFont()->getWidth(
- mText.substr(0, mCaretPosition));
-
- const int width = mDimension.width;
- const int pad = 2 * mPadding;
- if (caretX - mXScroll >= width - pad)
- {
- mXScroll = caretX - width + pad;
- }
- else if (caretX - mXScroll <= 0)
- {
- mXScroll = caretX - width / 2;
-
- if (mXScroll < 0)
- mXScroll = 0;
- }
- }
-}
-
-void TextField::setCaretPosition(unsigned int position)
-{
- const unsigned int sz = CAST_U32(mText.size());
- if (position > sz)
- mCaretPosition = CAST_S32(sz);
- else
- mCaretPosition = position;
-
- fixScroll();
-}
-
-void TextField::fontChanged()
-{
- fixScroll();
-}
-
-void TextField::mousePressed(MouseEvent &event)
-{
-#ifdef ANDROID
- if (!WindowManager::isKeyboardVisible())
- inputManager.executeAction(InputAction::SHOW_KEYBOARD);
-#endif // ANDROID
-
- event.consume();
- if (event.getButton() == MouseButton::RIGHT)
- {
-#ifndef DYECMD
- if (popupMenu != nullptr)
- popupMenu->showTextFieldPopup(this);
-#endif // DYECMD
- }
- else if (event.getButton() == MouseButton::LEFT)
- {
- mCaretPosition = getFont()->getStringIndexAt(
- mText, event.getX() + mXScroll);
- fixScroll();
- }
-}
-
-void TextField::focusGained(const Event &event A_UNUSED)
-{
-#ifdef ANDROID
- if (!WindowManager::isKeyboardVisible())
- inputManager.executeAction(InputAction::SHOW_KEYBOARD);
-#endif // ANDROID
-}
-
-void TextField::focusLost(const Event &event A_UNUSED)
-{
-}
-
-void TextField::setText(const std::string& text)
-{
- const unsigned int sz = CAST_U32(text.size());
- if (sz < mCaretPosition)
- mCaretPosition = sz;
- mText = text;
- mTextChanged = true;
-}
-
-void TextField::mouseDragged(MouseEvent& event)
-{
- event.consume();
-}
-
-void TextField::widgetHidden(const Event &event A_UNUSED)
-{
- mTextChanged = true;
- mTextChunk.deleteImage();
-}
-
-void TextField::setParent(Widget *widget)
-{
- if (mWindow != nullptr)
- mWindow->addWidgetListener(this);
- Widget::setParent(widget);
-}
-
-void TextField::setWindow(Widget *const widget)
-{
- if ((widget == nullptr) && (mWindow != nullptr))
- {
- mWindow->removeWidgetListener(this);
- mWindow = nullptr;
- }
- else
- {
- Widget2::setWindow(widget);
- }
-}
diff --git a/src/gui/widgets/textfield.h b/src/gui/widgets/textfield.h
deleted file mode 100644
index 8001008a1..000000000
--- a/src/gui/widgets/textfield.h
+++ /dev/null
@@ -1,293 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GUI_WIDGETS_TEXTFIELD_H
-#define GUI_WIDGETS_TEXTFIELD_H
-
-#include "listeners/focuslistener.h"
-#include "listeners/keylistener.h"
-#include "listeners/mouselistener.h"
-#include "listeners/widgetlistener.h"
-
-#include "enums/simpletypes/losefocusontab.h"
-
-#include "gui/fonts/textchunk.h"
-
-#include "gui/widgets/widget.h"
-
-#include "localconsts.h"
-
-/**
- * A text field.
- *
- * \ingroup GUI
- */
-class TextField notfinal : public Widget,
- public FocusListener,
- public KeyListener,
- public MouseListener,
- public WidgetListener
-{
- public:
- /**
- * Constructor, initializes the text field with the given string.
- */
- explicit TextField(const Widget2 *restrict const widget,
- const std::string &restrict text = "",
- const LoseFocusOnTab loseFocusOnTab =
- LoseFocusOnTab_true,
- ActionListener *restrict
- const listener = nullptr,
- const std::string &restrict eventId = "",
- const bool sendAlwaysEvents = false);
-
- A_DELETE_COPY(TextField)
-
- virtual ~TextField();
-
- /**
- * Draws the text field.
- */
- void draw(Graphics *const graphics) override A_NONNULL(2);
-
- void safeDraw(Graphics *const graphics) override A_NONNULL(2);
-
- /**
- * Update the alpha value to the graphic components.
- */
- void updateAlpha();
-
- /**
- * Draws the background and border.
- */
- void drawFrame(Graphics *const graphics) override final A_NONNULL(2);
-
- void safeDrawFrame(Graphics *const graphics) override final
- A_NONNULL(2);
-
- /**
- * Determine whether the field should be numeric or not
- */
- void setNumeric(const bool numeric);
-
- /**
- * Set the range on the field if it is numeric
- */
- void setRange(const int min,
- const int max)
- {
- mMinimum = min;
- mMaximum = max;
- }
-
- /**
- * Processes one keypress.
- */
- void keyPressed(KeyEvent &event) override;
-
- /**
- * Set the minimum value for a range
- */
- void setMinimum(const int min)
- { mMinimum = min; }
-
- /**
- * Set the maximum value for a range
- */
- void setMaximum(const int max)
- { mMaximum = max; }
-
- /**
- * Return the value for a numeric field
- */
- int getValue() const A_WARN_UNUSED;
-
- void setSendAlwaysEvents(const bool b) noexcept2
- { mSendAlwaysEvents = b; }
-
- void adjustSize();
-
- void adjustHeight();
-
- void setCaretPosition(unsigned int position);
-
- void mousePressed(MouseEvent &event) override final;
-
- void handlePaste();
-
- void handleCopy() const;
-
-#ifdef ANDROID
- void focusGained(const Event &event) override final;
-#else // ANDROID
-
- void focusGained(const Event &event) override final A_CONST;
-#endif // ANDROID
-
- void focusLost(const Event &event) override A_CONST;
-
- void moveCaretBack();
-
- void moveCaretForward();
-
- void moveCaretWordBack();
-
- void moveCaretWordForward();
-
- void caretDelete();
-
- void caretDeleteToStart();
-
- void caretDeleteWord();
-
- void setAllowSpecialActions(const bool b)
- { mAllowSpecialActions = b; }
-
- std::string getTextBeforeCaret() const
- { return mText.substr(0, mCaretPosition); }
-
- /**
- * Sets the text of the text field.
- *
- * @param text The text of the text field.
- * @see getText
- */
- void setText(const std::string& text);
-
- /**
- * Gets the text of the text field.
- *
- * @return The text of the text field.
- * @see setText
- */
- const std::string& getText() const
- { return mText; }
-
- /**
- * Gets the caret position. As there is only one line of text
- * in a text field the position is the caret's x coordinate.
- *
- * @return The caret position.
- * @see setCaretPosition
- */
- unsigned int getCaretPosition() const
- { return mCaretPosition; }
-
- void mouseDragged(MouseEvent& event) override final;
-
- void widgetHidden(const Event &event) override final;
-
- void setParent(Widget *widget) override final;
-
- void setWindow(Widget *const widget) override final;
-
- protected:
- void drawCaret(Graphics* graphics, int x) A_NONNULL(2);
-
- void fixScroll();
-
- void fontChanged() override;
-
- bool handleNormalKeys(const InputActionT action, bool &consumed);
-
- void handleCtrlKeys(const InputActionT action, bool &consumed);
-
- static Skin *mSkin;
-
- /**
- * Holds the text of the text box.
- */
- std::string mText;
-
- TextChunk mTextChunk;
-
- /**
- * Holds the caret position.
- */
- unsigned int mCaretPosition;
-
- /**
- * Holds the amount scrolled in x. If a user types more characters than
- * the text field can display, due to the text field being to small, the
- * text needs to scroll in order to show the last type character.
- */
- int mXScroll;
-
- const Color *mCaretColor;
- static int instances;
- static float mAlpha;
- static ImageRect skin;
- int mMinimum;
- int mMaximum;
- time_t mLastEventPaste;
- int mPadding;
- bool mNumeric;
- LoseFocusOnTab mLoseFocusOnTab;
- bool mAllowSpecialActions;
- bool mSendAlwaysEvents;
- bool mTextChanged;
-};
-
-#endif // GUI_WIDGETS_TEXTFIELD_H
diff --git a/src/gui/widgets/textpreview.cpp b/src/gui/widgets/textpreview.cpp
deleted file mode 100644
index 53f84badc..000000000
--- a/src/gui/widgets/textpreview.cpp
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2006-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 "gui/widgets/textpreview.h"
-
-#include "settings.h"
-
-#include "gui/gui.h"
-#include "gui/skin.h"
-
-#include "gui/fonts/font.h"
-
-#include "render/graphics.h"
-
-#include "debug.h"
-
-int TextPreview::instances = 0;
-float TextPreview::mAlpha = 1.0;
-Skin *TextPreview::mSkin = nullptr;
-
-TextPreview::TextPreview(const Widget2 *const widget,
- const std::string &text) :
- Widget(widget),
- mFont(gui->getFont()),
- mText(text),
- mTextColor(&getThemeColor(ThemeColorId::TEXT)),
- mTextColor2(&getThemeColor(ThemeColorId::TEXT_OUTLINE)),
- mBGColor(&getThemeColor(ThemeColorId::BACKGROUND)),
- mTextBGColor(nullptr),
- mPadding(0),
- mTextAlpha(false),
- mOpaque(Opaque_false),
- mShadow(false),
- mOutline(false)
-{
- mAllowLogic = false;
- if (instances == 0)
- {
- if (theme != nullptr)
- mSkin = theme->load("textpreview.xml", "");
- }
-
- instances++;
-
- if (mSkin != nullptr)
- mPadding = mSkin->getOption("padding", 0);
-
- adjustSize();
-}
-
-TextPreview::~TextPreview()
-{
- if (gui != nullptr)
- gui->removeDragged(this);
-
- instances--;
-
- if (instances == 0)
- {
- if (theme != nullptr)
- theme->unload(mSkin);
- }
-}
-
-void TextPreview::draw(Graphics *const graphics)
-{
- if (mFont == nullptr)
- return;
-
- BLOCK_START("TextPreview::draw")
- if (settings.guiAlpha != mAlpha)
- mAlpha = settings.guiAlpha;
-
- const int intAlpha = CAST_S32(mAlpha * 255.0F);
- const int alpha = mTextAlpha ? intAlpha : 255;
-
- if (mOpaque == Opaque_true)
- {
- graphics->setColor(Color(CAST_S32(mBGColor->r),
- CAST_S32(mBGColor->g),
- CAST_S32(mBGColor->b),
- CAST_S32(mAlpha * 255.0F)));
- graphics->fillRectangle(Rect(0, 0,
- mDimension.width, mDimension.height));
- }
-
- if (mTextBGColor != nullptr)
- {
- const int x = mFont->getWidth(mText) + 1
- + 2 * ((mOutline || mShadow) ? 1 :0);
- const int y = mFont->getHeight() + 1
- + 2 * ((mOutline || mShadow) ? 1 : 0);
- graphics->setColor(Color(CAST_S32(mTextBGColor->r),
- CAST_S32(mTextBGColor->g),
- CAST_S32(mTextBGColor->b),
- intAlpha));
- graphics->fillRectangle(Rect(mPadding, mPadding, x, y));
- }
-
- Color color1(mTextColor->r, mTextColor->g, mTextColor->b, alpha);
-
- if (mOutline && mTextColor != mTextColor2)
- {
- const Color &color2 = getThemeColor(ThemeColorId::OUTLINE, 255);
- mFont->drawString(graphics,
- color1,
- color2,
- mText,
- mPadding + 1, mPadding + 1);
- }
- else
- {
- Color color2(mTextColor2->r, mTextColor2->g, mTextColor2->b, alpha);
- mFont->drawString(graphics,
- color1,
- color2,
- mText,
- mPadding + 1, mPadding + 1);
- }
-
- BLOCK_END("TextPreview::draw")
-}
-
-void TextPreview::safeDraw(Graphics *const graphics)
-{
- TextPreview::draw(graphics);
-}
-
-void TextPreview::adjustSize()
-{
- setHeight(getFont()->getHeight() + 2 * mPadding);
-}
diff --git a/src/gui/widgets/textpreview.h b/src/gui/widgets/textpreview.h
deleted file mode 100644
index 7f4a5e873..000000000
--- a/src/gui/widgets/textpreview.h
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2006-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_TEXTPREVIEW_H
-#define GUI_WIDGETS_TEXTPREVIEW_H
-
-#include "gui/widgets/widget.h"
-
-#include "enums/simpletypes/opaque.h"
-
-#include "localconsts.h"
-
-/**
- * Preview widget for particle colors, etc.
- */
-class TextPreview final : public Widget
-{
- public:
- TextPreview(const Widget2 *const widget,
- const std::string &text);
-
- A_DELETE_COPY(TextPreview)
-
- ~TextPreview();
-
- inline void setTextColor(const Color *color)
- { mTextColor = color; adjustSize(); }
-
- inline void setTextColor2(const Color *color)
- { mTextColor2 = color; adjustSize(); }
-
- /**
- * Sets the text to use the set alpha value.
- *
- * @param alpha whether to use alpha values for the text or not
- */
- inline void useTextAlpha(const bool alpha)
- { mTextAlpha = alpha; }
-
- /**
- * Sets the color the text background is drawn in. This is only the
- * rectangle directly behind the text, not to full widget.
- *
- * @param color the color to set
- */
- inline void setTextBGColor(const Color *color)
- { mTextBGColor = color; }
-
- /**
- * Sets the background color of the widget.
- *
- * @param color the color to set
- */
- inline void setBGColor(const Color *color)
- { mBGColor = color; }
-
- /**
- * Sets the font to render the text in.
- *
- * @param font the font to use.
- */
- inline void setFont(Font *const font)
- { mFont = font; }
-
- /**
- * Sets whether to use a shadow while rendering.
- *
- * @param shadow true, if a shadow is wanted, false else
- */
- inline void setShadow(const bool shadow)
- { mShadow = shadow; }
-
- /**
- * Sets whether to use an outline while rendering.
- *
- * @param outline true, if an outline is wanted, false else
- */
- inline void setOutline(const bool outline)
- { mOutline = outline; }
-
- /**
- * Widget's draw method. Does the actual job.
- *
- * @param graphics graphics to draw into
- */
- void draw(Graphics *const graphics) override final A_NONNULL(2);
-
- void safeDraw(Graphics *const graphics) override final A_NONNULL(2);
-
- /**
- * Set opacity for this widget (whether or not to show the background
- * color)
- *
- * @param opaque Whether the widget should be opaque or not
- */
- void setOpaque(const Opaque opaque) noexcept2
- { mOpaque = opaque; }
-
- /**
- * Gets opacity for this widget (whether or not the background color
- * is shown below the widget)
- */
- bool isOpaque() const noexcept2 A_WARN_UNUSED
- { return mOpaque == Opaque_true; }
-
- void adjustSize();
-
- private:
- Font *mFont;
- std::string mText;
- const Color *mTextColor;
- const Color *mTextColor2;
- const Color *mBGColor;
- const Color *mTextBGColor;
- int mPadding;
- static int instances;
- static float mAlpha;
- static Skin *mSkin;
- bool mTextAlpha;
- Opaque mOpaque;
- bool mShadow;
- bool mOutline;
-};
-
-#endif // GUI_WIDGETS_TEXTPREVIEW_H
diff --git a/src/gui/widgets/vertcontainer.cpp b/src/gui/widgets/vertcontainer.cpp
deleted file mode 100644
index 53e082501..000000000
--- a/src/gui/widgets/vertcontainer.cpp
+++ /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/>.
- */
-
-#include "gui/widgets/vertcontainer.h"
-
-#include "utils/foreach.h"
-
-#include "debug.h"
-
-VertContainer::VertContainer(const Widget2 *const widget,
- const int verticalItemSize,
- const bool resizable,
- const int leftSpacing) :
- Container(widget),
- WidgetListener(),
- mResizableWidgets(),
- mVerticalItemSize(verticalItemSize),
- mCount(0),
- mNextY(0),
- mLeftSpacing(leftSpacing),
- mVerticalSpacing(0),
- mResizable(resizable)
-{
- addWidgetListener(this);
-}
-
-void VertContainer::add1(Widget *const widget, const int spacing)
-{
- add2(widget, mResizable, spacing);
-}
-
-void VertContainer::add2(Widget *const widget, const bool resizable,
- const int spacing)
-{
- if (widget == nullptr)
- return;
-
- Container::add(widget);
- widget->setPosition(mLeftSpacing, mNextY);
- if (resizable)
- {
- widget->setSize(mDimension.width - mLeftSpacing,
- mVerticalItemSize * 5);
- mResizableWidgets.push_back(widget);
- }
- else if (widget->getHeight() > mVerticalItemSize)
- {
- widget->setSize(widget->getWidth(), mVerticalItemSize);
- }
-
- if (spacing == -1)
- mNextY += mVerticalItemSize + (mVerticalSpacing * 2);
- else
- mNextY += mVerticalItemSize + (spacing * 2);
- setHeight(mNextY);
-}
-
-void VertContainer::clear()
-{
- Container::clear();
-
- mCount = 0;
- mNextY = 0;
- mResizableWidgets.clear();
-}
-
-void VertContainer::widgetResized(const Event &event A_UNUSED)
-{
- FOR_EACH (STD_VECTOR<Widget*>::const_iterator, it, mResizableWidgets)
- (*it)->setWidth(getWidth());
-}
diff --git a/src/gui/widgets/vertcontainer.h b/src/gui/widgets/vertcontainer.h
deleted file mode 100644
index c0dd118cf..000000000
--- a/src/gui/widgets/vertcontainer.h
+++ /dev/null
@@ -1,66 +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 GUI_WIDGETS_VERTCONTAINER_H
-#define GUI_WIDGETS_VERTCONTAINER_H
-
-#include "gui/widgets/container.h"
-
-#include "listeners/widgetlistener.h"
-
-#include "localconsts.h"
-
-/**
- * A widget container.
- *
- * This container places it's contents veritcally.
- */
-class VertContainer final : public Container,
- public WidgetListener
-{
- public:
- VertContainer(const Widget2 *const widget,
- const int verticalItemSize,
- const bool resizable = true,
- const int leftSpacing = 0);
-
- A_DELETE_COPY(VertContainer)
-
- void add2(Widget *const widget, const bool resizable,
- const int spacing = -1);
-
- void add1(Widget *const widget, const int spacing = -1);
-
- void clear() override final;
-
- void widgetResized(const Event &event) override final;
-
- private:
- STD_VECTOR<Widget*> mResizableWidgets;
- int mVerticalItemSize;
- int mCount;
- int mNextY;
- int mLeftSpacing;
- int mVerticalSpacing;
- bool mResizable;
-};
-
-#endif // GUI_WIDGETS_VERTCONTAINER_H
diff --git a/src/gui/widgets/virtshortcutcontainer.cpp b/src/gui/widgets/virtshortcutcontainer.cpp
deleted file mode 100644
index 6b7642a3d..000000000
--- a/src/gui/widgets/virtshortcutcontainer.cpp
+++ /dev/null
@@ -1,383 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 Andrei Karas
- * 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 "gui/widgets/virtshortcutcontainer.h"
-
-#include "dragdrop.h"
-#include "settings.h"
-
-#include "being/playerinfo.h"
-
-#include "gui/viewport.h"
-
-#include "gui/fonts/font.h"
-
-#include "gui/shortcut/shortcutbase.h"
-
-#include "gui/popups/itempopup.h"
-#include "gui/popups/popupmenu.h"
-
-#include "gui/windows/inventorywindow.h"
-
-#include "utils/stringutils.h"
-
-#include "debug.h"
-
-VirtShortcutContainer::VirtShortcutContainer(Widget2 *const widget,
- ShortcutBase *const shortcut) :
- ShortcutContainer(widget),
- mItemClicked(false),
- mEquipedColor(getThemeColor(ThemeColorId::ITEM_EQUIPPED)),
- mEquipedColor2(getThemeColor(ThemeColorId::ITEM_EQUIPPED_OUTLINE)),
- mUnEquipedColor(getThemeColor(ThemeColorId::ITEM_NOT_EQUIPPED)),
- mUnEquipedColor2(getThemeColor(ThemeColorId::ITEM_NOT_EQUIPPED_OUTLINE)),
- mShortcut(shortcut)
-{
- if (mShortcut != nullptr)
- mMaxItems = mShortcut->getItemCount();
- else
- mMaxItems = 0;
-}
-
-VirtShortcutContainer::~VirtShortcutContainer()
-{
-}
-
-void VirtShortcutContainer::setWidget2(const Widget2 *const widget)
-{
- Widget2::setWidget2(widget);
- mEquipedColor = getThemeColor(ThemeColorId::ITEM_EQUIPPED);
- mEquipedColor2 = getThemeColor(ThemeColorId::ITEM_EQUIPPED_OUTLINE);
- mUnEquipedColor = getThemeColor(ThemeColorId::ITEM_NOT_EQUIPPED);
- mUnEquipedColor2 = getThemeColor(ThemeColorId::ITEM_NOT_EQUIPPED_OUTLINE);
-}
-
-void VirtShortcutContainer::draw(Graphics *const graphics)
-{
- if (mShortcut == nullptr)
- return;
-
- BLOCK_START("VirtShortcutContainer::draw")
- if (settings.guiAlpha != mAlpha)
- {
- mAlpha = settings.guiAlpha;
- if (mBackgroundImg != nullptr)
- mBackgroundImg->setAlpha(mAlpha);
- }
-
- drawBackground(graphics);
-
- const Inventory *const inv = PlayerInfo::getInventory();
- if (inv == nullptr)
- {
- BLOCK_END("VirtShortcutContainer::draw")
- return;
- }
-
- Font *const font = getFont();
-
- for (unsigned i = 0; i < mMaxItems; i++)
- {
- const int itemX = (i % mGridWidth) * mBoxWidth;
- const int itemY = (i / mGridWidth) * mBoxHeight;
-
- if (mShortcut->getItem(i) < 0)
- continue;
-
- const Item *const item = inv->findItem(mShortcut->getItem(i),
- mShortcut->getItemColor(i));
-
- if (item != nullptr)
- {
- // Draw item icon.
- Image *const image = item->getImage();
-
- if (image != nullptr)
- {
- std::string caption;
- if (item->getQuantity() > 1)
- caption = toString(item->getQuantity());
- else if (item->isEquipped() == Equipped_true)
- caption = "Eq.";
-
- image->setAlpha(1.0F);
- graphics->drawImage(image, itemX, itemY);
- if (item->isEquipped() == Equipped_true)
- {
- font->drawString(graphics,
- mEquipedColor,
- mEquipedColor2,
- caption,
- itemX + (mBoxWidth - font->getWidth(caption)) / 2,
- itemY + mBoxHeight - 14);
- }
- else
- {
- font->drawString(graphics,
- mUnEquipedColor,
- mUnEquipedColor2,
- caption,
- itemX + (mBoxWidth - font->getWidth(caption)) / 2,
- itemY + mBoxHeight - 14);
- }
- }
- }
- }
- BLOCK_END("VirtShortcutContainer::draw")
-}
-
-void VirtShortcutContainer::safeDraw(Graphics *const graphics)
-{
- if (mShortcut == nullptr)
- return;
-
- BLOCK_START("VirtShortcutContainer::safeDraw")
- if (settings.guiAlpha != mAlpha)
- {
- mAlpha = settings.guiAlpha;
- if (mBackgroundImg != nullptr)
- mBackgroundImg->setAlpha(mAlpha);
- }
-
- safeDrawBackground(graphics);
-
- const Inventory *const inv = PlayerInfo::getInventory();
- if (inv == nullptr)
- {
- BLOCK_END("VirtShortcutContainer::safeDraw")
- return;
- }
-
- Font *const font = getFont();
-
- for (unsigned i = 0; i < mMaxItems; i++)
- {
- const int itemX = (i % mGridWidth) * mBoxWidth;
- const int itemY = (i / mGridWidth) * mBoxHeight;
-
- if (mShortcut->getItem(i) < 0)
- continue;
-
- const Item *const item = inv->findItem(mShortcut->getItem(i),
- mShortcut->getItemColor(i));
-
- if (item != nullptr)
- {
- // Draw item icon.
- Image *const image = item->getImage();
-
- if (image != nullptr)
- {
- std::string caption;
- if (item->getQuantity() > 1)
- caption = toString(item->getQuantity());
- else if (item->isEquipped() == Equipped_true)
- caption = "Eq.";
-
- image->setAlpha(1.0F);
- graphics->drawImage(image, itemX, itemY);
- if (item->isEquipped() == Equipped_true)
- {
- font->drawString(graphics,
- mEquipedColor,
- mEquipedColor2,
- caption,
- itemX + (mBoxWidth - font->getWidth(caption)) / 2,
- itemY + mBoxHeight - 14);
- }
- else
- {
- font->drawString(graphics,
- mUnEquipedColor,
- mUnEquipedColor2,
- caption,
- itemX + (mBoxWidth - font->getWidth(caption)) / 2,
- itemY + mBoxHeight - 14);
- }
- }
- }
- }
- BLOCK_END("VirtShortcutContainer::safeDraw")
-}
-
-void VirtShortcutContainer::mouseDragged(MouseEvent &event)
-{
- if (mShortcut == nullptr)
- return;
-
- if (event.getButton() == MouseButton::LEFT)
- {
- if (dragDrop.isEmpty() && mItemClicked)
- {
- const int index = getIndexFromGrid(event.getX(), event.getY());
-
- if (index == -1)
- return;
-
- const int itemId = mShortcut->getItem(index);
- const ItemColor itemColor = mShortcut->getItemColor(index);
-
- if (itemId < 0)
- return;
-
- const Inventory *const inv = PlayerInfo::getInventory();
- if (inv == nullptr)
- return;
-
- Item *const item = inv->findItem(itemId, itemColor);
-
- if (item != nullptr)
- {
- dragDrop.dragItem(item, DragDropSource::Drop);
- mShortcut->removeItem(index);
- }
- else
- {
- dragDrop.clear();
- }
- }
- }
-}
-
-void VirtShortcutContainer::mousePressed(MouseEvent &event)
-{
- if ((mShortcut == nullptr) || (inventoryWindow == nullptr))
- return;
-
- const int index = getIndexFromGrid(event.getX(), event.getY());
-
- if (index == -1)
- return;
-
- event.consume();
-
- const MouseButtonT eventButton = event.getButton();
- if (eventButton == MouseButton::LEFT)
- {
- if (mShortcut->getItem(index) > 0)
- {
- mItemClicked = true;
- }
- else
- {
- if (dragDrop.isSelected())
- {
- mShortcut->setItems(index, dragDrop.getSelected(),
- dragDrop.getSelectedColor());
- dragDrop.deselect();
- }
- }
- }
- else if (eventButton == MouseButton::RIGHT)
- {
- const Inventory *const inv = PlayerInfo::getInventory();
- if (inv == nullptr)
- return;
-
- Item *const item = inv->findItem(mShortcut->getItem(index),
- mShortcut->getItemColor(index));
-
- if (popupMenu != nullptr)
- {
- popupMenu->showDropPopup(viewport->mMouseX,
- viewport->mMouseY,
- item);
- }
- }
-}
-
-void VirtShortcutContainer::mouseReleased(MouseEvent &event)
-{
- if (mShortcut == nullptr)
- return;
-
- if (event.getButton() == MouseButton::LEFT)
- {
- if (mShortcut->isItemSelected())
- mShortcut->setItemSelected(-1);
-
- const int index = getIndexFromGrid(event.getX(), event.getY());
- if (index == -1)
- {
- dragDrop.clear();
- return;
- }
- if (!dragDrop.isEmpty())
- {
- if (dragDrop.isSourceItemContainer())
- {
- mShortcut->setItems(index, dragDrop.getItem(),
- dragDrop.getItemColor());
- dragDrop.clear();
- dragDrop.deselect();
- }
- }
-
- mItemClicked = false;
- }
-}
-
-// Show ItemTooltip
-void VirtShortcutContainer::mouseMoved(MouseEvent &event)
-{
- if (mShortcut == nullptr)
- return;
-
- const int index = getIndexFromGrid(event.getX(), event.getY());
-
- if (index == -1)
- return;
-
- const int itemId = mShortcut->getItem(index);
- const ItemColor itemColor = mShortcut->getItemColor(index);
-
- if (itemId < 0)
- return;
-
- const Inventory *const inv = PlayerInfo::getInventory();
- if (inv == nullptr)
- return;
-
- const Item *const item = inv->findItem(itemId, itemColor);
-
- if ((item != nullptr) && (viewport != nullptr))
- {
- itemPopup->setItem(item, false);
- itemPopup->position(viewport->mMouseX, viewport->mMouseY);
- }
- else
- {
- itemPopup->setVisible(Visible_false);
- }
-}
-
-void VirtShortcutContainer::mouseExited(MouseEvent &event A_UNUSED)
-{
- if (itemPopup != nullptr)
- itemPopup->setVisible(Visible_false);
-}
-
-void VirtShortcutContainer::widgetHidden(const Event &event A_UNUSED)
-{
- if (itemPopup != nullptr)
- itemPopup->setVisible(Visible_false);
-}
diff --git a/src/gui/widgets/virtshortcutcontainer.h b/src/gui/widgets/virtshortcutcontainer.h
deleted file mode 100644
index 989a6c8d7..000000000
--- a/src/gui/widgets/virtshortcutcontainer.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 Andrei Karas
- * 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_VIRTSHORTCUTCONTAINER_H
-#define GUI_WIDGETS_VIRTSHORTCUTCONTAINER_H
-
-#include "gui/widgets/shortcutcontainer.h"
-
-class ShortcutBase;
-
-/**
- * An item shortcut container. Used to quickly use items.
- *
- * \ingroup GUI
- */
-class VirtShortcutContainer final : public ShortcutContainer
-{
- public:
- /**
- * Constructor. Initializes the graphic.
- */
- VirtShortcutContainer(Widget2 *const widget,
- ShortcutBase *const shortcut);
-
- A_DELETE_COPY(VirtShortcutContainer)
-
- /**
- * Destructor.
- */
- ~VirtShortcutContainer();
-
- /**
- * Draws the items.
- */
- void draw(Graphics *const graphics) override final A_NONNULL(2);
-
- void safeDraw(Graphics *const graphics) override final A_NONNULL(2);
-
- /**
- * Handles mouse when dragged.
- */
- void mouseDragged(MouseEvent &event) override final;
-
- /**
- * Handles mouse when pressed.
- */
- void mousePressed(MouseEvent &event) override final;
-
- /**
- * Handles mouse release.
- */
- void mouseReleased(MouseEvent &event) override final;
-
- void widgetHidden(const Event &event) override final;
-
- void mouseExited(MouseEvent &event) override final;
-
- void mouseMoved(MouseEvent &event) override final;
-
- void setWidget2(const Widget2 *const widget) override final;
-
- private:
- bool mItemClicked;
-
- Color mEquipedColor;
- Color mEquipedColor2;
- Color mUnEquipedColor;
- Color mUnEquipedColor2;
-
- ShortcutBase *mShortcut;
-};
-
-#endif // GUI_WIDGETS_VIRTSHORTCUTCONTAINER_H
diff --git a/src/gui/widgets/widget.cpp b/src/gui/widgets/widget.cpp
deleted file mode 100644
index 47bca1fb3..000000000
--- a/src/gui/widgets/widget.cpp
+++ /dev/null
@@ -1,526 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * For comments regarding functions please see the header file.
- */
-
-#include "gui/widgets/widget.h"
-
-#include "gui/focushandler.h"
-
-#include "listeners/actionlistener.h"
-#include "listeners/widgetdeathlistener.h"
-#include "listeners/widgetlistener.h"
-
-#include "utils/foreach.h"
-
-#include "debug.h"
-
-Font* Widget::mGlobalFont = nullptr;
-std::list<Widget*> Widget::mAllWidgets;
-std::set<Widget*> Widget::mAllWidgetsSet;
-
-Widget::Widget(const Widget2 *const widget) :
- Widget2(widget),
- mVisible(Visible_true),
- mMouseListeners(),
- mKeyListeners(),
- mActionListeners(),
- mDeathListeners(),
- mFocusListeners(),
- mWidgetListeners(),
- mForegroundColor(0x000000),
- mBackgroundColor(0xffffff),
- mBaseColor(0x808090),
- mDimension(),
- mActionEventId(),
- mId(),
- mFocusHandler(nullptr),
- mInternalFocusHandler(nullptr),
- mParent(nullptr),
- mCurrentFont(nullptr),
- mFrameSize(0),
- mFocusable(false),
- mTabIn(true),
- mTabOut(true),
- mEnabled(true),
- mAllowLogic(true),
- mMouseConsume(true),
- mRedraw(true),
- mSelectable(true)
-{
- mAllWidgets.push_back(this);
- mAllWidgetsSet.insert(this);
-}
-
-Widget::~Widget()
-{
- FOR_EACH (WidgetDeathListenerIterator, iter, mDeathListeners)
- {
- Event event(this);
- (*iter)->death(event);
- }
-
- // +++ call to virtual member
- setFocusHandler(nullptr);
-
- mAllWidgets.remove(this);
- mAllWidgetsSet.erase(this);
-}
-
-void Widget::setWidth(const int width)
-{
- Rect newDimension = mDimension;
- newDimension.width = width;
- setDimension(newDimension);
-}
-
-void Widget::setHeight(const int height)
-{
- Rect newDimension = mDimension;
- newDimension.height = height;
- setDimension(newDimension);
-}
-
-void Widget::setX(const int x)
-{
- Rect newDimension = mDimension;
- newDimension.x = x;
- setDimension(newDimension);
-}
-
-void Widget::setY(const int y)
-{
- Rect newDimension = mDimension;
- newDimension.y = y;
- setDimension(newDimension);
-}
-
-void Widget::setPosition(const int x, const int y)
-{
- Rect newDimension = mDimension;
- newDimension.x = x;
- newDimension.y = y;
- setDimension(newDimension);
-}
-
-void Widget::setDimension(const Rect& dimension)
-{
- const Rect oldDimension = mDimension;
- mDimension = dimension;
-
- if (mDimension.width != oldDimension.width
- || mDimension.height != oldDimension.height)
- {
- distributeResizedEvent();
- }
-
- if (mDimension.x != oldDimension.x || mDimension.y != oldDimension.y)
- distributeMovedEvent();
-}
-
-bool Widget::isFocused() const
-{
- if (mFocusHandler == nullptr)
- return false;
-
- return mFocusHandler->isFocused(this);
-}
-
-void Widget::setFocusable(const bool focusable)
-{
- if (!focusable && isFocused() && (mFocusHandler != nullptr))
- mFocusHandler->focusNone();
- mFocusable = focusable;
-}
-
-bool Widget::isFocusable() const
-{
- return mFocusable && isVisible() && isEnabled();
-}
-
-void Widget::requestFocus()
-{
- if (mFocusHandler == nullptr)
- return;
-
- if (isFocusable())
- mFocusHandler->requestFocus(this);
-}
-
-void Widget::requestMoveToTop()
-{
- if (mParent != nullptr)
- mParent->moveToTop(this);
-}
-
-void Widget::requestMoveToBottom()
-{
- if (mParent != nullptr)
- mParent->moveToBottom(this);
-}
-
-void Widget::setVisible(Visible visible)
-{
- if (visible == Visible_false && isFocused() && (mFocusHandler != nullptr))
- mFocusHandler->focusNone();
-
- if (visible == Visible_true)
- distributeShownEvent();
- else
- distributeHiddenEvent();
-
- mVisible = visible;
-}
-
-void Widget::setFocusHandler(FocusHandler *const focusHandler)
-{
- if (mFocusHandler != nullptr)
- {
- releaseModalFocus();
- mFocusHandler->remove(this);
- }
-
- if (focusHandler != nullptr)
- focusHandler->add(this);
-
- mFocusHandler = focusHandler;
-}
-
-void Widget::addActionListener(ActionListener *const actionListener)
-{
- mActionListeners.push_back(actionListener);
-}
-
-void Widget::removeActionListener(ActionListener *const actionListener)
-{
- mActionListeners.remove(actionListener);
-}
-
-void Widget::addDeathListener(WidgetDeathListener *const deathListener)
-{
- mDeathListeners.push_back(deathListener);
-}
-
-void Widget::removeDeathListener(WidgetDeathListener *const deathListener)
-{
- mDeathListeners.remove(deathListener);
-}
-
-void Widget::addKeyListener(KeyListener *const keyListener)
-{
- mKeyListeners.push_back(keyListener);
-}
-
-void Widget::removeKeyListener(KeyListener *const keyListener)
-{
- mKeyListeners.remove(keyListener);
-}
-
-void Widget::addFocusListener(FocusListener *const focusListener)
-{
- mFocusListeners.push_back(focusListener);
-}
-
-void Widget::removeFocusListener(FocusListener *const focusListener)
-{
- mFocusListeners.remove(focusListener);
-}
-
-void Widget::addMouseListener(MouseListener *const mouseListener)
-{
- mMouseListeners.push_back(mouseListener);
-}
-
-void Widget::removeMouseListener(MouseListener *const mouseListener)
-{
- mMouseListeners.remove(mouseListener);
-}
-
-void Widget::addWidgetListener(WidgetListener *const widgetListener)
-{
- mWidgetListeners.push_back(widgetListener);
-}
-
-void Widget::removeWidgetListener(WidgetListener *const widgetListener)
-{
- mWidgetListeners.remove(widgetListener);
-}
-
-void Widget::getAbsolutePosition(int& x, int& y) const
-{
- if (mParent == nullptr)
- {
- x = mDimension.x;
- y = mDimension.y;
- return;
- }
-
- int parentX;
- int parentY;
-
- mParent->getAbsolutePosition(parentX, parentY);
-
- const Rect &rect = mParent->getChildrenArea();
- x = parentX + mDimension.x + rect.x;
- y = parentY + mDimension.y + rect.y;
-}
-
-Font* Widget::getFont() const
-{
- if (mCurrentFont == nullptr)
- return mGlobalFont;
- return mCurrentFont;
-}
-
-void Widget::setGlobalFont(Font *const font)
-{
- mGlobalFont = font;
-
- FOR_EACH (std::list<Widget*>::const_iterator, iter, mAllWidgets)
- {
- if ((*iter)->mCurrentFont == nullptr)
- (*iter)->fontChanged();
- }
-}
-
-void Widget::setFont(Font *const font)
-{
- mCurrentFont = font;
- fontChanged();
-}
-
-void Widget::distributeWindowResizeEvent()
-{
- FOR_EACH (std::list<Widget*>::const_iterator, iter, mAllWidgets)
- (*iter)->windowResized();
-}
-
-bool Widget::widgetExists(const Widget *const widget)
-{
- return mAllWidgetsSet.find(const_cast<Widget*>(widget))
- != mAllWidgetsSet.end();
-}
-
-void Widget::setSize(const int width, const int height)
-{
- Rect newDimension = mDimension;
- newDimension.width = width;
- newDimension.height = height;
- setDimension(newDimension);
-}
-
-bool Widget::isEnabled() const
-{
- return mEnabled && isVisible();
-}
-
-void Widget::requestModalFocus()
-{
- if (mFocusHandler == nullptr)
- return;
- mFocusHandler->requestModalFocus(this);
-}
-
-void Widget::requestModalMouseInputFocus()
-{
- if (mFocusHandler == nullptr)
- return;
- mFocusHandler->requestModalMouseInputFocus(this);
-}
-
-void Widget::releaseModalFocus()
-{
- if (mFocusHandler == nullptr)
- return;
- mFocusHandler->releaseModalFocus(this);
-}
-
-void Widget::releaseModalMouseInputFocus()
-{
- if (mFocusHandler == nullptr)
- return;
- mFocusHandler->releaseModalMouseInputFocus(this);
-}
-
-bool Widget::isModalFocused() const
-{
- if (mFocusHandler == nullptr)
- return false;
-
- if (mParent != nullptr)
- {
- return (mFocusHandler->getModalFocused() == this)
- || mParent->isModalFocused();
- }
-
- return mFocusHandler->getModalFocused() == this;
-}
-
-bool Widget::isModalMouseInputFocused() const
-{
- if (mFocusHandler == nullptr)
- return false;
-
- if (mParent != nullptr)
- {
- return (mFocusHandler->getModalMouseInputFocused() == this)
- || mParent->isModalMouseInputFocused();
- }
-
- return mFocusHandler->getModalMouseInputFocused() == this;
-}
-
-const std::list<MouseListener*> &Widget::getMouseListeners() const
-{
- return mMouseListeners;
-}
-
-const std::list<KeyListener*> &Widget::getKeyListeners() const
-{
- return mKeyListeners;
-}
-
-const std::list<FocusListener*> &Widget::getFocusListeners() const
-{
- return mFocusListeners;
-}
-
-Rect Widget::getChildrenArea()
-{
- return Rect(0, 0, 0, 0);
-}
-
-FocusHandler* Widget::getInternalFocusHandler()
-{
- return mInternalFocusHandler;
-}
-
-void Widget::setInternalFocusHandler(FocusHandler *const focusHandler)
-{
- mInternalFocusHandler = focusHandler;
-}
-
-void Widget::distributeResizedEvent()
-{
- FOR_EACH (WidgetListenerIterator, iter, mWidgetListeners)
- {
- Event event(this);
- (*iter)->widgetResized(event);
- }
-}
-
-void Widget::distributeMovedEvent()
-{
- FOR_EACH (WidgetListenerIterator, iter, mWidgetListeners)
- {
- Event event(this);
- (*iter)->widgetMoved(event);
- }
-}
-
-void Widget::distributeHiddenEvent()
-{
- FOR_EACH (WidgetListenerIterator, iter, mWidgetListeners)
- {
- Event event(this);
- (*iter)->widgetHidden(event);
- }
-}
-
-void Widget::distributeActionEvent()
-{
- FOR_EACH (ActionListenerIterator, iter, mActionListeners)
- {
- ActionEvent actionEvent(this, mActionEventId);
- (*iter)->action(actionEvent);
- }
-}
-
-void Widget::distributeShownEvent()
-{
- FOR_EACH (WidgetListenerIterator, iter, mWidgetListeners)
- {
- Event event(this);
- (*iter)->widgetShown(event);
- }
-}
-
-void Widget::showPart(const Rect &rectangle)
-{
- if (mParent != nullptr)
- mParent->showWidgetPart(this, rectangle);
-}
-
-void Widget::windowResized()
-{
- mRedraw = true;
-}
-
-Widget *Widget::callPostInit(Widget *const widget)
-{
- if (widget != nullptr)
- widget->postInit();
- return widget;
-}
diff --git a/src/gui/widgets/widget.h b/src/gui/widgets/widget.h
deleted file mode 100644
index bb41054d2..000000000
--- a/src/gui/widgets/widget.h
+++ /dev/null
@@ -1,1181 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GUI_WIDGETS_WIDGET_H
-#define GUI_WIDGETS_WIDGET_H
-
-#include "enums/simpletypes/visible.h"
-
-#include "gui/rect.h"
-
-#include "gui/widgets/widget2.h"
-
-#include <list>
-
-#include "localconsts.h"
-
-class ActionListener;
-class WidgetDeathListener;
-class FocusHandler;
-class FocusListener;
-class Font;
-class Graphics;
-class KeyListener;
-class MouseListener;
-class WidgetListener;
-
-/**
- * Abstract class for widgets of Guichan. It contains basic functions
- * every widget should have.
- *
- * NOTE: Functions begining with underscore "_" should not
- * be overloaded unless you know what you are doing
- *
- * @author Olof Naessén
- * @author Per Larsson.
- */
-class Widget notfinal : public Widget2
-{
- public:
- friend class BasicContainer;
-
- /**
- * Constructor. Resets member variables. Noteable, a widget is not
- * focusable as default, therefore, widgets that are supposed to be
- * focusable should overide this default in their own constructor.
- */
- explicit Widget(const Widget2 *const widget);
-
- A_DELETE_COPY(Widget)
-
- /**
- * Default destructor.
- */
- virtual ~Widget();
-
- /**
- * Draws the widget. It is called by the parent widget when it is time
- * for the widget to draw itself. The graphics object is set up so
- * that all drawing is relative to the widget, i.e coordinate (0,0) is
- * the top left corner of the widget. It is not possible to draw
- * outside of a widget's dimension.
- *
- * @param graphics aA graphics object to draw with.
- */
- virtual void draw(Graphics *const graphics) A_NONNULL(2) = 0;
-
- virtual void safeDraw(Graphics *const graphics) A_NONNULL(2) = 0;
-
- /**
- * Called when a widget is given a chance to draw a frame around itself.
- * The frame is not considered a part of the widget, it only allows a frame
- * to be drawn around the widget, thus a frame will never be included when
- * calculating if a widget should receive events from user input. Also
- * a widget's frame will never be included when calculating a widget's
- * position.
- *
- * The size of the frame is calculated using the widget's frame size.
- * If a widget has a frame size of 10 pixels than the area the drawFrame
- * function can draw to will be the size of the widget with an additional
- * extension of 10 pixels in each direction.
- *
- * An example when drawFrame is a useful function is if a widget needs
- * a glow around itself.
- *
- * @param graphics A graphics object to draw with.
- * @see setFrameSize, getFrameSize
- */
- virtual void drawFrame(Graphics* graphics A_UNUSED) A_NONNULL(2)
- { }
-
- virtual void safeDrawFrame(Graphics* graphics A_UNUSED) A_NONNULL(2)
- { }
-
- /**
- * Sets the size of the widget's frame. The frame is not considered a part of
- * the widget, it only allows a frame to be drawn around the widget, thus a frame
- * will never be included when calculating if a widget should receive events
- * from user input. Also a widget's frame will never be included when calculating
- * a widget's position.
- *
- * A frame size of 0 means that the widget has no frame. The default frame size
- * is 0.
- *
- * @param frameSize The size of the widget's frame.
- * @see getFrameSize, drawFrame
- */
- void setFrameSize(const unsigned int frameSize) noexcept2
- { mFrameSize = frameSize; }
-
- /**
- * Gets the size of the widget's frame. The frame is not considered a part of
- * the widget, it only allows a frame to be drawn around the widget, thus a frame
- * will never be included when calculating if a widget should receive events
- * from user input. Also a widget's frame will never be included when calculating
- * a widget's position.
- *
- * A frame size of 0 means that the widget has no frame. The default frame size
- * is 0.
- *
- * @return The size of the widget's frame.
- * @see setFrameSize, drawFrame
- */
- unsigned int getFrameSize() const noexcept2 A_WARN_UNUSED
- { return mFrameSize; }
-
- /**
- * Called for all widgets in the gui each time Gui::logic is called.
- * You can do logic stuff here like playing an animation.
- *
- * @see Gui::logic
- */
- virtual void logic()
- { }
-
- /**
- * Gets the widget's parent container.
- *
- * @return The widget's parent container. NULL if the widget
- * has no parent.
- */
- Widget* getParent() const noexcept2 A_WARN_UNUSED
- { return mParent; }
-
- /**
- * Sets the width of the widget.
- *
- * @param width The width of the widget.
- * @see getWidth, setHeight, getHeight, setSize,
- * setDimension, getDimensi
- */
- void setWidth(const int width);
-
- /**
- * Gets the width of the widget.
- *
- * @return The width of the widget.
- * @see setWidth, setHeight, getHeight, setSize,
- * setDimension, getDimension
- */
- int getWidth() const noexcept2 A_WARN_UNUSED
- { return mDimension.width; }
-
- /**
- * Sets the height of the widget.
- *
- * @param height The height of the widget.
- * @see getHeight, setWidth, getWidth, setSize,
- * setDimension, getDimension
- */
- void setHeight(const int height);
-
- /**
- * Gets the height of the widget.
- *
- * @return The height of the widget.
- * @see setHeight, setWidth, getWidth, setSize,
- * setDimension, getDimension
- */
- int getHeight() const noexcept2 A_WARN_UNUSED
- { return mDimension.height; }
-
- /**
- * Sets the size of the widget.
- *
- * @param width The width of the widget.
- * @param height The height of the widget.
- * @see setWidth, setHeight, getWidth, getHeight,
- * setDimension, getDimension
- */
- void setSize(const int width, const int height);
-
- /**
- * Sets the x coordinate of the widget. The coordinate is
- * relateive to the widget's parent.
- *
- * @param x The x coordinate of the widget.
- * @see getX, setY, getY, setPosition, setDimension, getDimension
- */
- void setX(const int x);
-
- /**
- * Gets the x coordinate of the widget. The coordinate is
- * relative to the widget's parent.
- *
- * @return The x coordinate of the widget.
- * @see setX, setY, getY, setPosition, setDimension, getDimension
- */
- int getX() const noexcept2 A_WARN_UNUSED
- { return mDimension.x; }
-
- /**
- * Sets the y coordinate of the widget. The coordinate is
- * relative to the widget's parent.
- *
- * @param y The y coordinate of the widget.
- * @see setY, setX, getX, setPosition, setDimension, getDimension
- */
- void setY(const int y);
-
- /**
- * Gets the y coordinate of the widget. The coordinate is
- * relative to the widget's parent.
- *
- * @return The y coordinate of the widget.
- * @see setY, setX, getX, setPosition, setDimension, getDimension
- */
- int getY() const noexcept2 A_WARN_UNUSED
- { return mDimension.y; }
-
- /**
- * Sets position of the widget. The position is relative
- * to the widget's parent.
- *
- * @param x The x coordinate of the widget.
- * @param y The y coordinate of the widget.
- * @see setX, getX, setY, getY, setDimension, getDimension
- */
- void setPosition(const int x, const int y);
-
- /**
- * Sets the dimension of the widget. The dimension is
- * relative to the widget's parent.
- *
- * @param dimension The dimension of the widget.
- * @see getDimension, setX, getX, setY, getY, setPosition
- */
- void setDimension(const Rect& dimension);
-
- /**
- * Gets the dimension of the widget. The dimension is
- * relative to the widget's parent.
- *
- * @return The dimension of the widget.
- * @see getDimension, setX, getX, setY, getY, setPosition
- */
- const Rect& getDimension() const noexcept2 A_WARN_UNUSED
- { return mDimension; }
-
- /**
- * Sets the widget to be fosusable, or not.
- *
- * @param focusable True if the widget should be focusable,
- * false otherwise.
- * @see isFocusable
- */
- void setFocusable(const bool focusable);
-
- /**
- * Checks if a widget is focsable.
- *
- * @return True if the widget should be focusable, false otherwise.
- * @see setFocusable
- */
- bool isFocusable() const A_WARN_UNUSED;
-
- /**
- * Checks if the widget is focused.
- *
- * @return True if the widget is focused, false otherwise.
- */
- virtual bool isFocused() const A_WARN_UNUSED;
-
- /**
- * Sets the widget to enabled, or not. A disabled
- * widget will never recieve mouse or key events.
- *
- * @param enabled True if widget should be enabled,
- * false otherwise.
- * @see isEnabled
- */
- void setEnabled(const bool enabled) noexcept2
- { mEnabled = enabled; }
-
- /**
- * Checks if the widget is enabled. A disabled
- * widget will never recieve mouse or key events.
- *
- * @return True if widget is enabled, false otherwise.
- * @see setEnabled
- */
- bool isEnabled() const A_WARN_UNUSED;
-
- /**
- * Sets the widget to be visible, or not.
- *
- * @param visible True if widget should be visible, false otherwise.
- * @see isVisible
- */
- void setVisible(Visible visible);
-
- /**
- * Checks if the widget is visible.
- *
- * @return True if widget is be visible, false otherwise.
- * @see setVisible
- */
- bool isVisible() const A_WARN_UNUSED
- {
- return mVisible == Visible_true &&
- ((mParent == nullptr) || mParent->isVisible());
- }
-
- /**
- * Sets the base color of the widget.
- *
- * @param color The baseground color.
- * @see getBaseColor
- */
- void setBaseColor(const Color& color) noexcept2
- { mBaseColor = color; }
-
- /**
- * Gets the base color.
- *
- * @return The base color.
- * @see setBaseColor
- */
- const Color& getBaseColor() const noexcept2 A_WARN_UNUSED
- { return mBaseColor; }
-
- /**
- * Sets the foreground color.
- *
- * @param color The foreground color.
- * @see getForegroundColor
- */
- void setForegroundColor(const Color& color) noexcept2
- { mForegroundColor = color; }
-
- /**
- * Gets the foreground color.
- *
- * @see setForegroundColor
- */
- const Color& getForegroundColor() const noexcept2 A_WARN_UNUSED
- { return mForegroundColor; }
-
- /**
- * Sets the background color.
- *
- * @param color The background Color.
- * @see setBackgroundColor
- */
- void setBackgroundColor(const Color &color) noexcept2
- { mBackgroundColor = color; }
-
- /**
- * Gets the background color.
- *
- * @see setBackgroundColor
- */
- const Color &getBackgroundColor() const noexcept2 A_WARN_UNUSED
- { return mBackgroundColor; }
-
- /**
- * Requests focus for the widget. A widget will only recieve focus
- * if it is focusable.
- */
- virtual void requestFocus();
-
- /**
- * Requests a move to the top in the parent widget.
- */
- virtual void requestMoveToTop();
-
- /**
- * Requests a move to the bottom in the parent widget.
- */
- virtual void requestMoveToBottom();
-
- /**
- * Sets the focus handler to be used.
- *
- * WARNING: This function is used internally and should not
- * be called or overloaded unless you know what you
- * are doing.
- *
- * @param focusHandler The focus handler to use.
- * @see getFocusHandler
- */
- virtual void setFocusHandler(FocusHandler *const focusHandler);
-
- /**
- * Gets the focus handler used.
- *
- * WARNING: This function is used internally and should not
- * be called or overloaded unless you know what you
- * are doing.
- *
- * @return The focus handler used.
- * @see setFocusHandler
- */
- FocusHandler* getFocusHandler() noexcept2 A_WARN_UNUSED
- { return mFocusHandler; }
-
- /**
- * Adds an action listener to the widget. When an action event
- * is fired by the widget the action listeners of the widget
- * will get notified.
- *
- * @param actionListener The action listener to add.
- * @see removeActionListener
- */
- void addActionListener(ActionListener *const actionListener);
-
- /**
- * Removes an added action listener from the widget.
- *
- * @param actionListener The action listener to remove.
- * @see addActionListener
- */
- void removeActionListener(ActionListener *const actionListener);
-
- /**
- * Adds a death listener to the widget. When a death event is
- * fired by the widget the death listeners of the widget will
- * get notified.
- *
- * @param deathListener The death listener to add.
- * @see removeDeathListener
- */
- void addDeathListener(WidgetDeathListener *const deathListener);
-
- /**
- * Removes an added death listener from the widget.
- *
- * @param deathListener The death listener to remove.
- * @see addDeathListener
- */
- void removeDeathListener(WidgetDeathListener *const deathListener);
-
- /**
- * Adds a mouse listener to the widget. When a mouse event is
- * fired by the widget the mouse listeners of the widget will
- * get notified.
- *
- * @param mouseListener The mouse listener to add.
- * @see removeMouseListener
- */
- void addMouseListener(MouseListener *const mouseListener);
-
- /**
- * Removes an added mouse listener from the widget.
- *
- * @param mouseListener The mouse listener to remove.
- * @see addMouseListener
- */
- void removeMouseListener(MouseListener *const mouseListener);
-
- /**
- * Adds a key listener to the widget. When a key event is
- * fired by the widget the key listeners of the widget will
- * get notified.
- *
- * @param keyListener The key listener to add.
- * @see removeKeyListener
- */
- void addKeyListener(KeyListener *const keyListener);
-
- /**
- * Removes an added key listener from the widget.
- *
- * @param keyListener The key listener to remove.
- * @see addKeyListener
- */
- void removeKeyListener(KeyListener *const keyListener);
-
- /**
- * Adds a focus listener to the widget. When a focus event is
- * fired by the widget the key listeners of the widget will
- * get notified.
- *
- * @param focusListener The focus listener to add.
- * @see removeFocusListener
- */
- void addFocusListener(FocusListener *const focusListener);
-
- /**
- * Removes an added focus listener from the widget.
- *
- * @param focusListener The focus listener to remove.
- * @see addFocusListener
- */
- void removeFocusListener(FocusListener *const focusListener);
-
- /**
- * Adds a widget listener to the widget. When a widget event is
- * fired by the widget the key listeners of the widget will
- * get notified.
- *
- * @param widgetListener The widget listener to add.
- * @see removeWidgetListener
- */
- void addWidgetListener(WidgetListener *const widgetListener);
-
- /**
- * Removes an added widget listener from the widget.
- *
- * @param widgetListener The widget listener to remove.
- * @see addWidgetListener
- */
- void removeWidgetListener(WidgetListener *const widgetListener);
-
- /**
- * Sets the action event identifier of the widget. The identifier is
- * used to be able to identify which action has occured.
- *
- * NOTE: An action event identifier should not be used to identify a
- * certain widget but rather a certain event in your application.
- * Several widgets can have the same action event identifer.
- *
- * @param actionEventId The action event identifier.
- * @see getActionEventId
- */
- void setActionEventId(const std::string &actionEventId) noexcept2
- { mActionEventId = actionEventId; }
-
- /**
- * Gets the action event identifier of the widget.
- *
- * @return The action event identifier of the widget.
- * @see setActionEventId
- */
- const std::string &getActionEventId() const noexcept2
- { return mActionEventId; }
-
- /**
- * Gets the absolute position on the screen for the widget.
- *
- * @param x The absolute x coordinate will be stored in this parameter.
- * @param y The absolute y coordinate will be stored in this parameter.
- */
- virtual void getAbsolutePosition(int& x, int& y) const;
-
- /**
- * Sets the parent of the widget. A parent must be a BasicContainer.
- *
- * WARNING: This function is used internally and should not
- * be called or overloaded unless you know what you
- * are doing.
- *
- * @param parent The parent of the widget.
- * @see getParent
- */
- virtual void setParent(Widget* parent)
- { mParent = parent; }
-
- /**
- * Gets the font set for the widget. If no font has been set,
- * the global font will be returned. If no global font has been set,
- * the default font will be returend.
- *
- * @return The font set for the widget.
- * @see setFont, setGlobalFont
- */
- Font *getFont() const RETURNS_NONNULL A_WARN_UNUSED;
-
- /**
- * Sets the global font to be used by default for all widgets.
- *
- * @param font The global font.
- * @see getGlobalFont
- */
- static void setGlobalFont(Font *const font);
-
- static Font *getGloablFont()
- { return mGlobalFont; }
-
- static void cleanGlobalFont()
- { mGlobalFont = nullptr; }
-
- /**
- * Sets the font for the widget. If NULL is passed, the global font
- * will be used.
- *
- * @param font The font to set for the widget.
- * @see getFont
- */
- void setFont(Font *const font);
-
- /**
- * Called when the font has changed. If the change is global,
- * this function will only be called if the widget doesn't have a
- * font already set.
- */
- virtual void fontChanged()
- { }
-
- /**
- * Checks if a widget exists or not, that is if it still exists
- * an instance of the object.
- *
- * @param widget The widget to check.
- * @return True if an instance of the widget exists, false otherwise.
- */
- static bool widgetExists(const Widget *const widget) A_WARN_UNUSED;
-
- /**
- * Checks if tab in is enabled. Tab in means that you can set focus
- * to this widget by pressing the tab button. If tab in is disabled
- * then the focus handler will skip this widget and focus the next
- * in its focus order.
- *
- * @return True if tab in is enabled, false otherwise.
- * @see setTabInEnabled
- */
- bool isTabInEnabled() const noexcept2 A_WARN_UNUSED
- { return mTabIn; }
-
- /**
- * Sets tab in enabled, or not. Tab in means that you can set focus
- * to this widget by pressing the tab button. If tab in is disabled
- * then the FocusHandler will skip this widget and focus the next
- * in its focus order.
- *
- * @param enabled True if tab in should be enabled, false otherwise.
- * @see isTabInEnabled
- */
- void setTabInEnabled(const bool enabled) noexcept2
- { mTabIn = enabled; }
-
- /**
- * Checks if tab out is enabled. Tab out means that you can lose
- * focus to this widget by pressing the tab button. If tab out is
- * disabled then the FocusHandler ignores tabbing and focus will
- * stay with this widget.
- *
- * @return True if tab out is enabled, false otherwise.
- * @see setTabOutEnabled
- */
- bool isTabOutEnabled() const noexcept2 A_WARN_UNUSED
- { return mTabOut; }
-
- /**
- * Sets tab out enabled. Tab out means that you can lose
- * focus to this widget by pressing the tab button. If tab out is
- * disabled then the FocusHandler ignores tabbing and focus will
- * stay with this widget.
- *
- * @param enabled True if tab out should be enabled, false otherwise.
- * @see isTabOutEnabled
- */
- void setTabOutEnabled(const bool enabled) noexcept2
- { mTabOut = enabled; }
-
- /**
- * Requests modal focus. When a widget has modal focus, only that
- * widget and it's children may recieve input.
- *
- * @throws Exception if another widget already has modal focus.
- * @see releaseModalFocus, isModalFocused
- */
- void requestModalFocus();
-
- /**
- * Requests modal mouse input focus. When a widget has modal input focus
- * that widget will be the only widget receiving input even if the input
- * occurs outside of the widget and no matter what the input is.
- *
- * @throws Exception if another widget already has modal focus.
- * @see releaseModalMouseInputFocus, isModalMouseInputFocused
- */
- virtual void requestModalMouseInputFocus();
-
- /**
- * Releases modal focus. Modal focus will only be released if the
- * widget has modal focus.
- *
- * @see requestModalFocus, isModalFocused
- */
- virtual void releaseModalFocus();
-
- /**
- * Releases modal mouse input focus. Modal mouse input focus will only
- * be released if the widget has modal mouse input focus.
- *
- * @see requestModalMouseInputFocus, isModalMouseInputFocused
- */
- virtual void releaseModalMouseInputFocus();
-
- /**
- * Checks if the widget or it's parent has modal focus.
- *
- * @return True if the widget has modal focus, false otherwise.
- * @see requestModalFocus, releaseModalFocus
- */
- virtual bool isModalFocused() const A_WARN_UNUSED;
-
- /**
- * Checks if the widget or it's parent has modal mouse input focus.
- *
- * @return True if the widget has modal mouse input focus, false
- * otherwise.
- * @see requestModalMouseInputFocus, releaseModalMouseInputFocus
- */
- virtual bool isModalMouseInputFocused() const A_WARN_UNUSED;
-
- /**
- * Gets a widget from a certain position in the widget.
- * This function is used to decide which gets mouse input,
- * thus it can be overloaded to change that behaviour.
- *
- * NOTE: This always returns NULL if the widget is not
- * a container.
- *
- * @param x The x coordinate of the widget to get.
- * @param y The y coordinate of the widget to get.
- * @return The widget at the specified coodinate, NULL
- * if no widget is found.
- */
- virtual Widget *getWidgetAt(int x A_UNUSED,
- int y A_UNUSED) A_WARN_UNUSED
- { return nullptr; }
-
- /**
- * Gets the mouse listeners of the widget.
- *
- * @return The mouse listeners of the widget.
- */
- const std::list<MouseListener*>& getMouseListeners() const
- A_CONST A_WARN_UNUSED;
-
- /**
- * Gets the key listeners of the widget.
- *
- * @return The key listeners of the widget.
- */
- const std::list<KeyListener*>& getKeyListeners() const
- A_CONST A_WARN_UNUSED;
-
- /**
- * Gets the focus listeners of the widget.
- *
- * @return The focus listeners of the widget.
- */
- const std::list<FocusListener*>& getFocusListeners() const
- A_CONST A_WARN_UNUSED;
-
- /**
- * Gets the area of the widget occupied by the widget's children.
- * By default this method returns an empty rectangle as not all
- * widgets are containers. If you want to make a container this
- * method should return the area where the children resides. This
- * method is used when drawing children of a widget when computing
- * clip rectangles for the children.
- *
- * An example of a widget that overloads this method is ScrollArea.
- * A ScrollArea has a view of its contant and that view is the
- * children area. The size of a ScrollArea's children area might
- * vary depending on if the scroll bars of the ScrollArea is shown
- * or not.
- *
- * @return The area of the widget occupied by the widget's children.
- * @see BasicContainer
- * @see BasicContainer::getChildrenArea
- * @see BasicContainer::drawChildren
- */
- virtual Rect getChildrenArea() A_WARN_UNUSED;
-
- /**
- * Gets the internal focus handler used.
- *
- * @return the internalFocusHandler used. If no internal focus handler
- * is used, NULL will be returned.
- * @see setInternalFocusHandler
- */
- virtual FocusHandler* getInternalFocusHandler() A_WARN_UNUSED;
-
- /**
- * Sets the internal focus handler. An internal focus handler is
- * needed if both a widget in the widget and the widget itself
- * should be foucsed at the same time.
- *
- * @param focusHandler The internal focus handler to be used.
- * @see getInternalFocusHandler
- */
- void setInternalFocusHandler(FocusHandler *const internalFocusHandler);
-
- /**
- * Moves a widget to the top of this widget. The moved widget will be
- * drawn above all other widgets in this widget.
- *
- * @param widget The widget to move to the top.
- * @see moveToBottom
- */
- virtual void moveToTop(Widget* widget A_UNUSED)
- { }
-
- /**
- * Moves a widget in this widget to the bottom of this widget.
- * The moved widget will be drawn below all other widgets in this widget.
- *
- * @param widget The widget to move to the bottom.
- * @see moveToTop
- */
- virtual void moveToBottom(Widget* widget A_UNUSED)
- { }
-
- /**
- * Focuses the next widget in the widget.
- *
- * @see moveToBottom
- */
- virtual void focusNext()
- { }
-
- /**
- * Focuses the previous widget in the widget.
- *
- * @see moveToBottom
- */
- virtual void focusPrevious()
- { }
-
- /**
- * Tries to show a specific part of a widget by moving it. Used if the
- * widget should act as a container.
- *
- * @param widget The target widget.
- * @param area The area to show.
- */
- virtual void showWidgetPart(Widget *const widget A_UNUSED,
- const Rect &area A_UNUSED)
- { }
-
- /**
- * Sets an id of a widget. An id can be useful if a widget needs to be
- * identified in a container. For example, if widgets are created by an
- * XML document, a certain widget can be retrieved given that the widget
- * has an id.
- *
- * @param id The id to set to the widget.
- * @see getId
- */
- void setId(const std::string& id)
- { mId = id; }
-
- const std::string& getId() const noexcept2 A_WARN_UNUSED
- { return mId; }
-
- /**
- * Shows a certain part of a widget in the widget's parent.
- * Used when widgets want a specific part to be visible in
- * its parent. An example is a TextArea that wants a specific
- * part of its text to be visible when a TextArea is a child
- * of a ScrollArea.
- *
- * @param rectangle The rectangle to be shown.
- */
- virtual void showPart(const Rect &rectangle);
-
- bool isAllowLogic() const noexcept2 A_WARN_UNUSED
- { return mAllowLogic; }
-
- void setMouseConsume(const bool b) noexcept2
- { mMouseConsume = b; }
-
- bool isMouseConsume() const noexcept2 A_WARN_UNUSED
- { return mMouseConsume; }
-
- void setRedraw(const bool b) noexcept2
- { mRedraw = b; }
-
- virtual bool isSelectable() const noexcept2 A_WARN_UNUSED
- { return mSelectable; }
-
- void setSelectable(const bool selectable) noexcept2
- { mSelectable = selectable; }
-
- static void distributeWindowResizeEvent();
-
- void windowResized();
-
- static Widget *callPostInit(Widget *const widget) RETURNS_NONNULL;
-
- virtual void postInit()
- { }
-
- /**
- * True if the widget visible, false otherwise.
- */
- Visible mVisible;
-
- protected:
- /**
- * Distributes an action event to all action listeners
- * of the widget.
- */
- void distributeActionEvent();
-
- /**
- * Distributes resized events to all of the widget's listeners.
- */
- void distributeResizedEvent();
-
- /**
- * Distributes moved events to all of the widget's listeners.
- */
- void distributeMovedEvent();
-
- /**
- * Distributes hidden events to all of the widget's listeners.
- *
- * @author Olof Naessén
- */
- void distributeHiddenEvent();
-
- /**
- * Distributes shown events to all of the widget's listeners.
- *
- * @author Olof Naessén
- */
- void distributeShownEvent();
-
- /**
- * Typdef.
- */
- typedef std::list<MouseListener*> MouseListenerList;
-
- /**
- * Typdef.
- */
- typedef MouseListenerList::iterator MouseListenerIterator;
-
- /**
- * Holds the mouse listeners of the widget.
- */
- MouseListenerList mMouseListeners;
-
- /**
- * Typdef.
- */
- typedef std::list<KeyListener*> KeyListenerList;
-
- /**
- * Holds the key listeners of the widget.
- */
- KeyListenerList mKeyListeners;
-
- /**
- * Typdef.
- */
- typedef KeyListenerList::iterator KeyListenerIterator;
-
- /**
- * Typdef.
- */
- typedef std::list<ActionListener*> ActionListenerList;
-
- /**
- * Holds the action listeners of the widget.
- */
- ActionListenerList mActionListeners;
-
- /**
- * Typdef.
- */
- typedef ActionListenerList::iterator ActionListenerIterator;
-
- /**
- * Typdef.
- */
- typedef std::list<WidgetDeathListener*> WidgetDeathListenerList;
-
- /**
- * Holds the death listeners of the widget.
- */
- WidgetDeathListenerList mDeathListeners;
-
- /**
- * Typdef.
- */
- typedef WidgetDeathListenerList::iterator WidgetDeathListenerIterator;
-
- /**
- * Typdef.
- */
- typedef std::list<FocusListener*> FocusListenerList;
-
- /**
- * Holds the focus listeners of the widget.
- */
- FocusListenerList mFocusListeners;
-
- /**
- * Typdef.
- */
- typedef FocusListenerList::iterator FocusListenerIterator;
-
- typedef std::list<WidgetListener*> WidgetListenerList;
-
- /**
- * Holds the widget listeners of the widget.
- */
- WidgetListenerList mWidgetListeners;
-
- /**
- * Typdef.
- */
- typedef WidgetListenerList::iterator WidgetListenerIterator;
-
- /**
- * Holds the foreground color of the widget.
- */
- Color mForegroundColor;
-
- /**
- * Holds the background color of the widget.
- */
- Color mBackgroundColor;
-
- /**
- * Holds the base color of the widget.
- */
- Color mBaseColor;
-
- /**
- * Holds the dimension of the widget.
- */
- Rect mDimension;
-
- /**
- * Holds the action event of the widget.
- */
- std::string mActionEventId;
-
- /**
- * Holds the id of the widget.
- */
- std::string mId;
-
- /**
- * Holds the focus handler used by the widget.
- */
- FocusHandler* mFocusHandler;
-
- /**
- * Holds the focus handler used by the widget. NULL
- * if no internal focus handler is used.
- */
- FocusHandler* mInternalFocusHandler;
-
- /**
- * Holds the parent of the widget. NULL if the widget
- * has no parent.
- */
- Widget* mParent;
-
- /**
- * Holds the font used by the widget.
- */
- Font* mCurrentFont;
-
- /**
- * Holds the frame size of the widget.
- */
- unsigned int mFrameSize;
-
- /**
- * True if the widget focusable, false otherwise.
- */
- bool mFocusable;
-
- /**
- * True if the widget has tab in enabled, false otherwise.
- */
- bool mTabIn;
-
- /**
- * True if the widget has tab in enabled, false otherwise.
- */
- bool mTabOut;
-
- /**
- * True if the widget is enabled, false otherwise.
- */
- bool mEnabled;
-
- bool mAllowLogic;
-
- bool mMouseConsume;
-
- bool mRedraw;
-
- bool mSelectable;
-
- /**
- * Holds the global font used by the widget.
- */
- static Font* mGlobalFont;
-
- private:
- /**
- * Holds a list of all instances of widgets.
- */
- static std::list<Widget*> mAllWidgets;
-
- static std::set<Widget*> mAllWidgetsSet;
-};
-
-#endif // GUI_WIDGETS_WIDGET_H
diff --git a/src/gui/widgets/widget2.h b/src/gui/widgets/widget2.h
deleted file mode 100644
index 12103e317..000000000
--- a/src/gui/widgets/widget2.h
+++ /dev/null
@@ -1,117 +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 GUI_WIDGETS_WIDGET2_H
-#define GUI_WIDGETS_WIDGET2_H
-
-#include "const/gui/theme.h"
-
-#include "enums/render/rendertype.h"
-
-#include "gui/themecolorsidoperators.h"
-#include "gui/theme.h"
-
-#include "localconsts.h"
-
-class Widget;
-
-class Widget2 notfinal
-{
- public:
- A_DEFAULT_COPY(Widget2)
-
- virtual ~Widget2()
- {
- }
-
- inline const Color &getThemeColor(const ThemeColorIdT type,
- const unsigned int alpha = 255U)
- const A_WARN_UNUSED A_INLINE
- {
- return theme->getColor(type + mPaletteOffset, alpha);
- }
-
- inline const Color &getThemeCharColor(const signed char c,
- bool &valid)
- const A_WARN_UNUSED A_INLINE
- {
- if (theme == nullptr)
- return Palette::BLACK;
- const ThemeColorIdT colorId = theme->getIdByChar(c, valid);
- if (valid)
- return theme->getColor(colorId + mPaletteOffset, 255U);
- return Palette::BLACK;
- }
-
- virtual void setWidget2(const Widget2 *const widget)
- {
- mPaletteOffset = widget != nullptr ? widget->mPaletteOffset : 0;
- }
-
- void setPalette(int palette)
- {
- mPaletteOffset = palette * CAST_S32(
- ThemeColorId::THEME_COLORS_END);
- checkPalette();
- setWidget2(this);
- }
-
- void checkPalette()
- {
- if (mPaletteOffset < 0 ||
- mPaletteOffset >= THEME_PALETTES * CAST_S32(
- ThemeColorId::THEME_COLORS_END))
- {
- mPaletteOffset = 0;
- }
- }
-
- void setForegroundColor2(const Color &color) noexcept2
- {
- mForegroundColor2 = color;
- }
-
- Widget* getWindow() const noexcept2 A_WARN_UNUSED
- {
- return mWindow;
- }
-
- virtual void setWindow(Widget *const window)
- {
- mWindow = window;
- }
-
- protected:
- explicit Widget2(const Widget2 *const widget) :
- mPaletteOffset(widget != nullptr ? widget->mPaletteOffset : 0),
- mWindow(widget != nullptr ? widget->getWindow() : nullptr),
- mForegroundColor2()
- {
- checkPalette();
- }
-
- int mPaletteOffset;
- Widget *mWindow;
- Color mForegroundColor2;
-};
-
-extern RenderType openGLMode;
-
-#endif // GUI_WIDGETS_WIDGET2_H
diff --git a/src/gui/widgets/widgetgroup.cpp b/src/gui/widgets/widgetgroup.cpp
deleted file mode 100644
index 72524b07c..000000000
--- a/src/gui/widgets/widgetgroup.cpp
+++ /dev/null
@@ -1,87 +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 "gui/widgets/widgetgroup.h"
-
-#include "debug.h"
-
-WidgetGroup::WidgetGroup(const Widget2 *const widget,
- const std::string &group,
- const int height,
- const int spacing) :
- Container(widget),
- WidgetListener(),
- ActionListener(),
- mSpacing(spacing),
- mCount(0),
- mGroup(group),
- mLastX(spacing)
-{
- setHeight(height);
- addWidgetListener(this);
-}
-
-void WidgetGroup::addButton(const std::string &restrict text,
- const std::string &restrict tag,
- const bool pressed)
-{
- if (text.empty() || tag.empty())
- return;
-
- Widget *const widget = createWidget(text, pressed);
- if (widget != nullptr)
- {
- widget->setActionEventId(mActionEventId + tag);
- widget->addActionListener(this);
- addWidget(widget, mSpacing);
- }
-}
-
-void WidgetGroup::action(const ActionEvent &event)
-{
- for (ActionListenerIterator iter = mActionListeners.begin();
- iter != mActionListeners.end(); ++iter)
- {
- (*iter)->action(event);
- }
-}
-
-void WidgetGroup::addWidget(Widget *const widget,
- const int spacing)
-{
- if (widget == nullptr)
- return;
-
- Container::add(widget);
- widget->setPosition(mLastX, spacing);
- mCount++;
- mLastX += widget->getWidth() + 2 * mSpacing;
-}
-
-void WidgetGroup::clear()
-{
- Container::clear();
-
- mCount = 0;
-}
-
-void WidgetGroup::widgetResized(const Event &event A_UNUSED)
-{
-}
diff --git a/src/gui/widgets/widgetgroup.h b/src/gui/widgets/widgetgroup.h
deleted file mode 100644
index 129581ebc..000000000
--- a/src/gui/widgets/widgetgroup.h
+++ /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/>.
- */
-
-#ifndef GUI_WIDGETS_WIDGETGROUP_H
-#define GUI_WIDGETS_WIDGETGROUP_H
-
-#include "gui/widgets/container.h"
-
-#include "listeners/actionlistener.h"
-#include "listeners/widgetlistener.h"
-
-#include "localconsts.h"
-
-class WidgetGroup notfinal : public Container,
- public WidgetListener,
- public ActionListener
-{
- public:
- A_DELETE_COPY(WidgetGroup)
-
- virtual void addButton(const std::string &restrict text,
- const std::string &restrict tag,
- const bool pressed);
-
- void action(const ActionEvent &event) override;
-
- virtual void addWidget(Widget *const widget,
- const int spacing);
-
- void clear() override final;
-
- void widgetResized(const Event &event) override final A_CONST;
-
- virtual Widget *createWidget(const std::string &name,
- const bool pressed)
- const A_WARN_UNUSED = 0;
-
- protected:
- WidgetGroup(const Widget2 *const widget,
- const std::string &group,
- const int height,
- const int spacing);
-
- int mSpacing;
- int mCount;
- std::string mGroup;
-
- private:
- int mLastX;
-};
-
-#endif // GUI_WIDGETS_WIDGETGROUP_H
diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp
deleted file mode 100644
index b192bad35..000000000
--- a/src/gui/widgets/window.cpp
+++ /dev/null
@@ -1,1499 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "gui/widgets/window.h"
-
-#include "client.h"
-#include "configuration.h"
-#ifndef DYECMD
-#include "dragdrop.h"
-#else // DYECMD
-#include "resources/image/image.h"
-#endif // DYECMD
-#include "soundmanager.h"
-
-#include "const/sound.h"
-
-#include "gui/focushandler.h"
-#include "gui/gui.h"
-#include "gui/popupmanager.h"
-#include "gui/skin.h"
-#include "gui/viewport.h"
-
-#include "gui/fonts/font.h"
-
-#include "gui/popups/popupmenu.h"
-
-#include "gui/windows/setupwindow.h"
-
-#include "gui/widgets/containerplacer.h"
-#include "gui/widgets/layout.h"
-
-#include "render/renderers.h"
-
-#include "render/vertexes/imagecollection.h"
-
-#include "utils/checkutils.h"
-#include "utils/delete2.h"
-
-#include "debug.h"
-
-const int resizeMask = 8 + 4 + 2 + 1;
-
-int Window::windowInstances = 0;
-int Window::mouseResize = 0;
-
-Window::Window(const std::string &caption,
- const Modal modal,
- Window *const parent,
- std::string skin) :
- BasicContainer2(nullptr),
- MouseListener(),
- WidgetListener(),
- mCaption(caption),
- mAlignment(Graphics::CENTER),
- mPadding(2),
- mTitleBarHeight(16),
- mMovable(Move_true),
- mDragOffsetX(0),
- mDragOffsetY(0),
- mMoved(false),
- mSkin(nullptr),
- mDefaultX(0),
- mDefaultY(0),
- mDefaultWidth(0),
- mDefaultHeight(0),
- mCaptionOffsetX(7),
- mCaptionOffsetY(5),
- mShowTitle(true),
- mLastRedraw(true),
- mGrip(nullptr),
- mParentWindow(parent),
- mLayout(nullptr),
- mCloseRect(),
- mStickyRect(),
- mGripRect(),
- mTextChunk(),
- mWindowName("window"),
- mMinWinWidth(100),
- mMinWinHeight(40),
- mMaxWinWidth(mainGraphics->mWidth),
- mMaxWinHeight(mainGraphics->mHeight),
- mVertexes(new ImageCollection),
- mCaptionAlign(Graphics::LEFT),
- mTitlePadding(4),
- mGripPadding(2),
- mResizeHandles(-1),
- mOldResizeHandles(-1),
- mClosePadding(0),
- mStickySpacing(0),
- mStickyPadding(0),
- mCaptionFont(getFont()),
- mModal(modal),
- mCloseWindowButton(false),
- mDefaultVisible(false),
- mSaveVisible(false),
- mStickyButton(false),
- mSticky(false),
- mStickyButtonLock(false),
- mPlayVisibleSound(false),
- mInit(false),
- mTextChanged(true),
- mAllowClose(false)
-{
- logger->log("Window::Window(\"%s\")", caption.c_str());
-
- mWindow = this;
-
- windowInstances++;
-
-// mFrameSize = 1;
- addMouseListener(this);
-
- setFrameSize(0);
- setPadding(3);
- setTitleBarHeight(20);
-
- if (skin.empty())
- skin = "window.xml";
-
- int childPalette = 1;
- // Loads the skin
- if (theme != nullptr)
- {
- mSkin = theme->load(skin, "window.xml");
- if (mSkin != nullptr)
- {
- setPadding(mSkin->getPadding());
- if (getOptionBool("titlebarBold"))
- mCaptionFont = boldFont;
- mTitlePadding = mSkin->getTitlePadding();
- mGripPadding = getOption("resizePadding");
- mCaptionOffsetX = getOption("captionoffsetx");
- if (mCaptionOffsetX == 0)
- mCaptionOffsetX = 7;
- mCaptionOffsetY = getOption("captionoffsety");
- if (mCaptionOffsetY == 0)
- mCaptionOffsetY = 5;
- mCaptionAlign = static_cast<Graphics::Alignment>(
- getOption("captionalign"));
- if (mCaptionAlign < Graphics::LEFT
- || mCaptionAlign > Graphics::RIGHT)
- {
- mCaptionAlign = Graphics::LEFT;
- }
- setTitleBarHeight(CAST_U32(
- getOption("titlebarHeight")));
- if (mTitleBarHeight == 0u)
- mTitleBarHeight = mCaptionFont->getHeight() + mPadding;
-
- mTitleBarHeight += getOption("titlebarHeightRelative");
- setPalette(getOption("palette"));
- childPalette = getOption("childPalette");
- mShowTitle = getOptionBool("showTitle", true);
- mClosePadding = getOption("closePadding");
- mStickySpacing = getOption("stickySpacing");
- mStickyPadding = getOption("stickyPadding");
- }
- }
-
- // Add this window to the window container
- if (windowContainer != nullptr)
- windowContainer->add(this);
-
- if (mModal == Modal_true)
- {
- gui->setCursorType(Cursor::CURSOR_POINTER);
- requestModalFocus();
- }
-
- // Windows are invisible by default
- setVisible(Visible_false, false);
-
- addWidgetListener(this);
- mForegroundColor = getThemeColor(ThemeColorId::WINDOW);
- mForegroundColor2 = getThemeColor(ThemeColorId::WINDOW_OUTLINE);
- setPalette(childPalette);
-}
-
-void Window::postInit()
-{
- if (mInit)
- {
- reportAlways("error: Window created with calling postInit() "
- "more than once: %s",
- mWindowName.c_str());
- }
- mInit = true;
-}
-
-Window::~Window()
-{
- logger->log("Window::~Window(\"%s\")", getCaption().c_str());
-
- if (gui != nullptr)
- gui->removeDragged(this);
-
-#ifndef DYECMD
- if (setupWindow != nullptr)
- setupWindow->unregisterWindowForReset(this);
-#endif // DYECMD
-
- client->windowRemoved(this);
-
- saveWindowState();
-
- delete2(mLayout);
-
- while (!mWidgets.empty())
- delete mWidgets.front();
-
- mWidgets.clear();
-
- removeWidgetListener(this);
- delete2(mVertexes);
-
- windowInstances--;
-
- if (mSkin != nullptr)
- {
- if (theme != nullptr)
- theme->unload(mSkin);
- mSkin = nullptr;
- }
- if (mGrip != nullptr)
- {
- mGrip->decRef();
- mGrip = nullptr;
- }
- if (!mInit)
- {
- reportAlways("error: Window created without calling postInit(): %s",
- mWindowName.c_str());
- }
-}
-
-void Window::setWindowContainer(WindowContainer *const wc)
-{
- windowContainer = wc;
-}
-
-void Window::draw(Graphics *const graphics)
-{
- if (mSkin == nullptr)
- return;
-
- BLOCK_START("Window::draw")
- bool update = false;
-
- if (mResizeHandles != mOldResizeHandles)
- {
- mRedraw = true;
- mOldResizeHandles = mResizeHandles;
- }
- if (mRedraw)
- {
- mLastRedraw = true;
- mRedraw = false;
- update = true;
- mVertexes->clear();
- graphics->calcWindow(mVertexes,
- 0, 0,
- mDimension.width,
- mDimension.height,
- mSkin->getBorder());
-
- // Draw Close Button
- if (mCloseWindowButton)
- {
- const Image *const button = mSkin->getCloseImage(
- mResizeHandles == CLOSE);
- if (button != nullptr)
- {
- graphics->calcTileCollection(mVertexes,
- button,
- mCloseRect.x,
- mCloseRect.y);
- }
- }
- // Draw Sticky Button
- if (mStickyButton)
- {
- const Image *const button = mSkin->getStickyImage(mSticky);
- if (button != nullptr)
- {
- graphics->calcTileCollection(mVertexes,
- button,
- mStickyRect.x,
- mStickyRect.y);
- }
- }
-
- if (mGrip != nullptr)
- {
- graphics->calcTileCollection(mVertexes,
- mGrip,
- mGripRect.x,
- mGripRect.y);
- }
- graphics->finalize(mVertexes);
- }
- else
- {
- mLastRedraw = false;
- }
- graphics->drawTileCollection(mVertexes);
-
- // Draw title
- if (mShowTitle)
- {
- int x;
- switch (mCaptionAlign)
- {
- case Graphics::LEFT:
- default:
- x = mCaptionOffsetX;
- break;
- case Graphics::CENTER:
- x = mCaptionOffsetX - mCaptionFont->getWidth(mCaption) / 2;
- break;
- case Graphics::RIGHT:
- x = mCaptionOffsetX - mCaptionFont->getWidth(mCaption);
- break;
- }
- if (mTextChanged)
- {
- mTextChunk.textFont = mCaptionFont;
- mTextChunk.deleteImage();
- mTextChunk.text = mCaption;
- mTextChunk.color = mForegroundColor;
- mTextChunk.color2 = mForegroundColor2;
- mCaptionFont->generate(mTextChunk);
- mTextChanged = false;
- }
-
- const Image *const image = mTextChunk.img;
- if (image != nullptr)
- graphics->drawImage(image, x, mCaptionOffsetY);
- }
-
- if (update)
- {
- graphics->setRedraw(update);
- drawChildren(graphics);
- graphics->setRedraw(false);
- }
- else
- {
- drawChildren(graphics);
- }
- BLOCK_END("Window::draw")
-}
-
-void Window::safeDraw(Graphics *const graphics)
-{
- if (mSkin == nullptr)
- return;
-
- BLOCK_START("Window::safeDraw")
-
- graphics->drawImageRect(0, 0,
- mDimension.width,
- mDimension.height,
- mSkin->getBorder());
-
- // Draw Close Button
- if (mCloseWindowButton)
- {
- const Image *const button = mSkin->getCloseImage(
- mResizeHandles == CLOSE);
- if (button != nullptr)
- graphics->drawImage(button, mCloseRect.x, mCloseRect.y);
- }
- // Draw Sticky Button
- if (mStickyButton)
- {
- const Image *const button = mSkin->getStickyImage(mSticky);
- if (button != nullptr)
- graphics->drawImage(button, mStickyRect.x, mStickyRect.y);
- }
-
- if (mGrip != nullptr)
- graphics->drawImage(mGrip, mGripRect.x, mGripRect.y);
-
- // Draw title
- if (mShowTitle)
- {
- int x;
- switch (mCaptionAlign)
- {
- case Graphics::LEFT:
- default:
- x = mCaptionOffsetX;
- break;
- case Graphics::CENTER:
- x = mCaptionOffsetX - mCaptionFont->getWidth(mCaption) / 2;
- break;
- case Graphics::RIGHT:
- x = mCaptionOffsetX - mCaptionFont->getWidth(mCaption);
- break;
- }
- if (mTextChanged)
- {
- mTextChunk.textFont = mCaptionFont;
- mTextChunk.deleteImage();
- mTextChunk.text = mCaption;
- mTextChunk.color = mForegroundColor;
- mTextChunk.color2 = mForegroundColor2;
- mCaptionFont->generate(mTextChunk);
- mTextChanged = false;
- }
-
- const Image *const image = mTextChunk.img;
- if (image != nullptr)
- graphics->drawImage(image, x, mCaptionOffsetY);
- }
-
- safeDrawChildren(graphics);
-
- BLOCK_END("Window::safeDraw")
-}
-
-void Window::setContentSize(int width, int height)
-{
- width = width + 2 * mPadding;
- height = height + mPadding + mTitleBarHeight;
-
- if (mMinWinWidth > width)
- width = mMinWinWidth;
- else if (mMaxWinWidth < width)
- width = mMaxWinWidth;
- if (mMinWinHeight > height)
- height = mMinWinHeight;
- else if (mMaxWinHeight < height)
- height = mMaxWinHeight;
-
- setSize(width, height);
-}
-
-void Window::setLocationRelativeTo(const Widget *const widget)
-{
- if (widget == nullptr)
- return;
-
- int wx, wy;
- int x, y;
-
- widget->getAbsolutePosition(wx, wy);
- getAbsolutePosition(x, y);
-
- setPosition(mDimension.x + (wx + (widget->getWidth()
- - mDimension.width) / 2 - x),
- mDimension.y + (wy + (widget->getHeight()
- - mDimension.height) / 2 - y));
-}
-
-void Window::setLocationHorisontallyRelativeTo(const Widget *const widget)
-{
- if (widget == nullptr)
- return;
-
- int wx, wy;
- int x, y;
-
- widget->getAbsolutePosition(wx, wy);
- getAbsolutePosition(x, y);
-
- setPosition(mDimension.x + (wx + (widget->getWidth()
- - mDimension.width) / 2 - x), 0);
-}
-
-void Window::setLocationRelativeTo(const ImagePosition::Type &position,
- int offsetX, int offsetY)
-{
- if (position == ImagePosition::UPPER_LEFT)
- {
- }
- else if (position == ImagePosition::UPPER_CENTER)
- {
- offsetX += (mainGraphics->mWidth - mDimension.width) / 2;
- }
- else if (position == ImagePosition::UPPER_RIGHT)
- {
- offsetX += mainGraphics->mWidth - mDimension.width;
- }
- else if (position == ImagePosition::LEFT)
- {
- offsetY += (mainGraphics->mHeight - mDimension.height) / 2;
- }
- else if (position == ImagePosition::CENTER)
- {
- offsetX += (mainGraphics->mWidth - mDimension.width) / 2;
- offsetY += (mainGraphics->mHeight - mDimension.height) / 2;
- }
- else if (position == ImagePosition::RIGHT)
- {
- offsetX += mainGraphics->mWidth - mDimension.width;
- offsetY += (mainGraphics->mHeight - mDimension.height) / 2;
- }
- else if (position == ImagePosition::LOWER_LEFT)
- {
- offsetY += mainGraphics->mHeight - mDimension.height;
- }
- else if (position == ImagePosition::LOWER_CENTER)
- {
- offsetX += (mainGraphics->mWidth - mDimension.width) / 2;
- offsetY += mainGraphics->mHeight - mDimension.height;
- }
- else if (position == ImagePosition::LOWER_RIGHT)
- {
- offsetX += mainGraphics->mWidth - mDimension.width;
- offsetY += mainGraphics->mHeight - mDimension.height;
- }
-
- setPosition(offsetX, offsetY);
-}
-
-void Window::setMinWidth(const int width)
-{
- if (mSkin != nullptr)
- {
- mMinWinWidth = width > mSkin->getMinWidth()
- ? width : mSkin->getMinWidth();
- }
- else
- {
- mMinWinWidth = width;
- }
-}
-
-void Window::setMinHeight(const int height)
-{
- if (mSkin != nullptr)
- {
- mMinWinHeight = height > mSkin->getMinHeight()
- ? height : mSkin->getMinHeight();
- }
- else
- {
- mMinWinHeight = height;
- }
-}
-
-void Window::setMaxWidth(const int width)
-{
- mMaxWinWidth = width;
-}
-
-void Window::setMaxHeight(const int height)
-{
- mMaxWinHeight = height;
-}
-
-void Window::setResizable(const bool r)
-{
- if ((mGrip != nullptr) == r)
- return;
-
- if (mGrip != nullptr)
- mGrip->decRef();
- if (r)
- {
- mGrip = Theme::getImageFromThemeXml("resize.xml", "");
- if (mGrip != nullptr)
- {
- mGripRect.x = mDimension.width - mGrip->getWidth() - mGripPadding;
- mGripRect.y = mDimension.height - mGrip->getHeight()
- - mGripPadding;
- }
- else
- {
- mGripRect.x = 0;
- mGripRect.y = 0;
- }
- }
- else
- {
- mGrip = nullptr;
- }
-}
-
-void Window::widgetResized(const Event &event A_UNUSED)
-{
- if (mGrip != nullptr)
- {
- mGripRect.x = mDimension.width - mGrip->getWidth() - mGripPadding;
- mGripRect.y = mDimension.height - mGrip->getHeight() - mGripPadding;
- }
-
- if (mLayout != nullptr)
- {
- const Rect area = getChildrenArea();
- int w = area.width;
- int h = area.height;
- mLayout->reflow(w, h);
- }
- if (mSkin != nullptr)
- {
- const bool showClose = mCloseWindowButton
- && (mSkin->getCloseImage(false) != nullptr);
- if (showClose)
- {
- const Image *const button = mSkin->getCloseImage(false);
- if (button != nullptr)
- {
- const int buttonWidth = button->getWidth();
- mCloseRect.x = mDimension.width - buttonWidth - mClosePadding;
- mCloseRect.y = mClosePadding;
- mCloseRect.width = buttonWidth;
- mCloseRect.height = button->getHeight();
- }
- }
- if (mStickyButton)
- {
- const Image *const button = mSkin->getStickyImage(mSticky);
- if (button != nullptr)
- {
- const int buttonWidth = button->getWidth();
- int x = mDimension.width - buttonWidth
- - mStickySpacing - mClosePadding;
-
- if (showClose)
- x -= mSkin->getCloseImage(false)->getWidth();
-
- mStickyRect.x = x;
- mStickyRect.y = mStickyPadding;
- mStickyRect.width = buttonWidth;
- mStickyRect.height = button->getHeight();
- }
- }
- }
- else
- {
- mCloseRect.x = 0;
- mCloseRect.y = 0;
- mCloseRect.width = 0;
- mCloseRect.height = 0;
- mStickyRect.x = 0;
- mStickyRect.y = 0;
- mStickyRect.width = 0;
- mStickyRect.height = 0;
- }
-
- mRedraw = true;
-}
-
-void Window::widgetMoved(const Event& event A_UNUSED)
-{
- mRedraw = true;
-}
-
-void Window::widgetHidden(const Event &event A_UNUSED)
-{
- if (isBatchDrawRenders(openGLMode))
- mVertexes->clear();
-
- mTextChunk.deleteImage();
-
- mTextChanged = true;
- mRedraw = true;
-
- if (gui != nullptr)
- gui->setCursorType(Cursor::CURSOR_POINTER);
-
- if (mFocusHandler == nullptr)
- return;
-
- for (WidgetListConstIterator it = mWidgets.begin();
- it != mWidgets.end(); ++ it)
- {
- if (mFocusHandler->isFocused(*it))
- mFocusHandler->focusNone();
- }
-}
-
-void Window::setCloseButton(const bool flag)
-{
- mCloseWindowButton = flag;
- if (flag)
- mAllowClose = true;
-}
-
-bool Window::isResizable() const
-{
- return mGrip != nullptr;
-}
-
-void Window::setStickyButton(const bool flag)
-{
- mStickyButton = flag;
-}
-
-void Window::setSticky(const bool sticky)
-{
- mSticky = sticky;
- mRedraw = true;
-}
-
-void Window::setStickyButtonLock(const bool lock)
-{
- mStickyButtonLock = lock;
- mStickyButton = lock;
-}
-
-void Window::setVisible(Visible visible)
-{
- setVisible(visible, false);
-}
-
-void Window::setVisible(const Visible visible, const bool forceSticky)
-{
- if (visible == mVisible)
- return;
-
- // Check if the window is off screen...
- if (visible == Visible_true)
- ensureOnScreen();
- else
- mResizeHandles = 0;
-
- if (mStickyButtonLock)
- {
- BasicContainer2::setVisible(visible);
- }
- else
- {
- BasicContainer2::setVisible(fromBool((!forceSticky && mSticky) ||
- visible == Visible_true, Visible));
- }
- if (visible == Visible_true)
- {
- if (mPlayVisibleSound)
- soundManager.playGuiSound(SOUND_SHOW_WINDOW);
- if (gui != nullptr)
- {
- MouseEvent *const event = reinterpret_cast<MouseEvent*>(
- gui->createMouseEvent(this));
- if (event != nullptr)
- {
- const int x = event->getX();
- const int y = event->getY();
- if (x >= 0 && x <= mDimension.width
- && y >= 0 && y <= mDimension.height)
- {
- mouseMoved(*event);
- }
- delete event;
- }
- }
- }
- else
- {
- if (mPlayVisibleSound)
- soundManager.playGuiSound(SOUND_HIDE_WINDOW);
- }
-}
-
-void Window::scheduleDelete()
-{
- windowContainer->scheduleDelete(this);
-}
-
-void Window::mousePressed(MouseEvent &event)
-{
- if (event.isConsumed())
- return;
-
- if (event.getSource() == this)
- {
- if (getParent() != nullptr)
- getParent()->moveToTop(this);
-
- mDragOffsetX = event.getX();
- mDragOffsetY = event.getY();
- mMoved = event.getY() <= CAST_S32(mTitleBarHeight);
- }
-
- const MouseButtonT button = event.getButton();
- if (button == MouseButton::LEFT)
- {
- const int x = event.getX();
- const int y = event.getY();
-
- // Handle close button
- if (mCloseWindowButton &&
- mSkin != nullptr &&
- mCloseRect.isPointInRect(x, y))
- {
- mouseResize = 0;
- mMoved = false;
- event.consume();
- close();
- return;
- }
-
- // Handle sticky button
- if (mStickyButton &&
- mSkin != nullptr &&
- mStickyRect.isPointInRect(x, y))
- {
- setSticky(!isSticky());
- mouseResize = 0;
- mMoved = false;
- event.consume();
- return;
- }
-
- // Handle window resizing
- mouseResize = getResizeHandles(event) & resizeMask;
- if (mouseResize != 0)
- event.consume();
- if (canMove())
- mMoved = (mouseResize == 0);
- else
- mMoved = false;
- }
-#ifndef DYECMD
- else if (button == MouseButton::RIGHT)
- {
- if (popupMenu != nullptr)
- {
- event.consume();
- popupMenu->showWindowPopup(this);
- }
- }
-#endif // DYECMD
-}
-
-void Window::close()
-{
- setVisible(Visible_false);
-}
-
-void Window::mouseReleased(MouseEvent &event A_UNUSED)
-{
- if ((mGrip != nullptr) && (mouseResize != 0))
- {
- mouseResize = 0;
- if (gui != nullptr)
- gui->setCursorType(Cursor::CURSOR_POINTER);
- }
-
- mMoved = false;
-}
-
-void Window::mouseEntered(MouseEvent &event)
-{
- updateResizeHandler(event);
-}
-
-void Window::mouseExited(MouseEvent &event A_UNUSED)
-{
- if ((mGrip != nullptr) && (mouseResize == 0) && (gui != nullptr))
- gui->setCursorType(Cursor::CURSOR_POINTER);
-}
-
-void Window::updateResizeHandler(MouseEvent &event)
-{
- if (gui == nullptr)
- return;
-
-#ifndef DYECMD
- if (!dragDrop.isEmpty())
- return;
-#endif // DYECMD
-
- mResizeHandles = getResizeHandles(event);
-
- // Changes the custom mouse cursor based on it's current position.
- switch (mResizeHandles & resizeMask)
- {
- case BOTTOM | RIGHT:
- case TOP | LEFT:
- gui->setCursorType(Cursor::CURSOR_RESIZE_DOWN_RIGHT);
- break;
- case TOP | RIGHT:
- case BOTTOM | LEFT:
- gui->setCursorType(Cursor::CURSOR_RESIZE_DOWN_LEFT);
- break;
- case BOTTOM:
- case TOP:
- gui->setCursorType(Cursor::CURSOR_RESIZE_DOWN);
- break;
- case RIGHT:
- case LEFT:
- gui->setCursorType(Cursor::CURSOR_RESIZE_ACROSS);
- break;
- default:
- gui->setCursorType(Cursor::CURSOR_POINTER);
- break;
- }
-}
-
-void Window::mouseMoved(MouseEvent &event)
-{
- updateResizeHandler(event);
- if ((popupManager != nullptr) && !event.isConsumed())
- {
- PopupManager::hideBeingPopup();
- PopupManager::hideTextPopup();
- }
-}
-
-bool Window::canMove() const
-{
- return !mStickyButtonLock || !mSticky;
-}
-
-void Window::mouseDragged(MouseEvent &event)
-{
- if (canMove())
- {
- if (!event.isConsumed() && event.getSource() == this)
- {
- if (isMovable() && mMoved)
- {
- setPosition(event.getX() - mDragOffsetX + getX(),
- event.getY() - mDragOffsetY + getY());
- }
-
- event.consume();
- }
- }
- else
- {
- if (!event.isConsumed() && event.getSource() == this)
- event.consume();
- return;
- }
-
- // Keep guichan window inside screen when it may be moved
- if (isMovable() && mMoved)
- {
- setPosition(std::min(mainGraphics->mWidth - mDimension.width,
- std::max(0, mDimension.x)),
- std::min(mainGraphics->mHeight - mDimension.height,
- std::max(0, mDimension.y)));
- }
-
- if ((mouseResize != 0) && !mMoved)
- {
- const int dx = event.getX() - mDragOffsetX;
- const int dy = event.getY() - mDragOffsetY;
- Rect newDim = getDimension();
-
- if ((mouseResize & (TOP | BOTTOM)) != 0)
- {
- const int newHeight = newDim.height
- + ((mouseResize & TOP) != 0 ? -dy : dy);
- newDim.height = std::min(mMaxWinHeight,
- std::max(mMinWinHeight, newHeight));
-
- if ((mouseResize & TOP) != 0)
- newDim.y -= newDim.height - getHeight();
- }
-
- if ((mouseResize & (LEFT | RIGHT)) != 0)
- {
- const int newWidth = newDim.width
- + ((mouseResize & LEFT) != 0 ? -dx : dx);
- newDim.width = std::min(mMaxWinWidth,
- std::max(mMinWinWidth, newWidth));
-
- if ((mouseResize & LEFT) != 0)
- newDim.x -= newDim.width - mDimension.width;
- }
-
- // Keep guichan window inside screen (supports resizing any side)
- if (newDim.x < 0)
- {
- newDim.width += newDim.x;
- newDim.x = 0;
- }
- if (newDim.y < 0)
- {
- newDim.height += newDim.y;
- newDim.y = 0;
- }
- if (newDim.x + newDim.width > mainGraphics->mWidth)
- newDim.width = mainGraphics->mWidth - newDim.x;
- if (newDim.y + newDim.height > mainGraphics->mHeight)
- newDim.height = mainGraphics->mHeight - newDim.y;
-
- // Update mouse offset when dragging bottom or right border
- if ((mouseResize & BOTTOM) != 0)
- mDragOffsetY += newDim.height - mDimension.height;
-
- if ((mouseResize & RIGHT) != 0)
- mDragOffsetX += newDim.width - mDimension.width;
-
- // Set the new window and content dimensions
- setDimension(newDim);
- }
-}
-
-void Window::setModal(const Modal modal)
-{
- if (mModal != modal)
- {
- mModal = modal;
- if (mModal == Modal_true)
- {
- if (gui != nullptr)
- gui->setCursorType(Cursor::CURSOR_POINTER);
- requestModalFocus();
- }
- else
- {
- releaseModalFocus();
- }
- }
-}
-
-void Window::loadWindowState()
-{
- const std::string &name = mWindowName;
- if (name.empty())
- return;
-
- setPosition(config.getValueInt(name + "WinX", mDefaultX),
- config.getValueInt(name + "WinY", mDefaultY));
-
- if (mSaveVisible)
- {
- setVisible(fromBool(config.getValueBool(name
- + "Visible", mDefaultVisible), Visible));
- }
-
- if (mStickyButton)
- {
- setSticky(config.getValueBool(name
- + "Sticky", isSticky()));
- }
-
- if (mGrip != nullptr)
- {
- int width = config.getValueInt(name + "WinWidth", mDefaultWidth);
- int height = config.getValueInt(name + "WinHeight", mDefaultHeight);
-
- if (getMinWidth() > width)
- width = getMinWidth();
- else if (getMaxWidth() < width)
- width = getMaxWidth();
- if (getMinHeight() > height)
- height = getMinHeight();
- else if (getMaxHeight() < height)
- height = getMaxHeight();
-
- setSize(width, height);
- }
- else
- {
- setSize(mDefaultWidth, mDefaultHeight);
- }
-
- // Check if the window is off screen...
- ensureOnScreen();
-
- if (viewport != nullptr)
- {
- int width = mDimension.width;
- int height = mDimension.height;
-
- if (mDimension.x + width > viewport->getWidth())
- width = viewport->getWidth() - mDimension.x;
- if (mDimension.y + height > viewport->getHeight())
- height = viewport->getHeight() - mDimension.y;
- if (width < 0)
- width = 0;
- if (height < 0)
- height = 0;
- setSize(width, height);
- }
-}
-
-void Window::saveWindowState()
-{
- // Saving X, Y and Width and Height for resizables in the config
- if (!mWindowName.empty() && mWindowName != "window")
- {
- config.setValue(mWindowName + "WinX", mDimension.x);
- config.setValue(mWindowName + "WinY", mDimension.y);
-
- if (mSaveVisible)
- config.setValue(mWindowName + "Visible", isWindowVisible());
-
- if (mStickyButton)
- config.setValue(mWindowName + "Sticky", isSticky());
-
- if (mGrip != nullptr)
- {
- if (getMinWidth() > mDimension.width)
- setWidth(getMinWidth());
- else if (getMaxWidth() < mDimension.width)
- setWidth(getMaxWidth());
- if (getMinHeight() > mDimension.height)
- setHeight(getMinHeight());
- else if (getMaxHeight() < mDimension.height)
- setHeight(getMaxHeight());
-
- config.setValue(mWindowName + "WinWidth", mDimension.width);
- config.setValue(mWindowName + "WinHeight", mDimension.height);
- }
- }
-}
-
-void Window::setDefaultSize(const int defaultX, const int defaultY,
- int defaultWidth, int defaultHeight)
-{
- if (mMinWinWidth > defaultWidth)
- defaultWidth = mMinWinWidth;
- else if (mMaxWinWidth < defaultWidth)
- defaultWidth = mMaxWinWidth;
- if (mMinWinHeight > defaultHeight)
- defaultHeight = mMinWinHeight;
- else if (mMaxWinHeight < defaultHeight)
- defaultHeight = mMaxWinHeight;
-
- mDefaultX = defaultX;
- mDefaultY = defaultY;
- mDefaultWidth = defaultWidth;
- mDefaultHeight = defaultHeight;
-}
-
-void Window::setDefaultSize()
-{
- mDefaultX = mDimension.x;
- mDefaultY = mDimension.y;
- mDefaultWidth = mDimension.width;
- mDefaultHeight = mDimension.height;
-}
-
-void Window::setDefaultSize(const int defaultWidth, const int defaultHeight,
- const ImagePosition::Type &position,
- const int offsetX, const int offsetY)
-{
- int x = 0;
- int y = 0;
-
- if (position == ImagePosition::UPPER_LEFT)
- {
- }
- else if (position == ImagePosition::UPPER_CENTER)
- {
- x = (mainGraphics->mWidth - defaultWidth) / 2;
- }
- else if (position == ImagePosition::UPPER_RIGHT)
- {
- x = mainGraphics->mWidth - defaultWidth;
- }
- else if (position == ImagePosition::LEFT)
- {
- y = (mainGraphics->mHeight - defaultHeight) / 2;
- }
- else if (position == ImagePosition::CENTER)
- {
- x = (mainGraphics->mWidth - defaultWidth) / 2;
- y = (mainGraphics->mHeight - defaultHeight) / 2;
- }
- else if (position == ImagePosition::RIGHT)
- {
- x = mainGraphics->mWidth - defaultWidth;
- y = (mainGraphics->mHeight - defaultHeight) / 2;
- }
- else if (position == ImagePosition::LOWER_LEFT)
- {
- y = mainGraphics->mHeight - defaultHeight;
- }
- else if (position == ImagePosition::LOWER_CENTER)
- {
- x = (mainGraphics->mWidth - defaultWidth) / 2;
- y = mainGraphics->mHeight - defaultHeight;
- }
- else if (position == ImagePosition::LOWER_RIGHT)
- {
- x = mainGraphics->mWidth - defaultWidth;
- y = mainGraphics->mHeight - defaultHeight;
- }
-
- mDefaultX = x - offsetX;
- mDefaultY = y - offsetY;
- mDefaultWidth = defaultWidth;
- mDefaultHeight = defaultHeight;
-}
-
-void Window::resetToDefaultSize()
-{
- setPosition(mDefaultX, mDefaultY);
- setSize(mDefaultWidth, mDefaultHeight);
- saveWindowState();
-}
-
-void Window::adjustPositionAfterResize(const int oldScreenWidth,
- const int oldScreenHeight)
-{
- // If window was aligned to the right or bottom, keep it there
- const int rightMargin = oldScreenWidth - (mDimension.x + mDimension.width);
- const int bottomMargin = oldScreenHeight
- - (mDimension.y + mDimension.height);
- if (mDimension.x > 0 && mDimension.x > rightMargin)
- mDimension.x = mainGraphics->mWidth - rightMargin - mDimension.width;
- if (mDimension.y > 0 && mDimension.y > bottomMargin)
- {
- mDimension.y = mainGraphics->mHeight
- - bottomMargin - mDimension.height;
- }
-
- ensureOnScreen();
- adjustSizeToScreen();
-}
-
-void Window::adjustSizeToScreen()
-{
- if (mGrip == nullptr)
- return;
-
- const int screenWidth = mainGraphics->mWidth;
- const int screenHeight = mainGraphics->mHeight;
- const int oldWidth = mDimension.width;
- const int oldHeight = mDimension.height;
- if (oldWidth + mDimension.x > screenWidth)
- mDimension.x = 0;
- if (oldHeight + mDimension.y > screenHeight)
- mDimension.x = 0;
- if (mDimension.width > screenWidth)
- mDimension.width = screenWidth;
- if (mDimension.height > screenHeight)
- mDimension.height = screenHeight;
- if (oldWidth != mDimension.width || oldHeight != mDimension.height)
- widgetResized(Event(this));
-}
-
-int Window::getResizeHandles(const MouseEvent &event)
-{
- if (event.getX() < 0 || event.getY() < 0)
- return 0;
-
- int resizeHandles = 0;
- const unsigned y = event.getY();
- const unsigned x = event.getX();
- if (mCloseRect.isPointInRect(x, y))
- return CLOSE;
-
- if (!mStickyButtonLock || !mSticky)
- {
- if ((mGrip != nullptr) &&
- (y > mTitleBarHeight ||
- (CAST_S32(y) < mPadding &&
- CAST_S32(mTitleBarHeight) > mPadding)))
- {
- if (!getWindowArea().isPointInRect(x, y)
- && event.getSource() == this)
- {
- resizeHandles |= (x > mDimension.width - resizeBorderWidth)
- ? RIGHT : (x < resizeBorderWidth) ? LEFT : 0;
- resizeHandles |= (y > mDimension.height - resizeBorderWidth)
- ? BOTTOM : (y < resizeBorderWidth) ? TOP : 0;
- }
- if (x >= CAST_U32(mGripRect.x)
- && y >= CAST_U32(mGripRect.y))
- {
- mDragOffsetX = x;
- mDragOffsetY = y;
- resizeHandles |= BOTTOM | RIGHT;
- }
- }
- }
-
- return resizeHandles;
-}
-
-bool Window::isResizeAllowed(const MouseEvent &event) const
-{
- const int y = event.getY();
-
- if ((mGrip != nullptr) &&
- (y > CAST_S32(mTitleBarHeight) ||
- y < mPadding))
- {
- const int x = event.getX();
-
- if (!getWindowArea().isPointInRect(x, y) && event.getSource() == this)
- return true;
-
- if (x >= mGripRect.x && y >= mGripRect.y)
- return true;
- }
-
- return false;
-}
-
-Layout &Window::getLayout()
-{
- if (mLayout == nullptr)
- mLayout = new Layout;
- return *mLayout;
-}
-
-void Window::clearLayout()
-{
- clear();
-
- // Recreate layout instance when one is present
- if (mLayout != nullptr)
- {
- delete mLayout;
- mLayout = new Layout;
- }
-}
-
-LayoutCell &Window::place(const int x, const int y, Widget *const wg,
- const int w, const int h)
-{
- add(wg);
- return getLayout().place(wg, x, y, w, h);
-}
-
-ContainerPlacer Window::getPlacer(const int x, const int y)
-{
- return ContainerPlacer(this, &getLayout().at(x, y));
-}
-
-void Window::reflowLayout(int w, int h)
-{
- if (mLayout == nullptr)
- return;
-
- mLayout->reflow(w, h);
- delete2(mLayout);
- setContentSize(w, h);
-}
-
-void Window::redraw()
-{
- if (mLayout != nullptr)
- {
- const Rect area = getChildrenArea();
- int w = area.width;
- int h = area.height;
- mLayout->reflow(w, h);
- }
-}
-
-void Window::center()
-{
- setLocationRelativeTo(getParent());
-}
-
-void Window::centerHorisontally()
-{
- setLocationHorisontallyRelativeTo(getParent());
-}
-
-void Window::ensureOnScreen()
-{
- // Skip when a window hasn't got any size initialized yet
- if (mDimension.width == 0 && mDimension.height == 0)
- return;
-
- // Check the left and bottom screen boundaries
- if (mDimension.x + mDimension.width > mainGraphics->mWidth)
- mDimension.x = mainGraphics->mWidth - mDimension.width;
- if (mDimension.y + mDimension.height > mainGraphics->mHeight)
- mDimension.y = mainGraphics->mHeight - mDimension.height;
-
- // But never allow the windows to disappear in to the right and top
- if (mDimension.x < 0)
- mDimension.x = 0;
- if (mDimension.y < 0)
- mDimension.y = 0;
-}
-
-Rect Window::getWindowArea() const
-{
- return Rect(mPadding,
- mPadding,
- mDimension.width - mPadding * 2,
- mDimension.height - mPadding * 2);
-}
-
-int Window::getOption(const std::string &name, const int def) const
-{
- if (mSkin != nullptr)
- {
- const int val = mSkin->getOption(name);
- if (val != 0)
- return val;
- return def;
- }
- return def;
-}
-
-bool Window::getOptionBool(const std::string &name, const bool def) const
-{
- if (mSkin != nullptr)
- return mSkin->getOption(name, static_cast<int>(def)) != 0;
- return def;
-}
-
-Rect Window::getChildrenArea()
-{
- return Rect(mPadding,
- mTitleBarHeight,
- mDimension.width - mPadding * 2,
- mDimension.height - mPadding - mTitleBarHeight);
-}
-
-void Window::resizeToContent()
-{
- int w = 0;
- int h = 0;
- for (WidgetListConstIterator it = mWidgets.begin();
- it != mWidgets.end(); ++ it)
- {
- const Widget *const widget = *it;
- const int x = widget->getX();
- const int y = widget->getY();
- const int width = widget->getWidth();
- const int height = widget->getHeight();
- if (x + width > w)
- w = x + width;
-
- if (y + height > h)
- h = y + height;
- }
-
- setSize(w + 2 * mPadding,
- h + mPadding + mTitleBarHeight);
-}
-
-#ifdef USE_PROFILER
-void Window::logic()
-{
- BLOCK_START("Window::logic")
- logicChildren();
- BLOCK_END("Window::logic")
-}
-#endif // USE_PROFILER
diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h
deleted file mode 100644
index d089680af..000000000
--- a/src/gui/widgets/window.h
+++ /dev/null
@@ -1,725 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GUI_WIDGETS_WINDOW_H
-#define GUI_WIDGETS_WINDOW_H
-
-#include "enums/simpletypes/modal.h"
-#include "enums/simpletypes/move.h"
-
-#include "enums/resources/imageposition.h"
-
-#include "gui/fonts/textchunk.h"
-
-#include "gui/widgets/basiccontainer2.h"
-
-#include "listeners/mouselistener.h"
-#include "listeners/widgetlistener.h"
-
-#include "render/graphics.h"
-
-#include "localconsts.h"
-
-class ContainerPlacer;
-class ImageCollection;
-class Layout;
-class LayoutCell;
-class Skin;
-class WindowContainer;
-
-/**
- * A window. This window can be dragged around and has a title bar. Windows are
- * invisible by default.
- *
- * \ingroup GUI
- */
-class Window notfinal : public BasicContainer2,
- public MouseListener,
- public WidgetListener
-{
- public:
- /**
- * Constructor. Initializes the title to the given text and hooks
- * itself into the window container.
- *
- * @param caption The initial window title, "Window" by default.
- * @param modal Block input to other windows.
- * @param parent The parent window. This is the window standing above
- * this one in the window hiearchy. When reordering,
- * a window will never go below its parent window.
- * @param skin The location where the window's skin XML can be found.
- */
- explicit Window(const std::string &caption = "Window",
- const Modal modal = Modal_false,
- Window *const parent = nullptr,
- std::string skin = "");
-
- A_DELETE_COPY(Window)
-
- /**
- * Destructor. Deletes all the added widgets.
- */
- virtual ~Window();
-
- /**
- * Sets the window container to be used by new windows.
- */
- static void setWindowContainer(WindowContainer *const windowContainer);
-
- /**
- * Draws the window.
- */
- void draw(Graphics *const graphics) override A_NONNULL(2);
-
- void safeDraw(Graphics *const graphics) override A_NONNULL(2);
-
- /**
- * Sets the size of this window.
- */
- void setContentSize(int width, int height);
-
- /**
- * Sets the location relative to the given widget.
- */
- void setLocationRelativeTo(const Widget *const widget);
-
- /**
- * Sets the location relative to the given widget (only horisontally)
- */
- void setLocationHorisontallyRelativeTo(const Widget
- *const widget);
-
- /**
- * Sets the location relative to the given enumerated position.
- */
- void setLocationRelativeTo(const ImagePosition::Type &position,
- int offsetX = 0, int offsetY = 0);
-
- /**
- * Sets whether or not the window can be resized.
- */
- void setResizable(const bool resize);
-
- void redraw();
-
- /**
- * Called whenever the widget changes size.
- */
- void widgetResized(const Event &event) override;
-
- void widgetMoved(const Event& event) override;
-
- /**
- * Called whenever the widget is hidden.
- */
- void widgetHidden(const Event &event) override;
-
- /**
- * Sets whether or not the window has a close button.
- */
- void setCloseButton(const bool flag);
-
- bool getCloseButton() const noexcept2 A_WARN_UNUSED
- { return mCloseWindowButton; }
-
- void setAllowClose(const bool b)
- { mAllowClose = b; }
-
- bool getAlowClose() const noexcept2 A_WARN_UNUSED
- { return mCloseWindowButton || mAllowClose; }
-
- /**
- * Returns whether the window can be resized.
- */
- bool isResizable() const A_WARN_UNUSED;
-
- /**
- * Sets the minimum width of the window.
- */
- void setMinWidth(const int width);
-
- int getMinWidth() const noexcept2 A_WARN_UNUSED
- { return mMinWinWidth; }
-
- /**
- * Sets the minimum height of the window.
- */
- void setMinHeight(const int height);
-
- int getMinHeight() const noexcept2 A_WARN_UNUSED
- { return mMinWinHeight; }
-
- /**
- * Sets the maximum width of the window.
- */
- void setMaxWidth(const int width);
-
- int getMaxWidth() const noexcept2 A_WARN_UNUSED
- { return mMaxWinWidth; }
-
- /**
- * Sets the minimum height of the window.
- */
- void setMaxHeight(const int height);
-
- int getMaxHeight() const noexcept2 A_WARN_UNUSED
- { return mMaxWinHeight; }
-
- /**
- * Sets flag to show a title or not.
- */
- void setShowTitle(bool flag)
- { mShowTitle = flag; }
-
- /**
- * Sets whether or not the window has a sticky button.
- */
- void setStickyButton(const bool flag);
-
- /**
- * Sets whether the window is sticky. A sticky window will not have
- * its visibility set to false on a general setVisible(false) call.
- * Use this to set the default before you call loadWindowState().
- */
- void setSticky(const bool sticky);
-
- /**
- * Returns whether the window is sticky.
- */
- bool isSticky() const noexcept2 A_WARN_UNUSED
- { return mSticky; }
-
- /**
- * Sets whether the window sticky mean window locked or not.
- */
- void setStickyButtonLock(const bool sticky);
-
- /**
- * Returns whether the window sticky locking window.
- */
- bool isStickyButtonLock() const noexcept2 A_WARN_UNUSED
- { return mStickyButtonLock; }
-
- /**
- * Overloads window setVisible by Guichan to allow sticky window
- * handling.
- */
- virtual void setVisible(Visible visible);
-
- /**
- * Overloads window setVisible by Guichan to allow sticky window
- * handling, or not, if you force the sticky state.
- */
- void setVisible(const Visible visible, const bool forceSticky);
-
- /**
- * Returns whether the window is visible by default.
- */
- bool isDefaultVisible() const noexcept2 A_WARN_UNUSED
- { return mDefaultVisible; }
-
- /**
- * Sets whether the window is visible by default.
- */
- void setDefaultVisible(const bool save)
- { mDefaultVisible = save; }
-
- /**
- * Returns whether the window will save it's visibility.
- */
- bool willSaveVisible() const
- { return mSaveVisible; }
-
- /**
- * Sets whether the window will save it's visibility.
- */
- void setSaveVisible(const bool save)
- { mSaveVisible = save; }
-
- void postInit() override;
-
- /**
- * Returns the parent window.
- *
- * @return The parent window or <code>NULL</code> if there is none.
- */
- Window *getParentWindow() const
- { return mParentWindow; }
-
- /**
- * Schedule this window for deletion. It will be deleted at the start
- * of the next logic update.
- */
- virtual void scheduleDelete();
-
- /**
- * Starts window resizing when appropriate.
- */
- void mousePressed(MouseEvent &event) override;
-
- /**
- * Implements window resizing and makes sure the window is not
- * dragged/resized outside of the screen.
- */
- void mouseDragged(MouseEvent &event) override;
-
- /**
- * Implements custom cursor image changing context, based on mouse
- * relative position.
- */
- void mouseMoved(MouseEvent &event) override;
-
- /**
- * When the mouse button has been let go, this ensures that the mouse
- * custom cursor is restored back to it's standard image.
- */
- void mouseReleased(MouseEvent &event) override;
-
- /**
- * When the mouse leaves the window this ensures that the custom cursor
- * is restored back to it's standard image.
- */
- void mouseExited(MouseEvent &event) override;
-
- void mouseEntered(MouseEvent &event) override;
-
- void updateResizeHandler(MouseEvent &event);
-
- /**
- * Sets the name of the window. This is not the window title.
- */
- void setWindowName(const std::string &name)
- { mWindowName = name; }
-
- /**
- * Returns the name of the window. This is not the window title.
- */
- const std::string &getWindowName() const noexcept2 A_WARN_UNUSED
- { return mWindowName; }
-
- /**
- * Reads the position (and the size for resizable windows) in the
- * configuration based on the given string.
- * Uses the default values when config values are missing.
- * Don't forget to set these default values and resizable before
- * calling this function.
- */
- void loadWindowState();
-
- /**
- * Saves the window state so that when the window is reloaded, it'll
- * maintain its previous state and location.
- */
- void saveWindowState();
-
- /**
- * Set the default win pos and size.
- * (which can be different of the actual ones.)
- */
- void setDefaultSize(const int defaultX, const int defaultY,
- int defaultWidth, int defaultHeight);
-
- /**
- * Set the default win pos and size to the current ones.
- */
- void setDefaultSize();
-
- /**
- * Set the default win pos and size.
- * (which can be different of the actual ones.)
- * This version of setDefaultSize sets the window's position based
- * on a relative enumerated position, rather than a coordinate position.
- */
- void setDefaultSize(const int defaultWidth, const int defaultHeight,
- const ImagePosition::Type &position,
- const int offsetx = 0, const int offsetY = 0);
-
- /**
- * Reset the win pos and size to default. Don't forget to set defaults
- * first.
- */
- virtual void resetToDefaultSize();
-
- /**
- * Adjusts the window position after the application window has been
- * resized.
- */
- void adjustPositionAfterResize(const int oldScreenWidth,
- const int oldScreenHeight);
-
- /**
- * Gets the layout handler for this window.
- */
- Layout &getLayout() A_WARN_UNUSED;
-
- /**
- * Clears the window's layout (useful for redesigning the window). Does
- * not delete the widgets!
- */
- void clearLayout();
-
- /**
- * Computes the position of the widgets according to the current
- * layout. Resizes the window so that the layout fits. Deletes the
- * layout.
- * @param w if non-zero, force the window to this width.
- * @param h if non-zero, force the window to this height.
- * @note This function is meant to be called with fixed-size windows.
- */
- void reflowLayout(int w = 0, int h = 0);
-
- /**
- * Adds a widget to the window and sets it at given cell.
- */
- LayoutCell &place(const int x, const int y, Widget *const wg,
- const int w = 1, const int h = 1);
-
- /**
- * Returns a proxy for adding widgets in an inner table of the layout.
- */
- ContainerPlacer getPlacer(const int x, const int y) A_WARN_UNUSED;
-
- /**
- * Positions the window in the center of it's parent.
- */
- void center();
-
- /**
- * Positions the window in the horisontal center of it's parent.
- */
- void centerHorisontally();
-
- /**
- * Overrideable functionality for when the window is to close. This
- * allows for class implementations to clean up or do certain actions
- * on window close they couldn't do otherwise.
- */
- virtual void close();
-
- /**
- * Allows the windows modal status to change
- */
- void setModal(const Modal modal);
-
- Rect getWindowArea() const A_WARN_UNUSED;
-
- bool isResizeAllowed(const MouseEvent &event) const A_WARN_UNUSED;
-
- void setCaptionFont(Font *font)
- { mCaptionFont = font; }
-
- void enableVisibleSound(bool b)
- { mPlayVisibleSound = b; }
-
- bool isWindowVisible() const noexcept2 A_WARN_UNUSED
- { return mVisible == Visible_true; }
-
- /**
- * Sets the padding of the window. The padding is the distance between the
- * window border and the content.
- *
- * @param padding The padding of the window.
- * @see getPadding
- */
- void setPadding(int padding)
- { mPadding = padding; }
-
- /**
- * Gets the padding of the window. The padding is the distance between the
- * window border and the content.
- *
- * @return The padding of the window.
- * @see setPadding
- */
- int getPadding() const
- { return mPadding; }
-
- /**
- * Sets the title bar height.
- *
- * @param height The title height value.
- * @see getTitleBarHeight
- */
- void setTitleBarHeight(unsigned int height)
- { mTitleBarHeight = height; }
-
- /**
- * Gets the title bar height.
- *
- * @return The title bar height.
- * @see setTitleBarHeight
- */
- unsigned int getTitleBarHeight() const
- { return mTitleBarHeight; }
-
- /**
- * Sets the caption of the window.
- *
- * @param caption The caption of the window.
- * @see getCaption
- */
- void setCaption(const std::string& caption)
- { mCaption = caption; mTextChanged = true; }
-
- /**
- * Gets the caption of the window.
- *
- * @return the caption of the window.
- * @see setCaption
- */
- const std::string& getCaption() const
- { return mCaption; }
-
- /**
- * Sets the alignment of the caption.
- *
- * @param alignment The alignment of the caption.
- * @see getAlignment, Graphics
- */
- void setAlignment(Graphics::Alignment alignment)
- { mAlignment = alignment; }
-
- /**
- * Gets the alignment of the caption.
- *
- * @return The alignment of caption.
- * @see setAlignment, Graphics
- */
- Graphics::Alignment getAlignment() const
- { return mAlignment; }
-
- /**
- * Sets the window to be moveble or not.
- *
- * @param movable True if the window should be movable, false otherwise.
- * @see isMovable
- */
- void setMovable(Move movable)
- { mMovable = movable; }
-
- /**
- * Checks if the window is movable.
- *
- * @return True if the window is movable, false otherwise.
- * @see setMovable
- */
- bool isMovable() const
- { return mMovable == Move_true; }
-
- Rect getChildrenArea() override;
-
- /**
- * Resizes the window to fit the content.
- */
- virtual void resizeToContent();
-
-#ifdef USE_PROFILER
- virtual void logic();
-#endif // USE_PROFILER
-
- protected:
- bool canMove() const A_WARN_UNUSED;
-
- int getOption(const std::string &name,
- const int def = 0) const A_WARN_UNUSED;
-
- bool getOptionBool(const std::string &name,
- const bool def = false) const A_WARN_UNUSED;
-
- void setTitlePadding(const int p) noexcept2
- { mTitlePadding = p; }
-
- int getTitlePadding() const noexcept2 A_WARN_UNUSED
- { return mTitlePadding; }
-
- /**
- * Holds the caption of the window.
- */
- std::string mCaption;
-
- /**
- * Holds the alignment of the caption.
- */
- Graphics::Alignment mAlignment;
-
- /**
- * Holds the padding of the window.
- */
- int mPadding;
-
- /**
- * Holds the title bar height of the window.
- */
- unsigned int mTitleBarHeight;
-
- /**
- * True if the window is movable, false otherwise.
- */
- Move mMovable;
-
- /**
- * Holds a drag offset as an x coordinate where the drag of the window
- * started if the window is being dragged. It's used to move the window
- * correctly when dragged.
- */
- int mDragOffsetX;
-
- /**
- * Holds a drag offset as an y coordinate where the drag of the window
- * started if the window is being dragged. It's used to move the window
- * correctly when dragged.
- */
- int mDragOffsetY;
-
- /**
- * True if the window is being moved, false otherwise.
- */
- bool mMoved;
-
- Skin *mSkin; /**< Skin in use by this window */
- int mDefaultX; /**< Default window X position */
- int mDefaultY; /**< Default window Y position */
- int mDefaultWidth; /**< Default window width */
- int mDefaultHeight; /**< Default window height */
- int mCaptionOffsetX;
- int mCaptionOffsetY;
- bool mShowTitle; /**< Window has a title bar */
- bool mLastRedraw;
-
- private:
- enum ResizeHandles
- {
- TOP = 0x01,
- RIGHT = 0x02,
- BOTTOM = 0x04,
- LEFT = 0x08,
- CLOSE = 0x10
- };
-
- /**
- * Ensures the window is on the screen, moving it if necessary. This is
- * used by loadWindowState and setVisible(true), and when the screen
- * is resized.
- */
- void ensureOnScreen();
-
- void adjustSizeToScreen();
-
- /**
- * Determines if the mouse is in a resize area and returns appropriate
- * resize handles. Also initializes drag offset in case the resize
- * grip is used.
- *
- * @see ResizeHandles
- */
- int getResizeHandles(const MouseEvent &event) A_WARN_UNUSED;
-
- Image *mGrip; /**< Resize grip */
- Window *mParentWindow; /**< The parent window */
- Layout *mLayout; /**< Layout handler */
- Rect mCloseRect; /**< Close button rectangle */
- Rect mStickyRect; /**< Sticky button rectangle */
- Rect mGripRect; /**< Resize grip rectangle */
- TextChunk mTextChunk;
- std::string mWindowName; /**< Name of the window */
- int mMinWinWidth; /**< Minimum window width */
- int mMinWinHeight; /**< Minimum window height */
- int mMaxWinWidth; /**< Maximum window width */
- int mMaxWinHeight; /**< Maximum window height */
-
- static int mouseResize; /**< Active resize handles */
- static int windowInstances; /**< Number of Window instances */
-
-
- /**
- * The width of the resize border. Is independent of the actual window
- * border width, and determines mostly the size of the corner area
- * where two borders are moved at the same time.
- */
- static const unsigned resizeBorderWidth = 10;
- ImageCollection *mVertexes A_NONNULLPOINTER;
- Graphics::Alignment mCaptionAlign;
- int mTitlePadding;
- int mGripPadding;
- int mResizeHandles;
- int mOldResizeHandles;
- int mClosePadding;
- int mStickySpacing;
- int mStickyPadding;
- Font *mCaptionFont A_NONNULLPOINTER;
- Modal mModal; /**< Window is modal */
- bool mCloseWindowButton; /**< Window has a close button */
- bool mDefaultVisible; /**< Window's default visibility */
- bool mSaveVisible; /**< Window will save visibility */
- bool mStickyButton; /**< Window has a sticky button */
- bool mSticky; /**< Window resists hiding*/
- bool mStickyButtonLock; /**< Window locked if sticky enabled*/
- bool mPlayVisibleSound;
- bool mInit;
- bool mTextChanged;
- bool mAllowClose;
-};
-
-#endif // GUI_WIDGETS_WINDOW_H
diff --git a/src/gui/widgets/windowcontainer.cpp b/src/gui/widgets/windowcontainer.cpp
deleted file mode 100644
index e054e27ad..000000000
--- a/src/gui/widgets/windowcontainer.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 "gui/widgets/windowcontainer.h"
-
-#include "gui/widgets/window.h"
-
-#include "utils/dtor.h"
-#include "utils/foreach.h"
-
-#include "debug.h"
-
-WindowContainer *windowContainer = nullptr;
-
-WindowContainer::WindowContainer(const Widget2 *const widget) :
- Container(widget),
- mDeathList()
-{
-}
-
-void WindowContainer::slowLogic()
-{
- delete_all(mDeathList);
- mDeathList.clear();
-}
-
-void WindowContainer::scheduleDelete(Widget *const widget)
-{
- if (widget != nullptr)
- mDeathList.push_back(widget);
-}
-
-void WindowContainer::adjustAfterResize(const int oldScreenWidth,
- const int oldScreenHeight)
-{
- FOR_EACH (WidgetListIterator, i, mWidgets)
- {
- if (Window *const window = dynamic_cast<Window*>(*i))
- window->adjustPositionAfterResize(oldScreenWidth, oldScreenHeight);
- }
-}
-
-void WindowContainer::moveWidgetAfter(Widget *const after,
- Widget *const widget)
-{
- const WidgetListIterator widgetIter = std::find(
- mWidgets.begin(), mWidgets.end(), widget);
-
- if (widgetIter != mWidgets.end())
- {
- WidgetListIterator afterIter = std::find(
- mWidgets.begin(), mWidgets.end(), after);
-
- if (afterIter != mWidgets.end())
- {
- ++ afterIter;
- mWidgets.erase(widgetIter);
- mWidgets.insert(afterIter, widget);
- }
- }
-
- const WidgetListIterator widgetIter2 = std::find(
- mLogicWidgets.begin(), mLogicWidgets.end(), widget);
-
- if (widgetIter2 != mLogicWidgets.end())
- {
- WidgetListIterator afterIter = std::find(
- mLogicWidgets.begin(), mLogicWidgets.end(), after);
-
- if (afterIter != mLogicWidgets.end())
- {
- ++ afterIter;
- mLogicWidgets.erase(widgetIter2);
- mLogicWidgets.insert(afterIter, widget);
- }
- }
-}
-
-#ifdef USE_PROFILER
-void WindowContainer::draw(Graphics *const graphics)
-{
- BLOCK_START("WindowContainer::draw")
- Container::draw(graphics);
- BLOCK_END("WindowContainer::draw")
-}
-#endif // USE_PROFILER
diff --git a/src/gui/widgets/windowcontainer.h b/src/gui/widgets/windowcontainer.h
deleted file mode 100644
index 98a62ac28..000000000
--- a/src/gui/widgets/windowcontainer.h
+++ /dev/null
@@ -1,74 +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_WINDOWCONTAINER_H
-#define GUI_WIDGETS_WINDOWCONTAINER_H
-
-#include "gui/widgets/container.h"
-
-/**
- * A window container. This container adds functionality for more convenient
- * widget (windows in particular) destruction.
- *
- * \ingroup GUI
- */
-class WindowContainer notfinal : public Container
-{
- public:
- explicit WindowContainer(const Widget2 *const widget);
-
- A_DELETE_COPY(WindowContainer)
-
- void slowLogic();
-
- /**
- * Schedule a widget for deletion. It will be deleted at the start of
- * the next logic update.
- */
- void scheduleDelete(Widget *const widget);
-
- /**
- * Ensures that all visible windows are on the screen after the screen
- * has been resized.
- */
- void adjustAfterResize(const int oldScreenWidth,
- const int oldScreenHeight);
-
- void moveWidgetAfter(Widget *const before,
- Widget *const widget);
-
-#ifdef USE_PROFILER
- void draw(Graphics *const graphics) override A_NONNULL(2);
-#endif // UNITTESTS
-
- private:
- /**
- * List of widgets that are scheduled to be deleted.
- */
- typedef STD_VECTOR<Widget*> Widgets;
- typedef Widgets::iterator WidgetIterator;
- Widgets mDeathList;
-};
-
-extern WindowContainer *windowContainer;
-
-#endif // GUI_WIDGETS_WINDOWCONTAINER_H
diff --git a/src/gui/windowmanager.cpp b/src/gui/windowmanager.cpp
deleted file mode 100644
index c7b81d1a9..000000000
--- a/src/gui/windowmanager.cpp
+++ /dev/null
@@ -1,498 +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 "gui/windowmanager.h"
-
-#include "client.h"
-#include "configuration.h"
-#include "game.h"
-#include "main.h"
-#include "settings.h"
-#include "spellmanager.h"
-
-#include "fs/virtfs/tools.h"
-
-#include "gui/gui.h"
-#include "gui/userpalette.h"
-
-#include "gui/shortcut/spellshortcut.h"
-
-#include "gui/popups/textpopup.h"
-
-#ifdef DYECMD
-#include "render/graphics.h"
-#else // DYECMD
-#include "gui/popups/beingpopup.h"
-#include "gui/popups/itempopup.h"
-#include "gui/popups/popupmenu.h"
-#include "gui/popups/skillpopup.h"
-#include "gui/popups/spellpopup.h"
-#include "gui/popups/textboxpopup.h"
-
-#include "gui/windows/chatwindow.h"
-#include "gui/windows/debugwindow.h"
-#include "gui/windows/didyouknowwindow.h"
-#include "gui/windows/equipmentwindow.h"
-#include "gui/windows/helpwindow.h"
-#include "gui/windows/setupwindow.h"
-#include "gui/windows/skilldialog.h"
-#include "gui/windows/questswindow.h"
-
-#include "gui/widgets/tabs/chat/chattab.h"
-
-#include "utils/gettext.h"
-#endif // DYECMD
-
-#include "gui/widgets/createwidget.h"
-#include "gui/widgets/desktop.h"
-
-#include "input/touch/touchmanager.h"
-
-#include "utils/delete2.h"
-#include "utils/sdlcheckutils.h"
-#include "utils/sdlhelper.h"
-#ifdef __native_client__
-#include "utils/naclmessages.h"
-#endif // __native_client__
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#ifdef ANDROID
-#ifndef USE_SDL2
-#include <SDL_screenkeyboard.h>
-#endif // USE_SDL2
-#endif // ANDROID
-
-#ifdef USE_SDL2
-#include <SDL2_framerate.h>
-#else // USE_SDL2
-#include <SDL_framerate.h>
-#endif // USE_SDL2
-
-#include <SDL_image.h>
-
-#ifdef WIN32
-#include <SDL_syswm.h>
-#endif // WIN32
-PRAGMA48(GCC diagnostic pop)
-
-#include "debug.h"
-
-FPSmanager fpsManager;
-
-namespace
-{
- SDL_Surface *mIcon(nullptr);
-#ifndef USE_SDL2
- int mKeyboardHeight(0);
-#endif // USE_SDL2
-
- bool mIsMinimized(false);
- bool mNewMessageFlag(false);
-} // namespace
-
-void WindowManager::init()
-{
- // Initialize frame limiting
- fpsManager.framecount = 0;
- fpsManager.rateticks = 0;
- fpsManager.lastticks = 0;
- fpsManager.rate = 0;
-}
-
-void WindowManager::createWindows()
-{
- userPalette = new UserPalette;
-#ifndef DYECMD
- CREATEWIDGETV0(setupWindow, SetupWindow);
- CREATEWIDGETV0(helpWindow, HelpWindow);
- CREATEWIDGETV0(didYouKnowWindow, DidYouKnowWindow);
- CREATEWIDGETV0(popupMenu, PopupMenu);
- CREATEWIDGETV0(beingPopup, BeingPopup);
- CREATEWIDGETV0(textBoxPopup, TextBoxPopup);
- CREATEWIDGETV0(itemPopup, ItemPopup);
- CREATEWIDGETV0(spellPopup, SpellPopup);
- CREATEWIDGETV0(skillPopup, SkillPopup);
- delete2(debugChatTab);
- if (chatWindow != nullptr)
- {
- chatWindow->scheduleDelete();
- chatWindow = nullptr;
- }
- CREATEWIDGETV(chatWindow, ChatWindow,
- "DebugChat");
- // TRANSLATORS: chat tab header
- debugChatTab = new ChatTab(chatWindow, _("Debug"), "",
- "#Debug", ChatTabType::DEBUG);
- debugChatTab->setAllowHighlight(false);
- chatWindow->setVisible(Visible_false);
- if (debugWindow != nullptr)
- {
- debugWindow->scheduleDelete();
- debugWindow = nullptr;
- }
- CREATEWIDGETV(debugWindow, DebugWindow,
- "DebugDebug");
-#endif // DYECMD
-
- CREATEWIDGETV0(textPopup, TextPopup);
-}
-
-void WindowManager::createValidateWindows()
-{
-#ifndef DYECMD
- CREATEWIDGETV0(skillDialog, SkillDialog);
- skillDialog->loadSkills();
- CREATEWIDGETV(beingEquipmentWindow, EquipmentWindow,
- nullptr, nullptr, true);
- CREATEWIDGETV0(questsWindow, QuestsWindow);
-#endif // DYECMD
-}
-
-void WindowManager::deleteValidateWindows()
-{
-#ifndef DYECMD
- delete2(skillDialog);
- delete2(beingEquipmentWindow);
- delete2(questsWindow);
-#endif // DYECMD
-}
-
-void WindowManager::deleteWindows()
-{
-#ifndef DYECMD
- delete2(textBoxPopup);
- delete2(beingPopup);
- delete2(itemPopup);
- delete2(spellPopup);
- delete2(skillPopup);
- delete2(popupMenu);
- delete2(didYouKnowWindow);
- delete2(helpWindow);
- delete2(setupWindow);
- delete2(userPalette);
- delete2(spellManager)
- delete2(spellShortcut)
-
- delete2(debugChatTab);
- delete2(chatWindow);
- delete2(debugWindow);
-#endif // DYECMD
-
- delete2(textPopup);
-}
-
-void WindowManager::initTitle()
-{
- if (settings.options.test.empty())
- {
- settings.windowCaption = strprintf("%s %s",
- branding.getStringValue("appName").c_str(),
- SMALL_VERSION);
- }
- else
- {
- settings.windowCaption = strprintf(
- "Please wait - VIDEO MODE TEST - %s %s - Please wait",
- branding.getStringValue("appName").c_str(),
- SMALL_VERSION);
- }
-
- SDL::SetWindowTitle(mainGraphics->getWindow(),
- settings.windowCaption.c_str());
-}
-
-void WindowManager::updateTitle()
-{
- std::string str;
- if (settings.login.empty())
- str = settings.serverName;
- else
- str.append(settings.login).append(" ").append(settings.serverName);
- if (str.empty())
- {
- settings.windowCaption = strprintf("%s %s",
- branding.getStringValue("appName").c_str(),
- SMALL_VERSION);
- }
- else
- {
- settings.windowCaption = strprintf("%s %s - %s",
- branding.getStringValue("appName").c_str(),
- SMALL_VERSION,
- str.c_str());
- }
- SDL::SetWindowTitle(mainGraphics->getWindow(),
- settings.windowCaption.c_str());
-}
-
-void WindowManager::setFramerate(const unsigned int fpsLimit)
-{
- if (fpsLimit == 0u)
- return;
-
- if (!settings.limitFps)
- return;
-
- SDL_setFramerate(&fpsManager, fpsLimit);
-}
-
-int WindowManager::getFramerate()
-{
- if (!settings.limitFps)
- return 0;
-
- return SDL_getFramerate(&fpsManager);
-}
-
-void WindowManager::doResizeVideo(const int actualWidth,
- const int actualHeight,
- const bool always)
-{
- if (!always
- && mainGraphics->mActualWidth == actualWidth
- && mainGraphics->mActualHeight == actualHeight)
- {
- return;
- }
-
-#ifdef __native_client__
- naclPostMessage("resize-window",
- strprintf("%d,%d", actualWidth, actualHeight));
-#else // __native_client__
-
- resizeVideo(actualWidth, actualHeight, always);
-#endif // __native_client__
-}
-
-void WindowManager::resizeVideo(int actualWidth,
- int actualHeight,
- const bool always)
-{
- // Keep a minimum size. This isn't adhered to by the actual window, but
- // it keeps some window positions from getting messed up.
- actualWidth = std::max(470, actualWidth);
- actualHeight = std::max(320, actualHeight);
-
- if (mainGraphics == nullptr)
- return;
- if (!always
- && mainGraphics->mActualWidth == actualWidth
- && mainGraphics->mActualHeight == actualHeight)
- {
- return;
- }
-
- if (mainGraphics->resizeScreen(actualWidth, actualHeight))
- {
- const int width = mainGraphics->mWidth;
- const int height = mainGraphics->mHeight;
- touchManager.resize(width, height);
-
- if (gui != nullptr)
- gui->videoResized();
-
- if (desktop != nullptr)
- desktop->setSize(width, height);
-
- client->moveButtons(width);
-
-#ifndef DYECMD
- Game *const game = Game::instance();
- if (game != nullptr)
- Game::videoResized(width, height);
-#endif // DYECMD
-
- if (gui != nullptr)
- gui->draw();
-
- config.setValue("screenwidth", actualWidth);
- config.setValue("screenheight", actualHeight);
- }
-}
-
-bool WindowManager::setFullScreen(const bool fs)
-{
-#ifdef __native_client__
- naclPostMessage("set-fullscreen",
- fs ? "on" : "off");
- return true;
-#else // __native_client__
-
- if (mainGraphics == nullptr)
- return false;
- return mainGraphics->setFullscreen(fs);
-#endif // __native_client__
-}
-
-void WindowManager::applyGrabMode()
-{
- SDL::grabInput(mainGraphics->getWindow(),
- config.getBoolValue("grabinput"));
-}
-
-void WindowManager::applyGamma()
-{
- if (config.getBoolValue("enableGamma"))
- {
- SDL::setGamma(mainGraphics->getWindow(),
- config.getFloatValue("gamma"));
- }
-}
-
-void WindowManager::applyVSync()
-{
- const int val = config.getIntValue("vsync");
- if (val > 0 && val < 2)
- SDL::setVsync(val);
-}
-
-void WindowManager::applyKeyRepeat()
-{
-#ifndef USE_SDL2
- SDL_EnableKeyRepeat(config.getIntValue("repeateDelay"),
- config.getIntValue("repeateInterval"));
-#endif // USE_SDL2
-}
-
-void WindowManager::applyScale()
-{
- const int scale = config.getIntValue("scale");
- if (mainGraphics->getScale() == scale)
- return;
- mainGraphics->setScale(scale);
- doResizeVideo(mainGraphics->mActualWidth,
- mainGraphics->mActualHeight,
- true);
-}
-
-void WindowManager::setIsMinimized(const bool n)
-{
- mIsMinimized = n;
- if (!n && mNewMessageFlag)
- {
- mNewMessageFlag = false;
- SDL::SetWindowTitle(mainGraphics->getWindow(),
- settings.windowCaption.c_str());
- }
-}
-
-void WindowManager::newChatMessage()
-{
- if (!mNewMessageFlag && mIsMinimized)
- {
- // show * on window caption
- SDL::SetWindowTitle(mainGraphics->getWindow(),
- ("*" + settings.windowCaption).c_str());
- mNewMessageFlag = true;
- }
-}
-
-void WindowManager::setIcon()
-{
-#ifndef ANDROID
- std::string iconFile = branding.getValue("appIcon", "icons/manaplus");
-#ifdef WIN32
- iconFile.append(".ico");
-#else // WIN32
-
- iconFile.append(".png");
-#endif // WIN32
-
- iconFile = VirtFs::getPath(iconFile);
- logger->log("Loading icon from file: %s", iconFile.c_str());
-
-#ifdef WIN32
- static SDL_SysWMinfo pInfo;
- if (mainGraphics)
- SDL::getWindowWMInfo(mainGraphics->getWindow(), &pInfo);
- else
- SDL::getWindowWMInfo(nullptr, &pInfo);
- // Attempt to load icon from .ico file
- HICON icon = static_cast<HICON>(LoadImage(nullptr,
- iconFile.c_str(),
- IMAGE_ICON,
- 64, 64,
- LR_LOADFROMFILE));
- // If it's failing, we load the default resource file.
- if (!icon)
- {
- logger->log("icon load error");
- icon = LoadIcon(GetModuleHandle(nullptr), "A");
- }
- if (icon)
- {
-#ifdef WIN64
- SetClassLongPtr(pInfo.window,
- GCLP_HICON,
- reinterpret_cast<LONG_PTR>(icon));
-#else // WIN64
- SetClassLong(pInfo.window,
- GCL_HICON,
- reinterpret_cast<LONG>(icon));
-#endif // WIN64
- }
-#else // WIN32
-
- mIcon = MIMG_Load(iconFile.c_str());
- if (mIcon != nullptr)
- {
-#ifdef USE_SDL2
- SDL_SetSurfaceAlphaMod(mIcon, SDL_ALPHA_OPAQUE);
-#else // USE_SDL2
-
- SDL_SetAlpha(mIcon, SDL_SRCALPHA, SDL_ALPHA_OPAQUE);
-#endif // USE_SDL2
-
- SDL::SetWindowIcon(mainGraphics->getWindow(), mIcon);
- }
-#endif // WIN32
-#endif // ANDROID
-}
-
-bool WindowManager::isKeyboardVisible()
-{
-#ifdef USE_SDL2
- return SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE;
-#else // USE_SDL2
-
- return mKeyboardHeight > 1;
-#endif // USE_SDL2
-}
-
-bool WindowManager::getIsMinimized()
-{
- return mIsMinimized;
-}
-
-#ifndef USE_SDL2
-void WindowManager::updateScreenKeyboard(const int height)
-{
- mKeyboardHeight = height;
-}
-#endif // USE_SDL2
-
-void WindowManager::deleteIcon()
-{
- MSDL_FreeSurface(mIcon);
- mIcon = nullptr;
-}
diff --git a/src/gui/windowmanager.h b/src/gui/windowmanager.h
deleted file mode 100644
index 8662f39a1..000000000
--- a/src/gui/windowmanager.h
+++ /dev/null
@@ -1,87 +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_WINDOWMANAGER_H
-#define GUI_WINDOWMANAGER_H
-
-#include "localconsts.h"
-
-namespace WindowManager
-{
- void init();
-
- bool getIsMinimized() A_WARN_UNUSED;
-
- void setIsMinimized(const bool n);
-
- void newChatMessage();
-
- bool isKeyboardVisible();
-
- void setFramerate(const unsigned int fpsLimit);
-
- int getFramerate() A_WARN_UNUSED;
-
- void applyGrabMode();
-
- void applyGamma();
-
- void applyVSync();
-
- void applyKeyRepeat();
-
- void doResizeVideo(const int actualWidth,
- const int actualHeight,
- const bool always);
-
- void resizeVideo(int actualWidth,
- int actualHeight,
- const bool always);
-
- bool setFullScreen(const bool fs);
-
- void applyScale();
-
-#ifndef USE_SDL2
- void updateScreenKeyboard(const int height);
-#endif // USE_SDL2
-
- void reloadWallpaper();
-
- void createWindows();
-
- void deleteWindows();
-
- void initTitle();
-
- void setIcon();
-
- void deleteIcon();
-
- void updateTitle();
-
- void createValidateWindows();
-
- void deleteValidateWindows();
-} // namespace WindowManager
-
-#endif // GUI_WINDOWMANAGER_H
diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp
deleted file mode 100644
index 477aa719d..000000000
--- a/src/gui/windowmenu.cpp
+++ /dev/null
@@ -1,493 +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 "gui/windowmenu.h"
-
-#include "configuration.h"
-
-#include "input/inputmanager.h"
-
-#include "gui/buttoninfo.h"
-#include "gui/buttontext.h"
-#include "gui/popupmanager.h"
-#include "gui/skin.h"
-
-#include "gui/popups/popupmenu.h"
-#include "gui/popups/textpopup.h"
-
-#include "gui/windows/skilldialog.h"
-
-#include "gui/widgets/button.h"
-
-#include "utils/dtor.h"
-#include "utils/foreach.h"
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-WindowMenu *windowMenu = nullptr;
-
-WindowMenu::WindowMenu(const Widget2 *const widget) :
- Container(widget),
- ConfigListener(),
- ActionListener(),
- SelectionListener(),
- MouseListener(),
- mSkin(theme != nullptr ? theme->load("windowmenu.xml", "") : nullptr),
- mPadding(mSkin != nullptr ? mSkin->getPadding() : 1),
- mSpacing(mSkin != nullptr ? mSkin->getOption("spacing", 3) : 3),
- mButtons(),
- mButtonTexts(),
- mButtonNames(),
- mHaveMouse(false),
- mAutoHide(1),
- mSmallWindow(mainGraphics->getWidth() < 600)
-{
- int x = mPadding;
- int h = 0;
-
- setFocusable(false);
- // TRANSLATORS: short button name for who is online window.
- addButton(N_("ONL"),
- // TRANSLATORS: long button name for who is online window.
- _("Who is online"), x, h, InputAction::WINDOW_ONLINE);
- // TRANSLATORS: short button name for help window.
- addButton(N_("HLP"),
- // TRANSLATORS: long button name for help window.
- _("Help"), x, h, InputAction::WINDOW_HELP);
- // TRANSLATORS: short button name for quests window.
- addButton(N_("QE"),
- // TRANSLATORS: long button name for quests window.
- _("Quests"), x, h, InputAction::WINDOW_QUESTS);
- // TRANSLATORS: short button name for kill stats window.
- addButton(N_("KS"),
- // TRANSLATORS: long button name for kill stats window.
- _("Kill stats"), x, h, InputAction::WINDOW_KILLS);
- addButton(":-)",
- // TRANSLATORS: long button name for emotes window.
- _("Smilies"), x, h, InputAction::WINDOW_EMOTE_SHORTCUT);
- // TRANSLATORS: short button name for chat window.
- addButton(N_("CH"),
- // TRANSLATORS: longt button name for chat window.
- _("Chat"), x, h, InputAction::WINDOW_CHAT,
-#ifdef ANDROID
- Visible_true);
-#else // ANDROID
- Visible_false);
-#endif // ANDROID
-
- // TRANSLATORS: short button name for status window.
- addButton(N_("STA"),
- // TRANSLATORS: long button name for status window.
- _("Status"), x, h, InputAction::WINDOW_STATUS);
- // TRANSLATORS: short button name for equipment window.
- addButton(N_("EQU"),
- // TRANSLATORS: long button name for equipment window.
- _("Equipment"), x, h, InputAction::WINDOW_EQUIPMENT);
- // TRANSLATORS: short button name for inventory window.
- addButton(N_("INV"),
- // TRANSLATORS: long button name for inventory window.
- _("Inventory"), x, h, InputAction::WINDOW_INVENTORY);
- // TRANSLATORS: short button name for cart window.
- addButton(N_("CA"),
- // TRANSLATORS: long button name for cart window.
- _("Cart"), x, h, InputAction::WINDOW_CART);
- // TRANSLATORS: short button name for map window.
- addButton(N_("MAP"),
- // TRANSLATORS: long button name for map window.
- _("Map"), x, h, InputAction::WINDOW_MINIMAP,
- Visible_false);
-
- if (skillDialog->hasSkills())
- {
- // TRANSLATORS: short button name for skills window.
- addButton(N_("SKI"),
- // TRANSLATORS: long button name for skills window.
- _("Skills"), x, h, InputAction::WINDOW_SKILL);
- }
-
- // TRANSLATORS: short button name for social window.
- addButton(N_("SOC"),
- // TRANSLATORS: long button name for social window.
- _("Social"), x, h, InputAction::WINDOW_SOCIAL);
- // TRANSLATORS: short button name for shortcuts window.
- addButton(N_("SH"),
- // TRANSLATORS: long button name for shortcuts window.
- _("Shortcuts"), x, h, InputAction::WINDOW_SHORTCUT);
- // TRANSLATORS: short button name for spells window.
- addButton(N_("SP"),
- // TRANSLATORS: long button name for spells window.
- _("Spells"), x, h, InputAction::WINDOW_SPELLS);
- // TRANSLATORS: short button name for drops window.
- addButton(N_("DR"),
- // TRANSLATORS: long button name for drops window.
- _("Drop"), x, h, InputAction::WINDOW_DROP,
- Visible_false);
- // TRANSLATORS: short button name for did you know window.
- addButton(N_("YK"),
- // TRANSLATORS: long button name for did you know window.
- _("Did you know"), x, h, InputAction::WINDOW_DIDYOUKNOW,
- Visible_false);
- // TRANSLATORS: short button name for shop window.
- addButton(N_("SHP"),
- // TRANSLATORS: long button name for shop window.
- _("Shop"), x, h, InputAction::WINDOW_SHOP,
- Visible_false);
- // TRANSLATORS: short button name for outfits window.
- addButton(N_("OU"),
- // TRANSLATORS: long button name for outfits window.
- _("Outfits"), x, h, InputAction::WINDOW_OUTFIT,
- Visible_false);
- // TRANSLATORS: short button name for updates window.
- addButton(N_("UP"),
- // TRANSLATORS: long button name for updates window.
- _("Updates"), x, h, InputAction::WINDOW_UPDATER,
- Visible_false);
- // TRANSLATORS: short button name for bank window.
- addButton(N_("BA"),
- // TRANSLATORS: long button name for bank window.
- _("Bank"), x, h, InputAction::WINDOW_BANK,
- Visible_true);
- // TRANSLATORS: short button name for mail window.
- addButton(N_("MA"),
- // TRANSLATORS: long button name for mail window.
- _("Mail"), x, h, InputAction::WINDOW_MAIL,
- Visible_true);
- // TRANSLATORS: short button name for server info window.
- addButton(N_("SI"),
- // TRANSLATORS: long button name for server info window.
- _("Server info"), x, h, InputAction::WINDOW_SERVER_INFO,
- Visible_true);
- // TRANSLATORS: short button name for debug window.
- addButton(N_("DBG"),
- // TRANSLATORS: long button name for debug window.
- _("Debug"), x, h, InputAction::WINDOW_DEBUG,
-#ifdef ANDROID
- Visible_true);
-#else // ANDROID
- Visible_false);
-#endif // ANDROID
-
- // TRANSLATORS: short button name for windows list menu.
- addButton(N_("WIN"),
- // TRANSLATORS: long button name for windows list menu.
- _("Windows"), x, h, InputAction::SHOW_WINDOWS,
- Visible_false);
- // TRANSLATORS: short button name for setup window.
- addButton(N_("SET"),
- // TRANSLATORS: long button name for setup window.
- _("Setup"), x, h, InputAction::WINDOW_SETUP);
-
- x += mPadding - mSpacing;
- if (mainGraphics != nullptr)
- setDimension(Rect(mainGraphics->mWidth - x, 0, x, h));
-
- loadButtons();
-
- addMouseListener(this);
- setVisible(Visible_true);
-
- config.addListener("autohideButtons", this);
- mAutoHide = config.getIntValue("autohideButtons");
-}
-
-WindowMenu::~WindowMenu()
-{
- config.removeListener("autohideButtons", this);
- CHECKLISTENERS
-
- for (std::map <std::string, ButtonInfo*>::iterator
- it = mButtonNames.begin(),
- it_fend = mButtonNames.end(); it != it_fend; ++it)
- {
- delete (*it).second;
- }
- mButtonNames.clear();
- FOR_EACH (STD_VECTOR <Button*>::iterator, it, mButtons)
- {
- Button *const btn = *it;
- if (btn == nullptr)
- continue;
- if (btn->mVisible == Visible_false)
- delete btn;
- }
- delete_all(mButtonTexts);
- mButtonTexts.clear();
- if (mSkin != nullptr)
- {
- if (theme != nullptr)
- theme->unload(mSkin);
- mSkin = nullptr;
- }
-}
-
-void WindowMenu::action(const ActionEvent &event)
-{
- const std::string &eventId = event.getId();
- const std::map <std::string, ButtonInfo*>::iterator
- it = mButtonNames.find(eventId);
- if (it == mButtonNames.end())
- return;
-
- const ButtonInfo *const info = (*it).second;
- if (info == nullptr)
- return;
-
- inputManager.executeAction(info->key);
-}
-
-void WindowMenu::addButton(const char *const text,
- const std::string &description,
- int &restrict x,
- int &restrict h,
- const InputActionT key,
- const Visible visible)
-{
- Button *const btn = new Button(this, gettext(text), text, this);
- btn->setPosition(x, mPadding);
- btn->setDescription(description);
- btn->setTag(CAST_S32(key));
- add(btn);
- btn->setFocusable(false);
- x += btn->getWidth() + mSpacing;
- h = btn->getHeight() + 2 * mPadding;
- mButtons.push_back(btn);
- mButtonNames[text] = new ButtonInfo(btn, key, visible);
- if (key != InputAction::SHOW_WINDOWS)
- mButtonTexts.push_back(new ButtonText(description, key));
-}
-
-void WindowMenu::mousePressed(MouseEvent &event)
-{
- if (popupManager == nullptr)
- return;
-
- if (event.getButton() == MouseButton::RIGHT)
- {
- if (mSmallWindow)
- return;
-
- event.consume();
- Button *const btn = dynamic_cast<Button*>(event.getSource());
- if (btn == nullptr)
- return;
- if (popupMenu != nullptr)
- {
- popupMenu->showPopup(getX() + event.getX(),
- getY() + event.getY(), btn);
- }
- }
-}
-
-void WindowMenu::mouseMoved(MouseEvent &event)
-{
- mHaveMouse = true;
-
- if (textPopup == nullptr)
- return;
-
- if (event.getSource() == this)
- {
- textPopup->hide();
- return;
- }
-
- const Button *const btn = dynamic_cast<const Button *>(
- event.getSource());
-
- if (btn == nullptr)
- {
- textPopup->hide();
- return;
- }
-
- const int x = event.getX();
- const int y = event.getY();
- const InputActionT key = static_cast<InputActionT>(btn->getTag());
- const Rect &rect = mDimension;
- if (key != InputAction::NO_VALUE)
- {
- textPopup->show(x + rect.x, y + rect.y, btn->getDescription(),
- // TRANSLATORS: short key name
- strprintf(_("Key: %s"), inputManager.getKeyValueString(
- key).c_str()));
- }
- else
- {
- textPopup->show(x + rect.x, y + rect.y, btn->getDescription());
- }
-}
-
-void WindowMenu::mouseExited(MouseEvent& event A_UNUSED)
-{
- mHaveMouse = false;
- if (textPopup == nullptr)
- return;
-
- textPopup->hide();
-}
-
-void WindowMenu::showButton(const std::string &name,
- const Visible visible)
-{
- const ButtonInfo *const info = mButtonNames[name];
- if ((info == nullptr) || (info->button == nullptr))
- return;
-
- info->button->setVisible(visible);
- updateButtons();
- saveButtons();
-}
-
-void WindowMenu::updateButtons()
-{
- int x = mPadding;
- int h = 0;
- FOR_EACH (STD_VECTOR <Button*>::const_iterator, it, mButtons)
- safeRemove(*it);
- const int pad2 = 2 * mPadding;
- FOR_EACH (STD_VECTOR <Button*>::iterator, it, mButtons)
- {
- Button *const btn = *it;
- if (btn == nullptr)
- continue;
- if (btn->mVisible == Visible_true)
- {
- btn->setPosition(x, mPadding);
- add(btn);
- x += btn->getWidth() + mSpacing;
- h = btn->getHeight() + pad2;
- }
- }
- x += mPadding - mSpacing;
- if (mainGraphics != nullptr)
- setDimension(Rect(mainGraphics->mWidth - x, 0, x, h));
-}
-
-void WindowMenu::loadButtons()
-{
- if (!mSmallWindow)
- {
- if (config.getValue("windowmenu0", "").empty())
- {
- for (std::map <std::string, ButtonInfo*>::iterator
- it = mButtonNames.begin(),
- it_fend = mButtonNames.end(); it != it_fend; ++it)
- {
- const ButtonInfo *const info = (*it).second;
- if (info == nullptr ||
- info->button == nullptr ||
- info->visible == Visible_true)
- {
- continue;
- }
- info->button->setVisible(Visible_false);
- }
- updateButtons();
- return;
- }
-
- for (int f = 0; f < 30; f ++)
- {
- const std::string str = config.getValue(
- "windowmenu" + toString(f), "");
- if (str.empty() || str == "SET")
- continue;
- const ButtonInfo *const info = mButtonNames[str];
- if ((info == nullptr) || (info->button == nullptr))
- continue;
- info->button->setVisible(Visible_false);
- }
- }
- else
- {
- for (std::map <std::string, ButtonInfo*>::iterator
- it = mButtonNames.begin(),
- it_fend = mButtonNames.end(); it != it_fend; ++it)
- {
- const ButtonInfo *const info = (*it).second;
- if ((info == nullptr) || (info->button == nullptr))
- continue;
- Button *const button = info->button;
- const std::string &str = button->getActionEventId();
- button->setVisible(fromBool(
- str == "SET" || str == "WIN", Visible));
- }
- }
- updateButtons();
-}
-
-void WindowMenu::saveButtons() const
-{
- int i = 0;
- FOR_EACH (STD_VECTOR <Button*>::const_iterator, it, mButtons)
- {
- const Button *const btn = *it;
- if ((btn != nullptr) && btn->mVisible == Visible_false)
- {
- config.setValue("windowmenu" + toString(i),
- btn->getActionEventId());
- i ++;
- }
- }
- for (int f = i; f < 30; f ++)
- config.deleteKey("windowmenu" + toString(f));
-}
-
-void WindowMenu::drawChildren(Graphics *const graphics)
-{
- if (mHaveMouse ||
- mAutoHide == 0 ||
- (mAutoHide == 1 &&
- mainGraphics != nullptr &&
- (mSmallWindow || mainGraphics->mWidth > 800)))
- {
- Container::drawChildren(graphics);
- }
-}
-
-void WindowMenu::safeDrawChildren(Graphics *const graphics)
-{
- if (mHaveMouse ||
- mAutoHide == 0 ||
- (mAutoHide == 1 &&
- mainGraphics != nullptr &&
- (mSmallWindow || mainGraphics->mWidth > 800)))
- {
- Container::safeDrawChildren(graphics);
- }
-}
-
-void WindowMenu::optionChanged(const std::string &name)
-{
- if (name == "autohideButtons")
- mAutoHide = config.getIntValue("autohideButtons");
-}
-
-#ifdef USE_PROFILER
-void WindowMenu::logicChildren()
-{
- BLOCK_START("WindowMenu::logicChildren")
- BasicContainer::logicChildren();
- BLOCK_END("WindowMenu::logicChildren")
-}
-#endif // USE_PROFILER
diff --git a/src/gui/windowmenu.h b/src/gui/windowmenu.h
deleted file mode 100644
index 780fe29ea..000000000
--- a/src/gui/windowmenu.h
+++ /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/>.
- */
-
-#ifndef GUI_WINDOWMENU_H
-#define GUI_WINDOWMENU_H
-
-#include "enums/input/inputaction.h"
-
-#include "gui/widgets/container.h"
-
-#include "listeners/actionlistener.h"
-#include "listeners/mouselistener.h"
-#include "listeners/selectionlistener.h"
-
-#include "localconsts.h"
-
-class Button;
-
-struct ButtonInfo;
-struct ButtonText;
-
-/**
- * The window menu. Allows showing and hiding many of the different windows
- * used in the game.
- *
- * \ingroup Interface
- */
-class WindowMenu final : public Container,
- public ConfigListener,
- public ActionListener,
- public SelectionListener,
- public MouseListener
-{
- public:
- explicit WindowMenu(const Widget2 *const widget);
-
- A_DELETE_COPY(WindowMenu)
-
- ~WindowMenu();
-
- void action(const ActionEvent &event) override final;
-
- void mousePressed(MouseEvent &event) override final;
-
- void mouseMoved(MouseEvent &event) override final;
-
- void mouseExited(MouseEvent& event A_UNUSED) override final;
-
- std::map <std::string, ButtonInfo*> &getButtonNames() A_WARN_UNUSED
- { return mButtonNames; }
-
- STD_VECTOR <Button*> &getButtons() A_WARN_UNUSED
- { return mButtons; }
-
- STD_VECTOR <ButtonText*> &getButtonTexts() A_WARN_UNUSED
- { return mButtonTexts; }
-
- void showButton(const std::string &name, const Visible visible);
-
- void loadButtons();
-
- void saveButtons() const;
-
- void optionChanged(const std::string &name) override final;
-
-#ifdef USE_PROFILER
- void logicChildren();
-#endif // USE_PROFILER
-
- protected:
- void drawChildren(Graphics *const graphics) override final
- A_NONNULL(2);
-
- void safeDrawChildren(Graphics *const graphics) override final
- A_NONNULL(2);
-
- private:
- inline void addButton(const char *const text,
- const std::string &description,
- int &restrict x, int &restrict h,
- const InputActionT key,
- const Visible visible = Visible_true);
-
- void updateButtons();
-
- Skin *mSkin;
- int mPadding;
- int mSpacing;
- STD_VECTOR <Button*> mButtons;
- STD_VECTOR <ButtonText*> mButtonTexts;
- std::map <std::string, ButtonInfo*> mButtonNames;
- bool mHaveMouse;
- int mAutoHide;
- bool mSmallWindow;
-};
-
-extern WindowMenu *windowMenu;
-
-#endif // GUI_WINDOWMENU_H
diff --git a/src/gui/windows/bankwindow.cpp b/src/gui/windows/bankwindow.cpp
deleted file mode 100644
index 242d30aa1..000000000
--- a/src/gui/windows/bankwindow.cpp
+++ /dev/null
@@ -1,102 +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 "gui/windows/bankwindow.h"
-
-#include "net/bankhandler.h"
-
-#include "gui/windows/setupwindow.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/containerplacer.h"
-#include "gui/widgets/inttextfield.h"
-#include "gui/widgets/label.h"
-
-#include "utils/gettext.h"
-#include "utils/stringutils.h"
-
-#include "resources/db/unitsdb.h"
-
-#include "debug.h"
-
-BankWindow *bankWindow = nullptr;
-
-BankWindow::BankWindow() :
- // TRANSLATORS: bank window name
- Window(_("Bank"), Modal_false, nullptr, "bank.xml"),
- ActionListener(),
- BankListener(),
- mBankMoneyLabel(new Label(this, strprintf(
- // TRANSLATORS: bank window money label
- _("Money in bank: %s"), " "))),
- mInputMoneyTextField(new IntTextField(this, 0, 0, 2147483647)),
- // TRANSLATORS: bank window button
- mWithdrawButton(new Button(this, _("Withdraw"), "withdraw", this)),
- // TRANSLATORS: bank window button
- mDepositButton(new Button(this, _("Deposit"), "deposit", this))
-{
- setWindowName("Bank");
- setCloseButton(true);
-
- if (setupWindow != nullptr)
- setupWindow->registerWindowForReset(this);
-
- mBankMoneyLabel->adjustSize();
- ContainerPlacer placer = getPlacer(0, 0);
- placer(0, 0, mBankMoneyLabel, 7);
- placer(0, 1, mInputMoneyTextField, 10);
- placer(0, 2, mDepositButton, 5);
- placer(5, 2, mWithdrawButton, 5);
-
- setContentSize(300, 100);
- setDefaultSize(300, 100, ImagePosition::CENTER, 0, 0);
-
- center();
- setDefaultSize();
- loadWindowState();
- reflowLayout(300);
- enableVisibleSound(true);
-}
-
-BankWindow::~BankWindow()
-{
-}
-
-void BankWindow::widgetShown(const Event &event)
-{
- if (event.getSource() == this)
- bankHandler->check();
-}
-
-void BankWindow::bankMoneyChanged(const int money)
-{
- // TRANSLATORS: bank window money label
- mBankMoneyLabel->setCaption(strprintf(_("Money in bank: %s"),
- UnitsDb::formatCurrency(money).c_str()));
-}
-
-void BankWindow::action(const ActionEvent &event)
-{
- const std::string &eventId = event.getId();
- if (eventId == "deposit")
- bankHandler->deposit(mInputMoneyTextField->getValue());
- else if (eventId == "withdraw")
- bankHandler->withdraw(mInputMoneyTextField->getValue());
-}
diff --git a/src/gui/windows/bankwindow.h b/src/gui/windows/bankwindow.h
deleted file mode 100644
index 046b11ec4..000000000
--- a/src/gui/windows/bankwindow.h
+++ /dev/null
@@ -1,64 +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 GUI_WINDOWS_BANKWINDOW_H
-#define GUI_WINDOWS_BANKWINDOW_H
-
-#include "gui/widgets/window.h"
-
-#include "listeners/actionlistener.h"
-#include "listeners/banklistener.h"
-
-class Button;
-class IntTextField;
-class Label;
-
-/**
- * A dialog to choose between buying or selling at a shop.
- *
- * \ingroup Interface
- */
-class BankWindow final : public Window,
- public ActionListener,
- public BankListener
-{
- public:
- BankWindow();
-
- A_DELETE_COPY(BankWindow)
-
- ~BankWindow();
-
- void action(const ActionEvent &event) override final;
-
- void widgetShown(const Event &event) override final;
-
- void bankMoneyChanged(const int money) override final;
-
- private:
- Label *mBankMoneyLabel;
- IntTextField *mInputMoneyTextField;
- Button *mWithdrawButton;
- Button *mDepositButton;
-};
-
-extern BankWindow *bankWindow;
-
-#endif // GUI_WINDOWS_BANKWINDOW_H
diff --git a/src/gui/windows/buydialog.cpp b/src/gui/windows/buydialog.cpp
deleted file mode 100644
index db1dc6e50..000000000
--- a/src/gui/windows/buydialog.cpp
+++ /dev/null
@@ -1,794 +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 "gui/windows/buydialog.h"
-
-#include "actormanager.h"
-#include "configuration.h"
-
-#include "being/being.h"
-
-#include "enums/gui/layouttype.h"
-
-#include "gui/windows/setupwindow.h"
-#ifdef TMWA_SUPPORT
-#include "gui/windows/tradewindow.h"
-#endif // TMWA_SUPPORT
-
-#include "gui/models/shopitems.h"
-#include "gui/models/sortlistmodelbuy.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/containerplacer.h"
-#include "gui/widgets/createwidget.h"
-#include "gui/widgets/dropdown.h"
-#include "gui/widgets/inttextfield.h"
-#include "gui/widgets/label.h"
-#include "gui/widgets/layout.h"
-#include "gui/widgets/scrollarea.h"
-#include "gui/widgets/shoplistbox.h"
-#include "gui/widgets/slider.h"
-
-#include "net/adminhandler.h"
-#include "net/buysellhandler.h"
-#include "net/cashshophandler.h"
-#include "net/markethandler.h"
-#include "net/net.h"
-#include "net/vendinghandler.h"
-#include "net/npchandler.h"
-
-#include "resources/iteminfo.h"
-
-#include "resources/db/unitsdb.h"
-
-#include "utils/delete2.h"
-#include "utils/foreach.h"
-
-#include <algorithm>
-
-#include "debug.h"
-
-namespace
-{
- class SortItemPriceFunctor final
- {
- public:
- A_DEFAULT_COPY(SortItemPriceFunctor)
-
- bool operator() (const ShopItem *const item1,
- const ShopItem *const item2) const
- {
- if ((item1 == nullptr) || (item2 == nullptr))
- return false;
-
- const int price1 = item1->getPrice();
- const int price2 = item2->getPrice();
- if (price1 == price2)
- return item1->getDisplayName() < item2->getDisplayName();
- return price1 < price2;
- }
- } itemPriceBuySorter;
-
- class SortItemNameFunctor final
- {
- public:
- A_DEFAULT_COPY(SortItemNameFunctor)
-
- bool operator() (const ShopItem *const item1,
- const ShopItem *const item2) const
- {
- if ((item1 == nullptr) || (item2 == nullptr))
- return false;
-
- const std::string &name1 = item1->getDisplayName();
- const std::string &name2 = item2->getDisplayName();
- if (name1 == name2)
- return item1->getPrice() < item2->getPrice();
- return name1 < name2;
- }
- } itemNameBuySorter;
-
- class SortItemIdFunctor final
- {
- public:
- A_DEFAULT_COPY(SortItemIdFunctor)
-
- bool operator() (const ShopItem *const item1,
- const ShopItem *const item2) const
- {
- if ((item1 == nullptr) || (item2 == nullptr))
- return false;
-
- const int id1 = item1->getId();
- const int id2 = item2->getId();
- if (id1 == id2)
- return item1->getPrice() < item2->getPrice();
- return id1 < id2;
- }
- } itemIdBuySorter;
-
- class SortItemWeightFunctor final
- {
- public:
- A_DEFAULT_COPY(SortItemWeightFunctor)
-
- bool operator() (const ShopItem *const item1,
- const ShopItem *const item2) const
- {
- if ((item1 == nullptr) || (item2 == nullptr))
- return false;
-
- const int weight1 = item1->getInfo().getWeight();
- const int weight2 = item2->getInfo().getWeight();
- if (weight1 == weight2)
- return item1->getPrice() < item2->getPrice();
- return weight1 < weight2;
- }
- } itemWeightBuySorter;
-
- class SortItemAmountFunctor final
- {
- public:
- A_DEFAULT_COPY(SortItemAmountFunctor)
-
- bool operator() (const ShopItem *const item1,
- const ShopItem *const item2) const
- {
- if ((item1 == nullptr) || (item2 == nullptr))
- return false;
-
- const int amount1 = item1->getQuantity();
- const int amount2 = item2->getQuantity();
- if (amount1 == amount2)
- return item1->getPrice() < item2->getPrice();
- return amount1 < amount2;
- }
- } itemAmountBuySorter;
-
- class SortItemTypeFunctor final
- {
- public:
- A_DEFAULT_COPY(SortItemTypeFunctor)
-
- bool operator() (const ShopItem *const item1,
- const ShopItem *const item2) const
- {
- if ((item1 == nullptr) || (item2 == nullptr))
- return false;
-
- const ItemDbTypeT type1 = item1->getInfo().getType();
- const ItemDbTypeT type2 = item2->getInfo().getType();
- if (type1 == type2)
- return item1->getPrice() < item2->getPrice();
- return type1 < type2;
- }
- } itemTypeBuySorter;
-} // namespace
-
-BuyDialog::DialogList BuyDialog::instances;
-
-BuyDialog::BuyDialog() :
- // TRANSLATORS: buy dialog name
- Window(_("Create items"), Modal_false, nullptr, "buy.xml"),
- ActionListener(),
- SelectionListener(),
- mSortModel(nullptr),
- mSortDropDown(nullptr),
- mFilterTextField(new TextField(this, "", LoseFocusOnTab_true,
- this, "namefilter", true)),
- mFilterLabel(nullptr),
- mNick(),
- mCurrency(),
- mNpcId(fromInt(Items, BeingId)),
- mMoney(0),
- mAmountItems(0),
- mMaxItems(0),
- mAdvanced(false)
-{
- init();
-}
-
-BuyDialog::BuyDialog(const BeingId npcId,
- const std::string &currency) :
- // TRANSLATORS: buy dialog name
- Window(_("Buy"), Modal_false, nullptr, "buy.xml"),
- ActionListener(),
- SelectionListener(),
- mSortModel(nullptr),
- mSortDropDown(nullptr),
- mFilterTextField(new TextField(this, "", LoseFocusOnTab_true,
- this, "namefilter", true)),
- mFilterLabel(nullptr),
- mNick(),
- mCurrency(currency),
- mNpcId(npcId),
- mMoney(0),
- mAmountItems(0),
- mMaxItems(0),
- mAdvanced(Net::getNetworkType() != ServerType::TMWATHENA)
-{
- init();
-}
-
-#ifdef TMWA_SUPPORT
-BuyDialog::BuyDialog(const std::string &nick,
- const std::string &currency) :
- // TRANSLATORS: buy dialog name
- Window(_("Buy"), Modal_false, nullptr, "buy.xml"),
- ActionListener(),
- SelectionListener(),
- mSortModel(new SortListModelBuy),
- mSortDropDown(new DropDown(this, mSortModel, false,
- Modal_false, this, "sort")),
- mFilterTextField(new TextField(this, "", LoseFocusOnTab_true,
- this, "namefilter", true)),
- mFilterLabel(nullptr),
- mNick(nick),
- mCurrency(currency),
- mNpcId(fromInt(Nick, BeingId)),
- mMoney(0),
- mAmountItems(0),
- mMaxItems(0),
- mAdvanced(false)
-{
- init();
-}
-#endif // TMWA_SUPPORT
-
-BuyDialog::BuyDialog(const Being *const being,
- const std::string &currency) :
- // TRANSLATORS: buy dialog name
- Window(_("Buy"), Modal_false, nullptr, "buy.xml"),
- ActionListener(),
- SelectionListener(),
- mSortModel(new SortListModelBuy),
- mSortDropDown(new DropDown(this, mSortModel, false,
- Modal_false, this, "sort")),
- mFilterTextField(new TextField(this, "", LoseFocusOnTab_true,
- this, "namefilter", true)),
- mFilterLabel(nullptr),
- mNick(being != nullptr ? being->getName() : std::string()),
- mCurrency(currency),
- mNpcId(fromInt(Vending, BeingId)),
- mMoney(0),
- mAmountItems(0),
- mMaxItems(0),
- mAdvanced(true)
-{
- init();
-}
-
-void BuyDialog::init()
-{
- setWindowName("Buy");
- setResizable(true);
- setCloseButton(true);
- setStickyButtonLock(true);
- setMinWidth(260);
- setMinHeight(220);
- setDefaultSize(260, 230, ImagePosition::CENTER);
-
-#ifdef TMWA_SUPPORT
- // reset advance flag for personal shops
- if (mAdvanced &&
- mNpcId == fromInt(Nick, BeingId))
- {
- mAdvanced = false;
- }
-#endif // TMWA_SUPPORT
-
- if (setupWindow != nullptr)
- setupWindow->registerWindowForReset(this);
-
- mShopItems = new ShopItems(false,
- mCurrency);
-
- CREATEWIDGETV(mShopItemList, ShopListBox, this,
- mShopItems, mShopItems, ShopListBoxType::Unknown);
- mScrollArea = new ScrollArea(this, mShopItemList,
- fromBool(getOptionBool("showbackground"), Opaque),
- "buy_background.xml");
- mScrollArea->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
-
- mSlider = new Slider(this, 1.0, 1.0);
- mQuantityLabel = new Label(this, strprintf(
- "%d / %d", mAmountItems, mMaxItems));
- mQuantityLabel->setAlignment(Graphics::CENTER);
- mMoneyLabel = new Label(this, strprintf(
- // TRANSLATORS: buy dialog label
- _("Price: %s / Total: %s"), "", ""));
-
- mAmountField = new IntTextField(this, 1, 1, 123);
- mAmountField->setActionEventId("amount");
- mAmountField->addActionListener(this);
- mAmountField->setSendAlwaysEvents(true);
- mAmountField->setEnabled(false);
-
- // TRANSLATORS: buy dialog label
- mAmountLabel = new Label(this, _("Amount:"));
- mAmountLabel->adjustSize();
-
- // TRANSLATORS: This is a narrow symbol used to denote 'increasing'.
- // You may change this symbol if your language uses another.
- mIncreaseButton = new Button(this, _("+"), "inc", this);
- // TRANSLATORS: This is a narrow symbol used to denote 'decreasing'.
- // You may change this symbol if your language uses another.
- mDecreaseButton = new Button(this, _("-"), "dec", this);
- mBuyButton = new Button(this, mNpcId == fromInt(Items, BeingId)
- // TRANSLATORS: buy dialog button
- ? _("Create") : (mAdvanced ? _("Add") : _("Buy")), "buy", this);
- if (mAdvanced)
- {
- // TRANSLATORS: buy dialog button
- mConfirmButton = new Button(this, _("Buy"), "confirm", this);
- mConfirmButton->setEnabled(false);
- }
- else
- {
- mConfirmButton = nullptr;
- }
- // TRANSLATORS: buy dialog button
- mQuitButton = new Button(this, _("Quit"), "quit", this);
- // TRANSLATORS: buy dialog button
- mAddMaxButton = new Button(this, _("Max"), "max", this);
-
- mDecreaseButton->adjustSize();
- mDecreaseButton->setWidth(mIncreaseButton->getWidth());
-
- mIncreaseButton->setEnabled(false);
- mDecreaseButton->setEnabled(false);
- mBuyButton->setEnabled(false);
- mSlider->setEnabled(false);
-
- mSlider->setActionEventId("slider");
- mSlider->addActionListener(this);
-
- mShopItemList->setDistributeMousePressed(false);
- mShopItemList->setActionEventId("buy");
- mShopItemList->addActionListener(this);
- mShopItemList->addSelectionListener(this);
-
- mFilterTextField->setWidth(100);
-
- ContainerPlacer placer = getPlacer(0, 0);
- placer(0, 0, mScrollArea, 9, 5).setPadding(3);
- placer(0, 5, mDecreaseButton);
- placer(1, 5, mSlider, 4);
- placer(5, 5, mIncreaseButton);
- placer(6, 5, mQuantityLabel, 2);
- placer(8, 5, mAddMaxButton);
- placer(0, 6, mAmountLabel, 2);
- placer(2, 6, mAmountField, 2);
- placer(0, 7, mMoneyLabel, 8);
- if (mSortDropDown != nullptr)
- {
- placer(0, 8, mSortDropDown, 2);
- }
- else
- {
- // TRANSLATORS: buy dialog label
- mFilterLabel = new Label(this, _("Filter:"));
- mFilterLabel->adjustSize();
- placer(0, 8, mFilterLabel, 2);
- }
- placer(2, 8, mFilterTextField, 2);
- if (mAdvanced)
- {
- placer(6, 8, mBuyButton);
- placer(7, 8, mConfirmButton);
- }
- else
- {
- placer(7, 8, mBuyButton);
- }
- placer(8, 8, mQuitButton);
-
- Layout &layout = getLayout();
- layout.setRowHeight(0, LayoutType::SET);
-
- center();
- loadWindowState();
- enableVisibleSound(true);
-
- instances.push_back(this);
- setVisible(Visible_true);
-
- if (mSortDropDown != nullptr)
- mSortDropDown->setSelected(config.getIntValue("buySortOrder"));
-}
-
-BuyDialog::~BuyDialog()
-{
- delete2(mShopItems);
- delete2(mSortModel);
- instances.remove(this);
- if (buySellHandler != nullptr)
- buySellHandler->cleanDialogReference(this);
-}
-
-void BuyDialog::setMoney(const int amount)
-{
- mMoney = amount;
- mShopItemList->setPlayersMoney(amount);
-
- updateButtonsAndLabels();
-}
-
-void BuyDialog::reset()
-{
- mShopItems->clear();
- mShopItemList->adjustSize();
-
- // Reset previous selected items to prevent failing asserts
- mShopItemList->setSelected(-1);
- mSlider->setValue(0);
-
- setMoney(0);
-}
-
-ShopItem *BuyDialog::addItem(const int id,
- const ItemTypeT type,
- const ItemColor color,
- const int amount,
- const int price)
-{
- ShopItem *const item = mShopItems->addItem(id,
- type,
- color,
- amount,
- price);
- mShopItemList->adjustSize();
- return item;
-}
-
-void BuyDialog::sort()
-{
- if ((mSortDropDown != nullptr) && (mShopItems != nullptr))
- {
- STD_VECTOR<ShopItem*> &items = mShopItems->items();
- switch (mSortDropDown->getSelected())
- {
- case 1:
- std::sort(items.begin(), items.end(), itemPriceBuySorter);
- break;
- case 2:
- std::sort(items.begin(), items.end(), itemNameBuySorter);
- break;
- case 3:
- std::sort(items.begin(), items.end(), itemIdBuySorter);
- break;
- case 4:
- std::sort(items.begin(), items.end(), itemWeightBuySorter);
- break;
- case 5:
- std::sort(items.begin(), items.end(), itemAmountBuySorter);
- break;
- case 6:
- std::sort(items.begin(), items.end(), itemTypeBuySorter);
- break;
- case 0:
- default:
- break;
- }
- }
-}
-
-void BuyDialog::close()
-{
- switch (toInt(mNpcId, int))
- {
-#ifdef TMWA_SUPPORT
- case Nick:
-#endif // TMWA_SUPPORT
- case Items:
- break;
- case Market:
- marketHandler->close();
- break;
- case Cash:
- cashShopHandler->close();
- break;
- case Vending:
- vendingHandler->close();
- break;
- default:
- buySellHandler->close();
- break;
- }
- Window::close();
-}
-
-void BuyDialog::action(const ActionEvent &event)
-{
- const std::string &eventId = event.getId();
- if (eventId == "quit")
- {
- close();
- return;
- }
- else if (eventId == "sort")
- {
- sort();
- if (mSortDropDown != nullptr)
- config.setValue("buySortOrder", mSortDropDown->getSelected());
- return;
- }
- else if (eventId == "namefilter")
- {
- applyNameFilter(mFilterTextField->getText());
- }
-
- const int selectedItem = mShopItemList->getSelected();
-
- // The following actions require a valid selection
- if (selectedItem < 0 || selectedItem >= mShopItems->getNumberOfElements())
- return;
-
- if (eventId == "slider")
- {
- mAmountItems = CAST_S32(mSlider->getValue());
- mAmountField->setValue(mAmountItems);
- updateButtonsAndLabels();
- }
- else if (eventId == "inc" && mAmountItems < mMaxItems)
- {
- mAmountItems++;
- mSlider->setValue(mAmountItems);
- mAmountField->setValue(mAmountItems);
- updateButtonsAndLabels();
- }
- else if (eventId == "dec" && mAmountItems > 1)
- {
- mAmountItems--;
- mSlider->setValue(mAmountItems);
- mAmountField->setValue(mAmountItems);
- updateButtonsAndLabels();
- }
- else if (eventId == "max")
- {
- mAmountItems = mMaxItems;
- mSlider->setValue(mAmountItems);
- mAmountField->setValue(mAmountItems);
- updateButtonsAndLabels();
- }
- else if (eventId == "amount")
- {
- mAmountItems = mAmountField->getValue();
- mSlider->setValue(mAmountItems);
- updateButtonsAndLabels();
- }
- else if (eventId == "buy" && mAmountItems > 0 && mAmountItems <= mMaxItems)
- {
- ShopItem *const item = mShopItems->at(selectedItem);
- if (item == nullptr)
- return;
- if (mNpcId == fromInt(Items, BeingId))
- {
- adminHandler->createItems(item->getId(),
- item->getColor(),
- mAmountItems);
- }
-#ifdef TMWA_SUPPORT
- else if (mNpcId == fromInt(Nick, BeingId))
- {
- if (tradeWindow != nullptr)
- {
- buySellHandler->sendBuyRequest(mNick,
- item, mAmountItems);
- tradeWindow->addAutoMoney(mNick,
- item->getPrice() * mAmountItems);
- }
- }
-#endif // TMWA_SUPPORT
- else if (mNpcId == fromInt(Vending, BeingId))
- {
- item->increaseUsedQuantity(mAmountItems);
- item->update();
- if (mConfirmButton != nullptr)
- mConfirmButton->setEnabled(true);
- }
-#ifdef TMWA_SUPPORT
- else if (mNpcId != fromInt(Nick, BeingId))
-#else
- else
-#endif // TMWA_SUPPORT
- {
- if (mAdvanced)
- {
- item->increaseUsedQuantity(mAmountItems);
- item->update();
- if (mConfirmButton != nullptr)
- mConfirmButton->setEnabled(true);
- }
- else if (mNpcId == fromInt(Market, BeingId))
- {
- marketHandler->buyItem(item->getId(),
- item->getType(),
- item->getColor(),
- mAmountItems);
- item->increaseQuantity(-mAmountItems);
- item->update();
- }
- else if (mNpcId == fromInt(Cash, BeingId))
- {
- cashShopHandler->buyItem(item->getPrice(),
- item->getId(),
- item->getColor(),
- mAmountItems);
- }
- else
- {
- npcHandler->buyItem(mNpcId,
- item->getId(),
- item->getColor(),
- mAmountItems);
- }
-
- updateSlider(selectedItem);
- }
- }
- else if (eventId == "confirm")
- {
- STD_VECTOR<ShopItem*> &items = mShopItems->allItems();
-
- if (mNpcId == fromInt(Market, BeingId))
- {
- marketHandler->buyItems(items);
- }
- else if (mNpcId == fromInt(Vending, BeingId))
- {
- const Being *const being = actorManager->findBeingByName(
- mNick,
- ActorType::Player);
- if (being != nullptr)
- {
- vendingHandler->buyItems(being,
- items);
- }
- }
- else if (mNpcId == fromInt(Cash, BeingId))
- {
- cashShopHandler->buyItems(0, items);
- }
- else
- {
- npcHandler->buyItems(items);
- }
- close();
- }
-}
-
-void BuyDialog::updateSlider(const int selectedItem)
-{
- // Update money and adjust the max number of items
- // that can be bought
- mMaxItems -= mAmountItems;
- const ShopItem *const item = mShopItems->at(selectedItem);
- if (item != nullptr)
- setMoney(mMoney - mAmountItems * item->getPrice());
- else
- setMoney(mMoney);
-
- // Reset selection
- mAmountItems = 1;
- mSlider->setScale(1, mMaxItems);
- mSlider->setValue(1);
-}
-
-void BuyDialog::valueChanged(const SelectionEvent &event A_UNUSED)
-{
- // Reset amount of items and update labels
- mAmountItems = 1;
- mSlider->setValue(1);
-
- updateButtonsAndLabels();
- mSlider->setScale(1, mMaxItems);
- mAmountField->setRange(1, mMaxItems);
- mAmountField->setValue(1);
-}
-
-void BuyDialog::updateButtonsAndLabels()
-{
- const int selectedItem = mShopItemList->getSelected();
- int price = 0;
-
- if (selectedItem > -1)
- {
- const ShopItem *const item = mShopItems->at(selectedItem);
- if (item != nullptr)
- {
- const int itemPrice = item->getPrice();
-
- // Calculate how many the player can afford
- if (mNpcId == fromInt(Items, BeingId))
- mMaxItems = 100;
- else if (itemPrice != 0)
- mMaxItems = mMoney / itemPrice;
- else
- mMaxItems = 1;
-
- if (item->getQuantity() > 0 && mMaxItems > item->getQuantity())
- mMaxItems = item->getQuantity();
-
- if (mAmountItems > mMaxItems)
- mAmountItems = mMaxItems;
-
- price = mAmountItems * itemPrice;
- }
- }
- else
- {
- mMaxItems = 0;
- mAmountItems = 0;
- }
-
- mIncreaseButton->setEnabled(mAmountItems < mMaxItems);
- mDecreaseButton->setEnabled(mAmountItems > 1);
- mBuyButton->setEnabled(mAmountItems > 0);
- mSlider->setEnabled(mMaxItems > 1);
- mAmountField->setEnabled(mAmountItems > 0);
-
- mQuantityLabel->setCaption(strprintf("%d / %d", mAmountItems, mMaxItems));
- // TRANSLATORS: buy dialog label
- mMoneyLabel->setCaption(strprintf(_("Price: %s / Total: %s"),
- UnitsDb::formatCurrency(mCurrency, price).c_str(),
- UnitsDb::formatCurrency(mCurrency, mMoney - price).c_str()));
-}
-
-void BuyDialog::setVisible(Visible visible)
-{
- Window::setVisible(visible);
-
- if (visible == Visible_true && (mShopItemList != nullptr))
- mShopItemList->requestFocus();
- else
- scheduleDelete();
-}
-
-void BuyDialog::closeAll()
-{
- FOR_EACH (DialogList::const_iterator, it, instances)
- {
- if (*it != nullptr)
- (*it)->close();
- }
-}
-
-void BuyDialog::applyNameFilter(const std::string &filter)
-{
- STD_VECTOR<ShopItem*> &items = mShopItems->allItems();
- std::string filterStr = filter;
- toLower(filterStr);
- FOR_EACH (STD_VECTOR<ShopItem*>::iterator, it, items)
- {
- ShopItem *const item = *it;
- if (item == nullptr)
- continue;
- std::string name = item->getName();
- toLower(name);
- if (name.find(filterStr) != std::string::npos)
- item->setVisible(true);
- else
- item->setVisible(false);
- }
- mShopItems->updateList();
-}
diff --git a/src/gui/windows/buydialog.h b/src/gui/windows/buydialog.h
deleted file mode 100644
index 7914c0ef3..000000000
--- a/src/gui/windows/buydialog.h
+++ /dev/null
@@ -1,207 +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_WINDOWS_BUYDIALOG_H
-#define GUI_WINDOWS_BUYDIALOG_H
-
-#include "enums/resources/item/itemtype.h"
-
-#include "enums/simpletypes/beingid.h"
-#include "enums/simpletypes/itemcolor.h"
-
-#include "gui/widgets/window.h"
-
-#include "listeners/actionlistener.h"
-#include "listeners/selectionlistener.h"
-
-class Being;
-class Button;
-class DropDown;
-class ShopItem;
-class ShopItems;
-class ShopListBox;
-class SortListModelBuy;
-class IntTextField;
-class Label;
-class ScrollArea;
-class Slider;
-class TextField;
-
-/**
- * The buy dialog.
- *
- * \ingroup Interface
- */
-class BuyDialog final : public Window,
- public ActionListener,
- public SelectionListener
-{
- public:
- /**
- * Constructor.
- *
- * @see Window::Window
- */
- BuyDialog();
-
- /**
- * Constructor.
- *
- * @see Window::Window
- */
- BuyDialog(const BeingId npcId,
- const std::string &currency);
-
-#ifdef TMWA_SUPPORT
- /**
- * Constructor.
- *
- * @see Window::Window
- */
- BuyDialog(const std::string &nick,
- const std::string &currency);
-#endif // TMWA_SUPPORT
-
- /**
- * Constructor.
- *
- * @see Window::Window
- */
- BuyDialog(const Being *const being,
- const std::string &currency);
-
- A_DELETE_COPY(BuyDialog)
-
- /**
- * Destructor
- */
- ~BuyDialog();
-
- enum
- {
-#ifdef TMWA_SUPPORT
- Nick = -1,
-#endif // TMWA_SUPPORT
- Items = -2,
- Market = -3,
- Cash = -4,
- Vending = -5
- };
-
- void init();
-
- /**
- * Resets the dialog, clearing shop inventory.
- */
- void reset();
-
- /**
- * Sets the amount of available money.
- */
- void setMoney(const int amount);
-
- /**
- * Adds an item to the shop inventory.
- */
- ShopItem *addItem(const int id,
- const ItemTypeT type,
- const ItemColor color,
- const int amount,
- const int price);
-
- /**
- * Called when receiving actions from the widgets.
- */
- void action(const ActionEvent &event) override final;
-
- /**
- * Returns the number of items in the shop inventory.
- */
- int getNumberOfElements() A_WARN_UNUSED;
-
- /**
- * Updates the labels according to the selected item.
- */
- void valueChanged(const SelectionEvent &event) override final;
-
- /**
- * Updates the state of buttons and labels.
- */
- void updateButtonsAndLabels();
-
- /**
- * Sets the visibility of this window.
- */
- void setVisible(Visible visible) override final;
-
- void sort();
-
- void close() override final;
-
- /**
- * Returns true if any instances exist.
- */
- static bool isActive() A_WARN_UNUSED
- { return !instances.empty(); }
-
- /**
- * Closes all instances.
- */
- static void closeAll();
-
- private:
- void updateSlider(const int selectedItem);
-
- void applyNameFilter(const std::string &filter);
-
- typedef std::list<BuyDialog*> DialogList;
- static DialogList instances;
-
- Button *mBuyButton A_NONNULLPOINTER;
- Button *mConfirmButton A_NONNULLPOINTER;
- Button *mQuitButton A_NONNULLPOINTER;
- Button *mAddMaxButton A_NONNULLPOINTER;
- Button *mIncreaseButton A_NONNULLPOINTER;
- Button *mDecreaseButton A_NONNULLPOINTER;
- ShopListBox *mShopItemList A_NONNULLPOINTER;
- ScrollArea *mScrollArea A_NONNULLPOINTER;
- Label *mMoneyLabel A_NONNULLPOINTER;
- Label *mQuantityLabel A_NONNULLPOINTER;
- Slider *mSlider A_NONNULLPOINTER;
- Label *mAmountLabel A_NONNULLPOINTER;
- IntTextField *mAmountField A_NONNULLPOINTER;
- ShopItems *mShopItems A_NONNULLPOINTER;
- SortListModelBuy *mSortModel;
- DropDown *mSortDropDown;
- TextField *mFilterTextField A_NONNULLPOINTER;
- Label *mFilterLabel;
-
- std::string mNick;
- std::string mCurrency;
- BeingId mNpcId;
- int mMoney;
- int mAmountItems;
- int mMaxItems;
- bool mAdvanced;
-};
-
-#endif // GUI_WINDOWS_BUYDIALOG_H
diff --git a/src/gui/windows/buyingstoreselldialog.cpp b/src/gui/windows/buyingstoreselldialog.cpp
deleted file mode 100644
index 369d52223..000000000
--- a/src/gui/windows/buyingstoreselldialog.cpp
+++ /dev/null
@@ -1,70 +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 "gui/windows/buyingstoreselldialog.h"
-
-#include "actormanager.h"
-
-#include "being/playerinfo.h"
-
-#include "gui/models/shopitems.h"
-
-#include "gui/widgets/shoplistbox.h"
-
-#include "net/buyingstorehandler.h"
-
-#include "resources/inventory/inventory.h"
-
-#include "resources/item/shopitem.h"
-
-#include "debug.h"
-
-BuyingStoreSellDialog::BuyingStoreSellDialog(const BeingId accountId,
- const int storeId) :
- SellDialog(IsSell_true, Advanced_false),
- mAccountId(accountId),
- mStoreId(storeId)
-{
-}
-
-void BuyingStoreSellDialog::sellAction(const ActionEvent &event A_UNUSED)
-{
- if (mAmountItems <= 0 || mAmountItems > mMaxItems)
- return;
-
- const int selectedItem = mShopItemList->getSelected();
- const ShopItem *const item1 = mShopItems->at(selectedItem);
- if ((item1 == nullptr) || PlayerInfo::isItemProtected(item1->getId()))
- return;
- const Being *const being = actorManager->findBeing(mAccountId);
- if (being == nullptr)
- return;
- const Item *const item2 = PlayerInfo::getInventory()->findItem(
- item1->getId(),
- item1->getColor());
- if (item2 == nullptr)
- return;
-
- mPlayerMoney += mAmountItems * item1->getPrice();
- mMaxItems -= mAmountItems;
- buyingStoreHandler->sell(being, mStoreId, item2, mAmountItems);
-}
diff --git a/src/gui/windows/buyingstoreselldialog.h b/src/gui/windows/buyingstoreselldialog.h
deleted file mode 100644
index db2005213..000000000
--- a/src/gui/windows/buyingstoreselldialog.h
+++ /dev/null
@@ -1,55 +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_WINDOWS_BUYINGSTORESELLDIALOG_H
-#define GUI_WINDOWS_BUYINGSTORESELLDIALOG_H
-
-#include "enums/simpletypes/beingid.h"
-
-#include "gui/widgets/selldialog.h"
-
-/**
- * The sell dialog.
- *
- * \ingroup Interface
- */
-class BuyingStoreSellDialog final : public SellDialog
-{
- public:
- /**
- * Constructor.
- *
- * @see Window::Window
- */
- BuyingStoreSellDialog(const BeingId accountId,
- const int storeId);
-
- A_DELETE_COPY(BuyingStoreSellDialog)
-
- protected:
- void sellAction(const ActionEvent &event) override final;
-
- BeingId mAccountId;
- int mStoreId;
-};
-
-#endif // GUI_WINDOWS_BUYINGSTORESELLDIALOG_H
diff --git a/src/gui/windows/buyselldialog.cpp b/src/gui/windows/buyselldialog.cpp
deleted file mode 100644
index 26cf2af17..000000000
--- a/src/gui/windows/buyselldialog.cpp
+++ /dev/null
@@ -1,167 +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 "gui/windows/buyselldialog.h"
-
-#include "actormanager.h"
-
-#include "net/buysellhandler.h"
-#include "net/npchandler.h"
-
-#include "gui/windows/setupwindow.h"
-
-#include "gui/widgets/button.h"
-
-#include "utils/foreach.h"
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-BuySellDialog::DialogList BuySellDialog::dialogInstances;
-
-BuySellDialog::BuySellDialog(const BeingId npcId) :
- // TRANSLATORS: shop window name
- Window(_("Shop"), Modal_false, nullptr, "buysell.xml"),
- ActionListener(),
- mNpcId(npcId),
- mNick(""),
- mBuyButton(nullptr)
-{
- init();
-}
-
-BuySellDialog::BuySellDialog(const std::string &nick) :
- // TRANSLATORS: shop window name
- Window(_("Shop"), Modal_false, nullptr, "buysell.xml"),
- ActionListener(),
- mNpcId(BeingId_negOne),
- mNick(nick),
- mBuyButton(nullptr)
-{
- init();
-}
-
-void BuySellDialog::init()
-{
- setWindowName("BuySell");
- setCloseButton(true);
-
- if (setupWindow != nullptr)
- setupWindow->registerWindowForReset(this);
-
- static const char *const buttonNames[] =
- {
- // TRANSLATORS: shop window button
- N_("Buy"),
- // TRANSLATORS: shop window button
- N_("Sell"),
- // TRANSLATORS: shop window button
- N_("Cancel"),
- nullptr
- };
- const int buttonPadding = getOption("buttonpadding", 10);
- int x = buttonPadding;
- const int y = buttonPadding;
-
- for (const char *const *curBtn = buttonNames;
- *curBtn != nullptr;
- curBtn++)
- {
- Button *const btn = new Button(this, gettext(*curBtn), *curBtn, this);
- if (mBuyButton == nullptr)
- mBuyButton = btn; // For focus request
- btn->setPosition(x, y);
- add(btn);
- x += btn->getWidth() + buttonPadding;
- }
- if (mBuyButton != nullptr)
- {
- mBuyButton->requestFocus();
- setContentSize(x, 2 * y + mBuyButton->getHeight());
- }
-
- center();
- setDefaultSize();
- loadWindowState();
- enableVisibleSound(true);
-
- dialogInstances.push_back(this);
- setVisible(Visible_true);
-}
-
-BuySellDialog::~BuySellDialog()
-{
- dialogInstances.remove(this);
-}
-
-void BuySellDialog::setVisible(Visible visible)
-{
- Window::setVisible(visible);
-
- if (visible == Visible_true)
- {
- if (mBuyButton != nullptr)
- mBuyButton->requestFocus();
- }
- else
- {
- scheduleDelete();
- }
-}
-
-void BuySellDialog::action(const ActionEvent &event)
-{
- const std::string &eventId = event.getId();
- if (eventId == "Buy")
- {
- if (mNpcId != BeingId_negOne)
- {
- const Being *const being = actorManager->findBeing(mNpcId);
- if (being != nullptr)
- npcHandler->buy(being);
- else
- npcHandler->buy(mNpcId);
- }
- else
- {
- buySellHandler->requestSellList(mNick);
- }
- }
- else if (eventId == "Sell")
- {
- if (mNpcId != BeingId_negOne)
- npcHandler->sell(mNpcId);
- else
- buySellHandler->requestBuyList(mNick);
- }
-
- close();
-}
-
-void BuySellDialog::closeAll()
-{
- FOR_EACH (DialogList::const_iterator, it, dialogInstances)
- {
- if (*it != nullptr)
- (*it)->close();
- }
-}
diff --git a/src/gui/windows/buyselldialog.h b/src/gui/windows/buyselldialog.h
deleted file mode 100644
index b2a527d16..000000000
--- a/src/gui/windows/buyselldialog.h
+++ /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/>.
- */
-
-#ifndef GUI_WINDOWS_BUYSELLDIALOG_H
-#define GUI_WINDOWS_BUYSELLDIALOG_H
-
-#include "enums/simpletypes/beingid.h"
-
-#include "gui/widgets/window.h"
-
-#include "listeners/actionlistener.h"
-
-class Button;
-
-/**
- * A dialog to choose between buying or selling at a shop.
- *
- * \ingroup Interface
- */
-class BuySellDialog final : public Window,
- public ActionListener
-{
- public:
- /**
- * Constructor. The action listener passed will receive "sell", "buy"
- * or "cancel" events when the respective buttons are pressed.
- *
- * @see Window::Window
- */
- explicit BuySellDialog(const BeingId npcId);
-
- explicit BuySellDialog(const std::string &nick);
-
- A_DELETE_COPY(BuySellDialog)
-
- ~BuySellDialog();
-
- void init();
-
- void setVisible(Visible visible) override final;
-
- /**
- * Called when receiving actions from the widgets.
- */
- void action(const ActionEvent &event) override final;
-
- /**
- * Returns true if any instances exist.
- */
- static bool isActive() A_WARN_UNUSED
- { return !dialogInstances.empty(); }
-
- /**
- * Closes all instances.
- */
- static void closeAll();
-
- private:
- typedef std::list<BuySellDialog*> DialogList;
- static DialogList dialogInstances;
-
- BeingId mNpcId;
- std::string mNick;
- Button *mBuyButton;
-};
-
-#endif // GUI_WINDOWS_BUYSELLDIALOG_H
diff --git a/src/gui/windows/changeemaildialog.cpp b/src/gui/windows/changeemaildialog.cpp
deleted file mode 100644
index 9d9358967..000000000
--- a/src/gui/windows/changeemaildialog.cpp
+++ /dev/null
@@ -1,186 +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 "gui/windows/changeemaildialog.h"
-
-#include "client.h"
-
-#include "gui/windows/okdialog.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/createwidget.h"
-#include "gui/widgets/label.h"
-#include "gui/widgets/textfield.h"
-
-#include "listeners/wrongdatanoticelistener.h"
-
-#include "net/logindata.h"
-#include "net/loginhandler.h"
-
-#include "utils/delete2.h"
-#include "utils/gettext.h"
-
-#include <sstream>
-
-#include "debug.h"
-
-ChangeEmailDialog::ChangeEmailDialog(LoginData &data) :
- // TRANSLATORS: change email dialog header
- Window(_("Change Email Address"), Modal_true, nullptr, "changeemail.xml"),
- ActionListener(),
- mFirstEmailField(new TextField(this)),
- mSecondEmailField(new TextField(this)),
- // TRANSLATORS: button in change email dialog
- mChangeEmailButton(new Button(this, _("Change Email Address"),
- "change_email", this)),
- // TRANSLATORS: button in change email dialog
- mCancelButton(new Button(this, _("Cancel"), "cancel", this)),
- mWrongDataNoticeListener(new WrongDataNoticeListener),
- mLoginData(&data)
-{
- // TRANSLATORS: label in change email dialog
- Label *const accountLabel = new Label(this, strprintf(_("Account: %s"),
- mLoginData->username.c_str()));
- Label *const newEmailLabel = new Label(this,
- // TRANSLATORS: label in change email dialog
- _("Type new email address twice:"));
-
- const int width = 200;
- const int height = 130;
- setContentSize(width, height);
-
- accountLabel->setPosition(5, 5);
- accountLabel->setWidth(130);
-
- newEmailLabel->setPosition(
- 5, accountLabel->getY() + accountLabel->getHeight() + 7);
- newEmailLabel->setWidth(width - 5);
-
- mFirstEmailField->setPosition(
- 5, newEmailLabel->getY() + newEmailLabel->getHeight() + 7);
- mFirstEmailField->setWidth(130);
-
- mSecondEmailField->setPosition(
- 5, mFirstEmailField->getY() + mFirstEmailField->getHeight() + 7);
- mSecondEmailField->setWidth(130);
-
- mCancelButton->setPosition(
- width - 5 - mCancelButton->getWidth(),
- height - 5 - mCancelButton->getHeight());
- mChangeEmailButton->setPosition(
- mCancelButton->getX() - 5 - mChangeEmailButton->getWidth(),
- mCancelButton->getY());
-
- add(accountLabel);
- add(newEmailLabel);
- add(mFirstEmailField);
- add(mSecondEmailField);
- add(mChangeEmailButton);
- add(mCancelButton);
-
- center();
- mFirstEmailField->requestFocus();
-
- mFirstEmailField->setActionEventId("change_email");
- mSecondEmailField->setActionEventId("change_email");
-}
-
-ChangeEmailDialog::~ChangeEmailDialog()
-{
- delete2(mWrongDataNoticeListener);
-}
-
-void ChangeEmailDialog::action(const ActionEvent &event)
-{
- const std::string &eventId = event.getId();
- if (eventId == "cancel")
- {
- client->setState(State::CHAR_SELECT);
- }
- else if (eventId == "change_email")
- {
- const std::string username = mLoginData->username;
- const std::string &newFirstEmail = mFirstEmailField->getText();
- const std::string &newSecondEmail = mSecondEmailField->getText();
- logger->log("ChangeEmailDialog::Email change, Username is %s",
- username.c_str());
-
- std::stringstream errorMsg;
- int error = 0;
-
- const unsigned int min = loginHandler->getMinPasswordLength();
- const unsigned int max = loginHandler->getMaxPasswordLength();
-
- if (newFirstEmail.length() < min)
- {
- // First email address too short
- // TRANSLATORS: change email error
- errorMsg << strprintf(_("The new email address needs to be at "
- "least %u characters long."), min);
- error = 1;
- }
- else if (newFirstEmail.length() > max)
- {
- // First email address too long
- // TRANSLATORS: change email error
- errorMsg << strprintf(_("The new email address needs to be "
- "less than %u characters long."), max);
- error = 1;
- }
- else if (newFirstEmail != newSecondEmail)
- {
- // Second Pass mismatch
- // TRANSLATORS: change email error
- errorMsg << _("The email address entries mismatch.");
- error = 2;
- }
-
- if (error > 0)
- {
- if (error == 1)
- mWrongDataNoticeListener->setTarget(this->mFirstEmailField);
- else // if (error == 2)
- mWrongDataNoticeListener->setTarget(this->mSecondEmailField);
-
- OkDialog *const dlg = CREATEWIDGETR(OkDialog,
- // TRANSLATORS: change email error header
- _("Error"),
- errorMsg.str(),
- // TRANSLATORS: ok dialog button
- _("OK"),
- DialogType::ERROR,
- Modal_true,
- ShowCenter_true,
- nullptr,
- 260);
- dlg->addActionListener(mWrongDataNoticeListener);
- }
- else
- {
- // No errors detected, change account password.
- mChangeEmailButton->setEnabled(false);
- // Set the new email address
- mLoginData->email = newFirstEmail;
- client->setState(State::CHANGEEMAIL_ATTEMPT);
- }
- }
-}
diff --git a/src/gui/windows/changeemaildialog.h b/src/gui/windows/changeemaildialog.h
deleted file mode 100644
index c20dffd9e..000000000
--- a/src/gui/windows/changeemaildialog.h
+++ /dev/null
@@ -1,81 +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 GUI_WINDOWS_CHANGEEMAILDIALOG_H
-#define GUI_WINDOWS_CHANGEEMAILDIALOG_H
-
-#include "gui/widgets/window.h"
-
-#include "listeners/actionlistener.h"
-
-class Button;
-class LoginData;
-class TextField;
-class WrongDataNoticeListener;
-
-/**
- * The Change email dialog.
- *
- * \ingroup Interface
- */
-class ChangeEmailDialog final : public Window,
- public ActionListener
-{
- public:
- /**
- * Constructor.
- *
- * @see Window::Window
- */
- explicit ChangeEmailDialog(LoginData &data);
-
- A_DELETE_COPY(ChangeEmailDialog)
-
- /**
- * Destructor.
- */
- ~ChangeEmailDialog();
-
- /**
- * Called when receiving actions from the widgets.
- */
- void action(const ActionEvent &event) override final;
-
- /**
- * This is used to pass the pointer to where the new email should be
- * put when the dialog finishes.
- */
- static void setEmail(std::string *email);
-
- private:
- TextField *mFirstEmailField A_NONNULLPOINTER;
- TextField *mSecondEmailField A_NONNULLPOINTER;
-
- Button *mChangeEmailButton A_NONNULLPOINTER;
- Button *mCancelButton A_NONNULLPOINTER;
-
- WrongDataNoticeListener *mWrongDataNoticeListener A_NONNULLPOINTER;
-
- LoginData *mLoginData A_NONNULLPOINTER;
-};
-
-#endif // GUI_WINDOWS_CHANGEEMAILDIALOG_H
diff --git a/src/gui/windows/changepassworddialog.cpp b/src/gui/windows/changepassworddialog.cpp
deleted file mode 100644
index ca29a8ef1..000000000
--- a/src/gui/windows/changepassworddialog.cpp
+++ /dev/null
@@ -1,177 +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 "gui/windows/changepassworddialog.h"
-
-#include "client.h"
-
-#include "gui/windows/okdialog.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/createwidget.h"
-#include "gui/widgets/passwordfield.h"
-#include "gui/widgets/label.h"
-#include "gui/widgets/layoutcell.h"
-
-#include "listeners/wrongdatanoticelistener.h"
-
-#include "net/logindata.h"
-#include "net/loginhandler.h"
-
-#include "utils/delete2.h"
-#include "utils/gettext.h"
-
-#include <sstream>
-
-#include "debug.h"
-
-ChangePasswordDialog::ChangePasswordDialog(LoginData &data) :
- // TRANSLATORS: change password window name
- Window(_("Change Password"), Modal_true, nullptr, "changepassword.xml"),
- ActionListener(),
- mOldPassField(new PasswordField(this)),
- mFirstPassField(new PasswordField(this)),
- mSecondPassField(new PasswordField(this)),
- // TRANSLATORS: change password dialog button
- mChangePassButton(new Button(this, _("Change Password"),
- "change_password", this)),
- // TRANSLATORS: change password dialog button
- mCancelButton(new Button(this, _("Cancel"), "cancel", this)),
- mWrongDataNoticeListener(new WrongDataNoticeListener),
- mLoginData(&data)
-{
- Label *const accountLabel = new Label(this,
- // TRANSLATORS: change password dialog label
- strprintf(_("Account: %s"), mLoginData->username.c_str()));
-
- place(0, 0, accountLabel, 3);
- // TRANSLATORS: change password dialog label
- place(0, 1, new Label(this, _("Password:")), 3);
- place(0, 2, mOldPassField, 3).setPadding(1);
- // TRANSLATORS: change password dialog label
- place(0, 3, new Label(this, _("Type new password twice:")), 3);
- place(0, 4, mFirstPassField, 3).setPadding(1);
- place(0, 5, mSecondPassField, 3).setPadding(1);
- place(1, 6, mCancelButton);
- place(2, 6, mChangePassButton);
- reflowLayout(200);
-
- center();
- mOldPassField->requestFocus();
-
- mOldPassField->setActionEventId("change_password");
- mFirstPassField->setActionEventId("change_password");
- mSecondPassField->setActionEventId("change_password");
-}
-
-ChangePasswordDialog::~ChangePasswordDialog()
-{
- delete2(mWrongDataNoticeListener);
-}
-
-void ChangePasswordDialog::action(const ActionEvent &event)
-{
- const std::string &eventId = event.getId();
- if (eventId == "cancel")
- {
- client->setState(State::CHAR_SELECT);
- }
- else if (eventId == "change_password")
- {
- const std::string username = mLoginData->username;
- const std::string &oldPassword = mOldPassField->getText();
- const std::string &newFirstPass = mFirstPassField->getText();
- const std::string &newSecondPass = mSecondPassField->getText();
- logger->log("ChangePasswordDialog::Password change, Username is %s",
- username.c_str());
-
- std::stringstream errorMsg;
- int error = 0;
-
- const unsigned int min = loginHandler->getMinPasswordLength();
- const unsigned int max = loginHandler->getMaxPasswordLength();
-
- // Check old Password
- if (oldPassword.empty())
- {
- // No old password
- // TRANSLATORS: change password error
- errorMsg << _("Enter the old password first.");
- error = 1;
- }
- else if (newFirstPass.length() < min)
- {
- // First password too short
- // TRANSLATORS: change password error
- errorMsg << strprintf(_("The new password needs to be at least"
- " %u characters long."), min);
- error = 2;
- }
- else if (newFirstPass.length() > max)
- {
- // First password too long
- // TRANSLATORS: change password error
- errorMsg << strprintf(_("The new password needs to be less "
- "than %u characters long."), max);
- error = 2;
- }
- else if (newFirstPass != newSecondPass)
- {
- // Second Pass mismatch
- // TRANSLATORS: change password error
- errorMsg << _("The new password entries mismatch.");
- error = 3;
- }
-
- if (error > 0)
- {
- if (error == 1)
- mWrongDataNoticeListener->setTarget(this->mOldPassField);
- else if (error == 2)
- mWrongDataNoticeListener->setTarget(this->mFirstPassField);
- else // if (error == 3)
- mWrongDataNoticeListener->setTarget(this->mSecondPassField);
-
- OkDialog *const dlg = CREATEWIDGETR(OkDialog,
- // TRANSLATORS: change password error header
- _("Error"),
- errorMsg.str(),
- // TRANSLATORS: ok dialog button
- _("OK"),
- DialogType::ERROR,
- Modal_true,
- ShowCenter_true,
- nullptr,
- 260);
- dlg->addActionListener(mWrongDataNoticeListener);
- }
- else
- {
- // No errors detected, change account password.
- mChangePassButton->setEnabled(false);
- // Set the new password
- mLoginData->password = oldPassword;
- mLoginData->newPassword = newFirstPass;
- client->setState(State::CHANGEPASSWORD_ATTEMPT);
- }
- }
-}
diff --git a/src/gui/windows/changepassworddialog.h b/src/gui/windows/changepassworddialog.h
deleted file mode 100644
index dd5c0d152..000000000
--- a/src/gui/windows/changepassworddialog.h
+++ /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/>.
- */
-
-#ifndef GUI_WINDOWS_CHANGEPASSWORDDIALOG_H
-#define GUI_WINDOWS_CHANGEPASSWORDDIALOG_H
-
-#include "gui/widgets/window.h"
-
-#include "listeners/actionlistener.h"
-
-class Button;
-class LoginData;
-class TextField;
-class WrongDataNoticeListener;
-
-/**
- * The Change password dialog.
- *
- * \ingroup Interface
- */
-class ChangePasswordDialog final : public Window,
- public ActionListener
-{
- public:
- /**
- * Constructor
- *
- * @see Window::Window
- */
- explicit ChangePasswordDialog(LoginData &data);
-
- A_DELETE_COPY(ChangePasswordDialog)
-
- /**
- * Destructor
- */
- ~ChangePasswordDialog();
-
- /**
- * Called when receiving actions from the widgets.
- */
- void action(const ActionEvent &event) override final;
-
- private:
- TextField *mOldPassField A_NONNULLPOINTER;
- TextField *mFirstPassField A_NONNULLPOINTER;
- TextField *mSecondPassField A_NONNULLPOINTER;
-
- Button *mChangePassButton A_NONNULLPOINTER;
- Button *mCancelButton A_NONNULLPOINTER;
-
- WrongDataNoticeListener *mWrongDataNoticeListener A_NONNULLPOINTER;
-
- LoginData *mLoginData A_NONNULLPOINTER;
-};
-
-#endif // GUI_WINDOWS_CHANGEPASSWORDDIALOG_H
diff --git a/src/gui/windows/charcreatedialog.cpp b/src/gui/windows/charcreatedialog.cpp
deleted file mode 100644
index 9037ac614..000000000
--- a/src/gui/windows/charcreatedialog.cpp
+++ /dev/null
@@ -1,885 +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 "gui/windows/charcreatedialog.h"
-
-#include "configuration.h"
-
-#include "enums/being/beingdirection.h"
-
-#include "being/being.h"
-
-#include "gui/windows/okdialog.h"
-
-#include "gui/widgets/button.h"
-#include "gui/windows/charselectdialog.h"
-#include "gui/widgets/createwidget.h"
-#include "gui/widgets/label.h"
-#include "gui/widgets/playerbox.h"
-#include "gui/widgets/slider.h"
-#include "gui/widgets/tabstrip.h"
-#include "gui/widgets/textfield.h"
-
-#include "net/charserverhandler.h"
-#include "net/serverfeatures.h"
-
-#include "resources/iteminfo.h"
-
-#include "resources/db/chardb.h"
-#include "resources/db/colordb.h"
-#include "resources/db/itemdb.h"
-
-#include "utils/delete2.h"
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-#undef ERROR
-
-static const BeingActionT actions[] =
-{
- BeingAction::STAND,
- BeingAction::SIT,
- BeingAction::MOVE,
- BeingAction::ATTACK,
- BeingAction::DEAD
-};
-
-static const uint8_t directions[] =
-{
- BeingDirection::DOWN,
- BeingDirection::RIGHT,
- BeingDirection::UP,
- BeingDirection::LEFT
-};
-
-CharCreateDialog::CharCreateDialog(CharSelectDialog *const parent,
- const int slot) :
- // TRANSLATORS: char create dialog name
- Window(_("New Character"), Modal_true, parent, "charcreate.xml"),
- ActionListener(),
- KeyListener(),
- mCharSelectDialog(parent),
- mNameField(new TextField(this, "")),
- // TRANSLATORS: char create dialog label
- mNameLabel(new Label(this, _("Name:"))),
- mNextHairColorButton(nullptr),
- mPrevHairColorButton(nullptr),
- mHairColorLabel(nullptr),
- mHairColorNameLabel(nullptr),
- mNextHairStyleButton(nullptr),
- mPrevHairStyleButton(nullptr),
- mHairStyleLabel(nullptr),
- mHairStyleNameLabel(nullptr),
- mNextRaceButton(nullptr),
- mPrevRaceButton(nullptr),
- mRaceLabel(nullptr),
- mRaceNameLabel(nullptr),
- mNextLookButton(nullptr),
- mPrevLookButton(nullptr),
- mLookLabel(nullptr),
- mLookNameLabel(nullptr),
- // TRANSLATORS: char create dialog button
- mActionButton(new Button(this, _("^"), "action", this)),
- // TRANSLATORS: char create dialog button
- mRotateButton(new Button(this, _(">"), "rotate", this)),
- mAttributeSlider(),
- mAttributeLabel(),
- mAttributeValue(),
- mAttributesLeft(new Label(this,
- // TRANSLATORS: char create dialog label
- strprintf(_("Please distribute %d points"), 99))),
- // TRANSLATORS: char create dialog button
- mCreateButton(new Button(this, _("Create"), "create", this)),
- // TRANSLATORS: char create dialog button
- mCancelButton(new Button(this, _("Cancel"), "cancel", this)),
- mPlayer(Being::createBeing(BeingId_zero,
- ActorType::Player,
- BeingTypeId_zero,
- nullptr)),
- mPlayerBox(new PlayerBox(this, mPlayer, "charcreate_playerbox.xml",
- "charcreate_selectedplayerbox.xml")),
- mGenderStrip(nullptr),
- mMaxPoints(0),
- mUsedPoints(0),
- mRace(CharDB::getMinRace()),
- mLook(0),
- mMinLook(CharDB::getMinLook()),
- mMaxLook(CharDB::getMaxLook()),
- mMinRace(CharDB::getMinRace()),
- mMaxRace(CharDB::getMaxRace()),
- mHairStyle(0),
- mHairColor(0),
- mMaxY(0U),
- mSlot(slot),
- mDefaultGender(Gender::FEMALE),
- mGender(Gender::UNSPECIFIED),
- maxHairColor(CharDB::getMaxHairColor()),
- minHairColor(CharDB::getMinHairColor()),
- maxHairStyle(CharDB::getMaxHairStyle()),
- minHairStyle(CharDB::getMinHairStyle()),
- mAction(0),
- mDirection(0)
-{
- setStickyButtonLock(true);
- setSticky(true);
- setWindowName("NewCharacter");
-
- const int w = 480;
- const int h = 350;
- setContentSize(w, h);
-
- mPlayer->setGender(Gender::MALE);
- const STD_VECTOR<BeingSlot> &items = CharDB::getDefaultItems();
- int i = 1;
- for (STD_VECTOR<BeingSlot>::const_iterator it = items.begin(),
- it_fend = items.end();
- it != it_fend;
- ++ it, i ++)
- {
- const BeingSlot &beingSlot = *it;
- mPlayer->setSpriteCards(i,
- beingSlot.spriteId,
- beingSlot.cardsId);
- }
-
- if (maxHairColor == 0u)
- maxHairColor = ColorDB::getHairSize();
- if (maxHairStyle == 0u)
- maxHairStyle = ItemDB::getNumOfHairstyles();
-
- if (maxHairStyle != 0u)
- {
- mHairStyle = (CAST_U32(rand())
- % maxHairStyle) + minHairStyle;
- }
- else
- {
- mHairStyle = 0;
- }
- if (maxHairColor != 0u)
- {
- mHairColor = (CAST_U32(rand())
- % maxHairColor) + minHairColor;
- }
- else
- {
- mHairColor = 0;
- }
-
- mNameField->setMaximum(24);
-
- if (maxHairColor > minHairColor)
- {
- // TRANSLATORS: This is a narrow symbol used to denote 'next'.
- // You may change this symbol if your language uses another.
- // TRANSLATORS: char create dialog button
- mNextHairColorButton = new Button(this, _(">"), "nextcolor", this);
- // TRANSLATORS: This is a narrow symbol used to denote 'previous'.
- // You may change this symbol if your language uses another.
- // TRANSLATORS: char create dialog button
- mPrevHairColorButton = new Button(this, _("<"), "prevcolor", this);
- // TRANSLATORS: char create dialog label
- mHairColorLabel = new Label(this, _("Hair color:"));
- mHairColorNameLabel = new Label(this, "");
- }
-
- if (maxHairStyle > minHairStyle)
- {
- // TRANSLATORS: char create dialog button
- mNextHairStyleButton = new Button(this, _(">"), "nextstyle", this);
- // TRANSLATORS: char create dialog button
- mPrevHairStyleButton = new Button(this, _("<"), "prevstyle", this);
- // TRANSLATORS: char create dialog label
- mHairStyleLabel = new Label(this, _("Hair style:"));
- mHairStyleNameLabel = new Label(this, "");
- }
-
- if (serverFeatures->haveRaceSelection() && mMinRace < mMaxRace)
- {
- // TRANSLATORS: char create dialog button
- mNextRaceButton = new Button(this, _(">"), "nextrace", this);
- // TRANSLATORS: char create dialog button
- mPrevRaceButton = new Button(this, _("<"), "prevrace", this);
- // TRANSLATORS: char create dialog label
- mRaceLabel = new Label(this, _("Race:"));
- mRaceNameLabel = new Label(this, "");
- }
- if (serverFeatures->haveLookSelection() && mMinLook < mMaxLook)
- {
- // TRANSLATORS: char create dialog button
- mNextLookButton = new Button(this, _(">"), "nextlook", this);
- // TRANSLATORS: char create dialog button
- mPrevLookButton = new Button(this, _("<"), "prevlook", this);
- // TRANSLATORS: char create dialog label
- mLookLabel = new Label(this, _("Look:"));
- mLookNameLabel = new Label(this, "");
- }
-
- if (serverFeatures->haveCreateCharGender())
- {
- const int forceGender = features.getIntValue("forceCharGender");
- if (forceGender == -1)
- {
- const int size = config.getIntValue("fontSize");
- mGenderStrip = new TabStrip(this,
- "gender_" + getWindowName(),
- size + 16);
- mGenderStrip->setPressFirst(false);
- mGenderStrip->addActionListener(this);
- mGenderStrip->setActionEventId("gender_");
- // TRANSLATORS: one char size female character gender
- mGenderStrip->addButton(_("F"), "f", false);
- if (features.getIntValue("forceAccountGender") == -1)
- {
- if (serverFeatures->haveCharOtherGender())
- {
- // TRANSLATORS: one char size male character gender
- mGenderStrip->addButton(_("M"), "m", true);
- // TRANSLATORS: one char size other character gender
- mGenderStrip->addButton(_("O"), "o", false);
- }
- else
- {
- // TRANSLATORS: one char size male character gender
- mGenderStrip->addButton(_("M"), "m", false);
- // TRANSLATORS: one char size unknown character gender
- mGenderStrip->addButton(_("U"), "u", true);
- }
- }
- else
- {
- // TRANSLATORS: one char size male character gender
- mGenderStrip->addButton(_("M"), "m", true);
- if (serverFeatures->haveCharOtherGender())
- {
- // TRANSLATORS: one char size other character gender
- mGenderStrip->addButton(_("O"), "o", false);
- }
- }
-
-
- mGenderStrip->setVisible(Visible_true);
- add(mGenderStrip);
-
- mGenderStrip->setPosition(385, 130);
- mGenderStrip->setWidth(500);
- mGenderStrip->setHeight(50);
- }
- else
- {
- mGender = Being::intToGender(CAST_U8(forceGender));
- mPlayer->setGender(mGender);
- }
- }
-
- mPlayerBox->setWidth(74);
-
- mNameField->setActionEventId("create");
- mNameField->addActionListener(this);
-
- mPlayerBox->setDimension(Rect(360, 0, 110, 90));
- mActionButton->setPosition(385, 100);
- mRotateButton->setPosition(415, 100);
-
- mNameLabel->setPosition(mPadding, 2);
- mNameField->setDimension(Rect(60, 2,
- 300, mNameField->getHeight()));
-
- const uint32_t labelPadding = getOption("labelPadding", 2);
- const uint32_t leftX = 120 + mPadding;
- const uint32_t rightX = 300 + mPadding;
- const uint32_t labelX = mPadding;
- uint32_t nameX = leftX + labelPadding;
- uint32_t y = 30;
- if (mPrevHairColorButton != nullptr)
- nameX += mPrevHairColorButton->getWidth();
- else if (mPrevHairStyleButton != nullptr)
- nameX += mPrevHairStyleButton->getWidth();
- else if (mPrevLookButton != nullptr)
- nameX += mPrevLookButton->getWidth();
- else if (mPrevRaceButton != nullptr)
- nameX += mPrevRaceButton->getWidth();
-
- if (maxHairColor > minHairColor)
- {
- mPrevHairColorButton->setPosition(leftX, y);
- mNextHairColorButton->setPosition(rightX, y);
- y += 5;
- mHairColorLabel->setPosition(labelX, y);
- mHairColorNameLabel->setPosition(nameX, y);
- y += 24;
- }
- if (maxHairStyle > minHairStyle)
- {
- mPrevHairStyleButton->setPosition(leftX, y);
- mNextHairStyleButton->setPosition(rightX, y);
- y += 5;
- mHairStyleLabel->setPosition(labelX, y);
- mHairStyleNameLabel->setPosition(nameX, y);
- y += 24;
- }
-
- if (serverFeatures->haveLookSelection() && mMinLook < mMaxLook)
- {
- if (mPrevLookButton != nullptr)
- mPrevLookButton->setPosition(leftX, y);
- if (mNextLookButton != nullptr)
- mNextLookButton->setPosition(rightX, y);
- y += 5;
- if (mLookLabel != nullptr)
- mLookLabel->setPosition(labelX, y);
- if (mLookNameLabel != nullptr)
- mLookNameLabel->setPosition(nameX, y); // 93
- y += 24;
- }
- if (serverFeatures->haveRaceSelection() && mMinRace < mMaxRace)
- {
- if (mPrevRaceButton != nullptr)
- mPrevRaceButton->setPosition(leftX, y);
- if (mNextRaceButton != nullptr)
- mNextRaceButton->setPosition(rightX, y);
- y += 5;
- if (mRaceLabel != nullptr)
- mRaceLabel->setPosition(labelX, y);
- if (mRaceNameLabel != nullptr)
- mRaceNameLabel->setPosition(nameX, y);
- }
- mMaxY = y + 29 + getTitlePadding();
-
- updateSliders();
- setButtonsPosition(w, h);
-
- add(mPlayerBox);
- add(mNameField);
- add(mNameLabel);
-
- if (maxHairColor > minHairColor)
- {
- add(mNextHairColorButton);
- add(mPrevHairColorButton);
- add(mHairColorLabel);
- add(mHairColorNameLabel);
- }
-
- if (maxHairStyle > minHairStyle)
- {
- add(mNextHairStyleButton);
- add(mPrevHairStyleButton);
- add(mHairStyleLabel);
- add(mHairStyleNameLabel);
- }
- add(mActionButton);
- add(mRotateButton);
-
- if (serverFeatures->haveLookSelection() && mMinLook < mMaxLook)
- {
- add(mNextLookButton);
- add(mPrevLookButton);
- add(mLookLabel);
- add(mLookNameLabel);
- }
-
- if (serverFeatures->haveRaceSelection() && mMinRace < mMaxRace)
- {
- add(mNextRaceButton);
- add(mPrevRaceButton);
- add(mRaceLabel);
- add(mRaceNameLabel);
- }
-
- add(mAttributesLeft);
- add(mCreateButton);
- add(mCancelButton);
-
- center();
- setVisible(Visible_true);
- mNameField->requestFocus();
-
- updateHair();
- if (serverFeatures->haveRaceSelection() && mMinRace < mMaxRace)
- updateRace();
- if (serverFeatures->haveLookSelection() && mMinLook < mMaxLook)
- updateLook();
- updatePlayer();
-
- addKeyListener(this);
-}
-
-CharCreateDialog::~CharCreateDialog()
-{
- delete2(mPlayer);
-
- if (charServerHandler != nullptr)
- charServerHandler->setCharCreateDialog(nullptr);
-}
-
-void CharCreateDialog::action(const ActionEvent &event)
-{
- const std::string &id = event.getId();
- if (id == "create")
- {
- if (getName().length() >= 4)
- {
- // Attempt to create the character
- mCreateButton->setEnabled(false);
-
- STD_VECTOR<int> atts;
- const size_t sz = mAttributeSlider.size();
- for (size_t i = 0; i < sz; i++)
- {
- atts.push_back(CAST_S32(
- mAttributeSlider[i]->getValue()));
- }
- for (size_t i = sz; i < 6; i ++)
- atts.push_back(1);
-
- const int characterSlot = mSlot;
-
- charServerHandler->newCharacter(getName(),
- characterSlot,
- mGender,
- mHairStyle,
- mHairColor,
- CAST_U8(mRace),
- CAST_U8(mLook),
- atts);
- }
- else
- {
- CREATEWIDGET(OkDialog,
- // TRANSLATORS: char creation error
- _("Error"),
- // TRANSLATORS: char creation error
- _("Your name needs to be at least 4 characters."),
- // TRANSLATORS: ok dialog button
- _("OK"),
- DialogType::ERROR,
- Modal_true,
- ShowCenter_true,
- nullptr,
- 260);
- }
- }
- else if (id == "cancel")
- {
- scheduleDelete();
- }
- else if (id == "nextcolor")
- {
- mHairColor ++;
- updateHair();
- }
- else if (id == "prevcolor")
- {
- mHairColor --;
- updateHair();
- }
- else if (id == "nextstyle")
- {
- mHairStyle ++;
- updateHair();
- }
- else if (id == "prevstyle")
- {
- mHairStyle --;
- updateHair();
- }
- else if (id == "nextrace")
- {
- mRace ++;
- updateRace();
- }
- else if (id == "prevrace")
- {
- mRace --;
- updateRace();
- }
- else if (id == "nextlook")
- {
- mLook ++;
- updateLook();
- }
- else if (id == "prevlook")
- {
- mLook --;
- updateLook();
- }
- else if (id == "statslider")
- {
- updateSliders();
- }
- else if (id == "action")
- {
- mAction ++;
- if (mAction >= 5)
- mAction = 0;
- updatePlayer();
- }
- else if (id == "rotate")
- {
- mDirection ++;
- if (mDirection >= 4)
- mDirection = 0;
- updatePlayer();
- }
- else if (id == "gender_m")
- {
- mGender = Gender::MALE;
- mPlayer->setGender(Gender::MALE);
- }
- else if (id == "gender_f")
- {
- mGender = Gender::FEMALE;
- mPlayer->setGender(Gender::FEMALE);
- }
- else if (id == "gender_u")
- {
- mGender = Gender::UNSPECIFIED;
- mPlayer->setGender(mDefaultGender);
- }
- else if (id == "gender_o")
- {
- mGender = Gender::OTHER;
- mPlayer->setGender(Gender::OTHER);
- }
-}
-
-std::string CharCreateDialog::getName() const
-{
- std::string name = mNameField->getText();
- trim(name);
- return name;
-}
-
-void CharCreateDialog::updateSliders()
-{
- for (size_t i = 0, sz = mAttributeSlider.size(); i < sz; i++)
- {
- // Update captions
- mAttributeValue[i]->setCaption(
- toString(CAST_S32(mAttributeSlider[i]->getValue())));
- mAttributeValue[i]->adjustSize();
- }
-
- // Update distributed points
- const int pointsLeft = mMaxPoints - getDistributedPoints();
- if (pointsLeft == 0)
- {
- // TRANSLATORS: char create dialog label
- mAttributesLeft->setCaption(_("Character stats OK"));
- mCreateButton->setEnabled(true);
- }
- else
- {
- mCreateButton->setEnabled(false);
- if (pointsLeft > 0)
- {
- mAttributesLeft->setCaption(
- // TRANSLATORS: char create dialog label
- strprintf(_("Please distribute %d points"), pointsLeft));
- }
- else
- {
- mAttributesLeft->setCaption(
- // TRANSLATORS: char create dialog label
- strprintf(_("Please remove %d points"), -pointsLeft));
- }
- }
-
- mAttributesLeft->adjustSize();
-}
-
-void CharCreateDialog::unlock()
-{
- mCreateButton->setEnabled(true);
-}
-
-int CharCreateDialog::getDistributedPoints() const
-{
- int points = 0;
-
- for (size_t i = 0, sz = mAttributeSlider.size(); i < sz; i++)
- points += CAST_S32(mAttributeSlider[i]->getValue());
- return points;
-}
-
-void CharCreateDialog::setAttributes(const StringVect &labels,
- int available,
- const int min, const int max)
-{
- size_t sz;
-
- if (min == max || available == 0)
- {
- sz = 0U;
- available = 0;
- }
- else
- {
- sz = labels.size();
- }
-
- mMaxPoints = available;
-
- for (size_t i = 0; i < mAttributeLabel.size(); i++)
- {
- remove(mAttributeLabel[i]);
- delete2(mAttributeLabel[i])
- remove(mAttributeSlider[i]);
- delete2(mAttributeSlider[i])
- remove(mAttributeValue[i]);
- delete2(mAttributeValue[i])
- }
-
- mAttributeLabel.resize(sz);
- mAttributeSlider.resize(sz);
- mAttributeValue.resize(sz);
-
- const uint32_t w = 480;
- uint32_t h = 350;
- uint32_t y = 89;
- if (serverFeatures->haveLookSelection() && mMinLook < mMaxLook)
- y += 29;
- if (serverFeatures->haveRaceSelection() && mMinRace < mMaxRace)
- y += 29;
-
- for (size_t i = 0; i < sz; i++)
- {
- mAttributeLabel[i] = new Label(this, labels[i]);
- mAttributeLabel[i]->setWidth(70);
- mAttributeLabel[i]->setPosition(mPadding,
- y + CAST_S32(i * 24));
- mAttributeLabel[i]->adjustSize();
- add(mAttributeLabel[i]);
-
- mAttributeSlider[i] = new Slider(this, min, max, 1.0);
- mAttributeSlider[i]->setDimension(Rect(140 + mPadding,
- y + CAST_S32(i * 24),
- 150,
- 12));
- mAttributeSlider[i]->setActionEventId("statslider");
- mAttributeSlider[i]->addActionListener(this);
- add(mAttributeSlider[i]);
-
- mAttributeValue[i] = new Label(this, toString(min));
- mAttributeValue[i]->setPosition(295 + mPadding,
- y + CAST_S32(i * 24));
- add(mAttributeValue[i]);
- }
-
- updateSliders();
- if (available == 0)
- {
- mAttributesLeft->setVisible(Visible_false);
- h = y;
- }
- else
- {
- h = y +
- CAST_S32(sz) * 24 +
- mAttributesLeft->getHeight() +
- getPadding();
- }
- if (serverFeatures->haveCreateCharGender() &&
- features.getIntValue("forceCharGender") == -1 &&
- y < 160)
- {
- if (h < 160)
- h = 160;
- }
- if (h < mMaxY)
- h = mMaxY;
- if (serverFeatures->haveCreateCharGender())
- {
- const int forceGender = features.getIntValue("forceCharGender");
- if (forceGender == -1 && h < 180)
- h = 180;
- else if (h < 120)
- h = 120;
- }
- h += mCreateButton->getHeight();
-
- setContentSize(w, h);
- setButtonsPosition(w, h);
-}
-
-void CharCreateDialog::setDefaultGender(const GenderT gender)
-{
- if (features.getIntValue("forceCharGender") != -1)
- return;
-
- mDefaultGender = gender;
- mPlayer->setGender(gender);
-}
-
-void CharCreateDialog::updateHair()
-{
- if (mHairStyle <= 0)
- mHairStyle = ItemDB::getNumOfHairstyles() - 1;
- else
- mHairStyle %= ItemDB::getNumOfHairstyles();
- if (mHairStyle < CAST_S32(minHairStyle)
- || mHairStyle > CAST_S32(maxHairStyle))
- {
- mHairStyle = minHairStyle;
- }
- const ItemInfo &item = ItemDB::get(-mHairStyle);
- if (mHairStyleNameLabel != nullptr)
- {
- mHairStyleNameLabel->setCaption(item.getName());
- mHairStyleNameLabel->resizeTo(150, 150);
- }
-
- if (ColorDB::getHairSize() != 0)
- mHairColor %= ColorDB::getHairSize();
- else
- mHairColor = 0;
- if (mHairColor < 0)
- mHairColor += ColorDB::getHairSize();
- if (mHairColor < CAST_S32(minHairColor)
- || mHairColor > CAST_S32(maxHairColor))
- {
- mHairColor = minHairColor;
- }
- if (mHairColorNameLabel != nullptr)
- {
- mHairColorNameLabel->setCaption(ColorDB::getHairColorName(
- fromInt(mHairColor, ItemColor)));
- mHairColorNameLabel->resizeTo(150, 150);
- }
-
- mPlayer->setSpriteColor(charServerHandler->hairSprite(),
- mHairStyle * -1,
- item.getDyeColorsString(fromInt(mHairColor, ItemColor)));
- updatePlayer();
-}
-
-void CharCreateDialog::updateRace()
-{
- if (mRace < mMinRace)
- mRace = mMaxRace;
- else if (mRace > mMaxRace)
- mRace = mMinRace;
-
- updateLook();
-}
-
-void CharCreateDialog::updateLook()
-{
- const ItemInfo &item = ItemDB::get(-100 - mRace);
- const int sz = item.getColorsSize();
- if (sz > 0 && serverFeatures->haveLookSelection())
- {
- if (mLook < 0)
- mLook = sz - 1;
- if (mLook > mMaxLook)
- mLook = mMinLook;
- if (mLook >= sz)
- mLook = mMinLook;
- }
- else
- {
- mLook = 0;
- }
- mPlayer->setSubtype(fromInt(mRace, BeingTypeId),
- CAST_U8(mLook));
- if (mRaceNameLabel != nullptr)
- {
- mRaceNameLabel->setCaption(item.getName());
- mRaceNameLabel->resizeTo(150, 150);
- }
- if (mLookNameLabel != nullptr)
- {
- mLookNameLabel->setCaption(item.getColorName(
- fromInt(mLook, ItemColor)));
- mLookNameLabel->resizeTo(150, 150);
- }
-}
-
-void CharCreateDialog::logic()
-{
- BLOCK_START("CharCreateDialog::logic")
- if (mPlayer != nullptr)
- mPlayer->logic();
- BLOCK_END("CharCreateDialog::logic")
-}
-
-void CharCreateDialog::updatePlayer()
-{
- if (mPlayer != nullptr)
- {
- mPlayer->setDirection(directions[mDirection]);
- mPlayer->setAction(actions[mAction], 0);
- }
-}
-
-void CharCreateDialog::keyPressed(KeyEvent &event)
-{
- const InputActionT actionId = event.getActionId();
- PRAGMA45(GCC diagnostic push)
- PRAGMA45(GCC diagnostic ignored "-Wswitch-enum")
- switch (actionId)
- {
- case InputAction::GUI_CANCEL:
- event.consume();
- action(ActionEvent(mCancelButton,
- mCancelButton->getActionEventId()));
- break;
-
- default:
- break;
- }
- PRAGMA45(GCC diagnostic pop)
-}
-
-void CharCreateDialog::setButtonsPosition(const int w, const int h)
-{
- const int h2 = h - 5 - mCancelButton->getHeight();
- if (mainGraphics->getHeight() < 480)
- {
- if (mMaxPoints != 0)
- {
- mCreateButton->setPosition(337, 160);
- mCancelButton->setPosition(337 + mCreateButton->getWidth(), 160);
- }
- else
- {
- mCancelButton->setPosition(
- w / 2,
- 160);
- mCreateButton->setPosition(
- mCancelButton->getX() - 5 - mCreateButton->getWidth(),
- 160);
- }
- }
- else
- {
- mCancelButton->setPosition(
- w / 2,
- h2);
- mCreateButton->setPosition(
- mCancelButton->getX() - 5 - mCreateButton->getWidth(),
- h2);
- }
- mAttributesLeft->setPosition(15, h2 - mAttributesLeft->getHeight());
-}
diff --git a/src/gui/windows/charcreatedialog.h b/src/gui/windows/charcreatedialog.h
deleted file mode 100644
index 5c4fdfcc3..000000000
--- a/src/gui/windows/charcreatedialog.h
+++ /dev/null
@@ -1,171 +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 GUI_WINDOWS_CHARCREATEDIALOG_H
-#define GUI_WINDOWS_CHARCREATEDIALOG_H
-
-#include "enums/being/gender.h"
-
-#include "gui/widgets/window.h"
-
-#include "listeners/actionlistener.h"
-#include "listeners/keylistener.h"
-
-class Being;
-class Button;
-class CharSelectDialog;
-class Label;
-class PlayerBox;
-class Slider;
-class TabStrip;
-class TextField;
-
-/**
- * Character creation dialog.
- *
- * \ingroup Interface
- */
-class CharCreateDialog final : public Window,
- public ActionListener,
- public KeyListener
-{
- public:
- /**
- * Constructor.
- */
- CharCreateDialog(CharSelectDialog *const parent, const int slot);
-
- A_DELETE_COPY(CharCreateDialog)
-
- /**
- * Destructor.
- */
- ~CharCreateDialog();
-
- void action(const ActionEvent &event) override final;
-
- /**
- * Unlocks the dialog, enabling the create character button again.
- */
- void unlock();
-
- void setAttributes(const StringVect &labels,
- int available,
- const int min, const int max);
-
- void setDefaultGender(const GenderT gender = Gender::FEMALE);
-
- void logic() override final;
-
- void updatePlayer();
-
- void keyPressed(KeyEvent &event) override final;
-
- private:
- int getDistributedPoints() const A_WARN_UNUSED;
-
- void updateSliders();
-
- void setButtonsPosition(const int w, const int h);
-
- /**
- * Returns the name of the character to create.
- */
- std::string getName() const A_WARN_UNUSED;
-
- /**
- * Communicate character creation to the server.
- */
- void attemptCharCreate();
-
- void updateHair();
-
- void updateRace();
-
- void updateLook();
-
- CharSelectDialog *mCharSelectDialog;
-
- TextField *mNameField A_NONNULLPOINTER;
- Label *mNameLabel A_NONNULLPOINTER;
- Button *mNextHairColorButton A_NONNULLPOINTER;
- Button *mPrevHairColorButton A_NONNULLPOINTER;
- Label *mHairColorLabel A_NONNULLPOINTER;
- Label *mHairColorNameLabel A_NONNULLPOINTER;
- Button *mNextHairStyleButton A_NONNULLPOINTER;
- Button *mPrevHairStyleButton A_NONNULLPOINTER;
- Label *mHairStyleLabel A_NONNULLPOINTER;
- Label *mHairStyleNameLabel A_NONNULLPOINTER;
- Button *mNextRaceButton;
- Button *mPrevRaceButton;
- Label *mRaceLabel;
- Label *mRaceNameLabel;
- Button *mNextLookButton;
- Button *mPrevLookButton;
- Label *mLookLabel;
- Label *mLookNameLabel;
-
- Button *mActionButton;
- Button *mRotateButton;
-
- STD_VECTOR<Slider*> mAttributeSlider;
- STD_VECTOR<Label*> mAttributeLabel;
- STD_VECTOR<Label*> mAttributeValue;
- Label *mAttributesLeft;
-
- Button *mCreateButton;
- Button *mCancelButton;
-
- Being *mPlayer;
- PlayerBox *mPlayerBox;
-
- TabStrip *mGenderStrip;
-
- int mMaxPoints;
- int mUsedPoints;
-
- int mRace;
- int mLook;
- int mMinLook;
- int mMaxLook;
- int mMinRace;
- int mMaxRace;
-
- int mHairStyle;
- int mHairColor;
- uint32_t mMaxY;
-
- int mSlot;
-
- GenderT mDefaultGender;
- GenderT mGender;
-
- unsigned int maxHairColor;
- unsigned int minHairColor;
- unsigned int maxHairStyle;
- unsigned int minHairStyle;
-
- unsigned int mAction;
- unsigned int mDirection;
-};
-
-#endif // GUI_WINDOWS_CHARCREATEDIALOG_H
diff --git a/src/gui/windows/chardeleteconfirm.h b/src/gui/windows/chardeleteconfirm.h
deleted file mode 100644
index 7049050a3..000000000
--- a/src/gui/windows/chardeleteconfirm.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 GUI_WINDOWS_CHARDELETECONFIRM_H
-#define GUI_WINDOWS_CHARDELETECONFIRM_H
-
-#include "gui/windows/charselectdialog.h"
-#include "gui/windows/confirmdialog.h"
-
-#include "utils/gettext.h"
-
-#include "localconsts.h"
-
-/**
- * Listener for confirming character deletion.
- */
-class CharDeleteConfirm final : public ConfirmDialog
-{
- public:
- CharDeleteConfirm(CharSelectDialog *const m, const int index) :
- // TRANSLATORS: char deletion message
- ConfirmDialog(_("Confirm Character Delete"),
- // TRANSLATORS: char deletion message
- _("Are you sure you want to delete this character?"),
- SOUND_REQUEST, false, Modal_false, m),
- mMaster(m),
- mIndex(index)
- {
- }
-
- A_DELETE_COPY(CharDeleteConfirm)
-
- void action(const ActionEvent &event) override final
- {
- if (event.getId() == "yes" && (mMaster != nullptr))
- mMaster->askPasswordForDeletion(mIndex);
-
- ConfirmDialog::action(event);
- }
-
- private:
- CharSelectDialog *mMaster;
- int mIndex;
-};
-
-#endif // GUI_WINDOWS_CHARDELETECONFIRM_H
diff --git a/src/gui/windows/charselectdialog.cpp b/src/gui/windows/charselectdialog.cpp
deleted file mode 100644
index 5a0a02acb..000000000
--- a/src/gui/windows/charselectdialog.cpp
+++ /dev/null
@@ -1,644 +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 "gui/windows/charselectdialog.h"
-
-#include "client.h"
-#include "configuration.h"
-
-#include "listeners/charrenamelistener.h"
-#include "listeners/pincodelistener.h"
-
-#include "gui/windows/charcreatedialog.h"
-#include "gui/windows/chardeleteconfirm.h"
-#include "gui/windows/editdialog.h"
-#include "gui/windows/logindialog.h"
-#include "gui/windows/okdialog.h"
-#include "gui/windows/textdialog.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/characterdisplay.h"
-#include "gui/widgets/characterviewnormal.h"
-#include "gui/widgets/characterviewsmall.h"
-#include "gui/widgets/containerplacer.h"
-#include "gui/widgets/createwidget.h"
-
-#include "net/character.h"
-#include "net/charserverhandler.h"
-#include "net/logindata.h"
-#ifdef TMWA_SUPPORT
-#include "net/net.h"
-#endif // TMWA_SUPPORT
-#include "net/serverfeatures.h"
-
-#include "utils/foreach.h"
-
-#include "resources/db/unitsdb.h"
-
-#include "debug.h"
-
-// Character slots per row in the dialog
-static const int SLOTS_PER_ROW = 5;
-
-CharSelectDialog::CharSelectDialog(LoginData &data) :
- // TRANSLATORS: char select dialog name
- Window(strprintf(_("Account %s (last login time %s)"),
- data.username.c_str(), data.lastLogin.c_str()),
- Modal_false,
- nullptr,
- "char.xml"),
- ActionListener(),
- KeyListener(),
- mLoginData(&data),
- // TRANSLATORS: char select dialog. button.
- mSwitchLoginButton(new Button(this, _("Switch"), "switch", this)),
- // TRANSLATORS: char select dialog. button.
- mChangePasswordButton(new Button(this, _("Password"),
- "change_password", this)),
- // TRANSLATORS: char select dialog. button.
- mPlayButton(new Button(this, _("Play"), "use", this)),
- // TRANSLATORS: char select dialog. button.
- mInfoButton(new Button(this, _("Info"), "info", this)),
- // TRANSLATORS: char select dialog. button.
- mDeleteButton(new Button(this, _("Delete"), "delete", this)),
- // TRANSLATORS: char select dialog. button.
- mRenameButton(nullptr),
- mCharacterView(nullptr),
- mCharacterEntries(0),
- mCharServerHandler(charServerHandler),
- mDeleteDialog(nullptr),
- mDeleteIndex(-1),
- mLocked(false),
- mSmallScreen(mainGraphics->getWidth() < 470
- || mainGraphics->getHeight() < 370)
-{
- setCloseButton(true);
- setFocusable(true);
-
- ContainerPlacer placer;
- placer = getPlacer(0, 0);
-
- placer(0, 0, mSwitchLoginButton);
-
- int n = 1;
- placer(n, 0, mChangePasswordButton);
- n ++;
- placer(n, 0, mDeleteButton);
- n ++;
-#ifdef TMWA_SUPPORT
- if (Net::getNetworkType() != ServerType::TMWATHENA)
-#endif
- {
- mRenameButton = new Button(this,
- // TRANSLATORS: character rename button
- _("Rename"),
- "rename",
- this);
- placer(n, 0, mRenameButton);
- n ++;
- }
- placer(n, 0, mInfoButton);
- n ++;
-
- for (int i = 0; i < CAST_S32(mLoginData->characterSlots); i++)
- {
- CharacterDisplay *const character = new CharacterDisplay(this, this);
- character->setVisible(Visible_false);
- mCharacterEntries.push_back(character);
- }
-
- placer(0, 2, mPlayButton);
-
- if (!mSmallScreen)
- {
- mCharacterView = new CharacterViewNormal(
- this, &mCharacterEntries, mPadding);
- placer(0, 1, mCharacterView, 10);
- int sz = 410 + 2 * mPadding;
- if (config.getIntValue("fontSize") > 18)
- sz = 500 + 2 * mPadding;
- const int width = mCharacterView->getWidth() + 2 * mPadding;
- if (sz < width)
- sz = width;
- if (sz > mainGraphics->getWidth())
- sz = mainGraphics->getWidth();
- reflowLayout(sz);
- }
- else
- {
- // TRANSLATORS: char select dialog name
- setCaption(strprintf(_("Account %s"), mLoginData->username.c_str()));
- mCharacterView = new CharacterViewSmall(
- this, &mCharacterEntries, mPadding);
- mCharacterView->setWidth(mainGraphics->getWidth()
- - 2 * getPadding());
- placer(0, 1, mCharacterView, 10);
- reflowLayout();
- }
- addKeyListener(this);
- center();
-
- charServerHandler->setCharSelectDialog(this);
- mCharacterView->show(0);
- updateState();
-}
-
-CharSelectDialog::~CharSelectDialog()
-{
-}
-
-void CharSelectDialog::postInit()
-{
- Window::postInit();
- setVisible(Visible_true);
- requestFocus();
- if (charServerHandler->isNeedCreatePin())
- {
- EditDialog *const dialog = CREATEWIDGETR(EditDialog,
- // TRANSLATORS: pin code dialog header.
- _("Please set new pincode"),
- "",
- "OK");
- dialog->addActionListener(&pincodeListener);
- }
-}
-
-void CharSelectDialog::action(const ActionEvent &event)
-{
- // Check if a button of a character was pressed
- const Widget *const sourceParent = event.getSource()->getParent();
- int selected = -1;
- for (unsigned int i = 0, fsz = CAST_U32(
- mCharacterEntries.size());
- i < fsz;
- ++i)
- {
- if (mCharacterEntries[i] == sourceParent)
- {
- selected = i;
- mCharacterView->show(i);
- updateState();
- break;
- }
- }
- if (selected == -1)
- selected = mCharacterView->getSelected();
-
- const std::string &eventId = event.getId();
-
- if (selected >= 0)
- {
- if (eventId == "use")
- {
- use(selected);
- return;
- }
- else if (eventId == "delete"
- && (mCharacterEntries[selected]->getCharacter() != nullptr))
- {
- CREATEWIDGET(CharDeleteConfirm, this, selected);
- return;
- }
- else if (eventId == "rename"
- && (mCharacterEntries[selected]->getCharacter() != nullptr))
- {
- const LocalPlayer *const player = mCharacterEntries[
- selected]->getCharacter()->dummy;
- EditDialog *const dialog = CREATEWIDGETR(EditDialog,
- // TRANSLATORS: character rename dialog header.
- _("Please enter new name"),
- player->getName(),
- "OK");
- charRenameListener.setId(player->getId());
- charRenameListener.setDialog(dialog);
- dialog->addActionListener(&charRenameListener);
- }
- else if (eventId == "info")
- {
- Net::Character *const character = mCharacterEntries[
- selected]->getCharacter();
- if (character == nullptr)
- return;
-
- const LocalPlayer *const data = character->dummy;
- if (data == nullptr)
- return;
-
- const std::string strExp = toString(CAST_U64(
- character->data.mAttributes[Attributes::PLAYER_EXP]));
- const std::string msg = strprintf(
- // TRANSLATORS: char select dialog. player info message.
- _("Hp: %u/%u\nMp: %u/%u\nLevel: %u\n"
- "Experience: %s\nMoney: %s"),
- CAST_U32(
- character->data.mAttributes[Attributes::PLAYER_HP]),
- CAST_U32(
- character->data.mAttributes[Attributes::PLAYER_MAX_HP]),
- CAST_U32(
- character->data.mAttributes[Attributes::PLAYER_MP]),
- CAST_U32(
- character->data.mAttributes[Attributes::PLAYER_MAX_MP]),
- CAST_U32(
- character->data.mAttributes[Attributes::PLAYER_BASE_LEVEL]),
- strExp.c_str(),
- UnitsDb::formatCurrency(CAST_S32(
- character->data.mAttributes[Attributes::MONEY])).c_str());
- CREATEWIDGET(OkDialog, data->getName(), msg,
- // TRANSLATORS: ok dialog button
- _("OK"),
- DialogType::SILENCE,
- Modal_true,
- ShowCenter_true,
- nullptr,
- 260);
- }
- }
- if (eventId == "switch")
- {
- charServerHandler->clear();
- close();
- }
- else if (eventId == "change_password")
- {
- client->setState(State::CHANGEPASSWORD);
- }
- else if (eventId == "change_email")
- {
- client->setState(State::CHANGEEMAIL);
- }
- else if (eventId == "try delete character")
- {
- if ((mDeleteDialog != nullptr) && mDeleteIndex != -1)
- {
- if (serverFeatures->haveEmailOnDelete())
- {
- attemptCharacterDelete(mDeleteIndex, mDeleteDialog->getText());
- mDeleteDialog = nullptr;
- }
- else if (mDeleteDialog->getText() == LoginDialog::savedPassword)
- {
- attemptCharacterDelete(mDeleteIndex, "");
- mDeleteDialog = nullptr;
- }
- else
- {
- CREATEWIDGET(OkDialog,
- // TRANSLATORS: error header
- _("Error"),
- // TRANSLATORS: error message
- _("Incorrect password"),
- // TRANSLATORS: ok dialog button
- _("OK"),
- DialogType::ERROR,
- Modal_true,
- ShowCenter_true,
- nullptr,
- 260);
- }
- }
- mDeleteIndex = -1;
- }
-}
-
-void CharSelectDialog::use(const int selected)
-{
- if ((mCharacterEntries[selected] != nullptr)
- && (mCharacterEntries[selected]->getCharacter() != nullptr))
- {
- attemptCharacterSelect(selected);
- }
- else
- {
- CharCreateDialog *const charCreateDialog =
- CREATEWIDGETR(CharCreateDialog, this, selected);
- mCharServerHandler->setCharCreateDialog(charCreateDialog);
- }
-}
-
-void CharSelectDialog::keyPressed(KeyEvent &event)
-{
- const InputActionT actionId = event.getActionId();
- PRAGMA45(GCC diagnostic push)
- PRAGMA45(GCC diagnostic ignored "-Wswitch-enum")
- switch (actionId)
- {
- case InputAction::GUI_CANCEL:
- event.consume();
- action(ActionEvent(mSwitchLoginButton,
- mSwitchLoginButton->getActionEventId()));
- break;
-
- case InputAction::GUI_RIGHT:
- {
- event.consume();
- int idx = mCharacterView->getSelected();
- if (idx >= 0)
- {
- idx ++;
- if (idx == SLOTS_PER_ROW)
- break;
- mCharacterView->show(idx);
- updateState();
- }
- break;
- }
-
- case InputAction::GUI_LEFT:
- {
- event.consume();
- int idx = mCharacterView->getSelected();
- if (idx >= 0)
- {
- if ((idx == 0) || idx == SLOTS_PER_ROW)
- break;
- idx --;
- mCharacterView->show(idx);
- updateState();
- }
- break;
- }
-
- case InputAction::GUI_UP:
- {
- event.consume();
- int idx = mCharacterView->getSelected();
- if (idx >= 0)
- {
- if (idx < SLOTS_PER_ROW)
- break;
- idx -= SLOTS_PER_ROW;
- mCharacterView->show(idx);
- updateState();
- }
- break;
- }
-
- case InputAction::GUI_DOWN:
- {
- event.consume();
- int idx = mCharacterView->getSelected();
- if (idx >= 0)
- {
- if (idx >= SLOTS_PER_ROW)
- break;
- idx += SLOTS_PER_ROW;
- mCharacterView->show(idx);
- updateState();
- }
- break;
- }
-
- case InputAction::GUI_DELETE:
- {
- event.consume();
- const int idx = mCharacterView->getSelected();
- if (idx >= 0 && (mCharacterEntries[idx] != nullptr)
- && (mCharacterEntries[idx]->getCharacter() != nullptr))
- {
- CREATEWIDGET(CharDeleteConfirm, this, idx);
- }
- break;
- }
-
- case InputAction::GUI_SELECT:
- {
- event.consume();
- use(mCharacterView->getSelected());
- break;
- }
- default:
- break;
- }
- PRAGMA45(GCC diagnostic pop)
-}
-
-/**
- * Communicate character deletion to the server.
- */
-void CharSelectDialog::attemptCharacterDelete(const int index,
- const std::string &email)
-{
- if (mLocked)
- return;
-
- if (mCharacterEntries[index] != nullptr)
- {
- mCharServerHandler->deleteCharacter(
- mCharacterEntries[index]->getCharacter(),
- email);
- }
- lock();
-}
-
-void CharSelectDialog::askPasswordForDeletion(const int index)
-{
- mDeleteIndex = index;
- if (serverFeatures->haveEmailOnDelete())
- {
- CREATEWIDGETV(mDeleteDialog, TextDialog,
- // TRANSLATORS: char deletion question.
- _("Enter your email for deleting character"),
- // TRANSLATORS: email label.
- _("Enter email:"),
- this, false);
- }
- else
- {
- CREATEWIDGETV(mDeleteDialog, TextDialog,
- // TRANSLATORS: char deletion question.
- _("Enter password for deleting character"),
- // TRANSLATORS: email label.
- _("Enter password:"),
- this, true);
- }
- mDeleteDialog->setActionEventId("try delete character");
- mDeleteDialog->addActionListener(this);
-}
-
-/**
- * Communicate character selection to the server.
- */
-void CharSelectDialog::attemptCharacterSelect(const int index)
-{
- if (mLocked || (mCharacterEntries[index] == nullptr))
- return;
-
- setVisible(Visible_false);
- if (mCharServerHandler != nullptr)
- {
- mCharServerHandler->chooseCharacter(
- mCharacterEntries[index]->getCharacter());
- }
- lock();
-}
-
-void CharSelectDialog::setCharacters(const Net::Characters &characters)
-{
- // Reset previous characters
- FOR_EACH (STD_VECTOR<CharacterDisplay*>::const_iterator,
- iter, mCharacterEntries)
- {
- if (*iter != nullptr)
- (*iter)->setCharacter(nullptr);
- }
-
- FOR_EACH (Net::Characters::const_iterator, i, characters)
- setCharacter(*i);
- updateState();
-}
-
-void CharSelectDialog::setCharacter(Net::Character *const character)
-{
- if (character == nullptr)
- return;
- const int characterSlot = character->slot;
- if (characterSlot >= CAST_S32(mCharacterEntries.size()))
- {
- logger->log("Warning: slot out of range: %d", character->slot);
- return;
- }
-
- if (mCharacterEntries[characterSlot] != nullptr)
- mCharacterEntries[characterSlot]->setCharacter(character);
-}
-
-void CharSelectDialog::lock()
-{
- if (!mLocked)
- setLocked(true);
-}
-
-void CharSelectDialog::unlock()
-{
- setLocked(false);
-}
-
-void CharSelectDialog::setLocked(const bool locked)
-{
- mLocked = locked;
-
- if (mSwitchLoginButton != nullptr)
- mSwitchLoginButton->setEnabled(!locked);
- if (mChangePasswordButton != nullptr)
- mChangePasswordButton->setEnabled(!locked);
- mPlayButton->setEnabled(!locked);
- if (mDeleteButton != nullptr)
- mDeleteButton->setEnabled(!locked);
-
- for (size_t i = 0, sz = mCharacterEntries.size(); i < sz; ++i)
- {
- if (mCharacterEntries[i] != nullptr)
- mCharacterEntries[i]->setActive(!mLocked);
- }
-}
-
-bool CharSelectDialog::selectByName(const std::string &name,
- const SelectAction selAction)
-{
- if (mLocked)
- return false;
-
- for (size_t i = 0, sz = mCharacterEntries.size(); i < sz; ++i)
- {
- if (mCharacterEntries[i] != nullptr)
- {
- const Net::Character *const character
- = mCharacterEntries[i]->getCharacter();
- if (character != nullptr)
- {
- if (character->dummy != nullptr &&
- character->dummy->getName() == name)
- {
- mCharacterView->show(CAST_S32(i));
- updateState();
- if (selAction == Choose)
- attemptCharacterSelect(CAST_S32(i));
- return true;
- }
- }
- }
- }
-
- return false;
-}
-
-void CharSelectDialog::close()
-{
- client->setState(State::SWITCH_LOGIN);
- Window::close();
-}
-
-void CharSelectDialog::widgetResized(const Event &event)
-{
- Window::widgetResized(event);
- mCharacterView->resize();
-}
-
-void CharSelectDialog::updateState()
-{
- const int idx = mCharacterView->getSelected();
- if (idx == -1)
- {
- mPlayButton->setEnabled(false);
- return;
- }
- mPlayButton->setEnabled(true);
-
- if (mCharacterEntries[idx] != nullptr &&
- mCharacterEntries[idx]->getCharacter() != nullptr)
- {
- // TRANSLATORS: char select dialog. button.
- mPlayButton->setCaption(_("Play"));
-
- const LocalPlayer *const player = mCharacterEntries[
- idx]->getCharacter()->dummy;
- if ((player != nullptr) && (mRenameButton != nullptr))
- mRenameButton->setEnabled(player->getRename() ? true : false);
- }
- else
- {
- // TRANSLATORS: char select dialog. button.
- mPlayButton->setCaption(_("Create"));
- }
-}
-
-void CharSelectDialog::setName(const BeingId id, const std::string &newName)
-{
- for (unsigned int i = 0, fsz = CAST_U32(
- mCharacterEntries.size());
- i < fsz;
- ++i)
- {
- if (mCharacterEntries[i] == nullptr)
- continue;
- CharacterDisplay *const character = mCharacterEntries[i];
- if (character == nullptr)
- continue;
- LocalPlayer *const player = character->getCharacter()->dummy;
- if ((player != nullptr) && player->getId() == id)
- {
- player->setName(newName);
- character->update();
- return;
- }
- }
-}
diff --git a/src/gui/windows/charselectdialog.h b/src/gui/windows/charselectdialog.h
deleted file mode 100644
index 9cf56bfd6..000000000
--- a/src/gui/windows/charselectdialog.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 GUI_WINDOWS_CHARSELECTDIALOG_H
-#define GUI_WINDOWS_CHARSELECTDIALOG_H
-
-#include "enums/simpletypes/beingid.h"
-
-#include "gui/widgets/window.h"
-
-#include "net/characters.h"
-
-#include "listeners/actionlistener.h"
-#include "listeners/keylistener.h"
-
-class Button;
-class CharacterDisplay;
-class CharacterViewBase;
-class LoginData;
-class TextDialog;
-
-namespace Net
-{
- class CharServerHandler;
-} // namespace Net
-
-/**
- * Character selection dialog.
- *
- * \ingroup Interface
- */
-class CharSelectDialog final : public Window,
- public ActionListener,
- public KeyListener
-{
- public:
- friend class CharDeleteConfirm;
- friend class Net::CharServerHandler;
-
- /**
- * Constructor.
- */
- explicit CharSelectDialog(LoginData &data);
-
- A_DELETE_COPY(CharSelectDialog)
-
- ~CharSelectDialog();
-
- void action(const ActionEvent &event) override final;
-
- void keyPressed(KeyEvent &event) override final;
-
- enum SelectAction
- {
- Focus = 0,
- Choose
- };
-
- /**
- * Attempt to select the character with the given name. Returns whether
- * a character with the given name was found.
- *
- * \param action determines what to do when a character with the given
- * name was found (just focus or also try to choose this
- * character).
- */
- bool selectByName(const std::string &name,
- const SelectAction action = Focus);
-
- void askPasswordForDeletion(const int index);
-
- void close() override final;
-
- void widgetResized(const Event &event) override final;
-
- void updateState();
-
- void postInit() override final;
-
- void setName(const BeingId id, const std::string &newName);
-
- private:
- void attemptCharacterDelete(const int index,
- const std::string &email);
-
- void attemptCharacterSelect(const int index);
-
- void setCharacters(const Net::Characters &characters);
-
- void setCharacter(Net::Character *const character);
-
- void use(const int selected);
-
- void lock();
- void unlock();
- void setLocked(const bool locked);
-
- LoginData *mLoginData A_NONNULLPOINTER;
-
- Button *mSwitchLoginButton A_NONNULLPOINTER;
- Button *mChangePasswordButton A_NONNULLPOINTER;
- Button *mPlayButton A_NONNULLPOINTER;
- Button *mInfoButton A_NONNULLPOINTER;
- Button *mDeleteButton A_NONNULLPOINTER;
- Button *mRenameButton;
- CharacterViewBase *mCharacterView;
-
- STD_VECTOR<CharacterDisplay*> mCharacterEntries;
-
- Net::CharServerHandler *mCharServerHandler;
- TextDialog *mDeleteDialog;
- int mDeleteIndex;
- bool mLocked;
- bool mSmallScreen;
-};
-
-#endif // GUI_WINDOWS_CHARSELECTDIALOG_H
diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp
deleted file mode 100644
index aa899202d..000000000
--- a/src/gui/windows/chatwindow.cpp
+++ /dev/null
@@ -1,2181 +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 "gui/windows/chatwindow.h"
-
-#include "actormanager.h"
-#include "game.h"
-#include "guild.h"
-#include "party.h"
-#include "settings.h"
-#include "spellmanager.h"
-
-#include "being/localplayer.h"
-#include "being/playerinfo.h"
-#include "being/playerrelations.h"
-
-#include "const/gui/chat.h"
-
-#include "fs/virtfs/tools.h"
-
-#include "input/inputmanager.h"
-
-#include "gui/focushandler.h"
-#include "gui/gui.h"
-#include "gui/skin.h"
-#include "gui/viewport.h"
-
-#include "gui/models/colorlistmodel.h"
-
-#include "gui/popups/popupmenu.h"
-
-#include "gui/windows/setupwindow.h"
-#include "gui/windows/whoisonline.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/chatinput.h"
-#include "gui/widgets/createwidget.h"
-#include "gui/widgets/dropdown.h"
-#include "gui/widgets/itemlinkhandler.h"
-#include "gui/widgets/scrollarea.h"
-#include "gui/widgets/tabbedarea.h"
-
-#include "gui/widgets/tabs/chat/battletab.h"
-#include "gui/widgets/tabs/chat/channeltab.h"
-#include "gui/widgets/tabs/chat/gmtab.h"
-#include "gui/widgets/tabs/chat/langtab.h"
-#include "gui/widgets/tabs/chat/tradetab.h"
-#include "gui/widgets/tabs/chat/whispertab.h"
-
-#include "render/opengl/opengldebug.h"
-
-#include "resources/db/textdb.h"
-
-#include "net/chathandler.h"
-#include "net/net.h"
-
-#include "utils/copynpaste.h"
-#include "utils/delete2.h"
-#include "utils/foreach.h"
-
-#include "utils/translation/podict.h"
-
-#include <sys/stat.h>
-
-#include <sstream>
-
-#include "debug.h"
-
-ChatWindow *chatWindow = nullptr;
-
-static const char *const ACTION_COLOR_PICKER = "color picker";
-
-ChatWindow::ChatWindow(const std::string &name) :
- // TRANSLATORS: chat window name
- Window(_("Chat"), Modal_false, nullptr, "chat.xml"),
- ActionListener(),
- KeyListener(),
- AttributeListener(),
- mItemLinkHandler(new ItemLinkHandler),
- mChatTabs(CREATEWIDGETR(TabbedArea, this)),
- mChatInput(new ChatInput(this)),
- mRainbowColor(0U),
- mWhispers(),
- mChannels(),
- mHistory(),
- mCurHist(),
- mCommands(),
- mCustomWords(),
- mTradeFilter(),
- mColorListModel(new ColorListModel),
- mColorPicker(new DropDown(this, mColorListModel)),
- mChatButton(new Button(this, ":)", "openemote", this)),
- mAwayLog(),
- mHighlights(),
- mGlobalsFilter(),
- mChatColor(config.getIntValue("chatColor")),
- mEmoteButtonSpacing(mSkin != nullptr ?
- mSkin->getOption("emoteButtonSpacing", 2) : 2),
- mEmoteButtonY(mSkin != nullptr ?
- mSkin->getOption("emoteButtonY", -2) : -2),
- mChatHistoryIndex(0),
- mReturnToggles(config.getBoolValue("ReturnToggles")),
- mGMLoaded(false),
- mHaveMouse(false),
- mAutoHide(config.getBoolValue("autohideChat")),
- mShowBattleEvents(config.getBoolValue("showBattleEvents")),
- mShowAllLang(serverConfig.getValue("showAllLang", 0) != 0),
- mEnableTradeFilter(config.getBoolValue("enableTradeFilter")),
- mTmpVisible(false)
-{
- setWindowName(name);
-
- if (setupWindow != nullptr)
- setupWindow->registerWindowForReset(this);
-
- setShowTitle(false);
- setResizable(true);
- setDefaultVisible(true);
- setSaveVisible(true);
- setStickyButtonLock(true);
-
- int w = 600;
-#ifdef ANDROID
- if (mainGraphics->getWidth() < 710)
- w = mainGraphics->getWidth() - 110;
- if (w < 100)
- w = 100;
- if (mainGraphics->getHeight() < 480)
- setDefaultSize(w, 90, ImagePosition::UPPER_LEFT, -110, -35);
- else
- setDefaultSize(w, 123, ImagePosition::UPPER_LEFT, -110, -35);
-#else // ANDROID
-
- if (mainGraphics->getWidth() < 600)
- w = mainGraphics->getWidth() - 10;
- if (w < 100)
- w = 100;
- setDefaultSize(w, 123, ImagePosition::LOWER_LEFT);
-#endif // ANDROID
-
- setMinWidth(150);
- setMinHeight(90);
-
- setTitleBarHeight(getPadding() + getTitlePadding());
-
- if (emoteWindow != nullptr)
- emoteWindow->addListeners(this);
-
- mChatButton->adjustSize();
-
- mChatTabs->enableScrollButtons(true);
- mChatTabs->setFollowDownScroll(true);
- mChatTabs->setResizeHeight(false);
-
- mChatInput->setActionEventId("chatinput");
- mChatInput->addActionListener(this);
- mChatInput->setAllowSpecialActions(false);
-
- mColorPicker->setActionEventId(ACTION_COLOR_PICKER);
- mColorPicker->addActionListener(this);
- mColorPicker->setSelected(mChatColor);
-
- mItemLinkHandler->setAllowCommands(false);
-
- loadWindowState();
-
- mColorPicker->setPosition(this->getWidth() - mColorPicker->getWidth()
- - 2 * mPadding - 8 - 16, mPadding);
-
- // Add key listener to chat input to be able to respond to up/down
- mChatInput->addKeyListener(this);
- mCurHist = mHistory.end();
- mColorPicker->setVisible(fromBool(config.getBoolValue(
- "showChatColorsList"), Visible));
- updateTabsMargin();
-
- fillCommands();
- if ((localPlayer != nullptr) && localPlayer->isGM())
- loadGMCommands();
- initTradeFilter();
- loadCustomList();
- parseHighlights();
- parseGlobalsFilter();
-
- config.addListener("autohideChat", this);
- config.addListener("showBattleEvents", this);
- config.addListener("globalsFilter", this);
- config.addListener("enableTradeFilter", this);
-
- enableVisibleSound(true);
-}
-
-ChatWindow::~ChatWindow()
-{
- config.removeListeners(this);
- CHECKLISTENERS
- saveState();
- config.setValue("ReturnToggles", mReturnToggles);
- removeAllWhispers();
- removeAllChannels();
- delete2(mItemLinkHandler);
- delete2(mColorPicker);
- delete2(mColorListModel);
-}
-
-void ChatWindow::postInit()
-{
- Window::postInit();
- add(mChatTabs);
- add(mChatInput);
- add(mColorPicker);
- add(mChatButton);
- updateVisibility();
-}
-
-void ChatWindow::loadCommandsFile(const std::string &name)
-{
- StringVect list;
- VirtFs::loadTextFile(name, list);
- StringVectCIter it = list.begin();
- const StringVectCIter it_end = list.end();
-
- while (it != it_end)
- {
- const std::string str = *it;
- if (!str.empty())
- mCommands.push_back(str);
- ++ it;
- }
-}
-
-void ChatWindow::fillCommands()
-{
- loadCommandsFile("chatcommands.txt");
- inputManager.addChatCommands(mCommands);
-}
-
-void ChatWindow::loadGMCommands()
-{
- if (mGMLoaded)
- return;
-
- loadCommandsFile("gmcommands.txt");
- mGMLoaded = true;
-}
-
-void ChatWindow::updateTabsMargin()
-{
- if (mColorPicker->mVisible == Visible_true)
- mChatTabs->setRightMargin(mColorPicker->getWidth() + 16 + 8);
- else
- mChatTabs->setRightMargin(8);
-}
-
-void ChatWindow::adjustTabSize()
-{
- const Rect area = getChildrenArea();
-
- const int aw = area.width;
- const int ah = area.height;
- const int frame = mChatInput->getFrameSize();
- const int inputHeight = mChatInput->getHeight();
- const bool showEmotes = config.getBoolValue("showEmotesButton");
- int maxHeight = inputHeight;
- if (showEmotes)
- {
- const int buttonHeight = mChatButton->getHeight();
- if (buttonHeight > maxHeight)
- maxHeight = buttonHeight;
- }
- const int frame2 = 2 * frame;
- const int awFrame2 = aw - frame2;
- int y = ah - maxHeight - frame;
- mChatInput->setPosition(frame, y);
- mChatTabs->setWidth(awFrame2);
- const int height = ah - frame2 - (maxHeight + frame2);
- if (mChatInput->mVisible == Visible_true ||
- !config.getBoolValue("hideChatInput"))
- {
- mChatTabs->setHeight(height);
- }
- else
- {
- mChatTabs->setHeight(height + maxHeight);
- }
- updateTabsMargin();
-
- if (showEmotes)
- {
- const int chatButtonSize = mChatButton->getWidth();
- int w = awFrame2 - chatButtonSize;
- const int x = aw - frame - chatButtonSize;
- w -= mEmoteButtonSpacing;
- y += mEmoteButtonY;
- mChatInput->setWidth(w);
- mChatButton->setVisible(mChatInput->mVisible);
- mChatButton->setPosition(x, y);
- }
- else
- {
- mChatInput->setWidth(awFrame2);
- mChatButton->setVisible(Visible_false);
- }
-
- const ChatTab *const tab = getFocused();
- if (tab != nullptr)
- {
- Widget *const content = tab->mScrollArea;
- if (content != nullptr)
- {
- const int contentFrame2 = 2 * content->getFrameSize();
- content->setSize(mChatTabs->getWidth() - contentFrame2,
- mChatTabs->getContainerHeight() - contentFrame2);
- content->logic();
- }
- }
-
- mColorPicker->setPosition(this->getWidth() - mColorPicker->getWidth()
- - 2 * mPadding - 8 - 16, mPadding);
-
- mChatTabs->adjustSize();
-}
-
-void ChatWindow::widgetResized(const Event &event)
-{
- Window::widgetResized(event);
-
- adjustTabSize();
-}
-
-ChatTab *ChatWindow::getFocused() const
-{
- return static_cast<ChatTab*>(mChatTabs->getSelectedTab());
-}
-
-void ChatWindow::clearTab(ChatTab *const tab)
-{
- if (tab != nullptr)
- tab->clearText();
-}
-
-void ChatWindow::clearTab() const
-{
- clearTab(getFocused());
-}
-
-void ChatWindow::prevTab()
-{
- if (mChatTabs == nullptr)
- return;
-
- int tab = mChatTabs->getSelectedTabIndex();
-
- if (tab <= 0)
- tab = mChatTabs->getNumberOfTabs();
- tab--;
-
- mChatTabs->setSelectedTabByIndex(tab);
-}
-
-void ChatWindow::nextTab()
-{
- if (mChatTabs == nullptr)
- return;
-
- int tab = mChatTabs->getSelectedTabIndex();
-
- tab++;
- if (tab == mChatTabs->getNumberOfTabs())
- tab = 0;
-
- mChatTabs->setSelectedTabByIndex(tab);
-}
-
-void ChatWindow::selectTabByType(const ChatTabTypeT &type)
-{
- if (mChatTabs == nullptr)
- return;
-
- int sz = mChatTabs->getNumberOfTabs();
- for (int f = 0; f < sz; f ++)
- {
- ChatTab *const tab = dynamic_cast<ChatTab*>(
- mChatTabs->getTabByIndex(f));
- if ((tab != nullptr) && tab->getType() == type)
- {
- mChatTabs->setSelectedTab(tab);
- break;
- }
- }
-}
-
-void ChatWindow::closeTab() const
-{
- if (mChatTabs == nullptr)
- return;
-
- ChatTab *const tab = dynamic_cast<ChatTab*>(mChatTabs->getTabByIndex(
- mChatTabs->getSelectedTabIndex()));
- if (tab == nullptr)
- return;
- const ChatTabTypeT &type = tab->getType();
- if (type == ChatTabType::WHISPER || type == ChatTabType::CHANNEL)
- tab->handleCommand("close", "");
-}
-
-void ChatWindow::defaultTab()
-{
- if (mChatTabs != nullptr)
- mChatTabs->setSelectedTabByIndex(CAST_U32(0));
-}
-
-void ChatWindow::action(const ActionEvent &event)
-{
- const std::string &eventId = event.getId();
- if (eventId == "chatinput")
- {
- std::string message = mChatInput->getText();
-
- if (!message.empty())
- {
- // If message different from previous, put it in the history
- if (mHistory.empty() || message != mHistory.back())
- mHistory.push_back(message);
-
- // Reset history iterator
- mCurHist = mHistory.end();
-
- // Send the message to the server
- chatInput(addColors(message));
-
- // Clear the text from the chat input
- mChatInput->setText("");
- }
-
- if (message.empty() || !mReturnToggles)
- {
- // Remove focus and hide input
- mChatInput->unprotectFocus();
- if (mFocusHandler != nullptr)
- mFocusHandler->focusNone();
-
- // If the chatWindow is shown up because you want to send a message
- // It should hide now
- if (mTmpVisible)
- setVisible(Visible_false);
- }
- }
- else if (eventId == "emote")
- {
- if (emoteWindow != nullptr)
- {
- const std::string str = emoteWindow->getSelectedEmote();
- if (!str.empty())
- {
- addInputText(str, false);
- emoteWindow->clearEmote();
- }
- }
- }
- else if (eventId == "openemote")
- {
- if (emoteWindow != nullptr)
- {
- if (emoteWindow->mVisible == Visible_true)
- emoteWindow->hide();
- else
- emoteWindow->show();
- }
- }
- else if (eventId == "color")
- {
- if (emoteWindow != nullptr)
- {
- const std::string str = emoteWindow->getSelectedColor();
- if (!str.empty())
- {
- addInputText(str, false);
- emoteWindow->clearColor();
- }
- }
- }
- else if (eventId == "font")
- {
- if (emoteWindow != nullptr)
- {
- const std::string str = emoteWindow->getSelectedFont();
- if (!str.empty())
- {
- addInputText(str, false);
- emoteWindow->clearFont();
- }
- }
- }
- else if (eventId == "text")
- {
- if ((emoteWindow != nullptr) && (reverseDictionary != nullptr))
- {
- const int idx = emoteWindow->getSelectedTextIndex();
- if (idx >= 0)
- {
- const std::string str = TextDb::getByIndex(idx);
- const std::string enStr = reverseDictionary->getStr(str);
- addInputText(enStr, false);
- }
- emoteWindow->clearText();
- }
- }
- else if (eventId == ACTION_COLOR_PICKER)
- {
- if (mColorPicker != nullptr)
- {
- mChatColor = mColorPicker->getSelected();
- config.setValue("chatColor", mChatColor);
- }
- }
-
- if (mColorPicker != nullptr)
- {
- const Visible vis = fromBool(config.getBoolValue(
- "showChatColorsList"), Visible);
- if (mColorPicker->mVisible != vis)
- mColorPicker->setVisible(vis);
- }
-}
-
-bool ChatWindow::requestChatFocus()
-{
- // Make sure chatWindow is visible
- if (!isWindowVisible())
- {
- setVisible(Visible_true);
-
- /*
- * This is used to hide chatWindow after sending the message. There is
- * a trick here, because setVisible will set mTmpVisible to false, you
- * have to put this sentence *after* setVisible, not before it
- */
- mTmpVisible = true;
- }
-
- // Don't do anything else if the input is already visible and has focus
- if (mChatInput->isVisible() && mChatInput->isFocused())
- return false;
-
- // Give focus to the chat input
- mChatInput->processVisible(Visible_true);
- unHideWindow();
- mChatInput->requestFocus();
- return true;
-}
-
-bool ChatWindow::isInputFocused() const
-{
- return mChatInput->isFocused();
-}
-
-void ChatWindow::removeTab(ChatTab *const tab)
-{
- mChatTabs->removeTab(tab);
-}
-
-void ChatWindow::addTab(ChatTab *const tab)
-{
- if (tab == nullptr)
- return;
-
- mChatTabs->addTab(tab, tab->mScrollArea);
- logic();
-}
-
-void ChatWindow::removeWhisper(const std::string &nick)
-{
- std::string tempNick = nick;
- toLower(tempNick);
- mWhispers.erase(tempNick);
-}
-
-void ChatWindow::removeChannel(const std::string &name)
-{
- std::string tempName = name;
- toLower(tempName);
- mChannels.erase(tempName);
- chatHandler->partChannel(name);
-}
-
-void ChatWindow::removeAllWhispers()
-{
- std::list<ChatTab*> tabs;
-
- FOR_EACH (TabMap::iterator, iter, mWhispers)
- tabs.push_back(iter->second);
-
- for (std::list<ChatTab*>::iterator it = tabs.begin();
- it != tabs.end(); ++it)
- {
- delete *it;
- }
-
- mWhispers.clear();
-}
-
-void ChatWindow::removeAllChannels()
-{
- std::list<ChatTab*> tabs;
-
- FOR_EACH (ChannelMap::iterator, iter, mChannels)
- tabs.push_back(iter->second);
-
- for (std::list<ChatTab*>::iterator it = tabs.begin();
- it != tabs.end(); ++it)
- {
- delete *it;
- }
-
- mChannels.clear();
-}
-
-void ChatWindow::ignoreAllWhispers()
-{
- for (TabMap::iterator iter = mWhispers.begin();
- iter != mWhispers.end();
- ++ iter)
- {
- WhisperTab *const tab = iter->second;
- if (tab != nullptr)
- {
- if (playerRelations.getRelation(tab->getNick())
- != Relation::IGNORED)
- {
- playerRelations.setRelation(tab->getNick(),
- Relation::IGNORED);
- }
- tab->handleCommand("close", "");
- }
- }
-}
-
-void ChatWindow::chatInput(const std::string &message) const
-{
- ChatTab *tab = nullptr;
- std::string msg = message;
- trim(msg);
-
- if (config.getBoolValue("allowCommandsInChatTabs")
- && msg.length() > 1
- && ((msg.at(0) == '#' && msg.at(1) != '#') || msg.at(0) == '@')
- && (localChatTab != nullptr))
- {
- tab = localChatTab;
- }
- else
- {
- tab = getFocused();
- if (tab == nullptr)
- tab = localChatTab;
- }
- if (tab != nullptr)
- tab->chatInput(msg);
- Game *const game = Game::instance();
- if (game != nullptr)
- game->setValidSpeed();
-}
-
-void ChatWindow::localChatInput(const std::string &msg) const
-{
- if (localChatTab != nullptr)
- localChatTab->chatInput(msg);
- else
- chatInput(msg);
-}
-
-void ChatWindow::doPresent() const
-{
- if (actorManager == nullptr)
- return;
-
- const ActorSprites &actors = actorManager->getAll();
- std::string response;
- int playercount = 0;
-
- FOR_EACH (ActorSpritesIterator, it, actors)
- {
- if ((*it)->getType() == ActorType::Player)
- {
- if (!response.empty())
- response.append(", ");
- response.append(static_cast<Being*>(*it)->getName());
- playercount ++;
- }
- }
-
- ChatTab *const tab = getFocused();
- if (tab != nullptr)
- {
- const std::string log = strprintf(
- // TRANSLATORS: chat message
- _("Present: %s; %d players are present."),
- response.c_str(), playercount);
- tab->chatLog(log, ChatMsgType::BY_SERVER);
- }
-}
-
-void ChatWindow::scroll(const int amount) const
-{
- if (!isWindowVisible())
- return;
-
- ChatTab *const tab = getFocused();
- if (tab != nullptr)
- tab->scroll(amount);
-}
-
-void ChatWindow::mousePressed(MouseEvent &event)
-{
- if (event.isConsumed())
- return;
-
- if (event.getButton() == MouseButton::RIGHT)
- {
- if (popupMenu != nullptr)
- {
- ChatTab *const cTab = dynamic_cast<ChatTab*>(
- mChatTabs->getSelectedTab());
- if (cTab != nullptr)
- {
- event.consume();
- if (inputManager.isActionActive(InputAction::CHAT_MOD))
- {
- inputManager.executeChatCommand(
- InputAction::CLOSE_CHAT_TAB,
- std::string(), cTab);
- }
- else
- {
- popupMenu->showChatPopup(viewport->mMouseX,
- viewport->mMouseY,
- cTab);
- }
- }
- }
- }
-
- Window::mousePressed(event);
-
- if (event.isConsumed())
- return;
-
- if (event.getButton() == MouseButton::LEFT)
- {
- const int clicks = event.getClickCount();
- if (clicks == 2)
- {
- toggleChatFocus();
- if (gui != nullptr)
- gui->resetClickCount();
- }
- else if (clicks == 1)
- {
- const ChatTab *const tab = getFocused();
- if (tab != nullptr)
- mMoved = !isResizeAllowed(event);
- }
- }
-
- mDragOffsetX = event.getX();
- mDragOffsetY = event.getY();
-}
-
-void ChatWindow::mouseDragged(MouseEvent &event)
-{
- Window::mouseDragged(event);
-
- if (event.isConsumed())
- return;
-
- if (canMove() && isMovable() && mMoved)
- {
- int newX = std::max(0, getX() + event.getX() - mDragOffsetX);
- int newY = std::max(0, getY() + event.getY() - mDragOffsetY);
- newX = std::min(mainGraphics->mWidth - getWidth(), newX);
- newY = std::min(mainGraphics->mHeight - getHeight(), newY);
- setPosition(newX, newY);
- }
-}
-
-#define ifKey(key, str) \
- else if (actionId == key) \
- { \
- temp = str; \
- }
-
-void ChatWindow::keyPressed(KeyEvent &event)
-{
- const InputActionT actionId = event.getActionId();
- std::string temp;
- if (actionId == InputAction::GUI_DOWN)
- {
- if (mCurHist != mHistory.end())
- {
- // Move forward through the history
- const HistoryIterator prevHist = mCurHist++;
- addCurrentToHistory();
-
- if (mCurHist != mHistory.end())
- {
- mChatInput->setText(*mCurHist);
- mChatInput->setCaretPosition(CAST_U32(
- mChatInput->getText().length()));
- }
- else
- {
- mChatInput->setText("");
- mCurHist = prevHist;
- }
- }
- else if (!mChatInput->getText().empty())
- {
- if (addCurrentToHistory())
- mCurHist = mHistory.end();
- mChatInput->setText("");
- }
- }
- else if (actionId == InputAction::GUI_UP &&
- mCurHist != mHistory.begin() &&
- !mHistory.empty())
- {
- // Move backward through the history
- --mCurHist;
- addCurrentToHistory();
- mChatInput->setText(*mCurHist);
- mChatInput->setCaretPosition(CAST_U32(
- mChatInput->getText().length()));
- }
- else if (actionId == InputAction::GUI_INSERT &&
- !mChatInput->getText().empty())
- {
- const std::string str = mChatInput->getText();
- // Add the current message to the history and clear the text
- if (mHistory.empty() || str != mHistory.back())
- mHistory.push_back(str);
- mCurHist = mHistory.end();
- mChatInput->setText(std::string());
- }
- else if (actionId == InputAction::GUI_TAB &&
- !mChatInput->getText().empty())
- {
- autoComplete();
- return;
- }
- else if (actionId == InputAction::GUI_CANCEL &&
- mChatInput->mVisible == Visible_true)
- {
- mChatInput->processVisible(Visible_false);
- }
- else if (actionId == InputAction::CHAT_PREV_HISTORY &&
- mChatInput->mVisible == Visible_true)
- {
- const ChatTab *const tab = getFocused();
- if ((tab != nullptr) && tab->hasRows())
- {
- if (mChatHistoryIndex == 0u)
- {
- mChatHistoryIndex = CAST_U32(
- tab->getRows().size());
-
- mChatInput->setText("");
- mChatInput->setCaretPosition(0);
- return;
- }
-
- mChatHistoryIndex --;
-
- unsigned int f = 0;
- const std::list<std::string> &rows = tab->getRows();
- for (std::list<std::string>::const_iterator it = rows.begin(),
- it_end = rows.end(); it != it_end; ++ it, f ++)
- {
- if (f == mChatHistoryIndex)
- mChatInput->setText(*it);
- }
- mChatInput->setCaretPosition(CAST_U32(
- mChatInput->getText().length()));
- }
- }
- else if (actionId == InputAction::CHAT_NEXT_HISTORY &&
- mChatInput->mVisible == Visible_true)
- {
- const ChatTab *const tab = getFocused();
- if ((tab != nullptr) && tab->hasRows())
- {
- const std::list<std::string> &rows = tab->getRows();
- const size_t &tabSize = rows.size();
- if (CAST_SIZE(mChatHistoryIndex) + 1 < tabSize)
- {
- mChatHistoryIndex ++;
- }
- else if (CAST_SIZE(mChatHistoryIndex) < tabSize)
- {
- mChatHistoryIndex ++;
- mChatInput->setText("");
- mChatInput->setCaretPosition(0);
- return;
- }
- else
- {
- mChatHistoryIndex = 0;
- }
-
- unsigned int f = 0;
- for (std::list<std::string>::const_iterator
- it = rows.begin(), it_end = rows.end();
- it != it_end; ++it, f++)
- {
- if (f == mChatHistoryIndex)
- mChatInput->setText(*it);
- }
- mChatInput->setCaretPosition(CAST_U32(
- mChatInput->getText().length()));
- }
- }
- else if (actionId == InputAction::GUI_F1)
- {
- if (emoteWindow != nullptr)
- {
- if (emoteWindow->mVisible == Visible_true)
- emoteWindow->hide();
- else
- emoteWindow->show();
- }
- }
- ifKey(InputAction::GUI_F2, "\u2318")
- ifKey(InputAction::GUI_F3, "\u263A")
- ifKey(InputAction::GUI_F4, "\u2665")
- ifKey(InputAction::GUI_F5, "\u266A")
- ifKey(InputAction::GUI_F6, "\u266B")
- ifKey(InputAction::GUI_F7, "\u26A0")
- ifKey(InputAction::GUI_F8, "\u2622")
- ifKey(InputAction::GUI_F9, "\u262E")
- ifKey(InputAction::GUI_F10, "\u2605")
- ifKey(InputAction::GUI_F11, "\u2618")
- ifKey(InputAction::GUI_F12, "\u2592")
-
- if (inputManager.isActionActive(InputAction::GUI_CTRL))
- {
- if (actionId == InputAction::GUI_B)
- {
- std::string inputText = mChatInput->getTextBeforeCaret();
- toLower(inputText);
- const size_t idx = inputText.rfind("##b");
- if (idx == std::string::npos
- || mChatInput->getTextBeforeCaret().substr(idx, 3) == "##b")
- {
- temp = "##B";
- }
- else
- {
- temp = "##b";
- }
- }
- }
-
- if (!temp.empty())
- addInputText(temp, false);
-}
-
-#undef ifKey
-
-bool ChatWindow::addCurrentToHistory()
-{
- const std::string &str = mChatInput->getText();
- if (str.empty())
- return false;
- FOR_EACH (HistoryIterator, it, mHistory)
- {
- if (*it == str)
- return false;
- }
- mHistory.push_back(str);
- return true;
-}
-
-void ChatWindow::attributeChanged(const AttributesT id,
- const int64_t oldVal,
- const int64_t newVal)
-{
- if (!mShowBattleEvents)
- return;
- PRAGMA45(GCC diagnostic push)
- PRAGMA45(GCC diagnostic ignored "-Wswitch-enum")
- switch (id)
- {
- case Attributes::PLAYER_EXP:
- {
- if (oldVal > newVal)
- break;
- const int64_t change = newVal - oldVal;
- if (change != 0)
- {
- battleChatLog(std::string("+").append(toString(
- CAST_U64(change))).append(" xp"),
- ChatMsgType::BY_SERVER);
- }
- break;
- }
- case Attributes::PLAYER_BASE_LEVEL:
- battleChatLog(std::string(
- "Level: ").append(toString(CAST_S32(
- newVal))),
- ChatMsgType::BY_SERVER);
- break;
- case Attributes::PLAYER_JOB_EXP:
- {
- if (!config.getBoolValue("showJobExp"))
- return;
- if (oldVal > newVal ||
- PlayerInfo::getAttribute(
- Attributes::PLAYER_JOB_EXP_NEEDED) == 0)
- {
- return;
- }
- const int64_t change = newVal - oldVal;
- if (change != 0)
- {
- battleChatLog(std::string("+").append(toString(CAST_U64(
- change))).append(" job"),
- ChatMsgType::BY_SERVER);
- }
- break;
- }
- default:
- break;
- };
- PRAGMA45(GCC diagnostic pop)
-}
-
-void ChatWindow::addInputText(const std::string &text, const bool space)
-{
- const int caretPos = mChatInput->getCaretPosition();
- const std::string &inputText = mChatInput->getText();
-
- std::ostringstream ss;
- ss << inputText.substr(0, caretPos) << text;
- if (space)
- ss << " ";
-
- ss << inputText.substr(caretPos);
- mChatInput->setText(ss.str());
- mChatInput->setCaretPosition(caretPos + CAST_S32(
- text.length()) + CAST_S32(space));
- requestChatFocus();
-}
-
-void ChatWindow::addItemText(const std::string &item)
-{
- std::ostringstream text;
- text << "[" << item << "]";
- addInputText(text.str());
-}
-
-void ChatWindow::setVisible(Visible visible)
-{
- Window::setVisible(visible);
-
- /*
- * For whatever reason, if setVisible is called, the mTmpVisible effect
- * should be disabled.
- */
- mTmpVisible = false;
-}
-
-void ChatWindow::addWhisper(const std::string &restrict nick,
- const std::string &restrict mes,
- const ChatMsgTypeT own)
-{
- if (mes.empty() || (localPlayer == nullptr))
- return;
-
- std::string playerName = localPlayer->getName();
- std::string tempNick = nick;
-
- toLower(playerName);
- toLower(tempNick);
-
- if (tempNick == playerName)
- return;
-
- WhisperTab *tab = nullptr;
- const TabMap::const_iterator i = mWhispers.find(tempNick);
-
- if (i != mWhispers.end())
- {
- tab = i->second;
- }
- else if (config.getBoolValue("whispertab"))
- {
- tab = addWhisperTab(nick, nick);
- if (tab != nullptr)
- saveState();
- }
-
- if (tab != nullptr)
- {
- if (own == ChatMsgType::BY_PLAYER)
- {
- tab->chatInput(mes);
- }
- else if (own == ChatMsgType::BY_SERVER)
- {
- tab->chatLog(mes, ChatMsgType::BY_SERVER);
- }
- else
- {
- if (tab->getRemoveNames())
- {
- std::string msg = mes;
- const size_t idx = mes.find(':');
- if (idx != std::string::npos && idx > 0)
- {
- std::string nick2 = msg.substr(0, idx);
- msg = msg.substr(idx + 1);
- nick2 = removeColors(nick2);
- nick2 = trim(nick2);
- if (config.getBoolValue("removeColors"))
- msg = removeColors(msg);
- msg = trim(msg);
- tab->chatLog(nick2, msg);
- }
- else
- {
- if (config.getBoolValue("removeColors"))
- msg = removeColors(msg);
- tab->chatLog(msg, ChatMsgType::BY_SERVER);
- }
- }
- else
- {
- tab->chatLog(nick, mes);
- }
- localPlayer->afkRespond(tab, nick);
- }
- }
- else if (localChatTab != nullptr)
- {
- if (own == ChatMsgType::BY_PLAYER)
- {
- chatHandler->privateMessage(nick, mes);
-
- // TRANSLATORS: chat message
- localChatTab->chatLog(strprintf(_("Whispering to %s: %s"),
- nick.c_str(), mes.c_str()),
- ChatMsgType::BY_PLAYER);
- }
- else
- {
- localChatTab->chatLog(std::string(nick).append(
- " : ").append(mes),
- ChatMsgType::ACT_WHISPER,
- IgnoreRecord_false);
- if (localPlayer != nullptr)
- localPlayer->afkRespond(nullptr, nick);
- }
- }
-}
-
-WhisperTab *ChatWindow::addWhisperTab(const std::string &caption,
- const std::string &nick,
- const bool switchTo)
-{
- if (localPlayer == nullptr)
- return nullptr;
-
- std::string playerName = localPlayer->getName();
- std::string tempNick = nick;
-
- toLower(playerName);
- toLower(tempNick);
-
- const TabMap::const_iterator i = mWhispers.find(tempNick);
- WhisperTab *ret = nullptr;
-
- if (tempNick == playerName)
- return nullptr;
-
- if (i != mWhispers.end())
- {
- ret = i->second;
- }
- else
- {
- ret = new WhisperTab(this, caption, nick);
- if ((gui != nullptr) && !playerRelations.isGoodName(nick))
- ret->setLabelFont(gui->getSecureFont());
- mWhispers[tempNick] = ret;
- if (config.getBoolValue("showChatHistory"))
- ret->loadFromLogFile(nick);
- }
-
- if (switchTo)
- mChatTabs->setSelectedTab(ret);
-
- return ret;
-}
-
-WhisperTab *ChatWindow::getWhisperTab(const std::string &nick) const
-{
- if (localPlayer == nullptr)
- return nullptr;
-
- std::string playerName = localPlayer->getName();
- std::string tempNick = nick;
-
- toLower(playerName);
- toLower(tempNick);
-
- const TabMap::const_iterator i = mWhispers.find(tempNick);
- WhisperTab *ret = nullptr;
-
- if (tempNick == playerName)
- return nullptr;
-
- if (i != mWhispers.end())
- ret = i->second;
-
- return ret;
-}
-
-ChatTab *ChatWindow::addSpecialChannelTab(const std::string &name,
- const bool switchTo)
-{
- ChatTab *ret = nullptr;
- if (name == TRADE_CHANNEL)
- {
- if (tradeChatTab == nullptr)
- {
- tradeChatTab = new TradeTab(chatWindow);
- tradeChatTab->setAllowHighlight(false);
- chatHandler->joinChannel(tradeChatTab->getChannelName());
- }
- ret = tradeChatTab;
- }
- else if (name == GM_CHANNEL)
- {
- if (gmChatTab == nullptr)
- {
- gmChatTab = new GmTab(chatWindow);
- chatHandler->joinChannel(gmChatTab->getChannelName());
- }
- ret = gmChatTab;
- }
- if (switchTo)
- mChatTabs->setSelectedTab(ret);
-
- return ret;
-}
-
-ChatTab *ChatWindow::addChannelTab(const std::string &name,
- const bool switchTo)
-{
- std::string tempName = name;
- toLower(tempName);
-
- ChatTab *const tab = addSpecialChannelTab(name, switchTo);
- if (tab != nullptr)
- return tab;
-
- const ChannelMap::const_iterator i = mChannels.find(tempName);
- ChannelTab *ret = nullptr;
-
- if (i != mChannels.end())
- {
- ret = i->second;
- }
- else
- {
- ret = new ChannelTab(this, name);
- mChannels[tempName] = ret;
- ret->setAllowHighlight(false);
- if (config.getBoolValue("showChatHistory"))
- ret->loadFromLogFile(name);
- }
-
- if (switchTo)
- mChatTabs->setSelectedTab(ret);
-
- return ret;
-}
-
-ChatTab *ChatWindow::addChatTab(const std::string &name,
- const bool switchTo,
- const bool join)
-{
- if (Net::getNetworkType() != ServerType::TMWATHENA &&
- name.size() > 1 &&
- name[0] == '#')
- {
- ChatTab *const tab = addChannelTab(name, switchTo);
- if ((tab != nullptr) && join)
- chatHandler->joinChannel(name);
- return tab;
- }
- return addWhisperTab(name, name, switchTo);
-}
-
-void ChatWindow::postConnection()
-{
- FOR_EACH (ChannelMap::const_iterator, iter, mChannels)
- {
- ChatTab *const tab = iter->second;
- if (tab == nullptr)
- return;
- chatHandler->joinChannel(tab->getChannelName());
- }
- if (langChatTab != nullptr)
- chatHandler->joinChannel(langChatTab->getChannelName());
-}
-
-#define changeColor(fun) \
- { \
- msg = removeColors(msg); \
- int skip = 0; \
- const size_t sz = msg.length(); \
- for (size_t f = 0; f < sz; f ++) \
- { \
- if (skip > 0) \
- { \
- newMsg += msg.at(f); \
- skip --; \
- continue; \
- } \
- const unsigned char ch = CAST_U8(msg.at(f)); \
- if (f + 2 < sz && msg.substr(f, 2) == "%%") \
- { \
- newMsg += msg.at(f); \
- skip = 2; \
- } \
- else if (ch > 0xc0 || ch < 0x80) \
- { \
- newMsg += "##" + toString(fun) + msg.at(f); \
- if (mRainbowColor > 9U) \
- mRainbowColor = 0U; \
- } \
- else \
- { \
- newMsg += msg.at(f); \
- } \
- } \
- }
-
-std::string ChatWindow::addColors(std::string &msg)
-{
- // default color or chat command
- if (mChatColor == 0 || msg.length() == 0 || msg.at(0) == '#'
- || msg.at(0) == '/' || msg.at(0) == '@' || msg.at(0) == '!')
- {
- return msg;
- }
-
- std::string newMsg;
- const int cMap[] = {1, 4, 5, 2, 3, 6, 7, 9, 0, 8};
-
- // rainbow
- switch (mChatColor)
- {
- case 11:
- changeColor(mRainbowColor++)
- return newMsg;
- case 12:
- changeColor(cMap[mRainbowColor++])
- return newMsg;
- case 13:
- changeColor(cMap[9-mRainbowColor++])
- return newMsg;
- default:
- break;
- }
-
- // simple colors
- return std::string("##").append(toString(mChatColor - 1)).append(msg);
-}
-
-#undef changeColor
-
-void ChatWindow::autoComplete()
-{
- const int caretPos = mChatInput->getCaretPosition();
- int startName = 0;
- const std::string &inputText = mChatInput->getText();
- std::string name = inputText.substr(0, caretPos);
-
- for (int f = caretPos - 1; f > -1; f --)
- {
- if (isWordSeparator(inputText[f]))
- {
- startName = f + 1;
- name = inputText.substr(f + 1, caretPos - f);
- break;
- }
- }
-
- if (caretPos - 1 + 1 == startName)
- return;
-
- const ChatTab *const cTab = static_cast<ChatTab*>(
- mChatTabs->getSelectedTab());
- StringVect nameList;
-
- if (cTab != nullptr)
- cTab->getAutoCompleteList(nameList);
- std::string newName = autoComplete(nameList, name);
- if (!newName.empty() && (startName == 0))
- secureChatCommand(newName);
-
- if ((cTab != nullptr) && newName.empty())
- {
- cTab->getAutoCompleteCommands(nameList);
- newName = autoComplete(nameList, name);
- }
-
- if (newName.empty() && (actorManager != nullptr))
- {
- actorManager->getPlayerNames(nameList, NpcNames_true);
- newName = autoComplete(nameList, name);
- if (!newName.empty() && (startName == 0))
- secureChatCommand(newName);
- }
- if (newName.empty())
- newName = autoCompleteHistory(name);
- if (newName.empty() && (spellManager != nullptr))
- newName = spellManager->autoComplete(name);
- if (newName.empty())
- newName = autoComplete(name, &mCommands);
- if (newName.empty() && (actorManager != nullptr))
- {
- actorManager->getMobNames(nameList);
- newName = autoComplete(nameList, name);
- }
- if (newName.empty())
- newName = autoComplete(name, &mCustomWords);
- if (newName.empty())
- {
- whoIsOnline->getPlayerNames(nameList);
- newName = autoComplete(nameList, name);
- }
-
- if (!newName.empty())
- {
- mChatInput->setText(inputText.substr(0, startName).append(newName)
- .append(inputText.substr(caretPos,
- inputText.length() - caretPos)));
-
- const int len = caretPos - CAST_S32(name.length())
- + CAST_S32(newName.length());
-
- if (startName > 0)
- mChatInput->setCaretPosition(len + 1);
- else
- mChatInput->setCaretPosition(len);
- }
-}
-
-std::string ChatWindow::autoComplete(const StringVect &names,
- std::string partName)
-{
- StringVectCIter i = names.begin();
- const StringVectCIter i_end = names.end();
- toLower(partName);
- std::string newName;
-
- while (i != i_end)
- {
- if (!i->empty())
- {
- std::string name = *i;
- toLower(name);
-
- const size_t pos = name.find(partName, 0);
- if (pos == 0)
- {
- if (!newName.empty())
- newName = findSameSubstringI(*i, newName);
- else
- newName = *i;
- }
- }
- ++i;
- }
-
- return newName;
-}
-
-std::string ChatWindow::autoComplete(const std::string &partName,
- const History *const words) const
-{
- if (words == nullptr)
- return "";
-
- ChatCommands::const_iterator i = words->begin();
- const ChatCommands::const_iterator i_end = words->end();
- StringVect nameList;
-
- while (i != i_end)
- {
- const std::string line = *i;
- if (line.find(partName, 0) == 0)
- nameList.push_back(line);
- ++i;
- }
- return autoComplete(nameList, partName);
-}
-
-/*
-void ChatWindow::moveTabLeft(ChatTab *tab)
-{
- mChatTabs->moveLeft(tab);
-}
-
-void ChatWindow::moveTabRight(ChatTab *tab)
-{
- mChatTabs->moveRight(tab);
-}
-*/
-
-std::string ChatWindow::autoCompleteHistory(const std::string &partName) const
-{
- History::const_iterator i = mHistory.begin();
- const History::const_iterator i_end = mHistory.end();
- StringVect nameList;
-
- while (i != i_end)
- {
- std::string line = *i;
- unsigned int f = 0;
- while (f < line.length() && !isWordSeparator(line.at(f)))
- f++;
-
- line = line.substr(0, f);
- if (!line.empty())
- nameList.push_back(line);
-
- ++i;
- }
- return autoComplete(nameList, partName);
-}
-
-bool ChatWindow::resortChatLog(std::string line,
- ChatMsgTypeT own,
- const std::string &channel,
- const IgnoreRecord ignoreRecord,
- const TryRemoveColors tryRemoveColors)
-{
- if (own == ChatMsgType::BY_UNKNOWN)
- {
- const size_t pos = line.find(" : ");
- if (pos != std::string::npos)
- {
- if (line.length() <= pos + 3)
- own = ChatMsgType::BY_SERVER;
- else if (line.substr(0, pos) == localPlayer->getName())
- own = ChatMsgType::BY_PLAYER;
- else
- own = ChatMsgType::BY_OTHER;
- }
- else
- {
- own = ChatMsgType::BY_SERVER;
- }
- }
-
- std::string prefix;
- if (!channel.empty())
- {
- prefix = std::string("##3").append(channel).append("##0");
- }
- else if (mEnableTradeFilter &&
- (tradeChatTab != nullptr) &&
- findI(line, mTradeFilter) != std::string::npos)
- {
- // TRANSLATORS: prefix for moved message to trade tab.
- tradeChatTab->chatLog(std::string("##S") + _("Moved: ") + line,
- own,
- ignoreRecord,
- tryRemoveColors);
- if (own == ChatMsgType::BY_PLAYER)
- {
- own = ChatMsgType::BY_SERVER;
- // TRANSLATORS: moved message to trade tab warning.
- line = _("Your message was moved to trade tab");
- }
- else
- {
- return false;
- }
- }
-
- size_t idx2 = line.find(": ");
- if (idx2 != std::string::npos)
- {
- std::string tmpNick = line.substr(0, idx2);
- if (tmpNick.find('#') != std::string::npos ||
- tmpNick.find(':') != std::string::npos ||
- tmpNick.find('%') != std::string::npos ||
- tmpNick.find('@') != std::string::npos ||
- tmpNick.size() < 5 ||
- tmpNick[0] == '@' ||
- tmpNick[0] == '/' ||
- tmpNick[0] == '!'
- )
- {
- replaceAll(tmpNick, "#", "_");
- replaceAll(tmpNick, "%", "_");
- // TRANSLATORS: error message
- line = _("Broken nick detected: ") + line;
- own = ChatMsgType::BY_SERVER;
- }
- const size_t idx = line.find(": \302\202");
- if (idx == idx2)
- {
- if (line.find(": \302\202\302") != std::string::npos)
- {
- if (line.find(": \302\202\302e") != std::string::npos)
- {
- // Do nothing. Before was local pet emote
- }
- else if (line.find(": \302\202\302m") != std::string::npos)
- {
- // Do nothing. Before was local pet move
- }
- else if (line.find(": \302\202\302d") != std::string::npos)
- {
- // Do nothing. Before was local pet direction
- }
- else if (line.find(": \302\202\302a") != std::string::npos)
- {
- // Do nothing. Before was local pet ai enable/disable
- }
- // ignore other special message formats.
- return false;
- }
-
- // pet talk message detected
- if (line.find(": \302\202\303 ") != std::string::npos)
- {
- // Do nothing. Before was local pet talk
- return false;
- }
- if (line.find(": \302\202\304") != std::string::npos)
- {
- replaceAll(line, ": \302\202\304", ": ");
- }
-
- if (tradeChatTab != nullptr)
- {
- line = line.erase(idx + 2, 2);
- tradeChatTab->chatLog(prefix + line,
- own,
- ignoreRecord,
- tryRemoveColors);
- }
- else if (localChatTab != nullptr)
- {
- line = line.erase(idx + 2, 2);
- localChatTab->chatLog(prefix + line,
- own,
- ignoreRecord,
- tryRemoveColors);
- }
- return false;
- }
- }
-
- if (!channel.empty())
- {
- if (langChatTab != nullptr)
- {
- if (langChatTab->getChannelName() == channel)
- {
- langChatTab->chatLog(line, own, ignoreRecord, tryRemoveColors);
- }
- else if (mShowAllLang)
- {
- langChatTab->chatLog(prefix + line,
- own,
- ignoreRecord,
- tryRemoveColors);
- }
- }
- else if (Net::getNetworkType() != ServerType::TMWATHENA)
- {
- channelChatLog(channel, line, own, ignoreRecord, tryRemoveColors);
- return false;
- }
- else if (mShowAllLang)
- {
- localChatTab->chatLog(prefix + line,
- own,
- ignoreRecord,
- tryRemoveColors);
- }
- }
- else if ((localChatTab != nullptr) && channel.empty())
- {
- localChatTab->chatLog(line, own, ignoreRecord, tryRemoveColors);
- }
- return true;
-}
-
-void ChatWindow::battleChatLog(const std::string &line, ChatMsgTypeT own,
- const IgnoreRecord ignoreRecord,
- const TryRemoveColors tryRemoveColors)
-{
- if (own == ChatMsgType::BY_UNKNOWN)
- own = ChatMsgType::BY_SERVER;
- if (battleChatTab != nullptr)
- battleChatTab->chatLog(line, own, ignoreRecord, tryRemoveColors);
- else if (debugChatTab != nullptr)
- debugChatTab->chatLog(line, own, ignoreRecord, tryRemoveColors);
-}
-
-void ChatWindow::channelChatLog(const std::string &channel,
- const std::string &line,
- ChatMsgTypeT own,
- const IgnoreRecord ignoreRecord,
- const TryRemoveColors tryRemoveColors)
-{
- std::string tempChannel = channel;
- toLower(tempChannel);
-
- ChatTab *tab = nullptr;
- const ChannelMap::const_iterator i = mChannels.find(tempChannel);
-
- if (i != mChannels.end())
- {
- tab = i->second;
- }
- else
- {
- tab = addChannelTab(channel, false);
- if (tab != nullptr)
- saveState();
- }
-
- if (tab != nullptr)
- tab->chatLog(line, own, ignoreRecord, tryRemoveColors);
-}
-
-void ChatWindow::initTradeFilter()
-{
- const std::string tradeListName = settings.serverConfigDir
- + "/tradefilter.txt";
-
- std::ifstream tradeFile;
- struct stat statbuf;
-
- if (stat(tradeListName.c_str(), &statbuf) == 0 &&
- S_ISREG(statbuf.st_mode))
- {
- tradeFile.open(tradeListName.c_str(), std::ios::in);
- if (tradeFile.is_open())
- {
- char line[100];
- while (tradeFile.getline(line, 100))
- {
- const std::string str = line;
- if (!str.empty())
- mTradeFilter.push_back(str);
- }
- }
- tradeFile.close();
- }
-}
-
-void ChatWindow::updateOnline(const std::set<std::string> &onlinePlayers) const
-{
- const Party *party = nullptr;
- const Guild *guild = nullptr;
- if (localPlayer != nullptr)
- {
- party = localPlayer->getParty();
- guild = localPlayer->getGuild();
- }
- FOR_EACH (TabMap::const_iterator, iter, mWhispers)
- {
- if (iter->second == nullptr)
- return;
-
- WhisperTab *const tab = static_cast<WhisperTab*>(iter->second);
- if (tab == nullptr)
- continue;
-
- if (onlinePlayers.find(tab->getNick()) != onlinePlayers.end())
- {
- tab->setWhisperTabColors();
- }
- else
- {
- const std::string &nick = tab->getNick();
- if (actorManager != nullptr)
- {
- const Being *const being = actorManager->findBeingByName(
- nick, ActorType::Player);
- if (being != nullptr)
- {
- tab->setWhisperTabColors();
- continue;
- }
- }
- if (party != nullptr)
- {
- const PartyMember *const pm = party->getMember(nick);
- if ((pm != nullptr) && pm->getOnline())
- {
- tab->setWhisperTabColors();
- continue;
- }
- }
- if (guild != nullptr)
- {
- const GuildMember *const gm = guild->getMember(nick);
- if ((gm != nullptr) && gm->getOnline())
- {
- tab->setWhisperTabColors();
- continue;
- }
- }
- tab->setWhisperTabOfflineColors();
- }
- }
-}
-
-void ChatWindow::loadState()
-{
- int num = 0;
- while (num < 50)
- {
- const std::string nick = serverConfig.getValue(
- "chatWhisper" + toString(num), "");
-
- if (nick.empty())
- break;
-
- const int flags = serverConfig.getValue(
- "chatWhisperFlags" + toString(num), 1);
-
- ChatTab *const tab = addChatTab(nick, false, false);
- if (tab != nullptr)
- {
- tab->setAllowHighlight((flags & 1) != 0);
- tab->setRemoveNames(((flags & 2) / 2) != 0);
- tab->setNoAway(((flags & 4) / 4) != 0);
- }
- num ++;
- }
-}
-
-void ChatWindow::saveState() const
-{
- int num = 0;
- for (ChannelMap::const_iterator iter = mChannels.begin(),
- iter_end = mChannels.end(); iter != iter_end && num < 50; ++iter)
- {
- if (iter->second == nullptr)
- return;
- if (!saveTab(num, iter->second))
- continue;
- num ++;
- }
-
- for (TabMap::const_iterator iter = mWhispers.begin(),
- iter_end = mWhispers.end(); iter != iter_end && num < 50; ++iter)
- {
- if (iter->second == nullptr)
- return;
- if (!saveTab(num, iter->second))
- continue;
- num ++;
- }
-
- while (num < 50)
- {
- serverConfig.deleteKey("chatWhisper" + toString(num));
- serverConfig.deleteKey("chatWhisperFlags" + toString(num));
- num ++;
- }
-}
-
-bool ChatWindow::saveTab(const int num,
- const ChatTab *const tab) const
-{
- if (tab == nullptr)
- return false;
-
- serverConfig.setValue("chatWhisper" + toString(num),
- tab->getChannelName());
-
- serverConfig.setValue("chatWhisperFlags" + toString(num),
- CAST_S32(tab->getAllowHighlight())
- + (2 * CAST_S32(tab->getRemoveNames()))
- + (4 * CAST_S32(tab->getNoAway())));
-
- return true;
-}
-
-std::string ChatWindow::doReplace(const std::string &msg)
-{
- std::string str = msg;
- replaceSpecialChars(str);
- return str;
-}
-
-void ChatWindow::loadCustomList()
-{
- std::ifstream listFile;
- struct stat statbuf;
-
- std::string listName = settings.serverConfigDir
- + "/customwords.txt";
-
- if ((stat(listName.c_str(), &statbuf) == 0) && S_ISREG(statbuf.st_mode))
- {
- listFile.open(listName.c_str(), std::ios::in);
- if (listFile.is_open())
- {
- char line[101];
- while (listFile.getline(line, 100))
- {
- std::string str = line;
- if (!str.empty())
- mCustomWords.push_back(str);
- }
- }
- listFile.close();
- }
-}
-
-void ChatWindow::addToAwayLog(const std::string &line)
-{
- if (!settings.awayMode)
- return;
-
- if (mAwayLog.size() > 20)
- mAwayLog.pop_front();
-
- if (findI(line, mHighlights) != std::string::npos)
- mAwayLog.push_back("##aaway:" + line);
-}
-
-void ChatWindow::displayAwayLog() const
-{
- if (localChatTab == nullptr)
- return;
-
- std::list<std::string>::const_iterator i = mAwayLog.begin();
- const std::list<std::string>::const_iterator i_end = mAwayLog.end();
-
- while (i != i_end)
- {
- std::string str = *i;
- localChatTab->addNewRow(str);
- ++i;
- }
-}
-
-void ChatWindow::parseHighlights()
-{
- mHighlights.clear();
- if (localPlayer == nullptr)
- return;
-
- splitToStringVector(mHighlights, config.getStringValue(
- "highlightWords"), ',');
-
- mHighlights.push_back(localPlayer->getName());
-}
-
-void ChatWindow::parseGlobalsFilter()
-{
- mGlobalsFilter.clear();
- if (localPlayer == nullptr)
- return;
-
- splitToStringVector(mGlobalsFilter, config.getStringValue(
- "globalsFilter"), ',');
-
- mHighlights.push_back(localPlayer->getName());
-}
-
-bool ChatWindow::findHighlight(const std::string &str)
-{
- return findI(str, mHighlights) != std::string::npos;
-}
-
-void ChatWindow::copyToClipboard(const int x, const int y) const
-{
- const ChatTab *const tab = getFocused();
- if (tab == nullptr)
- return;
-
- const BrowserBox *const text = tab->mTextOutput;
- if (text == nullptr)
- return;
-
- std::string str = text->getTextAtPos(x, y);
- sendBuffer(str);
-}
-
-void ChatWindow::optionChanged(const std::string &name)
-{
- if (name == "autohideChat")
- mAutoHide = config.getBoolValue("autohideChat");
- else if (name == "showBattleEvents")
- mShowBattleEvents = config.getBoolValue("showBattleEvents");
- else if (name == "globalsFilter")
- parseGlobalsFilter();
- else if (name == "enableTradeFilter")
- mEnableTradeFilter = config.getBoolValue("enableTradeFilter");
-}
-
-void ChatWindow::mouseMoved(MouseEvent &event)
-{
- mHaveMouse = true;
- Window::mouseMoved(event);
-}
-
-void ChatWindow::mouseEntered(MouseEvent& event)
-{
- mHaveMouse = true;
- Window::mouseEntered(event);
-}
-
-void ChatWindow::mouseExited(MouseEvent& event)
-{
- updateVisibility();
- Window::mouseExited(event);
-}
-
-void ChatWindow::draw(Graphics *const graphics)
-{
- BLOCK_START("ChatWindow::draw")
- if (!mAutoHide || mHaveMouse)
- {
- GLDEBUG_START("ChatWindow::draw");
- Window::draw(graphics);
- GLDEBUG_END();
- }
- BLOCK_END("ChatWindow::draw")
-}
-
-void ChatWindow::safeDraw(Graphics *const graphics)
-{
- BLOCK_START("ChatWindow::draw")
- if (!mAutoHide || mHaveMouse)
- {
- GLDEBUG_START("ChatWindow::draw");
- Window::safeDraw(graphics);
- GLDEBUG_END();
- }
- BLOCK_END("ChatWindow::draw")
-}
-
-void ChatWindow::updateVisibility()
-{
- if (gui == nullptr)
- return;
-
- int mouseX = 0;
- int mouseY = 0;
- int x = 0;
- int y = 0;
- Gui::getMouseState(mouseX, mouseY);
- getAbsolutePosition(x, y);
- if (mChatInput->isVisible())
- {
- mHaveMouse = true;
- }
- else
- {
- mHaveMouse = mouseX >= x && mouseX <= x + getWidth()
- && mouseY >= y && mouseY <= y + getHeight();
- }
-}
-
-void ChatWindow::unHideWindow()
-{
- mHaveMouse = true;
-}
-
-#ifdef USE_PROFILER
-void ChatWindow::logicChildren()
-{
- BLOCK_START("ChatWindow::logicChildren")
- BasicContainer::logicChildren();
- BLOCK_END("ChatWindow::logicChildren")
-}
-#endif // USE_PROFILER
-
-void ChatWindow::addGlobalMessage(const std::string &line)
-{
- if (debugChatTab != nullptr &&
- findI(line, mGlobalsFilter) != std::string::npos)
- {
- debugChatTab->chatLog(line, ChatMsgType::BY_OTHER);
- }
- else
- {
- localChatTab->chatLog(line, ChatMsgType::BY_GM);
- }
-}
-
-bool ChatWindow::isTabPresent(const ChatTab *const tab) const
-{
- return mChatTabs->isTabPresent(tab);
-}
-
-void ChatWindow::debugMessage(const std::string &msg)
-{
- if (debugChatTab != nullptr)
- debugChatTab->chatLog(msg, ChatMsgType::BY_SERVER);
-}
-
-void ChatWindow::showGMTab()
-{
- if ((gmChatTab == nullptr) &&
- config.getBoolValue("enableGmTab") &&
- localPlayer->getGroupId() >= paths.getIntValue("gmTabMinimalLevel"))
- {
- addSpecialChannelTab(GM_CHANNEL, false);
- }
-}
-
-void ChatWindow::toggleChatFocus()
-{
- if (mChatInput->isVisible() && mChatInput->isFocused())
- mChatInput->processVisible(Visible_false);
- else
- requestChatFocus();
-}
-
-void ChatWindow::joinRoom(const bool isJoin)
-{
- Tab *const tab = mChatTabs->getTabByIndex(0);
- if (tab != nullptr)
- {
- std::string name;
- if (isJoin)
- {
- name = PlayerInfo::getRoomName();
- }
- else
- {
- // TRANSLATORS: chat tab name
- name = _("General");
- }
- tab->setCaption(name);
- }
-}
-
-void ChatWindow::scheduleDelete()
-{
- DebugMessageListener::removeListener(this);
- Window::scheduleDelete();
-}
diff --git a/src/gui/windows/chatwindow.h b/src/gui/windows/chatwindow.h
deleted file mode 100644
index 7d02e0fd3..000000000
--- a/src/gui/windows/chatwindow.h
+++ /dev/null
@@ -1,406 +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_WINDOWS_CHATWINDOW_H
-#define GUI_WINDOWS_CHATWINDOW_H
-
-#include "enums/gui/chatmsgtype.h"
-#include "enums/gui/chattabtype.h"
-
-#include "enums/simpletypes/ignorerecord.h"
-#include "enums/simpletypes/tryremovecolors.h"
-
-#include "gui/widgets/window.h"
-
-#include "listeners/actionlistener.h"
-#include "listeners/attributelistener.h"
-#include "listeners/debugmessagelistener.h"
-#include "listeners/keylistener.h"
-
-class Button;
-class ChannelTab;
-class ChatTab;
-class ChatInput;
-class ColorListModel;
-class DropDown;
-class TabbedArea;
-class ItemLinkHandler;
-class WhisperTab;
-
-/**
- * The chat window.
- *
- * \ingroup Interface
- */
-class ChatWindow final : public Window,
- public ActionListener,
- public KeyListener,
- public ConfigListener,
- public AttributeListener,
- public DebugMessageListener
-{
- public:
- /**
- * Constructor.
- */
- explicit ChatWindow(const std::string &name);
-
- A_DELETE_COPY(ChatWindow)
-
- /**
- * Destructor: used to write back values to the config file
- */
- ~ChatWindow();
-
- /**
- * Gets the focused tab.
- */
- ChatTab *getFocused() const A_WARN_UNUSED;
-
- /**
- * Clear the given tab.
- */
- static void clearTab(ChatTab *const tab);
-
- /**
- * Clear the current tab.
- */
- void clearTab() const;
-
- /**
- * Switch to the previous tab in order
- */
- void prevTab();
-
- /**
- * Switch to the next tab in order
- */
- void nextTab();
-
- /**
- * Close current chat tab
- */
- void closeTab() const;
-
- /**
- * Switch to the default tab
- */
- void defaultTab();
-
- /**
- * Performs action.
- */
- void action(const ActionEvent &event) override final;
-
- /**
- * Request focus for typing chat message.
- *
- * \returns true if the input was shown
- * false otherwise
- */
- bool requestChatFocus();
-
- /**
- * Checks whether ChatWindow is Focused or not.
- */
- bool isInputFocused() const A_WARN_UNUSED;
-
- /**
- * Passes the text to the current tab as input
- *
- * @param msg The message text which is to be sent.
- */
- void chatInput(const std::string &msg) const;
-
- /**
- * Passes the text to the local chat tab as input
- *
- * @param msg The message text which is to be sent.
- */
- void localChatInput(const std::string &msg) const;
-
- /** Called when key is pressed */
- void keyPressed(KeyEvent &event) override final;
-
- /** Set the chat input as the given text. */
- void setInputText(const std::string &text);
-
- /** Add the given text to the chat input. */
- void addInputText(const std::string &text, const bool space = true);
-
- /** Called to add item to chat */
- void addItemText(const std::string &item);
-
- /** Override to reset mTmpVisible */
- void setVisible(Visible visible) override final;
-
- /**
- * Handles mouse when dragged.
- */
- void mouseDragged(MouseEvent &event) override final;
-
- /**
- * Handles mouse when pressed.
- */
- void mousePressed(MouseEvent &event) override final;
-
- /**
- * Scrolls the chat window
- *
- * @param amount direction and amount to scroll. Negative numbers scroll
- * up, positive numbers scroll down. The absolute amount indicates the
- * amount of 1/8ths of chat window real estate that should be scrolled.
- */
- void scroll(const int amount) const;
-
- /**
- * Sets the file being recorded to
- *
- * @param msg The file to write out to. If null, then stop recording.
- */
- void setRecordingFile(const std::string &msg);
-
- bool getReturnTogglesChat() const noexcept2 A_WARN_UNUSED
- { return mReturnToggles; }
-
- void setReturnTogglesChat(const bool toggles)
- { mReturnToggles = toggles; }
-
- void doPresent() const;
-
- void addWhisper(const std::string &restrict nick,
- const std::string &restrict mes,
- const ChatMsgTypeT own = ChatMsgType::BY_OTHER);
-
- WhisperTab *addWhisperTab(const std::string &caption,
- const std::string &nick,
- const bool switchTo = false) A_WARN_UNUSED;
-
- WhisperTab *getWhisperTab(const std::string &nick) const A_WARN_UNUSED;
-
- ChatTab *addChannelTab(const std::string &name,
- const bool switchTo = false);
-
- ChatTab *addSpecialChannelTab(const std::string &name,
- const bool switchTo = false);
-
- ChatTab *addChatTab(const std::string &name,
- const bool switchTo,
- const bool join) A_WARN_UNUSED;
-
- void joinRoom(const bool isJoin);
-
- void removeAllWhispers();
-
- void removeAllChannels();
-
- void ignoreAllWhispers();
-
- bool resortChatLog(std::string line, ChatMsgTypeT own,
- const std::string &channel,
- const IgnoreRecord ignoreRecord,
- const TryRemoveColors tryRemoveColors);
-
- static void battleChatLog(const std::string &line,
- ChatMsgTypeT own
- = ChatMsgType::BY_UNKNOWN,
- const IgnoreRecord ignoreRecord
- = IgnoreRecord_false,
- const TryRemoveColors tryRemoveColors
- = TryRemoveColors_true);
-
- void channelChatLog(const std::string &channel,
- const std::string &line,
- ChatMsgTypeT own,
- const IgnoreRecord ignoreRecord,
- const TryRemoveColors tryRemoveColors);
-
- void updateOnline(const std::set<std::string> &onlinePlayers) const;
-
- void loadState();
-
- void saveState() const;
-
- bool saveTab(const int num,
- const ChatTab *const tab) const;
-
- void loadCustomList();
-
- void loadGMCommands();
-
- static std::string doReplace(const std::string &msg) A_WARN_UNUSED;
-
- void adjustTabSize();
-
- void addToAwayLog(const std::string &line);
-
- void displayAwayLog() const;
-
- void clearAwayLog()
- { mAwayLog.clear(); }
-
- void parseHighlights();
-
- void parseGlobalsFilter();
-
- bool findHighlight(const std::string &str) A_WARN_UNUSED;
-
- void copyToClipboard(const int x, const int y) const;
-
- void optionChanged(const std::string &name) override final;
-
- void mouseEntered(MouseEvent& event) override final;
-
- void mouseMoved(MouseEvent &event) override final;
-
- void mouseExited(MouseEvent& event A_UNUSED) override final;
-
- void draw(Graphics *const graphics) override final A_NONNULL(2);
-
- void safeDraw(Graphics *const graphics) override final A_NONNULL(2);
-
- void updateVisibility();
-
- void unHideWindow();
-
- void widgetResized(const Event &event) override final;
-
- void addGlobalMessage(const std::string &line);
-
- void postInit() override final;
-
- bool isTabPresent(const ChatTab *const tab) const A_WARN_UNUSED;
-
- void selectTabByType(const ChatTabTypeT &type);
-
- void attributeChanged(const AttributesT id,
- const int64_t oldVal,
- const int64_t newVal) override final;
-
- void postConnection();
-
- void showGMTab();
-
- void debugMessage(const std::string &msg) override final;
-
- void scheduleDelete() override final;
-
-#ifdef USE_PROFILER
- void logicChildren();
-#endif // USE_PROFILER
-
- protected:
- friend class ChannelTab;
- friend class ChatTab;
- friend class WhisperTab;
- friend class PopupMenu;
-
- typedef std::list<std::string> History;
-
- /** Remove the given tab from the window */
- void removeTab(ChatTab *const tab);
-
- /** Add the tab to the window */
- void addTab(ChatTab *const tab);
-
- void removeWhisper(const std::string &nick);
-
- void removeChannel(const std::string &nick);
-
- void autoComplete();
-
- std::string addColors(std::string &msg);
-
- std::string autoCompleteHistory(const std::string &partName) const;
-
- std::string autoComplete(const std::string &partName,
- const History *const words) const;
-
- static std::string autoComplete(const StringVect &names,
- std::string partName);
-
- /** Used for showing item popup on clicking links **/
- ItemLinkHandler *mItemLinkHandler A_NONNULLPOINTER;
-
- /** Tabbed area for holding each channel. */
- TabbedArea *mChatTabs A_NONNULLPOINTER;
-
- /** Input box for typing chat messages. */
- ChatInput *mChatInput A_NONNULLPOINTER;
-
- void initTradeFilter();
-
- void toggleChatFocus();
-
- unsigned int mRainbowColor;
-
- private:
- void fillCommands();
-
- void loadCommandsFile(const std::string &name);
-
- void updateTabsMargin();
-
- bool addCurrentToHistory();
-
- typedef std::map<const std::string, WhisperTab*> TabMap;
- typedef std::map<const std::string, ChannelTab*> ChannelMap;
-
- /** Manage whisper tabs */
- TabMap mWhispers;
- ChannelMap mChannels;
-
- typedef History::iterator HistoryIterator;
- History mHistory; /**< Command history. */
- HistoryIterator mCurHist; /**< History iterator. */
-
- typedef std::list<std::string> ChatCommands;
- typedef ChatCommands::iterator ChatCommandsIterator;
- History mCommands; /**< Command list. */
- History mCustomWords;
-
- StringVect mTradeFilter;
-
- ColorListModel *mColorListModel A_NONNULLPOINTER;
- DropDown *mColorPicker A_NONNULLPOINTER;
- Button *mChatButton A_NONNULLPOINTER;
- std::list<std::string> mAwayLog;
- StringVect mHighlights;
- StringVect mGlobalsFilter;
- int mChatColor;
- int mEmoteButtonSpacing;
- int mEmoteButtonY;
- unsigned int mChatHistoryIndex;
- bool mReturnToggles; // Marks whether <Return> toggles the chat log
- // or not
- bool mGMLoaded;
- bool mHaveMouse;
- bool mAutoHide;
- bool mShowBattleEvents;
- bool mShowAllLang;
- bool mEnableTradeFilter;
- bool mTmpVisible;
-};
-
-extern ChatWindow *chatWindow;
-
-#endif // GUI_WINDOWS_CHATWINDOW_H
diff --git a/src/gui/windows/confirmdialog.cpp b/src/gui/windows/confirmdialog.cpp
deleted file mode 100644
index 913fb7c41..000000000
--- a/src/gui/windows/confirmdialog.cpp
+++ /dev/null
@@ -1,120 +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 "gui/windows/confirmdialog.h"
-
-#include "soundmanager.h"
-
-#include "gui/fonts/font.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/textbox.h"
-
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-ConfirmDialog::ConfirmDialog(const std::string &restrict title,
- const std::string &restrict msg,
- const std::string &restrict soundEvent,
- const bool ignore,
- const Modal modal,
- Window *const parent) :
- Window(title, modal, parent, "confirm.xml"),
- ActionListener(),
- mTextBox(new TextBox(this)),
- mIgnore(ignore)
-{
- mTextBox->setEditable(false);
- mTextBox->setOpaque(Opaque_false);
- mTextBox->setTextWrapped(msg, 260);
- soundManager.playGuiSound(soundEvent);
-}
-
-void ConfirmDialog::postInit()
-{
- Window::postInit();
- // TRANSLATORS: confirm dialog button
- Button *const yesButton = new Button(this, _("Yes"), "yes", this);
- // TRANSLATORS: confirm dialog button
- Button *const noButton = new Button(this, _("No"), "no", this);
- Button *const ignoreButton = mIgnore ? new Button(
- // TRANSLATORS: confirm dialog button
- this, _("Ignore"), "ignore", this) : nullptr;
-
- const int numRows = mTextBox->getNumberOfRows();
- int inWidth = yesButton->getWidth() + noButton->getWidth() +
- (2 * mPadding);
-
- if (ignoreButton != nullptr)
- inWidth += ignoreButton->getWidth();
-
- const int fontHeight = getFont()->getHeight();
- const int height = numRows * fontHeight;
- int width = getFont()->getWidth(getCaption()) + mCaptionOffsetX;
-
- if (width < mTextBox->getMinWidth())
- width = mTextBox->getMinWidth();
- if (width < inWidth)
- width = inWidth;
-
- int windowWidth = width;
- if (windowWidth < mTextBox->getMinWidth() + fontHeight)
- {
- windowWidth = mTextBox->getMinWidth() + fontHeight;
- }
- setContentSize(windowWidth,
- height + fontHeight + noButton->getHeight());
- mTextBox->setPosition(mPadding, mPadding);
-
- const int buttonPadding = getOption("buttonPadding", 8);
- yesButton->setPosition((width - inWidth) / 2, height + buttonPadding);
- noButton->setPosition(yesButton->getX() + yesButton->getWidth()
- + (2 * mPadding), height + buttonPadding);
- if (ignoreButton != nullptr)
- {
- ignoreButton->setPosition(noButton->getX() + noButton->getWidth()
- + (2 * mPadding), height + buttonPadding);
- }
-
- add(mTextBox);
- add(yesButton);
- add(noButton);
-
- if (mIgnore && (ignoreButton != nullptr))
- add(ignoreButton);
-
- if (getParent() != nullptr)
- {
- center();
- getParent()->moveToTop(this);
- }
- setVisible(Visible_true);
- yesButton->requestFocus();
-}
-
-void ConfirmDialog::action(const ActionEvent &event)
-{
- setActionEventId(event.getId());
- distributeActionEvent();
- scheduleDelete();
-}
diff --git a/src/gui/windows/confirmdialog.h b/src/gui/windows/confirmdialog.h
deleted file mode 100644
index 5d828eafb..000000000
--- a/src/gui/windows/confirmdialog.h
+++ /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/>.
- */
-
-#ifndef GUI_WINDOWS_CONFIRMDIALOG_H
-#define GUI_WINDOWS_CONFIRMDIALOG_H
-
-#include "localconsts.h"
-
-#include "const/sound.h"
-
-#include "gui/widgets/window.h"
-
-#include "listeners/actionlistener.h"
-
-class TextBox;
-
-/**
- * An option dialog.
- *
- * \ingroup GUI
- */
-class ConfirmDialog notfinal : public Window,
- public ActionListener
-{
- public:
- /**
- * Constructor.
- *
- * @see Window::Window
- */
- ConfirmDialog(const std::string &restrict title,
- const std::string &restrict msg,
- const std::string &restrict soundEvent = SOUND_REQUEST,
- const bool ignore = false,
- const Modal modal = Modal_false,
- Window *const parent = nullptr);
-
- A_DELETE_COPY(ConfirmDialog)
-
- /**
- * Called when receiving actions from the widgets.
- */
- void action(const ActionEvent &event) override;
-
- void postInit() override final;
-
- private:
- TextBox *mTextBox A_NONNULLPOINTER;
- bool mIgnore;
-};
-
-#endif // GUI_WINDOWS_CONFIRMDIALOG_H
diff --git a/src/gui/windows/connectiondialog.cpp b/src/gui/windows/connectiondialog.cpp
deleted file mode 100644
index ec23ab646..000000000
--- a/src/gui/windows/connectiondialog.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 "gui/windows/connectiondialog.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/label.h"
-#include "gui/widgets/layoutcell.h"
-#include "gui/widgets/progressindicator.h"
-
-#include "utils/gettext.h"
-
-#include "client.h"
-
-#include "debug.h"
-
-extern bool mStatsReUpdated;
-
-ConnectionDialog::ConnectionDialog(const std::string &text,
- const StateT cancelState) :
- Window("", Modal_false, nullptr, "connection.xml"),
- ActionListener(),
- mCancelState(cancelState)
-{
- mTitleBarHeight = 0;
- setMovable(Move_false);
- setMinWidth(0);
-
- ProgressIndicator *const progressIndicator = new ProgressIndicator(this);
- Label *const label = new Label(this, text);
- Button *const cancelButton = new Button(
- // TRANSLATORS: connection dialog button
- this, _("Cancel"), "cancelButton", this);
-
- place(0, 0, progressIndicator);
- place(0, 1, label);
- place(0, 2, cancelButton).setHAlign(LayoutCell::CENTER);
- reflowLayout();
-
- center();
- if ((mSearchHash ^ 0x202020U) == 0x70E9296C)
- mStatsReUpdated = true;
-}
-
-void ConnectionDialog::postInit()
-{
- Window::postInit();
- setVisible(Visible_true);
-}
-
-void ConnectionDialog::action(const ActionEvent &event A_UNUSED)
-{
- logger->log1("Cancel pressed");
- client->setState(mCancelState);
-}
-
-void ConnectionDialog::draw(Graphics *const graphics)
-{
- BLOCK_START("ConnectionDialog::draw")
- // Don't draw the window background, only draw the children
- drawChildren(graphics);
- BLOCK_END("ConnectionDialog::draw")
-}
-
-void ConnectionDialog::safeDraw(Graphics *const graphics)
-{
- BLOCK_START("ConnectionDialog::draw")
- // Don't draw the window background, only draw the children
- safeDrawChildren(graphics);
- BLOCK_END("ConnectionDialog::draw")
-}
diff --git a/src/gui/windows/connectiondialog.h b/src/gui/windows/connectiondialog.h
deleted file mode 100644
index ca403c477..000000000
--- a/src/gui/windows/connectiondialog.h
+++ /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/>.
- */
-
-#ifndef GUI_WINDOWS_CONNECTIONDIALOG_H
-#define GUI_WINDOWS_CONNECTIONDIALOG_H
-
-#include "enums/state.h"
-
-#include "gui/widgets/window.h"
-
-#include "listeners/actionlistener.h"
-
-/**
- * The connection dialog.
- *
- * \ingroup Interface
- */
-class ConnectionDialog final : public Window,
- private ActionListener
-{
- public:
- /**
- * Constructor.
- *
- * @param text The text to display
- * @param cancelState The state to enter when Cancel is pressed
- *
- * @see Window::Window
- */
- ConnectionDialog(const std::string &text, const StateT cancelState);
-
- A_DELETE_COPY(ConnectionDialog)
-
- void postInit() override final;
-
- /**
- * Called when the user presses Cancel. Restores the global state to
- * the previous one.
- */
- void action(const ActionEvent &event) override final;
-
- void draw(Graphics *const graphics) override final A_NONNULL(2);
-
- void safeDraw(Graphics *const graphics) override final A_NONNULL(2);
-
- private:
- StateT mCancelState;
-};
-
-#endif // GUI_WINDOWS_CONNECTIONDIALOG_H
diff --git a/src/gui/windows/cutinwindow.cpp b/src/gui/windows/cutinwindow.cpp
deleted file mode 100644
index 2713dfdfc..000000000
--- a/src/gui/windows/cutinwindow.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 "gui/windows/cutinwindow.h"
-
-#include "configuration.h"
-
-#include "const/utils/timer.h"
-
-#include "resources/sprite/animatedsprite.h"
-
-#include "utils/delete2.h"
-#include "utils/timer.h"
-
-#include "debug.h"
-
-CutInWindow *cutInWindow = nullptr;
-
-CutInWindow::CutInWindow() :
- Window("", Modal_false, nullptr, "cutin.xml"),
- mImage(nullptr),
- mOldTitleBarHeight(mTitleBarHeight)
-{
- setWindowName("CutIn");
-
- setShowTitle(false);
- setResizable(false);
- setDefaultVisible(false);
- setSaveVisible(false);
- setVisible(Visible_false);
- enableVisibleSound(false);
-}
-
-CutInWindow::~CutInWindow()
-{
- delete2(mImage);
-}
-
-void CutInWindow::draw(Graphics *const graphics)
-{
- Window::draw(graphics);
- draw2(graphics);
-}
-
-void CutInWindow::safeDraw(Graphics *const graphics)
-{
- Window::safeDraw(graphics);
- draw2(graphics);
-}
-
-void CutInWindow::draw2(Graphics *const graphics)
-{
- if (mImage != nullptr)
- mImage->drawRaw(graphics, mPadding, mTitleBarHeight);
-}
-
-void CutInWindow::show(const std::string &name,
- const CutInT cutin)
-{
- delete2(mImage);
- if (name.empty())
- {
- setVisible(Visible_false);
- }
- else
- {
- mImage = AnimatedSprite::load(
- pathJoin(paths.getStringValue("cutInsDir"),
- name).append(
- ".xml"));
- if (mImage != nullptr)
- {
- mImage->update(1);
- const bool showTitle = (cutin == CutIn::MovableClose);
- if (showTitle)
- mTitleBarHeight = mOldTitleBarHeight;
- else
- mTitleBarHeight = mPadding;
- const int width = mImage->getWidth() + 2 * mPadding;
- const int height = mImage->getHeight() + mTitleBarHeight
- + mPadding;
-
- const int screenWidth = mainGraphics->mWidth;
- const int screenHeight = mainGraphics->mHeight;
-
- if (width * 2 > screenWidth ||
- height * 2 > screenHeight)
- {
- return;
- }
- const int padding = 100;
- int x = 0;
- const int y = screenHeight - height - padding;
- switch (cutin)
- {
- case CutIn::BottomRight:
- x = screenWidth - width - padding;
- break;
- case CutIn::BottomCenter:
- case CutIn::Movable:
- case CutIn::MovableClose:
- x = (screenWidth - width) / 2;
- break;
- case CutIn::BottomLeft:
- default:
- x = padding;
- break;
- }
- setCloseButton(false);
- setVisible(Visible_true);
- setPosition(x, y);
- setCloseButton(showTitle);
- setShowTitle(showTitle);
- setSize(width, height);
- setVisible(Visible_true);
- requestMoveToTop();
- }
- }
-}
-
-void CutInWindow::hide()
-{
- delete2(mImage);
- setVisible(Visible_false);
-}
-
-void CutInWindow::logic()
-{
- if (mImage != nullptr)
- {
- const int time = tick_time * MILLISECONDS_IN_A_TICK;
- mImage->update(time);
- }
-}
diff --git a/src/gui/windows/cutinwindow.h b/src/gui/windows/cutinwindow.h
deleted file mode 100644
index c0aa81577..000000000
--- a/src/gui/windows/cutinwindow.h
+++ /dev/null
@@ -1,61 +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_WINDOWS_CUTINWINDOW_H
-#define GUI_WINDOWS_CUTINWINDOW_H
-
-#include "gui/widgets/window.h"
-
-#include "enums/cutin.h"
-
-class AnimatedSprite;
-
-class CutInWindow final : public Window
-{
- public:
- CutInWindow();
-
- A_DELETE_COPY(CutInWindow)
-
- ~CutInWindow();
-
- void draw(Graphics *const graphics) override final A_NONNULL(2);
-
- void safeDraw(Graphics *const graphics) override final A_NONNULL(2);
-
- void draw2(Graphics *const graphics) A_NONNULL(2);
-
- void show(const std::string &name,
- const CutInT cutin);
-
- void hide();
-
- void logic() override final;
-
- private:
- AnimatedSprite *mImage;
- int mOldTitleBarHeight;
-};
-
-extern CutInWindow *cutInWindow;
-
-#endif // GUI_WINDOWS_CUTINWINDOW_H
diff --git a/src/gui/windows/debugwindow.cpp b/src/gui/windows/debugwindow.cpp
deleted file mode 100644
index e10ad1b2c..000000000
--- a/src/gui/windows/debugwindow.cpp
+++ /dev/null
@@ -1,173 +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 "gui/windows/debugwindow.h"
-
-#include "being/localplayer.h"
-
-#include "gui/windows/setupwindow.h"
-
-#include "gui/widgets/createwidget.h"
-#include "gui/widgets/tabbedarea.h"
-
-#include "gui/widgets/tabs/debugwindowtabs.h"
-
-#include "utils/delete2.h"
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-DebugWindow *debugWindow = nullptr;
-
-DebugWindow::DebugWindow(const std::string &name) :
- // TRANSLATORS: debug window name
- Window(_("Debug"), Modal_false, nullptr, "debug.xml"),
- mTabs(CREATEWIDGETR(TabbedArea, this)),
- mMapWidget(new MapDebugTab(this)),
- mTargetWidget(new TargetDebugTab(this)),
- mNetWidget(new NetDebugTab(this))
-{
- setWindowName(name);
- if (setupWindow != nullptr)
- setupWindow->registerWindowForReset(this);
-
- setResizable(true);
- setCloseButton(true);
- setSaveVisible(true);
- setStickyButtonLock(true);
-
- setDefaultSize(400, 300, ImagePosition::CENTER);
-
- mTabs->setSelectable(false);
- mTabs->getWidgetContainer()->setSelectable(false);
- mTabs->getTabContainer()->setSelectable(false);
- // TRANSLATORS: debug window tab
- mTabs->addTab(std::string(_("Map")), mMapWidget);
- // TRANSLATORS: debug window tab
- mTabs->addTab(std::string(_("Target")), mTargetWidget);
- // TRANSLATORS: debug window tab
- mTabs->addTab(std::string(_("Net")), mNetWidget);
-
- mTabs->setDimension(Rect(0, 0, 600, 300));
-
- const int w = mDimension.width;
- const int h = mDimension.height;
- mMapWidget->resize(w, h);
- mTargetWidget->resize(w, h);
- mNetWidget->resize(w, h);
- loadWindowState();
- enableVisibleSound(true);
-}
-
-DebugWindow::~DebugWindow()
-{
- delete2(mMapWidget);
- delete2(mTargetWidget);
- delete2(mNetWidget);
-}
-
-void DebugWindow::postInit()
-{
- Window::postInit();
- add(mTabs);
-}
-
-void DebugWindow::slowLogic()
-{
- BLOCK_START("DebugWindow::slowLogic")
- if (!isWindowVisible() || (mTabs == nullptr))
- {
- BLOCK_END("DebugWindow::slowLogic")
- return;
- }
-
- switch (mTabs->getSelectedTabIndex())
- {
- default:
- case 0:
- mMapWidget->logic();
- break;
- case 1:
- mTargetWidget->logic();
- break;
- case 2:
- mNetWidget->logic();
- break;
- }
-
- if (localPlayer != nullptr)
- localPlayer->tryPingRequest();
- BLOCK_END("DebugWindow::slowLogic")
-}
-
-void DebugWindow::draw(Graphics *const g)
-{
- BLOCK_START("DebugWindow::draw")
- Window::draw(g);
-
- if (localPlayer != nullptr)
- {
- const Being *const target = localPlayer->getTarget();
- if (target != nullptr)
- {
- target->draw(g, -target->getPixelX() + mapTileSize / 2
- + mDimension.width / 2, -target->getPixelY() + mapTileSize
- + mDimension.height / 2);
- }
- }
- BLOCK_END("DebugWindow::draw")
-}
-
-void DebugWindow::safeDraw(Graphics *const g)
-{
- BLOCK_START("DebugWindow::draw")
- Window::safeDraw(g);
-
- if (localPlayer != nullptr)
- {
- const Being *const target = localPlayer->getTarget();
- if (target != nullptr)
- {
- target->draw(g, -target->getPixelX() + mapTileSize / 2
- + mDimension.width / 2, -target->getPixelY() + mapTileSize
- + mDimension.height / 2);
- }
- }
- BLOCK_END("DebugWindow::draw")
-}
-
-void DebugWindow::widgetResized(const Event &event)
-{
- Window::widgetResized(event);
-
- mTabs->setDimension(Rect(0, 0,
- mDimension.width, mDimension.height));
-}
-
-#ifdef USE_PROFILER
-void DebugWindow::logicChildren()
-{
- BLOCK_START("DebugWindow::logicChildren")
- BasicContainer::logicChildren();
- BLOCK_END("DebugWindow::logicChildren")
-}
-#endif // USE_PROFILER
diff --git a/src/gui/windows/debugwindow.h b/src/gui/windows/debugwindow.h
deleted file mode 100644
index 6350b8820..000000000
--- a/src/gui/windows/debugwindow.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 GUI_WINDOWS_DEBUGWINDOW_H
-#define GUI_WINDOWS_DEBUGWINDOW_H
-
-#include "gui/widgets/window.h"
-
-class MapDebugTab;
-class NetDebugTab;
-class TabbedArea;
-class TargetDebugTab;
-
-/**
- * The debug window.
- *
- * \ingroup Interface
- */
-class DebugWindow final : public Window
-{
- public:
- /**
- * Constructor.
- */
- explicit DebugWindow(const std::string &name);
-
- A_DELETE_COPY(DebugWindow)
-
- ~DebugWindow();
-
- void postInit() override final;
-
- /**
- * Logic (updates components' size and infos)
- */
- void slowLogic();
-
- void draw(Graphics *const g) override final A_NONNULL(2);
-
- void safeDraw(Graphics *const g) override final A_NONNULL(2);
-
- void setPing(int pingTime);
-
- void widgetResized(const Event &event) override final;
-
-#ifdef USE_PROFILER
- void logicChildren();
-#endif // USE_PROFILER
-
- private:
- TabbedArea *mTabs A_NONNULLPOINTER;
- MapDebugTab *mMapWidget A_NONNULLPOINTER;
- TargetDebugTab *mTargetWidget A_NONNULLPOINTER;
- NetDebugTab *mNetWidget A_NONNULLPOINTER;
-};
-
-extern DebugWindow *debugWindow;
-
-#endif // GUI_WINDOWS_DEBUGWINDOW_H
diff --git a/src/gui/windows/didyouknowwindow.cpp b/src/gui/windows/didyouknowwindow.cpp
deleted file mode 100644
index adaf6fe2f..000000000
--- a/src/gui/windows/didyouknowwindow.cpp
+++ /dev/null
@@ -1,188 +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 "gui/windows/didyouknowwindow.h"
-
-#include "configuration.h"
-
-#include "enums/gui/layouttype.h"
-
-#include "gui/gui.h"
-
-#include "gui/windows/setupwindow.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/checkbox.h"
-#include "gui/widgets/itemlinkhandler.h"
-#include "gui/widgets/layout.h"
-#include "gui/widgets/scrollarea.h"
-#include "gui/widgets/staticbrowserbox.h"
-
-#include "utils/delete2.h"
-#include "utils/gettext.h"
-
-#include "utils/translation/podict.h"
-#include "utils/translation/translationmanager.h"
-
-#include "debug.h"
-
-DidYouKnowWindow *didYouKnowWindow = nullptr;
-
-static const int minTip = 1;
-static const int maxTip = 18;
-
-DidYouKnowWindow::DidYouKnowWindow() :
- // TRANSLATORS: did you know window name
- Window(_("Did You Know?"), Modal_false, nullptr, "didyouknow.xml"),
- ActionListener(),
- mItemLinkHandler(new ItemLinkHandler),
- mBrowserBox(new StaticBrowserBox(this, Opaque_true,
- "browserbox.xml")),
- mScrollArea(new ScrollArea(this, mBrowserBox,
- Opaque_true, "didyouknow_background.xml")),
- // TRANSLATORS: did you know window button
- mButtonPrev(new Button(this, _("< Previous"), "prev", this)),
- // TRANSLATORS: did you know window button
- mButtonNext(new Button(this, _("Next >"), "next", this)),
- // TRANSLATORS: did you know window checkbox
- mOpenAgainCheckBox(new CheckBox(this, _("Auto open this window"),
- config.getBoolValue("showDidYouKnow"), this, "openagain"))
-{
- setMinWidth(300);
- setMinHeight(220);
- setContentSize(455, 350);
- setWindowName("DidYouKnow");
- setCloseButton(true);
- setResizable(true);
- setStickyButtonLock(true);
-
- if (setupWindow != nullptr)
- setupWindow->registerWindowForReset(this);
- setDefaultSize(500, 400, ImagePosition::CENTER);
-
- mBrowserBox->setOpaque(Opaque_false);
- // TRANSLATORS: did you know window button
- Button *const okButton = new Button(this, _("Close"), "close", this);
-
- mBrowserBox->setLinkHandler(mItemLinkHandler);
- if (gui != nullptr)
- mBrowserBox->setFont(gui->getHelpFont());
- mBrowserBox->setProcessVars(true);
- mBrowserBox->setEnableImages(true);
- mBrowserBox->setEnableKeys(true);
- mBrowserBox->setEnableTabs(true);
-
- place(0, 0, mScrollArea, 5, 3).setPadding(3);
- place(0, 3, mOpenAgainCheckBox, 5);
- place(1, 4, mButtonPrev, 1);
- place(2, 4, mButtonNext, 1);
- place(4, 4, okButton);
-
- Layout &layout = getLayout();
- layout.setRowHeight(0, LayoutType::SET);
-
- loadWindowState();
- enableVisibleSound(true);
-}
-
-void DidYouKnowWindow::postInit()
-{
- Window::postInit();
- widgetResized(Event(nullptr));
-}
-
-DidYouKnowWindow::~DidYouKnowWindow()
-{
- delete2(mItemLinkHandler);
-}
-
-void DidYouKnowWindow::action(const ActionEvent &event)
-{
- const std::string &eventId = event.getId();
- if (eventId == "close")
- {
- setVisible(Visible_false);
- }
- else
- {
- const unsigned num = config.getIntValue("currentTip");
- if (eventId == "prev")
- {
- loadData(num - 1);
- }
- else if (eventId == "next")
- {
- loadData(num + 1);
- }
- else if (eventId == "openagain")
- {
- config.setValue("showDidYouKnow",
- mOpenAgainCheckBox->isSelected());
- }
- }
-}
-
-void DidYouKnowWindow::loadData(int num)
-{
- mBrowserBox->clearRows();
- if (num == 0)
- {
- const int curTip = config.getIntValue("currentTip");
- if (curTip == 1)
- num = maxTip;
- else
- num = curTip + 1;
- }
-
- if (num < minTip || num > maxTip)
- num = minTip;
-
- config.setValue("currentTip", num);
-
- loadFile(num);
-
- mBrowserBox->updateHeight();
- mScrollArea->setVerticalScrollAmount(0);
-}
-
-void DidYouKnowWindow::loadFile(const int num)
-{
- const std::string file = strprintf("tips/%d", num);
- std::string helpPath = branding.getStringValue("helpPath");
- if (helpPath.empty())
- helpPath = paths.getStringValue("help");
-
- StringVect lines;
- TranslationManager::translateFile(pathJoin(helpPath, file).append(".txt"),
- translator, lines);
-
- for (size_t i = 0, sz = lines.size(); i < sz; ++i)
- mBrowserBox->addRow(lines[i]);
-}
-
-void DidYouKnowWindow::setVisible(Visible visible)
-{
- Window::setVisible(visible);
-
- if (visible == Visible_true || isWindowVisible())
- loadData();
-}
diff --git a/src/gui/windows/didyouknowwindow.h b/src/gui/windows/didyouknowwindow.h
deleted file mode 100644
index 6d5fdf1ae..000000000
--- a/src/gui/windows/didyouknowwindow.h
+++ /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/>.
- */
-
-#ifndef GUI_WINDOWS_DIDYOUKNOWWINDOW_H
-#define GUI_WINDOWS_DIDYOUKNOWWINDOW_H
-
-#include "gui/widgets/window.h"
-
-#include "listeners/actionlistener.h"
-
-class Button;
-class CheckBox;
-class ItemLinkHandler;
-class ScrollArea;
-class StaticBrowserBox;
-
-/**
- * The help dialog.
- */
-class DidYouKnowWindow final : public Window,
- public ActionListener
-{
- public:
- /**
- * Constructor.
- */
- DidYouKnowWindow();
-
- ~DidYouKnowWindow();
-
- A_DELETE_COPY(DidYouKnowWindow)
-
- void postInit() override final;
-
- /**
- * Called when receiving actions from the widgets.
- */
- void action(const ActionEvent &event) override final;
-
- void loadData(int num = 0);
-
- void setVisible(Visible visible) override final;
-
- private:
- void loadFile(const int num);
-
- ItemLinkHandler *mItemLinkHandler A_NONNULLPOINTER;
- StaticBrowserBox *mBrowserBox A_NONNULLPOINTER;
- ScrollArea *mScrollArea A_NONNULLPOINTER;
- Button *mButtonPrev A_NONNULLPOINTER;
- Button *mButtonNext A_NONNULLPOINTER;
- CheckBox *mOpenAgainCheckBox A_NONNULLPOINTER;
-};
-
-extern DidYouKnowWindow *didYouKnowWindow;
-
-#endif // GUI_WINDOWS_DIDYOUKNOWWINDOW_H
diff --git a/src/gui/windows/editdialog.cpp b/src/gui/windows/editdialog.cpp
deleted file mode 100644
index e14b96191..000000000
--- a/src/gui/windows/editdialog.cpp
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 Andrei Karas
- * 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 "gui/windows/editdialog.h"
-
-#include "gui/widgets/button.h"
-
-#include "utils/foreach.h"
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-EditDialog::EditDialog(const std::string &restrict title,
- const std::string &restrict msg,
- const std::string &restrict eventOk,
- const int width,
- Window *const parent,
- const Modal modal) :
- Window(title, modal, parent, "edit.xml"),
- ActionListener(),
- mEventOk(eventOk),
- mTextField(new TextField(this))
-{
- mDefaultWidth = width;
- mTextField->setText(msg);
-}
-
-void EditDialog::postInit()
-{
- Window::postInit();
- // TRANSLATORS: edit dialog label
- Button *const okButton = new Button(this, _("OK"), mEventOk, this);
-
- const int pad = getPadding();
- const int pad2 = pad * 2;
- mTextField->setPosition(pad, pad);
- mTextField->setWidth(mDefaultWidth - pad2);
- const int buttonPadding = getOption("buttonPadding", 8)
- + mTextField->getHeight();
- setContentSize(mDefaultWidth, okButton->getHeight()
- + buttonPadding + pad2);
- okButton->setPosition((mDefaultWidth - okButton->getWidth()) / 2,
- buttonPadding + pad);
-
- add(mTextField);
- add(okButton);
-
- center();
- setVisible(Visible_true);
- okButton->requestFocus();
-}
-
-void EditDialog::action(const ActionEvent &event)
-{
- // Proxy button events to our listeners
- FOR_EACH (ActionListenerIterator, i, mActionListeners)
- (*i)->action(event);
-
- if (event.getId() == mEventOk)
- scheduleDelete();
-}
diff --git a/src/gui/windows/editdialog.h b/src/gui/windows/editdialog.h
deleted file mode 100644
index cea7d6f78..000000000
--- a/src/gui/windows/editdialog.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 Andrei Karas
- * 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_WINDOWS_EDITDIALOG_H
-#define GUI_WINDOWS_EDITDIALOG_H
-
-#include "localconsts.h"
-
-#include "gui/widgets/window.h"
-#include "gui/widgets/textfield.h"
-
-#include "listeners/actionlistener.h"
-
-#define ACTION_EDIT_OK "edit ok"
-
-/**
- * An 'Ok' button dialog.
- *
- * \ingroup GUI
- */
-class EditDialog final : public Window,
- public ActionListener
-{
- public:
- /**
- * Constructor.
- *
- * @see Window::Window
- */
- EditDialog(const std::string &restrict title,
- const std::string &restrict msg,
- const std::string &restrict eventOk = ACTION_EDIT_OK,
- const int width = 300, Window *const parent = nullptr,
- const Modal modal = Modal_true);
-
- A_DELETE_COPY(EditDialog)
-
- void postInit() override final;
-
- /**
- * Called when receiving actions from the widgets.
- */
- void action(const ActionEvent &event) override final;
-
- std::string getMsg() const A_WARN_UNUSED
- { return mTextField->getText(); }
-
- private:
- std::string mEventOk;
- TextField *mTextField A_NONNULLPOINTER;
-};
-
-#endif // GUI_WINDOWS_EDITDIALOG_H
diff --git a/src/gui/windows/editserverdialog.cpp b/src/gui/windows/editserverdialog.cpp
deleted file mode 100644
index 37683caf5..000000000
--- a/src/gui/windows/editserverdialog.cpp
+++ /dev/null
@@ -1,297 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2012 The Mana Developers
- * 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 "gui/windows/editserverdialog.h"
-
-#include "const/net/maxpacketversion.h"
-
-#include "gui/models/typelistmodel.h"
-
-#include "gui/windows/okdialog.h"
-#include "gui/windows/serverdialog.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/checkbox.h"
-#include "gui/widgets/createwidget.h"
-#include "gui/widgets/dropdown.h"
-#include "gui/widgets/inttextfield.h"
-#include "gui/widgets/label.h"
-#include "gui/widgets/layout.h"
-
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-EditServerDialog::EditServerDialog(ServerDialog *const parent,
- const ServerInfo &server,
- const int index) :
- // TRANSLATORS: edit server dialog name
- Window(_("Edit Server"), Modal_true, parent),
- ActionListener(),
- KeyListener(),
- mServerAddressField(new TextField(this, std::string())),
- mPortField(new TextField(this, std::string())),
- mNameField(new TextField(this, std::string())),
- mDescriptionField(new TextField(this, std::string())),
- mOnlineListUrlField(new TextField(this, std::string())),
- mPacketVersionField(new IntTextField(this, 0, 0, maxPacketVersion)),
- // TRANSLATORS: edit server dialog button
- mConnectButton(new Button(this, _("Connect"), "connect", this)),
- // TRANSLATORS: edit server dialog button
- mOkButton(new Button(this, _("OK"), "addServer", this)),
- // TRANSLATORS: edit server dialog button
- mCancelButton(new Button(this, _("Cancel"), "cancel", this)),
- // TRANSLATORS: edit server dialog label
- mPersistentIp(new CheckBox(this, _("Use same ip"),
- true, this, "persistentIp")),
- mTypeListModel(new TypeListModel),
- mTypeField(new DropDown(this, mTypeListModel, false, Modal_true)),
- mServerDialog(parent),
- mServer(server),
- mIndex(index)
-{
- setWindowName("EditServerDialog");
-
- // TRANSLATORS: edit server dialog label
- Label *const nameLabel = new Label(this, _("Name:"));
- // TRANSLATORS: edit server dialog label
- Label *const serverAdressLabel = new Label(this, _("Address:"));
- // TRANSLATORS: edit server dialog label
- Label *const portLabel = new Label(this, _("Port:"));
- // TRANSLATORS: edit server dialog label
- Label *const typeLabel = new Label(this, _("Server type:"));
- // TRANSLATORS: edit server dialog label
- Label *const descriptionLabel = new Label(this, _("Description:"));
- // TRANSLATORS: edit server dialog label
- Label *const onlineListUrlLabel = new Label(this, _("Online list url:"));
- // TRANSLATORS: edit server dialog label
- Label *const packetVersionLabel = new Label(this, _("Packet version:"));
- mPortField->setNumeric(true);
- mPortField->setRange(1, 65535);
-
- mTypeField->setSelected(0); // TmwAthena by default
-
- mServerAddressField->addActionListener(this);
- mPortField->addActionListener(this);
-
- place(0, 0, nameLabel);
- place(1, 0, mNameField, 4).setPadding(3);
- place(0, 1, serverAdressLabel);
- place(1, 1, mServerAddressField, 4).setPadding(3);
- place(0, 2, portLabel);
- place(1, 2, mPortField, 4).setPadding(3);
- place(0, 3, typeLabel);
- place(1, 3, mTypeField).setPadding(3);
- place(0, 4, descriptionLabel);
- place(1, 4, mDescriptionField, 4).setPadding(3);
- place(0, 5, onlineListUrlLabel);
- place(1, 5, mOnlineListUrlField, 4).setPadding(3);
- place(0, 6, packetVersionLabel);
- place(1, 6, mPacketVersionField, 4).setPadding(3);
- place(0, 7, mPersistentIp, 4).setPadding(3);
- place(0, 8, mConnectButton);
- place(4, 8, mOkButton);
- place(3, 8, mCancelButton);
-
- // Do this manually instead of calling reflowLayout so we can enforce a
- // minimum width.
- int width = 0;
- int height = 0;
- getLayout().reflow(width, height);
- if (width < 300)
- {
- width = 300;
- getLayout().reflow(width, height);
- }
- if (height < 120)
- {
- height = 120;
- getLayout().reflow(width, height);
- }
-
- setContentSize(width, height);
-
- setMinWidth(getWidth());
- setMinHeight(getHeight());
- setDefaultSize(getWidth(), getHeight(), ImagePosition::CENTER);
-
- setResizable(false);
- addKeyListener(this);
-
- loadWindowState();
-
- mNameField->setText(mServer.name);
- mDescriptionField->setText(mServer.description);
- mOnlineListUrlField->setText(mServer.onlineListUrl);
- mServerAddressField->setText(mServer.hostname);
- mPacketVersionField->setValue(mServer.packetVersion);
- mPortField->setText(toString(mServer.port));
- mPersistentIp->setSelected(mServer.persistentIp);
-
- switch (mServer.type)
- {
- case ServerType::EATHENA:
-#ifdef TMWA_SUPPORT
- mTypeField->setSelected(1);
-#else // TMWA_SUPPORT
- mTypeField->setSelected(0);
-#endif // TMWA_SUPPORT
- break;
- default:
- case ServerType::UNKNOWN:
- case ServerType::TMWATHENA:
- mTypeField->setSelected(0);
- break;
- case ServerType::EVOL2:
-#ifdef TMWA_SUPPORT
- mTypeField->setSelected(2);
-#else // TMWA_SUPPORT
- mTypeField->setSelected(1);
-#endif // TMWA_SUPPORT
- break;
- }
-
- setLocationRelativeTo(getParentWindow());
-}
-
-EditServerDialog::~EditServerDialog()
-{
- delete mTypeListModel;
-}
-
-void EditServerDialog::postInit()
-{
- Window::postInit();
- setVisible(Visible_true);
- mNameField->requestFocus();
-}
-
-void EditServerDialog::action(const ActionEvent &event)
-{
- const std::string &eventId = event.getId();
-
- if (eventId == "ok")
- {
- // Give focus back to the server dialog.
- mServerAddressField->requestFocus();
- }
- if (eventId == "addServer" || eventId == "connect")
- {
- // Check the given information
- if (mServerAddressField->getText().empty()
- || mPortField->getText().empty())
- {
- OkDialog *const dlg = CREATEWIDGETR(OkDialog,
- // TRANSLATORS: edit server dialog error header
- _("Error"),
- // TRANSLATORS: edit server dialog error message
- _("Please at least type both the address and the port "
- "of the server."),
- // TRANSLATORS: ok dialog button
- _("OK"),
- DialogType::ERROR,
- Modal_true,
- ShowCenter_true,
- nullptr,
- 260);
- dlg->addActionListener(this);
- }
- else
- {
- mCancelButton->setEnabled(false);
- mOkButton->setEnabled(false);
-
- mServer.name = mNameField->getText();
- mServer.description = mDescriptionField->getText();
- mServer.onlineListUrl = mOnlineListUrlField->getText();
- mServer.hostname = mServerAddressField->getText();
- mServer.packetVersion = mPacketVersionField->getValue();
- mServer.port = CAST_S16(atoi(
- mPortField->getText().c_str()));
- mServer.persistentIp = mPersistentIp->isSelected();
-
- if (mTypeField != nullptr)
- {
- switch (mTypeField->getSelected())
- {
-#ifdef TMWA_SUPPORT
- case 0:
- mServer.type = ServerType::TMWATHENA;
- break;
- case 1:
- mServer.type = ServerType::EATHENA;
- break;
- case 2:
- mServer.type = ServerType::EVOL2;
- break;
-#else // TMWA_SUPPORT
-
- case 0:
- mServer.type = ServerType::EATHENA;
- break;
- case 1:
- mServer.type = ServerType::EVOL2;
- break;
-#endif // TMWA_SUPPORT
-
- default:
- mServer.type = ServerType::UNKNOWN;
- break;
- }
- }
- else
- {
- mServer.type = ServerType::TMWATHENA;
- }
-
- // Tell the server has to be saved
- mServer.save = true;
-
- // Add server
- mServerDialog->updateServer(mServer, mIndex);
- if (eventId == "connect")
- mServerDialog->connectToSelectedServer();
- scheduleDelete();
- }
- }
- else if (eventId == "cancel")
- {
- scheduleDelete();
- }
-}
-
-void EditServerDialog::keyPressed(KeyEvent &event)
-{
- if (event.isConsumed())
- return;
-
- const InputActionT actionId = event.getActionId();
-
- if (actionId == InputAction::GUI_CANCEL)
- {
- scheduleDelete();
- }
- else if (actionId == InputAction::GUI_SELECT ||
- actionId == InputAction::GUI_SELECT2)
- {
- action(ActionEvent(nullptr, mOkButton->getActionEventId()));
- }
-}
diff --git a/src/gui/windows/editserverdialog.h b/src/gui/windows/editserverdialog.h
deleted file mode 100644
index e53632c00..000000000
--- a/src/gui/windows/editserverdialog.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2012 The Mana Developers
- * 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 GUI_WINDOWS_EDITSERVERDIALOG_H
-#define GUI_WINDOWS_EDITSERVERDIALOG_H
-
-class Button;
-class CheckBox;
-class DropDown;
-class IntTextField;
-class ServerDialog;
-class TextField;
-class TypeListModel;
-
-#include "gui/widgets/window.h"
-
-#include "net/serverinfo.h"
-
-#include "listeners/actionlistener.h"
-#include "listeners/keylistener.h"
-
-/**
- * The custom server addition dialog.
- *
- * \ingroup Interface
- */
-class EditServerDialog final : public Window,
- public ActionListener,
- public KeyListener
-{
- public:
- EditServerDialog(ServerDialog *const parent,
- const ServerInfo &server,
- const int index);
-
- A_DELETE_COPY(EditServerDialog)
-
- ~EditServerDialog();
-
- void postInit() override final;
-
- /**
- * Called when receiving actions from the widgets.
- */
- void action(const ActionEvent &event) override final;
-
- void keyPressed(KeyEvent &event) override final;
-
- private:
- TextField *mServerAddressField A_NONNULLPOINTER;
- TextField *mPortField A_NONNULLPOINTER;
- TextField *mNameField A_NONNULLPOINTER;
- TextField *mDescriptionField A_NONNULLPOINTER;
- TextField *mOnlineListUrlField A_NONNULLPOINTER;
- IntTextField *mPacketVersionField A_NONNULLPOINTER;
- Button *mConnectButton A_NONNULLPOINTER;
- Button *mOkButton A_NONNULLPOINTER;
- Button *mCancelButton A_NONNULLPOINTER;
- CheckBox *mPersistentIp A_NONNULLPOINTER;
- TypeListModel *mTypeListModel A_NONNULLPOINTER;
- DropDown *mTypeField A_NONNULLPOINTER;
-
- ServerDialog *mServerDialog;
- ServerInfo mServer;
- int mIndex;
-};
-
-#endif // GUI_WINDOWS_EDITSERVERDIALOG_H
diff --git a/src/gui/windows/eggselectiondialog.cpp b/src/gui/windows/eggselectiondialog.cpp
deleted file mode 100644
index 5e77d8ec1..000000000
--- a/src/gui/windows/eggselectiondialog.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 "gui/windows/eggselectiondialog.h"
-
-#include "gui/models/shopitems.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/shoplistbox.h"
-
-#include "net/inventoryhandler.h"
-
-#include "utils/gettext.h"
-
-#include "resources/item/shopitem.h"
-
-#include "debug.h"
-
-EggSelectionDialog::EggSelectionDialog() :
- SellDialog(IsSell_false, Advanced_false)
-{
- // TRANSLATORS: egg selection dialog name
- setWindowName(_("Select egg"));
- // TRANSLATORS: egg selection dialog name
- setCaption(_("Select egg"));
-}
-
-void EggSelectionDialog::initButtons()
-{
- logger->log("EggSelectionDialog::initButtons");
- // TRANSLATORS: egg selection dialog button
- mSellButton->setCaption(_("Select"));
- mSellButton->adjustSize();
- mShopItems->setMergeDuplicates(false);
-}
-
-void EggSelectionDialog::sellAction(const ActionEvent &event A_UNUSED)
-{
- if (mAmountItems <= 0 || mAmountItems > mMaxItems)
- return;
-
- const int selectedItem = mShopItemList->getSelected();
- const ShopItem *const item = mShopItems->at(selectedItem);
- if (item == nullptr)
- return;
- inventoryHandler->selectEgg(item);
- scheduleDelete();
-}
diff --git a/src/gui/windows/eggselectiondialog.h b/src/gui/windows/eggselectiondialog.h
deleted file mode 100644
index 14d91a699..000000000
--- a/src/gui/windows/eggselectiondialog.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 GUI_WINDOWS_EGGSELECTIONDIALOG_H
-#define GUI_WINDOWS_EGGSELECTIONDIALOG_H
-
-#include "gui/widgets/selldialog.h"
-
-class EggSelectionDialog final : public SellDialog
-{
- public:
- /**
- * Constructor.
- *
- * @see Window::Window
- */
- EggSelectionDialog();
-
- A_DELETE_COPY(EggSelectionDialog)
-
- protected:
- void initButtons() override final;
- void sellAction(const ActionEvent &event) override final;
-};
-
-#endif // GUI_WINDOWS_EGGSELECTIONDIALOG_H
diff --git a/src/gui/windows/emotewindow.cpp b/src/gui/windows/emotewindow.cpp
deleted file mode 100644
index f4f720535..000000000
--- a/src/gui/windows/emotewindow.cpp
+++ /dev/null
@@ -1,278 +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 "gui/windows/emotewindow.h"
-
-#include "gui/models/colormodel.h"
-#include "gui/models/namesmodel.h"
-
-#include "gui/windows/setupwindow.h"
-
-#include "gui/widgets/colorpage.h"
-#include "gui/widgets/createwidget.h"
-#include "gui/widgets/emotepage.h"
-#include "gui/widgets/scrollarea.h"
-#include "gui/widgets/tabbedarea.h"
-
-#include "utils/delete2.h"
-#include "utils/foreach.h"
-#include "utils/gettext.h"
-
-#include "utils/translation/podict.h"
-
-#include "resources/imageset.h"
-
-#include "resources/db/textdb.h"
-
-#include "resources/image/image.h"
-
-#include "debug.h"
-
-EmoteWindow *emoteWindow = nullptr;
-static const int fontSizeListSize = 2;
-
-static const char *const fontSizeList[] =
-{
- // TRANSLATORS: font size
- N_("Normal font"),
- // TRANSLATORS: font size
- N_("Bold font"),
-};
-
-EmoteWindow::EmoteWindow() :
- // TRANSLATORS: emotes window name
- Window(_("Emotes"), Modal_false, nullptr, "emotes.xml"),
- mTabs(CREATEWIDGETR(TabbedArea, this)),
- mEmotePage(new EmotePage(this)),
- mColorModel(ColorModel::createDefault(this)),
- mColorPage(CREATEWIDGETR(ColorPage, this, mColorModel, "colorpage.xml")),
- mScrollColorPage(new ScrollArea(this, mColorPage, Opaque_false,
- "emotepage.xml")),
- mFontModel(new NamesModel),
- mFontPage(CREATEWIDGETR(ListBox, this, mFontModel, "")),
- mScrollFontPage(new ScrollArea(this, mFontPage, Opaque_false,
- "fontpage.xml")),
- mTextModel(new NamesModel),
- mTextPage(CREATEWIDGETR(ListBox, this, mTextModel, "")),
- mScrollTextPage(new ScrollArea(this, mTextPage, Opaque_false,
- "textpage.xml")),
- mImageSet(Theme::getImageSetFromThemeXml("emotetabs.xml", "", 17, 16))
-{
- setShowTitle(false);
- setResizable(true);
-
- if (setupWindow != nullptr)
- setupWindow->registerWindowForReset(this);
-
- addMouseListener(this);
-}
-
-void EmoteWindow::postInit()
-{
- Window::postInit();
- const int pad2 = mPadding * 2;
- const int width = 200;
- const int height = 150;
- setWidth(width + pad2);
- setHeight(height + pad2);
- add(mTabs);
- mTabs->setPosition(mPadding, mPadding);
- mTabs->setWidth(width);
- mTabs->setHeight(height);
- center();
-
- setTitleBarHeight(getPadding() + getTitlePadding());
- mScrollColorPage->setVerticalScrollPolicy(ScrollArea::SHOW_ALWAYS);
- mScrollColorPage->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
- mScrollFontPage->setVerticalScrollPolicy(ScrollArea::SHOW_NEVER);
- mScrollFontPage->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
- mScrollTextPage->setVerticalScrollPolicy(ScrollArea::SHOW_NEVER);
- mScrollTextPage->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
-
- mFontModel->fillFromArray(&fontSizeList[0], fontSizeListSize);
-
- mFontPage->setCenter(true);
- mTextPage->setCenter(true);
-
- if ((mImageSet != nullptr) && mImageSet->size() >= 3)
- {
- for (int f = 0; f < 3; f ++)
- {
- Image *const image = mImageSet->get(f);
- if (image != nullptr)
- image->incRef();
- }
-
- mTabs->addTab(mImageSet->get(0), mEmotePage);
- mTabs->addTab(mImageSet->get(2), mScrollColorPage);
- mTabs->addTab(mImageSet->get(1), mScrollFontPage);
- }
- else
- {
- // TRANSLATORS: emotes tab name
- mTabs->addTab(_("Emotes"), mEmotePage);
- // TRANSLATORS: emotes tab name
- mTabs->addTab(_("Colors"), mScrollColorPage);
- // TRANSLATORS: emotes tab name
- mTabs->addTab(_("Fonts"), mScrollFontPage);
- }
- // TRANSLATORS: emotes tab name
- mTabs->addTab(_("T"), mScrollTextPage);
-
- mEmotePage->setActionEventId("emote");
- mColorPage->setActionEventId("color");
- mFontPage->setActionEventId("font");
- mTextPage->setActionEventId("text");
-}
-
-EmoteWindow::~EmoteWindow()
-{
- mTabs->removeAll(false);
- mTabs->removeTab(mTabs->getTabByIndex(0));
- delete2(mEmotePage);
- delete2(mColorPage);
- delete2(mColorModel);
- delete2(mScrollColorPage);
- delete2(mFontPage);
- delete2(mFontModel);
- delete2(mScrollFontPage);
- delete2(mTextPage);
- delete2(mTextModel);
- delete2(mScrollTextPage);
- if (mImageSet != nullptr)
- {
- mImageSet->decRef();
- mImageSet = nullptr;
- }
-}
-
-void EmoteWindow::show()
-{
- setVisible(Visible_true);
- if (dictionary != nullptr)
- {
- mTextModel->clear();
- const STD_VECTOR<std::string> &texts = TextDb::getTexts();
- FOR_EACH (StringVectCIter, it, texts)
- {
- mTextModel->add(dictionary->getStr(*it));
- }
- }
-}
-
-void EmoteWindow::hide()
-{
- setVisible(Visible_false);
-}
-
-std::string EmoteWindow::getSelectedEmote() const
-{
- const int index = mEmotePage->getSelectedIndex();
- if (index < 0)
- return std::string();
-
- char chr[2];
- chr[0] = CAST_8('0' + index);
- chr[1] = 0;
- return std::string("%%").append(&chr[0]);
-}
-
-void EmoteWindow::clearEmote()
-{
- const int index = mEmotePage->getSelectedIndex();
- mEmotePage->resetAction();
- if (index >= 0)
- setVisible(Visible_false);
-}
-
-std::string EmoteWindow::getSelectedColor() const
-{
- const int index = mColorPage->getSelected();
- if (index < 0)
- return std::string();
-
- char chr[2];
- chr[0] = CAST_8('0' + index);
- chr[1] = 0;
- return std::string("##").append(&chr[0]);
-}
-
-int EmoteWindow::getSelectedTextIndex() const
-{
- return mTextPage->getSelected();
-}
-
-void EmoteWindow::clearColor()
-{
- mColorPage->resetAction();
- setVisible(Visible_false);
-}
-
-std::string EmoteWindow::getSelectedFont() const
-{
- const int index = mFontPage->getSelected();
- if (index < 0)
- return std::string();
-
- if (index == 0)
- return "##b";
- return "##B";
-}
-
-void EmoteWindow::clearFont()
-{
- mFontPage->setSelected(-1);
- setVisible(Visible_false);
-}
-
-void EmoteWindow::clearText()
-{
- mTextPage->setSelected(-1);
- setVisible(Visible_false);
-}
-
-void EmoteWindow::addListeners(ActionListener *const listener)
-{
- mEmotePage->addActionListener(listener);
- mColorPage->addActionListener(listener);
- mFontPage->addActionListener(listener);
- mTextPage->addActionListener(listener);
-}
-
-void EmoteWindow::widgetResized(const Event &event)
-{
- Window::widgetResized(event);
- const int pad2 = mPadding * 2;
- const int width = mDimension.width;
- const int height = mDimension.height;
-
- mTabs->setSize(width - pad2, height - pad2);
- mTabs->adjustWidget(mEmotePage);
- mTabs->adjustWidget(mScrollColorPage);
- mColorPage->setSize(mScrollColorPage->getWidth(),
- mScrollColorPage->getHeight());
- mEmotePage->widgetResized(event);
-}
-
-void EmoteWindow::widgetMoved(const Event &event)
-{
- Window::widgetMoved(event);
- mEmotePage->widgetResized(event);
-}
diff --git a/src/gui/windows/emotewindow.h b/src/gui/windows/emotewindow.h
deleted file mode 100644
index 66fb0c83c..000000000
--- a/src/gui/windows/emotewindow.h
+++ /dev/null
@@ -1,89 +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 GUI_WINDOWS_EMOTEWINDOW_H
-#define GUI_WINDOWS_EMOTEWINDOW_H
-
-#include "gui/widgets/window.h"
-
-class ColorModel;
-class ColorPage;
-class EmotePage;
-class ImageSet;
-class ListBox;
-class NamesModel;
-class ScrollArea;
-class TabbedArea;
-
-class EmoteWindow final : public Window
-{
- public:
- EmoteWindow();
-
- A_DELETE_COPY(EmoteWindow)
-
- ~EmoteWindow();
-
- void postInit() override final;
-
- void show();
-
- void hide();
-
- std::string getSelectedEmote() const;
-
- void clearEmote();
-
- std::string getSelectedColor() const;
-
- void clearColor();
-
- std::string getSelectedFont() const;
-
- int getSelectedTextIndex() const;
-
- void clearFont();
-
- void clearText();
-
- void addListeners(ActionListener *const listener);
-
- void widgetResized(const Event &event) override final;
-
- void widgetMoved(const Event &event) override final;
-
- private:
- TabbedArea *mTabs A_NONNULLPOINTER;
- EmotePage *mEmotePage A_NONNULLPOINTER;
- ColorModel *mColorModel A_NONNULLPOINTER;
- ColorPage *mColorPage A_NONNULLPOINTER;
- ScrollArea *mScrollColorPage A_NONNULLPOINTER;
- NamesModel *mFontModel A_NONNULLPOINTER;
- ListBox *mFontPage A_NONNULLPOINTER;
- ScrollArea *mScrollFontPage A_NONNULLPOINTER;
- NamesModel *mTextModel A_NONNULLPOINTER;
- ListBox *mTextPage A_NONNULLPOINTER;
- ScrollArea *mScrollTextPage A_NONNULLPOINTER;
- ImageSet *mImageSet;
-};
-
-extern EmoteWindow *emoteWindow;
-
-#endif // GUI_WINDOWS_EMOTEWINDOW_H
diff --git a/src/gui/windows/equipmentwindow.cpp b/src/gui/windows/equipmentwindow.cpp
deleted file mode 100644
index a859ef02b..000000000
--- a/src/gui/windows/equipmentwindow.cpp
+++ /dev/null
@@ -1,848 +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 "gui/windows/equipmentwindow.h"
-
-#include "configuration.h"
-#include "dragdrop.h"
-
-#include "being/localplayer.h"
-#include "being/playerinfo.h"
-
-#include "gui/fonts/font.h"
-
-#include "gui/popups/popupmenu.h"
-#include "gui/popups/itempopup.h"
-
-#include "gui/windows/setupwindow.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/equipmentbox.h"
-#include "gui/widgets/equipmentpage.h"
-#include "gui/widgets/playerbox.h"
-#include "gui/widgets/tabstrip.h"
-
-#include "render/vertexes/imagecollection.h"
-
-#include "resources/imageset.h"
-
-#include "utils/checkutils.h"
-#include "utils/delete2.h"
-#include "utils/dtor.h"
-#include "utils/foreach.h"
-#include "utils/gettext.h"
-
-#include "net/inventoryhandler.h"
-
-#include "debug.h"
-
-EquipmentWindow *equipmentWindow = nullptr;
-EquipmentWindow *beingEquipmentWindow = nullptr;
-static const int BOX_COUNT = 27;
-StringIntMap EquipmentWindow::mSlotNames;
-
-EquipmentWindow::EquipmentWindow(Equipment *const equipment,
- Being *const being,
- const bool foring) :
- // TRANSLATORS: equipment window name
- Window(_("Equipment"), Modal_false, nullptr, "equipment.xml"),
- ActionListener(),
- mEquipment(equipment),
- mPlayerBox(new PlayerBox(this,
- "equipment_playerbox.xml",
- "equipment_selectedplayerbox.xml")),
- // TRANSLATORS: equipment window button
- mUnequip(new Button(this, _("Unequip"), "unequip", this)),
- mImageSet(nullptr),
- mBeing(being),
- mSlotBackground(),
- mSlotHighlightedBackground(),
- mVertexes(new ImageCollection),
- mPages(),
- mTabs(nullptr),
- mHighlightColor(getThemeColor(ThemeColorId::HIGHLIGHT)),
- mBorderColor(getThemeColor(ThemeColorId::BORDER)),
- mLabelsColor(getThemeColor(ThemeColorId::LABEL)),
- mLabelsColor2(getThemeColor(ThemeColorId::LABEL_OUTLINE)),
- mSelected(-1),
- mItemPadding(getOption("itemPadding")),
- mBoxSize(getOption("boxSize")),
- mButtonPadding(getOption("buttonPadding", 5)),
- mMinX(180),
- mMinY(345),
- mMaxX(0),
- mMaxY(0),
- mYPadding(0),
- mSelectedTab(0),
- mForing(foring),
- mHaveDefaultPage(false)
-{
- const int size = config.getIntValue("fontSize")
- + getOption("tabHeightAdjust", 16);
- mTabs = new TabStrip(this, "equipment", size);
- mTabs->addActionListener(this);
- mTabs->setActionEventId("tab_");
- mTabs->setSelectable(false);
-
- mYPadding = mTabs->getHeight() + getOption("tabPadding", 2);
-
- if (setupWindow != nullptr)
- setupWindow->registerWindowForReset(this);
-
- if (mBoxSize == 0)
- mBoxSize = 36;
-
- // Control that shows the Player
- mPlayerBox->setDimension(Rect(50, 80 + mYPadding, 74, 168));
- mPlayerBox->setPlayer(being);
- mPlayerBox->setSelectable(false);
-
- if (foring)
- setWindowName("Being equipment");
- else
- setWindowName("Equipment");
-
- setCloseButton(true);
- setSaveVisible(true);
- setStickyButtonLock(true);
-
- fillBoxes();
- recalcSize();
- updatePage();
- loadWindowState();
-}
-
-void EquipmentWindow::postInit()
-{
- Window::postInit();
- const Rect &area = getChildrenArea();
- mUnequip->setPosition(area.width - mUnequip->getWidth() - mButtonPadding,
- area.height - mUnequip->getHeight() - mButtonPadding);
- mUnequip->setEnabled(false);
-
- ImageRect rect;
- theme->loadRect(rect, "equipment_background.xml", "", 0, 1);
- mSlotBackground = rect.grid[0];
- mSlotHighlightedBackground = rect.grid[1];
- add(mTabs);
- add(mPlayerBox);
- add(mUnequip);
- enableVisibleSound(true);
- mPlayerBox->setActionEventId("playerbox");
- mPlayerBox->addActionListener(this);
-}
-
-EquipmentWindow::~EquipmentWindow()
-{
- if (this == beingEquipmentWindow)
- {
- if (mEquipment != nullptr)
- delete mEquipment->getBackend();
- delete2(mEquipment)
- }
- FOR_EACH (STD_VECTOR<EquipmentPage*>::iterator, it, mPages)
- {
- STD_VECTOR<EquipmentBox*> &boxes = (*it)->boxes;
- delete_all(boxes);
- boxes.clear();
- delete *it;
- }
- if (mImageSet != nullptr)
- {
- mImageSet->decRef();
- mImageSet = nullptr;
- }
- if (mSlotBackground != nullptr)
- mSlotBackground->decRef();
- if (mSlotHighlightedBackground != nullptr)
- mSlotHighlightedBackground->decRef();
- delete2(mVertexes);
-}
-
-void EquipmentWindow::draw(Graphics *const graphics)
-{
- BLOCK_START("EquipmentWindow::draw")
- // Draw window graphics
- Window::draw(graphics);
-
- int i = 0;
- Font *const font = getFont();
- const int fontHeight = font->getHeight();
- const STD_VECTOR<EquipmentBox*> &boxes = mPages[mSelectedTab]->boxes;
-
- if (mLastRedraw)
- {
- mVertexes->clear();
- FOR_EACH (STD_VECTOR<EquipmentBox*>::const_iterator, it, boxes)
- {
- const EquipmentBox *const box = *it;
- if (box == nullptr)
- {
- i ++;
- continue;
- }
- if (i == mSelected)
- {
- graphics->calcTileCollection(mVertexes,
- mSlotHighlightedBackground,
- box->x, box->y);
- }
- else
- {
- graphics->calcTileCollection(mVertexes,
- mSlotBackground,
- box->x, box->y);
- }
- i ++;
- }
- graphics->finalize(mVertexes);
- }
- graphics->drawTileCollection(mVertexes);
-
- if (mEquipment == nullptr)
- {
- BLOCK_END("EquipmentWindow::draw")
- return;
- }
-
- i = 0;
- const int projSlot = inventoryHandler->getProjectileSlot();
- for (STD_VECTOR<EquipmentBox*>::const_iterator it = boxes.begin(),
- it_end = boxes.end(); it != it_end; ++ it, ++ i)
- {
- const EquipmentBox *const box = *it;
- if (box == nullptr)
- continue;
- const Item *const item = mEquipment->getEquipment(i);
- if (item != nullptr)
- {
- // Draw Item.
- Image *const image = item->getImage();
- if (image != nullptr)
- {
- image->setAlpha(1.0F); // Ensure the image is drawn
- // with maximum opacity
- graphics->drawImage(image, box->x + mItemPadding,
- box->y + mItemPadding);
- if (i == projSlot)
- {
- const std::string str = toString(item->getQuantity());
- font->drawString(graphics,
- mLabelsColor,
- mLabelsColor2,
- str,
- box->x + (mBoxSize - font->getWidth(str)) / 2,
- box->y - fontHeight);
- }
- }
- }
- else if (box->image != nullptr)
- {
- graphics->drawImage(box->image,
- box->x + mItemPadding,
- box->y + mItemPadding);
- }
- }
- BLOCK_END("EquipmentWindow::draw")
-}
-
-void EquipmentWindow::safeDraw(Graphics *const graphics)
-{
- BLOCK_START("EquipmentWindow::draw")
- // Draw window graphics
- Window::safeDraw(graphics);
-
- int i = 0;
- Font *const font = getFont();
- const int fontHeight = font->getHeight();
- const STD_VECTOR<EquipmentBox*> &boxes = mPages[mSelectedTab]->boxes;
-
- for (STD_VECTOR<EquipmentBox*>::const_iterator it = boxes.begin(),
- it_end = boxes.end(); it != it_end; ++ it, ++ i)
- {
- const EquipmentBox *const box = *it;
- if (box == nullptr)
- continue;
- if (i == mSelected)
- {
- graphics->drawImage(mSlotHighlightedBackground,
- box->x, box->y);
- }
- else
- {
- graphics->drawImage(mSlotBackground, box->x, box->y);
- }
- }
-
- if (mEquipment == nullptr)
- {
- BLOCK_END("EquipmentWindow::draw")
- return;
- }
-
- i = 0;
- const int projSlot = inventoryHandler->getProjectileSlot();
- for (STD_VECTOR<EquipmentBox*>::const_iterator it = boxes.begin(),
- it_end = boxes.end(); it != it_end; ++ it, ++ i)
- {
- const EquipmentBox *const box = *it;
- if (box == nullptr)
- continue;
- const Item *const item = mEquipment->getEquipment(i);
- if (item != nullptr)
- {
- // Draw Item.
- Image *const image = item->getImage();
- if (image != nullptr)
- {
- image->setAlpha(1.0F); // Ensure the image is drawn
- // with maximum opacity
- graphics->drawImage(image, box->x + mItemPadding,
- box->y + mItemPadding);
- if (i == projSlot)
- {
- const std::string str = toString(item->getQuantity());
- font->drawString(graphics,
- mLabelsColor,
- mLabelsColor2,
- str,
- box->x + (mBoxSize - font->getWidth(str)) / 2,
- box->y - fontHeight);
- }
- }
- }
- else if (box->image != nullptr)
- {
- graphics->drawImage(box->image,
- box->x + mItemPadding,
- box->y + mItemPadding);
- }
- }
- BLOCK_END("EquipmentWindow::draw")
-}
-
-void EquipmentWindow::action(const ActionEvent &event)
-{
- const std::string &eventId = event.getId();
- if (eventId == "unequip")
- {
- if ((mEquipment == nullptr) || mSelected == -1)
- return;
-
- const Item *const item = mEquipment->getEquipment(mSelected);
- PlayerInfo::unequipItem(item, Sfx_true);
- setSelected(-1);
- }
- else if (eventId.find("tab_") == 0u)
- {
- Button *const button = dynamic_cast<Button*>(event.getSource());
- if (button == nullptr)
- return;
- mSelectedTab = button->getTag();
- updatePage();
- }
- else if (eventId == "playerbox")
- {
- const DragDropSourceT src = dragDrop.getSource();
- if (dragDrop.isEmpty() || (src != DragDropSource::Inventory
- && src != DragDropSource::Equipment))
- {
- return;
- }
- Inventory *const inventory = localPlayer != nullptr
- ? PlayerInfo::getInventory() : nullptr;
- if (inventory == nullptr)
- return;
- Item *const item = inventory->findItem(dragDrop.getItem(),
- dragDrop.getItemColor());
- if (item == nullptr)
- return;
-
- if (dragDrop.getSource() == DragDropSource::Inventory)
- {
- if (item->isEquipment() == Equipm_true)
- {
- if (item->isEquipped() == Equipped_false)
- PlayerInfo::equipItem(item, Sfx_true);
- }
- }
- }
-}
-
-void EquipmentWindow::updatePage()
-{
- EquipmentPage *const page = mPages[mSelectedTab];
- const Visible visible = fromBool(page->showPlayerBox, Visible);
- mPlayerBox->setVisible(visible);
- if (visible == Visible_true)
- {
- mPlayerBox->setDimension(Rect(page->x, page->y,
- page->width, page->height));
- }
- mRedraw = true;
-}
-
-const Item *EquipmentWindow::getItem(const int x, const int y) const
-{
- if (mEquipment == nullptr)
- return nullptr;
-
- int i = 0;
-
- STD_VECTOR<EquipmentBox*> &boxes = mPages[mSelectedTab]->boxes;
- for (STD_VECTOR<EquipmentBox*>::const_iterator it = boxes.begin(),
- it_end = boxes.end(); it != it_end; ++ it, ++ i)
- {
- const EquipmentBox *const box = *it;
- if (box == nullptr)
- continue;
- const Rect tRect(box->x, box->y, mBoxSize, mBoxSize);
-
- if (tRect.isPointInRect(x, y))
- return mEquipment->getEquipment(i);
- }
- return nullptr;
-}
-
-void EquipmentWindow::mousePressed(MouseEvent& event)
-{
- if (mEquipment == nullptr)
- {
- Window::mousePressed(event);
- return;
- }
-
- const int x = event.getX();
- const int y = event.getY();
-
- if (event.getButton() == MouseButton::LEFT)
- {
- if (mForing)
- {
- Window::mousePressed(event);
- return;
- }
- // Checks if any of the presses were in the equip boxes.
- int i = 0;
-
- bool inBox(false);
-
- STD_VECTOR<EquipmentBox*> &boxes = mPages[mSelectedTab]->boxes;
- for (STD_VECTOR<EquipmentBox*>::const_iterator it = boxes.begin(),
- it_end = boxes.end(); it != it_end; ++ it, ++ i)
- {
- const EquipmentBox *const box = *it;
- if (box == nullptr)
- continue;
- const Item *const item = mEquipment->getEquipment(i);
- const Rect tRect(box->x, box->y, mBoxSize, mBoxSize);
-
- if (tRect.isPointInRect(x, y))
- {
- inBox = true;
- if (item != nullptr)
- {
- event.consume();
- setSelected(i);
- dragDrop.dragItem(item, DragDropSource::Equipment);
- return;
- }
- }
- if (inBox)
- return;
- }
- }
- else if (event.getButton() == MouseButton::RIGHT)
- {
- if (const Item *const item = getItem(x, y))
- {
- if (itemPopup != nullptr)
- itemPopup->setVisible(Visible_false);
-
- /* Convert relative to the window coordinates to absolute screen
- * coordinates.
- */
- const int mx = x + getX();
- const int my = y + getY();
- if (popupMenu != nullptr)
- {
- event.consume();
- if (mForing)
- {
- popupMenu->showUndressPopup(mx, my, mBeing, item);
- }
- else
- {
- popupMenu->showPopup(this, mx, my, item,
- InventoryType::Inventory);
- }
- return;
- }
- }
- }
- Window::mousePressed(event);
-}
-
-void EquipmentWindow::mouseReleased(MouseEvent &event)
-{
- Window::mouseReleased(event);
- const DragDropSourceT src = dragDrop.getSource();
- if (dragDrop.isEmpty() || (src != DragDropSource::Inventory
- && src != DragDropSource::Equipment))
- {
- return;
- }
- Inventory *const inventory = localPlayer != nullptr
- ? PlayerInfo::getInventory() : nullptr;
- if (inventory == nullptr)
- return;
-
- Item *const item = inventory->findItem(dragDrop.getItem(),
- dragDrop.getItemColor());
- if (item == nullptr)
- return;
-
- if (dragDrop.getSource() == DragDropSource::Inventory)
- {
- if (item->isEquipment() == Equipm_true)
- {
- if (item->isEquipped() == Equipped_false)
- PlayerInfo::equipItem(item, Sfx_true);
- }
- }
- else if (dragDrop.getSource() == DragDropSource::Equipment)
- {
- if (item->isEquipment() == Equipm_true)
- {
- const int x = event.getX();
- const int y = event.getY();
- STD_VECTOR<EquipmentBox*> &boxes = mPages[mSelectedTab]->boxes;
- for (STD_VECTOR<EquipmentBox*>::const_iterator
- it = boxes.begin(), it_end = boxes.end();
- it != it_end; ++ it)
- {
- const EquipmentBox *const box = *it;
- if (box == nullptr)
- continue;
- const Rect tRect(box->x, box->y, mBoxSize, mBoxSize);
-
- if (tRect.isPointInRect(x, y))
- return;
- }
-
- if (item->isEquipped() == Equipped_true)
- PlayerInfo::unequipItem(item, Sfx_true);
- }
- }
- dragDrop.clear();
- dragDrop.deselect();
-}
-
-// Show ItemTooltip
-void EquipmentWindow::mouseMoved(MouseEvent &event)
-{
- Window::mouseMoved(event);
-
- if (itemPopup == nullptr)
- return;
-
- const int x = event.getX();
- const int y = event.getY();
-
- const Item *const item = getItem(x, y);
-
- if (item != nullptr)
- {
- itemPopup->setItem(item, false);
- itemPopup->position(x + getX(), y + getY());
- }
- else
- {
- itemPopup->setVisible(Visible_false);
- }
-}
-
-// Hide ItemTooltip
-void EquipmentWindow::mouseExited(MouseEvent &event A_UNUSED)
-{
- if (itemPopup != nullptr)
- itemPopup->setVisible(Visible_false);
-}
-
-void EquipmentWindow::setSelected(const int index)
-{
- mSelected = index;
- mRedraw = true;
- if (mUnequip != nullptr)
- mUnequip->setEnabled(mSelected != -1);
- if (itemPopup != nullptr)
- itemPopup->setVisible(Visible_false);
-}
-
-void EquipmentWindow::setBeing(Being *const being)
-{
- mPlayerBox->setPlayer(being);
- mBeing = being;
- if (mEquipment != nullptr)
- delete mEquipment->getBackend();
- delete mEquipment;
- if (being == nullptr)
- {
- mEquipment = nullptr;
- return;
- }
- mEquipment = being->getEquipment();
-}
-
-void EquipmentWindow::updateBeing(Being *const being)
-{
- if (being == mBeing)
- setBeing(being);
-}
-
-void EquipmentWindow::resetBeing(const Being *const being)
-{
- if (being == mBeing)
- setBeing(nullptr);
-}
-
-void EquipmentWindow::fillBoxes()
-{
- XML::Document *const doc = new XML::Document(
- paths.getStringValue("equipmentWindowFile"),
- UseVirtFs_true,
- SkipError_false);
- XmlNodeConstPtr root = doc->rootNode();
- if (root == nullptr)
- {
- delete doc;
- fillDefault();
- return;
- }
-
- if (mImageSet != nullptr)
- mImageSet->decRef();
-
- mImageSet = Theme::getImageSetFromTheme(XML::getProperty(
- root, "image", "equipmentbox.png"), 32, 32);
-
- for_each_xml_child_node(node, root)
- {
- if (xmlNameEqual(node, "page"))
- {
- loadPage(node);
- }
- }
- delete doc;
- if (reportTrue(mPages.empty()))
- fillDefault();
-}
-
-void EquipmentWindow::addDefaultPage()
-{
- if (!mHaveDefaultPage)
- {
- mHaveDefaultPage = true;
- // TRANSLATORS: equipment window tab
- addPage(_("default"));
- }
-}
-
-void EquipmentWindow::loadPage(XmlNodeConstPtr node)
-{
- if (node == nullptr)
- return;
- // TRANSLATORS: unknown equipment page name
- const std::string &name = XML::langProperty(node, "name", _("Unknown"));
- const int page = addPage(name);
- for_each_xml_child_node(childNode, node)
- {
- if (xmlNameEqual(childNode, "playerbox"))
- loadPlayerBox(childNode, page);
- else if (xmlNameEqual(childNode, "slot"))
- loadSlot(childNode, mImageSet, page);
- }
-}
-
-void EquipmentWindow::loadPlayerBox(XmlNodeConstPtr playerBoxNode,
- const int page)
-{
- EquipmentPage *const data = mPages[page];
- data->x = XML::getProperty(playerBoxNode, "x", 50);
- data->y = XML::getProperty(playerBoxNode, "y", 80) + mYPadding;
- data->width = XML::getProperty(playerBoxNode, "width", 74);
- data->height = XML::getProperty(playerBoxNode, "height", 168);
-}
-
-void EquipmentWindow::loadSlot(XmlNodeConstPtr slotNode,
- const ImageSet *const imageset,
- const int page)
-{
- if (imageset == nullptr)
- return;
- const int slot = parseSlotName(XML::getProperty(slotNode, "name", ""));
- if (slot < 0)
- return;
-
- const int x = XML::getProperty(slotNode, "x", 0) + getPadding();
- const int y = XML::getProperty(slotNode, "y", 0)
- + getTitleBarHeight() + mYPadding;
- const int imageIndex = XML::getProperty(slotNode, "image", -1);
- Image *image = nullptr;
-
- if (imageIndex >= 0 && imageIndex < CAST_S32(imageset->size()))
- image = imageset->get(imageIndex);
-
- STD_VECTOR<EquipmentBox*> &boxes = mPages[page]->boxes;
- if (boxes[slot] != nullptr)
- {
- EquipmentBox *const box = boxes[slot];
- box->x = x;
- box->y = y;
- box->image = image;
- }
- else
- {
- boxes[slot] = new EquipmentBox(x, y, image);
- }
- if (x < mMinX)
- mMinX = x;
- if (y < mMinY)
- mMinY = y;
- if (x + mBoxSize > mMaxX)
- mMaxX = x + mBoxSize;
- if (y + mBoxSize > mMaxY)
- mMaxY = y + mBoxSize;
-}
-
-void EquipmentWindow::prepareSlotNames()
-{
- mSlotNames.clear();
- XML::Document doc(paths.getStringValue("equipmentSlotsFile"),
- UseVirtFs_true,
- SkipError_false);
- XmlNodeConstPtrConst root = doc.rootNode();
- if (root == nullptr)
- return;
-
- for_each_xml_child_node(slotNode, root)
- {
- if (!xmlNameEqual(slotNode, "slot"))
- continue;
- const std::string name = XML::getProperty(slotNode, "name", "");
- if (name.empty())
- {
- reportAlways("Empty slot name detected.");
- continue;
- }
-
- const int slot = XML::getProperty(slotNode, "slot", -1);
- if (slot < 0 || slot >= BOX_COUNT)
- {
- reportAlways("Wrong slot id '%d' for slot with name '%s'",
- slot,
- name.c_str());
- continue;
- }
- mSlotNames[name] = slot;
- }
-}
-
-int EquipmentWindow::parseSlotName(const std::string &name)
-{
- StringIntMapCIter it = mSlotNames.find(name);
- if (it != mSlotNames.end())
- return (*it).second;
- return -1;
-}
-
-void EquipmentWindow::fillDefault()
-{
- if (mImageSet != nullptr)
- mImageSet->decRef();
-
- addDefaultPage();
- mImageSet = Theme::getImageSetFromTheme(
- "equipmentbox.png", 32, 32);
-
- addBox(0, 90, 40, 0); // torso
- addBox(1, 8, 78, 1); // gloves
- addBox(2, 70, 0, 2); // hat
- addBox(3, 50, 253, 3); // pants
- addBox(4, 90, 253, 4); // boots
- addBox(5, 8, 213, 5); // FREE
- addBox(6, 129, 213, 6); // wings
- addBox(7, 50, 40, 5); // scarf
- addBox(8, 8, 168, 7); // weapon
- addBox(9, 129, 168, 8); // shield
- addBox(10, 129, 78, 9); // ammo
- addBox(11, 8, 123, 5); // amulet
- addBox(12, 129, 123, 5); // ring
-}
-
-void EquipmentWindow::addBox(const int idx, int x, int y, const int imageIndex)
-{
- Image *image = nullptr;
-
- if ((mImageSet != nullptr) && imageIndex >= 0 && imageIndex
- < CAST_S32(mImageSet->size()))
- {
- image = mImageSet->get(imageIndex);
- }
-
- x += getPadding();
- y += getTitleBarHeight() + mYPadding;
- STD_VECTOR<EquipmentBox*> &boxes = mPages[0]->boxes;
- boxes[idx] = new EquipmentBox(x, y, image);
-
- if (x < mMinX)
- mMinX = x;
- if (y < mMinY)
- mMinY = y;
- if (x + mBoxSize > mMaxX)
- mMaxX = x + mBoxSize;
- if (y + mBoxSize > mMaxY)
- mMaxY = y + mBoxSize;
-}
-
-void EquipmentWindow::recalcSize()
-{
- mMaxX += mMinX;
- mMaxY += mMinY;
- mTabs->setWidth(mMaxX);
- mMaxY += mUnequip->getHeight() - mYPadding;
- setDefaultSize(mMaxX, mMaxY, ImagePosition::CENTER);
-}
-
-int EquipmentWindow::addPage(const std::string &name)
-{
- EquipmentPage *const page = new EquipmentPage;
- mPages.push_back(page);
- STD_VECTOR<EquipmentBox*> &boxes = page->boxes;
-
- boxes.reserve(BOX_COUNT);
- for (int f = 0; f < BOX_COUNT; f ++)
- boxes.push_back(nullptr);
-
- mTabs->addButton(name, name, false);
- return CAST_S32(mPages.size()) - 1;
-}
diff --git a/src/gui/windows/equipmentwindow.h b/src/gui/windows/equipmentwindow.h
deleted file mode 100644
index b36174095..000000000
--- a/src/gui/windows/equipmentwindow.h
+++ /dev/null
@@ -1,167 +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_WINDOWS_EQUIPMENTWINDOW_H
-#define GUI_WINDOWS_EQUIPMENTWINDOW_H
-
-#include "equipment.h"
-#include "localconsts.h"
-
-#include "gui/widgets/window.h"
-
-#include "utils/stringmap.h"
-#include "utils/xml.h"
-
-#include "listeners/actionlistener.h"
-
-class Being;
-class Button;
-class Image;
-class ImageSet;
-class Item;
-class PlayerBox;
-class TabStrip;
-
-struct EquipmentPage;
-
-/**
- * Equipment dialog.
- *
- * \ingroup Interface
- */
-class EquipmentWindow final : public Window,
- public ActionListener
-{
- public:
- /**
- * Constructor.
- */
- EquipmentWindow(Equipment *const equipment, Being *const being,
- const bool foring = false);
-
- A_DELETE_COPY(EquipmentWindow)
-
- /**
- * Destructor.
- */
- ~EquipmentWindow();
-
- void postInit() override final;
-
- /**
- * Draws the equipment window.
- */
- void draw(Graphics *const graphics) override final A_NONNULL(2);
-
- void safeDraw(Graphics *const graphics) override final A_NONNULL(2);
-
- void action(const ActionEvent &event) override final;
-
- void mousePressed(MouseEvent& event) override final;
-
- const Item* getEquipment(const int i) const A_WARN_UNUSED
- {
- return mEquipment != nullptr ?
- mEquipment->getEquipment(i) : nullptr;
- }
-
- void setBeing(Being *const being);
-
- void updateBeing(Being *const being);
-
- void resetBeing(const Being *const being);
-
- void mouseExited(MouseEvent &event) override final;
-
- void mouseMoved(MouseEvent &event) override final;
-
- void mouseReleased(MouseEvent &event) override final;
-
- void recalcSize();
-
- static void prepareSlotNames();
-
- private:
- const Item *getItem(const int x, const int y) const A_WARN_UNUSED;
-
- void setSelected(const int index);
-
- void fillBoxes();
-
- void fillDefault();
-
- void updatePage();
-
- int addPage(const std::string &name);
-
- void addDefaultPage();
-
- void addBox(const int idx, int x, int y, const int imageIndex);
-
- void loadWindow(XmlNodeConstPtrConst windowNode);
-
- void loadPage(XmlNodeConstPtr node);
-
- void loadPlayerBox(XmlNodeConstPtr playerBoxNode, const int page);
-
- void loadSlot(XmlNodeConstPtr slotNode,
- const ImageSet *const imageset,
- const int page);
-
- static int parseSlotName(const std::string &name) A_WARN_UNUSED;
-
- static StringIntMap mSlotNames;
-
- Equipment *mEquipment;
-
- PlayerBox *mPlayerBox A_NONNULLPOINTER;
- Button *mUnequip A_NONNULLPOINTER;
-
- ImageSet *mImageSet;
- Being *mBeing;
- Image *mSlotBackground;
- Image *mSlotHighlightedBackground;
- ImageCollection *mVertexes A_NONNULLPOINTER;
- STD_VECTOR<EquipmentPage*> mPages;
- TabStrip *mTabs;
- Color mHighlightColor;
- Color mBorderColor;
- Color mLabelsColor;
- Color mLabelsColor2;
- int mSelected; /**< Index of selected item. */
- int mItemPadding;
- int mBoxSize;
- int mButtonPadding;
- int mMinX;
- int mMinY;
- int mMaxX;
- int mMaxY;
- int mYPadding;
- int mSelectedTab;
- bool mForing;
- bool mHaveDefaultPage;
-};
-
-extern EquipmentWindow *equipmentWindow;
-extern EquipmentWindow *beingEquipmentWindow;
-
-#endif // GUI_WINDOWS_EQUIPMENTWINDOW_H
diff --git a/src/gui/windows/helpwindow.cpp b/src/gui/windows/helpwindow.cpp
deleted file mode 100644
index 1cfb30e2b..000000000
--- a/src/gui/windows/helpwindow.cpp
+++ /dev/null
@@ -1,220 +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 "gui/windows/helpwindow.h"
-
-#include "configuration.h"
-
-#include "enums/gui/layouttype.h"
-
-#include "fs/paths.h"
-
-#include "fs/virtfs/tools.h"
-
-#include "gui/gui.h"
-
-#include "gui/windows/setupwindow.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/staticbrowserbox.h"
-#include "gui/widgets/layout.h"
-#include "gui/widgets/scrollarea.h"
-
-#include "input/inputmanager.h"
-
-#include "utils/foreach.h"
-#include "utils/gettext.h"
-#include "utils/process.h"
-
-#include "utils/translation/podict.h"
-#include "utils/translation/translationmanager.h"
-
-#include "debug.h"
-
-HelpWindow *helpWindow = nullptr;
-
-HelpWindow::HelpWindow() :
- // TRANSLATORS: help window name
- Window(_("Help"), Modal_false, nullptr, "help.xml"),
- LinkHandler(),
- ActionListener(),
- // TRANSLATORS: help window. button.
- mDYKButton(new Button(this, _("Did you know..."), "DYK", this)),
- mBrowserBox(new StaticBrowserBox(this, Opaque_true,
- "browserbox.xml")),
- mScrollArea(new ScrollArea(this, mBrowserBox,
- Opaque_true, "help_background.xml")),
- mTagFileMap()
-{
- setMinWidth(300);
- setMinHeight(220);
- setContentSize(455, 350);
- setWindowName("Help");
- setCloseButton(true);
- setResizable(true);
- setStickyButtonLock(true);
-
- if (setupWindow != nullptr)
- setupWindow->registerWindowForReset(this);
-
- setDefaultSize(500, 400, ImagePosition::CENTER);
-
- mBrowserBox->setOpaque(Opaque_false);
-
- mBrowserBox->setLinkHandler(this);
- if (gui != nullptr)
- mBrowserBox->setFont(gui->getHelpFont());
- mBrowserBox->setProcessVars(true);
- mBrowserBox->setEnableImages(true);
- mBrowserBox->setEnableKeys(true);
- mBrowserBox->setEnableTabs(true);
-
- place(4, 3, mDYKButton);
- place(0, 0, mScrollArea, 5, 3).setPadding(3);
-
- Layout &layout = getLayout();
- layout.setRowHeight(0, LayoutType::SET);
-
- loadWindowState();
- loadTags();
- enableVisibleSound(true);
- widgetResized(Event(nullptr));
-}
-
-void HelpWindow::action(const ActionEvent &event)
-{
- if (event.getId() == "DYK")
- inputManager.executeAction(InputAction::WINDOW_DIDYOUKNOW);
-}
-
-void HelpWindow::handleLink(const std::string &link,
- MouseEvent *const event A_UNUSED)
-{
- if (!strStartWith(link, "http://") && !strStartWith(link, "https://"))
- {
- // need use separate variable
- const std::string helpFile = link;
- loadHelp(helpFile);
- }
- else
- {
- openBrowser(link);
- }
-}
-
-void HelpWindow::loadHelp(const std::string &helpFile)
-{
- if (!checkPath(helpFile))
- return;
- mBrowserBox->clearRows();
- loadFile("header");
- loadFile(helpFile);
- loadFile("footer");
- mScrollArea->setVerticalScrollAmount(0);
- mBrowserBox->updateHeight();
- setVisible(Visible_true);
-}
-
-void HelpWindow::loadHelpSimple(const std::string &helpFile)
-{
- if (!checkPath(helpFile))
- return;
- mBrowserBox->clearRows();
- loadFile(helpFile);
- mScrollArea->setVerticalScrollAmount(0);
- mBrowserBox->updateHeight();
- setVisible(Visible_true);
-}
-
-void HelpWindow::loadFile(std::string file)
-{
- trim(file);
- std::string helpPath = branding.getStringValue("helpPath");
- if (helpPath.empty())
- helpPath = paths.getStringValue("help");
-
- StringVect lines;
- TranslationManager::translateFile(pathJoin(helpPath, file).append(".txt"),
- translator, lines);
-
- for (size_t i = 0, sz = lines.size(); i < sz; ++i)
- mBrowserBox->addRow(lines[i]);
-}
-
-void HelpWindow::loadTags()
-{
- std::string helpPath = branding.getStringValue("tagsPath");
- if (helpPath.empty())
- helpPath = paths.getStringValue("tags");
-
- StringVect filesVect;
- VirtFs::getFilesInDir(helpPath, filesVect, ".idx");
- FOR_EACH (StringVectCIter, itVect, filesVect)
- {
- StringVect lines;
- VirtFs::loadTextFile(*itVect, lines);
- FOR_EACH (StringVectCIter, it, lines)
- {
- const std::string &str = *it;
- const size_t idx = str.find('|');
- if (idx != std::string::npos)
- mTagFileMap[str.substr(idx + 1)].insert(str.substr(0, idx));
- }
- }
-}
-
-void HelpWindow::search(const std::string &text0)
-{
- std::string text = text0;
- trim(text);
- toLower(text);
- if (mTagFileMap.find(text) == mTagFileMap.end())
- {
- loadHelp("searchnotfound");
- }
- else
- {
- const HelpNames &names = mTagFileMap[text];
- if (names.size() == 1)
- {
- loadHelp(*names.begin());
- }
- else
- {
- if (translator == nullptr)
- return;
- mBrowserBox->clearRows();
- loadFile("header");
- loadFile("searchmany");
- FOR_EACH (HelpNamesCIter, it, names)
- {
- const char *const str = (*it).c_str();
- mBrowserBox->addRow(strprintf(" -> @@%s|%s@@", str,
- translator->getChar(str)));
- }
- loadFile("footer");
- mScrollArea->setVerticalScrollAmount(0);
- mBrowserBox->updateHeight();
- setVisible(Visible_true);
- }
- }
-}
diff --git a/src/gui/windows/helpwindow.h b/src/gui/windows/helpwindow.h
deleted file mode 100644
index 2fb2407d9..000000000
--- a/src/gui/windows/helpwindow.h
+++ /dev/null
@@ -1,92 +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_WINDOWS_HELPWINDOW_H
-#define GUI_WINDOWS_HELPWINDOW_H
-
-#include "gui/widgets/linkhandler.h"
-#include "gui/widgets/window.h"
-
-#include "listeners/actionlistener.h"
-
-#include "localconsts.h"
-
-class Button;
-class ScrollArea;
-class StaticBrowserBox;
-
-typedef std::set<std::string> HelpNames;
-typedef HelpNames::const_iterator HelpNamesCIter;
-typedef std::map<std::string, HelpNames> HelpTagsMap;
-
-/**
- * The help window.
- */
-class HelpWindow final : public Window,
- public LinkHandler,
- public ActionListener
-{
- public:
- /**
- * Constructor.
- */
- HelpWindow();
-
- A_DELETE_COPY(HelpWindow)
-
- /**
- * Called when receiving actions from the widgets.
- */
- void action(const ActionEvent &event) override final;
-
- /**
- * Handles link action.
- */
- void handleLink(const std::string &link,
- MouseEvent *const event A_UNUSED) override final;
-
- /**
- * Loads help in the dialog.
- */
- void loadHelp(const std::string &helpFile);
-
- void loadHelpSimple(const std::string &helpFile);
-
- /**
- * Seach for given text in tags.
- */
- void search(const std::string &text);
-
- private:
- void loadTags();
-
- void loadFile(std::string file);
-
- Button *mDYKButton A_NONNULLPOINTER;
- StaticBrowserBox *mBrowserBox A_NONNULLPOINTER;
- ScrollArea *mScrollArea A_NONNULLPOINTER;
- HelpTagsMap mTagFileMap;
-};
-
-extern HelpWindow *helpWindow;
-
-#endif // GUI_WINDOWS_HELPWINDOW_H
diff --git a/src/gui/windows/insertcarddialog.cpp b/src/gui/windows/insertcarddialog.cpp
deleted file mode 100644
index 590df6aba..000000000
--- a/src/gui/windows/insertcarddialog.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 "gui/windows/insertcarddialog.h"
-
-#include "gui/models/shopitems.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/shoplistbox.h"
-
-#include "net/inventoryhandler.h"
-
-#include "utils/gettext.h"
-#include "utils/stringutils.h"
-
-#include "resources/item/shopitem.h"
-
-#include "debug.h"
-
-InsertCardDialog::InsertCardDialog(const int itemIndex,
- const Item *const item) :
- SellDialog(IsSell_false, Advanced_false),
- mItemIndex(itemIndex)
-{
- // TRANSLATORS: insert card dialog name
- setWindowName(_("Insert card"));
- if (item != nullptr)
- {
- // TRANSLATORS: insert card dialog name
- setCaption(strprintf(_("Insert card %s"),
- item->getName().c_str()));
- }
- else
- {
- // TRANSLATORS: insert card dialog name
- setCaption(strprintf(_("Insert card %s"),
- ""));
- }
-}
-
-void InsertCardDialog::initButtons()
-{
- // TRANSLATORS: insert card dialog button
- mSellButton->setCaption(_("Insert"));
- mSellButton->adjustSize();
- mShopItems->setMergeDuplicates(false);
-}
-
-void InsertCardDialog::sellAction(const ActionEvent &event A_UNUSED)
-{
- if (mAmountItems <= 0 || mAmountItems > mMaxItems)
- return;
-
- const int selectedItem = mShopItemList->getSelected();
- const ShopItem *const item = mShopItems->at(selectedItem);
- if (item == nullptr)
- return;
- inventoryHandler->insertCard(mItemIndex, item->getInvIndex());
- scheduleDelete();
-}
diff --git a/src/gui/windows/insertcarddialog.h b/src/gui/windows/insertcarddialog.h
deleted file mode 100644
index ba46022a2..000000000
--- a/src/gui/windows/insertcarddialog.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 GUI_WINDOWS_INSERTCARDDIALOG_H
-#define GUI_WINDOWS_INSERTCARDDIALOG_H
-
-#include "gui/widgets/selldialog.h"
-
-class InsertCardDialog final : public SellDialog
-{
- public:
- /**
- * Constructor.
- *
- * @see Window::Window
- */
- InsertCardDialog(const int itemIndex,
- const Item *const item);
-
- A_DELETE_COPY(InsertCardDialog)
-
- protected:
- void initButtons() override final;
- void sellAction(const ActionEvent &event) override final;
-
- private:
- int mItemIndex;
-};
-
-#endif // GUI_WINDOWS_INSERTCARDDIALOG_H
diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp
deleted file mode 100644
index f973f250f..000000000
--- a/src/gui/windows/inventorywindow.cpp
+++ /dev/null
@@ -1,1083 +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 "gui/windows/inventorywindow.h"
-
-#include "configuration.h"
-
-#include "being/playerinfo.h"
-
-#include "enums/gui/layouttype.h"
-
-#include "input/inputmanager.h"
-
-#include "gui/gui.h"
-
-#include "gui/fonts/font.h"
-
-#include "gui/models/sortlistmodelinv.h"
-
-#include "gui/popups/itempopup.h"
-#include "gui/popups/popupmenu.h"
-#include "gui/popups/textpopup.h"
-
-#include "gui/windows/confirmdialog.h"
-#include "gui/windows/itemamountwindow.h"
-#include "gui/windows/npcdialog.h"
-#include "gui/windows/setupwindow.h"
-#include "gui/windows/tradewindow.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/createwidget.h"
-#include "gui/widgets/containerplacer.h"
-#include "gui/widgets/dropdown.h"
-#include "gui/widgets/itemcontainer.h"
-#include "gui/widgets/layout.h"
-#include "gui/widgets/progressbar.h"
-#include "gui/widgets/scrollarea.h"
-#include "gui/widgets/tabstrip.h"
-#include "gui/widgets/textfield.h"
-#include "gui/widgets/windowcontainer.h"
-
-#include "listeners/insertcardlistener.h"
-
-#include "net/npchandler.h"
-
-#include "resources/iteminfo.h"
-
-#include "resources/db/unitsdb.h"
-
-#include "resources/item/item.h"
-
-#include "utils/delete2.h"
-#include "utils/foreach.h"
-
-#include "debug.h"
-
-InventoryWindow *inventoryWindow = nullptr;
-InventoryWindow *storageWindow = nullptr;
-InventoryWindow *cartWindow = nullptr;
-InventoryWindow::WindowList InventoryWindow::invInstances;
-InsertCardListener insertCardListener;
-
-InventoryWindow::InventoryWindow(Inventory *const inventory) :
- Window("Inventory", Modal_false, nullptr, "inventory.xml"),
- ActionListener(),
- KeyListener(),
- SelectionListener(),
- InventoryListener(),
- AttributeListener(),
- mInventory(inventory),
- mItems(new ItemContainer(this, mInventory)),
- mUseButton(nullptr),
- mDropButton(nullptr),
- mOutfitButton(nullptr),
- mShopButton(nullptr),
- mCartButton(nullptr),
- mEquipmentButton(nullptr),
- mStoreButton(nullptr),
- mRetrieveButton(nullptr),
- mInvCloseButton(nullptr),
- mWeightBar(nullptr),
- mSlotsBar(new ProgressBar(this, 0.0F, 100, 0,
- ProgressColorId::PROG_INVY_SLOTS,
- "slotsprogressbar.xml", "slotsprogressbar_fill.xml")),
- mFilter(nullptr),
- mSortModel(new SortListModelInv),
- mSortDropDown(new DropDown(this, mSortModel, false,
- Modal_false, this, "sort")),
- mNameFilter(new TextField(this, "", LoseFocusOnTab_true,
- this, "namefilter", true)),
- mSortDropDownCell(nullptr),
- mNameFilterCell(nullptr),
- mFilterCell(nullptr),
- mSlotsBarCell(nullptr),
- mSplit(false),
- mCompactMode(false)
-{
- mSlotsBar->setColor(getThemeColor(ThemeColorId::SLOTS_BAR),
- getThemeColor(ThemeColorId::SLOTS_BAR_OUTLINE));
-
- if (inventory != nullptr)
- {
- setCaption(gettext(inventory->getName().c_str()));
- setWindowName(inventory->getName());
- switch (inventory->getType())
- {
- case InventoryType::Inventory:
- case InventoryType::Trade:
- case InventoryType::Npc:
- case InventoryType::Vending:
- case InventoryType::MailEdit:
- case InventoryType::MailView:
- case InventoryType::Craft:
- case InventoryType::TypeEnd:
- default:
- mSortDropDown->setSelected(config.getIntValue(
- "inventorySortOrder"));
- break;
- case InventoryType::Storage:
- mSortDropDown->setSelected(config.getIntValue(
- "storageSortOrder"));
- break;
- case InventoryType::Cart:
- mSortDropDown->setSelected(config.getIntValue(
- "cartSortOrder"));
- break;
- };
- }
- else
- {
- // TRANSLATORS: inventory window name
- setCaption(_("Inventory"));
- setWindowName("Inventory");
- mSortDropDown->setSelected(0);
- }
-
- if ((setupWindow != nullptr) &&
- (inventory != nullptr) &&
- inventory->getType() != InventoryType::Storage)
- {
- setupWindow->registerWindowForReset(this);
- }
-
- setResizable(true);
- setCloseButton(true);
- setSaveVisible(true);
- setStickyButtonLock(true);
-
- if (mainGraphics->mWidth > 600)
- setDefaultSize(450, 310, ImagePosition::CENTER);
- else
- setDefaultSize(387, 307, ImagePosition::CENTER);
- setMinWidth(310);
- setMinHeight(179);
- addKeyListener(this);
-
- mItems->addSelectionListener(this);
-
- const int size = config.getIntValue("fontSize");
- mFilter = new TabStrip(this, "filter_" + getWindowName(), size + 16);
- mFilter->addActionListener(this);
- mFilter->setActionEventId("tag_");
- mFilter->setSelectable(false);
-
- StringVect tags = ItemDB::getTags();
- const size_t sz = tags.size();
- for (size_t f = 0; f < sz; f ++)
- mFilter->addButton(tags[f], tags[f], false);
-
- if (mInventory == nullptr)
- {
- invInstances.push_back(this);
- return;
- }
-
- ScrollArea *const invenScroll = new ScrollArea(this, mItems,
- fromBool(getOptionBool("showbackground"), Opaque),
- "inventory_background.xml");
- invenScroll->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
-
- switch (mInventory->getType())
- {
- case InventoryType::Inventory:
- {
- // TRANSLATORS: inventory button
- const std::string equip = _("Equip");
- // TRANSLATORS: inventory button
- const std::string use = _("Use");
- // TRANSLATORS: inventory button
- const std::string unequip = _("Unequip");
-
- std::string longestUseString = getFont()->getWidth(equip) >
- getFont()->getWidth(use) ? equip : use;
-
- if (getFont()->getWidth(longestUseString) <
- getFont()->getWidth(unequip))
- {
- longestUseString = unequip;
- }
-
- mUseButton = new Button(this, longestUseString, "use", this);
- // TRANSLATORS: inventory button
- mDropButton = new Button(this, _("Drop..."), "drop", this);
- // TRANSLATORS: inventory outfits button
- mOutfitButton = new Button(this, _("O"), "outfit", this);
- // TRANSLATORS: inventory cart button
- mCartButton = new Button(this, _("C"), "cart", this);
- // TRANSLATORS: inventory shop button
- mShopButton = new Button(this, _("S"), "shop", this);
- // TRANSLATORS: inventory equipment button
- mEquipmentButton = new Button(this, _("E"), "equipment", this);
- mWeightBar = new ProgressBar(this, 0.0F, 100, 0,
- ProgressColorId::PROG_WEIGHT,
- "weightprogressbar.xml", "weightprogressbar_fill.xml");
- mWeightBar->setColor(getThemeColor(ThemeColorId::WEIGHT_BAR),
- getThemeColor(ThemeColorId::WEIGHT_BAR_OUTLINE));
-
- // TRANSLATORS: outfits button tooltip
- mOutfitButton->setDescription(_("Outfits"));
- // TRANSLATORS: cart button tooltip
- mCartButton->setDescription(_("Cart"));
- // TRANSLATORS: shop button tooltip
- mShopButton->setDescription(_("Shop"));
- // TRANSLATORS: equipment button tooltip
- mEquipmentButton->setDescription(_("Equipment"));
-
- place(0, 0, mWeightBar, 4);
- mSlotsBarCell = &place(4, 0, mSlotsBar, 4);
- mSortDropDownCell = &place(8, 0, mSortDropDown, 3);
-
- mFilterCell = &place(0, 1, mFilter, 10).setPadding(3);
- mNameFilterCell = &place(8, 1, mNameFilter, 3);
-
- place(0, 2, invenScroll, 11).setPadding(3);
- place(0, 3, mUseButton);
- place(1, 3, mDropButton);
- ContainerPlacer placer = getPlacer(10, 3);
- placer(0, 0, mShopButton);
- placer(1, 0, mOutfitButton);
- placer(2, 0, mCartButton);
- placer(3, 0, mEquipmentButton);
-
- updateWeight();
- break;
- }
-
- case InventoryType::Storage:
- {
- // TRANSLATORS: storage button
- mStoreButton = new Button(this, _("Store"), "store", this);
- // TRANSLATORS: storage button
- mRetrieveButton = new Button(this, _("Retrieve"),
- "retrieve", this);
- // TRANSLATORS: storage button
- mInvCloseButton = new Button(this, _("Close"), "close", this);
-
- mSlotsBarCell = &place(0, 0, mSlotsBar, 6);
- mSortDropDownCell = &place(6, 0, mSortDropDown, 1);
-
- mFilterCell = &place(0, 1, mFilter, 7).setPadding(3);
- mNameFilterCell = &place(6, 1, mNameFilter, 1);
-
- place(0, 2, invenScroll, 7, 4);
- place(0, 6, mStoreButton);
- place(1, 6, mRetrieveButton);
- place(6, 6, mInvCloseButton);
- break;
- }
-
- case InventoryType::Cart:
- {
- // TRANSLATORS: storage button
- mStoreButton = new Button(this, _("Store"), "store", this);
- // TRANSLATORS: storage button
- mRetrieveButton = new Button(this, _("Retrieve"),
- "retrieve", this);
- // TRANSLATORS: storage button
- mInvCloseButton = new Button(this, _("Close"), "close", this);
-
- mWeightBar = new ProgressBar(this, 0.0F, 100, 0,
- ProgressColorId::PROG_WEIGHT,
- "weightprogressbar.xml", "weightprogressbar_fill.xml");
- mWeightBar->setColor(getThemeColor(ThemeColorId::WEIGHT_BAR),
- getThemeColor(ThemeColorId::WEIGHT_BAR_OUTLINE));
-
- mSlotsBarCell = &place(3, 0, mSlotsBar, 3);
- mSortDropDownCell = &place(6, 0, mSortDropDown, 1);
-
- mFilterCell = &place(0, 1, mFilter, 7).setPadding(3);
- mNameFilterCell = &place(6, 1, mNameFilter, 1);
-
- place(0, 0, mWeightBar, 3);
- place(0, 2, invenScroll, 7, 4);
- place(0, 6, mStoreButton);
- place(1, 6, mRetrieveButton);
- place(6, 6, mInvCloseButton);
- break;
- }
-
- default:
- case InventoryType::Trade:
- case InventoryType::Npc:
- case InventoryType::Vending:
- case InventoryType::MailEdit:
- case InventoryType::MailView:
- case InventoryType::Craft:
- case InventoryType::TypeEnd:
- break;
- };
-
- Layout &layout = getLayout();
- layout.setRowHeight(2, LayoutType::SET);
-
- mInventory->addInventoyListener(this);
-
- invInstances.push_back(this);
-
- if (inventory->isMainInventory())
- {
- updateDropButton();
- }
- else
- {
- if (!invInstances.empty())
- invInstances.front()->updateDropButton();
- }
-
- loadWindowState();
- enableVisibleSound(true);
-}
-
-void InventoryWindow::postInit()
-{
- Window::postInit();
- slotsChanged(mInventory);
-
- mItems->setSortType(mSortDropDown->getSelected());
- widgetResized(Event(nullptr));
- if (mInventory != nullptr &&
- mInventory->getType() == InventoryType::Storage)
- {
- setVisible(Visible_true);
- }
-}
-
-InventoryWindow::~InventoryWindow()
-{
- invInstances.remove(this);
- if (mInventory != nullptr)
- mInventory->removeInventoyListener(this);
- if (!invInstances.empty())
- invInstances.front()->updateDropButton();
-
- mSortDropDown->hideDrop(false);
- delete2(mSortModel);
-}
-
-void InventoryWindow::storeSortOrder() const
-{
- if (mInventory != nullptr)
- {
- switch (mInventory->getType())
- {
- case InventoryType::Inventory:
- case InventoryType::Trade:
- case InventoryType::Npc:
- case InventoryType::Vending:
- case InventoryType::MailEdit:
- case InventoryType::MailView:
- case InventoryType::Craft:
- case InventoryType::TypeEnd:
- default:
- config.setValue("inventorySortOrder",
- mSortDropDown->getSelected());
- break;
- case InventoryType::Storage:
- config.setValue("storageSortOrder",
- mSortDropDown->getSelected());
- break;
- case InventoryType::Cart:
- config.setValue("cartSortOrder",
- mSortDropDown->getSelected());
- break;
- };
- }
-}
-
-void InventoryWindow::action(const ActionEvent &event)
-{
- const std::string &eventId = event.getId();
- if (eventId == "outfit")
- {
- inputManager.executeAction(InputAction::WINDOW_OUTFIT);
- }
- else if (eventId == "shop")
- {
- inputManager.executeAction(InputAction::WINDOW_SHOP);
- }
- else if (eventId == "equipment")
- {
- inputManager.executeAction(InputAction::WINDOW_EQUIPMENT);
- }
- else if (eventId == "cart")
- {
- inputManager.executeAction(InputAction::WINDOW_CART);
- }
- else if (eventId == "close")
- {
- close();
- }
- else if (eventId == "store")
- {
- if (inventoryWindow == nullptr || !inventoryWindow->isWindowVisible())
- return;
-
- Item *const item = inventoryWindow->getSelectedItem();
-
- if (item == nullptr)
- return;
-
- if (storageWindow != nullptr)
- {
- ItemAmountWindow::showWindow(ItemAmountWindowUsage::StoreAdd,
- this, item);
- }
- else if ((cartWindow != nullptr) && cartWindow->isWindowVisible())
- {
- ItemAmountWindow::showWindow(ItemAmountWindowUsage::CartAdd,
- this, item);
- }
- }
- else if (eventId == "sort")
- {
- mItems->setSortType(mSortDropDown->getSelected());
- storeSortOrder();
- return;
- }
- else if (eventId == "namefilter")
- {
- mItems->setName(mNameFilter->getText());
- mItems->updateMatrix();
- }
- else if (eventId.find("tag_") == 0u)
- {
- std::string tagName = event.getId().substr(4);
- mItems->setFilter(ItemDB::getTagId(tagName));
- return;
- }
-
- Item *const item = mItems->getSelectedItem();
-
- if (item == nullptr)
- return;
-
- if (eventId == "use")
- {
- PlayerInfo::useEquipItem(item, 0, Sfx_true);
- }
- if (eventId == "equip")
- {
- PlayerInfo::useEquipItem2(item, 0, Sfx_true);
- }
- else if (eventId == "drop")
- {
- if (isStorageActive())
- {
- inventoryHandler->moveItem2(InventoryType::Inventory,
- item->getInvIndex(),
- item->getQuantity(),
- InventoryType::Storage);
- }
- else if ((cartWindow != nullptr) && cartWindow->isWindowVisible())
- {
- inventoryHandler->moveItem2(InventoryType::Inventory,
- item->getInvIndex(),
- item->getQuantity(),
- InventoryType::Cart);
- }
- else
- {
- if (PlayerInfo::isItemProtected(item->getId()))
- return;
-
- if (inputManager.isActionActive(InputAction::STOP_ATTACK))
- {
- PlayerInfo::dropItem(item, item->getQuantity(), Sfx_true);
- }
- else
- {
- ItemAmountWindow::showWindow(ItemAmountWindowUsage::ItemDrop,
- this, item);
- }
- }
- }
- else if (eventId == "split")
- {
- ItemAmountWindow::showWindow(ItemAmountWindowUsage::ItemSplit,
- this, item,
- (item->getQuantity() - 1));
- }
- else if (eventId == "retrieve")
- {
- if (storageWindow != nullptr)
- {
- ItemAmountWindow::showWindow(ItemAmountWindowUsage::StoreRemove,
- this, item);
- }
- else if ((cartWindow != nullptr) && cartWindow->isWindowVisible())
- {
- ItemAmountWindow::showWindow(ItemAmountWindowUsage::CartRemove,
- this, item);
- }
- }
-}
-
-Item *InventoryWindow::getSelectedItem() const
-{
- return mItems->getSelectedItem();
-}
-
-void InventoryWindow::unselectItem()
-{
- mItems->selectNone();
-}
-
-void InventoryWindow::widgetHidden(const Event &event)
-{
- Window::widgetHidden(event);
- if (itemPopup != nullptr)
- itemPopup->setVisible(Visible_false);
-}
-
-void InventoryWindow::mouseClicked(MouseEvent &event)
-{
- Window::mouseClicked(event);
-
- const int clicks = event.getClickCount();
-
- if (clicks == 2 && (gui != nullptr))
- gui->resetClickCount();
-
- const bool mod = (isStorageActive() &&
- inputManager.isActionActive(InputAction::STOP_ATTACK));
-
- const bool mod2 = (tradeWindow != nullptr &&
- tradeWindow->isWindowVisible() &&
- inputManager.isActionActive(InputAction::STOP_ATTACK));
-
- if (mInventory != nullptr)
- {
- if (!mod && !mod2 && event.getButton() == MouseButton::RIGHT)
- {
- Item *const item = mItems->getSelectedItem();
-
- if (item == nullptr)
- return;
-
- /* Convert relative to the window coordinates to absolute screen
- * coordinates.
- */
- const int mx = event.getX() + getX();
- const int my = event.getY() + getY();
-
- if (popupMenu != nullptr)
- {
- popupMenu->showPopup(this,
- mx, my,
- item,
- mInventory->getType());
- }
- }
- }
- else
- {
- return;
- }
-
- if (event.getButton() == MouseButton::LEFT ||
- event.getButton() == MouseButton::RIGHT)
- {
- Item *const item = mItems->getSelectedItem();
-
- if (item == nullptr)
- return;
-
- if (mod)
- {
- if (mInventory->isMainInventory())
- {
- if (event.getButton() == MouseButton::RIGHT)
- {
- ItemAmountWindow::showWindow(
- ItemAmountWindowUsage::StoreAdd,
- inventoryWindow,
- item);
- }
- else
- {
- inventoryHandler->moveItem2(InventoryType::Inventory,
- item->getInvIndex(),
- item->getQuantity(),
- InventoryType::Storage);
- }
- }
- else
- {
- if (event.getButton() == MouseButton::RIGHT)
- {
- ItemAmountWindow::showWindow(
- ItemAmountWindowUsage::StoreRemove,
- inventoryWindow,
- item);
- }
- else
- {
- inventoryHandler->moveItem2(InventoryType::Storage,
- item->getInvIndex(),
- item->getQuantity(),
- InventoryType::Inventory);
- }
- }
- }
- else if (mod2 && mInventory->isMainInventory())
- {
- if (PlayerInfo::isItemProtected(item->getId()))
- return;
- if (event.getButton() == MouseButton::RIGHT)
- {
- ItemAmountWindow::showWindow(ItemAmountWindowUsage::TradeAdd,
- tradeWindow, item);
- }
- else
- {
- if (tradeWindow != nullptr)
- tradeWindow->tradeItem(item, item->getQuantity(), true);
- }
- }
- else if (clicks == 2)
- {
- if (mInventory->isMainInventory())
- {
- if (isStorageActive())
- {
- ItemAmountWindow::showWindow(
- ItemAmountWindowUsage::StoreAdd,
- inventoryWindow, item);
- }
- else if (tradeWindow != nullptr &&
- tradeWindow->isWindowVisible())
- {
- if (PlayerInfo::isItemProtected(item->getId()))
- return;
- ItemAmountWindow::showWindow(
- ItemAmountWindowUsage::TradeAdd,
- tradeWindow, item);
- }
- else
- {
- PlayerInfo::useEquipItem(item, 0, Sfx_true);
- }
- }
- else
- {
- if (isStorageActive())
- {
- ItemAmountWindow::showWindow(
- ItemAmountWindowUsage::StoreRemove,
- inventoryWindow, item);
- }
- }
- }
- }
-}
-
-void InventoryWindow::mouseMoved(MouseEvent &event)
-{
- Window::mouseMoved(event);
- if (textPopup == nullptr)
- return;
-
- const Widget *const src = event.getSource();
- if (src == nullptr)
- {
- textPopup->hide();
- return;
- }
- const int x = event.getX();
- const int y = event.getY();
- const Rect &rect = mDimension;
- if (src == mSlotsBar || src == mWeightBar)
- {
- // TRANSLATORS: money label
- textPopup->show(rect.x + x, rect.y + y, strprintf(_("Money: %s"),
- UnitsDb::formatCurrency(PlayerInfo::getAttribute(
- Attributes::MONEY)).c_str()));
- }
- else
- {
- const Button *const btn = dynamic_cast<const Button *>(src);
- if (btn == nullptr)
- {
- textPopup->hide();
- return;
- }
- const std::string text = btn->getDescription();
- if (!text.empty())
- textPopup->show(x + rect.x, y + rect.y, text);
- }
-}
-
-void InventoryWindow::mouseExited(MouseEvent &event A_UNUSED)
-{
- textPopup->hide();
-}
-
-void InventoryWindow::keyPressed(KeyEvent &event)
-{
- if (event.getActionId() == InputAction::GUI_MOD)
- mSplit = true;
-}
-
-void InventoryWindow::keyReleased(KeyEvent &event)
-{
- if (event.getActionId() == InputAction::GUI_MOD)
- mSplit = false;
-}
-
-void InventoryWindow::valueChanged(const SelectionEvent &event A_UNUSED)
-{
- if ((mInventory == nullptr) || !mInventory->isMainInventory())
- return;
-
- Item *const item = mItems->getSelectedItem();
-
- if (mSplit && (item != nullptr) && inventoryHandler->
- canSplit(mItems->getSelectedItem()))
- {
- ItemAmountWindow::showWindow(ItemAmountWindowUsage::ItemSplit,
- this, item, item->getQuantity() - 1);
- }
- updateButtons(item);
-}
-
-void InventoryWindow::updateButtons(const Item *item)
-{
- if ((mInventory == nullptr) || !mInventory->isMainInventory())
- return;
-
- const Item *const selectedItem = mItems->getSelectedItem();
- if ((item != nullptr) && selectedItem != item)
- return;
-
- if (item == nullptr)
- item = selectedItem;
-
- if ((item == nullptr) || item->getQuantity() == 0)
- {
- if (mUseButton != nullptr)
- mUseButton->setEnabled(false);
- if (mDropButton != nullptr)
- mDropButton->setEnabled(false);
- return;
- }
-
- if (mDropButton != nullptr)
- mDropButton->setEnabled(true);
-
- if (mUseButton != nullptr)
- {
- const ItemInfo &info = item->getInfo();
- const std::string &str = (item->isEquipment() == Equipm_true
- && item->isEquipped() == Equipped_true)
- ? info.getUseButton2() : info.getUseButton();
- if (str.empty())
- {
- mUseButton->setEnabled(false);
- // TRANSLATORS: default use button name
- mUseButton->setCaption(_("Use"));
- }
- else
- {
- mUseButton->setEnabled(true);
- mUseButton->setCaption(str);
- }
- }
-
- updateDropButton();
-}
-
-void InventoryWindow::close()
-{
- if (mInventory == nullptr)
- {
- Window::close();
- return;
- }
-
- switch (mInventory->getType())
- {
- case InventoryType::Inventory:
- case InventoryType::Cart:
- setVisible(Visible_false);
- break;
-
- case InventoryType::Storage:
- if (inventoryHandler != nullptr)
- {
- inventoryHandler->closeStorage();
- inventoryHandler->forgotStorage();
- }
- scheduleDelete();
- break;
-
- default:
- case InventoryType::Trade:
- case InventoryType::Npc:
- case InventoryType::Vending:
- case InventoryType::MailEdit:
- case InventoryType::MailView:
- case InventoryType::Craft:
- case InventoryType::TypeEnd:
- break;
- }
-}
-
-void InventoryWindow::updateWeight()
-{
- if ((mInventory == nullptr) || (mWeightBar == nullptr))
- return;
- const InventoryTypeT type = mInventory->getType();
- if (type != InventoryType::Inventory &&
- type != InventoryType::Cart)
- {
- return;
- }
-
- const bool isInv = type == InventoryType::Inventory;
- const int total = PlayerInfo::getAttribute(isInv
- ? Attributes::TOTAL_WEIGHT : Attributes::CART_TOTAL_WEIGHT);
- const int max = PlayerInfo::getAttribute(isInv
- ? Attributes::MAX_WEIGHT : Attributes::CART_MAX_WEIGHT);
-
- if (max <= 0)
- return;
-
- // Adjust progress bar
- mWeightBar->setProgress(static_cast<float>(total)
- / static_cast<float>(max));
- mWeightBar->setText(strprintf("%s/%s",
- UnitsDb::formatWeight(total).c_str(),
- UnitsDb::formatWeight(max).c_str()));
-}
-
-void InventoryWindow::slotsChanged(const Inventory *const inventory)
-{
- if (inventory == mInventory)
- {
- const int usedSlots = mInventory->getNumberOfSlotsUsed();
- const int maxSlots = mInventory->getSize();
-
- if (maxSlots != 0)
- {
- mSlotsBar->setProgress(static_cast<float>(usedSlots)
- / static_cast<float>(maxSlots));
- }
-
- mSlotsBar->setText(strprintf("%d/%d", usedSlots, maxSlots));
- mItems->updateMatrix();
- }
-}
-
-void InventoryWindow::updateDropButton()
-{
- if (mDropButton == nullptr)
- return;
-
- if (isStorageActive() ||
- (cartWindow != nullptr && cartWindow->isWindowVisible()))
- {
- // TRANSLATORS: inventory button
- mDropButton->setCaption(_("Store"));
- }
- else
- {
- const Item *const item = mItems->getSelectedItem();
- if ((item != nullptr) && item->getQuantity() > 1)
- {
- // TRANSLATORS: inventory button
- mDropButton->setCaption(_("Drop..."));
- }
- else
- {
- // TRANSLATORS: inventory button
- mDropButton->setCaption(_("Drop"));
- }
- }
-}
-
-bool InventoryWindow::isInputFocused() const
-{
- return (mNameFilter != nullptr) && mNameFilter->isFocused();
-}
-
-bool InventoryWindow::isAnyInputFocused()
-{
- FOR_EACH (WindowList::const_iterator, it, invInstances)
- {
- if (((*it) != nullptr) && (*it)->isInputFocused())
- return true;
- }
- return false;
-}
-
-InventoryWindow *InventoryWindow::getFirstVisible()
-{
- std::set<Widget*> list;
- FOR_EACH (WindowList::const_iterator, it, invInstances)
- {
- if (((*it) != nullptr) && (*it)->isWindowVisible())
- list.insert(*it);
- }
- return dynamic_cast<InventoryWindow*>(
- windowContainer->findFirstWidget(list));
-}
-
-void InventoryWindow::nextTab()
-{
- const InventoryWindow *const window = getFirstVisible();
- if (window != nullptr)
- window->mFilter->nextTab();
-}
-
-void InventoryWindow::prevTab()
-{
- const InventoryWindow *const window = getFirstVisible();
- if (window != nullptr)
- window->mFilter->prevTab();
-}
-
-void InventoryWindow::widgetResized(const Event &event)
-{
- Window::widgetResized(event);
-
- if (mInventory == nullptr)
- return;
- const InventoryTypeT type = mInventory->getType();
- if (type != InventoryType::Inventory &&
- type != InventoryType::Cart)
- {
- return;
- }
-
- if (getWidth() < 600)
- {
- if (!mCompactMode)
- {
- mNameFilter->setVisible(Visible_false);
- mNameFilterCell->setType(LayoutCell::NONE);
- mFilterCell->setWidth(mFilterCell->getWidth() + 3);
- mCompactMode = true;
- }
- }
- else if (mCompactMode)
- {
- mNameFilter->setVisible(Visible_true);
- mNameFilterCell->setType(LayoutCell::WIDGET);
- mFilterCell->setWidth(mFilterCell->getWidth() - 3);
- mCompactMode = false;
- }
-}
-
-void InventoryWindow::setVisible(Visible visible)
-{
- if (visible == Visible_false)
- mSortDropDown->hideDrop();
- Window::setVisible(visible);
-}
-
-void InventoryWindow::unsetInventory()
-{
- if (mInventory != nullptr)
- {
- mInventory->removeInventoyListener(this);
- if (mItems != nullptr)
- mItems->unsetInventory();
- }
- mInventory = nullptr;
-}
-
-void InventoryWindow::attributeChanged(const AttributesT id,
- const int64_t oldVal A_UNUSED,
- const int64_t newVal A_UNUSED)
-{
- if (id == Attributes::TOTAL_WEIGHT
- || id == Attributes::MAX_WEIGHT
- || id == Attributes::CART_TOTAL_WEIGHT
- || id == Attributes::CART_MAX_WEIGHT)
- {
- updateWeight();
- }
-}
-
-void InventoryWindow::combineItems(const int index1,
- const int index2)
-{
- if (mInventory == nullptr)
- return;
- const Item *item1 = mInventory->getItem(index1);
- if (item1 == nullptr)
- return;
- const Item *item2 = mInventory->getItem(index2);
- if (item2 == nullptr)
- return;
-
- if (item1->getType() != ItemType::Card)
- {
- const Item *tmpItem = item1;
- item1 = item2;
- item2 = tmpItem;
- }
-
- ConfirmDialog *const confirmDlg = CREATEWIDGETR(ConfirmDialog,
- // TRANSLATORS: question dialog title
- _("Insert card request"),
- // TRANSLATORS: question dialog message
- strprintf(_("Insert %s into %s?"),
- item1->getName().c_str(),
- item2->getName().c_str()),
- SOUND_REQUEST,
- false,
- Modal_true);
- insertCardListener.itemIndex = item2->getInvIndex();
- insertCardListener.cardIndex = item1->getInvIndex();
- confirmDlg->addActionListener(&insertCardListener);
-}
-
-void InventoryWindow::moveItemToCraft(const int craftSlot)
-{
- if (npcHandler == nullptr)
- return;
-
- Item *const item = mItems->getSelectedItem();
- if (item == nullptr)
- return;
-
- NpcDialog *const dialog = npcHandler->getCurrentNpcDialog();
- if ((dialog != nullptr) &&
- dialog->getInputState() == NpcInputState::ITEM_CRAFT)
- {
- if (item->getQuantity() > 1
- && !inputManager.isActionActive(InputAction::STOP_ATTACK))
- {
- ItemAmountWindow::showWindow(ItemAmountWindowUsage::CraftAdd,
- npcHandler->getCurrentNpcDialog(),
- item,
- 0,
- craftSlot);
- }
- else
- {
- dialog->addCraftItem(item, 1, craftSlot);
- }
- }
-}
diff --git a/src/gui/windows/inventorywindow.h b/src/gui/windows/inventorywindow.h
deleted file mode 100644
index 81cfd38e4..000000000
--- a/src/gui/windows/inventorywindow.h
+++ /dev/null
@@ -1,210 +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_WINDOWS_INVENTORYWINDOW_H
-#define GUI_WINDOWS_INVENTORYWINDOW_H
-
-#include "resources/inventory/inventory.h"
-
-#include "gui/widgets/window.h"
-
-#include "listeners/actionlistener.h"
-#include "listeners/attributelistener.h"
-#include "listeners/inventorylistener.h"
-#include "listeners/keylistener.h"
-#include "listeners/selectionlistener.h"
-
-class Button;
-class DropDown;
-class InventoryWindow;
-class Item;
-class ItemContainer;
-class LayoutCell;
-class ProgressBar;
-class SortListModelInv;
-class TabStrip;
-class TextField;
-
-extern InventoryWindow *inventoryWindow;
-extern InventoryWindow *storageWindow;
-extern InventoryWindow *cartWindow;
-
-/**
- * Inventory dialog.
- *
- * \ingroup Interface
- */
-class InventoryWindow final : public Window,
- public ActionListener,
- public KeyListener,
- public SelectionListener,
- public InventoryListener,
- public AttributeListener
-{
- public:
- /**
- * Constructor.
- */
- explicit InventoryWindow(Inventory *const inventory);
-
- A_DELETE_COPY(InventoryWindow)
-
- /**
- * Destructor.
- */
- ~InventoryWindow();
-
- void postInit() override final;
-
- void storeSortOrder() const;
-
- /**
- * Called when receiving actions from the widgets.
- */
- void action(const ActionEvent &event) override final;
-
- /**
- * Returns the selected item.
- */
- Item* getSelectedItem() const A_WARN_UNUSED;
-
- /**
- * Unselect item
- */
- void unselectItem();
-
- /**
- * Handles closing of the window
- */
- void widgetHidden(const Event &event) override final;
-
- /**
- * Handles the mouse clicks.
- */
- void mouseClicked(MouseEvent &event) override final;
-
- /**
- * Handles the key presses.
- */
- void keyPressed(KeyEvent &event) override final;
-
- /**
- * Handles the key releases.
- */
- void keyReleased(KeyEvent &event) override final;
-
- /**
- * Updates labels to currently selected item.
- */
- void valueChanged(const SelectionEvent &event) override final;
-
- /**
- * Closes the Storage Window, as well as telling the server that the
- * window has been closed.
- */
- void close() override final;
-
- void slotsChanged(const Inventory *const inventory) override final;
-
- bool isMainInventory() const A_WARN_UNUSED
- {
- return mInventory != nullptr ?
- mInventory->isMainInventory() : false;
- }
-
- /**
- * Returns true if any instances exist.
- */
- static bool isStorageActive() A_WARN_UNUSED
- { return storageWindow != nullptr; }
-
- void updateDropButton();
-
- void updateButtons(const Item *item = nullptr);
-
- bool isInputFocused() const A_WARN_UNUSED;
-
- void widgetResized(const Event &event) override final;
-
- void mouseMoved(MouseEvent &event) override final;
-
- void mouseExited(MouseEvent &event) override final;
-
- void setVisible(Visible visible) override final;
-
- void unsetInventory();
-
- void attributeChanged(const AttributesT id,
- const int64_t oldVal,
- const int64_t newVal) override final;
-
- void combineItems(const int index1,
- const int index2);
-
- void moveItemToCraft(const int craftSlot);
-
- static bool isAnyInputFocused();
-
- static InventoryWindow *getFirstVisible();
-
- static void nextTab();
-
- static void prevTab();
-
- private:
- /**
- * Updates the weight bar.
- */
- void updateWeight();
-
- typedef std::list<InventoryWindow*> WindowList;
- static WindowList invInstances;
-
- Inventory *mInventory;
- ItemContainer *mItems A_NONNULLPOINTER;
-
- Button *mUseButton;
- Button *mDropButton;
- Button *mOutfitButton;
- Button *mShopButton;
- Button *mCartButton;
- Button *mEquipmentButton;
- Button *mStoreButton;
- Button *mRetrieveButton;
- Button *mInvCloseButton;
-
- ProgressBar *mWeightBar;
- ProgressBar *mSlotsBar A_NONNULLPOINTER;
- TabStrip *mFilter;
- SortListModelInv *mSortModel A_NONNULLPOINTER;
- DropDown *mSortDropDown A_NONNULLPOINTER;
- TextField *mNameFilter A_NONNULLPOINTER;
- LayoutCell *mSortDropDownCell;
- LayoutCell *mNameFilterCell;
- LayoutCell *mFilterCell;
- LayoutCell *mSlotsBarCell;
-
- bool mSplit;
- bool mCompactMode;
-};
-
-#endif // GUI_WINDOWS_INVENTORYWINDOW_H
diff --git a/src/gui/windows/itemamountwindow.cpp b/src/gui/windows/itemamountwindow.cpp
deleted file mode 100644
index 100ad748a..000000000
--- a/src/gui/windows/itemamountwindow.cpp
+++ /dev/null
@@ -1,504 +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 "gui/windows/itemamountwindow.h"
-
-#include "settings.h"
-
-#include "being/playerinfo.h"
-
-#include "input/keyboardconfig.h"
-
-#include "gui/viewport.h"
-
-#include "gui/models/itemsmodel.h"
-
-#include "gui/popups/itempopup.h"
-
-#include "gui/windows/maileditwindow.h"
-#include "gui/windows/npcdialog.h"
-#include "gui/windows/shopwindow.h"
-#include "gui/windows/tradewindow.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/containerplacer.h"
-#include "gui/widgets/createwidget.h"
-#include "gui/widgets/dropdown.h"
-#include "gui/widgets/icon.h"
-#include "gui/widgets/inttextfield.h"
-#include "gui/widgets/label.h"
-#include "gui/widgets/slider.h"
-
-#include "net/inventoryhandler.h"
-#include "net/mail2handler.h"
-#include "net/npchandler.h"
-
-#include "resources/item/item.h"
-
-#include "utils/delete2.h"
-#include "utils/gettext.h"
-
-#ifndef USE_SDL2
-#include <cmath>
-#endif // USE_SDL2
-
-#include "debug.h"
-
-void ItemAmountWindow::finish(Item *const item,
- const int amount,
- const int price,
- const ItemAmountWindowUsageT usage)
-{
- if (item == nullptr)
- return;
- switch (usage)
- {
- case ItemAmountWindowUsage::TradeAdd:
- if (tradeWindow != nullptr)
- tradeWindow->tradeItem(item, amount);
- break;
- case ItemAmountWindowUsage::ItemDrop:
- PlayerInfo::dropItem(item, amount, Sfx_true);
- break;
- case ItemAmountWindowUsage::ItemSplit:
- inventoryHandler->splitItem(item, amount);
- break;
- case ItemAmountWindowUsage::StoreAdd:
- inventoryHandler->moveItem2(InventoryType::Inventory,
- item->getInvIndex(), amount, InventoryType::Storage);
- break;
- case ItemAmountWindowUsage::StoreRemove:
- inventoryHandler->moveItem2(InventoryType::Storage,
- item->getInvIndex(), amount, InventoryType::Inventory);
- break;
- case ItemAmountWindowUsage::ShopBuyAdd:
- if (shopWindow != nullptr)
- shopWindow->addBuyItem(item, amount, price);
- break;
- case ItemAmountWindowUsage::ShopSellAdd:
- if (shopWindow != nullptr)
- shopWindow->addSellItem(item, amount, price);
- break;
- case ItemAmountWindowUsage::CartAdd:
- inventoryHandler->moveItem2(InventoryType::Inventory,
- item->getInvIndex(), amount, InventoryType::Cart);
- break;
- case ItemAmountWindowUsage::CartRemove:
- inventoryHandler->moveItem2(InventoryType::Cart,
- item->getInvIndex(), amount, InventoryType::Inventory);
- break;
- case ItemAmountWindowUsage::MailAdd:
- if (settings.enableNewMailSystem)
- {
- mail2Handler->addItem(item, amount);
- }
- else if (mailEditWindow != nullptr)
- {
- mailEditWindow->addItem(item, amount);
- }
- break;
- case ItemAmountWindowUsage::CraftAdd:
- {
- NpcDialog *const dialog = npcHandler->getCurrentNpcDialog();
- if (dialog != nullptr)
- dialog->addCraftItem(item, amount, price); // price as slot
- break;
- }
- default:
- break;
- }
-}
-
-ItemAmountWindow::ItemAmountWindow(const ItemAmountWindowUsageT usage,
- Window *const parent,
- Item *const item,
- const int maxRange) :
- Window("", Modal_false, parent, "amount.xml"),
- ActionListener(),
- KeyListener(),
- mItemAmountTextField(new IntTextField(this, 1)),
- mItemPriceTextField(nullptr),
- mGPLabel(nullptr),
- mItem(item),
- mItemIcon(new Icon(this, item != nullptr ? item->getImage() : nullptr)),
- mItemAmountSlide(new Slider(this, 1.0, maxRange, 1.0)),
- mItemPriceSlide(nullptr),
- mItemDropDown(nullptr),
- mItemsModal(nullptr),
- mPrice(0),
- mMax(maxRange),
- mUsage(usage),
- mEnabledKeyboard(keyboard.isEnabled())
-{
- if (mItem == nullptr)
- return;
-
- if (usage == ItemAmountWindowUsage::ShopBuyAdd)
- mMax = 10000;
- else if (mMax == 0)
- mMax = mItem->getQuantity();
-
- keyboard.setEnabled(false);
-
- mItemAmountTextField->setRange(1, mMax);
- mItemAmountTextField->setWidth(35);
- mItemAmountTextField->addKeyListener(this);
-
- mItemAmountSlide->setHeight(10);
- mItemAmountSlide->setActionEventId("slide");
- mItemAmountSlide->addActionListener(this);
-
- if (mUsage == ItemAmountWindowUsage::ShopBuyAdd ||
- mUsage == ItemAmountWindowUsage::ShopSellAdd)
- {
- mItemPriceTextField = new IntTextField(this, 1);
- mItemPriceTextField->setRange(1, 10000000);
- mItemPriceTextField->setWidth(35);
- mItemPriceTextField->addKeyListener(this);
-
- mItemPriceSlide = new Slider(this, 1.0, 10000000, 1.0);
- mItemPriceSlide->setHeight(10);
- mItemPriceSlide->setActionEventId("slidePrice");
- mItemPriceSlide->addActionListener(this);
-
- mGPLabel = new Label(this, " GP");
- }
-
- if (mUsage == ItemAmountWindowUsage::ShopBuyAdd)
- {
- mItemsModal = new ItemsModal;
- mItemDropDown = new DropDown(this, mItemsModal);
- mItemDropDown->setActionEventId("itemType");
- mItemDropDown->addActionListener(this);
- }
-
- // Buttons
- // TRANSLATORS: item amount window button
- Button *const minusAmountButton = new Button(this, _("-"), "dec", this);
- // TRANSLATORS: item amount window button
- Button *const plusAmountButton = new Button(this, _("+"), "inc", this);
- // TRANSLATORS: item amount window button
- Button *const okButton = new Button(this, _("OK"), "ok", this);
- // TRANSLATORS: item amount window button
- Button *const cancelButton = new Button(this, _("Cancel"), "cancel", this);
- // TRANSLATORS: item amount window button
- Button *const addAllButton = new Button(this, _("All"), "all", this);
-
- minusAmountButton->adjustSize();
- minusAmountButton->setWidth(plusAmountButton->getWidth());
-
- // Set positions
- ContainerPlacer placer;
- placer = getPlacer(0, 0);
- int n = 0;
- if (mUsage == ItemAmountWindowUsage::ShopBuyAdd)
- {
- placer(0, n, mItemDropDown, 8);
- n++;
- }
- placer(1, n, minusAmountButton);
- placer(2, n, mItemAmountTextField, 3);
- placer(5, n, plusAmountButton);
- placer(6, n, addAllButton);
-
- placer(0, n, mItemIcon, 1, 3);
- placer(1, n + 1, mItemAmountSlide, 7);
-
- if (mUsage == ItemAmountWindowUsage::ShopBuyAdd ||
- mUsage == ItemAmountWindowUsage::ShopSellAdd)
- {
- Button *const minusPriceButton = new Button(
- // TRANSLATORS: item amount window button
- this, _("-"), "decPrice", this);
- Button *const plusPriceButton = new Button(
- // TRANSLATORS: item amount window button
- this, _("+"), "incPrice", this);
- minusPriceButton->adjustSize();
- minusPriceButton->setWidth(plusPriceButton->getWidth());
-
- placer(1, n + 2, minusPriceButton);
- placer(2, n + 2, mItemPriceTextField, 3);
- placer(5, n + 2, plusPriceButton);
- placer(6, n + 2, mGPLabel);
-
- placer(1, n + 3, mItemPriceSlide, 7);
- placer(4, n + 5, cancelButton);
- placer(5, n + 5, okButton);
- }
- else
- {
- placer(4, n + 2, cancelButton);
- placer(5, n + 2, okButton);
- }
-
- reflowLayout(225, 0);
-
- resetAmount();
-
- switch (usage)
- {
- case ItemAmountWindowUsage::TradeAdd:
- // TRANSLATORS: amount window message
- setCaption(_("Select amount of items to trade."));
- break;
- case ItemAmountWindowUsage::ItemDrop:
- // TRANSLATORS: amount window message
- setCaption(_("Select amount of items to drop."));
- break;
- case ItemAmountWindowUsage::StoreAdd:
- // TRANSLATORS: amount window message
- setCaption(_("Select amount of items to store."));
- break;
- case ItemAmountWindowUsage::MailAdd:
- // TRANSLATORS: amount window message
- setCaption(_("Select amount of items to send."));
- break;
- case ItemAmountWindowUsage::CraftAdd:
- // TRANSLATORS: amount window message
- setCaption(_("Select amount of items to craft."));
- break;
- case ItemAmountWindowUsage::CartAdd:
- // TRANSLATORS: amount window message
- setCaption(_("Select amount of items to store to cart."));
- break;
- case ItemAmountWindowUsage::StoreRemove:
- // TRANSLATORS: amount window message
- setCaption(_("Select amount of items to retrieve."));
- break;
- case ItemAmountWindowUsage::CartRemove:
- // TRANSLATORS: amount window message
- setCaption(_("Select amount of items to retrieve from cart."));
- break;
- case ItemAmountWindowUsage::ItemSplit:
- // TRANSLATORS: amount window message
- setCaption(_("Select amount of items to split."));
- break;
- case ItemAmountWindowUsage::ShopBuyAdd:
- // TRANSLATORS: amount window message
- setCaption(_("Add to buy shop."));
- break;
- case ItemAmountWindowUsage::ShopSellAdd:
- // TRANSLATORS: amount window message
- setCaption(_("Add to sell shop."));
- break;
- default:
- // TRANSLATORS: amount window message
- setCaption(_("Unknown."));
- break;
- }
-
- setLocationRelativeTo(getParentWindow());
-
- mItemIcon->addMouseListener(this);
-}
-
-void ItemAmountWindow::postInit()
-{
- Window::postInit();
- setVisible(fromBool(mItem, Visible));
-}
-
-ItemAmountWindow::~ItemAmountWindow()
-{
- delete2(mItemsModal);
-}
-
-// Show ItemTooltip
-void ItemAmountWindow::mouseMoved(MouseEvent &event)
-{
- Window::mouseMoved(event);
-
- if ((viewport == nullptr) || (itemPopup == nullptr))
- return;
-
- if (event.getSource() == mItemIcon)
- {
- itemPopup->setItem(mItem, false);
- itemPopup->position(viewport->mMouseX, viewport->mMouseY);
- }
-}
-
-// Hide ItemTooltip
-void ItemAmountWindow::mouseExited(MouseEvent &event A_UNUSED)
-{
- if (itemPopup != nullptr)
- itemPopup->setVisible(Visible_false);
-}
-
-void ItemAmountWindow::resetAmount()
-{
- mItemAmountTextField->setValue(1);
-}
-
-void ItemAmountWindow::action(const ActionEvent &event)
-{
- const std::string &eventId = event.getId();
- if (eventId == "cancel")
- {
- close();
- return;
- }
- else if (eventId == "ok")
- {
- if (mItemPriceTextField != nullptr)
- {
- finish(mItem,
- mItemAmountTextField->getValue(),
- mItemPriceTextField->getValue(),
- mUsage);
- }
- else
- {
- if (mUsage == ItemAmountWindowUsage::CraftAdd)
- {
- finish(mItem,
- mItemAmountTextField->getValue(),
- mPrice,
- mUsage);
- }
- else
- {
- finish(mItem,
- mItemAmountTextField->getValue(),
- 0,
- mUsage);
- }
- }
- close();
- return;
- }
- else if (eventId == "itemType")
- {
- if ((mItemDropDown == nullptr) || (mItemsModal == nullptr))
- return;
-
- const int id = ItemDB::get(mItemsModal->getElementAt(
- mItemDropDown->getSelected())).getId();
-
- mItem = new Item(id,
- ItemType::Unknown,
- 10000,
- 0,
- ItemColor_one,
- Identified_true,
- Damaged_true,
- Favorite_false,
- Equipm_false,
- Equipped_false);
-
- if (mUsage == ItemAmountWindowUsage::ShopBuyAdd)
- mMax = 10000;
- else if (mMax == 0)
- mMax = mItem->getQuantity();
-
- mItemIcon->setImage(mItem->getImage());
- }
-
- int amount = mItemAmountTextField->getValue();
-
- if (eventId == "inc" && amount < mMax)
- amount++;
- else if (eventId == "dec" && amount > 1)
- amount--;
- else if (eventId == "all")
- amount = mMax;
- else if (eventId == "slide")
- amount = CAST_S32(mItemAmountSlide->getValue());
- mItemAmountTextField->setValue(amount);
- mItemAmountSlide->setValue(amount);
-
- if ((mItemPriceTextField != nullptr) && (mItemPriceSlide != nullptr))
- {
- if (mPrice > 7)
- mPrice = 7;
- else if (mPrice < 0)
- mPrice = 0;
-
- int price = 0;
-
- if (eventId == "incPrice")
- {
- mPrice++;
- price = CAST_S32(pow(10.0, mPrice));
- mItemPriceTextField->setValue(price);
- mItemPriceSlide->setValue(price);
- }
- else if (eventId == "decPrice")
- {
- mPrice--;
- price = CAST_S32(pow(10.0, mPrice));
- mItemPriceTextField->setValue(price);
- mItemPriceSlide->setValue(price);
- }
- else if (eventId == "slidePrice")
- {
- price = CAST_S32(mItemPriceSlide->getValue());
- if (price != 0)
- mPrice = CAST_S32(log(static_cast<float>(price)));
- else
- mPrice = 0;
- mItemPriceTextField->setValue(price);
- mItemPriceSlide->setValue(price);
- }
- }
-}
-
-void ItemAmountWindow::close()
-{
- keyboard.setEnabled(mEnabledKeyboard);
- scheduleDelete();
-}
-
-void ItemAmountWindow::keyReleased(KeyEvent &event A_UNUSED)
-{
- mItemAmountSlide->setValue(mItemAmountTextField->getValue());
-}
-
-void ItemAmountWindow::showWindow(const ItemAmountWindowUsageT usage,
- Window *const parent,
- Item *const item,
- int maxRange,
- int tag)
-{
- if (item == nullptr)
- return;
-
- if (maxRange == 0)
- maxRange = item->getQuantity();
-
- if (usage != ItemAmountWindowUsage::ShopBuyAdd &&
- usage != ItemAmountWindowUsage::ShopSellAdd &&
- maxRange <= 1)
- {
- if (usage == ItemAmountWindowUsage::CraftAdd)
- finish(item, maxRange, tag, usage);
- else
- finish(item, maxRange, 0, usage);
- }
- else
- {
- ItemAmountWindow *const window = CREATEWIDGETR(ItemAmountWindow,
- usage, parent, item, maxRange);
- if (usage == ItemAmountWindowUsage::CraftAdd)
- window->mPrice = tag;
- }
-}
diff --git a/src/gui/windows/itemamountwindow.h b/src/gui/windows/itemamountwindow.h
deleted file mode 100644
index 97f539ac9..000000000
--- a/src/gui/windows/itemamountwindow.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 GUI_WINDOWS_ITEMAMOUNTWINDOW_H
-#define GUI_WINDOWS_ITEMAMOUNTWINDOW_H
-
-#include "gui/widgets/window.h"
-
-#include "enums/gui/itemamountwindowusage.h"
-
-#include "listeners/actionlistener.h"
-#include "listeners/keylistener.h"
-
-class DropDown;
-class Icon;
-class IntTextField;
-class Item;
-class ItemsModal;
-class Label;
-class Slider;
-
-/**
- * Window used for selecting the amount of items to drop, trade or split.
- *
- * \ingroup Interface
- */
-class ItemAmountWindow final : public Window,
- public ActionListener,
- public KeyListener
-{
- public:
- A_DELETE_COPY(ItemAmountWindow)
-
- void postInit() override final;
-
- /**
- * Called when receiving actions from widget.
- */
- void action(const ActionEvent &event) override final;
-
- /**
- * Sets default amount value.
- */
- void resetAmount();
-
- // MouseListener
- void mouseMoved(MouseEvent &event) override final;
-
- void mouseExited(MouseEvent &event) override final;
-
- /**
- * Schedules the Item Amount window for deletion.
- */
- void close() override final;
-
- void keyReleased(KeyEvent &event) override final;
-
- /**
- * Creates the dialog, or bypass it if there aren't enough items.
- */
- static void showWindow(const ItemAmountWindowUsageT usage,
- Window *const parent,
- Item *const item,
- int maxRange = 0,
- const int tag = 0);
-
- ~ItemAmountWindow();
-
-#ifndef UNITTESTS
- private:
-#endif // UNITTESTS
- static void finish(Item *const item,
- const int amount,
- const int price,
- const ItemAmountWindowUsageT usage);
-
- ItemAmountWindow(const ItemAmountWindowUsageT usage,
- Window *const parent,
- Item *const item,
- const int maxRange = 0);
-
- /**< Item amount caption. */
- IntTextField *mItemAmountTextField A_NONNULLPOINTER;
- /**< Item price caption. */
- IntTextField *mItemPriceTextField;
- Label *mGPLabel;
- Item *mItem;
- Icon *mItemIcon A_NONNULLPOINTER;
-
- /**
- * Item Amount buttons.
- */
- Slider *mItemAmountSlide A_NONNULLPOINTER;
- Slider *mItemPriceSlide;
- DropDown *mItemDropDown;
- ItemsModal *mItemsModal;
-
- int mPrice;
- int mMax;
- ItemAmountWindowUsageT mUsage;
- bool mEnabledKeyboard;
-};
-
-#endif // GUI_WINDOWS_ITEMAMOUNTWINDOW_H
diff --git a/src/gui/windows/killstats.cpp b/src/gui/windows/killstats.cpp
deleted file mode 100644
index 80efb4b36..000000000
--- a/src/gui/windows/killstats.cpp
+++ /dev/null
@@ -1,479 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 Andrei Karas
- * 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 "gui/windows/killstats.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/label.h"
-#include "gui/widgets/layoutcell.h"
-
-#include "gui/windows/setupwindow.h"
-
-#include "client.h"
-#include "game.h"
-
-#include "being/localplayer.h"
-#include "being/playerinfo.h"
-
-#include "utils/gettext.h"
-
-#ifdef WIN32
-#include <sys/time.h>
-#endif // WIN32
-
-#include "debug.h"
-
-KillStats *killStats = nullptr;
-
-KillStats::KillStats() :
- // TRANSLATORS: kill stats window name
- Window(_("Kill stats"), Modal_false, nullptr, "killstats.xml"),
- ActionListener(),
- AttributeListener(),
- mKillTimer(0),
- // TRANSLATORS: kill stats window button
- mResetButton(new Button(this, _("Reset stats"), "reset", this)),
- // TRANSLATORS: kill stats window button
- mTimerButton(new Button(this, _("Reset timer"), "timer", this)),
- mLine1(nullptr),
- mLine2(nullptr),
- mLine3(nullptr),
- // TRANSLATORS: kill stats window label
- mLine4(new Label(this, strprintf(_("Kills: %s, total exp: %s"),
- "?", "?"))),
- // TRANSLATORS: kill stats window label
- mLine5(new Label(this, strprintf(_("Avg Exp: %s"), "?"))),
- // TRANSLATORS: kill stats window label
- mLine6(new Label(this, strprintf(_("No. of avg mob to next level: %s"),
- "?"))),
- // TRANSLATORS: kill stats window label
- mLine7(new Label(this, strprintf(_("Kills/Min: %s, Exp/Min: %s"),
- "?", "?"))),
- mExpSpeed1Label(new Label(this, strprintf(ngettext(
- // TRANSLATORS: kill stats window label
- "Exp speed per %d min: %s", "Exp speed per %d min: %s", 1), 1, "?"))),
- mExpTime1Label(new Label(this, strprintf(ngettext(
- "Time for next level per %d min: %s",
- "Time for next level per %d min: %s", 1), 1, "?"))),
- mExpSpeed5Label(new Label(this, strprintf(ngettext(
- "Exp speed per %d min: %s", "Exp speed per %d min: %s", 5), 5, "?"))),
- mExpTime5Label(new Label(this, strprintf(ngettext(
- "Time for next level per %d min: %s",
- "Time for next level per %d min: %s", 5), 5, "?"))),
- mExpSpeed15Label(new Label(this, strprintf(ngettext(
- "Exp speed per %d min: %s", "Exp speed per %d min: %s", 15),
- 15, "?"))),
- mExpTime15Label(new Label(this, strprintf(ngettext(
- "Time for next level per %d min: %s",
- "Time for next level per %d min: %s", 15), 15, "?"))),
- // TRANSLATORS: kill stats window label
- mLastKillExpLabel(new Label(this, strprintf("%s ?", _("Last kill exp:")))),
- mKillCounter(0),
- mExpCounter(0),
- mKillTCounter(0),
- mExpTCounter(0),
- m1minExpTime(0),
- m1minExpNum(0),
- m1minSpeed(0),
- m5minExpTime(0),
- m5minExpNum(0),
- m5minSpeed(0),
- m15minExpTime(0),
- m15minExpNum(0),
- m15minSpeed(0)
-{
- setWindowName("Kill stats");
- setCloseButton(true);
- setResizable(true);
- setSaveVisible(true);
- setStickyButtonLock(true);
- setDefaultSize(250, 250, 350, 300);
-
- if (setupWindow != nullptr)
- setupWindow->registerWindowForReset(this);
-
- const int64_t xp(PlayerInfo::getAttribute64(Attributes::PLAYER_EXP));
- int64_t xpNextLevel(PlayerInfo::getAttribute64(
- Attributes::PLAYER_EXP_NEEDED));
-
- if (xpNextLevel == 0)
- xpNextLevel = 1;
-
- // TRANSLATORS: kill stats window label
- mLine1 = new Label(this, strprintf(_("Level: %d at %f%%"),
- localPlayer->getLevel(), static_cast<double>(xp)
- / static_cast<double>(xpNextLevel) * 100.0));
-
- const std::string strXp = toString(CAST_U64(xp));
- const std::string strXpNextLevel = toString(CAST_U64(xpNextLevel));
- const std::string strXpLeft = toString(CAST_U64(xpNextLevel - xp));
- const std::string strXpPercent = toString(CAST_U64(xpNextLevel / 100));
- // TRANSLATORS: kill stats window label
- mLine2 = new Label(this, strprintf(_("Exp: %s/%s Left: %s"),
- strXp.c_str(),
- strXpNextLevel.c_str(),
- strXpLeft.c_str()));
-
- // TRANSLATORS: kill stats window label
- mLine3 = new Label(this, strprintf(_("1%% = %s exp, avg mob for 1%%: %s"),
- strXpPercent.c_str(),
- "?"));
-
- place(0, 0, mLine1, 6).setPadding(0);
- place(0, 1, mLine2, 6).setPadding(0);
- place(0, 2, mLine3, 6).setPadding(0);
- place(0, 3, mLine4, 6).setPadding(0);
- place(0, 4, mLine5, 6).setPadding(0);
- place(0, 5, mLine6, 6).setPadding(0);
- place(0, 6, mLine7, 6).setPadding(0);
-
- place(0, 7, mLastKillExpLabel, 6).setPadding(0);
- place(0, 8, mExpSpeed1Label, 6).setPadding(0);
- place(0, 9, mExpTime1Label, 6).setPadding(0);
- place(0, 10, mExpSpeed5Label, 6).setPadding(0);
- place(0, 11, mExpTime5Label, 6).setPadding(0);
- place(0, 12, mExpSpeed15Label, 6).setPadding(0);
- place(0, 13, mExpTime15Label, 6).setPadding(0);
-
- place(5, 12, mTimerButton).setPadding(0);
- place(5, 13, mResetButton).setPadding(0);
-
- loadWindowState();
- enableVisibleSound(true);
-}
-
-void KillStats::action(const ActionEvent &event)
-{
- const std::string &eventId = event.getId();
- if (eventId == "reset")
- {
- mKillCounter = 0;
- mExpCounter = 0;
- const std::string strXpPercent = toString(CAST_U64(
- PlayerInfo::getAttribute64(Attributes::PLAYER_EXP_NEEDED) / 100));
- mLine3->setCaption(strprintf("1%% = %s exp, avg mob for 1%%: %s",
- strXpPercent.c_str(),
- "?"));
- // TRANSLATORS: kill stats window label
- mLine4->setCaption(strprintf(_("Kills: %s, total exp: %s"), "?", "?"));
- // TRANSLATORS: kill stats window label
- mLine5->setCaption(strprintf(_("Avg Exp: %s"), "?"));
- mLine6->setCaption(strprintf(
- // TRANSLATORS: kill stats window label
- _("No. of avg mob to next level: %s"), "?"));
-
- resetTimes();
- }
- else if (eventId == "timer")
- {
- mKillTimer = 0;
- mKillTCounter = 0;
- mExpTCounter = 0;
- mLine7->setCaption(strprintf(
- // TRANSLATORS: kill stats window label
- _("Kills/Min: %s, Exp/Min: %s"), "?", "?"));
-
- resetTimes();
- }
-}
-
-void KillStats::resetTimes()
-{
- m1minExpTime = 0;
- m1minExpNum = 0;
- m1minSpeed = 0;
- m5minExpTime = 0;
- m5minExpNum = 0;
- m5minSpeed = 0;
- m15minExpTime = 0;
- m15minExpNum = 0;
- m15minSpeed = 0;
-}
-
-void KillStats::gainXp(int64_t xp)
-{
- const int64_t expNeed = PlayerInfo::getAttribute64(
- Attributes::PLAYER_EXP_NEEDED);
- if (xp == expNeed)
- xp = 0;
- else if (xp == 0)
- return;
-
- mKillCounter++;
- mKillTCounter++;
-
- mExpCounter = mExpCounter + xp;
- mExpTCounter = mExpTCounter + xp;
- if (mKillCounter == 0)
- mKillCounter = 1;
-
- const float AvgExp = static_cast<float>(mExpCounter)
- / static_cast<float>(mKillCounter);
- int64_t xpNextLevel(expNeed);
-
- if (mKillTimer == 0)
- mKillTimer = cur_time;
-
- if (xpNextLevel == 0)
- xpNextLevel = 1;
-
- double timeDiff = difftime(cur_time, mKillTimer) / 60;
-
- if (timeDiff <= 0.001)
- timeDiff = 1;
-
- const int64_t exp = PlayerInfo::getAttribute64(Attributes::PLAYER_EXP);
- // TRANSLATORS: kill stats window label
- mLine1->setCaption(strprintf(_("Level: %d at %f%%"),
- localPlayer->getLevel(), static_cast<double>(exp)
- / static_cast<double>(xpNextLevel) * 100.0));
-
- const std::string strXp = toString(CAST_U64(exp));
- const std::string strXpNextLevel = toString(CAST_U64(xpNextLevel));
- const std::string strXpLeft = toString(CAST_U64(xpNextLevel - exp));
- const std::string strXpPercent = toString(CAST_U64(xpNextLevel / 100));
- // TRANSLATORS: kill stats window label
- mLine2->setCaption(strprintf(_("Exp: %s/%s Left: %s"),
- strXp.c_str(),
- strXpNextLevel.c_str(),
- strXpLeft.c_str()));
-
- if (AvgExp >= -0.001F && AvgExp <= 0.001F)
- {
- // TRANSLATORS: kill stats window label
- mLine3->setCaption(strprintf(_("1%% = %s exp, avg mob for 1%%: %s"),
- strXpPercent.c_str(),
- "?"));
-
- // TRANSLATORS: kill stats window label
- mLine5->setCaption(strprintf(_("Avg Exp: %s"),
- toString(AvgExp).c_str()));
-
- mLine6->setCaption(strprintf(
- // TRANSLATORS: kill stats window label
- _("No. of avg mob to next level: %s"), "?"));
- }
- else
- {
- // TRANSLATORS: kill stats window label
- mLine3->setCaption(strprintf(_("1%% = %s exp, avg mob for 1%%: %s"),
- strXpPercent.c_str(), toString((static_cast<float>(
- xpNextLevel) / 100) / AvgExp).c_str()));
-
- // TRANSLATORS: kill stats window label
- mLine5->setCaption(strprintf(_("Avg Exp: %s"),
- toString(AvgExp).c_str()));
-
- // TRANSLATORS: kill stats window label
- mLine6->setCaption(strprintf(_("No. of avg mob to next level: %s"),
- toString(static_cast<float>(xpNextLevel - exp) / AvgExp).c_str()));
- }
- // TRANSLATORS: kill stats window label
- mLine4->setCaption(strprintf(_("Kills: %s, total exp: %s"),
- toString(mKillCounter).c_str(),
- toString(CAST_U64(mExpCounter)).c_str()));
-
- // TRANSLATORS: kill stats window label
- mLine7->setCaption(strprintf(_("Kills/Min: %s, Exp/Min: %s"),
- toString(mKillTCounter / timeDiff).c_str(),
- toString(CAST_U64(mExpTCounter / timeDiff)).c_str()));
-
- mLastKillExpLabel->setCaption(strprintf("%s %s",
- // TRANSLATORS: kill stats window label
- _("Last kill exp:"),
- strXp.c_str()));
-
- recalcStats();
- update();
-}
-
-void KillStats::recalcStats()
-{
- BLOCK_START("KillStats::recalcStats")
- const time_t curTime = cur_time;
-
- // Need Update Exp Counter
- if (curTime - m1minExpTime > 60)
- {
- const int64_t newExp = PlayerInfo::getAttribute(
- Attributes::PLAYER_EXP);
- if (m1minExpTime != 0)
- m1minSpeed = CAST_S32(newExp - m1minExpNum);
- else
- m1minSpeed = 0;
- m1minExpTime = curTime;
- m1minExpNum = newExp;
- }
-
- if (curTime != 0 && mLastHost == 0xFF6B66 && cur_time > 1)
- {
- const int newExp = PlayerInfo::getAttribute(
- Attributes::PLAYER_EXP_NEEDED);
- if (m1minExpTime != 0)
- m1minSpeed = CAST_S32(newExp - m1minExpNum);
- mStatsReUpdated = true;
- m1minExpNum = newExp;
- }
-
- if (curTime - m5minExpTime > 60*5)
- {
- const int64_t newExp = PlayerInfo::getAttribute(
- Attributes::PLAYER_EXP);
- if (m5minExpTime != 0)
- m5minSpeed = CAST_S32(newExp - m5minExpNum);
- else
- m5minSpeed = 0;
- m5minExpTime = curTime;
- m5minExpNum = newExp;
- }
-
- if (curTime - m15minExpTime > 60*15)
- {
- const int64_t newExp = PlayerInfo::getAttribute(
- Attributes::PLAYER_EXP);
- if (m15minExpTime != 0)
- m15minSpeed = CAST_S32(newExp - m15minExpNum);
- else
- m15minSpeed = 0;
- m15minExpTime = curTime;
- m15minExpNum = newExp;
- }
- BLOCK_END("KillStats::recalcStats")
-}
-
-void KillStats::update()
-{
- BLOCK_START("KillStats::update")
-
- mExpSpeed1Label->setCaption(strprintf(ngettext("Exp speed per %d min: %s",
- "Exp speed per %d min: %s", 1),
- 1,
- toString(m1minSpeed).c_str()));
-
- if (m1minSpeed != 0)
- {
- // TRANSLATORS: kill stats window label
- mExpTime1Label->setCaption(strprintf(_(" Time for next level: %s"),
- toString(static_cast<float>((PlayerInfo::getAttribute(
- Attributes::PLAYER_EXP_NEEDED) - PlayerInfo::getAttribute(
- Attributes::PLAYER_EXP)) /
- static_cast<float>(m1minSpeed))).c_str()));
- }
- else
- {
- mExpTime1Label->setCaption(strprintf(
- // TRANSLATORS: kill stats window label
- _(" Time for next level: %s"), "?"));
- }
- mExpTime1Label->adjustSize();
-
- mExpSpeed5Label->setCaption(strprintf(ngettext("Exp speed per %d min: %s",
- "Exp speed per %d min: %s", 5),
- 5,
- toString(m5minSpeed / 5).c_str()));
- mExpSpeed5Label->adjustSize();
-
- if (m5minSpeed != 0)
- {
- // TRANSLATORS: kill stats window label
- mExpTime5Label->setCaption(strprintf(_(" Time for next level: %s"),
- toString(static_cast<float>((PlayerInfo::getAttribute(
- Attributes::PLAYER_EXP_NEEDED) - PlayerInfo::getAttribute(
- Attributes::PLAYER_EXP)) / m5minSpeed * 5)).c_str()));
- }
- else
- {
- mExpTime5Label->setCaption(strprintf(
- // TRANSLATORS: kill stats window label
- _(" Time for next level: %s"), "?"));
- }
- mExpTime5Label->adjustSize();
-
-
- mExpSpeed15Label->setCaption(strprintf(ngettext("Exp speed per %d min: %s",
- "Exp speed per %d min: %s", 15), 15, toString(
- m15minSpeed / 15).c_str()));
- mExpSpeed15Label->adjustSize();
-
- if (m15minSpeed != 0)
- {
- // TRANSLATORS: kill stats window label
- mExpTime15Label->setCaption(strprintf(_(" Time for next level: %s"),
- toString(static_cast<float>((PlayerInfo::getAttribute(
- Attributes::PLAYER_EXP_NEEDED) - PlayerInfo::getAttribute(
- Attributes::PLAYER_EXP)) / m15minSpeed * 15)).c_str()));
- }
- else
- {
- mExpTime15Label->setCaption(strprintf(
- // TRANSLATORS: kill stats window label
- _(" Time for next level: %s"), "?"));
- }
-
- BLOCK_END("KillStats::update")
-}
-
-void KillStats::attributeChanged(const AttributesT id,
- const int64_t oldVal,
- const int64_t newVal)
-{
- PRAGMA45(GCC diagnostic push)
- PRAGMA45(GCC diagnostic ignored "-Wswitch-enum")
- switch (id)
- {
- case Attributes::PLAYER_EXP:
- case Attributes::PLAYER_EXP_NEEDED:
- gainXp(newVal - oldVal);
- break;
- case Attributes::PLAYER_BASE_LEVEL:
- {
- const std::string strXpPercent = toString(CAST_U64(
- PlayerInfo::getAttribute(
- Attributes::PLAYER_EXP_NEEDED) / 100));
- mKillCounter = 0;
- mKillTCounter = 0;
- mExpCounter = 0;
- mExpTCounter = 0;
- mLine3->setCaption(strprintf("1%% = %s exp, avg mob for 1%%: %s",
- strXpPercent.c_str(),
- "?"));
- mLine4->setCaption(strprintf(
- // TRANSLATORS: kill stats window label
- _("Kills: %s, total exp: %s"), "?", "?"));
- // TRANSLATORS: kill stats window label
- mLine5->setCaption(strprintf(_("Avg Exp: %s"), "?"));
- mLine6->setCaption(strprintf(
- // TRANSLATORS: kill stats window label
- _("No. of avg mob to next level: %s"), "?"));
- mLine7->setCaption(strprintf(
- // TRANSLATORS: kill stats window label
- _("Kills/Min: %s, Exp/Min: %s"), "?", "?"));
-
- resetTimes();
- update();
- break;
- }
- default:
- break;
- }
- PRAGMA45(GCC diagnostic pop)
-}
diff --git a/src/gui/windows/killstats.h b/src/gui/windows/killstats.h
deleted file mode 100644
index c701d8430..000000000
--- a/src/gui/windows/killstats.h
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 Andrei Karas
- * 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_WINDOWS_KILLSTATS_H
-#define GUI_WINDOWS_KILLSTATS_H
-
-#include "listeners/actionlistener.h"
-#include "listeners/attributelistener.h"
-
-#include "gui/widgets/window.h"
-
-class Label;
-class Button;
-
-class KillStats final : public Window,
- public ActionListener,
- public AttributeListener
-{
- public:
- /**
- * Constructor.
- */
- KillStats();
-
- A_DELETE_COPY(KillStats)
-
- /**
- * Destructor.
- */
- ~KillStats()
- { }
-
- /**
- * Stuff.
- */
- void action(const ActionEvent &event) override final;
-
- void gainXp(int64_t Xp);
-
- /**
- * Recalc stats if needed
- */
- void recalcStats();
-
- /**
- * Updates this dialog
- */
- void update();
-
- void resetTimes();
-
- void attributeChanged(const AttributesT id,
- const int64_t oldVal,
- const int64_t newVal) override final;
-
- private:
- time_t mKillTimer; /**< Timer for kill stats. */
- Button *mResetButton A_NONNULLPOINTER;
- Button *mTimerButton A_NONNULLPOINTER;
- Label *mLine1;
- Label *mLine2;
- Label *mLine3;
- Label *mLine4 A_NONNULLPOINTER;
- Label *mLine5 A_NONNULLPOINTER;
- Label *mLine6 A_NONNULLPOINTER;
- Label *mLine7 A_NONNULLPOINTER;
-
- Label *mExpSpeed1Label A_NONNULLPOINTER;
- Label *mExpTime1Label A_NONNULLPOINTER;
- Label *mExpSpeed5Label A_NONNULLPOINTER;
- Label *mExpTime5Label A_NONNULLPOINTER;
- Label *mExpSpeed15Label A_NONNULLPOINTER;
- Label *mExpTime15Label A_NONNULLPOINTER;
-
- Label *mLastKillExpLabel A_NONNULLPOINTER;
-
- int mKillCounter; /**< Session Kill counter. */
- int64_t mExpCounter; /**< Session Exp counter. */
- int mKillTCounter; /**< Timer Kill counter. */
- int64_t mExpTCounter; /**< Timer Exp counter. */
-
- time_t m1minExpTime;
- int64_t m1minExpNum;
- int m1minSpeed;
-
- time_t m5minExpTime;
- int64_t m5minExpNum;
- int m5minSpeed;
-
- time_t m15minExpTime;
- int64_t m15minExpNum;
- int m15minSpeed;
-};
-
-extern KillStats *killStats;
-
-#endif // GUI_WINDOWS_KILLSTATS_H
diff --git a/src/gui/windows/logindialog.cpp b/src/gui/windows/logindialog.cpp
deleted file mode 100644
index 21af69b91..000000000
--- a/src/gui/windows/logindialog.cpp
+++ /dev/null
@@ -1,402 +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 "gui/windows/logindialog.h"
-
-#include "client.h"
-#include "configuration.h"
-
-#include "fs/paths.h"
-
-#include "gui/models/updatelistmodel.h"
-#include "gui/models/updatetypemodel.h"
-
-#include "gui/windows/confirmdialog.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/checkbox.h"
-#include "gui/widgets/createwidget.h"
-#include "gui/widgets/dropdown.h"
-#include "gui/widgets/label.h"
-#include "gui/widgets/passwordfield.h"
-#include "gui/widgets/layoutcell.h"
-
-#include "listeners/openurllistener.h"
-
-#include "net/charserverhandler.h"
-#include "net/logindata.h"
-#include "net/loginhandler.h"
-#include "net/updatetypeoperators.h"
-
-#include "utils/delete2.h"
-#include "utils/stdmove.h"
-
-#include "debug.h"
-
-std::string LoginDialog::savedPassword;
-std::string LoginDialog::savedPasswordKey;
-
-namespace
-{
- OpenUrlListener urlListener;
-} // namespace
-
-LoginDialog::LoginDialog(LoginData &data,
- ServerInfo *const server,
- std::string *const updateHost) :
- // TRANSLATORS: login dialog name
- Window(_("Login"), Modal_false, nullptr, "login.xml"),
- ActionListener(),
- KeyListener(),
- mLoginData(&data),
- mServer(server),
- mUserField(new TextField(this, mLoginData->username)),
- mPassField(new PasswordField(this, mLoginData->password)),
- // TRANSLATORS: login dialog label
- mKeepCheck(new CheckBox(this, _("Remember username"),
- mLoginData->remember)),
- // TRANSLATORS: login dialog label
- mUpdateTypeLabel(new Label(this, _("Update:"))),
- mUpdateTypeModel(new UpdateTypeModel),
- mUpdateTypeDropDown(new DropDown(this, mUpdateTypeModel)),
- // TRANSLATORS: login dialog button
- mServerButton(new Button(this, _("Change Server"), "server", this)),
- // TRANSLATORS: login dialog button
- mLoginButton(new Button(this, _("Login"), "login", this)),
- // TRANSLATORS: login dialog button
- mRegisterButton(new Button(this, _("Register"), "register", this)),
- // TRANSLATORS: login dialog checkbox
- mCustomUpdateHost(new CheckBox(this, _("Custom update host"),
- (mLoginData->updateType & UpdateType::Custom) != 0,
- this, "customhost")),
- mUpdateHostText(new TextField(this, serverConfig.getValue(
- "customUpdateHost", ""))),
- mUpdateListModel(nullptr),
- mUpdateHostDropDown(nullptr),
- mUpdateHost(updateHost),
- mServerName(server->hostname)
-{
- setCloseButton(true);
- setWindowName("Login");
-
- if (charServerHandler != nullptr)
- charServerHandler->clear();
-
- mergeUpdateHosts();
-
- // TRANSLATORS: login dialog label
- Label *const serverLabel1 = new Label(this, _("Server:"));
- Label *const serverLabel2 = new Label(this, mServerName);
- serverLabel2->adjustSize();
- // TRANSLATORS: login dialog label
- Label *const userLabel = new Label(this, _("Name:"));
- // TRANSLATORS: login dialog label
- Label *const passLabel = new Label(this, _("Password:"));
- if (mServer->updateHosts.size() > 1)
- {
- mUpdateListModel = new UpdateListModel(mServer);
- mUpdateHostDropDown = new DropDown(this, mUpdateListModel,
- false, Modal_false, this, "updateselect");
- const std::string str = serverConfig.getValue("updateHost2", "");
- if (!str.empty())
- mUpdateHostDropDown->setSelectedString(str);
- }
- else
- {
- mUpdateListModel = nullptr;
- mUpdateHostDropDown = nullptr;
- }
- mUpdateHostText->adjustSize();
-
- if (mPassField->getText().empty() &&
- !LoginDialog::savedPassword.empty())
- {
- mPassField->setText(LoginDialog::savedPassword);
- }
-
- mUpdateTypeDropDown->setActionEventId("updatetype");
- mUpdateTypeDropDown->setSelected((mLoginData->updateType
- | UpdateType::Custom) ^ CAST_S32(UpdateType::Custom));
-
- if (!mCustomUpdateHost->isSelected())
- mUpdateHostText->setVisible(Visible_false);
-
- mUserField->setActionEventId("login");
- mPassField->setActionEventId("login");
-
- mUserField->addKeyListener(this);
- mPassField->addKeyListener(this);
- mUserField->addActionListener(this);
- mPassField->addActionListener(this);
-
- place(0, 0, serverLabel1);
- place(1, 0, serverLabel2, 8);
- place(0, 1, userLabel);
- place(1, 1, mUserField, 8);
- place(0, 2, passLabel);
- place(1, 2, mPassField, 8);
- place(0, 6, mUpdateTypeLabel, 1);
- place(1, 6, mUpdateTypeDropDown, 8);
- int n = 7;
- if (mUpdateHostDropDown != nullptr)
- {
- place(0, 7, mUpdateHostDropDown, 9);
- n += 1;
- }
- place(0, n, mCustomUpdateHost, 9);
- place(0, n + 1, mUpdateHostText, 9);
- place(0, n + 2, mKeepCheck, 9);
- place(0, n + 3, mRegisterButton).setHAlign(LayoutCell::LEFT);
- place(2, n + 3, mServerButton);
- place(3, n + 3, mLoginButton);
-
- addKeyListener(this);
-}
-
-void LoginDialog::postInit()
-{
- Window::postInit();
- setVisible(Visible_true);
-
- const int h = 200;
- if (mUpdateHostDropDown != nullptr)
- setContentSize(310, 250);
- setContentSize(310, h);
-#ifdef ANDROID
- setDefaultSize(310, h, ImagePosition::UPPER_CENTER, 0, 0);
-#else // ANDROID
-
- setDefaultSize(310, h, ImagePosition::CENTER, 0, 0);
-#endif // ANDROID
-
- center();
- loadWindowState();
- reflowLayout();
-
- if (mUserField->getText().empty())
- mUserField->requestFocus();
- else
- mPassField->requestFocus();
-
- mLoginButton->setEnabled(canSubmit());
- if (loginHandler != nullptr)
- {
- mRegisterButton->setEnabled(loginHandler->isRegistrationEnabled()
- || !mLoginData->registerUrl.empty());
- }
- else
- {
- mRegisterButton->setEnabled(false);
- }
-}
-
-LoginDialog::~LoginDialog()
-{
- if (mUpdateTypeDropDown != nullptr)
- mUpdateTypeDropDown->hideDrop(false);
- if (mUpdateHostDropDown != nullptr)
- mUpdateHostDropDown->hideDrop(false);
-
- delete2(mUpdateTypeModel);
- delete2(mUpdateListModel);
-}
-
-void LoginDialog::action(const ActionEvent &event)
-{
- const std::string &eventId = event.getId();
- if (eventId == "login" && canSubmit())
- {
- prepareUpdate();
- mLoginData->registerLogin = false;
- client->setState(State::LOGIN_ATTEMPT);
- }
- else if (eventId == "server")
- {
- close();
- }
- else if (eventId == "register")
- {
- if (loginHandler->isRegistrationEnabled())
- {
- prepareUpdate();
- client->setState(State::REGISTER_PREP);
- }
- else if (!mLoginData->registerUrl.empty())
- {
- const std::string &url = mLoginData->registerUrl;
- urlListener.url = url;
- ConfirmDialog *const confirmDlg = CREATEWIDGETR(ConfirmDialog,
- // TRANSLATORS: question dialog
- _("Open register url"),
- url,
- SOUND_REQUEST,
- false,
- Modal_true);
- confirmDlg->addActionListener(&urlListener);
- }
- }
- else if (eventId == "customhost")
- {
- mUpdateHostText->setVisible(fromBool(
- mCustomUpdateHost->isSelected(), Visible));
- }
- else if (eventId == "updateselect")
- {
- mCustomUpdateHost->setSelected(false);
- mUpdateHostText->setVisible(Visible_false);
- }
-}
-
-void LoginDialog::keyPressed(KeyEvent &event)
-{
- if (event.isConsumed())
- {
- mLoginButton->setEnabled(canSubmit());
- return;
- }
-
- const InputActionT actionId = event.getActionId();
- if (actionId == InputAction::GUI_CANCEL)
- {
- action(ActionEvent(nullptr, mServerButton->getActionEventId()));
- }
-#ifdef USE_SDL2
- else if (actionId == InputAction::GUI_SELECT2)
-#else // USE_SDL2
- else if (actionId == InputAction::GUI_SELECT ||
- actionId == InputAction::GUI_SELECT2)
-#endif // USE_SDL2
- {
- action(ActionEvent(nullptr, mLoginButton->getActionEventId()));
- }
- else
- {
- mLoginButton->setEnabled(canSubmit());
- }
-}
-
-bool LoginDialog::canSubmit() const
-{
- return !mUserField->getText().empty() &&
- !mPassField->getText().empty() &&
- client->getState() == State::LOGIN;
-}
-
-void LoginDialog::prepareUpdate()
-{
- mLoginData->username = mUserField->getText();
- mLoginData->password = mPassField->getText();
- mLoginData->remember = mKeepCheck->isSelected();
- UpdateTypeT updateType = static_cast<UpdateTypeT>(
- mUpdateTypeDropDown->getSelected());
-
- if (mCustomUpdateHost->isSelected()
- && !mUpdateHostText->getText().empty())
- {
- updateType = static_cast<UpdateTypeT>(
- updateType | UpdateType::Custom);
- serverConfig.setValue("customUpdateHost",
- mUpdateHostText->getText());
-
- if (checkPath(mUpdateHostText->getText()))
- {
- mLoginData->updateHost = mUpdateHostText->getText();
- *mUpdateHost = mLoginData->updateHost;
- }
- else
- {
- mLoginData->updateHost.clear();
- (*mUpdateHost).clear();
- }
- }
- else
- {
- std::string str;
- if (mUpdateHostDropDown != nullptr)
- {
- const int sel = mUpdateHostDropDown->getSelected();
- if (sel >= 0)
- {
- const HostsGroup &group = mServer->updateHosts[sel];
- if (!group.hosts.empty())
- {
- str = group.hosts[0];
- mLoginData->updateHosts = group.hosts;
- serverConfig.setValue("updateHost2", group.name);
- }
- else
- {
- serverConfig.setValue("updateHost2", "");
- }
- }
- }
- else if (mLoginData->updateHost.empty()
- && !mLoginData->updateHosts.empty())
- {
- str = mLoginData->updateHosts[0];
- serverConfig.setValue("updateHost2", str);
- }
- if (!str.empty() && checkPath(str))
- {
- mLoginData->updateHost = str;
- *mUpdateHost = STD_MOVE(str);
- }
- else
- {
- mLoginData->updateHost.clear();
- (*mUpdateHost).clear();
- }
- }
-
- mLoginData->updateType = updateType;
- serverConfig.setValue("updateType", CAST_S32(updateType));
-
- mRegisterButton->setEnabled(false);
- mServerButton->setEnabled(false);
- mLoginButton->setEnabled(false);
-
- LoginDialog::savedPassword = mPassField->getText();
- if (mLoginData->remember)
- LoginDialog::savedPasswordKey = mServerName;
- else
- LoginDialog::savedPasswordKey = "-";
-}
-
-void LoginDialog::close()
-{
- client->setState(State::SWITCH_SERVER);
- Window::close();
-}
-
-void LoginDialog::mergeUpdateHosts()
-{
- HostsGroup group;
-
- group.name = mServer->defaultHostName;
- if (group.name.empty())
- {
- // TRANSLATORS: update hosts group default name
- group.name = _("default updates");
- }
- group.hosts = mLoginData->updateHosts;
- mServer->updateHosts.insert(mServer->updateHosts.begin(), group);
-}
diff --git a/src/gui/windows/logindialog.h b/src/gui/windows/logindialog.h
deleted file mode 100644
index c3178f079..000000000
--- a/src/gui/windows/logindialog.h
+++ /dev/null
@@ -1,113 +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_WINDOWS_LOGINDIALOG_H
-#define GUI_WINDOWS_LOGINDIALOG_H
-
-#include "gui/widgets/window.h"
-
-#include "listeners/actionlistener.h"
-#include "listeners/keylistener.h"
-
-class Button;
-class CheckBox;
-class DropDown;
-class Label;
-class LoginData;
-class ServerInfo;
-class TextField;
-class UpdateListModel;
-class UpdateTypeModel;
-
-/**
- * The login dialog.
- *
- * \ingroup Interface
- */
-class LoginDialog final : public Window,
- public ActionListener,
- public KeyListener
-{
- public:
- /**
- * Constructor
- *
- * @see Window::Window
- */
- LoginDialog(LoginData &data,
- ServerInfo *const server,
- std::string *const updateHost) A_NONNULL(3, 4);
-
- A_DELETE_COPY(LoginDialog)
-
- ~LoginDialog();
-
- void postInit() override final;
-
- /**
- * Called when receiving actions from the widgets.
- */
- void action(const ActionEvent &event) override final;
-
- /**
- * Called when a key is pressed in one of the text fields.
- */
- void keyPressed(KeyEvent &event) override final;
-
- void close() override final;
-
- static std::string savedPasswordKey;
- static std::string savedPassword;
-
- private:
- /**
- * Returns whether submit can be enabled. This is true in the login
- * state, when all necessary fields have some text.
- */
- bool canSubmit() const;
-
- void prepareUpdate();
-
- void mergeUpdateHosts();
-
- LoginData *mLoginData A_NONNULLPOINTER;
- ServerInfo *mServer A_NONNULLPOINTER;
-
- TextField *mUserField A_NONNULLPOINTER;
- TextField *mPassField A_NONNULLPOINTER;
- CheckBox *mKeepCheck A_NONNULLPOINTER;
- Label *mUpdateTypeLabel A_NONNULLPOINTER;
- UpdateTypeModel *mUpdateTypeModel A_NONNULLPOINTER;
- DropDown *mUpdateTypeDropDown A_NONNULLPOINTER;
- Button *mServerButton A_NONNULLPOINTER;
- Button *mLoginButton A_NONNULLPOINTER;
- Button *mRegisterButton A_NONNULLPOINTER;
- CheckBox *mCustomUpdateHost A_NONNULLPOINTER;
- TextField *mUpdateHostText A_NONNULLPOINTER;
- UpdateListModel *mUpdateListModel;
- DropDown *mUpdateHostDropDown;
-
- std::string *mUpdateHost;
- std::string mServerName;
-};
-
-#endif // GUI_WINDOWS_LOGINDIALOG_H
diff --git a/src/gui/windows/maileditwindow.cpp b/src/gui/windows/maileditwindow.cpp
deleted file mode 100644
index a47b284de..000000000
--- a/src/gui/windows/maileditwindow.cpp
+++ /dev/null
@@ -1,278 +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 "gui/windows/maileditwindow.h"
-
-#include "settings.h"
-
-#include "being/playerinfo.h"
-
-#include "gui/windows/inventorywindow.h"
-#include "gui/windows/itemamountwindow.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/containerplacer.h"
-#include "gui/widgets/inttextfield.h"
-#include "gui/widgets/itemcontainer.h"
-#include "gui/widgets/label.h"
-#include "gui/widgets/scrollarea.h"
-
-#include "resources/item/item.h"
-
-#include "net/mail2handler.h"
-#include "net/mailhandler.h"
-
-#include "utils/delete2.h"
-#include "utils/gettext.h"
-
-#include <climits>
-
-#include "debug.h"
-
-MailEditWindow *mailEditWindow = nullptr;
-
-MailEditWindow::MailEditWindow() :
- // TRANSLATORS: mail edit window name
- Window(_("Edit mail"), Modal_false, nullptr, "mailedit.xml"),
- ActionListener(),
- FocusListener(),
- // TRANSLATORS: mail edit window button
- mSendButton(new Button(this, _("Send"), "send", this)),
- // TRANSLATORS: mail edit window button
- mCloseButton(new Button(this, _("Close"), "close", this)),
- // TRANSLATORS: mail edit window button
- mAddButton(new Button(this, _("Add"), "add", this)),
- // TRANSLATORS: mail edit window label
- mToLabel(new Label(this, _("To:"))),
- // TRANSLATORS: mail edit window label
- mSubjectLabel(new Label(this, _("Subject:"))),
- // TRANSLATORS: mail edit window label
- mMoneyLabel(new Label(this, _("Money:"))),
- // TRANSLATORS: mail edit window label
- mItemLabel(new Label(this, _("Item:"))),
- // TRANSLATORS: mail edit window label
- mMessageLabel(new Label(this, _("Message:"))),
- mToField(new TextField(this)),
- mSubjectField(new TextField(this)),
- mMoneyField(new IntTextField(this, 0, 0,
- settings.enableNewMailSystem ? INT_MAX : 10000000)),
- mMessageField(new TextField(this)),
- mInventory(new Inventory(InventoryType::MailEdit,
- settings.enableNewMailSystem ? -1 : 1)),
- mItemContainer(new ItemContainer(this, mInventory)),
- mItemScrollArea(new ScrollArea(this, mItemContainer,
- fromBool(getOptionBool("showitemsbackground"), Opaque),
- "mailedit_listbackground.xml")),
- mUseMail2(settings.enableNewMailSystem)
-{
- setWindowName("MailEdit");
- setCloseButton(true);
- setResizable(true);
- setCloseButton(true);
- setSaveVisible(false);
- setStickyButtonLock(true);
- setVisible(Visible_true);
-
- setDefaultSize(380, 200, ImagePosition::CENTER);
- setMinWidth(200);
- setMinHeight(200);
- center();
-
- ContainerPlacer placer;
- placer = getPlacer(0, 0);
-
- mToField->setWidth(100);
- mSubjectField->setWidth(100);
- mMessageField->setWidth(100);
- mItemScrollArea->setHeight(100);
- mItemScrollArea->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
- mToField->addFocusListener(this);
-
- placer(0, 0, mToLabel);
- placer(1, 0, mToField, 3);
- placer(0, 1, mSubjectLabel);
- placer(1, 1, mSubjectField, 3);
- placer(0, 2, mMoneyLabel);
- placer(1, 2, mMoneyField, 3);
- placer(0, 3, mItemLabel);
- placer(1, 3, mItemScrollArea, 2, 2);
- placer(3, 4, mAddButton, 1);
-
- placer(0, 5, mMessageLabel);
- placer(1, 5, mMessageField, 3);
- placer(0, 6, mSendButton);
- placer(3, 6, mCloseButton);
-
- loadWindowState();
- if (mUseMail2)
- mSendButton->setEnabled(false);
- enableVisibleSound(true);
-}
-
-MailEditWindow::~MailEditWindow()
-{
- mailEditWindow = nullptr;
- delete2(mInventory);
-}
-
-void MailEditWindow::action(const ActionEvent &event)
-{
- const std::string &eventId = event.getId();
- if (eventId == "close")
- {
- close();
- }
- else if (eventId == "send")
- {
- sendMail();
- }
- else if (eventId == "add")
- {
- Item *const item = inventoryWindow->getSelectedItem();
-
- if (item == nullptr)
- return;
-
- ItemAmountWindow::showWindow(ItemAmountWindowUsage::MailAdd,
- this, item);
- }
-}
-
-void MailEditWindow::addItem(const Item *const item,
- const int amount)
-{
- if (item == nullptr)
- return;
- mInventory->addItem(item->getId(),
- item->getType(),
- amount,
- item->getRefine(),
- item->getColor(),
- item->getIdentified(),
- item->getDamaged(),
- item->getFavorite(),
- Equipm_false,
- Equipped_false);
-}
-
-void MailEditWindow::setSubject(const std::string &str)
-{
- mSubjectField->setText(str);
-}
-
-void MailEditWindow::setTo(const std::string &str)
-{
- mToField->setText(str);
- mSendButton->setEnabled(true);
-}
-
-void MailEditWindow::setMessage(const std::string &str)
-{
- mMessageField->setText(str);
-}
-
-void MailEditWindow::close()
-{
- if (mUseMail2)
- mail2Handler->cancelWriteMail();
- mailEditWindow = nullptr;
- scheduleDelete();
-}
-
-Inventory *MailEditWindow::getInventory() const
-{
- return mInventory;
-}
-
-void MailEditWindow::sendMail()
-{
- const int money = mMoneyField->getValue();
- std::string subject = mSubjectField->getText();
- if (subject.empty())
- {
- // TRANSLATORS: empty mail message subject
- subject.append(_("empty subject"));
- }
- if (mUseMail2)
- {
- mail2Handler->sendMail(mToField->getText(),
- subject,
- mMessageField->getText(),
- money);
- }
- else
- {
- if (money != 0)
- mailHandler->setAttachMoney(money);
- const Item *const tempItem = mInventory->getItem(0);
- if (tempItem != nullptr)
- {
- const Inventory *const inv = PlayerInfo::getInventory();
- if (inv != nullptr)
- {
- const Item *const item = inv->findItem(
- tempItem->getId(), ItemColor_one);
- if (item != nullptr)
- {
- mailHandler->setAttach(item->getInvIndex(),
- tempItem->getQuantity());
- }
- }
- }
-
- mailHandler->send(mToField->getText(),
- subject,
- mMessageField->getText());
- }
-}
-
-void MailEditWindow::updateItems()
-{
- mItemContainer->updateMatrix();
-}
-
-void MailEditWindow::focusLost(const Event &event)
-{
- if (!mUseMail2)
- return;
-
- if (event.getSource() == mToField)
- {
- const std::string to = mToField->getText();
- if (to != mail2Handler->getCheckedName())
- {
- mail2Handler->queueCheckName(MailQueueType::ValidateTo,
- to,
- std::string(),
- std::string(),
- 0);
- mSendButton->setEnabled(false);
- }
- else
- {
- mSendButton->setEnabled(true);
- }
- }
-}
-
-void MailEditWindow::validatedTo()
-{
- mSendButton->setEnabled(true);
-}
diff --git a/src/gui/windows/maileditwindow.h b/src/gui/windows/maileditwindow.h
deleted file mode 100644
index 2c6c5d0ef..000000000
--- a/src/gui/windows/maileditwindow.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 GUI_WINDOWS_MAILEDITWINDOW_H
-#define GUI_WINDOWS_MAILEDITWINDOW_H
-
-#include "gui/widgets/window.h"
-
-#include "listeners/actionlistener.h"
-#include "listeners/focuslistener.h"
-
-class Button;
-class IntTextField;
-class Inventory;
-class Item;
-class ItemContainer;
-class Label;
-class ScrollArea;
-class TextField;
-
-class MailEditWindow final : public Window,
- public ActionListener,
- public FocusListener
-{
- public:
- MailEditWindow();
-
- A_DELETE_COPY(MailEditWindow)
-
- ~MailEditWindow();
-
- void action(const ActionEvent &event) override final;
-
- void addItem(const Item *const item, const int amount);
-
- void setSubject(const std::string &str);
-
- void setTo(const std::string &str);
-
- void setMessage(const std::string &str);
-
- void close() override final;
-
- Inventory *getInventory() const A_WARN_UNUSED;
-
- void updateItems();
-
- void focusLost(const Event &event) override final;
-
- void validatedTo();
-
- private:
- void sendMail();
-
- Button *mSendButton;
- Button *mCloseButton;
- Button *mAddButton;
- Label *mToLabel;
- Label *mSubjectLabel;
- Label *mMoneyLabel;
- Label *mItemLabel;
- Label *mMessageLabel;
- TextField *mToField;
- TextField *mSubjectField;
- IntTextField *mMoneyField;
- TextField *mMessageField;
- Inventory *mInventory;
- ItemContainer *mItemContainer;
- ScrollArea *mItemScrollArea;
- bool mUseMail2;
-};
-
-extern MailEditWindow *mailEditWindow;
-
-#endif // GUI_WINDOWS_MAILEDITWINDOW_H
diff --git a/src/gui/windows/mailviewwindow.cpp b/src/gui/windows/mailviewwindow.cpp
deleted file mode 100644
index fbe0c9112..000000000
--- a/src/gui/windows/mailviewwindow.cpp
+++ /dev/null
@@ -1,269 +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 "gui/windows/mailviewwindow.h"
-
-#include "settings.h"
-
-#include "net/mail2handler.h"
-#include "net/mailhandler.h"
-
-#include "gui/mailmessage.h"
-
-#include "gui/windows/maileditwindow.h"
-#include "gui/windows/mailwindow.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/containerplacer.h"
-#include "gui/widgets/createwidget.h"
-#include "gui/widgets/itemcontainer.h"
-#include "gui/widgets/label.h"
-#include "gui/widgets/scrollarea.h"
-
-#include "utils/delete2.h"
-#include "utils/gettext.h"
-#include "utils/stringutils.h"
-
-#include "resources/inventory/inventory.h"
-#include "debug.h"
-
-MailViewWindow *mailViewWindow = nullptr;
-
-MailViewWindow::MailViewWindow(MailMessage *const message,
- const int itemsCount) :
- // TRANSLATORS: mail view window name
- Window(_("View mail"), Modal_false, nullptr, "mailview.xml"),
- ActionListener(),
- mMessage(message),
- mGetAttachButton(new Button(this,
- // TRANSLATORS: mail view attach / items button
- settings.enableNewMailSystem ? _("Get items") : _("Get attach"),
- "attach", this)),
- mGetMoneyButton(nullptr),
- // TRANSLATORS: mail view window button
- mCloseButton(new Button(this, _("Close"), "close", this)),
- mPrevButton(new Button(this, "<", "prev", this)),
- mNextButton(new Button(this, ">", "next", this)),
- // TRANSLATORS: mail view window button
- mReplyButton(new Button(this, _("Reply"), "reply", this)),
- // TRANSLATORS: mail view window label
- mTimeLabel(new Label(this, strprintf("%s %s", _("Time:"),
- message->strTime.c_str()))),
- mMoneyLabel(nullptr),
- // TRANSLATORS: mail view window label
- mFromLabel(new Label(this, strprintf("%s %s", _("From:"),
- message->sender.c_str()))),
- // TRANSLATORS: mail view window label
- mSubjectLabel(new Label(this, strprintf("%s %s", _("Subject:"),
- message->title.c_str()))),
- // TRANSLATORS: mail view window label
- mMessageLabel(new Label(this, strprintf("%s %s", _("Message:"),
- message->text.c_str()))),
- mInventory(new Inventory(InventoryType::MailView, itemsCount)),
- mItemContainer(new ItemContainer(this, mInventory)),
- mItemScrollArea(new ScrollArea(this, mItemContainer,
- fromBool(getOptionBool("showitemsbackground"), Opaque),
- "mailview_listbackground.xml")),
- mUseMail2(settings.enableNewMailSystem)
-{
- setWindowName("MailView");
- setCloseButton(true);
- setResizable(true);
- setSaveVisible(false);
- setStickyButtonLock(true);
- setVisible(Visible_true);
-
- setDefaultSize(380, 370, ImagePosition::CENTER);
- setMinWidth(200);
- setMinHeight(100);
- center();
- mItemScrollArea->setHeight(100);
-
- mItemScrollArea->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
-
- ContainerPlacer placer;
- placer = getPlacer(0, 0);
-
- int n = 0;
- placer(0, n++, mTimeLabel);
- placer(0, n++, mFromLabel);
- placer(0, n++, mSubjectLabel);
- if (message->money != 0)
- {
- mMoneyLabel = new Label(this, strprintf("%s %u",
- // TRANSLATORS: mail view window label
- _("Money:"),
- CAST_U32(message->money)));
- placer(0, n++, mMoneyLabel);
- }
- placer(0, n++, mMessageLabel);
- placer(0, n++, mItemScrollArea);
-
- if (mUseMail2 && message->money != 0)
- {
- mGetMoneyButton = new Button(this,
- // TRANSLATORS: mail view attached money button
- _("Get money"),
- "money", this);
- placer(0, n++, mGetMoneyButton);
- }
- placer(0, n++, mGetAttachButton);
- updateAttachButton();
-
- ContainerPlacer placer2;
- placer2 = getPlacer(0, n);
-
- placer2(0, 0, mPrevButton);
- placer2(1, 0, mNextButton);
- placer2(3, 0, mReplyButton);
- placer2(4, 0, mCloseButton);
-
- loadWindowState();
- enableVisibleSound(true);
-}
-
-MailViewWindow::~MailViewWindow()
-{
- if (mUseMail2)
- {
- mMessage = nullptr;
- }
- else
- {
- delete2(mMessage);
- delete2(mGetMoneyButton);
- }
- delete2(mInventory);
- mailViewWindow = nullptr;
-}
-
-void MailViewWindow::action(const ActionEvent &event)
-{
- const std::string &eventId = event.getId();
- if (eventId == "close")
- {
- scheduleDelete();
- }
- else if (eventId == "attach")
- {
- if (mUseMail2)
- {
- mail2Handler->requestItems(mailWindow->getOpenType(),
- mMessage->id);
- }
- else
- {
- mailHandler->getAttach(CAST_S32(mMessage->id));
- }
- }
- else if (eventId == "money")
- {
- if (mUseMail2)
- {
- mail2Handler->requestMoney(mailWindow->getOpenType(),
- mMessage->id);
- }
- }
- else if (eventId == "next")
- {
- if (mMessage != nullptr)
- mailWindow->viewNext(mMessage->id);
- }
- else if (eventId == "prev")
- {
- if (mMessage != nullptr)
- mailWindow->viewPrev(mMessage->id);
- }
- else if (eventId == "reply")
- {
- if (mMessage == nullptr)
- return;
- if (mailEditWindow != nullptr)
- mailEditWindow->scheduleDelete();
- CREATEWIDGETV0(mailEditWindow, MailEditWindow);
- mailEditWindow->setTo(mMessage->sender);
- mailEditWindow->setSubject("Re:" + mMessage->title);
- mailEditWindow->setMessage(">" + mMessage->text);
- scheduleDelete();
- }
-}
-
-Inventory *MailViewWindow::getInventory() const
-{
- return mInventory;
-}
-
-void MailViewWindow::updateAttachButton()
-{
- if ((mMessage->money != 0 && !mUseMail2) ||
- mInventory->getLastUsedSlot() != -1)
- {
- mGetAttachButton->setVisible(Visible_true);
- }
- else
- {
- mGetAttachButton->setVisible(Visible_false);
- }
-}
-
-void MailViewWindow::updateItems()
-{
- mItemContainer->updateMatrix();
- updateAttachButton();
-}
-
-void MailViewWindow::removeItems(const int64_t mailId)
-{
- if (mailId != mMessage->id)
- return;
- mInventory->clear();
- mMessage->type = static_cast<MailMessageType::Type>(
- CAST_S32(mMessage->type) | CAST_S32(MailMessageType::Item));
- mMessage->type = static_cast<MailMessageType::Type>(
- CAST_S32(mMessage->type) ^ CAST_S32(MailMessageType::Item));
- updateAttachButton();
- if (mailWindow != nullptr)
- mailWindow->refreshMailNames();
-}
-
-void MailViewWindow::removeMoney(const int64_t mailId)
-{
- if (mailId != mMessage->id)
- return;
- mMessage->type = static_cast<MailMessageType::Type>(
- CAST_S32(mMessage->type) | CAST_S32(MailMessageType::Money));
- mMessage->type = static_cast<MailMessageType::Type>(
- CAST_S32(mMessage->type) ^ CAST_S32(MailMessageType::Money));
-
- mMessage->money = 0;
-
- if (mMoneyLabel == nullptr)
- return;
-
- if (mGetMoneyButton != nullptr)
- mGetMoneyButton->setVisible(Visible_false);
-
- mMoneyLabel->setCaption(strprintf("%s %d",
- // TRANSLATORS: mail view window label
- _("Money:"),
- 0));
- if (mailWindow != nullptr)
- mailWindow->refreshMailNames();
-}
diff --git a/src/gui/windows/mailviewwindow.h b/src/gui/windows/mailviewwindow.h
deleted file mode 100644
index 19585de03..000000000
--- a/src/gui/windows/mailviewwindow.h
+++ /dev/null
@@ -1,80 +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 GUI_WINDOWS_MAILVIEWWINDOW_H
-#define GUI_WINDOWS_MAILVIEWWINDOW_H
-
-#include "gui/widgets/window.h"
-
-#include "listeners/actionlistener.h"
-
-class Button;
-class Inventory;
-class ItemContainer;
-class Label;
-class ScrollArea;
-
-struct MailMessage;
-
-class MailViewWindow final : public Window,
- public ActionListener
-{
- public:
- MailViewWindow(MailMessage *const message,
- const int itemsCount) A_NONNULL(2);
-
- A_DELETE_COPY(MailViewWindow)
-
- ~MailViewWindow();
-
- void action(const ActionEvent &event) override final;
-
- Inventory *getInventory() const A_WARN_UNUSED;
-
- void updateItems();
-
- void removeItems(const int64_t mailId);
-
- void removeMoney(const int64_t mailId);
-
- private:
- void updateAttachButton();
-
- MailMessage *mMessage;
- Button *mGetAttachButton;
- Button *mGetMoneyButton;
- Button *mCloseButton;
- Button *mPrevButton;
- Button *mNextButton;
- Button *mReplyButton;
- Label *mTimeLabel;
- Label *mMoneyLabel;
- Label *mFromLabel;
- Label *mSubjectLabel;
- Label *mMessageLabel;
- Inventory *mInventory;
- ItemContainer *mItemContainer;
- ScrollArea *mItemScrollArea;
- bool mUseMail2;
-};
-
-extern MailViewWindow *mailViewWindow;
-
-#endif // GUI_WINDOWS_MAILVIEWWINDOW_H
diff --git a/src/gui/windows/mailwindow.cpp b/src/gui/windows/mailwindow.cpp
deleted file mode 100644
index 9da69fb0a..000000000
--- a/src/gui/windows/mailwindow.cpp
+++ /dev/null
@@ -1,393 +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 "gui/windows/mailwindow.h"
-
-#include "settings.h"
-
-#include "enums/gui/layouttype.h"
-
-#include "net/mail2handler.h"
-#include "net/mailhandler.h"
-
-#include "gui/models/extendednamesmodel.h"
-
-#include "gui/mailmessage.h"
-
-#include "gui/windows/maileditwindow.h"
-#include "gui/windows/mailviewwindow.h"
-#include "gui/windows/setupwindow.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/containerplacer.h"
-#include "gui/widgets/createwidget.h"
-#include "gui/widgets/extendedlistbox.h"
-#include "gui/widgets/layout.h"
-#include "gui/widgets/scrollarea.h"
-
-#include "utils/delete2.h"
-#include "utils/dtor.h"
-#include "utils/foreach.h"
-#include "utils/gettext.h"
-#include "utils/stdmove.h"
-#include "utils/stringutils.h"
-
-#include "debug.h"
-
-MailWindow *mailWindow = nullptr;
-
-MailWindow::MailWindow() :
- // TRANSLATORS: mail window name
- Window(_("Mail"), Modal_false, nullptr, "mail.xml"),
- ActionListener(),
- mMessages(),
- mMessagesMap(),
- mMailModel(new ExtendedNamesModel),
- mListBox(CREATEWIDGETR(ExtendedListBox,
- this, mMailModel, "extendedlistbox.xml", 0)),
- mListScrollArea(new ScrollArea(this, mListBox,
- fromBool(getOptionBool("showlistbackground"), Opaque),
- "mail_listbackground.xml")),
- // TRANSLATORS: mail window button
- mRefreshButton(new Button(this, _("Refresh"), "refresh", this)),
- // TRANSLATORS: mail window button
- mNewButton(new Button(this, _("New"), "new", this)),
- // TRANSLATORS: mail window button
- mDeleteButton(new Button(this, _("Delete"), "delete", this)),
- mReturnButton(new Button(this,
- // TRANSLATORS: mail window button
- settings.enableNewMailSystem ? _("Get old") : _("Return"),
- "return", this)),
- // TRANSLATORS: mail window button
- mOpenButton(new Button(this, _("Open"), "open", this)),
- mOpenType(MailOpenType::Mail),
- mUseMail2(settings.enableNewMailSystem),
- mLastPage(false)
-{
- setWindowName("Mail");
- setCloseButton(true);
- setResizable(true);
- setCloseButton(true);
- setSaveVisible(true);
- setStickyButtonLock(true);
-
- if (setupWindow != nullptr)
- setupWindow->registerWindowForReset(this);
-
- setDefaultSize(310, 180, ImagePosition::CENTER);
- setMinWidth(310);
- setMinHeight(250);
- center();
-
- mListScrollArea->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
-
- ContainerPlacer placer;
- placer = getPlacer(0, 0);
-
- placer(0, 0, mListScrollArea, 4, 5).setPadding(3);
- placer(4, 0, mRefreshButton);
- placer(4, 1, mOpenButton);
- placer(4, 2, mNewButton);
- placer(4, 3, mDeleteButton);
- placer(4, 4, mReturnButton);
-
- Layout &layout = getLayout();
- layout.setRowHeight(0, LayoutType::SET);
-
- loadWindowState();
- enableVisibleSound(true);
-}
-
-MailWindow::~MailWindow()
-{
- delete_all(mMessages);
- delete2(mMailModel);
- delete2(mailViewWindow);
- delete2(mailEditWindow);
-}
-
-void MailWindow::action(const ActionEvent &event)
-{
- const std::string &eventId = event.getId();
- if (eventId == "refresh")
- {
- refreshMails();
- }
- else if (eventId == "new")
- {
- if (mailEditWindow == nullptr)
- {
- CREATEWIDGETV0(mailEditWindow, MailEditWindow);
- }
- }
- else if (eventId == "open")
- {
- const int sel = mListBox->getSelected();
- if (sel < 0)
- return;
- const MailMessage *const mail = mMessages[sel];
- if (mUseMail2)
- mail2Handler->readMail(mOpenType, mail->id);
- else
- mailHandler->readMessage(CAST_S32(mail->id));
- }
- else if (eventId == "delete")
- {
- const int sel = mListBox->getSelected();
- if (sel < 0)
- return;
- const MailMessage *const mail = mMessages[sel];
- if (mUseMail2)
- mail2Handler->deleteMail(mOpenType, mail->id);
- else
- mailHandler->deleteMessage(CAST_S32(mail->id));
- }
- else if (eventId == "return")
- {
- if (mUseMail2)
- {
- const size_t idx = mMessages.size();
- if (idx == 0)
- mail2Handler->refreshMailList(MailOpenType::Mail, 0);
- else
- mail2Handler->nextPage(mOpenType, mMessages[idx - 1]->id);
- }
- else
- {
- const int sel = mListBox->getSelected();
- if (sel < 0)
- return;
- const MailMessage *const mail = mMessages[sel];
- mailHandler->returnMessage(CAST_S32(mail->id));
- }
- }
-}
-
-void MailWindow::clear()
-{
- delete_all(mMessages);
- mMessages.clear();
- mMessagesMap.clear();
- mMailModel->clear();
- mListBox->setSelected(-1);
-}
-
-std::string MailWindow::getMailHeader(const MailMessage *const message) const
-{
- if (mUseMail2)
- {
- std::string header;
- if (message->read)
- header.append(" ");
- else
- header.append("U");
- const MailMessageType::Type type = message->type;
- if ((type & MailMessageType::Money) != 0)
- header.append("M");
- else
- header.append(" ");
- if ((type & MailMessageType::Item) != 0)
- header.append("I");
- else
- header.append(" ");
- header.append(" ").append(message->title);
- return STD_MOVE(header);
- }
- return strprintf("%s %s",
- message->read ? " " : "U",
- message->title.c_str());
-}
-
-void MailWindow::addMail(MailMessage *const message)
-{
- if (message == nullptr)
- return;
- mMessages.push_back(message);
- mMailModel->add(getMailHeader(message));
- mMessagesMap[message->id] = message;
-}
-
-void MailWindow::removeMail(const int64_t id)
-{
- std::map<int64_t, MailMessage*>::iterator it1 = mMessagesMap.find(id);
- if (it1 != mMessagesMap.end())
- mMessagesMap.erase(it1);
-
- mMailModel->clear();
-
- FOR_EACH (STD_VECTOR<MailMessage*>::iterator, it, mMessages)
- {
- MailMessage *message = *it;
- if ((message != nullptr) && message->id == id)
- {
- mMessages.erase(it);
- delete message;
- break;
- }
- }
-
- FOR_EACH (STD_VECTOR<MailMessage*>::iterator, it, mMessages)
- {
- MailMessage *message = *it;
- if (message != nullptr)
- mMailModel->add(getMailHeader(message));
- }
-}
-
-void MailWindow::showMessage(MailMessage *const mail,
- const int itemsCount)
-{
- if (mail == nullptr)
- return;
- const std::map<int64_t, MailMessage*>::const_iterator
- it = mMessagesMap.find(mail->id);
- if (it != mMessagesMap.end())
- {
- const MailMessage *const mail2 = (*it).second;
- mail->time = mail2->time;
- mail->strTime = mail2->strTime;
- }
- delete mailViewWindow;
- CREATEWIDGETV(mailViewWindow, MailViewWindow, mail,
- itemsCount);
-}
-
-void MailWindow::viewNext(const int64_t id)
-{
- FOR_EACH (STD_VECTOR<MailMessage*>::iterator, it, mMessages)
- {
- MailMessage *message = *it;
- if (message != nullptr &&
- message->id == id)
- {
- ++ it;
- if (it == mMessages.end())
- {
- it = mMessages.begin();
- mListBox->setSelected(0);
- }
- else
- {
- mListBox->setSelected(mListBox->getSelected() + 1);
- }
- message = *it;
- if (mUseMail2)
- mail2Handler->readMail(mOpenType, message->id);
- else
- mailHandler->readMessage(CAST_S32(message->id));
- return;
- }
- }
-}
-
-void MailWindow::viewPrev(const int64_t id)
-{
- FOR_EACH (STD_VECTOR<MailMessage*>::iterator, it, mMessages)
- {
- MailMessage *message = *it;
- if (message != nullptr &&
- message->id == id)
- {
- if (it == mMessages.begin())
- {
- it = mMessages.end();
- mListBox->setSelected(CAST_S32(mMessages.size()) - 1);
- }
- else
- {
- mListBox->setSelected(mListBox->getSelected() - 1);
- }
- -- it;
- message = *it;
- if (mUseMail2)
- mail2Handler->readMail(mOpenType, message->id);
- else
- mailHandler->readMessage(CAST_S32(message->id));
- return;
- }
- }
-}
-
-void MailWindow::mouseClicked(MouseEvent &event)
-{
- if (event.getButton() == MouseButton::LEFT)
- {
- event.consume();
- if (event.getClickCount() == 2 &&
- event.getSource() == mListBox)
- {
- action(ActionEvent(mListBox, "open"));
- }
- }
-}
-
-void MailWindow::postConnection()
-{
- refreshMails();
-}
-
-void MailWindow::refreshMails()
-{
- if (mUseMail2)
- {
- clear();
- mail2Handler->refreshMailList(MailOpenType::Mail, 0);
- mLastPage = false;
- mReturnButton->setEnabled(true);
- }
- else
- {
- mailHandler->refresh();
- }
-}
-
-void MailWindow::createMail(const std::string &to)
-{
- if (mailEditWindow != nullptr)
- return;
-
- CREATEWIDGETV0(mailEditWindow, MailEditWindow);
- mailEditWindow->setTo(to);
-}
-
-MailMessage *MailWindow::findMail(const int64_t id)
-{
- std::map<int64_t, MailMessage*>::iterator it = mMessagesMap.find(id);
- if (it != mMessagesMap.end())
- return (*it).second;
- return nullptr;
-}
-
-void MailWindow::setLastPage()
-{
- mLastPage = true;
- mReturnButton->setEnabled(false);
-}
-
-void MailWindow::refreshMailNames()
-{
- mMailModel->clear();
- FOR_EACH (STD_VECTOR<MailMessage*>::iterator, it, mMessages)
- {
- MailMessage *message = *it;
- if (message != nullptr)
- mMailModel->add(getMailHeader(message));
- }
-}
diff --git a/src/gui/windows/mailwindow.h b/src/gui/windows/mailwindow.h
deleted file mode 100644
index c99236499..000000000
--- a/src/gui/windows/mailwindow.h
+++ /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/>.
- */
-
-#ifndef GUI_WINDOWS_MAILWINDOW_H
-#define GUI_WINDOWS_MAILWINDOW_H
-
-#include "gui/widgets/window.h"
-
-#include "enums/net/mailopentype.h"
-
-#include "listeners/actionlistener.h"
-
-class Button;
-class ExtendedListBox;
-class ExtendedNamesModel;
-class ScrollArea;
-
-struct MailMessage;
-
-/**
- * A dialog to choose between buying or selling at a shop.
- *
- * \ingroup Interface
- */
-class MailWindow final : public Window,
- public ActionListener
-{
- public:
- MailWindow();
-
- A_DELETE_COPY(MailWindow)
-
- ~MailWindow();
-
- void action(const ActionEvent &event) override final;
-
- void addMail(MailMessage *const message);
-
- void clear() override final;
-
- void showMessage(MailMessage *const mail,
- const int itemsCount);
-
- void removeMail(const int64_t id);
-
- void viewNext(const int64_t id);
-
- void viewPrev(const int64_t id);
-
- void mouseClicked(MouseEvent &event) override final;
-
- void postConnection();
-
- void createMail(const std::string &to);
-
- MailMessage *findMail(const int64_t id) A_WARN_UNUSED;
-
- void setOpenType(const MailOpenTypeT &type)
- { mOpenType = type; }
-
- MailOpenTypeT getOpenType() const A_WARN_UNUSED
- { return mOpenType; }
-
- void setLastPage();
-
- void refreshMailNames();
-
- private:
- void refreshMails();
-
- std::string getMailHeader(const MailMessage *const message) const
- A_WARN_UNUSED A_NONNULL(2);
-
- STD_VECTOR<MailMessage*> mMessages;
- std::map<int64_t, MailMessage*> mMessagesMap;
- ExtendedNamesModel *mMailModel;
- ExtendedListBox *mListBox;
- ScrollArea *mListScrollArea;
- Button *mRefreshButton;
- Button *mNewButton;
- Button *mDeleteButton;
- Button *mReturnButton;
- Button *mOpenButton;
- MailOpenTypeT mOpenType;
- bool mUseMail2;
- bool mLastPage;
-};
-
-extern MailWindow *mailWindow;
-
-#endif // GUI_WINDOWS_MAILWINDOW_H
diff --git a/src/gui/windows/minimap.cpp b/src/gui/windows/minimap.cpp
deleted file mode 100644
index 7f48f4a10..000000000
--- a/src/gui/windows/minimap.cpp
+++ /dev/null
@@ -1,540 +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 "gui/windows/minimap.h"
-
-#include "actormanager.h"
-#include "configuration.h"
-#include "party.h"
-#include "settings.h"
-
-#include "being/localplayer.h"
-
-#include "enums/resources/map/blockmask.h"
-
-#include "fs/virtfs/fs.h"
-
-#include "gui/popupmanager.h"
-#include "gui/viewport.h"
-#include "gui/userpalette.h"
-
-#include "gui/popups/popupmenu.h"
-#include "gui/popups/textpopup.h"
-
-#include "gui/windows/setupwindow.h"
-
-#include "resources/imagehelper.h"
-
-#include "resources/image/image.h"
-
-#include "resources/map/map.h"
-#include "resources/map/metatile.h"
-
-#include "resources/loaders/imageloader.h"
-
-#include "utils/gettext.h"
-#include "utils/foreach.h"
-#include "utils/sdlcheckutils.h"
-#include "utils/stdmove.h"
-
-#include "debug.h"
-
-Minimap *minimap = nullptr;
-bool Minimap::mShow = true;
-
-Minimap::Minimap() :
- // TRANSLATORS: mini map window name
- Window(_("Map"), Modal_false, nullptr, "map.xml"),
- mWidthProportion(0.5),
- mHeightProportion(0.5),
- mMapImage(nullptr),
- mMapOriginX(0),
- mMapOriginY(0),
- mCustomMapImage(false),
- mAutoResize(config.getBoolValue("autoresizeminimaps"))
-{
- setWindowName("Minimap");
- mShow = config.getValueBool(getWindowName() + "Show", true);
-
- config.addListener("autoresizeminimaps", this);
-
- setDefaultSize(5, 25, 100, 100);
- // set this to false as the minimap window size is changed
- // depending on the map size
- setResizable(true);
- if (setupWindow != nullptr)
- setupWindow->registerWindowForReset(this);
-
- setDefaultVisible(true);
- setSaveVisible(true);
-
- setStickyButton(true);
- setSticky(false);
-
- loadWindowState();
- setVisible(fromBool(mShow, Visible), isSticky());
- enableVisibleSound(true);
-}
-
-Minimap::~Minimap()
-{
- config.setValue(getWindowName() + "Show", mShow);
- config.removeListeners(this);
- CHECKLISTENERS
- deleteMapImage();
-}
-
-void Minimap::deleteMapImage()
-{
- if (mMapImage != nullptr)
- {
- if (mCustomMapImage)
- delete mMapImage;
- else
- mMapImage->decRef();
- mMapImage = nullptr;
- }
-}
-
-void Minimap::setMap(const Map *const map)
-{
- BLOCK_START("Minimap::setMap")
- std::string caption;
-
- if (map != nullptr)
- caption = map->getName();
-
- if (caption.empty())
- {
- // TRANSLATORS: mini map window name
- caption = _("Map");
- }
-
- setCaption(caption);
- deleteMapImage();
-
- if (map != nullptr)
- {
- if (config.getBoolValue("showExtMinimaps"))
- {
- SDL_Surface *const surface = MSDL_CreateRGBSurface(SDL_SWSURFACE,
- map->getWidth(), map->getHeight(), 32,
- 0x00ff0000, 0x0000ff00, 0x000000ff, 0x00000000);
- if (surface == nullptr)
- {
- if (!isSticky())
- setVisible(Visible_false);
- BLOCK_END("Minimap::setMap")
- return;
- }
-
- // I'm not sure if the locks are necessary since it's a SWSURFACE
- SDL_LockSurface(surface);
- int* data = static_cast<int*>(surface->pixels);
- if (data == nullptr)
- {
- if (!isSticky())
- setVisible(Visible_false);
- BLOCK_END("Minimap::setMap")
- return;
- }
- const int size = surface->h * surface->w;
- const int mask = (BlockMask::WALL |
- BlockMask::AIR |
- BlockMask::WATER |
- BlockMask::PLAYERWALL);
-
- for (int ptr = 0; ptr < size; ptr ++)
- {
- *(data ++) = (map->mMetaTiles[ptr].blockmask & mask) != 0 ?
- 0x0 : 0x00ffffff;
- }
-
- SDL_UnlockSurface(surface);
-
- mMapImage = imageHelper->loadSurface(surface);
- mMapImage->setAlpha(settings.guiAlpha);
- mCustomMapImage = true;
- MSDL_FreeSurface(surface);
- }
- else
- {
- std::string tempname = pathJoin(paths.getStringValue("minimaps"),
- map->getFilename()).append(".png");
-
- std::string minimapName = map->getProperty("minimap");
-
- if (minimapName.empty() && VirtFs::exists(tempname))
- minimapName = tempname;
-
- if (minimapName.empty())
- {
- tempname = pathJoin("graphics/minimaps",
- map->getFilename()).append(".png");
- if (VirtFs::exists(tempname))
- minimapName = STD_MOVE(tempname);
- }
-
- if (!minimapName.empty())
- mMapImage = Loader::getImage(minimapName);
- else
- mMapImage = nullptr;
- mCustomMapImage = false;
- }
- }
-
- if ((mMapImage != nullptr) && (map != nullptr))
- {
- const int width = mMapImage->mBounds.w + 2 * getPadding();
- const int height = mMapImage->mBounds.h
- + getTitleBarHeight() + getPadding();
- const int mapWidth = mMapImage->mBounds.w < 100 ? width : 100;
- const int mapHeight = mMapImage->mBounds.h < 100 ? height : 100;
- const int minWidth = mapWidth > 310 ? 310 : mapWidth;
- const int minHeight = mapHeight > 220 ? 220 : mapHeight;
-
- setMinWidth(minWidth);
- setMinHeight(minHeight);
-
- mWidthProportion = static_cast<float>(
- mMapImage->mBounds.w) / static_cast<float>(map->getWidth());
- mHeightProportion = static_cast<float>(
- mMapImage->mBounds.h) / static_cast<float>(map->getHeight());
-
- setMaxWidth(width);
- setMaxHeight(height);
- if (mAutoResize)
- {
- setWidth(width);
- setHeight(height);
- }
-
- const Rect &rect = mDimension;
- setDefaultSize(rect.x, rect.y, rect.width, rect.height);
- resetToDefaultSize();
-
- if (mShow)
- setVisible(Visible_true);
- }
- else
- {
- if (!isSticky())
- setVisible(Visible_false);
- }
- BLOCK_END("Minimap::setMap")
-}
-
-void Minimap::toggle()
-{
- setVisible(fromBool(!isWindowVisible(), Visible), isSticky());
- mShow = isWindowVisible();
-}
-
-void Minimap::draw(Graphics *const graphics)
-{
- BLOCK_START("Minimap::draw")
-
- Window::draw(graphics);
- draw2(graphics);
-}
-
-void Minimap::safeDraw(Graphics *const graphics)
-{
- BLOCK_START("Minimap::draw")
-
- Window::safeDraw(graphics);
- draw2(graphics);
-}
-
-void Minimap::draw2(Graphics *const graphics)
-{
- if (userPalette == nullptr ||
- localPlayer == nullptr ||
- viewport == nullptr)
- {
- BLOCK_END("Minimap::draw")
- return;
- }
-
- const Rect a = getChildrenArea();
-
- graphics->pushClipArea(a);
-
- if (actorManager == nullptr)
- {
- BLOCK_END("Minimap::draw")
- return;
- }
-
- mMapOriginX = 0;
- mMapOriginY = 0;
-
- if (mMapImage != nullptr)
- {
- const SDL_Rect &rect = mMapImage->mBounds;
- const int w = rect.w;
- const int h = rect.h;
- if (w > a.width || h > a.height)
- {
- mMapOriginX = (a.width / 2) - (localPlayer->mPixelX +
- viewport->getCameraRelativeX() * mWidthProportion) / 32;
-
- mMapOriginY = (a.height / 2) - (localPlayer->mPixelY +
- viewport->getCameraRelativeY() * mHeightProportion) / 32;
-
- const int minOriginX = a.width - w;
- const int minOriginY = a.height - h;
-
- if (mMapOriginX < minOriginX)
- mMapOriginX = minOriginX;
- if (mMapOriginY < minOriginY)
- mMapOriginY = minOriginY;
- if (mMapOriginX > 0)
- mMapOriginX = 0;
- if (mMapOriginY > 0)
- mMapOriginY = 0;
- }
-
- graphics->drawImage(mMapImage, mMapOriginX, mMapOriginY);
- }
-
- const ActorSprites &actors = actorManager->getAll();
- FOR_EACH (ActorSpritesConstIterator, it, actors)
- {
- if (((*it) == nullptr) || (*it)->getType() == ActorType::FloorItem)
- continue;
-
- const Being *const being = static_cast<const Being *>(*it);
- if (being == nullptr)
- continue;
-
- int dotSize = 2;
- UserColorIdT type = UserColorId::PC;
-
- if (being == localPlayer)
- {
- type = UserColorId::SELF;
- dotSize = 3;
- }
- else if (being->isGM())
- {
- type = UserColorId::GM;
- }
- else if (being->getGuild() == localPlayer->getGuild()
- || being->getGuildName() == localPlayer->getGuildName())
- {
- type = UserColorId::GUILD;
- }
- else
- {
- switch (being->getType())
- {
- case ActorType::Monster:
- type = UserColorId::MONSTER;
- break;
-
- case ActorType::Npc:
- type = UserColorId::NPC;
- break;
-
- case ActorType::Portal:
- type = UserColorId::PORTAL_HIGHLIGHT;
- break;
-
- case ActorType::Pet:
- type = UserColorId::PET;
- break;
- case ActorType::Mercenary:
- type = UserColorId::MERCENARY;
- break;
-
- case ActorType::Homunculus:
- type = UserColorId::HOMUNCULUS;
- break;
-
- case ActorType::SkillUnit:
- type = UserColorId::SKILLUNIT;
- break;
- case ActorType::Avatar:
- case ActorType::Unknown:
- case ActorType::Player:
- case ActorType::FloorItem:
- case ActorType::Elemental:
- default:
- continue;
- }
- }
-
- if (userPalette != nullptr)
- graphics->setColor(userPalette->getColor(type));
-
- const int offsetHeight = CAST_S32(static_cast<float>(
- dotSize - 1) * mHeightProportion);
- const int offsetWidth = CAST_S32(static_cast<float>(
- dotSize - 1) * mWidthProportion);
- graphics->fillRectangle(Rect(
- (being->mPixelX * mWidthProportion) / 32
- + mMapOriginX - offsetWidth,
- (being->mPixelY * mHeightProportion) / 32
- + mMapOriginY - offsetHeight, dotSize, dotSize));
- }
-
- if (localPlayer->isInParty())
- {
- const Party *const party = localPlayer->getParty();
- if (party != nullptr)
- {
- const PartyMember *const m = party->getMember(
- localPlayer->getName());
- const Party::MemberList *const members = party->getMembers();
- if (m != nullptr)
- {
- const std::string curMap = m->getMap();
- Party::MemberList::const_iterator it = members->begin();
- const Party::MemberList::const_iterator
- it_end = members->end();
- while (it != it_end)
- {
- const PartyMember *const member = *it;
- if ((member != nullptr) && member->getMap() == curMap
- && member->getOnline() && member != m)
- {
- if (userPalette != nullptr)
- {
- graphics->setColor(userPalette->getColor(
- UserColorId::PARTY));
- }
-
- const int offsetHeight = CAST_S32(
- mHeightProportion);
- const int offsetWidth = CAST_S32(
- mWidthProportion);
-
- graphics->fillRectangle(Rect(
- CAST_S32(member->getX()
- * mWidthProportion) + mMapOriginX - offsetWidth,
- CAST_S32(member->getY()
- * mHeightProportion) + mMapOriginY - offsetHeight,
- 2, 2));
- }
- ++ it;
- }
- }
- }
- }
-
- const int gw = graphics->getWidth();
- const int gh = graphics->getHeight();
- int x = (localPlayer->mPixelX - (gw / 2)
- + viewport->getCameraRelativeX())
- * mWidthProportion / 32 + mMapOriginX;
- int y = (localPlayer->mPixelY - (gh / 2)
- + viewport->getCameraRelativeY())
- * mHeightProportion / 32 + mMapOriginY;
-
- const int w = CAST_S32(static_cast<float>(
- gw) * mWidthProportion / 32);
- const int h = CAST_S32(static_cast<float>(
- gh) * mHeightProportion / 32);
-
- if (w <= a.width)
- {
- if (x < 0 && (w != 0))
- x = 0;
- if (x + w > a.width)
- x = a.width - w;
- }
- if (h <= a.height)
- {
- if (y < 0 && (h != 0))
- y = 0;
- if (y + h > a.height)
- y = a.height - h;
- }
-
- graphics->setColor(userPalette->getColor(UserColorId::PC));
- graphics->drawRectangle(Rect(x, y, w, h));
- graphics->popClipArea();
- BLOCK_END("Minimap::draw")
-}
-
-void Minimap::mousePressed(MouseEvent &event)
-{
- if (event.getButton() == MouseButton::RIGHT)
- return;
- Window::mousePressed(event);
-}
-
-void Minimap::mouseReleased(MouseEvent &event)
-{
- Window::mouseReleased(event);
-
- if ((localPlayer == nullptr) || (popupManager == nullptr))
- return;
-
- if (event.getButton() == MouseButton::LEFT)
- {
- int x = event.getX();
- int y = event.getY();
- screenToMap(x, y);
-
- localPlayer->navigateTo(x, y);
- }
- else if (event.getButton() == MouseButton::RIGHT)
- {
- int x = event.getX();
- int y = event.getY();
- screenToMap(x, y);
- popupMenu->showMapPopup(viewport->mMouseX,
- viewport->mMouseY,
- x, y,
- true);
- }
-}
-
-void Minimap::mouseMoved(MouseEvent &event)
-{
- Window::mouseMoved(event);
- const int x = event.getX();
- const int y = event.getY();
- const Rect &rect = mDimension;
- textPopup->show(x + rect.x, y + rect.y, mCaption);
-}
-
-void Minimap::mouseExited(MouseEvent &event)
-{
- Window::mouseExited(event);
- textPopup->hide();
-}
-
-void Minimap::screenToMap(int &x, int &y)
-{
- const Rect a = getChildrenArea();
- x = (x - a.x - mMapOriginX + mWidthProportion) / mWidthProportion;
- y = (y - a.y - mMapOriginY + mHeightProportion) / mHeightProportion;
-}
-
-void Minimap::optionChanged(const std::string &name)
-{
- if (name == "autoresizeminimaps")
- mAutoResize = config.getBoolValue("autoresizeminimaps");
-}
diff --git a/src/gui/windows/minimap.h b/src/gui/windows/minimap.h
deleted file mode 100644
index 5aad6e8be..000000000
--- a/src/gui/windows/minimap.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 GUI_WINDOWS_MINIMAP_H
-#define GUI_WINDOWS_MINIMAP_H
-
-#include "gui/widgets/window.h"
-
-class Image;
-class Map;
-
-/**
- * Minimap window. Shows a minimap image and the name of the current map.
- *
- * The name of the map is defined by the map property "name". The minimap image
- * is defined by the map property "minimap". The path to the image should be
- * given relative to the root of the client data.
- *
- * \ingroup Interface
- */
-class Minimap final : public Window, public ConfigListener
-{
- public:
- Minimap();
-
- A_DELETE_COPY(Minimap)
-
- ~Minimap();
-
- /**
- * Sets the map image that should be displayed.
- */
- void setMap(const Map *const map);
-
- /**
- * Toggles the displaying of the minimap.
- */
- void toggle();
-
- /**
- * Draws the minimap.
- */
- void draw(Graphics *const graphics) override final A_NONNULL(2);
-
- void safeDraw(Graphics *const graphics) override final A_NONNULL(2);
-
- void draw2(Graphics *const graphics) A_NONNULL(2);
-
- void mouseMoved(MouseEvent &event) override final;
-
- void mouseReleased(MouseEvent &event) override final;
-
- void mousePressed(MouseEvent &event) override final;
-
- void mouseExited(MouseEvent &event) override final;
-
- void screenToMap(int &x, int &y);
-
- void optionChanged(const std::string &name) override final;
-
- private:
- void deleteMapImage();
-
- float mWidthProportion;
- float mHeightProportion;
- Image *mMapImage;
- int mMapOriginX;
- int mMapOriginY;
- bool mCustomMapImage;
- bool mAutoResize;
- static bool mShow;
-};
-
-extern Minimap *minimap;
-
-#endif // GUI_WINDOWS_MINIMAP_H
diff --git a/src/gui/windows/ministatuswindow.cpp b/src/gui/windows/ministatuswindow.cpp
deleted file mode 100644
index e596f1fae..000000000
--- a/src/gui/windows/ministatuswindow.cpp
+++ /dev/null
@@ -1,594 +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 "gui/windows/ministatuswindow.h"
-
-#include "configuration.h"
-
-#include "being/localplayer.h"
-#include "being/playerinfo.h"
-
-#include "gui/popupmanager.h"
-#include "gui/skin.h"
-
-#include "gui/popups/popupmenu.h"
-#include "gui/popups/statuspopup.h"
-#include "gui/popups/textpopup.h"
-
-#include "gui/windows/statuswindow.h"
-
-#include "gui/widgets/createwidget.h"
-#include "gui/widgets/progressbar.h"
-
-#include "net/playerhandler.h"
-
-#include "resources/inventory/inventory.h"
-
-#include "resources/sprite/animatedsprite.h"
-
-#include "utils/delete2.h"
-#include "utils/dtor.h"
-#include "utils/foreach.h"
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-MiniStatusWindow *miniStatusWindow = nullptr;
-extern volatile int tick_time;
-
-typedef STD_VECTOR <ProgressBar*>::const_iterator ProgressBarVectorCIter;
-
-MiniStatusWindow::MiniStatusWindow() :
- Window("MiniStatus", Modal_false, nullptr, "ministatus.xml"),
- InventoryListener(),
- AttributeListener(),
- StatListener(),
- ArrowsListener(),
- UpdateStatusListener(),
- mBars(),
- mBarNames(),
- mIcons(),
- mHpBar(createBar(0, 100, 0, ThemeColorId::HP_BAR, ProgressColorId::PROG_HP,
- "hpprogressbar.xml", "hpprogressbar_fill.xml",
- // TRANSLATORS: status bar name
- "hp bar", _("health bar"))),
- mMpBar(createBar(0, 100, 0, playerHandler->canUseMagic()
- ? ThemeColorId::MP_BAR : ThemeColorId::NO_MP_BAR,
- playerHandler->canUseMagic()
- ? ProgressColorId::PROG_MP : ProgressColorId::PROG_NO_MP,
- playerHandler->canUseMagic()
- ? "mpprogressbar.xml" : "nompprogressbar.xml",
- playerHandler->canUseMagic()
- ? "mpprogressbar_fill.xml" : "nompprogressbar_fill.xml",
- // TRANSLATORS: status bar name
- "mp bar", _("mana bar"))),
- mXpBar(createBar(0, 100, 0,
- ThemeColorId::XP_BAR, ProgressColorId::PROG_EXP,
- "xpprogressbar.xml", "xpprogressbar_fill.xml",
- // TRANSLATORS: status bar name
- "xp bar", _("experience bar"))),
- mJobBar(nullptr),
- mWeightBar(createBar(0, 140, 0, ThemeColorId::WEIGHT_BAR,
- ProgressColorId::PROG_WEIGHT,
- "weightprogressbar.xml", "weightprogressbar_fill.xml",
- // TRANSLATORS: status bar name
- "weight bar", _("weight bar"))),
- mInvSlotsBar(createBar(0, 45, 0,
- ThemeColorId::SLOTS_BAR, ProgressColorId::PROG_INVY_SLOTS,
- "slotsprogressbar.xml", "slotsprogressbar_fill.xml",
- "inventory slots bar",
- // TRANSLATORS: status bar name
- _("inventory slots bar"))),
- mMoneyBar(createBar(0, 130, 0, ThemeColorId::MONEY_BAR,
- ProgressColorId::PROG_MONEY,
- "moneyprogressbar.xml", "moneyprogressbar_fill.xml",
- // TRANSLATORS: status bar name
- "money bar", _("money bar"))),
- mArrowsBar(createBar(0, 50, 0, ThemeColorId::ARROWS_BAR,
- ProgressColorId::PROG_ARROWS,
- "arrowsprogressbar.xml", "arrowsprogressbar_fill.xml",
- // TRANSLATORS: status bar name
- "arrows bar", _("arrows bar"))),
- mStatusBar(createBar(100, (config.getIntValue("fontSize") > 16
- ? 270 : 180), 0, ThemeColorId::STATUS_BAR,
- ProgressColorId::PROG_STATUS,
- "statusprogressbar.xml", "statusprogressbar_fill.xml",
- // TRANSLATORS: status bar name
- "status bar", _("status bar"))),
- mStatusPopup(CREATEWIDGETR0(StatusPopup)),
- mSpacing(mSkin != nullptr ? mSkin->getOption("spacing", 3) : 3),
- mIconPadding(mSkin != nullptr ? mSkin->getOption("iconPadding", 3) : 3),
- mIconSpacing(mSkin != nullptr ? mSkin->getOption("iconSpacing", 2) : 2),
- mMaxX(0)
-{
- StatusWindow::updateHPBar(mHpBar);
-
- if (statusWindow != nullptr)
- statusWindow->updateMPBar(mMpBar);
-
- const bool job = serverConfig.getValueBool("showJob", true);
-
- StatusWindow::updateXPBar(mXpBar);
-
- if (job)
- {
- mJobBar = createBar(0, 100, 0,
- ThemeColorId::JOB_BAR,
- ProgressColorId::PROG_JOB,
- "jobprogressbar.xml", "jobprogressbar_fill.xml",
- // TRANSLATORS: status bar name
- "job bar", _("job bar"));
- StatusWindow::updateJobBar(mJobBar);
- }
-
- loadBars();
- updateBars();
-
- setVisible(Visible_true);
- addMouseListener(this);
- Inventory *const inv = PlayerInfo::getInventory();
- if (inv != nullptr)
- inv->addInventoyListener(this);
-
- StatusWindow::updateMoneyBar(mMoneyBar);
- StatusWindow::updateArrowsBar(mArrowsBar);
- updateStatus();
-}
-
-MiniStatusWindow::~MiniStatusWindow()
-{
- delete2(mStatusPopup);
- delete_all(mIcons);
- mIcons.clear();
-
- Inventory *const inv = PlayerInfo::getInventory();
- if (inv != nullptr)
- inv->removeInventoyListener(this);
-
- FOR_EACH (ProgressBarVectorCIter, it, mBars)
- {
- ProgressBar *bar = *it;
- if (bar == nullptr)
- continue;
- if (bar->mVisible == Visible_false)
- delete bar;
- }
- mBars.clear();
-}
-
-ProgressBar *MiniStatusWindow::createBar(const float progress,
- const int width,
- const int height,
- const ThemeColorIdT textColor,
- const ProgressColorIdT backColor,
- const std::string &restrict skin,
- const std::string &restrict skinFill,
- const std::string &restrict name,
- const std::string &restrict
- description)
-{
- ProgressBar *const bar = new ProgressBar(this,
- progress, width, height, backColor, skin, skinFill);
- bar->setActionEventId(name);
- bar->setId(description);
- bar->setColor(getThemeColor(textColor), getThemeColor(textColor + 1));
- mBars.push_back(bar);
- mBarNames[name] = bar;
- return bar;
-}
-
-void MiniStatusWindow::updateBars()
-{
- int x = 0;
- const ProgressBar *lastBar = nullptr;
- FOR_EACH (ProgressBarVectorCIter, it, mBars)
- remove(*it);
-
- FOR_EACH (ProgressBarVectorCIter, it, mBars)
- {
- ProgressBar *const bar = *it;
- if (bar == nullptr)
- continue;
- if (bar->mVisible == Visible_true)
- {
- bar->setPosition(x, 0);
- add(bar);
- x += bar->getWidth() + mSpacing;
- lastBar = bar;
- }
- }
-
- if (lastBar != nullptr)
- {
- setContentSize(lastBar->getX() + lastBar->getWidth(),
- lastBar->getY() + lastBar->getHeight());
- }
- mMaxX = x;
-}
-
-void MiniStatusWindow::setIcon(const int index, AnimatedSprite *const sprite)
-{
- if (index >= CAST_S32(mIcons.size()))
- mIcons.resize(index + 1, nullptr);
-
- delete mIcons[index];
- mIcons[index] = sprite;
-}
-
-void MiniStatusWindow::eraseIcon(const int index)
-{
- if (index < CAST_S32(mIcons.size()))
- {
- delete mIcons[index];
- mIcons.erase(mIcons.begin() + index);
- }
-}
-
-void MiniStatusWindow::drawIcons(Graphics *const graphics)
-{
- // Draw icons
- int icon_x = mMaxX + mIconPadding;
- for (size_t i = 0, sz = mIcons.size(); i < sz; i ++)
- {
- const AnimatedSprite *const icon = mIcons[i];
- if (icon != nullptr)
- {
- icon->draw(graphics, icon_x, mIconPadding);
- icon_x += mIconSpacing + icon->getWidth();
- }
- }
-}
-
-void MiniStatusWindow::statChanged(const AttributesT id A_UNUSED,
- const int oldVal1 A_UNUSED,
- const int oldVal2 A_UNUSED)
-{
- if (statusWindow != nullptr)
- statusWindow->updateMPBar(mMpBar);
- StatusWindow::updateJobBar(mJobBar);
-}
-
-void MiniStatusWindow::attributeChanged(const AttributesT id,
- const int64_t oldVal A_UNUSED,
- const int64_t newVal A_UNUSED)
-{
- PRAGMA45(GCC diagnostic push)
- PRAGMA45(GCC diagnostic ignored "-Wswitch-enum")
- switch (id)
- {
- case Attributes::PLAYER_HP:
- case Attributes::PLAYER_MAX_HP:
- StatusWindow::updateHPBar(mHpBar);
- break;
- case Attributes::PLAYER_MP:
- case Attributes::PLAYER_MAX_MP:
- statusWindow->updateMPBar(mMpBar);
- break;
- case Attributes::PLAYER_EXP:
- case Attributes::PLAYER_EXP_NEEDED:
- StatusWindow::updateXPBar(mXpBar);
- break;
- case Attributes::TOTAL_WEIGHT:
- case Attributes::MAX_WEIGHT:
- StatusWindow::updateWeightBar(mWeightBar);
- break;
- case Attributes::MONEY:
- StatusWindow::updateMoneyBar(mMoneyBar);
- break;
- default:
- break;
- }
- PRAGMA45(GCC diagnostic pop)
-}
-
-void MiniStatusWindow::updateStatus()
-{
- if (statusWindow != nullptr)
- statusWindow->updateStatusBar(mStatusBar);
- if ((mStatusPopup != nullptr) && mStatusPopup->isPopupVisible())
- mStatusPopup->update();
-}
-
-void MiniStatusWindow::logic()
-{
- BLOCK_START("MiniStatusWindow::logic")
- Window::logic();
-
- for (size_t i = 0, sz = mIcons.size(); i < sz; i++)
- {
- AnimatedSprite *const icon = mIcons[i];
- if (icon != nullptr)
- icon->update(tick_time * 10);
- }
- BLOCK_END("MiniStatusWindow::logic")
-}
-
-void MiniStatusWindow::draw(Graphics *const graphics)
-{
- BLOCK_START("MiniStatusWindow::draw")
- drawChildren(graphics);
- BLOCK_END("MiniStatusWindow::draw")
-}
-
-void MiniStatusWindow::safeDraw(Graphics *const graphics)
-{
- BLOCK_START("MiniStatusWindow::draw")
- safeDrawChildren(graphics);
- BLOCK_END("MiniStatusWindow::draw")
-}
-
-void MiniStatusWindow::mouseMoved(MouseEvent &event)
-{
- Window::mouseMoved(event);
-
- const int x = event.getX();
- const int y = event.getY();
-
- const Rect &rect = mDimension;
- if (event.getSource() == mStatusBar)
- {
- mStatusPopup->view(x + rect.x, y + rect.y);
- textPopup->hide();
- }
- else if (event.getSource() == mXpBar)
- {
- std::string level;
- if ((localPlayer != nullptr) && localPlayer->isGM())
- {
- // TRANSLATORS: status bar label
- level = strprintf(_("Level: %d (GM %d)"),
- PlayerInfo::getAttribute(Attributes::PLAYER_BASE_LEVEL),
- localPlayer->getGroupId());
- }
- else
- {
- // TRANSLATORS: status bar label
- level = strprintf(_("Level: %d"),
- PlayerInfo::getAttribute(Attributes::PLAYER_BASE_LEVEL));
- }
-
- const int64_t exp = PlayerInfo::getAttribute64(Attributes::PLAYER_EXP);
- const int64_t expNeed = PlayerInfo::getAttribute64(
- Attributes::PLAYER_EXP_NEEDED);
- const std::string str = toString(CAST_U64(exp)) +
- "/" +
- toString(CAST_U64(expNeed));
- if (exp > expNeed)
- {
- textPopup->show(x + rect.x,
- y + rect.y,
- level,
- str);
- }
- else
- {
- const std::string str2 = toString(CAST_U64(expNeed - exp));
- textPopup->show(x + rect.x,
- y + rect.y,
- level,
- str,
- // TRANSLATORS: status bar label
- strprintf("%s: %s", _("Need"), str2.c_str()));
- }
- mStatusPopup->hide();
- }
- else if (event.getSource() == mHpBar)
- {
- textPopup->show(x + rect.x, y + rect.y, event.getSource()->getId(),
- strprintf("%d/%d", PlayerInfo::getAttribute(Attributes::PLAYER_HP),
- PlayerInfo::getAttribute(Attributes::PLAYER_MAX_HP)));
- mStatusPopup->hide();
- }
- else if (event.getSource() == mMpBar)
- {
- textPopup->show(x + rect.x, y + rect.y, event.getSource()->getId(),
- strprintf("%d/%d", PlayerInfo::getAttribute(Attributes::PLAYER_MP),
- PlayerInfo::getAttribute(Attributes::PLAYER_MAX_MP)));
- mStatusPopup->hide();
- }
- else if (event.getSource() == mJobBar)
- {
- const int64_t exp = PlayerInfo::getAttribute64(
- Attributes::PLAYER_JOB_EXP);
- const int64_t expNeed = PlayerInfo::getAttribute64(
- Attributes::PLAYER_JOB_EXP_NEEDED);
- const int32_t jobLevel = PlayerInfo::getAttribute(
- Attributes::PLAYER_JOB_LEVEL);
- const std::string expStr = toString(CAST_U64(exp));
- const std::string expNeedStr = toString(CAST_U64(expNeed));
- const std::string expLeftStr = toString(CAST_U64(expNeed - exp));
-
- // TRANSLATORS: job bar label
- const std::string level = strprintf(_("Job level: %d"),
- jobLevel);
-
- if (exp > expNeed)
- {
- textPopup->show(x + rect.x,
- y + rect.y,
- level,
- strprintf("%s/%s", expStr.c_str(), expNeedStr.c_str()));
- }
- else
- {
- textPopup->show(x + rect.x,
- y + rect.y,
- level,
- strprintf("%s/%s", expStr.c_str(), expNeedStr.c_str()),
- // TRANSLATORS: status bar label
- strprintf("%s: %s", _("Need"), expLeftStr.c_str()));
- }
- mStatusPopup->hide();
- }
- else if (event.getSource() == mWeightBar)
- {
- textPopup->show(x + rect.x, y + rect.y, event.getSource()->getId(),
- strprintf("%d/%d", PlayerInfo::getAttribute(
- Attributes::TOTAL_WEIGHT),
- PlayerInfo::getAttribute(Attributes::MAX_WEIGHT)));
- mStatusPopup->hide();
- }
- else if (event.getSource() == mInvSlotsBar)
- {
- const Inventory *const inv = PlayerInfo::getInventory();
- if (inv != nullptr)
- {
- const int usedSlots = inv->getNumberOfSlotsUsed();
- const int maxSlots = inv->getSize();
- textPopup->show(x + rect.x, y + rect.y,
- event.getSource()->getId(),
- strprintf("%d/%d", usedSlots, maxSlots));
- }
- mStatusPopup->hide();
- }
- else if (event.getSource() == mMoneyBar)
- {
- textPopup->show(x + rect.x, y + rect.y,
- event.getSource()->getId(),
- toString(PlayerInfo::getAttribute(Attributes::MONEY)));
- }
- else
- {
- textPopup->hide();
- mStatusPopup->hide();
- }
-}
-
-void MiniStatusWindow::mousePressed(MouseEvent &event)
-{
- if (event.getButton() == MouseButton::RIGHT)
- {
- const ProgressBar *const bar = dynamic_cast<ProgressBar*>(
- event.getSource());
- if (bar == nullptr)
- return;
- event.consume();
- if (popupManager != nullptr)
- {
- popupMenu->showPopup(getX() + event.getX(),
- getY() + event.getY(), bar);
- }
- }
-}
-
-void MiniStatusWindow::mouseExited(MouseEvent &event)
-{
- Window::mouseExited(event);
-
- textPopup->hide();
- mStatusPopup->hide();
-}
-
-void MiniStatusWindow::showBar(const std::string &name,
- const Visible visible)
-{
- ProgressBar *const bar = mBarNames[name];
- if (bar == nullptr)
- return;
- bar->setVisible(visible);
- updateBars();
- saveBars();
-}
-
-void MiniStatusWindow::loadBars()
-{
- if (config.getIntValue("ministatussaved") == 0)
- {
- if (mWeightBar != nullptr)
- mWeightBar->setVisible(Visible_false);
- if (mInvSlotsBar != nullptr)
- mInvSlotsBar->setVisible(Visible_false);
- if (mMoneyBar != nullptr)
- mMoneyBar->setVisible(Visible_false);
- if (mArrowsBar != nullptr)
- mArrowsBar->setVisible(Visible_false);
- if (mStatusBar != nullptr)
- mStatusBar->setVisible(Visible_false);
- if (mJobBar != nullptr)
- mJobBar->setVisible(Visible_true);
- return;
- }
-
- for (int f = 0; f < 10; f ++)
- {
- const std::string str = config.getValue(
- "ministatus" + toString(f), "");
- if (str.empty())
- continue;
- ProgressBar *const bar = mBarNames[str];
- if (bar == nullptr)
- continue;
- bar->setVisible(Visible_false);
- }
-}
-
-void MiniStatusWindow::saveBars() const
-{
- int i = 0;
- FOR_EACH (ProgressBarVectorCIter, it, mBars)
- {
- const ProgressBar *const bar = *it;
- if (bar->mVisible == Visible_false)
- {
- config.setValue("ministatus" + toString(i),
- bar->getActionEventId());
- i ++;
- }
- }
- for (int f = i; f < 10; f ++)
- config.deleteKey("ministatus" + toString(f));
-
- config.setValue("ministatussaved", true);
-}
-
-void MiniStatusWindow::slotsChanged(const Inventory *const inventory)
-{
- if (inventory == nullptr)
- return;
-
- if (inventory->getType() == InventoryType::Inventory)
- StatusWindow::updateInvSlotsBar(mInvSlotsBar);
-}
-
-Rect MiniStatusWindow::getChildrenArea()
-{
- const int padding = mPadding;
- const int padding2 = padding * 2;
- const Rect &rect = mDimension;
- return Rect(padding, padding,
- rect.width - padding2,
- rect.height - padding2);
-}
-
-void MiniStatusWindow::arrowsChanged()
-{
- StatusWindow::updateArrowsBar(mArrowsBar);
-}
-
-#ifdef USE_PROFILER
-void MiniStatusWindow::logicChildren()
-{
- BLOCK_START("MiniStatusWindow::logicChildren")
- BasicContainer::logicChildren();
- BLOCK_END("MiniStatusWindow::logicChildren")
-}
-#endif // USE_PROFILER
diff --git a/src/gui/windows/ministatuswindow.h b/src/gui/windows/ministatuswindow.h
deleted file mode 100644
index 9d6e19ac7..000000000
--- a/src/gui/windows/ministatuswindow.h
+++ /dev/null
@@ -1,151 +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_WINDOWS_MINISTATUSWINDOW_H
-#define GUI_WINDOWS_MINISTATUSWINDOW_H
-
-#include "listeners/arrowslistener.h"
-#include "listeners/attributelistener.h"
-#include "listeners/inventorylistener.h"
-#include "listeners/statlistener.h"
-#include "listeners/updatestatuslistener.h"
-
-#include "gui/widgets/window.h"
-
-class AnimatedSprite;
-class Graphics;
-class Inventory;
-class ProgressBar;
-class StatusPopup;
-
-/**
- * The player mini-status dialog.
- *
- * \ingroup Interface
- */
-class MiniStatusWindow final : public Window,
- public InventoryListener,
- public AttributeListener,
- public StatListener,
- public ArrowsListener,
- public UpdateStatusListener
-{
- public:
- MiniStatusWindow();
-
- A_DELETE_COPY(MiniStatusWindow)
-
- ~MiniStatusWindow();
-
- /**
- * Sets one of the icons.
- */
- void setIcon(const int index, AnimatedSprite *const sprite);
-
- void eraseIcon(const int index);
-
- void drawIcons(Graphics *const graphics) A_NONNULL(2);
-
- void updateStatus() override final;
-
- void logic() override final;
-
- void draw(Graphics *const graphics) override final A_NONNULL(2);
-
- void safeDraw(Graphics *const graphics) override final A_NONNULL(2);
-
- void mouseMoved(MouseEvent &event) override final;
-
- void mousePressed(MouseEvent &event) override final;
-
- void mouseExited(MouseEvent &event) override final;
-
- void showBar(const std::string &name, const Visible visible);
-
- void updateBars();
-
- void slotsChanged(const Inventory *const inventory) override final;
-
- STD_VECTOR <ProgressBar*> &getBars() A_WARN_UNUSED
- { return mBars; }
-
- Rect getChildrenArea() override final A_WARN_UNUSED;
-
- void attributeChanged(const AttributesT id,
- const int64_t oldVal,
- const int64_t newVal) override final;
-
- void statChanged(const AttributesT id,
- const int oldVal1,
- const int oldVal2) override final;
-
- void arrowsChanged() override final;
-
-#ifdef USE_PROFILER
- void logicChildren();
-#endif // USE_PROFILER
-
- private:
- bool isInBar(ProgressBar *bar, int x, int y) const;
-
- ProgressBar *createBar(const float progress,
- const int width,
- const int height,
- const ThemeColorIdT textColor,
- const ProgressColorIdT backColor,
- const std::string &restrict skin,
- const std::string &restrict skinFill,
- const std::string &restrict name,
- const std::string &restrict description)
- A_WARN_UNUSED;
-
- void loadBars();
-
- void saveBars() const;
-
- STD_VECTOR <ProgressBar*> mBars;
- std::map <std::string, ProgressBar*> mBarNames;
- STD_VECTOR<AnimatedSprite *> mIcons;
-
- /*
- * Mini Status Bars
- */
- ProgressBar *mHpBar;
- ProgressBar *mMpBar;
- ProgressBar *mXpBar;
- ProgressBar *mJobBar;
- ProgressBar *mWeightBar;
- ProgressBar *mInvSlotsBar;
- ProgressBar *mMoneyBar;
- ProgressBar *mArrowsBar;
- ProgressBar *mStatusBar;
- StatusPopup *mStatusPopup;
-
- int mSpacing;
- int mIconPadding;
- int mIconSpacing;
- int mMaxX;
-};
-
-extern MiniStatusWindow *miniStatusWindow;
-
-#endif // GUI_WINDOWS_MINISTATUSWINDOW_H
diff --git a/src/gui/windows/npcdialog.cpp b/src/gui/windows/npcdialog.cpp
deleted file mode 100644
index fb38dcc72..000000000
--- a/src/gui/windows/npcdialog.cpp
+++ /dev/null
@@ -1,1395 +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 "gui/windows/npcdialog.h"
-
-#include "actormanager.h"
-#include "configuration.h"
-#include "settings.h"
-#include "soundmanager.h"
-
-#include "const/sound.h"
-
-#include "being/being.h"
-#include "being/playerinfo.h"
-
-#include "enums/gui/layouttype.h"
-
-#include "gui/gui.h"
-#include "gui/viewport.h"
-
-#include "gui/fonts/font.h"
-
-#include "gui/popups/popupmenu.h"
-
-#include "gui/windows/cutinwindow.h"
-#include "gui/windows/inventorywindow.h"
-
-#include "gui/widgets/browserbox.h"
-#include "gui/widgets/button.h"
-#include "gui/widgets/createwidget.h"
-#include "gui/widgets/icon.h"
-#include "gui/widgets/inttextfield.h"
-#include "gui/widgets/itemcontainer.h"
-#include "gui/widgets/itemlinkhandler.h"
-#include "gui/widgets/layout.h"
-#include "gui/widgets/extendedlistbox.h"
-#include "gui/widgets/playerbox.h"
-#include "gui/widgets/scrollarea.h"
-
-#include "resources/npcdialoginfo.h"
-
-#include "resources/db/avatardb.h"
-#include "resources/db/npcdb.h"
-#include "resources/db/npcdialogdb.h"
-
-#include "resources/inventory/complexinventory.h"
-
-#include "resources/item/complexitem.h"
-
-#include "resources/loaders/imageloader.h"
-
-#include "net/npchandler.h"
-#include "net/packetlimiter.h"
-
-#include "utils/copynpaste.h"
-#include "utils/delete2.h"
-#include "utils/foreach.h"
-#include "utils/gettext.h"
-
-#include <sstream>
-
-#include "debug.h"
-
-// TRANSLATORS: npc dialog button
-#define CAPTION_WAITING _("Stop waiting")
-// TRANSLATORS: npc dialog button
-#define CAPTION_NEXT _("Next")
-// TRANSLATORS: npc dialog button
-#define CAPTION_CLOSE _("Close")
-// TRANSLATORS: npc dialog button
-#define CAPTION_SUBMIT _("Submit")
-
-NpcDialog::DialogList NpcDialog::instances;
-NpcDialogs NpcDialog::mNpcDialogs;
-
-typedef STD_VECTOR<Image *>::iterator ImageVectorIter;
-
-NpcDialog::NpcDialog(const BeingId npcId) :
- // TRANSLATORS: npc dialog name
- Window(_("NPC"), Modal_false, nullptr, "npc.xml"),
- ActionListener(),
- mNpcId(npcId),
- mDefaultInt(0),
- mDefaultString(),
- mTextBox(new BrowserBox(this, Opaque_true,
- "browserbox.xml")),
- mScrollArea(new ScrollArea(this, mTextBox,
- fromBool(getOptionBool("showtextbackground"), Opaque),
- "npc_textbackground.xml")),
- mText(),
- mNewText(),
- mItems(),
- mImages(),
- mItemList(CREATEWIDGETR(ExtendedListBox,
- this, this, "extendedlistbox.xml")),
- mListScrollArea(new ScrollArea(this, mItemList,
- fromBool(getOptionBool("showlistbackground"), Opaque),
- "npc_listbackground.xml")),
- mSkinContainer(new Container(this)),
- mSkinScrollArea(new ScrollArea(this, mSkinContainer,
- fromBool(getOptionBool("showlistbackground"), Opaque),
- "npc_listbackground.xml")),
- mItemLinkHandler(new ItemLinkHandler),
- mTextField(new TextField(this, "")),
- mIntField(new IntTextField(this)),
- // TRANSLATORS: npc dialog button
- mPlusButton(new Button(this, _("+"), "inc", this)),
- // TRANSLATORS: npc dialog button
- mMinusButton(new Button(this, _("-"), "dec", this)),
- // TRANSLATORS: npc dialog button
- mClearButton(new Button(this, _("Clear"), "clear", this)),
- mButton(new Button(this, "", "ok", this)),
- // TRANSLATORS: npc dialog button
- mButton2(new Button(this, _("Close"), "close", this)),
- // TRANSLATORS: npc dialog button
- mButton3(new Button(this, _("Add"), "add", this)),
- // TRANSLATORS: npc dialog button
- mResetButton(new Button(this, _("Reset"), "reset", this)),
- mInventory(new Inventory(InventoryType::Npc, 1)),
- mComplexInventory(new ComplexInventory(InventoryType::Craft, 1)),
- mItemContainer(new ItemContainer(this, mInventory,
- 10000, ShowEmptyRows_true)),
- mItemScrollArea(new ScrollArea(this, mItemContainer,
- fromBool(getOptionBool("showitemsbackground"), Opaque),
- "npc_listbackground.xml")),
- mInputState(NpcInputState::NONE),
- mActionState(NpcActionState::WAIT),
- mSkinControls(),
- mSkinName(),
- mPlayerBox(new PlayerBox(nullptr)),
- mAvatarBeing(nullptr),
- mDialogInfo(nullptr),
- mLastNextTime(0),
- mCameraMode(-1),
- mCameraX(0),
- mCameraY(0),
- mShowAvatar(false),
- mLogInteraction(config.getBoolValue("logNpcInGui"))
-{
- // Basic Window Setup
- setWindowName("NpcText");
- setResizable(true);
- setFocusable(true);
- setStickyButtonLock(true);
-
- setMinWidth(200);
- setMinHeight(150);
-
- setDefaultSize(300, 578, ImagePosition::LOWER_LEFT);
-
- mPlayerBox->setWidth(70);
- mPlayerBox->setHeight(100);
-
- // Setup output text box
- mTextBox->setOpaque(Opaque_false);
- mTextBox->setMaxRow(config.getIntValue("ChatLogLength"));
- mTextBox->setLinkHandler(mItemLinkHandler);
- mTextBox->setProcessVars(true);
- mTextBox->setFont(gui->getNpcFont());
- mTextBox->setEnableKeys(true);
- mTextBox->setEnableTabs(true);
- mTextBox->setEnableImages(true);
-
- mScrollArea->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
- mScrollArea->setVerticalScrollPolicy(ScrollArea::SHOW_ALWAYS);
-
- // Setup listbox
- mItemList->setWrappingEnabled(true);
- mItemList->setActionEventId("ok");
- mItemList->addActionListener(this);
- mItemList->setDistributeMousePressed(false);
- mItemList->setFont(gui->getNpcFont());
- if (gui->getNpcFont()->getHeight() < 20)
- mItemList->setRowHeight(20);
- else
- mItemList->setRowHeight(gui->getNpcFont()->getHeight());
-
- setContentSize(260, 175);
- mListScrollArea->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
- mItemScrollArea->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
- mSkinScrollArea->setScrollPolicy(ScrollArea::SHOW_NEVER,
- ScrollArea::SHOW_NEVER);
- mItemList->setVisible(Visible_true);
- mTextField->setVisible(Visible_true);
- mIntField->setVisible(Visible_true);
-
- const Font *const fnt = mButton->getFont();
- int width = std::max(fnt->getWidth(CAPTION_WAITING),
- fnt->getWidth(CAPTION_NEXT));
- width = std::max(width, fnt->getWidth(CAPTION_CLOSE));
- width = std::max(width, fnt->getWidth(CAPTION_SUBMIT));
- mButton->setWidth(8 + width);
-
- // Place widgets
- buildLayout();
-
- center();
- loadWindowState();
-
- instances.push_back(this);
-}
-
-void NpcDialog::postInit()
-{
- Window::postInit();
- setVisible(Visible_true);
- requestFocus();
- enableVisibleSound(true);
- soundManager.playGuiSound(SOUND_SHOW_WINDOW);
-
- if (actorManager != nullptr)
- {
- const Being *const being = actorManager->findBeing(mNpcId);
- if (being != nullptr)
- {
- showAvatar(NPCDB::getAvatarFor(fromInt(
- being->getSubType(), BeingTypeId)));
- setCaption(being->getName());
- }
- }
-
- config.addListener("logNpcInGui", this);
-}
-
-NpcDialog::~NpcDialog()
-{
- config.removeListeners(this);
- CHECKLISTENERS
- clearLayout();
-
- if (mPlayerBox != nullptr)
- {
- delete mPlayerBox->getBeing();
- delete mPlayerBox;
- }
-
- deleteSkinControls();
-
- delete2(mTextBox);
- delete2(mClearButton);
- delete2(mButton);
- delete2(mButton2);
- delete2(mButton3);
- delete2(mScrollArea);
- delete2(mItemList);
- delete2(mTextField);
- delete2(mIntField);
- delete2(mResetButton);
- delete2(mPlusButton);
- delete2(mMinusButton);
- delete2(mItemLinkHandler);
- delete2(mItemContainer);
- delete2(mInventory);
- delete2(mComplexInventory);
- delete2(mItemScrollArea);
- delete2(mListScrollArea);
- delete2(mSkinScrollArea);
-
- FOR_EACH (ImageVectorIter, it, mImages)
- {
- if (*it != nullptr)
- (*it)->decRef();
- }
-
- mImages.clear();
-
- instances.remove(this);
-}
-
-void NpcDialog::addText(const std::string &text, const bool save)
-{
- if (save || mLogInteraction)
- {
- if (mText.size() > 5000)
- mText.clear();
-
- mNewText.append(text);
- mTextBox->addRow(text);
- }
- mScrollArea->setVerticalScrollAmount(mScrollArea->getVerticalMaxScroll());
- mActionState = NpcActionState::WAIT;
- buildLayout();
-}
-
-void NpcDialog::showNextButton()
-{
- mActionState = NpcActionState::NEXT;
- buildLayout();
-}
-
-void NpcDialog::showCloseButton()
-{
- mActionState = NpcActionState::CLOSE;
- buildLayout();
-}
-
-void NpcDialog::action(const ActionEvent &event)
-{
- const std::string &eventId = event.getId();
- if (eventId == "ok")
- {
- if (mActionState == NpcActionState::NEXT)
- {
- if (!PacketLimiter::limitPackets(PacketType::PACKET_NPC_NEXT))
- return;
-
- nextDialog();
- addText(std::string(), false);
- }
- else if (mActionState == NpcActionState::CLOSE
- || mActionState == NpcActionState::WAIT)
- {
- if (cutInWindow != nullptr)
- cutInWindow->hide();
- closeDialog();
- }
- else if (mActionState == NpcActionState::INPUT)
- {
- std::string printText; // Text that will get printed
- // in the textbox
- switch (mInputState)
- {
- case NpcInputState::LIST:
- {
- if (mDialogInfo != nullptr)
- return;
- if (gui != nullptr)
- gui->resetClickCount();
- const int selectedIndex = mItemList->getSelected();
-
- if (selectedIndex >= CAST_S32(mItems.size())
- || selectedIndex < 0
- || !PacketLimiter::limitPackets(
- PacketType::PACKET_NPC_INPUT))
- {
- return;
- }
- unsigned char choice = CAST_U8(
- selectedIndex + 1);
- printText = mItems[selectedIndex];
-
- npcHandler->listInput(mNpcId, choice);
- break;
- }
- case NpcInputState::STRING:
- {
- if (!PacketLimiter::limitPackets(
- PacketType::PACKET_NPC_INPUT))
- {
- return;
- }
- printText = mTextField->getText();
- npcHandler->stringInput(mNpcId, printText);
- break;
- }
- case NpcInputState::INTEGER:
- {
- if (!PacketLimiter::limitPackets(
- PacketType::PACKET_NPC_INPUT))
- {
- return;
- }
- printText = strprintf("%d", mIntField->getValue());
- npcHandler->integerInput(
- mNpcId, mIntField->getValue());
- break;
- }
- case NpcInputState::ITEM:
- {
- restoreVirtuals();
- if (!PacketLimiter::limitPackets(
- PacketType::PACKET_NPC_INPUT))
- {
- return;
- }
-
- std::string str;
- const int sz = mInventory->getSize();
- if (sz == 0)
- {
- str = "0,0";
- }
- else
- {
- const Item *item = mInventory->getItem(0);
- if (item != nullptr)
- {
- str = strprintf("%d,%d", item->getId(),
- toInt(item->getColor(), int));
- }
- else
- {
- str = "0,0";
- }
- for (int f = 1; f < sz; f ++)
- {
- str.append(";");
- item = mInventory->getItem(f);
- if (item != nullptr)
- {
- str.append(strprintf("%d,%d", item->getId(),
- toInt(item->getColor(), int)));
- }
- else
- {
- str.append("0,0");
- }
- }
- }
-
- // need send selected item
- npcHandler->stringInput(mNpcId, str);
- mInventory->clear();
- break;
- }
- case NpcInputState::ITEM_INDEX:
- {
- restoreVirtuals();
- if (!PacketLimiter::limitPackets(
- PacketType::PACKET_NPC_INPUT))
- {
- return;
- }
-
- std::string str;
- const int sz = mInventory->getSize();
- if (sz == 0)
- {
- str = "-1";
- }
- else
- {
- const Item *item = mInventory->getItem(0);
- if (item != nullptr)
- {
- str = strprintf("%d", item->getTag());
- }
- else
- {
- str = "-1";
- }
- for (int f = 1; f < sz; f ++)
- {
- str.append(";");
- item = mInventory->getItem(f);
- if (item != nullptr)
- str.append(strprintf("%d", item->getTag()));
- else
- str.append("-1");
- }
- }
-
- // need send selected item
- npcHandler->stringInput(mNpcId, str);
- mInventory->clear();
- break;
- }
- case NpcInputState::ITEM_CRAFT:
- {
- restoreVirtuals();
- if (!PacketLimiter::limitPackets(
- PacketType::PACKET_NPC_INPUT))
- {
- return;
- }
-
- std::string str;
- const int sz = mComplexInventory->getSize();
- if (sz == 0)
- {
- str.clear();
- }
- else
- {
- const ComplexItem *item = dynamic_cast<ComplexItem*>(
- mComplexInventory->getItem(0));
- str = complexItemToStr(item);
- for (int f = 1; f < sz; f ++)
- {
- str.append("|");
- item = dynamic_cast<ComplexItem*>(
- mComplexInventory->getItem(f));
- str.append(complexItemToStr(item));
- }
- }
-
- // need send selected item
- npcHandler->stringInput(mNpcId, str);
- mInventory->clear();
- break;
- }
-
- case NpcInputState::NONE:
- default:
- break;
- }
- if (mInputState != NpcInputState::ITEM &&
- mInputState != NpcInputState::ITEM_INDEX &&
- mInputState != NpcInputState::ITEM_CRAFT)
- {
- // addText will auto remove the input layout
- addText(strprintf("> \"%s\"", printText.c_str()), false);
- }
- mNewText.clear();
- }
-
- if (!mLogInteraction)
- mTextBox->clearRows();
- }
- else if (eventId == "reset")
- {
- switch (mInputState)
- {
- case NpcInputState::STRING:
- mTextField->setText(mDefaultString);
- break;
- case NpcInputState::INTEGER:
- mIntField->setValue(mDefaultInt);
- break;
- case NpcInputState::ITEM:
- case NpcInputState::ITEM_INDEX:
- mInventory->clear();
- break;
- case NpcInputState::ITEM_CRAFT:
- mComplexInventory->clear();
- break;
- case NpcInputState::NONE:
- case NpcInputState::LIST:
- default:
- break;
- }
- }
- else if (eventId == "inc")
- {
- mIntField->setValue(mIntField->getValue() + 1);
- }
- else if (eventId == "dec")
- {
- mIntField->setValue(mIntField->getValue() - 1);
- }
- else if (eventId == "clear")
- {
- switch (mInputState)
- {
- case NpcInputState::ITEM:
- case NpcInputState::ITEM_INDEX:
- mInventory->clear();
- break;
- case NpcInputState::ITEM_CRAFT:
- mComplexInventory->clear();
- break;
- case NpcInputState::STRING:
- case NpcInputState::INTEGER:
- case NpcInputState::LIST:
- case NpcInputState::NONE:
- default:
- clearRows();
- break;
- }
- }
- else if (eventId == "close")
- {
- restoreVirtuals();
- if (mActionState == NpcActionState::INPUT)
- {
- switch (mInputState)
- {
- case NpcInputState::ITEM:
- npcHandler->stringInput(mNpcId, "0,0");
- break;
- case NpcInputState::ITEM_INDEX:
- npcHandler->stringInput(mNpcId, "-1");
- break;
- case NpcInputState::ITEM_CRAFT:
- npcHandler->stringInput(mNpcId, "");
- break;
- case NpcInputState::STRING:
- case NpcInputState::INTEGER:
- case NpcInputState::NONE:
- case NpcInputState::LIST:
- default:
- npcHandler->listInput(mNpcId, 255);
- break;
- }
- if (cutInWindow != nullptr)
- cutInWindow->hide();
- closeDialog();
- }
- }
- else if (eventId == "add")
- {
- if (inventoryWindow != nullptr)
- {
- Item *const item = inventoryWindow->getSelectedItem();
- Inventory *const inventory = PlayerInfo::getInventory();
- if (inventory != nullptr)
- {
- if (mInputState == NpcInputState::ITEM_CRAFT)
- {
- if (mComplexInventory->addVirtualItem(item, -1, 1))
- inventory->virtualRemove(item, 1);
- }
- else
- {
- if (mInventory->addVirtualItem(item, -1, 1))
- inventory->virtualRemove(item, 1);
- }
- }
- }
- }
- else if (eventId.find("skin_") == 0)
- {
- const std::string cmd = eventId.substr(5);
- std::string printText;
- int cnt = 0;
- FOR_EACH (StringVectCIter, it, mItems)
- {
- if (cmd == *it)
- {
- npcHandler->listInput(mNpcId, CAST_U8(cnt + 1));
- printText = mItems[cnt];
-
- if (mInputState != NpcInputState::ITEM &&
- mInputState != NpcInputState::ITEM_INDEX &&
- mInputState != NpcInputState::ITEM_CRAFT)
- {
- // addText will auto remove the input layout
- addText(strprintf("> \"%s\"", printText.c_str()), false);
- }
- mNewText.clear();
- break;
- }
- cnt ++;
- }
- }
-}
-
-void NpcDialog::nextDialog()
-{
- npcHandler->nextDialog(mNpcId);
-}
-
-void NpcDialog::closeDialog()
-{
- restoreCamera();
- npcHandler->closeDialog(mNpcId);
-}
-
-int NpcDialog::getNumberOfElements()
-{
- return CAST_S32(mItems.size());
-}
-
-std::string NpcDialog::getElementAt(int i)
-{
- return mItems[i];
-}
-
-const Image *NpcDialog::getImageAt(int i)
-{
- return mImages[i];
-}
-
-void NpcDialog::choiceRequest()
-{
- mItems.clear();
- FOR_EACH (ImageVectorIter, it, mImages)
- {
- if (*it != nullptr)
- (*it)->decRef();
- }
- mImages.clear();
- mActionState = NpcActionState::INPUT;
- mInputState = NpcInputState::LIST;
- buildLayout();
-}
-
-void NpcDialog::addChoice(const std::string &choice)
-{
- mItems.push_back(choice);
- mImages.push_back(nullptr);
-}
-
-void NpcDialog::parseListItems(const std::string &itemString)
-{
- std::istringstream iss(itemString);
- std::string tmp;
- const std::string path = paths.getStringValue("guiIcons");
- while (getline(iss, tmp, ':'))
- {
- if (tmp.empty())
- continue;
- const size_t pos = tmp.find('|');
- if (pos == std::string::npos)
- {
- mItems.push_back(tmp);
- mImages.push_back(nullptr);
- }
- else
- {
- mItems.push_back(tmp.substr(pos + 1));
- Image *const img = Loader::getImage(pathJoin(path,
- std::string(tmp.substr(0, pos)).append(".png")));
- mImages.push_back(img);
- }
- }
-
- if (!mItems.empty())
- {
- mItemList->setSelected(0);
- mItemList->requestFocus();
- }
- else
- {
- mItemList->setSelected(-1);
- }
-}
-
-void NpcDialog::refocus()
-{
- if (!mItems.empty())
- mItemList->refocus();
-}
-
-void NpcDialog::textRequest(const std::string &defaultText)
-{
- mActionState = NpcActionState::INPUT;
- mInputState = NpcInputState::STRING;
- mDefaultString = defaultText;
- mTextField->setText(defaultText);
-
- buildLayout();
-}
-
-bool NpcDialog::isTextInputFocused() const
-{
- return mTextField->isFocused();
-}
-
-bool NpcDialog::isInputFocused() const
-{
- return mTextField->isFocused() || mIntField->isFocused()
- || mItemList->isFocused();
-}
-
-bool NpcDialog::isAnyInputFocused()
-{
- FOR_EACH (DialogList::const_iterator, it, instances)
- {
- if (((*it) != nullptr) && (*it)->isInputFocused())
- return true;
- }
-
- return false;
-}
-
-void NpcDialog::integerRequest(const int defaultValue, const int min,
- const int max)
-{
- mActionState = NpcActionState::INPUT;
- mInputState = NpcInputState::INTEGER;
- mDefaultInt = defaultValue;
- mIntField->setRange(min, max);
- mIntField->setValue(defaultValue);
- buildLayout();
-}
-
-void NpcDialog::itemRequest(const int size)
-{
- mActionState = NpcActionState::INPUT;
- mInputState = NpcInputState::ITEM;
- mInventory->resize(size);
- buildLayout();
-}
-
-void NpcDialog::itemIndexRequest(const int size)
-{
- mActionState = NpcActionState::INPUT;
- mInputState = NpcInputState::ITEM_INDEX;
- mInventory->resize(size);
- buildLayout();
-}
-
-void NpcDialog::itemCraftRequest(const int size)
-{
- mActionState = NpcActionState::INPUT;
- mInputState = NpcInputState::ITEM_CRAFT;
- mComplexInventory->resize(size);
- buildLayout();
-}
-
-void NpcDialog::move(const int amount)
-{
- if (mActionState != NpcActionState::INPUT)
- return;
-
- switch (mInputState)
- {
- case NpcInputState::INTEGER:
- mIntField->setValue(mIntField->getValue() + amount);
- break;
- case NpcInputState::LIST:
- mItemList->setSelected(mItemList->getSelected() - amount);
- break;
- case NpcInputState::NONE:
- case NpcInputState::STRING:
- case NpcInputState::ITEM:
- case NpcInputState::ITEM_INDEX:
- case NpcInputState::ITEM_CRAFT:
- default:
- break;
- }
-}
-
-void NpcDialog::setVisible(Visible visible)
-{
- Window::setVisible(visible);
-
- if (visible == Visible_false)
- scheduleDelete();
-}
-
-void NpcDialog::optionChanged(const std::string &name)
-{
- if (name == "logNpcInGui")
- mLogInteraction = config.getBoolValue("logNpcInGui");
-}
-
-NpcDialog *NpcDialog::getActive()
-{
- if (instances.size() == 1)
- return instances.front();
-
- FOR_EACH (DialogList::const_iterator, it, instances)
- {
- if (((*it) != nullptr) && (*it)->isFocused())
- return (*it);
- }
-
- return nullptr;
-}
-
-void NpcDialog::closeAll()
-{
- FOR_EACH (DialogList::const_iterator, it, instances)
- {
- if (*it != nullptr)
- (*it)->close();
- }
-}
-
-void NpcDialog::placeNormalControls()
-{
- if (mShowAvatar)
- {
- place(0, 0, mPlayerBox);
- place(1, 0, mScrollArea, 5, 3);
- place(4, 3, mClearButton);
- place(5, 3, mButton);
- }
- else
- {
- place(0, 0, mScrollArea, 5, 3);
- place(3, 3, mClearButton);
- place(4, 3, mButton);
- }
-}
-
-void NpcDialog::placeMenuControls()
-{
- if (mShowAvatar)
- {
- place(0, 0, mPlayerBox);
- place(1, 0, mScrollArea, 6, 3);
- place(0, 3, mListScrollArea, 7, 3);
- place(1, 6, mButton2, 2);
- place(3, 6, mClearButton, 2);
- place(5, 6, mButton, 2);
- }
- else
- {
- place(0, 0, mScrollArea, 6, 3);
- place(0, 3, mListScrollArea, 6, 3);
- place(0, 6, mButton2, 2);
- place(2, 6, mClearButton, 2);
- place(4, 6, mButton, 2);
- }
-}
-
-void NpcDialog::placeSkinControls()
-{
- createSkinControls();
- if ((mDialogInfo != nullptr) && mDialogInfo->hideText)
- {
- if (mShowAvatar)
- {
- place(0, 0, mPlayerBox);
- place(1, 0, mSkinScrollArea, 7, 3);
- place(1, 3, mButton2, 2);
- }
- else
- {
- place(0, 0, mSkinScrollArea, 6, 3);
- place(0, 3, mButton2, 2);
- }
- }
- else
- {
- if (mShowAvatar)
- {
- place(0, 0, mPlayerBox);
- place(1, 0, mScrollArea, 6, 3);
- place(0, 3, mSkinScrollArea, 7, 3);
- place(1, 6, mButton2, 2);
- }
- else
- {
- place(0, 0, mScrollArea, 6, 3);
- place(0, 3, mSkinScrollArea, 6, 3);
- place(0, 6, mButton2, 2);
- }
- }
-}
-
-void NpcDialog::placeTextInputControls()
-{
- if (mShowAvatar)
- {
- place(0, 0, mPlayerBox);
- place(1, 0, mScrollArea, 6, 3);
- place(1, 3, mTextField, 6);
- place(1, 4, mResetButton, 2);
- place(3, 4, mClearButton, 2);
- place(5, 4, mButton, 2);
- }
- else
- {
- place(0, 0, mScrollArea, 6, 3);
- place(0, 3, mTextField, 6);
- place(0, 4, mResetButton, 2);
- place(2, 4, mClearButton, 2);
- place(4, 4, mButton, 2);
- }
-}
-
-void NpcDialog::placeIntInputControls()
-{
- if (mShowAvatar)
- {
- place(0, 0, mPlayerBox);
- place(1, 0, mScrollArea, 6, 3);
- place(1, 3, mMinusButton, 1);
- place(2, 3, mIntField, 4);
- place(6, 3, mPlusButton, 1);
- place(1, 4, mResetButton, 2);
- place(3, 4, mClearButton, 2);
- place(5, 4, mButton, 2);
- }
- else
- {
- place(0, 0, mScrollArea, 6, 3);
- place(0, 3, mMinusButton, 1);
- place(1, 3, mIntField, 4);
- place(5, 3, mPlusButton, 1);
- place(0, 4, mResetButton, 2);
- place(2, 4, mClearButton, 2);
- place(4, 4, mButton, 2);
- }
-}
-
-void NpcDialog::placeItemInputControls()
-{
- if (mDialogInfo != nullptr)
- {
- mItemContainer->setCellBackgroundImage(mDialogInfo->inventory.cell);
- mItemContainer->setMaxColumns(mDialogInfo->inventory.columns);
- }
- else
- {
- mItemContainer->setCellBackgroundImage("inventory_cell.xml");
- mItemContainer->setMaxColumns(10000);
- }
-
- if (mInputState == NpcInputState::ITEM_CRAFT)
- mItemContainer->setInventory(mComplexInventory);
- else
- mItemContainer->setInventory(mInventory);
-
- if ((mDialogInfo != nullptr) && mDialogInfo->hideText)
- {
- if (mShowAvatar)
- {
- place(0, 0, mPlayerBox);
- place(1, 0, mItemScrollArea, 7, 3);
- place(1, 3, mButton3, 2);
- place(3, 3, mClearButton, 2);
- place(5, 3, mButton, 2);
- }
- else
- {
- place(0, 0, mItemScrollArea, 6, 3);
- place(0, 3, mButton3, 2);
- place(2, 3, mClearButton, 2);
- place(4, 3, mButton, 2);
- }
- }
- else
- {
- if (mShowAvatar)
- {
- place(0, 0, mPlayerBox);
- place(1, 0, mScrollArea, 6, 3);
- place(0, 3, mItemScrollArea, 7, 3);
- place(1, 6, mButton3, 2);
- place(3, 6, mClearButton, 2);
- place(5, 6, mButton, 2);
- }
- else
- {
- place(0, 0, mScrollArea, 6, 3);
- place(0, 3, mItemScrollArea, 6, 3);
- place(0, 6, mButton3, 2);
- place(2, 6, mClearButton, 2);
- place(4, 6, mButton, 2);
- }
- }
-}
-
-void NpcDialog::buildLayout()
-{
- clearLayout();
-
- if (mActionState != NpcActionState::INPUT)
- {
- if (mActionState == NpcActionState::WAIT)
- mButton->setCaption(CAPTION_WAITING);
- else if (mActionState == NpcActionState::NEXT)
- mButton->setCaption(CAPTION_NEXT);
- else if (mActionState == NpcActionState::CLOSE)
- mButton->setCaption(CAPTION_CLOSE);
- placeNormalControls();
- }
- else if (mInputState != NpcInputState::NONE)
- {
- mButton->setCaption(CAPTION_SUBMIT);
- switch (mInputState)
- {
- case NpcInputState::LIST:
- if (mDialogInfo == nullptr)
- placeMenuControls();
- else
- placeSkinControls();
- mItemList->setSelected(-1);
- break;
-
- case NpcInputState::STRING:
- placeTextInputControls();
- break;
-
- case NpcInputState::INTEGER:
- placeIntInputControls();
- break;
-
- case NpcInputState::ITEM:
- case NpcInputState::ITEM_INDEX:
- case NpcInputState::ITEM_CRAFT:
- placeItemInputControls();
- break;
-
- case NpcInputState::NONE:
- default:
- break;
- }
- }
-
- Layout &layout = getLayout();
- layout.setRowHeight(1, LayoutType::SET);
- redraw();
- mScrollArea->setVerticalScrollAmount(mScrollArea->getVerticalMaxScroll());
-}
-
-void NpcDialog::saveCamera()
-{
- if ((viewport == nullptr) || mCameraMode >= 0)
- return;
-
- mCameraMode = CAST_S32(settings.cameraMode);
- mCameraX = viewport->getCameraRelativeX();
- mCameraY = viewport->getCameraRelativeY();
-}
-
-void NpcDialog::restoreCamera()
-{
- if ((viewport == nullptr) || mCameraMode == -1)
- return;
-
- if (CAST_S32(settings.cameraMode) != mCameraMode)
- viewport->toggleCameraMode();
- if (mCameraMode != 0)
- {
- viewport->setCameraRelativeX(mCameraX);
- viewport->setCameraRelativeY(mCameraY);
- }
- mCameraMode = -1;
-}
-
-void NpcDialog::showAvatar(const BeingTypeId avatarId)
-{
- const bool needShow = (avatarId != BeingTypeId_zero);
- if (needShow)
- {
- delete mAvatarBeing;
- mAvatarBeing = Being::createBeing(BeingId_zero,
- ActorType::Avatar,
- avatarId,
- nullptr);
- mPlayerBox->setPlayer(mAvatarBeing);
- if (!mAvatarBeing->mSprites.empty())
- {
- mAvatarBeing->logic();
- const BeingInfo *const info = AvatarDB::get(avatarId);
- const int pad2 = 2 * mPadding;
- int width = 0;
- if (info != nullptr)
- {
- width = info->getWidth();
- mPlayerBox->setWidth(width + pad2);
- mPlayerBox->setHeight(info->getHeight() + pad2);
- }
- const Sprite *const sprite = mAvatarBeing->mSprites[0];
- if ((sprite != nullptr) && (width == 0))
- {
- mPlayerBox->setWidth(sprite->getWidth() + pad2);
- mPlayerBox->setHeight(sprite->getHeight() + pad2);
- }
- }
- }
- else
- {
- delete2(mAvatarBeing)
- mPlayerBox->setPlayer(nullptr);
- }
- if (needShow != mShowAvatar)
- {
- mShowAvatar = needShow;
- buildLayout();
- }
- else
- {
- mShowAvatar = needShow;
- }
-}
-
-void NpcDialog::setAvatarDirection(const uint8_t direction)
-{
- Being *const being = mPlayerBox->getBeing();
- if (being != nullptr)
- being->setDirection(direction);
-}
-
-void NpcDialog::setAvatarAction(const int actionId)
-{
- Being *const being = mPlayerBox->getBeing();
- if (being != nullptr)
- being->setAction(static_cast<BeingActionT>(actionId), 0);
-}
-
-void NpcDialog::logic()
-{
- BLOCK_START("NpcDialog::logic")
- Window::logic();
- if (mShowAvatar && (mAvatarBeing != nullptr))
- {
- mAvatarBeing->logic();
- if (mPlayerBox->getWidth() < CAST_S32(3 * getPadding()))
- {
- const Sprite *const sprite = mAvatarBeing->mSprites[0];
- if (sprite != nullptr)
- {
- mPlayerBox->setWidth(sprite->getWidth() + 2 * getPadding());
- mPlayerBox->setHeight(sprite->getHeight() + 2 * getPadding());
- buildLayout();
- }
- }
- }
- BLOCK_END("NpcDialog::logic")
-}
-
-void NpcDialog::clearRows()
-{
- mTextBox->clearRows();
-}
-
-void NpcDialog::clearDialogs()
-{
- NpcDialogs::iterator it = mNpcDialogs.begin();
- const NpcDialogs::iterator it_end = mNpcDialogs.end();
- while (it != it_end)
- {
- delete (*it).second;
- ++ it;
- }
- mNpcDialogs.clear();
-}
-
-void NpcDialog::mousePressed(MouseEvent &event)
-{
- Window::mousePressed(event);
- if (event.getButton() == MouseButton::RIGHT
- && event.getSource() == mTextBox)
- {
- event.consume();
- if (popupMenu != nullptr)
- {
- popupMenu->showNpcDialogPopup(mNpcId,
- viewport->mMouseX,
- viewport->mMouseY);
- }
- }
-}
-
-void NpcDialog::copyToClipboard(const int x, const int y) const
-{
- std::string str = mTextBox->getTextAtPos(x, y);
- sendBuffer(str);
-}
-
-void NpcDialog::setSkin(const std::string &skin)
-{
- if (skin.empty())
- {
- mSkinName = skin;
- mDialogInfo = nullptr;
- return;
- }
- const NpcDialogInfo *const dialog = NpcDialogDB::getDialog(skin);
- if (dialog == nullptr)
- {
- logger->log("Error: creating controls for not existing npc dialog %s",
- skin.c_str());
- return;
- }
- mSkinName = skin;
- mDialogInfo = dialog;
-}
-
-void NpcDialog::deleteSkinControls()
-{
- mSkinContainer->removeControls();
-}
-
-void NpcDialog::createSkinControls()
-{
- deleteSkinControls();
-
- if (mDialogInfo == nullptr)
- return;
-
- FOR_EACH (STD_VECTOR<NpcImageInfo*>::const_iterator,
- it,
- mDialogInfo->menu.images)
- {
- const NpcImageInfo *const info = *it;
- Image *const image = Theme::getImageFromTheme(info->name);
- if (image != nullptr)
- {
- Icon *const icon = new Icon(this, image, AutoRelease_true);
- icon->setPosition(info->x, info->y);
- mSkinContainer->add(icon);
- }
- }
- FOR_EACH (STD_VECTOR<NpcTextInfo*>::const_iterator,
- it,
- mDialogInfo->menu.texts)
- {
- const NpcTextInfo *const info = *it;
- BrowserBox *box = new BrowserBox(this,
- Opaque_true,
- "browserbox.xml");
- box->setOpaque(Opaque_false);
- box->setMaxRow(config.getIntValue("ChatLogLength"));
- box->setLinkHandler(mItemLinkHandler);
- box->setProcessVars(true);
- box->setFont(gui->getNpcFont());
- box->setEnableKeys(true);
- box->setEnableTabs(true);
- box->setPosition(info->x, info->y);
- mSkinContainer->add(box);
- box->setWidth(info->width);
- box->setHeight(info->height);
- StringVect parts;
- splitToStringVector(parts, info->text, '\n');
- FOR_EACH (StringVectCIter, it2, parts)
- {
- box->addRow(*it2);
- }
- }
- FOR_EACH (STD_VECTOR<NpcButtonInfo*>::const_iterator,
- it,
- mDialogInfo->menu.buttons)
- {
- const NpcButtonInfo *const info = *it;
- Button *const button = new Button(this);
- button->setCaption(info->name);
- button->setActionEventId("skin_" + info->value);
- button->addActionListener(this);
- button->setPosition(info->x, info->y);
- if (!info->image.empty())
- {
- button->setImageWidth(info->imageWidth);
- button->setImageHeight(info->imageHeight);
- button->loadImageSet(info->image);
- }
- mSkinContainer->add(button);
- button->adjustSize();
- }
-}
-
-void NpcDialog::restoreVirtuals()
-{
- Inventory *const inventory = PlayerInfo::getInventory();
- if (inventory != nullptr)
- inventory->restoreVirtuals();
-}
-
-std::string NpcDialog::complexItemToStr(const ComplexItem *const item)
-{
- std::string str;
- if (item != nullptr)
- {
- const STD_VECTOR<Item*> &items = item->getChilds();
- const size_t sz = items.size();
- if (sz == 0u)
- return str;
-
- const Item *item2 = items[0];
-
- str = strprintf("%d,%d",
- item2->getInvIndex(),
- item2->getQuantity());
- for (size_t f = 1; f < sz; f ++)
- {
- str.append(";");
- item2 = items[f];
- str.append(strprintf("%d,%d",
- item2->getInvIndex(),
- item2->getQuantity()));
- }
- }
- else
- {
- str.clear();
- }
- return str;
-}
-
-void NpcDialog::addCraftItem(Item *const item,
- const int amount,
- const int slot)
-{
- if (mInputState != NpcInputState::ITEM_CRAFT)
- return;
-
- Inventory *const inventory = PlayerInfo::getInventory();
-
- if (inventory == nullptr)
- return;
-
- if (mComplexInventory->addVirtualItem(
- item,
- slot,
- amount))
- {
- inventory->virtualRemove(item, amount);
- }
-}
diff --git a/src/gui/windows/npcdialog.h b/src/gui/windows/npcdialog.h
deleted file mode 100644
index 4680d774d..000000000
--- a/src/gui/windows/npcdialog.h
+++ /dev/null
@@ -1,324 +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_WINDOWS_NPCDIALOG_H
-#define GUI_WINDOWS_NPCDIALOG_H
-
-#include "enums/simpletypes/beingid.h"
-#include "enums/simpletypes/beingtypeid.h"
-
-#include "enums/gui/npcactionstate.h"
-#include "enums/gui/npcinputstate.h"
-
-#include "gui/models/extendedlistmodel.h"
-
-#include "gui/widgets/window.h"
-
-#include "listeners/actionlistener.h"
-
-class Being;
-class Button;
-class BrowserBox;
-class ComplexInventory;
-class ComplexItem;
-class Container;
-class ExtendedListBox;
-class Item;
-class ItemLinkHandler;
-class Inventory;
-class IntTextField;
-class ItemContainer;
-class NpcDialog;
-class PlayerBox;
-class ScrollArea;
-class TextField;
-
-struct NpcDialogInfo;
-
-typedef std::map<BeingId, NpcDialog*> NpcDialogs;
-
-/**
- * The npc dialog.
- *
- * \ingroup Interface
- */
-class NpcDialog final : public Window,
- public ActionListener,
- public ExtendedListModel,
- public ConfigListener
-{
- public:
- /**
- * Constructor.
- *
- * @see Window::Window
- */
- explicit NpcDialog(const BeingId npcId);
-
- A_DELETE_COPY(NpcDialog)
-
- ~NpcDialog();
-
- void postInit() override final;
-
- /**
- * Called when receiving actions from the widgets.
- */
- void action(const ActionEvent &event) override final;
-
- /**
- * Sets the text shows in the dialog.
- *
- * @param string The new text.
- */
-// void setText(const std::string &string);
-
- /**
- * Adds the text to the text shows in the dialog. Also adds a newline
- * to the end.
- *
- * @param string The text to add.
- */
- void addText(const std::string &string, const bool save = true);
-
- /**
- * When called, the widget will show a "Next" button.
- */
- void showNextButton();
-
- /**
- * When called, the widget will show a "Close" button and will close
- * the dialog when clicked.
- */
- void showCloseButton();
-
- /**
- * Notifies the server that client has performed a next action.
- */
- void nextDialog();
-
- /**
- * Notifies the server that the client has performed a close action.
- */
- void closeDialog();
-
- /**
- * Returns the number of items in the choices list.
- */
- int getNumberOfElements() override final A_WARN_UNUSED;
-
- /**
- * Returns the name of item number i of the choices list.
- */
- std::string getElementAt(int i) override final A_WARN_UNUSED;
-
- /**
- * Returns the image of item number i of the choices list.
- */
- const Image *getImageAt(int i) override final A_WARN_UNUSED;
-
- /**
- * Makes this dialog request a choice selection from the user.
- */
- void choiceRequest();
-
- /**
- * Adds a choice to the list box.
- */
- void addChoice(const std::string &);
-
- /**
- * Fills the options list for an NPC dialog.
- *
- * @param itemString A string with the options separated with colons.
- */
- void parseListItems(const std::string &itemString);
-
- /**
- * Requests a text string from the user.
- */
- void textRequest(const std::string &defaultText = "");
-
- bool isInputFocused() const A_WARN_UNUSED;
-
- bool isTextInputFocused() const A_WARN_UNUSED;
-
- static bool isAnyInputFocused() A_WARN_UNUSED;
-
- /**
- * Requests a interger from the user.
- */
- void integerRequest(const int defaultValue = 0, const int min = 0,
- const int max = 2147483647);
-
- void itemRequest(const int size);
-
- void itemIndexRequest(const int size);
-
- void itemCraftRequest(const int size);
-
- void move(const int amount);
-
- void setVisible(Visible visible) override final;
-
- void optionChanged(const std::string &name) override final;
-
- /**
- * Returns true if any instances exist.
- */
- static bool isActive() A_WARN_UNUSED
- { return !instances.empty(); }
-
- /**
- * Returns the first active instance. Useful for pushing user
- * interaction.
- */
- static NpcDialog *getActive() A_WARN_UNUSED;
-
- /**
- * Closes all instances.
- */
- static void closeAll();
-
- /**
- * Closes all instances and destroy also net handler dialogs.
- */
- static void destroyAll();
-
- void saveCamera();
-
- void restoreCamera();
-
- void refocus();
-
- void showAvatar(const BeingTypeId avatarId);
-
- void setAvatarDirection(const uint8_t direction);
-
- void setAvatarAction(const int actionId);
-
- void logic() override final;
-
- void clearRows();
-
- void mousePressed(MouseEvent &event) override final;
-
- int isCloseState() const
- { return static_cast<int>(mActionState == NpcActionState::CLOSE); }
-
- void setSkin(const std::string &skin);
-
- void addCraftItem(Item *const item,
- const int amount,
- const int slot);
-
- NpcInputStateT getInputState()
- { return mInputState; }
-
- void copyToClipboard(const int x, const int y) const;
-
- static NpcDialogs mNpcDialogs;
-
- static void clearDialogs();
-
- private:
- typedef std::list<NpcDialog*> DialogList;
- static DialogList instances;
-
- void buildLayout();
-
- void placeNormalControls();
-
- void placeMenuControls();
-
- void placeSkinControls();
-
- void placeTextInputControls();
-
- void placeIntInputControls();
-
- void placeItemInputControls();
-
- void createSkinControls();
-
- void deleteSkinControls();
-
- void restoreVirtuals();
-
- std::string complexItemToStr(const ComplexItem *const item);
-
- BeingId mNpcId;
-
- int mDefaultInt;
- std::string mDefaultString;
-
- // Used for the main input area
- BrowserBox *mTextBox A_NONNULLPOINTER;
- ScrollArea *mScrollArea A_NONNULLPOINTER;
- std::string mText;
- std::string mNewText;
-
- // Used for choice input
- StringVect mItems;
- STD_VECTOR<Image *> mImages;
- ExtendedListBox *mItemList A_NONNULLPOINTER;
- ScrollArea *mListScrollArea A_NONNULLPOINTER;
- Container *mSkinContainer A_NONNULLPOINTER;
- ScrollArea *mSkinScrollArea A_NONNULLPOINTER;
- ItemLinkHandler *mItemLinkHandler A_NONNULLPOINTER;
-
- // Used for string and integer input
- TextField *mTextField A_NONNULLPOINTER;
- IntTextField *mIntField A_NONNULLPOINTER;
- Button *mPlusButton A_NONNULLPOINTER;
- Button *mMinusButton A_NONNULLPOINTER;
- Button *mClearButton A_NONNULLPOINTER;
-
- // Used for the button
- Button *mButton A_NONNULLPOINTER;
- Button *mButton2 A_NONNULLPOINTER;
- Button *mButton3 A_NONNULLPOINTER;
-
- // Will reset the text and integer input to the provided default
- Button *mResetButton A_NONNULLPOINTER;
-
- Inventory *mInventory A_NONNULLPOINTER;
- ComplexInventory *mComplexInventory A_NONNULLPOINTER;
- ItemContainer *mItemContainer A_NONNULLPOINTER;
- ScrollArea *mItemScrollArea A_NONNULLPOINTER;
-
- NpcInputStateT mInputState;
- NpcActionStateT mActionState;
- STD_VECTOR<Widget*> mSkinControls;
- std::string mSkinName;
- PlayerBox *mPlayerBox A_NONNULLPOINTER;
- Being *mAvatarBeing;
- const NpcDialogInfo *mDialogInfo;
- int mLastNextTime;
- int mCameraMode;
- int mCameraX;
- int mCameraY;
- bool mShowAvatar;
- bool mLogInteraction;
-};
-
-#endif // GUI_WINDOWS_NPCDIALOG_H
diff --git a/src/gui/windows/npcselldialog.cpp b/src/gui/windows/npcselldialog.cpp
deleted file mode 100644
index c00edda6c..000000000
--- a/src/gui/windows/npcselldialog.cpp
+++ /dev/null
@@ -1,154 +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 "gui/windows/npcselldialog.h"
-
-#include "being/playerinfo.h"
-
-#include "gui/windows/confirmdialog.h"
-
-#include "gui/models/shopitems.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/createwidget.h"
-#include "gui/widgets/shoplistbox.h"
-#include "gui/widgets/slider.h"
-
-#include "net/buysellhandler.h"
-#include "net/net.h"
-#include "net/npchandler.h"
-
-#include "resources/iteminfo.h"
-
-#include "utils/gettext.h"
-#include "utils/stringutils.h"
-
-#include "debug.h"
-
-NpcSellDialog::NpcSellDialog(const BeingId npcId) :
- SellDialog(IsSell_true,
- (Net::getNetworkType() != ServerType::TMWATHENA) ?
- Advanced_true : Advanced_false),
- mNpcId(npcId)
-{
-}
-
-void NpcSellDialog::sellAction(const ActionEvent &event)
-{
- const std::string &eventId = event.getId();
- const int selectedItem = mShopItemList->getSelected();
- const ShopItem *const item = mShopItems->at(selectedItem);
- if ((item == nullptr) || PlayerInfo::isItemProtected(item->getId()))
- return;
-
- if (eventId == "presell")
- {
- if (mAmountItems <= 0 || mAmountItems > mMaxItems)
- return;
-
- const ItemInfo &info = ItemDB::get(item->getId());
- if (info.isProtected())
- {
- ConfirmDialog *const dialog = CREATEWIDGETR(ConfirmDialog,
- // TRANSLATORS: sell confirmation header
- _("sell item"),
- // TRANSLATORS: sell confirmation message
- strprintf(_("Do you really want to sell %s?"),
- info.getName().c_str()),
- SOUND_REQUEST,
- false,
- Modal_true);
- dialog->addActionListener(this);
- return;
- }
- }
-
- if (mAdvanced == Advanced_true)
- sellManyItems(event.getId());
- else
- sellOneItem();
-}
-
-void NpcSellDialog::sellManyItems(const std::string &eventId)
-{
- if (eventId == "confirm")
- {
- npcHandler->sellItems(mShopItems->allItems());
- close();
- }
- else
- {
- const int selectedItem = mShopItemList->getSelected();
- ShopItem *const item = mShopItems->at(selectedItem);
- item->increaseUsedQuantity(mAmountItems);
- item->update();
- if (mConfirmButton != nullptr)
- mConfirmButton->setEnabled(true);
- }
-}
-
-void NpcSellDialog::sellOneItem()
-{
- if (mAmountItems <= 0 || mAmountItems > mMaxItems)
- return;
-
- const int selectedItem = mShopItemList->getSelected();
- ShopItem *const item = mShopItems->at(selectedItem);
- // Attempt sell
- mPlayerMoney += mAmountItems * mShopItems->at(selectedItem)->getPrice();
- mMaxItems -= mAmountItems;
- while (mAmountItems > 0)
- {
- // This order is important, item->getCurrentInvIndex() would
- // return the inventory index of the next Duplicate otherwise.
- const int itemIndex = item->getCurrentInvIndex();
- const int sellCount = item->sellCurrentDuplicate(mAmountItems);
- npcHandler->sellItem(mNpcId, itemIndex, sellCount);
- mAmountItems -= sellCount;
- }
-
- mPlayerMoney += mAmountItems * mShopItems->at(selectedItem)->getPrice();
- mAmountItems = 1;
- mSlider->setValue(0);
-
- if (mMaxItems != 0)
- {
- updateButtonsAndLabels();
- }
- else
- {
- // All were sold
- mShopItemList->setSelected(-1);
- mShopItems->del(selectedItem);
-
- Rect scroll;
- scroll.y = mShopItemList->getRowHeight() * (selectedItem + 1);
- scroll.height = mShopItemList->getRowHeight();
- mShopItemList->showPart(scroll);
- }
-}
-
-void NpcSellDialog::close()
-{
- buySellHandler->close();
- Window::close();
-}
diff --git a/src/gui/windows/npcselldialog.h b/src/gui/windows/npcselldialog.h
deleted file mode 100644
index 688932a1b..000000000
--- a/src/gui/windows/npcselldialog.h
+++ /dev/null
@@ -1,59 +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_WINDOWS_NPCSELLDIALOG_H
-#define GUI_WINDOWS_NPCSELLDIALOG_H
-
-#include "enums/simpletypes/beingid.h"
-
-#include "gui/widgets/selldialog.h"
-
-/**
- * The sell dialog.
- *
- * \ingroup Interface
- */
-class NpcSellDialog final : public SellDialog
-{
- public:
- /**
- * Constructor.
- *
- * @see Window::Window
- */
- explicit NpcSellDialog(const BeingId npcId);
-
- A_DELETE_COPY(NpcSellDialog)
-
- void close() override final;
-
- protected:
- void sellAction(const ActionEvent &event) override final;
-
- void sellOneItem();
-
- void sellManyItems(const std::string &eventId);
-
- BeingId mNpcId;
-};
-
-#endif // GUI_WINDOWS_NPCSELLDIALOG_H
diff --git a/src/gui/windows/okdialog.cpp b/src/gui/windows/okdialog.cpp
deleted file mode 100644
index 95ea9a641..000000000
--- a/src/gui/windows/okdialog.cpp
+++ /dev/null
@@ -1,94 +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 "gui/windows/okdialog.h"
-
-#include "soundmanager.h"
-
-#include "const/sound.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/textbox.h"
-
-#include "gui/fonts/font.h"
-
-#include "debug.h"
-
-OkDialog::OkDialog(const std::string &restrict title,
- const std::string &restrict msg,
- const std::string &restrict button,
- const DialogTypeT soundEvent,
- const Modal modal,
- const ShowCenter showCenter,
- Window *const parent,
- const int minWidth) :
- Window(title, modal, parent, "ok.xml"),
- ActionListener(),
- mTextBox(new TextBox(this))
-{
- mTextBox->setEditable(false);
- mTextBox->setOpaque(Opaque_false);
- mTextBox->setTextWrapped(msg, minWidth);
-
- // TRANSLATORS: ok dialog button
- Button *const okButton = new Button(this, button, "ok", this);
-
- int width = getFont()->getWidth(title);
- if (width < mTextBox->getMinWidth())
- width = mTextBox->getMinWidth();
- if (width < okButton->getWidth())
- width = okButton->getWidth();
-
- if (mTextBox->getWidth() > width)
- width = mTextBox->getWidth();
- if (okButton->getWidth() > width)
- width = okButton->getWidth();
- setContentSize(width, mTextBox->getHeight() + okButton->getHeight()
- + getOption("buttonPadding", 8));
- mTextBox->setPosition((width - mTextBox->getWidth()) / 2, 0);
- okButton->setPosition((width - okButton->getWidth()) / 2,
- mTextBox->getHeight() + getOption("buttonPadding", 8));
-
- // +++ virtual method call
- add(mTextBox);
- add(okButton);
-
- if (showCenter == ShowCenter_true)
- center();
- else
- centerHorisontally();
- // +++ virtual method call
- setVisible(Visible_true);
- okButton->requestFocus();
-
- if (soundEvent == DialogType::OK)
- soundManager.playGuiSound(SOUND_INFO);
- else if (soundEvent == DialogType::ERROR)
- soundManager.playGuiSound(SOUND_ERROR);
-}
-
-void OkDialog::action(const ActionEvent &event)
-{
- setActionEventId(event.getId());
- distributeActionEvent();
- scheduleDelete();
-}
diff --git a/src/gui/windows/okdialog.h b/src/gui/windows/okdialog.h
deleted file mode 100644
index 1cd923e14..000000000
--- a/src/gui/windows/okdialog.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 GUI_WINDOWS_OKDIALOG_H
-#define GUI_WINDOWS_OKDIALOG_H
-
-#include "gui/widgets/window.h"
-
-#include "enums/gui/dialogtype.h"
-
-#include "enums/simpletypes/showcenter.h"
-
-#include "listeners/actionlistener.h"
-
-#include "localconsts.h"
-
-class TextBox;
-
-/**
- * An 'Ok' button dialog.
- *
- * \ingroup GUI
- */
-class OkDialog final : public Window,
- public ActionListener
-{
- public:
- /**
- * Constructor.
- *
- * @see Window::Window
- */
- OkDialog(const std::string &restrict title,
- const std::string &restrict msg,
- const std::string &restrict button,
- const DialogTypeT soundEvent,
- const Modal modal,
- const ShowCenter showCenter,
- Window *const parent,
- const int minWidth);
-
- A_DELETE_COPY(OkDialog)
-
- /**
- * Called when receiving actions from the widgets.
- */
- void action(const ActionEvent &event) override final;
-
- private:
- TextBox *mTextBox;
-};
-
-#endif // GUI_WINDOWS_OKDIALOG_H
diff --git a/src/gui/windows/outfitwindow.cpp b/src/gui/windows/outfitwindow.cpp
deleted file mode 100644
index fa288c7d9..000000000
--- a/src/gui/windows/outfitwindow.cpp
+++ /dev/null
@@ -1,749 +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 "gui/windows/outfitwindow.h"
-
-#include "configuration.h"
-#include "dragdrop.h"
-#include "game.h"
-
-#include "being/playerinfo.h"
-
-#include "const/emoteshortcut.h"
-
-#include "enums/gui/layouttype.h"
-
-#include "input/inputactionoperators.h"
-#include "input/inputmanager.h"
-
-#include "gui/viewport.h"
-
-#include "gui/popups/popupmenu.h"
-
-#include "gui/windows/setupwindow.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/checkbox.h"
-#include "gui/widgets/label.h"
-#include "gui/widgets/layout.h"
-
-#include "utils/gettext.h"
-
-#include "resources/inventory/inventory.h"
-
-#include <sstream>
-
-#include "debug.h"
-
-OutfitWindow *outfitWindow = nullptr;
-
-OutfitWindow::OutfitWindow() :
- // TRANSLATORS: outfits window name
- Window(_("Outfits"), Modal_false, nullptr, "outfits.xml"),
- ActionListener(),
- // TRANSLATORS: outfits window button
- mPreviousButton(new Button(this, _("<"), "previous", this)),
- // TRANSLATORS: outfits window button
- mNextButton(new Button(this, _(">"), "next", this)),
- // TRANSLATORS: outfits window button
- mEquipBottom(new Button(this, _("Equip"), "equip", this)),
- // TRANSLATORS: outfits window label
- mCurrentLabel(new Label(this, strprintf(_("Outfit: %d"), 1))),
- // TRANSLATORS: outfits window checkbox
- mUnequipCheck(new CheckBox(this, _("Unequip first"),
- serverConfig.getValueBool("OutfitUnequip0", true))),
- // TRANSLATORS: outfits window checkbox
- mAwayOutfitCheck(new CheckBox(this, _("Away outfit"),
- serverConfig.getValue("OutfitAwayIndex", OUTFITS_COUNT - 1) != 0u)),
- // TRANSLATORS: outfits window label
- mKeyLabel(new Label(this, strprintf(_("Key: %s"),
- keyName(0).c_str()))),
- mBorderColor(getThemeColor(ThemeColorId::BORDER, 64)),
- mCurrentOutfit(0),
- mBoxWidth(33),
- mBoxHeight(33),
- mGridWidth(4),
- mGridHeight(4),
- mItems(),
- mAwayOutfit(0),
- mItemColors(),
- mItemClicked(false),
- mItemsUnequip()
-{
- setWindowName("Outfits");
- setResizable(true);
- setCloseButton(true);
- setStickyButtonLock(true);
-
- mBackgroundColor = getThemeColor(ThemeColorId::BACKGROUND, 32);
-
- setDefaultSize(250, 400, 150, 290);
- setMinWidth(145);
- setMinHeight(220);
-
- if (setupWindow != nullptr)
- setupWindow->registerWindowForReset(this);
-
- mCurrentLabel->setAlignment(Graphics::CENTER);
- mKeyLabel->setAlignment(Graphics::CENTER);
-
- mUnequipCheck->setActionEventId("unequip");
- mUnequipCheck->addActionListener(this);
-
- mAwayOutfitCheck->setActionEventId("away");
- mAwayOutfitCheck->addActionListener(this);
-
- place(1, 3, mEquipBottom, 2);
- place(0, 4, mKeyLabel, 4);
- place(0, 5, mPreviousButton, 1);
- place(1, 5, mCurrentLabel, 2);
- place(3, 5, mNextButton, 1);
- place(0, 6, mUnequipCheck, 4);
- place(0, 7, mAwayOutfitCheck, 4);
-
- Layout &layout = getLayout();
- layout.setRowHeight(0, LayoutType::SET);
- layout.setColWidth(4, Layout::CENTER);
-
- loadWindowState();
-
- enableVisibleSound(true);
- load();
-}
-
-OutfitWindow::~OutfitWindow()
-{
- save();
-}
-
-void OutfitWindow::load()
-{
- const Configuration *cfg = &serverConfig;
-
- memset(mItems, -1, sizeof(mItems));
- memset(mItemColors, 1, sizeof(mItemColors));
-
- for (unsigned o = 0; o < OUTFITS_COUNT; o++)
- {
- std::string outfit = cfg->getValue("Outfit" + toString(o), "-1");
- std::string buf;
- std::stringstream ss(outfit);
-
- STD_VECTOR<int> tokens;
-
- while (ss >> buf)
- tokens.push_back(atoi(buf.c_str()));
-
- for (size_t i = 0, sz = tokens.size();
- i < sz && i < OUTFIT_ITEM_COUNT; i++)
- {
- mItems[o][i] = tokens[i];
- }
-
- outfit = cfg->getValue("OutfitColor" + toString(o), "1");
- std::stringstream ss2(outfit);
-
- tokens.clear();
-
- STD_VECTOR<unsigned char> tokens2;
- while (ss2 >> buf)
- tokens2.push_back(CAST_U8(atoi(buf.c_str())));
-
- for (size_t i = 0, sz = tokens2.size();
- i < sz && i < OUTFIT_ITEM_COUNT; i++)
- {
- mItemColors[o][i] = fromInt(tokens2[i], ItemColor);
- }
-
- mItemsUnequip[o] = cfg->getValueBool("OutfitUnequip" + toString(o),
- true);
- }
- mAwayOutfit = cfg->getValue("OutfitAwayIndex", OUTFITS_COUNT - 1);
- if (mAwayOutfit >= CAST_S32(OUTFITS_COUNT))
- mAwayOutfit = CAST_S32(OUTFITS_COUNT) - 1;
-
- if (mAwayOutfitCheck != nullptr)
- mAwayOutfitCheck->setSelected(mAwayOutfit == mCurrentOutfit);
-}
-
-void OutfitWindow::save() const
-{
- std::string outfitStr;
- std::string outfitColorsStr;
- for (unsigned o = 0; o < OUTFITS_COUNT; o++)
- {
- bool good = false;
- for (unsigned i = 0; i < OUTFIT_ITEM_COUNT; i++)
- {
- const int val = mItems[o][i];
- const int res = val != 0 ? val : -1;
- if (res != -1)
- good = true;
- outfitStr.append(toString(res));
- if (i < OUTFIT_ITEM_COUNT - 1)
- outfitStr.append(" ");
- outfitColorsStr.append(toString(CAST_S32(
- toInt(mItemColors[o][i], int))));
- if (i < OUTFIT_ITEM_COUNT - 1)
- outfitColorsStr.append(" ");
- }
- if (good)
- {
- serverConfig.setValue("Outfit" + toString(o), outfitStr);
- serverConfig.setValue("OutfitColor" + toString(o),
- outfitColorsStr);
- }
- else
- {
- serverConfig.deleteKey("Outfit" + toString(o));
- serverConfig.deleteKey("OutfitColor" + toString(o));
- }
-
- if (mItemsUnequip[o])
- {
- serverConfig.deleteKey("OutfitUnequip" + toString(o));
- }
- else
- {
- serverConfig.setValue("OutfitUnequip" + toString(o),
- mItemsUnequip[o]);
- }
- outfitStr.clear();
- outfitColorsStr.clear();
- }
- serverConfig.setValue("OutfitAwayIndex", mAwayOutfit);
-}
-
-void OutfitWindow::action(const ActionEvent &event)
-{
- const std::string &eventId = event.getId();
- if (eventId == "next")
- {
- next();
- }
- else if (eventId == "previous")
- {
- previous();
- }
- else if (eventId == "unequip")
- {
- if (mCurrentOutfit >= 0 && mCurrentOutfit < CAST_S32(
- OUTFITS_COUNT))
- {
- mItemsUnequip[mCurrentOutfit] = mUnequipCheck->isSelected();
- }
- }
- else if (eventId == "equip")
- {
- wearOutfit(mCurrentOutfit);
- if (Game::instance() != nullptr)
- Game::instance()->setValidSpeed();
- }
- else if (eventId == "away")
- {
- mAwayOutfit = mCurrentOutfit;
- if (!mAwayOutfitCheck->isSelected())
- mAwayOutfitCheck->setSelected(true);
- }
-}
-
-void OutfitWindow::wearOutfit(const int outfit, const bool unwearEmpty,
- const bool select)
-{
- bool isEmpty = true;
-
- if (outfit < 0 || outfit > CAST_S32(OUTFITS_COUNT))
- return;
-
- for (unsigned i = 0; i < OUTFIT_ITEM_COUNT; i++)
- {
- const Item *const item = PlayerInfo::getInventory()->findItem(
- mItems[outfit][i],
- mItemColors[outfit][i]);
- if ((item != nullptr)
- && item->isEquipped() == Equipped_false
- && (item->getQuantity() != 0))
- {
- if (item->isEquipment() == Equipm_true)
- {
- PlayerInfo::equipItem(item, Sfx_false);
- isEmpty = false;
- }
- }
- }
-
- if ((!isEmpty || unwearEmpty) && outfit < CAST_S32(OUTFITS_COUNT)
- && mItemsUnequip[outfit])
- {
- unequipNotInOutfit(outfit);
- }
- if (select)
- {
- mCurrentOutfit = outfit;
- showCurrentOutfit();
- }
-}
-
-void OutfitWindow::copyOutfit(const int outfit)
-{
- copyOutfit(outfit, mCurrentOutfit);
-}
-
-void OutfitWindow::copyOutfit(const int src, const int dst)
-{
- if (src < 0 || src > CAST_S32(OUTFITS_COUNT)
- || dst < 0 || dst > CAST_S32(OUTFITS_COUNT))
- {
- return;
- }
-
- for (unsigned int i = 0; i < OUTFIT_ITEM_COUNT; i++)
- mItems[dst][i] = mItems[src][i];
- save();
-}
-
-void OutfitWindow::draw(Graphics *const graphics)
-{
- BLOCK_START("OutfitWindow::draw")
- Window::draw(graphics);
-
- if (mCurrentOutfit < 0 || mCurrentOutfit
- >= static_cast<signed int>(OUTFITS_COUNT))
- {
- return;
- }
-
- for (unsigned int i = 0; i < OUTFIT_ITEM_COUNT; i++)
- {
- const int itemX = mPadding + ((i % mGridWidth) * mBoxWidth);
- const int itemY = mPadding + mTitleBarHeight
- + ((i / CAST_U32(mGridWidth)) * mBoxHeight);
-
- graphics->setColor(mBorderColor);
- graphics->drawRectangle(Rect(itemX, itemY, 32, 32));
- graphics->setColor(mBackgroundColor);
- graphics->fillRectangle(Rect(itemX, itemY, 32, 32));
-
- if (mItems[mCurrentOutfit][i] < 0)
- continue;
-
- bool foundItem = false;
- const Inventory *const inv = PlayerInfo::getInventory();
- if (inv != nullptr)
- {
- const Item *const item = inv->findItem(mItems[mCurrentOutfit][i],
- mItemColors[mCurrentOutfit][i]);
- if (item != nullptr)
- {
- // Draw item icon.
- const Image *const image = item->getImage();
- if (image != nullptr)
- {
- graphics->drawImage(image, itemX, itemY);
- foundItem = true;
- }
- }
- }
- if (!foundItem)
- {
- Image *const image = Item::getImage(mItems[mCurrentOutfit][i],
- mItemColors[mCurrentOutfit][i]);
- if (image != nullptr)
- {
- graphics->drawImage(image, itemX, itemY);
- image->decRef();
- }
- }
- }
- BLOCK_END("OutfitWindow::draw")
-}
-
-void OutfitWindow::safeDraw(Graphics *const graphics)
-{
- BLOCK_START("OutfitWindow::draw")
- Window::safeDraw(graphics);
-
- if (mCurrentOutfit < 0 || mCurrentOutfit
- >= static_cast<signed int>(OUTFITS_COUNT))
- {
- return;
- }
-
- for (unsigned int i = 0; i < OUTFIT_ITEM_COUNT; i++)
- {
- const int itemX = mPadding + ((i % mGridWidth) * mBoxWidth);
- const int itemY = mPadding + mTitleBarHeight
- + ((i / CAST_U32(mGridWidth)) * mBoxHeight);
-
- graphics->setColor(mBorderColor);
- graphics->drawRectangle(Rect(itemX, itemY, 32, 32));
- graphics->setColor(mBackgroundColor);
- graphics->fillRectangle(Rect(itemX, itemY, 32, 32));
-
- if (mItems[mCurrentOutfit][i] < 0)
- continue;
-
- bool foundItem = false;
- const Inventory *const inv = PlayerInfo::getInventory();
- if (inv != nullptr)
- {
- const Item *const item = inv->findItem(mItems[mCurrentOutfit][i],
- mItemColors[mCurrentOutfit][i]);
- if (item != nullptr)
- {
- // Draw item icon.
- const Image *const image = item->getImage();
- if (image != nullptr)
- {
- graphics->drawImage(image, itemX, itemY);
- foundItem = true;
- }
- }
- }
- if (!foundItem)
- {
- Image *const image = Item::getImage(mItems[mCurrentOutfit][i],
- mItemColors[mCurrentOutfit][i]);
- if (image != nullptr)
- {
- graphics->drawImage(image, itemX, itemY);
- image->decRef();
- }
- }
- }
- BLOCK_END("OutfitWindow::draw")
-}
-
-void OutfitWindow::mouseDragged(MouseEvent &event)
-{
- if (event.getButton() == MouseButton::LEFT)
- {
- if (dragDrop.isEmpty() && mItemClicked)
- {
- if (mCurrentOutfit < 0 || mCurrentOutfit
- >= static_cast<signed int>(OUTFITS_COUNT))
- {
- Window::mouseDragged(event);
- return;
- }
-
- const int index = getIndexFromGrid(event.getX(), event.getY());
- if (index == -1)
- {
- Window::mouseDragged(event);
- return;
- }
- const int itemId = mItems[mCurrentOutfit][index];
- const ItemColor itemColor = mItemColors[mCurrentOutfit][index];
- if (itemId < 0)
- {
- Window::mouseDragged(event);
- return;
- }
- mMoved = false;
- event.consume();
- const Inventory *const inv = PlayerInfo::getInventory();
- if (inv != nullptr)
- {
- Item *const item = inv->findItem(itemId, itemColor);
- if (item != nullptr)
- dragDrop.dragItem(item, DragDropSource::Outfit);
- else
- dragDrop.clear();
- mItems[mCurrentOutfit][index] = -1;
- }
- }
- }
- Window::mouseDragged(event);
-}
-
-void OutfitWindow::mousePressed(MouseEvent &event)
-{
- const int index = getIndexFromGrid(event.getX(), event.getY());
- if (event.getButton() == MouseButton::RIGHT && (popupMenu != nullptr))
- {
- popupMenu->showOutfitsWindowPopup(viewport->mMouseX,
- viewport->mMouseY);
- event.consume();
- return;
- }
- else if (index == -1)
- {
- Window::mousePressed(event);
- return;
- }
- mMoved = false;
- event.consume();
-
- if (mItems[mCurrentOutfit][index] > 0)
- {
- mItemClicked = true;
- }
- else
- {
- if (dragDrop.isSelected())
- {
- mItems[mCurrentOutfit][index] = dragDrop.getSelected();
- mItemColors[mCurrentOutfit][index] = dragDrop.getSelectedColor();
- dragDrop.deselect();
- save();
- }
- }
-
- Window::mousePressed(event);
-}
-
-void OutfitWindow::mouseReleased(MouseEvent &event)
-{
- if (event.getButton() == MouseButton::LEFT)
- {
- if (mCurrentOutfit < 0 || mCurrentOutfit
- >= static_cast<signed int>(OUTFITS_COUNT))
- {
- return;
- }
- const int index = getIndexFromGrid(event.getX(), event.getY());
- if (index == -1)
- {
- dragDrop.clear();
- Window::mouseReleased(event);
- return;
- }
- mMoved = false;
- event.consume();
- if (!dragDrop.isEmpty())
- {
- if (dragDrop.isSourceItemContainer())
- {
- mItems[mCurrentOutfit][index] = dragDrop.getItem();
- mItemColors[mCurrentOutfit][index] = dragDrop.getItemColor();
- dragDrop.clear();
- dragDrop.deselect();
- save();
- }
- }
- if (mItemClicked)
- mItemClicked = false;
- }
- Window::mouseReleased(event);
-}
-
-int OutfitWindow::getIndexFromGrid(const int pointX, const int pointY) const
-{
- const Rect tRect = Rect(mPadding, mTitleBarHeight,
- mGridWidth * mBoxWidth, mGridHeight * mBoxHeight);
- if (!tRect.isPointInRect(pointX, pointY))
- return -1;
- const int index = (((pointY - mTitleBarHeight) / mBoxHeight) * mGridWidth)
- + (pointX - mPadding) / mBoxWidth;
- if (index >= CAST_S32(OUTFIT_ITEM_COUNT) || index < 0)
- return -1;
- return index;
-}
-
-void OutfitWindow::unequipNotInOutfit(const int outfit) const
-{
- // here we think that outfit is correct index
-
- const Inventory *const inventory = PlayerInfo::getInventory();
- if (inventory == nullptr)
- return;
-
- const unsigned int invSize = inventory->getSize();
- for (unsigned i = 0; i < invSize; i++)
- {
- const Item *const item = inventory->getItem(i);
- if ((item != nullptr) && item->isEquipped() == Equipped_true)
- {
- bool found = false;
- for (unsigned f = 0; f < OUTFIT_ITEM_COUNT; f++)
- {
- if (item->getId() == mItems[outfit][f])
- {
- found = true;
- break;
- }
- }
- if (!found)
- PlayerInfo::unequipItem(item, Sfx_false);
- }
- }
-}
-
-std::string OutfitWindow::keyName(const int number)
-{
- if (number < 0 || number >= SHORTCUT_EMOTES)
- return "";
- return inputManager.getKeyStringLong(InputAction::OUTFIT_1 + number);
-}
-
-void OutfitWindow::next()
-{
- if (mCurrentOutfit < (CAST_S32(OUTFITS_COUNT) - 1))
- mCurrentOutfit++;
- else
- mCurrentOutfit = 0;
- showCurrentOutfit();
-}
-
-void OutfitWindow::previous()
-{
- if (mCurrentOutfit > 0)
- mCurrentOutfit--;
- else
- mCurrentOutfit = OUTFITS_COUNT - 1;
- showCurrentOutfit();
-}
-
-void OutfitWindow::showCurrentOutfit()
-{
- // TRANSLATORS: outfits window label
- mCurrentLabel->setCaption(strprintf(_("Outfit: %d"), mCurrentOutfit + 1));
- if (mCurrentOutfit < CAST_S32(OUTFITS_COUNT))
- mUnequipCheck->setSelected(mItemsUnequip[mCurrentOutfit]);
- else
- mUnequipCheck->setSelected(false);
- // TRANSLATORS: outfits window label
- mKeyLabel->setCaption(strprintf(_("Key: %s"),
- keyName(mCurrentOutfit).c_str()));
- mAwayOutfitCheck->setSelected(mAwayOutfit == mCurrentOutfit);
-}
-
-void OutfitWindow::wearNextOutfit(const bool all)
-{
- next();
- if (!all && mCurrentOutfit >= 0 && mCurrentOutfit
- < CAST_S32(OUTFITS_COUNT))
- {
- bool fromStart = false;
- while (!mItemsUnequip[mCurrentOutfit])
- {
- next();
- if (mCurrentOutfit == 0)
- {
- if (!fromStart)
- fromStart = true;
- else
- return;
- }
- }
- }
- wearOutfit(mCurrentOutfit);
-}
-
-void OutfitWindow::wearPreviousOutfit(const bool all)
-{
- previous();
- if (!all && mCurrentOutfit >= 0 && mCurrentOutfit
- < CAST_S32(OUTFITS_COUNT))
- {
- bool fromStart = false;
- while (!mItemsUnequip[mCurrentOutfit])
- {
- previous();
- if (mCurrentOutfit == 0)
- {
- if (!fromStart)
- fromStart = true;
- else
- return;
- }
- }
- }
- wearOutfit(mCurrentOutfit);
-}
-
-void OutfitWindow::copyFromEquiped()
-{
- copyFromEquiped(mCurrentOutfit);
-}
-
-void OutfitWindow::copyFromEquiped(const int dst)
-{
- const Inventory *const inventory = PlayerInfo::getInventory();
- if (inventory == nullptr)
- return;
-
- int outfitCell = 0;
- for (unsigned i = 0, sz = inventory->getSize(); i < sz; i++)
- {
- const Item *const item = inventory->getItem(i);
- if ((item != nullptr) && item->isEquipped() == Equipped_true)
- {
- mItems[dst][outfitCell] = item->getId();
- mItemColors[dst][outfitCell++] = item->getColor();
- if (outfitCell >= CAST_S32(OUTFIT_ITEM_COUNT))
- break;
- }
- }
- save();
-}
-
-void OutfitWindow::wearAwayOutfit()
-{
- copyFromEquiped(OUTFITS_COUNT);
- wearOutfit(mAwayOutfit, false);
-}
-
-void OutfitWindow::unwearAwayOutfit()
-{
- wearOutfit(OUTFITS_COUNT);
-}
-
-void OutfitWindow::clearCurrentOutfit()
-{
- if (mCurrentOutfit < 0 || mCurrentOutfit
- >= static_cast<signed int>(OUTFITS_COUNT))
- {
- return;
- }
- for (unsigned f = 0; f < OUTFIT_ITEM_COUNT; f++)
- {
- mItems[mCurrentOutfit][f] = -1;
- mItemColors[mCurrentOutfit][f] = ItemColor_one;
- }
- save();
-}
-
-std::string OutfitWindow::getOutfitString() const
-{
- std::string str;
- for (unsigned int i = 0; i < OUTFIT_ITEM_COUNT; i++)
- {
- const int id = mItems[mCurrentOutfit][i];
- if (id < 0)
- continue;
-
- const ItemColor color = mItemColors[mCurrentOutfit][i];
- STD_VECTOR<int> ids;
- ids.push_back(id);
- ids.push_back(CAST_S32(color));
-
- const std::string name = ItemDB::getNamesStr(ids);
- if (name.empty())
- continue;
- str.append("[");
- str.append(name);
- str.append("] ");
- }
- return str;
-}
diff --git a/src/gui/windows/outfitwindow.h b/src/gui/windows/outfitwindow.h
deleted file mode 100644
index cf2799d2b..000000000
--- a/src/gui/windows/outfitwindow.h
+++ /dev/null
@@ -1,133 +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 GUI_WINDOWS_OUTFITWINDOW_H
-#define GUI_WINDOWS_OUTFITWINDOW_H
-
-#include "enums/simpletypes/itemcolor.h"
-
-#include "gui/widgets/window.h"
-
-#include "listeners/actionlistener.h"
-
-const unsigned int OUTFITS_COUNT = 100;
-const unsigned int OUTFIT_ITEM_COUNT = 16;
-
-class Button;
-class CheckBox;
-class Label;
-
-class OutfitWindow final : public Window,
- private ActionListener
-{
- public:
- /**
- * Constructor.
- */
- OutfitWindow();
-
- A_DELETE_COPY(OutfitWindow)
-
- /**
- * Destructor.
- */
- ~OutfitWindow();
-
- void action(const ActionEvent &event) override final;
-
- void draw(Graphics *const graphics) override final A_NONNULL(2);
-
- void safeDraw(Graphics *const graphics) override final A_NONNULL(2);
-
- void mousePressed(MouseEvent &event) override final;
-
- void mouseDragged(MouseEvent &event) override final;
-
- void mouseReleased(MouseEvent &event) override final;
-
- void load();
-
- void wearOutfit(const int outfit, const bool unwearEmpty = true,
- const bool select = false);
-
- void copyOutfit(const int outfit);
-
- void copyOutfit(const int src, const int dst);
-
- void copyFromEquiped();
-
- void copyFromEquiped(const int dst);
-
- void unequipNotInOutfit(const int outfit) const;
-
- void next();
-
- void previous();
-
- void wearNextOutfit(const bool all = false);
-
- void wearPreviousOutfit(const bool all = false);
-
- void wearAwayOutfit();
-
- void unwearAwayOutfit();
-
- void showCurrentOutfit();
-
- static std::string keyName(const int number) A_WARN_UNUSED;
-
- void clearCurrentOutfit();
-
- std::string getOutfitString() const;
-
- private:
- int getIndexFromGrid(const int pointX,
- const int pointY) const A_WARN_UNUSED;
- void save() const;
-
- Button *mPreviousButton A_NONNULLPOINTER;
- Button *mNextButton A_NONNULLPOINTER;
- Button *mEquipBottom A_NONNULLPOINTER;
- Label *mCurrentLabel A_NONNULLPOINTER;
- CheckBox *mUnequipCheck A_NONNULLPOINTER;
- CheckBox *mAwayOutfitCheck A_NONNULLPOINTER;
- Label *mKeyLabel A_NONNULLPOINTER;
-
- Color mBorderColor;
-
- int mCurrentOutfit;
- int mBoxWidth;
- int mBoxHeight;
- int mGridWidth;
- int mGridHeight;
-
- int mItems[OUTFITS_COUNT + 1][OUTFIT_ITEM_COUNT];
- int mAwayOutfit;
-
- ItemColor mItemColors[OUTFITS_COUNT + 1][OUTFIT_ITEM_COUNT];
- bool mItemClicked;
- bool mItemsUnequip[OUTFITS_COUNT];
-};
-
-extern OutfitWindow *outfitWindow;
-
-#endif // GUI_WINDOWS_OUTFITWINDOW_H
diff --git a/src/gui/windows/questswindow.cpp b/src/gui/windows/questswindow.cpp
deleted file mode 100644
index 269f2aab9..000000000
--- a/src/gui/windows/questswindow.cpp
+++ /dev/null
@@ -1,483 +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 "gui/windows/questswindow.h"
-
-#include "actormanager.h"
-#include "configuration.h"
-#include "effectmanager.h"
-
-#include "being/localplayer.h"
-
-#include "enums/gui/layouttype.h"
-
-#include "gui/gui.h"
-
-#include "gui/fonts/font.h"
-
-#include "gui/models/questsmodel.h"
-
-#include "gui/windows/setupwindow.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/browserbox.h"
-#include "gui/widgets/containerplacer.h"
-#include "gui/widgets/createwidget.h"
-#include "gui/widgets/layout.h"
-#include "gui/widgets/extendedlistbox.h"
-#include "gui/widgets/itemlinkhandler.h"
-#include "gui/widgets/scrollarea.h"
-
-#include "utils/delete2.h"
-#include "utils/foreach.h"
-#include "utils/gettext.h"
-
-#include "resources/questeffect.h"
-#include "resources/questitem.h"
-
-#include "resources/db/questdb.h"
-
-#include "resources/map/map.h"
-
-#include "debug.h"
-
-QuestsWindow *questsWindow = nullptr;
-
-QuestsWindow::QuestsWindow() :
- // TRANSLATORS: quests window name
- Window(_("Quests"), Modal_false, nullptr, "quests.xml"),
- ActionListener(),
- mQuestsModel(new QuestsModel),
- mQuestsListBox(CREATEWIDGETR(ExtendedListBox,
- this, mQuestsModel, "extendedlistbox.xml")),
- mQuestScrollArea(new ScrollArea(this, mQuestsListBox,
- fromBool(getOptionBool("showlistbackground"), Opaque),
- "quests_list_background.xml")),
- mItemLinkHandler(new ItemLinkHandler),
- mText(new BrowserBox(this, Opaque_true,
- "browserbox.xml")),
- mTextScrollArea(new ScrollArea(this, mText,
- fromBool(getOptionBool("showtextbackground"), Opaque),
- "quests_text_background.xml")),
- // TRANSLATORS: quests window button
- mCloseButton(new Button(this, _("Close"), "close", this)),
- mCompleteIcon(Theme::getImageFromThemeXml("complete_icon.xml", "")),
- mIncompleteIcon(Theme::getImageFromThemeXml("incomplete_icon.xml", "")),
- mMapEffects(),
- mVars(nullptr),
- mQuests(nullptr),
- mAllEffects(nullptr),
- mNpcEffects(),
- mQuestLinks(),
- mQuestReverseLinks(),
- mNewQuestEffectId(paths.getIntValue("newQuestEffectId")),
- mCompleteQuestEffectId(paths.getIntValue("completeQuestEffectId")),
- mMap(nullptr)
-{
- setWindowName("Quests");
- setResizable(true);
- setCloseButton(true);
- setStickyButtonLock(true);
- setSaveVisible(true);
-
- setDefaultSize(400, 350, ImagePosition::RIGHT);
- setMinWidth(310);
- setMinHeight(220);
-
- if (setupWindow != nullptr)
- setupWindow->registerWindowForReset(this);
-
- mQuestsListBox->setActionEventId("select");
- mQuestsListBox->addActionListener(this);
-
- mQuestScrollArea->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
- mText->setOpaque(Opaque_false);
- mText->setLinkHandler(mItemLinkHandler);
- mTextScrollArea->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
- mQuestsListBox->setWidth(500);
- if ((gui == nullptr) || gui->getNpcFont()->getHeight() < 20)
- mQuestsListBox->setRowHeight(20);
- else
- mQuestsListBox->setRowHeight(gui->getNpcFont()->getHeight());
-
- ContainerPlacer placer;
- placer = getPlacer(0, 0);
-
- placer(0, 0, mQuestScrollArea, 4, 3).setPadding(3);
- placer(4, 0, mTextScrollArea, 4, 3).setPadding(3);
- placer(7, 3, mCloseButton);
-
- Layout &layout = getLayout();
- layout.setRowHeight(0, LayoutType::SET);
-
- loadWindowState();
- enableVisibleSound(true);
- QuestDb::load();
- mVars = QuestDb::getVars();
- mQuests = QuestDb::getQuests();
- mAllEffects = QuestDb::getAllEffects();
-}
-
-QuestsWindow::~QuestsWindow()
-{
- delete2(mQuestsModel);
-
- QuestDb::unload();
-
- delete2(mItemLinkHandler);
- mQuestLinks.clear();
- mQuestReverseLinks.clear();
- if (mCompleteIcon != nullptr)
- {
- mCompleteIcon->decRef();
- mCompleteIcon = nullptr;
- }
- if (mIncompleteIcon != nullptr)
- {
- mIncompleteIcon->decRef();
- mIncompleteIcon = nullptr;
- }
-}
-
-void QuestsWindow::action(const ActionEvent &event)
-{
- const std::string &eventId = event.getId();
- if (eventId == "select")
- {
- const int id = mQuestsListBox->getSelected();
- if (id < 0)
- return;
- showQuest(mQuestLinks[id]);
- }
- else if (eventId == "close")
- {
- setVisible(Visible_false);
- }
-}
-
-void QuestsWindow::updateQuest(const int var,
- const int val1,
- const int val2,
- const int val3,
- const int time1)
-{
- (*mVars)[var] = QuestVar(val1, val2, val3, time1);
-}
-
-void QuestsWindow::rebuild(const bool playSound)
-{
- mQuestsModel->clear();
- mQuestLinks.clear();
- mQuestReverseLinks.clear();
- StringVect &names = mQuestsModel->getNames();
- STD_VECTOR<Image*> &images = mQuestsModel->getImages();
- STD_VECTOR<QuestItem*> complete;
- STD_VECTOR<QuestItem*> incomplete;
- STD_VECTOR<QuestItem*> hidden;
- int updatedQuest = -1;
- int newCompleteStatus = -1;
-
- FOR_EACHP (NpcQuestVarMapCIter, it, mVars)
- {
- const int var = (*it).first;
- const QuestVar &val = (*it).second;
- const STD_VECTOR<QuestItem*> &quests = (*mQuests)[var];
- FOR_EACH (STD_VECTOR<QuestItem*>::const_iterator, it2, quests)
- {
- if (*it2 == nullptr)
- continue;
- QuestItem *const quest = *it2;
- // complete quest
- if (quest->complete.find(val.var1) != quest->complete.end())
- {
- complete.push_back(quest);
- }
- // incomplete quest
- else if (quest->incomplete.find(val.var1) !=
- quest->incomplete.end())
- {
- incomplete.push_back(quest);
- }
- // hidden quest
- else
- {
- hidden.push_back(quest);
- }
- }
- }
-
- int k = 0;
-
- for (STD_VECTOR<QuestItem*>::const_iterator it = complete.begin(),
- it_end = complete.end(); it != it_end; ++ it, k ++)
- {
- QuestItem *const quest = *it;
- if (quest->completeFlag == 0 || (quest->broken
- && quest->completeFlag == -1))
- {
- updatedQuest = k;
- newCompleteStatus = 1;
- }
- quest->completeFlag = 1;
- mQuestLinks.push_back(quest);
- mQuestReverseLinks[quest->var] = k;
- names.push_back(quest->name);
- if (mCompleteIcon != nullptr)
- {
- mCompleteIcon->incRef();
- images.push_back(mCompleteIcon);
- }
- else
- {
- images.push_back(nullptr);
- }
- }
-
- for (STD_VECTOR<QuestItem*>::const_iterator it = incomplete.begin(),
- it_end = incomplete.end(); it != it_end; ++ it, k ++)
- {
- QuestItem *const quest = *it;
- if (quest->completeFlag == -1)
- {
- updatedQuest = k;
- newCompleteStatus = 0;
- }
- quest->completeFlag = 0;
- mQuestLinks.push_back(quest);
- mQuestReverseLinks[quest->var] = k;
- names.push_back(quest->name);
- if (mIncompleteIcon != nullptr)
- {
- mIncompleteIcon->incRef();
- images.push_back(mIncompleteIcon);
- }
- else
- {
- images.push_back(nullptr);
- }
- }
-
- FOR_EACH (STD_VECTOR<QuestItem*>::const_iterator, it, hidden)
- (*it)->completeFlag = -1;
-
- if (updatedQuest == -1 || updatedQuest >= CAST_S32(
- mQuestLinks.size()))
- {
- updatedQuest = CAST_S32(mQuestLinks.size() - 1);
- }
- if (updatedQuest >= 0)
- {
- mQuestsListBox->setSelected(updatedQuest);
- showQuest(mQuestLinks[updatedQuest]);
- if (playSound && (effectManager != nullptr))
- {
- switch (newCompleteStatus)
- {
- case 0:
- effectManager->trigger(mNewQuestEffectId, localPlayer);
- break;
- case 1:
- effectManager->trigger(mCompleteQuestEffectId,
- localPlayer);
- break;
- default:
- break;
- }
- }
- }
- updateEffects();
-}
-
-void QuestsWindow::showQuest(const QuestItem *const quest)
-{
- if (quest == nullptr)
- return;
-
- const STD_VECTOR<QuestItemText> &texts = quest->texts;
- const QuestVar &var = (*mVars)[quest->var];
- const std::string var1 = toString(var.var1);
- const std::string var2 = toString(var.var2);
- const std::string var3 = toString(var.var3);
- const std::string timeStr = timeDiffToString(var.time1);
- mText->clearRows();
- FOR_EACH (STD_VECTOR<QuestItemText>::const_iterator, it, texts)
- {
- const QuestItemText &data = *it;
- std::string text = data.text;
- replaceAll(text, "{@@var1}", var1);
- replaceAll(text, "{@@var2}", var2);
- replaceAll(text, "{@@var3}", var3);
- replaceAll(text, "{@@time}", timeStr);
- switch (data.type)
- {
- case QuestType::TEXT:
- default:
- mText->addRow(text);
- break;
- case QuestType::NAME:
- mText->addRow(std::string("[").append(text).append("]"));
- break;
- case QuestType::REWARD:
- mText->addRow(std::string(
- // TRANSLATORS: quest reward
- _("Reward:")).append(
- " ").append(
- text));
- break;
- case QuestType::GIVER:
- mText->addRow(std::string(
- // TRANSLATORS: quest giver name
- _("Quest Giver:")).append(
- " ").append(
- text));
- break;
- case QuestType::NPC:
- mText->addRow(std::string(
- // TRANSLATORS: quest npc name
- _("Npc:")).append(
- " ").append(
- text));
- break;
- case QuestType::COORDINATES:
- mText->addRow(std::string(
- strprintf("%s [@@=navigate %s %s|%s@@]",
- // TRANSLATORS: quest coordinates
- _("Coordinates:"),
- data.data1.c_str(),
- data.data2.c_str(),
- text.c_str())));
- break;
- }
- }
- mText->updateHeight();
-}
-
-void QuestsWindow::setMap(const Map *const map)
-{
- if (mMap != map)
- {
- mMap = map;
- mMapEffects.clear();
- if (mMap == nullptr)
- return;
-
- const std::string name = mMap->getProperty("shortName");
- FOR_EACHP (STD_VECTOR<QuestEffect*>::const_iterator, it, mAllEffects)
- {
- const QuestEffect *const effect = *it;
- if ((effect != nullptr) && name == effect->map)
- mMapEffects.push_back(effect);
- }
- updateEffects();
- }
-}
-
-void QuestsWindow::updateEffects()
-{
- NpcQuestEffectMap oldNpc = mNpcEffects;
- mNpcEffects.clear();
-
- FOR_EACH (STD_VECTOR<const QuestEffect*>::const_iterator,
- it, mMapEffects)
- {
- const QuestEffect *const effect = *it;
- if (effect != nullptr)
- {
- const NpcQuestVarMapCIter varIt = mVars->find(effect->var);
- if (varIt != mVars->end())
- {
- const std::set<int> &vals = effect->values;
- if (vals.find((*mVars)[effect->var].var1) != vals.end())
- mNpcEffects[effect->id] = effect;
- }
- }
- }
- if (actorManager == nullptr)
- return;
-
- std::set<BeingTypeId> removeEffects;
- std::map<BeingTypeId, int> addEffects;
-
- // for old effects
- FOR_EACH (NpcQuestEffectMapCIter, it, oldNpc)
- {
- const BeingTypeId id = (*it).first;
- const QuestEffect *const effect = (*it).second;
-
- const NpcQuestEffectMapCIter itNew = mNpcEffects.find(id);
- if (itNew == mNpcEffects.end())
- { // in new list no effect for this npc
- removeEffects.insert(id);
- }
- else
- { // in new list exists effect for this npc
- const QuestEffect *const newEffect = (*itNew).second;
- if (effect != newEffect)
- { // new effects is not equal to old effect
- addEffects[id] = newEffect->effectId;
- removeEffects.insert(id);
- }
- }
- }
-
- // for new effects
- FOR_EACH (NpcQuestEffectMapCIter, it, mNpcEffects)
- {
- const BeingTypeId id = (*it).first;
- const QuestEffect *const effect = (*it).second;
-
- const NpcQuestEffectMapCIter itNew = oldNpc.find(id);
- // check if old effect was not present
- if (itNew == oldNpc.end())
- addEffects[id] = effect->effectId;
- }
- if (!removeEffects.empty() || !addEffects.empty())
- actorManager->updateEffects(addEffects, removeEffects);
-}
-
-void QuestsWindow::addEffect(Being *const being)
-{
- if (being == nullptr)
- return;
- const BeingTypeId id = being->getSubType();
- const std::map<BeingTypeId, const QuestEffect*>::const_iterator
- it = mNpcEffects.find(id);
- if (it != mNpcEffects.end())
- {
- const QuestEffect *const effect = (*it).second;
- if (effect != nullptr)
- being->addSpecialEffect(effect->effectId);
- }
-}
-
-void QuestsWindow::selectQuest(const int varId)
-{
- std::map<int, int>::const_iterator it = mQuestReverseLinks.find(varId);
- if (it == mQuestReverseLinks.end())
- return;
- if (mVisible == Visible_false)
- setVisible(Visible_true);
- const int listPos = (*it).second;
- if (listPos < 0)
- return;
- showQuest(mQuestLinks[listPos]);
- mQuestsListBox->setSelected(listPos);
- requestMoveToTop();
-}
diff --git a/src/gui/windows/questswindow.h b/src/gui/windows/questswindow.h
deleted file mode 100644
index fd4175754..000000000
--- a/src/gui/windows/questswindow.h
+++ /dev/null
@@ -1,105 +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 GUI_WINDOWS_QUESTSWINDOW_H
-#define GUI_WINDOWS_QUESTSWINDOW_H
-
-#include "localconsts.h"
-
-#include "enums/simpletypes/beingtypeid.h"
-
-#include "gui/widgets/window.h"
-
-#include "listeners/actionlistener.h"
-
-#include "resources/questvar.h"
-
-class Being;
-class BrowserBox;
-class Button;
-class ExtendedListBox;
-class ItemLinkHandler;
-class Map;
-class ScrollArea;
-class QuestsModel;
-
-struct QuestEffect;
-struct QuestItem;
-
-typedef std::map<BeingTypeId, const QuestEffect*> NpcQuestEffectMap;
-typedef NpcQuestEffectMap::const_iterator NpcQuestEffectMapCIter;
-
-class QuestsWindow final : public Window,
- public ActionListener
-{
- public:
- QuestsWindow();
-
- A_DELETE_COPY(QuestsWindow)
-
- ~QuestsWindow();
-
- void action(const ActionEvent &event) override final;
-
- void updateQuest(const int var,
- const int val1,
- const int val2,
- const int val3,
- const int time1);
-
- void rebuild(const bool playSound);
-
- void showQuest(const QuestItem *const quest);
-
- void setMap(const Map *const map);
-
- void updateEffects();
-
- void addEffect(Being *const being);
-
- void selectQuest(const int varId);
-
- private:
- QuestsModel *mQuestsModel A_NONNULLPOINTER;
- ExtendedListBox *mQuestsListBox A_NONNULLPOINTER;
- ScrollArea *mQuestScrollArea A_NONNULLPOINTER;
- ItemLinkHandler *mItemLinkHandler A_NONNULLPOINTER;
- BrowserBox *mText A_NONNULLPOINTER;
- ScrollArea *mTextScrollArea A_NONNULLPOINTER;
- Button *mCloseButton A_NONNULLPOINTER;
- Image *mCompleteIcon;
- Image *mIncompleteIcon;
- STD_VECTOR<const QuestEffect*> mMapEffects;
- NpcQuestVarMap *mVars;
- std::map<int, STD_VECTOR<QuestItem*> > *mQuests;
- STD_VECTOR<QuestEffect*> *mAllEffects;
-
- // npc effects for current map and values: npc, effect
- NpcQuestEffectMap mNpcEffects;
- STD_VECTOR<QuestItem*> mQuestLinks;
- std::map<int, int> mQuestReverseLinks;
- int mNewQuestEffectId;
- int mCompleteQuestEffectId;
- const Map *mMap;
-};
-
-extern QuestsWindow *questsWindow;
-
-#endif // GUI_WINDOWS_QUESTSWINDOW_H
diff --git a/src/gui/windows/quitdialog.cpp b/src/gui/windows/quitdialog.cpp
deleted file mode 100644
index b9ef417c3..000000000
--- a/src/gui/windows/quitdialog.cpp
+++ /dev/null
@@ -1,260 +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 "gui/windows/quitdialog.h"
-
-#include "client.h"
-#include "configuration.h"
-#include "soundmanager.h"
-
-#include "const/sound.h"
-
-#include "gui/dialogsmanager.h"
-#include "gui/viewport.h"
-
-#include "gui/widgets/containerplacer.h"
-#include "gui/widgets/button.h"
-#include "gui/widgets/radiobutton.h"
-
-#include "net/charserverhandler.h"
-#include "net/gamehandler.h"
-
-#include "resources/map/map.h"
-
-#include "utils/delete2.h"
-#include "utils/gettext.h"
-#include "utils/process.h"
-
-#include "debug.h"
-
-QuitDialog::QuitDialog(QuitDialog **const pointerToMe) :
- // TRANSLATORS: quit dialog name
- Window(_("Quit"), Modal_true, nullptr, "quit.xml"),
- ActionListener(),
- KeyListener(),
- mOptions(),
- // TRANSLATORS: quit dialog button
- mLogoutQuit(new RadioButton(this, _("Quit"), "quitdialog")),
- // TRANSLATORS: quit dialog button
- mForceQuit(new RadioButton(this, _("Quit"), "quitdialog")),
- mSwitchAccountServer(new RadioButton(this,
- // TRANSLATORS: quit dialog button
- _("Switch server"), "quitdialog")),
- mSwitchCharacter(new RadioButton(this,
- // TRANSLATORS: quit dialog button
- _("Switch character"), "quitdialog")),
- mRate(nullptr),
- // TRANSLATORS: quit dialog button
- mOkButton(new Button(this, _("OK"), "ok", this)),
- // TRANSLATORS: quit dialog button
- mCancelButton(new Button(this, _("Cancel"), "cancel", this)),
- mMyPointer(pointerToMe),
- mNeedForceQuit(false)
-{
- addKeyListener(this);
-
- ContainerPlacer placer = getPlacer(0, 0);
- const StateT state = client->getState();
- mNeedForceQuit = (state == State::CHOOSE_SERVER
- || state == State::CONNECT_SERVER || state == State::LOGIN
- || state == State::PRE_LOGIN || state == State::LOGIN_ATTEMPT
- || state == State::UPDATE || state == State::LOAD_DATA);
-
- // All states, when we're not logged in to someone.
- if (mNeedForceQuit)
- {
- placeOption(placer, mForceQuit);
- }
- else
- {
- // Only added if we are connected to an accountserver or gameserver
- placeOption(placer, mLogoutQuit);
- placeOption(placer, mSwitchAccountServer);
-
- // Only added if we are connected to a gameserver
- if (state == State::GAME)
- placeOption(placer, mSwitchCharacter);
- }
-
-/*
-#ifdef ANDROID
- if (config.getBoolValue("rated") == false
- && config.getIntValue("gamecount") > 3)
- {
- // TRANSLATORS: rate button
- mRate = new RadioButton(this, _("Rate in google play"), "quitdialog");
- placeOption(placer, mRate);
- mOptions[mOptions.size() - 1]->setSelected(true);
- }
- else
-#endif
-*/
- {
- mOptions[0]->setSelected(true);
- }
-
- placer = getPlacer(0, 1);
- placer(1, 0, mOkButton, 1);
- placer(2, 0, mCancelButton, 1);
- reflowLayout(200, 0);
-}
-
-void QuitDialog::postInit()
-{
- Window::postInit();
- setLocationRelativeTo(getParent());
- setVisible(Visible_true);
- soundManager.playGuiSound(SOUND_SHOW_WINDOW);
- requestModalFocus();
- mOkButton->requestFocus();
-}
-
-QuitDialog::~QuitDialog()
-{
- if (mMyPointer != nullptr)
- *mMyPointer = nullptr;
- delete2(mForceQuit);
- delete2(mLogoutQuit);
- delete2(mSwitchAccountServer);
- delete2(mSwitchCharacter);
-}
-
-void QuitDialog::placeOption(ContainerPlacer &placer,
- RadioButton *const option)
-{
- placer(0, CAST_S32(mOptions.size()), option, 3);
- mOptions.push_back(option);
-}
-
-void QuitDialog::action(const ActionEvent &event)
-{
- soundManager.playGuiSound(SOUND_HIDE_WINDOW);
- if (event.getId() == "ok")
- {
- if (viewport != nullptr)
- {
- const Map *const map = viewport->getMap();
- if (map != nullptr)
- map->saveExtraLayer();
- }
-
- if (mForceQuit->isSelected())
- {
- client->setState(State::FORCE_QUIT);
- }
- else if (mLogoutQuit->isSelected())
- {
- DialogsManager::closeDialogs();
- client->setState(State::EXIT);
- }
- else if ((mRate != nullptr) && mRate->isSelected())
- {
- openBrowser("https://play.google.com/store/apps/details?"
- "id=org.evolonline.beta.manaplus");
- config.setValue("rated", true);
- if (mNeedForceQuit)
- {
- client->setState(State::FORCE_QUIT);
- }
- else
- {
- DialogsManager::closeDialogs();
- client->setState(State::EXIT);
- }
- }
- else if (gameHandler->isConnected()
- && mSwitchAccountServer->isSelected())
- {
- DialogsManager::closeDialogs();
- client->setState(State::SWITCH_SERVER);
- }
- else if (mSwitchCharacter->isSelected())
- {
- if (client->getState() == State::GAME)
- {
- charServerHandler->switchCharacter();
- DialogsManager::closeDialogs();
- serverConfig.write();
- }
- }
- }
- scheduleDelete();
-}
-
-void QuitDialog::keyPressed(KeyEvent &event)
-{
- const InputActionT actionId = event.getActionId();
- int dir = 0;
-
- PRAGMA45(GCC diagnostic push)
- PRAGMA45(GCC diagnostic ignored "-Wswitch-enum")
- switch (actionId)
- {
- case InputAction::GUI_SELECT:
- case InputAction::GUI_SELECT2:
- action(ActionEvent(nullptr, mOkButton->getActionEventId()));
- break;
- case InputAction::GUI_CANCEL:
- action(ActionEvent(nullptr, mCancelButton->getActionEventId()));
- break;
- case InputAction::GUI_UP:
- dir = -1;
- break;
- case InputAction::GUI_DOWN:
- dir = 1;
- break;
- default:
- break;
- }
- PRAGMA45(GCC diagnostic pop)
-
- if (dir != 0)
- {
- STD_VECTOR<RadioButton*>::const_iterator it = mOptions.begin();
- const STD_VECTOR<RadioButton*>::const_iterator
- it_end = mOptions.end();
-
- for (; it < it_end; ++it)
- {
- if ((*it)->isSelected())
- break;
- }
-
- if (it == mOptions.end())
- {
- if (mOptions[0] != nullptr)
- mOptions[0]->setSelected(true);
- return;
- }
- else if (it == mOptions.begin() && dir < 0)
- {
- it = mOptions.end();
- }
-
- it += dir;
-
- if (it == mOptions.end())
- it = mOptions.begin();
-
- (*it)->setSelected(true);
- }
-}
diff --git a/src/gui/windows/quitdialog.h b/src/gui/windows/quitdialog.h
deleted file mode 100644
index e12e13e7b..000000000
--- a/src/gui/windows/quitdialog.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 GUI_WINDOWS_QUITDIALOG_H
-#define GUI_WINDOWS_QUITDIALOG_H
-
-#include "gui/widgets/window.h"
-
-#include "listeners/actionlistener.h"
-#include "listeners/keylistener.h"
-
-class Button;
-class RadioButton;
-
-/**
- * The quit dialog.
- *
- * \ingroup Interface
- */
-class QuitDialog final : public Window,
- public ActionListener,
- public KeyListener
-{
- public:
- /**
- * Constructor
- *
- * @pointerToMe will be set to NULL when the QuitDialog is destroyed
- */
- explicit QuitDialog(QuitDialog **const pointerToMe) A_NONNULL(2);
-
- A_DELETE_COPY(QuitDialog)
-
- /**
- * Destructor
- */
- ~QuitDialog();
-
- void postInit() override final;
-
- /**
- * Called when receiving actions from the widgets.
- */
- void action(const ActionEvent &event) override final;
-
- void keyPressed(KeyEvent &event) override final;
-
- private:
- void placeOption(ContainerPlacer &placer,
- RadioButton *const option);
- STD_VECTOR<RadioButton*> mOptions;
-
- RadioButton *mLogoutQuit A_NONNULLPOINTER;
- RadioButton *mForceQuit A_NONNULLPOINTER;
- RadioButton *mSwitchAccountServer A_NONNULLPOINTER;
- RadioButton *mSwitchCharacter A_NONNULLPOINTER;
- RadioButton *mRate A_NONNULLPOINTER;
- Button *mOkButton A_NONNULLPOINTER;
- Button *mCancelButton A_NONNULLPOINTER;
-
- QuitDialog **mMyPointer A_NONNULLPOINTER;
- bool mNeedForceQuit;
-};
-
-#endif // GUI_WINDOWS_QUITDIALOG_H
diff --git a/src/gui/windows/registerdialog.cpp b/src/gui/windows/registerdialog.cpp
deleted file mode 100644
index 699023d93..000000000
--- a/src/gui/windows/registerdialog.cpp
+++ /dev/null
@@ -1,317 +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 "gui/windows/registerdialog.h"
-
-#include "client.h"
-#include "configuration.h"
-
-#include "being/being.h"
-
-#include "gui/windows/okdialog.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/containerplacer.h"
-#include "gui/widgets/createwidget.h"
-#include "gui/widgets/label.h"
-#include "gui/widgets/layoutcell.h"
-#include "gui/widgets/passwordfield.h"
-#include "gui/widgets/radiobutton.h"
-
-#include "listeners/wrongdatanoticelistener.h"
-
-#include "net/logindata.h"
-#include "net/loginhandler.h"
-#include "net/serverfeatures.h"
-
-#include "utils/delete2.h"
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-RegisterDialog::RegisterDialog(LoginData &data) :
- // TRANSLATORS: register dialog name
- Window(_("Register"), Modal_false, nullptr, "register.xml"),
- ActionListener(),
- KeyListener(),
- mLoginData(&data),
- mUserField(new TextField(this, mLoginData->username)),
- mPasswordField(new PasswordField(this, mLoginData->password)),
- mConfirmField(new PasswordField(this)),
- mEmailField(nullptr),
- // TRANSLATORS: register dialog. button.
- mRegisterButton(new Button(this, _("Register"), "register", this)),
- // TRANSLATORS: register dialog. button.
- mCancelButton(new Button(this, _("Cancel"), "cancel", this)),
- mMaleButton(nullptr),
- mFemaleButton(nullptr),
- mWrongDataNoticeListener(new WrongDataNoticeListener)
-{
- setCloseButton(true);
-
- // TRANSLATORS: register dialog. label.
- Label *const userLabel = new Label(this, _("Name:"));
- // TRANSLATORS: register dialog. label.
- Label *const passwordLabel = new Label(this, _("Password:"));
- // TRANSLATORS: register dialog. label.
- Label *const confirmLabel = new Label(this, _("Confirm:"));
-
- ContainerPlacer placer;
- placer = getPlacer(0, 0);
- placer(0, 0, userLabel);
- placer(0, 1, passwordLabel);
- placer(0, 2, confirmLabel);
-
- placer(1, 0, mUserField, 3).setPadding(2);
- placer(1, 1, mPasswordField, 3).setPadding(2);
- placer(1, 2, mConfirmField, 3).setPadding(2);
-
- int row = 3;
-
- if (features.getIntValue("forceAccountGender") == -1)
- {
- // TRANSLATORS: register dialog. button.
- mMaleButton = new RadioButton(this, _("Male"), "sex", true);
- // TRANSLATORS: register dialog. button.
- mFemaleButton = new RadioButton(this, _("Female"), "sex", false);
- placer(1, row, mMaleButton);
- placer(2, row, mFemaleButton);
-
- row++;
- }
-
- if (serverFeatures->haveEmailOnRegister())
- {
- // TRANSLATORS: register dialog. label.
- Label *const emailLabel = new Label(this, _("Email:"));
- mEmailField = new TextField(this);
- placer(0, row, emailLabel);
- placer(1, row, mEmailField, 3).setPadding(2);
- mEmailField->addKeyListener(this);
- mEmailField->setActionEventId("register");
- mEmailField->addActionListener(this);
-// row++;
- }
-
- placer = getPlacer(0, 2);
- placer(1, 0, mRegisterButton);
- placer(2, 0, mCancelButton);
- reflowLayout(250, 0);
-
- mUserField->addKeyListener(this);
- mPasswordField->addKeyListener(this);
- mConfirmField->addKeyListener(this);
-
- mUserField->setActionEventId("register");
- mPasswordField->setActionEventId("register");
- mConfirmField->setActionEventId("register");
-
- mUserField->addActionListener(this);
- mPasswordField->addActionListener(this);
- mConfirmField->addActionListener(this);
-
- center();
-}
-
-void RegisterDialog::postInit()
-{
- Window::postInit();
- setVisible(Visible_true);
- mUserField->requestFocus();
- mUserField->setCaretPosition(CAST_U32(
- mUserField->getText().length()));
-
- mRegisterButton->setEnabled(canSubmit());
-}
-
-RegisterDialog::~RegisterDialog()
-{
- delete2(mWrongDataNoticeListener);
-}
-
-void RegisterDialog::action(const ActionEvent &event)
-{
- const std::string &eventId = event.getId();
- if (eventId == "cancel")
- {
- close();
- }
- else if (eventId == "register" && canSubmit())
- {
- const std::string &user = mUserField->getText();
- logger->log("RegisterDialog::register Username is %s", user.c_str());
-
- std::string errorMsg;
- int error = 0;
-
- const unsigned int minUser = loginHandler->getMinUserNameLength();
- const unsigned int maxUser = loginHandler->getMaxUserNameLength();
- const unsigned int minPass = loginHandler->getMinPasswordLength();
- const unsigned int maxPass = loginHandler->getMaxPasswordLength();
-
- if (user.length() < minUser)
- {
- // Name too short
- errorMsg = strprintf
- // TRANSLATORS: error message
- (_("The username needs to be at least %u characters long."),
- minUser);
- error = 1;
- }
- else if (user.length() > maxUser - 1)
- {
- // Name too long
- errorMsg = strprintf
- // TRANSLATORS: error message
- (_("The username needs to be less than %u characters long."),
- maxUser);
- error = 1;
- }
- else if (mPasswordField->getText().length() < minPass)
- {
- // Pass too short
- errorMsg = strprintf
- // TRANSLATORS: error message
- (_("The password needs to be at least %u characters long."),
- minPass);
- error = 2;
- }
- else if (mPasswordField->getText().length() > maxPass)
- {
- // Pass too long
- errorMsg = strprintf
- // TRANSLATORS: error message
- (_("The password needs to be less than %u characters long."),
- maxPass);
- error = 2;
- }
- else if (mPasswordField->getText() != mConfirmField->getText())
- {
- // Password does not match with the confirmation one
- // TRANSLATORS: error message
- errorMsg = _("Passwords do not match.");
- error = 2;
- }
- else if ((mEmailField != nullptr) &&
- mEmailField->getText().find('@') == std::string::npos)
- {
- // TRANSLATORS: error message
- errorMsg = _("Incorrect email.");
- error = 1;
- }
- else if (mEmailField != nullptr &&
- mEmailField->getText().size() > 40)
- {
- // TRANSLATORS: error message
- errorMsg = _("Email too long.");
- error = 1;
- }
-
- if (error > 0)
- {
- if (error == 1)
- {
- mWrongDataNoticeListener->setTarget(this->mUserField);
- }
- else if (error == 2)
- {
- // Reset password confirmation
- mPasswordField->setText("");
- mConfirmField->setText("");
- mWrongDataNoticeListener->setTarget(this->mPasswordField);
- }
-
- OkDialog *const dlg = CREATEWIDGETR(OkDialog,
- // TRANSLATORS: error message
- _("Error"), errorMsg, _("OK"),
- DialogType::ERROR,
- Modal_true,
- ShowCenter_true,
- nullptr,
- 260);
- dlg->addActionListener(mWrongDataNoticeListener);
- }
- else
- {
- // No errors detected, register the new user.
- mRegisterButton->setEnabled(false);
- mLoginData->username = mUserField->getText();
- mLoginData->password = mPasswordField->getText();
- if (features.getIntValue("forceAccountGender") == -1)
- {
- if ((mFemaleButton != nullptr) && mFemaleButton->isSelected())
- mLoginData->gender = Gender::FEMALE;
- else
- mLoginData->gender = Gender::MALE;
- }
- else
- {
- mLoginData->gender = Being::intToGender(
- CAST_U8(features.getIntValue("forceAccountGender")));
- }
-
- if (mEmailField != nullptr)
- mLoginData->email = mEmailField->getText();
- mLoginData->registerLogin = true;
-
- client->setState(State::REGISTER_ATTEMPT);
- }
- }
-}
-
-void RegisterDialog::keyPressed(KeyEvent &event)
-{
- if (event.isConsumed())
- {
- mRegisterButton->setEnabled(canSubmit());
- return;
- }
- const InputActionT actionId = event.getActionId();
- if (actionId == InputAction::GUI_CANCEL)
- {
- action(ActionEvent(nullptr, mCancelButton->getActionEventId()));
- }
- else if (actionId == InputAction::GUI_SELECT ||
- actionId == InputAction::GUI_SELECT2)
- {
- action(ActionEvent(nullptr, mRegisterButton->getActionEventId()));
- }
- else
- {
- mRegisterButton->setEnabled(canSubmit());
- }
-}
-
-bool RegisterDialog::canSubmit() const
-{
- return !mUserField->getText().empty() &&
- !mPasswordField->getText().empty() &&
- !mConfirmField->getText().empty() &&
- client->getState() == State::REGISTER &&
- ((mEmailField == nullptr) || !mEmailField->getText().empty());
-}
-
-void RegisterDialog::close()
-{
- client->setState(State::LOGIN);
- Window::close();
-}
diff --git a/src/gui/windows/registerdialog.h b/src/gui/windows/registerdialog.h
deleted file mode 100644
index d0d0d821a..000000000
--- a/src/gui/windows/registerdialog.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 GUI_WINDOWS_REGISTERDIALOG_H
-#define GUI_WINDOWS_REGISTERDIALOG_H
-
-#include "gui/widgets/window.h"
-
-#include "listeners/actionlistener.h"
-#include "listeners/keylistener.h"
-
-class Button;
-class LoginData;
-class RadioButton;
-class TextField;
-class WrongDataNoticeListener;
-
-/**
- * The registration dialog.
- *
- * \ingroup Interface
- */
-class RegisterDialog final : public Window,
- public ActionListener,
- public KeyListener
-{
- public:
- /**
- * Constructor. Name, password and server fields will be initialized to
- * the information already present in the LoginData instance.
- *
- * @see Window::Window
- */
- explicit RegisterDialog(LoginData &loginData);
-
- A_DELETE_COPY(RegisterDialog)
-
- /**
- * Destructor
- */
- ~RegisterDialog();
-
- void postInit() override;
-
- /**
- * Called when receiving actions from the widgets.
- */
- void action(const ActionEvent &event) override;
-
- /**
- * Called when a key is pressed in one of the text fields.
- */
- void keyPressed(KeyEvent &event) override;
-
- void close() override;
-
- private:
- /**
- * Returns whether submit can be enabled. This is true in the register
- * state, when all necessary fields have some text.
- */
- bool canSubmit() const;
-
- LoginData *mLoginData A_NONNULLPOINTER;
- TextField *mUserField A_NONNULLPOINTER;
- TextField *mPasswordField A_NONNULLPOINTER;
- TextField *mConfirmField A_NONNULLPOINTER;
- TextField *mEmailField;
- Button *mRegisterButton A_NONNULLPOINTER;
- Button *mCancelButton A_NONNULLPOINTER;
- RadioButton *mMaleButton;
- RadioButton *mFemaleButton;
- WrongDataNoticeListener *mWrongDataNoticeListener A_NONNULLPOINTER;
-};
-
-#endif // GUI_WINDOWS_REGISTERDIALOG_H
diff --git a/src/gui/windows/serverdialog.cpp b/src/gui/windows/serverdialog.cpp
deleted file mode 100644
index ab630e960..000000000
--- a/src/gui/windows/serverdialog.cpp
+++ /dev/null
@@ -1,902 +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 "gui/windows/serverdialog.h"
-
-#include "chatlogger.h"
-#include "client.h"
-#include "configuration.h"
-#include "main.h"
-#include "settings.h"
-
-#include "net/download.h"
-
-#include "fs/paths.h"
-
-#include "gui/widgets/checkbox.h"
-#include "gui/widgets/createwidget.h"
-#include "gui/widgets/desktop.h"
-#include "gui/windows/editserverdialog.h"
-#include "gui/windows/logindialog.h"
-#include "gui/windows/serverinfowindow.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/label.h"
-#include "gui/widgets/layout.h"
-#include "gui/widgets/serverslistbox.h"
-#include "gui/widgets/scrollarea.h"
-
-#include "utils/delete2.h"
-#include "utils/foreach.h"
-#include "utils/langs.h"
-
-#include "debug.h"
-
-#ifdef WIN32
-#undef ERROR
-#endif // WIN32
-
-static const int MAX_SERVERLIST = 15;
-
-static std::string serverTypeToString(const ServerTypeT type)
-{
- switch (type)
- {
- case ServerType::TMWATHENA:
-#ifdef TMWA_SUPPORT
- return "TmwAthena";
-#else // TMWA_SUPPORT
-
- return "";
-#endif // TMWA_SUPPORT
-
- case ServerType::EATHENA:
- return "eAthena";
- case ServerType::EVOL2:
- return "Evol2";
- default:
- case ServerType::UNKNOWN:
- return "";
- }
-}
-
-static uint16_t defaultPortForServerType(const ServerTypeT type)
-{
- switch (type)
- {
- default:
- case ServerType::EATHENA:
- case ServerType::EVOL2:
- return 6900;
- case ServerType::UNKNOWN:
- case ServerType::TMWATHENA:
- return 6901;
- }
-}
-
-ServerDialog::ServerDialog(ServerInfo *const serverInfo,
- const std::string &dir) :
- // TRANSLATORS: servers dialog name
- Window(_("Choose Your Server"), Modal_false, nullptr, "server.xml"),
- ActionListener(),
- KeyListener(),
- SelectionListener(),
- mMutex(),
- mServers(ServerInfos()),
- mDir(dir),
- mDescription(new Label(this, std::string())),
- // TRANSLATORS: servers dialog button
- mQuitButton(new Button(this, _("Quit"), "quit", this)),
- // TRANSLATORS: servers dialog button
- mConnectButton(new Button(this, _("Connect"), "connect", this)),
- // TRANSLATORS: servers dialog button
- mAddEntryButton(new Button(this, _("Add"), "addEntry", this)),
- // TRANSLATORS: servers dialog button
- mEditEntryButton(new Button(this, _("Edit"), "editEntry", this)),
- // TRANSLATORS: servers dialog button
- mDeleteButton(new Button(this, _("Delete"), "remove", this)),
- // TRANSLATORS: servers dialog button
- mLoadButton(new Button(this, _("Load"), "load", this)),
- // TRANSLATORS: servers dialog button
- mInfoButton(new Button(this, _("Info"), "info", this)),
- mServersListModel(new ServersListModel(&mServers, this)),
- mServersList(CREATEWIDGETR(ServersListBox, this, mServersListModel)),
- mDownload(nullptr),
- mServerInfo(serverInfo),
- mPersistentIPCheckBox(nullptr),
- mDownloadProgress(-1.0F),
- mDownloadStatus(ServerDialogDownloadStatus::UNKNOWN)
-{
- if (isSafeMode)
- {
- // TRANSLATORS: servers dialog name
- setCaption(_("Choose Your Server *** SAFE MODE ***"));
- }
-
- setWindowName("ServerDialog");
-
- setCloseButton(true);
-
- mPersistentIPCheckBox = new CheckBox(this,
- // TRANSLATORS: servers dialog checkbox
- _("Use same ip for game sub servers"),
- config.getBoolValue("usePersistentIP"),
- this, "persitent ip");
-
- loadCustomServers();
-
- mServersList->addMouseListener(this);
-
- ScrollArea *const usedScroll = new ScrollArea(this, mServersList,
- fromBool(getOptionBool("showbackground"), Opaque),
- "server_background.xml");
- usedScroll->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
-
- mServersList->addSelectionListener(this);
- usedScroll->setVerticalScrollAmount(0);
-
- place(0, 0, usedScroll, 8, 5).setPadding(3);
- place(0, 5, mDescription, 8);
- place(0, 6, mPersistentIPCheckBox, 8);
- place(0, 7, mInfoButton);
- place(1, 7, mAddEntryButton);
- place(2, 7, mEditEntryButton);
- place(3, 7, mLoadButton);
- place(4, 7, mDeleteButton);
- place(6, 7, mQuitButton);
- place(7, 7, mConnectButton);
-
- // Make sure the list has enough height
- getLayout().setRowHeight(0, 80);
-
- // Do this manually instead of calling reflowLayout so we can enforce a
- // minimum width.
- int width = 500;
- int height = 350;
-
- getLayout().reflow(width, height);
- setContentSize(width, height);
-
- setMinWidth(310);
- setMinHeight(220);
- setDefaultSize(getWidth(), getHeight(), ImagePosition::CENTER);
-
- setResizable(true);
- addKeyListener(this);
-
- loadWindowState();
-}
-
-void ServerDialog::postInit()
-{
- Window::postInit();
- setVisible(Visible_true);
-
- mConnectButton->requestFocus();
-
- loadServers(true);
-
- mServersList->setSelected(0); // Do this after for the Delete button
-
- if (needUpdateServers())
- downloadServerList();
- else
- logger->log("Skipping servers list update");
-}
-
-ServerDialog::~ServerDialog()
-{
- if (mDownload != nullptr)
- {
- mDownload->cancel();
- delete2(mDownload)
- }
- delete2(mServersListModel);
-}
-
-void ServerDialog::connectToSelectedServer()
-{
- if (client->getState() == State::CONNECT_SERVER)
- return;
-
- const int index = mServersList->getSelected();
- if (index < 0)
- return;
-
- if (mDownload != nullptr)
- mDownload->cancel();
-
- mQuitButton->setEnabled(false);
- mConnectButton->setEnabled(false);
- mLoadButton->setEnabled(false);
-
- ServerInfo server = mServers.at(index);
- mServerInfo->hostname = server.hostname;
- mServerInfo->althostname = server.althostname;
- mServerInfo->port = server.port;
- mServerInfo->type = server.type;
- mServerInfo->name = server.name;
- mServerInfo->description = server.description;
- mServerInfo->registerUrl = server.registerUrl;
- mServerInfo->onlineListUrl = server.onlineListUrl;
- mServerInfo->supportUrl = server.supportUrl;
- mServerInfo->defaultHostName = server.defaultHostName;
- mServerInfo->save = true;
- mServerInfo->persistentIp = server.persistentIp;
- mServerInfo->freeType = server.freeType;
- mServerInfo->updateMirrors = server.updateMirrors;
- mServerInfo->packetVersion = server.packetVersion;
- mServerInfo->updateHosts = server.updateHosts;
- mServerInfo->freeSources = server.freeSources;
- mServerInfo->nonFreeSources = server.nonFreeSources;
- mServerInfo->docs = server.docs;
- mServerInfo->serverUrl = server.serverUrl;
-
- settings.persistentIp = mServerInfo->persistentIp;
- settings.supportUrl = mServerInfo->supportUrl;
- settings.updateMirrors = mServerInfo->updateMirrors;
-
- if (chatLogger != nullptr)
- chatLogger->setServerName(mServerInfo->hostname);
-
- saveCustomServers(*mServerInfo);
-
- if (!LoginDialog::savedPasswordKey.empty())
- {
- if (mServerInfo->hostname != LoginDialog::savedPasswordKey)
- {
- LoginDialog::savedPassword.clear();
- if (desktop != nullptr)
- desktop->reloadWallpaper();
- }
- }
-
- config.setValue("usePersistentIP",
- mPersistentIPCheckBox->isSelected());
- client->setState(State::CONNECT_SERVER);
-}
-
-void ServerDialog::action(const ActionEvent &event)
-{
- const std::string &eventId = event.getId();
- if (eventId == "connect")
- {
- connectToSelectedServer();
- }
- else if (eventId == "quit")
- {
- close();
- }
- else if (eventId == "load")
- {
- downloadServerList();
- }
- else if (eventId == "addEntry")
- {
- CREATEWIDGET(EditServerDialog, this, ServerInfo(), -1);
- }
- else if (eventId == "editEntry")
- {
- const int index = mServersList->getSelected();
- if (index >= 0)
- {
- CREATEWIDGET(EditServerDialog,
- this,
- mServers.at(index),
- index);
- }
- }
- else if (eventId == "remove")
- {
- const int index = mServersList->getSelected();
- if (index >= 0)
- {
- mServersList->setSelected(0);
- mServers.erase(mServers.begin() + index);
- saveCustomServers();
- }
- }
- else if (eventId == "info")
- {
- const int index = mServersList->getSelected();
- if (index >= 0)
- {
- if (serverInfoWindow != nullptr)
- serverInfoWindow->scheduleDelete();
- serverInfoWindow = CREATEWIDGETR(ServerInfoWindow,
- mServers.at(index));
- }
- }
-}
-
-void ServerDialog::keyPressed(KeyEvent &event)
-{
- PRAGMA45(GCC diagnostic push)
- PRAGMA45(GCC diagnostic ignored "-Wswitch-enum")
- switch (event.getActionId())
- {
- case InputAction::GUI_CANCEL:
- event.consume();
- client->setState(State::EXIT);
- return;
-
- case InputAction::GUI_SELECT:
- case InputAction::GUI_SELECT2:
- event.consume();
- action(ActionEvent(nullptr,
- mConnectButton->getActionEventId()));
- return;
-
- case InputAction::GUI_INSERT:
- CREATEWIDGET(EditServerDialog, this, ServerInfo(), -1);
- return;
-
- case InputAction::GUI_DELETE:
- {
- const int index = mServersList->getSelected();
- if (index >= 0)
- {
- mServersList->setSelected(0);
- mServers.erase(mServers.begin() + index);
- saveCustomServers();
- }
- return;
- }
-
- case InputAction::GUI_BACKSPACE:
- {
- const int index = mServersList->getSelected();
- if (index >= 0)
- {
- CREATEWIDGET(EditServerDialog, this, mServers.at(index),
- index);
- }
- return;
- }
-
- default:
- break;
- }
- PRAGMA45(GCC diagnostic pop)
- if (!event.isConsumed())
- mServersList->keyPressed(event);
-}
-
-void ServerDialog::valueChanged(const SelectionEvent &event A_UNUSED)
-{
- const int index = mServersList->getSelected();
- if (index == -1)
- {
- mDeleteButton->setEnabled(false);
- return;
- }
- mDeleteButton->setEnabled(true);
-}
-
-void ServerDialog::mouseClicked(MouseEvent &event)
-{
- if (event.getButton() == MouseButton::LEFT)
- {
- event.consume();
- if (event.getClickCount() == 2 &&
- event.getSource() == mServersList)
- {
- action(ActionEvent(mConnectButton,
- mConnectButton->getActionEventId()));
- }
- }
-}
-
-void ServerDialog::logic()
-{
- BLOCK_START("ServerDialog::logic")
- {
- MutexLocker tempLock(&mMutex);
- if (mDownloadStatus == ServerDialogDownloadStatus::COMPLETE)
- {
- loadServers();
- mDownloadStatus = ServerDialogDownloadStatus::OVER;
- mDescription->setCaption(std::string());
- logger->log("Servers list updated");
- }
- else if (mDownloadStatus == ServerDialogDownloadStatus::IN_PROGRESS)
- {
- // TRANSLATORS: servers dialog label
- mDescription->setCaption(strprintf(_("Downloading server list..."
- "%2.2f%%"), static_cast<double>(mDownloadProgress * 100)));
- }
- else if (mDownloadStatus == ServerDialogDownloadStatus::IDLE)
- {
- // TRANSLATORS: servers dialog label
- mDescription->setCaption(_("Waiting for server..."));
- }
- else if (mDownloadStatus == ServerDialogDownloadStatus::PREPARING)
- {
- // TRANSLATORS: servers dialog label
- mDescription->setCaption(_("Preparing download"));
- }
- else if (mDownloadStatus == ServerDialogDownloadStatus::ERROR)
- {
- // TRANSLATORS: servers dialog label
- mDescription->setCaption(_("Error retreiving server list!"));
- logger->log("Error: servers list updating error");
- }
- }
-
- Window::logic();
- BLOCK_END("ServerDialog::logic")
-}
-
-void ServerDialog::downloadServerList()
-{
- // Try to load the configuration value for the onlineServerList
- std::string listFile = branding.getStringValue("onlineServerList");
- std::string listFile2 = branding.getStringValue("onlineServerList2");
-
- // Fall back to manaplus.org when neither branding
- // nor config set it
- if (listFile.empty())
- listFile = "http://manaplus.org/serverlist.xml";
-
- if (mDownload != nullptr)
- {
- mDownload->cancel();
- delete2(mDownload)
- }
-
- mDownload = new Net::Download(this, listFile,
- &downloadUpdate, false, false, true);
- mDownload->setFile(pathJoin(mDir,
- branding.getStringValue("onlineServerFile")));
- if (!listFile2.empty())
- mDownload->addMirror(listFile2);
- mDownload->start();
-
- config.setValue("serverslistupdate", getDateString());
-}
-
-static void loadHostsGroup(XmlNodeConstPtr node,
- ServerInfo &server)
-{
- HostsGroup group;
- group.name = XML::langProperty(node,
- "name",
- // TRANSLATORS: unknown hosts group name
- _("Unknown"));
- for_each_xml_child_node(hostNode, node)
- {
- if (!xmlNameEqual(hostNode, "host") ||
- !XmlHaveChildContent(hostNode))
- {
- continue;
- }
- const std::string host = XmlChildContent(hostNode);
- if (host.empty())
- continue;
- if (!checkPath(host))
- {
- logger->log1("Warning: incorrect update server name");
- continue;
- }
-
- group.hosts.push_back(host);
- }
- if (!group.hosts.empty())
- server.updateHosts.push_back(group);
-}
-
-static void loadServerSourcesList(XmlNodeConstPtr node,
- STD_VECTOR<ServerUrlInfo> &list)
-{
- for_each_xml_child_node(urlNode, node)
- {
- if (!xmlNameEqual(urlNode, "url") ||
- !XmlHaveChildContent(urlNode))
- {
- continue;
- }
- const std::string name = XML::langProperty(urlNode,
- "name",
- "");
- if (name.empty())
- continue;
- const std::string url = XmlChildContent(urlNode);
- if (url.empty())
- continue;
- list.push_back(ServerUrlInfo(name, url));
- }
-}
-
-static void loadServerSources(XmlNodeConstPtr node,
- ServerInfo &server)
-{
- for_each_xml_child_node(subNode, node)
- {
- if (xmlNameEqual(subNode, "free"))
- {
- loadServerSourcesList(subNode, server.freeSources);
- }
- else if (xmlNameEqual(subNode, "nonfree"))
- {
- loadServerSourcesList(subNode, server.nonFreeSources);
- }
- }
-}
-
-void ServerDialog::loadServers(const bool addNew)
-{
- XML::Document doc(pathJoin(mDir,
- branding.getStringValue("onlineServerFile")),
- UseVirtFs_false,
- SkipError_true);
- XmlNodeConstPtr rootNode = doc.rootNode();
-
- if (rootNode == nullptr ||
- !xmlNameEqual(rootNode, "serverlist"))
- {
- logger->log1("Error loading server list!");
- return;
- }
-
- const int ver = XML::getProperty(rootNode, "version", 0);
- if (ver != 1)
- {
- logger->log("Error: unsupported online server list version: %d",
- ver);
- return;
- }
-
- const std::string lang = getLangShort();
- const std::string description2("description_" + lang);
-
- for_each_xml_child_node(serverNode, rootNode)
- {
- if (!xmlNameEqual(serverNode, "server"))
- continue;
-
- const std::string type = XML::getProperty(
- serverNode, "type", "unknown");
- ServerInfo server;
- server.type = ServerInfo::parseType(type);
- const std::string licenseType = XML::getProperty(
- serverNode, "licenseType", "notset");
- server.freeType = ServerInfo::parseFreeType(licenseType);
-
- // Ignore unknown server types
- if (server.type == ServerType::UNKNOWN)
- {
- logger->log("Ignoring server entry with unknown type: %s",
- type.c_str());
- continue;
- }
-
- server.name = XML::getProperty(serverNode, "name", std::string());
- std::string version = XML::getProperty(serverNode, "minimumVersion",
- std::string());
-
- const bool meetsMinimumVersion = (compareStrI(version, SMALL_VERSION)
- <= 0);
-
- // For display in the list
- if (meetsMinimumVersion)
- version.clear();
- else if (version.empty())
- {
- // TRANSLATORS: servers dialog label
- version = _("requires a newer version");
- }
- else
- {
- // TRANSLATORS: servers dialog label
- version = strprintf(_("requires v%s"), version.c_str());
- }
-
- const Font *const font = gui->getFont();
-
- for_each_xml_child_node(subNode, serverNode)
- {
- if (xmlNameEqual(subNode, "connection"))
- {
- server.hostname = XML::getProperty(subNode, "hostname", "");
- server.althostname = XML::getProperty(
- subNode, "althostname", "");
- server.port = CAST_U16(
- XML::getProperty(subNode, "port", 0));
- server.packetVersion = XML::getProperty(subNode,
- "packetVersion", 0);
-
- if (server.port == 0)
- {
- // If no port is given, use the default for the given type
- server.port = defaultPortForServerType(server.type);
- }
- }
- else if (XmlHaveChildContent(subNode))
- {
- if ((xmlNameEqual(subNode, "description")
- && server.description.empty()) || (!lang.empty()
- && xmlNameEqual(subNode, description2.c_str())))
- {
- server.description = XmlChildContent(subNode);
- }
- else if (xmlNameEqual(subNode, "registerurl"))
- {
- server.registerUrl = XmlChildContent(subNode);
- }
- else if (xmlNameEqual(subNode, "onlineListUrl"))
- {
- server.onlineListUrl = XmlChildContent(subNode);
- }
- else if (xmlNameEqual(subNode, "support"))
- {
- server.supportUrl = XmlChildContent(subNode);
- }
- else if (xmlNameEqual(subNode, "persistentIp"))
- {
- std::string text = XmlChildContent(subNode);
- server.persistentIp = (text == "1" || text == "true");
- }
- else if (xmlNameEqual(subNode, "updateMirror"))
- {
- server.updateMirrors.push_back(XmlChildContent(subNode));
- }
- else if (xmlNameEqual(subNode, "site"))
- {
- server.serverUrl = XmlChildContent(subNode);
- }
- }
- if (xmlNameEqual(subNode, "updates"))
- {
- loadHostsGroup(subNode, server);
- }
- else if (xmlNameEqual(subNode, "defaultUpdateHost"))
- {
- server.defaultHostName = XML::langProperty(
- // TRANSLATORS: default hosts group name
- subNode, "name", _("default"));
- }
- else if (xmlNameEqual(subNode, "sources"))
- {
- loadServerSources(subNode, server);
- }
- else if (xmlNameEqual(subNode, "docs"))
- {
- loadServerSourcesList(subNode, server.docs);
- }
- }
-
- server.version.first = font->getWidth(version);
- server.version.second = version;
-
- MutexLocker tempLock(&mMutex);
- // Add the server to the local list if it's not already present
- bool found = false;
- for (unsigned int i = 0, fsz = CAST_U32(
- mServers.size()); i < fsz; i++)
- {
- if (mServers[i] == server)
- {
- // Use the name listed in the server list
- mServers[i].name = server.name;
- mServers[i].type = server.type;
- mServers[i].freeType = server.freeType;
- mServers[i].version = server.version;
- mServers[i].description = server.description;
- mServers[i].registerUrl = server.registerUrl;
- mServers[i].onlineListUrl = server.onlineListUrl;
- mServers[i].supportUrl = server.supportUrl;
- mServers[i].serverUrl = server.serverUrl;
- mServers[i].althostname = server.althostname;
- mServers[i].persistentIp = server.persistentIp;
- mServers[i].updateMirrors = server.updateMirrors;
- mServers[i].defaultHostName = server.defaultHostName;
- mServers[i].updateHosts = server.updateHosts;
- mServers[i].packetVersion = server.packetVersion;
- mServers[i].freeSources = server.freeSources;
- mServers[i].nonFreeSources = server.nonFreeSources;
- mServers[i].docs = server.docs;
- mServersListModel->setVersionString(i, version);
- found = true;
- break;
- }
- }
- if (!found && addNew)
- mServers.push_back(server);
- }
- if (mServersList->getSelected() < 0)
- mServersList->setSelected(0);
-}
-
-void ServerDialog::loadCustomServers()
-{
- for (int i = 0; i < MAX_SERVERLIST; ++i)
- {
- const std::string index = toString(i);
- const std::string nameKey("MostUsedServerDescName" + index);
- const std::string descKey("MostUsedServerDescription" + index);
- const std::string hostKey("MostUsedServerName" + index);
- const std::string typeKey("MostUsedServerType" + index);
- const std::string portKey("MostUsedServerPort" + index);
- const std::string onlineListUrlKey
- ("MostUsedServerOnlineList" + index);
- const std::string persistentIpKey("persistentIp" + index);
- const std::string packetVersionKey
- ("MostUsedServerPacketVersion" + index);
-
- ServerInfo server;
- server.name = config.getValue(nameKey, "");
- server.description = config.getValue(descKey, "");
- server.onlineListUrl = config.getValue(onlineListUrlKey, "");
- server.hostname = config.getValue(hostKey, "");
- server.type = ServerInfo::parseType(config.getValue(typeKey, ""));
- server.persistentIp = config.getValue(
- persistentIpKey, 0) != 0 ? true : false;
- server.packetVersion = config.getValue(packetVersionKey, 0);
-
- const int defaultPort = defaultPortForServerType(server.type);
- server.port = CAST_U16(
- config.getValue(portKey, defaultPort));
-
- // skip invalid server
- if (!server.isValid())
- continue;
-
- server.save = true;
- mServers.push_back(server);
- }
-}
-
-void ServerDialog::saveCustomServers(const ServerInfo &currentServer,
- const int index)
-{
- // Make sure the current server is mentioned first
- if (currentServer.isValid())
- {
- if (index >= 0 && CAST_SIZE(index) < mServers.size())
- {
- mServers[index] = currentServer;
- }
- else
- {
- FOR_EACH (ServerInfos::iterator, i, mServers)
- {
- if (*i == currentServer)
- {
- mServers.erase(i);
- break;
- }
- }
- mServers.insert(mServers.begin(), currentServer);
- }
- }
-
- int savedServerCount = 0;
-
- for (unsigned i = 0, fsz = CAST_U32(mServers.size());
- i < fsz && savedServerCount < MAX_SERVERLIST; ++ i)
- {
- const ServerInfo &server = mServers.at(i);
-
- // Only save servers that were loaded from settings
- if (!(server.save && server.isValid()))
- continue;
-
- const std::string num = toString(savedServerCount);
- const std::string nameKey("MostUsedServerDescName" + num);
- const std::string descKey("MostUsedServerDescription" + num);
- const std::string hostKey("MostUsedServerName" + num);
- const std::string typeKey("MostUsedServerType" + num);
- const std::string portKey("MostUsedServerPort" + num);
- const std::string onlineListUrlKey
- ("MostUsedServerOnlineList" + num);
- const std::string persistentIpKey("persistentIp" + num);
- const std::string packetVersionKey
- ("MostUsedServerPacketVersion" + num);
-
- config.setValue(nameKey, server.name);
- config.setValue(descKey, server.description);
- config.setValue(onlineListUrlKey, server.onlineListUrl);
- config.setValue(hostKey, server.hostname);
- config.setValue(typeKey, serverTypeToString(server.type));
- config.setValue(portKey, toString(server.port));
- config.setValue(persistentIpKey, server.persistentIp);
- config.setValue(packetVersionKey, server.packetVersion);
- ++ savedServerCount;
- }
-
- // Insert an invalid entry at the end to make the loading stop there
- if (savedServerCount < MAX_SERVERLIST)
- config.setValue("MostUsedServerName" + toString(savedServerCount), "");
-}
-
-int ServerDialog::downloadUpdate(void *ptr,
- const DownloadStatusT status,
- size_t total,
- const size_t remaining)
-{
- if ((ptr == nullptr) || status == DownloadStatus::Cancelled)
- return -1;
-
- ServerDialog *const sd = reinterpret_cast<ServerDialog*>(ptr);
- bool finished = false;
-
- if (sd->mDownload == nullptr)
- return -1;
-
- if (status == DownloadStatus::Complete)
- {
- finished = true;
- }
- else if (CAST_S32(status) < 0)
- {
- logger->log("Error retreiving server list: %s\n",
- sd->mDownload->getError());
- sd->mDownloadStatus = ServerDialogDownloadStatus::ERROR;
- }
- else
- {
- float progress = static_cast<float>(remaining);
- if (total != 0u)
- progress /= static_cast<float>(total);
-
- if (progress != progress || progress < 0.0F)
- progress = 0.0f;
- else if (progress > 1.0F)
- progress = 1.0F;
-
- MutexLocker lock1(&sd->mMutex);
- sd->mDownloadStatus = ServerDialogDownloadStatus::IN_PROGRESS;
- sd->mDownloadProgress = progress;
- }
-
- if (finished)
- {
- MutexLocker lock1(&sd->mMutex);
- sd->mDownloadStatus = ServerDialogDownloadStatus::COMPLETE;
- }
-
- return 0;
-}
-
-void ServerDialog::updateServer(const ServerInfo &server, const int index)
-{
- saveCustomServers(server, index);
-}
-
-bool ServerDialog::needUpdateServers() const
-{
- if (mServers.empty() || config.getStringValue("serverslistupdate")
- != getDateString())
- {
- return true;
- }
-
- return false;
-}
-
-void ServerDialog::close()
-{
- if (mDownload != nullptr)
- mDownload->cancel();
- client->setState(State::FORCE_QUIT);
- Window::close();
-}
diff --git a/src/gui/windows/serverdialog.h b/src/gui/windows/serverdialog.h
deleted file mode 100644
index b541e7f65..000000000
--- a/src/gui/windows/serverdialog.h
+++ /dev/null
@@ -1,150 +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_WINDOWS_SERVERDIALOG_H
-#define GUI_WINDOWS_SERVERDIALOG_H
-
-#include "gui/widgets/window.h"
-
-#include "enums/gui/serverdialogdonwloadstatus.h"
-
-#include "enums/net/downloadstatus.h"
-
-#include "net/serverinfo.h"
-
-#include "utils/mutex.h"
-
-#include "listeners/actionlistener.h"
-#include "listeners/keylistener.h"
-#include "listeners/selectionlistener.h"
-
-class Button;
-class CheckBox;
-class Label;
-class ListBox;
-class ServersListModel;
-
-namespace Net
-{
- class Download;
-} // namespace Net
-
-/**
- * The server choice dialog.
- *
- * \ingroup Interface
- */
-class ServerDialog final : public Window,
- public ActionListener,
- public KeyListener,
- public SelectionListener
-{
- public:
- /**
- * Constructor
- *
- * @see Window::Window
- */
- ServerDialog(ServerInfo *const serverInfo, const std::string &dir);
-
- A_DELETE_COPY(ServerDialog)
-
- void postInit() override final;
-
- /**
- * Destructor
- */
- ~ServerDialog();
-
- /**
- * Called when receiving actions from the widgets.
- */
- void action(const ActionEvent &event) override final;
-
- void keyPressed(KeyEvent &event) override final;
-
- /**
- * Called when the selected value changed in the servers list box.
- */
- void valueChanged(const SelectionEvent &event) override final;
-
- void mouseClicked(MouseEvent &event) override final;
-
- void logic() override final;
-
- void updateServer(const ServerInfo &server, const int index);
-
- void connectToSelectedServer();
-
- void close() override final;
-
- protected:
- friend class ServersListModel;
-
- MutexLocker lock()
- { return MutexLocker(&mMutex); }
-
- private:
- friend class EditServerDialog;
-
- /**
- * Called to load a list of available server from an online xml file.
- */
- void downloadServerList();
-
- void loadServers(const bool addNew = true);
-
- void loadCustomServers();
-
- void saveCustomServers(const ServerInfo &currentServer = ServerInfo(),
- const int index = -1);
-
- bool needUpdateServers() const;
-
- static int downloadUpdate(void *ptr,
- const DownloadStatusT status,
- size_t total,
- const size_t remaining);
-
- Mutex mMutex;
- ServerInfos mServers;
- const std::string &mDir;
- Label *mDescription A_NONNULLPOINTER;
- Button *mQuitButton A_NONNULLPOINTER;
- Button *mConnectButton A_NONNULLPOINTER;
- Button *mAddEntryButton A_NONNULLPOINTER;
- Button *mEditEntryButton A_NONNULLPOINTER;
- Button *mDeleteButton A_NONNULLPOINTER;
- Button *mLoadButton A_NONNULLPOINTER;
- Button *mInfoButton A_NONNULLPOINTER;
- ServersListModel *mServersListModel A_NONNULLPOINTER;
- ListBox *mServersList A_NONNULLPOINTER;
-
- /** Status of the current download. */
- Net::Download *mDownload;
- ServerInfo *mServerInfo;
- CheckBox *mPersistentIPCheckBox;
- float mDownloadProgress;
- ServerDialogDownloadStatusT mDownloadStatus;
-};
-
-#endif // GUI_WINDOWS_SERVERDIALOG_H
diff --git a/src/gui/windows/serverinfowindow.cpp b/src/gui/windows/serverinfowindow.cpp
deleted file mode 100644
index 20f8d5f42..000000000
--- a/src/gui/windows/serverinfowindow.cpp
+++ /dev/null
@@ -1,184 +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 "gui/windows/serverinfowindow.h"
-
-#include "enums/gui/layouttype.h"
-
-#include "gui/gui.h"
-
-#include "gui/widgets/layout.h"
-#include "gui/widgets/scrollarea.h"
-#include "gui/widgets/staticbrowserbox.h"
-
-#include "utils/foreach.h"
-#include "utils/gettext.h"
-#include "utils/process.h"
-
-#include "debug.h"
-
-ServerInfoWindow *serverInfoWindow = nullptr;
-
-ServerInfoWindow::ServerInfoWindow(ServerInfo &serverInfo) :
- // TRANSLATORS: servers dialog name
- Window(_("Server info"), Modal_false, nullptr, "serverinfo.xml"),
- LinkHandler(),
- mServerInfo(serverInfo),
- mBrowserBox(new StaticBrowserBox(this, Opaque_true,
- "browserbox.xml")),
- mScrollArea(new ScrollArea(this, mBrowserBox,
- Opaque_true, "serverinfo_background.xml"))
-{
- setMinWidth(300);
- setMinHeight(220);
- setContentSize(455, 350);
- setWindowName("ServerInfoWindow");
- setCloseButton(true);
- setResizable(true);
- setStickyButtonLock(true);
-
- setDefaultSize(500, 400, ImagePosition::CENTER);
-
- mBrowserBox->setOpaque(Opaque_false);
- mBrowserBox->setLinkHandler(this);
- if (gui != nullptr)
- mBrowserBox->setFont(gui->getHelpFont());
- mBrowserBox->setProcessVars(true);
- mBrowserBox->setEnableTabs(true);
-
- place(0, 0, mScrollArea, 5, 3).setPadding(3);
-
- Layout &layout = getLayout();
- layout.setRowHeight(0, LayoutType::SET);
-
- loadWindowState();
- enableVisibleSound(true);
- widgetResized(Event(nullptr));
-}
-
-void ServerInfoWindow::postInit()
-{
- Window::postInit();
- setVisible(Visible_true);
- showServerInfo();
-}
-
-ServerInfoWindow::~ServerInfoWindow()
-{
-}
-
-void ServerInfoWindow::handleLink(const std::string &link,
- MouseEvent *const event A_UNUSED)
-{
- if (strStartWith(link, "http://") ||
- strStartWith(link, "https://"))
- {
- openBrowser(link);
- }
-}
-
-void ServerInfoWindow::showServerInfo()
-{
- const ServerFreeTypeT type = mServerInfo.freeType;
- if (type == ServerFreeType::Free)
- {
- // TRANSLATORS: server info comment
- mBrowserBox->addRow(_("##BServer with free license."));
- }
- else if (type == ServerFreeType::NonFree)
- {
- // TRANSLATORS: server info comment
- mBrowserBox->addRow(_("##BServer with non free license."));
- }
- else if (type == ServerFreeType::Unknown ||
- type == ServerFreeType::NotSet)
- {
- // TRANSLATORS: server info comment
- mBrowserBox->addRow(_("##BServer unknown license."));
- }
- mBrowserBox->addRow("");
- addServerComment(mServerInfo.serverUrl,
- // TRANSLATORS: server info comment
- _("Server"));
- addServerComment(mServerInfo.supportUrl,
- // TRANSLATORS: server info comment
- _("Support"));
- addServerComment(mServerInfo.registerUrl,
- // TRANSLATORS: server info comment
- _("Register"));
-
- addSourcesList(mServerInfo.nonFreeSources,
- // TRANSLATORS: server info non free comment
- _("##BNon free sources"));
- addSourcesList(mServerInfo.freeSources,
- // TRANSLATORS: server info non free comment
- _("##BFree sources"));
- addSourcesList(mServerInfo.docs,
- // TRANSLATORS: server info documentation comment
- _("##BDocumentation"));
- mBrowserBox->updateHeight();
-}
-
-void ServerInfoWindow::addSourcesList(const STD_VECTOR<ServerUrlInfo> &list,
- const std::string &comment)
-{
- if (!list.empty())
- {
- mBrowserBox->addRow("");
- mBrowserBox->addRow(comment);
- FOR_EACH (STD_VECTOR<ServerUrlInfo>::const_iterator, it, list)
- {
- const ServerUrlInfo &info = *it;
- addServerComment(info.url,
- info.name);
- }
- }
-}
-
-void ServerInfoWindow::addServerComment(const std::string &url,
- const std::string &comment)
-{
- std::string str;
- if (!url.empty())
- {
- if (strStartWith(url, "http://") ||
- strStartWith(url, "https://"))
- {
- str = strprintf("%s: @@%s|@@##0",
- comment.c_str(),
- url.c_str());
- }
- else
- {
- str = strprintf("%s: %s",
- comment.c_str(),
- url.c_str());
- }
- mBrowserBox->addRow(str);
- }
-}
-
-void ServerInfoWindow::close()
-{
- Window::close();
- if (serverInfoWindow == this)
- serverInfoWindow = nullptr;
- scheduleDelete();
-}
diff --git a/src/gui/windows/serverinfowindow.h b/src/gui/windows/serverinfowindow.h
deleted file mode 100644
index d872b1fdf..000000000
--- a/src/gui/windows/serverinfowindow.h
+++ /dev/null
@@ -1,68 +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 GUI_WINDOWS_SERVERINFOWINDOW_H
-#define GUI_WINDOWS_SERVERINFOWINDOW_H
-
-#include "gui/widgets/window.h"
-
-#include "gui/widgets/linkhandler.h"
-
-#include "net/serverinfo.h"
-
-class ScrollArea;
-class ServerInfo;
-class StaticBrowserBox;
-
-class ServerInfoWindow final : public Window,
- public LinkHandler
-{
- public:
- explicit ServerInfoWindow(ServerInfo &serverInfo);
-
- A_DELETE_COPY(ServerInfoWindow)
-
- void postInit() override final;
-
- ~ServerInfoWindow();
-
- void handleLink(const std::string &link,
- MouseEvent *const event A_UNUSED) override final;
-
- void close() override final;
-
- protected:
- void showServerInfo();
-
- void addSourcesList(const STD_VECTOR<ServerUrlInfo> &list,
- const std::string &comment);
-
- void addServerComment(const std::string &url,
- const std::string &comment);
-
- private:
- ServerInfo mServerInfo;
- StaticBrowserBox *mBrowserBox A_NONNULLPOINTER;
- ScrollArea *mScrollArea A_NONNULLPOINTER;
-};
-
-extern ServerInfoWindow *serverInfoWindow;
-
-#endif // GUI_WINDOWS_SERVERINFOWINDOW_H
diff --git a/src/gui/windows/setupwindow.cpp b/src/gui/windows/setupwindow.cpp
deleted file mode 100644
index eeb86ce7d..000000000
--- a/src/gui/windows/setupwindow.cpp
+++ /dev/null
@@ -1,335 +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 "gui/windows/setupwindow.h"
-
-#include "configuration.h"
-#include "game.h"
-#include "main.h"
-
-#include "gui/windows/chatwindow.h"
-#include "gui/windows/statuswindow.h"
-
-#include "gui/widgets/createwidget.h"
-
-#include "gui/widgets/tabs/setup_audio.h"
-#include "gui/widgets/tabs/setup_chat.h"
-#include "gui/widgets/tabs/setup_colors.h"
-#include "gui/widgets/tabs/setup_input.h"
-#include "gui/widgets/tabs/setup_joystick.h"
-#include "gui/widgets/tabs/setup_misc.h"
-#include "gui/widgets/tabs/setup_mods.h"
-#include "gui/widgets/tabs/setup_perfomance.h"
-#include "gui/widgets/tabs/setup_players.h"
-#include "gui/widgets/tabs/setup_quick.h"
-#include "gui/widgets/tabs/setup_relations.h"
-#include "gui/widgets/tabs/setup_theme.h"
-#include "gui/widgets/tabs/setup_touch.h"
-#include "gui/widgets/tabs/setup_video.h"
-#include "gui/widgets/tabs/setup_visual.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/label.h"
-#include "gui/widgets/tabbedarea.h"
-
-#include "input/touch/touchmanager.h"
-
-#include "utils/delete2.h"
-#include "utils/dtor.h"
-#include "utils/foreach.h"
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-SetupWindow *setupWindow = nullptr;
-
-SetupWindow::SetupWindow() :
- // TRANSLATORS: setup window name
- Window(_("Setup"), Modal_false, nullptr, "setup.xml"),
- ActionListener(),
- mTabs(),
- mWindowsToReset(),
- mButtons(),
- mModsTab(nullptr),
- mQuickTab(nullptr),
- mResetWindows(nullptr),
- mPanel(CREATEWIDGETR(TabbedArea, this)),
- mVersion(new Label(this, FULL_VERSION)),
- mButtonPadding(5)
-{
- setCloseButton(true);
- setResizable(true);
- setStickyButtonLock(true);
-}
-
-void SetupWindow::postInit()
-{
- Window::postInit();
- int width = 620;
- const int height = 450;
-
- if (config.getIntValue("screenwidth") >= 730)
- width += 100;
-
- setContentSize(width, height);
- setMinWidth(310);
- setMinHeight(210);
-
- mPanel->setSelectable(false);
- mPanel->getTabContainer()->setSelectable(false);
- mPanel->getWidgetContainer()->setSelectable(false);
-
- static const char *const buttonNames[] =
- {
- // TRANSLATORS: setup button
- N_("Apply"),
- // TRANSLATORS: setup button
- N_("Cancel"),
- // TRANSLATORS: setup button
- N_("Store"),
- // TRANSLATORS: setup button
- N_("Reset Windows"),
- nullptr
- };
- int x = width;
- mButtonPadding = getOption("buttonPadding", 5);
- for (const char *const * curBtn = buttonNames;
- *curBtn != nullptr;
- ++ curBtn)
- {
- Button *const btn = new Button(this, gettext(*curBtn), *curBtn, this);
- mButtons.push_back(btn);
- x -= btn->getWidth() + mButtonPadding;
- btn->setPosition(x, height - btn->getHeight() - mButtonPadding);
- add(btn);
-
- // Store this button, as it needs to be enabled/disabled
- if (strcmp(*curBtn, "Reset Windows") == 0)
- mResetWindows = btn;
- }
-
- mPanel->setDimension(Rect(5, 5, width - 10, height - 40));
- mPanel->enableScrollButtons(true);
-
- mTabs.push_back(new Setup_Video(this));
- mTabs.push_back(new Setup_Visual(this));
- mTabs.push_back(new Setup_Audio(this));
- mTabs.push_back(new Setup_Perfomance(this));
- mTabs.push_back(new Setup_Touch(this));
- mTabs.push_back(new Setup_Input(this));
- mTabs.push_back(new Setup_Joystick(this));
- mTabs.push_back(new Setup_Colors(this));
- mTabs.push_back(new Setup_Chat(this));
- mTabs.push_back(new Setup_Players(this));
- mTabs.push_back(new Setup_Relations(this));
- mTabs.push_back(new Setup_Theme(this));
- mTabs.push_back(new Setup_Misc(this));
-
- FOR_EACH (std::list<SetupTab*>::const_iterator, i, mTabs)
- {
- SetupTab *const tab = *i;
- mPanel->addTab(tab->getName(), tab);
- }
- add(mPanel);
-
- if (mResetWindows != nullptr)
- {
- mVersion->setPosition(9,
- height - mVersion->getHeight() - mResetWindows->getHeight() - 9);
- }
- else
- {
- mVersion->setPosition(9, height - mVersion->getHeight() - 30);
- }
- add(mVersion);
-
- center();
-
- widgetResized(Event(nullptr));
- setInGame(false);
- enableVisibleSound(true);
-}
-
-SetupWindow::~SetupWindow()
-{
- delete_all(mTabs);
- mButtons.clear();
- setupWindow = nullptr;
-}
-
-void SetupWindow::action(const ActionEvent &event)
-{
- if (Game::instance() != nullptr)
- Game::instance()->resetAdjustLevel();
- const std::string &eventId = event.getId();
-
- if (eventId == "Apply")
- {
- setVisible(Visible_false);
- for_each(mTabs.begin(), mTabs.end(), std::mem_fun(&SetupTab::apply));
- }
- else if (eventId == "Cancel")
- {
- doCancel();
- }
- else if (eventId == "Store")
- {
- if (chatWindow != nullptr)
- chatWindow->saveState();
- config.write();
- serverConfig.write();
- }
- else if (eventId == "Reset Windows")
- {
- // Bail out if this action happens to be activated before the windows
- // are created (though it should be disabled then)
- if (statusWindow == nullptr)
- return;
-
- FOR_EACH (std::list<Window*>::const_iterator, it, mWindowsToReset)
- {
- if (*it != nullptr)
- (*it)->resetToDefaultSize();
- }
- }
-}
-
-void SetupWindow::setInGame(const bool inGame)
-{
- if (mResetWindows != nullptr)
- mResetWindows->setEnabled(inGame);
-}
-
-void SetupWindow::externalUpdate()
-{
- unloadAdditionalTabs();
- mModsTab = new Setup_Mods(this);
- mTabs.push_back(mModsTab);
- mPanel->addTab(mModsTab->getName(), mModsTab);
- mQuickTab = new Setup_Quick(this);
- mTabs.push_back(mQuickTab);
- mPanel->addTab(mQuickTab->getName(), mQuickTab);
- FOR_EACH (std::list<SetupTab*>::const_iterator, it, mTabs)
- {
- if (*it != nullptr)
- (*it)->externalUpdated();
- }
-}
-
-void SetupWindow::unloadTab(SetupTab *const page)
-{
- if (page != nullptr)
- {
- mTabs.remove(page);
- mPanel->removeTab(mPanel->getTab(page->getName()));
- }
-}
-
-void SetupWindow::unloadAdditionalTabs()
-{
- unloadTab(mModsTab);
- unloadTab(mQuickTab);
- delete2(mModsTab);
- delete2(mQuickTab);
-}
-
-void SetupWindow::externalUnload()
-{
- FOR_EACH (std::list<SetupTab*>::const_iterator, it, mTabs)
- {
- if (*it != nullptr)
- (*it)->externalUnloaded();
- }
- unloadAdditionalTabs();
-}
-
-void SetupWindow::registerWindowForReset(Window *const window)
-{
- mWindowsToReset.push_back(window);
-}
-
-void SetupWindow::unregisterWindowForReset(const Window *const window)
-{
- FOR_EACH (std::list<Window*>::iterator, it, mWindowsToReset)
- {
- if (*it == window)
- {
- mWindowsToReset.erase(it);
- return;
- }
- }
-}
-
-void SetupWindow::hideWindows()
-{
- FOR_EACH (std::list<Window*>::const_iterator, it, mWindowsToReset)
- {
- Window *const window = *it;
- if ((window != nullptr) && !window->isSticky())
- window->setVisible(Visible_false);
- }
- setVisible(Visible_false);
-}
-
-void SetupWindow::doCancel()
-{
- setVisible(Visible_false);
- for_each(mTabs.begin(), mTabs.end(), std::mem_fun(&SetupTab::cancel));
-}
-
-void SetupWindow::activateTab(const std::string &name)
-{
- std::string tmp = gettext(name.c_str());
- mPanel->setSelectedTabByName(tmp);
-}
-
-void SetupWindow::setVisible(Visible visible)
-{
- touchManager.setTempHide(visible == Visible_true);
- Window::setVisible(visible);
-}
-
-void SetupWindow::widgetResized(const Event &event)
-{
- Window::widgetResized(event);
-
- const Rect area = getChildrenArea();
- int x = area.width;
- const int height = area.height;
- const int width = area.width;
- mPanel->setDimension(Rect(5, 5, width - 10, height - 40));
- FOR_EACH (STD_VECTOR<Button*>::iterator, it, mButtons)
- {
- Button *const btn = *it;
- x -= btn->getWidth() + mButtonPadding;
- btn->setPosition(x, height - btn->getHeight() - mButtonPadding);
- }
- if (mResetWindows != nullptr)
- {
- mVersion->setPosition(9,
- height - mVersion->getHeight() - mResetWindows->getHeight() - 9);
- }
- else
- {
- mVersion->setPosition(9, height - mVersion->getHeight() - 30);
- }
-}
diff --git a/src/gui/windows/setupwindow.h b/src/gui/windows/setupwindow.h
deleted file mode 100644
index 79a11a469..000000000
--- a/src/gui/windows/setupwindow.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 GUI_WINDOWS_SETUPWINDOW_H
-#define GUI_WINDOWS_SETUPWINDOW_H
-
-#include "gui/widgets/window.h"
-
-#include "listeners/actionlistener.h"
-
-class Button;
-class Label;
-class SetupTab;
-class TabbedArea;
-
-/**
- * The setup dialog. Displays several tabs for configuring different aspects
- * of the game.
- *
- * \ingroup GUI
- */
-class SetupWindow final : public Window,
- public ActionListener
-{
- public:
- SetupWindow();
-
- A_DELETE_COPY(SetupWindow)
-
- ~SetupWindow();
-
- void postInit() override final;
-
- void action(const ActionEvent &event) override final;
-
- void setInGame(const bool inGame);
-
- void externalUpdate();
-
- void externalUnload();
-
- void registerWindowForReset(Window *const window);
-
- void unregisterWindowForReset(const Window *const window);
-
- void hideWindows();
-
- void clearWindowsForReset()
- { mWindowsToReset.clear(); }
-
- void doCancel();
-
- void activateTab(const std::string &name);
-
- void setVisible(Visible visible) override final;
-
- void widgetResized(const Event &event) override final;
-
- private:
- void unloadAdditionalTabs();
-
- void unloadTab(SetupTab *const page);
-
- std::list<SetupTab*> mTabs;
- std::list<Window*> mWindowsToReset;
- STD_VECTOR<Button*> mButtons;
- SetupTab *mModsTab;
- SetupTab *mQuickTab;
- Button *mResetWindows;
- TabbedArea *mPanel A_NONNULLPOINTER;
- Label *mVersion A_NONNULLPOINTER;
- int mButtonPadding;
-};
-
-extern SetupWindow* setupWindow;
-
-#endif // GUI_WINDOWS_SETUPWINDOW_H
diff --git a/src/gui/windows/shopselldialog.cpp b/src/gui/windows/shopselldialog.cpp
deleted file mode 100644
index 26911836b..000000000
--- a/src/gui/windows/shopselldialog.cpp
+++ /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/>.
- */
-
-#ifdef TMWA_SUPPORT
-
-#include "gui/windows/shopselldialog.h"
-
-#include "being/playerinfo.h"
-
-#include "gui/windows/tradewindow.h"
-
-#include "gui/models/shopitems.h"
-
-#include "gui/widgets/shoplistbox.h"
-
-#include "net/buysellhandler.h"
-
-#include "debug.h"
-
-ShopSellDialog::ShopSellDialog(const std::string &nick) :
- SellDialog(IsSell_true, Advanced_false),
- mNick(nick)
-{
-}
-
-void ShopSellDialog::sellAction(const ActionEvent &event A_UNUSED)
-{
- if (mAmountItems <= 0 || mAmountItems > mMaxItems)
- return;
-
- const int selectedItem = mShopItemList->getSelected();
- ShopItem *const item = mShopItems->at(selectedItem);
- if (item == nullptr || PlayerInfo::isItemProtected(item->getId()))
- return;
- buySellHandler->sendSellRequest(mNick, item, mAmountItems);
-
- if (tradeWindow != nullptr)
- tradeWindow->addAutoItem(mNick, item, mAmountItems);
-}
-
-#endif // TMWA_SUPPORT
diff --git a/src/gui/windows/shopselldialog.h b/src/gui/windows/shopselldialog.h
deleted file mode 100644
index debed53b3..000000000
--- a/src/gui/windows/shopselldialog.h
+++ /dev/null
@@ -1,54 +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_WINDOWS_SHOPSELLDIALOG_H
-#define GUI_WINDOWS_SHOPSELLDIALOG_H
-
-#ifdef TMWA_SUPPORT
-
-#include "gui/widgets/selldialog.h"
-
-/**
- * The sell dialog.
- *
- * \ingroup Interface
- */
-class ShopSellDialog final : public SellDialog
-{
- public:
- /**
- * Constructor.
- *
- * @see Window::Window
- */
- explicit ShopSellDialog(const std::string &nick);
-
- A_DELETE_COPY(ShopSellDialog)
-
- protected:
- void sellAction(const ActionEvent &event) override final;
-
- std::string mNick;
-};
-
-#endif // TMWA_SUPPORT
-#endif // GUI_WINDOWS_SHOPSELLDIALOG_H
diff --git a/src/gui/windows/shopwindow.cpp b/src/gui/windows/shopwindow.cpp
deleted file mode 100644
index 0e55bcca1..000000000
--- a/src/gui/windows/shopwindow.cpp
+++ /dev/null
@@ -1,1175 +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 "gui/windows/shopwindow.h"
-
-#include "const/resources/currency.h"
-
-#ifdef TMWA_SUPPORT
-#include "gui/windows/buydialog.h"
-#include "gui/windows/chatwindow.h"
-#include "gui/windows/confirmdialog.h"
-#include "gui/windows/shopselldialog.h"
-#include "gui/windows/tradewindow.h"
-
-#include "const/gui/chat.h"
-#endif // TMWA_SUPPORT
-
-#include "enums/gui/layouttype.h"
-
-#include "gui/windows/editdialog.h"
-
-#include "gui/windows/itemamountwindow.h"
-#include "gui/windows/setupwindow.h"
-
-#include "gui/models/shopitems.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/checkbox.h"
-#include "gui/widgets/containerplacer.h"
-#include "gui/widgets/createwidget.h"
-#include "gui/widgets/layout.h"
-#include "gui/widgets/scrollarea.h"
-#include "gui/widgets/shoplistbox.h"
-#include "gui/widgets/tabstrip.h"
-
-#include "listeners/shoprenamelistener.h"
-
-#ifdef TMWA_SUPPORT
-#include "actormanager.h"
-#include "soundmanager.h"
-#endif // TMWA_SUPPORT
-#include "configuration.h"
-#include "settings.h"
-
-#include "being/localplayer.h"
-#include "being/playerinfo.h"
-
-#ifdef TMWA_SUPPORT
-#include "being/playerrelations.h"
-#include "net/chathandler.h"
-#endif // TMWA_SUPPORT
-#include "net/buyingstorehandler.h"
-#include "net/vendinghandler.h"
-#include "net/net.h"
-#ifdef TMWA_SUPPORT
-#include "net/tradehandler.h"
-#endif // TMWA_SUPPORT
-
-#include "utils/checkutils.h"
-#include "utils/delete2.h"
-#include "utils/foreach.h"
-#include "utils/gettext.h"
-
-#ifdef TMWA_SUPPORT
-#include "resources/iteminfo.h"
-#endif // TMWA_SUPPORT
-
-#include "resources/inventory/inventory.h"
-
-#include "resources/item/shopitem.h"
-
-#include <sys/stat.h>
-
-#include <sstream>
-
-#include "debug.h"
-
-ShopWindow *shopWindow = nullptr;
-extern std::string tradePartnerName;
-ShopWindow::DialogList ShopWindow::instances;
-
-ShopWindow::ShopWindow() :
- // TRANSLATORS: shop window name
- Window(_("Personal Shop"), Modal_false, nullptr, "shop.xml"),
- VendingModeListener(),
- VendingSlotsListener(),
- BuyingStoreModeListener(),
- BuyingStoreSlotsListener(),
- ActionListener(),
- SelectionListener(),
- // TRANSLATORS: shop window button
- mCloseButton(new Button(this, _("Close"), "close", this)),
- mBuyShopItems(new ShopItems(false, DEFAULT_CURRENCY)),
- mSellShopItems(new ShopItems(false, DEFAULT_CURRENCY)),
- mTradeItem(nullptr),
- mBuyShopItemList(CREATEWIDGETR(ShopListBox,
- this, mBuyShopItems, mBuyShopItems, ShopListBoxType::BuyShop)),
- mSellShopItemList(CREATEWIDGETR(ShopListBox,
- this, mSellShopItems, mSellShopItems, ShopListBoxType::SellShop)),
- mCurrentShopItemList(nullptr),
- mScrollArea(new ScrollArea(this, mBuyShopItemList,
- fromBool(getOptionBool("showbuybackground"), Opaque),
- "shop_buy_background.xml")),
- // TRANSLATORS: shop window label
- mAddButton(new Button(this, _("Add"), "add", this)),
- // TRANSLATORS: shop window label
- mDeleteButton(new Button(this, _("Delete"), "delete", this)),
- mAnnounceButton(nullptr),
- mPublishButton(nullptr),
- mRenameButton(nullptr),
- mAnnounceLinks(nullptr),
- mTabs(nullptr),
- mAcceptPlayer(),
- mTradeNick(),
- mSellShopName(serverConfig.getStringValue("sellShopName")),
- mSelectedItem(-1),
- mAnnonceTime(0),
- mLastRequestTimeList(0),
- mLastRequestTimeItem(0),
- mRandCounter(0),
- mTradeMoney(0),
- mSellShopSize(0),
- mBuyShopSize(0),
- isBuySelected(true),
- mHaveVending(Net::getNetworkType() != ServerType::TMWATHENA),
- mEnableBuyingStore(false),
- mEnableVending(false)
-{
- setWindowName("Personal Shop");
- setResizable(true);
- setCloseButton(true);
- setStickyButtonLock(true);
- setMinWidth(300);
- setMinHeight(220);
- if (mainGraphics->mWidth > 600)
- setDefaultSize(500, 300, ImagePosition::CENTER);
- else
- setDefaultSize(380, 300, ImagePosition::CENTER);
-
- if (setupWindow != nullptr)
- setupWindow->registerWindowForReset(this);
-
- const int size = config.getIntValue("fontSize")
- + getOption("tabHeightAdjust", 16);
- mTabs = new TabStrip(this, "shop", size);
- mTabs->addActionListener(this);
- mTabs->setActionEventId("tab_");
- // TRANSLATORS: shop window tab name
- mTabs->addButton(_("Buy"), "buy", true);
- // TRANSLATORS: shop window tab name
- mTabs->addButton(_("Sell"), "sell", false);
- mTabs->setSelectable(false);
- mScrollArea->setSelectable(false);
-
- loadList();
-
- mBuyShopItemList->setPriceCheck(false);
- mSellShopItemList->setPriceCheck(false);
-
- mScrollArea->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
-
- mBuyShopItemList->addSelectionListener(this);
- mSellShopItemList->addSelectionListener(this);
-
- ContainerPlacer placer;
- placer = getPlacer(0, 0);
-
- placer(0, 0, mTabs, 8).setPadding(3);
-
- if (mHaveVending)
- {
- // TRANSLATORS: shop window button
- mPublishButton = new Button(this, _("Publish"), "publish", this);
- // TRANSLATORS: shop window button
- mRenameButton = new Button(this, _("Rename"), "rename", this);
- placer(2, 6, mPublishButton);
- placer(3, 6, mRenameButton);
- }
- else
- {
- // TRANSLATORS: shop window button
- mAnnounceButton = new Button(this, _("Announce"), "announce", this);
- // TRANSLATORS: shop window checkbox
- mAnnounceLinks = new CheckBox(this, _("Show links in announce"), false,
- this, "link announce");
-
- placer(2, 6, mAnnounceButton);
- placer(0, 7, mAnnounceLinks, 7);
- }
-
- placer(0, 1, mScrollArea, 8, 5).setPadding(3);
- placer(0, 6, mAddButton);
- placer(1, 6, mDeleteButton);
- placer(7, 6, mCloseButton);
-
- Layout &layout = getLayout();
- layout.setRowHeight(0, LayoutType::SET);
-
- center();
- loadWindowState();
- updateShopName();
- instances.push_back(this);
-}
-
-void ShopWindow::postInit()
-{
- Window::postInit();
- setVisible(Visible_false);
- enableVisibleSound(true);
- updateSelection();
-}
-
-ShopWindow::~ShopWindow()
-{
- saveList();
-
- delete2(mBuyShopItemList);
- delete2(mSellShopItemList);
- delete2(mBuyShopItems);
- delete2(mSellShopItems);
- delete2(mTradeItem);
-
- instances.remove(this);
-}
-
-void ShopWindow::action(const ActionEvent &event)
-{
- const std::string &eventId = event.getId();
- if (eventId == "close")
- {
- close();
- return;
- }
-#ifdef TMWA_SUPPORT
- else if (eventId == "yes")
- {
- startTrade();
- }
- else if (eventId == "no")
- {
- mTradeNick.clear();
- }
- else if (eventId == "ignore")
- {
- playerRelations.ignoreTrade(mTradeNick);
- mTradeNick.clear();
- }
- else if (eventId == "announce")
- {
- if (isBuySelected)
- {
- if (mBuyShopItems->getNumberOfElements() > 0)
- announce(mBuyShopItems, BUY);
- }
- else if (mSellShopItems->getNumberOfElements() > 0)
- {
- announce(mSellShopItems, SELL);
- }
- }
-#endif // TMWA_SUPPORT
- else if (eventId == "delete")
- {
- if (isBuySelected)
- {
- if (mBuyShopItemList != nullptr &&
- mBuyShopItemList->getSelected() >= 0)
- {
- mBuyShopItems->del(mBuyShopItemList->getSelected());
- if (isShopEmpty() && (localPlayer != nullptr))
- localPlayer->updateStatus();
- }
- }
- else if ((mSellShopItemList != nullptr)
- && mSellShopItemList->getSelected() >= 0)
- {
- mSellShopItems->del(mSellShopItemList->getSelected());
- if (isShopEmpty() && (localPlayer != nullptr))
- localPlayer->updateStatus();
- }
- }
- else if (eventId == "tab_buy")
- {
- isBuySelected = true;
- updateSelection();
- }
- else if (eventId == "tab_sell")
- {
- isBuySelected = false;
- updateSelection();
- }
- else if (eventId == "publish")
- {
- if (isBuySelected)
- {
- if (mEnableBuyingStore)
- {
- buyingStoreHandler->close();
- BuyingStoreModeListener::distributeEvent(false);
- }
- else
- {
- STD_VECTOR<ShopItem*> &items = mBuyShopItems->items();
- if (!items.empty())
- {
- buyingStoreHandler->create(mSellShopName,
- PlayerInfo::getAttribute(Attributes::MONEY),
- true,
- items);
- }
- }
- }
- else
- {
- if (mEnableVending)
- {
- vendingHandler->close();
- VendingModeListener::distributeEvent(false);
- }
- else
- {
- STD_VECTOR<ShopItem*> &oldItems = mSellShopItems->items();
- STD_VECTOR<ShopItem*> items;
- const Inventory *const inv = PlayerInfo::getCartInventory();
- if (inv == nullptr)
- return;
- FOR_EACH (STD_VECTOR<ShopItem*>::iterator, it, oldItems)
- {
- ShopItem *const item = *it;
- if (item == nullptr)
- continue;
- const Item *const cartItem = inv->findItem(item->getId(),
- item->getColor());
- if (cartItem == nullptr)
- continue;
- item->setInvIndex(cartItem->getInvIndex());
- const int amount = cartItem->getQuantity();
- if (amount == 0)
- continue;
- if (item->getQuantity() > amount)
- item->setQuantity(amount);
- items.push_back(item);
- if (static_cast<signed int>(items.size()) >= mSellShopSize)
- break;
- }
- if (!items.empty())
- vendingHandler->createShop(mSellShopName, true, items);
- }
- }
- }
- else if (eventId == "rename")
- {
- EditDialog *const dialog = CREATEWIDGETR(EditDialog,
- // TRANSLATORS: shop rename dialog title
- _("Please enter new shop name"),
- mSellShopName,
- "OK");
- shopRenameListener.setDialog(dialog);
- dialog->addActionListener(&shopRenameListener);
- }
-
- if (mSelectedItem < 1)
- return;
-
- const Inventory *const inv = mHaveVending && !isBuySelected
- ? PlayerInfo::getCartInventory() : PlayerInfo::getInventory();
- if (inv == nullptr)
- return;
-
- // +++ need support for colors
- Item *const item = inv->findItem(mSelectedItem, ItemColor_zero);
- if (item != nullptr)
- {
- if (eventId == "add")
- {
- if (isBuySelected)
- {
- ItemAmountWindow::showWindow(ItemAmountWindowUsage::ShopBuyAdd,
- this,
- item,
- sumAmount(item));
- }
- else
- {
- ItemAmountWindow::showWindow(
- ItemAmountWindowUsage::ShopSellAdd,
- this,
- item,
- sumAmount(item));
- }
- }
- }
-}
-
-void ShopWindow::valueChanged(const SelectionEvent &event A_UNUSED)
-{
- updateButtonsAndLabels();
-}
-
-void ShopWindow::updateButtonsAndLabels()
-{
- bool allowDel(false);
- bool allowAdd(false);
- const bool sellNotEmpty = mSellShopItems->getNumberOfElements() > 0;
- if (isBuySelected)
- {
- allowAdd = !mEnableBuyingStore;
- allowDel = !mEnableBuyingStore
- && mBuyShopItemList->getSelected() != -1
- && mBuyShopItems->getNumberOfElements() > 0;
- if (mPublishButton != nullptr)
- {
- if (mEnableBuyingStore)
- {
- // TRANSLATORS: unpublish shop button
- mPublishButton->setCaption(_("Unpublish"));
- }
- else
- {
- // TRANSLATORS: publish shop button
- mPublishButton->setCaption(_("Publish"));
- }
- mPublishButton->adjustSize();
- if (mBuyShopSize > 0)
- mPublishButton->setEnabled(true);
- else
- mPublishButton->setEnabled(false);
- }
- }
- else
- {
- allowAdd = !mEnableVending && mSelectedItem != -1;
- allowDel = !mEnableVending
- && mSellShopItemList->getSelected() != -1
- && sellNotEmpty;
- if (mPublishButton != nullptr)
- {
- if (mEnableVending)
- {
- // TRANSLATORS: unpublish shop button
- mPublishButton->setCaption(_("Unpublish"));
- }
- else
- {
- // TRANSLATORS: publish shop button
- mPublishButton->setCaption(_("Publish"));
- }
- mPublishButton->adjustSize();
- if (sellNotEmpty
- && mSellShopSize > 0
- && (localPlayer != nullptr)
- && localPlayer->getHaveCart())
- {
- mPublishButton->setEnabled(true);
- }
- else
- {
- mPublishButton->setEnabled(false);
- }
- }
- }
- mAddButton->setEnabled(allowAdd);
- mDeleteButton->setEnabled(allowDel);
- if (mRenameButton != nullptr)
- mRenameButton->setEnabled(!mEnableVending);
-}
-
-void ShopWindow::setVisible(Visible visible)
-{
- Window::setVisible(visible);
-}
-
-void ShopWindow::addBuyItem(const Item *const item, const int amount,
- const int price)
-{
- if (item == nullptr)
- return;
- const bool emp = isShopEmpty();
- mBuyShopItems->addItemNoDup(item->getId(),
- item->getType(),
- item->getColor(),
- amount,
- price);
- if (emp && (localPlayer != nullptr))
- localPlayer->updateStatus();
-
- updateButtonsAndLabels();
-}
-
-void ShopWindow::addSellItem(const Item *const item, const int amount,
- const int price)
-{
- if (item == nullptr)
- return;
- const bool emp = isShopEmpty();
- mSellShopItems->addItemNoDup(item->getId(),
- item->getType(),
- item->getColor(),
- amount,
- price);
- if (emp && (localPlayer != nullptr))
- localPlayer->updateStatus();
-
- updateButtonsAndLabels();
-}
-
-void ShopWindow::loadList()
-{
- std::ifstream shopFile;
- struct stat statbuf;
-
- mBuyShopItems->clear();
- mSellShopItems->clear();
-
- const std::string shopListName = settings.serverConfigDir
- + "/shoplist.txt";
-
- if (stat(shopListName.c_str(), &statbuf) == 0 &&
- S_ISREG(statbuf.st_mode))
- {
- shopFile.open(shopListName.c_str(), std::ios::in);
- if (!shopFile.is_open())
- {
- reportAlways("Error opening file for reading: %s",
- shopListName.c_str());
- shopFile.close();
- return;
- }
- char line[101];
- while (shopFile.getline(line, 100))
- {
- std::string buf;
- const std::string str = line;
- if (!str.empty())
- {
- STD_VECTOR<int> tokens;
- std::stringstream ss(str);
-
- while (ss >> buf)
- tokens.push_back(atoi(buf.c_str()));
-
- if (tokens.size() == 5 && (tokens[0] != 0))
- {
- // +++ need impliment colors?
- if ((tokens[1] != 0) && (tokens[2] != 0))
- {
- mBuyShopItems->addItem(
- tokens[0],
- ItemType::Unknown,
- ItemColor_one,
- tokens[1],
- tokens[2]);
- }
- if ((tokens[3] != 0) && (tokens[4] != 0))
- {
- mSellShopItems->addItem(
- tokens[0],
- ItemType::Unknown,
- ItemColor_one,
- tokens[3],
- tokens[4]);
- }
- }
- }
- }
- shopFile.close();
- }
-}
-
-void ShopWindow::saveList() const
-{
- std::ofstream shopFile;
- const std::string shopListName = settings.serverConfigDir
- + "/shoplist.txt";
- std::map<int, ShopItem*> mapItems;
-
- shopFile.open(shopListName.c_str(), std::ios::binary);
- if (!shopFile.is_open())
- {
- reportAlways("Error opening file writing: %s",
- shopListName.c_str());
- return;
- }
-
- STD_VECTOR<ShopItem*> items = mBuyShopItems->items();
- FOR_EACH (STD_VECTOR<ShopItem*>::const_iterator, it, items)
- {
- ShopItem *const item = *(it);
- if (item != nullptr)
- mapItems[item->getId()] = item;
- }
-
- items = mSellShopItems->items();
- FOR_EACH (STD_VECTOR<ShopItem*>::const_iterator, it, items)
- {
- if ((*it) == nullptr)
- continue;
- const ShopItem *const sellItem = *(it);
- const ShopItem *const buyItem = mapItems[sellItem->getId()];
-
- shopFile << sellItem->getId();
- if (buyItem != nullptr)
- {
- shopFile << strprintf(" %d %d ", buyItem->getQuantity(),
- buyItem->getPrice());
- mapItems.erase(sellItem->getId());
- }
- else
- {
- shopFile << " 0 0 ";
- }
-
- shopFile << strprintf("%d %d", sellItem->getQuantity(),
- sellItem->getPrice()) << std::endl;
- }
-
- for (std::map<int, ShopItem*>::const_iterator mapIt = mapItems.begin(),
- mapIt_fend = mapItems.end();
- mapIt != mapIt_fend;
- ++mapIt)
- {
- const ShopItem *const buyItem = (*mapIt).second;
- if (buyItem != nullptr)
- {
- shopFile << buyItem->getId();
- shopFile << strprintf(" %d %d ", buyItem->getQuantity(),
- buyItem->getPrice());
- shopFile << "0 0" << std::endl;
- }
- }
-
- shopFile.close();
-}
-
-#ifdef TMWA_SUPPORT
-void ShopWindow::announce(ShopItems *const list, const int mode)
-{
- if (list == nullptr)
- return;
-
- std::string data;
- if (mode == BUY)
- data.append("Buy ");
- else
- data.append("Sell ");
-
- if (mAnnonceTime != 0 &&
- (mAnnonceTime + (2 * 60) > cur_time || mAnnonceTime > cur_time))
- {
- return;
- }
-
- mAnnonceTime = cur_time;
- if (mAnnounceButton != nullptr)
- mAnnounceButton->setEnabled(false);
-
- STD_VECTOR<ShopItem*> items = list->items();
-
- FOR_EACH (STD_VECTOR<ShopItem*>::const_iterator, it, items)
- {
- const ShopItem *const item = *(it);
- if (item->getQuantity() > 1)
- {
- if (mAnnounceLinks->isSelected())
- {
- data.append(strprintf("[@@%d|%s@@] (%dGP) %d, ", item->getId(),
- item->getInfo().getName().c_str(),
- item->getPrice(), item->getQuantity()));
- }
- else
- {
- data.append(strprintf("%s (%dGP) %d, ",
- item->getInfo().getName().c_str(),
- item->getPrice(), item->getQuantity()));
- }
- }
- else
- {
- if (mAnnounceLinks->isSelected())
- {
- data.append(strprintf("[@@%d|%s@@] (%dGP), ", item->getId(),
- item->getInfo().getName().c_str(), item->getPrice()));
- }
- else
- {
- data.append(strprintf("%s (%dGP), ",
- item->getInfo().getName().c_str(), item->getPrice()));
- }
- }
- }
-
- chatHandler->channelMessage(TRADE_CHANNEL, data);
-}
-
-void ShopWindow::startTrade()
-{
- if (actorManager == nullptr ||
- tradeWindow == nullptr)
- {
- return;
- }
-
- const Being *const being = actorManager->findBeingByName(
- mTradeNick, ActorType::Player);
- tradeWindow->clear();
- if (mTradeMoney != 0)
- {
- tradeWindow->addAutoMoney(mTradeNick, mTradeMoney);
- }
- else
- {
- tradeWindow->addAutoItem(mTradeNick, mTradeItem,
- mTradeItem->getQuantity());
- }
- tradeHandler->request(being);
- tradePartnerName = mTradeNick;
- mTradeNick.clear();
-}
-
-void ShopWindow::giveList(const std::string &nick, const int mode)
-{
- if (!checkFloodCounter(mLastRequestTimeList))
- return;
-
- std::string data("\302\202");
-
- ShopItems *list;
- if (mode == BUY)
- {
- list = mBuyShopItems;
- data.append("S1");
- }
- else
- {
- list = mSellShopItems;
- data.append("B1");
- }
- if (list == nullptr)
- return;
-
- const Inventory *const inv = PlayerInfo::getInventory();
- if (inv == nullptr)
- return;
-
- STD_VECTOR<ShopItem*> items = list->items();
-
- FOR_EACH (STD_VECTOR<ShopItem*>::const_iterator, it, items)
- {
- const ShopItem *const item = *(it);
- if (item == nullptr)
- continue;
-
- if (mode == SELL)
- {
- const Item *const item2 = inv->findItem(item->getId(),
- ItemColor_zero);
- if (item2 != nullptr)
- {
- int amount = item->getQuantity();
- if (item2->getQuantity() < amount)
- amount = item2->getQuantity();
-
- if (amount != 0)
- {
- data.append(strprintf("%s%s%s",
- encodeStr(item->getId(), 2).c_str(),
- encodeStr(item->getPrice(), 4).c_str(),
- encodeStr(amount, 3).c_str()));
- }
- }
- }
- else
- {
- int amount = item->getQuantity();
- if (item->getPrice() * amount > PlayerInfo::getAttribute(
- Attributes::MONEY))
- {
- amount = PlayerInfo::getAttribute(Attributes::MONEY)
- / item->getPrice();
- }
-
- if (amount > 0)
- {
- data.append(strprintf("%s%s%s",
- encodeStr(item->getId(), 2).c_str(),
- encodeStr(item->getPrice(), 4).c_str(),
- encodeStr(amount, 3).c_str()));
- }
- }
- }
- sendMessage(nick, data, true);
-}
-
-void ShopWindow::sendMessage(const std::string &nick,
- std::string data,
- const bool random)
-{
- if (chatWindow == nullptr)
- return;
-
- if (random)
- {
- mRandCounter ++;
- if (mRandCounter > 200)
- mRandCounter = 0;
- data.append(encodeStr(mRandCounter, 2));
- }
-
- if (config.getBoolValue("hideShopMessages"))
- chatHandler->privateMessage(nick, data);
- else
- chatWindow->addWhisper(nick, data, ChatMsgType::BY_PLAYER);
-}
-
-void ShopWindow::showList(const std::string &nick, std::string data)
-{
- const Inventory *const inv = PlayerInfo::getInventory();
- if (inv == nullptr)
- return;
-
- BuyDialog *buyDialog = nullptr;
- SellDialog *sellDialog = nullptr;
- if (data.find("B1") == 0)
- {
- data = data.substr(2);
- CREATEWIDGETV(buyDialog, BuyDialog, nick, DEFAULT_CURRENCY);
- }
- else if (data.find("S1") == 0)
- {
- data = data.substr(2);
- CREATEWIDGETV(sellDialog, ShopSellDialog, nick);
- }
- else
- {
- return;
- }
-
- if (buyDialog != nullptr)
- buyDialog->setMoney(PlayerInfo::getAttribute(Attributes::MONEY));
- if (sellDialog != nullptr)
- sellDialog->setMoney(PlayerInfo::getAttribute(Attributes::MONEY));
-
- for (unsigned f = 0; f < data.length(); f += 9)
- {
- if (f + 9 > data.length())
- break;
-
- const int id = decodeStr(data.substr(f, 2));
- const int price = decodeStr(data.substr(f + 2, 4));
- int amount = decodeStr(data.substr(f + 6, 3));
- if (buyDialog != nullptr && amount > 0)
- {
- buyDialog->addItem(id,
- ItemType::Unknown,
- ItemColor_one,
- amount,
- price);
- }
- if (sellDialog != nullptr)
- {
- const Item *const item = inv->findItem(id, ItemColor_zero);
- if (item != nullptr)
- {
- if (item->getQuantity() < amount)
- amount = item->getQuantity();
- }
- else
- {
- amount = 0;
- }
- ShopItem *const shopItem = sellDialog->addItem(id,
- ItemType::Unknown,
- ItemColor_one,
- amount,
- price);
-
- if (shopItem != nullptr && amount <= 0)
- shopItem->setDisabled(true);
- }
- }
- if (buyDialog != nullptr)
- buyDialog->sort();
-}
-
-void ShopWindow::processRequest(const std::string &nick,
- std::string data,
- const int mode)
-{
- if (localPlayer == nullptr ||
- !mTradeNick.empty() ||
- PlayerInfo::isTrading() == Trading_true ||
- actorManager == nullptr ||
- actorManager->findBeingByName(nick, ActorType::Player) == nullptr)
- {
- return;
- }
-
- const Inventory *const inv = PlayerInfo::getInventory();
- if (inv == nullptr)
- return;
-
- const size_t idx = data.find(' ');
- if (idx == std::string::npos)
- return;
-
- if (!checkFloodCounter(mLastRequestTimeItem))
- return;
-
- if (!mTradeNick.empty())
- {
- sendMessage(nick,
- // TRANSLATORS: error buy/sell shop request
- _("error: player busy") + std::string(" "),
- true);
- return;
- }
-
- data = data.substr(idx + 1);
-
- std::string part1;
- std::string part2;
- std::string part3;
- std::stringstream ss(data);
- int id;
- int price;
- int amount;
-
- if (!(ss >> part1))
- return;
-
- if (!(ss >> part2))
- return;
-
- if (!(ss >> part3))
- return;
-
- id = atoi(part1.c_str());
- price = atoi(part2.c_str());
- amount = atoi(part3.c_str());
-
- delete mTradeItem;
- // +++ need impliment colors?
- mTradeItem = new ShopItem(-1,
- id,
- ItemType::Unknown,
- ItemColor_one,
- amount,
- price,
- DEFAULT_CURRENCY);
-
- if (mode == BUY)
- {
- // +++ need support for colors
- const Item *const item2 = inv->findItem(mTradeItem->getId(),
- ItemColor_zero);
- if (item2 == nullptr ||
- item2->getQuantity() < amount ||
- !findShopItem(mTradeItem, SELL))
- {
- sendMessage(nick,
- // TRANSLATORS: error buy/sell shop request
- _("error: Can't sell this item") + std::string(" "),
- true);
- return;
- }
- mTradeMoney = 0;
- }
- else
- {
- if (!findShopItem(mTradeItem, BUY))
- {
- sendMessage(nick,
- // TRANSLATORS: error buy/sell shop request
- _("error: Can't buy this item") + std::string(" "),
- true);
- return;
- }
- mTradeMoney = mTradeItem->getPrice() * mTradeItem->getQuantity();
- }
-
- mTradeNick = nick;
-
- if (config.getBoolValue("autoShop"))
- {
- soundManager.playGuiSound(SOUND_TRADE);
- startTrade();
- }
- else
- {
- std::string msg;
- if (mode == BUY)
- {
- // TRANSLATORS: buy shop request (nick, item)
- msg = strprintf(_("%s wants to buy %s do you accept?"),
- nick.c_str(),
- mTradeItem->getInfo().getName().c_str());
- }
- else
- {
- // TRANSLATORS: sell shop request (nick, item)
- msg = strprintf(_("%s wants to sell %s do you accept?"),
- nick.c_str(),
- mTradeItem->getInfo().getName().c_str());
- }
-
- ConfirmDialog *const confirmDlg = CREATEWIDGETR(ConfirmDialog,
- // TRANSLATORS: shop window dialog
- _("Request for Trade"),
- msg,
- SOUND_REQUEST,
- true);
- confirmDlg->addActionListener(this);
- }
-}
-
-void ShopWindow::updateTimes()
-{
- BLOCK_START("ShopWindow::updateTimes")
- if (mAnnounceButton == nullptr)
- {
- BLOCK_END("ShopWindow::updateTimes")
- return;
- }
- if (mAnnonceTime + (2 * 60) < cur_time ||
- mAnnonceTime > cur_time)
- {
- mAnnounceButton->setEnabled(true);
- }
- BLOCK_END("ShopWindow::updateTimes")
-}
-
-bool ShopWindow::checkFloodCounter(time_t &counterTime)
-{
- if (counterTime == 0 || counterTime > cur_time)
- counterTime = cur_time;
- else if (counterTime + 10 > cur_time)
- return false;
- else
- counterTime = cur_time;
- return true;
-}
-
-bool ShopWindow::findShopItem(const ShopItem *const shopItem,
- const int mode) const
-{
- if (shopItem == nullptr)
- return false;
-
- STD_VECTOR<ShopItem*> items;
- if (mode == SELL)
- items = mSellShopItems->items();
- else
- items = mBuyShopItems->items();
-
- FOR_EACH (STD_VECTOR<ShopItem*>::const_iterator, it, items)
- {
- const ShopItem *const item = *(it);
- if (item == nullptr)
- continue;
-
- if (item->getId() == shopItem->getId()
- && item->getPrice() == shopItem->getPrice()
- && item->getQuantity() >= shopItem->getQuantity())
- {
- return true;
- }
- }
- return false;
-}
-#endif // TMWA_SUPPORT
-
-int ShopWindow::sumAmount(const Item *const shopItem)
-{
- if ((localPlayer == nullptr) || (shopItem == nullptr))
- return 0;
-
- const Inventory *const inv = PlayerInfo::getInventory();
- if (inv == nullptr)
- return 0;
- int sum = 0;
-
- for (unsigned f = 0; f < inv->getSize(); f ++)
- {
- const Item *const item = inv->getItem(f);
- if ((item != nullptr) && item->getId() == shopItem->getId())
- sum += item->getQuantity();
- }
- return sum;
-}
-
-bool ShopWindow::isShopEmpty() const
-{
- if (mBuyShopItems->empty() && mSellShopItems->empty())
- return true;
- return false;
-}
-
-void ShopWindow::updateSelection()
-{
- if (isBuySelected)
- mCurrentShopItemList = mBuyShopItemList;
- else
- mCurrentShopItemList = mSellShopItemList;
- mScrollArea->setContent(mCurrentShopItemList);
- updateButtonsAndLabels();
-}
-
-void ShopWindow::updateShopName()
-{
- if (mSellShopName.empty())
- {
- // TRANSLATORS: shop window name
- setCaption(_("Personal Shop"));
- }
- else
- {
- // TRANSLATORS: shop window name
- setCaption(strprintf(_("Personal Shop - %s"), mSellShopName.c_str()));
- }
-}
-
-void ShopWindow::setShopName(const std::string &name)
-{
- mSellShopName = name;
- serverConfig.setValue("sellShopName", mSellShopName);
- updateShopName();
-}
-
-void ShopWindow::vendingSlotsChanged(const int slots)
-{
- mSellShopSize = slots;
- updateButtonsAndLabels();
-}
-
-void ShopWindow::vendingEnabled(const bool b)
-{
- mEnableVending = b;
- localPlayer->enableShop(b);
- if (!b)
- mSellShopSize = 0;
- updateButtonsAndLabels();
-}
-
-void ShopWindow::buyingStoreSlotsChanged(const int slots)
-{
- mBuyShopSize = slots;
- updateButtonsAndLabels();
-}
-
-void ShopWindow::buyingStoreEnabled(const bool b)
-{
- mEnableBuyingStore = b;
- localPlayer->enableShop(b);
- if (!b)
- mBuyShopSize = 0;
- updateButtonsAndLabels();
-}
diff --git a/src/gui/windows/shopwindow.h b/src/gui/windows/shopwindow.h
deleted file mode 100644
index e96ab3de8..000000000
--- a/src/gui/windows/shopwindow.h
+++ /dev/null
@@ -1,207 +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_WINDOWS_SHOPWINDOW_H
-#define GUI_WINDOWS_SHOPWINDOW_H
-
-#include "gui/widgets/window.h"
-
-#include "listeners/actionlistener.h"
-#include "listeners/buyingstoremodelistener.h"
-#include "listeners/buyingstoreslotslistener.h"
-#include "listeners/selectionlistener.h"
-#include "listeners/vendingmodelistener.h"
-#include "listeners/vendingslotslistener.h"
-
-class Button;
-class CheckBox;
-class Item;
-class ScrollArea;
-class ShopItem;
-class ShopItems;
-class ShopListBox;
-class TabStrip;
-
-/**
- * The buy dialog.
- *
- * \ingroup Interface
- */
-class ShopWindow final : public Window,
- public VendingModeListener,
- public VendingSlotsListener,
- public BuyingStoreModeListener,
- public BuyingStoreSlotsListener,
- public ActionListener,
- public SelectionListener
-{
- public:
- enum ShopMode
- {
- BUY = 0,
- SELL = 1
- };
-
- /**
- * Constructor.
- *
- * @see Window::Window
- */
- ShopWindow();
-
- A_DELETE_COPY(ShopWindow)
-
- /**
- * Destructor
- */
- ~ShopWindow();
-
- void postInit() override final;
-
- /**
- * Called when receiving actions from the widgets.
- */
- void action(const ActionEvent &event) override final;
-
- /**
- * Updates the labels according to the selected item.
- */
- void valueChanged(const SelectionEvent &event) override final;
-
- /**
- * Updates the state of buttons and labels.
- */
- void updateButtonsAndLabels();
-
- /**
- * Sets the visibility of this window.
- */
- void setVisible(Visible visible) override final;
-
- /**
- * Returns true if any instances exist.
- */
- static bool isActive() A_WARN_UNUSED
- { return !instances.empty(); }
-
- void setItemSelected(const int id)
- { mSelectedItem = id; updateButtonsAndLabels(); }
-
- void addBuyItem(const Item *const item, const int amount,
- const int price);
-
- void addSellItem(const Item *const item, const int amount,
- const int price);
-
- void loadList();
-
- void saveList() const;
-
-#ifdef TMWA_SUPPORT
- void setAcceptPlayer(const std::string &name)
- { mAcceptPlayer = name; }
-
- const std::string &getAcceptPlayer() const noexcept2 A_WARN_UNUSED
- { return mAcceptPlayer; }
-
- void announce(ShopItems *const list, const int mode);
-
- void giveList(const std::string &nick, const int mode);
-
- void sendMessage(const std::string &nick, std::string data,
- const bool random = false);
-
- static void showList(const std::string &nick, std::string data);
-
- void processRequest(const std::string &nick, std::string data,
- const int mode);
- void updateTimes();
-
- static bool checkFloodCounter(time_t &counterTime) A_WARN_UNUSED;
-
- bool findShopItem(const ShopItem *const shopItem,
- const int mode) const A_WARN_UNUSED;
-#endif // TMWA_SUPPORT
-
- static int sumAmount(const Item *const shopItem) A_WARN_UNUSED;
-
- bool isShopEmpty() const A_WARN_UNUSED;
-
- void vendingEnabled(const bool b) override final;
-
- void vendingSlotsChanged(const int slots) override final;
-
- void buyingStoreEnabled(const bool b) override final;
-
- void buyingStoreSlotsChanged(const int slots) override final;
-
- void setShopName(const std::string &name);
-
- private:
-#ifdef TMWA_SUPPORT
- void startTrade();
-#endif // TMWA_SUPPORT
-
- void updateSelection();
-
- void updateShopName();
-
- typedef std::list<ShopWindow*> DialogList;
- static DialogList instances;
-
- Button *mCloseButton A_NONNULLPOINTER;
-
- ShopItems *mBuyShopItems A_NONNULLPOINTER;
- ShopItems *mSellShopItems A_NONNULLPOINTER;
- ShopItem *mTradeItem;
-
- ShopListBox *mBuyShopItemList A_NONNULLPOINTER;
- ShopListBox *mSellShopItemList A_NONNULLPOINTER;
- ShopListBox *mCurrentShopItemList;
- ScrollArea *mScrollArea A_NONNULLPOINTER;
- Button *mAddButton A_NONNULLPOINTER;
- Button *mDeleteButton A_NONNULLPOINTER;
- Button *mAnnounceButton;
- Button *mPublishButton;
- Button *mRenameButton;
- CheckBox *mAnnounceLinks;
- TabStrip *mTabs;
- std::string mAcceptPlayer;
- std::string mTradeNick;
- std::string mSellShopName;
- int mSelectedItem;
- time_t mAnnonceTime;
- time_t mLastRequestTimeList;
- time_t mLastRequestTimeItem;
- int mRandCounter;
- int mTradeMoney;
- int mSellShopSize;
- int mBuyShopSize;
- bool isBuySelected;
- bool mHaveVending;
- bool mEnableBuyingStore;
- bool mEnableVending;
-};
-
-extern ShopWindow *shopWindow;
-
-#endif // GUI_WINDOWS_SHOPWINDOW_H
diff --git a/src/gui/windows/shortcutwindow.cpp b/src/gui/windows/shortcutwindow.cpp
deleted file mode 100644
index 1bb35d3f1..000000000
--- a/src/gui/windows/shortcutwindow.cpp
+++ /dev/null
@@ -1,269 +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 "gui/windows/shortcutwindow.h"
-
-#include "enums/gui/layouttype.h"
-
-#include "gui/windows/setupwindow.h"
-#include "gui/widgets/tabbedarea.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/createwidget.h"
-#include "gui/widgets/layout.h"
-#include "gui/widgets/scrollarea.h"
-#include "gui/widgets/shortcutcontainer.h"
-
-#include "gui/widgets/tabs/shortcuttab.h"
-
-#include "utils/delete2.h"
-#include "utils/foreach.h"
-
-#include "debug.h"
-
-ShortcutWindow *dropShortcutWindow = nullptr;
-ShortcutWindow *emoteShortcutWindow = nullptr;
-ShortcutWindow *itemShortcutWindow = nullptr;
-ShortcutWindow *spellShortcutWindow = nullptr;
-static const int SCROLL_PADDING = 0;
-
-int ShortcutWindow::mBoxesWidth = 0;
-
-ShortcutWindow::ShortcutWindow(const std::string &restrict title,
- ShortcutContainer *restrict const content,
- const std::string &restrict skinFile,
- int width, int height) :
- Window("Window", Modal_false, nullptr, skinFile),
- mItems(content),
- mScrollArea(new ScrollArea(this, mItems, Opaque_false)),
- mTabs(nullptr),
- mPages(),
- mButtonIndex(0)
-{
- setWindowName(title);
- setTitleBarHeight(getPadding() + getTitlePadding());
-
- setShowTitle(false);
- setResizable(true);
- setDefaultVisible(false);
- setSaveVisible(true);
- setAllowClose(true);
-
- mDragOffsetX = 0;
- mDragOffsetY = 0;
-
- if (content != nullptr)
- content->setWidget2(this);
- if (setupWindow != nullptr)
- setupWindow->registerWindowForReset(this);
-
- setMinWidth(32);
- setMinHeight(32);
- const int border = SCROLL_PADDING * 2 + getPadding() * 2;
- if (mItems != nullptr)
- {
- const int bw = mItems->getBoxWidth();
- const int bh = mItems->getBoxHeight();
- const int maxItems = mItems->getMaxItems();
- setMaxWidth(bw * maxItems + border);
- setMaxHeight(bh * maxItems + border);
-
- if (width == 0)
- width = bw + border;
- if (height == 0)
- height = bh * maxItems + border;
-
- setDefaultSize(width, height, ImagePosition::LOWER_RIGHT);
-
- mBoxesWidth += bw + border;
- }
-
- mScrollArea->setPosition(SCROLL_PADDING, SCROLL_PADDING);
- mScrollArea->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
-
- place(0, 0, mScrollArea, 5, 5).setPadding(0);
-
- Layout &layout = getLayout();
- layout.setRowHeight(0, LayoutType::SET);
- layout.setMargin(0);
-
- loadWindowState();
- enableVisibleSound(true);
-}
-
-ShortcutWindow::ShortcutWindow(const std::string &restrict title,
- const std::string &restrict skinFile,
- const int width, const int height) :
- Window("Window", Modal_false, nullptr, skinFile),
- mItems(nullptr),
- mScrollArea(nullptr),
- mTabs(CREATEWIDGETR(TabbedArea, this)),
- mPages(),
- mButtonIndex(0)
-{
- setWindowName(title);
- setTitleBarHeight(getPadding() + getTitlePadding());
- setShowTitle(false);
- setResizable(true);
- setDefaultVisible(false);
- setSaveVisible(true);
- setAllowClose(true);
-
- mDragOffsetX = 0;
- mDragOffsetY = 0;
-
- if (setupWindow != nullptr)
- setupWindow->registerWindowForReset(this);
-
- if ((width != 0) && (height != 0))
- setDefaultSize(width, height, ImagePosition::LOWER_RIGHT);
-
- setMinWidth(32);
- setMinHeight(32);
-
- place(0, 0, mTabs, 5, 5);
-
- Layout &layout = getLayout();
- layout.setRowHeight(0, LayoutType::SET);
- layout.setMargin(0);
-
- loadWindowState();
- enableVisibleSound(true);
-}
-
-ShortcutWindow::~ShortcutWindow()
-{
- if (mTabs != nullptr)
- mTabs->removeAll();
- delete2(mTabs);
- delete2(mItems);
-}
-
-void ShortcutWindow::addButton(const std::string &text,
- const std::string &eventName,
- ActionListener *const listener)
-{
- place(mButtonIndex++, 5, new Button(this, text, eventName, listener));
- Window::widgetResized(Event(nullptr));
-}
-
-void ShortcutWindow::addTab(const std::string &name,
- ShortcutContainer *const content)
-{
- if ((content == nullptr) || (mTabs == nullptr))
- return;
- ScrollArea *const scroll = new ScrollArea(this, content, Opaque_false);
- scroll->setPosition(SCROLL_PADDING, SCROLL_PADDING);
- scroll->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
- content->setWidget2(this);
- Tab *const tab = new ShortcutTab(this, name, content);
- mTabs->addTab(tab, scroll);
- mPages.push_back(content);
-}
-
-int ShortcutWindow::getTabIndex() const
-{
- if (mTabs == nullptr)
- return 0;
- return mTabs->getSelectedTabIndex();
-}
-
-void ShortcutWindow::widgetHidden(const Event &event)
-{
- Window::widgetHidden(event);
- if (mItems != nullptr)
- mItems->widgetHidden(event);
- if (mTabs != nullptr)
- {
- ScrollArea *const scroll = static_cast<ScrollArea *>(
- mTabs->getCurrentWidget());
- if (scroll != nullptr)
- {
- ShortcutContainer *const content = static_cast<ShortcutContainer*>(
- scroll->getContent());
-
- if (content != nullptr)
- content->widgetHidden(event);
- }
- }
-}
-
-void ShortcutWindow::mousePressed(MouseEvent &event)
-{
- Window::mousePressed(event);
-
- if (event.isConsumed())
- return;
-
- if (event.getButton() == MouseButton::LEFT)
- {
- mDragOffsetX = event.getX();
- mDragOffsetY = event.getY();
- }
-}
-
-void ShortcutWindow::mouseDragged(MouseEvent &event)
-{
- Window::mouseDragged(event);
-
- if (event.isConsumed())
- return;
-
- if (canMove() && isMovable() && mMoved)
- {
- int newX = std::max(0, getX() + event.getX() - mDragOffsetX);
- int newY = std::max(0, getY() + event.getY() - mDragOffsetY);
- newX = std::min(mainGraphics->mWidth - getWidth(), newX);
- newY = std::min(mainGraphics->mHeight - getHeight(), newY);
- setPosition(newX, newY);
- }
-}
-
-void ShortcutWindow::widgetMoved(const Event& event)
-{
- Window::widgetMoved(event);
- if (mItems != nullptr)
- mItems->setRedraw(true);
- FOR_EACH (STD_VECTOR<ShortcutContainer*>::iterator, it, mPages)
- (*it)->setRedraw(true);
-}
-
-void ShortcutWindow::nextTab()
-{
- if (mTabs != nullptr)
- mTabs->selectNextTab();
-}
-
-void ShortcutWindow::prevTab()
-{
- if (mTabs != nullptr)
- mTabs->selectPrevTab();
-}
-
-#ifdef USE_PROFILER
-void ShortcutWindow::logicChildren()
-{
- BLOCK_START("ShortcutWindow::logicChildren")
- BasicContainer::logicChildren();
- BLOCK_END("ShortcutWindow::logicChildren")
-}
-#endif // USE_PROFILER
diff --git a/src/gui/windows/shortcutwindow.h b/src/gui/windows/shortcutwindow.h
deleted file mode 100644
index f21c505c5..000000000
--- a/src/gui/windows/shortcutwindow.h
+++ /dev/null
@@ -1,100 +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 GUI_WINDOWS_SHORTCUTWINDOW_H
-#define GUI_WINDOWS_SHORTCUTWINDOW_H
-
-#include "gui/widgets/window.h"
-
-class ScrollArea;
-class ShortcutContainer;
-class TabbedArea;
-
-/**
- * A window around a ShortcutContainer.
- *
- * \ingroup Interface
- */
-class ShortcutWindow final : public Window
-{
- public:
- /**
- * Constructor.
- */
- ShortcutWindow(const std::string &restrict title,
- ShortcutContainer *restrict const content,
- const std::string &restrict skinFile = "",
- int width = 0, int height = 0);
-
- explicit ShortcutWindow(const std::string &restrict title,
- const std::string &restrict skinFile = "",
- const int width = 0, const int height = 0);
-
- A_DELETE_COPY(ShortcutWindow)
-
- /**
- * Destructor.
- */
- ~ShortcutWindow();
-
- void addTab(const std::string &name, ShortcutContainer *const content);
-
- int getTabIndex() const A_WARN_UNUSED;
-
- void widgetHidden(const Event &event) override final;
-
- void widgetMoved(const Event& event) override final;
-
- void mousePressed(MouseEvent &event) override final;
-
- void mouseDragged(MouseEvent &event) override final;
-
- void nextTab();
-
- void prevTab();
-
- void addButton(const std::string &text,
- const std::string &eventName,
- ActionListener *const listener);
-
-#ifdef USE_PROFILER
- void logicChildren();
-#endif // USE_PROFILER
-
- private:
- ShortcutWindow();
- ShortcutContainer *mItems;
-
- ScrollArea *mScrollArea A_NONNULLPOINTER;
- TabbedArea *mTabs;
- STD_VECTOR<ShortcutContainer*> mPages;
- int mButtonIndex;
-
- static int mBoxesWidth;
-};
-
-extern ShortcutWindow *dropShortcutWindow;
-extern ShortcutWindow *emoteShortcutWindow;
-extern ShortcutWindow *itemShortcutWindow;
-extern ShortcutWindow *spellShortcutWindow;
-
-#endif // GUI_WINDOWS_SHORTCUTWINDOW_H
diff --git a/src/gui/windows/skilldialog.cpp b/src/gui/windows/skilldialog.cpp
deleted file mode 100644
index 9f11605ef..000000000
--- a/src/gui/windows/skilldialog.cpp
+++ /dev/null
@@ -1,1432 +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 "gui/windows/skilldialog.h"
-
-#include "configuration.h"
-#include "effectmanager.h"
-#include "spellmanager.h"
-
-#include "being/localplayer.h"
-#include "being/playerinfo.h"
-
-#include "const/resources/spriteaction.h"
-
-#include "enums/resources/skill/skillsettype.h"
-
-#include "gui/shortcut/itemshortcut.h"
-
-#include "gui/windows/setupwindow.h"
-#include "gui/windows/shortcutwindow.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/createwidget.h"
-#include "gui/widgets/label.h"
-#include "gui/widgets/scrollarea.h"
-#include "gui/widgets/tabbedarea.h"
-
-#include "gui/widgets/tabs/skilltab.h"
-
-#include "gui/windows/textdialog.h"
-
-#include "listeners/textskilllistener.h"
-
-#include "net/playerhandler.h"
-#include "net/skillhandler.h"
-
-#include "utils/checkutils.h"
-#include "utils/dtor.h"
-#include "utils/gettext.h"
-#include "utils/timer.h"
-
-#include "resources/beingcommon.h"
-
-#include "debug.h"
-
-SkillDialog *skillDialog = nullptr;
-
-namespace
-{
- TextSkillListener textSkillListener;
-} // namespace
-
-static SkillOwner::Type parseOwner(const std::string &str)
-{
- if (str == "player")
- return SkillOwner::Player;
- else if (str == "mercenary")
- return SkillOwner::Mercenary;
- else if (str == "homunculus")
- return SkillOwner::Homunculus;
- return SkillOwner::Player;
-}
-
-SkillDialog::SkillDialog() :
- // TRANSLATORS: skills dialog name
- Window(_("Skills"), Modal_false, nullptr, "skills.xml"),
- ActionListener(),
- mSkills(),
- mDurations(),
- mTabs(CREATEWIDGETR(TabbedArea, this)),
- mDeleteTabs(),
- mPointsLabel(new Label(this, "0")),
- // TRANSLATORS: skills dialog button
- mUseButton(new Button(this, _("Use"), "use", this)),
- // TRANSLATORS: skills dialog button
- mIncreaseButton(new Button(this, _("Up"), "inc", this)),
- mDefaultModel(nullptr),
- mDefaultTab(nullptr)
-{
- setWindowName("Skills");
- setCloseButton(true);
- setResizable(true);
- setSaveVisible(true);
- setStickyButtonLock(true);
- setDefaultSize(windowContainer->getWidth() - 280, 30, 275, 425);
- if (setupWindow != nullptr)
- setupWindow->registerWindowForReset(this);
-
- mUseButton->setEnabled(false);
- mIncreaseButton->setEnabled(false);
- mTabs->setSelectable(false);
- mTabs->getTabContainer()->setSelectable(false);
- mTabs->getWidgetContainer()->setSelectable(false);
-
- place(0, 0, mTabs, 5, 5);
- place(0, 5, mPointsLabel, 4);
- place(3, 5, mUseButton);
- place(4, 5, mIncreaseButton);
-}
-
-void SkillDialog::postInit()
-{
- Window::postInit();
- setLocationRelativeTo(getParent());
- loadWindowState();
- enableVisibleSound(true);
-}
-
-SkillDialog::~SkillDialog()
-{
- clearSkills();
-}
-
-void SkillDialog::addDefaultTab()
-{
- mDefaultModel = new SkillModel;
- SkillListBox *const listbox = new SkillListBox(this,
- mDefaultModel);
- listbox->setActionEventId("sel");
- listbox->addActionListener(this);
- ScrollArea *const scroll = new ScrollArea(this,
- listbox,
- Opaque_false);
- scroll->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
- scroll->setVerticalScrollPolicy(ScrollArea::SHOW_ALWAYS);
- // TRANSLATORS: unknown skills tab name
- mDefaultTab = new SkillTab(this, _("Unknown"), listbox);
- mDeleteTabs.push_back(mDefaultTab);
- mDefaultTab->setVisible(Visible_false);
- mTabs->addTab(mDefaultTab, scroll);
- mTabs->adjustTabPositions();
- mTabs->setSelectedTabDefault();
-}
-
-void SkillDialog::action(const ActionEvent &event)
-{
- const std::string &eventId = event.getId();
- if (eventId == "inc")
- {
- if (playerHandler == nullptr)
- return;
- const SkillTab *const tab = static_cast<const SkillTab *>(
- mTabs->getSelectedTab());
- if (tab != nullptr)
- {
- if (const SkillInfo *const info = tab->getSelectedInfo())
- playerHandler->increaseSkill(CAST_U16(info->id));
- }
- }
- else if (eventId == "sel")
- {
- const SkillTab *const tab = static_cast<const SkillTab *>(
- mTabs->getSelectedTab());
- if (tab != nullptr)
- {
- if (const SkillInfo *const info = tab->getSelectedInfo())
- {
- mUseButton->setEnabled(info->isUsable());
- mUseButton->setCaption(info->useButton);
- mIncreaseButton->setEnabled(info->id < SKILL_VAR_MIN_ID);
- const int num = itemShortcutWindow->getTabIndex();
- if (num >= 0 && num < CAST_S32(SHORTCUT_TABS)
- && (itemShortcut[num] != nullptr))
- {
- itemShortcut[num]->setItemSelected(
- info->id + SKILL_MIN_ID);
- }
- }
- else
- {
- mUseButton->setEnabled(false);
- mIncreaseButton->setEnabled(false);
- // TRANSLATORS: skills dialog button
- mUseButton->setCaption(_("Use"));
- }
- }
- }
- else if (eventId == "use")
- {
- const SkillTab *const tab = static_cast<const SkillTab *>(
- mTabs->getSelectedTab());
- if (tab != nullptr)
- {
- const SkillInfo *const info = tab->getSelectedInfo();
- if (info == nullptr)
- return;
- useSkill(info,
- fromBool(config.getBoolValue("skillAutotarget"), AutoTarget),
- info->customSelectedLevel,
- info->useTextParameter,
- std::string(),
- info->customCastType,
- info->customOffsetX,
- info->customOffsetY);
- }
- }
- else if (eventId == "close")
- {
- setVisible(Visible_false);
- }
-}
-
-std::string SkillDialog::update(const int id)
-{
- const SkillMap::const_iterator i = mSkills.find(id);
-
- if (i != mSkills.end())
- {
- SkillInfo *const info = i->second;
- if (info != nullptr)
- {
- info->update();
- return info->data->name;
- }
- }
-
- return std::string();
-}
-
-void SkillDialog::update()
-{
- // TRANSLATORS: skills dialog label
- mPointsLabel->setCaption(strprintf(_("Skill points available: %d"),
- PlayerInfo::getAttribute(Attributes::PLAYER_SKILL_POINTS)));
- mPointsLabel->adjustSize();
-
- ItemShortcut *const shortcuts = itemShortcut[SHORTCUT_AUTO_TAB];
- shortcuts->clear();
- size_t idx = 0;
-
- FOR_EACH (SkillMap::const_iterator, it, mSkills)
- {
- SkillInfo *const info = (*it).second;
- if (info == nullptr)
- continue;
- if (info->modifiable == Modifiable_true)
- info->update();
- if (info->visible == Visible_false ||
- idx >= SHORTCUT_ITEMS ||
- !info->data->autoTab)
- {
- continue;
- }
- const SkillType::SkillType type = info->type;
- if (type == SkillType::Attack ||
- type == SkillType::Ground ||
- type == SkillType::Self ||
- type == SkillType::Support)
- {
- shortcuts->setItemFast(idx,
- info->id + SKILL_MIN_ID,
- fromInt(info->customSelectedLevel, ItemColor));
-
- shortcuts->setItemData(idx,
- info->toDataStr());
- idx ++;
- }
- }
-
- skillPopup->reset();
-}
-
-void SkillDialog::updateModels()
-{
- std::set<SkillModel*> models;
-
- FOR_EACH (SkillMap::const_iterator, it, mSkills)
- {
- SkillInfo *const info = (*it).second;
- if (info != nullptr)
- {
- SkillModel *const model = info->model;
- if (model != nullptr)
- models.insert(model);
- }
- }
- FOR_EACH (std::set<SkillModel*>::iterator, it, models)
- {
- SkillModel *const model = *it;
- if (model != nullptr)
- model->updateVisibilities();
- }
-}
-
-void SkillDialog::clearSkills()
-{
- mTabs->removeAll();
- mDeleteTabs.clear();
- mDefaultTab = nullptr;
- mDefaultModel = nullptr;
-
- delete_all(mSkills);
- mSkills.clear();
- mDurations.clear();
-}
-
-void SkillDialog::hideSkills(const SkillOwner::Type owner)
-{
- FOR_EACH (SkillMap::iterator, it, mSkills)
- {
- SkillInfo *const info = (*it).second;
- if ((info != nullptr) && info->owner == owner)
- {
- PlayerInfo::setSkillLevel(info->id, 0);
- if (info->alwaysVisible == Visible_false)
- info->visible = Visible_false;
- }
- }
-}
-
-void SkillDialog::loadSkills()
-{
- clearSkills();
- loadXmlFile(paths.getStringValue("skillsFile"), SkipError_false);
- if (mSkills.empty())
- loadXmlFile(paths.getStringValue("skillsFile2"), SkipError_false);
- loadXmlFile(paths.getStringValue("skillsPatchFile"), SkipError_true);
- loadXmlDir("skillsPatchDir", loadXmlFile);
- addDefaultTab();
-
- update();
-}
-
-void SkillDialog::loadXmlFile(const std::string &fileName,
- const SkipError skipError)
-{
- XML::Document doc(fileName,
- UseVirtFs_true,
- skipError);
- XmlNodePtrConst root = doc.rootNode();
-
- int setCount = 0;
-
- if ((root == nullptr) || !xmlNameEqual(root, "skills"))
- {
- logger->log("Error loading skills: " + fileName);
- return;
- }
-
- for_each_xml_child_node(set, root)
- {
- if (xmlNameEqual(set, "include"))
- {
- const std::string name = XML::getProperty(set, "name", "");
- if (!name.empty())
- loadXmlFile(name, skipError);
- continue;
- }
- else if (xmlNameEqual(set, "set"))
- {
- setCount++;
- const std::string setName = XML::getProperty(set, "name",
- // TRANSLATORS: skills dialog default skill tab
- strprintf(_("Skill Set %d"), setCount));
-
- const std::string setTypeStr = XML::getProperty(set, "type", "");
- SkillSetTypeT setType = SkillSetType::VerticalList;
- if (setTypeStr.empty() ||
- setTypeStr == "list" ||
- setTypeStr == "vertical")
- {
- setType = SkillSetType::VerticalList;
- }
- else if (setTypeStr == "rectangle")
- {
- setType = SkillSetType::Rectangle;
- }
-
- bool alwaysVisible = false;
- SkillModel *const model = new SkillModel;
- SkillTab *tab = nullptr;
- ScrollArea *scroll = nullptr;
-
- switch (setType)
- {
- case SkillSetType::VerticalList:
- {
- // possible leak listbox, scroll
- SkillListBox *const listbox = new SkillListBox(this,
- model);
- listbox->setActionEventId("sel");
- listbox->addActionListener(this);
- scroll = new ScrollArea(this,
- listbox,
- Opaque_false);
- scroll->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
- scroll->setVerticalScrollPolicy(ScrollArea::SHOW_ALWAYS);
- tab = new SkillTab(this, setName, listbox);
- break;
- }
- case SkillSetType::Rectangle:
- {
- SkillRectangleListBox *const listbox =
- new SkillRectangleListBox(this,
- model);
- listbox->setActionEventId("sel");
- listbox->addActionListener(this);
- scroll = new ScrollArea(this,
- listbox,
- Opaque_false);
- scroll->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
- scroll->setVerticalScrollPolicy(ScrollArea::SHOW_ALWAYS);
- tab = new SkillTab(this, setName, listbox);
- break;
- }
- default:
- reportAlways("Unsupported skillset type: %s",
- setTypeStr.c_str());
- return;
- }
- if (mDefaultModel == nullptr)
- {
- mDefaultModel = model;
- mDefaultTab = tab;
- }
-
- mDeleteTabs.push_back(tab);
- if (alwaysVisible == true)
- tab->setVisible(Visible_true);
- else
- tab->setVisible(Visible_false);
- mTabs->addTab(tab, scroll);
-
- for_each_xml_child_node(node, set)
- {
- if (xmlNameEqual(node, "skill"))
- {
- SkillInfo *const skill = loadSkill(node, model);
- if (skill == nullptr)
- continue;
- if (skill->alwaysVisible == Visible_true)
- alwaysVisible = true;
- skill->tab = tab;
- for_each_xml_child_node(levelNode, node)
- {
- if (!xmlNameEqual(levelNode, "level"))
- continue;
- loadSkillData(node, skill);
- }
- }
- }
-
- model->updateVisibilities();
- }
- }
-}
-
-SkillInfo *SkillDialog::loadSkill(XmlNodeConstPtr node,
- SkillModel *const model)
-{
- int id = XML::getIntProperty(node, "id", -1, -1, 1000000);
- if (id == -1)
- {
- id = XML::getIntProperty(node, "var", -1, -1, 100000);
- if (id == -1)
- return nullptr;
- id += SKILL_VAR_MIN_ID;
- }
-
- SkillInfo *skill = getSkill(id);
- if (skill == nullptr)
- {
- std::string name = XML::langProperty(node, "name",
- // TRANSLATORS: skills dialog. skill id
- strprintf(_("Skill %d"), id));
-
- skill = new SkillInfo;
- skill->id = CAST_U32(id);
- skill->modifiable = Modifiable_false;
- skill->model = model;
- skill->update();
- skill->useButton = XML::getProperty(
- // TRANSLATORS: skills dialog button
- node, "useButton", _("Use"));
- skill->owner = parseOwner(XML::getProperty(
- node, "owner", "player"));
- skill->errorText = XML::getProperty(
- node, "errorText", name);
- skill->alwaysVisible = fromBool(XML::getBoolProperty(
- node, "alwaysVisible", false), Visible);
- skill->castingAction = XML::getProperty(node,
- "castingAction", SpriteAction::CAST);
- skill->castingRideAction = XML::getProperty(node,
- "castingRideAction", SpriteAction::CASTRIDE);
- skill->castingSkyAction = XML::getProperty(node,
- "castingSkyAction", SpriteAction::CASTSKY);
- skill->castingWaterAction = XML::getProperty(node,
- "castingWaterAction", SpriteAction::CASTWATER);
- skill->useTextParameter = XML::getBoolProperty(
- node, "useTextParameter", false);
- skill->x = XML::getProperty(node,
- "x", 0);
- skill->y = XML::getProperty(node,
- "y", 0);
- skill->visible = skill->alwaysVisible;
- model->addSkill(skill);
- mSkills[id] = skill;
- }
-
- loadSkillData(node, skill);
- return skill;
-}
-
-void SkillDialog::loadSkillData(XmlNodeConstPtr node,
- SkillInfo *const skill)
-{
- if (skill == nullptr)
- return;
- const int level = (skill->alwaysVisible == Visible_true) ?
- 0 : XML::getProperty(node, "level", 0);
- SkillData *data = skill->getData(level);
- if (data == nullptr)
- data = new SkillData;
-
- const std::string name = XML::langProperty(node, "name",
- // TRANSLATORS: skills dialog. skill id
- strprintf(_("Skill %u"), skill->id));
- data->name = name;
- const std::string icon = XML::getProperty(node, "icon", "");
- if (icon.empty())
- {
- data->setIcon(paths.getStringValue("missingSkillIcon"));
- data->haveIcon = false;
- }
- else
- {
- data->setIcon(icon);
- data->haveIcon = true;
- }
- if (skill->id < SKILL_VAR_MIN_ID)
- {
- data->dispName = strprintf("%s, %u",
- name.c_str(),
- skill->id);
- }
- else
- {
- data->dispName = strprintf("%s, (%u)",
- name.c_str(),
- skill->id - SKILL_VAR_MIN_ID);
- }
- data->shortName = XML::langProperty(node,
- "shortName", name.substr(0, 3));
- data->description = XML::langProperty(
- node, "description", "");
-
- MissileInfo &missile = data->missile;
- missile.particle = XML::getProperty(
- node, "missile-particle", "");
- missile.z = XML::getFloatProperty(
- node, "missile-z", 32.0f);
- missile.lifeTime = XML::getProperty(
- node, "missile-lifetime", 500);
- missile.speed = XML::getFloatProperty(
- node, "missile-speed", 7.0f);
- missile.dieDistance = XML::getFloatProperty(
- node, "missile-diedistance", 8.0f);
-
- MissileInfo &castingMissile = data->castingMissile;
- castingMissile.particle = XML::getProperty(
- node, "castingMissile-particle", "");
- castingMissile.z = XML::getFloatProperty(
- node, "castingMissile-z", 32.0f);
- castingMissile.lifeTime = XML::getProperty(
- node, "castingMissile-lifetime", 500);
- castingMissile.speed = XML::getFloatProperty(
- node, "castingMissile-speed", 7.0f);
- castingMissile.dieDistance = XML::getFloatProperty(
- node, "castingMissile-diedistance", 8.0f);
-
- data->castingAnimation = XML::getProperty(
- node,
- "castingAnimation",
- paths.getStringValue("skillCastingAnimation"));
-
- data->soundHit.sound = XML::getProperty(
- node, "soundHit", "");
- data->soundHit.delay = XML::getProperty(
- node, "soundHitDelay", 0);
- data->soundMiss.sound = XML::getProperty(
- node, "soundMiss", "");
- data->soundMiss.delay = XML::getProperty(
- node, "soundMissDelay", 0);
- data->invokeCmd = XML::getProperty(
- node, "invokeCmd", "");
- data->updateEffectId = XML::getProperty(
- node, "levelUpEffectId", -1);
- data->removeEffectId = XML::getProperty(
- node, "removeEffectId", -1);
- data->hitEffectId = XML::getProperty(
- node, "hitEffectId", -1);
- data->missEffectId = XML::getProperty(
- node, "missEffectId", -1);
- data->castingSrcEffectId = XML::getProperty(
- node, "castingSrcEffectId", -1);
- data->castingDstEffectId = XML::getProperty(
- node, "castingDstEffectId", -1);
- data->srcEffectId = XML::getProperty(
- node, "srcEffectId", -1);
- data->dstEffectId = XML::getProperty(
- node, "dstEffectId", -1);
- data->castingGroundEffectId = XML::getProperty(
- node, "castingGroundEffectId", -1);
- data->autoTab = XML::getBoolProperty(
- node, "autoTab", true);
-
- skill->addData(level, data);
-}
-
-void SkillDialog::removeSkill(const int id)
-{
- const SkillMap::const_iterator it = mSkills.find(id);
-
- if (it != mSkills.end())
- {
- SkillInfo *const info = it->second;
- if (info != nullptr)
- {
- info->level = 0;
- info->update();
- PlayerInfo::setSkillLevel(id, 0);
- if (info->alwaysVisible == Visible_false)
- info->visible = Visible_false;
- }
- }
-}
-
-bool SkillDialog::updateSkill(const int id,
- const int range,
- const Modifiable modifiable,
- const SkillType::SkillType type,
- const int sp)
-{
- const SkillMap::const_iterator it = mSkills.find(id);
-
- if (it != mSkills.end())
- {
- SkillInfo *const info = it->second;
- if (info != nullptr)
- {
- info->modifiable = modifiable;
- info->range = range;
- info->type = type;
- info->sp = sp;
- info->update();
- if (info->tab != nullptr)
- {
- info->tab->setVisible(Visible_true);
- mTabs->adjustTabPositions();
- mTabs->setSelectedTabDefault();
- }
- }
- return true;
- }
- return false;
-}
-
-std::string SkillDialog::getDefaultSkillIcon(const SkillType::SkillType type)
-{
- std::string icon;
- switch (type)
- {
- case SkillType::Attack:
- icon = paths.getStringValue("attackSkillIcon");
- break;
- case SkillType::Ground:
- icon = paths.getStringValue("groundSkillIcon");
- break;
- case SkillType::Self:
- icon = paths.getStringValue("selfSkillIcon");
- break;
- case SkillType::Unused:
- icon = paths.getStringValue("unusedSkillIcon");
- break;
- case SkillType::Support:
- icon = paths.getStringValue("supportSkillIcon");
- break;
- case SkillType::TargetTrap:
- icon = paths.getStringValue("trapSkillIcon");
- break;
- case SkillType::Unknown:
- icon = paths.getStringValue("unknownSkillIcon");
- break;
- default:
- break;
- }
- return icon;
-}
-
-void SkillDialog::addSkill(const SkillOwner::Type owner,
- const int id,
- const std::string &name,
- const int level,
- const int range,
- const Modifiable modifiable,
- const SkillType::SkillType type,
- const int sp)
-{
- if (mDefaultModel != nullptr)
- {
- SkillInfo *const skill = new SkillInfo;
- skill->id = CAST_U32(id);
- skill->type = type;
- skill->owner = owner;
- SkillData *const data = skill->data;
- if (name.empty())
- {
- data->name = "Unknown skill Id: " + toString(id);
- data->dispName = data->name;
- }
- else
- {
- data->name = name;
- data->dispName = strprintf("%s, %u", name.c_str(), skill->id);
- }
- data->description.clear();
- const std::string icon = getDefaultSkillIcon(type);
- if (icon.empty())
- {
- data->setIcon(paths.getStringValue("missingSkillIcon"));
- data->haveIcon = false;
- }
- else
- {
- data->setIcon(icon);
- data->haveIcon = true;
- }
- data->autoTab = settings.unknownSkillsAutoTab;
- data->shortName = toString(skill->id);
- skill->modifiable = modifiable;
- skill->visible = Visible_false;
- skill->alwaysVisible = Visible_false;
- skill->model = mDefaultModel;
- skill->level = level;
- // TRANSLATORS: skills dialog. skill level
- skill->skillLevel = strprintf(_("Lvl: %d"), level);
- skill->range = range;
- skill->sp = sp;
- skill->update();
- // TRANSLATORS: skills dialog button
- skill->useButton = _("Use");
- // TRANSLATORS: skill error message
- skill->errorText = strprintf(_("Failed skill: %s"), name.c_str());
- skill->tab = mDefaultTab;
- mDefaultModel->addSkill(skill);
- mDefaultTab->setVisible(Visible_true);
- mTabs->adjustTabPositions();
- mTabs->setSelectedTabDefault();
-
- mSkills[id] = skill;
- mDefaultModel->updateVisibilities();
- }
-}
-
-SkillInfo* SkillDialog::getSkill(const int id) const
-{
- SkillMap::const_iterator it = mSkills.find(id);
- if (it != mSkills.end())
- return (*it).second;
- return nullptr;
-}
-
-SkillInfo* SkillDialog::getSkillByItem(const int itemId) const
-{
- SkillMap::const_iterator it = mSkills.find(itemId - SKILL_MIN_ID);
- if (it != mSkills.end())
- return (*it).second;
- return nullptr;
-}
-
-void SkillDialog::setSkillDuration(const SkillOwner::Type owner,
- const int id,
- const int duration)
-{
- SkillMap::const_iterator it = mSkills.find(id);
- SkillInfo *info = nullptr;
- if (it == mSkills.end())
- {
- addSkill(owner, id, "", 0, 0, Modifiable_false, SkillType::Unknown, 0);
- it = mSkills.find(id);
- }
- if (it != mSkills.end())
- {
- info = (*it).second;
- }
- if (info != nullptr)
- {
- info->duration = duration;
- info->durationTime = tick_time;
- addSkillDuration(info);
- }
-}
-
-void SkillDialog::widgetResized(const Event &event)
-{
- Window::widgetResized(event);
-
- if (mTabs != nullptr)
- mTabs->adjustSize();
-}
-
-void SkillDialog::useItem(const int itemId,
- const AutoTarget autoTarget,
- const int level,
- const std::string &data) const
-{
- const std::map<int, SkillInfo*>::const_iterator
- it = mSkills.find(itemId - SKILL_MIN_ID);
- if (it == mSkills.end())
- return;
-
- const SkillInfo *const info = (*it).second;
- CastTypeT castType = CastType::Default;
- int offsetX = 0;
- int offsetY = 0;
-
- if (!data.empty())
- {
- STD_VECTOR<int> vect;
- splitToIntVector(vect, data, ' ');
- const size_t sz = vect.size();
- if (sz > 0)
- castType = static_cast<CastTypeT>(vect[0]);
- if (sz > 2)
- {
- offsetX = vect[1];
- offsetY = vect[2];
- }
- }
- useSkill(info,
- autoTarget,
- level,
- false,
- std::string(),
- castType,
- offsetX,
- offsetY);
-}
-
-void SkillDialog::updateTabSelection()
-{
- const SkillTab *const tab = static_cast<SkillTab*>(
- mTabs->getSelectedTab());
- if (tab != nullptr)
- {
- if (const SkillInfo *const info = tab->getSelectedInfo())
- {
- mUseButton->setEnabled(info->range > 0);
- mIncreaseButton->setEnabled(info->id < SKILL_VAR_MIN_ID);
- mUseButton->setCaption(info->useButton);
- }
- else
- {
- mUseButton->setEnabled(false);
- // TRANSLATORS: inventory button
- mUseButton->setCaption(_("Use"));
- }
- }
-}
-
-void SkillDialog::updateQuest(const int var,
- const int val1,
- const int val2 A_UNUSED,
- const int val3 A_UNUSED,
- const int time1 A_UNUSED)
-{
- const int id = var + SKILL_VAR_MIN_ID;
- const SkillMap::const_iterator it = mSkills.find(id);
-
- if (it != mSkills.end())
- {
- SkillInfo *const info = it->second;
- if (info != nullptr)
- {
- PlayerInfo::setSkillLevel(id, val1);
- info->level = val1;
- info->update();
- }
- }
-}
-
-SkillData *SkillDialog::getSkillData(const int id) const
-{
- const SkillMap::const_iterator it = mSkills.find(id);
- if (it != mSkills.end())
- {
- SkillInfo *const info = it->second;
- if (info != nullptr)
- return info->data;
- }
- return nullptr;
-}
-
-SkillData *SkillDialog::getSkillDataByLevel(const int id,
- const int level) const
-{
- const SkillMap::const_iterator it = mSkills.find(id);
- if (it != mSkills.end())
- {
- SkillInfo *const info = it->second;
- if (info != nullptr)
- return info->getData1(level);
- }
- return nullptr;
-}
-
-void SkillDialog::playUpdateEffect(const int id) const
-{
- if (effectManager == nullptr)
- return;
- const SkillData *const data = getSkillData(id);
- if (data == nullptr)
- return;
- effectManager->triggerDefault(data->updateEffectId,
- localPlayer,
- paths.getIntValue("skillLevelUpEffectId"));
-}
-
-void SkillDialog::playRemoveEffect(const int id) const
-{
- if (effectManager == nullptr)
- return;
- const SkillData *const data = getSkillData(id);
- if (data == nullptr)
- return;
- effectManager->triggerDefault(data->removeEffectId,
- localPlayer,
- paths.getIntValue("skillRemoveEffectId"));
-}
-
-void SkillDialog::playCastingDstTileEffect(const int id,
- const int level,
- const int x,
- const int y,
- const int delay) const
-{
- if (effectManager == nullptr)
- return;
- SkillData *const data = getSkillDataByLevel(id, level);
- if (data == nullptr)
- return;
- effectManager->triggerDefault(data->castingGroundEffectId,
- x * 32,
- y * 32,
- cur_time + delay / 1000, // end time in seconds
- paths.getIntValue("skillCastingGroundEffectId"));
-}
-
-void SkillDialog::useSkill(const int skillId,
- const AutoTarget autoTarget,
- int level,
- const bool withText,
- const std::string &text,
- CastTypeT castType,
- const int offsetX,
- const int offsetY)
-{
- SkillInfo *const info = skillDialog->getSkill(skillId);
- if (info == nullptr)
- return;
- if (castType == CastType::Default)
- castType = info->customCastType;
- useSkill(info,
- autoTarget,
- level,
- withText,
- text,
- castType,
- offsetX,
- offsetY);
-}
-
-void SkillDialog::useSkill(const SkillInfo *const info,
- const AutoTarget autoTarget,
- int level,
- const bool withText,
- const std::string &text,
- const CastTypeT castType,
- const int offsetX,
- const int offsetY)
-{
- if ((info == nullptr) || (localPlayer == nullptr))
- return;
- if (level == 0)
- level = info->level;
-
- const SkillData *data = info->getData1(level);
- if (data != nullptr)
- {
- const std::string cmd = data->invokeCmd;
- if (!cmd.empty())
- SpellManager::invokeCommand(cmd, localPlayer->getTarget());
- }
- switch (castType)
- {
- default:
- case CastType::Default:
- useSkillDefault(info,
- autoTarget,
- level,
- withText,
- text,
- offsetX,
- offsetY);
- break;
- case CastType::Target:
- {
- const Being *const being = localPlayer->getTarget();
- useSkillTarget(info,
- autoTarget,
- level,
- withText,
- text,
- being,
- offsetX,
- offsetY);
- break;
- }
- case CastType::Position:
- {
- int x = 0;
- int y = 0;
- viewport->getMouseTile(x, y);
- useSkillPosition(info,
- level,
- withText,
- text,
- x,
- y,
- offsetX,
- offsetY);
- break;
- }
- case CastType::Self:
- // +++ probably need call useSkillSelf
- useSkillTarget(info,
- autoTarget,
- level,
- withText,
- text,
- localPlayer,
- offsetX,
- offsetY);
- break;
- }
-}
-
-void SkillDialog::useSkillTarget(const SkillInfo *const info,
- const AutoTarget autoTarget,
- int level,
- const bool withText,
- const std::string &text,
- const Being *being,
- int offsetX,
- int offsetY)
-{
- SkillType::SkillType type = info->type;
- if ((type & SkillType::Attack) != 0)
- {
- if ((being == nullptr) && autoTarget == AutoTarget_true)
- {
- if (localPlayer != nullptr)
- {
- being = localPlayer->setNewTarget(ActorType::Monster,
- AllowSort_true);
- }
- }
- if (being != nullptr)
- {
- skillHandler->useBeing(info->id,
- level,
- being->getId());
- }
- }
- else if ((type & SkillType::Support) != 0)
- {
- if (being == nullptr)
- being = localPlayer;
- if (being != nullptr)
- {
- skillHandler->useBeing(info->id,
- level,
- being->getId());
- }
- }
- else if ((type & SkillType::Self) != 0)
- {
- skillHandler->useBeing(info->id,
- level,
- localPlayer->getId());
- }
- else if ((type & SkillType::Ground) != 0)
- {
- if (being == nullptr)
- return;
- being->fixDirectionOffsets(offsetX, offsetY);
- const int x = being->getTileX() + offsetX;
- const int y = being->getTileY() + offsetY;
- if (info->useTextParameter)
- {
- if (withText)
- {
- skillHandler->usePos(info->id,
- level,
- x, y,
- text);
- }
- else
- {
- const SkillData *data = info->getData1(level);
- textSkillListener.setSkill(info->id,
- x,
- y,
- level);
- TextDialog *const dialog = CREATEWIDGETR(TextDialog,
- // TRANSLATORS: text skill dialog header
- strprintf(_("Add text to skill %s"),
- data->name.c_str()),
- // TRANSLATORS: text skill dialog field
- _("Text: "));
- dialog->setModal(Modal_true);
- textSkillListener.setDialog(dialog);
- dialog->setActionEventId("ok");
- dialog->addActionListener(&textSkillListener);
- }
- }
- else
- {
- skillHandler->usePos(info->id,
- level,
- x, y);
- }
- }
- else if ((type & SkillType::TargetTrap) != 0)
- {
- // for now unused
- }
- else if (type == SkillType::Unknown ||
- type == SkillType::Unused)
- {
- // unknown / unused
- }
- else
- {
- reportAlways("Unsupported skill type: %d", type);
- }
-}
-
-void SkillDialog::useSkillPosition(const SkillInfo *const info,
- int level,
- const bool withText,
- const std::string &text,
- const int x,
- const int y,
- int offsetX,
- int offsetY)
-{
- SkillType::SkillType type = info->type;
- if ((type & SkillType::Ground) != 0)
- {
- localPlayer->fixDirectionOffsets(offsetX, offsetY);
- if (info->useTextParameter)
- {
- if (withText)
- {
- skillHandler->usePos(info->id,
- level,
- x + offsetX,
- y + offsetY,
- text);
- }
- else
- {
- const SkillData *data = info->getData1(level);
- textSkillListener.setSkill(info->id,
- x + offsetX,
- y + offsetY,
- level);
- TextDialog *const dialog = CREATEWIDGETR(TextDialog,
- // TRANSLATORS: text skill dialog header
- strprintf(_("Add text to skill %s"),
- data->name.c_str()),
- // TRANSLATORS: text skill dialog field
- _("Text: "));
- dialog->setModal(Modal_true);
- textSkillListener.setDialog(dialog);
- dialog->setActionEventId("ok");
- dialog->addActionListener(&textSkillListener);
- }
- }
- else
- {
- skillHandler->usePos(info->id,
- level,
- x + offsetX,
- y + offsetY);
- }
- }
- else if ((type & SkillType::Support) != 0)
- {
- // wrong type
- skillHandler->useBeing(info->id,
- level,
- localPlayer->getId());
- }
- else if ((type & SkillType::Self) != 0)
- {
- skillHandler->useBeing(info->id,
- level,
- localPlayer->getId());
- }
- else if ((type & SkillType::Attack) != 0)
- {
- // do nothing
- // +++ probably need select some target on x,y position?
- }
- else if ((type & SkillType::TargetTrap) != 0)
- {
- // for now unused
- }
- else if (type == SkillType::Unknown ||
- type == SkillType::Unused)
- {
- // unknown / unused
- }
- else
- {
- reportAlways("Unsupported skill type: %d", type);
- }
-}
-
-void SkillDialog::useSkillDefault(const SkillInfo *const info,
- const AutoTarget autoTarget,
- int level,
- const bool withText,
- const std::string &text,
- int offsetX,
- int offsetY)
-{
- SkillType::SkillType type = info->type;
- if ((type & SkillType::Attack) != 0)
- {
- const Being *being = localPlayer->getTarget();
- if ((being == nullptr) && autoTarget == AutoTarget_true)
- {
- being = localPlayer->setNewTarget(ActorType::Monster,
- AllowSort_true);
- }
- if (being != nullptr)
- {
- skillHandler->useBeing(info->id,
- level,
- being->getId());
- }
- }
- else if ((type & SkillType::Support) != 0)
- {
- const Being *being = localPlayer->getTarget();
- if (being == nullptr)
- being = localPlayer;
- if (being != nullptr)
- {
- skillHandler->useBeing(info->id,
- level,
- being->getId());
- }
- }
- else if ((type & SkillType::Self) != 0)
- {
- skillHandler->useBeing(info->id,
- level,
- localPlayer->getId());
- }
- else if ((type & SkillType::Ground) != 0)
- {
- int x = 0;
- int y = 0;
- viewport->getMouseTile(x, y);
- localPlayer->fixDirectionOffsets(offsetX, offsetY);
- x += offsetX;
- y += offsetY;
- if (info->useTextParameter)
- {
- if (withText)
- {
- skillHandler->usePos(info->id,
- level,
- x, y,
- text);
- }
- else
- {
- const SkillData *data = info->getData1(level);
- textSkillListener.setSkill(info->id,
- x,
- y,
- level);
- TextDialog *const dialog = CREATEWIDGETR(TextDialog,
- // TRANSLATORS: text skill dialog header
- strprintf(_("Add text to skill %s"),
- data->name.c_str()),
- // TRANSLATORS: text skill dialog field
- _("Text: "));
- dialog->setModal(Modal_true);
- textSkillListener.setDialog(dialog);
- dialog->setActionEventId("ok");
- dialog->addActionListener(&textSkillListener);
- }
- }
- else
- {
- skillHandler->usePos(info->id,
- level,
- x, y);
- }
- }
- else if ((type & SkillType::TargetTrap) != 0)
- {
- // for now unused
- }
- else if (type == SkillType::Unknown ||
- type == SkillType::Unused)
- {
- // unknown / unused
- }
- else
- {
- reportAlways("Unsupported skill type: %d", type);
- }
-}
-
-void SkillDialog::addSkillDuration(SkillInfo *const skill)
-{
- if (skill == nullptr)
- return;
-
- FOR_EACH (STD_VECTOR<SkillInfo*>::const_iterator, it, mDurations)
- {
- if ((*it)->id == skill->id)
- return;
- }
- mDurations.push_back(skill);
-}
-
-void SkillDialog::slowLogic()
-{
- FOR_EACH_SAFE (STD_VECTOR<SkillInfo*>::iterator, it, mDurations)
- {
- SkillInfo *const skill = *it;
- if (skill != nullptr)
- {
- const int time = get_elapsed_time(skill->durationTime);
- if (time >= skill->duration)
- {
- it = mDurations.erase(it);
- skill->cooldown = 0;
- skill->duration = 0;
- skill->durationTime = 0;
- if (it == mDurations.end())
- return;
- if (it != mDurations.begin())
- -- it;
- }
- else if (time != 0)
- {
- skill->cooldown = skill->duration * 100 / time;
- }
- }
- }
-}
-
-void SkillDialog::selectSkillLevel(const int skillId,
- const int level)
-{
- SkillInfo *const info = getSkill(skillId);
- if (info == nullptr)
- return;
- if (level > info->level)
- info->customSelectedLevel = info->level;
- else
- info->customSelectedLevel = level;
- info->update();
-}
-
-void SkillDialog::selectSkillCastType(const int skillId,
- const CastTypeT type)
-{
- SkillInfo *const info = getSkill(skillId);
- if (info == nullptr)
- return;
- info->customCastType = type;
- info->update();
-}
-
-void SkillDialog::setSkillOffsetX(const int skillId,
- const int offset)
-{
- SkillInfo *const info = getSkill(skillId);
- if (info == nullptr)
- return;
- info->customOffsetX = offset;
- info->update();
-}
-
-void SkillDialog::setSkillOffsetY(const int skillId,
- const int offset)
-{
- SkillInfo *const info = getSkill(skillId);
- if (info == nullptr)
- return;
- info->customOffsetY = offset;
- info->update();
-}
diff --git a/src/gui/windows/skilldialog.h b/src/gui/windows/skilldialog.h
deleted file mode 100644
index 2273125f0..000000000
--- a/src/gui/windows/skilldialog.h
+++ /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/>.
- */
-
-#ifndef GUI_WINDOWS_SKILLDIALOG_H
-#define GUI_WINDOWS_SKILLDIALOG_H
-
-#include "gui/widgets/window.h"
-
-#include "enums/simpletypes/autotarget.h"
-#include "enums/simpletypes/modifiable.h"
-
-#include "enums/resources/skill/casttype.h"
-#include "enums/resources/skill/skillowner.h"
-#include "enums/resources/skill/skilltype.h"
-
-#include "listeners/actionlistener.h"
-
-#include "utils/xml.h"
-
-class Being;
-class Button;
-class Label;
-class SkillModel;
-class SkillTab;
-class Tab;
-class TabbedArea;
-
-struct SkillData;
-struct SkillInfo;
-
-/**
- * The skill dialog.
- *
- * \ingroup Interface
- */
-class SkillDialog final : public Window,
- public ActionListener
-{
- public:
- SkillDialog();
-
- A_DELETE_COPY(SkillDialog)
-
- ~SkillDialog();
-
- void postInit() override final;
-
- /**
- * Called when receiving actions from widget.
- */
- void action(const ActionEvent &event) override final;
-
- /**
- * Update the given skill's display
- */
- std::string update(const int id);
-
- /**
- * Update other parts of the display
- */
- void update();
-
- void updateModels();
-
- void loadXmlFile(const std::string &fileName,
- const SkipError skipError);
-
- void clearSkills();
-
- void hideSkills(const SkillOwner::Type owner);
-
- void loadSkills();
-
- bool updateSkill(const int id,
- const int range,
- const Modifiable modifiable,
- const SkillType::SkillType type,
- const int sp);
-
- void addSkill(const SkillOwner::Type owner,
- const int id,
- const std::string &name,
- const int level,
- const int range,
- const Modifiable modifiable,
- const SkillType::SkillType type,
- const int sp);
-
- SkillInfo* getSkill(const int id) const A_WARN_UNUSED;
-
- SkillInfo* getSkillByItem(const int itemId) const A_WARN_UNUSED;
-
- void setSkillDuration(const SkillOwner::Type owner,
- const int id,
- const int duration);
-
- bool hasSkills() const noexcept2 A_WARN_UNUSED
- { return !mSkills.empty(); }
-
- void widgetResized(const Event &event) override final;
-
- void useItem(const int itemId,
- const AutoTarget autoTarget,
- const int level,
- const std::string &data) const;
-
- void updateTabSelection();
-
- void updateQuest(const int var,
- const int val1,
- const int val2,
- const int val3,
- const int time1);
-
- void playUpdateEffect(const int id) const;
-
- void playRemoveEffect(const int id) const;
-
- void playCastingDstTileEffect(const int id,
- const int level,
- const int x,
- const int y,
- const int delay) const;
-
- void slowLogic();
-
- void removeSkill(const int id);
-
- static void useSkill(const int skillId,
- const AutoTarget autoTarget,
- int level,
- const bool withText,
- const std::string &text,
- CastTypeT castType,
- const int offsetX,
- const int offsetY);
-
- static void useSkill(const SkillInfo *const info,
- const AutoTarget autoTarget,
- int level,
- const bool withText,
- const std::string &text,
- const CastTypeT castType,
- const int offsetX,
- const int offsetY);
-
- SkillData *getSkillData(const int id) const;
-
- SkillData *getSkillDataByLevel(const int id,
- const int level) const;
-
- void selectSkillLevel(const int skillId,
- const int level);
-
- void selectSkillCastType(const int skillId,
- const CastTypeT type);
-
- void setSkillOffsetX(const int skillId,
- const int offset);
-
- void setSkillOffsetY(const int skillId,
- const int offset);
-
- private:
- static void useSkillDefault(const SkillInfo *const info,
- const AutoTarget autoTarget,
- int level,
- const bool withText,
- const std::string &text,
- int offsetX,
- int offsetY);
-
- static void useSkillTarget(const SkillInfo *const info,
- const AutoTarget autoTarget,
- int level,
- const bool withText,
- const std::string &text,
- const Being *being,
- int offsetX,
- int offsetY);
-
- static void useSkillPosition(const SkillInfo *const info,
- int level,
- const bool withText,
- const std::string &text,
- const int x,
- const int y,
- int offsetX,
- int offsetY);
-
- static std::string getDefaultSkillIcon(const SkillType::SkillType
- type);
-
- void addSkillDuration(SkillInfo *const skill);
-
- SkillInfo *loadSkill(XmlNodeConstPtr node,
- SkillModel *const model);
-
- void loadSkillData(XmlNodeConstPtr node,
- SkillInfo *const skill);
-
- void addDefaultTab();
-
- typedef std::map<int, SkillInfo*> SkillMap;
- SkillMap mSkills;
- STD_VECTOR<SkillInfo*> mDurations;
- TabbedArea *mTabs A_NONNULLPOINTER;
- std::list<Tab*> mDeleteTabs;
- Label *mPointsLabel A_NONNULLPOINTER;
- Button *mUseButton A_NONNULLPOINTER;
- Button *mIncreaseButton A_NONNULLPOINTER;
- SkillModel *mDefaultModel;
- SkillTab *mDefaultTab;
-};
-
-extern SkillDialog *skillDialog;
-
-#endif // GUI_WINDOWS_SKILLDIALOG_H
diff --git a/src/gui/windows/socialwindow.cpp b/src/gui/windows/socialwindow.cpp
deleted file mode 100644
index 174762100..000000000
--- a/src/gui/windows/socialwindow.cpp
+++ /dev/null
@@ -1,659 +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 "gui/windows/socialwindow.h"
-
-#include "gui/popups/popupmenu.h"
-
-#include "gui/windows/setupwindow.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/label.h"
-#include "gui/widgets/tabbedarea.h"
-
-#include "gui/widgets/tabs/socialattacktab.h"
-#include "gui/widgets/tabs/socialfriendstab.h"
-#include "gui/widgets/tabs/socialguildtab.h"
-#include "gui/widgets/tabs/socialnavigationtab.h"
-#include "gui/widgets/tabs/socialpartytab.h"
-#include "gui/widgets/tabs/socialpickuptab.h"
-#include "gui/widgets/tabs/socialplayerstab.h"
-
-#ifdef TMWA_SUPPORT
-#include "gui/widgets/tabs/socialguildtab2.h"
-
-#include "net/tmwa/guildmanager.h"
-#endif // TMWA_SUPPORT
-
-#include "debug.h"
-
-SocialWindow *socialWindow = nullptr;
-
-SocialWindow::SocialWindow() :
- // TRANSLATORS: social window name
- Window(_("Social"), Modal_false, nullptr, "social.xml"),
- ActionListener(),
- PlayerRelationsListener(),
- mGuildInvited(0),
- mGuildAcceptDialog(nullptr),
- mGuildCreateDialog(nullptr),
- mPartyInviter(),
- mGuilds(),
- mParties(),
- mPartyAcceptDialog(nullptr),
- mAttackFilter(nullptr),
- mPickupFilter(nullptr),
- // TRANSLATORS: here P is title for visible players tab in social window
- mPlayers(new SocialPlayersTab(this, _("P"),
- fromBool(getOptionBool("showtabbackground"), Opaque))),
- mNavigation(new SocialNavigationTab(this,
- fromBool(getOptionBool("showtabbackground"), Opaque))),
- // TRANSLATORS: here F is title for friends tab in social window
- mFriends(new SocialFriendsTab(this, _("F"),
- fromBool(getOptionBool("showtabbackground"), Opaque))),
- // TRANSLATORS: social window button
- mMenuButton(new Button(this, _("Menu"), "menu", this)),
- mCountLabel(new Label(this, "1000 / 1000")),
- mTabs(CREATEWIDGETR(TabbedArea, this)),
- mMap(nullptr),
- mLastUpdateTime(0),
- mPartyId(0),
- mNeedUpdate(false),
- mProcessedPortals(false)
-{
-}
-
-void SocialWindow::postInit()
-{
- Window::postInit();
- setWindowName("Social");
- setVisible(Visible_false);
- setSaveVisible(true);
- setResizable(true);
- setSaveVisible(true);
- setCloseButton(true);
- setStickyButtonLock(true);
-
- setMinWidth(120);
- setMinHeight(55);
- setDefaultSize(590, 200, 180, 300);
- if (setupWindow != nullptr)
- setupWindow->registerWindowForReset(this);
-
- place(0, 0, mMenuButton);
- place(0, 1, mCountLabel);
- place(0, 2, mTabs, 2, 4);
-
- widgetResized(Event(nullptr));
-
- loadWindowState();
-
- mTabs->addTab(mPlayers, mPlayers->mScroll);
- mTabs->addTab(mFriends, mFriends->mScroll);
- mTabs->addTab(mNavigation, mNavigation->mScroll);
- mTabs->setSelectable(false);
- mTabs->getTabContainer()->setSelectable(false);
- mTabs->getWidgetContainer()->setSelectable(false);
-
- if (config.getBoolValue("enableAttackFilter"))
- {
- mAttackFilter = new SocialAttackTab(this,
- fromBool(getOptionBool("showtabbackground"), Opaque));
- mTabs->addTab(mAttackFilter, mAttackFilter->mScroll);
- }
- else
- {
- mAttackFilter = nullptr;
- }
-
- if (config.getBoolValue("enablePickupFilter"))
- {
- mPickupFilter = new SocialPickupTab(this,
- fromBool(getOptionBool("showtabbackground"), Opaque));
- mTabs->addTab(mPickupFilter, mPickupFilter->mScroll);
- }
- else
- {
- mPickupFilter = nullptr;
- }
-
- if ((localPlayer != nullptr) && (localPlayer->getParty() != nullptr))
- addTab(localPlayer->getParty());
-
- if ((localPlayer != nullptr) && (localPlayer->getGuild() != nullptr))
- addTab(localPlayer->getGuild());
-
- enableVisibleSound(true);
- updateButtons();
- playerRelations.addListener(this);
-}
-
-SocialWindow::~SocialWindow()
-{
- playerRelations.removeListener(this);
- if (mGuildAcceptDialog != nullptr)
- {
- mGuildAcceptDialog->close();
- mGuildAcceptDialog->scheduleDelete();
- mGuildAcceptDialog = nullptr;
-
- mGuildInvited = 0;
- }
-
- if (mPartyAcceptDialog != nullptr)
- {
- mPartyAcceptDialog->close();
- mPartyAcceptDialog->scheduleDelete();
- mPartyAcceptDialog = nullptr;
-
- mPartyInviter.clear();
- }
- delete2(mPlayers);
- delete2(mNavigation);
- delete2(mAttackFilter);
- delete2(mPickupFilter);
- delete2(mFriends);
- FOR_EACH (GuildMap::iterator, it, mGuilds)
- {
- delete (*it).second;
- }
- mGuilds.clear();
- FOR_EACH (PartyMap::iterator, it, mParties)
- {
- delete (*it).second;
- }
- mParties.clear();
-}
-
-bool SocialWindow::addTab(Guild *const guild)
-{
- if (guild == nullptr)
- return false;
-
- if (mGuilds.find(guild) != mGuilds.end())
- return false;
-
- SocialTab *tab = nullptr;
- if (guild->getServerGuild())
- {
- tab = new SocialGuildTab(this, guild,
- fromBool(getOptionBool("showtabbackground"), Opaque));
- }
-#ifdef TMWA_SUPPORT
- else
- {
- tab = new SocialGuildTab2(this, guild,
- fromBool(getOptionBool("showtabbackground"), Opaque));
- }
-#endif // TMWA_SUPPORT
-
- mGuilds[guild] = tab;
- mTabs->addTab(tab, tab->mScroll);
-
- updateButtons();
-
- return true;
-}
-
-bool SocialWindow::removeTab(Guild *const guild)
-{
- const GuildMap::iterator it = mGuilds.find(guild);
- if (it == mGuilds.end())
- return false;
-
- mTabs->removeTab(it->second);
- delete it->second;
- mGuilds.erase(it);
-
- updateButtons();
-
- return true;
-}
-
-bool SocialWindow::addTab(Party *const party)
-{
- if (party == nullptr)
- return false;
-
- if (mParties.find(party) != mParties.end())
- return false;
-
- SocialPartyTab *const tab = new SocialPartyTab(this, party,
- fromBool(getOptionBool("showtabbackground"), Opaque));
- mParties[party] = tab;
-
- mTabs->addTab(tab, tab->mScroll);
-
- updateButtons();
-
- return true;
-}
-
-bool SocialWindow::removeTab(Party *const party)
-{
- const PartyMap::iterator it = mParties.find(party);
- if (it == mParties.end())
- return false;
-
- mTabs->removeTab(it->second);
- delete it->second;
- mParties.erase(it);
-
- updateButtons();
-
- return true;
-}
-
-void SocialWindow::action(const ActionEvent &event)
-{
- const std::string &eventId = event.getId();
-
- if (event.getSource() == mPartyAcceptDialog)
- {
- if (eventId == "yes")
- {
- if (localChatTab != nullptr)
- {
- localChatTab->chatLog(
- // TRANSLATORS: chat message
- strprintf(_("Accepted party invite from %s."),
- mPartyInviter.c_str()),
- ChatMsgType::BY_SERVER);
- }
- partyHandler->inviteResponse(mPartyId, true);
- }
- else if (eventId == "no")
- {
- if (localChatTab != nullptr)
- {
- localChatTab->chatLog(
- // TRANSLATORS: chat message
- strprintf(_("Rejected party invite from %s."),
- mPartyInviter.c_str()),
- ChatMsgType::BY_SERVER);
- }
- partyHandler->inviteResponse(mPartyId, false);
- }
-
- mPartyInviter.clear();
- mPartyAcceptDialog = nullptr;
- }
- else if (event.getSource() == mGuildAcceptDialog)
- {
- if (eventId == "yes")
- {
- if (localChatTab != nullptr)
- {
- localChatTab->chatLog(
- // TRANSLATORS: chat message
- strprintf(_("Accepted guild invite from %s."),
- mPartyInviter.c_str()),
- ChatMsgType::BY_SERVER);
- }
-#ifdef TMWA_SUPPORT
- if (guildManager == nullptr || !GuildManager::getEnableGuildBot())
- guildHandler->inviteResponse(mGuildInvited, true);
- else
- GuildManager::inviteResponse(true);
-#else // TMWA_SUPPORT
-
- guildHandler->inviteResponse(mGuildInvited, true);
-#endif // TMWA_SUPPORT
- }
- else if (eventId == "no")
- {
- if (localChatTab != nullptr)
- {
- localChatTab->chatLog(
- // TRANSLATORS: chat message
- strprintf(_("Rejected guild invite from %s."),
- mPartyInviter.c_str()),
- ChatMsgType::BY_SERVER);
- }
-#ifdef TMWA_SUPPORT
- if (guildManager == nullptr || !GuildManager::getEnableGuildBot())
- guildHandler->inviteResponse(mGuildInvited, false);
- else
- GuildManager::inviteResponse(false);
-#else // TMWA_SUPPORT
-
- guildHandler->inviteResponse(mGuildInvited, false);
-#endif // TMWA_SUPPORT
- }
-
- mGuildInvited = 0;
- mGuildAcceptDialog = nullptr;
- }
- else if (eventId == "party")
- {
- popupMenu->showPartyPopup();
- }
- else if (eventId == "guild")
- {
- popupMenu->showGuildPopup();
- }
- else if (eventId == "attack")
- {
- popupMenu->showAttackPopup();
- }
- else if (eventId == "friends")
- {
- popupMenu->showFriendsPopup();
- }
- else if (eventId == "navigation")
- {
- popupMenu->showNavigationPopup();
- }
- else if (eventId == "pickup")
- {
- popupMenu->showPickupPopup();
- }
- else if (eventId == "players")
- {
- popupMenu->showPlayersPopup();
- }
-}
-
-void SocialWindow::showGuildInvite(const std::string &restrict guildName,
- const int guildId,
- const std::string &restrict inviterName)
-{
- // check there isnt already an invite showing
- if (mGuildInvited != 0)
- {
- if (localChatTab != nullptr)
- {
- // TRANSLATORS: chat message
- localChatTab->chatLog(_("Received guild request, but one already "
- "exists."),
- ChatMsgType::BY_SERVER);
- }
- return;
- }
-
- const std::string msg = strprintf(
- // TRANSLATORS: chat message
- _("%s has invited you to join the guild %s."),
- inviterName.c_str(), guildName.c_str());
-
- if (localChatTab != nullptr)
- localChatTab->chatLog(msg, ChatMsgType::BY_SERVER);
-
- CREATEWIDGETV(mGuildAcceptDialog, ConfirmDialog,
- // TRANSLATORS: guild invite message
- _("Accept Guild Invite"),
- msg,
- SOUND_REQUEST,
- false,
- Modal_false,
- this);
- mGuildAcceptDialog->addActionListener(this);
- mGuildInvited = guildId;
-}
-
-void SocialWindow::showPartyInvite(const std::string &restrict partyName,
- const std::string &restrict inviter,
- const int partyId)
-{
- // check there isnt already an invite showing
- if (!mPartyInviter.empty())
- {
- if (localChatTab != nullptr)
- {
- // TRANSLATORS: chat message
- localChatTab->chatLog(_("Received party request, but one already "
- "exists."),
- ChatMsgType::BY_SERVER);
- }
- return;
- }
-
- std::string msg;
- if (inviter.empty())
- {
- if (partyName.empty())
- {
- // TRANSLATORS: party invite message
- msg = _("You have been invited you to join a party.");
- }
- else
- {
- // TRANSLATORS: party invite message
- msg = strprintf(_("You have been invited to join the %s party."),
- partyName.c_str());
- }
- }
- else
- {
- if (partyName.empty())
- {
- // TRANSLATORS: party invite message
- msg = strprintf(_("%s has invited you to join their party."),
- inviter.c_str());
- }
- else
- {
- // TRANSLATORS: party invite message
- msg = strprintf(_("%s has invited you to join the %s party."),
- inviter.c_str(), partyName.c_str());
- }
- }
-
- if (localChatTab != nullptr)
- localChatTab->chatLog(msg, ChatMsgType::BY_SERVER);
-
- // show invite
- CREATEWIDGETV(mPartyAcceptDialog, ConfirmDialog,
- // TRANSLATORS: party invite message
- _("Accept Party Invite"),
- msg,
- SOUND_REQUEST,
- false,
- Modal_false,
- this);
- mPartyAcceptDialog->addActionListener(this);
- mPartyInviter = inviter;
- mPartyId = partyId;
-}
-
-void SocialWindow::updateActiveList()
-{
- mNeedUpdate = true;
-}
-
-void SocialWindow::slowLogic()
-{
- BLOCK_START("SocialWindow::slowLogic")
- const time_t nowTime = cur_time;
- if (mNeedUpdate && nowTime - mLastUpdateTime > 1)
- {
- mPlayers->updateList();
- mFriends->updateList();
- mNeedUpdate = false;
- mLastUpdateTime = nowTime;
- }
- else if (nowTime - mLastUpdateTime > 5)
- {
- mPlayers->updateList();
- mNeedUpdate = false;
- mLastUpdateTime = nowTime;
- }
- BLOCK_END("SocialWindow::slowLogic")
-}
-
-void SocialWindow::updateAvatar(const std::string &name)
-{
- mPlayers->updateAvatar(name);
-}
-
-void SocialWindow::resetDamage(const std::string &name)
-{
- mPlayers->resetDamage(name);
-}
-
-void SocialWindow::updateButtons()
-{
-// if (!mTabs)
-// return;
-
-// const bool hasTabs = mTabs->getNumberOfTabs() > 0;
-}
-
-void SocialWindow::updatePortals()
-{
- if (mNavigation != nullptr)
- mNavigation->updateList();
-}
-
-void SocialWindow::updatePortalNames()
-{
- if (mNavigation != nullptr)
- static_cast<SocialNavigationTab*>(mNavigation)->updateNames();
-}
-
-void SocialWindow::selectPortal(const unsigned num)
-{
- if (mNavigation != nullptr)
- mNavigation->selectIndex(num);
-}
-
-int SocialWindow::getPortalIndex(const int x, const int y)
-{
- if (mNavigation != nullptr)
- {
- return static_cast<SocialNavigationTab*>(
- mNavigation)->getPortalIndex(x, y);
- }
- return -1;
-}
-
-void SocialWindow::addPortal(const int x, const int y)
-{
- if (mNavigation != nullptr)
- static_cast<SocialNavigationTab*>(mNavigation)->addPortal(x, y);
-}
-
-void SocialWindow::removePortal(const int x, const int y)
-{
- if (mNavigation != nullptr)
- static_cast<SocialNavigationTab*>(mNavigation)->removePortal(x, y);
-}
-
-void SocialWindow::nextTab()
-{
- if (mTabs != nullptr)
- mTabs->selectNextTab();
-}
-
-void SocialWindow::prevTab()
-{
- if (mTabs != nullptr)
- mTabs->selectPrevTab();
-}
-
-void SocialWindow::updateAttackFilter()
-{
- if (mAttackFilter != nullptr)
- mAttackFilter->updateList();
-}
-
-void SocialWindow::updatePickupFilter()
-{
- if (mPickupFilter != nullptr)
- mPickupFilter->updateList();
-}
-
-void SocialWindow::updateParty()
-{
- if (localPlayer == nullptr)
- return;
-
- Party *const party = localPlayer->getParty();
- if (party != nullptr)
- {
- const PartyMap::iterator it = mParties.find(party);
- if (it != mParties.end())
- {
- SocialTab *const tab = (*it).second;
- tab->buildCounter(0, 0);
- }
- }
-}
-
-void SocialWindow::widgetResized(const Event &event)
-{
- Window::widgetResized(event);
- if (mTabs != nullptr)
- mTabs->adjustSize();
-}
-
-void SocialWindow::updateCounter(const SocialTab *const tab,
- const std::string &counter)
-{
- if (mTabs->getSelectedTab() == tab)
- {
- mCountLabel->setCaption(counter);
- mCountLabel->adjustSize();
- }
-}
-
-void SocialWindow::updateMenu(const SocialTab *const tab,
- const std::string &menu)
-{
- if (mTabs->getSelectedTab() == tab)
- mMenuButton->setActionEventId(menu);
-}
-
-void SocialWindow::updateGuildCounter(const int online, const int total)
-{
- if (localPlayer == nullptr)
- return;
-
- Guild *const guild = localPlayer->getGuild();
- if (guild != nullptr)
- {
- const GuildMap::iterator it = mGuilds.find(guild);
- if (it != mGuilds.end())
- {
- SocialTab *const tab = (*it).second;
- tab->buildCounter(online, total);
- }
- }
-}
-
-void SocialWindow::updatedPlayer(const std::string &name A_UNUSED)
-{
- mNeedUpdate = true;
-}
-
-void SocialWindow::updateAll()
-{
- mNeedUpdate = true;
-}
-
-#ifdef USE_PROFILER
-void SocialWindow::logicChildren()
-{
- BLOCK_START("SocialWindow::logicChildren")
- BasicContainer::logicChildren();
- BLOCK_END("SocialWindow::logicChildren")
-}
-#endif // USE_PROFILER
diff --git a/src/gui/windows/socialwindow.h b/src/gui/windows/socialwindow.h
deleted file mode 100644
index 2abee7170..000000000
--- a/src/gui/windows/socialwindow.h
+++ /dev/null
@@ -1,171 +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 GUI_WINDOWS_SOCIALWINDOW_H
-#define GUI_WINDOWS_SOCIALWINDOW_H
-
-#include "gui/widgets/window.h"
-
-#include "listeners/actionlistener.h"
-#include "listeners/playerrelationslistener.h"
-
-class Button;
-class ConfirmDialog;
-class Guild;
-class Label;
-class Map;
-class Party;
-class SocialTab;
-class TabbedArea;
-class TextDialog;
-
-/**
- * Party window.
- *
- * \ingroup Interface
- */
-class SocialWindow final : public Window,
- private ActionListener,
- public PlayerRelationsListener
-{
- public:
- SocialWindow();
-
- A_DELETE_COPY(SocialWindow)
-
- ~SocialWindow();
-
- void postInit() override final;
-
- bool addTab(Guild *const guild);
-
- bool removeTab(Guild *const guild);
-
- bool addTab(Party *const party);
-
- bool removeTab(Party *const party);
-
- void action(const ActionEvent &event) override final;
-
- void showGuildInvite(const std::string &restrict guildName,
- const int guildId,
- const std::string &restrict inviterName);
-
- void showPartyInvite(const std::string &restrict partyName,
- const std::string &restrict inviter,
- const int partyId);
-
- void updateActiveList();
-
- void updateAvatar(const std::string &name);
-
- void resetDamage(const std::string &name);
-
- void slowLogic();
-
- void updatePortals();
-
- void updatePortalNames();
-
- void updateParty();
-
- int getPortalIndex(const int x, const int y) A_WARN_UNUSED;
-
- void addPortal(const int x, const int y);
-
- void removePortal(const int x, const int y);
-
- void nextTab();
-
- void prevTab();
-
- const Map* getMap() const noexcept2 A_WARN_UNUSED
- { return mMap; }
-
- void setMap(Map *const map)
- { mMap = map; mProcessedPortals = false; }
-
- bool getProcessedPortals() const noexcept2 A_WARN_UNUSED
- { return mProcessedPortals; }
-
- void setProcessedPortals(const bool n) noexcept2
- { mProcessedPortals = n; }
-
- void selectPortal(const unsigned num);
-
- void updateAttackFilter();
-
- void updatePickupFilter();
-
- void widgetResized(const Event &event) override final;
-
- void updateCounter(const SocialTab *const tab,
- const std::string &count);
-
- void updateMenu(const SocialTab *const tab,
- const std::string &menu);
-
- void updateGuildCounter(const int online = 0, const int total = 0);
-
- void updatedPlayer(const std::string &name) override final;
-
- void updateAll() override final;
-
-#ifdef USE_PROFILER
- void logicChildren();
-#endif // USE_PROFILER
-
- protected:
- friend class SocialTab;
- typedef std::map<Guild*, SocialTab*> GuildMap;
- typedef std::map<Party*, SocialTab*> PartyMap;
-
- void updateButtons();
-
- int mGuildInvited;
- ConfirmDialog *mGuildAcceptDialog;
- TextDialog *mGuildCreateDialog;
- std::string mPartyInviter;
- GuildMap mGuilds;
- PartyMap mParties;
-
- ConfirmDialog *mPartyAcceptDialog;
-
- SocialTab *mAttackFilter;
- SocialTab *mPickupFilter;
- SocialTab *mPlayers A_NONNULLPOINTER;
- SocialTab *mNavigation A_NONNULLPOINTER;
- SocialTab *mFriends A_NONNULLPOINTER;
-
- Button *mMenuButton A_NONNULLPOINTER;
- Label *mCountLabel A_NONNULLPOINTER;
- TabbedArea *mTabs A_NONNULLPOINTER;
- Map *mMap;
-
- time_t mLastUpdateTime;
- int mPartyId;
- bool mNeedUpdate;
- bool mProcessedPortals;
-};
-
-extern SocialWindow *socialWindow;
-
-#endif // GUI_WINDOWS_SOCIALWINDOW_H
diff --git a/src/gui/windows/statuswindow.cpp b/src/gui/windows/statuswindow.cpp
deleted file mode 100644
index 092e401c2..000000000
--- a/src/gui/windows/statuswindow.cpp
+++ /dev/null
@@ -1,652 +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 "gui/windows/statuswindow.h"
-
-#include "configuration.h"
-#include "gamemodifiers.h"
-#include "settings.h"
-
-#include "being/localplayer.h"
-#include "being/playerinfo.h"
-
-#include "enums/gui/layouttype.h"
-
-#include "gui/windows/chatwindow.h"
-
-#include "gui/windows/equipmentwindow.h"
-#include "gui/windows/setupwindow.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/createwidget.h"
-#include "gui/widgets/layout.h"
-#include "gui/widgets/progressbar.h"
-#include "gui/widgets/statspage.h"
-#include "gui/widgets/statspagebasic.h"
-#include "gui/widgets/tabbedarea.h"
-#include "gui/widgets/windowcontainer.h"
-
-#include "net/inventoryhandler.h"
-#include "net/playerhandler.h"
-
-#include "resources/db/groupdb.h"
-#include "resources/db/unitsdb.h"
-#include "resources/db/statdb.h"
-
-#include "resources/item/item.h"
-
-#include "utils/delete2.h"
-#include "utils/dtor.h"
-#include "utils/foreach.h"
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-StatusWindow *statusWindow = nullptr;
-
-StatusWindow::StatusWindow() :
- Window(localPlayer != nullptr ? localPlayer->getName() :
- "?", Modal_false, nullptr, "status.xml"),
- ActionListener(),
- AttributeListener(),
- mPages(),
- mTabs(CREATEWIDGETR(TabbedArea, this)),
- // TRANSLATORS: status window label
- mLvlLabel(new Label(this, strprintf(_("Level: %d"), 0))),
- // TRANSLATORS: status window label
- mMoneyLabel(new Label(this, strprintf(_("Money: %s"), ""))),
- // TRANSLATORS: status window label
- mHpLabel(new Label(this, _("HP:"))),
- mMpLabel(nullptr),
- // TRANSLATORS: status window label
- mXpLabel(new Label(this, _("Exp:"))),
- mHpBar(nullptr),
- mMpBar(nullptr),
- mXpBar(nullptr),
- mJobLvlLabel(nullptr),
- mJobLabel(nullptr),
- mJobBar(nullptr),
- mBasicStatsPage(new StatsPageBasic(this)),
- // TRANSLATORS: status window button
- mCopyButton(new Button(this, _("Copy to chat"), "copy", this))
-{
- setWindowName("Status");
- if (setupWindow != nullptr)
- setupWindow->registerWindowForReset(this);
- setResizable(true);
- setCloseButton(true);
- setSaveVisible(true);
- setStickyButtonLock(true);
- setDefaultSize((windowContainer->getWidth() - 480) / 2,
- (windowContainer->getHeight() - 500) / 2, 480, 500);
-
- mTabs->setSelectable(false);
- mTabs->getWidgetContainer()->setSelectable(false);
- mTabs->getTabContainer()->setSelectable(false);
-
- if ((localPlayer != nullptr) && !localPlayer->getRaceName().empty())
- {
- setCaption(strprintf("%s (%s)", localPlayer->getName().c_str(),
- localPlayer->getRaceName().c_str()));
- }
-
- int max = PlayerInfo::getAttribute(Attributes::PLAYER_MAX_HP);
- if (max == 0)
- max = 1;
-
- mHpBar = new ProgressBar(this,
- static_cast<float>(PlayerInfo::getAttribute(Attributes::PLAYER_HP))
- / static_cast<float>(max),
- 80,
- 0,
- ProgressColorId::PROG_HP,
- "hpprogressbar.xml", "hpprogressbar_fill.xml");
- mHpBar->setColor(getThemeColor(ThemeColorId::HP_BAR),
- getThemeColor(ThemeColorId::HP_BAR_OUTLINE));
- mHpBar->setSelectable(false);
-
- const int64_t maxExp = PlayerInfo::getAttribute64(
- Attributes::PLAYER_EXP_NEEDED);
- mXpBar = new ProgressBar(this,
- maxExp != 0 ?
- static_cast<float>(PlayerInfo::getAttribute64(
- Attributes::PLAYER_EXP)) /
- static_cast<float>(maxExp) : static_cast<float>(0),
- 80,
- 0,
- ProgressColorId::PROG_EXP,
- "xpprogressbar.xml", "xpprogressbar_fill.xml");
- mXpBar->setColor(getThemeColor(ThemeColorId::XP_BAR),
- getThemeColor(ThemeColorId::XP_BAR_OUTLINE));
- mXpBar->setSelectable(false);
-
- const bool job = serverConfig.getValueBool("showJob", true);
-
- max = PlayerInfo::getAttribute(Attributes::PLAYER_MAX_MP);
- // TRANSLATORS: status window label
- mMpLabel = new Label(this, _("MP:"));
- const bool useMagic = playerHandler->canUseMagic();
- mMpBar = new ProgressBar(this,
- max != 0 ? static_cast<float>(PlayerInfo::getAttribute(
- Attributes::PLAYER_MAX_MP)) / static_cast<float>(max)
- : static_cast<float>(0),
- 80,
- 0,
- useMagic ? ProgressColorId::PROG_MP : ProgressColorId::PROG_NO_MP,
- useMagic ? "mpprogressbar.xml" : "nompprogressbar.xml",
- useMagic ? "mpprogressbar_fill.xml" : "nompprogressbar_fill.xml");
- mMpBar->setSelectable(false);
- if (useMagic)
- {
- mMpBar->setColor(getThemeColor(ThemeColorId::MP_BAR),
- getThemeColor(ThemeColorId::MP_BAR_OUTLINE));
- }
- else
- {
- mMpBar->setColor(getThemeColor(ThemeColorId::NO_MP_BAR),
- getThemeColor(ThemeColorId::NO_MP_BAR_OUTLINE));
- }
-
- place(0, 0, mLvlLabel, 3);
- place(0, 1, mHpLabel).setPadding(3);
- place(1, 1, mHpBar, 4);
- place(5, 1, mXpLabel).setPadding(3);
- place(6, 1, mXpBar, 5);
- place(0, 2, mMpLabel).setPadding(3);
- // 5, 2 and 6, 2 Job Progress Bar
- if (job)
- place(1, 2, mMpBar, 4);
- else
- place(1, 2, mMpBar, 10);
-
- if (job)
- {
- // TRANSLATORS: status window label
- mJobLvlLabel = new Label(this, strprintf(_("Job: %d"), 0));
- // TRANSLATORS: status window label
- mJobLabel = new Label(this, _("Job:"));
- mJobBar = new ProgressBar(this, 0.0F, 80, 0, ProgressColorId::PROG_JOB,
- "jobprogressbar.xml", "jobprogressbar_fill.xml");
- mJobBar->setColor(getThemeColor(ThemeColorId::JOB_BAR),
- getThemeColor(ThemeColorId::JOB_BAR_OUTLINE));
- mJobBar->setSelectable(false);
-
- place(3, 0, mJobLvlLabel, 3);
- place(5, 2, mJobLabel).setPadding(3);
- place(6, 2, mJobBar, 5);
- place(6, 0, mMoneyLabel, 3);
- }
- else
- {
- mJobLvlLabel = nullptr;
- mJobLabel = nullptr;
- mJobBar = nullptr;
- place(3, 0, mMoneyLabel, 3);
- }
-
- place(0, 3, mTabs, 11, 3);
-
- getLayout().setRowHeight(3, LayoutType::SET);
-
- place(0, 5, mCopyButton);
-
- loadWindowState();
- enableVisibleSound(true);
-
- // Update bars
- updateHPBar(mHpBar, true);
- updateMPBar(mMpBar, true);
- updateXPBar(mXpBar, false);
-
- // TRANSLATORS: status window label
- mMoneyLabel->setCaption(strprintf(_("Money: %s"),
- UnitsDb::formatCurrency(PlayerInfo::getAttribute(
- Attributes::MONEY)).c_str()));
- mMoneyLabel->adjustSize();
-
- updateLevelLabel();
- addTabs();
-}
-
-StatusWindow::~StatusWindow()
-{
- delete2(mBasicStatsPage);
- delete_all(mPages);
-}
-
-void StatusWindow::addTabs()
-{
- // TRANSLATORS: status window tab name
- addTabBasic(_("Basic"));
- const STD_VECTOR<std::string> &pages = StatDb::getPages();
- FOR_EACH(STD_VECTOR<std::string>::const_iterator, it, pages)
- {
- addTab(*it);
- }
- mTabs->adjustSize();
-}
-
-void StatusWindow::addTab(const std::string &name)
-{
- StatsPage *const page = new StatsPage(this, name);
- mTabs->addTab(name,
- page);
- mPages.push_back(page);
-}
-
-void StatusWindow::addTabBasic(const std::string &name)
-{
- mTabs->addTab(name,
- mBasicStatsPage);
-}
-
-void StatusWindow::updateLevelLabel()
-{
- if (localPlayer == nullptr)
- return;
-
- const int groupId = localPlayer->getGroupId();
- const std::string &name = GroupDb::getName(groupId);
- if (!name.empty())
- {
- // TRANSLATORS: status window label
- mLvlLabel->setCaption(strprintf(_("Level: %d (%s %d)"),
- PlayerInfo::getAttribute(Attributes::PLAYER_BASE_LEVEL),
- name.c_str(),
- groupId));
- }
- else
- {
- // TRANSLATORS: status window label
- mLvlLabel->setCaption(strprintf(_("Level: %d"),
- PlayerInfo::getAttribute(Attributes::PLAYER_BASE_LEVEL)));
- }
- mLvlLabel->adjustSize();
-}
-
-void StatusWindow::attributeChanged(const AttributesT id,
- const int64_t oldVal,
- const int64_t newVal)
-{
- static bool blocked = false;
-
- PRAGMA45(GCC diagnostic push)
- PRAGMA45(GCC diagnostic ignored "-Wswitch-enum")
- switch (id)
- {
- case Attributes::PLAYER_HP:
- case Attributes::PLAYER_MAX_HP:
- updateHPBar(mHpBar, true);
- break;
-
- case Attributes::PLAYER_MP:
- case Attributes::PLAYER_MAX_MP:
- updateMPBar(mMpBar, true);
- break;
-
- case Attributes::PLAYER_EXP:
- case Attributes::PLAYER_EXP_NEEDED:
- updateXPBar(mXpBar, false);
- break;
-
- case Attributes::MONEY:
- // TRANSLATORS: status window label
- mMoneyLabel->setCaption(strprintf(_("Money: %s"),
- UnitsDb::formatCurrency64(newVal).c_str()));
- mMoneyLabel->adjustSize();
- break;
-
- case Attributes::PLAYER_BASE_LEVEL:
- // TRANSLATORS: status window label
- mLvlLabel->setCaption(strprintf(_("Level: %d"),
- CAST_S32(newVal)));
- mLvlLabel->adjustSize();
- break;
-
- // +++ probable need use only some attributes here
- case Attributes::PLAYER_JOB_LEVEL:
- case Attributes::PLAYER_JOB_EXP:
- case Attributes::PLAYER_JOB_EXP_NEEDED:
- if (blocked)
- return;
- if (mJobLvlLabel != nullptr)
- {
- int lvl = PlayerInfo::getAttribute(
- Attributes::PLAYER_JOB_LEVEL);
- const int64_t exp = PlayerInfo::getAttribute(
- Attributes::PLAYER_JOB_EXP);
- const int64_t expNeed = PlayerInfo::getAttribute(
- Attributes::PLAYER_JOB_EXP_NEEDED);
-
- if (lvl == 0)
- {
- // possible server broken and don't send job level,
- // then we fixing it.
- if (expNeed < 20000)
- {
- lvl = 0;
- }
- else
- {
- lvl = CAST_S32((expNeed - 20000) / 150);
- blocked = true;
- PlayerInfo::setAttribute(Attributes::PLAYER_JOB_LEVEL,
- lvl);
- blocked = false;
- }
- }
-
- if (id == Attributes::PLAYER_JOB_EXP &&
- exp < oldVal &&
- expNeed >= 20000)
- { // possible job level up. but server broken and don't send
- // new job exp limit, we fixing it
- lvl ++;
- blocked = true;
- PlayerInfo::setAttribute(Attributes::PLAYER_JOB_EXP_NEEDED,
- 20000 + lvl * 150);
- PlayerInfo::setAttribute(Attributes::PLAYER_JOB_LEVEL,
- lvl);
- blocked = false;
- }
-
- // TRANSLATORS: status window label
- mJobLvlLabel->setCaption(strprintf(_("Job: %d"), lvl));
- mJobLvlLabel->adjustSize();
-
- updateJobBar(mJobBar, false);
- }
- break;
-
- default:
- break;
- }
- PRAGMA45(GCC diagnostic pop)
-}
-
-void StatusWindow::setPointsNeeded(const AttributesT id,
- const int needed)
-{
- mBasicStatsPage->setPointsNeeded(id, needed);
-}
-
-void StatusWindow::updateHPBar(ProgressBar *const bar, const bool showMax)
-{
- if (bar == nullptr)
- return;
-
- const int hp = PlayerInfo::getAttribute(Attributes::PLAYER_HP);
- const int maxHp = PlayerInfo::getAttribute(Attributes::PLAYER_MAX_HP);
- if (showMax)
- bar->setText(toString(hp).append("/").append(toString(maxHp)));
- else
- bar->setText(toString(hp));
-
- float prog = 1.0;
- if (maxHp > 0)
- prog = static_cast<float>(hp) / static_cast<float>(maxHp);
- bar->setProgress(prog);
-}
-
-void StatusWindow::updateMPBar(ProgressBar *const bar,
- const bool showMax) const
-{
- if (bar == nullptr)
- return;
-
- const int mp = PlayerInfo::getAttribute(Attributes::PLAYER_MP);
- const int maxMp = PlayerInfo::getAttribute(Attributes::PLAYER_MAX_MP);
- if (showMax)
- bar->setText(toString(mp).append("/").append(toString(maxMp)));
- else
- bar->setText(toString(mp));
-
- float prog = 1.0F;
- if (maxMp > 0)
- prog = static_cast<float>(mp) / static_cast<float>(maxMp);
-
- if (playerHandler->canUseMagic())
- {
- bar->setColor(getThemeColor(ThemeColorId::MP_BAR),
- getThemeColor(ThemeColorId::MP_BAR_OUTLINE));
- bar->setProgressPalette(ProgressColorId::PROG_MP);
- }
- else
- {
- bar->setColor(getThemeColor(ThemeColorId::NO_MP_BAR),
- getThemeColor(ThemeColorId::NO_MP_BAR_OUTLINE));
- bar->setProgressPalette(ProgressColorId::PROG_NO_MP);
- }
-
- bar->setProgress(prog);
-}
-
-void StatusWindow::updateProgressBar(ProgressBar *const bar,
- const int64_t value,
- const int64_t max,
- const bool percent)
-{
- if (bar == nullptr)
- return;
-
- if (max == 0)
- {
- // TRANSLATORS: status bar label
- bar->setText(_("Max"));
- bar->setProgress(1);
- bar->setText(toString(CAST_U64(value)));
- }
- else
- {
- const float progress = static_cast<float>(value)
- / static_cast<float>(max);
- if (percent)
- {
- bar->setText(strprintf("%2.5f%%",
- static_cast<double>(100 * progress)));
- }
- else
- {
- bar->setText(toString(
- CAST_U64(value)).append(
- "/").append(toString(
- CAST_U64(max))));
- }
- bar->setProgress(progress);
- }
-}
-
-void StatusWindow::updateXPBar(ProgressBar *const bar, const bool percent)
-{
- if (bar == nullptr)
- return;
-
- updateProgressBar(bar,
- PlayerInfo::getAttribute(Attributes::PLAYER_EXP),
- PlayerInfo::getAttribute(Attributes::PLAYER_EXP_NEEDED),
- percent);
-}
-
-void StatusWindow::updateJobBar(ProgressBar *const bar, const bool percent)
-{
- if (bar == nullptr)
- return;
-
- updateProgressBar(bar,
- PlayerInfo::getAttribute(Attributes::PLAYER_JOB_EXP),
- PlayerInfo::getAttribute(Attributes::PLAYER_JOB_EXP_NEEDED),
- percent);
-}
-
-void StatusWindow::updateProgressBar(ProgressBar *const bar,
- const AttributesT id,
- const bool percent)
-{
- const std::pair<int, int> exp = PlayerInfo::getStatExperience(id);
- updateProgressBar(bar, exp.first, exp.second, percent);
-}
-
-void StatusWindow::updateWeightBar(ProgressBar *const bar)
-{
- if (bar == nullptr)
- return;
-
- if (PlayerInfo::getAttribute(Attributes::MAX_WEIGHT) == 0)
- {
- // TRANSLATORS: status bar label
- bar->setText(_("Max"));
- bar->setProgress(1.0);
- }
- else
- {
- const int totalWeight = PlayerInfo::getAttribute(
- Attributes::TOTAL_WEIGHT);
- const int maxWeight = PlayerInfo::getAttribute(Attributes::MAX_WEIGHT);
- float progress = 1.0F;
- if (maxWeight != 0)
- {
- progress = static_cast<float>(totalWeight)
- / static_cast<float>(maxWeight);
- }
- bar->setText(strprintf("%s/%s",
- UnitsDb::formatWeight(totalWeight).c_str(),
- UnitsDb::formatWeight(maxWeight).c_str()));
- bar->setProgress(progress);
- }
-}
-
-void StatusWindow::updateMoneyBar(ProgressBar *const bar)
-{
- if (bar == nullptr)
- return;
-
- const int money = PlayerInfo::getAttribute(Attributes::MONEY);
- bar->setText(UnitsDb::formatCurrency(money));
- if (money > 0)
- {
- const float progress = static_cast<float>(money)
- / static_cast<float>(1000000000);
- bar->setProgress(progress);
- }
- else
- {
- bar->setProgress(1.0);
- }
-}
-
-void StatusWindow::updateArrowsBar(ProgressBar *const bar)
-{
- if ((bar == nullptr) || (equipmentWindow == nullptr))
- return;
-
- const Item *const item = equipmentWindow->getEquipment(
- inventoryHandler->getProjectileSlot());
-
- if ((item != nullptr) && item->getQuantity() > 0)
- bar->setText(toString(item->getQuantity()));
- else
- bar->setText("0");
-}
-
-void StatusWindow::updateInvSlotsBar(ProgressBar *const bar)
-{
- if (bar == nullptr)
- return;
-
- const Inventory *const inv = PlayerInfo::getInventory();
- if (inv == nullptr)
- return;
-
- const int usedSlots = inv->getNumberOfSlotsUsed();
- const int maxSlots = inv->getSize();
-
- if (maxSlots != 0)
- {
- bar->setProgress(static_cast<float>(usedSlots)
- / static_cast<float>(maxSlots));
- }
-
- bar->setText(strprintf("%d", usedSlots));
-}
-
-std::string StatusWindow::translateLetter(const char *const letters)
-{
- char buf[2];
- char *const str = gettext(letters);
- if ((str == nullptr) || strlen(str) != 3)
- return letters;
-
- buf[0] = str[1];
- buf[1] = 0;
- return std::string(buf);
-}
-
-std::string StatusWindow::translateLetter2(const std::string &letters)
-{
- if (letters.size() < 5)
- return "";
-
- return std::string(gettext(letters.substr(1, 1).c_str()));
-}
-
-void StatusWindow::updateStatusBar(ProgressBar *const bar,
- const bool percent A_UNUSED) const
-{
- if (bar == nullptr)
- return;
- bar->setText(translateLetter2(GameModifiers::getMoveTypeString())
- .append(translateLetter2(GameModifiers::getCrazyMoveTypeString()))
- .append(translateLetter2(GameModifiers::getMoveToTargetTypeString()))
- .append(translateLetter2(GameModifiers::getFollowModeString()))
- .append(" ").append(translateLetter2(
- GameModifiers::getAttackWeaponTypeString()))
- .append(translateLetter2(GameModifiers::getAttackTypeString()))
- .append(translateLetter2(GameModifiers::getMagicAttackTypeString()))
- .append(translateLetter2(GameModifiers::getPvpAttackTypeString()))
- .append(" ").append(translateLetter2(
- GameModifiers::getQuickDropCounterString()))
- .append(translateLetter2(GameModifiers::getPickUpTypeString()))
- .append(" ").append(translateLetter2(
- GameModifiers::getMapDrawTypeString()))
- .append(" ").append(translateLetter2(
- GameModifiers::getImitationModeString()))
- .append(translateLetter2(GameModifiers::getCameraModeString()))
- .append(translateLetter2(GameModifiers::getAwayModeString()))
- .append(translateLetter2(GameModifiers::getTargetingTypeString())));
-
- bar->setProgress(50);
- if (settings.disableGameModifiers)
- bar->setBackgroundColor(getThemeColor(ThemeColorId::STATUSBAR_ON));
- else
- bar->setBackgroundColor(getThemeColor(ThemeColorId::STATUSBAR_OFF));
-}
-
-void StatusWindow::action(const ActionEvent &event)
-{
- if (chatWindow == nullptr)
- return;
-
- if (event.getId() == "copy")
- {
- chatWindow->addInputText(mBasicStatsPage->getStatsStr());
- }
-}
diff --git a/src/gui/windows/statuswindow.h b/src/gui/windows/statuswindow.h
deleted file mode 100644
index 233840d17..000000000
--- a/src/gui/windows/statuswindow.h
+++ /dev/null
@@ -1,119 +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_WINDOWS_STATUSWINDOW_H
-#define GUI_WINDOWS_STATUSWINDOW_H
-
-#include "gui/widgets/window.h"
-
-#include "listeners/actionlistener.h"
-#include "listeners/attributelistener.h"
-
-class Button;
-class Label;
-class ProgressBar;
-class StatsPage;
-class StatsPageBasic;
-class TabbedArea;
-
-/**
- * The player status dialog.
- *
- * \ingroup Interface
- */
-class StatusWindow final : public Window,
- public ActionListener,
- public AttributeListener
-{
- public:
- /**
- * Constructor.
- */
- StatusWindow();
-
- A_DELETE_COPY(StatusWindow)
-
- ~StatusWindow();
-
- void setPointsNeeded(const AttributesT id,
- const int needed);
-
- static void updateHPBar(ProgressBar *const bar,
- const bool showMax = false);
- void updateMPBar(ProgressBar *bar, const bool showMax = false) const;
- static void updateJobBar(ProgressBar *const bar,
- const bool percent = true);
- static void updateXPBar(ProgressBar *const bar,
- const bool percent = true);
- static void updateWeightBar(ProgressBar *const bar);
- static void updateInvSlotsBar(ProgressBar *const bar);
- static void updateMoneyBar(ProgressBar *const bar);
- static void updateArrowsBar(ProgressBar *const bar);
- void updateStatusBar(ProgressBar *const bar,
- const bool percent = true) const;
- static void updateProgressBar(ProgressBar *const bar,
- const int64_t value,
- const int64_t max,
- const bool percent);
- static void updateProgressBar(ProgressBar *const bar,
- const AttributesT id,
- const bool percent = true);
-
- void action(const ActionEvent &event) override;
-
- void attributeChanged(const AttributesT id,
- const int64_t oldVal,
- const int64_t newVal) override final;
-
- void updateLevelLabel();
-
- private:
- void addTabs();
- void addTab(const std::string &name);
- void addTabBasic(const std::string &name);
-
- static std::string translateLetter(const char *const letters);
- static std::string translateLetter2(const std::string &letters);
-
- STD_VECTOR<StatsPage*> mPages;
-
- TabbedArea *mTabs A_NONNULLPOINTER;
- Label *mLvlLabel A_NONNULLPOINTER;
- Label *mMoneyLabel A_NONNULLPOINTER;
- Label *mHpLabel A_NONNULLPOINTER;
- Label *mMpLabel A_NONNULLPOINTER;
- Label *mXpLabel A_NONNULLPOINTER;
- ProgressBar *mHpBar A_NONNULLPOINTER;
- ProgressBar *mMpBar A_NONNULLPOINTER;
- ProgressBar *mXpBar A_NONNULLPOINTER;
-
- Label *mJobLvlLabel;
- Label *mJobLabel;
- ProgressBar *mJobBar;
-
- StatsPageBasic *mBasicStatsPage;
- Button *mCopyButton;
-};
-
-extern StatusWindow *statusWindow;
-
-#endif // GUI_WINDOWS_STATUSWINDOW_H
diff --git a/src/gui/windows/textcommandeditor.cpp b/src/gui/windows/textcommandeditor.cpp
deleted file mode 100644
index 88d88af8a..000000000
--- a/src/gui/windows/textcommandeditor.cpp
+++ /dev/null
@@ -1,344 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 Andrei Karas
- * 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 "gui/windows/textcommandeditor.h"
-
-#include "spellmanager.h"
-#include "textcommand.h"
-
-#include "input/keyboardconfig.h"
-
-#include "gui/models/iconsmodel.h"
-#include "gui/models/targettypemodel.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/containerplacer.h"
-#include "gui/widgets/dropdown.h"
-#include "gui/widgets/inttextfield.h"
-#include "gui/widgets/label.h"
-#include "gui/widgets/layoutcell.h"
-
-#ifdef TMWA_SUPPORT
-#include "gui/models/magicschoolmodel.h"
-
-#include "gui/widgets/radiobutton.h"
-#endif // TMWA_SUPPORT
-
-#include "utils/delete2.h"
-
-#include "debug.h"
-
-#ifdef TMWA_SUPPORT
-const unsigned int MAGIC_START_ID = 340;
-#endif // TMWA_SUPPORT
-
-TextCommandEditor::TextCommandEditor(TextCommand *const command) :
- // TRANSLATORS: command editor name
- Window(_("Command Editor"), Modal_false, nullptr, "commandeditor.xml"),
- ActionListener(),
-#ifdef TMWA_SUPPORT
- mIsMagicCommand(command != nullptr ?
- (command->getCommandType() == TextCommandType::Magic) : false),
-#endif // TMWA_SUPPORT
- mCommand(command),
-#ifdef TMWA_SUPPORT
- // TRANSLATORS: command editor button
- mIsMagic(new RadioButton(this, _("magic"), "magic", mIsMagicCommand)),
- // TRANSLATORS: command editor button
- mIsOther(new RadioButton(this, _("other"), "magic", !mIsMagicCommand)),
-#endif // TMWA_SUPPORT
- // TRANSLATORS: command editor label
- mSymbolLabel(new Label(this, _("Symbol:"))),
- mSymbolTextField(new TextField(this)),
- // TRANSLATORS: command editor label
- mCommandLabel(new Label(this, _("Command:"))),
- mCommandTextField(new TextField(this)),
- // TRANSLATORS: command editor label
- mCommentLabel(new Label(this, _("Comment:"))),
- mCommentTextField(new TextField(this)),
- mTargetTypeModel(new TargetTypeModel),
- // TRANSLATORS: command editor label
- mTypeLabel(new Label(this, _("Target Type:"))),
- mTypeDropDown(new DropDown(this, mTargetTypeModel)),
- mIconsModel(new IconsModel),
- // TRANSLATORS: command editor label
- mIconLabel(new Label(this, _("Icon:"))),
- mIconDropDown(new DropDown(this, mIconsModel)),
-#ifdef TMWA_SUPPORT
- // TRANSLATORS: command editor label
- mManaLabel(new Label(this, _("Mana:"))),
- mManaField(new IntTextField(this, 0)),
- // TRANSLATORS: command editor label
- mMagicLvlLabel(new Label(this, _("Magic level:"))),
- mMagicLvlField(new IntTextField(this, 0)),
- mMagicSchoolModel(new MagicSchoolModel),
- // TRANSLATORS: command editor label
- mSchoolLabel(new Label(this, _("Magic School:"))),
- mSchoolDropDown(new DropDown(this, mMagicSchoolModel)),
- // TRANSLATORS: command editor label
- mSchoolLvlLabel(new Label(this, _("School level:"))),
- mSchoolLvlField(new IntTextField(this, 0)),
-#endif // TMWA_SUPPORT
- // TRANSLATORS: command editor button
- mCancelButton(new Button(this, _("Cancel"), "cancel", this)),
- // TRANSLATORS: command editor button
- mSaveButton(new Button(this, _("Save"), "save", this)),
- // TRANSLATORS: command editor button
- mDeleteButton(new Button(this, _("Delete"), "delete", this)),
- mEnabledKeyboard(keyboard.isEnabled())
-{
- const int w = 350;
- const int h = 370;
-
- keyboard.setEnabled(false);
-
- setWindowName("TextCommandEditor");
- setDefaultSize(w, h, ImagePosition::CENTER);
-
-#ifdef TMWA_SUPPORT
- mIsMagic->setActionEventId("magic");
- mIsMagic->addActionListener(this);
-
- mIsOther->setActionEventId("other");
- mIsOther->addActionListener(this);
-
- mManaField->setRange(0, 500);
- mManaField->setWidth(20);
-
- mMagicLvlField->setRange(0, 5);
- mMagicLvlField->setWidth(20);
-
- mSchoolDropDown->setActionEventId("school");
- mSchoolDropDown->addActionListener(this);
- mSchoolDropDown->setSelected(0);
-
- mSchoolLvlField->setRange(0, 5);
- mSchoolLvlField->setWidth(20);
-#endif // TMWA_SUPPORT
-
- mTypeDropDown->setActionEventId("type");
- mTypeDropDown->addActionListener(this);
-
- mIconDropDown->setActionEventId("icon");
- mIconDropDown->addActionListener(this);
- if (mCommand != nullptr)
- mIconDropDown->setSelectedString(mCommand->getIcon());
-
- mSaveButton->adjustSize();
- mCancelButton->adjustSize();
- mDeleteButton->adjustSize();
-
- if (command != nullptr)
- {
-#ifdef TMWA_SUPPORT
- if (command->getCommandType() == TextCommandType::Magic)
- showControls(Visible_true);
- else
- showControls(Visible_false);
-
- mManaField->setValue(command->getMana());
- mMagicLvlField->setValue(command->getBaseLvl());
- mSchoolDropDown->setSelected(CAST_S32(command->getSchool())
- - MAGIC_START_ID);
- mSchoolLvlField->setValue(command->getSchoolLvl());
-#endif // TMWA_SUPPORT
- }
-
- ContainerPlacer placer;
- placer = getPlacer(0, 0);
-
-#ifdef TMWA_SUPPORT
- placer(0, 0, mIsMagic, 1);
- placer(2, 0, mIsOther, 1);
- placer(0, 1, mSymbolLabel, 2).setPadding(3);
- placer(2, 1, mSymbolTextField, 3).setPadding(3);
- placer(0, 2, mCommandLabel, 2).setPadding(3);
- placer(2, 2, mCommandTextField, 4).setPadding(3);
-
- placer(0, 3, mCommentLabel, 2).setPadding(3);
- placer(2, 3, mCommentTextField, 4).setPadding(3);
-
- placer(0, 4, mTypeLabel, 2).setPadding(3);
- placer(2, 4, mTypeDropDown, 3).setPadding(3);
-
- placer(0, 5, mIconLabel, 2).setPadding(3);
- placer(2, 5, mIconDropDown, 3).setPadding(3);
-
- placer(0, 6, mManaLabel, 2).setPadding(3);
- placer(2, 6, mManaField, 3).setPadding(3);
- placer(0, 7, mMagicLvlLabel, 2).setPadding(3);
- placer(2, 7, mMagicLvlField, 3).setPadding(3);
-
- placer(0, 8, mSchoolLabel, 2).setPadding(3);
- placer(2, 8, mSchoolDropDown, 3).setPadding(3);
- placer(0, 9, mSchoolLvlLabel, 2).setPadding(3);
- placer(2, 9, mSchoolLvlField, 3).setPadding(3);
-
- placer(0, 10, mSaveButton, 2).setPadding(3);
- placer(2, 10, mCancelButton, 2).setPadding(3);
- placer(4, 10, mDeleteButton, 2).setPadding(3);
-#else // TMWA_SUPPORT
-
- placer(0, 0, mSymbolLabel, 2).setPadding(3);
- placer(2, 0, mSymbolTextField, 3).setPadding(3);
- placer(0, 1, mCommandLabel, 2).setPadding(3);
- placer(2, 1, mCommandTextField, 4).setPadding(3);
-
- placer(0, 2, mCommentLabel, 2).setPadding(3);
- placer(2, 2, mCommentTextField, 4).setPadding(3);
-
- placer(0, 3, mTypeLabel, 2).setPadding(3);
- placer(2, 3, mTypeDropDown, 3).setPadding(3);
-
- placer(0, 4, mIconLabel, 2).setPadding(3);
- placer(2, 4, mIconDropDown, 3).setPadding(3);
-
- placer(0, 5, mSaveButton, 2).setPadding(3);
- placer(2, 5, mCancelButton, 2).setPadding(3);
- placer(4, 5, mDeleteButton, 2).setPadding(3);
-#endif // TMWA_SUPPORT
-
- setWidth(w);
- setHeight(h);
-
- reflowLayout(w);
-
- center();
-}
-
-void TextCommandEditor::postInit()
-{
- Window::postInit();
- enableVisibleSound(true);
- setVisible(Visible_true);
-}
-
-TextCommandEditor::~TextCommandEditor()
-{
- delete2(mIconsModel);
- delete2(mTargetTypeModel);
-#ifdef TMWA_SUPPORT
- delete2(mMagicSchoolModel);
-#endif // TMWA_SUPPORT
-}
-
-void TextCommandEditor::action(const ActionEvent &event)
-{
- const std::string &eventId = event.getId();
- if (eventId == "save")
- {
- save();
- scheduleDelete();
- }
- else if (eventId == "cancel")
- {
- scheduleDelete();
- }
- else if (eventId == "delete")
- {
- deleteCommand();
- scheduleDelete();
- }
-#ifdef TMWA_SUPPORT
- else if (eventId == "magic")
- {
- mIsMagicCommand = true;
- showControls(Visible_true);
- }
- else if (eventId == "other")
- {
- mIsMagicCommand = false;
- showControls(Visible_false);
- }
-#endif // TMWA_SUPPORT
-}
-
-#ifdef TMWA_SUPPORT
-void TextCommandEditor::showControls(const Visible show)
-{
- mManaField->setVisible(show);
- mManaLabel->setVisible(show);
- mMagicLvlLabel->setVisible(show);
- mMagicLvlField->setVisible(show);
- mSchoolLabel->setVisible(show);
- mSchoolDropDown->setVisible(show);
- mSchoolLvlLabel->setVisible(show);
- mSchoolLvlField->setVisible(show);
-}
-#endif // TMWA_SUPPORT
-
-void TextCommandEditor::scheduleDelete()
-{
- keyboard.setEnabled(mEnabledKeyboard);
- Window::scheduleDelete();
-}
-
-void TextCommandEditor::save()
-{
- if (mCommand == nullptr)
- return;
-#ifdef TMWA_SUPPORT
- if (mIsMagicCommand)
- mCommand->setCommandType(TextCommandType::Magic);
- else
- mCommand->setCommandType(TextCommandType::Text);
-#endif // TMWA_SUPPORT
-
- mCommand->setSymbol(mSymbolTextField->getText());
- mCommand->setCommand(mCommandTextField->getText());
- mCommand->setComment(mCommentTextField->getText());
- mCommand->setTargetType(
- static_cast<CommandTargetT>(mTypeDropDown->getSelected()));
- mCommand->setIcon(mIconDropDown->getSelectedString());
-
-#ifdef TMWA_SUPPORT
- mCommand->setMana(mManaField->getValue());
- mCommand->setBaseLvl(mMagicLvlField->getValue());
- mCommand->setSchool(static_cast<MagicSchoolT>(
- mSchoolDropDown->getSelected() + MAGIC_START_ID));
- mCommand->setSchoolLvl(mSchoolLvlField->getValue());
-#endif // TMWA_SUPPORT
-
- if (spellManager != nullptr)
- spellManager->save();
-}
-
-void TextCommandEditor::deleteCommand()
-{
- if (mCommand == nullptr)
- return;
- mCommand->setSymbol("");
- mCommand->setCommand("");
- mCommand->setComment("");
- mCommand->setTargetType(CommandTarget::NoTarget);
- mCommand->setIcon("");
-#ifdef TMWA_SUPPORT
- mCommand->setCommandType(TextCommandType::Text);
- mCommand->setMana(0);
- mCommand->setBaseLvl(0);
- mCommand->setSchool(MagicSchool::SkillMagic);
- mCommand->setSchoolLvl(0);
-#endif // TMWA_SUPPORT
-
- if (spellManager != nullptr)
- spellManager->save();
-}
diff --git a/src/gui/windows/textcommandeditor.h b/src/gui/windows/textcommandeditor.h
deleted file mode 100644
index 88bfd48d4..000000000
--- a/src/gui/windows/textcommandeditor.h
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 Andrei Karas
- * 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_WINDOWS_TEXTCOMMANDEDITOR_H
-#define GUI_WINDOWS_TEXTCOMMANDEDITOR_H
-
-#include "gui/widgets/window.h"
-
-#include "listeners/actionlistener.h"
-
-class Button;
-class DropDown;
-class IconsModel;
-class IntTextField;
-class Label;
-#ifdef TMWA_SUPPORT
-class MagicSchoolModel;
-#endif // TMWA_SUPPORT
-
-class RadioButton;
-class TargetTypeModel;
-class TextCommand;
-class TextField;
-
-class TextCommandEditor final : public Window,
- public ActionListener
-{
- public:
- /**
- * Constructor.
- */
- explicit TextCommandEditor(TextCommand *const command);
-
- A_DELETE_COPY(TextCommandEditor)
-
- /**
- * Destructor.
- */
- ~TextCommandEditor();
-
- void postInit() override final;
-
- void action(const ActionEvent &event) override final;
-
- void scheduleDelete() override final;
-
- private:
-#ifdef TMWA_SUPPORT
- void showControls(const Visible show);
-#endif // TMWA_SUPPORT
-
- void save();
-
- void deleteCommand();
-
-#ifdef TMWA_SUPPORT
- bool mIsMagicCommand;
-#endif // TMWA_SUPPORT
-
- TextCommand* mCommand;
-#ifdef TMWA_SUPPORT
- RadioButton* mIsMagic A_NONNULLPOINTER;
-#endif // TMWA_SUPPORT
-
- RadioButton* mIsOther A_NONNULLPOINTER;
- Label* mSymbolLabel A_NONNULLPOINTER;
- TextField* mSymbolTextField A_NONNULLPOINTER;
- Label* mCommandLabel A_NONNULLPOINTER;
- TextField* mCommandTextField A_NONNULLPOINTER;
- Label* mCommentLabel A_NONNULLPOINTER;
- TextField* mCommentTextField A_NONNULLPOINTER;
- TargetTypeModel* mTargetTypeModel A_NONNULLPOINTER;
- Label* mTypeLabel A_NONNULLPOINTER;
- DropDown* mTypeDropDown A_NONNULLPOINTER;
- IconsModel* mIconsModel A_NONNULLPOINTER;
- Label* mIconLabel A_NONNULLPOINTER;
- DropDown* mIconDropDown A_NONNULLPOINTER;
-#ifdef TMWA_SUPPORT
- Label* mManaLabel A_NONNULLPOINTER;
- IntTextField* mManaField A_NONNULLPOINTER;
- Label* mMagicLvlLabel A_NONNULLPOINTER;
- IntTextField* mMagicLvlField A_NONNULLPOINTER;
- MagicSchoolModel* mMagicSchoolModel A_NONNULLPOINTER;
- Label* mSchoolLabel A_NONNULLPOINTER;
- DropDown* mSchoolDropDown A_NONNULLPOINTER;
- Label* mSchoolLvlLabel A_NONNULLPOINTER;
- IntTextField* mSchoolLvlField A_NONNULLPOINTER;
-#endif // TMWA_SUPPORT
-
- Button* mCancelButton A_NONNULLPOINTER;
- Button* mSaveButton A_NONNULLPOINTER;
- Button* mDeleteButton A_NONNULLPOINTER;
-
- bool mEnabledKeyboard;
-};
-
-#endif // GUI_WINDOWS_TEXTCOMMANDEDITOR_H
diff --git a/src/gui/windows/textdialog.cpp b/src/gui/windows/textdialog.cpp
deleted file mode 100644
index 87c9dcfa8..000000000
--- a/src/gui/windows/textdialog.cpp
+++ /dev/null
@@ -1,135 +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 "gui/windows/textdialog.h"
-
-#include "input/keyboardconfig.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/label.h"
-#include "gui/widgets/passwordfield.h"
-
-#include "utils/gettext.h"
-
-#include "gui/fonts/font.h"
-
-#include "debug.h"
-
-int TextDialog::instances = 0;
-
-namespace
-{
- const std::string emptyStr;
-} // namespace
-
-TextDialog::TextDialog(const std::string &restrict title,
- const std::string &restrict msg,
- Window *const parent,
- const bool isPassword) :
- Window(title, Modal_true, parent, "textdialog.xml"),
- ActionListener(),
- mTextField(nullptr),
- mPasswordField(nullptr),
- // TRANSLATORS: text dialog button
- mOkButton(new Button(this, _("OK"), "OK", this)),
- mEnabledKeyboard(keyboard.isEnabled())
-{
- keyboard.setEnabled(false);
-
- Label *const textLabel = new Label(this, msg);
- // TRANSLATORS: text dialog button
- Button *const cancelButton = new Button(this, _("Cancel"), "CANCEL", this);
-
- place(0, 0, textLabel, 4);
- if (isPassword)
- {
- mPasswordField = new PasswordField(this);
- place(0, 1, mPasswordField, 4);
- }
- else
- {
- mTextField = new TextField(this);
- place(0, 1, mTextField, 4);
- }
- place(2, 2, mOkButton);
- place(3, 2, cancelButton);
-
- int width = getFont()->getWidth(title);
- if (width < textLabel->getWidth())
- width = textLabel->getWidth();
- reflowLayout(CAST_S32(width + 20));
-}
-
-void TextDialog::postInit()
-{
- Window::postInit();
- if (getParent() != nullptr)
- {
- setLocationRelativeTo(getParent());
- getParent()->moveToTop(this);
- }
- setVisible(Visible_true);
- requestModalFocus();
- if (mPasswordField != nullptr)
- mPasswordField->requestFocus();
- else if (mTextField != nullptr)
- mTextField->requestFocus();
-
- instances++;
-}
-
-TextDialog::~TextDialog()
-{
- instances--;
-}
-
-void TextDialog::action(const ActionEvent &event)
-{
- if (event.getId() == "CANCEL")
- setActionEventId("~" + getActionEventId());
-
- distributeActionEvent();
- close();
-}
-
-const std::string &TextDialog::getText() const
-{
- if (mTextField != nullptr)
- return mTextField->getText();
- else if (mPasswordField != nullptr)
- return mPasswordField->getText();
- return emptyStr;
-}
-
-void TextDialog::setText(const std::string &text)
-{
- if (mTextField != nullptr)
- mTextField->setText(text);
- else if (mPasswordField != nullptr)
- mPasswordField->setText(text);
-}
-
-void TextDialog::close()
-{
- keyboard.setEnabled(mEnabledKeyboard);
- scheduleDelete();
-}
diff --git a/src/gui/windows/textdialog.h b/src/gui/windows/textdialog.h
deleted file mode 100644
index a2901e04e..000000000
--- a/src/gui/windows/textdialog.h
+++ /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/>.
- */
-
-#ifndef GUI_WINDOWS_TEXTDIALOG_H
-#define GUI_WINDOWS_TEXTDIALOG_H
-
-#include "gui/widgets/window.h"
-
-#include "listeners/actionlistener.h"
-
-class Button;
-class PasswordField;
-class TextField;
-
-/**
-* An option dialog.
- *
- * \ingroup GUI
- */
-class TextDialog final : public Window,
- public ActionListener
-{
- public:
- /**
- * Constructor.
- *
- * @see Window::Window
- */
- TextDialog(const std::string &restrict title,
- const std::string &restrict msg,
- Window *const parent = nullptr,
- const bool isPassword = false);
-
- A_DELETE_COPY(TextDialog)
-
- ~TextDialog();
-
- void postInit() override final;
-
- /**
- * Called when receiving actions from the widgets.
- */
- void action(const ActionEvent &event) override final;
-
- /**
- * Get the text in the textfield
- */
- const std::string &getText() const A_WARN_UNUSED;
-
- void setText(const std::string &text);
-
- static bool isActive() noexcept2 A_WARN_UNUSED
- { return instances != 0; }
-
- void close() override final;
-
- private:
- static int instances;
-
- TextField *mTextField;
- PasswordField *mPasswordField;
- Button *mOkButton;
- bool mEnabledKeyboard;
-};
-
-#endif // GUI_WINDOWS_TEXTDIALOG_H
diff --git a/src/gui/windows/textselectdialog.cpp b/src/gui/windows/textselectdialog.cpp
deleted file mode 100644
index 11100d2d8..000000000
--- a/src/gui/windows/textselectdialog.cpp
+++ /dev/null
@@ -1,192 +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 "gui/windows/textselectdialog.h"
-
-#include "enums/gui/layouttype.h"
-
-#include "gui/windows/setupwindow.h"
-
-#include "gui/models/namesmodel.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/containerplacer.h"
-#include "gui/widgets/createwidget.h"
-#include "gui/widgets/layout.h"
-#include "gui/widgets/listbox.h"
-#include "gui/widgets/scrollarea.h"
-
-#include "utils/delete2.h"
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-TextSelectDialog::TextSelectDialog(const std::string &name,
- const std::string &selectButton,
- const AllowQuit allowQuit) :
- // TRANSLATORS: sell dialog name
- Window(name, Modal_false, nullptr, "sell.xml"),
- ActionListener(),
- SelectionListener(),
- mSelectButtonName(selectButton),
- mText(),
- mSelectButton(nullptr),
- mQuitButton(nullptr),
- mItemList(nullptr),
- mScrollArea(nullptr),
- mModel(nullptr),
- mAllowQuit(allowQuit),
- mTag(0)
-{
-}
-
-void TextSelectDialog::postInit()
-{
- Window::postInit();
- setWindowName("TextSelectDialog");
- setResizable(true);
- setCloseButton(mAllowQuit == AllowQuit_true);
- setStickyButtonLock(true);
- setMinWidth(260);
- setMinHeight(220);
- setDefaultSize(260, 230, ImagePosition::CENTER);
-
- if (setupWindow != nullptr)
- setupWindow->registerWindowForReset(this);
-
- setActionEventId("OK");
- mModel = new NamesModel;
- mItemList = CREATEWIDGETR(ListBox,
- this,
- mModel,
- "listbox.xml");
- mScrollArea = new ScrollArea(this, mItemList,
- fromBool(getOptionBool("showbackground"), Opaque),
- "sell_background.xml");
- mScrollArea->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
-
- mSelectButton = new Button(this,
- mSelectButtonName,
- "select",
- this);
- if (mAllowQuit == AllowQuit_true)
- {
- // TRANSLATORS: sell dialog button
- mQuitButton = new Button(this, _("Quit"), "quit", this);
- }
-
- mSelectButton->setEnabled(false);
-
- mItemList->setDistributeMousePressed(false);
- mItemList->addSelectionListener(this);
- mItemList->setActionEventId("item");
- mItemList->addActionListener(this);
-
- ContainerPlacer placer;
- placer = getPlacer(0, 0);
-
- placer(0, 0, mScrollArea, 8, 5).setPadding(3);
- if (mQuitButton != nullptr)
- {
- placer(6, 5, mSelectButton);
- placer(7, 5, mQuitButton);
- }
- else
- {
- placer(7, 5, mSelectButton);
- }
-
- Layout &layout = getLayout();
- layout.setRowHeight(0, LayoutType::SET);
-
- center();
- loadWindowState();
-
- setVisible(Visible_true);
- enableVisibleSound(true);
-}
-
-TextSelectDialog::~TextSelectDialog()
-{
- delete2(mModel);
-}
-
-void TextSelectDialog::action(const ActionEvent &event)
-{
- const std::string &eventId = event.getId();
-
- if (eventId == "quit")
- {
- close();
- return;
- }
-
- const int selectedItem = mItemList->getSelected();
-
- // The following actions require a valid item selection
- if (selectedItem == -1 ||
- selectedItem >= mModel->getNumberOfElements())
- {
- return;
- }
- else if (eventId == "select")
- {
- const int index = mItemList->getSelected();
- if (index < 0 || index >= CAST_S32(mModel->size()))
- return;
- mText = mModel->getElementAt(index);
- distributeActionEvent();
- close();
- }
-}
-
-void TextSelectDialog::updateButtonsAndLabels()
-{
- mSelectButton->setEnabled(mItemList->getSelected() > -1);
-}
-
-void TextSelectDialog::valueChanged(const SelectionEvent &event A_UNUSED)
-{
- updateButtonsAndLabels();
-}
-
-void TextSelectDialog::setVisible(Visible visible)
-{
- Window::setVisible(visible);
-
- if (visible == Visible_true)
- {
- if (mItemList != nullptr)
- mItemList->requestFocus();
- }
- else
- {
- scheduleDelete();
- }
-}
-
-void TextSelectDialog::addText(const std::string &text)
-{
- if (text.empty())
- return;
- mModel->add(text);
-}
diff --git a/src/gui/windows/textselectdialog.h b/src/gui/windows/textselectdialog.h
deleted file mode 100644
index 30e596d32..000000000
--- a/src/gui/windows/textselectdialog.h
+++ /dev/null
@@ -1,104 +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_WINDOWS_TEXTSELECTDIALOG_H
-#define GUI_WINDOWS_TEXTSELECTDIALOG_H
-
-#include "gui/widgets/window.h"
-
-#include "enums/simpletypes/allowquit.h"
-
-#include "listeners/actionlistener.h"
-#include "listeners/selectionlistener.h"
-
-class Button;
-class ScrollArea;
-class NamesModel;
-class ListBox;
-
-class TextSelectDialog notfinal : public Window,
- public ActionListener,
- private SelectionListener
-{
- public:
- /**
- * Constructor.
- */
- TextSelectDialog(const std::string &name,
- const std::string &selectButton,
- const AllowQuit allowQuit);
-
- A_DELETE_COPY(TextSelectDialog)
-
- /**
- * Destructor
- */
- ~TextSelectDialog();
-
- /**
- * Called when receiving actions from the widgets.
- */
- void action(const ActionEvent &event) override final;
-
- /**
- * Updates labels according to selected item.
- *
- * @see SelectionListener::selectionChanged
- */
- void valueChanged(const SelectionEvent &event) override final;
-
- /**
- * Sets the visibility of this window.
- */
- void setVisible(Visible visible) override final;
-
- void postInit() override;
-
- void addText(const std::string &text);
-
- std::string getText() const noexcept2 A_WARN_UNUSED
- { return mText; }
-
- void setTag(const int tag) noexcept2
- { mTag = tag; }
-
- int getTag() const noexcept2 A_WARN_UNUSED
- { return mTag; }
-
- protected:
- /**
- * Updates the state of buttons and labels.
- */
- void updateButtonsAndLabels();
-
- std::string mSelectButtonName;
- std::string mText;
- Button *mSelectButton A_NONNULLPOINTER;
- Button *mQuitButton A_NONNULLPOINTER;
- ListBox *mItemList A_NONNULLPOINTER;
- ScrollArea *mScrollArea A_NONNULLPOINTER;
- NamesModel *mModel A_NONNULLPOINTER;
- AllowQuit mAllowQuit;
- int mTag;
-};
-
-#endif // GUI_WINDOWS_TEXTSELECTDIALOG_H
diff --git a/src/gui/windows/tradewindow.cpp b/src/gui/windows/tradewindow.cpp
deleted file mode 100644
index 66f4e0550..000000000
--- a/src/gui/windows/tradewindow.cpp
+++ /dev/null
@@ -1,553 +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 "gui/windows/tradewindow.h"
-
-#include "configuration.h"
-#include "game.h"
-
-#include "being/localplayer.h"
-#include "being/playerinfo.h"
-#include "being/playerrelations.h"
-
-#include "enums/gui/layouttype.h"
-
-#include "gui/gui.h"
-
-#include "gui/fonts/font.h"
-
-#include "gui/windows/inventorywindow.h"
-#include "gui/windows/itemamountwindow.h"
-#include "gui/windows/setupwindow.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/containerplacer.h"
-#include "gui/widgets/itemcontainer.h"
-#include "gui/widgets/label.h"
-#include "gui/widgets/layout.h"
-#include "gui/widgets/scrollarea.h"
-#include "gui/widgets/textfield.h"
-
-#include "gui/widgets/tabs/chat/chattab.h"
-
-#include "resources/db/unitsdb.h"
-
-#include "resources/item/item.h"
-
-#include "net/net.h"
-#include "net/tradehandler.h"
-
-#include "utils/delete2.h"
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-TradeWindow *tradeWindow = nullptr;
-
-// TRANSLATORS: trade window button
-#define CAPTION_PROPOSE _("Propose trade")
-// TRANSLATORS: trade window button
-#define CAPTION_CONFIRMED _("Confirmed. Waiting...")
-// TRANSLATORS: trade window button
-#define CAPTION_ACCEPT _("Agree trade")
-// TRANSLATORS: trade window button
-#define CAPTION_ACCEPTED _("Agreed. Waiting...")
-
-TradeWindow::TradeWindow() :
- // TRANSLATORS: trade window caption
- Window(_("Trade: You"), Modal_false, nullptr, "trade.xml"),
- ActionListener(),
- SelectionListener(),
- mMyInventory(new Inventory(InventoryType::Trade)),
- mPartnerInventory(new Inventory(InventoryType::Trade)),
- mMyItemContainer(new ItemContainer(this, mMyInventory)),
- mPartnerItemContainer(new ItemContainer(this, mPartnerInventory)),
- // TRANSLATORS: trade window money label
- mMoneyLabel(new Label(this, strprintf(_("You get %s"), ""))),
- // TRANSLATORS: trade window button
- mAddButton(new Button(this, _("Add"), "add", this)),
- mOkButton(new Button(this, "", "", this)), // Will be filled in later
- // TRANSLATORS: trade window money change button
- mMoneyChangeButton(new Button(this, _("Change"), "money", this)),
- mMoneyField(new TextField(this)),
- mAutoAddItem(nullptr),
- mAutoAddToNick(""),
- mGotMoney(0),
- mGotMaxMoney(0),
- mAutoMoney(0),
- mAutoAddAmount(0),
- mStatus(PROPOSING),
- mOkOther(false),
- mOkMe(false)
-{
- setWindowName("Trade");
- setResizable(true);
- setCloseButton(true);
- setStickyButtonLock(true);
- setDefaultSize(386, 180, ImagePosition::CENTER);
- setMinWidth(310);
- setMinHeight(180);
-
- if (setupWindow != nullptr)
- setupWindow->registerWindowForReset(this);
-
- const Font *const fnt = mOkButton->getFont();
- int width = std::max(fnt->getWidth(CAPTION_PROPOSE),
- fnt->getWidth(CAPTION_CONFIRMED));
- width = std::max(width, fnt->getWidth(CAPTION_ACCEPT));
- width = std::max(width, fnt->getWidth(CAPTION_ACCEPTED));
-
- mOkButton->setWidth(8 + width);
-
- mMyItemContainer->addSelectionListener(this);
-
- ScrollArea *const myScroll = new ScrollArea(this, mMyItemContainer,
- Opaque_true, "trade_background.xml");
- myScroll->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
-
- mPartnerItemContainer->addSelectionListener(this);
-
- ScrollArea *const partnerScroll = new ScrollArea(this,
- mPartnerItemContainer,
- Opaque_true, "trade_background.xml");
- partnerScroll->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
-
- // TRANSLATORS: trade window money label
- Label *const moneyLabel2 = new Label(this, _("You give:"));
-
- mMoneyField->setWidth(40);
-
- place(1, 0, mMoneyLabel);
- place(0, 1, myScroll).setPadding(3);
- place(1, 1, partnerScroll).setPadding(3);
- ContainerPlacer placer = getPlacer(0, 0);
- placer(0, 0, moneyLabel2);
- placer(1, 0, mMoneyField, 2);
- placer(3, 0, mMoneyChangeButton).setHAlign(LayoutCell::LEFT);
- placer = getPlacer(0, 2);
- placer(0, 0, mAddButton);
- placer(1, 0, mOkButton);
- Layout &layout = getLayout();
- layout.extend(0, 2, 2, 1);
- layout.setRowHeight(1, LayoutType::SET);
- layout.setRowHeight(2, 0);
- layout.setColWidth(0, LayoutType::SET);
- layout.setColWidth(1, LayoutType::SET);
-
- loadWindowState();
- enableVisibleSound(true);
-
- reset();
-}
-
-TradeWindow::~TradeWindow()
-{
- delete2(mMyInventory);
- delete2(mPartnerInventory);
-}
-
-void TradeWindow::setMoney(const int amount)
-{
- if (amount < 0 || amount < mGotMaxMoney)
- {
- if (config.getBoolValue("securetrades"))
- {
- close();
- return;
- }
- mMoneyLabel->setForegroundColorAll(
- getThemeColor(ThemeColorId::WARNING),
- getThemeColor(ThemeColorId::WARNING_OUTLINE));
- }
- else
- {
- mMoneyLabel->setForegroundColorAll(
- getThemeColor(ThemeColorId::LABEL),
- getThemeColor(ThemeColorId::LABEL_OUTLINE));
- mGotMaxMoney = amount;
- }
-
- mGotMoney = amount;
- // TRANSLATORS: trade window money label
- mMoneyLabel->setCaption(strprintf(_("You get %s"),
- UnitsDb::formatCurrency(amount).c_str()));
- mMoneyLabel->adjustSize();
-}
-
-void TradeWindow::addItem(const int id,
- const ItemTypeT type,
- const bool own,
- const int quantity,
- const uint8_t refine,
- const ItemColor color,
- const Identified identified,
- const Damaged damaged,
- const Favorite favorite) const
-{
- Inventory *const inv = own ? mMyInventory : mPartnerInventory;
- inv->addItem(id,
- type,
- quantity,
- refine,
- color,
- identified,
- damaged,
- favorite,
- Equipm_false,
- Equipped_false);
-}
-
-void TradeWindow::addItem2(const int id,
- const ItemTypeT type,
- const int *const cards,
- const ItemOptionsList *const options,
- const int sz,
- const bool own,
- const int quantity,
- const uint8_t refine,
- const ItemColor color,
- const Identified identified,
- const Damaged damaged,
- const Favorite favorite,
- const Equipm equipment) const
-{
- Inventory *const inv = own ? mMyInventory : mPartnerInventory;
- const int slot = inv->addItem(id,
- type,
- quantity,
- refine,
- color,
- identified,
- damaged,
- favorite,
- equipment,
- Equipped_false);
- if (slot >= 0)
- {
- inv->setCards(slot, cards, sz);
- inv->setOptions(slot, options);
- }
-}
-
-void TradeWindow::changeQuantity(const int index, const bool own,
- const int quantity) const
-{
- Item *item;
- if (own)
- item = mMyInventory->getItem(index);
- else
- item = mPartnerInventory->getItem(index);
- if (item != nullptr)
- item->setQuantity(quantity);
-}
-
-void TradeWindow::increaseQuantity(const int index, const bool own,
- const int quantity) const
-{
- Item *item;
- if (own)
- item = mMyInventory->getItem(index);
- else
- item = mPartnerInventory->getItem(index);
- if (item != nullptr)
- item->increaseQuantity(quantity);
-}
-
-void TradeWindow::reset()
-{
- mMyInventory->clear();
- mPartnerInventory->clear();
- mOkOther = false;
- mOkMe = false;
- setMoney(0);
- mMoneyField->setEnabled(true);
- mMoneyField->setText("");
- mMoneyLabel->setForegroundColorAll(
- getThemeColor(ThemeColorId::LABEL),
- getThemeColor(ThemeColorId::LABEL_OUTLINE));
- mAddButton->setEnabled(true);
- mMoneyChangeButton->setEnabled(true);
- mGotMoney = 0;
- mGotMaxMoney = 0;
- setStatus(PREPARING);
-}
-
-void TradeWindow::receivedOk(const bool own)
-{
- if (own)
- mOkMe = true;
- else
- mOkOther = true;
-
- if (mOkMe && mOkOther)
- setStatus(ACCEPTING);
-}
-
-void TradeWindow::completeTrade()
-{
- if (config.getBoolValue("tradescreenshot"))
- Game::createScreenshot(std::string());
- setVisible(Visible_false);
- reset();
-}
-
-void TradeWindow::tradeItem(const Item *const item, const int quantity,
- const bool check) const
-{
- if (check && !checkItem(item))
- return;
-
- tradeHandler->addItem(item, quantity);
-}
-
-void TradeWindow::valueChanged(const SelectionEvent &event)
-{
- if ((mMyItemContainer == nullptr) || (mPartnerItemContainer == nullptr))
- return;
-
- /* If an item is selected in one container, make sure no item is selected
- * in the other container.
- */
- if (event.getSource() == mMyItemContainer &&
- (mMyItemContainer->getSelectedItem() != nullptr))
- {
- mPartnerItemContainer->selectNone();
- }
- else if (mPartnerItemContainer->getSelectedItem() != nullptr)
- {
- mMyItemContainer->selectNone();
- }
-}
-
-void TradeWindow::setStatus(const Status s)
-{
- if (s == mStatus)
- return;
- mStatus = s;
-
- switch (s)
- {
- case PREPARING:
- mOkButton->setCaption(CAPTION_PROPOSE);
- mOkButton->setActionEventId("ok");
- break;
- case PROPOSING:
- mOkButton->setCaption(CAPTION_CONFIRMED);
- mOkButton->setActionEventId("");
- break;
- case ACCEPTING:
- mOkButton->setCaption(CAPTION_ACCEPT);
- mOkButton->setActionEventId("trade");
- break;
- case ACCEPTED:
- mOkButton->setCaption(CAPTION_ACCEPTED);
- mOkButton->setActionEventId("");
- break;
- default:
- break;
- }
-
- mOkButton->setEnabled((s != PROPOSING && s != ACCEPTED));
-}
-
-void TradeWindow::action(const ActionEvent &event)
-{
- if (inventoryWindow == nullptr)
- return;
-
- Item *const item = inventoryWindow->getSelectedItem();
- const std::string &eventId = event.getId();
-
- if (eventId == "add")
- {
- if (mStatus != PREPARING)
- return;
-
- if (!inventoryWindow->isWindowVisible())
- {
- inventoryWindow->setVisible(Visible_true);
- return;
- }
-
- if (item == nullptr)
- return;
-
- if (mMyInventory->getFreeSlot() == -1)
- return;
-
- if (!checkItem(item))
- return;
-
- // Choose amount of items to trade
- ItemAmountWindow::showWindow(ItemAmountWindowUsage::TradeAdd,
- this, item);
-
- setStatus(PREPARING);
- }
- else if (eventId == "cancel")
- {
- setVisible(Visible_false);
- reset();
- PlayerInfo::setTrading(Trading_false);
- tradeHandler->cancel();
- }
- else if (eventId == "ok")
- {
- mMoneyField->setEnabled(false);
- mAddButton->setEnabled(false);
- mMoneyChangeButton->setEnabled(false);
- receivedOk(true);
- setStatus(PROPOSING);
- tradeHandler->confirm();
- }
- else if (eventId == "trade")
- {
- receivedOk(true);
- setStatus(ACCEPTED);
- tradeHandler->finish();
- }
- else if (eventId == "money")
- {
- if (mStatus != PREPARING)
- return;
-
- int v = atoi(mMoneyField->getText().c_str());
- const int curMoney = PlayerInfo::getAttribute(Attributes::MONEY);
- if (v > curMoney)
- {
- if (localChatTab != nullptr)
- {
- // TRANSLATORS: trade error
- localChatTab->chatLog(_("You don't have enough money."),
- ChatMsgType::BY_SERVER);
- }
- v = curMoney;
- }
- tradeHandler->setMoney(v);
- mMoneyField->setText(strprintf("%d", v));
- }
-}
-
-void TradeWindow::close()
-{
- tradeHandler->cancel();
- clear();
-}
-
-void TradeWindow::clear()
-{
- mAutoAddItem = nullptr;
- mAutoAddToNick.clear();
- mAutoMoney = 0;
- mAutoAddAmount = 0;
- mGotMoney = 0;
- mGotMaxMoney = 0;
- mMoneyLabel->setForegroundColorAll(
- getThemeColor(ThemeColorId::LABEL),
- getThemeColor(ThemeColorId::LABEL_OUTLINE));
-}
-
-void TradeWindow::addAutoItem(const std::string &nick, Item* const item,
- const int amount)
-{
- mAutoAddToNick = nick;
- mAutoAddItem = item;
- mAutoAddAmount = amount;
-}
-
-void TradeWindow::addAutoMoney(const std::string &nick, const int money)
-{
- mAutoAddToNick = nick;
- mAutoMoney = money;
-}
-
-void TradeWindow::initTrade(const std::string &nick)
-{
- if (localPlayer == nullptr)
- return;
-
- if (!mAutoAddToNick.empty() && mAutoAddToNick == nick)
- {
- if ((mAutoAddItem != nullptr) && (mAutoAddItem->getQuantity() != 0))
- {
- const Inventory *const inv = PlayerInfo::getInventory();
- if (inv != nullptr)
- {
- const Item *const item = inv->findItem(mAutoAddItem->getId(),
- mAutoAddItem->getColor());
- if (item != nullptr)
- tradeItem(item, mAutoAddAmount);
- }
- }
- if (mAutoMoney != 0)
- {
- tradeHandler->setMoney(mAutoMoney);
- mMoneyField->setText(strprintf("%d", mAutoMoney));
- }
- }
- clear();
- if (!playerRelations.isGoodName(nick))
- setCaptionFont(gui->getSecureFont());
-}
-
-bool TradeWindow::checkItem(const Item *const item) const
-{
- if (item == nullptr)
- return false;
-
- const int itemId = item->getId();
- if (PlayerInfo::isItemProtected(itemId))
- return false;
- const Item *const tItem = mMyInventory->findItem(
- itemId, item->getColor());
-
- if ((tItem != nullptr) && (tItem->getQuantity() > 1
- || item->getQuantity() > 1))
- {
- if (localChatTab != nullptr)
- {
- // TRANSLATORS: trade error
- localChatTab->chatLog(_("Failed adding item. You can not "
- "overlap one kind of item on the window."),
- ChatMsgType::BY_SERVER);
- }
- return false;
- }
- if (Net::getNetworkType() != ServerType::TMWATHENA &&
- item->isEquipped() == Equipped_true)
- {
- if (localChatTab != nullptr)
- {
- localChatTab->chatLog(
- // TRANSLATORS: trade error
- _("Failed adding item. You can not trade equipped items."),
- ChatMsgType::BY_SERVER);
- }
- return false;
- }
- return true;
-}
-
-bool TradeWindow::isInpupFocused() const
-{
- return mMoneyField != nullptr && mMoneyField->isFocused();
-}
diff --git a/src/gui/windows/tradewindow.h b/src/gui/windows/tradewindow.h
deleted file mode 100644
index 6cfc89a3f..000000000
--- a/src/gui/windows/tradewindow.h
+++ /dev/null
@@ -1,214 +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_WINDOWS_TRADEWINDOW_H
-#define GUI_WINDOWS_TRADEWINDOW_H
-
-#include "gui/widgets/window.h"
-
-#include "enums/resources/item/itemtype.h"
-
-#include "enums/simpletypes/damaged.h"
-#include "enums/simpletypes/equipm.h"
-#include "enums/simpletypes/favorite.h"
-#include "enums/simpletypes/identified.h"
-#include "enums/simpletypes/itemcolor.h"
-
-#include "listeners/actionlistener.h"
-#include "listeners/selectionlistener.h"
-
-class Button;
-class Inventory;
-class Item;
-class ItemContainer;
-class Label;
-class TextField;
-
-struct ItemOptionsList;
-
-/**
- * Trade dialog.
- *
- * \ingroup Interface
- */
-class TradeWindow final : public Window,
- private ActionListener,
- private SelectionListener
-{
- public:
- /**
- * Constructor.
- */
- TradeWindow();
-
- A_DELETE_COPY(TradeWindow)
-
- /**
- * Destructor.
- */
- ~TradeWindow();
-
- /**
- * Displays expected money in the trade window.
- */
- void setMoney(const int quantity);
-
- /**
- * Add an item to the trade window.
- */
- void addItem(const int id,
- const ItemTypeT type,
- const bool own,
- const int quantity,
- const uint8_t refine,
- const ItemColor color,
- const Identified identified,
- const Damaged damaged,
- const Favorite favorite) const;
-
- /**
- * Reset both item containers
- */
- void reset();
-
- /**
- * Add an item to the trade window.
- */
- void addItem2(const int id,
- const ItemTypeT type,
- const int *const cards,
- const ItemOptionsList *const options,
- const int sz,
- const bool own,
- const int quantity,
- const uint8_t refine,
- const ItemColor color,
- const Identified identified,
- const Damaged damaged,
- const Favorite favorite,
- const Equipm equipment) const;
-
- /**
- * Change quantity of an item.
- */
- void changeQuantity(const int index, const bool own,
- const int quantity) const;
-
- /**
- * Increase quantity of an item.
- */
- void increaseQuantity(const int index, const bool own,
- const int quantity) const;
-
- /**
- * Player received ok message from server
- */
- void receivedOk(const bool own);
-
- /**
- * Send trade packet.
- */
- void tradeItem(const Item *const item,
- const int quantity,
- const bool check = false) const;
-
- /**
- * Updates the labels and makes sure only one item is selected in
- * either my inventory or partner inventory.
- */
- void valueChanged(const SelectionEvent &event) override final;
-
- /**
- * Called when receiving actions from the widgets.
- */
- void action(const ActionEvent &event) override final;
-
- /**
- * Closes the Trade Window, as well as telling the server that the
- * window has been closed.
- */
- void close() override final;
-
- /**
- * Clear auto trade items.
- */
- void clear() override final;
-
- /**
- * Add item what will be added to trade.
- */
- void addAutoItem(const std::string &nick, Item *const item,
- const int amount);
-
- void addAutoMoney(const std::string &nick, const int money);
-
- void initTrade(const std::string &nick);
-
- std::string getAutoTradeNick() const noexcept2 A_WARN_UNUSED
- { return mAutoAddToNick; }
-
- bool checkItem(const Item *const item) const A_WARN_UNUSED;
-
- bool isInpupFocused() const A_WARN_UNUSED;
-
- void completeTrade();
-
- private:
- enum Status
- {
- PREPARING = 0, /**< Players are adding items. (1) */
- PROPOSING, /**< Local player has confirmed the trade. (1) */
- ACCEPTING, /**< Accepting the trade. (2) */
- ACCEPTED /**< Local player has accepted the trade. */
- };
-
- /**
- * Sets the current status of the trade.
- */
- void setStatus(const Status s);
-
- Inventory *mMyInventory A_NONNULLPOINTER;
- Inventory *mPartnerInventory A_NONNULLPOINTER;
-
- ItemContainer *mMyItemContainer A_NONNULLPOINTER;
- ItemContainer *mPartnerItemContainer A_NONNULLPOINTER;
-
- Label *mMoneyLabel A_NONNULLPOINTER;
- Button *mAddButton A_NONNULLPOINTER;
- Button *mOkButton A_NONNULLPOINTER;
- Button *mMoneyChangeButton A_NONNULLPOINTER;
- TextField *mMoneyField A_NONNULLPOINTER;
-
- Item* mAutoAddItem;
- std::string mAutoAddToNick;
- int mGotMoney;
- int mGotMaxMoney;
- int mAutoMoney;
- int mAutoAddAmount;
- Status mStatus;
- bool mOkOther;
- bool mOkMe;
-};
-
-extern TradeWindow *tradeWindow;
-
-#endif // GUI_WINDOWS_TRADEWINDOW_H
diff --git a/src/gui/windows/updaterwindow.cpp b/src/gui/windows/updaterwindow.cpp
deleted file mode 100644
index 3858b0a5e..000000000
--- a/src/gui/windows/updaterwindow.cpp
+++ /dev/null
@@ -1,1217 +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 "gui/windows/updaterwindow.h"
-
-#include "client.h"
-#include "configuration.h"
-#include "main.h"
-#include "settings.h"
-
-#include "enums/gui/layouttype.h"
-
-#include "fs/files.h"
-#include "fs/mkdir.h"
-#include "fs/paths.h"
-
-#include "fs/virtfs/fs.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/containerplacer.h"
-#include "gui/widgets/itemlinkhandler.h"
-#include "gui/widgets/label.h"
-#include "gui/widgets/layout.h"
-#include "gui/widgets/progressbar.h"
-#include "gui/widgets/scrollarea.h"
-#include "gui/widgets/staticbrowserbox.h"
-
-#include "net/download.h"
-#include "net/updatetypeoperators.h"
-
-#include "resources/db/moddb.h"
-
-#include "utils/delete2.h"
-#include "utils/foreach.h"
-#include "utils/gettext.h"
-
-#include <sys/stat.h>
-
-#include <sstream>
-
-#include "debug.h"
-
-UpdaterWindow *updaterWindow = nullptr;
-
-const std::string xmlUpdateFile("resources.xml");
-const std::string txtUpdateFile("resources2.txt");
-const std::string updateServer2
- ("http://download.manaplus.org/manaplus/updates/");
-const std::string updateServer3
- ("http://download2.manaplus.org/manaplus/updates/");
-const std::string updateServer4
- ("http://download.evolonline.org/manaplus/updates/");
-const std::string updateServer5
- ("http://download3.manaplus.org/manaplus/updates/");
-
-/**
- * Load the given file into a vector of updateFiles.
- */
-static STD_VECTOR<UpdateFile> loadXMLFile(const std::string &fileName,
- const bool loadMods)
-{
- STD_VECTOR<UpdateFile> files;
- XML::Document doc(fileName, UseVirtFs_false, SkipError_false);
- XmlNodeConstPtrConst rootNode = doc.rootNode();
-
- if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "updates"))
- {
- logger->log("Error loading update file: %s", fileName.c_str());
- return files;
- }
-
- for_each_xml_child_node(fileNode, rootNode)
- {
- const bool isMod = xmlNameEqual(fileNode, "mod");
- if (!xmlNameEqual(fileNode, "update") && !isMod)
- continue;
-
- UpdateFile file;
- file.name = XML::getProperty(fileNode, "file", "");
- file.hash = XML::getProperty(fileNode, "hash", "");
- file.type = XML::getProperty(fileNode, "type", "data");
- file.desc = XML::getProperty(fileNode, "description", "");
- file.group = XML::getProperty(fileNode, "group", "");
- if (!file.group.empty() && (!isMod || !loadMods))
- continue;
-
- const std::string version = XML::getProperty(
- fileNode, "version", "");
- if (!version.empty())
- {
- if (version > CHECK_VERSION)
- continue;
- }
- const std::string notVersion = XML::getProperty(
- fileNode, "notVersion", "");
- if (!notVersion.empty())
- {
- if (notVersion <= CHECK_VERSION)
- continue;
- }
- if (XML::getProperty(fileNode, "required", "yes") == "yes")
- file.required = true;
- else
- file.required = false;
-
- if (checkPath(file.name))
- files.push_back(file);
- }
-
- return files;
-}
-
-static STD_VECTOR<UpdateFile> loadTxtFile(const std::string &fileName)
-{
- STD_VECTOR<UpdateFile> files;
- std::ifstream fileHandler;
- fileHandler.open(fileName.c_str(), std::ios::in);
-
- if (fileHandler.is_open())
- {
- while (fileHandler.good())
- {
- char name[256];
- char hash[50];
- fileHandler.getline(name, 256, ' ');
- fileHandler.getline(hash, 50);
-
- UpdateFile thisFile;
- thisFile.name = name;
- thisFile.hash = hash;
- thisFile.type = "data";
- thisFile.group.clear();
- thisFile.required = true;
- thisFile.desc.clear();
-
- if (!thisFile.name.empty() && checkPath(thisFile.name))
- files.push_back(thisFile);
- }
- }
- else
- {
- logger->log("Error loading update file: %s", fileName.c_str());
- }
- fileHandler.close();
-
- return files;
-}
-
-UpdaterWindow::UpdaterWindow(const std::string &restrict updateHost,
- const std::string &restrict updatesDir,
- const bool applyUpdates,
- const UpdateTypeT updateType) :
- // TRANSLATORS: updater window name
- Window(_("Updating..."), Modal_false, nullptr, "update.xml"),
- ActionListener(),
- KeyListener(),
- mDownloadProgress(0.0F),
- mUpdateHost(updateHost),
- mUpdatesDir(updatesDir),
- mUpdatesDirReal(updatesDir),
- mCurrentFile("news.txt"),
- mNewLabelCaption(),
- mDownloadMutex(),
- mCurrentChecksum(0),
- mMemoryBuffer(nullptr),
- mDownload(nullptr),
- mUpdateFiles(),
- mTempUpdateFiles(),
- mUpdateServerPath(mUpdateHost),
- mItemLinkHandler(new ItemLinkHandler),
- // TRANSLATORS: updater window label
- mLabel(new Label(this, _("Connecting..."))),
- // TRANSLATORS: updater window button
- mCancelButton(new Button(this, _("Cancel"), "cancel", this)),
- // TRANSLATORS: updater window button
- mPlayButton(new Button(this, _("Play"), "play", this)),
- mProgressBar(new ProgressBar(this, 0.0, 310, 0,
- ProgressColorId::PROG_UPDATE,
- "updateprogressbar.xml", "updateprogressbar_fill.xml")),
- mBrowserBox(new StaticBrowserBox(this, Opaque_true,
- "browserbox.xml")),
- mScrollArea(new ScrollArea(this, mBrowserBox,
- Opaque_true, "update_background.xml")),
- mDownloadStatus(UpdateDownloadStatus::UPDATE_NEWS),
- mDownloadedBytes(0),
- mUpdateIndex(0),
- mUpdateIndexOffset(0),
- mUpdateType(updateType),
- mStoreInMemory(true),
- mDownloadComplete(true),
- mUserCancel(false),
- mLoadUpdates(applyUpdates),
- mValidateXml(false),
- mSkipPatches(false)
-{
- setWindowName("UpdaterWindow");
- setResizable(true);
- setDefaultSize(450, 400, ImagePosition::CENTER);
- setMinWidth(310);
- setMinHeight(220);
-
- mProgressBar->setSmoothProgress(false);
- mBrowserBox->setOpaque(Opaque_false);
- mBrowserBox->setLinkHandler(mItemLinkHandler);
- mBrowserBox->setProcessVars(true);
- mBrowserBox->setEnableKeys(true);
- mBrowserBox->setEnableTabs(true);
- mPlayButton->setEnabled(false);
-
- ContainerPlacer placer;
- placer = getPlacer(0, 0);
-
- placer(0, 0, mScrollArea, 5, 3).setPadding(3);
- placer(0, 3, mLabel, 5);
- placer(0, 4, mProgressBar, 5);
- placer(3, 5, mCancelButton);
- placer(4, 5, mPlayButton);
-
- Layout &layout = getLayout();
- layout.setRowHeight(0, LayoutType::SET);
-
- addKeyListener(this);
-
- if (mUpdateHost.empty())
- {
- const STD_VECTOR<std::string> &mirrors = settings.updateMirrors;
- if (mirrors.begin() != mirrors.end())
- mUpdateHost = *mirrors.begin();
- mSkipPatches = true;
- }
-
- loadWindowState();
-}
-
-void UpdaterWindow::postInit()
-{
- Window::postInit();
- setVisible(Visible_true);
- mCancelButton->requestFocus();
- removeProtocol(mUpdateServerPath);
-
- download();
-}
-
-UpdaterWindow::~UpdaterWindow()
-{
- if (mLoadUpdates)
- loadUpdates();
-
- if (mDownload != nullptr)
- {
- mDownload->cancel();
-
- delete2(mDownload)
- }
- free(mMemoryBuffer);
- delete2(mItemLinkHandler);
-}
-
-void UpdaterWindow::setProgress(const float p)
-{
- // Do delayed progress bar update, since Guichan isn't thread-safe
- MutexLocker lock(&mDownloadMutex);
- mDownloadProgress = p;
-}
-
-void UpdaterWindow::setLabel(const std::string &str)
-{
- // Do delayed label text update, since Guichan isn't thread-safe
- MutexLocker lock(&mDownloadMutex);
- mNewLabelCaption = str;
-}
-
-void UpdaterWindow::enable()
-{
- mCancelButton->setEnabled(false);
- mPlayButton->setEnabled(true);
- mPlayButton->requestFocus();
-
- if (client->getState() != State::GAME)
- {
- if ((mUpdateType & UpdateType::Close) != 0)
- client->setState(State::LOAD_DATA);
- }
- else
- {
- deleteSelf();
- }
-}
-
-void UpdaterWindow::action(const ActionEvent &event)
-{
- const std::string &eventId = event.getId();
- if (eventId == "cancel")
- {
- // Register the user cancel
- mUserCancel = true;
- // Skip the updating process
- if (mDownloadStatus != UpdateDownloadStatus::UPDATE_COMPLETE)
- {
- if (mDownload != nullptr)
- mDownload->cancel();
- mDownloadStatus = UpdateDownloadStatus::UPDATE_ERROR;
- }
- }
- else if (eventId == "play")
- {
- if (client->getState() != State::GAME)
- client->setState(State::LOAD_DATA);
- else
- deleteSelf();
- }
-}
-
-void UpdaterWindow::keyPressed(KeyEvent &event)
-{
- const InputActionT actionId = event.getActionId();
- if (actionId == InputAction::GUI_CANCEL)
- {
- action(ActionEvent(nullptr, mCancelButton->getActionEventId()));
- if (client->getState() != State::GAME)
- client->setState(State::LOGIN);
- else
- deleteSelf();
- }
- else if (actionId == InputAction::GUI_SELECT ||
- actionId == InputAction::GUI_SELECT2)
- {
- if (mDownloadStatus == UpdateDownloadStatus::UPDATE_COMPLETE ||
- mDownloadStatus == UpdateDownloadStatus::UPDATE_ERROR ||
- mDownloadStatus == UpdateDownloadStatus::UPDATE_IDLE)
- {
- action(ActionEvent(nullptr, mPlayButton->getActionEventId()));
- }
- else
- {
- action(ActionEvent(nullptr, mCancelButton->getActionEventId()));
- }
- }
-}
-
-void UpdaterWindow::loadNews()
-{
- if (mMemoryBuffer == nullptr)
- {
- logger->log1("Couldn't load news");
- return;
- }
-
- // Reallocate and include terminating 0 character
- mMemoryBuffer = static_cast<char*>(realloc(
- mMemoryBuffer, mDownloadedBytes + 1));
- if (mMemoryBuffer == nullptr)
- {
- logger->log1("Couldn't load news");
- return;
- }
- mMemoryBuffer[mDownloadedBytes] = '\0';
- mBrowserBox->clearRows();
-
- std::string newsName = mUpdatesDir + "/local/help/news.txt";
- mkdir_r((mUpdatesDir + "/local/help/").c_str());
- bool firstLine(true);
- std::ofstream file;
- std::stringstream ss(mMemoryBuffer);
- std::string line;
- file.open(newsName.c_str(), std::ios::out);
- int cnt = 0;
- const int maxNews = 50;
- while (std::getline(ss, line, '\n'))
- {
- cnt ++;
- if (firstLine)
- {
- firstLine = false;
- const size_t i = line.find("##9 Latest client version: ##6");
- if (i == 0u)
- continue;
-
- if (file.is_open())
- file << line << std::endl;
- if (cnt < maxNews)
- mBrowserBox->addRow(line);
- }
- else
- {
- if (file.is_open())
- file << line << std::endl;
- if (cnt < maxNews)
- mBrowserBox->addRow(line);
- }
- }
-
- file.close();
- if (cnt > maxNews)
- {
- mBrowserBox->addRow("");
- // TRANSLATORS: updater window checkbox
- mBrowserBox->addRow("news", _("Show all news (can be slow)"));
- mBrowserBox->addRow("");
- }
- // Free the memory buffer now that we don't need it anymore
- free(mMemoryBuffer);
- mMemoryBuffer = nullptr;
- mDownloadedBytes = 0;
-
- mBrowserBox->updateHeight();
- mScrollArea->setVerticalScrollAmount(0);
-}
-
-void UpdaterWindow::loadPatch()
-{
- if (mMemoryBuffer == nullptr)
- {
- logger->log1("Couldn't load patch");
- return;
- }
-
- // Reallocate and include terminating 0 character
- mMemoryBuffer = static_cast<char*>(
- realloc(mMemoryBuffer, mDownloadedBytes + 1));
- if (mMemoryBuffer == nullptr)
- {
- logger->log1("Couldn't load patch");
- return;
- }
- mMemoryBuffer[mDownloadedBytes] = '\0';
-
- std::string version;
-
- // Tokenize and add each line separately
- char *line = strtok(mMemoryBuffer, "\n");
- if (line != nullptr)
- {
- version = line;
- if (serverVersion < 1)
- {
- line = strtok(nullptr, "\n");
- if (line != nullptr)
- {
- mBrowserBox->addRow(strprintf("##9 Latest client version: "
- "##6ManaPlus %s##0", line), true);
- }
- }
- if (version > CHECK_VERSION)
- {
- mBrowserBox->addRow("", true);
-#if defined(ANDROID)
- const std::string url = "androidDownloadUrl";
- const std::string text = "androidDownloadUrl";
-#elif defined(WIN32)
- const std::string url = "windowsDownloadUrl";
- const std::string text = "windowsDownloadUrl";
-#else // defined(ANDROID)
-
- const std::string url = "otherDownloadUrl";
- const std::string text = "otherDownloadUrl";
-#endif // defined(ANDROID)
-
- mBrowserBox->addRow(std::string(" ##1[@@").append(
- branding.getStringValue(url)).append("|").append(
- branding.getStringValue(text)).append("@@]"), true);
- mBrowserBox->addRow("##1You can download it from", true);
- mBrowserBox->addRow("##1ManaPlus updated.", true);
- }
- else
- {
- mBrowserBox->addRow("You have latest client version.", true);
- }
- }
-
- // Free the memory buffer now that we don't need it anymore
- free(mMemoryBuffer);
- mMemoryBuffer = nullptr;
- mDownloadedBytes = 0;
-
- mBrowserBox->updateHeight();
- mScrollArea->setVerticalScrollAmount(0);
-}
-
-int UpdaterWindow::updateProgress(void *ptr,
- const DownloadStatusT status,
- size_t dt,
- const size_t dn)
-{
- UpdaterWindow *const uw = reinterpret_cast<UpdaterWindow *>(ptr);
- if (uw == nullptr)
- return -1;
-
- if (status == DownloadStatus::Complete)
- {
- uw->mDownloadComplete = true;
- }
- else if (status == DownloadStatus::Error ||
- status == DownloadStatus::Cancelled)
- {
- if (uw->mDownloadStatus == UpdateDownloadStatus::UPDATE_COMPLETE ||
- uw->mDownloadStatus == UpdateDownloadStatus::UPDATE_NEWS)
- { // ignoring error in last state (was UPDATE_PATCH)
- uw->mDownloadStatus = UpdateDownloadStatus::UPDATE_COMPLETE;
- uw->mDownloadComplete = true;
- free(uw->mMemoryBuffer);
- uw->mMemoryBuffer = nullptr;
- }
- else
- {
- uw->mDownloadStatus = UpdateDownloadStatus::UPDATE_ERROR;
- }
- }
-
- if (dt == 0u)
- dt = 1;
-
- float progress = static_cast<float>(dn) /
- static_cast<float>(dt);
-
- if (progress != progress)
- progress = 0.0F; // check for NaN
- if (progress < 0.0F)
- progress = 0.0F; // no idea how this could ever happen,
- // but why not check for it anyway.
- if (progress > 1.0F)
- progress = 1.0F;
-
- uw->setLabel(std::string(uw->mCurrentFile).append(" (")
- .append(toString(CAST_S32(progress * 100))).append("%)"));
-
- uw->setProgress(progress);
-
- if ((client->getState() != State::UPDATE &&
- client->getState() != State::GAME) ||
- uw->mDownloadStatus == UpdateDownloadStatus::UPDATE_ERROR)
- {
- // If the action was canceled return an error code to stop the mThread
- return -1;
- }
-
- return 0;
-}
-
-size_t UpdaterWindow::memoryWrite(void *ptr, size_t size,
- size_t nmemb, void *stream)
-{
- UpdaterWindow *const uw = reinterpret_cast<UpdaterWindow *>(stream);
- const size_t totalMem = size * nmemb;
- if (uw == nullptr)
- return 0;
- uw->mMemoryBuffer = static_cast<char*>(realloc(uw->mMemoryBuffer,
- CAST_SIZE(uw->mDownloadedBytes) + totalMem));
- if (uw->mMemoryBuffer != nullptr)
- {
- memcpy(&(uw->mMemoryBuffer[uw->mDownloadedBytes]), ptr, totalMem);
- uw->mDownloadedBytes += CAST_S32(totalMem);
- }
-
- return totalMem;
-}
-
-void UpdaterWindow::download()
-{
- if (mDownload != nullptr)
- {
- mDownload->cancel();
- delete mDownload;
- }
- if (mDownloadStatus == UpdateDownloadStatus::UPDATE_PATCH)
- {
- mDownload = new Net::Download(this,
- branding.getStringValue("updateMirror1") + mCurrentFile,
- &updateProgress,
- true, false, mValidateXml);
- for (int f = 2; f < 8; f ++)
- {
- const std::string url = branding.getStringValue(
- "updateMirror" + toString(f));
- if (!url.empty())
- mDownload->addMirror(url + mCurrentFile);
- }
- }
- else
- {
- mDownload = new Net::Download(this,
- urlJoin(mUpdateHost, mCurrentFile),
- &updateProgress,
- false, false, mValidateXml);
-
- if (mDownloadStatus == UpdateDownloadStatus::UPDATE_LIST2 ||
- mDownloadStatus == UpdateDownloadStatus::UPDATE_RESOURCES2)
- {
- const std::string str = urlJoin(mUpdateServerPath, mCurrentFile);
- mDownload->addMirror(updateServer3 + str);
- mDownload->addMirror(updateServer4 + str);
- mDownload->addMirror(updateServer5 + str);
- }
- else
- {
- const STD_VECTOR<std::string> &mirrors = settings.updateMirrors;
- FOR_EACH (STD_VECTOR<std::string>::const_iterator, it, mirrors)
- {
- mDownload->addMirror(pathJoin(*it,
- mCurrentFile));
- }
- }
- }
-
- if (mStoreInMemory)
- {
- mDownload->setWriteFunction(&UpdaterWindow::memoryWrite);
- }
- else
- {
- if (mDownloadStatus == UpdateDownloadStatus::UPDATE_RESOURCES)
- {
- mDownload->setFile(pathJoin(mUpdatesDir, mCurrentFile),
- mCurrentChecksum);
- }
- else
- {
- mDownload->setFile(pathJoin(mUpdatesDir,
- mCurrentFile));
- }
- }
-
- if (mDownloadStatus != UpdateDownloadStatus::UPDATE_RESOURCES)
- mDownload->noCache();
-
- setLabel(mCurrentFile + " (0%)");
- mDownloadComplete = false;
-
- mDownload->start();
-}
-
-void UpdaterWindow::loadUpdates()
-{
- if (mUpdateFiles.empty())
- { // updates not downloaded
- mUpdateFiles = loadXMLFile(pathJoin(mUpdatesDir, xmlUpdateFile),
- false);
- if (mUpdateFiles.empty())
- {
- logger->log("Warning this server does not have a"
- " %s file falling back to %s", xmlUpdateFile.c_str(),
- txtUpdateFile.c_str());
- mUpdateFiles = loadTxtFile(pathJoin(mUpdatesDir,
- txtUpdateFile));
- }
- }
-
- std::string fixPath = mUpdatesDir + "/fix";
- const unsigned sz = CAST_U32(mUpdateFiles.size());
- for (mUpdateIndex = 0; mUpdateIndex < sz; mUpdateIndex++)
- {
- const UpdateFile &file = mUpdateFiles[mUpdateIndex];
- if (!file.group.empty())
- continue;
- UpdaterWindow::addUpdateFile(mUpdatesDir,
- fixPath,
- file.name,
- Append_false);
- }
- loadManaPlusUpdates(mUpdatesDir);
- loadMods(mUpdatesDir, mUpdateFiles);
-}
-
-void UpdaterWindow::loadLocalUpdates(const std::string &dir)
-{
- STD_VECTOR<UpdateFile> updateFiles = loadXMLFile(
- pathJoin(dir, xmlUpdateFile),
- false);
-
- if (updateFiles.empty())
- {
- logger->log("Warning this server does not have a"
- " %s file falling back to %s", xmlUpdateFile.c_str(),
- txtUpdateFile.c_str());
- updateFiles = loadTxtFile(pathJoin(dir,
- txtUpdateFile));
- }
-
- const std::string fixPath = dir + "/fix";
- for (unsigned int updateIndex = 0,
- fsz = CAST_U32(updateFiles.size());
- updateIndex < fsz;
- updateIndex++)
- {
- const UpdateFile &file = updateFiles[updateIndex];
- if (!file.group.empty())
- continue;
- UpdaterWindow::addUpdateFile(dir,
- fixPath,
- file.name,
- Append_false);
- }
- loadManaPlusUpdates(dir);
- loadMods(dir, updateFiles);
-}
-
-void UpdaterWindow::unloadUpdates(const std::string &dir)
-{
- STD_VECTOR<UpdateFile> updateFiles = loadXMLFile(
- pathJoin(dir, xmlUpdateFile),
- true);
-
- if (updateFiles.empty())
- {
- updateFiles = loadTxtFile(pathJoin(dir,
- txtUpdateFile));
- }
-
- const std::string fixPath = dir + "/fix";
- for (unsigned int updateIndex = 0,
- fsz = CAST_U32(updateFiles.size());
- updateIndex < fsz;
- updateIndex++)
- {
- UpdaterWindow::removeUpdateFile(dir,
- fixPath,
- updateFiles[updateIndex].name);
- }
- unloadManaPlusUpdates(dir);
-}
-
-void UpdaterWindow::loadManaPlusUpdates(const std::string &dir)
-{
- std::string fixPath = dir + "/fix";
- STD_VECTOR<UpdateFile> updateFiles = loadXMLFile(
- pathJoin(fixPath, xmlUpdateFile),
- false);
-
- for (unsigned int updateIndex = 0,
- fsz = CAST_U32(updateFiles.size());
- updateIndex < fsz;
- updateIndex++)
- {
- const UpdateFile &file = updateFiles[updateIndex];
- if (!file.group.empty())
- continue;
- const std::string name = file.name;
- if (strStartWith(name, "manaplus_"))
- {
- struct stat statbuf;
- std::string fileName = pathJoin(fixPath,
- name);
- if (stat(fileName.c_str(), &statbuf) == 0)
- {
- VirtFs::mountZip(fileName,
- Append_false);
- }
- }
- }
-}
-
-void UpdaterWindow::unloadManaPlusUpdates(const std::string &dir)
-{
- const std::string fixPath = dir + "/fix";
- const STD_VECTOR<UpdateFile> updateFiles = loadXMLFile(
- pathJoin(fixPath, xmlUpdateFile),
- true);
-
- for (unsigned int updateIndex = 0,
- fsz = CAST_U32(updateFiles.size());
- updateIndex < fsz;
- updateIndex++)
- {
- std::string name = updateFiles[updateIndex].name;
- if (strStartWith(name, "manaplus_"))
- {
- struct stat statbuf;
- const std::string file = pathJoin(
- fixPath, name);
- if (stat(file.c_str(), &statbuf) == 0)
- VirtFs::unmountZip(file);
- }
- }
-}
-
-void UpdaterWindow::addUpdateFile(const std::string &restrict path,
- const std::string &restrict fixPath,
- const std::string &restrict file,
- const Append append)
-{
- const std::string tmpPath = pathJoin(path, file);
- if (append == Append_false)
- VirtFs::mountZip(tmpPath, append);
-
- const std::string fixFile = pathJoin(fixPath, file);
- struct stat statbuf;
- if (stat(fixFile.c_str(), &statbuf) == 0)
- VirtFs::mountZip(fixFile, append);
-
- if (append == Append_true)
- VirtFs::mountZip(tmpPath, append);
-}
-
-void UpdaterWindow::removeUpdateFile(const std::string &restrict path,
- const std::string &restrict fixPath,
- const std::string &restrict file)
-{
- VirtFs::unmountZip(pathJoin(path, file));
- const std::string fixFile = pathJoin(fixPath, file);
- struct stat statbuf;
- if (stat(fixFile.c_str(), &statbuf) == 0)
- VirtFs::unmountZip(fixFile);
-}
-
-void UpdaterWindow::logic()
-{
- BLOCK_START("UpdaterWindow::logic")
- // Update Scroll logic
- mScrollArea->logic();
-
- // Synchronize label caption when necessary
- {
- MutexLocker lock(&mDownloadMutex);
-
- if (mLabel->getCaption() != mNewLabelCaption)
- {
- mLabel->setCaption(mNewLabelCaption);
- mLabel->adjustSize();
- }
-
- mProgressBar->setProgress(mDownloadProgress);
- if (!mUpdateFiles.empty() &&
- CAST_SIZE(mUpdateIndex) <= mUpdateFiles.size())
- {
- mProgressBar->setText(strprintf("%u/%u", mUpdateIndex
- + mUpdateIndexOffset + 1, CAST_U32(
- mUpdateFiles.size()) + CAST_S32(
- mTempUpdateFiles.size()) + 1));
- }
- else
- {
- mProgressBar->setText("");
- }
- }
-
- switch (mDownloadStatus)
- {
- case UpdateDownloadStatus::UPDATE_ERROR:
- mBrowserBox->addRow("");
- // TRANSLATORS: update message
- mBrowserBox->addRow(_("##1 The update process is incomplete."));
- // TRANSLATORS: Continues "The update process is incomplete.".
- mBrowserBox->addRow(_("##1 It is strongly recommended that"));
- // TRANSLATORS: Begins "It is strongly recommended that".
- mBrowserBox->addRow(_("##1 you try again later."));
- if (mDownload != nullptr)
- mBrowserBox->addRow(mDownload->getError());
- mBrowserBox->updateHeight();
- mScrollArea->setVerticalScrollAmount(
- mScrollArea->getVerticalMaxScroll());
- mDownloadStatus = UpdateDownloadStatus::UPDATE_COMPLETE;
- break;
- case UpdateDownloadStatus::UPDATE_NEWS:
- if (mDownloadComplete)
- {
- // Parse current memory buffer as news and dispose of the data
- loadNews();
-
- mValidateXml = true;
- mCurrentFile = xmlUpdateFile;
- mStoreInMemory = false;
- mDownloadStatus = UpdateDownloadStatus::UPDATE_LIST;
- download(); // download() changes mDownloadComplete to false
- }
- break;
- case UpdateDownloadStatus::UPDATE_PATCH:
- if (mDownloadComplete)
- {
- // Parse current memory buffer as news and dispose of the data
- loadPatch();
-
- mUpdateHost = updateServer2 + mUpdateServerPath;
- mUpdatesDir = pathJoin(mUpdatesDir, "fix");
- mCurrentFile = xmlUpdateFile;
- mValidateXml = true;
- mStoreInMemory = false;
- mDownloadStatus = UpdateDownloadStatus::UPDATE_LIST2;
- download();
- }
- break;
-
- case UpdateDownloadStatus::UPDATE_LIST:
- if (mDownloadComplete)
- {
- if (mCurrentFile == xmlUpdateFile)
- {
- mUpdateFiles = loadXMLFile(pathJoin(
- mUpdatesDir, xmlUpdateFile),
- true);
-
- if (mUpdateFiles.empty())
- {
- logger->log("Warning this server does not have a %s"
- " file falling back to %s",
- xmlUpdateFile.c_str(),
- txtUpdateFile.c_str());
-
- // If the resources.xml file fails,
- // fall back onto a older version
- mCurrentFile = txtUpdateFile;
- mValidateXml = false;
- mStoreInMemory = false;
- mDownloadStatus = UpdateDownloadStatus::UPDATE_LIST;
- download();
- break;
- }
- }
- else if (mCurrentFile == txtUpdateFile)
- {
- mValidateXml = true;
- mUpdateFiles = loadTxtFile(pathJoin(mUpdatesDir,
- txtUpdateFile));
- }
- mStoreInMemory = false;
- mDownloadStatus = UpdateDownloadStatus::UPDATE_RESOURCES;
- }
- break;
- case UpdateDownloadStatus::UPDATE_RESOURCES:
- if (mDownloadComplete)
- {
- if (CAST_SIZE(mUpdateIndex) < mUpdateFiles.size())
- {
- UpdateFile thisFile = mUpdateFiles[mUpdateIndex];
- if (thisFile.type == "music"
- && !config.getBoolValue("download-music"))
- {
- mUpdateIndex++;
- break;
- }
- mCurrentFile = thisFile.name;
- std::string checksum;
- checksum = thisFile.hash;
- std::stringstream ss(checksum);
- ss >> std::hex >> mCurrentChecksum;
-
- std::ifstream temp(pathJoin(mUpdatesDir,
- mCurrentFile).c_str());
-
- mValidateXml = false;
- if (!temp.is_open() || !validateFile(pathJoin(
- mUpdatesDir, mCurrentFile),
- mCurrentChecksum))
- {
- temp.close();
- download();
- }
- else
- {
- temp.close();
- logger->log("%s already here", mCurrentFile.c_str());
- }
- mUpdateIndex++;
- }
- else
- {
- if (!mSkipPatches)
- {
- // Download of updates completed
- mCurrentFile = "latest.txt";
- mStoreInMemory = true;
- mDownloadStatus = UpdateDownloadStatus::UPDATE_PATCH;
- mValidateXml = false;
- download(); // download() changes
- // mDownloadComplete to false
- }
- else
- {
- mDownloadStatus =
- UpdateDownloadStatus::UPDATE_COMPLETE;
- }
- }
- }
- break;
- case UpdateDownloadStatus::UPDATE_LIST2:
- if (mDownloadComplete)
- {
- if (mCurrentFile == xmlUpdateFile)
- {
- mTempUpdateFiles = loadXMLFile(pathJoin(
- mUpdatesDir, xmlUpdateFile),
- true);
- }
- mUpdateIndexOffset = mUpdateIndex;
- mUpdateIndex = 0;
- mValidateXml = true;
- mStoreInMemory = false;
- mDownloadStatus = UpdateDownloadStatus::UPDATE_RESOURCES2;
- download();
- }
- break;
- case UpdateDownloadStatus::UPDATE_RESOURCES2:
- if (mDownloadComplete)
- {
- mValidateXml = false;
- if (CAST_SIZE(mUpdateIndex)
- < mTempUpdateFiles.size())
- {
- const UpdateFile thisFile = mTempUpdateFiles[mUpdateIndex];
- mCurrentFile = thisFile.name;
- std::string checksum;
- checksum = thisFile.hash;
- std::stringstream ss(checksum);
- ss >> std::hex >> mCurrentChecksum;
-
- std::ifstream temp((pathJoin(mUpdatesDir,
- mCurrentFile)).c_str());
-
- if (!temp.is_open() || !validateFile(pathJoin(
- mUpdatesDir, mCurrentFile),
- mCurrentChecksum))
- {
- temp.close();
- download();
- }
- else
- {
- temp.close();
- logger->log("%s already here", mCurrentFile.c_str());
- }
- mUpdateIndex++;
- }
- else
- {
- mUpdatesDir = mUpdatesDirReal;
- mDownloadStatus = UpdateDownloadStatus::UPDATE_COMPLETE;
- }
- }
- break;
- case UpdateDownloadStatus::UPDATE_COMPLETE:
- mUpdatesDir = mUpdatesDirReal;
- enable();
- // TRANSLATORS: updater window label
- setLabel(_("Completed"));
- mDownloadStatus = UpdateDownloadStatus::UPDATE_IDLE;
- break;
- case UpdateDownloadStatus::UPDATE_IDLE:
- break;
- default:
- logger->log("UpdaterWindow::logic unknown status: "
- + toString(CAST_U32(mDownloadStatus)));
- break;
- }
- BLOCK_END("UpdaterWindow::logic")
-}
-
-bool UpdaterWindow::validateFile(const std::string &filePath,
- const unsigned long hash)
-{
- FILE *const file = fopen(filePath.c_str(), "rb");
- if (file == nullptr)
- return false;
-
- const unsigned long adler = Net::Download::fadler32(file);
- fclose(file);
- return adler == hash;
-}
-
-unsigned long UpdaterWindow::getFileHash(const std::string &filePath)
-{
- int size = 0;
- const char *const buf = VirtFs::loadFile(filePath, size);
- if (buf == nullptr)
- return 0;
- unsigned long res = Net::Download::adlerBuffer(buf, size);
- delete [] buf;
- return res;
-}
-
-void UpdaterWindow::loadFile(std::string file)
-{
- mBrowserBox->clearRows();
- trim(file);
-
- StringVect lines;
- Files::loadTextFileLocal(mUpdatesDir + "/local/help/news.txt", lines);
-
- for (size_t i = 0, sz = lines.size(); i < sz; ++i)
- mBrowserBox->addRow(lines[i]);
- mBrowserBox->updateHeight();
-}
-
-void UpdaterWindow::loadMods(const std::string &dir,
- const STD_VECTOR<UpdateFile> &updateFiles)
-{
- ModDB::load();
- std::string modsString = serverConfig.getValue("mods", "");
- std::set<std::string> modsList;
- splitToStringSet(modsList, modsString, '|');
-
- const std::string fixPath = dir + "/fix";
- for (unsigned int updateIndex = 0,
- fsz = CAST_U32(updateFiles.size());
- updateIndex < fsz;
- updateIndex ++)
- {
- const UpdateFile &file = updateFiles[updateIndex];
- if (file.group.empty())
- continue;
- const std::set<std::string>::const_iterator
- it = modsList.find(file.group);
- if (it != modsList.end())
- {
- UpdaterWindow::addUpdateFile(dir,
- fixPath,
- file.name,
- Append_false);
- }
- }
-
- STD_VECTOR<UpdateFile> updateFiles2 = loadXMLFile(
- pathJoin(fixPath, xmlUpdateFile),
- true);
-
- for (unsigned int updateIndex = 0,
- fsz = CAST_U32(updateFiles2.size());
- updateIndex < fsz;
- updateIndex++)
- {
- const UpdateFile &file = updateFiles2[updateIndex];
- if (file.group.empty())
- continue;
- std::string name = file.name;
- if (strStartWith(name, "manaplus_"))
- {
- const std::set<std::string>::const_iterator
- it = modsList.find(file.group);
- if (it != modsList.end())
- {
- struct stat statbuf;
- std::string fileName = pathJoin(fixPath,
- name);
- if (stat(fileName.c_str(), &statbuf) == 0)
- {
- VirtFs::mountZip(fileName,
- Append_false);
- }
- }
- }
- }
-
- loadDirMods(dir + "/local/");
-}
-
-void UpdaterWindow::loadDirMods(const std::string &dir)
-{
- ModDB::load();
- const ModInfos &mods = ModDB::getAll();
-
- std::string modsString = serverConfig.getValue("mods", "");
- StringVect modsList;
- splitToStringVector(modsList, modsString, '|');
- FOR_EACH (StringVectCIter, it, modsList)
- {
- const std::string &name = *it;
- const ModInfoCIterator modIt = mods.find(name);
- if (modIt == mods.end())
- continue;
- const ModInfo *const mod = (*modIt).second;
- if (mod != nullptr)
- {
- const std::string &localDir = mod->getLocalDir();
- if (!localDir.empty())
- {
- VirtFs::mountDir(pathJoin(dir, localDir),
- Append_false);
- }
- }
- }
-}
-
-void UpdaterWindow::unloadMods(const std::string &dir)
-{
- const ModInfos &mods = ModDB::getAll();
- std::string modsString = serverConfig.getValue("mods", "");
- StringVect modsList;
- splitToStringVector(modsList, modsString, '|');
- FOR_EACH (StringVectCIter, it, modsList)
- {
- const std::string &name = *it;
- const ModInfoCIterator modIt = mods.find(name);
- if (modIt == mods.end())
- continue;
- const ModInfo *const mod = (*modIt).second;
- if (mod != nullptr)
- {
- const std::string &localDir = mod->getLocalDir();
- if (!localDir.empty())
- VirtFs::unmountDir(pathJoin(dir, localDir));
- }
- }
-}
-
-void UpdaterWindow::deleteSelf()
-{
- scheduleDelete();
- updaterWindow = nullptr;
-}
diff --git a/src/gui/windows/updaterwindow.h b/src/gui/windows/updaterwindow.h
deleted file mode 100644
index 661168a9f..000000000
--- a/src/gui/windows/updaterwindow.h
+++ /dev/null
@@ -1,252 +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_WINDOWS_UPDATERWINDOW_H
-#define GUI_WINDOWS_UPDATERWINDOW_H
-
-#include "enums/gui/updatedownloadstatus.h"
-
-#include "enums/net/downloadstatus.h"
-#include "enums/net/updatetype.h"
-
-#include "enums/simpletypes/append.h"
-
-#include "gui/widgets/window.h"
-
-#include "resources/updatefile.h"
-
-#include "utils/mutex.h"
-
-#include "listeners/actionlistener.h"
-#include "listeners/keylistener.h"
-
-class Button;
-class ItemLinkHandler;
-class Label;
-class ProgressBar;
-class ScrollArea;
-class StaticBrowserBox;
-
-namespace Net
-{
- class Download;
-} // namespace Net
-
-/**
- * Update progress window GUI
- *
- * \ingroup GUI
- */
-class UpdaterWindow final : public Window,
- public ActionListener,
- public KeyListener
-{
- public:
- /**
- * Constructor.
- *
- * @param updateHost Host where to get the updated files.
- * @param updatesDir Directory where to store updates (should be
- * absolute and already created).
- * @param applyUpdates If true, the update window will pass the updates
- * to teh resource manager.
- */
- UpdaterWindow(const std::string &restrict updateHost,
- const std::string &restrict updatesDir,
- const bool applyUpdates,
- const UpdateTypeT updateType);
-
- A_DELETE_COPY(UpdaterWindow)
-
- /**
- * Destructor
- */
- ~UpdaterWindow();
-
- void postInit() override final;
-
- /**
- * Set's progress bar status
- */
- void setProgress(const float p);
-
- /**
- * Set's label above progress
- */
- void setLabel(const std::string &);
-
- /**
- * Enables play button
- */
- void enable();
-
- /**
- * Loads and display news. Assumes the news file contents have been
- * loaded into the memory buffer.
- */
- void loadNews();
-
- void loadPatch();
-
- void action(const ActionEvent &event) override final;
-
- void keyPressed(KeyEvent &event) override final;
-
- void logic() override final;
-
- void loadFile(std::string file);
-
- void deleteSelf();
-
- static void loadLocalUpdates(const std::string &dir);
-
- static void unloadUpdates(const std::string &dir);
-
- static void addUpdateFile(const std::string &restrict path,
- const std::string &restrict fixPath,
- const std::string &restrict file,
- const Append append);
-
- static void removeUpdateFile(const std::string &restrict path,
- const std::string &restrict fixPath,
- const std::string &filerestrict);
-
- static void loadManaPlusUpdates(const std::string &dir);
-
- static void unloadManaPlusUpdates(const std::string &dir);
-
- static unsigned long getFileHash(const std::string &filePath);
-
- static void loadMods(const std::string &dir,
- const STD_VECTOR<UpdateFile> &updateFiles);
-
- static void loadDirMods(const std::string &dir);
-
- static void unloadMods(const std::string &dir);
-
- private:
- void download();
-
- /**
- * Loads the updates this window has gotten into the resource manager
- */
- void loadUpdates();
-
- /**
- * A download callback for progress updates.
- */
- static int updateProgress(void *ptr,
- const DownloadStatusT status,
- size_t dt,
- const size_t dn);
-
- /**
- * A libcurl callback for writing to memory.
- */
- static size_t memoryWrite(void *ptr, size_t size, size_t nmemb,
- void *stream);
-
- static bool validateFile(const std::string &filePath,
- const unsigned long hash) A_WARN_UNUSED;
-
- /** The new progress value to be set in the logic method. */
- float mDownloadProgress;
-
- /** Host where we get the updated files. */
- std::string mUpdateHost;
-
- /** Place where the updates are stored (absolute path). */
- std::string mUpdatesDir;
-
- std::string mUpdatesDirReal;
-
- /** The file currently downloading. */
- std::string mCurrentFile;
-
- /** The new label caption to be set in the logic method. */
- std::string mNewLabelCaption;
-
- // The mutex used to guard access to mNewLabelCaption
- // and mDownloadProgress.
- Mutex mDownloadMutex;
-
- /** The Adler32 checksum of the file currently downloading. */
- unsigned long mCurrentChecksum;
-
- /** Buffer for files downloaded to memory. */
- char *mMemoryBuffer;
-
- /** Download handle. */
- Net::Download *mDownload;
-
- /** List of files to download. */
- STD_VECTOR<UpdateFile> mUpdateFiles;
-
- /** List of temp files to download. */
- STD_VECTOR<UpdateFile> mTempUpdateFiles;
-
- std::string mUpdateServerPath;
-
- ItemLinkHandler *mItemLinkHandler A_NONNULLPOINTER;
- Label *mLabel A_NONNULLPOINTER;
- Button *mCancelButton A_NONNULLPOINTER;
- Button *mPlayButton A_NONNULLPOINTER;
- ProgressBar *mProgressBar A_NONNULLPOINTER;
- StaticBrowserBox *mBrowserBox A_NONNULLPOINTER;
- ScrollArea *mScrollArea A_NONNULLPOINTER;
-
- /** Status of the current download. */
- UpdateDownloadStatusT mDownloadStatus;
-
- /** Byte count currently downloaded in mMemoryBuffer. */
- int mDownloadedBytes;
-
- /** Index of the file to be downloaded. */
- unsigned int mUpdateIndex;
-
- /** Index offset for disaplay downloaded file. */
- unsigned int mUpdateIndexOffset;
-
- UpdateTypeT mUpdateType;
-
- /** A flag to indicate whether to use a memory buffer or a regular
- * file.
- */
- bool mStoreInMemory;
-
- /** Flag that show if current download is complete. */
- bool mDownloadComplete;
-
- /** Flag that show if the user has canceled the update. */
- bool mUserCancel;
-
- /** Tells ~UpdaterWindow() if it should load updates */
- bool mLoadUpdates;
-
- bool mValidateXml;
-
- bool mSkipPatches;
-};
-
-extern UpdaterWindow *updaterWindow;
-
-#endif // GUI_WINDOWS_UPDATERWINDOW_H
diff --git a/src/gui/windows/whoisonline.cpp b/src/gui/windows/whoisonline.cpp
deleted file mode 100644
index e123d3941..000000000
--- a/src/gui/windows/whoisonline.cpp
+++ /dev/null
@@ -1,909 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 Andrei Karas
- * 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 "gui/windows/whoisonline.h"
-
-#include "actormanager.h"
-#include "configuration.h"
-#include "guild.h"
-#include "party.h"
-#ifdef TMWA_SUPPORT
-#include "settings.h"
-#endif // TMWA_SUPPORT
-
-#include "gui/onlineplayer.h"
-#include "gui/popupmanager.h"
-#include "gui/viewport.h"
-
-#include "gui/popups/popupmenu.h"
-
-#include "gui/windows/chatwindow.h"
-#include "gui/windows/setupwindow.h"
-#include "gui/windows/socialwindow.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/scrollarea.h"
-#include "gui/widgets/staticbrowserbox.h"
-
-#include "being/beingflag.h"
-#include "being/localplayer.h"
-#include "being/playerrelations.h"
-
-#ifdef TMWA_SUPPORT
-#include "net/download.h"
-#endif // TMWA_SUPPORT
-#include "net/packetlimiter.h"
-#include "net/playerhandler.h"
-#include "net/serverfeatures.h"
-
-#include "utils/foreach.h"
-#include "utils/gettext.h"
-#include "utils/sdlhelper.h"
-
-#ifdef TMWA_SUPPORT
-#include "net/net.h"
-#else // TMWA_SUPPORT
-#include <curl/curl.h>
-#endif // TMWA_SUPPORT
-
-#include "debug.h"
-
-#ifdef free
-#undef free
-#endif // free
-
-#ifdef malloc
-#undef malloc
-#endif // malloc
-
-WhoIsOnline *whoIsOnline = nullptr;
-
-namespace
-{
- class NameFunctuator final
- {
- public:
- A_DEFAULT_COPY(NameFunctuator)
-
- bool operator()(const OnlinePlayer *left,
- const OnlinePlayer *right) const
- {
- return (compareStrI(left->getNick(), right->getNick()) < 0);
- }
- } nameCompare;
-} // namespace
-
-WhoIsOnline::WhoIsOnline() :
- // TRANSLATORS: who is online window name
- Window(_("Who Is Online - Updating"),
- Modal_false,
- nullptr,
- "whoisonline.xml"),
- mUpdateTimer(0),
- mThread(nullptr),
- mMemoryBuffer(nullptr),
- mCurlError(new char[CURL_ERROR_SIZE]),
- mBrowserBox(new StaticBrowserBox(this, Opaque_true,
- "onlinebrowserbox.xml")),
- mScrollArea(new ScrollArea(this, mBrowserBox, Opaque_false)),
- // TRANSLATORS: who is online. button.
- mUpdateButton(new Button(this, _("Update"), "update", this)),
- mOnlinePlayers(),
- mOnlineNicks(),
- mFriends(),
- mNeutral(),
- mDisregard(),
- mEnemy(),
- mDownloadedBytes(0),
- mDownloadStatus(UPDATE_LIST),
- mDownloadComplete(true),
- mAllowUpdate(true),
- mShowLevel(false),
- mUpdateOnlineList(config.getBoolValue("updateOnlineList")),
- mGroupFriends(true),
-#ifdef TMWA_SUPPORT
- mWebList(Net::getNetworkType() == ServerType::TMWATHENA),
-#endif
- mServerSideList(serverFeatures->haveServerOnlineList())
-{
- mCurlError[0] = 0;
- setWindowName("WhoIsOnline");
-}
-
-void WhoIsOnline::postInit()
-{
- Window::postInit();
- const int h = 350;
- const int w = 200;
- setDefaultSize(w, h, ImagePosition::CENTER);
-
- setVisible(Visible_false);
- setCloseButton(true);
- setResizable(true);
- setStickyButtonLock(true);
- setSaveVisible(true);
-
- if (setupWindow != nullptr)
- setupWindow->registerWindowForReset(this);
-
- mUpdateButton->setEnabled(false);
- mUpdateButton->setDimension(Rect(5, 5, w - 10, 20 + 5));
-
- mBrowserBox->setOpaque(Opaque_false);
- mScrollArea->setDimension(Rect(5, 20 + 10, w - 10, h - 10 - 30));
- mScrollArea->setSize(w - 10, h - 10 - 30);
- mScrollArea->setSelectable(false);
- mBrowserBox->setLinkHandler(this);
-
- add(mUpdateButton);
- add(mScrollArea);
-
- setLocationRelativeTo(getParent());
-
- loadWindowState();
- enableVisibleSound(true);
-
- download();
-
- widgetResized(Event(nullptr));
- config.addListener("updateOnlineList", this);
- config.addListener("groupFriends", this);
- mGroupFriends = config.getBoolValue("groupFriends");
-}
-
-WhoIsOnline::~WhoIsOnline()
-{
- config.removeListeners(this);
- CHECKLISTENERS
-
- SDL::WaitThread(mThread);
- mThread = nullptr;
- free(mMemoryBuffer);
- mMemoryBuffer = nullptr;
-
- // Remove possibly leftover temporary download
- delete []mCurlError;
-
- FOR_EACH (std::set<OnlinePlayer*>::iterator, itd, mOnlinePlayers)
- delete *itd;
- mOnlinePlayers.clear();
- mOnlineNicks.clear();
-}
-
-void WhoIsOnline::handleLink(const std::string& link, MouseEvent *event)
-{
- if ((event == nullptr) || event->getButton() == MouseButton::LEFT)
- {
- if (chatWindow != nullptr)
- {
- const std::string text = decodeLinkText(link);
- if (config.getBoolValue("whispertab"))
- {
- chatWindow->localChatInput("/q " + text);
- }
- else
- {
- chatWindow->addInputText(std::string("/w \"").append(
- text).append("\" "));
- }
- }
- }
- else if (event->getButton() == MouseButton::RIGHT)
- {
- if ((localPlayer != nullptr) && link == localPlayer->getName())
- return;
-
- if (popupMenu != nullptr)
- {
- if (actorManager != nullptr)
- {
- const std::string text = decodeLinkText(link);
- Being *const being = actorManager->findBeingByName(
- text, ActorType::Player);
-
- if ((being != nullptr) && (popupManager != nullptr))
- {
- popupMenu->showPopup(viewport->mMouseX,
- viewport->mMouseY,
- being);
- return;
- }
- }
- popupMenu->showPlayerPopup(link);
- }
- }
-}
-
-void WhoIsOnline::updateWindow(size_t numOnline)
-{
- // Set window caption
- // TRANSLATORS: who is online window name
- setCaption(_("Who Is Online - ") + toString(CAST_U32(numOnline)));
-
- // List the online people
- std::sort(mFriends.begin(), mFriends.end(), nameCompare);
- std::sort(mNeutral.begin(), mNeutral.end(), nameCompare);
- std::sort(mDisregard.begin(), mDisregard.end(), nameCompare);
- bool addedFromSection(false);
- FOR_EACH (STD_VECTOR<OnlinePlayer*>::const_iterator, it, mFriends)
- {
- mBrowserBox->addRow((*it)->getText());
- addedFromSection = true;
- }
- if (addedFromSection == true)
- {
- mBrowserBox->addRow("---");
- addedFromSection = false;
- }
- FOR_EACH (STD_VECTOR<OnlinePlayer*>::const_iterator, it, mEnemy)
- {
- mBrowserBox->addRow((*it)->getText());
- addedFromSection = true;
- }
- if (addedFromSection == true)
- {
- mBrowserBox->addRow("---");
- addedFromSection = false;
- }
- FOR_EACH (STD_VECTOR<OnlinePlayer*>::const_iterator, it, mNeutral)
- {
- mBrowserBox->addRow((*it)->getText());
- addedFromSection = true;
- }
- if (addedFromSection == true && !mDisregard.empty())
- mBrowserBox->addRow("---");
-
- FOR_EACH (STD_VECTOR<OnlinePlayer*>::const_iterator, it, mDisregard)
- mBrowserBox->addRow((*it)->getText());
-
- if (mScrollArea->getVerticalMaxScroll() <
- mScrollArea->getVerticalScrollAmount())
- {
- mScrollArea->setVerticalScrollAmount(
- mScrollArea->getVerticalMaxScroll());
- }
- mBrowserBox->updateHeight();
-}
-
-void WhoIsOnline::handlerPlayerRelation(const std::string &nick,
- OnlinePlayer *const player)
-{
- if (player == nullptr)
- return;
- switch (playerRelations.getRelation(nick))
- {
- case Relation::NEUTRAL:
- default:
- setNeutralColor(player);
- mNeutral.push_back(player);
- break;
-
- case Relation::FRIEND:
- player->setText("2");
- if (mGroupFriends)
- mFriends.push_back(player);
- else
- mNeutral.push_back(player);
- break;
-
- case Relation::DISREGARDED:
- case Relation::BLACKLISTED:
- player->setText("8");
- mDisregard.push_back(player);
- break;
-
- case Relation::ENEMY2:
- player->setText("1");
- mEnemy.push_back(player);
- break;
-
- case Relation::IGNORED:
- case Relation::ERASED:
- // Ignore the ignored.
- break;
- }
-}
-
-void WhoIsOnline::loadList(const STD_VECTOR<OnlinePlayer*> &list)
-{
- mBrowserBox->clearRows();
- const size_t numOnline = list.size();
-
- FOR_EACH (std::set<OnlinePlayer*>::iterator, itd, mOnlinePlayers)
- delete *itd;
- mOnlinePlayers.clear();
- mOnlineNicks.clear();
-
- mShowLevel = config.getBoolValue("showlevel");
-
- FOR_EACH (STD_VECTOR<OnlinePlayer*>::const_iterator, it, list)
- {
- OnlinePlayer *player = *it;
- const std::string nick = player->getNick();
- mOnlinePlayers.insert(player);
- mOnlineNicks.insert(nick);
-
- if (!mShowLevel)
- player->setLevel(0);
-
- handlerPlayerRelation(nick, player);
- }
-
- updateWindow(numOnline);
- if (!mOnlineNicks.empty())
- {
- if (chatWindow != nullptr)
- chatWindow->updateOnline(mOnlineNicks);
- if (socialWindow != nullptr)
- socialWindow->updateActiveList();
- if (actorManager != nullptr)
- actorManager->updateSeenPlayers(mOnlineNicks);
- }
- updateSize();
- mFriends.clear();
- mNeutral.clear();
- mDisregard.clear();
- mEnemy.clear();
-}
-
-#ifdef TMWA_SUPPORT
-void WhoIsOnline::loadWebList()
-{
- if (mMemoryBuffer == nullptr)
- return;
-
- // Reallocate and include terminating 0 character
- mMemoryBuffer = static_cast<char*>(
- realloc(mMemoryBuffer, mDownloadedBytes + 1));
- if (mMemoryBuffer == nullptr)
- return;
-
- mMemoryBuffer[mDownloadedBytes] = '\0';
-
- mBrowserBox->clearRows();
- bool listStarted(false);
- std::string lineStr;
- size_t numOnline(0U);
-
- // Tokenize and add each line separately
- char *line = strtok(mMemoryBuffer, "\n");
- const std::string gmText("(GM)");
- const std::string gmText2("(gm)");
-
- FOR_EACH (std::set<OnlinePlayer*>::iterator, itd, mOnlinePlayers)
- delete *itd;
-
- mOnlinePlayers.clear();
- mOnlineNicks.clear();
-
- mShowLevel = config.getBoolValue("showlevel");
-
- while (line != nullptr)
- {
- std::string nick;
- lineStr = line;
- trim(lineStr);
- if (listStarted == true)
- {
- if (lineStr.find(" users are online.") == std::string::npos)
- {
- if (lineStr.length() > 24)
- {
- nick = lineStr.substr(0, 24);
- lineStr = lineStr.substr(25);
- }
- else
- {
- nick = lineStr;
- lineStr.clear();
- }
- trim(nick);
-
- bool isGM(false);
- size_t pos = lineStr.find(gmText, 0);
- if (pos != std::string::npos)
- {
- lineStr = lineStr.substr(pos + gmText.length());
- isGM = true;
- }
- else
- {
- pos = lineStr.find(gmText2, 0);
- if (pos != std::string::npos)
- {
- lineStr = lineStr.substr(pos + gmText.length());
- isGM = true;
- }
- }
-
- trim(lineStr);
- pos = lineStr.find('/', 0);
-
- if (pos != std::string::npos)
- lineStr = lineStr.substr(0, pos);
-
- int level = 0;
- if (!lineStr.empty())
- level = atoi(lineStr.c_str());
-
- if (actorManager != nullptr)
- {
- Being *const being = actorManager->findBeingByName(
- nick, ActorType::Player);
- if (being != nullptr)
- {
- if (level > 0)
- {
- being->setLevel(level);
- being->updateName();
- }
- else
- {
- if (being->getLevel() > 1)
- level = being->getLevel();
- }
- }
- }
-
- if (!mShowLevel)
- level = 0;
-
- OnlinePlayer *const player = new OnlinePlayer(nick,
- CAST_U8(255), level,
- Gender::UNSPECIFIED, -1);
- mOnlinePlayers.insert(player);
- mOnlineNicks.insert(nick);
-
- if (isGM)
- player->setIsGM(true);
-
- numOnline++;
- handlerPlayerRelation(nick, player);
- }
- }
- else if (lineStr.find("------------------------------")
- != std::string::npos)
- {
- listStarted = true;
- }
- line = strtok(nullptr, "\n");
- }
-
- updateWindow(numOnline);
- mBrowserBox->updateHeight();
-
- // Free the memory buffer now that we don't need it anymore
- free(mMemoryBuffer);
- mMemoryBuffer = nullptr;
- mFriends.clear();
- mNeutral.clear();
- mDisregard.clear();
- mEnemy.clear();
-}
-
-size_t WhoIsOnline::memoryWrite(void *restrict ptr,
- size_t size,
- size_t nmemb,
- FILE *restrict stream)
-{
- if (stream == nullptr)
- return 0;
-
- WhoIsOnline *restrict const wio =
- reinterpret_cast<WhoIsOnline *restrict>(stream);
- const size_t totalMem = size * nmemb;
- wio->mMemoryBuffer = static_cast<char*>(realloc(wio->mMemoryBuffer,
- CAST_SIZE(wio->mDownloadedBytes) + totalMem));
- if (wio->mMemoryBuffer != nullptr)
- {
- memcpy(&(wio->mMemoryBuffer[wio->mDownloadedBytes]), ptr, totalMem);
- wio->mDownloadedBytes += CAST_S32(totalMem);
- }
-
- return totalMem;
-}
-
-int WhoIsOnline::downloadThread(void *ptr)
-{
- int attempts = 0;
- WhoIsOnline *const wio = reinterpret_cast<WhoIsOnline *>(ptr);
- if (wio == nullptr)
- return 0;
- CURLcode res;
- const std::string url(settings.onlineListUrl + "/online.txt");
-
- while (attempts < 1 && !wio->mDownloadComplete)
- {
- CURL *curl = curl_easy_init();
- if (curl != nullptr)
- {
- if (!wio->mAllowUpdate)
- {
- curl_easy_cleanup(curl);
- curl = nullptr;
- break;
- }
- wio->mDownloadedBytes = 0;
- curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
- curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1);
- curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION,
- &WhoIsOnline::memoryWrite);
- curl_easy_setopt(curl, CURLOPT_WRITEDATA, ptr);
-
- curl_easy_setopt(curl,
- CURLOPT_USERAGENT,
- settings.userAgent.c_str());
-
- curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, wio->mCurlError);
- curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
- curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1);
- curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, ptr);
-
-#if LIBCURL_VERSION_NUM >= 0x070a00
- curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
-#endif // LIBCURL_VERSION_NUM >= 0x070a00
- curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 7);
- curl_easy_setopt(curl, CURLOPT_TIMEOUT, 30);
- Net::Download::addHeaders(curl);
- Net::Download::addProxy(curl);
- Net::Download::secureCurl(curl);
-
- // Make sure the resources2.txt and news.txt aren't cached,
- // in order to always get the latest version.
- struct curl_slist *pHeaders = nullptr;
- pHeaders = curl_slist_append(
- pHeaders, "pragma: no-cache");
- pHeaders = curl_slist_append(pHeaders,
- "Cache-Control: no-cache");
- curl_easy_setopt(curl, CURLOPT_HTTPHEADER, pHeaders);
-
- if ((res = curl_easy_perform(curl)) != 0)
- {
- wio->mDownloadStatus = UPDATE_ERROR;
- PRAGMA45(GCC diagnostic push)
- PRAGMA45(GCC diagnostic ignored "-Wswitch-enum")
- switch (res)
- {
- case CURLE_COULDNT_CONNECT:
- default:
- std::cerr << "curl error "
- << CAST_U32(res) << ": "
- << wio->mCurlError << " host: "
- << url.c_str() << std::endl;
- break;
- }
- PRAGMA45(GCC diagnostic pop)
- attempts++;
- curl_easy_cleanup(curl);
- curl_slist_free_all(pHeaders);
- curl = nullptr;
- continue;
- }
-
- curl_easy_cleanup(curl);
- curl_slist_free_all(pHeaders);
-
- // It's stored in memory, we're done
- wio->mDownloadComplete = true;
- }
- if (!wio->mAllowUpdate)
- break;
- attempts++;
- }
-
- if (!wio->mDownloadComplete)
- wio->mDownloadStatus = UPDATE_ERROR;
- return 0;
-}
-#endif // TMWA_SUPPORT
-
-void WhoIsOnline::download()
-{
- if (mServerSideList)
- {
- if (PacketLimiter::limitPackets(PacketType::PACKET_ONLINELIST))
- playerHandler->requestOnlineList();
- }
-#ifdef TMWA_SUPPORT
- else if (mWebList)
- {
- mDownloadComplete = true;
- SDL::WaitThread(mThread);
- mThread = nullptr;
- mDownloadComplete = false;
- mThread = SDL::createThread(&WhoIsOnline::downloadThread,
- "whoisonline", this);
- if (mThread == nullptr)
- mDownloadStatus = UPDATE_ERROR;
- }
-#endif // TMWA_SUPPORT
-}
-
-void WhoIsOnline::logic()
-{
- BLOCK_START("WhoIsOnline::logic")
- mScrollArea->logic();
- BLOCK_END("WhoIsOnline::logic")
-}
-
-void WhoIsOnline::slowLogic()
-{
- if (!mAllowUpdate)
- return;
-
- BLOCK_START("WhoIsOnline::slowLogic")
- if (mUpdateTimer == 0)
- mUpdateTimer = cur_time;
-
- const double timeDiff = difftime(cur_time, mUpdateTimer);
- const int timeLimit = isWindowVisible() ? 20 : 120;
-
- if (mUpdateOnlineList && timeDiff >= timeLimit
- && mDownloadStatus != UPDATE_LIST)
- {
- if (mDownloadComplete == true)
- {
- // TRANSLATORS: who is online window name
- setCaption(_("Who Is Online - Updating"));
- mUpdateTimer = 0;
- mDownloadStatus = UPDATE_LIST;
- download();
- }
- }
-
-#ifdef TMWA_SUPPORT
- switch (mDownloadStatus)
- {
- case UPDATE_ERROR:
- logger->assertLog("Failed to fetch the online list:");
- if (mCurlError != nullptr)
- logger->assertLog("%s", mCurlError);
- mDownloadStatus = UPDATE_COMPLETE;
- // TRANSLATORS: who is online window name
- setCaption(_("Who Is Online - error"));
- mUpdateButton->setEnabled(true);
- mUpdateTimer = cur_time + 240;
- mDownloadComplete = true;
- updateSize();
- break;
- case UPDATE_LIST:
- if (mDownloadComplete == true)
- {
- loadWebList();
- mDownloadStatus = UPDATE_COMPLETE;
- mUpdateButton->setEnabled(true);
- mUpdateTimer = 0;
- updateSize();
- if (!mOnlineNicks.empty())
- {
- if (chatWindow != nullptr)
- chatWindow->updateOnline(mOnlineNicks);
- if (socialWindow != nullptr)
- socialWindow->updateActiveList();
- if (actorManager != nullptr)
- actorManager->updateSeenPlayers(mOnlineNicks);
- }
- }
- break;
- case UPDATE_COMPLETE:
- default:
- break;
- }
-#endif // TMWA_SUPPORT
-
- BLOCK_END("WhoIsOnline::slowLogic")
-}
-
-void WhoIsOnline::action(const ActionEvent &event)
-{
- if (event.getId() == "update")
- {
-#ifdef TMWA_SUPPORT
- if (!mServerSideList)
- {
- if (mDownloadStatus == UPDATE_COMPLETE)
- {
- mUpdateTimer = cur_time - 20;
- if (mUpdateButton != nullptr)
- mUpdateButton->setEnabled(false);
- // TRANSLATORS: who is online window name
- setCaption(_("Who Is Online - Update"));
- SDL::WaitThread(mThread);
- mThread = nullptr;
- mDownloadComplete = true;
- }
- }
- else
-#endif // TMWA_SUPPORT
- {
- if (PacketLimiter::limitPackets(PacketType::PACKET_ONLINELIST))
- {
- mUpdateTimer = cur_time;
- playerHandler->requestOnlineList();
- }
- }
- }
-}
-
-void WhoIsOnline::widgetResized(const Event &event)
-{
- Window::widgetResized(event);
- updateSize();
-}
-
-void WhoIsOnline::updateSize()
-{
- const Rect area = getChildrenArea();
- if (mUpdateButton != nullptr)
- mUpdateButton->setWidth(area.width - 10);
-
- if (mScrollArea != nullptr)
- mScrollArea->setSize(area.width - 10, area.height - 10 - 30);
-}
-
-const std::string WhoIsOnline::prepareNick(const std::string &restrict nick,
- const int level,
- const std::string &restrict
- color) const
-{
- const std::string text = encodeLinkText(nick);
- if (mShowLevel && level > 1)
- {
- return strprintf("@@%s|##%s%s (%d)@@", text.c_str(),
- color.c_str(), text.c_str(), level);
- }
- return strprintf("@@%s|##%s%s@@", text.c_str(),
- color.c_str(), text.c_str());
-}
-
-void WhoIsOnline::optionChanged(const std::string &name)
-{
- if (name == "updateOnlineList")
- mUpdateOnlineList = config.getBoolValue("updateOnlineList");
- else if (name == "groupFriends")
- mGroupFriends = config.getBoolValue("groupFriends");
-}
-
-void WhoIsOnline::setNeutralColor(OnlinePlayer *const player)
-{
- if (player == nullptr)
- return;
-
- if ((actorManager != nullptr) && (localPlayer != nullptr))
- {
- const std::string &nick = player->getNick();
- if (nick == localPlayer->getName())
- {
- player->setText("s");
- return;
- }
- if (localPlayer->isInParty())
- {
- const Party *const party = localPlayer->getParty();
- if (party != nullptr)
- {
- if (party->getMember(nick) != nullptr)
- {
- player->setText("P");
- return;
- }
- }
- }
-
- const Being *const being = actorManager->findBeingByName(nick);
- if (being != nullptr)
- {
- const Guild *const guild2 = localPlayer->getGuild();
- if (guild2 != nullptr)
- {
- const Guild *const guild1 = being->getGuild();
- if (guild1 != nullptr)
- {
- if (guild1->getId() == guild2->getId()
- || (guild2->getMember(nick) != nullptr))
- {
- player->setText("U");
- return;
- }
- }
- else if (guild2->isMember(nick))
- {
- player->setText("U");
- return;
- }
- }
- }
- const Guild *const guild3 = Guild::getGuild(1);
- if ((guild3 != nullptr) && guild3->isMember(nick))
- {
- player->setText("U");
- return;
- }
- }
- player->setText("0");
-}
-
-void WhoIsOnline::getPlayerNames(StringVect &names)
-{
- names.clear();
- FOR_EACH (std::set<std::string>::const_iterator, it, mOnlineNicks)
- names.push_back(*it);
-}
-
-void OnlinePlayer::setText(std::string color)
-{
- mText.clear();
-
- if (mStatus != 255 && (actorManager != nullptr))
- {
- Being *const being = actorManager->findBeingByName(
- mNick, ActorType::Player);
- if (being != nullptr)
- {
- being->setState(mStatus);
- // for now highlight versions > 3
- if (mVersion > 3)
- being->setAdvanced(true);
- }
- }
-
- if ((mStatus != 255 && ((mStatus & BeingFlag::GM) != 0)) || mIsGM)
- mText.append("(GM) ");
-
- if (mLevel > 0)
- mText.append(strprintf("%d", mLevel));
-
- if (mGender == Gender::FEMALE)
- mText.append("\u2640");
- else if (mGender == Gender::MALE)
- mText.append("\u2642");
-
- if (mStatus > 0 && mStatus != 255)
- {
- if ((mStatus & BeingFlag::SHOP) != 0)
- mText.append("$");
- if ((mStatus & BeingFlag::AWAY) != 0)
- {
- // TRANSLATORS: this away status writed in player nick
- mText.append(_("A"));
- }
- if ((mStatus & BeingFlag::INACTIVE) != 0)
- {
- // TRANSLATORS: this inactive status writed in player nick
- mText.append(_("I"));
- }
-
- if (((mStatus & BeingFlag::GM) != 0) && color == "0")
- color = "2";
- }
- else if (mIsGM && color == "0")
- {
- color = "2";
- }
-
- if (mVersion > 0)
- mText.append(strprintf(" - %d", mVersion));
-
- const std::string text = encodeLinkText(mNick);
- mText = strprintf("@@%s|##%s%s %s@@", text.c_str(), color.c_str(),
- text.c_str(), mText.c_str());
-}
diff --git a/src/gui/windows/whoisonline.h b/src/gui/windows/whoisonline.h
deleted file mode 100644
index afdb43785..000000000
--- a/src/gui/windows/whoisonline.h
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 Andrei Karas
- * 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_WINDOWS_WHOISONLINE_H
-#define GUI_WINDOWS_WHOISONLINE_H
-
-#include "gui/widgets/linkhandler.h"
-#include "gui/widgets/window.h"
-
-#include "listeners/actionlistener.h"
-
-class Button;
-class OnlinePlayer;
-class ScrollArea;
-class StaticBrowserBox;
-
-/**
- * Update progress window GUI
- *
- * \ingroup GUI
- */
-class WhoIsOnline final : public Window,
- public LinkHandler,
- public ActionListener,
- public ConfigListener
-{
- public:
- /**
- * Constructor.
- */
- WhoIsOnline();
-
- A_DELETE_COPY(WhoIsOnline)
-
- /**
- * Destructor
- */
- ~WhoIsOnline();
-
- void postInit() override final;
-
-#ifdef TMWA_SUPPORT
- /**
- * Loads and display online list from the memory buffer.
- */
- void loadWebList();
-#endif // TMWA_SUPPORT
-
- void loadList(const STD_VECTOR<OnlinePlayer*> &list);
-
- void handleLink(const std::string& link,
- MouseEvent *event) override final;
-
- void logic() override final;
-
- void slowLogic();
-
- void action(const ActionEvent &event) override final;
-
- void widgetResized(const Event &event) override final;
-
- const std::set<OnlinePlayer*> &getOnlinePlayers() const noexcept2
- A_WARN_UNUSED
- { return mOnlinePlayers; }
-
- const std::set<std::string> &getOnlineNicks() const noexcept2
- A_WARN_UNUSED
- { return mOnlineNicks; }
-
- void setAllowUpdate(const bool n) noexcept2
- { mAllowUpdate = n; }
-
- void optionChanged(const std::string &name) override final;
-
- void updateList(StringVect &list);
-
- void readFromWeb();
-
- static void setNeutralColor(OnlinePlayer *const player);
-
- void getPlayerNames(StringVect &names);
-
- private:
- void download();
-
- void updateSize();
-
- void handlerPlayerRelation(const std::string &nick,
- OnlinePlayer *const player);
-
-#ifdef TMWA_SUPPORT
- /**
- * The thread function that download the files.
- */
- static int downloadThread(void *ptr);
-
- /**
- * A libcurl callback for writing to memory.
- */
- static size_t memoryWrite(void *restrict ptr,
- size_t size,
- size_t nmemb,
- FILE *restrict stream);
-#endif // TMWA_SUPPORT
-
- const std::string prepareNick(const std::string &restrict nick,
- const int level,
- const std::string &restrict color)
- const A_WARN_UNUSED;
-
- void updateWindow(size_t numOnline);
-
- enum DownloadStatus
- {
- UPDATE_ERROR = 0,
- UPDATE_COMPLETE,
- UPDATE_LIST
- };
-
- time_t mUpdateTimer;
-
- /** A thread that use libcurl to download updates. */
- SDL_Thread *mThread;
-
- /** Buffer for files downloaded to memory. */
- char *mMemoryBuffer;
-
- /** Buffer to handler human readable error provided by curl. */
- char *mCurlError A_NONNULLPOINTER;
-
- StaticBrowserBox *mBrowserBox A_NONNULLPOINTER;
- ScrollArea *mScrollArea A_NONNULLPOINTER;
- Button *mUpdateButton A_NONNULLPOINTER;
-
- std::set<OnlinePlayer*> mOnlinePlayers;
- std::set<std::string> mOnlineNicks;
-
- STD_VECTOR<OnlinePlayer*> mFriends;
- STD_VECTOR<OnlinePlayer*> mNeutral;
- STD_VECTOR<OnlinePlayer*> mDisregard;
- STD_VECTOR<OnlinePlayer*> mEnemy;
-
- /** Byte count currently downloaded in mMemoryBuffer. */
- int mDownloadedBytes;
-
- /** Status of the current download. */
- WhoIsOnline::DownloadStatus mDownloadStatus;
-
- /** Flag that show if current download is complete. */
- bool mDownloadComplete;
- bool mAllowUpdate;
- bool mShowLevel;
- bool mUpdateOnlineList;
- bool mGroupFriends;
-#ifdef TMWA_SUPPORT
- bool mWebList;
-#endif
- bool mServerSideList;
-};
-
-extern WhoIsOnline *whoIsOnline;
-
-#endif // GUI_WINDOWS_WHOISONLINE_H
diff --git a/src/gui/windows/worldselectdialog.cpp b/src/gui/windows/worldselectdialog.cpp
deleted file mode 100644
index 919440a40..000000000
--- a/src/gui/windows/worldselectdialog.cpp
+++ /dev/null
@@ -1,134 +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 "gui/windows/worldselectdialog.h"
-
-#include "client.h"
-#include "settings.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/createwidget.h"
-#include "gui/widgets/layout.h"
-#include "gui/widgets/listbox.h"
-#include "gui/widgets/scrollarea.h"
-
-#include "gui/models/worldlistmodel.h"
-
-#include "net/loginhandler.h"
-
-#include "utils/delete2.h"
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-extern WorldInfo **server_info;
-
-WorldSelectDialog::WorldSelectDialog(const Worlds &worlds) :
- // TRANSLATORS: world select dialog name
- Window(_("Select World"), Modal_false, nullptr, "world.xml"),
- ActionListener(),
- KeyListener(),
- mWorldListModel(new WorldListModel(worlds)),
- mWorldList(CREATEWIDGETR(ListBox, this, mWorldListModel, "")),
- // TRANSLATORS: world dialog button
- mChangeLoginButton(new Button(this, _("Change Login"), "login", this)),
- // TRANSLATORS: world dialog button
- mChooseWorld(new Button(this, _("Choose World"), "world", this))
-{
- ScrollArea *const worldsScroll = new ScrollArea(this, mWorldList,
- fromBool(getOptionBool("showbackground"), Opaque),
- "world_background.xml");
-
- worldsScroll->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
-
- place(0, 0, worldsScroll, 3, 5).setPadding(2);
- place(1, 5, mChangeLoginButton);
- place(2, 5, mChooseWorld);
-
- // Make sure the list has enough height
- getLayout().setRowHeight(0, 60);
-
- reflowLayout(0, 0);
-
- if (worlds.empty())
- {
- // Disable Ok button
- mChooseWorld->setEnabled(false);
- }
- else
- {
- // Select first server
- mWorldList->setSelected(0);
- }
-
- addKeyListener(this);
-
- center();
-}
-
-void WorldSelectDialog::postInit()
-{
- Window::postInit();
- setVisible(Visible_true);
- mChooseWorld->requestFocus();
-}
-
-WorldSelectDialog::~WorldSelectDialog()
-{
- delete2(mWorldListModel);
-}
-
-void WorldSelectDialog::action(const ActionEvent &event)
-{
- const std::string &eventId = event.getId();
- if (eventId == "world")
- {
- mChangeLoginButton->setEnabled(false);
- mChooseWorld->setEnabled(false);
- loginHandler->chooseServer(mWorldList->getSelected(),
- settings.persistentIp);
-
- // Check in case netcode moves us forward
- if (client->getState() == State::WORLD_SELECT)
- client->setState(State::WORLD_SELECT_ATTEMPT);
- }
- else if (eventId == "login")
- {
- client->setState(State::PRE_LOGIN);
- }
-}
-
-void WorldSelectDialog::keyPressed(KeyEvent &event)
-{
- const InputActionT actionId = event.getActionId();
-
- if (actionId == InputAction::GUI_CANCEL)
- {
- action(ActionEvent(nullptr,
- mChangeLoginButton->getActionEventId()));
- }
- else if (actionId == InputAction::GUI_SELECT ||
- actionId == InputAction::GUI_SELECT2)
- {
- action(ActionEvent(nullptr, mChooseWorld->getActionEventId()));
- }
-}
diff --git a/src/gui/windows/worldselectdialog.h b/src/gui/windows/worldselectdialog.h
deleted file mode 100644
index 4c6dc0f8c..000000000
--- a/src/gui/windows/worldselectdialog.h
+++ /dev/null
@@ -1,77 +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_WINDOWS_WORLDSELECTDIALOG_H
-#define GUI_WINDOWS_WORLDSELECTDIALOG_H
-
-#include "gui/widgets/window.h"
-
-#include "net/worldinfo.h"
-
-#include "listeners/actionlistener.h"
-#include "listeners/keylistener.h"
-
-class Button;
-class ListBox;
-class WorldListModel;
-
-/**
- * The server select dialog.
- *
- * \ingroup Interface
- */
-class WorldSelectDialog final : public Window,
- public ActionListener,
- public KeyListener
-{
- public:
- /**
- * Constructor
- *
- * @see Window::Window
- */
- explicit WorldSelectDialog(const Worlds &worlds);
-
- A_DELETE_COPY(WorldSelectDialog)
-
- void postInit() override final;
-
- /**
- * Destructor.
- */
- ~WorldSelectDialog();
-
- /**
- * Called when receiving actions from the widgets.
- */
- void action(const ActionEvent &event) override final;
-
- void keyPressed(KeyEvent &event) override final;
-
- private:
- WorldListModel *mWorldListModel A_NONNULLPOINTER;
- ListBox *mWorldList A_NONNULLPOINTER;
- Button *mChangeLoginButton A_NONNULLPOINTER;
- Button *mChooseWorld A_NONNULLPOINTER;
-};
-
-#endif // GUI_WINDOWS_WORLDSELECTDIALOG_H
diff --git a/src/guild.cpp b/src/guild.cpp
deleted file mode 100644
index feb986e15..000000000
--- a/src/guild.cpp
+++ /dev/null
@@ -1,389 +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 "guild.h"
-
-#include "actormanager.h"
-
-#include "being/being.h"
-
-#include "utils/stringutils.h"
-
-#include "debug.h"
-
-static class SortGuildFunctor final
-{
- public:
- A_DEFAULT_COPY(SortGuildFunctor)
-
- bool operator() (const GuildMember *const m1,
- const GuildMember *const m2) const
- {
- if ((m1 == nullptr) || (m2 == nullptr))
- return false;
-
- if (m1->getOnline() != m2->getOnline())
- {
- return static_cast<int>(m1->getOnline()) >
- static_cast<int>(m2->getOnline());
- }
-
- if (m1->getPos() != m2->getPos())
- return m1->getPos() > m2->getPos();
-
- if (m1->getName() != m2->getName())
- {
- std::string s1 = m1->getName();
- std::string s2 = m2->getName();
- toLower(s1);
- toLower(s2);
- return s1 < s2;
- }
- return false;
- }
-} guildSorter;
-
-GuildMember::GuildMember(Guild *const guild,
- const BeingId accountId,
- const int charId,
- const std::string &name) :
- Avatar(name),
- mGuild(guild),
- mPos(0)
-{
- mId = accountId;
- mCharId = charId;
-}
-
-GuildMember::GuildMember(Guild *const guild, const std::string &name) :
- Avatar(name),
- mGuild(guild),
- mPos(0)
-{
-}
-
-std::string GuildMember::getAdditionString() const
-{
- if (mGuild == nullptr)
- return "";
-
- return " - " + mGuild->getPos(mPos);
-}
-
-Guild::GuildMap Guild::guilds;
-
-Guild::Guild(const int16_t id) :
- mMembers(),
- mPositions(),
- mName(),
- mEmblemId(0),
- mId(id),
- mCanInviteUsers(false),
- mServerGuild(true)
-{
- guilds[id] = this;
-}
-
-Guild::~Guild()
-{
- clearMembers();
-}
-
-GuildMember *Guild::addMember(const BeingId accountId,
- const int charId,
- const std::string &name)
-{
- GuildMember *m = getMember(accountId, charId);
- if (m != nullptr)
- return m;
-
- m = new GuildMember(this, accountId, charId, name);
-
- mMembers.push_back(m);
-
- return m;
-}
-
-GuildMember *Guild::addMember(const std::string &name)
-{
- GuildMember *m = getMember(name);
- if (m != nullptr)
- return m;
-
- m = new GuildMember(this, name);
-
- mMembers.push_back(m);
-
- return m;
-}
-
-GuildMember *Guild::getMember(const BeingId id) const
-{
- MemberList::const_iterator itr = mMembers.begin();
- const MemberList::const_iterator itr_end = mMembers.end();
- while (itr != itr_end)
- {
- if (((*itr) != nullptr) && (*itr)->mId == id)
- return (*itr);
- ++itr;
- }
-
- return nullptr;
-}
-
-GuildMember *Guild::getMember(const BeingId accountId,
- const int charId) const
-{
- MemberList::const_iterator itr = mMembers.begin();
- const MemberList::const_iterator itr_end = mMembers.end();
- while (itr != itr_end)
- {
- if ((*itr) != nullptr &&
- (*itr)->mId == accountId &&
- (*itr)->mCharId == charId)
- {
- return (*itr);
- }
- ++itr;
- }
-
- return nullptr;
-}
-
-GuildMember *Guild::getMember(const std::string &name) const
-{
- MemberList::const_iterator itr = mMembers.begin();
- const MemberList::const_iterator itr_end = mMembers.end();
- while (itr != itr_end)
- {
- if (((*itr) != nullptr) && (*itr)->getName() == name)
- return (*itr);
- ++itr;
- }
-
- return nullptr;
-}
-
-void Guild::removeMember(const GuildMember *const member)
-{
- if (member == nullptr)
- return;
- MemberList::iterator itr = mMembers.begin();
- const MemberList::iterator itr_end = mMembers.end();
- while (itr != itr_end)
- {
- if (*itr == nullptr)
- continue;
- if ((*itr)->mId == member->mId &&
- (*itr)->mCharId == member->mCharId &&
- (*itr)->getName() == member->getName())
- {
- GuildMember *m = *itr;
- mMembers.erase(itr);
- delete m;
- return;
- }
- ++ itr;
- }
-}
-
-void Guild::removeMember(const BeingId id)
-{
- bool deleted = true;
- while (deleted)
- {
- deleted = false;
- MemberList::iterator itr = mMembers.begin();
- const MemberList::iterator itr_end = mMembers.end();
- while (itr != itr_end)
- {
- if (((*itr) != nullptr) && (*itr)->mId == id)
- {
- GuildMember *member = *itr;
- mMembers.erase(itr);
- delete member;
- deleted = true;
- break;
- }
- ++itr;
- }
- }
-}
-
-void Guild::removeMember(const std::string &name)
-{
- bool deleted = true;
- while (deleted)
- {
- deleted = false;
- MemberList::iterator itr = mMembers.begin();
- const MemberList::iterator itr_end = mMembers.end();
- while (itr != itr_end)
- {
- if (((*itr) != nullptr) && (*itr)->getName() == name)
- {
- GuildMember *member = *itr;
- mMembers.erase(itr);
- delete member;
- deleted = true;
- break;
- }
- ++itr;
- }
- }
-}
-
-void Guild::removeFromMembers()
-{
- if (actorManager == nullptr)
- return;
-
- MemberList::const_iterator itr = mMembers.begin();
- const MemberList::const_iterator itr_end = mMembers.end();
- while (itr != itr_end)
- {
- if (*itr != nullptr)
- {
- Being *const b = actorManager->findBeing((*itr)->getID());
- if (b != nullptr)
- b->removeGuild(mId);
- }
- ++itr;
- }
-}
-
-Avatar *Guild::getAvatarAt(const int index)
-{
- return mMembers[index];
-}
-
-void Guild::setRights(const int16_t rights)
-{
- // to invite, rights must be greater than 0
- if (rights > 0)
- mCanInviteUsers = true;
-}
-
-bool Guild::isMember(const GuildMember *const member) const
-{
- if (member == nullptr)
- return false;
-
- if ((member->mGuild != nullptr) && member->mGuild != this)
- return false;
-
- MemberList::const_iterator itr = mMembers.begin();
- const MemberList::const_iterator itr_end = mMembers.end();
- while (itr != itr_end)
- {
- if (((*itr) != nullptr) && (*itr)->mId == member->mId &&
- (*itr)->getName() == member->getName())
- {
- return true;
- }
- ++itr;
- }
-
- return false;
-}
-
-bool Guild::isMember(const BeingId id) const
-{
- MemberList::const_iterator itr = mMembers.begin();
- const MemberList::const_iterator itr_end = mMembers.end();
- while (itr != itr_end)
- {
- if (((*itr) != nullptr) && (*itr)->mId == id)
- return true;
- ++itr;
- }
-
- return false;
-}
-
-bool Guild::isMember(const std::string &name) const
-{
- MemberList::const_iterator itr = mMembers.begin();
- const MemberList::const_iterator itr_end = mMembers.end();
- while (itr != itr_end)
- {
- if (((*itr) != nullptr) && (*itr)->getName() == name)
- return true;
- ++itr;
- }
-
- return false;
-}
-
-void Guild::getNames(StringVect &names) const
-{
- names.clear();
- MemberList::const_iterator it = mMembers.begin();
- const MemberList::const_iterator it_end = mMembers.end();
-
- while (it != it_end)
- {
- if (*it != nullptr)
- names.push_back((*it)->getName());
- ++it;
- }
-}
-
-void Guild::addPos(const int id, const std::string &name)
-{
- mPositions[id] = name;
-}
-
-Guild *Guild::getGuild(const int16_t id)
-{
- const GuildMap::const_iterator it = guilds.find(id);
- if (it != guilds.end())
- return it->second;
-
- Guild *const guild = new Guild(id);
- guilds[id] = guild;
- return guild;
-}
-
-std::string Guild::getPos(const int id) const
-{
- const PositionsMap::const_iterator it = mPositions.find(id);
- if (it == mPositions.end())
- return "";
- return it->second;
-}
-
-void Guild::sort()
-{
- std::sort(mMembers.begin(), mMembers.end(), guildSorter);
-}
-
-void Guild::clearGuilds()
-{
- GuildMap::iterator it = guilds.begin();
- while (it != guilds.end())
- {
- delete (*it).second;
- ++ it;
- }
- guilds.clear();
-}
diff --git a/src/guild.h b/src/guild.h
deleted file mode 100644
index 7157ddf21..000000000
--- a/src/guild.h
+++ /dev/null
@@ -1,224 +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 GUILD_H
-#define GUILD_H
-
-#include "gui/models/avatarlistmodel.h"
-
-#include "utils/cast.h"
-#include "utils/dtor.h"
-#include "utils/stringvector.h"
-
-#include <map>
-
-class Guild;
-
-typedef std::map<unsigned, std::string> PositionsMap;
-
-class GuildMember final : public Avatar
-{
- public:
- A_DELETE_COPY(GuildMember)
-
- const Guild *getGuild() const noexcept2 A_WARN_UNUSED
- { return mGuild; }
-
- int getPos() const noexcept2 A_WARN_UNUSED
- { return mPos; }
-
- void setPos(const int pos)
- { mPos = pos; }
-
- std::string getAdditionString() const override final A_WARN_UNUSED;
-
- protected:
- friend class Guild;
-
- GuildMember(Guild *const guild,
- const BeingId accountId,
- const int charId,
- const std::string &name);
-
- GuildMember(Guild *const guild, const std::string &name);
-
- Guild *mGuild;
- int mPos;
-};
-
-class Guild final : public AvatarListModel
-{
- public:
- A_DELETE_COPY(Guild)
-
- ~Guild();
-
- /**
- * Set the guild's name.
- */
- void setName(const std::string &name)
- { mName = name; }
-
- /**
- * Adds member to the list.
- */
- GuildMember *addMember(const BeingId accountId,
- const int charId,
- const std::string &name);
-
- /**
- * Adds member to the list.
- */
- GuildMember *addMember(const std::string &name);
-
- /**
- * Find a member by ID.
- *
- * @return the member with the given ID, or NULL if they don't exist.
- */
- GuildMember *getMember(const BeingId id) const;
-
- /**
- * Find a member by account ID and char ID.
- *
- * @return the member with the given ID, or NULL if they don't exist.
- */
- GuildMember *getMember(const BeingId accountId,
- const int charId)
- const A_WARN_UNUSED;
-
- /**
- * Find a member by name.
- *
- * @return the member with the given name, or NULL if they don't exist.
- */
- GuildMember *getMember(const std::string &name) const A_WARN_UNUSED;
-
- /**
- * Get the name of the guild.
- * @return returns name of the guild
- */
- const std::string &getName() const noexcept2 A_WARN_UNUSED
- { return mName; }
-
- /**
- * Get the id of the guild.
- * @return Returns the id of the guild
- */
- int16_t getId() const noexcept2 A_WARN_UNUSED
- { return mId; }
-
- /**
- * Removes a member from the guild.
- */
- void removeMember(const GuildMember *const member);
-
- /**
- * Removes a member from the guild.
- */
- void removeMember(const BeingId id);
-
- /**
- * Removes a member from the guild.
- */
- void removeMember(const std::string &name);
-
- void removeFromMembers();
-
- void clearMembers()
- { delete_all(mMembers); mMembers.clear(); }
-
- /**
- * Get size of members list.
- * @return Returns the number of members in the guild.
- */
- int getNumberOfElements() override final A_WARN_UNUSED
- { return CAST_S32(mMembers.size()); }
-
- Avatar *getAvatarAt(const int index) override final A_WARN_UNUSED;
-
- /**
- * Get whether user can invite users to this guild.
- * @return Returns true if user can invite users
- */
- bool getInviteRights() const noexcept2 A_WARN_UNUSED
- { return mCanInviteUsers; }
-
- void setRights(const int16_t rights);
-
- bool isMember(const GuildMember *const member) const A_WARN_UNUSED;
-
- bool isMember(const BeingId id) const A_WARN_UNUSED;
-
- bool isMember(const std::string &name) const A_WARN_UNUSED;
-
- void getNames(StringVect &names) const;
-
- void addPos(const int id, const std::string &name);
-
- void sort();
-
- std::string getPos(const int id) const A_WARN_UNUSED;
-
- static Guild *getGuild(const int16_t id) A_WARN_UNUSED;
-
- const PositionsMap &getPositions() const noexcept2 A_WARN_UNUSED
- { return mPositions; }
-
- void setEmblemId(const int id)
- { mEmblemId = id; }
-
- int getEmblemId() const noexcept2 A_WARN_UNUSED
- { return mEmblemId; }
-
- static void clearGuilds();
-
- void setServerGuild(const bool b)
- { mServerGuild = b; }
-
- bool getServerGuild() const noexcept2 A_WARN_UNUSED
- { return mServerGuild; }
-
- typedef STD_VECTOR<GuildMember*> MemberList;
-
- const MemberList *getMembers() const RETURNS_NONNULL A_WARN_UNUSED
- { return &mMembers; }
-
- private:
- typedef std::map<int, Guild*> GuildMap;
- static GuildMap guilds;
-
- /**
- * Constructor with guild id passed to it.
- */
- explicit Guild(const int16_t id);
-
- MemberList mMembers;
- PositionsMap mPositions;
- std::string mName;
- int mEmblemId;
- int16_t mId;
- bool mCanInviteUsers;
- bool mServerGuild;
-};
-
-#endif // GUILD_H
diff --git a/src/input/inputactiondata.h b/src/input/inputactiondata.h
deleted file mode 100644
index 507b30b49..000000000
--- a/src/input/inputactiondata.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2007 Joshua Langley <joshlangley@optusnet.com.au>
- * 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 INPUT_INPUTACTIONDATA_H
-#define INPUT_INPUTACTIONDATA_H
-
-#include "actions/actionfuncptr.h"
-
-#include "enums/input/inputtype.h"
-
-#include "enums/simpletypes/useargs.h"
-#include "enums/simpletypes/protected.h"
-
-struct InputActionData final
-{
- A_DEFAULT_COPY(InputActionData)
-
- const char *const configField;
- const InputTypeT defaultType1;
- const int defaultValue1;
- const InputTypeT defaultType2;
- const int defaultValue2;
- const int grp;
- const ActionFuncPtr action;
- const InputActionT modKeyIndex;
- const int priority;
- const int condition;
- const std::string chatCommand;
- const UseArgs useArgs;
- const Protected isProtected;
-};
-
-#endif // INPUT_INPUTACTIONDATA_H
diff --git a/src/input/inputactionmap.h b/src/input/inputactionmap.h
deleted file mode 100644
index 0c81000bc..000000000
--- a/src/input/inputactionmap.h
+++ /dev/null
@@ -1,5963 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2007 Joshua Langley <joshlangley@optusnet.com.au>
- * 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 INPUT_INPUTACTIONMAP_H
-#define INPUT_INPUTACTIONMAP_H
-
-#include "sdlshared.h"
-
-#include "actions/actions.h"
-#include "actions/chat.h"
-#include "actions/commands.h"
-#include "actions/move.h"
-#include "actions/pets.h"
-#include "actions/statusbar.h"
-#include "actions/tabs.h"
-#include "actions/target.h"
-#include "actions/windows.h"
-
-#include "enums/input/inputcondition.h"
-#include "enums/input/inputgroup.h"
-
-#include "input/inputactiondata.h"
-#include "input/inputmanager.h"
-
-#include "localconsts.h"
-
-#define defaultAction(name) \
- InputType::UNKNOWN, -1, \
- InputType::UNKNOWN, -1, \
- Input::GRP_DEFAULT, \
- name, \
- InputAction::NO_VALUE, 50
-
-#define addKey(name) InputType::KEYBOARD, name
-#define emptyKey InputType::UNKNOWN, -1
-#define joystickButton(num) InputType::JOYSTICK, num
-
-// keyData must be in same order as enum keyAction.
-static const InputActionData inputActionData
- [CAST_SIZE(InputAction::TOTAL)] =
- {
- {"keyMoveUp",
- addKey(SDLK_UP),
- emptyKey,
- Input::GRP_DEFAULT,
- &Actions::moveUp,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::ARROWKEYS,
- "",
- UseArgs_false,
- Protected_false},
- {"keyMoveDown",
- addKey(SDLK_DOWN),
- emptyKey,
- Input::GRP_DEFAULT,
- &Actions::moveDown,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::ARROWKEYS,
- "",
- UseArgs_false,
- Protected_false},
- {"keyMoveLeft",
- addKey(SDLK_LEFT),
- emptyKey,
- Input::GRP_DEFAULT,
- &Actions::moveLeft,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::ARROWKEYS,
- "",
- UseArgs_false,
- Protected_false},
- {"keyMoveRight",
- addKey(SDLK_RIGHT),
- emptyKey,
- Input::GRP_DEFAULT,
- &Actions::moveRight,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::ARROWKEYS,
- "",
- UseArgs_false,
- Protected_false},
- {"keyAttack",
- addKey(SDLK_x),
- emptyKey,
- Input::GRP_DEFAULT | Input::GRP_REPEAT,
- &Actions::attack,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::GAME |
- InputCondition::NOFOLLOW |
- InputCondition::VALIDSPEED,
- "attack",
- UseArgs_false,
- Protected_false},
- {"keyTargetAttack",
- addKey(SDLK_LCTRL),
- joystickButton(0),
- Input::GRP_DEFAULT,
- &Actions::targetAttack,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::GAME |
- InputCondition::NOFOLLOW |
- InputCondition::VALIDSPEED |
- InputCondition::ALIVE,
- "targetattack",
- UseArgs_true,
- Protected_false},
- {"keyMoveToTarget",
- addKey(SDLK_v),
- emptyKey,
- Input::GRP_DEFAULT,
- &Actions::moveToTarget,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::GAME |
- InputCondition::VALIDSPEED,
- "movetotarget",
- UseArgs_false,
- Protected_false},
- {"keyChangeMoveToTarget",
- addKey(SDLK_PERIOD),
- emptyKey,
- Input::GRP_DEFAULT,
- &Actions::changeMoveToTarget,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::GAME |
- InputCondition::VALIDSPEED |
- InputCondition::EMODS,
- "",
- UseArgs_false,
- Protected_true},
- {"keyMoveToHome",
- addKey(SDLK_d),
- emptyKey,
- Input::GRP_DEFAULT,
- &Actions::moveToHome,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::GAME |
- InputCondition::VALIDSPEED,
- "movetohome",
- UseArgs_false,
- Protected_false},
- {"keySetHome",
- addKey(SDLK_KP5),
- emptyKey,
- Input::GRP_DEFAULT,
- &Actions::setHome,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::GAME |
- InputCondition::VALIDSPEED,
- "sethome",
- UseArgs_false,
- Protected_true},
- {"keyMoveToPoint",
- addKey(SDLK_RSHIFT),
- emptyKey,
- Input::GRP_DEFAULT,
- nullptr,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::DEFAULT |
- InputCondition::INGAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyTalk",
- addKey(SDLK_t),
- emptyKey,
- Input::GRP_DEFAULT,
- &Actions::talk,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "talk",
- UseArgs_false,
- Protected_false},
- {"keyTarget",
- addKey(SDLK_LSHIFT),
- joystickButton(4),
- Input::GRP_DEFAULT,
- &Actions::stopAttack,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "stopattack",
- UseArgs_false,
- Protected_false},
- {"keyUnTarget",
- defaultAction(&Actions::untarget),
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "untarget",
- UseArgs_false,
- Protected_false},
- {"keyTargetMonster",
- addKey(SDLK_a),
- joystickButton(3),
- Input::GRP_DEFAULT | Input::GRP_REPEAT,
- &Actions::targetMonster,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::GAME |
- InputCondition::NOTARGET |
- InputCondition::VALIDSPEED,
- "targetmonster",
- UseArgs_false,
- Protected_false},
- {"keyTargetNPC",
- addKey(SDLK_n),
- emptyKey,
- Input::GRP_DEFAULT,
- &Actions::targetNPC,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::GAME |
- InputCondition::NOTARGET,
- "targetnpc",
- UseArgs_false,
- Protected_false},
- {"keyTargetPlayer",
- addKey(SDLK_q),
- emptyKey,
- Input::GRP_DEFAULT,
- &Actions::targetPlayer,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::GAME |
- InputCondition::NOTARGET,
- "targetplayer",
- UseArgs_false,
- Protected_false},
- {"keyPickup",
- addKey(SDLK_z),
- joystickButton(1),
- Input::GRP_DEFAULT,
- &Actions::pickup,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::GAME |
- InputCondition::NOTARGET,
- "pickup",
- UseArgs_false,
- Protected_false},
- {"keyChangePickupType",
- addKey(SDLK_o),
- emptyKey,
- Input::GRP_DEFAULT,
- &Actions::changePickupType,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::GAME |
- InputCondition::VALIDSPEED |
- InputCondition::EMODS,
- "",
- UseArgs_false,
- Protected_true},
- {"keyHideWindows",
- addKey(SDLK_h),
- emptyKey,
- Input::GRP_DEFAULT | Input::GRP_GUI,
- &Actions::hideWindows,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::GAME |
- InputCondition::NOTARGET,
- "hidewindows",
- UseArgs_false,
- Protected_true},
- {"keyBeingSit",
- addKey(SDLK_s),
- joystickButton(2),
- Input::GRP_DEFAULT,
- &Actions::sit,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::GAME |
- InputCondition::NOTARGET |
- InputCondition::NOBLOCK,
- "sit",
- UseArgs_false,
- Protected_false},
- {"keyScreenshot",
- addKey(SDLK_p),
- emptyKey,
- Input::GRP_DEFAULT,
- &Actions::screenshot,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::NOTARGET |
- InputCondition::NOINPUT,
- "screenshot",
- UseArgs_false,
- Protected_true},
- {"keyTrade",
- addKey(SDLK_r),
- emptyKey,
- Input::GRP_DEFAULT,
- &Actions::changeTrade,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::GAME |
- InputCondition::NOTARGET,
- "changetrade",
- UseArgs_false,
- Protected_true},
- {"keyPathfind",
- addKey(SDLK_f),
- emptyKey,
- Input::GRP_DEFAULT,
- &Actions::changeMapMode,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::GAME |
- InputCondition::NOTARGET |
- InputCondition::EMODS,
- "",
- UseArgs_false,
- Protected_false},
- {"keyOK",
- addKey(SDLK_SPACE),
- emptyKey,
- Input::GRP_DEFAULT | Input::GRP_GUI,
- &Actions::ok,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::NOMODAL |
- InputCondition::NOAWAY |
- InputCondition::NONPCINPUT,
- "",
- UseArgs_false,
- Protected_false},
- {"keyQuit",
- addKey(SDLK_ESCAPE),
-#if defined(USE_SDL2) && defined(ANDROID)
- addKey(SDLK_AC_BACK),
-#else // defined(USE_SDL2) && defined(ANDROID)
- emptyKey,
-#endif // defined(USE_SDL2) && defined(ANDROID)
- Input::GRP_DEFAULT,
- &Actions::quit,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::DEFAULT,
- "quit",
- UseArgs_false,
- Protected_true},
- {"keyShortcutsKey",
- addKey(SDLK_MENU),
- emptyKey,
- Input::GRP_DEFAULT,
- nullptr,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::DEFAULT |
- InputCondition::INGAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyShortcut1",
- addKey(SDLK_1),
- emptyKey,
- Input::GRP_DEFAULT,
- &Actions::shortcut,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::SHORTCUT,
- "",
- UseArgs_false,
- Protected_true},
- {"keyShortcut2",
- addKey(SDLK_2),
- emptyKey,
- Input::GRP_DEFAULT,
- &Actions::shortcut,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::SHORTCUT,
- "",
- UseArgs_false,
- Protected_true},
- {"keyShortcut3",
- addKey(SDLK_3),
- emptyKey,
- Input::GRP_DEFAULT,
- &Actions::shortcut,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::SHORTCUT,
- "",
- UseArgs_false,
- Protected_true},
- {"keyShortcut4",
- addKey(SDLK_4),
- emptyKey,
- Input::GRP_DEFAULT,
- &Actions::shortcut,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::SHORTCUT,
- "",
- UseArgs_false,
- Protected_true},
- {"keyShortcut5",
- addKey(SDLK_5),
- emptyKey,
- Input::GRP_DEFAULT,
- &Actions::shortcut,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::SHORTCUT,
- "",
- UseArgs_false,
- Protected_true},
- {"keyShortcut6",
- addKey(SDLK_6),
- emptyKey,
- Input::GRP_DEFAULT,
- &Actions::shortcut,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::SHORTCUT,
- "",
- UseArgs_false,
- Protected_true},
- {"keyShortcut7",
- addKey(SDLK_7),
- emptyKey,
- Input::GRP_DEFAULT,
- &Actions::shortcut,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::SHORTCUT,
- "",
- UseArgs_false,
- Protected_true},
- {"keyShortcut8",
- addKey(SDLK_8),
- emptyKey,
- Input::GRP_DEFAULT,
- &Actions::shortcut,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::SHORTCUT,
- "",
- UseArgs_false,
- Protected_true},
- {"keyShortcut9",
- addKey(SDLK_9),
- emptyKey,
- Input::GRP_DEFAULT,
- &Actions::shortcut,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::SHORTCUT,
- "",
- UseArgs_false,
- Protected_true},
- {"keyShortcut10",
- addKey(SDLK_0),
- emptyKey,
- Input::GRP_DEFAULT,
- &Actions::shortcut,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::SHORTCUT,
- "",
- UseArgs_false,
- Protected_true},
- {"keyShortcut11",
- addKey(SDLK_MINUS),
- emptyKey,
- Input::GRP_DEFAULT,
- &Actions::shortcut,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::SHORTCUT,
- "",
- UseArgs_false,
- Protected_true},
- {"keyShortcut12",
- addKey(SDLK_EQUALS),
- emptyKey,
- Input::GRP_DEFAULT,
- &Actions::shortcut,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::SHORTCUT,
- "",
- UseArgs_false,
- Protected_true},
- {"keyShortcut13",
- addKey(SDLK_BACKSPACE),
- emptyKey,
- Input::GRP_DEFAULT,
- &Actions::shortcut,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::SHORTCUT,
- "",
- UseArgs_false,
- Protected_true},
- {"keyShortcut14",
- addKey(SDLK_INSERT),
- emptyKey,
- Input::GRP_DEFAULT,
- &Actions::shortcut,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::SHORTCUT,
- "",
- UseArgs_false,
- Protected_true},
- {"keyShortcut15",
- addKey(SDLK_HOME),
- emptyKey,
- Input::GRP_DEFAULT,
- &Actions::shortcut,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::SHORTCUT,
- "",
- UseArgs_false,
- Protected_true},
- {"keyShortcut16",
- defaultAction(&Actions::shortcut),
- InputCondition::KEY_DOWN | InputCondition::SHORTCUT,
- "",
- UseArgs_false,
- Protected_true},
- {"keyShortcut17",
- defaultAction(&Actions::shortcut),
- InputCondition::KEY_DOWN | InputCondition::SHORTCUT,
- "",
- UseArgs_false,
- Protected_true},
- {"keyShortcut18",
- defaultAction(&Actions::shortcut),
- InputCondition::KEY_DOWN | InputCondition::SHORTCUT,
- "",
- UseArgs_false,
- Protected_true},
- {"keyShortcut19",
- defaultAction(&Actions::shortcut),
- InputCondition::KEY_DOWN | InputCondition::SHORTCUT,
- "",
- UseArgs_false,
- Protected_true},
- {"keyShortcut20",
- defaultAction(&Actions::shortcut),
- InputCondition::KEY_DOWN | InputCondition::SHORTCUT,
- "",
- UseArgs_false,
- Protected_true},
- {"keyWindowHelp",
- addKey(SDLK_F1),
- emptyKey,
- Input::GRP_DEFAULT | Input::GRP_GUI,
- &Actions::helpWindowShow,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::SHORTCUT0,
- "help|openhelp",
- UseArgs_false,
- Protected_false},
- {"keyWindowStatus",
- addKey(SDLK_F2),
- emptyKey,
- Input::GRP_DEFAULT | Input::GRP_GUI,
- &Actions::statusWindowShow,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::GAME |
- InputCondition::NOTARGET,
- "status|openstatus",
- UseArgs_false,
- Protected_false},
- {"keyWindowInventory",
- addKey(SDLK_F3),
- emptyKey,
- Input::GRP_DEFAULT | Input::GRP_GUI,
- &Actions::inventoryWindowShow,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::GAME |
- InputCondition::NOTARGET,
- "inventory|openinventory",
- UseArgs_false,
- Protected_false},
- {"keyWindowEquipment",
- addKey(SDLK_F4),
- emptyKey,
- Input::GRP_DEFAULT | Input::GRP_GUI,
- &Actions::equipmentWindowShow,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::GAME |
- InputCondition::NOTARGET,
- "equipment|openequipment",
- UseArgs_false,
- Protected_false},
- {"keyWindowSkill",
- addKey(SDLK_F5),
- emptyKey,
- Input::GRP_DEFAULT | Input::GRP_GUI,
- &Actions::skillDialogShow,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::GAME |
- InputCondition::NOTARGET,
- "skill|skills|openskills",
- UseArgs_false,
- Protected_false},
- {"keyWindowMinimap",
- addKey(SDLK_F6),
- emptyKey,
- Input::GRP_DEFAULT | Input::GRP_GUI,
- &Actions::minimapWindowShow,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::GAME |
- InputCondition::NOTARGET,
- "minimap|openminimap",
- UseArgs_false,
- Protected_false},
- {"keyWindowChat",
- addKey(SDLK_F7),
- emptyKey,
- Input::GRP_DEFAULT | Input::GRP_GUI,
- &Actions::chatWindowShow,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::SHORTCUT0,
- "openchat",
- UseArgs_false,
- Protected_false},
- {"keyWindowShortcut",
- addKey(SDLK_F8),
- emptyKey,
- Input::GRP_DEFAULT | Input::GRP_GUI,
- &Actions::shortcutWindowShow,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::GAME |
- InputCondition::NOTARGET,
- "openshortcut|openshortcuts",
- UseArgs_false,
- Protected_false},
- {"keyWindowSetup",
- addKey(SDLK_F9),
- emptyKey,
- Input::GRP_DEFAULT | Input::GRP_GUI,
- &Actions::setupWindowShow,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::NOTARGET |
- InputCondition::NOINPUT |
- InputCondition::ENABLED,
- "setup|opensetup",
- UseArgs_false,
- Protected_false},
- {"keyWindowDebug",
- addKey(SDLK_F10),
- emptyKey,
- Input::GRP_DEFAULT | Input::GRP_GUI,
- &Actions::debugWindowShow,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::SHORTCUT0 |
- InputCondition::NOTARGET,
- "debug|opendebug",
- UseArgs_false,
- Protected_false},
- {"keyWindowSocial",
- addKey(SDLK_F11),
- emptyKey,
- Input::GRP_DEFAULT | Input::GRP_GUI,
- &Actions::socialWindowShow,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::GAME |
- InputCondition::NOTARGET,
- "social|opensocial",
- UseArgs_false,
- Protected_false},
- {"keyWindowEmoteBar",
- addKey(SDLK_F12),
- emptyKey,
- Input::GRP_DEFAULT | Input::GRP_GUI,
- &Actions::emoteShortcutWindowShow,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::GAME |
- InputCondition::NOTARGET,
- "emotes|openemotes",
- UseArgs_false,
- Protected_false},
- {"keyWindowOutfit",
- addKey(SDLK_BACKQUOTE),
- emptyKey,
- Input::GRP_DEFAULT | Input::GRP_GUI,
- &Actions::outfitWindowShow,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::GAME |
- InputCondition::NOTARGET,
- "openoutfit|openoutfits",
- UseArgs_false,
- Protected_false},
- {"keyWindowShop",
- emptyKey,
- emptyKey,
- Input::GRP_DEFAULT | Input::GRP_GUI,
- &Actions::shopWindowShow,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::GAME |
- InputCondition::NOTARGET,
- "shop|openshop",
- UseArgs_false,
- Protected_false},
- {"keyWindowDrop",
- addKey(SDLK_w),
- emptyKey,
- Input::GRP_DEFAULT | Input::GRP_GUI,
- &Actions::dropShortcutWindowShow,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::GAME |
- InputCondition::NOTARGET,
- "opendrop",
- UseArgs_false,
- Protected_false},
- {"keyWindowKills",
- addKey(SDLK_e),
- emptyKey,
- Input::GRP_DEFAULT | Input::GRP_GUI,
- &Actions::killStatsWindowShow,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::GAME |
- InputCondition::NOTARGET,
- "kills|openkills",
- UseArgs_false,
- Protected_false},
- {"keyWindowSpells",
- addKey(SDLK_j),
- emptyKey,
- Input::GRP_DEFAULT | Input::GRP_GUI,
- &Actions::spellShortcutWindowShow,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::GAME |
- InputCondition::NOTARGET,
- "spells|openspells",
- UseArgs_false,
- Protected_false},
- {"keyWindowBotChecker",
- emptyKey,
- emptyKey,
- Input::GRP_DEFAULT | Input::GRP_GUI,
- nullptr,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::GAME |
- InputCondition::NOTARGET,
- "",
- UseArgs_false,
- Protected_false},
- {"keyWindowOnline",
- emptyKey,
- emptyKey,
- Input::GRP_DEFAULT | Input::GRP_GUI,
- &Actions::whoIsOnlineWindowShow,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::GAME |
- InputCondition::NOTARGET,
- "online|openonline",
- UseArgs_false,
- Protected_false},
- {"keyWindowDidYouKnow",
- emptyKey,
- emptyKey,
- Input::GRP_DEFAULT | Input::GRP_GUI,
- &Actions::didYouKnowWindowShow,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::SHORTCUT0,
- "didyouknow|opendidyouknow",
- UseArgs_false,
- Protected_false},
- {"keyWindowQuests",
- addKey(SDLK_LEFTBRACKET),
- emptyKey,
- Input::GRP_DEFAULT | Input::GRP_GUI,
- &Actions::questsWindowShow,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::GAME |
- InputCondition::NOTARGET,
- "quests|openquests",
- UseArgs_false,
- Protected_false},
- {"keySocialPrevTab",
- emptyKey,
- emptyKey,
- Input::GRP_DEFAULT | Input::GRP_GUI,
- &Actions::prevSocialTab,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::NOINPUT |
- InputCondition::INGAME,
- "prevsocialtab",
- UseArgs_false,
- Protected_false},
- {"keySocialNextTab",
- emptyKey,
- emptyKey,
- Input::GRP_DEFAULT | Input::GRP_GUI,
- &Actions::nextSocialTab,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::NOINPUT |
- InputCondition::INGAME,
- "nextsocialtab",
- UseArgs_false,
- Protected_false},
- {"keySmilie",
- addKey(SDLK_LALT),
- emptyKey,
- Input::GRP_DEFAULT,
- nullptr,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::DEFAULT |
- InputCondition::INGAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyEmoteShortcut1",
- addKey(SDLK_1),
- emptyKey,
- Input::GRP_EMOTION,
- &Actions::emote,
- InputAction::EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyEmoteShortcut2",
- addKey(SDLK_2),
- emptyKey,
- Input::GRP_EMOTION,
- &Actions::emote,
- InputAction::EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyEmoteShortcut3",
- addKey(SDLK_3),
- emptyKey,
- Input::GRP_EMOTION,
- &Actions::emote,
- InputAction::EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyEmoteShortcut4",
- addKey(SDLK_4),
- emptyKey,
- Input::GRP_EMOTION,
- &Actions::emote,
- InputAction::EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyEmoteShortcut5",
- addKey(SDLK_5),
- emptyKey,
- Input::GRP_EMOTION,
- &Actions::emote,
- InputAction::EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyEmoteShortcut6",
- addKey(SDLK_6),
- emptyKey,
- Input::GRP_EMOTION,
- &Actions::emote,
- InputAction::EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyEmoteShortcut7",
- addKey(SDLK_7),
- emptyKey,
- Input::GRP_EMOTION,
- &Actions::emote,
- InputAction::EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyEmoteShortcut8",
- addKey(SDLK_8),
- emptyKey,
- Input::GRP_EMOTION,
- &Actions::emote,
- InputAction::EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyEmoteShortcut9",
- addKey(SDLK_9),
- emptyKey,
- Input::GRP_EMOTION,
- &Actions::emote,
- InputAction::EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyEmoteShortcut10",
- addKey(SDLK_0),
- emptyKey,
- Input::GRP_EMOTION,
- &Actions::emote,
- InputAction::EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyEmoteShortcut11",
- addKey(SDLK_MINUS),
- emptyKey,
- Input::GRP_EMOTION,
- &Actions::emote,
- InputAction::EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyEmoteShortcut12",
- addKey(SDLK_EQUALS),
- emptyKey,
- Input::GRP_EMOTION,
- &Actions::emote,
- InputAction::EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyEmoteShortcut13",
- addKey(SDLK_BACKSPACE),
- emptyKey,
- Input::GRP_EMOTION,
- &Actions::emote,
- InputAction::EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyEmoteShortcut14",
- addKey(SDLK_INSERT),
- emptyKey,
- Input::GRP_EMOTION,
- &Actions::emote,
- InputAction::EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyEmoteShortcut15",
- addKey(SDLK_HOME),
- emptyKey,
- Input::GRP_EMOTION,
- &Actions::emote,
- InputAction::EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyEmoteShortcut16",
- addKey(SDLK_q),
- emptyKey,
- Input::GRP_EMOTION,
- &Actions::emote,
- InputAction::EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyEmoteShortcut17",
- addKey(SDLK_w),
- emptyKey,
- Input::GRP_EMOTION,
- &Actions::emote,
- InputAction::EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyEmoteShortcut18",
- addKey(SDLK_e),
- emptyKey,
- Input::GRP_EMOTION,
- &Actions::emote,
- InputAction::EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyEmoteShortcut19",
- addKey(SDLK_r),
- emptyKey,
- Input::GRP_EMOTION,
- &Actions::emote,
- InputAction::EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyEmoteShortcut20",
- addKey(SDLK_t),
- emptyKey,
- Input::GRP_EMOTION,
- &Actions::emote,
- InputAction::EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyEmoteShortcut21",
- addKey(SDLK_y),
- emptyKey,
- Input::GRP_EMOTION,
- &Actions::emote,
- InputAction::EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyEmoteShortcut22",
- addKey(SDLK_u),
- emptyKey,
- Input::GRP_EMOTION,
- &Actions::emote,
- InputAction::EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyEmoteShortcut23",
- addKey(SDLK_i),
- emptyKey,
- Input::GRP_EMOTION,
- &Actions::emote,
- InputAction::EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyEmoteShortcut24",
- addKey(SDLK_o),
- emptyKey,
- Input::GRP_EMOTION,
- &Actions::emote,
- InputAction::EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyEmoteShortcut25",
- addKey(SDLK_p),
- emptyKey,
- Input::GRP_EMOTION,
- &Actions::emote,
- InputAction::EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyEmoteShortcut26",
- addKey(SDLK_LEFTBRACKET),
- emptyKey,
- Input::GRP_EMOTION,
- &Actions::emote,
- InputAction::EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyEmoteShortcut27",
- addKey(SDLK_RIGHTBRACKET),
- emptyKey,
- Input::GRP_EMOTION,
- &Actions::emote,
- InputAction::EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyEmoteShortcut28",
- addKey(SDLK_BACKSLASH),
- emptyKey,
- Input::GRP_EMOTION,
- &Actions::emote,
- InputAction::EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyEmoteShortcut29",
- addKey(SDLK_a),
- emptyKey,
- Input::GRP_EMOTION,
- &Actions::emote,
- InputAction::EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyEmoteShortcut30",
- addKey(SDLK_s),
- emptyKey,
- Input::GRP_EMOTION,
- &Actions::emote,
- InputAction::EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyEmoteShortcut31",
- addKey(SDLK_d),
- emptyKey,
- Input::GRP_EMOTION,
- &Actions::emote,
- InputAction::EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyEmoteShortcut32",
- addKey(SDLK_f),
- emptyKey,
- Input::GRP_EMOTION,
- &Actions::emote,
- InputAction::EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyEmoteShortcut33",
- addKey(SDLK_g),
- emptyKey,
- Input::GRP_EMOTION,
- &Actions::emote,
- InputAction::EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyEmoteShortcut34",
- addKey(SDLK_h),
- emptyKey,
- Input::GRP_EMOTION,
- &Actions::emote,
- InputAction::EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyEmoteShortcut35",
- addKey(SDLK_j),
- emptyKey,
- Input::GRP_EMOTION,
- &Actions::emote,
- InputAction::EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyEmoteShortcut36",
- addKey(SDLK_k),
- emptyKey,
- Input::GRP_EMOTION,
- &Actions::emote,
- InputAction::EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyEmoteShortcut37",
- addKey(SDLK_l),
- emptyKey,
- Input::GRP_EMOTION,
- &Actions::emote,
- InputAction::EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyEmoteShortcut38",
- addKey(SDLK_SEMICOLON),
- emptyKey,
- Input::GRP_EMOTION,
- &Actions::emote,
- InputAction::EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyEmoteShortcut39",
- addKey(SDLK_QUOTE),
- emptyKey,
- Input::GRP_EMOTION,
- &Actions::emote,
- InputAction::EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyEmoteShortcut40",
- addKey(SDLK_z),
- emptyKey,
- Input::GRP_EMOTION,
- &Actions::emote,
- InputAction::EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyEmoteShortcut41",
- addKey(SDLK_x),
- emptyKey,
- Input::GRP_EMOTION,
- &Actions::emote,
- InputAction::EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyEmoteShortcut42",
- addKey(SDLK_c),
- emptyKey,
- Input::GRP_EMOTION,
- &Actions::emote,
- InputAction::EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyEmoteShortcut43",
- addKey(SDLK_v),
- emptyKey,
- Input::GRP_EMOTION,
- &Actions::emote,
- InputAction::EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyEmoteShortcut44",
- addKey(SDLK_b),
- emptyKey,
- Input::GRP_EMOTION,
- &Actions::emote,
- InputAction::EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyEmoteShortcut45",
- addKey(SDLK_n),
- emptyKey,
- Input::GRP_EMOTION,
- &Actions::emote,
- InputAction::EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyEmoteShortcut46",
- addKey(SDLK_m),
- emptyKey,
- Input::GRP_EMOTION,
- &Actions::emote,
- InputAction::EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyEmoteShortcut47",
- addKey(SDLK_COMMA),
- emptyKey,
- Input::GRP_EMOTION,
- &Actions::emote,
- InputAction::EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyEmoteShortcut48",
- addKey(SDLK_PERIOD),
- emptyKey,
- Input::GRP_EMOTION,
- &Actions::emote,
- InputAction::EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyWearOutfit",
- addKey(SDLK_RCTRL),
- emptyKey,
- Input::GRP_DEFAULT,
- nullptr,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::DEFAULT |
- InputCondition::INGAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyCopyOutfit",
- addKey(SDLK_RALT),
- emptyKey,
- Input::GRP_DEFAULT,
- nullptr,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::DEFAULT |
- InputCondition::INGAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyCopyEquipedOutfit",
- addKey(SDLK_RIGHTBRACKET),
- emptyKey,
- Input::GRP_DEFAULT,
- &Actions::copyEquippedToOutfit,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::GAME |
- InputCondition::VALIDSPEED,
- "copyequippedtooutfit|itemstooutfit",
- UseArgs_false,
- Protected_true},
- {"keyOutfitShortcut1",
- addKey(SDLK_1),
- emptyKey,
- Input::GRP_OUTFIT,
- &Actions::outfit,
- InputAction::NO_VALUE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyOutfitShortcut2",
- addKey(SDLK_2),
- emptyKey,
- Input::GRP_OUTFIT,
- &Actions::outfit,
- InputAction::NO_VALUE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyOutfitShortcut3",
- addKey(SDLK_3),
- emptyKey,
- Input::GRP_OUTFIT,
- &Actions::outfit,
- InputAction::NO_VALUE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyOutfitShortcut4",
- addKey(SDLK_4),
- emptyKey,
- Input::GRP_OUTFIT,
- &Actions::outfit,
- InputAction::NO_VALUE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyOutfitShortcut5",
- addKey(SDLK_5),
- emptyKey,
- Input::GRP_OUTFIT,
- &Actions::outfit,
- InputAction::NO_VALUE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyOutfitShortcut6",
- addKey(SDLK_6),
- emptyKey,
- Input::GRP_OUTFIT,
- &Actions::outfit,
- InputAction::NO_VALUE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyOutfitShortcut7",
- addKey(SDLK_7),
- emptyKey,
- Input::GRP_OUTFIT,
- &Actions::outfit,
- InputAction::NO_VALUE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyOutfitShortcut8",
- addKey(SDLK_8),
- emptyKey,
- Input::GRP_OUTFIT,
- &Actions::outfit,
- InputAction::NO_VALUE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyOutfitShortcut9",
- addKey(SDLK_9),
- emptyKey,
- Input::GRP_OUTFIT,
- &Actions::outfit,
- InputAction::NO_VALUE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyOutfitShortcut10",
- addKey(SDLK_0),
- emptyKey,
- Input::GRP_OUTFIT,
- &Actions::outfit,
- InputAction::NO_VALUE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyOutfitShortcut11",
- addKey(SDLK_MINUS),
- emptyKey,
- Input::GRP_OUTFIT,
- &Actions::outfit,
- InputAction::NO_VALUE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyOutfitShortcut12",
- addKey(SDLK_EQUALS),
- emptyKey,
- Input::GRP_OUTFIT,
- &Actions::outfit,
- InputAction::NO_VALUE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyOutfitShortcut13",
- addKey(SDLK_BACKSPACE),
- emptyKey,
- Input::GRP_OUTFIT,
- &Actions::outfit,
- InputAction::NO_VALUE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyOutfitShortcut14",
- addKey(SDLK_INSERT),
- emptyKey,
- Input::GRP_OUTFIT,
- &Actions::outfit,
- InputAction::NO_VALUE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyOutfitShortcut15",
- addKey(SDLK_HOME),
- emptyKey,
- Input::GRP_OUTFIT,
- &Actions::outfit,
- InputAction::NO_VALUE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyOutfitShortcut16",
- addKey(SDLK_q),
- emptyKey,
- Input::GRP_OUTFIT,
- &Actions::outfit,
- InputAction::NO_VALUE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyOutfitShortcut17",
- addKey(SDLK_w),
- emptyKey,
- Input::GRP_OUTFIT,
- &Actions::outfit,
- InputAction::NO_VALUE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyOutfitShortcut18",
- addKey(SDLK_e),
- emptyKey,
- Input::GRP_OUTFIT,
- &Actions::outfit,
- InputAction::NO_VALUE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyOutfitShortcut19",
- addKey(SDLK_r),
- emptyKey,
- Input::GRP_OUTFIT,
- &Actions::outfit,
- InputAction::NO_VALUE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyOutfitShortcut20",
- addKey(SDLK_t),
- emptyKey,
- Input::GRP_OUTFIT,
- &Actions::outfit,
- InputAction::NO_VALUE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyOutfitShortcut21",
- addKey(SDLK_y),
- emptyKey,
- Input::GRP_OUTFIT,
- &Actions::outfit,
- InputAction::NO_VALUE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyOutfitShortcut22",
- addKey(SDLK_u),
- emptyKey,
- Input::GRP_OUTFIT,
- &Actions::outfit,
- InputAction::NO_VALUE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyOutfitShortcut23",
- addKey(SDLK_i),
- emptyKey,
- Input::GRP_OUTFIT,
- &Actions::outfit,
- InputAction::NO_VALUE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyOutfitShortcut24",
- addKey(SDLK_o),
- emptyKey,
- Input::GRP_OUTFIT,
- &Actions::outfit,
- InputAction::NO_VALUE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyOutfitShortcut25",
- addKey(SDLK_p),
- emptyKey,
- Input::GRP_OUTFIT,
- &Actions::outfit,
- InputAction::NO_VALUE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyOutfitShortcut26",
- addKey(SDLK_LEFTBRACKET),
- emptyKey,
- Input::GRP_OUTFIT,
- &Actions::outfit,
- InputAction::NO_VALUE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyOutfitShortcut27",
- addKey(SDLK_RIGHTBRACKET),
- emptyKey,
- Input::GRP_OUTFIT,
- &Actions::outfit,
- InputAction::NO_VALUE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyOutfitShortcut28",
- addKey(SDLK_BACKSLASH),
- emptyKey,
- Input::GRP_OUTFIT,
- &Actions::outfit,
- InputAction::NO_VALUE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyOutfitShortcut29",
- addKey(SDLK_a),
- emptyKey,
- Input::GRP_OUTFIT,
- &Actions::outfit,
- InputAction::NO_VALUE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyOutfitShortcut30",
- addKey(SDLK_s),
- emptyKey,
- Input::GRP_OUTFIT,
- &Actions::outfit,
- InputAction::NO_VALUE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyOutfitShortcut31",
- addKey(SDLK_d),
- emptyKey,
- Input::GRP_OUTFIT,
- &Actions::outfit,
- InputAction::NO_VALUE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyOutfitShortcut32",
- addKey(SDLK_f),
- emptyKey,
- Input::GRP_OUTFIT,
- &Actions::outfit,
- InputAction::NO_VALUE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyOutfitShortcut33",
- addKey(SDLK_g),
- emptyKey,
- Input::GRP_OUTFIT,
- &Actions::outfit,
- InputAction::NO_VALUE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyOutfitShortcut34",
- addKey(SDLK_h),
- emptyKey,
- Input::GRP_OUTFIT,
- &Actions::outfit,
- InputAction::NO_VALUE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyOutfitShortcut35",
- addKey(SDLK_j),
- emptyKey,
- Input::GRP_OUTFIT,
- &Actions::outfit,
- InputAction::NO_VALUE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyOutfitShortcut36",
- addKey(SDLK_k),
- emptyKey,
- Input::GRP_OUTFIT,
- &Actions::outfit,
- InputAction::NO_VALUE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyOutfitShortcut37",
- addKey(SDLK_l),
- emptyKey,
- Input::GRP_OUTFIT,
- &Actions::outfit,
- InputAction::NO_VALUE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyOutfitShortcut38",
- addKey(SDLK_SEMICOLON),
- emptyKey,
- Input::GRP_OUTFIT,
- &Actions::outfit,
- InputAction::NO_VALUE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyOutfitShortcut39",
- addKey(SDLK_QUOTE),
- emptyKey,
- Input::GRP_OUTFIT,
- &Actions::outfit,
- InputAction::NO_VALUE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyOutfitShortcut40",
- addKey(SDLK_z),
- emptyKey,
- Input::GRP_OUTFIT,
- &Actions::outfit,
- InputAction::NO_VALUE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyOutfitShortcut41",
- addKey(SDLK_x),
- emptyKey,
- Input::GRP_OUTFIT,
- &Actions::outfit,
- InputAction::NO_VALUE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyOutfitShortcut42",
- addKey(SDLK_c),
- emptyKey,
- Input::GRP_OUTFIT,
- &Actions::outfit,
- InputAction::NO_VALUE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyOutfitShortcut43",
- addKey(SDLK_v),
- emptyKey,
- Input::GRP_OUTFIT,
- &Actions::outfit,
- InputAction::NO_VALUE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyOutfitShortcut44",
- addKey(SDLK_b),
- emptyKey,
- Input::GRP_OUTFIT,
- &Actions::outfit,
- InputAction::NO_VALUE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyOutfitShortcut45",
- addKey(SDLK_n),
- emptyKey,
- Input::GRP_OUTFIT,
- &Actions::outfit,
- InputAction::NO_VALUE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyOutfitShortcut46",
- addKey(SDLK_m),
- emptyKey,
- Input::GRP_OUTFIT,
- &Actions::outfit,
- InputAction::NO_VALUE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyOutfitShortcut47",
- addKey(SDLK_COMMA),
- emptyKey,
- Input::GRP_OUTFIT,
- &Actions::outfit,
- InputAction::NO_VALUE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyOutfitShortcut48",
- addKey(SDLK_PERIOD),
- emptyKey,
- Input::GRP_OUTFIT,
- &Actions::outfit,
- InputAction::NO_VALUE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyMoveToPointShortcut1",
- addKey(SDLK_1),
- emptyKey,
- Input::GRP_MOVETOPOINT,
- &Actions::moveToPoint,
- InputAction::MOVE_TO_POINT, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyMoveToPointShortcut2",
- addKey(SDLK_2),
- emptyKey,
- Input::GRP_MOVETOPOINT,
- &Actions::moveToPoint,
- InputAction::MOVE_TO_POINT, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyMoveToPointShortcut3",
- addKey(SDLK_3),
- emptyKey,
- Input::GRP_MOVETOPOINT,
- &Actions::moveToPoint,
- InputAction::MOVE_TO_POINT, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyMoveToPointShortcut4",
- addKey(SDLK_4),
- emptyKey,
- Input::GRP_MOVETOPOINT,
- &Actions::moveToPoint,
- InputAction::MOVE_TO_POINT, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyMoveToPointShortcut5",
- addKey(SDLK_5),
- emptyKey,
- Input::GRP_MOVETOPOINT,
- &Actions::moveToPoint,
- InputAction::MOVE_TO_POINT, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyMoveToPointShortcut6",
- addKey(SDLK_6),
- emptyKey,
- Input::GRP_MOVETOPOINT,
- &Actions::moveToPoint,
- InputAction::MOVE_TO_POINT, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyMoveToPointShortcut7",
- addKey(SDLK_7),
- emptyKey,
- Input::GRP_MOVETOPOINT,
- &Actions::moveToPoint,
- InputAction::MOVE_TO_POINT, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyMoveToPointShortcut8",
- addKey(SDLK_8),
- emptyKey,
- Input::GRP_MOVETOPOINT,
- &Actions::moveToPoint,
- InputAction::MOVE_TO_POINT, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyMoveToPointShortcut9",
- addKey(SDLK_9),
- emptyKey,
- Input::GRP_MOVETOPOINT,
- &Actions::moveToPoint,
- InputAction::MOVE_TO_POINT, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyMoveToPointShortcut10",
- addKey(SDLK_0),
- emptyKey,
- Input::GRP_MOVETOPOINT,
- &Actions::moveToPoint,
- InputAction::MOVE_TO_POINT, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyMoveToPointShortcut11",
- addKey(SDLK_MINUS),
- emptyKey,
- Input::GRP_MOVETOPOINT,
- &Actions::moveToPoint,
- InputAction::MOVE_TO_POINT, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyMoveToPointShortcut12",
- addKey(SDLK_EQUALS),
- emptyKey,
- Input::GRP_MOVETOPOINT,
- &Actions::moveToPoint,
- InputAction::MOVE_TO_POINT, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyMoveToPointShortcut13",
- addKey(SDLK_BACKSPACE),
- emptyKey,
- Input::GRP_MOVETOPOINT,
- &Actions::moveToPoint,
- InputAction::MOVE_TO_POINT, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyMoveToPointShortcut14",
- addKey(SDLK_INSERT),
- emptyKey,
- Input::GRP_MOVETOPOINT,
- &Actions::moveToPoint,
- InputAction::MOVE_TO_POINT, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyMoveToPointShortcut15",
- addKey(SDLK_HOME),
- emptyKey,
- Input::GRP_MOVETOPOINT,
- &Actions::moveToPoint,
- InputAction::MOVE_TO_POINT, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyMoveToPointShortcut16",
- addKey(SDLK_q),
- emptyKey,
- Input::GRP_MOVETOPOINT,
- &Actions::moveToPoint,
- InputAction::MOVE_TO_POINT, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyMoveToPointShortcut17",
- addKey(SDLK_w),
- emptyKey,
- Input::GRP_MOVETOPOINT,
- &Actions::moveToPoint,
- InputAction::MOVE_TO_POINT, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyMoveToPointShortcut18",
- addKey(SDLK_e),
- emptyKey,
- Input::GRP_MOVETOPOINT,
- &Actions::moveToPoint,
- InputAction::MOVE_TO_POINT, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyMoveToPointShortcut19",
- addKey(SDLK_r),
- emptyKey,
- Input::GRP_MOVETOPOINT,
- &Actions::moveToPoint,
- InputAction::MOVE_TO_POINT, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyMoveToPointShortcut20",
- addKey(SDLK_t),
- emptyKey,
- Input::GRP_MOVETOPOINT,
- &Actions::moveToPoint,
- InputAction::MOVE_TO_POINT, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyMoveToPointShortcut21",
- addKey(SDLK_y),
- emptyKey,
- Input::GRP_MOVETOPOINT,
- &Actions::moveToPoint,
- InputAction::MOVE_TO_POINT, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyMoveToPointShortcut22",
- addKey(SDLK_u),
- emptyKey,
- Input::GRP_MOVETOPOINT,
- &Actions::moveToPoint,
- InputAction::MOVE_TO_POINT, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyMoveToPointShortcut23",
- addKey(SDLK_i),
- emptyKey,
- Input::GRP_MOVETOPOINT,
- &Actions::moveToPoint,
- InputAction::MOVE_TO_POINT, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyMoveToPointShortcut24",
- addKey(SDLK_o),
- emptyKey,
- Input::GRP_MOVETOPOINT,
- &Actions::moveToPoint,
- InputAction::MOVE_TO_POINT, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyMoveToPointShortcut25",
- addKey(SDLK_p),
- emptyKey,
- Input::GRP_MOVETOPOINT,
- &Actions::moveToPoint,
- InputAction::MOVE_TO_POINT, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyMoveToPointShortcut26",
- addKey(SDLK_LEFTBRACKET),
- emptyKey,
- Input::GRP_MOVETOPOINT,
- &Actions::moveToPoint,
- InputAction::MOVE_TO_POINT, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyMoveToPointShortcut27",
- addKey(SDLK_RIGHTBRACKET),
- emptyKey,
- Input::GRP_MOVETOPOINT,
- &Actions::moveToPoint,
- InputAction::MOVE_TO_POINT, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyMoveToPointShortcut28",
- addKey(SDLK_BACKSLASH),
- emptyKey,
- Input::GRP_MOVETOPOINT,
- &Actions::moveToPoint,
- InputAction::MOVE_TO_POINT, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyMoveToPointShortcut29",
- addKey(SDLK_a),
- emptyKey,
- Input::GRP_MOVETOPOINT,
- &Actions::moveToPoint,
- InputAction::MOVE_TO_POINT, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyMoveToPointShortcut30",
- addKey(SDLK_s),
- emptyKey,
- Input::GRP_MOVETOPOINT,
- &Actions::moveToPoint,
- InputAction::MOVE_TO_POINT, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyMoveToPointShortcut31",
- addKey(SDLK_d),
- emptyKey,
- Input::GRP_MOVETOPOINT,
- &Actions::moveToPoint,
- InputAction::MOVE_TO_POINT, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyMoveToPointShortcut32",
- addKey(SDLK_f),
- emptyKey,
- Input::GRP_MOVETOPOINT,
- &Actions::moveToPoint,
- InputAction::MOVE_TO_POINT, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyMoveToPointShortcut33",
- addKey(SDLK_g),
- emptyKey,
- Input::GRP_MOVETOPOINT,
- &Actions::moveToPoint,
- InputAction::MOVE_TO_POINT, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyMoveToPointShortcut34",
- addKey(SDLK_h),
- emptyKey,
- Input::GRP_MOVETOPOINT,
- &Actions::moveToPoint,
- InputAction::MOVE_TO_POINT, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyMoveToPointShortcut35",
- addKey(SDLK_j),
- emptyKey,
- Input::GRP_MOVETOPOINT,
- &Actions::moveToPoint,
- InputAction::MOVE_TO_POINT, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyMoveToPointShortcut36",
- addKey(SDLK_k),
- emptyKey,
- Input::GRP_MOVETOPOINT,
- &Actions::moveToPoint,
- InputAction::MOVE_TO_POINT, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyMoveToPointShortcut37",
- addKey(SDLK_l),
- emptyKey,
- Input::GRP_MOVETOPOINT,
- &Actions::moveToPoint,
- InputAction::MOVE_TO_POINT, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyMoveToPointShortcut38",
- addKey(SDLK_SEMICOLON),
- emptyKey,
- Input::GRP_MOVETOPOINT,
- &Actions::moveToPoint,
- InputAction::MOVE_TO_POINT, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyMoveToPointShortcut39",
- addKey(SDLK_QUOTE),
- emptyKey,
- Input::GRP_MOVETOPOINT,
- &Actions::moveToPoint,
- InputAction::MOVE_TO_POINT, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyMoveToPointShortcut40",
- addKey(SDLK_z),
- emptyKey,
- Input::GRP_MOVETOPOINT,
- &Actions::moveToPoint,
- InputAction::MOVE_TO_POINT, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyMoveToPointShortcut41",
- addKey(SDLK_x),
- emptyKey,
- Input::GRP_MOVETOPOINT,
- &Actions::moveToPoint,
- InputAction::MOVE_TO_POINT, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyMoveToPointShortcut42",
- addKey(SDLK_c),
- emptyKey,
- Input::GRP_MOVETOPOINT,
- &Actions::moveToPoint,
- InputAction::MOVE_TO_POINT, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyMoveToPointShortcut43",
- addKey(SDLK_v),
- emptyKey,
- Input::GRP_MOVETOPOINT,
- &Actions::moveToPoint,
- InputAction::MOVE_TO_POINT, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyMoveToPointShortcut44",
- addKey(SDLK_b),
- emptyKey,
- Input::GRP_MOVETOPOINT,
- &Actions::moveToPoint,
- InputAction::MOVE_TO_POINT, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyMoveToPointShortcut45",
- addKey(SDLK_n),
- emptyKey,
- Input::GRP_MOVETOPOINT,
- &Actions::moveToPoint,
- InputAction::MOVE_TO_POINT, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyMoveToPointShortcut46",
- addKey(SDLK_m),
- emptyKey,
- Input::GRP_MOVETOPOINT,
- &Actions::moveToPoint,
- InputAction::MOVE_TO_POINT, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyMoveToPointShortcut47",
- addKey(SDLK_COMMA),
- emptyKey,
- Input::GRP_MOVETOPOINT,
- &Actions::moveToPoint,
- InputAction::MOVE_TO_POINT, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyMoveToPointShortcut48",
- addKey(SDLK_PERIOD),
- emptyKey,
- Input::GRP_MOVETOPOINT,
- &Actions::moveToPoint,
- InputAction::MOVE_TO_POINT, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_true},
- {"keyChat",
- addKey(SDLK_RETURN),
- emptyKey,
- Input::GRP_DEFAULT | Input::GRP_CHAT,
- &Actions::toggleChat,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::NOINPUT |
- InputCondition::NOAWAY |
- InputCondition::NOMODAL,
- "chat",
- UseArgs_false,
- Protected_false},
- {"keyChatScrollUp",
- addKey(SDLK_PAGEUP),
- emptyKey,
- Input::GRP_DEFAULT | Input::GRP_GUI,
- &Actions::scrollChatUp,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::DEFAULT |
- InputCondition::INGAME,
- "chatscrollup",
- UseArgs_false,
- Protected_false},
- {"keyChatScrollDown",
- addKey(SDLK_PAGEDOWN),
- emptyKey,
- Input::GRP_DEFAULT | Input::GRP_GUI,
- &Actions::scrollChatDown,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::DEFAULT |
- InputCondition::INGAME,
- "chatscrolldown",
- UseArgs_false,
- Protected_false},
- {"keyChatPrevTab",
- addKey(SDLK_KP7),
- emptyKey,
- Input::GRP_DEFAULT | Input::GRP_GUI,
- &Actions::prevChatTab,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::NOINPUT |
- InputCondition::INGAME,
- "prevtab",
- UseArgs_false,
- Protected_false},
- {"keyChatNextTab",
- addKey(SDLK_KP9),
- emptyKey,
- Input::GRP_DEFAULT | Input::GRP_GUI,
- &Actions::nextChatTab,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::NOINPUT |
- InputCondition::INGAME,
- "nexttab",
- UseArgs_false,
- Protected_false},
- {"keyChatCloseTab",
- emptyKey,
- emptyKey,
- Input::GRP_DEFAULT | Input::GRP_GUI,
- &Actions::closeChatTab,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::NOINPUT |
- InputCondition::INGAME,
- "close",
- UseArgs_false,
- Protected_false},
- {"keyChatPrevHistory",
- addKey(SDLK_KP7),
- emptyKey,
- Input::GRP_CHAT | Input::GRP_GUICHAN,
- nullptr,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::DEFAULT |
- InputCondition::INGAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyChatNextHistory",
- addKey(SDLK_KP9),
- emptyKey,
- Input::GRP_CHAT | Input::GRP_GUICHAN,
- nullptr,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::DEFAULT |
- InputCondition::INGAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyIgnoreInput1",
-#ifdef USE_SDL2
- addKey(SDLK_LGUI),
-#else // USE_SDL2
- addKey(SDLK_LSUPER),
-#endif // USE_SDL2
- emptyKey,
- Input::GRP_DEFAULT,
- &Actions::ignoreInput,
- InputAction::NO_VALUE, 500,
- InputCondition::KEY_DOWN | InputCondition::DEFAULT,
- "",
- UseArgs_false,
- Protected_true},
- {"keyIgnoreInput2",
-#ifdef USE_SDL2
- addKey(SDLK_RGUI),
-#else // USE_SDL2
- addKey(SDLK_RSUPER),
-#endif // USE_SDL2
- emptyKey,
- Input::GRP_DEFAULT,
- &Actions::ignoreInput,
- InputAction::NO_VALUE, 500,
- InputCondition::KEY_DOWN | InputCondition::DEFAULT,
- "",
- UseArgs_false,
- Protected_true},
- {"keyDirectUp",
- defaultAction(&Actions::directUp),
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "directup|turnup",
- UseArgs_false,
- Protected_false},
- {"keyDirectDown",
- defaultAction(&Actions::directDown),
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "directdown|turndown",
- UseArgs_false,
- Protected_false},
- {"keyDirectLeft",
- defaultAction(&Actions::directLeft),
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "directleft|turnleft",
- UseArgs_false,
- Protected_false},
- {"keyDirectRight",
- defaultAction(&Actions::directRight),
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "directright|turnright",
- UseArgs_false,
- Protected_false},
- {"keyCrazyMoves",
- addKey(SDLK_SLASH),
- emptyKey,
- Input::GRP_DEFAULT,
- &Actions::crazyMoves,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::GAME |
- InputCondition::VALIDSPEED,
- "",
- UseArgs_false,
- Protected_true},
- {"keyChangeCrazyMoveType",
- addKey(SDLK_BACKSLASH),
- emptyKey,
- Input::GRP_DEFAULT,
- &Actions::changeCrazyMove,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::GAME |
- InputCondition::VALIDSPEED |
- InputCondition::EMODS,
- "",
- UseArgs_false,
- Protected_true},
- {"keyQuickDrop",
- addKey(SDLK_y),
- emptyKey,
- Input::GRP_DEFAULT,
- &Actions::dropItem0,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::GAME |
- InputCondition::VALIDSPEED,
- "drop",
- UseArgs_false,
- Protected_true},
- {"keyQuickDropN",
- addKey(SDLK_u),
- emptyKey,
- Input::GRP_DEFAULT,
- &Actions::dropItem,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::GAME |
- InputCondition::VALIDSPEED,
- "dropn",
- UseArgs_false,
- Protected_true},
- {"keySwitchQuickDrop",
- addKey(SDLK_i),
- emptyKey,
- Input::GRP_DEFAULT,
- &Actions::switchQuickDrop,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::GAME |
- InputCondition::VALIDSPEED,
- "",
- UseArgs_false,
- Protected_true},
- {"keyMagicInma1",
- addKey(SDLK_c),
- emptyKey,
- Input::GRP_DEFAULT,
- &Actions::heal,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::GAME |
- InputCondition::VALIDSPEED,
- "heal",
- UseArgs_true,
- Protected_false},
- {"keyMagicItenplz",
- addKey(SDLK_m),
- emptyKey,
- Input::GRP_DEFAULT,
- &Actions::itenplz,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::GAME |
- InputCondition::VALIDSPEED,
- "itenplz",
- UseArgs_false,
- Protected_true},
- {"keyMagicAttack",
- addKey(SDLK_b),
- emptyKey,
- Input::GRP_DEFAULT,
- &Actions::magicAttack,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::GAME |
- InputCondition::NOFOLLOW |
- InputCondition::VALIDSPEED,
- "magicattack",
- UseArgs_false,
- Protected_false},
- {"keySwitchMagicAttack",
- addKey(SDLK_COMMA),
- emptyKey,
- Input::GRP_DEFAULT,
- &Actions::changeMagicAttackType,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::GAME |
- InputCondition::VALIDSPEED |
- InputCondition::EMODS,
- "",
- UseArgs_false,
- Protected_true},
- {"keySwitchPvpAttack",
- defaultAction(&Actions::changePvpMode),
- InputCondition::KEY_DOWN |
- InputCondition::GAME |
- InputCondition::VALIDSPEED |
- InputCondition::EMODS,
- "",
- UseArgs_false,
- Protected_true},
- {"keyInvertDirection",
- defaultAction(&Actions::changeMoveType),
- InputCondition::KEY_DOWN |
- InputCondition::GAME |
- InputCondition::VALIDSPEED |
- InputCondition::EMODS,
- "",
- UseArgs_false,
- Protected_false},
- {"keyChangeAttackWeaponType",
- addKey(SDLK_g),
- emptyKey,
- Input::GRP_DEFAULT,
- &Actions::changeAttackWeaponType,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::GAME |
- InputCondition::VALIDSPEED |
- InputCondition::EMODS,
- "",
- UseArgs_false,
- Protected_true},
- {"keyChangeAttackType",
- addKey(SDLK_END),
- emptyKey,
- Input::GRP_DEFAULT,
- &Actions::changeAttackType,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::GAME |
- InputCondition::VALIDSPEED |
- InputCondition::EMODS,
- "",
- UseArgs_false,
- Protected_true},
- {"keyChangeFollowMode",
- addKey(SDLK_KP1),
- emptyKey,
- Input::GRP_DEFAULT,
- &Actions::changeFollowMode,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::GAME |
- InputCondition::VALIDSPEED |
- InputCondition::EMODS,
- "",
- UseArgs_false,
- Protected_true},
- {"keyChangeImitationMode",
- addKey(SDLK_KP4),
- emptyKey,
- Input::GRP_DEFAULT,
- &Actions::changeImitationMode,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::GAME |
- InputCondition::VALIDSPEED |
- InputCondition::EMODS,
- "",
- UseArgs_false,
- Protected_true},
- {"keyDisableGameModifiers",
- addKey(SDLK_KP8),
- emptyKey,
- Input::GRP_DEFAULT,
- &Actions::changeGameModifier,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::GAME |
- InputCondition::VALIDSPEED,
- "",
- UseArgs_false,
- Protected_true},
- {"keyChangeAudio",
- addKey(SDLK_KP3),
- emptyKey,
- Input::GRP_DEFAULT,
- &Actions::changeAudio,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::GAME |
- InputCondition::VALIDSPEED,
- "audio",
- UseArgs_false,
- Protected_true},
- {"keyAway",
- addKey(SDLK_KP2),
- emptyKey,
- Input::GRP_DEFAULT,
- &Actions::away,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::GAME |
- InputCondition::VALIDSPEED,
- "",
- UseArgs_false,
- Protected_false},
- {"keyRightClick",
- addKey(SDLK_TAB),
- emptyKey,
- Input::GRP_DEFAULT,
- &Actions::mouseClick,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::NOINPUT |
- InputCondition::NOAWAY |
- InputCondition::NOMODAL |
- InputCondition::INGAME,
- "rightclick",
- UseArgs_false,
- Protected_false},
- {"keyCameraMode",
- addKey(SDLK_KP_PLUS),
- emptyKey,
- Input::GRP_DEFAULT,
- &Actions::camera,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::GAME |
- InputCondition::VALIDSPEED |
- InputCondition::EMODS,
- "",
- UseArgs_false,
- Protected_false},
- {"keyMod",
- emptyKey,
- emptyKey,
- 0,
- nullptr,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::DEFAULT,
- "",
- UseArgs_false,
- Protected_false},
- {"keyGUIUp",
- addKey(SDLK_UP),
- emptyKey,
- Input::GRP_GUICHAN,
- nullptr,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::DEFAULT,
- "",
- UseArgs_false,
- Protected_false},
- {"keyGUIDown",
- addKey(SDLK_DOWN),
- emptyKey,
- Input::GRP_GUICHAN,
- nullptr,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::DEFAULT,
- "",
- UseArgs_false,
- Protected_false},
- {"keyGUILeft",
- addKey(SDLK_LEFT),
- emptyKey,
- Input::GRP_GUICHAN,
- nullptr,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::DEFAULT,
- "",
- UseArgs_false,
- Protected_false},
- {"keyGUIRight",
- addKey(SDLK_RIGHT),
- emptyKey,
- Input::GRP_GUICHAN,
- nullptr,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::DEFAULT,
- "",
- UseArgs_false,
- Protected_false},
- {"keyGUISelect",
- addKey(SDLK_SPACE),
- emptyKey,
- Input::GRP_GUICHAN,
- nullptr,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::DEFAULT,
- "",
- UseArgs_false,
- Protected_false},
- {"keyGUISelect2",
- addKey(SDLK_RETURN),
- emptyKey,
- Input::GRP_GUICHAN,
- nullptr,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::DEFAULT,
- "",
- UseArgs_false,
- Protected_false},
- {"keyGUICancel",
- addKey(SDLK_ESCAPE),
-#if defined(USE_SDL2) && defined(ANDROID)
- addKey(SDLK_AC_BACK),
-#else // defined(USE_SDL2) && defined(ANDROID)
- emptyKey,
-#endif // defined(USE_SDL2) && defined(ANDROID)
- Input::GRP_GUICHAN,
- nullptr,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::DEFAULT,
- "",
- UseArgs_false,
- Protected_false},
- {"keyGUIHome",
- addKey(SDLK_HOME),
- emptyKey,
- Input::GRP_GUICHAN,
- nullptr,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::DEFAULT,
- "",
- UseArgs_false,
- Protected_false},
- {"keyGUIEnd",
- addKey(SDLK_END),
- emptyKey,
- Input::GRP_GUICHAN,
- nullptr,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::DEFAULT,
- "",
- UseArgs_false,
- Protected_false},
- {"keyGUIDelete",
- addKey(SDLK_DELETE),
- emptyKey,
- Input::GRP_GUICHAN,
- nullptr,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::DEFAULT,
- "",
- UseArgs_false,
- Protected_false},
- {"keyGUIBackSpace",
- addKey(SDLK_BACKSPACE),
- emptyKey,
- Input::GRP_GUICHAN,
- nullptr,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::DEFAULT,
- "",
- UseArgs_false,
- Protected_false},
- {"keyGUITab",
- addKey(SDLK_TAB),
- emptyKey,
- Input::GRP_GUICHAN,
- nullptr,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::DEFAULT,
- "",
- UseArgs_false,
- Protected_false},
- {"keyGUIPageUp",
- addKey(SDLK_PAGEUP),
- emptyKey,
- Input::GRP_GUICHAN,
- nullptr,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::DEFAULT,
- "",
- UseArgs_false,
- Protected_false},
- {"keyGUIPageDown",
- addKey(SDLK_PAGEDOWN),
- emptyKey,
- Input::GRP_GUICHAN,
- nullptr,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::DEFAULT,
- "",
- UseArgs_false,
- Protected_false},
- {"keyGUIInsert",
- addKey(SDLK_INSERT),
- emptyKey,
- Input::GRP_GUICHAN,
- nullptr,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::DEFAULT,
- "",
- UseArgs_false,
- Protected_false},
- {"keyGUIMod",
- addKey(SDLK_LSHIFT),
- addKey(SDLK_RSHIFT),
- Input::GRP_GUICHAN,
- nullptr,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::DEFAULT,
- "",
- UseArgs_false,
- Protected_false},
- {"keySafeVideo",
- addKey(SDLK_KP_MINUS),
- emptyKey,
- Input::GRP_DEFAULT,
- &Actions::safeVideoMode,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::DEFAULT,
- "",
- UseArgs_false,
- Protected_true},
- {"keyStopSit",
- defaultAction(&Actions::stopSit),
- InputCondition::KEY_DOWN |
- InputCondition::DEFAULT |
- InputCondition::INGAME,
- "sit2",
- UseArgs_false,
- Protected_false},
- {"keyShowKeyboard",
- defaultAction(&Actions::showKeyboard),
- InputCondition::KEY_DOWN | InputCondition::DEFAULT,
- "showkeyboard",
- UseArgs_false,
- Protected_false},
- {"keyShowWindows",
- defaultAction(&Actions::showWindows),
- InputCondition::KEY_DOWN |
- InputCondition::DEFAULT |
- InputCondition::INGAME,
- "showwindows",
- UseArgs_false,
- Protected_false},
- {"keyChatMod",
- addKey(SDLK_LSHIFT),
- emptyKey,
- Input::GRP_CHAT,
- nullptr,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::DEFAULT |
- InputCondition::INGAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyMoveForward",
- defaultAction(&Actions::moveForward),
- InputCondition::KEY_DOWN | InputCondition::ARROWKEYS,
- "",
- UseArgs_false,
- Protected_false},
- {"keyGUICtrl",
- addKey(SDLK_LCTRL),
- addKey(SDLK_RCTRL),
- Input::GRP_GUICHAN,
- nullptr,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::DEFAULT,
- "",
- UseArgs_false,
- Protected_false},
- {"keyGUIb",
- addKey(SDLK_b),
- emptyKey,
- Input::GRP_GUICHAN,
- nullptr,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::DEFAULT,
- "",
- UseArgs_false,
- Protected_false},
- {"keyGUIc",
- addKey(SDLK_c),
- emptyKey,
- Input::GRP_GUICHAN,
- nullptr,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::DEFAULT,
- "",
- UseArgs_false,
- Protected_false},
- {"keyGUId",
- addKey(SDLK_d),
- emptyKey,
- Input::GRP_GUICHAN,
- nullptr,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::DEFAULT,
- "",
- UseArgs_false,
- Protected_false},
- {"keyGUIe",
- addKey(SDLK_e),
- emptyKey,
- Input::GRP_GUICHAN,
- nullptr,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::DEFAULT,
- "",
- UseArgs_false,
- Protected_false},
- {"keyGUIf",
- addKey(SDLK_f),
- emptyKey,
- Input::GRP_GUICHAN,
- nullptr,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::DEFAULT,
- "",
- UseArgs_false,
- Protected_false},
- {"keyGUIh",
- addKey(SDLK_h),
- emptyKey,
- Input::GRP_GUICHAN,
- nullptr,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::DEFAULT,
- "",
- UseArgs_false,
- Protected_false},
- {"keyGUIk",
- addKey(SDLK_k),
- emptyKey,
- Input::GRP_GUICHAN,
- nullptr,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::DEFAULT,
- "",
- UseArgs_false,
- Protected_false},
- {"keyGUIu",
- addKey(SDLK_u),
- emptyKey,
- Input::GRP_GUICHAN,
- nullptr,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::DEFAULT,
- "",
- UseArgs_false,
- Protected_false},
- {"keyGUIv",
- addKey(SDLK_v),
- emptyKey,
- Input::GRP_GUICHAN,
- nullptr,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::DEFAULT,
- "",
- UseArgs_false,
- Protected_false},
- {"keyGUIw",
- addKey(SDLK_w),
- emptyKey,
- Input::GRP_GUICHAN,
- nullptr,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::DEFAULT,
- "",
- UseArgs_false,
- Protected_false},
- {"keyShortcutsPrevTab",
- emptyKey,
- emptyKey,
- Input::GRP_DEFAULT | Input::GRP_GUI,
- &Actions::prevShortcutsTab,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::NOINPUT |
- InputCondition::INGAME,
- "shortcutprevtab",
- UseArgs_false,
- Protected_false},
- {"keyShortcutsNextTab",
- emptyKey,
- emptyKey,
- Input::GRP_DEFAULT | Input::GRP_GUI,
- &Actions::nextShortcutsTab,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::NOINPUT |
- InputCondition::INGAME,
- "shortcutnexttab",
- UseArgs_false,
- Protected_false},
- {"keyCommandsPrevTab",
- emptyKey,
- emptyKey,
- Input::GRP_DEFAULT | Input::GRP_GUI,
- &Actions::prevCommandsTab,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::NOINPUT |
- InputCondition::INGAME,
- "commandsprevtab",
- UseArgs_false,
- Protected_false},
- {"keyCommandsNextTab",
- emptyKey,
- emptyKey,
- Input::GRP_DEFAULT | Input::GRP_GUI,
- &Actions::nextCommandsTab,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::NOINPUT |
- InputCondition::INGAME,
- "commandsnexttab",
- UseArgs_false,
- Protected_false},
- {"keyOpenTrade",
- defaultAction(&Actions::openTrade),
- InputCondition::KEY_DOWN |
- InputCondition::GAME |
- InputCondition::NOTARGET,
- "trade",
- UseArgs_false,
- Protected_false},
- {"keyGUIF1",
- addKey(SDLK_F1),
- emptyKey,
- Input::GRP_GUICHAN | Input::GRP_CHAT,
- nullptr,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::DEFAULT,
- "",
- UseArgs_false,
- Protected_false},
- {"keyGUIF2",
- addKey(SDLK_F2),
- emptyKey,
- Input::GRP_GUICHAN | Input::GRP_CHAT,
- nullptr,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::DEFAULT,
- "",
- UseArgs_false,
- Protected_false},
- {"keyGUIF3",
- addKey(SDLK_F3),
- emptyKey,
- Input::GRP_GUICHAN | Input::GRP_CHAT,
- nullptr,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::DEFAULT,
- "",
- UseArgs_false,
- Protected_false},
- {"keyGUIF4",
- addKey(SDLK_F4),
- emptyKey,
- Input::GRP_GUICHAN | Input::GRP_CHAT,
- nullptr,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::DEFAULT,
- "",
- UseArgs_false,
- Protected_false},
- {"keyGUIF5",
- addKey(SDLK_F5),
- emptyKey,
- Input::GRP_GUICHAN | Input::GRP_CHAT,
- nullptr,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::DEFAULT,
- "",
- UseArgs_false,
- Protected_false},
- {"keyGUIF6",
- addKey(SDLK_F6),
- emptyKey,
- Input::GRP_GUICHAN | Input::GRP_CHAT,
- nullptr,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::DEFAULT,
- "",
- UseArgs_false,
- Protected_false},
- {"keyGUIF7",
- addKey(SDLK_F7),
- emptyKey,
- Input::GRP_GUICHAN | Input::GRP_CHAT,
- nullptr,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::DEFAULT,
- "",
- UseArgs_false,
- Protected_false},
- {"keyGUIF8",
- addKey(SDLK_F8),
- emptyKey,
- Input::GRP_GUICHAN | Input::GRP_CHAT,
- nullptr,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::DEFAULT,
- "",
- UseArgs_false,
- Protected_false},
- {"keyGUIF9",
- addKey(SDLK_F9),
- emptyKey,
- Input::GRP_GUICHAN | Input::GRP_CHAT,
- nullptr,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::DEFAULT,
- "",
- UseArgs_false,
- Protected_false},
- {"keyGUIF10",
- addKey(SDLK_F10),
- emptyKey,
- Input::GRP_GUICHAN | Input::GRP_CHAT,
- nullptr,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::DEFAULT,
- "",
- UseArgs_false,
- Protected_false},
- {"keyGUIF11",
- addKey(SDLK_F11),
- emptyKey,
- Input::GRP_GUICHAN | Input::GRP_CHAT,
- nullptr,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::DEFAULT,
- "",
- UseArgs_false,
- Protected_false},
- {"keyGUIF12",
- addKey(SDLK_F12),
- emptyKey,
- Input::GRP_GUICHAN | Input::GRP_CHAT,
- nullptr,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::DEFAULT,
- "",
- UseArgs_false,
- Protected_false},
- {"keyWindowAbout",
- emptyKey,
- emptyKey,
- Input::GRP_DEFAULT | Input::GRP_GUI,
- &Actions::aboutWindowShow,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::SHORTCUT0,
- "about",
- UseArgs_false,
- Protected_false},
- {"keyWindowUpdater",
- emptyKey,
- emptyKey,
- Input::GRP_DEFAULT | Input::GRP_GUI,
- &Actions::updaterWindowShow,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "updater",
- UseArgs_false,
- Protected_false},
- {"keyTargetClosestMonster",
- emptyKey,
- emptyKey,
- Input::GRP_DEFAULT | Input::GRP_REPEAT,
- &Actions::targetClosestMonster,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::GAME |
- InputCondition::NOTARGET |
- InputCondition::VALIDSPEED,
- "targetclosestmonster",
- UseArgs_false,
- Protected_false},
- {"keyChatCloseAllTabs",
- emptyKey,
- emptyKey,
- Input::GRP_DEFAULT | Input::GRP_GUI,
- &Actions::closeAllChatTabs,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "closeall",
- UseArgs_false,
- Protected_true},
- {"keyChatIgnoreAllWhispers",
- emptyKey,
- emptyKey,
- Input::GRP_DEFAULT | Input::GRP_GUI,
- &Actions::ignoreAllWhispers,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "ignoreallwhispers",
- UseArgs_false,
- Protected_true},
- {"keyChatAnnounce",
- emptyKey,
- emptyKey,
- Input::GRP_DEFAULT | Input::GRP_GUI,
- &Actions::chatAnnounce,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "announce",
- UseArgs_true,
- Protected_true},
- {"keyIpcToggle",
- defaultAction(&Actions::ipcToggle),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "ipctoggle",
- UseArgs_false,
- Protected_true},
- {"keyWhere",
- defaultAction(&Actions::where),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "where",
- UseArgs_false,
- Protected_false},
- {"keyWho",
- defaultAction(&Actions::who),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "who",
- UseArgs_false,
- Protected_false},
- {"keyWhisper",
- defaultAction(&Actions::msg),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "w|whisper|msg",
- UseArgs_true,
- Protected_true},
- {"keyQuery",
- defaultAction(&Actions::query),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "q|query|j|join",
- UseArgs_true,
- Protected_false},
- {"keyClearChatTab",
- defaultAction(&Actions::clearChatTab),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "clear",
- UseArgs_false,
- Protected_false},
- {"keyIgnore",
- defaultAction(&Actions::chatIgnore),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "ignore",
- UseArgs_true,
- Protected_true},
- {"keyUnignore",
- defaultAction(&Actions::chatUnignore),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "unignore",
- UseArgs_true,
- Protected_true},
- {"keyFriend",
- defaultAction(&Actions::chatFriend),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "friend|befriend",
- UseArgs_true,
- Protected_true},
- {"keyDisregard",
- defaultAction(&Actions::chatDisregard),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "disregard",
- UseArgs_true,
- Protected_true},
- {"keyNeutral",
- defaultAction(&Actions::chatNeutral),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "neutral",
- UseArgs_true,
- Protected_true},
- {"keyBlacklist",
- defaultAction(&Actions::chatBlackList),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "blacklist",
- UseArgs_true,
- Protected_true},
- {"keyEnemy",
- defaultAction(&Actions::chatEnemy),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "enemy",
- UseArgs_true,
- Protected_true},
- {"keyErase",
- defaultAction(&Actions::chatErase),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "erase",
- UseArgs_true,
- Protected_true},
- {"keyCleanGraphics",
- defaultAction(&Actions::cleanGraphics),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "cleangraphics",
- UseArgs_false,
- Protected_false},
- {"keyCleanFonts",
- defaultAction(&Actions::cleanFonts),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "cleanfonts",
- UseArgs_false,
- Protected_false},
- {"keyCreateParty",
- defaultAction(&Actions::createParty),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "createparty",
- UseArgs_true,
- Protected_true},
- {"keyCreateGuild",
- defaultAction(&Actions::createGuild),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "createguild",
- UseArgs_true,
- Protected_true},
- {"keyParty",
- defaultAction(&Actions::party),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "party",
- UseArgs_true,
- Protected_true},
- {"keyMe",
- defaultAction(&Actions::me),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "me",
- UseArgs_true,
- Protected_true},
- {"keyToggle",
- defaultAction(&Actions::toggle),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "toggle",
- UseArgs_false,
- Protected_false},
- {"keyPresent",
- defaultAction(&Actions::present),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "present",
- UseArgs_false,
- Protected_false},
- {"keyPrintAll",
- defaultAction(&Actions::printAll),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "all",
- UseArgs_false,
- Protected_true},
- {"keyMove",
- defaultAction(&Actions::move),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "move",
- UseArgs_true,
- Protected_false},
- {"keySetTarget",
- defaultAction(&Actions::setTarget),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "target",
- UseArgs_true,
- Protected_false},
- {"keyAttackHuman",
- defaultAction(&Actions::attackHuman),
- InputCondition::KEY_DOWN |
- InputCondition::GAME |
- InputCondition::NOFOLLOW |
- InputCondition::VALIDSPEED,
- "atkhuman",
- UseArgs_false,
- Protected_false},
- {"keyOutfit",
- defaultAction(&Actions::commandOutfit),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "outfit",
- UseArgs_true,
- Protected_true},
- {"keyEmote",
- defaultAction(&Actions::commandEmote),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "emote",
- UseArgs_true,
- Protected_false},
- {"keyEmotePet",
- defaultAction(&Actions::commandEmotePet),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "emotepet",
- UseArgs_true,
- Protected_false},
- {"keyAwayMessage",
- defaultAction(&Actions::awayMessage),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "away",
- UseArgs_true,
- Protected_true},
- {"keyPseudoAway",
- defaultAction(&Actions::pseudoAway),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "pseudoaway",
- UseArgs_true,
- Protected_true},
- {"keyFollow",
- defaultAction(&Actions::follow),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "follow",
- UseArgs_true,
- Protected_false},
- {"keyNavigate",
- defaultAction(&Actions::navigate),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "navigate",
- UseArgs_true,
- Protected_false},
- {"keyImitation",
- defaultAction(&Actions::imitation),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "imitation",
- UseArgs_true,
- Protected_false},
- {"keySendMail",
- defaultAction(&Actions::sendMail),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "sendmail|mailsend|mailto",
- UseArgs_true,
- Protected_true},
- {"keyTradeCommand",
- defaultAction(&Actions::trade),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "trade",
- UseArgs_true,
- Protected_false},
- {"keyPriceLoad",
- defaultAction(&Actions::priceLoad),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "priceload",
- UseArgs_false,
- Protected_true},
- {"keyPriceSave",
- defaultAction(&Actions::priceSave),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "pricesave",
- UseArgs_false,
- Protected_true},
- {"keyCacheInfo",
- defaultAction(&Actions::cacheInfo),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "cacheinfo",
- UseArgs_false,
- Protected_true},
- {"keyDisconnect",
- defaultAction(&Actions::disconnect),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "disconnect",
- UseArgs_false,
- Protected_true},
- {"keyUndress",
- defaultAction(&Actions::undress),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "undress",
- UseArgs_true,
- Protected_false},
- {"keyDirs",
- defaultAction(&Actions::dirs),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "dirs",
- UseArgs_false,
- Protected_false},
- {"keyInfo",
- defaultAction(&Actions::info),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "info",
- UseArgs_false,
- Protected_false},
- {"keyWait",
- defaultAction(&Actions::wait),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "wait",
- UseArgs_true,
- Protected_true},
- {"keyUptime",
- defaultAction(&Actions::uptime),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "uptime",
- UseArgs_false,
- Protected_false},
- {"keyAddPriorityAttack",
- defaultAction(&Actions::addPriorityAttack),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "addpriorityattack",
- UseArgs_true,
- Protected_true},
- {"keyAddAttack",
- defaultAction(&Actions::addAttack),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "addattack",
- UseArgs_true,
- Protected_true},
- {"keyRemoveAttack",
- defaultAction(&Actions::removeAttack),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "removeattack|removeignoreattack",
- UseArgs_true,
- Protected_true},
- {"keyAddIgnoreAttack",
- defaultAction(&Actions::addIgnoreAttack),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "addignoreattack",
- UseArgs_true,
- Protected_true},
- {"keyDump",
- defaultAction(&Actions::dump),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "dump",
- UseArgs_false,
- Protected_true},
- {"keyServerIgnoreAll",
- defaultAction(&Actions::serverIgnoreAll),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "serverignoreall",
- UseArgs_false,
- Protected_true},
- {"keyServerUnIgnoreAll",
- defaultAction(&Actions::serverUnIgnoreAll),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "serverunignoreall",
- UseArgs_false,
- Protected_true},
- {"keySetDrop",
- defaultAction(&Actions::setDrop),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "setdrop",
- UseArgs_true,
- Protected_false},
- {"keyError",
- defaultAction(&Actions::error),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "error",
- UseArgs_false,
- Protected_true},
- {"keyDumpg",
- defaultAction(&Actions::dumpGraphics),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "dumpg",
- UseArgs_false,
- Protected_true},
- {"keyDumpe",
- defaultAction(&Actions::dumpEnvironment),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "dumpe",
- UseArgs_false,
- Protected_true},
- {"keyDumpt",
- defaultAction(&Actions::dumpTests),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "dumpt",
- UseArgs_false,
- Protected_true},
- {"keyDumpOGL",
- defaultAction(&Actions::dumpOGL),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "dumpogl",
- UseArgs_false,
- Protected_true},
- {"keyDumpGL",
- defaultAction(&Actions::dumpGL),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "dumpgl",
- UseArgs_false,
- Protected_true},
- {"keyDumpMods",
- defaultAction(&Actions::dumpMods),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "dumpMods",
- UseArgs_false,
- Protected_false},
- {"keyUrl",
- defaultAction(&Actions::url),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "url",
- UseArgs_true,
- Protected_true},
- {"keyOpenUrl",
- defaultAction(&Actions::openUrl),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "open",
- UseArgs_true,
- Protected_true},
- {"keyExecute",
- defaultAction(&Actions::execute),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "execute",
- UseArgs_true,
- Protected_true},
- {"keyTestSdlFont",
- emptyKey,
- emptyKey,
- Input::GRP_DEFAULT,
-#if defined USE_OPENGL && defined DEBUG_SDLFONT
- &Actions::testSdlFont,
-#else // defined USE_OPENGL && defined DEBUG_SDLFONT
- nullptr,
-#endif // defined USE_OPENGL && defined DEBUG_SDLFONT
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::INGAME,
-#if defined USE_OPENGL && defined DEBUG_SDLFONT
- "testsdlfont",
-#else // defined USE_OPENGL && defined DEBUG_SDLFONT
- "",
-#endif // defined USE_OPENGL && defined DEBUG_SDLFONT
- UseArgs_false,
- Protected_true},
- {"keyEnableHightlight",
- defaultAction(&Actions::enableHighlight),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "enablehighlight",
- UseArgs_false,
- Protected_true},
- {"keyDisableHightlight",
- defaultAction(&Actions::disableHighlight),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "disablehighlight",
- UseArgs_false,
- Protected_true},
- {"keyDontRemoveName",
- defaultAction(&Actions::dontRemoveName),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "dontremovename",
- UseArgs_false,
- Protected_true},
- {"keyRemoveName",
- defaultAction(&Actions::removeName),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "removename",
- UseArgs_false,
- Protected_true},
- {"keyDisableAway",
- defaultAction(&Actions::disableAway),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "disableaway",
- UseArgs_false,
- Protected_true},
- {"keyEnableAway",
- defaultAction(&Actions::enableAway),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "enableaway",
- UseArgs_false,
- Protected_true},
- {"keyTestParticle",
- defaultAction(&Actions::testParticle),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "testparticle",
- UseArgs_true,
- Protected_false},
- {"keyCreateItems",
- defaultAction(&Actions::createItems),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "createitems",
- UseArgs_false,
- Protected_false},
- {"keyTalkRaw",
- defaultAction(&Actions::talkRaw),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "talkraw",
- UseArgs_true,
- Protected_true},
- {"keyTalkPet",
- defaultAction(&Actions::talkPet),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "talkpet",
- UseArgs_true,
- Protected_true},
- {"keyUploadConfig",
- defaultAction(&Actions::uploadConfig),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "uploadconfig",
- UseArgs_false,
- Protected_true},
- {"keyUploadServerConfig",
- defaultAction(&Actions::uploadServerConfig),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "uploadserverconfig",
- UseArgs_false,
- Protected_true},
- {"keyUploadLog",
- defaultAction(&Actions::uploadLog),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "uploadlog",
- UseArgs_false,
- Protected_true},
- {"keyGm",
- defaultAction(&Actions::gm),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "gm",
- UseArgs_true,
- Protected_true},
- {"keyHack",
- defaultAction(&Actions::hack),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "hack",
- UseArgs_true,
- Protected_true},
- {"keyDebugSpawn",
- defaultAction(&Actions::debugSpawn),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "debugspawn",
- UseArgs_true,
- Protected_true},
- {"keyPetSmilie",
- defaultAction(nullptr),
- InputCondition::KEY_DOWN |
- InputCondition::DEFAULT |
- InputCondition::INGAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyPetEmoteShortcut1",
- addKey(SDLK_1),
- emptyKey,
- Input::GRP_PET_EMOTION,
- &Actions::petEmote,
- InputAction::PET_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyPetEmoteShortcut2",
- addKey(SDLK_2),
- emptyKey,
- Input::GRP_PET_EMOTION,
- &Actions::petEmote,
- InputAction::PET_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyPetEmoteShortcut3",
- addKey(SDLK_3),
- emptyKey,
- Input::GRP_PET_EMOTION,
- &Actions::petEmote,
- InputAction::PET_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyPetEmoteShortcut4",
- addKey(SDLK_4),
- emptyKey,
- Input::GRP_PET_EMOTION,
- &Actions::petEmote,
- InputAction::PET_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyPetEmoteShortcut5",
- addKey(SDLK_5),
- emptyKey,
- Input::GRP_PET_EMOTION,
- &Actions::petEmote,
- InputAction::PET_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyPetEmoteShortcut6",
- addKey(SDLK_6),
- emptyKey,
- Input::GRP_PET_EMOTION,
- &Actions::petEmote,
- InputAction::PET_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyPetEmoteShortcut7",
- addKey(SDLK_7),
- emptyKey,
- Input::GRP_PET_EMOTION,
- &Actions::petEmote,
- InputAction::PET_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyPetEmoteShortcut8",
- addKey(SDLK_8),
- emptyKey,
- Input::GRP_PET_EMOTION,
- &Actions::petEmote,
- InputAction::PET_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyPetEmoteShortcut9",
- addKey(SDLK_9),
- emptyKey,
- Input::GRP_PET_EMOTION,
- &Actions::petEmote,
- InputAction::PET_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyPetEmoteShortcut10",
- addKey(SDLK_0),
- emptyKey,
- Input::GRP_PET_EMOTION,
- &Actions::petEmote,
- InputAction::PET_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyPetEmoteShortcut11",
- addKey(SDLK_MINUS),
- emptyKey,
- Input::GRP_PET_EMOTION,
- &Actions::petEmote,
- InputAction::PET_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyPetEmoteShortcut12",
- addKey(SDLK_EQUALS),
- emptyKey,
- Input::GRP_PET_EMOTION,
- &Actions::petEmote,
- InputAction::PET_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyPetEmoteShortcut13",
- addKey(SDLK_BACKSPACE),
- emptyKey,
- Input::GRP_PET_EMOTION,
- &Actions::petEmote,
- InputAction::PET_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyPetEmoteShortcut14",
- addKey(SDLK_INSERT),
- emptyKey,
- Input::GRP_PET_EMOTION,
- &Actions::petEmote,
- InputAction::PET_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyPetEmoteShortcut15",
- addKey(SDLK_HOME),
- emptyKey,
- Input::GRP_PET_EMOTION,
- &Actions::petEmote,
- InputAction::PET_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyPetEmoteShortcut16",
- addKey(SDLK_q),
- emptyKey,
- Input::GRP_PET_EMOTION,
- &Actions::petEmote,
- InputAction::PET_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyPetEmoteShortcut17",
- addKey(SDLK_w),
- emptyKey,
- Input::GRP_PET_EMOTION,
- &Actions::petEmote,
- InputAction::PET_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyPetEmoteShortcut18",
- addKey(SDLK_e),
- emptyKey,
- Input::GRP_PET_EMOTION,
- &Actions::petEmote,
- InputAction::PET_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyPetEmoteShortcut19",
- addKey(SDLK_r),
- emptyKey,
- Input::GRP_PET_EMOTION,
- &Actions::petEmote,
- InputAction::PET_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyPetEmoteShortcut20",
- addKey(SDLK_t),
- emptyKey,
- Input::GRP_PET_EMOTION,
- &Actions::petEmote,
- InputAction::PET_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyPetEmoteShortcut21",
- addKey(SDLK_y),
- emptyKey,
- Input::GRP_PET_EMOTION,
- &Actions::petEmote,
- InputAction::PET_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyPetEmoteShortcut22",
- addKey(SDLK_u),
- emptyKey,
- Input::GRP_PET_EMOTION,
- &Actions::petEmote,
- InputAction::PET_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyPetEmoteShortcut23",
- addKey(SDLK_i),
- emptyKey,
- Input::GRP_PET_EMOTION,
- &Actions::petEmote,
- InputAction::PET_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyPetEmoteShortcut24",
- addKey(SDLK_o),
- emptyKey,
- Input::GRP_PET_EMOTION,
- &Actions::petEmote,
- InputAction::PET_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyPetEmoteShortcut25",
- addKey(SDLK_p),
- emptyKey,
- Input::GRP_PET_EMOTION,
- &Actions::petEmote,
- InputAction::PET_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyPetEmoteShortcut26",
- addKey(SDLK_LEFTBRACKET),
- emptyKey,
- Input::GRP_PET_EMOTION,
- &Actions::petEmote,
- InputAction::PET_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyPetEmoteShortcut27",
- addKey(SDLK_RIGHTBRACKET),
- emptyKey,
- Input::GRP_PET_EMOTION,
- &Actions::petEmote,
- InputAction::PET_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyPetEmoteShortcut28",
- addKey(SDLK_BACKSLASH),
- emptyKey,
- Input::GRP_PET_EMOTION,
- &Actions::petEmote,
- InputAction::PET_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyPetEmoteShortcut29",
- addKey(SDLK_a),
- emptyKey,
- Input::GRP_PET_EMOTION,
- &Actions::petEmote,
- InputAction::PET_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyPetEmoteShortcut30",
- addKey(SDLK_s),
- emptyKey,
- Input::GRP_PET_EMOTION,
- &Actions::petEmote,
- InputAction::PET_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyPetEmoteShortcut31",
- addKey(SDLK_d),
- emptyKey,
- Input::GRP_PET_EMOTION,
- &Actions::petEmote,
- InputAction::PET_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyPetEmoteShortcut32",
- addKey(SDLK_f),
- emptyKey,
- Input::GRP_PET_EMOTION,
- &Actions::petEmote,
- InputAction::PET_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyPetEmoteShortcut33",
- addKey(SDLK_g),
- emptyKey,
- Input::GRP_PET_EMOTION,
- &Actions::petEmote,
- InputAction::PET_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyPetEmoteShortcut34",
- addKey(SDLK_h),
- emptyKey,
- Input::GRP_PET_EMOTION,
- &Actions::petEmote,
- InputAction::PET_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyPetEmoteShortcut35",
- addKey(SDLK_j),
- emptyKey,
- Input::GRP_PET_EMOTION,
- &Actions::petEmote,
- InputAction::PET_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyPetEmoteShortcut36",
- addKey(SDLK_k),
- emptyKey,
- Input::GRP_PET_EMOTION,
- &Actions::petEmote,
- InputAction::PET_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyPetEmoteShortcut37",
- addKey(SDLK_l),
- emptyKey,
- Input::GRP_PET_EMOTION,
- &Actions::petEmote,
- InputAction::PET_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyPetEmoteShortcut38",
- addKey(SDLK_SEMICOLON),
- emptyKey,
- Input::GRP_PET_EMOTION,
- &Actions::petEmote,
- InputAction::PET_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyPetEmoteShortcut39",
- addKey(SDLK_QUOTE),
- emptyKey,
- Input::GRP_PET_EMOTION,
- &Actions::petEmote,
- InputAction::PET_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyPetEmoteShortcut40",
- addKey(SDLK_z),
- emptyKey,
- Input::GRP_PET_EMOTION,
- &Actions::petEmote,
- InputAction::PET_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyPetEmoteShortcut41",
- addKey(SDLK_x),
- emptyKey,
- Input::GRP_PET_EMOTION,
- &Actions::petEmote,
- InputAction::PET_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyPetEmoteShortcut42",
- addKey(SDLK_c),
- emptyKey,
- Input::GRP_PET_EMOTION,
- &Actions::petEmote,
- InputAction::PET_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyPetEmoteShortcut43",
- addKey(SDLK_v),
- emptyKey,
- Input::GRP_PET_EMOTION,
- &Actions::petEmote,
- InputAction::PET_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyPetEmoteShortcut44",
- addKey(SDLK_b),
- emptyKey,
- Input::GRP_PET_EMOTION,
- &Actions::petEmote,
- InputAction::PET_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyPetEmoteShortcut45",
- addKey(SDLK_n),
- emptyKey,
- Input::GRP_PET_EMOTION,
- &Actions::petEmote,
- InputAction::PET_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyPetEmoteShortcut46",
- addKey(SDLK_m),
- emptyKey,
- Input::GRP_PET_EMOTION,
- &Actions::petEmote,
- InputAction::PET_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyPetEmoteShortcut47",
- addKey(SDLK_COMMA),
- emptyKey,
- Input::GRP_PET_EMOTION,
- &Actions::petEmote,
- InputAction::PET_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyPetEmoteShortcut48",
- addKey(SDLK_PERIOD),
- emptyKey,
- Input::GRP_PET_EMOTION,
- &Actions::petEmote,
- InputAction::PET_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyCatchPet",
- defaultAction(&Actions::catchPet),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "catchpet|catch|taming",
- UseArgs_true,
- Protected_true},
- {"keyChatServerIgnoreWhisper",
- emptyKey,
- emptyKey,
- Input::GRP_DEFAULT | Input::GRP_GUI,
- &Actions::serverIgnoreWhisper,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "serverignore",
- UseArgs_false,
- Protected_true},
- {"keyChatServerUnIgnoreWhisper",
- emptyKey,
- emptyKey,
- Input::GRP_DEFAULT | Input::GRP_GUI,
- &Actions::serverUnIgnoreWhisper,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "serverunignore",
- UseArgs_false,
- Protected_true},
- {"keyMercenaryFire",
- defaultAction(&Actions::mercenaryFire),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "mercenaryfire|firemercenary",
- UseArgs_false,
- Protected_true},
- {"keyTargetMercenary",
- defaultAction(&Actions::targetMercenary),
- InputCondition::KEY_DOWN |
- InputCondition::INGAME |
- InputCondition::NOTARGET,
- "targetmercenary",
- UseArgs_false,
- Protected_false},
- {"keyTargetPet",
- defaultAction(&Actions::targetPet),
- InputCondition::KEY_DOWN |
- InputCondition::INGAME |
- InputCondition::NOTARGET,
- "targetpet",
- UseArgs_false,
- Protected_false},
- {"keyPetSetName",
- defaultAction(&Actions::setPetName),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "setpetname|petsetname",
- UseArgs_false,
- Protected_true},
- {"keyHomunculusSetName",
- defaultAction(&Actions::setHomunculusName),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "sethomunname|homunsetname|sethomunculusname|homunculussetname",
- UseArgs_false,
- Protected_true},
- {"keyHomunculusFire",
- defaultAction(&Actions::fireHomunculus),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "firehomunculus|homunculusfire|firehomun|homunfire",
- UseArgs_false,
- Protected_true},
- {"keyWindowBank",
- emptyKey,
- emptyKey,
- Input::GRP_DEFAULT | Input::GRP_GUI,
- &Actions::bankWindowShow,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN | InputCondition::SHORTCUT0,
- "bank|openbank",
- UseArgs_false,
- Protected_false},
- {"keyInventoryPrevTab",
- emptyKey,
- emptyKey,
- Input::GRP_DEFAULT | Input::GRP_GUI,
- &Actions::prevInvTab,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::NOINPUT |
- InputCondition::INGAME,
- "previnvtab",
- UseArgs_false,
- Protected_false},
- {"keyInventoryNextTab",
- emptyKey,
- emptyKey,
- Input::GRP_DEFAULT | Input::GRP_GUI,
- &Actions::nextInvTab,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::NOINPUT |
- InputCondition::INGAME,
- "nextinvtab",
- UseArgs_false,
- Protected_false},
- {"keyContextMenu",
- defaultAction(&Actions::contextMenu),
- InputCondition::KEY_DOWN |
- InputCondition::NOINPUT |
- InputCondition::NOAWAY |
- InputCondition::NOMODAL |
- InputCondition::INGAME,
- "contextmenu",
- UseArgs_false,
- Protected_false},
- {"keyBuy",
- defaultAction(&Actions::buy),
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "buy",
- UseArgs_false,
- Protected_false},
- {"keySell",
- defaultAction(&Actions::sell),
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "sell",
- UseArgs_false,
- Protected_false},
- {"keyWhisper2",
- defaultAction(&Actions::msg2),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "w2|whisper2|msg2",
- UseArgs_true,
- Protected_true},
- {"keyGuild",
- defaultAction(&Actions::guild),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "guild",
- UseArgs_true,
- Protected_true},
- {"keyNuke",
- defaultAction(&Actions::chatNuke),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "nuke",
- UseArgs_true,
- Protected_true},
- {"keyUse",
- defaultAction(&Actions::useItem),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "use|useitem",
- UseArgs_true,
- Protected_true},
- {"keyChatAdd",
- defaultAction(&Actions::chatAdd),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "addchat|chatadd",
- UseArgs_true,
- Protected_true},
- {"keyWhisperText",
- defaultAction(&Actions::msgText),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "wt|whispertext|msgtext",
- UseArgs_true,
- Protected_true},
- {"keyNavigateTo",
- defaultAction(&Actions::navigateTo),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "navigateto",
- UseArgs_true,
- Protected_false},
- {"keyCameraMove",
- defaultAction(&Actions::moveCamera),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "movecamera|cameramove",
- UseArgs_true,
- Protected_false},
- {"keyDropItem",
- defaultAction(&Actions::dropItemId),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "dropitem",
- UseArgs_true,
- Protected_true},
- {"keyDropItemAll",
- defaultAction(&Actions::dropItemIdAll),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "dropitemall",
- UseArgs_true,
- Protected_true},
- {"keyDropInv",
- defaultAction(&Actions::dropItemInv),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "dropinv",
- UseArgs_true,
- Protected_true},
- {"keyDropInvAll",
- defaultAction(&Actions::dropItemInvAll),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "dropinvall",
- UseArgs_true,
- Protected_true},
- {"keyUseInv",
- defaultAction(&Actions::useItemInv),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "useinv",
- UseArgs_true,
- Protected_true},
- {"keyInvToStorage",
- defaultAction(&Actions::invToStorage),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "invtostorage|invstorage",
- UseArgs_true,
- Protected_true},
- {"keyTradeAdd",
- defaultAction(&Actions::tradeAdd),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "tradeadd|addtrade",
- UseArgs_true,
- Protected_true},
- {"keyStorageToInv",
- defaultAction(&Actions::storageToInv),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "storagetoinv|storageinv",
- UseArgs_true,
- Protected_true},
- {"keyProtectItem",
- defaultAction(&Actions::protectItem),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "protectitem|itemprotect",
- UseArgs_true,
- Protected_true},
- {"keyUnProtectItem",
- defaultAction(&Actions::unprotectItem),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "unprotectitem|itemunprotect",
- UseArgs_true,
- Protected_true},
- {"keyKickParty",
- defaultAction(&Actions::kickParty),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "kickparty|partykick",
- UseArgs_true,
- Protected_true},
- {"keyAddText",
- defaultAction(&Actions::addText),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "addtext|textadd",
- UseArgs_true,
- Protected_true},
- {"keyKick",
- defaultAction(&Actions::kick),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "kick",
- UseArgs_true,
- Protected_true},
- {"keyLeaveParty",
- defaultAction(&Actions::leaveParty),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "leaveparty|partyleave",
- UseArgs_true,
- Protected_true},
- {"keyWarp",
- defaultAction(&Actions::warp),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "warp",
- UseArgs_true,
- Protected_true},
- {"keyClearChat",
- defaultAction(&Actions::clearChat),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "clearchat|chatclear",
- UseArgs_false,
- Protected_false},
- {"keyPetMoveUp",
- defaultAction(&Actions::petMoveUp),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "petmoveup|moveuppet",
- UseArgs_false,
- Protected_false},
- {"keyPetMoveDown",
- defaultAction(&Actions::petMoveDown),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "petmovedown|movedownpet",
- UseArgs_false,
- Protected_false},
- {"keyPetMoveLeft",
- defaultAction(&Actions::petMoveLeft),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "petmoveleft|moveleftpet",
- UseArgs_false,
- Protected_false},
- {"keyPetMoveRight",
- defaultAction(&Actions::petMoveRight),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "petmoveright|moverightpet",
- UseArgs_false,
- Protected_false},
- {"keyPetDirectUp",
- defaultAction(&Actions::petDirectUp),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "petdirectup|directuppet",
- UseArgs_false,
- Protected_false},
- {"keyPetDirectDown",
- defaultAction(&Actions::petDirectDown),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "petdirectdown|directdownpet",
- UseArgs_false,
- Protected_false},
- {"keyPetDirectLeft",
- defaultAction(&Actions::petDirectLeft),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "petdirectleft|directleftpet",
- UseArgs_false,
- Protected_false},
- {"keyPetDirectRight",
- defaultAction(&Actions::petDirectRight),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "petdirectright|directrightpet",
- UseArgs_false,
- Protected_false},
- {"keyPetAiStart",
- defaultAction(nullptr),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyPetAiStop",
- defaultAction(nullptr),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyGeneralTab",
- defaultAction(&Actions::chatGeneralTab),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "generaltab|generalchattab|general",
- UseArgs_false,
- Protected_false},
- {"keyDebugTab",
- defaultAction(&Actions::chatDebugTab),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "debugtab|debugchattab",
- UseArgs_false,
- Protected_false},
- {"keyBattleTab",
- defaultAction(&Actions::chatBattleTab),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "battletab|battlechattab",
- UseArgs_false,
- Protected_false},
- {"keyTradeTab",
- defaultAction(&Actions::chatTradeTab),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "tradetab|tradechattab",
- UseArgs_false,
- Protected_false},
- {"keyLangTab",
- defaultAction(&Actions::chatLangTab),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "langtab|langchattab",
- UseArgs_false,
- Protected_false},
- {"keyGmTab",
- defaultAction(&Actions::chatGmTab),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "gmtab|gmchattab",
- UseArgs_false,
- Protected_false},
- {"keyPartyTab",
- defaultAction(&Actions::chatPartyTab),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "partytab|partychattab",
- UseArgs_false,
- Protected_false},
- {"keyGuildTab",
- defaultAction(&Actions::chatGuildTab),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "guildtab|guildchattab",
- UseArgs_false,
- Protected_false},
- {"keyDropClear",
- defaultAction(&Actions::clearDrop),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "cleardrops|cleardrop|cleardropwindow|dropclear|dropsclear",
- UseArgs_false,
- Protected_true},
- {"keyWindowCart",
- defaultAction(&Actions::cartWindowShow),
- InputCondition::KEY_DOWN | InputCondition::SHORTCUT0,
- "cart|opencart",
- UseArgs_false,
- Protected_false},
- {"keyMagicHealMostDamaged",
- defaultAction(&Actions::healmd),
- InputCondition::KEY_DOWN |
- InputCondition::GAME |
- InputCondition::VALIDSPEED,
- "healmd|saveass",
- UseArgs_false,
- Protected_false},
- {"keyPetMove",
- defaultAction(&Actions::petMove),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "movepet|petmove",
- UseArgs_true,
- Protected_false},
- {"keyHomunTalk",
- defaultAction(&Actions::homunTalk),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "homuntalk|merctalk",
- UseArgs_true,
- Protected_true},
- {"keyHomunEmote",
- defaultAction(&Actions::commandHomunEmote),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "homunemote|mercemote",
- UseArgs_true,
- Protected_false},
- {"keyHomunSmilie",
- defaultAction(nullptr),
- InputCondition::KEY_DOWN |
- InputCondition::DEFAULT |
- InputCondition::INGAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyHomunEmoteShortcut1",
- addKey(SDLK_1),
- emptyKey,
- Input::GRP_HOMUN_EMOTION,
- &Actions::homunEmote,
- InputAction::HOMUN_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyHomunEmoteShortcut2",
- addKey(SDLK_2),
- emptyKey,
- Input::GRP_HOMUN_EMOTION,
- &Actions::homunEmote,
- InputAction::HOMUN_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyHomunEmoteShortcut3",
- addKey(SDLK_3),
- emptyKey,
- Input::GRP_HOMUN_EMOTION,
- &Actions::homunEmote,
- InputAction::HOMUN_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyHomunEmoteShortcut4",
- addKey(SDLK_4),
- emptyKey,
- Input::GRP_HOMUN_EMOTION,
- &Actions::homunEmote,
- InputAction::HOMUN_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyHomunEmoteShortcut5",
- addKey(SDLK_5),
- emptyKey,
- Input::GRP_HOMUN_EMOTION,
- &Actions::homunEmote,
- InputAction::HOMUN_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyHomunEmoteShortcut6",
- addKey(SDLK_6),
- emptyKey,
- Input::GRP_HOMUN_EMOTION,
- &Actions::homunEmote,
- InputAction::HOMUN_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyHomunEmoteShortcut7",
- addKey(SDLK_7),
- emptyKey,
- Input::GRP_HOMUN_EMOTION,
- &Actions::homunEmote,
- InputAction::HOMUN_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyHomunEmoteShortcut8",
- addKey(SDLK_8),
- emptyKey,
- Input::GRP_HOMUN_EMOTION,
- &Actions::homunEmote,
- InputAction::HOMUN_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyHomunEmoteShortcut9",
- addKey(SDLK_9),
- emptyKey,
- Input::GRP_HOMUN_EMOTION,
- &Actions::homunEmote,
- InputAction::HOMUN_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyHomunEmoteShortcut10",
- addKey(SDLK_0),
- emptyKey,
- Input::GRP_HOMUN_EMOTION,
- &Actions::homunEmote,
- InputAction::HOMUN_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyHomunEmoteShortcut11",
- addKey(SDLK_MINUS),
- emptyKey,
- Input::GRP_HOMUN_EMOTION,
- &Actions::homunEmote,
- InputAction::HOMUN_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyHomunEmoteShortcut12",
- addKey(SDLK_EQUALS),
- emptyKey,
- Input::GRP_HOMUN_EMOTION,
- &Actions::homunEmote,
- InputAction::HOMUN_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyHomunEmoteShortcut13",
- addKey(SDLK_BACKSPACE),
- emptyKey,
- Input::GRP_HOMUN_EMOTION,
- &Actions::homunEmote,
- InputAction::HOMUN_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyHomunEmoteShortcut14",
- addKey(SDLK_INSERT),
- emptyKey,
- Input::GRP_HOMUN_EMOTION,
- &Actions::homunEmote,
- InputAction::HOMUN_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyHomunEmoteShortcut15",
- addKey(SDLK_HOME),
- emptyKey,
- Input::GRP_HOMUN_EMOTION,
- &Actions::homunEmote,
- InputAction::HOMUN_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyHomunEmoteShortcut16",
- addKey(SDLK_q),
- emptyKey,
- Input::GRP_HOMUN_EMOTION,
- &Actions::homunEmote,
- InputAction::HOMUN_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyHomunEmoteShortcut17",
- addKey(SDLK_w),
- emptyKey,
- Input::GRP_HOMUN_EMOTION,
- &Actions::homunEmote,
- InputAction::HOMUN_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyHomunEmoteShortcut18",
- addKey(SDLK_e),
- emptyKey,
- Input::GRP_HOMUN_EMOTION,
- &Actions::homunEmote,
- InputAction::HOMUN_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyHomunEmoteShortcut19",
- addKey(SDLK_r),
- emptyKey,
- Input::GRP_HOMUN_EMOTION,
- &Actions::homunEmote,
- InputAction::HOMUN_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyHomunEmoteShortcut20",
- addKey(SDLK_t),
- emptyKey,
- Input::GRP_HOMUN_EMOTION,
- &Actions::homunEmote,
- InputAction::HOMUN_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyHomunEmoteShortcut21",
- addKey(SDLK_y),
- emptyKey,
- Input::GRP_HOMUN_EMOTION,
- &Actions::homunEmote,
- InputAction::HOMUN_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyHomunEmoteShortcut22",
- addKey(SDLK_u),
- emptyKey,
- Input::GRP_HOMUN_EMOTION,
- &Actions::homunEmote,
- InputAction::HOMUN_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyHomunEmoteShortcut23",
- addKey(SDLK_i),
- emptyKey,
- Input::GRP_HOMUN_EMOTION,
- &Actions::homunEmote,
- InputAction::HOMUN_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyHomunEmoteShortcut24",
- addKey(SDLK_o),
- emptyKey,
- Input::GRP_HOMUN_EMOTION,
- &Actions::homunEmote,
- InputAction::HOMUN_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyHomunEmoteShortcut25",
- addKey(SDLK_p),
- emptyKey,
- Input::GRP_HOMUN_EMOTION,
- &Actions::homunEmote,
- InputAction::HOMUN_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyHomunEmoteShortcut26",
- addKey(SDLK_LEFTBRACKET),
- emptyKey,
- Input::GRP_HOMUN_EMOTION,
- &Actions::homunEmote,
- InputAction::HOMUN_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyHomunEmoteShortcut27",
- addKey(SDLK_RIGHTBRACKET),
- emptyKey,
- Input::GRP_HOMUN_EMOTION,
- &Actions::homunEmote,
- InputAction::HOMUN_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyHomunEmoteShortcut28",
- addKey(SDLK_BACKSLASH),
- emptyKey,
- Input::GRP_HOMUN_EMOTION,
- &Actions::homunEmote,
- InputAction::HOMUN_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyHomunEmoteShortcut29",
- addKey(SDLK_a),
- emptyKey,
- Input::GRP_HOMUN_EMOTION,
- &Actions::homunEmote,
- InputAction::HOMUN_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyHomunEmoteShortcut30",
- addKey(SDLK_s),
- emptyKey,
- Input::GRP_HOMUN_EMOTION,
- &Actions::homunEmote,
- InputAction::HOMUN_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyHomunEmoteShortcut31",
- addKey(SDLK_d),
- emptyKey,
- Input::GRP_HOMUN_EMOTION,
- &Actions::homunEmote,
- InputAction::HOMUN_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyHomunEmoteShortcut32",
- addKey(SDLK_f),
- emptyKey,
- Input::GRP_HOMUN_EMOTION,
- &Actions::homunEmote,
- InputAction::HOMUN_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyHomunEmoteShortcut33",
- addKey(SDLK_g),
- emptyKey,
- Input::GRP_HOMUN_EMOTION,
- &Actions::homunEmote,
- InputAction::HOMUN_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyHomunEmoteShortcut34",
- addKey(SDLK_h),
- emptyKey,
- Input::GRP_HOMUN_EMOTION,
- &Actions::homunEmote,
- InputAction::HOMUN_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyHomunEmoteShortcut35",
- addKey(SDLK_j),
- emptyKey,
- Input::GRP_HOMUN_EMOTION,
- &Actions::homunEmote,
- InputAction::HOMUN_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyHomunEmoteShortcut36",
- addKey(SDLK_k),
- emptyKey,
- Input::GRP_HOMUN_EMOTION,
- &Actions::homunEmote,
- InputAction::HOMUN_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyHomunEmoteShortcut37",
- addKey(SDLK_l),
- emptyKey,
- Input::GRP_HOMUN_EMOTION,
- &Actions::homunEmote,
- InputAction::HOMUN_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyHomunEmoteShortcut38",
- addKey(SDLK_SEMICOLON),
- emptyKey,
- Input::GRP_HOMUN_EMOTION,
- &Actions::homunEmote,
- InputAction::HOMUN_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyHomunEmoteShortcut39",
- addKey(SDLK_QUOTE),
- emptyKey,
- Input::GRP_HOMUN_EMOTION,
- &Actions::homunEmote,
- InputAction::HOMUN_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyHomunEmoteShortcut40",
- addKey(SDLK_z),
- emptyKey,
- Input::GRP_HOMUN_EMOTION,
- &Actions::homunEmote,
- InputAction::HOMUN_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyHomunEmoteShortcut41",
- addKey(SDLK_x),
- emptyKey,
- Input::GRP_HOMUN_EMOTION,
- &Actions::homunEmote,
- InputAction::HOMUN_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyHomunEmoteShortcut42",
- addKey(SDLK_c),
- emptyKey,
- Input::GRP_HOMUN_EMOTION,
- &Actions::homunEmote,
- InputAction::HOMUN_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyHomunEmoteShortcut43",
- addKey(SDLK_v),
- emptyKey,
- Input::GRP_HOMUN_EMOTION,
- &Actions::homunEmote,
- InputAction::HOMUN_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyHomunEmoteShortcut44",
- addKey(SDLK_b),
- emptyKey,
- Input::GRP_HOMUN_EMOTION,
- &Actions::homunEmote,
- InputAction::HOMUN_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyHomunEmoteShortcut45",
- addKey(SDLK_n),
- emptyKey,
- Input::GRP_HOMUN_EMOTION,
- &Actions::homunEmote,
- InputAction::HOMUN_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyHomunEmoteShortcut46",
- addKey(SDLK_m),
- emptyKey,
- Input::GRP_HOMUN_EMOTION,
- &Actions::homunEmote,
- InputAction::HOMUN_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyHomunEmoteShortcut47",
- addKey(SDLK_COMMA),
- emptyKey,
- Input::GRP_HOMUN_EMOTION,
- &Actions::homunEmote,
- InputAction::HOMUN_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyHomunEmoteShortcut48",
- addKey(SDLK_PERIOD),
- emptyKey,
- Input::GRP_HOMUN_EMOTION,
- &Actions::homunEmote,
- InputAction::HOMUN_EMOTE, 100,
- InputCondition::KEY_DOWN | InputCondition::GAME,
- "",
- UseArgs_false,
- Protected_false},
- {"keyKickGuild",
- defaultAction(&Actions::kickGuild),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "kickguild|guildkick",
- UseArgs_true,
- Protected_true},
- {"keyHat",
- defaultAction(&Actions::hat),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "hat|hats|showhat",
- UseArgs_false,
- Protected_false},
- {"keyCreatePublicRoom",
- defaultAction(&Actions::createPublicChatRoom),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "createroom|createpublicroom",
- UseArgs_true,
- Protected_true},
- {"keyJoinRoom",
- defaultAction(&Actions::joinChatRoom),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "joinroom",
- UseArgs_true,
- Protected_true},
- {"keyLeaveRoom",
- defaultAction(&Actions::leaveChatRoom),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "leaveroom",
- UseArgs_false,
- Protected_true},
- {"keyWindowStatusBar",
- emptyKey,
- emptyKey,
- Input::GRP_DEFAULT | Input::GRP_GUI,
- &Actions::quickWindowShow,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::GAME |
- InputCondition::NOTARGET,
- "yellowbar|quickoptions",
- UseArgs_false,
- Protected_false},
- {"keyWindowMail",
- emptyKey,
- emptyKey,
- Input::GRP_DEFAULT | Input::GRP_GUI,
- &Actions::mailWindowShow,
- InputAction::NO_VALUE, 50,
- InputCondition::KEY_DOWN |
- InputCondition::GAME |
- InputCondition::NOTARGET,
- "mailwindow|mail",
- UseArgs_false,
- Protected_false},
- {"keyConfSet",
- defaultAction(&Actions::confSet),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "confset|setconf",
- UseArgs_true,
- Protected_true},
- {"keyServerConfSet",
- defaultAction(&Actions::serverConfSet),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "servconfset|setservconf",
- UseArgs_true,
- Protected_true},
- {"keyConfGet",
- defaultAction(&Actions::confGet),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "confget|getconf",
- UseArgs_true,
- Protected_true},
- {"keyServerConfGet",
- defaultAction(&Actions::serverConfGet),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "servconfget|getservconf",
- UseArgs_true,
- Protected_true},
- {"keyChangeTargetingType",
- defaultAction(&Actions::changeTargetingType),
- InputCondition::KEY_DOWN |
- InputCondition::GAME |
- InputCondition::VALIDSPEED | InputCondition::EMODS,
- "",
- UseArgs_false,
- Protected_true},
- {"keyTestInfo",
- defaultAction(&Actions::testInfo),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "testinfo",
- UseArgs_false,
- Protected_true},
- {"keySlide",
- defaultAction(&Actions::slide),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "slide",
- UseArgs_true,
- Protected_true},
- {"keySelectSkillLevel",
- defaultAction(&Actions::selectSkillLevel),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "selectskilllevel",
- UseArgs_true,
- Protected_true},
- {"keySkill",
- defaultAction(&Actions::skill),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "skill|useskill",
- UseArgs_true,
- Protected_true},
- {"keyCraftShortcut1",
- emptyKey,
- emptyKey,
- Input::GRP_DEFAULT,
- &Actions::craftKey,
- InputAction::NO_VALUE, 100,
- InputCondition::KEY_DOWN |
- InputCondition::NOMODAL |
- InputCondition::NOAWAY |
- InputCondition::NONPCINPUT,
- "",
- UseArgs_false,
- Protected_true},
- {"keyCraftShortcut2",
- emptyKey,
- emptyKey,
- Input::GRP_DEFAULT,
- &Actions::craftKey,
- InputAction::NO_VALUE, 100,
- InputCondition::KEY_DOWN |
- InputCondition::NOMODAL |
- InputCondition::NOAWAY |
- InputCondition::NONPCINPUT,
- "",
- UseArgs_false,
- Protected_true},
- {"keyCraftShortcut3",
- emptyKey,
- emptyKey,
- Input::GRP_DEFAULT,
- &Actions::craftKey,
- InputAction::NO_VALUE, 100,
- InputCondition::KEY_DOWN |
- InputCondition::NOMODAL |
- InputCondition::NOAWAY |
- InputCondition::NONPCINPUT,
- "",
- UseArgs_false,
- Protected_true},
- {"keyCraftShortcut4",
- emptyKey,
- emptyKey,
- Input::GRP_DEFAULT,
- &Actions::craftKey,
- InputAction::NO_VALUE, 100,
- InputCondition::KEY_DOWN |
- InputCondition::NOMODAL |
- InputCondition::NOAWAY |
- InputCondition::NONPCINPUT,
- "",
- UseArgs_false,
- Protected_true},
- {"keyCraftShortcut5",
- emptyKey,
- emptyKey,
- Input::GRP_DEFAULT,
- &Actions::craftKey,
- InputAction::NO_VALUE, 100,
- InputCondition::KEY_DOWN |
- InputCondition::NOMODAL |
- InputCondition::NOAWAY |
- InputCondition::NONPCINPUT,
- "",
- UseArgs_false,
- Protected_true},
- {"keyCraftShortcut6",
- emptyKey,
- emptyKey,
- Input::GRP_DEFAULT,
- &Actions::craftKey,
- InputAction::NO_VALUE, 100,
- InputCondition::KEY_DOWN |
- InputCondition::NOMODAL |
- InputCondition::NOAWAY |
- InputCondition::NONPCINPUT,
- "",
- UseArgs_false,
- Protected_true},
- {"keyCraftShortcut7",
- emptyKey,
- emptyKey,
- Input::GRP_DEFAULT,
- &Actions::craftKey,
- InputAction::NO_VALUE, 100,
- InputCondition::KEY_DOWN |
- InputCondition::NOMODAL |
- InputCondition::NOAWAY |
- InputCondition::NONPCINPUT,
- "",
- UseArgs_false,
- Protected_true},
- {"keyCraftShortcut8",
- emptyKey,
- emptyKey,
- Input::GRP_DEFAULT,
- &Actions::craftKey,
- InputAction::NO_VALUE, 100,
- InputCondition::KEY_DOWN |
- InputCondition::NOMODAL |
- InputCondition::NOAWAY |
- InputCondition::NONPCINPUT,
- "",
- UseArgs_false,
- Protected_true},
- {"keyCraftShortcut9",
- emptyKey,
- emptyKey,
- Input::GRP_DEFAULT,
- &Actions::craftKey,
- InputAction::NO_VALUE, 100,
- InputCondition::KEY_DOWN |
- InputCondition::NOMODAL |
- InputCondition::NOAWAY |
- InputCondition::NONPCINPUT,
- "",
- UseArgs_false,
- Protected_true},
- {"keyCraft",
- defaultAction(&Actions::craft),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "craft",
- UseArgs_true,
- Protected_true},
- {"keyChatClipboard",
- defaultAction(&Actions::chatClipboard),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "chatclipboard",
- UseArgs_true,
- Protected_true},
- {"keyNpcClipboard",
- defaultAction(&Actions::npcClipboard),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "npcclipboard",
- UseArgs_true,
- Protected_true},
- {"keyAddPickup",
- defaultAction(&Actions::addPickup),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "addpickup|pickupadd",
- UseArgs_true,
- Protected_true},
- {"keyRemovePickup",
- defaultAction(&Actions::removePickup),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "removepickup|pickupremove",
- UseArgs_true,
- Protected_true},
- {"keyIgnorePickup",
- defaultAction(&Actions::ignorePickup),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "ignorepickup|pickupignore",
- UseArgs_true,
- Protected_true},
- {"keyResetModifiers",
- defaultAction(&Actions::resetGameModifiers),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "resetyellowbar|resetmodifiers|resetgamemodifiers",
- UseArgs_false,
- Protected_true},
- {"keyBarToChat",
- defaultAction(&Actions::barToChat),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "bartochat",
- UseArgs_true,
- Protected_true},
- {"keySeenCmd",
- defaultAction(&Actions::seen),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "seen|lastseen",
- UseArgs_true,
- Protected_true},
- {"keyTargetSkillUnit",
- defaultAction(&Actions::targetSkillUnit),
- InputCondition::KEY_DOWN |
- InputCondition::INGAME |
- InputCondition::NOTARGET,
- "targetskillunit|targetskill",
- UseArgs_false,
- Protected_false},
- {"keyMonsterInfo",
- defaultAction(&Actions::monsterInfo),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "monsterinfo|mobinfo|mi",
- UseArgs_true,
- Protected_true},
- {"keyItemInfo",
- defaultAction(&Actions::itemInfo),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "iteminfo|ii",
- UseArgs_true,
- Protected_true},
- {"keyWhoDrops",
- defaultAction(&Actions::whoDrops),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "whodrops|whodrop",
- UseArgs_true,
- Protected_true},
- {"keyMobSearch",
- defaultAction(&Actions::mobSearch),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "mobsearch|monstersearch",
- UseArgs_true,
- Protected_true},
- {"keyMobSpawnSearch",
- defaultAction(&Actions::mobSpawnSearch),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "mobspawnsearch|monsterspawnsearch|whereis",
- UseArgs_true,
- Protected_true},
- {"keyPlayerGmCommands",
- defaultAction(&Actions::playerGmCommands),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "gmcommands|playergmcommands|playercommands",
- UseArgs_true,
- Protected_true},
- {"keyPlayerCharGmCommands",
- defaultAction(&Actions::playerCharGmCommands),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "gmcharcommands|playerchargmcommands|playercharcommands",
- UseArgs_true,
- Protected_true},
- {"keyCommandShowLevel",
- defaultAction(&Actions::commandShowLevel),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "showlevel|exp",
- UseArgs_true,
- Protected_true},
- {"keyCommandShowStats",
- defaultAction(&Actions::commandShowStats),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "showstats|stats",
- UseArgs_true,
- Protected_true},
- {"keyCommandShowStorageList",
- defaultAction(&Actions::commandShowStorage),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "showstorage|storagelist",
- UseArgs_true,
- Protected_true},
- {"keyCommandShowCartList",
- defaultAction(&Actions::commandShowCart),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "showcart|cartlist",
- UseArgs_true,
- Protected_true},
- {"keyCommandShowInventoryList",
- defaultAction(&Actions::commandShowInventory),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "showinventory|inventorylist|itemlist",
- UseArgs_true,
- Protected_true},
- {"keyLocatePlayer",
- defaultAction(&Actions::locatePlayer),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "locate|locateplayer|whereplayer",
- UseArgs_true,
- Protected_true},
- {"keyCommandShowAccountInfo",
- defaultAction(&Actions::commandShowAccountInfo),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "showaccountinfo|showaccinfo|accinfo",
- UseArgs_true,
- Protected_true},
- {"keyCommandSpawn",
- defaultAction(&Actions::commandSpawn),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "spawn|monster",
- UseArgs_true,
- Protected_true},
- {"keyCommandSpawnSlave",
- defaultAction(&Actions::commandSpawnSlave),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "spawnslave|monsterslave|summon",
- UseArgs_true,
- Protected_true},
- {"keyCommandSpawnClone",
- defaultAction(&Actions::commandSpawnClone),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "spawnclone|playerclone|clone",
- UseArgs_true,
- Protected_true},
- {"keyCommandSpawnSlaveClone",
- defaultAction(&Actions::commandSpawnSlaveClone),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "spawnslaveclone|playerslaveclone|slaveclone",
- UseArgs_true,
- Protected_true},
- {"keyCommandSpawnEvilClone",
- defaultAction(&Actions::commandSpawnEvilClone),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "spawnevilclone|playerevilclone|evilclone",
- UseArgs_true,
- Protected_true},
- {"keyCommandSavePosition",
- defaultAction(&Actions::commandSavePosition),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "savepos|saveposition",
- UseArgs_true,
- Protected_true},
- {"keyCommandLoadPosition",
- defaultAction(&Actions::commandLoadPosition),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "loadpos|loadposition",
- UseArgs_true,
- Protected_true},
- {"keyCommandRandomWarp",
- defaultAction(&Actions::commandRandomWarp),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "randomwarp|jump",
- UseArgs_true,
- Protected_true},
- {"keyCommandGotoNpc",
- defaultAction(&Actions::commandGotoNpc),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "gotonpc|warptonpc",
- UseArgs_true,
- Protected_true},
- {"keyCommandKiller",
- defaultAction(&Actions::commandKiller),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "setkiller|killer",
- UseArgs_true,
- Protected_true},
- {"keyCommandKillable",
- defaultAction(&Actions::commandKillable),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "setkillable|killable",
- UseArgs_true,
- Protected_true},
- {"keyCommandHeal",
- defaultAction(&Actions::commandHeal),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "gmheal",
- UseArgs_true,
- Protected_true},
- {"keyCommandAlive",
- defaultAction(&Actions::commandAlive),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "alive|revive",
- UseArgs_true,
- Protected_true},
- {"keyCommandDisguise",
- defaultAction(&Actions::commandDisguise),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "disguise",
- UseArgs_true,
- Protected_true},
- {"keyCommandImmortal",
- defaultAction(&Actions::commandImmortal),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "immortal",
- UseArgs_true,
- Protected_true},
- {"keyCommandHide",
- defaultAction(&Actions::commandHide),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "hide",
- UseArgs_true,
- Protected_true},
- {"keyCommandNuke",
- defaultAction(&Actions::commandNuke),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "gmnuke",
- UseArgs_true,
- Protected_true},
- {"keyCommandKill",
- defaultAction(&Actions::commandKill),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "kill",
- UseArgs_true,
- Protected_true},
- {"keyCommandJail",
- defaultAction(&Actions::commandJail),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "jail",
- UseArgs_true,
- Protected_true},
- {"keyCommandUnjail",
- defaultAction(&Actions::commandUnjail),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "unjail",
- UseArgs_true,
- Protected_true},
- {"keyCommandNpcMove",
- defaultAction(&Actions::commandNpcMove),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "npcmove|movenpc|warpnpc|npcwarp",
- UseArgs_true,
- Protected_true},
- {"keyCommandNpcHide",
- defaultAction(&Actions::commandNpcHide),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "npchide|hidenpc",
- UseArgs_true,
- Protected_true},
- {"keyCommandNpcShow",
- defaultAction(&Actions::commandNpcShow),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "npcshow|shownpc",
- UseArgs_true,
- Protected_true},
- {"keyCommandChangePartyLeader",
- defaultAction(&Actions::commandChangePartyLeader),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "gmpartyleader|changepartyleader",
- UseArgs_true,
- Protected_true},
- {"keyCommandPartyRecall",
- defaultAction(&Actions::commandPartyRecall),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "partyrecall|recallparty",
- UseArgs_true,
- Protected_true},
- {"keyCommandBreakGuild",
- defaultAction(&Actions::commandBreakGuild),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "breakguild|gmbreakguild",
- UseArgs_true,
- Protected_true},
- {"keyCommandGuildRecall",
- defaultAction(&Actions::commandGuildRecall),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "guildrecall|recallguild",
- UseArgs_true,
- Protected_true},
- {"keyMailTo",
- defaultAction(&Actions::mailTo),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "mailto",
- UseArgs_true,
- Protected_true},
- {"keyAdoptChild",
- defaultAction(&Actions::adoptChild),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "adoptchild|childadopt|askforchild",
- UseArgs_true,
- Protected_true},
- {"keyDumpMemmoryUsage",
- defaultAction(&Actions::dumpMemoryUsage),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "dumpmemoryusage|memoryusage",
- UseArgs_false,
- Protected_true},
- {"keySetEmoteType",
- defaultAction(&Actions::setEmoteType),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "setemotetype",
- UseArgs_true,
- Protected_true},
- {"keyCameraRestore",
- defaultAction(&Actions::restoreCamera),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "restorecamera|returncamera|camerarestore",
- UseArgs_false,
- Protected_false},
- {"keyShowSkillLevels",
- defaultAction(&Actions::showSkillLevels),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "showskilllevels",
- UseArgs_true,
- Protected_true},
- {"keyShowskilltype",
- defaultAction(&Actions::showSkillType),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "showskilltypes",
- UseArgs_true,
- Protected_true},
- {"keySelectSkillType",
- defaultAction(&Actions::selectSkillType),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "selectskilltype",
- UseArgs_true,
- Protected_true},
- {"keyShowSkillOffsetX",
- defaultAction(&Actions::showSkillOffsetX),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "showskilloffsetx",
- UseArgs_true,
- Protected_true},
- {"keyShowSkillOffsetY",
- defaultAction(&Actions::showSkillOffsetY),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "showskilloffsety",
- UseArgs_true,
- Protected_true},
- {"keySetSkillOffsetX",
- defaultAction(&Actions::setSkillOffsetX),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "setskilloffsetx",
- UseArgs_true,
- Protected_true},
- {"keySetSkillOffsetY",
- defaultAction(&Actions::setSkillOffsetY),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "setskilloffsety",
- UseArgs_true,
- Protected_true},
- {"keyLeaveGuild",
- defaultAction(&Actions::leaveGuild),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "leaveguild|guildleave",
- UseArgs_false,
- Protected_true},
- {"keyGuildNotice",
- defaultAction(&Actions::guildNotice),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "notice|guildnotice",
- UseArgs_true,
- Protected_true},
- {"keyPartyItemShare",
- defaultAction(&Actions::partyItemShare),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "itemshare|shareitem",
- UseArgs_true,
- Protected_true},
- {"keyPartyExpShare",
- defaultAction(&Actions::partyExpShare),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "expshare|shareexp",
- UseArgs_true,
- Protected_true},
- {"keyPartyAutoItemShare",
- defaultAction(&Actions::partyAutoItemShare),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "autoitemshare|shareautoitem|itemautoshare",
- UseArgs_true,
- Protected_true},
- {"keyCreateItem",
- defaultAction(&Actions::createItem),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "createitem",
- UseArgs_true,
- Protected_true},
- {"keyCopyOutfitToChat",
- defaultAction(&Actions::outfitToChat),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "outfittochat|copyoutfittochat",
- UseArgs_false,
- Protected_true},
- {"keyCommandTranslate",
- defaultAction(&Actions::translate),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "translate|trans|tran",
- UseArgs_false,
- Protected_true},
- {"keyCommandSendGuiKey",
- defaultAction(&Actions::sendGuiKey),
- InputCondition::KEY_DOWN | InputCondition::ENABLED,
- "guikey|sendguikey",
- UseArgs_true,
- Protected_true},
- {"keyMoveAttackUp",
- defaultAction(&Actions::moveAttackUp),
- InputCondition::KEY_DOWN | InputCondition::ENABLED,
- "attackmoveup|moveattackup",
- UseArgs_true,
- Protected_true},
- {"keyMoveAttackDown",
- defaultAction(&Actions::moveAttackDown),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "attackmovedown|moveattackdown",
- UseArgs_true,
- Protected_true},
- {"keyMovePriorityAttackUp",
- defaultAction(&Actions::movePriorityAttackUp),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "attackmovepriorityup|movepriorityattackup",
- UseArgs_true,
- Protected_true},
- {"keyMovePriorityAttackDown",
- defaultAction(&Actions::movePriorityAttackDown),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "attackmoveprioritydown|movepriorityattackdown",
- UseArgs_true,
- Protected_true},
- {"keyShowItems",
- defaultAction(&Actions::showItems),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "showitems|items|itemsshow",
- UseArgs_true,
- Protected_true},
- {"keyCommandSendMouseKey",
- defaultAction(&Actions::sendMouseKey),
- InputCondition::KEY_DOWN | InputCondition::ENABLED,
- "mousekey|sendmousekey",
- UseArgs_true,
- Protected_true},
- {"keyCommandSendChars",
- defaultAction(&Actions::sendChars),
- InputCondition::KEY_DOWN | InputCondition::ENABLED,
- "sendchar|sendchars|charsend",
- UseArgs_true,
- Protected_true},
- {"keyClearOutfit",
- defaultAction(&Actions::outfitClear),
- InputCondition::KEY_DOWN |
- InputCondition::DEFAULT |
- InputCondition::INGAME,
- "clearoutfit|outfitclear",
- UseArgs_false,
- Protected_true},
- {"keyClipboardCopy",
- defaultAction(&Actions::clipboardCopy),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "clipboardcopy|copyclipboard",
- UseArgs_true,
- Protected_true},
- {"keyGotoPc",
- defaultAction(&Actions::commandGotoPc),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "goto|gotopc",
- UseArgs_true,
- Protected_true},
- {"keyCommandRecallPc",
- defaultAction(&Actions::commandRecallPc),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "recall|recallpc",
- UseArgs_true,
- Protected_true},
- {"keyCommandIpCheck",
- defaultAction(&Actions::commandIpCheck),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "ipcheck|checkip",
- UseArgs_true,
- Protected_true},
- {"keyWindowServerInfo",
- defaultAction(&Actions::serverInfoWindowShow),
- InputCondition::KEY_DOWN |
- InputCondition::GAME |
- InputCondition::NOTARGET,
- "serverinfo|infoserver",
- UseArgs_false,
- Protected_false},
- {"keyMercenaryToMaster",
- defaultAction(&Actions::mercenaryToMaster),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "mercenarytomaster|mercmaster",
- UseArgs_false,
- Protected_false},
- {"keyHomunculusToMaster",
- defaultAction(&Actions::homunculusToMaster),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "homunculustomaster|homunmaster",
- UseArgs_false,
- Protected_false},
- {"keyHomunculusFeed",
- defaultAction(&Actions::homunculusFeed),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "homunculusfeed|homunfeed|feedhomun|feedhomunculus",
- UseArgs_false,
- Protected_false},
- {"keyPetFeed",
- defaultAction(&Actions::petFeed),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "petfeed|feedpet",
- UseArgs_false,
- Protected_false},
- {"keyPetDropLoot",
- defaultAction(&Actions::petDropLoot),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "petdroploot|petloot",
- UseArgs_false,
- Protected_true},
- {"keyPetReturnToEgg",
- defaultAction(&Actions::petReturnToEgg),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "pettoegg|petegg|petreturn|returnpet|petreturnegg",
- UseArgs_false,
- Protected_false},
- {"keyPetUnequip",
- defaultAction(&Actions::petUnequip),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "petunequip|unequippet",
- UseArgs_false,
- Protected_false},
- {"keyAddSkillShortcut",
- defaultAction(&Actions::addSkillShortcut),
- InputCondition::KEY_DOWN | InputCondition::INGAME,
- "addskillshortcut|skillshortcut",
- UseArgs_true,
- Protected_false},
-};
-
-#undef defaultAction
-#undef addKey
-#undef joystickButton
-
-#endif // INPUT_INPUTACTIONMAP_H
diff --git a/src/input/inputactionoperators.cpp b/src/input/inputactionoperators.cpp
deleted file mode 100644
index 5d6db0967..000000000
--- a/src/input/inputactionoperators.cpp
+++ /dev/null
@@ -1,42 +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/>.
- */
-
-#include "input/inputactionoperators.h"
-
-#include "utils/cast.h"
-
-#include "debug.h"
-
-InputActionT operator+(InputActionT action, const int& i)
-{
- action = static_cast<InputActionT>(CAST_S32(action) + i);
- return action;
-}
-
-InputActionT operator+(InputActionT action, const unsigned int& i)
-{
- action = static_cast<InputActionT>(CAST_U32(action) + i);
- return action;
-}
-
-int operator-(const InputActionT &action1, const InputActionT &action2)
-{
- return CAST_S32(action1) - CAST_S32(action2);
-}
diff --git a/src/input/inputactionoperators.h b/src/input/inputactionoperators.h
deleted file mode 100644
index 02f98d1eb..000000000
--- a/src/input/inputactionoperators.h
+++ /dev/null
@@ -1,30 +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 INPUT_INPUTACTIONOPERATORS_H
-#define INPUT_INPUTACTIONOPERATORS_H
-
-#include "enums/input/inputaction.h"
-
-InputActionT operator+(InputActionT action, const int& i);
-InputActionT operator+(InputActionT action, const unsigned int& i);
-int operator-(const InputActionT &action1, const InputActionT &action2);
-
-#endif // INPUT_INPUTACTIONOPERATORS_H
diff --git a/src/input/inputactionsortfunctor.h b/src/input/inputactionsortfunctor.h
deleted file mode 100644
index 106f44b0a..000000000
--- a/src/input/inputactionsortfunctor.h
+++ /dev/null
@@ -1,46 +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 INPUT_INPUTACTIONSORTFUNCTOR_H
-#define INPUT_INPUTACTIONSORTFUNCTOR_H
-
-#include "input/inputactiondata.h"
-
-#include "utils/cast.h"
-
-#include "localconsts.h"
-
-class InputActionSortFunctor final
-{
- public:
- A_DEFAULT_COPY(InputActionSortFunctor)
-
- bool operator() (const InputActionT key1,
- const InputActionT key2) const
- {
- const size_t k1 = CAST_SIZE(key1);
- const size_t k2 = CAST_SIZE(key2);
- return keys[k1].priority > keys[k2].priority;
- }
-
- const InputActionData *keys A_NONNULLPOINTER;
-};
-
-#endif // INPUT_INPUTACTIONSORTFUNCTOR_H
diff --git a/src/input/inputfunction.h b/src/input/inputfunction.h
deleted file mode 100644
index 7b43203d6..000000000
--- a/src/input/inputfunction.h
+++ /dev/null
@@ -1,37 +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 INPUT_INPUTFUNCTION_H
-#define INPUT_INPUTFUNCTION_H
-
-#include "input/inputitem.h"
-
-#include "localconsts.h"
-
-const size_t inputFunctionSize = 3U;
-
-struct InputFunction final
-{
- A_DEFAULT_COPY(InputFunction)
-
- InputItem values[inputFunctionSize];
-};
-
-#endif // INPUT_INPUTFUNCTION_H
diff --git a/src/input/inputitem.h b/src/input/inputitem.h
deleted file mode 100644
index e7c7b4488..000000000
--- a/src/input/inputitem.h
+++ /dev/null
@@ -1,47 +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 INPUT_INPUTITEM_H
-#define INPUT_INPUTITEM_H
-
-#include "enums/input/inputtype.h"
-
-#include "localconsts.h"
-
-struct InputItem final
-{
- InputItem() :
- type(InputType::UNKNOWN),
- value(-1)
- { }
-
- InputItem(const InputTypeT type0,
- const int value0) :
- type(type0),
- value(value0)
- { }
-
- A_DEFAULT_COPY(InputItem)
-
- InputTypeT type;
- int value;
-};
-
-#endif // INPUT_INPUTITEM_H
diff --git a/src/input/inputmanager.cpp b/src/input/inputmanager.cpp
deleted file mode 100644
index db0c0c6c5..000000000
--- a/src/input/inputmanager.cpp
+++ /dev/null
@@ -1,1096 +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 "input/inputmanager.h"
-
-#include "configuration.h"
-#include "game.h"
-#include "settings.h"
-
-#include "being/localplayer.h"
-#include "being/playerinfo.h"
-
-#include "input/inputactionmap.h"
-#include "input/inputactionsortfunctor.h"
-#include "input/joystick.h"
-#include "input/keyboardconfig.h"
-#ifdef USE_SDL2
-#include "input/touch/multitouchmanager.h"
-#endif // USE_SDL2
-
-#include "input/touch/touchmanager.h"
-
-#include "gui/gui.h"
-#include "gui/sdlinput.h"
-
-#include "gui/widgets/selldialog.h"
-#include "gui/widgets/textfield.h"
-
-#include "gui/widgets/tabs/setup_input.h"
-
-#include "gui/windows/buydialog.h"
-#include "gui/windows/chatwindow.h"
-#include "gui/windows/inventorywindow.h"
-#include "gui/windows/npcdialog.h"
-#include "gui/windows/setupwindow.h"
-#include "gui/windows/textdialog.h"
-#include "gui/windows/tradewindow.h"
-
-#include "utils/checkutils.h"
-#include "utils/foreach.h"
-#include "utils/gettext.h"
-#include "utils/stdmove.h"
-#include "utils/timer.h"
-
-#include "gui/focushandler.h"
-
-#include <algorithm>
-
-#include "debug.h"
-
-InputManager inputManager;
-
-class QuitDialog;
-
-extern QuitDialog *quitDialog;
-
-namespace
-{
- InputActionSortFunctor inputActionDataSorter;
-} // namespace
-
-InputManager::InputManager() :
- mSetupInput(nullptr),
- mNewKeyIndex(InputAction::NO_VALUE),
- mMask(1),
- mNameMap(),
- mChatMap(),
- mKey()
-{
-}
-
-void InputManager::init() restrict2
-{
- for (size_t i = 0;
- i < CAST_SIZE(InputAction::TOTAL);
- i ++)
- {
- InputFunction &kf = mKey[i];
- mKeyStr[i].clear();
- for (size_t f = 0; f < inputFunctionSize; f ++)
- {
- InputItem &ki = kf.values[f];
- ki.type = InputType::UNKNOWN;
- ki.value = -1;
- }
- }
-
- mNewKeyIndex = InputAction::NO_VALUE;
-
- resetKeys();
- retrieve();
- update();
-}
-
-void InputManager::update()
-{
- keyboard.update();
- if (joystick != nullptr)
- joystick->update();
-}
-
-void InputManager::retrieve() restrict2
-{
- for (int i = 0; i < CAST_S32(InputAction::TOTAL); i ++)
- {
- const std::string &restrict cmd = inputActionData[i].chatCommand;
- if (!cmd.empty())
- {
- StringVect tokens;
- splitToStringVector(tokens, cmd, '|');
- FOR_EACH (StringVectCIter, it, tokens)
- mChatMap[*it] = i;
- }
-#ifdef USE_SDL2
- const std::string cf = std::string("sdl2")
- + inputActionData[i].configField;
-#else // USE_SDL2
-
- const std::string cf = inputActionData[i].configField;
-#endif // USE_SDL2
-
- InputFunction &restrict kf = mKey[i];
- if (!cf.empty())
- {
- mNameMap[cf] = static_cast<InputActionT>(i);
- const std::string keyStr = config.getValue(cf, "");
- const size_t keyStrSize = keyStr.size();
- if (keyStr.empty())
- {
- updateKeyString(kf, i);
- continue;
- }
-
- StringVect keys;
- splitToStringVector(keys, keyStr, ',');
- unsigned int i2 = 0;
- for (StringVectCIter it = keys.begin(), it_end = keys.end();
- it != it_end && i2 < inputFunctionSize; ++ it)
- {
- std::string keyStr2 = *it;
- if (keyStrSize < 2)
- continue;
- InputTypeT type = InputType::KEYBOARD;
- if ((keyStr2[0] < '0' || keyStr2[0] > '9')
- && keyStr2[0] != '-')
- {
- switch (keyStr2[0])
- {
- case 'm':
- type = InputType::MOUSE;
- break;
- case 'j':
- type = InputType::JOYSTICK;
- break;
- default:
- break;
- }
- keyStr2 = keyStr2.substr(1);
- }
- const int key = atoi(keyStr2.c_str());
- if (key >= -255 && key < SDLK_LAST)
- {
- kf.values[i2] = InputItem(type, key);
- i2 ++;
- }
- }
- for (; i2 < inputFunctionSize; i2 ++)
- kf.values[i2] = InputItem();
- }
- updateKeyString(kf, i);
- }
-}
-
-void InputManager::store() const restrict2
-{
- for (int i = 0; i < CAST_S32(InputAction::TOTAL); i ++)
- {
-#ifdef USE_SDL2
- const std::string cf = std::string("sdl2")
- + inputActionData[i].configField;
-#else // USE_SDL2
-
- const std::string cf = inputActionData[i].configField;
-#endif // USE_SDL2
-
- if (!cf.empty())
- {
- std::string keyStr;
- const InputFunction &restrict kf = mKey[i];
-
- for (size_t i2 = 0; i2 < inputFunctionSize; i2 ++)
- {
- const InputItem &restrict key = kf.values[i2];
- if (key.type != InputType::UNKNOWN)
- {
- std::string tmp("k");
- switch (key.type)
- {
- case InputType::MOUSE:
- tmp = "m";
- break;
- case InputType::JOYSTICK:
- tmp = "j";
- break;
- case InputType::KEYBOARD:
- case InputType::UNKNOWN:
- default:
- break;
- }
- if (key.value != -1)
- {
- if (keyStr.empty())
- {
- keyStr.append(tmp).append(toString(key.value));
- }
- else
- {
- keyStr.append(strprintf(",%s%d",
- tmp.c_str(), key.value));
- }
- }
- }
- }
- if (keyStr.empty())
- keyStr = "-1";
-
- config.setValue(cf, keyStr);
- }
- }
-}
-
-void InputManager::resetKey(const InputActionT i) restrict2
-{
- InputFunction &restrict key = mKey[CAST_SIZE(i)];
- for (size_t i2 = 1; i2 < inputFunctionSize; i2 ++)
- {
- InputItem &restrict ki2 = key.values[i2];
- ki2.type = InputType::UNKNOWN;
- ki2.value = -1;
- }
- const InputActionData &restrict kd =
- inputActionData[CAST_SIZE(i)];
- InputItem &restrict val0 = key.values[0];
- val0.type = kd.defaultType1;
- InputItem &restrict val1 = key.values[1];
- val1.type = kd.defaultType2;
-#ifdef USE_SDL2
- if (kd.defaultType1 == InputType::KEYBOARD)
- val0.value = SDL_GetScancodeFromKey(kd.defaultValue1);
- else
- val0.value = kd.defaultValue1;
- if (kd.defaultType2 == InputType::KEYBOARD)
- val1.value = SDL_GetScancodeFromKey(kd.defaultValue2);
- else
- val1.value = kd.defaultValue2;
- if (val0.value == SDL_SCANCODE_UNKNOWN)
- val0.value = -1;
- if (val1.value == SDL_SCANCODE_UNKNOWN)
- val1.value = -1;
-#else // USE_SDL2
-
- val0.value = kd.defaultValue1;
- val1.value = kd.defaultValue2;
-#endif // USE_SDL2
-
- updateKeyString(key, CAST_SIZE(i));
-}
-
-void InputManager::resetKeys() restrict2
-{
- for (int i = 0; i < CAST_S32(InputAction::TOTAL); i++)
- resetKey(static_cast<InputActionT>(i));
-}
-
-void InputManager::makeDefault(const InputActionT i) restrict2
-{
- if (i > InputAction::NO_VALUE && i < InputAction::TOTAL)
- {
- resetKey(i);
- update();
- }
-}
-
-bool InputManager::hasConflicts(InputActionT &restrict key1,
- InputActionT &restrict key2) const restrict2
-{
- /**
- * No need to parse the square matrix: only check one triangle
- * that's enough to detect conflicts
- */
- for (int i = 0; i < CAST_S32(InputAction::TOTAL); i++)
- {
- const InputActionData &restrict kdi = inputActionData[i];
- if (*kdi.configField == 0)
- continue;
-
- const InputFunction &restrict ki = mKey[i];
- for (size_t i2 = 0; i2 < inputFunctionSize; i2 ++)
- {
- const InputItem &restrict vali2 = ki.values[i2];
- if (vali2.value == -1)
- continue;
-
- size_t j;
- for (j = i, j++; j < CAST_S32(InputAction::TOTAL); j++)
- {
- if ((kdi.grp & inputActionData[j].grp) == 0
- || (*kdi.configField == 0))
- {
- continue;
- }
-
- for (size_t j2 = 0; j2 < inputFunctionSize; j2 ++)
- {
- const InputItem &restrict valj2 = mKey[j].values[j2];
- // Allow for item shortcut and emote keys to overlap
- // as well as emote and ignore keys, but no other keys
- if (valj2.type != InputType::UNKNOWN
- && vali2.value == valj2.value
- && vali2.type == valj2.type)
- {
- key1 = static_cast<InputActionT>(i);
- key2 = static_cast<InputActionT>(j);
- return true;
- }
- }
- }
- }
- }
- return false;
-}
-
-void InputManager::callbackNewKey() restrict2
-{
-#ifndef DYECMD
- mSetupInput->newKeyCallback(mNewKeyIndex);
-#endif // DYECMD
-}
-
-bool InputManager::isActionActive(const InputActionT index) const restrict2
-{
- if (!isActionActive0(index))
- return false;
-
- const InputActionData &restrict key =
- inputActionData[CAST_SIZE(index)];
-// logger->log("isActionActive mask=%d, condition=%d, index=%d",
-// mMask, key.condition, index);
- if ((key.condition & mMask) != key.condition)
- return false;
- return true;
-}
-
-bool InputManager::isActionActive0(const InputActionT index)
-{
- if (keyboard.isActionActive(index))
- return true;
- if ((joystick != nullptr) && joystick->isActionActive(index))
- return true;
- return touchManager.isActionActive(index);
-}
-
-InputFunction &InputManager::getKey(InputActionT index) restrict2
-{
- if (CAST_S32(index) < 0 || index >= InputAction::TOTAL)
- index = InputAction::MOVE_UP;
- return mKey[CAST_SIZE(index)];
-}
-
-std::string InputManager::getKeyStringLong(const InputActionT index) const
- restrict2
-{
- std::string keyStr;
- const InputFunction &restrict ki = mKey[CAST_SIZE(index)];
-
- for (size_t i = 0; i < inputFunctionSize; i ++)
- {
- const InputItem &restrict key = ki.values[i];
- std::string str;
- if (key.type == InputType::KEYBOARD)
- {
- if (key.value >= 0)
- {
- str = KeyboardConfig::getKeyName(key.value);
- }
- else if (key.value < -1)
- {
- // TRANSLATORS: long key name. must be short.
- str = strprintf(_("key_%d"), -key.value);
- }
- }
- else if (key.type == InputType::JOYSTICK)
- {
- // TRANSLATORS: long joystick button name. must be short.
- str = strprintf(_("JButton%d"), key.value + 1);
- }
- if (!str.empty())
- {
- if (keyStr.empty())
- keyStr = str;
- else
- keyStr.append(", ").append(str);
- }
- }
-
- if (keyStr.empty())
- {
- // TRANSLATORS: unknown long key type
- return _("unknown key");
- }
- return keyStr;
-}
-
-void InputManager::updateKeyString(const InputFunction &ki,
- const size_t actionIdx) restrict2
-{
- std::string keyStr;
- for (size_t i = 0; i < inputFunctionSize; i ++)
- {
- const InputItem &restrict key = ki.values[i];
- std::string str;
- if (key.type == InputType::KEYBOARD)
- {
- if (key.value >= 0)
- {
- str = KeyboardConfig::getKeyShortString(
- KeyboardConfig::getKeyName(key.value));
- }
- else if (key.value < -1)
- {
- // TRANSLATORS: short key name. must be very short.
- str = strprintf(_("key_%d"), -key.value);
- }
- }
- else if (key.type == InputType::JOYSTICK)
- {
- // TRANSLATORS: short joystick button name. muse be very short
- str = strprintf(_("JB%d"), key.value + 1);
- }
- if (!str.empty())
- {
- if (keyStr.empty())
- keyStr = str;
- else
- keyStr.append(", ").append(str);
- }
- }
-
- if (keyStr.empty())
- {
- // TRANSLATORS: unknown short key type. must be short
- mKeyStr[actionIdx] = _("u key");
- }
- else
- {
- mKeyStr[actionIdx] = STD_MOVE(keyStr);
- }
-}
-
-std::string InputManager::getKeyValueString(const InputActionT index) const
- restrict2
-{
- return mKeyStr[CAST_SIZE(index)];
-}
-
-std::string InputManager::getKeyValueByName(const std::string &restrict
- keyName) restrict2
-{
- const StringInpActionMapCIter it = mNameMap.find(keyName);
-
- if (it == mNameMap.end())
- return std::string();
- return getKeyValueString((*it).second);
-}
-
-std::string InputManager::getKeyValueByNameLong(const std::string &restrict
- keyName) restrict2
-{
- const StringInpActionMapCIter it = mNameMap.find(keyName);
-
- if (it == mNameMap.end())
- return std::string();
- return getKeyStringLong((*it).second);
-}
-
-void InputManager::addActionKey(const InputActionT action,
- const InputTypeT type,
- const int val) restrict2
-{
- if (CAST_S32(action) < 0 || action >= InputAction::TOTAL)
- return;
-
- int idx = -1;
- InputFunction &restrict key = mKey[CAST_SIZE(action)];
- for (size_t i = 0; i < inputFunctionSize; i ++)
- {
- const InputItem &restrict val2 = key.values[i];
- if (val2.type == InputType::UNKNOWN ||
- (val2.type == type && val2.value == val))
- {
- idx = CAST_S32(i);
- break;
- }
- }
- if (idx == -1)
- {
- for (size_t i = 1; i < inputFunctionSize; i ++)
- {
- InputItem &restrict val1 = key.values[i - 1];
- InputItem &restrict val2 = key.values[i];
- val1.type = val2.type;
- val1.value = val2.value;
- }
- idx = inputFunctionSize - 1;
- }
-
- key.values[idx] = InputItem(type, val);
- updateKeyString(key, CAST_SIZE(action));
-}
-
-void InputManager::setNewKey(const SDL_Event &event,
- const InputTypeT type) restrict2
-{
- int val = -1;
- if (type == InputType::KEYBOARD)
- val = KeyboardConfig::getKeyValueFromEvent(event);
- else if (type == InputType::JOYSTICK && (joystick != nullptr))
- val = joystick->getButtonFromEvent(event);
-
- if (val != -1)
- {
- addActionKey(mNewKeyIndex, type, val);
- update();
- }
-}
-
-void InputManager::unassignKey() restrict2
-{
- InputFunction &restrict key = mKey[CAST_SIZE(mNewKeyIndex)];
- for (size_t i = 0; i < inputFunctionSize; i ++)
- {
- InputItem &restrict val = key.values[i];
- val.type = InputType::UNKNOWN;
- val.value = -1;
- }
- updateKeyString(key, CAST_SIZE(mNewKeyIndex));
- update();
-}
-
-#ifndef DYECMD
-bool InputManager::handleAssignKey(const SDL_Event &restrict event,
- const InputTypeT type) restrict2
-{
- if ((setupWindow != nullptr) && setupWindow->isWindowVisible() &&
- getNewKeyIndex() > InputAction::NO_VALUE)
- {
- setNewKey(event, type);
- callbackNewKey();
- setNewKeyIndex(InputAction::NO_VALUE);
- return true;
- }
- return false;
-}
-#else // DYECMD
-
-bool InputManager::handleAssignKey(const SDL_Event &restrict event A_UNUSED,
- const InputTypeT type A_UNUSED) restrict2
-{
- return false;
-}
-#endif // DYECMD
-
-bool InputManager::handleEvent(const SDL_Event &restrict event) restrict2
-{
- BLOCK_START("InputManager::handleEvent")
- switch (event.type)
- {
- case SDL_KEYDOWN:
- {
-#ifdef USE_SDL2
- if (keyboard.ignoreKey(event))
- {
- BLOCK_END("InputManager::handleEvent")
- return true;
- }
-#endif // USE_SDL2
-
- keyboard.refreshActiveKeys();
- updateConditionMask(true);
- if (handleAssignKey(event, InputType::KEYBOARD))
- {
- BLOCK_END("InputManager::handleEvent")
- return true;
- }
-
- keyboard.handleActivateKey(event);
- // send straight to gui for certain windows
-#ifndef DYECMD
- if ((quitDialog != nullptr) || TextDialog::isActive())
- {
- if (guiInput != nullptr)
- guiInput->pushInput(event);
- if (gui != nullptr)
- gui->handleInput();
- BLOCK_END("InputManager::handleEvent")
- return true;
- }
-#endif // DYECMD
-
- break;
- }
- case SDL_KEYUP:
- {
-#ifdef USE_SDL2
- if (keyboard.ignoreKey(event))
- {
- BLOCK_END("InputManager::handleEvent")
- return true;
- }
-#endif // USE_SDL2
-
- keyboard.refreshActiveKeys();
- updateConditionMask(false);
- keyboard.handleDeActicateKey(event);
- break;
- }
- case SDL_JOYBUTTONDOWN:
- {
- updateConditionMask(true);
-// joystick.handleActicateButton(event);
- if (handleAssignKey(event, InputType::JOYSTICK))
- {
- BLOCK_END("InputManager::handleEvent")
- return true;
- }
- break;
- }
- case SDL_JOYBUTTONUP:
- {
- updateConditionMask(false);
-// joystick.handleDeActicateButton(event);
- break;
- }
-#ifdef USE_SDL2
- case SDL_FINGERDOWN:
- multiTouchManager.handleFingerDown(event);
- break;
- case SDL_FINGERUP:
- multiTouchManager.handleFingerUp(event);
- break;
-#else // USE_SDL2
-#ifdef ANDROID
- case SDL_ACCELEROMETER:
- {
- break;
- }
-#endif // ANDROID
-#endif // USE_SDL2
-
- default:
- break;
- }
-
- if (guiInput != nullptr)
- guiInput->pushInput(event);
- if (gui != nullptr)
- {
- const bool res = gui->handleInput();
- if (res && event.type == SDL_KEYDOWN)
- {
- BLOCK_END("InputManager::handleEvent")
- return true;
- }
- }
-
- switch (event.type)
- {
- case SDL_KEYDOWN:
- if (isActionActive(InputAction::IGNORE_INPUT_1) ||
- isActionActive(InputAction::IGNORE_INPUT_2))
- {
- BLOCK_END("InputManager::handleEvent")
- return true;
- }
- if (triggerAction(keyboard.getActionVector(event)))
- {
- BLOCK_END("InputManager::handleEvent")
- return true;
- }
- break;
-
-// disabled temporary
-// case SDL_KEYUP:
-// if (triggerAction(keyboard.getActionVector(event)))
-// {
-// BLOCK_END("InputManager::handleEvent")
-// return true;
-// }
-// break;
-
- case SDL_JOYBUTTONDOWN:
- if ((joystick != nullptr) && joystick->validate())
- {
- if (triggerAction(joystick->getActionVector(event)))
- {
- BLOCK_END("InputManager::handleEvent")
- return true;
- }
- }
- break;
-#ifdef ANDROID
-#ifndef USE_SDL2
- case SDL_ACCELEROMETER:
- {
- break;
- }
-#endif // USE_SDL2
-#endif // ANDROID
-
- default:
- break;
- }
-
- BLOCK_END("InputManager::handleEvent")
- return false;
-}
-
-void InputManager::handleRepeat()
-{
- const int time = tick_time;
- keyboard.handleRepeat(time);
- if (joystick != nullptr)
- joystick->handleRepeat(time);
-}
-
-void InputManager::updateConditionMask(const bool pressed A_UNUSED) restrict2
-{
- mMask = 1;
- if (keyboard.isEnabled())
- mMask |= InputCondition::ENABLED;
-#ifndef DYECMD
- if (((chatWindow == nullptr) || !chatWindow->isInputFocused()) &&
- !NpcDialog::isAnyInputFocused() &&
- !InventoryWindow::isAnyInputFocused() &&
- ((tradeWindow == nullptr) || !tradeWindow->isInpupFocused()))
- {
- if (gui != nullptr)
- {
- FocusHandler *restrict const focus = gui->getFocusHandler();
- if (focus != nullptr)
- {
- if (dynamic_cast<TextField*>(focus->getFocused()) == nullptr)
- mMask |= InputCondition::NOINPUT;
- }
- else
- {
- mMask |= InputCondition::NOINPUT;
- }
- }
- else
- {
- mMask |= InputCondition::NOINPUT;
- }
- }
-
- if (!BuyDialog::isActive() && !SellDialog::isActive())
- mMask |= InputCondition::NOBUYSELL;
-
- if (!PlayerInfo::isVending())
- mMask |= InputCondition::NOVENDING;
- if (!PlayerInfo::isInRoom())
- mMask |= InputCondition::NOROOM;
-
- const NpcDialog *restrict const dialog = NpcDialog::getActive();
- if ((dialog == nullptr) || !dialog->isTextInputFocused())
- mMask |= InputCondition::NONPCINPUT;
- if ((dialog == nullptr) || (dialog->isCloseState() != 0))
- {
- mMask |= InputCondition::NONPCDIALOG;
- if (!InventoryWindow::isStorageActive())
- mMask |= InputCondition::NOTALKING;
- }
- if ((setupWindow == nullptr) || !setupWindow->isWindowVisible())
- mMask |= InputCondition::NOSETUP;
-
- if ((Game::instance() != nullptr) && Game::instance()->getValidSpeed())
- mMask |= InputCondition::VALIDSPEED;
-
- if (Game::instance() != nullptr)
- mMask |= InputCondition::INGAME;
-
- if (localPlayer != nullptr)
- {
- if (localPlayer->getFollow().empty())
- mMask |= InputCondition::NOFOLLOW;
-
- if (!localPlayer->isTrickDead())
- mMask |= InputCondition::NOBLOCK;
-
- if (localPlayer->isAlive())
- mMask |= InputCondition::ALIVE;
- }
- else
- {
- mMask |= InputCondition::NOFOLLOW;
- mMask |= InputCondition::NOBLOCK;
- }
-#endif // DYECMD
-
- if (!settings.awayMode)
- mMask |= InputCondition::NOAWAY;
-
- if (gui != nullptr && gui->getFocusHandler()->getModalFocused() == nullptr)
- mMask |= InputCondition::NOMODAL;
-
- if (!settings.disableGameModifiers)
- mMask |= InputCondition::EMODS;
-
- if (!isActionActive0(InputAction::STOP_ATTACK)
- && !isActionActive0(InputAction::UNTARGET))
- {
- mMask |= InputCondition::NOTARGET;
- }
- // enable it temporary
- mMask |= InputCondition::KEY_DOWN;
-// if (pressed == true)
-// mMask |= InputCondition::KEY_DOWN;
-// else
-// mMask |= InputCondition::KEY_UP;
-}
-
-bool InputManager::checkKey(const InputActionData *restrict const key) const
- restrict2
-{
- // logger->log("checkKey mask=%d, condition=%d", mMask, key->condition);
- if ((key == nullptr) || (key->condition & mMask) != key->condition)
- return false;
-
- return key->modKeyIndex == InputAction::NO_VALUE
- || isActionActive0(key->modKeyIndex);
-}
-
-bool InputManager::invokeKey(const InputActionData *restrict const key,
- const InputActionT keyNum) restrict2
-{
- // no validation to keyNum because it validated in caller
-
- if (checkKey(key))
- {
- InputEvent evt(keyNum, mMask);
- ActionFuncPtr func = *(inputActionData[
- CAST_SIZE(keyNum)].action);
- if ((func != nullptr) && func(evt))
- return true;
- }
- return false;
-}
-
-void InputManager::executeAction(const InputActionT keyNum) restrict2
-{
- if (keyNum < InputAction::MOVE_UP || keyNum >= InputAction::TOTAL)
- return;
-
- ActionFuncPtr func = *(inputActionData[CAST_SIZE(
- keyNum)].action);
- if (func != nullptr)
- {
- InputEvent evt(keyNum, mMask);
- func(evt);
- }
-}
-
-bool InputManager::executeChatCommand(const std::string &restrict cmd,
- const std::string &restrict args,
- ChatTab *restrict const tab) restrict2
-{
- const StringIntMapCIter it = mChatMap.find(cmd);
- if (it != mChatMap.end())
- {
- ActionFuncPtr func = *(inputActionData[(*it).second].action);
- if (func != nullptr)
- {
- InputEvent evt(args, tab, mMask);
- func(evt);
- return true;
- }
- }
- else
- {
- reportAlways("Unknown chat command: /%s %s",
- cmd.c_str(),
- args.c_str());
- }
- return false;
-}
-
-bool InputManager::executeRemoteChatCommand(const std::string &restrict cmd,
- const std::string &restrict args,
- ChatTab *restrict const tab)
- restrict2
-{
- const StringIntMapCIter it = mChatMap.find(cmd);
- if (it != mChatMap.end())
- {
- const InputActionData &restrict data = inputActionData[(*it).second];
- if (data.isProtected == Protected_true)
- return false;
- ActionFuncPtr func = *(data.action);
- if (func != nullptr)
- {
- InputEvent evt(args, tab, mMask);
- func(evt);
- return true;
- }
- }
- return false;
-}
-
-bool InputManager::executeChatCommand(const InputActionT keyNum,
- const std::string &restrict args,
- ChatTab *restrict const tab) restrict2
-{
- if (CAST_S32(keyNum) < 0 || keyNum >= InputAction::TOTAL)
- return false;
- ActionFuncPtr func = *(inputActionData[CAST_SIZE(
- keyNum)].action);
- if (func != nullptr)
- {
- InputEvent evt(args, tab, mMask);
- func(evt);
- return true;
- }
- return false;
-}
-
-void InputManager::updateKeyActionMap(KeyToActionMap &restrict actionMap,
- KeyToIdMap &restrict idMap,
- KeyTimeMap &restrict keyTimeMap,
- const InputTypeT type) const restrict2
-{
- actionMap.clear();
- keyTimeMap.clear();
-
- for (size_t i = 0; i < CAST_SIZE(InputAction::TOTAL); i ++)
- {
- const InputFunction &restrict key = mKey[i];
- const InputActionData &restrict kd = inputActionData[i];
- if (kd.action != nullptr)
- {
- for (size_t i2 = 0; i2 < inputFunctionSize; i2 ++)
- {
- const InputItem &restrict ki = key.values[i2];
- if (ki.type == type && ki.value != -1)
- {
- actionMap[ki.value].push_back(
- static_cast<InputActionT>(i));
- }
- }
- }
- if (kd.configField != nullptr && (kd.grp & Input::GRP_GUICHAN) != 0)
- {
- for (size_t i2 = 0; i2 < inputFunctionSize; i2 ++)
- {
- const InputItem &restrict ki = key.values[i2];
- if (ki.type == type && ki.value != -1)
- idMap[ki.value] = static_cast<InputActionT>(i);
- }
- }
- if (kd.configField != nullptr && (kd.grp & Input::GRP_REPEAT) != 0)
- {
- for (size_t i2 = 0; i2 < inputFunctionSize; i2 ++)
- {
- const InputItem &restrict ki = key.values[i2];
- if (ki.type == type && ki.value != -1)
- keyTimeMap[ki.value] = 0;
- }
- }
- }
-
- inputActionDataSorter.keys = &inputActionData[0];
- FOR_EACH (KeyToActionMapIter, it, actionMap)
- {
- KeysVector *const keys = &it->second;
- if (keys->size() > 1)
- std::sort(keys->begin(), keys->end(), inputActionDataSorter);
- }
-}
-
-bool InputManager::triggerAction(const KeysVector *restrict const ptrs)
- restrict2
-{
- if (ptrs == nullptr)
- return false;
-
-// logger->log("ptrs: %d", (int)ptrs.size());
-
- FOR_EACHP (KeysVectorCIter, it, ptrs)
- {
- const InputActionT keyNum = *it;
- if (CAST_S32(keyNum) < 0 || keyNum >= InputAction::TOTAL)
- continue;
-
- if (invokeKey(&inputActionData[CAST_SIZE(keyNum)], keyNum))
- return true;
- }
- return false;
-}
-
-InputActionT InputManager::getKeyIndex(const int value,
- const int grp,
- const InputTypeT type) const restrict2
-{
- for (size_t i = 0; i < CAST_SIZE(InputAction::TOTAL); i++)
- {
- const InputFunction &restrict key = mKey[i];
- const InputActionData &restrict kd = inputActionData[i];
- for (size_t i2 = 0; i2 < inputFunctionSize; i2 ++)
- {
- const InputItem &restrict vali2 = key.values[i2];
- if (value == vali2.value &&
- (grp & kd.grp) != 0 && vali2.type == type)
- {
- return static_cast<InputActionT>(i);
- }
- }
- }
- return InputAction::NO_VALUE;
-}
-
-InputActionT InputManager::getActionByKey(const SDL_Event &restrict event)
- const restrict2
-{
- // for now support only keyboard events
- if (event.type == SDL_KEYDOWN || event.type == SDL_KEYUP)
- {
- const InputActionT idx = keyboard.getActionId(event);
- if (CAST_S32(idx) >= 0 &&
- checkKey(&inputActionData[CAST_SIZE(idx)]))
- {
- return idx;
- }
- }
- return InputAction::NO_VALUE;
-}
-
-InputActionT InputManager::getActionByConfigField(const std::string &field)
- const restrict2
-{
- for (int i = 0; i < CAST_S32(InputAction::TOTAL); i ++)
- {
- const std::string cf = inputActionData[i].configField;
- if (field == cf)
- return static_cast<InputActionT>(i);
- }
- return InputAction::NO_VALUE;
-}
-
-void InputManager::addChatCommands(std::list<std::string> &restrict arr)
- restrict
-{
- const int sz = CAST_S32(InputAction::TOTAL);
- for (int i = 0; i < sz; i++)
- {
- const InputActionData &restrict ad = inputActionData[i];
- std::string cmd = ad.chatCommand;
- if (!cmd.empty())
- {
- StringVect tokens;
- splitToStringVector(tokens, cmd, '|');
- FOR_EACH (StringVectCIter, it, tokens)
- {
- cmd = std::string("/").append(*it);
- if (ad.useArgs == UseArgs_true)
- cmd.append(" ");
- arr.push_back(cmd);
- }
- }
- }
-}
diff --git a/src/input/inputmanager.h b/src/input/inputmanager.h
deleted file mode 100644
index 012c06f7d..000000000
--- a/src/input/inputmanager.h
+++ /dev/null
@@ -1,189 +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 INPUT_INPUTMANAGER_H
-#define INPUT_INPUTMANAGER_H
-
-#include "input/inputfunction.h"
-
-#include "events/inputevent.h"
-
-#include "utils/cast.h"
-#include "utils/stringmap.h"
-
-#include <list>
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_events.h>
-PRAGMA48(GCC diagnostic pop)
-
-class Setup_Input;
-
-struct InputActionData;
-
-typedef std::map<std::string, InputActionT> StringInpActionMap;
-typedef StringInpActionMap::const_iterator StringInpActionMapCIter;
-
-class InputManager final
-{
- public:
- InputManager();
-
- A_DELETE_COPY(InputManager)
-
- void init() restrict2;
-
- bool handleEvent(const SDL_Event &restrict event) restrict2;
-
- bool checkKey(const InputActionData *restrict const key) const
- restrict2 A_WARN_UNUSED;
-
- void retrieve() restrict2;
-
- void store() const restrict2;
-
- void resetKeys() restrict2;
-
- void makeDefault(const InputActionT i) restrict2;
-
- bool hasConflicts(InputActionT &restrict key1,
- InputActionT &restrict key2) const
- restrict2 A_WARN_UNUSED;
-
- void callbackNewKey() restrict2;
-
- InputFunction &getKey(InputActionT index)
- restrict2 A_CONST A_WARN_UNUSED;
-
- std::string getKeyValueString(const InputActionT index)
- const restrict2 A_WARN_UNUSED;
-
- std::string getKeyStringLong(const InputActionT index)
- const restrict2 A_WARN_UNUSED;
-
- std::string getKeyValueByName(const std::string &restrict keyName)
- restrict2;
-
- std::string getKeyValueByNameLong(const std::string &restrict keyName)
- restrict2;
-
- void addActionKey(const InputActionT action,
- const InputTypeT type,
- const int val) restrict2;
-
- void setNewKey(const SDL_Event &event,
- const InputTypeT type) restrict2;
-
- void unassignKey() restrict2;
-
- bool isActionActive(const InputActionT index) const
- restrict2 A_WARN_UNUSED;
-
- /**
- * Set the index of the new key to be assigned.
- */
- void setNewKeyIndex(const InputActionT value) restrict2 noexcept2
- { mNewKeyIndex = value; }
-
- /**
- * Set a reference to the key setup window.
- */
- void setSetupInput(Setup_Input *restrict const setupInput)
- restrict2 noexcept2 A_NONNULL(2)
- { mSetupInput = setupInput; }
-
- /**
- * Get the index of the new key to be assigned.
- */
- InputActionT getNewKeyIndex() const restrict2 noexcept2 A_WARN_UNUSED
- { return mNewKeyIndex; }
-
- void updateKeyActionMap(KeyToActionMap &restrict actionMap,
- KeyToIdMap &restrict idMap,
- KeyTimeMap &restrict keyTimeMap,
- const InputTypeT type) const restrict2;
-
- bool invokeKey(const InputActionData *restrict const key,
- const InputActionT keyNum) restrict2;
-
- bool handleAssignKey(const SDL_Event &restrict event,
- const InputTypeT type) restrict2;
-
- static void handleRepeat();
-
- bool triggerAction(const KeysVector *restrict const ptrs) restrict2;
-
- InputActionT getKeyIndex(const int value,
- const int grp,
- const InputTypeT type) const
- restrict2 A_WARN_UNUSED;
-
- static void update();
-
- void updateConditionMask(const bool pressed) restrict2;
-
- InputActionT getActionByKey(const SDL_Event &restrict event)
- const restrict2 A_WARN_UNUSED;
-
- InputActionT getActionByConfigField(const std::string &field)
- const restrict2 A_WARN_UNUSED;
-
- void executeAction(const InputActionT keyNum) restrict2;
-
- bool executeChatCommand(const std::string &restrict cmd,
- const std::string &restrict args,
- ChatTab *restrict const tab) restrict2;
-
- bool executeRemoteChatCommand(const std::string &restrict cmd,
- const std::string &restrict args,
- ChatTab *restrict const tab) restrict2;
-
- bool executeChatCommand(const InputActionT keyNum,
- const std::string &restrict args,
- ChatTab *restrict const tab) restrict2;
-
- void addChatCommands(std::list<std::string> &restrict arr) restrict;
-
- protected:
- void resetKey(const InputActionT i) restrict2;
-
- static bool isActionActive0(const InputActionT index) A_WARN_UNUSED;
-
- void updateKeyString(const InputFunction &ki,
- const size_t actionIdx) restrict2;
-
- /** Reference to setup window */
- Setup_Input *mSetupInput A_NONNULLPOINTER;
- /** Index of new key to be assigned */
- InputActionT mNewKeyIndex;
-
- int mMask;
-
- StringInpActionMap mNameMap;
- StringIntMap mChatMap;
-
- InputFunction mKey[CAST_SIZE(InputAction::TOTAL)];
- std::string mKeyStr[CAST_SIZE(InputAction::TOTAL)];
-};
-
-extern InputManager inputManager;
-
-#endif // INPUT_INPUTMANAGER_H
diff --git a/src/input/joystick.cpp b/src/input/joystick.cpp
deleted file mode 100644
index fc4b8434d..000000000
--- a/src/input/joystick.cpp
+++ /dev/null
@@ -1,446 +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 "input/joystick.h"
-
-#include "configuration.h"
-#include "logger.h"
-#include "settings.h"
-#include "sdlshared.h"
-
-#include "input/inputmanager.h"
-
-#include "utils/foreach.h"
-#include "utils/timer.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL.h>
-PRAGMA48(GCC diagnostic pop)
-
-#include "debug.h"
-
-Joystick *joystick = nullptr;
-int Joystick::joystickCount = 0;
-bool Joystick::mEnabled = false;
-
-Joystick::Joystick(const int no) :
- mDirection(0),
- mJoystick(nullptr),
- mUpTolerance(0),
- mDownTolerance(0),
- mLeftTolerance(0),
- mRightTolerance(0),
- mCalibrating(false),
- mNumber(no >= joystickCount ? joystickCount : no),
- mCalibrated(false),
- mButtonsNumber(MAX_BUTTONS),
- mUseInactive(false),
- mHaveHats(false),
- mKeyToAction(),
- mKeyToId(),
- mKeyTimeMap()
-{
- for (int i = 0; i < MAX_BUTTONS; i++)
- mActiveButtons[i] = false;
-}
-
-Joystick::~Joystick()
-{
- close();
-}
-
-void Joystick::init()
-{
- SDL_InitSubSystem(SDL_INIT_JOYSTICK);
- // +++ possible to use SDL_EventState with different joystick features.
- SDL_JoystickEventState(SDL_ENABLE);
- joystickCount = SDL_NumJoysticks();
- logger->log("%i joysticks/gamepads found", joystickCount);
- for (int i = 0; i < joystickCount; i++)
- logger->log("- %s", SDL_JoystickNameForIndex(i));
-
- mEnabled = config.getBoolValue("joystickEnabled");
-
- if (joystickCount > 0)
- {
- joystick = new Joystick(config.getIntValue("selectedJoystick"));
- if (mEnabled)
- joystick->open();
- }
-}
-
-bool Joystick::open()
-{
- if (mNumber >= joystickCount)
- mNumber = joystickCount - 1;
- if (mNumber < 0)
- {
- logger->log1("error: incorrect joystick selection");
- return false;
- }
- logger->log("open joystick %d", mNumber);
-
- mJoystick = SDL_JoystickOpen(mNumber);
-
- if (mJoystick == nullptr)
- {
- logger->log("Couldn't open joystick: %s", SDL_GetError());
- return false;
- }
-
- mButtonsNumber = SDL_JoystickNumButtons(mJoystick);
- logger->log("Joystick: %i ", mNumber);
-#ifdef USE_SDL2
- logger->log("Name: %s", SDL_JoystickName(mJoystick));
- SDL_JoystickGUID guid = SDL_JoystickGetGUID(mJoystick);
- std::string guidStr;
- for (int f = 0; f < 16; f ++)
- guidStr.append(strprintf("%02x", CAST_U32(guid.data[f])));
- logger->log("Guid: %s", guidStr.c_str());
-#if SDL_VERSION_ATLEAST(2, 0, 6)
- logger->log("Device id: %u:%u.%u",
- CAST_U32(SDL_JoystickGetVendor(mJoystick)),
- CAST_U32(SDL_JoystickGetProduct(mJoystick)),
- CAST_U32(SDL_JoystickGetProductVersion(mJoystick)));
-
- SDL_JoystickType type = SDL_JoystickGetType(mJoystick);
- std::string typeStr;
- switch (type)
- {
- default:
- case SDL_JOYSTICK_TYPE_UNKNOWN:
- typeStr = "unknown";
- break;
- case SDL_JOYSTICK_TYPE_GAMECONTROLLER:
- typeStr = "game controller";
- break;
- case SDL_JOYSTICK_TYPE_WHEEL:
- typeStr = "wheel";
- break;
- case SDL_JOYSTICK_TYPE_ARCADE_STICK:
- typeStr = "arcade stick";
- break;
- case SDL_JOYSTICK_TYPE_FLIGHT_STICK:
- typeStr = "flight stick";
- break;
- case SDL_JOYSTICK_TYPE_DANCE_PAD:
- typeStr = "dance pad";
- break;
- case SDL_JOYSTICK_TYPE_GUITAR:
- typeStr = "guitar";
- break;
- case SDL_JOYSTICK_TYPE_DRUM_KIT:
- typeStr = "drum kit";
- break;
- case SDL_JOYSTICK_TYPE_ARCADE_PAD:
- typeStr = "arcade pad";
- break;
- case SDL_JOYSTICK_TYPE_THROTTLE:
- typeStr = "throttle";
- break;
- }
- logger->log("Type: " + typeStr);
-#endif // SDL_VERSION_ATLEAST(2, 0, 6)
- // probably need aslo dump SDL_JoystickCurrentPowerLevel
-#else // USE_SDL2
-
- logger->log("Name: %s", SDL_JoystickName(mNumber));
-#endif // USE_SDL2
-
- logger->log("Axes: %i ", SDL_JoystickNumAxes(mJoystick));
- logger->log("Balls: %i", SDL_JoystickNumBalls(mJoystick));
- logger->log("Hats: %i", SDL_JoystickNumHats(mJoystick));
- logger->log("Buttons: %i", mButtonsNumber);
-
- mHaveHats = (SDL_JoystickNumHats(mJoystick) > 0);
-
- if (mButtonsNumber > MAX_BUTTONS)
- mButtonsNumber = MAX_BUTTONS;
-
- mCalibrated = config.getValueBool("joystick"
- + toString(mNumber) + "calibrated", false);
- mUpTolerance = config.getIntValue("upTolerance" + toString(mNumber));
- mDownTolerance = config.getIntValue("downTolerance" + toString(mNumber));
- mLeftTolerance = config.getIntValue("leftTolerance" + toString(mNumber));
- mRightTolerance = config.getIntValue("rightTolerance" + toString(mNumber));
- mUseInactive = config.getBoolValue("useInactiveJoystick");
-
- return true;
-}
-
-void Joystick::close()
-{
- logger->log("close joystick %d", mNumber);
- if (mJoystick != nullptr)
- {
- SDL_JoystickClose(mJoystick);
- mJoystick = nullptr;
- }
-}
-
-void Joystick::reload()
-{
- joystickCount = SDL_NumJoysticks();
- setNumber(mNumber);
-}
-
-void Joystick::setNumber(const int n)
-{
- if (mJoystick != nullptr)
- {
- SDL_JoystickClose(mJoystick);
- mNumber = n;
- open();
- }
- else
- {
- mNumber = n;
- }
-}
-
-void Joystick::logic()
-{
- BLOCK_START("Joystick::logic")
- // When calibrating, don't bother the outside with our state
- if (mCalibrating)
- {
- doCalibration();
- BLOCK_END("Joystick::logic")
- return;
- };
-
- if (!mEnabled || !mCalibrated)
- {
- BLOCK_END("Joystick::logic")
- return;
- }
-
- mDirection = 0;
-
- if (mUseInactive ||
- settings.inputFocused != KeyboardFocus::Unfocused)
- {
- // X-Axis
- int position = SDL_JoystickGetAxis(mJoystick, 0);
- if (position >= mRightTolerance)
- mDirection |= RIGHT;
- else if (position <= mLeftTolerance)
- mDirection |= LEFT;
-
- // Y-Axis
- position = SDL_JoystickGetAxis(mJoystick, 1);
- if (position <= mUpTolerance)
- mDirection |= UP;
- else if (position >= mDownTolerance)
- mDirection |= DOWN;
-
-#ifdef DEBUG_JOYSTICK
- if (SDL_JoystickGetAxis(mJoystick, 2))
- logger->log("axis 2 pos: %d", SDL_JoystickGetAxis(mJoystick, 2));
- if (SDL_JoystickGetAxis(mJoystick, 3))
- logger->log("axis 3 pos: %d", SDL_JoystickGetAxis(mJoystick, 3));
- if (SDL_JoystickGetAxis(mJoystick, 4))
- logger->log("axis 4 pos: %d", SDL_JoystickGetAxis(mJoystick, 4));
-#endif // DEBUG_JOYSTICK
-
- if ((mDirection == 0u) && mHaveHats)
- {
- // reading only hat 0
- const uint8_t hat = SDL_JoystickGetHat(mJoystick, 0);
- if ((hat & SDL_HAT_RIGHT) != 0)
- mDirection |= RIGHT;
- else if ((hat & SDL_HAT_LEFT) != 0)
- mDirection |= LEFT;
- if ((hat & SDL_HAT_UP) != 0)
- mDirection |= UP;
- else if ((hat & SDL_HAT_DOWN) != 0)
- mDirection |= DOWN;
- }
-
- // Buttons
- for (int i = 0; i < mButtonsNumber; i++)
- {
- const bool state = (SDL_JoystickGetButton(mJoystick, i) == 1);
- mActiveButtons[i] = state;
- if (!state)
- resetRepeat(i);
-#ifdef DEBUG_JOYSTICK
- if (mActiveButtons[i])
- logger->log("button: %d", i);
-#endif // DEBUG_JOYSTICK
- }
- }
- else
- {
- for (int i = 0; i < mButtonsNumber; i++)
- mActiveButtons[i] = false;
- }
- BLOCK_END("Joystick::logic")
-}
-
-void Joystick::startCalibration()
-{
- mUpTolerance = 0;
- mDownTolerance = 0;
- mLeftTolerance = 0;
- mRightTolerance = 0;
- mCalibrating = true;
-}
-
-void Joystick::doCalibration()
-{
- // X-Axis
- int position = SDL_JoystickGetAxis(mJoystick, 0);
- if (position > mRightTolerance)
- mRightTolerance = position;
- else if (position < mLeftTolerance)
- mLeftTolerance = position;
-
- // Y-Axis
- position = SDL_JoystickGetAxis(mJoystick, 1);
- if (position > mDownTolerance)
- mDownTolerance = position;
- else if (position < mUpTolerance)
- mUpTolerance = position;
-}
-
-void Joystick::finishCalibration()
-{
- mCalibrated = true;
- mCalibrating = false;
- config.setValue("joystick" + toString(mNumber) + "calibrated", true);
- config.setValue("leftTolerance" + toString(mNumber), mLeftTolerance);
- config.setValue("rightTolerance" + toString(mNumber), mRightTolerance);
- config.setValue("upTolerance" + toString(mNumber), mUpTolerance);
- config.setValue("downTolerance" + toString(mNumber), mDownTolerance);
-}
-
-bool Joystick::buttonPressed(const unsigned char no) const
-{
- return (mEnabled && no < MAX_BUTTONS) ? mActiveButtons[no] : false;
-}
-
-void Joystick::getNames(STD_VECTOR <std::string> &names)
-{
- names.clear();
- for (int i = 0; i < joystickCount; i++)
- names.push_back(SDL_JoystickNameForIndex(i));
-}
-
-void Joystick::update()
-{
- inputManager.updateKeyActionMap(mKeyToAction, mKeyToId,
- mKeyTimeMap, InputType::JOYSTICK);
-}
-
-KeysVector *Joystick::getActionVector(const SDL_Event &event)
-{
- const int i = getButtonFromEvent(event);
-
- if (i < 0 || i >= mButtonsNumber)
- return nullptr;
-// logger->log("button triggerAction: %d", i);
- if (mKeyToAction.find(i) != mKeyToAction.end())
- return &mKeyToAction[i];
- return nullptr;
-}
-
-KeysVector *Joystick::getActionVectorByKey(const int i)
-{
- if (i < 0 || i >= mButtonsNumber)
- return nullptr;
-// logger->log("button triggerAction: %d", i);
- if (mKeyToAction.find(i) != mKeyToAction.end())
- return &mKeyToAction[i];
- return nullptr;
-}
-
-int Joystick::getButtonFromEvent(const SDL_Event &event) const
-{
- if (event.jbutton.which != mNumber)
- return -1;
- return event.jbutton.button;
-}
-
-bool Joystick::isActionActive(const InputActionT index) const
-{
- if (!validate())
- return false;
-
- const InputFunction &key = inputManager.getKey(index);
- for (size_t i = 0; i < inputFunctionSize; i ++)
- {
- const InputItem &val = key.values[i];
- if (val.type != InputType::JOYSTICK)
- continue;
- const int value = val.value;
- if (value >= 0 && value < mButtonsNumber)
- {
- if (mActiveButtons[value])
- return true;
- }
- }
- return false;
-}
-
-bool Joystick::validate() const
-{
- if (mCalibrating || !mEnabled || !mCalibrated)
- return false;
-
- return mUseInactive ||
- settings.inputFocused != KeyboardFocus::Unfocused;
-}
-
-void Joystick::handleRepeat(const int time)
-{
- BLOCK_START("Joystick::handleRepeat")
- FOR_EACH (KeyTimeMapIter, it, mKeyTimeMap)
- {
- bool repeat(false);
- const int key = (*it).first;
- if (key >= 0 && key < mButtonsNumber)
- {
- if (mActiveButtons[key])
- repeat = true;
- }
- if (repeat)
- {
- int &keyTime = (*it).second;
- if (time > keyTime && abs(time - keyTime)
- > SDL_DEFAULT_REPEAT_DELAY * 10)
- {
- keyTime = time;
- inputManager.triggerAction(getActionVectorByKey(key));
- }
- }
- }
- BLOCK_END("Joystick::handleRepeat")
-}
-
-void Joystick::resetRepeat(const int key)
-{
- const KeyTimeMapIter it = mKeyTimeMap.find(key);
- if (it != mKeyTimeMap.end())
- (*it).second = tick_time;
-}
diff --git a/src/input/joystick.h b/src/input/joystick.h
deleted file mode 100644
index cb4b7a78d..000000000
--- a/src/input/joystick.h
+++ /dev/null
@@ -1,175 +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 INPUT_JOYSTICK_H
-#define INPUT_JOYSTICK_H
-
-#include "events/inputevent.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_events.h>
-PRAGMA48(GCC diagnostic pop)
-
-class Joystick final
-{
- public:
- /**
- * Number of buttons we can handle.
- */
- enum
- {
- MAX_BUTTONS = 64
- };
-
- /**
- * Directions, to be used as bitmask values.
- */
- enum
- {
- UP = 1,
- DOWN = 2,
- LEFT = 4,
- RIGHT = 8
- };
-
- /**
- * Initializes the joystick subsystem.
- */
- static void init();
-
- /**
- * Returns the number of available joysticks.
- */
- static int getNumberOfJoysticks() A_WARN_UNUSED
- { return joystickCount; }
-
- /**
- * Constructor, pass the number of the joystick the new object
- * should access.
- */
- explicit Joystick(const int no);
-
- A_DELETE_COPY(Joystick)
-
- ~Joystick();
-
- bool open();
-
- void close();
-
- static bool isEnabled() A_WARN_UNUSED
- { return mEnabled; }
-
- void setNumber(const int n);
-
- constexpr2 static void setEnabled(const bool enabled) noexcept2
- { mEnabled = enabled; }
-
- static void getNames(STD_VECTOR <std::string> &names);
-
- /**
- * Updates the direction and button information.
- */
- void logic();
-
- void startCalibration();
-
- void finishCalibration();
-
- bool isCalibrating() const noexcept2 A_WARN_UNUSED
- { return mCalibrating; }
-
- bool buttonPressed(const unsigned char no) const A_WARN_UNUSED;
-
- bool isUp() const noexcept2 A_WARN_UNUSED
- { return mEnabled && ((mDirection & UP) != 0); }
-
- bool isDown() const noexcept2 A_WARN_UNUSED
- { return mEnabled && ((mDirection & DOWN) != 0); }
-
- bool isLeft() const noexcept2 A_WARN_UNUSED
- { return mEnabled && ((mDirection & LEFT) != 0); }
-
- bool isRight() const noexcept2 A_WARN_UNUSED
- { return mEnabled && ((mDirection & RIGHT) != 0); }
-
- int getNumber() const noexcept2 A_WARN_UNUSED
- { return mNumber; }
-
- void setUseInactive(const bool b)
- { mUseInactive = b; }
-
- void update();
-
- KeysVector *getActionVector(const SDL_Event &event) A_WARN_UNUSED;
-
- KeysVector *getActionVectorByKey(const int i) A_WARN_UNUSED;
-
- int getButtonFromEvent(const SDL_Event &event) const A_WARN_UNUSED;
-
- bool isActionActive(const InputActionT index) const A_WARN_UNUSED;
-
- bool validate() const A_WARN_UNUSED;
-
- void handleRepeat(const int time);
-
- void resetRepeat(const int key);
-
- void reload();
-
- protected:
- unsigned char mDirection;
-
- bool mActiveButtons[MAX_BUTTONS];
-
- SDL_Joystick *mJoystick;
-
- int mUpTolerance;
- int mDownTolerance;
- int mLeftTolerance;
- int mRightTolerance;
- bool mCalibrating;
- int mNumber;
- bool mCalibrated;
- int mButtonsNumber;
- bool mUseInactive;
- bool mHaveHats;
-
- KeyToActionMap mKeyToAction;
-
- KeyToIdMap mKeyToId;
-
- KeyTimeMap mKeyTimeMap;
-
- /**
- * Is joystick support enabled.
- */
- static bool mEnabled;
- static int joystickCount;
-
- void doCalibration();
-};
-
-extern Joystick *joystick;
-
-#endif // INPUT_JOYSTICK_H
diff --git a/src/input/key.cpp b/src/input/key.cpp
deleted file mode 100644
index 13646dc8e..000000000
--- a/src/input/key.cpp
+++ /dev/null
@@ -1,111 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * For comments regarding functions please see the header file.
- */
-
-#include "input/key.h"
-
-#include "debug.h"
-
-Key::Key(const int value) :
- mValue(value)
-{
-}
-
-bool Key::isCharacter() const
-{
- return (mValue >= 32 && mValue <= 126)
- || (mValue >= 162 && mValue <= 255)
- || (mValue == 9);
-}
-
-bool Key::isNumber() const
-{
- return mValue >= 48 && mValue <= 57;
-}
-
-bool Key::isLetter() const
-{
- return ((mValue >= 65 && mValue <= 90) ||
- (mValue >= 97 && mValue <= 122) ||
- (mValue >= 192 && mValue <= 255)) &&
- mValue != 215 &&
- mValue != 247;
-}
-
-int Key::getValue() const
-{
- return mValue;
-}
-
-bool Key::operator==(const Key& key) const
-{
- return mValue == key.mValue;
-}
-
-bool Key::operator!=(const Key& key) const
-{
- return mValue != key.mValue;
-}
diff --git a/src/input/key.h b/src/input/key.h
deleted file mode 100644
index 58c594f36..000000000
--- a/src/input/key.h
+++ /dev/null
@@ -1,147 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef INPUT_KEY_H
-#define INPUT_KEY_H
-
-#include "localconsts.h"
-
-// windows.h defines DELETE which breaks this file as we have a constant named
-// DELETE, hence we undefine DELETE if it is defined and hope people don't use
-// that windows define with Guichan.
-#if defined (_WIN32) && defined(DELETE)
-#undef DELETE
-#endif // defined (_WIN32) && defined(DELETE)
-
-/**
- * Represents a key or a character.
- */
-class Key final
-{
- public:
- /**
- * Constructor.
- *
- * @param value The ascii or enum value for the key.
- */
- explicit Key(const int value = 0);
-
- A_DEFAULT_COPY(Key)
-
- /**
- * Checks if a key is a character.
- *
- * @return True if the key is a letter, number or whitespace,
- * false otherwise.
- */
- bool isCharacter() const A_WARN_UNUSED;
-
- /**
- * Checks if a key is a number.
- *
- * @return True if the key is a number (0-9),
- * false otherwise.
- */
- bool isNumber() const A_WARN_UNUSED;
-
- /**
- * Checks if a key is a letter.
- *
- * @return True if the key is a letter (a-z,A-Z),
- * false otherwise.
- */
- bool isLetter() const A_WARN_UNUSED;
-
- /**
- * Gets the value of the key. If an ascii value exists it
- * will be returned. Otherwise an enum value will be returned.
- *
- * @return the value of the key.
- */
- int getValue() const A_WARN_UNUSED;
-
- /**
- * Compares two keys.
- *
- * @param key The key to compare this key with.
- * @return True if the keys are equal, false otherwise.
- */
- bool operator==(const Key& key) const;
-
- /**
- * Compares two keys.
- *
- * @param key The key to compare this key with.
- * @return True if the keys are not equal, false otherwise.
- */
- bool operator!=(const Key& key) const;
-
- protected:
- /**
- * Holds the value of the key. It may be an ascii value
- * or an enum value.
- */
- int mValue;
-};
-
-#endif // INPUT_KEY_H
diff --git a/src/input/keyboardconfig.cpp b/src/input/keyboardconfig.cpp
deleted file mode 100644
index c67fb5151..000000000
--- a/src/input/keyboardconfig.cpp
+++ /dev/null
@@ -1,307 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2007 Joshua Langley <joshlangley@optusnet.com.au>
- * 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 "input/keyboardconfig.h"
-
-#include "configuration.h"
-#ifdef USE_SDL2
-#include "settings.h"
-#endif // USE_SDL2
-
-#include "input/inputmanager.h"
-
-#include "utils/foreach.h"
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-extern volatile int tick_time;
-
-KeyboardConfig keyboard;
-
-KeyboardConfig::KeyboardConfig() :
- mEnabled(true),
- mActiveKeys(nullptr),
- mActiveKeys2(nullptr),
- mRepeatTime(0),
- mKeyToAction(),
- mKeyToId(),
- mKeyTimeMap(),
- mBlockAltTab(true)
-{
-}
-
-void KeyboardConfig::init()
-{
- mEnabled = true;
- delete [] mActiveKeys2;
- mActiveKeys2 = new uint8_t[500];
- mRepeatTime = config.getIntValue("repeateInterval2") / 10;
- mBlockAltTab = config.getBoolValue("blockAltTab");
-}
-
-void KeyboardConfig::deinit()
-{
- delete [] mActiveKeys2;
- mActiveKeys2 = nullptr;
-}
-
-InputActionT KeyboardConfig::getKeyIndex(const SDL_Event &event, const int grp)
-{
- const int keyValue = getKeyValueFromEvent(event);
- return inputManager.getKeyIndex(keyValue, grp, InputType::KEYBOARD);
-}
-
-void KeyboardConfig::refreshActiveKeys()
-{
- mActiveKeys = SDL_GetKeyState(nullptr);
-}
-
-std::string KeyboardConfig::getKeyName(const int key)
-{
- if (key == -1)
- return "";
- if (key > -1)
- {
-#ifdef USE_SDL2
- return SDL_GetKeyName(SDL_GetKeyFromScancode(
- static_cast<SDL_Scancode>(key)));
-#else // USE_SDL2
-
- return SDL_GetKeyName(static_cast<SDLKey>(key));
-#endif // USE_SDL2
- }
-
- // TRANSLATORS: long key name, should be short
- return strprintf(_("key_%d"), CAST_S32(key));
-}
-
-std::string KeyboardConfig::getKeyShortString(const std::string &key)
-{
- if (key == "backspace")
- return "bksp";
- else if (key == "numlock")
- return "numlock";
- else if (key == "caps lock")
- return "caplock";
- else if (key == "scroll lock")
- return "scrlock";
- else if (key == "right shift")
- return "rshift";
- else if (key == "left shift")
- return "lshift";
- else if (key == "right ctrl")
- return "rctrl";
- else if (key == "left ctrl")
- return "lctrl";
- else if (key == "right alt")
- return "ralt";
- else if (key == "left alt")
- return "lalt";
- else if (key == "right meta")
- return "rmeta";
- else if (key == "left meta")
- return "lmeta";
- else if (key == "right super")
- return "rsuper";
- else if (key == "left super")
- return "lsuper";
- else if (key == "print screen")
- return "print screen";
- else if (key == "page up")
- return "pg up";
- else if (key == "page down")
- return "pg down";
-
- if (key == "unknown key")
- {
- // TRANSLATORS: Unknown key short string.
- // TRANSLATORS: This string must be maximum 5 chars
- return _("u key");
- }
- return key;
-}
-
-KeysVector *KeyboardConfig::getActionVector(const SDL_Event &event)
-{
- const int i = getKeyValueFromEvent(event);
-// logger->log("key triggerAction: %d", i);
- if (i != 0 && i < SDLK_LAST && mKeyToAction.find(i) != mKeyToAction.end())
- return &mKeyToAction[i];
- return nullptr;
-}
-
-KeysVector *KeyboardConfig::getActionVectorByKey(const int i)
-{
-// logger->log("key triggerAction: %d", i);
- if (i != 0 && i < SDLK_LAST && mKeyToAction.find(i) != mKeyToAction.end())
- return &mKeyToAction[i];
- return nullptr;
-}
-
-InputActionT KeyboardConfig::getActionId(const SDL_Event &event)
-{
- const int i = getKeyValueFromEvent(event);
-// logger->log("getActionId: %d", i);
- if (i != 0 && i < SDLK_LAST && mKeyToId.find(i) != mKeyToId.end())
- return mKeyToId[i];
- return InputAction::NO_VALUE;
-}
-
-bool KeyboardConfig::isActionActive(const InputActionT index) const
-{
- if ((mActiveKeys == nullptr) || (mActiveKeys2 == nullptr))
- return false;
-
- const InputFunction &key = inputManager.getKey(index);
- for (size_t i = 0; i < inputFunctionSize; i ++)
- {
- const InputItem &val = key.values[i];
- if (val.type != InputType::KEYBOARD)
- continue;
-
- const int value = val.value;
- if (value >= 0)
- {
- if (mActiveKeys[value] != 0u)
- return true;
- }
- else if (value < -1 && value > -500)
- {
- if (mActiveKeys2[-value] != 0u)
- return true;
- }
- }
- return false;
-}
-
-void KeyboardConfig::update()
-{
- inputManager.updateKeyActionMap(mKeyToAction, mKeyToId,
- mKeyTimeMap, InputType::KEYBOARD);
-}
-
-void KeyboardConfig::handleActivateKey(const SDL_Event &event)
-{
- if (mActiveKeys2 == nullptr)
- return;
- const int key = getKeyValueFromEvent(event);
- if (key < -1 && key > -500)
- mActiveKeys2[-key] = 1;
- resetRepeat(key);
-}
-
-void KeyboardConfig::handleActivateKey(const int key)
-{
- if (mActiveKeys2 == nullptr)
- return;
- if (key < -1 && key > -500)
- mActiveKeys2[-key] = 1;
- resetRepeat(key);
-}
-
-void KeyboardConfig::handleDeActicateKey(const SDL_Event &event)
-{
- if (mActiveKeys2 == nullptr)
- return;
- const int key = getKeyValueFromEvent(event);
- if (key < -1 && key > -500)
- mActiveKeys2[-key] = 0;
- resetRepeat(key);
-}
-
-void KeyboardConfig::handleDeActicateKey(const int key)
-{
- if (mActiveKeys2 == nullptr)
- return;
- if (key < -1 && key > -500)
- mActiveKeys2[-key] = 0;
- resetRepeat(key);
-}
-
-void KeyboardConfig::handleRepeat(const int time)
-{
- BLOCK_START("KeyboardConfig::handleRepeat")
- FOR_EACH (KeyTimeMapIter, it, mKeyTimeMap)
- {
- bool repeat(false);
- const int key = (*it).first;
- if (key >= 0)
- {
- if ((mActiveKeys != nullptr) && (mActiveKeys[key] != 0u))
- repeat = true;
- }
- else if (key < -1 && key > -500)
- {
- if ((mActiveKeys2 != nullptr) && (mActiveKeys2[-key] != 0u))
- repeat = true;
- }
- if (repeat)
- {
- int &keyTime = (*it).second;
- if (time > keyTime && abs(time - keyTime)
- > CAST_S32(mRepeatTime))
- {
- keyTime = time;
- inputManager.triggerAction(getActionVectorByKey(key));
- }
- }
- }
- BLOCK_END("KeyboardConfig::handleRepeat")
-}
-
-void KeyboardConfig::resetRepeat(const int key)
-{
- const KeyTimeMapIter it = mKeyTimeMap.find(key);
- if (it != mKeyTimeMap.end())
- (*it).second = tick_time;
-}
-
-#ifdef USE_SDL2
-
-bool KeyboardConfig::ignoreKey(const SDL_Event &restrict event)
-{
- if (!mBlockAltTab ||
- mActiveKeys == nullptr)
- {
- return false;
- }
- const int key = event.key.keysym.scancode;
- if (key == SDL_SCANCODE_TAB)
- {
-#if SDL_VERSION_ATLEAST(2, 0, 5)
- // SDL_WINDOWEVENT_TAKE_FOCUS not triggered after focus restored
- if (settings.inputFocused != KeyboardFocus::Focused2)
- return true;
-#endif // SDL_VERSION_ATLEAST(2, 0, 5)
-
- if (mActiveKeys[SDL_SCANCODE_LALT] != 0)
- return true;
- }
- else if (key == SDL_SCANCODE_LALT)
- {
- if (mActiveKeys[SDL_SCANCODE_TAB] != 0)
- return true;
- }
- return false;
-}
-#endif // USE_SDL2
diff --git a/src/input/keyboardconfig.h b/src/input/keyboardconfig.h
deleted file mode 100644
index ef3f056b7..000000000
--- a/src/input/keyboardconfig.h
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2007 Joshua Langley <joshlangley@optusnet.com.au>
- * 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 INPUT_KEYBOARDCONFIG_H
-#define INPUT_KEYBOARDCONFIG_H
-
-#include "localconsts.h"
-
-#ifndef USE_SDL2
-#include "utils/cast.h"
-#endif // USE_SDL2
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_events.h>
-PRAGMA48(GCC diagnostic pop)
-
-#include "sdlshared.h"
-
-#include "events/inputevent.h"
-
-class KeyboardConfig final
-{
- public:
- KeyboardConfig();
-
- A_DELETE_COPY(KeyboardConfig)
-
- /**
- * Initializes the keyboard config explicitly.
- */
- void init();
-
- void deinit();
-
- /**
- * Get the enable flag, which will stop the user from doing actions.
- */
- bool isEnabled() const noexcept2 A_WARN_UNUSED
- { return mEnabled; }
-
- /**
- * Get the key function index by providing the keys value.
- */
- static InputActionT getKeyIndex(const SDL_Event &event,
- const int grp = 1) A_WARN_UNUSED;
-
- /**
- * Set the enable flag, which will stop the user from doing actions.
- */
- void setEnabled(const bool flag)
- { mEnabled = flag; }
-
- /**
- * Takes a snapshot of all the active keys.
- */
- void refreshActiveKeys();
-
- static std::string getKeyShortString(const std::string &key)
- A_WARN_UNUSED;
-
- constexpr static SDLKey getKeyFromEvent(const SDL_Event &event)
- A_WARN_UNUSED
- {
-#ifdef USE_SDL2
- return event.key.keysym.scancode;
-#else // USE_SDL2
-
- return event.key.keysym.sym;
-#endif // USE_SDL2
- }
-
- constexpr2 static int getKeyValueFromEvent(const SDL_Event &event)
- A_WARN_UNUSED
- {
-#ifdef USE_SDL2
- return event.key.keysym.scancode;
-#else // USE_SDL2
-
- if (event.key.keysym.sym != 0u)
- return CAST_S32(event.key.keysym.sym);
- else if (event.key.keysym.scancode > 1)
- return -event.key.keysym.scancode;
- return 0;
-#endif // USE_SDL2
- }
-
-
- KeysVector *getActionVector(const SDL_Event &event) A_WARN_UNUSED;
-
- KeysVector *getActionVectorByKey(const int i) A_WARN_UNUSED;
-
- static std::string getKeyName(const int key) A_WARN_UNUSED;
-
- bool isActionActive(const InputActionT index) const A_WARN_UNUSED;
-
- void update();
-
- void handleActivateKey(const SDL_Event &event);
-
- void handleActivateKey(const int key);
-
- void handleDeActicateKey(const SDL_Event &event);
-
- void handleDeActicateKey(const int key);
-
- InputActionT getActionId(const SDL_Event &event) A_WARN_UNUSED;
-
- void handleRepeat(const int time);
-
- void resetRepeat(const int key);
-
-#ifdef USE_SDL2
- bool ignoreKey(const SDL_Event &restrict event) A_WARN_UNUSED;
-#endif // USE_SDL2
-
- private:
- bool mEnabled; /**< Flag to respond to key input */
-
- const uint8_t *mActiveKeys; /**< Stores a list of all the keys */
-
- uint8_t *mActiveKeys2; /**< Stores a list of all the keys */
-
- unsigned int mRepeatTime;
-
- KeyToActionMap mKeyToAction;
-
- KeyToIdMap mKeyToId;
-
- KeyTimeMap mKeyTimeMap;
-
- bool mBlockAltTab;
-};
-
-extern KeyboardConfig keyboard;
-
-#endif // INPUT_KEYBOARDCONFIG_H
diff --git a/src/input/keyinput.h b/src/input/keyinput.h
deleted file mode 100644
index 28262b861..000000000
--- a/src/input/keyinput.h
+++ /dev/null
@@ -1,177 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef INPUT_KEYINPUT_H
-#define INPUT_KEYINPUT_H
-
-#include "enums/events/keyeventtype.h"
-
-#include "enums/input/inputaction.h"
-
-#include "input/key.h"
-
-#ifdef USE_SDL2
-#include <string>
-#endif // USE_SDL2
-
-#include "localconsts.h"
-
-class KeyInput final
-{
- public:
- KeyInput() :
- mKey(0),
- mType(KeyEventType::PRESSED),
-#ifdef USE_SDL2
- mText(),
-#endif // USE_SDL2
- mActionId(InputAction::UNDEFINED_VALUE)
- { }
-
- KeyInput(const KeyInput &k) :
- mKey(k.mKey),
- mType(k.mType),
-#ifdef USE_SDL2
- mText(k.mText),
-#endif // USE_SDL2
- mActionId(k.mActionId)
- {
- }
-
- A_DEFAULT_COPY(KeyInput)
-
- KeyInput &operator=(const KeyInput &k) noexcept2
- {
- mKey = k.mKey;
- mType = k.mType;
-#ifdef USE_SDL2
- mText = k.mText;
-#endif // USE_SDL2
- mActionId = k.mActionId;
- return *this;
- }
-
- ~KeyInput()
- { }
-
- void setType(KeyEventTypeT type) noexcept2
- {
- mType = type;
- }
-
- KeyEventTypeT getType() const noexcept2 A_WARN_UNUSED
- {
- return mType;
- }
-
- void setKey(const Key& key) noexcept2
- {
- mKey = key;
- }
-
- const Key& getKey() const noexcept2
- {
- return mKey;
- }
-
- void setActionId(const InputActionT n) noexcept2
- {
- mActionId = n;
- }
-
- InputActionT getActionId() const noexcept2 A_WARN_UNUSED
- {
- return mActionId;
- }
-
-#ifdef USE_SDL2
- void setText(const std::string &text) noexcept2
- {
- mText = text;
- }
-
- std::string getText() const noexcept2
- {
- return mText;
- }
-#endif // USE_SDL2
-
- protected:
- /**
- * Holds the key of the key input.
- */
- Key mKey;
-
- /**
- * Holds the type of the key input.
- */
- KeyEventTypeT mType;
-
-#ifdef USE_SDL2
- std::string mText;
-#endif // USE_SDL2
-
- InputActionT mActionId;
-};
-
-#endif // INPUT_KEYINPUT_H
diff --git a/src/input/mouseinput.h b/src/input/mouseinput.h
deleted file mode 100644
index 2e3a5f58e..000000000
--- a/src/input/mouseinput.h
+++ /dev/null
@@ -1,219 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef INPUT_MOUSEINPUT_H
-#define INPUT_MOUSEINPUT_H
-
-#include "enums/events/mousebutton.h"
-#include "enums/events/mouseeventtype.h"
-
-#include "localconsts.h"
-
-class MouseInput final
-{
- public:
- MouseInput() :
- mType(MouseEventType::MOVED),
- mButton(MouseButton::EMPTY),
- mTimeStamp(0),
- mX(0),
- mY(0),
- mRealX(0),
- mRealY(0)
- { }
-
- MouseInput(const MouseInput &m) :
- mType(m.mType),
- mButton(m.mButton),
- mTimeStamp(m.mTimeStamp),
- mX(m.mX),
- mY(m.mY),
- mRealX(m.mRealX),
- mRealY(m.mRealY)
- {
- }
-
- A_DEFAULT_COPY(MouseInput)
-
- MouseInput &operator=(const MouseInput &m)
- {
- mType = m.mType;
- mButton = m.mButton;
- mTimeStamp = m.mTimeStamp;
- mX = m.mX;
- mY = m.mY;
- mRealX = m.mRealX;
- mRealY = m.mRealY;
- return *this;
- }
-
- ~MouseInput()
- { }
-
- void setType(MouseEventTypeT type) noexcept2
- {
- mType = type;
- }
-
- MouseEventTypeT getType() const noexcept2
- {
- return mType;
- }
-
- void setButton(MouseButtonT button) noexcept2
- {
- mButton = button;
- }
-
- MouseButtonT getButton() const noexcept2
- {
- return mButton;
- }
-
- int getTimeStamp() const noexcept2
- {
- return mTimeStamp;
- }
-
- void setTimeStamp(int timeStamp) noexcept2
- {
- mTimeStamp = timeStamp;
- }
-
- void setX(int x) noexcept2
- {
- mX = x;
- }
-
- int getX() const noexcept2
- {
- return mX;
- }
-
- void setY(int y) noexcept2
- {
- mY = y;
- }
-
- int getY() const noexcept2
- {
- return mY;
- }
-
- void setReal(const int x, const int y) noexcept2
- { mRealX = x; mRealY = y; }
-
- int getRealX() const noexcept2 A_WARN_UNUSED
- { return mRealX; }
-
- int getRealY() const noexcept2 A_WARN_UNUSED
- { return mRealY; }
-
-#ifdef ANDROID
- int getTouchX() const noexcept2 A_WARN_UNUSED
- { return mRealX; }
-
- int getTouchY() const noexcept2 A_WARN_UNUSED
- { return mRealY; }
-#else // ANDROID
-
- int getTouchX() const noexcept2 A_WARN_UNUSED
- { return mX; }
-
- int getTouchY() const noexcept2 A_WARN_UNUSED
- { return mY; }
-#endif // ANDROID
-
- protected:
- /**
- * Holds the type of the mouse input.
- */
- MouseEventTypeT mType;
-
- /**
- * Holds the button of the mouse input.
- */
- MouseButtonT mButton;
-
- /**
- * Holds the timestamp of the mouse input. Used to
- * check for double clicks.
- */
- int mTimeStamp;
-
- /**
- * Holds the x coordinate of the mouse input.
- */
- int mX;
-
- /**
- * Holds the y coordinate of the mouse input.
- */
- int mY;
-
- int mRealX;
-
- int mRealY;
-};
-
-#endif // INPUT_MOUSEINPUT_H
diff --git a/src/input/pages/basic.cpp b/src/input/pages/basic.cpp
deleted file mode 100644
index ad4ad2c6f..000000000
--- a/src/input/pages/basic.cpp
+++ /dev/null
@@ -1,271 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2007 Joshua Langley <joshlangley@optusnet.com.au>
- * 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 "gui/setupactiondata.h"
-
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-SetupActionData setupActionDataBasic[] =
-{
- {
- // TRANSLATORS: input action name
- N_("Target and attack keys"),
- InputAction::NO_VALUE,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Attack"),
- InputAction::ATTACK,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Target & attack closest monster"),
- InputAction::TARGET_ATTACK,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Target & attack closest player"),
- InputAction::ATTACK_HUMAN,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Move to Target"),
- InputAction::MOVE_TO_TARGET,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Change Move to Target type"),
- InputAction::CHANGE_MOVE_TO_TARGET,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Move to Home location"),
- InputAction::MOVE_TO_HOME,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Set home location"),
- InputAction::SET_HOME,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Move to navigation point"),
- InputAction::MOVE_TO_POINT,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Talk"),
- InputAction::TALK,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Stop Attack / Modifier key"),
- InputAction::STOP_ATTACK,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Untarget"),
- InputAction::UNTARGET,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Target monster"),
- InputAction::TARGET_MONSTER,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Target closest monster (without filters)"),
- InputAction::TARGET_CLOSEST_MONSTER,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Target NPC"),
- InputAction::TARGET_NPC,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Target Player"),
- InputAction::TARGET_PLAYER,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Target mercenary"),
- InputAction::TARGET_MERCENARY,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Target skill unit"),
- InputAction::TARGET_SKILL_UNIT,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Change targeting type"),
- InputAction::CHANGE_TARGETING_TYPE,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Target pet"),
- InputAction::TARGET_PET,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Catch pet"),
- InputAction::CATCH_PET,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Other Keys"),
- InputAction::NO_VALUE,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Pickup"),
- InputAction::PICKUP,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Change Pickup Type"),
- InputAction::CHANGE_PICKUP_TYPE,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Sit"),
- InputAction::SIT,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Screenshot"),
- InputAction::SCREENSHOT,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Enable/Disable Trading"),
- InputAction::CHANGE_TRADE,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Open trade window"),
- InputAction::OPEN_TRADE,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Start trade with target"),
- InputAction::TRADE,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Follow selected player"),
- InputAction::FOLLOW,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Change Map View Mode"),
- InputAction::PATHFIND,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Select OK"),
- InputAction::OK,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Quit"),
- InputAction::QUIT,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Stop or sit"),
- InputAction::STOP_SIT,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Return to safe video mode"),
- InputAction::SAFE_VIDEO,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Fire your homunculus"),
- InputAction::HOMUNCULUS_FIRE,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Buy"),
- InputAction::BUY,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Sell"),
- InputAction::SELL,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Open context menu"),
- InputAction::CONTEXT_MENU,
- "",
- },
- {
- "",
- InputAction::NO_VALUE,
- ""
- }
-};
diff --git a/src/input/pages/basic.h b/src/input/pages/basic.h
deleted file mode 100644
index 5cfe3af53..000000000
--- a/src/input/pages/basic.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2007 Joshua Langley <joshlangley@optusnet.com.au>
- * 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 INPUT_PAGES_BASIC_H
-#define INPUT_PAGES_BASIC_H
-
-#include "gui/setupactiondata.h"
-
-extern SetupActionData setupActionDataBasic[];
-
-#endif // INPUT_PAGES_BASIC_H
diff --git a/src/input/pages/chat.cpp b/src/input/pages/chat.cpp
deleted file mode 100644
index c8abfc9ca..000000000
--- a/src/input/pages/chat.cpp
+++ /dev/null
@@ -1,251 +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 "gui/setupactiondata.h"
-
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-SetupActionData setupActionDataChat[] =
-{
- {
- // TRANSLATORS: input action group
- N_("Main"),
- InputAction::NO_VALUE,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Toggle Chat"),
- InputAction::TOGGLE_CHAT,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Chat modifier key"),
- InputAction::CHAT_MOD,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Scroll Chat Up"),
- InputAction::SCROLL_CHAT_UP,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Scroll Chat Down"),
- InputAction::SCROLL_CHAT_DOWN,
- "",
- },
- {
- // TRANSLATORS: input action group
- N_("Tabs"),
- InputAction::NO_VALUE,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Previous Chat Tab"),
- InputAction::PREV_CHAT_TAB,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Next Chat Tab"),
- InputAction::NEXT_CHAT_TAB,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Clear current chat tab"),
- InputAction::CLEAR_CHAT_TAB,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Close current Chat Tab"),
- InputAction::CLOSE_CHAT_TAB,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Close all chat tabs"),
- InputAction::CLOSE_ALL_CHAT_TABS,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Select general tab"),
- InputAction::CHAT_GENERAL_TAB,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Select debug tab"),
- InputAction::CHAT_DEBUG_TAB,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Select trade tab"),
- InputAction::CHAT_TRADE_TAB,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Select battle tab"),
- InputAction::CHAT_BATTLE_TAB,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Select gm tab"),
- InputAction::CHAT_GM_TAB,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Select lang tab"),
- InputAction::CHAT_LANG_TAB,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Select party tab"),
- InputAction::CHAT_PARTY_TAB,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Select guild tab"),
- InputAction::CHAT_GUILD_TAB,
- "",
- },
- {
- // TRANSLATORS: input action group
- N_("Other"),
- InputAction::NO_VALUE,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Ignore all whispers"),
- InputAction::IGNORE_ALL_WHISPERS,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Ignore all whispers on server side"),
- InputAction::SERVER_IGNORE_ALL,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Unignore all whispers on server side"),
- InputAction::SERVER_UNIGNORE_ALL,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Previous chat line"),
- InputAction::CHAT_PREV_HISTORY,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Next chat line"),
- InputAction::CHAT_NEXT_HISTORY,
- "",
- },
- {
- // TRANSLATORS: input action group
- N_("Smiles"),
- InputAction::NO_VALUE,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Show smiles"),
- InputAction::GUI_F1,
- "",
- },
- {
- "F2",
- InputAction::GUI_F2,
- "",
- },
- {
- "F3",
- InputAction::GUI_F3,
- "",
- },
- {
- "F4",
- InputAction::GUI_F4,
- "",
- },
- {
- "F5",
- InputAction::GUI_F5,
- "",
- },
- {
- "F6",
- InputAction::GUI_F6,
- "",
- },
- {
- "F7",
- InputAction::GUI_F7,
- "",
- },
- {
- "F8",
- InputAction::GUI_F8,
- "",
- },
- {
- "F9",
- InputAction::GUI_F9,
- "",
- },
- {
- "F10",
- InputAction::GUI_F10,
- "",
- },
- {
- "F11",
- InputAction::GUI_F11,
- "",
- },
- {
- "F12",
- InputAction::GUI_F12,
- "",
- },
- {
- "",
- InputAction::NO_VALUE,
- ""
- }
-};
diff --git a/src/input/pages/chat.h b/src/input/pages/chat.h
deleted file mode 100644
index 2f4cf147b..000000000
--- a/src/input/pages/chat.h
+++ /dev/null
@@ -1,28 +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 INPUT_PAGES_CHAT_H
-#define INPUT_PAGES_CHAT_H
-
-#include "gui/setupactiondata.h"
-
-extern SetupActionData setupActionDataChat[];
-
-#endif // INPUT_PAGES_CHAT_H
diff --git a/src/input/pages/craft.cpp b/src/input/pages/craft.cpp
deleted file mode 100644
index fe93a0c1e..000000000
--- a/src/input/pages/craft.cpp
+++ /dev/null
@@ -1,89 +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 "gui/setupactiondata.h"
-
-#include "utils/gettext.h"
-#include "utils/stringutils.h"
-
-#include "debug.h"
-
-SetupActionData setupActionDataCraft[] =
-{
- {
- // TRANSLATORS: input action name
- strprintf(N_("Craft shortcut %d"), 1),
- InputAction::CRAFT_1,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Craft shortcut %d"), 2),
- InputAction::CRAFT_2,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Craft shortcut %d"), 3),
- InputAction::CRAFT_3,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Craft shortcut %d"), 4),
- InputAction::CRAFT_4,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Craft shortcut %d"), 5),
- InputAction::CRAFT_5,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Craft shortcut %d"), 6),
- InputAction::CRAFT_6,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Craft shortcut %d"), 7),
- InputAction::CRAFT_7,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Craft shortcut %d"), 8),
- InputAction::CRAFT_8,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Craft shortcut %d"), 9),
- InputAction::CRAFT_9,
- "",
- },
- {
- "",
- InputAction::NO_VALUE,
- ""
- },
-};
diff --git a/src/input/pages/craft.h b/src/input/pages/craft.h
deleted file mode 100644
index d69425c63..000000000
--- a/src/input/pages/craft.h
+++ /dev/null
@@ -1,28 +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 INPUT_PAGES_CRAFT_H
-#define INPUT_PAGES_CRAFT_H
-
-#include "gui/setupactiondata.h"
-
-extern SetupActionData setupActionDataCraft[];
-
-#endif // INPUT_PAGES_CRAFT_H
diff --git a/src/input/pages/emotes.cpp b/src/input/pages/emotes.cpp
deleted file mode 100644
index 84537771d..000000000
--- a/src/input/pages/emotes.cpp
+++ /dev/null
@@ -1,655 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2007 Joshua Langley <joshlangley@optusnet.com.au>
- * 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 "gui/setupactiondata.h"
-
-#include "utils/gettext.h"
-#include "utils/stringutils.h"
-
-#include "debug.h"
-
-SetupActionData setupActionDataEmotes[] =
-{
- {
- // TRANSLATORS: input action name
- N_("Emote modifiers keys"),
- InputAction::NO_VALUE,
- ""
- },
- {
- // TRANSLATORS: input action name
- N_("Emote modifier key"),
- InputAction::EMOTE,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Pet emote modifier key"),
- InputAction::PET_EMOTE,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Homunculus / mercenary emote modifier key"),
- InputAction::HOMUN_EMOTE,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Emote shortcuts"),
- InputAction::NO_VALUE,
- ""
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Emote Shortcut %d"), 1),
- InputAction::EMOTE_1,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Emote Shortcut %d"), 2),
- InputAction::EMOTE_2,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Emote Shortcut %d"), 3),
- InputAction::EMOTE_3,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Emote Shortcut %d"), 4),
- InputAction::EMOTE_4,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Emote Shortcut %d"), 5),
- InputAction::EMOTE_5,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Emote Shortcut %d"), 6),
- InputAction::EMOTE_6,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Emote Shortcut %d"), 7),
- InputAction::EMOTE_7,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Emote Shortcut %d"), 8),
- InputAction::EMOTE_8,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Emote Shortcut %d"), 9),
- InputAction::EMOTE_9,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Emote Shortcut %d"), 10),
- InputAction::EMOTE_10,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Emote Shortcut %d"), 11),
- InputAction::EMOTE_11,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Emote Shortcut %d"), 12),
- InputAction::EMOTE_12,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Emote Shortcut %d"), 13),
- InputAction::EMOTE_13,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Emote Shortcut %d"), 14),
- InputAction::EMOTE_14,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Emote Shortcut %d"), 15),
- InputAction::EMOTE_15,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Emote Shortcut %d"), 16),
- InputAction::EMOTE_16,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Emote Shortcut %d"), 17),
- InputAction::EMOTE_17,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Emote Shortcut %d"), 18),
- InputAction::EMOTE_18,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Emote Shortcut %d"), 19),
- InputAction::EMOTE_19,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Emote Shortcut %d"), 20),
- InputAction::EMOTE_20,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Emote Shortcut %d"), 21),
- InputAction::EMOTE_21,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Emote Shortcut %d"), 22),
- InputAction::EMOTE_22,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Emote Shortcut %d"), 23),
- InputAction::EMOTE_23,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Emote Shortcut %d"), 24),
- InputAction::EMOTE_24,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Emote Shortcut %d"), 25),
- InputAction::EMOTE_25,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Emote Shortcut %d"), 26),
- InputAction::EMOTE_26,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Emote Shortcut %d"), 27),
- InputAction::EMOTE_27,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Emote Shortcut %d"), 28),
- InputAction::EMOTE_28,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Emote Shortcut %d"), 29),
- InputAction::EMOTE_29,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Emote Shortcut %d"), 30),
- InputAction::EMOTE_30,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Emote Shortcut %d"), 31),
- InputAction::EMOTE_31,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Emote Shortcut %d"), 32),
- InputAction::EMOTE_32,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Emote Shortcut %d"), 33),
- InputAction::EMOTE_33,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Emote Shortcut %d"), 34),
- InputAction::EMOTE_34,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Emote Shortcut %d"), 35),
- InputAction::EMOTE_35,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Emote Shortcut %d"), 36),
- InputAction::EMOTE_36,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Emote Shortcut %d"), 37),
- InputAction::EMOTE_37,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Emote Shortcut %d"), 38),
- InputAction::EMOTE_38,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Emote Shortcut %d"), 39),
- InputAction::EMOTE_39,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Emote Shortcut %d"), 40),
- InputAction::EMOTE_40,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Emote Shortcut %d"), 41),
- InputAction::EMOTE_41,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Emote Shortcut %d"), 42),
- InputAction::EMOTE_42,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Emote Shortcut %d"), 43),
- InputAction::EMOTE_43,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Emote Shortcut %d"), 44),
- InputAction::EMOTE_44,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Emote Shortcut %d"), 45),
- InputAction::EMOTE_45,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Emote Shortcut %d"), 46),
- InputAction::EMOTE_46,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Emote Shortcut %d"), 47),
- InputAction::EMOTE_47,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Emote Shortcut %d"), 48),
- InputAction::EMOTE_48,
- "",
- },
- {
- "",
- InputAction::NO_VALUE,
- ""
- },
- {
- // TRANSLATORS: input action name
- N_("Pet emote shortcuts"),
- InputAction::NO_VALUE,
- ""
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Pet emote shortcut %d"), 1),
- InputAction::PET_EMOTE_1,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Pet emote shortcut %d"), 2),
- InputAction::PET_EMOTE_2,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Pet emote shortcut %d"), 3),
- InputAction::PET_EMOTE_3,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Pet emote shortcut %d"), 4),
- InputAction::PET_EMOTE_4,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Pet emote shortcut %d"), 5),
- InputAction::PET_EMOTE_5,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Pet emote shortcut %d"), 6),
- InputAction::PET_EMOTE_6,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Pet emote shortcut %d"), 7),
- InputAction::PET_EMOTE_7,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Pet emote shortcut %d"), 8),
- InputAction::PET_EMOTE_8,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Pet emote shortcut %d"), 9),
- InputAction::PET_EMOTE_9,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Pet emote shortcut %d"), 10),
- InputAction::PET_EMOTE_10,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Pet emote shortcut %d"), 11),
- InputAction::PET_EMOTE_11,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Pet emote shortcut %d"), 12),
- InputAction::PET_EMOTE_12,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Pet emote shortcut %d"), 13),
- InputAction::PET_EMOTE_13,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Pet emote shortcut %d"), 14),
- InputAction::PET_EMOTE_14,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Pet emote shortcut %d"), 15),
- InputAction::PET_EMOTE_15,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Pet emote shortcut %d"), 16),
- InputAction::PET_EMOTE_16,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Pet emote shortcut %d"), 17),
- InputAction::PET_EMOTE_17,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Pet emote shortcut %d"), 18),
- InputAction::PET_EMOTE_18,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Pet emote shortcut %d"), 19),
- InputAction::PET_EMOTE_19,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Pet emote shortcut %d"), 20),
- InputAction::PET_EMOTE_20,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Pet emote shortcut %d"), 21),
- InputAction::PET_EMOTE_21,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Pet emote shortcut %d"), 22),
- InputAction::PET_EMOTE_22,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Pet emote shortcut %d"), 23),
- InputAction::PET_EMOTE_23,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Pet emote shortcut %d"), 24),
- InputAction::PET_EMOTE_24,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Pet emote shortcut %d"), 25),
- InputAction::PET_EMOTE_25,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Pet emote shortcut %d"), 26),
- InputAction::PET_EMOTE_26,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Pet emote shortcut %d"), 27),
- InputAction::PET_EMOTE_27,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Pet emote shortcut %d"), 28),
- InputAction::PET_EMOTE_28,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Pet emote shortcut %d"), 29),
- InputAction::PET_EMOTE_29,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Pet emote shortcut %d"), 30),
- InputAction::PET_EMOTE_30,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Pet emote shortcut %d"), 31),
- InputAction::PET_EMOTE_31,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Pet emote shortcut %d"), 32),
- InputAction::PET_EMOTE_32,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Pet emote shortcut %d"), 33),
- InputAction::PET_EMOTE_33,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Pet emote shortcut %d"), 34),
- InputAction::PET_EMOTE_34,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Pet emote shortcut %d"), 35),
- InputAction::PET_EMOTE_35,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Pet emote shortcut %d"), 36),
- InputAction::PET_EMOTE_36,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Pet emote shortcut %d"), 37),
- InputAction::PET_EMOTE_37,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Pet emote shortcut %d"), 38),
- InputAction::PET_EMOTE_38,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Pet emote shortcut %d"), 39),
- InputAction::PET_EMOTE_39,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Pet emote shortcut %d"), 40),
- InputAction::PET_EMOTE_40,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Pet emote shortcut %d"), 41),
- InputAction::PET_EMOTE_41,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Pet emote shortcut %d"), 42),
- InputAction::PET_EMOTE_42,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Pet emote shortcut %d"), 43),
- InputAction::PET_EMOTE_43,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Pet emote shortcut %d"), 44),
- InputAction::PET_EMOTE_44,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Pet emote shortcut %d"), 45),
- InputAction::PET_EMOTE_45,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Pet emote shortcut %d"), 46),
- InputAction::PET_EMOTE_46,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Pet emote shortcut %d"), 47),
- InputAction::PET_EMOTE_47,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Pet emote shortcut %d"), 48),
- InputAction::PET_EMOTE_48,
- "",
- },
- {
- "",
- InputAction::NO_VALUE,
- ""
- },
-};
diff --git a/src/input/pages/emotes.h b/src/input/pages/emotes.h
deleted file mode 100644
index e0a5ee452..000000000
--- a/src/input/pages/emotes.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2007 Joshua Langley <joshlangley@optusnet.com.au>
- * 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 INPUT_PAGES_EMOTES_H
-#define INPUT_PAGES_EMOTES_H
-
-#include "gui/setupactiondata.h"
-
-extern SetupActionData setupActionDataEmotes[];
-
-#endif // INPUT_PAGES_EMOTES_H
diff --git a/src/input/pages/gui.cpp b/src/input/pages/gui.cpp
deleted file mode 100644
index d09aa6f35..000000000
--- a/src/input/pages/gui.cpp
+++ /dev/null
@@ -1,198 +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 "gui/setupactiondata.h"
-
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-SetupActionData setupActionDataGui[] =
-{
- {
- // TRANSLATORS: input action name
- N_("Move & selection"),
- InputAction::NO_VALUE,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Move Up"),
- InputAction::GUI_UP,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Move Down"),
- InputAction::GUI_DOWN,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Move Left"),
- InputAction::GUI_LEFT,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Move Right"),
- InputAction::GUI_RIGHT,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Move Home"),
- InputAction::GUI_HOME,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Move End"),
- InputAction::GUI_END,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Page up"),
- InputAction::GUI_PAGE_UP,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Page down"),
- InputAction::GUI_PAGE_DOWN,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Other"),
- InputAction::NO_VALUE,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Select"),
- InputAction::GUI_SELECT,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Select2"),
- InputAction::GUI_SELECT2,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Cancel"),
- InputAction::GUI_CANCEL,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Delete"),
- InputAction::GUI_DELETE,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Backspace"),
- InputAction::GUI_BACKSPACE,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Insert"),
- InputAction::GUI_INSERT,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Tab"),
- InputAction::GUI_TAB,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Mod"),
- InputAction::GUI_MOD,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Ctrl"),
- InputAction::GUI_CTRL,
- "",
- },
- {
- "B",
- InputAction::GUI_B,
- "",
- },
- {
- "C",
- InputAction::GUI_C,
- "",
- },
- {
- "D",
- InputAction::GUI_D,
- "",
- },
- {
- "E",
- InputAction::GUI_E,
- "",
- },
- {
- "F",
- InputAction::GUI_F,
- "",
- },
- {
- "H",
- InputAction::GUI_H,
- "",
- },
- {
- "K",
- InputAction::GUI_K,
- "",
- },
- {
- "U",
- InputAction::GUI_U,
- "",
- },
- {
- "V",
- InputAction::GUI_V,
- "",
- },
- {
- "W",
- InputAction::GUI_W,
- "",
- },
- {
- "",
- InputAction::NO_VALUE,
- ""
- }
-};
diff --git a/src/input/pages/gui.h b/src/input/pages/gui.h
deleted file mode 100644
index 5c72fca13..000000000
--- a/src/input/pages/gui.h
+++ /dev/null
@@ -1,28 +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 INPUT_PAGES_GUI_H
-#define INPUT_PAGES_GUI_H
-
-#include "gui/setupactiondata.h"
-
-extern SetupActionData setupActionDataGui[];
-
-#endif // INPUT_PAGES_GUI_H
diff --git a/src/input/pages/move.cpp b/src/input/pages/move.cpp
deleted file mode 100644
index 8df8a2c5d..000000000
--- a/src/input/pages/move.cpp
+++ /dev/null
@@ -1,404 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2007 Joshua Langley <joshlangley@optusnet.com.au>
- * 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 "gui/setupactiondata.h"
-
-#include "utils/gettext.h"
-#include "utils/stringutils.h"
-
-#include "debug.h"
-
-SetupActionData setupActionDataMove[] =
-{
- {
- // TRANSLATORS: input action name
- N_("Move Keys"),
- InputAction::NO_VALUE,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Move player up"),
- InputAction::MOVE_UP,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Move player down"),
- InputAction::MOVE_DOWN,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Move player left"),
- InputAction::MOVE_LEFT,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Move player right"),
- InputAction::MOVE_RIGHT,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Move player forward"),
- InputAction::MOVE_FORWARD,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Move pet up"),
- InputAction::PET_MOVE_UP,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Move pet down"),
- InputAction::PET_MOVE_DOWN,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Move pet left"),
- InputAction::PET_MOVE_LEFT,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Move pet right"),
- InputAction::PET_MOVE_RIGHT,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Move homunculus to master"),
- InputAction::HOMUNCULUS_TO_MASTER,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Move mercenary to master"),
- InputAction::MERCENARY_TO_MASTER,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Move to navigation point shortcuts"),
- InputAction::NO_VALUE,
- ""
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Move to point Shortcut %d"), 1),
- InputAction::MOVE_TO_POINT_1,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Move to point Shortcut %d"), 2),
- InputAction::MOVE_TO_POINT_2,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Move to point Shortcut %d"), 3),
- InputAction::MOVE_TO_POINT_3,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Move to point Shortcut %d"), 4),
- InputAction::MOVE_TO_POINT_4,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Move to point Shortcut %d"), 5),
- InputAction::MOVE_TO_POINT_5,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Move to point Shortcut %d"), 6),
- InputAction::MOVE_TO_POINT_6,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Move to point Shortcut %d"), 7),
- InputAction::MOVE_TO_POINT_7,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Move to point Shortcut %d"), 8),
- InputAction::MOVE_TO_POINT_8,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Move to point Shortcut %d"), 9),
- InputAction::MOVE_TO_POINT_9,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Move to point Shortcut %d"), 10),
- InputAction::MOVE_TO_POINT_10,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Move to point Shortcut %d"), 11),
- InputAction::MOVE_TO_POINT_11,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Move to point Shortcut %d"), 12),
- InputAction::MOVE_TO_POINT_12,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Move to point Shortcut %d"), 13),
- InputAction::MOVE_TO_POINT_13,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Move to point Shortcut %d"), 14),
- InputAction::MOVE_TO_POINT_14,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Move to point Shortcut %d"), 15),
- InputAction::MOVE_TO_POINT_15,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Move to point Shortcut %d"), 16),
- InputAction::MOVE_TO_POINT_16,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Move to point Shortcut %d"), 17),
- InputAction::MOVE_TO_POINT_17,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Move to point Shortcut %d"), 18),
- InputAction::MOVE_TO_POINT_18,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Move to point Shortcut %d"), 19),
- InputAction::MOVE_TO_POINT_19,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Move to point Shortcut %d"), 20),
- InputAction::MOVE_TO_POINT_20,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Move to point Shortcut %d"), 21),
- InputAction::MOVE_TO_POINT_21,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Move to point Shortcut %d"), 22),
- InputAction::MOVE_TO_POINT_22,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Move to point Shortcut %d"), 23),
- InputAction::MOVE_TO_POINT_23,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Move to point Shortcut %d"), 24),
- InputAction::MOVE_TO_POINT_24,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Move to point Shortcut %d"), 25),
- InputAction::MOVE_TO_POINT_25,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Move to point Shortcut %d"), 26),
- InputAction::MOVE_TO_POINT_26,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Move to point Shortcut %d"), 27),
- InputAction::MOVE_TO_POINT_27,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Move to point Shortcut %d"), 28),
- InputAction::MOVE_TO_POINT_28,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Move to point Shortcut %d"), 29),
- InputAction::MOVE_TO_POINT_29,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Move to point Shortcut %d"), 30),
- InputAction::MOVE_TO_POINT_30,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Move to point Shortcut %d"), 31),
- InputAction::MOVE_TO_POINT_31,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Move to point Shortcut %d"), 32),
- InputAction::MOVE_TO_POINT_32,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Move to point Shortcut %d"), 33),
- InputAction::MOVE_TO_POINT_33,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Move to point Shortcut %d"), 34),
- InputAction::MOVE_TO_POINT_34,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Move to point Shortcut %d"), 35),
- InputAction::MOVE_TO_POINT_35,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Move to point Shortcut %d"), 36),
- InputAction::MOVE_TO_POINT_36,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Move to point Shortcut %d"), 37),
- InputAction::MOVE_TO_POINT_37,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Move to point Shortcut %d"), 38),
- InputAction::MOVE_TO_POINT_38,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Move to point Shortcut %d"), 39),
- InputAction::MOVE_TO_POINT_39,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Move to point Shortcut %d"), 40),
- InputAction::MOVE_TO_POINT_40,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Move to point Shortcut %d"), 41),
- InputAction::MOVE_TO_POINT_41,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Move to point Shortcut %d"), 42),
- InputAction::MOVE_TO_POINT_42,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Move to point Shortcut %d"), 43),
- InputAction::MOVE_TO_POINT_43,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Move to point Shortcut %d"), 44),
- InputAction::MOVE_TO_POINT_44,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Move to point Shortcut %d"), 45),
- InputAction::MOVE_TO_POINT_45,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Move to point Shortcut %d"), 46),
- InputAction::MOVE_TO_POINT_46,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Move to point Shortcut %d"), 47),
- InputAction::MOVE_TO_POINT_47,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Move to point Shortcut %d"), 48),
- InputAction::MOVE_TO_POINT_48,
- "",
- },
- {
- "",
- InputAction::NO_VALUE,
- ""
- }
-};
diff --git a/src/input/pages/move.h b/src/input/pages/move.h
deleted file mode 100644
index 33ec08c2b..000000000
--- a/src/input/pages/move.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2007 Joshua Langley <joshlangley@optusnet.com.au>
- * 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 INPUT_PAGES_MOVE_H
-#define INPUT_PAGES_MOVE_H
-
-#include "gui/setupactiondata.h"
-
-extern SetupActionData setupActionDataMove[];
-
-#endif // INPUT_PAGES_MOVE_H
diff --git a/src/input/pages/other.cpp b/src/input/pages/other.cpp
deleted file mode 100644
index 88677c576..000000000
--- a/src/input/pages/other.cpp
+++ /dev/null
@@ -1,465 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2007 Joshua Langley <joshlangley@optusnet.com.au>
- * 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 "gui/setupactiondata.h"
-
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-SetupActionData setupActionDataOther[] =
-{
- {
- // TRANSLATORS: input action name
- N_("Input ignore"),
- InputAction::NO_VALUE,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Ignore input 1"),
- InputAction::IGNORE_INPUT_1,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Ignore input 2"),
- InputAction::IGNORE_INPUT_2,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Direction keys"),
- InputAction::NO_VALUE,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Player direct up"),
- InputAction::DIRECT_UP,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Player direct down"),
- InputAction::DIRECT_DOWN,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Player direct left"),
- InputAction::DIRECT_LEFT,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Player direct right"),
- InputAction::DIRECT_RIGHT,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Pet direct up"),
- InputAction::PET_DIRECT_UP,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Pet direct down"),
- InputAction::PET_DIRECT_DOWN,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Pet direct left"),
- InputAction::PET_DIRECT_LEFT,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Pet direct right"),
- InputAction::PET_DIRECT_RIGHT,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Other"),
- InputAction::NO_VALUE,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Crazy moves"),
- InputAction::CRAZY_MOVES,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Change Crazy Move mode"),
- InputAction::CHANGE_CRAZY_MOVES_TYPE,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Quick Drop N Items from 0 slot"),
- InputAction::QUICK_DROP,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Quick Drop N Items"),
- InputAction::QUICK_DROPN,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Switch Quick Drop Counter"),
- InputAction::SWITCH_QUICK_DROP,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Quick heal target or self"),
- InputAction::MAGIC_INMA1,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Heal the most injured player"),
- InputAction::HEAL_MOST_DAMAGED,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Use #itenplz spell"),
- InputAction::MAGIC_ITENPLZ,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Use magic attack"),
- InputAction::MAGIC_ATTACK,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Switch magic attack"),
- InputAction::SWITCH_MAGIC_ATTACK,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Switch pvp attack"),
- InputAction::SWITCH_PVP_ATTACK,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Change move type"),
- InputAction::INVERT_DIRECTION,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Change Attack Weapon Type"),
- InputAction::CHANGE_ATTACK_WEAPON_TYPE,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Change Attack Type"),
- InputAction::CHANGE_ATTACK_TYPE,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Change Follow mode"),
- InputAction::CHANGE_FOLLOW_MODE,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Change Imitation mode"),
- InputAction::CHANGE_IMITATION_MODE,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Disable / Enable Game modifier keys"),
- InputAction::DISABLE_GAME_MODIFIERS,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("On / Off audio"),
- InputAction::CHANGE_AUDIO,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Enable / Disable away mode"),
- InputAction::AWAY,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Emulate right click from keyboard"),
- InputAction::RIGHT_CLICK,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Toggle camera mode"),
- InputAction::CAMERA,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Toggle ipc mode"),
- InputAction::IPC_TOGGLE,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Show information about position in chat"),
- InputAction::WHERE,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Show online players number in chat"),
- InputAction::WHO,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Show onscreen keyboard"),
- InputAction::SHOW_KEYBOARD,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Clean cached graphics"),
- InputAction::CLEAN_GRAPHICS,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Clean cached fonts"),
- InputAction::CLEAN_FONTS,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Print visible players in chat"),
- InputAction::PRESENT,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Print all visible beings in chat"),
- InputAction::PRINT_ALL,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Load shop items list from disk"),
- InputAction::PRICE_LOAD,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Save shop items list to disk"),
- InputAction::PRICE_SAVE,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Print debug cache info"),
- InputAction::CACHE_INFO,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Undress selected player"),
- InputAction::UNDRESS,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Quick disconnect from server"),
- InputAction::DISCONNECT,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Disable debug particle"),
- InputAction::TEST_PARTICLE,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Create items (for gms)"),
- InputAction::CREATE_ITEMS,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Print configured directories in chat"),
- InputAction::DIRS,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Print client uptime in chat"),
- InputAction::UPTIME,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Dump debug information"),
- InputAction::DUMP,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Crash client"),
- InputAction::ERROR,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Dump graphics info into chat"),
- InputAction::DUMP_GRAPHICS,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Dump tests info into chat"),
- InputAction::DUMP_TESTS,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Print OpenGL version in chat"),
- InputAction::DUMP_GL,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Print enabled mods in chat"),
- InputAction::DUMP_MODS,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Dump environments into log"),
- InputAction::DUMP_ENVIRONMENT,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Dump OpenGL state into log"),
- InputAction::DUMP_OGL,
- "",
- },
-#if defined USE_OPENGL && defined DEBUG_SDLFONT
- {
- // TRANSLATORS: input action name
- N_("Test SDL font speed"),
- InputAction::TEST_SDL_FONT,
- "",
- },
-#endif // defined USE_OPENGL && defined DEBUG_SDLFONT
- {
- // TRANSLATORS: input action name
- N_("Upload main config"),
- InputAction::UPLOAD_CONFIG,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Upload server config"),
- InputAction::UPLOAD_SERVER_CONFIG,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Upload log file"),
- InputAction::UPLOAD_LOG,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Fire your mercenary"),
- InputAction::MERCENARY_FIRE,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Pet ai start"),
- InputAction::PET_AI_START,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Pet ai stop"),
- InputAction::PET_AI_STOP,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Feed homunculus"),
- InputAction::HOMUNCULUS_FEED,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Feed pet"),
- InputAction::PET_FEED,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Drop pet's loot"),
- InputAction::PET_DROP_LOOT,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Return pet to egg"),
- InputAction::PET_RETURN_TO_EGG,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Unequip pet"),
- InputAction::PET_UNEQUIP,
- "",
- },
- {
- "",
- InputAction::NO_VALUE,
- ""
- }
-};
diff --git a/src/input/pages/other.h b/src/input/pages/other.h
deleted file mode 100644
index 86b024f9f..000000000
--- a/src/input/pages/other.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2007 Joshua Langley <joshlangley@optusnet.com.au>
- * 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 INPUT_PAGES_OTHER_H
-#define INPUT_PAGES_OTHER_H
-
-#include "gui/setupactiondata.h"
-
-extern SetupActionData setupActionDataOther[];
-
-#endif // INPUT_PAGES_OTHER_H
diff --git a/src/input/pages/outfits.cpp b/src/input/pages/outfits.cpp
deleted file mode 100644
index 0b9beabd3..000000000
--- a/src/input/pages/outfits.cpp
+++ /dev/null
@@ -1,374 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2007 Joshua Langley <joshlangley@optusnet.com.au>
- * 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 "gui/setupactiondata.h"
-
-#include "utils/gettext.h"
-#include "utils/stringutils.h"
-
-#include "debug.h"
-
-SetupActionData setupActionDataOutfits[] =
-{
- {
- // TRANSLATORS: input action name
- N_("Outfits keys"),
- InputAction::NO_VALUE,
- ""
- },
- {
- // TRANSLATORS: input action name
- N_("Wear outfit"),
- InputAction::WEAR_OUTFIT,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Clear outfit"),
- InputAction::CLEAR_OUTFIT,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Copy Outfit to other outfit"),
- InputAction::COPY_OUTFIT,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Copy outfit to chat"),
- InputAction::COPY_OUTFIT_TO_CHAT,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Copy equipped to outfit"),
- InputAction::COPY_EQUIPED_OUTFIT,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Show hat in chat"),
- InputAction::HAT,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Outfits shortcuts"),
- InputAction::NO_VALUE,
- ""
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Outfit Shortcut %d"), 1),
- InputAction::OUTFIT_1,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Outfit Shortcut %d"), 2),
- InputAction::OUTFIT_2,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Outfit Shortcut %d"), 3),
- InputAction::OUTFIT_3,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Outfit Shortcut %d"), 4),
- InputAction::OUTFIT_4,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Outfit Shortcut %d"), 5),
- InputAction::OUTFIT_5,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Outfit Shortcut %d"), 6),
- InputAction::OUTFIT_6,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Outfit Shortcut %d"), 7),
- InputAction::OUTFIT_7,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Outfit Shortcut %d"), 8),
- InputAction::OUTFIT_8,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Outfit Shortcut %d"), 9),
- InputAction::OUTFIT_9,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Outfit Shortcut %d"), 10),
- InputAction::OUTFIT_10,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Outfit Shortcut %d"), 11),
- InputAction::OUTFIT_11,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Outfit Shortcut %d"), 12),
- InputAction::OUTFIT_12,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Outfit Shortcut %d"), 13),
- InputAction::OUTFIT_13,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Outfit Shortcut %d"), 14),
- InputAction::OUTFIT_14,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Outfit Shortcut %d"), 15),
- InputAction::OUTFIT_15,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Outfit Shortcut %d"), 16),
- InputAction::OUTFIT_16,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Outfit Shortcut %d"), 17),
- InputAction::OUTFIT_17,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Outfit Shortcut %d"), 18),
- InputAction::OUTFIT_18,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Outfit Shortcut %d"), 19),
- InputAction::OUTFIT_19,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Outfit Shortcut %d"), 20),
- InputAction::OUTFIT_20,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Outfit Shortcut %d"), 21),
- InputAction::OUTFIT_21,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Outfit Shortcut %d"), 22),
- InputAction::OUTFIT_22,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Outfit Shortcut %d"), 23),
- InputAction::OUTFIT_23,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Outfit Shortcut %d"), 24),
- InputAction::OUTFIT_24,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Outfit Shortcut %d"), 25),
- InputAction::OUTFIT_25,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Outfit Shortcut %d"), 26),
- InputAction::OUTFIT_26,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Outfit Shortcut %d"), 27),
- InputAction::OUTFIT_27,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Outfit Shortcut %d"), 28),
- InputAction::OUTFIT_28,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Outfit Shortcut %d"), 29),
- InputAction::OUTFIT_29,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Outfit Shortcut %d"), 30),
- InputAction::OUTFIT_30,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Outfit Shortcut %d"), 31),
- InputAction::OUTFIT_31,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Outfit Shortcut %d"), 32),
- InputAction::OUTFIT_32,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Outfit Shortcut %d"), 33),
- InputAction::OUTFIT_33,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Outfit Shortcut %d"), 34),
- InputAction::OUTFIT_34,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Outfit Shortcut %d"), 35),
- InputAction::OUTFIT_35,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Outfit Shortcut %d"), 36),
- InputAction::OUTFIT_36,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Outfit Shortcut %d"), 37),
- InputAction::OUTFIT_37,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Outfit Shortcut %d"), 38),
- InputAction::OUTFIT_38,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Outfit Shortcut %d"), 39),
- InputAction::OUTFIT_39,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Outfit Shortcut %d"), 40),
- InputAction::OUTFIT_40,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Outfit Shortcut %d"), 41),
- InputAction::OUTFIT_41,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Outfit Shortcut %d"), 42),
- InputAction::OUTFIT_42,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Outfit Shortcut %d"), 43),
- InputAction::OUTFIT_43,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Outfit Shortcut %d"), 44),
- InputAction::OUTFIT_44,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Outfit Shortcut %d"), 45),
- InputAction::OUTFIT_45,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Outfit Shortcut %d"), 46),
- InputAction::OUTFIT_46,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Outfit Shortcut %d"), 47),
- InputAction::OUTFIT_47,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Outfit Shortcut %d"), 48),
- InputAction::OUTFIT_48,
- "",
- },
- {
- "",
- InputAction::NO_VALUE,
- ""
- }
-};
diff --git a/src/input/pages/outfits.h b/src/input/pages/outfits.h
deleted file mode 100644
index 5bc1cf4a9..000000000
--- a/src/input/pages/outfits.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2007 Joshua Langley <joshlangley@optusnet.com.au>
- * 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 INPUT_PAGES_OUTFITS_H
-#define INPUT_PAGES_OUTFITS_H
-
-#include "gui/setupactiondata.h"
-
-extern SetupActionData setupActionDataOutfits[];
-
-#endif // INPUT_PAGES_OUTFITS_H
diff --git a/src/input/pages/shortcuts.cpp b/src/input/pages/shortcuts.cpp
deleted file mode 100644
index e4c57dbff..000000000
--- a/src/input/pages/shortcuts.cpp
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2007 Joshua Langley <joshlangley@optusnet.com.au>
- * 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 "gui/setupactiondata.h"
-
-#include "utils/gettext.h"
-#include "utils/stringutils.h"
-
-#include "debug.h"
-
-SetupActionData setupActionDataShortcuts[] =
-{
- {
- // TRANSLATORS: input action name
- N_("Shortcuts modifiers keys"),
- InputAction::NO_VALUE,
- ""
- },
- {
- // TRANSLATORS: input action name
- N_("Item Shortcuts Key"),
- InputAction::SHORTCUTS_KEY,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Shortcuts keys"),
- InputAction::NO_VALUE,
- ""
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Item Shortcut %d"), 1),
- InputAction::SHORTCUT_1,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Item Shortcut %d"), 2),
- InputAction::SHORTCUT_2,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Item Shortcut %d"), 3),
- InputAction::SHORTCUT_3,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Item Shortcut %d"), 4),
- InputAction::SHORTCUT_4,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Item Shortcut %d"), 5),
- InputAction::SHORTCUT_5,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Item Shortcut %d"), 6),
- InputAction::SHORTCUT_6,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Item Shortcut %d"), 7),
- InputAction::SHORTCUT_7,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Item Shortcut %d"), 8),
- InputAction::SHORTCUT_8,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Item Shortcut %d"), 9),
- InputAction::SHORTCUT_9,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Item Shortcut %d"), 10),
- InputAction::SHORTCUT_10,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Item Shortcut %d"), 11),
- InputAction::SHORTCUT_11,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Item Shortcut %d"), 12),
- InputAction::SHORTCUT_12,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Item Shortcut %d"), 13),
- InputAction::SHORTCUT_13,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Item Shortcut %d"), 14),
- InputAction::SHORTCUT_14,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Item Shortcut %d"), 15),
- InputAction::SHORTCUT_15,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Item Shortcut %d"), 16),
- InputAction::SHORTCUT_16,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Item Shortcut %d"), 17),
- InputAction::SHORTCUT_17,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Item Shortcut %d"), 18),
- InputAction::SHORTCUT_18,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Item Shortcut %d"), 19),
- InputAction::SHORTCUT_19,
- "",
- },
- {
- // TRANSLATORS: input action name
- strprintf(N_("Item Shortcut %d"), 20),
- InputAction::SHORTCUT_20,
- "",
- },
- {
- "",
- InputAction::NO_VALUE,
- ""
- }
-};
diff --git a/src/input/pages/shortcuts.h b/src/input/pages/shortcuts.h
deleted file mode 100644
index 56e0db05f..000000000
--- a/src/input/pages/shortcuts.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2007 Joshua Langley <joshlangley@optusnet.com.au>
- * 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 INPUT_PAGES_SHORTCUTS_H
-#define INPUT_PAGES_SHORTCUTS_H
-
-#include "gui/setupactiondata.h"
-
-extern SetupActionData setupActionDataShortcuts[];
-
-#endif // INPUT_PAGES_SHORTCUTS_H
diff --git a/src/input/pages/windows.cpp b/src/input/pages/windows.cpp
deleted file mode 100644
index ca232f914..000000000
--- a/src/input/pages/windows.cpp
+++ /dev/null
@@ -1,271 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2007 Joshua Langley <joshlangley@optusnet.com.au>
- * 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 "gui/setupactiondata.h"
-
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-SetupActionData setupActionDataWindows[] =
-{
- {
- // TRANSLATORS: input action label
- N_("Windows"),
- InputAction::NO_VALUE,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Show Windows Menu"),
- InputAction::SHOW_WINDOWS,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Hide Windows"),
- InputAction::HIDE_WINDOWS,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("About Window"),
- InputAction::WINDOW_ABOUT,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Bank Window"),
- InputAction::WINDOW_BANK,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Help Window"),
- InputAction::WINDOW_HELP,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Server Info Window"),
- InputAction::WINDOW_SERVER_INFO,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Status Window"),
- InputAction::WINDOW_STATUS,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Inventory Window"),
- InputAction::WINDOW_INVENTORY,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Equipment Window"),
- InputAction::WINDOW_EQUIPMENT,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Skill Window"),
- InputAction::WINDOW_SKILL,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Minimap Window"),
- InputAction::WINDOW_MINIMAP,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Chat Window"),
- InputAction::WINDOW_CHAT,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Item Shortcut Window"),
- InputAction::WINDOW_SHORTCUT,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Setup Window"),
- InputAction::WINDOW_SETUP,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Debug Window"),
- InputAction::WINDOW_DEBUG,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Social Window"),
- InputAction::WINDOW_SOCIAL,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Emote Shortcut Window"),
- InputAction::WINDOW_EMOTE_SHORTCUT,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Outfits Window"),
- InputAction::WINDOW_OUTFIT,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Shop Window"),
- InputAction::WINDOW_SHOP,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Quick drop Window"),
- InputAction::WINDOW_DROP,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Kill Stats Window"),
- InputAction::WINDOW_KILLS,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Commands Window"),
- InputAction::WINDOW_SPELLS,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Who Is Online Window"),
- InputAction::WINDOW_ONLINE,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Did you know Window"),
- InputAction::WINDOW_DIDYOUKNOW,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Quests Window"),
- InputAction::WINDOW_QUESTS,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Updates Window"),
- InputAction::WINDOW_UPDATER,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Cart window"),
- InputAction::WINDOW_CART,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Quick settings window"),
- InputAction::WINDOW_QUICK_SETTINGS,
- "",
- },
- {
- // TRANSLATORS: input action label
- N_("Tabs"),
- InputAction::NO_VALUE,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Previous Social Tab"),
- InputAction::PREV_SOCIAL_TAB,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Next Social Tab"),
- InputAction::NEXT_SOCIAL_TAB,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Previous Shortcuts tab"),
- InputAction::PREV_SHORTCUTS_TAB,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Next Shortcuts tab"),
- InputAction::NEXT_SHORTCUTS_TAB,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Previous Commands tab"),
- InputAction::PREV_COMMANDS_TAB,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Next Commands tab"),
- InputAction::NEXT_COMMANDS_TAB,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Previous inventory tab"),
- InputAction::PREV_INV_TAB,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Next inventory tab"),
- InputAction::NEXT_INV_TAB,
- "",
- },
- {
- // TRANSLATORS: input action name
- N_("Clear drops window"),
- InputAction::DROP_CLEAR,
- "",
- },
- {
- "",
- InputAction::NO_VALUE,
- ""
- }
-};
diff --git a/src/input/pages/windows.h b/src/input/pages/windows.h
deleted file mode 100644
index 388a9b84d..000000000
--- a/src/input/pages/windows.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2007 Joshua Langley <joshlangley@optusnet.com.au>
- * 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 INPUT_PAGES_WINDOWS_H
-#define INPUT_PAGES_WINDOWS_H
-
-#include "gui/setupactiondata.h"
-
-extern SetupActionData setupActionDataWindows[];
-
-#endif // INPUT_PAGES_WINDOWS_H
diff --git a/src/input/touch/multitouchmanager.cpp b/src/input/touch/multitouchmanager.cpp
deleted file mode 100644
index aaee3410f..000000000
--- a/src/input/touch/multitouchmanager.cpp
+++ /dev/null
@@ -1,88 +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 "input/touch/multitouchmanager.h"
-
-#ifdef USE_SDL2
-#include "render/graphics.h"
-
-#include "gui/sdlinput.h"
-#endif // USE_SDL2
-#include "debug.h"
-
-MultiTouchManager multiTouchManager;
-
-MultiTouchManager::MultiTouchManager() :
- mEvents()
-{
-}
-
-MultiTouchManager::~MultiTouchManager()
-{
-}
-
-void MultiTouchManager::init()
-{
-}
-
-#ifdef USE_SDL2
-void MultiTouchManager::updateFinger(const SDL_Event &event, const bool active)
-{
- const SDL_TouchFingerEvent &touch = event.tfinger;
- MultiTouchEventsMap &device = mEvents[touch.touchId];
- MultiTouchEvent &finger = device[touch.fingerId];
- finger.active = active;
- finger.x = touch.x;
- finger.y = touch.y;
-}
-
-void MultiTouchManager::handleFingerDown(const SDL_Event &event)
-{
- updateFinger(event, true);
- const SDL_TouchFingerEvent &touch = event.tfinger;
- checkDevice(touch.touchId, touch.fingerId);
-}
-
-void MultiTouchManager::handleFingerUp(const SDL_Event &event)
-{
- updateFinger(event, false);
-}
-
-void MultiTouchManager::checkDevice(const long touchId,
- const long fingerId)
-{
- if (fingerId != 1 || !guiInput)
- return;
-
- MultiTouchEventsMap &device = mEvents[touchId];
- MultiTouchEvent &finger0 = device[0];
- if (finger0.active)
- {
- MultiTouchEvent &finger1 = device[1];
- if (finger1.active)
- {
- const int w = mainGraphics->mWidth;
- const int h = mainGraphics->mHeight;
- guiInput->simulateMouseClick(finger0.x * w, finger0.y * h,
- MouseButton::RIGHT);
- }
- }
-}
-#endif // USE_SDL2
diff --git a/src/input/touch/multitouchmanager.h b/src/input/touch/multitouchmanager.h
deleted file mode 100644
index fbb240503..000000000
--- a/src/input/touch/multitouchmanager.h
+++ /dev/null
@@ -1,72 +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 INPUT_TOUCH_MULTITOUCHMANAGER_H
-#define INPUT_TOUCH_MULTITOUCHMANAGER_H
-
-#include <map>
-
-#include "localconsts.h"
-
-#ifdef USE_SDL2
-union SDL_Event;
-#endif // USE_SDL2
-
-struct MultiTouchEvent final
-{
- A_DEFAULT_COPY(MultiTouchEvent)
-
- bool active;
- float x;
- float y;
-};
-
-typedef std::map<int, MultiTouchEvent> MultiTouchEventsMap;
-typedef std::map<int, MultiTouchEventsMap> MultiTouchDevicesMap;
-
-class MultiTouchManager final
-{
- public:
- MultiTouchManager();
-
- ~MultiTouchManager();
-
- A_DELETE_COPY(MultiTouchManager)
-
- void init() A_CONST;
-
-#ifdef USE_SDL2
- void updateFinger(const SDL_Event &event, const bool active);
-
- void handleFingerDown(const SDL_Event &event);
-
- void handleFingerUp(const SDL_Event &event);
-
- void checkDevice(const long touchId,
- const long fingerId);
-#endif // USE_SDL2
-
- private:
- MultiTouchDevicesMap mEvents;
-};
-
-extern MultiTouchManager multiTouchManager;
-
-#endif // INPUT_TOUCH_MULTITOUCHMANAGER_H
diff --git a/src/input/touch/touchactions.cpp b/src/input/touch/touchactions.cpp
deleted file mode 100644
index f1f8e4676..000000000
--- a/src/input/touch/touchactions.cpp
+++ /dev/null
@@ -1,129 +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 "input/touch/touchactions.h"
-
-#include "input/inputmanager.h"
-#include "input/mouseinput.h"
-
-#include "input/touch/touchmanager.h"
-
-#include "debug.h"
-
-bool padClicked(false);
-int halfJoyPad = 50;
-
-#define impHandler(name) void name(const MouseInput &mouseInput)
-#define impHandler0(name) void name(const MouseInput &mouseInput A_UNUSED)
-
-void setHalfJoyPad(const int s)
-{
- halfJoyPad = s;
-}
-
-static void moveChar(int x, int y)
-{
- static const int lim1 = 10;
- static const int diff = 20;
-
- // set center at (0,0)
- x -= halfJoyPad;
- y -= halfJoyPad;
-
- // some magic for checking at what sector was click
- if (abs(x) < lim1)
- x = 0;
-
- if (abs(y) < lim1)
- y = 0;
-
- const int x2 = abs(x);
- const int y2 = abs(y);
- if (x2 > y2)
- {
- if ((y2 != 0) && x2 * 10 / y2 > diff)
- y = 0;
- }
- else
- {
- if ((x2 != 0) && y2 * 10 / x2 > diff)
- x = 0;
- }
-
- // detecting direction
- if (x > 0)
- {
- touchManager.setActionActive(InputAction::MOVE_LEFT, false);
- touchManager.setActionActive(InputAction::MOVE_RIGHT, true);
- }
- else if (x < 0)
- {
- touchManager.setActionActive(InputAction::MOVE_LEFT, true);
- touchManager.setActionActive(InputAction::MOVE_RIGHT, false);
- }
- else
- {
- touchManager.setActionActive(InputAction::MOVE_LEFT, false);
- touchManager.setActionActive(InputAction::MOVE_RIGHT, false);
- }
- if (y > 0)
- {
- touchManager.setActionActive(InputAction::MOVE_DOWN, true);
- touchManager.setActionActive(InputAction::MOVE_UP, false);
- }
- else if (y < 0)
- {
- touchManager.setActionActive(InputAction::MOVE_DOWN, false);
- touchManager.setActionActive(InputAction::MOVE_UP, true);
- }
- else
- {
- touchManager.setActionActive(InputAction::MOVE_DOWN, false);
- touchManager.setActionActive(InputAction::MOVE_UP, false);
- }
- inputManager.updateConditionMask(true);
-}
-
-impHandler(padClick)
-{
- moveChar(mouseInput.getX(), mouseInput.getY());
- padClicked = true;
-}
-
-impHandler(padEvents)
-{
- if (mouseInput.getType() == MouseEventType::MOVED)
- {
- if (padClicked)
- moveChar(mouseInput.getX(), mouseInput.getY());
- }
-}
-
-impHandler0(padOut)
-{
- padClicked = false;
- moveChar(halfJoyPad, halfJoyPad);
-}
-
-impHandler0(padUp)
-{
- padClicked = false;
- moveChar(halfJoyPad, halfJoyPad);
-}
diff --git a/src/input/touch/touchactions.h b/src/input/touch/touchactions.h
deleted file mode 100644
index 1d0017275..000000000
--- a/src/input/touch/touchactions.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 INPUT_TOUCH_TOUCHACTIONS_H
-#define INPUT_TOUCH_TOUCHACTIONS_H
-
-#include "localconsts.h"
-
-#define decHandler(name) void name(const MouseInput &mouseInput)
-
-class MouseInput;
-
-decHandler(padClick);
-decHandler(padEvents);
-decHandler(padOut);
-decHandler(padUp);
-
-void setHalfJoyPad(const int s);
-
-#undef decHandler
-
-#endif // INPUT_TOUCH_TOUCHACTIONS_H
diff --git a/src/input/touch/touchmanager.cpp b/src/input/touch/touchmanager.cpp
deleted file mode 100644
index df98e667f..000000000
--- a/src/input/touch/touchmanager.cpp
+++ /dev/null
@@ -1,709 +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 "input/touch/touchmanager.h"
-
-#include "configuration.h"
-
-#include "gui/gui.h"
-#include "gui/skin.h"
-#include "gui/theme.h"
-
-#include "gui/fonts/font.h"
-
-#include "input/inputmanager.h"
-#include "input/mouseinput.h"
-
-#include "input/touch/touchactions.h"
-
-#include "utils/delete2.h"
-#include "utils/foreach.h"
-
-#include "render/graphics.h"
-
-#include "render/vertexes/imagecollection.h"
-
-#include "resources/imagerect.h"
-
-#include "resources/image/image.h"
-
-#include "debug.h"
-
-TouchManager touchManager;
-
-extern RenderType openGLMode;
-
-TouchManager::TouchManager() :
- mKeyboard(nullptr),
- mPad(nullptr),
- mObjects(),
- mVertexes(nullptr),
- mRedraw(true),
- mShowJoystick(false),
- mShowButtons(false),
- mShowKeyboard(false),
- mButtonsSize(1),
- mJoystickSize(1),
- mButtonsFormat(0),
- mWidth(0),
- mHeight(0),
- mShow(false),
- mInGame(false),
- mTempHideButtons(false)
-{
- for (int f = 0; f < actionsSize; f ++)
- mActions[f] = false;
- for (int f = 0; f < buttonsCount; f ++)
- mButtons[f] = nullptr;
-}
-
-TouchManager::~TouchManager()
-{
- clear();
- CHECKLISTENERS
-}
-
-void TouchManager::shutdown() restrict2
-{
- config.removeListeners(this);
-}
-
-void TouchManager::init() restrict2
-{
- delete mVertexes;
- mVertexes = new ImageCollection;
-
- config.addListener("showScreenJoystick", this);
- config.addListener("showScreenButtons", this);
- config.addListener("showScreenKeyboard", this);
- config.addListener("screenButtonsSize", this);
- config.addListener("screenJoystickSize", this);
- config.addListener("screenButtonsFormat", this);
-
- mShowJoystick = config.getBoolValue("showScreenJoystick");
- mShowButtons = config.getBoolValue("showScreenButtons");
- mShowKeyboard = config.getBoolValue("showScreenKeyboard");
- mButtonsSize = config.getIntValue("screenButtonsSize");
- mJoystickSize = config.getIntValue("screenJoystickSize");
- mButtonsFormat = config.getIntValue("screenButtonsFormat");
-
- setHalfJoyPad(getPadSize() / 2);
-
- if (mShowKeyboard)
- loadKeyboard();
- if (mShowJoystick)
- loadPad();
- if (mShowButtons)
- loadButtons();
- mWidth = mainGraphics->mWidth;
- mHeight = mainGraphics->mHeight;
-}
-
-void TouchManager::loadTouchItem(TouchItem **restrict item,
- const std::string &restrict name,
- const std::string &restrict imageName,
- const std::string &restrict text,
- int x, int y,
- const int width, const int height,
- const int type,
- const std::string &restrict eventPressed,
- const std::string &restrict eventReleased,
- const TouchFuncPtr fAll,
- const TouchFuncPtr fPressed,
- const TouchFuncPtr fReleased,
- const TouchFuncPtr fOut) restrict2
-{
- *item = nullptr;
- if (theme == nullptr)
- return;
- ImageRect *images = new ImageRect;
- for (int f = 0; f < 9; f ++)
- images->grid[f] = nullptr;
-
- Image *icon;
- if (imageName.empty())
- icon = nullptr;
- else
- icon = Theme::getImageFromThemeXml(imageName, "");
-
- Skin *const skin = theme->loadSkinRect(*images, name, "");
- if (skin != nullptr)
- {
- Image *const image = images->grid[0];
- if (image != nullptr)
- {
- if (x == -1)
- x = skin->getOption("x", 10);
- if (y == -1)
- y = skin->getOption("y", 10);
- const int pad = skin->getPadding();
- const int pad2 = 2 * pad;
- const int border = skin->getOption("clickborder");
- const int border2 = border * 2;
- const int diff = pad - border;
- switch (type)
- {
- case LEFT:
- y += (mainGraphics->mHeight - height) / 2;
- break;
- case RIGHT:
- x = mainGraphics->mWidth - width - pad2 - x;
- y = mainGraphics->mHeight - height - pad2 - y;
- break;
- case NORMAL:
- default:
- break;
- }
- *item = new TouchItem(text, Rect(x + diff, y + diff,
- width + border2, height + border2), type,
- eventPressed, eventReleased, images, icon,
- x + pad, y + pad, width, height,
- fAll, fPressed, fReleased, fOut);
- mObjects.push_back(*item);
- }
- else
- {
- delete images;
- }
- theme->unload(skin);
- }
- else
- {
- delete images;
- }
- mRedraw = true;
-}
-
-void TouchManager::clear() restrict2
-{
- FOR_EACH (TouchItemVectorCIter, it, mObjects)
- unload(*it);
- mObjects.clear();
- delete2(mVertexes);
- mRedraw = true;
-}
-
-void TouchManager::draw() restrict2
-{
- if (mRedraw)
- {
- mRedraw = false;
- mVertexes->clear();
- FOR_EACH (TouchItemVectorCIter, it, mObjects)
- {
- const TouchItem *const item = *it;
- if ((item != nullptr) && (item->images != nullptr) && (mShow ||
- (item == mKeyboard && mShowKeyboard)))
- {
- mainGraphics->calcWindow(mVertexes, item->x, item->y,
- item->width, item->height, *item->images);
- const Image *const icon = item->icon;
- if (icon != nullptr)
- {
- mainGraphics->calcTileCollection(mVertexes, icon,
- item->x + (item->width - icon->mBounds.w) / 2,
- item->y + (item->height - icon->mBounds.h) / 2);
- }
- }
- }
- mainGraphics->finalize(mVertexes);
- }
- mainGraphics->drawTileCollection(mVertexes);
- drawText();
-}
-
-void TouchManager::safeDraw() restrict2
-{
- FOR_EACH (TouchItemVectorCIter, it, mObjects)
- {
- const TouchItem *const item = *it;
- if ((item != nullptr) && (item->images != nullptr) && (mShow ||
- (item == mKeyboard && mShowKeyboard)))
- {
- mainGraphics->drawImageRect(item->x, item->y,
- item->width, item->height, *item->images);
- const Image *const icon = item->icon;
- if (icon != nullptr)
- {
- mainGraphics->drawImage(icon,
- item->x + (item->width - icon->mBounds.w) / 2,
- item->y + (item->height - icon->mBounds.h) / 2);
- }
- }
- }
- drawText();
-}
-
-void TouchManager::drawText() restrict2
-{
- if (gui == nullptr)
- return;
-
- Font *const font = boldFont;
- const Color &color1 = theme->getColor(ThemeColorId::TEXT, 255);
- const Color &color2 = theme->getColor(ThemeColorId::TEXT_OUTLINE, 255);
-
- FOR_EACH (TouchItemVectorCIter, it, mObjects)
- {
- const TouchItem *const item = *it;
- if ((item != nullptr) && mShow && !item->text.empty())
- {
- const std::string str = item->text;
- const int textX = (item->rect.width - font->getWidth(str))
- / 2 + item->x;
- const int textY = (item->rect.height - font->getHeight())
- / 2 + item->y;
- font->drawString(mainGraphics,
- color1,
- color2,
- str, textX, textY);
- }
- }
-}
-
-bool TouchManager::processEvent(const MouseInput &mouseInput) restrict2
-{
- const int x = mouseInput.getTouchX();
- const int y = mouseInput.getTouchY();
-
- FOR_EACH (TouchItemVectorCIter, it, mObjects)
- {
- const TouchItem *const item = *it;
- if (item == nullptr ||
- (!mShow && (item != mKeyboard || !mShowKeyboard)))
- {
- continue;
- }
- const Rect &rect = item->rect;
- if (rect.isPointInRect(x, y))
- {
- MouseInput event = mouseInput;
- event.setX(event.getTouchX() - item->x);
- event.setY(event.getTouchY() - item->y);
- if (item->funcAll != nullptr)
- item->funcAll(event);
-
- switch (mouseInput.getType())
- {
- case MouseEventType::PRESSED:
- if (!item->eventPressed.empty())
- executeAction(item->eventPressed);
- else if (item->funcPressed != nullptr)
- item->funcPressed(event);
- break;
- case MouseEventType::RELEASED:
- if (!item->eventReleased.empty())
- executeAction(item->eventReleased);
- else if (item->funcReleased != nullptr)
- item->funcReleased(event);
- break;
- default:
- case MouseEventType::MOVED:
- case MouseEventType::WHEEL_MOVED_DOWN:
- case MouseEventType::WHEEL_MOVED_UP:
- case MouseEventType::CLICKED:
- case MouseEventType::ENTERED:
- case MouseEventType::EXITED:
- case MouseEventType::DRAGGED:
- case MouseEventType::RELEASED2:
- break;
- }
- return true;
- }
- else if (item->funcOut != nullptr)
- {
- item->funcOut(mouseInput);
- }
- }
- return false;
-}
-
-bool TouchManager::isActionActive(const InputActionT index) restrict2 const
-{
- if (CAST_S32(index) < 0 ||
- CAST_S32(index) >= actionsSize)
- {
- return false;
- }
- return mActions[CAST_SIZE(index)];
-}
-
-void TouchManager::resize(const int width, const int height) restrict2
-{
- mRedraw = true;
- const int maxHeight = mHeight;
- const int diffW = width - mWidth;
- const int diffH = height - maxHeight;
- FOR_EACH (TouchItemVectorCIter, it, mObjects)
- {
- TouchItem *const item = *it;
- if (item == nullptr)
- continue;
-
- switch (item->type)
- {
- case LEFT:
- if (height != maxHeight)
- {
- item->y = (height - item->height) / 2;
- item->rect.y = (height - item->rect.y) / 2;
- }
- break;
- case RIGHT:
- {
- item->x += diffW;
- item->rect.x += diffW;
- item->y += diffH;
- item->rect.y += diffH;
- break;
- }
- case NORMAL:
- default:
- break;
- }
- }
- mWidth = mainGraphics->mWidth;
- mHeight = mainGraphics->mHeight;
-}
-
-void TouchManager::unload(TouchItem *restrict const item)
-{
- if (item != nullptr)
- {
- if (item->images != nullptr)
- {
- Theme::unloadRect(*item->images);
- delete2(item->images);
- if (item->icon != nullptr)
- {
- item->icon->decRef();
- item->icon = nullptr;
- }
- }
- delete item;
- }
-}
-
-void TouchManager::unloadTouchItem(TouchItem *restrict *unloadItem) restrict2
-{
- FOR_EACH (TouchItemVectorIter, it, mObjects)
- {
- TouchItem *item = *it;
- if ((item != nullptr) && *unloadItem == item)
- {
- mObjects.erase(it);
- unload(item);
- return;
- }
- }
-}
-
-void TouchManager::loadPad() restrict2
-{
- const int sz = (mJoystickSize + 2) * 50;
- loadTouchItem(&mPad, "dpad.xml", "dpad_image.xml", "", -1, -1, sz, sz,
- LEFT, "", "", &padEvents, &padClick, &padUp, &padOut);
-}
-
-void TouchManager::loadButtons() restrict2
-{
- const int sz = (mButtonsSize + 1) * 50;
- if (theme == nullptr)
- return;
- Skin *const skin = theme->load("dbutton.xml", "");
-
- if (skin != nullptr)
- {
- const int x = skin->getOption("x", 10);
- const int y = skin->getOption("y", 10);
- const int pad = skin->getPadding();
- const int pad2 = 2 * pad + sz;
- const int skipWidth = pad2 + x;
- const int skipHeight = pad2 + y;
-
- switch (mButtonsFormat)
- {
- // 2x1
- case 0:
- default:
- {
- loadTouchItem(&mButtons[1], "dbutton.xml", "dbutton_image.xml",
- "2", x, y, sz, sz, RIGHT, "screenActionButton1", "");
- loadTouchItem(&mButtons[0], "dbutton.xml", "dbutton_image.xml",
- "1", skipWidth, y, sz, sz, RIGHT,
- "screenActionButton0", "");
- break;
- }
- // 2x2
- case 1:
- {
- loadTouchItem(&mButtons[3], "dbutton.xml", "dbutton_image.xml",
- "4", x, y, sz, sz, RIGHT, "screenActionButton3", "");
- loadTouchItem(&mButtons[2], "dbutton.xml", "dbutton_image.xml",
- "3", skipWidth, y, sz, sz, RIGHT,
- "screenActionButton2", "");
- loadTouchItem(&mButtons[1], "dbutton.xml", "dbutton_image.xml",
- "2", x, skipHeight, sz, sz, RIGHT,
- "screenActionButton1", "");
- loadTouchItem(&mButtons[0], "dbutton.xml", "dbutton_image.xml",
- "1", skipWidth, skipHeight, sz, sz, RIGHT,
- "screenActionButton0", "");
- break;
- }
- // 3x3
- case 2:
- {
- const int pad4 = pad2 * 2;
- const int skipWidth2 = pad4 + x;
- const int skipHeight2 = pad4 + y;
- loadTouchItem(&mButtons[8], "dbutton.xml", "dbutton_image.xml",
- "9", x, y, sz, sz, RIGHT, "screenActionButton8", "");
- loadTouchItem(&mButtons[7], "dbutton.xml", "dbutton_image.xml",
- "8", skipWidth, y, sz, sz, RIGHT,
- "screenActionButton7", "");
- loadTouchItem(&mButtons[6], "dbutton.xml", "dbutton_image.xml",
- "7", skipWidth2, y, sz, sz, RIGHT,
- "screenActionButton6", "");
- loadTouchItem(&mButtons[5], "dbutton.xml", "dbutton_image.xml",
- "6", x, skipHeight, sz, sz, RIGHT,
- "screenActionButton5", "");
- loadTouchItem(&mButtons[4], "dbutton.xml", "dbutton_image.xml",
- "5", skipWidth, skipHeight, sz, sz, RIGHT,
- "screenActionButton4", "");
- loadTouchItem(&mButtons[3], "dbutton.xml", "dbutton_image.xml",
- "4", skipWidth2, skipHeight, sz, sz, RIGHT,
- "screenActionButton3", "");
- loadTouchItem(&mButtons[2], "dbutton.xml", "dbutton_image.xml",
- "3", x, skipHeight2, sz, sz, RIGHT,
- "screenActionButton2", "");
- loadTouchItem(&mButtons[1], "dbutton.xml", "dbutton_image.xml",
- "2", skipWidth, skipHeight2, sz, sz, RIGHT,
- "screenActionButton1", "");
- loadTouchItem(&mButtons[0], "dbutton.xml", "dbutton_image.xml",
- "1", skipWidth2, skipHeight2, sz, sz, RIGHT,
- "screenActionButton0", "");
- break;
- }
- // 4x2
- case 3:
- {
- const int skipWidth2 = pad2 * 2 + x;
- const int skipWidth3 = pad2 * 3 + x;
- loadTouchItem(&mButtons[7], "dbutton.xml", "dbutton_image.xml",
- "8", x, y, sz, sz, RIGHT, "screenActionButton7", "");
- loadTouchItem(&mButtons[6], "dbutton.xml", "dbutton_image.xml",
- "7", skipWidth, y, sz, sz, RIGHT,
- "screenActionButton6", "");
- loadTouchItem(&mButtons[5], "dbutton.xml", "dbutton_image.xml",
- "6", skipWidth2, y, sz, sz, RIGHT,
- "screenActionButton5", "");
- loadTouchItem(&mButtons[4], "dbutton.xml", "dbutton_image.xml",
- "5", skipWidth3, y, sz, sz, RIGHT,
- "screenActionButton4", "");
- loadTouchItem(&mButtons[3], "dbutton.xml", "dbutton_image.xml",
- "4", x, skipHeight, sz, sz, RIGHT,
- "screenActionButton3", "");
- loadTouchItem(&mButtons[2], "dbutton.xml", "dbutton_image.xml",
- "3", skipWidth, skipHeight, sz, sz, RIGHT,
- "screenActionButton2", "");
- loadTouchItem(&mButtons[1], "dbutton.xml", "dbutton_image.xml",
- "2", skipWidth2, skipHeight, sz, sz, RIGHT,
- "screenActionButton1", "");
- loadTouchItem(&mButtons[0], "dbutton.xml", "dbutton_image.xml",
- "1", skipWidth3, skipHeight, sz, sz, RIGHT,
- "screenActionButton0", "");
- break;
- }
- // 4x3
- case 4:
- {
- const int skipWidth2 = pad2 * 2 + x;
- const int skipWidth3 = pad2 * 3 + x;
- const int skipHeight2 = pad2 * 2 + y;
- loadTouchItem(&mButtons[11], "dbutton.xml",
- "dbutton_image.xml", "12", x, y, sz, sz, RIGHT,
- "screenActionButton11", "");
- loadTouchItem(&mButtons[10], "dbutton.xml",
- "dbutton_image.xml", "11", skipWidth, y, sz, sz, RIGHT,
- "screenActionButton10", "");
- loadTouchItem(&mButtons[9], "dbutton.xml", "dbutton_image.xml",
- "10", skipWidth2, y, sz, sz, RIGHT,
- "screenActionButton9", "");
- loadTouchItem(&mButtons[8], "dbutton.xml", "dbutton_image.xml",
- "9", skipWidth3, y, sz, sz, RIGHT,
- "screenActionButton8", "");
- loadTouchItem(&mButtons[7], "dbutton.xml", "dbutton_image.xml",
- "8", x, skipHeight, sz, sz, RIGHT,
- "screenActionButton7", "");
- loadTouchItem(&mButtons[6], "dbutton.xml", "dbutton_image.xml",
- "7", skipWidth, skipHeight, sz, sz, RIGHT,
- "screenActionButton6", "");
- loadTouchItem(&mButtons[5], "dbutton.xml", "dbutton_image.xml",
- "6", skipWidth2, skipHeight, sz, sz, RIGHT,
- "screenActionButton5", "");
- loadTouchItem(&mButtons[4], "dbutton.xml", "dbutton_image.xml",
- "5", skipWidth3, skipHeight, sz, sz, RIGHT,
- "screenActionButton4", "");
- loadTouchItem(&mButtons[3], "dbutton.xml", "dbutton_image.xml",
- "4", x, skipHeight2, sz, sz, RIGHT,
- "screenActionButton3", "");
- loadTouchItem(&mButtons[2], "dbutton.xml", "dbutton_image.xml",
- "3", skipWidth, skipHeight2, sz, sz, RIGHT,
- "screenActionButton2", "");
- loadTouchItem(&mButtons[1], "dbutton.xml", "dbutton_image.xml",
- "2", skipWidth2, skipHeight2, sz, sz, RIGHT,
- "screenActionButton1", "");
- loadTouchItem(&mButtons[0], "dbutton.xml", "dbutton_image.xml",
- "1", skipWidth3, skipHeight2, sz, sz, RIGHT,
- "screenActionButton0", "");
- break;
- }
- // 3x2
- case 5:
- {
- const int pad4 = pad2 * 2;
- const int skipWidth2 = pad4 + x;
- loadTouchItem(&mButtons[5], "dbutton.xml", "dbutton_image.xml",
- "6", x, y, sz, sz, RIGHT, "screenActionButton5", "");
- loadTouchItem(&mButtons[4], "dbutton.xml", "dbutton_image.xml",
- "5", skipWidth, y, sz, sz, RIGHT,
- "screenActionButton4", "");
- loadTouchItem(&mButtons[3], "dbutton.xml", "dbutton_image.xml",
- "4", skipWidth2, y, sz, sz, RIGHT,
- "screenActionButton3", "");
- loadTouchItem(&mButtons[2], "dbutton.xml", "dbutton_image.xml",
- "3", x, skipHeight, sz, sz, RIGHT,
- "screenActionButton2", "");
- loadTouchItem(&mButtons[1], "dbutton.xml", "dbutton_image.xml",
- "2", skipWidth, skipHeight, sz, sz, RIGHT,
- "screenActionButton1", "");
- loadTouchItem(&mButtons[0], "dbutton.xml", "dbutton_image.xml",
- "1", skipWidth2, skipHeight, sz, sz, RIGHT,
- "screenActionButton0", "");
- break;
- }
- };
- theme->unload(skin);
- }
-}
-
-void TouchManager::loadKeyboard() restrict2
-{
- loadTouchItem(&mKeyboard, "keyboard_icon.xml", "", "", -1, -1, 28, 28,
- NORMAL, "", "screenActionKeyboard");
-}
-
-void TouchManager::optionChanged(const std::string &value) restrict2
-{
- if (value == "showScreenJoystick")
- {
- if (mShowJoystick == config.getBoolValue("showScreenJoystick"))
- return;
- mShowJoystick = config.getBoolValue("showScreenJoystick");
- if (mShowJoystick)
- loadPad();
- else
- unloadTouchItem(&mPad);
- mRedraw = true;
- }
- else if (value == "showScreenButtons")
- {
- if (mShowButtons == config.getBoolValue("showScreenButtons"))
- return;
- mShowButtons = config.getBoolValue("showScreenButtons");
- if (mShowButtons)
- {
- loadButtons();
- }
- else
- {
- for (int f = 0; f < buttonsCount; f ++)
- unloadTouchItem(&mButtons[f]);
- }
- mRedraw = true;
- }
- else if (value == "showScreenKeyboard")
- {
- if (mShowKeyboard == config.getBoolValue("showScreenKeyboard"))
- return;
- mShowKeyboard = config.getBoolValue("showScreenKeyboard");
- if (mShowKeyboard)
- loadKeyboard();
- else
- unloadTouchItem(&mKeyboard);
- mRedraw = true;
- }
- else if (value == "screenButtonsSize")
- {
- if (mButtonsSize == config.getIntValue("screenButtonsSize"))
- return;
- mButtonsSize = config.getIntValue("screenButtonsSize");
- if (mShowButtons)
- {
- for (int f = 0; f < buttonsCount; f ++)
- unloadTouchItem(&mButtons[f]);
- loadButtons();
- }
- }
- else if (value == "screenJoystickSize")
- {
- if (mJoystickSize == config.getIntValue("screenJoystickSize"))
- return;
- mJoystickSize = config.getIntValue("screenJoystickSize");
- setHalfJoyPad(getPadSize() / 2);
- if (mShowJoystick)
- {
- unloadTouchItem(&mPad);
- loadPad();
- }
- }
- else if (value == "screenButtonsFormat")
- {
- if (mButtonsFormat == config.getIntValue("screenButtonsFormat"))
- return;
- mButtonsFormat = config.getIntValue("screenButtonsFormat");
- if (mShowButtons)
- {
- for (int f = 0; f < buttonsCount; f ++)
- unloadTouchItem(&mButtons[f]);
- loadButtons();
- }
- }
-}
-
-void TouchManager::setInGame(const bool b) restrict2
-{
- mInGame = b;
- mShow = mInGame && !mTempHideButtons;
- mRedraw = true;
-}
-
-void TouchManager::setTempHide(const bool b) restrict2
-{
- mTempHideButtons = b;
- mShow = mInGame && !mTempHideButtons;
- mRedraw = true;
-}
-
-void TouchManager::executeAction(const std::string &restrict event)
-{
- inputManager.executeAction(static_cast<InputActionT>(
- config.getIntValue(event)));
-}
diff --git a/src/input/touch/touchmanager.h b/src/input/touch/touchmanager.h
deleted file mode 100644
index 0b9187968..000000000
--- a/src/input/touch/touchmanager.h
+++ /dev/null
@@ -1,204 +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 INPUT_TOUCH_TOUCHMANAGER_H
-#define INPUT_TOUCH_TOUCHMANAGER_H
-
-#include "listeners/configlistener.h"
-
-#include "enums/input/inputaction.h"
-
-#include "gui/rect.h"
-
-#include "utils/cast.h"
-#include "utils/vector.h"
-
-#include "localconsts.h"
-
-class Image;
-class ImageCollection;
-class ImageRect;
-class MouseInput;
-
-typedef void (*TouchFuncPtr) (const MouseInput &restrict mouseInput);
-
-const int actionsSize = CAST_S32(InputAction::TOTAL);
-const int buttonsCount = 12;
-
-struct TouchItem final
-{
- TouchItem(const std::string &text0,
- const Rect &rect0,
- const int type0,
- const std::string &restrict eventPressed0,
- const std::string &restrict eventReleased0,
- ImageRect *restrict const images0,
- Image *restrict const icon0,
- const int x0, const int y0,
- const int width0, const int height0,
- const TouchFuncPtr ptrAll,
- const TouchFuncPtr ptrPressed,
- const TouchFuncPtr ptrReleased,
- const TouchFuncPtr ptrOut) :
- text(text0),
- rect(rect0),
- type(type0),
- eventPressed(eventPressed0),
- eventReleased(eventReleased0),
- images(images0),
- icon(icon0),
- x(x0),
- y(y0),
- width(width0),
- height(height0),
- funcAll(ptrAll),
- funcPressed(ptrPressed),
- funcReleased(ptrReleased),
- funcOut(ptrOut)
- {
- }
-
- A_DELETE_COPY(TouchItem)
-
- std::string text;
- Rect rect;
- int type;
- std::string eventPressed;
- std::string eventReleased;
- ImageRect *images;
- Image *icon;
- int x;
- int y;
- int width;
- int height;
- TouchFuncPtr funcAll;
- TouchFuncPtr funcPressed;
- TouchFuncPtr funcReleased;
- TouchFuncPtr funcOut;
-};
-
-typedef STD_VECTOR<TouchItem*> TouchItemVector;
-typedef TouchItemVector::const_iterator TouchItemVectorCIter;
-typedef TouchItemVector::iterator TouchItemVectorIter;
-
-class TouchManager final : public ConfigListener
-{
- public:
- TouchManager();
-
- ~TouchManager();
-
- A_DELETE_COPY(TouchManager)
-
- enum Types
- {
- NORMAL = 0,
- LEFT = 1,
- RIGHT = 2
- };
-
- void init() restrict2;
-
- void loadTouchItem(TouchItem **restrict item,
- const std::string &restrict name,
- const std::string &restrict imageName,
- const std::string &restrict text,
- int x, int y,
- const int width, const int height,
- const int type,
- const std::string &restrict eventPressed,
- const std::string &restrict eventReleased,
- const TouchFuncPtr fAll = nullptr,
- const TouchFuncPtr fPressed = nullptr,
- const TouchFuncPtr fReleased = nullptr,
- const TouchFuncPtr fOut = nullptr)
- restrict2 A_NONNULL(2);
-
- void clear() restrict2;
-
- void draw() restrict2;
-
- void safeDraw() restrict2;
-
- void drawText() restrict2;
-
- bool processEvent(const MouseInput &mouseInput) restrict2;
-
- bool isActionActive(const InputActionT index) restrict2 const;
-
- void setActionActive(const InputActionT index,
- const bool value) restrict2
- {
- if (CAST_S32(index) >= 0 &&
- CAST_S32(index) < actionsSize)
- {
- mActions[CAST_SIZE(index)] = value;
- }
- }
-
- void resize(const int width, const int height) restrict2;
-
- static void unload(TouchItem *restrict const item);
-
- void unloadTouchItem(TouchItem *restrict *unloadItem) restrict2;
-
- void optionChanged(const std::string &value) restrict2 override final;
-
- void loadPad() restrict2;
-
- void loadButtons() restrict2;
-
- void loadKeyboard() restrict2;
-
- int getPadSize() restrict2 const
- { return (mJoystickSize + 2) * 50; }
-
- void setInGame(const bool b) restrict2;
-
- void setTempHide(const bool b) restrict2;
-
- void shutdown() restrict2;
-
- static void executeAction(const std::string &restrict event);
-
- private:
- TouchItem *mKeyboard;
- TouchItem *mPad;
- TouchItem *mButtons[buttonsCount] A_NONNULLPOINTER;
- TouchItemVector mObjects;
- ImageCollection *mVertexes A_NONNULLPOINTER;
- bool mActions[actionsSize];
- bool mRedraw;
- bool mShowJoystick;
- bool mShowButtons;
- bool mShowKeyboard;
- int mButtonsSize;
- int mJoystickSize;
- int mButtonsFormat;
- int mWidth;
- int mHeight;
- bool mShow;
- bool mInGame;
- bool mTempHideButtons;
-};
-
-extern TouchManager touchManager;
-
-#endif // INPUT_TOUCH_TOUCHMANAGER_H
diff --git a/src/itemcolormanager.cpp b/src/itemcolormanager.cpp
deleted file mode 100644
index c5a75239b..000000000
--- a/src/itemcolormanager.cpp
+++ /dev/null
@@ -1,57 +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/>.
- */
-
-#include "itemcolormanager.h"
-
-#include "resources/iteminfo.h"
-
-#include "resources/db/itemdb.h"
-
-#include "resources/item/cardslist.h"
-
-#include "debug.h"
-
-ItemColor ItemColorManager::getColorFromCards(const int *const cards)
-{
- if (cards == nullptr)
- return ItemColor_one;
- if (cards[0] == CARD0_FORGE ||
- cards[0] == CARD0_CREATE ||
- cards[0] == CARD0_PET)
- {
- return ItemColor_one;
- }
- for (int f = 0; f < maxCards; f ++)
- {
- const int id = cards[f];
- if (id == 0)
- continue;
- const ItemInfo &info = ItemDB::get(id);
- const ItemColor &color = info.getCardColor();
- if (color != ItemColor_zero)
- return color;
- }
- return ItemColor_one;
-}
-
-ItemColor ItemColorManager::getColorFromCards(const CardsList &cards)
-{
- return getColorFromCards(&cards.cards[0]);
-}
diff --git a/src/itemcolormanager.h b/src/itemcolormanager.h
deleted file mode 100644
index b0f87d213..000000000
--- a/src/itemcolormanager.h
+++ /dev/null
@@ -1,42 +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 ITEMCOLORMANAGER_H
-#define ITEMCOLORMANAGER_H
-
-#include "enums/simpletypes/itemcolor.h"
-
-#include "localconsts.h"
-
-struct CardsList;
-
-class ItemColorManager final
-{
- public:
- A_DELETE_COPY(ItemColorManager)
-
- static ItemColor getColorFromCards(const int *const cards)
- A_WARN_UNUSED;
-
- static ItemColor getColorFromCards(const CardsList &cards)
- A_WARN_UNUSED;
-};
-
-#endif // ITEMCOLORMANAGER_H
diff --git a/src/itemsoundmanager.cpp b/src/itemsoundmanager.cpp
deleted file mode 100644
index 060cd2392..000000000
--- a/src/itemsoundmanager.cpp
+++ /dev/null
@@ -1,68 +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 "itemsoundmanager.h"
-
-#include "soundmanager.h"
-
-#include "being/flooritem.h"
-#include "being/localplayer.h"
-
-#include "resources/iteminfo.h"
-
-#include "resources/item/item.h"
-
-#include "debug.h"
-
-void ItemSoundManager::playSfx(const Item *const item,
- const ItemSoundEvent::Type sound)
-{
- if (item == nullptr)
- return;
- playSfx(item->getId(), sound);
-}
-
-void ItemSoundManager::playSfx(const int itemId,
- const ItemSoundEvent::Type sound)
-{
- playSfx(ItemDB::get(itemId), sound);
-}
-
-void ItemSoundManager::playSfx(const FloorItem *const item,
- const ItemSoundEvent::Type sound)
-{
- if (item == nullptr)
- return;
- playSfx(ItemDB::get(item->getItemId()), sound);
-}
-
-void ItemSoundManager::playSfx(const ItemInfo &info,
- const ItemSoundEvent::Type sound)
-{
- std::string sfx = info.getSound(sound).sound;
- if (sfx.empty())
- {
- // fallback to player race sound if no item sound.
- const int id = -100 - toInt(localPlayer->getSubType(), int);
- const ItemInfo &info2 = ItemDB::get(id);
- sfx = info2.getSound(sound).sound;
- }
- soundManager.playGuiSfx(sfx);
-}
diff --git a/src/itemsoundmanager.h b/src/itemsoundmanager.h
deleted file mode 100644
index 4690eea12..000000000
--- a/src/itemsoundmanager.h
+++ /dev/null
@@ -1,50 +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 ITEMSOUNDMANAGER_H
-#define ITEMSOUNDMANAGER_H
-
-#include "enums/resources/item/itemsoundevent.h"
-
-#include "localconsts.h"
-
-class FloorItem;
-class Item;
-class ItemInfo;
-
-class ItemSoundManager final
-{
- public:
- A_DELETE_COPY(ItemSoundManager)
-
- static void playSfx(const int item,
- const ItemSoundEvent::Type sound);
-
- static void playSfx(const Item *const item,
- const ItemSoundEvent::Type sound);
-
- static void playSfx(const FloorItem *const item,
- const ItemSoundEvent::Type sound);
-
- static void playSfx(const ItemInfo &info,
- const ItemSoundEvent::Type sound);
-};
-
-#endif // ITEMSOUNDMANAGER_H
diff --git a/src/listeners/actionlistener.h b/src/listeners/actionlistener.h
deleted file mode 100644
index 4303ddda3..000000000
--- a/src/listeners/actionlistener.h
+++ /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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LISTENERS_ACTIONLISTENER_H
-#define LISTENERS_ACTIONLISTENER_H
-
-#include "events/actionevent.h"
-
-/**
- * Interface for listening for action events from widgets.
- *
- * @see Widget::addActionListener, Widget::removeActionListener,
- * ActionEvent
- * @author Olof Naessén
- * @author Per Larsson
- */
-class ActionListener notfinal
-{
- public:
- A_DELETE_COPY(ActionListener)
-
- /**
- * Destructor.
- */
- virtual ~ActionListener()
- { }
-
- /**
- * Called when an action is recieved from a widget. It is used
- * to be able to recieve a notification that an action has
- * occured.
- *
- * @param actionEvent The event of the action.
- */
- virtual void action(const ActionEvent &actionEvent) = 0;
-
- protected:
- /**
- * Constructor.
- *
- * You should not be able to make an instance of ActionListener,
- * therefore its constructor is protected.
- */
- ActionListener()
- { }
-};
-
-#endif // LISTENERS_ACTIONLISTENER_H
diff --git a/src/listeners/actorspritelistener.h b/src/listeners/actorspritelistener.h
deleted file mode 100644
index 4f4bcd799..000000000
--- a/src/listeners/actorspritelistener.h
+++ /dev/null
@@ -1,51 +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 LISTENERS_ACTORSPRITELISTENER_H
-#define LISTENERS_ACTORSPRITELISTENER_H
-
-#include "localconsts.h"
-
-class ActorSprite;
-
-class ActorSpriteListener notfinal
-{
- public:
- ActorSpriteListener()
- { }
-
- A_DELETE_COPY(ActorSpriteListener)
-
- /**
- * Destructor.
- */
- virtual ~ActorSpriteListener()
- { }
-
- /**
- * Called when the ActorSprite has been destroyed. The listener will
- * have to be registered first.
- * @param actorSprite the ActorSprite being destroyed.
- */
- virtual void actorSpriteDestroyed(const ActorSprite &actorSprite) = 0;
-};
-
-#endif // LISTENERS_ACTORSPRITELISTENER_H
diff --git a/src/listeners/arrowslistener.cpp b/src/listeners/arrowslistener.cpp
deleted file mode 100644
index 3a647f6c1..000000000
--- a/src/listeners/arrowslistener.cpp
+++ /dev/null
@@ -1,38 +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 "listeners/arrowslistener.h"
-
-#include "utils/foreach.h"
-
-#include "debug.h"
-
-defineListener(ArrowsListener)
-
-void ArrowsListener::distributeEvent()
-{
- FOR_EACH (STD_VECTOR<ArrowsListener*>::iterator,
- it, mListeners)
- {
- ArrowsListener *const listener = *it;
- if (listener != nullptr)
- listener->arrowsChanged();
- }
-}
diff --git a/src/listeners/arrowslistener.h b/src/listeners/arrowslistener.h
deleted file mode 100644
index 5dfa68d6e..000000000
--- a/src/listeners/arrowslistener.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 LISTENERS_ARROWSLISTENER_H
-#define LISTENERS_ARROWSLISTENER_H
-
-#include "listeners/baselistener.hpp"
-
-#include "localconsts.h"
-
-class ArrowsListener notfinal
-{
- public:
- A_DELETE_COPY(ArrowsListener)
-
- virtual void arrowsChanged() = 0;
-
- static void distributeEvent();
-
- defineListenerHeader(ArrowsListener)
-};
-
-#endif // LISTENERS_ARROWSLISTENER_H
diff --git a/src/listeners/assertlistener.cpp b/src/listeners/assertlistener.cpp
deleted file mode 100644
index 7df99d1fe..000000000
--- a/src/listeners/assertlistener.cpp
+++ /dev/null
@@ -1,41 +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 "listeners/assertlistener.h"
-
-#include "debug.h"
-
-AssertListener *assertListener = nullptr;
-
-AssertListener::AssertListener() :
- DebugMessageListener(),
- mMessages()
-{
-}
-
-void AssertListener::debugMessage(const std::string &msg)
-{
- mMessages.push_back(msg);
-}
-
-const StringVect &AssertListener::getMessages() const
-{
- return mMessages;
-}
diff --git a/src/listeners/assertlistener.h b/src/listeners/assertlistener.h
deleted file mode 100644
index 81712e7e2..000000000
--- a/src/listeners/assertlistener.h
+++ /dev/null
@@ -1,47 +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 LISTENERS_ASSERTLISTENER_H
-#define LISTENERS_ASSERTLISTENER_H
-
-#include "listeners/debugmessagelistener.h"
-
-#include "utils/stringvector.h"
-
-#include "localconsts.h"
-
-class AssertListener final : public DebugMessageListener
-{
- public:
- AssertListener();
-
- A_DELETE_COPY(AssertListener)
-
- void debugMessage(const std::string &msg) override final;
-
- const StringVect &getMessages() const;
-
- private:
- StringVect mMessages;
-};
-
-extern AssertListener *assertListener;
-
-#endif // LISTENERS_ASSERTLISTENER_H
diff --git a/src/listeners/attributelistener.cpp b/src/listeners/attributelistener.cpp
deleted file mode 100644
index 696f9a120..000000000
--- a/src/listeners/attributelistener.cpp
+++ /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/>.
- */
-
-#include "listeners/attributelistener.h"
-
-#include "utils/foreach.h"
-
-#include "debug.h"
-
-defineListener(AttributeListener)
-
-void AttributeListener::distributeEvent(const AttributesT id,
- const int64_t oldVal,
- const int64_t newVal)
-{
- FOR_EACH (STD_VECTOR<AttributeListener*>::iterator,
- it, mListeners)
- {
- AttributeListener *const listener = *it;
- if (listener != nullptr)
- listener->attributeChanged(id, oldVal, newVal);
- }
-}
diff --git a/src/listeners/attributelistener.h b/src/listeners/attributelistener.h
deleted file mode 100644
index 87b634af2..000000000
--- a/src/listeners/attributelistener.h
+++ /dev/null
@@ -1,46 +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 LISTENERS_ATTRIBUTELISTENER_H
-#define LISTENERS_ATTRIBUTELISTENER_H
-
-#include "enums/being/attributes.h"
-
-#include "listeners/baselistener.hpp"
-
-#include "localconsts.h"
-
-class AttributeListener notfinal
-{
- public:
- A_DELETE_COPY(AttributeListener)
-
- virtual void attributeChanged(const AttributesT id,
- const int64_t oldVal,
- const int64_t newVal) = 0;
-
- static void distributeEvent(const AttributesT id,
- const int64_t oldVal,
- const int64_t newVal);
-
- defineListenerHeader(AttributeListener)
-};
-
-#endif // LISTENERS_ATTRIBUTELISTENER_H
diff --git a/src/listeners/awaylistener.cpp b/src/listeners/awaylistener.cpp
deleted file mode 100644
index 3261fe403..000000000
--- a/src/listeners/awaylistener.cpp
+++ /dev/null
@@ -1,48 +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 "listeners/awaylistener.h"
-
-#include "gamemodifiers.h"
-#include "settings.h"
-
-#include "being/localplayer.h"
-
-#include "gui/windows/outfitwindow.h"
-
-#include "listeners/updatestatuslistener.h"
-
-#include "debug.h"
-
-void AwayListener::action(const ActionEvent &event)
-{
- if (event.getId() == "ok" &&
- localPlayer != nullptr &&
- settings.awayMode)
- {
- GameModifiers::changeAwayMode(true);
- localPlayer->updateStatus();
- if (outfitWindow != nullptr)
- outfitWindow->unwearAwayOutfit();
- UpdateStatusListener::distributeEvent();
- }
-}
diff --git a/src/listeners/awaylistener.h b/src/listeners/awaylistener.h
deleted file mode 100644
index 08fa908c7..000000000
--- a/src/listeners/awaylistener.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 LISTENERS_AWAYLISTENER_H
-#define LISTENERS_AWAYLISTENER_H
-
-#include "listeners/actionlistener.h"
-
-#include "localconsts.h"
-
-class AwayListener final : public ActionListener
-{
- public:
- AwayListener()
- { }
-
- A_DELETE_COPY(AwayListener)
-
- void action(const ActionEvent &event) override final;
-};
-
-#endif // LISTENERS_AWAYLISTENER_H
diff --git a/src/listeners/banklistener.cpp b/src/listeners/banklistener.cpp
deleted file mode 100644
index 8dfe1d808..000000000
--- a/src/listeners/banklistener.cpp
+++ /dev/null
@@ -1,38 +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 "listeners/banklistener.h"
-
-#include "utils/foreach.h"
-
-#include "debug.h"
-
-defineListener(BankListener)
-
-void BankListener::distributeEvent(const int money)
-{
- FOR_EACH (STD_VECTOR<BankListener*>::iterator,
- it, mListeners)
- {
- BankListener *const listener = *it;
- if (listener != nullptr)
- listener->bankMoneyChanged(money);
- }
-}
diff --git a/src/listeners/banklistener.h b/src/listeners/banklistener.h
deleted file mode 100644
index a71d13d05..000000000
--- a/src/listeners/banklistener.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 LISTENERS_BANKLISTENER_H
-#define LISTENERS_BANKLISTENER_H
-
-#include "listeners/baselistener.hpp"
-
-#include "localconsts.h"
-
-class BankListener notfinal
-{
- public:
- A_DELETE_COPY(BankListener)
-
- virtual void bankMoneyChanged(const int money) = 0;
-
- static void distributeEvent(const int money);
-
- defineListenerHeader(BankListener)
-};
-
-#endif // LISTENERS_BANKLISTENER_H
diff --git a/src/listeners/baselistener.hpp b/src/listeners/baselistener.hpp
deleted file mode 100644
index 7afb429d5..000000000
--- a/src/listeners/baselistener.hpp
+++ /dev/null
@@ -1,70 +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 LISTENERS_BASELISTENER_HPP
-#define LISTENERS_BASELISTENER_HPP
-
-#include "utils/vector.h"
-
-#define defineListener(name) \
- STD_VECTOR<name*> name::mListeners; \
- \
- name::name() \
- { \
- addListener(this); \
- } \
- \
- name::~name() \
- { \
- removeListener(this); \
- } \
- \
- void name::addListener(name *const listener) \
- { \
- if (listener) \
- mListeners.push_back(listener); \
- } \
- \
- void name::removeListener(const name *const listener) \
- { \
- STD_VECTOR<name*>::iterator it = mListeners.begin(); \
- while (it != mListeners.end()) \
- { \
- if (*it == listener) \
- it = mListeners.erase(it); \
- else \
- ++ it; \
- } \
- }
-
-#define defineListenerHeader(name) \
- public: \
- name(); \
- \
- virtual ~name(); \
- \
- static void addListener(name *const listener); \
- \
- static void removeListener(const name *const listener); \
- \
- private: \
- static STD_VECTOR<name*> mListeners;
-
-#endif // LISTENERS_BASELISTENER_HPP
diff --git a/src/listeners/buyingstoremodelistener.cpp b/src/listeners/buyingstoremodelistener.cpp
deleted file mode 100644
index 7ce95033c..000000000
--- a/src/listeners/buyingstoremodelistener.cpp
+++ /dev/null
@@ -1,38 +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 "listeners/buyingstoremodelistener.h"
-
-#include "utils/foreach.h"
-
-#include "debug.h"
-
-defineListener(BuyingStoreModeListener)
-
-void BuyingStoreModeListener::distributeEvent(const bool b)
-{
- FOR_EACH (STD_VECTOR<BuyingStoreModeListener*>::iterator,
- it, mListeners)
- {
- BuyingStoreModeListener *const listener = *it;
- if (listener != nullptr)
- listener->buyingStoreEnabled(b);
- }
-}
diff --git a/src/listeners/buyingstoremodelistener.h b/src/listeners/buyingstoremodelistener.h
deleted file mode 100644
index 5da4e901e..000000000
--- a/src/listeners/buyingstoremodelistener.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 LISTENERS_BUYINGSTOREMODELISTENER_H
-#define LISTENERS_BUYINGSTOREMODELISTENER_H
-
-#include "listeners/baselistener.hpp"
-
-#include "localconsts.h"
-
-class BuyingStoreModeListener notfinal
-{
- public:
- A_DELETE_COPY(BuyingStoreModeListener)
-
- virtual void buyingStoreEnabled(const bool b) = 0;
-
- static void distributeEvent(const bool b);
-
- defineListenerHeader(BuyingStoreModeListener)
-};
-
-#endif // LISTENERS_BUYINGSTOREMODELISTENER_H
diff --git a/src/listeners/buyingstoreslotslistener.cpp b/src/listeners/buyingstoreslotslistener.cpp
deleted file mode 100644
index 5afeaaa48..000000000
--- a/src/listeners/buyingstoreslotslistener.cpp
+++ /dev/null
@@ -1,38 +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 "listeners/buyingstoreslotslistener.h"
-
-#include "utils/foreach.h"
-
-#include "debug.h"
-
-defineListener(BuyingStoreSlotsListener)
-
-void BuyingStoreSlotsListener::distributeEvent(const int slots)
-{
- FOR_EACH (STD_VECTOR<BuyingStoreSlotsListener*>::iterator,
- it, mListeners)
- {
- BuyingStoreSlotsListener *const listener = *it;
- if (listener != nullptr)
- listener->buyingStoreSlotsChanged(slots);
- }
-}
diff --git a/src/listeners/buyingstoreslotslistener.h b/src/listeners/buyingstoreslotslistener.h
deleted file mode 100644
index d508069c3..000000000
--- a/src/listeners/buyingstoreslotslistener.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 LISTENERS_BUYINGSTORESLOTSLISTENER_H
-#define LISTENERS_BUYINGSTORESLOTSLISTENER_H
-
-#include "listeners/baselistener.hpp"
-
-#include "localconsts.h"
-
-class BuyingStoreSlotsListener notfinal
-{
- public:
- A_DELETE_COPY(BuyingStoreSlotsListener)
-
- virtual void buyingStoreSlotsChanged(const int slots) = 0;
-
- static void distributeEvent(const int slots);
-
- defineListenerHeader(BuyingStoreSlotsListener)
-};
-
-#endif // LISTENERS_BUYINGSTORESLOTSLISTENER_H
diff --git a/src/listeners/charrenamelistener.cpp b/src/listeners/charrenamelistener.cpp
deleted file mode 100644
index 0ac83b39c..000000000
--- a/src/listeners/charrenamelistener.cpp
+++ /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/>.
- */
-
-#include "listeners/charrenamelistener.h"
-
-#include "gui/windows/editdialog.h"
-
-#include "net/charserverhandler.h"
-
-#include "debug.h"
-
-CharRenameListener charRenameListener;
-
-CharRenameListener::CharRenameListener() :
- ActionListener(),
- mDialog(nullptr),
- mId(BeingId_zero)
-{
-}
-
-void CharRenameListener::action(const ActionEvent &event)
-{
- if (event.getId() != "OK")
- return;
- if (mDialog != nullptr)
- {
- if (charServerHandler != nullptr)
- charServerHandler->renameCharacter(mId, mDialog->getMsg());
- mDialog = nullptr;
- }
-}
diff --git a/src/listeners/charrenamelistener.h b/src/listeners/charrenamelistener.h
deleted file mode 100644
index c66fe7c5d..000000000
--- a/src/listeners/charrenamelistener.h
+++ /dev/null
@@ -1,54 +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 LISTENERS_CHARRENAMELISTENER_H
-#define LISTENERS_CHARRENAMELISTENER_H
-
-#include "enums/simpletypes/beingid.h"
-
-#include "listeners/actionlistener.h"
-
-#include "localconsts.h"
-
-class EditDialog;
-
-class CharRenameListener final : public ActionListener
-{
- public:
- CharRenameListener();
-
- A_DELETE_COPY(CharRenameListener)
-
- void action(const ActionEvent &event) override final;
-
- void setId(const BeingId id)
- { mId = id; }
-
- void setDialog(EditDialog *const dialog)
- { mDialog = dialog; }
-
- protected:
- EditDialog *mDialog;
- BeingId mId;
-};
-
-extern CharRenameListener charRenameListener;
-
-#endif // LISTENERS_CHARRENAMELISTENER_H
diff --git a/src/listeners/configlistener.h b/src/listeners/configlistener.h
deleted file mode 100644
index 76250eea6..000000000
--- a/src/listeners/configlistener.h
+++ /dev/null
@@ -1,57 +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 LISTENERS_CONFIGLISTENER_H
-#define LISTENERS_CONFIGLISTENER_H
-
-#include <string>
-
-#include "localconsts.h"
-
-/**
- * The listener interface for receiving notifications about changes to
- * configuration options.
- *
- * \ingroup CORE
- */
-class ConfigListener notfinal
-{
- public:
- ConfigListener()
- { }
-
- A_DELETE_COPY(ConfigListener)
-
- /**
- * Destructor.
- */
- virtual ~ConfigListener()
- { }
-
- /**
- * Called when an option changed. The config listener will have to be
- * registered to the option name first.
- */
- virtual void optionChanged(const std::string &name) = 0;
-};
-
-#endif // LISTENERS_CONFIGLISTENER_H
diff --git a/src/listeners/debugmessagelistener.cpp b/src/listeners/debugmessagelistener.cpp
deleted file mode 100644
index b759e7c14..000000000
--- a/src/listeners/debugmessagelistener.cpp
+++ /dev/null
@@ -1,38 +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 "listeners/debugmessagelistener.h"
-
-#include "utils/foreach.h"
-
-#include "debug.h"
-
-defineListener(DebugMessageListener)
-
-void DebugMessageListener::distributeEvent(const std::string &msg)
-{
- FOR_EACH (STD_VECTOR<DebugMessageListener*>::iterator,
- it, mListeners)
- {
- DebugMessageListener *const listener = *it;
- if (listener != nullptr)
- listener->debugMessage(msg);
- }
-}
diff --git a/src/listeners/debugmessagelistener.h b/src/listeners/debugmessagelistener.h
deleted file mode 100644
index 2e981cfbf..000000000
--- a/src/listeners/debugmessagelistener.h
+++ /dev/null
@@ -1,42 +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 LISTENERS_DEBUGMESSAGELISTENER_H
-#define LISTENERS_DEBUGMESSAGELISTENER_H
-
-#include "listeners/baselistener.hpp"
-
-#include <string>
-
-#include "localconsts.h"
-
-class DebugMessageListener notfinal
-{
- public:
- A_DELETE_COPY(DebugMessageListener)
-
- virtual void debugMessage(const std::string &msg) = 0;
-
- static void distributeEvent(const std::string &msg);
-
- defineListenerHeader(DebugMessageListener)
-};
-
-#endif // LISTENERS_DEBUGMESSAGELISTENER_H
diff --git a/src/listeners/errorlistener.cpp b/src/listeners/errorlistener.cpp
deleted file mode 100644
index 17f30fbf9..000000000
--- a/src/listeners/errorlistener.cpp
+++ /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/>.
- */
-
-#include "listeners/errorlistener.h"
-
-#include "client.h"
-#include "settings.h"
-
-#include "utils/process.h"
-
-#include "debug.h"
-
-ErrorListener errorListener;
-
-void ErrorListener::action(const ActionEvent &event)
-{
- if (event.getId() == "yes")
- openBrowser(settings.supportUrl);
- client->setState(State::CHOOSE_SERVER);
-}
diff --git a/src/listeners/errorlistener.h b/src/listeners/errorlistener.h
deleted file mode 100644
index 6573e8107..000000000
--- a/src/listeners/errorlistener.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 LISTENERS_ERRORLISTENER_H
-#define LISTENERS_ERRORLISTENER_H
-
-#include "listeners/actionlistener.h"
-
-#include "localconsts.h"
-
-class ErrorListener final : public ActionListener
-{
- public:
- ErrorListener() :
- ActionListener()
- { }
-
- A_DELETE_COPY(ErrorListener)
-
- void action(const ActionEvent &event) override final;
-};
-
-extern ErrorListener errorListener;
-
-#endif // LISTENERS_ERRORLISTENER_H
diff --git a/src/listeners/focuslistener.h b/src/listeners/focuslistener.h
deleted file mode 100644
index 013d8137b..000000000
--- a/src/listeners/focuslistener.h
+++ /dev/null
@@ -1,115 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LISTENERS_FOCUSLISTENER_H
-#define LISTENERS_FOCUSLISTENER_H
-
-#include "events/event.h"
-
-#include "localconsts.h"
-
-/**
- * Interface for listening for focus events from widgets.
- *
- * @see Widget::addFocusListener, Widget::removeFocusListener
- * @author Olof Naessén
- */
-class FocusListener notfinal
-{
- public:
- A_DELETE_COPY(FocusListener)
-
- /**
- * Destructor.
- */
- virtual ~FocusListener()
- { }
-
- /**
- * Called when a widget gains focus.
- *
- * @param event Discribes the event.
- */
- virtual void focusGained(const Event &event A_UNUSED)
- { }
-
- /**
- * Called when a widget loses focus.
- *
- * @param event Discribes the event.
- */
- virtual void focusLost(const Event &event A_UNUSED)
- { }
-
- protected:
- /**
- * Constructor.
- *
- * You should not be able to make an instance of FocusListener,
- * therefore its constructor is protected.
- */
- FocusListener()
- { }
-};
-
-#endif // LISTENERS_FOCUSLISTENER_H
diff --git a/src/listeners/gamemodifierlistener.cpp b/src/listeners/gamemodifierlistener.cpp
deleted file mode 100644
index ad17b186b..000000000
--- a/src/listeners/gamemodifierlistener.cpp
+++ /dev/null
@@ -1,38 +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 "listeners/gamemodifierlistener.h"
-
-#include "utils/foreach.h"
-
-#include "debug.h"
-
-defineListener(GameModifierListener)
-
-void GameModifierListener::distributeEvent()
-{
- FOR_EACH (STD_VECTOR<GameModifierListener*>::iterator,
- it, mListeners)
- {
- GameModifierListener *const listener = *it;
- if (listener != nullptr)
- listener->gameModifiersChanged();
- }
-}
diff --git a/src/listeners/gamemodifierlistener.h b/src/listeners/gamemodifierlistener.h
deleted file mode 100644
index 86635f5df..000000000
--- a/src/listeners/gamemodifierlistener.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 LISTENERS_GAMEMODIFIERLISTENER_H
-#define LISTENERS_GAMEMODIFIERLISTENER_H
-
-#include "listeners/baselistener.hpp"
-
-#include "localconsts.h"
-
-class GameModifierListener notfinal
-{
- public:
- A_DELETE_COPY(GameModifierListener)
-
- virtual void gameModifiersChanged() = 0;
-
- static void distributeEvent();
-
- defineListenerHeader(GameModifierListener)
-};
-
-#endif // LISTENERS_GAMEMODIFIERLISTENER_H
diff --git a/src/listeners/guiconfiglistener.h b/src/listeners/guiconfiglistener.h
deleted file mode 100644
index 9d0788b38..000000000
--- a/src/listeners/guiconfiglistener.h
+++ /dev/null
@@ -1,61 +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 LISTENERS_GUICONFIGLISTENER_H
-#define LISTENERS_GUICONFIGLISTENER_H
-
-#include "configuration.h"
-
-#include "gui/gui.h"
-
-#include "listeners/configlistener.h"
-
-#include "localconsts.h"
-
-class GuiConfigListener final : public ConfigListener
-{
- public:
- explicit GuiConfigListener(Gui *const g) :
- mGui(g)
- {}
-
- A_DELETE_COPY(GuiConfigListener)
-
- virtual ~GuiConfigListener()
- {
- CHECKLISTENERS
- }
-
- void optionChanged(const std::string &name) override final
- {
- if (mGui == nullptr)
- return;
- if (name == "customcursor")
- mGui->setUseCustomCursor(config.getBoolValue("customcursor"));
- else if (name == "doubleClick")
- mGui->setDoubleClick(config.getBoolValue("doubleClick"));
- }
- private:
- Gui *mGui;
-};
-
-#endif // LISTENERS_GUICONFIGLISTENER_H
diff --git a/src/listeners/guitableactionlistener.cpp b/src/listeners/guitableactionlistener.cpp
deleted file mode 100644
index 2abcaaf6e..000000000
--- a/src/listeners/guitableactionlistener.cpp
+++ /dev/null
@@ -1,64 +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 "listeners/guitableactionlistener.h"
-
-#include "gui/widgets/guitable.h"
-
-#include "debug.h"
-
-GuiTableActionListener::GuiTableActionListener(GuiTable *const restrict table,
- Widget *const restrict widget,
- const int row,
- const int column) :
- ActionListener(),
- mTable(table),
- mRow(row),
- mColumn(column),
- mWidget(widget)
-{
- if ((widget != nullptr) && (table != nullptr))
- {
- widget->addActionListener(this);
- widget->setParent(table);
- widget->setWindow(table->getWindow());
- }
-}
-
-GuiTableActionListener::~GuiTableActionListener()
-{
- if (mWidget != nullptr)
- {
- mWidget->removeActionListener(this);
- mWidget->setWindow(nullptr);
- mWidget->setParent(nullptr);
- }
-}
-
-void GuiTableActionListener::action(const ActionEvent &actionEvent A_UNUSED)
-{
- if (mTable != nullptr)
- {
- mTable->setSelected(mRow, mColumn);
- mTable->distributeActionEvent();
- }
-}
diff --git a/src/listeners/guitableactionlistener.h b/src/listeners/guitableactionlistener.h
deleted file mode 100644
index 08ec04d62..000000000
--- a/src/listeners/guitableactionlistener.h
+++ /dev/null
@@ -1,53 +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 LISTENERS_GUITABLEACTIONLISTENER_H
-#define LISTENERS_GUITABLEACTIONLISTENER_H
-
-#include "listeners/actionlistener.h"
-
-#include "localconsts.h"
-
-class GuiTable;
-
-class GuiTableActionListener final : public ActionListener
-{
- public:
- GuiTableActionListener(GuiTable *const restrict table,
- Widget *const restrict widget,
- const int row,
- const int column);
-
- A_DELETE_COPY(GuiTableActionListener)
-
- ~GuiTableActionListener();
-
- void action(const ActionEvent& actionEvent) override final;
-
- protected:
- GuiTable *mTable;
- int mRow;
- int mColumn;
- Widget *mWidget;
-};
-
-#endif // LISTENERS_GUITABLEACTIONLISTENER_H
diff --git a/src/listeners/inputactionremotelistener.cpp b/src/listeners/inputactionremotelistener.cpp
deleted file mode 100644
index 2a7da94b5..000000000
--- a/src/listeners/inputactionremotelistener.cpp
+++ /dev/null
@@ -1,50 +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 "listeners/inputactionremotelistener.h"
-
-#include "input/inputmanager.h"
-
-#include "debug.h"
-
-InputActionRemoteListener inputActionRemoteListener;
-
-InputActionRemoteListener::InputActionRemoteListener() :
- ActionListener(),
- mCommand(),
- mArgs()
-{
-}
-
-void InputActionRemoteListener::action(const ActionEvent &event)
-{
- if (event.getId() != "yes")
- {
- mCommand.clear();
- mArgs.clear();
- return;
- }
-
- inputManager.executeRemoteChatCommand(mCommand,
- mArgs,
- nullptr);
- mCommand.clear();
- mArgs.clear();
-}
diff --git a/src/listeners/inputactionremotelistener.h b/src/listeners/inputactionremotelistener.h
deleted file mode 100644
index c259ce3cf..000000000
--- a/src/listeners/inputactionremotelistener.h
+++ /dev/null
@@ -1,51 +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 LISTENERS_INPUTACTIONREMOTELISTENER_H
-#define LISTENERS_INPUTACTIONREMOTELISTENER_H
-
-#include "listeners/actionlistener.h"
-
-#include "localconsts.h"
-
-class InputActionRemoteListener final : public ActionListener
-{
- public:
- InputActionRemoteListener();
-
- A_DELETE_COPY(InputActionRemoteListener)
-
- void action(const ActionEvent &event) override final;
-
- void setCommand(const std::string &command,
- const std::string &args)
- {
- mCommand = command;
- mArgs = args;
- }
-
- protected:
- std::string mCommand;
- std::string mArgs;
-};
-
-extern InputActionRemoteListener inputActionRemoteListener;
-
-#endif // LISTENERS_INPUTACTIONREMOTELISTENER_H
diff --git a/src/listeners/inputactionreplaylistener.cpp b/src/listeners/inputactionreplaylistener.cpp
deleted file mode 100644
index 8efa2bb19..000000000
--- a/src/listeners/inputactionreplaylistener.cpp
+++ /dev/null
@@ -1,66 +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 "listeners/inputactionreplaylistener.h"
-
-#include "gui/windows/editdialog.h"
-
-#include "gui/widgets/createwidget.h"
-
-#include "input/inputmanager.h"
-
-#include "debug.h"
-
-InputActionReplayListener inputActionReplayListener;
-
-InputActionReplayListener::InputActionReplayListener() :
- ActionListener(),
- mDialog(nullptr),
- mAction(InputAction::NO_VALUE)
-{
-}
-
-void InputActionReplayListener::openDialog(const std::string &caption,
- const std::string &text,
- const InputActionT action0)
-{
- CREATEWIDGETV(mDialog, EditDialog,
- caption, text, "OK");
- mDialog->addActionListener(this);
- mAction = action0;
-}
-
-void InputActionReplayListener::action(const ActionEvent &event)
-{
- if (event.getId() != "OK")
- {
- mDialog = nullptr;
- mAction = InputAction::NO_VALUE;
- return;
- }
- if (mDialog != nullptr)
- {
- inputManager.executeChatCommand(mAction,
- mDialog->getMsg(),
- nullptr);
- mDialog = nullptr;
- }
- mAction = InputAction::NO_VALUE;
-}
diff --git a/src/listeners/inputactionreplaylistener.h b/src/listeners/inputactionreplaylistener.h
deleted file mode 100644
index a22b52da4..000000000
--- a/src/listeners/inputactionreplaylistener.h
+++ /dev/null
@@ -1,55 +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 LISTENERS_INPUTACTIONREPLAYLISTENER_H
-#define LISTENERS_INPUTACTIONREPLAYLISTENER_H
-
-#include "enums/input/inputaction.h"
-
-#include "listeners/actionlistener.h"
-
-#include "localconsts.h"
-
-class EditDialog;
-
-class InputActionReplayListener final : public ActionListener
-{
- public:
- InputActionReplayListener();
-
- A_DELETE_COPY(InputActionReplayListener)
-
- void action(const ActionEvent &event) override final;
-
- void setDialog(EditDialog *const dialog)
- { mDialog = dialog; }
-
- void openDialog(const std::string &caption,
- const std::string &text,
- const InputActionT action0);
-
- protected:
- EditDialog *mDialog;
- InputActionT mAction;
-};
-
-extern InputActionReplayListener inputActionReplayListener;
-
-#endif // LISTENERS_INPUTACTIONREPLAYLISTENER_H
diff --git a/src/listeners/insertcardlistener.h b/src/listeners/insertcardlistener.h
deleted file mode 100644
index db963332a..000000000
--- a/src/listeners/insertcardlistener.h
+++ /dev/null
@@ -1,54 +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 LISTENERS_INSERTCARDLISTENER_H
-#define LISTENERS_INSERTCARDLISTENER_H
-
-#include "listeners/actionlistener.h"
-
-#include "net/inventoryhandler.h"
-
-#include "localconsts.h"
-
-struct InsertCardListener final : public ActionListener
-{
- InsertCardListener() :
- ActionListener(),
- cardIndex(0),
- itemIndex(0)
- {
- }
-
- A_DELETE_COPY(InsertCardListener)
-
- public:
- void action(const ActionEvent &event) override final
- {
- if (event.getId() == "yes" && (inventoryHandler != nullptr))
- inventoryHandler->insertCard(cardIndex, itemIndex);
- }
-
- int cardIndex;
- int itemIndex;
-};
-
-#endif // LISTENERS_INSERTCARDLISTENER_H
diff --git a/src/listeners/inventorylistener.h b/src/listeners/inventorylistener.h
deleted file mode 100644
index c8ca86dcb..000000000
--- a/src/listeners/inventorylistener.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 LISTENERS_INVENTORYLISTENER_H
-#define LISTENERS_INVENTORYLISTENER_H
-
-#include "localconsts.h"
-
-class Inventory;
-
-class InventoryListener notfinal
-{
- public:
- A_DELETE_COPY(InventoryListener)
-
- virtual ~InventoryListener()
- { }
-
- virtual void slotsChanged(const Inventory *const inventory) = 0;
-
- protected:
- InventoryListener()
- { }
-};
-
-#endif // LISTENERS_INVENTORYLISTENER_H
diff --git a/src/listeners/keylistener.h b/src/listeners/keylistener.h
deleted file mode 100644
index e89e6d9d1..000000000
--- a/src/listeners/keylistener.h
+++ /dev/null
@@ -1,118 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LISTENERS_KEYLISTENER_H
-#define LISTENERS_KEYLISTENER_H
-
-#include "events/keyevent.h"
-
-#include "localconsts.h"
-
-class Key;
-
-/**
- * Interface for listening for key events from widgets.
- *
- * @see Widget::addKeyListener, Widget::removeKeyListener
- */
-class KeyListener notfinal
-{
- public:
- A_DELETE_COPY(KeyListener)
-
- /**
- * Destructor.
- */
- virtual ~KeyListener()
- { }
-
- /**
- * Called if a key is pressed when the widget has keyboard focus.
- * If a key is held down the widget will generate multiple key
- * presses.
- *
- * @param event Discribes the event.
- */
- virtual void keyPressed(KeyEvent &event A_UNUSED)
- { }
-
- /**
- * Called if a key is released when the widget has keyboard focus.
- *
- * @param event Discribes the event.
- */
- virtual void keyReleased(KeyEvent &event A_UNUSED)
- { }
-
- protected:
- /**
- * Constructor.
- *
- * You should not be able to make an instance of KeyListener,
- * therefore its constructor is protected.
- */
- KeyListener()
- { }
-};
-
-#endif // LISTENERS_KEYLISTENER_H
diff --git a/src/listeners/mouselistener.h b/src/listeners/mouselistener.h
deleted file mode 100644
index cebc89e60..000000000
--- a/src/listeners/mouselistener.h
+++ /dev/null
@@ -1,185 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LISTENERS_MOUSELISTENER_H
-#define LISTENERS_MOUSELISTENER_H
-
-#include "events/mouseevent.h"
-
-#include "localconsts.h"
-
-/**
- * Interface for listening for mouse events from widgets.
- *
- * @see Widget::addMouseListener, Widget::removeMouseListener
- */
-class MouseListener notfinal
-{
- public:
- A_DELETE_COPY(MouseListener)
-
- /**
- * Destructor.
- */
- virtual ~MouseListener()
- { }
-
- /**
- * Called when the mouse has entered into the widget area.
- *
- * @param event Describes the event.
- */
- virtual void mouseEntered(MouseEvent &event A_UNUSED)
- {
- }
-
- /**
- * Called when the mouse has exited the widget area.
- *
- * @param event Describes the event.
- */
- virtual void mouseExited(MouseEvent &event A_UNUSED)
- {
- }
-
- /**
- * Called when a mouse button has been pressed on the widget area.
- *
- * NOTE: A mouse press is NOT equal to a mouse click.
- * Use mouseClickMessage to check for mouse clicks.
- *
- * @param event Describes the event.
- */
- virtual void mousePressed(MouseEvent &event A_UNUSED)
- {
- }
-
- /**
- * Called when a mouse button has been released on the widget area.
- *
- * @param event Describes the event.
- */
- virtual void mouseReleased(MouseEvent &event A_UNUSED)
- {
- }
-
- /**
- * Called when a mouse button is pressed and released (clicked) on
- * the widget area.
- *
- * @param event Describes the event.
- */
- virtual void mouseClicked(MouseEvent &event A_UNUSED)
- {
- }
-
- /**
- * Called when the mouse wheel has moved up on the widget area.
- *
- * @param event Describes the event.
- */
- virtual void mouseWheelMovedUp(MouseEvent &event A_UNUSED)
- {
- }
-
- /**
- * Called when the mouse wheel has moved down on the widget area.
- *
- * @param event Describes the event.
- */
- virtual void mouseWheelMovedDown(MouseEvent &event A_UNUSED)
- {
- }
-
- /**
- * Called when the mouse has moved in the widget area and no mouse button
- * has been pressed (i.e no widget is being dragged).
- *
- * @param event Describes the event.
- */
- virtual void mouseMoved(MouseEvent &event A_UNUSED)
- {
- }
-
- /**
- * Called when the mouse has moved and the mouse has previously been
- * pressed on the widget.
- *
- * @param event Describes the event.
- */
- virtual void mouseDragged(MouseEvent &event A_UNUSED)
- {
- }
-
- protected:
- /**
- * Constructor.
- *
- * You should not be able to make an instance of MouseListener,
- * therefore its constructor is protected.
- */
- MouseListener()
- { }
-};
-
-#endif // LISTENERS_MOUSELISTENER_H
diff --git a/src/listeners/openurllistener.h b/src/listeners/openurllistener.h
deleted file mode 100644
index cb836c67e..000000000
--- a/src/listeners/openurllistener.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 LISTENERS_OPENURLLISTENER_H
-#define LISTENERS_OPENURLLISTENER_H
-
-#include "listeners/actionlistener.h"
-
-#include "utils/process.h"
-
-#include "localconsts.h"
-
-struct OpenUrlListener final : public ActionListener
-{
- OpenUrlListener() :
- ActionListener(),
- url()
- {
- }
-
- A_DELETE_COPY(OpenUrlListener)
-
- public:
- void action(const ActionEvent &event) override final
- {
- if (event.getId() == "yes")
- openBrowser(url);
- }
-
- std::string url;
-};
-
-#endif // LISTENERS_OPENURLLISTENER_H
diff --git a/src/listeners/pincodelistener.cpp b/src/listeners/pincodelistener.cpp
deleted file mode 100644
index 5b3c757d1..000000000
--- a/src/listeners/pincodelistener.cpp
+++ /dev/null
@@ -1,40 +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 "listeners/pincodelistener.h"
-
-#include "net/charserverhandler.h"
-
-#include "gui/windows/editdialog.h"
-
-#include "debug.h"
-
-PincodeListener pincodeListener;
-
-void PincodeListener::action(const ActionEvent &event)
-{
- const EditDialog *const dialog = dynamic_cast<EditDialog*>(
- event.getSource());
- if (dialog != nullptr)
- {
- const std::string pincode = dialog->getMsg();
- charServerHandler->setNewPincode(pincode);
- }
-}
diff --git a/src/listeners/pincodelistener.h b/src/listeners/pincodelistener.h
deleted file mode 100644
index 45bce5be3..000000000
--- a/src/listeners/pincodelistener.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 LISTENERS_PINCODELISTENER_H
-#define LISTENERS_PINCODELISTENER_H
-
-#include "listeners/actionlistener.h"
-
-#include "localconsts.h"
-
-class PincodeListener final : public ActionListener
-{
- public:
- PincodeListener() :
- ActionListener()
- { }
-
- A_DELETE_COPY(PincodeListener)
-
- void action(const ActionEvent &event) override final;
-};
-
-extern PincodeListener pincodeListener;
-
-#endif // LISTENERS_PINCODELISTENER_H
diff --git a/src/listeners/playerdeathlistener.cpp b/src/listeners/playerdeathlistener.cpp
deleted file mode 100644
index 5a20d64e9..000000000
--- a/src/listeners/playerdeathlistener.cpp
+++ /dev/null
@@ -1,38 +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 "listeners/playerdeathlistener.h"
-
-#include "utils/foreach.h"
-
-#include "debug.h"
-
-defineListener(PlayerDeathListener)
-
-void PlayerDeathListener::distributeEvent()
-{
- FOR_EACH (STD_VECTOR<PlayerDeathListener*>::iterator,
- it, mListeners)
- {
- PlayerDeathListener *const listener = *it;
- if (listener != nullptr)
- listener->playerDeath();
- }
-}
diff --git a/src/listeners/playerdeathlistener.h b/src/listeners/playerdeathlistener.h
deleted file mode 100644
index 2e9ea99a9..000000000
--- a/src/listeners/playerdeathlistener.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 LISTENERS_PLAYERDEATHLISTENER_H
-#define LISTENERS_PLAYERDEATHLISTENER_H
-
-#include "listeners/baselistener.hpp"
-
-#include "localconsts.h"
-
-class PlayerDeathListener notfinal
-{
- public:
- A_DELETE_COPY(PlayerDeathListener)
-
- virtual void playerDeath() = 0;
-
- static void distributeEvent();
-
- defineListenerHeader(PlayerDeathListener)
-};
-
-#endif // LISTENERS_PLAYERDEATHLISTENER_H
diff --git a/src/listeners/playerlistener.cpp b/src/listeners/playerlistener.cpp
deleted file mode 100644
index 62a749b6e..000000000
--- a/src/listeners/playerlistener.cpp
+++ /dev/null
@@ -1,51 +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 "listeners/playerlistener.h"
-
-#include "actormanager.h"
-
-#include "being/being.h"
-
-#include "gui/windows/textdialog.h"
-
-#include "debug.h"
-
-PlayerListener::PlayerListener() :
- ActionListener(),
- mNick(),
- mDialog(nullptr),
- mType(ActorType::Unknown)
-{
-}
-
-void PlayerListener::action(const ActionEvent &event)
-{
- if (event.getId() == "ok" && !mNick.empty() && (mDialog != nullptr))
- {
- std::string comment = mDialog->getText();
- Being *const being = actorManager->findBeingByName(
- mNick, static_cast<ActorTypeT>(mType));
- if (being != nullptr)
- being->setComment(comment);
- Being::saveComment(mNick, comment, mType);
- }
- mDialog = nullptr;
-}
diff --git a/src/listeners/playerlistener.h b/src/listeners/playerlistener.h
deleted file mode 100644
index 0f2992bb5..000000000
--- a/src/listeners/playerlistener.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 LISTENERS_PLAYERLISTENER_H
-#define LISTENERS_PLAYERLISTENER_H
-
-#include "enums/being/actortype.h"
-
-#include "listeners/actionlistener.h"
-
-#include "localconsts.h"
-
-class TextDialog;
-
-class PlayerListener final : public ActionListener
-{
- public:
- PlayerListener();
-
- A_DELETE_COPY(PlayerListener)
-
- void action(const ActionEvent &event) override final;
-
- void setNick(const std::string &name)
- { mNick = name; }
-
- void setDialog(TextDialog *const dialog)
- { mDialog = dialog; }
-
- void setType(const ActorTypeT type)
- { mType = type; }
-
- private:
- std::string mNick;
- TextDialog *mDialog;
- ActorTypeT mType;
-};
-
-#endif // LISTENERS_PLAYERLISTENER_H
diff --git a/src/listeners/playerpostdeathlistener.h b/src/listeners/playerpostdeathlistener.h
deleted file mode 100644
index 2a5f86235..000000000
--- a/src/listeners/playerpostdeathlistener.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 LISTENERS_PLAYERPOSTDEATHLISTENER_H
-#define LISTENERS_PLAYERPOSTDEATHLISTENER_H
-
-#include "being/localplayer.h"
-
-#include "gui/dialogsmanager.h"
-#include "gui/popupmanager.h"
-
-#include "gui/windows/npcdialog.h"
-
-#include "net/playerhandler.h"
-
-#include "localconsts.h"
-
-extern OkDialog *deathNotice;
-
-/**
- * Listener used for handling death message.
- */
-struct PlayerPostDeathListener final : public ActionListener
-{
- PlayerPostDeathListener() :
- ActionListener()
- { }
-
- A_DELETE_COPY(PlayerPostDeathListener)
-
- void action(const ActionEvent &event A_UNUSED) override final
- {
- if (playerHandler != nullptr)
- playerHandler->respawn();
- deathNotice = nullptr;
-
- DialogsManager::closeDialogs();
- PopupManager::closePopupMenu();
-
- NpcDialog::clearDialogs();
- if (localPlayer != nullptr)
- localPlayer->respawn();
- }
-};
-
-#endif // LISTENERS_PLAYERPOSTDEATHLISTENER_H
diff --git a/src/listeners/playerrelationslistener.h b/src/listeners/playerrelationslistener.h
deleted file mode 100644
index ced919964..000000000
--- a/src/listeners/playerrelationslistener.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 LISTENERS_PLAYERRELATIONSLISTENER_H
-#define LISTENERS_PLAYERRELATIONSLISTENER_H
-
-#include <string>
-
-#include "localconsts.h"
-
-class PlayerRelationsListener notfinal
-{
- public:
- A_DELETE_COPY(PlayerRelationsListener)
-
- virtual ~PlayerRelationsListener()
- { }
-
- virtual void updatedPlayer(const std::string &name) = 0;
-
- virtual void updateAll() = 0;
-
- protected:
- PlayerRelationsListener()
- { }
-};
-
-#endif // LISTENERS_PLAYERRELATIONSLISTENER_H
diff --git a/src/listeners/renamelistener.cpp b/src/listeners/renamelistener.cpp
deleted file mode 100644
index b8bc19883..000000000
--- a/src/listeners/renamelistener.cpp
+++ /dev/null
@@ -1,80 +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 "listeners/renamelistener.h"
-
-#include "gui/viewport.h"
-
-#include "gui/windows/socialwindow.h"
-#include "gui/windows/textdialog.h"
-
-#include "resources/map/map.h"
-#include "resources/map/mapitem.h"
-#include "resources/map/speciallayer.h"
-
-#include "debug.h"
-
-RenameListener::RenameListener() :
- ActionListener(),
- mMapItemX(0),
- mMapItemY(0),
- mDialog(nullptr)
-{
-}
-
-void RenameListener::setMapItem(const MapItem *const mapItem)
-{
- if (mapItem != nullptr)
- {
- mMapItemX = mapItem->getX();
- mMapItemY = mapItem->getY();
- }
- else
- {
- mMapItemX = 0;
- mMapItemY = 0;
- }
-}
-
-void RenameListener::action(const ActionEvent &event)
-{
- if (event.getId() == "ok" && (viewport != nullptr) && (mDialog != nullptr))
- {
- const Map *const map = viewport->getMap();
- if (map == nullptr)
- return;
-
- const SpecialLayer *const sl = map->getSpecialLayer();
- MapItem *item = nullptr;
- if (sl != nullptr)
- {
- item = sl->getTile(mMapItemX, mMapItemY);
- if (item != nullptr)
- item->setComment(mDialog->getText());
- }
- item = map->findPortalXY(mMapItemX, mMapItemY);
- if (item != nullptr)
- item->setComment(mDialog->getText());
-
- if (socialWindow != nullptr)
- socialWindow->updatePortalNames();
- }
- mDialog = nullptr;
-}
diff --git a/src/listeners/renamelistener.h b/src/listeners/renamelistener.h
deleted file mode 100644
index 87355116a..000000000
--- a/src/listeners/renamelistener.h
+++ /dev/null
@@ -1,51 +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 LISTENERS_RENAMELISTENER_H
-#define LISTENERS_RENAMELISTENER_H
-
-#include "listeners/actionlistener.h"
-
-#include "localconsts.h"
-
-class MapItem;
-class TextDialog;
-
-class RenameListener final : public ActionListener
-{
- public:
- RenameListener();
-
- A_DELETE_COPY(RenameListener)
-
- void action(const ActionEvent &event) override final;
-
- void setMapItem(const MapItem *const mapItem);
-
- void setDialog(TextDialog *dialog)
- { mDialog = dialog; }
-
- private:
- int mMapItemX;
- int mMapItemY;
- TextDialog *mDialog;
-};
-
-#endif // LISTENERS_RENAMELISTENER_H
diff --git a/src/listeners/requestadoptchildlistener.h b/src/listeners/requestadoptchildlistener.h
deleted file mode 100644
index e69759ed9..000000000
--- a/src/listeners/requestadoptchildlistener.h
+++ /dev/null
@@ -1,46 +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 LISTENERS_REQUESTADOPTCHILDLISTENER_H
-#define LISTENERS_REQUESTADOPTCHILDLISTENER_H
-
-#include "gui/windows/confirmdialog.h"
-
-#include "net/familyhandler.h"
-
-#include "localconsts.h"
-
-struct RequestAdoptChildListener final : public ActionListener
-{
- public:
- RequestAdoptChildListener() :
- ActionListener()
- { }
-
- A_DELETE_COPY(RequestAdoptChildListener)
-
- void action(const ActionEvent &event) override final
- {
- const std::string &eventId = event.getId();
- familyHandler->askForChildReply(eventId == "yes");
- }
-};
-
-#endif // LISTENERS_REQUESTADOPTCHILDLISTENER_H
diff --git a/src/listeners/requesttradelistener.h b/src/listeners/requesttradelistener.h
deleted file mode 100644
index 577d75c3c..000000000
--- a/src/listeners/requesttradelistener.h
+++ /dev/null
@@ -1,58 +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 LISTENERS_REQUESTTRADELISTENER_H
-#define LISTENERS_REQUESTTRADELISTENER_H
-
-#include "being/playerrelations.h"
-
-#include "gui/windows/confirmdialog.h"
-
-#include "net/tradehandler.h"
-
-#include "localconsts.h"
-
-extern std::string tradePartnerName;
-extern ConfirmDialog *confirmDlg;
-
-/**
- * Listener for request trade dialogs
- */
-struct RequestTradeListener final : public ActionListener
-{
- public:
- RequestTradeListener()
- { }
-
- A_DELETE_COPY(RequestTradeListener)
-
- void action(const ActionEvent &event) override final
- {
- confirmDlg = nullptr;
- const std::string &eventId = event.getId();
- if (eventId == "ignore")
- playerRelations.ignoreTrade(tradePartnerName);
- tradeHandler->respond(eventId == "yes");
- }
-};
-
-#endif // LISTENERS_REQUESTTRADELISTENER_H
diff --git a/src/listeners/selectionlistener.h b/src/listeners/selectionlistener.h
deleted file mode 100644
index ab4d0478b..000000000
--- a/src/listeners/selectionlistener.h
+++ /dev/null
@@ -1,112 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LISTENERS_SELECTIONLISTENER_H
-#define LISTENERS_SELECTIONLISTENER_H
-
-#include "events/selectionevent.h"
-
-#include "localconsts.h"
-
-/**
- * Interface for listening for selection events from widgets.
- *
- * @see ListBox::addSelectionListener,
- * ListBox::removeSelectionListener,
- * DropDown::addSelectionListener,
- * DropDown::removeSelectionListener
- * @author Olof Naessén
- */
-class SelectionListener notfinal
-{
- public:
- /**
- * Destructor.
- */
- virtual ~SelectionListener()
- { }
-
- /**
- * Called when the value of a selection has been changed in a Widget.
- * It is used to be able to recieve a notification that a value has
- * been changed.
- *
- * @param event The event of the value change.
- */
- virtual void valueChanged(const SelectionEvent &event A_UNUSED)
- { }
-
- protected:
- /**
- * Constructor.
- *
- * You should not be able to make an instance of SelectionListener,
- * therefore its constructor is protected.
- */
- SelectionListener()
- { }
-
- A_DELETE_COPY(SelectionListener)
-};
-
-#endif // LISTENERS_SELECTIONLISTENER_H
diff --git a/src/listeners/shoprenamelistener.cpp b/src/listeners/shoprenamelistener.cpp
deleted file mode 100644
index 60ca7945e..000000000
--- a/src/listeners/shoprenamelistener.cpp
+++ /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/>.
- */
-
-#include "listeners/shoprenamelistener.h"
-
-#include "gui/windows/editdialog.h"
-#include "gui/windows/shopwindow.h"
-
-#include "debug.h"
-
-ShopRenameListener shopRenameListener;
-
-ShopRenameListener::ShopRenameListener() :
- ActionListener(),
- mDialog(nullptr)
-{
-}
-
-void ShopRenameListener::action(const ActionEvent &event)
-{
- if (event.getId() != "OK")
- return;
- if (mDialog != nullptr)
- {
- shopWindow->setShopName(mDialog->getMsg());
- mDialog = nullptr;
- }
-}
diff --git a/src/listeners/shoprenamelistener.h b/src/listeners/shoprenamelistener.h
deleted file mode 100644
index d57fd785a..000000000
--- a/src/listeners/shoprenamelistener.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 LISTENERS_SHOPRENAMELISTENER_H
-#define LISTENERS_SHOPRENAMELISTENER_H
-
-#include "listeners/actionlistener.h"
-
-#include "localconsts.h"
-
-class EditDialog;
-
-class ShopRenameListener final : public ActionListener
-{
- public:
- ShopRenameListener();
-
- A_DELETE_COPY(ShopRenameListener)
-
- void action(const ActionEvent &event) override final;
-
- void setDialog(EditDialog *const dialog)
- { mDialog = dialog; }
-
- protected:
- EditDialog *mDialog;
-};
-
-extern ShopRenameListener shopRenameListener;
-
-#endif // LISTENERS_SHOPRENAMELISTENER_H
diff --git a/src/listeners/skillwarplistener.cpp b/src/listeners/skillwarplistener.cpp
deleted file mode 100644
index d8f66f9a8..000000000
--- a/src/listeners/skillwarplistener.cpp
+++ /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/>.
- */
-
-#include "listeners/skillwarplistener.h"
-
-#include "gui/windows/textselectdialog.h"
-
-#include "net/skillhandler.h"
-
-#include "debug.h"
-
-SkillWarpListener skillWarpListener;
-
-SkillWarpListener::SkillWarpListener() :
- ActionListener(),
- mDialog(nullptr),
- mSkillId(0)
-{
-}
-
-void SkillWarpListener::action(const ActionEvent &event)
-{
- if (event.getId() != "OK")
- return;
- if ((mDialog != nullptr) && (skillHandler != nullptr))
- {
- skillHandler->useMap(mSkillId,
- mDialog->getText());
- }
- mDialog = nullptr;
-}
diff --git a/src/listeners/skillwarplistener.h b/src/listeners/skillwarplistener.h
deleted file mode 100644
index 04517c27c..000000000
--- a/src/listeners/skillwarplistener.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 LISTENERS_SKILLWARPLISTENER_H
-#define LISTENERS_SKILLWARPLISTENER_H
-
-#include "listeners/actionlistener.h"
-
-#include "localconsts.h"
-
-class TextSelectDialog;
-
-class SkillWarpListener final : public ActionListener
-{
- public:
- SkillWarpListener();
-
- A_DELETE_COPY(SkillWarpListener)
-
- void action(const ActionEvent &event) override final;
-
- void setDialog(TextSelectDialog *const dialog)
- { mDialog = dialog; }
-
- void setSkill(const int skillId)
- { mSkillId = skillId; }
-
- protected:
- TextSelectDialog *mDialog;
- int mSkillId;
-};
-
-extern SkillWarpListener skillWarpListener;
-
-#endif // LISTENERS_SKILLWARPLISTENER_H
diff --git a/src/listeners/statlistener.cpp b/src/listeners/statlistener.cpp
deleted file mode 100644
index 7d973d6aa..000000000
--- a/src/listeners/statlistener.cpp
+++ /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/>.
- */
-
-#include "listeners/statlistener.h"
-
-#include "utils/foreach.h"
-
-#include "debug.h"
-
-defineListener(StatListener)
-
-void StatListener::distributeEvent(const AttributesT id,
- const int oldVal1,
- const int oldVal2)
-{
- FOR_EACH (STD_VECTOR<StatListener*>::iterator,
- it, mListeners)
- {
- StatListener *const listener = *it;
- if (listener != nullptr)
- listener->statChanged(id, oldVal1, oldVal2);
- }
-}
diff --git a/src/listeners/statlistener.h b/src/listeners/statlistener.h
deleted file mode 100644
index 485401728..000000000
--- a/src/listeners/statlistener.h
+++ /dev/null
@@ -1,46 +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 LISTENERS_STATLISTENER_H
-#define LISTENERS_STATLISTENER_H
-
-#include "enums/being/attributes.h"
-
-#include "listeners/baselistener.hpp"
-
-#include "localconsts.h"
-
-class StatListener notfinal
-{
- public:
- A_DELETE_COPY(StatListener)
-
- virtual void statChanged(const AttributesT id,
- const int oldVal1,
- const int oldVal2) = 0;
-
- static void distributeEvent(const AttributesT id,
- const int oldVal1,
- const int oldVal2);
-
- defineListenerHeader(StatListener)
-};
-
-#endif // LISTENERS_STATLISTENER_H
diff --git a/src/listeners/tablemodellistener.h b/src/listeners/tablemodellistener.h
deleted file mode 100644
index 717df4f11..000000000
--- a/src/listeners/tablemodellistener.h
+++ /dev/null
@@ -1,54 +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 LISTENERS_TABLEMODELLISTENER_H
-#define LISTENERS_TABLEMODELLISTENER_H
-
-#include "localconsts.h"
-
-class Widget;
-
-class TableModelListener notfinal
-{
- public:
- TableModelListener()
- { }
-
- A_DELETE_COPY(TableModelListener)
-
- /**
- * Must be invoked by the TableModel whenever a global change is about
- * to occur or has occurred (e.g., when a row or column is being
- * removed or added).
- *
- * This method is triggered twice, once before and once after
- * the update.
- *
- * \param completed whether we are signalling the end of the update
- */
- virtual void modelUpdated(const bool completed) = 0;
-
- virtual ~TableModelListener()
- { }
-};
-
-#endif // LISTENERS_TABLEMODELLISTENER_H
diff --git a/src/listeners/textskilllistener.cpp b/src/listeners/textskilllistener.cpp
deleted file mode 100644
index 1c0434948..000000000
--- a/src/listeners/textskilllistener.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/>.
- */
-
-#include "listeners/textskilllistener.h"
-
-#include "gui/windows/textdialog.h"
-
-#include "net/skillhandler.h"
-
-#include "debug.h"
-
-TextSkillListener::TextSkillListener() :
- ActionListener(),
- mDialog(nullptr),
- mSkillId(0),
- mX(0),
- mY(0),
- mLevel(0)
-{
-}
-
-void TextSkillListener::setSkill(const int skillId,
- const int x,
- const int y,
- const int level)
-{
- mSkillId = skillId;
- mX = x;
- mY = y;
- mLevel = level;
-}
-
-void TextSkillListener::action(const ActionEvent &event)
-{
- if (event.getId() == "ok" && (mDialog != nullptr))
- {
- const std::string text = mDialog->getText();
- if (text.empty())
- return;
- skillHandler->usePos(mSkillId,
- mLevel,
- mX, mY,
- text);
- }
- mDialog = nullptr;
-}
diff --git a/src/listeners/textskilllistener.h b/src/listeners/textskilllistener.h
deleted file mode 100644
index 025a4a51a..000000000
--- a/src/listeners/textskilllistener.h
+++ /dev/null
@@ -1,55 +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 LISTENERS_TEXTSKILLLISTENER_H
-#define LISTENERS_TEXTSKILLLISTENER_H
-
-#include "listeners/actionlistener.h"
-
-#include "localconsts.h"
-
-class TextDialog;
-
-class TextSkillListener final : public ActionListener
-{
- public:
- TextSkillListener();
-
- A_DELETE_COPY(TextSkillListener)
-
- void action(const ActionEvent &event) override final;
-
- void setSkill(const int skillId,
- const int x,
- const int y,
- const int level);
-
- void setDialog(TextDialog *dialog)
- { mDialog = dialog; }
-
- private:
- TextDialog *mDialog;
- int mSkillId;
- int mX;
- int mY;
- int mLevel;
-};
-
-#endif // LISTENERS_TEXTSKILLLISTENER_H
diff --git a/src/listeners/tooltiplistener.cpp b/src/listeners/tooltiplistener.cpp
deleted file mode 100644
index 665839abf..000000000
--- a/src/listeners/tooltiplistener.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/>.
- */
-
-#include "listeners/tooltiplistener.h"
-
-#include "gui/gui.h"
-#include "gui/viewport.h"
-
-#include "gui/popups/textboxpopup.h"
-
-#include "debug.h"
-
-ToolTipListener::ToolTipListener() :
- MouseListener(),
- mToolTip()
-{
-}
-
-void ToolTipListener::mouseMoved(MouseEvent &event)
-{
- if (mToolTip.empty() || (textBoxPopup == nullptr))
- return;
-
- int x = 0;
- int y = 0;
- if (viewport != nullptr)
- {
- x = viewport->mMouseX;
- y = viewport->mMouseY;
- }
- else
- {
- Gui::getMouseState(x, y);
- }
-
- event.consume();
- textBoxPopup->show(x, y, mToolTip);
-}
-
-void ToolTipListener::mouseExited(MouseEvent &event A_UNUSED)
-{
- if (mToolTip.empty() || (textBoxPopup == nullptr))
- return;
- textBoxPopup->hide();
-}
diff --git a/src/listeners/tooltiplistener.h b/src/listeners/tooltiplistener.h
deleted file mode 100644
index 0e4f5d231..000000000
--- a/src/listeners/tooltiplistener.h
+++ /dev/null
@@ -1,51 +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 LISTENERS_TOOLTIPLISTENER_H
-#define LISTENERS_TOOLTIPLISTENER_H
-
-#include "listeners/mouselistener.h"
-
-#include <string>
-
-#include "localconsts.h"
-
-class ToolTipListener notfinal : public MouseListener
-{
- public:
- ToolTipListener();
-
- A_DELETE_COPY(ToolTipListener)
-
- void setToolTip(const std::string &str)
- { mToolTip = str; }
-
- std::string getToolTip() const
- { return mToolTip; }
-
- void mouseMoved(MouseEvent &event) override;
-
- void mouseExited(MouseEvent &event) override;
-
- protected:
- std::string mToolTip;
-};
-
-#endif // LISTENERS_TOOLTIPLISTENER_H
diff --git a/src/listeners/updatestatuslistener.cpp b/src/listeners/updatestatuslistener.cpp
deleted file mode 100644
index 511ba9c7a..000000000
--- a/src/listeners/updatestatuslistener.cpp
+++ /dev/null
@@ -1,38 +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 "listeners/updatestatuslistener.h"
-
-#include "utils/foreach.h"
-
-#include "debug.h"
-
-defineListener(UpdateStatusListener)
-
-void UpdateStatusListener::distributeEvent()
-{
- FOR_EACH (STD_VECTOR<UpdateStatusListener*>::iterator,
- it, mListeners)
- {
- UpdateStatusListener *const listener = *it;
- if (listener != nullptr)
- listener->updateStatus();
- }
-}
diff --git a/src/listeners/updatestatuslistener.h b/src/listeners/updatestatuslistener.h
deleted file mode 100644
index 68b7b14b5..000000000
--- a/src/listeners/updatestatuslistener.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 LISTENERS_UPDATESTATUSLISTENER_H
-#define LISTENERS_UPDATESTATUSLISTENER_H
-
-#include "listeners/baselistener.hpp"
-
-#include "localconsts.h"
-
-class UpdateStatusListener notfinal
-{
- public:
- A_DELETE_COPY(UpdateStatusListener)
-
- virtual void updateStatus() = 0;
-
- static void distributeEvent();
-
- defineListenerHeader(UpdateStatusListener)
-};
-
-#endif // LISTENERS_UPDATESTATUSLISTENER_H
diff --git a/src/listeners/uploadlistener.cpp b/src/listeners/uploadlistener.cpp
deleted file mode 100644
index d253fb1aa..000000000
--- a/src/listeners/uploadlistener.cpp
+++ /dev/null
@@ -1,32 +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 "listeners/uploadlistener.h"
-
-#include "input/inputmanager.h"
-
-#include "debug.h"
-
-UploadListener uploadListener;
-
-void UploadListener::action(const ActionEvent &event A_UNUSED)
-{
- inputManager.executeAction(InputAction::UPLOAD_LOG);
-}
diff --git a/src/listeners/uploadlistener.h b/src/listeners/uploadlistener.h
deleted file mode 100644
index b75fe58b8..000000000
--- a/src/listeners/uploadlistener.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 LISTENERS_UPLOADLISTENER_H
-#define LISTENERS_UPLOADLISTENER_H
-
-#include "listeners/actionlistener.h"
-
-#include "localconsts.h"
-
-class UploadListener final : public ActionListener
-{
- public:
- UploadListener() :
- ActionListener()
- { }
-
- A_DELETE_COPY(UploadListener)
-
- void action(const ActionEvent &event A_UNUSED) override final;
-};
-
-extern UploadListener uploadListener;
-
-#endif // LISTENERS_UPLOADLISTENER_H
diff --git a/src/listeners/vendingmodelistener.cpp b/src/listeners/vendingmodelistener.cpp
deleted file mode 100644
index aa532099f..000000000
--- a/src/listeners/vendingmodelistener.cpp
+++ /dev/null
@@ -1,38 +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 "listeners/vendingmodelistener.h"
-
-#include "utils/foreach.h"
-
-#include "debug.h"
-
-defineListener(VendingModeListener)
-
-void VendingModeListener::distributeEvent(const bool b)
-{
- FOR_EACH (STD_VECTOR<VendingModeListener*>::iterator,
- it, mListeners)
- {
- VendingModeListener *const listener = *it;
- if (listener != nullptr)
- listener->vendingEnabled(b);
- }
-}
diff --git a/src/listeners/vendingmodelistener.h b/src/listeners/vendingmodelistener.h
deleted file mode 100644
index 65035e32d..000000000
--- a/src/listeners/vendingmodelistener.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 LISTENERS_VENDINGMODELISTENER_H
-#define LISTENERS_VENDINGMODELISTENER_H
-
-#include "listeners/baselistener.hpp"
-
-#include "localconsts.h"
-
-class VendingModeListener notfinal
-{
- public:
- A_DELETE_COPY(VendingModeListener)
-
- virtual void vendingEnabled(const bool b) = 0;
-
- static void distributeEvent(const bool b);
-
- defineListenerHeader(VendingModeListener)
-};
-
-#endif // LISTENERS_VENDINGMODELISTENER_H
diff --git a/src/listeners/vendingslotslistener.cpp b/src/listeners/vendingslotslistener.cpp
deleted file mode 100644
index 2f6b90c4a..000000000
--- a/src/listeners/vendingslotslistener.cpp
+++ /dev/null
@@ -1,38 +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 "listeners/vendingslotslistener.h"
-
-#include "utils/foreach.h"
-
-#include "debug.h"
-
-defineListener(VendingSlotsListener)
-
-void VendingSlotsListener::distributeEvent(const int slots)
-{
- FOR_EACH (STD_VECTOR<VendingSlotsListener*>::iterator,
- it, mListeners)
- {
- VendingSlotsListener *const listener = *it;
- if (listener != nullptr)
- listener->vendingSlotsChanged(slots);
- }
-}
diff --git a/src/listeners/vendingslotslistener.h b/src/listeners/vendingslotslistener.h
deleted file mode 100644
index ea79848a9..000000000
--- a/src/listeners/vendingslotslistener.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 LISTENERS_VENDINGSLOTSLISTENER_H
-#define LISTENERS_VENDINGSLOTSLISTENER_H
-
-#include "listeners/baselistener.hpp"
-
-#include "localconsts.h"
-
-class VendingSlotsListener notfinal
-{
- public:
- A_DELETE_COPY(VendingSlotsListener)
-
- virtual void vendingSlotsChanged(const int slots) = 0;
-
- static void distributeEvent(const int slots);
-
- defineListenerHeader(VendingSlotsListener)
-};
-
-#endif // LISTENERS_VENDINGSLOTSLISTENER_H
diff --git a/src/listeners/weightlistener.h b/src/listeners/weightlistener.h
deleted file mode 100644
index 781a76988..000000000
--- a/src/listeners/weightlistener.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 LISTENERS_WEIGHTLISTENER_H
-#define LISTENERS_WEIGHTLISTENER_H
-
-#include "gui/windows/okdialog.h"
-
-#include "localconsts.h"
-
-extern OkDialog *weightNotice;
-
-/**
- * Listener used for handling the overweigth message.
- */
-struct WeightListener final : public ActionListener
-{
- public:
- WeightListener() :
- ActionListener()
- { }
-
- A_DELETE_COPY(WeightListener)
-
- void action(const ActionEvent &event A_UNUSED) override final
- {
- weightNotice = nullptr;
- }
-};
-
-#endif // LISTENERS_WEIGHTLISTENER_H
diff --git a/src/listeners/widgetdeathlistener.h b/src/listeners/widgetdeathlistener.h
deleted file mode 100644
index 5933edcec..000000000
--- a/src/listeners/widgetdeathlistener.h
+++ /dev/null
@@ -1,105 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LISTENERS_WIDGETDEATHLISTENER_H
-#define LISTENERS_WIDGETDEATHLISTENER_H
-
-#include "events/event.h"
-
-/**
- * Interface for listening for death events from widgets.
- *
- * @see Widget::addDeathListener, Widget::removeDeathListener
- * @author Olof Naessén
- */
-class WidgetDeathListener notfinal
-{
- public:
- A_DELETE_COPY(WidgetDeathListener)
-
- /**
- * Destructor.
- */
- virtual ~WidgetDeathListener()
- { }
-
- /**
- * Called when a widget dies. It is used to be able to recieve
- * a notification when a death of a widget occurs.
- *
- * @param event The event of the death.
- */
- virtual void death(const Event &event) = 0;
-
- protected:
- /**
- * Constructor.
- *
- * You should not be able to make an instance of DeathListener,
- * therefore its constructor is protected.
- */
- WidgetDeathListener()
- { }
-};
-
-#endif // LISTENERS_WIDGETDEATHLISTENER_H
diff --git a/src/listeners/widgetlistener.h b/src/listeners/widgetlistener.h
deleted file mode 100644
index c3e44ebb6..000000000
--- a/src/listeners/widgetlistener.h
+++ /dev/null
@@ -1,135 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LISTENERS_WIDGETLISTENER_H
-#define LISTENERS_WIDGETLISTENER_H
-
-#include "events/event.h"
-
-#include "localconsts.h"
-
-/**
- * Interface for listening for events from widgets. When a widget's size,
- * location or visibility changes, the relevant method of the listener is
- * invoked.
- *
- * @see Widget::addWidgetListener, Widget::removeWidgetListener
- * @author Olof Naessén
- */
-class WidgetListener notfinal
-{
- public:
- A_DELETE_COPY(WidgetListener)
-
- /**
- * Destructor.
- */
- virtual ~WidgetListener()
- { }
-
- /**
- * Invoked when a widget changes its size.
- *
- * @param event Describes the event.
- */
- virtual void widgetResized(const Event &event A_UNUSED)
- { }
-
- /**
- * Invoked when a widget is moved.
- *
- * @param event Describes the event.
- */
- virtual void widgetMoved(const Event &event A_UNUSED)
- { }
-
- /**
- * Invoked when a widget is hidden, i.e it's set to be
- * not visible.
- *
- * @param event Describes the event.
- */
- virtual void widgetHidden(const Event &event A_UNUSED)
- { }
-
- /**
- * Invoked when a widget is shown, i.e it's set to be
- * visible.
- *
- * @param event Describes the event.
- */
- virtual void widgetShown(const Event &event A_UNUSED)
- { }
-
- protected:
- /**
- * Constructor.
- *
- * You should not be able to make an instance of WidgetListener,
- * therefore its constructor is protected.
- */
- WidgetListener()
- { }
-};
-
-#endif // LISTENERS_WIDGETLISTENER_H
diff --git a/src/listeners/wrongdatanoticelistener.cpp b/src/listeners/wrongdatanoticelistener.cpp
deleted file mode 100644
index ea227eca7..000000000
--- a/src/listeners/wrongdatanoticelistener.cpp
+++ /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/>.
- */
-
-#include "listeners/wrongdatanoticelistener.h"
-
-#include "gui/widgets/textfield.h"
-
-#include "debug.h"
-
-WrongDataNoticeListener::WrongDataNoticeListener() :
- ActionListener(),
- mTarget(nullptr)
-{
-}
-
-void WrongDataNoticeListener::setTarget(TextField *const textField)
-{
- mTarget = textField;
-}
-
-void WrongDataNoticeListener::action(const ActionEvent &event)
-{
- if (event.getId() == "ok" && (mTarget != nullptr))
- mTarget->requestFocus();
-}
diff --git a/src/listeners/wrongdatanoticelistener.h b/src/listeners/wrongdatanoticelistener.h
deleted file mode 100644
index 07820d6d5..000000000
--- a/src/listeners/wrongdatanoticelistener.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 LISTENERS_WRONGDATANOTICELISTENER_H
-#define LISTENERS_WRONGDATANOTICELISTENER_H
-
-#include "listeners/actionlistener.h"
-
-class TextField;
-
-/**
- * Listener used while dealing with wrong data. It is used to direct the focus
- * to the field which contained wrong data when the Ok button was pressed on
- * the error notice.
- */
-class WrongDataNoticeListener final : public ActionListener
-{
- public:
- WrongDataNoticeListener();
-
- A_DELETE_COPY(WrongDataNoticeListener)
-
- void setTarget(TextField *const textField);
-
- void action(const ActionEvent &event) override final;
- private:
- TextField *mTarget;
-};
-
-#endif // LISTENERS_WRONGDATANOTICELISTENER_H
diff --git a/src/localconsts.h b/src/localconsts.h
deleted file mode 100644
index 0f554a677..000000000
--- a/src/localconsts.h
+++ /dev/null
@@ -1,393 +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 LOCALCONSTS_H
-#define LOCALCONSTS_H
-
-#define ENABLEDEBUGLOG 1
-
-#ifndef GCC_VERSION
-#define GCC_VERSION (__GNUC__ * 10000 \
- + __GNUC_MINOR__ * 100 \
- + __GNUC_PATCHLEVEL__)
-#endif // GCC_VERSION
-
-#ifdef __clang__
-#ifndef CLANG_VERSION
-#define CLANG_VERSION (__clang_major__ * 10000 \
- + __clang_minor__ * 100 \
- + __clang_patchlevel__)
-#endif // CLANG_VERSION
-#endif // __clang__
-
-#define A_DEFAULT_COPY(func)
-
-#if !defined(__GXX_EXPERIMENTAL_CXX0X__)
-#undef nullptr
-#define nullptr 0
-#define final
-#define override
-#define constexpr
-#define constexpr2
-#define noexcept2
-#define noexcept
-#define A_DELETE(func)
-#define A_DELETE_COPY(func)
-#else // !defined(__GXX_EXPERIMENTAL_CXX0X__)
-#if GCC_VERSION < 40700
-
-#if defined(__clang__) && __cplusplus > 201100L
-#else // __clang__
-#define final
-#define override
-#define constexpr
-#define noexcept
-#endif // __clang__
-#define noexcept2
-#define constexpr2
-
-// #define A_DELETE
-// #define A_DELETE_COPY
-#else // GCC_VERSION < 40700
-#define ADVGCC
-#if GCC_VERSION < 40900
-#define constexpr2
-#define noexcept2
-#else // GCC_VERSION < 40900
-#if __cpp_constexpr >= 201304
-#define constexpr2 constexpr
-#else // __cpp_constexpr >= 201304
-#define constexpr2
-#endif // __cpp_constexpr >= 201304
-
-#ifdef __clang__
-#define noexcept2
-#else // __clang__
-#define noexcept2 noexcept
-#endif // __clang__
-
-#endif // GCC_VERSION < 40900
-#endif // GCC_VERSION < 40700
-#define M_TCPOK
-#define A_DELETE(func) func = delete
-#define A_DELETE_COPY(name) name(const name &) = delete; \
- name &operator=(const name&) = delete;
-#endif // !defined(__GXX_EXPERIMENTAL_CXX0X__)
-
-#ifdef __GNUC__
-#define A_UNUSED __attribute__ ((unused))
-#define A_WARN_UNUSED __attribute__ ((warn_unused_result))
-#ifdef UNITTESTS
-#define A_WARN_UNUSED_NON_TESTS
-#else // UNITTESTS
-#define A_WARN_UNUSED_NON_TESTS __attribute__ ((warn_unused_result))
-#endif // UNITTESTS
-#define DEPRECATED __attribute__ ((deprecated))
-#ifdef DYECMD
-#define A_DYECMD_UNUSED __attribute__ ((unused))
-#else // DYECMD
-#define A_DYECMD_UNUSED
-#endif // DYECMD
-
-#ifdef __native_client__
-#define restrict
-#define restrict2
-#else // __native_client__
-#ifdef __clang__
-// because restrict broken in clang, now it removed from all places.
-// #define restrict __restrict__
-#define restrict
-#define restrict2
-#else // __clang__
-#define restrict __restrict__
-#define restrict2 __restrict__
-#endif // __clang__
-#endif // __native_client__
-
-#ifdef ENABLE_CILKPLUS
-#ifdef __GNUC__
-#if GCC_VERSION < 60000
-#define BAD_CILKPLUS
-#else // GCC_VERSION < 60000
-#define GOOD_CILKPLUS
-#endif // GCC_VERSION < 60000
-#endif // __GNUC__
-#endif // ENABLE_CILKPLUS
-
-#if defined(ENABLE_CILKPLUS) && defined(BAD_CILKPLUS)
-#define A_CONST
-#define A_PURE
-#define A_INLINE
-#else // ENABLE_CILKPLUS
-#define A_CONST __attribute__ ((const))
-#define A_PURE __attribute__ ((pure))
-#define A_INLINE __attribute__ ((always_inline))
-#endif // ENABLE_CILKPLUS
-
-#ifdef __x86_64__
-// gcc 4.8 look like support avx2, but need global define for enable any SIMD
-#if GCC_VERSION >= 40900
-#define SIMD_SUPPORTED
-#endif // GCC_VERSION > 40900
-#if defined(__clang__) && CLANG_VERSION >= 30800
-#define SIMD_SUPPORTED
-#endif // defined(__clang__) && CLANG_VERSION >= 30800
-#endif // __x86_64__
-
-#ifdef __INTEL_COMPILER
-#define RETURNS_NONNULL
-#else // __INTEL_COMPILER
-#if GCC_VERSION < 40900
-#define RETURNS_NONNULL
-#else // GCC_VERSION < 40900
-#define RETURNS_NONNULL __attribute__((returns_nonnull))
-#endif // GCC_VERSION < 40900
-#endif // __INTEL_COMPILER
-
-#ifndef ENABLE_CILKPLUS
-#define A_NONNULL(...) __attribute__((nonnull (__VA_ARGS__)))
-#else // ENABLE_CILKPLUS
-#define A_NONNULL(...)
-#endif // ENABLE_CILKPLUS
-
-#else // __GNUC__
-#define A_UNUSED
-#define A_WARN_UNUSED
-#define A_WARN_UNUSED_NON_TESTS
-#define gnu_printf printf
-#define DEPRECATED
-#define restrict
-#define restrict2
-#define RETURNS_NONNULL
-#define A_NONNULL(...)
-#endif // __GNUC__
-#ifdef __clang__
-#define gnu_printf printf
-#endif // __clang__
-
-#ifdef ENABLE_CILKPLUS
-#include <cilk/cilk.h>
-#endif // ENABLE_CILKPLUS
-
-#ifdef ADVGCC
-
-#define const2 const
-
-#if GCC_VERSION >= 60000
-#define PRAGMA6(str) _Pragma(#str)
-#else // GCC_VERSION > 60000
-#define PRAGMA6(str)
-#endif // GCC_VERSION > 60000
-
-#if GCC_VERSION >= 70000
-#define A_FALLTHROUGH __attribute__ ((fallthrough));
-#else // GCC_VERSION > 70000
-#define A_FALLTHROUGH
-#endif // GCC_VERSION > 70000
-
-#else // ADVGCC
-#define const2
-#define PRAGMA6(str)
-#define A_FALLTHROUGH
-#endif // ADVGCC
-
-#if GCC_VERSION >= 48000
-#define PRAGMA48(str) _Pragma(#str)
-#else // GCC_VERSION > 48000
-#define PRAGMA48(str)
-#endif // GCC_VERSION > 48000
-
-#if GCC_VERSION >= 49000
-#define PRAGMA49(str) _Pragma(#str)
-#else // GCC_VERSION > 49000
-#define PRAGMA49(str)
-#endif // GCC_VERSION > 49000
-
-#if GCC_VERSION >= 80000
-#define PRAGMA8(str) _Pragma(#str)
-#else // GCC_VERSION > 80000
-#define PRAGMA8(str)
-#endif // GCC_VERSION > 80000
-
-#ifdef __clang__
-#define PRAGMACLANG(str) _Pragma(#str)
-#if CLANG_VERSION >= 30800
-#define PRAGMACLANG6(str) _Pragma(#str)
-#define CLANG_FALLTHROUGH [[clang::fallthrough]];
-#else // __clang_major__ >= 6
-#define PRAGMACLANG6(str)
-#define CLANG_FALLTHROUGH
-#endif // __clang_major__ >= 6
-#else // __clang__
-#define PRAGMACLANG(str)
-#define PRAGMACLANG6(str)
-#define CLANG_FALLTHROUGH
-#endif // __clang__
-
-#if GCC_VERSION >= 40600
-#define PRAGMACLANG6GCC(str) _Pragma(#str)
-#elif defined(__clang__) && CLANG_VERSION >= 30800
-#define PRAGMACLANG6GCC(str) _Pragma(#str)
-#else // __clang__
-#define PRAGMACLANG6GCC(str)
-#endif // __clang__
-
-#ifdef __GNUC__
-#if GCC_VERSION >= 40600
-#define PRAGMA45(str) _Pragma(#str)
-#elif defined(__clang__)
-#define PRAGMA45(str) _Pragma(#str)
-#else // GCC_VERSION > 40600
-#define PRAGMA45(str)
-#endif // GCC_VERSION > 40600
-
-#if GCC_VERSION >= 40000
-#define PRAGMA4(str) _Pragma(#str)
-#elif defined(__clang__)
-#define PRAGMA4(str) _Pragma(#str)
-#else // GCC_VERSION > 40000
-#define PRAGMA4(str)
-#endif // GCC_VERSION > 40000
-#endif // __GNUC__
-
-#ifdef __GNUC__
-#ifdef ENABLE_CILKPLUS
-#if GCC_VERSION < 40900
-#define cilk_for for
-#define cilk_spawn
-#define cilk_sync
-#elif GCC_VERSION < 50000
-#ifdef cilk_for
-#undef cilk_for
-#endif // cilk_for
-#define cilk_for for
-#endif // GCC_VERSION < 40900
-#else // ENABLE_CILKPLUS
-#define cilk_for for
-#define cilk_spawn
-#define cilk_sync
-#endif // ENABLE_CILKPLUS
-#endif // __GNUC__
-
-#define notfinal
-
-#ifdef ENABLE_CHECKPLUGIN
-#define A_NONNULLPOINTER __attribute__((nonnullpointer))
-#else // ENABLE_CHECKPLUGIN
-#define A_NONNULLPOINTER
-#endif // ENABLE_CHECKPLUGIN
-
-#ifdef ENABLE_CHECKS
-
-#define CHECKLISTENERS \
- config.checkListeners(this, __FILE__, __LINE__); \
- serverConfig.checkListeners(this, __FILE__, __LINE__);
-
-#else // ENABLE_CHECKS
-
-#define CHECKLISTENERS
-
-#endif // ENABLE_CHECKS
-
-#if defined(__cpp_if_constexpr) && __cpp_if_constexpr >= 201606
-#define ifconstexpr if constexpr
-#else // defined(__cpp_if_constexpr) && __cpp_if_constexpr >= 201606
-#define ifconstexpr if
-#endif // defined(__cpp_if_constexpr) && __cpp_if_constexpr >= 201606
-
-#ifdef USE_SDL2
-PRAGMA45(GCC diagnostic push)
-PRAGMA45(GCC diagnostic ignored "-Wswitch-default")
-#endif // USE_SDL2
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_version.h>
-PRAGMA48(GCC diagnostic pop)
-#ifdef USE_SDL2
-PRAGMA45(GCC diagnostic pop)
-#endif // USE_SDL2
-
-#if SDL_VERSION_ATLEAST(2, 0, 0)
-#ifndef USE_SDL2
-#warning using SDL2 headers but configure set to use SDL1.2
-#warning please add configure flag --with-sdl2
-#define USE_SDL2
-#endif // USE_SDL2
-#else // SDL_VERSION_ATLEAST(2, 0, 0)
-#ifdef USE_SDL2
-#error using SDL1.2 headers but configure set to use SDL2
-#error please remove configure flag --with-sdl2
-#endif // USE_SDL2
-#endif // SDL_VERSION_ATLEAST(2, 0, 0)
-
-// #define DEBUG_CONFIG 1
-// #define DEBUG_BIND_TEXTURE 1
-// #define DISABLE_RESOURCE_CACHING 1
-#define DUMP_LEAKED_RESOURCES 1
-// #define DEBUG_DUMP_LEAKS1 1
-// #define DEBUG_SDLFONT 1
-
-// android or nacl logging
-// #define SPECIAL_LOGGING 1
-
-// profiler
-// #define USE_PROFILER 1
-
-// draw calls
-// #define DEBUG_DRAW_CALLS 1
-
-// debug images usage
-// #define DEBUG_IMAGES 1
-
-// debug SDL surfaces
-// #define DEBUG_SDL_SURFACES 1
-
-// debug virtfs usage
-// #define DEBUG_VIRTFS 1
-
-// use file access fuzzer
-// #define USE_FUZZER 1
-
-// use OpenGL debug features
-// #define DEBUG_OPENGL 1
-
-// debug animations
-// #define DEBUG_ANIMATIONS 1
-
-#define USE_FILE_FOPEN 1
-
-#ifdef __MINGW32__
-#define PRAGMAMINGW(str) _Pragma(#str)
-#define A_WIN_UNUSED __attribute__ ((unused))
-#else // __MINGW32__
-#define PRAGMAMINGW(str)
-#define A_WIN_UNUSED
-#endif // __MINGW32__
-
-#ifdef DYECMD
-#undef USE_FUZZER
-#endif // DYECMD
-#include "utils/perfomance.h"
-UTILS_PERFOMANCE_H // guard for protect previous include
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif // HAVE_CONFIG_H
-
-#endif // LOCALCONSTS_H
diff --git a/src/logger.cpp b/src/logger.cpp
deleted file mode 100644
index c8317f808..000000000
--- a/src/logger.cpp
+++ /dev/null
@@ -1,493 +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 "logger.h"
-
-#include "settings.h"
-
-#include "listeners/debugmessagelistener.h"
-
-#include "utils/cast.h"
-#include "utils/foreach.h"
-#include "utils/stringutils.h"
-
-#include <iostream>
-
-#ifdef WIN32
-#include <windows.h>
-#elif defined __APPLE__
-#include <Carbon/Carbon.h>
-#endif // WIN32
-
-#include <sys/time.h>
-
-#include <sstream>
-
-#ifdef USE_SDL2
-#include <SDL_messagebox.h>
-#endif // USE_SDl2
-
-#ifdef ENABLEDEBUGLOG
-#if defined(__ANDROID__)
-#include <android/log.h>
-#ifdef SPECIAL_LOGGING
-#define SPECIALLOG(x) __android_log_print(ANDROID_LOG_INFO, "manaplus", x);
-#define DSPECIALLOG(x) __android_log_print(ANDROID_LOG_VERBOSE, \
- "manaplus", x);
-#else // SPECIAL_LOGGING
-#define SPECIALLOG(x) if (mDebugLog) \
- __android_log_print(ANDROID_LOG_INFO, "manaplus", x);
-#define DSPECIALLOG(x) if (mDebugLog) \
- __android_log_print(ANDROID_LOG_VERBOSE, "manaplus", x);
-#endif // SPECIAL_LOGGING
-#elif defined __native_client__
-#ifdef SPECIAL_LOGGING
-#define SPECIALLOG(x) std::cerr << x;
-#define DSPECIALLOG(x) std::cerr << x;
-#else // SPECIAL_LOGGING
-#define SPECIALLOG(x) if (mDebugLog) \
- std::cerr << x;
-#define DSPECIALLOG(x) if (mDebugLog) \
- std::cerr << x;
-#endif // SPECIAL_LOGGING
-#else // defined(__ANDROID__)
-#define SPECIALLOG(x)
-#define DSPECIALLOG(x)
-#endif // defined(__ANDROID__)
-#endif // ENABLEDEBUGLOG
-
-#include "debug.h"
-
-#define DATESTREAM \
- timeStr << "[" \
- << ((((tv.tv_sec / 60) / 60) % 24 < 10) ? "0" : "") \
- << CAST_S32(((tv.tv_sec / 60) / 60) % 24) \
- << ":" \
- << (((tv.tv_sec / 60) % 60 < 10) ? "0" : "") \
- << CAST_S32((tv.tv_sec / 60) % 60) \
- << ":" \
- << ((tv.tv_sec % 60 < 10) ? "0" : "") \
- << CAST_S32(tv.tv_sec % 60) \
- << "." \
- << (((tv.tv_usec / 10000) % 100) < 10 ? "0" : "") \
- << CAST_S32((tv.tv_usec / 10000) % 100) \
- << "] ";
-
-Logger *logger = nullptr; // Log object
-
-Logger::Logger() :
- mLogFile(),
- mDelayedLog(),
- mMutex(SDL_CreateMutex()),
- mThreadLocked(false),
- mLogToStandardOut(true),
- mDebugLog(false),
- mReportUnimplemented(false)
-{
-#if defined __native_client__ && defined(NACL_LOG)
- std::cout.setf(std::ios_base::unitbuf);
-#endif // defined __native_client__ && defined(NACL_LOG)
-}
-
-Logger::~Logger()
-{
- if (mLogFile.is_open())
- mLogFile.close();
- SDL_DestroyMutex(mMutex);
-}
-
-void Logger::setLogFile(const std::string &logFilename)
-{
- if (mLogFile.is_open())
- mLogFile.close();
-
- mLogFile.open(logFilename.c_str(), std::ios_base::trunc);
-
- if (!mLogFile.is_open())
- {
- std::cout << "Warning: error while opening " << logFilename <<
- " for writing.\n";
- mLogToStandardOut = true;
- }
- else
- {
- mLogToStandardOut = false;
- }
-}
-
-void Logger::log(const std::string &str)
-{
- log("%s", str.c_str());
-}
-
-#ifdef ENABLEDEBUGLOG
-void Logger::dlog(const std::string &str)
-{
- if (!mDebugLog)
- return;
-
- // Get the current system time
- timeval tv;
- gettimeofday(&tv, nullptr);
-
- // Print the log entry
- std::stringstream timeStr;
- DATESTREAM
- DSPECIALLOG(str.c_str())
-
- if (mLogFile.is_open())
- mLogFile << timeStr.str() << str << std::endl;
-
- if (mLogToStandardOut)
- std::cout << timeStr.str() << str << std::endl;
-}
-
-void Logger::dlog2(const std::string &str,
- const int pos,
- const char* const comment)
-{
- if (!mDebugLog)
- return;
-
- // Get the current system time
- timeval tv;
- gettimeofday(&tv, nullptr);
-
- // Print the log entry
- std::stringstream timeStr;
- DATESTREAM
- DSPECIALLOG(str.c_str())
-
- if (mLogFile.is_open())
- {
- if (comment != nullptr)
- {
- mLogFile << timeStr.str();
- mLogFile.fill('0');
- mLogFile.width(4);
- mLogFile << pos << " ";
- mLogFile << str << ": " << comment << std::endl;
- }
- else
- {
- mLogFile << timeStr.str();
- mLogFile.fill('0');
- mLogFile.width(4);
- mLogFile << pos << " ";
- mLogFile << str << std::endl;
- }
- }
-
- if (mLogToStandardOut)
- {
- if (comment != nullptr)
- {
- std::cout << timeStr.str();
- std::cout.fill('0');
- std::cout.width(4);
- std::cout << pos << " ";
- std::cout << str << ": " << comment << std::endl;
- }
- else
- {
- std::cout << timeStr.str();
- std::cout.fill('0');
- std::cout.width(4);
- std::cout << pos << " ";
- std::cout << str << std::endl;
- }
- }
-}
-#endif // ENABLEDEBUGLOG
-
-void Logger::log1(const char *const buf)
-{
- if (settings.disableLoggingInGame)
- return;
-
- // Get the current system time
- timeval tv;
- gettimeofday(&tv, nullptr);
-
- // Print the log entry
- std::stringstream timeStr;
- DATESTREAM
- SPECIALLOG(buf)
-
- if (mLogFile.is_open())
- mLogFile << timeStr.str() << buf << std::endl;
-
- if (mLogToStandardOut)
- std::cout << timeStr.str() << buf << std::endl;
-}
-
-void Logger::log(const char *const log_text, ...)
-{
- if (settings.disableLoggingInGame)
- return;
-
- unsigned size = 1024;
- if (strlen(log_text) * 3 > size)
- size = CAST_U32(strlen(log_text) * 3);
-
- char* buf = new char[CAST_SIZE(size + 1)];
- va_list ap;
-
- // Use a temporary buffer to fill in the variables
- va_start(ap, log_text);
- vsnprintf(buf, size, log_text, ap);
- buf[size] = 0;
- va_end(ap);
-
- // Get the current system time
- timeval tv;
- gettimeofday(&tv, nullptr);
-
- // Print the log entry
- std::stringstream timeStr;
- DATESTREAM
- SPECIALLOG(buf)
-
- if (mLogFile.is_open())
- mLogFile << timeStr.str() << buf << std::endl;
-
- if (mLogToStandardOut)
- std::cout << timeStr.str() << buf << std::endl;
-
- // Delete temporary buffer
- delete [] buf;
-}
-
-void Logger::assertLog(const char *const log_text, ...)
-{
- if (settings.disableLoggingInGame)
- return;
-
- unsigned size = 1024;
- if (strlen(log_text) * 3 > size)
- size = CAST_U32(strlen(log_text) * 3);
-
- char* buf = new char[CAST_SIZE(size + 1)];
- va_list ap;
-
- // Use a temporary buffer to fill in the variables
- va_start(ap, log_text);
- vsnprintf(buf, size, log_text, ap);
- buf[size] = 0;
- va_end(ap);
-
- // Get the current system time
- timeval tv;
- gettimeofday(&tv, nullptr);
-
- // Print the log entry
- std::stringstream timeStr;
- DATESTREAM
- SPECIALLOG(buf)
-
- if (mLogFile.is_open())
- mLogFile << timeStr.str() << buf << std::endl;
-
- if (mLogToStandardOut)
- std::cout << timeStr.str() << buf << std::endl;
-
- DebugMessageListener::distributeEvent(buf);
-
- // Delete temporary buffer
- delete [] buf;
-}
-
-void Logger::log_r(const char *const log_text, ...)
-{
- if (settings.disableLoggingInGame)
- return;
-
- SDL_mutexP(mMutex);
-
- unsigned size = 1024;
- if (strlen(log_text) * 3 > size)
- size = CAST_U32(strlen(log_text) * 3);
-
- char* buf = new char[CAST_SIZE(size + 1)];
- va_list ap;
-
- // Use a temporary buffer to fill in the variables
- va_start(ap, log_text);
- vsnprintf(buf, size, log_text, ap);
- buf[size] = 0;
- va_end(ap);
-
- // Get the current system time
- timeval tv;
- gettimeofday(&tv, nullptr);
-
- // Print the log entry
- std::stringstream timeStr;
- DATESTREAM
- SPECIALLOG(buf)
-
- if (mLogFile.is_open())
- {
- timeStr << buf;
- mThreadLocked = true;
- mDelayedLog.push_back(timeStr.str());
- mThreadLocked = false;
- }
-
- if (mLogToStandardOut)
- std::cout << timeStr.str() << buf << std::endl;
-
- // Delete temporary buffer
- delete [] buf;
-
- SDL_mutexV(mMutex);
-}
-
-void Logger::flush()
-{
- if (!mThreadLocked)
- {
- SDL_mutexP(mMutex);
- FOR_EACH (STD_VECTOR<std::string>::const_iterator, it, mDelayedLog)
- mLogFile << *it << std::endl;
- mDelayedLog.clear();
- SDL_mutexV(mMutex);
- }
-}
-
-// here string must be safe for any usage
-void Logger::safeError(const std::string &error_text)
-{
- log("Error: %s", error_text.c_str());
-#ifdef USE_SDL2
- SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR,
- "Error",
- error_text.c_str(),
- nullptr);
-#else // USE_SDL2
-#ifdef WIN32
- MessageBox(nullptr, error_text.c_str(), "Error", MB_ICONERROR | MB_OK);
-#elif defined __APPLE__
-// Str255 msg;
-// CFStringRef error;
-// error = CFStringCreateWithCString(nullptr,
-// error_text.c_str(),
-// kCFStringEncodingMacRoman);
-// CFStringGetPascalString(error, msg, 255, kCFStringEncodingMacRoman);
-// StandardAlert(kAlertStopAlert,
-// (const unsigned char*)"\pError",
-// (ConstStr255Param) msg, nullptr, nullptr);
-#elif defined(__linux__) || defined(__linux)
- std::cerr << "Error: " << error_text << std::endl;
- const std::string msg = std::string("xmessage \"").append(
- error_text).append("\"");
- if (system(msg.c_str()) == -1)
- std::cerr << "Error: " << error_text << std::endl;
-#else // WIN32
-
- std::cerr << "Error: " << error_text << std::endl;
-#endif // WIN32
-#endif // USE_SDL2
-
- exit(1);
-}
-
-// here string can be unsafe strings
-void Logger::error(const std::string &error_text)
-{
- log("Error: %s", error_text.c_str());
-#ifdef USE_SDL2
- SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR,
- "Error",
- error_text.c_str(),
- nullptr);
-#else // USE_SDL2
-#ifdef WIN32
- MessageBox(nullptr, error_text.c_str(), "Error", MB_ICONERROR | MB_OK);
-#elif defined __APPLE__
-// Str255 msg;
-// CFStringRef error;
-// error = CFStringCreateWithCString(nullptr,
-// error_text.c_str(),
-// kCFStringEncodingMacRoman);
-// CFStringGetPascalString(error, msg, 255, kCFStringEncodingMacRoman);
-// StandardAlert(kAlertStopAlert,
-// (const unsigned char*)"\pError",
-// (ConstStr255Param) msg, nullptr, nullptr);
-#elif defined(__linux__) || defined(_linux)
- std::cerr << "Error: " << error_text << std::endl;
- const std::string msg("xmessage \"Error happened. "
- "Please see log file for more information.\"");
- if (system(msg.c_str()) == -1)
- std::cerr << "Error: " << error_text << std::endl;
-#else // WIN32
-
- std::cerr << "Error: " << error_text << std::endl;
-#endif // WIN32
-#endif // USE_SDL2
-
- exit(1);
-}
-
-void Logger::unimplemented(const int id)
-{
- if (!mReportUnimplemented)
- return;
-
- const std::string str = strprintf("Unimplimented packet: %d (0x%x)",
- id,
- CAST_U32(id));
- DebugMessageListener::distributeEvent(str);
- log(str);
-}
-
-void Logger::unimplemented(const int id,
- const int id2)
-{
- if (!mReportUnimplemented)
- return;
-
- const std::string str = strprintf(
- "Unimplimented field value %d for packet %d (0x%x)",
- id2,
- id,
- CAST_U32(id));
- DebugMessageListener::distributeEvent(str);
- log(str);
-}
-
-void Logger::unimplemented(const uint32_t id,
- const uint32_t id2,
- const uint32_t id3) const
-{
- if (!mReportUnimplemented)
- return;
-
- const std::string str = strprintf(
- "Wrong actual or planned inbound packet size!. "
- "Packet id: %u(0x%x), Planned size: %u, Actual size: %u",
- id,
- id,
- id2,
- id3);
- DebugMessageListener::distributeEvent(str);
-}
diff --git a/src/logger.h b/src/logger.h
deleted file mode 100644
index 3c0f8b0b1..000000000
--- a/src/logger.h
+++ /dev/null
@@ -1,225 +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 LOGGER_H
-#define LOGGER_H
-
-#include "localconsts.h"
-
-#include "utils/vector.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_mutex.h>
-PRAGMA48(GCC diagnostic pop)
-
-#include <fstream>
-
-#ifdef ENABLEDEBUGLOG
-#define DEBUGLOG(str) \
- if (logger && !mIgnore) \
- logger->dlog(str)
-#define DEBUGLOG2(str, pos, comment) \
- if (logger && !mIgnore) \
- logger->dlog2(str, pos, comment)
-#define DEBUGLOGSTR(str) \
- if (logger) \
- logger->dlog(str)
-#define IGNOREDEBUGLOG mIgnore = Net::isIgnorePacket(mId)
-#else // ENABLEDEBUGLOG
-#define DEBUGLOG(str) {}
-#define DEBUGLOG2(str, comment) {}
-#define DEBUGLOGSTR(str)
-#define IGNOREDEBUGLOG {}
-#endif // ENABLEDEBUGLOG
-
-#define UNIMPLEMENTEDPACKET \
- logger->unimplemented(msg.getId())
-
-#define UNIMPLEMENTEDPACKETFIELD(field) \
- logger->unimplemented(msg.getId(), field)
-
-#define WRONGPACKETSIZE \
- logger->unimplemented(CAST_U32(mId), mLength, mPos)
-
-/**
- * The Log Class : Useful to write debug or info messages
- */
-class Logger final
-{
- public:
- /**
- * Constructor.
- */
- Logger();
-
- A_DELETE_COPY(Logger)
-
- /**
- * Destructor, closes log file.
- */
- ~Logger();
-
- /**
- * Sets the file to log to and opens it
- */
- void setLogFile(const std::string &logFilename);
-
- /**
- * Sets whether the log should be written to standard output.
- */
- void setLogToStandardOut(const bool value)
- { mLogToStandardOut = value; }
-
- /**
- * Enters a message in the log. The message will be timestamped.
- */
- void log(const char *const log_text, ...) A_NONNULL(2)
-#ifdef __GNUC__
-#ifdef __OpenBSD__
-
- __attribute__((__format__(printf, 2, 3)))
-#else // __OpenBSD__
-
-#ifdef BAD_CILKPLUS
- __attribute__((__format__(gnu_printf, 1, 2)))
-#else // BAD_CILKPLUS
-
- __attribute__((__format__(gnu_printf, 2, 3)))
-#endif // BAD_CILKPLUS
-
-#endif // __OpenBSD__
-#endif // __GNUC__
- ;
-
- /**
- * Enters a message in the log. The message will be timestamped.
- */
- void assertLog(const char *const log_text, ...) A_NONNULL(2)
-#ifdef __GNUC__
-#ifdef __OpenBSD__
-
- __attribute__((__format__(printf, 2, 3)))
-#else // __OpenBSD__
-
-#ifdef BAD_CILKPLUS
- __attribute__((__format__(gnu_printf, 1, 2)))
-#else // BAD_CILKPLUS
-
- __attribute__((__format__(gnu_printf, 2, 3)))
-#endif // BAD_CILKPLUS
-
-#endif // __OpenBSD__
-#endif // __GNUC__
- ;
-
- /**
- * Enters a message in the log (thread safe).
- */
- void log_r(const char *const log_text, ...) A_NONNULL(2)
-#ifdef __GNUC__
-#ifdef __OpenBSD__
- __attribute__((__format__(printf, 2, 3)))
-#else // __OpenBSD__
-
-#ifdef BAD_CILKPLUS
- __attribute__((__format__(gnu_printf, 1, 2)))
-#else // BAD_CILKPLUS
-
- __attribute__((__format__(gnu_printf, 2, 3)))
-#endif // BAD_CILKPLUS
-
-#endif // __OpenBSD__
-#endif // __GNUC__
- ;
-
- /**
- * Enters a message in the log. The message will be timestamped.
- */
- void log1(const char *const log_text) A_NONNULL(2);
-
- /**
- * Enters a message in the log. The message will be timestamped.
- */
- void log(const std::string &str);
-
- void flush();
-
-#ifdef ENABLEDEBUGLOG
- /**
- * Enters debug message in the log. The message will be timestamped.
- */
- void dlog(const std::string &str);
-
- void dlog2(const std::string &str,
- const int pos,
- const char* const comment);
-#endif // ENABLEDEBUGLOG
-
- void setDebugLog(const bool n)
- { mDebugLog = n; }
-
- void setReportUnimplemented(const bool n)
- { mReportUnimplemented = n; }
-
- /**
- * Log an error and quit. The error will pop-up on Windows and Mac, and
- * will be printed to standard error everywhere else.
- */
- void error(const std::string &error_text)
-#ifndef BAD_CILKPLUS
- __attribute__ ((noreturn))
-#endif // BAD_CILKPLUS
- ;
-
- /**
- * Log an error and quit. The error will pop-up on Windows and Mac, and
- * will be printed to standard error everywhere else.
- */
- void safeError(const std::string &error_text)
-#ifndef BAD_CILKPLUS
- __attribute__ ((noreturn))
-#endif // BAD_CILKPLUS
- ;
-
- void unimplemented(const int id);
-
- void unimplemented(const int id,
- const int id2);
-
- void unimplemented(const uint32_t id,
- const uint32_t id2,
- const uint32_t id3) const;
-
- private:
- std::ofstream mLogFile;
- STD_VECTOR<std::string> mDelayedLog;
- SDL_mutex *mMutex;
- volatile bool mThreadLocked;
- bool mLogToStandardOut;
- bool mDebugLog;
- bool mReportUnimplemented;
-};
-
-extern Logger *logger;
-
-#endif // LOGGER_H
diff --git a/src/main.cpp b/src/main.cpp
deleted file mode 100644
index 1ec5bb586..000000000
--- a/src/main.cpp
+++ /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/>.
- */
-
-#include "maingui.h"
-
-#ifdef WIN32
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL.h>
-PRAGMA48(GCC diagnostic pop)
-#endif // WIN32
-
-#include "debug.h"
-
-#if !defined(UNITTESTS) && !defined(ANDROID)
-#if defined __native_client__
-extern "C"
-#endif // defined __native_client__
-
-int main(int argc, char *argv[])
-{
- return mainGui(argc, argv);
-}
-#endif // !defined(UNITTESTS) && !defined(ANDROID)
diff --git a/src/main.h b/src/main.h
deleted file mode 100644
index 733d33037..000000000
--- a/src/main.h
+++ /dev/null
@@ -1,180 +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 MAIN_H
-#define MAIN_H
-
-/**
- * \mainpage
- *
- * \section General General information
- *
- * During the game, the current Map is displayed by the main Viewport, which
- * is the bottom-most widget in the WindowContainer. Aside the viewport, the
- * window container keeps track of all the \link Window Windows\endlink
- * displayed during the game. It is the <i>top</i> widget for Guichan.
- *
- * A Map is composed of several layers of \link Image Images\endlink (tiles),
- * a layer with collision information and \link Sprite Sprites\endlink. The
- * sprites define the visible part of \link Being Beings\endlink and
- * \link FloorItem FloorItems\endlink, they are drawn from top to bottom
- * by the map, interleaved with the tiles in the fringe layer.
- */
-
-#define SMALL_VERSION "1.7.9.30"
-#define CHECK_VERSION "01.07.09.30"
-
-#ifdef HAVE_CONFIG_H
-#include "../config.h"
-#else // HAVE_CONFIG_H
-#ifdef PACKAGE_VERSION
-#undef PACKAGE_VERSION
-#endif // PACKAGE_VERSION
-#define PACKAGE_VERSION SMALL_VERSION;
-#endif // HAVE_CONFIG_H
-
-#include "localconsts.h"
-
-#if defined __APPLE__
-#define PACKAGE_OS "Mac OS X"
-#elif defined(__ANDROID__) || defined(ANDROID)
-#define PACKAGE_OS "Android"
-#elif defined(__FreeBSD_kernel__) && defined(__GLIBC__)
-#define PACKAGE_OS "kFreeBSD"
-#elif defined __FreeBSD__ || defined __DragonFly__
-#define PACKAGE_OS "FreeBSD"
-#elif defined(__NetBSD__) || defined(__NetBSD)
-#define PACKAGE_OS "NetBSD"
-#elif defined(__OpenBSD__) || defined(__OPENBSD)
-#define PACKAGE_OS "OpenBSD"
-#elif defined __linux__ || defined __linux
-#define PACKAGE_OS "Linux"
-#elif defined __CYGWIN__
-#define PACKAGE_OS "Cygwin"
-#elif defined(__sun) || defined(sun)
-#define PACKAGE_OS "SunOS"
-#elif defined(_AIX) || defined(__AIX) || defined(__AIX__) \
- || defined(__aix) || defined(__aix__)
-#define PACKAGE_OS "AIX"
-#elif defined(__sgi) || defined(__sgi__) || defined(_SGI)
-#define PACKAGE_OS "IRIX"
-#elif defined(__hpux) || defined(__hpux__)
-#define PACKAGE_OS "HP-UX"
-#elif defined(__BeOS) || defined(__BEOS__) || defined(_BEOS)
-#define PACKAGE_OS "BeOS"
-#elif defined(__QNX__) || defined(__QNXNTO__)
-#define PACKAGE_OS "QNX"
-#elif defined(__tru64) || defined(_tru64) || defined(__TRU64__)
-#define PACKAGE_OS "Tru64"
-#elif defined(__riscos) || defined(__riscos__)
-#define PACKAGE_OS "RISCos"
-#elif defined(__sinix) || defined(__sinix__) || defined(__SINIX__)
-#define PACKAGE_OS "SINIX"
-#elif defined(__UNIX_SV__)
-#define PACKAGE_OS "UNIX_SV"
-#elif defined(__bsdos__)
-#define PACKAGE_OS "BSDOS"
-#elif defined(_MPRAS) || defined(MPRAS)
-#define PACKAGE_OS "MP-RAS"
-#elif defined(__osf) || defined(__osf__)
-#define PACKAGE_OS "OSF1"
-#elif defined(_SCO_SV) || defined(SCO_SV) || defined(sco_sv)
-#define PACKAGE_OS "SCO_SV"
-#elif defined(__ultrix) || defined(__ultrix__) || defined(_ULTRIX)
-#define PACKAGE_OS "ULTRIX"
-#elif defined(__XENIX__) || defined(_XENIX) || defined(XENIX)
-#define PACKAGE_OS "Xenix"
-#elif defined(bsdi) || defined(__bsdi) || defined(__bsdi__)
-#define PACKAGE_OS "BSDI"
-#elif defined(_arch_dreamcast)
-#define PACKAGE_OS "Dreamcast"
-#elif defined(__OS2__)
-#define PACKAGE_OS "OS/2"
-#elif defined(osf) || defined(__osf) || defined(__osf__)
-#define PACKAGE_OS "OSF"
-#elif defined(riscos) || defined(__riscos) || defined(__riscos__)
-#define PACKAGE_OS "RISC OS"
-#elif defined(__SVR4)
-#define PACKAGE_OS "Solaris"
-#elif defined __GNU__
-#define PACKAGE_OS "GNU Hurd"
-#elif defined __HAIKU__
-#define PACKAGE_OS "Haiku"
-#elif defined WIN32 || defined _WIN32 || defined __WIN32__ || defined __NT__ \
- || defined WIN64 || defined _WIN64 || defined __WIN64__ \
- || defined __MINGW32__ || defined _MSC_VER
-#define PACKAGE_OS "Windows"
-#elif defined __native_client__
-#define PACKAGE_OS "nacl"
-#else // OTHER
-#define PACKAGE_OS "Other"
-#endif // defined __APPLE__
-
-// define DEBUG_LEAKS 1
-// define DEBUG_CONFIG 1
-// define DEBUG_FONT 1
-// define DEBUG_FONT_COUNTERS 1
-// define DEBUG_ALPHA_CACHE 1
-// define DEBUG_OPENGL_LEAKS 1
-
-#ifdef USE_SDL2
-#define SDL_NAME "SDL2"
-#else // USE_SDL2
-#define SDL_NAME "SDL1.2"
-#endif // USE_SDL2
-#if defined(ENABLE_PUGIXML)
-#define XML_NAME "pugixml"
-#elif defined(ENABLE_LIBXML)
-#define XML_NAME "libxml2"
-#elif defined(ENABLE_TINYXML2)
-#define XML_NAME "tinyxml2"
-#else // defined(ENABLE_PUGIXML)
-#define XML_NAME "unknown"
-#endif // defined(ENABLE_PUGIXML)
-
-#ifdef SIMD_SUPPORTED
-#define SIMD_NAME ", SIMD"
-#else // SIMD_SUPPORTED
-#define SIMD_NAME ""
-#endif // SIMD_SUPPORTED
-
-#define PACKAGE_EXTENDED_VERSION "ManaPlus (" PACKAGE_OS \
-"; %s; " SDL_NAME ", " XML_NAME SIMD_NAME ", %s; 4144 v" SMALL_VERSION ")"
-
-#define FULL_VERSION "ManaPlus " SMALL_VERSION " " PACKAGE_OS ", " \
- SDL_NAME ", " XML_NAME SIMD_NAME
-
-#ifdef ANDROID
-#ifdef PKG_DATADIR
-#undef PKG_DATADIR
-#endif // PKG_DATADIR
-#ifdef LOCALEDIR
-#undef LOCALEDIR
-#endif // LOCALEDIR
-#define LOCALEDIR "locale"
-#endif // ANDROID
-
-#ifndef PKG_DATADIR
-#define PKG_DATADIR ""
-#endif // PKG_DATADIR
-
-#endif // MAIN_H
diff --git a/src/maingui.cpp b/src/maingui.cpp
deleted file mode 100644
index fc3df1b98..000000000
--- a/src/maingui.cpp
+++ /dev/null
@@ -1,172 +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 "maingui.h"
-
-#include "client.h"
-#include "commandline.h"
-#include "settings.h"
-
-#include "fs/virtfs/fs.h"
-
-#include "utils/delete2.h"
-#ifdef ANDROID
-#include "fs/mkdir.h"
-#include "fs/paths.h"
-#endif // ANDROID
-#include "utils/process.h"
-
-#ifdef __MINGW32__
-#include <windows.h>
-#endif // __MINGW32__
-
-#include <iostream>
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_image.h>
-#include <SDL_mixer.h>
-PRAGMA48(GCC diagnostic pop)
-
-#ifndef SDL_VERSIONNUM
-#error missing <SDL_version.h>
-#endif // SDL_VERSIONNUM
-
-#ifdef UNITTESTS
-#include "logger.h"
-
-#include "utils/cpu.h"
-#include "utils/sdlhelper.h"
-#include "resources/dye/dyepalette.h"
-#ifdef UNITTESTS_CATCH
-#define CATCH_CONFIG_RUNNER
-#include "unittests/catch.hpp"
-#endif // UNITTESTS_CATCH
-#ifdef UNITTESTS_DOCTEST
-#define DOCTEST_CONFIG_IMPLEMENT
-#include "unittests/doctest.h"
-#endif // UNITTESTS_DOCTEST
-#else // UNITTESTS
-#include "utils/xml.h"
-#endif // UNITTESTS
-
-#define SDL_IMAGE_COMPILEDVERSION \
- SDL_VERSIONNUM(SDL_IMAGE_MAJOR_VERSION, \
- SDL_IMAGE_MINOR_VERSION, SDL_IMAGE_PATCHLEVEL)
-
-#define SDL_IMAGE_VERSION_ATLEAST(X, Y, Z) \
- (SDL_IMAGE_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z))
-
-#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))
-
-#include "debug.h"
-
-char *selfName = nullptr;
-
-#ifndef UNITTESTS
-#ifdef ANDROID
-int main(int argc, char *argv[])
-#else // ANDROID
-
-int mainGui(int argc, char *argv[])
-#endif // ANDROID
-{
-#if defined(__MINGW32__)
- // load mingw crash handler. Won't fail if dll is not present.
- // may load libray from current dir, it may not same as program dir
- LoadLibrary("exchndl.dll");
-#endif // defined(__MINGW32__)
-
- selfName = argv[0];
-
- parseOptions(argc, argv);
-
- std::ios::sync_with_stdio(false);
-
-#ifdef ANDROID
- mkdir_r(getSdStoragePath().c_str());
-#endif // ANDROID
-
- VirtFs::init(argv[0]);
- XML::initXML();
-#if SDL_IMAGE_VERSION_ATLEAST(1, 2, 11)
- IMG_Init(IMG_INIT_PNG);
-#endif // SDL_IMAGE_VERSION_ATLEAST(1, 2, 11)
-#if SDL_MIXER_VERSION_ATLEAST(1, 2, 11)
- Mix_Init(MIX_INIT_OGG);
-#endif // SDL_MIXER_VERSION_ATLEAST(1, 2, 11)
-
-#ifdef WIN32
- SetCurrentDirectory(VirtFs::getBaseDir());
-#endif // WIN32
-
- setPriority(true);
- client = new Client;
- int ret = 0;
- if (!settings.options.testMode)
- {
- client->gameInit();
- ret = client->gameExec();
- }
- else
- {
- client->testsInit();
- ret = Client::testsExec();
- }
- delete2(client);
- VirtFs::deinit();
-
-#if SDL_MIXER_VERSION_ATLEAST(1, 2, 11)
- Mix_Quit();
-#endif // SDL_MIXER_VERSION_ATLEAST(1, 2, 11)
-#if SDL_IMAGE_VERSION_ATLEAST(1, 2, 11)
- IMG_Quit();
-#endif // SDL_IMAGE_VERSION_ATLEAST(1, 2, 11)
-
- return ret;
-}
-#else // UNITTESTS
-
-int main(int argc, char *argv[])
-{
- logger = new Logger;
- SDL::initLogger();
- VirtFs::init(argv[0]);
- Cpu::detect();
- DyePalette::initFunctions();
-#ifdef UNITTESTS_CATCH
- return Catch::Session().run(argc, argv);
-#elif defined(UNITTESTS_DOCTEST)
- doctest::Context context;
- context.applyCommandLine(argc, argv);
- return context.run();
-#else // UNITTESTS_CATCH
- return 1;
-#endif // UNITTESTS_CATCH
-}
-
-#endif // UNITTESTS
diff --git a/src/maingui.h b/src/maingui.h
deleted file mode 100644
index e894435c0..000000000
--- a/src/maingui.h
+++ /dev/null
@@ -1,30 +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 MAINGUI_H
-#define MAINGUI_H
-
-#include "localconsts.h"
-
-int mainGui(int argc, char *argv[]);
-
-#endif // MAINGUI_H
diff --git a/src/manaplus.rc b/src/manaplus.rc
deleted file mode 100644
index 53095ceb1..000000000
--- a/src/manaplus.rc
+++ /dev/null
@@ -1,25 +0,0 @@
-#include <windows.h> // include for version info constants
-
-#include "winver.h"
-
-A ICON MOVEABLE PURE LOADONCALL DISCARDABLE "../data/icons/manaplus.ico"
-evol ICON MOVEABLE PURE LOADONCALL DISCARDABLE "../data/evol/icons/evol-client.ico"
-tmw ICON MOVEABLE PURE LOADONCALL DISCARDABLE "../data/tmw/icons/tmw-client.ico"
-
-1 VERSIONINFO
-FILEVERSION VER_MAJOR,VER_MINOR,VER_RELEASE,VER_BUILD
-PRODUCTVERSION VER_MAJOR,VER_MINOR,VER_RELEASE,VER_BUILD
-//FILETYPE VFT_APP
-{
- BLOCK "StringFileInfo" {
- BLOCK "040904E4" {
- VALUE "CompanyName", "The ManaPlus Development Team"
- VALUE "FileVersion", PACKAGE_VERSION "4144"
- VALUE "FileDescription", "ManaPlus"
- VALUE "LegalCopyright", "2004-2014 (C)"
- VALUE "OriginalFilename", "manaplus.exe"
- VALUE "ProductName", "ManaPlus MMORPG Client"
- VALUE "ProductVersion", PACKAGE_VERSION "4144"
- }
- }
-}
diff --git a/src/mumblemanager.cpp b/src/mumblemanager.cpp
deleted file mode 100644
index efb4320ff..000000000
--- a/src/mumblemanager.cpp
+++ /dev/null
@@ -1,318 +0,0 @@
-/*
- * Code taken from: http://mumble.sourceforge.net/Link
- *
- * All code listed below is in the public domain and can be used, shared or
- * modified freely
- *
- * Copyright (C) 2011-2017 The ManaPlus Developers
- */
-
-#ifdef USE_MUMBLE
-
-#include "mumblemanager.h"
-
-#include "configuration.h"
-#include "logger.h"
-
-#include "utils/mathutils.h"
-
-#ifdef __OpenBSD__
-#include <sys/param.h>
-#endif // __OpenBSD__
-#include <wchar.h>
-#include <cctype>
-
-#include <fcntl.h>
-#include <unistd.h>
-#include <sys/types.h>
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_syswm.h>
-PRAGMA48(GCC diagnostic pop)
-
-#ifndef WIN32
-#include <sys/mman.h>
-#endif // WIN32
-
-#include "debug.h"
-
-#ifdef USE_MUMBLE
-MumbleManager *mumbleManager = nullptr;
-#endif // USE_MUMBLE
-
-MumbleManager::MumbleManager() :
- mLinkedMem(nullptr),
- mLinkedMemCache()
-{
- mMapBase[0] = mMapBase[1] = mMapBase[2] = 0.;
- init();
-}
-
-MumbleManager::~MumbleManager()
-{
- if (mLinkedMem)
- {
-#ifdef WIN32
- UnmapViewOfFile(mLinkedMem);
-#elif defined BSD4_4
-#else // WIN32
-
- munmap(mLinkedMem, sizeof(LinkedMem));
-#endif // WIN32
-
- mLinkedMem = nullptr;
- }
-}
-
-uint16_t MumbleManager::getMapId(std::string mapName)
-{
- uint16_t res = 0;
- if (mapName.size() != 5 || mapName[3] != '-')
- {
- res = getCrc16(mapName);
- }
- else
- {
- mapName = mapName.substr(0, 3) + mapName[4];
- res = CAST_U16(atoi(mapName.c_str()));
- }
- return res;
-}
-
-void MumbleManager::setMapBase(uint16_t mapid)
-{
- mMapBase[0] = 10000.0F * (mapid & 0x1F);
- mapid >>= 5;
- mMapBase[1] = 1000.0F * (mapid & 0x3F);
- mapid >>= 6;
- mMapBase[2] = 10000.0F * (mapid & 0x1F);
-}
-
-void MumbleManager::init()
-{
-#if defined BSD4_4
- return;
-#endif // defined BSD4_4
-
- if (mLinkedMem || !config.getBoolValue("enableMumble"))
- return;
-
- logger->log1("MumbleManager::init");
-#ifdef WIN32
- HANDLE hMapObject = OpenFileMappingW(FILE_MAP_ALL_ACCESS,
- FALSE, L"MumbleLink");
- if (!hMapObject)
- {
- logger->log1("MumbleManager::init can't open MumbleLink");
- return;
- }
-
- mLinkedMem = reinterpret_cast<LinkedMem *>(MapViewOfFile(hMapObject,
- FILE_MAP_ALL_ACCESS, 0, 0, sizeof(LinkedMem)));
-
- if (!mLinkedMem)
- {
- CloseHandle(hMapObject);
- hMapObject = nullptr;
- logger->log1("MumbleManager::init can't map MumbleLink");
- return;
- }
-#elif defined BSD4_4
-#else // WIN32
-
- char memName[256];
- snprintf(memName, sizeof(memName), "/MumbleLink.%u", getuid());
-
- const int shmfd = shm_open(memName, O_RDWR, S_IRUSR | S_IWUSR);
-
- if (shmfd < 0)
- {
- logger->log1("MumbleManager::init can't"
- " open shared memory MumbleLink");
- return;
- }
-
- mLinkedMem = static_cast<LinkedMem *>(mmap(nullptr,
- sizeof(LinkedMem), PROT_READ | PROT_WRITE,
- MAP_SHARED, shmfd, 0));
-
- if (mLinkedMem == reinterpret_cast<void *>(-1))
- {
- mLinkedMem = nullptr;
- logger->log1("MumbleManager::init can't map MumbleLink");
- return;
- }
-
-#endif // WIN32
-
- wcsncpy(mLinkedMemCache.name, L"ManaPlus", 256);
- wcsncpy(mLinkedMemCache.description, L"ManaPlus Plugin", 2048);
- mLinkedMemCache.uiVersion = 2;
-
- // Left handed coordinate system.
- // X positive towards "left".
- // Y positive towards "up".
- // Z positive towards "into screen".
- //
- // 1 unit = 1 meter
-
- // Unit vector pointing out of the avatars eyes
- // (here Front looks into scene).
- /* no way to look "up", 2d */
- mLinkedMemCache.fAvatarFront[1] = 0.0F;
-
- // Unit vector pointing out of the top of the avatars head
- // (here Top looks straight up).
- /* no way to change this in tmw */
- mLinkedMemCache.fAvatarTop[0] = 0.0F;
- mLinkedMemCache.fAvatarTop[1] = 1.0F;
- mLinkedMemCache.fAvatarTop[2] = 0.0F;
-
- mLinkedMemCache.fCameraFront[0] = 0.0F;
- mLinkedMemCache.fCameraFront[1] = 0.0F;
- mLinkedMemCache.fCameraFront[2] = 1.0F;
-
- mLinkedMemCache.fCameraTop[0] = 0.0F;
- mLinkedMemCache.fCameraTop[1] = 1.0F;
- mLinkedMemCache.fCameraTop[2] = 0.0F;
-
- mLinkedMemCache.uiTick++;
-}
-
-void MumbleManager::setPlayer(const std::string &userName)
-{
- if (!mLinkedMem)
- return;
-
- // Identifier which uniquely identifies a certain player in a context
- // (e.g. the ingame Name).
- mbstowcs(mLinkedMemCache.identity, userName.c_str(), 256);
- mLinkedMemCache.uiTick ++;
-PRAGMA8(GCC diagnostic push)
-PRAGMA8(GCC diagnostic ignored "-Wclass-memaccess")
- memcpy(mLinkedMem, &mLinkedMemCache, sizeof(mLinkedMemCache));
-PRAGMA8(GCC diagnostic pop)
-}
-
-void MumbleManager::setAction(const int action)
-{
- if (!mLinkedMem)
- return;
-
- switch (action)
- {
- case 0: /* STAND */
- case 1: /* WALK */
- case 2: /* ATTACK */
- case 5: /* HURT */
- mLinkedMemCache.fAvatarPosition[1] = 1.5F;
- break;
- case 3: /* SIT */
- mLinkedMemCache.fAvatarPosition[1] = 1.0F;
- break;
- case 4: /* DEAD */
- default:
- mLinkedMemCache.fAvatarPosition[1] = 0.0F;
- break;
- }
- mLinkedMemCache.fAvatarPosition[1] += mMapBase[1];
- mLinkedMemCache.fCameraPosition[1] = mLinkedMemCache.fAvatarPosition[1];
-
- mLinkedMemCache.uiTick++;
-PRAGMA8(GCC diagnostic push)
-PRAGMA8(GCC diagnostic ignored "-Wclass-memaccess")
- memcpy(mLinkedMem, &mLinkedMemCache, sizeof(mLinkedMemCache));
-PRAGMA8(GCC diagnostic pop)
-}
-
-void MumbleManager::setPos(const int tileX, const int tileY,
- const int direction)
-{
- if (!mLinkedMem)
- return;
-
- // Position of the avatar (here standing slightly off the origin)
- // lm->fAvatarPosition
-
- /* tmw coordinates work exactly the other way round */
- mLinkedMemCache.fAvatarPosition[0] = static_cast<float>(tileX)
- + mMapBase[0];
- mLinkedMemCache.fAvatarPosition[2] = static_cast<float>(tileY)
- + mMapBase[2];
-
- // Same as avatar but for the camera.
- // lm->fCameraPosition, fCameraFront, fCameraTop
-
- // Same as avatar but for the camera.
- mLinkedMemCache.fCameraPosition[0] = mLinkedMemCache.fAvatarPosition[0];
- mLinkedMemCache.fCameraPosition[2] = mLinkedMemCache.fAvatarPosition[2];
-
- // Unit vector pointing out of the avatars eyes
- // (here Front looks into scene).
- switch (direction)
- {
- case 4: /* UP */
- mLinkedMemCache.fAvatarFront[0] = 0.0F;
- mLinkedMemCache.fAvatarFront[2] = 1.0F;
- break;
- case 1: /* DOWN */
- mLinkedMemCache.fAvatarFront[0] = 0.0F;
- mLinkedMemCache.fAvatarFront[2] = -1.0F;
- break;
- case 2: /* LEFT */
- mLinkedMemCache.fAvatarFront[0] = 1.0F;
- mLinkedMemCache.fAvatarFront[2] = 0.0F;
- break;
- case 8: /* RIGHT */
- mLinkedMemCache.fAvatarFront[0] = -1.0F;
- mLinkedMemCache.fAvatarFront[2] = 0.0F;
- break;
- default:
- break;
- }
-
- mLinkedMemCache.uiTick ++;
-PRAGMA8(GCC diagnostic push)
-PRAGMA8(GCC diagnostic ignored "-Wclass-memaccess")
- memcpy(mLinkedMem, &mLinkedMemCache, sizeof(mLinkedMemCache));
-PRAGMA8(GCC diagnostic pop)
-}
-
-void MumbleManager::setMap(const std::string &mapName)
-{
- if (!mLinkedMem)
- return;
-
- // Context should be equal for players which should be able to hear each
- // other positional and differ for those who shouldn't
- // (e.g. it could contain the server+port and team)
-
- setMapBase(getMapId(mapName));
- setAction(0); /* update y coordinate */
-}
-
-void MumbleManager::setServer(const std::string &serverName)
-{
- if (!mLinkedMem)
- return;
-
- unsigned size = CAST_U32(serverName.size());
- if (size > sizeof(mLinkedMemCache.context) - 1)
- size = sizeof(mLinkedMemCache.context) - 1;
-
- memset(mLinkedMemCache.context, 0, sizeof(mLinkedMemCache.context));
-PRAGMA8(GCC diagnostic push)
-PRAGMA8(GCC diagnostic ignored "-Wclass-memaccess")
- memcpy(mLinkedMemCache.context, serverName.c_str(), size);
-PRAGMA8(GCC diagnostic pop)
- mLinkedMemCache.context[size] = '\0';
- mLinkedMemCache.context_len = size;
- mLinkedMemCache.uiTick ++;
-PRAGMA8(GCC diagnostic push)
-PRAGMA8(GCC diagnostic ignored "-Wclass-memaccess")
- memcpy(mLinkedMem, &mLinkedMemCache, sizeof(mLinkedMemCache));
-PRAGMA8(GCC diagnostic pop)
-}
-
-#endif // USE_MUMBLE
diff --git a/src/mumblemanager.h b/src/mumblemanager.h
deleted file mode 100644
index 4a3361a75..000000000
--- a/src/mumblemanager.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Code taken from: http://mumble.sourceforge.net/Link
- *
- * All code listed below is in the public domain and can be used, shared or
- * modified freely
- *
- * Copyright (C) 2011-2017 The ManaPlus Developers
- */
-
-#ifndef MUMBLEMANAGER_H
-#define MUMBLEMANAGER_H
-
-#ifdef USE_MUMBLE
-
-#include <string>
-#if defined (__FreeBSD__) || (defined __DragonFly__)
-#include <sys/stat.h>
-#endif // defined (__FreeBSD__) || (defined __DragonFly__)
-
-#include "localconsts.h"
-
-struct LinkedMem final
-{
- LinkedMem() :
- uiVersion(0U),
- uiTick(0U),
- fAvatarPosition(),
- fAvatarFront(),
- fAvatarTop(),
- name(),
- fCameraPosition(),
- fCameraFront(),
- fCameraTop(),
- identity(),
- context_len(0U),
- context(),
- description()
- { }
-
- A_DELETE_COPY(LinkedMem)
-
- uint32_t uiVersion;
- uint32_t uiTick;
- float fAvatarPosition[3];
- float fAvatarFront[3];
- float fAvatarTop[3];
- wchar_t name[256];
- float fCameraPosition[3];
- float fCameraFront[3];
- float fCameraTop[3];
- wchar_t identity[256];
- uint32_t context_len;
- char context[256];
- wchar_t description[2048];
-};
-
-class MumbleManager final
-{
- public:
- MumbleManager();
-
- A_DELETE_COPY(MumbleManager)
-
- ~MumbleManager();
-
- void init();
-
- void setPlayer(const std::string &userName);
-
- void setAction(const int action);
-
- void setPos(const int tileX, const int tileY, const int direction);
-
- void setMap(const std::string &mapName);
-
- void setServer(const std::string &serverName);
-
- private:
- static uint16_t getMapId(std::string mapName) A_WARN_UNUSED;
-
- void setMapBase(uint16_t mapid);
-
- LinkedMem *mLinkedMem;
- LinkedMem mLinkedMemCache;
- float mMapBase[3];
-};
-
-extern MumbleManager *mumbleManager;
-
-#endif // USE_MUMBLE
-#endif // MUMBLEMANAGER_H
diff --git a/src/navigationmanager.cpp b/src/navigationmanager.cpp
deleted file mode 100644
index 189d37f4e..000000000
--- a/src/navigationmanager.cpp
+++ /dev/null
@@ -1,178 +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 "navigationmanager.h"
-
-#include "enums/resources/map/blockmask.h"
-
-#include "resources/map/map.h"
-#include "resources/map/metatile.h"
-#include "resources/map/walklayer.h"
-
-#include "debug.h"
-
-static const int blockWalkMask = (BlockMask::WALL |
- BlockMask::AIR |
- BlockMask::WATER);
-
-#ifndef DYECMD
-namespace
-{
- struct Cell final
- {
- Cell(const int x0, const int y0) :
- x(x0),
- y(y0)
- {
- }
-
- A_DEFAULT_COPY(Cell)
-
- int x;
- int y;
- };
-} // namespace
-#endif // DYECMD
-
-NavigationManager::NavigationManager()
-{
-}
-
-NavigationManager::~NavigationManager()
-{
-}
-
-#ifndef DYECMD
-Resource *NavigationManager::loadWalkLayer(const Map *const map)
-{
- if (map == nullptr)
- return nullptr;
-
- const int width = map->getWidth();
- const int height = map->getHeight();
- if (width < 2 || height < 2)
- return nullptr;
- WalkLayer *const walkLayer = new WalkLayer(width, height);
-
- const MetaTile *const tiles = map->getMetaTiles();
- int *const data = walkLayer->getData();
- if ((tiles == nullptr) || (data == nullptr))
- return walkLayer;
-
- int x = 0;
- int y = 0;
- int num = 1;
- while (findWalkableTile(x, y, width, height, tiles, data))
- {
- fillNum(x, y, width, height, num, tiles, data);
- num ++;
- }
-
- return walkLayer;
-}
-
-void NavigationManager::fillNum(int x, int y,
- const int width,
- const int height,
- const int num,
- const MetaTile *const tiles,
- int *const data)
-{
- STD_VECTOR<Cell> cells;
- cells.push_back(Cell(x, y));
- while (!cells.empty())
- {
- const Cell cell = cells.back();
- cells.pop_back();
- int ptr;
- x = cell.x;
- y = cell.y;
- data[x + width * y] = num;
- if (x > 0)
- {
- ptr = (x - 1) + width * y;
- if (data[ptr] == 0)
- {
- if ((tiles[ptr].blockmask & blockWalkMask) == 0)
- cells.push_back(Cell(x - 1, y));
- else
- data[ptr] = -num;
- }
- }
- if (x < width - 1)
- {
- ptr = (x + 1) + width * y;
- if (data[ptr] == 0)
- {
- if ((tiles[ptr].blockmask & blockWalkMask) == 0)
- cells.push_back(Cell(x + 1, y));
- else
- data[ptr] = -num;
- }
- }
- if (y > 0)
- {
- ptr = x + width * (y - 1);
- if (data[ptr] == 0)
- {
- if ((tiles[ptr].blockmask & blockWalkMask) == 0)
- cells.push_back(Cell(x, y - 1));
- else
- data[ptr] = -num;
- }
- }
- if (y < height - 1)
- {
- ptr = x + width * (y + 1);
- if (data[ptr] == 0)
- {
- if ((tiles[ptr].blockmask & blockWalkMask) == 0)
- cells.push_back(Cell(x, y + 1));
- else
- data[ptr] = -num;
- }
- }
- }
-}
-
-bool NavigationManager::findWalkableTile(int &x1, int &y1,
- const int width,
- const int height,
- const MetaTile *const tiles,
- const int *const data)
-{
- for (int y = 0; y < height; y ++)
- {
- const int y2 = y * width;
- for (int x = 0; x < width; x ++)
- {
- const int ptr = x + y2;
- if (((tiles[ptr].blockmask & blockWalkMask) == 0) &&
- data[ptr] == 0)
- {
- x1 = x;
- y1 = y;
- return true;
- }
- }
- }
- return false;
-}
-#endif // DYECMD
diff --git a/src/navigationmanager.h b/src/navigationmanager.h
deleted file mode 100644
index b00860b2b..000000000
--- a/src/navigationmanager.h
+++ /dev/null
@@ -1,61 +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 NAVIGATIONMANAGER_H
-#define NAVIGATIONMANAGER_H
-
-#include "localconsts.h"
-
-class Map;
-class Resource;
-
-struct MetaTile;
-
-class NavigationManager final
-{
- public:
- NavigationManager() A_CONST;
-
- A_DELETE_COPY(NavigationManager)
-
- ~NavigationManager() A_CONST;
-
-#ifndef DYECMD
- static Resource *loadWalkLayer(const Map *const map);
-#endif // DYECMD
-
- private:
-#ifndef DYECMD
- static bool findWalkableTile(int &x1, int &y1,
- const int width,
- const int height,
- const MetaTile *const tiles,
- const int *const data) A_NONNULL(5, 6);
-
- static void fillNum(int x, int y,
- const int width,
- const int height,
- const int num,
- const MetaTile *const tiles,
- int *const data) A_NONNULL(6, 7);
-#endif // DYECMD
-};
-
-#endif // NAVIGATIONMANAGER_H
diff --git a/src/net/adminhandler.h b/src/net/adminhandler.h
deleted file mode 100644
index 6d3497be3..000000000
--- a/src/net/adminhandler.h
+++ /dev/null
@@ -1,192 +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 NET_ADMINHANDLER_H
-#define NET_ADMINHANDLER_H
-
-#include "enums/simpletypes/beingid.h"
-#include "enums/simpletypes/itemcolor.h"
-
-#include <string>
-
-#include "localconsts.h"
-
-class Being;
-
-namespace Net
-{
-
-class AdminHandler notfinal
-{
- public:
- AdminHandler()
- { }
-
- A_DELETE_COPY(AdminHandler)
-
- virtual ~AdminHandler()
- { }
-
- virtual void announce(const std::string &text) const = 0;
-
- virtual void localAnnounce(const std::string &text) const = 0;
-
- virtual void hide(const bool hide) const = 0;
-
- virtual void kick(const BeingId playerId) const = 0;
-
- virtual void kickName(const std::string &name) const = 0;
-
- virtual void kickAll() const = 0;
-
- virtual void ban(const int playerId) const = 0;
-
- virtual void banName(const std::string &name) const = 0;
-
- virtual void unban(const int playerId) const = 0;
-
- virtual void unbanName(const std::string &name) const = 0;
-
- virtual void mute(const Being *const being,
- const int type,
- const int limit) const = 0;
-
- virtual void muteName(const std::string &name) const = 0;
-
- virtual void warp(const std::string &map,
- const int x, const int y) const = 0;
-
- virtual void slide(const int x, const int y) const = 0;
-
- virtual void createItems(const int id,
- const ItemColor color,
- const int amount) const = 0;
-
- virtual void gotoName(const std::string &name) const = 0;
-
- virtual void recallName(const std::string &name) const = 0;
-
- virtual void alive(const std::string &name) const = 0;
-
- virtual void ipcheckName(const std::string &name) const = 0;
-
- virtual void resetStats() const = 0;
-
- virtual void resetSkills() const = 0;
-
- virtual void requestLogin(const Being *const being) const = 0;
-
- virtual void setTileType(const int x, const int y,
- const int type) const = 0;
-
- virtual void unequipAll(const Being *const being) const = 0;
-
- virtual void requestStats(const std::string &name) const = 0;
-
- virtual void monsterInfo(const std::string &name) const = 0;
-
- virtual void itemInfo(const std::string &name) const = 0;
-
- virtual void whoDrops(const std::string &name) const = 0;
-
- virtual void mobSearch(const std::string &name) const = 0;
-
- virtual void mobSpawnSearch(const std::string &name) const = 0;
-
- virtual void playerGmCommands(const std::string &name) const = 0;
-
- virtual void playerCharGmCommands(const std::string &name) const = 0;
-
- virtual void showLevel(const std::string &name) const = 0;
-
- virtual void showStats(const std::string &name) const = 0;
-
- virtual void showStorageList(const std::string &name) const = 0;
-
- virtual void showCartList(const std::string &name) const = 0;
-
- virtual void showInventoryList(const std::string &name) const = 0;
-
- virtual void locatePlayer(const std::string &name) const = 0;
-
- virtual void showAccountInfo(const std::string &name) const = 0;
-
- virtual void spawn(const std::string &name) const = 0;
-
- virtual void spawnSlave(const std::string &name) const = 0;
-
- virtual void spawnClone(const std::string &name) const = 0;
-
- virtual void spawnSlaveClone(const std::string &name) const = 0;
-
- virtual void spawnEvilClone(const std::string &name) const = 0;
-
- virtual void savePosition(const std::string &name) const = 0;
-
- virtual void loadPosition(const std::string &name) const = 0;
-
- virtual void randomWarp(const std::string &name) const = 0;
-
- virtual void gotoNpc(const std::string &name) const = 0;
-
- virtual void killer(const std::string &name) const = 0;
-
- virtual void killable(const std::string &name) const = 0;
-
- virtual void heal(const std::string &name) const = 0;
-
- virtual void disguise(const std::string &name) const = 0;
-
- virtual void immortal(const std::string &name) const = 0;
-
- virtual void hide(const std::string &name) const = 0;
-
- virtual void nuke(const std::string &name) const = 0;
-
- virtual void kill(const std::string &name) const = 0;
-
- virtual void jail(const std::string &name) const = 0;
-
- virtual void unjail(const std::string &name) const = 0;
-
- virtual void npcMove(const std::string &name,
- const int x,
- const int y) const = 0;
-
- virtual void hideNpc(const std::string &name) const = 0;
-
- virtual void showNpc(const std::string &name) const = 0;
-
- virtual void changePartyLeader(const std::string &name) const = 0;
-
- virtual void partyRecall(const std::string &name) const = 0;
-
- virtual void breakGuild(const std::string &name) const = 0;
-
- virtual void guildRecall(const std::string &name) const = 0;
-};
-
-} // namespace Net
-
-extern Net::AdminHandler *adminHandler;
-
-#endif // NET_ADMINHANDLER_H
diff --git a/src/net/auctionhandler.h b/src/net/auctionhandler.h
deleted file mode 100644
index ce2c004d6..000000000
--- a/src/net/auctionhandler.h
+++ /dev/null
@@ -1,76 +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 NET_AUCTIONHANDLER_H
-#define NET_AUCTIONHANDLER_H
-
-#include "enums/net/auctionsearchtype.h"
-
-#include <string>
-
-#include "localconsts.h"
-
-class Item;
-
-namespace Net
-{
-
-class AuctionHandler notfinal
-{
- public:
- AuctionHandler()
- { }
-
- A_DELETE_COPY(AuctionHandler)
-
- virtual ~AuctionHandler()
- { }
-
- virtual void cancelReg() const = 0;
-
- virtual void setItem(const Item *const item,
- const int amount) const = 0;
-
- virtual void reg(const int currentPrice,
- const int maxPrice,
- const int hours) const = 0;
-
- virtual void cancel(const int auctionId) const = 0;
-
- virtual void close(const int auctionId) const = 0;
-
- virtual void bid(const int auctionId,
- const int money) const = 0;
-
- virtual void search(const AuctionSearchTypeT type,
- const int auctionId,
- const std::string &text,
- const int page) const = 0;
-
- virtual void buy() const = 0;
-
- virtual void sell() const = 0;
-};
-
-} // namespace Net
-
-extern Net::AuctionHandler *auctionHandler;
-
-#endif // NET_AUCTIONHANDLER_H
diff --git a/src/net/bankhandler.h b/src/net/bankhandler.h
deleted file mode 100644
index a827178fb..000000000
--- a/src/net/bankhandler.h
+++ /dev/null
@@ -1,55 +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 NET_BANKHANDLER_H
-#define NET_BANKHANDLER_H
-
-#include "localconsts.h"
-
-namespace Net
-{
-
-class BankHandler notfinal
-{
- public:
- BankHandler()
- { }
-
- A_DELETE_COPY(BankHandler)
-
- virtual ~BankHandler()
- { }
-
- virtual void deposit(const int money) const = 0;
-
- virtual void withdraw(const int money) const = 0;
-
- virtual void check() const = 0;
-
- virtual void open() const = 0;
-
- virtual void close() const = 0;
-};
-
-} // namespace Net
-
-extern Net::BankHandler *bankHandler;
-
-#endif // NET_BANKHANDLER_H
diff --git a/src/net/battlegroundhandler.h b/src/net/battlegroundhandler.h
deleted file mode 100644
index 1e62b93ad..000000000
--- a/src/net/battlegroundhandler.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 NET_BATTLEGROUNDHANDLER_H
-#define NET_BATTLEGROUNDHANDLER_H
-
-#include "enums/net/battlegroundtype.h"
-
-#include <string>
-
-#include "localconsts.h"
-
-namespace Net
-{
-
-class BattleGroundHandler notfinal
-{
- public:
- BattleGroundHandler()
- { }
-
- A_DELETE_COPY(BattleGroundHandler)
-
- virtual ~BattleGroundHandler()
- { }
-
- virtual void registerBg(const BattleGroundTypeT &type,
- const std::string &name) const = 0;
-
- virtual void rekoveRequest(const std::string &name) const = 0;
-
- virtual void beginAck(const bool result,
- const std::string &bgName,
- const std::string &gameName) const = 0;
-
- virtual void checkState(const std::string &name) const = 0;
-};
-
-} // namespace Net
-
-extern Net::BattleGroundHandler *battleGroundHandler;
-
-#endif // NET_BATTLEGROUNDHANDLER_H
diff --git a/src/net/beinghandler.h b/src/net/beinghandler.h
deleted file mode 100644
index ccf998def..000000000
--- a/src/net/beinghandler.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004 The Mana World 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 NET_BEINGHANDLER_H
-#define NET_BEINGHANDLER_H
-
-#include "being/being.h"
-
-#include "enums/being/rank.h"
-
-namespace Net
-{
-
-class BeingHandler notfinal
-{
- public:
- BeingHandler()
- { }
-
- A_DELETE_COPY(BeingHandler)
-
- virtual ~BeingHandler()
- { }
-
- virtual void requestNameById(const BeingId id) const = 0;
-
- virtual void requestNameByCharId(const int id) const = 0;
-
- virtual void undress(Being *const being) const = 0;
-
- virtual void requestRanks(const RankT rank) const = 0;
-
- virtual void viewPlayerEquipment(const Being *const being) const = 0;
-};
-
-} // namespace Net
-
-extern Net::BeingHandler *beingHandler;
-
-#endif // NET_BEINGHANDLER_H
diff --git a/src/net/buyingstorehandler.h b/src/net/buyingstorehandler.h
deleted file mode 100644
index 1ab94de88..000000000
--- a/src/net/buyingstorehandler.h
+++ /dev/null
@@ -1,67 +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 NET_BUYINGSTOREHANDLER_H
-#define NET_BUYINGSTOREHANDLER_H
-
-#include "utils/vector.h"
-
-#include <string>
-
-#include "localconsts.h"
-
-class Being;
-class Item;
-class ShopItem;
-
-namespace Net
-{
-
-class BuyingStoreHandler notfinal
-{
- public:
- BuyingStoreHandler()
- { }
-
- A_DELETE_COPY(BuyingStoreHandler)
-
- virtual ~BuyingStoreHandler()
- { }
-
- virtual void open(const Being *const being) const = 0;
-
- virtual void create(const std::string &name,
- const int maxMoney,
- const bool flag,
- const STD_VECTOR<ShopItem*> &items) const = 0;
-
- virtual void close() const = 0;
-
- virtual void sell(const Being *const being,
- const int storeId,
- const Item *const item,
- const int amount) const = 0;
-};
-
-} // namespace Net
-
-extern Net::BuyingStoreHandler *buyingStoreHandler;
-
-#endif // NET_BUYINGSTOREHANDLER_H
diff --git a/src/net/buysellhandler.h b/src/net/buysellhandler.h
deleted file mode 100644
index e6f66129c..000000000
--- a/src/net/buysellhandler.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 NET_BUYSELLHANDLER_H
-#define NET_BUYSELLHANDLER_H
-
-#include "resources/item/shopitem.h"
-
-class BuyDialog;
-
-namespace Net
-{
-
-class BuySellHandler notfinal
-{
- public:
- BuySellHandler()
- { }
-
- A_DELETE_COPY(BuySellHandler)
-
- virtual ~BuySellHandler()
- { }
-
- virtual void requestSellList(const std::string &nick) const = 0;
-
- virtual void requestBuyList(const std::string &nick) const = 0;
-
- virtual void sendBuyRequest(const std::string &nick,
- const ShopItem *const item,
- const int amount) const = 0;
-
- virtual void sendSellRequest(const std::string &nick,
- const ShopItem *const item,
- const int amount) const = 0;
-
- virtual void close() const = 0;
-
- virtual void cleanDialogReference(const BuyDialog *const dialog)
- const = 0;
-};
-
-} // namespace Net
-
-extern Net::BuySellHandler *buySellHandler;
-
-#endif // NET_BUYSELLHANDLER_H
diff --git a/src/net/cashshophandler.h b/src/net/cashshophandler.h
deleted file mode 100644
index 68b7c3ceb..000000000
--- a/src/net/cashshophandler.h
+++ /dev/null
@@ -1,67 +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 NET_CASHSHOPHANDLER_H
-#define NET_CASHSHOPHANDLER_H
-
-#include "enums/simpletypes/itemcolor.h"
-
-#include "utils/vector.h"
-
-#include "localconsts.h"
-
-class ShopItem;
-
-namespace Net
-{
-
-class CashShopHandler notfinal
-{
- public:
- CashShopHandler()
- { }
-
- A_DELETE_COPY(CashShopHandler)
-
- virtual ~CashShopHandler()
- { }
-
- virtual void buyItem(const int points,
- const int itemId,
- const ItemColor color,
- const int amount) const = 0;
-
- virtual void buyItems(const int points,
- const STD_VECTOR<ShopItem*> &items) const = 0;
-
- virtual void close() const = 0;
-
- virtual void requestPoints() const = 0;
-
- virtual void requestTab(const int tab) const = 0;
-
- virtual void schedule() const = 0;
-};
-
-} // namespace Net
-
-extern Net::CashShopHandler *cashShopHandler;
-
-#endif // NET_CASHSHOPHANDLER_H
diff --git a/src/net/character.h b/src/net/character.h
deleted file mode 100644
index b2340e154..000000000
--- a/src/net/character.h
+++ /dev/null
@@ -1,64 +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 NET_CHARACTER_H
-#define NET_CHARACTER_H
-
-#include "being/localplayer.h"
-#include "being/playerinfo.h"
-
-#include "utils/delete2.h"
-
-#include "localconsts.h"
-
-namespace Net
-{
-
-/**
- * A structure to hold information about a character.
- */
-struct Character final
-{
- Character() :
- dummy(nullptr),
- data(),
- slot(0U)
- {
- }
-
- A_DELETE_COPY(Character)
-
- ~Character()
- {
- delete2(dummy);
- }
-
- LocalPlayer *dummy; /**< A dummy representing this character */
- PlayerInfoBackend data;
- uint16_t slot; /**< The index in the list of characters */
-};
-
-typedef std::list<Character*> Characters;
-
-} // namespace Net
-
-#endif // NET_CHARACTER_H
diff --git a/src/net/characters.h b/src/net/characters.h
deleted file mode 100644
index 429abd848..000000000
--- a/src/net/characters.h
+++ /dev/null
@@ -1,37 +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 NET_CHARACTERS_H
-#define NET_CHARACTERS_H
-
-#include <list>
-
-#include "localconsts.h"
-
-namespace Net
-{
- struct Character;
-
- typedef std::list<Character*> Characters;
-} // namespace Net
-
-#endif // NET_CHARACTERS_H
diff --git a/src/net/charserverhandler.cpp b/src/net/charserverhandler.cpp
deleted file mode 100644
index c6bef957c..000000000
--- a/src/net/charserverhandler.cpp
+++ /dev/null
@@ -1,48 +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 "net/charserverhandler.h"
-
-#include "gui/windows/charselectdialog.h"
-
-#include "debug.h"
-
-namespace Net
-{
-
-Net::Characters CharServerHandler::mCharacters;
-Net::Character *CharServerHandler::mSelectedCharacter = nullptr;
-CharSelectDialog *CharServerHandler::mCharSelectDialog = nullptr;
-CharCreateDialog *CharServerHandler::mCharCreateDialog = nullptr;
-
-void CharServerHandler::updateCharSelectDialog()
-{
- if (mCharSelectDialog != nullptr)
- mCharSelectDialog->setCharacters(mCharacters);
-}
-
-void CharServerHandler::unlockCharSelectDialog()
-{
- if (mCharSelectDialog != nullptr)
- mCharSelectDialog->unlock();
-}
-
-} // namespace Net
diff --git a/src/net/charserverhandler.h b/src/net/charserverhandler.h
deleted file mode 100644
index 7d14a3bab..000000000
--- a/src/net/charserverhandler.h
+++ /dev/null
@@ -1,125 +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 NET_CHARSERVERHANDLER_H
-#define NET_CHARSERVERHANDLER_H
-
-#include "enums/being/gender.h"
-
-#include "enums/simpletypes/beingid.h"
-
-#include "net/characters.h"
-
-#include "utils/vector.h"
-
-#include <string>
-
-class CharCreateDialog;
-class CharSelectDialog;
-
-namespace Net
-{
-
-struct Character;
-
-class CharServerHandler notfinal
-{
- public:
- A_DELETE_COPY(CharServerHandler)
-
- virtual ~CharServerHandler()
- { }
-
- virtual void setCharSelectDialog(CharSelectDialog *const window)
- const = 0;
-
- virtual void setCharCreateDialog(CharCreateDialog *const window)
- const = 0;
-
- virtual void requestCharacters() const = 0;
-
- virtual void chooseCharacter(Net::Character *const character)
- const = 0;
-
- virtual void newCharacter(const std::string &name,
- const int slot,
- const GenderT gender,
- const int hairstyle,
- const int hairColor,
- const unsigned char race,
- const uint16_t look,
- const STD_VECTOR<int> &stats) const = 0;
-
- virtual void deleteCharacter(Net::Character *const character,
- const std::string &email) const = 0;
-
- virtual void renameCharacter(const BeingId id,
- const std::string &newName) const = 0;
-
- virtual void switchCharacter() const = 0;
-
- virtual unsigned int baseSprite() const A_WARN_UNUSED = 0;
-
- virtual unsigned int hairSprite() const A_WARN_UNUSED = 0;
-
- virtual unsigned int hatSprite() const A_WARN_UNUSED = 0;
-
- virtual unsigned int maxSprite() const A_WARN_UNUSED = 0;
-
- virtual void clear() const = 0;
-
- virtual bool isNeedCreatePin() const = 0;
-
- virtual void setNewPincode(const std::string &pin) const = 0;
-
- virtual void changeSlot(const int oldSlot,
- const int newSlot) const = 0;
-
- virtual void ping() const = 0;
-
- /** The list of available characters. */
- static Net::Characters mCharacters;
-
- static CharSelectDialog *mCharSelectDialog;
- static CharCreateDialog *mCharCreateDialog;
-
- /** The selected character. */
- static Net::Character *mSelectedCharacter;
-
- static void updateCharSelectDialog();
- static void unlockCharSelectDialog();
-
- protected:
- CharServerHandler()
- {
- mCharacters.clear();
- mSelectedCharacter = nullptr;
- mCharSelectDialog = nullptr;
- mCharCreateDialog = nullptr;
- }
-};
-
-} // namespace Net
-
-extern Net::CharServerHandler *charServerHandler;
-
-#endif // NET_CHARSERVERHANDLER_H
diff --git a/src/net/chathandler.h b/src/net/chathandler.h
deleted file mode 100644
index e43912ca2..000000000
--- a/src/net/chathandler.h
+++ /dev/null
@@ -1,111 +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 NET_CHATHANDLER_H
-#define NET_CHATHANDLER_H
-
-#include <string>
-
-#include "localconsts.h"
-
-struct ChatObject;
-
-namespace Net
-{
-
-class ChatHandler notfinal
-{
- public:
- ChatHandler()
- { }
-
- A_DELETE_COPY(ChatHandler)
-
- virtual ~ChatHandler()
- { }
-
- virtual void talk(const std::string &restrict text,
- const std::string &restrict channel) const = 0;
-
- virtual void talkPet(const std::string &restrict text,
- const std::string &restrict channel) const = 0;
-
- virtual void talkRaw(const std::string &text) const = 0;
-
- virtual void me(const std::string &restrict text,
- const std::string &restrict channel) const = 0;
-
- virtual void privateMessage(const std::string &restrict recipient,
- const std::string &restrict text)
- const = 0;
-
- virtual void channelMessage(const std::string &restrict channel,
- const std::string &restrict text)
- const = 0;
-
- virtual void joinChannel(const std::string &channel) const = 0;
-
- virtual void partChannel(const std::string &channel) const = 0;
-
- virtual void who() const = 0;
-
- virtual void sendRaw(const std::string &args) const = 0;
-
- virtual void ignoreAll() const = 0;
-
- virtual void unIgnoreAll() const = 0;
-
- virtual void ignore(const std::string &nick) const = 0;
-
- virtual void unIgnore(const std::string &nick) const = 0;
-
- virtual void requestIgnoreList() const = 0;
-
- virtual void clear() const = 0;
-
- virtual void createChatRoom(const std::string &title,
- const std::string &password,
- const int limit,
- const bool isPublic) const = 0;
-
- virtual void leaveChatRoom() const = 0;
-
- virtual void battleTalk(const std::string &text) const = 0;
-
- virtual void joinChat(const ChatObject *const chat,
- const std::string &password) const = 0;
-
- virtual void setChatRoomOptions(const int limit,
- const bool isPublic,
- const std::string &password,
- const std::string &title) const = 0;
-
- virtual void setChatRoomOwner(const std::string &nick) const = 0;
-
- virtual void kickFromChatRoom(const std::string &nick) const = 0;
-};
-
-} // namespace Net
-
-extern Net::ChatHandler *chatHandler;
-
-#endif // NET_CHATHANDLER_H
diff --git a/src/net/download.cpp b/src/net/download.cpp
deleted file mode 100644
index 9068f15ca..000000000
--- a/src/net/download.cpp
+++ /dev/null
@@ -1,643 +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 "net/download.h"
-
-#include "configuration.h"
-#include "logger.h"
-#include "settings.h"
-
-#include "fs/files.h"
-
-#include "utils/cast.h"
-#include "utils/sdlhelper.h"
-
-#include <zlib.h>
-
-#include <sstream>
-
-#include "debug.h"
-
-const char *DOWNLOAD_ERROR_MESSAGE_THREAD
- = "Could not create download thread!";
-
-extern volatile bool isTerminate;
-
-enum
-{
- OPTIONS_NONE = 0,
- OPTIONS_MEMORY = 1
-};
-
-namespace Net
-{
-
-std::string Download::mUploadResponse;
-
-Download::Download(void *const ptr,
- const std::string &url,
- const DownloadUpdate updateFunction,
- const bool ignoreError,
- const bool isUpload,
- const bool isXml) :
- mPtr(ptr),
- mUrl(url),
- mOptions(),
- mFileName(),
- mUrlQueue(),
- mWriteFunction(nullptr),
- mAdler(0),
- mUpdateFunction(updateFunction),
- mThread(nullptr),
- mCurl(nullptr),
- mHeaders(nullptr),
- mFormPost(nullptr),
- mError(static_cast<char*>(calloc(CURL_ERROR_SIZE + 1, 1))),
- mIgnoreError(ignoreError),
- mUpload(isUpload),
- mIsXml(isXml)
-{
- if (mError != nullptr)
- mError[0] = 0;
-
- mOptions.cancel = 0;
- mOptions.memoryWrite = 0;
- mOptions.checkAdler = 1u;
- if (!mUpload)
- {
- const std::string serverName = settings.serverName;
- if (!serverName.empty())
- {
- if (mUrl.find('?') == std::string::npos)
- mUrl.append("?host=");
- else
- mUrl.append("&host=");
- mUrl.append(serverName);
- }
- }
- mUrlQueue.push(url);
-}
-
-Download::~Download()
-{
- if (mFormPost != nullptr)
- {
- curl_formfree(mFormPost);
- mFormPost = nullptr;
- }
-
- if (mHeaders != nullptr)
- {
- curl_slist_free_all(mHeaders);
- mHeaders = nullptr;
- }
-
- SDL::WaitThread(mThread);
- mThread = nullptr;
- free(mError);
-}
-
-/**
- * Calculates the Alder-32 checksum for the given file.
- */
-unsigned long Download::fadler32(FILE *const file)
-{
- if (file == nullptr)
- return 0;
-
- // Obtain file size
- fseek(file, 0, SEEK_END);
- const long fileSize = ftell(file);
- if (fileSize < 0)
- { // file size error
- return 0;
- }
- rewind(file);
-
- // Calculate Adler-32 checksum
- char *const buffer = new char[CAST_SIZE(fileSize)];
- const uInt read = static_cast<uInt>(fread(buffer, 1, fileSize, file));
- unsigned long adler = adler32(0L, nullptr, 0);
- adler = adler32(static_cast<uInt>(adler),
- reinterpret_cast<Bytef*>(buffer), read);
- delete [] buffer;
- return adler;
-}
-
-unsigned long Download::adlerBuffer(const char *const buffer, int size)
-{
- FUNC_BLOCK("Download::adlerBuffer", 1)
- unsigned long adler = adler32(0L, nullptr, 0);
- return adler32(static_cast<uInt>(adler),
- reinterpret_cast<const Bytef*>(buffer), size);
-}
-
-void Download::addHeader(const std::string &header)
-{
- mHeaders = curl_slist_append(mHeaders, header.c_str());
-}
-
-void Download::noCache()
-{
- addHeader("pragma: no-cache");
- addHeader("Cache-Control: no-cache");
-}
-
-void Download::setFile(const std::string &filename, const int64_t adler32)
-{
- mOptions.memoryWrite = 0;
- mFileName = filename;
-
- if (adler32 > -1)
- {
- mAdler = static_cast<unsigned long>(adler32);
- mOptions.checkAdler = 1u;
- }
- else
- {
- mOptions.checkAdler = 0;
- }
-}
-
-void Download::setWriteFunction(WriteFunction write)
-{
- mOptions.memoryWrite = 1u;
- mWriteFunction = write;
-}
-
-bool Download::start()
-{
- logger->log("Starting download: %s", mUrl.c_str());
-
- mThread = SDL::createThread(&downloadThread, "download", this);
- if (mThread == nullptr)
- {
- logger->log1(DOWNLOAD_ERROR_MESSAGE_THREAD);
- if (mError != nullptr)
- strcpy(mError, DOWNLOAD_ERROR_MESSAGE_THREAD);
- mUpdateFunction(mPtr, DownloadStatus::ThreadError, 0, 0);
- if (!mIgnoreError)
- return false;
- }
-
- return true;
-}
-
-void Download::cancel()
-{
- logger->log("Canceling download: %s", mUrl.c_str());
-
- mOptions.cancel = 1u;
- SDL::WaitThread(mThread);
- mThread = nullptr;
-}
-
-const char *Download::getError() const
-{
- return mError;
-}
-
-int Download::downloadProgress(void *clientp, double dltotal, double dlnow,
- double ultotal A_UNUSED, double ulnow A_UNUSED)
-{
- Download *const d = reinterpret_cast<Download *>(clientp);
-
- if (d == nullptr)
- return -5;
-
- if (d->mUpload)
- return 0;
-
- if (d->mOptions.cancel != 0u)
- {
- return d->mUpdateFunction(d->mPtr, DownloadStatus::Cancelled,
- CAST_SIZE(dltotal),
- CAST_SIZE(dlnow));
- }
-
- return d->mUpdateFunction(d->mPtr, DownloadStatus::Idle,
- CAST_SIZE(dltotal),
- CAST_SIZE(dlnow));
-}
-
-int Download::downloadThread(void *ptr)
-{
- int attempts = 0;
- bool complete = false;
- Download *const d = reinterpret_cast<Download*>(ptr);
- CURLcode res;
-
- if (d == nullptr)
- return 0;
-
- std::string outFilename;
- if (d->mUpload)
- {
- outFilename = d->mFileName;
- prepareForm(&d->mFormPost, outFilename);
- }
- else
- {
- if (d->mOptions.memoryWrite == 0u)
- outFilename = d->mFileName + ".part";
- else
- outFilename.clear();
- }
-
- while (!d->mUrlQueue.empty())
- {
- attempts = 0;
- complete = false;
- d->mUrl = d->mUrlQueue.front();
- d->mUrlQueue.pop();
-
- logger->log_r("selected url: %s", d->mUrl.c_str());
- while (attempts < 3 &&
- !complete &&
- (d->mOptions.cancel == 0u) &&
- isTerminate == false)
- {
- d->mUpdateFunction(d->mPtr, DownloadStatus::Starting, 0, 0);
-
- if ((d->mOptions.cancel != 0u) || isTerminate == true)
- {
- return 0;
- }
- d->mCurl = curl_easy_init();
-
- if (d->mCurl != nullptr &&
- d->mOptions.cancel == 0u &&
- isTerminate == false)
- {
- FILE *file = nullptr;
-
- if (d->mUpload)
- {
- logger->log_r("Uploading: %s", d->mUrl.c_str());
- curl_easy_setopt(d->mCurl, CURLOPT_URL, d->mUrl.c_str());
- curl_easy_setopt(d->mCurl, CURLOPT_HTTPPOST, d->mFormPost);
- curl_easy_setopt(d->mCurl, CURLOPT_WRITEFUNCTION,
- &Download::writeFunction);
- mUploadResponse.clear();
- }
- else
- {
- logger->log_r("Downloading: %s", d->mUrl.c_str());
- curl_easy_setopt(d->mCurl, CURLOPT_FOLLOWLOCATION, 1);
- curl_easy_setopt(d->mCurl, CURLOPT_HTTPHEADER,
- d->mHeaders);
- if (d->mOptions.memoryWrite != 0u)
- {
- curl_easy_setopt(d->mCurl, CURLOPT_FAILONERROR, 1);
- curl_easy_setopt(d->mCurl, CURLOPT_WRITEFUNCTION,
- d->mWriteFunction);
- curl_easy_setopt(d->mCurl, CURLOPT_WRITEDATA, d->mPtr);
- }
- else
- {
- file = fopen(outFilename.c_str(), "w+b");
- if (file != nullptr)
- {
- curl_easy_setopt(d->mCurl, CURLOPT_WRITEDATA,
- file);
- }
- }
- curl_easy_setopt(d->mCurl,
- CURLOPT_USERAGENT,
- settings.userAgent.c_str());
-
- curl_easy_setopt(d->mCurl, CURLOPT_ERRORBUFFER, d->mError);
- curl_easy_setopt(d->mCurl, CURLOPT_URL, d->mUrl.c_str());
- curl_easy_setopt(d->mCurl, CURLOPT_NOPROGRESS, 0);
- curl_easy_setopt(d->mCurl, CURLOPT_PROGRESSFUNCTION,
- &downloadProgress);
- curl_easy_setopt(d->mCurl, CURLOPT_PROGRESSDATA, ptr);
-#if LIBCURL_VERSION_NUM >= 0x070a00
- curl_easy_setopt(d->mCurl, CURLOPT_NOSIGNAL, 1);
-#endif // LIBCURL_VERSION_NUM >= 0x070a00
- curl_easy_setopt(d->mCurl, CURLOPT_CONNECTTIMEOUT, 30);
- curl_easy_setopt(d->mCurl, CURLOPT_TIMEOUT, 1800);
- addHeaders(d->mCurl);
- addProxy(d->mCurl);
- secureCurl(d->mCurl);
- }
-
- if ((res = curl_easy_perform(d->mCurl)) != 0 &&
- (d->mOptions.cancel == 0u) &&
- isTerminate == false)
- {
- PRAGMA45(GCC diagnostic push)
- PRAGMA45(GCC diagnostic ignored "-Wswitch-enum")
- switch (res)
- {
- case CURLE_ABORTED_BY_CALLBACK:
- d->mOptions.cancel = 1u;
- break;
- case CURLE_COULDNT_CONNECT:
- default:
- break;
- }
- PRAGMA45(GCC diagnostic pop)
-
- if (res != 0u)
- {
- if (d->mError != nullptr)
- {
- logger->log_r("curl error %d: %s host: %s",
- res, d->mError, d->mUrl.c_str());
- }
- attempts++;
- continue;
- }
-
- if ((d->mOptions.cancel != 0u) || isTerminate == true)
- break;
-
-// d->mUpdateFunction(d->mPtr, DownloadStatus::Error, 0, 0);
-
- if (file != nullptr)
- {
- fclose(file);
- file = nullptr;
- }
- if (!d->mUpload && (d->mOptions.memoryWrite == 0u))
- ::remove(outFilename.c_str());
- attempts++;
- continue;
- }
-
- curl_easy_cleanup(d->mCurl);
- d->mCurl = nullptr;
-
- if (d->mUpload)
- {
- if (file != nullptr)
- {
- fclose(file);
- file = nullptr;
- }
- // need check first if we read data from server
- complete = true;
- }
- else
- {
- if (d->mOptions.memoryWrite == 0u)
- {
- // Don't check resources.xml checksum
- if (d->mOptions.checkAdler != 0u)
- {
- const unsigned long adler = fadler32(file);
-
- if (d->mAdler != adler)
- {
- if (file != nullptr)
- {
- fclose(file);
- file = nullptr;
- }
-
- // Remove the corrupted file
- ::remove(d->mFileName.c_str());
- logger->log_r("Checksum for file %s failed:"
- " (%lx/%lx)",
- d->mFileName.c_str(),
- adler, d->mAdler);
- attempts++;
- continue;
- }
- }
-
- if (file != nullptr)
- {
- fclose(file);
- file = nullptr;
- }
-
- // Any existing file with this name is deleted first,
- // otherwise the rename will fail on Windows.
- if ((d->mOptions.cancel == 0u) && isTerminate == false)
- {
- if (d->mIsXml)
- {
- if (!XML::Document::validateXml(outFilename))
- {
- logger->log_r("Xml file validation error");
- attempts++;
- continue;
- }
- }
-
- ::remove(d->mFileName.c_str());
- Files::renameFile(outFilename, d->mFileName);
-
- // Check if we can open it and no errors were
- // encountered during renaming
- file = fopen(d->mFileName.c_str(), "rb");
- if (file != nullptr)
- {
- fclose(file);
- file = nullptr;
- complete = true;
- }
- }
- }
- else
- {
- // It's stored in memory, we're done
- complete = true;
- }
- }
- }
-
- if (d->mCurl != nullptr)
- {
- curl_easy_cleanup(d->mCurl);
- d->mCurl = nullptr;
- }
-
- if ((d->mOptions.cancel != 0u) || isTerminate == true)
- {
- return 0;
- }
- attempts++;
- }
-
- if ((complete && attempts < 3) || (d->mOptions.cancel != 0u))
- break;
- }
-
- if ((d->mOptions.cancel != 0u) || isTerminate == true)
- {
- // Nothing to do...
- }
- else if (!complete || attempts >= 3)
- {
- d->mUpdateFunction(d->mPtr, DownloadStatus::Error, 0, 0);
- }
- else
- {
- d->mUpdateFunction(d->mPtr, DownloadStatus::Complete, 0, 0);
- }
-
- return 0;
-}
-
-void Download::addProxy(CURL *const curl)
-{
- const int mode = config.getIntValue("downloadProxyType");
- if (mode == 0)
- return;
-
- if (mode > 1)
- {
- curl_easy_setopt(curl, CURLOPT_PROXY,
- config.getStringValue("downloadProxy").c_str());
- }
-
- switch (mode)
- {
- case 1: // direct connection
- default:
- curl_easy_setopt(curl, CURLOPT_PROXY, "");
- break;
- case 2: // HTTP
-#if LIBCURL_VERSION_NUM >= 0x070300
- curl_easy_setopt(curl, CURLOPT_HTTPPROXYTUNNEL,
- config.getIntValue("downloadProxyTunnel"));
-#endif // LIBCURL_VERSION_NUM >= 0x070300
- break;
- case 3: // HTTP 1.0
-#if LIBCURL_VERSION_NUM >= 0x071304
- curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP_1_0);
-#endif // LIBCURL_VERSION_NUM >= 0x071304
-#if LIBCURL_VERSION_NUM >= 0x070300
- curl_easy_setopt(curl, CURLOPT_HTTPPROXYTUNNEL,
- config.getIntValue("downloadProxyTunnel"));
-#endif // LIBCURL_VERSION_NUM >= 0x070300
- break;
- case 4: // SOCKS4
-#if LIBCURL_VERSION_NUM >= 0x070a00
- curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
-#endif // LIBCURL_VERSION_NUM >= 0x070a00
- break;
- case 5: // SOCKS4A
-#if LIBCURL_VERSION_NUM >= 0x071200
- curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4A);
-#elif LIBCURL_VERSION_NUM >= 0x071000
- curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
-#endif // LIBCURL_VERSION_NUM >= 0x071200
-
- break;
- case 6: // SOCKS5
-#if LIBCURL_VERSION_NUM >= 0x071200
- curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
-#endif // LIBCURL_VERSION_NUM >= 0x071200
-
- break;
- case 7: // SOCKS5 hostname
-#if LIBCURL_VERSION_NUM >= 0x071200
- curl_easy_setopt(curl, CURLOPT_PROXYTYPE,
- CURLPROXY_SOCKS5_HOSTNAME);
-#endif // LIBCURL_VERSION_NUM >= 0x071200
-
- break;
- }
-}
-
-#if LIBCURL_VERSION_NUM >= 0x070a08
-void Download::secureCurl(CURL *const curl)
-#else // LIBCURL_VERSION_NUM >= 0x070f01
-void Download::secureCurl(CURL *const curl A_UNUSED)
-#endif // LIBCURL_VERSION_NUM >= 0x070f01
-{
-#if LIBCURL_VERSION_NUM >= 0x071304
- curl_easy_setopt(curl, CURLOPT_PROTOCOLS,
- CURLPROTO_HTTP | CURLPROTO_HTTPS);
- curl_easy_setopt(curl, CURLOPT_REDIR_PROTOCOLS,
- CURLPROTO_HTTP | CURLPROTO_HTTPS);
-#endif // LIBCURL_VERSION_NUM >= 0x071304
-#if LIBCURL_VERSION_NUM >= 0x071500
- curl_easy_setopt(curl, CURLOPT_WILDCARDMATCH, 0);
-#endif // LIBCURL_VERSION_NUM >= 0x071500
-#if LIBCURL_VERSION_NUM >= 0x070f01
- curl_easy_setopt(curl, CURLOPT_MAXREDIRS, 3);
-#endif // LIBCURL_VERSION_NUM >= 0x070f01
-#if LIBCURL_VERSION_NUM >= 0x070a08
- curl_easy_setopt(curl, CURLOPT_MAXFILESIZE, 536870912);
-#endif // LIBCURL_VERSION_NUM >= 0x070a08
-
-#if LIBCURL_VERSION_NUM >= 0x073100
- curl_easy_setopt(curl, CURLOPT_TCP_FASTOPEN, 1L);
-#endif // LIBCURL_VERSION_NUM >= 0x073100
-
- curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 1L);
- curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, 60L);
-}
-
-#if LIBCURL_VERSION_NUM >= 0x071507
-void Download::addHeaders(CURL *const curl)
-{
- curl_easy_setopt(curl, CURLOPT_ACCEPT_ENCODING, "");
-}
-#else // LIBCURL_VERSION_NUM >= 0x071507
-
-void Download::addHeaders(CURL *const curl A_UNUSED)
-{
-}
-#endif // LIBCURL_VERSION_NUM >= 0x071507
-
-void Download::prepareForm(curl_httppost **form, const std::string &fileName)
-{
- curl_httppost *lastPtr = nullptr;
-
- std::ifstream file;
- file.open(fileName.c_str(), std::ios::in);
- if (!file.is_open())
- return;
-
- char *line = new char[10001];
- std::ostringstream str;
- while (file.getline(line, 10000))
- str << line << "\n";
-
- delete [] line;
-
- curl_formadd(form, &lastPtr,
- CURLFORM_COPYNAME, "sprunge",
- CURLFORM_COPYCONTENTS, str.str().c_str(),
- CURLFORM_END);
-}
-
-size_t Download::writeFunction(void *ptr,
- size_t size,
- size_t nmemb,
- void *stream A_UNUSED)
-{
- const size_t totalMem = size * nmemb;
- char *buf = new char[totalMem + 1];
- memcpy(buf, ptr, totalMem);
- buf[totalMem] = 0;
- mUploadResponse.append(buf);
- delete [] buf;
- return totalMem;
-}
-
-} // namespace Net
diff --git a/src/net/download.h b/src/net/download.h
deleted file mode 100644
index ce99b7b91..000000000
--- a/src/net/download.h
+++ /dev/null
@@ -1,144 +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 NET_DOWNLOAD_H
-#define NET_DOWNLOAD_H
-
-#include "enums/net/downloadstatus.h"
-
-#include <curl/curl.h>
-
-#include <string>
-#include <queue>
-
-#include "localconsts.h"
-
-typedef int (*DownloadUpdate)(void *ptr,
- const DownloadStatusT status,
- size_t total,
- const size_t remaining);
-
-// Matches what CURL expects
-typedef size_t (*WriteFunction)( void *ptr, size_t size, size_t nmemb,
- void *stream);
-
-struct SDL_Thread;
-
-namespace Net
-{
-class Download final
-{
- public:
- Download(void *const ptr,
- const std::string &url,
- const DownloadUpdate updateFunction,
- const bool ignoreError,
- const bool isUpload,
- const bool isXml);
-
- A_DELETE_COPY(Download)
-
- ~Download();
-
- void addHeader(const std::string &header);
-
- /**
- * Convience method for adding no-cache headers.
- */
- void noCache();
-
- void setFile(const std::string &filename, const int64_t adler32 = -1);
-
- void setWriteFunction(WriteFunction write);
-
- /**
- * Starts the download thread.
- * @returns true if thread was created
- * false if the thread could not be made or download wasn't
- * properly setup
- */
- bool start();
-
- /**
- * Cancels the download. Returns immediately, the cancelled status will
- * be noted in the next avialable update call.
- */
- void cancel();
-
- void addMirror(const std::string &str)
- { mUrlQueue.push(str); }
-
- const char *getError() const A_WARN_UNUSED;
-
- void setIgnoreError(const bool n)
- { mIgnoreError = n; }
-
- static size_t writeFunction(void *ptr, size_t size,
- size_t nmemb, void *stream);
-
- static void prepareForm(curl_httppost **form,
- const std::string &fileName);
-
- static unsigned long fadler32(FILE *const file) A_WARN_UNUSED;
-
- static void addProxy(CURL *const curl);
-
- static void secureCurl(CURL *const curl);
-
- static void addHeaders(CURL *const curl);
-
- static unsigned long adlerBuffer(const char *const buffer, int size);
-
- static std::string getUploadResponse()
- { return mUploadResponse; }
-
- private:
- static int downloadThread(void *ptr);
- static int downloadProgress(void *clientp, double dltotal,
- double dlnow, double ultotal,
- double ulnow);
- static std::string mUploadResponse;
- void *mPtr;
- std::string mUrl;
- struct
- {
- unsigned cancel : 1;
- unsigned memoryWrite: 1;
- unsigned checkAdler: 1;
- } mOptions;
- std::string mFileName;
- std::queue<std::string> mUrlQueue;
- WriteFunction mWriteFunction;
- unsigned long mAdler;
- DownloadUpdate mUpdateFunction;
- SDL_Thread *mThread;
- CURL *mCurl;
- curl_slist *mHeaders;
- curl_httppost *mFormPost;
- char *mError;
- bool mIgnoreError;
- bool mUpload;
- bool mIsXml;
-};
-
-} // namespace Net
-
-#endif // NET_DOWNLOAD_H
diff --git a/src/net/ea/adminhandler.cpp b/src/net/ea/adminhandler.cpp
deleted file mode 100644
index 4188fc803..000000000
--- a/src/net/ea/adminhandler.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 "net/ea/adminhandler.h"
-
-#include "utils/gmfunctions.h"
-#include "utils/stringutils.h"
-
-#include "debug.h"
-
-namespace Ea
-{
-
-void AdminHandler::kickName(const std::string &name) const
-{
- Gm::runCommand("kick", name);
-}
-
-void AdminHandler::ban(const int playerId A_UNUSED) const
-{
- // Not supported
-}
-
-void AdminHandler::banName(const std::string &name) const
-{
- Gm::runCommand("ban", name);
-}
-
-void AdminHandler::unban(const int playerId A_UNUSED) const
-{
- // Not supported
-}
-
-void AdminHandler::unbanName(const std::string &name) const
-{
- Gm::runCommand("unban", name);
-}
-
-void AdminHandler::ipcheckName(const std::string &name) const
-{
- Gm::runCommand("ipcheck", name);
-}
-
-void AdminHandler::createItems(const int id,
- const ItemColor color A_UNUSED,
- const int amount) const
-{
- Gm::runCommand("item",
- strprintf("%d %d", id, amount));
-}
-
-void AdminHandler::spawn(const std::string &name) const
-{
- Gm::runCommand("spawn", name);
-}
-
-} // namespace Ea
diff --git a/src/net/ea/adminhandler.h b/src/net/ea/adminhandler.h
deleted file mode 100644
index f300fda55..000000000
--- a/src/net/ea/adminhandler.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 NET_EA_ADMINHANDLER_H
-#define NET_EA_ADMINHANDLER_H
-
-#include "net/adminhandler.h"
-
-#include "localconsts.h"
-
-namespace Ea
-{
-
-class AdminHandler notfinal : public Net::AdminHandler
-{
- public:
- AdminHandler()
- { }
-
- A_DELETE_COPY(AdminHandler)
-
- virtual ~AdminHandler()
- { }
-
- void kickName(const std::string &name) const override final;
-
- void ban(const int playerId) const override final A_CONST;
-
- void banName(const std::string &name) const override final;
-
- void unban(const int playerId) const override final A_CONST;
-
- void unbanName(const std::string &name) const override final;
-
- void ipcheckName(const std::string &name) const override final;
-
- void createItems(const int id,
- const ItemColor color,
- const int amount) const override final;
-
- void spawn(const std::string &name) const override final;
-};
-
-} // namespace Ea
-
-#endif // NET_EA_ADMINHANDLER_H
diff --git a/src/net/ea/adminrecv.cpp b/src/net/ea/adminrecv.cpp
deleted file mode 100644
index a083ed78d..000000000
--- a/src/net/ea/adminrecv.cpp
+++ /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/>.
- */
-
-#include "net/ea/adminrecv.h"
-
-#include "notifymanager.h"
-
-#include "enums/resources/notifytypes.h"
-
-#include "net/messagein.h"
-
-#include "debug.h"
-
-namespace Ea
-{
-
-void AdminRecv::processKickAck(Net::MessageIn &msg)
-{
- if (msg.readInt32("flag") == 0)
- NotifyManager::notify(NotifyTypes::KICK_FAIL);
- else
- NotifyManager::notify(NotifyTypes::KICK_SUCCEED);
-}
-
-} // namespace Ea
diff --git a/src/net/ea/adminrecv.h b/src/net/ea/adminrecv.h
deleted file mode 100644
index 71451aa21..000000000
--- a/src/net/ea/adminrecv.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 NET_EA_ADMINRECV_H
-#define NET_EA_ADMINRECV_H
-
-#include "localconsts.h"
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-namespace Ea
-{
- namespace AdminRecv
- {
- void processKickAck(Net::MessageIn &msg);
- } // namespace AdminRecv
-} // namespace Ea
-
-#endif // NET_EA_ADMINRECV_H
diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp
deleted file mode 100644
index 4f62175c3..000000000
--- a/src/net/ea/beinghandler.cpp
+++ /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/>.
- */
-
-#include "net/ea/beinghandler.h"
-
-#include "net/ea/beingrecv.h"
-
-#include "debug.h"
-
-namespace Ea
-{
-
-BeingHandler::BeingHandler(const bool enableSync) :
- Net::BeingHandler()
-{
- BeingRecv::mSync = enableSync;
- BeingRecv::mSpawnId = BeingId_zero;
-}
-
-} // namespace Ea
diff --git a/src/net/ea/beinghandler.h b/src/net/ea/beinghandler.h
deleted file mode 100644
index 625077855..000000000
--- a/src/net/ea/beinghandler.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 NET_EA_BEINGHANDLER_H
-#define NET_EA_BEINGHANDLER_H
-
-#include "net/beinghandler.h"
-
-namespace Ea
-{
-
-class BeingHandler notfinal : public Net::BeingHandler
-{
- public:
- A_DELETE_COPY(BeingHandler)
-
- protected:
- explicit BeingHandler(const bool enableSync);
-};
-
-} // namespace Ea
-
-#endif // NET_EA_BEINGHANDLER_H
diff --git a/src/net/ea/beingrecv.cpp b/src/net/ea/beingrecv.cpp
deleted file mode 100644
index b2859d76f..000000000
--- a/src/net/ea/beingrecv.cpp
+++ /dev/null
@@ -1,520 +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 "net/ea/beingrecv.h"
-
-#include "actormanager.h"
-#include "configuration.h"
-#include "game.h"
-#include "notifymanager.h"
-#include "party.h"
-
-#include "being/localplayer.h"
-#include "being/playerrelation.h"
-#include "being/playerrelations.h"
-
-#include "enums/resources/notifytypes.h"
-
-#include "enums/resources/map/mapitemtype.h"
-
-#include "gui/viewport.h"
-
-#include "gui/windows/socialwindow.h"
-
-#include "utils/foreach.h"
-
-#include "resources/map/map.h"
-
-#include "net/messagein.h"
-#include "net/serverfeatures.h"
-
-#include "debug.h"
-
-namespace Ea
-{
-
-namespace BeingRecv
-{
- bool mSync = false;
- BeingId mSpawnId = BeingId_zero;
-} // namespace BeingRecv
-
-void BeingRecv::processBeingRemove(Net::MessageIn &msg)
-{
- BLOCK_START("BeingRecv::processBeingRemove")
- if ((actorManager == nullptr) || (localPlayer == nullptr))
- {
- BLOCK_END("BeingRecv::processBeingRemove")
- return;
- }
-
- // A being should be removed or has died
-
- const BeingId id = msg.readBeingId("being id");
- const uint8_t type = msg.readUInt8("remove flag");
- Being *const dstBeing = actorManager->findBeing(id);
- if (dstBeing == nullptr)
- {
- BLOCK_END("BeingRecv::processBeingRemove")
- return;
- }
-
- localPlayer->followMoveTo(dstBeing, localPlayer->getNextDestX(),
- localPlayer->getNextDestY());
-
- // If this is player's current target, clear it.
- if (dstBeing == localPlayer->getTarget())
- localPlayer->stopAttack(true);
-
- if (type == 1U)
- {
- if (dstBeing->getCurrentAction() != BeingAction::DEAD)
- {
- dstBeing->setAction(BeingAction::DEAD, 0);
- dstBeing->recalcSpritesOrder();
- }
- }
- else if (type == 0U && dstBeing->getType() == ActorType::Npc)
- {
- const BeingInfo *const info = dstBeing->getInfo();
- if ((info == nullptr) || (info->getAllowDelete() != 0))
- actorManager->destroy(dstBeing);
- }
- else
- {
- if (dstBeing->getType() == ActorType::Player)
- {
- if (socialWindow != nullptr)
- socialWindow->updateActiveList();
- const std::string name = dstBeing->getName();
- if (!name.empty() && config.getBoolValue("logPlayerActions"))
- {
- switch (type)
- {
- case 0:
- dstBeing->serverRemove();
- break;
- case 1:
- NotifyManager::notify(
- NotifyTypes::BEING_REMOVE_DIED,
- name);
- break;
- case 2:
- NotifyManager::notify(
- NotifyTypes::BEING_REMOVE_LOGGED_OUT,
- name);
- break;
- case 3:
- NotifyManager::notify(
- NotifyTypes::BEING_REMOVE_WARPED,
- name);
- break;
- case 4:
- NotifyManager::notify(
- NotifyTypes::BEING_REMOVE_TRICK_DEAD,
- name);
- break;
- default:
- NotifyManager::notify(
- NotifyTypes::BEING_REMOVE_UNKNOWN,
- name);
- break;
- }
- }
- }
- actorManager->destroy(dstBeing);
- }
- BLOCK_END("BeingRecv::processBeingRemove")
-}
-
-void BeingRecv::processBeingAction(Net::MessageIn &msg)
-{
- BLOCK_START("BeingRecv::processBeingAction")
- if (actorManager == nullptr)
- {
- BLOCK_END("BeingRecv::processBeingAction")
- return;
- }
-
- Being *const srcBeing = actorManager->findBeing(
- msg.readBeingId("src being id"));
- Being *const dstBeing = actorManager->findBeing(
- msg.readBeingId("dst being id"));
-
- msg.readInt32("tick");
- const int srcSpeed = msg.readInt32("src speed");
- msg.readInt32("dst speed");
- const int param1 = msg.readInt16("param1");
- msg.readInt16("param 2");
- const AttackTypeT type = static_cast<AttackTypeT>(
- msg.readUInt8("type"));
- msg.readInt16("param 3");
-
- switch (type)
- {
- case AttackType::HIT: // Damage
- case AttackType::CRITICAL: // Critical Damage
- case AttackType::MULTI: // Critical Damage
- case AttackType::REFLECT: // Reflected Damage
- case AttackType::FLEE: // Lucky Dodge
- if (srcBeing != nullptr)
- {
- if (srcSpeed != 0 && srcBeing->getType() == ActorType::Player)
- srcBeing->setAttackDelay(srcSpeed);
- // attackid=1, type
- srcBeing->handleAttack(dstBeing, param1, 1);
- if (srcBeing->getType() == ActorType::Player)
- srcBeing->setAttackTime();
- }
- if (dstBeing != nullptr)
- {
- // level not present, using 1
- dstBeing->takeDamage(srcBeing, param1,
- static_cast<AttackTypeT>(type), 1);
- }
- break;
-
- case AttackType::PICKUP:
- break;
- // tmw server can send here garbage?
-// if (srcBeing)
-// srcBeing->setAction(BeingAction::DEAD, 0);
-
- case AttackType::SIT:
- if (srcBeing != nullptr)
- {
- srcBeing->setAction(BeingAction::SIT, 0);
- if (srcBeing->getType() == ActorType::Player)
- {
- srcBeing->setMoveTime();
- if (localPlayer != nullptr)
- localPlayer->imitateAction(srcBeing, BeingAction::SIT);
- }
- }
- break;
-
- case AttackType::STAND:
- if (srcBeing != nullptr)
- {
- srcBeing->setAction(BeingAction::STAND, 0);
- if (srcBeing->getType() == ActorType::Player)
- {
- srcBeing->setMoveTime();
- if (localPlayer != nullptr)
- {
- localPlayer->imitateAction(srcBeing,
- BeingAction::STAND);
- }
- }
- }
- break;
- default:
- case AttackType::SPLASH:
- case AttackType::SKILL:
- case AttackType::REPEATE:
- case AttackType::MULTI_REFLECT:
- case AttackType::TOUCH_SKILL:
- case AttackType::MISS:
- case AttackType::SKILLMISS:
- UNIMPLEMENTEDPACKETFIELD(CAST_S32(type));
- break;
- }
- BLOCK_END("BeingRecv::processBeingAction")
-}
-
-void BeingRecv::processBeingEmotion(Net::MessageIn &msg)
-{
- BLOCK_START("BeingRecv::processBeingEmotion")
- if ((localPlayer == nullptr) || (actorManager == nullptr))
- {
- BLOCK_END("BeingRecv::processBeingEmotion")
- return;
- }
-
- Being *const dstBeing = actorManager->findBeing(
- msg.readBeingId("being id"));
- if (dstBeing == nullptr)
- {
- DEBUGLOGSTR("invisible player?");
- msg.readUInt8("emote");
- BLOCK_END("BeingRecv::processBeingEmotion")
- return;
- }
-
- const uint8_t emote = msg.readUInt8("emote");
- if ((emote != 0u) &&
- playerRelations.hasPermission(dstBeing, PlayerRelation::EMOTE))
- {
- dstBeing->setEmote(emote, 0);
- localPlayer->imitateEmote(dstBeing, emote);
- }
- if (dstBeing->getType() == ActorType::Player)
- dstBeing->setOtherTime();
- BLOCK_END("BeingRecv::processBeingEmotion")
-}
-
-void BeingRecv::processNameResponse(Net::MessageIn &msg)
-{
- BLOCK_START("BeingRecv::processNameResponse")
- if ((localPlayer == nullptr) || (actorManager == nullptr))
- {
- BLOCK_END("BeingRecv::processNameResponse")
- return;
- }
-
- const BeingId beingId = msg.readBeingId("being id");
- const std::string name = msg.readString(24, "name");
- Being *const dstBeing = actorManager->findBeing(beingId);
-
- actorManager->updateNameId(name, beingId);
-
- if (dstBeing != nullptr)
- {
- if (beingId == localPlayer->getId())
- {
- localPlayer->pingResponse();
- }
- else
- {
- if (dstBeing->getType() != ActorType::Portal)
- {
- dstBeing->setName(name);
- }
- else if (viewport != nullptr)
- {
- Map *const map = viewport->getMap();
- if (map != nullptr)
- {
- map->addPortalTile(name, MapItemType::PORTAL,
- dstBeing->getTileX(), dstBeing->getTileY());
- }
- }
- dstBeing->updateGuild();
- dstBeing->addToCache();
-
- if (dstBeing->getType() == ActorType::Player)
- dstBeing->updateColors();
-
- if (localPlayer != nullptr)
- {
- const Party *const party = localPlayer->getParty();
- if (party != nullptr && party->isMember(dstBeing->getId()))
- {
- PartyMember *const member = party->getMember(
- dstBeing->getId());
-
- if (member != nullptr)
- member->setName(dstBeing->getName());
- }
- localPlayer->checkNewName(dstBeing);
- }
- BLOCK_END("BeingRecv::processNameResponse")
- return;
- }
- }
- BLOCK_END("BeingRecv::processNameResponse")
-}
-
-void BeingRecv::processPlayerStop(Net::MessageIn &msg)
-{
- BLOCK_START("BeingRecv::processPlayerStop")
- if ((actorManager == nullptr) || (localPlayer == nullptr))
- {
- BLOCK_END("BeingRecv::processPlayerStop")
- return;
- }
-
- const BeingId id = msg.readBeingId("account id");
-
- if (mSync || id != localPlayer->getId())
- {
- Being *const dstBeing = actorManager->findBeing(id);
- if (dstBeing != nullptr)
- {
- const uint16_t x = msg.readInt16("x");
- const uint16_t y = msg.readInt16("y");
- dstBeing->setTileCoords(x, y);
- if (dstBeing->getCurrentAction() == BeingAction::MOVE)
- dstBeing->setAction(BeingAction::STAND, 0);
- BLOCK_END("BeingRecv::processPlayerStop")
- return;
- }
- }
- msg.readInt16("x");
- msg.readInt16("y");
- BLOCK_END("BeingRecv::processPlayerStop")
-}
-
-void BeingRecv::processPlayerMoveToAttack(Net::MessageIn &msg)
-{
- BLOCK_START("BeingRecv::processPlayerStop")
- msg.readInt32("target id");
- msg.readInt16("target x");
- msg.readInt16("target y");
- msg.readInt16("x");
- msg.readInt16("y");
- msg.readInt16("attack range");
-
- if (localPlayer != nullptr)
- localPlayer->fixAttackTarget();
- BLOCK_END("BeingRecv::processPlayerStop")
-}
-
-void BeingRecv::processSkillNoDamage(Net::MessageIn &msg)
-{
- const int id = msg.readInt16("skill id");
- int heal;
- if (msg.getVersion() >= 20131223)
- heal = msg.readInt32("heal");
- else
- heal = msg.readInt16("heal");
- Being *const dstBeing = actorManager->findBeing(
- msg.readBeingId("dst being id"));
- Being *const srcBeing = actorManager->findBeing(
- msg.readBeingId("src being id"));
- msg.readUInt8("fail");
-
- if (srcBeing != nullptr)
- srcBeing->handleSkill(dstBeing, heal, id, 1);
-}
-
-void BeingRecv::processPvpMapMode(Net::MessageIn &msg)
-{
- BLOCK_START("BeingRecv::processPvpMapMode")
- const Game *const game = Game::instance();
- if (game == nullptr)
- {
- BLOCK_END("BeingRecv::processPvpMapMode")
- return;
- }
-
- Map *const map = game->getCurrentMap();
- if (map != nullptr)
- map->setPvpMode(msg.readInt16("pvp mode"));
- BLOCK_END("BeingRecv::processPvpMapMode")
-}
-
-void BeingRecv::processBeingMove3(Net::MessageIn &msg)
-{
- BLOCK_START("BeingRecv::processBeingMove3")
- if ((actorManager == nullptr) || !serverFeatures->haveMove3())
- {
- BLOCK_END("BeingRecv::processBeingMove3")
- return;
- }
-
- static const int16_t dirx[8] = {0, -1, -1, -1, 0, 1, 1, 1};
- static const int16_t diry[8] = {1, 1, 0, -1, -1, -1, 0, 1};
-
- const int len = msg.readInt16("len") - 14;
- Being *const dstBeing = actorManager->findBeing(
- msg.readBeingId("being id"));
- if (dstBeing == nullptr ||
- dstBeing == localPlayer)
- {
- DEBUGLOGSTR("invisible player?");
- msg.readInt16("speed");
- msg.readInt16("x");
- msg.readInt16("y");
- unsigned char *bytes = msg.readBytes(len, "moving path");
- delete [] bytes;
- BLOCK_END("BeingRecv::processBeingMove3")
- return;
- }
- const int16_t speed = msg.readInt16("speed");
- dstBeing->setWalkSpeed(speed);
- const int16_t x = msg.readInt16("x");
- const int16_t y = msg.readInt16("y");
- const unsigned char *moves = msg.readBytes(len, "moving path");
-
- Path path;
- if (moves != nullptr)
- {
- int x2 = dstBeing->getCachedX();
- int y2 = dstBeing->getCachedY();
- Path path2;
- path2.push_back(Position(x2, y2));
- for (int f = len - 1; f >= 0; f --)
- {
- const unsigned char dir = moves[f];
- if (dir <= 7)
- {
- x2 -= dirx[dir];
- y2 -= diry[dir];
- path2.push_back(Position(x2, y2));
- if (x2 == x && y2 == y)
- break;
- }
- else
- {
- logger->log("bad move packet: %d", dir);
- }
- }
-
- if (!path2.empty())
- {
- const Position &pos = path2.back();
- if (x != pos.x ||
- y != pos.y)
- {
- dstBeing->setTileCoords(pos.x, pos.y);
- }
- }
-
- path2.pop_back();
- FOR_EACHR (PathRIterator, it, path2)
- {
- path.push_back(*it);
- }
- delete [] moves;
- }
-
- if (path.empty())
- return;
-
- dstBeing->setAction(BeingAction::STAND, 0);
- dstBeing->setTileCoords(x, y);
- dstBeing->setPath(path);
- BLOCK_END("BeingRecv::processBeingMove3")
-}
-
-Being *BeingRecv::createBeing(const BeingId id,
- const int job)
-{
- if (actorManager == nullptr)
- return nullptr;
-
- ActorTypeT type = ActorType::Unknown;
- if (job <= 25 || (job >= 4001 && job <= 4049))
- type = ActorType::Player;
- else if (job >= 46 && job <= 1000)
- type = ActorType::Npc;
- else if (job > 1000 && job <= 2000)
- type = ActorType::Monster;
- else if (job == 45)
- type = ActorType::Portal;
-
- return actorManager->createBeing(
- id, type, fromInt(job, BeingTypeId));
-}
-
-} // namespace Ea
diff --git a/src/net/ea/beingrecv.h b/src/net/ea/beingrecv.h
deleted file mode 100644
index 878d53fb6..000000000
--- a/src/net/ea/beingrecv.h
+++ /dev/null
@@ -1,56 +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 NET_EA_BEINGRECV_H
-#define NET_EA_BEINGRECV_H
-
-#include "enums/simpletypes/beingid.h"
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-class Being;
-
-namespace Ea
-{
- namespace BeingRecv
- {
- extern bool mSync;
- extern BeingId mSpawnId;
-
- void processBeingRemove(Net::MessageIn &msg);
- void processBeingAction(Net::MessageIn &msg);
- void processBeingEmotion(Net::MessageIn &msg);
- void processNameResponse(Net::MessageIn &msg);
- void processPlayerStop(Net::MessageIn &msg);
- void processPlayerMoveToAttack(Net::MessageIn &msg);
- void processSkillNoDamage(Net::MessageIn &msg);
- void processPvpMapMode(Net::MessageIn &msg);
- void processBeingMove3(Net::MessageIn &msg);
- Being *createBeing(const BeingId id,
- const int job);
- } // namespace BeingRecv
-} // namespace Ea
-
-#endif // NET_EA_BEINGRECV_H
diff --git a/src/net/ea/buysellhandler.cpp b/src/net/ea/buysellhandler.cpp
deleted file mode 100644
index 21769cef4..000000000
--- a/src/net/ea/buysellhandler.cpp
+++ /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/>.
- */
-
-#include "net/ea/buysellhandler.h"
-
-#include "net/ea/buysellrecv.h"
-
-#include "debug.h"
-
-namespace Ea
-{
-
-BuySellHandler::BuySellHandler()
-{
- BuySellRecv::mNpcId = BeingId_zero;
- BuySellRecv::mBuyDialog = nullptr;
-}
-
-void BuySellHandler::cleanDialogReference(const BuyDialog *const dialog) const
-{
- if (BuySellRecv::mBuyDialog == dialog)
- BuySellRecv::mBuyDialog = nullptr;
-}
-
-} // namespace Ea
diff --git a/src/net/ea/buysellhandler.h b/src/net/ea/buysellhandler.h
deleted file mode 100644
index 2c5e1caad..000000000
--- a/src/net/ea/buysellhandler.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 NET_EA_BUYSELLHANDLER_H
-#define NET_EA_BUYSELLHANDLER_H
-
-#include "net/buysellhandler.h"
-
-namespace Ea
-{
-
-class BuySellHandler notfinal : public Net::BuySellHandler
-{
- public:
- BuySellHandler();
-
- A_DELETE_COPY(BuySellHandler)
-
- void cleanDialogReference(const BuyDialog *const dialog) const
- override final;
-};
-
-} // namespace Ea
-
-#endif // NET_EA_BUYSELLHANDLER_H
diff --git a/src/net/ea/buysellrecv.cpp b/src/net/ea/buysellrecv.cpp
deleted file mode 100644
index 95f69129f..000000000
--- a/src/net/ea/buysellrecv.cpp
+++ /dev/null
@@ -1,92 +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 "net/ea/buysellrecv.h"
-
-#include "notifymanager.h"
-
-#include "being/playerinfo.h"
-
-#include "const/net/inventory.h"
-
-#include "enums/resources/notifytypes.h"
-
-#include "gui/windows/buyselldialog.h"
-#include "gui/windows/npcselldialog.h"
-
-#include "gui/widgets/createwidget.h"
-
-#include "net/messagein.h"
-
-#include "resources/inventory/inventory.h"
-
-#include "resources/item/item.h"
-
-#include "debug.h"
-
-namespace Ea
-{
-
-namespace BuySellRecv
-{
- BeingId mNpcId = BeingId_zero;
- BuyDialog *mBuyDialog = nullptr;
-} // namespace BuySellRecv
-
-void BuySellRecv::processNpcBuySellChoice(Net::MessageIn &msg)
-{
- if (!BuySellDialog::isActive())
- {
- mNpcId = msg.readBeingId("npc id");
- CREATEWIDGET(BuySellDialog, mNpcId);
- }
-}
-
-void BuySellRecv::processNpcSell(Net::MessageIn &msg)
-{
- msg.readInt16("len");
- const int n_items = (msg.getLength() - 4) / 10;
- if (n_items > 0)
- {
- SellDialog *const dialog = CREATEWIDGETR(NpcSellDialog, mNpcId);
- dialog->setMoney(PlayerInfo::getAttribute(Attributes::MONEY));
-
- for (int k = 0; k < n_items; k++)
- {
- const int index = msg.readInt16("index") - INVENTORY_OFFSET;
- const int value = msg.readInt32("value");
- msg.readInt32("value?");
-
- const Item *const item = PlayerInfo::getInventory()
- ->getItem(index);
-
- if ((item != nullptr) && item->isEquipped() == Equipped_false)
- dialog->addItem(item, value);
- }
- }
- else
- {
- NotifyManager::notify(NotifyTypes::SELL_LIST_EMPTY);
- }
-}
-
-} // namespace Ea
diff --git a/src/net/ea/buysellrecv.h b/src/net/ea/buysellrecv.h
deleted file mode 100644
index 7d70044fe..000000000
--- a/src/net/ea/buysellrecv.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 NET_EA_BUYSELLRECV_H
-#define NET_EA_BUYSELLRECV_H
-
-#include "enums/simpletypes/beingid.h"
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-class BuyDialog;
-
-namespace Ea
-{
- namespace BuySellRecv
- {
- extern BeingId mNpcId;
- extern BuyDialog *mBuyDialog;
-
- void processNpcBuySellChoice(Net::MessageIn &msg);
- void processNpcSell(Net::MessageIn &msg);
- } // namespace BuySellRecv
-} // namespace Ea
-
-#endif // NET_EA_BUYSELLRECV_H
diff --git a/src/net/ea/charserverhandler.cpp b/src/net/ea/charserverhandler.cpp
deleted file mode 100644
index ae8da9e4a..000000000
--- a/src/net/ea/charserverhandler.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 "net/ea/charserverhandler.h"
-
-#include "net/character.h"
-#include "net/serverinfo.h"
-
-#include "net/ea/eaprotocol.h"
-
-#include "utils/dtor.h"
-
-#include "debug.h"
-
-namespace Ea
-{
-
-extern ServerInfo mapServer;
-
-CharServerHandler::CharServerHandler() :
- Net::CharServerHandler()
-{
-}
-
-CharServerHandler::~CharServerHandler()
-{
- clear();
-}
-
-void CharServerHandler::setCharSelectDialog(CharSelectDialog *const window)
- const
-{
- mCharSelectDialog = window;
- updateCharSelectDialog();
-}
-
-void CharServerHandler::requestCharacters() const
-{
- connect();
-}
-
-unsigned int CharServerHandler::baseSprite() const
-{
- return EA_SPRITE_BASE;
-}
-
-unsigned int CharServerHandler::hairSprite() const
-{
- return EA_SPRITE_HAIR_COLOR;
-}
-
-unsigned int CharServerHandler::maxSprite() const
-{
- return EA_SPRITE_VECTOREND;
-}
-
-void CharServerHandler::clear() const
-{
- delete_all(mCharacters);
- mCharacters.clear();
-}
-
-} // namespace Ea
diff --git a/src/net/ea/charserverhandler.h b/src/net/ea/charserverhandler.h
deleted file mode 100644
index 1faa59403..000000000
--- a/src/net/ea/charserverhandler.h
+++ /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/>.
- */
-
-#ifndef NET_EA_CHARSERVERHANDLER_H
-#define NET_EA_CHARSERVERHANDLER_H
-
-#include "net/charserverhandler.h"
-
-namespace Ea
-{
-
-/**
- * Deals with incoming messages from the character server.
- */
-class CharServerHandler notfinal : public Net::CharServerHandler
-{
- public:
- A_DELETE_COPY(CharServerHandler)
-
- ~CharServerHandler();
-
- void setCharSelectDialog(CharSelectDialog *const window) const
- override final;
-
- void requestCharacters() const override final;
-
- unsigned int baseSprite() const override final A_CONST A_WARN_UNUSED;
-
- unsigned int hairSprite() const override final A_CONST A_WARN_UNUSED;
-
- unsigned int maxSprite() const override final A_CONST A_WARN_UNUSED;
-
- virtual void connect() const = 0;
-
- void clear() const override final;
-
- protected:
- CharServerHandler();
-};
-
-} // namespace Ea
-
-#endif // NET_EA_CHARSERVERHANDLER_H
diff --git a/src/net/ea/charserverrecv.cpp b/src/net/ea/charserverrecv.cpp
deleted file mode 100644
index d058dfe6d..000000000
--- a/src/net/ea/charserverrecv.cpp
+++ /dev/null
@@ -1,143 +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 "net/ea/charserverrecv.h"
-
-#include "client.h"
-
-#include "gui/windows/charcreatedialog.h"
-#include "gui/windows/okdialog.h"
-
-#include "gui/widgets/createwidget.h"
-
-#include "net/character.h"
-#include "net/charserverhandler.h"
-#include "net/messagein.h"
-
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-namespace Ea
-{
-
-void CharServerRecv::processCharLoginError(Net::MessageIn &msg)
-{
- BLOCK_START("CharServerRecv::processCharLoginError")
- switch (msg.readUInt8("error"))
- {
- case 0:
- // TRANSLATORS: error message
- errorMessage = _("Access denied. Most likely, there are "
- "too many players on this server.");
- break;
- case 1:
- // TRANSLATORS: error message
- errorMessage = _("Cannot use this ID.");
- break;
- default:
- // TRANSLATORS: error message
- errorMessage = _("Unknown char-server failure.");
- break;
- }
- client->setState(State::ERROR);
- BLOCK_END("CharServerRecv::processCharLoginError")
-}
-
-void CharServerRecv::processCharCreateFailed(Net::MessageIn &msg)
-{
- BLOCK_START("CharServerRecv::processCharCreateFailed")
- switch (msg.readUInt8("error"))
- {
- case 1:
- case 0:
- default:
- // TRANSLATORS: error message
- errorMessage = _("Failed to create character. Most "
- "likely the name is already taken.");
- break;
- case 2:
- // TRANSLATORS: error message
- errorMessage = _("Wrong name.");
- break;
- case 3:
- // TRANSLATORS: error message
- errorMessage = _("Incorrect stats.");
- break;
- case 4:
- // TRANSLATORS: error message
- errorMessage = _("Incorrect hair.");
- break;
- case 5:
- // TRANSLATORS: error message
- errorMessage = _("Incorrect slot.");
- break;
- case 6:
- // TRANSLATORS: error message
- errorMessage = _("Incorrect race.");
- break;
- case 7:
- // TRANSLATORS: error message
- errorMessage = _("Incorrect look.");
- break;
- }
- CREATEWIDGET(OkDialog,
- // TRANSLATORS: error message header
- _("Error"),
- errorMessage,
- // TRANSLATORS: ok dialog button
- _("OK"),
- DialogType::ERROR,
- Modal_true,
- ShowCenter_true,
- nullptr,
- 260);
- if (Net::CharServerHandler::mCharCreateDialog != nullptr)
- Net::CharServerHandler::mCharCreateDialog->unlock();
- BLOCK_END("CharServerRecv::processCharCreateFailed")
-}
-
-void CharServerRecv::processCharDelete(Net::MessageIn &msg A_UNUSED)
-{
- BLOCK_START("CharServerRecv::processCharDelete")
- delete Net::CharServerHandler::mSelectedCharacter;
- Net::CharServerHandler::mCharacters.remove(
- Net::CharServerHandler::mSelectedCharacter);
- Net::CharServerHandler::mSelectedCharacter = nullptr;
- Net::CharServerHandler::updateCharSelectDialog();
- Net::CharServerHandler::unlockCharSelectDialog();
- CREATEWIDGET(OkDialog,
- // TRANSLATORS: info message header
- _("Info"),
- // TRANSLATORS: info message
- _("Character deleted."),
- // TRANSLATORS: ok dialog button
- _("OK"),
- DialogType::OK,
- Modal_true,
- ShowCenter_true,
- nullptr,
- 260);
- BLOCK_END("CharServerRecv::processCharDelete")
-}
-
-} // namespace Ea
diff --git a/src/net/ea/charserverrecv.h b/src/net/ea/charserverrecv.h
deleted file mode 100644
index 5e105210c..000000000
--- a/src/net/ea/charserverrecv.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 NET_EA_CHARSERVERRECV_H
-#define NET_EA_CHARSERVERRECV_H
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-namespace Ea
-{
- namespace CharServerRecv
- {
- void processCharLoginError(Net::MessageIn &msg);
- void processCharCreateFailed(Net::MessageIn &msg);
- void processCharDelete(Net::MessageIn &msg);
- } // namespace CharServerRecv
-} // namespace Ea
-
-#endif // NET_EA_CHARSERVERRECV_H
diff --git a/src/net/ea/chathandler.cpp b/src/net/ea/chathandler.cpp
deleted file mode 100644
index 8937852c6..000000000
--- a/src/net/ea/chathandler.cpp
+++ /dev/null
@@ -1,63 +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 "net/ea/chathandler.h"
-
-#include "configuration.h"
-
-#include "net/ea/chatrecv.h"
-
-#include "debug.h"
-
-namespace Ea
-{
-
-ChatHandler::ChatHandler()
-{
- if (!ChatRecv::mSentWhispers.empty())
- ChatRecv::mSentWhispers.pop();
- ChatRecv::mMotdTime = 0;
- ChatRecv::mShowAllLang = (serverConfig.getValue("showAllLang", 0) != 0);
- ChatRecv::mShowMotd = config.getBoolValue("showmotd");
- ChatRecv::mSkipping = true;
-}
-
-ChatHandler::~ChatHandler()
-{
- clear();
-}
-
-void ChatHandler::clear() const
-{
- ChatRecv::mShowMotd = config.getBoolValue("showmotd");
- ChatRecv::mSkipping = true;
-}
-
-void ChatHandler::me(const std::string &restrict text,
- const std::string &restrict channel) const
-{
- // here need string duplication
- std::string action = strprintf("*%s*", text.c_str());
- talk(action, channel);
-}
-
-} // namespace Ea
diff --git a/src/net/ea/chathandler.h b/src/net/ea/chathandler.h
deleted file mode 100644
index b19105193..000000000
--- a/src/net/ea/chathandler.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 NET_EA_CHATHANDLER_H
-#define NET_EA_CHATHANDLER_H
-
-#include "net/chathandler.h"
-
-#include <queue>
-
-namespace Ea
-{
-
-typedef std::queue<std::string> WhisperQueue;
-
-class ChatHandler notfinal : public Net::ChatHandler
-{
- public:
- ChatHandler();
-
- A_DELETE_COPY(ChatHandler)
-
- ~ChatHandler();
-
- void me(const std::string &restrict text,
- const std::string &restrict channel) const override final;
-
- void clear() const override final;
-};
-
-} // namespace Ea
-
-#endif // NET_EA_CHATHANDLER_H
diff --git a/src/net/ea/chatrecv.cpp b/src/net/ea/chatrecv.cpp
deleted file mode 100644
index 87db3fa98..000000000
--- a/src/net/ea/chatrecv.cpp
+++ /dev/null
@@ -1,192 +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 "net/ea/chatrecv.h"
-
-#include "actormanager.h"
-#include "configuration.h"
-#include "notifymanager.h"
-
-#include "being/being.h"
-
-#include "enums/resources/notifytypes.h"
-
-#include "gui/windows/chatwindow.h"
-
-#include "gui/widgets/tabs/chat/chattab.h"
-
-#include "net/messagein.h"
-
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-namespace Ea
-{
-
-namespace ChatRecv
-{
- WhisperQueue mSentWhispers;
- time_t mMotdTime = 0;
- bool mShowAllLang = false;
- bool mShowMotd = false;
- bool mSkipping = true;
-} // namespace ChatRecv
-
-std::string ChatRecv::getPopLastWhisperNick()
-{
- std::string nick;
- if (mSentWhispers.empty())
- {
- nick = "user";
- }
- else
- {
- nick = mSentWhispers.front();
- mSentWhispers.pop();
- }
- return nick;
-}
-
-std::string ChatRecv::getLastWhisperNick()
-{
- std::string nick;
- if (mSentWhispers.empty())
- nick = "user";
- else
- nick = mSentWhispers.front();
- return nick;
-}
-
-void ChatRecv::processWhisperResponseContinue(Net::MessageIn &msg,
- const uint8_t type)
-{
- const std::string nick = getPopLastWhisperNick();
- switch (type)
- {
- case 0x00:
- // Success (don't need to report)
- break;
- case 0x01:
- if (chatWindow != nullptr)
- {
- chatWindow->addWhisper(nick,
- // TRANSLATORS: chat message
- strprintf(_("Whisper could not be sent, %s is offline."),
- nick.c_str()),
- ChatMsgType::BY_SERVER);
- }
- break;
- case 0x02:
- if (chatWindow != nullptr)
- {
- chatWindow->addWhisper(nick,
- // TRANSLATORS: chat message
- strprintf(_("Whisper could not "
- "be sent, ignored by %s."), nick.c_str()),
- ChatMsgType::BY_SERVER);
- }
- break;
- case 0x03:
- if (chatWindow != nullptr)
- {
- chatWindow->addWhisper(nick,
- // TRANSLATORS: chat message
- _("Whisper could not "
- "be sent, you ignored by all players."),
- ChatMsgType::BY_SERVER);
- }
- break;
- default:
- UNIMPLEMENTEDPACKETFIELD(type);
- break;
- }
- BLOCK_END("ChatRecv::processWhisperResponse")
-}
-
-void ChatRecv::processMVPEffect(Net::MessageIn &msg)
-{
- BLOCK_START("ChatRecv::processMVPEffect")
- // Display MVP player
- const BeingId id = msg.readBeingId("being id");
- if (localChatTab != nullptr &&
- actorManager != nullptr &&
- config.getBoolValue("showMVP"))
- {
- const Being *const being = actorManager->findBeing(id);
- if (being == nullptr)
- NotifyManager::notify(NotifyTypes::MVP_PLAYER, "");
- else
- NotifyManager::notify(NotifyTypes::MVP_PLAYER, being->getName());
- }
- BLOCK_END("ChatRecv::processMVPEffect")
-}
-
-void ChatRecv::processIgnoreAllResponse(Net::MessageIn &msg)
-{
- BLOCK_START("ChatRecv::processIgnoreAllResponse")
- const uint8_t action = msg.readUInt8("action");
- const uint8_t fail = msg.readUInt8("result");
- if (localChatTab == nullptr)
- {
- BLOCK_END("ChatRecv::processIgnoreAllResponse")
- return;
- }
-
- switch (action)
- {
- case 0:
- {
- switch (fail)
- {
- case 0:
- NotifyManager::notify(NotifyTypes::WHISPERS_IGNORED);
- break;
- default:
- NotifyManager::notify(NotifyTypes::
- WHISPERS_IGNORE_FAILED);
- break;
- }
- break;
- }
- case 1:
- {
- switch (fail)
- {
- case 0:
- NotifyManager::notify(NotifyTypes::WHISPERS_UNIGNORED);
- break;
- default:
- NotifyManager::notify(NotifyTypes::
- WHISPERS_UNIGNORE_FAILED);
- break;
- }
- break;
- }
- default:
- // unknown result
- break;
- }
- BLOCK_END("ChatRecv::processIgnoreAllResponse")
-}
-
-} // namespace Ea
diff --git a/src/net/ea/chatrecv.h b/src/net/ea/chatrecv.h
deleted file mode 100644
index 4a8427ea7..000000000
--- a/src/net/ea/chatrecv.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 NET_EA_CHATRECV_H
-#define NET_EA_CHATRECV_H
-
-#if defined(__GXX_EXPERIMENTAL_CXX0X__)
-#if defined(__APPLE__)
-#include <tr1/cstdint>
-#endif // defined(__APPLE__)
-#else // defined(__GXX_EXPERIMENTAL_CXX0X__)
-#include <stdint.h>
-#endif // defined(__GXX_EXPERIMENTAL_CXX0X__)
-
-#include <string>
-#include <queue>
-#ifndef __time_t_defined
-#include <sys/time.h>
-#endif // __time_t_defined
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-namespace Ea
-{
- typedef std::queue<std::string> WhisperQueue;
-
- namespace ChatRecv
- {
- void processMVPEffect(Net::MessageIn &msg);
- void processIgnoreAllResponse(Net::MessageIn &msg);
- void processWhisperResponseContinue(Net::MessageIn &msg,
- const uint8_t type);
- std::string getPopLastWhisperNick();
- std::string getLastWhisperNick();
-
- extern WhisperQueue mSentWhispers;
- extern time_t mMotdTime;
- extern bool mShowAllLang;
- extern bool mShowMotd;
- extern bool mSkipping;
- } // namespace ChatRecv
-} // namespace Ea
-
-#endif // NET_EA_CHATRECV_H
diff --git a/src/net/ea/eaprotocol.h b/src/net/ea/eaprotocol.h
deleted file mode 100644
index 2a8831a24..000000000
--- a/src/net/ea/eaprotocol.h
+++ /dev/null
@@ -1,57 +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 NET_EA_EAPROTOCOL_H
-#define NET_EA_EAPROTOCOL_H
-
-enum
-{
- EA_SPRITE_BASE = 0,
- EA_SPRITE_HAIR = 1,
- EA_SPRITE_WEAPON = 2,
- EA_SPRITE_HEAD_BOTTOM = 3,
- EA_SPRITE_HEAD_TOP = 4,
- EA_SPRITE_HEAD_MID = 5,
- EA_SPRITE_HAIR_COLOR = 6,
- EA_SPRITE_CLOTHES_COLOR = 7,
- EA_SPRITE_SHIELD = 8,
- EA_SPRITE_SHOES = 9,
- EA_SPRITE_BODY = 10,
- EA_SPRITE_FLOOR = 11,
- EA_SPRITE_ROBE = 12,
- EA_SPRITE_EVOL2 = 13,
- EA_SPRITE_EVOL3 = 14,
- EA_SPRITE_EVOL4 = 15,
- EA_SPRITE_EVOL5 = 16,
- EA_SPRITE_EVOL6 = 17,
- EA_SPRITE_EVOL7 = 18,
- EA_SPRITE_EVOL8 = 19,
- EA_SPRITE_EVOL9 = 20,
- EA_SPRITE_EVOL10 = 21,
- EA_SPRITE_EVOL11 = 22,
- EA_SPRITE_EVOL12 = 23,
- EA_SPRITE_EVOL13 = 24,
- EA_SPRITE_EVOL14 = 25,
- EA_SPRITE_VECTOREND
-};
-
-#endif // NET_EA_EAPROTOCOL_H
diff --git a/src/net/ea/equipbackend.h b/src/net/ea/equipbackend.h
deleted file mode 100644
index 15aeb93fb..000000000
--- a/src/net/ea/equipbackend.h
+++ /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/>.
- */
-
-#ifndef NET_EA_EQUIPBACKEND_H
-#define NET_EA_EQUIPBACKEND_H
-
-#include "resources/item/item.h"
-
-#include "being/playerinfo.h"
-
-#include "const/equipment.h"
-
-#include "gui/windows/inventorywindow.h"
-
-namespace Ea
-{
-
-class EquipBackend final : public Equipment::Backend
-{
- public:
- EquipBackend()
- {
- memset(mEquipment, -1, sizeof(mEquipment));
- }
-
- A_DELETE_COPY(EquipBackend)
-
- Item *getEquipment(const int index) const override final A_WARN_UNUSED
- {
- int invyIndex = mEquipment[index];
- if (invyIndex == -1)
- return nullptr;
-
- const Inventory *const inv = PlayerInfo::getInventory();
- if (inv != nullptr)
- return inv->getItem(invyIndex);
- return nullptr;
- }
-
- void clear() override final
- {
- Inventory *const inv = PlayerInfo::getInventory();
- if (inv == nullptr)
- return;
- for (int i = 0; i < EQUIPMENT_SIZE; i++)
- {
- if (mEquipment[i] != -1)
- {
- Item* item = inv->getItem(i);
- if (item != nullptr)
- item->setEquipped(Equipped_false);
- }
-
- mEquipment[i] = -1;
- }
- }
-
- void setEquipment(const int index, const int inventoryIndex)
- {
- Inventory *const inv = PlayerInfo::getInventory();
- if (inv == nullptr)
- return;
-
- if (index < 0 || index >= EQUIPMENT_SIZE)
- return;
-
- // Unequip existing item
- Item *item = inv->getItem(mEquipment[index]);
-
- if (item != nullptr)
- item->setEquipped(Equipped_false);
-
- // not checking index because it must be safe
- mEquipment[index] = inventoryIndex;
-
- item = inv->getItem(inventoryIndex);
- if (item != nullptr)
- item->setEquipped(Equipped_true);
-
- if (inventoryWindow != nullptr)
- inventoryWindow->updateButtons();
- }
-
- private:
- int mEquipment[EQUIPMENT_SIZE];
-};
-
-} // namespace Ea
-
-#endif // NET_EA_EQUIPBACKEND_H
diff --git a/src/net/ea/gamehandler.cpp b/src/net/ea/gamehandler.cpp
deleted file mode 100644
index 3fe6a4e51..000000000
--- a/src/net/ea/gamehandler.cpp
+++ /dev/null
@@ -1,62 +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 "net/ea/gamehandler.h"
-
-#include "game.h"
-
-#include "net/ea/gamerecv.h"
-
-#include "debug.h"
-
-namespace Ea
-{
-
-GameHandler::GameHandler() :
- Net::GameHandler()
-{
- GameRecv::mMap.clear();
- GameRecv::mCharID = BeingId_zero;
-}
-
-void GameHandler::who() const
-{
-}
-
-void GameHandler::setMap(const std::string &map)
-{
- GameRecv::mMap = map.substr(0, map.rfind('.'));
-}
-
-void GameHandler::clear() const
-{
- GameRecv::mMap.clear();
- GameRecv::mCharID = BeingId_zero;
-}
-
-void GameHandler::initEngines() const
-{
- if (!GameRecv::mMap.empty())
- Game::instance()->changeMap(GameRecv::mMap);
-}
-
-} // namespace Ea
diff --git a/src/net/ea/gamehandler.h b/src/net/ea/gamehandler.h
deleted file mode 100644
index b64d5cf25..000000000
--- a/src/net/ea/gamehandler.h
+++ /dev/null
@@ -1,52 +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 NET_EA_GAMEHANDLER_H
-#define NET_EA_GAMEHANDLER_H
-
-#include "net/gamehandler.h"
-
-namespace Ea
-{
-
-class GameHandler notfinal : public Net::GameHandler
-{
- public:
- GameHandler();
-
- A_DELETE_COPY(GameHandler)
-
- void who() const override final A_CONST;
-
- bool removeDeadBeings() const override final A_WARN_UNUSED
- { return true; }
-
- static void setMap(const std::string &map);
-
- void clear() const override final;
-
- void initEngines() const override final;
-};
-
-} // namespace Ea
-
-#endif // NET_EA_GAMEHANDLER_H
diff --git a/src/net/ea/gamerecv.cpp b/src/net/ea/gamerecv.cpp
deleted file mode 100644
index 230e3e012..000000000
--- a/src/net/ea/gamerecv.cpp
+++ /dev/null
@@ -1,80 +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 "net/ea/gamerecv.h"
-
-#include "client.h"
-#include "notifymanager.h"
-
-#include "enums/resources/notifytypes.h"
-
-#include "gui/windows/okdialog.h"
-
-#include "gui/widgets/createwidget.h"
-
-#include "net/messagein.h"
-
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-namespace Ea
-{
-
-namespace GameRecv
-{
- std::string mMap;
- BeingId mCharID = BeingId_zero;
-} // namespace GameRecv
-
-void GameRecv::processWhoAnswer(Net::MessageIn &msg)
-{
- NotifyManager::notify(NotifyTypes::ONLINE_USERS,
- msg.readInt32("users count"));
-}
-
-void GameRecv::processCharSwitchResponse(Net::MessageIn &msg)
-{
- if (msg.readUInt8("response") != 0u)
- client->setState(State::SWITCH_CHARACTER);
-}
-
-void GameRecv::processMapQuitResponse(Net::MessageIn &msg)
-{
- if (msg.readInt16("response") != 0)
- {
- CREATEWIDGET(OkDialog,
- // TRANSLATORS: error header
- _("Game"),
- // TRANSLATORS: error message
- _("Request to quit denied!"),
- // TRANSLATORS: ok dialog button
- _("OK"),
- DialogType::ERROR,
- Modal_true,
- ShowCenter_true,
- nullptr,
- 260);
- }
-}
-
-} // namespace Ea
diff --git a/src/net/ea/gamerecv.h b/src/net/ea/gamerecv.h
deleted file mode 100644
index f0c5d8f41..000000000
--- a/src/net/ea/gamerecv.h
+++ /dev/null
@@ -1,48 +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 NET_EA_GAMERECV_H
-#define NET_EA_GAMERECV_H
-
-#include "enums/simpletypes/beingid.h"
-
-#include <string>
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-namespace Ea
-{
- namespace GameRecv
- {
- extern std::string mMap;
- extern BeingId mCharID; // < Saved for map-server switching
-
- void processWhoAnswer(Net::MessageIn &msg);
- void processCharSwitchResponse(Net::MessageIn &msg);
- void processMapQuitResponse(Net::MessageIn &msg);
- } // namespace GameRecv
-} // namespace Ea
-
-#endif // NET_EA_GAMERECV_H
diff --git a/src/net/ea/inventoryhandler.cpp b/src/net/ea/inventoryhandler.cpp
deleted file mode 100644
index 1f816f7c1..000000000
--- a/src/net/ea/inventoryhandler.cpp
+++ /dev/null
@@ -1,128 +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 "net/ea/inventoryhandler.h"
-
-#include "net/ea/equipbackend.h"
-#include "net/ea/inventoryrecv.h"
-
-#include "utils/delete2.h"
-
-#include "debug.h"
-
-namespace Ea
-{
-
-InventoryHandler::InventoryHandler() :
- Net::InventoryHandler()
-{
- InventoryRecv::mEquips.clear();
- InventoryRecv::mInventoryItems.clear();
- InventoryRecv::mStorage = nullptr;
- storageWindow = nullptr;
- while (!InventoryRecv::mSentPickups.empty())
- InventoryRecv::mSentPickups.pop();
- InventoryRecv::mDebugInventory = true;
-}
-
-InventoryHandler::~InventoryHandler()
-{
- if (storageWindow != nullptr)
- {
- storageWindow->close();
- storageWindow = nullptr;
- }
-
- delete2(InventoryRecv::mStorage);
-}
-
-void InventoryHandler::clear() const
-{
- delete2(InventoryRecv::mStorage);
-}
-
-bool InventoryHandler::canSplit(const Item *const item A_UNUSED) const
-{
- return false;
-}
-
-void InventoryHandler::splitItem(const Item *const item A_UNUSED,
- const int amount A_UNUSED) const
-{
- // Not implemented for eAthena (possible?)
-}
-
-void InventoryHandler::moveItem(const int oldIndex A_UNUSED,
- const int newIndex A_UNUSED) const
-{
- // Not implemented for eAthena (possible?)
-}
-
-size_t InventoryHandler::getSize(const InventoryTypeT type) const
-{
- switch (type)
- {
- case InventoryType::Inventory:
- case InventoryType::MailEdit:
- return 100;
- case InventoryType::Storage:
- return 0; // Comes from server after items
- case InventoryType::Trade:
- return 12;
- case InventoryType::Npc:
- case InventoryType::Cart:
- case InventoryType::Vending:
- case InventoryType::Craft:
- case InventoryType::TypeEnd:
- case InventoryType::MailView:
- default:
- return 0;
- }
-}
-void InventoryHandler::destroyStorage() const
-{
- BLOCK_START("InventoryHandler::closeStorage")
- if (storageWindow != nullptr)
- {
- InventoryWindow *const inv = storageWindow;
- storageWindow->close();
- inv->unsetInventory();
- }
- BLOCK_END("InventoryHandler::closeStorage")
-}
-
-void InventoryHandler::forgotStorage() const
-{
- storageWindow = nullptr;
-}
-
-void InventoryHandler::pushPickup(const BeingId floorId)
-{
- InventoryRecv::mSentPickups.push(floorId);
-}
-
-Inventory *InventoryHandler::getStorage() const
-{
- return InventoryRecv::mStorage;
-}
-
-} // namespace Ea
diff --git a/src/net/ea/inventoryhandler.h b/src/net/ea/inventoryhandler.h
deleted file mode 100644
index f968a3216..000000000
--- a/src/net/ea/inventoryhandler.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 NET_EA_INVENTORYHANDLER_H
-#define NET_EA_INVENTORYHANDLER_H
-
-#include "localconsts.h"
-
-#include "net/inventoryhandler.h"
-
-#include <queue>
-
-namespace Ea
-{
-
-typedef std::queue<BeingId> PickupQueue;
-
-class InventoryHandler notfinal : public Net::InventoryHandler
-{
- public:
- A_DELETE_COPY(InventoryHandler)
-
- virtual ~InventoryHandler();
-
- void clear() const override final;
-
- bool canSplit(const Item *const item) const
- override final A_CONST A_WARN_UNUSED;
-
- void splitItem(const Item *const item,
- const int amount) const override final A_CONST;
-
- void moveItem(const int oldIndex,
- const int newIndex) const override final A_CONST;
-
- size_t getSize(const InventoryTypeT type) const override final
- A_CONST A_WARN_UNUSED;
-
- static void pushPickup(const BeingId floorId);
-
- void destroyStorage() const override final;
-
- void forgotStorage() const override final;
-
- Inventory *getStorage() const override final;
-
- protected:
- InventoryHandler();
-};
-
-} // namespace Ea
-
-#endif // NET_EA_INVENTORYHANDLER_H
diff --git a/src/net/ea/inventoryitem.h b/src/net/ea/inventoryitem.h
deleted file mode 100644
index daf5cd65e..000000000
--- a/src/net/ea/inventoryitem.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 NET_EA_INVENTORYITEM_H
-#define NET_EA_INVENTORYITEM_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/favorite.h"
-#include "enums/simpletypes/identified.h"
-#include "enums/simpletypes/itemcolor.h"
-
-#include "utils/vector.h"
-
-#include "resources/item/itemoptionslist.h"
-
-#include "localconsts.h"
-
-namespace Ea
-{
-
-/**
- * Used to cache storage data until we get size data for it.
- */
-class InventoryItem final
-{
- public:
- int slot;
- int id;
- ItemTypeT type;
- int cards[maxCards];
- ItemOptionsList *options;
- int quantity;
- uint8_t refine;
- ItemColor color;
- Identified identified;
- Damaged damaged;
- Favorite favorite;
- Equipm equip;
-
- InventoryItem(const int slot0,
- const int id0,
- const ItemTypeT type0,
- const int *const cards0,
- ItemOptionsList *options0,
- const int quantity0,
- const uint8_t refine0,
- const ItemColor color0,
- const Identified identified0,
- const Damaged damaged0,
- const Favorite favorite0,
- Equipm equip0) :
- slot(slot0),
- id(id0),
- type(type0),
- cards(),
- options(ItemOptionsList::copy(options0)),
- quantity(quantity0),
- refine(refine0),
- color(color0),
- identified(identified0),
- damaged(damaged0),
- favorite(favorite0),
- equip(equip0)
- {
- if (cards0 == nullptr)
- return;
- for (int f = 0; f < 4; f ++)
- cards[f] = cards0[f];
- }
-
- InventoryItem(const InventoryItem &c) :
- slot(c.slot),
- id(c.id),
- type(c.type),
- cards(),
- options(ItemOptionsList::copy(c.options)),
- quantity(c.quantity),
- refine(c.refine),
- color(c.color),
- identified(c.identified),
- damaged(c.damaged),
- favorite(c.favorite),
- equip(c.equip)
- {
- for (int f = 0; f < 4; f ++)
- cards[f] = c.cards[f];
- }
-
- A_DEFAULT_COPY(InventoryItem)
-
- ~InventoryItem()
- {
- delete options;
- }
-};
-
-typedef STD_VECTOR<InventoryItem> InventoryItems;
-
-} // namespace Ea
-
-#endif // NET_EA_INVENTORYITEM_H
diff --git a/src/net/ea/inventoryrecv.cpp b/src/net/ea/inventoryrecv.cpp
deleted file mode 100644
index 3e8c239e9..000000000
--- a/src/net/ea/inventoryrecv.cpp
+++ /dev/null
@@ -1,193 +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 "net/ea/inventoryrecv.h"
-
-#include "notifymanager.h"
-
-#include "being/localplayer.h"
-
-#include "const/net/inventory.h"
-
-#include "enums/resources/notifytypes.h"
-
-#include "gui/widgets/createwidget.h"
-
-#include "net/inventoryhandler.h"
-#include "net/messagein.h"
-
-#include "net/ea/equipbackend.h"
-
-#include "utils/delete2.h"
-#include "utils/foreach.h"
-
-#include "listeners/arrowslistener.h"
-
-#include "debug.h"
-
-namespace Ea
-{
-
-namespace InventoryRecv
-{
- EquipBackend mEquips;
- InventoryItems mInventoryItems;
- Inventory *mStorage = nullptr;
- PickupQueue mSentPickups;
- bool mDebugInventory = true;
-} // namespace InventoryRecv
-
-void InventoryRecv::processPlayerInventoryUse(Net::MessageIn &msg)
-{
- BLOCK_START("InventoryRecv::processPlayerInventoryUse")
- Inventory *const inventory = localPlayer != nullptr
- ? PlayerInfo::getInventory() : nullptr;
-
- const int index = msg.readInt16("index") - INVENTORY_OFFSET;
- msg.readInt16("item id");
- msg.readInt32("id?");
- const int amount = msg.readInt16("amount");
- msg.readUInt8("type");
-
- if (inventory != nullptr)
- {
- if (Item *const item = inventory->getItem(index))
- {
- if (amount != 0)
- item->setQuantity(amount);
- else
- inventory->removeItemAt(index);
- }
- }
- BLOCK_END("InventoryRecv::processPlayerInventoryUse")
-}
-
-void InventoryRecv::processItemUseResponse(Net::MessageIn &msg)
-{
- BLOCK_START("InventoryRecv::processItemUseResponse")
- Inventory *const inventory = localPlayer != nullptr
- ? PlayerInfo::getInventory() : nullptr;
-
- const int index = msg.readInt16("index") - INVENTORY_OFFSET;
- const int amount = msg.readInt16("amount");
-
- if (msg.readUInt8("result") == 0)
- {
- NotifyManager::notify(NotifyTypes::USE_FAILED);
- }
- else
- {
- if (inventory != nullptr)
- {
- if (Item *const item = inventory->getItem(index))
- {
- if (amount != 0)
- item->setQuantity(amount);
- else
- inventory->removeItemAt(index);
- }
- }
- }
- BLOCK_END("InventoryRecv::processItemUseResponse")
-}
-
-void InventoryRecv::processPlayerStorageStatus(Net::MessageIn &msg)
-{
- BLOCK_START("InventoryRecv::processPlayerStorageStatus")
- /*
- * This is the closest we get to an "Open Storage" packet from the
- * server. It always comes after the two SMSG_PLAYER_STORAGE_...
- * packets that update storage contents.
- */
- msg.readInt16("used count");
- const int size = msg.readInt16("max size");
-
- if (mStorage == nullptr)
- mStorage = new Inventory(InventoryType::Storage, size);
-
- FOR_EACH (Ea::InventoryItems::const_iterator, it, mInventoryItems)
- {
- mStorage->setItem((*it).slot,
- (*it).id,
- (*it).type,
- (*it).quantity,
- (*it).refine,
- (*it).color,
- (*it).identified,
- (*it).damaged,
- (*it).favorite,
- (*it).equip,
- Equipped_false);
- }
- mInventoryItems.clear();
-
- if (storageWindow == nullptr)
- {
- CREATEWIDGETV(storageWindow, InventoryWindow, mStorage);
- }
- BLOCK_END("InventoryRecv::processPlayerStorageStatus")
-}
-
-void InventoryRecv::processPlayerStorageClose(Net::MessageIn &msg A_UNUSED)
-{
- BLOCK_START("InventoryRecv::processPlayerStorageClose")
- // Storage access has been closed
- // Storage window deletes itself
- if (storageWindow != nullptr)
- {
- storageWindow->unsetInventory();
- storageWindow->close();
- }
- storageWindow = nullptr;
-
- if (mStorage != nullptr)
- mStorage->clear();
-
- delete2(mStorage);
- BLOCK_END("InventoryRecv::processPlayerStorageClose")
-}
-
-void InventoryRecv::processPlayerAttackRange(Net::MessageIn &msg)
-{
- BLOCK_START("InventoryRecv::processPlayerAttackRange")
- const int range = msg.readInt16("range");
- if (localPlayer != nullptr)
- localPlayer->setAttackRange(range);
- PlayerInfo::setStatBase(Attributes::PLAYER_ATTACK_RANGE, range);
- PlayerInfo::setStatMod(Attributes::PLAYER_ATTACK_RANGE, 0);
- BLOCK_END("InventoryRecv::processPlayerAttackRange")
-}
-
-void InventoryRecv::processPlayerArrowEquip(Net::MessageIn &msg)
-{
- BLOCK_START("InventoryRecv::processPlayerArrowEquip")
- int index = msg.readInt16("index");
- if (index <= 1)
- return;
-
- index -= INVENTORY_OFFSET;
- mEquips.setEquipment(inventoryHandler->getProjectileSlot(), index);
- ArrowsListener::distributeEvent();
- BLOCK_END("InventoryRecv::processPlayerArrowEquip")
-}
-
-} // namespace Ea
diff --git a/src/net/ea/inventoryrecv.h b/src/net/ea/inventoryrecv.h
deleted file mode 100644
index 33c4f4682..000000000
--- a/src/net/ea/inventoryrecv.h
+++ /dev/null
@@ -1,64 +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 NET_EA_INVENTORYRECV_H
-#define NET_EA_INVENTORYRECV_H
-
-#include "localconsts.h"
-
-#include "enums/simpletypes/beingid.h"
-
-#include "net/ea/inventoryitem.h"
-
-#include <queue>
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-class Inventory;
-
-namespace Ea
-{
- typedef std::queue<BeingId> PickupQueue;
-
- class EquipBackend;
-
- namespace InventoryRecv
- {
- extern EquipBackend mEquips;
- extern InventoryItems mInventoryItems;
- extern Inventory *mStorage;
- extern PickupQueue mSentPickups;
- extern bool mDebugInventory;
-
- void processPlayerInventoryUse(Net::MessageIn &msg);
- void processItemUseResponse(Net::MessageIn &msg);
- void processPlayerStorageStatus(Net::MessageIn &msg);
- void processPlayerStorageClose(Net::MessageIn &msg);
- void processPlayerAttackRange(Net::MessageIn &msg);
- void processPlayerArrowEquip(Net::MessageIn &msg);
- } // namespace InventoryRecv
-} // namespace Ea
-
-#endif // NET_EA_INVENTORYRECV_H
diff --git a/src/net/ea/itemhandler.cpp b/src/net/ea/itemhandler.cpp
deleted file mode 100644
index b5a676cb7..000000000
--- a/src/net/ea/itemhandler.cpp
+++ /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/>.
- */
-
-#include "net/ea/itemhandler.h"
-
-#include "debug.h"
-
-namespace Ea
-{
-
-ItemHandler::ItemHandler()
-{
-}
-
-ItemHandler::~ItemHandler()
-{
-}
-
-} // namespace Ea
diff --git a/src/net/ea/itemhandler.h b/src/net/ea/itemhandler.h
deleted file mode 100644
index 405886b4a..000000000
--- a/src/net/ea/itemhandler.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 NET_EA_ITEMHANDLER_H
-#define NET_EA_ITEMHANDLER_H
-
-#include "localconsts.h"
-
-namespace Ea
-{
-
-class ItemHandler notfinal
-{
- public:
- ItemHandler();
-
- A_DELETE_COPY(ItemHandler)
-
- virtual ~ItemHandler();
-};
-
-} // namespace Ea
-
-#endif // NET_EA_ITEMHANDLER_H
diff --git a/src/net/ea/itemrecv.cpp b/src/net/ea/itemrecv.cpp
deleted file mode 100644
index 59256535d..000000000
--- a/src/net/ea/itemrecv.cpp
+++ /dev/null
@@ -1,48 +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 "net/ea/itemrecv.h"
-
-#include "actormanager.h"
-
-#include "being/flooritem.h"
-
-#include "net/messagein.h"
-
-#include "debug.h"
-
-namespace Ea
-{
-
-void ItemRecv::processItemRemove(Net::MessageIn &msg)
-{
- if (actorManager != nullptr)
- {
- if (FloorItem *const item = actorManager
- ->findItem(msg.readBeingId("floor item id")))
- {
- actorManager->destroy(item);
- }
- }
-}
-
-} // namespace Ea
diff --git a/src/net/ea/itemrecv.h b/src/net/ea/itemrecv.h
deleted file mode 100644
index 5e159b791..000000000
--- a/src/net/ea/itemrecv.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 NET_EA_ITEMRECV_H
-#define NET_EA_ITEMRECV_H
-
-#include "localconsts.h"
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-namespace Ea
-{
- namespace ItemRecv
- {
- void processItemRemove(Net::MessageIn &msg);
- } // namespace ItemRecv
-} // namespace Ea
-
-#endif // NET_EA_ITEMRECV_H
diff --git a/src/net/ea/loginhandler.cpp b/src/net/ea/loginhandler.cpp
deleted file mode 100644
index 28aefef7a..000000000
--- a/src/net/ea/loginhandler.cpp
+++ /dev/null
@@ -1,183 +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 "net/ea/loginhandler.h"
-
-#include "client.h"
-#include "configuration.h"
-#include "logger.h"
-#include "settings.h"
-
-#include "utils/cast.h"
-#include "utils/dtor.h"
-
-#include "net/logindata.h"
-
-#include "net/ea/loginrecv.h"
-
-#include "debug.h"
-
-namespace Ea
-{
-
-LoginHandler::LoginHandler() :
- Net::LoginHandler()
-{
- LoginRecv::mVersionResponse = false;
- LoginRecv::mRegistrationEnabled = true;
- LoginRecv::mUpdateHost.clear();
- LoginRecv::mWorlds.clear();
- LoginRecv::mToken.clear();
-}
-
-LoginHandler::~LoginHandler()
-{
- delete_all(LoginRecv::mWorlds);
-}
-
-bool LoginHandler::isRegistrationEnabled() const
-{
- return LoginRecv::mRegistrationEnabled;
-}
-
-void LoginHandler::getRegistrationDetails() const
-{
- // Not supported, so move on
- client->setState(State::REGISTER);
-}
-
-void LoginHandler::loginAccount(LoginData *const loginData1) const
-{
- if (loginData1 != nullptr)
- {
- loginData1->resetCharacterSlots();
- sendLoginRegister(loginData1->username, loginData1->password, "");
- }
-}
-
-void LoginHandler::chooseServer(const unsigned int server,
- const bool persistentIp) const
-{
- if (CAST_SIZE(server) >= LoginRecv::mWorlds.size() ||
- (LoginRecv::mWorlds[server] == nullptr))
- {
- return;
- }
-
- ServerInfo *const charServer = getCharServer();
- if (charServer != nullptr)
- {
- if (config.getBoolValue("usePersistentIP") || persistentIp)
- {
- charServer->hostname = settings.serverName;
- }
- else
- {
- charServer->hostname = ipToString(
- LoginRecv::mWorlds[server]->address);
- }
- charServer->port = LoginRecv::mWorlds[server]->port;
- }
-
- client->setState(State::UPDATE);
-}
-
-void LoginHandler::registerAccount(const LoginData *const loginData1) const
-{
- if (loginData1 == nullptr)
- return;
-
- std::string username = loginData1->username;
- switch (loginData1->gender)
- {
- case Gender::FEMALE:
- username.append("_F");
- break;
- case Gender::MALE:
- username.append("_M");
- break;
- case Gender::OTHER:
- username.append("_O");
- break;
- case Gender::UNSPECIFIED:
- default:
- break;
- }
-
- sendLoginRegister(username, loginData1->password, loginData1->email);
-}
-
-const Worlds &LoginHandler::getWorlds() const
-{
- return LoginRecv::mWorlds;
-}
-
-void LoginHandler::clearWorlds() const
-{
- delete_all(LoginRecv::mWorlds);
- LoginRecv::mWorlds.clear();
-}
-
-void LoginHandler::loginOrRegister(LoginData *const data) const
-{
- if (data == nullptr)
- return;
-
- logger->log("Username is %s", data->username.c_str());
-
- // Send login infos
- if (data->registerLogin)
- registerAccount(data);
- else
- loginAccount(data);
-
- // Clear the password, avoids auto login when returning to login
- data->password.clear();
-
- const bool remember = data->remember;
- if (remember)
- serverConfig.setValue("username", data->username);
- else
- serverConfig.setValue("username", "");
- serverConfig.setValue("remember", remember);
-}
-
-void LoginHandler::logout() const
-{
-}
-
-void LoginHandler::changeEmail(const std::string &email A_UNUSED) const
-{
-}
-
-void LoginHandler::unregisterAccount(const std::string &username A_UNUSED,
- const std::string &password
- A_UNUSED) const
-{
-}
-
-const Token &LoginHandler::getToken() const
-{
- return LoginRecv::mToken;
-}
-
-} // namespace Ea
diff --git a/src/net/ea/loginhandler.h b/src/net/ea/loginhandler.h
deleted file mode 100644
index d475fc184..000000000
--- a/src/net/ea/loginhandler.h
+++ /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/>.
- */
-
-#ifndef NET_EA_LOGINHANDLER_H
-#define NET_EA_LOGINHANDLER_H
-
-#include "net/loginhandler.h"
-
-class LoginData;
-
-struct Token;
-
-namespace Ea
-{
-
-class LoginHandler notfinal : public Net::LoginHandler
-{
- public:
- A_DELETE_COPY(LoginHandler)
-
- virtual ~LoginHandler();
-
- bool isRegistrationEnabled() const override final A_WARN_UNUSED;
-
- void getRegistrationDetails() const override final;
-
- unsigned int getMaxPasswordLength() const override A_WARN_UNUSED
- { return 24; }
-
- void loginAccount(LoginData *const loginData) const override final;
-
- void chooseServer(const unsigned int server,
- const bool persistentIp) const override;
-
- void registerAccount(const LoginData *const loginData)
- const override final;
-
- const Worlds &getWorlds() const override final A_CONST A_WARN_UNUSED;
-
- void clearWorlds() const override final;
-
- virtual ServerInfo *getCharServer() const A_WARN_UNUSED = 0;
-
- const Token &getToken() const A_CONST A_WARN_UNUSED;
-
- void logout() const override final A_CONST;
-
- void changeEmail(const std::string &email) const
- override final A_CONST;
-
- void unregisterAccount(const std::string &username,
- const std::string &password)
- const override final A_CONST;
-
- void loginOrRegister(LoginData *const data) const override final;
-
- protected:
- LoginHandler();
-
- virtual void sendLoginRegister(const std::string &username,
- const std::string &password,
- const std::string &email) const = 0;
-};
-
-} // namespace Ea
-
-#endif // NET_EA_LOGINHANDLER_H
diff --git a/src/net/ea/loginrecv.cpp b/src/net/ea/loginrecv.cpp
deleted file mode 100644
index 2591a417c..000000000
--- a/src/net/ea/loginrecv.cpp
+++ /dev/null
@@ -1,135 +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 "net/ea/loginrecv.h"
-
-#include "client.h"
-
-#include "fs/paths.h"
-
-#include "gui/windows/logindialog.h"
-
-#include "utils/gettext.h"
-
-#include "net/logindata.h"
-#include "net/messagein.h"
-
-#include "debug.h"
-
-namespace Ea
-{
-
-namespace LoginRecv
-{
- std::string mUpdateHost;
- Worlds mWorlds;
- Token mToken;
- bool mVersionResponse = false;
- bool mRegistrationEnabled = true;
-} // namespace LoginRecv
-
-void LoginRecv::processUpdateHost(Net::MessageIn &msg)
-{
- const int len = msg.readInt16("len") - 4;
- mUpdateHost = msg.readString(len, "update host");
-
- if (!checkPath(mUpdateHost))
- {
- mUpdateHost.clear();
- logger->log1("Warning: incorrect update server name");
- }
- loginData.updateHost = mUpdateHost;
-
- logger->log("Received update host \"%s\" from login server.",
- mUpdateHost.c_str());
-}
-
-void LoginRecv::processLoginError(Net::MessageIn &msg)
-{
- const uint8_t code = msg.readUInt8("error");
- logger->log("Login::error code: %u", CAST_U32(code));
- std::string date = msg.readString(20, "date");
-
- switch (code)
- {
- case 0:
- // TRANSLATORS: error message
- errorMessage = _("Unregistered ID.");
- break;
- case 1:
- // TRANSLATORS: error message
- errorMessage = _("Wrong password.");
- LoginDialog::savedPassword.clear();
- break;
- case 2:
- // TRANSLATORS: error message
- errorMessage = _("Account expired.");
- break;
- case 3:
- // TRANSLATORS: error message
- errorMessage = _("Rejected from server.");
- break;
- case 4:
- // TRANSLATORS: error message
- errorMessage = _("You have been permanently banned from "
- "the game. Please contact the GM team.");
- break;
- case 5:
- // TRANSLATORS: error message
- errorMessage = _("Client too old or wrong server type.\n"
- "Please update client on http://manaplus.org");
- break;
- case 6:
- // TRANSLATORS: error message
- errorMessage = strprintf(_("You have been temporarily "
- "banned from the game until %s.\nPlease contact the GM "
- "team via the forums."), date.c_str());
- break;
- case 7:
- // TRANSLATORS: error message
- errorMessage = _("Server overpopulated.");
- break;
- case 9:
- // TRANSLATORS: error message
- errorMessage = _("This user name is already taken.");
- break;
- case 10:
- // TRANSLATORS: error message
- errorMessage = _("Wrong name.");
- break;
- case 11:
- // TRANSLATORS: error message
- errorMessage = _("Incorrect email.");
- break;
- case 99:
- // TRANSLATORS: error message
- errorMessage = _("Username permanently erased.");
- break;
- default:
- // TRANSLATORS: error message
- errorMessage = _("Unknown error.");
- break;
- }
- client->setState(State::ERROR);
-}
-
-} // namespace Ea
diff --git a/src/net/ea/loginrecv.h b/src/net/ea/loginrecv.h
deleted file mode 100644
index 80ac08e44..000000000
--- a/src/net/ea/loginrecv.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 NET_EA_LOGINRECV_H
-#define NET_EA_LOGINRECV_H
-
-#include "net/worldinfo.h"
-
-#include "net/ea/token.h"
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-namespace Ea
-{
- namespace LoginRecv
- {
- extern std::string mUpdateHost;
- extern Worlds mWorlds;
- extern Token mToken;
- extern bool mVersionResponse;
- extern bool mRegistrationEnabled;
-
- void processUpdateHost(Net::MessageIn &msg);
- void processLoginError(Net::MessageIn &msg);
- } // namespace LoginRecv
-} // namespace Ea
-
-#endif // NET_EA_LOGINRECV_H
diff --git a/src/net/ea/maprecv.cpp b/src/net/ea/maprecv.cpp
deleted file mode 100644
index dbe9d4559..000000000
--- a/src/net/ea/maprecv.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 Lloyd Bryant <lloyd_bryant@netzero.net>
- * 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 "net/ea/maprecv.h"
-
-#include "gui/viewport.h"
-
-#include "resources/map/map.h"
-
-#include "net/messagein.h"
-
-#include "debug.h"
-
-namespace Ea
-{
-
-void MapRecv::processSetTilesType(Net::MessageIn &msg)
-{
- const int x1 = msg.readInt16("x1");
- const int y1 = msg.readInt16("y1");
- const int x2 = msg.readInt16("x2");
- const int y2 = msg.readInt16("y2");
- const BlockTypeT mask = static_cast<BlockTypeT>(msg.readInt32("mask"));
- const int layer = msg.readInt32("layer");
- const std::string name = msg.readString(16, "map name");
- if (layer != 0)
- return;
- Map *const map = viewport->getMap();
- if ((map != nullptr) && map->getGatName() == name)
- {
- for (int y = y1; y <= y2; y ++)
- {
- for (int x = x1; x <= x2; x ++)
- map->setBlockMask(x, y, mask);
- }
- map->updateConditionLayers();
- map->preCacheLayers();
- }
-}
-
-} // namespace Ea
diff --git a/src/net/ea/maprecv.h b/src/net/ea/maprecv.h
deleted file mode 100644
index 48c19d158..000000000
--- a/src/net/ea/maprecv.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 Lloyd Bryant <lloyd_bryant@netzero.net>
- * 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 NET_EA_MAPRECV_H
-#define NET_EA_MAPRECV_H
-
-#include "localconsts.h"
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-namespace Ea
-{
- namespace MapRecv
- {
- void processSetTilesType(Net::MessageIn &msg);
- } // namespace MapRecv
-} // namespace Ea
-
-#endif // NET_EA_MAPRECV_H
diff --git a/src/net/ea/network.cpp b/src/net/ea/network.cpp
deleted file mode 100644
index 1ae4d2323..000000000
--- a/src/net/ea/network.cpp
+++ /dev/null
@@ -1,372 +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 "net/ea/network.h"
-
-#include "configuration.h"
-#include "logger.h"
-
-#include "net/packetinfo.h"
-
-#include "utils/cast.h"
-#include "utils/delete2.h"
-#include "utils/gettext.h"
-#include "utils/sdlhelper.h"
-
-#include <sstream>
-
-#include "debug.h"
-
-#ifndef SDL_BIG_ENDIAN
-#error missing SDL_endian.h
-#endif // SDL_BYTEORDER
-
-extern unsigned int mLastHost;
-
-namespace Ea
-{
-
-const unsigned int BUFFER_SIZE = 1000000;
-const unsigned int BUFFER_LIMIT = 930000;
-
-int networkThread(void *data)
-{
- Network *const network = static_cast<Network *>(data);
-
- if ((network == nullptr) || !network->realConnect())
- return -1;
-
- network->receive();
-
- return 0;
-}
-
-Network::Network() :
- mSocket(nullptr),
- mServer(),
- mPackets(nullptr),
- mInBuffer(new char[BUFFER_SIZE]),
- mOutBuffer(new char[BUFFER_SIZE]),
- mInSize(0),
- mOutSize(0),
- mToSkip(0),
- mState(IDLE),
- mError(),
- mWorkerThread(nullptr),
- mMutexIn(SDL_CreateMutex()),
- mMutexOut(SDL_CreateMutex()),
- mSleep(config.getIntValue("networksleep")),
- mPauseDispatch(false)
-{
- TcpNet::init();
-}
-
-Network::~Network()
-{
- if (mState != IDLE && mState != NET_ERROR)
- disconnect();
-
- SDL_DestroyMutex(mMutexIn);
- mMutexIn = nullptr;
- SDL_DestroyMutex(mMutexOut);
- mMutexOut = nullptr;
-
- delete2Arr(mInBuffer);
- delete2Arr(mOutBuffer);
- delete2Arr(mPackets);
-
- TcpNet::quit();
-}
-
-bool Network::connect(const ServerInfo &server)
-{
- if (mState != IDLE && mState != NET_ERROR)
- {
- logger->log1("Tried to connect an already connected socket!");
- return false;
- }
-
- if (server.hostname.empty())
- {
- // TRANSLATORS: error message
- setError(_("Empty address given to Network::connect()!"));
- return false;
- }
-
- logger->log("Network::Connecting to %s:%i",
- server.hostname.c_str(), server.port);
-
- mServer.hostname = server.hostname;
- mServer.althostname = server.althostname;
- mServer.port = server.port;
-
- // Reset to sane values
- mOutSize = 0;
- mInSize = 0;
- mToSkip = 0;
-
- mState = CONNECTING;
- mWorkerThread = SDL::createThread(&networkThread, "network", this);
- if (mWorkerThread == nullptr)
- {
- setError("Unable to create network worker thread");
- return false;
- }
-
- return true;
-}
-
-void Network::disconnect()
-{
- BLOCK_START("Network::disconnect")
- mState = IDLE;
-
- SDL::WaitThread(mWorkerThread);
- mWorkerThread = nullptr;
-
- if (mSocket != nullptr)
- {
- TcpNet::closeSocket(mSocket);
- mSocket = nullptr;
- if (mSleep > 0)
- SDL_Delay(mSleep);
- }
- BLOCK_END("Network::disconnect")
-}
-
-void Network::flush()
-{
- if ((mOutSize == 0u) || mState != CONNECTED)
- return;
-
- SDL_mutexP(mMutexOut);
- const int ret = TcpNet::send(mSocket, mOutBuffer, mOutSize);
-/*
- if (logger)
- {
- logger->dlog(std::string("Send ").append(
- toString(mOutSize)).append(" bytes"));
- }
-*/
- if (ret < CAST_S32(mOutSize))
- {
- SDL_mutexV(mMutexOut);
- setError("Error in TcpNet::send(): " +
- std::string(TcpNet::getError()));
- }
- mOutSize = 0;
- SDL_mutexV(mMutexOut);
-}
-
-void Network::skip(const int len)
-{
- SDL_mutexP(mMutexIn);
- mToSkip += len;
- if (mInSize == 0u)
- {
- SDL_mutexV(mMutexIn);
- return;
- }
-
- if (mInSize >= mToSkip)
- {
- mInSize -= mToSkip;
- memmove(mInBuffer, mInBuffer + CAST_SIZE(mToSkip), mInSize);
- mToSkip = 0;
- }
- else
- {
- mToSkip -= mInSize;
- mInSize = 0;
- }
- SDL_mutexV(mMutexIn);
-}
-
-bool Network::realConnect()
-{
- IPaddress ipAddress;
-
- if (TcpNet::resolveHost(&ipAddress, mServer.hostname.c_str(),
- mServer.port) == -1)
- {
- if (mServer.althostname.empty() || TcpNet::resolveHost(&ipAddress,
- mServer.althostname.c_str(), mServer.port) == -1)
- {
- const std::string errorMessage = std::string(
- // TRANSLATORS: error message
- _("Unable to resolve host \"")).append(
- mServer.hostname).append("\".");
- setError(errorMessage);
- logger->log_r("TcpNet::ResolveHost: %s", errorMessage.c_str());
- return false;
- }
- logger->log_r("using alt host name: %s", mServer.althostname.c_str());
- }
-
- mState = CONNECTING;
-
- mSocket = TcpNet::open(&ipAddress);
- if (mSocket == nullptr)
- {
- logger->log_r("Error in TcpNet::open(): %s", TcpNet::getError());
- setError(TcpNet::getError());
- return false;
- }
-
- mLastHost = ipAddress.host;
- logger->log_r("Network::Started session with %s:%i",
- ipToString(ipAddress.host), ipAddress.port);
-
- mState = CONNECTED;
- return true;
-}
-
-void Network::receive()
-{
- TcpNet::SocketSet set;
-
- if ((set = TcpNet::allocSocketSet(1)) == nullptr)
- {
- setError("Error in TcpNet::allocSocketSet(): " +
- std::string(TcpNet::getError()));
- return;
- }
-
- if (TcpNet::addSocket(set, mSocket) == -1)
- {
- setError("Error in TcpNet::addSocket(): " +
- std::string(TcpNet::getError()));
- }
-
- while (mState == CONNECTED)
- {
- const int numReady = TcpNet::checkSockets(
- set, (CAST_U32(500)));
- switch (numReady)
- {
- case -1:
- logger->log_r("Error: TcpNet::checkSockets");
- break;
- // FALLTHROUGH
- case 0:
- break;
-
- case 1:
- {
- // Receive data from the socket
- SDL_mutexP(mMutexIn);
- if (mInSize > BUFFER_LIMIT)
- {
- SDL_mutexV(mMutexIn);
- SDL_Delay(100);
- continue;
- }
-
- const int ret = TcpNet::recv(mSocket,
- mInBuffer + CAST_SIZE(mInSize),
- BUFFER_SIZE - mInSize);
-
- if (ret == 0)
- {
- // We got disconnected
- mState = IDLE;
- logger->log_r("Disconnected.");
- }
- else if (ret < 0)
- {
- // TRANSLATORS: error message
- setError(_("Connection to server terminated. ") +
- std::string(TcpNet::getError()));
- }
- else
- {
-// DEBUGLOG("Receive " + toString(ret) + " bytes");
- mInSize += ret;
- if (mToSkip != 0u)
- {
- if (mInSize >= mToSkip)
- {
- mInSize -= mToSkip;
- memmove(mInBuffer,
- mInBuffer + CAST_SIZE(mToSkip),
- mInSize);
- mToSkip = 0;
- }
- else
- {
- mToSkip -= mInSize;
- mInSize = 0;
- }
- }
- }
- SDL_mutexV(mMutexIn);
- break;
- }
-
- default:
- // more than one socket is ready..
- // this should not happen since we only listen once socket.
- std::stringstream errorStream;
- errorStream << "Error in TcpNet::recv(), " << numReady
- << " sockets are ready: " << TcpNet::getError();
- setError(errorStream.str());
- break;
- }
- }
-
- if (TcpNet::delSocket(set, mSocket) == -1)
- logger->log_r("Error in TcpNet::delSocket(): %s", TcpNet::getError());
-
- TcpNet::freeSocketSet(set);
-}
-
-void Network::setError(const std::string &error)
-{
- logger->log_r("Network error: %s", error.c_str());
- mError = error;
- mState = NET_ERROR;
-}
-
-uint16_t Network::readWord(const int pos) const
-{
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- return SDL_Swap16(*reinterpret_cast<uint16_t*>(
- mInBuffer + CAST_SIZE(pos)));
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- return (*reinterpret_cast<uint16_t*>(
- mInBuffer + CAST_SIZE(pos)));
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-}
-
-void Network::fixSendBuffer()
-{
- if (mOutSize > BUFFER_LIMIT)
- {
- if (mState != CONNECTED)
- mOutSize = 0;
- else
- flush();
- }
-}
-
-} // namespace Ea
diff --git a/src/net/ea/network.h b/src/net/ea/network.h
deleted file mode 100644
index cd5be69e3..000000000
--- a/src/net/ea/network.h
+++ /dev/null
@@ -1,121 +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 NET_EA_NETWORK_H
-#define NET_EA_NETWORK_H
-
-#include "net/serverinfo.h"
-
-PRAGMACLANG6GCC(GCC diagnostic push)
-PRAGMACLANG6GCC(GCC diagnostic ignored "-Wold-style-cast")
-#include "net/sdltcpnet.h"
-PRAGMACLANG6GCC(GCC diagnostic pop)
-
-struct PacketInfo;
-
-namespace Ea
-{
-
-class Network notfinal
-{
- public:
- Network();
-
- A_DELETE_COPY(Network)
-
- virtual ~Network();
-
- bool connect(const ServerInfo &server);
-
- void disconnect();
-
- ServerInfo getServer() const A_WARN_UNUSED
- { return mServer; }
-
- int getState() const A_WARN_UNUSED
- { return mState; }
-
- const std::string &getError() const A_WARN_UNUSED
- { return mError; }
-
- bool isConnected() const A_WARN_UNUSED
- { return mState == CONNECTED; }
-
- int getInSize() const A_WARN_UNUSED
- { return mInSize; }
-
- void skip(const int len);
-
- void flush();
-
- void fixSendBuffer();
-
- void pauseDispatch()
- { mPauseDispatch = true; }
-
- // ERROR replaced by NET_ERROR because already defined in Windows
- enum
- {
- IDLE = 0,
- CONNECTED,
- CONNECTING,
- DATA,
- NET_ERROR
- };
-
- protected:
- friend int networkThread(void *data);
-
- void setError(const std::string &error);
-
- uint16_t readWord(const int pos) const A_WARN_UNUSED;
-
- bool realConnect();
-
- void receive();
-
- TcpNet::Socket mSocket;
-
- ServerInfo mServer;
-
- PacketInfo *mPackets;
-
- char *mInBuffer;
- char *mOutBuffer;
- unsigned int mInSize;
- unsigned int mOutSize;
-
- unsigned int mToSkip;
-
- int mState;
- std::string mError;
-
- SDL_Thread *mWorkerThread;
- SDL_mutex *mMutexIn;
- SDL_mutex *mMutexOut;
- int mSleep;
- bool mPauseDispatch;
-};
-
-} // namespace Ea
-
-#endif // NET_EA_NETWORK_H
diff --git a/src/net/ea/npchandler.cpp b/src/net/ea/npchandler.cpp
deleted file mode 100644
index e7ac6fa65..000000000
--- a/src/net/ea/npchandler.cpp
+++ /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/>.
- */
-
-#include "net/ea/npchandler.h"
-
-#include "net/ea/npcrecv.h"
-
-#include "debug.h"
-
-namespace Ea
-{
-
-NpcHandler::NpcHandler()
-{
- NpcRecv::mDialog = nullptr;
- NpcRecv::mRequestLang = false;
-}
-
-NpcDialog *NpcHandler::getCurrentNpcDialog() const
-{
- return NpcRecv::mDialog;
-}
-
-} // namespace Ea
diff --git a/src/net/ea/npchandler.h b/src/net/ea/npchandler.h
deleted file mode 100644
index 2f3503957..000000000
--- a/src/net/ea/npchandler.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 NET_EA_NPCHANDLER_H
-#define NET_EA_NPCHANDLER_H
-
-#include "net/npchandler.h"
-
-#include "localconsts.h"
-
-namespace Ea
-{
-
-class NpcHandler notfinal : public Net::NpcHandler
-{
- public:
- A_DELETE_COPY(NpcHandler)
-
- NpcDialog *getCurrentNpcDialog() const override final;
-
- protected:
- NpcHandler();
-};
-
-} // namespace Ea
-
-#endif // NET_EA_NPCHANDLER_H
diff --git a/src/net/ea/npcrecv.cpp b/src/net/ea/npcrecv.cpp
deleted file mode 100644
index 098f07e79..000000000
--- a/src/net/ea/npcrecv.cpp
+++ /dev/null
@@ -1,246 +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 "net/ea/npcrecv.h"
-
-#include "gui/viewport.h"
-
-#include "gui/windows/npcdialog.h"
-
-#include "net/messagein.h"
-#include "net/npchandler.h"
-
-#include "utils/langs.h"
-
-#include "debug.h"
-
-namespace Ea
-{
-
-namespace NpcRecv
-{
- NpcDialog *mDialog = nullptr;
- bool mRequestLang = false;
-} // namespace NpcRecv
-
-void NpcRecv::processNpcChoice(Net::MessageIn &msg)
-{
- msg.readInt16("len");
- npcHandler->getNpc(msg, NpcAction::Other);
- mRequestLang = false;
-
- if (mDialog != nullptr)
- {
- mDialog->choiceRequest();
- mDialog->parseListItems(msg.readString(msg.getLength() - 8,
- "select items"));
- }
- else
- {
- msg.readString(msg.getLength() - 8, "select items");
- }
-}
-
-void NpcRecv::processNpcMessage(Net::MessageIn &msg)
-{
- msg.readInt16("len");
- npcHandler->getNpc(msg, NpcAction::Other);
- mRequestLang = false;
-
- const std::string message = msg.readString(msg.getLength() - 8, "message");
- // ignore future legacy npc commands.
- if (message.size() > 3 && message.substr(0, 3) == "###")
- return;
- if (mDialog != nullptr)
- mDialog->addText(message);
-}
-
-void NpcRecv::processNpcClose(Net::MessageIn &msg)
-{
- // Show the close button
- npcHandler->getNpc(msg, NpcAction::Close);
- mRequestLang = false;
- if (mDialog != nullptr)
- mDialog->showCloseButton();
-}
-
-void NpcRecv::processNpcNext(Net::MessageIn &msg)
-{
- // Show the next button
- npcHandler->getNpc(msg, NpcAction::Next);
- mRequestLang = false;
- if (mDialog != nullptr)
- mDialog->showNextButton();
-}
-
-void NpcRecv::processNpcIntInput(Net::MessageIn &msg)
-{
- // Request for an integer
- npcHandler->getNpc(msg, NpcAction::Other);
- mRequestLang = false;
- if (mDialog != nullptr)
- mDialog->integerRequest(0);
-}
-
-void NpcRecv::processNpcStrInput(Net::MessageIn &msg)
-{
- // Request for a string
- BeingId npcId = npcHandler->getNpc(msg, NpcAction::Other);
- if (mRequestLang)
- {
- mRequestLang = false;
- npcHandler->stringInput(npcId, getLangSimple());
- }
- else if (mDialog != nullptr)
- {
- mDialog->textRequest("");
- }
-}
-
-void NpcRecv::processNpcCommand(Net::MessageIn &msg)
-{
- const BeingId npcId = npcHandler->getNpc(msg, NpcAction::Other);
- mRequestLang = false;
-
- const int cmd = msg.readInt16("cmd");
- const BeingId id = msg.readBeingId("id");
- const int x = msg.readInt16("x");
- const int y = msg.readInt16("y");
- switch (cmd)
- {
- case 0:
- mRequestLang = true;
- break;
-
- case 1:
- if (viewport != nullptr)
- viewport->moveCameraToActor(npcId);
- break;
-
- case 2:
- if (viewport != nullptr)
- {
- if (id == BeingId_zero)
- viewport->moveCameraToPosition(x, y);
- else
- viewport->moveCameraToActor(id, x, y);
- }
- break;
-
- case 3:
- if (viewport != nullptr)
- viewport->returnCamera();
- break;
-
- case 4:
- if (viewport != nullptr)
- {
- viewport->moveCameraRelative(x, y);
- }
- break;
- case 5: // close dialog
- if (mDialog != nullptr)
- mDialog->restoreCamera();
- npcHandler->closeDialog(npcId);
- break;
- case 6: // show avatar
- if (mDialog != nullptr)
- {
- mDialog->showAvatar(fromInt(id, BeingTypeId));
- }
- break;
- case 7: // set avatar direction
- if (mDialog != nullptr)
- {
- mDialog->setAvatarDirection(
- Net::MessageIn::fromServerDirection(
- CAST_U8(id)));
- }
- break;
- case 8: // set avatar action
- if (mDialog != nullptr)
- mDialog->setAvatarAction(toInt(id, int));
- break;
- case 9: // clear npc dialog
- if (mDialog != nullptr)
- mDialog->clearRows();
- break;
- case 10: // send selected item id
- {
- int invSize = toInt(id, int);
- if (invSize == 0)
- invSize = 1;
- if (mDialog != nullptr)
- mDialog->itemRequest(invSize);
- break;
- }
- case 11: // send selected item index
- {
- int invSize = toInt(id, int);
- if (invSize == 0)
- invSize = 1;
- if (mDialog != nullptr)
- mDialog->itemIndexRequest(invSize);
- break;
- }
- case 12: // send complex items
- {
- int invSize = toInt(id, int);
- if (invSize == 0)
- invSize = 1;
- if (mDialog != nullptr)
- mDialog->itemCraftRequest(invSize);
- break;
- }
- case 14:
- {
- const NpcDialogs::iterator it = NpcDialog::mNpcDialogs.find(npcId);
- if (it != NpcDialog::mNpcDialogs.end())
- {
- NpcDialog *const dialog = (*it).second;
- if (dialog != nullptr)
- dialog->close();
- if (dialog == Ea::NpcRecv::mDialog)
- Ea::NpcRecv::mDialog = nullptr;
- NpcDialog::mNpcDialogs.erase(it);
- }
- break;
- }
- default:
- UNIMPLEMENTEDPACKETFIELD(cmd);
- break;
- }
-}
-
-void NpcRecv::processChangeTitle(Net::MessageIn &msg)
-{
- msg.readInt16("len");
- npcHandler->getNpc(msg, NpcAction::Other);
- mRequestLang = false;
- if (mDialog != nullptr)
- {
- const std::string str = msg.readString(-1, "title");
- mDialog->setCaption(str);
- }
-}
-
-} // namespace Ea
diff --git a/src/net/ea/npcrecv.h b/src/net/ea/npcrecv.h
deleted file mode 100644
index 1cf7fa058..000000000
--- a/src/net/ea/npcrecv.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 NET_EA_NPCRECV_H
-#define NET_EA_NPCRECV_H
-
-#include "localconsts.h"
-
-class NpcDialog;
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-namespace Ea
-{
- namespace NpcRecv
- {
- extern NpcDialog *mDialog;
- extern bool mRequestLang;
-
- void processNpcChoice(Net::MessageIn &msg);
- void processNpcMessage(Net::MessageIn &msg);
- void processNpcClose(Net::MessageIn &msg);
- void processNpcNext(Net::MessageIn &msg);
- void processNpcIntInput(Net::MessageIn &msg);
- void processNpcStrInput(Net::MessageIn &msg);
- void processNpcCommand(Net::MessageIn &msg);
- void processChangeTitle(Net::MessageIn &msg);
- } // namespace NpcRecv
-} // namespace Ea
-
-#endif // NET_EA_NPCRECV_H
diff --git a/src/net/ea/partyhandler.cpp b/src/net/ea/partyhandler.cpp
deleted file mode 100644
index 23f7347b9..000000000
--- a/src/net/ea/partyhandler.cpp
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 Lloyd Bryant <lloyd_bryant@netzero.net>
- * 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 "net/ea/partyhandler.h"
-
-#include "party.h"
-
-#include "net/ea/partyrecv.h"
-
-#include "gui/widgets/tabs/chat/partytab.h"
-
-#include "utils/delete2.h"
-
-#include "debug.h"
-
-namespace Ea
-{
-
-PartyHandler::PartyHandler() :
- Net::PartyHandler()
-{
- PartyRecv::mShareExp = PartyShare::UNKNOWN;
- PartyRecv::mShareItems = PartyShare::UNKNOWN;
- taParty = Party::getParty(1);
-}
-
-PartyHandler::~PartyHandler()
-{
- delete2(partyTab);
- taParty = nullptr;
-}
-
-void PartyHandler::join(const int partyId A_UNUSED) const
-{
-}
-
-void PartyHandler::reload()
-{
- taParty = Party::getParty(1);
-}
-
-void PartyHandler::clear() const
-{
- taParty = nullptr;
-}
-
-ChatTab *PartyHandler::getTab() const
-{
- return partyTab;
-}
-
-PartyShareT PartyHandler::getShareExperience() const
-{
- return PartyRecv::mShareExp;
-}
-
-PartyShareT PartyHandler::getShareItems() const
-{
- return PartyRecv::mShareItems;
-}
-
-} // namespace Ea
diff --git a/src/net/ea/partyhandler.h b/src/net/ea/partyhandler.h
deleted file mode 100644
index 2be323d85..000000000
--- a/src/net/ea/partyhandler.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 Lloyd Bryant <lloyd_bryant@netzero.net>
- * 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 NET_EA_PARTYHANDLER_H
-#define NET_EA_PARTYHANDLER_H
-
-#include "net/partyhandler.h"
-
-class Party;
-
-namespace Ea
-{
-class PartyHandler notfinal : public Net::PartyHandler
-{
- public:
- PartyHandler();
-
- A_DELETE_COPY(PartyHandler)
-
- virtual ~PartyHandler();
-
- void join(const int partyId) const override final A_CONST;
-
- PartyShareT getShareExperience() const override final A_WARN_UNUSED;
-
- PartyShareT getShareItems() const override final A_WARN_UNUSED;
-
- static void reload();
-
- void clear() const override final;
-
- ChatTab *getTab() const override final;
-};
-
-extern Party *taParty;
-
-} // namespace Ea
-
-#endif // NET_EA_PARTYHANDLER_H
diff --git a/src/net/ea/partyrecv.cpp b/src/net/ea/partyrecv.cpp
deleted file mode 100644
index d81bb4295..000000000
--- a/src/net/ea/partyrecv.cpp
+++ /dev/null
@@ -1,232 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 Lloyd Bryant <lloyd_bryant@netzero.net>
- * 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 "net/ea/partyrecv.h"
-
-#include "actormanager.h"
-#include "configuration.h"
-#include "notifymanager.h"
-#include "party.h"
-
-#include "being/localplayer.h"
-
-#include "enums/resources/notifytypes.h"
-
-#include "gui/windows/chatwindow.h"
-#include "gui/windows/socialwindow.h"
-
-#include "net/messagein.h"
-
-#include "gui/widgets/tabs/chat/partytab.h"
-
-#include "utils/delete2.h"
-
-#include "debug.h"
-
-namespace Ea
-{
-
-Party *taParty = nullptr;
-
-namespace PartyRecv
-{
- PartyShareT mShareExp = PartyShare::UNKNOWN;
- PartyShareT mShareItems = PartyShare::UNKNOWN;
-} // namespace PartyRecv
-
-void PartyRecv::processPartyCreate(Net::MessageIn &msg)
-{
- if (msg.readUInt8("flag") != 0u)
- NotifyManager::notify(NotifyTypes::PARTY_CREATE_FAILED);
- else
- NotifyManager::notify(NotifyTypes::PARTY_CREATED);
-}
-
-void PartyRecv::processPartyExpSettingsContinue(Net::MessageIn &msg,
- const PartyShareT exp)
-{
- switch (exp)
- {
- case PartyShare::YES:
- if (mShareExp == PartyShare::YES)
- break;
- mShareExp = PartyShare::YES;
- NotifyManager::notify(NotifyTypes::PARTY_EXP_SHARE_ON);
- break;
- case PartyShare::NO:
- if (mShareExp == PartyShare::NO)
- break;
- mShareExp = PartyShare::NO;
- NotifyManager::notify(NotifyTypes::PARTY_EXP_SHARE_OFF);
- break;
- case PartyShare::NOT_POSSIBLE:
- if (mShareExp == PartyShare::NOT_POSSIBLE)
- break;
- mShareExp = PartyShare::NOT_POSSIBLE;
- NotifyManager::notify(NotifyTypes::PARTY_EXP_SHARE_ERROR);
- break;
- default:
- case PartyShare::UNKNOWN:
- UNIMPLEMENTEDPACKETFIELD(CAST_S32(exp));
- break;
- }
-}
-
-void PartyRecv::processPartyItemSettingsContinue(Net::MessageIn &msg,
- const PartyShareT item)
-{
- switch (item)
- {
- case PartyShare::YES:
- if (mShareItems == PartyShare::YES)
- break;
- mShareItems = PartyShare::YES;
- NotifyManager::notify(NotifyTypes::PARTY_ITEM_SHARE_ON);
- break;
- case PartyShare::NO:
- if (mShareItems == PartyShare::NO)
- break;
- mShareItems = PartyShare::NO;
- NotifyManager::notify(NotifyTypes::PARTY_ITEM_SHARE_OFF);
- break;
- case PartyShare::NOT_POSSIBLE:
- if (mShareItems == PartyShare::NOT_POSSIBLE)
- break;
- mShareItems = PartyShare::NOT_POSSIBLE;
- NotifyManager::notify(NotifyTypes::PARTY_ITEM_SHARE_ERROR);
- break;
- default:
- case PartyShare::UNKNOWN:
- UNIMPLEMENTEDPACKETFIELD(CAST_S32(item));
- break;
- }
-}
-
-void PartyRecv::processPartyLeave(Net::MessageIn &msg)
-{
- const BeingId id = msg.readBeingId("account id");
- const std::string nick = msg.readString(24, "nick");
- const int reason = msg.readUInt8("flag");
- if (localPlayer == nullptr)
- return;
-
- if (id == localPlayer->getId())
- {
- switch (reason)
- {
- case 0:
- default:
- NotifyManager::notify(NotifyTypes::PARTY_LEFT);
- break;
-
- case 1:
- NotifyManager::notify(NotifyTypes::PARTY_KICKED);
- break;
-
- case 2:
- NotifyManager::notify(NotifyTypes::PARTY_LEFT_DENY);
- break;
-
- case 3:
- NotifyManager::notify(NotifyTypes::PARTY_KICK_DENY);
- break;
- }
-
- if (reason >= 2)
- return;
-
- if (Ea::taParty != nullptr)
- {
- Ea::taParty->removeFromMembers();
- Ea::taParty->clearMembers();
- }
-
- delete2(partyTab)
-
- if ((socialWindow != nullptr) && (Ea::taParty != nullptr))
- socialWindow->removeTab(Ea::taParty);
- localPlayer->setPartyName("");
- }
- else
- {
- switch (reason)
- {
- case 0:
- default:
- NotifyManager::notify(NotifyTypes::PARTY_USER_LEFT, nick);
- break;
-
- case 1:
- NotifyManager::notify(NotifyTypes::PARTY_USER_KICKED, nick);
- break;
-
- case 2:
- NotifyManager::notify(NotifyTypes::PARTY_USER_LEFT_DENY, nick);
- break;
-
- case 3:
- NotifyManager::notify(NotifyTypes::PARTY_USER_KICK_DENY, nick);
- break;
- }
-
- if (reason >= 2)
- return;
-
- if (actorManager != nullptr)
- {
- Being *const b = actorManager->findBeing(id);
- if ((b != nullptr) && b->getType() == ActorType::Player)
- {
- b->setParty(nullptr);
- b->setPartyName("");
- }
- }
- if (Ea::taParty != nullptr)
- Ea::taParty->removeMember(id);
- }
-}
-
-void PartyRecv::processPartyUpdateCoords(Net::MessageIn &msg)
-{
- const BeingId id = msg.readBeingId("account id");
- PartyMember *m = nullptr;
- if (Ea::taParty != nullptr)
- m = Ea::taParty->getMember(id);
- if (m != nullptr)
- {
- m->setX(msg.readInt16("x"));
- m->setY(msg.readInt16("y"));
- }
- else
- {
- msg.readInt16("x");
- msg.readInt16("y");
- }
-}
-
-void PartyRecv::createTab()
-{
- partyTab = new PartyTab(chatWindow);
- if (config.getBoolValue("showChatHistory"))
- partyTab->loadFromLogFile("#Party");
-}
-
-} // namespace Ea
diff --git a/src/net/ea/partyrecv.h b/src/net/ea/partyrecv.h
deleted file mode 100644
index 07629567d..000000000
--- a/src/net/ea/partyrecv.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 Lloyd Bryant <lloyd_bryant@netzero.net>
- * 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 NET_EA_PARTYRECV_H
-#define NET_EA_PARTYRECV_H
-
-#include "enums/net/partyshare.h"
-
-class Party;
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-namespace Ea
-{
- namespace PartyRecv
- {
- extern PartyShareT mShareExp;
- extern PartyShareT mShareItems;
-
- void processPartyCreate(Net::MessageIn &msg);
- void processPartyLeave(Net::MessageIn &msg);
- void processPartyUpdateCoords(Net::MessageIn &msg);
- void processPartyExpSettingsContinue(Net::MessageIn &msg,
- const PartyShareT exp);
- void processPartyItemSettingsContinue(Net::MessageIn &msg,
- const PartyShareT item);
-
- void createTab();
- } // namespace PartyRecv
- extern Party *taParty;
-} // namespace Ea
-
-#endif // NET_EA_PARTYRECV_H
diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp
deleted file mode 100644
index 3300c5c8d..000000000
--- a/src/net/ea/playerhandler.cpp
+++ /dev/null
@@ -1,55 +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 "net/ea/playerhandler.h"
-
-#include "being/playerinfo.h"
-
-#include "debug.h"
-
-namespace Ea
-{
-
-PlayerHandler::PlayerHandler()
-{
-}
-
-void PlayerHandler::ignorePlayer(const std::string &player A_UNUSED,
- const bool ignore A_UNUSED) const
-{
-}
-
-void PlayerHandler::ignoreAll(const bool ignore A_UNUSED) const
-{
-}
-
-int PlayerHandler::getDefaultWalkSpeed() const
-{
- return 150;
-}
-
-bool PlayerHandler::canUseMagic() const
-{
- return PlayerInfo::getStatEffective(Attributes::PLAYER_MATK) > 0;
-}
-
-} // namespace Ea
diff --git a/src/net/ea/playerhandler.h b/src/net/ea/playerhandler.h
deleted file mode 100644
index d852d1086..000000000
--- a/src/net/ea/playerhandler.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 NET_EA_PLAYERHANDLER_H
-#define NET_EA_PLAYERHANDLER_H
-
-#include "net/playerhandler.h"
-
-namespace Ea
-{
-
-class PlayerHandler notfinal : public Net::PlayerHandler
-{
- public:
- PlayerHandler();
-
- A_DELETE_COPY(PlayerHandler)
-
- void ignorePlayer(const std::string &player,
- const bool ignore) const override final A_CONST;
-
- void ignoreAll(const bool ignore) const override final A_CONST;
-
- bool canUseMagic() const override final;
-
- int getDefaultWalkSpeed() const override final A_WARN_UNUSED;
-};
-
-} // namespace Ea
-
-#endif // NET_EA_PLAYERHANDLER_H
diff --git a/src/net/ea/playerrecv.cpp b/src/net/ea/playerrecv.cpp
deleted file mode 100644
index edc604907..000000000
--- a/src/net/ea/playerrecv.cpp
+++ /dev/null
@@ -1,266 +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 "net/ea/playerrecv.h"
-
-#include "game.h"
-#include "notifymanager.h"
-#include "settings.h"
-#include "soundmanager.h"
-
-#include "being/localplayer.h"
-#include "being/playerinfo.h"
-
-#include "const/net/nostat.h"
-
-#include "enums/resources/notifytypes.h"
-
-#include "gui/viewport.h"
-
-#include "gui/windows/statuswindow.h"
-
-#include "input/inputmanager.h"
-
-#include "resources/map/map.h"
-
-#include "net/playerhandler.h"
-
-#include "utils/stdmove.h"
-#include "utils/stringutils.h"
-
-#include "debug.h"
-
-// Max. distance we are willing to scroll after a teleport;
-// everything beyond will reset the port hard.
-static const int MAP_TELEPORT_SCROLL_DISTANCE = 8;
-
-namespace Ea
-{
-
-void PlayerRecv::processPlayerWarp(Net::MessageIn &msg)
-{
- BLOCK_START("PlayerRecv::processPlayerWarp")
- std::string mapPath = msg.readString(16, "map name");
- int x = msg.readInt16("x");
- int y = msg.readInt16("y");
-
- logger->log("Warping to %s (%d, %d)", mapPath.c_str(), x, y);
-
- if (localPlayer == nullptr)
- logger->log1("SMSG_PLAYER_WARP localPlayer null");
-
- /*
- * We must clear the local player's target *before* the call
- * to changeMap, as it deletes all beings.
- */
- if (localPlayer != nullptr)
- localPlayer->stopAttack();
-
- Game *const game = Game::instance();
- if (game == nullptr)
- {
- BLOCK_END("PlayerRecv::processPlayerWarp")
- return;
- }
-
- const std::string &currentMapName = game->getCurrentMapName();
- const bool sameMap = (currentMapName == mapPath);
-
- // Switch the actual map, deleting the previous one if necessary
- mapPath = mapPath.substr(0, mapPath.rfind('.'));
- game->changeMap(mapPath);
-
- int scrollOffsetX = 0;
- int scrollOffsetY = 0;
-
- if (localPlayer != nullptr)
- {
- const Map *const map = game->getCurrentMap();
- if (map != nullptr)
- {
- if (x >= map->getWidth())
- x = map->getWidth() - 1;
- if (y >= map->getHeight())
- y = map->getHeight() - 1;
- if (x < 0)
- x = 0;
- if (y < 0)
- y = 0;
- /* Scroll if neccessary */
- if (!sameMap
- || (abs(x - localPlayer->getTileX())
- > MAP_TELEPORT_SCROLL_DISTANCE)
- || (abs(y - localPlayer->getTileY())
- > MAP_TELEPORT_SCROLL_DISTANCE))
- {
- scrollOffsetX = (x - localPlayer->getTileX())
- * map->getTileWidth();
- scrollOffsetY = (y - localPlayer->getTileY())
- * map->getTileHeight();
- }
- }
-
- localPlayer->setAction(BeingAction::STAND, 0);
- localPlayer->setTileCoords(x, y);
- localPlayer->navigateClean();
- localPlayer->reset();
- }
-
- logger->log("Adjust scrolling by %d:%d", scrollOffsetX, scrollOffsetY);
-
- if (viewport != nullptr)
- {
- viewport->returnCamera();
- viewport->scrollBy(scrollOffsetX, scrollOffsetY);
- }
- BLOCK_END("PlayerRecv::processPlayerWarp")
-}
-
-void PlayerRecv::processPlayerStatUpdate1(Net::MessageIn &msg)
-{
- BLOCK_START("PlayerRecv::processPlayerStatUpdate1")
- const int type = msg.readInt16("type");
- const int value = msg.readInt32("value");
- if (localPlayer == nullptr)
- {
- BLOCK_END("PlayerRecv::processPlayerStatUpdate1")
- return;
- }
-
- playerHandler->setStat(msg, type, value, NoStat, Notify_true);
- BLOCK_END("PlayerRecv::processPlayerStatUpdate1")
-}
-
-void PlayerRecv::processPlayerStatUpdate2(Net::MessageIn &msg)
-{
- BLOCK_START("PlayerRecv::processPlayerStatUpdate2")
- const int type = msg.readInt16("type");
- const int value = msg.readInt32("value");
- playerHandler->setStat(msg, type, value, NoStat, Notify_true);
- BLOCK_END("PlayerRecv::processPlayerStatUpdate2")
-}
-
-void PlayerRecv::processPlayerStatUpdate3(Net::MessageIn &msg)
-{
- BLOCK_START("PlayerRecv::processPlayerStatUpdate3")
- const int type = msg.readInt32("type");
- const int base = msg.readInt32("base");
- const int bonus = msg.readInt32("bonus");
-
- playerHandler->setStat(msg, type, base, bonus, Notify_false);
- BLOCK_END("PlayerRecv::processPlayerStatUpdate3")
-}
-
-void PlayerRecv::processPlayerStatUpdate4(Net::MessageIn &msg)
-{
- BLOCK_START("PlayerRecv::processPlayerStatUpdate4")
- const uint16_t type = msg.readInt16("type");
- const uint8_t ok = msg.readUInt8("flag");
- const int value = msg.readUInt8("value");
-
- if (ok != 1)
- {
- const int oldValue = PlayerInfo::getStatBase(
- static_cast<AttributesT>(type));
- const int points = PlayerInfo::getAttribute(
- Attributes::PLAYER_CHAR_POINTS) + oldValue - value;
- PlayerInfo::setAttribute(Attributes::PLAYER_CHAR_POINTS, points);
- NotifyManager::notify(NotifyTypes::SKILL_RAISE_ERROR);
- }
-
- playerHandler->setStat(msg, type, value, NoStat, Notify_true);
- BLOCK_END("PlayerRecv::processPlayerStatUpdate4")
-}
-
-void PlayerRecv::processPlayerStatUpdate6(Net::MessageIn &msg)
-{
- BLOCK_START("PlayerRecv::processPlayerStatUpdate6")
- const int type = msg.readInt16("type");
- const int value = msg.readUInt8("value");
- if (statusWindow != nullptr)
- playerHandler->setStat(msg, type, value, NoStat, Notify_true);
- BLOCK_END("PlayerRecv::processPlayerStatUpdate6")
-}
-
-void PlayerRecv::processPlayerArrowMessage(Net::MessageIn &msg)
-{
- BLOCK_START("PlayerRecv::processPlayerArrowMessage")
- const int type = msg.readInt16("type");
- switch (type)
- {
- case 0:
- NotifyManager::notify(NotifyTypes::ARROWS_EQUIP_NEEDED);
- break;
- case 3:
- // arrows equiped
- break;
- default:
- UNIMPLEMENTEDPACKETFIELD(type);
- break;
- }
- BLOCK_END("PlayerRecv::processPlayerArrowMessage")
-}
-
-void PlayerRecv::processMapMusic(Net::MessageIn &msg)
-{
- const int size = msg.readInt16("len") - 4;
- const std::string music = msg.readString(size, "name");
- soundManager.playMusic(music,
- SkipError_false);
-
- Map *const map = viewport->getMap();
- if (map != nullptr)
- map->setMusicFile(music);
-}
-
-void PlayerRecv::processMapMask(Net::MessageIn &msg)
-{
- const int mask = msg.readInt32("mask");
- msg.readInt32("unused");
- Map *const map = Game::instance()->getCurrentMap();
- if (map != nullptr)
- map->setMask(mask);
-}
-
-void PlayerRecv::processPlayerClientCommand(Net::MessageIn &msg)
-{
- const int sz = msg.readInt16("len") - 4;
- std::string command = msg.readString(sz, "command");
- std::string cmd;
- std::string args;
-
- if (settings.awayMode ||
- settings.pseudoAwayMode ||
- !settings.enableRemoteCommands)
- {
- return;
- }
-
- if (!parse2Str(command, cmd, args))
- {
- cmd = STD_MOVE(command);
- args.clear();
- }
- inputManager.executeRemoteChatCommand(cmd, args, nullptr);
-}
-
-} // namespace Ea
diff --git a/src/net/ea/playerrecv.h b/src/net/ea/playerrecv.h
deleted file mode 100644
index 8c0913b09..000000000
--- a/src/net/ea/playerrecv.h
+++ /dev/null
@@ -1,48 +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 NET_EA_PLAYERRECV_H
-#define NET_EA_PLAYERRECV_H
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-namespace Ea
-{
- namespace PlayerRecv
- {
- void processPlayerWarp(Net::MessageIn &msg);
- void processPlayerStatUpdate1(Net::MessageIn &msg);
- void processPlayerStatUpdate2(Net::MessageIn &msg);
- void processPlayerStatUpdate3(Net::MessageIn &msg);
- void processPlayerStatUpdate4(Net::MessageIn &msg);
- void processPlayerStatUpdate6(Net::MessageIn &msg);
- void processPlayerArrowMessage(Net::MessageIn &msg);
- void processPlayerClientCommand(Net::MessageIn &msg);
- void processMapMusic(Net::MessageIn &msg);
- void processMapMask(Net::MessageIn &msg);
- } // namespace PlayerRecv
-} // namespace Ea
-
-#endif // NET_EA_PLAYERRECV_H
diff --git a/src/net/ea/skillhandler.cpp b/src/net/ea/skillhandler.cpp
deleted file mode 100644
index e44bc5609..000000000
--- a/src/net/ea/skillhandler.cpp
+++ /dev/null
@@ -1,34 +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 "net/ea/skillhandler.h"
-
-#include "debug.h"
-
-namespace Ea
-{
-
-SkillHandler::SkillHandler()
-{
-}
-
-} // namespace Ea
diff --git a/src/net/ea/skillhandler.h b/src/net/ea/skillhandler.h
deleted file mode 100644
index acda5e7ad..000000000
--- a/src/net/ea/skillhandler.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 NET_EA_SKILLHANDLER_H
-#define NET_EA_SKILLHANDLER_H
-
-#include "net/skillhandler.h"
-
-#include "localconsts.h"
-
-namespace Ea
-{
-
-class SkillHandler notfinal : public Net::SkillHandler
-{
- public:
- SkillHandler();
-
- A_DELETE_COPY(SkillHandler)
-};
-
-} // namespace Ea
-
-#endif // NET_EA_SKILLHANDLER_H
diff --git a/src/net/ea/skillrecv.cpp b/src/net/ea/skillrecv.cpp
deleted file mode 100644
index 58a083478..000000000
--- a/src/net/ea/skillrecv.cpp
+++ /dev/null
@@ -1,59 +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 "net/ea/skillrecv.h"
-
-#include "being/playerinfo.h"
-
-#include "gui/windows/skilldialog.h"
-
-#include "net/messagein.h"
-
-#include "debug.h"
-
-namespace Ea
-{
-
-void SkillRecv::processPlayerSkillUp(Net::MessageIn &msg)
-{
- const int skillId = msg.readInt16("skill id");
- const int level = msg.readInt16("skill level");
- const int sp = msg.readInt16("sp");
- const int range = msg.readInt16("range");
- const Modifiable up = fromBool(msg.readUInt8("up flag"), Modifiable);
-
- if (skillDialog != nullptr && PlayerInfo::getSkillLevel(skillId) != level)
- skillDialog->playUpdateEffect(skillId);
- PlayerInfo::setSkillLevel(skillId, level);
- if (skillDialog != nullptr)
- {
- if (!skillDialog->updateSkill(skillId, range,
- up, SkillType::Unknown, sp))
- {
- skillDialog->addSkill(SkillOwner::Player,
- skillId, "", level,
- range, up, SkillType::Unknown, sp);
- }
- }
-}
-
-} // namespace Ea
diff --git a/src/net/ea/skillrecv.h b/src/net/ea/skillrecv.h
deleted file mode 100644
index de4fe1112..000000000
--- a/src/net/ea/skillrecv.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 NET_EA_SKILLRECV_H
-#define NET_EA_SKILLRECV_H
-
-#include "localconsts.h"
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-namespace Ea
-{
- namespace SkillRecv
- {
- void processPlayerSkillUp(Net::MessageIn &msg);
- } // namespace SkillRecv
-} // namespace Ea
-
-#endif // NET_EA_SKILLRECV_H
diff --git a/src/net/ea/token.h b/src/net/ea/token.h
deleted file mode 100644
index 1e8f72c8d..000000000
--- a/src/net/ea/token.h
+++ /dev/null
@@ -1,54 +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 NET_EA_TOKEN_H
-#define NET_EA_TOKEN_H
-
-#include "enums/simpletypes/beingid.h"
-#include "enums/being/gender.h"
-
-struct Token final
-{
- Token() :
- account_ID(BeingId_zero),
- session_ID1(0),
- session_ID2(0),
- sex(Gender::UNSPECIFIED)
- { }
-
- A_DELETE_COPY(Token)
-
- BeingId account_ID;
- int session_ID1;
- int session_ID2;
- GenderT sex;
-
- void clear()
- {
- account_ID = BeingId_zero;
- session_ID1 = 0;
- session_ID2 = 0;
- sex = Gender::UNSPECIFIED;
- }
-};
-
-#endif // NET_EA_TOKEN_H
diff --git a/src/net/ea/tradehandler.cpp b/src/net/ea/tradehandler.cpp
deleted file mode 100644
index a56136b3d..000000000
--- a/src/net/ea/tradehandler.cpp
+++ /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/>.
- */
-
-#include "net/ea/tradehandler.h"
-
-#include "listeners/requesttradelistener.h"
-
-#include "debug.h"
-
-/**
- * Listener for request trade dialogs
- */
-namespace
-{
- RequestTradeListener listener;
-} // namespace
-
-namespace Ea
-{
-
-TradeHandler::TradeHandler() :
- Net::TradeHandler()
-{
- confirmDlg = nullptr;
-}
-
-void TradeHandler::removeItem(const int slotNum A_UNUSED,
- const int amount A_UNUSED) const
-{
-}
-
-} // namespace Ea
diff --git a/src/net/ea/tradehandler.h b/src/net/ea/tradehandler.h
deleted file mode 100644
index 0a350bd46..000000000
--- a/src/net/ea/tradehandler.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 NET_EA_TRADEHANDLER_H
-#define NET_EA_TRADEHANDLER_H
-
-#include "net/tradehandler.h"
-
-namespace Ea
-{
-
-class TradeHandler notfinal : public Net::TradeHandler
-{
- public:
- TradeHandler();
-
- A_DELETE_COPY(TradeHandler)
-
- void removeItem(const int slotNum,
- const int amount) const override final A_CONST;
-};
-
-} // namespace Ea
-
-#endif // NET_EA_TRADEHANDLER_H
diff --git a/src/net/ea/traderecv.cpp b/src/net/ea/traderecv.cpp
deleted file mode 100644
index d47fc256b..000000000
--- a/src/net/ea/traderecv.cpp
+++ /dev/null
@@ -1,184 +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 "net/ea/traderecv.h"
-
-#include "notifymanager.h"
-
-#include "being/playerinfo.h"
-#include "being/playerrelation.h"
-
-#include "enums/resources/notifytypes.h"
-
-#include "gui/windows/tradewindow.h"
-
-#include "gui/widgets/createwidget.h"
-
-#include "net/messagein.h"
-
-#include "utils/gettext.h"
-#include "utils/stringutils.h"
-
-#include "listeners/requesttradelistener.h"
-
-#include "debug.h"
-
-
-ConfirmDialog *confirmDlg = nullptr;
-
-/**
- * Listener for request trade dialogs
- */
-namespace
-{
- RequestTradeListener listener;
-} // namespace
-
-namespace Ea
-{
-
-void TradeRecv::processTradeResponseContinue(const uint8_t type)
-{
- switch (type)
- {
- case 0: // Too far away
- NotifyManager::notify(NotifyTypes::TRADE_FAIL_FAR_AWAY,
- tradePartnerName);
- break;
- case 1: // Character doesn't exist
- NotifyManager::notify(NotifyTypes::TRADE_FAIL_CHAR_NOT_EXISTS,
- tradePartnerName);
- break;
- case 2: // Invite request check failed...
- NotifyManager::notify(NotifyTypes::TRADE_CANCELLED_ERROR);
- break;
- case 3: // Trade accepted
- if (tradeWindow != nullptr)
- {
- tradeWindow->reset();
- // TRANSLATORS: trade header
- tradeWindow->setCaption(strprintf(_("Trade: You and %s"),
- tradePartnerName.c_str()));
- tradeWindow->initTrade(tradePartnerName);
- tradeWindow->setVisible(Visible_true);
- }
- break;
- case 4: // Trade cancelled
- if (playerRelations.hasPermission(tradePartnerName,
- PlayerRelation::SPEECH_LOG))
- {
- NotifyManager::notify(NotifyTypes::TRADE_CANCELLED_NAME,
- tradePartnerName);
- }
- // otherwise ignore silently
-
- if (tradeWindow != nullptr)
- {
- tradeWindow->setVisible(Visible_false);
-// tradeWindow->clear();
- }
- PlayerInfo::setTrading(Trading_false);
- break;
- case 5:
- NotifyManager::notify(NotifyTypes::TRADE_CANCELLED_BUSY,
- tradePartnerName);
- break;
- default: // Shouldn't happen as well, but to be sure
- NotifyManager::notify(NotifyTypes::TRADE_ERROR_UNKNOWN,
- tradePartnerName);
- if (tradeWindow != nullptr)
- tradeWindow->clear();
- break;
- }
-}
-
-void TradeRecv::processTradeOk(Net::MessageIn &msg)
-{
- // 0 means ok from myself, 1 means ok from other;
- if (tradeWindow != nullptr)
- tradeWindow->receivedOk(msg.readUInt8("status") == 0U);
- else
- msg.readUInt8("status");
-}
-
-void TradeRecv::processTradeCancel(Net::MessageIn &msg A_UNUSED)
-{
- NotifyManager::notify(NotifyTypes::TRADE_CANCELLED);
- if (tradeWindow != nullptr)
- {
- tradeWindow->setVisible(Visible_false);
- tradeWindow->reset();
- }
- PlayerInfo::setTrading(Trading_false);
-}
-
-void TradeRecv::processTradeComplete(Net::MessageIn &msg A_UNUSED)
-{
- NotifyManager::notify(NotifyTypes::TRADE_COMPLETE);
- if (tradeWindow != nullptr)
- tradeWindow->completeTrade();
- PlayerInfo::setTrading(Trading_false);
-}
-
-void TradeRecv::processTradeRequestContinue(const std::string &partner)
-{
- if (playerRelations.hasPermission(partner,
- PlayerRelation::TRADE))
- {
- if (PlayerInfo::isTrading() == Trading_true || (confirmDlg != nullptr))
- {
- tradeHandler->respond(false);
- return;
- }
-
- tradePartnerName = partner;
- PlayerInfo::setTrading(Trading_true);
- if (tradeWindow != nullptr)
- {
- if (tradePartnerName.empty() || tradeWindow->getAutoTradeNick()
- != tradePartnerName)
- {
- tradeWindow->clear();
- CREATEWIDGETV(confirmDlg, ConfirmDialog,
- // TRANSLATORS: trade message
- _("Request for Trade"),
- // TRANSLATORS: trade message
- strprintf(_("%s wants to trade with you, do"
- " you accept?"), tradePartnerName.c_str()),
- SOUND_REQUEST,
- true);
- confirmDlg->addActionListener(&listener);
- }
- else
- {
- tradeHandler->respond(true);
- }
- }
- }
- else
- {
- tradeHandler->respond(false);
- return;
- }
-}
-
-} // namespace Ea
diff --git a/src/net/ea/traderecv.h b/src/net/ea/traderecv.h
deleted file mode 100644
index ce8176bf3..000000000
--- a/src/net/ea/traderecv.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 NET_EA_TRADERECV_H
-#define NET_EA_TRADERECV_H
-
-#if defined(__GXX_EXPERIMENTAL_CXX0X__)
-#if defined(__APPLE__)
-#include <tr1/cstdint>
-#endif // defined(__APPLE__)
-#else // defined(__GXX_EXPERIMENTAL_CXX0X__)
-#include <stdint.h>
-#endif // defined(__GXX_EXPERIMENTAL_CXX0X__)
-
-#include <string>
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-namespace Ea
-{
- namespace TradeRecv
- {
- void processTradeOk(Net::MessageIn &msg);
- void processTradeCancel(Net::MessageIn &msg);
- void processTradeComplete(Net::MessageIn &msg);
- void processTradeRequestContinue(const std::string &partner);
- void processTradeResponseContinue(const uint8_t type);
- } // namespace TradeRecv
-} // namespace Ea
-
-#endif // NET_EA_TRADERECV_H
diff --git a/src/net/eathena/adminhandler.cpp b/src/net/eathena/adminhandler.cpp
deleted file mode 100644
index 45cfb9ed5..000000000
--- a/src/net/eathena/adminhandler.cpp
+++ /dev/null
@@ -1,379 +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 "net/eathena/adminhandler.h"
-
-#include "being/being.h"
-
-#include "net/eathena/messageout.h"
-#include "net/eathena/protocolout.h"
-
-#include "utils/gmfunctions.h"
-#include "utils/stringutils.h"
-
-#include "debug.h"
-
-namespace EAthena
-{
-
-std::string AdminHandler::mStatsName;
-
-AdminHandler::AdminHandler() :
- Ea::AdminHandler()
-{
- adminHandler = this;
-}
-
-AdminHandler::~AdminHandler()
-{
- adminHandler = nullptr;
-}
-
-void AdminHandler::announce(const std::string &text) const
-{
- createOutPacket(CMSG_ADMIN_ANNOUNCE);
- outMsg.writeInt16(CAST_S16(text.length() + 4), "len");
- outMsg.writeString(text, CAST_S32(text.length()), "message");
-}
-
-void AdminHandler::localAnnounce(const std::string &text) const
-{
- createOutPacket(CMSG_ADMIN_LOCAL_ANNOUNCE);
- outMsg.writeInt16(CAST_S16(text.length() + 4), "len");
- outMsg.writeString(text, CAST_S32(text.length()), "message");
-}
-
-void AdminHandler::hide(const bool h A_UNUSED) const
-{
- createOutPacket(CMSG_ADMIN_HIDE);
- outMsg.writeInt32(0, "unused");
-}
-
-void AdminHandler::kick(const BeingId playerId) const
-{
- createOutPacket(CMSG_ADMIN_KICK);
- outMsg.writeBeingId(playerId, "account id");
-}
-
-void AdminHandler::kickAll() const
-{
- createOutPacket(CMSG_ADMIN_KICK_ALL);
-}
-
-void AdminHandler::warp(const std::string &map, const int x, const int y) const
-{
- createOutPacket(CMSG_PLAYER_MAPMOVE);
- outMsg.writeString(map, 16, "map");
- outMsg.writeInt16(CAST_S16(x), "x");
- outMsg.writeInt16(CAST_S16(y), "y");
-}
-
-void AdminHandler::resetStats() const
-{
- createOutPacket(CMSG_ADMIN_RESET_PLAYER);
- outMsg.writeInt16(0, "flag");
-}
-
-void AdminHandler::resetSkills() const
-{
- createOutPacket(CMSG_ADMIN_RESET_PLAYER);
- outMsg.writeInt16(1, "flag");
-}
-
-void AdminHandler::gotoName(const std::string &name) const
-{
- createOutPacket(CMSG_ADMIN_GOTO);
- outMsg.writeString(name, 24, "name");
-}
-
-void AdminHandler::recallName(const std::string &name) const
-{
- createOutPacket(CMSG_ADMIN_RECALL);
- outMsg.writeString(name, 24, "name");
-}
-
-void AdminHandler::mute(const Being *const being,
- const int type,
- const int limit) const
-{
- if (being == nullptr)
- return;
-
- createOutPacket(CMSG_ADMIN_MUTE);
- outMsg.writeBeingId(being->getId(), "account id");
- outMsg.writeInt8(CAST_S8(type), "type");
- outMsg.writeInt16(CAST_S16(limit), "value");
-}
-
-void AdminHandler::muteName(const std::string &name) const
-{
- createOutPacket(CMSG_ADMIN_MUTE_NAME);
- outMsg.writeString(name, 24, "name");
-}
-
-void AdminHandler::requestLogin(const Being *const being) const
-{
- if (being == nullptr)
- return;
-
- createOutPacket(CMSG_ADMIN_ID_TO_LOGIN);
- outMsg.writeBeingId(being->getId(), "account id");
-}
-
-void AdminHandler::setTileType(const int x, const int y,
- const int type) const
-{
- createOutPacket(CMSG_ADMIN_SET_TILE_TYPE);
- outMsg.writeInt16(CAST_S16(x), "x");
- outMsg.writeInt16(CAST_S16(y), "y");
- outMsg.writeInt16(CAST_S16(type), "type");
-}
-
-void AdminHandler::unequipAll(const Being *const being) const
-{
- if (being == nullptr)
- return;
-
- createOutPacket(CMSG_ADMIN_UNEQUIP_ALL);
- outMsg.writeBeingId(being->getId(), "account id");
-}
-
-void AdminHandler::requestStats(const std::string &name) const
-{
- mStatsName = name;
- createOutPacket(CMSG_ADMIN_REQUEST_STATS);
- outMsg.writeString(name, 24, "name");
-}
-
-void AdminHandler::monsterInfo(const std::string &name) const
-{
- Gm::runCommand("monsterinfo", name);
-}
-
-void AdminHandler::itemInfo(const std::string &name) const
-{
- Gm::runCommand("iteminfo", name);
-}
-
-void AdminHandler::whoDrops(const std::string &name) const
-{
- Gm::runCommand("whodrops", name);
-}
-
-void AdminHandler::mobSearch(const std::string &name) const
-{
- Gm::runCommand("mobsearch", name);
-}
-
-void AdminHandler::mobSpawnSearch(const std::string &name) const
-{
- Gm::runCommand("whereis", name);
-}
-
-void AdminHandler::playerGmCommands(const std::string &name) const
-{
- Gm::runCharCommand("commands", name);
-}
-
-void AdminHandler::playerCharGmCommands(const std::string &name) const
-{
- Gm::runCharCommand("charcommands", name);
-}
-
-void AdminHandler::showLevel(const std::string &name) const
-{
- Gm::runCharCommand("exp", name);
-}
-
-void AdminHandler::showStats(const std::string &name) const
-{
- Gm::runCharCommand("stats", name);
-}
-
-void AdminHandler::showStorageList(const std::string &name) const
-{
- Gm::runCharCommand("storagelist", name);
-}
-
-void AdminHandler::showCartList(const std::string &name) const
-{
- Gm::runCharCommand("cartlist", name);
-}
-
-void AdminHandler::showInventoryList(const std::string &name) const
-{
- Gm::runCharCommand("itemlist", name);
-}
-
-void AdminHandler::locatePlayer(const std::string &name) const
-{
- Gm::runCommand("where", name);
-}
-
-void AdminHandler::showAccountInfo(const std::string &name) const
-{
- Gm::runCommand("accinfo", name);
-}
-
-void AdminHandler::spawnSlave(const std::string &name) const
-{
- Gm::runCommand("summon", name);
-}
-
-void AdminHandler::spawnClone(const std::string &name) const
-{
- Gm::runCommand("clone", name);
-}
-
-void AdminHandler::spawnSlaveClone(const std::string &name) const
-{
- Gm::runCommand("slaveclone", name);
-}
-
-void AdminHandler::spawnEvilClone(const std::string &name) const
-{
- Gm::runCommand("evilclone", name);
-}
-
-void AdminHandler::savePosition(const std::string &name) const
-{
- Gm::runCharCommand("save", name);
-}
-
-void AdminHandler::loadPosition(const std::string &name) const
-{
- Gm::runCharCommand("load", name);
-}
-
-void AdminHandler::randomWarp(const std::string &name) const
-{
- Gm::runCharCommand("jump", name);
-}
-
-void AdminHandler::gotoNpc(const std::string &name) const
-{
- Gm::runCommand("tonpc", name);
-}
-
-void AdminHandler::killer(const std::string &name) const
-{
- Gm::runCharCommand("killer", name);
-}
-
-void AdminHandler::killable(const std::string &name) const
-{
- Gm::runCharCommand("killable", name);
-}
-
-void AdminHandler::heal(const std::string &name) const
-{
- Gm::runCharCommand("heal", name);
-}
-
-void AdminHandler::alive(const std::string &name) const
-{
- Gm::runCharCommand("alive", name);
-}
-
-void AdminHandler::disguise(const std::string &name) const
-{
- Gm::runCommand("disguise", name);
-}
-
-void AdminHandler::immortal(const std::string &name) const
-{
- Gm::runCharCommand("monsterignore", name);
-}
-
-void AdminHandler::hide(const std::string &name) const
-{
- Gm::runCharCommand("hide", name);
-}
-
-void AdminHandler::nuke(const std::string &name) const
-{
- Gm::runCommand("nuke", name);
-}
-
-void AdminHandler::kill(const std::string &name) const
-{
- Gm::runCharCommand("kill", name);
-}
-
-void AdminHandler::jail(const std::string &name) const
-{
- Gm::runCommand("jail", name);
-}
-
-void AdminHandler::unjail(const std::string &name) const
-{
- Gm::runCommand("unjail", name);
-}
-
-void AdminHandler::npcMove(const std::string &name,
- const int x,
- const int y) const
-{
- Gm::runCommand("npcmove",
- strprintf("%d %d %s",
- x,
- y,
- name.c_str()));
-}
-
-void AdminHandler::hideNpc(const std::string &name) const
-{
- Gm::runCommand("hidenpc", name);
-}
-
-void AdminHandler::showNpc(const std::string &name) const
-{
- Gm::runCommand("shownpc", name);
-}
-
-void AdminHandler::changePartyLeader(const std::string &name) const
-{
- Gm::runCommand("changeleader", name);
-}
-
-void AdminHandler::partyRecall(const std::string &name) const
-{
- Gm::runCommand("partyrecall", name);
-}
-
-void AdminHandler::breakGuild(const std::string &name) const
-{
- Gm::runCharCommand("breakguild", name);
-}
-
-void AdminHandler::guildRecall(const std::string &name) const
-{
- Gm::runCommand("guildrecall", name);
-}
-
-void AdminHandler::slide(const int x, const int y) const
-{
- Gm::runCommand("slide",
- strprintf("%d %d", x, y));
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/adminhandler.h b/src/net/eathena/adminhandler.h
deleted file mode 100644
index 2cee9a354..000000000
--- a/src/net/eathena/adminhandler.h
+++ /dev/null
@@ -1,167 +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 NET_EATHENA_ADMINHANDLER_H
-#define NET_EATHENA_ADMINHANDLER_H
-
-#include "net/ea/adminhandler.h"
-
-namespace EAthena
-{
-
-class AdminHandler final : public Ea::AdminHandler
-{
- public:
- AdminHandler();
-
- A_DELETE_COPY(AdminHandler)
-
- ~AdminHandler();
-
- void announce(const std::string &text) const override final;
-
- void localAnnounce(const std::string &text) const override final;
-
- void hide(const bool h) const override final;
-
- void kick(const BeingId playerId) const override final;
-
- void kickAll() const override final;
-
- void warp(const std::string &map,
- const int x, const int y) const override final;
-
- void resetStats() const override final;
-
- void resetSkills() const override final;
-
- void gotoName(const std::string &name) const override final;
-
- void recallName(const std::string &name) const override final;
-
- void mute(const Being *const being,
- const int type,
- const int limit) const override final;
-
- void muteName(const std::string &name) const override final;
-
- void requestLogin(const Being *const being) const override final;
-
- void setTileType(const int x, const int y,
- const int type) const override final;
-
- void unequipAll(const Being *const being) const override final;
-
- void requestStats(const std::string &name) const override final;
-
- void monsterInfo(const std::string &name) const override final;
-
- void itemInfo(const std::string &name) const override final;
-
- void whoDrops(const std::string &name) const override final;
-
- void mobSearch(const std::string &name) const override final;
-
- void mobSpawnSearch(const std::string &name) const override final;
-
- void playerGmCommands(const std::string &name) const override final;
-
- void playerCharGmCommands(const std::string &name) const
- override final;
-
- void showLevel(const std::string &name) const override final;
-
- void showStats(const std::string &name) const override final;
-
- void showStorageList(const std::string &name) const override final;
-
- void showCartList(const std::string &name) const override final;
-
- void showInventoryList(const std::string &name) const override final;
-
- void locatePlayer(const std::string &name) const override final;
-
- void showAccountInfo(const std::string &name) const override final;
-
- void spawnSlave(const std::string &name) const override final;
-
- void spawnClone(const std::string &name) const override final;
-
- void spawnSlaveClone(const std::string &name) const override final;
-
- void spawnEvilClone(const std::string &name) const override final;
-
- void savePosition(const std::string &name) const override final;
-
- void loadPosition(const std::string &name) const override final;
-
- void randomWarp(const std::string &name) const override final;
-
- void gotoNpc(const std::string &name) const override final;
-
- void killer(const std::string &name) const override final;
-
- void killable(const std::string &name) const override final;
-
- void heal(const std::string &name) const override final;
-
- void alive(const std::string &name) const override final;
-
- void disguise(const std::string &name) const override final;
-
- void immortal(const std::string &name) const override final;
-
- void hide(const std::string &name) const override final;
-
- void nuke(const std::string &name) const override final;
-
- void kill(const std::string &name) const override final;
-
- void jail(const std::string &name) const override final;
-
- void unjail(const std::string &name) const override final;
-
- void npcMove(const std::string &name,
- const int x,
- const int y) const override final;
-
- void hideNpc(const std::string &name) const override final;
-
- void showNpc(const std::string &name) const override final;
-
- void changePartyLeader(const std::string &name) const override final;
-
- void partyRecall(const std::string &name) const override final;
-
- void breakGuild(const std::string &name) const override final;
-
- void guildRecall(const std::string &name) const override final;
-
- void slide(const int x, const int y) const override final;
-
- protected:
- static std::string mStatsName;
-};
-
-} // namespace EAthena
-
-#endif // NET_EATHENA_ADMINHANDLER_H
diff --git a/src/net/eathena/adminrecv.cpp b/src/net/eathena/adminrecv.cpp
deleted file mode 100644
index a49776ba4..000000000
--- a/src/net/eathena/adminrecv.cpp
+++ /dev/null
@@ -1,81 +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 "net/eathena/adminrecv.h"
-
-#include "logger.h"
-
-#include "net/messagein.h"
-
-#include "debug.h"
-
-namespace EAthena
-{
-
-void AdminRecv::processAdminGetLoginAck(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readBeingId("account id");
- msg.readString(24, "login");
-}
-
-void AdminRecv::processSetTileType(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- // +++ here need set collision tile for map
- msg.readInt16("x");
- msg.readInt16("y");
- msg.readInt16("type");
- msg.readString(16, "map name");
-}
-
-void AdminRecv::processAccountStats(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- // +++ need show in other players stats window, nick in mStatsName
- msg.readUInt8("str");
- msg.readUInt8("need str");
- msg.readUInt8("agi");
- msg.readUInt8("need agi");
- msg.readUInt8("vit");
- msg.readUInt8("need vit");
- msg.readUInt8("int");
- msg.readUInt8("need int");
- msg.readUInt8("dex");
- msg.readUInt8("need dex");
- msg.readUInt8("luk");
- msg.readUInt8("need luk");
- msg.readInt16("attack");
- msg.readInt16("refine");
- msg.readInt16("matk max");
- msg.readInt16("matk min");
- msg.readInt16("item def");
- msg.readInt16("plus def");
- msg.readInt16("mdef");
- msg.readInt16("plus mdef");
- msg.readInt16("hit");
- msg.readInt16("flee");
- msg.readInt16("flee2/10");
- msg.readInt16("cri/10");
- msg.readInt16("speed");
- msg.readInt16("zero");
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/adminrecv.h b/src/net/eathena/adminrecv.h
deleted file mode 100644
index 36453de0f..000000000
--- a/src/net/eathena/adminrecv.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 NET_EATHENA_ADMINRECV_H
-#define NET_EATHENA_ADMINRECV_H
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-namespace EAthena
-{
- namespace AdminRecv
- {
- void processAdminGetLoginAck(Net::MessageIn &msg);
- void processSetTileType(Net::MessageIn &msg);
- void processAccountStats(Net::MessageIn &msg);
- } // namespace AdminRecv
-} // namespace EAthena
-
-#endif // NET_EATHENA_ADMINRECV_H
diff --git a/src/net/eathena/auctionhandler.cpp b/src/net/eathena/auctionhandler.cpp
deleted file mode 100644
index 709e15138..000000000
--- a/src/net/eathena/auctionhandler.cpp
+++ /dev/null
@@ -1,116 +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 "net/eathena/auctionhandler.h"
-
-#include "const/net/inventory.h"
-
-#include "net/eathena/messageout.h"
-#include "net/eathena/protocolout.h"
-
-#include "resources/item/item.h"
-
-#include "debug.h"
-
-namespace EAthena
-{
-
-AuctionHandler::AuctionHandler()
-{
- auctionHandler = this;
-}
-
-AuctionHandler::~AuctionHandler()
-{
- auctionHandler = nullptr;
-}
-
-void AuctionHandler::cancelReg() const
-{
- createOutPacket(CMSG_AUCTION_CANCEL_REG);
- outMsg.writeInt16(0, "type"); // unused
-}
-
-void AuctionHandler::setItem(const Item *const item,
- const int amount) const
-{
- if (item == nullptr)
- return;
- createOutPacket(CMSG_AUCTION_SET_ITEM);
- outMsg.writeInt16(CAST_S16(
- item->getInvIndex() + INVENTORY_OFFSET), "index");
- outMsg.writeInt32(amount, "amount"); // always 1
-}
-
-void AuctionHandler::reg(const int currentPrice,
- const int maxPrice,
- const int hours) const
-{
- createOutPacket(CMSG_AUCTION_REGISTER);
- outMsg.writeInt32(currentPrice, "now money");
- outMsg.writeInt32(maxPrice, "max money");
- outMsg.writeInt32(hours, "delete hour");
-}
-
-void AuctionHandler::cancel(const int auctionId) const
-{
- createOutPacket(CMSG_AUCTION_CANCEL);
- outMsg.writeInt32(auctionId, "auction id");
-}
-
-void AuctionHandler::close(const int auctionId) const
-{
- createOutPacket(CMSG_AUCTION_CLOSE);
- outMsg.writeInt32(auctionId, "auction id");
-}
-
-void AuctionHandler::bid(const int auctionId,
- const int money) const
-{
- createOutPacket(CMSG_AUCTION_BID);
- outMsg.writeInt32(auctionId, "auction id");
- outMsg.writeInt32(money, "money");
-}
-
-void AuctionHandler::search(const AuctionSearchTypeT type,
- const int auctionId,
- const std::string &text,
- const int page) const
-{
- createOutPacket(CMSG_AUCTION_SEARCH);
- outMsg.writeInt16(CAST_S16(type), "search type");
- outMsg.writeInt32(auctionId, "auction id");
- outMsg.writeString(text, 24, "search text");
- outMsg.writeInt16(CAST_S16(page), "page");
-}
-
-void AuctionHandler::buy() const
-{
- createOutPacket(CMSG_AUCTION_BUY_SELL);
- outMsg.writeInt16(1, "buy/sell type");
-}
-
-void AuctionHandler::sell() const
-{
- createOutPacket(CMSG_AUCTION_BUY_SELL);
- outMsg.writeInt16(0, "buy/sell type");
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/auctionhandler.h b/src/net/eathena/auctionhandler.h
deleted file mode 100644
index 097f4ca3b..000000000
--- a/src/net/eathena/auctionhandler.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 NET_EATHENA_AUCTIONHANDLER_H
-#define NET_EATHENA_AUCTIONHANDLER_H
-
-#include "net/auctionhandler.h"
-
-namespace EAthena
-{
-class AuctionHandler final : public Net::AuctionHandler
-{
- public:
- AuctionHandler();
-
- A_DELETE_COPY(AuctionHandler)
-
- ~AuctionHandler();
-
- void cancelReg() const override final;
-
- void setItem(const Item *const item,
- const int amount) const override final;
-
- void reg(const int currentPrice,
- const int maxPrice,
- const int hours) const override final;
-
- void cancel(const int auctionId) const override final;
-
- void close(const int auctionId) const override final;
-
- void bid(const int auctionId,
- const int money) const override final;
-
- void search(const AuctionSearchTypeT type,
- const int auctionId,
- const std::string &text,
- const int page) const override final;
-
- void buy() const override final;
-
- void sell() const override final;
-};
-
-} // namespace EAthena
-
-#endif // NET_EATHENA_AUCTIONHANDLER_H
diff --git a/src/net/eathena/auctionrecv.cpp b/src/net/eathena/auctionrecv.cpp
deleted file mode 100644
index 5b51dc9a9..000000000
--- a/src/net/eathena/auctionrecv.cpp
+++ /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/>.
- */
-
-#include "net/eathena/auctionrecv.h"
-
-#include "logger.h"
-
-#include "const/resources/item/cards.h"
-
-#include "net/messagein.h"
-
-#include "debug.h"
-
-namespace EAthena
-{
-
-void AuctionRecv::processOpenWindow(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readInt32("flag"); // 0 - open, 1 - close
-}
-
-void AuctionRecv::processAuctionResults(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readInt16("len");
- msg.readInt32("pages");
- const int itemCount = msg.readInt32("items count");
- for (int f = 0; f < itemCount; f ++)
- {
- msg.readInt32("auction id");
- msg.readString(24, "seller name");
- msg.readInt32("item id");
- msg.readInt32("auction type");
- msg.readInt16("item amount"); // always 1
- msg.readUInt8("identify");
- msg.readUInt8("attribute");
- msg.readUInt8("refine");
- for (int d = 0; d < maxCards; d ++)
- msg.readUInt16("card");
- msg.readInt32("price");
- msg.readInt32("buy now");
- msg.readString(24, "buyer name");
- msg.readInt32("timestamp");
- // +++ need use ItemColorManager for color
- }
-}
-
-void AuctionRecv::processAuctionSetItem(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readInt16("index");
- msg.readUInt8("flag");
-}
-
-void AuctionRecv::processAuctionMessage(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readUInt8("message");
-}
-
-void AuctionRecv::processAuctionClose(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readInt16("flag");
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/auctionrecv.h b/src/net/eathena/auctionrecv.h
deleted file mode 100644
index 25e91a848..000000000
--- a/src/net/eathena/auctionrecv.h
+++ /dev/null
@@ -1,41 +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 NET_EATHENA_AUCTIONRECV_H
-#define NET_EATHENA_AUCTIONRECV_H
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-namespace EAthena
-{
- namespace AuctionRecv
- {
- void processOpenWindow(Net::MessageIn &msg);
- void processAuctionResults(Net::MessageIn &msg);
- void processAuctionSetItem(Net::MessageIn &msg);
- void processAuctionMessage(Net::MessageIn &msg);
- void processAuctionClose(Net::MessageIn &msg);
- } // namespace AuctionRecv
-} // namespace EAthena
-
-#endif // NET_EATHENA_AUCTIONRECV_H
diff --git a/src/net/eathena/bankhandler.cpp b/src/net/eathena/bankhandler.cpp
deleted file mode 100644
index 19d600059..000000000
--- a/src/net/eathena/bankhandler.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 "net/eathena/bankhandler.h"
-
-#include "net/eathena/messageout.h"
-#include "net/eathena/protocolout.h"
-
-#include "debug.h"
-
-extern int packetVersion;
-
-namespace EAthena
-{
-
-BankHandler::BankHandler() :
- Net::BankHandler()
-{
- bankHandler = this;
-}
-
-BankHandler::~BankHandler()
-{
- bankHandler = nullptr;
-}
-
-void BankHandler::deposit(const int money) const
-{
- if (packetVersion < 20130320)
- return;
- createOutPacket(CMSG_BANK_DEPOSIT);
- outMsg.writeInt32(0, "account id");
- outMsg.writeInt32(money, "money");
-}
-
-void BankHandler::withdraw(const int money) const
-{
- if (packetVersion < 20130320)
- return;
- createOutPacket(CMSG_BANK_WITHDRAW);
- outMsg.writeInt32(0, "account id");
- outMsg.writeInt32(money, "money");
-}
-
-void BankHandler::check() const
-{
- if (packetVersion < 20130320)
- return;
- createOutPacket(CMSG_BANK_CHECK);
- outMsg.writeInt32(0, "account id");
-}
-
-void BankHandler::open() const
-{
- if (packetVersion < 20130417)
- return;
- createOutPacket(CMSG_BANK_OPEN);
- outMsg.writeInt32(0, "unused");
-}
-
-void BankHandler::close() const
-{
- if (packetVersion < 20130417)
- return;
- createOutPacket(CMSG_BANK_CLOSE);
- outMsg.writeInt32(0, "unused");
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/bankhandler.h b/src/net/eathena/bankhandler.h
deleted file mode 100644
index 0e890a61e..000000000
--- a/src/net/eathena/bankhandler.h
+++ /dev/null
@@ -1,50 +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 NET_EATHENA_BANKHANDLER_H
-#define NET_EATHENA_BANKHANDLER_H
-
-#include "net/bankhandler.h"
-
-namespace EAthena
-{
-class BankHandler final : public Net::BankHandler
-{
- public:
- BankHandler();
-
- A_DELETE_COPY(BankHandler)
-
- ~BankHandler();
-
- void deposit(const int money) const override final;
-
- void withdraw(const int money) const override final;
-
- void check() const override final;
-
- void open() const override final;
-
- void close() const override final;
-};
-
-} // namespace EAthena
-
-#endif // NET_EATHENA_BANKHANDLER_H
diff --git a/src/net/eathena/bankrecv.cpp b/src/net/eathena/bankrecv.cpp
deleted file mode 100644
index 12b17727b..000000000
--- a/src/net/eathena/bankrecv.cpp
+++ /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/>.
- */
-
-#include "net/eathena/bankrecv.h"
-
-#include "notifymanager.h"
-
-#include "enums/resources/notifytypes.h"
-
-#include "listeners/banklistener.h"
-
-#include "net/messagein.h"
-
-#include "utils/cast.h"
-
-#include "debug.h"
-
-namespace EAthena
-{
-
-void BankRecv::processBankStatus(Net::MessageIn &msg)
-{
- const int money = CAST_S32(msg.readInt64("money"));
- msg.readInt16("reason");
- BankListener::distributeEvent(money);
-}
-
-void BankRecv::processBankDeposit(Net::MessageIn &msg)
-{
- const int reason = msg.readInt16("reason");
- const int money = CAST_S32(msg.readInt64("money"));
- msg.readInt32("balance");
- BankListener::distributeEvent(money);
- if (reason != 0)
- NotifyManager::notify(NotifyTypes::BANK_DEPOSIT_FAILED);
-}
-
-void BankRecv::processBankWithdraw(Net::MessageIn &msg)
-{
- const int reason = msg.readInt16("reason");
- const int money = CAST_S32(msg.readInt64("money"));
- msg.readInt32("balance");
- BankListener::distributeEvent(money);
- if (reason != 0)
- NotifyManager::notify(NotifyTypes::BANK_WITHDRAW_FAILED);
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/bankrecv.h b/src/net/eathena/bankrecv.h
deleted file mode 100644
index 2d2755170..000000000
--- a/src/net/eathena/bankrecv.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 NET_EATHENA_BANKRECV_H
-#define NET_EATHENA_BANKRECV_H
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-namespace EAthena
-{
- namespace BankRecv
- {
- void processBankStatus(Net::MessageIn &msg);
- void processBankDeposit(Net::MessageIn &msg);
- void processBankWithdraw(Net::MessageIn &msg);
- } // namespace BankRecv
-} // namespace EAthena
-
-#endif // NET_EATHENA_BANKRECV_H
diff --git a/src/net/eathena/battlegroundhandler.cpp b/src/net/eathena/battlegroundhandler.cpp
deleted file mode 100644
index 09bc28a01..000000000
--- a/src/net/eathena/battlegroundhandler.cpp
+++ /dev/null
@@ -1,81 +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 "net/eathena/battlegroundhandler.h"
-
-#include "net/eathena/messageout.h"
-#include "net/eathena/protocolout.h"
-
-#include "debug.h"
-
-extern int packetVersion;
-
-namespace EAthena
-{
-
-BattleGroundHandler::BattleGroundHandler()
-{
- battleGroundHandler = this;
-}
-
-BattleGroundHandler::~BattleGroundHandler()
-{
- battleGroundHandler = nullptr;
-}
-
-void BattleGroundHandler::registerBg(const BattleGroundTypeT &type,
- const std::string &name) const
-{
- if (packetVersion < 20111005)
- return;
- createOutPacket(CMSG_BATTLE_REGISTER);
- outMsg.writeInt16(CAST_S16(type), "type");
- outMsg.writeString(name, 24, "bg name");
-}
-
-void BattleGroundHandler::rekoveRequest(const std::string &name) const
-{
- if (packetVersion < 20111005)
- return;
- createOutPacket(CMSG_BATTLE_REVOKE);
- outMsg.writeString(name, 24, "bg name");
-}
-
-void BattleGroundHandler::beginAck(const bool result,
- const std::string &bgName,
- const std::string &gameName) const
-{
- if (packetVersion < 20111005)
- return;
- createOutPacket(CMSG_BATTLE_BEGIN_ACK);
- outMsg.writeInt8(CAST_S8(result ? 1 : 0), "result");
- outMsg.writeString(bgName, 24, "bg name");
- outMsg.writeString(gameName, 24, "game name");
-}
-
-void BattleGroundHandler::checkState(const std::string &name) const
-{
- if (packetVersion < 20111005)
- return;
- createOutPacket(CMSG_BATTLE_CHECK_STATE);
- outMsg.writeString(name, 24, "bg name");
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/battlegroundhandler.h b/src/net/eathena/battlegroundhandler.h
deleted file mode 100644
index 230146963..000000000
--- a/src/net/eathena/battlegroundhandler.h
+++ /dev/null
@@ -1,51 +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 NET_EATHENA_BATTLEGROUNDHANDLER_H
-#define NET_EATHENA_BATTLEGROUNDHANDLER_H
-
-#include "net/battlegroundhandler.h"
-
-namespace EAthena
-{
-class BattleGroundHandler final : public Net::BattleGroundHandler
-{
- public:
- BattleGroundHandler();
-
- A_DELETE_COPY(BattleGroundHandler)
-
- ~BattleGroundHandler();
-
- void registerBg(const BattleGroundTypeT &type,
- const std::string &name) const override final;
-
- void rekoveRequest(const std::string &name) const override final;
-
- void beginAck(const bool result,
- const std::string &bgName,
- const std::string &gameName) const override final;
-
- void checkState(const std::string &name) const override final;
-};
-
-} // namespace EAthena
-
-#endif // NET_EATHENA_BATTLEGROUNDHANDLER_H
diff --git a/src/net/eathena/battlegroundrecv.cpp b/src/net/eathena/battlegroundrecv.cpp
deleted file mode 100644
index 2aaab9294..000000000
--- a/src/net/eathena/battlegroundrecv.cpp
+++ /dev/null
@@ -1,123 +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 "net/eathena/battlegroundrecv.h"
-
-#include "actormanager.h"
-#include "logger.h"
-
-#include "being/being.h"
-
-#include "net/messagein.h"
-
-#include "debug.h"
-
-namespace EAthena
-{
-
-void BattleGroundRecv::processBattleEmblem(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readBeingId("account id");
- msg.readString(24, "name");
- msg.readInt16("bg id");
-}
-
-void BattleGroundRecv::processBattleEmblem2(Net::MessageIn &msg)
-{
- const BeingId id = msg.readBeingId("account id");
- msg.readString(24, "name");
- msg.readInt16("bg id");
- const int teamId = msg.readInt16("team id");
-
- Being *const dstBeing = actorManager->findBeing(id);
- if (dstBeing != nullptr)
- dstBeing->setTeamId(CAST_U16(teamId));
-}
-
-void BattleGroundRecv::processBattleUpdateScore(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readInt16("camp a points");
- msg.readInt16("camp b points");
-}
-
-void BattleGroundRecv::processBattleUpdateCoords(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readBeingId("account id");
- msg.readString(24, "name");
- msg.readInt16("class");
- msg.readInt16("x");
- msg.readInt16("y");
-}
-
-void BattleGroundRecv::processBattlePlay(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readString(24, "battle ground name");
-}
-
-void BattleGroundRecv::processBattleQueueAck(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readUInt8("type");
- msg.readString(24, "bg name");
-}
-
-void BattleGroundRecv::processBattleBegins(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readString(24, "bg name");
- msg.readString(24, "game name");
-}
-
-void BattleGroundRecv::processBattleNoticeDelete(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readUInt8("type");
- msg.readString(24, "bg name");
-}
-
-void BattleGroundRecv::processBattleJoined(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readString(24, "name");
- msg.readInt32("position");
-}
-
-void BattleGroundRecv::processBattleUpdateHp(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readBeingId("account id");
- if (msg.getVersion() >= 20140613)
- {
- msg.readInt32("hp");
- msg.readInt32("max hp");
- }
- else
- {
- msg.readString(24, "name");
- msg.readInt16("hp");
- msg.readInt16("max hp");
- }
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/battlegroundrecv.h b/src/net/eathena/battlegroundrecv.h
deleted file mode 100644
index 7036fb31a..000000000
--- a/src/net/eathena/battlegroundrecv.h
+++ /dev/null
@@ -1,46 +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 NET_EATHENA_BATTLEGROUNDRECV_H
-#define NET_EATHENA_BATTLEGROUNDRECV_H
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-namespace EAthena
-{
- namespace BattleGroundRecv
- {
- void processBattleEmblem(Net::MessageIn &msg);
- void processBattleEmblem2(Net::MessageIn &msg);
- void processBattleUpdateScore(Net::MessageIn &msg);
- void processBattleUpdateCoords(Net::MessageIn &msg);
- void processBattlePlay(Net::MessageIn &msg);
- void processBattleQueueAck(Net::MessageIn &msg);
- void processBattleBegins(Net::MessageIn &msg);
- void processBattleNoticeDelete(Net::MessageIn &msg);
- void processBattleJoined(Net::MessageIn &msg);
- void processBattleUpdateHp(Net::MessageIn &msg);
- } // namespace BattleGroundRecv
-} // namespace EAthena
-
-#endif // NET_EATHENA_BATTLEGROUNDRECV_H
diff --git a/src/net/eathena/beinghandler.cpp b/src/net/eathena/beinghandler.cpp
deleted file mode 100644
index d53848654..000000000
--- a/src/net/eathena/beinghandler.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/>.
- */
-
-#include "net/eathena/beinghandler.h"
-
-#include "net/eathena/messageout.h"
-#include "net/eathena/protocolout.h"
-#include "net/eathena/sprite.h"
-
-#include "debug.h"
-
-extern int packetVersion;
-extern int serverVersion;
-
-namespace EAthena
-{
-
-BeingHandler::BeingHandler(const bool enableSync) :
- Ea::BeingHandler(enableSync)
-{
- beingHandler = this;
-}
-
-BeingHandler::~BeingHandler()
-{
- beingHandler = nullptr;
-}
-
-void BeingHandler::requestNameById(const BeingId id) const
-{
- createOutPacket(CMSG_NAME_REQUEST);
- if (packetVersion >= 20080827 && packetVersion < 20101124)
- {
- outMsg.writeInt32(0, "unused");
- outMsg.writeInt32(0, "unused");
- }
- outMsg.writeBeingId(id, "being id");
-}
-
-void BeingHandler::undress(Being *const being) const
-{
- if (being == nullptr)
- return;
- being->unSetSprite(SPRITE_WEAPON);
- being->unSetSprite(SPRITE_HEAD_BOTTOM);
- being->unSetSprite(SPRITE_HEAD_TOP);
- being->unSetSprite(SPRITE_HEAD_MID);
- being->unSetSprite(SPRITE_CLOTHES_COLOR);
- being->unSetSprite(SPRITE_SHIELD);
- being->unSetSprite(SPRITE_FLOOR);
- being->unSetSprite(SPRITE_ROBE);
- being->unSetSprite(SPRITE_EVOL2);
- being->unSetSprite(SPRITE_EVOL3);
- being->unSetSprite(SPRITE_EVOL4);
- being->unSetSprite(SPRITE_EVOL5);
- being->unSetSprite(SPRITE_EVOL6);
- being->unSetSprite(SPRITE_HAIR);
- being->unSetSprite(SPRITE_SHOES);
-}
-
-void BeingHandler::requestRanks(const RankT rank) const
-{
- if (packetVersion < 20130605)
- return;
-
- createOutPacket(CMSG_REQUEST_RANKS);
- outMsg.writeInt16(CAST_S16(rank), "type");
-}
-
-void BeingHandler::viewPlayerEquipment(const Being *const being) const
-{
- if (being == nullptr)
- return;
-
- createOutPacket(CMSG_PLAYER_VIEW_EQUIPMENT);
- outMsg.writeBeingId(being->getId(), "account id");
-}
-
-void BeingHandler::requestNameByCharId(const int id) const
-{
- createOutPacket(CMSG_SOLVE_CHAR_NAME);
- if (packetVersion >= 20080827 && packetVersion < 20101124)
- {
- outMsg.writeInt32(9, "unused");
- outMsg.writeInt32(9, "unused");
- }
- outMsg.writeInt32(id, "character id");
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/beinghandler.h b/src/net/eathena/beinghandler.h
deleted file mode 100644
index cb8f8c248..000000000
--- a/src/net/eathena/beinghandler.h
+++ /dev/null
@@ -1,54 +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 NET_EATHENA_BEINGHANDLER_H
-#define NET_EATHENA_BEINGHANDLER_H
-
-#include "net/ea/beinghandler.h"
-
-namespace EAthena
-{
-
-class BeingHandler final : public Ea::BeingHandler
-{
- public:
- explicit BeingHandler(const bool enableSync);
-
- A_DELETE_COPY(BeingHandler)
-
- ~BeingHandler();
-
- void requestNameById(const BeingId id) const override final;
-
- void undress(Being *const being) const override final;
-
- void requestRanks(const RankT rank) const override final;
-
- void requestNameByCharId(const int id) const override final;
-
- void viewPlayerEquipment(const Being *const being) const
- override final;
-};
-
-} // namespace EAthena
-
-#endif // NET_EATHENA_BEINGHANDLER_H
diff --git a/src/net/eathena/beingrecv.cpp b/src/net/eathena/beingrecv.cpp
deleted file mode 100644
index 8d986797b..000000000
--- a/src/net/eathena/beingrecv.cpp
+++ /dev/null
@@ -1,2191 +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 "net/eathena/beingrecv.h"
-
-#include "actormanager.h"
-#include "effectmanager.h"
-#include "game.h"
-#include "notifymanager.h"
-#include "party.h"
-
-#include "being/mercenaryinfo.h"
-
-#include "const/utils/timer.h"
-
-#include "enums/resources/notifytypes.h"
-
-#include "particle/particleengine.h"
-
-#include "input/keyboardconfig.h"
-
-#include "gui/viewport.h"
-
-#include "gui/windows/skilldialog.h"
-#include "gui/windows/socialwindow.h"
-#include "gui/windows/okdialog.h"
-#include "gui/windows/outfitwindow.h"
-
-#include "net/character.h"
-#include "net/charserverhandler.h"
-#include "net/messagein.h"
-#include "net/serverfeatures.h"
-
-#include "net/ea/beingrecv.h"
-
-#include "net/eathena/maptypeproperty2.h"
-#include "net/eathena/sp.h"
-#include "net/eathena/sprite.h"
-
-#include "resources/iteminfo.h"
-#include "resources/db/itemdb.h"
-
-#include "resources/map/map.h"
-
-#include "utils/checkutils.h"
-#include "utils/foreach.h"
-#include "utils/timer.h"
-
-#include "debug.h"
-
-extern int serverVersion;
-extern OkDialog *deathNotice;
-
-namespace EAthena
-{
-
-void BeingRecv::processBeingChangeLook2(Net::MessageIn &msg)
-{
- if (actorManager == nullptr)
- return;
-
- Being *const dstBeing = actorManager->findBeing(
- msg.readBeingId("being id"));
- const uint8_t type = msg.readUInt8("type");
-
- const int id = msg.readInt16("id1");
- unsigned int id2 = msg.readInt16("id2");
- if (type != 2)
- id2 = 1;
-
- if ((localPlayer == nullptr) || (dstBeing == nullptr))
- return;
-
- processBeingChangeLookContinue(msg, dstBeing, type, id, id2, nullptr);
-}
-
-void BeingRecv::processBeingChangeLookCards(Net::MessageIn &msg)
-{
- Being *dstBeing = nullptr;
- int cards[maxCards];
-
- if (actorManager == nullptr)
- { // here can be look from char server
- Net::Characters &chars = Net::CharServerHandler::mCharacters;
- const BeingId id = msg.readBeingId("being id");
-
- FOR_EACH (Net::Characters::iterator, it, chars)
- {
- const Net::Character *const character = *it;
- if (character->dummy != nullptr &&
- character->dummy->getId() == id)
- {
- dstBeing = character->dummy;
- break;
- }
- }
- }
- else
- {
- dstBeing = actorManager->findBeing(
- msg.readBeingId("being id"));
- }
-
- const uint8_t type = msg.readUInt8("type");
-
- const int id = msg.readInt16("id1");
- unsigned int id2 = msg.readInt16("id2");
- if (type != 2)
- id2 = 1;
-
- for (int f = 0; f < maxCards; f ++)
- cards[f] = msg.readUInt16("card");
-
- if (dstBeing == nullptr)
- return;
-
- processBeingChangeLookContinue(msg, dstBeing, type, id, id2, &cards[0]);
-}
-
-void BeingRecv::processBeingChangeLookContinue(const Net::MessageIn &msg,
- Being *const dstBeing,
- const uint8_t type,
- const int id,
- const int id2,
- const int *const cards)
-{
- if (dstBeing->getType() == ActorType::Player)
- dstBeing->setOtherTime();
-
- switch (type)
- {
- // here should be used SPRITE_* constants
- // but for now they conflicting with sprites
- // SPRITE_* is same with server LOOK_*
- case 0: // change race
- dstBeing->setSubtype(fromInt(id, BeingTypeId),
- dstBeing->getLook());
- break;
- case 1: // eAthena LOOK_HAIR
- dstBeing->setHairColor(fromInt(id, ItemColor));
- dstBeing->setHairColorSpriteID(SPRITE_HAIR_COLOR,
- id * -1);
- break;
- case 2: // LOOK_WEAPON Weapon ID in id, Shield ID in id2
- dstBeing->setSpriteCards(SPRITE_BODY,
- id,
- CardsList(cards));
- dstBeing->setWeaponId(id);
- dstBeing->setSpriteId(SPRITE_FLOOR,
- id2);
- if (localPlayer != nullptr)
- localPlayer->imitateOutfit(dstBeing, SPRITE_FLOOR);
- break;
- case 3: // LOOK_HEAD_BOTTOM
- dstBeing->setSpriteCards(SPRITE_WEAPON,
- id,
- CardsList(cards));
- if (localPlayer != nullptr)
- localPlayer->imitateOutfit(dstBeing, SPRITE_WEAPON);
- break;
- case 4: // LOOK_HEAD_TOP Change upper headgear for eAthena, hat for us
- dstBeing->setSpriteCards(SPRITE_CLOTHES_COLOR,
- id,
- CardsList(cards));
- if (localPlayer != nullptr)
- localPlayer->imitateOutfit(dstBeing, SPRITE_CLOTHES_COLOR);
- break;
- case 5: // LOOK_HEAD_MID Change middle headgear for eathena,
- // armor for us
- dstBeing->setSpriteCards(SPRITE_HEAD_BOTTOM,
- id,
- CardsList(cards));
- if (localPlayer != nullptr)
- localPlayer->imitateOutfit(dstBeing, SPRITE_HEAD_BOTTOM);
- break;
- case 6: // eAthena LOOK_HAIR_COLOR
- dstBeing->setHairColor(fromInt(id, ItemColor));
- dstBeing->setSpriteColor(SPRITE_HAIR_COLOR,
- ItemDB::get(dstBeing->getSpriteID(
- SPRITE_HAIR_COLOR)).getDyeColorsString(
- fromInt(id, ItemColor)));
- break;
- case 7: // Clothes color. Now used as look
- dstBeing->setLook(CAST_U8(id));
- break;
- case 8: // eAthena LOOK_SHIELD
- dstBeing->setSpriteCards(SPRITE_FLOOR,
- id,
- CardsList(cards));
- if (localPlayer != nullptr)
- localPlayer->imitateOutfit(dstBeing, SPRITE_FLOOR);
- break;
- case 9: // eAthena LOOK_SHOES
- dstBeing->setSpriteCards(SPRITE_HAIR,
- id,
- CardsList(cards));
- if (localPlayer != nullptr)
- localPlayer->imitateOutfit(dstBeing, SPRITE_HAIR);
- break;
- case 10: // LOOK_GLOVES
- dstBeing->setSpriteCards(SPRITE_SHOES,
- id,
- CardsList(cards));
- if (localPlayer != nullptr)
- localPlayer->imitateOutfit(dstBeing, SPRITE_SHOES);
- break;
- case 11: // LOOK_FLOOR
- dstBeing->setSpriteCards(SPRITE_SHIELD,
- id,
- CardsList(cards));
- if (localPlayer != nullptr)
- localPlayer->imitateOutfit(dstBeing, SPRITE_SHIELD);
- break;
- case 12: // LOOK_ROBE
- dstBeing->setSpriteCards(SPRITE_HEAD_TOP,
- id,
- CardsList(cards));
- if (localPlayer != nullptr)
- localPlayer->imitateOutfit(dstBeing, SPRITE_HEAD_TOP);
- break;
- case 13: // COSTUME_HEAD_TOP
- dstBeing->setSpriteCards(SPRITE_HEAD_MID,
- id,
- CardsList(cards));
- if (localPlayer != nullptr)
- localPlayer->imitateOutfit(dstBeing, SPRITE_HEAD_MID);
- break;
- case 14: // COSTUME_HEAD_MID
- dstBeing->setSpriteCards(SPRITE_ROBE,
- id,
- CardsList(cards));
- if (localPlayer != nullptr)
- localPlayer->imitateOutfit(dstBeing, SPRITE_ROBE);
- break;
- case 15: // COSTUME_HEAD_LOW
- dstBeing->setSpriteCards(SPRITE_EVOL2,
- id,
- CardsList(cards));
- if (localPlayer != nullptr)
- localPlayer->imitateOutfit(dstBeing, SPRITE_EVOL2);
- break;
- case 16: // COSTUME_GARMENT
- dstBeing->setSpriteCards(SPRITE_EVOL3,
- id,
- CardsList(cards));
- if (localPlayer != nullptr)
- localPlayer->imitateOutfit(dstBeing, SPRITE_EVOL3);
- break;
- case 17: // ARMOR
- dstBeing->setSpriteCards(SPRITE_EVOL4,
- id,
- CardsList(cards));
- if (localPlayer != nullptr)
- localPlayer->imitateOutfit(dstBeing, SPRITE_EVOL4);
- break;
- case 18:
- dstBeing->setSpriteCards(SPRITE_EVOL5,
- id,
- CardsList(cards));
- if (localPlayer != nullptr)
- localPlayer->imitateOutfit(dstBeing, SPRITE_EVOL5);
- break;
- case 19:
- dstBeing->setSpriteCards(SPRITE_EVOL6,
- id,
- CardsList(cards));
- if (localPlayer != nullptr)
- localPlayer->imitateOutfit(dstBeing, SPRITE_EVOL6);
- break;
- default:
- UNIMPLEMENTEDPACKETFIELD(type);
- break;
- }
-}
-
-void BeingRecv::processBeingVisible(Net::MessageIn &msg)
-{
- if (actorManager == nullptr)
- return;
-
- // need set type based on id
- BeingTypeT type = BeingType::MONSTER;
- if (msg.getVersion() >= 20091103)
- {
- msg.readInt16("len");
- type = static_cast<BeingTypeT>(
- msg.readUInt8("object type"));
- }
-
- // Information about a being in range
- const BeingId id = msg.readBeingId("being id");
- if (msg.getVersion() >= 20131223)
- msg.readBeingId("char id");
- BeingId spawnId;
- if (id == Ea::BeingRecv::mSpawnId)
- spawnId = Ea::BeingRecv::mSpawnId;
- else
- spawnId = BeingId_zero;
- Ea::BeingRecv::mSpawnId = BeingId_zero;
-
- int16_t speed = msg.readInt16("speed");
- const uint32_t opt1 = msg.readInt16("opt1");
- // probably wrong effect usage
- const uint32_t opt2 = msg.readInt16("opt2");
- uint32_t option;
- if (msg.getVersion() >= 20080102)
- option = msg.readInt32("option");
- else
- option = msg.readInt16("option");
- const int16_t job = msg.readInt16("class");
-
- Being *dstBeing = actorManager->findBeing(id);
-
- if ((dstBeing != nullptr) && dstBeing->getType() == ActorType::Monster
- && !dstBeing->isAlive())
- {
- actorManager->destroy(dstBeing);
- actorManager->erase(dstBeing);
- dstBeing = nullptr;
- }
-
- if (dstBeing == nullptr)
- {
- if (actorManager->isBlocked(id) == true)
- return;
-
- dstBeing = createBeing2(msg, id, job, type);
- if (dstBeing == nullptr)
- return;
- }
- else
- {
- // undeleting marked for deletion being
- if (dstBeing->getType() == ActorType::Npc)
- actorManager->undelete(dstBeing);
- }
-
- if (dstBeing->getType() == ActorType::Player)
- dstBeing->setMoveTime();
-
- if (spawnId != BeingId_zero)
- {
- dstBeing->setAction(BeingAction::SPAWN, 0);
- }
- else
- {
- dstBeing->clearPath();
- dstBeing->setActionTime(tick_time);
- dstBeing->setAction(BeingAction::STAND, 0);
- }
-
- // Prevent division by 0 when calculating frame
- if (speed == 0)
- speed = 150;
-
- dstBeing->setWalkSpeed(speed);
- dstBeing->setSubtype(fromInt(job, BeingTypeId), 0);
- if (dstBeing->getType() == ActorType::Monster && (localPlayer != nullptr))
- localPlayer->checkNewName(dstBeing);
-
- const int hairStyle = msg.readInt16("hair style");
- uint32_t weapon;
- if (msg.getVersion() >= 7)
- weapon = CAST_U32(msg.readInt32("weapon"));
- else
- weapon = CAST_U32(msg.readInt16("weapon"));
- const uint16_t headBottom = msg.readInt16("head bottom");
- if (msg.getVersion() < 7)
- msg.readInt16("shield");
- const uint16_t headTop = msg.readInt16("head top");
- const uint16_t headMid = msg.readInt16("head mid");
- const ItemColor hairColor = fromInt(msg.readInt16("hair color"),
- ItemColor);
- const uint16_t shoes = msg.readInt16("shoes or clothes color?");
-
- const uint16_t gloves = msg.readInt16("head dir / gloves");
- // may be use robe as gloves?
- if (msg.getVersion() >= 20101124)
- msg.readInt16("robe");
- msg.readInt32("guild id");
- msg.readInt16("guild emblem");
- dstBeing->setManner(msg.readInt16("manner"));
- uint32_t opt3;
- if (msg.getVersion() >= 7)
- opt3 = msg.readInt32("opt3");
- else
- opt3 = msg.readInt16("opt3");
- dstBeing->setKarma(msg.readUInt8("karma"));
- const uint8_t gender = CAST_U8(msg.readUInt8("gender") & 3);
-
- const ActorTypeT actorType = dstBeing->getType();
- switch (actorType)
- {
- case ActorType::Player:
- dstBeing->setGender(Being::intToGender(gender));
- dstBeing->setHairColor(hairColor);
- // Set these after the gender, as the sprites may be gender-specific
- if (hairStyle == 0)
- {
- dstBeing->updateSprite(SPRITE_HAIR_COLOR,
- 0,
- std::string());
- }
- else
- {
- dstBeing->updateSprite(SPRITE_HAIR_COLOR,
- hairStyle * -1,
- ItemDB::get(-hairStyle).getDyeColorsString(hairColor));
- }
- dstBeing->updateSprite(SPRITE_WEAPON, headBottom);
- dstBeing->updateSprite(SPRITE_HEAD_BOTTOM, headMid);
- dstBeing->updateSprite(SPRITE_CLOTHES_COLOR, headTop);
- dstBeing->updateSprite(SPRITE_HAIR, shoes);
- dstBeing->updateSprite(SPRITE_SHOES, gloves);
- dstBeing->updateSprite(SPRITE_BODY, weapon);
- dstBeing->setWeaponId(weapon);
- break;
- case ActorType::Npc:
- if (serverFeatures->haveNpcGender())
- {
- dstBeing->setGender(Being::intToGender(gender));
- }
- break;
- default:
- case ActorType::Monster:
- case ActorType::Portal:
- case ActorType::Pet:
- case ActorType::Mercenary:
- case ActorType::Homunculus:
- case ActorType::SkillUnit:
- case ActorType::Elemental:
- break;
- case ActorType::FloorItem:
- case ActorType::Avatar:
- case ActorType::Unknown:
- reportAlways("Wrong being type detected: %d",
- CAST_S32(actorType));
- break;
- }
-
- uint8_t dir;
- uint16_t x, y;
- msg.readCoordinates(x, y, dir, "position");
- msg.readInt8("xs");
- msg.readInt8("ys");
- applyPlayerAction(msg, dstBeing, msg.readUInt8("action type"));
- dstBeing->setTileCoords(x, y);
-
- if (job == 45 && (socialWindow != nullptr) && (outfitWindow != nullptr))
- {
- const int num = socialWindow->getPortalIndex(x, y);
- if (num >= 0)
- {
- dstBeing->setName(KeyboardConfig::getKeyShortString(
- OutfitWindow::keyName(num)));
- }
- else
- {
- dstBeing->setName("");
- }
- }
-
- dstBeing->setDirection(dir);
-
- const int level = CAST_S32(msg.readInt16("level"));
- if (level != 0)
- dstBeing->setLevel(level);
- if (msg.getVersion() >= 20080102)
- msg.readInt16("font");
-
- if (msg.getVersion() >= 20120221)
- {
- const int maxHP = msg.readInt32("max hp");
- const int hp = msg.readInt32("hp");
- dstBeing->setMaxHP(maxHP);
- dstBeing->setHP(hp);
- msg.readInt8("is boss");
- }
-
- if (serverVersion == 0 ||
- serverVersion >= 16)
- {
- if (msg.getVersion() >= 20150513)
- {
- msg.readInt16("body2");
- }
- if (msg.getVersion() >= 20131223)
- {
- msg.readString(24, "name");
- }
- }
- else
- {
- if (msg.getVersion() >= 20150513)
- {
- msg.readInt16("body2");
- msg.readString(24, "name");
- }
- }
-
- dstBeing->setStatusEffectOpitons(option,
- opt1,
- opt2,
- opt3);
-}
-
-void BeingRecv::processBeingMove(Net::MessageIn &msg)
-{
- if (actorManager == nullptr)
- return;
-
- if (msg.getVersion() >= 20091103)
- msg.readInt16("len");
- BeingTypeT type;
- if (msg.getVersion() >= 20071106)
- {
- type = static_cast<BeingTypeT>(
- msg.readUInt8("object type"));
- }
- else
- {
- // need detect type based on id
- type = BeingType::MONSTER;
- }
-
- // Information about a being in range
- const BeingId id = msg.readBeingId("being id");
- if (msg.getVersion() >= 20131223)
- msg.readBeingId("char id");
- BeingId spawnId;
- if (id == Ea::BeingRecv::mSpawnId)
- spawnId = Ea::BeingRecv::mSpawnId;
- else
- spawnId = BeingId_zero;
- Ea::BeingRecv::mSpawnId = BeingId_zero;
- int16_t speed = msg.readInt16("speed");
- const uint32_t opt1 = msg.readInt16("opt1");
- // probably wrong effect usage
- const uint32_t opt2 = msg.readInt16("opt2");
- uint32_t option;
- if (msg.getVersion() >= 7)
- option = msg.readInt32("option");
- else
- option = msg.readInt16("option");
- const int16_t job = msg.readInt16("class");
-
- Being *dstBeing = actorManager->findBeing(id);
-
- if ((dstBeing != nullptr) && dstBeing->getType() == ActorType::Monster
- && !dstBeing->isAlive())
- {
- actorManager->destroy(dstBeing);
- actorManager->erase(dstBeing);
- dstBeing = nullptr;
- }
-
- if (dstBeing == nullptr)
- {
- if (actorManager->isBlocked(id) == true)
- return;
-
- dstBeing = createBeing2(msg, id, job, type);
- if (dstBeing == nullptr)
- return;
- }
- else
- {
- // undeleting marked for deletion being
- if (dstBeing->getType() == ActorType::Npc)
- actorManager->undelete(dstBeing);
- }
-
- if (dstBeing->getType() == ActorType::Player)
- dstBeing->setMoveTime();
-
- if (spawnId != BeingId_zero)
- dstBeing->setAction(BeingAction::SPAWN, 0);
-
- // Prevent division by 0 when calculating frame
- if (speed == 0)
- speed = 150;
-
- dstBeing->setWalkSpeed(speed);
- dstBeing->setSubtype(fromInt(job, BeingTypeId), 0);
- if (dstBeing->getType() == ActorType::Monster && (localPlayer != nullptr))
- localPlayer->checkNewName(dstBeing);
-
- const int hairStyle = msg.readInt16("hair style");
- uint32_t weapon;
- if (msg.getVersion() >= 7)
- weapon = CAST_U32(msg.readInt32("weapon"));
- else
- weapon = CAST_U32(msg.readInt16("weapon"));
- const uint16_t headBottom = msg.readInt16("head bottom");
- msg.readInt32("tick");
- if (msg.getVersion() < 7)
- msg.readInt16("shield");
- const uint16_t headTop = msg.readInt16("head top");
- const uint16_t headMid = msg.readInt16("head mid");
- const ItemColor hairColor = fromInt(
- msg.readInt16("hair color"), ItemColor);
- const uint16_t shoes = msg.readInt16("shoes or clothes color?");
-
- const uint16_t gloves = msg.readInt16("head dir / gloves");
- // may be use robe as gloves?
- if (msg.getVersion() >= 20101124)
- msg.readInt16("robe");
- msg.readInt32("guild id");
- msg.readInt16("guild emblem");
- dstBeing->setManner(msg.readInt16("manner"));
- uint32_t opt3;
- if (msg.getVersion() >= 7)
- opt3 = msg.readInt32("opt3");
- else
- opt3 = msg.readInt16("opt3");
- dstBeing->setKarma(msg.readUInt8("karma"));
- const uint8_t gender = CAST_U8(msg.readUInt8("gender") & 3);
-
- const ActorTypeT actorType = dstBeing->getType();
- switch (actorType)
- {
- case ActorType::Player:
- dstBeing->setGender(Being::intToGender(gender));
- dstBeing->setHairColor(hairColor);
- // Set these after the gender, as the sprites may be gender-specific
- if (hairStyle == 0)
- {
- dstBeing->updateSprite(SPRITE_HAIR_COLOR, 0);
- }
- else
- {
- dstBeing->updateSprite(SPRITE_HAIR_COLOR,
- hairStyle * -1,
- ItemDB::get(-hairStyle).getDyeColorsString(hairColor));
- }
- if (!serverFeatures->haveMove3())
- {
- dstBeing->updateSprite(SPRITE_WEAPON, headBottom);
- dstBeing->updateSprite(SPRITE_HEAD_BOTTOM, headMid);
- dstBeing->updateSprite(SPRITE_CLOTHES_COLOR, headTop);
- dstBeing->updateSprite(SPRITE_HAIR, shoes);
- dstBeing->updateSprite(SPRITE_SHOES, gloves);
- dstBeing->updateSprite(SPRITE_BODY, weapon);
- dstBeing->setWeaponId(weapon);
- }
- break;
- case ActorType::Npc:
- if (serverFeatures->haveNpcGender())
- {
- dstBeing->setGender(Being::intToGender(gender));
- }
- break;
- default:
- case ActorType::Monster:
- case ActorType::Portal:
- case ActorType::Pet:
- case ActorType::Mercenary:
- case ActorType::Homunculus:
- case ActorType::SkillUnit:
- case ActorType::Elemental:
- break;
- case ActorType::FloorItem:
- case ActorType::Avatar:
- case ActorType::Unknown:
- reportAlways("Wrong being type detected: %d",
- CAST_S32(actorType));
- break;
- }
-
- uint16_t srcX, srcY, dstX, dstY;
- msg.readCoordinatePair(srcX, srcY, dstX, dstY, "move path");
- msg.readUInt8("(sx<<4) | (sy&0x0f)");
- msg.readInt8("xs");
- msg.readInt8("ys");
- dstBeing->setAction(BeingAction::STAND, 0);
- dstBeing->setTileCoords(srcX, srcY);
- if (localPlayer != nullptr)
- localPlayer->followMoveTo(dstBeing, srcX, srcY, dstX, dstY);
- if (serverFeatures->haveMove3())
- dstBeing->setCachedDestination(dstX, dstY);
- else
- dstBeing->setDestination(dstX, dstY);
-
- // because server don't send direction in move packet, we fixing it
-
- uint8_t d = 0;
- if (localPlayer != nullptr &&
- srcX == dstX &&
- srcY == dstY)
- { // if player did one step from invisible area to visible,
- // move path is broken
- int x2 = localPlayer->getTileX();
- int y2 = localPlayer->getTileY();
- if (abs(x2 - srcX) > abs(y2 - srcY))
- y2 = srcY;
- else
- x2 = srcX;
- d = dstBeing->calcDirection(x2, y2);
- }
- else
- {
- d = dstBeing->calcDirection(dstX, dstY);
- }
- if ((d != 0u) && dstBeing->getDirection() != d)
- dstBeing->setDirection(d);
-
- const int level = CAST_S32(msg.readInt16("level"));
- if (level != 0)
- dstBeing->setLevel(level);
- if (msg.getVersion() >= 20080102)
- msg.readInt16("font");
- if (msg.getVersion() >= 20120221)
- {
- const int maxHP = msg.readInt32("max hp");
- const int hp = msg.readInt32("hp");
- dstBeing->setMaxHP(maxHP);
- dstBeing->setHP(hp);
- msg.readInt8("is boss");
- }
- if (serverVersion == 0 ||
- serverVersion >= 16)
- {
- if (msg.getVersion() >= 20150513)
- {
- msg.readInt16("body2");
- }
- if (msg.getVersion() >= 20131223)
- {
- msg.readString(24, "name");
- }
- }
- else
- {
- if (msg.getVersion() >= 20150513)
- {
- msg.readInt16("body2");
- msg.readString(24, "name");
- }
- }
-
- dstBeing->setStatusEffectOpitons(option,
- opt1,
- opt2,
- opt3);
-}
-
-void BeingRecv::processBeingSpawn(Net::MessageIn &msg)
-{
- if (actorManager == nullptr)
- return;
-
- // need get type from id
- BeingTypeT type = BeingType::MONSTER;
- if (msg.getVersion() >= 20091103)
- {
- msg.readInt16("len");
- type = static_cast<BeingTypeT>(
- msg.readUInt8("object type"));
- }
-
- // Information about a being in range
- const BeingId id = msg.readBeingId("being id");
- if (msg.getVersion() >= 20131223)
- {
- msg.readBeingId("char id");
- }
- Ea::BeingRecv::mSpawnId = id;
- const BeingId spawnId = id;
- int16_t speed = msg.readInt16("speed");
- const uint32_t opt1 = msg.readInt16("opt1");
- // probably wrong effect usage
- const uint32_t opt2 = msg.readInt16("opt2");
- uint32_t option;
- if (msg.getVersion() >= 20080102)
- option = msg.readInt32("option");
- else
- option = msg.readInt16("option");
- const int16_t job = msg.readInt16("class");
-
- Being *dstBeing = actorManager->findBeing(id);
-
- if ((dstBeing != nullptr) && dstBeing->getType() == ActorType::Monster
- && !dstBeing->isAlive())
- {
- actorManager->destroy(dstBeing);
- actorManager->erase(dstBeing);
- dstBeing = nullptr;
- }
-
- if (dstBeing == nullptr)
- {
- if (actorManager->isBlocked(id) == true)
- return;
-
- dstBeing = createBeing2(msg, id, job, type);
- if (dstBeing == nullptr)
- return;
- }
- else
- {
- // undeleting marked for deletion being
- if (dstBeing->getType() == ActorType::Npc)
- actorManager->undelete(dstBeing);
- }
-
- if (dstBeing->getType() == ActorType::Player)
- dstBeing->setMoveTime();
-
- if (spawnId != BeingId_zero)
- dstBeing->setAction(BeingAction::SPAWN, 0);
-
- // Prevent division by 0 when calculating frame
- if (speed == 0)
- speed = 150;
-
- dstBeing->setWalkSpeed(speed);
- dstBeing->setSubtype(fromInt(job, BeingTypeId), 0);
- if (dstBeing->getType() == ActorType::Monster && (localPlayer != nullptr))
- localPlayer->checkNewName(dstBeing);
-
- const int hairStyle = msg.readInt16("hair style");
- uint32_t weapon;
- if (msg.getVersion() >= 7)
- weapon = CAST_U32(msg.readInt32("weapon"));
- else
- weapon = CAST_U32(msg.readInt16("weapon"));
- const uint16_t headBottom = msg.readInt16("head bottom");
- if (msg.getVersion() < 7)
- msg.readInt16("shield");
- const uint16_t headTop = msg.readInt16("head top");
- const uint16_t headMid = msg.readInt16("head mid");
- const ItemColor hairColor = fromInt(
- msg.readInt16("hair color"), ItemColor);
- const uint16_t shoes = msg.readInt16("shoes or clothes color?");
- const uint16_t gloves = msg.readInt16("head dir / gloves");
- // may be use robe as gloves?
- if (msg.getVersion() >= 20101124)
- msg.readInt16("robe");
- msg.readInt32("guild id");
- msg.readInt16("guild emblem");
- dstBeing->setManner(msg.readInt16("manner"));
- uint32_t opt3;
- if (msg.getVersion() >= 7)
- opt3 = msg.readInt32("opt3");
- else
- opt3 = msg.readInt16("opt3");
-
- dstBeing->setKarma(msg.readUInt8("karma"));
- const uint8_t gender = CAST_U8(msg.readUInt8("gender") & 3);
-
- const ActorTypeT actorType = dstBeing->getType();
- switch (actorType)
- {
- case ActorType::Player:
- dstBeing->setGender(Being::intToGender(gender));
- dstBeing->setHairColor(hairColor);
- // Set these after the gender, as the sprites may be gender-specific
- if (hairStyle == 0)
- {
- dstBeing->updateSprite(SPRITE_HAIR_COLOR, 0);
- }
- else
- {
- dstBeing->updateSprite(SPRITE_HAIR_COLOR,
- hairStyle * -1,
- ItemDB::get(-hairStyle).getDyeColorsString(hairColor));
- }
- dstBeing->updateSprite(SPRITE_WEAPON, headBottom);
- dstBeing->updateSprite(SPRITE_HEAD_BOTTOM, headMid);
- dstBeing->updateSprite(SPRITE_CLOTHES_COLOR, headTop);
- dstBeing->updateSprite(SPRITE_HAIR, shoes);
- dstBeing->updateSprite(SPRITE_SHOES, gloves);
- dstBeing->updateSprite(SPRITE_BODY, weapon);
- dstBeing->setWeaponId(weapon);
- break;
- case ActorType::Npc:
- if (serverFeatures->haveNpcGender())
- {
- dstBeing->setGender(Being::intToGender(gender));
- }
- break;
- default:
- case ActorType::Monster:
- case ActorType::Portal:
- case ActorType::Pet:
- case ActorType::Mercenary:
- case ActorType::Homunculus:
- case ActorType::SkillUnit:
- case ActorType::Elemental:
- break;
- case ActorType::FloorItem:
- case ActorType::Avatar:
- case ActorType::Unknown:
- reportAlways("Wrong being type detected: %d",
- CAST_S32(actorType));
- break;
- }
-
- uint8_t dir;
- uint16_t x, y;
- msg.readCoordinates(x, y, dir, "position");
- msg.readInt8("xs");
- msg.readInt8("ys");
- dstBeing->setTileCoords(x, y);
-
- if (job == 45 && (socialWindow != nullptr) && (outfitWindow != nullptr))
- {
- const int num = socialWindow->getPortalIndex(x, y);
- if (num >= 0)
- {
- dstBeing->setName(KeyboardConfig::getKeyShortString(
- OutfitWindow::keyName(num)));
- }
- else
- {
- dstBeing->setName("");
- }
- }
-
- dstBeing->setDirection(dir);
-
- const int level = CAST_S32(msg.readInt16("level"));
- if (level != 0)
- dstBeing->setLevel(level);
- if (msg.getVersion() >= 20080102)
- msg.readInt16("font");
- if (msg.getVersion() >= 20120221)
- {
- const int maxHP = msg.readInt32("max hp");
- const int hp = msg.readInt32("hp");
- dstBeing->setMaxHP(maxHP);
- dstBeing->setHP(hp);
- msg.readInt8("is boss");
- }
- if (serverVersion == 0 ||
- serverVersion >= 16)
- {
- if (msg.getVersion() >= 20150513)
- {
- msg.readInt16("body2");
- }
- if (msg.getVersion() >= 20131223)
- {
- msg.readString(24, "name");
- }
- }
- else
- {
- if (msg.getVersion() >= 20150513)
- {
- msg.readInt16("body2");
- msg.readString(24, "name");
- }
- }
-
- dstBeing->setStatusEffectOpitons(option,
- opt1,
- opt2,
- opt3);
-}
-
-void BeingRecv::processMapTypeProperty(Net::MessageIn &msg)
-{
- const int16_t type = msg.readInt16("type");
- const int flags = msg.readInt32("flags");
- if (type == 0x28)
- {
- // +++ need get other flags from here
- MapTypeProperty2 props;
- props.data = CAST_U32(flags);
- const Game *const game = Game::instance();
- if (game == nullptr)
- return;
- Map *const map = game->getCurrentMap();
- if (map == nullptr)
- return;
- map->setPvpMode(props.bits.party | (props.bits.guild * 2));
- }
-}
-
-void BeingRecv::processMapType(Net::MessageIn &msg)
-{
- const int16_t type = msg.readInt16("type");
- if (type == 19)
- NotifyManager::notify(NotifyTypes::MAP_TYPE_BATTLEFIELD);
- else
- UNIMPLEMENTEDPACKETFIELD(type);
-}
-
-void BeingRecv::processSkillCasting(Net::MessageIn &msg)
-{
- const BeingId srcId = msg.readBeingId("src id");
- const BeingId dstId = msg.readBeingId("dst id");
- const int dstX = msg.readInt16("dst x");
- const int dstY = msg.readInt16("dst y");
- const int skillId = msg.readInt16("skill id");
- msg.readInt32("property"); // can be used to trigger effect
- const int castTime = msg.readInt32("cast time");
- if (msg.getVersion() >= 20091124)
- msg.readInt8("dispossable");
-
- processSkillCastingContinue(msg,
- srcId, dstId,
- dstX, dstY,
- skillId,
- 1,
- 0,
- SkillType2::Unknown,
- castTime);
-}
-
-void BeingRecv::processSkillCasting2(Net::MessageIn &msg)
-{
- msg.readInt16("len"); // for now unused
- const BeingId srcId = msg.readBeingId("src id");
- const BeingId dstId = msg.readBeingId("dst id");
- const int dstX = msg.readInt16("dst x");
- const int dstY = msg.readInt16("dst y");
- const int skillId = msg.readInt16("skill id");
- const int skillLevel = msg.readInt16("skill level");
- msg.readInt32("property"); // can be used to trigger effect
- const int castTime = msg.readInt32("cast time");
- const int range = msg.readInt32("skill range");
- const SkillType2::SkillType2 inf2 =
- static_cast<SkillType2::SkillType2>(msg.readInt32("inf2"));
-
- processSkillCastingContinue(msg,
- srcId, dstId,
- dstX, dstY,
- skillId,
- skillLevel,
- range,
- inf2,
- castTime);
-}
-
-void BeingRecv::processSkillCastingContinue(Net::MessageIn &msg,
- const BeingId srcId,
- const BeingId dstId,
- const int dstX,
- const int dstY,
- const int skillId,
- const int skillLevel,
- const int range,
- const SkillType2::SkillType2 inf2,
- const int castTime)
-{
- if (effectManager == nullptr)
- return;
-
- if (srcId == BeingId_zero)
- {
- UNIMPLEMENTEDPACKETFIELD(0);
- return;
- }
- Being *const srcBeing = actorManager->findBeing(srcId);
- if (dstId != BeingId_zero)
- { // being to being
- Being *const dstBeing = actorManager->findBeing(dstId);
- if (srcBeing != nullptr)
- {
- srcBeing->handleSkillCasting(dstBeing, skillId, skillLevel);
- if (dstBeing != nullptr)
- {
- srcBeing->addCast(dstBeing->getTileX(),
- dstBeing->getTileY(),
- skillId,
- skillLevel,
- range,
- castTime / MILLISECONDS_IN_A_TICK);
- }
- }
- }
- else if (dstX != 0 || dstY != 0)
- { // being to position
- if (srcBeing != nullptr)
- srcBeing->setAction(BeingAction::CAST, skillId);
- skillDialog->playCastingDstTileEffect(skillId,
- skillLevel,
- dstX, dstY,
- castTime);
- if (srcBeing != nullptr)
- {
- srcBeing->addCast(dstX, dstY,
- skillId,
- skillLevel,
- range,
- castTime / MILLISECONDS_IN_A_TICK);
- }
- }
- if ((localPlayer != nullptr) &&
- srcBeing == localPlayer &&
- (inf2 & SkillType2::FreeCastAny) == 0)
- {
- localPlayer->freezeMoving(castTime / MILLISECONDS_IN_A_TICK);
- }
-}
-
-void BeingRecv::processBeingStatusChange(Net::MessageIn &msg)
-{
- BLOCK_START("BeingRecv::processBeingStatusChange")
- if (actorManager == nullptr)
- {
- BLOCK_END("BeingRecv::processBeingStatusChange")
- return;
- }
-
- // Status change
- const uint16_t status = msg.readInt16("status");
- const BeingId id = msg.readBeingId("being id");
- const Enable flag = fromBool(
- msg.readUInt8("flag: 0: stop, 1: start"), Enable);
- if (msg.getVersion() >= 20120618)
- msg.readInt32("total");
- if (msg.getVersion() >= 20090121)
- {
- msg.readInt32("left");
- msg.readInt32("val1");
- msg.readInt32("val2");
- msg.readInt32("val3");
- }
-
- const IsStart start = msg.getVersion() == 20090121 ?
- IsStart_false : IsStart_true;
-
- Being *const dstBeing = actorManager->findBeing(id);
- if (dstBeing != nullptr)
- dstBeing->setStatusEffect(status, flag, start);
- BLOCK_END("BeingRecv::processBeingStatusChange")
-}
-
-void BeingRecv::processBeingMove2(Net::MessageIn &msg)
-{
- BLOCK_START("BeingRecv::processBeingMove2")
- if (actorManager == nullptr)
- {
- BLOCK_END("BeingRecv::processBeingMove2")
- return;
- }
-
- /*
- * A simplified movement packet, used by the
- * later versions of eAthena for both mobs and
- * players
- */
- Being *const dstBeing = actorManager->findBeing(
- msg.readBeingId("being id"));
-
- uint16_t srcX, srcY, dstX, dstY;
- msg.readCoordinatePair(srcX, srcY, dstX, dstY, "move path");
- msg.readUInt8("(sx<<4) | (sy&0x0f)");
- msg.readInt32("tick");
-
- /*
- * This packet doesn't have enough info to actually
- * create a new being, so if the being isn't found,
- * we'll just pretend the packet didn't happen
- */
-
- if (dstBeing == nullptr)
- {
- BLOCK_END("BeingRecv::processBeingMove2")
- return;
- }
-
- dstBeing->setTileCoords(srcX, srcY);
- if (localPlayer != nullptr)
- localPlayer->followMoveTo(dstBeing, srcX, srcY, dstX, dstY);
- if (serverFeatures->haveMove3())
- dstBeing->setCachedDestination(dstX, dstY);
- else
- dstBeing->setDestination(dstX, dstY);
- if (dstBeing->getType() == ActorType::Player)
- dstBeing->setMoveTime();
- BLOCK_END("BeingRecv::processBeingMove2")
-}
-
-void BeingRecv::processBeingAction2(Net::MessageIn &msg)
-{
- BLOCK_START("BeingRecv::processBeingAction2")
- if (actorManager == nullptr)
- {
- BLOCK_END("BeingRecv::processBeingAction2")
- return;
- }
-
- Being *const srcBeing = actorManager->findBeing(
- msg.readBeingId("src being id"));
- Being *const dstBeing = actorManager->findBeing(
- msg.readBeingId("dst being id"));
-
- msg.readInt32("tick");
- const int srcSpeed = msg.readInt32("src speed");
- msg.readInt32("dst speed");
- int param1;
- if (msg.getVersion() >= 20071113)
- param1 = msg.readInt32("damage");
- else
- param1 = msg.readInt16("damage");
- if (msg.getVersion() >= 20131223)
- msg.readUInt8("is sp damaged");
- msg.readInt16("count");
- const AttackTypeT type = static_cast<AttackTypeT>(
- msg.readUInt8("action"));
- if (msg.getVersion() >= 20071113)
- msg.readInt32("left damage");
- else
- msg.readInt16("left damage");
-
- switch (type)
- {
- case AttackType::HIT: // Damage
- case AttackType::CRITICAL: // Critical Damage
- case AttackType::MULTI: // Critical Damage
- case AttackType::MULTI_REFLECT:
- case AttackType::REFLECT: // Reflected Damage
- case AttackType::FLEE: // Lucky Dodge
- case AttackType::SPLASH:
- case AttackType::SKILL:
- case AttackType::REPEATE:
- if (srcBeing != nullptr)
- {
- if (srcSpeed != 0 && srcBeing->getType() == ActorType::Player)
- srcBeing->setAttackDelay(srcSpeed);
- // attackid=1, type
- srcBeing->handleAttack(dstBeing, param1, 1);
- if (srcBeing->getType() == ActorType::Player)
- srcBeing->setAttackTime();
- }
- if (dstBeing != nullptr)
- {
- // level not present, using 1
- dstBeing->takeDamage(srcBeing, param1,
- static_cast<AttackTypeT>(type), 1);
- }
- break;
-
- case AttackType::PICKUP:
- break;
-
- case AttackType::TOUCH_SKILL:
- break;
-
- case AttackType::SIT:
- if (srcBeing != nullptr)
- {
- srcBeing->setAction(BeingAction::SIT, 0);
- if (srcBeing->getType() == ActorType::Player)
- {
- srcBeing->setMoveTime();
- if (localPlayer != nullptr)
- localPlayer->imitateAction(srcBeing, BeingAction::SIT);
- }
- }
- break;
-
- case AttackType::STAND:
- if (srcBeing != nullptr)
- {
- srcBeing->setAction(BeingAction::STAND, 0);
- if (srcBeing->getType() == ActorType::Player)
- {
- srcBeing->setMoveTime();
- if (localPlayer != nullptr)
- {
- localPlayer->imitateAction(srcBeing,
- BeingAction::STAND);
- }
- }
- }
- break;
- default:
- case AttackType::MISS:
- case AttackType::SKILLMISS:
- UNIMPLEMENTEDPACKETFIELD(CAST_S32(type));
- break;
- }
- BLOCK_END("BeingRecv::processBeingAction2")
-}
-
-void BeingRecv::processBeingHp(Net::MessageIn &msg)
-{
- Being *const dstBeing = actorManager->findBeing(
- msg.readBeingId("being id"));
- int hp;
- int maxHP;
- if (msg.getVersion() >= 20100126)
- {
- hp = msg.readInt32("hp");
- maxHP = msg.readInt32("max hp");
- }
- else
- {
- hp = msg.readInt16("hp");
- maxHP = msg.readInt16("max hp");
- }
- if (dstBeing != nullptr)
- {
- dstBeing->setHP(hp);
- dstBeing->setMaxHP(maxHP);
- }
-}
-
-void BeingRecv::processMonsterHp(Net::MessageIn &msg)
-{
- Being *const dstBeing = actorManager->findBeing(
- msg.readBeingId("monster id"));
- const int hp = msg.readInt32("hp");
- const int maxHP = msg.readInt32("max hp");
- if (dstBeing != nullptr)
- {
- dstBeing->setHP(hp);
- dstBeing->setMaxHP(maxHP);
- }
-}
-
-void BeingRecv::processSkillAutoCast(Net::MessageIn &msg)
-{
- const int id = msg.readInt16("skill id");
- msg.readInt16("inf");
- msg.readInt16("unused");
- const int level = msg.readInt16("skill level");
- msg.readInt16("sp");
- msg.readInt16("range");
- msg.readString(24, "skill name");
- msg.readInt8("unused");
-
- if (localPlayer != nullptr)
- {
- localPlayer->handleSkill(localPlayer, 0, id, level);
- localPlayer->takeDamage(localPlayer, 0, AttackType::SKILL, id, level);
- }
-}
-
-void BeingRecv::processRanksList(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- // +++ here need window with rank tables.
- msg.readInt16("rank type");
- for (int f = 0; f < 10; f ++)
- msg.readString(24, "name");
- for (int f = 0; f < 10; f ++)
- msg.readInt32("points");
- msg.readInt32("my points");
-}
-
-void BeingRecv::processBlacksmithRanksList(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- // +++ here need window with rank tables.
- for (int f = 0; f < 10; f ++)
- msg.readString(24, "name");
- for (int f = 0; f < 10; f ++)
- msg.readInt32("points");
-}
-
-void BeingRecv::processAlchemistRanksList(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- // +++ here need window with rank tables.
- for (int f = 0; f < 10; f ++)
- msg.readString(24, "name");
- for (int f = 0; f < 10; f ++)
- msg.readInt32("points");
-}
-
-void BeingRecv::processTaekwonRanksList(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- // +++ here need window with rank tables.
- for (int f = 0; f < 10; f ++)
- msg.readString(24, "name");
- for (int f = 0; f < 10; f ++)
- msg.readInt32("points");
-}
-
-void BeingRecv::processPkRanksList(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- // +++ here need window with rank tables.
- for (int f = 0; f < 10; f ++)
- msg.readString(24, "name");
- for (int f = 0; f < 10; f ++)
- msg.readInt32("points");
-}
-
-void BeingRecv::processBeingChangeDirection(Net::MessageIn &msg)
-{
- BLOCK_START("BeingRecv::processBeingChangeDirection")
- if (actorManager == nullptr)
- {
- BLOCK_END("BeingRecv::processBeingChangeDirection")
- return;
- }
-
- Being *const dstBeing = actorManager->findBeing(
- msg.readBeingId("being id"));
-
- msg.readInt16("head direction");
-
- const uint8_t dir = Net::MessageIn::fromServerDirection(
- CAST_U8(msg.readUInt8("player direction") & 0x0FU));
-
- if (dstBeing == nullptr)
- {
- BLOCK_END("BeingRecv::processBeingChangeDirection")
- return;
- }
-
- dstBeing->setDirection(dir);
- if (localPlayer != nullptr)
- localPlayer->imitateDirection(dstBeing, dir);
- BLOCK_END("BeingRecv::processBeingChangeDirection")
-}
-
-void BeingRecv::processBeingSpecialEffect(Net::MessageIn &msg)
-{
- if ((effectManager == nullptr) || (actorManager == nullptr))
- return;
-
- const BeingId id = msg.readBeingId("being id");
- Being *const being = actorManager->findBeing(id);
- if (being == nullptr)
- return;
-
- const int effectType = msg.readInt32("effect type");
-
- if (ParticleEngine::enabled)
- effectManager->trigger(effectType, being);
-
- // +++ need dehard code effectType == 3
- if (effectType == 3 && being->getType() == ActorType::Player
- && (socialWindow != nullptr))
- { // reset received damage
- socialWindow->resetDamage(being->getName());
- }
-}
-
-void BeingRecv::processBeingSpecialEffectNum(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- // +++ need somhow show this effects.
- // type is not same with self/misc effect.
- msg.readBeingId("account id");
- msg.readInt32("effect type");
- msg.readInt32("num"); // effect variable
-}
-
-void BeingRecv::processBeingSoundEffect(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- // +++ need play this effect.
- msg.readString(24, "sound effect name");
- msg.readUInt8("type");
- msg.readInt32("unused");
- msg.readInt32("source being id");
-}
-
-void BeingRecv::processSkillGroundNoDamage(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readInt16("skill id");
- msg.readInt32("src id");
- msg.readInt16("val");
- msg.readInt16("x");
- msg.readInt16("y");
- msg.readInt32("tick");
-}
-
-void BeingRecv::processSkillEntry(Net::MessageIn &msg)
-{
- if (msg.getVersion() >= 20110718)
- msg.readInt16("len");
- const BeingId id = msg.readBeingId("skill unit id");
- const BeingId creatorId = msg.readBeingId("creator accound id");
- const int x = msg.readInt16("x");
- const int y = msg.readInt16("y");
- int job = 0;
- if (msg.getVersion() >= 20121212)
- job = msg.readInt32("job");
- if (msg.getVersion() >= 20110718)
- msg.readUInt8("radius");
- msg.readUInt8("visible");
- int level = 0;
- if (msg.getVersion() >= 20130731)
- level = msg.readUInt8("level");
- Being *const dstBeing = createBeing2(msg,
- id,
- job,
- BeingType::SKILL);
- if (dstBeing == nullptr)
- return;
- dstBeing->setAction(BeingAction::STAND, 0);
- dstBeing->setTileCoords(x, y);
- dstBeing->setLevel(level);
- dstBeing->setCreatorId(creatorId);
-}
-
-void BeingRecv::processPlayerStatusChange(Net::MessageIn &msg)
-{
- BLOCK_START("BeingRecv::processPlayerStop")
- if (actorManager == nullptr)
- {
- BLOCK_END("BeingRecv::processPlayerStop")
- return;
- }
-
- // Change in players' flags
- const BeingId id = msg.readBeingId("account id");
- Being *const dstBeing = actorManager->findBeing(id);
- if (dstBeing == nullptr)
- {
- msg.readInt16("opt1");
- msg.readInt16("opt2");
- if (msg.getVersion() >= 7)
- msg.readInt32("option");
- else
- msg.readInt16("option");
- msg.readUInt8("karma");
- return;
- }
-
- const uint32_t opt1 = msg.readInt16("opt1");
- const uint32_t opt2 = msg.readInt16("opt2");
- uint32_t option;
- if (msg.getVersion() >= 7)
- option = msg.readInt32("option");
- else
- option = msg.readInt16("option");
- dstBeing->setKarma(msg.readUInt8("karma"));
-
- dstBeing->setStatusEffectOpitons(option,
- opt1,
- opt2);
- BLOCK_END("BeingRecv::processPlayerStop")
-}
-
-void BeingRecv::processPlayerStatusChange2(Net::MessageIn &msg)
-{
- if (actorManager == nullptr)
- return;
-
- // look like this function unused on server
-
- const BeingId id = msg.readBeingId("account id");
- Being *const dstBeing = actorManager->findBeing(id);
- if (dstBeing == nullptr)
- return;
-
- const uint32_t option = msg.readInt32("option");
- dstBeing->setLevel(msg.readInt32("level"));
- msg.readInt32("showEFST");
- dstBeing->setStatusEffectOpiton0(option);
-}
-
-void BeingRecv::processBeingResurrect(Net::MessageIn &msg)
-{
- BLOCK_START("BeingRecv::processBeingResurrect")
- if (actorManager == nullptr ||
- localPlayer == nullptr)
- {
- BLOCK_END("BeingRecv::processBeingResurrect")
- return;
- }
-
- // A being changed mortality status
-
- const BeingId id = msg.readBeingId("being id");
- msg.readInt16("unused");
- Being *const dstBeing = actorManager->findBeing(id);
- if (dstBeing == nullptr)
- {
- DEBUGLOGSTR("insible player?");
- BLOCK_END("BeingRecv::processBeingResurrect")
- return;
- }
-
- // If this is player's current target, clear it.
- if (dstBeing == localPlayer->getTarget())
- localPlayer->stopAttack();
- if (dstBeing == localPlayer &&
- deathNotice != nullptr)
- {
- deathNotice->scheduleDelete();
- deathNotice = nullptr;
- }
-
- dstBeing->setAction(BeingAction::STAND, 0);
- BLOCK_END("BeingRecv::processBeingResurrect")
-}
-
-void BeingRecv::processPlayerGuilPartyInfo(Net::MessageIn &msg)
-{
- BLOCK_START("BeingRecv::processPlayerGuilPartyInfo")
- if (actorManager == nullptr)
- {
- BLOCK_END("BeingRecv::processPlayerGuilPartyInfo")
- return;
- }
-
- const BeingId beingId = msg.readBeingId("being id");
- const std::string name = msg.readString(24, "char name");
- actorManager->updateNameId(name, beingId);
- Being *const dstBeing = actorManager->findBeing(beingId);
- if (dstBeing != nullptr)
- {
- if (beingId == localPlayer->getId())
- {
- localPlayer->pingResponse();
- }
- dstBeing->setName(name);
- dstBeing->setPartyName(msg.readString(24, "party name"));
- dstBeing->setGuildName(msg.readString(24, "guild name"));
- dstBeing->setGuildPos(msg.readString(24, "guild pos"));
- dstBeing->addToCache();
- }
- else
- {
- msg.readString(24, "party name");
- msg.readString(24, "guild name");
- msg.readString(24, "guild pos");
- }
- BLOCK_END("BeingRecv::processPlayerGuilPartyInfo")
-}
-
-void BeingRecv::processBeingRemoveSkill(Net::MessageIn &msg)
-{
- const BeingId id = msg.readBeingId("skill unit id");
- if (actorManager == nullptr)
- return;
- Being *const dstBeing = actorManager->findBeing(id);
- if (dstBeing == nullptr)
- return;
- actorManager->destroy(dstBeing);
-}
-
-void BeingRecv::processBeingFakeName(Net::MessageIn &msg)
-{
- uint16_t x, y;
- uint8_t dir;
- if (msg.getVersion() < 20071106)
- {
- msg.readBeingId("npc id");
- msg.skip(8, "unused");
- msg.readInt16("class?"); // 111
- msg.skip(30, "unused");
- msg.readCoordinates(x, y, dir, "position");
- msg.readUInt8("sx");
- msg.readUInt8("sy");
- msg.skip(3, "unused");
- return;
- }
- const BeingTypeT type = static_cast<BeingTypeT>(
- msg.readUInt8("object type"));
- const BeingId id = msg.readBeingId("npc id");
- msg.skip(8, "unused");
- const uint16_t job = msg.readInt16("class?"); // 111
- msg.skip(30, "unused");
- msg.readCoordinates(x, y, dir, "position");
- msg.readUInt8("sx");
- msg.readUInt8("sy");
- msg.skip(3, "unused");
-
- Being *const dstBeing = createBeing2(msg, id, job, type);
- if (dstBeing == nullptr)
- return;
- dstBeing->setSubtype(fromInt(job, BeingTypeId), 0);
- dstBeing->setTileCoords(x, y);
- dstBeing->setDirection(dir);
-}
-
-void BeingRecv::processBeingStatUpdate1(Net::MessageIn &msg)
-{
- const BeingId id = msg.readBeingId("account id");
- const int type = msg.readInt16("type");
- const int value = msg.readInt32("value");
-
- Being *const dstBeing = actorManager->findBeing(id);
- if (dstBeing == nullptr)
- return;
-
- if (type != Sp::MANNER)
- {
- UNIMPLEMENTEDPACKETFIELD(type);
- return;
- }
- dstBeing->setManner(value);
-}
-
-void BeingRecv::processBeingSelfEffect(Net::MessageIn &msg)
-{
- BLOCK_START("BeingRecv::processBeingSelfEffect")
- if ((effectManager == nullptr) || (actorManager == nullptr))
- {
- BLOCK_END("BeingRecv::processBeingSelfEffect")
- return;
- }
-
- const BeingId id = msg.readBeingId("being id");
- Being *const being = actorManager->findBeing(id);
- if (being == nullptr)
- {
- DEBUGLOGSTR("insible player?");
- msg.readInt32("effect type");
- BLOCK_END("BeingRecv::processBeingSelfEffect")
- return;
- }
-
- const int effectType = msg.readInt32("effect type");
- if (ParticleEngine::enabled)
- effectManager->trigger(effectType, being);
-
- BLOCK_END("BeingRecv::processBeingSelfEffect")
-}
-
-void BeingRecv::processMobInfo(Net::MessageIn &msg)
-{
- const int len = msg.readInt16("len");
- if (len < 12)
- return;
- Being *const dstBeing = actorManager->findBeing(
- msg.readBeingId("monster id"));
- const int attackRange = msg.readInt32("range");
- if (dstBeing != nullptr)
- dstBeing->setAttackRange(attackRange);
-}
-
-void BeingRecv::processBeingAttrs(Net::MessageIn &msg)
-{
- const int len = msg.readInt16("len");
- if (len < 14)
- return;
-
- Being *const dstBeing = actorManager->findBeing(
- msg.readBeingId("player id"));
- const int groupId = msg.readInt32("group id");
- uint16_t mount = 0;
- mount = msg.readInt16("mount");
- int language = -1;
- if (serverVersion >= 17 && len > 14)
- language = msg.readInt16("language");
- if (dstBeing != nullptr)
- {
- if (serverVersion <= 17 ||
- dstBeing != localPlayer)
- {
- dstBeing->setGroupId(groupId);
- if (groupId != 0)
- dstBeing->setGM(true);
- else
- dstBeing->setGM(false);
- }
- dstBeing->setHorse(mount);
- dstBeing->setLanguageId(language);
- if (dstBeing == localPlayer)
- PlayerInfo::setServerLanguage(language);
- }
-}
-
-void BeingRecv::processMonsterInfo(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
-
- msg.readInt16("class");
- msg.readInt16("level");
- msg.readInt16("size");
- msg.readInt32("hp");
- msg.readInt16("def");
- msg.readInt16("race");
- msg.readInt16("mdef");
- msg.readInt16("ele");
-}
-
-void BeingRecv::processClassChange(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
-
- msg.readBeingId("being id");
- msg.readUInt8("type");
- msg.readInt32("class");
-}
-
-void BeingRecv::processSpiritBalls(Net::MessageIn &msg)
-{
- Being *const dstBeing = actorManager->findBeing(
- msg.readBeingId("being id"));
- const int balls = msg.readInt16("spirits amount");
- if (dstBeing != nullptr)
- dstBeing->setSpiritBalls(balls);
-}
-
-void BeingRecv::processBladeStop(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
-
- msg.readInt32("src being id");
- msg.readInt32("dst being id");
- msg.readInt32("flag");
-}
-
-void BeingRecv::processComboDelay(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
-
- msg.readBeingId("being id");
- msg.readInt32("wait");
-}
-
-void BeingRecv::processWddingEffect(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
-
- msg.readBeingId("being id");
-}
-
-void BeingRecv::processBeingSlide(Net::MessageIn &msg)
-{
- Being *const dstBeing = actorManager->findBeing(
- msg.readBeingId("being id"));
- const int x = msg.readInt16("x");
- const int y = msg.readInt16("y");
- if (dstBeing == nullptr)
- return;
- if (localPlayer == dstBeing)
- {
- localPlayer->stopAttack();
- localPlayer->navigateClean();
- if (viewport != nullptr)
- viewport->returnCamera();
- }
-
- dstBeing->setAction(BeingAction::STAND, 0);
- dstBeing->setTileCoords(x, y);
-}
-
-void BeingRecv::processStarsKill(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
-
- msg.readString(24, "map name");
- msg.readInt32("monster id");
- msg.readUInt8("start");
- msg.readUInt8("result");
-}
-
-void BeingRecv::processGladiatorFeelRequest(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
-
- msg.readUInt8("which");
-}
-
-void BeingRecv::processBossMapInfo(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
-
- msg.readUInt8("info type");
- msg.readInt32("x");
- msg.readInt32("y");
- msg.readInt16("min hours");
- msg.readInt16("min minutes");
- msg.readInt16("max hours");
- msg.readInt16("max minutes");
- msg.readString(24, "monster name"); // really can be used 51 byte?
-}
-
-void BeingRecv::processBeingFont(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
-
- msg.readBeingId("account id");
- msg.readInt16("font");
-}
-
-void BeingRecv::processBeingMilleniumShield(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
-
- msg.readBeingId("account id");
- msg.readInt16("shields");
- msg.readInt16("unused");
-}
-
-void BeingRecv::processBeingCharm(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
-
- msg.readBeingId("account id");
- msg.readInt16("charm type");
- msg.readInt16("charm count");
-}
-
-void BeingRecv::processBeingViewEquipment(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
-
- const int count = (msg.readInt16("len") - 45) / 31;
- msg.readString(24, "name");
- msg.readInt16("job");
- msg.readInt16("head");
- msg.readInt16("accessory");
- msg.readInt16("accessory2");
- msg.readInt16("accessory3");
- if (msg.getVersion() >= 20101124)
- msg.readInt16("robe");
- msg.readInt16("hair color");
- msg.readInt16("body color");
- msg.readUInt8("gender");
- for (int f = 0; f < count; f ++)
- {
- msg.readInt16("index");
- msg.readInt16("item id");
- msg.readUInt8("item type");
- msg.readInt32("location");
- msg.readInt32("wear state");
- msg.readInt8("refine");
- for (int d = 0; d < maxCards; d ++)
- msg.readUInt16("card");
- msg.readInt32("hire expire date (?)");
- msg.readInt16("equip type");
- msg.readInt16("item sprite number");
- msg.readUInt8("flags");
- }
-}
-
-void BeingRecv::processPvpSet(Net::MessageIn &msg)
-{
- BLOCK_START("BeingRecv::processPvpSet")
- const BeingId id = msg.readBeingId("being id");
- const int rank = msg.readInt32("rank");
- msg.readInt32("num");
- if (actorManager != nullptr)
- {
- Being *const dstBeing = actorManager->findBeing(id);
- if (dstBeing != nullptr)
- dstBeing->setPvpRank(rank);
- }
- BLOCK_END("BeingRecv::processPvpSet")
-}
-
-void BeingRecv::processNameResponse2(Net::MessageIn &msg)
-{
- BLOCK_START("BeingRecv::processNameResponse2")
- if ((actorManager == nullptr) || (localPlayer == nullptr))
- {
- BLOCK_END("BeingRecv::processNameResponse2")
- return;
- }
-
- const int len = msg.readInt16("len");
- const BeingId beingId = msg.readBeingId("account id");
- const std::string str = msg.readString(len - 8, "name");
- actorManager->updateNameId(str, beingId);
- Being *const dstBeing = actorManager->findBeing(beingId);
- if (dstBeing != nullptr)
- {
- if (beingId == localPlayer->getId())
- {
- localPlayer->pingResponse();
- }
- else
- {
- dstBeing->setName(str);
- dstBeing->updateGuild();
- dstBeing->addToCache();
-
- if (dstBeing->getType() == ActorType::Player)
- dstBeing->updateColors();
-
- if (localPlayer != nullptr)
- {
- const Party *const party = localPlayer->getParty();
- if (party != nullptr && party->isMember(dstBeing->getId()))
- {
- PartyMember *const member = party->getMember(
- dstBeing->getId());
-
- if (member != nullptr)
- member->setName(dstBeing->getName());
- }
- localPlayer->checkNewName(dstBeing);
- }
- }
- }
- BLOCK_END("BeingRecv::processNameResponse2")
-}
-
-Being *BeingRecv::createBeing2(Net::MessageIn &msg,
- const BeingId id,
- const int32_t job,
- const BeingTypeT beingType)
-{
- if (actorManager == nullptr)
- return nullptr;
-
- ActorTypeT type = ActorType::Unknown;
- switch (beingType)
- {
- case BeingType::PC:
- type = ActorType::Player;
- break;
- case BeingType::NPC:
- case BeingType::NPC_EVENT:
- type = ActorType::Npc;
- break;
- case BeingType::MONSTER:
- type = ActorType::Monster;
- break;
- case BeingType::MERSOL:
- type = ActorType::Mercenary;
- break;
- case BeingType::PET:
- type = ActorType::Pet;
- break;
- case BeingType::HOMUN:
- type = ActorType::Homunculus;
- break;
- case BeingType::SKILL:
- type = ActorType::SkillUnit;
- break;
- case BeingType::ELEMENTAL:
- type = ActorType::Elemental;
- break;
- case BeingType::ITEM:
- logger->log("not supported object type: %d, job: %d",
- CAST_S32(beingType), CAST_S32(job));
- break;
- case BeingType::CHAT:
- default:
- UNIMPLEMENTEDPACKETFIELD(CAST_S32(beingType));
- type = ActorType::Monster;
- logger->log("not supported object type: %d, job: %d",
- CAST_S32(beingType), CAST_S32(job));
- break;
- }
- if (job == 45 && beingType == BeingType::NPC_EVENT)
- type = ActorType::Portal;
-
- Being *const being = actorManager->createBeing(
- id, type, fromInt(job, BeingTypeId));
- if (beingType == BeingType::MERSOL)
- {
- const MercenaryInfo *const info = PlayerInfo::getMercenary();
- if ((info != nullptr) && info->id == id)
- PlayerInfo::setMercenaryBeing(being);
- }
- else if (beingType == BeingType::PET)
- {
- if (PlayerInfo::getPetBeingId() == id)
- PlayerInfo::setPetBeing(being);
- }
- return being;
-}
-
-void BeingRecv::processSkillCancel(Net::MessageIn &msg)
-{
- msg.readInt32("id?");
-}
-
-void BeingRecv::processSolveCharName(Net::MessageIn &msg)
-{
- const int id = msg.readInt32("char id");
- if (actorManager == nullptr)
- {
- msg.readString(24, "name");
- return;
- }
- actorManager->addChar(id, msg.readString(24, "name"));
-}
-
-void BeingRecv::processGraffiti(Net::MessageIn &msg)
-{
- const BeingId id = msg.readBeingId("graffiti id");
- const BeingId creatorId = msg.readBeingId("creator id");
- const int x = msg.readInt16("x");
- const int y = msg.readInt16("y");
- const int job = msg.readUInt8("job");
- msg.readUInt8("visible");
- msg.readUInt8("is content");
- const std::string text = msg.readString(80, "text");
-
- Being *const dstBeing = createBeing2(msg, id, job, BeingType::SKILL);
- if (dstBeing == nullptr)
- return;
-
- dstBeing->setAction(BeingAction::STAND, 0);
- dstBeing->setTileCoords(x, y);
- dstBeing->setShowName(true);
- dstBeing->setName(text);
- dstBeing->setCreatorId(creatorId);
-}
-
-void BeingRecv::processSkillDamage(Net::MessageIn &msg)
-{
- BLOCK_START("BeingRecv::processSkillDamage")
- if (actorManager == nullptr)
- {
- BLOCK_END("BeingRecv::processSkillDamage")
- return;
- }
-
- const int id = msg.readInt16("skill id");
- Being *const srcBeing = actorManager->findBeing(
- msg.readBeingId("src being id"));
- Being *const dstBeing = actorManager->findBeing(
- msg.readBeingId("dst being id"));
- msg.readInt32("tick");
- msg.readInt32("src speed");
- msg.readInt32("dst speed");
- int param1;
- if (msg.getVersion() >= 3)
- param1 = msg.readInt32("damage");
- else
- param1 = msg.readInt16("damage");
- const int level = msg.readInt16("skill level");
- msg.readInt16("div");
- msg.readUInt8("skill hit/type?");
- if (srcBeing != nullptr)
- srcBeing->handleSkill(dstBeing, param1, id, level);
- if (dstBeing != nullptr)
- dstBeing->takeDamage(srcBeing, param1, AttackType::SKILL, id, level);
- BLOCK_END("BeingRecv::processSkillDamage")
-}
-
-void BeingRecv::processNavigateTo(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- // 0 position
- // 1 no position
- // 3 monster
- msg.readUInt8("navigate type");
- msg.readUInt8("transportation flag");
- msg.readUInt8("hide window");
- msg.readString(16, "map name");
- msg.readInt16("x");
- msg.readInt16("y");
- msg.readInt16("mob id");
-}
-
-void BeingRecv::applyPlayerAction(Net::MessageIn &msg,
- Being *const being,
- const uint8_t type)
-{
- if (being == nullptr)
- return;
- switch (type)
- {
- case 0:
- being->setAction(BeingAction::STAND, 0);
- localPlayer->imitateAction(being, BeingAction::STAND);
- break;
-
- case 1:
- if (being->getCurrentAction() != BeingAction::DEAD)
- {
- being->setAction(BeingAction::DEAD, 0);
- being->recalcSpritesOrder();
- }
- break;
-
- case 2:
- being->setAction(BeingAction::SIT, 0);
- localPlayer->imitateAction(being, BeingAction::SIT);
- break;
-
- default:
- UNIMPLEMENTEDPACKETFIELD(type);
- break;
- }
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/beingrecv.h b/src/net/eathena/beingrecv.h
deleted file mode 100644
index b70d1f7fb..000000000
--- a/src/net/eathena/beingrecv.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 NET_EATHENA_BEINGRECV_H
-#define NET_EATHENA_BEINGRECV_H
-
-#include "enums/net/beingtype.h"
-
-#include "enums/resources/skill/skilltype2.h"
-
-#include "enums/simpletypes/beingid.h"
-
-#if defined(__GXX_EXPERIMENTAL_CXX0X__)
-#if defined(__APPLE__)
-#include <tr1/cstdint>
-#endif // defined(__APPLE__)
-#endif // defined(__GXX_EXPERIMENTAL_CXX0X__)
-
-#include "localconsts.h"
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-class Being;
-
-namespace EAthena
-{
- namespace BeingRecv
- {
- void processBeingChangeLook2(Net::MessageIn &msg);
- void processBeingChangeLookCards(Net::MessageIn &msg);
- void processBeingVisible(Net::MessageIn &msg);
- void processBeingMove(Net::MessageIn &msg);
- void processBeingSpawn(Net::MessageIn &msg);
- void processMapTypeProperty(Net::MessageIn &msg);
- void processMapType(Net::MessageIn &msg);
- void processSkillCasting(Net::MessageIn &msg);
- void processSkillCasting2(Net::MessageIn &msg);
- void processBeingStatusChange(Net::MessageIn &msg);
- void processBeingMove2(Net::MessageIn &msg);
- void processBeingAction2(Net::MessageIn &msg);
- void processMonsterHp(Net::MessageIn &msg);
- void processBeingHp(Net::MessageIn &msg);
- void processSkillAutoCast(Net::MessageIn &msg);
- void processRanksList(Net::MessageIn &msg);
- void processBeingChangeDirection(Net::MessageIn &msg);
- void processBeingChangeLookContinue(const Net::MessageIn &msg,
- Being *const dstBeing,
- const uint8_t type,
- const int id,
- const int id2,
- const int *const cards)
- A_NONNULL(2);
- void processBeingSpecialEffect(Net::MessageIn &msg);
- void processBeingSpecialEffectNum(Net::MessageIn &msg);
- void processBeingSoundEffect(Net::MessageIn &msg);
- void processSkillGroundNoDamage(Net::MessageIn &msg);
- void processSkillEntry(Net::MessageIn &msg);
- void processPlayerStatusChange(Net::MessageIn &msg);
- void processBeingResurrect(Net::MessageIn &msg);
- void processPlayerGuilPartyInfo(Net::MessageIn &msg);
- void processBeingRemoveSkill(Net::MessageIn &msg);
- void processBeingFakeName(Net::MessageIn &msg);
- void processBeingStatUpdate1(Net::MessageIn &msg);
- void processPlayerStatusChange2(Net::MessageIn &msg);
- void processBeingSelfEffect(Net::MessageIn &msg);
- void processMobInfo(Net::MessageIn &msg);
- void processBeingAttrs(Net::MessageIn &msg);
- void processMonsterInfo(Net::MessageIn &msg);
- void processClassChange(Net::MessageIn &msg);
- void processSpiritBalls(Net::MessageIn &msg);
- void processBladeStop(Net::MessageIn &msg);
- void processComboDelay(Net::MessageIn &msg);
- void processWddingEffect(Net::MessageIn &msg);
- void processBeingSlide(Net::MessageIn &msg);
- void processStarsKill(Net::MessageIn &msg);
- void processBlacksmithRanksList(Net::MessageIn &msg);
- void processAlchemistRanksList(Net::MessageIn &msg);
- void processTaekwonRanksList(Net::MessageIn &msg);
- void processPkRanksList(Net::MessageIn &msg);
- void processGladiatorFeelRequest(Net::MessageIn &msg);
- void processBossMapInfo(Net::MessageIn &msg);
- void processBeingFont(Net::MessageIn &msg);
- void processBeingMilleniumShield(Net::MessageIn &msg);
- void processBeingCharm(Net::MessageIn &msg);
- void processBeingViewEquipment(Net::MessageIn &msg);
- void processPvpSet(Net::MessageIn &msg);
- void processNameResponse2(Net::MessageIn &msg);
- void processSkillCancel(Net::MessageIn &msg);
- void processSolveCharName(Net::MessageIn &msg);
- void processGraffiti(Net::MessageIn &msg);
- void processSkillDamage(Net::MessageIn &msg);
- void processNavigateTo(Net::MessageIn &msg);
-
- Being *createBeing2(Net::MessageIn &msg,
- const BeingId id,
- const int32_t job,
- const BeingTypeT beingType);
- void applyPlayerAction(Net::MessageIn &msg,
- Being *const being,
- const uint8_t type);
- void processSkillCastingContinue(Net::MessageIn &msg,
- const BeingId srcId,
- const BeingId dstId,
- const int dstX,
- const int dstY,
- const int skillId,
- const int skillLevel,
- const int range,
- const SkillType2::SkillType2 inf2,
- const int castTime);
- } // namespace BeingRecv
-} // namespace EAthena
-
-#endif // NET_EATHENA_BEINGRECV_H
diff --git a/src/net/eathena/buyingstorehandler.cpp b/src/net/eathena/buyingstorehandler.cpp
deleted file mode 100644
index c4d172b89..000000000
--- a/src/net/eathena/buyingstorehandler.cpp
+++ /dev/null
@@ -1,112 +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 "net/eathena/buyingstorehandler.h"
-
-#include "being/being.h"
-#include "being/playerinfo.h"
-
-#include "const/net/inventory.h"
-
-#include "net/eathena/messageout.h"
-#include "net/eathena/protocolout.h"
-
-#include "utils/foreach.h"
-
-#include "resources/item/shopitem.h"
-
-#include "debug.h"
-
-extern int packetVersion;
-
-namespace EAthena
-{
-
-BuyingStoreHandler::BuyingStoreHandler()
-{
- buyingStoreHandler = this;
-}
-
-BuyingStoreHandler::~BuyingStoreHandler()
-{
- buyingStoreHandler = nullptr;
-}
-
-void BuyingStoreHandler::create(const std::string &name,
- const int maxMoney,
- const bool flag,
- const STD_VECTOR<ShopItem*> &items) const
-{
- if (packetVersion < 20100303)
- return;
- createOutPacket(CMSG_BUYINGSTORE_CREATE);
- outMsg.writeInt16(CAST_S16(89 + items.size() * 8), "len");
- outMsg.writeInt32(maxMoney, "limit money");
- outMsg.writeInt8(static_cast<int8_t>(flag), "flag");
- outMsg.writeString(name, 80, "store name");
- FOR_EACH (STD_VECTOR<ShopItem*>::const_iterator, it, items)
- {
- const ShopItem *const item = *it;
- outMsg.writeInt16(CAST_S16(item->getId()), "item id");
- outMsg.writeInt16(CAST_S16(item->getQuantity()), "amount");
- outMsg.writeInt32(item->getPrice(), "price");
- }
-}
-
-void BuyingStoreHandler::close() const
-{
- if (packetVersion < 20100420)
- return;
- createOutPacket(CMSG_BUYINGSTORE_CLOSE);
- PlayerInfo::enableVending(false);
-}
-
-void BuyingStoreHandler::open(const Being *const being) const
-{
- if (being == nullptr)
- return;
- if (packetVersion < 20100420)
- return;
- createOutPacket(CMSG_BUYINGSTORE_OPEN);
- outMsg.writeBeingId(being->getId(), "account id");
-}
-
-void BuyingStoreHandler::sell(const Being *const being,
- const int storeId,
- const Item *const item,
- const int amount) const
-{
- if ((being == nullptr) || (item == nullptr))
- return;
- if (packetVersion < 20100420)
- return;
-
- createOutPacket(CMSG_BUYINGSTORE_SELL);
- outMsg.writeInt16(18, "len");
- outMsg.writeBeingId(being->getId(), "account id");
- outMsg.writeInt32(storeId, "store id");
- outMsg.writeInt16(CAST_S16(
- item->getInvIndex() + INVENTORY_OFFSET),
- "index");
- outMsg.writeInt16(CAST_S16(item->getId()), "item id");
- outMsg.writeInt16(CAST_S16(amount), "amount");
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/buyingstorehandler.h b/src/net/eathena/buyingstorehandler.h
deleted file mode 100644
index 8aed152c9..000000000
--- a/src/net/eathena/buyingstorehandler.h
+++ /dev/null
@@ -1,54 +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 NET_EATHENA_BUYINGSTOREHANDLER_H
-#define NET_EATHENA_BUYINGSTOREHANDLER_H
-
-#include "net/buyingstorehandler.h"
-
-namespace EAthena
-{
-class BuyingStoreHandler final : public Net::BuyingStoreHandler
-{
- public:
- BuyingStoreHandler();
-
- A_DELETE_COPY(BuyingStoreHandler)
-
- ~BuyingStoreHandler();
-
- void create(const std::string &name,
- const int maxMoney,
- const bool flag,
- const STD_VECTOR<ShopItem*> &items) const override final;
-
- void close() const override final;
-
- void open(const Being *const being) const override final;
-
- void sell(const Being *const being,
- const int storeId,
- const Item *const item,
- const int amount) const override final;
-};
-
-} // namespace EAthena
-
-#endif // NET_EATHENA_BUYINGSTOREHANDLER_H
diff --git a/src/net/eathena/buyingstorerecv.cpp b/src/net/eathena/buyingstorerecv.cpp
deleted file mode 100644
index bf5d2032b..000000000
--- a/src/net/eathena/buyingstorerecv.cpp
+++ /dev/null
@@ -1,238 +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 "net/eathena/buyingstorerecv.h"
-
-#include "actormanager.h"
-#include "notifymanager.h"
-
-#include "being/localplayer.h"
-#include "being/playerinfo.h"
-
-#include "const/net/inventory.h"
-
-#include "enums/resources/notifytypes.h"
-
-#include "gui/windows/buyingstoreselldialog.h"
-
-#include "gui/widgets/createwidget.h"
-
-#include "listeners/arrowslistener.h"
-#include "listeners/buyingstoremodelistener.h"
-#include "listeners/buyingstoreslotslistener.h"
-
-#include "net/messagein.h"
-
-#include "resources/inventory/inventory.h"
-
-#include "resources/item/item.h"
-
-#include "debug.h"
-
-namespace EAthena
-{
-
-void BuyingStoreRecv::processBuyingStoreOpen(Net::MessageIn &msg)
-{
- BuyingStoreSlotsListener::distributeEvent(msg.readUInt8("slots"));
-}
-
-void BuyingStoreRecv::processBuyingStoreCreateFailed(Net::MessageIn &msg)
-{
- const int16_t result = msg.readInt16("result");
- const int weight = msg.readInt32("weight");
- switch (result)
- {
- case 1:
- default:
- NotifyManager::notify(NotifyTypes::BUYING_STORE_CREATE_FAILED);
- break;
- case 2:
- NotifyManager::notify(
- NotifyTypes::BUYING_STORE_CREATE_FAILED_WEIGHT,
- weight);
- break;
- case 8:
- NotifyManager::notify(NotifyTypes::BUYING_STORE_CREATE_EMPTY);
- break;
- }
-}
-
-void BuyingStoreRecv::processBuyingStoreOwnItems(Net::MessageIn &msg)
-{
- const int count = (msg.readInt16("len") - 12) / 9;
- msg.readBeingId("account id");
- msg.readInt32("money limit");
- for (int f = 0; f < count; f ++)
- {
- msg.readInt32("price");
- msg.readInt16("amount");
- msg.readUInt8("item type");
- msg.readInt16("item id");
- }
- PlayerInfo::enableVending(true);
- BuyingStoreModeListener::distributeEvent(true);
-}
-
-void BuyingStoreRecv::processBuyingStoreShowBoard(Net::MessageIn &msg)
-{
- const BeingId id = msg.readBeingId("owner id");
- Being *const dstBeing = actorManager->findBeing(id);
- if (dstBeing != nullptr)
- {
- dstBeing->setBuyBoard(msg.readString(80, "shop name"));
- }
- else
- {
- msg.readString(80, "shop name");
- }
-}
-
-void BuyingStoreRecv::processBuyingStoreHideBoard(Net::MessageIn &msg)
-{
- const BeingId id = msg.readBeingId("owner id");
- Being *const dstBeing = actorManager->findBeing(id);
- if (dstBeing != nullptr)
- dstBeing->setBuyBoard(std::string());
- if (dstBeing == localPlayer)
- {
- PlayerInfo::enableVending(false);
- BuyingStoreModeListener::distributeEvent(false);
- }
-}
-
-void BuyingStoreRecv::processBuyingStoreItemsList(Net::MessageIn &msg)
-{
- const int count = (msg.readInt16("len") - 16) / 9;
- const BeingId id = msg.readBeingId("account id");
- const int storeId = msg.readInt32("store id");
- // +++ in future need use it too
- msg.readInt32("money limit");
-
- const Being *const dstBeing = actorManager->findBeing(id);
- if (dstBeing == nullptr)
- return;
-
- SellDialog *const dialog = CREATEWIDGETR(BuyingStoreSellDialog,
- dstBeing->getId(),
- storeId);
- dialog->setMoney(PlayerInfo::getAttribute(Attributes::MONEY));
- const Inventory *const inv = PlayerInfo::getInventory();
- for (int f = 0; f < count; f ++)
- {
- const int price = msg.readInt32("price");
- const int amount = msg.readInt16("amount");
- const ItemTypeT itemType = static_cast<ItemTypeT>(
- msg.readUInt8("item type"));
- const int itemId = msg.readInt16("item id");
-
- if (inv == nullptr)
- continue;
- const Item *const item = inv->findItem(itemId, ItemColor_one);
- if (item == nullptr)
- continue;
- // +++ need add colors support
- dialog->addItem(itemId, itemType, ItemColor_one, amount, price);
- }
-}
-
-void BuyingStoreRecv::processBuyingStoreSellFailed(Net::MessageIn &msg)
-{
- const int16_t result = msg.readInt16("result");
- switch (result)
- {
- case 3:
- NotifyManager::notify(
- NotifyTypes::BUYING_STORE_SELL_FAILED_MONEY_LIMIT);
- break;
- case 4:
- NotifyManager::notify(NotifyTypes::BUYING_STORE_SELL_FAILED_EMPTY);
- break;
- default:
- NotifyManager::notify(NotifyTypes::BUYING_STORE_SELL_FAILED);
- break;
- }
-}
-
-void BuyingStoreRecv::processBuyingStoreSellerSellFailed(Net::MessageIn &msg)
-{
- const int16_t result = msg.readInt16("result");
- msg.readInt16("item id");
- switch (result)
- {
- case 5:
- NotifyManager::notify(
- NotifyTypes::BUYING_STORE_SELLER_SELL_FAILED_DEAL);
- break;
- case 6:
- NotifyManager::notify(
- NotifyTypes::BUYING_STORE_SELLER_SELL_FAILED_AMOUNT);
- break;
- case 7:
- NotifyManager::notify(
- NotifyTypes::BUYING_STORE_SELLER_SELL_FAILED_BALANCE);
- break;
- default:
- NotifyManager::notify(
- NotifyTypes::BUYING_STORE_SELLER_SELL_FAILED);
- break;
- }
-}
-
-void BuyingStoreRecv::processBuyingStoreReport(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readInt16("item id");
- msg.readInt16("amount");
- if (msg.getVersion() >= 20141016)
- {
- msg.readInt32("money");
- msg.readInt32("money limit");
- msg.readInt32("char id");
- msg.readInt32("date");
- }
- else
- {
- msg.readInt32("money limit");
- }
-}
-
-void BuyingStoreRecv::processBuyingStoreDeleteItem(Net::MessageIn &msg)
-{
- Inventory *const inventory = localPlayer != nullptr
- ? PlayerInfo::getInventory() : nullptr;
-
- const int index = msg.readInt16("index") - INVENTORY_OFFSET;
- const int amount = msg.readInt16("amount");
- msg.readInt32("price");
-
- if (inventory != nullptr)
- {
- if (Item *const item = inventory->getItem(index))
- {
- item->increaseQuantity(-amount);
- if (item->getQuantity() == 0)
- inventory->removeItemAt(index);
- ArrowsListener::distributeEvent();
- }
- }
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/buyingstorerecv.h b/src/net/eathena/buyingstorerecv.h
deleted file mode 100644
index 15935c3b8..000000000
--- a/src/net/eathena/buyingstorerecv.h
+++ /dev/null
@@ -1,55 +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 NET_EATHENA_BUYINGSTORERECV_H
-#define NET_EATHENA_BUYINGSTORERECV_H
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-namespace EAthena
-{
- namespace BuyingStoreRecv
- {
- void processBuyingStoreOpen(Net::MessageIn &msg);
-
- void processBuyingStoreCreateFailed(Net::MessageIn &msg);
-
- void processBuyingStoreOwnItems(Net::MessageIn &msg);
-
- void processBuyingStoreShowBoard(Net::MessageIn &msg);
-
- void processBuyingStoreHideBoard(Net::MessageIn &msg);
-
- void processBuyingStoreItemsList(Net::MessageIn &msg);
-
- void processBuyingStoreSellFailed(Net::MessageIn &msg);
-
- void processBuyingStoreReport(Net::MessageIn &msg);
-
- void processBuyingStoreDeleteItem(Net::MessageIn &msg);
-
- void processBuyingStoreSellerSellFailed(Net::MessageIn &msg);
- } // namespace BuyingStoreRecv
-} // namespace EAthena
-
-#endif // NET_EATHENA_BUYINGSTORERECV_H
diff --git a/src/net/eathena/buysellhandler.cpp b/src/net/eathena/buysellhandler.cpp
deleted file mode 100644
index 6858f0808..000000000
--- a/src/net/eathena/buysellhandler.cpp
+++ /dev/null
@@ -1,77 +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 "net/eathena/buysellhandler.h"
-
-#include "net/ea/buysellrecv.h"
-
-#include "net/eathena/messageout.h"
-#include "net/eathena/protocolout.h"
-
-#include "debug.h"
-
-extern int packetVersion;
-
-namespace EAthena
-{
-
-BuySellHandler::BuySellHandler() :
- Ea::BuySellHandler()
-{
- buySellHandler = this;
- Ea::BuySellRecv::mBuyDialog = nullptr;
-}
-
-BuySellHandler::~BuySellHandler()
-{
- buySellHandler = nullptr;
-}
-
-void BuySellHandler::requestSellList(const std::string &nick A_UNUSED) const
-{
-}
-
-void BuySellHandler::requestBuyList(const std::string &nick A_UNUSED) const
-{
-}
-
-void BuySellHandler::sendBuyRequest(const std::string &nick A_UNUSED,
- const ShopItem *const item A_UNUSED,
- const int amount A_UNUSED) const
-{
-}
-
-void BuySellHandler::sendSellRequest(const std::string &nick A_UNUSED,
- const ShopItem *const item A_UNUSED,
- const int amount A_UNUSED) const
-{
-}
-
-void BuySellHandler::close() const
-{
- if (packetVersion < 20131218)
- return;
-
- createOutPacket(CMSG_NPC_SHOP_CLOSE);
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/buysellhandler.h b/src/net/eathena/buysellhandler.h
deleted file mode 100644
index b7aea35c7..000000000
--- a/src/net/eathena/buysellhandler.h
+++ /dev/null
@@ -1,59 +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 NET_EATHENA_BUYSELLHANDLER_H
-#define NET_EATHENA_BUYSELLHANDLER_H
-
-#include "net/ea/buysellhandler.h"
-
-namespace EAthena
-{
-
-class BuySellHandler final : public Ea::BuySellHandler
-{
- public:
- BuySellHandler();
-
- A_DELETE_COPY(BuySellHandler)
-
- ~BuySellHandler();
-
- void requestSellList(const std::string &nick)
- const override final A_CONST;
-
- void requestBuyList(const std::string &nick)
- const override final A_CONST;
-
- void sendBuyRequest(const std::string &nick,
- const ShopItem *const item,
- const int amount) const override final A_CONST;
-
- void sendSellRequest(const std::string &nick,
- const ShopItem *const item,
- const int amount) const override final A_CONST;
-
- void close() const override final;
-};
-
-} // namespace EAthena
-
-#endif // NET_EATHENA_BUYSELLHANDLER_H
diff --git a/src/net/eathena/buysellrecv.cpp b/src/net/eathena/buysellrecv.cpp
deleted file mode 100644
index db2b6a607..000000000
--- a/src/net/eathena/buysellrecv.cpp
+++ /dev/null
@@ -1,141 +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 "net/eathena/buysellrecv.h"
-
-#include "notifymanager.h"
-
-#include "being/playerinfo.h"
-
-#include "const/resources/currency.h"
-
-#include "enums/resources/notifytypes.h"
-
-#include "gui/windows/buydialog.h"
-
-#include "gui/widgets/createwidget.h"
-
-#include "net/messagein.h"
-
-#include "net/ea/buysellrecv.h"
-
-#include "net/eathena/npcrecv.h"
-
-#include "resources/beinginfo.h"
-
-#include "resources/db/npcdb.h"
-
-#include "debug.h"
-
-namespace EAthena
-{
-
-void BuySellRecv::processNpcBuy(Net::MessageIn &msg)
-{
- msg.readInt16("len");
- const int sz = 11;
- const int n_items = (msg.getLength() - 4) / sz;
-
- const BeingTypeId npcId = NpcRecv::mNpcTypeId;
- std::string currency;
-
- if (npcId != BeingTypeId_zero)
- {
- const BeingInfo *const info = NPCDB::get(npcId);
- if (info != nullptr)
- currency = info->getCurrency();
- else
- currency = DEFAULT_CURRENCY;
- }
- else
- {
- currency = DEFAULT_CURRENCY;
- }
-
- CREATEWIDGETV(Ea::BuySellRecv::mBuyDialog, BuyDialog,
- Ea::BuySellRecv::mNpcId,
- currency);
- Ea::BuySellRecv::mBuyDialog->setMoney(
- PlayerInfo::getAttribute(Attributes::MONEY));
-
- for (int k = 0; k < n_items; k++)
- {
- const int value = msg.readInt32("price");
- msg.readInt32("dc value?");
- const ItemTypeT type = static_cast<ItemTypeT>(
- msg.readUInt8("type"));
- const int itemId = msg.readInt16("item id");
- const ItemColor color = ItemColor_one;
- Ea::BuySellRecv::mBuyDialog->addItem(itemId, type, color, 0, value);
- }
- Ea::BuySellRecv::mBuyDialog->sort();
-}
-
-void BuySellRecv::processNpcSellResponse(Net::MessageIn &msg)
-{
- switch (msg.readUInt8("result"))
- {
- case 0:
- NotifyManager::notify(NotifyTypes::SOLD);
- break;
- case 1:
- default:
- NotifyManager::notify(NotifyTypes::SELL_FAILED);
- break;
- case 2:
- NotifyManager::notify(NotifyTypes::SELL_TRADE_FAILED);
- break;
- case 3:
- NotifyManager::notify(NotifyTypes::SELL_UNSELLABLE_FAILED);
- break;
- }
-}
-
-void BuySellRecv::processNpcBuyResponse(Net::MessageIn &msg)
-{
- const uint8_t response = msg.readUInt8("response");
- if (response == 0U)
- {
- NotifyManager::notify(NotifyTypes::BUY_DONE);
- return;
- }
- switch (response)
- {
- case 1:
- NotifyManager::notify(NotifyTypes::BUY_FAILED_NO_MONEY);
- break;
-
- case 2:
- NotifyManager::notify(NotifyTypes::BUY_FAILED_OVERWEIGHT);
- break;
-
- case 3:
- NotifyManager::notify(NotifyTypes::BUY_FAILED_TOO_MANY_ITEMS);
- break;
-
- default:
- NotifyManager::notify(NotifyTypes::BUY_FAILED);
- break;
- };
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/buysellrecv.h b/src/net/eathena/buysellrecv.h
deleted file mode 100644
index 445fe35c6..000000000
--- a/src/net/eathena/buysellrecv.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 NET_EATHENA_BUYSELLRECV_H
-#define NET_EATHENA_BUYSELLRECV_H
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-namespace EAthena
-{
- namespace BuySellRecv
- {
- void processNpcBuy(Net::MessageIn &msg);
- void processNpcSellResponse(Net::MessageIn &msg);
- void processNpcBuyResponse(Net::MessageIn &msg);
- } // namespace BuySellRecv
-} // namespace EAthena
-
-#endif // NET_EATHENA_BUYSELLRECV_H
diff --git a/src/net/eathena/cashshophandler.cpp b/src/net/eathena/cashshophandler.cpp
deleted file mode 100644
index 2e1e9cde4..000000000
--- a/src/net/eathena/cashshophandler.cpp
+++ /dev/null
@@ -1,160 +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 "net/eathena/cashshophandler.h"
-
-#include "net/eathena/cashshoprecv.h"
-#include "net/eathena/messageout.h"
-#include "net/eathena/protocolout.h"
-
-#include "utils/foreach.h"
-
-#include "resources/item/shopitem.h"
-
-#include "debug.h"
-
-extern int packetVersion;
-
-namespace EAthena
-{
-
-CashShopHandler::CashShopHandler() :
- Net::CashShopHandler()
-{
- cashShopHandler = this;
- CashShopRecv::mBuyDialog = nullptr;
-}
-
-CashShopHandler::~CashShopHandler()
-{
- cashShopHandler = nullptr;
-}
-
-void CashShopHandler::buyItem(const int points,
- const int itemId,
- const ItemColor color A_UNUSED,
- const int amount) const
-{
- if (packetVersion < 20101124)
- return;
- createOutPacket(CMSG_NPC_CASH_SHOP_BUY);
- outMsg.writeInt16(10 + 4, "len");
- outMsg.writeInt32(points, "points");
- outMsg.writeInt16(1, "count");
- outMsg.writeInt16(CAST_S16(amount), "amount");
- outMsg.writeInt16(CAST_S16(itemId), "item id");
-}
-
-void CashShopHandler::buyItems(const int points,
- const STD_VECTOR<ShopItem*> &items) const
-{
- if (packetVersion < 20101124)
- return;
-
- int cnt = 0;
- const int pairSize = 4;
-
- FOR_EACH (STD_VECTOR<ShopItem*>::const_iterator, it, items)
- {
- const ShopItem *const item = *it;
- const int usedQuantity = item->getUsedQuantity();
- const ItemTypeT type = item->getType();
- if (usedQuantity == 0)
- continue;
- if (type == ItemType::Weapon ||
- type == ItemType::Armor ||
- type == ItemType::PetEgg ||
- type == ItemType::PetArmor)
- {
- cnt += item->getUsedQuantity();
- }
- else
- {
- cnt ++;
- }
- }
-
- if (cnt > 100)
- return;
-
- createOutPacket(CMSG_NPC_CASH_SHOP_BUY);
- outMsg.writeInt16(CAST_S16(10 + pairSize * cnt), "len");
- outMsg.writeInt32(points, "points");
- outMsg.writeInt16(CAST_S16(cnt), "count");
- FOR_EACH (STD_VECTOR<ShopItem*>::const_iterator, it, items)
- {
- ShopItem *const item = *it;
- const int usedQuantity = item->getUsedQuantity();
- if (usedQuantity == 0)
- continue;
- item->increaseQuantity(usedQuantity);
- item->increaseUsedQuantity(-usedQuantity);
- item->update();
- const ItemTypeT type = item->getType();
- if (type == ItemType::Weapon ||
- type == ItemType::Armor ||
- type == ItemType::PetEgg ||
- type == ItemType::PetArmor)
- {
- for (int f = 0; f < usedQuantity; f ++)
- {
- outMsg.writeInt16(CAST_S16(1), "amount");
- outMsg.writeInt16(CAST_S16(item->getId()),
- "item id");
- }
- }
- else
- {
- outMsg.writeInt16(CAST_S16(usedQuantity), "amount");
- outMsg.writeInt16(CAST_S16(item->getId()), "item id");
- }
- }
-}
-
-void CashShopHandler::close() const
-{
- if (packetVersion < 20110718)
- return;
- createOutPacket(CMSG_NPC_CASH_SHOP_CLOSE);
-}
-
-void CashShopHandler::requestPoints() const
-{
- if (packetVersion < 20110718)
- return;
- createOutPacket(CMSG_NPC_CASH_SHOP_OPEN);
-}
-
-void CashShopHandler::requestTab(const int tab) const
-{
- if (packetVersion < 20110718)
- return;
- createOutPacket(CMSG_NPC_CASH_SHOP_REQUEST_TAB);
- outMsg.writeInt16(CAST_S16(tab), "tab");
-}
-
-void CashShopHandler::schedule() const
-{
- if (packetVersion < 20110614)
- return;
- createOutPacket(CMSG_NPC_CASH_SHOP_SCHEDULE);
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/cashshophandler.h b/src/net/eathena/cashshophandler.h
deleted file mode 100644
index 7294b5cae..000000000
--- a/src/net/eathena/cashshophandler.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 NET_EATHENA_CASHSHOPHANDLER_H
-#define NET_EATHENA_CASHSHOPHANDLER_H
-
-#include "net/cashshophandler.h"
-
-namespace EAthena
-{
-class CashShopHandler final : public Net::CashShopHandler
-{
- public:
- CashShopHandler();
-
- A_DELETE_COPY(CashShopHandler)
-
- ~CashShopHandler();
-
- void buyItem(const int points,
- const int itemId,
- const ItemColor color,
- const int amount) const override final;
-
- void buyItems(const int points,
- const STD_VECTOR<ShopItem*> &items) const override final
- A_CONST;
-
- void close() const override final;
-
- void requestPoints() const override final;
-
- void requestTab(const int tab) const override final;
-
- void schedule() const override final;
-};
-
-} // namespace EAthena
-
-#endif // NET_EATHENA_CASHSHOPHANDLER_H
diff --git a/src/net/eathena/cashshoprecv.cpp b/src/net/eathena/cashshoprecv.cpp
deleted file mode 100644
index 421631ab6..000000000
--- a/src/net/eathena/cashshoprecv.cpp
+++ /dev/null
@@ -1,181 +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 "net/eathena/cashshoprecv.h"
-
-#include "notifymanager.h"
-
-#include "const/resources/currency.h"
-
-#include "enums/resources/notifytypes.h"
-
-#include "gui/windows/buydialog.h"
-
-#include "gui/widgets/createwidget.h"
-
-#include "net/messagein.h"
-
-#include "net/eathena/npcrecv.h"
-
-#include "resources/beinginfo.h"
-
-#include "resources/db/npcdb.h"
-
-#include "debug.h"
-
-extern int packetVersion;
-
-namespace EAthena
-{
-
-namespace CashShopRecv
-{
- BuyDialog *mBuyDialog;
-} // namespace CashShopRecv
-
-void CashShopRecv::processCashShopOpen(Net::MessageIn &msg)
-{
- int count;
- if (packetVersion >= 20070711)
- count = (msg.readInt16("len") - 12) / 11;
- else
- count = (msg.readInt16("len") - 8) / 11;
-
- const BeingTypeId npcId = NpcRecv::mNpcTypeId;
- std::string currency;
-
- if (npcId != BeingTypeId_zero)
- {
- const BeingInfo *const info = NPCDB::get(npcId);
- if (info != nullptr)
- currency = info->getCurrency();
- else
- currency = DEFAULT_CURRENCY;
- }
- else
- {
- currency = DEFAULT_CURRENCY;
- }
- CREATEWIDGETV(mBuyDialog, BuyDialog,
- fromInt(BuyDialog::Cash, BeingId),
- currency);
- const int points = msg.readInt32("cash points");
-
- mBuyDialog->setMoney(points);
-
- if (packetVersion >= 20070711)
- msg.readInt32("kafra points");
- for (int f = 0; f < count; f ++)
- {
- msg.readInt32("price");
- const int value = msg.readInt32("discount price");
- const ItemTypeT type = static_cast<ItemTypeT>(
- msg.readUInt8("item type"));
- const int itemId = msg.readInt16("item id");
- const ItemColor color = ItemColor_one;
- mBuyDialog->addItem(itemId, type, color, 0, value);
- }
- mBuyDialog->sort();
-}
-
-void CashShopRecv::processCashShopBuyAck(Net::MessageIn &msg)
-{
- msg.readInt32("cash points");
- if (packetVersion >= 20070711)
- msg.readInt32("kafra points");
- const uint16_t res = msg.readInt16("error");
- switch (res)
- {
- case 0:
- NotifyManager::notify(NotifyTypes::BUY_DONE);
- break;
- case 1:
- NotifyManager::notify(NotifyTypes::BUY_FAILED_NPC_NOT_FOUND);
- break;
- case 2:
- NotifyManager::notify(NotifyTypes::BUY_FAILED_SYSTEM_ERROR);
- break;
- case 3:
- NotifyManager::notify(NotifyTypes::BUY_FAILED_OVERWEIGHT);
- break;
- case 4:
- NotifyManager::notify(NotifyTypes::BUY_TRADE_FAILED);
- break;
- case 5:
- NotifyManager::notify(NotifyTypes::BUY_FAILED_WRONG_ITEM);
- break;
- case 6:
- NotifyManager::notify(NotifyTypes::BUY_FAILED_NO_MONEY);
- break;
- default:
- UNIMPLEMENTEDPACKETFIELD(res);
- break;
- }
-}
-
-void CashShopRecv::processCashShopPoints(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readInt32("cash points");
- msg.readInt32("kafra points");
-}
-
-void CashShopRecv::processCashShopBuy(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readInt32("id");
- msg.readInt16("result");
- msg.readInt32("cash points");
- msg.readInt32("kafra points");
-}
-
-void CashShopRecv::processCashShopTabPriceList(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- const int count = (msg.readInt16("len") - 10) / 6;
- msg.readInt32("tab");
- const int itemsCount = msg.readInt16("count");
- if (count != itemsCount)
- logger->log("error: wrong list count");
-
- for (int f = 0; f < count; f ++)
- {
- msg.readInt16("item id");
- msg.readInt32("price");
- }
-}
-
-void CashShopRecv::processCashShopSchedule(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- const int count = (msg.readInt16("len") - 8) / 6;
- const int itemsCount = msg.readInt16("count");
- msg.readInt16("tab");
- if (count != itemsCount)
- logger->log("error: wrong list count");
-
- for (int f = 0; f < count; f ++)
- {
- msg.readInt16("item id");
- msg.readInt32("price");
- }
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/cashshoprecv.h b/src/net/eathena/cashshoprecv.h
deleted file mode 100644
index 619474a6c..000000000
--- a/src/net/eathena/cashshoprecv.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 NET_EATHENA_CASHSHOPRECV_H
-#define NET_EATHENA_CASHSHOPRECV_H
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-class BuyDialog;
-
-namespace EAthena
-{
- namespace CashShopRecv
- {
- extern BuyDialog *mBuyDialog;
- void processCashShopOpen(Net::MessageIn &msg);
- void processCashShopBuyAck(Net::MessageIn &msg);
- void processCashShopPoints(Net::MessageIn &msg);
- void processCashShopBuy(Net::MessageIn &msg);
- void processCashShopTabPriceList(Net::MessageIn &msg);
- void processCashShopSchedule(Net::MessageIn &msg);
- } // namespace CashShopRecv
-} // namespace EAthena
-
-#endif // NET_EATHENA_CASHSHOPRECV_H
diff --git a/src/net/eathena/charserverhandler.cpp b/src/net/eathena/charserverhandler.cpp
deleted file mode 100644
index 18273de0a..000000000
--- a/src/net/eathena/charserverhandler.cpp
+++ /dev/null
@@ -1,248 +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 "net/eathena/charserverhandler.h"
-
-#include "gui/windows/charcreatedialog.h"
-
-#include "net/character.h"
-#include "net/serverfeatures.h"
-
-#include "net/ea/token.h"
-
-#include "net/eathena/charserverrecv.h"
-#include "net/eathena/loginhandler.h"
-#include "net/eathena/messageout.h"
-#include "net/eathena/network.h"
-#include "net/eathena/protocolout.h"
-
-#include "debug.h"
-
-extern int packetVersion;
-extern int serverVersion;
-
-namespace EAthena
-{
-
-extern ServerInfo charServer;
-extern ServerInfo mapServer;
-
-CharServerHandler::CharServerHandler() :
- Ea::CharServerHandler()
-{
- CharServerRecv::mNewName.clear();
- CharServerRecv::mPinSeed = 0;
- CharServerRecv::mPinAccountId = BeingId_zero;
- CharServerRecv::mRenameId = BeingId_zero;
- CharServerRecv::mNeedCreatePin = false;
-
- charServerHandler = this;
-}
-
-CharServerHandler::~CharServerHandler()
-{
- charServerHandler = nullptr;
-}
-
-void CharServerHandler::chooseCharacter(Net::Character *const character) const
-{
- if (character == nullptr)
- return;
-
- mSelectedCharacter = character;
- mCharSelectDialog = nullptr;
-
- createOutPacket(CMSG_CHAR_SELECT);
- outMsg.writeInt8(CAST_U8(
- mSelectedCharacter->slot), "slot");
-}
-
-void CharServerHandler::newCharacter(const std::string &name, const int slot,
- const GenderT gender,
- const int hairstyle, const int hairColor,
- const unsigned char race,
- const uint16_t look,
- const STD_VECTOR<int> &stats A_UNUSED)
- const
-{
- createOutPacket(CMSG_CHAR_CREATE);
- outMsg.writeString(name, 24, "login");
- if (serverVersion > 0)
- {
- outMsg.writeInt8(CAST_U8(slot), "slot");
- outMsg.writeInt16(CAST_S16(hairColor), "hair color");
- outMsg.writeInt16(CAST_S16(hairstyle), "hair style");
- if (serverFeatures->haveRaceSelection())
- outMsg.writeInt16(CAST_S16(race), "race");
- if (serverFeatures->haveCreateCharGender())
- {
- uint8_t sex = 0;
- if (gender == Gender::UNSPECIFIED)
- sex = 99;
- else
- sex = Being::genderToInt(gender);
- outMsg.writeInt8(sex, "gender");
- }
- if (serverFeatures->haveLookSelection())
- outMsg.writeInt16(CAST_S16(look), "look");
- }
- else
- {
- if (packetVersion >= 20151001)
- {
- outMsg.writeInt8(CAST_U8(slot), "slot");
- outMsg.writeInt16(CAST_S16(hairColor), "hair color");
- outMsg.writeInt16(CAST_S16(hairstyle), "hair style");
- outMsg.writeInt16(CAST_S16(0), "starting job id");
- outMsg.writeInt16(0, "unknown");
- uint8_t sex = 0;
- if (gender == Gender::UNSPECIFIED)
- sex = 99;
- else
- sex = Being::genderToInt(gender);
- outMsg.writeInt8(sex, "gender");
- }
- else if (packetVersion >= 20120307)
- {
- outMsg.writeInt8(CAST_U8(slot), "slot");
- outMsg.writeInt16(CAST_S16(hairColor), "hair color");
- outMsg.writeInt16(CAST_S16(hairstyle), "hair style");
- }
- else
- { // < 20120307
- // +++ here need send stat points
- // sending 5 for each stat for now
- for (int i = 0; i < 6; i++)
- outMsg.writeInt8(CAST_U8(5), "stat");
-
- outMsg.writeInt8(CAST_U8(slot), "slot");
- outMsg.writeInt16(CAST_S16(hairColor), "hair color");
- outMsg.writeInt16(CAST_S16(hairstyle), "hair style");
- }
- }
-}
-
-void CharServerHandler::deleteCharacter(Net::Character *const character,
- const std::string &email) const
-{
- if (character == nullptr)
- return;
-
- mSelectedCharacter = character;
-
- createOutPacket(CMSG_CHAR_DELETE);
- outMsg.writeBeingId(mSelectedCharacter->dummy->getId(), "id?");
- if (email.empty())
- outMsg.writeString("a@a.com", 40, "email");
- else
- outMsg.writeString(email, 40, "email");
-}
-
-void CharServerHandler::switchCharacter() const
-{
- // This is really a map-server packet
- createOutPacket(CMSG_PLAYER_RESTART);
- outMsg.writeInt8(1, "flag");
-}
-
-void CharServerHandler::connect() const
-{
- const Token &token =
- static_cast<LoginHandler*>(loginHandler)->getToken();
-
- if (Network::mInstance == nullptr)
- return;
-
- Network::mInstance->disconnect();
- Network::mInstance->connect(charServer);
- createOutPacket(CMSG_CHAR_SERVER_CONNECT);
- outMsg.writeBeingId(token.account_ID, "account id");
- outMsg.writeInt32(token.session_ID1, "session id1");
- outMsg.writeInt32(token.session_ID2, "session id2");
- outMsg.writeInt16(CLIENT_PROTOCOL_VERSION, "client protocol version");
- outMsg.writeInt8(Being::genderToInt(token.sex), "gender");
-
- // We get 4 useless bytes before the real answer comes in (what are these?)
- Network::mInstance->skip(4);
-}
-
-void CharServerHandler::setCharCreateDialog(CharCreateDialog *const window)
- const
-{
- mCharCreateDialog = window;
-
- if (mCharCreateDialog == nullptr)
- return;
-
- StringVect attributes;
-
- const Token &token = static_cast<LoginHandler*>(loginHandler)->getToken();
-
- mCharCreateDialog->setAttributes(attributes, 0, 0, 0);
- mCharCreateDialog->setDefaultGender(token.sex);
-}
-
-void CharServerHandler::setNewPincode(const std::string &pin A_UNUSED) const
-{
-// here need ecript pin with mPinSeed and pin values.
-
-// createOutPacket(CMSG_CHAR_CREATE_PIN);
-// outMsg.writeBeingId(mPinAccountId, "account id");
-// outMsg.writeString(pin, 4, "encrypted pin");
-}
-
-void CharServerHandler::renameCharacter(const BeingId id,
- const std::string &newName) const
-{
- createOutPacket(CMSG_CHAR_CHECK_RENAME);
- CharServerRecv::mRenameId = id;
- CharServerRecv::mNewName = newName;
- outMsg.writeBeingId(id, "char id");
- outMsg.writeString(newName, 24, "name");
-}
-
-void CharServerHandler::changeSlot(const int oldSlot,
- const int newSlot) const
-{
- createOutPacket(CMSG_CHAR_CHANGE_SLOT);
- outMsg.writeInt16(CAST_S16(oldSlot), "old slot");
- outMsg.writeInt16(CAST_S16(newSlot), "new slot");
- outMsg.writeInt16(0, "unused");
-}
-
-void CharServerHandler::ping() const
-{
- createOutPacket(CMSG_CHAR_PING);
- outMsg.writeInt32(0, "unused");
-}
-
-unsigned int CharServerHandler::hatSprite() const
-{
- return 7;
-}
-
-bool CharServerHandler::isNeedCreatePin() const
-{
- return CharServerRecv::mNeedCreatePin;
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/charserverhandler.h b/src/net/eathena/charserverhandler.h
deleted file mode 100644
index cef8f868e..000000000
--- a/src/net/eathena/charserverhandler.h
+++ /dev/null
@@ -1,88 +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 NET_EATHENA_CHARSERVERHANDLER_H
-#define NET_EATHENA_CHARSERVERHANDLER_H
-
-#include "net/ea/charserverhandler.h"
-
-namespace EAthena
-{
-
-/**
- * Deals with incoming messages from the character server.
- */
-class CharServerHandler final : public Ea::CharServerHandler
-{
- public:
- CharServerHandler();
-
- A_DELETE_COPY(CharServerHandler)
-
- ~CharServerHandler();
-
- void chooseCharacter(Net::Character *const character) const
- override final;
-
- void newCharacter(const std::string &name,
- const int slot,
- const GenderT gender,
- const int hairstyle,
- const int hairColor,
- const unsigned char race,
- const uint16_t look,
- const STD_VECTOR<int> &stats) const override final;
-
- void renameCharacter(const BeingId id,
- const std::string &newName) const override final;
-
- void deleteCharacter(Net::Character *const character,
- const std::string &email) const override final;
-
- void switchCharacter() const override final;
-
- void connect() const override final;
-
- bool isNeedCreatePin() const override final A_WARN_UNUSED;
-
- void setNewPincode(const std::string &pin) const override final
- A_CONST;
-
- /**
- * Sets the character create dialog. The handler will clean up this
- * dialog when a new character is successfully created, and will unlock
- * the dialog when a new character failed to be created.
- */
- void setCharCreateDialog(CharCreateDialog *const window) const
- override final;
-
- void changeSlot(const int oldSlot,
- const int newSlot) const override final;
-
- void ping() const override final;
-
- unsigned int hatSprite() const override final A_CONST A_WARN_UNUSED;
-};
-
-} // namespace EAthena
-
-#endif // NET_EATHENA_CHARSERVERHANDLER_H
diff --git a/src/net/eathena/charserverrecv.cpp b/src/net/eathena/charserverrecv.cpp
deleted file mode 100644
index ec906f081..000000000
--- a/src/net/eathena/charserverrecv.cpp
+++ /dev/null
@@ -1,570 +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 "net/eathena/charserverrecv.h"
-
-#include "client.h"
-#include "configuration.h"
-#include "settings.h"
-
-#include "gui/windows/charcreatedialog.h"
-#include "gui/windows/charselectdialog.h"
-#include "gui/windows/okdialog.h"
-
-#include "gui/widgets/createwidget.h"
-
-#include "net/character.h"
-#include "net/charserverhandler.h"
-#include "net/playerhandler.h"
-
-#include "net/ea/token.h"
-
-#include "net/eathena/gamehandler.h"
-#include "net/eathena/loginhandler.h"
-#include "net/eathena/messageout.h"
-#include "net/eathena/network.h"
-#include "net/eathena/protocolout.h"
-#include "net/eathena/sprite.h"
-
-#include "resources/iteminfo.h"
-
-#include "resources/db/itemdb.h"
-
-#include "utils/dtor.h"
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-extern int packetVersion;
-
-namespace EAthena
-{
-
-extern ServerInfo charServer;
-extern ServerInfo mapServer;
-
-namespace CharServerRecv
-{
- std::string mNewName;
- uint32_t mPinSeed = 0;
- BeingId mPinAccountId = BeingId_zero;
- BeingId mRenameId = BeingId_zero;
- bool mNeedCreatePin = false;
-} // namespace CharServerRecv
-
-// callers must count each packet size by self
-void CharServerRecv::readPlayerData(Net::MessageIn &msg,
- Net::Character *const character)
-{
- if (character == nullptr)
- return;
-
- const Token &token =
- static_cast<LoginHandler*>(loginHandler)->getToken();
-
- LocalPlayer *const tempPlayer = new LocalPlayer(
- msg.readBeingId("player id"), BeingTypeId_zero);
- tempPlayer->setGender(token.sex);
-
- PlayerInfoBackend &data = character->data;
- if (packetVersion >= 20170830)
- data.mAttributes[Attributes::PLAYER_EXP] = msg.readInt64("exp");
- else
- data.mAttributes[Attributes::PLAYER_EXP] = msg.readInt32("exp");
- data.mAttributes[Attributes::MONEY] = msg.readInt32("money");
- if (packetVersion >= 20170830)
- {
- data.mAttributes[Attributes::PLAYER_JOB_EXP] =
- msg.readInt64("job exp");
- }
- else
- {
- data.mAttributes[Attributes::PLAYER_JOB_EXP] =
- msg.readInt32("job exp");
- }
- data.mAttributes[Attributes::PLAYER_JOB_LEVEL] =
- msg.readInt32("job level");
-
- msg.readInt16("shoes?");
- const int gloves = msg.readInt16("gloves");
- const int cape = msg.readInt16("cape");
- const int misc1 = msg.readInt16("misc1");
-
- msg.readInt32("option");
- tempPlayer->setKarma(msg.readInt32("karma"));
- tempPlayer->setManner(msg.readInt32("manner"));
- msg.readInt16("left points");
-
- if (packetVersion >= 20081217)
- {
- data.mAttributes[Attributes::PLAYER_HP] = msg.readInt32("hp");
- data.mAttributes[Attributes::PLAYER_MAX_HP] = msg.readInt32("max hp");
- }
- else
- {
- data.mAttributes[Attributes::PLAYER_HP] = msg.readInt16("hp");
- data.mAttributes[Attributes::PLAYER_MAX_HP] = msg.readInt16("max hp");
- }
- data.mAttributes[Attributes::PLAYER_MP] = msg.readInt16("mp/sp");
- data.mAttributes[Attributes::PLAYER_MAX_MP] = msg.readInt16("max mp/sp");
-
- msg.readInt16("speed");
- const uint16_t race = msg.readInt16("class");
-// tempPlayer->setSubtype(race, 0);
- const int hairStyle = msg.readInt16("hair style");
- if (packetVersion >= 20141022)
- msg.readInt16("body");
- const int option A_UNUSED = (msg.readInt16("weapon") | 1) ^ 1;
- const int weapon = 0;
-
- tempPlayer->setSpriteId(SPRITE_BODY,
- weapon);
- tempPlayer->setWeaponId(weapon);
-
- data.mAttributes[Attributes::PLAYER_BASE_LEVEL] = msg.readInt16("level");
-
- msg.readInt16("skill points");
- const int bottomClothes = msg.readInt16("head bottom");
- const int shield = msg.readInt16("shild");
- const int hat = msg.readInt16("head top");
- const int topClothes = msg.readInt16("head mid");
-
- const ItemColor color = fromInt(msg.readInt16("hair color"), ItemColor);
- tempPlayer->setHairColor(color);
- if (hairStyle == 0)
- {
- tempPlayer->unSetSprite(SPRITE_HAIR_COLOR);
- }
- else
- {
- tempPlayer->setSpriteColor(SPRITE_HAIR_COLOR,
- hairStyle * -1,
- ItemDB::get(-hairStyle).getDyeColorsString(
- color));
- }
-
- const uint16_t look = msg.readInt16("clothes color");
- tempPlayer->setSubtype(fromInt(race, BeingTypeId), look);
- tempPlayer->setName(msg.readString(24, "name"));
-
- character->dummy = tempPlayer;
-
- character->data.mStats[Attributes::PLAYER_STR].base = msg.readUInt8("str");
- character->data.mStats[Attributes::PLAYER_AGI].base = msg.readUInt8("agi");
- character->data.mStats[Attributes::PLAYER_VIT].base = msg.readUInt8("vit");
- character->data.mStats[Attributes::PLAYER_INT].base = msg.readUInt8("int");
- character->data.mStats[Attributes::PLAYER_DEX].base = msg.readUInt8("dex");
- character->data.mStats[Attributes::PLAYER_LUK].base = msg.readUInt8("luk");
-
- character->slot = msg.readInt16("character slot id");
- if (packetVersion >= 20061023)
- msg.readInt16("rename");
- if (packetVersion >= 20100803)
- {
- msg.readString(16, "map name");
- msg.readInt32("delete date");
- }
- int shoes = 0;
- if (packetVersion >= 20110111)
- shoes = msg.readInt32("robe");
- if (serverVersion == 0)
- {
- tempPlayer->setSpriteId(SPRITE_HAIR,
- shoes);
- tempPlayer->setSpriteId(SPRITE_SHOES,
- gloves);
- tempPlayer->setSpriteId(SPRITE_SHIELD,
- cape);
- tempPlayer->setSpriteId(SPRITE_HEAD_TOP,
- misc1);
- tempPlayer->setSpriteId(SPRITE_WEAPON,
- bottomClothes);
- tempPlayer->setSpriteId(SPRITE_FLOOR,
- shield);
- tempPlayer->setSpriteId(SPRITE_CLOTHES_COLOR,
- hat);
- tempPlayer->setSpriteId(SPRITE_HEAD_BOTTOM,
- topClothes);
-// tempPlayer->setSprite(SPRITE_HEAD_MID, misc2);
- }
- if (packetVersion >= 20110928)
- msg.readInt32("slot change");
- if (packetVersion >= 20111025)
- tempPlayer->setRename(msg.readInt32("rename (inverse)") != 0);
- uint8_t gender = 99U;
- if (packetVersion >= 20141016)
- gender = CAST_U8(msg.readUInt8("gender"));
- if (gender != 99)
- tempPlayer->setGender(Being::intToGender(gender));
-}
-
-void CharServerRecv::processCharLogin(Net::MessageIn &msg)
-{
- msg.skip(2, "packet len");
- int slots = 9;
- int offset = 0;
- if (packetVersion >= 20100413)
- {
- slots = msg.readInt8("MAX_CHARS");
- msg.readInt8("sd->char_slots");
- msg.readInt8("MAX_CHARS");
- offset = 3;
- }
- loginData.characterSlots = CAST_U16(slots);
-
- msg.skip(20, "unused 0");
-
- delete_all(Net::CharServerHandler::mCharacters);
- Net::CharServerHandler::mCharacters.clear();
-
- // Derive number of characters from message length
- const int count = (msg.getLength() - 24 - offset)
- / (106 + 4 + 2 + 16 + 4 + 4 + 4 + 4);
-
- for (int i = 0; i < count; ++i)
- {
- Net::Character *const character = new Net::Character;
- readPlayerData(msg, character);
- Net::CharServerHandler::mCharacters.push_back(character);
- if (character->dummy != nullptr)
- {
- logger->log("CharServer: Player: %s (%d)",
- character->dummy->getName().c_str(), character->slot);
- }
- }
-
- client->setState(State::CHAR_SELECT);
-}
-
-void CharServerRecv::processCharLogin2(Net::MessageIn &msg)
-{
- // ignored
- msg.readInt16("len");
- msg.readUInt8("char slots");
- msg.readUInt8("left slots");
- msg.readUInt8("left slots");
- msg.readUInt8("char slots");
- msg.readUInt8("char slots");
- msg.skip(20, "unused");
-}
-
-void CharServerRecv::processCharMapInfo(Net::MessageIn &restrict msg)
-{
- Network *const network = Network::mInstance;
- ServerInfo &server = mapServer;
- BLOCK_START("CharServerRecv::processCharMapInfo")
- PlayerInfo::setCharId(msg.readInt32("char id"));
- GameHandler::setMap(msg.readString(16, "map name"));
- if (config.getBoolValue("usePersistentIP") || settings.persistentIp)
- {
- msg.readInt32("map ip address");
- server.hostname = settings.serverName;
- }
- else
- {
- server.hostname = ipToString(msg.readInt32("map ip address"));
- }
- server.port = msg.readInt16("map ip port");
- if (msg.getVersion() >= 20170329)
- {
- for (int f = 0; f < 32; f ++)
- msg.readInt32("unused");
- }
-
- // Prevent the selected local player from being deleted
- localPlayer = Net::CharServerHandler::mSelectedCharacter->dummy;
- PlayerInfo::setBackend(Net::CharServerHandler::mSelectedCharacter->data);
- PlayerInfo::setStatBase(Attributes::PLAYER_WALK_SPEED,
- playerHandler->getDefaultWalkSpeed());
-
- Net::CharServerHandler::mSelectedCharacter->dummy = nullptr;
-
- charServerHandler->clear();
- Net::CharServerHandler::updateCharSelectDialog();
-
- if (network != nullptr)
- network->disconnect();
- client->setState(State::CONNECT_GAME);
- BLOCK_END("CharServerRecv::processCharMapInfo")
-}
-
-void CharServerRecv::processChangeMapServer(Net::MessageIn &msg)
-{
- Network *const network = Network::mInstance;
- ServerInfo &server = mapServer;
- BLOCK_START("CharServerRecv::processChangeMapServer")
- if (network == nullptr)
- {
- BLOCK_END("CharServerRecv::processChangeMapServer")
- return;
- }
- GameHandler::setMap(msg.readString(16, "map name"));
- const int x = msg.readInt16("x");
- const int y = msg.readInt16("y");
- if (config.getBoolValue("usePersistentIP") || settings.persistentIp)
- {
- msg.readInt32("host");
- server.hostname = settings.serverName;
- }
- else
- {
- server.hostname = ipToString(msg.readInt32("host"));
- }
- server.port = msg.readInt16("port");
-
- network->disconnect();
- client->setState(State::CHANGE_MAP);
- if (localPlayer != nullptr)
- {
- localPlayer->setTileCoords(x, y);
- localPlayer->setMap(nullptr);
- }
- BLOCK_END("CharServerRecv::processChangeMapServer")
-}
-
-void CharServerRecv::processPincodeStatus(Net::MessageIn &msg)
-{
- mPinSeed = msg.readInt32("pincode seed");
- mPinAccountId = msg.readBeingId("account id");
- const uint16_t state = CAST_U16(msg.readInt16("state"));
- switch (state)
- {
- case 0: // pin ok
- break;
- case 1: // ask for pin
- break;
- case 2: // create new pin
- case 4: // create new pin?
- {
- mNeedCreatePin = true;
- break;
- }
- case 3: // pin must be changed
- break;
- case 5: // client show error?
- break;
- case 6: // Unable to use your KSSN number
- break;
- case 7: // char select window shows a button
- break;
- case 8: // pincode was incorrect
- break;
- default:
- UNIMPLEMENTEDPACKET;
- break;
- }
-}
-
-void CharServerRecv::processCharCreate(Net::MessageIn &msg)
-{
- BLOCK_START("CharServerRecv::processCharCreate")
- Net::Character *const character = new Net::Character;
- readPlayerData(msg, character);
- Net::CharServerHandler::mCharacters.push_back(character);
-
- Net::CharServerHandler::updateCharSelectDialog();
-
- // Close the character create dialog
- Net::CharServerHandler::mCharCreateDialog->scheduleDelete();
- Net::CharServerHandler::mCharCreateDialog = nullptr;
- BLOCK_END("CharServerRecv::processCharCreate")
-}
-
-void CharServerRecv::processCharCheckRename(Net::MessageIn &msg)
-{
- if (msg.readInt16("flag") != 0)
- {
- createOutPacket(CMSG_CHAR_RENAME);
- outMsg.writeBeingId(mRenameId, "char id");
- }
- else
- {
- CREATEWIDGET(OkDialog,
- // TRANSLATORS: error header
- _("Error"),
- // TRANSLATORS: error message
- _("Character rename error."),
- // TRANSLATORS: ok dialog button
- _("Error"),
- DialogType::ERROR,
- Modal_true,
- ShowCenter_true,
- nullptr,
- 260);
- }
-}
-
-void CharServerRecv::processCharRename(Net::MessageIn &msg)
-{
- const int flag = msg.readInt16("flag");
- if (flag == 0)
- {
- Net::CharServerHandler::mCharSelectDialog->setName(
- mRenameId,
- mNewName);
- CREATEWIDGET(OkDialog,
- // TRANSLATORS: info header
- _("Info"),
- // TRANSLATORS: info message
- _("Character renamed."),
- // TRANSLATORS: ok dialog button
- _("OK"),
- DialogType::OK,
- Modal_true,
- ShowCenter_true,
- nullptr,
- 260);
- }
- else
- {
- std::string message;
- switch (flag)
- {
- case 1:
- // TRANSLATORS: char rename error
- message = _("Rename not allowed.");
- break;
- case 2:
- // TRANSLATORS: char rename error
- message = _("New name is not set.");
- break;
- case 3:
- default:
- // TRANSLATORS: char rename error
- message = _("Character rename error.");
- break;
- case 4:
- // TRANSLATORS: char rename error
- message = _("Character not found.");
- break;
- }
- CREATEWIDGET(OkDialog,
- // TRANSLATORS: info message
- _("Info"),
- message,
- // TRANSLATORS: ok dialog button
- _("OK"),
- DialogType::OK,
- Modal_true,
- ShowCenter_true,
- nullptr,
- 260);
- }
-}
-
-void CharServerRecv::processCharChangeSlot(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readInt16("len");
- msg.readInt16("flag"); // 0 - ok, 1 - error
- msg.readInt16("unused");
-}
-
-void CharServerRecv::processCharDeleteFailed(Net::MessageIn &msg)
-{
- BLOCK_START("CharServerRecv::processCharDeleteFailed")
- Net::CharServerHandler::unlockCharSelectDialog();
- msg.readUInt8("error");
- CREATEWIDGET(OkDialog,
- // TRANSLATORS: error header
- _("Error"),
- // TRANSLATORS: error message
- _("Failed to delete character."),
- // TRANSLATORS: ok dialog button
- _("OK"),
- DialogType::ERROR,
- Modal_true,
- ShowCenter_true,
- nullptr,
- 260);
- BLOCK_END("CharServerRecv::processCharDeleteFailed")
-}
-
-void CharServerRecv::processCharCaptchaNotSupported(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readInt16("5");
- msg.readUInt8("1");
-}
-
-void CharServerRecv::processCharDelete2Ack(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readInt32("char id");
- msg.readInt32("result");
- // for packets before 20130000, this is raw time
- // in other case raw time - time(NULL)
- msg.readInt32("time");
-}
-
-void CharServerRecv::processCharDelete2AcceptActual(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readInt32("char id");
- msg.readInt32("result");
-}
-
-void CharServerRecv::processCharDelete2CancelAck(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readInt32("char id");
- msg.readInt32("result");
-}
-
-void CharServerRecv::processCharCharacters(Net::MessageIn &msg)
-{
- msg.skip(2, "packet len");
-
- delete_all(Net::CharServerHandler::mCharacters);
- Net::CharServerHandler::mCharacters.clear();
-
- // Derive number of characters from message length
- const int count = (msg.getLength() - 4)
- / (106 + 4 + 2 + 16 + 4 + 4 + 4 + 4);
-
- for (int i = 0; i < count; ++i)
- {
- Net::Character *const character = new Net::Character;
- readPlayerData(msg, character);
- Net::CharServerHandler::mCharacters.push_back(character);
- if (character->dummy != nullptr)
- {
- logger->log("CharServer: Player: %s (%d)",
- character->dummy->getName().c_str(), character->slot);
- }
- }
-
- client->setState(State::CHAR_SELECT);
-}
-
-void CharServerRecv::processCharBanCharList(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- const int count = (msg.readInt16("len") - 4) / 24;
- for (int f = 0; f < count; f ++)
- {
- msg.readInt32("char id");
- msg.readString(20, "unbun time");
- }
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/charserverrecv.h b/src/net/eathena/charserverrecv.h
deleted file mode 100644
index df37ed363..000000000
--- a/src/net/eathena/charserverrecv.h
+++ /dev/null
@@ -1,68 +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 NET_EATHENA_CHARSERVERRECV_H
-#define NET_EATHENA_CHARSERVERRECV_H
-
-#include "enums/simpletypes/beingid.h"
-
-#include <string>
-
-namespace Net
-{
- class MessageIn;
-
- struct Character;
-} // namespace Net
-
-namespace EAthena
-{
- namespace CharServerRecv
- {
- extern std::string mNewName;
- extern uint32_t mPinSeed;
- extern BeingId mPinAccountId;
- extern BeingId mRenameId;
- extern bool mNeedCreatePin;
-
- void readPlayerData(Net::MessageIn &msg,
- Net::Character *const character);
- void processPincodeStatus(Net::MessageIn &msg);
- void processCharLogin2(Net::MessageIn &msg);
- void processCharCreate(Net::MessageIn &msg);
- void processCharCheckRename(Net::MessageIn &msg);
- void processCharRename(Net::MessageIn &msg);
- void processCharChangeSlot(Net::MessageIn &msg);
- void processCharDeleteFailed(Net::MessageIn &msg);
- void processCharCaptchaNotSupported(Net::MessageIn &msg);
- void processCharDelete2Ack(Net::MessageIn &msg);
- void processCharDelete2AcceptActual(Net::MessageIn &msg);
- void processCharDelete2CancelAck(Net::MessageIn &msg);
- void processCharCharacters(Net::MessageIn &msg);
- void processCharBanCharList(Net::MessageIn &msg);
- void processCharLogin(Net::MessageIn &msg);
- void processCharMapInfo(Net::MessageIn &msg);
- void processChangeMapServer(Net::MessageIn &msg);
- } // namespace CharServerRecv
-} // namespace EAthena
-
-#endif // NET_EATHENA_CHARSERVERRECV_H
diff --git a/src/net/eathena/chathandler.cpp b/src/net/eathena/chathandler.cpp
deleted file mode 100644
index 6b8e0517b..000000000
--- a/src/net/eathena/chathandler.cpp
+++ /dev/null
@@ -1,338 +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 "net/eathena/chathandler.h"
-
-#include "being/localplayer.h"
-
-#include "net/serverfeatures.h"
-
-#include "net/ea/chatrecv.h"
-
-#include "net/eathena/chatrecv.h"
-#include "net/eathena/messageout.h"
-#include "net/eathena/protocolout.h"
-
-#include "resources/chatobject.h"
-
-#include "utils/stringutils.h"
-
-#include "debug.h"
-
-extern int packetVersion;
-
-namespace EAthena
-{
-
-ChatHandler::ChatHandler() :
- Ea::ChatHandler()
-{
- chatHandler = this;
-}
-
-ChatHandler::~ChatHandler()
-{
- chatHandler = nullptr;
-}
-
-void ChatHandler::talk(const std::string &restrict text,
- const std::string &restrict channel A_UNUSED) const
-{
- if (localPlayer == nullptr)
- return;
-
- const std::string mes = std::string(localPlayer->getName()).append(
- " : ").append(text);
-
- createOutPacket(CMSG_CHAT_MESSAGE);
- if (packetVersion >= 20151001)
- {
- outMsg.writeInt16(CAST_S16(mes.length() + 4), "len");
- outMsg.writeString(mes, CAST_S32(mes.length()), "message");
- }
- else
- {
- // Added + 1 in order to let eAthena parse admin commands correctly
- outMsg.writeInt16(CAST_S16(mes.length() + 4 + 1), "len");
- outMsg.writeString(mes, CAST_S32(mes.length() + 1), "message");
- }
-}
-
-void ChatHandler::talkRaw(const std::string &mes) const
-{
- createOutPacket(CMSG_CHAT_MESSAGE);
- outMsg.writeInt16(CAST_S16(mes.length() + 4), "len");
- outMsg.writeString(mes, CAST_S32(mes.length()), "message");
-}
-
-void ChatHandler::privateMessage(const std::string &restrict recipient,
- const std::string &restrict text) const
-{
- createOutPacket(CMSG_CHAT_WHISPER);
- if (packetVersion >= 20151001)
- {
- outMsg.writeInt16(CAST_S16(text.length() + 28), "len");
- outMsg.writeString(recipient, 24, "recipient nick");
- outMsg.writeString(text, CAST_S32(text.length()), "message");
- }
- else
- {
- outMsg.writeInt16(CAST_S16(text.length() + 28 + 1), "len");
- outMsg.writeString(recipient, 24, "recipient nick");
- outMsg.writeString(text, CAST_S32(text.length()), "message");
- outMsg.writeInt8(0, "null char");
- }
- Ea::ChatRecv::mSentWhispers.push(recipient);
-}
-
-void ChatHandler::channelMessage(const std::string &restrict channel,
- const std::string &restrict text) const
-{
- privateMessage(channel, text);
-}
-
-void ChatHandler::who() const
-{
- createOutPacket(CMSG_WHO_REQUEST);
-}
-
-void ChatHandler::sendRaw(const std::string &args) const
-{
- std::string line = args;
- std::string str;
- MessageOut *outMsg = nullptr;
-
- if (line.empty())
- return;
-
- size_t pos = line.find(' ');
- if (pos != std::string::npos)
- {
- str = line.substr(0, pos);
-
- const int16_t id = CAST_S16(parseNumber(str));
- outMsg = new MessageOut(id);
- outMsg->writeInt16(id, "packet id");
- line = line.substr(pos + 1);
- pos = line.find(' ');
- }
- else
- {
- const int16_t id = CAST_S16(parseNumber(line));
- outMsg = new MessageOut(id);
- outMsg->writeInt16(id, "packet id");
- delete outMsg;
- return;
- }
-
- while (pos != std::string::npos)
- {
- str = line.substr(0, pos);
- processRaw(*outMsg, str);
- line = line.substr(pos + 1);
- pos = line.find(' ');
- }
- if (!line.empty())
- processRaw(*outMsg, line);
- delete outMsg;
-}
-
-void ChatHandler::processRaw(MessageOut &restrict outMsg,
- const std::string &restrict line)
-{
- if (line.size() < 2)
- return;
-
- const uint32_t i = parseNumber(line.substr(1));
- switch (tolower(line[0]))
- {
- case 'b':
- {
- outMsg.writeInt8(CAST_U8(i), "raw");
- break;
- }
- case 'w':
- {
- outMsg.writeInt16(CAST_S16(i), "raw");
- break;
- }
- case 'l':
- {
- outMsg.writeInt32(CAST_S32(i), "raw");
- break;
- }
- default:
- break;
- }
-}
-
-void ChatHandler::ignoreAll() const
-{
- createOutPacket(CMSG_IGNORE_ALL);
- outMsg.writeInt8(0, "flag");
-}
-
-void ChatHandler::unIgnoreAll() const
-{
- createOutPacket(CMSG_IGNORE_ALL);
- outMsg.writeInt8(1, "flag");
-}
-
-
-void ChatHandler::ignore(const std::string &nick) const
-{
- createOutPacket(CMSG_IGNORE_NICK);
- outMsg.writeString(nick, 24, "nick");
- outMsg.writeInt8(0, "flag");
-}
-
-void ChatHandler::unIgnore(const std::string &nick) const
-{
- createOutPacket(CMSG_IGNORE_NICK);
- outMsg.writeString(nick, 24, "nick");
- outMsg.writeInt8(1, "flag");
-}
-
-void ChatHandler::requestIgnoreList() const
-{
- createOutPacket(CMSG_REQUEST_IGNORE_LIST);
-}
-
-void ChatHandler::createChatRoom(const std::string &title,
- const std::string &password,
- const int limit,
- const bool isPublic) const
-{
- createOutPacket(CMSG_CREAYE_CHAT_ROOM);
- outMsg.writeInt16(CAST_S16(
- 7 + 8 + 36), "len");
- outMsg.writeInt16(CAST_S16(limit), "limit");
- outMsg.writeInt8(CAST_S8(isPublic ? 1 : 0), "public");
- outMsg.writeString(password, 8, "password");
- outMsg.writeString(title, 36, "title");
- ChatRecv::mChatRoom = title;
-}
-
-void ChatHandler::battleTalk(const std::string &text) const
-{
- if (localPlayer == nullptr)
- return;
-
- const std::string mes = std::string(localPlayer->getName()).append(
- " : ").append(text);
-
- createOutPacket(CMSG_BATTLE_CHAT_MESSAGE);
- if (packetVersion >= 20151001)
- {
- outMsg.writeInt16(CAST_S16(mes.length() + 4), "len");
- outMsg.writeString(mes, CAST_S32(mes.length()), "message");
- }
- else
- {
- // Added + 1 in order to let eAthena parse admin commands correctly
- outMsg.writeInt16(CAST_S16(mes.length() + 4 + 1), "len");
- outMsg.writeString(mes, CAST_S32(mes.length() + 1), "message");
- }
-}
-
-void ChatHandler::joinChat(const ChatObject *const chat,
- const std::string &password) const
-{
- if (chat == nullptr)
- return;
-
- createOutPacket(CMSG_CHAT_ROOM_JOIN);
- outMsg.writeInt32(chat->chatId, "chat id");
- outMsg.writeString(password, 8, "password");
-}
-
-void ChatHandler::joinChannel(const std::string &channel) const
-{
- if (serverFeatures->haveJoinChannel())
- {
- createOutPacket(CMSG_CHAT_JOIN_CHANNEL);
- outMsg.writeString(channel, 24, "channel name");
- }
- else
- {
- channelMessage(channel, "\302\202\302");
- }
-}
-
-void ChatHandler::partChannel(const std::string &channel) const
-{
- if (serverFeatures->haveJoinChannel())
- {
- createOutPacket(CMSG_CHAT_PART_CHANNEL);
- outMsg.writeString(channel, 24, "channel name");
- }
-}
-
-void ChatHandler::talkPet(const std::string &restrict text,
- const std::string &restrict channel A_UNUSED) const
-{
- if (text.empty())
- return;
- std::string msg = text;
- if (msg.size() > 500)
- msg = msg.substr(0, 500);
- const size_t sz = msg.size();
-
- createOutPacket(CMSG_PET_TALK);
- outMsg.writeInt16(CAST_S16(sz + 4 + 1), "len");
- outMsg.writeString(msg, CAST_S32(sz), "message");
- outMsg.writeInt8(0, "zero byte");
-}
-
-void ChatHandler::leaveChatRoom() const
-{
- createOutPacket(CMSG_LEAVE_CHAT_ROOM);
-}
-
-void ChatHandler::setChatRoomOptions(const int limit,
- const bool isPublic,
- const std::string &password,
- const std::string &title) const
-{
- createOutPacket(CMSG_SET_CHAT_ROOM_OPTIONS);
- const int sz = CAST_S32(title.size());
- outMsg.writeInt16(CAST_S16(15 + sz), "len");
- outMsg.writeInt16(CAST_S16(limit), "limit");
- outMsg.writeInt8(CAST_S8(isPublic ? 1 : 0), "type");
- outMsg.writeString(password, 8, "password");
- outMsg.writeString(title, sz, "title");
-}
-
-void ChatHandler::setChatRoomOwner(const std::string &nick) const
-{
- createOutPacket(CMSG_SET_CHAT_ROOM_OWNER);
- outMsg.writeInt32(0, "role (unused)");
- outMsg.writeString(nick, 24, "nick");
-}
-
-void ChatHandler::kickFromChatRoom(const std::string &nick) const
-{
- createOutPacket(CMSG_KICK_FROM_CHAT_ROOM);
- outMsg.writeString(nick, 24, "nick");
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/chathandler.h b/src/net/eathena/chathandler.h
deleted file mode 100644
index 685327cd3..000000000
--- a/src/net/eathena/chathandler.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 NET_EATHENA_CHATHANDLER_H
-#define NET_EATHENA_CHATHANDLER_H
-
-#include "net/ea/chathandler.h"
-
-namespace EAthena
-{
-class MessageOut;
-
-class ChatHandler final : public Ea::ChatHandler
-{
- public:
- ChatHandler();
-
- A_DELETE_COPY(ChatHandler)
-
- ~ChatHandler();
-
- void talk(const std::string &restrict text,
- const std::string &restrict channel) const override final;
-
- void talkRaw(const std::string &text) const override final;
-
- void privateMessage(const std::string &restrict recipient,
- const std::string &restrict text) const
- override final;
-
- void channelMessage(const std::string &restrict channel,
- const std::string &restrict text) const
- override final;
-
- void joinChannel(const std::string &channel) const override final;
-
- void who() const override final;
-
- void sendRaw(const std::string &args) const override final;
-
- void ignoreAll() const override final;
-
- void unIgnoreAll() const override final;
-
- void createChatRoom(const std::string &title,
- const std::string &password,
- const int limit,
- const bool isPublic) const override final;
-
- void ignore(const std::string &nick) const override final;
-
- void unIgnore(const std::string &nick) const override final;
-
- void requestIgnoreList() const override final;
-
- void battleTalk(const std::string &text) const override final;
-
- void joinChat(const ChatObject *const chat,
- const std::string &password) const override final;
-
- void partChannel(const std::string &channel) const override final;
-
- void talkPet(const std::string &restrict text,
- const std::string &restrict channel) const override final;
-
- void leaveChatRoom() const override final;
-
- void setChatRoomOptions(const int limit,
- const bool isPublic,
- const std::string &password,
- const std::string &title) const override final;
-
- void setChatRoomOwner(const std::string &nick) const override final;
-
- void kickFromChatRoom(const std::string &nick) const override final;
-
- protected:
- static void processRaw(MessageOut &restrict outMsg,
- const std::string &restrict line);
-};
-
-} // namespace EAthena
-
-#endif // NET_EATHENA_CHATHANDLER_H
diff --git a/src/net/eathena/chatrecv.cpp b/src/net/eathena/chatrecv.cpp
deleted file mode 100644
index 97f0de803..000000000
--- a/src/net/eathena/chatrecv.cpp
+++ /dev/null
@@ -1,768 +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 "net/eathena/chatrecv.h"
-
-#include "actormanager.h"
-#include "notifymanager.h"
-
-#include "being/localplayer.h"
-#include "being/playerinfo.h"
-#include "being/playerrelation.h"
-#include "being/playerrelations.h"
-
-#include "const/gui/chat.h"
-
-#include "enums/resources/notifytypes.h"
-
-#include "gui/windows/chatwindow.h"
-
-#include "gui/widgets/tabs/chat/chattab.h"
-
-#include "net/messagein.h"
-
-#include "net/ea/chatrecv.h"
-
-#include "net/eathena/mercenaryrecv.h"
-
-#include "resources/chatobject.h"
-#include "utils/gettext.h"
-#include "utils/stringutils.h"
-
-#include "debug.h"
-
-namespace EAthena
-{
-
-namespace ChatRecv
-{
- std::string mChatRoom;
-} // namespace ChatRecv
-
-void ChatRecv::processIgnoreNickAck(Net::MessageIn &msg)
-{
- const int type = msg.readUInt8("type");
- const int flag = msg.readUInt8("flag");
- switch (type)
- {
- case 0:
- switch (flag)
- {
- case 0:
- NotifyManager::notify(NotifyTypes::IGNORE_PLAYER_SUCCESS);
- break;
- case 1:
- NotifyManager::notify(NotifyTypes::IGNORE_PLAYER_FAILURE);
- break;
- case 2:
- NotifyManager::notify(NotifyTypes::IGNORE_PLAYER_TOO_MANY);
- break;
- default:
- NotifyManager::notify(NotifyTypes::IGNORE_PLAYER_UNKNOWN);
- break;
- }
- break;
- case 1:
- switch (flag)
- {
- case 0:
- NotifyManager::notify(
- NotifyTypes::UNIGNORE_PLAYER_SUCCESS);
- break;
- case 1:
- NotifyManager::notify(
- NotifyTypes::UNIGNORE_PLAYER_FAILURE);
- break;
- default:
- NotifyManager::notify(
- NotifyTypes::UNIGNORE_PLAYER_UNKNOWN);
- break;
- }
- break;
-
- default:
- NotifyManager::notify(NotifyTypes::IGNORE_PLAYER_TYPE_UNKNOWN);
- break;
- }
-}
-
-void ChatRecv::processChat(Net::MessageIn &msg)
-{
- BLOCK_START("ChatRecv::processChat")
- const int chatMsgLength = msg.readInt16("len") - 4;
- if (chatMsgLength <= 0)
- {
- BLOCK_END("ChatRecv::processChat")
- return;
- }
-
- processChatContinue(msg.readRawString(chatMsgLength, "message"),
- ChatMsgType::BY_PLAYER);
-}
-
-void ChatRecv::processFormatMessage(Net::MessageIn &msg)
-{
- const int msgId = msg.readInt16("msg id");
- // +++ here need load message from configuration file
- std::string chatMsg;
- if (msgId >= 1266 && msgId <= 1269)
- {
- MercenaryRecv::handleMercenaryMessage(msgId - 1266);
- return;
- }
- switch (msgId)
- {
- case 1334:
- // TRANSLATORS: error message
- chatMsg = _("Can't cast skill in this area.");
- break;
- case 1335:
- // TRANSLATORS: error message
- chatMsg = _("Can't use item in this area.");
- break;
- case 1773:
- // TRANSLATORS: error message
- chatMsg = _("Can't equip. Wrong level.");
- break;
- case 1774:
- // TRANSLATORS: error message
- chatMsg = _("Can't use. Wrong level.");
- break;
- case 1923:
- // TRANSLATORS: error message
- chatMsg = _("Work in progress."); // busy with npc
- break;
- default:
- chatMsg = strprintf("Message #%d", msgId);
- break;
- }
- processChatContinue(chatMsg, ChatMsgType::BY_SERVER);
-}
-
-void ChatRecv::processFormatMessageNumber(Net::MessageIn &msg)
-{
- const int msgId = msg.readInt16("msg id");
- const int value = msg.readInt32("value");
- if (msgId == 1862)
- {
- NotifyManager::notify(NotifyTypes::USE_ITEM_WAIT, value);
- return;
- }
- // +++ here need load message from configuration file
- const std::string chatMsg = strprintf(
- "Message #%d, value: %d", msgId, value);
- processChatContinue(chatMsg, ChatMsgType::BY_SERVER);
-}
-
-void ChatRecv::processFormatMessageSkill(Net::MessageIn &msg)
-{
- const int skillId = msg.readInt16("skill id");
- const int msgId = msg.readInt32("msg id");
- // +++ here need load message from configuration file
- const std::string chatMsg = strprintf(
- "Message #%d, skill: %d", msgId, skillId);
- processChatContinue(chatMsg, ChatMsgType::BY_SERVER);
-}
-
-void ChatRecv::processColorChat(Net::MessageIn &msg)
-{
- BLOCK_START("ChatRecv::processChat")
- int chatMsgLength = msg.readInt16("len") - 4;
- msg.readInt32("unused");
- msg.readInt32("chat color");
- chatMsgLength -= 8;
- if (chatMsgLength <= 0)
- {
- BLOCK_END("ChatRecv::processChat")
- return;
- }
-
- std::string message = msg.readRawString(chatMsgLength, "message");
- std::string msg2 = message;
- if (findCutFirst(msg2, "You're now in the '#") && findCutLast(msg2, "'"))
- {
- const size_t idx = msg2.find("' channel for '");
- if (idx != std::string::npos && (chatWindow != nullptr))
- {
- chatWindow->addChannelTab(std::string("#").append(
- msg2.substr(0, idx)), false);
- return;
- }
- }
- else
- {
- const std::string nick = Ea::ChatRecv::getLastWhisperNick();
- if (nick.size() > 1 && nick[0] == '#')
- {
- if (message == strprintf("[ %s ] %s : \302\202\302",
- nick.c_str(), localPlayer->getName().c_str()))
- {
- Ea::ChatRecv::mSentWhispers.pop();
- }
- }
- }
- processChatContinue(message, ChatMsgType::BY_UNKNOWN);
-}
-
-std::string ChatRecv::extractChannelFromMessage(std::string &chatMsg)
-{
- std::string msg = chatMsg;
- std::string channel(GENERAL_CHANNEL);
- if (findCutFirst(msg, "[ #"))
- { // found channel message
- const size_t idx = msg.find(" ] ");
- if (idx != std::string::npos)
- {
- channel = std::string("#").append(msg.substr(0, idx));
- chatMsg = msg.substr(idx + 3);
- }
- }
- return channel;
-}
-
-void ChatRecv::processChatContinue(std::string chatMsg,
- const ChatMsgTypeT own)
-{
- const std::string channel = extractChannelFromMessage(chatMsg);
- bool allow(true);
- if (chatWindow != nullptr)
- {
- allow = chatWindow->resortChatLog(chatMsg,
- own,
- channel,
- IgnoreRecord_false,
- TryRemoveColors_true);
- }
-
- const size_t pos = chatMsg.find(" : ", 0);
- if (pos != std::string::npos)
- chatMsg.erase(0, pos + 3);
-
- trim(chatMsg);
-
- if (localPlayer != nullptr)
- {
- if (((chatWindow != nullptr) || Ea::ChatRecv::mShowMotd) && allow)
- localPlayer->setSpeech(chatMsg, GENERAL_CHANNEL);
- }
- BLOCK_END("ChatRecv::processChat")
-}
-
-void ChatRecv::processGmChat(Net::MessageIn &msg)
-{
- BLOCK_START("ChatRecv::processChat")
- const int chatMsgLength = msg.readInt16("len") - 4;
- if (chatMsgLength <= 0)
- {
- BLOCK_END("ChatRecv::processChat")
- return;
- }
-
- std::string chatMsg = msg.readRawString(chatMsgLength, "message");
- // remove non persistend "colors" from server.
- if (!findCutFirst(chatMsg, "ssss"))
- findCutFirst(chatMsg, "eulb");
-
- if (chatWindow != nullptr)
- chatWindow->addGlobalMessage(chatMsg);
- BLOCK_END("ChatRecv::processChat")
-}
-
-void ChatRecv::processGmChat2(Net::MessageIn &msg)
-{
- const int chatMsgLength = msg.readInt16("len") - 16;
- msg.readInt32("font color");
- msg.readInt16("font type");
- msg.readInt16("font size");
- msg.readInt16("font align");
- msg.readInt16("font y");
- if (chatWindow != nullptr)
- {
- const std::string chatMsg = msg.readRawString(chatMsgLength,
- "message");
- chatWindow->addGlobalMessage(chatMsg);
- }
- else
- {
- msg.readRawString(chatMsgLength, "message");
- }
-}
-
-void ChatRecv::processWhisper(Net::MessageIn &msg)
-{
- BLOCK_START("ChatRecv::processWhisper")
- int packetLen = 28;
- if (msg.getVersion() >= 20091104)
- packetLen += 4;
- const int chatMsgLength = msg.readInt16("len") - packetLen;
- std::string nick = msg.readString(24, "nick");
- if (msg.getVersion() >= 20091104)
- msg.readInt32("admin flag");
-
- if (chatMsgLength <= 0)
- {
- BLOCK_END("ChatRecv::processWhisper")
- return;
- }
-
- processWhisperContinue(nick, msg.readString(chatMsgLength, "message"));
-}
-
-void ChatRecv::processWhisperResponse(Net::MessageIn &msg)
-{
- BLOCK_START("ChatRecv::processWhisperResponse")
-
- const uint8_t type = msg.readUInt8("response");
- if (msg.getVersion() >= 20131223)
- msg.readInt32("unknown");
- if (type == 1 && (chatWindow != nullptr))
- {
- const std::string nick = Ea::ChatRecv::getLastWhisperNick();
- if (nick.size() > 1 && nick[0] == '#')
- {
- chatWindow->channelChatLog(nick,
- // TRANSLATORS: chat message
- strprintf(_("Message could not be sent, channel "
- "%s is not exists."), nick.c_str()),
- ChatMsgType::BY_SERVER,
- IgnoreRecord_false,
- TryRemoveColors_false);
- if (!Ea::ChatRecv::mSentWhispers.empty())
- Ea::ChatRecv::mSentWhispers.pop();
- return;
- }
- }
- Ea::ChatRecv::processWhisperResponseContinue(msg, type);
-}
-
-void ChatRecv::processChatIgnoreList(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- // +++ need put it in some object or window
- const int count = (msg.readInt16("len") - 4) / 24;
- for (int f = 0; f < count; f ++)
- msg.readString(24, "nick");
-}
-
-void ChatRecv::processChatDisplay(Net::MessageIn &msg)
-{
- const int len = msg.readInt16("len") - 17;
- ChatObject *const obj = new ChatObject;
- obj->ownerId = msg.readBeingId("owner account id");
- obj->chatId = msg.readInt32("chat id");
- obj->maxUsers = msg.readInt16("max users");
- obj->currentUsers = msg.readInt16("current users");
- obj->type = msg.readUInt8("type");
- obj->title = msg.readString(len, "title");
- obj->update();
-
- Being *const dstBeing = actorManager->findBeing(obj->ownerId);
- if (dstBeing != nullptr)
- dstBeing->setChat(obj);
-}
-
-void ChatRecv::processChatRoomJoinAck(Net::MessageIn &msg)
-{
- const int count = (msg.readInt16("len") - 8) / 28;
- const int id = msg.readInt32("chat id");
-
- // +++ ignore chat members for now
- for (int f = 0; f < count; f ++)
- {
- msg.readInt32("role");
- msg.readString(24, "name");
- }
-
- const ChatObject *const oldChat = ChatObject::findById(id);
-
- if (oldChat != nullptr)
- PlayerInfo::setRoomName(oldChat->title);
- else
- PlayerInfo::setRoomName(std::string());
- chatWindow->joinRoom(true);
- ChatObject *const obj = new ChatObject;
- if (oldChat != nullptr)
- {
- obj->ownerId = oldChat->ownerId;
- obj->chatId = oldChat->chatId;
- obj->maxUsers = oldChat->maxUsers;
- obj->currentUsers = oldChat->currentUsers;
- obj->type = oldChat->type;
- obj->title = oldChat->title;
-// obj->update();
- }
- localPlayer->setChat(obj);
-}
-
-void ChatRecv::processChatRoomLeave(Net::MessageIn &msg)
-{
- msg.readInt16("users");
- const std::string name = msg.readString(24, "name");
- const int status = msg.readUInt8("flag"); // 0 - left, 1 - kicked
- switch (status)
- {
- case 0:
- NotifyManager::notify(NotifyTypes::ROOM_LEAVE, name);
- break;
- case 1:
- NotifyManager::notify(NotifyTypes::ROOM_KICKED, name);
- break;
- default:
- UNIMPLEMENTEDPACKETFIELD(status);
- break;
- }
- if ((localPlayer != nullptr) && name == localPlayer->getName())
- {
- if (chatWindow != nullptr)
- chatWindow->joinRoom(false);
- PlayerInfo::setRoomName(std::string());
- if (localPlayer != nullptr)
- localPlayer->setChat(nullptr);
- }
- else
- {
- Being *const being = actorManager->findBeingByName(
- name, ActorType::Player);
- if (being != nullptr)
- being->setChat(nullptr);
- }
-}
-
-void ChatRecv::processJoinChannel(Net::MessageIn &msg)
-{
- if (chatWindow == nullptr)
- return;
-
- const std::string channel = msg.readString(24, "channel name");
- const int flag = msg.readUInt8("flag");
-
- if (channel.size() < 2)
- return;
- switch (flag)
- {
- case 0:
- default:
- chatWindow->channelChatLog(channel,
- // TRANSLATORS: chat message
- strprintf(_("Can't open channel. Channel "
- "%s is not exists."), channel.c_str()),
- ChatMsgType::BY_SERVER,
- IgnoreRecord_false,
- TryRemoveColors_false);
- break;
-
- case 1:
- case 2:
- chatWindow->addChannelTab(std::string("#").append(
- channel.substr(1)), false);
- break;
- }
-}
-
-void ChatRecv::processWhisperContinue(const std::string &nick,
- std::string chatMsg)
-{
- // ignoring future whisper messages
- if (chatMsg.find("\302\202G") == 0 || chatMsg.find("\302\202A") == 0)
- {
- BLOCK_END("ChatRecv::processWhisper")
- return;
- }
- // remove first unicode space if this is may be whisper command.
- if (chatMsg.find("\302\202!") == 0)
- chatMsg = chatMsg.substr(2);
-
- if (nick != "Server")
- {
- if (playerRelations.hasPermission(nick, PlayerRelation::WHISPER))
- chatWindow->addWhisper(nick, chatMsg);
- }
- else if (localChatTab != nullptr)
- {
- localChatTab->chatLog(chatMsg, ChatMsgType::BY_SERVER);
- }
- BLOCK_END("ChatRecv::processWhisper")
-}
-
-void ChatRecv::processBeingChat(Net::MessageIn &msg)
-{
- if (actorManager == nullptr)
- return;
-
- BLOCK_START("ChatRecv::processBeingChat")
- const int chatMsgLength = msg.readInt16("len") - 8;
- Being *const being = actorManager->findBeing(msg.readBeingId("being id"));
-
- if (chatMsgLength <= 0)
- {
- BLOCK_END("ChatRecv::processBeingChat")
- return;
- }
-
- std::string chatMsg = msg.readRawString(chatMsgLength, "message");
-
- if ((being != nullptr) && being->getType() == ActorType::Player)
- being->setTalkTime();
-
- const size_t pos = chatMsg.find(" : ", 0);
- std::string sender_name = ((pos == std::string::npos)
- ? "" : chatMsg.substr(0, pos));
-
- if ((being != nullptr) && sender_name != being->getName()
- && being->getType() == ActorType::Player)
- {
- if (!being->getName().empty())
- sender_name = being->getName();
- }
- else
- {
- chatMsg.erase(0, pos + 3);
- }
-
- trim(chatMsg);
-
- bool allow(true);
- // We use getIgnorePlayer instead of ignoringPlayer here
- // because ignorePlayer' side effects are triggered
- // right below for Being::IGNORE_SPEECH_FLOAT.
- if ((playerRelations.checkPermissionSilently(sender_name,
- PlayerRelation::SPEECH_LOG) != 0u) && (chatWindow != nullptr))
- {
- allow = chatWindow->resortChatLog(
- removeColors(sender_name).append(" : ").append(chatMsg),
- ChatMsgType::BY_OTHER,
- GENERAL_CHANNEL,
- IgnoreRecord_false,
- TryRemoveColors_true);
- }
-
- if (allow &&
- being != nullptr &&
- playerRelations.hasPermission(sender_name,
- PlayerRelation::SPEECH_FLOAT))
- {
- being->setSpeech(chatMsg, GENERAL_CHANNEL);
- }
- BLOCK_END("ChatRecv::processBeingChat")
-}
-
-void ChatRecv::processChatRoomCreateAck(Net::MessageIn &msg)
-{
- const int result = msg.readUInt8("flag");
- switch (result)
- {
- case 0:
- {
- PlayerInfo::setRoomName(mChatRoom);
- chatWindow->joinRoom(true);
- ChatObject *const obj = new ChatObject;
- obj->ownerId = localPlayer->getId();
- obj->chatId = 0;
- obj->maxUsers = 1000;
- obj->currentUsers = 1;
- obj->type = 1;
- obj->title = mChatRoom;
- obj->update();
- localPlayer->setChat(obj);
- break;
- }
- case 1:
- NotifyManager::notify(NotifyTypes::ROOM_LIMIT_EXCEEDED);
- break;
- case 2:
- NotifyManager::notify(NotifyTypes::ROOM_ALREADY_EXISTS);
- break;
- default:
- UNIMPLEMENTEDPACKETFIELD(result);
- break;
- }
- mChatRoom.clear();
-}
-
-void ChatRecv::processChatRoomDestroy(Net::MessageIn &msg)
-{
- const int chatId = msg.readInt32("chat id");
- actorManager->removeRoom(chatId);
-}
-
-void ChatRecv::processChatRoomJoinFailed(Net::MessageIn &msg)
-{
- const int result = msg.readUInt8("flag");
- switch (result)
- {
- case 0:
- NotifyManager::notify(NotifyTypes::ROOM_ERROR_FULL);
- break;
- case 1:
- NotifyManager::notify(NotifyTypes::ROOM_ERROR_WRONG_PASSWORD);
- break;
- case 2:
- NotifyManager::notify(NotifyTypes::ROOM_ERROR_KICKED);
- break;
- case 3:
- break;
- case 4:
- NotifyManager::notify(NotifyTypes::ROOM_ERROR_ZENY);
- break;
- case 5:
- NotifyManager::notify(NotifyTypes::ROOM_ERROR_LOW_LEVEL);
- break;
- case 6:
- NotifyManager::notify(NotifyTypes::ROOM_ERROR_HIGH_LEVEL);
- break;
- case 7:
- NotifyManager::notify(NotifyTypes::ROOM_ERROR_RACE);
- break;
- default:
- UNIMPLEMENTEDPACKETFIELD(result);
- break;
- }
-}
-
-void ChatRecv::processChatRoomAddMember(Net::MessageIn &msg)
-{
- msg.readInt16("users");
- const std::string name = msg.readString(24, "name");
- if (localChatTab == nullptr)
- return;
- NotifyManager::notify(NotifyTypes::ROOM_JOINED, name);
-}
-
-void ChatRecv::processChatRoomSettings(Net::MessageIn &msg)
-{
- const int sz = msg.readInt16("len") - 17;
- const BeingId ownerId = msg.readBeingId("owner id");
- const int chatId = msg.readInt32("chat id");
- const uint16_t limit = msg.readInt16("limit");
- msg.readInt16("users");
- const uint8_t type = msg.readUInt8("type");
- const std::string &title = msg.readString(sz, "title");
- ChatObject *const chat = localPlayer->getChat();
- if ((chat != nullptr) && chat->chatId == chatId)
- {
- chat->ownerId = ownerId;
- chat->maxUsers = limit;
- chat->type = type;
- if (chat->title != title)
- {
- chat->title = title;
- actorManager->updateRoom(chat);
- chatWindow->joinRoom(true);
- }
- }
-}
-
-void ChatRecv::processChatRoomRoleChange(Net::MessageIn &msg)
-{
- const int role = msg.readInt32("role");
- const std::string name = msg.readString(24, "name");
- switch (role)
- {
- case 0:
- NotifyManager::notify(NotifyTypes::ROOM_ROLE_OWNER, name);
- break;
- case 1:
- // dont show normal role
- break;
- default:
- UNIMPLEMENTEDPACKETFIELD(role);
- break;
- }
-}
-
-void ChatRecv::processMVPItem(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readInt16("item id");
-}
-
-void ChatRecv::processMVPExp(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readInt32("exo");
-}
-
-void ChatRecv::processMVPNoItem(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
-}
-
-void ChatRecv::processMannerMessage(Net::MessageIn &msg)
-{
- const int result = msg.readInt32("type");
- switch (result)
- {
- case 0:
- NotifyManager::notify(NotifyTypes::MANNER_CHANGED);
- break;
- case 5:
- break;
- default:
- UNIMPLEMENTEDPACKETFIELD(result);
- break;
- }
-}
-
-void ChatRecv::processChatSilence(Net::MessageIn &msg)
-{
- const int result = msg.readUInt8("type");
- const std::string name = msg.readString(24, "gm name");
-
- switch (result)
- {
- case 0:
- NotifyManager::notify(NotifyTypes::MANNER_POSITIVE_POINTS, name);
- break;
- case 1:
- NotifyManager::notify(NotifyTypes::MANNER_NEGATIVE_POINTS, name);
- break;
- default:
- UNIMPLEMENTEDPACKETFIELD(result);
- break;
- }
-}
-
-void ChatRecv::processChatTalkieBox(Net::MessageIn &msg)
-{
- msg.readBeingId("being id");
- const std::string message = msg.readString(80, "message");
- localChatTab->chatLog(message, ChatMsgType::BY_SERVER);
-}
-
-void ChatRecv::processBattleChatMessage(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- const int sz = msg.readInt16("len") - 24 - 8;
- msg.readBeingId("account id");
- msg.readString(24, "nick");
- msg.readString(sz, "message");
-}
-
-void ChatRecv::processScriptMessage(Net::MessageIn &msg)
-{
- const int sz = msg.readInt16("len") - 8;
- msg.readBeingId("being id");
- const std::string message = msg.readString(sz, "message");
- localChatTab->chatLog(message, ChatMsgType::BY_SERVER);
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/chatrecv.h b/src/net/eathena/chatrecv.h
deleted file mode 100644
index 0f072bee6..000000000
--- a/src/net/eathena/chatrecv.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 NET_EATHENA_CHATRECV_H
-#define NET_EATHENA_CHATRECV_H
-
-#include "enums/gui/chatmsgtype.h"
-
-#include <string>
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-namespace EAthena
-{
- namespace ChatRecv
- {
- std::string extractChannelFromMessage(std::string &chatMsg);
- void processChat(Net::MessageIn &msg);
- void processColorChat(Net::MessageIn &msg);
- void processChatContinue(std::string chatMsg,
- const ChatMsgTypeT own);
- void processWhisper(Net::MessageIn &msg);
- void processWhisperResponse(Net::MessageIn &msg);
- void processGmChat(Net::MessageIn &msg);
- void processGmChat2(Net::MessageIn &msg);
- void processChatIgnoreList(Net::MessageIn &msg);
- void processFormatMessage(Net::MessageIn &msg);
- void processFormatMessageNumber(Net::MessageIn &msg);
- void processFormatMessageSkill(Net::MessageIn &msg);
- void processChatDisplay(Net::MessageIn &msg);
- void processChatRoomJoinAck(Net::MessageIn &msg);
- void processChatRoomLeave(Net::MessageIn &msg);
- void processJoinChannel(Net::MessageIn &msg);
- void processWhisperContinue(const std::string &nick,
- std::string chatMsg);
- void processBeingChat(Net::MessageIn &msg);
- void processIgnoreNickAck(Net::MessageIn &msg);
- void processChatRoomCreateAck(Net::MessageIn &msg);
- void processChatRoomDestroy(Net::MessageIn &msg);
- void processChatRoomJoinFailed(Net::MessageIn &msg);
- void processChatRoomAddMember(Net::MessageIn &msg);
- void processChatRoomSettings(Net::MessageIn &msg);
- void processChatRoomRoleChange(Net::MessageIn &msg);
- void processMVPItem(Net::MessageIn &msg);
- void processMVPExp(Net::MessageIn &msg);
- void processMVPNoItem(Net::MessageIn &msg);
- void processMannerMessage(Net::MessageIn &msg);
- void processChatSilence(Net::MessageIn &msg);
- void processChatTalkieBox(Net::MessageIn &msg);
- void processBattleChatMessage(Net::MessageIn &msg);
- void processScriptMessage(Net::MessageIn &msg);
- extern std::string mChatRoom;
- } // namespace ChatRecv
-} // namespace EAthena
-
-#endif // NET_EATHENA_CHATRECV_H
diff --git a/src/net/eathena/elementalhandler.cpp b/src/net/eathena/elementalhandler.cpp
deleted file mode 100644
index 8a8fa56bb..000000000
--- a/src/net/eathena/elementalhandler.cpp
+++ /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/>.
- */
-
-#include "net/eathena/elementalhandler.h"
-
-#include "debug.h"
-
-namespace EAthena
-{
-
-ElementalHandler::ElementalHandler() :
- Net::ElementalHandler()
-{
- elementalHandler = this;
-}
-
-ElementalHandler::~ElementalHandler()
-{
- elementalHandler = nullptr;
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/elementalhandler.h b/src/net/eathena/elementalhandler.h
deleted file mode 100644
index 517b74a30..000000000
--- a/src/net/eathena/elementalhandler.h
+++ /dev/null
@@ -1,40 +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 NET_EATHENA_ELEMENTALHANDLER_H
-#define NET_EATHENA_ELEMENTALHANDLER_H
-
-#include "net/elementalhandler.h"
-
-namespace EAthena
-{
-class ElementalHandler final : public Net::ElementalHandler
-{
- public:
- ElementalHandler();
-
- A_DELETE_COPY(ElementalHandler)
-
- ~ElementalHandler();
-};
-
-} // namespace EAthena
-
-#endif // NET_EATHENA_ELEMENTALHANDLER_H
diff --git a/src/net/eathena/elementalrecv.cpp b/src/net/eathena/elementalrecv.cpp
deleted file mode 100644
index d5e0c6d18..000000000
--- a/src/net/eathena/elementalrecv.cpp
+++ /dev/null
@@ -1,73 +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 "net/eathena/elementalrecv.h"
-
-#include "being/playerinfo.h"
-
-#include "net/messagein.h"
-
-#include "net/eathena/sp.h"
-
-#include "utils/checkutils.h"
-
-#include "debug.h"
-
-namespace EAthena
-{
-
-#define setElementalStat(sp, stat) \
- case sp: \
- PlayerInfo::setStatBase(stat, \
- val); \
- break;
-
-void ElementalRecv::processElementalUpdateStatus(Net::MessageIn &msg)
-{
- const int sp = msg.readInt16("type");
- const int val = msg.readInt32("value");
- switch (sp)
- {
- setElementalStat(Sp::HP, Attributes::ELEMENTAL_HP);
- setElementalStat(Sp::MAXHP, Attributes::ELEMENTAL_MAX_HP);
- setElementalStat(Sp::SP, Attributes::ELEMENTAL_MP);
- setElementalStat(Sp::MAXSP, Attributes::ELEMENTAL_MAX_MP);
- default:
- reportAlways("Unknown elemental stat %d",
- sp);
- break;
- }
-}
-
-void ElementalRecv::processElementalInfo(Net::MessageIn &msg)
-{
- const BeingId id = msg.readBeingId("elemental id");
- PlayerInfo::setStatBase(Attributes::ELEMENTAL_HP,
- msg.readInt32("hp"));
- PlayerInfo::setStatBase(Attributes::ELEMENTAL_MAX_HP,
- msg.readInt32("max hp"));
- PlayerInfo::setStatBase(Attributes::ELEMENTAL_MP,
- msg.readInt32("sp"));
- PlayerInfo::setStatBase(Attributes::ELEMENTAL_MAX_MP,
- msg.readInt32("max sp"));
- PlayerInfo::setElemental(id);
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/elementalrecv.h b/src/net/eathena/elementalrecv.h
deleted file mode 100644
index f99c8e1a3..000000000
--- a/src/net/eathena/elementalrecv.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 NET_EATHENA_ELEMENTALRECV_H
-#define NET_EATHENA_ELEMENTALRECV_H
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-namespace EAthena
-{
- namespace ElementalRecv
- {
- void processElementalUpdateStatus(Net::MessageIn &msg);
- void processElementalInfo(Net::MessageIn &msg);
- } // namespace ElementalRecv
-} // namespace EAthena
-
-#endif // NET_EATHENA_ELEMENTALRECV_H
diff --git a/src/net/eathena/familyhandler.cpp b/src/net/eathena/familyhandler.cpp
deleted file mode 100644
index 5ec423ce5..000000000
--- a/src/net/eathena/familyhandler.cpp
+++ /dev/null
@@ -1,67 +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 "net/eathena/familyhandler.h"
-
-#include "being/being.h"
-
-#include "net/eathena/familyrecv.h"
-#include "net/eathena/messageout.h"
-#include "net/eathena/protocolout.h"
-
-#include "debug.h"
-
-namespace EAthena
-{
-
-FamilyHandler::FamilyHandler() :
- Net::FamilyHandler()
-{
- FamilyRecv::mParent1 = BeingId_zero;
- FamilyRecv::mParent2 = BeingId_zero;
-
- familyHandler = this;
-}
-
-FamilyHandler::~FamilyHandler()
-{
- familyHandler = nullptr;
-}
-
-void FamilyHandler::askForChild(const Being *const being) const
-{
- if (being == nullptr)
- return;
-
- createOutPacket(CMSG_FAMILY_ASK_FOR_CHILD);
- outMsg.writeBeingId(being->getId(), "account id");
-}
-
-void FamilyHandler::askForChildReply(const bool accept) const
-{
- createOutPacket(CMSG_FAMILY_ASK_FOR_CHILD_REPLY);
- outMsg.writeBeingId(FamilyRecv::mParent1, "parent1");
- outMsg.writeBeingId(FamilyRecv::mParent2, "parent2");
- outMsg.writeInt32(accept ? 1 : 0, "result");
- FamilyRecv::mParent1 = BeingId_zero;
- FamilyRecv::mParent2 = BeingId_zero;
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/familyhandler.h b/src/net/eathena/familyhandler.h
deleted file mode 100644
index 91531fb2d..000000000
--- a/src/net/eathena/familyhandler.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 NET_EATHENA_FAMILYHANDLER_H
-#define NET_EATHENA_FAMILYHANDLER_H
-
-#include "net/familyhandler.h"
-
-namespace EAthena
-{
-class FamilyHandler final : public Net::FamilyHandler
-{
- public:
- FamilyHandler();
-
- A_DELETE_COPY(FamilyHandler)
-
- ~FamilyHandler();
-
- void askForChild(const Being *const being) const override final;
-
- void askForChildReply(const bool accept) const override final;
-};
-
-} // namespace EAthena
-
-#endif // NET_EATHENA_FAMILYHANDLER_H
diff --git a/src/net/eathena/familyrecv.cpp b/src/net/eathena/familyrecv.cpp
deleted file mode 100644
index f9f7b2fd8..000000000
--- a/src/net/eathena/familyrecv.cpp
+++ /dev/null
@@ -1,123 +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 "net/eathena/familyrecv.h"
-
-#include "notifymanager.h"
-#include "party.h"
-
-#include "being/localplayer.h"
-
-#include "enums/resources/notifytypes.h"
-
-#include "gui/widgets/createwidget.h"
-
-#include "utils/gettext.h"
-#include "utils/stringutils.h"
-
-#include "listeners/requestadoptchildlistener.h"
-
-#include "net/messagein.h"
-
-#include "debug.h"
-
-namespace EAthena
-{
-
-namespace FamilyRecv
-{
- ConfirmDialog *confirmDlg = nullptr;
- RequestAdoptChildListener listener;
- BeingId mParent1 = BeingId_zero;
- BeingId mParent2 = BeingId_zero;
-} // namespace FamilyRecv
-
-void FamilyRecv::processAskForChild(Net::MessageIn &msg)
-{
- if (localPlayer == nullptr)
- {
- mParent1 = msg.readBeingId("account id who ask");
- mParent2 = msg.readBeingId("acoount id for other parent");
- msg.readString(24, "name who ask");
- return;
- }
- mParent1 = msg.readBeingId("account id who ask");
- mParent2 = msg.readBeingId("acoount id for other parent");
- const std::string name1 = msg.readString(24, "name who ask");
- const Party *const party = localPlayer->getParty();
- if (party != nullptr)
- {
- const PartyMember *const member = party->getMember(mParent2);
- if (member != nullptr)
- {
- const std::string name2 = member->getName();
- CREATEWIDGETV(confirmDlg, ConfirmDialog,
- // TRANSLATORS: adopt child message
- _("Request parents"),
- // TRANSLATORS: adopt child message
- strprintf(_("Do you accept %s and %s as parents?"),
- name1.c_str(), name2.c_str()),
- SOUND_REQUEST,
- false);
- confirmDlg->addActionListener(&listener);
- }
- }
-}
-
-void FamilyRecv::processCallPartner(Net::MessageIn &msg)
-{
- const std::string name = msg.readString(24, "name");
- if ((localPlayer != nullptr) && name == localPlayer->getName())
- {
- NotifyManager::notify(NotifyTypes::CALLED_PARTNER);
- }
- else
- {
- NotifyManager::notify(NotifyTypes::CALLING_PARTNER, name.c_str());
- }
-}
-
-void FamilyRecv::processDivorced(Net::MessageIn &msg)
-{
- const std::string name = msg.readString(24, "name");
- NotifyManager::notify(NotifyTypes::DIVORCED, name.c_str());
-}
-
-void FamilyRecv::processAskForChildReply(Net::MessageIn &msg)
-{
- const int type = msg.readInt32("type");
- switch (type)
- {
- case 0:
- NotifyManager::notify(NotifyTypes::ADOPT_CHILD_ERROR_HAVE_BABY);
- break;
- case 1:
- NotifyManager::notify(NotifyTypes::ADOPT_CHILD_ERROR_LEVEL);
- break;
- case 2:
- NotifyManager::notify(NotifyTypes::ADOPT_CHILD_ERROR_BABY_MARRIED);
- break;
- default:
- UNIMPLEMENTEDPACKETFIELD(type);
- break;
- }
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/familyrecv.h b/src/net/eathena/familyrecv.h
deleted file mode 100644
index f069851aa..000000000
--- a/src/net/eathena/familyrecv.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 NET_EATHENA_FAMILYRECV_H
-#define NET_EATHENA_FAMILYRECV_H
-
-#include "enums/simpletypes/beingid.h"
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-namespace EAthena
-{
- namespace FamilyRecv
- {
- extern BeingId mParent1;
- extern BeingId mParent2;
-
- void processAskForChild(Net::MessageIn &msg);
- void processCallPartner(Net::MessageIn &msg);
- void processDivorced(Net::MessageIn &msg);
- void processAskForChildReply(Net::MessageIn &msg);
- } // namespace FamilyRecv
-} // namespace EAthena
-
-#endif // NET_EATHENA_FAMILYRECV_H
diff --git a/src/net/eathena/friendshandler.cpp b/src/net/eathena/friendshandler.cpp
deleted file mode 100644
index 000ea909d..000000000
--- a/src/net/eathena/friendshandler.cpp
+++ /dev/null
@@ -1,64 +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 "net/eathena/friendshandler.h"
-
-#include "net/eathena/messageout.h"
-#include "net/eathena/protocolout.h"
-
-#include "debug.h"
-
-namespace EAthena
-{
-
-FriendsHandler::FriendsHandler()
-{
- friendsHandler = this;
-}
-
-FriendsHandler::~FriendsHandler()
-{
- friendsHandler = nullptr;
-}
-
-void FriendsHandler::invite(const std::string &name) const
-{
- createOutPacket(CMSG_FRIENDS_ADD_PLAYER);
- outMsg.writeString(name, 24, "name");
-}
-
-void FriendsHandler::inviteResponse(const int accountId,
- const int charId,
- const bool accept) const
-{
- createOutPacket(CMSG_FRIENDS_REQUEST_ACK);
- outMsg.writeInt32(accountId, "account id");
- outMsg.writeInt32(charId, "char id");
- outMsg.writeInt32(accept ? 1 : 0, "result");
-}
-
-void FriendsHandler::remove(const int accountId, const int charId) const
-{
- createOutPacket(CMSG_FRIENDS_DELETE_PLAYER);
- outMsg.writeInt32(accountId, "account id");
- outMsg.writeInt32(charId, "char id");
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/friendshandler.h b/src/net/eathena/friendshandler.h
deleted file mode 100644
index 7b985e0ca..000000000
--- a/src/net/eathena/friendshandler.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 NET_EATHENA_FRIENDSHANDLER_H
-#define NET_EATHENA_FRIENDSHANDLER_H
-
-#include "net/friendshandler.h"
-
-namespace EAthena
-{
-class FriendsHandler final : public Net::FriendsHandler
-{
- public:
- FriendsHandler();
-
- A_DELETE_COPY(FriendsHandler)
-
- ~FriendsHandler();
-
- void invite(const std::string &name) const override final;
-
- void inviteResponse(const int accountId,
- const int charId,
- const bool accept) const override final;
-
- void remove(const int accountId,
- const int charId) const override final;
-};
-
-} // namespace EAthena
-
-#endif // NET_EATHENA_FRIENDSHANDLER_H
diff --git a/src/net/eathena/friendsrecv.cpp b/src/net/eathena/friendsrecv.cpp
deleted file mode 100644
index cf0f6f66a..000000000
--- a/src/net/eathena/friendsrecv.cpp
+++ /dev/null
@@ -1,76 +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 "net/eathena/friendsrecv.h"
-
-#include "logger.h"
-
-#include "net/messagein.h"
-
-#include "debug.h"
-
-namespace EAthena
-{
-
-void FriendsRecv::processPlayerOnline(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readBeingId("account id");
- msg.readInt32("char id");
- msg.readUInt8("flag"); // 0 - online, 1 - offline
-}
-
-void FriendsRecv::processFriendsList(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- const int count = (msg.readInt16("size") - 4) / 32;
- for (int f = 0; f < count; f ++)
- {
- msg.readBeingId("account id");
- msg.readInt32("char id");
- msg.readString(24, "name");
- }
-}
-
-void FriendsRecv::processRequestAck(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readInt16("type");
- msg.readBeingId("account id");
- msg.readInt32("char id");
- msg.readString(24, "name");
-}
-
-void FriendsRecv::processRequest(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readBeingId("account id");
- msg.readInt32("char id");
- msg.readString(24, "name");
-}
-
-void FriendsRecv::processDeletePlayer(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readBeingId("account id");
- msg.readInt32("char id");
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/friendsrecv.h b/src/net/eathena/friendsrecv.h
deleted file mode 100644
index c6dbb5841..000000000
--- a/src/net/eathena/friendsrecv.h
+++ /dev/null
@@ -1,41 +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 NET_EATHENA_FRIENDSRECV_H
-#define NET_EATHENA_FRIENDSRECV_H
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-namespace EAthena
-{
- namespace FriendsRecv
- {
- void processPlayerOnline(Net::MessageIn &msg);
- void processFriendsList(Net::MessageIn &msg);
- void processRequestAck(Net::MessageIn &msg);
- void processRequest(Net::MessageIn &msg);
- void processDeletePlayer(Net::MessageIn &msg);
- } // namespace FriendsRecv
-} // namespace EAthena
-
-#endif // NET_EATHENA_FRIENDSRECV_H
diff --git a/src/net/eathena/gamehandler.cpp b/src/net/eathena/gamehandler.cpp
deleted file mode 100644
index 274c04c0d..000000000
--- a/src/net/eathena/gamehandler.cpp
+++ /dev/null
@@ -1,226 +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 "net/eathena/gamehandler.h"
-
-#include "client.h"
-
-#include "being/localplayer.h"
-
-#include "net/serverfeatures.h"
-
-#include "net/ea/token.h"
-
-#include "net/ea/gamerecv.h"
-
-#include "net/eathena/loginhandler.h"
-#include "net/eathena/messageout.h"
-#include "net/eathena/network.h"
-#include "net/eathena/protocolout.h"
-
-#include "debug.h"
-
-extern int packetVersion;
-
-namespace EAthena
-{
-
-extern ServerInfo mapServer;
-
-GameHandler::GameHandler() :
- Ea::GameHandler()
-{
- gameHandler = this;
-}
-
-GameHandler::~GameHandler()
-{
- gameHandler = nullptr;
-}
-
-void GameHandler::mapLoadedEvent() const
-{
- createOutPacket(CMSG_MAP_LOADED);
-}
-
-void GameHandler::connect() const
-{
- if (Network::mInstance == nullptr)
- return;
-
- Network::mInstance->connect(mapServer);
-
- const Token &token = static_cast<LoginHandler*>(loginHandler)->getToken();
-
-
- if (client->getState() == State::CONNECT_GAME)
- {
- // Change the player's ID to the account ID to match what eAthena uses
- if (localPlayer != nullptr)
- {
- Ea::GameRecv::mCharID = localPlayer->getId();
- localPlayer->setId(token.account_ID);
- }
- else
- {
- Ea::GameRecv::mCharID = BeingId_zero;
- }
- }
-
- // Send login infos
- createOutPacket(CMSG_MAP_SERVER_CONNECT);
- outMsg.writeBeingId(token.account_ID, "account id");
- outMsg.writeBeingId(Ea::GameRecv::mCharID, "char id");
- outMsg.writeInt32(token.session_ID1, "session key1");
- outMsg.writeInt32(0, "tick");
- outMsg.writeInt8(Being::genderToInt(token.sex), "sex");
- if (serverFeatures->haveMapServerVersion())
- loginHandler->sendVersion();
-
- // We get 4 useless bytes before the real answer comes in (what are these?)
-// Network::mInstance->skip(4);
-}
-
-bool GameHandler::isConnected() const
-{
- if (Network::mInstance == nullptr)
- return false;
- return Network::mInstance->isConnected();
-}
-
-void GameHandler::disconnect() const
-{
- if (Network::mInstance != nullptr)
- Network::mInstance->disconnect();
-}
-
-void GameHandler::quit() const
-{
- createOutPacket(CMSG_CLIENT_QUIT);
-}
-
-void GameHandler::ping(const int tick) const
-{
- createOutPacket(CMSG_MAP_PING);
- if (packetVersion >= 20101124)
- {
- // nothing here
- }
- else if (packetVersion >= 20080827)
- {
- outMsg.writeInt16(0, "unknown");
- outMsg.writeInt8(0, "unknown");
- outMsg.writeInt8(0, "unknown");
- outMsg.writeInt8(0, "unknown");
- }
- else if (packetVersion >= 20070212)
- {
- outMsg.writeInt16(0, "unknown");
- }
- else if (packetVersion >= 20070108)
- {
- outMsg.writeInt16(0, "unknown");
- outMsg.writeInt16(0, "unknown");
- outMsg.writeInt8(0, "unknown");
- }
- else if (packetVersion >= 20050719)
- {
- outMsg.writeInt16(0, "unknown");
- outMsg.writeInt16(0, "unknown");
- outMsg.writeInt16(0, "unknown");
- outMsg.writeInt8(0, "unknown");
- }
- else if (packetVersion >= 20050718)
- {
- outMsg.writeInt8(0, "unknown");
- }
- else if (packetVersion >= 20050628)
- {
- outMsg.writeInt16(0, "unknown");
- outMsg.writeInt16(0, "unknown");
- outMsg.writeInt16(0, "unknown");
- outMsg.writeInt8(0, "unknown");
- }
- else if (packetVersion >= 20050509)
- {
- outMsg.writeInt16(0, "unknown");
- }
- else if (packetVersion >= 20050110)
- {
- outMsg.writeInt16(0, "unknown");
- outMsg.writeInt8(0, "unknown");
- }
- else if (packetVersion >= 20041129)
- {
- outMsg.writeInt8(0, "unknown");
- }
- else if (packetVersion >= 20041025)
- {
- outMsg.writeInt8(0, "unknown");
- outMsg.writeInt8(0, "unknown");
- outMsg.writeInt8(0, "unknown");
- }
- else if (packetVersion >= 20041005)
- {
- outMsg.writeInt8(0, "unknown");
- outMsg.writeInt8(0, "unknown");
- outMsg.writeInt8(0, "unknown");
- outMsg.writeInt8(0, "unknown");
- }
- else if (packetVersion >= 20040920)
- {
- outMsg.writeInt16(0, "unknown");
- outMsg.writeInt16(0, "unknown");
- outMsg.writeInt8(0, "unknown");
- outMsg.writeInt8(0, "unknown");
- outMsg.writeInt8(0, "unknown");
- outMsg.writeInt8(0, "unknown");
- }
- else if (packetVersion >= 20040906)
- {
- outMsg.writeInt16(0, "unknown");
- outMsg.writeInt8(0, "unknown");
- outMsg.writeInt8(0, "unknown");
- outMsg.writeInt8(0, "unknown");
- }
- else if (packetVersion >= 20040809)
- {
- outMsg.writeInt16(0, "unknown");
- outMsg.writeInt16(0, "unknown");
- outMsg.writeInt8(0, "unknown");
- outMsg.writeInt8(0, "unknown");
- outMsg.writeInt8(0, "unknown");
- }
- else if (packetVersion >= 20040726)
- {
- outMsg.writeInt16(0, "unknown");
- outMsg.writeInt16(0, "unknown");
- }
- outMsg.writeInt32(tick, "tick");
-}
-
-void GameHandler::disconnect2() const
-{
- createOutPacket(CMSG_CLIENT_QUIT);
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/gamehandler.h b/src/net/eathena/gamehandler.h
deleted file mode 100644
index 4b2725a2f..000000000
--- a/src/net/eathena/gamehandler.h
+++ /dev/null
@@ -1,60 +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 NET_EATHENA_GAMEHANDLER_H
-#define NET_EATHENA_GAMEHANDLER_H
-
-#include "net/ea/gamehandler.h"
-
-namespace EAthena
-{
-
-class GameHandler final : public Ea::GameHandler
-{
- public:
- GameHandler();
-
- A_DELETE_COPY(GameHandler)
-
- ~GameHandler();
-
- void connect() const override final;
-
- bool isConnected() const override final A_WARN_UNUSED;
-
- void disconnect() const override final;
-
- void quit() const override final;
-
- void ping(const int tick) const override final;
-
- void disconnect2() const override final A_CONST;
-
- void mapLoadedEvent() const override final;
-
- bool mustPing() const override final A_WARN_UNUSED
- { return true; }
-};
-
-} // namespace EAthena
-
-#endif // NET_EATHENA_GAMEHANDLER_H
diff --git a/src/net/eathena/gamerecv.cpp b/src/net/eathena/gamerecv.cpp
deleted file mode 100644
index 00d2c4f9d..000000000
--- a/src/net/eathena/gamerecv.cpp
+++ /dev/null
@@ -1,86 +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 "net/eathena/gamerecv.h"
-
-#include "client.h"
-#include "logger.h"
-
-#include "being/localplayer.h"
-
-#include "net/messagein.h"
-
-#include "net/eathena/network.h"
-
-#include "debug.h"
-
-namespace EAthena
-{
-
-extern ServerInfo mapServer;
-
-void GameRecv::processMapAccountId(Net::MessageIn &msg)
-{
- // ignored, because we already know local player account id.
- msg.readBeingId("account id");
-}
-
-void GameRecv::processMapLogin(Net::MessageIn &msg)
-{
- unsigned char direction;
- uint16_t x, y;
- msg.readInt32("start time");
- msg.readCoordinates(x, y, direction, "position");
- msg.readInt8("x size");
- msg.readInt8("y size");
- logger->log("Protocol: Player start position: "
- "(%d, %d), Direction: %d",
- x, y, direction);
- if (msg.getVersion() >= 20080102)
- msg.readInt16("font");
- if (msg.getVersion() >= 20141022 && msg.getVersion() < 20160330)
- msg.readUInt8("sex");
-
- mLastHost &= 0xffffff;
-
- Network *const network = Network::mInstance;
- if (network != nullptr)
- network->pauseDispatch();
-
- // Switch now or we'll have problems
- client->setState(State::GAME);
- if (localPlayer != nullptr)
- localPlayer->setTileCoords(x, y);
-}
-
-void GameRecv::processServerTick(Net::MessageIn &msg)
-{
- // ignoring
- msg.readInt32("tick");
-}
-
-void GameRecv::processMapAuthRefuse(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readUInt8("error");
-}
-} // namespace EAthena
diff --git a/src/net/eathena/gamerecv.h b/src/net/eathena/gamerecv.h
deleted file mode 100644
index 3d2dbe590..000000000
--- a/src/net/eathena/gamerecv.h
+++ /dev/null
@@ -1,42 +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 NET_EATHENA_GAMERECV_H
-#define NET_EATHENA_GAMERECV_H
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-namespace EAthena
-{
- namespace GameRecv
- {
- void processMapAccountId(Net::MessageIn &msg);
- void processMapLogin(Net::MessageIn &msg);
- void processServerTick(Net::MessageIn &msg);
- void processMapAuthRefuse(Net::MessageIn &msg);
- } // namespace GameRecv
-} // namespace EAthena
-
-#endif // NET_EATHENA_GAMERECV_H
diff --git a/src/net/eathena/generalhandler.cpp b/src/net/eathena/generalhandler.cpp
deleted file mode 100644
index c2aac194b..000000000
--- a/src/net/eathena/generalhandler.cpp
+++ /dev/null
@@ -1,245 +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 "net/eathena/generalhandler.h"
-
-#include "client.h"
-#include "configuration.h"
-
-#include "gui/windows/skilldialog.h"
-#include "gui/windows/socialwindow.h"
-
-#include "gui/widgets/tabs/chat/guildtab.h"
-#include "gui/widgets/tabs/chat/partytab.h"
-
-#include "net/eathena/adminhandler.h"
-#include "net/eathena/auctionhandler.h"
-#include "net/eathena/bankhandler.h"
-#include "net/eathena/battlegroundhandler.h"
-#include "net/eathena/beinghandler.h"
-#include "net/eathena/buyingstorehandler.h"
-#include "net/eathena/buysellhandler.h"
-#include "net/eathena/cashshophandler.h"
-#include "net/eathena/chathandler.h"
-#include "net/eathena/charserverhandler.h"
-#include "net/eathena/elementalhandler.h"
-#include "net/eathena/familyhandler.h"
-#include "net/eathena/friendshandler.h"
-#include "net/eathena/gamehandler.h"
-#include "net/eathena/guildhandler.h"
-#include "net/eathena/homunculushandler.h"
-#include "net/eathena/inventoryhandler.h"
-#include "net/eathena/itemhandler.h"
-#include "net/eathena/loginhandler.h"
-#include "net/eathena/maphandler.h"
-#include "net/eathena/mail2handler.h"
-#include "net/eathena/mailhandler.h"
-#include "net/eathena/markethandler.h"
-#include "net/eathena/mercenaryhandler.h"
-#include "net/eathena/network.h"
-#include "net/eathena/npchandler.h"
-#include "net/eathena/partyhandler.h"
-#include "net/eathena/pethandler.h"
-#include "net/eathena/playerhandler.h"
-#include "net/eathena/roulettehandler.h"
-#include "net/eathena/searchstorehandler.h"
-#include "net/eathena/serverfeatures.h"
-#include "net/eathena/tradehandler.h"
-#include "net/eathena/skillhandler.h"
-#include "net/eathena/questhandler.h"
-#include "net/eathena/vendinghandler.h"
-
-#include "utils/delete2.h"
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-namespace EAthena
-{
-
-GeneralHandler::GeneralHandler() :
- mAdminHandler(new AdminHandler),
- mBeingHandler(new BeingHandler(config.getBoolValue("EnableSync"))),
- mBuySellHandler(new BuySellHandler),
- mCharServerHandler(new CharServerHandler),
- mChatHandler(new ChatHandler),
- mGameHandler(new GameHandler),
- mGuildHandler(new GuildHandler),
- mInventoryHandler(new InventoryHandler),
- mItemHandler(new ItemHandler),
- mLoginHandler(new LoginHandler),
- mNpcHandler(new NpcHandler),
- mPartyHandler(new PartyHandler),
- mPetHandler(new PetHandler),
- mPlayerHandler(new PlayerHandler),
- mSkillHandler(new SkillHandler),
- mTradeHandler(new TradeHandler),
- mQuestHandler(new QuestHandler),
- mServerFeatures(new ServerFeatures),
- mMail2Handler(new Mail2Handler),
- mMailHandler(new MailHandler),
- mAuctionHandler(new AuctionHandler),
- mCashShopHandler(new CashShopHandler),
- mFamilyHandler(new FamilyHandler),
- mBankHandler(new BankHandler),
- mBattleGroundHandler(new BattleGroundHandler),
- mMercenaryHandler(new MercenaryHandler),
- mBuyingStoreHandler(new BuyingStoreHandler),
- mHomunculusHandler(new HomunculusHandler),
- mFriendsHandler(new FriendsHandler),
- mElementalHandler(new ElementalHandler),
- mMapHandler(new MapHandler),
- mMarketHandler(new MarketHandler),
- mVendingHandler(new VendingHandler),
- mRouletteHandler(new RouletteHandler),
- mSearchStoreHandler(new SearchStoreHandler)
-{
- generalHandler = this;
-}
-
-GeneralHandler::~GeneralHandler()
-{
- delete2(Network::mInstance);
-
- delete2(mAdminHandler);
- delete2(mBeingHandler);
- delete2(mBuySellHandler);
- delete2(mCharServerHandler);
- delete2(mChatHandler);
- delete2(mGameHandler);
- delete2(mGuildHandler);
- delete2(mInventoryHandler);
- delete2(mItemHandler);
- delete2(mLoginHandler);
- delete2(mNpcHandler);
- delete2(mPartyHandler);
- delete2(mPetHandler);
- delete2(mPlayerHandler);
- delete2(mSkillHandler);
- delete2(mTradeHandler);
- delete2(mQuestHandler);
- delete2(mServerFeatures);
- delete2(mMail2Handler);
- delete2(mMailHandler);
- delete2(mAuctionHandler);
- delete2(mCashShopHandler);
- delete2(mFamilyHandler);
- delete2(mBankHandler);
- delete2(mBattleGroundHandler);
- delete2(mMercenaryHandler);
- delete2(mBuyingStoreHandler);
- delete2(mHomunculusHandler);
- delete2(mFriendsHandler);
- delete2(mElementalHandler);
- delete2(mMapHandler);
- delete2(mMarketHandler);
- delete2(mVendingHandler);
- delete2(mRouletteHandler);
- delete2(mSearchStoreHandler);
-}
-
-void GeneralHandler::load() const
-{
- new Network;
- Network::mInstance->registerHandlers();
-}
-
-void GeneralHandler::reload() const
-{
- if (Network::mInstance != nullptr)
- Network::mInstance->disconnect();
-
- static_cast<LoginHandler*>(mLoginHandler)->clearWorlds();
- const CharServerHandler *const charHandler =
- static_cast<CharServerHandler*>(mCharServerHandler);
- charHandler->setCharCreateDialog(nullptr);
- charHandler->setCharSelectDialog(nullptr);
- PartyHandler::reload();
-}
-
-void GeneralHandler::reloadPartially() const
-{
- PartyHandler::reload();
-}
-
-void GeneralHandler::unload() const
-{
- clearHandlers();
-}
-
-void GeneralHandler::flushSend() const
-{
- if (Network::mInstance == nullptr)
- return;
-
- Network::mInstance->flush();
-}
-
-void GeneralHandler::flushNetwork() const
-{
- if (Network::mInstance == nullptr)
- return;
-
- Network::mInstance->flush();
- Network::mInstance->dispatchMessages();
-
- if (Network::mInstance->getState() == Network::NET_ERROR)
- {
- if (!Network::mInstance->getError().empty())
- {
- errorMessage = Network::mInstance->getError();
- }
- else
- {
- // TRANSLATORS: error message
- errorMessage = _("Got disconnected from server!");
- }
-
- client->setState(State::ERROR);
- }
-}
-
-void GeneralHandler::clearHandlers() const
-{
- if (Network::mInstance != nullptr)
- Network::mInstance->clearHandlers();
-}
-
-void GeneralHandler::gameStarted() const
-{
- if (skillDialog != nullptr)
- skillDialog->loadSkills();
-}
-
-void GeneralHandler::gameEnded() const
-{
- if (socialWindow != nullptr)
- {
- socialWindow->removeTab(taGuild);
- socialWindow->removeTab(Ea::taParty);
- }
-
- delete2(guildTab);
- delete2(partyTab);
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/generalhandler.h b/src/net/eathena/generalhandler.h
deleted file mode 100644
index c4ff43402..000000000
--- a/src/net/eathena/generalhandler.h
+++ /dev/null
@@ -1,134 +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 NET_EATHENA_GENERALHANDLER_H
-#define NET_EATHENA_GENERALHANDLER_H
-
-#include "net/generalhandler.h"
-
-namespace EAthena
-{
-
-class AdminHandler;
-class BeingHandler;
-class BuySellHandler;
-class CharServerHandler;
-class ChatHandler;
-class GameHandler;
-class GuildHandler;
-class InventoryHandler;
-class ItemHandler;
-class LoginHandler;
-class NpcHandler;
-class PartyHandler;
-class PetHandler;
-class PlayerHandler;
-class SkillHandler;
-class TradeHandler;
-class QuestHandler;
-class ServerFeatures;
-class AuctionHandler;
-class BankHandler;
-class BattleGroundHandler;
-class BuyingStoreHandler;
-class CashShopHandler;
-class ElementalHandler;
-class FamilyHandler;
-class FriendsHandler;
-class HomunculusHandler;
-class MailHandler;
-class Mail2Handler;
-class MapHandler;
-class MarketHandler;
-class MercenaryHandler;
-class RouletteHandler;
-class SearchStoreHandler;
-class VendingHandler;
-
-class GeneralHandler final : public Net::GeneralHandler
-{
- public:
- GeneralHandler();
-
- A_DELETE_COPY(GeneralHandler)
-
- ~GeneralHandler();
-
- void load() const override final;
-
- void reload() const override final;
-
- void unload() const override final;
-
- void flushNetwork() const override final;
-
- void flushSend() const override final;
-
- void clearHandlers() const override final;
-
- void reloadPartially() const override final;
-
- void gameStarted() const override final;
-
- void gameEnded() const override final;
-
- protected:
- AdminHandler *mAdminHandler;
- BeingHandler *mBeingHandler;
- BuySellHandler *mBuySellHandler;
- CharServerHandler *mCharServerHandler;
- ChatHandler *mChatHandler;
- GameHandler *mGameHandler;
- GuildHandler *mGuildHandler;
- InventoryHandler *mInventoryHandler;
- ItemHandler *mItemHandler;
- LoginHandler *mLoginHandler;
- NpcHandler *mNpcHandler;
- PartyHandler *mPartyHandler;
- PetHandler *mPetHandler;
- PlayerHandler *mPlayerHandler;
- SkillHandler *mSkillHandler;
- TradeHandler *mTradeHandler;
- QuestHandler *mQuestHandler;
- ServerFeatures *mServerFeatures;
- Mail2Handler *mMail2Handler;
- MailHandler *mMailHandler;
- AuctionHandler *mAuctionHandler;
- CashShopHandler *mCashShopHandler;
- FamilyHandler *mFamilyHandler;
- BankHandler *mBankHandler;
- BattleGroundHandler *mBattleGroundHandler;
- MercenaryHandler *mMercenaryHandler;
- BuyingStoreHandler *mBuyingStoreHandler;
- HomunculusHandler *mHomunculusHandler;
- FriendsHandler *mFriendsHandler;
- ElementalHandler *mElementalHandler;
- MapHandler *mMapHandler;
- MarketHandler *mMarketHandler;
- VendingHandler *mVendingHandler;
- RouletteHandler *mRouletteHandler;
- SearchStoreHandler *mSearchStoreHandler;
-};
-
-} // namespace EAthena
-
-#endif // NET_EATHENA_GENERALHANDLER_H
diff --git a/src/net/eathena/generalrecv.cpp b/src/net/eathena/generalrecv.cpp
deleted file mode 100644
index 2074fe31e..000000000
--- a/src/net/eathena/generalrecv.cpp
+++ /dev/null
@@ -1,180 +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 "net/eathena/generalrecv.h"
-
-#include "client.h"
-#include "logger.h"
-
-#include "net/messagein.h"
-
-#include "utils/cast.h"
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-namespace EAthena
-{
-
-ServerInfo charServer;
-ServerInfo mapServer;
-
-void GeneralRecv::processConnectionProblem(Net::MessageIn &msg)
-{
- const uint8_t code = msg.readUInt8("flag");
- logger->log("Connection problem: %u", CAST_U32(code));
-
- switch (code)
- {
- case 0:
- // TRANSLATORS: error message
- errorMessage = _("Authentication failed.");
- break;
- case 1:
- // TRANSLATORS: error message
- errorMessage = _("No servers available.");
- break;
- case 2:
- if (client->getState() == State::GAME)
- {
- // TRANSLATORS: error message
- errorMessage = _("Someone else is trying to use "
- "this account.");
- }
- else
- {
- // TRANSLATORS: error message
- errorMessage = _("This account is already logged in.");
- }
- break;
- case 3:
- // TRANSLATORS: error message
- errorMessage = _("Speed hack detected.");
- break;
- case 4:
- // TRANSLATORS: error message
- errorMessage = _("Server full.");
- break;
- case 5:
- // TRANSLATORS: error message
- errorMessage = _("Sorry, you are underaged.");
- break;
- case 8:
- // TRANSLATORS: error message
- errorMessage = _("Duplicated login.");
- break;
- case 9:
- // TRANSLATORS: error message
- errorMessage = _("To many connections from same ip.");
- break;
- case 10:
- // TRANSLATORS: error message
- errorMessage = _("Not paid for this time.");
- break;
- case 11:
- // TRANSLATORS: error message
- errorMessage = _("Pay suspended.");
- break;
- case 12:
- // TRANSLATORS: error message
- errorMessage = _("Pay changed.");
- break;
- case 13:
- // TRANSLATORS: error message
- errorMessage = _("Pay wrong ip.");
- break;
- case 14:
- // TRANSLATORS: error message
- errorMessage = _("Pay game room.");
- break;
- case 15:
- // TRANSLATORS: error message
- errorMessage = _("Disconnect forced by GM.");
- break;
- case 16:
- case 17:
- // TRANSLATORS: error message
- errorMessage = _("Ban japan refuse.");
- break;
- case 18:
- // TRANSLATORS: error message
- errorMessage = _("Remained other account.");
- break;
- case 100:
- // TRANSLATORS: error message
- errorMessage = _("Ip unfair.");
- break;
- case 101:
- // TRANSLATORS: error message
- errorMessage = _("Ip count all.");
- break;
- case 102:
- // TRANSLATORS: error message
- errorMessage = _("Ip count.");
- break;
- case 103:
- case 104:
- // TRANSLATORS: error message
- errorMessage = _("Memory.");
- break;
- case 105:
- // TRANSLATORS: error message
- errorMessage = _("Han valid.");
- break;
- case 106:
- // TRANSLATORS: error message
- errorMessage = _("Ip limited access.");
- break;
- case 107:
- // TRANSLATORS: error message
- errorMessage = _("Over characters list.");
- break;
- case 108:
- // TRANSLATORS: error message
- errorMessage = _("Ip blocked.");
- break;
- case 109:
- // TRANSLATORS: error message
- errorMessage = _("Invalid password count.");
- break;
- case 110:
- // TRANSLATORS: error message
- errorMessage = _("Not allowed race.");
- break;
- default:
- // TRANSLATORS: error message
- errorMessage = _("Unknown connection error.");
- break;
- }
- client->setState(State::ERROR);
-}
-
-void GeneralRecv::processMapNotFound(Net::MessageIn &msg)
-{
- const int sz = msg.readInt16("len") - 4;
- msg.readString(sz, "map name?");
- // TRANSLATORS: error message
- errorMessage = _("Map not found");
- client->setState(State::ERROR);
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/generalrecv.h b/src/net/eathena/generalrecv.h
deleted file mode 100644
index fa5088c3d..000000000
--- a/src/net/eathena/generalrecv.h
+++ /dev/null
@@ -1,40 +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 NET_EATHENA_GENERALRECV_H
-#define NET_EATHENA_GENERALRECV_H
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-namespace EAthena
-{
- namespace GeneralRecv
- {
- void processConnectionProblem(Net::MessageIn &msg);
- void processMapNotFound(Net::MessageIn &msg);
- } // namespace GeneralRecv
-} // namespace EAthena
-
-#endif // NET_EATHENA_GENERALRECV_H
diff --git a/src/net/eathena/guildhandler.cpp b/src/net/eathena/guildhandler.cpp
deleted file mode 100644
index b55918f85..000000000
--- a/src/net/eathena/guildhandler.cpp
+++ /dev/null
@@ -1,291 +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 "net/eathena/guildhandler.h"
-
-#include "actormanager.h"
-
-#include "being/localplayer.h"
-#include "being/playerinfo.h"
-
-#include "gui/widgets/tabs/chat/guildtab.h"
-
-#include "net/eathena/guildrecv.h"
-#include "net/eathena/messageout.h"
-#include "net/eathena/protocolout.h"
-
-#include "utils/delete2.h"
-
-#include "debug.h"
-
-GuildTab *guildTab = nullptr;
-
-extern int packetVersion;
-
-namespace EAthena
-{
-
-GuildHandler::GuildHandler() :
- Net::GuildHandler()
-{
- guildHandler = this;
- GuildRecv::showBasicInfo = false;
-}
-
-GuildHandler::~GuildHandler()
-{
- delete2(guildTab);
- guildHandler = nullptr;
- taGuild = nullptr;
-}
-
-void GuildHandler::clear() const
-{
- taGuild = nullptr;
-}
-
-ChatTab *GuildHandler::getTab() const
-{
- return guildTab;
-}
-
-void GuildHandler::create(const std::string &name) const
-{
- createOutPacket(CMSG_GUILD_CREATE);
- outMsg.writeInt32(0, "unused");
- outMsg.writeString(name, 24, "guild name");
-}
-
-void GuildHandler::invite(const std::string &name) const
-{
- if (actorManager == nullptr)
- return;
-
- const Being *const being = actorManager->findBeingByName(
- name, ActorType::Player);
- if (being != nullptr)
- {
- createOutPacket(CMSG_GUILD_INVITE);
- outMsg.writeBeingId(being->getId(), "account id");
- outMsg.writeInt32(0, "unused");
- outMsg.writeInt32(0, "unused");
- }
- else if (packetVersion >= 20120418)
- {
- createOutPacket(CMSG_GUILD_INVITE2);
- outMsg.writeString(name, 24, "name");
- }
-}
-
-void GuildHandler::invite(const Being *const being) const
-{
- if (being == nullptr)
- return;
-
- createOutPacket(CMSG_GUILD_INVITE);
- outMsg.writeBeingId(being->getId(), "account id");
- outMsg.writeInt32(0, "unused");
- outMsg.writeInt32(0, "unused");
-}
-
-void GuildHandler::inviteResponse(const int guildId,
- const bool response) const
-{
- createOutPacket(CMSG_GUILD_INVITE_REPLY);
- outMsg.writeInt32(guildId, "guild id");
- outMsg.writeInt8(static_cast<int8_t>(response), "response");
- outMsg.writeInt8(0, "unused");
- outMsg.writeInt16(0, "unused");
-}
-
-void GuildHandler::leave(const int guildId) const
-{
- if (localPlayer == nullptr)
- return;
-
- createOutPacket(CMSG_GUILD_LEAVE);
- outMsg.writeInt32(guildId, "guild id");
- outMsg.writeBeingId(localPlayer->getId(), "account id");
- outMsg.writeInt32(PlayerInfo::getCharId(), "char id");
- outMsg.writeString("", 40, "message");
-}
-
-void GuildHandler::kick(const GuildMember *restrict const member,
- const std::string &restrict reason) const
-{
- if ((member == nullptr) || (member->getGuild() == nullptr))
- return;
-
- createOutPacket(CMSG_GUILD_EXPULSION);
- outMsg.writeInt32(member->getGuild()->getId(), "guild id");
- outMsg.writeBeingId(member->getID(), "account id");
- outMsg.writeInt32(member->getCharId(), "char id");
- outMsg.writeString(reason, 40, "message");
-}
-
-void GuildHandler::chat(const std::string &text) const
-{
- if (localPlayer == nullptr)
- return;
-
- const std::string str = std::string(localPlayer->getName()).append(
- " : ").append(text);
- createOutPacket(CMSG_GUILD_MESSAGE);
- if (packetVersion >= 20151001)
- {
- outMsg.writeInt16(CAST_U16(str.size() + 4), "len");
- outMsg.writeString(str, CAST_S32(str.length()), "message");
- }
- else
- {
- outMsg.writeInt16(CAST_U16(str.size() + 4 + 1), "len");
- outMsg.writeString(str, CAST_S32(str.length()), "message");
- outMsg.writeInt8(0, "zero byte");
- }
-}
-
-void GuildHandler::memberList() const
-{
- // 0 = basic info + alliance info
- // 1 = position name list + member list
- // 2 = position name list + position info list
- // 3 = skill info
- // 4 = expulsion list
-
- createOutPacket(CMSG_GUILD_REQUEST_INFO);
- outMsg.writeInt32(1, "action"); // Request member list
-}
-
-void GuildHandler::info() const
-{
- // 0 = basic info + alliance info
- // 1 = position name list + member list
- // 2 = position name list + position info list
- // 3 = skill info
- // 4 = expulsion list
-
- GuildRecv::showBasicInfo = true;
- createOutPacket(CMSG_GUILD_REQUEST_INFO);
- outMsg.writeInt32(0, "action"); // Request basic info
-}
-
-void GuildHandler::changeMemberPostion(const GuildMember *const member,
- const int level) const
-{
- if ((member == nullptr) || (member->getGuild() == nullptr))
- return;
-
- createOutPacket(CMSG_GUILD_CHANGE_MEMBER_POS);
- outMsg.writeInt16(16, "len");
- outMsg.writeBeingId(member->getID(), "account id");
- outMsg.writeInt32(member->getCharId(), "char id");
- outMsg.writeInt32(level, "pos");
-}
-
-void GuildHandler::changeNotice(const int guildId,
- const std::string &restrict msg1,
- const std::string &restrict msg2) const
-{
- createOutPacket(CMSG_GUILD_CHANGE_NOTICE);
- outMsg.writeInt32(guildId, "guild id");
- outMsg.writeString(msg1, 60, "msg1");
- outMsg.writeString(msg2, 120, "msg2");
-}
-
-void GuildHandler::checkMaster() const
-{
- createOutPacket(CMSG_GUILD_CHECK_MASTER);
-}
-
-void GuildHandler::requestAlliance(const Being *const being) const
-{
- if (being == nullptr)
- return;
-
- createOutPacket(CMSG_GUILD_ALLIANCE_REQUEST);
- outMsg.writeBeingId(being->getId(), "account id");
- outMsg.writeInt32(0, "inviter account id");
- outMsg.writeInt32(0, "inviter char id");
-}
-
-void GuildHandler::requestAllianceResponse(const int beingId,
- const bool accept) const
-{
- createOutPacket(CMSG_GUILD_ALLIANCE_REPLY);
- outMsg.writeInt32(beingId, "account id");
- outMsg.writeInt32(static_cast<int32_t>(accept), "accept flag");
-}
-
-void GuildHandler::endAlliance(const int guildId,
- const int flag) const
-{
- createOutPacket(CMSG_GUILD_ALLIANCE_DELETE);
- outMsg.writeInt32(guildId, "guild id");
- outMsg.writeInt32(flag, "flag");
-}
-
-void GuildHandler::changePostionInfo(const int posId,
- const int mode,
- const int ranking,
- const int payRate,
- const std::string &name) const
-{
- createOutPacket(CMSG_GUILD_CHANGE_POS_INFO);
- outMsg.writeInt16(44, "len");
- outMsg.writeInt32(posId, "position id");
- outMsg.writeInt32(mode, "mode");
- outMsg.writeInt32(ranking, "ranking");
- outMsg.writeInt32(payRate, "pay rate");
- outMsg.writeString(name, 24, "name");
-}
-
-void GuildHandler::requestOpposition(const Being *const being) const
-{
- if (being == nullptr)
- return;
-
- createOutPacket(CMSG_GUILD_OPPOSITION);
- outMsg.writeBeingId(being->getId(), "account id");
-}
-
-void GuildHandler::breakGuild(const std::string &name) const
-{
- createOutPacket(CMSG_GUILD_BREAK);
- outMsg.writeString(name, 40, "name");
-}
-
-void GuildHandler::changeEmblem(std::string emblem) const
-{
- createOutPacket(CMSG_GUILD_CHANGE_EMBLEM);
- if (emblem.size() > 200)
- emblem = emblem.substr(0, 200);
- const int sz = CAST_S32(emblem.size());
- outMsg.writeInt16(CAST_S16(sz + 4), "len");
- outMsg.writeString(emblem, sz, "emblem");
-}
-
-void GuildHandler::requestEmblem(const int guildId) const
-{
- createOutPacket(CMSG_GUILD_REQUEST_EMBLEM);
- outMsg.writeInt32(guildId, "guild id");
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/guildhandler.h b/src/net/eathena/guildhandler.h
deleted file mode 100644
index b9475f1b8..000000000
--- a/src/net/eathena/guildhandler.h
+++ /dev/null
@@ -1,104 +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 NET_EATHENA_GUILDHANDLER_H
-#define NET_EATHENA_GUILDHANDLER_H
-
-#include "net/guildhandler.h"
-
-class GuildTab;
-
-namespace EAthena
-{
-
-class GuildHandler final : public Net::GuildHandler
-{
- public:
- GuildHandler();
-
- A_DELETE_COPY(GuildHandler)
-
- ~GuildHandler();
-
- void clear() const override final;
-
- ChatTab *getTab() const override final;
-
- void create(const std::string &name) const override final;
-
- void invite(const std::string &name) const override final;
-
- void invite(const Being *const being) const override final;
-
- void inviteResponse(const int guildId,
- const bool response) const override final;
-
- void leave(const int guildId) const override final;
-
- void kick(const GuildMember *restrict const member,
- const std::string &restrict reason) const override final;
-
- void chat(const std::string &text) const override final;
-
- void memberList() const override final;
-
- void info() const override final;
-
- void changeMemberPostion(const GuildMember *const member,
- const int level) const override final;
-
- void changeNotice(const int guildId,
- const std::string &restrict msg1,
- const std::string &restrict msg2)
- const override final;
-
- void checkMaster() const override final;
-
- void requestAlliance(const Being *const being) const override final;
-
- void requestAllianceResponse(const int beingId,
- const bool accept) const override final;
-
- void endAlliance(const int guildId,
- const int flag) const override final;
-
- void changePostionInfo(const int posId,
- const int mode,
- const int ranking,
- const int payRate,
- const std::string &name) const override final;
-
- void requestOpposition(const Being *const being) const override final;
-
- void breakGuild(const std::string &name) const override final;
-
- void changeEmblem(std::string emblem) const override final;
-
- void requestEmblem(const int guildId) const override final;
-};
-
-extern Guild *taGuild;
-
-} // namespace EAthena
-
-extern GuildTab *guildTab;
-
-#endif // NET_EATHENA_GUILDHANDLER_H
diff --git a/src/net/eathena/guildrecv.cpp b/src/net/eathena/guildrecv.cpp
deleted file mode 100644
index d235c23bb..000000000
--- a/src/net/eathena/guildrecv.cpp
+++ /dev/null
@@ -1,717 +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 "net/eathena/guildrecv.h"
-
-#include "actormanager.h"
-#include "configuration.h"
-#include "notifymanager.h"
-
-#include "being/localplayer.h"
-#include "being/playerinfo.h"
-
-#include "enums/resources/notifytypes.h"
-
-#include "gui/windows/chatwindow.h"
-#include "gui/windows/skilldialog.h"
-#include "gui/windows/socialwindow.h"
-
-#include "gui/widgets/tabs/chat/guildtab.h"
-
-#include "net/messagein.h"
-
-#include "net/eathena/guildhandler.h"
-
-#include "utils/delete2.h"
-#include "utils/checkutils.h"
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-namespace EAthena
-{
-
-Guild *taGuild = nullptr;
-
-namespace GuildRecv
-{
- bool showBasicInfo = false;
-} // namespace GuildRecv
-
-void GuildRecv::processGuildCreateResponse(Net::MessageIn &msg)
-{
- const uint8_t flag = msg.readUInt8("flag");
-
- switch (flag)
- {
- case 0:
- // Success
- NotifyManager::notify(NotifyTypes::GUILD_CREATED);
- break;
-
- case 1:
- // Already in a guild
- NotifyManager::notify(NotifyTypes::GUILD_ALREADY);
- break;
-
- case 2:
- // Unable to make (likely name already in use)
- NotifyManager::notify(NotifyTypes::GUILD_ALREADY);
- break;
-
- case 3:
- // Emperium check failed
- NotifyManager::notify(NotifyTypes::GUILD_EMPERIUM_CHECK_FAILED);
- break;
-
- default:
- // Unknown response
- NotifyManager::notify(NotifyTypes::GUILD_ERROR);
- break;
- }
-}
-
-void GuildRecv::processGuildMasterOrMember(Net::MessageIn &msg)
-{
- msg.readInt32("type"); // Type (0x57 for member, 0xd7 for master)
-}
-
-void GuildRecv::processGuildBasicInfo(Net::MessageIn &msg)
-{
- const int guildId = msg.readInt32("guild id");
- const int level = msg.readInt32("guild level");
- const int members = msg.readInt32("connect member");
- const int maxMembers = msg.readInt32("max member");
- const int avgLevel = msg.readInt32("average level");
- const int exp = msg.readInt32("exp");
- const int nextExp = msg.readInt32("next exp");
- msg.skip(12, "unused");
- const int emblem = msg.readInt32("emblem id");
- std::string name = msg.readString(24, "guild name");
- std::string castle;
- std::string master;
- if (msg.getVersion() >= 20160622)
- {
- castle = msg.readString(16, "castles");
- msg.readInt32("money, unused");
- msg.readBeingId("leader char id");
- }
- else
- {
- master = msg.readString(24, "master name");
- castle = msg.readString(16, "castles");
- msg.readInt32("money, unused");
- }
-
- if (guildTab != nullptr &&
- showBasicInfo)
- {
- showBasicInfo = false;
- // TRANSLATORS: guild info message
- guildTab->chatLog(strprintf(_("Guild name: %s"),
- name.c_str()), ChatMsgType::BY_SERVER);
- if (!master.empty())
- {
- // TRANSLATORS: guild info message
- guildTab->chatLog(strprintf(_("Guild master: %s"),
- master.c_str()), ChatMsgType::BY_SERVER);
- }
- // TRANSLATORS: guild info message
- guildTab->chatLog(strprintf(_("Guild level: %d"), level),
- ChatMsgType::BY_SERVER);
- // TRANSLATORS: guild info message
- guildTab->chatLog(strprintf(_("Online members: %d"),
- members), ChatMsgType::BY_SERVER);
- // TRANSLATORS: guild info message
- guildTab->chatLog(strprintf(_("Max members: %d"),
- maxMembers), ChatMsgType::BY_SERVER);
- // TRANSLATORS: guild info message
- guildTab->chatLog(strprintf(_("Average level: %d"),
- avgLevel), ChatMsgType::BY_SERVER);
- // TRANSLATORS: guild info message
- guildTab->chatLog(strprintf(_("Guild exp: %d"), exp),
- ChatMsgType::BY_SERVER);
- // TRANSLATORS: guild info message
- guildTab->chatLog(strprintf(_("Guild next exp: %d"),
- nextExp), ChatMsgType::BY_SERVER);
- // TRANSLATORS: guild info message
- guildTab->chatLog(strprintf(_("Guild castle: %s"),
- castle.c_str()), ChatMsgType::BY_SERVER);
- }
-
- Guild *const g = Guild::getGuild(CAST_S16(guildId));
- if (g == nullptr)
- return;
- g->setName(name);
- g->setEmblemId(emblem);
-}
-
-void GuildRecv::processGuildAlianceInfo(Net::MessageIn &msg)
-{
- const int length = msg.readInt16("len");
- if (length < 4)
- return;
- const int count = (length - 4) / 32;
-
- for (int i = 0; i < count; i++)
- {
- msg.readInt32("opposition");
- msg.readInt32("guild id");
- msg.readString(24, "guild name");
- }
-}
-
-void GuildRecv::processGuildMemberList(Net::MessageIn &msg)
-{
- const int length = msg.readInt16("len");
- if (length < 4)
- return;
- int guildSize = 0;
- if (msg.getVersion() >= 20161026)
- {
- guildSize = 34;
- reportAlways("missing guild member names");
- }
- else
- {
- guildSize = 104;
- }
-
- const int count = (length - 4) / guildSize;
- if (taGuild == nullptr)
- {
- logger->log1("!taGuild");
- return;
- }
-
- taGuild->clearMembers();
-
- int onlineNum = 0;
- int totalNum = 0;
- for (int i = 0; i < count; i++)
- {
- const BeingId id = msg.readBeingId("account id");
- const int charId = msg.readInt32("char id");
- msg.readInt16("hair");
- msg.readInt16("hair color");
- const int gender = msg.readInt16("gender");
- const int race = msg.readInt16("class");
- const int level = msg.readInt16("level");
- const int exp = msg.readInt32("exp");
- const int online = msg.readInt32("online");
- const int pos = msg.readInt32("position");
- std::string name;
- if (msg.getVersion() < 20161026)
- {
- msg.skip(50, "unused");
- name = msg.readString(24, "name");
- }
- else
- {
- msg.readInt32("last login"); // for now unused
- continue;
- }
-
- GuildMember *const m = taGuild->addMember(id, charId, name);
- if (m != nullptr)
- {
- m->setOnline(online != 0);
- m->setID(id);
- m->setCharId(charId);
- m->setGender(Being::intToGender(CAST_U8(gender)));
- m->setLevel(level);
- m->setExp(exp);
- m->setPos(pos);
- m->setRace(race);
- if (actorManager != nullptr)
- {
- Being *const being = actorManager->findBeingByName(
- name, ActorType::Player);
- if (being != nullptr)
- {
- being->setGuildName(taGuild->getName());
- if (being->getLevel() != level)
- {
- being->setLevel(level);
- being->updateName();
- }
- }
- }
- if (online != 0)
- onlineNum ++;
- totalNum ++;
- }
- }
- taGuild->sort();
- if (actorManager != nullptr)
- {
- actorManager->updatePlayerGuild();
- actorManager->updatePlayerColors();
- }
- if (socialWindow != nullptr)
- socialWindow->updateGuildCounter(onlineNum, totalNum);
-}
-
-void GuildRecv::processGuildPosNameList(Net::MessageIn &msg)
-{
- if (taGuild == nullptr)
- {
- logger->log1("!taGuild");
- return;
- }
-
- const int length = msg.readInt16("len");
- if (length < 4)
- return;
- const int count = (length - 4) / 28;
-
- for (int i = 0; i < count; i++)
- {
- const int id = msg.readInt32("position id");
- const std::string name = msg.readString(24, "position name");
- taGuild->addPos(id, name);
- }
-}
-
-void GuildRecv::processGuildPosInfoList(Net::MessageIn &msg)
-{
- const int length = msg.readInt16("len");
- if (length < 4)
- return;
- const int count = (length - 4) / 16;
-
- for (int i = 0; i < count; i++)
- {
- msg.readInt32("id");
- msg.readInt32("mode");
- msg.readInt32("same id");
- msg.readInt32("exp mode");
- }
-}
-
-void GuildRecv::processGuildPositionChanged(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readInt16("len");
- msg.readInt32("id");
- msg.readInt32("mode");
- msg.readInt32("same ip");
- msg.readInt32("exp mode");
- msg.readString(24, "name");
-}
-
-void GuildRecv::processGuildMemberPosChange(Net::MessageIn &msg)
-{
- msg.readInt16("len");
- const BeingId accountId = msg.readBeingId("account id");
- const int charId = msg.readInt32("char id");
- const int pos = msg.readInt32("position");
- if (taGuild != nullptr)
- {
- GuildMember *const m = taGuild->getMember(accountId, charId);
- if (m != nullptr)
- m->setPos(pos);
- }
-}
-
-void GuildRecv::processGuildEmblemData(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- const int length = msg.readInt16("len");
-
- msg.readInt32("guild id");
- msg.readInt32("emblem id");
- if (length < 12)
- return;
- msg.skip(length - 12, "emblem data");
-}
-
-void GuildRecv::processGuildSkillInfo(Net::MessageIn &msg)
-{
- const int count = (msg.readInt16("len") - 6) / 37;
- msg.readInt16("skill points");
-
- if (skillDialog != nullptr)
- skillDialog->hideSkills(SkillOwner::Guild);
- for (int i = 0; i < count; i++)
- {
- const int skillId = msg.readInt16("skill id");
- const SkillType::SkillType inf = static_cast<SkillType::SkillType>(
- msg.readInt32("inf"));
- const int level = msg.readInt16("skill level");
- const int sp = msg.readInt16("sp");
- const int range = msg.readInt16("range");
- const std::string name = msg.readString(24, "skill name");
- const Modifiable up = fromBool(msg.readUInt8("up flag"), Modifiable);
- PlayerInfo::setSkillLevel(skillId, level);
- if (skillDialog != nullptr)
- {
- if (!skillDialog->updateSkill(skillId, range, up, inf, sp))
- {
- skillDialog->addSkill(SkillOwner::Guild,
- skillId, name, level, range, up, inf, sp);
- }
- }
- }
- if (skillDialog != nullptr)
- skillDialog->updateModels();
-}
-
-void GuildRecv::processGuildNotice(Net::MessageIn &msg)
-{
- if (guildTab != nullptr)
- {
- const std::string msg1 = msg.readString(60, "msg1");
- const std::string msg2 = msg.readString(120, "msg2");
- guildTab->chatLog(msg1, ChatMsgType::BY_SERVER);
- guildTab->chatLog(msg2, ChatMsgType::BY_SERVER);
- }
- else
- {
- msg.readString(60, "msg1");
- msg.readString(120, "msg2");
- }
-}
-
-void GuildRecv::processGuildInvite(Net::MessageIn &msg)
-{
- const int guildId = msg.readInt32("guild id");
-
- if (socialWindow != nullptr)
- {
- const std::string guildName = msg.readString(24, "guild name");
- socialWindow->showGuildInvite(guildName, guildId, "");
- }
- else
- {
- msg.readString(24, "guild name");
- }
-}
-
-void GuildRecv::processGuildInviteAck(Net::MessageIn &msg)
-{
- const uint8_t flag = msg.readUInt8("flag");
- if (guildTab == nullptr)
- return;
-
- switch (flag)
- {
- case 0:
- NotifyManager::notify(NotifyTypes::GUILD_INVITE_FAILED);
- break;
-
- case 1:
- NotifyManager::notify(NotifyTypes::GUILD_INVITE_REJECTED);
- break;
-
- case 2:
- NotifyManager::notify(NotifyTypes::GUILD_INVITE_JOINED);
- break;
-
- case 3:
- NotifyManager::notify(NotifyTypes::GUILD_INVITE_FULL);
- break;
-
- default:
- NotifyManager::notify(NotifyTypes::GUILD_INVITE_ERROR);
- break;
- }
-}
-
-void GuildRecv::processGuildLeave(Net::MessageIn &msg)
-{
- const std::string nick = msg.readString(24, "nick");
- msg.readString(40, "message");
-
- if (taGuild != nullptr)
- taGuild->removeMember(nick);
-
- if (localPlayer == nullptr)
- return;
-
- if (nick == localPlayer->getName())
- {
- if (taGuild != nullptr)
- {
- taGuild->removeFromMembers();
- taGuild->clearMembers();
- localPlayer->removeGuild(taGuild->getId());
- }
- NotifyManager::notify(NotifyTypes::GUILD_LEFT);
- delete2(guildTab)
-
- if ((socialWindow != nullptr) && (taGuild != nullptr))
- socialWindow->removeTab(taGuild);
- if (actorManager != nullptr)
- actorManager->updatePlayerColors();
- }
- else
- {
- NotifyManager::notify(NotifyTypes::GUILD_USER_LEFT, nick);
- if (actorManager != nullptr)
- {
- Being *const b = actorManager->findBeingByName(
- nick, ActorType::Player);
-
- if (b != nullptr)
- b->clearGuilds();
- if (taGuild != nullptr)
- taGuild->removeMember(nick);
- }
- }
-}
-
-void GuildRecv::processGuildMessage(Net::MessageIn &msg)
-{
- const int msgLength = msg.readInt16("len") - 4;
-
- if (msgLength <= 0)
- return;
- if (guildTab != nullptr)
- {
- std::string chatMsg = msg.readString(msgLength, "message");
- const size_t pos = chatMsg.find(" : ", 0);
- if (pos != std::string::npos)
- {
- const std::string sender_name = chatMsg.substr(0, pos);
- chatMsg.erase(0, pos + 3);
- trim(chatMsg);
- guildTab->chatLog(sender_name, chatMsg);
- }
- else
- {
- guildTab->chatLog(chatMsg, ChatMsgType::BY_SERVER);
- }
- }
- else
- {
- DEBUGLOGSTR("invisible guild?");
- msg.readString(msgLength, "message");
- }
-}
-
-void GuildRecv::processGuildSkillUp(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readInt16("skill id");
- msg.readInt16("level");
- msg.readInt16("sp");
- msg.readInt16("range");
- msg.readUInt8("unused?");
-}
-
-void GuildRecv::processGuildReqAlliance(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readInt32("id");
- msg.readString(24, "name");
-}
-
-void GuildRecv::processGuildReqAllianceAck(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readInt32("flag");
-}
-
-void GuildRecv::processGuildDelAlliance(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readInt32("guild id");
- msg.readInt32("flag");
-}
-
-void GuildRecv::processGuildOppositionAck(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readUInt8("flag");
-}
-
-void GuildRecv::processGuildBroken(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readInt32("flag");
-}
-
-void GuildRecv::processGuildExpulsionContinue(const std::string &nick)
-{
- if (taGuild != nullptr)
- taGuild->removeMember(nick);
-
- if (localPlayer == nullptr)
- return;
-
- if (nick == localPlayer->getName())
- {
- if (taGuild != nullptr)
- {
- taGuild->removeFromMembers();
- taGuild->clearMembers();
- }
- NotifyManager::notify(NotifyTypes::GUILD_KICKED);
- delete2(guildTab)
-
- if ((socialWindow != nullptr) && (taGuild != nullptr))
- socialWindow->removeTab(taGuild);
- if (actorManager != nullptr)
- actorManager->updatePlayerColors();
- }
- else
- {
- NotifyManager::notify(NotifyTypes::GUILD_USER_KICKED, nick);
- if (actorManager != nullptr)
- {
- Being *const b = actorManager->findBeingByName(
- nick, ActorType::Player);
-
- if (b != nullptr)
- b->clearGuilds();
- if (taGuild != nullptr)
- taGuild->removeMember(nick);
- }
- }
-}
-
-void GuildRecv::processGuildUpdateCoords(Net::MessageIn &msg)
-{
- const BeingId id = msg.readBeingId("account id");
- const int x = msg.readInt16("x");
- const int y = msg.readInt16("y");
- if (taGuild != nullptr)
- {
- GuildMember *const m = taGuild->getMember(id);
- if (m != nullptr)
- {
- m->setX(x);
- m->setY(y);
- }
- }
-}
-
-void GuildRecv::processGuildPositionInfo(Net::MessageIn &msg)
-{
- const int guildId = msg.readInt32("guild id");
- const int emblem = msg.readInt32("elblem id");
- PlayerInfo::setGuildPositionFlags(
- static_cast<GuildPositionFlags::Type>(msg.readInt32("mode")));
- msg.readUInt8("guild master");
- msg.readInt32("unused");
- std::string guildName = msg.readString(24, "guild name");
-
- Guild *const g = Guild::getGuild(CAST_S16(guildId));
- if (g == nullptr)
- return;
-
- g->setName(guildName);
- g->setEmblemId(emblem);
- if (taGuild == nullptr)
- taGuild = g;
- if ((guildTab == nullptr) && (chatWindow != nullptr))
- {
- guildTab = new GuildTab(chatWindow);
- if (config.getBoolValue("showChatHistory"))
- guildTab->loadFromLogFile("#Guild");
- if (localPlayer != nullptr)
- localPlayer->addGuild(taGuild);
- guildHandler->memberList();
- }
-
- if (localPlayer != nullptr)
- {
- localPlayer->setGuild(g);
- localPlayer->setGuildName(g->getName());
- }
-}
-
-void GuildRecv::processGuildMemberLogin(Net::MessageIn &msg)
-{
- const BeingId accountId = msg.readBeingId("account id");
- const int charId = msg.readInt32("char id");
- const int online = msg.readInt32("flag");
- const GenderT gender = Being::intToGender(CAST_U8(
- msg.readInt16("sex")));
- msg.readInt16("hair");
- msg.readInt16("hair color");
- if (taGuild != nullptr)
- {
- GuildMember *const m = taGuild->getMember(accountId, charId);
- if (m != nullptr)
- {
- m->setOnline(online != 0);
- if (online != 0)
- m->setGender(gender);
- if (guildTab != nullptr)
- guildTab->showOnline(m->getName(), fromBool(online, Online));
- if (socialWindow != nullptr)
- socialWindow->updateGuildCounter();
- }
- }
-}
-
-void GuildRecv::processGuildExpulsion(Net::MessageIn &msg)
-{
- const std::string nick = msg.readString(24, "name");
- msg.readString(40, "message");
-
- GuildRecv::processGuildExpulsionContinue(nick);
-}
-
-void GuildRecv::processGuildExpulsionList(Net::MessageIn &msg)
-{
- const int length = msg.readInt16("len");
- if (length < 4)
- return;
-
- int count;
- if (msg.getVersion() < 20100803)
- {
- count = (length - 4) / 64;
- for (int i = 0; i < count; i++)
- {
- msg.readString(24, "name");
- msg.readString(40, "message");
- }
- }
- else
- {
- count = (length - 4) / 40;
- for (int i = 0; i < count; i++)
- msg.readString(40, "message");
- }
-}
-
-void GuildRecv::processGuildEmblem(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readBeingId("being id");
- msg.readInt32("guild id");
- msg.readInt16("emblem id");
-}
-
-void GuildRecv::processOnlineInfo(Net::MessageIn &msg)
-{
- // look like unused packet
- UNIMPLEMENTEDPACKET;
- msg.readBeingId("being id");
- msg.readInt32("char id");
- msg.readInt32("online");
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/guildrecv.h b/src/net/eathena/guildrecv.h
deleted file mode 100644
index f449480bf..000000000
--- a/src/net/eathena/guildrecv.h
+++ /dev/null
@@ -1,77 +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 NET_EATHENA_GUILDRECV_H
-#define NET_EATHENA_GUILDRECV_H
-
-#include <string>
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-class Guild;
-class GuildTab;
-
-namespace EAthena
-{
- namespace GuildRecv
- {
- extern bool showBasicInfo;
-
- void processGuildCreateResponse(Net::MessageIn &msg);
- void processGuildMasterOrMember(Net::MessageIn &msg);
- void processGuildBasicInfo(Net::MessageIn &msg);
- void processGuildAlianceInfo(Net::MessageIn &msg);
- void processGuildMemberList(Net::MessageIn &msg);
- void processGuildPosNameList(Net::MessageIn &msg);
- void processGuildPosInfoList(Net::MessageIn &msg);
- void processGuildPositionChanged(Net::MessageIn &msg);
- void processGuildMemberPosChange(Net::MessageIn &msg);
- void processGuildEmblemData(Net::MessageIn &msg);
- void processGuildSkillInfo(Net::MessageIn &msg);
- void processGuildNotice(Net::MessageIn &msg);
- void processGuildInvite(Net::MessageIn &msg);
- void processGuildInviteAck(Net::MessageIn &msg);
- void processGuildLeave(Net::MessageIn &msg);
- void processGuildMessage(Net::MessageIn &msg);
- void processGuildSkillUp(Net::MessageIn &msg);
- void processGuildReqAlliance(Net::MessageIn &msg);
- void processGuildReqAllianceAck(Net::MessageIn &msg);
- void processGuildDelAlliance(Net::MessageIn &msg);
- void processGuildOppositionAck(Net::MessageIn &msg);
- void processGuildBroken(Net::MessageIn &msg);
- void processGuildExpulsionContinue(const std::string &nick);
- void processGuildUpdateCoords(Net::MessageIn &msg);
- void processGuildPositionInfo(Net::MessageIn &msg);
- void processGuildMemberLogin(Net::MessageIn &msg);
- void processGuildExpulsion(Net::MessageIn &msg);
- void processGuildExpulsionList(Net::MessageIn &msg);
- void processGuildEmblem(Net::MessageIn &msg);
- void processOnlineInfo(Net::MessageIn &msg);
- } // namespace GuildRecv
- extern Guild *taGuild;
-} // namespace EAthena
-
-extern GuildTab *guildTab;
-
-#endif // NET_EATHENA_GUILDRECV_H
diff --git a/src/net/eathena/homunculushandler.cpp b/src/net/eathena/homunculushandler.cpp
deleted file mode 100644
index 3a3021387..000000000
--- a/src/net/eathena/homunculushandler.cpp
+++ /dev/null
@@ -1,141 +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 "net/eathena/homunculushandler.h"
-
-#include "being/playerinfo.h"
-
-#include "net/serverfeatures.h"
-
-#include "net/eathena/messageout.h"
-#include "net/eathena/protocolout.h"
-
-#include "debug.h"
-
-extern int packetVersion;
-
-namespace EAthena
-{
-
-HomunculusHandler::HomunculusHandler()
-{
- homunculusHandler = this;
-}
-
-HomunculusHandler::~HomunculusHandler()
-{
- homunculusHandler = nullptr;
-}
-
-void HomunculusHandler::setName(const std::string &name) const
-{
- createOutPacket(CMSG_HOMUNCULUS_SET_NAME);
- outMsg.writeString(name, 24, "name");
-}
-
-void HomunculusHandler::moveToMaster() const
-{
- const BeingId id = PlayerInfo::getHomunculusId();
- if (id == BeingId_zero)
- return;
- createOutPacket(CMSG_HOMMERC_MOVE_TO_MASTER);
- outMsg.writeBeingId(id, "homunculus id");
-}
-
-void HomunculusHandler::move(const int x, const int y) const
-{
- const BeingId id = PlayerInfo::getHomunculusId();
- if (id == BeingId_zero)
- return;
- createOutPacket(CMSG_HOMMERC_MOVE_TO);
- outMsg.writeBeingId(id, "homunculus id");
- outMsg.writeCoordinates(CAST_U16(x),
- CAST_U16(y),
- 1U, "position");
-}
-
-void HomunculusHandler::attack(const BeingId targetId,
- const Keep keep) const
-{
- const BeingId id = PlayerInfo::getHomunculusId();
- if (id == BeingId_zero)
- return;
- createOutPacket(CMSG_HOMMERC_ATTACK);
- outMsg.writeBeingId(id, "homunculus id");
- outMsg.writeBeingId(targetId, "target id");
- outMsg.writeInt8(CAST_S8(keep == Keep_true ? 1 : 0), "keep");
-}
-
-void HomunculusHandler::feed() const
-{
- if (packetVersion < 20050425)
- return;
- createOutPacket(CMSG_HOMUNCULUS_MENU);
- outMsg.writeInt16(0, "type");
- outMsg.writeInt8(1, "command"); // feed
-}
-
-void HomunculusHandler::fire() const
-{
- if (packetVersion < 20050425)
- return;
- createOutPacket(CMSG_HOMUNCULUS_MENU);
- outMsg.writeInt16(0, "type");
- outMsg.writeInt8(2, "command"); // delete
-}
-
-void HomunculusHandler::talk(const std::string &restrict text) const
-{
- if (!serverFeatures->haveMovePet())
- return;
- if (text.empty())
- return;
- std::string msg = text;
- if (msg.size() > 500)
- msg = msg.substr(0, 500);
- const size_t sz = msg.size();
-
- createOutPacket(CMSG_HOMMERC_TALK);
- outMsg.writeInt16(CAST_S16(sz + 4 + 1), "len");
- outMsg.writeString(msg, CAST_S32(sz), "message");
- outMsg.writeInt8(0, "zero byte");
-}
-
-void HomunculusHandler::emote(const uint8_t emoteId) const
-{
- if (!serverFeatures->haveMovePet())
- return;
- createOutPacket(CMSG_HOMMERC_EMOTE);
- outMsg.writeInt8(emoteId, "emote id");
-}
-
-void HomunculusHandler::setDirection(const unsigned char type) const
-{
- if (!serverFeatures->haveMovePet())
- return;
- createOutPacket(CMSG_HOMMERC_DIRECTION);
- outMsg.writeInt32(0, "pet id");
- outMsg.writeInt8(0, "head direction");
- outMsg.writeInt8(0, "unused");
- outMsg.writeInt8(MessageOut::toServerDirection(type),
- "pet direction");
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/homunculushandler.h b/src/net/eathena/homunculushandler.h
deleted file mode 100644
index 817c6ee75..000000000
--- a/src/net/eathena/homunculushandler.h
+++ /dev/null
@@ -1,59 +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 NET_EATHENA_HOMUNCULUSHANDLER_H
-#define NET_EATHENA_HOMUNCULUSHANDLER_H
-
-#include "net/homunculushandler.h"
-
-namespace EAthena
-{
-class HomunculusHandler final : public Net::HomunculusHandler
-{
- public:
- HomunculusHandler();
-
- A_DELETE_COPY(HomunculusHandler)
-
- ~HomunculusHandler();
-
- void setName(const std::string &name) const override final;
-
- void moveToMaster() const override final;
-
- void move(const int x, const int y) const override final;
-
- void attack(const BeingId targetId,
- const Keep keep) const override final;
-
- void feed() const override final;
-
- void fire() const override final;
-
- void talk(const std::string &restrict text) const override final;
-
- void emote(const uint8_t emoteId) const override final;
-
- void setDirection(const unsigned char type) const override final;
-};
-
-} // namespace EAthena
-
-#endif // NET_EATHENA_HOMUNCULUSHANDLER_H
diff --git a/src/net/eathena/homunculusrecv.cpp b/src/net/eathena/homunculusrecv.cpp
deleted file mode 100644
index 204b618a7..000000000
--- a/src/net/eathena/homunculusrecv.cpp
+++ /dev/null
@@ -1,227 +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 "net/eathena/homunculusrecv.h"
-
-#include "actormanager.h"
-#include "notifymanager.h"
-
-#include "being/homunculusinfo.h"
-#include "being/playerinfo.h"
-#include "being/localplayer.h"
-
-#include "enums/resources/notifytypes.h"
-
-#include "gui/windows/skilldialog.h"
-
-#include "resources/iteminfo.h"
-
-#include "resources/db/itemdb.h"
-
-#include "net/messagein.h"
-
-#include "utils/stringutils.h"
-
-#include "debug.h"
-
-namespace EAthena
-{
-
-void HomunculusRecv::processHomunculusSkills(Net::MessageIn &msg)
-{
- if (skillDialog != nullptr)
- skillDialog->hideSkills(SkillOwner::Homunculus);
-
- const int count = (msg.readInt16("len") - 4) / 37;
- for (int f = 0; f < count; f ++)
- {
- const int skillId = msg.readInt16("skill id");
- const SkillType::SkillType inf = static_cast<SkillType::SkillType>(
- msg.readInt16("inf"));
- msg.readInt16("unused");
- const int level = msg.readInt16("skill level");
- const int sp = msg.readInt16("sp");
- const int range = msg.readInt16("range");
- const std::string name = msg.readString(24, "skill name");
- const Modifiable up = fromBool(msg.readUInt8("up flag"), Modifiable);
- PlayerInfo::setSkillLevel(skillId, level);
- if (skillDialog != nullptr)
- {
- if (!skillDialog->updateSkill(skillId, range, up, inf, sp))
- {
- skillDialog->addSkill(SkillOwner::Homunculus,
- skillId, name, level, range, up, inf, sp);
- }
- }
- }
- if (skillDialog != nullptr)
- skillDialog->updateModels();
-}
-
-void HomunculusRecv::processHomunculusData(Net::MessageIn &msg)
-{
- msg.readUInt8("unused");
- const int cmd = msg.readUInt8("state");
- const BeingId id = msg.readBeingId("homunculus id");
- Being *const dstBeing = actorManager->findBeing(id);
- const int data = msg.readInt32("data");
- if (cmd == 0) // pre init
- {
- HomunculusInfo *const info = new HomunculusInfo;
- info->id = id;
- PlayerInfo::setHomunculus(info);
- PlayerInfo::setHomunculusBeing(dstBeing);
- return;
- }
- HomunculusInfo *const info = PlayerInfo::getHomunculus();
- if (info == nullptr)
- return;
- switch (cmd)
- {
- case 1: // intimacy
- info->intimacy = data;
- break;
- case 2: // hunger
- info->hungry = data;
- break;
- case 3: // accesory
- info->equip = data;
- break;
- default:
- break;
- }
-}
-
-void HomunculusRecv::processHomunculusInfo(Net::MessageIn &msg)
-{
- const std::string name = msg.readString(24, "name");
- msg.readUInt8("flags"); // 0x01 - renamed, 0x02 - vaporize, 0x04 - alive
- const int level = msg.readInt16("level");
- PlayerInfo::setStatBase(Attributes::HOMUN_LEVEL, level);
- const int hungry = msg.readInt16("hungry");
- const int intimacy = msg.readInt16("intimacy");
- const int equip = msg.readInt16("equip");
- PlayerInfo::setStatBase(Attributes::HOMUN_ATK,
- msg.readInt16("atk"));
- PlayerInfo::setStatBase(Attributes::HOMUN_MATK,
- msg.readInt16("matk"));
- PlayerInfo::setStatBase(Attributes::HOMUN_HIT,
- msg.readInt16("hit"));
- PlayerInfo::setStatBase(Attributes::HOMUN_CRIT,
- msg.readInt16("luk/3 or crit/10"));
- PlayerInfo::setStatBase(Attributes::HOMUN_DEF,
- msg.readInt16("def"));
- PlayerInfo::setStatBase(Attributes::HOMUN_MDEF,
- msg.readInt16("mdef"));
- PlayerInfo::setStatBase(Attributes::HOMUN_FLEE,
- msg.readInt16("flee"));
- PlayerInfo::setStatBase(Attributes::HOMUN_ATTACK_DELAY,
- msg.readInt16("attack speed"));
- if (msg.getVersion() >= 20150513)
- {
- PlayerInfo::setStatBase(Attributes::HOMUN_HP,
- msg.readInt32("hp"));
- PlayerInfo::setStatBase(Attributes::HOMUN_MAX_HP,
- msg.readInt32("max hp"));
- }
- else
- {
- PlayerInfo::setStatBase(Attributes::HOMUN_HP,
- msg.readInt16("hp"));
- PlayerInfo::setStatBase(Attributes::HOMUN_MAX_HP,
- msg.readInt16("max hp"));
- }
- PlayerInfo::setStatBase(Attributes::HOMUN_MP,
- msg.readInt16("sp"));
- PlayerInfo::setStatBase(Attributes::HOMUN_MAX_MP,
- msg.readInt16("max sp"));
- PlayerInfo::setStatBase(Attributes::HOMUN_EXP,
- msg.readInt32("exp"));
- PlayerInfo::setStatBase(Attributes::HOMUN_EXP_NEEDED,
- msg.readInt32("next exp"));
- PlayerInfo::setStatBase(Attributes::HOMUN_SKILL_POINTS,
- msg.readInt16("skill points"));
- const int range = msg.readInt16("attack range");
- PlayerInfo::setStatBase(Attributes::HOMUN_ATTACK_RANGE,
- range);
-
- PlayerInfo::updateAttrs();
- HomunculusInfo *const info = PlayerInfo::getHomunculus();
- if (info == nullptr)
- return;
- Being *const dstBeing = actorManager->findBeing(info->id);
-
- info->name = name;
- info->level = level;
- info->range = range;
- info->hungry = hungry;
- info->intimacy = intimacy;
- info->equip = equip;
- PlayerInfo::setHomunculusBeing(dstBeing);
-}
-
-void HomunculusRecv::processHomunculusSkillUp(Net::MessageIn &msg)
-{
- const int skillId = msg.readInt16("skill id");
- const int level = msg.readInt16("level");
- const int sp = msg.readInt16("sp");
- const int range = msg.readInt16("range");
- const Modifiable up = fromBool(msg.readUInt8("up flag"), Modifiable);
-
- if (skillDialog != nullptr && PlayerInfo::getSkillLevel(skillId) != level)
- skillDialog->playUpdateEffect(skillId);
- PlayerInfo::setSkillLevel(skillId, level);
- if (skillDialog != nullptr)
- {
- if (!skillDialog->updateSkill(skillId, range,
- up, SkillType::Unknown, sp))
- {
- skillDialog->addSkill(SkillOwner::Homunculus,
- skillId, "", level,
- range, up, SkillType::Unknown, sp);
- }
- }
-}
-
-void HomunculusRecv::processHomunculusFood(Net::MessageIn &msg)
-{
- const int flag = msg.readUInt8("fail");
- const int itemId = msg.readInt16("food id");
- if (flag != 0)
- {
- NotifyManager::notify(NotifyTypes::HOMUNCULUS_FEED_OK);
- }
- else
- {
- const std::string name = strprintf("[@@%d|%s@@]", itemId,
- ItemDB::get(itemId).getName().c_str());
- NotifyManager::notify(NotifyTypes::HOMUNCULUS_FEED_FAIL, name);
- }
-}
-
-void HomunculusRecv::processHomunculusExp(Net::MessageIn &msg)
-{
- const int exp = msg.readInt32("exp");
- msg.readInt32("unused");
- if (localPlayer != nullptr)
- localPlayer->addHomunXpMessage(exp);
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/homunculusrecv.h b/src/net/eathena/homunculusrecv.h
deleted file mode 100644
index d53a6fcda..000000000
--- a/src/net/eathena/homunculusrecv.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 NET_EATHENA_HOMUNCULUSRECV_H
-#define NET_EATHENA_HOMUNCULUSRECV_H
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-namespace EAthena
-{
- namespace HomunculusRecv
- {
- void processHomunculusSkills(Net::MessageIn &msg);
- void processHomunculusData(Net::MessageIn &msg);
- void processHomunculusInfo(Net::MessageIn &msg);
- void processHomunculusSkillUp(Net::MessageIn &msg);
- void processHomunculusFood(Net::MessageIn &msg);
- void processHomunculusExp(Net::MessageIn &msg);
- } // namespace HomunculusRecv
-} // namespace EAthena
-
-#endif // NET_EATHENA_HOMUNCULUSRECV_H
diff --git a/src/net/eathena/inventoryhandler.cpp b/src/net/eathena/inventoryhandler.cpp
deleted file mode 100644
index 40ae67d5d..000000000
--- a/src/net/eathena/inventoryhandler.cpp
+++ /dev/null
@@ -1,603 +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 "net/eathena/inventoryhandler.h"
-
-#include "const/net/inventory.h"
-
-#include "enums/equipslot.h"
-
-#include "net/eathena/inventoryrecv.h"
-#include "net/eathena/menu.h"
-#include "net/eathena/messageout.h"
-#include "net/eathena/protocolout.h"
-
-#include "utils/foreach.h"
-
-#include "resources/item/item.h"
-
-#include "debug.h"
-
-extern int packetVersion;
-extern int serverVersion;
-
-// this conversion from bit corrupted LOOK_* to EquipSlot
-// for how it corrupted, see BeingRecv::processBeingChangeLookContinue
-const EquipSlot::Type EQUIP_CONVERT[] =
-{
- EquipSlot::PROJECTILE_SLOT, // 0 SPRITE_BASE
- EquipSlot::FEET_SLOT, // 1 SPRITE_HAIR
- EquipSlot::LEGS_SLOT, // 2 SPRITE_WEAPON
- EquipSlot::TORSO_SLOT, // 3 SPRITE_HEAD_BOTTOM
- EquipSlot::GLOVES_SLOT, // 4 SPRITE_HEAD_TOP
- EquipSlot::EVOL_RING1_SLOT, // 5 SPRITE_HEAD_MID
- EquipSlot::PROJECTILE_SLOT, // 6 SPRITE_HAIR_COLOR
- EquipSlot::HEAD_SLOT, // 7 SPRITE_CLOTHES_COLOR
- EquipSlot::RING2_SLOT, // 8 SPRITE_SHIELD
- EquipSlot::PROJECTILE_SLOT, // 9 SPRITE_SHOES
- EquipSlot::FIGHT1_SLOT, // 10 SPRITE_BODY
- EquipSlot::FIGHT2_SLOT, // 11 SPRITE_FLOOR
- EquipSlot::EVOL_RING2_SLOT, // 12 SPRITE_ROBE
- EquipSlot::PROJECTILE_SLOT, // 13 SPRITE_EVOL2
- EquipSlot::COSTUME_ROBE_SLOT, // 14 SPRITE_EVOL3
- EquipSlot::RING1_SLOT, // 15 SPRITE_EVOL4
- EquipSlot::NECK_SLOT, // 16 SPRITE_EVOL5
- EquipSlot::RING2_SLOT, // 17 SPRITE_EVOL6
-};
-
-namespace EAthena
-{
-
-InventoryHandler::InventoryHandler() :
- Ea::InventoryHandler(),
- mItemIndex(0)
-{
- inventoryHandler = this;
-
- InventoryRecv::mCartItems.clear();
-}
-
-InventoryHandler::~InventoryHandler()
-{
- inventoryHandler = nullptr;
-}
-
-void InventoryHandler::equipItem(const Item *const item) const
-{
- if (item == nullptr)
- return;
-
- createOutPacket(CMSG_PLAYER_EQUIP);
- outMsg.writeInt16(CAST_S16(
- item->getInvIndex() + INVENTORY_OFFSET), "index");
- // here we set flag for any slots,
- // probably better set to slot from item properties
- if (packetVersion >= 20130320)
- outMsg.writeInt32(0xFFFFFFFFU, "wear location");
- else
- outMsg.writeInt16(0x7FFFU, "wear location");
-}
-
-void InventoryHandler::unequipItem(const Item *const item) const
-{
- if (item == nullptr)
- return;
-
- createOutPacket(CMSG_PLAYER_UNEQUIP);
- outMsg.writeInt16(CAST_S16(
- item->getInvIndex() + INVENTORY_OFFSET), "index");
-}
-
-void InventoryHandler::useItem(const Item *const item) const
-{
- if (item == nullptr)
- return;
-
- createOutPacket(CMSG_PLAYER_INVENTORY_USE);
- outMsg.writeInt16(CAST_S16(
- item->getInvIndex() + INVENTORY_OFFSET), "index");
- outMsg.writeInt32(item->getId(), "unused");
-}
-
-void InventoryHandler::useItem(const Item *const item,
- const int16_t useType) const
-{
- if (item == nullptr)
- return;
-
- if (serverVersion >= 19)
- {
- createOutPacket(CMSG_PLAYER_INVENTORY_USE2);
- outMsg.writeInt16(CAST_S16(
- item->getInvIndex() + INVENTORY_OFFSET), "index");
- outMsg.writeInt16(useType, "use type");
- }
- else
- {
- createOutPacket(CMSG_PLAYER_INVENTORY_USE);
- outMsg.writeInt16(CAST_S16(
- item->getInvIndex() + INVENTORY_OFFSET), "index");
- outMsg.writeInt32(item->getId(), "unused");
- }
-}
-
-void InventoryHandler::dropItem(const Item *const item, const int amount) const
-{
- if (item == nullptr)
- return;
-
- createOutPacket(CMSG_PLAYER_INVENTORY_DROP);
- const int16_t index = CAST_S16(item->getInvIndex() + INVENTORY_OFFSET);
- if (packetVersion >= 20101124)
- {
- outMsg.writeInt16(index, "index");
- outMsg.writeInt16(CAST_S16(amount), "amount");
- }
- else if (packetVersion >= 20080827)
- {
- outMsg.writeInt16(0, "unknown");
- outMsg.writeInt16(index, "index");
- outMsg.writeInt32(0, "unknown");
- outMsg.writeInt16(0, "unknown");
- outMsg.writeInt8(0, "unknown");
- outMsg.writeInt16(CAST_S16(amount), "amount");
- }
- else if (packetVersion >= 20070212)
- {
- outMsg.writeInt16(0, "unknown");
- outMsg.writeInt8(0, "unknown");
- outMsg.writeInt16(index, "index");
- outMsg.writeInt8(0, "unknown");
- outMsg.writeInt16(CAST_S16(amount), "amount");
- }
- else if (packetVersion >= 20070108)
- {
- outMsg.writeInt32(0, "unknown");
- outMsg.writeInt32(0, "unknown");
- outMsg.writeInt16(0, "unknown");
- outMsg.writeInt16(index, "index");
- outMsg.writeInt32(0, "unknown");
- outMsg.writeInt16(CAST_S16(amount), "amount");
- }
- else if (packetVersion >= 20060327)
- {
- outMsg.writeInt32(0, "unknown");
- outMsg.writeInt16(0, "unknown");
- outMsg.writeInt16(index, "index");
- outMsg.writeInt32(0, "unknown");
- outMsg.writeInt8(0, "unknown");
- outMsg.writeInt16(CAST_S16(amount), "amount");
- }
- else if (packetVersion >= 20050719)
- {
- outMsg.writeInt8(0, "unknown");
- outMsg.writeInt16(index, "index");
- outMsg.writeInt8(0, "unknown");
- outMsg.writeInt32(0, "unknown");
- outMsg.writeInt16(CAST_S16(amount), "amount");
- }
- else if (packetVersion >= 20050718)
- {
- outMsg.writeInt32(0, "unknown");
- outMsg.writeInt16(index, "index");
- outMsg.writeInt16(0, "unknown");
- outMsg.writeInt16(CAST_S16(amount), "amount");
- }
- else if (packetVersion >= 20050628)
- {
- outMsg.writeInt8(0, "unknown");
- outMsg.writeInt16(index, "index");
- outMsg.writeInt32(0, "unknown");
- outMsg.writeInt8(0, "unknown");
- outMsg.writeInt16(CAST_S16(amount), "amount");
- }
- else if (packetVersion >= 20050509)
- {
- outMsg.writeInt16(0, "unknown");
- outMsg.writeInt8(0, "unknown");
- outMsg.writeInt16(index, "index");
- outMsg.writeInt8(0, "unknown");
- outMsg.writeInt16(CAST_S16(amount), "amount");
- }
- else if (packetVersion >= 20050110)
- {
- outMsg.writeInt32(0, "unknown");
- outMsg.writeInt32(0, "unknown");
- outMsg.writeInt32(0, "unknown");
- outMsg.writeInt8(0, "unknown");
- outMsg.writeInt16(index, "index");
- outMsg.writeInt8(0, "unknown");
- outMsg.writeInt16(CAST_S16(amount), "amount");
- }
- else if (packetVersion >= 20041129)
- {
- outMsg.writeInt16(0, "unknown");
- outMsg.writeInt16(index, "index");
- outMsg.writeInt32(0, "unknown");
- outMsg.writeInt16(CAST_S16(amount), "amount");
- }
- else if (packetVersion >= 20041025)
- {
- outMsg.writeInt32(0, "unknown");
- outMsg.writeInt16(index, "index");
- outMsg.writeInt16(0, "unknown");
- outMsg.writeInt16(CAST_S16(amount), "amount");
- }
- else if (packetVersion >= 20041005)
- {
- outMsg.writeInt16(0, "unknown");
- outMsg.writeInt8(0, "unknown");
- outMsg.writeInt16(index, "index");
- outMsg.writeInt32(0, "unknown");
- outMsg.writeInt8(0, "unknown");
- outMsg.writeInt16(CAST_S16(amount), "amount");
- }
- else if (packetVersion >= 20040920)
- {
- outMsg.writeInt32(0, "unknown");
- outMsg.writeInt32(0, "unknown");
- outMsg.writeInt16(0, "unknown");
- outMsg.writeInt16(index, "index");
- outMsg.writeInt16(0, "unknown");
- outMsg.writeInt8(0, "unknown");
- outMsg.writeInt16(CAST_S16(amount), "amount");
- }
- else if (packetVersion >= 20040906)
- {
- outMsg.writeInt32(0, "unknown");
- outMsg.writeInt16(index, "index");
- outMsg.writeInt32(0, "unknown");
- outMsg.writeInt16(0, "unknown");
- outMsg.writeInt8(0, "unknown");
- outMsg.writeInt16(CAST_S16(amount), "amount");
- }
- else if (packetVersion >= 20040809)
- {
- outMsg.writeInt32(0, "unknown");
- outMsg.writeInt16(0, "unknown");
- outMsg.writeInt16(index, "index");
- outMsg.writeInt32(0, "unknown");
- outMsg.writeInt8(0, "unknown");
- outMsg.writeInt16(CAST_S16(amount), "amount");
- }
- else if (packetVersion >= 20040726)
- {
- outMsg.writeInt16(0, "unknown");
- outMsg.writeInt8(0, "unknown");
- outMsg.writeInt16(index, "index");
- outMsg.writeInt32(0, "unknown");
- outMsg.writeInt8(0, "unknown");
- outMsg.writeInt16(CAST_S16(amount), "amount");
- }
- else
- {
- outMsg.writeInt16(index, "index");
- outMsg.writeInt16(CAST_S16(amount), "amount");
- }
-}
-
-void InventoryHandler::closeStorage() const
-{
- createOutPacket(CMSG_CLOSE_STORAGE);
-}
-
-void InventoryHandler::moveItemInventoryToStorage(const int slot,
- const int amount) const
-{
- createOutPacket(CMSG_MOVE_TO_STORAGE);
- if (packetVersion >= 20101124)
- {
- outMsg.writeInt16(CAST_S16(slot + INVENTORY_OFFSET), "index");
- outMsg.writeInt32(amount, "amount");
- }
- else if (packetVersion >= 20080827)
- {
- outMsg.writeInt8(0, "unknown");
- outMsg.writeInt16(CAST_S16(slot + INVENTORY_OFFSET), "index");
- outMsg.writeInt32(0, "unknown");
- outMsg.writeInt32(0, "unknown");
- outMsg.writeInt32(0, "unknown");
- outMsg.writeInt16(0, "unknown");
- outMsg.writeInt8(0, "unknown");
- outMsg.writeInt32(amount, "amount");
- }
- else if (packetVersion >= 20070212)
- {
- outMsg.writeInt32(0, "unknown");
- outMsg.writeInt8(0, "unknown");
- outMsg.writeInt16(CAST_S16(slot + INVENTORY_OFFSET), "index");
- outMsg.writeInt8(0, "unknown");
- outMsg.writeInt32(amount, "amount");
- }
- else if (packetVersion >= 20070108)
- {
- outMsg.writeInt16(0, "unknown");
- outMsg.writeInt16(CAST_S16(slot + INVENTORY_OFFSET), "index");
- outMsg.writeInt32(0, "unknown");
- outMsg.writeInt16(0, "unknown");
- outMsg.writeInt8(0, "unknown");
- outMsg.writeInt32(amount, "amount");
- }
- else if (packetVersion >= 20060327)
- {
- outMsg.writeInt16(0, "unknown");
- outMsg.writeInt8(0, "unknown");
- outMsg.writeInt16(CAST_S16(slot + INVENTORY_OFFSET), "index");
- outMsg.writeInt32(0, "unknown");
- outMsg.writeInt32(0, "unknown");
- outMsg.writeInt32(0, "unknown");
- outMsg.writeInt32(amount, "amount");
- }
- else if (packetVersion >= 20050719)
- {
- outMsg.writeInt32(0, "unknown");
- outMsg.writeInt32(0, "unknown");
- outMsg.writeInt32(0, "unknown");
- outMsg.writeInt16(0, "unknown");
- outMsg.writeInt16(CAST_S16(slot + INVENTORY_OFFSET), "index");
- outMsg.writeInt32(0, "unknown");
- outMsg.writeInt32(0, "unknown");
- outMsg.writeInt8(0, "unknown");
- outMsg.writeInt32(amount, "amount");
- }
- else if (packetVersion >= 20050718)
- {
- outMsg.writeInt32(0, "unknown");
- outMsg.writeInt32(0, "unknown");
- outMsg.writeInt16(0, "unknown");
- outMsg.writeInt16(CAST_S16(slot + INVENTORY_OFFSET), "index");
- outMsg.writeInt16(0, "unknown");
- outMsg.writeInt8(0, "unknown");
- outMsg.writeInt32(amount, "amount");
- }
- else if (packetVersion >= 20050628)
- {
- outMsg.writeInt32(0, "unknown");
- outMsg.writeInt32(0, "unknown");
- outMsg.writeInt32(0, "unknown");
- outMsg.writeInt16(0, "unknown");
- outMsg.writeInt16(CAST_S16(slot + INVENTORY_OFFSET), "index");
- outMsg.writeInt32(0, "unknown");
- outMsg.writeInt32(0, "unknown");
- outMsg.writeInt16(0, "unknown");
- outMsg.writeInt32(amount, "amount");
- }
- else if (packetVersion >= 20050509)
- {
- outMsg.writeInt32(0, "unknown");
- outMsg.writeInt8(0, "unknown");
- outMsg.writeInt16(CAST_S16(slot + INVENTORY_OFFSET), "index");
- outMsg.writeInt8(0, "unknown");
- outMsg.writeInt32(amount, "amount");
- }
- else if (packetVersion >= 20050110)
- {
- outMsg.writeInt32(0, "unknown");
- outMsg.writeInt32(0, "unknown");
- outMsg.writeInt16(CAST_S16(slot + INVENTORY_OFFSET), "index");
- outMsg.writeInt32(0, "unknown");
- outMsg.writeInt16(0, "unknown");
- outMsg.writeInt32(amount, "amount");
- }
- else if (packetVersion >= 20041129)
- {
- outMsg.writeInt16(0, "unknown");
- outMsg.writeInt16(CAST_S16(slot + INVENTORY_OFFSET), "index");
- outMsg.writeInt32(0, "unknown");
- outMsg.writeInt32(amount, "amount");
- }
- else if (packetVersion >= 20041025)
- {
- outMsg.writeInt32(0, "unknown");
- outMsg.writeInt16(CAST_S16(slot + INVENTORY_OFFSET), "index");
- outMsg.writeInt8(0, "unknown");
- outMsg.writeInt32(amount, "amount");
- }
- else if (packetVersion >= 20041005)
- {
- outMsg.writeInt16(0, "unknown");
- outMsg.writeInt8(0, "unknown");
- outMsg.writeInt16(CAST_S16(slot + INVENTORY_OFFSET), "index");
- outMsg.writeInt32(0, "unknown");
- outMsg.writeInt8(0, "unknown");
- outMsg.writeInt32(amount, "amount");
- }
- else if (packetVersion >= 20040920)
- {
- outMsg.writeInt32(0, "unknown");
- outMsg.writeInt16(CAST_S16(slot + INVENTORY_OFFSET), "index");
- outMsg.writeInt32(0, "unknown");
- outMsg.writeInt32(0, "unknown");
- outMsg.writeInt32(0, "unknown");
- outMsg.writeInt8(0, "unknown");
- outMsg.writeInt32(amount, "amount");
- }
- else if (packetVersion >= 20040906)
- {
- outMsg.writeInt8(0, "unknown");
- outMsg.writeInt16(CAST_S16(slot + INVENTORY_OFFSET), "index");
- outMsg.writeInt32(0, "unknown");
- outMsg.writeInt32(0, "unknown");
- outMsg.writeInt16(0, "unknown");
- outMsg.writeInt32(amount, "amount");
- }
- else if (packetVersion >= 20040809)
- {
- outMsg.writeInt16(0, "unknown");
- outMsg.writeInt8(0, "unknown");
- outMsg.writeInt16(CAST_S16(slot + INVENTORY_OFFSET), "index");
- outMsg.writeInt32(0, "unknown");
- outMsg.writeInt32(0, "unknown");
- outMsg.writeInt32(0, "unknown");
- outMsg.writeInt32(amount, "amount");
- }
- else if (packetVersion >= 20040726)
- {
- outMsg.writeInt16(0, "unknown");
- outMsg.writeInt8(0, "unknown");
- outMsg.writeInt16(CAST_S16(slot + INVENTORY_OFFSET), "index");
- outMsg.writeInt32(0, "unknown");
- outMsg.writeInt8(0, "unknown");
- outMsg.writeInt32(amount, "amount");
- }
- else
- {
- outMsg.writeInt16(CAST_S16(slot + INVENTORY_OFFSET), "index");
- outMsg.writeInt32(amount, "amount");
- }
-}
-
-void InventoryHandler::moveItem2(const InventoryTypeT source,
- const int slot,
- const int amount,
- const InventoryTypeT destination) const
-{
- int packet = 0;
- int offset = INVENTORY_OFFSET;
- if (source == InventoryType::Inventory)
- {
- if (destination == InventoryType::Storage)
- {
- moveItemInventoryToStorage(slot, amount);
- return;
- }
- else if (destination == InventoryType::Cart)
- {
- packet = CMSG_MOVE_TO_CART;
- }
- }
- else if (source == InventoryType::Storage)
- {
- offset = STORAGE_OFFSET;
- if (destination == InventoryType::Inventory)
- packet = CMSG_MOVE_FROM_STORAGE;
- else if (destination == InventoryType::Cart)
- packet = CMSG_MOVE_FROM_STORAGE_TO_CART;
- }
- else if (source == InventoryType::Cart)
- {
- if (destination == InventoryType::Inventory)
- packet = CMSG_MOVE_FROM_CART;
- else if (destination == InventoryType::Storage)
- packet = CMSG_MOVE_FROM_CART_TO_STORAGE;
- }
-
- // for packetVersion < 20101124 need use other packet offset
- if (packet != 0)
- {
- createOutPacket(packet);
- outMsg.writeInt16(CAST_S16(slot + offset), "index");
- outMsg.writeInt32(amount, "amount");
- }
-}
-
-void InventoryHandler::useCard(const Item *const item)
-{
- if (item == nullptr)
- return;
-
- mItemIndex = item->getInvIndex();
- createOutPacket(CMSG_PLAYER_USE_CARD);
- outMsg.writeInt16(CAST_S16(
- mItemIndex + INVENTORY_OFFSET), "index");
-}
-
-void InventoryHandler::insertCard(const int cardIndex,
- const int itemIndex) const
-{
- createOutPacket(CMSG_PLAYER_INSERT_CARD);
- outMsg.writeInt16(CAST_S16(cardIndex + INVENTORY_OFFSET),
- "card index");
- outMsg.writeInt16(CAST_S16(itemIndex + INVENTORY_OFFSET),
- "item index");
-}
-
-void InventoryHandler::favoriteItem(const Item *const item,
- const bool favorite) const
-{
- if (item == nullptr)
- return;
- if (packetVersion < 20120410)
- return;
- createOutPacket(CMSG_PLAYER_FAVORITE_ITEM);
- outMsg.writeInt16(CAST_S16(item->getInvIndex()
- + INVENTORY_OFFSET),
- "item index");
- outMsg.writeInt8(static_cast<int8_t>(favorite), "favorite flag");
-}
-
-void InventoryHandler::selectEgg(const Item *const item) const
-{
- if (item == nullptr)
- return;
- createOutPacket(CMSG_PET_SELECT_EGG);
- outMsg.writeInt16(CAST_S16(
- item->getInvIndex() + INVENTORY_OFFSET), "index");
- menu = MenuType::Unknown;
-}
-
-int InventoryHandler::convertFromServerSlot(const int serverSlot) const
-{
- if (serverSlot < 0 || serverSlot >= 17)
- return 0;
-
- return CAST_S32(EQUIP_CONVERT[serverSlot]);
-}
-
-void InventoryHandler::selectCart(const BeingId accountId,
- const int type) const
-{
- if (packetVersion < 20150805)
- return;
- createOutPacket(CMSG_SELECT_CART);
- outMsg.writeBeingId(accountId, "account id");
- outMsg.writeInt8(CAST_S8(type), "type");
-}
-
-void InventoryHandler::identifyItem(const Item *const item) const
-{
- if (packetVersion < 20150513)
- return;
- createOutPacket(CMSG_QUICK_IDENTIFY_ITEM);
- outMsg.writeInt16(CAST_S16(item->getInvIndex()),
- "item index");
-}
-
-void InventoryHandler::mergeItemsAck(const STD_VECTOR<Item*> &items) const
-{
- createOutPacket(CMSG_MERGE_ITEM_ACK);
- const size_t sz = items.size();
- outMsg.writeInt16(CAST_S16(sz * 2 + 4),
- "len");
- FOR_EACH (STD_VECTOR<Item*>::const_iterator, it, items)
- {
- outMsg.writeInt16(CAST_S16((*it)->getInvIndex() + 2),
- "item index");
- }
-}
-
-void InventoryHandler::mergetItemsCancel() const
-{
- createOutPacket(CMSG_MERGE_ITEM_CANCEL);
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/inventoryhandler.h b/src/net/eathena/inventoryhandler.h
deleted file mode 100644
index 79155ddaa..000000000
--- a/src/net/eathena/inventoryhandler.h
+++ /dev/null
@@ -1,97 +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 NET_EATHENA_INVENTORYHANDLER_H
-#define NET_EATHENA_INVENTORYHANDLER_H
-
-#include "net/ea/inventoryhandler.h"
-
-namespace EAthena
-{
-
-class InventoryHandler final : public Ea::InventoryHandler
-{
- public:
- InventoryHandler();
-
- A_DELETE_COPY(InventoryHandler)
-
- ~InventoryHandler();
-
- void equipItem(const Item *const item) const override final;
-
- void unequipItem(const Item *const item) const override final;
-
- void useItem(const Item *const item) const override final;
-
- void useItem(const Item *const item,
- const int16_t useType) const override final;
-
- void dropItem(const Item *const item,
- const int amount) const override final;
-
- void closeStorage() const override final;
-
- void moveItem2(const InventoryTypeT source,
- const int slot,
- const int amount,
- const InventoryTypeT destination) const override final;
-
- void moveItemInventoryToStorage(const int slot,
- const int amount) const;
-
- void useCard(const Item *const item) override final;
-
- void insertCard(const int cardIndex,
- const int itemIndex) const override final;
-
- void favoriteItem(const Item *const item,
- const bool favorite) const override final;
-
- void selectEgg(const Item *const item) const override final;
-
- int convertFromServerSlot(const int serverSlot)
- const override final A_WARN_UNUSED;
-
- void selectCart(const BeingId accountId,
- const int type) const override final;
-
- void identifyItem(const Item *const item) const override final;
-
- void mergeItemsAck(const STD_VECTOR<Item*> &items) const
- override final;
-
- void mergetItemsCancel() const override final;
-
- int getProjectileSlot() const override final
- { return 10; }
-
- int getItemIndex() const override final A_WARN_UNUSED
- { return mItemIndex; }
-
- private:
- int mItemIndex;
-};
-
-} // namespace EAthena
-
-#endif // NET_EATHENA_INVENTORYHANDLER_H
diff --git a/src/net/eathena/inventoryrecv.cpp b/src/net/eathena/inventoryrecv.cpp
deleted file mode 100644
index ead74ad63..000000000
--- a/src/net/eathena/inventoryrecv.cpp
+++ /dev/null
@@ -1,1441 +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 "net/eathena/inventoryrecv.h"
-
-#include "notifymanager.h"
-#include "itemcolormanager.h"
-
-#include "being/localplayer.h"
-
-#include "const/net/inventory.h"
-
-#include "enums/equipslot.h"
-
-#include "enums/resources/notifytypes.h"
-
-#include "enums/net/deleteitemreason.h"
-
-#include "gui/popups/itempopup.h"
-
-#include "gui/widgets/createwidget.h"
-
-#include "gui/windows/insertcarddialog.h"
-
-#include "listeners/arrowslistener.h"
-
-#include "net/inventoryhandler.h"
-#include "net/messagein.h"
-
-#include "net/eathena/itemflags.h"
-#include "net/eathena/menu.h"
-
-#include "net/ea/equipbackend.h"
-#include "net/ea/inventoryrecv.h"
-
-#include "resources/iteminfo.h"
-
-#include "utils/gettext.h"
-#include "utils/foreach.h"
-#include "utils/stringutils.h"
-
-#include "debug.h"
-
-extern int serverVersion;
-extern int packetVersion;
-
-namespace EAthena
-{
-
-namespace InventoryRecv
-{
- // EQP_* to EquipSlot
- const EquipSlot::Type EQUIP_POINTS[EquipSlot::VECTOREND] =
- {
- EquipSlot::LEGS_SLOT, // 0 1 EQP_HEAD_LOW
- EquipSlot::FIGHT1_SLOT, // 1 2 EQP_HAND_R
- EquipSlot::GLOVES_SLOT, // 2 4 EQP_GARMENT
- EquipSlot::RING2_SLOT, // 3 8 EQP_ACC_L
- EquipSlot::RING1_SLOT, // 4 16 EQP_ARMOR
- EquipSlot::FIGHT2_SLOT, // 5 32 EQP_HAND_L
- EquipSlot::FEET_SLOT, // 6 64 EQP_SHOES
- EquipSlot::NECK_SLOT, // 7 128 EQP_ACC_R
- EquipSlot::HEAD_SLOT, // 8 256 EQP_HEAD_TOP
- EquipSlot::TORSO_SLOT, // 9 512 EQP_HEAD_MID
- EquipSlot::EVOL_RING1_SLOT, // 10 1024 EQP_COSTUME_HEAD_TOP
- EquipSlot::EVOL_RING2_SLOT, // 11 2048 EQP_COSTUME_HEAD_MID
- EquipSlot::PROJECTILE_SLOT, // 12 4096 EQP_COSTUME_HEAD_LOW
- EquipSlot::COSTUME_ROBE_SLOT, // 13 8192 EQP_COSTUME_GARMENT
- EquipSlot::PROJECTILE_SLOT, // 14 16384 UNUSED_COSTUME_FLOOR
- EquipSlot::PROJECTILE_SLOT, // 15 32768 EQP_AMMO
- EquipSlot::SHADOW_ARMOR_SLOT, // 16 65536 EQP_SHADOW_ARMOR
- EquipSlot::SHADOW_WEAPON_SLOT, // 17 131072 EQP_SHADOW_WEAPON
- EquipSlot::SHADOW_SHIELD_SLOT, // 18 262144 EQP_SHADOW_SHIELD
- EquipSlot::SHADOW_SHOES_SLOT, // 19 524288 EQP_SHADOW_SHOES
- EquipSlot::SHADOW_ACCESSORY2_SLOT, // 20 1048576 EQP_SHADOW_ACC_R
- EquipSlot::SHADOW_ACCESSORY1_SLOT, // 21 2097152 EQP_SHADOW_ACC_L
- };
-
- Ea::InventoryItems mCartItems;
-} // namespace InventoryRecv
-
-void InventoryRecv::processPlayerEquipment(Net::MessageIn &msg)
-{
- BLOCK_START("InventoryRecv::processPlayerEquipment")
- Inventory *const inventory = localPlayer != nullptr
- ? PlayerInfo::getInventory() : nullptr;
-
- msg.readInt16("len");
- Equipment *const equipment = PlayerInfo::getEquipment();
- if ((equipment != nullptr) && (equipment->getBackend() == nullptr))
- { // look like SMSG_PLAYER_INVENTORY was not received
- Ea::InventoryRecv::mEquips.clear();
- equipment->setBackend(&Ea::InventoryRecv::mEquips);
- }
-
- int packetLen = 2 + 2 + 1 + 1 + 8;
- if (msg.getVersion() >= 20120925)
- packetLen += 4 + 4 + 1;
- else
- packetLen += 1 + 2 + 2 + 1;
- if (msg.getVersion() >= 20071002)
- packetLen += 4;
- if (msg.getVersion() >= 20080102)
- packetLen += 2;
- if (msg.getVersion() >= 20100629)
- packetLen += 2;
- if (msg.getVersion() >= 20150226)
- packetLen += 26;
-
- const int number = (msg.getLength() - 4) / packetLen;
-
- for (int loop = 0; loop < number; loop++)
- {
- const int index = msg.readInt16("index") - INVENTORY_OFFSET;
- const int itemId = msg.readInt16("item id");
- const ItemTypeT itemType = static_cast<ItemTypeT>(
- msg.readUInt8("item type"));
- int equipType;
- if (msg.getVersion() >= 20120925)
- {
- msg.readInt32("location");
- equipType = msg.readInt32("wear state");
- }
- else
- {
- msg.readUInt8("identified");
- msg.readInt16("location");
- equipType = msg.readInt16("wear state");
- msg.readUInt8("is damaged");
- }
- const uint8_t refine = CAST_U8(msg.readInt8("refine"));
- int cards[maxCards];
- for (int f = 0; f < maxCards; f++)
- cards[f] = msg.readUInt16("card");
- if (msg.getVersion() >= 20071002)
- msg.readInt32("hire expire date (?)");
- if (msg.getVersion() >= 20080102)
- msg.readInt16("equip type");
- if (msg.getVersion() >= 20100629)
- msg.readInt16("item sprite number");
- ItemOptionsList *options = nullptr;
- if (msg.getVersion() >= 20150226)
- {
- options = new ItemOptionsList(msg.readUInt8("option count"));
- for (int f = 0; f < 5; f ++)
- {
- const uint16_t idx = msg.readInt16("option index");
- const uint16_t val = msg.readInt16("option value");
- msg.readUInt8("option param");
- options->add(idx, val);
- }
- }
- ItemFlags flags;
- if (msg.getVersion() >= 20120925)
- flags.byte = msg.readUInt8("flags");
- else
- flags.byte = 0;
- if (inventory != nullptr)
- {
- inventory->setItem(index,
- itemId,
- itemType,
- 1,
- refine,
- ItemColorManager::getColorFromCards(&cards[0]),
- fromBool(flags.bits.isIdentified, Identified),
- fromBool(flags.bits.isDamaged, Damaged),
- fromBool(flags.bits.isFavorite, Favorite),
- Equipm_true,
- Equipped_false);
- inventory->setCards(index, cards, maxCards);
- inventory->setOptions(index, options);
- }
- delete options;
-
- if (equipType != 0)
- {
- Ea::InventoryRecv::mEquips.setEquipment(
- InventoryRecv::getSlot(equipType),
- index);
- }
- }
- BLOCK_END("InventoryRecv::processPlayerEquipment")
-}
-
-void InventoryRecv::processPlayerInventoryAdd(Net::MessageIn &msg)
-{
- BLOCK_START("InventoryRecv::processPlayerInventoryAdd")
- Inventory *const inventory = localPlayer != nullptr
- ? PlayerInfo::getInventory() : nullptr;
-
- if ((PlayerInfo::getEquipment() != nullptr)
- && (PlayerInfo::getEquipment()->getBackend() == nullptr))
- { // look like SMSG_PLAYER_INVENTORY was not received
- Ea::InventoryRecv::mEquips.clear();
- PlayerInfo::getEquipment()->setBackend(&Ea::InventoryRecv::mEquips);
- }
- const int index = msg.readInt16("index") - INVENTORY_OFFSET;
- int amount = msg.readInt16("count");
- const int itemId = msg.readInt16("item id");
- const uint8_t identified = msg.readUInt8("identified");
- const uint8_t damaged = msg.readUInt8("is damaged");
- const uint8_t refine = msg.readUInt8("refine");
- Favorite favorite = Favorite_false;
- int cards[maxCards];
- for (int f = 0; f < maxCards; f++)
- cards[f] = msg.readUInt16("card");
- int equipType;
- if (msg.getVersion() >= 20120925)
- equipType = msg.readInt32("location");
- else
- equipType = msg.readInt16("location");
- const ItemTypeT itemType = static_cast<ItemTypeT>(
- msg.readUInt8("item type"));
- const unsigned char err = msg.readUInt8("result");
- if (msg.getVersion() >= 20061218)
- msg.readInt32("hire expire date");
- if (msg.getVersion() >= 20071002)
- msg.readInt16("bind on equip");
- ItemOptionsList *options = nullptr;
- if (msg.getVersion() >= 20150226)
- {
- options = new ItemOptionsList;
- for (int f = 0; f < 5; f ++)
- {
- const uint16_t idx = msg.readInt16("option index");
- const uint16_t val = msg.readInt16("option value");
- msg.readUInt8("option param");
- options->add(idx, val);
- }
- }
- if (msg.getVersion() >= 20160921)
- {
- favorite = fromBool(msg.readUInt8("favorite"), Favorite);
- msg.readInt16("look");
- }
-
- const ItemColor color = ItemColorManager::getColorFromCards(&cards[0]);
- BeingId floorId;
- if (Ea::InventoryRecv::mSentPickups.empty())
- {
- floorId = BeingId_zero;
- }
- else
- {
- floorId = Ea::InventoryRecv::mSentPickups.front();
- Ea::InventoryRecv::mSentPickups.pop();
- }
-
- if (err != 0u)
- {
- PickupT pickup;
- switch (err)
- {
- case 1:
- pickup = Pickup::BAD_ITEM;
- break;
- case 2:
- pickup = Pickup::TOO_HEAVY;
- break;
- case 4:
- pickup = Pickup::INV_FULL;
- break;
- case 5:
- pickup = Pickup::MAX_AMOUNT;
- break;
- case 6:
- pickup = Pickup::TOO_FAR;
- break;
- case 7:
- pickup = Pickup::STACK_AMOUNT;
- break;
- default:
- pickup = Pickup::UNKNOWN;
- UNIMPLEMENTEDPACKETFIELD(err);
- break;
- }
- if (localPlayer != nullptr)
- {
- if (itemId == 0)
- {
- localPlayer->pickedUp(ItemDB::getEmpty(),
- 0,
- color,
- floorId,
- pickup);
- }
- else
- {
- localPlayer->pickedUp(ItemDB::get(itemId),
- 0,
- color,
- floorId,
- pickup);
- }
- }
- }
- else
- {
- if (localPlayer != nullptr)
- {
- if (itemId == 0)
- {
- localPlayer->pickedUp(ItemDB::getEmpty(),
- amount,
- color,
- floorId,
- Pickup::OKAY);
- }
- else
- {
- localPlayer->pickedUp(ItemDB::get(itemId),
- amount,
- color,
- floorId,
- Pickup::OKAY);
- }
- }
-
- if (inventory != nullptr)
- {
- const Item *const item = inventory->getItem(index);
-
- if ((item != nullptr) && item->getId() == itemId)
- amount += item->getQuantity();
-
- inventory->setItem(index,
- itemId,
- itemType,
- amount,
- refine,
- color,
- fromBool(identified, Identified),
- fromBool(damaged, Damaged),
- favorite,
- fromBool(equipType, Equipm),
- Equipped_false);
- inventory->setCards(index, cards, maxCards);
- inventory->setOptions(index, options);
- }
- ArrowsListener::distributeEvent();
- }
- delete options;
- BLOCK_END("InventoryRecv::processPlayerInventoryAdd")
-}
-
-void InventoryRecv::processPlayerInventory(Net::MessageIn &msg)
-{
- BLOCK_START("InventoryRecv::processPlayerInventory")
- Inventory *const inventory = localPlayer != nullptr
- ? PlayerInfo::getInventory() : nullptr;
- if (PlayerInfo::getEquipment() != nullptr)
- {
- // Clear inventory - this will be a complete refresh
- Ea::InventoryRecv::mEquips.clear();
- PlayerInfo::getEquipment()->setBackend(&Ea::InventoryRecv::mEquips);
- }
-
- if (inventory != nullptr)
- inventory->clear();
-
- msg.readInt16("len");
-
- int packetLen = 7;
- if (msg.getVersion() >= 20120925)
- packetLen += 4 + 1;
- else
- packetLen += 1 + 2;
- if (packetVersion >= 5)
- packetLen += 8;
- if (msg.getVersion() >= 20080102)
- packetLen += 4;
-
- const int number = (msg.getLength() - 4) / packetLen;
-
- for (int loop = 0; loop < number; loop++)
- {
- const int index = msg.readInt16("item index") - INVENTORY_OFFSET;
- const int itemId = msg.readInt16("item id");
- const ItemTypeT itemType = static_cast<ItemTypeT>(
- msg.readUInt8("item type"));
- if (msg.getVersion() < 20120925)
- msg.readUInt8("identified");
- const int amount = msg.readInt16("count");
- if (msg.getVersion() >= 20120925)
- msg.readInt32("wear state / equip");
- else
- msg.readInt16("wear state / equip");
- int cards[maxCards];
- if (packetVersion >= 5)
- {
- for (int f = 0; f < maxCards; f++)
- cards[f] = msg.readUInt16("card");
- }
- else
- {
- for (int f = 0; f < maxCards; f++)
- cards[f] = 0;
- }
- if (msg.getVersion() >= 20080102)
- msg.readInt32("hire expire date (?)");
- ItemFlags flags;
- if (msg.getVersion() >= 20120925)
- flags.byte = msg.readUInt8("flags");
- else
- flags.byte = 0;
-
- if (inventory != nullptr)
- {
- inventory->setItem(index,
- itemId,
- itemType,
- amount,
- 0,
- ItemColorManager::getColorFromCards(&cards[0]),
- fromBool(flags.bits.isIdentified, Identified),
- fromBool(flags.bits.isDamaged, Damaged),
- fromBool(flags.bits.isFavorite, Favorite),
- Equipm_false,
- Equipped_false);
- inventory->setCards(index, cards, maxCards);
- }
- }
- BLOCK_END("InventoryRecv::processPlayerInventory")
-}
-
-void InventoryRecv::processPlayerStorage(Net::MessageIn &msg)
-{
- BLOCK_START("InventoryRecv::processPlayerInventory")
- Ea::InventoryRecv::mInventoryItems.clear();
-
- msg.readInt16("len");
-
- int packetLen = 7;
- if (msg.getVersion() >= 20120925)
- packetLen += 4 + 1;
- else
- packetLen += 1 + 2;
- if (packetVersion >= 5)
- packetLen += 8;
- if (msg.getVersion() >= 20080102)
- packetLen += 4;
-
- int number;
- if (msg.getVersion() >= 20120925)
- {
- msg.readString(24, "storage name");
- number = (msg.getLength() - 4 - 24) / packetLen;
- }
- else
- {
- number = (msg.getLength() - 4) / packetLen;
- }
-
- for (int loop = 0; loop < number; loop++)
- {
- const int index = msg.readInt16("item index") - STORAGE_OFFSET;
- const int itemId = msg.readInt16("item id");
- const ItemTypeT itemType = static_cast<ItemTypeT>(
- msg.readUInt8("item type"));
- if (msg.getVersion() < 20120925)
- msg.readUInt8("identified");
- const int amount = msg.readInt16("count");
- if (msg.getVersion() >= 20120925)
- msg.readInt32("wear state / equip");
- else
- msg.readInt16("wear state / equip");
- int cards[maxCards];
- if (msg.getVersion() >= 5)
- {
- for (int f = 0; f < maxCards; f++)
- cards[f] = msg.readUInt16("card");
- }
- else
- {
- for (int f = 0; f < maxCards; f++)
- cards[f] = 0;
- }
- if (msg.getVersion() >= 20080102)
- msg.readInt32("hire expire date (?)");
- ItemFlags flags;
- if (msg.getVersion() >= 20120925)
- flags.byte = msg.readUInt8("flags");
- else
- flags.byte = 0;
-
- Ea::InventoryRecv::mInventoryItems.push_back(Ea::InventoryItem(
- index,
- itemId,
- itemType,
- cards,
- nullptr,
- amount,
- 0,
- ItemColorManager::getColorFromCards(&cards[0]),
- fromBool(flags.bits.isIdentified, Identified),
- fromBool(flags.bits.isDamaged, Damaged),
- fromBool(flags.bits.isFavorite, Favorite),
- Equipm_false));
- }
- BLOCK_END("InventoryRecv::processPlayerInventory")
-}
-
-void InventoryRecv::processPlayerEquip(Net::MessageIn &msg)
-{
- BLOCK_START("InventoryRecv::processPlayerEquip")
- const int index = msg.readInt16("index") - INVENTORY_OFFSET;
- int equipType;
- if (msg.getVersion() >= 20120925)
- equipType = msg.readInt32("wear location");
- else
- equipType = msg.readInt16("wear location");
- if (msg.getVersion() >= 20100629)
- msg.readInt16("sprite");
- const uint8_t flag = msg.readUInt8("result");
-
- switch (flag)
- {
- case 0:
- Ea::InventoryRecv::mEquips.setEquipment(
- InventoryRecv::getSlot(equipType),
- index);
- break;
- case 1:
- NotifyManager::notify(NotifyTypes::EQUIP_FAILED_LEVEL);
- break;
-
- case 2:
- default:
- NotifyManager::notify(NotifyTypes::EQUIP_FAILED);
- break;
- }
- BLOCK_END("InventoryRecv::processPlayerEquip")
-}
-
-void InventoryRecv::processPlayerUnEquip(Net::MessageIn &msg)
-{
- BLOCK_START("InventoryRecv::processPlayerUnEquip")
- msg.readInt16("index");
- int equipType;
- if (msg.getVersion() >= 20120925)
- equipType = msg.readInt32("wear location");
- else
- equipType = msg.readInt16("wear location");
- const uint8_t flag = msg.readUInt8("result");
-
- if (flag != 0u)
- {
- NotifyManager::notify(NotifyTypes::UNEQUIP_FAILED);
- }
- else
- {
- Ea::InventoryRecv::mEquips.setEquipment(
- InventoryRecv::getSlot(equipType),
- -1);
- }
- if ((equipType & 0x8000) != 0)
- ArrowsListener::distributeEvent();
- BLOCK_END("InventoryRecv::processPlayerUnEquip")
-}
-
-void InventoryRecv::processPlayerInventoryRemove2(Net::MessageIn &msg)
-{
- BLOCK_START("InventoryRecv::processPlayerInventoryRemove2")
- Inventory *const inventory = localPlayer != nullptr
- ? PlayerInfo::getInventory() : nullptr;
-
- const DeleteItemReasonT reason = static_cast<DeleteItemReasonT>(
- msg.readInt16("reason"));
- const int index = msg.readInt16("index") - INVENTORY_OFFSET;
- const int amount = msg.readInt16("amount");
-
- if (inventory != nullptr)
- {
- if (Item *const item = inventory->getItem(index))
- {
- switch (reason)
- {
- case DeleteItemReason::Normal:
- NotifyManager::notify(NotifyTypes::DELETE_ITEM_NORMAL,
- item->getName());
- break;
- case DeleteItemReason::SkillUse:
- NotifyManager::notify(NotifyTypes::DELETE_ITEM_SKILL_USE,
- item->getName());
- break;
- case DeleteItemReason::FailRefine:
- NotifyManager::notify(NotifyTypes::DELETE_ITEM_FAIL_REFINE,
- item->getName());
- break;
- case DeleteItemReason::MaterialChange:
- NotifyManager::notify(
- NotifyTypes::DELETE_ITEM_MATERIAL_CHANGE,
- item->getName());
- break;
- case DeleteItemReason::ToStorage:
- NotifyManager::notify(NotifyTypes::DELETE_ITEM_TO_STORAGE,
- item->getName());
- break;
- case DeleteItemReason::ToCart:
- NotifyManager::notify(NotifyTypes::DELETE_ITEM_TO_CART,
- item->getName());
- break;
- case DeleteItemReason::Sold:
- NotifyManager::notify(NotifyTypes::DELETE_ITEM_SOLD,
- item->getName());
- break;
- case DeleteItemReason::Analysis:
- NotifyManager::notify(NotifyTypes::DELETE_ITEM_ANALYSIS,
- item->getName());
- break;
- default:
- NotifyManager::notify(NotifyTypes::DELETE_ITEM_UNKNOWN,
- item->getName());
- break;
- }
-
- item->increaseQuantity(-amount);
- if (item->getQuantity() == 0)
- inventory->removeItemAt(index);
- ArrowsListener::distributeEvent();
- }
- }
- BLOCK_END("InventoryRecv::processPlayerInventoryRemove2")
-}
-
-void InventoryRecv::processPlayerStorageEquip(Net::MessageIn &msg)
-{
- BLOCK_START("InventoryRecv::processPlayerStorageEquip")
- msg.readInt16("len");
-
- int packetLen = 2 + 2 + 1 + 1 + 8;
- if (msg.getVersion() >= 20120925)
- packetLen += 4 + 4 + 1;
- else
- packetLen += 1 + 2 + 2 + 1;
- if (msg.getVersion() >= 20071002)
- packetLen += 4;
- if (msg.getVersion() >= 20080102)
- packetLen += 2;
- if (msg.getVersion() >= 20100629)
- packetLen += 2;
- if (msg.getVersion() >= 20150226)
- packetLen += 26;
-
- int number;
- if (msg.getVersion() >= 20120925)
- {
- msg.readString(24, "storage name");
- number = (msg.getLength() - 4 - 24) / packetLen;
- }
- else
- {
- number = (msg.getLength() - 4) / packetLen;
- }
-
- for (int loop = 0; loop < number; loop++)
- {
- const int index = msg.readInt16("index") - STORAGE_OFFSET;
- const int itemId = msg.readInt16("item id");
- const ItemTypeT itemType = static_cast<ItemTypeT>(
- msg.readUInt8("item type"));
- const int amount = 1;
- if (msg.getVersion() >= 20120925)
- {
- msg.readInt32("location");
- msg.readInt32("wear state");
- }
- else
- {
- msg.readUInt8("identified");
- msg.readInt16("location");
- msg.readInt16("wear state");
- msg.readUInt8("is damaged");
- }
- const uint8_t refine = msg.readUInt8("refine level");
- int cards[maxCards];
- for (int f = 0; f < maxCards; f++)
- cards[f] = msg.readUInt16("card");
- if (msg.getVersion() >= 20071002)
- msg.readInt32("hire expire date");
- if (msg.getVersion() >= 20080102)
- msg.readInt16("bind on equip");
- if (msg.getVersion() >= 20100629)
- msg.readInt16("sprite");
- ItemOptionsList *options = nullptr;
- if (msg.getVersion() >= 20150226)
- {
- options = new ItemOptionsList(msg.readUInt8("option count"));
- for (int f = 0; f < 5; f ++)
- {
- const uint16_t idx = msg.readInt16("option index");
- const uint16_t val = msg.readInt16("option value");
- msg.readUInt8("option param");
- options->add(idx, val);
- }
- }
-
- ItemFlags flags;
- if (msg.getVersion() >= 20120925)
- flags.byte = msg.readUInt8("flags");
- else
- flags.byte = 0;
-
- Ea::InventoryRecv::mInventoryItems.push_back(Ea::InventoryItem(
- index,
- itemId,
- itemType,
- cards,
- options,
- amount,
- refine,
- ItemColorManager::getColorFromCards(&cards[0]),
- fromBool(flags.bits.isIdentified, Identified),
- fromBool(flags.bits.isDamaged, Damaged),
- fromBool(flags.bits.isFavorite, Favorite),
- Equipm_false));
- delete options;
- }
- BLOCK_END("InventoryRecv::processPlayerStorageEquip")
-}
-
-void InventoryRecv::processPlayerStorageAdd(Net::MessageIn &msg)
-{
- BLOCK_START("InventoryRecv::processPlayerStorageAdd")
- // Move an item into storage
- const int index = msg.readInt16("index") - STORAGE_OFFSET;
- const int amount = msg.readInt32("amount");
- const int itemId = msg.readInt16("item id");
- ItemTypeT itemType;
- if (msg.getVersion() >= 5)
- itemType = static_cast<ItemTypeT>(msg.readUInt8("type"));
- else
- itemType = ItemType::Unknown;
- const unsigned char identified = msg.readUInt8("identify");
- const Damaged damaged = fromBool(msg.readUInt8("attribute"), Damaged);
- const uint8_t refine = msg.readUInt8("refine");
- int cards[maxCards];
- for (int f = 0; f < maxCards; f++)
- cards[f] = msg.readUInt16("card");
- ItemOptionsList *options = nullptr;
- if (msg.getVersion() >= 20150226)
- {
- options = new ItemOptionsList;
- for (int f = 0; f < 5; f ++)
- {
- const uint16_t idx = msg.readInt16("option index");
- const uint16_t val = msg.readInt16("option value");
- msg.readUInt8("option param");
- options->add(idx, val);
- }
- }
-
- const ItemColor color = ItemColorManager::getColorFromCards(&cards[0]);
- if (Item *const item = Ea::InventoryRecv::mStorage->getItem(index))
- {
- item->setId(itemId, color);
- item->increaseQuantity(amount);
- }
- else
- {
- if (Ea::InventoryRecv::mStorage != nullptr)
- {
- Ea::InventoryRecv::mStorage->setItem(index,
- itemId,
- itemType,
- amount,
- refine,
- color,
- fromBool(identified, Identified),
- damaged,
- Favorite_false,
- Equipm_false,
- Equipped_false);
- Ea::InventoryRecv::mStorage->setCards(index, cards, maxCards);
- Ea::InventoryRecv::mStorage->setOptions(index, options);
- }
- }
- delete options;
- BLOCK_END("InventoryRecv::processPlayerStorageAdd")
-}
-
-void InventoryRecv::processPlayerUseCard(Net::MessageIn &msg)
-{
- const Inventory *const inv = PlayerInfo::getInventory();
- const int index = inventoryHandler->getItemIndex();
- const Item *item1 = nullptr;
- if (inv != nullptr)
- item1 = inv->getItem(index);
- SellDialog *const dialog = CREATEWIDGETR(InsertCardDialog,
- index, item1);
-
- const int count = (msg.readInt16("len") - 4) / 2;
- for (int f = 0; f < count; f ++)
- {
- const int itemIndex = msg.readInt16("item index") - INVENTORY_OFFSET;
- if (inv == nullptr)
- continue;
- const Item *const item = inv->getItem(itemIndex);
- if (item == nullptr)
- continue;
- dialog->addItem(item, 0);
- }
-}
-
-void InventoryRecv::processPlayerInsertCard(Net::MessageIn &msg)
-{
- const int itemIndex = msg.readInt16("item index") - INVENTORY_OFFSET;
- const int cardIndex = msg.readInt16("card index") - INVENTORY_OFFSET;
- if (msg.readUInt8("flag") != 0u)
- {
- NotifyManager::notify(NotifyTypes::CARD_INSERT_FAILED);
- }
- else
- {
- NotifyManager::notify(NotifyTypes::CARD_INSERT_SUCCESS);
- Inventory *const inv = PlayerInfo::getInventory();
- if (inv == nullptr)
- return;
- Item *const card = inv->getItem(cardIndex);
- int cardId = 0;
- if (card != nullptr)
- {
- cardId = card->getId();
- card->increaseQuantity(-1);
- if (card->getQuantity() == 0)
- inv->removeItemAt(cardIndex);
- }
- Item *const item = inv->getItem(itemIndex);
- if (item != nullptr)
- {
- item->addCard(cardId);
- item->updateColor();
- itemPopup->resetPopup();
- }
- }
-}
-
-void InventoryRecv::processPlayerItemRentalTime(Net::MessageIn &msg)
-{
- const int id = msg.readInt16("item id");
- const int seconds = msg.readInt32("seconds");
- const ItemInfo &info = ItemDB::get(id);
- const std::string timeStr = timeDiffToString(seconds);
- NotifyManager::notify(NotifyTypes::RENTAL_TIME_LEFT,
- // TRANSLATORS: notification message
- strprintf(_("Left %s rental time for item %s."),
- timeStr.c_str(), info.getName().c_str()));
-}
-
-void InventoryRecv::processPlayerItemRentalExpired(Net::MessageIn &msg)
-{
- Inventory *const inventory = localPlayer != nullptr
- ? PlayerInfo::getInventory() : nullptr;
-
- const int index = msg.readInt16("index") - INVENTORY_OFFSET;
- const int id = msg.readInt16("item id");
- const ItemInfo &info = ItemDB::get(id);
-
- NotifyManager::notify(NotifyTypes::RENTAL_TIME_EXPIRED,
- info.getName());
- if (inventory != nullptr)
- {
- if (Item *const item = inventory->getItem(index))
- {
- item->increaseQuantity(-item->getQuantity());
- inventory->removeItemAt(index);
- ArrowsListener::distributeEvent();
- }
- }
-}
-
-void InventoryRecv::processPlayerStorageRemove(Net::MessageIn &msg)
-{
- BLOCK_START("InventoryRecv::processPlayerStorageRemove")
- // Move an item out of storage
- const int index = msg.readInt16("index") - STORAGE_OFFSET;
- const int amount = msg.readInt32("amount");
- if (Ea::InventoryRecv::mStorage != nullptr)
- {
- if (Item *const item = Ea::InventoryRecv::mStorage->getItem(index))
- {
- item->increaseQuantity(-amount);
- if (item->getQuantity() == 0)
- Ea::InventoryRecv::mStorage->removeItemAt(index);
- }
- }
- BLOCK_END("InventoryRecv::processPlayerStorageRemove")
-}
-
-void InventoryRecv::processCartInfo(Net::MessageIn &msg)
-{
- msg.readInt16("cart items used");
- const int size = msg.readInt16("max cart items");
- PlayerInfo::setAttribute(Attributes::CART_TOTAL_WEIGHT,
- msg.readInt32("cart weight"));
- PlayerInfo::setAttribute(Attributes::CART_MAX_WEIGHT,
- msg.readInt32("max cart weight"));
- if (mCartItems.empty())
- return;
-
- Inventory *const inv = PlayerInfo::getCartInventory();
- if (inv == nullptr)
- return;
-
- inv->resize(size);
-
- FOR_EACH (Ea::InventoryItems::const_iterator, it, mCartItems)
- {
- inv->setItem((*it).slot,
- (*it).id,
- (*it).type,
- (*it).quantity,
- (*it).refine,
- (*it).color,
- (*it).identified,
- (*it).damaged,
- (*it).favorite,
- (*it).equip,
- Equipped_false);
- }
- mCartItems.clear();
-}
-
-void InventoryRecv::processCartRemove(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- // +++ need close or clear cart?
-}
-
-void InventoryRecv::processPlayerCartAdd(Net::MessageIn &msg)
-{
- BLOCK_START("InventoryRecv::processPlayerCartAdd")
- Inventory *const inventory = localPlayer != nullptr
- ? PlayerInfo::getCartInventory() : nullptr;
-
- const int index = msg.readInt16("index") - INVENTORY_OFFSET;
- int amount = msg.readInt32("count");
- const int itemId = msg.readInt16("item id");
- ItemTypeT itemType = ItemType::Unknown;
- if (msg.getVersion() >= 5)
- {
- itemType = static_cast<ItemTypeT>(
- msg.readUInt8("item type"));
- }
- const uint8_t identified = msg.readUInt8("identified");
- const Damaged damaged = fromBool(msg.readUInt8("attribute"), Damaged);
- const uint8_t refine = msg.readUInt8("refine");
- int cards[maxCards];
- for (int f = 0; f < maxCards; f++)
- cards[f] = msg.readUInt16("card");
- ItemOptionsList *options = nullptr;
- if (msg.getVersion() >= 20150226)
- {
- options = new ItemOptionsList;
- for (int f = 0; f < 5; f ++)
- {
- const uint16_t idx = msg.readInt16("option index");
- const uint16_t val = msg.readInt16("option value");
- msg.readUInt8("option param");
- options->add(idx, val);
- }
- }
-
- // check what cart was created, if not add delayed items
- if ((inventory != nullptr) && inventory->getSize() > 0)
- {
- const Item *const item = inventory->getItem(index);
-
- if ((item != nullptr) && item->getId() == itemId)
- amount += item->getQuantity();
-
- inventory->setItem(index,
- itemId,
- itemType,
- amount,
- refine,
- ItemColorManager::getColorFromCards(&cards[0]),
- fromBool(identified, Identified),
- damaged,
- Favorite_false,
- Equipm_false,
- Equipped_false);
- inventory->setCards(index, cards, maxCards);
- inventory->setOptions(index, options);
- }
- else
- {
- mCartItems.push_back(Ea::InventoryItem(index,
- itemId,
- itemType,
- cards,
- options,
- amount,
- refine,
- ItemColorManager::getColorFromCards(&cards[0]),
- fromBool(identified, Identified),
- damaged,
- Favorite_false,
- Equipm_false));
- }
- delete options;
- BLOCK_END("InventoryRecv::processPlayerCartAdd")
-}
-
-void InventoryRecv::processPlayerCartEquip(Net::MessageIn &msg)
-{
- BLOCK_START("InventoryRecv::processPlayerCartEquip")
- msg.readInt16("len");
-
- int packetLen = 2 + 2 + 1 + 1 + 8;
- if (msg.getVersion() >= 20120925)
- packetLen += 4 + 4 + 1;
- else
- packetLen += 1 + 2 + 2 + 1;
- if (msg.getVersion() >= 20071002)
- packetLen += 4;
- if (msg.getVersion() >= 20080102)
- packetLen += 2;
- if (msg.getVersion() >= 20100629)
- packetLen += 2;
- if (msg.getVersion() >= 20150226)
- packetLen += 26;
-
- const int number = (msg.getLength() - 4) / packetLen;
- for (int loop = 0; loop < number; loop++)
- {
- const int index = msg.readInt16("index") - INVENTORY_OFFSET;
- const int itemId = msg.readInt16("item id");
- const ItemTypeT itemType = static_cast<ItemTypeT>(
- msg.readUInt8("item type"));
- const int amount = 1;
- if (msg.getVersion() >= 20120925)
- {
- msg.readInt32("location");
- msg.readInt32("wear state");
- }
- else
- {
- msg.readUInt8("identified");
- msg.readInt16("location");
- msg.readInt16("wear state");
- msg.readUInt8("is damaged");
- }
- const uint8_t refine = msg.readUInt8("refine level");
- int cards[maxCards];
- for (int f = 0; f < maxCards; f++)
- cards[f] = msg.readUInt16("card");
- if (msg.getVersion() >= 20071002)
- msg.readInt32("hire expire date");
- if (msg.getVersion() >= 20080102)
- msg.readInt16("bind on equip");
- if (msg.getVersion() >= 20100629)
- msg.readInt16("sprite");
- ItemOptionsList *options = nullptr;
- if (msg.getVersion() >= 20150226)
- {
- options = new ItemOptionsList(msg.readUInt8("option count"));
- for (int f = 0; f < 5; f ++)
- {
- const uint16_t idx = msg.readInt16("option index");
- const uint16_t val = msg.readInt16("option value");
- msg.readUInt8("option param");
- options->add(idx, val);
- }
- }
- ItemFlags flags;
- if (msg.getVersion() >= 20120925)
- flags.byte = msg.readUInt8("flags");
- else
- flags.byte = 0;
-
- mCartItems.push_back(Ea::InventoryItem(index,
- itemId,
- itemType,
- cards,
- options,
- amount,
- refine,
- ItemColorManager::getColorFromCards(&cards[0]),
- fromBool(flags.bits.isIdentified, Identified),
- fromBool(flags.bits.isDamaged, Damaged),
- fromBool(flags.bits.isFavorite, Favorite),
- Equipm_false));
- delete options;
- }
- BLOCK_END("InventoryRecv::processPlayerCartEquip")
-}
-
-void InventoryRecv::processPlayerCartItems(Net::MessageIn &msg)
-{
- BLOCK_START("InventoryRecv::processPlayerCartItems")
- Ea::InventoryRecv::mInventoryItems.clear();
-
- msg.readInt16("len");
-
- int packetLen = 7;
- if (msg.getVersion() >= 20120925)
- packetLen += 4 + 1;
- else
- packetLen += 1 + 2;
- if (packetVersion >= 5)
- packetLen += 8;
- if (msg.getVersion() >= 20080102)
- packetLen += 4;
-
- const int number = (msg.getLength() - 4) / packetLen;
- for (int loop = 0; loop < number; loop++)
- {
- const int index = msg.readInt16("item index") - INVENTORY_OFFSET;
- const int itemId = msg.readInt16("item id");
- const ItemTypeT itemType = static_cast<ItemTypeT>(
- msg.readUInt8("item type"));
- if (msg.getVersion() < 20120925)
- msg.readUInt8("identified");
- const int amount = msg.readInt16("count");
- if (msg.getVersion() >= 20120925)
- msg.readInt32("wear state / equip");
- int cards[maxCards];
- if (msg.getVersion() >= 5)
- {
- for (int f = 0; f < maxCards; f++)
- cards[f] = msg.readUInt16("card");
- }
- else
- {
- for (int f = 0; f < maxCards; f++)
- cards[f] = 0;
- }
- if (msg.getVersion() >= 20080102)
- msg.readInt32("hire expire date (?)");
- ItemFlags flags;
- if (msg.getVersion() >= 20120925)
- flags.byte = msg.readUInt8("flags");
- else
- flags.byte = 0;
-
- mCartItems.push_back(Ea::InventoryItem(index,
- itemId,
- itemType,
- cards,
- nullptr,
- amount,
- 0,
- ItemColorManager::getColorFromCards(&cards[0]),
- fromBool(flags.bits.isIdentified, Identified),
- fromBool(flags.bits.isDamaged, Damaged),
- fromBool(flags.bits.isFavorite, Favorite),
- Equipm_false));
- }
- BLOCK_END("InventoryRecv::processPlayerCartItems")
-}
-
-void InventoryRecv::processPlayerCartRemove(Net::MessageIn &msg)
-{
- BLOCK_START("InventoryRecv::processPlayerCartRemove")
- const int index = msg.readInt16("index") - INVENTORY_OFFSET;
- const int amount = msg.readInt32("amount");
-
- Inventory *const inv = PlayerInfo::getCartInventory();
- if (inv == nullptr)
- return;
-
- if (Item *const item = inv->getItem(index))
- {
- item->increaseQuantity(-amount);
- if (item->getQuantity() == 0)
- inv->removeItemAt(index);
- }
- BLOCK_END("InventoryRecv::processPlayerCartRemove")
-}
-
-void InventoryRecv::processPlayerIdentifyList(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
-
- menu = MenuType::Identify;
- const int count = msg.readInt16("len") - 4;
- for (int f = 0; f < count; f ++)
- msg.readInt16("inv index");
-}
-
-void InventoryRecv::processPlayerIdentified(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
-
- msg.readInt16("inv index");
- msg.readUInt8("flag");
-}
-
-void InventoryRecv::processPlayerRefine(Net::MessageIn &msg)
-{
- const int flag = msg.readInt16("flag");
- const int index = msg.readInt16("inv index") - INVENTORY_OFFSET;
- msg.readInt16("refine");
- const Inventory *const inv = PlayerInfo::getInventory();
- const Item *item = nullptr;
- int notifyType;
- std::string itemName;
- if (inv != nullptr)
- item = inv->getItem(index);
- if (item != nullptr)
- {
- itemName = item->getName();
- }
- else
- {
- // TRANSLATORS: unknown item
- itemName = _("Unknown item");
- }
- switch (flag)
- {
- case 0:
- notifyType = NotifyTypes::REFINE_SUCCESS;
- break;
- case 1:
- notifyType = NotifyTypes::REFINE_FAILURE;
- break;
- case 2:
- notifyType = NotifyTypes::REFINE_DOWNGRADE;
- break;
- default:
- UNIMPLEMENTEDPACKETFIELD(flag);
- notifyType = NotifyTypes::REFINE_UNKNOWN;
- break;
- }
- NotifyManager::notify(notifyType, itemName);
-}
-
-void InventoryRecv::processPlayerRepairList(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
-
- const int count = (msg.readInt16("len") - 4) / 13;
- for (int f = 0; f < count; f ++)
- {
- msg.readInt16("index");
- msg.readInt16("item id");
- msg.readUInt8("refine");
- for (int d = 0; d < maxCards; d ++)
- msg.readUInt16("card");
- }
- menu = MenuType::RepairWespon;
-}
-
-void InventoryRecv::processPlayerRepairEffect(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
-
- msg.readInt16("item index");
- msg.readUInt8("flag");
-}
-
-void InventoryRecv::processPlayerRefineList(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
-
- const int count = (msg.readInt16("len") - 4) / 13;
-
- for (int f = 0; f < count; f ++)
- {
- msg.readInt16("item index");
- msg.readInt16("item id");
- msg.readUInt8("refine");
- for (int d = 0; d < maxCards; d ++)
- msg.readUInt16("card");
- }
- menu = MenuType::WeaponeRefine;
-}
-
-void InventoryRecv::processPlayerStoragePassword(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
-
- msg.readInt16("info");
-}
-
-void InventoryRecv::processPlayerStoragePasswordResult(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
-
- msg.readInt16("result");
- msg.readInt16("error count");
-}
-
-void InventoryRecv::processPlayerCookingList(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
-
- const int count = (msg.readInt16("len") - 6) / 2;
- msg.readInt16("list type");
- for (int f = 0; f < count; f ++)
- msg.readInt16("item id");
-}
-
-void InventoryRecv::processItemDamaged(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
-
- msg.readInt16("position");
- msg.readBeingId("account id");
-}
-
-void InventoryRecv::processFavoriteItem(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
-
- msg.readInt16("item index");
- msg.readUInt8("favorite (0 - favorite)");
-}
-
-void InventoryRecv::processCartAddError(Net::MessageIn &msg)
-{
- switch (msg.readUInt8("flag"))
- {
- case 0:
- NotifyManager::notify(NotifyTypes::CART_ADD_WEIGHT_ERROR);
- break;
- case 1:
- NotifyManager::notify(NotifyTypes::CART_ADD_COUNT_ERROR);
- break;
- default:
- break;
- }
-}
-
-void InventoryRecv::processBindItem(Net::MessageIn &msg)
-{
- const int index = msg.readInt16("item index") - INVENTORY_OFFSET;
- const Inventory *const inv = PlayerInfo::getInventory();
- if (inv != nullptr)
- {
- std::string itemName;
- const Item *const item = inv->getItem(index);
- if (item != nullptr)
- {
- itemName = item->getName();
- }
- else
- {
- // TRANSLATORS: unknown item message
- itemName = _("Unknown item");
- }
- NotifyManager::notify(NotifyTypes::BOUND_ITEM, itemName);
- }
-}
-
-void InventoryRecv::processPlayerInventoryRemove(Net::MessageIn &msg)
-{
- BLOCK_START("InventoryRecv::processPlayerInventoryRemove")
- Inventory *const inventory = localPlayer != nullptr
- ? PlayerInfo::getInventory() : nullptr;
-
- const int index = msg.readInt16("index") - INVENTORY_OFFSET;
- const int amount = msg.readInt16("amount");
- if (inventory != nullptr)
- {
- if (Item *const item = inventory->getItem(index))
- {
- if (amount != 0)
- {
- NotifyManager::notify(NotifyTypes::DELETE_ITEM_DROPPED,
- item->getName());
- }
- item->increaseQuantity(-amount);
- if (item->getQuantity() == 0)
- inventory->removeItemAt(index);
- ArrowsListener::distributeEvent();
- }
- }
- BLOCK_END("InventoryRecv::processPlayerInventoryRemove")
-}
-
-void InventoryRecv::processSelectCart(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
-
- const int count = msg.readInt16("len") - 8;
- msg.readBeingId("account id");
- for (int f = 0; f < count; f ++)
- msg.readUInt8("cart type");
-}
-
-int InventoryRecv::getSlot(const int eAthenaSlot)
-{
- if (eAthenaSlot == 0)
- return EquipSlot::VECTOREND;
-
- if ((eAthenaSlot & 0x8000) != 0)
- return inventoryHandler->getProjectileSlot();
-
- unsigned int mask = 1;
- int position = 0;
- while ((eAthenaSlot & mask) == 0u)
- {
- mask <<= 1;
- position++;
- }
- if (position >= EquipSlot::VECTOREND)
- return EquipSlot::VECTOREND;
- return CAST_S32(EQUIP_POINTS[position]);
-}
-
-void InventoryRecv::processMergeItem(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
-
- const int count = (msg.readInt16("len") - 4) / 2;
- for (int f = 0; f < count; f ++)
- msg.readInt16("inv index");
-}
-
-void InventoryRecv::processMergeItemResponse(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
-
- msg.readInt16("inv index");
- msg.readInt16("amount");
- msg.readUInt8("result");
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/inventoryrecv.h b/src/net/eathena/inventoryrecv.h
deleted file mode 100644
index 09d868f21..000000000
--- a/src/net/eathena/inventoryrecv.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 NET_EATHENA_INVENTORYRECV_H
-#define NET_EATHENA_INVENTORYRECV_H
-
-#include "net/ea/inventoryitem.h"
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-namespace EAthena
-{
- namespace InventoryRecv
- {
- extern Ea::InventoryItems mCartItems;
-
- void processPlayerEquipment(Net::MessageIn &msg);
- void processPlayerInventoryAdd(Net::MessageIn &msg);
- void processPlayerInventory(Net::MessageIn &msg);
- void processPlayerStorage(Net::MessageIn &msg);
- void processPlayerEquip(Net::MessageIn &msg);
- void processPlayerUnEquip(Net::MessageIn &msg);
- void processPlayerInventoryRemove2(Net::MessageIn &msg);
- void processPlayerStorageEquip(Net::MessageIn &msg);
- void processPlayerStorageAdd(Net::MessageIn &msg);
- void processPlayerUseCard(Net::MessageIn &msg);
- void processPlayerInsertCard(Net::MessageIn &msg);
- void processPlayerItemRentalTime(Net::MessageIn &msg);
- void processPlayerItemRentalExpired(Net::MessageIn &msg);
- void processPlayerStorageRemove(Net::MessageIn &msg);
- void processCartInfo(Net::MessageIn &msg);
- void processCartRemove(Net::MessageIn &msg);
- void processPlayerCartAdd(Net::MessageIn &msg);
- void processPlayerCartEquip(Net::MessageIn &msg);
- void processPlayerCartItems(Net::MessageIn &msg);
- void processPlayerCartRemove(Net::MessageIn &msg);
- void processPlayerIdentifyList(Net::MessageIn &msg);
- void processPlayerIdentified(Net::MessageIn &msg);
- void processPlayerRefine(Net::MessageIn &msg);
- void processPlayerRepairList(Net::MessageIn &msg);
- void processPlayerRepairEffect(Net::MessageIn &msg);
- void processPlayerRefineList(Net::MessageIn &msg);
- void processPlayerStoragePassword(Net::MessageIn &msg);
- void processPlayerStoragePasswordResult(Net::MessageIn &msg);
- void processPlayerCookingList(Net::MessageIn &msg);
- void processItemDamaged(Net::MessageIn &msg);
- void processFavoriteItem(Net::MessageIn &msg);
- void processCartAddError(Net::MessageIn &msg);
- void processBindItem(Net::MessageIn &msg);
- void processPlayerInventoryRemove(Net::MessageIn &msg);
- void processSelectCart(Net::MessageIn &msg);
- void processMergeItem(Net::MessageIn &msg);
- void processMergeItemResponse(Net::MessageIn &msg);
-
- int getSlot(const int eAthenaSlot) A_WARN_UNUSED;
- } // namespace InventoryRecv
-} // namespace EAthena
-
-#endif // NET_EATHENA_INVENTORYRECV_H
diff --git a/src/net/eathena/itemflags.h b/src/net/eathena/itemflags.h
deleted file mode 100644
index a36099f60..000000000
--- a/src/net/eathena/itemflags.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 NET_EATHENA_ITEMFLAGS_H
-#define NET_EATHENA_ITEMFLAGS_H
-
-#include "localconsts.h"
-
-namespace EAthena
-{
- struct ItemFlagBits final
- {
- A_DEFAULT_COPY(ItemFlagBits)
-
- unsigned char isIdentified : 1;
- unsigned char isDamaged : 1;
- unsigned char isFavorite : 1;
- unsigned char spareBits : 5;
- };
-
- union ItemFlags final
- {
- ItemFlagBits bits;
- uint8_t byte;
- } __attribute__((packed));
-} // namespace EAthena
-
-#endif // NET_EATHENA_ITEMFLAGS_H
diff --git a/src/net/eathena/itemhandler.cpp b/src/net/eathena/itemhandler.cpp
deleted file mode 100644
index 02ad723bb..000000000
--- a/src/net/eathena/itemhandler.cpp
+++ /dev/null
@@ -1,35 +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 "net/eathena/itemhandler.h"
-
-#include "debug.h"
-
-namespace EAthena
-{
-
-ItemHandler::ItemHandler() :
- Ea::ItemHandler()
-{
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/itemhandler.h b/src/net/eathena/itemhandler.h
deleted file mode 100644
index 8543fbeac..000000000
--- a/src/net/eathena/itemhandler.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 NET_EATHENA_ITEMHANDLER_H
-#define NET_EATHENA_ITEMHANDLER_H
-
-#include "net/ea/itemhandler.h"
-
-namespace EAthena
-{
-
-class ItemHandler final : public Ea::ItemHandler
-{
- public:
- ItemHandler();
-
- A_DELETE_COPY(ItemHandler)
-};
-
-} // namespace EAthena
-
-#endif // NET_EATHENA_ITEMHANDLER_H
diff --git a/src/net/eathena/itemrecv.cpp b/src/net/eathena/itemrecv.cpp
deleted file mode 100644
index f0a6bd585..000000000
--- a/src/net/eathena/itemrecv.cpp
+++ /dev/null
@@ -1,178 +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 "net/eathena/itemrecv.h"
-
-#include "actormanager.h"
-#include "itemcolormanager.h"
-#include "logger.h"
-
-#include "const/resources/item/cards.h"
-
-#include "net/messagein.h"
-
-#include "debug.h"
-
-namespace EAthena
-{
-
-void ItemRecv::processItemDropped(Net::MessageIn &msg)
-{
- const BeingId id = msg.readBeingId("id");
- const int itemId = msg.readInt16("item id");
- ItemTypeT itemType = ItemType::Unknown;
- if (msg.getVersion() >= 20130000)
- itemType = static_cast<ItemTypeT>(msg.readInt16("type"));
- const Identified identified = fromInt(
- msg.readUInt8("identify"), Identified);
- const int x = msg.readInt16("x");
- const int y = msg.readInt16("y");
- const int subX = CAST_S32(msg.readInt8("subx"));
- const int subY = CAST_S32(msg.readInt8("suby"));
- const int amount = msg.readInt16("count");
-
- if (actorManager != nullptr)
- {
- actorManager->createItem(id,
- itemId,
- x, y,
- itemType,
- amount,
- 0,
- ItemColor_one,
- identified,
- Damaged_false,
- subX, subY,
- nullptr);
- }
-}
-
-void ItemRecv::processItemDropped2(Net::MessageIn &msg)
-{
- const BeingId id = msg.readBeingId("id");
- const int itemId = msg.readInt16("item id");
- const ItemTypeT itemType = static_cast<ItemTypeT>(msg.readUInt8("type"));
- const Identified identified = fromInt(
- msg.readUInt8("identify"), Identified);
- const Damaged damaged = fromBool(msg.readUInt8("attribute"), Damaged);
- const uint8_t refine = msg.readUInt8("refine");
- int cards[maxCards];
- for (int f = 0; f < maxCards; f++)
- cards[f] = msg.readUInt16("card");
- const int x = msg.readInt16("x");
- const int y = msg.readInt16("y");
- const int amount = msg.readInt16("amount");
- const int subX = CAST_S32(msg.readInt8("subx"));
- const int subY = CAST_S32(msg.readInt8("suby"));
-
- if (actorManager != nullptr)
- {
- actorManager->createItem(id,
- itemId,
- x, y,
- itemType,
- amount,
- refine,
- ItemColorManager::getColorFromCards(&cards[0]),
- identified,
- damaged,
- subX, subY,
- &cards[0]);
- }
-}
-
-void ItemRecv::processItemMvpDropped(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readInt16("len");
- msg.readUInt8("type");
- msg.readInt16("item id");
- msg.readUInt8("len");
- msg.readString(24, "name");
- msg.readUInt8("monster name len");
- msg.readString(24, "monster name");
-}
-
-void ItemRecv::processItemVisible(Net::MessageIn &msg)
-{
- const BeingId id = msg.readBeingId("item object id");
- const int itemId = msg.readInt16("item id");
- const Identified identified = fromInt(
- msg.readUInt8("identify"), Identified);
- const int x = msg.readInt16("x");
- const int y = msg.readInt16("y");
- const int amount = msg.readInt16("amount");
- const int subX = CAST_S32(msg.readInt8("sub x"));
- const int subY = CAST_S32(msg.readInt8("sub y"));
-
- if (actorManager != nullptr)
- {
- actorManager->createItem(id,
- itemId,
- x, y,
- ItemType::Unknown,
- amount,
- 0,
- ItemColor_one,
- identified,
- Damaged_false,
- subX, subY,
- nullptr);
- }
-}
-
-void ItemRecv::processItemVisible2(Net::MessageIn &msg)
-{
- const BeingId id = msg.readBeingId("item object id");
- const int itemId = msg.readInt16("item id");
- const ItemTypeT itemType = static_cast<ItemTypeT>(
- msg.readUInt8("type"));
- const Identified identified = fromInt(
- msg.readUInt8("identify"), Identified);
- const Damaged damaged = fromBool(msg.readUInt8("attribute"), Damaged);
- const uint8_t refine = msg.readUInt8("refine");
- int cards[maxCards];
- for (int f = 0; f < maxCards; f++)
- cards[f] = msg.readUInt16("card");
- const int x = msg.readInt16("x");
- const int y = msg.readInt16("y");
- const int amount = msg.readInt16("amount");
- const int subX = CAST_S32(msg.readInt8("sub x"));
- const int subY = CAST_S32(msg.readInt8("sub y"));
-
- if (actorManager != nullptr)
- {
- actorManager->createItem(id,
- itemId,
- x, y,
- itemType,
- amount,
- refine,
- ItemColorManager::getColorFromCards(&cards[0]),
- identified,
- damaged,
- subX, subY,
- &cards[0]);
- }
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/itemrecv.h b/src/net/eathena/itemrecv.h
deleted file mode 100644
index d4eb2df34..000000000
--- a/src/net/eathena/itemrecv.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 NET_EATHENA_ITEMRECV_H
-#define NET_EATHENA_ITEMRECV_H
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-namespace EAthena
-{
- namespace ItemRecv
- {
- void processItemDropped(Net::MessageIn &msg);
- void processItemDropped2(Net::MessageIn &msg);
- void processItemMvpDropped(Net::MessageIn &msg);
- void processItemVisible(Net::MessageIn &msg);
- void processItemVisible2(Net::MessageIn &msg);
- } // namespace ItemRecv
-} // namespace EAthena
-
-#endif // NET_EATHENA_ITEMRECV_H
diff --git a/src/net/eathena/loginhandler.cpp b/src/net/eathena/loginhandler.cpp
deleted file mode 100644
index 35a8cf77f..000000000
--- a/src/net/eathena/loginhandler.cpp
+++ /dev/null
@@ -1,167 +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 "net/eathena/loginhandler.h"
-
-#include "client.h"
-
-#include "net/generalhandler.h"
-#include "net/net.h"
-#include "net/serverfeatures.h"
-
-#include "net/eathena/messageout.h"
-#include "net/eathena/network.h"
-#include "net/eathena/updateprotocol.h"
-#include "net/eathena/protocolout.h"
-
-#include "debug.h"
-
-namespace EAthena
-{
-
-extern ServerInfo charServer;
-
-LoginHandler::LoginHandler() :
- Ea::LoginHandler()
-{
- loginHandler = this;
-}
-
-LoginHandler::~LoginHandler()
-{
- loginHandler = nullptr;
-}
-
-void LoginHandler::connect() const
-{
- if (Network::mInstance == nullptr)
- return;
-
- Network::mInstance->connect(mServer);
- if (serverFeatures->haveServerVersion())
- {
- sendVersion();
- }
- else
- {
- if (client->getState() != State::LOGIN)
- client->setState(State::LOGIN);
- }
-}
-
-bool LoginHandler::isConnected() const
-{
- if (Network::mInstance == nullptr)
- return false;
-
- return Network::mInstance->isConnected();
-}
-
-void LoginHandler::disconnect() const
-{
- if (Network::mInstance != nullptr &&
- Network::mInstance->getServer() == mServer)
- {
- Network::mInstance->disconnect();
- }
-}
-
-void LoginHandler::changePassword(const std::string &restrict oldPassword,
- const std::string &restrict newPassword)
- const
-{
- if (serverVersion == 0)
- return;
- createOutPacket(CMSG_CHAR_PASSWORD_CHANGE);
- outMsg.writeStringNoLog(oldPassword, 24, "old password");
- outMsg.writeStringNoLog(newPassword, 24, "new password");
-}
-
-void LoginHandler::sendLoginRegister(const std::string &restrict username,
- const std::string &restrict password,
- const std::string &restrict email) const
-{
- if (email.empty())
- {
- if (Net::getNetworkType() == ServerType::EATHENA)
- {
- createOutPacket(CMSG_LOGIN_REGISTER_HAN);
- outMsg.writeInt32(20, "client version");
- outMsg.writeString(username, 24, "login");
- outMsg.writeStringNoLog(password, 24, "password");
- outMsg.writeInt8(0x03, "client type");
- outMsg.writeString("127.0.0.1", 16, "ip address");
- outMsg.writeString("001122334455", 13, "mac address");
- outMsg.writeInt8(0, "is gravity id");
- }
- else
- {
- createOutPacket(CMSG_LOGIN_REGISTER);
- outMsg.writeInt32(20, "client version");
- outMsg.writeString(username, 24, "login");
- outMsg.writeStringNoLog(password, 24, "password");
- outMsg.writeInt8(0x03, "client type");
- }
- }
- else
- {
- createOutPacket(CMSG_LOGIN_REGISTER4);
- outMsg.writeString(username, 24, "login");
- outMsg.writeStringNoLog(password, 24, "password");
- outMsg.writeInt8(0x03, "client type");
- outMsg.writeString(email, 40, "email");
- }
-}
-
-ServerInfo *LoginHandler::getCharServer() const
-{
- return &charServer;
-}
-
-void LoginHandler::sendVersion() const
-{
- createOutPacket(CMSG_SERVER_VERSION_REQUEST);
- outMsg.writeInt32(CLIENT_PROTOCOL_VERSION, "protocol version");
- outMsg.writeInt32(0, "unused");
- outMsg.writeInt32(0, "unused");
- outMsg.writeInt32(0, "unused");
- outMsg.writeInt32(0, "unused");
- generalHandler->flushSend();
-}
-
-void LoginHandler::ping() const
-{
- createOutPacket(CMSG_LOGIN_PING);
- outMsg.writeInt32(0, "unused");
- outMsg.writeInt32(0, "unused");
- outMsg.writeInt32(0, "unused");
- outMsg.writeInt32(0, "unused");
- outMsg.writeInt32(0, "unused");
- outMsg.writeInt32(0, "unused");
-}
-
-void LoginHandler::updatePacketVersion() const
-{
- updateProtocol();
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/loginhandler.h b/src/net/eathena/loginhandler.h
deleted file mode 100644
index f9201e8fd..000000000
--- a/src/net/eathena/loginhandler.h
+++ /dev/null
@@ -1,70 +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 NET_EATHENA_LOGINHANDLER_H
-#define NET_EATHENA_LOGINHANDLER_H
-
-#include "net/ea/loginhandler.h"
-
-namespace EAthena
-{
-
-class LoginHandler final : public Ea::LoginHandler
-{
- public:
- LoginHandler();
-
- A_DELETE_COPY(LoginHandler)
-
- ~LoginHandler();
-
- void connect() const override final;
-
- bool isConnected() const override final A_WARN_UNUSED;
-
- void disconnect() const override final;
-
- unsigned int getMaxPasswordLength() const override final A_WARN_UNUSED
- { return 24; }
-
- void changePassword(const std::string &restrict oldPassword,
- const std::string &restrict newPassword)
- const override final;
-
- void sendVersion() const override final;
-
- ServerInfo *getCharServer() const override final A_WARN_UNUSED;
-
- void ping() const override final;
-
- void updatePacketVersion() const override final;
-
- private:
- void sendLoginRegister(const std::string &restrict username,
- const std::string &restrict password,
- const std::string &restrict email)
- const override final;
-};
-
-} // namespace EAthena
-
-#endif // NET_EATHENA_LOGINHANDLER_H
diff --git a/src/net/eathena/loginrecv.cpp b/src/net/eathena/loginrecv.cpp
deleted file mode 100644
index 555d1a2c1..000000000
--- a/src/net/eathena/loginrecv.cpp
+++ /dev/null
@@ -1,294 +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 "net/eathena/loginrecv.h"
-
-#include "client.h"
-#include "configuration.h"
-
-#include "being/being.h"
-
-#include "fs/paths.h"
-
-#include "gui/windows/logindialog.h"
-
-#include "net/logindata.h"
-#include "net/loginhandler.h"
-#include "net/messagein.h"
-
-#include "net/ea/loginrecv.h"
-
-#include "net/eathena/updateprotocol.h"
-
-#include "utils/gettext.h"
-#include "utils/foreach.h"
-
-#include "debug.h"
-
-extern int packetVersion;
-extern int evolPacketOffset;
-
-namespace EAthena
-{
-
-extern ServerInfo charServer;
-
-void LoginRecv::processLoginError2(Net::MessageIn &msg)
-{
- const uint32_t code = msg.readInt32("error");
- msg.readString(20, "error message");
- logger->log("Login::error code: %u", code);
-
- switch (code)
- {
- case 0:
- // TRANSLATORS: error message
- errorMessage = _("Unregistered ID.");
- break;
- case 1:
- // TRANSLATORS: error message
- errorMessage = _("Wrong password.");
- LoginDialog::savedPassword.clear();
- break;
- case 2:
- // TRANSLATORS: error message
- errorMessage = _("Account expired.");
- break;
- case 3:
- // TRANSLATORS: error message
- errorMessage = _("Rejected from server.");
- break;
- case 4:
- // TRANSLATORS: error message
- errorMessage = _("You have been permanently banned from "
- "the game. Please contact the GM team.");
- break;
- case 5:
- // TRANSLATORS: error message
- errorMessage = _("Client too old or wrong server type.\n"
- "Please update client on http://manaplus.org");
- break;
- case 6:
- // TRANSLATORS: error message
- errorMessage = strprintf(_("You have been temporarily "
- "banned from the game until "
- "%s.\nPlease contact the GM "
- "team via the forums."),
- msg.readString(20, "date").c_str());
- break;
- case 7:
- // look like unused
- // TRANSLATORS: error message
- errorMessage = _("Server overpopulated.");
- break;
- case 9:
- // look like unused
- // TRANSLATORS: error message
- errorMessage = _("This user name is already taken.");
- break;
- case 10:
- // look like unused
- // TRANSLATORS: error message
- errorMessage = _("Wrong name.");
- break;
- case 11:
- // look like unused
- // TRANSLATORS: error message
- errorMessage = _("Incorrect email.");
- break;
- case 99:
- // look like unused
- // TRANSLATORS: error message
- errorMessage = _("Username permanently erased.");
- break;
- default:
- // TRANSLATORS: error message
- errorMessage = _("Unknown error.");
- UNIMPLEMENTEDPACKETFIELD(code);
- break;
- }
- client->setState(State::ERROR);
-}
-
-void LoginRecv::processUpdateHost2(Net::MessageIn &msg)
-{
- const int len = msg.readInt16("len") - 4;
- const std::string updateHost = msg.readString(len, "host");
-
- splitToStringVector(loginData.updateHosts, updateHost, '|');
- FOR_EACH (StringVectIter, it, loginData.updateHosts)
- {
- if (!checkPath(*it))
- {
- logger->log1("Warning: incorrect update server name");
- loginData.updateHosts.clear();
- break;
- }
- }
-
- logger->log("Received update hosts \"%s\" from login server.",
- updateHost.c_str());
-
- if (client->getState() == State::PRE_LOGIN)
- client->setState(State::LOGIN);
-}
-
-void LoginRecv::processServerVersion(Net::MessageIn &msg)
-{
- const int len = msg.readInt16("len");
- msg.readInt32("unused");
- serverVersion = msg.readInt32("server version");
- if (serverVersion > 0)
- {
- logger->log("Evol2 server version: %d", serverVersion);
- packetVersion = msg.readInt32("packet version");
- logger->log("Hercules packet version: %d", packetVersion);
- if (packetVersion == 20150000)
- {
- packetVersion = 20141022;
- logger->log("autofix Hercules packet version to: %d",
- packetVersion);
- }
- if (serverVersion >= 16 && len >= 18)
- {
- evolPacketOffset = msg.readInt16("evol packet offset");
- }
- }
- else
- {
- logger->log("Hercules without version");
- }
- updateProtocol();
- client->setState(State::LOGIN);
-}
-
-void LoginRecv::processCondingKey(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- const int sz = msg.readInt16("len") - 4;
- msg.readString(sz, "coding key");
-}
-
-void LoginRecv::processCharPasswordResponse(Net::MessageIn &msg)
-{
- // 0: acc not found, 1: success, 2: password mismatch, 3: pass too short
- const uint8_t errMsg = msg.readUInt8("result code");
- // Successful pass change
- if (errMsg == 1)
- {
- client->setState(State::CHANGEPASSWORD_SUCCESS);
- }
- // pass change failed
- else
- {
- switch (errMsg)
- {
- case 0:
- errorMessage =
- // TRANSLATORS: error message
- _("Account was not found. Please re-login.");
- break;
- case 2:
- // TRANSLATORS: error message
- errorMessage = _("Old password incorrect.");
- break;
- case 3:
- // TRANSLATORS: error message
- errorMessage = _("New password too short.");
- break;
- default:
- // TRANSLATORS: error message
- errorMessage = _("Unknown error.");
- break;
- }
- client->setState(State::ACCOUNTCHANGE_ERROR);
- }
-}
-
-void LoginRecv::processLoginData(Net::MessageIn &msg)
-{
- msg.readInt16("len");
-
- loginHandler->clearWorlds();
-
- int offset = 0;
- int serverLen = 0;
- if (msg.getVersion() >= 20170315)
- {
- offset = 47 + 17;
- serverLen = 32 + 128;
- }
- else
- {
- offset = 47;
- serverLen = 32;
- }
-
- const int worldCount = (msg.getLength() - offset) / serverLen;
-
- Ea::LoginRecv::mToken.session_ID1 = msg.readInt32("session id1");
- Ea::LoginRecv::mToken.account_ID = msg.readBeingId("accound id");
- Ea::LoginRecv::mToken.session_ID2 = msg.readInt32("session id2");
- msg.readInt32("old ip");
- loginData.lastLogin = msg.readString(24, "last login");
- msg.readInt16("unused");
-
- // reserve bits for future usage
- Ea::LoginRecv::mToken.sex = Being::intToGender(CAST_U8(
- msg.readUInt8("gender") & 3U));
-
- if (msg.getVersion() >= 20170315)
- {
- msg.readInt32("unused1");
- msg.readInt32("unused1");
- msg.readInt32("unused1");
- msg.readInt32("unused1");
- msg.readUInt8("unused1");
- }
-
- for (int i = 0; i < worldCount; i++)
- {
- WorldInfo *const world = new WorldInfo;
-
- world->address = msg.readInt32("ip address");
- world->port = msg.readInt16("port");
- world->name = msg.readString(20, "name");
- world->online_users = msg.readInt16("online number");
- config.setValue("updatehost", Ea::LoginRecv::mUpdateHost);
- world->updateHost = Ea::LoginRecv::mUpdateHost;
- msg.readInt16("maintenance");
- msg.readInt16("new");
- if (msg.getVersion() >= 20170315)
- {
- for (int f = 0; f < 32; f ++)
- msg.readInt32("unused2");
- }
-
- logger->log("Network: Server: %s (%s:%d)", world->name.c_str(),
- ipToString(world->address), world->port);
-
- Ea::LoginRecv::mWorlds.push_back(world);
- }
- client->setState(State::WORLD_SELECT);
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/loginrecv.h b/src/net/eathena/loginrecv.h
deleted file mode 100644
index ca2da52bf..000000000
--- a/src/net/eathena/loginrecv.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 NET_EATHENA_LOGINRECV_H
-#define NET_EATHENA_LOGINRECV_H
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-namespace EAthena
-{
- namespace LoginRecv
- {
- void processLoginError2(Net::MessageIn &msg);
- void processUpdateHost2(Net::MessageIn &msg);
- void processServerVersion(Net::MessageIn &msg);
- void processCondingKey(Net::MessageIn &msg);
- void processCharPasswordResponse(Net::MessageIn &msg);
- void processLoginData(Net::MessageIn &msg);
- } // namespace LoginRecv
-} // namespace EAthena
-
-#endif // NET_EATHENA_LOGINRECV_H
diff --git a/src/net/eathena/mail2handler.cpp b/src/net/eathena/mail2handler.cpp
deleted file mode 100644
index 2b4de04ab..000000000
--- a/src/net/eathena/mail2handler.cpp
+++ /dev/null
@@ -1,285 +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 "net/eathena/mail2handler.h"
-
-#include "const/net/inventory.h"
-
-#include "being/localplayer.h"
-
-#include "net/eathena/mail2recv.h"
-#include "net/eathena/messageout.h"
-#include "net/eathena/protocolout.h"
-
-#include "utils/checkutils.h"
-
-#include "resources/mailqueue.h"
-
-#include "resources/item/item.h"
-
-#include "debug.h"
-
-extern int packetVersion;
-extern int serverVersion;
-
-namespace EAthena
-{
-
-Mail2Handler::Mail2Handler()
-{
- mail2Handler = this;
-}
-
-Mail2Handler::~Mail2Handler()
-{
- mail2Handler = nullptr;
- Mail2Recv::mCheckedName.clear();
- while (!Mail2Recv::mMailQueue.empty())
- {
- MailQueue *const mail = Mail2Recv::mMailQueue.front();
- delete mail;
- Mail2Recv::mMailQueue.pop();
- }
-}
-
-void Mail2Handler::openWriteMail(const std::string &receiver) const
-{
- if (packetVersion < 20140416 ||
- (serverVersion < 19 && serverVersion != 0))
- {
- return;
- }
- createOutPacket(CMSG_MAIL2_OPEN_WRITE_MAIL);
- outMsg.writeString(receiver, 24, "receiver name");
-}
-
-void Mail2Handler::addItem(const Item *const item,
- const int amount) const
-{
- if (item == nullptr)
- return;
- if (packetVersion < 20140416 ||
- (serverVersion < 19 && serverVersion != 0))
- {
- return;
- }
-
- createOutPacket(CMSG_MAIL2_ADD_ITEM_TO_MAIL);
- outMsg.writeInt16(CAST_S16(
- item->getInvIndex() + INVENTORY_OFFSET), "index");
- outMsg.writeInt16(CAST_S16(amount), "amount");
-}
-
-void Mail2Handler::removeItem(const int index,
- const int amount) const
-{
- if (packetVersion < 20140416 ||
- (serverVersion < 19 && serverVersion != 0))
- {
- return;
- }
-
- createOutPacket(CMSG_MAIL2_REMOVE_ITEM_MAIL);
- outMsg.writeInt16(CAST_S16(index + INVENTORY_OFFSET), "index");
- outMsg.writeInt16(CAST_S16(amount), "amount");
-}
-
-void Mail2Handler::sendMail(const std::string &to,
- const std::string &title,
- const std::string &body,
- const int64_t &money) const
-{
- if (packetVersion < 20131230 ||
- (serverVersion < 19 && serverVersion != 0))
- {
- return;
- }
- if (localPlayer == nullptr)
- return;
-
- const std::string from = localPlayer->getName();
- const int titleSz = CAST_S32(title.size()) + 1;
- const int bodySz = CAST_S32(body.size()) + 1;
- int32_t sz = 2 + 2 + 24 + 24 + 8 + 2 + 2 + titleSz + bodySz;
- if (sz > 32767 - 4)
- {
- reportAlways("Mail message too big");
- return;
- }
- if (packetVersion >= 20160600)
- sz += 4;
-
- createOutPacket(CMSG_MAIL2_SEND_MAIL);
- outMsg.writeInt16(CAST_S16(sz), "len");
- outMsg.writeString(to, 24, "to");
- outMsg.writeString(from, 24, "from");
- outMsg.writeInt64(money, "money");
- outMsg.writeInt16(CAST_S16(titleSz), "title len");
- outMsg.writeInt16(CAST_S16(bodySz), "body len");
- if (packetVersion >= 20160600)
- outMsg.writeInt32(0, "to char id");
- outMsg.writeString(title, titleSz, "title");
- outMsg.writeString(body, bodySz, "body");
- Mail2Recv::mCheckedName.clear();
-}
-
-void Mail2Handler::queueCheckName(const MailQueueTypeT type,
- const std::string &to,
- const std::string &title,
- const std::string &body,
- const int64_t &money) const
-{
- MailQueue *const mail = new MailQueue;
- mail->to = to;
- mail->title = title;
- mail->body = body;
- mail->money = money;
- mail->type = type;
- Mail2Recv::mMailQueue.push(mail);
- requestCheckName(to);
-}
-
-void Mail2Handler::nextPage(const MailOpenTypeT openType,
- const int64_t mailId) const
-{
- if (packetVersion < 20131218 ||
- (serverVersion < 19 && serverVersion != 0))
- {
- return;
- }
- createOutPacket(CMSG_MAIL2_NEXT_PAGE);
- outMsg.writeInt8(toInt(openType, int8_t), "open type");
- outMsg.writeInt64(mailId, "mail id");
-}
-
-void Mail2Handler::readMail(const MailOpenTypeT openType,
- const int64_t mailId) const
-{
- if (packetVersion < 20131223 ||
- (serverVersion < 19 && serverVersion != 0))
- {
- return;
- }
- createOutPacket(CMSG_MAIL2_READ_MAIL);
- outMsg.writeInt8(toInt(openType, int8_t), "open type");
- outMsg.writeInt64(mailId, "mail id");
-}
-
-void Mail2Handler::deleteMail(const MailOpenTypeT openType,
- const int64_t mailId) const
-{
- if (packetVersion < 20131218 ||
- (serverVersion < 19 && serverVersion != 0))
- {
- return;
- }
- createOutPacket(CMSG_MAIL2_DELETE_MAIL);
- outMsg.writeInt8(toInt(openType, int8_t), "open type");
- outMsg.writeInt64(mailId, "mail id");
-}
-
-void Mail2Handler::requestMoney(const MailOpenTypeT openType,
- const int64_t mailId) const
-{
- if (packetVersion < 20140326 ||
- (serverVersion < 19 && serverVersion != 0))
- {
- return;
- }
- createOutPacket(CMSG_MAIL2_REQUEST_MONEY);
- outMsg.writeInt64(mailId, "mail id");
- outMsg.writeInt8(toInt(openType, int8_t), "open type");
-}
-
-void Mail2Handler::requestItems(const MailOpenTypeT openType,
- const int64_t mailId) const
-{
- if (packetVersion < 20140326 ||
- (serverVersion < 19 && serverVersion != 0))
- {
- return;
- }
- createOutPacket(CMSG_MAIL2_REQUEST_ITEMS);
- outMsg.writeInt64(mailId, "mail id");
- outMsg.writeInt8(toInt(openType, int8_t), "open type");
-}
-
-void Mail2Handler::refreshMailList(const MailOpenTypeT openType,
- const int64_t mailId) const
-{
- if (packetVersion < 20131218 ||
- (serverVersion < 19 && serverVersion != 0))
- {
- return;
- }
- createOutPacket(CMSG_MAIL2_REFRESH_MAIL_LIST);
- outMsg.writeInt8(toInt(openType, int8_t), "open type");
- outMsg.writeInt64(mailId, "mail id");
-}
-
-void Mail2Handler::openMailBox(const MailOpenTypeT openType) const
-{
- if (packetVersion < 20140212 ||
- (serverVersion < 19 && serverVersion != 0))
- {
- return;
- }
- createOutPacket(CMSG_MAIL2_OPEN_MAILBOX);
- outMsg.writeInt8(toInt(openType, int8_t), "open type");
- outMsg.writeInt64(0, "mail id");
-}
-
-void Mail2Handler::closeMailBox() const
-{
- if (packetVersion < 20131211 ||
- (serverVersion < 19 && serverVersion != 0))
- {
- return;
- }
- createOutPacket(CMSG_MAIL2_CLOSE_MAILBOX);
-}
-
-void Mail2Handler::cancelWriteMail() const
-{
- if (packetVersion < 20140326 ||
- (serverVersion < 19 && serverVersion != 0))
- {
- return;
- }
- createOutPacket(CMSG_MAIL2_CANCEL_WRITE_MAIL);
-}
-
-void Mail2Handler::requestCheckName(const std::string &name) const
-{
- if (packetVersion < 20140423 ||
- serverVersion < 19)
- {
- return;
- }
- createOutPacket(CMSG_MAIL2_CHECK_NAME);
- outMsg.writeString(name, 24, "name");
-}
-
-std::string Mail2Handler::getCheckedName() const
-{
- return Mail2Recv::mCheckedName;
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/mail2handler.h b/src/net/eathena/mail2handler.h
deleted file mode 100644
index c7d15dc78..000000000
--- a/src/net/eathena/mail2handler.h
+++ /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/>.
- */
-
-#ifndef NET_EATHENA_MAIL2HANDLER_H
-#define NET_EATHENA_MAIL2HANDLER_H
-
-#include "net/mail2handler.h"
-
-namespace EAthena
-{
-
-class Mail2Handler final : public Net::Mail2Handler
-{
- public:
- Mail2Handler();
-
- A_DELETE_COPY(Mail2Handler)
-
- ~Mail2Handler();
-
- void openWriteMail(const std::string &receiver) const override final;
-
- void addItem(const Item *const item,
- const int amount) const override final;
-
- void removeItem(const int index,
- const int amount) const override final;
-
- void sendMail(const std::string &to,
- const std::string &title,
- const std::string &body,
- const int64_t &money) const override final;
-
- void queueCheckName(const MailQueueTypeT type,
- const std::string &to,
- const std::string &title,
- const std::string &body,
- const int64_t &money) const override final;
-
- void nextPage(const MailOpenTypeT openType,
- const int64_t mailId) const override final;
-
- void readMail(const MailOpenTypeT openType,
- const int64_t mailId) const override final;
-
- void deleteMail(const MailOpenTypeT openType,
- const int64_t mailId) const override final;
-
- void requestMoney(const MailOpenTypeT openType,
- const int64_t mailId) const override final;
-
- void requestItems(const MailOpenTypeT openType,
- const int64_t mailId) const override final;
-
- void refreshMailList(const MailOpenTypeT openType,
- const int64_t mailId) const override final;
-
- void openMailBox(const MailOpenTypeT openType) const override final;
-
- void closeMailBox() const override final;
-
- void cancelWriteMail() const override final;
-
- void requestCheckName(const std::string &name) const override final;
-
- std::string getCheckedName() const override final;
-};
-
-} // namespace EAthena
-
-#endif // NET_EATHENA_MAIL2HANDLER_H
diff --git a/src/net/eathena/mail2recv.cpp b/src/net/eathena/mail2recv.cpp
deleted file mode 100644
index 1afb69d16..000000000
--- a/src/net/eathena/mail2recv.cpp
+++ /dev/null
@@ -1,526 +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 "net/eathena/mail2recv.h"
-
-#include "itemcolormanager.h"
-#include "notifymanager.h"
-
-#include "const/net/inventory.h"
-
-#include "being/playerinfo.h"
-
-#include "enums/resources/notifytypes.h"
-
-#include "gui/mailmessage.h"
-
-#include "gui/windows/maileditwindow.h"
-#include "gui/windows/mailviewwindow.h"
-#include "gui/windows/mailwindow.h"
-
-#include "net/mail2handler.h"
-#include "net/messagein.h"
-
-#include "resources/mailqueue.h"
-
-#include "resources/inventory/inventory.h"
-
-#include "resources/item/item.h"
-#include "resources/item/itemoptionslist.h"
-
-#include "utils/checkutils.h"
-#include "utils/gettext.h"
-#include "utils/stringutils.h"
-#include "utils/timer.h"
-
-#include "debug.h"
-
-namespace EAthena
-{
-
-namespace Mail2Recv
-{
- std::queue<MailQueue*> mMailQueue;
- std::string mCheckedName;
-} // namespace Mail2Recv
-
-void Mail2Recv::processMailIcon(Net::MessageIn &msg)
-{
- // ignored, because if has new mail, server send chat message already.
- msg.readUInt8("has new mail");
-}
-
-void Mail2Recv::processOpenNewMailWindow(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readString(24, "receiver");
- msg.readUInt8("result");
-}
-
-void Mail2Recv::processAddItemResult(Net::MessageIn &msg)
-{
- const int res = msg.readUInt8("result");
- const int index = msg.readInt16("index") - INVENTORY_OFFSET;
- const int amount = msg.readInt16("amount");
- const int itemId = msg.readInt16("item id");
- const ItemTypeT itemType = static_cast<ItemTypeT>(
- msg.readUInt8("item type"));
- const uint8_t identify = msg.readUInt8("identify");
- const Damaged damaged = fromBool(msg.readUInt8("attribute"), Damaged);
- const uint8_t refine = msg.readUInt8("refine");
- int cards[maxCards];
- for (int f = 0; f < maxCards; f++)
- cards[f] = msg.readUInt16("card");
- ItemOptionsList *options = new ItemOptionsList(5);
- for (int f = 0; f < 5; f ++)
- {
- const uint16_t idx = msg.readInt16("option index");
- const uint16_t val = msg.readInt16("option value");
- msg.readUInt8("option param");
- options->add(idx, val);
- }
- msg.readInt16("weight");
- msg.readUInt8("unknown 1");
- msg.readUInt8("unknown 2");
- msg.readUInt8("unknown 3");
- msg.readUInt8("unknown 4");
- msg.readUInt8("unknown 5");
-
- if (mailEditWindow == nullptr)
- {
- reportAlways("Mail edit window not created");
- delete options;
- return;
- }
- Inventory *const inventory = mailEditWindow->getInventory();
- if (inventory == nullptr)
- {
- reportAlways("Mail edit window inventory not exists");
- delete options;
- return;
- }
-
- if (res != 0)
- {
- switch (res)
- {
- case 1:
- NotifyManager::notify(
- NotifyTypes::MAIL_ATTACH_ITEM_WEIGHT_ERROR);
- break;
- case 2:
- NotifyManager::notify(
- NotifyTypes::MAIL_ATTACH_ITEM_FATAL_ERROR);
- break;
- case 3:
- NotifyManager::notify(
- NotifyTypes::MAIL_ATTACH_ITEM_NO_SPACE);
- break;
- case 4:
- NotifyManager::notify(
- NotifyTypes::MAIL_ATTACH_ITEM_NOT_TRADEABLE);
- break;
- default:
- NotifyManager::notify(
- NotifyTypes::MAIL_ATTACH_ITEM_UNKNOWN_ERROR);
- UNIMPLEMENTEDPACKETFIELD(res);
- break;
- }
- delete options;
- return;
- }
-
- Item *const item = inventory->findItemByTag(index);
- if (item == nullptr)
- {
- const int slot = inventory->addItem(itemId,
- itemType,
- amount,
- refine,
- ItemColorManager::getColorFromCards(&cards[0]),
- fromBool(identify, Identified),
- damaged,
- Favorite_false,
- Equipm_false,
- Equipped_false);
- if (slot == -1)
- {
- delete options;
- return;
- }
- inventory->setCards(slot, cards, maxCards);
- inventory->setOptions(slot, options);
- inventory->setTag(slot, index);
- }
- else
- {
- item->increaseQuantity(amount);
- }
-
- mailEditWindow->updateItems();
- delete options;
-}
-
-void Mail2Recv::processRemoveItemResult(Net::MessageIn &msg)
-{
- const int result = msg.readUInt8("result");
- const int index = msg.readInt16("index") - INVENTORY_OFFSET;
- const int amount = msg.readInt16("count");
- msg.readInt16("weight");
-
- if (result == 0)
- {
- const Inventory *const inv = PlayerInfo::getInventory();
- if (inv == nullptr)
- {
- reportAlways("Player inventory not exists");
- return;
- }
- std::string itemName;
- const Item *const item = inv->getItem(index);
- if (item != nullptr)
- {
- itemName = item->getName();
- }
- else
- {
- // TRANSLATORS: unknown item name
- itemName = _("Unknown item");
- }
-
- NotifyManager::notify(
- NotifyTypes::MAIL_REMOVE_ITEM_ERROR,
- itemName);
- return;
- }
- if (mailEditWindow == nullptr)
- {
- reportAlways("Mail edit window not created");
- return;
- }
- Inventory *const inventory = mailEditWindow->getInventory();
- if (inventory == nullptr)
- {
- reportAlways("Mail edit window inventory not exists");
- return;
- }
- const int index2 = inventory->findIndexByTag(index);
- if (index2 == -1)
- {
- reportAlways("Item not exists in mail edit window.");
- return;
- }
- Item *const item = inventory->getItem(index2);
- if (item == nullptr)
- {
- reportAlways("Item not exists.");
- return;
- }
-
- item->increaseQuantity(-amount);
- mailEditWindow->updateItems();
-}
-
-void Mail2Recv::processCheckNameResult(Net::MessageIn &msg)
-{
- const int charId = msg.readInt32("char id");
- msg.readInt16("class");
- msg.readInt16("level");
- if (msg.getVersion() >= 20160316)
- msg.readString(24, "name");
- // +++ in future if name received, need use it in map
- if (mMailQueue.empty())
- {
- reportAlways("Mail2Recv::processCheckNameResult no names in queue."
- "Char id: %d", charId);
- return;
- }
- MailQueue *const mail = mMailQueue.front();
- mMailQueue.pop();
- if (charId == 0)
- {
- NotifyManager::notify(NotifyTypes::MAIL_NAME_VALIDATION_ERROR,
- mail->to);
- delete mail;
- return;
- }
- mCheckedName = mail->to;
- switch (mail->type)
- {
- case MailQueueType::SendMail:
- mail2Handler->sendMail(mail->to,
- mail->title,
- mail->body,
- mail->money);
- break;
- case MailQueueType::EditMail:
- if (mailWindow == nullptr)
- {
- reportAlways("Mail window not created");
- }
- else
- {
- mailWindow->createMail(mail->to);
- }
- break;
- case MailQueueType::ValidateTo:
- if (mailEditWindow == nullptr)
- {
- reportAlways("Mail edit window not created");
- }
- else
- {
- mailEditWindow->validatedTo();
- }
- break;
- case MailQueueType::Unknown:
- default:
- reportAlways("Not implemented yet.");
- break;
- }
- delete mail;
-}
-
-void Mail2Recv::processSendResult(Net::MessageIn &msg)
-{
- const int res = msg.readUInt8("result");
- switch (res)
- {
- case 0:
- NotifyManager::notify(NotifyTypes::MAIL_SEND_OK);
- if (mailEditWindow != nullptr)
- mailEditWindow->close();
- break;
- case 1:
- NotifyManager::notify(NotifyTypes::MAIL_SEND_FATAL_ERROR);
- break;
- case 2:
- NotifyManager::notify(NotifyTypes::MAIL_SEND_COUNT_ERROR);
- break;
- case 3:
- NotifyManager::notify(NotifyTypes::MAIL_SEND_ITEM_ERROR);
- break;
- case 4:
- NotifyManager::notify(NotifyTypes::MAIL_SEND_RECEIVER_ERROR);
- break;
- default:
- NotifyManager::notify(NotifyTypes::MAIL_SEND_ERROR);
- break;
- }
-}
-
-void Mail2Recv::processMailListPage(Net::MessageIn &msg)
-{
- if (mailWindow == nullptr)
- {
- reportAlways("mail window not created");
- return;
- }
- msg.readInt16("len");
- mailWindow->setOpenType(fromInt(msg.readUInt8("open type"),
- MailOpenTypeT));
- const int cnt = msg.readUInt8("cnt");
- const bool isEnd = msg.readUInt8("isEnd") != 0;
- for (int f = 0; f < cnt; f ++)
- {
- MailMessage *const mail = new MailMessage;
- mail->id = msg.readInt64("mail id");
- mail->read = msg.readUInt8("is read") != 0U ? true : false;
- mail->type = static_cast<MailMessageType::Type>(
- msg.readUInt8("type"));
- mail->sender = msg.readString(24, "sender name");
- mail->time = CAST_S32(cur_time - msg.readInt32("reg time"));
- mail->strTime = timeToStr(mail->time);
- mail->expireTime = msg.readInt32("expire time");
- mail->title = msg.readString(-1, "title");
- mailWindow->addMail(mail);
- }
- if (isEnd)
- mailWindow->setLastPage();
-}
-
-void Mail2Recv::processReadMail(Net::MessageIn &msg)
-{
- msg.readInt16("len");
- const MailOpenTypeT openType = static_cast<MailOpenTypeT>(
- msg.readUInt8("open type"));
- const int64_t mailId = msg.readInt64("mail id");
- const int textLen = msg.readInt16("text len");
- const int64_t money = msg.readInt64("money");
- const int itemsCount = msg.readUInt8("item count");
- const std::string text = msg.readString(textLen, "text message");
- MailMessage *mail = nullptr;
-
- if (mailWindow != nullptr &&
- openType == mailWindow->getOpenType())
- {
- mail = mailWindow->findMail(mailId);
- }
-
- if (mail == nullptr)
- {
- reportAlways("Mail message not found");
- for (int f = 0; f < itemsCount; f ++)
- {
- msg.readInt16("amount");
- msg.readInt16("item id");
- msg.readUInt8("identify");
- msg.readUInt8("damaged");
- msg.readUInt8("refine");
- for (int d = 0; d < maxCards; d ++)
- msg.readUInt16("card");
- msg.readInt32("unknown");
- msg.readUInt8("type");
- msg.readInt32("unknown");
- for (int d = 0; d < 5; d ++)
- {
- msg.readInt16("option index");
- msg.readInt16("option value");
- msg.readUInt8("option param");
- }
- }
- return;
- }
-
- mail->money = money;
- mail->text = text;
- mailWindow->showMessage(mail, itemsCount);
-
- Inventory *const inventory = mailViewWindow->getInventory();
-
- for (int f = 0; f < itemsCount; f ++)
- {
- // server may send wrong items count, if items was removed from mail
- if (msg.getUnreadLength() == 0)
- break;
- const int amount = msg.readInt16("amount");
- const int itemId = msg.readInt16("item id");
- const uint8_t identify = msg.readUInt8("identify");
- const Damaged damaged = fromBool(msg.readUInt8("attribute"), Damaged);
- const uint8_t refine = msg.readUInt8("refine");
- int cards[maxCards];
- for (int d = 0; d < maxCards; d ++)
- cards[d] = msg.readUInt16("card");
- msg.readInt32("unknown");
- const ItemTypeT itemType = static_cast<ItemTypeT>(
- msg.readUInt8("item type"));
- msg.readInt32("unknown");
- ItemOptionsList *options = new ItemOptionsList(5);
- for (int d = 0; d < 5; d ++)
- {
- const uint16_t idx = msg.readInt16("option index");
- const uint16_t val = msg.readInt16("option value");
- msg.readUInt8("option param");
- options->add(idx, val);
- }
-
- const int slot = inventory->addItem(itemId,
- itemType,
- amount,
- refine,
- ItemColorManager::getColorFromCards(&cards[0]),
- fromBool(identify, Identified),
- damaged,
- Favorite_false,
- Equipm_false,
- Equipped_false);
- if (slot == -1)
- {
- delete options;
- continue;
- }
- inventory->setCards(slot, cards, maxCards);
- inventory->setOptions(slot, options);
- delete options;
- }
- mailViewWindow->updateItems();
-}
-
-void Mail2Recv::processMailDelete(Net::MessageIn &msg)
-{
- msg.readUInt8("open type");
- const int64_t mailId = msg.readInt64("mail id");
- if (mailWindow == nullptr)
- {
- reportAlways("Mail window not created.");
- return;
- }
- mailWindow->removeMail(mailId);
-}
-
-void Mail2Recv::processRequestMoney(Net::MessageIn &msg)
-{
- const int64_t mailId = msg.readInt64("mail id");
- msg.readUInt8("open type");
- const int res = msg.readUInt8("result");
- switch (res)
- {
- case 0:
- NotifyManager::notify(
- NotifyTypes::MAIL_GET_MONEY_OK);
- if (mailViewWindow != nullptr)
- mailViewWindow->removeMoney(mailId);
- break;
- case 1:
- NotifyManager::notify(
- NotifyTypes::MAIL_GET_MONEY_ERROR);
- break;
- case 2:
- NotifyManager::notify(
- NotifyTypes::MAIL_GET_MONEY_LIMIT_ERROR);
- break;
- default:
- UNIMPLEMENTEDPACKETFIELD(res);
- NotifyManager::notify(
- NotifyTypes::MAIL_GET_MONEY_ERROR);
- break;
- }
-}
-
-void Mail2Recv::processRequestItems(Net::MessageIn &msg)
-{
- const int64_t mailId = msg.readInt64("mail id");
- msg.readUInt8("open type");
- const int res = msg.readUInt8("result");
- switch (res)
- {
- case 0:
- NotifyManager::notify(
- NotifyTypes::MAIL_GET_ATTACH_OK);
- if (mailViewWindow != nullptr)
- mailViewWindow->removeItems(mailId);
- break;
- case 1:
- NotifyManager::notify(
- NotifyTypes::MAIL_GET_ATTACH_ERROR);
- break;
- case 2:
- NotifyManager::notify(
- NotifyTypes::MAIL_GET_ATTACH_FULL_ERROR);
- break;
- default:
- UNIMPLEMENTEDPACKETFIELD(res);
- NotifyManager::notify(
- NotifyTypes::MAIL_GET_ATTACH_ERROR);
- break;
- }
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/mail2recv.h b/src/net/eathena/mail2recv.h
deleted file mode 100644
index e23603b8c..000000000
--- a/src/net/eathena/mail2recv.h
+++ /dev/null
@@ -1,55 +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 NET_EATHENA_MAIL2RECV_H
-#define NET_EATHENA_MAIL2RECV_H
-
-#include <string>
-#include <queue>
-
-struct MailQueue;
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-namespace EAthena
-{
- namespace Mail2Recv
- {
- extern std::queue<MailQueue*> mMailQueue;
- extern std::string mCheckedName;
-
- void processMailIcon(Net::MessageIn &msg);
- void processOpenNewMailWindow(Net::MessageIn &msg);
- void processAddItemResult(Net::MessageIn &msg);
- void processRemoveItemResult(Net::MessageIn &msg);
- void processCheckNameResult(Net::MessageIn &msg);
- void processSendResult(Net::MessageIn &msg);
- void processMailListPage(Net::MessageIn &msg);
- void processReadMail(Net::MessageIn &msg);
- void processMailDelete(Net::MessageIn &msg);
- void processRequestMoney(Net::MessageIn &msg);
- void processRequestItems(Net::MessageIn &msg);
- } // namespace Mail2Recv
-} // namespace EAthena
-
-#endif // NET_EATHENA_MAIL2RECV_H
diff --git a/src/net/eathena/mailhandler.cpp b/src/net/eathena/mailhandler.cpp
deleted file mode 100644
index 44edeb5bd..000000000
--- a/src/net/eathena/mailhandler.cpp
+++ /dev/null
@@ -1,109 +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 "net/eathena/mailhandler.h"
-
-#include "const/net/inventory.h"
-
-#include "net/eathena/messageout.h"
-#include "net/eathena/protocolout.h"
-
-#include "debug.h"
-
-namespace EAthena
-{
-
-MailHandler::MailHandler()
-{
- mailHandler = this;
-}
-
-MailHandler::~MailHandler()
-{
- mailHandler = nullptr;
-}
-
-void MailHandler::refresh() const
-{
- createOutPacket(CMSG_MAIL_REFRESH_INBOX);
-}
-
-void MailHandler::readMessage(const int msgId) const
-{
- createOutPacket(CMSG_MAIL_READ_MESSAGE);
- outMsg.writeInt32(msgId, "message id");
-}
-
-void MailHandler::getAttach(const int msgId) const
-{
- createOutPacket(CMSG_MAIL_GET_ATTACH);
- outMsg.writeInt32(msgId, "message id");
-}
-
-void MailHandler::deleteMessage(const int msgId) const
-{
- createOutPacket(CMSG_MAIL_DELETE_MESSAGE);
- outMsg.writeInt32(msgId, "message id");
-}
-
-void MailHandler::returnMessage(const int msgId) const
-{
- createOutPacket(CMSG_MAIL_RETURN_MESSAGE);
- outMsg.writeInt32(msgId, "message id");
- outMsg.writeString("", 24, "unused");
-}
-
-void MailHandler::setAttach(const int index, const int amount) const
-{
- createOutPacket(CMSG_MAIL_SET_ATTACH);
- outMsg.writeInt16(CAST_S16(index + INVENTORY_OFFSET), "index");
- outMsg.writeInt32(amount, "amount");
-}
-
-void MailHandler::setAttachMoney(const int money) const
-{
- createOutPacket(CMSG_MAIL_SET_ATTACH);
- outMsg.writeInt16(CAST_S16(0), "index");
- outMsg.writeInt32(money, "money");
-}
-
-void MailHandler::resetAttach(const int flag) const
-{
- createOutPacket(CMSG_MAIL_RESET_ATTACH);
- outMsg.writeInt16(CAST_S16(flag), "flag");
-}
-
-void MailHandler::send(const std::string &name,
- const std::string &title,
- std::string message) const
-{
- if (message.size() > 255)
- message = message.substr(0, 255);
- const int sz = CAST_S32(message.size());
-
- createOutPacket(CMSG_MAIL_SEND);
- outMsg.writeInt16(CAST_S16(69 + sz), "len");
- outMsg.writeString(name, 24, "name");
- outMsg.writeString(title, 40, "title");
- outMsg.writeInt8(CAST_S8(sz), "message size");
- outMsg.writeString(message, sz, "message");
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/mailhandler.h b/src/net/eathena/mailhandler.h
deleted file mode 100644
index 4d55238a6..000000000
--- a/src/net/eathena/mailhandler.h
+++ /dev/null
@@ -1,61 +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 NET_EATHENA_MAILHANDLER_H
-#define NET_EATHENA_MAILHANDLER_H
-
-#include "net/mailhandler.h"
-
-namespace EAthena
-{
-
-class MailHandler final : public Net::MailHandler
-{
- public:
- MailHandler();
-
- A_DELETE_COPY(MailHandler)
-
- ~MailHandler();
-
- void refresh() const override final;
-
- void readMessage(const int msgId) const override final;
-
- void getAttach(const int msgId) const override final;
-
- void deleteMessage(const int msgId) const override final;
-
- void returnMessage(const int msgId) const override final;
-
- void setAttach(const int index, const int amount) const override final;
-
- void setAttachMoney(const int money) const override final;
-
- void resetAttach(const int flag) const override final;
-
- void send(const std::string &name,
- const std::string &title,
- std::string message) const override final;
-};
-
-} // namespace EAthena
-
-#endif // NET_EATHENA_MAILHANDLER_H
diff --git a/src/net/eathena/mailrecv.cpp b/src/net/eathena/mailrecv.cpp
deleted file mode 100644
index de7945a7d..000000000
--- a/src/net/eathena/mailrecv.cpp
+++ /dev/null
@@ -1,251 +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 "net/eathena/mailrecv.h"
-
-#include "itemcolormanager.h"
-#include "notifymanager.h"
-
-#include "const/resources/item/cards.h"
-
-#include "enums/resources/notifytypes.h"
-
-#include "gui/mailmessage.h"
-
-#include "gui/windows/mailviewwindow.h"
-#include "gui/windows/mailwindow.h"
-
-#include "net/mailhandler.h"
-#include "net/messagein.h"
-
-#include "utils/checkutils.h"
-#include "utils/gettext.h"
-#include "utils/stringutils.h"
-
-#include "resources/inventory/inventory.h"
-
-#include "debug.h"
-
-namespace EAthena
-{
-
-void MailRecv::processMailOpen(Net::MessageIn &msg)
-{
- const int flag = msg.readInt32("flag");
- switch (flag)
- {
- case 0: // open window
- if (mailWindow != nullptr)
- {
- if (!mailWindow->isWindowVisible())
- mailWindow->setVisible(Visible_true);
- mailWindow->requestMoveToTop();
- }
- break;
-
- case 1: // close window
- if (mailWindow != nullptr)
- {
- if (mailWindow->isWindowVisible())
- mailWindow->setVisible(Visible_false);
- }
- break;
-
- default:
- UNIMPLEMENTEDPACKETFIELD(flag);
- break;
- }
-}
-
-void MailRecv::processMailList(Net::MessageIn &msg)
-{
- const int count = (msg.readInt16("len") - 8) / 73;
- const int amount = msg.readInt32("amount");
- if (count != amount)
- logger->log("error: wrong mails count");
- mailWindow->clear();
- for (int f = 0; f < count; f ++)
- {
- MailMessage *const mail = new MailMessage;
- mail->id = msg.readInt32("message id");
- mail->title = msg.readString(40, "title");
- mail->read = msg.readUInt8("unread flag") != 0u ? true : false;
- mail->sender = msg.readString(24, "sender name");
- mail->time = msg.readInt32("time stamp");
- mail->strTime = timeToStr(mail->time);
- mailWindow->addMail(mail);
- }
-}
-
-void MailRecv::processReadMail(Net::MessageIn &msg)
-{
- const int sz = msg.readInt16("len") - 101;
- MailMessage *const mail = new MailMessage;
- mail->id = msg.readInt32("message id");
- mail->title = msg.readString(40, "title");
- mail->sender = msg.readString(24, "sender name");
- msg.readInt32("unused");
- mail->money = msg.readInt32("money");
-
- const int amount = msg.readInt32("item amount");
- const int itemId = msg.readInt16("item id");
- const ItemTypeT itemType = static_cast<ItemTypeT>(
- msg.readInt16("item type"));
- const uint8_t identify = msg.readUInt8("identify");
- const Damaged damaged = fromBool(msg.readUInt8("attribute"), Damaged);
- const uint8_t refine = msg.readUInt8("refine");
- int cards[maxCards];
- for (int d = 0; d < maxCards; d ++)
- cards[d] = msg.readUInt16("card");
- const int msgLen = msg.readUInt8("msg len");
- if (msgLen != sz)
- logger->log("error: wrong message size");
- mail->text = msg.readString(sz, "message");
- msg.readUInt8("zero");
- mail->strTime = timeToStr(mail->time);
- if (mailWindow == nullptr)
- {
- reportAlways("Mail window not created");
- delete mail;
- return;
- }
- mailWindow->showMessage(mail, itemId != 0 ? 1 : 0);
- if (mailViewWindow == nullptr)
- {
- reportAlways("Mail view window not created");
- return;
- }
-
- Inventory *const inventory = mailViewWindow->getInventory();
- if (inventory == nullptr)
- {
- reportAlways("Mail view window missing inventory");
- return;
- }
-
- const int slot = inventory->addItem(itemId,
- itemType,
- amount,
- refine,
- ItemColorManager::getColorFromCards(&cards[0]),
- fromBool(identify, Identified),
- damaged,
- Favorite_false,
- Equipm_false,
- Equipped_false);
- if (slot != -1)
- inventory->setCards(slot, cards, maxCards);
-
- mailViewWindow->updateItems();
-}
-
-void MailRecv::processGetAttachment(Net::MessageIn &msg)
-{
- const uint8_t flag = msg.readUInt8("flag");
- switch (flag)
- {
- case 0:
- NotifyManager::notify(NotifyTypes::MAIL_GET_ATTACH_OK);
- break;
- case 1:
- NotifyManager::notify(NotifyTypes::MAIL_GET_ATTACH_ERROR);
- break;
- case 2:
- NotifyManager::notify(NotifyTypes::MAIL_GET_ATTACH_TOO_MANY_ITEMS);
- break;
- default:
- UNIMPLEMENTEDPACKETFIELD(flag);
- break;
- }
-}
-
-void MailRecv::processSendMailAck(Net::MessageIn &msg)
-{
- const uint8_t flag = msg.readUInt8("fail flag");
- switch (flag)
- {
- case 0:
- NotifyManager::notify(NotifyTypes::MAIL_SEND_OK);
- break;
- case 1:
- NotifyManager::notify(NotifyTypes::MAIL_SEND_ERROR);
- break;
- default:
- UNIMPLEMENTEDPACKETFIELD(flag);
- break;
- }
-}
-
-void MailRecv::processNewMail(Net::MessageIn &msg)
-{
- msg.readInt32("message id");
- const std::string subj = msg.readString(40, "title");
- const std::string sender = msg.readString(24, "sender name");
- NotifyManager::notify(NotifyTypes::NEW_MAIL,
- // TRANSLATORS: mail message notification
- strprintf(_("You have new mail from %s with subject %s"),
- sender.c_str(), subj.c_str()));
- mailHandler->refresh();
-}
-
-void MailRecv::processSetAttachmentAck(Net::MessageIn &msg)
-{
- const int index = msg.readInt16("index");
- const int flag = msg.readUInt8("flag");
- if (flag != 0)
- {
- if (index != 0)
- NotifyManager::notify(NotifyTypes::MAIL_ATTACH_ITEM_ERROR);
- else
- NotifyManager::notify(NotifyTypes::MAIL_ATTACH_MONEY_ERROR);
- }
-}
-
-void MailRecv::processDeleteAck(Net::MessageIn &msg)
-{
- const int mail = msg.readInt32("message id");
- const int flag = msg.readInt16("fail flag");
- if (flag != 0)
- {
- NotifyManager::notify(NotifyTypes::MAIL_DELETE_ERROR);
- }
- else
- {
- NotifyManager::notify(NotifyTypes::MAIL_DELETE_OK);
- mailWindow->removeMail(mail);
- }
-}
-
-void MailRecv::processMailReturn(Net::MessageIn &msg)
-{
- const int mail = msg.readInt32("message id");
- const int flag = msg.readInt16("fail flag");
- if (flag != 0)
- {
- NotifyManager::notify(NotifyTypes::MAIL_RETURN_ERROR);
- }
- else
- {
- NotifyManager::notify(NotifyTypes::MAIL_RETURN_OK);
- mailWindow->removeMail(mail);
- }
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/mailrecv.h b/src/net/eathena/mailrecv.h
deleted file mode 100644
index 8f56f5a9f..000000000
--- a/src/net/eathena/mailrecv.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 NET_EATHENA_MAILRECV_H
-#define NET_EATHENA_MAILRECV_H
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-namespace EAthena
-{
- namespace MailRecv
- {
- void processMailOpen(Net::MessageIn &msg);
- void processMailList(Net::MessageIn &msg);
- void processReadMail(Net::MessageIn &msg);
- void processGetAttachment(Net::MessageIn &msg);
- void processSendMailAck(Net::MessageIn &msg);
- void processNewMail(Net::MessageIn &msg);
- void processSetAttachmentAck(Net::MessageIn &msg);
- void processDeleteAck(Net::MessageIn &msg);
- void processMailReturn(Net::MessageIn &msg);
- } // namespace MailRecv
-} // namespace EAthena
-
-#endif // NET_EATHENA_MAILRECV_H
diff --git a/src/net/eathena/maphandler.cpp b/src/net/eathena/maphandler.cpp
deleted file mode 100644
index b16fc664f..000000000
--- a/src/net/eathena/maphandler.cpp
+++ /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/>.
- */
-
-#include "net/eathena/maphandler.h"
-
-#include "debug.h"
-
-namespace EAthena
-{
-
-MapHandler::MapHandler() :
- Net::MapHandler()
-{
- mapHandler = this;
-}
-
-MapHandler::~MapHandler()
-{
- mapHandler = nullptr;
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/maphandler.h b/src/net/eathena/maphandler.h
deleted file mode 100644
index 855ec4da7..000000000
--- a/src/net/eathena/maphandler.h
+++ /dev/null
@@ -1,41 +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 NET_EATHENA_MAPHANDLER_H
-#define NET_EATHENA_MAPHANDLER_H
-
-#include "net/maphandler.h"
-
-namespace EAthena
-{
-
-class MapHandler final : public Net::MapHandler
-{
- public:
- MapHandler();
-
- A_DELETE_COPY(MapHandler)
-
- ~MapHandler();
-};
-
-} // namespace EAthena
-
-#endif // NET_EATHENA_MAPHANDLER_H
diff --git a/src/net/eathena/maprecv.cpp b/src/net/eathena/maprecv.cpp
deleted file mode 100644
index cc079feba..000000000
--- a/src/net/eathena/maprecv.cpp
+++ /dev/null
@@ -1,68 +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 "net/eathena/maprecv.h"
-
-#include "logger.h"
-
-#include "net/messagein.h"
-
-#include "debug.h"
-
-namespace EAthena
-{
-
-void MapRecv::processInstanceStart(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readString(61, "instance name");
- msg.readInt16("flag");
-}
-
-void MapRecv::processInstanceCreate(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readInt16("flag");
-}
-
-void MapRecv::processInstanceInfo(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readString(61, "instance name");
- msg.readInt32("remaining time");
- msg.readInt32("no players close time");
-}
-
-void MapRecv::processInstanceDelete(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readInt32("flag");
- msg.readInt32("unused");
-}
-
-void MapRecv::processAddMapMarker(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readBeingId("account id");
- msg.readInt16("x");
- msg.readInt16("y");
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/maprecv.h b/src/net/eathena/maprecv.h
deleted file mode 100644
index d9fffc8a2..000000000
--- a/src/net/eathena/maprecv.h
+++ /dev/null
@@ -1,41 +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 NET_EATHENA_MAPRECV_H
-#define NET_EATHENA_MAPRECV_H
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-namespace EAthena
-{
- namespace MapRecv
- {
- void processInstanceStart(Net::MessageIn &msg);
- void processInstanceCreate(Net::MessageIn &msg);
- void processInstanceInfo(Net::MessageIn &msg);
- void processInstanceDelete(Net::MessageIn &msg);
- void processAddMapMarker(Net::MessageIn &msg);
- } // namespace MapRecv
-} // namespace EAthena
-
-#endif // NET_EATHENA_MAPRECV_H
diff --git a/src/net/eathena/maptypeproperty2.h b/src/net/eathena/maptypeproperty2.h
deleted file mode 100644
index 2bc235798..000000000
--- a/src/net/eathena/maptypeproperty2.h
+++ /dev/null
@@ -1,55 +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 NET_EATHENA_MAPTYPEPROPERTY2_H
-#define NET_EATHENA_MAPTYPEPROPERTY2_H
-
-#include "localconsts.h"
-
-namespace EAthena
-{
- struct MapTypeProperty2Bits final
- {
- A_DEFAULT_COPY(MapTypeProperty2Bits)
-
- uint32_t party : 1; // allow attack party members (PvP)
- uint32_t guild : 1; // allow attack guild members (GvG)
- uint32_t siege : 1; // show emblem in GvG (WoE castle)
- uint32_t mineffect : 1; // mine effect?
- uint32_t nolockon : 1; // unknown
- uint32_t countpk : 1; // show PvP counter
- uint32_t nopartyformation : 1; // prevent party creation/
- // modification
- uint32_t bg : 1; // is on battle ground
- uint32_t noitemconsumption : 1; // unused
- uint32_t usecart : 1; // unused
- uint32_t summonstarmiracle : 1; // unused
- uint32_t SpareBits : 15; // unused bits
- } __attribute__((packed));
-
- union MapTypeProperty2 final
- {
- MapTypeProperty2Bits bits;
- uint32_t data;
- } __attribute__((packed));
-
-} // namespace EAthena
-
-#endif // NET_EATHENA_MAPTYPEPROPERTY2_H
diff --git a/src/net/eathena/markethandler.cpp b/src/net/eathena/markethandler.cpp
deleted file mode 100644
index 46bf44027..000000000
--- a/src/net/eathena/markethandler.cpp
+++ /dev/null
@@ -1,145 +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 "net/eathena/markethandler.h"
-
-#include "net/eathena/marketrecv.h"
-#include "net/eathena/messageout.h"
-#include "net/eathena/protocolout.h"
-
-#include "utils/foreach.h"
-
-#include "resources/item/shopitem.h"
-
-#include "debug.h"
-
-extern int packetVersion;
-
-namespace EAthena
-{
-
-MarketHandler::MarketHandler() :
- Net::MarketHandler()
-{
- marketHandler = this;
- MarketRecv::mBuyDialog = nullptr;
-}
-
-MarketHandler::~MarketHandler()
-{
- marketHandler = nullptr;
-}
-
-void MarketHandler::close() const
-{
- if (packetVersion < 20131218)
- return;
-
- createOutPacket(CMSG_NPC_MARKET_CLOSE);
-}
-
-void MarketHandler::buyItem(const int itemId,
- const ItemTypeT type,
- const ItemColor color A_UNUSED,
- const int amount) const
-{
- if (packetVersion < 20131218)
- return;
- const bool nonStack = type == ItemType::Weapon ||
- type == ItemType::Armor ||
- type == ItemType::PetEgg ||
- type == ItemType::PetArmor;
- int cnt = nonStack ? amount : 1;
- const int amount2 = nonStack ? 1 : amount;
- if (cnt > 100)
- cnt = 100;
-
- createOutPacket(CMSG_NPC_MARKET_BUY);
- outMsg.writeInt16(CAST_S16(4 + 6 * cnt), "len");
- for (int f = 0; f < cnt; f ++)
- {
- outMsg.writeInt16(CAST_S16(itemId), "item id");
- outMsg.writeInt32(CAST_S16(amount2), "amount");
- }
-}
-
-void MarketHandler::buyItems(const STD_VECTOR<ShopItem*> &items) const
-{
- if (packetVersion < 20131218)
- return;
- int cnt = 0;
- const int pairSize = 6;
-
- FOR_EACH (STD_VECTOR<ShopItem*>::const_iterator, it, items)
- {
- const ShopItem *const item = *it;
- const int usedQuantity = item->getUsedQuantity();
- const ItemTypeT type = item->getType();
- if (usedQuantity == 0)
- continue;
- if (type == ItemType::Weapon ||
- type == ItemType::Armor ||
- type == ItemType::PetEgg ||
- type == ItemType::PetArmor)
- {
- cnt += item->getUsedQuantity();
- }
- else
- {
- cnt ++;
- }
- }
-
- if (cnt > 100)
- return;
-
- createOutPacket(CMSG_NPC_MARKET_BUY);
- outMsg.writeInt16(CAST_S16(4 + pairSize * cnt), "len");
- FOR_EACH (STD_VECTOR<ShopItem*>::const_iterator, it, items)
- {
- ShopItem *const item = *it;
- const int usedQuantity = item->getUsedQuantity();
- if (usedQuantity == 0)
- continue;
- item->increaseQuantity(usedQuantity);
- item->increaseUsedQuantity(-usedQuantity);
- item->update();
- const ItemTypeT type = item->getType();
- if (type == ItemType::Weapon ||
- type == ItemType::Armor ||
- type == ItemType::PetEgg ||
- type == ItemType::PetArmor)
- {
- for (int f = 0; f < usedQuantity; f ++)
- {
- outMsg.writeInt16(CAST_S16(item->getId()),
- "item id");
- outMsg.writeInt32(CAST_S16(1), "amount");
- }
- }
- else
- {
- outMsg.writeInt16(CAST_S16(item->getId()), "item id");
- outMsg.writeInt32(CAST_S16(usedQuantity), "amount");
- }
- }
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/markethandler.h b/src/net/eathena/markethandler.h
deleted file mode 100644
index c06018c0b..000000000
--- a/src/net/eathena/markethandler.h
+++ /dev/null
@@ -1,51 +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 NET_EATHENA_MARKETHANDLER_H
-#define NET_EATHENA_MARKETHANDLER_H
-
-#include "net/markethandler.h"
-
-namespace EAthena
-{
-
-class MarketHandler final : public Net::MarketHandler
-{
- public:
- MarketHandler();
-
- A_DELETE_COPY(MarketHandler)
-
- ~MarketHandler();
-
- void close() const override final;
-
- void buyItem(const int itemId,
- const ItemTypeT type,
- const ItemColor color,
- const int amount) const override final;
-
- void buyItems(const STD_VECTOR<ShopItem*> &items) const
- override final;
-};
-
-} // namespace EAthena
-
-#endif // NET_EATHENA_MARKETHANDLER_H
diff --git a/src/net/eathena/marketrecv.cpp b/src/net/eathena/marketrecv.cpp
deleted file mode 100644
index 8563c67ca..000000000
--- a/src/net/eathena/marketrecv.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 "net/eathena/marketrecv.h"
-
-#include "notifymanager.h"
-
-#include "being/playerinfo.h"
-
-#include "const/resources/currency.h"
-
-#include "enums/resources/notifytypes.h"
-
-#include "gui/windows/buydialog.h"
-
-#include "gui/widgets/createwidget.h"
-
-#include "net/messagein.h"
-
-#include "net/eathena/npcrecv.h"
-
-#include "resources/beinginfo.h"
-
-#include "resources/db/npcdb.h"
-
-#include "debug.h"
-
-namespace EAthena
-{
-
-namespace MarketRecv
-{
- BuyDialog *mBuyDialog = nullptr;
-} // namespace MarketRecv
-
-
-void MarketRecv::processMarketOpen(Net::MessageIn &msg)
-{
- const int len = (msg.readInt16("len") - 4) / 13;
-
- const BeingTypeId npcId = NpcRecv::mNpcTypeId;
- std::string currency;
-
- if (npcId != BeingTypeId_zero)
- {
- const BeingInfo *const info = NPCDB::get(npcId);
- if (info != nullptr)
- currency = info->getCurrency();
- else
- currency = DEFAULT_CURRENCY;
- }
- else
- {
- currency = DEFAULT_CURRENCY;
- }
-
- CREATEWIDGETV(mBuyDialog, BuyDialog,
- fromInt(BuyDialog::Market, BeingId),
- currency);
- mBuyDialog->setMoney(PlayerInfo::getAttribute(Attributes::MONEY));
-
- for (int f = 0; f < len; f ++)
- {
- const int itemId = msg.readInt16("item id");
- const ItemTypeT type = static_cast<ItemTypeT>(msg.readUInt8("type"));
- const int value = msg.readInt32("price");
- const int amount = msg.readInt32("amount");
- msg.readInt16("view");
- const ItemColor color = ItemColor_one;
- mBuyDialog->addItem(itemId, type, color, amount, value);
- }
- mBuyDialog->sort();
-}
-
-void MarketRecv::processMarketBuyAck(Net::MessageIn &msg)
-{
- const int len = (msg.readInt16("len") - 5) / 8;
- const int res = msg.readUInt8("result");
- for (int f = 0; f < len; f ++)
- {
- msg.readInt16("item id");
- msg.readInt16("amount");
- msg.readInt32("price");
- }
- if (res != 0)
- NotifyManager::notify(NotifyTypes::BUY_DONE);
- else
- NotifyManager::notify(NotifyTypes::BUY_FAILED);
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/marketrecv.h b/src/net/eathena/marketrecv.h
deleted file mode 100644
index a75491967..000000000
--- a/src/net/eathena/marketrecv.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 NET_EATHENA_MARKETRECV_H
-#define NET_EATHENA_MARKETRECV_H
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-class BuyDialog;
-
-namespace EAthena
-{
- namespace MarketRecv
- {
- extern BuyDialog *mBuyDialog;
-
- void processMarketOpen(Net::MessageIn &msg);
- void processMarketBuyAck(Net::MessageIn &msg);
- } // namespace MarketRecv
-} // namespace EAthena
-
-#endif // NET_EATHENA_MARKETRECV_H
diff --git a/src/net/eathena/menu.cpp b/src/net/eathena/menu.cpp
deleted file mode 100644
index 5fb14157e..000000000
--- a/src/net/eathena/menu.cpp
+++ /dev/null
@@ -1,28 +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 "enums/net/menutype.h"
-
-#include "debug.h"
-
-namespace EAthena
-{
- MenuTypeT menu = MenuType::Unknown;
-} // namespace EAthena
diff --git a/src/net/eathena/menu.h b/src/net/eathena/menu.h
deleted file mode 100644
index 0ed10da79..000000000
--- a/src/net/eathena/menu.h
+++ /dev/null
@@ -1,31 +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 NET_EATHENA_MENU_H
-#define NET_EATHENA_MENU_H
-
-#include "enums/net/menutype.h"
-
-namespace EAthena
-{
- extern MenuTypeT menu;
-} // namespace EAthena
-
-#endif // NET_EATHENA_MENU_H
diff --git a/src/net/eathena/mercenaryhandler.cpp b/src/net/eathena/mercenaryhandler.cpp
deleted file mode 100644
index ffb1b5b2c..000000000
--- a/src/net/eathena/mercenaryhandler.cpp
+++ /dev/null
@@ -1,121 +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 "net/eathena/mercenaryhandler.h"
-
-#include "being/playerinfo.h"
-
-#include "net/serverfeatures.h"
-
-#include "net/eathena/messageout.h"
-#include "net/eathena/protocolout.h"
-
-#include "debug.h"
-
-namespace EAthena
-{
-
-MercenaryHandler::MercenaryHandler()
-{
- mercenaryHandler = this;
-}
-
-MercenaryHandler::~MercenaryHandler()
-{
- mercenaryHandler = nullptr;
-}
-
-void MercenaryHandler::fire() const
-{
- createOutPacket(CMSG_MERCENARY_ACTION);
- outMsg.writeInt8(2, "action"); // delete
-}
-
-void MercenaryHandler::moveToMaster() const
-{
- const BeingId id = PlayerInfo::getMercenaryId();
- if (id == BeingId_zero)
- return;
- createOutPacket(CMSG_HOMMERC_MOVE_TO_MASTER);
- outMsg.writeBeingId(id, "mercenary id");
-}
-
-void MercenaryHandler::move(const int x, const int y) const
-{
- const BeingId id = PlayerInfo::getMercenaryId();
- if (id == BeingId_zero)
- return;
- createOutPacket(CMSG_HOMMERC_MOVE_TO);
- outMsg.writeBeingId(id, "mercenary id");
- outMsg.writeCoordinates(CAST_U16(x),
- CAST_U16(y),
- 1U, "position");
-}
-
-void MercenaryHandler::attack(const BeingId targetId,
- const Keep keep) const
-{
- const BeingId id = PlayerInfo::getMercenaryId();
- if (id == BeingId_zero)
- return;
- createOutPacket(CMSG_HOMMERC_ATTACK);
- outMsg.writeBeingId(id, "mercenary id");
- outMsg.writeBeingId(targetId, "target id");
- outMsg.writeInt8(CAST_S8(keep == Keep_true ? 1 : 0), "keep");
-}
-
-void MercenaryHandler::talk(const std::string &restrict text) const
-{
- if (!serverFeatures->haveMovePet())
- return;
- if (text.empty())
- return;
- std::string msg = text;
- if (msg.size() > 500)
- msg = msg.substr(0, 500);
- const size_t sz = msg.size();
-
- createOutPacket(CMSG_HOMMERC_TALK);
- outMsg.writeInt16(CAST_S16(sz + 4 + 1), "len");
- outMsg.writeString(msg, CAST_S32(sz), "message");
- outMsg.writeInt8(0, "zero byte");
-}
-
-void MercenaryHandler::emote(const uint8_t emoteId) const
-{
- if (!serverFeatures->haveMovePet())
- return;
- createOutPacket(CMSG_HOMMERC_EMOTE);
- outMsg.writeInt8(emoteId, "emote id");
-}
-
-void MercenaryHandler::setDirection(const unsigned char type) const
-{
- if (!serverFeatures->haveMovePet())
- return;
- createOutPacket(CMSG_HOMMERC_DIRECTION);
- outMsg.writeInt32(0, "pet id");
- outMsg.writeInt8(0, "head direction");
- outMsg.writeInt8(0, "unused");
- outMsg.writeInt8(MessageOut::toServerDirection(type),
- "pet direction");
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/mercenaryhandler.h b/src/net/eathena/mercenaryhandler.h
deleted file mode 100644
index bd5e06b14..000000000
--- a/src/net/eathena/mercenaryhandler.h
+++ /dev/null
@@ -1,55 +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 NET_EATHENA_MERCENARYHANDLER_H
-#define NET_EATHENA_MERCENARYHANDLER_H
-
-#include "net/mercenaryhandler.h"
-
-namespace EAthena
-{
-class MercenaryHandler final : public Net::MercenaryHandler
-{
- public:
- MercenaryHandler();
-
- A_DELETE_COPY(MercenaryHandler)
-
- ~MercenaryHandler();
-
- void fire() const override final;
-
- void moveToMaster() const override final;
-
- void move(const int x, const int y) const override final;
-
- void attack(const BeingId targetId,
- const Keep keep) const override final;
-
- void talk(const std::string &restrict text) const override final;
-
- void emote(const uint8_t emoteId) const override final;
-
- void setDirection(const unsigned char type) const override final;
-};
-
-} // namespace EAthena
-
-#endif // NET_EATHENA_MERCENARYHANDLER_H
diff --git a/src/net/eathena/mercenaryrecv.cpp b/src/net/eathena/mercenaryrecv.cpp
deleted file mode 100644
index 457045e5b..000000000
--- a/src/net/eathena/mercenaryrecv.cpp
+++ /dev/null
@@ -1,194 +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 "net/eathena/mercenaryrecv.h"
-
-#include "actormanager.h"
-#include "notifymanager.h"
-
-#include "being/localplayer.h"
-#include "being/mercenaryinfo.h"
-#include "being/playerinfo.h"
-
-#include "enums/resources/notifytypes.h"
-
-#include "gui/windows/skilldialog.h"
-
-#include "net/messagein.h"
-
-#include "net/eathena/sp.h"
-
-#include "utils/checkutils.h"
-
-#include "debug.h"
-
-namespace EAthena
-{
-
-#define setMercStat(sp, stat) \
- case sp: \
- PlayerInfo::setStatBase(stat, \
- val); \
- break;
-
-void MercenaryRecv::processMercenaryUpdate(Net::MessageIn &msg)
-{
- const int sp = msg.readInt16("type");
- const int val = msg.readInt32("value");
- switch (sp)
- {
- setMercStat(Sp::ATK1, Attributes::MERC_ATK);
- setMercStat(Sp::MATK1, Attributes::MERC_MATK);
- setMercStat(Sp::HIT, Attributes::MERC_HIT);
- setMercStat(Sp::CRITICAL, Attributes::MERC_CRIT);
- setMercStat(Sp::DEF1, Attributes::MERC_DEF);
- setMercStat(Sp::MDEF1, Attributes::MERC_MDEF);
- setMercStat(Sp::MERCFLEE, Attributes::MERC_FLEE);
- setMercStat(Sp::ASPD, Attributes::MERC_ATTACK_DELAY);
- setMercStat(Sp::HP, Attributes::MERC_HP);
- setMercStat(Sp::MAXHP, Attributes::MERC_MAX_HP);
- setMercStat(Sp::SP, Attributes::MERC_MP);
- setMercStat(Sp::MAXSP, Attributes::MERC_MAX_MP);
- setMercStat(Sp::MERCKILLS, Attributes::MERC_KILLS);
- setMercStat(Sp::MERCFAITH, Attributes::MERC_FAITH);
- default:
- reportAlways("Unknown mercenary stat %d",
- sp);
- break;
- }
-}
-
-void MercenaryRecv::processMercenaryInfo(Net::MessageIn &msg)
-{
- // +++ need create if need mercenary being and update stats
- Being *const dstBeing = actorManager->findBeing(
- msg.readBeingId("being id"));
- PlayerInfo::setStatBase(Attributes::MERC_ATK,
- msg.readInt16("atk"));
- PlayerInfo::setStatBase(Attributes::MERC_MATK,
- msg.readInt16("matk"));
- PlayerInfo::setStatBase(Attributes::MERC_HIT,
- msg.readInt16("hit"));
- PlayerInfo::setStatBase(Attributes::MERC_CRIT,
- msg.readInt16("crit/10"));
- PlayerInfo::setStatBase(Attributes::MERC_DEF,
- msg.readInt16("def"));
- PlayerInfo::setStatBase(Attributes::MERC_MDEF,
- msg.readInt16("mdef"));
- PlayerInfo::setStatBase(Attributes::MERC_FLEE,
- msg.readInt16("flee"));
- PlayerInfo::setStatBase(Attributes::MERC_ATTACK_DELAY,
- msg.readInt16("attack speed"));
- const std::string name = msg.readString(24, "name");
- const int level = msg.readInt16("level");
- PlayerInfo::setStatBase(Attributes::MERC_LEVEL,
- level);
- PlayerInfo::setStatBase(Attributes::MERC_HP,
- msg.readInt32("hp"));
- PlayerInfo::setStatBase(Attributes::MERC_MAX_HP,
- msg.readInt32("max hp"));
- PlayerInfo::setStatBase(Attributes::MERC_MP,
- msg.readInt32("sp"));
- PlayerInfo::setStatBase(Attributes::MERC_MAX_MP,
- msg.readInt32("max sp"));
- PlayerInfo::setStatBase(Attributes::MERC_EXPIRE,
- msg.readInt32("expire time"));
- PlayerInfo::setStatBase(Attributes::MERC_FAITH,
- msg.readInt16("faith"));
- PlayerInfo::setStatBase(Attributes::MERC_CALLS,
- msg.readInt32("calls"));
- PlayerInfo::setStatBase(Attributes::MERC_KILLS,
- msg.readInt32("kills"));
- const int range = msg.readInt16("attack range");
- PlayerInfo::setStatBase(Attributes::MERC_ATTACK_RANGE,
- range);
- PlayerInfo::updateAttrs();
-
- if ((dstBeing != nullptr) && (localPlayer != nullptr))
- {
- MercenaryInfo *const mercenary = new MercenaryInfo;
- mercenary->id = dstBeing->getId();
- mercenary->name = name;
- mercenary->level = level;
- mercenary->range = range;
- PlayerInfo::setMercenary(mercenary);
- PlayerInfo::setMercenaryBeing(dstBeing);
- }
-}
-
-void MercenaryRecv::processMercenarySkills(Net::MessageIn &msg)
-{
- if (skillDialog != nullptr)
- skillDialog->hideSkills(SkillOwner::Mercenary);
- const int count = (msg.readInt16("len") - 4) / 37;
- for (int f = 0; f < count; f ++)
- {
- const int skillId = msg.readInt16("skill id");
- const SkillType::SkillType inf = static_cast<SkillType::SkillType>(
- msg.readInt32("inf"));
- const int level = msg.readInt16("skill level");
- const int sp = msg.readInt16("sp");
- const int range = msg.readInt16("range");
- const std::string name = msg.readString(24, "skill name");
- const Modifiable up = fromBool(msg.readUInt8("up flag"), Modifiable);
- PlayerInfo::setSkillLevel(skillId, level);
- if (skillDialog != nullptr)
- {
- if (!skillDialog->updateSkill(skillId, range, up, inf, sp))
- {
- skillDialog->addSkill(SkillOwner::Mercenary,
- skillId, name, level, range, up, inf, sp);
- }
- }
- }
- if (skillDialog != nullptr)
- skillDialog->updateModels();
-}
-
-void MercenaryRecv::handleMercenaryMessage(const int cmd)
-{
- PlayerInfo::setMercenary(nullptr);
- if (skillDialog != nullptr)
- {
- skillDialog->hideSkills(SkillOwner::Mercenary);
- skillDialog->updateModels();
- }
-
- switch (cmd)
- {
- case 0:
- NotifyManager::notify(NotifyTypes::MERCENARY_EXPIRED);
- break;
- case 1:
- NotifyManager::notify(NotifyTypes::MERCENARY_KILLED);
- break;
- case 2:
- NotifyManager::notify(NotifyTypes::MERCENARY_FIRED);
- break;
- case 3:
- NotifyManager::notify(NotifyTypes::MERCENARY_RUN);
- break;
- default:
- NotifyManager::notify(NotifyTypes::MERCENARY_UNKNOWN);
- break;
- }
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/mercenaryrecv.h b/src/net/eathena/mercenaryrecv.h
deleted file mode 100644
index a18314bcd..000000000
--- a/src/net/eathena/mercenaryrecv.h
+++ /dev/null
@@ -1,40 +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 NET_EATHENA_MERCENARYRECV_H
-#define NET_EATHENA_MERCENARYRECV_H
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-namespace EAthena
-{
- namespace MercenaryRecv
- {
- void handleMercenaryMessage(const int cmd);
- void processMercenaryUpdate(Net::MessageIn &msg);
- void processMercenaryInfo(Net::MessageIn &msg);
- void processMercenarySkills(Net::MessageIn &msg);
- } // namespace MercenaryRecv
-} // namespace EAthena
-
-#endif // NET_EATHENA_MERCENARYRECV_H
diff --git a/src/net/eathena/messagein.cpp b/src/net/eathena/messagein.cpp
deleted file mode 100644
index c5cb79fda..000000000
--- a/src/net/eathena/messagein.cpp
+++ /dev/null
@@ -1,178 +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 "net/eathena/messagein.h"
-
-#include "logger.h"
-
-#include "net/net.h"
-#include "net/packetcounters.h"
-
-#include "utils/cast.h"
-#include "utils/stringutils.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"
-
-namespace EAthena
-{
-
-MessageIn::MessageIn(const char *const data,
- const unsigned int length) :
- Net::MessageIn(data, length)
-{
-}
-
-void MessageIn::postInit(const char *const str,
- const unsigned int version)
-{
- // Read the message ID
- mId = readId();
- mVersion = version;
- IGNOREDEBUGLOG;
- DEBUGLOG2("Receive packet", 0, "MessageIn");
-#ifdef ENABLEDEBUGLOG
- if (mVersion > 0)
- {
- const std::string verStr = toString(mVersion);
- DEBUGLOG2("Version", 0, verStr.c_str());
- }
-#endif // ENABLEDEBUGLOG
-
- readInt16(str);
-}
-
-uint16_t MessageIn::readId() const
-{
- int16_t value = -1;
- if (mPos + 2 <= mLength)
- {
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- int16_t swap;
- memcpy(&swap, mData + CAST_SIZE(mPos), sizeof(int16_t));
- value = SDL_Swap16(swap);
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- memcpy(&value, mData + CAST_SIZE(mPos), sizeof(int16_t));
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
- }
- return value;
-}
-
-int16_t MessageIn::readInt16(const char *const str)
-{
- int16_t value = -1;
- if (mPos + 2 <= mLength)
- {
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- int16_t swap;
- memcpy(&swap, mData + CAST_SIZE(mPos), sizeof(int16_t));
- value = SDL_Swap16(swap);
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- memcpy(&value, mData + CAST_SIZE(mPos), sizeof(int16_t));
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
- }
- DEBUGLOG2("readInt16: " + toStringPrint(CAST_U32(
- CAST_U16(value))),
- mPos, str);
- mPos += 2;
- PacketCounters::incInBytes(2);
- return value;
-}
-
-uint16_t MessageIn::readUInt16(const char *const str)
-{
- uint16_t value = 0xffU;
- if (mPos + 2 <= mLength)
- {
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- uint16_t swap;
- memcpy(&swap, mData + CAST_SIZE(mPos), sizeof(uint16_t));
- value = SDL_Swap16(swap);
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- memcpy(&value, mData + CAST_SIZE(mPos), sizeof(uint16_t));
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
- }
- DEBUGLOG2("readUInt16: " + toStringPrint(CAST_U32(
- CAST_U16(value))),
- mPos, str);
- mPos += 2;
- PacketCounters::incInBytes(2);
- return value;
-}
-
-int32_t MessageIn::readInt32(const char *const str)
-{
- int32_t value = -1;
- if (mPos + 4 <= mLength)
- {
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- int32_t swap;
- memcpy(&swap, mData + CAST_SIZE(mPos), sizeof(int32_t));
- value = SDL_Swap32(swap);
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- memcpy(&value, mData + CAST_SIZE(mPos), sizeof(int32_t));
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
- }
- DEBUGLOG2("readInt32: " + toStringPrint(CAST_U32(value)),
- mPos, str);
- mPos += 4;
- PacketCounters::incInBytes(4);
- return value;
-}
-
-BeingId MessageIn::readBeingId(const char *const str)
-{
- return fromInt(readInt32(str), BeingId);
-}
-
-int64_t MessageIn::readInt64(const char *const str)
-{
- int64_t value = -1;
- if (mPos + 8 <= mLength)
- {
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- int64_t swap;
- memcpy(&swap, mData + CAST_SIZE(mPos), sizeof(int64_t));
- value = SDL_Swap64(swap);
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- memcpy(&value, mData + CAST_SIZE(mPos), sizeof(int64_t));
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
- }
- DEBUGLOG2("readInt64: " + toStringPrint(CAST_U32(value)),
- mPos, str);
- mPos += 8;
- PacketCounters::incInBytes(8);
- return value;
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/messagein.h b/src/net/eathena/messagein.h
deleted file mode 100644
index 89fc75d4b..000000000
--- a/src/net/eathena/messagein.h
+++ /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/>.
- */
-
-#ifndef NET_EATHENA_MESSAGEIN_H
-#define NET_EATHENA_MESSAGEIN_H
-
-#include "net/messagein.h"
-
-#include "localconsts.h"
-
-namespace EAthena
-{
-
-/**
- * Used for parsing an incoming message.
- *
- * \ingroup Network
- */
-class MessageIn final : public Net::MessageIn
-{
- public:
- /**
- * Constructor.
- */
- MessageIn(const char *const data,
- const unsigned int length);
-
- A_DELETE_COPY(MessageIn)
-
- void postInit(const char *const str,
- const unsigned int version);
-
- /**< Reads a short. */
- int16_t readInt16(const char *const str) override final;
-
- uint16_t readUInt16(const char *const str) override final;
-
- /**< Reads a long. */
- int32_t readInt32(const char *const str) override final;
-
- int64_t readInt64(const char *const str) override final;
-
- BeingId readBeingId(const char *const str) override final;
-
- uint16_t readId() const;
-};
-
-} // namespace EAthena
-
-#endif // NET_EATHENA_MESSAGEIN_H
diff --git a/src/net/eathena/messageout.cpp b/src/net/eathena/messageout.cpp
deleted file mode 100644
index 78a242851..000000000
--- a/src/net/eathena/messageout.cpp
+++ /dev/null
@@ -1,150 +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 "net/eathena/messageout.h"
-
-#include "net/packetcounters.h"
-
-#include "net/eathena/network.h"
-
-#include "logger.h"
-
-#include "debug.h"
-
-#ifndef SDL_BIG_ENDIAN
-#error missing SDL_endian.h
-#endif // SDL_BYTEORDER
-
-namespace EAthena
-{
-
-MessageOut::MessageOut(const int16_t id) :
- Net::MessageOut(id),
- mNetwork(EAthena::Network::instance())
-{
- mNetwork->fixSendBuffer();
- mData = mNetwork->mOutBuffer + CAST_SIZE(mNetwork->mOutSize);
-}
-
-MessageOut::~MessageOut()
-{
- DEBUGLOG2("writeEnd: ", mPos, "position after end of packet");
-}
-
-void MessageOut::expand(const size_t bytes) const
-{
- mNetwork->mOutSize += CAST_U32(bytes);
- PacketCounters::incOutBytes(CAST_S32(bytes));
-}
-
-void MessageOut::writeInt16(const int16_t value, const char *const str)
-{
- expand(2);
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- int16_t swap = SDL_Swap16(value);
- memcpy(mData + CAST_SIZE(mPos), &swap, sizeof(int16_t));
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- memcpy(mData + CAST_SIZE(mPos), &value, sizeof(int16_t));
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- DEBUGLOG2("writeInt16: " + toStringPrint(CAST_U32(
- CAST_U16(value))),
- mPos, str);
- mPos += 2;
- PacketCounters::incOutBytes(2);
-}
-
-void MessageOut::writeInt32(const int32_t value, const char *const str)
-{
- DEBUGLOG2("writeInt32: " + toStringPrint(CAST_U32(value)),
- mPos, str);
- expand(4);
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- int32_t swap = SDL_Swap32(value);
- memcpy(mData + CAST_SIZE(mPos), &swap, sizeof(int32_t));
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- memcpy(mData + CAST_SIZE(mPos), &value, sizeof(int32_t));
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- mPos += 4;
- PacketCounters::incOutBytes(4);
-}
-
-void MessageOut::writeInt64(const int64_t value, const char *const str)
-{
- DEBUGLOG2("writeInt64: " + toStringPrint(CAST_U32(value)),
- mPos, str);
- expand(8);
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- int32_t swap = SDL_Swap64(value);
- memcpy(mData + CAST_SIZE(mPos), &swap, sizeof(int64_t));
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- memcpy(mData + CAST_SIZE(mPos), &value, sizeof(int64_t));
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- mPos += 8;
- PacketCounters::incOutBytes(8);
-}
-
-void MessageOut::writeBeingId(const BeingId value, const char *const str)
-{
- writeInt32(toInt(value, int32_t), str);
-}
-
-#define LOBYTE(w) (CAST_U8(w))
-#define HIBYTE(w) (CAST_U8(( \
-CAST_U16(w)) >> 8))
-
-void MessageOut::writeCoordinates(const uint16_t x,
- const uint16_t y,
- unsigned char direction,
- const char *const str)
-{
- DEBUGLOG2(strprintf("writeCoordinates: %u,%u %u",
- CAST_U32(x),
- CAST_U32(y),
- CAST_U32(direction)), mPos, str);
- unsigned char *const data = reinterpret_cast<unsigned char*>(mData)
- + CAST_SIZE(mPos);
- mNetwork->mOutSize += 3;
- mPos += 3;
-
- uint16_t temp = x;
- temp <<= 6;
- data[0] = 0;
- data[1] = 1;
- data[2] = 2;
- data[0] = HIBYTE(temp);
- data[1] = CAST_U8(temp);
- temp = y;
- temp <<= 4;
- data[1] |= HIBYTE(temp);
- data[2] = LOBYTE(temp);
- direction = toServerDirection(direction);
- data[2] |= direction;
- PacketCounters::incOutBytes(3);
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/messageout.h b/src/net/eathena/messageout.h
deleted file mode 100644
index 38525bad7..000000000
--- a/src/net/eathena/messageout.h
+++ /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/>.
- */
-
-#ifndef NET_EATHENA_MESSAGEOUT_H
-#define NET_EATHENA_MESSAGEOUT_H
-
-#include "net/messageout.h"
-
-#include "localconsts.h"
-
-namespace EAthena
-{
-
-class Network;
-
-/**
- * Used for building an outgoing message.
- *
- * \ingroup Network
- */
-class MessageOut final : public Net::MessageOut
-{
- public:
- /**
- * Constructor.
- */
- explicit MessageOut(const int16_t id);
-
- A_DELETE_COPY(MessageOut)
-
- virtual ~MessageOut();
-
- /**< Writes a short. */
- void writeInt16(const int16_t value,
- const char *const str) override final;
-
- /**< Writes a long. */
- void writeInt32(const int32_t value,
- const char *const str) override final;
-
- void writeInt64(const int64_t value,
- const char *const str);
-
- void writeBeingId(const BeingId value,
- const char *const str) override final;
-
- /**
- * Encodes coordinates and direction in 3 bytes.
- */
- void writeCoordinates(const uint16_t x,
- const uint16_t y,
- unsigned char direction,
- const char *const str);
-
- void resetPos()
- { mPos = 0; }
-
- private:
- void expand(const size_t size) const override final;
-
- Network *mNetwork;
-};
-
-} // namespace EAthena
-
-#endif // NET_EATHENA_MESSAGEOUT_H
diff --git a/src/net/eathena/network.cpp b/src/net/eathena/network.cpp
deleted file mode 100644
index 6829c08a6..000000000
--- a/src/net/eathena/network.cpp
+++ /dev/null
@@ -1,255 +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 "net/eathena/network.h"
-
-#include "net/packetinfo.h"
-
-#include "net/ea/adminrecv.h"
-#include "net/ea/beingrecv.h"
-#include "net/ea/buysellrecv.h"
-#include "net/ea/charserverrecv.h"
-#include "net/ea/chatrecv.h"
-#include "net/ea/gamerecv.h"
-#include "net/ea/inventoryrecv.h"
-#include "net/ea/itemrecv.h"
-#include "net/ea/loginrecv.h"
-#include "net/ea/maprecv.h"
-#include "net/ea/npcrecv.h"
-#include "net/ea/partyrecv.h"
-#include "net/ea/playerrecv.h"
-#include "net/ea/skillrecv.h"
-#include "net/ea/traderecv.h"
-
-#include "net/eathena/adminrecv.h"
-#include "net/eathena/auctionrecv.h"
-#include "net/eathena/bankrecv.h"
-#include "net/eathena/battlegroundrecv.h"
-#include "net/eathena/beingrecv.h"
-#include "net/eathena/buyingstorerecv.h"
-#include "net/eathena/buysellrecv.h"
-#include "net/eathena/cashshoprecv.h"
-#include "net/eathena/charserverrecv.h"
-#include "net/eathena/chatrecv.h"
-#include "net/eathena/elementalrecv.h"
-#include "net/eathena/familyrecv.h"
-#include "net/eathena/friendsrecv.h"
-#include "net/eathena/gamerecv.h"
-#include "net/eathena/generalrecv.h"
-#include "net/eathena/guildrecv.h"
-#include "net/eathena/homunculusrecv.h"
-#include "net/eathena/inventoryrecv.h"
-#include "net/eathena/itemrecv.h"
-#include "net/eathena/loginrecv.h"
-#include "net/eathena/mail2recv.h"
-#include "net/eathena/mailrecv.h"
-#include "net/eathena/maprecv.h"
-#include "net/eathena/marketrecv.h"
-#include "net/eathena/mercenaryrecv.h"
-#include "net/eathena/npcrecv.h"
-#include "net/eathena/partyrecv.h"
-#include "net/eathena/petrecv.h"
-#include "net/eathena/playerrecv.h"
-#include "net/eathena/questrecv.h"
-#include "net/eathena/rouletterecv.h"
-#include "net/eathena/searchstorerecv.h"
-#include "net/eathena/skillrecv.h"
-#include "net/eathena/traderecv.h"
-#include "net/eathena/vendingrecv.h"
-
-#include "net/eathena/messagein.h"
-
-#include "resources/db/networkdb.h"
-
-#include "utils/cast.h"
-#include "utils/checkutils.h"
-#include "utils/foreach.h"
-
-#include "debug.h"
-
-extern int packetVersion;
-extern int serverVersion;
-extern int evolPacketOffset;
-
-namespace EAthena
-{
-
-static const unsigned int packet_lengths_size = 0xFFFFU;
-static const unsigned int messagesSize = 0xFFFFU;
-Network *Network::mInstance = nullptr;
-
-Network::Network() :
- Ea::Network()
-{
- mInstance = this;
- mPackets = new PacketInfo[messagesSize];
-}
-
-Network::~Network()
-{
- clearHandlers();
- mInstance = nullptr;
-}
-
-void Network::registerHandlers()
-{
-#include "net/eathena/recvpackets.inc"
- RECVPACKETS_VOID
-}
-
-void Network::registerFakeHandlers()
-{
- const NetworkInPacketInfos &packets = NetworkDb::getFakePackets();
- FOR_EACH (NetworkInPacketInfosIter, it, packets)
- {
- const size_t id = (*it).first;
- if (id >= packet_lengths_size)
- {
- reportAlways("Wrong fake packet id %d", CAST_S32(id));
- continue;
- }
- if (mPackets[id].len != 0 ||
- mPackets[id].func != nullptr ||
- mPackets[id].version != 0)
- {
- continue;
- }
- const int32_t len = (*it).second;
- logger->log("Add fake packet: %d, %d",
- CAST_S32(id),
- len);
- mPackets[id].name = "fake";
- mPackets[id].len = len;
- mPackets[id].func = nullptr;
- mPackets[id].version = 0;
- }
-
- const NetworkRemovePacketInfos &removePackets =
- NetworkDb::getRemovePackets();
- FOR_EACH (NetworkRemovePacketInfosIter, it, removePackets)
- {
- const size_t id = *it;
- if (id >= packet_lengths_size)
- {
- reportAlways("Wrong remove packet id %d", CAST_S32(id));
- continue;
- }
- if (mPackets[id].len == 0 &&
- mPackets[id].func == nullptr &&
- mPackets[id].version == 0)
- {
- continue;
- }
- logger->log("Remove packet: %d",
- CAST_S32(id));
- mPackets[id].name = "";
- mPackets[id].len = 0;
- mPackets[id].func = nullptr;
- mPackets[id].version = 0;
- }
-}
-
-void Network::clearHandlers()
-{
- for (size_t f = 0; f < packet_lengths_size; f ++)
- {
- mPackets[f].name = "";
- mPackets[f].len = 0;
- mPackets[f].func = nullptr;
- mPackets[f].version = 0;
- }
-}
-
-void Network::dispatchMessages()
-{
- mPauseDispatch = false;
- while (messageReady())
- {
- SDL_mutexP(mMutexIn);
- const unsigned int msgId = readWord(0);
- int len = -1;
- if (msgId < packet_lengths_size)
- len = mPackets[msgId].len;
- if (len == -1)
- len = readWord(2);
-
- MessageIn msg(mInBuffer, len);
- unsigned int ver = mPackets[msgId].version;
- if (ver == 0)
- ver = packetVersion;
- msg.postInit(mPackets[msgId].name, ver);
- SDL_mutexV(mMutexIn);
-
- if (len == 0)
- {
- // need copy data for safty
- std::string str = strprintf(
- "Wrong packet %u 0x%x received. Exiting.",
- msgId, msgId);
- logger->safeError(str);
- }
-
- if (msgId < messagesSize)
- {
- const PacketFuncPtr func = mPackets[msgId].func;
- if (func != nullptr)
- func(msg);
- else
- logger->log("Unhandled packet: %u 0x%x", msgId, msgId);
- }
-
- skip(len);
- if (mPauseDispatch)
- break;
- }
-}
-
-bool Network::messageReady()
-{
- int len = -1;
-
- SDL_mutexP(mMutexIn);
- if (mInSize >= 2)
- {
- const int msgId = readWord(0);
- if (msgId >= 0 &&
- CAST_U32(msgId) < packet_lengths_size)
- {
- len = mPackets[msgId].len;
- }
-
- if (len == -1 && mInSize > 4)
- len = readWord(2);
- }
-
- const bool ret = (mInSize >= CAST_U32(len));
- SDL_mutexV(mMutexIn);
-
- return ret;
-}
-
-Network *Network::instance()
-{
- return mInstance;
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/network.h b/src/net/eathena/network.h
deleted file mode 100644
index acd377be3..000000000
--- a/src/net/eathena/network.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 NET_EATHENA_NETWORK_H
-#define NET_EATHENA_NETWORK_H
-
-#include "net/ea/network.h"
-
-/**
- * Protocol version, reported to the eAthena char and mapserver who can adjust
- * the protocol accordingly.
- */
-#define CLIENT_PROTOCOL_VERSION 23
-
-namespace EAthena
-{
-
-class Network final : public Ea::Network
-{
- public:
- Network();
-
- A_DELETE_COPY(Network)
-
- ~Network();
-
- void clearHandlers();
-
- bool messageReady();
-
- void dispatchMessages();
-
- void registerHandlers();
-
- void registerFakeHandlers();
-
- static Network *mInstance;
-
- protected:
- friend class MessageOut;
-
- static Network *instance() A_WARN_UNUSED;
-};
-
-} // namespace EAthena
-
-#endif // NET_EATHENA_NETWORK_H
diff --git a/src/net/eathena/npchandler.cpp b/src/net/eathena/npchandler.cpp
deleted file mode 100644
index 50d076ec4..000000000
--- a/src/net/eathena/npchandler.cpp
+++ /dev/null
@@ -1,365 +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 "net/eathena/npchandler.h"
-
-#include "being/localplayer.h"
-
-#include "const/net/inventory.h"
-
-#include "gui/windows/npcdialog.h"
-
-#include "gui/widgets/createwidget.h"
-
-#include "net/messagein.h"
-
-#include "net/ea/npcrecv.h"
-
-#include "net/eathena/messageout.h"
-#include "net/eathena/npcrecv.h"
-
-#include "net/eathena/protocolout.h"
-
-#include "utils/foreach.h"
-
-#include "resources/item/shopitem.h"
-
-#include "debug.h"
-
-extern int packetVersion;
-
-namespace EAthena
-{
-
-NpcHandler::NpcHandler() :
- Ea::NpcHandler()
-{
- npcHandler = this;
-}
-
-NpcHandler::~NpcHandler()
-{
- npcHandler = nullptr;
-}
-
-void NpcHandler::talk(const Being *const being) const
-{
- if (being == nullptr)
- return;
- createOutPacket(CMSG_NPC_TALK);
- outMsg.writeBeingId(being->getId(), "npc id");
- outMsg.writeInt8(0, "unused");
- EAthena::NpcRecv::mNpcTypeId = being->getSubType();
-}
-
-void NpcHandler::nextDialog(const BeingId npcId) const
-{
- createOutPacket(CMSG_NPC_NEXT_REQUEST);
- outMsg.writeBeingId(npcId, "npc id");
-}
-
-void NpcHandler::closeDialog(const BeingId npcId)
-{
- createOutPacket(CMSG_NPC_CLOSE);
- outMsg.writeBeingId(npcId, "npc id");
-
- const NpcDialogs::iterator it = NpcDialog::mNpcDialogs.find(npcId);
- if (it != NpcDialog::mNpcDialogs.end())
- {
- NpcDialog *const dialog = (*it).second;
- if (dialog != nullptr)
- dialog->close();
- if (dialog == Ea::NpcRecv::mDialog)
- Ea::NpcRecv::mDialog = nullptr;
- NpcDialog::mNpcDialogs.erase(it);
- }
-}
-
-void NpcHandler::listInput(const BeingId npcId,
- const unsigned char value) const
-{
- createOutPacket(CMSG_NPC_LIST_CHOICE);
- outMsg.writeBeingId(npcId, "npc id");
- outMsg.writeInt8(value, "value");
-}
-
-void NpcHandler::integerInput(const BeingId npcId,
- const int value) const
-{
- createOutPacket(CMSG_NPC_INT_RESPONSE);
- outMsg.writeBeingId(npcId, "npc id");
- outMsg.writeInt32(value, "value");
-}
-
-void NpcHandler::stringInput(const BeingId npcId,
- const std::string &value) const
-{
- createOutPacket(CMSG_NPC_STR_RESPONSE);
- if (packetVersion >= 20151029)
- {
- outMsg.writeInt16(CAST_S16(value.length() + 8), "len");
- outMsg.writeBeingId(npcId, "npc id");
- outMsg.writeString(value, CAST_S32(value.length()), "value");
- }
- else
- {
- outMsg.writeInt16(CAST_S16(value.length() + 9), "len");
- outMsg.writeBeingId(npcId, "npc id");
- outMsg.writeString(value, CAST_S32(value.length()), "value");
- outMsg.writeInt8(0, "null byte");
- }
-}
-
-void NpcHandler::buy(const Being *const being) const
-{
- if (being == nullptr)
- return;
- createOutPacket(CMSG_NPC_BUY_SELL_REQUEST);
- outMsg.writeBeingId(being->getId(), "npc id");
- outMsg.writeInt8(0, "action");
- EAthena::NpcRecv::mNpcTypeId = being->getSubType();
-}
-
-void NpcHandler::buy(const BeingId beingId) const
-{
- createOutPacket(CMSG_NPC_BUY_SELL_REQUEST);
- outMsg.writeBeingId(beingId, "npc id");
- outMsg.writeInt8(0, "action");
- EAthena::NpcRecv::mNpcTypeId = BeingTypeId_zero;
-}
-
-void NpcHandler::sell(const BeingId beingId) const
-{
- createOutPacket(CMSG_NPC_BUY_SELL_REQUEST);
- outMsg.writeBeingId(beingId, "npc id");
- outMsg.writeInt8(1, "action");
-}
-
-void NpcHandler::buyItem(const BeingId beingId A_UNUSED,
- const int itemId,
- const ItemColor color A_UNUSED,
- const int amount) const
-{
- createOutPacket(CMSG_NPC_BUY_REQUEST);
- outMsg.writeInt16(8, "len");
- outMsg.writeInt16(CAST_S16(amount), "amount");
- outMsg.writeInt16(CAST_S16(itemId), "item id");
-}
-
-void NpcHandler::buyItems(STD_VECTOR<ShopItem*> &items) const
-{
- int cnt = 0;
- const int pairSize = 4;
-
- FOR_EACH (STD_VECTOR<ShopItem*>::iterator, it, items)
- {
- ShopItem *const item = *it;
- const int usedQuantity = item->getUsedQuantity();
- const ItemTypeT type = item->getType();
- if (usedQuantity == 0)
- continue;
- if (type == ItemType::Weapon ||
- type == ItemType::Armor ||
- type == ItemType::PetEgg ||
- type == ItemType::PetArmor)
- {
- cnt += item->getUsedQuantity();
- }
- else
- {
- cnt ++;
- }
- }
-
- if (cnt > 100)
- return;
-
- createOutPacket(CMSG_NPC_BUY_REQUEST);
- outMsg.writeInt16(CAST_S16(4 + pairSize * cnt), "len");
- FOR_EACH (STD_VECTOR<ShopItem*>::iterator, it, items)
- {
- ShopItem *const item = *it;
- const int usedQuantity = item->getUsedQuantity();
- if (usedQuantity == 0)
- continue;
- item->increaseUsedQuantity(-usedQuantity);
- item->update();
- const ItemTypeT type = item->getType();
- if (type == ItemType::Weapon ||
- type == ItemType::Armor ||
- type == ItemType::PetEgg ||
- type == ItemType::PetArmor)
- {
- for (int f = 0; f < usedQuantity; f ++)
- {
- outMsg.writeInt16(CAST_S16(1), "amount");
- outMsg.writeInt16(CAST_S16(item->getId()),
- "item id");
- }
- }
- else
- {
- outMsg.writeInt16(CAST_S16(usedQuantity), "amount");
- outMsg.writeInt16(CAST_S16(item->getId()), "item id");
- }
- }
-}
-
-void NpcHandler::sellItem(const BeingId beingId A_UNUSED,
- const int itemId, const int amount) const
-{
- createOutPacket(CMSG_NPC_SELL_REQUEST);
- outMsg.writeInt16(8, "len");
- outMsg.writeInt16(CAST_S16(itemId + INVENTORY_OFFSET),
- "item index");
- outMsg.writeInt16(CAST_S16(amount), "amount");
-}
-
-void NpcHandler::sellItems(STD_VECTOR<ShopItem*> &items) const
-{
- const int pairSize = 4;
- int cnt = 0;
-
- FOR_EACH (STD_VECTOR<ShopItem*>::iterator, it, items)
- {
- ShopItem *const item = *it;
- const int usedQuantity = item->getUsedQuantity();
- if (usedQuantity == 0)
- continue;
- cnt ++;
- }
-
- createOutPacket(CMSG_NPC_SELL_REQUEST);
- outMsg.writeInt16(CAST_S16(4 + pairSize * cnt), "len");
- FOR_EACH (STD_VECTOR<ShopItem*>::iterator, it, items)
- {
- ShopItem *const item = *it;
- const int usedQuantity = item->getUsedQuantity();
- if (usedQuantity == 0)
- continue;
- item->increaseUsedQuantity(-usedQuantity);
- item->update();
- outMsg.writeInt16(CAST_S16(
- item->getCurrentInvIndex() + INVENTORY_OFFSET),
- "item index");
- outMsg.writeInt16(CAST_S16(usedQuantity), "amount");
- }
-}
-
-void NpcHandler::completeProgressBar() const
-{
- createOutPacket(CMSG_NPC_COMPLETE_PROGRESS_BAR);
-}
-
-void NpcHandler::produceMix(const int nameId,
- const int materialId1,
- const int materialId2,
- const int materialId3) const
-{
- createOutPacket(CMSG_NPC_PRODUCE_MIX);
- outMsg.writeInt16(CAST_S16(nameId), "name id");
- outMsg.writeInt16(CAST_S16(materialId1), "material 1");
- outMsg.writeInt16(CAST_S16(materialId2), "material 2");
- outMsg.writeInt16(CAST_S16(materialId3), "material 3");
-}
-
-void NpcHandler::cooking(const CookingTypeT type,
- const int nameId) const
-{
- createOutPacket(CMSG_NPC_COOKING);
- outMsg.writeInt16(CAST_S16(type), "type");
- outMsg.writeInt16(CAST_S16(nameId), "name id");
-}
-
-void NpcHandler::repair(const int index) const
-{
- createOutPacket(CMSG_NPC_REPAIR);
- outMsg.writeInt16(CAST_S16(index), "index");
-}
-
-void NpcHandler::refine(const int index) const
-{
- createOutPacket(CMSG_NPC_REFINE);
- outMsg.writeInt32(index, "index");
-}
-
-void NpcHandler::identify(const int index) const
-{
- createOutPacket(CMSG_NPC_IDENTIFY);
- outMsg.writeInt16(CAST_S16(index), "index");
-}
-
-void NpcHandler::selectArrow(const int nameId) const
-{
- createOutPacket(CMSG_NPC_SELECT_ARROW);
- outMsg.writeInt16(CAST_S16(nameId), "name id");
-}
-
-void NpcHandler::selectAutoSpell(const int skillId) const
-{
- createOutPacket(CMSG_NPC_SELECT_AUTO_SPELL);
- outMsg.writeInt32(CAST_S16(skillId), "skill id");
-}
-
-BeingId NpcHandler::getNpc(Net::MessageIn &msg,
- const NpcActionT action)
-{
- const BeingId npcId = msg.readBeingId("npc id");
-
- const NpcDialogs::const_iterator diag = NpcDialog::mNpcDialogs.find(npcId);
- Ea::NpcRecv::mDialog = nullptr;
-
- if (diag == NpcDialog::mNpcDialogs.end())
- {
- // Empty dialogs don't help
- if (action == NpcAction::Close)
- {
- closeDialog(npcId);
- return npcId;
- }
- else if (action == NpcAction::Next)
- {
- nextDialog(npcId);
- return npcId;
- }
- else
- {
- CREATEWIDGETV(Ea::NpcRecv::mDialog, NpcDialog, npcId);
- Ea::NpcRecv::mDialog->saveCamera();
- if (localPlayer != nullptr)
- localPlayer->stopWalking(false);
- NpcDialog::mNpcDialogs[npcId] = Ea::NpcRecv::mDialog;
- }
- }
- else
- {
- NpcDialog *const dialog = diag->second;
- if (Ea::NpcRecv::mDialog != nullptr && Ea::NpcRecv::mDialog != dialog)
- Ea::NpcRecv::mDialog->restoreCamera();
- Ea::NpcRecv::mDialog = dialog;
- if (Ea::NpcRecv::mDialog != nullptr)
- Ea::NpcRecv::mDialog->saveCamera();
- }
- return npcId;
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/npchandler.h b/src/net/eathena/npchandler.h
deleted file mode 100644
index e5177d7c9..000000000
--- a/src/net/eathena/npchandler.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 NET_EATHENA_NPCHANDLER_H
-#define NET_EATHENA_NPCHANDLER_H
-
-#include "net/ea/npchandler.h"
-
-namespace EAthena
-{
-
-class NpcHandler final : public Ea::NpcHandler
-{
- public:
- NpcHandler();
-
- A_DELETE_COPY(NpcHandler)
-
- ~NpcHandler();
-
- void talk(const Being *const being) const override final;
-
- void nextDialog(const BeingId npcId) const override final;
-
- void closeDialog(const BeingId npcId) override final;
-
- void listInput(const BeingId npcId,
- const unsigned char value) const override final;
-
- void integerInput(const BeingId npcId,
- const int value) const override final;
-
- void stringInput(const BeingId npcId,
- const std::string &value) const override final;
-
- void buy(const Being *const being) const override final;
-
- void buy(const BeingId beingId) const override final;
-
- void sell(const BeingId beingId) const override final;
-
- void buyItem(const BeingId beingId,
- const int itemId,
- const ItemColor color,
- const int amount) const override final;
-
- void buyItems(STD_VECTOR<ShopItem*> &items) const
- override final;
-
- void sellItem(const BeingId beingId,
- const int itemId,
- const int amount) const override final;
-
- void sellItems(STD_VECTOR<ShopItem*> &items) const override final;
-
- void completeProgressBar() const override final;
-
- void produceMix(const int nameId,
- const int materialId1,
- const int materialId2,
- const int materialId3) const override final;
-
- void cooking(const CookingTypeT type,
- const int nameId) const override final;
-
- void repair(const int index) const override final;
-
- void refine(const int index) const override final;
-
- BeingId getNpc(Net::MessageIn &msg,
- const NpcActionT action) override final;
-
- void identify(const int index) const override final;
-
- void selectArrow(const int nameId) const override final;
-
- void selectAutoSpell(const int skillId) const override final;
-};
-
-} // namespace EAthena
-
-#endif // NET_EATHENA_NPCHANDLER_H
diff --git a/src/net/eathena/npcrecv.cpp b/src/net/eathena/npcrecv.cpp
deleted file mode 100644
index 535e57d7c..000000000
--- a/src/net/eathena/npcrecv.cpp
+++ /dev/null
@@ -1,132 +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 "net/eathena/npcrecv.h"
-
-#include "actormanager.h"
-
-#include "being/being.h"
-
-#include "gui/windows/cutinwindow.h"
-#include "gui/windows/npcdialog.h"
-
-#include "net/messagein.h"
-#include "net/npchandler.h"
-
-#include "net/ea/npcrecv.h"
-
-#include "debug.h"
-
-namespace EAthena
-{
-
-namespace NpcRecv
-{
- BeingTypeId mNpcTypeId = BeingTypeId_zero;
-} // namespace NpcRecv
-
-void NpcRecv::processNpcCutin(Net::MessageIn &msg)
-{
- Ea::NpcRecv::mRequestLang = false;
- if (cutInWindow == nullptr)
- {
- msg.readString(64, "image name");
- msg.readUInt8("type");
- return;
- }
- const std::string image = msg.readString(64, "image name");
- const CutInT cutin = static_cast<CutInT>(msg.readUInt8("type"));
- if (cutInWindow != nullptr)
- cutInWindow->show(image, cutin);
-}
-
-void NpcRecv::processNpcViewPoint(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- Ea::NpcRecv::mRequestLang = false;
- // +++ probably need add nav point and start moving to it
- msg.readInt32("npc id");
- msg.readInt32("type"); // 0 display for 15 sec,
- // 1 display until teleport,
- // 2 remove
- msg.readInt32("x");
- msg.readInt32("y");
- msg.readUInt8("number"); // can be used for scripts
- msg.readInt32("color");
-}
-
-void NpcRecv::processNpcShowProgressBar(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- Ea::NpcRecv::mRequestLang = false;
- // +++ probably need show progress bar in npc dialog
- msg.readInt32("color");
- msg.readInt32("seconds");
-}
-
-void NpcRecv::processNpcCloseTimeout(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- Ea::NpcRecv::mRequestLang = false;
- // this packet send after npc closed by timeout.
- msg.readInt32("npc id");
-}
-
-void NpcRecv::processArea(Net::MessageIn &msg)
-{
- const int len = msg.readInt16("len");
- if (len < 12)
- return;
- Being *const dstBeing = actorManager->findBeing(
- msg.readBeingId("npc id"));
- const int area = msg.readInt32("area size");
- if (dstBeing != nullptr)
- dstBeing->setAreaSize(area);
-}
-
-void NpcRecv::processShowDigit(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
-
- msg.readUInt8("type");
- msg.readInt32("value");
-}
-
-void NpcRecv::processProgressBarAbort(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
-}
-
-void NpcRecv::processNpcSkin(Net::MessageIn &msg)
-{
- const int len = msg.readInt16("len");
- npcHandler->getNpc(msg, NpcAction::Other);
- if (Ea::NpcRecv::mDialog != nullptr)
- {
- const std::string skin = msg.readString(len - 8, "skin");
- Ea::NpcRecv::mDialog->setSkin(skin);
- }
- else
- {
- msg.readString(len - 8, "skin");
- }
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/npcrecv.h b/src/net/eathena/npcrecv.h
deleted file mode 100644
index c89d5f2f0..000000000
--- a/src/net/eathena/npcrecv.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 NET_EATHENA_NPCRECV_H
-#define NET_EATHENA_NPCRECV_H
-
-#include "enums/simpletypes/beingtypeid.h"
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-namespace EAthena
-{
- namespace NpcRecv
- {
- extern BeingTypeId mNpcTypeId;
-
- void processNpcCutin(Net::MessageIn &msg);
- void processNpcViewPoint(Net::MessageIn &msg);
- void processNpcShowProgressBar(Net::MessageIn &msg);
- void processNpcCloseTimeout(Net::MessageIn &msg);
- void processArea(Net::MessageIn &msg);
- void processShowDigit(Net::MessageIn &msg);
- void processProgressBarAbort(Net::MessageIn &msg);
- void processNpcSkin(Net::MessageIn &msg);
- } // namespace NpcRecv
-} // namespace EAthena
-
-#endif // NET_EATHENA_NPCRECV_H
diff --git a/src/net/eathena/packetsin.inc b/src/net/eathena/packetsin.inc
deleted file mode 100644
index af497c07c..000000000
--- a/src/net/eathena/packetsin.inc
+++ /dev/null
@@ -1,972 +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/>.
- */
-
-// very outdated packets
-packet(SMSG_MAP_LOGIN_SUCCESS, 0x0073, 11, &GameRecv::processMapLogin, 1);
-packet(SMSG_BEING_FAKE_NAME, 0x0078, 54, &BeingRecv::processBeingFakeName, 1);
-packet(SMSG_BEING_SPAWN, 0x0079, 53, &BeingRecv::processBeingSpawn, 1);
-packet(SMSG_BEING_MOVE, 0x007b, 60, &BeingRecv::processBeingMove, 1);
-packet(SMSG_BEING_SPAWN_OUTDATED, 0x007c, 41, nullptr, 1);
-packet(SMSG_WHISPER, 0x0097, -1, &ChatRecv::processWhisper, 1);
-packet(SMSG_WHISPER_RESPONSE, 0x0098, 3, &ChatRecv::processWhisperResponse, 1);
-packet(SMSG_ITEM_DROPPED, 0x009e, 17, &ItemRecv::processItemDropped, 1);
-packet(SMSG_PLAYER_INVENTORY_ADD, 0x00a0, 23, &InventoryRecv::processPlayerInventoryAdd, 1);
-packet(SMSG_PLAYER_INVENTORY, 0x00a3, -1, &InventoryRecv::processPlayerInventory, 1);
-packet(SMSG_PLAYER_EQUIPMENT, 0x00a4, -1, &InventoryRecv::processPlayerEquipment, 1);
-packet(SMSG_PLAYER_STORAGE_ITEMS, 0x00a5, -1, &InventoryRecv::processPlayerStorage, 1);
-packet(SMSG_PLAYER_STORAGE_EQUIP, 0x00a6, -1, &InventoryRecv::processPlayerStorageEquip, 1);
-packet(SMSG_PLAYER_EQUIP, 0x00aa, 7, &InventoryRecv::processPlayerEquip, 1);
-packet(SMSG_PLAYER_UNEQUIP, 0x00ac, 7, &InventoryRecv::processPlayerUnEquip, 1);
-packet(SMSG_BEING_CHANGE_LOOKS_OUTDATED, 0x00c3, 8, nullptr, 1);
-packet(SMSG_TRADE_REQUEST, 0x00e5, 26, &TradeRecv::processTradeRequest, 1);
-packet(SMSG_TRADE_ITEM_ADD, 0x00e9, 19, &TradeRecv::processTradeItemAdd, 1);
-packet(SMSG_TRADE_RESPONSE_OUTDATED, 0x00e7, 3, nullptr, 0);
-packet(SMSG_PLAYER_STORAGE_ADD, 0x00f4, 21, &InventoryRecv::processPlayerStorageAdd, 1);
-packet(SMSG_PARTY_INVITED, 0x00fe, 30, &PartyRecv::processPartyInvited, 1);
-packet(SMSG_PLAYER_STATUS_CHANGE, 0x0119, 13, &BeingRecv::processPlayerStatusChange, 1);
-packet(SMSG_SKILL_DAMAGE, 0x0114, 31, &BeingRecv::processSkillDamage, 1);
-packet(SMSG_SKILL_ENTRY, 0x011f, 16, &BeingRecv::processSkillEntry, 1);
-packet(SMSG_PLAYER_CART_EQUIP, 0x0122, -1, &InventoryRecv::processPlayerCartEquip, 1);
-packet(SMSG_PLAYER_CART_ITEMS, 0x0123, -1, &InventoryRecv::processPlayerCartItems, 1);
-packet(SMSG_PLAYER_CART_ADD, 0x0124, 21, &InventoryRecv::processPlayerCartAdd, 1);
-packet(SMSG_VENDING_ITEMS_LIST, 0x0133, -1, &VendingRecv::processItemsList, 1);
-packet(SMSG_VENDING_OPEN, 0x0136, -1, &VendingRecv::processOpen, 1);
-packet(SMSG_SKILL_CASTING, 0x013e, 24, &BeingRecv::processSkillCasting, 1);
-packet(SMSG_BEING_STATUS_CHANGE, 0x0196, 9, &BeingRecv::processBeingStatusChange, 1);
-packet(SMSG_QUEST_LIST, 0x02b1, -1, &QuestRecv::processAddQuests, 1);
-packet(SMSG_BEING_VIEW_EQUIPMENT, 0x02d7, -1, &BeingRecv::processBeingViewEquipment, 1);
-packet(SMSG_PARTY_SETTINGS, 0x0101, 6, &PartyRecv::processPartySettings, 1);
-packet(SMSG_PLAYER_HP, 0x0106, 10, &BeingRecv::processBeingHp, 1);
-packet(SMSG_PET_STATUS, 0x01a2, 35, &PetRecv::processPetStatus, 1);
-
-// fake packets for add packet name
-packet(SMSG_SELECT_CART, 0x0000, 0, nullptr, 0);
-packet(CMSG_NAVIGATE_TO, 0x0000, 0, nullptr, 0);
-packet(SMSG_MERGE_ITEM, 0x0000, 0, nullptr, 0);
-packet(SMSG_ACK_MERGE_ITEMS, 0x0000, 0, nullptr, 0);
-packet(SMSG_RANKS_LIST, 0x0000, 0, nullptr, 0);
-packet(SMSG_CHAR_CHARACTERS, 0x0000, 0, nullptr, 0);
-
-// login server, unknown version
-packet(SMSG_LOGIN_DATA, 0x0069, -1, &LoginRecv::processLoginData, 0);
-packet(SMSG_LOGIN_CODING_KEY, 0x01dc, -1, &LoginRecv::processCondingKey, 0);
-packet(SMSG_LOGIN_ERROR, 0x006a, 23, &Ea::LoginRecv::processLoginError, 0);
-
-// char server, unknown version
-packet(SMSG_CHAR_CHANGE_SLOT, 0x08d5, -1, &CharServerRecv::processCharChangeSlot, 0);
-packet(SMSG_CHAR_CHECK_RENAME, 0x028e, 4, &CharServerRecv::processCharCheckRename, 0);
-packet(SMSG_CHAR_CREATE_FAILED, 0x006e, 3, &Ea::CharServerRecv::processCharCreateFailed, 0);
-packet(SMSG_CHAR_CREATE_SUCCEEDED, 0x006d, 149, &CharServerRecv::processCharCreate, 0);
-packet(SMSG_CHAR_DELETE2_ACCEPT_ACTUAL_ACK, 0x082a, 10, &CharServerRecv::processCharDelete2AcceptActual, 0);
-packet(SMSG_CHAR_DELETE2_ACK, 0x0828, 14, &CharServerRecv::processCharDelete2Ack, 0);
-packet(SMSG_CHAR_DELETE2_CANCEL_ACK, 0x082c, 10, &CharServerRecv::processCharDelete2CancelAck, 0);
-packet(SMSG_CHAR_DELETE_FAILED, 0x0070, 3, &CharServerRecv::processCharDeleteFailed, 0);
-packet(SMSG_CHAR_DELETE_SUCCEEDED, 0x006f, 2, &Ea::CharServerRecv::processCharDelete, 0);
-packet(SMSG_CHAR_LOGIN, 0x006b, -1, &CharServerRecv::processCharLogin, 0);
-packet(SMSG_CHAR_LOGIN2, 0x082d, -1, &CharServerRecv::processCharLogin2, 0);
-packet(SMSG_CHAR_LOGIN_ERROR, 0x006c, 3, &Ea::CharServerRecv::processCharLoginError, 0);
-packet(SMSG_CHAR_MAP_INFO, 0x0071, 28, &CharServerRecv::processCharMapInfo, 0);
-packet(SMSG_CHAR_PINCODE_STATUS, 0x08b9, 12, &CharServerRecv::processPincodeStatus, 0);
-packet(SMSG_CHAR_RENAME, 0x0290, 4, &CharServerRecv::processCharRename, 0);
-packet(SMSG_MAP_NOT_FOUND, 0x0840, -1, &GeneralRecv::processMapNotFound, 0);
-
-// map server, unknown versions
-packet(SMSG_ADMIN_GET_LOGIN_ACK, 0x01e0, 30, &AdminRecv::processAdminGetLoginAck, 0);
-packet(SMSG_ADMIN_KICK_ACK, 0x00cd, 3, &Ea::AdminRecv::processKickAck, 0);
-packet(SMSG_ADMIN_SET_TILE_TYPE, 0x0192, 24, &AdminRecv::processSetTileType, 0);
-packet(SMSG_BATTLE_BEGINS, 0x08df, 50, &BattleGroundRecv::processBattleBegins, 0);
-packet(SMSG_BATTLE_JOINED, 0x08d9, 30, &BattleGroundRecv::processBattleJoined, 0);
-packet(SMSG_BATTLE_NOTICE_DELETE, 0x08db, 27, &BattleGroundRecv::processBattleNoticeDelete, 0);
-packet(SMSG_BATTLE_QUEUE_ACK, 0x08d8, 27, &BattleGroundRecv::processBattleQueueAck, 0);
-packet(SMSG_BEING_ACTION, 0x008a, 29, &Ea::BeingRecv::processBeingAction, 0);
-packet(SMSG_BEING_CHANGE_DIRECTION, 0x009c, 9, &BeingRecv::processBeingChangeDirection, 0);
-packet(SMSG_BEING_CHAT, 0x008d, -1, &ChatRecv::processBeingChat, 0);
-packet(SMSG_BEING_EMOTION, 0x00c0, 7, &Ea::BeingRecv::processBeingEmotion, 0);
-packet(SMSG_BEING_MOVE2, 0x0086, 16, &BeingRecv::processBeingMove2, 0);
-packet(SMSG_BEING_NAME_RESPONSE, 0x0095, 30, &Ea::BeingRecv::processNameResponse, 0);
-packet(SMSG_BEING_REMOVE, 0x0080, 7, &Ea::BeingRecv::processBeingRemove, 0);
-packet(SMSG_BEING_REMOVE_SKILL, 0x0120, 6, &BeingRecv::processBeingRemoveSkill, 0);
-packet(SMSG_BEING_RESURRECT, 0x0148, 8, &BeingRecv::processBeingResurrect, 0);
-packet(SMSG_BEING_SELFEFFECT, 0x019b, 10, &BeingRecv::processBeingSelfEffect, 0);
-packet(SMSG_BEING_SLIDE, 0x01ff, 10, &BeingRecv::processBeingSlide, 0);
-packet(SMSG_BEING_SOUND_EFFECT, 0x01d3, 35, &BeingRecv::processBeingSoundEffect, 0);
-packet(SMSG_BEING_SPECIAL_EFFECT, 0x01f3, 10, &BeingRecv::processBeingSpecialEffect, 0);
-packet(SMSG_BEING_STAT_UPDATE_1, 0x01ab, 12, &BeingRecv::processBeingStatUpdate1, 0);
-packet(SMSG_BIND_ITEM, 0x02d3, 4, &InventoryRecv::processBindItem, 0);
-packet(SMSG_BLADE_STOP, 0x01d1, 14, &BeingRecv::processBladeStop, 0);
-packet(SMSG_CART_INFO, 0x0121, 14, &InventoryRecv::processCartInfo, 0);
-packet(SMSG_CART_REMOVE, 0x012b, 2, &InventoryRecv::processCartRemove, 0);
-packet(SMSG_CHANGE_MAP_SERVER, 0x0092, 28, &CharServerRecv::processChangeMapServer, 0);
-packet(SMSG_CHAR_BAN_CHAR_LIST, 0x020d, -1, &CharServerRecv::processCharBanCharList, 0);
-packet(SMSG_CHAR_SWITCH_RESPONSE, 0x00b3, 3, &Ea::GameRecv::processCharSwitchResponse, 0);
-packet(SMSG_CHAT_DISPLAY, 0x00d7, -1, &ChatRecv::processChatDisplay, 0);
-packet(SMSG_CHAT_IGNORE_LIST, 0x00d4, -1, &ChatRecv::processChatIgnoreList, 0);
-packet(SMSG_CHAT_ROOM_ADD_MEMBER, 0x00dc, 28, &ChatRecv::processChatRoomAddMember, 0);
-packet(SMSG_CHAT_ROOM_CREATE_ACK, 0x00d6, 3, &ChatRecv::processChatRoomCreateAck, 0);
-packet(SMSG_CHAT_ROOM_DESTROY, 0x00d8, 6, &ChatRecv::processChatRoomDestroy, 0);
-packet(SMSG_CHAT_ROOM_JOIN_ACK, 0x00db, -1, &ChatRecv::processChatRoomJoinAck, 0);
-packet(SMSG_CHAT_ROOM_JOIN_FAILED, 0x00da, 3, &ChatRecv::processChatRoomJoinFailed, 0);
-packet(SMSG_CHAT_ROOM_LEAVE, 0x00dd, 29, &ChatRecv::processChatRoomLeave, 0);
-packet(SMSG_CHAT_ROOM_ROLE_CHANGE, 0x00e1, 30, &ChatRecv::processChatRoomRoleChange, 0);
-packet(SMSG_CHAT_ROOM_SETTINGS, 0x00df, -1, &ChatRecv::processChatRoomSettings, 0);
-packet(SMSG_CHAT_SILENCE, 0x014b, 27, &ChatRecv::processChatSilence, 0);
-packet(SMSG_CHAT_TALKIE_BOX, 0x0191, 86, &ChatRecv::processChatTalkieBox, 0);
-packet(SMSG_CLASS_CHANGE, 0x01b0, 11, &BeingRecv::processClassChange, 0);
-packet(SMSG_COMBO_DELAY, 0x01d2, 10, &BeingRecv::processComboDelay, 0);
-packet(SMSG_CONNECTION_PROBLEM, 0x0081, 3, &GeneralRecv::processConnectionProblem, 0);
-packet(SMSG_FAMILY_ASK_FOR_CHILD, 0x01f6, 34, &FamilyRecv::processAskForChild, 0);
-packet(SMSG_FAMILY_CALL_PARTNER, 0x01e6, 26, &FamilyRecv::processCallPartner, 0);
-packet(SMSG_FAMILY_DIVORCED, 0x0205, 26, &FamilyRecv::processDivorced, 0);
-packet(SMSG_FRIENDS_DELETE_PLAYER, 0x020a, 10, &FriendsRecv::processDeletePlayer, 0);
-packet(SMSG_FRIENDS_LIST, 0x0201, -1, &FriendsRecv::processFriendsList, 0);
-packet(SMSG_FRIENDS_PLAYER_ONLINE, 0x0206, 11, &FriendsRecv::processPlayerOnline, 0);
-packet(SMSG_FRIENDS_REQUEST, 0x0207, 34, &FriendsRecv::processRequest, 0);
-packet(SMSG_FRIENDS_REQUEST_ACK, 0x0209, 36, &FriendsRecv::processRequestAck, 0);
-packet(SMSG_GM_CHAT, 0x009a, -1, &ChatRecv::processGmChat, 0);
-packet(SMSG_GM_CHAT2, 0x01c3, -1, &ChatRecv::processGmChat2, 0);
-packet(SMSG_GRAFFITI_VISIBLE, 0x01c9, 97, &BeingRecv::processGraffiti, 0);
-packet(SMSG_GUILD_ALIANCE_INFO, 0x014c, -1, &GuildRecv::processGuildAlianceInfo, 0);
-packet(SMSG_GUILD_ALLIANCE_ADDED_DISABLED, 0x0185, 34, nullptr, 0);
-packet(SMSG_GUILD_BASIC_INFO, 0x01b6, 114, &GuildRecv::processGuildBasicInfo, 0);
-packet(SMSG_GUILD_BROKEN, 0x015e, 6, &GuildRecv::processGuildBroken, 0);
-packet(SMSG_GUILD_CREATE_RESPONSE, 0x0167, 3, &GuildRecv::processGuildCreateResponse, 0);
-packet(SMSG_GUILD_DEL_ALLIANCE, 0x0184, 10, &GuildRecv::processGuildDelAlliance, 0);
-packet(SMSG_GUILD_EMBLEM, 0x01b4, 12, &GuildRecv::processGuildEmblem, 0);
-packet(SMSG_GUILD_EMBLEM_DATA, 0x0152, -1, &GuildRecv::processGuildEmblemData, 0);
-packet(SMSG_GUILD_EXPULSION_LIST, 0x0163, -1, &GuildRecv::processGuildExpulsionList, 0);
-packet(SMSG_GUILD_INVITE, 0x016a, 30, &GuildRecv::processGuildInvite, 0);
-packet(SMSG_GUILD_INVITE_ACK, 0x0169, 3, &GuildRecv::processGuildInviteAck, 0);
-packet(SMSG_GUILD_LEAVE, 0x015a, 66, &GuildRecv::processGuildLeave, 0);
-packet(SMSG_GUILD_MASTER_OR_MEMBER, 0x014e, 6, &GuildRecv::processGuildMasterOrMember, 0);
-packet(SMSG_GUILD_MEMBER_LIST, 0x0154, -1, &GuildRecv::processGuildMemberList, 0);
-packet(SMSG_GUILD_MEMBER_LOGIN, 0x01f2, 20, &GuildRecv::processGuildMemberLogin, 0);
-packet(SMSG_GUILD_MEMBER_POS_CHANGE, 0x0156, -1, &GuildRecv::processGuildMemberPosChange, 0);
-packet(SMSG_GUILD_MESSAGE, 0x017f, -1, &GuildRecv::processGuildMessage, 0);
-packet(SMSG_GUILD_NOTICE, 0x016f, 182, &GuildRecv::processGuildNotice, 0);
-packet(SMSG_GUILD_OPPOSITION_ACK, 0x0181, 3, &GuildRecv::processGuildOppositionAck, 0);
-packet(SMSG_GUILD_POSITION_CHANGED, 0x0174, -1, &GuildRecv::processGuildPositionChanged, 0);
-packet(SMSG_GUILD_POSITION_INFO, 0x016c, 43, &GuildRecv::processGuildPositionInfo, 0);
-packet(SMSG_GUILD_POS_INFO_LIST, 0x0160, -1, &GuildRecv::processGuildPosInfoList, 0);
-packet(SMSG_GUILD_POS_NAME_LIST, 0x0166, -1, &GuildRecv::processGuildPosNameList, 0);
-packet(SMSG_GUILD_REQ_ALLIANCE, 0x0171, 30, &GuildRecv::processGuildReqAlliance, 0);
-packet(SMSG_GUILD_REQ_ALLIANCE_ACK, 0x0173, 3, &GuildRecv::processGuildReqAllianceAck, 0);
-packet(SMSG_GUILD_SKILL_INFO, 0x0162, -1, &GuildRecv::processGuildSkillInfo, 0);
-packet(SMSG_GUILD_SKILL_UP, 0x010e, 11, &GuildRecv::processGuildSkillUp, 0);
-packet(SMSG_GUILD_UPDATE_COORDS, 0x01eb, 10, &GuildRecv::processGuildUpdateCoords, 0);
-packet(SMSG_IGNORE_ALL_RESPONSE, 0x00d2, 4, &Ea::ChatRecv::processIgnoreAllResponse, 0);
-packet(SMSG_IGNORE_NICK_ACK, 0x00d1, 4, &ChatRecv::processIgnoreNickAck, 0);
-packet(SMSG_ITEM_MVP_DROPPED, 0x07fd, 59, &ItemRecv::processItemMvpDropped, 0);
-packet(SMSG_ITEM_REMOVE, 0x00a1, 6, &Ea::ItemRecv::processItemRemove, 0);
-packet(SMSG_ITEM_USE_RESPONSE, 0x00a8, 7, &Ea::InventoryRecv::processItemUseResponse, 0);
-packet(SMSG_ITEM_VISIBLE, 0x009d, 17, &ItemRecv::processItemVisible, 0);
-packet(SMSG_MANNER_MESSAGE, 0x014a, 6, &ChatRecv::processMannerMessage, 0);
-packet(SMSG_MAP_AUTH_REFUSE, 0x0074, 3, &GameRecv::processMapAuthRefuse, 0);
-packet(SMSG_MAP_QUIT_RESPONSE, 0x018b, 4, &Ea::GameRecv::processMapQuitResponse, 0);
-packet(SMSG_MAP_TYPE, 0x01d6, 4, &BeingRecv::processMapType, 0);
-packet(SMSG_MARRIAGE_PROCESS_OUTDATED, 0x01e4, 2, nullptr, 0);
-packet(SMSG_MARRIAGE_PROPOSAL_OUTDATED, 0x01e2, 34, nullptr, 0);
-packet(SMSG_MONSTER_INFO, 0x018c, 29, &BeingRecv::processMonsterInfo, 0);
-packet(SMSG_MVP_ITEM, 0x010a, 4, &ChatRecv::processMVPItem, 0);
-packet(SMSG_MVP_EXP, 0x010b, 6, &ChatRecv::processMVPExp, 0);
-packet(SMSG_MVP_EFFECT, 0x010c, 6, &Ea::ChatRecv::processMVPEffect, 0);
-packet(SMSG_MVP_NO_ITEM, 0x010d, 2, &ChatRecv::processMVPNoItem, 0);
-packet(SMSG_NPC_BUY, 0x00c6, -1, &BuySellRecv::processNpcBuy, 0);
-packet(SMSG_NPC_BUY_RESPONSE, 0x00ca, 3, &BuySellRecv::processNpcBuyResponse, 0);
-packet(SMSG_NPC_BUY_SELL_CHOICE, 0x00c4, 6, &Ea::BuySellRecv::processNpcBuySellChoice, 0);
-packet(SMSG_NPC_CASH_BUY, 0x0849, 16, &CashShopRecv::processCashShopBuy, 0);
-packet(SMSG_NPC_CASH_POINTS, 0x0845, 10, &CashShopRecv::processCashShopPoints, 0);
-packet(SMSG_NPC_CASH_SCHEDULE, 0x08ca, -1, &CashShopRecv::processCashShopSchedule, 0);
-packet(SMSG_NPC_CASH_TAB_PRICE_LIST, 0x08c0, -1, &CashShopRecv::processCashShopTabPriceList, 0);
-packet(SMSG_NPC_CHOICE, 0x00b7, -1, &Ea::NpcRecv::processNpcChoice, 0);
-packet(SMSG_NPC_CLOSE, 0x00b6, 6, &Ea::NpcRecv::processNpcClose, 0);
-packet(SMSG_NPC_CLOSE_TIMEOUT, 0x08d6, 6, &NpcRecv::processNpcCloseTimeout, 0);
-packet(SMSG_NPC_CUTIN, 0x01b3, 67, &NpcRecv::processNpcCutin, 0);
-packet(SMSG_NPC_INT_INPUT, 0x0142, 6, &Ea::NpcRecv::processNpcIntInput, 0);
-packet(SMSG_NPC_MESSAGE, 0x00b4, -1, &Ea::NpcRecv::processNpcMessage, 0);
-packet(SMSG_NPC_NEXT, 0x00b5, 6, &Ea::NpcRecv::processNpcNext, 0);
-packet(SMSG_NPC_SELL, 0x00c7, -1, &Ea::BuySellRecv::processNpcSell, 0);
-packet(SMSG_NPC_SELL_RESPONSE, 0x00cb, 3, &BuySellRecv::processNpcSellResponse, 0);
-packet(SMSG_NPC_SHOW_DIGIT, 0x01b1, 7, &NpcRecv::processShowDigit, 0);
-packet(SMSG_NPC_STR_INPUT, 0x01d4, 6, &Ea::NpcRecv::processNpcStrInput, 0);
-packet(SMSG_NPC_VIEWPOINT, 0x0144, 23, &NpcRecv::processNpcViewPoint, 0);
-packet(SMSG_PARTY_CREATE, 0x00fa, 3, &Ea::PartyRecv::processPartyCreate, 0);
-packet(SMSG_PARTY_INFO, 0x00fb, -1, &PartyRecv::processPartyInfo, 0);
-packet(SMSG_PARTY_INVITE_RESPONSE_OUTDATED, 0x00fd, 27, nullptr, 0);
-packet(SMSG_PARTY_LEADER, 0x07fc, 10, &PartyRecv::processPartyLeader, 0);
-packet(SMSG_PARTY_LEAVE, 0x0105, 31, &Ea::PartyRecv::processPartyLeave, 0);
-packet(SMSG_PARTY_MEMBER_INFO, 0x01e9, 81, &PartyRecv::processPartyMemberInfo, 0);
-packet(SMSG_PARTY_MESSAGE, 0x0109, -1, &PartyRecv::processPartyMessage, 0);
-packet(SMSG_PARTY_UPDATE_COORDS, 0x0107, 10, &Ea::PartyRecv::processPartyUpdateCoords, 0);
-packet(SMSG_PET_CATCH_PROCESS, 0x019e, 2, &PetRecv::processPetCatchProcess, 0);
-packet(SMSG_PET_DATA, 0x01a4, 11, &PetRecv::processPetData, 0);
-packet(SMSG_PET_EGGS_LIST, 0x01a6, -1, &PetRecv::processEggsList, 0);
-packet(SMSG_PET_FOOD, 0x01a3, 5, &PetRecv::processPetFood, 0);
-packet(SMSG_PET_MESSAGE, 0x01aa, 10, &PetRecv::processPetMessage, 0);
-packet(SMSG_PET_ROULETTE, 0x01a0, 3, &PetRecv::processPetRoulette, 0);
-packet(SMSG_PLAYER_ADD_SKILL, 0x0111, 39, &SkillRecv::processSkillAdd, 0);
-packet(SMSG_PLAYER_ARROW_EQUIP, 0x013c, 4, &Ea::InventoryRecv::processPlayerArrowEquip, 0);
-packet(SMSG_PLAYER_ARROW_MESSAGE, 0x013b, 4, &Ea::PlayerRecv::processPlayerArrowMessage, 0);
-packet(SMSG_PLAYER_ATTACK_RANGE, 0x013a, 4, &Ea::InventoryRecv::processPlayerAttackRange, 0);
-packet(SMSG_PLAYER_CART_ADD_ERROR, 0x012c, 3, &InventoryRecv::processCartAddError, 0);
-packet(SMSG_PLAYER_CART_REMOVE, 0x0125, 8, &InventoryRecv::processPlayerCartRemove, 0);
-packet(SMSG_PLAYER_CHAT, 0x008e, -1, &ChatRecv::processChat, 0);
-packet(SMSG_PLAYER_GUILD_PARTY_INFO, 0x0195, 102, &BeingRecv::processPlayerGuilPartyInfo, 0);
-packet(SMSG_PLAYER_HEAL, 0x013d, 6, &PlayerRecv::processPlayerHeal, 0);
-packet(SMSG_PLAYER_IDENTIFIED, 0x0179, 5, &InventoryRecv::processPlayerIdentified, 0);
-packet(SMSG_PLAYER_IDENTIFY_LIST, 0x0177, -1, &InventoryRecv::processPlayerIdentifyList, 0);
-packet(SMSG_PLAYER_INSERT_CARD, 0x017d, 7, &InventoryRecv::processPlayerInsertCard, 0);
-packet(SMSG_PLAYER_INVENTORY_REMOVE, 0x00af, 6, &InventoryRecv::processPlayerInventoryRemove, 0);
-packet(SMSG_PLAYER_MOVE_TO_ATTACK, 0x0139, 16, &Ea::BeingRecv::processPlayerMoveToAttack, 0);
-packet(SMSG_PLAYER_NOTIFY_MAPINFO, 0x0189, 4, &PlayerRecv::processNotifyMapInfo, 0);
-packet(SMSG_PLAYER_REFINE, 0x0188, 8, &InventoryRecv::processPlayerRefine, 0);
-packet(SMSG_PLAYER_REPAIR_EFFECT, 0x01fe, 5, &InventoryRecv::processPlayerRepairEffect, 0);
-packet(SMSG_PLAYER_REPAIR_LIST, 0x01fc, -1, &InventoryRecv::processPlayerRepairList, 0);
-packet(SMSG_PLAYER_SKILLS, 0x010f, -1, &SkillRecv::processPlayerSkills, 0);
-packet(SMSG_PLAYER_SKILL_AUTO_SPELLS, 0x01cd, 30, &SkillRecv::processSkillAutoSpells, 0);
-packet(SMSG_PLAYER_SKILL_PRODUCE_EFFECT, 0x018f, 6, &SkillRecv::processSkillProduceEffect, 0);
-packet(SMSG_PLAYER_SKILL_PRODUCE_MIX_LIST, 0x018d, -1, &SkillRecv::processSkillProduceMixList, 0);
-packet(SMSG_PLAYER_SKILL_UP, 0x010e, 11, &Ea::SkillRecv::processPlayerSkillUp, 0);
-packet(SMSG_PLAYER_STAT_UPDATE_1, 0x00b0, 8, &Ea::PlayerRecv::processPlayerStatUpdate1, 0);
-packet(SMSG_PLAYER_STAT_UPDATE_2, 0x00b1, 8, &Ea::PlayerRecv::processPlayerStatUpdate2, 0);
-packet(SMSG_PLAYER_STAT_UPDATE_3, 0x0141, 14, &Ea::PlayerRecv::processPlayerStatUpdate3, 0);
-packet(SMSG_PLAYER_STAT_UPDATE_4, 0x00bc, 6, &Ea::PlayerRecv::processPlayerStatUpdate4, 0);
-packet(SMSG_PLAYER_STAT_UPDATE_5, 0x00bd, 44, &PlayerRecv::processPlayerStatUpdate5, 0);
-packet(SMSG_PLAYER_STAT_UPDATE_6, 0x00be, 5, &Ea::PlayerRecv::processPlayerStatUpdate6, 0);
-packet(SMSG_PLAYER_STOP, 0x0088, 10, &Ea::BeingRecv::processPlayerStop, 0);
-packet(SMSG_PLAYER_STORAGE_CLOSE, 0x00f8, 2, &Ea::InventoryRecv::processPlayerStorageClose, 0);
-packet(SMSG_PLAYER_STORAGE_REMOVE, 0x00f6, 8, &InventoryRecv::processPlayerStorageRemove, 0);
-packet(SMSG_PLAYER_STORAGE_STATUS, 0x00f2, 6, &Ea::InventoryRecv::processPlayerStorageStatus, 0);
-packet(SMSG_PLAYER_USE_CARD, 0x017b, -1, &InventoryRecv::processPlayerUseCard, 0);
-packet(SMSG_PLAYER_WARP, 0x0091, 22, &Ea::PlayerRecv::processPlayerWarp, 0);
-packet(SMSG_PVP_MAP_MODE, 0x0199, 4, &Ea::BeingRecv::processPvpMapMode, 0);
-packet(SMSG_PVP_SET, 0x019a, 14, &BeingRecv::processPvpSet, 0);
-packet(SMSG_SCRIPT_MESSAGE, 0x08b3, -1, &ChatRecv::processScriptMessage, 0);
-packet(SMSG_SERVER_PING, 0x007f, 6, &GameRecv::processServerTick, 0);
-packet(SMSG_SKILL_ARROW_CREATE_LIST, 0x01ad, -1, &SkillRecv::processSkillArrowCreateList, 0);
-packet(SMSG_SKILL_AUTO_CAST, 0x0147, 39, &BeingRecv::processSkillAutoCast, 0);
-packet(SMSG_SKILL_CAST_CANCEL, 0x01b9, 6, &BeingRecv::processSkillCancel, 0);
-packet(SMSG_SKILL_DEVOTION_EFFECT, 0x01cf, 28, &SkillRecv::processSkillDevotionEffect, 0);
-packet(SMSG_SKILL_FAILED, 0x0110, 10, &SkillRecv::processSkillFailed, 0);
-packet(SMSG_SKILL_GROUND_DAMAGE_UNUSED, 0x0115, 35, nullptr, 0);
-packet(SMSG_SKILL_GROUND_NO_DAMAGE, 0x0117, 18, &BeingRecv::processSkillGroundNoDamage, 0);
-packet(SMSG_SKILL_MEMO_MESSAGE, 0x011e, 3, &SkillRecv::processSkillMemoMessage, 0);
-packet(SMSG_SKILL_NO_DAMAGE, 0x011a, 15, &Ea::BeingRecv::processSkillNoDamage, 1);
-packet(SMSG_SKILL_UNIT_UPDATE, 0x01ac, 6, &SkillRecv::processSkillUnitUpdate, 0);
-packet(SMSG_SKILL_WARP_POINT, 0x011c, 68, &SkillRecv::processSkillWarpPoint, 0);
-packet(SMSG_SOLVE_CHAR_NAME, 0x0194, 30, &BeingRecv::processSolveCharName, 0);
-packet(SMSG_SPIRIT_BALLS, 0x01d0, 8, &BeingRecv::processSpiritBalls, 0);
-packet(SMSG_SPIRIT_BALL_SINGLE, 0x01e1, 8, &BeingRecv::processSpiritBalls, 0);
-packet(SMSG_TRADE_CANCEL, 0x00ee, 2, &Ea::TradeRecv::processTradeCancel, 0);
-packet(SMSG_TRADE_COMPLETE, 0x00f0, 3, &Ea::TradeRecv::processTradeComplete, 0);
-packet(SMSG_TRADE_ITEM_ADD_RESPONSE, 0x00ea, 5, &TradeRecv::processTradeItemAddResponse, 0);
-packet(SMSG_TRADE_OK, 0x00ec, 3, &Ea::TradeRecv::processTradeOk, 0);
-packet(SMSG_TRADE_UNDO, 0x00f1, 2, &TradeRecv::processTradeUndo, 0);
-packet(SMSG_VENDING_BUY_ACK, 0x0135, 7, &VendingRecv::processBuyAck, 0);
-packet(SMSG_VENDING_HIDE_BOARD, 0x0132, 6, &VendingRecv::processHideBoard, 0);
-packet(SMSG_VENDING_OPEN_REQ, 0x012d, 4, &VendingRecv::processOpenReq, 0);
-packet(SMSG_VENDING_REPORT, 0x0137, 6, &VendingRecv::processReport, 0);
-packet(SMSG_VENDING_SHOW_BOARD, 0x0131, 86, &VendingRecv::processShowBoard, 0);
-packet(SMSG_WALK_RESPONSE, 0x0087, 12, &PlayerRecv::processWalkResponse, 0);
-packet(SMSG_WEDDING_EFFECT, 0x01ea, 6, &BeingRecv::processWddingEffect, 0);
-packet(SMSG_WHO_ANSWER, 0x00c2, 6, &Ea::GameRecv::processWhoAnswer, 0);
-packet(SMSG_BOOKING_CANCEL_VOLUNTEER, 0x0909, 6, nullptr, 0);
-packet(SMSG_BOOKING_ADD_FILTERING_LIST, 0x090b, 30, nullptr, 0);
-packet(SMSG_BOOKING_SUB_FILTERING_LIST, 0x090c, 30, nullptr, 0);
-packet(SMSG_ADD_MAP_MARKER, 0x09c1, 10, &MapRecv::processAddMapMarker, 0);
-packet(SMSG_GUILD_ONLINE_INFO, 0x016d, 14, &GuildRecv::processOnlineInfo, 0);
-
-// 3
-if (packetVersion >= 3)
-{
- packet(SMSG_PLAYER_INVENTORY_USE, 0x01c8, 13, &Ea::InventoryRecv::processPlayerInventoryUse, 3);
- packet(SMSG_SKILL_DAMAGE, 0x01de, 33, &BeingRecv::processSkillDamage, 3);
-}
-
-// 4
-if (packetVersion >= 4)
-{
- packet(SMSG_BEING_CHANGE_LOOKS2, 0x01d7, 11, &BeingRecv::processBeingChangeLook2, 4);
- packet(SMSG_BEING_VISIBLE, 0x01d8, 54, &BeingRecv::processBeingVisible, 4);
- packet(SMSG_BEING_SPAWN, 0x01d9, 53, &BeingRecv::processBeingSpawn, 4);
- packet(SMSG_BEING_MOVE, 0x01da, 60, &BeingRecv::processBeingMove, 4);
-}
-
-// 5
-packet(SMSG_PLAYER_STORAGE_ADD, 0x01c4, 22, &InventoryRecv::processPlayerStorageAdd, 5);
-packet(SMSG_PLAYER_CART_ADD, 0x01c5, 22, &InventoryRecv::processPlayerCartAdd, 5);
-
-// 6
-if (packetVersion >= 6)
-{
- packet(SMSG_TRADE_REQUEST, 0x01f4, 32, &TradeRecv::processTradeRequest, 6);
- packet(SMSG_TRADE_RESPONSE, 0x01f5, 9, &TradeRecv::processTradeResponse, 6);
-}
-
-if (packetVersion >= 7)
-{
- packet(SMSG_BEING_VISIBLE, 0x022a, 58, &BeingRecv::processBeingVisible, 7);
- packet(SMSG_BEING_SPAWN, 0x022b, 57, &BeingRecv::processBeingSpawn, 7);
- packet(SMSG_BEING_MOVE, 0x022c, 65, &BeingRecv::processBeingMove, 7);
-}
-
-// 20040816
-packet(SMSG_ADMIN_ACCOUNT_STATS, 0x0214, 42, &AdminRecv::processAccountStats, 20040816);
-
-// 20040817
-packet(SMSG_PVP_INFO, 0x0210, 22, &PlayerRecv::processPvpInfo, 20040817);
-
-// 20041101
-packet(SMSG_PLAYER_SKILL_MESSAGE, 0x0215, 6, &PlayerRecv::processPlayerSkillMessage, 20041101);
-
-// 20041108
-packet(SMSG_FAMILY_ASK_FOR_CHILD_REPLY, 0x0216, 6, &FamilyRecv::processAskForChildReply, 20041108);
-packet(SMSG_BLACKSMITH_RANKS_LIST, 0x0219, 282, &BeingRecv::processBlacksmithRanksList, 20041108);
-packet(SMSG_ALCHEMIST_RANKS_LIST, 0x021a, 282, &BeingRecv::processAlchemistRanksList, 20041108);
-packet(SMSG_PLAYER_FAME_BLACKSMITH, 0x021b, 10, &PlayerRecv::processPlayerFameBlacksmith, 20041108);
-packet(SMSG_PLAYER_FAME_ALCHEMIST, 0x021c, 10, &PlayerRecv::processPlayerFameAlchemist, 20041108);
-
-// 20041129
-packet(SMSG_PLAYER_REFINE_LIST, 0x0221, -1, &InventoryRecv::processPlayerRefineList, 20041129);
-packet(SMSG_PLAYER_UPGRADE_MESSAGE, 0x0223, 8, &PlayerRecv::processPlayerUpgradeMessage, 20041129);
-
-// 20050328
-packet(SMSG_PLAYER_FAME_TAEKWON, 0x0224, 10, &PlayerRecv::processPlayerFameTaekwon, 20050328);
-packet(SMSG_TAEKWON_RANKS_LIST, 0x0226, 282, &BeingRecv::processTaekwonRanksList, 20050328);
-
-// 20050411
-if (packetVersion >= 20050411)
-{
- packet(SMSG_PLAYER_STATUS_CHANGE, 0x0229, 15, &BeingRecv::processPlayerStatusChange, 20050411);
-}
-
-// 20050523
-packet(SMSG_HOMUNCULUS_DATA, 0x0230, 12, &HomunculusRecv::processHomunculusData, 20050523);
-
-// 20050530
-packet(SMSG_HOMUNCULUS_SKILLS, 0x0235, -1, &HomunculusRecv::processHomunculusSkills, 20050530);
-packet(SMSG_PK_RANKS_LIST, 0x0238, 282, &BeingRecv::processPkRanksList, 20050530);
-packet(SMSG_HOMUNCULUS_INFO, 0x022e, 71, &HomunculusRecv::processHomunculusInfo, 20050530);
-
-// 20050531
-packet(SMSG_HOMUNCULUS_SKILL_UP, 0x0239, 11, &HomunculusRecv::processHomunculusSkillUp, 20050531);
-
-// 20050608
-packet(SMSG_HOMUNCULUS_FOOD, 0x022f, 5, &HomunculusRecv::processHomunculusFood, 20050608);
-packet(SMSG_PLAYER_STORAGE_PASSWORD, 0x023a, 4, &InventoryRecv::processPlayerStoragePassword, 20050608);
-packet(SMSG_PLAYER_STORAGE_PASSWORD_RESULT, 0x023c, 6, &InventoryRecv::processPlayerStoragePasswordResult, 20050608);
-
-// 20050718
-packet(SMSG_MAIL_READ_MAIL, 0x0242, -1, &MailRecv::processReadMail, 20050718);
-packet(SMSG_MAIL_SEND_MAIL_ACK, 0x0249, 3, &MailRecv::processSendMailAck, 20050718);
-packet(SMSG_MAIL_NEW_MAIL, 0x024a, 70, &MailRecv::processNewMail, 20050718);
-packet(SMSG_AUCTION_MESSAGE, 0x0250, 3, &AuctionRecv::processAuctionMessage, 20050718);
-packet(SMSG_AUCTION_RESULTS, 0x0252, -1, &AuctionRecv::processAuctionResults, 20050718);
-
-// 20050801
-packet(SMSG_MAIL_GET_ATTACHMENT, 0x0245, 3, &MailRecv::processGetAttachment, 20050801);
-
-// 20050817
-packet(SMSG_GLADIATOR_FEEL_REQUEST, 0x0253, 3, &BeingRecv::processGladiatorFeelRequest, 20050817);
-
-// 20050829
-packet(SMSG_MAIL_MAILS_LIST, 0x0240, -1, &MailRecv::processMailList, 20050829);
-packet(SMSG_MAIL_SET_ATTACHMENT_ACK, 0x0255, 5, &MailRecv::processSetAttachmentAck, 20050829);
-packet(SMSG_MAIL_DELETE_MAIL_ACK, 0x0257, 8, &MailRecv::processDeleteAck, 20050829);
-
-// 20050912
-packet(SMSG_AUCTION_SET_ITEM, 0x0256, 5, &AuctionRecv::processAuctionSetItem, 20050912);
-
-// 20051010
-packet(SMSG_STARS_KILL, 0x020e, 32, &BeingRecv::processStarsKill, 20051010);
-packet(SMSG_PLAYER_COOKING_LIST, 0x025a, -1, &InventoryRecv::processPlayerCookingList, 20051010);
-
-// 20051017
-packet(SMSG_AUCTION_CLOSE, 0x025d, 4, &AuctionRecv::processAuctionClose, 20051017);
-
-// 20051024
-packet(SMSG_AUCTION_OPEN_WINDOW, 0x025f, 6, &AuctionRecv::processOpenWindow, 20051024);
-packet(SMSG_MAIL_OPEN_WINDOW, 0x0260, 6, &MailRecv::processMailOpen, 20051024);
-
-// 20060306
-packet(SMSG_MAIL_RETURN, 0x0274, 8, &MailRecv::processMailReturn, 20060306);
-
-// 20060424
-if (packetVersion >= 20060424)
-{
- packet(SMSG_MAP_ACCOUNT_ID, 0x0283, 6, &GameRecv::processMapAccountId, 20060424);
- packet(SMSG_BEING_SPECIAL_EFFECT_NUM, 0x0284, 14, &BeingRecv::processBeingSpecialEffectNum, 20060424);
- packet(SMSG_NPC_CASH_SHOP_OPEN, 0x0287, -1, &CashShopRecv::processCashShopOpen, 20060424);
- packet(SMSG_NPC_CASH_BUY_ACK, 0x0289, 8, &CashShopRecv::processCashShopBuyAck, 20060424);
- packet(SMSG_PLAYER_STATUS_CHANGE2, 0x028a, 18, &BeingRecv::processPlayerStatusChange2, 20060424);
- packet(SMSG_FORMAT_MESSAGE, 0x0291, 4, &ChatRecv::processFormatMessage, 20060424);
- packet(SMSG_BOSS_MAP_INFO, 0x0293, 70, &BeingRecv::processBossMapInfo, 20060424);
- packet(SMSG_PLAYER_READ_BOOK, 0x0294, 10, &PlayerRecv::processPlayerReadBook, 20060424);
- packet(SMSG_PLAYER_ITEM_RENTAL_TIME, 0x0298, 8, &InventoryRecv::processPlayerItemRentalTime, 20060424);
- packet(SMSG_PLAYER_ITEM_RENTAL_EXPIRED, 0x0299, 6, &InventoryRecv::processPlayerItemRentalExpired, 20060424);
- packet(SMSG_MERCENARY_SKILLS, 0x029d, -1, &MercenaryRecv::processMercenarySkills, 20060424);
- packet(SMSG_MERCENARY_UPDATE, 0x02a2, 8, &MercenaryRecv::processMercenaryUpdate, 20060424);
-}
-
-// 20061218
-if (packetVersion >= 20061218)
-{
- packet(SMSG_PLAYER_INVENTORY_ADD, 0x029a, 27, &InventoryRecv::processPlayerInventoryAdd, 20061218);
-}
-
-// 20070227
-if (packetVersion >= 20070227)
-{
- packet(SMSG_NPC_CASH_BUY_ACK, 0x0289, 12, &CashShopRecv::processCashShopBuyAck, 20070227);
- packet(SMSG_QUEST_LIST_OBJECTIVES, 0x02b2, -1, &QuestRecv::processAddQuestsObjectives, 20070227);
- packet(SMSG_QUEST_ADD, 0x02b3, 107, &QuestRecv::processAddQuest, 20070227);
- packet(SMSG_QUEST_REMOVE, 0x02b4, 6, &QuestRecv::processRemoveQuest, 20070227);
- packet(SMSG_QUEST_UPDATE_OBJECTIVES, 0x02b5, -1, &QuestRecv::processUpdateQuestsObjectives, 20070227);
- packet(SMSG_QUEST_ACTIVATE, 0x02b7, 7, &QuestRecv::processActivateQuest, 20070227);
- packet(SMSG_ITEM_DAMAGED, 0x02bb, 8, &InventoryRecv::processItemDamaged, 20070227);
- packet(SMSG_COLOR_MESSAGE, 0x02c1, -1, &ChatRecv::processColorChat, 20070227);
- packet(SMSG_PARTY_INVITATION_STATS, 0x02c9, 3, &PartyRecv::processPartyInvitationStats, 20070227);
- packet(SMSG_INSTANCE_CREATE, 0x02cc, 4, &MapRecv::processInstanceCreate, 20070227);
- packet(SMSG_INSTANCE_DELETE, 0x02ce, 10, &MapRecv::processInstanceDelete, 20070227);
- packet(SMSG_PLAYER_EQUIP_TICK_ACK, 0x02d9, 10, &PlayerRecv::processPlayerEquipTickAck, 20070227);
- packet(SMSG_PLAYER_SHOW_EQUIP, 0x02da, 3, &PlayerRecv::processPlayerShowEquip, 20070227);
- packet(SMSG_BATTLE_CHAT_MESSAGE, 0x02dc, -1, &ChatRecv::processBattleChatMessage, 20070227);
- packet(SMSG_BATTLE_EMBLEM, 0x02dd, 32, &BattleGroundRecv::processBattleEmblem, 20070227);
- packet(SMSG_BATTLE_UPDATE_SCORE, 0x02de, 6, &BattleGroundRecv::processBattleUpdateScore, 20070227);
- packet(SMSG_BATTLE_UPDATE_COORDS, 0x02df, 36, &BattleGroundRecv::processBattleUpdateCoords, 20070227);
- packet(SMSG_BATTLE_UPDATE_HP, 0x02e0, 34, &BattleGroundRecv::processBattleUpdateHp, 20070227);
-}
-
-// 20070821
-packet(SMSG_PARTY_INVITE_RESPONSE, 0x02c5, 30, &PartyRecv::processPartyInviteResponse, 20070821);
-packet(SMSG_PARTY_INVITED, 0x02c6, 30, &PartyRecv::processPartyInvited, 20070821);
-
-// 20071002
-if (packetVersion >= 20071002)
-{
- packet(SMSG_PLAYER_INVENTORY, 0x01ee, -1, &InventoryRecv::processPlayerInventory, 20071002);
- packet(SMSG_PLAYER_CART_ITEMS, 0x01ef, -1, &InventoryRecv::processPlayerCartItems, 20071002);
- packet(SMSG_PLAYER_STORAGE_ITEMS, 0x0295, -1, &InventoryRecv::processPlayerStorage, 20071002);
- packet(SMSG_PLAYER_STORAGE_EQUIP, 0x0296, -1, &InventoryRecv::processPlayerStorageEquip, 20071002);
- packet(SMSG_PLAYER_CART_EQUIP, 0x0297, -1, &InventoryRecv::processPlayerCartEquip, 20071002);
- packet(SMSG_PARTY_ITEM_PICKUP, 0x02b8, 22, &PartyRecv::processPartyItemPickup, 20071002);
- packet(SMSG_PLAYER_INVENTORY_ADD, 0x02d4, 29, &InventoryRecv::processPlayerInventoryAdd, 20071002);
-}
-
-// 20071023
-packet(SMSG_INSTANCE_START, 0x02cb, 65, &MapRecv::processInstanceStart, 20071023);
-packet(SMSG_INSTANCE_INFO, 0x02cd, 71, &MapRecv::processInstanceInfo, 20071023);
-
-// 20071106
-if (packetVersion >= 20071106)
-{
- packet(SMSG_BEING_FAKE_NAME, 0x0078, 55, &BeingRecv::processBeingFakeName, 20071106);
- packet(SMSG_BEING_SPAWN_OUTDATED, 0x007c, 42, nullptr, 20071106);
- packet(SMSG_BEING_MOVE, 0x022c, 65, &BeingRecv::processBeingMove, 20071106);
- packet(SMSG_MERCENARY_INFO, 0x029b, 80, &MercenaryRecv::processMercenaryInfo, 20071106);
-}
-
-// 20071113
-packet(SMSG_BEING_ACTION2, 0x02e1, 33, &BeingRecv::processBeingAction2, 20071113);
-
-// 20080102
-if (packetVersion >= 20080102)
-{
- packet(SMSG_PLAYER_EQUIPMENT, 0x02d0, -1, &InventoryRecv::processPlayerEquipment, 20080102);
- packet(SMSG_PLAYER_STORAGE_EQUIP, 0x02d1, -1, &InventoryRecv::processPlayerStorageEquip, 20080102);
- packet(SMSG_PLAYER_CART_EQUIP, 0x02d2, -1, &InventoryRecv::processPlayerCartEquip, 20080102);
- packet(SMSG_PLAYER_INVENTORY, 0x02e8, -1, &InventoryRecv::processPlayerInventory, 20080102);
- packet(SMSG_PLAYER_CART_ITEMS, 0x02e9, -1, &InventoryRecv::processPlayerCartItems, 20080102);
- packet(SMSG_PLAYER_STORAGE_ITEMS, 0x02ea, -1, &InventoryRecv::processPlayerStorage, 20080102);
- packet(SMSG_MAP_LOGIN_SUCCESS, 0x02eb, 13, &GameRecv::processMapLogin, 20080102);
- packet(SMSG_BEING_MOVE, 0x02ec, 67, &BeingRecv::processBeingMove, 20080102);
- packet(SMSG_BEING_SPAWN, 0x02ed, 59, &BeingRecv::processBeingSpawn, 20080102);
- packet(SMSG_BEING_VISIBLE, 0x02ee, 60, &BeingRecv::processBeingVisible, 20080102);
- packet(SMSG_BEING_FONT, 0x02ef, 8, &BeingRecv::processBeingFont, 20080102);
-}
-
-// 20080318
-packet(SMSG_NPC_SHOW_PROGRESS_BAR, 0x02f0, 10, &NpcRecv::processNpcShowProgressBar, 20080318);
-packet(SMSG_NPC_PROGRESS_BAR_ABORT, 0x02f2, 2, &NpcRecv::processProgressBarAbort, 20080318);
-
-// 20080827
-if (packetVersion >= 20080827)
-{
- packet(SMSG_BEING_SPAWN_OUTDATED, 0x007c, 44, nullptr, 20080827);
-}
-
-// 20081112
-packet(SMSG_PLAYER_SKILL_COOLDOWN, 0x043d, 8, &SkillRecv::processSkillCoolDown, 20081112);
-
-// 20081113
-if (packetVersion >= 20081113)
-{
- packet(SMSG_PLAYER_SKILL_COOLDOWN_LIST, 0x043e, -1, &SkillRecv::processSkillCoolDownList, 20081113);
-}
-
-// 20081126
-if (packetVersion >= 20081126)
-{
- packet(SMSG_PET_STATUS, 0x01a2, 37, &PetRecv::processPetStatus, 20081126);
-}
-
-// 20081210
-packet(SMSG_AUTOSHADOW_SPELL_LIST, 0x0442, -1, &PlayerRecv::processPlayerAutoShadowSpellList, 20081210);
-
-// 20081217
-packet(SMSG_BEING_MILLENIUM_SHIELD, 0x0440, 10, &BeingRecv::processBeingMilleniumShield, 20081217);
-packet(SMSG_PLAYER_DELETE_SKILL, 0x0441, 4, &SkillRecv::processSkillDelete, 20081217);
-
-// 20090121
-packet(SMSG_BEING_STATUS_CHANGE, 0x043f, 25, &BeingRecv::processBeingStatusChange, 20090121);
-
-// 20090218
-packet(SMSG_QUEST_NPC_EFFECT, 0x0446, 14, &QuestRecv::processNpcQuestEffect, 20090218);
-
-// 20090603
-packet(SMSG_PARTY_SETTINGS, 0x07d8, 8, &PartyRecv::processPartySettings, 20090603);
-packet(SMSG_PLAYER_SHORTCUTS, 0x07d9, 268, &PlayerRecv::processPlayerShortcuts, 20090603);
-
-// 20090715
-packet(SMSG_PLAYER_UPDATE_SKILL, 0x07e1, 15, &SkillRecv::processSkillUpdate, 20090715);
-
-// 20090805
-packet(SMSG_FORMAT_MESSAGE_NUMBER, 0x07e2, 8, &ChatRecv::processFormatMessageNumber, 20090805);
-
-// 20090818
-packet(SMSG_FORMAT_MESSAGE_SKILL, 0x07e6, 8, &ChatRecv::processFormatMessageSkill, 20090818);
-
-// 20090922
-packet(SMSG_SKILL_ITEM_LIST_WINDOW, 0x07e3, 6, &SkillRecv::processSkillItemListWindow, 20090922);
-packet(SMSG_CHAR_CAPTCHA_NOT_SUPPORTED, 0x07e9, 5, &CharServerRecv::processCharCaptchaNotSupported, 20090922);
-
-// 20091027
-packet(SMSG_PLAYER_GET_EXP, 0x07f6, 14, &PlayerRecv::processPlayerGetExp, 20091027);
-
-if (packetVersion >= 20091103)
-{
- packet(SMSG_BEING_MOVE, 0x07f7, -1, &BeingRecv::processBeingMove, 20091103);
- packet(SMSG_BEING_SPAWN, 0x07f8, -1, &BeingRecv::processBeingSpawn, 20091103);
- packet(SMSG_BEING_VISIBLE, 0x07f9, -1, &BeingRecv::processBeingVisible, 20091103);
-}
-
-// 20091104
-if (packetVersion >= 20091104)
-{
- packet(SMSG_WHISPER, 0x0097, -1, &ChatRecv::processWhisper, 20091104);
-}
-
-// 20091117
-packet(SMSG_PLAYER_INVENTORY_REMOVE2, 0x07fa, 8, &InventoryRecv::processPlayerInventoryRemove2, 20091117);
-
-// 20091124
-if (packetVersion >= 20091124)
-{
- packet(SMSG_SKILL_CASTING, 0x07fb, 25, &BeingRecv::processSkillCasting, 20091124);
-}
-
-// 20091201
-packet(SMSG_BATTLE_PLAY, 0x07fe, 26, &BattleGroundRecv::processBattlePlay, 20091201);
-
-// 20091222
-packet(SMSG_BOOKING_REGISTER_ACK, 0x0803, 4, nullptr, 20091222);
-packet(SMSG_BOOKING_SEARCH_ACK, 0x0805, -1, nullptr, 20091222);
-
-// 20091229
-packet(SMSG_BOOKING_DELETE_ACK, 0x0807, 4, nullptr, 20091229);
-packet(SMSG_BOOKING_INSERT_NOTIFY, 0x0809, 50, nullptr, 20091229);
-packet(SMSG_BOOKING_UPDATE_NOTIFY, 0x080a, 18, nullptr, 20091229);
-packet(SMSG_BOOKING_DELETE_NOTIFY, 0x080b, 6, nullptr, 20091229);
-
-// 20100105
-if (packetVersion >= 20100105)
-{
- packet(SMSG_VENDING_ITEMS_LIST, 0x0800, -1, &VendingRecv::processItemsList, 20100105);
-}
-
-// 20100126
-packet(SMSG_PLAYER_HP, 0x080e, 14, &BeingRecv::processBeingHp, 20100126);
-
-// 20100223
-packet(SMSG_TRADE_ITEM_ADD, 0x080f, 20, &TradeRecv::processTradeItemAdd, 20100223);
-
-// 20100303
-packet(SMSG_BUYINGSTORE_OPEN, 0x0810, 3, &BuyingStoreRecv::processBuyingStoreOpen, 20100303);
-
-// 20100309
-packet(SMSG_BUYINGSTORE_OWN_ITEMS, 0x0813, -1, &BuyingStoreRecv::processBuyingStoreOwnItems, 20100309);
-packet(SMSG_BUYINGSTORE_HIDE_BOARD, 0x0816, 6, &BuyingStoreRecv::processBuyingStoreHideBoard, 20100309);
-packet(SMSG_BUYINGSTORE_ITEMS_LIST, 0x0818, -1, &BuyingStoreRecv::processBuyingStoreItemsList, 20100309);
-packet(SMSG_ELEMENTAL_INFO, 0x081d, 22, &ElementalRecv::processElementalInfo, 20100309);
-packet(SMSG_ELEMENTAL_UPDATE_STATUS, 0x081e, 8, &ElementalRecv::processElementalUpdateStatus, 20100309);
-
-// 20100420
-packet(SMSG_BUYINGSTORE_CREATE_FAILED, 0x0812, 8, &BuyingStoreRecv::processBuyingStoreCreateFailed, 20100420);
-packet(SMSG_BUYINGSTORE_SHOW_BOARD, 0x0814, 86, &BuyingStoreRecv::processBuyingStoreShowBoard, 20100420);
-packet(SMSG_BUYINGSTORE_SELL_FAILED, 0x081a, 4, &BuyingStoreRecv::processBuyingStoreSellFailed, 20100420);
-packet(SMSG_BUYINGSTORE_REPORT, 0x081b, 10, &BuyingStoreRecv::processBuyingStoreReport, 20100420);
-packet(SMSG_BUYINGSTORE_DELETE_ITEM, 0x081c, 10, &BuyingStoreRecv::processBuyingStoreDeleteItem, 20100420);
-packet(SMSG_BUYINGSTORE_SELLER_SELL_FAILED, 0x0824, 6, &BuyingStoreRecv::processBuyingStoreSellerSellFailed, 20100420);
-
-// 20100601
-packet(SMSG_SEARCHSTORE_SEARCH_ACK, 0x0836, 0, &SearchStoreRecv::processSearchAck, 20100601);
-packet(SMSG_SEARCHSTORE_SEARCH_FAILED, 0x0837, 3, &SearchStoreRecv::processSearchFailed, 20100601);
-
-// 20100608
-if (packetVersion >= 20100608)
-{
- packet(SMSG_SEARCHSTORE_OPEN, 0x083a, 4, &SearchStoreRecv::processSearchOpen, 20100608);
- packet(SMSG_SEARCHSTORE_CLICK_ACK, 0x083d, 6, &SearchStoreRecv::processSearchClickAck, 20100608);
-}
-
-// 20100629
-if (packetVersion >= 20100629)
-{
- packet(SMSG_PLAYER_EQUIPMENT, 0x02d0, -1, &InventoryRecv::processPlayerEquipment, 20100629);
- packet(SMSG_PLAYER_STORAGE_EQUIP, 0x02d1, -1, &InventoryRecv::processPlayerStorageEquip, 20100629);
- packet(SMSG_PLAYER_CART_EQUIP, 0x02d2, -1, &InventoryRecv::processPlayerCartEquip, 20100629);
- packet(SMSG_PLAYER_EQUIP, 0x00aa, 9, &InventoryRecv::processPlayerEquip, 20100629);
-}
-
-// 20100701
-if (packetVersion >= 20100701)
-{
- packet(SMSG_SEARCHSTORE_OPEN, 0x083a, 5, &SearchStoreRecv::processSearchOpen, 20100701);
-}
-
-// 20100803
-packet(SMSG_GUILD_EXPULSION, 0x0839, 66, &GuildRecv::processGuildExpulsion, 20100803);
-
-// 20101124
-if (packetVersion >= 20101124)
-{
- packet(SMSG_BEING_MOVE, 0x0856, -1, &BeingRecv::processBeingMove, 20101124);
- packet(SMSG_BEING_VISIBLE, 0x0857, -1, &BeingRecv::processBeingVisible, 20101124);
- packet(SMSG_BEING_SPAWN, 0x0858, -1, &BeingRecv::processBeingSpawn, 20101124);
- packet(SMSG_BEING_VIEW_EQUIPMENT, 0x0859, -1, &BeingRecv::processBeingViewEquipment, 20101124);
-}
-
-// 20110718
-if (packetVersion >= 20110718)
-{
- packet(SMSG_SKILL_ENTRY, 0x08c7, -1, &BeingRecv::processSkillEntry, 20110718);
-}
-
-// 20111005
-packet(SMSG_SKILL_SNAP, 0x08d2, 10, &BeingRecv::processBeingSlide, 20111005);
-
-// 20111010
-packet(CMSG_NAVIGATE_TO, 0x08e2, 27, &BeingRecv::processNavigateTo, 20111010);
-
-// 20120000
-packet(SMSG_LOGIN_ERROR2, 0x083e, 26, &LoginRecv::processLoginError2, 20120000);
-
-// 20120221
-if (packetVersion >= 20120221)
-{
- packet(SMSG_BEING_VISIBLE, 0x0915, -1, &BeingRecv::processBeingVisible, 20120221);
- packet(SMSG_BEING_MOVE, 0x0914, -1, &BeingRecv::processBeingMove, 20120221);
- packet(SMSG_BEING_SPAWN, 0x090f, -1, &BeingRecv::processBeingSpawn, 20120221);
-}
-
-// 20120229
-if (packetVersion >= 20120229)
-{
- packet(SMSG_MERGE_ITEM, 0x096d, -1, &InventoryRecv::processMergeItem, 20120229);
- packet(SMSG_ACK_MERGE_ITEMS, 0x096f, 7, &InventoryRecv::processMergeItemResponse, 20120229);
-}
-
-// 20120410
-packet(SMSG_BEING_CHARM, 0x08cf, 10, &BeingRecv::processBeingCharm, 20120410);
-packet(SMSG_RECRUIT_REGISTER_ACK, 0x08e6, 4, nullptr, 20120410);
-packet(SMSG_RECRUIT_SEARCH_ACK, 0x08e8, -1, nullptr, 20120410);
-packet(SMSG_RECRUIT_DELETE_ACK, 0x08ea, 4, nullptr, 20120410);
-packet(SMSG_RECRUIT_INSERT_NOTIFY, 0x08ec, 73, nullptr, 20120410);
-packet(SMSG_RECRUIT_UPDATE_NOTIFY, 0x08ed, 43, nullptr, 20120410);
-packet(SMSG_RECRUIT_DELETE_NOTIFY, 0x08ee, 6, nullptr, 20120410);
-packet(SMSG_BOOKING_VOLUNTEER_INFO, 0x08f2, 36, nullptr, 20120410);
-packet(SMSG_BOOKING_REFUSE_VOLUNTEER, 0x08fa, 6, nullptr, 20120410);
-packet(SMSG_PLAYER_FAVORITE_ITEM, 0x0908, 5, &InventoryRecv::processFavoriteItem, 20120410);
-packet(SMSG_MONSTER_HP, 0x0977, 14, &BeingRecv::processMonsterHp, 20120410);
-
-// 20120419
-if (packetVersion >= 20120419)
-{
- packet(SMSG_CHAR_CHARACTERS, 0x099d, -1, &CharServerRecv::processCharCharacters, 20120419);
-}
-
-// 20120502
-if (packetVersion >= 20120502)
-{
- packet(SMSG_RANKS_LIST, 0x097d, 288, &BeingRecv::processRanksList, 20120502);
-}
-
-// 20120618
-if (packetVersion >= 20120618)
-{
- packet(SMSG_BEING_STATUS_CHANGE, 0x0983, 29, &BeingRecv::processBeingStatusChange, 20120618);
-}
-
-// 20120604
-if (packetVersion >= 20120604)
-{
- packet(SMSG_PLAYER_SKILL_COOLDOWN_LIST, 0x0985, -1, &SkillRecv::processSkillCoolDownList, 20120604);
-}
-
-// 20120925
-if (packetVersion >= 20120925)
-{
- packet(SMSG_PLAYER_INVENTORY_ADD, 0x0990, 31, &InventoryRecv::processPlayerInventoryAdd, 20120925);
- packet(SMSG_PLAYER_INVENTORY, 0x0991, -1, &InventoryRecv::processPlayerInventory, 20120925);
- packet(SMSG_PLAYER_EQUIPMENT, 0x0992, -1, &InventoryRecv::processPlayerEquipment, 20120925);
- packet(SMSG_PLAYER_CART_ITEMS, 0x0993, -1, &InventoryRecv::processPlayerCartItems, 20120925);
- packet(SMSG_PLAYER_CART_EQUIP, 0x0994, -1, &InventoryRecv::processPlayerCartEquip, 20120925);
- packet(SMSG_PLAYER_STORAGE_ITEMS, 0x0995, -1, &InventoryRecv::processPlayerStorage, 20120925);
- packet(SMSG_PLAYER_STORAGE_EQUIP, 0x0996, -1, &InventoryRecv::processPlayerStorageEquip, 20120925);
- packet(SMSG_BEING_VIEW_EQUIPMENT, 0x0997, -1, &BeingRecv::processBeingViewEquipment, 20120925);
- packet(SMSG_PLAYER_EQUIP, 0x0999, 11, &InventoryRecv::processPlayerEquip, 20120925);
- packet(SMSG_PLAYER_UNEQUIP, 0x099a, 9, &InventoryRecv::processPlayerUnEquip, 20120925);
-}
-
-// 20121010
-packet(SMSG_MAP_TYPE_PROPERTY2, 0x099b, 8, &BeingRecv::processMapTypeProperty, 20121010);
-
-// 20121212
-if (packetVersion >= 20121212)
-{
- packet(SMSG_SKILL_ENTRY, 0x099f, -1, &BeingRecv::processSkillEntry, 20121212);
-}
-
-// 20130000
-if (packetVersion >= 20130000)
-{
- packet(SMSG_ITEM_DROPPED, 0x084b, 19, &ItemRecv::processItemDropped, 20130000);
-}
-
-// 20130710
-packet(SMSG_PLAYER_RANK_POINTS, 0x097e, 12, &PlayerRecv::processPlayerRankPoints, 20130710);
-
-// 20130724
-packet(SMSG_BANK_STATUS, 0x09a6, 12, &BankRecv::processBankStatus, 20130724);
-packet(SMSG_BANK_DEPOSIT, 0x09a8, 16, &BankRecv::processBankDeposit, 20130724);
-packet(SMSG_BANK_WITHDRAW, 0x09aa, 16, &BankRecv::processBankWithdraw, 20130724);
-
-// 20130731
-if (packetVersion >= 20130731)
-{
- packet(SMSG_SKILL_ENTRY, 0x09ca, -1, &BeingRecv::processSkillEntry, 20130731);
-}
-
-// 20131218
-packet(SMSG_MAIL2_MAIL_LIST_PAGE, 0x09f0, -1, &Mail2Recv::processMailListPage, 20131218);
-packet(SMSG_MAIL2_MAIL_DELETE, 0x09f6, 11, &Mail2Recv::processMailDelete, 20131218);
-
-// 20131223
-if (packetVersion >= 20131223)
-{
- packet(SMSG_BEING_ACTION2, 0x08c8, 34, &BeingRecv::processBeingAction2, 20131223);
- packet(SMSG_NPC_MARKET_OPEN, 0x09d5, -1, &MarketRecv::processMarketOpen, 20131223);
- packet(SMSG_NPC_MARKET_BUY_ACK, 0x09d7, -1, &MarketRecv::processMarketBuyAck, 20131223);
- packet(SMSG_BEING_MOVE, 0x09db, -1, &BeingRecv::processBeingMove, 20131223);
- packet(SMSG_BEING_SPAWN, 0x09dc, -1, &BeingRecv::processBeingSpawn, 20131223);
- packet(SMSG_BEING_VISIBLE, 0x09dd, -1, &BeingRecv::processBeingVisible, 20131223);
- packet(SMSG_WHISPER_RESPONSE, 0x09df, 7, &ChatRecv::processWhisperResponse, 20131223);
- packet(SMSG_SKILL_NO_DAMAGE, 0x09cb, 17, &Ea::BeingRecv::processSkillNoDamage, 20131223);
-}
-
-// 20131230
-packet(SMSG_MAIL2_SEND_RESULT, 0x09ed, 3, &Mail2Recv::processSendResult, 20131230);
-
-// 20140409
-packet(SMSG_MAIL2_REQUEST_MONEY, 0x09f2, 12, &Mail2Recv::processRequestMoney, 20140409);
-packet(SMSG_MAIL2_REQUEST_ITEMS, 0x09f4, 12, &Mail2Recv::processRequestItems, 20140409);
-
-// 20140115
-packet(SMSG_MAIL2_READ_MAIL, 0x09eb, -1, &Mail2Recv::processReadMail, 20140115);
-
-// 20140416
-packet(SMSG_MAIL2_OPEN_NEW_MAIL_WINDOW, 0x0a12, 27, &Mail2Recv::processOpenNewMailWindow, 20140416);
-
-// 20140521
-packet(SMSG_MAIL2_REMOVE_ITEM_RESULT, 0x0a07, 9, &Mail2Recv::processRemoveItemResult, 20140521);
-packet(SMSG_MAIL2_CHECK_NAME_RESULT, 0x0a14, 10, &Mail2Recv::processCheckNameResult, 20140521);
-
-// 20140613
-if (packetVersion >= 20140613)
-{
- packet(SMSG_BATTLE_UPDATE_HP, 0x0a0e, 14, &BattleGroundRecv::processBattleUpdateHp, 20140613);
-}
-
-// 20141016
-packet(SMSG_ROULETTE_OPEN_ACK, 0x0a1a, 23, &RouletteRecv::processRouletteOpenAck, 20141016);
-packet(SMSG_ROULETTE_INFO_ACK_TYPE, 0x0a1c, -1, &RouletteRecv::processRouletteInfoAckType, 20141016);
-packet(SMSG_ROULETTE_GENERATE_ACK_TYPE, 0x0a20, 21, &RouletteRecv::processRouletteGenerateAckType, 20141016);
-packet(SMSG_ROULETTE_RECV_ITEM_ACK, 0x0a22, 5, &RouletteRecv::processRouletteItemAck, 20141016);
-if (packetVersion >= 20141016)
-{
- packet(SMSG_VENDING_REPORT, 0x09e5, 18, &VendingRecv::processReport, 20141016);
- packet(SMSG_BUYINGSTORE_REPORT, 0x09e6, 22, &BuyingStoreRecv::processBuyingStoreReport, 20141016);
-}
-
-// 20141022
-if (packetVersion >= 20141022)
-{
- packet(SMSG_QUEST_LIST, 0x097a, -1, &QuestRecv::processAddQuests, 20141022);
- packet(SMSG_PLAYER_SHORTCUTS, 0x0a00, 269, &PlayerRecv::processPlayerShortcuts, 20141022);
- packet(SMSG_MAP_LOGIN_SUCCESS, 0x0a18, 14, &GameRecv::processMapLogin, 20141022);
- packet(SMSG_VENDING_OPEN_STATUS, 0x0a28, 3, &VendingRecv::processOpenStatus, 20141022);
-}
-
-// 20141112
-packet(SMSG_MAIL2_ICON, 0x09e7, 3, &Mail2Recv::processMailIcon, 20141112);
-
-// 20141119
-packet(SMSG_MAIL2_ADD_ITEM_RESULT, 0x0a05, 53, &Mail2Recv::processAddItemResult, 20141119);
-
-// 0
-// evol packets
-if (serverVersion > 0)
-{
- packet2(SMSG_NPC_COMMAND, 0x0b00, 16, &Ea::NpcRecv::processNpcCommand, 0);
- packet2(SMSG_BEING_NAME_RESPONSE2, 0x0b01, -1, &BeingRecv::processNameResponse2, 0);
- packet2(SMSG_MAP_MASK, 0x0b02, 10, &Ea::PlayerRecv::processMapMask, 0);
- packet2(SMSG_MOB_INFO, 0x0b03, -1, &BeingRecv::processMobInfo, 0);
- packet2(SMSG_BEING_MOVE3, 0x0b04, -1, &Ea::BeingRecv::processBeingMove3, 0);
- packet2(SMSG_MAP_MUSIC, 0x0b05, -1, &Ea::PlayerRecv::processMapMusic, 0);
- packet2(SMSG_NPC_CHANGETITLE, 0x0b06, -1, &Ea::NpcRecv::processChangeTitle, 0);
- packet2(SMSG_CHAT_JOIN_CHANNEL, 0x0b08, 27, &ChatRecv::processJoinChannel, 0);
- packet2(SMSG_BEING_ATTRS, 0x0b0a, -1, &BeingRecv::processBeingAttrs, 0);
- packet2(SMSG_NPC_AREA, 0x0b0b, -1, &NpcRecv::processArea, 0);
- packet2(SMSG_ONLINE_LIST, 0x0b10, -1, &PlayerRecv::processOnlineList, 0);
- packet2(SMSG_PLAYER_CLIENT_COMMAND, 0x0b16, -1, &Ea::PlayerRecv::processPlayerClientCommand, 0);
- packet2(SMSG_BEING_CHANGE_LOOKS_CARDS, 0x0b17, 19, &BeingRecv::processBeingChangeLookCards, 0);
- packet2(SMSG_ITEM_VISIBLE2, 0x0b18, 28, &ItemRecv::processItemVisible2, 0);
- packet2(SMSG_ITEM_DROPPED2, 0x0b19, 28, &ItemRecv::processItemDropped2, 0);
- packet2(SMSG_BATTLE_EMBLEM2, 0x0b1a, 34, &BattleGroundRecv::processBattleEmblem2, 0);
- packet2(SMSG_MAP_SET_TILES_TYPE, 0x0b1b, 34, &Ea::MapRecv::processSetTilesType, 0);
- packet2(SMSG_NPC_SKIN, 0x0b1c, -1, &NpcRecv::processNpcSkin, 0);
- packet2(SMSG_PLAYER_KILLED_BY, 0x0b1d, 6, &PlayerRecv::processKilledBy, 0);
- packet2(SMSG_SKILL_CASTING2, 0x0b1e, -1, &BeingRecv::processSkillCasting2, 0);
- packet2(SMSG_PLAYER_ADD_SKILL2, 0x0b1f, -1, &SkillRecv::processSkillAdd2, 0);
- packet2(SMSG_PLAYER_UPDATE_SKILL2, 0x0b20, -1, &SkillRecv::processSkillUpdate2, 0);
- packet2(SMSG_WALK_ERROR, 0x0b21, 10, &PlayerRecv::processWalkError, 0);
- packet2(SMSG_HOMUNCULUS_EXP, 0x0b22, 10, &HomunculusRecv::processHomunculusExp, 0);
- packet2(SMSG_QUEST_LIST2, 0x0b23, -1, &QuestRecv::processAddQuests2, 0);
- packet2(SMSG_QUEST_ADD2, 0x0b24, 23, &QuestRecv::processAddQuest2, 0);
- packet2(SMSG_PLAYER_ATTRS, 0x0b25, -1, &PlayerRecv::processPlayerAttrs, 0);
-
- // char server
- packet2(SMSG_CHAR_PASSWORD_RESPONSE, 0x0062, 3, &LoginRecv::processCharPasswordResponse, 0);
-}
-
-// 20150226
-if ((serverVersion >= 8 || serverVersion == 0) && packetVersion >= 20150226)
-{
- packet(SMSG_VENDING_OPEN, 0x0136, -1, &VendingRecv::processOpen, 20150226);
- packet(SMSG_VENDING_ITEMS_LIST, 0x0800, -1, &VendingRecv::processItemsList, 20150226);
- packet(SMSG_TRADE_ITEM_ADD, 0x0a09, 45, &TradeRecv::processTradeItemAdd, 20150226);
- packet(SMSG_PLAYER_STORAGE_ADD, 0x0a0a, 47, &InventoryRecv::processPlayerStorageAdd, 20150226);
- packet(SMSG_PLAYER_CART_ADD, 0x0a0b, 47, &InventoryRecv::processPlayerCartAdd, 20150226);
- packet(SMSG_PLAYER_INVENTORY_ADD, 0x0a0c, 56, &InventoryRecv::processPlayerInventoryAdd, 20150226);
- packet(SMSG_PLAYER_EQUIPMENT, 0x0a0d, -1, &InventoryRecv::processPlayerEquipment, 20150226);
- packet(SMSG_PLAYER_CART_EQUIP, 0x0a0f, -1, &InventoryRecv::processPlayerCartEquip, 20150226);
- packet(SMSG_PLAYER_STORAGE_EQUIP, 0x0a10, -1, &InventoryRecv::processPlayerStorageEquip, 20150226);
- packet(SMSG_BEING_VIEW_EQUIPMENT, 0x0a2d, -1, &BeingRecv::processBeingViewEquipment, 20150226);
-}
-
-// 20150513
-if (packetVersion >= 20150513)
-{
- packet(SMSG_DRESS_ROOM_OPEN, 0x0a02, 4, &PlayerRecv::processDressRoomOpen, 20150513);
- packet(SMSG_BEING_VISIBLE, 0x09ff, -1, &BeingRecv::processBeingVisible, 20150513);
- packet(SMSG_BEING_SPAWN, 0x09fe, -1, &BeingRecv::processBeingSpawn, 20150513);
- packet(SMSG_BEING_MOVE, 0x09fd, -1, &BeingRecv::processBeingMove, 20150513);
- packet(SMSG_PLAYER_HEAL, 0x0a27, 8, &PlayerRecv::processPlayerHeal, 20150513);
- packet(SMSG_HOMUNCULUS_INFO, 0x09f7, 75, &HomunculusRecv::processHomunculusInfo, 20150513);
-}
-
-// 20150805
-if (packetVersion >= 20150805)
-{
- packet(SMSG_SELECT_CART, 0x097f, -1, &InventoryRecv::processSelectCart, 20150805);
-}
-
-// 20160330
-if (packetVersion >= 20160330)
-{
- packet(SMSG_MAP_LOGIN_SUCCESS, 0x02eb, 13, &GameRecv::processMapLogin, 20160330);
-}
-
-// 20160622
-if (packetVersion >= 20160622)
-{
- packet(SMSG_GUILD_BASIC_INFO, 0x0a84, 94, &GuildRecv::processGuildBasicInfo, 20160622);
-}
-
-// 20160921
-if (packetVersion >= 20160921)
-{
- packet(SMSG_PLAYER_INVENTORY_ADD, 0x0a37, 59, &InventoryRecv::processPlayerInventoryAdd, 20160921);
- packet(SMSG_VENDING_ITEMS_LIST, 0x0800, -1, &VendingRecv::processItemsList, 20160921);
-}
-
-// 20161026
-if (packetVersion >= 20161026)
-{
- packet(SMSG_GUILD_MEMBER_LIST, 0x0aa5, -1, &GuildRecv::processGuildMemberList, 20161026);
-}
-
-// 20170315
-if (packetVersion >= 20170315)
-{
- packet(SMSG_LOGIN_DATA, 0x0ac4, -1, &LoginRecv::processLoginData, 20170315);
-}
-
-// 20160316
-if (packetVersion >= 20160316)
-{
- packet(SMSG_MAIL2_CHECK_NAME_RESULT, 0x0a51, 34, &Mail2Recv::processCheckNameResult, 20160316);
-}
-
-// 20160601
-if (packetVersion >= 20160601)
-{
- packet(SMSG_MAIL2_MAIL_LIST_PAGE, 0x0a7d, -1, &Mail2Recv::processMailListPage, 20160601);
-}
-
-// 20170329
-if (packetVersion >= 20170329)
-{
- packet(SMSG_CHAR_MAP_INFO, 0x0ac5, 156, &CharServerRecv::processCharMapInfo, 20170329);
-}
-
-// 20170502
-if (packetVersion >= 20170502)
-{
- packet(SMSG_PARTY_MEMBER_INFO, 0x0a43, 85, &PartyRecv::processPartyMemberInfo, 20170502);
- packet(SMSG_PARTY_INFO, 0x0a44, -1, &PartyRecv::processPartyInfo, 20170502);
- packet(SMSG_PARTY_MEMBER_JOB_LEVEL, 0x0abd, 10, &PartyRecv::processPartyMemberJobLevel, 20170502);
-}
-
-// 0
-// evol always packets
-packet(SMSG_SERVER_VERSION_RESPONSE, 0x7531, -1, &LoginRecv::processServerVersion, 0);
-packet(SMSG_UPDATE_HOST, 0x0063, -1, &Ea::LoginRecv::processUpdateHost, 0);
diff --git a/src/net/eathena/packetsout.inc b/src/net/eathena/packetsout.inc
deleted file mode 100644
index 3ce489a09..000000000
--- a/src/net/eathena/packetsout.inc
+++ /dev/null
@@ -1,8044 +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/>.
- */
-
-#define PACKETSOUT_VOID
-
-// 0
-packet(CMSG_SERVER_VERSION_REQUEST, 0x7530, 0, nullptr);
-
-packet(CMSG_LOGIN_REGISTER, 0x0064, 0, lclif->p->parse_CA_LOGIN);
-packet(CMSG_LOGIN_REGISTER2, 0x01dd, 0, lclif->p->parse_CA_LOGIN2);
-packet(CMSG_LOGIN_REGISTER3, 0x01fa, 0, lclif->p->parse_CA_LOGIN3);
-packet(CMSG_LOGIN_REGISTER4, 0x027c, 0, lclif->p->parse_CA_LOGIN4);
-packet(CMSG_LOGIN_REGISTER_PCBANG, 0x0277, 0, lclif->p->parse_CA_LOGIN_PCBANG);
-packet(CMSG_LOGIN_REGISTER_HAN, 0x02b0, 0, lclif->p->parse_CA_LOGIN_HAN);
-packet(CMSG_LOGIN_REGISTER_SSO, 0x0825, -1, lclif->p->parse_CA_SSO_LOGIN_REQ);
-packet(CMSG_LOGIN_REGISTER_KEY, 0x01db, 0, lclif->p->parse_CA_REQ_HASH);
-
-packet(CMSG_NAME_REQUEST, 0x0094, 6, clif->pGetCharNameRequest);
-
-packet(CMSG_CHAR_PASSWORD_CHANGE, 0x0061, 0, nullptr);
-packet(CMSG_CHAR_SERVER_CONNECT, 0x0065, 0, chr->parse_char_connect);
-packet(CMSG_CHAR_SELECT, 0x0066, 3, chr->parse_char_select);
-packet(CMSG_CHAR_CREATE, 0x0067, 0, chr->parse_make_char_0067);
-packet(CMSG_CHAR_DELETE, 0x0068, 56, chr->parse_char_delete_char_0068);
-packet(CMSG_CHAR_DELETE2_REQ, 0x0827, 6, chr->parse_char_delete2_req);
-packet(CMSG_CHAR_DELETE2_ACCEPT, 0x0829, 12, chr->parse_char_delete2_accept);
-packet(CMSG_CHAR_DELETE2_CANCEL, 0x082b, 6, chr->parse_char_delete2_cancel);
-packet(CMSG_CHAR_CREATE_PIN, 0x08ba, 10, chr->parse_char_pincode_first_pin);
-packet(CMSG_CHAR_PIN_CHECK, 0x08b8, 10, chr->parse_char_pincode_check);
-packet(CMSG_CHAR_PIN_CHANGE, 0x08be, 14, chr->parse_char_pincode_change);
-packet(CMSG_CHAR_PIN_WINDOW, 0x08c5, 6, chr->parse_char_pincode_window);
-packet(CMSG_CHAR_REQUEST_CHARS, 0x09a1, 2, chr->parse_char_request_chars);
-packet(CMSG_CHAR_CHECK_RENAME, 0x08fc, 30, chr->parse_char_rename_char);
-packet(CMSG_CHAR_CHECK_RENAME2, 0x028d, 34, chr->parse_char_rename_char2);
-packet(CMSG_CHAR_RENAME, 0x028f, 6, chr->parse_char_rename_char_confirm);
-packet(CMSG_CHAR_CHANGE_SLOT, 0x08d4, 8, chr->parse_char_move_character);
-packet(CMSG_CHAR_REQUEST_CAPTCHA, 0x07e5, 8, chr->parse_char_request_captcha);
-packet(CMSG_CHAR_CHECK_CAPTCHA, 0x07e7, 32, chr->parse_char_check_captcha);
-
-packet(CMSG_MAP_SERVER_CONNECT, 0x0072, 19, clif->pWantToConnection);
-packet(CMSG_MAP_PING, 0x007e, 6, clif->pTickSend);
-packet(CMSG_LOGIN_PING, 0x0200, 0, lclif->p->parse_CA_CONNECT_INFO_CHANGED);
-packet(CMSG_LOGIN_HASH_CHECK, 0x0204, 0, lclif->p->parse_CA_EXE_HASHCHECK);
-
-packet(CMSG_CHAR_PING, 0x0187, 56, chr->parse_char_ping);
-packet(CMSG_MAP_LOADED, 0x007d, 2, clif->pLoadEndAck);
-packet(CMSG_CLIENT_QUIT, 0x018A, 4, clif->pQuitGame);
-
-packet(CMSG_CHAT_MESSAGE, 0x008c, -1, clif->pGlobalMessage);
-packet(CMSG_CHAT_WHISPER, 0x0096, -1, clif->pWisMessage);
-packet(CMSG_CHAT_ROOM_JOIN, 0x00d9, 14, clif->pChatAddMember);
-packet2(CMSG_CHAT_JOIN_CHANNEL, 0x0b07, 0, nullptr);
-packet2(CMSG_CHAT_PART_CHANNEL, 0x0b09, 0, nullptr);
-packet(CMSG_BATTLE_CHAT_MESSAGE, 0x02db, -1, clif->pBattleChat);
-
-packet(CMSG_CREAYE_CHAT_ROOM, 0x00d5, -1, clif->pCreateChatRoom);
-packet(CMSG_LEAVE_CHAT_ROOM, 0x00e3, 2, clif->pChatLeave);
-packet(CMSG_SET_CHAT_ROOM_OPTIONS, 0x00de, -1, clif->pChatRoomStatusChange);
-packet(CMSG_SET_CHAT_ROOM_OWNER, 0x00e0, 30, clif->pChangeChatOwner);
-packet(CMSG_KICK_FROM_CHAT_ROOM, 0x00e2, 26, clif->pKickFromChat);
-
-packet(CMSG_SKILL_LEVELUP_REQUEST, 0x0112, 4, clif->pSkillUp);
-packet(CMSG_STAT_UPDATE_REQUEST, 0x00bb, 5, clif->pStatusUp);
-packet(CMSG_SKILL_USE_BEING, 0x0113, 10, clif->pUseSkillToId);
-packet(CMSG_SKILL_USE_POSITION, 0x0116, 10, clif->pUseSkillToPos);
-packet(CMSG_SKILL_USE_POSITION_MORE, 0x0190, 90, clif->pUseSkillToPosMoreInfo);
-packet(CMSG_SKILL_USE_MAP, 0x011b, 20, clif->pUseSkillMap);
-
-packet(CMSG_PLAYER_INVENTORY_USE, 0x0439, 8, clif->pUseItem);
-packet(CMSG_PLAYER_INVENTORY_DROP, 0x00a2, 6, clif->pDropItem);
-packet(CMSG_PLAYER_EQUIP, 0x00a9, 6, clif->pEquipItem);
-packet(CMSG_PLAYER_UNEQUIP, 0x00ab, 4, clif->pUnequipItem);
-packet(CMSG_PLAYER_USE_CARD, 0x017a, 4, clif->pUseCard);
-packet(CMSG_PLAYER_INSERT_CARD, 0x017c, 6, clif->pInsertCard);
-packet(CMSG_PLAYER_VIEW_EQUIPMENT, 0x02d6, 6, clif->pViewPlayerEquip);
-packet(CMSG_PLAYER_SET_EQUIPMENT_VISIBLE, 0x02d8, 10, clif->pEquipTick);
-
-packet(CMSG_ITEM_PICKUP, 0x009f, 6, clif->pTakeItem);
-packet(CMSG_PLAYER_CHANGE_DIR, 0x009b, 5, clif->pChangeDir);
-packet(CMSG_PLAYER_CHANGE_DEST, 0x0085, 5, clif->pWalkToXY);
-packet(CMSG_PLAYER_CHANGE_ACT, 0x0089, 7, clif->pActionRequest);
-packet(CMSG_PLAYER_RESTART, 0x00b2, 3, clif->pRestart);
-packet(CMSG_PLAYER_EMOTE, 0x00bf, 3, clif->pEmotion);
-packet(CMSG_PLAYER_STOP_ATTACK, 0x0118, 2, clif->pStopAttack);
-packet(CMSG_WHO_REQUEST, 0x00c1, 2, clif->pHowManyConnections);
-
-packet(CMSG_NPC_TALK, 0x0090, 7, clif->pNpcClicked);
-packet(CMSG_NPC_NEXT_REQUEST, 0x00b9, 6, clif->pNpcNextClicked);
-packet(CMSG_NPC_CLOSE, 0x0146, 6, clif->pNpcCloseClicked);
-packet(CMSG_NPC_LIST_CHOICE, 0x00b8, 7, clif->pNpcSelectMenu);
-packet(CMSG_NPC_INT_RESPONSE, 0x0143, 10, clif->pNpcAmountInput);
-packet(CMSG_NPC_STR_RESPONSE, 0x01d5, -1, clif->pNpcStringInput);
-packet(CMSG_NPC_BUY_SELL_REQUEST, 0x00c5, 7, clif->pNpcBuySellSelected);
-packet(CMSG_NPC_BUY_REQUEST, 0x00c8, -1, clif->pNpcBuyListSend);
-packet(CMSG_NPC_SELL_REQUEST, 0x00c9, -1, clif->pNpcSellListSend);
-
-packet(CMSG_TRADE_REQUEST, 0x00e4, 6, clif->pTradeRequest);
-packet(CMSG_TRADE_RESPONSE, 0x00e6, 3, clif->pTradeAck);
-packet(CMSG_TRADE_ITEM_ADD_REQUEST, 0x00e8, 8, clif->pTradeAddItem);
-packet(CMSG_TRADE_CANCEL_REQUEST, 0x00ed, 2, clif->pTradeCancel);
-packet(CMSG_TRADE_ADD_COMPLETE, 0x00eb, 2, clif->pTradeOk);
-packet(CMSG_TRADE_OK, 0x00ef, 2, clif->pTradeCommit);
-
-packet(CMSG_PARTY_CREATE, 0x00f9, 26, clif->pCreateParty);
-packet(CMSG_PARTY_CREATE2, 0x01e8, 28, clif->pCreateParty2);
-packet(CMSG_PARTY_INVITE, 0x00fc, 6, clif->pPartyInvite);
-packet(CMSG_PARTY_INVITED, 0x00ff, 10, clif->pReplyPartyInvite);
-packet(CMSG_PARTY_INVITED2, 0x02c7, 7, clif->pReplyPartyInvite2);
-packet(CMSG_PARTY_LEAVE, 0x0100, 2, clif->pLeaveParty);
-packet(CMSG_PARTY_SETTINGS, 0x0102, 6, clif->pPartyChangeOption);
-packet(CMSG_PARTY_KICK, 0x0103, 30, clif->pRemovePartyMember);
-packet(CMSG_PARTY_MESSAGE, 0x0108, -1, clif->pPartyMessage);
-packet(CMSG_PARTY_CHANGE_LEADER, 0x07da, 6, clif->pPartyChangeLeader);
-packet(CMSG_PARTY_ALLOW_INVITES, 0x02c8, 3, clif->pPartyTick);
-
-packet(CMSG_MOVE_TO_STORAGE, 0x00f3, 8, clif->pMoveToKafra);
-packet(CMSG_MOVE_FROM_STORAGE, 0x00f5, 8, clif->pMoveFromKafra);
-packet(CMSG_CLOSE_STORAGE, 0x00f7, 2, clif->pCloseKafra);
-
-packet(CMSG_MOVE_TO_CART, 0x0126, 8, clif->pPutItemToCart);
-packet(CMSG_MOVE_FROM_CART, 0x0127, 8, clif->pGetItemFromCart);
-packet(CMSG_CHANGE_CART, 0x01af, 4, clif->pChangeCart);
-packet(CMSG_MOVE_FROM_STORAGE_TO_CART, 0x0128, 8, clif->pMoveFromKafraToCart);
-packet(CMSG_MOVE_FROM_CART_TO_STORAGE, 0x0129, 8, clif->pMoveToKafraFromCart);
-
-packet(CMSG_ADMIN_ANNOUNCE, 0x0099, -1, clif->pBroadcast);
-packet(CMSG_ADMIN_LOCAL_ANNOUNCE, 0x019C, -1, clif->pLocalBroadcast);
-packet(CMSG_ADMIN_HIDE, 0x019D, 6, clif->pGMHide);
-packet(CMSG_ADMIN_KICK, 0x00CC, 6, clif->pGMKick);
-packet(CMSG_ADMIN_KICK_ALL, 0x00ce, 2, clif->pGMKickAll);
-packet(CMSG_ADMIN_RESET_PLAYER, 0x0197, 4, clif->pResetChar);
-packet(CMSG_ADMIN_GOTO, 0x01bb, 26, clif->pGMShift);
-packet(CMSG_ADMIN_RECALL, 0x01bd, 26, clif->pGMRecall);
-packet(CMSG_ADMIN_MUTE, 0x0149, 9, clif->pGMReqNoChat);
-packet(CMSG_ADMIN_MUTE_NAME, 0x0212, 26, clif->pGMRc);
-packet(CMSG_ADMIN_ID_TO_LOGIN, 0x01df, 6, clif->pGMReqAccountName);
-packet(CMSG_ADMIN_SET_TILE_TYPE, 0x0198, 8, clif->pGMChangeMapType);
-packet(CMSG_ADMIN_UNEQUIP_ALL, 0x07f5, 6, clif->pGMFullStrip);
-packet(CMSG_ADMIN_REQUEST_STATS, 0x0213, 26, clif->pCheck);
-packet(CMSG_ADMIN_MONSTER_ITEM, 0x013f, 26, clif->pGM_Monster_Item);
-
-packet(CMSG_GUILD_CHECK_MASTER, 0x014d, 2, clif->pGuildCheckMaster);
-packet(CMSG_GUILD_REQUEST_INFO, 0x014f, 6, clif->pGuildRequestInfo);
-packet(CMSG_GUILD_REQUEST_EMBLEM, 0x0151, 6, clif->pGuildRequestEmblem);
-packet(CMSG_GUILD_CHANGE_EMBLEM, 0x0153, -1, clif->pGuildChangeEmblem);
-packet(CMSG_GUILD_CHANGE_MEMBER_POS, 0x0155, -1, clif->pGuildChangeMemberPosition);
-packet(CMSG_GUILD_LEAVE, 0x0159, 54, clif->pGuildLeave);
-packet(CMSG_GUILD_EXPULSION, 0x015b, 54, clif->pGuildExpulsion);
-packet(CMSG_GUILD_BREAK, 0x015d, 42, clif->pGuildBreak);
-packet(CMSG_GUILD_CHANGE_POS_INFO, 0x0161, -1, clif->pGuildChangePositionInfo);
-packet(CMSG_GUILD_CREATE, 0x0165, 30, clif->pCreateGuild);
-packet(CMSG_GUILD_INVITE, 0x0168, 14, clif->pGuildInvite);
-packet(CMSG_GUILD_INVITE_REPLY, 0x016b, 10, clif->pGuildReplyInvite);
-packet(CMSG_GUILD_CHANGE_NOTICE, 0x016e, 186, clif->pGuildChangeNotice);
-packet(CMSG_GUILD_ALLIANCE_REQUEST, 0x0170, 14, clif->pGuildRequestAlliance);
-packet(CMSG_GUILD_ALLIANCE_REPLY, 0x0172, 10, clif->pGuildReplyAlliance);
-packet(CMSG_GUILD_MESSAGE, 0x017e, -1, clif->pGuildMessage);
-packet(CMSG_GUILD_OPPOSITION, 0x0180, 6, clif->pGuildOpposition);
-packet(CMSG_GUILD_ALLIANCE_DELETE, 0x0183, 10, clif->pGuildDelAlliance);
-
-packet(CMSG_SOLVE_CHAR_NAME, 0x0193, 6, clif->pSolveCharName);
-packet(CMSG_IGNORE_ALL, 0x00d0, 3, clif->pPMIgnoreAll);
-packet(CMSG_IGNORE_NICK, 0x00cf, 27, clif->pPMIgnore);
-packet(CMSG_REQUEST_IGNORE_LIST, 0x00d3, 2, clif->pPMIgnoreList);
-packet(CMSG_SET_SHORTCUTS, 0x02ba, 11, clif->pHotkey);
-packet(CMSG_NPC_COMPLETE_PROGRESS_BAR, 0x02f1, 2, clif->pProgressbar);
-packet(CMSG_NPC_PRODUCE_MIX, 0x018e, 10, clif->pProduceMix);
-packet(CMSG_NPC_COOKING, 0x025b, 6, clif->pCooking);
-packet(CMSG_NPC_REPAIR, 0x01fd, 15, clif->pRepairItem);
-packet(CMSG_NPC_REFINE, 0x0222, 6, clif->pWeaponRefine);
-packet(CMSG_NPC_IDENTIFY, 0x0178, 4, clif->pItemIdentify);
-packet(CMSG_NPC_SELECT_ARROW, 0x01ae, 4, clif->pSelectArrow);
-packet(CMSG_NPC_SELECT_AUTO_SPELL, 0x01ce, 6, clif->pAutoSpell);
-
-packet(CMSG_PLAYER_MAPMOVE, 0x0140, 22, clif->pMapMove);
-packet(CMSG_REMOVE_OPTION, 0x012a, 2, clif->pRemoveOption);
-packet(CMSG_PLAYER_SET_MEMO, 0x011d, 2, clif->pRequestMemo);
-
-packet(CMSG_PET_CATCH, 0x019f, 6, clif->pCatchPet);
-packet(CMSG_PET_SEND_MESSAGE, 0x01a9, 6, clif->pSendEmotion);
-packet(CMSG_PET_SET_NAME, 0x01a5, 26, clif->pChangePetName);
-packet(CMSG_PET_SELECT_EGG, 0x01a7, 4, clif->pSelectEgg);
-packet(CMSG_PET_MENU_ACTION, 0x01a1, 3, clif->pPetMenu);
-packet2(CMSG_PET_TALK, 0x0b0c, 0, nullptr);
-packet2(CMSG_PET_EMOTE, 0x0b0d, 0, nullptr);
-packet2(CMSG_PET_MOVE_TO, 0x0b11, 0, nullptr);
-packet2(CMSG_PET_DIRECTION, 0x0b12, 0, nullptr);
-
-packet(CMSG_MERCENARY_ACTION, 0x029f, 3, clif->pmercenary_action);
-packet(CMSG_HOMUNCULUS_SET_NAME, 0x0231, 26, clif->pChangeHomunculusName);
-packet(CMSG_HOMMERC_MOVE_TO_MASTER, 0x0234, 6, clif->pHomMoveToMaster);
-packet(CMSG_HOMMERC_MOVE_TO, 0x0232, 9, clif->pHomMoveTo);
-packet(CMSG_HOMMERC_ATTACK, 0x0233, 11, clif->pHomAttack);
-packet2(CMSG_HOMMERC_TALK, 0x0b13, 0, nullptr);
-packet2(CMSG_HOMMERC_EMOTE, 0x0b14, 0, nullptr);
-packet2(CMSG_HOMMERC_DIRECTION, 0x0b15, 0, nullptr);
-
-packet(CMSG_DORI_DORI, 0x01e7, 2, clif->pNoviceDoriDori);
-packet(CMSG_EXPLOSION_SPIRITS, 0x01ed, 2, clif->pNoviceExplosionSpirits);
-packet(CMSG_PVP_INFO, 0x020f, 10, clif->pPVPInfo);
-packet(CMSG_PLAYER_AUTO_REVIVE, 0x0292, 2, clif->pAutoRevive);
-packet(CMSG_QUEST_ACTIVATE, 0x02b6, 7, clif->pquestStateAck);
-
-packet(CMSG_MAIL_REFRESH_INBOX, 0x023f, 2, clif->pMail_refreshinbox);
-packet(CMSG_MAIL_READ_MESSAGE, 0x0241, 6, clif->pMail_read);
-packet(CMSG_MAIL_GET_ATTACH, 0x0244, 6, clif->pMail_getattach);
-packet(CMSG_MAIL_DELETE_MESSAGE, 0x0243, 6, clif->pMail_delete);
-packet(CMSG_MAIL_RETURN_MESSAGE, 0x0273, 30, clif->pMail_return);
-packet(CMSG_MAIL_SET_ATTACH, 0x0247, 8, clif->pMail_setattach);
-packet(CMSG_MAIL_RESET_ATTACH, 0x0246, 4, clif->pMail_winopen);
-packet(CMSG_MAIL_SEND, 0x0248, -1, clif->pMail_send);
-
-packet(CMSG_FAMILY_ASK_FOR_CHILD, 0x01f9, 6, clif->pAdopt_request);
-packet(CMSG_FAMILY_ASK_FOR_CHILD_REPLY, 0x01f7, 14, clif->pAdopt_reply);
-
-packet(CMSG_FRIENDS_ADD_PLAYER, 0x0202, 26, clif->pFriendsListAdd);
-packet(CMSG_FRIENDS_REQUEST_ACK, 0x0208, 14, clif->pFriendsListReply);
-packet(CMSG_FRIENDS_DELETE_PLAYER, 0x0203, 10, clif->pFriendsListRemove);
-
-packet(CMSG_AUCTION_CANCEL_REG, 0x024b, 4, clif->pAuction_cancelreg);
-packet(CMSG_AUCTION_SET_ITEM, 0x024c, 8, clif->pAuction_setitem);
-packet(CMSG_AUCTION_REGISTER, 0x024d, 12, clif->pAuction_register);
-packet(CMSG_AUCTION_CANCEL, 0x024e, 6, clif->pAuction_cancel);
-packet(CMSG_AUCTION_CLOSE, 0x025d, 6, clif->pAuction_close);
-packet(CMSG_AUCTION_BID, 0x024f, 10, clif->pAuction_bid);
-packet(CMSG_AUCTION_SEARCH, 0x0251, 34, clif->pAuction_search);
-packet(CMSG_AUCTION_BUY_SELL, 0x025c, 4, clif->pAuction_buysell);
-
-packet(CMSG_VENDING_CLOSE, 0x012e, 2, clif->pCloseVending);
-packet(CMSG_VENDING_LIST_REQ, 0x0130, 6, clif->pVendingListReq);
-packet(CMSG_VENDING_BUY, 0x0134, -1, clif->pPurchaseReq);
-packet(CMSG_VENDING_BUY2, 0x0801, -1, clif->pPurchaseReq2);
-packet(CMSG_VENDING_CREATE_SHOP, 0x01b2, -1, clif->pOpenVending);
-
-
-packet(CMSG_MERGE_ITEM_ACK, 0x096e, -1, clif->ackmergeitems);
-packet(CMSG_MERGE_ITEM_CANCEL, 0x0974, 2, clif->cancelmergeitem);
-
-packet2(CMSG_SET_STATUS, 0x0b0e, 0, nullptr);
-
-packet2(CMSG_ONLINE_LIST, 0x0b0f, 0, nullptr);
-
-packet2(CMSG_PLAYER_INVENTORY_USE2, 0x0b26, 6, nullptr);
-
-#ifndef PACKETS_UPDATE
-// 0
-packet(CMSG_ALCHEMIST_RANKS, 0x0000, 0, nullptr);
-packet(CMSG_BLACKSMITH_RANKS, 0x0000, 0, nullptr);
-packet(CMSG_PK_RANKS, 0x0000, 0, nullptr);
-packet(CMSG_TAEKWON_RANKS, 0x0000, 0, nullptr);
-packet(CMSG_BUYINGSTORE_CLOSE, 0x0000, 0, nullptr);
-packet(CMSG_BUYINGSTORE_CREATE, 0x0000, 0, nullptr);
-packet(CMSG_BUYINGSTORE_SELL, 0x0000, 0, nullptr);
-packet(CMSG_SEARCHSTORE_SEARCH, 0x0000, 0, nullptr);
-packet(CMSG_SEARCHSTORE_CLOSE, 0x0000, 0, nullptr);
-packet(CMSG_HOMUNCULUS_MENU, 0x0000, 0, nullptr);
-packet(CMSG_SEARCHSTORE_CLICK, 0x0000, 0, nullptr);
-packet(CMSG_BUYINGSTORE_OPEN, 0x0000, 0, nullptr);
-packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0000, 0, nullptr);
-packet(CMSG_QUICK_IDENTIFY_ITEM, 0x0000, 0, nullptr);
-packet(CMSG_PARTY_INVITE2, 0x0000, 0, nullptr);
-packet(CMSG_SKILL_FEEL_SAVE_OK, 0x0000, 0, nullptr);
-packet(CMSG_SKILL_SELECT_MENU, 0x0000, 0, nullptr);
-packet(CMSG_PLAYER_LESS_EFFECTS, 0x0000, 0, nullptr);
-packet(CMSG_SHORTCUTS_ROW_SHIFT, 0x0000, 0, nullptr);
-packet(CMSG_NPC_SHOP_CLOSE, 0x0000, 0, nullptr);
-packet(CMSG_NPC_MARKET_BUY, 0x0000, 0, nullptr);
-packet(CMSG_NPC_MARKET_CLOSE, 0x0000, 0, nullptr);
-packet(CMSG_BANK_DEPOSIT, 0x0000, 0, nullptr);
-packet(CMSG_BANK_WITHDRAW, 0x0000, 0, nullptr);
-packet(CMSG_BANK_CHECK, 0x0000, 0, nullptr);
-packet(CMSG_BANK_OPEN, 0x0000, 0, nullptr);
-packet(CMSG_BANK_CLOSE, 0x0000, 0, nullptr);
-packet(CMSG_REQUEST_RANKS, 0x0000, 0, nullptr);
-packet(CMSG_PLAYER_FAVORITE_ITEM, 0x0000, 0, nullptr);
-packet(CMSG_BATTLE_REGISTER, 0x0000, 0, nullptr);
-packet(CMSG_BATTLE_REVOKE, 0x0000, 0, nullptr);
-packet(CMSG_BATTLE_BEGIN_ACK, 0x0000, 0, nullptr);
-packet(CMSG_BATTLE_CHECK_STATE, 0x0000, 0, nullptr);
-packet(CMSG_NPC_CASH_SHOP_BUY, 0x0000, 0, nullptr);
-packet(CMSG_NPC_CASH_SHOP_BUY1, 0x0000, 0, nullptr);
-packet(CMSG_NPC_CASH_SHOP_CLOSE, 0x0000, 0, nullptr);
-packet(CMSG_NPC_CASH_SHOP_OPEN, 0x0000, 0, nullptr);
-packet(CMSG_NPC_CASH_SHOP_REQUEST_TAB, 0x0000, 0, nullptr);
-packet(CMSG_NPC_CASH_SHOP_SCHEDULE, 0x0000, 0, nullptr);
-packet(CMSG_GUILD_INVITE2, 0x0000, 0, nullptr);
-packet(CMSG_STORAGE_PASSWORD, 0x0000, 0, nullptr);
-packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0000, 0, nullptr);
-packet(CMSG_SELECT_CART, 0x0000, 0, nullptr);
-packet(CMSG_ROULETTE_INFO, 0x0000, 0, nullptr);
-packet(CMSG_ROULETTE_GENERATE, 0x0000, 0, nullptr);
-packet(CMSG_ROULETTE_OPEN, 0x0000, 0, nullptr);
-packet(CMSG_ROULETTE_CLOSE, 0x0000, 0, nullptr);
-packet(CMSG_ROULETTE_RECV_ITEM, 0x0000, 0, nullptr);
-packet(CMSG_ADMIN_RECALL2, 0x0000, 0, nullptr);
-packet(CMSG_ADMIN_REMOVE2, 0x0000, 0, nullptr);
-packet(CMSG_BOOKING_REGISTER_REQ, 0x0000, 0, nullptr);
-packet(CMSG_BOOKING_SEARCH_REQ, 0x0000, 0, nullptr);
-packet(CMSG_BOOKING_DELETE_REQ, 0x0000, 0, nullptr);
-packet(CMSG_BOOKING_UPDATE_REQ, 0x0000, 0, nullptr);
-packet(CMSG_MAIL2_CHECK_NAME, 0x0000, 0, nullptr);
-packet(CMSG_MAIL2_OPEN_WRITE_MAIL, 0x0000, 0, nullptr);
-packet(CMSG_MAIL2_ADD_ITEM_TO_MAIL, 0x0000, 0, nullptr);
-packet(CMSG_MAIL2_REMOVE_ITEM_MAIL, 0x0000, 0, nullptr);
-packet(CMSG_MAIL2_SEND_MAIL, 0x0000, 0, nullptr);
-packet(CMSG_MAIL2_NEXT_PAGE, 0x0000, 0, nullptr);
-packet(CMSG_MAIL2_READ_MAIL, 0x0000, 0, nullptr);
-packet(CMSG_MAIL2_DELETE_MAIL, 0x0000, 0, nullptr);
-packet(CMSG_MAIL2_REQUEST_MONEY, 0x0000, 0, nullptr);
-packet(CMSG_MAIL2_REQUEST_ITEMS, 0x0000, 0, nullptr);
-packet(CMSG_MAIL2_REFRESH_MAIL_LIST, 0x0000, 0, nullptr);
-packet(CMSG_MAIL2_OPEN_MAILBOX, 0x0000, 0, nullptr);
-packet(CMSG_MAIL2_CLOSE_MAILBOX, 0x0000, 0, nullptr);
-packet(CMSG_MAIL2_CANCEL_WRITE_MAIL, 0x0000, 0, nullptr);
-#else
-// 20040713
-if (packetVersion >= 20040713)
-{
- packet(CMSG_PLAYER_CHANGE_DIR, 0x009b, 13, clif->pChangeDir);
- packet(CMSG_ITEM_PICKUP, 0x009f, 10, clif->pTakeItem);
-}
-
-// 20040726
-if (packetVersion >= 20040726)
-{
- packet(CMSG_CHAT_MESSAGE, 0x00f3, -1, clif->pGlobalMessage);
- packet(CMSG_MAP_PING, 0x00f7, 10, clif->pTickSend);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x009f, 13, clif->pChangeDir);
- packet(CMSG_ITEM_PICKUP, 0x0094, 10, clif->pTakeItem);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0072, 14, clif->pDropItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x0113, 16, clif->pMoveToKafra);
-}
-
-// 20040809
-if (packetVersion >= 20040809)
-{
- packet(CMSG_MAP_PING, 0x00f7, 13, clif->pTickSend);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x009f, 12, clif->pChangeDir);
- packet(CMSG_ITEM_PICKUP, 0x0094, 13, clif->pTakeItem);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0072, 17, clif->pDropItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x0113, 23, clif->pMoveToKafra);
-}
-
-// 20040906
-if (packetVersion >= 20040906)
-{
- packet(CMSG_CHAT_MESSAGE, 0x009f, -1, clif->pGlobalMessage);
- packet(CMSG_MAP_PING, 0x0116, 11, clif->pTickSend);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x00f3, 10, clif->pChangeDir);
- packet(CMSG_ITEM_PICKUP, 0x0113, 11, clif->pTakeItem);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0094, 17, clif->pDropItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x007e, 19, clif->pMoveToKafra);
-}
-
-// 20040920
-if (packetVersion >= 20040920)
-{
- packet(CMSG_MAP_PING, 0x0116, 14, clif->pTickSend);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x00f3, 18, clif->pChangeDir);
- packet(CMSG_ITEM_PICKUP, 0x0113, 14, clif->pTakeItem);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0094, 19, clif->pDropItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x007e, 25, clif->pMoveToKafra);
-}
-
-// 20041005
-if (packetVersion >= 20041005)
-{
- packet(CMSG_MAP_PING, 0x0116, 10, clif->pTickSend);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x00f3, 13, clif->pChangeDir);
- packet(CMSG_ITEM_PICKUP, 0x0113, 10, clif->pTakeItem);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0094, 14, clif->pDropItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x007e, 16, clif->pMoveToKafra);
-}
-
-// 20041025
-if (packetVersion >= 20041025)
-{
- packet(CMSG_MAP_PING, 0x0116, 9, clif->pTickSend);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x00f3, 15, clif->pChangeDir);
- packet(CMSG_ITEM_PICKUP, 0x0113, 9, clif->pTakeItem);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0094, 12, clif->pDropItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x007e, 13, clif->pMoveToKafra);
-}
-
-// 20041108
-if (packetVersion >= 20041108)
-{
- packet(CMSG_ALCHEMIST_RANKS, 0x0218, 2, clif->pAlchemist);
- packet(CMSG_BLACKSMITH_RANKS, 0x0217, 2, clif->pBlacksmith);
-}
-
-// 20041115
-if (packetVersion >= 20041115)
-{
- packet(CMSG_PLAYER_LESS_EFFECTS, 0x021d, 6, clif->pLessEffect);
-}
-
-// 20041129
-if (packetVersion >= 20041129)
-{
- packet(CMSG_CHAT_MESSAGE, 0x0085, -1, clif->pGlobalMessage);
- packet(CMSG_MAP_PING, 0x0089, 7, clif->pTickSend);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x00f3, 8, clif->pChangeDir);
- packet(CMSG_ITEM_PICKUP, 0x00a2, 7, clif->pTakeItem);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0116, 12, clif->pDropItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x0094, 14, clif->pMoveToKafra);
-}
-
-// 20050110
-if (packetVersion >= 20050110)
-{
- packet(CMSG_CHAT_MESSAGE, 0x00f3, -1, clif->pGlobalMessage);
- packet(CMSG_CLOSE_STORAGE, 0x0193, 2, clif->pCloseKafra);
- packet(CMSG_MAP_PING, 0x0089, 9, clif->pTickSend);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0085, 23, clif->pChangeDir);
- packet(CMSG_ITEM_PICKUP, 0x00f5, 9, clif->pTakeItem);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0116, 20, clif->pDropItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x0094, 20, clif->pMoveToKafra);
-}
-
-// 20050328
-if (packetVersion >= 20050328)
-{
- packet(CMSG_TAEKWON_RANKS, 0x0225, 2, clif->pTaekwon);
-}
-
-// 20050425
-if (packetVersion >= 20050425)
-{
- packet(CMSG_HOMUNCULUS_MENU, 0x022d, 5, clif->pHomMenu);
-}
-
-// 20050509
-if (packetVersion >= 20050509)
-{
- packet(CMSG_MAP_PING, 0x0089, 8, clif->pTickSend);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0085, 11, clif->pChangeDir);
- packet(CMSG_ITEM_PICKUP, 0x00f5, 8, clif->pTakeItem);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0116, 10, clif->pDropItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x0094, 14, clif->pMoveToKafra);
-}
-
-// 20050530
-if (packetVersion >= 20050530)
-{
- packet(CMSG_PK_RANKS, 0x0237, 2, clif->pRankingPk);
-}
-
-// 20050628
-if (packetVersion >= 20050628)
-{
- packet(CMSG_MAP_PING, 0x0089, 13, clif->pTickSend);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0085, 17, clif->pChangeDir);
- packet(CMSG_ITEM_PICKUP, 0x00f5, 13, clif->pTakeItem);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0116, 12, clif->pDropItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x0094, 31, clif->pMoveToKafra);
-}
-
-// 20050718
-if (packetVersion >= 20050718)
-{
- packet(CMSG_MAP_PING, 0x0089, 7, clif->pTickSend);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0085, 11, clif->pChangeDir);
- packet(CMSG_ITEM_PICKUP, 0x00f5, 7, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x0094, 21, clif->pMoveToKafra);
-}
-
-// 20050719
-if (packetVersion >= 20050719)
-{
- packet(CMSG_MAP_PING, 0x0089, 13, clif->pTickSend);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0085, 17, clif->pChangeDir);
- packet(CMSG_ITEM_PICKUP, 0x00f5, 13, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x0094, 31, clif->pMoveToKafra);
-}
-
-// 20050817
-if (packetVersion >= 20050817)
-{
- packet(CMSG_SKILL_FEEL_SAVE_OK, 0x0254, 3, clif->pFeelSaveOk);
-}
-
-// 20060327
-if (packetVersion >= 20060327)
-{
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0085, 12, clif->pChangeDir);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0116, 17, clif->pDropItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x0094, 23, clif->pMoveToKafra);
-}
-
-// 20070108
-if (packetVersion >= 20070108)
-{
- packet(CMSG_MAP_PING, 0x0089, 11, clif->pTickSend);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0085, 14, clif->pChangeDir);
- packet(CMSG_ITEM_PICKUP, 0x00f5, 11, clif->pTakeItem);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0116, 19, clif->pDropItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x0094, 17, clif->pMoveToKafra);
-}
-
-// 20070212
-if (packetVersion >= 20070212)
-{
- packet(CMSG_MAP_PING, 0x0089, 8, clif->pTickSend);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0085, 11, clif->pChangeDir);
- packet(CMSG_ITEM_PICKUP, 0x00f5, 8, clif->pTakeItem);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0116, 10, clif->pDropItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x0094, 14, clif->pMoveToKafra);
-}
-
-// 20070227
-if (packetVersion >= 20070227)
-{
- packet(CMSG_PARTY_INVITE2, 0x02c4, 26, clif->pPartyInvite2);
-}
-
-// 20080827
-if (packetVersion >= 20080827)
-{
- packet(CMSG_MAP_PING, 0x0089, 11, clif->pTickSend);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0085, 10, clif->pChangeDir);
- packet(CMSG_ITEM_PICKUP, 0x00f5, 11, clif->pTakeItem);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0116, 17, clif->pDropItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x0094, 19, clif->pMoveToKafra);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x00a7, 9, clif->pWalkToXY);
- packet(CMSG_NAME_REQUEST, 0x008c, 14, clif->pGetCharNameRequest);
- packet(CMSG_SKILL_USE_POSITION, 0x0113, 25, clif->pUseSkillToPos);
- packet(CMSG_SOLVE_CHAR_NAME, 0x00a2, 14, clif->pSolveCharName);
- packet(CMSG_MOVE_FROM_STORAGE, 0x00f7, 17, clif->pMoveFromKafra);
-}
-
-// 20080910
-if (packetVersion >= 20080910)
-{
- packet(CMSG_MAP_SERVER_CONNECT, 0x0436, 19, clif->pWantToConnection);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0437, 7, clif->pActionRequest);
- packet(CMSG_SKILL_USE_BEING, 0x0438, 10, clif->pUseSkillToId);
-}
-
-// 20081210
-if (packetVersion >= 20081210)
-{
- packet(CMSG_SKILL_SELECT_MENU, 0x0443, 8, clif->pSkillSelectMenu);
-}
-
-// 20090603
-if (packetVersion >= 20090603)
-{
- packet(CMSG_PARTY_SETTINGS, 0x07d7, 8, clif->pPartyChangeOption);
-}
-
-// 20091222
-if (packetVersion >= 20091222)
-{
- packet(CMSG_BOOKING_DELETE_REQ, 0x0806, 4, clif->pPartyBookingDeleteReq);
-}
-
-// 20091229
-if (packetVersion >= 20091229)
-{
- packet(CMSG_BOOKING_SEARCH_REQ, 0x0803, 14, clif->pPartyBookingSearchReq);
- packet(CMSG_BOOKING_DELETE_REQ, 0x0806, 2, clif->pPartyBookingDeleteReq);
- packet(CMSG_BOOKING_UPDATE_REQ, 0x0808, 14, clif->pPartyBookingUpdateReq);
-}
-
-// 20100303
-if (packetVersion >= 20100303)
-{
- packet(CMSG_BUYINGSTORE_CREATE, 0x0811, -1, clif->pReqOpenBuyingStore);
-}
-
-// 20100420
-if (packetVersion >= 20100420)
-{
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0815, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_BUYINGSTORE_SELL, 0x0819, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0817, 6, clif->pReqClickBuyingStore);
-}
-
-// 20100601
-if (packetVersion >= 20100601)
-{
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0835, -1, clif->pSearchStoreInfo);
-}
-
-// 20100608
-if (packetVersion >= 20100608)
-{
- packet(CMSG_SEARCHSTORE_CLICK, 0x083c, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0838, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLOSE, 0x083b, 2, clif->pCloseSearchStoreInfo);
-}
-
-// 20100803
-if (packetVersion >= 20100803)
-{
- packet(CMSG_ADMIN_RECALL2, 0x0842, 6, clif->pGMRecall2);
- packet(CMSG_ADMIN_REMOVE2, 0x0843, 6, clif->pGMRemove2);
-}
-
-// 20101124
-if (packetVersion >= 20101124)
-{
- packet(CMSG_MAP_PING, 0x0360, 6, clif->pTickSend);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0361, 5, clif->pChangeDir);
- packet(CMSG_ITEM_PICKUP, 0x0362, 6, clif->pTakeItem);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0363, 6, clif->pDropItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x0364, 8, clif->pMoveToKafra);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0367, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x035f, 5, clif->pWalkToXY);
- packet(CMSG_NAME_REQUEST, 0x0368, 6, clif->pGetCharNameRequest);
- packet(CMSG_SKILL_USE_POSITION, 0x0366, 10, clif->pUseSkillToPos);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0369, 6, clif->pSolveCharName);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0365, 8, clif->pMoveFromKafra);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0436, 19, clif->pWantToConnection);
- packet(CMSG_NPC_CASH_SHOP_BUY, 0x0288, -1, clif->pcashshop_buy);
-}
-
-// 20110614
-if (packetVersion >= 20110614)
-{
- packet(CMSG_NPC_CASH_SHOP_SCHEDULE, 0x08c9, 2, clif->pCashShopSchedule);
-}
-
-// 20110718
-if (packetVersion >= 20110718)
-{
- packet(CMSG_NPC_CASH_SHOP_CLOSE, 0x084a, 2, clif->pCashShopClose);
- packet(CMSG_NPC_CASH_SHOP_OPEN, 0x0844, 2, clif->pCashShopOpen);
- packet(CMSG_NPC_CASH_SHOP_REQUEST_TAB, 0x0846, 4, clif->pCashShopReqTab);
- packet(CMSG_NPC_CASH_SHOP_BUY1, 0x0848, -1, clif->pCashShopBuy);
-}
-
-// 20111005
-if (packetVersion >= 20111005)
-{
- packet(CMSG_NAME_REQUEST, 0x088a, 6, clif->pGetCharNameRequest);
- packet(CMSG_MAP_PING, 0x0817, 6, clif->pTickSend);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0366, 5, clif->pChangeDir);
- packet(CMSG_ITEM_PICKUP, 0x0815, 6, clif->pTakeItem);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0885, 6, clif->pDropItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x0893, 8, clif->pMoveToKafra);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x08ad, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0364, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0369, 10, clif->pUseSkillToPos);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0838, 6, clif->pSolveCharName);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0897, 8, clif->pMoveFromKafra);
- packet(CMSG_BATTLE_REGISTER, 0x08d7, 28, clif->pBGQueueRegister);
- packet(CMSG_BATTLE_REVOKE, 0x08da, 26, clif->pBGQueueRevokeReq);
- packet(CMSG_BATTLE_BEGIN_ACK, 0x08e0, 51, clif->pBGQueueBattleBeginAck);
- packet(CMSG_BATTLE_CHECK_STATE, 0x090a, 26, clif->pBGQueueCheckState);
-}
-
-// 20111102
-if (packetVersion >= 20111102)
-{
- packet(CMSG_SEARCHSTORE_SEARCH, 0x08ab, -1, clif->pSearchStoreInfo);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0835, 19, clif->pWantToConnection); // non PACKETVER_RE
- packet(CMSG_MAP_SERVER_CONNECT, 0x083c, 19, clif->pWantToConnection);
- packet(CMSG_MAP_PING, 0x0899, 6, clif->pTickSend); // non PACKETVER_RE
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x088b, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0892, 5, clif->pWalkToXY); // non PACKETVER_RE
- packet(CMSG_BUYINGSTORE_CLOSE, 0x089b, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x08aa, 7, clif->pActionRequest);
- packet(CMSG_BUYINGSTORE_SELL, 0x089e, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0436, 26, clif->pFriendsListAdd);
- packet(CMSG_SEARCHSTORE_CLICK, 0x08a2, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_BUYINGSTORE_OPEN, 0x08a1, 6, clif->pReqClickBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x0898, 5, clif->pHomMenu);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0835, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_SKILL_USE_BEING, 0x02c4, 10, clif->pUseSkillToId);
- packet(CMSG_PARTY_INVITE2, 0x088d, 26, clif->pPartyInvite2);
- packet(CMSG_STORAGE_PASSWORD, 0x0281, 36, clif->pStoragePassword);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0811, -1, clif->pItemListWindowSelected);
-}
-
-// 20120307
-if (packetVersion >= 20120307)
-{
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0884, -1, clif->pSearchStoreInfo);
- packet(CMSG_MAP_SERVER_CONNECT, 0x086A, 19, clif->pWantToConnection);
- packet(CMSG_CHAR_CREATE, 0x0970, 31, chr->parse_char_create_new_char);
- packet(CMSG_MAP_PING, 0x0887, 6, clif->pTickSend);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0890, 5, clif->pChangeDir);
- packet(CMSG_ITEM_PICKUP, 0x0865, 6, clif->pTakeItem);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x02c4, 6, clif->pDropItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x093b, 8, clif->pMoveToKafra);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0885, 7, clif->pActionRequest);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0369, 26, clif->pFriendsListAdd);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0963, 8, clif->pMoveFromKafra);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x0863, 5, clif->pHomMenu);
- packet(CMSG_SKILL_USE_BEING, 0x0889, 10, clif->pUseSkillToId);
- packet(CMSG_PARTY_INVITE2, 0x0929, 26, clif->pPartyInvite2);
- packet(CMSG_STORAGE_PASSWORD, 0x0861, 36, clif->pStoragePassword);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0870, -1, clif->pItemListWindowSelected);
-}
-
-// 20120410
-if (packetVersion >= 20120410)
-{
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_MAP_SERVER_CONNECT, 0x094b, 19, clif->pWantToConnection);
- packet(CMSG_MAP_PING, 0x0886, 6, clif->pTickSend);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0871, 5, clif->pChangeDir);
- packet(CMSG_ITEM_PICKUP, 0x0938, 6, clif->pTakeItem);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0891, 6, clif->pDropItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x086c, 8, clif->pMoveToKafra);
- packet(CMSG_NAME_REQUEST, 0x0889, 6, clif->pGetCharNameRequest);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0884, 6, clif->pSolveCharName);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x089c, 26, clif->pFriendsListAdd);
- packet(CMSG_MOVE_FROM_STORAGE, 0x08a6, 8, clif->pMoveFromKafra);
- packet(CMSG_HOMUNCULUS_MENU, 0x0885, 5, clif->pHomMenu);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_PLAYER_FAVORITE_ITEM, 0x0907, 5, clif->pMoveItem);
- packet(CMSG_PARTY_INVITE2, 0x091c, 26, clif->pPartyInvite2);
- packet(CMSG_STORAGE_PASSWORD, 0x0961, 36, clif->pStoragePassword);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0945, -1, clif->pItemListWindowSelected);
-}
-
-// 20120418
-if (packetVersion >= 20120418)
-{
- packet(CMSG_HOMUNCULUS_MENU, 0x0361, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0362, 6, clif->pDropItem);
- packet(CMSG_ITEM_PICKUP, 0x07e4, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x07ec, 8, clif->pMoveToKafra);
- packet(CMSG_MAP_SERVER_CONNECT, 0x022d, 19, clif->pWantToConnection);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0202, 5, clif->pChangeDir);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x023b, 26, clif->pFriendsListAdd);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0364, 8, clif->pMoveFromKafra);
- packet(CMSG_HOMUNCULUS_MENU, 0x0361, 5, clif->pHomMenu);
- packet(CMSG_GUILD_INVITE2, 0x0916, 26, clif->pGuildInvite2);
- packet(CMSG_PARTY_INVITE2, 0x0802, 26, clif->pPartyInvite2);
- packet(CMSG_STORAGE_PASSWORD, 0x08a8, 36, clif->pStoragePassword);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0281, -1, clif->pItemListWindowSelected);
-}
-
-// 20120502
-if (packetVersion >= 20120502)
-{
- packet(CMSG_SELECT_CART, 0x0980, 7, clif->pSelectCart);
-}
-
-// 20120702
-if (packetVersion >= 20120702)
-{
- packet(CMSG_MAP_SERVER_CONNECT, 0x0363, 19, clif->pWantToConnection);
- packet(CMSG_MAP_PING, 0x0364, 6, clif->pTickSend);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0960, 5, clif->pChangeDir);
- packet(CMSG_ITEM_PICKUP, 0x089f, 6, clif->pTakeItem);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x089e, 6, clif->pDropItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x08a0, 8, clif->pMoveToKafra);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0889, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0953, 5, clif->pWalkToXY);
- packet(CMSG_NAME_REQUEST, 0x094a, 6, clif->pGetCharNameRequest);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x085a, 7, clif->pActionRequest);
- packet(CMSG_SKILL_USE_POSITION, 0x0863, 10, clif->pUseSkillToPos);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0886, 6, clif->pSolveCharName);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0861, 8, clif->pMoveFromKafra);
- packet(CMSG_SKILL_USE_BEING, 0x0862, 10, clif->pUseSkillToId);
-}
-
-// 20120710
-if (packetVersion >= 20120710)
-{
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0886, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
-}
-
-// 20120716
-if (packetVersion >= 20120716)
-{
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0811, -1, clif->pSearchStoreInfo);
- packet(CMSG_MAP_SERVER_CONNECT, 0x022d, 19, clif->pWantToConnection);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0202, 5, clif->pChangeDir);
- packet(CMSG_ITEM_PICKUP, 0x07e4, 6, clif->pTakeItem);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0362, 6, clif->pDropItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x07ec, 8, clif->pMoveToKafra);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_BUYINGSTORE_SELL, 0x0940, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0364, 8, clif->pMoveFromKafra);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_STORAGE_PASSWORD, 0x0819, 36, clif->pStoragePassword);
-}
-
-// 20120925
-if (packetVersion >= 20120925)
-{
- packet(CMSG_PLAYER_EQUIP, 0x0998, 8, clif->pEquipItem);
-}
-
-// 20130320
-if (packetVersion >= 20130320)
-{
- packet(CMSG_SEARCHSTORE_SEARCH, 0x094e, -1, clif->pSearchStoreInfo);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0888, 19, clif->pWantToConnection);
- packet(CMSG_MAP_PING, 0x0363, 6, clif->pTickSend);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0897, 5, clif->pChangeDir);
- packet(CMSG_ITEM_PICKUP, 0x0933, 6, clif->pTakeItem);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0438, 6, clif->pDropItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x08ac, 8, clif->pMoveToKafra);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x085a, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x092e, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0881, 5, clif->pWalkToXY);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0886, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_NAME_REQUEST, 0x0898, 6, clif->pGetCharNameRequest);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x088e, 7, clif->pActionRequest);
- packet(CMSG_SKILL_USE_POSITION, 0x0959, 10, clif->pUseSkillToPos);
- packet(CMSG_BUYINGSTORE_SELL, 0x0922, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_SOLVE_CHAR_NAME, 0x094c, 6, clif->pSolveCharName);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x086f, 26, clif->pFriendsListAdd);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0365, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0874, 8, clif->pMoveFromKafra);
- packet(CMSG_BUYINGSTORE_OPEN, 0x035f, 6, clif->pReqClickBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x093f, 5, clif->pHomMenu);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0938, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_SKILL_USE_BEING, 0x089b, 10, clif->pUseSkillToId);
- packet(CMSG_PARTY_INVITE2, 0x086d, 26, clif->pPartyInvite2);
- packet(CMSG_STORAGE_PASSWORD, 0x0947, 36, clif->pStoragePassword);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0868, -1, clif->pItemListWindowSelected);
-}
-
-// 20130320
-if (packetVersion >= 20130320)
-{
- packet(CMSG_BANK_DEPOSIT, 0x09a7, 10, clif->pBankDeposit);
- packet(CMSG_BANK_WITHDRAW, 0x09a9, 10, clif->pBankWithdraw);
- packet(CMSG_BANK_CHECK, 0x09ab, 6, clif->pBankCheck);
-}
-
-// 20130417
-if (packetVersion >= 20130417)
-{
- packet(CMSG_BANK_OPEN, 0x09b6, 6, clif->pBankOpen);
- packet(CMSG_BANK_CLOSE, 0x09b8, 6, clif->pBankClose);
-}
-
-// 20130515
-if (packetVersion >= 20130515)
-{
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0943, 19, clif->pWantToConnection);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0362, 5, clif->pChangeDir);
- packet(CMSG_ITEM_PICKUP, 0x08a1, 6, clif->pTakeItem);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0944, 6, clif->pDropItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x0887, 8, clif->pMoveToKafra);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0962, 26, clif->pFriendsListAdd);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_MOVE_FROM_STORAGE, 0x08ac, 8, clif->pMoveFromKafra);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x0931, 5, clif->pHomMenu);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_PARTY_INVITE2, 0x0947, 26, clif->pPartyInvite2);
- packet(CMSG_STORAGE_PASSWORD, 0x093e, 36, clif->pStoragePassword);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0963, -1, clif->pItemListWindowSelected);
-}
-
-// 20130522
-if (packetVersion >= 20130522)
-{
- packet(CMSG_SEARCHSTORE_SEARCH, 0x095b, -1, clif->pSearchStoreInfo);
- packet(CMSG_MAP_SERVER_CONNECT, 0x08a9, 19, clif->pWantToConnection);
- packet(CMSG_MAP_PING, 0x07ec, 6, clif->pTickSend);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0925, 5, clif->pChangeDir);
- packet(CMSG_ITEM_PICKUP, 0x095e, 6, clif->pTakeItem);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x089c, 6, clif->pDropItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x08a3, 8, clif->pMoveToKafra);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0964, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x08aa, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0360, 5, clif->pWalkToXY);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x086e, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_NAME_REQUEST, 0x08a6, 6, clif->pGetCharNameRequest);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x08a2, 7, clif->pActionRequest);
- packet(CMSG_SKILL_USE_POSITION, 0x0811, 10, clif->pUseSkillToPos);
- packet(CMSG_BUYINGSTORE_SELL, 0x0952, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0369, 6, clif->pSolveCharName);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0362, 26, clif->pFriendsListAdd);
- packet(CMSG_SEARCHSTORE_CLICK, 0x093e, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_MOVE_FROM_STORAGE, 0x087e, 8, clif->pMoveFromKafra);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0368, 6, clif->pReqClickBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x0926, 5, clif->pHomMenu);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0874, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_SKILL_USE_BEING, 0x095c, 10, clif->pUseSkillToId);
- packet(CMSG_PARTY_INVITE2, 0x0950, 26, clif->pPartyInvite2);
- packet(CMSG_STORAGE_PASSWORD, 0x088e, 36, clif->pStoragePassword);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x086a, -1, clif->pItemListWindowSelected);
-}
-
-// 20130529
-if (packetVersion >= 20130529)
-{
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0918, -1, clif->pSearchStoreInfo);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0919, 19, clif->pWantToConnection);
- packet(CMSG_MAP_PING, 0x0897, 6, clif->pTickSend);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0951, 5, clif->pChangeDir);
- packet(CMSG_ITEM_PICKUP, 0x0895, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x0938, 8, clif->pMoveToKafra);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x085e, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0941, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0876, 5, clif->pWalkToXY);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0964, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_NAME_REQUEST, 0x0863, 6, clif->pGetCharNameRequest);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0890, 7, clif->pActionRequest);
- packet(CMSG_SKILL_USE_POSITION, 0x0917, 10, clif->pUseSkillToPos);
- packet(CMSG_BUYINGSTORE_SELL, 0x0936, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0937, 6, clif->pSolveCharName);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0877, 26, clif->pFriendsListAdd);
- packet(CMSG_SEARCHSTORE_CLICK, 0x085a, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0957, 8, clif->pMoveFromKafra);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0892, 6, clif->pReqClickBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x023b, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x08a7, 6, clif->pDropItem);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0869, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_SKILL_USE_BEING, 0x0438, 10, clif->pUseSkillToId);
- packet(CMSG_PARTY_INVITE2, 0x08a8, 26, clif->pPartyInvite2);
- packet(CMSG_STORAGE_PASSWORD, 0x0956, 36, clif->pStoragePassword);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0958, -1, clif->pItemListWindowSelected);
-}
-
-// 20130605
-if (packetVersion >= 20130605)
-{
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_MAP_SERVER_CONNECT, 0x022d, 19, clif->pWantToConnection);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0202, 5, clif->pChangeDir);
- packet(CMSG_ITEM_PICKUP, 0x07e4, 6, clif->pTakeItem);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0362, 6, clif->pDropItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x07ec, 8, clif->pMoveToKafra);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x023b, 26, clif->pFriendsListAdd);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0364, 8, clif->pMoveFromKafra);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x0361, 5, clif->pHomMenu);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_REQUEST_RANKS, 0x097c, 4, clif->pRanklist);
- packet(CMSG_PARTY_INVITE2, 0x0802, 26, clif->pPartyInvite2);
- packet(CMSG_STORAGE_PASSWORD, 0x0883, 36, clif->pStoragePassword);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0281, -1, clif->pItemListWindowSelected);
-}
-
-// 20130612
-if (packetVersion >= 20130612)
-{
- packet(CMSG_MAP_SERVER_CONNECT, 0x0919, 19, clif->pWantToConnection);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x087e, 5, clif->pChangeDir);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0940, 26, clif->pFriendsListAdd);
- packet(CMSG_HOMUNCULUS_MENU, 0x093a, 5, clif->pHomMenu);
- packet(CMSG_STORAGE_PASSWORD, 0x0964, 36, clif->pStoragePassword);
-}
-
-// 20130618
-if (packetVersion >= 20130618)
-{
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0281, -1, clif->pSearchStoreInfo);
- packet(CMSG_MAP_SERVER_CONNECT, 0x095b, 19, clif->pWantToConnection);
- packet(CMSG_MAP_PING, 0x0930, 6, clif->pTickSend);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x08a6, 5, clif->pChangeDir);
- packet(CMSG_ITEM_PICKUP, 0x0962, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x0885, 8, clif->pMoveToKafra);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x094f, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0363, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x088e, 5, clif->pWalkToXY);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x085a, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_NAME_REQUEST, 0x0944, 6, clif->pGetCharNameRequest);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0889, 7, clif->pActionRequest);
- packet(CMSG_SKILL_USE_POSITION, 0x096a, 10, clif->pUseSkillToPos);
- packet(CMSG_BUYINGSTORE_SELL, 0x0891, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0945, 6, clif->pSolveCharName);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0953, 26, clif->pFriendsListAdd);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0890, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0936, 8, clif->pMoveFromKafra);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0862, 6, clif->pReqClickBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x02c4, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0917, 6, clif->pDropItem);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0932, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_SKILL_USE_BEING, 0x0951, 10, clif->pUseSkillToId);
- packet(CMSG_PARTY_INVITE2, 0x0887, 26, clif->pPartyInvite2);
- packet(CMSG_STORAGE_PASSWORD, 0x0864, 36, clif->pStoragePassword);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0942, -1, clif->pItemListWindowSelected);
-}
-
-// 20130626
-if (packetVersion >= 20130626)
-{
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_MAP_SERVER_CONNECT, 0x088c, 19, clif->pWantToConnection);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x094d, 5, clif->pChangeDir);
- packet(CMSG_ITEM_PICKUP, 0x088b, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x0921, 8, clif->pMoveToKafra);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0365, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x08ab, 26, clif->pFriendsListAdd);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0817, 8, clif->pMoveFromKafra);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x0960, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0952, 6, clif->pDropItem);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_PARTY_INVITE2, 0x0895, 26, clif->pPartyInvite2);
- packet(CMSG_STORAGE_PASSWORD, 0x0930, 36, clif->pStoragePassword);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x08a5, -1, clif->pItemListWindowSelected);
-}
-
-// 20130703
-if (packetVersion >= 20130703)
-{
- packet(CMSG_MAP_SERVER_CONNECT, 0x022d, 19, clif->pWantToConnection);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0930, 5, clif->pChangeDir);
- packet(CMSG_ITEM_PICKUP, 0x07e4, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x07ec, 8, clif->pMoveToKafra);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0360, 26, clif->pFriendsListAdd);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0364, 8, clif->pMoveFromKafra);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0202, 6, clif->pReqClickBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x094a, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0362, 6, clif->pDropItem);
- packet(CMSG_PARTY_INVITE2, 0x0802, 26, clif->pPartyInvite2);
- packet(CMSG_STORAGE_PASSWORD, 0x0873, 36, clif->pStoragePassword);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0281, -1, clif->pItemListWindowSelected);
-}
-
-// 20130807
-if (packetVersion >= 20130807)
-{
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0202, 5, clif->pChangeDir);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x023b, 26, clif->pFriendsListAdd);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x0361, 5, clif->pHomMenu);
- packet(CMSG_STORAGE_PASSWORD, 0x0887, 36, clif->pStoragePassword);
-}
-
-// 20130814
-if (packetVersion >= 20130814)
-{
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0889, -1, clif->pSearchStoreInfo);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0368, 19, clif->pWantToConnection);
- packet(CMSG_MAP_PING, 0x088a, 6, clif->pTickSend);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x088c, 5, clif->pChangeDir);
- packet(CMSG_ITEM_PICKUP, 0x0926, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x0202, 8, clif->pMoveToKafra);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0962, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0941, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x093a, 5, clif->pWalkToXY);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x094e, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_NAME_REQUEST, 0x0937, 6, clif->pGetCharNameRequest);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0874, 7, clif->pActionRequest);
- packet(CMSG_SKILL_USE_POSITION, 0x0887, 10, clif->pUseSkillToPos);
- packet(CMSG_BUYINGSTORE_SELL, 0x0835, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0923, 6, clif->pSolveCharName);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0281, 26, clif->pFriendsListAdd);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0868, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0873, 8, clif->pMoveFromKafra);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0895, 6, clif->pReqClickBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x0958, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x095f, 6, clif->pDropItem);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0936, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_SKILL_USE_BEING, 0x0947, 10, clif->pUseSkillToId);
- packet(CMSG_PARTY_INVITE2, 0x0927, 26, clif->pPartyInvite2);
- packet(CMSG_STORAGE_PASSWORD, 0x0885, 36, clif->pStoragePassword);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x08a4, -1, clif->pItemListWindowSelected);
-}
-
-// 20130814
-if (packetVersion >= 20130814)
-{
- packet(CMSG_ADMIN_MONSTER_ITEM, 0x09ce, 102, clif->pGM_Monster_Item);
-}
-
-// 20131211
-if (packetVersion >= 20131211)
-{
- packet(CMSG_MAIL2_CLOSE_MAILBOX, 0x09e9, 2, clif->pRodexCloseMailbox);
-}
-
-// 20131218
-if (packetVersion >= 20131218)
-{
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_MAP_SERVER_CONNECT, 0x092f, 19, clif->pWantToConnection);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0947, 5, clif->pChangeDir);
- packet(CMSG_ITEM_PICKUP, 0x07e4, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x07ec, 8, clif->pMoveToKafra);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_BUYINGSTORE_SELL, 0x022d, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x08ab, 26, clif->pFriendsListAdd);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0364, 8, clif->pMoveFromKafra);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x0811, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0362, 6, clif->pDropItem);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_NPC_SHOP_CLOSE, 0x09d4, 2, clif->pNPCShopClosed);
- packet(CMSG_NPC_MARKET_BUY, 0x09d6, -1, clif->pNPCMarketPurchase);
- packet(CMSG_NPC_MARKET_CLOSE, 0x09d8, 2, clif->pNPCMarketClosed);
- packet(CMSG_PARTY_INVITE2, 0x0802, 26, clif->pPartyInvite2);
- packet(CMSG_STORAGE_PASSWORD, 0x085c, 36, clif->pStoragePassword);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0281, -1, clif->pItemListWindowSelected);
-}
-if (packetVersion >= 20131218)
-{
- packet(CMSG_MAIL2_NEXT_PAGE, 0x09ee, 11, clif->pRodexNextMaillist);
- packet(CMSG_MAIL2_DELETE_MAIL, 0x09f5, 11, clif->pRodexDeleteMail);
- packet(CMSG_MAIL2_REFRESH_MAIL_LIST, 0x09ef, 11, clif->pRodexRefreshMaillist);
-}
-
-// 20131223
-if (packetVersion >= 20131223)
-{
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0202, 5, clif->pChangeDir);
- packet(CMSG_MAP_SERVER_CONNECT, 0x022d, 19, clif->pWantToConnection);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x023b, 26, clif->pFriendsListAdd);
- packet(CMSG_HOMUNCULUS_MENU, 0x0361, 5, clif->pHomMenu);
- packet(CMSG_STORAGE_PASSWORD, 0x08a4, 36, clif->pStoragePassword);
-}
-
-if (packetVersion >= 20131223)
-{
- packet(CMSG_MAIL2_READ_MAIL, 0x09ea, 11, clif->pRodexReadMail);
-}
-
-// 20131230
-if (packetVersion >= 20131230)
-{
- packet(CMSG_BUYINGSTORE_CREATE, 0x0365, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_SELL, 0x087f, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x093d, -1, clif->pSearchStoreInfo);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x094c, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x0949, 5, clif->pHomMenu);
- packet(CMSG_SEARCHSTORE_CLICK, 0x087b, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0969, 6, clif->pReqClickBuyingStore);
- packet(CMSG_SKILL_USE_BEING, 0x02C4, 10, clif->pUseSkillToId);
- packet(CMSG_NAME_REQUEST, 0x0926, 6, clif->pGetCharNameRequest);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x094A, 5, clif->pChangeDir);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0860, 6, clif->pDropItem);
- packet(CMSG_SKILL_USE_POSITION, 0x091E, 10, clif->pUseSkillToPos);
- packet(CMSG_ITEM_PICKUP, 0x092A, 6, clif->pTakeItem);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0369, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_MOVE_TO_STORAGE, 0x0968, 8, clif->pMoveToKafra);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x035f, 5, clif->pWalkToXY);
- packet(CMSG_MAP_PING, 0x0438, 6, clif->pTickSend);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0895, 8, clif->pMoveFromKafra);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0871, 7, clif->pActionRequest);
- packet(CMSG_MAP_SERVER_CONNECT, 0x089c, 19, clif->pWantToConnection);
- packet(CMSG_PARTY_INVITE2, 0x08a9, 26, clif->pPartyInvite2);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0943, 26, clif->pFriendsListAdd);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x096a, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0898, 6, clif->pSolveCharName);
- packet(CMSG_STORAGE_PASSWORD, 0x091d, 36, clif->pStoragePassword);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x022d, -1, clif->pItemListWindowSelected);
-}
-if (packetVersion >= 20131230)
-{
- packet(CMSG_MAIL2_SEND_MAIL, 0x09ec, -1, clif->pRodexSendMail);
-}
-
-// 20140108
-if (packetVersion == 20140108)
-{
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0202, 5, clif->pChangeDir);
- packet(CMSG_MAP_SERVER_CONNECT, 0x022d, 19, clif->pWantToConnection);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x023b, 26, clif->pFriendsListAdd);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0281, -1, clif->pItemListWindowSelected);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x0361, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0362, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x0363, 8, clif->pDull);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0364, 8, clif->pMoveFromKafra);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0365, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
-// packet(UNKNOWN, 0x0436, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_ITEM_PICKUP, 0x07e4, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x07ec, 8, clif->pMoveToKafra);
- packet(CMSG_PARTY_INVITE2, 0x0802, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_STORAGE_PASSWORD, 0x0936, 36, clif->pStoragePassword);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20140115
-if (packetVersion == 20140115)
-{
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0361, 6, clif->pDropItem);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0367, 8, clif->pMoveFromKafra);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_NAME_REQUEST, 0x0802, 6, clif->pGetCharNameRequest);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_STORAGE_PASSWORD, 0x0865, 36, clif->pStoragePassword);
- packet(CMSG_BUYINGSTORE_SELL, 0x0887, -1, clif->pReqTradeBuyingStore);
-// packet(UNKNOWN, 0x088a, 8, clif->pDull);
- packet(CMSG_MOVE_TO_STORAGE, 0x088e, 8, clif->pMoveToKafra);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x089b, 26, clif->pFriendsListAdd);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x08a7, 5, clif->pChangeDir);
- packet(CMSG_HOMUNCULUS_MENU, 0x092d, 5, clif->pHomMenu);
- packet(CMSG_ITEM_PICKUP, 0x0940, 6, clif->pTakeItem);
-// packet(UNKNOWN, 0x095b, 4, clif->pDull);
- packet(CMSG_PARTY_INVITE2, 0x095d, 26, clif->pPartyInvite2);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0965, -1, clif->pItemListWindowSelected);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0966, 19, clif->pWantToConnection);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x096a, 18, clif->pPartyBookingRegisterReq);
-}
-
-// 20140122
-if (packetVersion == 20140122)
-{
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0360, 7, clif->pActionRequest);
- packet(CMSG_BUYINGSTORE_OPEN, 0x07ec, 6, clif->pReqClickBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0811, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x0863, 5, clif->pHomMenu);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0870, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0871, 19, clif->pWantToConnection);
- packet(CMSG_PARTY_INVITE2, 0x0872, 26, clif->pPartyInvite2);
-// packet(UNKNOWN, 0x088c, 8, clif->pDull);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0890, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0893, 26, clif->pFriendsListAdd);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0899, -1, clif->pSearchStoreInfo);
- packet(CMSG_NAME_REQUEST, 0x089d, 6, clif->pGetCharNameRequest);
-// packet(UNKNOWN, 0x08a2, 4, clif->pDull);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x08aa, 6, clif->pDropItem);
- packet(CMSG_MAP_PING, 0x0917, 6, clif->pTickSend);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x091a, 5, clif->pChangeDir);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0925, 5, clif->pWalkToXY);
- packet(CMSG_MOVE_TO_STORAGE, 0x092f, 8, clif->pMoveToKafra);
- packet(CMSG_SKILL_USE_BEING, 0x0940, 10, clif->pUseSkillToId);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0941, 6, clif->pSolveCharName);
- packet(CMSG_ITEM_PICKUP, 0x0942, 6, clif->pTakeItem);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x094b, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_MOVE_FROM_STORAGE, 0x094c, 8, clif->pMoveFromKafra);
- packet(CMSG_SKILL_USE_POSITION, 0x0950, 10, clif->pUseSkillToPos);
- packet(CMSG_BUYINGSTORE_SELL, 0x0952, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_STORAGE_PASSWORD, 0x0955, 36, clif->pStoragePassword);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0957, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x095d, -1, clif->pItemListWindowSelected);
- packet(CMSG_BUYINGSTORE_CREATE, 0x095f, -1, clif->pReqOpenBuyingStore);
-}
-
-// 20140129
-if (packetVersion == 20140129)
-{
- packet(CMSG_SKILL_USE_BEING, 0x0281, 10, clif->pUseSkillToId);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
-// packet(UNKNOWN, 0x0361, 8, clif->pDull);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0367, 6, clif->pDropItem);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x07ec, 5, clif->pChangeDir);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0802, 19, clif->pWantToConnection);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
-// packet(UNKNOWN, 0x083c, 4, clif->pDull);
- packet(CMSG_HOMUNCULUS_MENU, 0x0884, 5, clif->pHomMenu);
- packet(CMSG_ITEM_PICKUP, 0x0885, 6, clif->pTakeItem);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0889, 8, clif->pMoveFromKafra);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0921, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0924, -1, clif->pItemListWindowSelected);
- packet(CMSG_STORAGE_PASSWORD, 0x092c, 36, clif->pStoragePassword);
- packet(CMSG_MOVE_TO_STORAGE, 0x094d, 8, clif->pMoveToKafra);
- packet(CMSG_PARTY_INVITE2, 0x0958, 26, clif->pPartyInvite2);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0961, 26, clif->pFriendsListAdd);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20140129
-if (packetVersion >= 20140129)
-{
- packet(CMSG_SHORTCUTS_ROW_SHIFT, 0x0a01, 3, clif->pHotkeyRowShift);
-}
-
-// 20140205
-if (packetVersion == 20140205)
-{
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0202, 5, clif->pChangeDir);
- packet(CMSG_MAP_SERVER_CONNECT, 0x022d, 19, clif->pWantToConnection);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x023b, 26, clif->pFriendsListAdd);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0281, -1, clif->pItemListWindowSelected);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x0361, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0362, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x0363, 8, clif->pDull);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0364, 8, clif->pMoveFromKafra);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0365, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
-// packet(UNKNOWN, 0x0436, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_ITEM_PICKUP, 0x07e4, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x07ec, 8, clif->pMoveToKafra);
- packet(CMSG_PARTY_INVITE2, 0x0802, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_STORAGE_PASSWORD, 0x0938, 36, clif->pStoragePassword);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20140212
-if (packetVersion == 20140212)
-{
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x02c4, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0369, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0438, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SKILL_USE_BEING, 0x086e, 10, clif->pUseSkillToId);
- packet(CMSG_BUYINGSTORE_SELL, 0x0874, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0877, 6, clif->pReqClickBuyingStore);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0878, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x087e, 5, clif->pWalkToXY);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0888, 8, clif->pMoveFromKafra);
- packet(CMSG_BUYINGSTORE_CREATE, 0x088c, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_SKILL_USE_POSITION, 0x089d, 10, clif->pUseSkillToPos);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x089e, -1, clif->pSearchStoreInfo);
- packet(CMSG_STORAGE_PASSWORD, 0x08a0, 36, clif->pStoragePassword);
- packet(CMSG_PARTY_INVITE2, 0x08a1, 26, clif->pPartyInvite2);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x08a7, -1, clif->pItemListWindowSelected);
- packet(CMSG_MOVE_TO_STORAGE, 0x08ac, 8, clif->pMoveToKafra);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x08ad, 6, clif->pDropItem);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0919, 5, clif->pChangeDir);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x091b, 26, clif->pFriendsListAdd);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0928, 6, clif->pSolveCharName);
- packet(CMSG_MAP_PING, 0x0930, 6, clif->pTickSend);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0934, 7, clif->pActionRequest);
-// packet(UNKNOWN, 0x0936, 4, clif->pDull);
- packet(CMSG_MAP_SERVER_CONNECT, 0x093d, 19, clif->pWantToConnection);
- packet(CMSG_HOMUNCULUS_MENU, 0x0944, 5, clif->pHomMenu);
-// packet(UNKNOWN, 0x094e, 8, clif->pDull);
- packet(CMSG_NAME_REQUEST, 0x0952, 6, clif->pGetCharNameRequest);
- packet(CMSG_ITEM_PICKUP, 0x0953, 6, clif->pTakeItem);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0960, 2, clif->pReqCloseBuyingStore);
-}
-
-// 20140212
-if (packetVersion >= 20140212)
-{
- packet(CMSG_MAIL2_OPEN_MAILBOX, 0x09e8, 11, clif->pRodexOpenMailbox);
-}
-
-// 20140219
-if (packetVersion == 20140219)
-{
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0202, 26, clif->pFriendsListAdd);
-// packet(UNKNOWN, 0x0360, 4, clif->pDull);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0364, 6, clif->pSolveCharName);
- packet(CMSG_ITEM_PICKUP, 0x0802, 6, clif->pTakeItem);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SKILL_USE_BEING, 0x0838, 10, clif->pUseSkillToId);
- packet(CMSG_BUYINGSTORE_OPEN, 0x085b, 6, clif->pReqClickBuyingStore);
- packet(CMSG_SKILL_USE_POSITION, 0x085c, 10, clif->pUseSkillToPos);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x085d, 5, clif->pWalkToXY);
- packet(CMSG_NAME_REQUEST, 0x085f, 6, clif->pGetCharNameRequest);
- packet(CMSG_HOMUNCULUS_MENU, 0x0860, 5, clif->pHomMenu);
- packet(CMSG_STORAGE_PASSWORD, 0x0868, 36, clif->pStoragePassword);
- packet(CMSG_PARTY_INVITE2, 0x086f, 26, clif->pPartyInvite2);
- packet(CMSG_MOVE_TO_STORAGE, 0x087c, 8, clif->pMoveToKafra);
-// packet(UNKNOWN, 0x0889, 8, clif->pDull);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0897, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_SELL, 0x0898, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x089f, 6, clif->pDropItem);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x08a6, 5, clif->pChangeDir);
- packet(CMSG_SEARCHSTORE_CLICK, 0x08aa, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_MOVE_FROM_STORAGE, 0x08ac, 8, clif->pMoveFromKafra);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0921, 7, clif->pActionRequest);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0927, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0939, -1, clif->pItemListWindowSelected);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0946, 19, clif->pWantToConnection);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0949, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0953, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x095a, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_MAP_PING, 0x0961, 6, clif->pTickSend);
-}
-
-// 20140226
-if (packetVersion == 20140226)
-{
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_BUYINGSTORE_SELL, 0x0361, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0362, 26, clif->pFriendsListAdd);
- packet(CMSG_STORAGE_PASSWORD, 0x0364, 36, clif->pStoragePassword);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0811, 5, clif->pChangeDir);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_HOMUNCULUS_MENU, 0x0867, 5, clif->pHomMenu);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0877, 19, clif->pWantToConnection);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0887, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0894, 6, clif->pDropItem);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0895, 8, clif->pMoveFromKafra);
- packet(CMSG_MOVE_TO_STORAGE, 0x091a, 8, clif->pMoveToKafra);
- packet(CMSG_PARTY_INVITE2, 0x0921, 26, clif->pPartyInvite2);
-// packet(UNKNOWN, 0x0931, 4, clif->pDull);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0941, 18, clif->pPartyBookingRegisterReq);
-// packet(UNKNOWN, 0x0962, 8, clif->pDull);
- packet(CMSG_ITEM_PICKUP, 0x0964, 6, clif->pTakeItem);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0969, -1, clif->pItemListWindowSelected);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20140305
-if (packetVersion == 20140305)
-{
- packet(CMSG_ITEM_PICKUP, 0x0202, 6, clif->pTakeItem);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0281, -1, clif->pItemListWindowSelected);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0361, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0362, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x0363, 8, clif->pDull);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0364, 8, clif->pMoveFromKafra);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0365, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
- packet(CMSG_SKILL_USE_POSITION, 0x0436, 10, clif->pUseSkillToPos);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0438, 19, clif->pWantToConnection);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x07e4, 26, clif->pFriendsListAdd);
- packet(CMSG_MOVE_TO_STORAGE, 0x07ec, 8, clif->pMoveToKafra);
- packet(CMSG_PARTY_INVITE2, 0x0802, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0815, 5, clif->pChangeDir);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
-// packet(UNKNOWN, 0x0878, 4, clif->pDull);
- packet(CMSG_HOMUNCULUS_MENU, 0x0934, 5, clif->pHomMenu);
- packet(CMSG_STORAGE_PASSWORD, 0x095e, 36, clif->pStoragePassword);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20140312
-if (packetVersion == 20140312)
-{
- packet(CMSG_SKILL_USE_BEING, 0x0202, 10, clif->pUseSkillToId);
-// packet(UNKNOWN, 0x023b, 8, clif->pDull);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0366, -1, clif->pSearchStoreInfo);
- packet(CMSG_BUYINGSTORE_OPEN, 0x085e, 6, clif->pReqClickBuyingStore);
- packet(CMSG_MAP_PING, 0x086f, 6, clif->pTickSend);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0889, 19, clif->pWantToConnection);
- packet(CMSG_SKILL_USE_POSITION, 0x088c, 10, clif->pUseSkillToPos);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x088d, -1, clif->pItemListWindowSelected);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x088e, 7, clif->pActionRequest);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0891, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0894, 5, clif->pWalkToXY);
- packet(CMSG_NAME_REQUEST, 0x089b, 6, clif->pGetCharNameRequest);
- packet(CMSG_SEARCHSTORE_CLICK, 0x089d, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x089e, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x08a6, 4, clif->pDull);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x08a9, 26, clif->pFriendsListAdd);
- packet(CMSG_SOLVE_CHAR_NAME, 0x08ad, 6, clif->pSolveCharName);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x091b, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_PARTY_INVITE2, 0x091c, 26, clif->pPartyInvite2);
- packet(CMSG_HOMUNCULUS_MENU, 0x091e, 5, clif->pHomMenu);
- packet(CMSG_ITEM_PICKUP, 0x092a, 6, clif->pTakeItem);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0948, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x094a, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x094b, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x094c, 5, clif->pChangeDir);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0957, 8, clif->pMoveFromKafra);
- packet(CMSG_BUYINGSTORE_SELL, 0x095d, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_STORAGE_PASSWORD, 0x095e, 36, clif->pStoragePassword);
- packet(CMSG_MOVE_TO_STORAGE, 0x0966, 8, clif->pMoveToKafra);
-}
-
-// 20140326
-if (packetVersion == 20140326)
-{
- packet(CMSG_NAME_REQUEST, 0x0362, 6, clif->pGetCharNameRequest);
- packet(CMSG_BUYINGSTORE_SELL, 0x0365, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_ITEM_PICKUP, 0x07ec, 6, clif->pTakeItem);
- packet(CMSG_BUYINGSTORE_OPEN, 0x083c, 6, clif->pReqClickBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x085b, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0865, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0867, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0869, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_MOVE_FROM_STORAGE, 0x086b, 8, clif->pMoveFromKafra);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x087c, 5, clif->pWalkToXY);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x087e, 26, clif->pFriendsListAdd);
- packet(CMSG_SKILL_USE_POSITION, 0x087f, 10, clif->pUseSkillToPos);
-// packet(UNKNOWN, 0x0887, 4, clif->pDull);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0898, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x08aa, 8, clif->pDull);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x08ac, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_MAP_SERVER_CONNECT, 0x08ad, 19, clif->pWantToConnection);
- packet(CMSG_MAP_PING, 0x0918, 6, clif->pTickSend);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0928, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_STORAGE_PASSWORD, 0x092a, 36, clif->pStoragePassword);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x093d, 7, clif->pActionRequest);
- packet(CMSG_HOMUNCULUS_MENU, 0x0942, 5, clif->pHomMenu);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0945, -1, clif->pItemListWindowSelected);
- packet(CMSG_PARTY_INVITE2, 0x0946, 26, clif->pPartyInvite2);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0956, 5, clif->pChangeDir);
- packet(CMSG_MOVE_TO_STORAGE, 0x0959, 8, clif->pMoveToKafra);
- packet(CMSG_SOLVE_CHAR_NAME, 0x095a, 6, clif->pSolveCharName);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x095c, -1, clif->pSearchStoreInfo);
- packet(CMSG_SKILL_USE_BEING, 0x0969, 10, clif->pUseSkillToId);
-}
-
-// 20140326
-if (packetVersion >= 20140326)
-{
- packet(CMSG_MAIL2_REQUEST_MONEY, 0x09f1, 11, clif->pRodexRequestZeny);
- packet(CMSG_MAIL2_REQUEST_ITEMS, 0x09f3, 11, clif->pRodexRequestItems);
- packet(CMSG_MAIL2_CANCEL_WRITE_MAIL, 0x0a03, 2, clif->pRodexCancelWriteMail);
-}
-
-// 20140402
-if (packetVersion == 20140402)
-{
- packet(CMSG_BUYINGSTORE_OPEN, 0x023b, 6, clif->pReqClickBuyingStore);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0360, 5, clif->pChangeDir);
- packet(CMSG_SKILL_USE_POSITION, 0x0364, 10, clif->pUseSkillToPos);
- packet(CMSG_SOLVE_CHAR_NAME, 0x07ec, 6, clif->pSolveCharName);
- packet(CMSG_MOVE_FROM_STORAGE, 0x085b, 8, clif->pMoveFromKafra);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x085d, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0867, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SKILL_USE_BEING, 0x0868, 10, clif->pUseSkillToId);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0882, 6, clif->pDropItem);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0883, -1, clif->pItemListWindowSelected);
- packet(CMSG_NAME_REQUEST, 0x088a, 6, clif->pGetCharNameRequest);
-// packet(UNKNOWN, 0x088c, 4, clif->pDull);
- packet(CMSG_PARTY_INVITE2, 0x0890, 26, clif->pPartyInvite2);
- packet(CMSG_HOMUNCULUS_MENU, 0x0896, 5, clif->pHomMenu);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x089a, 26, clif->pFriendsListAdd);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x08ac, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_BUYINGSTORE_SELL, 0x091f, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0920, 19, clif->pWantToConnection);
- packet(CMSG_STORAGE_PASSWORD, 0x0926, 36, clif->pStoragePassword);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x092d, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0933, -1, clif->pSearchStoreInfo);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x093f, 5, clif->pWalkToXY);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0944, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0946, 7, clif->pActionRequest);
-// packet(UNKNOWN, 0x094c, 8, clif->pDull);
- packet(CMSG_MAP_PING, 0x0950, 6, clif->pTickSend);
- packet(CMSG_ITEM_PICKUP, 0x0958, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x095c, 8, clif->pMoveToKafra);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0965, 12, clif->pSearchStoreInfoListItemClick);
-}
-
-// 20140409
-if (packetVersion == 20140409)
-{
- packet(CMSG_MOVE_FROM_STORAGE, 0x0819, 8, clif->pMoveFromKafra);
- packet(CMSG_SOLVE_CHAR_NAME, 0x085b, 6, clif->pSolveCharName);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0868, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x086a, -1, clif->pItemListWindowSelected);
- packet(CMSG_BUYINGSTORE_SELL, 0x086d, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0873, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0875, -1, clif->pSearchStoreInfo);
- packet(CMSG_MAP_PING, 0x087e, 6, clif->pTickSend);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0883, 5, clif->pWalkToXY);
- packet(CMSG_NAME_REQUEST, 0x0884, 6, clif->pGetCharNameRequest);
-// packet(UNKNOWN, 0x088a, 8, clif->pDull);
- packet(CMSG_ITEM_PICKUP, 0x0890, 6, clif->pTakeItem);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0893, 7, clif->pActionRequest);
- packet(CMSG_SKILL_USE_BEING, 0x0896, 10, clif->pUseSkillToId);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0897, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0899, 26, clif->pFriendsListAdd);
-// packet(UNKNOWN, 0x08a2, 4, clif->pDull);
- packet(CMSG_SKILL_USE_POSITION, 0x08a4, 10, clif->pUseSkillToPos);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x08a6, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x08a7, 5, clif->pChangeDir);
- packet(CMSG_STORAGE_PASSWORD, 0x08a9, 36, clif->pStoragePassword);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0918, 6, clif->pDropItem);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x091c, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_PARTY_INVITE2, 0x092e, 26, clif->pPartyInvite2);
- packet(CMSG_MOVE_TO_STORAGE, 0x0942, 8, clif->pMoveToKafra);
- packet(CMSG_HOMUNCULUS_MENU, 0x0947, 5, clif->pHomMenu);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x094c, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_BUYINGSTORE_OPEN, 0x095a, 6, clif->pReqClickBuyingStore);
- packet(CMSG_MAP_SERVER_CONNECT, 0x095e, 19, clif->pWantToConnection);
-}
-
-// 20140416
-if (packetVersion == 20140416)
-{
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0202, 5, clif->pChangeDir);
- packet(CMSG_MAP_SERVER_CONNECT, 0x022d, 19, clif->pWantToConnection);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x023b, 26, clif->pFriendsListAdd);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0281, -1, clif->pItemListWindowSelected);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x0361, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0362, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x0363, 8, clif->pDull);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0364, 8, clif->pMoveFromKafra);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0365, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
-// packet(UNKNOWN, 0x0436, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_ITEM_PICKUP, 0x07e4, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x07ec, 8, clif->pMoveToKafra);
- packet(CMSG_PARTY_INVITE2, 0x0802, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_STORAGE_PASSWORD, 0x095c, 36, clif->pStoragePassword);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-if (packetVersion >= 20140416)
-{
- packet(CMSG_MAIL2_OPEN_WRITE_MAIL, 0x0a08, 26, clif->pRodexOpenWriteMail);
- packet(CMSG_MAIL2_ADD_ITEM_TO_MAIL, 0x0a04, 6, clif->pRodexAddItem);
- packet(CMSG_MAIL2_REMOVE_ITEM_MAIL, 0x0a06, 6, clif->pRodexRemoveItem);
-}
-
-// 20140423
-if (packetVersion == 20140423)
-{
- packet(CMSG_BOOKING_REGISTER_REQ, 0x022d, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_STORAGE_PASSWORD, 0x0360, 36, clif->pStoragePassword);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0436, 26, clif->pFriendsListAdd);
- packet(CMSG_ITEM_PICKUP, 0x07e4, 6, clif->pTakeItem);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0811, 8, clif->pMoveFromKafra);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x083c, 5, clif->pChangeDir);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x085a, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x085b, 5, clif->pWalkToXY);
- packet(CMSG_MOVE_TO_STORAGE, 0x0862, 8, clif->pMoveToKafra);
- packet(CMSG_BUYINGSTORE_SELL, 0x0863, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0866, 19, clif->pWantToConnection);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x086b, 6, clif->pDropItem);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x086f, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0873, -1, clif->pItemListWindowSelected);
- packet(CMSG_SOLVE_CHAR_NAME, 0x088b, 6, clif->pSolveCharName);
- packet(CMSG_SKILL_USE_BEING, 0x0890, 10, clif->pUseSkillToId);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0895, -1, clif->pSearchStoreInfo);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0896, 7, clif->pActionRequest);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0897, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_SKILL_USE_POSITION, 0x0898, 10, clif->pUseSkillToPos);
- packet(CMSG_BUYINGSTORE_OPEN, 0x089b, 6, clif->pReqClickBuyingStore);
- packet(CMSG_NAME_REQUEST, 0x089d, 6, clif->pGetCharNameRequest);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x089f, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x08a8, 5, clif->pHomMenu);
-// packet(UNKNOWN, 0x08ad, 8, clif->pDull);
- packet(CMSG_MAP_PING, 0x091a, 6, clif->pTickSend);
- packet(CMSG_PARTY_INVITE2, 0x0920, 26, clif->pPartyInvite2);
- packet(CMSG_SEARCHSTORE_CLICK, 0x094f, 12, clif->pSearchStoreInfoListItemClick);
-// packet(UNKNOWN, 0x095e, 4, clif->pDull);
-}
-
-// 20140423
-if (packetVersion >= 20140423)
-{
- packet(CMSG_MAIL2_CHECK_NAME, 0x0a13, 26, clif->pRodexCheckName);
-}
-
-// 20140508
-if (packetVersion == 20140508)
-{
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0202, 26, clif->pFriendsListAdd);
- packet(CMSG_HOMUNCULUS_MENU, 0x022d, 5, clif->pHomMenu);
- packet(CMSG_STORAGE_PASSWORD, 0x023b, 36, clif->pStoragePassword);
-// packet(UNKNOWN, 0x0281, 4, clif->pDull);
- packet(CMSG_PARTY_INVITE2, 0x02c4, 26, clif->pPartyInvite2);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x035f, 5, clif->pWalkToXY);
- packet(CMSG_MAP_PING, 0x0360, 6, clif->pTickSend);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0361, 5, clif->pChangeDir);
- packet(CMSG_ITEM_PICKUP, 0x0362, 6, clif->pTakeItem);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0363, 6, clif->pDropItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x0364, 8, clif->pMoveToKafra);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0365, 8, clif->pMoveFromKafra);
- packet(CMSG_SKILL_USE_POSITION, 0x0366, 10, clif->pUseSkillToPos);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0367, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_NAME_REQUEST, 0x0368, 6, clif->pGetCharNameRequest);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0369, 6, clif->pSolveCharName);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0436, 19, clif->pWantToConnection);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0437, 7, clif->pActionRequest);
- packet(CMSG_SKILL_USE_BEING, 0x0438, 10, clif->pUseSkillToId);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x07e4, -1, clif->pItemListWindowSelected);
-// packet(UNKNOWN, 0x07ec, 8, clif->pDull);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0802, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0811, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0815, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0817, 6, clif->pReqClickBuyingStore);
- packet(CMSG_BUYINGSTORE_SELL, 0x0819, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0835, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0838, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x083c, 12, clif->pSearchStoreInfoListItemClick);
-}
-
-// 20140514
-if (packetVersion == 20140514)
-{
- packet(CMSG_SEARCHSTORE_CLICK, 0x0437, 12, clif->pSearchStoreInfoListItemClick);
-// packet(UNKNOWN, 0x0817, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0865, 7, clif->pActionRequest);
- packet(CMSG_BUYINGSTORE_SELL, 0x0867, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0868, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_SKILL_USE_BEING, 0x0876, 10, clif->pUseSkillToId);
-// packet(UNKNOWN, 0x0877, 8, clif->pDull);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x087d, -1, clif->pItemListWindowSelected);
- packet(CMSG_STORAGE_PASSWORD, 0x0885, 36, clif->pStoragePassword);
- packet(CMSG_MAP_PING, 0x0886, 6, clif->pTickSend);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x088a, 5, clif->pChangeDir);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x088b, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_ITEM_PICKUP, 0x0895, 6, clif->pTakeItem);
- packet(CMSG_SOLVE_CHAR_NAME, 0x089a, 6, clif->pSolveCharName);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x089c, 26, clif->pFriendsListAdd);
- packet(CMSG_NAME_REQUEST, 0x08a5, 6, clif->pGetCharNameRequest);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0918, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_MAP_SERVER_CONNECT, 0x091d, 19, clif->pWantToConnection);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0921, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0925, 6, clif->pReqClickBuyingStore);
- packet(CMSG_MOVE_TO_STORAGE, 0x092c, 8, clif->pMoveToKafra);
- packet(CMSG_SKILL_USE_POSITION, 0x092f, 10, clif->pUseSkillToPos);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x094d, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_MOVE_FROM_STORAGE, 0x094e, 8, clif->pMoveFromKafra);
- packet(CMSG_HOMUNCULUS_MENU, 0x0958, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x095f, 5, clif->pWalkToXY);
- packet(CMSG_PARTY_INVITE2, 0x0962, 26, clif->pPartyInvite2);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0965, -1, clif->pSearchStoreInfo);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x096a, 6, clif->pDropItem);
-}
-
-// 20140521
-if (packetVersion == 20140521)
-{
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0281, -1, clif->pItemListWindowSelected);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0362, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x0363, 8, clif->pDull);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0364, 8, clif->pMoveFromKafra);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0365, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_ITEM_PICKUP, 0x07e4, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x07ec, 8, clif->pMoveToKafra);
- packet(CMSG_PARTY_INVITE2, 0x0802, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_STORAGE_PASSWORD, 0x0869, 36, clif->pStoragePassword);
-// packet(UNKNOWN, 0x088b, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x088d, 5, clif->pChangeDir);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x089c, 26, clif->pFriendsListAdd);
- packet(CMSG_MAP_SERVER_CONNECT, 0x08ac, 19, clif->pWantToConnection);
- packet(CMSG_HOMUNCULUS_MENU, 0x0968, 5, clif->pHomMenu);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20140528
-if (packetVersion == 20140528)
-{
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0202, 5, clif->pWalkToXY);
- packet(CMSG_STORAGE_PASSWORD, 0x0360, 36, clif->pStoragePassword);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x085f, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0862, 6, clif->pSolveCharName);
- packet(CMSG_HOMUNCULUS_MENU, 0x0872, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0875, 6, clif->pDropItem);
- packet(CMSG_MAP_PING, 0x0877, 6, clif->pTickSend);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0879, 8, clif->pMoveFromKafra);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x087e, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_CLICK, 0x088a, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x088f, 90, clif->pUseSkillToPosMoreInfo);
-// packet(UNKNOWN, 0x0894, 8, clif->pDull);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0896, -1, clif->pItemListWindowSelected);
- packet(CMSG_ITEM_PICKUP, 0x089d, 6, clif->pTakeItem);
- packet(CMSG_SKILL_USE_POSITION, 0x08a4, 10, clif->pUseSkillToPos);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x08a8, 2, clif->pSearchStoreInfoNextPage);
-// packet(UNKNOWN, 0x08ab, 4, clif->pDull);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x091d, 26, clif->pFriendsListAdd);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0929, 7, clif->pActionRequest);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0930, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0938, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_MOVE_TO_STORAGE, 0x093a, 8, clif->pMoveToKafra);
- packet(CMSG_PARTY_INVITE2, 0x093f, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_OPEN, 0x094a, 6, clif->pReqClickBuyingStore);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x094b, 5, clif->pChangeDir);
- packet(CMSG_NAME_REQUEST, 0x095f, 6, clif->pGetCharNameRequest);
- packet(CMSG_SKILL_USE_BEING, 0x0963, 10, clif->pUseSkillToId);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0964, 19, clif->pWantToConnection);
- packet(CMSG_BUYINGSTORE_SELL, 0x0966, -1, clif->pReqTradeBuyingStore);
-}
-
-// 20140605
-if (packetVersion == 20140605)
-{
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0281, -1, clif->pItemListWindowSelected);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0361, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0362, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x0363, 8, clif->pDull);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0364, 8, clif->pMoveFromKafra);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0365, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0368, 7, clif->pActionRequest);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0369, 19, clif->pWantToConnection);
-// packet(UNKNOWN, 0x0436, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_ITEM_PICKUP, 0x07e4, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x07ec, 8, clif->pMoveToKafra);
- packet(CMSG_PARTY_INVITE2, 0x0802, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0817, 5, clif->pChangeDir);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_STORAGE_PASSWORD, 0x0921, 36, clif->pStoragePassword);
- packet(CMSG_HOMUNCULUS_MENU, 0x0931, 5, clif->pHomMenu);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0940, 6, clif->pSolveCharName);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x094c, 26, clif->pFriendsListAdd);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20140605
-if (packetVersion >= 20140605)
-{
- packet(CMSG_ROULETTE_OPEN, 0x0a19, -1, clif->pRouletteOpen);
- packet(CMSG_ROULETTE_INFO, 0x0a1b, 2, clif->pRouletteInfo);
- packet(CMSG_ROULETTE_CLOSE, 0x0a1d, 14, clif->pRouletteClose);
-}
-
-// 20140611
-if (packetVersion == 20140611)
-{
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0364, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0438, -1, clif->pSearchStoreInfo);
- packet(CMSG_MOVE_TO_STORAGE, 0x07e4, 8, clif->pMoveToKafra);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0838, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_BUYINGSTORE_SELL, 0x0864, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_MAP_PING, 0x0867, 6, clif->pTickSend);
-// packet(UNKNOWN, 0x086c, 4, clif->pDull);
- packet(CMSG_PARTY_INVITE2, 0x0874, 26, clif->pPartyInvite2);
- packet(CMSG_ITEM_PICKUP, 0x0878, 6, clif->pTakeItem);
- packet(CMSG_SKILL_USE_POSITION, 0x088c, 10, clif->pUseSkillToPos);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0891, 7, clif->pActionRequest);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0893, 5, clif->pWalkToXY);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0894, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x089b, 26, clif->pFriendsListAdd);
- packet(CMSG_SKILL_USE_BEING, 0x08a1, 10, clif->pUseSkillToId);
-// packet(UNKNOWN, 0x08a2, 8, clif->pDull);
- packet(CMSG_NAME_REQUEST, 0x0924, 6, clif->pGetCharNameRequest);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0936, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_STORAGE_PASSWORD, 0x0941, 36, clif->pStoragePassword);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x094a, -1, clif->pItemListWindowSelected);
- packet(CMSG_SOLVE_CHAR_NAME, 0x094f, 6, clif->pSolveCharName);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0950, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0951, 5, clif->pChangeDir);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0952, 8, clif->pMoveFromKafra);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0957, 6, clif->pReqClickBuyingStore);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0958, 19, clif->pWantToConnection);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0963, 6, clif->pDropItem);
- packet(CMSG_HOMUNCULUS_MENU, 0x0965, 5, clif->pHomMenu);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0969, 2, clif->pSearchStoreInfoNextPage);
-}
-
-if (packetVersion >= 20140611)
-{
-// new packets
- packet(CMSG_ROULETTE_GENERATE, 0x0a1f, 2, clif->pRouletteGenerate);
- packet(CMSG_ROULETTE_RECV_ITEM, 0x0a21, 6, clif->pRouletteRecvItem);
-// changed packets
- packet(CMSG_ROULETTE_OPEN, 0x0a19, 2, clif->pRouletteOpen);
- packet(CMSG_ROULETTE_CLOSE, 0x0a1d, 2, clif->pRouletteClose);
-}
-
-// 20140612
-if (packetVersion == 20140612)
-{
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0364, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0438, -1, clif->pSearchStoreInfo);
- packet(CMSG_MOVE_TO_STORAGE, 0x07e4, 8, clif->pMoveToKafra);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0838, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_BUYINGSTORE_SELL, 0x0864, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_MAP_PING, 0x0867, 6, clif->pTickSend);
-// packet(UNKNOWN, 0x086c, 4, clif->pDull);
- packet(CMSG_PARTY_INVITE2, 0x0874, 26, clif->pPartyInvite2);
- packet(CMSG_ITEM_PICKUP, 0x0878, 6, clif->pTakeItem);
- packet(CMSG_SKILL_USE_POSITION, 0x088c, 10, clif->pUseSkillToPos);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0891, 7, clif->pActionRequest);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0893, 5, clif->pWalkToXY);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0894, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x089b, 26, clif->pFriendsListAdd);
- packet(CMSG_SKILL_USE_BEING, 0x08a1, 10, clif->pUseSkillToId);
-// packet(UNKNOWN, 0x08a2, 8, clif->pDull);
- packet(CMSG_NAME_REQUEST, 0x0924, 6, clif->pGetCharNameRequest);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0936, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_STORAGE_PASSWORD, 0x0941, 36, clif->pStoragePassword);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x094a, -1, clif->pItemListWindowSelected);
- packet(CMSG_SOLVE_CHAR_NAME, 0x094f, 6, clif->pSolveCharName);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0950, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0951, 5, clif->pChangeDir);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0952, 8, clif->pMoveFromKafra);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0957, 6, clif->pReqClickBuyingStore);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0958, 19, clif->pWantToConnection);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0963, 6, clif->pDropItem);
- packet(CMSG_HOMUNCULUS_MENU, 0x0965, 5, clif->pHomMenu);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0969, 2, clif->pSearchStoreInfoNextPage);
-}
-
-// 20140613
-if (packetVersion == 20140613)
-{
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0364, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0438, -1, clif->pSearchStoreInfo);
- packet(CMSG_MOVE_TO_STORAGE, 0x07e4, 8, clif->pMoveToKafra);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0838, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_BUYINGSTORE_SELL, 0x0864, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_MAP_PING, 0x0867, 6, clif->pTickSend);
-// packet(UNKNOWN, 0x086c, 4, clif->pDull);
- packet(CMSG_PARTY_INVITE2, 0x0874, 26, clif->pPartyInvite2);
- packet(CMSG_ITEM_PICKUP, 0x0878, 6, clif->pTakeItem);
- packet(CMSG_SKILL_USE_POSITION, 0x088c, 10, clif->pUseSkillToPos);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0891, 7, clif->pActionRequest);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0893, 5, clif->pWalkToXY);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0894, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x089b, 26, clif->pFriendsListAdd);
- packet(CMSG_SKILL_USE_BEING, 0x08a1, 10, clif->pUseSkillToId);
-// packet(UNKNOWN, 0x08a2, 8, clif->pDull);
- packet(CMSG_NAME_REQUEST, 0x0924, 6, clif->pGetCharNameRequest);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0936, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_STORAGE_PASSWORD, 0x0941, 36, clif->pStoragePassword);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x094a, -1, clif->pItemListWindowSelected);
- packet(CMSG_SOLVE_CHAR_NAME, 0x094f, 6, clif->pSolveCharName);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0950, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0951, 5, clif->pChangeDir);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0952, 8, clif->pMoveFromKafra);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0957, 6, clif->pReqClickBuyingStore);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0958, 19, clif->pWantToConnection);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0963, 6, clif->pDropItem);
- packet(CMSG_HOMUNCULUS_MENU, 0x0965, 5, clif->pHomMenu);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0969, 2, clif->pSearchStoreInfoNextPage);
-}
-
-// 20140618
-if (packetVersion == 20140618)
-{
- packet(CMSG_MOVE_TO_STORAGE, 0x085d, 8, clif->pMoveToKafra);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x085f, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_MAP_PING, 0x0860, 6, clif->pTickSend);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0861, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x086c, -1, clif->pSearchStoreInfo);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0878, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_SOLVE_CHAR_NAME, 0x087d, 6, clif->pSolveCharName);
- packet(CMSG_BUYINGSTORE_SELL, 0x0884, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0885, 8, clif->pMoveFromKafra);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0886, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0890, 5, clif->pChangeDir);
- packet(CMSG_SKILL_USE_BEING, 0x0892, 10, clif->pUseSkillToId);
- packet(CMSG_BUYINGSTORE_OPEN, 0x08a6, 6, clif->pReqClickBuyingStore);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x08a7, 5, clif->pWalkToXY);
-// packet(UNKNOWN, 0x08ac, 4, clif->pDull);
- packet(CMSG_SKILL_USE_POSITION, 0x0917, 10, clif->pUseSkillToPos);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x091f, -1, clif->pItemListWindowSelected);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0929, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_ITEM_PICKUP, 0x0935, 6, clif->pTakeItem);
- packet(CMSG_PARTY_INVITE2, 0x0938, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0939, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x093b, 7, clif->pActionRequest);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0945, 6, clif->pDropItem);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0954, 26, clif->pFriendsListAdd);
- packet(CMSG_STORAGE_PASSWORD, 0x0957, 36, clif->pStoragePassword);
- packet(CMSG_NAME_REQUEST, 0x095d, 6, clif->pGetCharNameRequest);
- packet(CMSG_MAP_SERVER_CONNECT, 0x095e, 19, clif->pWantToConnection);
-// packet(UNKNOWN, 0x0962, 8, clif->pDull);
- packet(CMSG_HOMUNCULUS_MENU, 0x0967, 5, clif->pHomMenu);
-}
-
-if (packetVersion >= 20140618)
-{
- packet(CMSG_ROULETTE_RECV_ITEM, 0x0a21, 3, clif->pRouletteRecvItem);
-}
-
-// 20140625
-if (packetVersion == 20140625)
-{
- packet(CMSG_MOVE_TO_STORAGE, 0x0202, 8, clif->pMoveToKafra);
- packet(CMSG_MOVE_FROM_STORAGE, 0x023b, 8, clif->pMoveFromKafra);
-// packet(UNKNOWN, 0x0815, 4, clif->pDull);
- packet(CMSG_BUYINGSTORE_SELL, 0x0817, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0835, 5, clif->pWalkToXY);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x085a, -1, clif->pSearchStoreInfo);
- packet(CMSG_SKILL_USE_BEING, 0x0861, 10, clif->pUseSkillToId);
- packet(CMSG_PARTY_INVITE2, 0x086b, 26, clif->pPartyInvite2);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0875, 6, clif->pSolveCharName);
- packet(CMSG_SKILL_USE_POSITION, 0x087b, 10, clif->pUseSkillToPos);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0885, 6, clif->pDropItem);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0886, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0888, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x088a, -1, clif->pItemListWindowSelected);
- packet(CMSG_MAP_SERVER_CONNECT, 0x088e, 19, clif->pWantToConnection);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0897, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_MAP_PING, 0x08a1, 6, clif->pTickSend);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x08a2, 5, clif->pChangeDir);
- packet(CMSG_ITEM_PICKUP, 0x091a, 6, clif->pTakeItem);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0923, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0928, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0940, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x0946, 5, clif->pHomMenu);
-// packet(UNKNOWN, 0x094e, 8, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0959, 7, clif->pActionRequest);
- packet(CMSG_STORAGE_PASSWORD, 0x0960, 36, clif->pStoragePassword);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0968, 6, clif->pReqClickBuyingStore);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0969, 26, clif->pFriendsListAdd);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20140702
-if (packetVersion == 20140702)
-{
- packet(CMSG_SEARCHSTORE_SEARCH, 0x022d, -1, clif->pSearchStoreInfo);
- packet(CMSG_BUYINGSTORE_CREATE, 0x023b, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0364, -1, clif->pItemListWindowSelected);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0437, 26, clif->pFriendsListAdd);
- packet(CMSG_MOVE_TO_STORAGE, 0x0438, 8, clif->pMoveToKafra);
- packet(CMSG_SKILL_USE_POSITION, 0x07e4, 10, clif->pUseSkillToPos);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_STORAGE_PASSWORD, 0x0815, 36, clif->pStoragePassword);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x0819, 5, clif->pHomMenu);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0835, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x085a, 6, clif->pDropItem);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x086c, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0887, 5, clif->pWalkToXY);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0892, 8, clif->pMoveFromKafra);
-// packet(UNKNOWN, 0x0895, 8, clif->pDull);
- packet(CMSG_PARTY_INVITE2, 0x08a0, 26, clif->pPartyInvite2);
- packet(CMSG_ITEM_PICKUP, 0x08a2, 6, clif->pTakeItem);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0925, 5, clif->pChangeDir);
- packet(CMSG_MAP_SERVER_CONNECT, 0x092c, 19, clif->pWantToConnection);
-// packet(UNKNOWN, 0x0933, 4, clif->pDull);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0940, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20140709
-if (packetVersion == 20140709)
-{
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0364, -1, clif->pSearchStoreInfo);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0437, 7, clif->pActionRequest);
- packet(CMSG_STORAGE_PASSWORD, 0x0860, 36, clif->pStoragePassword);
-// packet(UNKNOWN, 0x0866, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0869, 5, clif->pChangeDir);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0875, -1, clif->pItemListWindowSelected);
- packet(CMSG_SKILL_USE_BEING, 0x0877, 10, clif->pUseSkillToId);
- packet(CMSG_NAME_REQUEST, 0x0879, 6, clif->pGetCharNameRequest);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x087a, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_MOVE_TO_STORAGE, 0x0887, 8, clif->pMoveToKafra);
-// packet(UNKNOWN, 0x0888, 8, clif->pDull);
- packet(CMSG_PARTY_INVITE2, 0x088b, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0894, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0897, 6, clif->pReqClickBuyingStore);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0898, 19, clif->pWantToConnection);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x08ad, 6, clif->pDropItem);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x091a, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0925, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SKILL_USE_POSITION, 0x092f, 10, clif->pUseSkillToPos);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0931, 6, clif->pSolveCharName);
- packet(CMSG_MAP_PING, 0x0934, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_SELL, 0x0939, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_SEARCHSTORE_CLICK, 0x093f, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0940, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x094d, 5, clif->pHomMenu);
- packet(CMSG_MOVE_FROM_STORAGE, 0x094e, 8, clif->pMoveFromKafra);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x094f, 26, clif->pFriendsListAdd);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x095f, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_ITEM_PICKUP, 0x0961, 6, clif->pTakeItem);
-}
-
-// 20140716
-if (packetVersion == 20140716)
-{
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0362, -1, clif->pSearchStoreInfo);
- packet(CMSG_STORAGE_PASSWORD, 0x07e4, 36, clif->pStoragePassword);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0811, 7, clif->pActionRequest);
- packet(CMSG_NAME_REQUEST, 0x085c, 6, clif->pGetCharNameRequest);
- packet(CMSG_MAP_SERVER_CONNECT, 0x085f, 19, clif->pWantToConnection);
- packet(CMSG_PARTY_INVITE2, 0x0868, 26, clif->pPartyInvite2);
- packet(CMSG_MOVE_TO_STORAGE, 0x0871, 8, clif->pMoveToKafra);
- packet(CMSG_SKILL_USE_BEING, 0x0881, 10, clif->pUseSkillToId);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x088b, 2, clif->pSearchStoreInfoNextPage);
-// packet(UNKNOWN, 0x088d, 8, clif->pDull);
- packet(CMSG_SKILL_USE_POSITION, 0x088f, 10, clif->pUseSkillToPos);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0896, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x089a, 6, clif->pSolveCharName);
- packet(CMSG_BUYINGSTORE_SELL, 0x089f, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x08a2, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x08a4, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x08ac, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0918, 5, clif->pWalkToXY);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x091f, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0926, 6, clif->pDropItem);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x092c, 26, clif->pFriendsListAdd);
- packet(CMSG_SEARCHSTORE_CLICK, 0x092f, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0938, 8, clif->pMoveFromKafra);
- packet(CMSG_BUYINGSTORE_OPEN, 0x093b, 6, clif->pReqClickBuyingStore);
-// packet(UNKNOWN, 0x0947, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0952, 5, clif->pChangeDir);
- packet(CMSG_ITEM_PICKUP, 0x0958, 6, clif->pTakeItem);
- packet(CMSG_MAP_PING, 0x0959, 6, clif->pTickSend);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0969, -1, clif->pItemListWindowSelected);
-}
-
-// 20140723
-if (packetVersion == 20140723)
-{
- packet(CMSG_MAP_PING, 0x02c4, 6, clif->pTickSend);
- packet(CMSG_STORAGE_PASSWORD, 0x0364, 36, clif->pStoragePassword);
- packet(CMSG_NAME_REQUEST, 0x0368, 6, clif->pGetCharNameRequest);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0436, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0819, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_SKILL_USE_BEING, 0x0838, 10, clif->pUseSkillToId);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x085a, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x085f, 5, clif->pWalkToXY);
- packet(CMSG_MOVE_TO_STORAGE, 0x0869, 8, clif->pMoveToKafra);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x086d, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x087d, -1, clif->pSearchStoreInfo);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0888, 6, clif->pReqClickBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0891, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0896, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x0898, 8, clif->pDull);
- packet(CMSG_BUYINGSTORE_SELL, 0x089e, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_MOVE_FROM_STORAGE, 0x08a2, 8, clif->pMoveFromKafra);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x08ad, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0927, 6, clif->pSolveCharName);
- packet(CMSG_MAP_SERVER_CONNECT, 0x092f, 19, clif->pWantToConnection);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0934, 26, clif->pFriendsListAdd);
- packet(CMSG_PARTY_INVITE2, 0x0935, 26, clif->pPartyInvite2);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0939, -1, clif->pItemListWindowSelected);
- packet(CMSG_ITEM_PICKUP, 0x093d, 6, clif->pTakeItem);
- packet(CMSG_SKILL_USE_POSITION, 0x0945, 10, clif->pUseSkillToPos);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0947, 7, clif->pActionRequest);
- packet(CMSG_HOMUNCULUS_MENU, 0x0948, 5, clif->pHomMenu);
-// packet(UNKNOWN, 0x095f, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0960, 5, clif->pChangeDir);
-}
-
-// 20140730
-if (packetVersion == 20140730)
-{
- packet(CMSG_SKILL_USE_POSITION, 0x022d, 10, clif->pUseSkillToPos);
- packet(CMSG_NAME_REQUEST, 0x0364, 6, clif->pGetCharNameRequest);
- packet(CMSG_SKILL_USE_BEING, 0x0366, 10, clif->pUseSkillToId);
- packet(CMSG_BUYINGSTORE_SELL, 0x0367, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0437, 19, clif->pWantToConnection);
-// packet(UNKNOWN, 0x07ec, 4, clif->pDull);
-// packet(UNKNOWN, 0x0802, 8, clif->pDull);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0815, 26, clif->pFriendsListAdd);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0817, 7, clif->pActionRequest);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x085e, 5, clif->pWalkToXY);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x085f, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_MOVE_FROM_STORAGE, 0x087d, 8, clif->pMoveFromKafra);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x087e, -1, clif->pSearchStoreInfo);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x087f, 6, clif->pDropItem);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0889, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_MAP_PING, 0x088b, 6, clif->pTickSend);
- packet(CMSG_SEARCHSTORE_CLICK, 0x088d, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_MOVE_TO_STORAGE, 0x0892, 8, clif->pMoveToKafra);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x08a0, -1, clif->pItemListWindowSelected);
- packet(CMSG_BUYINGSTORE_OPEN, 0x08a6, 6, clif->pReqClickBuyingStore);
- packet(CMSG_SOLVE_CHAR_NAME, 0x08a7, 6, clif->pSolveCharName);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x08a9, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_STORAGE_PASSWORD, 0x08ad, 36, clif->pStoragePassword);
- packet(CMSG_PARTY_INVITE2, 0x091e, 26, clif->pPartyInvite2);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0924, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_ITEM_PICKUP, 0x092a, 6, clif->pTakeItem);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0934, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0940, 5, clif->pChangeDir);
- packet(CMSG_HOMUNCULUS_MENU, 0x0946, 5, clif->pHomMenu);
-}
-
-// 20140806
-if (packetVersion == 20140806)
-{
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0202, 5, clif->pChangeDir);
- packet(CMSG_MAP_SERVER_CONNECT, 0x022d, 19, clif->pWantToConnection);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x023b, 26, clif->pFriendsListAdd);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0281, -1, clif->pItemListWindowSelected);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x0361, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0362, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x0363, 8, clif->pDull);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0364, 8, clif->pMoveFromKafra);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0365, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
-// packet(UNKNOWN, 0x0436, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_ITEM_PICKUP, 0x07e4, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x07ec, 8, clif->pMoveToKafra);
- packet(CMSG_PARTY_INVITE2, 0x0802, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_STORAGE_PASSWORD, 0x0948, 36, clif->pStoragePassword);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20140813
-if (packetVersion == 20140813)
-{
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_STORAGE_PASSWORD, 0x0365, 36, clif->pStoragePassword);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x07e4, -1, clif->pSearchStoreInfo);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0802, 19, clif->pWantToConnection);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0819, -1, clif->pItemListWindowSelected);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_HOMUNCULUS_MENU, 0x0868, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0878, 5, clif->pChangeDir);
- packet(CMSG_PARTY_INVITE2, 0x087c, 26, clif->pPartyInvite2);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0882, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0895, 8, clif->pMoveFromKafra);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0897, 26, clif->pFriendsListAdd);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0899, 6, clif->pDropItem);
- packet(CMSG_ITEM_PICKUP, 0x08a3, 6, clif->pTakeItem);
-// packet(UNKNOWN, 0x08a7, 8, clif->pDull);
-// packet(UNKNOWN, 0x08ab, 4, clif->pDull);
- packet(CMSG_MOVE_TO_STORAGE, 0x0967, 8, clif->pMoveToKafra);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20140814
-if (packetVersion == 20140814)
-{
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_STORAGE_PASSWORD, 0x0365, 36, clif->pStoragePassword);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x07e4, -1, clif->pSearchStoreInfo);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0802, 19, clif->pWantToConnection);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0819, -1, clif->pItemListWindowSelected);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_HOMUNCULUS_MENU, 0x0868, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0878, 5, clif->pChangeDir);
- packet(CMSG_PARTY_INVITE2, 0x087c, 26, clif->pPartyInvite2);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0882, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0895, 8, clif->pMoveFromKafra);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0897, 26, clif->pFriendsListAdd);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0899, 6, clif->pDropItem);
- packet(CMSG_ITEM_PICKUP, 0x08a3, 6, clif->pTakeItem);
-// packet(UNKNOWN, 0x08a7, 8, clif->pDull);
-// packet(UNKNOWN, 0x08ab, 4, clif->pDull);
- packet(CMSG_MOVE_TO_STORAGE, 0x0967, 8, clif->pMoveToKafra);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20140820
-if (packetVersion == 20140820)
-{
- packet(CMSG_BUYINGSTORE_CLOSE, 0x035f, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_ITEM_PICKUP, 0x07e4, 6, clif->pTakeItem);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x07ec, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0835, 5, clif->pChangeDir);
- packet(CMSG_MAP_PING, 0x0861, 6, clif->pTickSend);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0864, 19, clif->pWantToConnection);
-// packet(UNKNOWN, 0x0869, 8, clif->pDull);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x086c, -1, clif->pItemListWindowSelected);
- packet(CMSG_PARTY_INVITE2, 0x086e, 26, clif->pPartyInvite2);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0872, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0876, 6, clif->pDropItem);
- packet(CMSG_NAME_REQUEST, 0x0891, 6, clif->pGetCharNameRequest);
- packet(CMSG_SKILL_USE_POSITION, 0x0899, 10, clif->pUseSkillToPos);
- packet(CMSG_BUYINGSTORE_SELL, 0x089a, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_MOVE_FROM_STORAGE, 0x089b, 8, clif->pMoveFromKafra);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x08a3, 5, clif->pWalkToXY);
- packet(CMSG_BUYINGSTORE_CREATE, 0x08a7, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_SOLVE_CHAR_NAME, 0x091d, 6, clif->pSolveCharName);
- packet(CMSG_SKILL_USE_BEING, 0x092f, 10, clif->pUseSkillToId);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0936, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_HOMUNCULUS_MENU, 0x0937, 5, clif->pHomMenu);
- packet(CMSG_STORAGE_PASSWORD, 0x093a, 36, clif->pStoragePassword);
- packet(CMSG_BUYINGSTORE_OPEN, 0x093e, 6, clif->pReqClickBuyingStore);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x094a, 26, clif->pFriendsListAdd);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0951, -1, clif->pSearchStoreInfo);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0952, 7, clif->pActionRequest);
- packet(CMSG_MOVE_TO_STORAGE, 0x0956, 8, clif->pMoveToKafra);
-// packet(UNKNOWN, 0x0958, 4, clif->pDull);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0961, 18, clif->pPartyBookingRegisterReq);
-}
-
-// 20140827
-if (packetVersion == 20140827)
-{
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0202, 5, clif->pChangeDir);
- packet(CMSG_MAP_SERVER_CONNECT, 0x022d, 19, clif->pWantToConnection);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x023b, 26, clif->pFriendsListAdd);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0281, -1, clif->pItemListWindowSelected);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x0361, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0362, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x0363, 8, clif->pDull);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0364, 8, clif->pMoveFromKafra);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0365, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
-// packet(UNKNOWN, 0x0436, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_ITEM_PICKUP, 0x07e4, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x07ec, 8, clif->pMoveToKafra);
- packet(CMSG_PARTY_INVITE2, 0x0802, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_STORAGE_PASSWORD, 0x0943, 36, clif->pStoragePassword);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20140903
-if (packetVersion == 20140903)
-{
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0281, -1, clif->pItemListWindowSelected);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0362, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x0363, 8, clif->pDull);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0364, 8, clif->pMoveFromKafra);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0365, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_ITEM_PICKUP, 0x07e4, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x07ec, 8, clif->pMoveToKafra);
- packet(CMSG_PARTY_INVITE2, 0x0802, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_MAP_SERVER_CONNECT, 0x088f, 19, clif->pWantToConnection);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x089b, 26, clif->pFriendsListAdd);
- packet(CMSG_HOMUNCULUS_MENU, 0x0931, 5, clif->pHomMenu);
- packet(CMSG_STORAGE_PASSWORD, 0x0941, 36, clif->pStoragePassword);
-// packet(UNKNOWN, 0x0943, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0945, 5, clif->pChangeDir);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20140917
-if (packetVersion == 20140917)
-{
- packet(CMSG_PARTY_INVITE2, 0x022d, 26, clif->pPartyInvite2);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0364, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_MOVE_TO_STORAGE, 0x0365, 8, clif->pMoveToKafra);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0366, 19, clif->pWantToConnection);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0367, -1, clif->pSearchStoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0369, 6, clif->pSolveCharName);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0838, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_ITEM_PICKUP, 0x0864, 6, clif->pTakeItem);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x086d, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0889, 7, clif->pActionRequest);
- packet(CMSG_HOMUNCULUS_MENU, 0x0895, 5, clif->pHomMenu);
- packet(CMSG_MAP_PING, 0x0897, 6, clif->pTickSend);
- packet(CMSG_NAME_REQUEST, 0x0898, 6, clif->pGetCharNameRequest);
- packet(CMSG_BUYINGSTORE_OPEN, 0x089c, 6, clif->pReqClickBuyingStore);
- packet(CMSG_STORAGE_PASSWORD, 0x08a8, 36, clif->pStoragePassword);
- packet(CMSG_BUYINGSTORE_SELL, 0x0919, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x091e, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_CLICK, 0x092a, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0930, 8, clif->pMoveFromKafra);
- packet(CMSG_SKILL_USE_BEING, 0x0949, 10, clif->pUseSkillToId);
- packet(CMSG_SKILL_USE_POSITION, 0x094f, 10, clif->pUseSkillToPos);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0951, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0955, 26, clif->pFriendsListAdd);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0956, -1, clif->pItemListWindowSelected);
-// packet(UNKNOWN, 0x0957, 8, clif->pDull);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x095a, 6, clif->pDropItem);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x095c, 5, clif->pWalkToXY);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x095e, 5, clif->pChangeDir);
-// packet(UNKNOWN, 0x0966, 4, clif->pDull);
-}
-
-// 20140924
-if (packetVersion == 20140924)
-{
- packet(CMSG_SKILL_USE_POSITION, 0x0366, 10, clif->pUseSkillToPos);
- packet(CMSG_PARTY_INVITE2, 0x0367, 26, clif->pPartyInvite2);
- packet(CMSG_STORAGE_PASSWORD, 0x07e4, 36, clif->pStoragePassword);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0802, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0815, 5, clif->pWalkToXY);
-// packet(UNKNOWN, 0x0862, 4, clif->pDull);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0864, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0865, -1, clif->pSearchStoreInfo);
- packet(CMSG_BUYINGSTORE_SELL, 0x0867, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x086b, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_ITEM_PICKUP, 0x086d, 6, clif->pTakeItem);
- packet(CMSG_HOMUNCULUS_MENU, 0x086e, 5, clif->pHomMenu);
- packet(CMSG_NAME_REQUEST, 0x0886, 6, clif->pGetCharNameRequest);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x088b, -1, clif->pItemListWindowSelected);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0894, 7, clif->pActionRequest);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0898, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_MOVE_TO_STORAGE, 0x089c, 8, clif->pMoveToKafra);
- packet(CMSG_SOLVE_CHAR_NAME, 0x08a5, 6, clif->pSolveCharName);
- packet(CMSG_SKILL_USE_BEING, 0x08a7, 10, clif->pUseSkillToId);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0918, 19, clif->pWantToConnection);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x091b, 2, clif->pSearchStoreInfoNextPage);
-// packet(UNKNOWN, 0x0925, 8, clif->pDull);
- packet(CMSG_MAP_PING, 0x0926, 6, clif->pTickSend);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0928, 8, clif->pMoveFromKafra);
- packet(CMSG_BUYINGSTORE_OPEN, 0x092b, 6, clif->pReqClickBuyingStore);
- packet(CMSG_SEARCHSTORE_CLICK, 0x092d, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0934, 5, clif->pChangeDir);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0949, 6, clif->pDropItem);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0952, 26, clif->pFriendsListAdd);
-}
-
-// 20141001
-if (packetVersion == 20141001)
-{
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0361, 6, clif->pDropItem);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0365, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0838, 8, clif->pMoveFromKafra);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_MOVE_TO_STORAGE, 0x087c, 8, clif->pMoveToKafra);
- packet(CMSG_PARTY_INVITE2, 0x0884, 26, clif->pPartyInvite2);
- packet(CMSG_NAME_REQUEST, 0x0885, 6, clif->pGetCharNameRequest);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x089c, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x089d, 26, clif->pFriendsListAdd);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x08ad, 5, clif->pChangeDir);
-// packet(UNKNOWN, 0x091c, 4, clif->pDull);
- packet(CMSG_STORAGE_PASSWORD, 0x092a, 36, clif->pStoragePassword);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0937, -1, clif->pItemListWindowSelected);
-// packet(UNKNOWN, 0x0939, 8, clif->pDull);
- packet(CMSG_ITEM_PICKUP, 0x093f, 6, clif->pTakeItem);
- packet(CMSG_MAP_SERVER_CONNECT, 0x094b, 19, clif->pWantToConnection);
- packet(CMSG_HOMUNCULUS_MENU, 0x0952, 5, clif->pHomMenu);
-}
-
-// 20141008
-if (packetVersion == 20141008)
-{
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0202, 5, clif->pChangeDir);
- packet(CMSG_MAP_SERVER_CONNECT, 0x022d, 19, clif->pWantToConnection);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x023b, 26, clif->pFriendsListAdd);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0281, -1, clif->pItemListWindowSelected);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x0361, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0362, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x0363, 8, clif->pDull);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0364, 8, clif->pMoveFromKafra);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0365, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
-// packet(UNKNOWN, 0x0436, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_ITEM_PICKUP, 0x07e4, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x07ec, 8, clif->pMoveToKafra);
- packet(CMSG_PARTY_INVITE2, 0x0802, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_STORAGE_PASSWORD, 0x0942, 36, clif->pStoragePassword);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20141015
-if (packetVersion == 20141015)
-{
- packet(CMSG_MOVE_FROM_STORAGE, 0x022d, 8, clif->pMoveFromKafra);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0281, -1, clif->pItemListWindowSelected);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0362, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x0363, 8, clif->pDull);
- packet(CMSG_HOMUNCULUS_MENU, 0x0364, 5, clif->pHomMenu);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0365, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_ITEM_PICKUP, 0x07e4, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x07ec, 8, clif->pMoveToKafra);
- packet(CMSG_PARTY_INVITE2, 0x0802, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_MAP_SERVER_CONNECT, 0x086e, 19, clif->pWantToConnection);
-// packet(UNKNOWN, 0x0922, 4, clif->pDull);
- packet(CMSG_STORAGE_PASSWORD, 0x0936, 36, clif->pStoragePassword);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x094b, 26, clif->pFriendsListAdd);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0967, 5, clif->pChangeDir);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20141016
-if (packetVersion == 20141016)
-{
- packet(CMSG_MOVE_FROM_STORAGE, 0x022d, 8, clif->pMoveFromKafra);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0281, -1, clif->pItemListWindowSelected);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0362, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x0363, 8, clif->pDull);
- packet(CMSG_HOMUNCULUS_MENU, 0x0364, 5, clif->pHomMenu);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0365, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_ITEM_PICKUP, 0x07e4, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x07ec, 8, clif->pMoveToKafra);
- packet(CMSG_PARTY_INVITE2, 0x0802, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_MAP_SERVER_CONNECT, 0x086e, 19, clif->pWantToConnection);
-// packet(UNKNOWN, 0x0922, 4, clif->pDull);
- packet(CMSG_STORAGE_PASSWORD, 0x0936, 36, clif->pStoragePassword);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x094b, 26, clif->pFriendsListAdd);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0967, 5, clif->pChangeDir);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20141022
-if (packetVersion == 20141022)
-{
- packet(CMSG_SKILL_USE_POSITION, 0x023b, 10, clif->pUseSkillToPos);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0281, -1, clif->pItemListWindowSelected);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_STORAGE_PASSWORD, 0x0438, 36, clif->pStoragePassword);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0835, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_MOVE_TO_STORAGE, 0x0878, 8, clif->pMoveToKafra);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x087d, 6, clif->pDropItem);
- packet(CMSG_PARTY_INVITE2, 0x0896, 26, clif->pPartyInvite2);
- packet(CMSG_HOMUNCULUS_MENU, 0x0899, 5, clif->pHomMenu);
- packet(CMSG_MOVE_FROM_STORAGE, 0x08aa, 8, clif->pMoveFromKafra);
-// packet(UNKNOWN, 0x08ab, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x08ad, 5, clif->pChangeDir);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x091a, 26, clif->pFriendsListAdd);
-// packet(UNKNOWN, 0x092b, 8, clif->pDull);
- packet(CMSG_MAP_SERVER_CONNECT, 0x093b, 19, clif->pWantToConnection);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0940, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_ITEM_PICKUP, 0x094e, 6, clif->pTakeItem);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0955, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20141029
-if (packetVersion == 20141029)
-{
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0202, 5, clif->pChangeDir);
- packet(CMSG_MAP_SERVER_CONNECT, 0x022d, 19, clif->pWantToConnection);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x023b, 26, clif->pFriendsListAdd);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0281, -1, clif->pItemListWindowSelected);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x0361, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0362, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x0363, 8, clif->pDull);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0364, 8, clif->pMoveFromKafra);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0365, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0369, 5, clif->pWalkToXY);
-// packet(UNKNOWN, 0x0436, 4, clif->pDull);
- packet(CMSG_STORAGE_PASSWORD, 0x0437, 36, clif->pStoragePassword);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_ITEM_PICKUP, 0x07e4, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x07ec, 8, clif->pMoveToKafra);
- packet(CMSG_PARTY_INVITE2, 0x0802, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0940, 7, clif->pActionRequest);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20141105
-if (packetVersion == 20141105)
-{
-// packet(UNKNOWN, 0x022d, 4, clif->pDull);
- packet(CMSG_SKILL_USE_BEING, 0x035f, 10, clif->pUseSkillToId);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0360, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_SKILL_USE_POSITION, 0x085c, 10, clif->pUseSkillToPos);
- packet(CMSG_NAME_REQUEST, 0x0863, 6, clif->pGetCharNameRequest);
- packet(CMSG_MAP_PING, 0x0864, 6, clif->pTickSend);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0865, 26, clif->pFriendsListAdd);
- packet(CMSG_STORAGE_PASSWORD, 0x0871, 36, clif->pStoragePassword);
-// packet(UNKNOWN, 0x0874, 8, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0875, 7, clif->pActionRequest);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0877, -1, clif->pItemListWindowSelected);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0879, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0887, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0892, 6, clif->pDropItem);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0898, 8, clif->pMoveFromKafra);
- packet(CMSG_MAP_SERVER_CONNECT, 0x08a0, 19, clif->pWantToConnection);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x08a5, 5, clif->pChangeDir);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x08a7, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_MOVE_TO_STORAGE, 0x08ad, 8, clif->pMoveToKafra);
- packet(CMSG_SOLVE_CHAR_NAME, 0x091d, 6, clif->pSolveCharName);
- packet(CMSG_BUYINGSTORE_OPEN, 0x091e, 6, clif->pReqClickBuyingStore);
- packet(CMSG_ITEM_PICKUP, 0x092b, 6, clif->pTakeItem);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x093e, -1, clif->pSearchStoreInfo);
- packet(CMSG_HOMUNCULUS_MENU, 0x0944, 5, clif->pHomMenu);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0948, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_PARTY_INVITE2, 0x0950, 26, clif->pPartyInvite2);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0957, 5, clif->pWalkToXY);
- packet(CMSG_BUYINGSTORE_SELL, 0x095f, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0968, 18, clif->pPartyBookingRegisterReq);
-}
-
-// 20141112
-if (packetVersion == 20141112)
-{
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0362, 26, clif->pFriendsListAdd);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0438, 6, clif->pSolveCharName);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x07e4, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_BUYINGSTORE_SELL, 0x0835, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0838, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_MOVE_TO_STORAGE, 0x083c, 8, clif->pMoveToKafra);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x085f, -1, clif->pSearchStoreInfo);
- packet(CMSG_SKILL_USE_BEING, 0x0863, 10, clif->pUseSkillToId);
- packet(CMSG_NAME_REQUEST, 0x0869, 6, clif->pGetCharNameRequest);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x086c, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0871, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0885, 5, clif->pChangeDir);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0886, -1, clif->pItemListWindowSelected);
- packet(CMSG_PARTY_INVITE2, 0x0887, 26, clif->pPartyInvite2);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x088d, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x08a0, 5, clif->pWalkToXY);
- packet(CMSG_BUYINGSTORE_OPEN, 0x08a1, 6, clif->pReqClickBuyingStore);
- packet(CMSG_STORAGE_PASSWORD, 0x08ab, 36, clif->pStoragePassword);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0919, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_HOMUNCULUS_MENU, 0x0926, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0929, 7, clif->pActionRequest);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0943, 6, clif->pDropItem);
- packet(CMSG_MAP_SERVER_CONNECT, 0x094b, 19, clif->pWantToConnection);
-// packet(UNKNOWN, 0x094c, 4, clif->pDull);
-// packet(UNKNOWN, 0x094f, 8, clif->pDull);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0955, 8, clif->pMoveFromKafra);
- packet(CMSG_MAP_PING, 0x095d, 6, clif->pTickSend);
- packet(CMSG_ITEM_PICKUP, 0x0960, 6, clif->pTakeItem);
- packet(CMSG_SKILL_USE_POSITION, 0x0962, 10, clif->pUseSkillToPos);
-}
-
-// 20141119
-if (packetVersion == 20141119)
-{
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0202, -1, clif->pSearchStoreInfo);
- packet(CMSG_BUYINGSTORE_OPEN, 0x085a, 6, clif->pReqClickBuyingStore);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0861, 26, clif->pFriendsListAdd);
- packet(CMSG_PARTY_INVITE2, 0x0865, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_SELL, 0x0866, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0872, 7, clif->pActionRequest);
- packet(CMSG_SKILL_USE_BEING, 0x0873, 10, clif->pUseSkillToId);
- packet(CMSG_NAME_REQUEST, 0x0875, 6, clif->pGetCharNameRequest);
- packet(CMSG_SOLVE_CHAR_NAME, 0x087c, 6, clif->pSolveCharName);
-// packet(UNKNOWN, 0x0885, 4, clif->pDull);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0887, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0888, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_BUYINGSTORE_CREATE, 0x088d, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0895, -1, clif->pItemListWindowSelected);
- packet(CMSG_ITEM_PICKUP, 0x08a8, 6, clif->pTakeItem);
- packet(CMSG_SEARCHSTORE_CLICK, 0x08aa, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_POSITION, 0x0918, 10, clif->pUseSkillToPos);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0920, 5, clif->pChangeDir);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0921, 19, clif->pWantToConnection);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0929, 8, clif->pMoveFromKafra);
-// packet(UNKNOWN, 0x092f, 8, clif->pDull);
- packet(CMSG_STORAGE_PASSWORD, 0x0933, 36, clif->pStoragePassword);
- packet(CMSG_MAP_PING, 0x0938, 6, clif->pTickSend);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0940, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_MOVE_TO_STORAGE, 0x0941, 8, clif->pMoveToKafra);
- packet(CMSG_HOMUNCULUS_MENU, 0x0942, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0948, 5, clif->pWalkToXY);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x094c, 6, clif->pDropItem);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0963, 90, clif->pUseSkillToPosMoreInfo);
-}
-
-// 20141119
-if (packetVersion >= 20141119)
-{
- packet(CMSG_QUICK_IDENTIFY_ITEM, 0x0a35, 4, clif->pOneClick_ItemIdentify);
-}
-
-// 20141126
-if (packetVersion == 20141126)
-{
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
-// packet(UNKNOWN, 0x0367, 8, clif->pDull);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0802, -1, clif->pSearchStoreInfo);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0819, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_MAP_SERVER_CONNECT, 0x086e, 19, clif->pWantToConnection);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0871, 8, clif->pMoveFromKafra);
-// packet(UNKNOWN, 0x0884, 4, clif->pDull);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0896, -1, clif->pItemListWindowSelected);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x08a4, 5, clif->pChangeDir);
- packet(CMSG_STORAGE_PASSWORD, 0x08ad, 36, clif->pStoragePassword);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0920, 6, clif->pDropItem);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0942, 26, clif->pFriendsListAdd);
- packet(CMSG_ITEM_PICKUP, 0x095a, 6, clif->pTakeItem);
- packet(CMSG_HOMUNCULUS_MENU, 0x095b, 5, clif->pHomMenu);
- packet(CMSG_MOVE_TO_STORAGE, 0x095f, 8, clif->pMoveToKafra);
- packet(CMSG_PARTY_INVITE2, 0x0965, 26, clif->pPartyInvite2);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20141203
-if (packetVersion == 20141203)
-{
- packet(CMSG_SOLVE_CHAR_NAME, 0x0202, 6, clif->pSolveCharName);
- packet(CMSG_BUYINGSTORE_SELL, 0x0281, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0362, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_NAME_REQUEST, 0x0367, 6, clif->pGetCharNameRequest);
-// packet(UNKNOWN, 0x0368, 8, clif->pDull);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0802, 19, clif->pWantToConnection);
- packet(CMSG_MOVE_TO_STORAGE, 0x0861, 8, clif->pMoveToKafra);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x086c, -1, clif->pSearchStoreInfo);
- packet(CMSG_MOVE_FROM_STORAGE, 0x086d, 8, clif->pMoveFromKafra);
- packet(CMSG_ITEM_PICKUP, 0x086e, 6, clif->pTakeItem);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x087b, 5, clif->pWalkToXY);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x087e, -1, clif->pItemListWindowSelected);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0880, 5, clif->pChangeDir);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0889, 26, clif->pFriendsListAdd);
- packet(CMSG_STORAGE_PASSWORD, 0x0898, 36, clif->pStoragePassword);
- packet(CMSG_SKILL_USE_POSITION, 0x089c, 10, clif->pUseSkillToPos);
- packet(CMSG_SEARCHSTORE_CLICK, 0x089d, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x08a5, 7, clif->pActionRequest);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x08aa, 6, clif->pDropItem);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0917, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x091c, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_PARTY_INVITE2, 0x091d, 26, clif->pPartyInvite2);
- packet(CMSG_MAP_PING, 0x0928, 6, clif->pTickSend);
-// packet(UNKNOWN, 0x092a, 4, clif->pDull);
- packet(CMSG_HOMUNCULUS_MENU, 0x0936, 5, clif->pHomMenu);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0952, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0957, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_BUYINGSTORE_OPEN, 0x095c, 6, clif->pReqClickBuyingStore);
- packet(CMSG_SKILL_USE_BEING, 0x0962, 10, clif->pUseSkillToId);
-}
-
-// 20141210
-if (packetVersion == 20141210)
-{
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
- packet(CMSG_HOMUNCULUS_MENU, 0x0436, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x07e4, 5, clif->pChangeDir);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_ITEM_PICKUP, 0x087b, 6, clif->pTakeItem);
- packet(CMSG_BUYINGSTORE_SELL, 0x0885, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x08ac, -1, clif->pItemListWindowSelected);
- packet(CMSG_PARTY_INVITE2, 0x0917, 26, clif->pPartyInvite2);
-// packet(UNKNOWN, 0x0927, 8, clif->pDull);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x092b, 18, clif->pPartyBookingRegisterReq);
-// packet(UNKNOWN, 0x0947, 4, clif->pDull);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0954, 19, clif->pWantToConnection);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0955, 8, clif->pMoveFromKafra);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0958, 6, clif->pDropItem);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0961, 26, clif->pFriendsListAdd);
- packet(CMSG_STORAGE_PASSWORD, 0x0963, 36, clif->pStoragePassword);
- packet(CMSG_MOVE_TO_STORAGE, 0x0967, 8, clif->pMoveToKafra);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20141224
-if (packetVersion == 20141224)
-{
- packet(CMSG_MOVE_TO_STORAGE, 0x0361, 8, clif->pMoveToKafra);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0438, 26, clif->pFriendsListAdd);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0835, -1, clif->pItemListWindowSelected);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x085a, -1, clif->pSearchStoreInfo);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x085e, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0865, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_HOMUNCULUS_MENU, 0x0867, 5, clif->pHomMenu);
- packet(CMSG_BUYINGSTORE_OPEN, 0x086c, 6, clif->pReqClickBuyingStore);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0870, 5, clif->pChangeDir);
- packet(CMSG_ITEM_PICKUP, 0x087a, 6, clif->pTakeItem);
-// packet(UNKNOWN, 0x087b, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x089a, 5, clif->pWalkToXY);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x089b, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_PARTY_INVITE2, 0x08a3, 26, clif->pPartyInvite2);
- packet(CMSG_STORAGE_PASSWORD, 0x08a4, 36, clif->pStoragePassword);
- packet(CMSG_BUYINGSTORE_SELL, 0x08a8, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x08ac, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0930, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x0932, 8, clif->pDull);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x093a, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_MAP_PING, 0x0945, 6, clif->pTickSend);
- packet(CMSG_NAME_REQUEST, 0x0946, 6, clif->pGetCharNameRequest);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0949, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_MAP_SERVER_CONNECT, 0x094f, 19, clif->pWantToConnection);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0950, 6, clif->pSolveCharName);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0953, 8, clif->pMoveFromKafra);
- packet(CMSG_SKILL_USE_POSITION, 0x0956, 10, clif->pUseSkillToPos);
- packet(CMSG_SKILL_USE_BEING, 0x095b, 10, clif->pUseSkillToId);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x095f, 7, clif->pActionRequest);
-}
-
-// 20141231
-if (packetVersion == 20141231)
-{
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0202, 5, clif->pChangeDir);
- packet(CMSG_MAP_SERVER_CONNECT, 0x022d, 19, clif->pWantToConnection);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x023b, 26, clif->pFriendsListAdd);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0281, -1, clif->pItemListWindowSelected);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x0361, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0362, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x0363, 8, clif->pDull);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0364, 8, clif->pMoveFromKafra);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0365, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
-// packet(UNKNOWN, 0x0436, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_ITEM_PICKUP, 0x07e4, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x07ec, 8, clif->pMoveToKafra);
- packet(CMSG_PARTY_INVITE2, 0x0802, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_STORAGE_PASSWORD, 0x086d, 36, clif->pStoragePassword);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20150107
-if (packetVersion == 20150107)
-{
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0281, -1, clif->pItemListWindowSelected);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0362, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x0363, 8, clif->pDull);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0364, 8, clif->pMoveFromKafra);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0365, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
-// packet(UNKNOWN, 0x0436, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_ITEM_PICKUP, 0x07e4, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x07ec, 8, clif->pMoveToKafra);
- packet(CMSG_PARTY_INVITE2, 0x0802, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x087c, 26, clif->pFriendsListAdd);
- packet(CMSG_STORAGE_PASSWORD, 0x0895, 36, clif->pStoragePassword);
- packet(CMSG_HOMUNCULUS_MENU, 0x092d, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0943, 5, clif->pChangeDir);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0947, 19, clif->pWantToConnection);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20150114
-if (packetVersion == 20150114)
-{
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0281, -1, clif->pItemListWindowSelected);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0362, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x0363, 8, clif->pDull);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0364, 8, clif->pMoveFromKafra);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0365, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
- packet(CMSG_SKILL_USE_BEING, 0x0436, 10, clif->pUseSkillToId);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_ITEM_PICKUP, 0x07e4, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x07ec, 8, clif->pMoveToKafra);
- packet(CMSG_PARTY_INVITE2, 0x0802, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_MAP_SERVER_CONNECT, 0x083c, 19, clif->pWantToConnection);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0868, 26, clif->pFriendsListAdd);
- packet(CMSG_HOMUNCULUS_MENU, 0x0899, 5, clif->pHomMenu);
- packet(CMSG_STORAGE_PASSWORD, 0x0946, 36, clif->pStoragePassword);
-// packet(UNKNOWN, 0x0955, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0957, 5, clif->pChangeDir);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20150121
-if (packetVersion == 20150121)
-{
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0281, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x07e4, -1, clif->pItemListWindowSelected);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
-// packet(UNKNOWN, 0x087c, 4, clif->pDull);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x088b, 26, clif->pFriendsListAdd);
- packet(CMSG_HOMUNCULUS_MENU, 0x089d, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x089e, 5, clif->pChangeDir);
- packet(CMSG_STORAGE_PASSWORD, 0x08ab, 36, clif->pStoragePassword);
-// packet(UNKNOWN, 0x0918, 8, clif->pDull);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0919, 6, clif->pDropItem);
- packet(CMSG_ITEM_PICKUP, 0x091d, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x0955, 8, clif->pMoveToKafra);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0959, 19, clif->pWantToConnection);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0963, 8, clif->pMoveFromKafra);
- packet(CMSG_PARTY_INVITE2, 0x0967, 26, clif->pPartyInvite2);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20150128
-if (packetVersion == 20150128)
-{
- packet(CMSG_SEARCHSTORE_CLICK, 0x0202, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x023b, 5, clif->pChangeDir);
- packet(CMSG_BUYINGSTORE_OPEN, 0x035f, 6, clif->pReqClickBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0365, -1, clif->pSearchStoreInfo);
-// packet(UNKNOWN, 0x0368, 8, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0838, 7, clif->pActionRequest);
- packet(CMSG_BUYINGSTORE_CREATE, 0x085a, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_SKILL_USE_POSITION, 0x0864, 10, clif->pUseSkillToPos);
- packet(CMSG_MOVE_TO_STORAGE, 0x086d, 8, clif->pMoveToKafra);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0870, 5, clif->pWalkToXY);
- packet(CMSG_NAME_REQUEST, 0x0874, 6, clif->pGetCharNameRequest);
- packet(CMSG_BUYINGSTORE_SELL, 0x0875, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x0876, 5, clif->pHomMenu);
- packet(CMSG_SOLVE_CHAR_NAME, 0x087d, 6, clif->pSolveCharName);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0888, -1, clif->pItemListWindowSelected);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x089a, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_ITEM_PICKUP, 0x08ab, 6, clif->pTakeItem);
- packet(CMSG_MAP_PING, 0x091f, 6, clif->pTickSend);
- packet(CMSG_PARTY_INVITE2, 0x0927, 26, clif->pPartyInvite2);
- packet(CMSG_STORAGE_PASSWORD, 0x0929, 36, clif->pStoragePassword);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x092d, 2, clif->pSearchStoreInfoNextPage);
-// packet(UNKNOWN, 0x0938, 4, clif->pDull);
- packet(CMSG_SKILL_USE_BEING, 0x093a, 10, clif->pUseSkillToId);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0944, 19, clif->pWantToConnection);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x094d, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_MOVE_FROM_STORAGE, 0x094e, 8, clif->pMoveFromKafra);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0952, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0963, 26, clif->pFriendsListAdd);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0968, 6, clif->pDropItem);
-}
-
-// 20150129
-if (packetVersion == 20150129)
-{
- packet(CMSG_SEARCHSTORE_CLICK, 0x0202, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x023b, 5, clif->pChangeDir);
- packet(CMSG_BUYINGSTORE_OPEN, 0x035f, 6, clif->pReqClickBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0365, -1, clif->pSearchStoreInfo);
-// packet(UNKNOWN, 0x0368, 8, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0838, 7, clif->pActionRequest);
- packet(CMSG_BUYINGSTORE_CREATE, 0x085a, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_SKILL_USE_POSITION, 0x0864, 10, clif->pUseSkillToPos);
- packet(CMSG_MOVE_TO_STORAGE, 0x086d, 8, clif->pMoveToKafra);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0870, 5, clif->pWalkToXY);
- packet(CMSG_NAME_REQUEST, 0x0874, 6, clif->pGetCharNameRequest);
- packet(CMSG_BUYINGSTORE_SELL, 0x0875, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x0876, 5, clif->pHomMenu);
- packet(CMSG_SOLVE_CHAR_NAME, 0x087d, 6, clif->pSolveCharName);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0888, -1, clif->pItemListWindowSelected);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x089a, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_ITEM_PICKUP, 0x08ab, 6, clif->pTakeItem);
- packet(CMSG_MAP_PING, 0x091f, 6, clif->pTickSend);
- packet(CMSG_PARTY_INVITE2, 0x0927, 26, clif->pPartyInvite2);
- packet(CMSG_STORAGE_PASSWORD, 0x0929, 36, clif->pStoragePassword);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x092d, 2, clif->pSearchStoreInfoNextPage);
-// packet(UNKNOWN, 0x0938, 4, clif->pDull);
- packet(CMSG_SKILL_USE_BEING, 0x093a, 10, clif->pUseSkillToId);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0944, 19, clif->pWantToConnection);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x094d, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_MOVE_FROM_STORAGE, 0x094e, 8, clif->pMoveFromKafra);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0952, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0963, 26, clif->pFriendsListAdd);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0968, 6, clif->pDropItem);
-}
-
-// 20150130
-if (packetVersion == 20150130)
-{
- packet(CMSG_SEARCHSTORE_CLICK, 0x0202, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x023b, 5, clif->pChangeDir);
- packet(CMSG_BUYINGSTORE_OPEN, 0x035f, 6, clif->pReqClickBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0365, -1, clif->pSearchStoreInfo);
-// packet(UNKNOWN, 0x0368, 8, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0838, 7, clif->pActionRequest);
- packet(CMSG_BUYINGSTORE_CREATE, 0x085a, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_SKILL_USE_POSITION, 0x0864, 10, clif->pUseSkillToPos);
- packet(CMSG_MOVE_TO_STORAGE, 0x086d, 8, clif->pMoveToKafra);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0870, 5, clif->pWalkToXY);
- packet(CMSG_NAME_REQUEST, 0x0874, 6, clif->pGetCharNameRequest);
- packet(CMSG_BUYINGSTORE_SELL, 0x0875, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x0876, 5, clif->pHomMenu);
- packet(CMSG_SOLVE_CHAR_NAME, 0x087d, 6, clif->pSolveCharName);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0888, -1, clif->pItemListWindowSelected);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x089a, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_ITEM_PICKUP, 0x08ab, 6, clif->pTakeItem);
- packet(CMSG_MAP_PING, 0x091f, 6, clif->pTickSend);
- packet(CMSG_PARTY_INVITE2, 0x0927, 26, clif->pPartyInvite2);
- packet(CMSG_STORAGE_PASSWORD, 0x0929, 36, clif->pStoragePassword);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x092d, 2, clif->pSearchStoreInfoNextPage);
-// packet(UNKNOWN, 0x0938, 4, clif->pDull);
- packet(CMSG_SKILL_USE_BEING, 0x093a, 10, clif->pUseSkillToId);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0944, 19, clif->pWantToConnection);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x094d, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_MOVE_FROM_STORAGE, 0x094e, 8, clif->pMoveFromKafra);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0952, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0963, 26, clif->pFriendsListAdd);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0968, 6, clif->pDropItem);
-}
-
-// 20150204
-if (packetVersion == 20150204)
-{
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0202, 5, clif->pChangeDir);
- packet(CMSG_MAP_SERVER_CONNECT, 0x022d, 19, clif->pWantToConnection);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x023b, 26, clif->pFriendsListAdd);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0281, -1, clif->pItemListWindowSelected);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x0361, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0362, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x0363, 8, clif->pDull);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0364, 8, clif->pMoveFromKafra);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0365, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
-// packet(UNKNOWN, 0x0436, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_ITEM_PICKUP, 0x07e4, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x07ec, 8, clif->pMoveToKafra);
- packet(CMSG_PARTY_INVITE2, 0x0802, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_STORAGE_PASSWORD, 0x0966, 36, clif->pStoragePassword);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20150211
-if (packetVersion == 20150211)
-{
-// packet(UNKNOWN, 0x023b, 4, clif->pDull);
- packet(CMSG_HOMUNCULUS_MENU, 0x0368, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0369, 5, clif->pChangeDir);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0436, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0437, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x07e4, 6, clif->pDropItem);
- packet(CMSG_SKILL_USE_POSITION, 0x0817, 10, clif->pUseSkillToPos);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0819, 2, clif->pReqCloseBuyingStore);
-// packet(UNKNOWN, 0x0835, 8, clif->pDull);
- packet(CMSG_BUYINGSTORE_SELL, 0x0862, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_SKILL_USE_BEING, 0x0863, 10, clif->pUseSkillToId);
- packet(CMSG_ITEM_PICKUP, 0x0870, 6, clif->pTakeItem);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0873, 5, clif->pWalkToXY);
- packet(CMSG_NAME_REQUEST, 0x087b, 6, clif->pGetCharNameRequest);
- packet(CMSG_STORAGE_PASSWORD, 0x087f, 36, clif->pStoragePassword);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0882, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0883, 8, clif->pMoveFromKafra);
- packet(CMSG_MAP_PING, 0x0885, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0886, 6, clif->pReqClickBuyingStore);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x089c, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x08a0, 26, clif->pFriendsListAdd);
- packet(CMSG_MAP_SERVER_CONNECT, 0x08a4, 19, clif->pWantToConnection);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x08aa, 7, clif->pActionRequest);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0919, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0920, 6, clif->pSolveCharName);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0944, -1, clif->pSearchStoreInfo);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0951, -1, clif->pItemListWindowSelected);
- packet(CMSG_PARTY_INVITE2, 0x0957, 26, clif->pPartyInvite2);
- packet(CMSG_MOVE_TO_STORAGE, 0x0958, 8, clif->pMoveToKafra);
-}
-
-// 20150217
-if (packetVersion == 20150217)
-{
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0202, 5, clif->pChangeDir);
- packet(CMSG_MAP_SERVER_CONNECT, 0x022d, 19, clif->pWantToConnection);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x023b, 26, clif->pFriendsListAdd);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0281, -1, clif->pItemListWindowSelected);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x0361, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0362, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x0363, 8, clif->pDull);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0364, 8, clif->pMoveFromKafra);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0365, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
-// packet(UNKNOWN, 0x0436, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_ITEM_PICKUP, 0x07e4, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x07ec, 8, clif->pMoveToKafra);
- packet(CMSG_PARTY_INVITE2, 0x0802, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_STORAGE_PASSWORD, 0x085b, 36, clif->pStoragePassword);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20150225
-if (packetVersion == 20150225)
-{
- packet(CMSG_BUYINGSTORE_OPEN, 0x02c4, 6, clif->pReqClickBuyingStore);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_PARTY_INVITE2, 0x0360, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0362, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
- packet(CMSG_NAME_REQUEST, 0x0436, 6, clif->pGetCharNameRequest);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_ITEM_PICKUP, 0x0817, 6, clif->pTakeItem);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0819, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0867, 18, clif->pPartyBookingRegisterReq);
-// packet(UNKNOWN, 0x0885, 4, clif->pDull);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0896, -1, clif->pItemListWindowSelected);
-// packet(UNKNOWN, 0x089b, 8, clif->pDull);
- packet(CMSG_MOVE_TO_STORAGE, 0x089c, 8, clif->pMoveToKafra);
- packet(CMSG_STORAGE_PASSWORD, 0x08a4, 36, clif->pStoragePassword);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0940, -1, clif->pSearchStoreInfo);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0946, 26, clif->pFriendsListAdd);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0948, 6, clif->pDropItem);
- packet(CMSG_HOMUNCULUS_MENU, 0x094f, 5, clif->pHomMenu);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0952, 8, clif->pMoveFromKafra);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0955, 5, clif->pChangeDir);
- packet(CMSG_MAP_SERVER_CONNECT, 0x096a, 19, clif->pWantToConnection);
-}
-
-// 20150226
-if (packetVersion == 20150226)
-{
- packet(CMSG_BUYINGSTORE_OPEN, 0x02c4, 6, clif->pReqClickBuyingStore);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_PARTY_INVITE2, 0x0360, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0362, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
- packet(CMSG_NAME_REQUEST, 0x0436, 6, clif->pGetCharNameRequest);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_ITEM_PICKUP, 0x0817, 6, clif->pTakeItem);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0819, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0867, 18, clif->pPartyBookingRegisterReq);
-// packet(UNKNOWN, 0x0885, 4, clif->pDull);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0896, -1, clif->pItemListWindowSelected);
-// packet(UNKNOWN, 0x089b, 8, clif->pDull);
- packet(CMSG_MOVE_TO_STORAGE, 0x089c, 8, clif->pMoveToKafra);
- packet(CMSG_STORAGE_PASSWORD, 0x08a4, 36, clif->pStoragePassword);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0940, -1, clif->pSearchStoreInfo);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0946, 26, clif->pFriendsListAdd);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0948, 6, clif->pDropItem);
- packet(CMSG_HOMUNCULUS_MENU, 0x094f, 5, clif->pHomMenu);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0952, 8, clif->pMoveFromKafra);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0955, 5, clif->pChangeDir);
- packet(CMSG_MAP_SERVER_CONNECT, 0x096a, 19, clif->pWantToConnection);
-}
-
-// 20150304
-if (packetVersion == 20150304)
-{
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0362, 6, clif->pDropItem);
- packet(CMSG_ITEM_PICKUP, 0x0363, 6, clif->pTakeItem);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
-// packet(UNKNOWN, 0x0802, 4, clif->pDull);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0862, 8, clif->pMoveFromKafra);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x086d, -1, clif->pItemListWindowSelected);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0879, 5, clif->pChangeDir);
- packet(CMSG_MAP_SERVER_CONNECT, 0x087e, 19, clif->pWantToConnection);
- packet(CMSG_STORAGE_PASSWORD, 0x0892, 36, clif->pStoragePassword);
- packet(CMSG_PARTY_INVITE2, 0x089a, 26, clif->pPartyInvite2);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x093a, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_MOVE_TO_STORAGE, 0x0947, 8, clif->pMoveToKafra);
-// packet(UNKNOWN, 0x095d, 8, clif->pDull);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0960, 26, clif->pFriendsListAdd);
- packet(CMSG_HOMUNCULUS_MENU, 0x0961, 5, clif->pHomMenu);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20150311
-if (packetVersion == 20150311)
-{
- packet(CMSG_HOMUNCULUS_MENU, 0x023b, 5, clif->pHomMenu);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0360, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0436, -1, clif->pSearchStoreInfo);
- packet(CMSG_BUYINGSTORE_SELL, 0x0438, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0815, 19, clif->pWantToConnection);
- packet(CMSG_SKILL_USE_POSITION, 0x0838, 10, clif->pUseSkillToPos);
- packet(CMSG_NAME_REQUEST, 0x086a, 6, clif->pGetCharNameRequest);
- packet(CMSG_STORAGE_PASSWORD, 0x086c, 36, clif->pStoragePassword);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x087b, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0883, -1, clif->pItemListWindowSelected);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0886, 5, clif->pWalkToXY);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0888, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0896, 7, clif->pActionRequest);
- packet(CMSG_SKILL_USE_BEING, 0x08a1, 10, clif->pUseSkillToId);
- packet(CMSG_ITEM_PICKUP, 0x08a3, 6, clif->pTakeItem);
- packet(CMSG_SEARCHSTORE_CLICK, 0x08a5, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x08a6, 26, clif->pFriendsListAdd);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x091c, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0928, 5, clif->pChangeDir);
-// packet(UNKNOWN, 0x092a, 8, clif->pDull);
- packet(CMSG_MOVE_FROM_STORAGE, 0x092e, 8, clif->pMoveFromKafra);
- packet(CMSG_PARTY_INVITE2, 0x093b, 26, clif->pPartyInvite2);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0943, 6, clif->pSolveCharName);
-// packet(UNKNOWN, 0x0946, 4, clif->pDull);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0957, 6, clif->pReqClickBuyingStore);
- packet(CMSG_MAP_PING, 0x0958, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_CREATE, 0x095b, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0963, 6, clif->pDropItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x0964, 8, clif->pMoveToKafra);
-}
-
-// 20150318
-if (packetVersion == 20150318)
-{
-// packet(UNKNOWN, 0x0202, 4, clif->pDull);
- packet(CMSG_MAP_PING, 0x023b, 6, clif->pTickSend);
-// packet(UNKNOWN, 0x0281, 8, clif->pDull);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0367, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x07e4, 26, clif->pFriendsListAdd);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0802, -1, clif->pItemListWindowSelected);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0811, 19, clif->pWantToConnection);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0862, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0863, 6, clif->pReqClickBuyingStore);
- packet(CMSG_STORAGE_PASSWORD, 0x0873, 36, clif->pStoragePassword);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0885, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0889, 7, clif->pActionRequest);
- packet(CMSG_SEARCHSTORE_CLICK, 0x088c, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_MOVE_TO_STORAGE, 0x089c, 8, clif->pMoveToKafra);
- packet(CMSG_BUYINGSTORE_SELL, 0x08a4, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_MOVE_FROM_STORAGE, 0x091d, 8, clif->pMoveFromKafra);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0920, 6, clif->pDropItem);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0927, 5, clif->pChangeDir);
- packet(CMSG_ITEM_PICKUP, 0x0928, 6, clif->pTakeItem);
- packet(CMSG_SKILL_USE_BEING, 0x0936, 10, clif->pUseSkillToId);
- packet(CMSG_SKILL_USE_POSITION, 0x0937, 10, clif->pUseSkillToPos);
- packet(CMSG_PARTY_INVITE2, 0x0938, 26, clif->pPartyInvite2);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x093a, 5, clif->pWalkToXY);
- packet(CMSG_SOLVE_CHAR_NAME, 0x093c, 6, clif->pSolveCharName);
- packet(CMSG_HOMUNCULUS_MENU, 0x094c, 5, clif->pHomMenu);
- packet(CMSG_NAME_REQUEST, 0x0951, 6, clif->pGetCharNameRequest);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0958, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0959, -1, clif->pSearchStoreInfo);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0960, 18, clif->pPartyBookingRegisterReq);
-}
-
-// 20150325
-if (packetVersion == 20150325)
-{
- packet(CMSG_PARTY_INVITE2, 0x0202, 26, clif->pPartyInvite2);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0363, 6, clif->pDropItem);
- packet(CMSG_SKILL_USE_BEING, 0x0365, 10, clif->pUseSkillToId);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0438, 2, clif->pSearchStoreInfoNextPage);
-// packet(UNKNOWN, 0x0802, 4, clif->pDull);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0819, 6, clif->pReqClickBuyingStore);
- packet(CMSG_SOLVE_CHAR_NAME, 0x085d, 6, clif->pSolveCharName);
- packet(CMSG_BUYINGSTORE_CREATE, 0x086f, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_MOVE_TO_STORAGE, 0x087c, 8, clif->pMoveToKafra);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x087e, 5, clif->pChangeDir);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0883, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_POSITION, 0x0885, 10, clif->pUseSkillToPos);
- packet(CMSG_NAME_REQUEST, 0x0891, 6, clif->pGetCharNameRequest);
-// packet(UNKNOWN, 0x0893, 8, clif->pDull);
- packet(CMSG_BUYINGSTORE_SELL, 0x0897, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0899, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x08a1, 7, clif->pActionRequest);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x08a7, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_STORAGE_PASSWORD, 0x0919, 36, clif->pStoragePassword);
- packet(CMSG_ITEM_PICKUP, 0x092c, 6, clif->pTakeItem);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0931, -1, clif->pSearchStoreInfo);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0932, 5, clif->pWalkToXY);
- packet(CMSG_HOMUNCULUS_MENU, 0x0938, 5, clif->pHomMenu);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0940, 26, clif->pFriendsListAdd);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0947, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_MAP_SERVER_CONNECT, 0x094a, 19, clif->pWantToConnection);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0950, -1, clif->pItemListWindowSelected);
- packet(CMSG_MAP_PING, 0x0954, 6, clif->pTickSend);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0969, 8, clif->pMoveFromKafra);
-}
-
-// 20150401
-if (packetVersion == 20150401)
-{
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0362, 7, clif->pActionRequest);
- packet(CMSG_NAME_REQUEST, 0x0367, 6, clif->pGetCharNameRequest);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0437, 6, clif->pReqClickBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x083c, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_CLICK, 0x085e, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x086f, 5, clif->pWalkToXY);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0875, -1, clif->pItemListWindowSelected);
-// packet(UNKNOWN, 0x087e, 8, clif->pDull);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x088c, 6, clif->pDropItem);
- packet(CMSG_MAP_PING, 0x088f, 6, clif->pTickSend);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0895, 8, clif->pMoveFromKafra);
- packet(CMSG_HOMUNCULUS_MENU, 0x0898, 5, clif->pHomMenu);
- packet(CMSG_STORAGE_PASSWORD, 0x089c, 36, clif->pStoragePassword);
- packet(CMSG_MOVE_TO_STORAGE, 0x08a5, 8, clif->pMoveToKafra);
- packet(CMSG_PARTY_INVITE2, 0x091b, 26, clif->pPartyInvite2);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x091c, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0922, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0924, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0938, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0939, 19, clif->pWantToConnection);
- packet(CMSG_SKILL_USE_POSITION, 0x093a, 10, clif->pUseSkillToPos);
- packet(CMSG_BUYINGSTORE_SELL, 0x093b, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x093e, 2, clif->pSearchStoreInfoNextPage);
-// packet(UNKNOWN, 0x0946, 4, clif->pDull);
- packet(CMSG_ITEM_PICKUP, 0x0949, 6, clif->pTakeItem);
- packet(CMSG_SKILL_USE_BEING, 0x094b, 10, clif->pUseSkillToId);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0953, 26, clif->pFriendsListAdd);
- packet(CMSG_SOLVE_CHAR_NAME, 0x095f, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0964, 5, clif->pChangeDir);
-}
-
-// 20150408
-if (packetVersion == 20150408)
-{
- packet(CMSG_MOVE_FROM_STORAGE, 0x0819, 8, clif->pMoveFromKafra);
- packet(CMSG_MAP_PING, 0x085a, 6, clif->pTickSend);
- packet(CMSG_SKILL_USE_BEING, 0x085c, 10, clif->pUseSkillToId);
- packet(CMSG_HOMUNCULUS_MENU, 0x085e, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0865, 7, clif->pActionRequest);
- packet(CMSG_BUYINGSTORE_SELL, 0x0868, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x086b, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_SKILL_USE_POSITION, 0x086e, 10, clif->pUseSkillToPos);
- packet(CMSG_PARTY_INVITE2, 0x0878, 26, clif->pPartyInvite2);
- packet(CMSG_NAME_REQUEST, 0x087e, 6, clif->pGetCharNameRequest);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x087f, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_MOVE_TO_STORAGE, 0x0888, 8, clif->pMoveToKafra);
- packet(CMSG_STORAGE_PASSWORD, 0x0889, 36, clif->pStoragePassword);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0891, -1, clif->pSearchStoreInfo);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0898, 6, clif->pDropItem);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x089c, 5, clif->pWalkToXY);
- packet(CMSG_SOLVE_CHAR_NAME, 0x08a2, 6, clif->pSolveCharName);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x08a4, 26, clif->pFriendsListAdd);
-// packet(UNKNOWN, 0x091b, 4, clif->pDull);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x091e, -1, clif->pItemListWindowSelected);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0922, 5, clif->pChangeDir);
-// packet(UNKNOWN, 0x092a, 8, clif->pDull);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0946, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x094f, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0955, 6, clif->pReqClickBuyingStore);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0957, 19, clif->pWantToConnection);
- packet(CMSG_ITEM_PICKUP, 0x0959, 6, clif->pTakeItem);
- packet(CMSG_SEARCHSTORE_CLICK, 0x095e, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0963, 2, clif->pSearchStoreInfoNextPage);
-}
-
-// 20150415
-if (packetVersion == 20150415)
-{
- packet(CMSG_MOVE_TO_STORAGE, 0x0361, 8, clif->pMoveToKafra);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0364, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0366, 5, clif->pWalkToXY);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0368, 6, clif->pReqClickBuyingStore);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0802, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_ITEM_PICKUP, 0x0817, 6, clif->pTakeItem);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0835, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x085e, 4, clif->pDull);
- packet(CMSG_BUYINGSTORE_SELL, 0x0863, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_PARTY_INVITE2, 0x0867, 26, clif->pPartyInvite2);
- packet(CMSG_SKILL_USE_POSITION, 0x0868, 10, clif->pUseSkillToPos);
- packet(CMSG_HOMUNCULUS_MENU, 0x0869, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x086c, 7, clif->pActionRequest);
-// packet(UNKNOWN, 0x0880, 8, clif->pDull);
- packet(CMSG_SKILL_USE_BEING, 0x088e, 10, clif->pUseSkillToId);
- packet(CMSG_NAME_REQUEST, 0x0891, 6, clif->pGetCharNameRequest);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0898, -1, clif->pItemListWindowSelected);
- packet(CMSG_BUYINGSTORE_CREATE, 0x08a0, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0922, 8, clif->pMoveFromKafra);
- packet(CMSG_SOLVE_CHAR_NAME, 0x092e, 6, clif->pSolveCharName);
- packet(CMSG_MAP_PING, 0x093c, 6, clif->pTickSend);
- packet(CMSG_SEARCHSTORE_CLICK, 0x093e, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0941, 19, clif->pWantToConnection);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0946, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x094d, 5, clif->pChangeDir);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0953, -1, clif->pSearchStoreInfo);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x095c, 26, clif->pFriendsListAdd);
- packet(CMSG_STORAGE_PASSWORD, 0x0960, 36, clif->pStoragePassword);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0961, 18, clif->pPartyBookingRegisterReq);
-}
-
-// 20150422
-if (packetVersion == 20150422)
-{
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0202, 5, clif->pChangeDir);
- packet(CMSG_MAP_SERVER_CONNECT, 0x022d, 19, clif->pWantToConnection);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x023b, 26, clif->pFriendsListAdd);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0281, -1, clif->pItemListWindowSelected);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x0361, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0362, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x0363, 8, clif->pDull);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0364, 8, clif->pMoveFromKafra);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0365, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
-// packet(UNKNOWN, 0x0436, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_ITEM_PICKUP, 0x07e4, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x07ec, 8, clif->pMoveToKafra);
- packet(CMSG_PARTY_INVITE2, 0x0802, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_STORAGE_PASSWORD, 0x0955, 36, clif->pStoragePassword);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20150429
-if (packetVersion == 20150429)
-{
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0363, 5, clif->pChangeDir);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_STORAGE_PASSWORD, 0x0867, 36, clif->pStoragePassword);
- packet(CMSG_MAP_SERVER_CONNECT, 0x086a, 19, clif->pWantToConnection);
- packet(CMSG_PARTY_INVITE2, 0x0886, 26, clif->pPartyInvite2);
- packet(CMSG_HOMUNCULUS_MENU, 0x088f, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0894, 6, clif->pDropItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x0899, 8, clif->pMoveToKafra);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x089f, -1, clif->pItemListWindowSelected);
-// packet(UNKNOWN, 0x08a6, 8, clif->pDull);
-// packet(UNKNOWN, 0x08a8, 4, clif->pDull);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x08ad, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0929, 8, clif->pMoveFromKafra);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x093d, 26, clif->pFriendsListAdd);
- packet(CMSG_ITEM_PICKUP, 0x0943, 6, clif->pTakeItem);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20150507
-if (packetVersion == 20150507)
-{
- packet(CMSG_HOMUNCULUS_MENU, 0x023b, 5, clif->pHomMenu);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0362, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_ITEM_PICKUP, 0x0817, 6, clif->pTakeItem);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_MOVE_TO_STORAGE, 0x085a, 8, clif->pMoveToKafra);
- packet(CMSG_PARTY_INVITE2, 0x0864, 26, clif->pPartyInvite2);
-// packet(UNKNOWN, 0x0887, 8, clif->pDull);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0889, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0924, 19, clif->pWantToConnection);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x092e, -1, clif->pItemListWindowSelected);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x093b, 5, clif->pChangeDir);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0941, 8, clif->pMoveFromKafra);
-// packet(UNKNOWN, 0x0942, 4, clif->pDull);
- packet(CMSG_STORAGE_PASSWORD, 0x0953, 36, clif->pStoragePassword);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0955, 6, clif->pDropItem);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0958, 26, clif->pFriendsListAdd);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20150513
-if (packetVersion == 20150513)
-{
- packet(CMSG_BUYINGSTORE_CLOSE, 0x022d, 2, clif->pReqCloseBuyingStore);
-// packet(UNKNOWN, 0x02c4, 8, clif->pDull);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0363, 19, clif->pWantToConnection);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x0817, 5, clif->pHomMenu);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0864, 8, clif->pMoveFromKafra);
- packet(CMSG_MOVE_TO_STORAGE, 0x0879, 8, clif->pMoveToKafra);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0883, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0885, 6, clif->pDropItem);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x08a8, 26, clif->pFriendsListAdd);
- packet(CMSG_STORAGE_PASSWORD, 0x0923, 36, clif->pStoragePassword);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0924, 5, clif->pChangeDir);
-// packet(UNKNOWN, 0x0927, 4, clif->pDull);
- packet(CMSG_PARTY_INVITE2, 0x094a, 26, clif->pPartyInvite2);
- packet(CMSG_ITEM_PICKUP, 0x0958, 6, clif->pTakeItem);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0960, -1, clif->pItemListWindowSelected);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20150520
-if (packetVersion == 20150520)
-{
- packet(CMSG_MAP_PING, 0x0202, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_SELL, 0x0361, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0835, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_BUYINGSTORE_OPEN, 0x085e, 6, clif->pReqClickBuyingStore);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0865, 19, clif->pWantToConnection);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0868, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_SEARCHSTORE_CLICK, 0x087d, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_PARTY_INVITE2, 0x0880, 26, clif->pPartyInvite2);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0882, -1, clif->pItemListWindowSelected);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x088c, -1, clif->pSearchStoreInfo);
- packet(CMSG_STORAGE_PASSWORD, 0x089c, 36, clif->pStoragePassword);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x089e, 6, clif->pDropItem);
- packet(CMSG_NAME_REQUEST, 0x08a2, 6, clif->pGetCharNameRequest);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x08ad, 5, clif->pChangeDir);
- packet(CMSG_ITEM_PICKUP, 0x091c, 6, clif->pTakeItem);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x091d, 7, clif->pActionRequest);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0924, 8, clif->pMoveFromKafra);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x092b, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0931, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SKILL_USE_BEING, 0x0936, 10, clif->pUseSkillToId);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x093d, 26, clif->pFriendsListAdd);
-// packet(UNKNOWN, 0x0940, 8, clif->pDull);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0945, 6, clif->pSolveCharName);
- packet(CMSG_SKILL_USE_POSITION, 0x094e, 10, clif->pUseSkillToPos);
- packet(CMSG_HOMUNCULUS_MENU, 0x095b, 5, clif->pHomMenu);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x095f, 2, clif->pSearchStoreInfoNextPage);
-// packet(UNKNOWN, 0x0960, 4, clif->pDull);
- packet(CMSG_MOVE_TO_STORAGE, 0x0961, 8, clif->pMoveToKafra);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x096a, 18, clif->pPartyBookingRegisterReq);
-}
-
-// 20150527
-if (packetVersion == 20150527)
-{
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0202, 5, clif->pChangeDir);
- packet(CMSG_MAP_SERVER_CONNECT, 0x022d, 19, clif->pWantToConnection);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x023b, 26, clif->pFriendsListAdd);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0281, -1, clif->pItemListWindowSelected);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x0361, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0362, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x0363, 8, clif->pDull);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0364, 8, clif->pMoveFromKafra);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0365, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
-// packet(UNKNOWN, 0x0436, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_ITEM_PICKUP, 0x07e4, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x07ec, 8, clif->pMoveToKafra);
- packet(CMSG_PARTY_INVITE2, 0x0802, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SKILL_USE_BEING, 0x0838, 10, clif->pUseSkillToId);
- packet(CMSG_STORAGE_PASSWORD, 0x083c, 36, clif->pStoragePassword);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0940, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20150603
-if (packetVersion == 20150603)
-{
- packet(CMSG_PARTY_INVITE2, 0x0361, 26, clif->pPartyInvite2);
-// packet(UNKNOWN, 0x0437, 8, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0811, 5, clif->pChangeDir);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0819, 6, clif->pReqClickBuyingStore);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0860, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0864, 26, clif->pFriendsListAdd);
- packet(CMSG_MOVE_TO_STORAGE, 0x0867, 8, clif->pMoveToKafra);
- packet(CMSG_MOVE_FROM_STORAGE, 0x086a, 8, clif->pMoveFromKafra);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0873, 7, clif->pActionRequest);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0877, -1, clif->pItemListWindowSelected);
- packet(CMSG_NAME_REQUEST, 0x0881, 6, clif->pGetCharNameRequest);
-// packet(UNKNOWN, 0x0884, 4, clif->pDull);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x088b, 6, clif->pDropItem);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0897, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_CLICK, 0x089a, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_BUYINGSTORE_CREATE, 0x089d, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_MAP_PING, 0x089e, 6, clif->pTickSend);
- packet(CMSG_SKILL_USE_POSITION, 0x08a1, 10, clif->pUseSkillToPos);
- packet(CMSG_MAP_SERVER_CONNECT, 0x08ad, 19, clif->pWantToConnection);
- packet(CMSG_SOLVE_CHAR_NAME, 0x091b, 6, clif->pSolveCharName);
- packet(CMSG_STORAGE_PASSWORD, 0x0922, 36, clif->pStoragePassword);
- packet(CMSG_ITEM_PICKUP, 0x092d, 6, clif->pTakeItem);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x093b, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x093f, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_HOMUNCULUS_MENU, 0x0955, 5, clif->pHomMenu);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0956, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SKILL_USE_BEING, 0x0960, 10, clif->pUseSkillToId);
- packet(CMSG_BUYINGSTORE_SELL, 0x0969, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x096a, 5, clif->pWalkToXY);
-}
-
-// 20150610
-if (packetVersion == 20150610)
-{
- packet(CMSG_BUYINGSTORE_CLOSE, 0x022d, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0438, -1, clif->pItemListWindowSelected);
- packet(CMSG_BUYINGSTORE_SELL, 0x07e4, -1, clif->pReqTradeBuyingStore);
-// packet(UNKNOWN, 0x0835, 8, clif->pDull);
- packet(CMSG_PARTY_INVITE2, 0x0870, 26, clif->pPartyInvite2);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0872, 6, clif->pSolveCharName);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0877, 6, clif->pReqClickBuyingStore);
- packet(CMSG_NAME_REQUEST, 0x087e, 6, clif->pGetCharNameRequest);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0884, 8, clif->pMoveFromKafra);
- packet(CMSG_HOMUNCULUS_MENU, 0x0885, 5, clif->pHomMenu);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0888, 19, clif->pWantToConnection);
- packet(CMSG_MOVE_TO_STORAGE, 0x088c, 8, clif->pMoveToKafra);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x088d, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x088f, 5, clif->pWalkToXY);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0897, 26, clif->pFriendsListAdd);
- packet(CMSG_STORAGE_PASSWORD, 0x08a0, 36, clif->pStoragePassword);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x08ac, 6, clif->pDropItem);
- packet(CMSG_ITEM_PICKUP, 0x0925, 6, clif->pTakeItem);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x092b, -1, clif->pSearchStoreInfo);
- packet(CMSG_BUYINGSTORE_CREATE, 0x092c, -1, clif->pReqOpenBuyingStore);
-// packet(UNKNOWN, 0x092e, 4, clif->pDull);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0932, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x093e, 7, clif->pActionRequest);
- packet(CMSG_SKILL_USE_POSITION, 0x0940, 10, clif->pUseSkillToPos);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0946, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SKILL_USE_BEING, 0x0949, 10, clif->pUseSkillToId);
- packet(CMSG_MAP_PING, 0x0957, 6, clif->pTickSend);
- packet(CMSG_SEARCHSTORE_CLICK, 0x095d, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0964, 5, clif->pChangeDir);
-}
-
-// 20150617
-if (packetVersion == 20150617)
-{
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_ITEM_PICKUP, 0x0360, 6, clif->pTakeItem);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0362, 6, clif->pReqClickBuyingStore);
- packet(CMSG_STORAGE_PASSWORD, 0x0363, 36, clif->pStoragePassword);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0365, -1, clif->pItemListWindowSelected);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0436, 19, clif->pWantToConnection);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_BUYINGSTORE_SELL, 0x07ec, -1, clif->pReqTradeBuyingStore);
-// packet(UNKNOWN, 0x0811, 8, clif->pDull);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0869, 8, clif->pMoveFromKafra);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x086a, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x086b, 5, clif->pChangeDir);
- packet(CMSG_PARTY_INVITE2, 0x0870, 26, clif->pPartyInvite2);
- packet(CMSG_MOVE_TO_STORAGE, 0x087a, 8, clif->pMoveToKafra);
- packet(CMSG_HOMUNCULUS_MENU, 0x0886, 5, clif->pHomMenu);
-// packet(UNKNOWN, 0x0894, 4, clif->pDull);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0940, 6, clif->pDropItem);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x094e, 26, clif->pFriendsListAdd);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20150618
-if (packetVersion == 20150618)
-{
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_ITEM_PICKUP, 0x0360, 6, clif->pTakeItem);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0362, 6, clif->pReqClickBuyingStore);
- packet(CMSG_STORAGE_PASSWORD, 0x0363, 36, clif->pStoragePassword);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0365, -1, clif->pItemListWindowSelected);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0436, 19, clif->pWantToConnection);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_BUYINGSTORE_SELL, 0x07ec, -1, clif->pReqTradeBuyingStore);
-// packet(UNKNOWN, 0x0811, 8, clif->pDull);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0869, 8, clif->pMoveFromKafra);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x086a, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x086b, 5, clif->pChangeDir);
- packet(CMSG_PARTY_INVITE2, 0x0870, 26, clif->pPartyInvite2);
- packet(CMSG_MOVE_TO_STORAGE, 0x087a, 8, clif->pMoveToKafra);
- packet(CMSG_HOMUNCULUS_MENU, 0x0886, 5, clif->pHomMenu);
-// packet(UNKNOWN, 0x0894, 4, clif->pDull);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0940, 6, clif->pDropItem);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x094e, 26, clif->pFriendsListAdd);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20150624
-if (packetVersion == 20150624)
-{
- packet(CMSG_MAP_SERVER_CONNECT, 0x022d, 19, clif->pWantToConnection);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0281, -1, clif->pItemListWindowSelected);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0362, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x0363, 8, clif->pDull);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0364, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_HOMUNCULUS_MENU, 0x0365, 5, clif->pHomMenu);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
-// packet(UNKNOWN, 0x0436, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_ITEM_PICKUP, 0x07e4, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x07ec, 8, clif->pMoveToKafra);
- packet(CMSG_PARTY_INVITE2, 0x0802, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_STORAGE_PASSWORD, 0x0870, 36, clif->pStoragePassword);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0940, 8, clif->pMoveFromKafra);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0941, 26, clif->pFriendsListAdd);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0966, 5, clif->pChangeDir);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20150702
-if (packetVersion == 20150702)
-{
- packet(CMSG_MAP_SERVER_CONNECT, 0x023b, 19, clif->pWantToConnection);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0281, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_MOVE_FROM_STORAGE, 0x07e4, 8, clif->pMoveFromKafra);
- packet(CMSG_NAME_REQUEST, 0x0802, 6, clif->pGetCharNameRequest);
- packet(CMSG_BUYINGSTORE_SELL, 0x086d, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_MAP_PING, 0x087d, 6, clif->pTickSend);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x087e, -1, clif->pItemListWindowSelected);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0883, -1, clif->pSearchStoreInfo);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x088e, 2, clif->pReqCloseBuyingStore);
-// packet(UNKNOWN, 0x0893, 4, clif->pDull);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x08a0, 6, clif->pDropItem);
- packet(CMSG_BUYINGSTORE_OPEN, 0x08a4, 6, clif->pReqClickBuyingStore);
- packet(CMSG_PARTY_INVITE2, 0x08a5, 26, clif->pPartyInvite2);
- packet(CMSG_SKILL_USE_BEING, 0x08a6, 10, clif->pUseSkillToId);
- packet(CMSG_SKILL_USE_POSITION, 0x08ad, 10, clif->pUseSkillToPos);
- packet(CMSG_STORAGE_PASSWORD, 0x0919, 36, clif->pStoragePassword);
-// packet(UNKNOWN, 0x0923, 8, clif->pDull);
- packet(CMSG_MOVE_TO_STORAGE, 0x0928, 8, clif->pMoveToKafra);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x092c, 5, clif->pWalkToXY);
- packet(CMSG_BUYINGSTORE_CREATE, 0x093e, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_SEARCHSTORE_CLICK, 0x093f, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_ITEM_PICKUP, 0x0946, 6, clif->pTakeItem);
- packet(CMSG_SOLVE_CHAR_NAME, 0x094e, 6, clif->pSolveCharName);
- packet(CMSG_HOMUNCULUS_MENU, 0x0954, 5, clif->pHomMenu);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0956, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0958, 7, clif->pActionRequest);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x095f, 26, clif->pFriendsListAdd);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0960, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0968, 5, clif->pChangeDir);
-}
-
-// 20150708
-if (packetVersion == 20150708)
-{
- packet(CMSG_SOLVE_CHAR_NAME, 0x022d, 6, clif->pSolveCharName);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x02c4, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_PARTY_INVITE2, 0x0366, 26, clif->pPartyInvite2);
- packet(CMSG_HOMUNCULUS_MENU, 0x0368, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
- packet(CMSG_BUYINGSTORE_SELL, 0x0436, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0811, 19, clif->pWantToConnection);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_MOVE_TO_STORAGE, 0x085e, 8, clif->pMoveToKafra);
- packet(CMSG_ITEM_PICKUP, 0x0872, 6, clif->pTakeItem);
-// packet(UNKNOWN, 0x087f, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0884, 5, clif->pWalkToXY);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x089d, 5, clif->pChangeDir);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x08a5, -1, clif->pItemListWindowSelected);
- packet(CMSG_STORAGE_PASSWORD, 0x08ad, 36, clif->pStoragePassword);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x091f, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_MOVE_FROM_STORAGE, 0x092a, 8, clif->pMoveFromKafra);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x093c, 26, clif->pFriendsListAdd);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x095b, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x0962, 8, clif->pDull);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20150715
-if (packetVersion == 20150715)
-{
- packet(CMSG_BUYINGSTORE_CREATE, 0x023b, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_SKILL_USE_POSITION, 0x0362, 10, clif->pUseSkillToPos);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0364, -1, clif->pItemListWindowSelected);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0436, 6, clif->pSolveCharName);
- packet(CMSG_SKILL_USE_BEING, 0x0437, 10, clif->pUseSkillToId);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0438, 5, clif->pWalkToXY);
- packet(CMSG_BUYINGSTORE_SELL, 0x0835, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x083c, 7, clif->pActionRequest);
- packet(CMSG_NAME_REQUEST, 0x085c, 6, clif->pGetCharNameRequest);
- packet(CMSG_MOVE_FROM_STORAGE, 0x086f, 8, clif->pMoveFromKafra);
- packet(CMSG_MAP_PING, 0x0873, 6, clif->pTickSend);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0879, 19, clif->pWantToConnection);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x087c, 6, clif->pDropItem);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x087f, 2, clif->pSearchStoreInfoNextPage);
-// packet(UNKNOWN, 0x0886, 8, clif->pDull);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0895, -1, clif->pSearchStoreInfo);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0896, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_PARTY_INVITE2, 0x0897, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0899, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_ITEM_PICKUP, 0x089a, 6, clif->pTakeItem);
-// packet(UNKNOWN, 0x08a4, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x08ac, 5, clif->pChangeDir);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0917, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_HOMUNCULUS_MENU, 0x093e, 5, clif->pHomMenu);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0944, 26, clif->pFriendsListAdd);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0950, 6, clif->pReqClickBuyingStore);
- packet(CMSG_STORAGE_PASSWORD, 0x0956, 36, clif->pStoragePassword);
- packet(CMSG_MOVE_TO_STORAGE, 0x0961, 8, clif->pMoveToKafra);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0965, 18, clif->pPartyBookingRegisterReq);
-}
-
-// 20150729
-if (packetVersion == 20150729)
-{
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0437, -1, clif->pSearchStoreInfo);
- packet(CMSG_HOMUNCULUS_MENU, 0x0438, 5, clif->pHomMenu);
-// packet(UNKNOWN, 0x085b, 8, clif->pDull);
- packet(CMSG_ITEM_PICKUP, 0x0860, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x086c, 8, clif->pMoveToKafra);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x086d, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x086e, 5, clif->pWalkToXY);
- packet(CMSG_MOVE_FROM_STORAGE, 0x086f, 8, clif->pMoveFromKafra);
- packet(CMSG_NAME_REQUEST, 0x0870, 6, clif->pGetCharNameRequest);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0880, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0881, 7, clif->pActionRequest);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0886, 6, clif->pSolveCharName);
- packet(CMSG_SKILL_USE_POSITION, 0x089a, 10, clif->pUseSkillToPos);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x089b, 26, clif->pFriendsListAdd);
-// packet(UNKNOWN, 0x08a3, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x08a4, 5, clif->pChangeDir);
- packet(CMSG_PARTY_INVITE2, 0x08ac, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_OPEN, 0x08ad, 6, clif->pReqClickBuyingStore);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0920, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x092b, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SKILL_USE_BEING, 0x092f, 10, clif->pUseSkillToId);
- packet(CMSG_MAP_PING, 0x093a, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_CREATE, 0x093f, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0940, 6, clif->pDropItem);
- packet(CMSG_MAP_SERVER_CONNECT, 0x094f, 19, clif->pWantToConnection);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0955, -1, clif->pItemListWindowSelected);
- packet(CMSG_BUYINGSTORE_SELL, 0x095e, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_STORAGE_PASSWORD, 0x0961, 36, clif->pStoragePassword);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x096a, 2, clif->pReqCloseBuyingStore);
-}
-
-// 20150805
-if (packetVersion == 20150805)
-{
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0202, 5, clif->pChangeDir);
- packet(CMSG_MAP_SERVER_CONNECT, 0x022d, 19, clif->pWantToConnection);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x023b, 26, clif->pFriendsListAdd);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0281, -1, clif->pItemListWindowSelected);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x0361, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0362, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x0363, 8, clif->pDull);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0364, 8, clif->pMoveFromKafra);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0365, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
-// packet(UNKNOWN, 0x0436, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_ITEM_PICKUP, 0x07e4, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x07ec, 8, clif->pMoveToKafra);
- packet(CMSG_PARTY_INVITE2, 0x0802, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_STORAGE_PASSWORD, 0x088a, 36, clif->pStoragePassword);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20150812
-if (packetVersion == 20150812)
-{
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0202, 5, clif->pChangeDir);
- packet(CMSG_MAP_SERVER_CONNECT, 0x022d, 19, clif->pWantToConnection);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x023b, 26, clif->pFriendsListAdd);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0281, -1, clif->pItemListWindowSelected);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x0361, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0362, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x0363, 8, clif->pDull);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0364, 8, clif->pMoveFromKafra);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0365, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
-// packet(UNKNOWN, 0x0436, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_ITEM_PICKUP, 0x07e4, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x07ec, 8, clif->pMoveToKafra);
- packet(CMSG_PARTY_INVITE2, 0x0802, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_STORAGE_PASSWORD, 0x087f, 36, clif->pStoragePassword);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20150819
-if (packetVersion == 20150819)
-{
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0202, -1, clif->pItemListWindowSelected);
- packet(CMSG_SKILL_USE_BEING, 0x022d, 10, clif->pUseSkillToId);
- packet(CMSG_ITEM_PICKUP, 0x0281, 6, clif->pTakeItem);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
-// packet(UNKNOWN, 0x0436, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_MOVE_FROM_STORAGE, 0x085d, 8, clif->pMoveFromKafra);
-// packet(UNKNOWN, 0x0862, 8, clif->pDull);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0865, 26, clif->pFriendsListAdd);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0871, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_HOMUNCULUS_MENU, 0x0888, 5, clif->pHomMenu);
- packet(CMSG_MOVE_TO_STORAGE, 0x0919, 8, clif->pMoveToKafra);
- packet(CMSG_STORAGE_PASSWORD, 0x091e, 36, clif->pStoragePassword);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0927, 19, clif->pWantToConnection);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0940, 6, clif->pDropItem);
- packet(CMSG_PARTY_INVITE2, 0x0961, 26, clif->pPartyInvite2);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0967, 5, clif->pChangeDir);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20150826
-if (packetVersion == 20150826)
-{
- packet(CMSG_STORAGE_PASSWORD, 0x0362, 36, clif->pStoragePassword);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0368, 8, clif->pMoveFromKafra);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0436, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x07ec, 7, clif->pActionRequest);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0819, 6, clif->pReqClickBuyingStore);
-// packet(UNKNOWN, 0x0861, 8, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0865, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x086b, 10, clif->pUseSkillToPos);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0870, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_SOLVE_CHAR_NAME, 0x087b, 6, clif->pSolveCharName);
- packet(CMSG_PARTY_INVITE2, 0x088b, 26, clif->pPartyInvite2);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x088d, 26, clif->pFriendsListAdd);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0890, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SKILL_USE_BEING, 0x0891, 10, clif->pUseSkillToId);
- packet(CMSG_SEARCHSTORE_CLICK, 0x08a0, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_MOVE_TO_STORAGE, 0x08a1, 8, clif->pMoveToKafra);
- packet(CMSG_ITEM_PICKUP, 0x08a4, 6, clif->pTakeItem);
- packet(CMSG_BUYINGSTORE_SELL, 0x08a8, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0924, 6, clif->pDropItem);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0928, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x092e, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_NAME_REQUEST, 0x093b, 6, clif->pGetCharNameRequest);
- packet(CMSG_HOMUNCULUS_MENU, 0x0945, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x094f, 5, clif->pChangeDir);
- packet(CMSG_MAP_PING, 0x0951, 6, clif->pTickSend);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0959, -1, clif->pItemListWindowSelected);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0964, 19, clif->pWantToConnection);
-// packet(UNKNOWN, 0x0968, 4, clif->pDull);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0969, -1, clif->pSearchStoreInfo);
-}
-
-// 20150902
-if (packetVersion == 20150902)
-{
- packet(CMSG_BOOKING_REGISTER_REQ, 0x023b, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0360, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_MAP_PING, 0x0367, 6, clif->pTickSend);
- packet(CMSG_STORAGE_PASSWORD, 0x0802, 36, clif->pStoragePassword);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x083c, -1, clif->pSearchStoreInfo);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x085b, 7, clif->pActionRequest);
- packet(CMSG_SOLVE_CHAR_NAME, 0x085d, 6, clif->pSolveCharName);
- packet(CMSG_SKILL_USE_BEING, 0x0863, 10, clif->pUseSkillToId);
- packet(CMSG_SKILL_USE_POSITION, 0x086f, 10, clif->pUseSkillToPos);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x087b, 5, clif->pWalkToXY);
-// packet(UNKNOWN, 0x087f, 4, clif->pDull);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0886, 12, clif->pSearchStoreInfoListItemClick);
-// packet(UNKNOWN, 0x0887, 8, clif->pDull);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0889, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_MOVE_FROM_STORAGE, 0x088d, 8, clif->pMoveFromKafra);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0892, -1, clif->pItemListWindowSelected);
- packet(CMSG_MOVE_TO_STORAGE, 0x0897, 8, clif->pMoveToKafra);
- packet(CMSG_NAME_REQUEST, 0x0899, 6, clif->pGetCharNameRequest);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x08a9, 6, clif->pDropItem);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0923, 26, clif->pFriendsListAdd);
- packet(CMSG_ITEM_PICKUP, 0x0928, 6, clif->pTakeItem);
- packet(CMSG_HOMUNCULUS_MENU, 0x092a, 5, clif->pHomMenu);
- packet(CMSG_PARTY_INVITE2, 0x092d, 26, clif->pPartyInvite2);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0941, 5, clif->pChangeDir);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0947, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_BUYINGSTORE_OPEN, 0x094f, 6, clif->pReqClickBuyingStore);
- packet(CMSG_BUYINGSTORE_SELL, 0x0953, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_MAP_SERVER_CONNECT, 0x095b, 19, clif->pWantToConnection);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0960, 2, clif->pSearchStoreInfoNextPage);
-}
-
-// 20150909
-if (packetVersion == 20150909)
-{
- packet(CMSG_PLAYER_CHANGE_ACT, 0x023b, 7, clif->pActionRequest);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0360, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_NAME_REQUEST, 0x0361, 6, clif->pGetCharNameRequest);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0365, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_STORAGE_PASSWORD, 0x0369, 36, clif->pStoragePassword);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0437, 8, clif->pMoveFromKafra);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
-// packet(UNKNOWN, 0x0861, 4, clif->pDull);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0871, -1, clif->pItemListWindowSelected);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x087b, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_ITEM_PICKUP, 0x0883, 6, clif->pTakeItem);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0886, 19, clif->pWantToConnection);
- packet(CMSG_PARTY_INVITE2, 0x088f, 26, clif->pPartyInvite2);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0895, 26, clif->pFriendsListAdd);
-// packet(UNKNOWN, 0x0928, 8, clif->pDull);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0940, 6, clif->pReqClickBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x0941, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x095e, 6, clif->pDropItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x0962, 8, clif->pMoveToKafra);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x096a, 5, clif->pChangeDir);
-}
-
-// 20150916
-if (packetVersion == 20150916)
-{
- packet(CMSG_SKILL_USE_POSITION, 0x022d, 10, clif->pUseSkillToPos);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0817, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0835, 6, clif->pReqClickBuyingStore);
- packet(CMSG_MOVE_FROM_STORAGE, 0x085e, 8, clif->pMoveFromKafra);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0869, 7, clif->pActionRequest);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0873, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0877, 5, clif->pWalkToXY);
- packet(CMSG_SEARCHSTORE_CLICK, 0x087f, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_BUYINGSTORE_SELL, 0x0881, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x089b, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_ITEM_PICKUP, 0x089c, 6, clif->pTakeItem);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x089e, 26, clif->pFriendsListAdd);
- packet(CMSG_MAP_PING, 0x08ac, 6, clif->pTickSend);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0920, -1, clif->pSearchStoreInfo);
- packet(CMSG_PARTY_INVITE2, 0x0924, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x092e, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x092f, 6, clif->pDropItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x0934, 8, clif->pMoveToKafra);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0936, 5, clif->pChangeDir);
-// packet(UNKNOWN, 0x0938, 4, clif->pDull);
- packet(CMSG_SKILL_USE_BEING, 0x093e, 10, clif->pUseSkillToId);
- packet(CMSG_STORAGE_PASSWORD, 0x0941, 36, clif->pStoragePassword);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0942, 6, clif->pSolveCharName);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0948, -1, clif->pReqOpenBuyingStore);
-// packet(UNKNOWN, 0x094f, 8, clif->pDull);
- packet(CMSG_NAME_REQUEST, 0x095a, 6, clif->pGetCharNameRequest);
- packet(CMSG_HOMUNCULUS_MENU, 0x0960, 5, clif->pHomMenu);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0961, -1, clif->pItemListWindowSelected);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0969, 19, clif->pWantToConnection);
-}
-
-// 20150923
-if (packetVersion == 20150923)
-{
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0361, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0366, -1, clif->pSearchStoreInfo);
- packet(CMSG_STORAGE_PASSWORD, 0x07e4, 36, clif->pStoragePassword);
- packet(CMSG_BUYINGSTORE_SELL, 0x0817, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_SOLVE_CHAR_NAME, 0x085c, 6, clif->pSolveCharName);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x085d, 26, clif->pFriendsListAdd);
- packet(CMSG_HOMUNCULUS_MENU, 0x0864, 5, clif->pHomMenu);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x086e, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SKILL_USE_BEING, 0x086f, 10, clif->pUseSkillToId);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0870, 5, clif->pChangeDir);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0879, 8, clif->pMoveFromKafra);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x087f, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0886, 5, clif->pWalkToXY);
- packet(CMSG_BUYINGSTORE_OPEN, 0x088e, 6, clif->pReqClickBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0892, -1, clif->pReqOpenBuyingStore);
-// packet(UNKNOWN, 0x0895, 4, clif->pDull);
- packet(CMSG_SKILL_USE_POSITION, 0x089b, 10, clif->pUseSkillToPos);
- packet(CMSG_MOVE_TO_STORAGE, 0x089f, 8, clif->pMoveToKafra);
- packet(CMSG_MAP_PING, 0x08a0, 6, clif->pTickSend);
- packet(CMSG_MAP_SERVER_CONNECT, 0x08a2, 19, clif->pWantToConnection);
- packet(CMSG_NAME_REQUEST, 0x08a5, 6, clif->pGetCharNameRequest);
- packet(CMSG_SEARCHSTORE_CLICK, 0x08a6, 12, clif->pSearchStoreInfoListItemClick);
-// packet(UNKNOWN, 0x091e, 8, clif->pDull);
- packet(CMSG_ITEM_PICKUP, 0x092b, 6, clif->pTakeItem);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0930, 6, clif->pDropItem);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0936, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_PARTY_INVITE2, 0x093b, 26, clif->pPartyInvite2);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0951, 7, clif->pActionRequest);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0961, -1, clif->pItemListWindowSelected);
-}
-
-// 20151001
-if (packetVersion == 20151001)
-{
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0202, 5, clif->pChangeDir);
- packet(CMSG_MAP_SERVER_CONNECT, 0x022d, 19, clif->pWantToConnection);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x023b, 26, clif->pFriendsListAdd);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0281, -1, clif->pItemListWindowSelected);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x0361, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0362, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x0363, 8, clif->pDull);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0364, 8, clif->pMoveFromKafra);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0365, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
-// packet(UNKNOWN, 0x0436, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_ITEM_PICKUP, 0x07e4, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x07ec, 8, clif->pMoveToKafra);
- packet(CMSG_PARTY_INVITE2, 0x0802, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_STORAGE_PASSWORD, 0x0960, 36, clif->pStoragePassword);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-if (packetVersion >= 20151001)
-{
- packet(CMSG_CHAR_CREATE, 0x0a39, 36, chr->parse_char_create_new_char);
-}
-
-// 20151007
-if (packetVersion == 20151007)
-{
- packet(CMSG_BUYINGSTORE_SELL, 0x0202, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0281, -1, clif->pItemListWindowSelected);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0362, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x0363, 8, clif->pDull);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0364, 8, clif->pMoveFromKafra);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0365, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_ITEM_PICKUP, 0x07e4, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x07ec, 8, clif->pMoveToKafra);
- packet(CMSG_PARTY_INVITE2, 0x0802, 26, clif->pPartyInvite2);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0811, 26, clif->pFriendsListAdd);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
-// packet(UNKNOWN, 0x0862, 4, clif->pDull);
- packet(CMSG_HOMUNCULUS_MENU, 0x093f, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x095f, 5, clif->pChangeDir);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0961, 19, clif->pWantToConnection);
- packet(CMSG_STORAGE_PASSWORD, 0x0967, 36, clif->pStoragePassword);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20151014
-if (packetVersion == 20151014)
-{
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0202, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0817, 26, clif->pFriendsListAdd);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0838, -1, clif->pSearchStoreInfo);
- packet(CMSG_SKILL_USE_BEING, 0x085a, 10, clif->pUseSkillToId);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x085c, 7, clif->pActionRequest);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0860, 6, clif->pDropItem);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0863, 5, clif->pChangeDir);
- packet(CMSG_BUYINGSTORE_SELL, 0x0867, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x0872, 5, clif->pHomMenu);
- packet(CMSG_SKILL_USE_POSITION, 0x0874, 10, clif->pUseSkillToPos);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0881, 8, clif->pMoveFromKafra);
- packet(CMSG_MAP_PING, 0x0883, 6, clif->pTickSend);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0884, -1, clif->pItemListWindowSelected);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0889, 6, clif->pReqClickBuyingStore);
-// packet(UNKNOWN, 0x088e, 8, clif->pDull);
-// packet(UNKNOWN, 0x089a, 4, clif->pDull);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x089b, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x089f, 5, clif->pWalkToXY);
- packet(CMSG_ITEM_PICKUP, 0x08aa, 6, clif->pTakeItem);
- packet(CMSG_PARTY_INVITE2, 0x091c, 26, clif->pPartyInvite2);
- packet(CMSG_STORAGE_PASSWORD, 0x091d, 36, clif->pStoragePassword);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0930, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0934, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0944, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x094f, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0956, 6, clif->pSolveCharName);
- packet(CMSG_MOVE_TO_STORAGE, 0x095e, 8, clif->pMoveToKafra);
- packet(CMSG_NAME_REQUEST, 0x0961, 6, clif->pGetCharNameRequest);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0964, 19, clif->pWantToConnection);
-}
-
-// 20151021
-if (packetVersion == 20151021)
-{
- packet(CMSG_MAP_SERVER_CONNECT, 0x023b, 19, clif->pWantToConnection);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0281, -1, clif->pItemListWindowSelected);
- packet(CMSG_STORAGE_PASSWORD, 0x02c4, 36, clif->pStoragePassword);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_MOVE_TO_STORAGE, 0x0361, 8, clif->pMoveToKafra);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0362, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x0363, 8, clif->pDull);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0364, 8, clif->pMoveFromKafra);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0365, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
-// packet(UNKNOWN, 0x0436, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_ITEM_PICKUP, 0x07e4, 6, clif->pTakeItem);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x07ec, 5, clif->pChangeDir);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x086a, 26, clif->pFriendsListAdd);
- packet(CMSG_HOMUNCULUS_MENU, 0x091d, 5, clif->pHomMenu);
- packet(CMSG_PARTY_INVITE2, 0x0940, 26, clif->pPartyInvite2);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20151022
-if (packetVersion == 20151022)
-{
- packet(CMSG_MAP_SERVER_CONNECT, 0x023b, 19, clif->pWantToConnection);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0281, -1, clif->pItemListWindowSelected);
- packet(CMSG_STORAGE_PASSWORD, 0x02c4, 36, clif->pStoragePassword);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_MOVE_TO_STORAGE, 0x0361, 8, clif->pMoveToKafra);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0362, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x0363, 8, clif->pDull);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0364, 8, clif->pMoveFromKafra);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0365, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
-// packet(UNKNOWN, 0x0436, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_ITEM_PICKUP, 0x07e4, 6, clif->pTakeItem);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x07ec, 5, clif->pChangeDir);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x086a, 26, clif->pFriendsListAdd);
- packet(CMSG_HOMUNCULUS_MENU, 0x091d, 5, clif->pHomMenu);
- packet(CMSG_PARTY_INVITE2, 0x0940, 26, clif->pPartyInvite2);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20151028
-if (packetVersion == 20151028)
-{
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0202, 5, clif->pChangeDir);
- packet(CMSG_MAP_SERVER_CONNECT, 0x022d, 19, clif->pWantToConnection);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x023b, 26, clif->pFriendsListAdd);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0281, -1, clif->pItemListWindowSelected);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x0361, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0362, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x0363, 8, clif->pDull);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0364, 8, clif->pMoveFromKafra);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0365, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
-// packet(UNKNOWN, 0x0436, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_ITEM_PICKUP, 0x07e4, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x07ec, 8, clif->pMoveToKafra);
- packet(CMSG_PARTY_INVITE2, 0x0802, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_STORAGE_PASSWORD, 0x0860, 36, clif->pStoragePassword);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20151029
-if (packetVersion == 20151029)
-{
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0202, 5, clif->pChangeDir);
- packet(CMSG_MAP_SERVER_CONNECT, 0x022d, 19, clif->pWantToConnection);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x023b, 26, clif->pFriendsListAdd);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0281, -1, clif->pItemListWindowSelected);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x0361, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0362, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x0363, 8, clif->pDull);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0364, 8, clif->pMoveFromKafra);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0365, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
-// packet(UNKNOWN, 0x0436, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_ITEM_PICKUP, 0x07e4, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x07ec, 8, clif->pMoveToKafra);
- packet(CMSG_PARTY_INVITE2, 0x0802, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_STORAGE_PASSWORD, 0x0860, 36, clif->pStoragePassword);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20151104
-if (packetVersion == 20151104)
-{
- packet(CMSG_BUYINGSTORE_CREATE, 0x023b, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0360, 19, clif->pWantToConnection);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0363, 5, clif->pWalkToXY);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0364, 8, clif->pMoveFromKafra);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0436, 6, clif->pReqClickBuyingStore);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0437, 6, clif->pDropItem);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x07ec, 26, clif->pFriendsListAdd);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0811, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_BUYINGSTORE_SELL, 0x0815, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_MAP_PING, 0x0886, 6, clif->pTickSend);
- packet(CMSG_NAME_REQUEST, 0x0887, 6, clif->pGetCharNameRequest);
- packet(CMSG_MOVE_TO_STORAGE, 0x088b, 8, clif->pMoveToKafra);
- packet(CMSG_HOMUNCULUS_MENU, 0x088d, 5, clif->pHomMenu);
-// packet(UNKNOWN, 0x08a3, 4, clif->pDull);
- packet(CMSG_PARTY_INVITE2, 0x08a5, 26, clif->pPartyInvite2);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0928, 5, clif->pChangeDir);
-// packet(UNKNOWN, 0x0939, 8, clif->pDull);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x093a, -1, clif->pItemListWindowSelected);
- packet(CMSG_STORAGE_PASSWORD, 0x0940, 36, clif->pStoragePassword);
- packet(CMSG_ITEM_PICKUP, 0x0964, 6, clif->pTakeItem);
-}
-
-// 20151111
-if (packetVersion == 20151111)
-{
- packet(CMSG_BUYINGSTORE_CREATE, 0x02c4, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x0362, 5, clif->pHomMenu);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_MOVE_TO_STORAGE, 0x0369, 8, clif->pMoveToKafra);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
-// packet(UNKNOWN, 0x0802, 4, clif->pDull);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_PARTY_INVITE2, 0x0815, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x085d, -1, clif->pItemListWindowSelected);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0862, 6, clif->pDropItem);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0871, 26, clif->pFriendsListAdd);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0885, 7, clif->pActionRequest);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x089c, 5, clif->pChangeDir);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0942, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_ITEM_PICKUP, 0x094a, 6, clif->pTakeItem);
-// packet(UNKNOWN, 0x0958, 8, clif->pDull);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0966, 8, clif->pMoveFromKafra);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0967, 19, clif->pWantToConnection);
- packet(CMSG_STORAGE_PASSWORD, 0x0969, 36, clif->pStoragePassword);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20151118
-if (packetVersion == 20151118)
-{
- packet(CMSG_MAP_PING, 0x022d, 6, clif->pTickSend);
- packet(CMSG_HOMUNCULUS_MENU, 0x035f, 5, clif->pHomMenu);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_PARTY_INVITE2, 0x0365, 26, clif->pPartyInvite2);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_MOVE_TO_STORAGE, 0x086b, 8, clif->pMoveToKafra);
- packet(CMSG_STORAGE_PASSWORD, 0x088b, 36, clif->pStoragePassword);
- packet(CMSG_MOVE_FROM_STORAGE, 0x08ab, 8, clif->pMoveFromKafra);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0921, 26, clif->pFriendsListAdd);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0925, 19, clif->pWantToConnection);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x092e, 5, clif->pChangeDir);
-// packet(UNKNOWN, 0x092f, 8, clif->pDull);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x093c, 6, clif->pDropItem);
- packet(CMSG_ITEM_PICKUP, 0x0943, 6, clif->pTakeItem);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0946, -1, clif->pItemListWindowSelected);
-// packet(UNKNOWN, 0x0957, 4, clif->pDull);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x095c, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20151125
-if (packetVersion == 20151125)
-{
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0361, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0365, 5, clif->pWalkToXY);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0366, 8, clif->pMoveFromKafra);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0368, -1, clif->pItemListWindowSelected);
- packet(CMSG_ITEM_PICKUP, 0x0438, 6, clif->pTakeItem);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0802, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0838, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_NAME_REQUEST, 0x085e, 6, clif->pGetCharNameRequest);
- packet(CMSG_MOVE_TO_STORAGE, 0x085f, 8, clif->pMoveToKafra);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0863, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0883, 5, clif->pChangeDir);
- packet(CMSG_STORAGE_PASSWORD, 0x0884, 36, clif->pStoragePassword);
-// packet(UNKNOWN, 0x0885, 4, clif->pDull);
- packet(CMSG_MAP_PING, 0x088c, 6, clif->pTickSend);
- packet(CMSG_MAP_SERVER_CONNECT, 0x088d, 19, clif->pWantToConnection);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0899, 26, clif->pFriendsListAdd);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x089c, 7, clif->pActionRequest);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x089f, -1, clif->pSearchStoreInfo);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x08a9, 6, clif->pDropItem);
- packet(CMSG_BUYINGSTORE_SELL, 0x08ad, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0920, 6, clif->pSolveCharName);
- packet(CMSG_SKILL_USE_BEING, 0x092a, 10, clif->pUseSkillToId);
- packet(CMSG_SKILL_USE_POSITION, 0x092e, 10, clif->pUseSkillToPos);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0939, 6, clif->pReqClickBuyingStore);
- packet(CMSG_SEARCHSTORE_CLICK, 0x093e, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_HOMUNCULUS_MENU, 0x0951, 5, clif->pHomMenu);
- packet(CMSG_PARTY_INVITE2, 0x0956, 26, clif->pPartyInvite2);
-// packet(UNKNOWN, 0x0957, 8, clif->pDull);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0959, 90, clif->pUseSkillToPosMoreInfo);
-}
-
-// 20151202
-if (packetVersion == 20151202)
-{
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0202, 5, clif->pChangeDir);
- packet(CMSG_MAP_SERVER_CONNECT, 0x022d, 19, clif->pWantToConnection);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x023b, 26, clif->pFriendsListAdd);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0281, -1, clif->pItemListWindowSelected);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x0361, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0362, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x0363, 8, clif->pDull);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0364, 8, clif->pMoveFromKafra);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0365, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
-// packet(UNKNOWN, 0x0436, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_ITEM_PICKUP, 0x07e4, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x07ec, 8, clif->pMoveToKafra);
- packet(CMSG_PARTY_INVITE2, 0x0802, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_STORAGE_PASSWORD, 0x0870, 36, clif->pStoragePassword);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20151209
-if (packetVersion == 20151209)
-{
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0365, 5, clif->pWalkToXY);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0369, 6, clif->pSolveCharName);
- packet(CMSG_PARTY_INVITE2, 0x07e4, 26, clif->pPartyInvite2);
- packet(CMSG_ITEM_PICKUP, 0x07ec, 6, clif->pTakeItem);
- packet(CMSG_MAP_PING, 0x0811, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0819, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_STORAGE_PASSWORD, 0x085b, 36, clif->pStoragePassword);
- packet(CMSG_NAME_REQUEST, 0x085d, 6, clif->pGetCharNameRequest);
- packet(CMSG_BUYINGSTORE_CREATE, 0x085e, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0861, -1, clif->pSearchStoreInfo);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0866, 5, clif->pChangeDir);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0875, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x087a, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_BUYINGSTORE_OPEN, 0x087f, 6, clif->pReqClickBuyingStore);
- packet(CMSG_SKILL_USE_BEING, 0x088e, 10, clif->pUseSkillToId);
-// packet(UNKNOWN, 0x088f, 8, clif->pDull);
- packet(CMSG_SKILL_USE_POSITION, 0x0894, 10, clif->pUseSkillToPos);
- packet(CMSG_HOMUNCULUS_MENU, 0x08a1, 5, clif->pHomMenu);
- packet(CMSG_BUYINGSTORE_SELL, 0x0920, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_MOVE_FROM_STORAGE, 0x092d, 8, clif->pMoveFromKafra);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0930, 6, clif->pDropItem);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0932, -1, clif->pItemListWindowSelected);
- packet(CMSG_MOVE_TO_STORAGE, 0x093b, 8, clif->pMoveToKafra);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0948, 19, clif->pWantToConnection);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x094a, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0956, 90, clif->pUseSkillToPosMoreInfo);
-// packet(UNKNOWN, 0x095c, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0961, 7, clif->pActionRequest);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0964, 26, clif->pFriendsListAdd);
-}
-
-// 20151216
-if (packetVersion == 20151216)
-{
- packet(CMSG_PLAYER_CHANGE_DIR, 0x022d, 5, clif->pChangeDir);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0361, 6, clif->pReqClickBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x0362, 5, clif->pHomMenu);
-// packet(UNKNOWN, 0x0364, 4, clif->pDull);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0365, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0436, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x083c, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_MAP_PING, 0x085b, 6, clif->pTickSend);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0864, 8, clif->pMoveFromKafra);
- packet(CMSG_SKILL_USE_POSITION, 0x0865, 10, clif->pUseSkillToPos);
-// packet(UNKNOWN, 0x086a, 8, clif->pDull);
- packet(CMSG_PARTY_INVITE2, 0x086e, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0870, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0874, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_STORAGE_PASSWORD, 0x0885, 36, clif->pStoragePassword);
- packet(CMSG_NAME_REQUEST, 0x088b, 6, clif->pGetCharNameRequest);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x089d, 7, clif->pActionRequest);
- packet(CMSG_SOLVE_CHAR_NAME, 0x089e, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x08a2, 5, clif->pWalkToXY);
- packet(CMSG_ITEM_PICKUP, 0x08a9, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x08ac, 8, clif->pMoveToKafra);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x091d, 26, clif->pFriendsListAdd);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0944, -1, clif->pSearchStoreInfo);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0947, 19, clif->pWantToConnection);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0949, -1, clif->pItemListWindowSelected);
- packet(CMSG_BUYINGSTORE_SELL, 0x0954, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0960, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0966, 6, clif->pDropItem);
- packet(CMSG_SKILL_USE_BEING, 0x0968, 10, clif->pUseSkillToId);
-}
-
-// 20151223
-if (packetVersion == 20151223)
-{
- packet(CMSG_MOVE_TO_STORAGE, 0x02c4, 8, clif->pMoveToKafra);
-// packet(UNKNOWN, 0x0362, 8, clif->pDull);
- packet(CMSG_ITEM_PICKUP, 0x0364, 6, clif->pTakeItem);
-// packet(UNKNOWN, 0x0802, 4, clif->pDull);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0815, -1, clif->pSearchStoreInfo);
- packet(CMSG_NAME_REQUEST, 0x0864, 6, clif->pGetCharNameRequest);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0866, 19, clif->pWantToConnection);
- packet(CMSG_SKILL_USE_POSITION, 0x086e, 10, clif->pUseSkillToPos);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0872, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SKILL_USE_BEING, 0x0875, 10, clif->pUseSkillToId);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0876, 6, clif->pDropItem);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0881, 7, clif->pActionRequest);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0884, 8, clif->pMoveFromKafra);
- packet(CMSG_BUYINGSTORE_SELL, 0x0886, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x088d, 5, clif->pHomMenu);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0890, -1, clif->pItemListWindowSelected);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0891, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0898, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_PARTY_INVITE2, 0x08aa, 26, clif->pPartyInvite2);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0918, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_BUYINGSTORE_OPEN, 0x091a, 6, clif->pReqClickBuyingStore);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x091b, 26, clif->pFriendsListAdd);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0920, 5, clif->pWalkToXY);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0923, 5, clif->pChangeDir);
- packet(CMSG_MAP_PING, 0x0924, 6, clif->pTickSend);
- packet(CMSG_SOLVE_CHAR_NAME, 0x095e, 6, clif->pSolveCharName);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x095f, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_STORAGE_PASSWORD, 0x0965, 36, clif->pStoragePassword);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0967, 12, clif->pSearchStoreInfoListItemClick);
-}
-
-// 20151230
-if (packetVersion == 20151230)
-{
- packet(CMSG_MOVE_TO_STORAGE, 0x02c4, 8, clif->pMoveToKafra);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0365, 18, clif->pPartyBookingRegisterReq);
-// packet(UNKNOWN, 0x0366, 8, clif->pDull);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0436, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x07ec, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0815, 19, clif->pWantToConnection);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x085b, -1, clif->pItemListWindowSelected);
- packet(CMSG_PARTY_INVITE2, 0x0861, 26, clif->pPartyInvite2);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0869, 5, clif->pChangeDir);
- packet(CMSG_SKILL_USE_POSITION, 0x0886, 10, clif->pUseSkillToPos);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x088e, 26, clif->pFriendsListAdd);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0897, 6, clif->pDropItem);
- packet(CMSG_MOVE_FROM_STORAGE, 0x091d, 8, clif->pMoveFromKafra);
- packet(CMSG_STORAGE_PASSWORD, 0x0923, 36, clif->pStoragePassword);
-// packet(UNKNOWN, 0x093a, 4, clif->pDull);
- packet(CMSG_HOMUNCULUS_MENU, 0x0949, 5, clif->pHomMenu);
- packet(CMSG_ITEM_PICKUP, 0x094e, 6, clif->pTakeItem);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20160106
-if (packetVersion == 20160106)
-{
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_HOMUNCULUS_MENU, 0x07ec, 5, clif->pHomMenu);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_ITEM_PICKUP, 0x0861, 6, clif->pTakeItem);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x086a, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x086c, 4, clif->pDull);
- packet(CMSG_STORAGE_PASSWORD, 0x0878, 36, clif->pStoragePassword);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x087a, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_MAP_SERVER_CONNECT, 0x087f, 19, clif->pWantToConnection);
- packet(CMSG_MOVE_TO_STORAGE, 0x0885, 8, clif->pMoveToKafra);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0889, 5, clif->pChangeDir);
- packet(CMSG_PARTY_INVITE2, 0x088a, 26, clif->pPartyInvite2);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0891, 8, clif->pMoveFromKafra);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x08a0, 26, clif->pFriendsListAdd);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x091d, -1, clif->pItemListWindowSelected);
-// packet(UNKNOWN, 0x0940, 8, clif->pDull);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20160113
-if (packetVersion == 20160113)
-{
- packet(CMSG_SKILL_USE_POSITION, 0x022d, 10, clif->pUseSkillToPos);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x023b, 5, clif->pWalkToXY);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x035f, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_STORAGE_PASSWORD, 0x0815, 36, clif->pStoragePassword);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x085b, 5, clif->pChangeDir);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0864, 6, clif->pReqClickBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x086d, 5, clif->pHomMenu);
-// packet(UNKNOWN, 0x0873, 4, clif->pDull);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0875, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0888, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_PARTY_INVITE2, 0x088b, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x088c, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SKILL_USE_BEING, 0x0892, 10, clif->pUseSkillToId);
- packet(CMSG_BUYINGSTORE_SELL, 0x0893, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0899, 26, clif->pFriendsListAdd);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x089a, 7, clif->pActionRequest);
- packet(CMSG_MAP_PING, 0x08a0, 6, clif->pTickSend);
- packet(CMSG_ITEM_PICKUP, 0x08a6, 6, clif->pTakeItem);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x08aa, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0919, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_NAME_REQUEST, 0x091b, 6, clif->pGetCharNameRequest);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0924, 6, clif->pDropItem);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0930, 6, clif->pSolveCharName);
- packet(CMSG_MOVE_TO_STORAGE, 0x0932, 8, clif->pMoveToKafra);
- packet(CMSG_MOVE_FROM_STORAGE, 0x093c, 8, clif->pMoveFromKafra);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0941, -1, clif->pItemListWindowSelected);
- packet(CMSG_MAP_SERVER_CONNECT, 0x094d, 19, clif->pWantToConnection);
-// packet(UNKNOWN, 0x094f, 8, clif->pDull);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0967, -1, clif->pReqOpenBuyingStore);
-}
-
-// 20160120
-if (packetVersion == 20160120)
-{
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0202, 5, clif->pChangeDir);
- packet(CMSG_MAP_SERVER_CONNECT, 0x022d, 19, clif->pWantToConnection);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x023b, 26, clif->pFriendsListAdd);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0281, -1, clif->pItemListWindowSelected);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x0361, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0362, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x0363, 8, clif->pDull);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0364, 8, clif->pMoveFromKafra);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0365, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
-// packet(UNKNOWN, 0x0436, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_ITEM_PICKUP, 0x07e4, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x07ec, 8, clif->pMoveToKafra);
- packet(CMSG_PARTY_INVITE2, 0x0802, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_STORAGE_PASSWORD, 0x0865, 36, clif->pStoragePassword);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20160127
-if (packetVersion == 20160127)
-{
- packet(CMSG_MAP_SERVER_CONNECT, 0x022d, 19, clif->pWantToConnection);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0281, -1, clif->pItemListWindowSelected);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0362, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x0363, 8, clif->pDull);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0364, 8, clif->pMoveFromKafra);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0365, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
-// packet(UNKNOWN, 0x0436, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_ITEM_PICKUP, 0x07e4, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x07ec, 8, clif->pMoveToKafra);
- packet(CMSG_PARTY_INVITE2, 0x0802, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x085e, 5, clif->pChangeDir);
- packet(CMSG_HOMUNCULUS_MENU, 0x0922, 5, clif->pHomMenu);
- packet(CMSG_STORAGE_PASSWORD, 0x095a, 36, clif->pStoragePassword);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0961, 26, clif->pFriendsListAdd);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20160203
-if (packetVersion == 20160203)
-{
- packet(CMSG_BUYINGSTORE_SELL, 0x0202, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0361, 26, clif->pFriendsListAdd);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0436, -1, clif->pSearchStoreInfo);
- packet(CMSG_MAP_PING, 0x0437, 6, clif->pTickSend);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x07e4, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0811, 5, clif->pChangeDir);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0819, 19, clif->pWantToConnection);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0835, -1, clif->pItemListWindowSelected);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x086c, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_HOMUNCULUS_MENU, 0x0872, 5, clif->pHomMenu);
- packet(CMSG_STORAGE_PASSWORD, 0x0873, 36, clif->pStoragePassword);
-// packet(UNKNOWN, 0x088c, 4, clif->pDull);
-// packet(UNKNOWN, 0x0918, 8, clif->pDull);
- packet(CMSG_PARTY_INVITE2, 0x093e, 26, clif->pPartyInvite2);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0940, 5, clif->pWalkToXY);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0947, 6, clif->pDropItem);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0954, 8, clif->pMoveFromKafra);
- packet(CMSG_ITEM_PICKUP, 0x095a, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x095d, 8, clif->pMoveToKafra);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20160211
-if (packetVersion == 20160211)
-{
- packet(CMSG_MAP_SERVER_CONNECT, 0x022d, 19, clif->pWantToConnection);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x023b, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0281, -1, clif->pItemListWindowSelected);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0362, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x0363, 8, clif->pDull);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0364, 8, clif->pMoveFromKafra);
- packet(CMSG_STORAGE_PASSWORD, 0x0365, 36, clif->pStoragePassword);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
-// packet(UNKNOWN, 0x0436, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_ITEM_PICKUP, 0x07e4, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x07ec, 8, clif->pMoveToKafra);
- packet(CMSG_PARTY_INVITE2, 0x0802, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x086c, 5, clif->pChangeDir);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0870, 26, clif->pFriendsListAdd);
- packet(CMSG_HOMUNCULUS_MENU, 0x0886, 5, clif->pHomMenu);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20160217
-if (packetVersion == 20160217)
-{
- packet(CMSG_BUYINGSTORE_SELL, 0x0202, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x023b, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0362, 5, clif->pChangeDir);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0365, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_MOVE_TO_STORAGE, 0x0864, 8, clif->pMoveToKafra);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0870, 26, clif->pFriendsListAdd);
- packet(CMSG_HOMUNCULUS_MENU, 0x0873, 5, clif->pHomMenu);
- packet(CMSG_MAP_SERVER_CONNECT, 0x087a, 19, clif->pWantToConnection);
- packet(CMSG_MAP_PING, 0x0888, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x088d, 6, clif->pReqClickBuyingStore);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x088f, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x0899, 4, clif->pDull);
- packet(CMSG_MOVE_FROM_STORAGE, 0x08a0, 8, clif->pMoveFromKafra);
- packet(CMSG_PARTY_INVITE2, 0x08a9, 26, clif->pPartyInvite2);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x08ac, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x08ad, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x091d, 5, clif->pWalkToXY);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0920, 7, clif->pActionRequest);
- packet(CMSG_SKILL_USE_BEING, 0x0926, 10, clif->pUseSkillToId);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x092e, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x093b, -1, clif->pItemListWindowSelected);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x093e, -1, clif->pSearchStoreInfo);
- packet(CMSG_ITEM_PICKUP, 0x0941, 6, clif->pTakeItem);
- packet(CMSG_SKILL_USE_POSITION, 0x094a, 10, clif->pUseSkillToPos);
-// packet(UNKNOWN, 0x094f, 8, clif->pDull);
- packet(CMSG_STORAGE_PASSWORD, 0x095e, 36, clif->pStoragePassword);
- packet(CMSG_NAME_REQUEST, 0x0966, 6, clif->pGetCharNameRequest);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0967, 6, clif->pSolveCharName);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0969, -1, clif->pReqOpenBuyingStore);
-}
-
-// 20160224
-if (packetVersion == 20160224)
-{
- packet(CMSG_PARTY_INVITE2, 0x022d, 26, clif->pPartyInvite2);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_SKILL_USE_BEING, 0x0364, 10, clif->pUseSkillToId);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0369, 8, clif->pMoveFromKafra);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0436, 6, clif->pDropItem);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_MOVE_TO_STORAGE, 0x083c, 8, clif->pMoveToKafra);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0861, 19, clif->pWantToConnection);
-// packet(UNKNOWN, 0x086b, 8, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0884, 7, clif->pActionRequest);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0885, 6, clif->pReqClickBuyingStore);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0888, 5, clif->pWalkToXY);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x08a9, 26, clif->pFriendsListAdd);
-// packet(UNKNOWN, 0x0920, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0929, 5, clif->pChangeDir);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x092f, -1, clif->pItemListWindowSelected);
- packet(CMSG_STORAGE_PASSWORD, 0x0936, 36, clif->pStoragePassword);
- packet(CMSG_ITEM_PICKUP, 0x0938, 6, clif->pTakeItem);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x094c, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_HOMUNCULUS_MENU, 0x0961, 5, clif->pHomMenu);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20160302
-if (packetVersion == 20160302)
-{
- packet(CMSG_PLAYER_CHANGE_DIR, 0x022d, 5, clif->pChangeDir);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0367, 6, clif->pReqClickBuyingStore);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0802, 19, clif->pWantToConnection);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0819, 5, clif->pWalkToXY);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x085b, 26, clif->pFriendsListAdd);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0864, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0865, -1, clif->pSearchStoreInfo);
- packet(CMSG_BUYINGSTORE_SELL, 0x0867, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x0868, 5, clif->pHomMenu);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0873, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0875, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SKILL_USE_POSITION, 0x087a, 10, clif->pUseSkillToPos);
- packet(CMSG_PARTY_INVITE2, 0x087d, 26, clif->pPartyInvite2);
- packet(CMSG_SKILL_USE_BEING, 0x0883, 10, clif->pUseSkillToId);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x08a6, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_MOVE_FROM_STORAGE, 0x08a9, 8, clif->pMoveFromKafra);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x091a, 6, clif->pDropItem);
- packet(CMSG_ITEM_PICKUP, 0x0927, 6, clif->pTakeItem);
-// packet(UNKNOWN, 0x092d, 4, clif->pDull);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x092f, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_NAME_REQUEST, 0x0945, 6, clif->pGetCharNameRequest);
- packet(CMSG_STORAGE_PASSWORD, 0x094e, 36, clif->pStoragePassword);
-// packet(UNKNOWN, 0x0950, 8, clif->pDull);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0957, -1, clif->pItemListWindowSelected);
- packet(CMSG_MAP_PING, 0x095a, 6, clif->pTickSend);
- packet(CMSG_MOVE_TO_STORAGE, 0x0960, 8, clif->pMoveToKafra);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0961, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0967, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0968, 7, clif->pActionRequest);
-}
-
-// 20160309
-if (packetVersion == 20160309)
-{
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x023b, 6, clif->pDropItem);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0281, 6, clif->pReqClickBuyingStore);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0361, 26, clif->pFriendsListAdd);
- packet(CMSG_STORAGE_PASSWORD, 0x0364, 36, clif->pStoragePassword);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_SKILL_USE_POSITION, 0x0819, 10, clif->pUseSkillToPos);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0838, 5, clif->pWalkToXY);
- packet(CMSG_PARTY_INVITE2, 0x083c, 26, clif->pPartyInvite2);
- packet(CMSG_MOVE_TO_STORAGE, 0x085a, 8, clif->pMoveToKafra);
- packet(CMSG_SKILL_USE_BEING, 0x085f, 10, clif->pUseSkillToId);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0866, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x086a, -1, clif->pSearchStoreInfo);
-// packet(UNKNOWN, 0x0873, 8, clif->pDull);
- packet(CMSG_MAP_SERVER_CONNECT, 0x087c, 19, clif->pWantToConnection);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x087e, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x089b, -1, clif->pItemListWindowSelected);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x089d, 5, clif->pChangeDir);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x08a7, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_NAME_REQUEST, 0x091d, 6, clif->pGetCharNameRequest);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0920, 8, clif->pMoveFromKafra);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0922, -1, clif->pReqOpenBuyingStore);
-// packet(UNKNOWN, 0x0929, 4, clif->pDull);
- packet(CMSG_BUYINGSTORE_SELL, 0x092a, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x092e, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x0932, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x094f, 7, clif->pActionRequest);
- packet(CMSG_MAP_PING, 0x0956, 6, clif->pTickSend);
- packet(CMSG_SEARCHSTORE_CLICK, 0x095e, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_ITEM_PICKUP, 0x096a, 6, clif->pTakeItem);
-}
-
-// 20160316
-if (packetVersion == 20160316)
-{
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0202, 5, clif->pChangeDir);
- packet(CMSG_MAP_SERVER_CONNECT, 0x022d, 19, clif->pWantToConnection);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x023b, 26, clif->pFriendsListAdd);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0281, -1, clif->pItemListWindowSelected);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x0361, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0362, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x0363, 8, clif->pDull);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0364, 8, clif->pMoveFromKafra);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0365, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
-// packet(UNKNOWN, 0x0436, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_ITEM_PICKUP, 0x07e4, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x07ec, 8, clif->pMoveToKafra);
- packet(CMSG_PARTY_INVITE2, 0x0802, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_STORAGE_PASSWORD, 0x0922, 36, clif->pStoragePassword);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20160318
-if (packetVersion == 20160318)
-{
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0202, 5, clif->pChangeDir);
- packet(CMSG_MAP_SERVER_CONNECT, 0x022d, 19, clif->pWantToConnection);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x023b, 26, clif->pFriendsListAdd);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0281, -1, clif->pItemListWindowSelected);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x0361, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0362, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x0363, 8, clif->pDull);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0364, 8, clif->pMoveFromKafra);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0365, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
-// packet(UNKNOWN, 0x0436, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_ITEM_PICKUP, 0x07e4, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x07ec, 8, clif->pMoveToKafra);
- packet(CMSG_PARTY_INVITE2, 0x0802, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_STORAGE_PASSWORD, 0x0922, 36, clif->pStoragePassword);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20160323
-if (packetVersion == 20160323)
-{
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0365, 26, clif->pFriendsListAdd);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
-// packet(UNKNOWN, 0x0867, 8, clif->pDull);
- packet(CMSG_ITEM_PICKUP, 0x0869, 6, clif->pTakeItem);
- packet(CMSG_MOVE_FROM_STORAGE, 0x086a, 8, clif->pMoveFromKafra);
- packet(CMSG_STORAGE_PASSWORD, 0x0872, 36, clif->pStoragePassword);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0878, 19, clif->pWantToConnection);
- packet(CMSG_PARTY_INVITE2, 0x0883, 26, clif->pPartyInvite2);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0896, -1, clif->pItemListWindowSelected);
- packet(CMSG_HOMUNCULUS_MENU, 0x089a, 5, clif->pHomMenu);
-// packet(UNKNOWN, 0x091b, 4, clif->pDull);
- packet(CMSG_MOVE_TO_STORAGE, 0x0926, 8, clif->pMoveToKafra);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0927, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0933, 5, clif->pChangeDir);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x093c, 6, clif->pDropItem);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20160330
-if (packetVersion == 20160330)
-{
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_STORAGE_PASSWORD, 0x0365, 36, clif->pStoragePassword);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_PARTY_INVITE2, 0x0867, 26, clif->pPartyInvite2);
- packet(CMSG_ITEM_PICKUP, 0x086d, 6, clif->pTakeItem);
-// packet(UNKNOWN, 0x0878, 8, clif->pDull);
- packet(CMSG_MOVE_FROM_STORAGE, 0x087f, 8, clif->pMoveFromKafra);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0889, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_HOMUNCULUS_MENU, 0x088b, 5, clif->pHomMenu);
-// packet(UNKNOWN, 0x088d, 4, clif->pDull);
- packet(CMSG_MOVE_TO_STORAGE, 0x0918, 8, clif->pMoveToKafra);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0925, 19, clif->pWantToConnection);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x092a, -1, clif->pItemListWindowSelected);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x092c, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0930, 5, clif->pChangeDir);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0939, 6, clif->pDropItem);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x093b, 26, clif->pFriendsListAdd);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-if (packetVersion >= 20160330)
-{
- packet(CMSG_MAIL2_SEND_MAIL, 0x0a6e, -1, clif->pRodexSendMail);
-}
-
-// 20160406
-if (packetVersion == 20160406)
-{
- packet(CMSG_SOLVE_CHAR_NAME, 0x0364, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x07e4, 6, clif->pDropItem);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0819, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x085a, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SKILL_USE_POSITION, 0x085c, 10, clif->pUseSkillToPos);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0869, -1, clif->pSearchStoreInfo);
- packet(CMSG_ITEM_PICKUP, 0x0877, 6, clif->pTakeItem);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0878, 26, clif->pFriendsListAdd);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0879, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_SELL, 0x0884, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0892, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0895, 19, clif->pWantToConnection);
- packet(CMSG_PARTY_INVITE2, 0x0898, 26, clif->pPartyInvite2);
- packet(CMSG_NAME_REQUEST, 0x089b, 6, clif->pGetCharNameRequest);
- packet(CMSG_MOVE_FROM_STORAGE, 0x089e, 8, clif->pMoveFromKafra);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x08a1, 7, clif->pActionRequest);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x08a9, 2, clif->pReqCloseBuyingStore);
-// packet(UNKNOWN, 0x08ac, 8, clif->pDull);
- packet(CMSG_MOVE_TO_STORAGE, 0x0927, 8, clif->pMoveToKafra);
- packet(CMSG_SEARCHSTORE_CLICK, 0x092d, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0933, 5, clif->pChangeDir);
- packet(CMSG_SKILL_USE_BEING, 0x0934, 10, clif->pUseSkillToId);
- packet(CMSG_MAP_PING, 0x0940, 6, clif->pTickSend);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0949, -1, clif->pItemListWindowSelected);
- packet(CMSG_BUYINGSTORE_OPEN, 0x094d, 6, clif->pReqClickBuyingStore);
- packet(CMSG_STORAGE_PASSWORD, 0x0953, 36, clif->pStoragePassword);
- packet(CMSG_HOMUNCULUS_MENU, 0x095d, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x095f, 5, clif->pWalkToXY);
-// packet(UNKNOWN, 0x0962, 4, clif->pDull);
-}
-
-// 20160414
-if (packetVersion == 20160414)
-{
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0362, -1, clif->pItemListWindowSelected);
- packet(CMSG_ITEM_PICKUP, 0x0363, 6, clif->pTakeItem);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0862, 19, clif->pWantToConnection);
-// packet(UNKNOWN, 0x087a, 8, clif->pDull);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0880, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0885, 8, clif->pMoveFromKafra);
- packet(CMSG_PARTY_INVITE2, 0x089e, 26, clif->pPartyInvite2);
-// packet(UNKNOWN, 0x0918, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0922, 5, clif->pChangeDir);
- packet(CMSG_STORAGE_PASSWORD, 0x0927, 36, clif->pStoragePassword);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0931, 6, clif->pDropItem);
- packet(CMSG_HOMUNCULUS_MENU, 0x0934, 5, clif->pHomMenu);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0945, 26, clif->pFriendsListAdd);
- packet(CMSG_MOVE_TO_STORAGE, 0x0953, 8, clif->pMoveToKafra);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20160420
-if (packetVersion == 20160420)
-{
- packet(CMSG_SEARCHSTORE_SEARCH, 0x022d, -1, clif->pSearchStoreInfo);
- packet(CMSG_MAP_PING, 0x02c4, 6, clif->pTickSend);
- packet(CMSG_PARTY_INVITE2, 0x035f, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x0819, 5, clif->pHomMenu);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_ITEM_PICKUP, 0x0864, 6, clif->pTakeItem);
-// packet(UNKNOWN, 0x0870, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0872, 5, clif->pChangeDir);
- packet(CMSG_MOVE_TO_STORAGE, 0x0874, 8, clif->pMoveToKafra);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0884, 6, clif->pDropItem);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0888, 19, clif->pWantToConnection);
- packet(CMSG_MOVE_FROM_STORAGE, 0x088b, 8, clif->pMoveFromKafra);
- packet(CMSG_STORAGE_PASSWORD, 0x08a5, 36, clif->pStoragePassword);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x092f, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0935, 26, clif->pFriendsListAdd);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x094e, -1, clif->pItemListWindowSelected);
-// packet(UNKNOWN, 0x095c, 8, clif->pDull);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20160504
-if (packetVersion == 20160504)
-{
- packet(CMSG_HOMUNCULUS_MENU, 0x0202, 5, clif->pHomMenu);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0363, -1, clif->pReqOpenBuyingStore);
-// packet(UNKNOWN, 0x0365, 4, clif->pDull);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x083c, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x085f, 7, clif->pActionRequest);
- packet(CMSG_BUYINGSTORE_SELL, 0x086b, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x087f, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SKILL_USE_POSITION, 0x0884, 10, clif->pUseSkillToPos);
- packet(CMSG_MOVE_TO_STORAGE, 0x0886, 8, clif->pMoveToKafra);
- packet(CMSG_PARTY_INVITE2, 0x0887, 26, clif->pPartyInvite2);
- packet(CMSG_ITEM_PICKUP, 0x088a, 6, clif->pTakeItem);
- packet(CMSG_SKILL_USE_BEING, 0x088d, 10, clif->pUseSkillToId);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x088f, -1, clif->pItemListWindowSelected);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0890, 6, clif->pDropItem);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0893, 18, clif->pPartyBookingRegisterReq);
-// packet(UNKNOWN, 0x0898, 8, clif->pDull);
- packet(CMSG_SOLVE_CHAR_NAME, 0x089d, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x08ad, 5, clif->pChangeDir);
- packet(CMSG_MAP_PING, 0x0918, 6, clif->pTickSend);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0921, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_NAME_REQUEST, 0x0922, 6, clif->pGetCharNameRequest);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0924, 5, clif->pWalkToXY);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x093e, -1, clif->pSearchStoreInfo);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0940, 19, clif->pWantToConnection);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0941, 8, clif->pMoveFromKafra);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0948, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0952, 26, clif->pFriendsListAdd);
- packet(CMSG_BUYINGSTORE_OPEN, 0x095b, 6, clif->pReqClickBuyingStore);
- packet(CMSG_STORAGE_PASSWORD, 0x0969, 36, clif->pStoragePassword);
-}
-
-// 20160511
-if (packetVersion == 20160511)
-{
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0281, -1, clif->pItemListWindowSelected);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0362, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x0363, 8, clif->pDull);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0364, 8, clif->pMoveFromKafra);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0365, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_ITEM_PICKUP, 0x07e4, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x07ec, 8, clif->pMoveToKafra);
- packet(CMSG_PARTY_INVITE2, 0x0802, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x085e, 5, clif->pChangeDir);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0894, 26, clif->pFriendsListAdd);
-// packet(UNKNOWN, 0x089b, 4, clif->pDull);
- packet(CMSG_HOMUNCULUS_MENU, 0x0918, 5, clif->pHomMenu);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0920, 19, clif->pWantToConnection);
- packet(CMSG_STORAGE_PASSWORD, 0x0940, 36, clif->pStoragePassword);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20160518
-if (packetVersion == 20160518)
-{
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0281, -1, clif->pItemListWindowSelected);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0362, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x0363, 8, clif->pDull);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0364, 8, clif->pMoveFromKafra);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0365, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
-// packet(UNKNOWN, 0x0436, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_ITEM_PICKUP, 0x07e4, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x07ec, 8, clif->pMoveToKafra);
- packet(CMSG_PARTY_INVITE2, 0x0802, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x086c, 5, clif->pChangeDir);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0874, 19, clif->pWantToConnection);
- packet(CMSG_STORAGE_PASSWORD, 0x089a, 36, clif->pStoragePassword);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x08a9, 26, clif->pFriendsListAdd);
- packet(CMSG_HOMUNCULUS_MENU, 0x0928, 5, clif->pHomMenu);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20160525
-if (packetVersion == 20160525)
-{
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
-// packet(UNKNOWN, 0x085a, 4, clif->pDull);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x085e, 6, clif->pDropItem);
- packet(CMSG_HOMUNCULUS_MENU, 0x0867, 5, clif->pHomMenu);
- packet(CMSG_MAP_SERVER_CONNECT, 0x086a, 19, clif->pWantToConnection);
- packet(CMSG_ITEM_PICKUP, 0x0899, 6, clif->pTakeItem);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x089c, 5, clif->pChangeDir);
- packet(CMSG_STORAGE_PASSWORD, 0x091d, 36, clif->pStoragePassword);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x092c, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0937, -1, clif->pItemListWindowSelected);
- packet(CMSG_PARTY_INVITE2, 0x0945, 26, clif->pPartyInvite2);
- packet(CMSG_MOVE_TO_STORAGE, 0x094a, 8, clif->pMoveToKafra);
-// packet(UNKNOWN, 0x094e, 8, clif->pDull);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0951, 26, clif->pFriendsListAdd);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0956, 8, clif->pMoveFromKafra);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20160601
-if (packetVersion == 20160601)
-{
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0202, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_PARTY_INVITE2, 0x02c4, 26, clif->pPartyInvite2);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0817, 26, clif->pFriendsListAdd);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_ITEM_PICKUP, 0x0863, 6, clif->pTakeItem);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0870, 8, clif->pMoveFromKafra);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x087d, -1, clif->pItemListWindowSelected);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x088d, 6, clif->pDropItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x088f, 8, clif->pMoveToKafra);
- packet(CMSG_HOMUNCULUS_MENU, 0x0895, 5, clif->pHomMenu);
-// packet(UNKNOWN, 0x08a7, 8, clif->pDull);
- packet(CMSG_MAP_SERVER_CONNECT, 0x08ac, 19, clif->pWantToConnection);
-// packet(UNKNOWN, 0x0924, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x095b, 5, clif->pChangeDir);
- packet(CMSG_STORAGE_PASSWORD, 0x095f, 36, clif->pStoragePassword);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0961, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20160608
-if (packetVersion == 20160608)
-{
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x022d, -1, clif->pItemListWindowSelected);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x02c4, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_PARTY_INVITE2, 0x035f, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0436, 5, clif->pWalkToXY);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0437, 19, clif->pWantToConnection);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x07ec, 5, clif->pChangeDir);
- packet(CMSG_MAP_PING, 0x0802, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
-// packet(UNKNOWN, 0x085c, 8, clif->pDull);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0885, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_BUYINGSTORE_SELL, 0x0889, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_ITEM_PICKUP, 0x0899, 6, clif->pTakeItem);
- packet(CMSG_HOMUNCULUS_MENU, 0x089b, 5, clif->pHomMenu);
- packet(CMSG_MOVE_FROM_STORAGE, 0x08a6, 8, clif->pMoveFromKafra);
-// packet(UNKNOWN, 0x093b, 4, clif->pDull);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x094d, 6, clif->pDropItem);
- packet(CMSG_STORAGE_PASSWORD, 0x0958, 36, clif->pStoragePassword);
- packet(CMSG_MOVE_TO_STORAGE, 0x095b, 8, clif->pMoveToKafra);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0969, 26, clif->pFriendsListAdd);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20160609
-if (packetVersion == 20160609)
-{
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x022d, -1, clif->pItemListWindowSelected);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x02c4, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_PARTY_INVITE2, 0x035f, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0436, 5, clif->pWalkToXY);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0437, 19, clif->pWantToConnection);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x07ec, 5, clif->pChangeDir);
- packet(CMSG_MAP_PING, 0x0802, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
-// packet(UNKNOWN, 0x085c, 8, clif->pDull);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0885, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_BUYINGSTORE_SELL, 0x0889, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_ITEM_PICKUP, 0x0899, 6, clif->pTakeItem);
- packet(CMSG_HOMUNCULUS_MENU, 0x089b, 5, clif->pHomMenu);
- packet(CMSG_MOVE_FROM_STORAGE, 0x08a6, 8, clif->pMoveFromKafra);
-// packet(UNKNOWN, 0x093b, 4, clif->pDull);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x094d, 6, clif->pDropItem);
- packet(CMSG_STORAGE_PASSWORD, 0x0958, 36, clif->pStoragePassword);
- packet(CMSG_MOVE_TO_STORAGE, 0x095b, 8, clif->pMoveToKafra);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0969, 26, clif->pFriendsListAdd);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20160615
-if (packetVersion == 20160615)
-{
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0281, 26, clif->pFriendsListAdd);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0363, 19, clif->pWantToConnection);
- packet(CMSG_STORAGE_PASSWORD, 0x0364, 36, clif->pStoragePassword);
- packet(CMSG_HOMUNCULUS_MENU, 0x0369, 5, clif->pHomMenu);
- packet(CMSG_NAME_REQUEST, 0x083c, 6, clif->pGetCharNameRequest);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0866, 5, clif->pWalkToXY);
-// packet(UNKNOWN, 0x0870, 4, clif->pDull);
- packet(CMSG_SOLVE_CHAR_NAME, 0x087d, 6, clif->pSolveCharName);
- packet(CMSG_ITEM_PICKUP, 0x087e, 6, clif->pTakeItem);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x087f, 90, clif->pUseSkillToPosMoreInfo);
-// packet(UNKNOWN, 0x0884, 8, clif->pDull);
- packet(CMSG_BUYINGSTORE_SELL, 0x0887, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_SKILL_USE_BEING, 0x0888, 10, clif->pUseSkillToId);
- packet(CMSG_MAP_PING, 0x088a, 6, clif->pTickSend);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x088d, -1, clif->pItemListWindowSelected);
- packet(CMSG_SKILL_USE_POSITION, 0x0891, 10, clif->pUseSkillToPos);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0898, 6, clif->pDropItem);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x092f, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_PARTY_INVITE2, 0x093e, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0947, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0948, 7, clif->pActionRequest);
- packet(CMSG_BUYINGSTORE_OPEN, 0x094a, 6, clif->pReqClickBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x094b, -1, clif->pSearchStoreInfo);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0954, 5, clif->pChangeDir);
- packet(CMSG_MOVE_TO_STORAGE, 0x0957, 8, clif->pMoveToKafra);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0958, 8, clif->pMoveFromKafra);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x095c, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_BUYINGSTORE_CREATE, 0x095e, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0961, 12, clif->pSearchStoreInfoListItemClick);
-}
-
-// 20160622
-if (packetVersion == 20160622)
-{
- packet(CMSG_SKILL_USE_POSITION, 0x023b, 10, clif->pUseSkillToPos);
- packet(CMSG_MOVE_FROM_STORAGE, 0x035f, 8, clif->pMoveFromKafra);
- packet(CMSG_PARTY_INVITE2, 0x0361, 26, clif->pPartyInvite2);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_HOMUNCULUS_MENU, 0x07e4, 5, clif->pHomMenu);
- packet(CMSG_BUYINGSTORE_SELL, 0x0861, -1, clif->pReqTradeBuyingStore);
-// packet(UNKNOWN, 0x0865, 4, clif->pDull);
-// packet(UNKNOWN, 0x0867, 8, clif->pDull);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0880, -1, clif->pSearchStoreInfo);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0887, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0890, 26, clif->pFriendsListAdd);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0891, 6, clif->pReqClickBuyingStore);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0892, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x089a, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x089e, 7, clif->pActionRequest);
- packet(CMSG_SOLVE_CHAR_NAME, 0x08a2, 6, clif->pSolveCharName);
- packet(CMSG_STORAGE_PASSWORD, 0x08a8, 36, clif->pStoragePassword);
- packet(CMSG_ITEM_PICKUP, 0x091c, 6, clif->pTakeItem);
- packet(CMSG_MAP_PING, 0x092d, 6, clif->pTickSend);
- packet(CMSG_SKILL_USE_BEING, 0x092f, 10, clif->pUseSkillToId);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0936, 19, clif->pWantToConnection);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0937, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_MOVE_TO_STORAGE, 0x093b, 8, clif->pMoveToKafra);
- packet(CMSG_BUYINGSTORE_CREATE, 0x093f, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0946, -1, clif->pItemListWindowSelected);
- packet(CMSG_NAME_REQUEST, 0x0959, 6, clif->pGetCharNameRequest);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0965, 5, clif->pChangeDir);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0969, 6, clif->pDropItem);
-}
-
-// 20160629
-if (packetVersion == 20160629)
-{
- packet(CMSG_SEARCHSTORE_CLICK, 0x0202, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x022d, 5, clif->pWalkToXY);
-// packet(UNKNOWN, 0x035f, 4, clif->pDull);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0363, 6, clif->pReqClickBuyingStore);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0368, -1, clif->pItemListWindowSelected);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x085c, 90, clif->pUseSkillToPosMoreInfo);
-// packet(UNKNOWN, 0x085e, 8, clif->pDull);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0860, -1, clif->pSearchStoreInfo);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0861, 6, clif->pDropItem);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0863, 6, clif->pSolveCharName);
- packet(CMSG_STORAGE_PASSWORD, 0x0867, 36, clif->pStoragePassword);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x086b, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0881, 19, clif->pWantToConnection);
- packet(CMSG_HOMUNCULUS_MENU, 0x0885, 5, clif->pHomMenu);
- packet(CMSG_NAME_REQUEST, 0x088e, 6, clif->pGetCharNameRequest);
- packet(CMSG_MAP_PING, 0x0893, 6, clif->pTickSend);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x091e, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0922, 8, clif->pMoveFromKafra);
- packet(CMSG_SKILL_USE_BEING, 0x0925, 10, clif->pUseSkillToId);
- packet(CMSG_PARTY_INVITE2, 0x0926, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_SELL, 0x093e, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0946, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0948, 5, clif->pChangeDir);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x094a, 26, clif->pFriendsListAdd);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0957, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x095a, 7, clif->pActionRequest);
- packet(CMSG_SKILL_USE_POSITION, 0x0968, 10, clif->pUseSkillToPos);
- packet(CMSG_ITEM_PICKUP, 0x0969, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x096a, 8, clif->pMoveToKafra);
-}
-
-// 20160630
-if (packetVersion == 20160630)
-{
- packet(CMSG_SEARCHSTORE_CLICK, 0x0202, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x022d, 5, clif->pWalkToXY);
-// packet(UNKNOWN, 0x035f, 4, clif->pDull);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0363, 6, clif->pReqClickBuyingStore);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0368, -1, clif->pItemListWindowSelected);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x085c, 90, clif->pUseSkillToPosMoreInfo);
-// packet(UNKNOWN, 0x085e, 8, clif->pDull);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0860, -1, clif->pSearchStoreInfo);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0861, 6, clif->pDropItem);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0863, 6, clif->pSolveCharName);
- packet(CMSG_STORAGE_PASSWORD, 0x0867, 36, clif->pStoragePassword);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x086b, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0881, 19, clif->pWantToConnection);
- packet(CMSG_HOMUNCULUS_MENU, 0x0885, 5, clif->pHomMenu);
- packet(CMSG_NAME_REQUEST, 0x088e, 6, clif->pGetCharNameRequest);
- packet(CMSG_MAP_PING, 0x0893, 6, clif->pTickSend);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x091e, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0922, 8, clif->pMoveFromKafra);
- packet(CMSG_SKILL_USE_BEING, 0x0925, 10, clif->pUseSkillToId);
- packet(CMSG_PARTY_INVITE2, 0x0926, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_SELL, 0x093e, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0946, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0948, 5, clif->pChangeDir);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x094a, 26, clif->pFriendsListAdd);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0957, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x095a, 7, clif->pActionRequest);
- packet(CMSG_SKILL_USE_POSITION, 0x0968, 10, clif->pUseSkillToPos);
- packet(CMSG_ITEM_PICKUP, 0x0969, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x096a, 8, clif->pMoveToKafra);
-}
-
-// 20160706
-if (packetVersion == 20160706)
-{
- packet(CMSG_SOLVE_CHAR_NAME, 0x0362, 6, clif->pSolveCharName);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0436, 6, clif->pReqClickBuyingStore);
- packet(CMSG_PARTY_INVITE2, 0x085f, 26, clif->pPartyInvite2);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0860, 7, clif->pActionRequest);
- packet(CMSG_BUYINGSTORE_SELL, 0x0869, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x086b, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0884, 26, clif->pFriendsListAdd);
-// packet(UNKNOWN, 0x0886, 4, clif->pDull);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0889, -1, clif->pSearchStoreInfo);
- packet(CMSG_HOMUNCULUS_MENU, 0x0892, 5, clif->pHomMenu);
- packet(CMSG_SKILL_USE_BEING, 0x0899, 10, clif->pUseSkillToId);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x08a4, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_MAP_SERVER_CONNECT, 0x08a5, 19, clif->pWantToConnection);
- packet(CMSG_MAP_PING, 0x08a8, 6, clif->pTickSend);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0918, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x091b, -1, clif->pItemListWindowSelected);
- packet(CMSG_SKILL_USE_POSITION, 0x0924, 10, clif->pUseSkillToPos);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0926, 5, clif->pChangeDir);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0927, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0929, 8, clif->pMoveFromKafra);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x092d, 5, clif->pWalkToXY);
- packet(CMSG_MOVE_TO_STORAGE, 0x0939, 8, clif->pMoveToKafra);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x093d, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x0944, 8, clif->pDull);
- packet(CMSG_NAME_REQUEST, 0x0945, 6, clif->pGetCharNameRequest);
- packet(CMSG_STORAGE_PASSWORD, 0x094c, 36, clif->pStoragePassword);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0952, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0957, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_ITEM_PICKUP, 0x0958, 6, clif->pTakeItem);
-}
-
-// 20160713
-if (packetVersion == 20160713)
-{
- packet(CMSG_STORAGE_PASSWORD, 0x022d, 36, clif->pStoragePassword);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0363, 5, clif->pChangeDir);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0364, -1, clif->pItemListWindowSelected);
- packet(CMSG_ITEM_PICKUP, 0x0838, 6, clif->pTakeItem);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0860, 6, clif->pReqClickBuyingStore);
- packet(CMSG_BUYINGSTORE_SELL, 0x0865, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0869, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0875, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SKILL_USE_POSITION, 0x0877, 10, clif->pUseSkillToPos);
- packet(CMSG_MAP_PING, 0x087b, 6, clif->pTickSend);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0883, -1, clif->pSearchStoreInfo);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x088d, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0892, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_PARTY_INVITE2, 0x089a, 26, clif->pPartyInvite2);
-// packet(UNKNOWN, 0x089f, 4, clif->pDull);
- packet(CMSG_MOVE_FROM_STORAGE, 0x08a2, 8, clif->pMoveFromKafra);
- packet(CMSG_MAP_SERVER_CONNECT, 0x08a4, 19, clif->pWantToConnection);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x091c, 5, clif->pWalkToXY);
- packet(CMSG_SOLVE_CHAR_NAME, 0x091d, 6, clif->pSolveCharName);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0921, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_HOMUNCULUS_MENU, 0x0922, 5, clif->pHomMenu);
- packet(CMSG_NAME_REQUEST, 0x092c, 6, clif->pGetCharNameRequest);
- packet(CMSG_SKILL_USE_BEING, 0x0931, 10, clif->pUseSkillToId);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0939, 26, clif->pFriendsListAdd);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0944, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0945, 7, clif->pActionRequest);
- packet(CMSG_MOVE_TO_STORAGE, 0x0947, 8, clif->pMoveToKafra);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0957, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x095b, 8, clif->pDull);
-}
-
-// 20160720
-if (packetVersion == 20160720)
-{
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0362, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SKILL_USE_BEING, 0x0363, 10, clif->pUseSkillToId);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0365, 7, clif->pActionRequest);
- packet(CMSG_MAP_SERVER_CONNECT, 0x07e4, 19, clif->pWantToConnection);
- packet(CMSG_BUYINGSTORE_SELL, 0x0819, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0838, 5, clif->pWalkToXY);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x085b, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x086a, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_BUYINGSTORE_OPEN, 0x086d, 6, clif->pReqClickBuyingStore);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x087f, 6, clif->pDropItem);
- packet(CMSG_SKILL_USE_POSITION, 0x0883, 10, clif->pUseSkillToPos);
- packet(CMSG_NAME_REQUEST, 0x0887, 6, clif->pGetCharNameRequest);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0897, -1, clif->pSearchStoreInfo);
- packet(CMSG_STORAGE_PASSWORD, 0x089a, 36, clif->pStoragePassword);
- packet(CMSG_HOMUNCULUS_MENU, 0x089c, 5, clif->pHomMenu);
- packet(CMSG_MOVE_FROM_STORAGE, 0x089e, 8, clif->pMoveFromKafra);
- packet(CMSG_SEARCHSTORE_CLICK, 0x08a0, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x08aa, -1, clif->pItemListWindowSelected);
-// packet(UNKNOWN, 0x0917, 4, clif->pDull);
- packet(CMSG_ITEM_PICKUP, 0x091c, 6, clif->pTakeItem);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x092a, 26, clif->pFriendsListAdd);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x093b, 5, clif->pChangeDir);
- packet(CMSG_BUYINGSTORE_CREATE, 0x093e, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_MAP_PING, 0x0946, 6, clif->pTickSend);
- packet(CMSG_SOLVE_CHAR_NAME, 0x094d, 6, clif->pSolveCharName);
-// packet(UNKNOWN, 0x0953, 8, clif->pDull);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x095b, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_MOVE_TO_STORAGE, 0x0960, 8, clif->pMoveToKafra);
- packet(CMSG_PARTY_INVITE2, 0x0969, 26, clif->pPartyInvite2);
-}
-
-// 20160727
-if (packetVersion == 20160727)
-{
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0202, 5, clif->pChangeDir);
-// packet(UNKNOWN, 0x023b, 8, clif->pDull);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0362, -1, clif->pSearchStoreInfo);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0363, 26, clif->pFriendsListAdd);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0436, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_MAP_PING, 0x0438, 6, clif->pTickSend);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x07ec, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x0866, 4, clif->pDull);
- packet(CMSG_PARTY_INVITE2, 0x0868, 26, clif->pPartyInvite2);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0869, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0874, 6, clif->pReqClickBuyingStore);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0877, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0883, 7, clif->pActionRequest);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0887, 19, clif->pWantToConnection);
- packet(CMSG_SKILL_USE_BEING, 0x088e, 10, clif->pUseSkillToId);
- packet(CMSG_BUYINGSTORE_SELL, 0x0891, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_SKILL_USE_POSITION, 0x089f, 10, clif->pUseSkillToPos);
- packet(CMSG_STORAGE_PASSWORD, 0x08a2, 36, clif->pStoragePassword);
- packet(CMSG_SOLVE_CHAR_NAME, 0x08a4, 6, clif->pSolveCharName);
- packet(CMSG_ITEM_PICKUP, 0x08a7, 6, clif->pTakeItem);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x092e, 5, clif->pWalkToXY);
- packet(CMSG_HOMUNCULUS_MENU, 0x0936, 5, clif->pHomMenu);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0941, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_NAME_REQUEST, 0x0946, 6, clif->pGetCharNameRequest);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0949, 8, clif->pMoveFromKafra);
- packet(CMSG_MOVE_TO_STORAGE, 0x0951, 8, clif->pMoveToKafra);
- packet(CMSG_BUYINGSTORE_CREATE, 0x095f, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0966, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0969, -1, clif->pItemListWindowSelected);
-}
-
-// 20160803
-if (packetVersion == 20160803)
-{
- packet(CMSG_MAP_SERVER_CONNECT, 0x0364, 19, clif->pWantToConnection);
- packet(CMSG_BUYINGSTORE_OPEN, 0x085d, 6, clif->pReqClickBuyingStore);
-// packet(UNKNOWN, 0x0878, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x087f, 5, clif->pWalkToXY);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0881, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_MOVE_TO_STORAGE, 0x0886, 8, clif->pMoveToKafra);
- packet(CMSG_NAME_REQUEST, 0x0887, 6, clif->pGetCharNameRequest);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0888, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x088b, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0891, 5, clif->pChangeDir);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0895, 26, clif->pFriendsListAdd);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x089c, 6, clif->pDropItem);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x089e, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_BUYINGSTORE_CREATE, 0x08a1, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_ITEM_PICKUP, 0x091b, 6, clif->pTakeItem);
- packet(CMSG_STORAGE_PASSWORD, 0x0929, 36, clif->pStoragePassword);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0930, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x0932, 10, clif->pUseSkillToId);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0934, 7, clif->pActionRequest);
- packet(CMSG_SKILL_USE_POSITION, 0x0937, 10, clif->pUseSkillToPos);
-// packet(UNKNOWN, 0x093a, 8, clif->pDull);
- packet(CMSG_MAP_PING, 0x093e, 6, clif->pTickSend);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x093f, -1, clif->pSearchStoreInfo);
- packet(CMSG_HOMUNCULUS_MENU, 0x0952, 5, clif->pHomMenu);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0955, 8, clif->pMoveFromKafra);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0956, -1, clif->pItemListWindowSelected);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0959, 6, clif->pSolveCharName);
- packet(CMSG_PARTY_INVITE2, 0x095a, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_SELL, 0x096a, -1, clif->pReqTradeBuyingStore);
-}
-
-// 20160810
-if (packetVersion == 20160810)
-{
- packet(CMSG_STORAGE_PASSWORD, 0x0361, 36, clif->pStoragePassword);
- packet(CMSG_SKILL_USE_POSITION, 0x0819, 10, clif->pUseSkillToPos);
- packet(CMSG_PARTY_INVITE2, 0x0838, 26, clif->pPartyInvite2);
- packet(CMSG_SEARCHSTORE_CLICK, 0x085d, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x085e, 6, clif->pDropItem);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x085f, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0860, 6, clif->pSolveCharName);
- packet(CMSG_BUYINGSTORE_CREATE, 0x086f, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x0875, 5, clif->pHomMenu);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0879, 6, clif->pReqClickBuyingStore);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x087a, 5, clif->pWalkToXY);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0885, 19, clif->pWantToConnection);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0888, 26, clif->pFriendsListAdd);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0890, -1, clif->pSearchStoreInfo);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x089d, 5, clif->pChangeDir);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x089f, -1, clif->pItemListWindowSelected);
- packet(CMSG_MOVE_TO_STORAGE, 0x08a9, 8, clif->pMoveToKafra);
- packet(CMSG_ITEM_PICKUP, 0x091a, 6, clif->pTakeItem);
- packet(CMSG_NAME_REQUEST, 0x091b, 6, clif->pGetCharNameRequest);
- packet(CMSG_SKILL_USE_BEING, 0x091c, 10, clif->pUseSkillToId);
-// packet(UNKNOWN, 0x0926, 4, clif->pDull);
- packet(CMSG_BUYINGSTORE_SELL, 0x092b, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_MOVE_FROM_STORAGE, 0x092d, 8, clif->pMoveFromKafra);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0935, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_MAP_PING, 0x0943, 6, clif->pTickSend);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x094b, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0959, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x095b, 7, clif->pActionRequest);
-// packet(UNKNOWN, 0x0967, 8, clif->pDull);
-}
-
-// 20160831
-if (packetVersion == 20160831)
-{
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x022d, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0366, 6, clif->pDropItem);
- packet(CMSG_BUYINGSTORE_OPEN, 0x07ec, 6, clif->pReqClickBuyingStore);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0835, 19, clif->pWantToConnection);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0865, 5, clif->pWalkToXY);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x086d, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0870, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_PARTY_INVITE2, 0x0874, 26, clif->pPartyInvite2);
-// packet(UNKNOWN, 0x0876, 8, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0878, 7, clif->pActionRequest);
- packet(CMSG_NAME_REQUEST, 0x087c, 6, clif->pGetCharNameRequest);
- packet(CMSG_BUYINGSTORE_SELL, 0x08a8, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_MAP_PING, 0x08a9, 6, clif->pTickSend);
- packet(CMSG_STORAGE_PASSWORD, 0x0917, 36, clif->pStoragePassword);
-// packet(UNKNOWN, 0x091b, 4, clif->pDull);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x092c, 26, clif->pFriendsListAdd);
- packet(CMSG_SEARCHSTORE_CLICK, 0x092e, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0938, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_HOMUNCULUS_MENU, 0x093a, 5, clif->pHomMenu);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0946, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x094a, 5, clif->pChangeDir);
- packet(CMSG_MOVE_TO_STORAGE, 0x094f, 8, clif->pMoveToKafra);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0950, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0954, -1, clif->pItemListWindowSelected);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0957, -1, clif->pSearchStoreInfo);
- packet(CMSG_MOVE_FROM_STORAGE, 0x095e, 8, clif->pMoveFromKafra);
- packet(CMSG_ITEM_PICKUP, 0x0960, 6, clif->pTakeItem);
- packet(CMSG_SKILL_USE_POSITION, 0x0964, 10, clif->pUseSkillToPos);
- packet(CMSG_SKILL_USE_BEING, 0x0967, 10, clif->pUseSkillToId);
-}
-
-// 20160907
-if (packetVersion == 20160907)
-{
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0202, 5, clif->pChangeDir);
- packet(CMSG_MAP_SERVER_CONNECT, 0x022d, 19, clif->pWantToConnection);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x023b, 26, clif->pFriendsListAdd);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0281, -1, clif->pItemListWindowSelected);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x0361, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0362, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x0363, 8, clif->pDull);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0364, 8, clif->pMoveFromKafra);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0365, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
-// packet(UNKNOWN, 0x0436, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_ITEM_PICKUP, 0x07e4, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x07ec, 8, clif->pMoveToKafra);
- packet(CMSG_PARTY_INVITE2, 0x0802, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_STORAGE_PASSWORD, 0x091c, 36, clif->pStoragePassword);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20160913
-if (packetVersion == 20160913)
-{
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0361, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_MOVE_TO_STORAGE, 0x0817, 8, clif->pMoveToKafra);
- packet(CMSG_SEARCHSTORE_CLICK, 0x085b, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_NAME_REQUEST, 0x0865, 6, clif->pGetCharNameRequest);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0874, 6, clif->pReqClickBuyingStore);
- packet(CMSG_MAP_PING, 0x0875, 6, clif->pTickSend);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0879, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x087a, 8, clif->pDull);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x087b, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0887, -1, clif->pItemListWindowSelected);
- packet(CMSG_ITEM_PICKUP, 0x0889, 6, clif->pTakeItem);
- packet(CMSG_SKILL_USE_BEING, 0x088e, 10, clif->pUseSkillToId);
- packet(CMSG_BUYINGSTORE_SELL, 0x088f, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0891, -1, clif->pSearchStoreInfo);
- packet(CMSG_SKILL_USE_POSITION, 0x0892, 10, clif->pUseSkillToPos);
- packet(CMSG_MOVE_FROM_STORAGE, 0x089b, 8, clif->pMoveFromKafra);
- packet(CMSG_STORAGE_PASSWORD, 0x089c, 36, clif->pStoragePassword);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x08a5, 5, clif->pChangeDir);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0928, 26, clif->pFriendsListAdd);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0935, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x093a, 5, clif->pHomMenu);
- packet(CMSG_PARTY_INVITE2, 0x0949, 26, clif->pPartyInvite2);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x094a, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0950, 7, clif->pActionRequest);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0952, 19, clif->pWantToConnection);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0954, 5, clif->pWalkToXY);
-// packet(UNKNOWN, 0x0962, 4, clif->pDull);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0963, 6, clif->pSolveCharName);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0968, 2, clif->pReqCloseBuyingStore);
-}
-
-// 20160921
-if (packetVersion == 20160921)
-{
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0202, 5, clif->pChangeDir);
- packet(CMSG_MAP_SERVER_CONNECT, 0x022d, 19, clif->pWantToConnection);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x023b, 26, clif->pFriendsListAdd);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0281, -1, clif->pItemListWindowSelected);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x0361, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0362, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x0363, 8, clif->pDull);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0364, 8, clif->pMoveFromKafra);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0365, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
-// packet(UNKNOWN, 0x0436, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_ITEM_PICKUP, 0x07e4, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x07ec, 8, clif->pMoveToKafra);
- packet(CMSG_PARTY_INVITE2, 0x0802, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_STORAGE_PASSWORD, 0x094a, 36, clif->pStoragePassword);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20160928
-if (packetVersion == 20160928)
-{
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0202, -1, clif->pItemListWindowSelected);
- packet(CMSG_NAME_REQUEST, 0x035f, 6, clif->pGetCharNameRequest);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0366, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0436, 6, clif->pReqClickBuyingStore);
-// packet(UNKNOWN, 0x0811, 8, clif->pDull);
- packet(CMSG_PARTY_INVITE2, 0x0838, 26, clif->pPartyInvite2);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0864, 8, clif->pMoveFromKafra);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0866, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x086d, 6, clif->pDropItem);
- packet(CMSG_HOMUNCULUS_MENU, 0x0872, 5, clif->pHomMenu);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0878, 6, clif->pSolveCharName);
- packet(CMSG_SEARCHSTORE_CLICK, 0x087f, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0889, 19, clif->pWantToConnection);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x088e, -1, clif->pSearchStoreInfo);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0897, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x089a, 7, clif->pActionRequest);
- packet(CMSG_STORAGE_PASSWORD, 0x08a2, 36, clif->pStoragePassword);
- packet(CMSG_MOVE_TO_STORAGE, 0x08a9, 8, clif->pMoveToKafra);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0919, 5, clif->pWalkToXY);
- packet(CMSG_MAP_PING, 0x091e, 6, clif->pTickSend);
- packet(CMSG_SKILL_USE_BEING, 0x0927, 10, clif->pUseSkillToId);
- packet(CMSG_SKILL_USE_POSITION, 0x092d, 10, clif->pUseSkillToPos);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0944, 5, clif->pChangeDir);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x094d, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x094e, 26, clif->pFriendsListAdd);
- packet(CMSG_BUYINGSTORE_SELL, 0x0953, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0955, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_ITEM_PICKUP, 0x0957, 6, clif->pTakeItem);
-// packet(UNKNOWN, 0x095a, 4, clif->pDull);
-}
-
-// 20161005
-if (packetVersion == 20161005)
-{
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0202, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0368, 7, clif->pActionRequest);
- packet(CMSG_STORAGE_PASSWORD, 0x0838, 36, clif->pStoragePassword);
- packet(CMSG_NAME_REQUEST, 0x0863, 6, clif->pGetCharNameRequest);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0886, -1, clif->pItemListWindowSelected);
- packet(CMSG_MOVE_FROM_STORAGE, 0x088e, 8, clif->pMoveFromKafra);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0891, 5, clif->pChangeDir);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0892, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_PARTY_INVITE2, 0x089b, 26, clif->pPartyInvite2);
- packet(CMSG_ITEM_PICKUP, 0x089c, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x08a0, 8, clif->pMoveToKafra);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x08ac, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_BUYINGSTORE_SELL, 0x08ad, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0918, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0919, 6, clif->pSolveCharName);
-// packet(UNKNOWN, 0x091e, 8, clif->pDull);
- packet(CMSG_MAP_PING, 0x092b, 6, clif->pTickSend);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0931, 26, clif->pFriendsListAdd);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0932, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_POSITION, 0x093b, 10, clif->pUseSkillToPos);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0942, 6, clif->pDropItem);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0944, -1, clif->pSearchStoreInfo);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0945, 5, clif->pWalkToXY);
- packet(CMSG_BUYINGSTORE_CREATE, 0x094a, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x094d, 5, clif->pHomMenu);
-// packet(UNKNOWN, 0x0952, 4, clif->pDull);
- packet(CMSG_BUYINGSTORE_OPEN, 0x095a, 6, clif->pReqClickBuyingStore);
- packet(CMSG_MAP_SERVER_CONNECT, 0x095b, 19, clif->pWantToConnection);
- packet(CMSG_SKILL_USE_BEING, 0x0967, 10, clif->pUseSkillToId);
-}
-
-// 20161012
-if (packetVersion == 20161012)
-{
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x023b, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0362, 6, clif->pDropItem);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0364, -1, clif->pItemListWindowSelected);
- packet(CMSG_MAP_PING, 0x0365, 6, clif->pTickSend);
- packet(CMSG_PARTY_INVITE2, 0x0369, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_CREATE, 0x07ec, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0819, 26, clif->pFriendsListAdd);
-// packet(UNKNOWN, 0x085b, 4, clif->pDull);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x085e, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0863, 7, clif->pActionRequest);
- packet(CMSG_ITEM_PICKUP, 0x0868, 6, clif->pTakeItem);
- packet(CMSG_MAP_SERVER_CONNECT, 0x086d, 19, clif->pWantToConnection);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0872, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0875, -1, clif->pSearchStoreInfo);
- packet(CMSG_SKILL_USE_POSITION, 0x0880, 10, clif->pUseSkillToPos);
- packet(CMSG_MOVE_TO_STORAGE, 0x0893, 8, clif->pMoveToKafra);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x08a0, 5, clif->pChangeDir);
- packet(CMSG_SOLVE_CHAR_NAME, 0x092d, 6, clif->pSolveCharName);
- packet(CMSG_NAME_REQUEST, 0x0936, 6, clif->pGetCharNameRequest);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0937, 6, clif->pReqClickBuyingStore);
- packet(CMSG_BUYINGSTORE_SELL, 0x0939, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0943, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0944, 8, clif->pMoveFromKafra);
-// packet(UNKNOWN, 0x094f, 8, clif->pDull);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0951, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_HOMUNCULUS_MENU, 0x095c, 5, clif->pHomMenu);
- packet(CMSG_SKILL_USE_BEING, 0x0962, 10, clif->pUseSkillToId);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0966, 5, clif->pWalkToXY);
- packet(CMSG_STORAGE_PASSWORD, 0x0967, 36, clif->pStoragePassword);
-}
-
-// 20161019
-if (packetVersion == 20161019)
-{
- packet(CMSG_BUYINGSTORE_OPEN, 0x022d, 6, clif->pReqClickBuyingStore);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0281, -1, clif->pItemListWindowSelected);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_HOMUNCULUS_MENU, 0x0360, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0361, 5, clif->pWalkToXY);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0362, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x0363, 8, clif->pDull);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0364, 8, clif->pMoveFromKafra);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0365, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0437, 5, clif->pChangeDir);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_ITEM_PICKUP, 0x07e4, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x07ec, 8, clif->pMoveToKafra);
- packet(CMSG_PARTY_INVITE2, 0x0802, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_STORAGE_PASSWORD, 0x0889, 36, clif->pStoragePassword);
-// packet(UNKNOWN, 0x0892, 4, clif->pDull);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0946, 19, clif->pWantToConnection);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0963, 26, clif->pFriendsListAdd);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20161026
-if (packetVersion == 20161026)
-{
- packet(CMSG_STORAGE_PASSWORD, 0x0363, 36, clif->pStoragePassword);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0438, 5, clif->pWalkToXY);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0802, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_MOVE_TO_STORAGE, 0x085a, 8, clif->pMoveToKafra);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x085f, 7, clif->pActionRequest);
- packet(CMSG_BUYINGSTORE_SELL, 0x0861, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_MAP_PING, 0x0862, 6, clif->pTickSend);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x086a, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x086c, 12, clif->pSearchStoreInfoListItemClick);
-// packet(UNKNOWN, 0x086e, 8, clif->pDull);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x087a, -1, clif->pSearchStoreInfo);
-// packet(UNKNOWN, 0x087c, 4, clif->pDull);
- packet(CMSG_SKILL_USE_POSITION, 0x087f, 10, clif->pUseSkillToPos);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0886, 6, clif->pDropItem);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0891, 6, clif->pReqClickBuyingStore);
- packet(CMSG_SKILL_USE_BEING, 0x0894, 10, clif->pUseSkillToId);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0898, 26, clif->pFriendsListAdd);
- packet(CMSG_MAP_SERVER_CONNECT, 0x091a, 19, clif->pWantToConnection);
- packet(CMSG_ITEM_PICKUP, 0x091b, 6, clif->pTakeItem);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0926, 6, clif->pSolveCharName);
- packet(CMSG_BUYINGSTORE_CREATE, 0x092c, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x092e, 5, clif->pHomMenu);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x092f, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_NAME_REQUEST, 0x0930, 6, clif->pGetCharNameRequest);
- packet(CMSG_MOVE_FROM_STORAGE, 0x094b, 8, clif->pMoveFromKafra);
- packet(CMSG_PARTY_INVITE2, 0x0953, 26, clif->pPartyInvite2);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x095c, -1, clif->pItemListWindowSelected);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x095e, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0962, 5, clif->pChangeDir);
-}
-
-// 20161102
-if (packetVersion == 20161102)
-{
- packet(CMSG_MOVE_FROM_STORAGE, 0x0361, 8, clif->pMoveFromKafra);
-// packet(UNKNOWN, 0x0367, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0436, 7, clif->pActionRequest);
- packet(CMSG_ITEM_PICKUP, 0x0802, 6, clif->pTakeItem);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0838, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x083c, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SKILL_USE_BEING, 0x085f, 10, clif->pUseSkillToId);
- packet(CMSG_MOVE_TO_STORAGE, 0x0869, 8, clif->pMoveToKafra);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x086c, 2, clif->pSearchStoreInfoNextPage);
-// packet(UNKNOWN, 0x086f, 8, clif->pDull);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0874, -1, clif->pSearchStoreInfo);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0886, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_HOMUNCULUS_MENU, 0x088f, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0890, 6, clif->pDropItem);
- packet(CMSG_PARTY_INVITE2, 0x089f, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_SELL, 0x08a2, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x08aa, 5, clif->pWalkToXY);
- packet(CMSG_STORAGE_PASSWORD, 0x091b, 36, clif->pStoragePassword);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0922, 6, clif->pReqClickBuyingStore);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0925, 6, clif->pSolveCharName);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0928, 26, clif->pFriendsListAdd);
- packet(CMSG_NAME_REQUEST, 0x092f, 6, clif->pGetCharNameRequest);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0936, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0946, 19, clif->pWantToConnection);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0949, 5, clif->pChangeDir);
- packet(CMSG_SEARCHSTORE_CLICK, 0x095e, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0964, -1, clif->pItemListWindowSelected);
- packet(CMSG_SKILL_USE_POSITION, 0x0965, 10, clif->pUseSkillToPos);
- packet(CMSG_MAP_PING, 0x0966, 6, clif->pTickSend);
-}
-
-// 20161103
-if (packetVersion == 20161103)
-{
- packet(CMSG_MOVE_FROM_STORAGE, 0x0361, 8, clif->pMoveFromKafra);
-// packet(UNKNOWN, 0x0367, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0436, 7, clif->pActionRequest);
- packet(CMSG_ITEM_PICKUP, 0x0802, 6, clif->pTakeItem);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0838, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x083c, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SKILL_USE_BEING, 0x085f, 10, clif->pUseSkillToId);
- packet(CMSG_MOVE_TO_STORAGE, 0x0869, 8, clif->pMoveToKafra);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x086c, 2, clif->pSearchStoreInfoNextPage);
-// packet(UNKNOWN, 0x086f, 8, clif->pDull);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0874, -1, clif->pSearchStoreInfo);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0886, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_HOMUNCULUS_MENU, 0x088f, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0890, 6, clif->pDropItem);
- packet(CMSG_PARTY_INVITE2, 0x089f, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_SELL, 0x08a2, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x08aa, 5, clif->pWalkToXY);
- packet(CMSG_STORAGE_PASSWORD, 0x091b, 36, clif->pStoragePassword);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0922, 6, clif->pReqClickBuyingStore);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0925, 6, clif->pSolveCharName);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0928, 26, clif->pFriendsListAdd);
- packet(CMSG_NAME_REQUEST, 0x092f, 6, clif->pGetCharNameRequest);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0936, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0946, 19, clif->pWantToConnection);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0949, 5, clif->pChangeDir);
- packet(CMSG_SEARCHSTORE_CLICK, 0x095e, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0964, -1, clif->pItemListWindowSelected);
- packet(CMSG_SKILL_USE_POSITION, 0x0965, 10, clif->pUseSkillToPos);
- packet(CMSG_MAP_PING, 0x0966, 6, clif->pTickSend);
-}
-
-// 20161109
-if (packetVersion == 20161109)
-{
- packet(CMSG_BOOKING_REGISTER_REQ, 0x02c4, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0361, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0362, 8, clif->pMoveFromKafra);
- packet(CMSG_MAP_PING, 0x0365, 6, clif->pTickSend);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0366, -1, clif->pSearchStoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0835, 6, clif->pSolveCharName);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x085d, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x085e, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0865, 5, clif->pWalkToXY);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x086a, 7, clif->pActionRequest);
- packet(CMSG_SKILL_USE_POSITION, 0x086d, 10, clif->pUseSkillToPos);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0870, 19, clif->pWantToConnection);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0876, 6, clif->pReqClickBuyingStore);
-// packet(UNKNOWN, 0x087a, 8, clif->pDull);
- packet(CMSG_MOVE_TO_STORAGE, 0x0881, 8, clif->pMoveToKafra);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x088e, -1, clif->pItemListWindowSelected);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0891, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_ITEM_PICKUP, 0x0898, 6, clif->pTakeItem);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x089a, 6, clif->pDropItem);
- packet(CMSG_BUYINGSTORE_CREATE, 0x089d, -1, clif->pReqOpenBuyingStore);
-// packet(UNKNOWN, 0x089f, 4, clif->pDull);
- packet(CMSG_HOMUNCULUS_MENU, 0x08a7, 5, clif->pHomMenu);
- packet(CMSG_BUYINGSTORE_SELL, 0x08ad, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_PARTY_INVITE2, 0x0927, 26, clif->pPartyInvite2);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0937, 26, clif->pFriendsListAdd);
- packet(CMSG_STORAGE_PASSWORD, 0x093c, 36, clif->pStoragePassword);
- packet(CMSG_NAME_REQUEST, 0x093f, 6, clif->pGetCharNameRequest);
- packet(CMSG_SKILL_USE_BEING, 0x0954, 10, clif->pUseSkillToId);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0956, 5, clif->pChangeDir);
-}
-
-// 20161116
-if (packetVersion == 20161116)
-{
- packet(CMSG_MAP_PING, 0x0368, 6, clif->pTickSend);
- packet(CMSG_MOVE_TO_STORAGE, 0x0369, 8, clif->pMoveToKafra);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0835, 26, clif->pFriendsListAdd);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x085f, 6, clif->pDropItem);
- packet(CMSG_PARTY_INVITE2, 0x0864, 26, clif->pPartyInvite2);
- packet(CMSG_ITEM_PICKUP, 0x086f, 6, clif->pTakeItem);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0885, -1, clif->pSearchStoreInfo);
- packet(CMSG_HOMUNCULUS_MENU, 0x088b, 5, clif->pHomMenu);
- packet(CMSG_BUYINGSTORE_OPEN, 0x088d, 6, clif->pReqClickBuyingStore);
- packet(CMSG_MAP_SERVER_CONNECT, 0x088f, 19, clif->pWantToConnection);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0890, 5, clif->pWalkToXY);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0892, -1, clif->pItemListWindowSelected);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0893, 7, clif->pActionRequest);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x08a1, 5, clif->pChangeDir);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x08a2, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SEARCHSTORE_CLICK, 0x08aa, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_MOVE_FROM_STORAGE, 0x08ac, 8, clif->pMoveFromKafra);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0920, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SKILL_USE_POSITION, 0x0925, 10, clif->pUseSkillToPos);
- packet(CMSG_SKILL_USE_BEING, 0x092a, 10, clif->pUseSkillToId);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0931, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_SELL, 0x093c, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_NAME_REQUEST, 0x094a, 6, clif->pGetCharNameRequest);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0952, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0957, 6, clif->pSolveCharName);
- packet(CMSG_STORAGE_PASSWORD, 0x095b, 36, clif->pStoragePassword);
-// packet(UNKNOWN, 0x095d, 4, clif->pDull);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x095f, 2, clif->pSearchStoreInfoNextPage);
-// packet(UNKNOWN, 0x0967, 8, clif->pDull);
-}
-
-// 20161123
-if (packetVersion == 20161123)
-{
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0281, -1, clif->pItemListWindowSelected);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x035f, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0362, -1, clif->pSearchStoreInfo);
- packet(CMSG_MAP_PING, 0x0437, 6, clif->pTickSend);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x085c, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0861, 5, clif->pWalkToXY);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0862, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0866, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x086f, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x0871, 4, clif->pDull);
- packet(CMSG_PARTY_INVITE2, 0x087f, 26, clif->pPartyInvite2);
- packet(CMSG_STORAGE_PASSWORD, 0x0880, 36, clif->pStoragePassword);
- packet(CMSG_BUYINGSTORE_SELL, 0x0882, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_NAME_REQUEST, 0x088b, 6, clif->pGetCharNameRequest);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x089c, 5, clif->pChangeDir);
- packet(CMSG_SKILL_USE_POSITION, 0x08a9, 10, clif->pUseSkillToPos);
- packet(CMSG_SEARCHSTORE_CLICK, 0x08aa, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_MOVE_TO_STORAGE, 0x091a, 8, clif->pMoveToKafra);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0926, 19, clif->pWantToConnection);
- packet(CMSG_BUYINGSTORE_OPEN, 0x092a, 6, clif->pReqClickBuyingStore);
- packet(CMSG_ITEM_PICKUP, 0x092f, 6, clif->pTakeItem);
- packet(CMSG_HOMUNCULUS_MENU, 0x0930, 5, clif->pHomMenu);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0941, 26, clif->pFriendsListAdd);
- packet(CMSG_SKILL_USE_BEING, 0x094d, 10, clif->pUseSkillToId);
- packet(CMSG_BUYINGSTORE_CREATE, 0x094f, -1, clif->pReqOpenBuyingStore);
-// packet(UNKNOWN, 0x095a, 8, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x095b, 7, clif->pActionRequest);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0962, 8, clif->pMoveFromKafra);
- packet(CMSG_SOLVE_CHAR_NAME, 0x096a, 6, clif->pSolveCharName);
-}
-
-// 20161130
-if (packetVersion == 20161130)
-{
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0281, -1, clif->pItemListWindowSelected);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x035f, 5, clif->pChangeDir);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_MAP_PING, 0x0361, 6, clif->pTickSend);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0362, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x0363, 8, clif->pDull);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0364, 8, clif->pMoveFromKafra);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0365, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_ITEM_PICKUP, 0x07e4, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x07ec, 8, clif->pMoveToKafra);
- packet(CMSG_PARTY_INVITE2, 0x0802, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
-// packet(UNKNOWN, 0x088f, 4, clif->pDull);
- packet(CMSG_HOMUNCULUS_MENU, 0x0931, 5, clif->pHomMenu);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0943, 19, clif->pWantToConnection);
- packet(CMSG_STORAGE_PASSWORD, 0x0954, 36, clif->pStoragePassword);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0959, 26, clif->pFriendsListAdd);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20161207
-if (packetVersion == 20161207)
-{
- packet(CMSG_HOMUNCULUS_MENU, 0x023b, 5, clif->pHomMenu);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0361, 19, clif->pWantToConnection);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0867, 26, clif->pFriendsListAdd);
-// packet(UNKNOWN, 0x0868, 8, clif->pDull);
- packet(CMSG_MOVE_TO_STORAGE, 0x0875, 8, clif->pMoveToKafra);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x087e, -1, clif->pItemListWindowSelected);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0886, 7, clif->pActionRequest);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x08a1, 5, clif->pChangeDir);
- packet(CMSG_ITEM_PICKUP, 0x08a2, 6, clif->pTakeItem);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x08ad, 6, clif->pDropItem);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0918, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_MOVE_FROM_STORAGE, 0x091d, 8, clif->pMoveFromKafra);
-// packet(UNKNOWN, 0x0943, 4, clif->pDull);
- packet(CMSG_STORAGE_PASSWORD, 0x095d, 36, clif->pStoragePassword);
- packet(CMSG_PARTY_INVITE2, 0x0965, 26, clif->pPartyInvite2);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20161214
-if (packetVersion == 20161214)
-{
- packet(CMSG_BUYINGSTORE_OPEN, 0x022d, 6, clif->pReqClickBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0281, -1, clif->pSearchStoreInfo);
- packet(CMSG_MOVE_FROM_STORAGE, 0x02c4, 8, clif->pMoveFromKafra);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_HOMUNCULUS_MENU, 0x0360, 5, clif->pHomMenu);
- packet(CMSG_MOVE_TO_STORAGE, 0x0364, 8, clif->pMoveToKafra);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0369, 19, clif->pWantToConnection);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0436, 7, clif->pActionRequest);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
-// packet(UNKNOWN, 0x0819, 4, clif->pDull);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x085a, -1, clif->pItemListWindowSelected);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0862, 26, clif->pFriendsListAdd);
- packet(CMSG_PARTY_INVITE2, 0x086d, 26, clif->pPartyInvite2);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0887, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x0895, 8, clif->pDull);
- packet(CMSG_STORAGE_PASSWORD, 0x0899, 36, clif->pStoragePassword);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x08a6, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_ITEM_PICKUP, 0x092e, 6, clif->pTakeItem);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x093d, 5, clif->pChangeDir);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20161221
-if (packetVersion == 20161221)
-{
- packet(CMSG_ITEM_PICKUP, 0x035f, 6, clif->pTakeItem);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0362, 6, clif->pDropItem);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0366, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0438, 5, clif->pWalkToXY);
- packet(CMSG_MOVE_TO_STORAGE, 0x0817, 8, clif->pMoveToKafra);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x085b, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0866, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0876, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_NAME_REQUEST, 0x0881, 6, clif->pGetCharNameRequest);
-// packet(UNKNOWN, 0x0884, 8, clif->pDull);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0885, -1, clif->pItemListWindowSelected);
- packet(CMSG_BUYINGSTORE_SELL, 0x088c, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_STORAGE_PASSWORD, 0x0890, 36, clif->pStoragePassword);
-// packet(UNKNOWN, 0x0899, 4, clif->pDull);
- packet(CMSG_MOVE_FROM_STORAGE, 0x089a, 8, clif->pMoveFromKafra);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x089b, 7, clif->pActionRequest);
- packet(CMSG_MAP_PING, 0x08aa, 6, clif->pTickSend);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x091e, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_PARTY_INVITE2, 0x0926, 26, clif->pPartyInvite2);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0928, 26, clif->pFriendsListAdd);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x092c, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x092e, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_HOMUNCULUS_MENU, 0x0930, 5, clif->pHomMenu);
- packet(CMSG_SKILL_USE_BEING, 0x0943, 10, clif->pUseSkillToId);
- packet(CMSG_SKILL_USE_POSITION, 0x0946, 10, clif->pUseSkillToPos);
- packet(CMSG_BUYINGSTORE_CREATE, 0x094b, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_OPEN, 0x095a, 6, clif->pReqClickBuyingStore);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0964, 19, clif->pWantToConnection);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0965, 5, clif->pChangeDir);
-}
-
-// 20161228
-if (packetVersion == 20161228)
-{
- packet(CMSG_BUYINGSTORE_SELL, 0x0362, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_NAME_REQUEST, 0x085a, 6, clif->pGetCharNameRequest);
- packet(CMSG_HOMUNCULUS_MENU, 0x085e, 5, clif->pHomMenu);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0865, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_BUYINGSTORE_CREATE, 0x086a, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_ITEM_PICKUP, 0x086c, 6, clif->pTakeItem);
- packet(CMSG_MAP_SERVER_CONNECT, 0x086d, 19, clif->pWantToConnection);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0870, -1, clif->pSearchStoreInfo);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0871, 5, clif->pChangeDir);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0875, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_CLICK, 0x087f, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0886, 5, clif->pWalkToXY);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0889, -1, clif->pItemListWindowSelected);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0893, 6, clif->pDropItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x089f, 8, clif->pMoveToKafra);
- packet(CMSG_SKILL_USE_BEING, 0x08a2, 10, clif->pUseSkillToId);
- packet(CMSG_BUYINGSTORE_OPEN, 0x08a3, 6, clif->pReqClickBuyingStore);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x08a5, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_MOVE_FROM_STORAGE, 0x08ab, 8, clif->pMoveFromKafra);
- packet(CMSG_SOLVE_CHAR_NAME, 0x08ac, 6, clif->pSolveCharName);
- packet(CMSG_STORAGE_PASSWORD, 0x08ad, 36, clif->pStoragePassword);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x091c, 26, clif->pFriendsListAdd);
- packet(CMSG_SKILL_USE_POSITION, 0x0929, 10, clif->pUseSkillToPos);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x092c, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_PARTY_INVITE2, 0x0934, 26, clif->pPartyInvite2);
-// packet(UNKNOWN, 0x0935, 8, clif->pDull);
-// packet(UNKNOWN, 0x0938, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x093d, 7, clif->pActionRequest);
- packet(CMSG_MAP_PING, 0x0944, 6, clif->pTickSend);
-}
-
-// 20170104
-if (packetVersion == 20170104)
-{
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0281, -1, clif->pItemListWindowSelected);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0362, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x0363, 8, clif->pDull);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0364, 8, clif->pMoveFromKafra);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0365, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
-// packet(UNKNOWN, 0x0436, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0438, 19, clif->pWantToConnection);
- packet(CMSG_ITEM_PICKUP, 0x07e4, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x07ec, 8, clif->pMoveToKafra);
- packet(CMSG_PARTY_INVITE2, 0x0802, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_POSITION, 0x083c, 10, clif->pUseSkillToPos);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x085a, 26, clif->pFriendsListAdd);
- packet(CMSG_STORAGE_PASSWORD, 0x087f, 36, clif->pStoragePassword);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0896, 5, clif->pChangeDir);
- packet(CMSG_HOMUNCULUS_MENU, 0x091b, 5, clif->pHomMenu);
- packet(CMSG_SKILL_USE_BEING, 0x0940, 10, clif->pUseSkillToId);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20170111
-if (packetVersion == 20170111)
-{
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
-// packet(UNKNOWN, 0x0436, 8, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_HOMUNCULUS_MENU, 0x085d, 5, clif->pHomMenu);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0877, 26, clif->pFriendsListAdd);
-// packet(UNKNOWN, 0x087f, 4, clif->pDull);
- packet(CMSG_MOVE_TO_STORAGE, 0x088a, 8, clif->pMoveToKafra);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x08a1, 5, clif->pChangeDir);
- packet(CMSG_ITEM_PICKUP, 0x08a3, 6, clif->pTakeItem);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x08a6, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_STORAGE_PASSWORD, 0x091a, 36, clif->pStoragePassword);
- packet(CMSG_MAP_SERVER_CONNECT, 0x091b, 19, clif->pWantToConnection);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0940, 6, clif->pDropItem);
- packet(CMSG_MOVE_FROM_STORAGE, 0x094c, 8, clif->pMoveFromKafra);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0961, -1, clif->pItemListWindowSelected);
- packet(CMSG_PARTY_INVITE2, 0x0969, 26, clif->pPartyInvite2);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20170118
-if (packetVersion == 20170118)
-{
- packet(CMSG_SKILL_USE_POSITION, 0x022d, 10, clif->pUseSkillToPos);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_NAME_REQUEST, 0x0364, 6, clif->pGetCharNameRequest);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
- packet(CMSG_HOMUNCULUS_MENU, 0x0436, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0438, 19, clif->pWantToConnection);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0862, 8, clif->pMoveFromKafra);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0865, 5, clif->pChangeDir);
- packet(CMSG_ITEM_PICKUP, 0x086f, 6, clif->pTakeItem);
-// packet(UNKNOWN, 0x0873, 4, clif->pDull);
- packet(CMSG_PARTY_INVITE2, 0x089e, 26, clif->pPartyInvite2);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x08ad, -1, clif->pItemListWindowSelected);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x091f, 18, clif->pPartyBookingRegisterReq);
-// packet(UNKNOWN, 0x0927, 8, clif->pDull);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0933, 6, clif->pDropItem);
- packet(CMSG_STORAGE_PASSWORD, 0x0958, 36, clif->pStoragePassword);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0962, 26, clif->pFriendsListAdd);
- packet(CMSG_MOVE_TO_STORAGE, 0x096a, 8, clif->pMoveToKafra);
-}
-
-// 20170125
-if (packetVersion == 20170125)
-{
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0438, 7, clif->pActionRequest);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0811, 19, clif->pWantToConnection);
- packet(CMSG_PARTY_INVITE2, 0x086e, 26, clif->pPartyInvite2);
- packet(CMSG_HOMUNCULUS_MENU, 0x0876, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0877, 6, clif->pDropItem);
- packet(CMSG_SKILL_USE_BEING, 0x0879, 10, clif->pUseSkillToId);
- packet(CMSG_ITEM_PICKUP, 0x087b, 6, clif->pTakeItem);
- packet(CMSG_BUYINGSTORE_SELL, 0x087d, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0881, 5, clif->pChangeDir);
-// packet(UNKNOWN, 0x0884, 8, clif->pDull);
- packet(CMSG_STORAGE_PASSWORD, 0x0893, 36, clif->pStoragePassword);
-// packet(UNKNOWN, 0x0894, 4, clif->pDull);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0895, -1, clif->pItemListWindowSelected);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0898, 6, clif->pSolveCharName);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x089b, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_BUYINGSTORE_CREATE, 0x08a5, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_OPEN, 0x091b, 6, clif->pReqClickBuyingStore);
- packet(CMSG_MOVE_TO_STORAGE, 0x091c, 8, clif->pMoveToKafra);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x091d, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0920, 26, clif->pFriendsListAdd);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0929, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_POSITION, 0x092b, 10, clif->pUseSkillToPos);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0930, 5, clif->pWalkToXY);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x093c, -1, clif->pSearchStoreInfo);
- packet(CMSG_MAP_PING, 0x0943, 6, clif->pTickSend);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0944, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_MOVE_FROM_STORAGE, 0x095c, 8, clif->pMoveFromKafra);
- packet(CMSG_NAME_REQUEST, 0x0965, 6, clif->pGetCharNameRequest);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0968, 2, clif->pSearchStoreInfoNextPage);
-}
-
-// 20170201
-if (packetVersion == 20170201)
-{
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_BUYINGSTORE_SELL, 0x0815, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x085d, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x085e, 5, clif->pChangeDir);
- packet(CMSG_ITEM_PICKUP, 0x0875, 6, clif->pTakeItem);
-// packet(UNKNOWN, 0x0879, 4, clif->pDull);
- packet(CMSG_MOVE_TO_STORAGE, 0x0881, 8, clif->pMoveToKafra);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0884, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0885, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_STORAGE_PASSWORD, 0x0886, 36, clif->pStoragePassword);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x088b, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x08a4, 8, clif->pDull);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0919, 26, clif->pFriendsListAdd);
- packet(CMSG_PARTY_INVITE2, 0x0920, 26, clif->pPartyInvite2);
- packet(CMSG_HOMUNCULUS_MENU, 0x0938, 5, clif->pHomMenu);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0940, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_MAP_SERVER_CONNECT, 0x094c, 19, clif->pWantToConnection);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0966, 8, clif->pMoveFromKafra);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0969, -1, clif->pItemListWindowSelected);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20170208
-if (packetVersion == 20170208)
-{
-// packet(UNKNOWN, 0x02c4, 4, clif->pDull);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0367, -1, clif->pItemListWindowSelected);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_PARTY_INVITE2, 0x085c, 26, clif->pPartyInvite2);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0860, 5, clif->pChangeDir);
-// packet(UNKNOWN, 0x087a, 8, clif->pDull);
- packet(CMSG_MAP_SERVER_CONNECT, 0x088c, 19, clif->pWantToConnection);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0892, 26, clif->pFriendsListAdd);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x08a1, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_MOVE_TO_STORAGE, 0x08ac, 8, clif->pMoveToKafra);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0921, 6, clif->pDropItem);
- packet(CMSG_ITEM_PICKUP, 0x0923, 6, clif->pTakeItem);
- packet(CMSG_HOMUNCULUS_MENU, 0x092d, 5, clif->pHomMenu);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0932, 8, clif->pMoveFromKafra);
- packet(CMSG_STORAGE_PASSWORD, 0x0937, 36, clif->pStoragePassword);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20170215
-if (packetVersion == 20170215)
-{
- packet(CMSG_STORAGE_PASSWORD, 0x02c4, 36, clif->pStoragePassword);
- packet(CMSG_BUYINGSTORE_SELL, 0x035f, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_MAP_PING, 0x0360, 6, clif->pTickSend);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0811, 19, clif->pWantToConnection);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x083c, 7, clif->pActionRequest);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x085c, 6, clif->pDropItem);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0876, 26, clif->pFriendsListAdd);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x087c, -1, clif->pItemListWindowSelected);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x087d, 5, clif->pChangeDir);
- packet(CMSG_SKILL_USE_BEING, 0x087e, 10, clif->pUseSkillToId);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0883, 6, clif->pSolveCharName);
-// packet(UNKNOWN, 0x0884, 8, clif->pDull);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x088a, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_PARTY_INVITE2, 0x088b, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_CREATE, 0x088c, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_SKILL_USE_POSITION, 0x0890, 10, clif->pUseSkillToPos);
-// packet(UNKNOWN, 0x0896, 4, clif->pDull);
- packet(CMSG_MOVE_TO_STORAGE, 0x089b, 8, clif->pMoveToKafra);
- packet(CMSG_SEARCHSTORE_CLICK, 0x08a2, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x08a8, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x091c, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0925, 8, clif->pMoveFromKafra);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x092b, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x092d, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_ITEM_PICKUP, 0x0942, 6, clif->pTakeItem);
- packet(CMSG_NAME_REQUEST, 0x094e, 6, clif->pGetCharNameRequest);
- packet(CMSG_BUYINGSTORE_OPEN, 0x095f, 6, clif->pReqClickBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x0962, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0969, 5, clif->pWalkToXY);
-}
-
-// 20170222
-if (packetVersion == 20170222)
-{
- packet(CMSG_HOMUNCULUS_MENU, 0x0202, 5, clif->pHomMenu);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x085f, 26, clif->pFriendsListAdd);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0866, 6, clif->pDropItem);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0870, 18, clif->pPartyBookingRegisterReq);
-// packet(UNKNOWN, 0x0871, 4, clif->pDull);
-// packet(UNKNOWN, 0x0877, 8, clif->pDull);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0889, -1, clif->pSearchStoreInfo);
- packet(CMSG_ITEM_PICKUP, 0x0894, 6, clif->pTakeItem);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x08a3, 5, clif->pChangeDir);
- packet(CMSG_PARTY_INVITE2, 0x08a8, 26, clif->pPartyInvite2);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0937, -1, clif->pItemListWindowSelected);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0939, 19, clif->pWantToConnection);
- packet(CMSG_STORAGE_PASSWORD, 0x0943, 36, clif->pStoragePassword);
- packet(CMSG_MOVE_TO_STORAGE, 0x095d, 8, clif->pMoveToKafra);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0962, 8, clif->pMoveFromKafra);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20170228
-if (packetVersion == 20170228)
-{
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x022d, 6, clif->pDropItem);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0360, 7, clif->pActionRequest);
- packet(CMSG_HOMUNCULUS_MENU, 0x0362, 5, clif->pHomMenu);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0819, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x085e, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0863, -1, clif->pSearchStoreInfo);
- packet(CMSG_MAP_SERVER_CONNECT, 0x086b, 19, clif->pWantToConnection);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0873, -1, clif->pItemListWindowSelected);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0874, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0876, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0883, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0884, 5, clif->pWalkToXY);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0889, 5, clif->pChangeDir);
- packet(CMSG_NAME_REQUEST, 0x0893, 6, clif->pGetCharNameRequest);
- packet(CMSG_MOVE_TO_STORAGE, 0x089e, 8, clif->pMoveToKafra);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x08a0, 26, clif->pFriendsListAdd);
- packet(CMSG_STORAGE_PASSWORD, 0x08a2, 36, clif->pStoragePassword);
-// packet(UNKNOWN, 0x08a6, 8, clif->pDull);
- packet(CMSG_BUYINGSTORE_OPEN, 0x08a7, 6, clif->pReqClickBuyingStore);
- packet(CMSG_SKILL_USE_BEING, 0x091f, 10, clif->pUseSkillToId);
- packet(CMSG_ITEM_PICKUP, 0x092a, 6, clif->pTakeItem);
- packet(CMSG_BUYINGSTORE_SELL, 0x092e, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_MAP_PING, 0x0937, 6, clif->pTickSend);
-// packet(UNKNOWN, 0x093e, 4, clif->pDull);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0944, 8, clif->pMoveFromKafra);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0947, 6, clif->pSolveCharName);
- packet(CMSG_PARTY_INVITE2, 0x0948, 26, clif->pPartyInvite2);
- packet(CMSG_SKILL_USE_POSITION, 0x0952, 10, clif->pUseSkillToPos);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0955, 18, clif->pPartyBookingRegisterReq);
-}
-
-// 20170308
-if (packetVersion == 20170308)
-{
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0202, 5, clif->pChangeDir);
- packet(CMSG_MAP_SERVER_CONNECT, 0x022d, 19, clif->pWantToConnection);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x023b, 26, clif->pFriendsListAdd);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0281, -1, clif->pItemListWindowSelected);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x0361, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0362, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x0363, 8, clif->pDull);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0364, 8, clif->pMoveFromKafra);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0365, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
-// packet(UNKNOWN, 0x0436, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_ITEM_PICKUP, 0x07e4, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x07ec, 8, clif->pMoveToKafra);
- packet(CMSG_PARTY_INVITE2, 0x0802, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_STORAGE_PASSWORD, 0x087d, 36, clif->pStoragePassword);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20170315
-if (packetVersion == 20170315)
-{
- packet(CMSG_SKILL_USE_POSITION, 0x02c4, 10, clif->pUseSkillToPos);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x035f, -1, clif->pSearchStoreInfo);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0360, 5, clif->pChangeDir);
- packet(CMSG_ITEM_PICKUP, 0x0366, 6, clif->pTakeItem);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0367, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_BUYINGSTORE_SELL, 0x0436, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_MAP_PING, 0x07ec, 6, clif->pTickSend);
-// packet(UNKNOWN, 0x085c, 4, clif->pDull);
- packet(CMSG_HOMUNCULUS_MENU, 0x0863, 5, clif->pHomMenu);
- packet(CMSG_MOVE_FROM_STORAGE, 0x086a, 8, clif->pMoveFromKafra);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0872, 26, clif->pFriendsListAdd);
- packet(CMSG_PARTY_INVITE2, 0x087b, 26, clif->pPartyInvite2);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0884, 7, clif->pActionRequest);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x088b, 18, clif->pPartyBookingRegisterReq);
-// packet(UNKNOWN, 0x088d, 8, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x088f, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_BEING, 0x0892, 10, clif->pUseSkillToId);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x089c, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_MOVE_TO_STORAGE, 0x08aa, 8, clif->pMoveToKafra);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x091a, 6, clif->pDropItem);
- packet(CMSG_BUYINGSTORE_CREATE, 0x091b, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_SEARCHSTORE_CLICK, 0x091d, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0920, 6, clif->pSolveCharName);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0922, -1, clif->pItemListWindowSelected);
- packet(CMSG_NAME_REQUEST, 0x0944, 6, clif->pGetCharNameRequest);
- packet(CMSG_BUYINGSTORE_OPEN, 0x094a, 6, clif->pReqClickBuyingStore);
- packet(CMSG_MAP_SERVER_CONNECT, 0x094e, 19, clif->pWantToConnection);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0950, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_STORAGE_PASSWORD, 0x0952, 36, clif->pStoragePassword);
-}
-
-// 20170322
-if (packetVersion == 20170322)
-{
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0202, 5, clif->pChangeDir);
- packet(CMSG_MAP_SERVER_CONNECT, 0x022d, 19, clif->pWantToConnection);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x023b, 26, clif->pFriendsListAdd);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0281, -1, clif->pItemListWindowSelected);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x0361, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0362, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x0363, 8, clif->pDull);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0364, 8, clif->pMoveFromKafra);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0365, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
-// packet(UNKNOWN, 0x0436, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_ITEM_PICKUP, 0x07e4, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x07ec, 8, clif->pMoveToKafra);
- packet(CMSG_PARTY_INVITE2, 0x0802, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_STORAGE_PASSWORD, 0x091a, 36, clif->pStoragePassword);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20170329
-if (packetVersion == 20170329)
-{
- packet(CMSG_PARTY_INVITE2, 0x0281, 26, clif->pPartyInvite2);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x0362, 5, clif->pHomMenu);
- packet(CMSG_MOVE_TO_STORAGE, 0x0363, 8, clif->pMoveToKafra);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_STORAGE_PASSWORD, 0x085d, 36, clif->pStoragePassword);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x087a, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0888, -1, clif->pSearchStoreInfo);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x08a8, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x0917, 8, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0926, 5, clif->pChangeDir);
- packet(CMSG_ITEM_PICKUP, 0x0929, 6, clif->pTakeItem);
- packet(CMSG_MAP_SERVER_CONNECT, 0x092e, 19, clif->pWantToConnection);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0937, -1, clif->pItemListWindowSelected);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0939, 26, clif->pFriendsListAdd);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0949, 8, clif->pMoveFromKafra);
-// packet(UNKNOWN, 0x095f, 4, clif->pDull);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20170405
-if (packetVersion == 20170405)
-{
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x022d, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0281, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0362, 7, clif->pActionRequest);
-// packet(UNKNOWN, 0x0363, 4, clif->pDull);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_ITEM_PICKUP, 0x0369, 6, clif->pTakeItem);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_HOMUNCULUS_MENU, 0x0835, 5, clif->pHomMenu);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_MOVE_TO_STORAGE, 0x085f, 8, clif->pMoveToKafra);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0860, -1, clif->pItemListWindowSelected);
- packet(CMSG_PARTY_INVITE2, 0x0864, 26, clif->pPartyInvite2);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0865, 5, clif->pChangeDir);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x086f, 26, clif->pFriendsListAdd);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0893, 8, clif->pMoveFromKafra);
- packet(CMSG_MAP_SERVER_CONNECT, 0x08a5, 19, clif->pWantToConnection);
- packet(CMSG_STORAGE_PASSWORD, 0x094c, 36, clif->pStoragePassword);
-// packet(UNKNOWN, 0x094f, 8, clif->pDull);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0964, 6, clif->pDropItem);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20170412
-if (packetVersion == 20170412)
-{
- packet(CMSG_SKILL_USE_POSITION, 0x023b, 10, clif->pUseSkillToPos);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0365, 6, clif->pReqClickBuyingStore);
- packet(CMSG_BUYINGSTORE_SELL, 0x0863, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0869, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_MOVE_FROM_STORAGE, 0x086d, 8, clif->pMoveFromKafra);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0878, 5, clif->pWalkToXY);
-// packet(UNKNOWN, 0x0879, 4, clif->pDull);
- packet(CMSG_SKILL_USE_BEING, 0x087b, 10, clif->pUseSkillToId);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x088b, -1, clif->pSearchStoreInfo);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0890, -1, clif->pItemListWindowSelected);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0893, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0898, 6, clif->pSolveCharName);
- packet(CMSG_HOMUNCULUS_MENU, 0x089a, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x089c, 6, clif->pDropItem);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x08a1, 7, clif->pActionRequest);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x091a, 5, clif->pChangeDir);
- packet(CMSG_MAP_SERVER_CONNECT, 0x091e, 19, clif->pWantToConnection);
- packet(CMSG_MAP_PING, 0x0929, 6, clif->pTickSend);
-// packet(UNKNOWN, 0x092e, 8, clif->pDull);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0938, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0942, 26, clif->pFriendsListAdd);
- packet(CMSG_MOVE_TO_STORAGE, 0x0945, 8, clif->pMoveToKafra);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0949, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_PARTY_INVITE2, 0x094f, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0952, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_ITEM_PICKUP, 0x0959, 6, clif->pTakeItem);
- packet(CMSG_NAME_REQUEST, 0x095b, 6, clif->pGetCharNameRequest);
- packet(CMSG_SEARCHSTORE_CLICK, 0x095c, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_STORAGE_PASSWORD, 0x095d, 36, clif->pStoragePassword);
-}
-
-// 20170419
-if (packetVersion == 20170419)
-{
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0811, 5, clif->pChangeDir);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0819, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_NAME_REQUEST, 0x0838, 6, clif->pGetCharNameRequest);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x085a, 7, clif->pActionRequest);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x085e, 5, clif->pWalkToXY);
- packet(CMSG_PARTY_INVITE2, 0x0862, 26, clif->pPartyInvite2);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0868, -1, clif->pSearchStoreInfo);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x086a, 18, clif->pPartyBookingRegisterReq);
-// packet(UNKNOWN, 0x0872, 8, clif->pDull);
- packet(CMSG_STORAGE_PASSWORD, 0x0881, 36, clif->pStoragePassword);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x088d, -1, clif->pItemListWindowSelected);
- packet(CMSG_HOMUNCULUS_MENU, 0x088f, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0897, 6, clif->pDropItem);
- packet(CMSG_MAP_PING, 0x0898, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_CREATE, 0x089d, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_MOVE_TO_STORAGE, 0x08aa, 8, clif->pMoveToKafra);
- packet(CMSG_SOLVE_CHAR_NAME, 0x091b, 6, clif->pSolveCharName);
- packet(CMSG_SKILL_USE_BEING, 0x0920, 10, clif->pUseSkillToId);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0922, 19, clif->pWantToConnection);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0930, 8, clif->pMoveFromKafra);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0931, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0935, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x093a, 26, clif->pFriendsListAdd);
- packet(CMSG_SKILL_USE_POSITION, 0x093f, 10, clif->pUseSkillToPos);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0942, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_ITEM_PICKUP, 0x095c, 6, clif->pTakeItem);
- packet(CMSG_BUYINGSTORE_SELL, 0x095d, -1, clif->pReqTradeBuyingStore);
-// packet(UNKNOWN, 0x0963, 4, clif->pDull);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0965, 6, clif->pReqClickBuyingStore);
-}
-
-// 20170426
-if (packetVersion == 20170426)
-{
- packet(CMSG_STORAGE_PASSWORD, 0x0281, 36, clif->pStoragePassword);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_PARTY_INVITE2, 0x0802, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0866, -1, clif->pItemListWindowSelected);
-// packet(UNKNOWN, 0x086f, 8, clif->pDull);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x087a, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0887, 6, clif->pSolveCharName);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0899, 8, clif->pMoveFromKafra);
- packet(CMSG_HOMUNCULUS_MENU, 0x089c, 5, clif->pHomMenu);
- packet(CMSG_MAP_SERVER_CONNECT, 0x08a2, 19, clif->pWantToConnection);
- packet(CMSG_ITEM_PICKUP, 0x08a4, 6, clif->pTakeItem);
-// packet(UNKNOWN, 0x091f, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0927, 5, clif->pChangeDir);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0940, 6, clif->pDropItem);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0958, 26, clif->pFriendsListAdd);
- packet(CMSG_MOVE_TO_STORAGE, 0x0963, 8, clif->pMoveToKafra);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20170502
-if (packetVersion == 20170502)
-{
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0281, -1, clif->pItemListWindowSelected);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0362, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x0363, 8, clif->pDull);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0364, 8, clif->pMoveFromKafra);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0365, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
-// packet(UNKNOWN, 0x0436, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_ITEM_PICKUP, 0x07e4, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x07ec, 8, clif->pMoveToKafra);
- packet(CMSG_PARTY_INVITE2, 0x0802, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_STORAGE_PASSWORD, 0x0875, 36, clif->pStoragePassword);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0894, 5, clif->pChangeDir);
- packet(CMSG_MAP_SERVER_CONNECT, 0x089c, 19, clif->pWantToConnection);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x093c, 26, clif->pFriendsListAdd);
- packet(CMSG_HOMUNCULUS_MENU, 0x0950, 5, clif->pHomMenu);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20170517
-if (packetVersion == 20170517)
-{
-// packet(UNKNOWN, 0x0364, 8, clif->pDull);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0367, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0437, 7, clif->pActionRequest);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0802, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SKILL_USE_BEING, 0x0815, 10, clif->pUseSkillToId);
- packet(CMSG_SKILL_USE_POSITION, 0x0817, 10, clif->pUseSkillToPos);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0868, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0875, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SOLVE_CHAR_NAME, 0x087b, 6, clif->pSolveCharName);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x087d, -1, clif->pSearchStoreInfo);
- packet(CMSG_MOVE_FROM_STORAGE, 0x088c, 8, clif->pMoveFromKafra);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x088d, 5, clif->pChangeDir);
- packet(CMSG_NAME_REQUEST, 0x0894, 6, clif->pGetCharNameRequest);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0896, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_PARTY_INVITE2, 0x0899, 26, clif->pPartyInvite2);
-// packet(UNKNOWN, 0x089e, 4, clif->pDull);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x089f, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_MAP_PING, 0x08a2, 6, clif->pTickSend);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x08a8, 5, clif->pWalkToXY);
- packet(CMSG_MOVE_TO_STORAGE, 0x08aa, 8, clif->pMoveToKafra);
- packet(CMSG_BUYINGSTORE_SELL, 0x091b, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0923, 19, clif->pWantToConnection);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x093b, 6, clif->pDropItem);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0945, -1, clif->pItemListWindowSelected);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0946, 6, clif->pReqClickBuyingStore);
- packet(CMSG_STORAGE_PASSWORD, 0x0947, 36, clif->pStoragePassword);
- packet(CMSG_HOMUNCULUS_MENU, 0x0958, 5, clif->pHomMenu);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0960, 26, clif->pFriendsListAdd);
- packet(CMSG_ITEM_PICKUP, 0x0964, 6, clif->pTakeItem);
-}
-
-// 20170524
-if (packetVersion == 20170524)
-{
- packet(CMSG_PARTY_INVITE2, 0x0364, 26, clif->pPartyInvite2);
- packet(CMSG_STORAGE_PASSWORD, 0x0368, 36, clif->pStoragePassword);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0802, 6, clif->pDropItem);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x085e, 7, clif->pActionRequest);
- packet(CMSG_BUYINGSTORE_OPEN, 0x085f, 6, clif->pReqClickBuyingStore);
- packet(CMSG_MAP_PING, 0x0860, 6, clif->pTickSend);
- packet(CMSG_ITEM_PICKUP, 0x0864, 6, clif->pTakeItem);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0866, -1, clif->pSearchStoreInfo);
- packet(CMSG_MOVE_TO_STORAGE, 0x0868, 8, clif->pMoveToKafra);
- packet(CMSG_HOMUNCULUS_MENU, 0x086d, 5, clif->pHomMenu);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0873, 19, clif->pWantToConnection);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0874, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_BUYINGSTORE_CREATE, 0x087d, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_SELL, 0x0882, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_SKILL_USE_BEING, 0x088d, 10, clif->pUseSkillToId);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0894, 8, clif->pMoveFromKafra);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x089c, 5, clif->pWalkToXY);
- packet(CMSG_SEARCHSTORE_CLICK, 0x08a1, 12, clif->pSearchStoreInfoListItemClick);
-// packet(UNKNOWN, 0x091e, 8, clif->pDull);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0923, -1, clif->pItemListWindowSelected);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0925, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0934, 5, clif->pChangeDir);
- packet(CMSG_SKILL_USE_POSITION, 0x0946, 10, clif->pUseSkillToPos);
-// packet(UNKNOWN, 0x0958, 4, clif->pDull);
- packet(CMSG_NAME_REQUEST, 0x095a, 6, clif->pGetCharNameRequest);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x095b, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0964, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0967, 26, clif->pFriendsListAdd);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0968, 6, clif->pSolveCharName);
-}
-
-// 20170531
-if (packetVersion == 20170531)
-{
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0361, 5, clif->pChangeDir);
- packet(CMSG_SKILL_USE_BEING, 0x0369, 10, clif->pUseSkillToId);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x07e4, 5, clif->pWalkToXY);
- packet(CMSG_BUYINGSTORE_SELL, 0x07ec, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_MAP_PING, 0x0819, 6, clif->pTickSend);
-// packet(UNKNOWN, 0x085b, 8, clif->pDull);
- packet(CMSG_SOLVE_CHAR_NAME, 0x085f, 6, clif->pSolveCharName);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0861, 26, clif->pFriendsListAdd);
-// packet(UNKNOWN, 0x0868, 4, clif->pDull);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0873, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SKILL_USE_POSITION, 0x0875, 10, clif->pUseSkillToPos);
- packet(CMSG_PARTY_INVITE2, 0x0878, 26, clif->pPartyInvite2);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x087b, 7, clif->pActionRequest);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0885, -1, clif->pItemListWindowSelected);
- packet(CMSG_BUYINGSTORE_CREATE, 0x088b, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x088d, 6, clif->pDropItem);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0894, 19, clif->pWantToConnection);
- packet(CMSG_STORAGE_PASSWORD, 0x089a, 36, clif->pStoragePassword);
- packet(CMSG_HOMUNCULUS_MENU, 0x089c, 5, clif->pHomMenu);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x08a2, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x08ac, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_MOVE_TO_STORAGE, 0x08ad, 8, clif->pMoveToKafra);
- packet(CMSG_NAME_REQUEST, 0x092d, 6, clif->pGetCharNameRequest);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0933, 8, clif->pMoveFromKafra);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0937, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0940, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0945, 6, clif->pReqClickBuyingStore);
- packet(CMSG_ITEM_PICKUP, 0x0963, 6, clif->pTakeItem);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0968, -1, clif->pSearchStoreInfo);
-}
-
-// 20170607
-if (packetVersion == 20170607)
-{
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0361, -1, clif->pItemListWindowSelected);
- packet(CMSG_STORAGE_PASSWORD, 0x0364, 36, clif->pStoragePassword);
- packet(CMSG_MAP_PING, 0x07e4, 6, clif->pTickSend);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x085a, 5, clif->pChangeDir);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x085e, -1, clif->pSearchStoreInfo);
- packet(CMSG_NAME_REQUEST, 0x0862, 6, clif->pGetCharNameRequest);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0863, 6, clif->pReqClickBuyingStore);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0864, 6, clif->pDropItem);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0871, 19, clif->pWantToConnection);
-// packet(UNKNOWN, 0x0873, 8, clif->pDull);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0875, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0885, 26, clif->pFriendsListAdd);
- packet(CMSG_MOVE_FROM_STORAGE, 0x088a, 8, clif->pMoveFromKafra);
- packet(CMSG_ITEM_PICKUP, 0x0897, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x089d, 8, clif->pMoveToKafra);
- packet(CMSG_SKILL_USE_BEING, 0x08a9, 10, clif->pUseSkillToId);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x08ab, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0917, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0918, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_BUYINGSTORE_SELL, 0x0919, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_PARTY_INVITE2, 0x0925, 26, clif->pPartyInvite2);
- packet(CMSG_SKILL_USE_POSITION, 0x0927, 10, clif->pUseSkillToPos);
-// packet(UNKNOWN, 0x0931, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0934, 5, clif->pWalkToXY);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0938, 7, clif->pActionRequest);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x093d, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x0942, 5, clif->pHomMenu);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0944, 6, clif->pSolveCharName);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0949, -1, clif->pReqOpenBuyingStore);
-}
-
-// 20170614
-if (packetVersion == 20170614)
-{
- packet(CMSG_MOVE_FROM_STORAGE, 0x023b, 8, clif->pMoveFromKafra);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0361, 5, clif->pWalkToXY);
- packet(CMSG_HOMUNCULUS_MENU, 0x0364, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0367, 6, clif->pDropItem);
- packet(CMSG_STORAGE_PASSWORD, 0x0437, 36, clif->pStoragePassword);
- packet(CMSG_SKILL_USE_POSITION, 0x0838, 10, clif->pUseSkillToPos);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x083c, 7, clif->pActionRequest);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0860, 6, clif->pReqClickBuyingStore);
-// packet(UNKNOWN, 0x0865, 4, clif->pDull);
- packet(CMSG_MAP_PING, 0x0866, 6, clif->pTickSend);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0867, 26, clif->pFriendsListAdd);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x086b, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x086c, -1, clif->pSearchStoreInfo);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0877, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_MOVE_TO_STORAGE, 0x0879, 8, clif->pMoveToKafra);
- packet(CMSG_SOLVE_CHAR_NAME, 0x087d, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x087e, 5, clif->pChangeDir);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0889, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_PARTY_INVITE2, 0x0899, 26, clif->pPartyInvite2);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x089d, -1, clif->pItemListWindowSelected);
- packet(CMSG_BUYINGSTORE_CREATE, 0x08a2, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_ITEM_PICKUP, 0x08ad, 6, clif->pTakeItem);
- packet(CMSG_SKILL_USE_BEING, 0x091b, 10, clif->pUseSkillToId);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0928, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_BUYINGSTORE_SELL, 0x092f, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_NAME_REQUEST, 0x0936, 6, clif->pGetCharNameRequest);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0944, 19, clif->pWantToConnection);
-// packet(UNKNOWN, 0x0957, 8, clif->pDull);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0963, 12, clif->pSearchStoreInfoListItemClick);
-}
-
-// 20170621
-if (packetVersion == 20170621)
-{
- packet(CMSG_SEARCHSTORE_CLICK, 0x0202, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_ITEM_PICKUP, 0x0361, 6, clif->pTakeItem);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0365, -1, clif->pItemListWindowSelected);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0366, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x07e4, 26, clif->pFriendsListAdd);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0802, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x085d, 5, clif->pChangeDir);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x087d, 6, clif->pDropItem);
- packet(CMSG_PARTY_INVITE2, 0x0885, 26, clif->pPartyInvite2);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0889, 8, clif->pMoveFromKafra);
- packet(CMSG_HOMUNCULUS_MENU, 0x08a8, 5, clif->pHomMenu);
-// packet(UNKNOWN, 0x0956, 8, clif->pDull);
- packet(CMSG_STORAGE_PASSWORD, 0x0957, 36, clif->pStoragePassword);
-// packet(UNKNOWN, 0x095b, 4, clif->pDull);
- packet(CMSG_MOVE_TO_STORAGE, 0x095c, 8, clif->pMoveToKafra);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0961, 19, clif->pWantToConnection);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20170628
-if (packetVersion == 20170628)
-{
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0202, 5, clif->pChangeDir);
- packet(CMSG_MAP_SERVER_CONNECT, 0x022d, 19, clif->pWantToConnection);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x023b, 26, clif->pFriendsListAdd);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0281, -1, clif->pItemListWindowSelected);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x0361, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0362, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x0363, 8, clif->pDull);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0364, 8, clif->pMoveFromKafra);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0365, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
-// packet(UNKNOWN, 0x0436, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_ITEM_PICKUP, 0x07e4, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x07ec, 8, clif->pMoveToKafra);
- packet(CMSG_PARTY_INVITE2, 0x0802, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_STORAGE_PASSWORD, 0x0863, 36, clif->pStoragePassword);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20170705
-if (packetVersion == 20170705)
-{
- packet(CMSG_STORAGE_PASSWORD, 0x0202, 36, clif->pStoragePassword);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x02c4, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_MOVE_TO_STORAGE, 0x0879, 8, clif->pMoveToKafra);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0886, 26, clif->pFriendsListAdd);
-// packet(UNKNOWN, 0x088d, 8, clif->pDull);
- packet(CMSG_PARTY_INVITE2, 0x088e, 26, clif->pPartyInvite2);
- packet(CMSG_MAP_SERVER_CONNECT, 0x089a, 19, clif->pWantToConnection);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x089d, 6, clif->pDropItem);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x091a, 5, clif->pChangeDir);
-// packet(UNKNOWN, 0x092f, 4, clif->pDull);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0930, -1, clif->pItemListWindowSelected);
- packet(CMSG_ITEM_PICKUP, 0x0932, 6, clif->pTakeItem);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0934, 8, clif->pMoveFromKafra);
- packet(CMSG_HOMUNCULUS_MENU, 0x094c, 5, clif->pHomMenu);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20170712
-if (packetVersion == 20170712)
-{
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0202, 5, clif->pChangeDir);
- packet(CMSG_MAP_SERVER_CONNECT, 0x022d, 19, clif->pWantToConnection);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x023b, 26, clif->pFriendsListAdd);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0281, -1, clif->pItemListWindowSelected);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x0361, 5, clif->pHomMenu);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0362, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x0363, 8, clif->pDull);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0364, 8, clif->pMoveFromKafra);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0365, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
-// packet(UNKNOWN, 0x0436, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_ITEM_PICKUP, 0x07e4, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x07ec, 8, clif->pMoveToKafra);
- packet(CMSG_PARTY_INVITE2, 0x0802, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_STORAGE_PASSWORD, 0x0944, 36, clif->pStoragePassword);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20170719
-if (packetVersion == 20170719)
-{
- packet(CMSG_PLAYER_CHANGE_ACT, 0x022d, 7, clif->pActionRequest);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0367, 2, clif->pReqCloseBuyingStore);
-// packet(UNKNOWN, 0x0368, 4, clif->pDull);
- packet(CMSG_HOMUNCULUS_MENU, 0x0369, 5, clif->pHomMenu);
- packet(CMSG_NAME_REQUEST, 0x07e4, 6, clif->pGetCharNameRequest);
- packet(CMSG_MAP_PING, 0x085a, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_CREATE, 0x085e, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0863, 6, clif->pReqClickBuyingStore);
- packet(CMSG_PARTY_INVITE2, 0x086e, 26, clif->pPartyInvite2);
- packet(CMSG_ITEM_PICKUP, 0x087d, 6, clif->pTakeItem);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0881, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0882, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0885, -1, clif->pItemListWindowSelected);
- packet(CMSG_SKILL_USE_POSITION, 0x0891, 10, clif->pUseSkillToPos);
- packet(CMSG_SKILL_USE_BEING, 0x0898, 10, clif->pUseSkillToId);
- packet(CMSG_STORAGE_PASSWORD, 0x089a, 36, clif->pStoragePassword);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x089d, -1, clif->pSearchStoreInfo);
- packet(CMSG_MOVE_FROM_STORAGE, 0x08a6, 8, clif->pMoveFromKafra);
- packet(CMSG_MAP_SERVER_CONNECT, 0x08a8, 19, clif->pWantToConnection);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x091b, 6, clif->pDropItem);
- packet(CMSG_SOLVE_CHAR_NAME, 0x091f, 6, clif->pSolveCharName);
- packet(CMSG_BUYINGSTORE_SELL, 0x092c, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x092e, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x092f, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x093d, 5, clif->pWalkToXY);
-// packet(UNKNOWN, 0x093e, 8, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0944, 5, clif->pChangeDir);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0946, 26, clif->pFriendsListAdd);
- packet(CMSG_MOVE_TO_STORAGE, 0x0966, 8, clif->pMoveToKafra);
-}
-
-// 20170726
-if (packetVersion == 20170726)
-{
- packet(CMSG_BUYINGSTORE_CREATE, 0x0363, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_MOVE_TO_STORAGE, 0x0364, 8, clif->pMoveToKafra);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0366, 19, clif->pWantToConnection);
- packet(CMSG_SKILL_USE_BEING, 0x0369, 10, clif->pUseSkillToId);
- packet(CMSG_PARTY_INVITE2, 0x0438, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0838, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0873, 6, clif->pReqClickBuyingStore);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0874, -1, clif->pItemListWindowSelected);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0878, 7, clif->pActionRequest);
-// packet(UNKNOWN, 0x0881, 4, clif->pDull);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0888, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x088e, 5, clif->pWalkToXY);
-// packet(UNKNOWN, 0x08a3, 8, clif->pDull);
- packet(CMSG_STORAGE_PASSWORD, 0x08a7, 36, clif->pStoragePassword);
- packet(CMSG_NAME_REQUEST, 0x08aa, 6, clif->pGetCharNameRequest);
- packet(CMSG_ITEM_PICKUP, 0x08ab, 6, clif->pTakeItem);
- packet(CMSG_MAP_PING, 0x08ac, 6, clif->pTickSend);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x091d, 26, clif->pFriendsListAdd);
- packet(CMSG_SEARCHSTORE_CLICK, 0x091e, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_HOMUNCULUS_MENU, 0x091f, 5, clif->pHomMenu);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0921, 6, clif->pSolveCharName);
- packet(CMSG_BUYINGSTORE_SELL, 0x0923, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0943, 6, clif->pDropItem);
- packet(CMSG_MOVE_FROM_STORAGE, 0x094f, 8, clif->pMoveFromKafra);
- packet(CMSG_SKILL_USE_POSITION, 0x0950, 10, clif->pUseSkillToPos);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0952, 5, clif->pChangeDir);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0954, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x095a, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0963, -1, clif->pSearchStoreInfo);
-}
-
-// 20170801
-if (packetVersion == 20170801)
-{
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x022d, 6, clif->pDropItem);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0281, 5, clif->pChangeDir);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0361, -1, clif->pItemListWindowSelected);
- packet(CMSG_HOMUNCULUS_MENU, 0x0362, 5, clif->pHomMenu);
-// packet(UNKNOWN, 0x0363, 8, clif->pDull);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0364, 8, clif->pMoveFromKafra);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0365, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_ITEM_PICKUP, 0x07e4, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x07ec, 8, clif->pMoveToKafra);
- packet(CMSG_PARTY_INVITE2, 0x0802, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_STORAGE_PASSWORD, 0x087d, 36, clif->pStoragePassword);
-// packet(UNKNOWN, 0x08a6, 4, clif->pDull);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x094f, 26, clif->pFriendsListAdd);
- packet(CMSG_MAP_SERVER_CONNECT, 0x095a, 19, clif->pWantToConnection);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20170816
-if (packetVersion == 20170816)
-{
- packet(CMSG_NAME_REQUEST, 0x022d, 6, clif->pGetCharNameRequest);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x035f, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0361, -1, clif->pItemListWindowSelected);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0362, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0438, 7, clif->pActionRequest);
- packet(CMSG_SOLVE_CHAR_NAME, 0x085a, 6, clif->pSolveCharName);
- packet(CMSG_SKILL_USE_POSITION, 0x0862, 10, clif->pUseSkillToPos);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0864, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_ITEM_PICKUP, 0x087e, 6, clif->pTakeItem);
- packet(CMSG_BUYINGSTORE_SELL, 0x0881, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_STORAGE_PASSWORD, 0x0882, 36, clif->pStoragePassword);
-// packet(UNKNOWN, 0x0884, 8, clif->pDull);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0888, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_MAP_PING, 0x0889, 6, clif->pTickSend);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x08a3, 26, clif->pFriendsListAdd);
-// packet(UNKNOWN, 0x08a7, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x08a9, 5, clif->pWalkToXY);
- packet(CMSG_HOMUNCULUS_MENU, 0x08ac, 5, clif->pHomMenu);
- packet(CMSG_SEARCHSTORE_CLICK, 0x091c, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0921, 6, clif->pReqClickBuyingStore);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0925, 8, clif->pMoveFromKafra);
- packet(CMSG_BUYINGSTORE_CREATE, 0x092c, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_PARTY_INVITE2, 0x093a, 26, clif->pPartyInvite2);
- packet(CMSG_MAP_SERVER_CONNECT, 0x093d, 19, clif->pWantToConnection);
- packet(CMSG_SKILL_USE_BEING, 0x0940, 10, clif->pUseSkillToId);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0941, 6, clif->pDropItem);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0950, 5, clif->pChangeDir);
- packet(CMSG_MOVE_TO_STORAGE, 0x0959, 8, clif->pMoveToKafra);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0960, -1, clif->pSearchStoreInfo);
-}
-
-// 20170823
-if (packetVersion == 20170823)
-{
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0281, -1, clif->pItemListWindowSelected);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_PARTY_INVITE2, 0x0361, 26, clif->pPartyInvite2);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0362, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x0363, 8, clif->pDull);
- packet(CMSG_MOVE_FROM_STORAGE, 0x0364, 8, clif->pMoveFromKafra);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0365, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0366, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
-// packet(UNKNOWN, 0x0436, 4, clif->pDull);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_ITEM_PICKUP, 0x07e4, 6, clif->pTakeItem);
- packet(CMSG_MOVE_TO_STORAGE, 0x07ec, 8, clif->pMoveToKafra);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0802, 5, clif->pChangeDir);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_MAP_SERVER_CONNECT, 0x086c, 19, clif->pWantToConnection);
- packet(CMSG_STORAGE_PASSWORD, 0x086d, 36, clif->pStoragePassword);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x08ac, 26, clif->pFriendsListAdd);
- packet(CMSG_HOMUNCULUS_MENU, 0x095b, 5, clif->pHomMenu);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20170830
-if (packetVersion == 20170830)
-{
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0281, 5, clif->pChangeDir);
- packet(CMSG_ITEM_PICKUP, 0x02c4, 6, clif->pTakeItem);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0363, 18, clif->pPartyBookingRegisterReq);
-// packet(UNKNOWN, 0x0364, 8, clif->pDull);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0860, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0865, 5, clif->pWalkToXY);
- packet(CMSG_PARTY_INVITE2, 0x086a, 26, clif->pPartyInvite2);
-// packet(UNKNOWN, 0x0875, 4, clif->pDull);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0884, 19, clif->pWantToConnection);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0885, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SKILL_USE_BEING, 0x0888, 10, clif->pUseSkillToId);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0897, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0899, 6, clif->pDropItem);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x089a, -1, clif->pItemListWindowSelected);
- packet(CMSG_MOVE_TO_STORAGE, 0x089e, 8, clif->pMoveToKafra);
- packet(CMSG_STORAGE_PASSWORD, 0x08a2, 36, clif->pStoragePassword);
- packet(CMSG_MOVE_FROM_STORAGE, 0x08a8, 8, clif->pMoveFromKafra);
- packet(CMSG_MAP_PING, 0x091e, 6, clif->pTickSend);
- packet(CMSG_HOMUNCULUS_MENU, 0x0921, 5, clif->pHomMenu);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0925, 6, clif->pReqClickBuyingStore);
- packet(CMSG_NAME_REQUEST, 0x092e, 6, clif->pGetCharNameRequest);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0939, 26, clif->pFriendsListAdd);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x093e, 7, clif->pActionRequest);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0940, 6, clif->pSolveCharName);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0942, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0943, -1, clif->pSearchStoreInfo);
- packet(CMSG_BUYINGSTORE_SELL, 0x0947, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0951, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SKILL_USE_POSITION, 0x0959, 10, clif->pUseSkillToPos);
-}
-
-// 20170906
-if (packetVersion == 20170906)
-{
-// packet(UNKNOWN, 0x0202, 4, clif->pDull);
- packet(CMSG_STORAGE_PASSWORD, 0x0281, 36, clif->pStoragePassword);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x02c4, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_MAP_PING, 0x035f, 6, clif->pTickSend);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0360, 6, clif->pReqClickBuyingStore);
- packet(CMSG_PARTY_INVITE2, 0x0366, 26, clif->pPartyInvite2);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0368, 6, clif->pSolveCharName);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0369, 7, clif->pActionRequest);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0437, 5, clif->pWalkToXY);
- packet(CMSG_SKILL_USE_POSITION, 0x0438, 10, clif->pUseSkillToPos);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0802, 5, clif->pChangeDir);
- packet(CMSG_BUYINGSTORE_SELL, 0x0811, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0815, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0817, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0819, -1, clif->pSearchStoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0835, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0838, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_SKILL_USE_BEING, 0x083c, 10, clif->pUseSkillToId);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x0860, 6, clif->pDropItem);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0866, -1, clif->pItemListWindowSelected);
-// packet(UNKNOWN, 0x086c, 8, clif->pDull);
- packet(CMSG_MOVE_TO_STORAGE, 0x087b, 8, clif->pMoveToKafra);
- packet(CMSG_MOVE_FROM_STORAGE, 0x08a2, 8, clif->pMoveFromKafra);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x08a3, 26, clif->pFriendsListAdd);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x08a7, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_ITEM_PICKUP, 0x091a, 6, clif->pTakeItem);
- packet(CMSG_HOMUNCULUS_MENU, 0x091e, 5, clif->pHomMenu);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0953, 19, clif->pWantToConnection);
- packet(CMSG_NAME_REQUEST, 0x096a, 6, clif->pGetCharNameRequest);
-}
-
-// 20170913
-if (packetVersion == 20170913)
-{
- packet(CMSG_NAME_REQUEST, 0x0281, 6, clif->pGetCharNameRequest);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x035f, 26, clif->pFriendsListAdd);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x0437, -1, clif->pSearchStoreInfo);
- packet(CMSG_MOVE_FROM_STORAGE, 0x07e4, 8, clif->pMoveFromKafra);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x0817, 7, clif->pActionRequest);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0835, 19, clif->pWantToConnection);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x085a, 2, clif->pReqCloseBuyingStore);
- packet(CMSG_ITEM_PICKUP, 0x0860, 6, clif->pTakeItem);
- packet(CMSG_PARTY_INVITE2, 0x0865, 26, clif->pPartyInvite2);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0866, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_HOMUNCULUS_MENU, 0x088c, 5, clif->pHomMenu);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0890, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_MOVE_TO_STORAGE, 0x0891, 8, clif->pMoveToKafra);
- packet(CMSG_STORAGE_PASSWORD, 0x0892, 36, clif->pStoragePassword);
- packet(CMSG_BUYINGSTORE_OPEN, 0x08a6, 6, clif->pReqClickBuyingStore);
-// packet(UNKNOWN, 0x08a7, 4, clif->pDull);
- packet(CMSG_SKILL_USE_BEING, 0x08aa, 10, clif->pUseSkillToId);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x08ab, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x08ac, 5, clif->pChangeDir);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x08ad, -1, clif->pItemListWindowSelected);
- packet(CMSG_MAP_PING, 0x091b, 6, clif->pTickSend);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x091d, 6, clif->pDropItem);
-// packet(UNKNOWN, 0x091e, 8, clif->pDull);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x0920, 2, clif->pSearchStoreInfoNextPage);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x0923, 5, clif->pWalkToXY);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0925, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_BUYINGSTORE_SELL, 0x0927, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_SKILL_USE_POSITION, 0x095a, 10, clif->pUseSkillToPos);
- packet(CMSG_SOLVE_CHAR_NAME, 0x095c, 6, clif->pSolveCharName);
-}
-
-// 20170920
-if (packetVersion == 20170920)
-{
- packet(CMSG_ITEM_PICKUP, 0x0369, 6, clif->pTakeItem);
- packet(CMSG_ITEM_LIST_WINDOW_SELECT, 0x0436, -1, clif->pItemListWindowSelected);
- packet(CMSG_MOVE_FROM_STORAGE, 0x07ec, 8, clif->pMoveFromKafra);
- packet(CMSG_PLAYER_CHANGE_DEST, 0x085a, 5, clif->pWalkToXY);
- packet(CMSG_FRIENDS_ADD_PLAYER, 0x0861, 26, clif->pFriendsListAdd);
- packet(CMSG_SKILL_USE_BEING, 0x0862, 10, clif->pUseSkillToId);
- packet(CMSG_STORAGE_PASSWORD, 0x0864, 36, clif->pStoragePassword);
- packet(CMSG_BUYINGSTORE_CREATE, 0x0865, -1, clif->pReqOpenBuyingStore);
- packet(CMSG_PARTY_INVITE2, 0x086a, 26, clif->pPartyInvite2);
- packet(CMSG_PLAYER_INVENTORY_DROP, 0x086c, 6, clif->pDropItem);
- packet(CMSG_BUYINGSTORE_CLOSE, 0x0874, 2, clif->pReqCloseBuyingStore);
-// packet(UNKNOWN, 0x0875, 4, clif->pDull);
- packet(CMSG_NAME_REQUEST, 0x0889, 6, clif->pGetCharNameRequest);
- packet(CMSG_MAP_PING, 0x088e, 6, clif->pTickSend);
- packet(CMSG_PLAYER_CHANGE_ACT, 0x089b, 7, clif->pActionRequest);
- packet(CMSG_SKILL_USE_POSITION, 0x0919, 10, clif->pUseSkillToPos);
-// packet(UNKNOWN, 0x091e, 8, clif->pDull);
- packet(CMSG_SOLVE_CHAR_NAME, 0x0921, 6, clif->pSolveCharName);
- packet(CMSG_MAP_SERVER_CONNECT, 0x0923, 19, clif->pWantToConnection);
- packet(CMSG_MOVE_TO_STORAGE, 0x0926, 8, clif->pMoveToKafra);
- packet(CMSG_BUYINGSTORE_SELL, 0x092e, -1, clif->pReqTradeBuyingStore);
- packet(CMSG_SEARCHSTORE_CLICK, 0x0937, 12, clif->pSearchStoreInfoListItemClick);
- packet(CMSG_PLAYER_CHANGE_DIR, 0x0939, 5, clif->pChangeDir);
- packet(CMSG_BOOKING_REGISTER_REQ, 0x0945, 18, clif->pPartyBookingRegisterReq);
- packet(CMSG_SEARCHSTORE_SEARCH, 0x094c, -1, clif->pSearchStoreInfo);
- packet(CMSG_HOMUNCULUS_MENU, 0x095d, 5, clif->pHomMenu);
- packet(CMSG_BUYINGSTORE_OPEN, 0x0961, 6, clif->pReqClickBuyingStore);
- packet(CMSG_SKILL_USE_POSITION_MORE, 0x0966, 90, clif->pUseSkillToPosMoreInfo);
- packet(CMSG_SEARCHSTORE_NEXT_PAGE, 0x096a, 2, clif->pSearchStoreInfoNextPage);
-}
-
-#endif
diff --git a/src/net/eathena/partyhandler.cpp b/src/net/eathena/partyhandler.cpp
deleted file mode 100644
index 07482dce7..000000000
--- a/src/net/eathena/partyhandler.cpp
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 Lloyd Bryant <lloyd_bryant@netzero.net>
- * 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 "net/eathena/partyhandler.h"
-
-#include "actormanager.h"
-#include "notifymanager.h"
-#include "party.h"
-
-#include "being/localplayer.h"
-
-#include "enums/resources/notifytypes.h"
-
-#include "net/ea/partyrecv.h"
-
-#include "net/eathena/messageout.h"
-#include "net/eathena/partyrecv.h"
-#include "net/eathena/protocolout.h"
-
-#include "debug.h"
-
-extern int packetVersion;
-
-namespace EAthena
-{
-
-PartyHandler::PartyHandler() :
- Ea::PartyHandler()
-{
- partyHandler = this;
-}
-
-PartyHandler::~PartyHandler()
-{
- partyHandler = nullptr;
-}
-
-void PartyHandler::create(const std::string &name) const
-{
- createOutPacket(CMSG_PARTY_CREATE);
- outMsg.writeString(name.substr(0, 23), 24, "party name");
-}
-
-void PartyHandler::invite(const std::string &name) const
-{
- if (actorManager == nullptr)
- return;
- const Being *const being = actorManager->findBeingByName(
- name, ActorType::Player);
- if (being != nullptr)
- {
- createOutPacket(CMSG_PARTY_INVITE);
- outMsg.writeBeingId(being->getId(), "account id");
- }
- else
- {
- if (packetVersion < 20070227)
- return;
- createOutPacket(CMSG_PARTY_INVITE2);
- outMsg.writeString(name, 24, "nick");
- }
-}
-
-void PartyHandler::inviteResponse(const int partyId,
- const bool accept) const
-{
- if (localPlayer != nullptr)
- {
- createOutPacket(CMSG_PARTY_INVITED2);
- outMsg.writeInt32(partyId, "party id");
- outMsg.writeInt8(CAST_S8(accept ? 1 : 0), "accept");
- }
-}
-
-void PartyHandler::leave() const
-{
- createOutPacket(CMSG_PARTY_LEAVE);
-}
-
-void PartyHandler::kick(const Being *const being) const
-{
- if (being != nullptr)
- {
- createOutPacket(CMSG_PARTY_KICK);
- outMsg.writeBeingId(being->getId(), "account id");
- outMsg.writeString(being->getName(), 24, "player name");
- }
-}
-
-void PartyHandler::kick(const std::string &name) const
-{
- if (Ea::taParty == nullptr)
- return;
-
- const PartyMember *const m = Ea::taParty->getMember(name);
- if (m == nullptr)
- {
- NotifyManager::notify(NotifyTypes::PARTY_USER_NOT_IN_PARTY, name);
- return;
- }
-
- createOutPacket(CMSG_PARTY_KICK);
- outMsg.writeBeingId(m->getID(), "account id");
- outMsg.writeString(name, 24, "player name");
-}
-
-void PartyHandler::chat(const std::string &text) const
-{
- createOutPacket(CMSG_PARTY_MESSAGE);
- const std::string mes = std::string(localPlayer->getName()).append(
- " : ").append(text);
- if (packetVersion >= 20151001)
- {
- outMsg.writeInt16(CAST_S16(mes.length() + 4), "len");
- outMsg.writeString(mes, CAST_S32(mes.length()), "nick : message");
- }
- else
- {
- outMsg.writeInt16(CAST_S16(mes.length() + 4 + 1), "len");
- outMsg.writeString(mes, CAST_S32(mes.length()), "nick : message");
- outMsg.writeInt8(0, "null char");
- }
-}
-
-// +++ must be 3 types item, exp, pickup
-void PartyHandler::setShareExperience(const PartyShareT share) const
-{
- if (share == PartyShare::NOT_POSSIBLE)
- return;
-
- createOutPacket(CMSG_PARTY_SETTINGS);
- if (packetVersion >= 20090603)
- {
- outMsg.writeInt32(CAST_S32(share), "share exp");
- outMsg.writeInt16(CAST_S16(Ea::PartyRecv::mShareItems),
- "share items");
- }
- else
- {
- outMsg.writeInt32(CAST_S32(share), "share exp");
- }
-}
-
-// +++ must be 3 types item, exp, pickup
-void PartyHandler::setShareItems(const PartyShareT share) const
-{
- if (share == PartyShare::NOT_POSSIBLE)
- return;
-
- createOutPacket(CMSG_PARTY_SETTINGS);
- if (packetVersion >= 20090603)
- {
- outMsg.writeInt32(CAST_S32(Ea::PartyRecv::mShareExp),
- "share exp");
- outMsg.writeInt16(CAST_S16(share), "share items");
- }
-}
-
-void PartyHandler::changeLeader(const std::string &name) const
-{
- const Being *const being = actorManager->findBeingByName(
- name, ActorType::Player);
- if (being == nullptr)
- return;
- createOutPacket(CMSG_PARTY_CHANGE_LEADER);
- outMsg.writeBeingId(being->getId(), "account id");
-}
-
-void PartyHandler::allowInvite(const bool allow) const
-{
- createOutPacket(CMSG_PARTY_ALLOW_INVITES);
- outMsg.writeInt8(CAST_S8(allow ? 1 : 0), "allow");
-}
-
-PartyShareT PartyHandler::getShareAutoItems() const
-{
- return PartyRecv::mShareAutoItems;
-}
-
-void PartyHandler::setShareAutoItems(const PartyShareT share) const
-{
- PartyRecv::mShareAutoItems = share;
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/partyhandler.h b/src/net/eathena/partyhandler.h
deleted file mode 100644
index 4b87f09fd..000000000
--- a/src/net/eathena/partyhandler.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 Lloyd Bryant <lloyd_bryant@netzero.net>
- * 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 NET_EATHENA_PARTYHANDLER_H
-#define NET_EATHENA_PARTYHANDLER_H
-
-#include "net/ea/partyhandler.h"
-
-namespace EAthena
-{
-
-class PartyHandler final : public Ea::PartyHandler
-{
- public:
- PartyHandler();
-
- A_DELETE_COPY(PartyHandler)
-
- ~PartyHandler();
-
- void create(const std::string &name) const override final;
-
- void invite(const std::string &name) const override final;
-
- void inviteResponse(const int partyId,
- const bool accept) const override final;
-
- void leave() const override final;
-
- void kick(const Being *const being) const override final;
-
- void kick(const std::string &name) const override final;
-
- void chat(const std::string &text) const override final;
-
- void setShareExperience(const PartyShareT share) const override final;
-
- void setShareItems(const PartyShareT share) const override final;
-
- void changeLeader(const std::string &name) const override final;
-
- void allowInvite(const bool allow) const override final;
-
- void setShareAutoItems(const PartyShareT share) const override final;
-
- PartyShareT getShareAutoItems() const override final A_WARN_UNUSED;
-};
-
-} // namespace EAthena
-
-#endif // NET_EATHENA_PARTYHANDLER_H
diff --git a/src/net/eathena/partyrecv.cpp b/src/net/eathena/partyrecv.cpp
deleted file mode 100644
index 9ce0dbdce..000000000
--- a/src/net/eathena/partyrecv.cpp
+++ /dev/null
@@ -1,422 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 Lloyd Bryant <lloyd_bryant@netzero.net>
- * 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 "net/eathena/partyrecv.h"
-
-#include "notifymanager.h"
-#include "party.h"
-
-#include "being/localplayer.h"
-
-#include "enums/resources/notifytypes.h"
-
-#include "gui/windows/chatwindow.h"
-#include "gui/windows/socialwindow.h"
-
-#include "gui/widgets/tabs/chat/partytab.h"
-
-#include "net/messagein.h"
-
-#include "net/ea/partyrecv.h"
-
-#include "utils/checkutils.h"
-#include "utils/foreach.h"
-
-#include "debug.h"
-
-namespace EAthena
-{
-
-namespace PartyRecv
-{
- PartyShareT mShareAutoItems = PartyShare::UNKNOWN;
-} // namespace PartyRecv
-
-void PartyRecv::processPartyInvitationStats(Net::MessageIn &msg)
-{
- // +++ for now server allow only switch this option but not using it.
- msg.readUInt8("allow party");
-}
-
-void PartyRecv::processPartyMemberInfo(Net::MessageIn &msg)
-{
- const BeingId id = msg.readBeingId("account id");
- const bool leader = msg.readInt32("leader") == 0U;
- int level = 0;
- if (msg.getVersion() >= 20170502)
- {
- msg.readInt16("class");
- level = msg.readInt16("level");
- }
- const int x = msg.readInt16("x");
- const int y = msg.readInt16("y");
- const bool online = msg.readInt8("online") == 0U;
- msg.readString(24, "party name");
- const std::string nick = msg.readString(24, "player name");
- const std::string map = msg.readString(16, "map name");
- msg.readInt8("pickup item share (&1)");
- msg.readInt8("get item share (&2)");
-
- if (Ea::taParty == nullptr)
- return;
-
- PartyMember *const member = Ea::taParty->addMember(id, nick);
- if (member != nullptr)
- {
- if ((partyTab != nullptr) && member->getOnline() != online)
- partyTab->showOnline(nick, fromBool(online, Online));
- member->setLeader(leader);
- member->setOnline(online);
- member->setMap(map);
- member->setX(x);
- member->setY(y);
- if (level != 0)
- member->setLevel(level);
- }
-}
-
-void PartyRecv::processPartyMemberJobLevel(Net::MessageIn &msg)
-{
- const BeingId id = msg.readBeingId("account id");
- msg.readInt16("class");
- const int level = msg.readInt16("level");
-
- if (Ea::taParty == nullptr)
- return;
-
- PartyMember *const member = Ea::taParty->getMember(id);
- if (member != nullptr)
- {
- member->setOnline(true);
- if (level != 0)
- member->setLevel(level);
- }
- else
- {
- reportAlways("processPartyMemberJobLevel: party member not exists.");
- }
-}
-
-void PartyRecv::processPartySettings(Net::MessageIn &msg)
-{
- if (partyTab == nullptr)
- {
- if (chatWindow == nullptr)
- return;
-
- Ea::PartyRecv::createTab();
- }
-
- const PartyShareT exp = static_cast<PartyShareT>(
- msg.readInt32("party exp"));
- Ea::PartyRecv::processPartyExpSettingsContinue(msg, exp);
- if (msg.getVersion() >= 20090603)
- {
- const PartyShareT item = static_cast<PartyShareT>(
- msg.readInt8("pickup item share (&1)"));
- Ea::PartyRecv::processPartyItemSettingsContinue(msg, item);
- const PartyShareT autoItem = static_cast<PartyShareT>(
- msg.readInt8("get auto item share (&2)"));
- processPartyAutoItemSettingsContinue(msg, autoItem);
- }
-}
-
-void PartyRecv::processPartyInfo(Net::MessageIn &msg)
-{
- bool isOldParty = false;
- std::set<std::string> names;
- std::set<std::string> onlineNames;
- if (Ea::taParty == nullptr)
- {
- logger->log1("error: party empty in SMSG_PARTY_INFO");
- Ea::taParty = Party::getParty(1);
- }
- if (partyTab == nullptr)
- Ea::PartyRecv::createTab();
-
- if (Ea::taParty != nullptr)
- {
- if (Ea::taParty->getNumberOfElements() > 1)
- {
- isOldParty = true;
- Ea::taParty->getNamesSet(names);
- const Party::MemberList *const members = Ea::taParty->getMembers();
- FOR_EACHP (Party::MemberList::const_iterator, it, members)
- {
- if ((*it)->getOnline())
- onlineNames.insert((*it)->getName());
- }
- if (localPlayer != nullptr)
- onlineNames.insert(localPlayer->getName());
- }
- }
-
- if (localPlayer == nullptr)
- logger->log1("error: localPlayer==0 in SMSG_PARTY_INFO");
-
- if (Ea::taParty != nullptr)
- Ea::taParty->clearMembers();
-
- const int length = msg.readInt16("len");
- if (Ea::taParty != nullptr)
- {
- const std::string name = msg.readString(24, "party name");
- Ea::taParty->setName(name);
- }
- else
- {
- msg.readString(24, "party name");
- }
-
- int partySize = 0;
- int offset = 0;
- if (msg.getVersion() >= 20170502)
- {
- partySize = 50;
- offset = 28 + 6;
- }
- else
- {
- partySize = 46;
- offset = 28;
- }
-
- const int count = (length - offset) / partySize;
- if (localPlayer != nullptr &&
- Ea::taParty != nullptr)
- {
- localPlayer->setParty(Ea::taParty);
- localPlayer->setPartyName(Ea::taParty->getName());
- }
-
- for (int i = 0; i < count; i++)
- {
- const BeingId id = msg.readBeingId("account id");
- std::string nick = msg.readString(24, "nick");
- std::string map = msg.readString(16, "map name");
- const bool leader = msg.readUInt8("leader") == 0U;
- const bool online = msg.readUInt8("online") == 0U;
- int level = 0;
- if (msg.getVersion() >= 20170502)
- {
- msg.readInt16("class");
- level = msg.readInt16("level");
- }
-
- if (Ea::taParty != nullptr)
- {
- bool joined(false);
-
- if (isOldParty)
- {
- if (names.find(nick) == names.end())
- {
- NotifyManager::notify(NotifyTypes::PARTY_USER_JOINED,
- nick);
- joined = true;
- }
- }
- PartyMember *const member = Ea::taParty->addMember(id, nick);
- if (member != nullptr)
- {
- if (!joined && (partyTab != nullptr))
- {
- if (!names.empty() && ((onlineNames.find(nick)
- == onlineNames.end() && online)
- || (onlineNames.find(nick) != onlineNames.end()
- && !online)))
- {
- partyTab->showOnline(nick, fromBool(online, Online));
- }
- }
- member->setLeader(leader);
- member->setOnline(online);
- member->setMap(map);
- if (level != 0)
- member->setLevel(level);
- }
- }
- }
-
- if (msg.getVersion() >= 20170502)
- {
- msg.readInt8("pickup item share (&1)");
- msg.readInt8("get item share (&2)");
- msg.readInt32("unknown");
- }
-
- if (Ea::taParty != nullptr)
- Ea::taParty->sort();
-
- if ((localPlayer != nullptr) && (Ea::taParty != nullptr))
- {
- localPlayer->setParty(Ea::taParty);
- localPlayer->setPartyName(Ea::taParty->getName());
- if (socialWindow != nullptr)
- socialWindow->updateParty();
- }
-}
-
-void PartyRecv::processPartyMessage(Net::MessageIn &msg)
-{
- const int msgLength = msg.readInt16("len") - 8;
- if (msgLength <= 0)
- return;
-
- const BeingId id = msg.readBeingId("id");
- std::string chatMsg = msg.readString(msgLength, "message");
-
- const size_t pos = chatMsg.find(" : ", 0);
- if (pos != std::string::npos)
- chatMsg.erase(0, pos + 3);
-
- if ((Ea::taParty != nullptr) && (partyTab != nullptr))
- {
- const PartyMember *const member = Ea::taParty->getMember(id);
- if (member != nullptr)
- {
- partyTab->chatLog(member->getName(), chatMsg);
- }
- else
- {
- NotifyManager::notify(NotifyTypes::PARTY_UNKNOWN_USER_MSG,
- chatMsg);
- }
- }
-}
-
-void PartyRecv::processPartyInviteResponse(Net::MessageIn &msg)
-{
- if (partyTab == nullptr)
- return;
-
- const std::string nick = msg.readString(24, "nick");
-
- switch (msg.readInt32("result"))
- {
- case 0:
- NotifyManager::notify(NotifyTypes::PARTY_INVITE_ALREADY_MEMBER,
- nick);
- break;
- case 1:
- NotifyManager::notify(NotifyTypes::PARTY_INVITE_REFUSED, nick);
- break;
- case 2:
- NotifyManager::notify(NotifyTypes::PARTY_INVITE_DONE, nick);
- break;
- case 3:
- NotifyManager::notify(NotifyTypes::PARTY_INVITE_PARTY_FULL,
- nick);
- break;
- case 4:
- NotifyManager::notify(NotifyTypes::PARTY_INVITE_PARTY_SAME_ACCOUNT,
- nick);
- break;
- case 5:
- NotifyManager::notify(
- NotifyTypes::PARTY_INVITE_PARTY_BLOCKED_INVITE,
- nick);
- break;
- case 7:
- NotifyManager::notify(NotifyTypes::PARTY_INVITE_PARTY_NOT_ONLINE,
- nick);
- break;
- default:
- NotifyManager::notify(NotifyTypes::PARTY_INVITE_ERROR, nick);
- break;
- }
-}
-
-void PartyRecv::processPartyItemPickup(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- // +++ probably need add option to show pickup notifications
- // in party tab
- msg.readBeingId("account id");
- msg.readInt16("item id");
- msg.readUInt8("identify");
- msg.readUInt8("attribute");
- msg.readUInt8("refine");
- for (int f = 0; f < maxCards; f++)
- msg.readUInt16("card");
- msg.readInt16("equip location");
- msg.readUInt8("item type");
- // for color can be used ItemColorManager
-}
-
-void PartyRecv::processPartyLeader(Net::MessageIn &msg)
-{
- PartyMember *const oldMember = Ea::taParty->getMember(
- msg.readBeingId("old leder id"));
- PartyMember *const newMember = Ea::taParty->getMember(
- msg.readBeingId("new leder id"));
- if (oldMember != nullptr)
- oldMember->setLeader(false);
- if (newMember != nullptr)
- newMember->setLeader(true);
-}
-
-void PartyRecv::processPartyInvited(Net::MessageIn &msg)
-{
- if (socialWindow == nullptr)
- {
- msg.readInt32("party id");
- msg.readString(24, "party name");
- return;
- }
- const int id = msg.readInt32("party id");
- const std::string partyName = msg.readString(24, "party name");
-
- if (socialWindow != nullptr)
- socialWindow->showPartyInvite(partyName, std::string(), id);
-}
-
-void PartyRecv::processPartyAutoItemSettingsContinue(Net::MessageIn &msg,
- const PartyShareT item)
-{
- switch (item)
- {
- case PartyShare::YES:
- if (mShareAutoItems == PartyShare::YES)
- break;
- mShareAutoItems = PartyShare::YES;
- NotifyManager::notify(NotifyTypes::PARTY_ITEM_SHARE_ON);
- break;
- case PartyShare::NO:
- if (mShareAutoItems == PartyShare::NO)
- break;
- mShareAutoItems = PartyShare::NO;
- NotifyManager::notify(NotifyTypes::PARTY_ITEM_SHARE_OFF);
- break;
- case PartyShare::NOT_POSSIBLE:
- if (mShareAutoItems == PartyShare::NOT_POSSIBLE)
- break;
- mShareAutoItems = PartyShare::NOT_POSSIBLE;
- NotifyManager::notify(NotifyTypes::PARTY_ITEM_SHARE_ERROR);
- break;
- default:
- case PartyShare::UNKNOWN:
- UNIMPLEMENTEDPACKETFIELD(CAST_S32(item));
- break;
- }
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/partyrecv.h b/src/net/eathena/partyrecv.h
deleted file mode 100644
index d89413297..000000000
--- a/src/net/eathena/partyrecv.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 Lloyd Bryant <lloyd_bryant@netzero.net>
- * 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 NET_EATHENA_PARTYRECV_H
-#define NET_EATHENA_PARTYRECV_H
-
-#include "enums/net/partyshare.h"
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-namespace EAthena
-{
- namespace PartyRecv
- {
- extern PartyShareT mShareAutoItems;
-
- void processPartySettings(Net::MessageIn &msg);
- void processPartyInvitationStats(Net::MessageIn &msg);
- void processPartyMemberInfo(Net::MessageIn &msg);
- void processPartyInfo(Net::MessageIn &msg);
- void processPartyMessage(Net::MessageIn &msg);
- void processPartyInviteResponse(Net::MessageIn &msg);
- void processPartyItemPickup(Net::MessageIn &msg);
- void processPartyLeader(Net::MessageIn &msg);
- void processPartyInvited(Net::MessageIn &msg);
- void processPartyMemberJobLevel(Net::MessageIn &msg);
-
- void processPartyAutoItemSettingsContinue(Net::MessageIn &msg,
- const PartyShareT item);
- } // namespace PartyRecv
-} // namespace EAthena
-
-#endif // NET_EATHENA_PARTYRECV_H
diff --git a/src/net/eathena/pethandler.cpp b/src/net/eathena/pethandler.cpp
deleted file mode 100644
index 28624e285..000000000
--- a/src/net/eathena/pethandler.cpp
+++ /dev/null
@@ -1,126 +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 "net/eathena/pethandler.h"
-
-#include "being/playerinfo.h"
-
-#include "net/serverfeatures.h"
-
-#include "net/eathena/messageout.h"
-#include "net/eathena/protocolout.h"
-
-#include "debug.h"
-
-namespace EAthena
-{
-
-PetHandler::PetHandler()
-{
- petHandler = this;
-}
-
-PetHandler::~PetHandler()
-{
- petHandler = nullptr;
-}
-
-void PetHandler::move(const int x,
- const int y) const
-{
- if (!serverFeatures->haveMovePet())
- return;
- createOutPacket(CMSG_PET_MOVE_TO);
- outMsg.writeInt32(0, "pet id");
- outMsg.writeInt16(CAST_S16(x), "x");
- outMsg.writeInt16(CAST_S16(y), "y");
-}
-
-void PetHandler::emote(const uint8_t emoteId)
-{
- createOutPacket(CMSG_PET_EMOTE);
- outMsg.writeInt8(emoteId, "emote id");
-}
-
-void PetHandler::catchPet(const Being *const being) const
-{
- if (being == nullptr)
- return;
-
- createOutPacket(CMSG_PET_CATCH);
- outMsg.writeBeingId(being->getId(), "monster id");
-}
-
-void PetHandler::sendPetMessage(const int data) const
-{
- createOutPacket(CMSG_PET_SEND_MESSAGE);
- outMsg.writeInt32(data, "param");
-}
-
-void PetHandler::setName(const std::string &name) const
-{
- createOutPacket(CMSG_PET_SET_NAME);
- outMsg.writeString(name, 24, "name");
-}
-
-void PetHandler::requestStatus() const
-{
- createOutPacket(CMSG_PET_MENU_ACTION);
- outMsg.writeInt8(0, "action");
-}
-
-void PetHandler::feed() const
-{
- createOutPacket(CMSG_PET_MENU_ACTION);
- outMsg.writeInt8(1, "action");
-}
-
-void PetHandler::dropLoot() const
-{
- createOutPacket(CMSG_PET_MENU_ACTION);
- outMsg.writeInt8(2, "action"); // performance
-}
-
-void PetHandler::returnToEgg() const
-{
- createOutPacket(CMSG_PET_MENU_ACTION);
- outMsg.writeInt8(3, "action");
- PlayerInfo::setPet(nullptr);
-}
-
-void PetHandler::unequip() const
-{
- createOutPacket(CMSG_PET_MENU_ACTION);
- outMsg.writeInt8(4, "action");
-}
-
-void PetHandler::setDirection(const unsigned char type) const
-{
- if (!serverFeatures->haveMovePet())
- return;
- createOutPacket(CMSG_PET_DIRECTION);
- outMsg.writeInt32(0, "pet id");
- outMsg.writeInt8(0, "head direction");
- outMsg.writeInt8(0, "unused");
- outMsg.writeInt8(MessageOut::toServerDirection(type),
- "pet direction");
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/pethandler.h b/src/net/eathena/pethandler.h
deleted file mode 100644
index 9785ade7d..000000000
--- a/src/net/eathena/pethandler.h
+++ /dev/null
@@ -1,64 +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 NET_EATHENA_PETHANDLER_H
-#define NET_EATHENA_PETHANDLER_H
-
-#include "net/pethandler.h"
-
-namespace EAthena
-{
-
-class PetHandler final : public Net::PetHandler
-{
- public:
- PetHandler();
-
- A_DELETE_COPY(PetHandler)
-
- ~PetHandler();
-
- void move(const int x,
- const int y) const override final;
-
- void emote(const uint8_t emoteId) override final;
-
- void catchPet(const Being *const being) const override final;
-
- void sendPetMessage(const int data) const override final;
-
- void setName(const std::string &name) const override final;
-
- void requestStatus() const override final;
-
- void feed() const override final;
-
- void dropLoot() const override final;
-
- void returnToEgg() const override final;
-
- void unequip() const override final;
-
- void setDirection(const unsigned char type) const override final;
-};
-
-} // namespace EAthena
-
-#endif // NET_EATHENA_PETHANDLER_H
diff --git a/src/net/eathena/petrecv.cpp b/src/net/eathena/petrecv.cpp
deleted file mode 100644
index f2cf65a28..000000000
--- a/src/net/eathena/petrecv.cpp
+++ /dev/null
@@ -1,181 +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 "net/eathena/petrecv.h"
-
-#include "actormanager.h"
-#include "notifymanager.h"
-
-#include "being/petinfo.h"
-#include "being/playerinfo.h"
-
-#include "const/net/inventory.h"
-
-#include "enums/resources/notifytypes.h"
-
-#include "gui/windows/eggselectiondialog.h"
-
-#include "gui/widgets/createwidget.h"
-
-#include "net/inventoryhandler.h"
-#include "net/messagein.h"
-
-#include "net/eathena/menu.h"
-
-#include "debug.h"
-
-namespace EAthena
-{
-
-void PetRecv::processPetMessage(Net::MessageIn &msg)
-{
- // techinally this is hercules pet emote,
- // but it may send also hungry level on connect
- // for both exists other packets.
- msg.readBeingId("pet id");
- msg.readInt32("param");
-}
-
-void PetRecv::processPetRoulette(Net::MessageIn &msg)
-{
- const uint8_t data = msg.readUInt8("data");
- switch (data)
- {
- case 0:
- NotifyManager::notify(NotifyTypes::PET_CATCH_FAILED);
- break;
- case 1:
- NotifyManager::notify(NotifyTypes::PET_CATCH_SUCCESS);
- break;
- default:
- NotifyManager::notify(NotifyTypes::PET_CATCH_UNKNOWN, data);
- break;
- }
-}
-
-void PetRecv::processEggsList(Net::MessageIn &msg)
-{
- const int count = (msg.readInt16("len") - 4) / 2;
- const Inventory *const inv = PlayerInfo::getInventory();
- if (inv == nullptr)
- return;
- menu = MenuType::Eggs;
-
- if (count == 1)
- {
- const int index = msg.readInt16("index") - INVENTORY_OFFSET;
- const Item *const item = inv->getItem(index);
- inventoryHandler->selectEgg(item);
- return;
- }
- SellDialog *const dialog = CREATEWIDGETR0(EggSelectionDialog);
-
- for (int f = 0; f < count; f ++)
- {
- const int index = msg.readInt16("index") - INVENTORY_OFFSET;
- const Item *const item = inv->getItem(index);
-
- if (item != nullptr)
- dialog->addItem(item, 0);
- }
-}
-
-void PetRecv::processPetData(Net::MessageIn &msg)
-{
- const int cmd = msg.readUInt8("type");
- const BeingId id = msg.readBeingId("pet id");
- Being *const dstBeing = actorManager->findBeing(id);
- const int data = msg.readInt32("data");
- if (cmd == 0) // pre init
- {
- PetInfo *const info = new PetInfo;
- info->id = id;
- PlayerInfo::setPet(info);
- PlayerInfo::setPetBeing(dstBeing);
- return;
- }
- PetInfo *const info = PlayerInfo::getPet();
- if (info == nullptr)
- return;
- switch (cmd)
- {
- case 1: // intimacy
- info->intimacy = data;
- break;
- case 2: // hunger
- info->hungry = data;
- break;
- case 3: // accesory
- info->equip = data;
- break;
- case 4: // performance
- info->performance = data;
- break;
- case 5: // hair style
- info->hairStyle = data;
- break;
- default:
- break;
- }
-}
-
-void PetRecv::processPetStatus(Net::MessageIn &msg)
-{
- const std::string name = msg.readString(24, "pet name");
- msg.readUInt8("rename flag");
- const int level = msg.readInt16("level");
- const int hungry = msg.readInt16("hungry");
- const int intimacy = msg.readInt16("intimacy");
- const int equip = msg.readInt16("equip");
-
-// Being *const being = PlayerInfo::getPetBeing();
-// if (being)
-// being->setLevel(level);
-
- PetInfo *const info = PlayerInfo::getPet();
- if (info == nullptr)
- return;
- info->name = name;
- info->level = level;
- info->hungry = hungry;
- info->intimacy = intimacy;
- info->equip = equip;
- if (msg.getVersion() >= 20081126)
- info->race = msg.readInt16("class");
- else
- info->race = 0;
-}
-
-void PetRecv::processPetFood(Net::MessageIn &msg)
-{
- const int result = msg.readUInt8("result");
- msg.readInt16("food id");
- if (result != 0)
- NotifyManager::notify(NotifyTypes::PET_FEED_OK);
- else
- NotifyManager::notify(NotifyTypes::PET_FEED_ERROR);
-}
-
-void PetRecv::processPetCatchProcess(Net::MessageIn &msg A_UNUSED)
-{
- NotifyManager::notify(NotifyTypes::PET_CATCH_PROCESS);
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/petrecv.h b/src/net/eathena/petrecv.h
deleted file mode 100644
index a520ca107..000000000
--- a/src/net/eathena/petrecv.h
+++ /dev/null
@@ -1,43 +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 NET_EATHENA_PETRECV_H
-#define NET_EATHENA_PETRECV_H
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-namespace EAthena
-{
- namespace PetRecv
- {
- void processPetMessage(Net::MessageIn &msg);
- void processPetRoulette(Net::MessageIn &msg);
- void processEggsList(Net::MessageIn &msg);
- void processPetData(Net::MessageIn &msg);
- void processPetStatus(Net::MessageIn &msg);
- void processPetFood(Net::MessageIn &msg);
- void processPetCatchProcess(Net::MessageIn &msg);
- } // namespace PetRecv
-} // namespace EAthena
-
-#endif // NET_EATHENA_PETRECV_H
diff --git a/src/net/eathena/playerhandler.cpp b/src/net/eathena/playerhandler.cpp
deleted file mode 100644
index a16984cfa..000000000
--- a/src/net/eathena/playerhandler.cpp
+++ /dev/null
@@ -1,718 +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 "net/eathena/playerhandler.h"
-
-#include "notifymanager.h"
-#include "party.h"
-
-#include "being/localplayer.h"
-#include "being/playerinfo.h"
-
-#include "const/net/nostat.h"
-
-#include "enums/resources/notifytypes.h"
-
-#include "gui/windows/skilldialog.h"
-#include "gui/windows/statuswindow.h"
-
-#include "net/ea/inventoryhandler.h"
-
-#include "net/eathena/messageout.h"
-#include "net/eathena/protocolout.h"
-#include "net/eathena/sp.h"
-
-#include "resources/db/unitsdb.h"
-
-#include "debug.h"
-
-extern int packetVersion;
-extern int serverVersion;
-
-namespace EAthena
-{
-
-PlayerHandler::PlayerHandler() :
- Ea::PlayerHandler()
-{
- playerHandler = this;
-}
-
-PlayerHandler::~PlayerHandler()
-{
- playerHandler = nullptr;
-}
-
-void PlayerHandler::attack(const BeingId id,
- const Keep keep) const
-{
- createOutPacket(CMSG_PLAYER_CHANGE_ACT);
- outMsg.writeBeingId(id, "target id");
- if (keep == Keep_true)
- outMsg.writeInt8(7, "action");
- else
- outMsg.writeInt8(0, "action");
-}
-
-void PlayerHandler::stopAttack() const
-{
- createOutPacket(CMSG_PLAYER_STOP_ATTACK);
-}
-
-void PlayerHandler::emote(const uint8_t emoteId) const
-{
- createOutPacket(CMSG_PLAYER_EMOTE);
- outMsg.writeInt8(emoteId, "emote id");
-}
-
-void PlayerHandler::increaseAttribute(const AttributesT attr,
- const int amount) const
-{
- if (attr >= Attributes::PLAYER_STR && attr <= Attributes::PLAYER_LUK)
- {
- createOutPacket(CMSG_STAT_UPDATE_REQUEST);
- outMsg.writeInt16(CAST_S16(attr), "attribute id");
- outMsg.writeInt8(CAST_S8(amount), "increase");
- }
-}
-
-void PlayerHandler::increaseSkill(const uint16_t skillId) const
-{
- if (PlayerInfo::getAttribute(Attributes::PLAYER_SKILL_POINTS) <= 0)
- return;
-
- createOutPacket(CMSG_SKILL_LEVELUP_REQUEST);
- outMsg.writeInt16(skillId, "skill id");
-}
-
-void PlayerHandler::pickUp(const FloorItem *const floorItem) const
-{
- if (floorItem == nullptr)
- return;
-
- createOutPacket(CMSG_ITEM_PICKUP);
- const BeingId id = floorItem->getId();
- if (packetVersion >= 20101124)
- {
- outMsg.writeBeingId(id, "object id");
- }
- else if (packetVersion >= 20080827)
- {
- outMsg.writeInt32(0, "unused");
- outMsg.writeInt8(0, "unused");
- outMsg.writeBeingId(id, "object id");
- }
- else if (packetVersion >= 20070212)
- {
- outMsg.writeInt32(0, "unused");
- outMsg.writeBeingId(id, "object id");
- }
- else if (packetVersion >= 20070108)
- {
- outMsg.writeInt32(0, "unused");
- outMsg.writeInt8(0, "unused");
- outMsg.writeBeingId(id, "object id");
- }
- else if (packetVersion >= 20050719)
- {
- outMsg.writeInt32(0, "unused");
- outMsg.writeInt16(0, "unused");
- outMsg.writeInt8(0, "unused");
- outMsg.writeBeingId(id, "object id");
- }
- else if (packetVersion >= 20050718)
- {
- outMsg.writeInt8(0, "unused");
- outMsg.writeBeingId(id, "object id");
- }
- else if (packetVersion >= 20050628)
- {
- outMsg.writeInt32(0, "unused");
- outMsg.writeInt8(0, "unused");
- outMsg.writeBeingId(id, "object id");
- }
- else if (packetVersion >= 20050509)
- {
- outMsg.writeInt16(0, "unused");
- outMsg.writeBeingId(id, "object id");
- }
- else if (packetVersion >= 20050110)
- {
- outMsg.writeInt16(0, "unused");
- outMsg.writeInt8(0, "unused");
- outMsg.writeBeingId(id, "object id");
- }
- else if (packetVersion >= 20041129)
- {
- outMsg.writeInt8(0, "unused");
- outMsg.writeBeingId(id, "object id");
- }
- else if (packetVersion >= 20041025)
- {
- outMsg.writeInt16(0, "unused");
- outMsg.writeInt8(0, "unused");
- outMsg.writeBeingId(id, "object id");
- }
- else if (packetVersion >= 20041005)
- {
- outMsg.writeInt32(0, "unused");
- outMsg.writeBeingId(id, "object id");
- }
- else if (packetVersion >= 20040920)
- {
- outMsg.writeInt32(0, "unused");
- outMsg.writeInt32(0, "unused");
- outMsg.writeBeingId(id, "object id");
- }
- else if (packetVersion >= 20040906)
- {
- outMsg.writeInt32(0, "unused");
- outMsg.writeInt8(0, "unused");
- outMsg.writeBeingId(id, "object id");
- }
- else if (packetVersion >= 20040809)
- {
- outMsg.writeInt32(0, "unused");
- outMsg.writeInt16(0, "unused");
- outMsg.writeInt8(0, "unused");
- outMsg.writeBeingId(id, "object id");
- }
- else if (packetVersion >= 20040713)
- {
- outMsg.writeInt32(0, "unused");
- outMsg.writeBeingId(id, "object id");
- }
- else
- {
- outMsg.writeBeingId(id, "object id");
- }
-
- Ea::InventoryHandler::pushPickup(floorItem->getId());
-}
-
-void PlayerHandler::setDirection(const unsigned char direction) const
-{
- createOutPacket(CMSG_PLAYER_CHANGE_DIR);
- if (packetVersion >= 20101124)
- {
- outMsg.writeInt8(0, "head direction");
- outMsg.writeInt8(0, "unused");
- outMsg.writeInt8(MessageOut::toServerDirection(direction),
- "player direction");
- }
- else if (packetVersion >= 20080827)
- {
- outMsg.writeInt16(0, "unused");
- outMsg.writeInt8(0, "head direction");
- outMsg.writeInt32(0, "unused");
- outMsg.writeInt8(MessageOut::toServerDirection(direction),
- "player direction");
- }
- else if (packetVersion >= 20070212)
- {
- outMsg.writeInt32(0, "unused");
- outMsg.writeInt16(0, "unused");
- outMsg.writeInt8(0, "head direction");
- outMsg.writeInt16(0, "unused");
- outMsg.writeInt8(MessageOut::toServerDirection(direction),
- "player direction");
- }
- else if (packetVersion >= 20070108)
- {
- outMsg.writeInt32(0, "unused");
- outMsg.writeInt32(0, "unused");
- outMsg.writeInt8(0, "head direction");
- outMsg.writeInt16(0, "unused");
- outMsg.writeInt8(MessageOut::toServerDirection(direction),
- "player direction");
- }
- else if (packetVersion >= 20060327)
- {
- outMsg.writeInt32(0, "unused");
- outMsg.writeInt8(0, "unused");
- outMsg.writeInt8(0, "head direction");
- outMsg.writeInt8(0, "unused");
- outMsg.writeInt16(0, "unused");
- outMsg.writeInt8(MessageOut::toServerDirection(direction),
- "player direction");
- }
- else if (packetVersion >= 20050719)
- {
- outMsg.writeInt32(0, "unused");
- outMsg.writeInt16(0, "unused");
- outMsg.writeInt8(0, "head direction");
- outMsg.writeInt8(0, "unused");
- outMsg.writeInt32(0, "unused");
- outMsg.writeInt16(0, "unused");
- outMsg.writeInt8(MessageOut::toServerDirection(direction),
- "player direction");
- }
- else if (packetVersion >= 20050718)
- {
- outMsg.writeInt32(0, "unused");
- outMsg.writeInt8(0, "head direction");
- outMsg.writeInt8(0, "unused");
- outMsg.writeInt16(0, "unused");
- outMsg.writeInt8(MessageOut::toServerDirection(direction),
- "player direction");
- }
- else if (packetVersion >= 20050628)
- {
- outMsg.writeInt32(0, "unused");
- outMsg.writeInt16(0, "unused");
- outMsg.writeInt8(0, "head direction");
- outMsg.writeInt8(0, "unused");
- outMsg.writeInt32(0, "unused");
- outMsg.writeInt16(0, "unused");
- outMsg.writeInt8(MessageOut::toServerDirection(direction),
- "player direction");
- }
- else if (packetVersion >= 20050509)
- {
- outMsg.writeInt8(0, "unused");
- outMsg.writeInt32(0, "unused");
- outMsg.writeInt16(0, "unused");
- outMsg.writeInt8(0, "head direction");
- outMsg.writeInt8(0, "unused");
- outMsg.writeInt16(0, "unused");
- outMsg.writeInt8(MessageOut::toServerDirection(direction),
- "player direction");
- }
- else if (packetVersion >= 20050110)
- {
- outMsg.writeInt32(0, "unused");
- outMsg.writeInt32(0, "unused");
- outMsg.writeInt16(0, "unused");
- outMsg.writeInt8(0, "head direction");
- outMsg.writeInt8(0, "unused");
- outMsg.writeInt32(0, "unused");
- outMsg.writeInt32(0, "unused");
- outMsg.writeInt8(MessageOut::toServerDirection(direction),
- "player direction");
- }
- else if (packetVersion >= 20041129)
- {
- outMsg.writeInt8(0, "unused");
- outMsg.writeInt8(0, "head direction");
- outMsg.writeInt8(0, "unused");
- outMsg.writeInt16(0, "unused");
- outMsg.writeInt8(MessageOut::toServerDirection(direction),
- "player direction");
- }
- else if (packetVersion >= 20041025)
- {
- outMsg.writeInt32(0, "unused");
- outMsg.writeInt8(0, "head direction");
- outMsg.writeInt8(0, "unused");
- outMsg.writeInt32(0, "unused");
- outMsg.writeInt16(0, "unused");
- outMsg.writeInt8(MessageOut::toServerDirection(direction),
- "player direction");
- }
- else if (packetVersion >= 20041005)
- {
- outMsg.writeInt16(0, "unused");
- outMsg.writeInt8(0, "unused");
- outMsg.writeInt8(0, "head direction");
- outMsg.writeInt32(0, "unused");
- outMsg.writeInt16(0, "unused");
- outMsg.writeInt8(MessageOut::toServerDirection(direction),
- "player direction");
- }
- else if (packetVersion >= 20040920)
- {
- outMsg.writeInt32(0, "unused");
- outMsg.writeInt16(0, "unused");
- outMsg.writeInt8(0, "head direction");
- outMsg.writeInt32(0, "unused");
- outMsg.writeInt32(0, "unused");
- outMsg.writeInt8(MessageOut::toServerDirection(direction),
- "player direction");
- }
- else if (packetVersion >= 20040906)
- {
- outMsg.writeInt16(0, "unused");
- outMsg.writeInt8(0, "head direction");
- outMsg.writeInt16(0, "unused");
- outMsg.writeInt16(0, "unused");
- outMsg.writeInt8(MessageOut::toServerDirection(direction),
- "player direction");
- }
- else if (packetVersion >= 20040809)
- {
- outMsg.writeInt16(0, "unused");
- outMsg.writeInt16(0, "unused");
- outMsg.writeInt8(0, "unused");
- outMsg.writeInt8(0, "head direction");
- outMsg.writeInt16(0, "unused");
- outMsg.writeInt8(0, "unused");
- outMsg.writeInt8(MessageOut::toServerDirection(direction),
- "player direction");
- }
- else if (packetVersion >= 20040713)
- {
- outMsg.writeInt8(0, "unused");
- outMsg.writeInt8(0, "unused");
- outMsg.writeInt8(0, "unused");
- outMsg.writeInt8(0, "head direction");
- outMsg.writeInt16(0, "unused");
- outMsg.writeInt16(0, "unused");
- outMsg.writeInt16(0, "unused");
- outMsg.writeInt8(MessageOut::toServerDirection(direction),
- "player direction");
- }
- else
- {
- outMsg.writeInt8(0, "head direction");
- outMsg.writeInt8(0, "unused");
- outMsg.writeInt8(MessageOut::toServerDirection(direction),
- "player direction");
- }
-}
-
-void PlayerHandler::setDestination(const int x, const int y,
- const int direction) const
-{
- createOutPacket(CMSG_PLAYER_CHANGE_DEST);
- if (packetVersion >= 20080827 && packetVersion < 20101124)
- outMsg.writeInt32(0, "unused");
- outMsg.writeCoordinates(CAST_U16(x),
- CAST_U16(y),
- CAST_U8(direction), "destination");
-}
-
-void PlayerHandler::changeAction(const BeingActionT &action) const
-{
- unsigned char type;
- switch (action)
- {
- case BeingAction::SIT:
- type = 2;
- break;
- case BeingAction::STAND:
- case BeingAction::PRESTAND:
- type = 3;
- break;
- default:
- case BeingAction::MOVE:
- case BeingAction::ATTACK:
- case BeingAction::DEAD:
- case BeingAction::HURT:
- case BeingAction::SPAWN:
- case BeingAction::CAST:
- return;
- }
-
- createOutPacket(CMSG_PLAYER_CHANGE_ACT);
- outMsg.writeInt32(0, "unused");
- outMsg.writeInt8(type, "action");
-}
-
-void PlayerHandler::respawn() const
-{
- createOutPacket(CMSG_PLAYER_RESTART);
- outMsg.writeInt8(0, "action");
-}
-
-void PlayerHandler::requestOnlineList() const
-{
- createOutPacket(CMSG_ONLINE_LIST);
-}
-
-void PlayerHandler::updateStatus(const uint8_t status) const
-{
- createOutPacket(CMSG_SET_STATUS);
- outMsg.writeInt8(status, "status");
- outMsg.writeInt8(0, "unused");
-}
-
-void PlayerHandler::setShortcut(const int idx,
- const uint8_t type,
- const int id,
- const int level) const
-{
- createOutPacket(CMSG_SET_SHORTCUTS);
- outMsg.writeInt16(CAST_S16(idx), "index");
- outMsg.writeInt8(CAST_S8(type), "type");
- outMsg.writeInt32(id, "id");
- outMsg.writeInt16(CAST_S16(level), "level");
-}
-
-void PlayerHandler::shortcutShiftRow(const int row) const
-{
- if (packetVersion < 20140129)
- return;
- createOutPacket(CMSG_SHORTCUTS_ROW_SHIFT);
- outMsg.writeInt8(CAST_S8(row), "row");
-}
-
-void PlayerHandler::removeOption() const
-{
- createOutPacket(CMSG_REMOVE_OPTION);
-}
-
-void PlayerHandler::changeCart(const int type) const
-{
- createOutPacket(CMSG_CHANGE_CART);
- outMsg.writeInt16(CAST_S16(type), "type");
-}
-
-void PlayerHandler::setMemo() const
-{
- createOutPacket(CMSG_PLAYER_SET_MEMO);
-}
-
-void PlayerHandler::doriDori() const
-{
- createOutPacket(CMSG_DORI_DORI);
-}
-
-void PlayerHandler::explosionSpirits() const
-{
- createOutPacket(CMSG_EXPLOSION_SPIRITS);
-}
-
-void PlayerHandler::requestPvpInfo() const
-{
- createOutPacket(CMSG_PVP_INFO);
- outMsg.writeInt32(0, "char id");
- outMsg.writeInt32(0, "account id");
-}
-
-void PlayerHandler::revive() const
-{
- createOutPacket(CMSG_PLAYER_AUTO_REVIVE);
-}
-
-void PlayerHandler::setViewEquipment(const bool allow) const
-{
- createOutPacket(CMSG_PLAYER_SET_EQUIPMENT_VISIBLE);
- outMsg.writeInt32(0, "unused");
- outMsg.writeInt32(allow ? 1 : 0, "allow");
-}
-
-#define setStatComplex(stat) \
- PlayerInfo::setStatBase(stat, base, notify); \
- if (mod != NoStat) \
- PlayerInfo::setStatMod(stat, mod)
-
-void PlayerHandler::setStat(Net::MessageIn &msg,
- const int type,
- const int base,
- const int mod,
- const Notify notify) const
-{
- switch (type)
- {
- case Sp::SPEED:
- localPlayer->setWalkSpeed(base);
- PlayerInfo::setStatBase(Attributes::PLAYER_WALK_SPEED, base);
- PlayerInfo::setStatMod(Attributes::PLAYER_WALK_SPEED, 0);
- break;
- case Sp::BASEEXP:
- PlayerInfo::setAttribute(Attributes::PLAYER_EXP, base);
- break;
- case Sp::JOBEXP:
- PlayerInfo::setAttribute(Attributes::PLAYER_JOB_EXP, base);
- break;
- case Sp::KARMA:
- PlayerInfo::setStatBase(Attributes::PLAYER_KARMA, base);
- PlayerInfo::setStatMod(Attributes::PLAYER_KARMA, 0);
- break;
- case Sp::MANNER:
- PlayerInfo::setStatBase(Attributes::PLAYER_MANNER, base);
- PlayerInfo::setStatMod(Attributes::PLAYER_MANNER, 0);
- break;
- case Sp::HP:
- PlayerInfo::setAttribute(Attributes::PLAYER_HP, base);
- if (localPlayer->isInParty() && (Party::getParty(1) != nullptr))
- {
- PartyMember *const m = Party::getParty(1)
- ->getMember(localPlayer->getId());
- if (m != nullptr)
- {
- m->setHp(base);
- m->setMaxHp(PlayerInfo::getAttribute(
- Attributes::PLAYER_MAX_HP));
- }
- }
- break;
- case Sp::MAXHP:
- PlayerInfo::setAttribute(Attributes::PLAYER_MAX_HP, base);
-
- if (localPlayer->isInParty() && (Party::getParty(1) != nullptr))
- {
- PartyMember *const m = Party::getParty(1)->getMember(
- localPlayer->getId());
- if (m != nullptr)
- {
- m->setHp(PlayerInfo::getAttribute(Attributes::PLAYER_HP));
- m->setMaxHp(base);
- }
- }
- break;
- case Sp::SP:
- PlayerInfo::setAttribute(Attributes::PLAYER_MP, base);
- break;
- case Sp::MAXSP:
- PlayerInfo::setAttribute(Attributes::PLAYER_MAX_MP, base);
- break;
- case Sp::STATUSPOINT:
- PlayerInfo::setAttribute(Attributes::PLAYER_CHAR_POINTS, base);
- break;
- case Sp::BASELEVEL:
- PlayerInfo::setAttribute(Attributes::PLAYER_BASE_LEVEL, base);
- if (localPlayer != nullptr)
- {
- localPlayer->setLevel(base);
- localPlayer->updateName();
- }
- break;
- case Sp::SKILLPOINT:
- PlayerInfo::setAttribute(Attributes::PLAYER_SKILL_POINTS, base);
- if (skillDialog != nullptr)
- skillDialog->update();
- break;
- case Sp::STR:
- setStatComplex(Attributes::PLAYER_STR);
- break;
- case Sp::AGI:
- setStatComplex(Attributes::PLAYER_AGI);
- break;
- case Sp::VIT:
- setStatComplex(Attributes::PLAYER_VIT);
- break;
- case Sp::INT:
- setStatComplex(Attributes::PLAYER_INT);
- break;
- case Sp::DEX:
- setStatComplex(Attributes::PLAYER_DEX);
- break;
- case Sp::LUK:
- setStatComplex(Attributes::PLAYER_LUK);
- break;
- case Sp::ZENY:
- {
- const int oldMoney = PlayerInfo::getAttribute(Attributes::MONEY);
- const int newMoney = base;
- if (newMoney > oldMoney)
- {
- NotifyManager::notify(NotifyTypes::MONEY_GET,
- UnitsDb::formatCurrency(newMoney - oldMoney));
- }
- else if (newMoney < oldMoney)
- {
- NotifyManager::notify(NotifyTypes::MONEY_SPENT,
- UnitsDb::formatCurrency(oldMoney - newMoney).c_str());
- }
-
- PlayerInfo::setAttribute(Attributes::MONEY, newMoney);
- break;
- }
- case Sp::NEXTBASEEXP:
- PlayerInfo::setAttribute(Attributes::PLAYER_EXP_NEEDED, base);
- break;
- case Sp::NEXTJOBEXP:
- PlayerInfo::setAttribute(Attributes::PLAYER_JOB_EXP_NEEDED, base);
- break;
- case Sp::WEIGHT:
- PlayerInfo::setAttribute(Attributes::TOTAL_WEIGHT, base);
- break;
- case Sp::MAXWEIGHT:
- PlayerInfo::setAttribute(Attributes::MAX_WEIGHT, base);
- break;
- case Sp::USTR:
- statusWindow->setPointsNeeded(Attributes::PLAYER_STR, base);
- break;
- case Sp::UAGI:
- statusWindow->setPointsNeeded(Attributes::PLAYER_AGI, base);
- break;
- case Sp::UVIT:
- statusWindow->setPointsNeeded(Attributes::PLAYER_VIT, base);
- break;
- case Sp::UINT:
- statusWindow->setPointsNeeded(Attributes::PLAYER_INT, base);
- break;
- case Sp::UDEX:
- statusWindow->setPointsNeeded(Attributes::PLAYER_DEX, base);
- break;
- case Sp::ULUK:
- statusWindow->setPointsNeeded(Attributes::PLAYER_LUK, base);
- break;
-
- case Sp::ATK1:
- PlayerInfo::setStatBase(Attributes::PLAYER_ATK, base);
- PlayerInfo::updateAttrs();
- break;
- case Sp::ATK2:
- PlayerInfo::setStatMod(Attributes::PLAYER_ATK, base);
- PlayerInfo::updateAttrs();
- break;
- case Sp::MATK1:
- PlayerInfo::setStatBase(Attributes::PLAYER_MATK, base);
- break;
- case Sp::MATK2:
- PlayerInfo::setStatMod(Attributes::PLAYER_MATK, base);
- break;
- case Sp::DEF1:
- PlayerInfo::setStatBase(Attributes::PLAYER_DEF, base);
- break;
- case Sp::DEF2:
- PlayerInfo::setStatMod(Attributes::PLAYER_DEF, base);
- break;
- case Sp::MDEF1:
- PlayerInfo::setStatBase(Attributes::PLAYER_MDEF, base);
- break;
- case Sp::MDEF2:
- PlayerInfo::setStatMod(Attributes::PLAYER_MDEF, base);
- break;
- case Sp::HIT:
- PlayerInfo::setStatBase(Attributes::PLAYER_HIT, base);
- break;
- case Sp::FLEE1:
- PlayerInfo::setStatBase(Attributes::PLAYER_FLEE, base);
- break;
- case Sp::FLEE2:
- PlayerInfo::setStatMod(Attributes::PLAYER_FLEE, base);
- break;
- case Sp::CRITICAL:
- PlayerInfo::setStatBase(Attributes::PLAYER_CRIT, base);
- break;
- case Sp::ASPD:
- localPlayer->setAttackSpeed(base);
- PlayerInfo::setStatBase(Attributes::PLAYER_ATTACK_DELAY, base);
- PlayerInfo::setStatMod(Attributes::PLAYER_ATTACK_DELAY, 0);
- PlayerInfo::updateAttrs();
- break;
- case Sp::JOBLEVEL:
- PlayerInfo::setAttribute(Attributes::PLAYER_JOB_LEVEL, base);
- break;
-
- default:
- UNIMPLEMENTEDPACKETFIELD(type);
- break;
- }
-}
-
-#undef setStatComplex
-
-} // namespace EAthena
diff --git a/src/net/eathena/playerhandler.h b/src/net/eathena/playerhandler.h
deleted file mode 100644
index 1b000025c..000000000
--- a/src/net/eathena/playerhandler.h
+++ /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/>.
- */
-
-#ifndef NET_EATHENA_PLAYERHANDLER_H
-#define NET_EATHENA_PLAYERHANDLER_H
-
-#include "net/ea/playerhandler.h"
-
-namespace EAthena
-{
-
-class PlayerHandler final : public Ea::PlayerHandler
-{
- public:
- PlayerHandler();
-
- A_DELETE_COPY(PlayerHandler)
-
- ~PlayerHandler();
-
- void attack(const BeingId id,
- const Keep keep) const override final;
- void stopAttack() const override final;
- void emote(const uint8_t emoteId) const override final;
-
- void increaseAttribute(const AttributesT attr,
- const int amount) const override final;
- void increaseSkill(const uint16_t skillId) const override final;
-
- void pickUp(const FloorItem *const floorItem) const override final;
- void setDirection(const unsigned char direction) const override final;
- void setDestination(const int x, const int y,
- const int direction) const override final;
- void changeAction(const BeingActionT &action)
- const override final;
- void updateStatus(const uint8_t status) const override final;
-
- void requestOnlineList() const override final;
- void respawn() const override final;
- void setShortcut(const int idx,
- const uint8_t type,
- const int id,
- const int level) const override final;
- void shortcutShiftRow(const int row) const override final;
- void removeOption() const override final;
- void changeCart(const int type) const override final;
- void setMemo() const override final;
- void doriDori() const override final;
- void explosionSpirits() const override final;
- void requestPvpInfo() const override final;
- void revive() const override final;
- void setViewEquipment(const bool allow) const override final;
-
- void setStat(Net::MessageIn &msg,
- const int type,
- const int base,
- const int mod,
- const Notify notify) const override final;
-};
-
-} // namespace EAthena
-
-#endif // NET_EATHENA_PLAYERHANDLER_H
diff --git a/src/net/eathena/playerrecv.cpp b/src/net/eathena/playerrecv.cpp
deleted file mode 100644
index a630bf9b7..000000000
--- a/src/net/eathena/playerrecv.cpp
+++ /dev/null
@@ -1,498 +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 "net/eathena/playerrecv.h"
-
-#include "actormanager.h"
-#include "configuration.h"
-#include "notifymanager.h"
-#include "party.h"
-
-#include "being/beingflag.h"
-#include "being/localplayer.h"
-#include "being/playerinfo.h"
-
-#include "enums/resources/notifytypes.h"
-
-#include "gui/onlineplayer.h"
-
-#include "gui/windows/statuswindow.h"
-#include "gui/windows/whoisonline.h"
-
-#include "gui/widgets/tabs/chat/chattab.h"
-
-#include "net/eathena/sp.h"
-#include "net/messagein.h"
-
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-namespace EAthena
-{
-
-void PlayerRecv::processPlayerShortcuts(Net::MessageIn &msg)
-{
- // +++ player shortcuts ignored. It also disabled on server side.
- // may be in future better use it?
- if (msg.getVersion() >= 20141022)
- msg.readUInt8("rotate");
- for (int f = 0; f < 27; f ++)
- {
- msg.readUInt8("type 0: item, 1: skill");
- msg.readInt32("item or skill id");
- msg.readInt16("skill level");
- }
- msg.skip(77, "unused");
-}
-
-void PlayerRecv::processPlayerShowEquip(Net::MessageIn &msg)
-{
- // +++ for now server allow only switch this option but not using it.
- msg.readUInt8("show equip"); // 1 mean need open "equipment" window
-}
-
-void PlayerRecv::processPlayerStatUpdate5(Net::MessageIn &msg)
-{
- BLOCK_START("PlayerRecv::processPlayerStatUpdate5")
- PlayerInfo::setAttribute(Attributes::PLAYER_CHAR_POINTS,
- msg.readInt16("char points"));
-
- unsigned int val = msg.readUInt8("str");
- PlayerInfo::setStatBase(Attributes::PLAYER_STR, val);
- if (statusWindow != nullptr)
- {
- statusWindow->setPointsNeeded(Attributes::PLAYER_STR,
- msg.readUInt8("str cost"));
- }
- else
- {
- msg.readUInt8("str need");
- }
-
- val = msg.readUInt8("agi");
- PlayerInfo::setStatBase(Attributes::PLAYER_AGI, val);
- if (statusWindow != nullptr)
- {
- statusWindow->setPointsNeeded(Attributes::PLAYER_AGI,
- msg.readUInt8("agi cost"));
- }
- else
- {
- msg.readUInt8("agi cost");
- }
-
- val = msg.readUInt8("vit");
- PlayerInfo::setStatBase(Attributes::PLAYER_VIT, val);
- if (statusWindow != nullptr)
- {
- statusWindow->setPointsNeeded(Attributes::PLAYER_VIT,
- msg.readUInt8("vit cost"));
- }
- else
- {
- msg.readUInt8("vit cost");
- }
-
- val = msg.readUInt8("int");
- PlayerInfo::setStatBase(Attributes::PLAYER_INT, val);
- if (statusWindow != nullptr)
- {
- statusWindow->setPointsNeeded(Attributes::PLAYER_INT,
- msg.readUInt8("int cost"));
- }
- else
- {
- msg.readUInt8("int cost");
- }
-
- val = msg.readUInt8("dex");
- PlayerInfo::setStatBase(Attributes::PLAYER_DEX, val);
- if (statusWindow != nullptr)
- {
- statusWindow->setPointsNeeded(Attributes::PLAYER_DEX,
- msg.readUInt8("dex cost"));
- }
- else
- {
- msg.readUInt8("dex cost");
- }
-
- val = msg.readUInt8("luk");
- PlayerInfo::setStatBase(Attributes::PLAYER_LUK, val);
- if (statusWindow != nullptr)
- {
- statusWindow->setPointsNeeded(Attributes::PLAYER_LUK,
- msg.readUInt8("luk cost"));
- }
- else
- {
- msg.readUInt8("luk cost");
- }
-
- PlayerInfo::setStatBase(Attributes::PLAYER_ATK,
- msg.readInt16("left atk"), Notify_false);
- PlayerInfo::setStatMod(Attributes::PLAYER_ATK,
- msg.readInt16("right atk"));
- PlayerInfo::updateAttrs();
-
- val = msg.readInt16("right matk");
- PlayerInfo::setStatBase(Attributes::PLAYER_MATK, val, Notify_false);
-
- val = msg.readInt16("left matk");
- PlayerInfo::setStatMod(Attributes::PLAYER_MATK, val);
-
- PlayerInfo::setStatBase(Attributes::PLAYER_DEF,
- msg.readInt16("left def"), Notify_false);
- PlayerInfo::setStatMod(Attributes::PLAYER_DEF,
- msg.readInt16("right def"));
-
- PlayerInfo::setStatBase(Attributes::PLAYER_MDEF,
- msg.readInt16("left mdef"), Notify_false);
- PlayerInfo::setStatMod(Attributes::PLAYER_MDEF,
- msg.readInt16("right mdef"));
-
- PlayerInfo::setStatBase(Attributes::PLAYER_HIT,
- msg.readInt16("hit"));
-
- PlayerInfo::setStatBase(Attributes::PLAYER_FLEE,
- msg.readInt16("flee"), Notify_false);
- PlayerInfo::setStatMod(Attributes::PLAYER_FLEE,
- msg.readInt16("flee2/10"));
-
- PlayerInfo::setStatBase(Attributes::PLAYER_CRIT,
- msg.readInt16("crit/10"));
-
- PlayerInfo::setAttribute(Attributes::PLAYER_ATTACK_DELAY,
- msg.readInt16("attack speed"));
- msg.readInt16("plus speed = 0");
-
- BLOCK_END("PlayerRecv::processPlayerStatUpdate5")
-}
-
-void PlayerRecv::processPlayerGetExp(Net::MessageIn &msg)
-{
- if (localPlayer == nullptr)
- return;
- const BeingId id = msg.readBeingId("player id");
- const int exp = msg.readInt32("exp amount");
- const int stat = msg.readInt16("exp type");
- const bool fromQuest = msg.readInt16("is from quest") != 0;
- if (!fromQuest && id == localPlayer->getId())
- {
- if (stat == 1)
- localPlayer->addXpMessage(exp);
- else if (stat == 2)
- localPlayer->addJobMessage(exp);
- else
- UNIMPLEMENTEDPACKETFIELD(stat);
- }
- // need show particle depend on isQuest flag, for now ignored
-}
-
-void PlayerRecv::processWalkResponse(Net::MessageIn &msg)
-{
- BLOCK_START("PlayerRecv::processWalkResponse")
- /*
- * This client assumes that all walk messages succeed,
- * and that the server will send a correction notice
- * otherwise.
- */
- uint16_t srcX, srcY, dstX, dstY;
- msg.readInt32("tick");
- msg.readCoordinatePair(srcX, srcY, dstX, dstY, "move path");
- msg.readUInt8("(sx<<4) | (sy&0x0f)");
- if (localPlayer != nullptr)
- localPlayer->setRealPos(dstX, dstY);
- BLOCK_END("PlayerRecv::processWalkResponse")
-}
-
-void PlayerRecv::processWalkError(Net::MessageIn &msg)
-{
- msg.readInt32("tick");
- const int x = msg.readInt16("x");
- const int y = msg.readInt16("y");
- if (localPlayer != nullptr)
- localPlayer->failMove(x, y);
-}
-
-void PlayerRecv::processPvpInfo(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readInt32("char id");
- msg.readBeingId("account id");
- msg.readInt32("pvp won");
- msg.readInt32("pvp lost");
- msg.readInt32("pvp point");
-}
-
-void PlayerRecv::processPlayerHeal(Net::MessageIn &msg)
-{
- if (localPlayer == nullptr)
- return;
-
- const int type = msg.readInt16("var id");
- int amount;
- if (msg.getVersion() >= 20150513)
- amount = msg.readInt32("value");
- else
- amount = msg.readInt16("value");
- if (type == Sp::HP)
- {
- const int base = PlayerInfo::getAttribute(Attributes::PLAYER_HP) +
- amount;
- PlayerInfo::setAttribute(Attributes::PLAYER_HP, base);
- if (localPlayer->isInParty() && (Party::getParty(1) != nullptr))
- {
- PartyMember *const m = Party::getParty(1)
- ->getMember(localPlayer->getId());
- if (m != nullptr)
- {
- m->setHp(base);
- m->setMaxHp(PlayerInfo::getAttribute(
- Attributes::PLAYER_MAX_HP));
- }
- }
- localPlayer->addHpMessage(amount);
- }
- else if (type == Sp::SP)
- {
- localPlayer->addSpMessage(amount);
- }
-}
-
-void PlayerRecv::processPlayerSkillMessage(Net::MessageIn &msg)
-{
- const int message = msg.readInt32("type");
- switch (message)
- {
- case 0x15:
- NotifyManager::notify(NotifyTypes::SKILL_END_ALL_NEGATIVE_STATUS);
- break;
- case 0x16:
- NotifyManager::notify(NotifyTypes::SKILL_IMMUNITY_TO_ALL_STATUSES);
- break;
- case 0x17:
- NotifyManager::notify(NotifyTypes::SKILL_MAX_HP);
- break;
- case 0x18:
- NotifyManager::notify(NotifyTypes::SKILL_MAX_SP);
- break;
- case 0x19:
- NotifyManager::notify(NotifyTypes::SKILL_ALL_STATUS_PLUS_20);
- break;
- case 0x1c:
- NotifyManager::notify(NotifyTypes::SKILL_ENCHANT_WEAPON_HOLY);
- break;
- case 0x1d:
- NotifyManager::notify(NotifyTypes::SKILL_ENCHANT_ARMOR_HOLY);
- break;
- case 0x1e:
- NotifyManager::notify(NotifyTypes::SKILL_DEF_PLUS_25);
- break;
- case 0x1f:
- NotifyManager::notify(NotifyTypes::SKILL_ATTACK_PLUS_100);
- break;
- case 0x20:
- NotifyManager::notify(NotifyTypes::SKILL_FLEE_PLUS_50);
- break;
- case 0x28:
- NotifyManager::notify(NotifyTypes::SKILL_FULL_STRIP_FAILED);
- break;
- default:
- NotifyManager::notify(NotifyTypes::SKILL_MESSAGE_UNKNOWN);
- break;
- }
-}
-
-void PlayerRecv::processNotifyMapInfo(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readInt16("type");
-}
-
-void PlayerRecv::processPlayerFameBlacksmith(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readInt32("points");
- msg.readInt32("total points");
-}
-
-void PlayerRecv::processPlayerFameAlchemist(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readInt32("points");
- msg.readInt32("total points");
-}
-
-void PlayerRecv::processPlayerUpgradeMessage(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readInt32("result");
- msg.readInt16("item id");
-}
-
-void PlayerRecv::processPlayerFameTaekwon(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readInt32("points");
- msg.readInt32("total points");
-}
-
-void PlayerRecv::processPlayerReadBook(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readInt32("book id");
- msg.readInt32("page");
-}
-
-void PlayerRecv::processPlayerEquipTickAck(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readInt32("unused");
- msg.readInt32("flag");
-}
-
-void PlayerRecv::processPlayerAutoShadowSpellList(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- const int count = (msg.readInt16("len") - 8) / 2;
- for (int f = 0; f < count; f ++)
- msg.readInt16("skill id");
-}
-
-void PlayerRecv::processPlayerRankPoints(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readInt16("type");
- msg.readInt32("points");
- msg.readInt32("fame");
-}
-
-void PlayerRecv::processOnlineList(Net::MessageIn &msg)
-{
- if (whoIsOnline == nullptr)
- return;
-
- BLOCK_START("PlayerRecv::processOnlineList")
- const int size = msg.readInt16("len") - 4;
- STD_VECTOR<OnlinePlayer*> arr;
-
- if (size == 0)
- {
- if (whoIsOnline != nullptr)
- whoIsOnline->loadList(arr);
- BLOCK_END("PlayerRecv::processOnlineList")
- return;
- }
-
- char *const start = reinterpret_cast<char*>(msg.readBytes(size, "nicks"));
- if (start == nullptr)
- {
- BLOCK_END("PlayerRecv::processOnlineList")
- return;
- }
-
- const char *buf = start;
-
- int addVal = 3;
-
- while (buf - start + 1 < size
- && (*(buf + CAST_SIZE(addVal)) != 0))
- {
- const unsigned char status = *buf;
- buf ++;
- const unsigned char level = *buf;
- buf ++;
- const unsigned char ver = *buf;
- buf ++;
-
- GenderT gender = Gender::UNSPECIFIED;
- if (config.getBoolValue("showgender"))
- {
- if ((status & BeingFlag::GENDER_MALE) != 0)
- gender = Gender::MALE;
- else if ((status & BeingFlag::GENDER_OTHER) != 0)
- gender = Gender::OTHER;
- else
- gender = Gender::FEMALE;
- }
- arr.push_back(new OnlinePlayer(static_cast<const char*>(buf),
- status, level, gender, ver));
- buf += strlen(buf) + 1;
- }
-
- if (whoIsOnline != nullptr)
- whoIsOnline->loadList(arr);
- delete [] start;
- BLOCK_END("PlayerRecv::processOnlineList")
-}
-
-void PlayerRecv::processDressRoomOpen(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readInt16("view");
-}
-
-void PlayerRecv::processKilledBy(Net::MessageIn &msg)
-{
- const BeingId id = msg.readBeingId("killer id");
- const Being *const dstBeing = actorManager->findBeing(id);
- if (id == BeingId_zero)
- {
- debugMsg(
- // TRANSLATORS: player killed message
- _("You were killed by unknown source."));
- }
- else
- {
- std::string name;
- if (dstBeing != nullptr)
- name = dstBeing->getName();
- else
- name = strprintf("?%u", CAST_U32(id));
- debugMsg(strprintf(
- // TRANSLATORS: player killed message
- _("You were killed by %s."),
- name.c_str()));
- }
-}
-
-void PlayerRecv::processPlayerAttrs(Net::MessageIn &msg)
-{
- const int len = msg.readInt16("len");
- if (len < 8)
- return;
-
- const int groupId = msg.readInt32("group id");
-
- if (localPlayer == nullptr)
- return;
-
- localPlayer->setGroupId(groupId);
- if (groupId > 0)
- localPlayer->setGM(true);
- else
- localPlayer->setGM(false);
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/playerrecv.h b/src/net/eathena/playerrecv.h
deleted file mode 100644
index eb38684b8..000000000
--- a/src/net/eathena/playerrecv.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 NET_EATHENA_PLAYERRECV_H
-#define NET_EATHENA_PLAYERRECV_H
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-namespace EAthena
-{
- namespace PlayerRecv
- {
- void processPlayerShortcuts(Net::MessageIn &msg);
- void processPlayerShowEquip(Net::MessageIn &msg);
- void processPlayerStatUpdate5(Net::MessageIn &msg);
- void processPlayerGetExp(Net::MessageIn &msg);
- void processPvpInfo(Net::MessageIn &msg);
- void processPlayerHeal(Net::MessageIn &msg);
- void processPlayerSkillMessage(Net::MessageIn &msg);
- void processWalkResponse(Net::MessageIn &msg);
- void processWalkError(Net::MessageIn &msg);
- void processNotifyMapInfo(Net::MessageIn &msg);
- void processPlayerFameBlacksmith(Net::MessageIn &msg);
- void processPlayerFameAlchemist(Net::MessageIn &msg);
- void processPlayerUpgradeMessage(Net::MessageIn &msg);
- void processPlayerFameTaekwon(Net::MessageIn &msg);
- void processPlayerReadBook(Net::MessageIn &msg);
- void processPlayerEquipTickAck(Net::MessageIn &msg);
- void processPlayerAutoShadowSpellList(Net::MessageIn &msg);
- void processPlayerRankPoints(Net::MessageIn &msg);
- void processOnlineList(Net::MessageIn &msg);
- void processDressRoomOpen(Net::MessageIn &msg);
- void processKilledBy(Net::MessageIn &msg);
- void processPlayerAttrs(Net::MessageIn &msg);
- } // namespace PlayerRecv
-} // namespace EAthena
-
-#endif // NET_EATHENA_PLAYERRECV_H
diff --git a/src/net/eathena/protocolout.cpp b/src/net/eathena/protocolout.cpp
deleted file mode 100644
index 154dacf6c..000000000
--- a/src/net/eathena/protocolout.cpp
+++ /dev/null
@@ -1,32 +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/>.
- */
-
-extern int evolPacketOffset;
-
-namespace EAthena
-{
-#include "net/protocoloutdefine.h"
-#include "net/eathena/packetsout.inc"
-#undef packet
-PROTOCOLOUT_VOID
-PACKETSOUT_VOID
-} // namespace EAthena
-
-#include "debug.h"
diff --git a/src/net/eathena/protocolout.h b/src/net/eathena/protocolout.h
deleted file mode 100644
index d6be65703..000000000
--- a/src/net/eathena/protocolout.h
+++ /dev/null
@@ -1,40 +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 NET_EATHENA_PROTOCOLOUT_H
-#define NET_EATHENA_PROTOCOLOUT_H
-
-#include "net/protocoloutinclude.h"
-
-#define PROTOCOLOUT_VOID
-
-namespace EAthena
-{
-#include "net/eathena/packetsout.inc"
-PACKETSOUT_VOID
-} // namespace EAthena
-
-#undef packet
-#undef packet2
-#undef startCondition
-#undef endCondition
-#undef PACKETSOUT_VOID
-
-#endif // NET_EATHENA_PROTOCOLOUT_H
diff --git a/src/net/eathena/questhandler.cpp b/src/net/eathena/questhandler.cpp
deleted file mode 100644
index 0db26ebf4..000000000
--- a/src/net/eathena/questhandler.cpp
+++ /dev/null
@@ -1,50 +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 "net/eathena/questhandler.h"
-
-#include "net/eathena/messageout.h"
-#include "net/eathena/protocolout.h"
-
-#include "debug.h"
-
-namespace EAthena
-{
-
-QuestHandler::QuestHandler() :
- Net::QuestHandler()
-{
- questHandler = this;
-}
-
-QuestHandler::~QuestHandler()
-{
- questHandler = nullptr;
-}
-
-void QuestHandler::setQeustActiveState(const int questId,
- const bool active) const
-{
- createOutPacket(CMSG_QUEST_ACTIVATE);
- outMsg.writeInt32(questId, "quest id");
- outMsg.writeInt8(CAST_S8(active ? 1 : 0), "activate");
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/questhandler.h b/src/net/eathena/questhandler.h
deleted file mode 100644
index 2c5f18b67..000000000
--- a/src/net/eathena/questhandler.h
+++ /dev/null
@@ -1,44 +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 NET_EATHENA_QUESTHANDLER_H
-#define NET_EATHENA_QUESTHANDLER_H
-
-#include "net/questhandler.h"
-
-namespace EAthena
-{
-
-class QuestHandler final : public Net::QuestHandler
-{
- public:
- QuestHandler();
-
- A_DELETE_COPY(QuestHandler)
-
- ~QuestHandler();
-
- void setQeustActiveState(const int questId,
- const bool active) const override final;
-};
-
-} // namespace EAthena
-
-#endif // NET_EATHENA_QUESTHANDLER_H
diff --git a/src/net/eathena/questrecv.cpp b/src/net/eathena/questrecv.cpp
deleted file mode 100644
index 69ad93541..000000000
--- a/src/net/eathena/questrecv.cpp
+++ /dev/null
@@ -1,205 +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 "net/eathena/questrecv.h"
-
-#include "gui/windows/skilldialog.h"
-#include "gui/windows/questswindow.h"
-
-#include "net/messagein.h"
-
-#include "const/resources/skill.h"
-
-#include "debug.h"
-
-namespace EAthena
-{
-
-void QuestRecv::processAddQuest(Net::MessageIn &msg)
-{
- const int var = msg.readInt32("quest id");
- const int val = msg.readUInt8("state");
- msg.readUInt8("time diff");
- msg.readInt32("time");
- const int num = msg.readInt16("objectives count");
- for (int f = 0; f < num; f ++)
- {
- // need use in quests kills list
- msg.readInt32("monster id");
- msg.readInt16("count");
- msg.readString(24, "monster name");
- }
-
- msg.skipToEnd("unused");
-
- if (questsWindow != nullptr)
- {
- questsWindow->updateQuest(var, val, 0, 0, 0);
- questsWindow->rebuild(true);
- }
- if (skillDialog != nullptr)
- {
- skillDialog->updateQuest(var, val, 0, 0, 0);
- skillDialog->playUpdateEffect(var + SKILL_VAR_MIN_ID);
- }
-}
-
-void QuestRecv::processAddQuest2(Net::MessageIn &msg)
-{
- const int var = msg.readInt32("quest id");
- msg.readUInt8("state");
- const int val1 = msg.readInt32("count1");
- const int val2 = msg.readInt32("count2");
- const int val3 = msg.readInt32("count3");
- const int time = msg.readInt32("time");
-
- if (questsWindow != nullptr)
- {
- questsWindow->updateQuest(var, val1, val2, val3, time);
- questsWindow->rebuild(true);
- }
- if (skillDialog != nullptr)
- {
- skillDialog->updateQuest(var, val1, val2, val3, time);
- skillDialog->playUpdateEffect(var + SKILL_VAR_MIN_ID);
- }
-}
-
-void QuestRecv::processAddQuests(Net::MessageIn &msg)
-{
- msg.readInt16("len");
- const int num = msg.readInt32("quests count");
- for (int f = 0; f < num; f ++)
- {
- const int var = msg.readInt32("quest id");
- const int val = msg.readUInt8("state");
- if (msg.getVersion() >= 20141022)
- {
- msg.readInt32("time diff");
- msg.readInt32("time");
- msg.readInt16("objectives count");
- }
- if (questsWindow != nullptr)
- questsWindow->updateQuest(var, val, 0, 0, 0);
- if (skillDialog != nullptr)
- skillDialog->updateQuest(var, val, 0, 0, 0);
- }
-
- if (questsWindow != nullptr)
- questsWindow->rebuild(false);
-}
-
-void QuestRecv::processAddQuests2(Net::MessageIn &msg)
-{
- msg.readInt16("len");
- const int num = msg.readInt32("quests count");
- for (int f = 0; f < num; f ++)
- {
- const int var = msg.readInt32("quest id");
- msg.readUInt8("state");
- const int val1 = msg.readInt32("count1");
- const int val2 = msg.readInt32("count2");
- const int val3 = msg.readInt32("count3");
- const int time = msg.readInt32("time");
- if (questsWindow != nullptr)
- questsWindow->updateQuest(var, val1, val2, val3, time);
- if (skillDialog != nullptr)
- skillDialog->updateQuest(var, val1, val2, val3, time);
- }
-
- if (questsWindow != nullptr)
- questsWindow->rebuild(false);
-}
-
-void QuestRecv::processAddQuestsObjectives(Net::MessageIn &msg)
-{
- msg.readInt16("len");
- const int quests = msg.readInt32("quests count");
- for (int f = 0; f < quests; f ++)
- {
- msg.readInt32("quest id");
- msg.readInt32("time diff");
- msg.readInt32("time");
- const int num = msg.readInt16("objectives count");
- for (int d = 0; d < num; d ++)
- {
- // need use in quests kills list
- msg.readInt32("monster id");
- msg.readInt16("count");
- msg.readString(24, "monster name");
- }
- }
- msg.skipToEnd("unused");
-}
-
-void QuestRecv::processUpdateQuestsObjectives(Net::MessageIn &msg)
-{
- // ignored
- msg.readInt16("len");
- const int num = msg.readInt16("objectives count");
- for (int f = 0; f < num; f ++)
- {
- msg.readInt32("quest id");
- msg.readInt32("monster id");
- msg.readInt16("count old");
- msg.readInt16("count new");
- }
-}
-
-void QuestRecv::processRemoveQuest(Net::MessageIn &msg)
-{
- const int var = msg.readInt32("quest id");
- const int val = -1;
-
- // not removing quest, because this is impossible,
- // but changing status to -1
- if (questsWindow != nullptr)
- {
- questsWindow->updateQuest(var, val, 0, 0, 0);
- questsWindow->rebuild(true);
- }
- if (skillDialog != nullptr)
- {
- skillDialog->updateQuest(var, val, 0, 0, 0);
- skillDialog->playUpdateEffect(var + SKILL_VAR_MIN_ID);
- }
-}
-
-void QuestRecv::processActivateQuest(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- // +++ need enable/disable quests depend on this packet
- msg.readInt32("quest id");
- msg.readUInt8("activate");
-}
-
-void QuestRecv::processNpcQuestEffect(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- // this packed mostly useless, because manaplus can show any
- // kind of effects based on quest states.
- msg.readInt32("npc id");
- msg.readInt16("x");
- msg.readInt16("y");
- msg.readInt16("state");
- msg.readInt16("color");
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/questrecv.h b/src/net/eathena/questrecv.h
deleted file mode 100644
index aff969a59..000000000
--- a/src/net/eathena/questrecv.h
+++ /dev/null
@@ -1,45 +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 NET_EATHENA_QUESTRECV_H
-#define NET_EATHENA_QUESTRECV_H
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-namespace EAthena
-{
- namespace QuestRecv
- {
- void processAddQuest(Net::MessageIn &msg);
- void processAddQuest2(Net::MessageIn &msg);
- void processAddQuests(Net::MessageIn &msg);
- void processAddQuests2(Net::MessageIn &msg);
- void processAddQuestsObjectives(Net::MessageIn &msg);
- void processUpdateQuestsObjectives(Net::MessageIn &msg);
- void processRemoveQuest(Net::MessageIn &msg);
- void processActivateQuest(Net::MessageIn &msg);
- void processNpcQuestEffect(Net::MessageIn &msg);
- } // namespace QuestRecv
-} // namespace EAthena
-
-#endif // NET_EATHENA_QUESTRECV_H
diff --git a/src/net/eathena/recvpackets.inc b/src/net/eathena/recvpackets.inc
deleted file mode 100644
index 32032296c..000000000
--- a/src/net/eathena/recvpackets.inc
+++ /dev/null
@@ -1,32 +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 NET_EATHENA_RECVPACKETS_H
-#define NET_EATHENA_RECVPACKETS_H
-
-#define RECVPACKETS_VOID
-
-#include "net/recvpacketdefine.h"
-
-#include "net/eathena/packetsin.inc"
-
-#undef packet
-
-#endif // NET_EATHENA_RECVPACKETS_H
diff --git a/src/net/eathena/roulettehandler.cpp b/src/net/eathena/roulettehandler.cpp
deleted file mode 100644
index b0d9d2829..000000000
--- a/src/net/eathena/roulettehandler.cpp
+++ /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/>.
- */
-
-#include "net/eathena/roulettehandler.h"
-
-#include "debug.h"
-
-namespace EAthena
-{
-
-RouletteHandler::RouletteHandler() :
- Net::RouletteHandler()
-{
- rouletteHandler = this;
-}
-
-RouletteHandler::~RouletteHandler()
-{
- rouletteHandler = nullptr;
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/roulettehandler.h b/src/net/eathena/roulettehandler.h
deleted file mode 100644
index 861f54582..000000000
--- a/src/net/eathena/roulettehandler.h
+++ /dev/null
@@ -1,40 +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 NET_EATHENA_ROULETTEHANDLER_H
-#define NET_EATHENA_ROULETTEHANDLER_H
-
-#include "net/roulettehandler.h"
-
-namespace EAthena
-{
-class RouletteHandler final : public Net::RouletteHandler
-{
- public:
- RouletteHandler();
-
- A_DELETE_COPY(RouletteHandler)
-
- ~RouletteHandler();
-};
-
-} // namespace EAthena
-
-#endif // NET_EATHENA_ROULETTEHANDLER_H
diff --git a/src/net/eathena/rouletterecv.cpp b/src/net/eathena/rouletterecv.cpp
deleted file mode 100644
index 2422fbcda..000000000
--- a/src/net/eathena/rouletterecv.cpp
+++ /dev/null
@@ -1,79 +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 "net/eathena/rouletterecv.h"
-
-#include "logger.h"
-
-#include "net/messagein.h"
-
-#include "debug.h"
-
-namespace EAthena
-{
-
-void RouletteRecv::processRouletteInfoAckType(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- const int count = (msg.readInt16("len") - 8) / 8;
- msg.readInt32("serial");
-
- for (int f = 0; f < count; f ++)
- {
- msg.readInt16("row");
- msg.readInt16("position");
- msg.readInt16("item id");
- msg.readInt16("count");
- }
-}
-
-void RouletteRecv::processRouletteItemAck(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readUInt8("result");
- msg.readInt16("item id");
-}
-
-void RouletteRecv::processRouletteGenerateAckType(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readUInt8("result");
- msg.readInt16("step");
- msg.readInt16("idx");
- msg.readInt16("item id");
- msg.readInt32("remain gold");
- msg.readInt32("remain silver");
- msg.readInt32("remain bronze");
-}
-
-void RouletteRecv::processRouletteOpenAck(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readUInt8("result");
- msg.readInt32("serial");
- msg.readUInt8("step");
- msg.readUInt8("idx");
- msg.readInt16("additional item id");
- msg.readInt32("gold point");
- msg.readInt32("silver point");
- msg.readInt32("bronze point");
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/rouletterecv.h b/src/net/eathena/rouletterecv.h
deleted file mode 100644
index e922a8b02..000000000
--- a/src/net/eathena/rouletterecv.h
+++ /dev/null
@@ -1,40 +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 NET_EATHENA_ROULETTERECV_H
-#define NET_EATHENA_ROULETTERECV_H
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-namespace EAthena
-{
- namespace RouletteRecv
- {
- void processRouletteInfoAckType(Net::MessageIn &msg);
- void processRouletteItemAck(Net::MessageIn &msg);
- void processRouletteGenerateAckType(Net::MessageIn &msg);
- void processRouletteOpenAck(Net::MessageIn &msg);
- } // namespace RouletteRecv
-} // namespace EAthena
-
-#endif // NET_EATHENA_ROULETTERECV_H
diff --git a/src/net/eathena/searchstorehandler.cpp b/src/net/eathena/searchstorehandler.cpp
deleted file mode 100644
index c8cd43d2d..000000000
--- a/src/net/eathena/searchstorehandler.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 "net/eathena/searchstorehandler.h"
-
-#include "net/eathena/messageout.h"
-#include "net/eathena/protocolout.h"
-
-#include "debug.h"
-
-extern int packetVersion;
-
-namespace EAthena
-{
-
-SearchStoreHandler::SearchStoreHandler() :
- Net::SearchStoreHandler()
-{
- searchStoreHandler = this;
-}
-
-SearchStoreHandler::~SearchStoreHandler()
-{
- searchStoreHandler = nullptr;
-}
-
-void SearchStoreHandler::search(const StoreSearchTypeT type,
- const int minPrice,
- const int maxPrice,
- const int itemId) const
-{
- if (packetVersion < 20100601)
- return;
-
- createOutPacket(CMSG_SEARCHSTORE_SEARCH);
- outMsg.writeInt16(23, "len");
- outMsg.writeInt8(CAST_U8(type), "search type");
- outMsg.writeInt32(maxPrice, "max price");
- outMsg.writeInt32(minPrice, "min price");
- outMsg.writeInt32(1, "items count");
- outMsg.writeInt32(0, "cards count");
- outMsg.writeInt16(CAST_S16(itemId), "item id");
-}
-
-void SearchStoreHandler::nextPage() const
-{
- if (packetVersion < 20100608)
- return;
- createOutPacket(CMSG_SEARCHSTORE_NEXT_PAGE);
-}
-
-void SearchStoreHandler::close() const
-{
- if (packetVersion < 20100608)
- return;
- createOutPacket(CMSG_SEARCHSTORE_CLOSE);
-}
-
-void SearchStoreHandler::select(const int accountId,
- const int storeId,
- const int itemId) const
-{
- if (packetVersion < 20100608)
- return;
- createOutPacket(CMSG_SEARCHSTORE_CLICK);
- outMsg.writeInt32(accountId, "account id");
- outMsg.writeInt32(storeId, "store id");
- outMsg.writeInt16(CAST_S16(itemId), "item id");
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/searchstorehandler.h b/src/net/eathena/searchstorehandler.h
deleted file mode 100644
index 5e425e6e5..000000000
--- a/src/net/eathena/searchstorehandler.h
+++ /dev/null
@@ -1,53 +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 NET_EATHENA_SEARCHSTOREHANDLER_H
-#define NET_EATHENA_SEARCHSTOREHANDLER_H
-
-#include "net/searchstorehandler.h"
-
-namespace EAthena
-{
-class SearchStoreHandler final : public Net::SearchStoreHandler
-{
- public:
- SearchStoreHandler();
-
- A_DELETE_COPY(SearchStoreHandler)
-
- ~SearchStoreHandler();
-
- void search(const StoreSearchTypeT type,
- const int minPrice,
- const int maxPrice,
- const int itemId) const override final;
-
- void nextPage() const override final;
-
- void close() const override final;
-
- void select(const int accountId,
- const int storeId,
- const int itemId) const override final;
-};
-
-} // namespace EAthena
-
-#endif // NET_EATHENA_SEARCHSTOREHANDLER_H
diff --git a/src/net/eathena/searchstorerecv.cpp b/src/net/eathena/searchstorerecv.cpp
deleted file mode 100644
index 9f8904f7c..000000000
--- a/src/net/eathena/searchstorerecv.cpp
+++ /dev/null
@@ -1,109 +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 "net/eathena/searchstorerecv.h"
-
-#include "logger.h"
-#include "notifymanager.h"
-
-#include "const/resources/item/cards.h"
-
-#include "enums/resources/notifytypes.h"
-
-#include "net/messagein.h"
-
-#include "debug.h"
-
-namespace EAthena
-{
-
-void SearchStoreRecv::processSearchAck(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- const int count = (msg.readInt16("len") - 7) / 106;
- msg.readUInt8("is first page");
- msg.readUInt8("is next page");
- msg.readUInt8("remain uses");
- for (int f = 0; f < count; f ++)
- {
- msg.readInt32("store id");
- msg.readInt32("aoount id");
- msg.readString(80, "store name");
- msg.readInt16("item id");
- msg.readUInt8("item type");
- msg.readInt32("price");
- msg.readInt16("amount");
- msg.readUInt8("refine");
- for (int d = 0; d < maxCards; d++)
- msg.readUInt16("card");
-
- // +++ need use ItemColorManager for colors
- }
-}
-
-void SearchStoreRecv::processSearchFailed(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- const int result = msg.readUInt8("result");
- switch (result)
- {
- case 0:
- NotifyManager::notify(
- NotifyTypes::SEARCH_STORE_FAILED_NO_STORES);
- break;
- case 1:
- NotifyManager::notify(
- NotifyTypes::SEARCH_STORE_FAILED_MANY_RESULTS);
- break;
- case 2:
- NotifyManager::notify(
- NotifyTypes::SEARCH_STORE_FAILED_CANT_SEARCH_ANYMORE);
- break;
- case 3:
- NotifyManager::notify(
- NotifyTypes::SEARCH_STORE_FAILED_CANT_SEARCH_YET);
- break;
- case 4:
- NotifyManager::notify(
- NotifyTypes::SEARCH_STORE_FAILED_NO_INFORMATION);
- break;
- default:
- NotifyManager::notify(
- NotifyTypes::SEARCH_STORE_FAILED);
- break;
- }
-}
-
-void SearchStoreRecv::processSearchOpen(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readInt16("effect");
- if (msg.getVersion() >= 20100701)
- msg.readUInt8("uses");
-}
-
-void SearchStoreRecv::processSearchClickAck(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readInt16("x");
- msg.readInt16("y");
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/searchstorerecv.h b/src/net/eathena/searchstorerecv.h
deleted file mode 100644
index 916c26ad2..000000000
--- a/src/net/eathena/searchstorerecv.h
+++ /dev/null
@@ -1,40 +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 NET_EATHENA_SEARCHSTORERECV_H
-#define NET_EATHENA_SEARCHSTORERECV_H
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-namespace EAthena
-{
- namespace SearchStoreRecv
- {
- void processSearchAck(Net::MessageIn &msg);
- void processSearchFailed(Net::MessageIn &msg);
- void processSearchOpen(Net::MessageIn &msg);
- void processSearchClickAck(Net::MessageIn &msg);
- } // namespace SearchStoreRecv
-} // namespace EAthena
-
-#endif // NET_EATHENA_SEARCHSTORERECV_H
diff --git a/src/net/eathena/serverfeatures.cpp b/src/net/eathena/serverfeatures.cpp
deleted file mode 100644
index ff6133eb1..000000000
--- a/src/net/eathena/serverfeatures.cpp
+++ /dev/null
@@ -1,153 +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 "net/eathena/serverfeatures.h"
-
-#include "net/net.h"
-
-#include "debug.h"
-
-extern int serverVersion;
-
-namespace EAthena
-{
-
-ServerFeatures::ServerFeatures() :
- Net::ServerFeatures()
-{
- serverFeatures = this;
-}
-
-bool ServerFeatures::haveServerOnlineList() const
-{
- return serverVersion > 0;
-}
-
-bool ServerFeatures::haveServerHp() const
-{
- return true;
-}
-
-bool ServerFeatures::havePlayerStatusUpdate() const
-{
- return serverVersion > 0;
-}
-
-bool ServerFeatures::haveIncompleteChatMessages() const
-{
- return false;
-}
-
-bool ServerFeatures::haveRaceSelection() const
-{
- return serverVersion > 0;
-}
-
-bool ServerFeatures::haveLookSelection() const
-{
- return serverVersion > 0;
-}
-
-bool ServerFeatures::haveMove3() const
-{
- return serverVersion > 0;
-}
-
-bool ServerFeatures::haveCharOtherGender() const
-{
- return true;
-}
-
-bool ServerFeatures::haveMonsterAttackRange() const
-{
- return false;
-}
-
-bool ServerFeatures::haveEmailOnRegister() const
-{
- return serverVersion > 0;
-}
-
-bool ServerFeatures::haveEmailOnDelete() const
-{
- return serverVersion > 0;
-}
-
-bool ServerFeatures::haveServerVersion() const
-{
- return Net::getNetworkType() == ServerType::EVOL2;
-}
-
-bool ServerFeatures::haveMapServerVersion() const
-{
- return serverVersion > 0;
-}
-
-bool ServerFeatures::haveNpcGender() const
-{
- return serverVersion > 0;
-}
-
-bool ServerFeatures::haveJoinChannel() const
-{
- return serverVersion > 0;
-}
-
-bool ServerFeatures::haveCreateCharGender() const
-{
- return serverVersion > 0;
-}
-
-bool ServerFeatures::haveTalkPet() const
-{
- return serverVersion > 0;
-}
-
-bool ServerFeatures::haveMovePet() const
-{
- return serverVersion > 0;
-}
-
-bool ServerFeatures::haveServerWarpNames() const
-{
- return serverVersion == 0;
-}
-
-bool ServerFeatures::haveExtendedRiding() const
-{
- return serverVersion > 0;
-}
-
-bool ServerFeatures::haveExtendedDropsPosition() const
-{
- return serverVersion >= 12;
-}
-
-bool ServerFeatures::haveMoveWhileSit() const
-{
- return serverVersion > 0;
-}
-
-bool ServerFeatures::haveKillerId() const
-{
- return serverVersion >= 14;
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/serverfeatures.h b/src/net/eathena/serverfeatures.h
deleted file mode 100644
index f60f6e741..000000000
--- a/src/net/eathena/serverfeatures.h
+++ /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/>.
- */
-
-#ifndef NET_EATHENA_SERVERFEATURES_H
-#define NET_EATHENA_SERVERFEATURES_H
-
-#include "net/serverfeatures.h"
-
-#include "localconsts.h"
-
-namespace EAthena
-{
-class ServerFeatures final : public Net::ServerFeatures
-{
- public:
- ServerFeatures();
-
- A_DELETE_COPY(ServerFeatures)
-
- bool haveServerOnlineList() const override final;
-
- bool haveServerHp() const override final A_CONST;
-
- bool havePlayerStatusUpdate() const override final;
-
- bool haveIncompleteChatMessages() const override final A_CONST;
-
- bool haveRaceSelection() const override final;
-
- bool haveLookSelection() const override final;
-
- bool haveMove3() const override final;
-
- bool haveCharOtherGender() const override final;
-
- bool haveMonsterAttackRange() const override final A_CONST;
-
- bool haveEmailOnRegister() const override final;
-
- bool haveEmailOnDelete() const override final;
-
- bool haveServerVersion() const override final;
-
- bool haveMapServerVersion() const override final;
-
- bool haveNpcGender() const override final;
-
- bool haveJoinChannel() const override final;
-
- bool haveCreateCharGender() const override final;
-
- bool haveTalkPet() const override final;
-
- bool haveMovePet() const override final;
-
- bool haveServerWarpNames() const override final;
-
- bool haveExtendedRiding() const override final;
-
- bool haveExtendedDropsPosition() const override final;
-
- bool haveMoveWhileSit() const override final;
-
- bool haveKillerId() const override final;
-};
-
-} // namespace EAthena
-
-#endif // NET_EATHENA_SERVERFEATURES_H
diff --git a/src/net/eathena/skillhandler.cpp b/src/net/eathena/skillhandler.cpp
deleted file mode 100644
index ec8176eef..000000000
--- a/src/net/eathena/skillhandler.cpp
+++ /dev/null
@@ -1,152 +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 "net/eathena/skillhandler.h"
-
-#include "net/eathena/menu.h"
-#include "net/eathena/messageout.h"
-#include "net/eathena/protocolout.h"
-
-#include "debug.h"
-
-extern int packetVersion;
-
-namespace EAthena
-{
-
-SkillHandler::SkillHandler() :
- Ea::SkillHandler()
-{
- skillHandler = this;
-}
-
-SkillHandler::~SkillHandler()
-{
- skillHandler = nullptr;
-}
-
-void SkillHandler::useBeing(const int id, const int level,
- const BeingId beingId) const
-{
- createOutPacket(CMSG_SKILL_USE_BEING);
- outMsg.writeInt16(CAST_S16(level), "skill level");
- outMsg.writeInt16(CAST_S16(id), "skill id");
- outMsg.writeInt32(toInt(beingId, int), "target id");
-}
-
-void SkillHandler::usePos(const int id, const int level,
- const int x, const int y) const
-{
- createOutPacket(CMSG_SKILL_USE_POSITION);
- if (packetVersion >= 20080827 && packetVersion < 20101124)
- {
- outMsg.writeInt32(0, "unused");
- outMsg.writeInt32(0, "unused");
- outMsg.writeInt16(CAST_S16(level), "skill level");
- outMsg.writeInt16(0, "unused");
- outMsg.writeInt16(CAST_S16(id), "skill id");
- outMsg.writeInt16(0, "unused");
- outMsg.writeInt16(CAST_S16(x), "x");
- outMsg.writeInt16(0, "unused");
- outMsg.writeInt8(0, "unused");
- outMsg.writeInt16(CAST_S16(y), "y");
- }
- else
- {
- outMsg.writeInt16(CAST_S16(level), "skill level");
- outMsg.writeInt16(CAST_S16(id), "skill id");
- outMsg.writeInt16(CAST_S16(x), "x");
- outMsg.writeInt16(CAST_S16(y), "y");
- }
-}
-
-void SkillHandler::usePos(const int id, const int level,
- const int x, const int y,
- const std::string &text) const
-{
- createOutPacket(CMSG_SKILL_USE_POSITION_MORE);
- outMsg.writeInt16(CAST_S16(level), "level");
- outMsg.writeInt16(CAST_S16(id), "id");
- outMsg.writeInt16(CAST_S16(x), "x");
- outMsg.writeInt16(CAST_S16(y), "y");
- outMsg.writeString(text, 80, "text");
-}
-
-void SkillHandler::useMap(const int id, const std::string &map) const
-{
- createOutPacket(CMSG_SKILL_USE_MAP);
- outMsg.writeInt16(CAST_S16(id), "skill id");
- outMsg.writeString(map, 16, "map name");
-}
-
-void SkillHandler::getAlchemistRanks() const
-{
- if (packetVersion >= 20041108)
- {
- createOutPacket(CMSG_ALCHEMIST_RANKS);
- }
-}
-
-void SkillHandler::getBlacksmithRanks() const
-{
- if (packetVersion >= 20041108)
- {
- createOutPacket(CMSG_BLACKSMITH_RANKS);
- }
-}
-
-void SkillHandler::getPkRanks() const
-{
- if (packetVersion >= 20050530)
- {
- createOutPacket(CMSG_PK_RANKS);
- }
-}
-
-void SkillHandler::getTaekwonRanks() const
-{
- if (packetVersion >= 20050328)
- {
- createOutPacket(CMSG_TAEKWON_RANKS);
- }
-}
-
-void SkillHandler::feelSaveOk(const int which) const
-{
- if (packetVersion >= 20050817)
- {
- createOutPacket(CMSG_SKILL_FEEL_SAVE_OK);
- outMsg.writeInt8(CAST_S8(which), "which");
- menu = MenuType::Unknown;
- }
-}
-
-void SkillHandler::lessEffects(const bool isLess) const
-{
- if (packetVersion >= 20041115)
- {
- createOutPacket(CMSG_PLAYER_LESS_EFFECTS);
- outMsg.writeInt32(isLess ? 1 : 0, "state");
- }
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/skillhandler.h b/src/net/eathena/skillhandler.h
deleted file mode 100644
index d615dac77..000000000
--- a/src/net/eathena/skillhandler.h
+++ /dev/null
@@ -1,70 +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 NET_EATHENA_SKILLHANDLER_H
-#define NET_EATHENA_SKILLHANDLER_H
-
-#include "net/ea/skillhandler.h"
-
-namespace EAthena
-{
-
-class SkillHandler final : public Ea::SkillHandler
-{
- public:
- SkillHandler();
-
- A_DELETE_COPY(SkillHandler)
-
- ~SkillHandler();
-
- void useBeing(const int id,
- const int level,
- const BeingId beingId) const override final;
-
- void usePos(const int id,
- const int level,
- const int x, const int y) const override final;
-
- void usePos(const int id,
- const int level,
- const int x, const int y,
- const std::string &text) const override final;
-
- void useMap(const int id, const std::string &map) const override final;
-
- void getAlchemistRanks() const override final;
-
- void getBlacksmithRanks() const override final;
-
- void getPkRanks() const override final;
-
- void getTaekwonRanks() const override final;
-
- void feelSaveOk(const int which) const override final;
-
- void lessEffects(const bool isLess) const override final;
-};
-
-} // namespace EAthena
-
-#endif // NET_EATHENA_SKILLHANDLER_H
diff --git a/src/net/eathena/skillrecv.cpp b/src/net/eathena/skillrecv.cpp
deleted file mode 100644
index e4b71a076..000000000
--- a/src/net/eathena/skillrecv.cpp
+++ /dev/null
@@ -1,529 +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 "net/eathena/skillrecv.h"
-
-#include "notifymanager.h"
-
-#include "being/localplayer.h"
-#include "being/playerinfo.h"
-
-#include "const/net/skill.h"
-
-#include "enums/resources/notifytypes.h"
-
-#include "gui/widgets/createwidget.h"
-
-#include "gui/windows/skilldialog.h"
-#include "gui/windows/textselectdialog.h"
-
-#include "listeners/skillwarplistener.h"
-
-#include "net/messagein.h"
-
-#include "net/eathena/menu.h"
-
-#include "resources/iteminfo.h"
-
-#include "resources/db/itemdb.h"
-
-#include "resources/skill/skillinfo.h"
-
-#include "utils/gettext.h"
-#include "utils/stringutils.h"
-
-#include "debug.h"
-
-static const unsigned int RFAIL = 10;
-static const unsigned int RFAIL_SUMMON = 19;
-static const unsigned int RFAIL_NEED_ITEM = 71;
-static const unsigned int RFAIL_NEED_EQUIPMENT = 72;
-static const unsigned int RFAIL_SPIRITS = 74;
-
-extern int serverVersion;
-
-namespace EAthena
-{
-
-void SkillRecv::processPlayerSkills(Net::MessageIn &msg)
-{
- msg.readInt16("len");
- const int sz = (serverVersion >= 15) ? 41 : 37;
- const int skillCount = (msg.getLength() - 4) / sz;
- int updateSkill = 0;
-
- if (skillDialog != nullptr)
- skillDialog->hideSkills(SkillOwner::Player);
- for (int k = 0; k < skillCount; k++)
- {
- const int skillId = msg.readInt16("skill id");
- const SkillType::SkillType inf = static_cast<SkillType::SkillType>(
- msg.readInt32("inf"));
- if (serverVersion >= 15)
- msg.readInt32("inf2");
- const int level = msg.readInt16("skill level");
- const int sp = msg.readInt16("sp");
- const int range = msg.readInt16("range");
- const std::string name = msg.readString(24, "skill name");
- const Modifiable up = fromBool(msg.readUInt8("up flag"), Modifiable);
- const int oldLevel = PlayerInfo::getSkillLevel(skillId);
- if ((oldLevel != 0) && oldLevel != level)
- updateSkill = skillId;
- PlayerInfo::setSkillLevel(skillId, level);
- if (skillDialog != nullptr)
- {
- if (!skillDialog->updateSkill(skillId, range, up, inf, sp))
- {
- skillDialog->addSkill(SkillOwner::Player,
- skillId, name, level, range, up, inf, sp);
- }
- }
- }
- if (skillDialog != nullptr)
- {
- skillDialog->update();
- if (updateSkill != 0)
- skillDialog->playUpdateEffect(updateSkill);
- }
-}
-
-void SkillRecv::processSkillAdd(Net::MessageIn &msg)
-{
- int updateSkill = 0;
- const int skillId = msg.readInt16("skill id");
- const SkillType::SkillType inf = static_cast<SkillType::SkillType>(
- msg.readInt32("inf"));
- const int level = msg.readInt16("skill level");
- const int sp = msg.readInt16("sp");
- const int range = msg.readInt16("range");
- const std::string name = msg.readString(24, "skill name");
- const Modifiable up = fromBool(msg.readUInt8("up flag"), Modifiable);
- const int oldLevel = PlayerInfo::getSkillLevel(skillId);
- if ((oldLevel != 0) && oldLevel != level)
- updateSkill = skillId;
- PlayerInfo::setSkillLevel(skillId, level);
- if (skillDialog != nullptr)
- {
- if (!skillDialog->updateSkill(skillId, range, up, inf, sp))
- {
- skillDialog->addSkill(SkillOwner::Player,
- skillId, name, level, range, up, inf, sp);
- }
- skillDialog->update();
- if (updateSkill != 0)
- skillDialog->playUpdateEffect(updateSkill);
- }
-}
-
-void SkillRecv::processSkillAdd2(Net::MessageIn &msg)
-{
- int updateSkill = 0;
- msg.readInt16("len"); // for now unused
- const int skillId = msg.readInt16("skill id");
- const SkillType::SkillType inf = static_cast<SkillType::SkillType>(
- msg.readInt32("inf"));
- msg.readInt32("inf2");
- const int level = msg.readInt16("skill level");
- const int sp = msg.readInt16("sp");
- const int range = msg.readInt16("range");
- const std::string name = msg.readString(24, "skill name");
- const Modifiable up = fromBool(msg.readUInt8("up flag"), Modifiable);
- const int oldLevel = PlayerInfo::getSkillLevel(skillId);
- if ((oldLevel != 0) && oldLevel != level)
- updateSkill = skillId;
- PlayerInfo::setSkillLevel(skillId, level);
- if (skillDialog != nullptr)
- {
- if (!skillDialog->updateSkill(skillId, range, up, inf, sp))
- {
- skillDialog->addSkill(SkillOwner::Player,
- skillId, name, level, range, up, inf, sp);
- }
- skillDialog->update();
- if (updateSkill != 0)
- skillDialog->playUpdateEffect(updateSkill);
- }
-}
-
-void SkillRecv::processSkillUpdate(Net::MessageIn &msg)
-{
- int updateSkill = 0;
- const int skillId = msg.readInt16("skill id");
- const SkillType::SkillType inf = static_cast<SkillType::SkillType>(
- msg.readInt32("inf"));
- const int level = msg.readInt16("skill level");
- const int sp = msg.readInt16("sp");
- const int range = msg.readInt16("range");
- const Modifiable up = fromBool(msg.readUInt8("up flag"), Modifiable);
- const int oldLevel = PlayerInfo::getSkillLevel(skillId);
- if ((oldLevel != 0) && oldLevel != level)
- updateSkill = skillId;
- PlayerInfo::setSkillLevel(skillId, level);
- if (skillDialog != nullptr)
- {
- if (!skillDialog->updateSkill(skillId, range, up, inf, sp))
- {
- skillDialog->addSkill(SkillOwner::Player,
- skillId, "", level, range, up, inf, sp);
- }
- skillDialog->update();
- if (updateSkill != 0)
- skillDialog->playUpdateEffect(updateSkill);
- }
-}
-
-void SkillRecv::processSkillUpdate2(Net::MessageIn &msg)
-{
- int updateSkill = 0;
- msg.readInt16("len"); // for now unused
- const int skillId = msg.readInt16("skill id");
- const SkillType::SkillType inf = static_cast<SkillType::SkillType>(
- msg.readInt32("inf"));
- msg.readInt32("inf2");
- const int level = msg.readInt16("skill level");
- const int sp = msg.readInt16("sp");
- const int range = msg.readInt16("range");
- const Modifiable up = fromBool(msg.readUInt8("up flag"), Modifiable);
- const int oldLevel = PlayerInfo::getSkillLevel(skillId);
- if ((oldLevel != 0) && oldLevel != level)
- updateSkill = skillId;
- PlayerInfo::setSkillLevel(skillId, level);
- if (skillDialog != nullptr)
- {
- if (!skillDialog->updateSkill(skillId, range, up, inf, sp))
- {
- skillDialog->addSkill(SkillOwner::Player,
- skillId, "", level, range, up, inf, sp);
- }
- skillDialog->update();
- if (updateSkill != 0)
- skillDialog->playUpdateEffect(updateSkill);
- }
-}
-
-void SkillRecv::processSkillDelete(Net::MessageIn &msg)
-{
- int updateSkill = 0;
- const int skillId = msg.readInt16("skill id");
- const int oldLevel = PlayerInfo::getSkillLevel(skillId);
- if (oldLevel != 0)
- updateSkill = skillId;
- PlayerInfo::setSkillLevel(skillId, 0);
- if (skillDialog != nullptr)
- {
- skillDialog->removeSkill(skillId);
- skillDialog->update();
- if (updateSkill != 0)
- skillDialog->playRemoveEffect(updateSkill);
- }
-}
-
-void SkillRecv::processSkillCoolDown(Net::MessageIn &msg)
-{
- const int skillId = msg.readInt16("skill id");
- const int duration = msg.readInt32("duration");
- if (skillDialog != nullptr)
- skillDialog->setSkillDuration(SkillOwner::Player, skillId, duration);
-}
-
-void SkillRecv::processSkillCoolDownList(Net::MessageIn &msg)
-{
- int packetLen;
- if (msg.getVersion() >= 20120604)
- packetLen = 10;
- else
- packetLen = 6;
- const int count = (msg.readInt16("len") - 4) / packetLen;
- for (int f = 0; f < count; f ++)
- {
- const int skillId = msg.readInt16("skill id");
- if (msg.getVersion() >= 20120604)
- msg.readInt32("total");
- const int duration = msg.readInt32("duration");
- if (skillDialog != nullptr)
- {
- skillDialog->setSkillDuration(SkillOwner::Player,
- skillId, duration);
- }
- }
-}
-
-void SkillRecv::processSkillFailed(Net::MessageIn &msg)
-{
- // Action failed (ex. sit because you have not reached the
- // right level)
- const int skillId = msg.readInt16("skill id");
- const int bskill = msg.readInt32("btype");
- const signed char success = msg.readUInt8("success");
- const signed char reason = msg.readUInt8("reason");
- if (success != CAST_S32(SKILL_FAILED)
- && bskill == CAST_S32(BSKILL_EMOTE))
- {
- logger->log("Action: %d/%d", bskill, success);
- }
-
- if (localPlayer != nullptr)
- localPlayer->stopCast(true);
- std::string txt;
- if (success == CAST_S32(SKILL_FAILED) && bskill != 0)
- {
- if ((localPlayer != nullptr) && bskill == CAST_S32(BSKILL_EMOTE)
- && reason == CAST_S32(RFAIL_SKILLDEP))
- {
- localPlayer->stopAdvert();
- }
-
- const SkillInfo *const info = skillDialog->getSkill(bskill);
- if (info != nullptr)
- {
- txt = info->errorText;
- }
- else
- {
- // TRANSLATORS: skill error message
- txt = strprintf(_("Unknown skill error: %d"), bskill);
- }
- }
- else
- {
- const SkillInfo *const info = skillDialog->getSkill(skillId);
- if (info != nullptr)
- {
- txt = info->errorText + ".";
- }
- else
- {
- // TRANSLATORS: skill error message
- txt = strprintf(_("Unknown skill error: %d."), skillId);
- }
- }
-
- txt.append(" ");
- switch (reason)
- {
- case RFAIL_SKILLDEP:
- // TRANSLATORS: error message
- txt.append(_("You have not yet reached a high enough lvl!"));
- break;
- case RFAIL_INSUFHP:
- // TRANSLATORS: error message
- txt.append(_("Insufficient HP!"));
- break;
- case RFAIL_INSUFSP:
- // TRANSLATORS: error message
- txt.append(_("Insufficient SP!"));
- break;
- case RFAIL_NOMEMO:
- // TRANSLATORS: error message
- txt.append(_("You have no memos!"));
- break;
- case RFAIL_SKILLDELAY:
- // TRANSLATORS: error message
- txt.append(_("You cannot do that right now!"));
- break;
- case RFAIL_ZENY:
- // TRANSLATORS: error message
- txt.append(_("Seems you need more money... ;-)"));
- break;
- case RFAIL_WEAPON:
- // TRANSLATORS: error message
- txt.append(_("You cannot use this skill with that "
- "kind of weapon!"));
- break;
- case RFAIL_REDGEM:
- // TRANSLATORS: error message
- txt.append(_("You need another red gem!"));
- break;
- case RFAIL_BLUEGEM:
- // TRANSLATORS: error message
- txt.append(_("You need another blue gem!"));
- break;
- case RFAIL_OVERWEIGHT:
- // TRANSLATORS: error message
- txt.append(_("You're carrying to much to do this!"));
- break;
- case RFAIL_SUMMON:
- // TRANSLATORS: error message
- txt.append(_("Fail summon."));
- break;
- case RFAIL_SPIRITS:
- // TRANSLATORS: error message
- txt.append(_("Need spirits."));
- break;
- case RFAIL_NEED_EQUIPMENT:
- {
- const int itemId = bskill >> 16U;
- const int amount = bskill & 0xFFFFU;
- const ItemInfo &info = ItemDB::get(itemId);
- if (amount == 1)
- {
- // TRANSLATORS: skill error message
- txt.append(strprintf(_("Need equipment %s."),
- info.getLink().c_str()));
- }
- else
- {
- // TRANSLATORS: skill error message
- txt.append(strprintf(_("Need equipment %s and amount %d"),
- info.getLink().c_str(),
- amount));
- }
- break;
- }
- case RFAIL_NEED_ITEM:
- {
- const int itemId = bskill >> 16U;
- const int amount = bskill & 0xFFFFU;
- const ItemInfo &info = ItemDB::get(itemId);
- if (amount == 1)
- {
- // TRANSLATORS: skill error message
- txt.append(strprintf(_("Need item %s."),
- info.getLink().c_str()));
- }
- else
- {
- // TRANSLATORS: skill error message
- txt.append(strprintf(_("Need item %s and amount %d"),
- info.getLink().c_str(),
- amount));
- }
- break;
- }
- case RFAIL:
- {
- // TRANSLATORS: error message
- txt.append(_("Skill failed!"));
- break;
- }
-
- default:
- UNIMPLEMENTEDPACKETFIELD(reason);
- break;
- }
-
- NotifyManager::notify(NotifyTypes::SKILL_FAIL_MESSAGE, txt);
-}
-
-void SkillRecv::processSkillWarpPoint(Net::MessageIn &msg)
-{
- const int skillId = msg.readInt16("skill id");
-
- TextSelectDialog *const dialog = CREATEWIDGETR(TextSelectDialog,
- // TRANSLATORS: warp select window name
- _("Select warp target"),
- // TRANSLATORS: warp select button
- _("Warp"),
- AllowQuit_false);
- skillWarpListener.setDialog(dialog);
- skillWarpListener.setSkill(skillId);
- dialog->addActionListener(&skillWarpListener);
- for (int f = 0; f < 4; f ++)
- dialog->addText(msg.readString(16, "map name"));
-}
-
-void SkillRecv::processSkillMemoMessage(Net::MessageIn &msg)
-{
- const int type = msg.readUInt8("type");
- switch (type)
- {
- case 0:
- NotifyManager::notify(NotifyTypes::SKILL_MEMO_SAVED);
- break;
- case 1:
- NotifyManager::notify(NotifyTypes::SKILL_MEMO_ERROR_LEVEL);
- break;
- case 2:
- NotifyManager::notify(NotifyTypes::SKILL_MEMO_ERROR_SKILL);
- break;
- default:
- UNIMPLEMENTEDPACKETFIELD(type);
- break;
- }
-}
-
-void SkillRecv::processSkillProduceMixList(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
-
- const int count = (msg.readInt16("len") - 8) / 8;
- for (int f = 0; f < count; f ++)
- {
- msg.readInt16("item id");
- for (int d = 0; d < 3; d ++)
- msg.readInt16("material id");
- }
-}
-
-void SkillRecv::processSkillProduceEffect(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
-
- msg.readInt16("flag");
- msg.readInt16("item id");
-}
-
-void SkillRecv::processSkillUnitUpdate(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
-
- msg.readBeingId("being id");
-}
-
-void SkillRecv::processSkillArrowCreateList(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
-
- const int count = (msg.readInt16("len") - 4) / 2;
- for (int f = 0; f < count; f ++)
- msg.readInt16("item id");
-}
-
-void SkillRecv::processSkillAutoSpells(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
-
- for (int f = 0; f < 7; f ++)
- msg.readInt32("skill id");
-
- menu = MenuType::AutoSpell;
-}
-
-void SkillRecv::processSkillDevotionEffect(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
-
- msg.readBeingId("being id");
- for (int f = 0; f < 5; f ++)
- msg.readInt32("devotee id");
- msg.readInt16("range");
-}
-
-void SkillRecv::processSkillItemListWindow(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
-
- msg.readInt32("skill level");
- msg.readInt32("unused");
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/skillrecv.h b/src/net/eathena/skillrecv.h
deleted file mode 100644
index 5facd510d..000000000
--- a/src/net/eathena/skillrecv.h
+++ /dev/null
@@ -1,56 +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 NET_EATHENA_SKILLRECV_H
-#define NET_EATHENA_SKILLRECV_H
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-namespace EAthena
-{
- namespace SkillRecv
- {
- void processSkillFailed(Net::MessageIn &msg);
- void processPlayerSkills(Net::MessageIn &msg);
- void processSkillCoolDown(Net::MessageIn &msg);
- void processSkillCoolDownList(Net::MessageIn &msg);
- void processSkillAdd(Net::MessageIn &msg);
- void processSkillAdd2(Net::MessageIn &msg);
- void processSkillUpdate(Net::MessageIn &msg);
- void processSkillUpdate2(Net::MessageIn &msg);
- void processSkillDelete(Net::MessageIn &msg);
- void processSkillWarpPoint(Net::MessageIn &msg);
- void processSkillMemoMessage(Net::MessageIn &msg);
- void processSkillProduceMixList(Net::MessageIn &msg);
- void processSkillProduceEffect(Net::MessageIn &msg);
- void processSkillUnitUpdate(Net::MessageIn &msg);
- void processSkillArrowCreateList(Net::MessageIn &msg);
- void processSkillAutoSpells(Net::MessageIn &msg);
- void processSkillDevotionEffect(Net::MessageIn &msg);
- void processSkillItemListWindow(Net::MessageIn &msg);
- } // namespace SkillRecv
-} // namespace EAthena
-
-#endif // NET_EATHENA_SKILLRECV_H
diff --git a/src/net/eathena/sp.h b/src/net/eathena/sp.h
deleted file mode 100644
index 1d983e0ea..000000000
--- a/src/net/eathena/sp.h
+++ /dev/null
@@ -1,271 +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 NET_EATHENA_SP_H
-#define NET_EATHENA_SP_H
-
-namespace Sp
-{
- enum
- {
- SPEED = 0,
- BASEEXP = 1,
- JOBEXP = 2,
- KARMA = 3,
- MANNER = 4,
- HP = 5,
- MAXHP = 6,
- SP = 7,
- MAXSP = 8,
- STATUSPOINT = 9,
- VAL10 = 10,
- BASELEVEL = 11,
- SKILLPOINT = 12,
- STR = 13,
- AGI = 14,
- VIT = 15,
- INT = 16,
- DEX = 17,
- LUK = 18,
- CLASS = 19,
- ZENY = 20,
- SEX = 21,
- NEXTBASEEXP = 22,
- NEXTJOBEXP = 23,
- WEIGHT = 24,
- MAXWEIGHT = 25,
- VAL26 = 26,
- VAL27 = 27,
- VAL28 = 28,
- VAL29 = 29,
- VAL30 = 30,
- VAL31 = 31,
- USTR = 32,
- UAGI = 33,
- UVIT = 34,
- UINT = 35,
- UDEX = 36,
- ULUK = 37,
- VAL38 = 38,
- VAL39 = 39,
- VAL40 = 40,
- ATK1 = 41,
- ATK2 = 42,
- MATK1 = 43,
- MATK2 = 44,
- DEF1 = 45,
- DEF2 = 46,
- MDEF1 = 47,
- MDEF2 = 48,
- HIT = 49,
- FLEE1 = 50,
- FLEE2 = 51,
- CRITICAL = 52,
- ASPD = 53,
- VAL54 = 54,
- JOBLEVEL = 55,
- UPPER = 56,
- PARTNER = 57,
- CART = 58,
- FAME = 59,
- UNBREAKABLE = 60,
-
- CARTINFO = 99,
-
- BASEJOB = 119,
- BASECLASS = 120,
- KILLERRID = 121,
- KILLEDRID = 122,
- SLOTCHANGE = 123,
- CHARRENAME = 124,
- MOD_EXP = 125,
- MOD_DROP = 126,
- MOD_DEATH = 127,
-
- MERCFLEE = 165,
-
- MERCKILLS = 189,
- MERCFAITH = 190,
-
- ATTACKRANGE = 1000,
- ATKELE = 1001,
- DEFELE = 1002,
- CASTRATE = 1003,
- MAXHPRATE = 1004,
- MAXSPRATE = 1005,
- SPRATE = 1006,
-
- ADDELE = 1007,
- ADDRACE = 1008,
- ADDSIZE = 1009,
- SUBELE = 1010,
- SUBRACE = 1011,
- ADDEFF = 1012,
- RESEFF = 1013,
- BASE_ATK = 1014,
- ASPD_RATE = 1015,
- HP_RECOV_RATE = 1016,
- RECOV_RATE = 1017,
- SPEED_RATE = 1018,
- CRITICAL_DEF = 1019,
- NEAR_ATK_DEF = 1020,
- LONG_ATK_DEF = 1021,
- DOUBLE_RATE = 1022,
- DOUBLE_ADD_RATE = 1023,
- SKILL_HEAL = 1024,
- MATK_RATE = 1025,
- IGNORE_DEF_ELE = 1026,
- IGNORE_DEF_RACE = 1027,
- ATK_RATE = 1028,
- SPEED_ADDRATE = 1029,
- REGEN_RATE = 1030,
- MAGIC_ATK_DEF = 1031,
- MISC_ATK_DEF = 1032,
- IGNORE_MDEF_ELE = 1033,
- IGNORE_MDEF_RACE = 1034,
- MAGIC_ADDELE = 1035,
- MAGIC_ADDRACE = 1036,
- MAGIC_ADDSIZE = 1037,
- PERFECT_HIT_RATE = 1038,
- PERFECT_HIT_ADD_RATE = 1039,
- CRITICAL_RATE = 1040,
- GET_ZENY_NUM = 1041,
- ADD_GET_ZENY_NUM = 1042,
- ADD_DAMAGE_CLASS = 1043,
- ADD_MAGIC_DAMAGE_CLASS = 1044,
- ADD_DEF_CLASS = 1045,
- ADD_MDEF_CLASS = 1046,
- ADD_MONSTER_DROP_ITEM = 1047,
- DEF_RATIO_ATK_ELE = 1048,
- DEF_RATIO_ATK_RACE = 1049,
- UNBREAKABLE_GARMENT = 1050,
- HIT_RATE = 1051,
- FLEE_RATE = 1052,
- FLEE2_RATE = 1053,
- DEF_RATE = 1054,
- DEF2_RATE = 1055,
- MDEF_RATE = 1056,
- MDEF2_RATE = 1057,
- SPLASH_RANGE = 1058,
- SPLASH_ADD_RANGE = 1059,
- AUTOSPELL = 1060,
- HP_DRAIN_RATE = 1061,
- DRAIN_RATE = 1062,
- SHORT_WEAPON_DAMAGE_RETURN = 1063,
- LONG_WEAPON_DAMAGE_RETURN = 1064,
- WEAPON_COMA_ELE = 1065,
- WEAPON_COMA_RACE = 1066,
- ADDEFF2 = 1067,
- BREAK_WEAPON_RATE = 1068,
- BREAK_ARMOR_RATE = 1069,
- ADD_STEAL_RATE = 1070,
- MAGIC_DAMAGE_RETURN = 1071,
-
- ALL_STATS = 1073,
- AGI_VIT = 1074,
- AGI_DEX_STR = 1075,
- PERFECT_HIDE = 1076,
- NO_KNOCKBACK = 1077,
- CLASSCHANGE = 1078,
- HP_DRAIN_VALUE = 1079,
- DRAIN_VALUE = 1080,
- WEAPON_ATK = 1081,
- WEAPON_ATK_RATE = 1082,
- DELAYRATE = 1083,
- HP_DRAIN_RATE_RACE = 1084,
- DRAIN_RATE_RACE = 1085,
- IGNORE_MDEF_RATE = 1086,
- IGNORE_DEF_RATE = 1087,
- SKILL_HEAL2 = 1088,
- ADDEFF_ONSKILL = 1089,
- ADD_HEAL_RATE = 1090,
- ADD_HEAL2_RATE = 1091,
- HP_VANISH_RATE = 1092,
-
- RESTART_FULL_RECOVER = 2000,
- NO_CASTCANCEL = 2001,
- NO_SIZEFIX = 2002,
- NO_MAGIC_DAMAGE = 2003,
- NO_WEAPON_DAMAGE = 2004,
- NO_GEMSTONE = 2005,
- NO_CASTCANCEL2 = 2006,
- NO_MISC_DAMAGE = 2007,
- UNBREAKABLE_WEAPON = 2008,
- UNBREAKABLE_ARMOR = 2009,
- UNBREAKABLE_HELM = 2010,
- UNBREAKABLE_SHIELD = 2011,
- LONG_ATK_RATE = 2012,
-
- CRIT_ATK_RATE = 2013,
- CRITICAL_ADDRACE = 2014,
- NO_REGEN = 2015,
- ADDEFF_WHENHIT = 2016,
- AUTOSPELL_WHENHIT = 2017,
- SKILL_ATK = 2018,
- UNSTRIPABLE = 2019,
- AUTOSPELL_ONSKILL = 2020,
- GAIN_VALUE = 2021,
- HP_REGEN_RATE = 2022,
- HP_LOSS_RATE = 2023,
- ADDRACE2 = 2024,
- HP_GAIN_VALUE = 2025,
- SUBSIZE = 2026,
- HP_DRAIN_VALUE_RACE = 2027,
- ADD_ITEM_HEAL_RATE = 2028,
- DRAIN_VALUE_RACE = 2029,
- EXP_ADDRACE = 2030,
- GAIN_RACE = 2031,
- SUBRACE2 = 2032,
- UNBREAKABLE_SHOES = 2033,
- UNSTRIPABLE_WEAPON = 2034,
- UNSTRIPABLE_ARMOR = 2035,
- UNSTRIPABLE_HELM = 2036,
- UNSTRIPABLE_SHIELD = 2037,
- INTRAVISION = 2038,
- ADD_MONSTER_DROP_CHAINITEM = 2039,
- LOSS_RATE = 2040,
- ADD_SKILL_BLOW = 2041,
- VANISH_RATE = 2042,
- MAGIC_GAIN_VALUE = 2043,
- MAGIC_HP_GAIN_VALUE = 2044,
- ADD_CLASS_DROP_ITEM = 2045,
- EMATK = 2046,
- GAIN_RACE_ATTACK = 2047,
- HP_GAIN_RACE_ATTACK = 2048,
- SKILL_USE_RATE = 2049,
- SKILL_COOLDOWN = 2050,
- SKILL_FIXEDCAST = 2051,
- SKILL_VARIABLECAST = 2052,
- FIXCASTRATE = 2053,
- VARCASTRATE = 2054,
- SKILL_USE_SP = 2055,
- MAGIC_ATK_ELE = 2056,
- ADD_FIXEDCAST = 2057,
- ADD_VARIABLECAST = 2058,
- SET_DEF_RACE = 2059,
- SET_MDEF_RACE = 2060,
- RACE_TOLERANCE = 2061,
- ADDMAXWEIGHT = 2062
- };
-} // namespace Sp
-
-#endif // NET_EATHENA_SP_H
diff --git a/src/net/eathena/sprite.h b/src/net/eathena/sprite.h
deleted file mode 100644
index ff259251b..000000000
--- a/src/net/eathena/sprite.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 NET_EATHENA_SPRITE_H
-#define NET_EATHENA_SPRITE_H
-
-enum
-{
- SPRITE_BASE = 0,
- SPRITE_HAIR = 1,
- SPRITE_WEAPON = 2,
- SPRITE_HEAD_BOTTOM = 3,
- SPRITE_HEAD_TOP = 4,
- SPRITE_HEAD_MID = 5,
- SPRITE_HAIR_COLOR = 6,
- SPRITE_CLOTHES_COLOR = 7,
- SPRITE_SHIELD = 8,
- SPRITE_SHOES = 9,
- SPRITE_BODY = 10,
- SPRITE_FLOOR = 11,
- SPRITE_ROBE = 12,
- SPRITE_EVOL2 = 13, // in new versions also BODY2
- SPRITE_EVOL3 = 14,
- SPRITE_EVOL4 = 15,
- SPRITE_EVOL5 = 16,
- SPRITE_EVOL6 = 17,
- SPRITE_VECTOREND
-};
-
-#endif // NET_EATHENA_SPRITE_H
diff --git a/src/net/eathena/tradehandler.cpp b/src/net/eathena/tradehandler.cpp
deleted file mode 100644
index 5c6877f5e..000000000
--- a/src/net/eathena/tradehandler.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 "net/eathena/tradehandler.h"
-
-#include "being/playerinfo.h"
-
-#include "const/net/inventory.h"
-
-#include "net/eathena/messageout.h"
-#include "net/eathena/protocolout.h"
-#include "net/eathena/traderecv.h"
-
-#include "resources/item/item.h"
-
-#include "debug.h"
-
-namespace EAthena
-{
-
-TradeHandler::TradeHandler() :
- Ea::TradeHandler()
-{
- tradeHandler = this;
- TradeRecv::mItemIndex = -1;
- TradeRecv::mQuantity = 0;
-}
-
-TradeHandler::~TradeHandler()
-{
- tradeHandler = nullptr;
-}
-
-void TradeHandler::request(const Being *const being) const
-{
- if (being == nullptr)
- return;
-
- createOutPacket(CMSG_TRADE_REQUEST);
- outMsg.writeBeingId(being->getId(), "player id");
-}
-
-void TradeHandler::respond(const bool accept) const
-{
- if (!accept)
- PlayerInfo::setTrading(Trading_false);
-
- createOutPacket(CMSG_TRADE_RESPONSE);
- outMsg.writeInt8(CAST_S8(accept ? 3 : 4), "accept");
-}
-
-void TradeHandler::addItem(const Item *const item, const int amount) const
-{
- if (item == nullptr)
- return;
-
- TradeRecv::mItemIndex = item->getInvIndex();
- TradeRecv::mQuantity = amount;
- createOutPacket(CMSG_TRADE_ITEM_ADD_REQUEST);
- outMsg.writeInt16(CAST_S16(
- TradeRecv::mItemIndex + INVENTORY_OFFSET),
- "index");
- outMsg.writeInt32(amount, "amount");
-}
-
-void TradeHandler::setMoney(const int amount) const
-{
- createOutPacket(CMSG_TRADE_ITEM_ADD_REQUEST);
- outMsg.writeInt16(0, "index");
- outMsg.writeInt32(amount, "amount");
-}
-
-void TradeHandler::confirm() const
-{
- createOutPacket(CMSG_TRADE_ADD_COMPLETE);
-}
-
-void TradeHandler::finish() const
-{
- createOutPacket(CMSG_TRADE_OK);
-}
-
-void TradeHandler::cancel() const
-{
- createOutPacket(CMSG_TRADE_CANCEL_REQUEST);
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/tradehandler.h b/src/net/eathena/tradehandler.h
deleted file mode 100644
index 0bf5b2eb2..000000000
--- a/src/net/eathena/tradehandler.h
+++ /dev/null
@@ -1,58 +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 NET_EATHENA_TRADEHANDLER_H
-#define NET_EATHENA_TRADEHANDLER_H
-
-#include "net/ea/tradehandler.h"
-
-namespace EAthena
-{
-
-class TradeHandler final : public Ea::TradeHandler
-{
- public:
- TradeHandler();
-
- A_DELETE_COPY(TradeHandler)
-
- ~TradeHandler();
-
- void request(const Being *const being) const override final;
-
- void respond(const bool accept) const override final;
-
- void addItem(const Item *const item,
- const int amount) const override final;
-
- void setMoney(const int amount) const override final;
-
- void confirm() const override final;
-
- void finish() const override final;
-
- void cancel() const override final;
-};
-
-} // namespace EAthena
-
-#endif // NET_EATHENA_TRADEHANDLER_H
diff --git a/src/net/eathena/traderecv.cpp b/src/net/eathena/traderecv.cpp
deleted file mode 100644
index ac64d4fb0..000000000
--- a/src/net/eathena/traderecv.cpp
+++ /dev/null
@@ -1,185 +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 "net/eathena/traderecv.h"
-
-#include "itemcolormanager.h"
-#include "notifymanager.h"
-
-#include "being/playerinfo.h"
-
-#include "enums/resources/notifytypes.h"
-
-#include "gui/windows/tradewindow.h"
-
-#include "net/messagein.h"
-
-#include "net/ea/traderecv.h"
-
-#include "resources/inventory/inventory.h"
-
-#include "resources/item/item.h"
-#include "resources/item/itemoptionslist.h"
-
-#include "debug.h"
-
-extern int serverVersion;
-
-namespace EAthena
-{
-
-namespace TradeRecv
-{
- int mQuantity = 0;
- int mItemIndex = -1;
-} // namespace TradeRecv
-
-void TradeRecv::processTradeRequest(Net::MessageIn &msg)
-{
- const std::string &partner = msg.readString(24, "name");
- if (msg.getVersion() >= 6)
- {
- msg.readInt32("char id");
- msg.readInt16("base level");
- }
- Ea::TradeRecv::processTradeRequestContinue(partner);
-}
-
-void TradeRecv::processTradeResponse(Net::MessageIn &msg)
-{
- const uint8_t type = msg.readUInt8("type");
- msg.readInt32("char id");
- msg.readInt16("base level");
- Ea::TradeRecv::processTradeResponseContinue(type);
-}
-
-void TradeRecv::processTradeItemAdd(Net::MessageIn &msg)
-{
- const int type = msg.readInt16("type");
- ItemTypeT itemType = ItemType::Unknown;
- if (msg.getVersion() >= 20100223)
- {
- itemType = static_cast<ItemTypeT>(
- msg.readUInt8("item type"));
- }
- const int amount = msg.readInt32("amount");
- const uint8_t identify = msg.readUInt8("identify");
- const Damaged damaged = fromBool(msg.readUInt8("attribute"), Damaged);
- const uint8_t refine = msg.readUInt8("refine");
- int cards[maxCards];
- for (int f = 0; f < maxCards; f++)
- cards[f] = msg.readUInt16("card");
- ItemOptionsList *options = nullptr;
- if (msg.getVersion() >= 20150226)
- {
- options = new ItemOptionsList;
- for (int f = 0; f < 5; f ++)
- {
- const uint16_t idx = msg.readInt16("option index");
- const uint16_t val = msg.readInt16("option value");
- msg.readUInt8("option param");
- options->add(idx, val);
- }
- }
-
- if (tradeWindow != nullptr)
- {
- if (type == 0)
- {
- tradeWindow->setMoney(amount);
- }
- else
- {
- tradeWindow->addItem2(type,
- itemType,
- cards,
- options,
- 4,
- false,
- amount,
- refine,
- ItemColorManager::getColorFromCards(&cards[0]),
- fromBool(identify, Identified),
- damaged,
- Favorite_false,
- Equipm_false);
- }
- }
- delete options;
-}
-
-void TradeRecv::processTradeItemAddResponse(Net::MessageIn &msg)
-{
- msg.readInt16("index");
- const uint8_t res = msg.readUInt8("fail");
- switch (res)
- {
- case 0: // Successfully added item
- case 9: // silent added item
- {
- Item *const item = PlayerInfo::getInventory()->getItem(
- mItemIndex);
- if (item == nullptr)
- return;
- if (tradeWindow != nullptr)
- {
- tradeWindow->addItem2(item->getId(),
- item->getType(),
- item->getCards(),
- item->getOptions(),
- 4,
- true,
- mQuantity,
- item->getRefine(),
- item->getColor(),
- item->getIdentified(),
- item->getDamaged(),
- item->getFavorite(),
- item->isEquipment());
- }
- item->increaseQuantity(-mQuantity);
- mItemIndex = -1;
- mQuantity = 0;
- break;
- }
- case 1:
- // Add item failed - player overweighted
- NotifyManager::notify(NotifyTypes::
- TRADE_ADD_PARTNER_OVER_WEIGHT);
- break;
- case 2:
- NotifyManager::notify(NotifyTypes::TRADE_ADD_ERROR);
- break;
- default:
- NotifyManager::notify(NotifyTypes::TRADE_ADD_ERROR);
- UNIMPLEMENTEDPACKETFIELD(res);
- break;
- }
-}
-
-void TradeRecv::processTradeUndo(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- // +++ here need clear trade window from partner side?
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/traderecv.h b/src/net/eathena/traderecv.h
deleted file mode 100644
index 2c06db5ae..000000000
--- a/src/net/eathena/traderecv.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 NET_EATHENA_TRADERECV_H
-#define NET_EATHENA_TRADERECV_H
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-namespace EAthena
-{
- namespace TradeRecv
- {
- extern int mQuantity;
- extern int mItemIndex;
-
- void processTradeRequest(Net::MessageIn &msg);
- void processTradeResponse(Net::MessageIn &msg);
- void processTradeUndo(Net::MessageIn &msg);
- void processTradeItemAdd(Net::MessageIn &msg);
- void processTradeItemAddResponse(Net::MessageIn &msg);
- } // namespace TradeRecv
-
-} // namespace EAthena
-
-#endif // NET_EATHENA_TRADERECV_H
diff --git a/src/net/eathena/updateprotocol.cpp b/src/net/eathena/updateprotocol.cpp
deleted file mode 100644
index ce9148d1e..000000000
--- a/src/net/eathena/updateprotocol.cpp
+++ /dev/null
@@ -1,57 +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/>.
- */
-
-#include "net/eathena/updateprotocol.h"
-
-#include "logger.h"
-
-#include "net/eathena/network.h"
-#include "net/eathena/protocolout.h"
-
-#include "debug.h"
-
-extern int packetVersion;
-extern int serverVersion;
-extern int evolPacketOffset;
-
-namespace EAthena
-{
-
-void updateProtocol()
-{
- logger->log("packet version: %d", packetVersion);
-#define PACKETS_UPDATE
-#include "net/protocoloutupdate.h"
-#include "net/eathena/packetsout.inc"
-#undef packet
- Network *const network = Network::mInstance;
- if (network != nullptr)
- {
- network->clearHandlers();
- network->registerHandlers();
- network->registerFakeHandlers();
- }
-}
-
-PACKETSOUT_VOID
-PROTOCOLOUTUPDATE_VOID
-PROTOCOLOUT_VOID
-
-} // namespace EAthena
diff --git a/src/net/eathena/updateprotocol.h b/src/net/eathena/updateprotocol.h
deleted file mode 100644
index 17960d0e6..000000000
--- a/src/net/eathena/updateprotocol.h
+++ /dev/null
@@ -1,29 +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 NET_EATHENA_UPDATEPROTOCOL_H
-#define NET_EATHENA_UPDATEPROTOCOL_H
-
-namespace EAthena
-{
- void updateProtocol();
-} // namespace EAthena
-
-#endif // NET_EATHENA_UPDATEPROTOCOL_H
diff --git a/src/net/eathena/vendinghandler.cpp b/src/net/eathena/vendinghandler.cpp
deleted file mode 100644
index 73fa5d12b..000000000
--- a/src/net/eathena/vendinghandler.cpp
+++ /dev/null
@@ -1,150 +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 "net/eathena/vendinghandler.h"
-
-#include "being/being.h"
-#include "being/playerinfo.h"
-
-#include "const/net/inventory.h"
-
-#include "net/eathena/messageout.h"
-#include "net/eathena/protocolout.h"
-#include "net/eathena/vendingrecv.h"
-
-#include "utils/foreach.h"
-
-#include "resources/item/shopitem.h"
-
-#include "debug.h"
-
-namespace EAthena
-{
-
-VendingHandler::VendingHandler()
-{
- vendingHandler = this;
- VendingRecv::mBuyDialog = nullptr;
-}
-
-VendingHandler::~VendingHandler()
-{
- vendingHandler = nullptr;
-}
-
-void VendingHandler::close() const
-{
- createOutPacket(CMSG_VENDING_CLOSE);
- PlayerInfo::enableVending(false);
-}
-
-void VendingHandler::open(const Being *const being) const
-{
- if (being == nullptr)
- return;
-
- createOutPacket(CMSG_VENDING_LIST_REQ);
- outMsg.writeBeingId(being->getId(), "account id");
-}
-
-void VendingHandler::buy(const Being *const being,
- const int index,
- const int amount) const
-{
- if (being == nullptr)
- return;
-
- createOutPacket(CMSG_VENDING_BUY);
- outMsg.writeInt16(12, "len");
- outMsg.writeBeingId(being->getId(), "account id");
- outMsg.writeInt16(CAST_S16(amount), "amount");
- outMsg.writeInt16(CAST_S16(index), "index");
-}
-
-void VendingHandler::buyItems(const Being *const being,
- const STD_VECTOR<ShopItem*> &items) const
-{
- int cnt = 0;
- const int pairSize = 4;
-
- FOR_EACH (STD_VECTOR<ShopItem*>::const_iterator, it, items)
- {
- ShopItem *const item = *it;
- const int usedQuantity = item->getUsedQuantity();
- if (usedQuantity == 0)
- continue;
- cnt ++;
- }
-
- if (cnt > 100)
- return;
-
- createOutPacket(CMSG_VENDING_BUY);
- outMsg.writeInt16(CAST_S16(4 + 4 + pairSize * cnt), "len");
- outMsg.writeBeingId(being->getId(), "account id");
- FOR_EACH (STD_VECTOR<ShopItem*>::const_iterator, it, items)
- {
- ShopItem *const item = *it;
- const int usedQuantity = item->getUsedQuantity();
- if (usedQuantity == 0)
- continue;
- item->increaseQuantity(usedQuantity);
- item->increaseUsedQuantity(-usedQuantity);
- item->update();
- outMsg.writeInt16(CAST_S16(usedQuantity), "amount");
- outMsg.writeInt16(CAST_S16(item->getInvIndex()), "index");
- }
-}
-
-void VendingHandler::buy2(const Being *const being,
- const int vendId,
- const int index,
- const int amount) const
-{
- if (being == nullptr)
- return;
-
- createOutPacket(CMSG_VENDING_BUY2);
- outMsg.writeInt16(16, "len");
- outMsg.writeBeingId(being->getId(), "account id");
- outMsg.writeInt32(vendId, "vend id");
- outMsg.writeInt16(CAST_S16(amount), "amount");
- outMsg.writeInt16(CAST_S16(index), "index");
-}
-
-void VendingHandler::createShop(const std::string &name,
- const bool flag,
- const STD_VECTOR<ShopItem*> &items) const
-{
- createOutPacket(CMSG_VENDING_CREATE_SHOP);
- outMsg.writeInt16(CAST_S16(85 + items.size() * 8), "len");
- outMsg.writeString(name, 80, "shop name");
- outMsg.writeInt8(CAST_S8(flag ? 1 : 0), "flag");
- FOR_EACH (STD_VECTOR<ShopItem*>::const_iterator, it, items)
- {
- const ShopItem *const item = *it;
- outMsg.writeInt16(CAST_S16(
- item->getInvIndex() + INVENTORY_OFFSET), "index");
- outMsg.writeInt16(CAST_S16(item->getQuantity()), "amount");
- outMsg.writeInt32(item->getPrice(), "price");
- }
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/vendinghandler.h b/src/net/eathena/vendinghandler.h
deleted file mode 100644
index 7929a6d19..000000000
--- a/src/net/eathena/vendinghandler.h
+++ /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/>.
- */
-
-#ifndef NET_EATHENA_VENDINGHANDLER_H
-#define NET_EATHENA_VENDINGHANDLER_H
-
-#include "net/vendinghandler.h"
-
-namespace EAthena
-{
-class VendingHandler final : public Net::VendingHandler
-{
- public:
- VendingHandler();
-
- A_DELETE_COPY(VendingHandler)
-
- ~VendingHandler();
-
- void close() const override final;
-
- void open(const Being *const being) const override final;
-
- void buy(const Being *const being,
- const int index,
- const int amount) const override final;
-
- void buy2(const Being *const being,
- const int vendId,
- const int index,
- const int amount) const override final;
-
- void buyItems(const Being *const being,
- const STD_VECTOR<ShopItem*> &items) const
- override final;
-
- void createShop(const std::string &name,
- const bool flag,
- const STD_VECTOR<ShopItem*> &items) const
- override final;
-};
-
-} // namespace EAthena
-
-#endif // NET_EATHENA_VENDINGHANDLER_H
diff --git a/src/net/eathena/vendingrecv.cpp b/src/net/eathena/vendingrecv.cpp
deleted file mode 100644
index d4f14bc87..000000000
--- a/src/net/eathena/vendingrecv.cpp
+++ /dev/null
@@ -1,277 +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 "net/eathena/vendingrecv.h"
-
-#include "actormanager.h"
-#include "itemcolormanager.h"
-#include "notifymanager.h"
-
-#include "const/resources/currency.h"
-
-#include "being/localplayer.h"
-#include "being/playerinfo.h"
-
-#include "const/net/inventory.h"
-
-#include "enums/resources/notifytypes.h"
-
-#include "gui/windows/buydialog.h"
-
-#include "gui/widgets/createwidget.h"
-
-#include "listeners/vendingmodelistener.h"
-#include "listeners/vendingslotslistener.h"
-
-#include "net/messagein.h"
-
-#include "resources/iteminfo.h"
-
-#include "resources/db/unitsdb.h"
-
-#include "resources/inventory/inventory.h"
-
-#include "resources/item/itemoptionslist.h"
-#include "resources/item/shopitem.h"
-
-#include "utils/gettext.h"
-#include "utils/stringutils.h"
-
-#include "debug.h"
-
-extern int packetVersion;
-extern int serverVersion;
-
-namespace EAthena
-{
-
-namespace VendingRecv
-{
- BuyDialog *mBuyDialog = nullptr;
-} // namespace VendingRecv
-
-void VendingRecv::processOpenReq(Net::MessageIn &msg)
-{
- VendingSlotsListener::distributeEvent(msg.readInt16("slots allowed"));
-}
-
-void VendingRecv::processShowBoard(Net::MessageIn &msg)
-{
- const BeingId id = msg.readBeingId("owner id");
- Being *const dstBeing = actorManager->findBeing(id);
- if (dstBeing != nullptr)
- {
- dstBeing->setSellBoard(msg.readString(80, "shop name"));
- }
- else
- {
- msg.readString(80, "shop name");
- }
-}
-
-void VendingRecv::processHideBoard(Net::MessageIn &msg)
-{
- const BeingId id = msg.readBeingId("owner id");
- Being *const dstBeing = actorManager->findBeing(id);
- if (dstBeing != nullptr)
- dstBeing->setSellBoard(std::string());
- if (dstBeing == localPlayer)
- {
- PlayerInfo::enableVending(false);
- VendingModeListener::distributeEvent(false);
- }
-}
-
-void VendingRecv::processItemsList(Net::MessageIn &msg)
-{
- int packetLen = 22;
- if (msg.getVersion() >= 20160921)
- packetLen = 53;
- else if (msg.getVersion() >= 20150226)
- packetLen = 47;
- int offset = 8;
- if (msg.getVersion() >= 20100105)
- offset += 4;
-
- const int count = (msg.readInt16("len") - offset) / packetLen;
- const BeingId id = msg.readBeingId("id");
- const Being *const being = actorManager->findBeing(id);
- if (being == nullptr)
- return;
- int cards[maxCards];
- CREATEWIDGETV(mBuyDialog, BuyDialog, being, DEFAULT_CURRENCY);
- mBuyDialog->setMoney(PlayerInfo::getAttribute(Attributes::MONEY));
- if (msg.getVersion() >= 20100105)
- msg.readInt32("vender id");
- for (int f = 0; f < count; f ++)
- {
- const int value = msg.readInt32("price");
- const int amount = msg.readInt16("amount");
- const int index = msg.readInt16("inv index");
- const ItemTypeT type = static_cast<ItemTypeT>(
- msg.readUInt8("item type"));
- const int itemId = msg.readInt16("item id");
- msg.readUInt8("identify");
- msg.readUInt8("attribute");
- msg.readUInt8("refine");
- for (int d = 0; d < maxCards; d ++)
- cards[d] = msg.readUInt16("card");
- ItemOptionsList *options = nullptr;
- if (msg.getVersion() >= 20150226)
- {
- options = new ItemOptionsList;
- for (int d = 0; d < 5; d ++)
- {
- const uint16_t idx = msg.readInt16("option index");
- const uint16_t val = msg.readInt16("option value");
- msg.readUInt8("option param");
- options->add(idx, val);
- }
- }
- if (msg.getVersion() >= 20160921)
- {
- msg.readInt32("equip type?");
- msg.readInt16("look");
- }
-
- const ItemColor color = ItemColorManager::getColorFromCards(&cards[0]);
- ShopItem *const item = mBuyDialog->addItem(itemId, type,
- color, amount, value);
- if (item != nullptr)
- {
- item->setInvIndex(index);
- item->setOptions(options);
- }
- delete options;
- }
- mBuyDialog->sort();
-}
-
-void VendingRecv::processBuyAck(Net::MessageIn &msg)
-{
- msg.readInt16("inv index");
- msg.readInt16("amount");
- const int flag = msg.readUInt8("flag");
- switch (flag)
- {
- case 0:
- break;
- case 1:
- NotifyManager::notify(NotifyTypes::BUY_FAILED_NO_MONEY);
- break;
- case 2:
- NotifyManager::notify(NotifyTypes::BUY_FAILED_OVERWEIGHT);
- break;
- case 4:
- NotifyManager::notify(NotifyTypes::BUY_FAILED_TOO_MANY_ITEMS);
- break;
- case 5:
- NotifyManager::notify(NotifyTypes::BUY_TRADE_FAILED);
- break;
- case 6: // +++ probably need show exact error messages?
- case 7:
- NotifyManager::notify(NotifyTypes::BUY_FAILED);
- break;
- default:
- NotifyManager::notify(NotifyTypes::BUY_FAILED);
- UNIMPLEMENTEDPACKETFIELD(flag);
- break;
- }
-}
-
-void VendingRecv::processOpen(Net::MessageIn &msg)
-{
- int packetLen = 22;
- if (msg.getVersion() >= 20150226)
- packetLen += 25;
-
- const int count = (msg.readInt16("len") - 8) / packetLen;
- msg.readInt32("id");
- for (int f = 0; f < count; f ++)
- {
- msg.readInt32("price");
- msg.readInt16("inv index");
- msg.readInt16("amount");
- msg.readUInt8("item type");
- msg.readInt16("item id");
- msg.readUInt8("identify");
- msg.readUInt8("attribute");
- msg.readUInt8("refine");
- for (int d = 0; d < maxCards; d ++)
- msg.readUInt16("card");
- if (msg.getVersion() >= 20150226)
- {
- for (int d = 0; d < 5; d ++)
- {
- msg.readInt16("option index");
- msg.readInt16("option value");
- msg.readUInt8("option param");
- }
- }
- }
- PlayerInfo::enableVending(true);
- VendingModeListener::distributeEvent(true);
-}
-
-void VendingRecv::processReport(Net::MessageIn &msg)
-{
- const int index = msg.readInt16("inv index") - INVENTORY_OFFSET;
- const int amount = msg.readInt16("amount");
- int money = 0;
- if (msg.getVersion() >= 20141016)
- {
- msg.readInt32("char id");
- msg.readInt32("time");
- money = msg.readInt32("zeny");
- }
- const Inventory *const inventory = PlayerInfo::getCartInventory();
- if (inventory == nullptr)
- return;
- const Item *const item = inventory->getItem(index);
- if (item == nullptr)
- return;
-
- const ItemInfo &info = item->getInfo();
- std::string str;
- if (money != 0)
- {
- // TRANSLATORS: vending sold item message
- str = strprintf(_("Sold item %s amount %d. You got: %s"),
- info.getLink().c_str(),
- amount,
- UnitsDb::formatCurrency(money).c_str());
- }
- else
- {
- // TRANSLATORS: vending sold item message
- str = strprintf(_("Sold item %s amount %d"),
- info.getLink().c_str(),
- amount);
- }
- NotifyManager::notify(NotifyTypes::VENDING_SOLD_ITEM, str);
-}
-
-void VendingRecv::processOpenStatus(Net::MessageIn &msg)
-{
- UNIMPLEMENTEDPACKET;
- msg.readUInt8("result");
-}
-
-} // namespace EAthena
diff --git a/src/net/eathena/vendingrecv.h b/src/net/eathena/vendingrecv.h
deleted file mode 100644
index 1424cd3be..000000000
--- a/src/net/eathena/vendingrecv.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 NET_EATHENA_VENDINGRECV_H
-#define NET_EATHENA_VENDINGRECV_H
-
-class BuyDialog;
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-namespace EAthena
-{
- namespace VendingRecv
- {
- extern BuyDialog *mBuyDialog;
-
- void processOpenReq(Net::MessageIn &msg);
- void processShowBoard(Net::MessageIn &msg);
- void processHideBoard(Net::MessageIn &msg);
- void processItemsList(Net::MessageIn &msg);
- void processBuyAck(Net::MessageIn &msg);
- void processOpen(Net::MessageIn &msg);
- void processReport(Net::MessageIn &msg);
- void processOpenStatus(Net::MessageIn &msg);
- } // namespace VendingRecv
-} // namespace EAthena
-
-#endif // NET_EATHENA_VENDINGRECV_H
diff --git a/src/net/elementalhandler.h b/src/net/elementalhandler.h
deleted file mode 100644
index 8318de106..000000000
--- a/src/net/elementalhandler.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 NET_ELEMENTALHANDLER_H
-#define NET_ELEMENTALHANDLER_H
-
-#include "localconsts.h"
-
-namespace Net
-{
-
-class ElementalHandler notfinal
-{
- public:
- ElementalHandler()
- { }
-
- A_DELETE_COPY(ElementalHandler)
-
- virtual ~ElementalHandler()
- { }
-};
-
-} // namespace Net
-
-extern Net::ElementalHandler *elementalHandler;
-
-#endif // NET_ELEMENTALHANDLER_H
diff --git a/src/net/familyhandler.h b/src/net/familyhandler.h
deleted file mode 100644
index b213c4824..000000000
--- a/src/net/familyhandler.h
+++ /dev/null
@@ -1,51 +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 NET_FAMILYHANDLER_H
-#define NET_FAMILYHANDLER_H
-
-#include "localconsts.h"
-
-class Being;
-
-namespace Net
-{
-
-class FamilyHandler notfinal
-{
- public:
- FamilyHandler()
- { }
-
- A_DELETE_COPY(FamilyHandler)
-
- virtual ~FamilyHandler()
- { }
-
- virtual void askForChild(const Being *const being) const = 0;
-
- virtual void askForChildReply(const bool accept) const = 0;
-};
-
-} // namespace Net
-
-extern Net::FamilyHandler *familyHandler;
-
-#endif // NET_FAMILYHANDLER_H
diff --git a/src/net/friendshandler.h b/src/net/friendshandler.h
deleted file mode 100644
index 6b9f29a13..000000000
--- a/src/net/friendshandler.h
+++ /dev/null
@@ -1,55 +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 NET_FRIENDSHANDLER_H
-#define NET_FRIENDSHANDLER_H
-
-#include <string>
-
-#include "localconsts.h"
-
-namespace Net
-{
-
-class FriendsHandler notfinal
-{
- public:
- FriendsHandler()
- { }
-
- A_DELETE_COPY(FriendsHandler)
-
- virtual void invite(const std::string &name) const = 0;
-
- virtual void inviteResponse(const int accountId,
- const int charId,
- const bool accept) const = 0;
-
- virtual void remove(const int accountId, const int charId) const = 0;
-
- virtual ~FriendsHandler()
- { }
-};
-
-} // namespace Net
-
-extern Net::FriendsHandler *friendsHandler;
-
-#endif // NET_FRIENDSHANDLER_H
diff --git a/src/net/gamehandler.h b/src/net/gamehandler.h
deleted file mode 100644
index 5bd4bca92..000000000
--- a/src/net/gamehandler.h
+++ /dev/null
@@ -1,71 +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 NET_GAMEHANDLER_H
-#define NET_GAMEHANDLER_H
-
-#include "net/logindata.h"
-
-namespace Net
-{
-
-class GameHandler notfinal
-{
- public:
- GameHandler()
- { }
-
- A_DELETE_COPY(GameHandler)
-
- virtual ~GameHandler()
- {}
-
- virtual void connect() const = 0;
-
- virtual bool isConnected() const = 0;
-
- virtual void disconnect() const = 0;
-
- virtual void who() const = 0;
-
- virtual void quit() const = 0;
-
- virtual void ping(const int tick) const = 0;
-
- virtual bool removeDeadBeings() const = 0;
-
- virtual void disconnect2() const = 0;
-
- virtual bool mustPing() const A_WARN_UNUSED = 0;
-
- virtual void mapLoadedEvent() const = 0;
-
- virtual void initEngines() const = 0;
-
- virtual void clear() const = 0;
-};
-
-} // namespace Net
-
-extern Net::GameHandler *gameHandler;
-
-#endif // NET_GAMEHANDLER_H
diff --git a/src/net/generalhandler.h b/src/net/generalhandler.h
deleted file mode 100644
index 480b50948..000000000
--- a/src/net/generalhandler.h
+++ /dev/null
@@ -1,65 +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 NET_GENERALHANDLER_H
-#define NET_GENERALHANDLER_H
-
-#include "localconsts.h"
-
-namespace Net
-{
-
-class GeneralHandler notfinal
-{
- public:
- GeneralHandler()
- { }
-
- A_DELETE_COPY(GeneralHandler)
-
- virtual ~GeneralHandler()
- { }
-
- virtual void load() const = 0;
-
- virtual void reload() const = 0;
-
- virtual void unload() const = 0;
-
- virtual void flushNetwork() const = 0;
-
- virtual void flushSend() const = 0;
-
- virtual void clearHandlers() const = 0;
-
- virtual void reloadPartially() const = 0;
-
- virtual void gameStarted() const = 0;
-
- virtual void gameEnded() const = 0;
-};
-
-} // namespace Net
-
-extern Net::GeneralHandler *generalHandler;
-
-#endif // NET_GENERALHANDLER_H
diff --git a/src/net/guildhandler.h b/src/net/guildhandler.h
deleted file mode 100644
index 2b1997f92..000000000
--- a/src/net/guildhandler.h
+++ /dev/null
@@ -1,106 +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 NET_GUILDHANDLER_H
-#define NET_GUILDHANDLER_H
-
-#include "guild.h"
-
-#include "gui/widgets/tabs/chat/chattab.h"
-
-class Being;
-
-namespace Net
-{
-
-class GuildHandler notfinal
-{
- public:
- GuildHandler()
- { }
-
- A_DELETE_COPY(GuildHandler)
-
- virtual ~GuildHandler()
- { }
-
- virtual void create(const std::string &name) const = 0;
-
- virtual void invite(const std::string &name) const = 0;
-
- virtual void invite(const Being *const being) const = 0;
-
- virtual void inviteResponse(const int guildId,
- const bool response) const = 0;
-
- virtual void leave(const int guildId) const = 0;
-
- virtual void kick(const GuildMember *restrict const member,
- const std::string &restrict reason) const = 0;
-
- virtual void chat(const std::string &text) const = 0;
-
- virtual void memberList() const = 0;
-
- virtual void info() const = 0;
-
- virtual void changeMemberPostion(const GuildMember *const member,
- const int level) const = 0;
-
- virtual void changePostionInfo(const int posId,
- const int mode,
- const int ranking,
- const int payRate,
- const std::string &name) const = 0;
-
- virtual void requestAlliance(const Being *const being) const = 0;
-
- virtual void requestOpposition(const Being *const being) const = 0;
-
- virtual void requestAllianceResponse(const int beingId,
- const bool accept) const = 0;
-
- virtual void endAlliance(const int guildId,
- const int flag) const = 0;
-
- virtual void changeNotice(const int guildId,
- const std::string &restrict msg1,
- const std::string &restrict msg2) const = 0;
-
- virtual void checkMaster() const = 0;
-
- virtual void breakGuild(const std::string &name) const = 0;
-
- virtual void changeEmblem(std::string emblem) const = 0;
-
- virtual void requestEmblem(const int guildId) const = 0;
-
- virtual void clear() const = 0;
-
- virtual ChatTab *getTab() const = 0;
-};
-
-} // namespace Net
-
-extern Net::GuildHandler *guildHandler;
-
-#endif // NET_GUILDHANDLER_H
diff --git a/src/net/homunculushandler.h b/src/net/homunculushandler.h
deleted file mode 100644
index c5a997b61..000000000
--- a/src/net/homunculushandler.h
+++ /dev/null
@@ -1,69 +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 NET_HOMUNCULUSHANDLER_H
-#define NET_HOMUNCULUSHANDLER_H
-
-#include "enums/simpletypes/beingid.h"
-#include "enums/simpletypes/keep.h"
-
-#include <string>
-
-#include "localconsts.h"
-
-namespace Net
-{
-
-class HomunculusHandler notfinal
-{
- public:
- HomunculusHandler()
- { }
-
- A_DELETE_COPY(HomunculusHandler)
-
- virtual ~HomunculusHandler()
- { }
-
- virtual void setName(const std::string &name) const = 0;
-
- virtual void moveToMaster() const = 0;
-
- virtual void move(const int x, const int y) const = 0;
-
- virtual void attack(const BeingId targetId,
- const Keep keep) const = 0;
-
- virtual void feed() const = 0;
-
- virtual void fire() const = 0;
-
- virtual void talk(const std::string &restrict text) const = 0;
-
- virtual void emote(const uint8_t emoteId) const = 0;
-
- virtual void setDirection(const unsigned char type) const = 0;
-};
-
-} // namespace Net
-
-extern Net::HomunculusHandler *homunculusHandler;
-
-#endif // NET_HOMUNCULUSHANDLER_H
diff --git a/src/net/hostsgroup.h b/src/net/hostsgroup.h
deleted file mode 100644
index ba2b9c05d..000000000
--- a/src/net/hostsgroup.h
+++ /dev/null
@@ -1,42 +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 NET_HOSTSGROUP_H
-#define NET_HOSTSGROUP_H
-
-#include "utils/stringvector.h"
-
-#include "localconsts.h"
-
-struct HostsGroup final
-{
- HostsGroup() :
- name(),
- hosts()
- {
- }
-
- A_DEFAULT_COPY(HostsGroup)
-
- std::string name;
- StringVect hosts;
-};
-
-#endif // NET_HOSTSGROUP_H
diff --git a/src/net/inventoryhandler.h b/src/net/inventoryhandler.h
deleted file mode 100644
index aaa4d6f67..000000000
--- a/src/net/inventoryhandler.h
+++ /dev/null
@@ -1,114 +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 NET_INVENTORYHANDLER_H
-#define NET_INVENTORYHANDLER_H
-
-#include "enums/simpletypes/beingid.h"
-
-#include "utils/vector.h"
-
-#include "resources/inventory/inventory.h"
-
-namespace Net
-{
-
-class InventoryHandler notfinal
-{
- public:
- InventoryHandler()
- { }
-
- A_DELETE_COPY(InventoryHandler)
-
- virtual ~InventoryHandler()
- { }
-
- virtual void clear() const = 0;
-
- virtual void equipItem(const Item *const item) const = 0;
-
- virtual void unequipItem(const Item *const item) const = 0;
-
- virtual void useItem(const Item *const item) const = 0;
-
- virtual void useItem(const Item *const item,
- const int16_t useType) const = 0;
-
- virtual void dropItem(const Item *const item,
- const int amount) const = 0;
-
- virtual bool canSplit(const Item *const item) const = 0;
-
- virtual void splitItem(const Item *const item,
- const int amount) const = 0;
-
- virtual void moveItem(const int oldIndex,
- const int newIndex) const = 0;
-
- virtual void closeStorage() const = 0;
-
- virtual void moveItem2(const InventoryTypeT source,
- const int slot,
- const int amount,
- const InventoryTypeT destination) const = 0;
-
- virtual size_t getSize(const InventoryTypeT type) const
- A_WARN_UNUSED = 0;
-
- virtual Inventory *getStorage() const = 0;
-
- virtual void destroyStorage() const = 0;
-
- virtual void forgotStorage() const = 0;
-
- virtual int convertFromServerSlot(const int eAthenaSlot) const = 0;
-
- virtual void useCard(const Item *const item) = 0;
-
- virtual void insertCard(const int cardIndex,
- const int itemIndex) const = 0;
-
- virtual void favoriteItem(const Item *const item,
- const bool favorite) const = 0;
-
- virtual void selectEgg(const Item *const item) const = 0;
-
- virtual int getProjectileSlot() const = 0;
-
- virtual int getItemIndex() const A_WARN_UNUSED = 0;
-
- virtual void selectCart(const BeingId accountId,
- const int type) const = 0;
-
- virtual void identifyItem(const Item *const item) const = 0;
-
- virtual void mergeItemsAck(const STD_VECTOR<Item*> &items) const = 0;
-
- virtual void mergetItemsCancel() const = 0;
-};
-
-} // namespace Net
-
-extern Net::InventoryHandler *inventoryHandler;
-
-#endif // NET_INVENTORYHANDLER_H
diff --git a/src/net/ipc.cpp b/src/net/ipc.cpp
deleted file mode 100644
index 2f910eaed..000000000
--- a/src/net/ipc.cpp
+++ /dev/null
@@ -1,226 +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 "net/ipc.h"
-
-#include "gui/windows/chatwindow.h"
-
-#ifndef DYECMD
-#include "input/inputmanager.h"
-#endif // DYECMD
-
-#include "utils/delete2.h"
-#include "utils/foreach.h"
-#include "utils/sdlhelper.h"
-#include "utils/stringutils.h"
-
-#include "debug.h"
-
-IPC *ipc = nullptr;
-
-IPC::IPC() :
- mNumReqs(0),
- mSocket(nullptr),
- mDelayedCommands(),
- mThread(nullptr),
- mMutex(SDL_CreateMutex()),
- mPort(44007U),
- mThreadLocked(false),
- mListen(false)
-{
-}
-
-IPC::~IPC()
-{
- mListen = false;
- if (mSocket != nullptr)
- {
- TcpNet::closeSocket(mSocket);
- mSocket = nullptr;
- }
- SDL_DestroyMutex(mMutex);
- mMutex = nullptr;
- SDL::WaitThread(mThread);
- mThread = nullptr;
-}
-
-bool IPC::init()
-{
- IPaddress ip;
-
- if (TcpNet::resolveHost(&ip, nullptr, mPort) == -1)
- {
- logger->log("IPC: resolveHost error: %s\n", TcpNet::getError());
- return false;
- }
-
- mSocket = TcpNet::open(&ip);
- if (mSocket == nullptr)
- {
- logger->log("IPC: open error: %s", TcpNet::getError());
- return false;
- }
-
- mThread = SDL::createThread(&acceptLoop, "ipc", this);
- if (mThread == nullptr)
- {
- logger->log("IPC: unable to create acceptLoop thread");
- return false;
- }
- return true;
-}
-
-int IPC::acceptLoop(void *ptr)
-{
- if (ptr == nullptr)
- return 1;
-
- IPC *const ipc1 = reinterpret_cast<IPC*>(ptr);
- const int max_length = 1024;
- const TcpNet::SocketSet set = TcpNet::allocSocketSet(1);
- TcpNet::addSocket(set, ipc1->mSocket);
- ipc1->mListen = true;
- while (ipc1->mListen)
- {
- TcpNet::checkSockets(set, 250);
- if (TcpNet::socketReady(ipc1->mSocket) == 0)
- continue;
-
- const TcpNet::Socket sock = TcpNet::accept(ipc1->mSocket);
- if (sock == nullptr)
- {
- logger->log_r("IPC: unable to accept connection");
- continue;
- }
- char data[max_length] = {0};
- int result = TcpNet::recv(sock, data, max_length);
- if (result <= 0)
- {
- logger->log_r("IPC: unable to accept connection");
- TcpNet::closeSocket(sock);
- continue;
- }
-
- std::string req(data);
- trim(req);
- logger->log_r("IPC command: %s", req.c_str());
-
- ipc1->mThreadLocked = true;
- SDL_mutexP(ipc1->mMutex);
- ipc1->mDelayedCommands.push_back(req);
- SDL_mutexV(ipc1->mMutex);
- ipc1->mThreadLocked = false;
-
- ipc1->mNumReqs ++;
- const std::string resp = strprintf("[%u] %s\n",
- ipc1->mNumReqs, req.c_str());
-
- const char *const respc = resp.c_str();
- const int len = CAST_S32(strlen(respc)) + 1;
- result = TcpNet::send(sock, respc, len);
- if (result < len)
- {
- logger->log_r("IPC: send error: %s\n", TcpNet::getError());
- TcpNet::closeSocket(sock);
- continue;
- }
- TcpNet::closeSocket(sock);
- }
- TcpNet::closeSocket(ipc1->mSocket);
- TcpNet::freeSocketSet(set);
- ipc1->mSocket = nullptr;
- ipc1->mThread = nullptr;
- return 0;
-}
-
-void IPC::stop()
-{
- if (ipc == nullptr)
- return;
-
- logger->log("Stopping IPC...");
- delete2(ipc);
-}
-
-void IPC::start()
-{
- if (ipc != nullptr)
- return;
-
- unsigned short port(44007);
- const char *const portStr = getenv("IPC_PORT");
- if (portStr != nullptr)
- port = static_cast<unsigned short>(atoi(portStr));
-
- logger->log("Starting IPC...");
- ipc = new IPC;
- for (int f = port; f < 65535; f ++)
- {
- ipc->setPort(static_cast<unsigned short>(f));
- logger->log(" -> trying port %d...", f);
- if (ipc->init())
- {
- logger->log(" -> Port %d selected", f);
- return;
- }
-
- port ++;
- }
- delete2(ipc);
-}
-
-void IPC::flush()
-{
- if (!mThreadLocked)
- {
- SDL_mutexP(mMutex);
-#ifndef DYECMD
-// probably need enable only commands in tool
- if (chatWindow != nullptr)
- {
- FOR_EACH (STD_VECTOR<std::string>::const_iterator, it,
- mDelayedCommands)
- {
- chatWindow->chatInput(*it);
- }
- }
- else
- {
- FOR_EACH (STD_VECTOR<std::string>::const_iterator, it,
- mDelayedCommands)
- {
- std::string msg = *it;
- if (msg.empty() || msg[0] != '/')
- continue;
- msg = msg.substr(1);
- const size_t pos = msg.find(' ');
- const std::string type(msg, 0, pos);
- std::string args(msg,
- pos == std::string::npos ? msg.size() : pos + 1);
- args = trim(args);
- inputManager.executeChatCommand(type, args, nullptr);
- }
- }
-#endif // DYECMD
-
- mDelayedCommands.clear();
- SDL_mutexV(mMutex);
- }
-}
diff --git a/src/net/ipc.h b/src/net/ipc.h
deleted file mode 100644
index a858e924a..000000000
--- a/src/net/ipc.h
+++ /dev/null
@@ -1,79 +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 NET_IPC_H
-#define NET_IPC_H
-
-#include "localconsts.h"
-
-PRAGMACLANG6GCC(GCC diagnostic push)
-PRAGMACLANG6GCC(GCC diagnostic ignored "-Wold-style-cast")
-#include "net/sdltcpnet.h"
-PRAGMACLANG6GCC(GCC diagnostic pop)
-
-#include "utils/vector.h"
-
-#include <string>
-
-class IPC final
-{
- public:
- /**
- * Constructor.
- */
- IPC();
-
- A_DELETE_COPY(IPC)
-
- /**
- * Destructor.
- */
- ~IPC();
-
- bool init();
-
- unsigned short getPort() const A_WARN_UNUSED
- { return mPort; }
-
- void flush();
-
- static int acceptLoop(void *ptr);
-
- static void start();
-
- static void stop();
-
- private:
- void setPort(const unsigned short port)
- { mPort = port; }
-
- unsigned int mNumReqs;
- TcpNet::Socket mSocket;
- STD_VECTOR<std::string> mDelayedCommands;
- SDL_Thread *mThread;
- SDL_mutex *mMutex;
- unsigned short mPort;
- volatile bool mThreadLocked;
- bool mListen;
-};
-
-extern IPC *ipc;
-
-#endif // NET_IPC_H
diff --git a/src/net/logindata.h b/src/net/logindata.h
deleted file mode 100644
index 1d80b9519..000000000
--- a/src/net/logindata.h
+++ /dev/null
@@ -1,110 +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 NET_LOGINDATA_H
-#define NET_LOGINDATA_H
-
-#include "enums/being/gender.h"
-
-#include "enums/net/updatetype.h"
-
-#include "utils/stringvector.h"
-
-#include "localconsts.h"
-
-class LoginData final
-{
- public:
- LoginData() :
- username(),
- password(),
- newPassword(),
- updateHost(),
- updateHosts(),
- lastLogin(),
- updateType(UpdateType::Normal),
- email(),
- captchaResponse(),
- registerUrl(),
- gender(Gender::UNSPECIFIED),
- packetVersion(0),
- remember(false),
- registerLogin(false),
- characterSlots(9)
- {
- }
-
- A_DELETE_COPY(LoginData)
-
- std::string username;
- std::string password;
- std::string newPassword;
- std::string updateHost;
- StringVect updateHosts;
- std::string lastLogin;
- UpdateTypeT updateType;
-
- std::string email;
- std::string captchaResponse;
- std::string registerUrl;
-
- GenderT gender;
-
- int packetVersion;
- bool remember; // Whether to store the username.
- bool registerLogin; // Whether an account is being registered.
-
- uint16_t characterSlots; // The number of character slots
-
- void clear()
- {
- username.clear();
- password.clear();
- newPassword.clear();
- updateHost.clear();
- updateHosts.clear();
- updateType = UpdateType::Normal;
- email.clear();
- captchaResponse.clear();
- registerUrl.clear();
- gender = Gender::UNSPECIFIED;
- packetVersion = 0;
- lastLogin.clear();
- resetCharacterSlots();
- }
-
- void clearUpdateHost()
- {
- updateHost.clear();
- updateHosts.clear();
- }
-
- /**
- * Initialize character slots to 3 for TmwAthena compatibility
- */
- void resetCharacterSlots()
- {
- characterSlots = 9; // Default value, used for TmwAthena.
- }
-};
-
-#endif // NET_LOGINDATA_H
diff --git a/src/net/loginhandler.h b/src/net/loginhandler.h
deleted file mode 100644
index b10d8430f..000000000
--- a/src/net/loginhandler.h
+++ /dev/null
@@ -1,114 +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 NET_LOGINHANDLER_H
-#define NET_LOGINHANDLER_H
-
-#include "net/serverinfo.h"
-#include "net/worldinfo.h"
-
-class LoginData;
-
-namespace Net
-{
-
-class LoginHandler notfinal
-{
- public:
- A_DELETE_COPY(LoginHandler)
-
- void setServer(const ServerInfo &server)
- { mServer = server; }
-
- const ServerInfo &getServer() const A_WARN_UNUSED
- { return mServer; }
-
- virtual void connect() const = 0;
-
- virtual bool isConnected() const A_WARN_UNUSED = 0;
-
- virtual void disconnect() const = 0;
-
- virtual bool isRegistrationEnabled() const A_WARN_UNUSED = 0;
-
- virtual void getRegistrationDetails() const = 0;
-
- virtual unsigned int getMinUserNameLength() const A_WARN_UNUSED
- { return 4; }
-
- virtual unsigned int getMaxUserNameLength() const A_WARN_UNUSED
- { return 25; }
-
- virtual unsigned int getMinPasswordLength() const A_WARN_UNUSED
- { return 4; }
-
- virtual unsigned int getMaxPasswordLength() const A_WARN_UNUSED
- { return 255; }
-
- virtual void loginAccount(LoginData *const loginData) const = 0;
-
- virtual void logout() const = 0;
-
- virtual void changeEmail(const std::string &email) const = 0;
-
- virtual void changePassword(const std::string &restrict oldPassword,
- const std::string &restrict newPassword)
- const = 0;
-
- virtual void chooseServer(unsigned int server,
- const bool persistentIp) const = 0;
-
- virtual void registerAccount(const LoginData *const loginData)
- const = 0;
-
- virtual void unregisterAccount(const std::string &username,
- const std::string &password) const = 0;
-
- virtual const Worlds &getWorlds() const A_WARN_UNUSED = 0;
-
- virtual void clearWorlds() const = 0;
-
- virtual void loginOrRegister(LoginData *const data) const = 0;
-
- virtual void sendVersion() const = 0;
-
- virtual void ping() const = 0;
-
- virtual void updatePacketVersion() const = 0;
-
- virtual ~LoginHandler()
- { }
-
- protected:
- LoginHandler() :
- mServer()
- {
- }
-
- ServerInfo mServer;
-};
-
-} // namespace Net
-
-extern Net::LoginHandler *loginHandler;
-
-#endif // NET_LOGINHANDLER_H
diff --git a/src/net/mail2handler.h b/src/net/mail2handler.h
deleted file mode 100644
index 55c238b46..000000000
--- a/src/net/mail2handler.h
+++ /dev/null
@@ -1,100 +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 NET_MAIL2HANDLER_H
-#define NET_MAIL2HANDLER_H
-
-#include "enums/net/mailopentype.h"
-
-#include "enums/resources/mailqueuetype.h"
-
-#include <string>
-
-#include "localconsts.h"
-
-class Item;
-
-namespace Net
-{
-
-class Mail2Handler notfinal
-{
- public:
- Mail2Handler()
- { }
-
- A_DELETE_COPY(Mail2Handler)
-
- virtual ~Mail2Handler()
- { }
-
- virtual void openWriteMail(const std::string &receiver) const = 0;
-
- virtual void addItem(const Item *const item,
- const int amount) const = 0;
-
- virtual void removeItem(const int index,
- const int amount) const = 0;
-
- virtual void sendMail(const std::string &to,
- const std::string &title,
- const std::string &body,
- const int64_t &money) const = 0;
-
- virtual void queueCheckName(const MailQueueTypeT type,
- const std::string &to,
- const std::string &title,
- const std::string &body,
- const int64_t &money) const = 0;
-
- virtual void nextPage(const MailOpenTypeT openType,
- const int64_t mailId) const = 0;
-
- virtual void readMail(const MailOpenTypeT openType,
- const int64_t mailId) const = 0;
-
- virtual void deleteMail(const MailOpenTypeT openType,
- const int64_t mailId) const = 0;
-
- virtual void requestMoney(const MailOpenTypeT openType,
- const int64_t mailId) const = 0;
-
- virtual void requestItems(const MailOpenTypeT openType,
- const int64_t mailId) const = 0;
-
- virtual void refreshMailList(const MailOpenTypeT openType,
- const int64_t mailId) const = 0;
-
- virtual void openMailBox(const MailOpenTypeT openType) const = 0;
-
- virtual void closeMailBox() const = 0;
-
- virtual void cancelWriteMail() const = 0;
-
- virtual void requestCheckName(const std::string &name) const = 0;
-
- virtual std::string getCheckedName() const = 0;
-};
-
-} // namespace Net
-
-extern Net::Mail2Handler *mail2Handler;
-
-#endif // NET_MAIL2HANDLER_H
diff --git a/src/net/mailhandler.h b/src/net/mailhandler.h
deleted file mode 100644
index ebe8fc72c..000000000
--- a/src/net/mailhandler.h
+++ /dev/null
@@ -1,67 +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 NET_MAILHANDLER_H
-#define NET_MAILHANDLER_H
-
-#include <string>
-
-#include "localconsts.h"
-
-namespace Net
-{
-
-class MailHandler notfinal
-{
- public:
- MailHandler()
- { }
-
- A_DELETE_COPY(MailHandler)
-
- virtual ~MailHandler()
- { }
-
- virtual void refresh() const = 0;
-
- virtual void readMessage(const int msgId) const = 0;
-
- virtual void getAttach(const int msgId) const = 0;
-
- virtual void deleteMessage(const int msgId) const = 0;
-
- virtual void returnMessage(const int msgId) const = 0;
-
- virtual void setAttach(const int index, const int amount) const = 0;
-
- virtual void setAttachMoney(const int money) const = 0;
-
- virtual void resetAttach(const int flag) const = 0;
-
- virtual void send(const std::string &name,
- const std::string &title,
- std::string message) const = 0;
-};
-
-} // namespace Net
-
-extern Net::MailHandler *mailHandler;
-
-#endif // NET_MAILHANDLER_H
diff --git a/src/net/maphandler.h b/src/net/maphandler.h
deleted file mode 100644
index b68fe19f1..000000000
--- a/src/net/maphandler.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 NET_MAPHANDLER_H
-#define NET_MAPHANDLER_H
-
-#include "localconsts.h"
-
-namespace Net
-{
-
-class MapHandler notfinal
-{
- public:
- MapHandler()
- { }
-
- A_DELETE_COPY(MapHandler)
-
- virtual ~MapHandler()
- { }
-};
-
-} // namespace Net
-
-extern Net::MapHandler *mapHandler;
-
-#endif // NET_MAPHANDLER_H
diff --git a/src/net/markethandler.h b/src/net/markethandler.h
deleted file mode 100644
index f4b43cccd..000000000
--- a/src/net/markethandler.h
+++ /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/>.
- */
-
-#ifndef NET_MARKETHANDLER_H
-#define NET_MARKETHANDLER_H
-
-#include "enums/resources/item/itemtype.h"
-
-#include "enums/simpletypes/itemcolor.h"
-
-#include "utils/vector.h"
-
-#include "localconsts.h"
-
-class ShopItem;
-
-namespace Net
-{
-
-class MarketHandler notfinal
-{
- public:
- MarketHandler()
- { }
-
- A_DELETE_COPY(MarketHandler)
-
- virtual ~MarketHandler()
- { }
-
- virtual void close() const = 0;
-
- virtual void buyItem(const int itemId,
- const ItemTypeT type,
- const ItemColor color,
- const int amount) const = 0;
-
- virtual void buyItems(const STD_VECTOR<ShopItem*> &items) const = 0;
-};
-
-} // namespace Net
-
-extern Net::MarketHandler *marketHandler;
-
-#endif // NET_MARKETHANDLER_H
diff --git a/src/net/mercenaryhandler.h b/src/net/mercenaryhandler.h
deleted file mode 100644
index 2fcd4790f..000000000
--- a/src/net/mercenaryhandler.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 NET_MERCENARYHANDLER_H
-#define NET_MERCENARYHANDLER_H
-
-#include "enums/simpletypes/beingid.h"
-#include "enums/simpletypes/keep.h"
-
-#include <string>
-
-#include "localconsts.h"
-
-namespace Net
-{
-
-class MercenaryHandler notfinal
-{
- public:
- MercenaryHandler()
- { }
-
- A_DELETE_COPY(MercenaryHandler)
-
- virtual ~MercenaryHandler()
- { }
-
- virtual void fire() const = 0;
-
- virtual void moveToMaster() const = 0;
-
- virtual void move(const int x, const int y) const = 0;
-
- virtual void attack(const BeingId targetId,
- const Keep keep) const = 0;
-
- virtual void talk(const std::string &restrict text) const = 0;
-
- virtual void emote(const uint8_t emoteId) const = 0;
-
- virtual void setDirection(const unsigned char type) const = 0;
-};
-
-} // namespace Net
-
-extern Net::MercenaryHandler *mercenaryHandler;
-
-#endif // NET_MERCENARYHANDLER_H
diff --git a/src/net/messagein.cpp b/src/net/messagein.cpp
deleted file mode 100644
index f474da086..000000000
--- a/src/net/messagein.cpp
+++ /dev/null
@@ -1,332 +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 "net/messagein.h"
-
-#include "net/packetcounters.h"
-
-#include "utils/cast.h"
-#include "utils/stringutils.h"
-
-#include "logger.h"
-
-#include "debug.h"
-
-#define MAKEWORD(low, high) \
- (CAST_U16((CAST_U8(low)) | \
- (CAST_U16(CAST_U8(high))) << 8))
-
-namespace Net
-{
-
-MessageIn::MessageIn(const char *const data,
- const unsigned int length) :
- mData(data),
- mLength(length),
- mPos(0),
- mVersion(0),
- mId(0),
- mIgnore(false)
-{
- PacketCounters::incInPackets();
-}
-
-MessageIn::~MessageIn()
-{
- if (mLength != 0u)
- {
- if (mPos != mLength && mPos != 2)
- {
- logger->log("Wrong actual or planned inbound packet size!");
- logger->log(" packet id: %u 0x%x",
- CAST_U32(mId),
- CAST_U32(mId));
- logger->log(" planned size: %u", mLength);
- logger->log(" read size: %u", mPos);
- WRONGPACKETSIZE;
- }
- }
- else
- {
- logger->log("Zero packet size: %d", CAST_S32(mId));
- }
-}
-
-unsigned char MessageIn::readUInt8(const char *const str)
-{
- unsigned char value = CAST_U8(-1);
- if (mPos < mLength)
- value = CAST_U8(mData[mPos]);
-
- DEBUGLOG2("readUInt8: " + toStringPrint(CAST_U32(value)),
- mPos, str);
- mPos += 1;
- PacketCounters::incInBytes(1);
- return value;
-}
-
-signed char MessageIn::readInt8(const char *const str)
-{
- signed char value = CAST_S8(-1);
- if (mPos < mLength)
- value = CAST_S8(mData[mPos]);
-
- DEBUGLOG2("readInt8: " + toStringPrint(CAST_U32(
- CAST_U8(value))),
- mPos, str);
- mPos += 1;
- PacketCounters::incInBytes(1);
- return value;
-}
-
-uint8_t MessageIn::fromServerDirection(const uint8_t serverDir)
-{
- // Translate from eAthena format
- switch (serverDir)
- {
- case 0:
- return 1;
- case 1:
- return 3;
- case 2:
- return 2;
- case 3:
- return 6;
- case 4:
- return 4;
- case 5:
- return 12;
- case 6:
- return 8;
- case 7:
- return 9;
- case 8:
- return 8;
- default:
- logger->log("incorrect direction: %d",
- CAST_S32(serverDir));
- return 0;
- }
-}
-
-void MessageIn::readCoordinates(uint16_t &restrict x,
- uint16_t &restrict y,
- uint8_t &restrict direction,
- const char *const str)
-{
- if (mPos + 3 <= mLength)
- {
- const char *const data = mData + CAST_SIZE(mPos);
- uint16_t temp = MAKEWORD(data[1] & 0x00c0, data[0] & 0x00ff);
- x = CAST_U16(temp >> 6);
- temp = MAKEWORD(data[2] & 0x00f0, data[1] & 0x003f);
- y = CAST_U16(temp >> 4);
-
- const uint8_t serverDir = CAST_U8(data[2] & 0x000f);
- direction = fromServerDirection(serverDir);
-
- DEBUGLOG2(std::string("readCoordinates: ").append(toString(
- CAST_S32(x))).append(",").append(toString(
- CAST_S32(y))).append(",").append(toString(
- CAST_S32(serverDir))), mPos, str);
- }
- else
- {
- x = 0;
- y = 0;
- direction = 0;
- logger->log("error: wrong readCoordinates packet");
- }
- mPos += 3;
- PacketCounters::incInBytes(3);
-}
-
-void MessageIn::readCoordinatePair(uint16_t &restrict srcX,
- uint16_t &restrict srcY,
- uint16_t &restrict dstX,
- uint16_t &restrict dstY,
- const char *const str)
-{
- if (mPos + 5 <= mLength)
- {
- const char *const data = mData + CAST_SIZE(mPos);
- uint16_t temp = MAKEWORD(data[3], data[2] & 0x000f);
- dstX = CAST_U16(temp >> 2);
-
- dstY = MAKEWORD(data[4], data[3] & 0x0003);
-
- temp = MAKEWORD(data[1], data[0]);
- srcX = CAST_U16(temp >> 6);
-
- temp = MAKEWORD(data[2], data[1] & 0x003f);
- srcY = CAST_U16(temp >> 4);
-
- DEBUGLOG2(std::string("readCoordinatePair: ").append(toString(
- CAST_S32(srcX))).append(",").append(toString(
- CAST_S32(srcY))).append(" ").append(toString(
- CAST_S32(dstX))).append(",").append(toString(
- CAST_S32(dstY))), mPos, str);
- }
- else
- {
- srcX = 0;
- srcY = 0;
- dstX = 0;
- dstY = 0;
- logger->log("error: wrong readCoordinatePair packet");
- }
- mPos += 5;
- PacketCounters::incInBytes(5);
-}
-
-void MessageIn::skip(const unsigned int length, const char *const str)
-{
- DEBUGLOG2("skip: " + toString(CAST_S32(length)), mPos, str);
- mPos += length;
- PacketCounters::incInBytes(length);
-}
-
-void MessageIn::skipToEnd(const char *const str)
-{
- const int diff = CAST_S32(mLength - mPos);
- if (diff != 0)
- {
- DEBUGLOG2("skip: " + toString(diff), mPos, str);
- mPos = mLength;
- PacketCounters::incInBytes(diff);
- }
-}
-
-std::string MessageIn::readString(int length, const char *const dstr)
-{
- // Get string length
- if (length < 0)
- length = readInt16("len");
-
- // Make sure the string isn't erroneous
- if (length < 0 || mPos + length > mLength)
- {
- DEBUGLOG2("readString error", mPos, dstr);
- mPos = mLength + 1;
- return "";
- }
-
- // Read the string
- const char *const stringBeg = mData + CAST_SIZE(mPos);
- const char *const stringEnd
- = static_cast<const char *>(memchr(stringBeg, '\0', length));
-
- const std::string str(stringBeg, stringEnd != nullptr
- ? stringEnd - stringBeg : CAST_SIZE(length));
- DEBUGLOG2("readString: " + str, mPos, dstr);
- mPos += length;
- PacketCounters::incInBytes(length);
- return str;
-}
-
-std::string MessageIn::readRawString(int length, const char *const dstr)
-{
- // Get string length
- if (length < 0)
- length = readInt16("len");
-
- // Make sure the string isn't erroneous
- if (length < 0 || mPos + length > mLength)
- {
- mPos = mLength + 1;
- return "";
- }
-
- // Read the string
- const char *const stringBeg = mData + CAST_SIZE(mPos);
- const char *const stringEnd
- = static_cast<const char *>(memchr(stringBeg, '\0', length));
- std::string str(stringBeg, stringEnd != nullptr
- ? stringEnd - stringBeg : CAST_SIZE(length));
-
- DEBUGLOG2("readString: " + str, mPos, dstr);
-
- if (stringEnd != nullptr)
- {
- const size_t len2 = CAST_SIZE(length)
- - (stringEnd - stringBeg) - 1;
- const char *const stringBeg2 = stringEnd + 1;
- const char *const stringEnd2
- = static_cast<const char *>(memchr(stringBeg2, '\0', len2));
- const std::string hiddenPart = std::string(stringBeg2,
- stringEnd2 != nullptr ? stringEnd2 - stringBeg2 : len2);
- if (hiddenPart.length() > 0)
- {
- DEBUGLOG2("readString2: " + hiddenPart, mPos, dstr);
- return str.append("|").append(hiddenPart);
- }
- }
- mPos += length;
- PacketCounters::incInBytes(length);
-
- return str;
-}
-
-unsigned char *MessageIn::readBytes(int length, const char *const dstr)
-{
- // Get string length
- if (length < 0)
- length = readInt16("len");
-
- // Make sure the string isn't erroneous
- if (length < 0 || mPos + length > mLength)
- {
- DEBUGLOG2("readBytesString error", mPos, dstr);
- mPos = mLength + 1;
- return nullptr;
- }
-
- unsigned char *const buf
- = new unsigned char[CAST_SIZE(length + 2)];
-
- memcpy(buf, mData + CAST_SIZE(mPos), length);
- buf[length] = 0;
- buf[length + 1] = 0;
- mPos += length;
-
-#ifdef ENABLEDEBUGLOG
- std::string str;
- for (int f = 0; f < length; f ++)
- str.append(strprintf("%02x", CAST_U32(buf[f])));
- str += " ";
- for (int f = 0; f < length; f ++)
- {
- if (buf[f] != 0u)
- str.append(strprintf("%c", buf[f]));
- else
- str.append("_");
- }
- if (dstr != nullptr)
- logger->dlog(dstr);
- logger->dlog("ReadBytes: " + str);
-#endif // ENABLEDEBUGLOG
-
- PacketCounters::incInBytes(length);
- return buf;
-}
-
-} // namespace Net
diff --git a/src/net/messagein.h b/src/net/messagein.h
deleted file mode 100644
index 0b3d0be67..000000000
--- a/src/net/messagein.h
+++ /dev/null
@@ -1,152 +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 NET_MESSAGEIN_H
-#define NET_MESSAGEIN_H
-
-#include "enums/simpletypes/beingid.h"
-
-#include <string>
-
-#include "localconsts.h"
-
-namespace Net
-{
-
-/**
- * Used for parsing an incoming message.
- *
- * \ingroup Network
- */
-class MessageIn notfinal
-{
- public:
- A_DELETE_COPY(MessageIn)
-
- virtual ~MessageIn();
-
- /**
- * Returns the message ID.
- */
- int getId() const noexcept2 A_WARN_UNUSED
- { return mId; }
-
- /**
- * Returns the message length.
- */
- unsigned int getLength() const noexcept2 A_WARN_UNUSED
- { return mLength; }
-
- /**
- * Returns the length of unread data.
- */
- unsigned int getUnreadLength() const noexcept2 A_WARN_UNUSED
- { return mLength > mPos ? mLength - mPos : 0; }
-
- /**< Reads a byte. */
- virtual unsigned char readUInt8(const char *const str);
-
- /**< Reads a byte. */
- virtual signed char readInt8(const char *const str);
-
- /**< Reads a short. */
- virtual int16_t readInt16(const char *const str) = 0;
-
- virtual uint16_t readUInt16(const char *const str) = 0;
-
- /**< Reads a long. */
- virtual int32_t readInt32(const char *const str) = 0;
-
- virtual int64_t readInt64(const char *const str) = 0;
-
- virtual BeingId readBeingId(const char *const str) = 0;
-
- /**
- * Reads a special 3 byte block used by eAthena, containing x and y
- * coordinates and direction.
- */
- virtual void readCoordinates(uint16_t &restrict x,
- uint16_t &restrict y,
- uint8_t &restrict direction,
- const char *const str);
-
- /**
- * Reads a special 5 byte block used by eAthena, containing a source
- * and destination coordinate pair.
- */
- virtual void readCoordinatePair(uint16_t &restrict srcX,
- uint16_t &restrict srcY,
- uint16_t &restrict dstX,
- uint16_t &restrict dstY,
- const char *const str);
-
- /**
- * Skips a given number of bytes.
- */
- virtual void skip(const unsigned int length,
- const char *const str);
-
- void skipToEnd(const char *const str);
-
- /**
- * Reads a string. If a length is not given (-1), it is assumed
- * that the length of the string is stored in a short at the
- * start of the string.
- */
- virtual std::string readString(int length,
- const char *const dstr);
-
- virtual std::string readRawString(int length,
- const char *const dstr);
-
- unsigned char *readBytes(int length,
- const char *const dstr);
-
- static uint8_t fromServerDirection(const uint8_t serverDir)
- A_WARN_UNUSED;
-
- unsigned int getVersion() const noexcept2 A_WARN_UNUSED
- { return mVersion; }
-
- protected:
- /**
- * Constructor.
- */
- MessageIn(const char *const data, const unsigned int length);
-
- const char *mData; /**< The message data. */
- unsigned int mLength; /**< The length of the data. */
-
- /**
- * Actual position in the packet. From 0 to packet->length.
- * A value bigger than packet->length means EOP was reached when
- * reading it.
- */
- unsigned int mPos;
- unsigned int mVersion;
- uint16_t mId; /**< The message ID. */
- bool mIgnore;
-};
-
-} // namespace Net
-
-#endif // NET_MESSAGEIN_H
diff --git a/src/net/messageout.cpp b/src/net/messageout.cpp
deleted file mode 100644
index f37af859e..000000000
--- a/src/net/messageout.cpp
+++ /dev/null
@@ -1,175 +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 "net/messageout.h"
-
-#include "logger.h"
-
-#include "net/net.h"
-#include "net/packetcounters.h"
-
-#include "utils/stringutils.h"
-
-#include "debug.h"
-
-namespace Net
-{
-
-MessageOut::MessageOut(const int16_t id) :
- mData(nullptr),
- mDataSize(0),
- mPos(0),
- mId(id),
- mIgnore(false)
-{
- PacketCounters::incOutPackets();
- IGNOREDEBUGLOG;
- DEBUGLOG2("Send packet", 0, "MessageOut");
-}
-
-void MessageOut::writeInt8(const int8_t value, const char *const str)
-{
- expand(1);
- mData[mPos] = value;
- DEBUGLOG2("writeInt8: " + toStringPrint(CAST_U32(
- CAST_U8(value))),
- mPos, str);
- mPos += 1;
- PacketCounters::incOutBytes(1);
-}
-
-void MessageOut::writeString(const std::string &string,
- int length,
- const char *const str)
-{
- int stringLength = CAST_S32(string.length());
- if (length < 0)
- {
- // Write the length at the start if not fixed
- writeInt16(CAST_S16(stringLength), "len");
- length = stringLength;
- }
- else if (length < stringLength)
- {
- // Make sure the length of the string is no longer than specified
- stringLength = length;
- }
- expand(length);
-
- // Write the actual string
- memcpy(mData + CAST_SIZE(mPos), string.c_str(), stringLength);
-
- // Pad remaining space with zeros
- if (length > stringLength)
- {
- memset(mData + CAST_SIZE(mPos + stringLength),
- '\0',
- length - stringLength);
- }
-
- DEBUGLOG2("writeString: " + string, mPos, str);
- mPos += length;
- PacketCounters::incOutBytes(length);
-}
-
-void MessageOut::writeStringNoLog(const std::string &string,
- int length,
- const char *const str)
-{
- int stringLength = CAST_S32(string.length());
- if (length < 0)
- {
- // Write the length at the start if not fixed
- writeInt16(CAST_S16(stringLength), "len");
- length = stringLength;
- }
- else if (length < stringLength)
- {
- // Make sure the length of the string is no longer than specified
- stringLength = length;
- }
- expand(length);
-
- // Write the actual string
- memcpy(mData + CAST_SIZE(mPos), string.c_str(), stringLength);
-
- // Pad remaining space with zeros
- if (length > stringLength)
- {
- memset(mData + CAST_SIZE(mPos + stringLength),
- '\0',
- length - stringLength);
- }
-
- DEBUGLOG2("writeString: ***", mPos, str);
- mPos += length;
- PacketCounters::incOutBytes(length);
-}
-
-const char *MessageOut::getData() const
-{
- return mData;
-}
-
-unsigned int MessageOut::getDataSize() const
-{
- return mDataSize;
-}
-
-unsigned char MessageOut::toServerDirection(unsigned char direction)
-{
- // Translate direction to eAthena format
- switch (direction)
- {
- case 1: // DOWN
- direction = 0;
- break;
- case 3: // DOWN | LEFT
- direction = 1;
- break;
- case 2: // LEFT
- direction = 2;
- break;
- case 6: // LEFT | UP
- direction = 3;
- break;
- case 4: // UP
- direction = 4;
- break;
- case 12: // UP | RIGHT
- direction = 5;
- break;
- case 8: // RIGHT
- direction = 6;
- break;
- case 9: // RIGHT + DOWN
- direction = 7;
- break;
- default:
- // OOPSIE! Impossible or unknown
- direction = CAST_U8(-1);
- break;
- }
- return direction;
-}
-
-} // namespace Net
diff --git a/src/net/messageout.h b/src/net/messageout.h
deleted file mode 100644
index 3e07ee28b..000000000
--- a/src/net/messageout.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 NET_MESSAGEOUT_H
-#define NET_MESSAGEOUT_H
-
-#include "enums/simpletypes/beingid.h"
-
-#include "utils/cast.h"
-
-#include <string>
-
-#include "localconsts.h"
-
-UTILS_CAST_H
-
-#define createOutPacket(name) MessageOut outMsg(name); \
- outMsg.writeInt16(CAST_S16(name), #name)
-
-namespace Net
-{
-
-/**
- * Used for building an outgoing message.
- *
- * \ingroup Network
- */
-class MessageOut notfinal
-{
- public:
- A_DELETE_COPY(MessageOut)
-
- /**< Writes a byte. */
- virtual void writeInt8(const int8_t value,
- const char *const str);
-
- /**< Writes a short. */
- virtual void writeInt16(const int16_t value,
- const char *const str) = 0;
-
- /**< Writes a long. */
- virtual void writeInt32(const int32_t value,
- const char *const str) = 0;
-
- virtual void writeBeingId(const BeingId value,
- const char *const str) = 0;
-
- /**
- * Writes a string. If a fixed length is not given (-1), it is stored
- * as a short at the start of the string.
- */
- virtual void writeString(const std::string &string,
- int length,
- const char *const str);
-
- /**
- * Writes a string. If a fixed length is not given (-1), it is stored
- * as a short at the start of the string.
- */
- virtual void writeStringNoLog(const std::string &string,
- int length,
- const char *const str);
-
- /**
- * Returns the content of the message.
- */
- virtual const char *getData() const A_WARN_UNUSED;
-
- /**
- * Returns the length of the data.
- */
- virtual unsigned int getDataSize() const A_WARN_UNUSED;
-
- virtual ~MessageOut()
- { }
-
- static unsigned char toServerDirection(unsigned char direction)
- A_CONST;
-
- protected:
- /**
- * Constructor.
- */
- explicit MessageOut(const int16_t id);
-
- /**
- * Expand the packet data to be able to hold more data.
- *
- * NOTE: For performance enhancements this method could allocate extra
- * memory in advance instead of expanding size every time more data is
- * added.
- */
- virtual void expand(size_t size) const = 0;
-
- char *mData; /**< Data building up. */
- unsigned int mDataSize; /**< Size of data. */
- unsigned int mPos; /**< Position in the data. */
- uint16_t mId;
- bool mIgnore;
-};
-
-} // namespace Net
-
-#endif // NET_MESSAGEOUT_H
diff --git a/src/net/net.cpp b/src/net/net.cpp
deleted file mode 100644
index ebc654563..000000000
--- a/src/net/net.cpp
+++ /dev/null
@@ -1,194 +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 "net/net.h"
-
-#include "configuration.h"
-
-#include "net/loginhandler.h"
-
-#ifdef TMWA_SUPPORT
-#include "net/tmwa/generalhandler.h"
-#endif // TMWA_SUPPORT
-
-#include "net/eathena/generalhandler.h"
-
-#include "utils/delete2.h"
-
-#include "debug.h"
-
-int evolPacketOffset = 0;
-
-namespace Net
-{
- class AuctionHandler;
- class BankHandler;
- class BattleGroundHandler;
- class BuyingStoreHandler;
- class CashShopHandler;
- class ElementalHandler;
- class FamilyHandler;
- class FriendsHandler;
- class HomunculusHandler;
- class Mail2Handler;
- class MailHandler;
- class MapHandler;
- class MarketHandler;
- class MercenaryHandler;
- class SearchStoreHandler;
- class RouletteHandler;
- class VendingHandler;
- class AdminHandler;
- class BeingHandler;
- class BuySellHandler;
- class CharServerHandler;
- class ChatHandler;
- class GameHandler;
- class GuildHandler;
- class InventoryHandler;
- class NpcHandler;
- class PartyHandler;
- class PetHandler;
- class PlayerHandler;
- class QuestHandler;
- class ServerFeatures;
- class SkillHandler;
- class TradeHandler;
-} // namespace Net
-
-Net::AdminHandler *adminHandler = nullptr;
-Net::CharServerHandler *charServerHandler = nullptr;
-Net::ChatHandler *chatHandler = nullptr;
-Net::GeneralHandler *generalHandler = nullptr;
-Net::InventoryHandler *inventoryHandler = nullptr;
-Net::LoginHandler *loginHandler = nullptr;
-Net::GameHandler *gameHandler = nullptr;
-Net::GuildHandler *guildHandler = nullptr;
-Net::NpcHandler *npcHandler = nullptr;
-Net::PartyHandler *partyHandler = nullptr;
-Net::PetHandler *petHandler = nullptr;
-Net::PlayerHandler *playerHandler = nullptr;
-Net::SkillHandler *skillHandler = nullptr;
-Net::TradeHandler *tradeHandler = nullptr;
-Net::BeingHandler *beingHandler = nullptr;
-Net::BuySellHandler *buySellHandler = nullptr;
-Net::ServerFeatures *serverFeatures = nullptr;
-Net::AuctionHandler *auctionHandler = nullptr;
-Net::BankHandler *bankHandler = nullptr;
-Net::BattleGroundHandler *battleGroundHandler = nullptr;
-Net::BuyingStoreHandler *buyingStoreHandler = nullptr;
-Net::CashShopHandler *cashShopHandler = nullptr;
-Net::ElementalHandler *elementalHandler = nullptr;
-Net::FamilyHandler *familyHandler = nullptr;
-Net::FriendsHandler *friendsHandler = nullptr;
-Net::HomunculusHandler *homunculusHandler = nullptr;
-Net::Mail2Handler *mail2Handler = nullptr;
-Net::MailHandler *mailHandler = nullptr;
-Net::MapHandler *mapHandler = nullptr;
-Net::MarketHandler *marketHandler = nullptr;
-Net::MercenaryHandler *mercenaryHandler = nullptr;
-Net::RouletteHandler *rouletteHandler = nullptr;
-Net::SearchStoreHandler *searchStoreHandler = nullptr;
-Net::VendingHandler *vendingHandler = nullptr;
-Net::QuestHandler *questHandler = nullptr;
-
-namespace Net
-{
-ServerTypeT networkType = ServerType::UNKNOWN;
-std::set<int> ignorePackets;
-
-void connectToServer(const ServerInfo &server)
-{
- BLOCK_START("Net::connectToServer")
- if (networkType == server.type &&
- generalHandler != nullptr)
- {
- generalHandler->reload();
- }
- else
- {
- if (networkType != ServerType::UNKNOWN &&
- generalHandler != nullptr)
- {
- generalHandler->unload();
- delete2(generalHandler);
- }
-
- switch (server.type)
- {
- case ServerType::EATHENA:
- case ServerType::EVOL2:
- new EAthena::GeneralHandler;
- break;
- case ServerType::TMWATHENA:
- case ServerType::UNKNOWN:
- default:
-#ifdef TMWA_SUPPORT
- new TmwAthena::GeneralHandler;
-#else // TMWA_SUPPORT
-
- new EAthena::GeneralHandler;
-#endif // TMWA_SUPPORT
-
- break;
- }
-
- if (generalHandler != nullptr)
- generalHandler->load();
-
- networkType = server.type;
- }
-
- if (loginHandler != nullptr)
- {
- loginHandler->setServer(server);
- loginHandler->connect();
- }
- BLOCK_END("Net::connectToServer")
-}
-
-void unload()
-{
- const GeneralHandler *const handler = generalHandler;
- if (handler != nullptr)
- handler->unload();
- ignorePackets.clear();
- delete2(generalHandler);
-}
-
-ServerTypeT getNetworkType()
-{
- return networkType;
-}
-
-void loadIgnorePackets()
-{
- const std::string str = config.getStringValue("ignorelogpackets");
- splitToIntSet(ignorePackets, str, ',');
-}
-
-bool isIgnorePacket(const int id)
-{
- return ignorePackets.find(id) != ignorePackets.end();
-}
-
-} // namespace Net
diff --git a/src/net/net.h b/src/net/net.h
deleted file mode 100644
index f7c05adf0..000000000
--- a/src/net/net.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 NET_NET_H
-#define NET_NET_H
-
-/**
- * \namespace Net
- *
- * The network communication layer. It is composed of a host of interfaces that
- * interact with different aspects of the game. They have different
- * implementations depending on the type of server the client is connecting to.
- */
-
-#include "enums/net/servertype.h"
-
-class ServerInfo;
-
-namespace Net
-{
-
-ServerTypeT getNetworkType() A_WARN_UNUSED;
-
-/**
- * Handles server detection and connection
- */
-void connectToServer(const ServerInfo &server);
-
-void unload();
-
-void loadIgnorePackets();
-
-bool isIgnorePacket(const int id);
-
-} // namespace Net
-
-#endif // NET_NET_H
diff --git a/src/net/npchandler.h b/src/net/npchandler.h
deleted file mode 100644
index 1e41c1144..000000000
--- a/src/net/npchandler.h
+++ /dev/null
@@ -1,123 +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 NET_NPCHANDLER_H
-#define NET_NPCHANDLER_H
-
-#include <iosfwd>
-
-#include "enums/being/cookingtype.h"
-
-#include "enums/net/npcaction.h"
-
-#include "enums/simpletypes/beingid.h"
-#include "enums/simpletypes/itemcolor.h"
-
-#include "utils/vector.h"
-
-#include "localconsts.h"
-
-class Being;
-class NpcDialog;
-class ShopItem;
-
-namespace Net
-{
-
-class MessageIn;
-
-class NpcHandler notfinal
-{
- public:
- NpcHandler()
- { }
-
- A_DELETE_COPY(NpcHandler)
-
- virtual ~NpcHandler()
- { }
-
- virtual BeingId getNpc(Net::MessageIn &msg,
- const NpcActionT action) = 0;
-
- virtual void talk(const Being *const being) const = 0;
-
- virtual void nextDialog(const BeingId npcId) const = 0;
-
- virtual void closeDialog(const BeingId npcId) = 0;
-
- virtual void listInput(const BeingId npcId,
- const unsigned char value) const = 0;
-
- virtual void integerInput(const BeingId npcId,
- const int value) const = 0;
-
- virtual void stringInput(const BeingId npcId,
- const std::string &value) const = 0;
-
- virtual void buy(const Being *const being) const = 0;
-
- virtual void buy(const BeingId beingId) const = 0;
-
- virtual void sell(const BeingId beingId) const = 0;
-
- virtual void buyItem(const BeingId beingId,
- const int itemId,
- const ItemColor color,
- const int amount) const = 0;
-
- virtual void buyItems(STD_VECTOR<ShopItem*> &items) const = 0;
-
- virtual void sellItem(const BeingId beingId,
- const int itemId,
- const int amount) const = 0;
-
- virtual void sellItems(STD_VECTOR<ShopItem*> &items) const = 0;
-
- virtual void completeProgressBar() const = 0;
-
- virtual void produceMix(const int nameId,
- const int materialId1,
- const int materialId2,
- const int materialId3) const = 0;
-
- virtual void cooking(const CookingTypeT type,
- const int nameId) const = 0;
-
- virtual void repair(const int index) const = 0;
-
- virtual void refine(const int index) const = 0;
-
- virtual void identify(const int index) const = 0;
-
- virtual void selectArrow(const int nameId) const = 0;
-
- virtual void selectAutoSpell(const int skillId) const = 0;
-
- virtual NpcDialog *getCurrentNpcDialog() const = 0;
-};
-
-} // namespace Net
-
-extern Net::NpcHandler *npcHandler;
-
-#endif // NET_NPCHANDLER_H
diff --git a/src/net/packetcounters.cpp b/src/net/packetcounters.cpp
deleted file mode 100644
index 6d0a8bbf6..000000000
--- a/src/net/packetcounters.cpp
+++ /dev/null
@@ -1,137 +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 "net/packetcounters.h"
-
-#include "utils/cast.h"
-
-#include "debug.h"
-
-extern volatile time_t cur_time;
-extern volatile bool runCounters;
-
-int PacketCounters::mInCurrentSec = 0;
-int PacketCounters::mInBytes = 0;
-int PacketCounters::mInBytesCalc = 0;
-int PacketCounters::mInPackets = 0;
-int PacketCounters::mInPacketsCalc = 0;
-int PacketCounters::mOutCurrentSec = 0;
-int PacketCounters::mOutBytes = 0;
-int PacketCounters::mOutBytesCalc = 0;
-int PacketCounters::mOutPackets = 0;
-int PacketCounters::mOutPacketsCalc = 0;
-
-void PacketCounters::incInBytes(const int cnt)
-{
- if (!runCounters)
- return;
-
- updateCounter(PacketCounters::mInCurrentSec, PacketCounters::mInBytesCalc,
- PacketCounters::mInBytes);
-
- PacketCounters::mInBytes += cnt;
-}
-
-void PacketCounters::incInPackets()
-{
- if (!runCounters)
- return;
-
- updateCounter(PacketCounters::mInCurrentSec,
- PacketCounters::mInPacketsCalc, PacketCounters::mInPackets);
-
- PacketCounters::mInPackets ++;
-}
-
-int PacketCounters::getInBytes()
-{
- return PacketCounters::mInBytesCalc;
-}
-
-int PacketCounters::getInPackets()
-{
- return PacketCounters::mInPacketsCalc;
-}
-
-void PacketCounters::incOutBytes(const int cnt)
-{
- if (!runCounters)
- return;
-
- updateCounter(PacketCounters::mOutCurrentSec,
- PacketCounters::mOutBytesCalc, PacketCounters::mOutBytes);
-
- PacketCounters::mOutBytes += cnt;
-}
-
-void PacketCounters::incOutPackets()
-{
- if (!runCounters)
- return;
-
- updateCounter(PacketCounters::mOutCurrentSec,
- PacketCounters::mOutPacketsCalc,
- PacketCounters::mOutPackets);
-
- PacketCounters::mOutPackets ++;
-}
-
-int PacketCounters::getOutBytes()
-{
- return PacketCounters::mOutBytesCalc;
-}
-
-int PacketCounters::getOutPackets()
-{
- return PacketCounters::mOutPacketsCalc;
-}
-
-
-void PacketCounters::updateCounter(int &restrict currentSec,
- int &restrict calc,
- int &restrict counter)
-{
- const int idx = CAST_S32(cur_time % 60);
- if (currentSec != idx)
- {
- currentSec = idx;
- calc = counter;
- counter = 0;
- }
-}
-
-void PacketCounters::update()
-{
- if (!runCounters)
- return;
-
- BLOCK_START("PacketCounters::update")
- updateCounter(PacketCounters::mInCurrentSec, PacketCounters::mInBytesCalc,
- PacketCounters::mInBytes);
- updateCounter(PacketCounters::mInCurrentSec,
- PacketCounters::mInPacketsCalc, PacketCounters::mInPackets);
- updateCounter(PacketCounters::mOutCurrentSec,
- PacketCounters::mOutBytesCalc, PacketCounters::mOutBytes);
- updateCounter(PacketCounters::mOutCurrentSec,
- PacketCounters::mOutPacketsCalc, PacketCounters::mOutPackets);
- BLOCK_END("PacketCounters::update")
-}
diff --git a/src/net/packetcounters.h b/src/net/packetcounters.h
deleted file mode 100644
index 6c3e0d8f9..000000000
--- a/src/net/packetcounters.h
+++ /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/>.
- */
-
-#ifndef NET_PACKETCOUNTERS_H
-#define NET_PACKETCOUNTERS_H
-
-#include "localconsts.h"
-
-class PacketCounters final
-{
- public:
- PacketCounters()
- { }
-
- A_DELETE_COPY(PacketCounters)
-
- static void incInBytes(const int cnt);
-
- static void incInPackets();
-
- static int getInBytes() A_WARN_UNUSED;
-
- static int getInPackets() A_WARN_UNUSED;
-
- static void incOutBytes(const int cnt);
-
- static void incOutPackets();
-
- static int getOutBytes() A_WARN_UNUSED;
-
- static int getOutPackets() A_WARN_UNUSED;
-
- static void update();
-
- static int mInCurrentSec;
- static int mInBytes;
- static int mInBytesCalc;
- static int mInPackets;
- static int mInPacketsCalc;
- static int mOutCurrentSec;
- static int mOutBytes;
- static int mOutBytesCalc;
- static int mOutPackets;
- static int mOutPacketsCalc;
-
- private:
- static void updateCounter(int &restrict currentSec,
- int &restrict calc,
- int &restrict counter);
-};
-
-#endif // NET_PACKETCOUNTERS_H
diff --git a/src/net/packetfunction.h b/src/net/packetfunction.h
deleted file mode 100644
index 832545ca3..000000000
--- a/src/net/packetfunction.h
+++ /dev/null
@@ -1,33 +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 NET_PACKETFUNCTION_H
-#define NET_PACKETFUNCTION_H
-
-#include "localconsts.h"
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-typedef void (*PacketFuncPtr) (Net::MessageIn &msg);
-
-#endif // NET_PACKETFUNCTION_H
diff --git a/src/net/packetinfo.h b/src/net/packetinfo.h
deleted file mode 100644
index 555314e5a..000000000
--- a/src/net/packetinfo.h
+++ /dev/null
@@ -1,46 +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 NET_PACKETINFO_H
-#define NET_PACKETINFO_H
-
-#include "net/packetfunction.h"
-
-#include "localconsts.h"
-
-struct PacketInfo final
-{
- PacketInfo() :
- name(nullptr),
- func(nullptr),
- len(0),
- version(0)
- {
- }
-
- A_DELETE_COPY(PacketInfo)
-
- const char *name;
- PacketFuncPtr func;
- int len;
- int version;
-};
-
-#endif // NET_PACKETINFO_H
diff --git a/src/net/packetlimiter.cpp b/src/net/packetlimiter.cpp
deleted file mode 100644
index ba87badc7..000000000
--- a/src/net/packetlimiter.cpp
+++ /dev/null
@@ -1,323 +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 "net/packetlimiter.h"
-
-#include "configuration.h"
-#include "settings.h"
-
-#include "utils/cast.h"
-#include "utils/checkutils.h"
-#include "utils/timer.h"
-
-#include <sys/stat.h>
-
-#include "debug.h"
-
-struct PacketLimit final
-{
- A_DEFAULT_COPY(PacketLimit)
-
- int lastTime;
- int timeLimit;
- int cnt;
- int cntLimit;
-};
-
-PacketLimit mPacketLimits[CAST_SIZE(PacketType::PACKET_SIZE) + 1];
-
-void PacketLimiter::initPacketLimiter()
-{
- // here i setting packet limits. but current server is broken,
- // and this limits may not help.
-
- mPacketLimits[CAST_SIZE(
- PacketType::PACKET_CHAT)].timeLimit = 10 + 5;
- mPacketLimits[CAST_SIZE(
- PacketType::PACKET_CHAT)].lastTime = 0;
- mPacketLimits[CAST_SIZE(
- PacketType::PACKET_CHAT)].cntLimit = 1;
- mPacketLimits[CAST_SIZE(
- PacketType::PACKET_CHAT)].cnt = 0;
-
- // 10
- mPacketLimits[CAST_SIZE(
- PacketType::PACKET_PICKUP)].timeLimit = 10 + 5;
- mPacketLimits[CAST_SIZE(
- PacketType::PACKET_PICKUP)].lastTime = 0;
- mPacketLimits[CAST_SIZE(
- PacketType::PACKET_PICKUP)].cntLimit = 1;
- mPacketLimits[CAST_SIZE(
- PacketType::PACKET_PICKUP)].cnt = 0;
-
- // 10 5
- mPacketLimits[CAST_SIZE(
- PacketType::PACKET_DROP)].timeLimit = 5;
- mPacketLimits[CAST_SIZE(
- PacketType::PACKET_DROP)].lastTime = 0;
- mPacketLimits[CAST_SIZE(
- PacketType::PACKET_DROP)].cntLimit = 1;
- mPacketLimits[CAST_SIZE(
- PacketType::PACKET_DROP)].cnt = 0;
-
- // 100
- mPacketLimits[CAST_SIZE(
- PacketType::PACKET_NPC_NEXT)].timeLimit = 0;
- mPacketLimits[CAST_SIZE(
- PacketType::PACKET_NPC_NEXT)].lastTime = 0;
- mPacketLimits[CAST_SIZE(
- PacketType::PACKET_NPC_NEXT)].cntLimit = 1;
- mPacketLimits[CAST_SIZE(
- PacketType::PACKET_NPC_NEXT)].cnt = 0;
-
- mPacketLimits[CAST_SIZE(
- PacketType::PACKET_NPC_INPUT)].timeLimit = 100;
- mPacketLimits[CAST_SIZE(
- PacketType::PACKET_NPC_INPUT)].lastTime = 0;
- mPacketLimits[CAST_SIZE(
- PacketType::PACKET_NPC_INPUT)].cntLimit = 1;
- mPacketLimits[CAST_SIZE(
- PacketType::PACKET_NPC_INPUT)].cnt = 0;
-
- // 50
- mPacketLimits[CAST_SIZE(
- PacketType::PACKET_NPC_TALK)].timeLimit = 60;
- mPacketLimits[CAST_SIZE(
- PacketType::PACKET_NPC_TALK)].lastTime = 0;
- mPacketLimits[CAST_SIZE(
- PacketType::PACKET_NPC_TALK)].cntLimit = 1;
- mPacketLimits[CAST_SIZE(
- PacketType::PACKET_NPC_TALK)].cnt = 0;
-
- // 10
- mPacketLimits[CAST_SIZE(
- PacketType::PACKET_EMOTE)].timeLimit = 10 + 5;
- mPacketLimits[CAST_SIZE(
- PacketType::PACKET_EMOTE)].lastTime = 0;
- mPacketLimits[CAST_SIZE(
- PacketType::PACKET_EMOTE)].cntLimit = 1;
- mPacketLimits[CAST_SIZE(
- PacketType::PACKET_EMOTE)].cnt = 0;
-
- // 100
- mPacketLimits[CAST_SIZE(
- PacketType::PACKET_SIT)].timeLimit = 100;
- mPacketLimits[CAST_SIZE(
- PacketType::PACKET_SIT)].lastTime = 0;
- mPacketLimits[CAST_SIZE(
- PacketType::PACKET_SIT)].cntLimit = 1;
- mPacketLimits[CAST_SIZE(
- PacketType::PACKET_SIT)].cnt = 0;
-
- mPacketLimits[CAST_SIZE(
- PacketType::PACKET_DIRECTION)].timeLimit = 50;
- mPacketLimits[CAST_SIZE(
- PacketType::PACKET_DIRECTION)].lastTime = 0;
- mPacketLimits[CAST_SIZE(
- PacketType::PACKET_DIRECTION)].cntLimit = 1;
- mPacketLimits[CAST_SIZE(
- PacketType::PACKET_DIRECTION)].cnt = 0;
-
- // 2+
- mPacketLimits[CAST_SIZE(
- PacketType::PACKET_ATTACK)].timeLimit = 2 + 10;
- mPacketLimits[CAST_SIZE(
- PacketType::PACKET_ATTACK)].lastTime = 0;
- mPacketLimits[CAST_SIZE(
- PacketType::PACKET_ATTACK)].cntLimit = 1;
- mPacketLimits[CAST_SIZE(
- PacketType::PACKET_ATTACK)].cnt = 0;
-
- mPacketLimits[CAST_SIZE(
- PacketType::PACKET_STOPATTACK)].timeLimit = 2 + 10;
- mPacketLimits[CAST_SIZE(
- PacketType::PACKET_STOPATTACK)].lastTime = 0;
- mPacketLimits[CAST_SIZE(
- PacketType::PACKET_STOPATTACK)].cntLimit = 1;
- mPacketLimits[CAST_SIZE(
- PacketType::PACKET_STOPATTACK)].cnt = 0;
-
- mPacketLimits[CAST_SIZE(
- PacketType::PACKET_ONLINELIST)].timeLimit = 1800;
- mPacketLimits[CAST_SIZE(
- PacketType::PACKET_ONLINELIST)].lastTime = 0;
- mPacketLimits[CAST_SIZE(
- PacketType::PACKET_ONLINELIST)].cntLimit = 1;
- mPacketLimits[CAST_SIZE(
- PacketType::PACKET_ONLINELIST)].cnt = 0;
-
- // 300ms + 50 fix
- mPacketLimits[CAST_SIZE(
- PacketType::PACKET_WHISPER)].timeLimit = 30 + 5;
- mPacketLimits[CAST_SIZE(
- PacketType::PACKET_WHISPER)].lastTime = 0;
- mPacketLimits[CAST_SIZE(
- PacketType::PACKET_WHISPER)].cntLimit = 1;
- mPacketLimits[CAST_SIZE(
- PacketType::PACKET_WHISPER)].cnt = 0;
-
- if (!settings.serverConfigDir.empty())
- {
- const std::string packetLimitsName = settings.serverConfigDir
- + "/packetlimiter.txt";
-
- std::ifstream inPacketFile;
- struct stat statbuf;
-
- if ((stat(packetLimitsName.c_str(), &statbuf) != 0)
- || !S_ISREG(statbuf.st_mode))
- {
- // wtiting new file
- writePacketLimits(packetLimitsName);
- }
- else
- { // reading existent file
- inPacketFile.open(packetLimitsName.c_str(), std::ios::in);
- char line[101];
-
- if (!inPacketFile.is_open() || !inPacketFile.getline(line, 100))
- {
- inPacketFile.close();
- return;
- }
-
- const int ver = atoi(line);
-
- for (int f = 0;
- f < CAST_S32(PacketType::PACKET_SIZE);
- f ++)
- {
- if (!inPacketFile.getline(line, 100))
- break;
-
- if (!(ver == 1 &&
- (static_cast<PacketTypeT>(f) == PacketType::PACKET_DROP ||
- static_cast<PacketTypeT>(f)
- == PacketType::PACKET_NPC_NEXT)))
- {
- mPacketLimits[f].timeLimit = atoi(line);
- }
- }
- inPacketFile.close();
- if (ver < 5)
- writePacketLimits(packetLimitsName);
- }
- }
-}
-
-void PacketLimiter::writePacketLimits(const std::string &packetLimitsName)
-{
- std::ofstream outPacketFile;
- outPacketFile.open(packetLimitsName.c_str(), std::ios::out);
- if (!outPacketFile.is_open())
- {
- reportAlways("Error opening file for writing: %s",
- packetLimitsName.c_str());
- outPacketFile.close();
- return;
- }
- outPacketFile << "4" << std::endl;
- for (int f = 0; f < CAST_S32(PacketType::PACKET_SIZE); f ++)
- {
- outPacketFile << toString(mPacketLimits[f].timeLimit)
- << std::endl;
- }
-
- outPacketFile.close();
-}
-
-bool PacketLimiter::checkPackets(const PacketTypeT type)
-{
- if (type > PacketType::PACKET_SIZE)
- return false;
-
- if (!serverConfig.getValueBool("enableBuggyServers", true))
- return true;
-
- const PacketLimit &limit = mPacketLimits[CAST_SIZE(type)];
- const int timeLimit = limit.timeLimit;
-
- if (timeLimit == 0)
- return true;
-
- const int time = tick_time;
- const int lastTime = limit.lastTime;
- const int cnt = limit.cnt;
- const int cntLimit = limit.cntLimit;
-
- if (lastTime > tick_time)
- {
-// instance()->mPacketLimits[type].lastTime = time;
-// instance()->mPacketLimits[type].cnt = 0;
-
- return true;
- }
- else if (lastTime + timeLimit > time)
- {
- if (cnt >= cntLimit)
- {
- return false;
- }
-// instance()->mPacketLimits[type].cnt ++;
- return true;
- }
-// instance()->mPacketLimits[type].lastTime = time;
-// instance()->mPacketLimits[type].cnt = 1;
- return true;
-}
-
-bool PacketLimiter::limitPackets(const PacketTypeT type)
-{
- if (CAST_S32(type) < 0 || type > PacketType::PACKET_SIZE)
- return false;
-
- if (!serverConfig.getValueBool("enableBuggyServers", true))
- return true;
-
- PacketLimit &pack = mPacketLimits[CAST_SIZE(type)];
- const int timeLimit = pack.timeLimit;
-
- if (timeLimit == 0)
- return true;
-
- const int time = tick_time;
- const int lastTime = pack.lastTime;
- const int cnt = pack.cnt;
- const int cntLimit = pack.cntLimit;
-
- if (lastTime > tick_time)
- {
- pack.lastTime = time;
- pack.cnt = 0;
- return true;
- }
- else if (lastTime + timeLimit > time)
- {
- if (cnt >= cntLimit)
- {
- return false;
- }
- pack.cnt ++;
- return true;
- }
- pack.lastTime = time;
- pack.cnt = 1;
- return true;
-}
diff --git a/src/net/packetlimiter.h b/src/net/packetlimiter.h
deleted file mode 100644
index ec8aa7b79..000000000
--- a/src/net/packetlimiter.h
+++ /dev/null
@@ -1,41 +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 NET_PACKETLIMITER_H
-#define NET_PACKETLIMITER_H
-
-#include "enums/net/packettype.h"
-
-#include <string>
-
-#include "localconsts.h"
-
-namespace PacketLimiter
-{
- void initPacketLimiter();
-
- void writePacketLimits(const std::string &packetLimitsName);
-
- bool limitPackets(const PacketTypeT type) A_WARN_UNUSED;
-
- bool checkPackets(const PacketTypeT type) A_WARN_UNUSED;
-} // namespace PacketLimiter
-
-#endif // NET_PACKETLIMITER_H
diff --git a/src/net/partyhandler.h b/src/net/partyhandler.h
deleted file mode 100644
index 9e3e8763d..000000000
--- a/src/net/partyhandler.h
+++ /dev/null
@@ -1,90 +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 NET_PARTYHANDLER_H
-#define NET_PARTYHANDLER_H
-
-#include "localconsts.h"
-
-#include "enums/net/partyshare.h"
-
-#include "gui/widgets/tabs/chat/chattab.h"
-
-class Being;
-
-namespace Net
-{
-
-class PartyHandler notfinal
-{
- public:
- PartyHandler()
- { }
-
- A_DELETE_COPY(PartyHandler)
-
- virtual ~PartyHandler()
- { }
-
- virtual void create(const std::string &name) const = 0;
-
- virtual void join(const int partyId) const = 0;
-
- virtual void invite(const std::string &name) const = 0;
-
- virtual void leave() const = 0;
-
- virtual void kick(const Being *const player) const = 0;
-
- virtual void kick(const std::string &name) const = 0;
-
- virtual void chat(const std::string &text) const = 0;
-
- virtual PartyShareT getShareExperience() const A_WARN_UNUSED = 0;
-
- virtual void setShareExperience(const PartyShareT share) const = 0;
-
- virtual PartyShareT getShareItems() const A_WARN_UNUSED = 0;
-
- virtual void setShareItems(const PartyShareT share) const = 0;
-
- virtual PartyShareT getShareAutoItems() const A_WARN_UNUSED = 0;
-
- virtual void setShareAutoItems(const PartyShareT share) const = 0;
-
- virtual void changeLeader(const std::string &name) const = 0;
-
- virtual void allowInvite(const bool allow) const = 0;
-
- virtual void clear() const = 0;
-
- virtual void inviteResponse(const int partyId,
- const bool accept) const = 0;
-
- virtual ChatTab *getTab() const = 0;
-};
-
-} // namespace Net
-
-extern Net::PartyHandler *partyHandler;
-
-#endif // NET_PARTYHANDLER_H
diff --git a/src/net/pethandler.h b/src/net/pethandler.h
deleted file mode 100644
index 2520d56ee..000000000
--- a/src/net/pethandler.h
+++ /dev/null
@@ -1,68 +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 NET_PETHANDLER_H
-#define NET_PETHANDLER_H
-
-#include "being/being.h"
-
-namespace Net
-{
-
-class PetHandler notfinal
-{
- public:
- PetHandler()
- { }
-
- A_DELETE_COPY(PetHandler)
-
- virtual ~PetHandler()
- { }
-
- virtual void move(const int x,
- const int y) const = 0;
-
- virtual void emote(const uint8_t emoteId) = 0;
-
- virtual void catchPet(const Being *const being) const = 0;
-
- virtual void sendPetMessage(const int data) const = 0;
-
- virtual void setName(const std::string &name) const = 0;
-
- virtual void requestStatus() const = 0;
-
- virtual void feed() const = 0;
-
- virtual void dropLoot() const = 0;
-
- virtual void returnToEgg() const = 0;
-
- virtual void unequip() const = 0;
-
- virtual void setDirection(const unsigned char type) const = 0;
-};
-
-} // namespace Net
-
-extern Net::PetHandler *petHandler;
-
-#endif // NET_PETHANDLER_H
diff --git a/src/net/playerhandler.h b/src/net/playerhandler.h
deleted file mode 100644
index 72cf8c9de..000000000
--- a/src/net/playerhandler.h
+++ /dev/null
@@ -1,120 +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 NET_PLAYERHANDLER_H
-#define NET_PLAYERHANDLER_H
-
-#include "being/flooritem.h"
-
-#include "enums/being/attributes.h"
-#include "enums/being/beingaction.h"
-
-#include "enums/simpletypes/keep.h"
-#include "enums/simpletypes/notify.h"
-
-#include "net/messagein.h"
-
-namespace Net
-{
-
-class PlayerHandler notfinal
-{
- public:
- PlayerHandler()
- { }
-
- A_DELETE_COPY(PlayerHandler)
-
- virtual ~PlayerHandler()
- { }
-
- virtual void attack(const BeingId id,
- const Keep keep) const = 0;
-
- virtual void stopAttack() const = 0;
-
- virtual void emote(const uint8_t emoteId) const = 0;
-
- virtual void increaseAttribute(const AttributesT attr,
- const int amount) const = 0;
-
- virtual void increaseSkill(const uint16_t skillId) const = 0;
-
- virtual void pickUp(const FloorItem *const floorItem) const = 0;
-
- virtual void setDirection(const unsigned char direction) const = 0;
-
- virtual void setDestination(const int x, const int y,
- const int direction) const = 0;
-
- virtual void changeAction(const BeingActionT &action) const = 0;
-
- virtual void respawn() const = 0;
-
- virtual void ignorePlayer(const std::string &player,
- const bool ignore) const = 0;
-
- virtual void ignoreAll(const bool ignore) const = 0;
-
- virtual bool canUseMagic() const = 0;
-
- virtual int getDefaultWalkSpeed() const A_WARN_UNUSED = 0;
-
- virtual void requestOnlineList() const = 0;
-
- virtual void updateStatus(const uint8_t status) const = 0;
-
- virtual void setShortcut(const int idx,
- const uint8_t type,
- const int id,
- const int level) const = 0;
-
- virtual void shortcutShiftRow(const int row) const = 0;
-
- virtual void removeOption() const = 0;
-
- virtual void changeCart(const int type) const = 0;
-
- virtual void setMemo() const = 0;
-
- virtual void doriDori() const = 0;
-
- virtual void explosionSpirits() const = 0;
-
- virtual void requestPvpInfo() const = 0;
-
- virtual void revive() const = 0;
-
- virtual void setViewEquipment(const bool allow) const = 0;
-
- virtual void setStat(Net::MessageIn &msg,
- const int type,
- const int base,
- const int mod,
- const Notify notify) const = 0;
-};
-
-} // namespace Net
-
-extern Net::PlayerHandler *playerHandler;
-
-#endif // NET_PLAYERHANDLER_H
diff --git a/src/net/protocoloutdefine.h b/src/net/protocoloutdefine.h
deleted file mode 100644
index b8ab72064..000000000
--- a/src/net/protocoloutdefine.h
+++ /dev/null
@@ -1,28 +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 NET_PROTOCOLOUTDEFINE_H
-#define NET_PROTOCOLOUTDEFINE_H
-
-#define packet(name, id, sz, comment) int name = id
-#define packet2(name, id, sz, comment) int name = id + evolPacketOffset
-#define PROTOCOLOUT_VOID
-
-#endif // NET_PROTOCOLOUTDEFINE_H
diff --git a/src/net/protocoloutinclude.h b/src/net/protocoloutinclude.h
deleted file mode 100644
index 08dddbf95..000000000
--- a/src/net/protocoloutinclude.h
+++ /dev/null
@@ -1,27 +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 NET_PROTOCOLOUTINCLUDE_H
-#define NET_PROTOCOLOUTINCLUDE_H
-
-#define packet(name, id, sz, comment) extern int name
-#define packet2(name, id, sz, comment) extern int name
-
-#endif // NET_PROTOCOLOUTINCLUDE_H
diff --git a/src/net/protocoloutupdate.h b/src/net/protocoloutupdate.h
deleted file mode 100644
index ea142a69d..000000000
--- a/src/net/protocoloutupdate.h
+++ /dev/null
@@ -1,28 +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 NET_PROTOCOLOUTUPDATE_H
-#define NET_PROTOCOLOUTUPDATE_H
-
-#define packet(name, id, sz, comment) name = id
-#define packet2(name, id, sz, comment) name = (id) + evolPacketOffset
-#define PROTOCOLOUTUPDATE_VOID
-
-#endif // NET_PROTOCOLOUTUPDATE_H
diff --git a/src/net/questhandler.h b/src/net/questhandler.h
deleted file mode 100644
index 37aefbae2..000000000
--- a/src/net/questhandler.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 NET_QUESTHANDLER_H
-#define NET_QUESTHANDLER_H
-
-#include "localconsts.h"
-
-namespace Net
-{
-
-class QuestHandler notfinal
-{
- public:
- QuestHandler()
- { }
-
- A_DELETE_COPY(QuestHandler)
-
- virtual ~QuestHandler()
- { }
-
- virtual void setQeustActiveState(const int questId,
- const bool active) const = 0;
-};
-
-} // namespace Net
-
-extern Net::QuestHandler *questHandler;
-
-#endif // NET_QUESTHANDLER_H
diff --git a/src/net/recvpacketdefine.h b/src/net/recvpacketdefine.h
deleted file mode 100644
index 1ba7bba58..000000000
--- a/src/net/recvpacketdefine.h
+++ /dev/null
@@ -1,36 +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 NET_RECVPACKETDEFINE_H
-#define NET_RECVPACKETDEFINE_H
-
-#define packet(pname, pid, sz, pfunc, ver) \
- mPackets[pid].name = #pname; \
- mPackets[pid].len = sz; \
- mPackets[pid].func = pfunc; \
- mPackets[pid].version = ver
-
-#define packet2(pname, pid, sz, pfunc, ver) \
- mPackets[pid + evolPacketOffset].name = #pname; \
- mPackets[pid + evolPacketOffset].len = sz; \
- mPackets[pid + evolPacketOffset].func = pfunc; \
- mPackets[pid + evolPacketOffset].version = ver
-
-#endif // NET_RECVPACKETDEFINE_H
diff --git a/src/net/roulettehandler.h b/src/net/roulettehandler.h
deleted file mode 100644
index 6a88acdca..000000000
--- a/src/net/roulettehandler.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 NET_ROULETTEHANDLER_H
-#define NET_ROULETTEHANDLER_H
-
-#include "localconsts.h"
-
-namespace Net
-{
-
-class RouletteHandler notfinal
-{
- public:
- RouletteHandler()
- { }
-
- A_DELETE_COPY(RouletteHandler)
-
- virtual ~RouletteHandler()
- { }
-};
-
-} // namespace Net
-
-extern Net::RouletteHandler *rouletteHandler;
-
-#endif // NET_ROULETTEHANDLER_H
diff --git a/src/net/sdltcpnet.cpp b/src/net/sdltcpnet.cpp
deleted file mode 100644
index dbfa2d5d6..000000000
--- a/src/net/sdltcpnet.cpp
+++ /dev/null
@@ -1,197 +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 "logger.h"
-
-#if defined __linux__ || defined __linux
-
-#include <sys/socket.h>
-
-#if defined(M_TCPOK) && !defined(ANDROID)
-#include <netinet/in.h>
-#include <netdb.h>
-#include <linux/tcp.h>
-#else // defined(M_TCPOK) && !defined(ANDROID)
-#include <netinet/in.h>
-#include <netinet/tcp.h>
-#include <netdb.h>
-#include <netinet/tcp.h>
-// Use linear timeouts for thin streams
-#define TCP_THIN_LINEAR_TIMEOUTS 16
-// Fast retrans. after 1 dupack
-#define TCP_THIN_DUPACK 17
-#endif // defined(M_TCPOK) && !defined(ANDROID)
-
-#endif // defined __linux__ || defined __linux
-
-PRAGMACLANG6GCC(GCC diagnostic push)
-PRAGMACLANG6GCC(GCC diagnostic ignored "-Wold-style-cast")
-#include "net/sdltcpnet.h"
-PRAGMACLANG6GCC(GCC diagnostic pop)
-
-#include "debug.h"
-
-#if !defined(__native_client__) \
- && (defined(TCP_THIN_LINEAR_TIMEOUTS) \
- || defined(TCP_THIN_DUPACK))
-// because actual struct is hidden in SDL_net we reinroducing it here
-struct TCPsocketHack final
-{
- TCPsocketHack() :
- ready(0),
- channel(0),
- remoteAddress(),
- localAddress(),
- sflag()
- { }
-
- A_DELETE_COPY(TCPsocketHack)
-
- int ready;
- int channel;
- IPaddress remoteAddress;
- IPaddress localAddress;
- int sflag;
-};
-#endif // !defined(__native_client__)
- // && (defined(TCP_THIN_LINEAR_TIMEOUTS)
- // || defined(TCP_THIN_DUPACK))
-
-void TcpNet::init()
-{
- SDLNet_Init();
-}
-
-void TcpNet::quit()
-{
- SDLNet_Quit();
-}
-
-void TcpNet::closeSocket(const TcpNet::Socket socket)
-{
- SDLNet_TCP_Close(socket);
-}
-
-int TcpNet::send(const TcpNet::Socket sock, const void *const data,
- const int len)
-{
- return SDLNet_TCP_Send(sock, data, len);
-}
-
-const char *TcpNet::getError()
-{
- return SDL_GetError();
-}
-
-int TcpNet::resolveHost(IPaddress *const address, const char *const host,
- const Uint16 port)
-{
- return SDLNet_ResolveHost(address, host, port);
-}
-
-TcpNet::Socket TcpNet::open(IPaddress *const ip)
-{
- const TcpNet::Socket sock = SDLNet_TCP_Open(ip);
-#if !defined(__native_client__) \
- && (defined(TCP_THIN_LINEAR_TIMEOUTS) \
- || defined(TCP_THIN_DUPACK))
- if ((sock != nullptr) && (ip != nullptr))
- {
- const TCPsocketHack *const hack
- = reinterpret_cast<const TCPsocketHack *>(sock);
- // here we using some magic to compare TCPsocket and own padding
- // because actual struct TCPsocket not in headers
- if (hack != nullptr)
- {
- const IPaddress &addr = hack->remoteAddress;
- if (addr.host == ip->host && addr.port == ip->port)
- {
- const int val = 1;
-#ifdef TCP_THIN_LINEAR_TIMEOUTS
- if (setsockopt(hack->channel, IPPROTO_TCP,
- TCP_THIN_LINEAR_TIMEOUTS, &val, sizeof(val)) != 0)
- {
- logger->log_r("error on set TCP_THIN_LINEAR_TIMEOUTS");
- }
-#endif // TCP_THIN_LINEAR_TIMEOUTS
-#ifdef TCP_THIN_DUPACK
- if (setsockopt(hack->channel, IPPROTO_TCP,
- TCP_THIN_DUPACK, &val, sizeof(val)) != 0)
- {
- logger->log_r("error on set TCP_THIN_DUPACK");
- }
-#endif // TCP_THIN_DUPACK
- }
- }
- }
-#endif // !defined(__native_client__)
- // && (defined(TCP_THIN_LINEAR_TIMEOUTS)
- // || defined(TCP_THIN_DUPACK))
- return sock;
-}
-
-TcpNet::SocketSet TcpNet::allocSocketSet(const int maxsockets)
-{
- return SDLNet_AllocSocketSet(maxsockets);
-}
-
-int TcpNet::addSocket(const TcpNet::SocketSet set, const TcpNet::Socket sock)
-{
- PRAGMACLANG6GCC(GCC diagnostic push)
- PRAGMACLANG6GCC(GCC diagnostic ignored "-Wold-style-cast")
- return SDLNet_TCP_AddSocket(set, sock);
- PRAGMACLANG6GCC(GCC diagnostic pop)
-}
-
-int TcpNet::socketReady(const TcpNet::Socket sock)
-{
- PRAGMACLANG6GCC(GCC diagnostic push)
- PRAGMACLANG6GCC(GCC diagnostic ignored "-Wold-style-cast")
- return SDLNet_SocketReady(sock);
- PRAGMACLANG6GCC(GCC diagnostic pop)
-}
-
-int TcpNet::checkSockets(const TcpNet::SocketSet set, const Uint32 timeout)
-{
- return SDLNet_CheckSockets(set, timeout);
-}
-
-int TcpNet::recv(const TcpNet::Socket sock, void *const data, const int maxlen)
-{
- return SDLNet_TCP_Recv(sock, data, maxlen);
-}
-
-int TcpNet::delSocket(const TcpNet::SocketSet set, const TcpNet::Socket sock)
-{
- PRAGMACLANG6GCC(GCC diagnostic push)
- PRAGMACLANG6GCC(GCC diagnostic ignored "-Wold-style-cast")
- return SDLNet_TCP_DelSocket(set, sock);
- PRAGMACLANG6GCC(GCC diagnostic pop)
-}
-
-void TcpNet::freeSocketSet(const TcpNet::SocketSet set)
-{
- SDLNet_FreeSocketSet(set);
-}
-
-TcpNet::Socket TcpNet::accept(const TcpNet::Socket sock)
-{
- return SDLNet_TCP_Accept(sock);
-}
diff --git a/src/net/sdltcpnet.h b/src/net/sdltcpnet.h
deleted file mode 100644
index daedb2b73..000000000
--- a/src/net/sdltcpnet.h
+++ /dev/null
@@ -1,68 +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 NET_SDLTCPNET_H
-#define NET_SDLTCPNET_H
-
-#include "localconsts.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_net.h>
-PRAGMA48(GCC diagnostic pop)
-
-namespace TcpNet
-{
- typedef ::SDLNet_SocketSet SocketSet;
- typedef ::TCPsocket Socket;
-
- void init();
-
- void quit();
-
- void closeSocket(const TcpNet::Socket socket);
-
- int send(const TcpNet::Socket sock, const void *const data, const int len);
-
- const char *getError();
-
- int resolveHost(IPaddress *const address, const char *const host,
- const Uint16 port);
-
- TcpNet::Socket open(IPaddress *const ip);
-
- SocketSet allocSocketSet(const int maxsockets);
-
- int addSocket(const TcpNet::SocketSet set, const TcpNet::Socket sock);
-
- int socketReady(const TcpNet::Socket sock);
-
- int checkSockets(const TcpNet::SocketSet set, const Uint32 timeout);
-
- int recv(const TcpNet::Socket sock, void *const data, const int maxlen);
-
- int delSocket(const TcpNet::SocketSet set, const TcpNet::Socket sock);
-
- void freeSocketSet(const TcpNet::SocketSet set);
-
- TcpNet::Socket accept(const TcpNet::Socket sock);
-} // namespace TcpNet
-
-#endif // NET_SDLTCPNET_H
diff --git a/src/net/searchstorehandler.h b/src/net/searchstorehandler.h
deleted file mode 100644
index 56bcc1ce7..000000000
--- a/src/net/searchstorehandler.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 NET_SEARCHSTOREHANDLER_H
-#define NET_SEARCHSTOREHANDLER_H
-
-#include "enums/net/storesearchtype.h"
-
-#include "localconsts.h"
-
-namespace Net
-{
-
-class SearchStoreHandler notfinal
-{
- public:
- SearchStoreHandler()
- { }
-
- A_DELETE_COPY(SearchStoreHandler)
-
- virtual ~SearchStoreHandler()
- { }
-
- virtual void search(const StoreSearchTypeT type,
- const int minPrice,
- const int maxPrice,
- const int itemId) const = 0;
-
- virtual void nextPage() const = 0;
-
- virtual void close() const = 0;
-
- virtual void select(const int accountId,
- const int storeId,
- const int itemId) const = 0;
-};
-
-} // namespace Net
-
-extern Net::SearchStoreHandler *searchStoreHandler;
-
-#endif // NET_SEARCHSTOREHANDLER_H
diff --git a/src/net/serverfeatures.h b/src/net/serverfeatures.h
deleted file mode 100644
index aed1948c8..000000000
--- a/src/net/serverfeatures.h
+++ /dev/null
@@ -1,90 +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 NET_SERVERFEATURES_H
-#define NET_SERVERFEATURES_H
-
-#include "localconsts.h"
-
-namespace Net
-{
-class ServerFeatures notfinal
-{
- public:
- ServerFeatures()
- { }
-
- A_DELETE_COPY(ServerFeatures)
-
- virtual ~ServerFeatures()
- { }
-
- virtual bool haveServerOnlineList() const = 0;
-
- virtual bool haveServerHp() const = 0;
-
- virtual bool havePlayerStatusUpdate() const = 0;
-
- virtual bool haveIncompleteChatMessages() const = 0;
-
- virtual bool haveRaceSelection() const = 0;
-
- virtual bool haveLookSelection() const = 0;
-
- virtual bool haveMove3() const = 0;
-
- virtual bool haveCharOtherGender() const = 0;
-
- virtual bool haveMonsterAttackRange() const = 0;
-
- virtual bool haveEmailOnRegister() const = 0;
-
- virtual bool haveEmailOnDelete() const = 0;
-
- virtual bool haveServerVersion() const = 0;
-
- virtual bool haveMapServerVersion() const = 0;
-
- virtual bool haveNpcGender() const = 0;
-
- virtual bool haveJoinChannel() const = 0;
-
- virtual bool haveCreateCharGender() const = 0;
-
- virtual bool haveTalkPet() const = 0;
-
- virtual bool haveMovePet() const = 0;
-
- virtual bool haveServerWarpNames() const = 0;
-
- virtual bool haveExtendedRiding() const = 0;
-
- virtual bool haveExtendedDropsPosition() const = 0;
-
- virtual bool haveMoveWhileSit() const = 0;
-
- virtual bool haveKillerId() const = 0;
-};
-
-} // namespace Net
-
-extern Net::ServerFeatures *serverFeatures;
-
-#endif // NET_SERVERFEATURES_H
diff --git a/src/net/serverinfo.h b/src/net/serverinfo.h
deleted file mode 100644
index 2bdec0251..000000000
--- a/src/net/serverinfo.h
+++ /dev/null
@@ -1,228 +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 NET_SERVERINFO_H
-#define NET_SERVERINFO_H
-
-#include "enums/net/serverfreetype.h"
-#include "enums/net/servertype.h"
-
-#include "net/hostsgroup.h"
-#include "net/serverurlinfo.h"
-
-#include "utils/stringutils.h"
-
-#include "localconsts.h"
-
-class ServerInfo final
-{
- public:
- typedef std::pair<int, std::string> VersionString;
-
- ServerTypeT type;
- ServerFreeTypeT freeType;
- std::string name;
- std::string hostname;
- std::string althostname;
- std::string description;
- std::string registerUrl;
- std::string onlineListUrl;
- std::string supportUrl;
- std::string serverUrl;
- std::string defaultHostName;
- STD_VECTOR<std::string> updateMirrors;
- STD_VECTOR<HostsGroup> updateHosts;
- STD_VECTOR<ServerUrlInfo> freeSources;
- STD_VECTOR<ServerUrlInfo> nonFreeSources;
- STD_VECTOR<ServerUrlInfo> docs;
- uint16_t port;
- VersionString version;
- int packetVersion;
- bool save;
- bool persistentIp;
-
- ServerInfo() :
- type(ServerType::TMWATHENA),
- freeType(ServerFreeType::NotSet),
- name(),
- hostname(),
- althostname(),
- description(),
- registerUrl(),
- onlineListUrl(),
- supportUrl(),
- serverUrl(),
- defaultHostName(),
- updateMirrors(),
- updateHosts(),
- freeSources(),
- nonFreeSources(),
- docs(),
-#ifdef TMWA_SUPPORT
- port(6901),
-#else // TMWA_SUPPORT
- port(6900),
-#endif // TMWA_SUPPORT
- version(),
- packetVersion(),
- save(false),
- persistentIp(true)
- {
- version.first = 0;
- }
-
- ServerInfo(const ServerInfo &info) :
- type(info.type),
- freeType(info.freeType),
- name(info.name),
- hostname(info.hostname),
- althostname(info.althostname),
- description(info.description),
- registerUrl(info.registerUrl),
- onlineListUrl(info.onlineListUrl),
- supportUrl(info.supportUrl),
- serverUrl(info.serverUrl),
- defaultHostName(info.defaultHostName),
- updateMirrors(info.updateMirrors),
- updateHosts(info.updateHosts),
- freeSources(info.freeSources),
- nonFreeSources(info.nonFreeSources),
- docs(info.docs),
- port(info.port),
- version(),
- packetVersion(info.packetVersion),
- save(info.save),
- persistentIp(info.persistentIp)
- {
- version.first = info.version.first;
- version.second = info.version.second;
- }
-
- A_DEFAULT_COPY(ServerInfo)
-
- ServerInfo &operator=(const ServerInfo &info)
- {
- type = info.type;
- freeType = info.freeType;
- name = info.name;
- hostname = info.hostname;
- althostname = info.althostname;
- description = info.description;
- registerUrl = info.registerUrl;
- onlineListUrl = info.onlineListUrl;
- supportUrl = info.supportUrl;
- serverUrl = info.serverUrl;
- defaultHostName = info.defaultHostName;
- updateMirrors = info.updateMirrors;
- updateHosts = info.updateHosts;
- freeSources = info.freeSources;
- nonFreeSources = info.nonFreeSources;
- docs = info.docs;
- port = info.port;
- save = info.save;
- persistentIp = info.persistentIp;
- version.first = info.version.first;
- version.second = info.version.second;
- packetVersion = info.packetVersion;
- return *this;
- }
-
- bool isValid() const noexcept2 A_WARN_UNUSED
- {
- return !(hostname.empty()
- || port == 0
- || type == ServerType::UNKNOWN);
- }
-
- void clear()
- {
- type = ServerType::UNKNOWN;
- name.clear();
- hostname.clear();
- althostname.clear();
- port = 0;
- description.clear();
- registerUrl.clear();
- onlineListUrl.clear();
- supportUrl.clear();
- serverUrl.clear();
- defaultHostName.clear();
- updateMirrors.clear();
- updateHosts.clear();
- freeSources.clear();
- nonFreeSources.clear();
- docs.clear();
- version.first = 0;
- version.second.clear();
- packetVersion = 0;
- save = false;
- persistentIp = true;
- freeType = ServerFreeType::Unknown;
- }
-
- bool operator==(const ServerInfo &other) const
- {
- return name == other.name &&
- hostname == other.hostname &&
- port == other.port;
- }
-
- bool operator!=(const ServerInfo &other) const
- {
- return name != other.name ||
- hostname != other.hostname ||
- port != other.port;
- }
-
- static ServerTypeT parseType(const std::string &serverType)
- A_WARN_UNUSED
- {
-#ifdef TMWA_SUPPORT
- if (compareStrI(serverType, "tmwathena") == 0)
- return ServerType::TMWATHENA;
- else
-#endif // TMWA_SUPPORT
- if (compareStrI(serverType, "eathena") == 0)
- return ServerType::EATHENA;
- else if (compareStrI(serverType, "hercules") == 0)
- return ServerType::EATHENA;
- else if (compareStrI(serverType, "evol2") == 0)
- return ServerType::EVOL2;
- return ServerType::UNKNOWN;
- }
-
- static ServerFreeTypeT parseFreeType(const std::string &serverFreeType)
- A_WARN_UNUSED
- {
- if (compareStrI(serverFreeType, "free") == 0)
- return ServerFreeType::Free;
- else if (compareStrI(serverFreeType, "nonfree") == 0)
- return ServerFreeType::NonFree;
- else if (compareStrI(serverFreeType, "unknown") == 0)
- return ServerFreeType::Unknown;
- return ServerFreeType::NotSet;
- }
-};
-
-typedef STD_VECTOR<ServerInfo> ServerInfos;
-
-#endif // NET_SERVERINFO_H
diff --git a/src/net/serverurlinfo.h b/src/net/serverurlinfo.h
deleted file mode 100644
index ea04a8c2f..000000000
--- a/src/net/serverurlinfo.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 NET_SERVERURLINFO_H
-#define NET_SERVERURLINFO_H
-
-#include "localconsts.h"
-
-#include <string>
-
-struct ServerUrlInfo final
-{
- ServerUrlInfo() :
- name(),
- url()
- {
- }
-
- ServerUrlInfo(const std::string &name0,
- const std::string &url0) :
- name(name0),
- url(url0)
- {
- }
-
- A_DEFAULT_COPY(ServerUrlInfo)
-
- std::string name;
- std::string url;
-};
-
-#endif // NET_SERVERURLINFO_H
diff --git a/src/net/skillhandler.h b/src/net/skillhandler.h
deleted file mode 100644
index 299eb633a..000000000
--- a/src/net/skillhandler.h
+++ /dev/null
@@ -1,77 +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 NET_SKILLHANDLER_H
-#define NET_SKILLHANDLER_H
-
-#include "enums/simpletypes/beingid.h"
-
-#include <iosfwd>
-
-#include "localconsts.h"
-
-namespace Net
-{
-class SkillHandler notfinal
-{
- public:
- SkillHandler()
- { }
-
- A_DELETE_COPY(SkillHandler)
-
- virtual ~SkillHandler()
- { }
-
- virtual void useBeing(const int id,
- const int level,
- const BeingId beingId) const = 0;
-
- virtual void usePos(const int id,
- const int level,
- const int x, const int y) const = 0;
-
- virtual void usePos(const int id,
- const int level,
- const int x, const int y,
- const std::string &text) const = 0;
-
- virtual void useMap(const int id, const std::string &map) const = 0;
-
- virtual void getAlchemistRanks() const = 0;
-
- virtual void getBlacksmithRanks() const = 0;
-
- virtual void getPkRanks() const = 0;
-
- virtual void getTaekwonRanks() const = 0;
-
- virtual void feelSaveOk(const int which) const = 0;
-
- virtual void lessEffects(const bool isLess) const = 0;
-};
-
-} // namespace Net
-
-extern Net::SkillHandler *skillHandler;
-
-#endif // NET_SKILLHANDLER_H
diff --git a/src/net/tmwa/adminhandler.cpp b/src/net/tmwa/adminhandler.cpp
deleted file mode 100644
index b0d2ebfa3..000000000
--- a/src/net/tmwa/adminhandler.cpp
+++ /dev/null
@@ -1,299 +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 "net/tmwa/adminhandler.h"
-
-#include "game.h"
-
-#include "net/tmwa/messageout.h"
-#include "net/tmwa/protocolout.h"
-
-#include "utils/gmfunctions.h"
-#include "utils/stringutils.h"
-
-#include "debug.h"
-
-namespace TmwAthena
-{
-
-AdminHandler::AdminHandler() :
- Ea::AdminHandler()
-{
- adminHandler = this;
-}
-
-AdminHandler::~AdminHandler()
-{
- adminHandler = nullptr;
-}
-
-void AdminHandler::announce(const std::string &text) const
-{
- createOutPacket(CMSG_ADMIN_ANNOUNCE);
- outMsg.writeInt16(CAST_S16(text.length() + 4), "len");
- outMsg.writeString(text, CAST_S32(text.length()), "message");
-}
-
-void AdminHandler::localAnnounce(const std::string &text) const
-{
- createOutPacket(CMSG_ADMIN_LOCAL_ANNOUNCE);
- outMsg.writeInt16(CAST_S16(text.length() + 4), "len");
- outMsg.writeString(text, CAST_S32(text.length()), "message");
-}
-
-void AdminHandler::hide(const bool h A_UNUSED) const
-{
- createOutPacket(CMSG_ADMIN_HIDE);
- outMsg.writeInt32(0, "unused");
-}
-
-void AdminHandler::kick(const BeingId playerId) const
-{
- createOutPacket(CMSG_ADMIN_KICK);
- outMsg.writeBeingId(playerId, "account id");
-}
-
-void AdminHandler::kickAll() const
-{
-}
-
-void AdminHandler::warp(const std::string &map, const int x, const int y) const
-{
- Gm::runCommand("warp",
- strprintf("%s %d %d", map.c_str(), x, y));
-}
-
-void AdminHandler::resetStats() const
-{
-}
-
-void AdminHandler::resetSkills() const
-{
-}
-
-void AdminHandler::gotoName(const std::string &name) const
-{
- Gm::runCommand("goto", name);
-}
-
-void AdminHandler::recallName(const std::string &name) const
-{
- Gm::runCommand("recall", name);
-}
-
-void AdminHandler::mute(const Being *const being A_UNUSED,
- const int type A_UNUSED,
- const int limit A_UNUSED) const
-{
-}
-
-void AdminHandler::muteName(const std::string &name A_UNUSED) const
-{
-}
-
-void AdminHandler::requestLogin(const Being *const being A_UNUSED) const
-{
-}
-
-void AdminHandler::setTileType(const int x A_UNUSED, const int y A_UNUSED,
- const int type A_UNUSED) const
-{
-}
-
-void AdminHandler::unequipAll(const Being *const being A_UNUSED) const
-{
-}
-
-void AdminHandler::requestStats(const std::string &name A_UNUSED) const
-{
-}
-
-void AdminHandler::monsterInfo(const std::string &name A_UNUSED) const
-{
-}
-
-void AdminHandler::itemInfo(const std::string &name A_UNUSED) const
-{
-}
-
-void AdminHandler::whoDrops(const std::string &name A_UNUSED) const
-{
-}
-
-void AdminHandler::mobSearch(const std::string &name A_UNUSED) const
-{
-}
-
-void AdminHandler::mobSpawnSearch(const std::string &name A_UNUSED) const
-{
-}
-
-void AdminHandler::playerGmCommands(const std::string &name A_UNUSED) const
-{
-}
-
-void AdminHandler::playerCharGmCommands(const std::string &name A_UNUSED) const
-{
-}
-
-void AdminHandler::showLevel(const std::string &name A_UNUSED) const
-{
-}
-
-void AdminHandler::showStats(const std::string &name A_UNUSED) const
-{
-}
-
-void AdminHandler::showStorageList(const std::string &name A_UNUSED) const
-{
-}
-
-void AdminHandler::showCartList(const std::string &name A_UNUSED) const
-{
-}
-
-void AdminHandler::showInventoryList(const std::string &name A_UNUSED) const
-{
-}
-
-void AdminHandler::locatePlayer(const std::string &name A_UNUSED) const
-{
-}
-
-void AdminHandler::showAccountInfo(const std::string &name A_UNUSED) const
-{
-}
-
-void AdminHandler::spawnSlave(const std::string &name A_UNUSED) const
-{
-}
-
-void AdminHandler::spawnClone(const std::string &name A_UNUSED) const
-{
-}
-
-void AdminHandler::spawnSlaveClone(const std::string &name A_UNUSED) const
-{
-}
-
-void AdminHandler::spawnEvilClone(const std::string &name A_UNUSED) const
-{
-}
-
-void AdminHandler::savePosition(const std::string &name A_UNUSED) const
-{
-}
-
-void AdminHandler::loadPosition(const std::string &name A_UNUSED) const
-{
-}
-
-void AdminHandler::randomWarp(const std::string &name A_UNUSED) const
-{
-}
-
-void AdminHandler::gotoNpc(const std::string &name A_UNUSED) const
-{
-}
-
-void AdminHandler::killer(const std::string &name A_UNUSED) const
-{
-}
-
-void AdminHandler::killable(const std::string &name A_UNUSED) const
-{
-}
-
-void AdminHandler::heal(const std::string &name A_UNUSED) const
-{
-}
-
-void AdminHandler::alive(const std::string &name) const
-{
- Gm::runCommand("revive", name);
-}
-
-void AdminHandler::disguise(const std::string &name A_UNUSED) const
-{
-}
-
-void AdminHandler::immortal(const std::string &name A_UNUSED) const
-{
-}
-
-void AdminHandler::hide(const std::string &name A_UNUSED) const
-{
- Gm::runCommand("hide");
-}
-
-void AdminHandler::nuke(const std::string &name A_UNUSED) const
-{
-}
-
-void AdminHandler::kill(const std::string &name A_UNUSED) const
-{
-}
-
-void AdminHandler::jail(const std::string &name A_UNUSED) const
-{
-}
-
-void AdminHandler::unjail(const std::string &name A_UNUSED) const
-{
-}
-
-void AdminHandler::npcMove(const std::string &name A_UNUSED,
- const int x A_UNUSED,
- const int y A_UNUSED) const
-{
-}
-
-void AdminHandler::hideNpc(const std::string &name A_UNUSED) const
-{
-}
-
-void AdminHandler::showNpc(const std::string &name A_UNUSED) const
-{
-}
-
-void AdminHandler::changePartyLeader(const std::string &name A_UNUSED) const
-{
-}
-
-void AdminHandler::partyRecall(const std::string &name A_UNUSED) const
-{
-}
-
-void AdminHandler::breakGuild(const std::string &name A_UNUSED) const
-{
-}
-
-void AdminHandler::guildRecall(const std::string &name A_UNUSED) const
-{
-}
-
-void AdminHandler::slide(const int x, const int y) const
-{
- warp(Game::instance()->getCurrentMapName(), x, y);
-}
-
-} // namespace TmwAthena
diff --git a/src/net/tmwa/adminhandler.h b/src/net/tmwa/adminhandler.h
deleted file mode 100644
index 01e7adcac..000000000
--- a/src/net/tmwa/adminhandler.h
+++ /dev/null
@@ -1,178 +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 NET_TMWA_ADMINHANDLER_H
-#define NET_TMWA_ADMINHANDLER_H
-
-#include "net/ea/adminhandler.h"
-
-namespace TmwAthena
-{
-
-class AdminHandler final : public Ea::AdminHandler
-{
- public:
- AdminHandler();
-
- A_DELETE_COPY(AdminHandler)
-
- ~AdminHandler();
-
- void announce(const std::string &text) const override final;
-
- void localAnnounce(const std::string &text) const override final;
-
- void hide(const bool h) const override final;
-
- void kick(const BeingId playerId) const override final;
-
- void kickAll() const override final A_CONST;
-
- void warp(const std::string &map,
- const int x, const int y) const override final;
-
- void resetStats() const override final A_CONST;
-
- void resetSkills() const override final A_CONST;
-
- void gotoName(const std::string &name) const override final;
-
- void recallName(const std::string &name) const override final;
-
- void mute(const Being *const being,
- const int type,
- const int limit) const override final A_CONST;
-
- void muteName(const std::string &name) const override final A_CONST;
-
- void requestLogin(const Being *const being) const override final
- A_CONST;
-
- void setTileType(const int x, const int y,
- const int type) const override final A_CONST;
-
- void unequipAll(const Being *const being) const override final A_CONST;
-
- void requestStats(const std::string &name) const override final
- A_CONST;
-
- void monsterInfo(const std::string &name) const override final A_CONST;
-
- void itemInfo(const std::string &name) const override final A_CONST;
-
- void whoDrops(const std::string &name) const override final A_CONST;
-
- void mobSearch(const std::string &name) const override final A_CONST;
-
- void mobSpawnSearch(const std::string &name) const override final
- A_CONST;
-
- void playerGmCommands(const std::string &name) const override final
- A_CONST;
-
- void playerCharGmCommands(const std::string &name) const override final
- A_CONST;
-
- void showLevel(const std::string &name) const override final A_CONST;
-
- void showStats(const std::string &name) const override final A_CONST;
-
- void showStorageList(const std::string &name) const override final
- A_CONST;
-
- void showCartList(const std::string &name) const override final
- A_CONST;
-
- void showInventoryList(const std::string &name) const override final
- A_CONST;
-
- void locatePlayer(const std::string &name) const override final
- A_CONST;
-
- void showAccountInfo(const std::string &name) const override final
- A_CONST;
-
- void spawnSlave(const std::string &name) const override final A_CONST;
-
- void spawnClone(const std::string &name) const override final A_CONST;
-
- void spawnSlaveClone(const std::string &name) const override final
- A_CONST;
-
- void spawnEvilClone(const std::string &name) const override final
- A_CONST;
-
- void savePosition(const std::string &name) const override final
- A_CONST;
-
- void loadPosition(const std::string &name) const override final
- A_CONST;
-
- void randomWarp(const std::string &name) const override final A_CONST;
-
- void gotoNpc(const std::string &name) const override final A_CONST;
-
- void killer(const std::string &name) const override final A_CONST;
-
- void killable(const std::string &name) const override final A_CONST;
-
- void heal(const std::string &name) const override final A_CONST;
-
- void alive(const std::string &name) const override final;
-
- void disguise(const std::string &name) const override final A_CONST;
-
- void immortal(const std::string &name) const override final A_CONST;
-
- void hide(const std::string &name) const override final;
-
- void nuke(const std::string &name) const override final A_CONST;
-
- void kill(const std::string &name) const override final A_CONST;
-
- void jail(const std::string &name) const override final A_CONST;
-
- void unjail(const std::string &name) const override final A_CONST;
-
- void npcMove(const std::string &name,
- const int x,
- const int y) const override final A_CONST;
-
- void hideNpc(const std::string &name) const override final A_CONST;
-
- void showNpc(const std::string &name) const override final A_CONST;
-
- void changePartyLeader(const std::string &name) const override final
- A_CONST;
-
- void partyRecall(const std::string &name) const override final A_CONST;
-
- void breakGuild(const std::string &name) const override final A_CONST;
-
- void guildRecall(const std::string &name) const override final A_CONST;
-
- void slide(const int x, const int y) const override final;
-};
-
-} // namespace TmwAthena
-
-#endif // NET_TMWA_ADMINHANDLER_H
diff --git a/src/net/tmwa/auctionhandler.cpp b/src/net/tmwa/auctionhandler.cpp
deleted file mode 100644
index 1a45e4135..000000000
--- a/src/net/tmwa/auctionhandler.cpp
+++ /dev/null
@@ -1,81 +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 "net/tmwa/auctionhandler.h"
-
-#include "debug.h"
-
-namespace TmwAthena
-{
-
-AuctionHandler::AuctionHandler()
-{
- auctionHandler = this;
-}
-
-AuctionHandler::~AuctionHandler()
-{
- auctionHandler = nullptr;
-}
-
-void AuctionHandler::cancelReg() const
-{
-}
-
-void AuctionHandler::setItem(const Item *const item A_UNUSED,
- const int amount A_UNUSED) const
-{
-}
-
-void AuctionHandler::reg(const int currentPrice A_UNUSED,
- const int maxPrice A_UNUSED,
- const int hours A_UNUSED) const
-{
-}
-
-void AuctionHandler::cancel(const int auctionId A_UNUSED) const
-{
-}
-
-void AuctionHandler::close(const int auctionId A_UNUSED) const
-{
-}
-
-void AuctionHandler::bid(const int auctionId A_UNUSED,
- const int money A_UNUSED) const
-{
-}
-
-void AuctionHandler::search(const AuctionSearchTypeT type A_UNUSED,
- const int auctionId A_UNUSED,
- const std::string &text A_UNUSED,
- const int page A_UNUSED) const
-{
-}
-
-void AuctionHandler::buy() const
-{
-}
-
-void AuctionHandler::sell() const
-{
-}
-
-} // namespace TmwAthena
diff --git a/src/net/tmwa/auctionhandler.h b/src/net/tmwa/auctionhandler.h
deleted file mode 100644
index 9e88e603d..000000000
--- a/src/net/tmwa/auctionhandler.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 NET_TMWA_AUCTIONHANDLER_H
-#define NET_TMWA_AUCTIONHANDLER_H
-
-#include "net/auctionhandler.h"
-
-namespace TmwAthena
-{
-class AuctionHandler final : public Net::AuctionHandler
-{
- public:
- AuctionHandler();
-
- A_DELETE_COPY(AuctionHandler)
-
- ~AuctionHandler();
-
- void cancelReg() const override final A_CONST;
-
- void setItem(const Item *const item,
- const int amount) const override final A_CONST;
-
- void reg(const int currentPrice,
- const int maxPrice,
- const int hours) const override final A_CONST;
-
- void cancel(const int auctionId) const override final A_CONST;
-
- void close(const int auctionId) const override final A_CONST;
-
- void bid(const int auctionId,
- const int money) const override final A_CONST;
-
- void search(const AuctionSearchTypeT type,
- const int auctionId,
- const std::string &text,
- const int page) const override final A_CONST;
-
- void buy() const override final A_CONST;
-
- void sell() const override final A_CONST;
-};
-
-} // namespace TmwAthena
-
-#endif // NET_TMWA_AUCTIONHANDLER_H
diff --git a/src/net/tmwa/bankhandler.cpp b/src/net/tmwa/bankhandler.cpp
deleted file mode 100644
index cacab379f..000000000
--- a/src/net/tmwa/bankhandler.cpp
+++ /dev/null
@@ -1,59 +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 "net/tmwa/bankhandler.h"
-
-#include "debug.h"
-
-namespace TmwAthena
-{
-
-BankHandler::BankHandler() :
- Net::BankHandler()
-{
- bankHandler = this;
-}
-
-BankHandler::~BankHandler()
-{
- bankHandler = nullptr;
-}
-
-void BankHandler::deposit(const int money A_UNUSED) const
-{
-}
-
-void BankHandler::withdraw(const int money A_UNUSED) const
-{
-}
-
-void BankHandler::check() const
-{
-}
-
-void BankHandler::open() const
-{
-}
-
-void BankHandler::close() const
-{
-}
-
-} // namespace TmwAthena
diff --git a/src/net/tmwa/bankhandler.h b/src/net/tmwa/bankhandler.h
deleted file mode 100644
index a99b7d50d..000000000
--- a/src/net/tmwa/bankhandler.h
+++ /dev/null
@@ -1,51 +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 NET_TMWA_BANKHANDLER_H
-#define NET_TMWA_BANKHANDLER_H
-
-#include "net/bankhandler.h"
-
-namespace TmwAthena
-{
-
-class BankHandler final : public Net::BankHandler
-{
- public:
- BankHandler();
-
- A_DELETE_COPY(BankHandler)
-
- ~BankHandler();
-
- void deposit(const int money) const override final A_CONST;
-
- void withdraw(const int money) const override final A_CONST;
-
- void check() const override final A_CONST;
-
- void open() const override final A_CONST;
-
- void close() const override final A_CONST;
-};
-
-} // namespace TmwAthena
-
-#endif // NET_TMWA_BANKHANDLER_H
diff --git a/src/net/tmwa/battlegroundhandler.cpp b/src/net/tmwa/battlegroundhandler.cpp
deleted file mode 100644
index b8631da1b..000000000
--- a/src/net/tmwa/battlegroundhandler.cpp
+++ /dev/null
@@ -1,58 +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 "net/tmwa/battlegroundhandler.h"
-
-#include "debug.h"
-
-namespace TmwAthena
-{
-
-BattleGroundHandler::BattleGroundHandler()
-{
- battleGroundHandler = this;
-}
-
-BattleGroundHandler::~BattleGroundHandler()
-{
- battleGroundHandler = nullptr;
-}
-
-void BattleGroundHandler::registerBg(const BattleGroundTypeT &type
- A_UNUSED,
- const std::string &name A_UNUSED) const
-{
-}
-
-void BattleGroundHandler::rekoveRequest(const std::string &name A_UNUSED) const
-{
-}
-
-void BattleGroundHandler::beginAck(const bool result A_UNUSED,
- const std::string &bgName A_UNUSED,
- const std::string &gameName A_UNUSED) const
-{
-}
-
-void BattleGroundHandler::checkState(const std::string &name A_UNUSED) const
-{
-}
-
-} // namespace TmwAthena
diff --git a/src/net/tmwa/battlegroundhandler.h b/src/net/tmwa/battlegroundhandler.h
deleted file mode 100644
index 2a1126589..000000000
--- a/src/net/tmwa/battlegroundhandler.h
+++ /dev/null
@@ -1,54 +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 NET_TMWA_BATTLEGROUNDHANDLER_H
-#define NET_TMWA_BATTLEGROUNDHANDLER_H
-
-#include "net/battlegroundhandler.h"
-
-namespace TmwAthena
-{
-
-class BattleGroundHandler final : public Net::BattleGroundHandler
-{
- public:
- BattleGroundHandler();
-
- A_DELETE_COPY(BattleGroundHandler)
-
- ~BattleGroundHandler();
-
- void registerBg(const BattleGroundTypeT &type,
- const std::string &name) const override final A_CONST;
-
- void rekoveRequest(const std::string &name) const override final
- A_CONST;
-
- void beginAck(const bool result,
- const std::string &bgName,
- const std::string &gameName) const override final
- A_CONST;
-
- void checkState(const std::string &name) const override final A_CONST;
-};
-
-} // namespace TmwAthena
-
-#endif // NET_TMWA_BATTLEGROUNDHANDLER_H
diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp
deleted file mode 100644
index c4e57627e..000000000
--- a/src/net/tmwa/beinghandler.cpp
+++ /dev/null
@@ -1,74 +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 "net/tmwa/beinghandler.h"
-
-#include "net/tmwa/messageout.h"
-#include "net/tmwa/protocolout.h"
-#include "net/tmwa/sprite.h"
-
-#include "debug.h"
-
-namespace TmwAthena
-{
-
-BeingHandler::BeingHandler(const bool enableSync) :
- Ea::BeingHandler(enableSync)
-{
- beingHandler = this;
-}
-
-BeingHandler::~BeingHandler()
-{
- beingHandler = nullptr;
-}
-
-void BeingHandler::requestNameById(const BeingId id) const
-{
- createOutPacket(CMSG_NAME_REQUEST);
- outMsg.writeBeingId(id, "being id");
-}
-
-void BeingHandler::undress(Being *const being) const
-{
- if (being == nullptr)
- return;
- being->unSetSprite(SPRITE_WEAPON);
- being->unSetSprite(SPRITE_HEAD_BOTTOM);
- being->unSetSprite(SPRITE_CLOTHES_COLOR);
- being->unSetSprite(SPRITE_HAIR);
- being->unSetSprite(SPRITE_SHOES);
-}
-
-void BeingHandler::requestRanks(const RankT rank A_UNUSED) const
-{
-}
-
-void BeingHandler::viewPlayerEquipment(const Being *const being A_UNUSED) const
-{
-}
-
-void BeingHandler::requestNameByCharId(const int id A_UNUSED) const
-{
-}
-
-} // namespace TmwAthena
diff --git a/src/net/tmwa/beinghandler.h b/src/net/tmwa/beinghandler.h
deleted file mode 100644
index 04cced3ed..000000000
--- a/src/net/tmwa/beinghandler.h
+++ /dev/null
@@ -1,55 +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 NET_TMWA_BEINGHANDLER_H
-#define NET_TMWA_BEINGHANDLER_H
-
-#include "net/ea/beinghandler.h"
-
-namespace TmwAthena
-{
-
-class BeingHandler final : public Ea::BeingHandler
-{
- public:
- explicit BeingHandler(const bool enableSync);
-
- A_DELETE_COPY(BeingHandler)
-
- ~BeingHandler();
-
- void requestNameById(const BeingId id) const override final;
-
- void undress(Being *const being) const override final;
-
- void requestRanks(const RankT rank A_UNUSED) const override final
- A_CONST;
-
- void viewPlayerEquipment(const Being *const being) const override final
- A_CONST;
-
- void requestNameByCharId(const int id) const override final A_CONST;
-};
-
-} // namespace TmwAthena
-
-#endif // NET_TMWA_BEINGHANDLER_H
diff --git a/src/net/tmwa/beingrecv.cpp b/src/net/tmwa/beingrecv.cpp
deleted file mode 100644
index bb165789d..000000000
--- a/src/net/tmwa/beingrecv.cpp
+++ /dev/null
@@ -1,1517 +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 "net/tmwa/beingrecv.h"
-
-#include "actormanager.h"
-#include "configuration.h"
-#include "effectmanager.h"
-#include "guild.h"
-#include "party.h"
-
-#include "being/localplayer.h"
-
-#include "particle/particleengine.h"
-
-#include "input/keyboardconfig.h"
-
-#include "gui/windows/okdialog.h"
-#include "gui/windows/outfitwindow.h"
-#include "gui/windows/socialwindow.h"
-
-#include "net/beinghandler.h"
-#include "net/serverfeatures.h"
-
-#include "net/messagein.h"
-
-#include "net/ea/beingrecv.h"
-
-#include "net/tmwa/guildmanager.h"
-#include "net/tmwa/sprite.h"
-
-#include "resources/iteminfo.h"
-
-#include "resources/db/itemdb.h"
-
-#include "utils/timer.h"
-
-#include "debug.h"
-
-extern OkDialog *deathNotice;
-
-namespace TmwAthena
-{
-
-static void setGm(Being *const dstBeing,
- const uint16_t gmstatus)
-{
- if (dstBeing != localPlayer)
- {
- if ((gmstatus & 0x80) != 0)
- {
- dstBeing->setGroupId(paths.getIntValue("gmDefaultLevel"));
- dstBeing->setGM(true);
- }
- else
- {
- dstBeing->setGroupId(0);
- dstBeing->setGM(false);
- }
- }
- else
- {
- if ((gmstatus & 0x80) != 0)
- dstBeing->setGM(true);
- else
- dstBeing->setGM(false);
- }
-}
-
-void BeingRecv::processBeingChangeLook(Net::MessageIn &msg)
-{
- BLOCK_START("BeingRecv::processBeingChangeLook")
- if (actorManager == nullptr)
- {
- BLOCK_END("BeingRecv::processBeingChangeLook")
- return;
- }
-
- Being *const dstBeing = actorManager->findBeing(
- msg.readBeingId("being id"));
-
- const uint8_t type = msg.readUInt8("type");
- const int16_t id = CAST_S16(msg.readUInt8("id"));
- const int id2 = 1;
-
- if ((localPlayer == nullptr) || (dstBeing == nullptr))
- {
- BLOCK_END("BeingRecv::processBeingChangeLook")
- return;
- }
- processBeingChangeLookContinue(msg, dstBeing, type, id, id2);
- BLOCK_END("BeingRecv::processBeingChangeLook")
-}
-
-void BeingRecv::processBeingChangeLook2(Net::MessageIn &msg)
-{
- BLOCK_START("BeingRecv::processBeingChangeLook")
- if (actorManager == nullptr)
- {
- BLOCK_END("BeingRecv::processBeingChangeLook")
- return;
- }
-
- Being *const dstBeing = actorManager->findBeing(
- msg.readBeingId("being id"));
-
- const uint8_t type = msg.readUInt8("type");
- int id2 = 0;
-
- const int16_t id = msg.readInt16("id1");
- if (type == 2)
- {
- id2 = msg.readInt16("id2");
- }
- else
- {
- msg.readInt16("id2");
- id2 = 1;
- }
-
- if ((localPlayer == nullptr) || (dstBeing == nullptr))
- {
- BLOCK_END("BeingRecv::processBeingChangeLook")
- return;
- }
- processBeingChangeLookContinue(msg, dstBeing, type, id, id2);
- BLOCK_END("BeingRecv::processBeingChangeLook")
-}
-
-void BeingRecv::processBeingChangeLookContinue(const Net::MessageIn &msg,
- Being *const dstBeing,
- const uint8_t type,
- const int id,
- const int id2)
-{
- if (dstBeing->getType() == ActorType::Player)
- dstBeing->setOtherTime();
-
- switch (type)
- {
- case 0: // change race
- dstBeing->setSubtype(fromInt(id, BeingTypeId),
- dstBeing->getLook());
- break;
- case 1: // eAthena LOOK_HAIR
- {
- const uint16_t look = CAST_U16(id / 256);
- const int hair = id % 256;
- dstBeing->setHairStyle(SPRITE_HAIR_COLOR, hair * -1);
- dstBeing->setLook(look);
- break;
- }
- case 2: // Weapon ID in id, Shield ID in id2
- dstBeing->setSpriteId(SPRITE_BODY,
- id);
- dstBeing->setWeaponId(id);
- dstBeing->setSpriteId(SPRITE_FLOOR,
- id2);
- localPlayer->imitateOutfit(dstBeing, SPRITE_FLOOR);
- break;
- case 3: // Change lower headgear for eAthena, pants for us
- dstBeing->setSpriteId(SPRITE_WEAPON,
- id);
- localPlayer->imitateOutfit(dstBeing, SPRITE_WEAPON);
- break;
- case 4: // Change upper headgear for eAthena, hat for us
- dstBeing->setSpriteId(SPRITE_CLOTHES_COLOR,
- id);
- localPlayer->imitateOutfit(dstBeing, SPRITE_CLOTHES_COLOR);
- break;
- case 5: // Change middle headgear for eathena, armor for us
- dstBeing->setSpriteId(SPRITE_HEAD_BOTTOM,
- id);
- localPlayer->imitateOutfit(dstBeing, SPRITE_HEAD_BOTTOM);
- break;
- case 6: // eAthena LOOK_HAIR_COLOR
- dstBeing->setHairColor(SPRITE_HAIR_COLOR,
- fromInt(id, ItemColor));
- break;
- case 7: // Clothes color
- // ignoring it
- break;
- case 8: // eAthena LOOK_SHIELD
- dstBeing->setSpriteId(SPRITE_FLOOR,
- id);
- localPlayer->imitateOutfit(dstBeing, SPRITE_FLOOR);
- break;
- case 9: // eAthena LOOK_SHOES
- dstBeing->setSpriteId(SPRITE_HAIR,
- id);
- localPlayer->imitateOutfit(dstBeing, SPRITE_HAIR);
- break;
- case 10: // LOOK_GLOVES
- dstBeing->setSpriteId(SPRITE_SHOES,
- id);
- localPlayer->imitateOutfit(dstBeing, SPRITE_SHOES);
- break;
- case 11: // LOOK_CAPE
- dstBeing->setSpriteId(SPRITE_SHIELD,
- id);
- localPlayer->imitateOutfit(dstBeing, SPRITE_SHIELD);
- break;
- case 12:
- dstBeing->setSpriteId(SPRITE_HEAD_TOP,
- id);
- localPlayer->imitateOutfit(dstBeing, SPRITE_HEAD_TOP);
- break;
- case 13:
- dstBeing->setSpriteId(SPRITE_HEAD_MID,
- id);
- localPlayer->imitateOutfit(dstBeing, SPRITE_HEAD_MID);
- break;
- case 14:
- dstBeing->setSpriteId(SPRITE_ROBE,
- id);
- localPlayer->imitateOutfit(dstBeing, SPRITE_ROBE);
- break;
- case 15:
- dstBeing->setSpriteId(SPRITE_EVOL2,
- id);
- localPlayer->imitateOutfit(dstBeing, SPRITE_EVOL2);
- break;
- case 16:
- dstBeing->setLook(CAST_U16(id));
- break;
- default:
- UNIMPLEMENTEDPACKETFIELD(type);
- break;
- }
-}
-
-void BeingRecv::processPlayerUpdate1(Net::MessageIn &msg)
-{
- BLOCK_START("BeingRecv::processPlayerMoveUpdate")
- if ((actorManager == nullptr) || (localPlayer == nullptr))
- {
- BLOCK_END("BeingRecv::processPlayerMoveUpdate")
- return;
- }
-
- // An update about a player, potentially including movement.
- const BeingId id = msg.readBeingId("account id");
- const int16_t speed = msg.readInt16("speed");
- const uint32_t opt1 = msg.readInt16("opt1");
- const uint32_t opt2 = msg.readInt16("opt2");
- const uint32_t option = msg.readInt16("option");
- const int16_t job = msg.readInt16("job");
- int disguiseId = 0;
- if (toInt(id, int) < 110000000 && job >= 1000)
- disguiseId = job;
-
- Being *dstBeing = actorManager->findBeing(id);
- if (dstBeing == nullptr)
- {
- if (actorManager->isBlocked(id) == true)
- {
- BLOCK_END("BeingRecv::processPlayerMoveUpdate")
- return;
- }
-
- dstBeing = Ea::BeingRecv::createBeing(id, job);
-
- if (dstBeing == nullptr)
- {
- BLOCK_END("BeingRecv::processPlayerMoveUpdate")
- return;
- }
- }
- else if (disguiseId != 0)
- {
- actorManager->undelete(dstBeing);
- beingHandler->requestNameById(id);
- }
-
- uint8_t dir = dstBeing->getDirectionDelayed();
- if (dir != 0u)
- {
- if (dir != dstBeing->getDirection())
- dstBeing->setDirection(dir);
- }
-
- if (Party *const party = localPlayer->getParty())
- {
- if (party->isMember(id))
- dstBeing->setParty(party);
- }
-
- dstBeing->setWalkSpeed(speed);
-
- const uint8_t hairStyle = msg.readUInt8("hair style");
- const uint16_t look = msg.readUInt8("look");
- dstBeing->setSubtype(fromInt(job, BeingTypeId), look);
- const uint16_t weapon = msg.readInt16("weapon");
- const uint16_t shield = msg.readInt16("shield");
- const uint16_t headBottom = msg.readInt16("head bottom");
-
- const uint16_t headTop = msg.readInt16("head top");
- const uint16_t headMid = msg.readInt16("head mid");
- const ItemColor hairColor = fromInt(
- msg.readUInt8("hair color"), ItemColor);
- msg.readUInt8("unused");
- msg.readInt32("unused");
-
- const int guild = msg.readInt32("guild");
-
- if ((guildManager == nullptr) || !GuildManager::getEnableGuildBot())
- {
- if (guild == 0)
- dstBeing->clearGuilds();
- else
- dstBeing->setGuild(Guild::getGuild(CAST_S16(guild)));
- }
-
- msg.readInt16("emblem");
- dstBeing->setManner(msg.readInt16("manner"));
- const uint32_t opt3 = msg.readInt16("opt3");
- dstBeing->setKarma(msg.readUInt8("karma"));
- // reserving bit for future usage
- dstBeing->setGender(Being::intToGender(
- CAST_U8(msg.readUInt8("gender") & 3)));
-
- if (disguiseId == 0)
- {
- // Set these after the gender, as the sprites may be gender-specific
- dstBeing->updateSprite(SPRITE_BODY,
- weapon,
- "");
- dstBeing->setWeaponId(weapon);
- dstBeing->updateSprite(SPRITE_FLOOR, shield);
- dstBeing->updateSprite(SPRITE_WEAPON, headBottom);
- dstBeing->updateSprite(SPRITE_HEAD_BOTTOM, headMid);
- dstBeing->updateSprite(SPRITE_CLOTHES_COLOR, headTop);
- if (hairStyle == 0)
- {
- dstBeing->updateSprite(SPRITE_HAIR_COLOR,
- 0,
- std::string());
- }
- else
- {
- dstBeing->updateSprite(SPRITE_HAIR_COLOR,
- hairStyle * -1,
- ItemDB::get(-hairStyle).getDyeColorsString(hairColor));
- }
- dstBeing->setHairColor(hairColor);
- }
- localPlayer->imitateOutfit(dstBeing);
-
- uint16_t x, y;
- msg.readCoordinates(x, y, dir, "position");
- dstBeing->setTileCoords(x, y);
- dstBeing->setDirection(dir);
-
- localPlayer->imitateDirection(dstBeing, dir);
-
- const uint16_t gmstatus = msg.readInt16("gm status");
-
- setGm(dstBeing, gmstatus);
-
- applyPlayerAction(msg, dstBeing, msg.readUInt8("action type"));
- const int level = CAST_S32(msg.readUInt8("level"));
- if (level != 0)
- dstBeing->setLevel(level);
-
- msg.readUInt8("unused");
-
- dstBeing->setActionTime(tick_time);
-
- dstBeing->setStatusEffectOpitons(option,
- opt1,
- opt2,
- opt3);
-
- BLOCK_END("BeingRecv::processPlayerMoveUpdate")
-}
-
-void BeingRecv::processPlayerUpdate2(Net::MessageIn &msg)
-{
- BLOCK_START("BeingRecv::processPlayerMoveUpdate")
- if ((actorManager == nullptr) || (localPlayer == nullptr))
- {
- BLOCK_END("BeingRecv::processPlayerMoveUpdate")
- return;
- }
-
- // An update about a player, potentially including movement.
- const BeingId id = msg.readBeingId("account id");
- const int16_t speed = msg.readInt16("speed");
- const uint32_t opt1 = msg.readInt16("opt1");
- const uint32_t opt2 = msg.readInt16("opt2");
- const uint32_t option = msg.readInt16("option");
- const int16_t job = msg.readInt16("job");
- int disguiseId = 0;
- if (toInt(id, int) < 110000000 && job >= 1000)
- disguiseId = job;
-
- Being *dstBeing = actorManager->findBeing(id);
- if (dstBeing == nullptr)
- {
- if (actorManager->isBlocked(id) == true)
- {
- BLOCK_END("BeingRecv::processPlayerMoveUpdate")
- return;
- }
-
- dstBeing = Ea::BeingRecv::createBeing(id, job);
-
- if (dstBeing == nullptr)
- {
- BLOCK_END("BeingRecv::processPlayerMoveUpdate")
- return;
- }
- }
- else if (disguiseId != 0)
- {
- actorManager->undelete(dstBeing);
- beingHandler->requestNameById(id);
- }
-
- uint8_t dir = dstBeing->getDirectionDelayed();
- if (dir != 0u)
- {
- if (dir != dstBeing->getDirection())
- dstBeing->setDirection(dir);
- }
-
- if (Party *const party = localPlayer->getParty())
- {
- if (party->isMember(id))
- dstBeing->setParty(party);
- }
-
- dstBeing->setWalkSpeed(speed);
-
- const uint8_t hairStyle = msg.readUInt8("hair style");
- const uint16_t look = msg.readUInt8("look");
- dstBeing->setSubtype(fromInt(job, BeingTypeId), look);
- const uint16_t weapon = msg.readInt16("weapon");
- const uint16_t shield = msg.readInt16("shield");
- const uint16_t headBottom = msg.readInt16("head bottom");
- const uint16_t headTop = msg.readInt16("head top");
- const uint16_t headMid = msg.readInt16("head mid");
- const ItemColor hairColor = fromInt(
- msg.readUInt8("hair color"), ItemColor);
- msg.readUInt8("unused");
- msg.readInt32("unused");
-
- const int guild = msg.readInt32("guild");
-
- if ((guildManager == nullptr) || !GuildManager::getEnableGuildBot())
- {
- if (guild == 0)
- dstBeing->clearGuilds();
- else
- dstBeing->setGuild(Guild::getGuild(CAST_S16(guild)));
- }
-
- msg.readInt16("emblem");
- dstBeing->setManner(msg.readInt16("manner"));
- const uint32_t opt3 = msg.readInt16("opt3");
- dstBeing->setKarma(msg.readUInt8("karma"));
- // reserving bit for future usage
- dstBeing->setGender(Being::intToGender(
- CAST_U8(msg.readUInt8("gender") & 3)));
-
- if (disguiseId == 0)
- {
- // Set these after the gender, as the sprites may be gender-specific
- dstBeing->updateSprite(SPRITE_BODY,
- weapon,
- "");
- dstBeing->setWeaponId(weapon);
- dstBeing->updateSprite(SPRITE_FLOOR, shield);
- dstBeing->updateSprite(SPRITE_WEAPON, headBottom);
- dstBeing->updateSprite(SPRITE_HEAD_BOTTOM, headMid);
- dstBeing->updateSprite(SPRITE_CLOTHES_COLOR, headTop);
- if (hairStyle == 0)
- {
- dstBeing->updateSprite(SPRITE_HAIR_COLOR,
- 0,
- std::string());
- }
- else
- {
- dstBeing->updateSprite(SPRITE_HAIR_COLOR,
- hairStyle * -1,
- ItemDB::get(-hairStyle).getDyeColorsString(hairColor));
- }
- dstBeing->setHairColor(hairColor);
- }
- localPlayer->imitateOutfit(dstBeing);
-
- uint16_t x, y;
- msg.readCoordinates(x, y, dir, "position");
- dstBeing->setTileCoords(x, y);
- dstBeing->setDirection(dir);
-
- localPlayer->imitateDirection(dstBeing, dir);
-
- const uint16_t gmstatus = msg.readInt16("gm status");
-
- setGm(dstBeing, gmstatus);
-
- applyPlayerAction(msg, dstBeing, msg.readUInt8("action type"));
- const int level = CAST_S32(msg.readUInt8("level"));
- if (level != 0)
- dstBeing->setLevel(level);
-
- dstBeing->setActionTime(tick_time);
- dstBeing->setStatusEffectOpitons(option,
- opt1,
- opt2,
- opt3);
-
- BLOCK_END("BeingRecv::processPlayerMoveUpdate")
-}
-
-void BeingRecv::processPlayerMove(Net::MessageIn &msg)
-{
- BLOCK_START("BeingRecv::processPlayerMoveUpdate")
- if ((actorManager == nullptr) || (localPlayer == nullptr))
- {
- BLOCK_END("BeingRecv::processPlayerMoveUpdate")
- return;
- }
-
- // An update about a player, potentially including movement.
- const BeingId id = msg.readBeingId("account id");
- const int16_t speed = msg.readInt16("speed");
- const uint32_t opt1 = msg.readInt16("opt1");
- const uint32_t opt2 = msg.readInt16("opt2");
- const uint32_t option = msg.readInt16("option");
- const int16_t job = msg.readInt16("job");
- int disguiseId = 0;
- if (toInt(id, int) < 110000000 && job >= 1000)
- disguiseId = job;
-
- Being *dstBeing = actorManager->findBeing(id);
- if (dstBeing == nullptr)
- {
- if (actorManager->isBlocked(id) == true)
- {
- BLOCK_END("BeingRecv::processPlayerMoveUpdate")
- return;
- }
-
- dstBeing = Ea::BeingRecv::createBeing(id, job);
-
- if (dstBeing == nullptr)
- {
- BLOCK_END("BeingRecv::processPlayerMoveUpdate")
- return;
- }
- }
- else if (disguiseId != 0)
- {
- actorManager->undelete(dstBeing);
- beingHandler->requestNameById(id);
- }
-
- const uint8_t dir = dstBeing->getDirectionDelayed();
- if (dir != 0u)
- {
- if (dir != dstBeing->getDirection())
- dstBeing->setDirection(dir);
- }
-
- if (Party *const party = localPlayer->getParty())
- {
- if (party->isMember(id))
- dstBeing->setParty(party);
- }
-
- dstBeing->setWalkSpeed(speed);
-
- const uint8_t hairStyle = msg.readUInt8("hair style");
- const uint16_t look = msg.readUInt8("look");
- dstBeing->setSubtype(fromInt(job, BeingTypeId), look);
- const uint16_t weapon = msg.readInt16("weapon");
- const uint16_t shield = msg.readInt16("shield");
- const uint16_t headBottom = msg.readInt16("head bottom");
-
- msg.readInt32("tick");
-
- const uint16_t headTop = msg.readInt16("head top");
- const uint16_t headMid = msg.readInt16("head mid");
- const ItemColor hairColor = fromInt(
- msg.readUInt8("hair color"), ItemColor);
- msg.readUInt8("unused");
- msg.readInt32("unused");
-
- const int guild = msg.readInt32("guild");
-
- if ((guildManager == nullptr) || !GuildManager::getEnableGuildBot())
- {
- if (guild == 0)
- dstBeing->clearGuilds();
- else
- dstBeing->setGuild(Guild::getGuild(CAST_S16(guild)));
- }
-
- msg.readInt16("emblem");
- dstBeing->setManner(msg.readInt16("manner"));
- const uint32_t opt3 = msg.readInt16("opt3");
- dstBeing->setKarma(msg.readUInt8("karma"));
- // reserving bit for future usage
- dstBeing->setGender(Being::intToGender(
- CAST_U8(msg.readUInt8("gender") & 3)));
-
- if (disguiseId == 0)
- {
- // Set these after the gender, as the sprites may be gender-specific
- dstBeing->updateSprite(SPRITE_BODY,
- weapon,
- "");
- dstBeing->setWeaponId(weapon);
- dstBeing->updateSprite(SPRITE_FLOOR, shield);
- dstBeing->updateSprite(SPRITE_WEAPON, headBottom);
- dstBeing->updateSprite(SPRITE_HEAD_BOTTOM, headMid);
- dstBeing->updateSprite(SPRITE_CLOTHES_COLOR, headTop);
- if (hairStyle == 0)
- {
- dstBeing->updateSprite(SPRITE_HAIR_COLOR,
- 0,
- std::string());
- }
- else
- {
- dstBeing->updateSprite(SPRITE_HAIR_COLOR,
- hairStyle * -1,
- ItemDB::get(-hairStyle).getDyeColorsString(hairColor));
- }
- dstBeing->setHairColor(hairColor);
- }
- localPlayer->imitateOutfit(dstBeing);
-
- uint16_t srcX, srcY, dstX, dstY;
- msg.readCoordinatePair(srcX, srcY, dstX, dstY, "moving path");
-
- localPlayer->followMoveTo(dstBeing, srcX, srcY, dstX, dstY);
-
- dstBeing->setTileCoords(srcX, srcY);
- dstBeing->setDestination(dstX, dstY);
-
- // because server don't send direction in move packet,
- // we fixing it
-
- if (srcX != dstX || srcY != dstY)
- {
- const int d = dstBeing->calcDirection(dstX, dstY);
-
- if ((d != 0) && dstBeing->getDirection() != d)
- dstBeing->setDirectionDelayed(CAST_U8(d));
- }
-
- if (localPlayer->getCurrentAction() != BeingAction::STAND)
- localPlayer->imitateAction(dstBeing, BeingAction::STAND);
- if (localPlayer->getDirection() != dstBeing->getDirection())
- {
- localPlayer->imitateDirection(dstBeing,
- dstBeing->getDirection());
- }
-
- const uint16_t gmstatus = msg.readInt16("gm status");
-
- setGm(dstBeing, gmstatus);
-
- msg.readUInt8("unused");
-
- const int level = CAST_S32(msg.readUInt8("level"));
- if (level != 0)
- dstBeing->setLevel(level);
-
- msg.readUInt8("unused");
-
- if (dstBeing->getType() != ActorType::Player)
- dstBeing->setActionTime(tick_time);
-
- dstBeing->setStatusEffectOpitons(option,
- opt1,
- opt2,
- opt3);
-
- if (dstBeing->getType() == ActorType::Player)
- dstBeing->setMoveTime();
- BLOCK_END("BeingRecv::processPlayerMoveUpdate")
-}
-
-void BeingRecv::processBeingVisible(Net::MessageIn &msg)
-{
- BLOCK_START("BeingRecv::processBeingVisibleOrMove")
- if (actorManager == nullptr)
- {
- BLOCK_END("BeingRecv::processBeingVisibleOrMove")
- return;
- }
-
- BeingId spawnId;
-
- // Information about a being in range
- const BeingId id = msg.readBeingId("being id");
- if (id == Ea::BeingRecv::mSpawnId)
- spawnId = Ea::BeingRecv::mSpawnId;
- else
- spawnId = BeingId_zero;
- Ea::BeingRecv::mSpawnId = BeingId_zero;
- int16_t speed = msg.readInt16("speed");
- const uint32_t opt1 = msg.readInt16("opt1");
- const uint32_t opt2 = msg.readInt16("opt2");
- const uint32_t option = msg.readInt16("option");
- const int16_t job = msg.readInt16("class");
- int disguiseId = 0;
- if (id == localPlayer->getId() && job >= 1000)
- disguiseId = job;
-
- Being *dstBeing = actorManager->findBeing(id);
-
- if ((dstBeing != nullptr) && dstBeing->getType() == ActorType::Monster
- && !dstBeing->isAlive())
- {
- actorManager->destroy(dstBeing);
- actorManager->erase(dstBeing);
- dstBeing = nullptr;
- }
-
- if (dstBeing == nullptr)
- {
- // Being with id >= 110000000 and job 0 are better
- // known as ghosts, so don't create those.
- if (job == 0 && toInt(id, int) >= 110000000)
- {
- BLOCK_END("BeingRecv::processBeingVisibleOrMove")
- return;
- }
-
- if (actorManager->isBlocked(id) == true)
- {
- BLOCK_END("BeingRecv::processBeingVisibleOrMove")
- return;
- }
-
- dstBeing = Ea::BeingRecv::createBeing(id, job);
-
- if (dstBeing == nullptr)
- {
- BLOCK_END("BeingRecv::processBeingVisibleOrMove")
- return;
- }
- }
- else
- {
- if (dstBeing->getType() == ActorType::Npc)
- {
- actorManager->undelete(dstBeing);
- beingHandler->requestNameById(id);
- }
- }
-
- if (dstBeing->getType() == ActorType::Player)
- dstBeing->setMoveTime();
-
- if (spawnId != BeingId_zero)
- {
- dstBeing->setAction(BeingAction::SPAWN, 0);
- }
- else
- {
- dstBeing->clearPath();
- dstBeing->setActionTime(tick_time);
- dstBeing->setAction(BeingAction::STAND, 0);
- }
-
- // Prevent division by 0 when calculating frame
- if (speed == 0)
- speed = 150;
-
- const uint8_t hairStyle = msg.readUInt8("hair style");
- const uint16_t look = msg.readUInt8("look");
- dstBeing->setSubtype(fromInt(job, BeingTypeId), look);
- if (dstBeing->getType() == ActorType::Monster && (localPlayer != nullptr))
- localPlayer->checkNewName(dstBeing);
- dstBeing->setWalkSpeed(speed);
- const uint16_t weapon = msg.readInt16("weapon");
- const uint16_t headBottom = msg.readInt16("head bottom");
-
- const uint16_t shield = msg.readInt16("shield");
- const uint16_t headTop = msg.readInt16("head top");
- const uint16_t headMid = msg.readInt16("head mid");
- const ItemColor hairColor = fromInt(msg.readUInt8("hair color"),
- ItemColor);
- msg.readUInt8("unused");
- const uint16_t shoes = msg.readInt16("shoes / clothes color");
-
- uint16_t gloves;
- if (dstBeing->getType() == ActorType::Monster)
- {
- if (serverFeatures->haveServerHp())
- {
- const int hp = msg.readInt32("hp");
- const int maxHP = msg.readInt32("max hp");
- if ((hp != 0) && (maxHP != 0))
- {
- dstBeing->setMaxHP(maxHP);
- const int oldHP = dstBeing->getHP();
- if ((oldHP == 0) || oldHP > hp)
- dstBeing->setHP(hp);
- }
- }
- else
- {
- msg.readInt32("unused");
- msg.readInt32("unused");
- }
- gloves = 0;
- }
- else
- {
- gloves = msg.readInt16("gloves / head dir");
- msg.readInt32("guild");
- msg.readInt16("guild emblem");
- }
-
- dstBeing->setManner(msg.readInt16("manner"));
- const uint32_t opt3 = msg.readInt16("opt3");
- if (serverFeatures->haveMonsterAttackRange()
- && dstBeing->getType() == ActorType::Monster)
- {
- const int attackRange = CAST_S32(
- msg.readUInt8("attack range (was karma)"));
- dstBeing->setAttackRange(attackRange);
- }
- else
- {
- dstBeing->setKarma(msg.readUInt8("karma"));
- }
- uint8_t gender = msg.readUInt8("gender");
-
- if ((disguiseId == 0) && dstBeing->getType() == ActorType::Player)
- {
- // reserving bits for future usage
- gender &= 3;
- dstBeing->setGender(Being::intToGender(gender));
- // Set these after the gender, as the sprites may be gender-specific
- if (hairStyle == 0)
- {
- dstBeing->updateSprite(SPRITE_HAIR_COLOR, 0);
- }
- else
- {
- dstBeing->updateSprite(SPRITE_HAIR_COLOR,
- hairStyle * -1,
- ItemDB::get(-hairStyle).getDyeColorsString(hairColor));
- }
- dstBeing->setHairColor(hairColor);
- dstBeing->updateSprite(SPRITE_WEAPON, headBottom);
- dstBeing->updateSprite(SPRITE_HEAD_BOTTOM, headMid);
- dstBeing->updateSprite(SPRITE_CLOTHES_COLOR, headTop);
- dstBeing->updateSprite(SPRITE_HAIR, shoes);
- dstBeing->updateSprite(SPRITE_SHOES, gloves);
- dstBeing->updateSprite(SPRITE_BODY, weapon);
- dstBeing->setWeaponId(weapon);
- dstBeing->updateSprite(SPRITE_FLOOR, shield);
- }
- else if (dstBeing->getType() == ActorType::Npc
- && serverFeatures->haveNpcGender())
- {
- setServerGender(dstBeing, gender);
- }
-
- uint8_t dir;
- uint16_t x, y;
- msg.readCoordinates(x, y, dir, "position");
- dstBeing->setTileCoords(x, y);
-
- if (job == 45 && (socialWindow != nullptr) && (outfitWindow != nullptr))
- {
- const int num = socialWindow->getPortalIndex(x, y);
- if (num >= 0)
- {
- dstBeing->setName(KeyboardConfig::getKeyShortString(
- OutfitWindow::keyName(num)));
- }
- else
- {
- dstBeing->setName("");
- }
- }
-
- dstBeing->setDirection(dir);
-
- msg.readUInt8("unknown");
- msg.readUInt8("unknown");
- msg.readUInt8("unknown");
- msg.readUInt8("unknown");
- msg.readUInt8("unknown");
-
- dstBeing->setStatusEffectOpitons(option,
- opt1,
- opt2,
- opt3);
- BLOCK_END("BeingRecv::processBeingVisibleOrMove")
-}
-
-void BeingRecv::processBeingMove(Net::MessageIn &msg)
-{
- BLOCK_START("BeingRecv::processBeingVisibleOrMove")
- if (actorManager == nullptr)
- {
- BLOCK_END("BeingRecv::processBeingVisibleOrMove")
- return;
- }
-
- BeingId spawnId;
-
- // Information about a being in range
- const BeingId id = msg.readBeingId("being id");
- if (id == Ea::BeingRecv::mSpawnId)
- spawnId = Ea::BeingRecv::mSpawnId;
- else
- spawnId = BeingId_zero;
- Ea::BeingRecv::mSpawnId = BeingId_zero;
- int16_t speed = msg.readInt16("speed");
- const uint32_t opt1 = msg.readInt16("opt1");
- const uint32_t opt2 = msg.readInt16("opt2");
- const uint32_t option = msg.readInt16("option");
- const int16_t job = msg.readInt16("class");
- int disguiseId = 0;
- if (id == localPlayer->getId() && job >= 1000)
- disguiseId = job;
-
- Being *dstBeing = actorManager->findBeing(id);
-
- if ((dstBeing != nullptr) && dstBeing->getType() == ActorType::Monster
- && !dstBeing->isAlive())
- {
- actorManager->destroy(dstBeing);
- actorManager->erase(dstBeing);
- dstBeing = nullptr;
- }
-
- if (dstBeing == nullptr)
- {
- // Being with id >= 110000000 and job 0 are better
- // known as ghosts, so don't create those.
- if (job == 0 && toInt(id, int) >= 110000000)
- {
- BLOCK_END("BeingRecv::processBeingVisibleOrMove")
- return;
- }
-
- if (actorManager->isBlocked(id) == true)
- {
- BLOCK_END("BeingRecv::processBeingVisibleOrMove")
- return;
- }
-
- dstBeing = Ea::BeingRecv::createBeing(id, job);
-
- if (dstBeing == nullptr)
- {
- BLOCK_END("BeingRecv::processBeingVisibleOrMove")
- return;
- }
- }
- else
- {
- if (dstBeing->getType() == ActorType::Npc)
- {
- actorManager->undelete(dstBeing);
- beingHandler->requestNameById(id);
- }
- }
-
- if (dstBeing->getType() == ActorType::Player)
- dstBeing->setMoveTime();
-
- if (spawnId != BeingId_zero)
- dstBeing->setAction(BeingAction::SPAWN, 0);
-
- // Prevent division by 0 when calculating frame
- if (speed == 0)
- speed = 150;
-
- const uint8_t hairStyle = msg.readUInt8("hair style");
- const uint16_t look = msg.readUInt8("look");
- dstBeing->setSubtype(fromInt(job, BeingTypeId), look);
- if (dstBeing->getType() == ActorType::Monster && (localPlayer != nullptr))
- localPlayer->checkNewName(dstBeing);
- dstBeing->setWalkSpeed(speed);
- const uint16_t weapon = msg.readInt16("weapon");
- const uint16_t headBottom = msg.readInt16("head bottom");
-
- msg.readInt32("tick");
-
- const uint16_t shield = msg.readInt16("shield");
- const uint16_t headTop = msg.readInt16("head top");
- const uint16_t headMid = msg.readInt16("head mid");
- const ItemColor hairColor = fromInt(
- msg.readUInt8("hair color"), ItemColor);
- msg.readUInt8("unused");
- const uint16_t shoes = msg.readInt16("shoes / clothes color");
-
- uint16_t gloves;
- if (dstBeing->getType() == ActorType::Monster)
- {
- if (serverFeatures->haveServerHp())
- {
- const int hp = msg.readInt32("hp");
- const int maxHP = msg.readInt32("max hp");
- if ((hp != 0) && (maxHP != 0))
- {
- dstBeing->setMaxHP(maxHP);
- const int oldHP = dstBeing->getHP();
- if ((oldHP == 0) || oldHP > hp)
- dstBeing->setHP(hp);
- }
- }
- else
- {
- msg.readInt32("unused");
- msg.readInt32("unused");
- }
- gloves = 0;
- }
- else
- {
- gloves = msg.readInt16("gloves / head dir");
- msg.readInt32("guild");
- msg.readInt16("guild emblem");
- }
-
- dstBeing->setManner(msg.readInt16("manner"));
- const uint32_t opt3 = msg.readInt16("opt3");
- if (serverFeatures->haveMonsterAttackRange()
- && dstBeing->getType() == ActorType::Monster)
- {
- const int attackRange = CAST_S32(
- msg.readUInt8("attack range (was karma)"));
- dstBeing->setAttackRange(attackRange);
- }
- else
- {
- dstBeing->setKarma(msg.readUInt8("karma"));
- }
- uint8_t gender = msg.readUInt8("gender");
-
- if ((disguiseId == 0) && dstBeing->getType() == ActorType::Player)
- {
- // reserving bits for future usage
- gender &= 3;
- dstBeing->setGender(Being::intToGender(gender));
- // Set these after the gender, as the sprites may be gender-specific
- if (hairStyle == 0)
- {
- dstBeing->updateSprite(SPRITE_HAIR_COLOR, 0);
- }
- else
- {
- dstBeing->updateSprite(SPRITE_HAIR_COLOR,
- hairStyle * -1,
- ItemDB::get(-hairStyle).getDyeColorsString(hairColor));
- }
- dstBeing->setHairColor(hairColor);
- dstBeing->updateSprite(SPRITE_WEAPON, headBottom);
- dstBeing->updateSprite(SPRITE_HEAD_BOTTOM, headMid);
- dstBeing->updateSprite(SPRITE_CLOTHES_COLOR, headTop);
- dstBeing->updateSprite(SPRITE_HAIR, shoes);
- dstBeing->updateSprite(SPRITE_SHOES, gloves);
- dstBeing->updateSprite(SPRITE_BODY, weapon);
- dstBeing->setWeaponId(weapon);
- dstBeing->updateSprite(SPRITE_FLOOR, shield);
- }
- else if (dstBeing->getType() == ActorType::Npc
- && serverFeatures->haveNpcGender())
- {
- setServerGender(dstBeing, gender);
- }
-
- uint16_t srcX, srcY, dstX, dstY;
- msg.readCoordinatePair(srcX, srcY, dstX, dstY, "move path");
- if (disguiseId == 0)
- {
- dstBeing->setAction(BeingAction::STAND, 0);
- dstBeing->setTileCoords(srcX, srcY);
- if (serverFeatures->haveMove3())
- dstBeing->setCachedDestination(dstX, dstY);
- else
- dstBeing->setDestination(dstX, dstY);
- }
-
- msg.readUInt8("unknown");
- msg.readUInt8("unknown");
- msg.readUInt8("unknown");
- msg.readUInt8("unknown");
- msg.readUInt8("unknown");
-
- dstBeing->setStatusEffectOpitons(option,
- opt1,
- opt2,
- opt3);
- BLOCK_END("BeingRecv::processBeingVisibleOrMove")
-}
-
-void BeingRecv::processBeingSpawn(Net::MessageIn &msg)
-{
- BLOCK_START("BeingRecv::processBeingSpawn")
- // skipping this packet
- Ea::BeingRecv::mSpawnId = msg.readBeingId("being id");
- msg.readInt16("speed");
- msg.readInt16("opt1");
- msg.readInt16("opt2");
- msg.readInt16("option");
- msg.readInt16("disguise");
- msg.skip(25, "unused");
- BLOCK_END("BeingRecv::processBeingSpawn")
-}
-
-void BeingRecv::processSkillCasting(Net::MessageIn &msg)
-{
- msg.readInt32("src id");
- msg.readInt32("dst id");
- msg.readInt16("dst x");
- msg.readInt16("dst y");
- msg.readInt16("skill num");
- msg.readInt32("skill get p1");
- msg.readInt32("cast time");
-}
-
-void BeingRecv::processBeingStatusChange(Net::MessageIn &msg)
-{
- BLOCK_START("BeingRecv::processBeingStatusChange")
- if (actorManager == nullptr)
- {
- BLOCK_END("BeingRecv::processBeingStatusChange")
- return;
- }
-
- // Status change
- const uint16_t status = msg.readInt16("status");
- const BeingId id = msg.readBeingId("being id");
- const Enable flag = fromBool(
- msg.readUInt8("flag: 0: stop, 1: start"), Enable);
-
- Being *const dstBeing = actorManager->findBeing(id);
- if (dstBeing != nullptr)
- {
- // dont know on legacy servers is effect really started
- // or not. Because this always sending IsStart_true
- dstBeing->setStatusEffect(status, flag, IsStart_true);
- }
- BLOCK_END("BeingRecv::processBeingStatusChange")
-}
-
-void BeingRecv::processBeingMove2(Net::MessageIn &msg)
-{
- BLOCK_START("BeingRecv::processBeingMove2")
- if (actorManager == nullptr)
- {
- BLOCK_END("BeingRecv::processBeingMove2")
- return;
- }
-
- /*
- * A simplified movement packet, used by the
- * later versions of eAthena for both mobs and
- * players
- */
- Being *const dstBeing = actorManager->findBeing(
- msg.readBeingId("being id"));
-
- /*
- * This packet doesn't have enough info to actually
- * create a new being, so if the being isn't found,
- * we'll just pretend the packet didn't happen
- */
-
- if (dstBeing == nullptr)
- {
- BLOCK_END("BeingRecv::processBeingMove2")
- return;
- }
-
- uint16_t srcX, srcY, dstX, dstY;
- msg.readCoordinatePair(srcX, srcY, dstX, dstY, "move path");
- msg.readInt32("tick");
-
- dstBeing->setAction(BeingAction::STAND, 0);
- dstBeing->setTileCoords(srcX, srcY);
- dstBeing->setDestination(dstX, dstY);
- if (dstBeing->getType() == ActorType::Player)
- dstBeing->setMoveTime();
- BLOCK_END("BeingRecv::processBeingMove2")
-}
-
-void BeingRecv::processBeingChangeDirection(Net::MessageIn &msg)
-{
- BLOCK_START("BeingRecv::processBeingChangeDirection")
- if (actorManager == nullptr)
- {
- BLOCK_END("BeingRecv::processBeingChangeDirection")
- return;
- }
-
- Being *const dstBeing = actorManager->findBeing(
- msg.readBeingId("being id"));
-
- if (dstBeing == nullptr)
- {
- DEBUGLOGSTR("invisible player?");
- msg.readInt16("unused");
- msg.readUInt8("direction");
- BLOCK_END("BeingRecv::processBeingChangeDirection");
- return;
- }
-
- msg.readInt16("unused");
-
- const uint8_t dir = Net::MessageIn::fromServerDirection(
- CAST_U8(msg.readUInt8("direction") & 0x0FU));
- dstBeing->setDirection(dir);
- if (localPlayer != nullptr)
- localPlayer->imitateDirection(dstBeing, dir);
- BLOCK_END("BeingRecv::processBeingChangeDirection")
-}
-
-void BeingRecv::processPlayerStatusChange(Net::MessageIn &msg)
-{
- BLOCK_START("BeingRecv::processPlayerStop")
- if (actorManager == nullptr)
- {
- BLOCK_END("BeingRecv::processPlayerStop")
- return;
- }
-
- // Change in players' flags
- const BeingId id = msg.readBeingId("account id");
- Being *const dstBeing = actorManager->findBeing(id);
- if (dstBeing == nullptr)
- {
- DEBUGLOGSTR("invisible player?");
- msg.readInt16("stun mode");
- msg.readInt16("status effect");
- msg.readInt16("opt?");
- msg.readUInt8("Unused?");
- return;
- }
-
- const uint32_t opt1 = msg.readInt16("opt1");
- const uint32_t opt2 = msg.readInt16("opt2");
- const uint32_t option = msg.readInt16("option");
- msg.readUInt8("Unused?");
-
- dstBeing->setStatusEffectOpitons(option,
- opt1,
- opt2);
- BLOCK_END("BeingRecv::processPlayerStop")
-}
-
-void BeingRecv::processBeingResurrect(Net::MessageIn &msg)
-{
- BLOCK_START("BeingRecv::processBeingResurrect")
- if (actorManager == nullptr || localPlayer == nullptr)
- {
- BLOCK_END("BeingRecv::processBeingResurrect")
- return;
- }
-
- // A being changed mortality status
-
- const BeingId id = msg.readBeingId("being id");
- Being *const dstBeing = actorManager->findBeing(id);
- if (dstBeing == nullptr)
- {
- DEBUGLOGSTR("insible player?");
- msg.readInt16("flag?");
- BLOCK_END("BeingRecv::processBeingResurrect")
- return;
- }
-
- // If this is player's current target, clear it.
- if (dstBeing == localPlayer->getTarget())
- localPlayer->stopAttack();
- if (dstBeing == localPlayer &&
- deathNotice != nullptr)
- {
- deathNotice->scheduleDelete();
- deathNotice = nullptr;
- }
-
- if (msg.readInt16("flag?") == 1)
- dstBeing->setAction(BeingAction::STAND, 0);
- BLOCK_END("BeingRecv::processBeingResurrect")
-}
-
-void BeingRecv::processPlayerGuilPartyInfo(Net::MessageIn &msg)
-{
- BLOCK_START("BeingRecv::processPlayerGuilPartyInfo")
- if (actorManager == nullptr)
- {
- BLOCK_END("BeingRecv::processPlayerGuilPartyInfo")
- return;
- }
-
- Being *const dstBeing = actorManager->findBeing(
- msg.readBeingId("being id"));
-
- if (dstBeing != nullptr)
- {
- dstBeing->setPartyName(msg.readString(24, "party name"));
- if ((guildManager == nullptr) || !GuildManager::getEnableGuildBot())
- {
- dstBeing->setGuildName(msg.readString(24, "guild name"));
- dstBeing->setGuildPos(msg.readString(24, "guild pos"));
- }
- else
- {
- msg.readString(24, "guild name");
- msg.readString(24, "guild pos");
- }
- dstBeing->addToCache();
- msg.readString(24, "?");
- }
- else
- {
- msg.readString(24, "party name");
- msg.readString(24, "guild name");
- msg.readString(24, "guild pos");
- msg.readString(24, "?");
- }
- BLOCK_END("BeingRecv::processPlayerGuilPartyInfo")
-}
-
-void BeingRecv::processBeingSelfEffect(Net::MessageIn &msg)
-{
- BLOCK_START("BeingRecv::processBeingSelfEffect")
- if ((effectManager == nullptr) || (actorManager == nullptr))
- {
- BLOCK_END("BeingRecv::processBeingSelfEffect")
- return;
- }
-
- const BeingId id = msg.readBeingId("being id");
- Being *const being = actorManager->findBeing(id);
- if (being == nullptr)
- {
- DEBUGLOGSTR("insible player?");
- msg.readInt32("effect type");
- BLOCK_END("BeingRecv::processBeingSelfEffect")
- return;
- }
-
- const int effectType = msg.readInt32("effect type");
-
- if (ParticleEngine::enabled)
- effectManager->trigger(effectType, being);
-
- // +++ need dehard code effectType == 3
- if (effectType == 3 && being->getType() == ActorType::Player
- && (socialWindow != nullptr))
- { // reset received damage
- socialWindow->resetDamage(being->getName());
- }
- BLOCK_END("BeingRecv::processBeingSelfEffect")
-}
-
-void BeingRecv::processSkillCastCancel(Net::MessageIn &msg)
-{
- msg.readInt32("skill id");
-}
-
-void BeingRecv::processIpResponse(Net::MessageIn &msg)
-{
- BLOCK_START("BeingRecv::processIpResponse")
- if (actorManager == nullptr)
- {
- BLOCK_END("BeingRecv::processIpResponse")
- return;
- }
-
- Being *const dstBeing = actorManager->findBeing(
- msg.readBeingId("being id"));
- if (dstBeing != nullptr)
- {
- const std::string ip = ipToString(msg.readInt32("ip address"));
- dstBeing->setIp(ip);
- }
- else
- {
- msg.readInt32("ip address");
- DEBUGLOGSTR("invisible player?");
- }
-
- BLOCK_END("BeingRecv::processIpResponse")
-}
-
-void BeingRecv::processPvpSet(Net::MessageIn &msg)
-{
- BLOCK_START("BeingRecv::processPvpSet")
- const BeingId id = msg.readBeingId("being id");
- const int rank = msg.readInt32("rank");
- int teamId = 0;
- teamId = msg.readInt32("team");
- if (actorManager != nullptr)
- {
- Being *const dstBeing = actorManager->findBeing(id);
- if (dstBeing != nullptr)
- {
- dstBeing->setPvpRank(rank);
- dstBeing->setTeamId(CAST_U16(teamId));
- dstBeing->addToCache();
- }
- }
- BLOCK_END("BeingRecv::processPvpSet")
-}
-
-void BeingRecv::applyPlayerAction(Net::MessageIn &msg,
- Being *const being,
- const uint8_t type)
-{
- if (being == nullptr)
- return;
- switch (type)
- {
- case 0:
- being->setAction(BeingAction::STAND, 0);
- localPlayer->imitateAction(being, BeingAction::STAND);
- break;
-
- case 1:
- if (being->getCurrentAction() != BeingAction::DEAD)
- {
- being->setAction(BeingAction::DEAD, 0);
- being->recalcSpritesOrder();
- }
- break;
-
- case 2:
- being->setAction(BeingAction::SIT, 0);
- localPlayer->imitateAction(being, BeingAction::SIT);
- break;
-
- default:
- UNIMPLEMENTEDPACKETFIELD(type);
- break;
- }
-}
-
-void BeingRecv::processSkillDamage(Net::MessageIn &msg)
-{
- BLOCK_START("BeingRecv::processSkillDamage")
- if (actorManager == nullptr)
- {
- BLOCK_END("BeingRecv::processSkillDamage")
- return;
- }
-
- const int id = msg.readInt16("skill id");
- Being *const srcBeing = actorManager->findBeing(
- msg.readBeingId("src being id"));
- Being *const dstBeing = actorManager->findBeing(
- msg.readBeingId("dst being id"));
- msg.readInt32("tick");
- msg.readInt32("src speed");
- msg.readInt32("dst speed");
- const int param1 = msg.readInt32("damage");
- const int level = msg.readInt16("skill level");
- msg.readInt16("div");
- msg.readUInt8("skill hit/type?");
- if (srcBeing != nullptr)
- srcBeing->handleSkill(dstBeing, param1, id, level);
- if (dstBeing != nullptr)
- dstBeing->takeDamage(srcBeing, param1, AttackType::SKILL, id, level);
- BLOCK_END("BeingRecv::processSkillDamage")
-}
-
-void BeingRecv::setServerGender(Being *const being,
- const uint8_t gender)
-{
- if (being == nullptr)
- return;
- switch (gender)
- {
- case 2:
- being->setGender(Gender::FEMALE);
- break;
- case 3:
- being->setGender(Gender::MALE);
- break;
- case 4:
- being->setGender(Gender::OTHER);
- break;
- default:
- being->setGender(Gender::UNSPECIFIED);
- break;
- }
-}
-
-} // namespace TmwAthena
diff --git a/src/net/tmwa/beingrecv.h b/src/net/tmwa/beingrecv.h
deleted file mode 100644
index 31e63b2f8..000000000
--- a/src/net/tmwa/beingrecv.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 NET_TMWA_BEINGRECV_H
-#define NET_TMWA_BEINGRECV_H
-
-#if defined(__GXX_EXPERIMENTAL_CXX0X__)
-#if defined(__APPLE__)
-#include <tr1/cstdint>
-#endif // defined(__APPLE__)
-#endif // defined(__GXX_EXPERIMENTAL_CXX0X__)
-
-#include "localconsts.h"
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-class Being;
-
-namespace TmwAthena
-{
- namespace BeingRecv
- {
- void processBeingChangeLook(Net::MessageIn &msg);
- void processBeingChangeLook2(Net::MessageIn &msg);
- void processBeingVisible(Net::MessageIn &msg);
- void processBeingMove(Net::MessageIn &msg);
- void processPlayerUpdate1(Net::MessageIn &msg);
- void processPlayerUpdate2(Net::MessageIn &msg);
- void processPlayerMove(Net::MessageIn &msg);
- void processBeingSpawn(Net::MessageIn &msg);
- void processSkillCasting(Net::MessageIn &msg);
- void processBeingStatusChange(Net::MessageIn &msg);
- void processBeingMove2(Net::MessageIn &msg);
- void processBeingChangeDirection(Net::MessageIn &msg);
- void processBeingChangeLookContinue(const Net::MessageIn &msg,
- Being *const dstBeing,
- const uint8_t type,
- const int id,
- const int id2) A_NONNULL(2);
- void processPlayerStatusChange(Net::MessageIn &msg);
- void processBeingResurrect(Net::MessageIn &msg);
- void processPlayerGuilPartyInfo(Net::MessageIn &msg);
- void processBeingSelfEffect(Net::MessageIn &msg);
- void processSkillCastCancel(Net::MessageIn &msg);
- void processIpResponse(Net::MessageIn &msg);
- void processPvpSet(Net::MessageIn &msg);
- void processSkillDamage(Net::MessageIn &msg);
- void applyPlayerAction(Net::MessageIn &msg,
- Being *const being,
- const uint8_t type);
- void setServerGender(Being *const being,
- const uint8_t gender);
- } // namespace BeingRecv
-} // namespace TmwAthena
-
-#endif // NET_TMWA_BEINGRECV_H
diff --git a/src/net/tmwa/buyingstorehandler.cpp b/src/net/tmwa/buyingstorehandler.cpp
deleted file mode 100644
index 4d028f918..000000000
--- a/src/net/tmwa/buyingstorehandler.cpp
+++ /dev/null
@@ -1,61 +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 "net/tmwa/buyingstorehandler.h"
-
-#include "debug.h"
-
-namespace TmwAthena
-{
-
-BuyingStoreHandler::BuyingStoreHandler()
-{
- buyingStoreHandler = this;
-}
-
-BuyingStoreHandler::~BuyingStoreHandler()
-{
- buyingStoreHandler = nullptr;
-}
-
-void BuyingStoreHandler::create(const std::string &name A_UNUSED,
- const int maxMoney A_UNUSED,
- const bool flag A_UNUSED,
- const STD_VECTOR<ShopItem*> &items A_UNUSED)
- const
-{
-}
-
-void BuyingStoreHandler::close() const
-{
-}
-
-void BuyingStoreHandler::open(const Being *const being A_UNUSED) const
-{
-}
-
-void BuyingStoreHandler::sell(const Being *const being A_UNUSED,
- const int storeId A_UNUSED,
- const Item *const item A_UNUSED,
- const int amount A_UNUSED) const
-{
-}
-
-} // namespace TmwAthena
diff --git a/src/net/tmwa/buyingstorehandler.h b/src/net/tmwa/buyingstorehandler.h
deleted file mode 100644
index 584293021..000000000
--- a/src/net/tmwa/buyingstorehandler.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 NET_TMWA_BUYINGSTOREHANDLER_H
-#define NET_TMWA_BUYINGSTOREHANDLER_H
-
-#include "net/buyingstorehandler.h"
-
-namespace TmwAthena
-{
-
-class BuyingStoreHandler final : public Net::BuyingStoreHandler
-{
- public:
- BuyingStoreHandler();
-
- A_DELETE_COPY(BuyingStoreHandler)
-
- ~BuyingStoreHandler();
-
- void create(const std::string &name,
- const int maxMoney,
- const bool flag,
- const STD_VECTOR<ShopItem*> &items) const override final
- A_CONST;
-
- void close() const override final A_CONST;
-
- void open(const Being *const being) const override final A_CONST;
-
- void sell(const Being *const being,
- const int storeId,
- const Item *const item,
- const int amount) const override final A_CONST;
-};
-
-} // namespace TmwAthena
-
-#endif // NET_TMWA_BUYINGSTOREHANDLER_H
diff --git a/src/net/tmwa/buysellhandler.cpp b/src/net/tmwa/buysellhandler.cpp
deleted file mode 100644
index 7d69c8a7a..000000000
--- a/src/net/tmwa/buysellhandler.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/>.
- */
-
-#include "net/tmwa/buysellhandler.h"
-
-#include "configuration.h"
-
-#include "gui/windows/chatwindow.h"
-#include "gui/windows/shopwindow.h"
-
-#include "net/chathandler.h"
-
-#include "net/ea/buysellrecv.h"
-
-#include "utils/timer.h"
-
-#include "debug.h"
-
-namespace TmwAthena
-{
-
-BuySellHandler::BuySellHandler() :
- Ea::BuySellHandler()
-{
- buySellHandler = this;
- Ea::BuySellRecv::mBuyDialog = nullptr;
-}
-
-BuySellHandler::~BuySellHandler()
-{
- buySellHandler = nullptr;
-}
-
-void BuySellHandler::requestSellList(const std::string &nick) const
-{
- if (nick.empty() || shopWindow == nullptr)
- return;
-
- const std::string data("!selllist " + toString(tick_time));
- shopWindow->setAcceptPlayer(nick);
- if (config.getBoolValue("hideShopMessages"))
- {
- chatHandler->privateMessage(nick, data);
- }
- else
- {
- if (chatWindow != nullptr)
- chatWindow->addWhisper(nick, data, ChatMsgType::BY_PLAYER);
- }
-}
-
-void BuySellHandler::requestBuyList(const std::string &nick) const
-{
- if (nick.empty() || (shopWindow == nullptr))
- return;
-
- const std::string data("!buylist " + toString(tick_time));
- shopWindow->setAcceptPlayer(nick);
-
- if (config.getBoolValue("hideShopMessages"))
- {
- chatHandler->privateMessage(nick, data);
- }
- else
- {
- if (chatWindow != nullptr)
- chatWindow->addWhisper(nick, data, ChatMsgType::BY_PLAYER);
- }
-}
-
-void BuySellHandler::sendBuyRequest(const std::string &nick,
- const ShopItem *const item,
- const int amount) const
-{
- if ((chatWindow == nullptr) || nick.empty() || (item == nullptr) ||
- amount < 1 || amount > item->getQuantity())
- {
- return;
- }
- const std::string data = strprintf("!buyitem %d %d %d",
- item->getId(), item->getPrice(), amount);
-
- if (config.getBoolValue("hideShopMessages"))
- chatHandler->privateMessage(nick, data);
- else
- chatWindow->addWhisper(nick, data, ChatMsgType::BY_PLAYER);
-}
-
-void BuySellHandler::sendSellRequest(const std::string &nick,
- const ShopItem *const item,
- const int amount) const
-{
- if ((chatWindow == nullptr) || nick.empty() || (item == nullptr) ||
- amount < 1 || amount > item->getQuantity())
- {
- return;
- }
-
- const std::string data = strprintf("!sellitem %d %d %d",
- item->getId(), item->getPrice(), amount);
-
- if (config.getBoolValue("hideShopMessages"))
- chatHandler->privateMessage(nick, data);
- else
- chatWindow->addWhisper(nick, data, ChatMsgType::BY_PLAYER);
-}
-
-void BuySellHandler::close() const
-{
-}
-
-} // namespace TmwAthena
diff --git a/src/net/tmwa/buysellhandler.h b/src/net/tmwa/buysellhandler.h
deleted file mode 100644
index 461935cda..000000000
--- a/src/net/tmwa/buysellhandler.h
+++ /dev/null
@@ -1,59 +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 NET_TMWA_BUYSELLHANDLER_H
-#define NET_TMWA_BUYSELLHANDLER_H
-
-#include "net/ea/buysellhandler.h"
-
-namespace TmwAthena
-{
-
-class BuySellHandler final : public Ea::BuySellHandler
-{
- public:
- BuySellHandler();
-
- A_DELETE_COPY(BuySellHandler)
-
- ~BuySellHandler();
-
- void requestSellList(const std::string &nick)
- const override final;
-
- void requestBuyList(const std::string &nick)
- const override final;
-
- void sendBuyRequest(const std::string &nick,
- const ShopItem *const item,
- const int amount) const override final;
-
- void sendSellRequest(const std::string &nick,
- const ShopItem *const item,
- const int amount) const override final;
-
- void close() const override final A_CONST;
-};
-
-} // namespace TmwAthena
-
-#endif // NET_TMWA_BUYSELLHANDLER_H
diff --git a/src/net/tmwa/buysellrecv.cpp b/src/net/tmwa/buysellrecv.cpp
deleted file mode 100644
index 004837e50..000000000
--- a/src/net/tmwa/buysellrecv.cpp
+++ /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/>.
- */
-
-#include "net/tmwa/buysellrecv.h"
-
-#include "notifymanager.h"
-
-#include "being/playerinfo.h"
-
-#include "const/resources/currency.h"
-
-#include "enums/resources/notifytypes.h"
-
-#include "gui/windows/buydialog.h"
-
-#include "gui/widgets/createwidget.h"
-
-#include "net/messagein.h"
-
-#include "net/ea/buysellrecv.h"
-
-#include "debug.h"
-
-namespace TmwAthena
-{
-
-void BuySellRecv::processNpcBuy(Net::MessageIn &msg)
-{
- msg.readInt16("len");
- const unsigned int n_items = (msg.getLength() - 4U) / 11;
- CREATEWIDGETV(Ea::BuySellRecv::mBuyDialog, BuyDialog,
- Ea::BuySellRecv::mNpcId,
- DEFAULT_CURRENCY);
- Ea::BuySellRecv::mBuyDialog->setMoney(
- PlayerInfo::getAttribute(Attributes::MONEY));
-
- for (unsigned int k = 0; k < n_items; k++)
- {
- const int value = msg.readInt32("price");
- msg.readInt32("dc value?");
- const ItemTypeT type = static_cast<ItemTypeT>(msg.readUInt8("type"));
- const int itemId = msg.readInt16("item id");
- const ItemColor color = ItemColor_one;
- Ea::BuySellRecv::mBuyDialog->addItem(itemId, type, color, 0, value);
- }
- Ea::BuySellRecv::mBuyDialog->sort();
-}
-
-void BuySellRecv::processNpcSellResponse(Net::MessageIn &msg)
-{
- switch (msg.readUInt8("result"))
- {
- case 0:
- NotifyManager::notify(NotifyTypes::SOLD);
- break;
- case 1:
- default:
- NotifyManager::notify(NotifyTypes::SELL_FAILED);
- break;
- case 2:
- NotifyManager::notify(NotifyTypes::SELL_TRADE_FAILED);
- break;
- case 3:
- NotifyManager::notify(NotifyTypes::SELL_UNSELLABLE_FAILED);
- break;
- }
-}
-
-void BuySellRecv::processNpcBuyResponse(Net::MessageIn &msg)
-{
- const uint8_t response = msg.readUInt8("response");
- if (response == 0U)
- {
- NotifyManager::notify(NotifyTypes::BUY_DONE);
- return;
- }
- // Reset player money since buy dialog already assumed purchase
- // would go fine
- if (Ea::BuySellRecv::mBuyDialog != nullptr)
- {
- Ea::BuySellRecv::mBuyDialog->setMoney(
- PlayerInfo::getAttribute(Attributes::MONEY));
- }
- switch (response)
- {
- case 1:
- NotifyManager::notify(NotifyTypes::BUY_FAILED_NO_MONEY);
- break;
-
- case 2:
- NotifyManager::notify(NotifyTypes::BUY_FAILED_OVERWEIGHT);
- break;
-
- case 3:
- NotifyManager::notify(NotifyTypes::BUY_FAILED_TOO_MANY_ITEMS);
- break;
-
- default:
- NotifyManager::notify(NotifyTypes::BUY_FAILED);
- break;
- };
-}
-
-} // namespace TmwAthena
diff --git a/src/net/tmwa/buysellrecv.h b/src/net/tmwa/buysellrecv.h
deleted file mode 100644
index fc1613b5d..000000000
--- a/src/net/tmwa/buysellrecv.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 NET_TMWA_BUYSELLRECV_H
-#define NET_TMWA_BUYSELLRECV_H
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-namespace TmwAthena
-{
- namespace BuySellRecv
- {
- void processNpcBuy(Net::MessageIn &msg);
- void processNpcSellResponse(Net::MessageIn &msg);
- void processNpcBuyResponse(Net::MessageIn &msg);
- } // namespace BuySellRecv
-} // namespace TmwAthena
-
-#endif // NET_TMWA_BUYSELLRECV_H
diff --git a/src/net/tmwa/cashshophandler.cpp b/src/net/tmwa/cashshophandler.cpp
deleted file mode 100644
index 9477af1cc..000000000
--- a/src/net/tmwa/cashshophandler.cpp
+++ /dev/null
@@ -1,68 +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 "net/tmwa/cashshophandler.h"
-
-#include "debug.h"
-
-namespace TmwAthena
-{
-
-CashShopHandler::CashShopHandler() :
- Net::CashShopHandler()
-{
- cashShopHandler = this;
-}
-
-CashShopHandler::~CashShopHandler()
-{
- cashShopHandler = nullptr;
-}
-
-void CashShopHandler::buyItem(const int points A_UNUSED,
- const int itemId A_UNUSED,
- const ItemColor color A_UNUSED,
- const int amount A_UNUSED) const
-{
-}
-
-void CashShopHandler::buyItems(const int points A_UNUSED,
- const STD_VECTOR<ShopItem*> &items A_UNUSED)
- const
-{
-}
-
-void CashShopHandler::close() const
-{
-}
-
-void CashShopHandler::requestPoints() const
-{
-}
-
-void CashShopHandler::requestTab(const int tab A_UNUSED) const
-{
-}
-
-void CashShopHandler::schedule() const
-{
-}
-
-} // namespace TmwAthena
diff --git a/src/net/tmwa/cashshophandler.h b/src/net/tmwa/cashshophandler.h
deleted file mode 100644
index 31d5872dd..000000000
--- a/src/net/tmwa/cashshophandler.h
+++ /dev/null
@@ -1,58 +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 NET_TMWA_CASHSHOPHANDLER_H
-#define NET_TMWA_CASHSHOPHANDLER_H
-
-#include "net/cashshophandler.h"
-
-namespace TmwAthena
-{
-
-class CashShopHandler final : public Net::CashShopHandler
-{
- public:
- CashShopHandler();
-
- A_DELETE_COPY(CashShopHandler)
-
- ~CashShopHandler();
-
- void buyItem(const int points,
- const int itemId,
- const ItemColor color,
- const int amount) const override final A_CONST;
-
- void buyItems(const int points,
- const STD_VECTOR<ShopItem*> &items) const override final
- A_CONST;
-
- void close() const override final A_CONST;
-
- void requestPoints() const override final A_CONST;
-
- void requestTab(const int tab) const override final A_CONST;
-
- void schedule() const override final A_CONST;
-};
-
-} // namespace TmwAthena
-
-#endif // NET_TMWA_CASHSHOPHANDLER_H
diff --git a/src/net/tmwa/charserverhandler.cpp b/src/net/tmwa/charserverhandler.cpp
deleted file mode 100644
index 258c1c163..000000000
--- a/src/net/tmwa/charserverhandler.cpp
+++ /dev/null
@@ -1,196 +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 "net/tmwa/charserverhandler.h"
-
-#include "gui/windows/charcreatedialog.h"
-
-#include "net/character.h"
-
-#include "net/ea/token.h"
-
-#include "net/tmwa/loginhandler.h"
-#include "net/tmwa/messageout.h"
-#include "net/tmwa/network.h"
-#include "net/tmwa/protocolout.h"
-
-#include "resources/db/chardb.h"
-
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-namespace TmwAthena
-{
-
-extern ServerInfo mapServer;
-
-extern ServerInfo charServer;
-
-CharServerHandler::CharServerHandler() :
- Ea::CharServerHandler()
-{
- charServerHandler = this;
-}
-
-CharServerHandler::~CharServerHandler()
-{
- charServerHandler = nullptr;
-}
-
-void CharServerHandler::chooseCharacter(Net::Character *const character) const
-{
- if (character == nullptr)
- return;
-
- mSelectedCharacter = character;
- mCharSelectDialog = nullptr;
-
- createOutPacket(CMSG_CHAR_SELECT);
- outMsg.writeInt8(CAST_U8(mSelectedCharacter->slot),
- "slot");
-}
-
-void CharServerHandler::newCharacter(const std::string &name, const int slot,
- const GenderT gender A_UNUSED,
- const int hairstyle,
- const int hairColor,
- const unsigned char race A_UNUSED,
- const uint16_t look A_UNUSED,
- const STD_VECTOR<int> &stats) const
-{
- createOutPacket(CMSG_CHAR_CREATE);
- outMsg.writeString(name, 24, "name");
- for (int i = 0; i < 6; i++)
- outMsg.writeInt8(CAST_U8(stats[i]), "stat");
-
- outMsg.writeInt8(CAST_U8(slot), "slot");
- outMsg.writeInt8(CAST_S8(hairColor), "hair color");
- outMsg.writeInt8(0, "unused");
- outMsg.writeInt8(CAST_S8(hairstyle), "hair style");
- outMsg.writeInt8(0, "unused");
-}
-
-void CharServerHandler::deleteCharacter(Net::Character *const character,
- const std::string &email A_UNUSED)
- const
-{
- if (character == nullptr)
- return;
-
- mSelectedCharacter = character;
-
- createOutPacket(CMSG_CHAR_DELETE);
- outMsg.writeBeingId(mSelectedCharacter->dummy->getId(), "id?");
- outMsg.writeString("a@a.com", 40, "email");
-}
-
-void CharServerHandler::switchCharacter() const
-{
- // This is really a map-server packet
- createOutPacket(CMSG_PLAYER_RESTART);
- outMsg.writeInt8(1, "flag");
-}
-
-void CharServerHandler::connect() const
-{
- const Token &token =
- static_cast<LoginHandler*>(loginHandler)->getToken();
-
- if (Network::mInstance == nullptr)
- return;
-
- Network::mInstance->disconnect();
- Network::mInstance->connect(charServer);
- createOutPacket(CMSG_CHAR_SERVER_CONNECT);
- outMsg.writeBeingId(token.account_ID, "account id");
- outMsg.writeInt32(token.session_ID1, "session id1");
- outMsg.writeInt32(token.session_ID2, "session id2");
- // [Fate] The next word is unused by the old char server, so we squeeze in
- // mana client version information
- outMsg.writeInt16(CLIENT_PROTOCOL_VERSION,
- "client protocol version");
- outMsg.writeInt8(Being::genderToInt(token.sex), "gender");
-
- // We get 4 useless bytes before the real answer comes in (what are these?)
- Network::mInstance->skip(4);
-}
-
-void CharServerHandler::setCharCreateDialog(CharCreateDialog *const window)
- const
-{
- mCharCreateDialog = window;
-
- if (mCharCreateDialog == nullptr)
- return;
-
- StringVect attributes;
- // TRANSLATORS: playe stat
- attributes.push_back(_("Strength:"));
- // TRANSLATORS: playe stat
- attributes.push_back(_("Agility:"));
- // TRANSLATORS: playe stat
- attributes.push_back(_("Vitality:"));
- // TRANSLATORS: playe stat
- attributes.push_back(_("Intelligence:"));
- // TRANSLATORS: playe stat
- attributes.push_back(_("Dexterity:"));
- // TRANSLATORS: playe stat
- attributes.push_back(_("Luck:"));
-
- const Token &token = static_cast<LoginHandler*>(loginHandler)->getToken();
-
- int minStat = CharDB::getMinStat();
- if (minStat == 0)
- minStat = 1;
- int maxStat = CharDB::getMaxStat();
- if (maxStat == 0)
- maxStat = 9;
- int sumStat = CharDB::getSumStat();
- if (sumStat == 0)
- sumStat = 30;
-
- mCharCreateDialog->setAttributes(attributes, sumStat, minStat, maxStat);
- mCharCreateDialog->setDefaultGender(token.sex);
-}
-
-void CharServerHandler::renameCharacter(const BeingId id A_UNUSED,
- const std::string &newName A_UNUSED)
- const
-{
-}
-
-void CharServerHandler::changeSlot(const int oldSlot A_UNUSED,
- const int newSlot A_UNUSED) const
-{
-}
-
-void CharServerHandler::ping() const
-{
-}
-
-unsigned int CharServerHandler::hatSprite() const
-{
- return 7;
-}
-
-} // namespace TmwAthena
diff --git a/src/net/tmwa/charserverhandler.h b/src/net/tmwa/charserverhandler.h
deleted file mode 100644
index e71fdb1b9..000000000
--- a/src/net/tmwa/charserverhandler.h
+++ /dev/null
@@ -1,91 +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 NET_TMWA_CHARSERVERHANDLER_H
-#define NET_TMWA_CHARSERVERHANDLER_H
-
-#include "net/ea/charserverhandler.h"
-
-namespace TmwAthena
-{
-
-/**
- * Deals with incoming messages from the character server.
- */
-class CharServerHandler final : public Ea::CharServerHandler
-{
- public:
- CharServerHandler();
-
- A_DELETE_COPY(CharServerHandler)
-
- ~CharServerHandler();
-
- void chooseCharacter(Net::Character *const character) const
- override final;
-
- void newCharacter(const std::string &name,
- const int slot,
- const GenderT gender,
- const int hairstyle,
- const int hairColor,
- const unsigned char race,
- const uint16_t look,
- const STD_VECTOR<int> &stats) const override final;
-
- void deleteCharacter(Net::Character *const character,
- const std::string &email) const override final;
-
- void renameCharacter(const BeingId id,
- const std::string &newName) const override final
- A_CONST;
-
- void switchCharacter() const override final;
-
- void connect() const override final;
-
- bool isNeedCreatePin() const override final
- { return false; }
-
- void setNewPincode(const std::string &pin A_UNUSED) const
- override final
- { }
-
- /**
- * Sets the character create dialog. The handler will clean up this
- * dialog when a new character is successfully created, and will unlock
- * the dialog when a new character failed to be created.
- */
- void setCharCreateDialog(CharCreateDialog *const window) const
- override final;
-
- void changeSlot(const int oldSlot,
- const int newSlot) const override final A_CONST;
-
- void ping() const override final A_CONST;
-
- unsigned int hatSprite() const override final A_CONST A_WARN_UNUSED;
-};
-
-} // namespace TmwAthena
-
-#endif // NET_TMWA_CHARSERVERHANDLER_H
diff --git a/src/net/tmwa/charserverrecv.cpp b/src/net/tmwa/charserverrecv.cpp
deleted file mode 100644
index 8b0f960df..000000000
--- a/src/net/tmwa/charserverrecv.cpp
+++ /dev/null
@@ -1,304 +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 "net/tmwa/charserverrecv.h"
-
-#include "client.h"
-#include "configuration.h"
-#include "settings.h"
-
-#include "gui/windows/charcreatedialog.h"
-#include "gui/windows/okdialog.h"
-
-#include "gui/widgets/createwidget.h"
-
-#include "net/character.h"
-#include "net/charserverhandler.h"
-#include "net/messagein.h"
-#include "net/serverfeatures.h"
-
-#include "net/ea/token.h"
-
-#include "net/tmwa/gamehandler.h"
-#include "net/tmwa/loginhandler.h"
-#include "net/tmwa/network.h"
-#include "net/tmwa/sprite.h"
-
-#include "resources/iteminfo.h"
-
-#include "resources/db/itemdb.h"
-
-#include "utils/dtor.h"
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-namespace TmwAthena
-{
-
-extern ServerInfo mapServer;
-
-extern ServerInfo charServer;
-
-void CharServerRecv::readPlayerData(Net::MessageIn &msg,
- Net::Character *const character)
-{
- if (character == nullptr)
- return;
-
- const Token &token =
- static_cast<LoginHandler*>(loginHandler)->getToken();
-
- LocalPlayer *const tempPlayer = new LocalPlayer(
- msg.readBeingId("account id"), BeingTypeId_zero);
-
- PlayerInfoBackend &data = character->data;
- data.mAttributes[Attributes::PLAYER_EXP] = msg.readInt32("base exp");
- data.mAttributes[Attributes::MONEY] = msg.readInt32("money");
- data.mAttributes[Attributes::PLAYER_JOB_EXP] = msg.readInt32("job exp");
- data.mAttributes[Attributes::PLAYER_JOB_LEVEL] =
- msg.readInt32("job level");
-
- const int shoes = msg.readInt16("shoes");
- const int gloves = msg.readInt16("gloves");
- const int cape = msg.readInt16("cape");
- const int misc1 = msg.readInt16("misc1");
-
- msg.readInt32("option");
- tempPlayer->setKarma(msg.readInt32("karma"));
- tempPlayer->setManner(msg.readInt32("manner"));
- msg.readInt16("character points left");
-
- data.mAttributes[Attributes::PLAYER_HP] = msg.readInt16("hp");
- data.mAttributes[Attributes::PLAYER_MAX_HP] = msg.readInt16("max hp");
- data.mAttributes[Attributes::PLAYER_MP] = msg.readInt16("mp");
- data.mAttributes[Attributes::PLAYER_MAX_MP] = msg.readInt16("max mp");
-
- msg.readInt16("speed");
- const uint16_t race = msg.readInt16("class");
- const uint8_t hairStyle = msg.readUInt8("hair style");
- const uint16_t look = msg.readUInt8("look");
- tempPlayer->setSubtype(fromInt(race, BeingTypeId), look);
- const uint16_t weapon = msg.readInt16("weapon");
- tempPlayer->setSpriteId(SPRITE_BODY,
- weapon);
- tempPlayer->setWeaponId(weapon);
-
- data.mAttributes[Attributes::PLAYER_BASE_LEVEL] = msg.readInt16("level");
-
- msg.readInt16("skill point");
- const int bottomClothes = msg.readInt16("bottom clothes");
- const int shield = msg.readInt16("shield");
-
- const int hat = msg.readInt16("hat");
- const int topClothes = msg.readInt16("top clothes");
-
- const ItemColor hairColor = fromInt(
- msg.readUInt8("hair color"), ItemColor);
- msg.readUInt8("unused");
- if (hairStyle == 0)
- {
- tempPlayer->unSetSprite(SPRITE_HAIR_COLOR);
- }
- else
- {
- tempPlayer->setSpriteColor(SPRITE_HAIR_COLOR,
- hairStyle * -1,
- ItemDB::get(-hairStyle).getDyeColorsString(hairColor));
- }
- tempPlayer->setHairColor(hairColor);
-
- const int misc2 = msg.readInt16("misc2");
- tempPlayer->setName(msg.readString(24, "name"));
-
- character->dummy = tempPlayer;
-
- character->data.mStats[Attributes::PLAYER_STR].base = msg.readUInt8("str");
- character->data.mStats[Attributes::PLAYER_AGI].base = msg.readUInt8("agi");
- character->data.mStats[Attributes::PLAYER_VIT].base = msg.readUInt8("vit");
- character->data.mStats[Attributes::PLAYER_INT].base = msg.readUInt8("int");
- character->data.mStats[Attributes::PLAYER_DEX].base = msg.readUInt8("dex");
- character->data.mStats[Attributes::PLAYER_LUK].base = msg.readUInt8("luk");
-
- tempPlayer->setSpriteId(SPRITE_HAIR,
- shoes);
- tempPlayer->setSpriteId(SPRITE_SHOES,
- gloves);
- tempPlayer->setSpriteId(SPRITE_SHIELD,
- cape);
- tempPlayer->setSpriteId(SPRITE_HEAD_TOP,
- misc1);
- tempPlayer->setSpriteId(SPRITE_WEAPON,
- bottomClothes);
- tempPlayer->setSpriteId(SPRITE_FLOOR,
- shield);
- tempPlayer->setSpriteId(SPRITE_CLOTHES_COLOR,
- hat);
- tempPlayer->setSpriteId(SPRITE_HEAD_BOTTOM,
- topClothes);
- tempPlayer->setSpriteId(SPRITE_HEAD_MID,
- misc2);
-
- character->slot = msg.readUInt8("slot");
- const uint8_t sex = CAST_U8(msg.readUInt8("gender"));
- if (serverFeatures->haveCreateCharGender())
- tempPlayer->setGender(Being::intToGender(sex));
- else
- tempPlayer->setGender(token.sex);
-}
-
-void CharServerRecv::processCharLogin(Net::MessageIn &msg)
-{
- BLOCK_START("CharServerRecv::processCharLogin")
-
- msg.readInt16("len");
- const int slots = msg.readInt16("slots");
- if (slots > 0 && slots < 30)
- loginData.characterSlots = CAST_U16(slots);
-
- msg.skip(18, "unused");
-
- delete_all(Net::CharServerHandler::mCharacters);
- Net::CharServerHandler::mCharacters.clear();
-
- // Derive number of characters from message length
- const int count = (msg.getLength() - 24) / 106;
-
- for (int i = 0; i < count; ++i)
- {
- Net::Character *const character = new Net::Character;
- readPlayerData(msg, character);
- Net::CharServerHandler::mCharacters.push_back(character);
- if (character->dummy != nullptr)
- {
- logger->log("CharServer: Player: %s (%d)",
- character->dummy->getName().c_str(), character->slot);
- }
- }
-
- client->setState(State::CHAR_SELECT);
- BLOCK_END("CharServerRecv::processCharLogin")
-}
-
-void CharServerRecv::processCharMapInfo(Net::MessageIn &restrict msg)
-{
- Network *const network = Network::mInstance;
- ServerInfo &server = mapServer;
- BLOCK_START("CharServerRecv::processCharMapInfo")
- PlayerInfo::setCharId(msg.readInt32("char id?"));
- GameHandler::setMap(msg.readString(16, "map name"));
- if (config.getBoolValue("usePersistentIP") || settings.persistentIp)
- {
- msg.readInt32("ip address");
- server.hostname = settings.serverName;
- }
- else
- {
- server.hostname = ipToString(msg.readInt32("ip address"));
- }
- server.port = msg.readInt16("port");
-
- // Prevent the selected local player from being deleted
- localPlayer = Net::CharServerHandler::mSelectedCharacter->dummy;
- PlayerInfo::setBackend(Net::CharServerHandler::mSelectedCharacter->data);
-
- Net::CharServerHandler::mSelectedCharacter->dummy = nullptr;
-
- charServerHandler->clear();
- Net::CharServerHandler::updateCharSelectDialog();
-
- if (network != nullptr)
- network->disconnect();
- client->setState(State::CONNECT_GAME);
- BLOCK_END("CharServerRecv::processCharMapInfo")
-}
-
-void CharServerRecv::processChangeMapServer(Net::MessageIn &msg)
-{
- Network *const network = Network::mInstance;
- ServerInfo &server = mapServer;
- BLOCK_START("CharServerRecv::processChangeMapServer")
- if (network == nullptr)
- {
- BLOCK_END("CharServerRecv::processChangeMapServer")
- return;
- }
- GameHandler::setMap(msg.readString(16, "map name"));
- const int x = msg.readInt16("x");
- const int y = msg.readInt16("y");
- if (config.getBoolValue("usePersistentIP") || settings.persistentIp)
- {
- msg.readInt32("ip address");
- server.hostname = settings.serverName;
- }
- else
- {
- server.hostname = ipToString(msg.readInt32("ip address"));
- }
- server.port = msg.readInt16("port");
-
- network->disconnect();
- client->setState(State::CHANGE_MAP);
- if (localPlayer != nullptr)
- {
- localPlayer->setTileCoords(x, y);
- localPlayer->setMap(nullptr);
- }
- BLOCK_END("CharServerRecv::processChangeMapServer")
-}
-
-void CharServerRecv::processCharCreate(Net::MessageIn &msg)
-{
- BLOCK_START("CharServerRecv::processCharCreate")
- Net::Character *const character = new Net::Character;
- readPlayerData(msg, character);
- Net::CharServerHandler::mCharacters.push_back(character);
-
- Net::CharServerHandler::updateCharSelectDialog();
-
- // Close the character create dialog
- Net::CharServerHandler::mCharCreateDialog->scheduleDelete();
- Net::CharServerHandler::mCharCreateDialog = nullptr;
- BLOCK_END("CharServerRecv::processCharCreate")
-}
-
-void CharServerRecv::processCharDeleteFailed(Net::MessageIn &msg)
-{
- BLOCK_START("CharServerRecv::processCharDeleteFailed")
- Net::CharServerHandler::unlockCharSelectDialog();
- msg.readUInt8("error");
- CREATEWIDGET(OkDialog,
- // TRANSLATORS: error header
- _("Error"),
- // TRANSLATORS: error message
- _("Failed to delete character."),
- // TRANSLATORS: ok dialog button
- _("OK"),
- DialogType::ERROR,
- Modal_true,
- ShowCenter_true,
- nullptr,
- 260);
- BLOCK_END("CharServerRecv::processCharDeleteFailed")
-}
-
-} // namespace TmwAthena
diff --git a/src/net/tmwa/charserverrecv.h b/src/net/tmwa/charserverrecv.h
deleted file mode 100644
index 195c5239c..000000000
--- a/src/net/tmwa/charserverrecv.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 NET_TMWA_CHARSERVERRECV_H
-#define NET_TMWA_CHARSERVERRECV_H
-
-namespace Net
-{
- class MessageIn;
-
- struct Character;
-} // namespace Net
-
-namespace TmwAthena
-{
- namespace CharServerRecv
- {
- void readPlayerData(Net::MessageIn &msg,
- Net::Character *const character);
- void processCharCreate(Net::MessageIn &msg);
- void processCharDeleteFailed(Net::MessageIn &msg);
- void processCharLogin(Net::MessageIn &msg);
- void processCharMapInfo(Net::MessageIn &msg);
- void processChangeMapServer(Net::MessageIn &msg);
- } // namespace CharServerRecv
-} // namespace TmwAthena
-
-#endif // NET_TMWA_CHARSERVERRECV_H
diff --git a/src/net/tmwa/chathandler.cpp b/src/net/tmwa/chathandler.cpp
deleted file mode 100644
index 2b768ffe2..000000000
--- a/src/net/tmwa/chathandler.cpp
+++ /dev/null
@@ -1,260 +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 "net/tmwa/chathandler.h"
-
-#include "being/localplayer.h"
-
-#include "const/gui/chat.h"
-
-#include "net/ea/chatrecv.h"
-
-#include "net/tmwa/messageout.h"
-#include "net/tmwa/protocolout.h"
-
-#include "utils/gmfunctions.h"
-#include "utils/stringutils.h"
-
-#include "debug.h"
-
-extern unsigned int tmwServerVersion;
-
-namespace TmwAthena
-{
-
-ChatHandler::ChatHandler() :
- Ea::ChatHandler()
-{
- chatHandler = this;
-}
-
-ChatHandler::~ChatHandler()
-{
- chatHandler = nullptr;
-}
-
-void ChatHandler::talk(const std::string &restrict text,
- const std::string &restrict channel A_UNUSED) const
-{
- if (localPlayer == nullptr)
- return;
-
- if (tmwServerVersion >= 0x100408)
- {
- createOutPacket(CMSG_CHAT_MESSAGE);
- // Added + 1 in order to let eAthena parse admin commands correctly
- outMsg.writeInt16(CAST_S16(text.length() + 4 + 1), "len");
- outMsg.writeString(text, CAST_S32(text.length() + 1), "message");
- }
- else
- {
- const std::string mes = std::string(localPlayer->getName()).append(
- " : ").append(text);
-
- createOutPacket(CMSG_CHAT_MESSAGE);
- // Added + 1 in order to let eAthena parse admin commands correctly
- outMsg.writeInt16(CAST_S16(mes.length() + 4 + 1), "len");
- outMsg.writeString(mes, CAST_S32(mes.length() + 1), "message");
- }
-}
-
-void ChatHandler::talkRaw(const std::string &mes) const
-{
- createOutPacket(CMSG_CHAT_MESSAGE);
- outMsg.writeInt16(CAST_S16(mes.length() + 4), "len");
- outMsg.writeString(mes, CAST_S32(mes.length()), "message");
-}
-
-void ChatHandler::privateMessage(const std::string &restrict recipient,
- const std::string &restrict text) const
-{
- createOutPacket(CMSG_CHAT_WHISPER);
- outMsg.writeInt16(CAST_S16(text.length() + 28), "len");
- outMsg.writeString(recipient, 24, "recipient nick");
- outMsg.writeString(text, CAST_S32(text.length()), "message");
- Ea::ChatRecv::mSentWhispers.push(recipient);
-}
-
-void ChatHandler::channelMessage(const std::string &restrict channel,
- const std::string &restrict text) const
-{
- if (channel == TRADE_CHANNEL)
- talk("\302\202" + text, GENERAL_CHANNEL);
- else if (channel == GM_CHANNEL)
- Gm::runCommand("wgm", text);
-}
-
-void ChatHandler::who() const
-{
- if (tmwServerVersion >= 0x0e0b0b)
- return;
-
- createOutPacket(CMSG_WHO_REQUEST);
-}
-
-void ChatHandler::sendRaw(const std::string &args) const
-{
- std::string line = args;
- std::string str;
- MessageOut *outMsg = nullptr;
-
- if (line.empty())
- return;
-
- size_t pos = line.find(' ');
- if (pos != std::string::npos)
- {
- str = line.substr(0, pos);
- const int16_t id = CAST_S16(parseNumber(str));
- outMsg = new MessageOut(id);
- outMsg->writeInt16(id, "packet id");
- line = line.substr(pos + 1);
- pos = line.find(' ');
- }
- else
- {
- const int16_t id = CAST_S16(parseNumber(line));
- outMsg = new MessageOut(id);
- outMsg->writeInt16(id, "packet id");
- delete outMsg;
- return;
- }
-
- while (pos != std::string::npos)
- {
- str = line.substr(0, pos);
- processRaw(*outMsg, str);
- line = line.substr(pos + 1);
- pos = line.find(' ');
- }
- if (!line.empty())
- processRaw(*outMsg, line);
- delete outMsg;
-}
-
-void ChatHandler::processRaw(MessageOut &restrict outMsg,
- const std::string &restrict line)
-{
- if (line.size() < 2)
- return;
-
- const uint32_t i = parseNumber(line.substr(1));
- switch (tolower(line[0]))
- {
- case 'b':
- {
- outMsg.writeInt8(CAST_U8(i), "raw");
- break;
- }
- case 'w':
- {
- outMsg.writeInt16(CAST_S16(i), "raw");
- break;
- }
- case 'l':
- {
- outMsg.writeInt32(CAST_S32(i), "raw");
- break;
- }
- default:
- break;
- }
-}
-
-void ChatHandler::ignoreAll() const
-{
-}
-
-void ChatHandler::unIgnoreAll() const
-{
-}
-
-void ChatHandler::ignore(const std::string &nick) const
-{
- createOutPacket(CMSG_IGNORE_NICK);
- outMsg.writeString(nick, 24, "nick");
- outMsg.writeInt8(0, "flag");
-}
-
-void ChatHandler::unIgnore(const std::string &nick) const
-{
- createOutPacket(CMSG_IGNORE_NICK);
- outMsg.writeString(nick, 24, "nick");
- outMsg.writeInt8(1, "flag");
-}
-
-void ChatHandler::requestIgnoreList() const
-{
-}
-
-void ChatHandler::createChatRoom(const std::string &title A_UNUSED,
- const std::string &password A_UNUSED,
- const int limit A_UNUSED,
- const bool isPublic A_UNUSED) const
-{
-}
-
-void ChatHandler::battleTalk(const std::string &text A_UNUSED) const
-{
-}
-
-void ChatHandler::joinChat(const ChatObject *const chat A_UNUSED,
- const std::string &password A_UNUSED) const
-{
-}
-
-void ChatHandler::joinChannel(const std::string &channel A_UNUSED) const
-{
-}
-
-void ChatHandler::partChannel(const std::string &channel A_UNUSED) const
-{
-}
-
-void ChatHandler::talkPet(const std::string &restrict text,
- const std::string &restrict channel) const
-{
- // here need string duplication
- std::string action = strprintf("\302\202\303 %s", text.c_str());
- talk(action, channel);
-}
-
-void ChatHandler::leaveChatRoom() const
-{
-}
-
-void ChatHandler::setChatRoomOptions(const int limit A_UNUSED,
- const bool isPublict A_UNUSED,
- const std::string &passwordt A_UNUSED,
- const std::string &titlet A_UNUSED) const
-{
-}
-
-void ChatHandler::setChatRoomOwner(const std::string &nick A_UNUSED) const
-{
-}
-
-void ChatHandler::kickFromChatRoom(const std::string &nick A_UNUSED) const
-{
-}
-
-} // namespace TmwAthena
diff --git a/src/net/tmwa/chathandler.h b/src/net/tmwa/chathandler.h
deleted file mode 100644
index 12de8067c..000000000
--- a/src/net/tmwa/chathandler.h
+++ /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/>.
- */
-
-#ifndef NET_TMWA_CHATHANDLER_H
-#define NET_TMWA_CHATHANDLER_H
-
-#include "net/ea/chathandler.h"
-
-namespace TmwAthena
-{
-class MessageOut;
-
-class ChatHandler final : public Ea::ChatHandler
-{
- public:
- ChatHandler();
-
- A_DELETE_COPY(ChatHandler)
-
- ~ChatHandler();
-
- void talk(const std::string &restrict text,
- const std::string &restrict channel) const override final;
-
- void talkRaw(const std::string &text) const override final;
-
- void privateMessage(const std::string &restrict recipient,
- const std::string &restrict text) const
- override final;
-
- void channelMessage(const std::string &restrict channel,
- const std::string &restrict text) const
- override final;
-
- void joinChannel(const std::string &channel) const override final
- A_CONST;
-
- void who() const override final;
-
- void sendRaw(const std::string &args) const override final;
-
- void ignoreAll() const override final;
-
- void unIgnoreAll() const override final;
-
- void createChatRoom(const std::string &title,
- const std::string &password,
- const int limit,
- const bool isPublic) const override final A_CONST;
-
- void ignore(const std::string &nick) const override final;
-
- void unIgnore(const std::string &nick) const override final;
-
- void requestIgnoreList() const override final A_CONST;
-
- void battleTalk(const std::string &text) const override final A_CONST;
-
- void joinChat(const ChatObject *const chat,
- const std::string &password) const override final
- A_CONST;
-
- void partChannel(const std::string &channel) const override final
- A_CONST;
-
- void talkPet(const std::string &restrict text,
- const std::string &restrict channel) const override final;
-
- void leaveChatRoom() const override final A_CONST;
-
- void setChatRoomOptions(const int limit,
- const bool isPublic,
- const std::string &password,
- const std::string &title) const override final
- A_CONST;
-
- void setChatRoomOwner(const std::string &nick) const override final
- A_CONST;
-
- void kickFromChatRoom(const std::string &nick) const override final
- A_CONST;
-
- protected:
- static void processRaw(MessageOut &restrict outMsg,
- const std::string &restrict line);
-};
-
-} // namespace TmwAthena
-
-#endif // NET_TMWA_CHATHANDLER_H
diff --git a/src/net/tmwa/chatrecv.cpp b/src/net/tmwa/chatrecv.cpp
deleted file mode 100644
index afa501004..000000000
--- a/src/net/tmwa/chatrecv.cpp
+++ /dev/null
@@ -1,377 +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 "net/tmwa/chatrecv.h"
-
-#include "actormanager.h"
-#include "configuration.h"
-
-#include "being/localplayer.h"
-#include "being/playerrelation.h"
-#include "being/playerrelations.h"
-
-#include "const/gui/chat.h"
-
-#include "gui/widgets/tabs/chat/gmtab.h"
-
-#include "gui/windows/chatwindow.h"
-#include "gui/windows/shopwindow.h"
-
-#include "net/serverfeatures.h"
-
-#include "net/ea/chatrecv.h"
-
-#include "net/messagein.h"
-
-#include "net/tmwa/guildmanager.h"
-
-#include "debug.h"
-
-namespace TmwAthena
-{
-
-void ChatRecv::processChat(Net::MessageIn &msg)
-{
- BLOCK_START("ChatRecv::processChat")
- const int chatMsgLength = msg.readInt16("len") - 4;
- if (chatMsgLength <= 0)
- {
- BLOCK_END("ChatRecv::processChat")
- return;
- }
-
- processChatContinue(msg.readRawString(chatMsgLength, "message"), "");
-}
-
-void ChatRecv::processChatContinue(std::string chatMsg,
- const std::string &channel)
-{
- const size_t pos = chatMsg.find(" : ", 0);
-
- bool allow(true);
- if (chatWindow != nullptr)
- {
- allow = chatWindow->resortChatLog(chatMsg,
- ChatMsgType::BY_PLAYER,
- channel,
- IgnoreRecord_false,
- TryRemoveColors_true);
- }
-
- if (channel.empty())
- {
- const std::string senseStr("You sense the following: ");
- if ((actorManager != nullptr) && (chatMsg.find(senseStr) == 0u))
- {
- actorManager->parseLevels(
- chatMsg.substr(senseStr.size()));
- }
- }
-
- if (pos == std::string::npos &&
- !Ea::ChatRecv::mShowMotd &&
- Ea::ChatRecv::mSkipping &&
- channel.empty())
- {
- // skip motd from "new" tmw server
- if (Ea::ChatRecv::mMotdTime == 0)
- {
- Ea::ChatRecv::mMotdTime = cur_time + 1;
- }
- else if (Ea::ChatRecv::mMotdTime == cur_time ||
- Ea::ChatRecv::mMotdTime < cur_time)
- {
- Ea::ChatRecv::mSkipping = false;
- }
- BLOCK_END("ChatRecv::processChat")
- return;
- }
-
- if (pos != std::string::npos)
- chatMsg.erase(0, pos + 3);
-
- trim(chatMsg);
-
- if (localPlayer != nullptr)
- {
- if (((chatWindow != nullptr) || Ea::ChatRecv::mShowMotd) && allow)
- localPlayer->setSpeech(chatMsg, channel);
- }
- BLOCK_END("ChatRecv::processChat")
-}
-
-void ChatRecv::processGmChat(Net::MessageIn &msg)
-{
- BLOCK_START("ChatRecv::processChat")
- const int chatMsgLength = msg.readInt16("len") - 4;
- if (chatMsgLength <= 0)
- {
- BLOCK_END("ChatRecv::processChat")
- return;
- }
-
- if (localChatTab != nullptr &&
- chatWindow != nullptr)
- {
- std::string chatMsg = msg.readRawString(chatMsgLength, "message");
- chatWindow->addGlobalMessage(chatMsg);
- }
- else
- {
- msg.readRawString(chatMsgLength, "message");
- }
- BLOCK_END("ChatRecv::processChat")
-}
-
-void ChatRecv::processWhisper(Net::MessageIn &msg)
-{
- BLOCK_START("ChatRecv::processWhisper")
- const int chatMsgLength = msg.readInt16("len") - 28;
- std::string nick = msg.readString(24, "nick");
-
- if (chatMsgLength <= 0)
- {
- BLOCK_END("ChatRecv::processWhisper")
- return;
- }
-
- processWhisperContinue(nick, msg.readString(chatMsgLength, "message"));
-}
-
-void ChatRecv::processWhisperResponse(Net::MessageIn &msg)
-{
- BLOCK_START("ChatRecv::processWhisperResponse")
-
- const uint8_t type = msg.readUInt8("response");
- Ea::ChatRecv::processWhisperResponseContinue(msg, type);
-}
-
-void ChatRecv::processWhisperContinue(const std::string &nick,
- std::string chatMsg)
-{
- // ignoring future whisper messages
- if (chatMsg.find("\302\202G") == 0 || chatMsg.find("\302\202A") == 0)
- {
- BLOCK_END("ChatRecv::processWhisper")
- return;
- }
- // remove first unicode space if this is may be whisper command.
- if (chatMsg.find("\302\202!") == 0)
- chatMsg = chatMsg.substr(2);
-
- if (nick != "Server")
- {
- if ((guildManager != nullptr) && GuildManager::getEnableGuildBot()
- && nick == "guild" && guildManager->processGuildMessage(chatMsg))
- {
- BLOCK_END("ChatRecv::processWhisper")
- return;
- }
-
- if (playerRelations.hasPermission(nick, PlayerRelation::WHISPER))
- {
- const bool tradeBot = config.getBoolValue("tradebot");
- const bool showMsg = !config.getBoolValue("hideShopMessages");
- if (playerRelations.hasPermission(nick, PlayerRelation::TRADE))
- {
- if (shopWindow != nullptr)
- { // commands to shop from player
- if (chatMsg.find("!selllist ") == 0)
- {
- if (tradeBot)
- {
- if (showMsg && (chatWindow != nullptr))
- chatWindow->addWhisper(nick, chatMsg);
- shopWindow->giveList(nick, ShopWindow::SELL);
- }
- }
- else if (chatMsg.find("!buylist ") == 0)
- {
- if (tradeBot)
- {
- if (showMsg && (chatWindow != nullptr))
- chatWindow->addWhisper(nick, chatMsg);
- shopWindow->giveList(nick, ShopWindow::BUY);
- }
- }
- else if (chatMsg.find("!buyitem ") == 0)
- {
- if (showMsg && (chatWindow != nullptr))
- chatWindow->addWhisper(nick, chatMsg);
- if (tradeBot)
- {
- shopWindow->processRequest(nick, chatMsg,
- ShopWindow::BUY);
- }
- }
- else if (chatMsg.find("!sellitem ") == 0)
- {
- if (showMsg && (chatWindow != nullptr))
- chatWindow->addWhisper(nick, chatMsg);
- if (tradeBot)
- {
- shopWindow->processRequest(nick, chatMsg,
- ShopWindow::SELL);
- }
- }
- else if (chatMsg.length() > 3
- && chatMsg.find("\302\202") == 0)
- {
- chatMsg = chatMsg.erase(0, 2);
- if (showMsg && (chatWindow != nullptr))
- chatWindow->addWhisper(nick, chatMsg);
- if (chatMsg.find("B1") == 0 || chatMsg.find("S1") == 0)
- ShopWindow::showList(nick, chatMsg);
- }
- else if (chatWindow != nullptr)
- {
- chatWindow->addWhisper(nick, chatMsg);
- }
- }
- else if (chatWindow != nullptr)
- {
- chatWindow->addWhisper(nick, chatMsg);
- }
- }
- else
- {
- if (chatWindow != nullptr &&
- (showMsg ||
- (chatMsg.find("!selllist") != 0 &&
- chatMsg.find("!buylist") != 0)))
- {
- chatWindow->addWhisper(nick, chatMsg);
- }
- }
- }
- }
- else if (localChatTab != nullptr)
- {
- if ((gmChatTab != nullptr) && strStartWith(chatMsg, "[GM] "))
- {
- chatMsg = chatMsg.substr(5);
- const size_t pos = chatMsg.find(": ", 0);
- if (pos == std::string::npos)
- {
- gmChatTab->chatLog(chatMsg, ChatMsgType::BY_SERVER);
- }
- else
- {
- gmChatTab->chatLog(chatMsg.substr(0, pos),
- chatMsg.substr(pos + 2));
- }
- }
- else
- {
- localChatTab->chatLog(chatMsg, ChatMsgType::BY_SERVER);
- }
- }
- BLOCK_END("ChatRecv::processWhisper")
-}
-
-void ChatRecv::processBeingChat(Net::MessageIn &msg)
-{
- if (actorManager == nullptr)
- return;
-
- BLOCK_START("ChatRecv::processBeingChat")
- const int chatMsgLength = msg.readInt16("len") - 8;
- const BeingId beingId = msg.readBeingId("being id");
- Being *const being = actorManager->findBeing(beingId);
-
- if (chatMsgLength <= 0)
- {
- BLOCK_END("ChatRecv::processBeingChat")
- return;
- }
-
- std::string chatMsg = msg.readRawString(chatMsgLength, "message");
-
- if ((being != nullptr) && being->getType() == ActorType::Player)
- being->setTalkTime();
-
- const size_t pos = chatMsg.find(" : ", 0);
- std::string sender_name = ((pos == std::string::npos)
- ? "" : chatMsg.substr(0, pos));
-
- if (serverFeatures->haveIncompleteChatMessages())
- {
- // work around for "new" tmw server
- if (being != nullptr)
- sender_name = being->getName();
- if (sender_name.empty())
- {
- sender_name = "?" + toString(CAST_S32(beingId));
- const std::string name = actorManager->getSeenPlayerById(beingId);
- if (!name.empty())
- sender_name.append(" ").append(name);
- }
- }
- else if ((being != nullptr) &&
- sender_name != being->getName() &&
- being->getType() == ActorType::Player)
- {
- if (!being->getName().empty())
- sender_name = being->getName();
- }
- else
- {
- chatMsg.erase(0, pos + 3);
- }
-
- trim(chatMsg);
-
- bool allow(true);
- // We use getIgnorePlayer instead of ignoringPlayer here
- // because ignorePlayer' side effects are triggered
- // right below for Being::IGNORE_SPEECH_FLOAT.
- if ((playerRelations.checkPermissionSilently(sender_name,
- PlayerRelation::SPEECH_LOG) != 0u) &&
- (chatWindow != nullptr))
- {
- allow = chatWindow->resortChatLog(
- removeColors(sender_name).append(" : ").append(chatMsg),
- ChatMsgType::BY_OTHER,
- GENERAL_CHANNEL,
- IgnoreRecord_false,
- TryRemoveColors_true);
- }
-
- if (allow &&
- (being != nullptr) &&
- playerRelations.hasPermission(sender_name,
- PlayerRelation::SPEECH_FLOAT))
- {
- being->setSpeech(chatMsg, GENERAL_CHANNEL);
- }
- BLOCK_END("ChatRecv::processBeingChat")
-}
-
-void ChatRecv::processScriptMessage(Net::MessageIn &msg)
-{
- const int sz = msg.readInt16("len") - 5;
- msg.readUInt8("message type");
- const std::string message = msg.readString(sz, "message");
- localChatTab->chatLog(message, ChatMsgType::BY_SERVER);
-}
-
-} // namespace TmwAthena
diff --git a/src/net/tmwa/chatrecv.h b/src/net/tmwa/chatrecv.h
deleted file mode 100644
index 3e7b58b15..000000000
--- a/src/net/tmwa/chatrecv.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 NET_TMWA_CHATRECV_H
-#define NET_TMWA_CHATRECV_H
-
-#include <string>
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-namespace TmwAthena
-{
- namespace ChatRecv
- {
- void processChat(Net::MessageIn &msg);
- void processChatContinue(std::string chatMsg,
- const std::string &channel);
- void processGmChat(Net::MessageIn &msg);
- void processWhisper(Net::MessageIn &msg);
- void processWhisperResponse(Net::MessageIn &msg);
- void processWhisperContinue(const std::string &nick,
- std::string chatMsg);
- void processBeingChat(Net::MessageIn &msg);
- void processScriptMessage(Net::MessageIn &msg);
- } // namespace ChatRecv
-} // namespace TmwAthena
-
-#endif // NET_TMWA_CHATRECV_H
diff --git a/src/net/tmwa/elementalhandler.cpp b/src/net/tmwa/elementalhandler.cpp
deleted file mode 100644
index 78230f3df..000000000
--- a/src/net/tmwa/elementalhandler.cpp
+++ /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/>.
- */
-
-#include "net/tmwa/elementalhandler.h"
-
-#include "debug.h"
-
-namespace TmwAthena
-{
-
-ElementalHandler::ElementalHandler() :
- Net::ElementalHandler()
-{
- elementalHandler = this;
-}
-
-ElementalHandler::~ElementalHandler()
-{
- elementalHandler = nullptr;
-}
-
-} // namespace TmwAthena
diff --git a/src/net/tmwa/elementalhandler.h b/src/net/tmwa/elementalhandler.h
deleted file mode 100644
index 5aea5b5d2..000000000
--- a/src/net/tmwa/elementalhandler.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 NET_TMWA_ELEMENTALHANDLER_H
-#define NET_TMWA_ELEMENTALHANDLER_H
-
-#include "net/elementalhandler.h"
-
-namespace TmwAthena
-{
- class ElementalHandler final : public Net::ElementalHandler
- {
- public:
- ElementalHandler();
-
- A_DELETE_COPY(ElementalHandler)
-
- ~ElementalHandler();
- };
-} // namespace TmwAthena
-
-#endif // NET_TMWA_ELEMENTALHANDLER_H
diff --git a/src/net/tmwa/familyhandler.cpp b/src/net/tmwa/familyhandler.cpp
deleted file mode 100644
index 9f5bb7fe9..000000000
--- a/src/net/tmwa/familyhandler.cpp
+++ /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/>.
- */
-
-#include "net/tmwa/familyhandler.h"
-
-#include "debug.h"
-
-namespace TmwAthena
-{
-
-FamilyHandler::FamilyHandler() :
- Net::FamilyHandler()
-{
- familyHandler = this;
-}
-
-FamilyHandler::~FamilyHandler()
-{
- familyHandler = nullptr;
-}
-
-void FamilyHandler::askForChild(const Being *const being A_UNUSED) const
-{
-}
-
-void FamilyHandler::askForChildReply(const bool accept A_UNUSED) const
-{
-}
-
-} // namespace TmwAthena
diff --git a/src/net/tmwa/familyhandler.h b/src/net/tmwa/familyhandler.h
deleted file mode 100644
index b2cc6c96a..000000000
--- a/src/net/tmwa/familyhandler.h
+++ /dev/null
@@ -1,46 +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 NET_TMWA_FAMILYHANDLER_H
-#define NET_TMWA_FAMILYHANDLER_H
-
-#include "net/familyhandler.h"
-
-namespace TmwAthena
-{
-
-class FamilyHandler final : public Net::FamilyHandler
-{
- public:
- FamilyHandler();
-
- A_DELETE_COPY(FamilyHandler)
-
- ~FamilyHandler();
-
- void askForChild(const Being *const being) const override final
- A_CONST;
-
- void askForChildReply(const bool accept) const override final A_CONST;
-};
-
-} // namespace TmwAthena
-
-#endif // NET_TMWA_FAMILYHANDLER_H
diff --git a/src/net/tmwa/friendshandler.cpp b/src/net/tmwa/friendshandler.cpp
deleted file mode 100644
index 094952df4..000000000
--- a/src/net/tmwa/friendshandler.cpp
+++ /dev/null
@@ -1,53 +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 "net/tmwa/friendshandler.h"
-
-#include "debug.h"
-
-namespace TmwAthena
-{
-
-FriendsHandler::FriendsHandler()
-{
- friendsHandler = this;
-}
-
-FriendsHandler::~FriendsHandler()
-{
- friendsHandler = nullptr;
-}
-
-void FriendsHandler::invite(const std::string &name A_UNUSED) const
-{
-}
-
-void FriendsHandler::inviteResponse(const int accountId A_UNUSED,
- const int charId A_UNUSED,
- const bool accept A_UNUSED) const
-{
-}
-
-void FriendsHandler::remove(const int accountId A_UNUSED,
- const int charId A_UNUSED) const
-{
-}
-
-} // namespace TmwAthena
diff --git a/src/net/tmwa/friendshandler.h b/src/net/tmwa/friendshandler.h
deleted file mode 100644
index ef9d05c60..000000000
--- a/src/net/tmwa/friendshandler.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 NET_TMWA_FRIENDSHANDLER_H
-#define NET_TMWA_FRIENDSHANDLER_H
-
-#include "net/friendshandler.h"
-
-namespace TmwAthena
-{
-class FriendsHandler final : public Net::FriendsHandler
-{
- public:
- FriendsHandler();
-
- A_DELETE_COPY(FriendsHandler)
-
- ~FriendsHandler();
-
- void invite(const std::string &name) const override final A_CONST;
-
- void inviteResponse(const int accountId,
- const int charId,
- const bool accept) const override final A_CONST;
-
- void remove(const int accountId,
- const int charId) const override final A_CONST;
-};
-
-} // namespace TmwAthena
-
-#endif // NET_TMWA_FRIENDSHANDLER_H
diff --git a/src/net/tmwa/gamehandler.cpp b/src/net/tmwa/gamehandler.cpp
deleted file mode 100644
index d13c46919..000000000
--- a/src/net/tmwa/gamehandler.cpp
+++ /dev/null
@@ -1,135 +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 "net/tmwa/gamehandler.h"
-
-#include "client.h"
-
-#include "being/localplayer.h"
-
-#include "net/ea/token.h"
-
-#include "net/ea/gamerecv.h"
-
-#include "net/tmwa/loginhandler.h"
-#include "net/tmwa/messageout.h"
-#include "net/tmwa/network.h"
-#include "net/tmwa/protocolout.h"
-
-#include "debug.h"
-
-namespace TmwAthena
-{
-
-extern ServerInfo mapServer;
-
-GameHandler::GameHandler() :
- Ea::GameHandler()
-{
- gameHandler = this;
-}
-
-GameHandler::~GameHandler()
-{
- gameHandler = nullptr;
-}
-
-void GameHandler::mapLoadedEvent() const
-{
- createOutPacket(CMSG_MAP_LOADED);
-}
-
-void GameHandler::connect() const
-{
- if (Network::mInstance == nullptr)
- return;
-
- BLOCK_START("GameHandler::connect")
- Network::mInstance->connect(mapServer);
- const Token &token = static_cast<LoginHandler*>(loginHandler)->getToken();
-
- if (client->getState() == State::CONNECT_GAME)
- {
- // Change the player's ID to the account ID to match what eAthena uses
- if (localPlayer != nullptr)
- {
- Ea::GameRecv::mCharID = localPlayer->getId();
- localPlayer->setId(token.account_ID);
- }
- else
- {
- Ea::GameRecv::mCharID = BeingId_zero;
- }
- }
-
- // Send login infos
- createOutPacket(CMSG_MAP_SERVER_CONNECT);
- outMsg.writeBeingId(token.account_ID, "account id");
- outMsg.writeBeingId(Ea::GameRecv::mCharID, "char id");
- outMsg.writeInt32(token.session_ID1, "session id1");
- outMsg.writeInt32(token.session_ID2, "session id2");
- outMsg.writeInt8(Being::genderToInt(token.sex), "gender");
-
-/*
- if (localPlayer)
- {
- // Change the player's ID to the account ID to match what eAthena uses
- localPlayer->setId(token.account_ID);
- }
-*/
- // We get 4 useless bytes before the real answer comes in (what are these?)
- Network::mInstance->skip(4);
- BLOCK_END("GameHandler::connect")
-}
-
-bool GameHandler::isConnected() const
-{
- if (Network::mInstance == nullptr)
- return false;
- return Network::mInstance->isConnected();
-}
-
-void GameHandler::disconnect() const
-{
- BLOCK_START("GameHandler::disconnect")
- if (Network::mInstance != nullptr)
- Network::mInstance->disconnect();
- BLOCK_END("GameHandler::disconnect")
-}
-
-void GameHandler::quit() const
-{
- createOutPacket(CMSG_CLIENT_QUIT);
-}
-
-void GameHandler::ping(const int tick) const
-{
- createOutPacket(CMSG_MAP_PING);
- outMsg.writeInt32(tick, "tick");
-}
-
-void GameHandler::disconnect2() const
-{
- createOutPacket(CMSG_CLIENT_DISCONNECT);
-}
-
-} // namespace TmwAthena
diff --git a/src/net/tmwa/gamehandler.h b/src/net/tmwa/gamehandler.h
deleted file mode 100644
index 78d30e7e3..000000000
--- a/src/net/tmwa/gamehandler.h
+++ /dev/null
@@ -1,60 +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 NET_TMWA_GAMEHANDLER_H
-#define NET_TMWA_GAMEHANDLER_H
-
-#include "net/ea/gamehandler.h"
-
-namespace TmwAthena
-{
-
-class GameHandler final : public Ea::GameHandler
-{
- public:
- GameHandler();
-
- A_DELETE_COPY(GameHandler)
-
- ~GameHandler();
-
- void connect() const override final;
-
- bool isConnected() const override final A_WARN_UNUSED;
-
- void disconnect() const override final;
-
- void quit() const override final;
-
- void ping(const int tick) const override final;
-
- void disconnect2() const override final;
-
- void mapLoadedEvent() const override final;
-
- bool mustPing() const override final A_WARN_UNUSED
- { return false; }
-};
-
-} // namespace TmwAthena
-
-#endif // NET_TMWA_GAMEHANDLER_H
diff --git a/src/net/tmwa/gamerecv.cpp b/src/net/tmwa/gamerecv.cpp
deleted file mode 100644
index ab13076fb..000000000
--- a/src/net/tmwa/gamerecv.cpp
+++ /dev/null
@@ -1,63 +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 "net/tmwa/gamerecv.h"
-
-#include "client.h"
-#include "logger.h"
-
-#include "being/localplayer.h"
-
-#include "net/messagein.h"
-
-#include "net/tmwa/network.h"
-
-#include "debug.h"
-
-namespace TmwAthena
-{
-
-extern ServerInfo mapServer;
-
-void GameRecv::processMapLogin(Net::MessageIn &msg)
-{
- unsigned char direction;
- uint16_t x, y;
- msg.readInt32("tick");
- msg.readCoordinates(x, y, direction, "position");
- msg.readInt16("unknown?");
- logger->log("Protocol: Player start position: (%d, %d),"
- " Direction: %d", x, y, direction);
-
- mLastHost &= 0xffffff;
-
- Network *const network = Network::mInstance;
- if (network != nullptr)
- network->pauseDispatch();
-
- // Switch now or we'll have problems
- client->setState(State::GAME);
- if (localPlayer != nullptr)
- localPlayer->setTileCoords(x, y);
-}
-
-} // namespace TmwAthena
diff --git a/src/net/tmwa/gamerecv.h b/src/net/tmwa/gamerecv.h
deleted file mode 100644
index eca251fd2..000000000
--- a/src/net/tmwa/gamerecv.h
+++ /dev/null
@@ -1,39 +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 NET_TMWA_GAMERECV_H
-#define NET_TMWA_GAMERECV_H
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-namespace TmwAthena
-{
- namespace GameRecv
- {
- void processMapLogin(Net::MessageIn &msg);
- } // namespace GameRecv
-} // namespace TmwAthena
-
-#endif // NET_TMWA_GAMERECV_H
diff --git a/src/net/tmwa/generalhandler.cpp b/src/net/tmwa/generalhandler.cpp
deleted file mode 100644
index 0cbaf1c4c..000000000
--- a/src/net/tmwa/generalhandler.cpp
+++ /dev/null
@@ -1,245 +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 "net/tmwa/generalhandler.h"
-
-#include "client.h"
-#include "configuration.h"
-
-#include "gui/windows/skilldialog.h"
-#include "gui/windows/socialwindow.h"
-
-#include "gui/widgets/tabs/chat/partytab.h"
-
-#include "net/tmwa/adminhandler.h"
-#include "net/tmwa/beinghandler.h"
-#include "net/tmwa/buysellhandler.h"
-#include "net/tmwa/chathandler.h"
-#include "net/tmwa/charserverhandler.h"
-#include "net/tmwa/gamehandler.h"
-#include "net/tmwa/guildhandler.h"
-#include "net/tmwa/inventoryhandler.h"
-#include "net/tmwa/itemhandler.h"
-#include "net/tmwa/loginhandler.h"
-#include "net/tmwa/network.h"
-#include "net/tmwa/npchandler.h"
-#include "net/tmwa/partyhandler.h"
-#include "net/tmwa/pethandler.h"
-#include "net/tmwa/playerhandler.h"
-#include "net/tmwa/serverfeatures.h"
-#include "net/tmwa/tradehandler.h"
-#include "net/tmwa/skillhandler.h"
-#include "net/tmwa/questhandler.h"
-
-#include "net/tmwa/auctionhandler.h"
-#include "net/tmwa/bankhandler.h"
-#include "net/tmwa/battlegroundhandler.h"
-#include "net/tmwa/buyingstorehandler.h"
-#include "net/tmwa/cashshophandler.h"
-#include "net/tmwa/elementalhandler.h"
-#include "net/tmwa/familyhandler.h"
-#include "net/tmwa/friendshandler.h"
-#include "net/tmwa/homunculushandler.h"
-#include "net/tmwa/mail2handler.h"
-#include "net/tmwa/mailhandler.h"
-#include "net/tmwa/maphandler.h"
-#include "net/tmwa/markethandler.h"
-#include "net/tmwa/mercenaryhandler.h"
-#include "net/tmwa/roulettehandler.h"
-#include "net/tmwa/searchstorehandler.h"
-#include "net/tmwa/vendinghandler.h"
-
-#include "utils/delete2.h"
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-namespace TmwAthena
-{
-
-GeneralHandler::GeneralHandler() :
- mAdminHandler(new AdminHandler),
- mBeingHandler(new BeingHandler(config.getBoolValue("EnableSync"))),
- mBuySellHandler(new BuySellHandler),
- mCharServerHandler(new CharServerHandler),
- mChatHandler(new ChatHandler),
- mGameHandler(new GameHandler),
- mGuildHandler(new GuildHandler),
- mInventoryHandler(new InventoryHandler),
- mItemHandler(new ItemHandler),
- mLoginHandler(new LoginHandler),
- mNpcHandler(new NpcHandler),
- mPartyHandler(new PartyHandler),
- mPetHandler(new PetHandler),
- mPlayerHandler(new PlayerHandler),
- mSkillHandler(new SkillHandler),
- mTradeHandler(new TradeHandler),
- mQuestHandler(new QuestHandler),
- mServerFeatures(new ServerFeatures),
- mAuctionHandler(new AuctionHandler),
- mBankHandler(new BankHandler),
- mBattleGroundHandler(new BattleGroundHandler),
- mBuyingStoreHandler(new BuyingStoreHandler),
- mCashShopHandler(new CashShopHandler),
- mElementalHandler(new ElementalHandler),
- mFamilyHandler(new FamilyHandler),
- mFriendsHandler(new FriendsHandler),
- mHomunculusHandler(new HomunculusHandler),
- mMail2Handler(new Mail2Handler),
- mMailHandler(new MailHandler),
- mMapHandler(new MapHandler),
- mMarketHandler(new MarketHandler),
- mMercenaryHandler(new MercenaryHandler),
- mRouletteHandler(new RouletteHandler),
- mSearchStoreHandler(new SearchStoreHandler),
- mVendingHandler(new VendingHandler)
-{
- generalHandler = this;
-}
-
-GeneralHandler::~GeneralHandler()
-{
- delete2(Network::mInstance);
-
- delete2(mAdminHandler);
- delete2(mBeingHandler);
- delete2(mBuySellHandler);
- delete2(mCharServerHandler);
- delete2(mChatHandler);
- delete2(mGameHandler);
- delete2(mGuildHandler);
- delete2(mInventoryHandler);
- delete2(mItemHandler);
- delete2(mLoginHandler);
- delete2(mNpcHandler);
- delete2(mPartyHandler);
- delete2(mPetHandler);
- delete2(mPlayerHandler);
- delete2(mSkillHandler);
- delete2(mTradeHandler);
- delete2(mQuestHandler);
- delete2(mServerFeatures);
- delete2(mAuctionHandler);
- delete2(mBankHandler);
- delete2(mBattleGroundHandler);
- delete2(mBuyingStoreHandler);
- delete2(mCashShopHandler);
- delete2(mElementalHandler);
- delete2(mFamilyHandler);
- delete2(mFriendsHandler);
- delete2(mHomunculusHandler);
- delete2(mMail2Handler);
- delete2(mMailHandler);
- delete2(mMapHandler);
- delete2(mMarketHandler);
- delete2(mMercenaryHandler);
- delete2(mRouletteHandler);
- delete2(mSearchStoreHandler);
- delete2(mVendingHandler);
-}
-
-void GeneralHandler::load() const
-{
- new Network;
- Network::mInstance->registerHandlers();
-}
-
-void GeneralHandler::reload() const
-{
- if (Network::mInstance != nullptr)
- Network::mInstance->disconnect();
-
- static_cast<LoginHandler*>(mLoginHandler)->clearWorlds();
- const CharServerHandler *const charHandler =
- static_cast<CharServerHandler*>(mCharServerHandler);
- charHandler->setCharCreateDialog(nullptr);
- charHandler->setCharSelectDialog(nullptr);
- PartyHandler::reload();
-}
-
-void GeneralHandler::reloadPartially() const
-{
- PartyHandler::reload();
-}
-
-void GeneralHandler::unload() const
-{
- clearHandlers();
-}
-
-void GeneralHandler::flushSend() const
-{
- if (Network::mInstance == nullptr)
- return;
-
- Network::mInstance->flush();
-}
-
-void GeneralHandler::flushNetwork() const
-{
- if (Network::mInstance == nullptr)
- return;
-
- BLOCK_START("GeneralHandler::flushNetwork 1")
- Network::mInstance->flush();
- BLOCK_END("GeneralHandler::flushNetwork 1")
- Network::mInstance->dispatchMessages();
-
- BLOCK_START("GeneralHandler::flushNetwork 3")
- if (Network::mInstance->getState() == Network::NET_ERROR)
- {
- if (!Network::mInstance->getError().empty())
- {
- errorMessage = Network::mInstance->getError();
- }
- else
- {
- // TRANSLATORS: error message
- errorMessage = _("Got disconnected from server!");
- }
-
- client->setState(State::ERROR);
- }
- BLOCK_END("GeneralHandler::flushNetwork 3")
-}
-
-void GeneralHandler::clearHandlers() const
-{
- if (Network::mInstance != nullptr)
- Network::mInstance->clearHandlers();
-}
-
-void GeneralHandler::gameStarted() const
-{
- if (skillDialog != nullptr)
- skillDialog->loadSkills();
-}
-
-void GeneralHandler::gameEnded() const
-{
- if (socialWindow != nullptr)
- socialWindow->removeTab(Ea::taParty);
-
- delete2(partyTab);
-}
-
-} // namespace TmwAthena
diff --git a/src/net/tmwa/generalhandler.h b/src/net/tmwa/generalhandler.h
deleted file mode 100644
index 818cb4be3..000000000
--- a/src/net/tmwa/generalhandler.h
+++ /dev/null
@@ -1,133 +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 NET_TMWA_GENERALHANDLER_H
-#define NET_TMWA_GENERALHANDLER_H
-
-#include "net/generalhandler.h"
-
-namespace TmwAthena
-{
-class AdminHandler;
-class BeingHandler;
-class BuySellHandler;
-class CharServerHandler;
-class ChatHandler;
-class GameHandler;
-class GuildHandler;
-class InventoryHandler;
-class ItemHandler;
-class LoginHandler;
-class NpcHandler;
-class PartyHandler;
-class PetHandler;
-class PlayerHandler;
-class SkillHandler;
-class TradeHandler;
-class QuestHandler;
-class ServerFeatures;
-class AuctionHandler;
-class BankHandler;
-class BattleGroundHandler;
-class BuyingStoreHandler;
-class CashShopHandler;
-class ElementalHandler;
-class FamilyHandler;
-class FriendsHandler;
-class HomunculusHandler;
-class Mail2Handler;
-class MailHandler;
-class MapHandler;
-class MarketHandler;
-class MercenaryHandler;
-class RouletteHandler;
-class SearchStoreHandler;
-class VendingHandler;
-
-class GeneralHandler final : public Net::GeneralHandler
-{
- public:
- GeneralHandler();
-
- A_DELETE_COPY(GeneralHandler)
-
- ~GeneralHandler();
-
- void load() const override final;
-
- void reload() const override final;
-
- void unload() const override final;
-
- void flushNetwork() const override final;
-
- void flushSend() const override final;
-
- void clearHandlers() const override final;
-
- void reloadPartially() const override final;
-
- void gameStarted() const override final;
-
- void gameEnded() const override final;
-
- protected:
- AdminHandler *mAdminHandler;
- BeingHandler *mBeingHandler;
- BuySellHandler *mBuySellHandler;
- CharServerHandler *mCharServerHandler;
- ChatHandler *mChatHandler;
- GameHandler *mGameHandler;
- GuildHandler *mGuildHandler;
- InventoryHandler *mInventoryHandler;
- ItemHandler *mItemHandler;
- LoginHandler *mLoginHandler;
- NpcHandler *mNpcHandler;
- PartyHandler *mPartyHandler;
- PetHandler *mPetHandler;
- PlayerHandler *mPlayerHandler;
- SkillHandler *mSkillHandler;
- TradeHandler *mTradeHandler;
- QuestHandler *mQuestHandler;
- ServerFeatures *mServerFeatures;
- AuctionHandler *mAuctionHandler;
- BankHandler *mBankHandler;
- BattleGroundHandler *mBattleGroundHandler;
- BuyingStoreHandler *mBuyingStoreHandler;
- CashShopHandler *mCashShopHandler;
- ElementalHandler *mElementalHandler;
- FamilyHandler *mFamilyHandler;
- FriendsHandler *mFriendsHandler;
- HomunculusHandler *mHomunculusHandler;
- Mail2Handler *mMail2Handler;
- MailHandler *mMailHandler;
- MapHandler *mMapHandler;
- MarketHandler *mMarketHandler;
- MercenaryHandler *mMercenaryHandler;
- RouletteHandler *mRouletteHandler;
- SearchStoreHandler *mSearchStoreHandler;
- VendingHandler *mVendingHandler;
-};
-
-} // namespace TmwAthena
-
-#endif // NET_TMWA_GENERALHANDLER_H
diff --git a/src/net/tmwa/generalrecv.cpp b/src/net/tmwa/generalrecv.cpp
deleted file mode 100644
index 0bc1c6a4c..000000000
--- a/src/net/tmwa/generalrecv.cpp
+++ /dev/null
@@ -1,85 +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 "net/tmwa/generalrecv.h"
-
-#include "client.h"
-#include "logger.h"
-
-#include "net/messagein.h"
-
-#include "utils/cast.h"
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-namespace TmwAthena
-{
-
-ServerInfo charServer;
-ServerInfo mapServer;
-
-void GeneralRecv::processConnectionProblem(Net::MessageIn &msg)
-{
- const uint8_t code = msg.readUInt8("flag");
- logger->log("Connection problem: %u", CAST_U32(code));
-
- switch (code)
- {
- case 0:
- // TRANSLATORS: error message
- errorMessage = _("Authentication failed.");
- break;
- case 1:
- // TRANSLATORS: error message
- errorMessage = _("No servers available.");
- break;
- case 2:
- if (client->getState() == State::GAME)
- {
- // TRANSLATORS: error message
- errorMessage = _("Someone else is trying to use this "
- "account.");
- }
- else
- {
- // TRANSLATORS: error message
- errorMessage = _("This account is already logged in.");
- }
- break;
- case 3:
- // TRANSLATORS: error message
- errorMessage = _("Speed hack detected.");
- break;
- case 8:
- // TRANSLATORS: error message
- errorMessage = _("Duplicated login.");
- break;
- default:
- // TRANSLATORS: error message
- errorMessage = _("Unknown connection error.");
- break;
- }
- client->setState(State::ERROR);
-}
-
-} // namespace TmwAthena
diff --git a/src/net/tmwa/generalrecv.h b/src/net/tmwa/generalrecv.h
deleted file mode 100644
index 92f0e71f8..000000000
--- a/src/net/tmwa/generalrecv.h
+++ /dev/null
@@ -1,39 +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 NET_TMWA_GENERALRECV_H
-#define NET_TMWA_GENERALRECV_H
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-namespace TmwAthena
-{
- namespace GeneralRecv
- {
- void processConnectionProblem(Net::MessageIn &msg);
- } // namespace GeneralRecv
-} // namespace TmwAthena
-
-#endif // NET_TMWA_GENERALRECV_H
diff --git a/src/net/tmwa/guildhandler.cpp b/src/net/tmwa/guildhandler.cpp
deleted file mode 100644
index 5b41ef49a..000000000
--- a/src/net/tmwa/guildhandler.cpp
+++ /dev/null
@@ -1,142 +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 "net/tmwa/guildhandler.h"
-
-#include "debug.h"
-
-namespace TmwAthena
-{
-
-GuildHandler::GuildHandler() :
- Net::GuildHandler()
-{
- guildHandler = this;
-}
-
-GuildHandler::~GuildHandler()
-{
- guildHandler = nullptr;
-}
-
-void GuildHandler::clear() const
-{
-}
-
-ChatTab *GuildHandler::getTab() const
-{
- return nullptr;
-}
-
-void GuildHandler::create(const std::string &name A_UNUSED) const
-{
-}
-
-void GuildHandler::invite(const std::string &name A_UNUSED) const
-{
-}
-
-void GuildHandler::invite(const Being *const being A_UNUSED) const
-{
-}
-
-void GuildHandler::inviteResponse(const int guildId A_UNUSED,
- const bool response A_UNUSED) const
-{
-}
-
-void GuildHandler::leave(const int guildId A_UNUSED) const
-{
-}
-
-void GuildHandler::kick(const GuildMember *restrict const member A_UNUSED,
- const std::string &restrict reason A_UNUSED) const
-{
-}
-
-void GuildHandler::chat(const std::string &text A_UNUSED) const
-{
-}
-
-void GuildHandler::memberList() const
-{
-}
-
-void GuildHandler::info() const
-{
-}
-
-void GuildHandler::changeMemberPostion(const GuildMember *const member
- A_UNUSED,
- const int level A_UNUSED) const
-{
-}
-
-void GuildHandler::changeNotice(const int guildId A_UNUSED,
- const std::string &restrict msg1 A_UNUSED,
- const std::string &restrict msg2 A_UNUSED)
- const
-{
-}
-
-void GuildHandler::checkMaster() const
-{
-}
-
-void GuildHandler::requestAlliance(const Being *const being A_UNUSED) const
-{
-}
-
-void GuildHandler::requestAllianceResponse(const int beingId A_UNUSED,
- const bool accept A_UNUSED) const
-{
-}
-
-void GuildHandler::endAlliance(const int guildId A_UNUSED,
- const int flag A_UNUSED) const
-{
-}
-
-void GuildHandler::changePostionInfo(const int posId A_UNUSED,
- const int mode A_UNUSED,
- const int ranking A_UNUSED,
- const int payRate A_UNUSED,
- const std::string &name A_UNUSED) const
-{
-}
-
-void GuildHandler::requestOpposition(const Being *const being A_UNUSED) const
-{
-}
-
-void GuildHandler::breakGuild(const std::string &name A_UNUSED) const
-{
-}
-
-void GuildHandler::changeEmblem(std::string emblem A_UNUSED) const
-{
-}
-
-void GuildHandler::requestEmblem(const int guildId A_UNUSED) const
-{
-}
-
-} // namespace TmwAthena
diff --git a/src/net/tmwa/guildhandler.h b/src/net/tmwa/guildhandler.h
deleted file mode 100644
index dcb9d6b7c..000000000
--- a/src/net/tmwa/guildhandler.h
+++ /dev/null
@@ -1,102 +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 NET_TMWA_GUILDHANDLER_H
-#define NET_TMWA_GUILDHANDLER_H
-
-#include "net/guildhandler.h"
-
-namespace TmwAthena
-{
-
-class GuildHandler final : public Net::GuildHandler
-{
- public:
- GuildHandler();
-
- A_DELETE_COPY(GuildHandler)
-
- ~GuildHandler();
-
- void clear() const override final;
-
- ChatTab *getTab() const override final;
-
- void create(const std::string &name) const override final;
-
- void invite(const std::string &name) const override final;
-
- void invite(const Being *const being) const override final;
-
- void inviteResponse(const int guildId,
- const bool response) const override final;
-
- void leave(const int guildId) const override final;
-
- void kick(const GuildMember *restrict const member,
- const std::string &restrict reason) const override final;
-
- void chat(const std::string &text) const override final;
-
- void memberList() const override final;
-
- void info() const override final;
-
- void changeMemberPostion(const GuildMember *const member,
- const int level) const override final;
-
- void changeNotice(const int guildId,
- const std::string &restrict msg1,
- const std::string &restrict msg2)
- const override final;
-
- void checkMaster() const override final;
-
- void requestAlliance(const Being *const being) const override final
- A_CONST;
-
- void requestAllianceResponse(const int beingId,
- const bool accept) const override final
- A_CONST;
-
- void endAlliance(const int guildId,
- const int flag) const override final A_CONST;
-
- void changePostionInfo(const int posId,
- const int mode,
- const int ranking,
- const int payRate,
- const std::string &name) const override final
- A_CONST;
-
- void requestOpposition(const Being *const being) const override final
- A_CONST;
-
- void breakGuild(const std::string &name) const override final A_CONST;
-
- void changeEmblem(std::string emblem) const override final A_CONST;
-
- void requestEmblem(const int guildId) const override final A_CONST;
-};
-
-} // namespace TmwAthena
-
-#endif // NET_TMWA_GUILDHANDLER_H
diff --git a/src/net/tmwa/guildmanager.cpp b/src/net/tmwa/guildmanager.cpp
deleted file mode 100644
index 5484f1b51..000000000
--- a/src/net/tmwa/guildmanager.cpp
+++ /dev/null
@@ -1,543 +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 TMWA_SUPPORT
-#include "net/tmwa/guildmanager.h"
-
-#include "actormanager.h"
-#include "client.h"
-#include "configuration.h"
-#include "guild.h"
-#include "notifymanager.h"
-
-#include "being/localplayer.h"
-
-#include "enums/resources/notifytypes.h"
-
-#include "gui/windows/chatwindow.h"
-#include "gui/windows/socialwindow.h"
-
-#include "gui/widgets/tabs/chat/emulateguildtab.h"
-
-#include "net/chathandler.h"
-#include "net/packetlimiter.h"
-
-#include "utils/delete2.h"
-#include "utils/timer.h"
-
-#include "debug.h"
-
-GuildManager *guildManager = nullptr;
-
-static const int requestTimeout = 5;
-
-bool GuildManager::mEnableGuildBot = false;
-
-GuildManager::GuildManager() :
- mGotInfo(false),
- mGotName(false),
- mSentInfoRequest(false),
- mSentNameRequest(false),
- mHavePower(false),
- mTempList(),
- mTab(nullptr),
- mRequest(false),
- mRequestTime(cur_time + 3),
- mGotOnlineInfo(false)
-{
-}
-
-GuildManager::~GuildManager()
-{
- delete2(mTab);
-}
-
-void GuildManager::init()
-{
- int val = serverConfig.getValue("enableGuildBot", -1);
- if (val == -1)
- {
- if (Client::isTmw())
- val = 1;
- else
- val = 0;
- serverConfig.setValue("enableGuildBot", val);
- }
- mEnableGuildBot = (val != 0);
- if (mEnableGuildBot)
- {
- if (guildManager == nullptr)
- guildManager = new GuildManager;
- else
- guildManager->reload();
- }
- else if (guildManager != nullptr)
- {
- delete2(guildManager);
- }
-}
-
-void GuildManager::reload()
-{
- mGotInfo = false;
- mGotName = false;
- mHavePower = false;
- mRequest = false;
- mSentNameRequest = false;
- mSentInfoRequest = false;
- mGotOnlineInfo = false;
- mRequestTime = 0;
- mTempList.clear();
-
- if (socialWindow != nullptr)
- {
- Guild *const guild = Guild::getGuild(1);
- if ((guild != nullptr) && (socialWindow != nullptr))
- socialWindow->removeTab(guild);
- }
- delete2(mTab);
-}
-
-void GuildManager::send(const std::string &msg)
-{
- chatHandler->privateMessage("guild", msg);
-}
-
-void GuildManager::chat(const std::string &msg)
-{
- if ((localPlayer == nullptr) || (mTab == nullptr))
- return;
-
- chatHandler->privateMessage("guild", msg);
- mTab->chatLog(localPlayer->getName(), msg);
-}
-
-void GuildManager::getNames(StringVect &names) const
-{
- const Guild *const guild = createGuild();
- if (guild != nullptr)
- guild->getNames(names);
-}
-
-void GuildManager::requestGuildInfo()
-{
- if (mRequest && mRequestTime + 15 < cur_time)
- return;
-
- if (!mGotName && !mSentNameRequest)
- {
- if (!PacketLimiter::limitPackets(PacketType::PACKET_WHISPER))
- return;
- send("!info " + toString(tick_time));
- mRequest = true;
- mSentNameRequest = true;
- mRequestTime = cur_time + requestTimeout;
- }
- else if (!mGotInfo && !mSentInfoRequest && !mSentNameRequest)
- {
- if (!PacketLimiter::limitPackets(PacketType::PACKET_WHISPER))
- return;
- send("!getonlineinfo " + toString(tick_time));
- mRequest = true;
- mSentInfoRequest = true;
- mRequestTime = cur_time + requestTimeout;
- }
-}
-
-void GuildManager::slowLogic()
-{
- if (!mGotOnlineInfo && mGotName && mRequestTime < cur_time)
- {
- if (!PacketLimiter::limitPackets(PacketType::PACKET_WHISPER))
- return;
- send("!getonlineinfo " + toString(tick_time));
- mRequest = true;
- mSentInfoRequest = true;
- mRequestTime = cur_time + requestTimeout;
- }
-}
-
-void GuildManager::updateList()
-{
- Guild *const guild = Guild::getGuild(1);
- if (guild != nullptr)
- {
- guild->setServerGuild(false);
- StringVectCIter it = mTempList.begin();
- const StringVectCIter it_end = mTempList.end();
- int i = 0;
- while (it != it_end)
- {
- std::string name = *it;
- const size_t sz = name.size();
- if (sz > 1)
- {
- const int status = atoi(name.substr(sz - 1).c_str());
-
- name = name.substr(0, sz - 1);
- GuildMember *const m = guild->addMember(
- fromInt(i, BeingId), 0, name);
- if (m != nullptr)
- {
- m->setOnline((status & 1) != 0);
- m->setGender(Gender::UNSPECIFIED);
- if ((status & 2) != 0)
- m->setPos(10);
- else
- m->setPos(0);
- if (localPlayer != nullptr &&
- name == localPlayer->getName())
- {
- mHavePower = ((status & 2) != 0);
- m->setOnline(true);
- }
- }
- }
- ++ it;
- i ++;
- }
- guild->sort();
- createTab(guild);
- if (actorManager != nullptr)
- {
- actorManager->updatePlayerGuild();
- actorManager->updatePlayerColors();
- }
- if (socialWindow != nullptr)
- socialWindow->updateGuildCounter();
- }
- mTempList.clear();
- mSentInfoRequest = false;
- mGotInfo = true;
-}
-
-void GuildManager::createTab(Guild *const guild)
-{
- if (mTab == nullptr)
- {
- mTab = new EmulateGuildTab(chatWindow);
- if (config.getBoolValue("showChatHistory"))
- mTab->loadFromLogFile("#Guild");
- if (localPlayer != nullptr)
- localPlayer->addGuild(guild);
- }
-}
-
-Guild *GuildManager::createGuild() const
-{
- Guild *const guild = Guild::getGuild(1);
- if (guild == nullptr)
- return nullptr;
-
- guild->setServerGuild(false);
- return guild;
-}
-
-bool GuildManager::processGuildMessage(const std::string &msg)
-{
- const bool res = process(msg);
-
- if (!mRequest)
- requestGuildInfo();
-
- return res;
-}
-
-bool GuildManager::process(std::string msg)
-{
- if (msg.size() > 4 && msg[0] == '#' && msg[1] == '#')
- msg = msg.substr(3);
-
- const bool haveNick = (msg.find(": ") != std::string::npos);
-
- if (!haveNick && findCutLast(msg, " is now Offline."))
- {
- Guild *const guild = createGuild();
- if (guild == nullptr)
- return false;
- if (msg.size() < 4)
- return false;
- if (msg[0] == '#' && msg[1] == '#')
- msg = msg.substr(3);
-
- GuildMember *const m = guild->addMember(msg);
- if (m != nullptr)
- m->setOnline(false);
- guild->sort();
- mRequest = false;
- if (mTab != nullptr)
- mTab->showOnline(msg, Online_false);
- if (socialWindow != nullptr)
- socialWindow->updateGuildCounter();
- return true;
- }
- else if (!haveNick && findCutLast(msg, " is now Online."))
- {
- Guild *const guild = createGuild();
- if (guild == nullptr)
- return false;
- if (msg.size() < 4)
- return false;
- if (msg[0] == '#' && msg[1] == '#')
- msg = msg.substr(3);
- GuildMember *const m = guild->addMember(msg);
- if (m != nullptr)
- m->setOnline(true);
- guild->sort();
- mRequest = false;
- if (mTab != nullptr)
- mTab->showOnline(msg, Online_true);
- if (socialWindow != nullptr)
- socialWindow->updateGuildCounter();
- return true;
- }
- else if (findCutFirst(msg, "Welcome to the "))
- {
- Guild *const guild = createGuild();
- if (guild == nullptr)
- return false;
-// logger->log("welcome message: %s", msg.c_str());
- const size_t pos = msg.find("! (");
- if (pos == std::string::npos)
- return false;
- msg = msg.substr(0, pos);
- guild->setName(msg);
- if (localPlayer != nullptr)
- localPlayer->setGuildName(msg);
- mGotName = true;
- mSentNameRequest = false;
- mRequest = false;
- return true;
- }
- else if (findCutFirst(msg, "Player name: "))
- {
- Guild *const guild = createGuild();
- if (guild == nullptr)
- return false;
- size_t pos = msg.find("Access Level: ");
- if (pos == std::string::npos)
- return false;
-
- msg = msg.substr(pos);
- if (!findCutFirst(msg, "Access Level: "))
- return false;
-
- pos = msg.find(", Guild:");
- if (pos == std::string::npos)
- return false;
-
- const int level = atoi(msg.substr(0, pos).c_str());
- if (level >= 10)
- mHavePower = true;
- else
- mHavePower = false;
-
- msg = msg.substr(pos + strlen(", Guild:"));
- pos = msg.find(", No. Of Online Players: ");
- if (pos == std::string::npos)
- return false;
-
- msg = msg.substr(0, pos);
-// logger->log("guild name: %s", msg.c_str());
-
- guild->setName(msg);
- if (localPlayer != nullptr)
- localPlayer->setGuildName(msg);
- mGotName = true;
- mSentNameRequest = false;
- mRequest = false;
- return true;
- }
- else if (findCutFirst(msg, "OL#"))
- {
-// logger->log("OL");
- mTempList.clear();
- splitToStringVector(mTempList, msg, '#');
- if (msg.empty() || msg[msg.size() - 1] != '#')
- updateList();
- mRequest = false;
- mGotOnlineInfo = true;
- return true;
- }
- else if (findCutFirst(msg, "oL#"))
- {
-// logger->log("oL");
- splitToStringVector(mTempList, msg, '#');
- if (msg.empty() || msg[msg.size() - 1] != '#')
- updateList();
- mRequest = false;
- mGotOnlineInfo = true;
- return true;
- }
- else if (msg == "You are currently not in a guild. For more information "
- "or to discuss the possibility of adding you own guild "
- "please contact Jero.")
- {
- mRequest = true;
- return true;
- }
- else if (findCutFirst(msg, "You have been invited to the ")
- && findCutLast(msg, " guild chat. If you would like to accept "
- "this invitation please reply \"yes\" and if not then \"no\" ."))
- {
- if (socialWindow != nullptr)
- socialWindow->showGuildInvite(msg, 1, "");
- return true;
- }
- else if (!haveNick && (findCutLast(msg, " has been removed "
- "from the Guild.") || findCutLast(msg, " has left the Guild.")))
- {
- Guild *const guild = createGuild();
- if (guild == nullptr)
- return false;
- if (msg.size() < 4)
- return false;
- if (msg[0] == '#' && msg[1] == '#')
- msg = msg.substr(3);
-
- if (actorManager != nullptr)
- {
- Being *const b = actorManager->findBeingByName(
- msg, ActorType::Player);
-
- if (b != nullptr)
- {
- b->clearGuilds();
- b->setGuildName("");
- b->updateColors();
- }
- }
-
- guild->removeMember(msg);
- return true;
- }
- else if (msg == "You have been removed from the Guild" ||
- msg == "You have left the Guild")
- {
- return afterRemove();
- }
- Guild *const guild = createGuild();
- if (guild == nullptr)
- return false;
- if (mTab == nullptr)
- {
- createTab(guild);
- }
- if (mTab != nullptr)
- {
- const size_t pos = msg.find(": ", 0);
- if (pos != std::string::npos)
- {
- const std::string sender_name = msg.substr(0, pos);
- if (guild->getMember(sender_name) == nullptr)
- {
- mTab->chatLog(msg, ChatMsgType::BY_SERVER);
- return true;
- }
-
- msg.erase(0, pos + 2);
- if (msg.size() > 3 && msg[0] == '#' && msg[1] == '#')
- msg.erase(0, 3);
-
- trim(msg);
- mTab->chatLog(sender_name, msg);
- }
- else
- {
- mTab->chatLog(msg, ChatMsgType::BY_SERVER);
- }
- return true;
- }
- return false;
-}
-
-void GuildManager::kick(const std::string &msg)
-{
- send("!remove " + msg);
-}
-
-void GuildManager::invite(const std::string &msg)
-{
- send("!invite " + msg);
-}
-
-void GuildManager::leave()
-{
- send("!leave");
-}
-
-void GuildManager::notice(const std::string &msg)
-{
- if (msg.empty())
- send("!removemotd");
- else
- send("!setmotd " + msg);
-}
-
-void GuildManager::clear()
-{
- if (socialWindow != nullptr)
- {
- Guild *const guild = Guild::getGuild(1);
- if (guild != nullptr)
- socialWindow->removeTab(guild);
- }
-}
-
-void GuildManager::inviteResponse(const bool response)
-{
- if (response)
- send("yes");
- else
- send("no");
-}
-
-bool GuildManager::afterRemove()
-{
- Guild *const guild = createGuild();
- if (guild == nullptr)
- return false;
- guild->removeFromMembers();
- guild->clearMembers();
- if (localPlayer != nullptr)
- {
- localPlayer->setGuildName("");
- localPlayer->clearGuilds();
- }
- NotifyManager::notify(NotifyTypes::GUILD_LEFT);
- delete2(mTab);
-
- if (socialWindow != nullptr)
- socialWindow->removeTab(guild);
- if (actorManager != nullptr)
- {
- actorManager->updatePlayerGuild();
- actorManager->updatePlayerColors();
- }
- reload();
- return true;
-}
-
-ChatTab *GuildManager::getTab()
-{
- return mTab;
-}
-
-#endif // TMWA_SUPPORT
diff --git a/src/net/tmwa/guildmanager.h b/src/net/tmwa/guildmanager.h
deleted file mode 100644
index 67f88927d..000000000
--- a/src/net/tmwa/guildmanager.h
+++ /dev/null
@@ -1,106 +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 NET_TMWA_GUILDMANAGER_H
-#define NET_TMWA_GUILDMANAGER_H
-
-#ifdef TMWA_SUPPORT
-
-#include "utils/stringvector.h"
-
-#include "localconsts.h"
-
-class ChatTab;
-class Guild;
-class EmulateGuildTab;
-
-class GuildManager final
-{
- public:
- GuildManager();
-
- A_DELETE_COPY(GuildManager)
-
- ~GuildManager();
-
- static void init();
-
- void chat(const std::string &msg);
-
- static void send(const std::string &msg);
-
- void getNames(StringVect &names) const;
-
- void requestGuildInfo();
-
- void updateList();
-
- static bool getEnableGuildBot() A_WARN_UNUSED
- { return mEnableGuildBot; }
-
- static void kick(const std::string &msg);
-
- static void invite(const std::string &msg);
-
- static void leave();
-
- static void notice(const std::string &msg);
-
- void createTab(Guild *const guild);
-
- Guild *createGuild() const A_WARN_UNUSED;
-
- static void clear();
-
- void reload();
-
- static void inviteResponse(const bool response);
-
- bool afterRemove();
-
- void slowLogic();
-
- bool havePower() const A_WARN_UNUSED
- { return mHavePower; }
-
- ChatTab *getTab();
-
- bool processGuildMessage(const std::string &msg);
-
- private:
- bool process(std::string msg);
-
- static bool mEnableGuildBot;
- bool mGotInfo;
- bool mGotName;
- bool mSentInfoRequest;
- bool mSentNameRequest;
- bool mHavePower;
- StringVect mTempList;
- EmulateGuildTab *mTab;
- bool mRequest;
- time_t mRequestTime;
- bool mGotOnlineInfo;
-};
-
-extern GuildManager *guildManager;
-
-#endif // TMWA_SUPPORT
-#endif // NET_TMWA_GUILDMANAGER_H
diff --git a/src/net/tmwa/homunculushandler.cpp b/src/net/tmwa/homunculushandler.cpp
deleted file mode 100644
index 0d1bb2e62..000000000
--- a/src/net/tmwa/homunculushandler.cpp
+++ /dev/null
@@ -1,75 +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 "net/tmwa/homunculushandler.h"
-
-#include "debug.h"
-
-namespace TmwAthena
-{
-
-HomunculusHandler::HomunculusHandler()
-{
- homunculusHandler = this;
-}
-
-HomunculusHandler::~HomunculusHandler()
-{
- homunculusHandler = nullptr;
-}
-
-void HomunculusHandler::setName(const std::string &name A_UNUSED) const
-{
-}
-
-void HomunculusHandler::moveToMaster() const
-{
-}
-
-void HomunculusHandler::move(const int x A_UNUSED, const int y A_UNUSED) const
-{
-}
-
-void HomunculusHandler::attack(const BeingId targetId A_UNUSED,
- const Keep keep A_UNUSED) const
-{
-}
-
-void HomunculusHandler::feed() const
-{
-}
-
-void HomunculusHandler::fire() const
-{
-}
-
-void HomunculusHandler::talk(const std::string &restrict text A_UNUSED) const
-{
-}
-
-void HomunculusHandler::emote(const uint8_t emoteId A_UNUSED) const
-{
-}
-
-void HomunculusHandler::setDirection(const unsigned char type A_UNUSED) const
-{
-}
-
-} // namespace TmwAthena
diff --git a/src/net/tmwa/homunculushandler.h b/src/net/tmwa/homunculushandler.h
deleted file mode 100644
index bd00927fa..000000000
--- a/src/net/tmwa/homunculushandler.h
+++ /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/>.
- */
-
-#ifndef NET_TMWA_HOMUNCULUSHANDLER_H
-#define NET_TMWA_HOMUNCULUSHANDLER_H
-
-#include "net/homunculushandler.h"
-
-namespace TmwAthena
-{
-
-class HomunculusHandler final : public Net::HomunculusHandler
-{
- public:
- HomunculusHandler();
-
- A_DELETE_COPY(HomunculusHandler)
-
- ~HomunculusHandler();
-
- void setName(const std::string &name) const override final A_CONST;
-
- void moveToMaster() const override final A_CONST;
-
- void move(const int x, const int y) const override final A_CONST;
-
- void attack(const BeingId targetId,
- const Keep keep) const override final A_CONST;
-
- void feed() const override final A_CONST;
-
- void fire() const override final A_CONST;
-
- void talk(const std::string &restrict text) const override final
- A_CONST;
-
- void emote(const uint8_t emoteId) const override final A_CONST;
-
- void setDirection(const unsigned char type) const override final
- A_CONST;
-};
-
-} // namespace TmwAthena
-
-#endif // NET_TMWA_HOMUNCULUSHANDLER_H
diff --git a/src/net/tmwa/inventoryhandler.cpp b/src/net/tmwa/inventoryhandler.cpp
deleted file mode 100644
index 7afbf746e..000000000
--- a/src/net/tmwa/inventoryhandler.cpp
+++ /dev/null
@@ -1,196 +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 "net/tmwa/inventoryhandler.h"
-
-#include "const/net/inventory.h"
-
-#include "enums/equipslot.h"
-
-#include "net/tmwa/messageout.h"
-#include "net/tmwa/protocolout.h"
-
-#include "resources/item/item.h"
-
-#include "debug.h"
-
-// missing EQUIP_RING1_SLOT
-const EquipSlot::Type EQUIP_CONVERT[] =
-{
- EquipSlot::PROJECTILE_SLOT, // 0 0
- EquipSlot::FEET_SLOT, // 1 SPRITE_HAIR
- EquipSlot::LEGS_SLOT, // 2 SPRITE_WEAPON
- EquipSlot::TORSO_SLOT, // 3 SPRITE_HEAD_BOTTOM
- EquipSlot::PROJECTILE_SLOT, // 4 0
- EquipSlot::NECK_SLOT, // 5 SPRITE_RING
- EquipSlot::PROJECTILE_SLOT, // 6 0
- EquipSlot::HEAD_SLOT, // 7 SPRITE_CLOTHES_COLOR
- EquipSlot::RING2_SLOT, // 8 0
- EquipSlot::GLOVES_SLOT, // 9 SPRITE_SHOES
- EquipSlot::FIGHT1_SLOT, // 10 SPRITE_BODY
- EquipSlot::FIGHT2_SLOT, // 11 SPRITE_FLOOR
- EquipSlot::EVOL_RING1_SLOT, // 12 SPRITE_ROBE
- EquipSlot::EVOL_RING2_SLOT, // 13 SPRITE_EVOL2
-};
-
-namespace TmwAthena
-{
-
-InventoryHandler::InventoryHandler() :
- Ea::InventoryHandler()
-{
- inventoryHandler = this;
-}
-
-InventoryHandler::~InventoryHandler()
-{
- inventoryHandler = nullptr;
-}
-
-void InventoryHandler::equipItem(const Item *const item) const
-{
- if (item == nullptr)
- return;
-
- createOutPacket(CMSG_PLAYER_EQUIP);
- outMsg.writeInt16(CAST_S16(
- item->getInvIndex() + INVENTORY_OFFSET), "index");
- outMsg.writeInt16(0, "unused");
-}
-
-void InventoryHandler::unequipItem(const Item *const item) const
-{
- if (item == nullptr)
- return;
-
- createOutPacket(CMSG_PLAYER_UNEQUIP);
- outMsg.writeInt16(CAST_S16(
- item->getInvIndex() + INVENTORY_OFFSET), "index");
-}
-
-void InventoryHandler::useItem(const Item *const item) const
-{
- if (item == nullptr)
- return;
-
- createOutPacket(CMSG_PLAYER_INVENTORY_USE);
- outMsg.writeInt16(CAST_S16(
- item->getInvIndex() + INVENTORY_OFFSET), "index");
- outMsg.writeInt32(item->getId(), "item id");
-}
-
-void InventoryHandler::useItem(const Item *const item,
- const int16_t useType A_UNUSED) const
-{
- if (item == nullptr)
- return;
-
- createOutPacket(CMSG_PLAYER_INVENTORY_USE);
- outMsg.writeInt16(CAST_S16(
- item->getInvIndex() + INVENTORY_OFFSET), "index");
- outMsg.writeInt32(item->getId(), "item id");
-}
-
-void InventoryHandler::dropItem(const Item *const item, const int amount) const
-{
- if (item == nullptr)
- return;
-
- createOutPacket(CMSG_PLAYER_INVENTORY_DROP);
- outMsg.writeInt16(CAST_S16(
- item->getInvIndex() + INVENTORY_OFFSET), "index");
- outMsg.writeInt16(CAST_S16(amount), "amount");
-}
-
-void InventoryHandler::closeStorage() const
-{
- createOutPacket(CMSG_CLOSE_STORAGE);
-}
-
-void InventoryHandler::moveItem2(const InventoryTypeT source,
- const int slot,
- const int amount,
- const InventoryTypeT destination) const
-{
- if (source == InventoryType::Inventory &&
- destination == InventoryType::Storage)
- {
- createOutPacket(CMSG_MOVE_TO_STORAGE);
- outMsg.writeInt16(CAST_S16(slot + INVENTORY_OFFSET),
- "index");
- outMsg.writeInt32(amount, "amount");
- }
- else if (source == InventoryType::Storage &&
- destination == InventoryType::Inventory)
- {
- createOutPacket(CMSG_MOVE_FROM_STORAGE);
- outMsg.writeInt16(CAST_S16(slot + STORAGE_OFFSET),
- "index");
- outMsg.writeInt32(amount, "amount");
- }
-}
-
-void InventoryHandler::useCard(const Item *const item A_UNUSED)
-{
-}
-
-void InventoryHandler::insertCard(const int cardIndex A_UNUSED,
- const int itemIndex A_UNUSED) const
-{
-}
-
-void InventoryHandler::favoriteItem(const Item *const item A_UNUSED,
- const bool favorite A_UNUSED) const
-{
-}
-
-void InventoryHandler::selectEgg(const Item *const item A_UNUSED) const
-{
-}
-
-int InventoryHandler::convertFromServerSlot(const int serverSlot) const
-{
- if (serverSlot < 0 || serverSlot > 13)
- return 0;
-
- return CAST_S32(EQUIP_CONVERT[serverSlot]);
-}
-
-void InventoryHandler::selectCart(const BeingId accountId A_UNUSED,
- const int type A_UNUSED) const
-{
-}
-
-void InventoryHandler::identifyItem(const Item *const item A_UNUSED) const
-{
-}
-
-void InventoryHandler::mergeItemsAck(const STD_VECTOR<Item*> &items A_UNUSED)
- const
-{
-}
-
-void InventoryHandler::mergetItemsCancel() const
-{
-}
-
-} // namespace TmwAthena
diff --git a/src/net/tmwa/inventoryhandler.h b/src/net/tmwa/inventoryhandler.h
deleted file mode 100644
index 5bf67f9f1..000000000
--- a/src/net/tmwa/inventoryhandler.h
+++ /dev/null
@@ -1,91 +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 NET_TMWA_INVENTORYHANDLER_H
-#define NET_TMWA_INVENTORYHANDLER_H
-
-#include "net/ea/inventoryhandler.h"
-
-namespace TmwAthena
-{
-
-class InventoryHandler final : public Ea::InventoryHandler
-{
- public:
- InventoryHandler();
-
- A_DELETE_COPY(InventoryHandler)
-
- ~InventoryHandler();
-
- void equipItem(const Item *const item) const override final;
-
- void unequipItem(const Item *const item) const override final;
-
- void useItem(const Item *const item) const override final;
-
- void useItem(const Item *const item,
- const int16_t useType) const override final;
-
- void dropItem(const Item *const item,
- const int amount) const override final;
-
- void closeStorage() const override final;
-
- void moveItem2(const InventoryTypeT source,
- const int slot,
- const int amount,
- const InventoryTypeT destination) const override final;
-
- void useCard(const Item *const item) override final A_CONST;
-
- void insertCard(const int cardIndex,
- const int itemIndex) const override final A_CONST;
-
- void favoriteItem(const Item *const item,
- const bool favorite) const override final A_CONST;
-
- void selectEgg(const Item *const item) const override final A_CONST;
-
- int convertFromServerSlot(const int serverSlot)
- const override final A_WARN_UNUSED;
-
- void selectCart(const BeingId accountId,
- const int type) const override final;
-
- void identifyItem(const Item *const item) const override final;
-
- void mergeItemsAck(const STD_VECTOR<Item*> &items) const
- override final;
-
- void mergetItemsCancel() const override final;
-
- int getProjectileSlot() const override final
- { return 10; }
-
- int getItemIndex() const override final A_WARN_UNUSED
- { return 0; }
-};
-
-} // namespace TmwAthena
-
-#endif // NET_TMWA_INVENTORYHANDLER_H
diff --git a/src/net/tmwa/inventoryrecv.cpp b/src/net/tmwa/inventoryrecv.cpp
deleted file mode 100644
index 1dcc445d7..000000000
--- a/src/net/tmwa/inventoryrecv.cpp
+++ /dev/null
@@ -1,563 +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 "net/tmwa/inventoryrecv.h"
-
-#include "notifymanager.h"
-
-#include "being/localplayer.h"
-
-#include "const/net/inventory.h"
-
-#include "enums/equipslot.h"
-
-#include "enums/resources/notifytypes.h"
-
-#include "listeners/arrowslistener.h"
-
-#include "net/inventoryhandler.h"
-#include "net/messagein.h"
-
-#include "net/ea/equipbackend.h"
-#include "net/ea/inventoryrecv.h"
-
-#include "debug.h"
-
-namespace TmwAthena
-{
-
-namespace InventoryRecv
-{
- const EquipSlot::Type EQUIP_POINTS[EquipSlot::VECTOREND] =
- {
- EquipSlot::LEGS_SLOT, // Lower Headgear
- EquipSlot::FIGHT1_SLOT, // Weapon
- EquipSlot::GLOVES_SLOT, // Garment
- EquipSlot::RING2_SLOT, // Accessory 1
- EquipSlot::RING1_SLOT, // Armor
- EquipSlot::FIGHT2_SLOT, // Shield
- EquipSlot::FEET_SLOT, // Footgear
- EquipSlot::NECK_SLOT, // Accessory 2
- EquipSlot::HEAD_SLOT, // Upper Headgear
- EquipSlot::TORSO_SLOT, // Middle Headgear
- EquipSlot::EVOL_RING1_SLOT, // Costume Top Headgear
- EquipSlot::EVOL_RING2_SLOT, // Costume Mid Headgear
- EquipSlot::PROJECTILE_SLOT, // Costume Low Headgear
- EquipSlot::COSTUME_ROBE_SLOT, // Costume Garment/Robe
- EquipSlot::MISSING1_SLOT, // Missing slot 1
- EquipSlot::MISSING2_SLOT, // Missing slot 2
- EquipSlot::SHADOW_ARMOR_SLOT, // Shadow Armor
- EquipSlot::SHADOW_WEAPON_SLOT, // Shadow Weapon
- EquipSlot::SHADOW_SHIELD_SLOT, // Shadow Shield
- EquipSlot::SHADOW_SHOES_SLOT, // Shadow Shoes
- EquipSlot::SHADOW_ACCESSORY2_SLOT, // Shadow Accessory 2
- EquipSlot::SHADOW_ACCESSORY1_SLOT, // Shadow Accessory 1
- };
-} // namespace InventoryRecv
-
-void InventoryRecv::processPlayerEquipment(Net::MessageIn &msg)
-{
- BLOCK_START("InventoryRecv::processPlayerEquipment")
- Inventory *const inventory = localPlayer != nullptr
- ? PlayerInfo::getInventory() : nullptr;
-
- msg.readInt16("len");
- Equipment *const equipment = PlayerInfo::getEquipment();
- if ((equipment != nullptr) && (equipment->getBackend() == nullptr))
- { // look like SMSG_PLAYER_INVENTORY was not received
- Ea::InventoryRecv::mEquips.clear();
- equipment->setBackend(&Ea::InventoryRecv::mEquips);
- }
- const int number = (msg.getLength() - 4) / 20;
-
- for (int loop = 0; loop < number; loop++)
- {
- const int index = msg.readInt16("index") - INVENTORY_OFFSET;
- const int itemId = msg.readInt16("item id");
- const ItemTypeT itemType = static_cast<ItemTypeT>(
- msg.readUInt8("item type"));
- const uint8_t identified = msg.readUInt8("identify");
- msg.readInt16("equip type?");
- const int equipType = msg.readInt16("equip type");
- msg.readUInt8("attribute");
- const uint8_t refine = msg.readUInt8("refine");
- int cards[maxCards];
- for (int f = 0; f < maxCards; f++)
- cards[f] = msg.readUInt16("card");
-
- if (Ea::InventoryRecv::mDebugInventory)
- {
- logger->log("Index: %d, ID: %d, Type: %d, Identified: %d",
- index, itemId, CAST_S32(itemType), identified);
- }
-
- if (inventory != nullptr)
- {
- inventory->setItem(index,
- itemId,
- itemType,
- 1,
- refine,
- ItemColor_one,
- fromBool(identified, Identified),
- Damaged_false,
- Favorite_false,
- Equipm_true,
- Equipped_false);
- inventory->setCards(index, cards, maxCards);
- }
-
- if (equipType != 0)
- {
- Ea::InventoryRecv::mEquips.setEquipment(
- InventoryRecv::getSlot(equipType),
- index);
- }
- }
- BLOCK_END("InventoryRecv::processPlayerEquipment")
-}
-
-void InventoryRecv::processPlayerInventoryAdd(Net::MessageIn &msg)
-{
- BLOCK_START("InventoryRecv::processPlayerInventoryAdd")
- Inventory *const inventory = localPlayer != nullptr
- ? PlayerInfo::getInventory() : nullptr;
-
- if ((PlayerInfo::getEquipment() != nullptr)
- && (PlayerInfo::getEquipment()->getBackend() == nullptr))
- { // look like SMSG_PLAYER_INVENTORY was not received
- Ea::InventoryRecv::mEquips.clear();
- PlayerInfo::getEquipment()->setBackend(&Ea::InventoryRecv::mEquips);
- }
- const int index = msg.readInt16("index") - INVENTORY_OFFSET;
- int amount = msg.readInt16("amount");
- const int itemId = msg.readInt16("item id");
- const uint8_t identified = msg.readUInt8("identified");
- msg.readUInt8("attribute");
- const uint8_t refine = msg.readUInt8("refine");
- int cards[maxCards];
- for (int f = 0; f < maxCards; f++)
- cards[f] = msg.readUInt16("card");
- const int equipType = msg.readInt16("equip type");
- const ItemTypeT type = static_cast<ItemTypeT>(msg.readUInt8("item type"));
- const unsigned char err = msg.readUInt8("status");
- BeingId floorId;
- if (Ea::InventoryRecv::mSentPickups.empty())
- {
- floorId = BeingId_zero;
- }
- else
- {
- floorId = Ea::InventoryRecv::mSentPickups.front();
- Ea::InventoryRecv::mSentPickups.pop();
- }
-
- if (err != 0u)
- {
- PickupT pickup;
- switch (err)
- {
- case 1:
- pickup = Pickup::BAD_ITEM;
- break;
- case 2:
- pickup = Pickup::TOO_HEAVY;
- break;
- case 3:
- pickup = Pickup::TOO_FAR;
- break;
- case 4:
- pickup = Pickup::INV_FULL;
- break;
- case 5:
- pickup = Pickup::STACK_FULL;
- break;
- case 6:
- pickup = Pickup::DROP_STEAL;
- break;
- default:
- pickup = Pickup::UNKNOWN;
- UNIMPLEMENTEDPACKETFIELD(err);
- break;
- }
- if (localPlayer != nullptr)
- {
- if (itemId == 0)
- {
- localPlayer->pickedUp(ItemDB::getEmpty(),
- 0,
- ItemColor_one,
- floorId,
- pickup);
- }
- else
- {
- localPlayer->pickedUp(ItemDB::get(itemId),
- 0,
- ItemColor_one,
- floorId,
- pickup);
- }
- }
- }
- else
- {
- if (localPlayer != nullptr)
- {
- if (itemId == 0)
- {
- localPlayer->pickedUp(ItemDB::getEmpty(),
- amount,
- ItemColor_one,
- floorId,
- Pickup::OKAY);
- }
- else
- {
- localPlayer->pickedUp(ItemDB::get(itemId),
- amount,
- ItemColor_one,
- floorId,
- Pickup::OKAY);
- }
- }
-
- if (inventory != nullptr)
- {
- const Item *const item = inventory->getItem(index);
-
- if ((item != nullptr) && item->getId() == itemId)
- amount += item->getQuantity();
-
- inventory->setItem(index,
- itemId,
- type,
- amount,
- refine,
- ItemColor_one,
- fromBool(identified, Identified),
- Damaged_false,
- Favorite_false,
- fromBool(equipType, Equipm),
- Equipped_false);
- inventory->setCards(index, cards, maxCards);
- }
- ArrowsListener::distributeEvent();
- }
- BLOCK_END("InventoryRecv::processPlayerInventoryAdd")
-}
-
-void InventoryRecv::processPlayerInventory(Net::MessageIn &msg)
-{
- BLOCK_START("InventoryRecv::processPlayerInventory")
- Inventory *const inventory = localPlayer != nullptr
- ? PlayerInfo::getInventory() : nullptr;
-
- if (PlayerInfo::getEquipment() != nullptr)
- {
- // Clear inventory - this will be a complete refresh
- Ea::InventoryRecv::mEquips.clear();
- PlayerInfo::getEquipment()->setBackend(&Ea::InventoryRecv::mEquips);
- }
-
- if (inventory != nullptr)
- inventory->clear();
-
- msg.readInt16("len");
- const int number = (msg.getLength() - 4) / 18;
-
- for (int loop = 0; loop < number; loop++)
- {
- int cards[maxCards];
- const int index = msg.readInt16("index") - INVENTORY_OFFSET;
- const int itemId = msg.readInt16("item id");
- const ItemTypeT itemType = static_cast<ItemTypeT>(
- msg.readUInt8("item type"));
- const uint8_t identified = msg.readUInt8("identified");
- const int amount = msg.readInt16("amount");
- const int arrow = msg.readInt16("arrow");
- for (int i = 0; i < maxCards; i++)
- cards[i] = msg.readUInt16("card");
-
- if (Ea::InventoryRecv::mDebugInventory)
- {
- logger->log("Index: %d, ID: %d, Type: %d, Identified: %d, "
- "Qty: %d, Cards: %d, %d, %d, %d",
- index, itemId, CAST_S32(itemType), identified, amount,
- cards[0], cards[1], cards[2], cards[3]);
- }
-
- // Trick because arrows are not considered equipment
- const bool isEquipment = (arrow & 0x8000) != 0;
-
- if (inventory != nullptr)
- {
- inventory->setItem(index,
- itemId,
- itemType,
- amount,
- 0,
- ItemColor_one,
- fromBool(identified, Identified),
- Damaged_false,
- Favorite_false,
- fromBool(isEquipment, Equipm),
- Equipped_false);
- inventory->setCards(index, cards, maxCards);
- }
- }
- BLOCK_END("InventoryRecv::processPlayerInventory")
-}
-
-void InventoryRecv::processPlayerStorage(Net::MessageIn &msg)
-{
- BLOCK_START("InventoryRecv::processPlayerInventory")
- Ea::InventoryRecv::mInventoryItems.clear();
-
- msg.readInt16("len");
- const int number = (msg.getLength() - 4) / 18;
-
- for (int loop = 0; loop < number; loop++)
- {
- int cards[maxCards];
- const int index = msg.readInt16("index") - STORAGE_OFFSET;
- const int itemId = msg.readInt16("item id");
- const ItemTypeT itemType = static_cast<ItemTypeT>(
- msg.readUInt8("item type"));
- const uint8_t identified = msg.readUInt8("identified");
- const int amount = msg.readInt16("amount");
- msg.readInt16("arrow");
- for (int i = 0; i < maxCards; i++)
- cards[i] = msg.readUInt16("card");
-
- if (Ea::InventoryRecv::mDebugInventory)
- {
- logger->log("Index: %d, ID: %d, Type: %d, Identified: %d, "
- "Qty: %d, Cards: %d, %d, %d, %d",
- index, itemId, CAST_S32(itemType), identified, amount,
- cards[0], cards[1], cards[2], cards[3]);
- }
-
- Ea::InventoryRecv::mInventoryItems.push_back(Ea::InventoryItem(
- index,
- itemId,
- itemType,
- cards,
- nullptr,
- amount,
- 0,
- ItemColor_one,
- fromBool(identified, Identified),
- Damaged_false,
- Favorite_false,
- Equipm_false));
- }
- BLOCK_END("InventoryRecv::processPlayerInventory")
-}
-
-void InventoryRecv::processPlayerEquip(Net::MessageIn &msg)
-{
- BLOCK_START("InventoryRecv::processPlayerEquip")
- const int index = msg.readInt16("index") - INVENTORY_OFFSET;
- const int equipType = msg.readInt16("equip type");
- const uint8_t flag = msg.readUInt8("flag");
-
- if (flag == 0u)
- {
- NotifyManager::notify(NotifyTypes::EQUIP_FAILED);
- }
- else
- {
- Ea::InventoryRecv::mEquips.setEquipment(
- InventoryRecv::getSlot(equipType),
- index);
- }
- BLOCK_END("InventoryRecv::processPlayerEquip")
-}
-
-void InventoryRecv::processPlayerUnEquip(Net::MessageIn &msg)
-{
- BLOCK_START("InventoryRecv::processPlayerUnEquip")
- msg.readInt16("index");
- const int equipType = msg.readInt16("equip type");
- const uint8_t flag = msg.readUInt8("flag");
-
- if (flag != 0u)
- {
- Ea::InventoryRecv::mEquips.setEquipment(
- InventoryRecv::getSlot(equipType),
- -1);
- }
- if ((equipType & 0x8000) != 0)
- ArrowsListener::distributeEvent();
- BLOCK_END("InventoryRecv::processPlayerUnEquip")
-}
-
-void InventoryRecv::processPlayerStorageEquip(Net::MessageIn &msg)
-{
- BLOCK_START("InventoryRecv::processPlayerStorageEquip")
- msg.readInt16("len");
- const int number = (msg.getLength() - 4) / 20;
-
- for (int loop = 0; loop < number; loop++)
- {
- int cards[maxCards];
- const int index = msg.readInt16("index") - STORAGE_OFFSET;
- const int itemId = msg.readInt16("item id");
- const ItemTypeT itemType = static_cast<ItemTypeT>(
- msg.readUInt8("item type"));
- const uint8_t identified = msg.readUInt8("identified");
- const int amount = 1;
- msg.readInt16("equip point?");
- msg.readInt16("another equip point?");
- msg.readUInt8("attribute (broken)");
- const uint8_t refine = msg.readUInt8("refine");
- for (int i = 0; i < maxCards; i++)
- cards[i] = msg.readUInt16("card");
-
- if (Ea::InventoryRecv::mDebugInventory)
- {
- logger->log("Index: %d, ID: %d, Type: %d, Identified: %u, "
- "Qty: %d, Cards: %d, %d, %d, %d, Refine: %u",
- index, itemId, CAST_S32(itemType),
- CAST_U32(identified), amount,
- cards[0], cards[1], cards[2], cards[3],
- CAST_U32(refine));
- }
-
- Ea::InventoryRecv::mInventoryItems.push_back(Ea::InventoryItem(
- index,
- itemId,
- itemType,
- cards,
- nullptr,
- amount,
- refine,
- ItemColor_one,
- fromBool(identified, Identified),
- Damaged_false,
- Favorite_false,
- Equipm_false));
- }
- BLOCK_END("InventoryRecv::processPlayerStorageEquip")
-}
-
-void InventoryRecv::processPlayerStorageAdd(Net::MessageIn &msg)
-{
- BLOCK_START("InventoryRecv::processPlayerStorageAdd")
- // Move an item into storage
- const int index = msg.readInt16("index") - STORAGE_OFFSET;
- const int amount = msg.readInt32("amount");
- const int itemId = msg.readInt16("item id");
- const unsigned char identified = msg.readUInt8("identified");
- msg.readUInt8("attribute");
- const uint8_t refine = msg.readUInt8("refine");
- int cards[maxCards];
- for (int f = 0; f < maxCards; f++)
- cards[f] = msg.readUInt16("card");
-
- if (Item *const item = Ea::InventoryRecv::mStorage->getItem(index))
- {
- item->setId(itemId, ItemColor_one);
- item->increaseQuantity(amount);
- }
- else
- {
- if (Ea::InventoryRecv::mStorage != nullptr)
- {
- Ea::InventoryRecv::mStorage->setItem(index,
- itemId,
- ItemType::Unknown,
- amount,
- refine,
- ItemColor_one,
- fromBool(identified, Identified),
- Damaged_false,
- Favorite_false,
- Equipm_false,
- Equipped_false);
- Ea::InventoryRecv::mStorage->setCards(index, cards, maxCards);
- }
- }
- BLOCK_END("InventoryRecv::processPlayerStorageAdd")
-}
-
-void InventoryRecv::processPlayerStorageRemove(Net::MessageIn &msg)
-{
- BLOCK_START("InventoryRecv::processPlayerStorageRemove")
- // Move an item out of storage
- const int index = msg.readInt16("index") - STORAGE_OFFSET;
- const int amount = msg.readInt32("amount");
- if (Ea::InventoryRecv::mStorage != nullptr)
- {
- if (Item *const item = Ea::InventoryRecv::mStorage->getItem(index))
- {
- item->increaseQuantity(-amount);
- if (item->getQuantity() == 0)
- Ea::InventoryRecv::mStorage->removeItemAt(index);
- }
- }
- BLOCK_END("InventoryRecv::processPlayerStorageRemove")
-}
-
-void InventoryRecv::processPlayerInventoryRemove(Net::MessageIn &msg)
-{
- BLOCK_START("InventoryRecv::processPlayerInventoryRemove")
- Inventory *const inventory = localPlayer != nullptr
- ? PlayerInfo::getInventory() : nullptr;
-
- const int index = msg.readInt16("index") - INVENTORY_OFFSET;
- const int amount = msg.readInt16("amount");
- if (inventory != nullptr)
- {
- if (Item *const item = inventory->getItem(index))
- {
- item->increaseQuantity(-amount);
- if (item->getQuantity() == 0)
- inventory->removeItemAt(index);
- ArrowsListener::distributeEvent();
- }
- }
- BLOCK_END("InventoryRecv::processPlayerInventoryRemove")
-}
-
-int InventoryRecv::getSlot(const int eAthenaSlot)
-{
- if (eAthenaSlot == 0)
- return EquipSlot::VECTOREND;
-
- if ((eAthenaSlot & 0x8000) != 0)
- return inventoryHandler->getProjectileSlot();
-
- unsigned int mask = 1;
- int position = 0;
- while ((eAthenaSlot & mask) == 0u)
- {
- mask <<= 1;
- position++;
- }
- if (position >= EquipSlot::VECTOREND)
- return EquipSlot::VECTOREND;
- return CAST_S32(EQUIP_POINTS[position]);
-}
-
-} // namespace TmwAthena
diff --git a/src/net/tmwa/inventoryrecv.h b/src/net/tmwa/inventoryrecv.h
deleted file mode 100644
index f8e8b8f05..000000000
--- a/src/net/tmwa/inventoryrecv.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 NET_TMWA_INVENTORYRECV_H
-#define NET_TMWA_INVENTORYRECV_H
-
-#include "localconsts.h"
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-namespace TmwAthena
-{
- namespace InventoryRecv
- {
- void processPlayerEquipment(Net::MessageIn &msg);
- void processPlayerInventoryAdd(Net::MessageIn &msg);
- void processPlayerInventory(Net::MessageIn &msg);
- void processPlayerStorage(Net::MessageIn &msg);
- void processPlayerEquip(Net::MessageIn &msg);
- void processPlayerUnEquip(Net::MessageIn &msg);
- void processPlayerStorageEquip(Net::MessageIn &msg);
- void processPlayerStorageAdd(Net::MessageIn &msg);
- void processPlayerStorageRemove(Net::MessageIn &msg);
- void processPlayerInventoryRemove(Net::MessageIn &msg);
-
- int getSlot(const int eAthenaSlot) A_WARN_UNUSED;
- } // namespace InventoryRecv
-} // namespace TmwAthena
-
-#endif // NET_TMWA_INVENTORYRECV_H
diff --git a/src/net/tmwa/itemhandler.cpp b/src/net/tmwa/itemhandler.cpp
deleted file mode 100644
index 69590909e..000000000
--- a/src/net/tmwa/itemhandler.cpp
+++ /dev/null
@@ -1,35 +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 "net/tmwa/itemhandler.h"
-
-#include "debug.h"
-
-namespace TmwAthena
-{
-
-ItemHandler::ItemHandler() :
- Ea::ItemHandler()
-{
-}
-
-} // namespace TmwAthena
diff --git a/src/net/tmwa/itemhandler.h b/src/net/tmwa/itemhandler.h
deleted file mode 100644
index a824f135b..000000000
--- a/src/net/tmwa/itemhandler.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 NET_TMWA_ITEMHANDLER_H
-#define NET_TMWA_ITEMHANDLER_H
-
-#include "net/ea/itemhandler.h"
-
-namespace TmwAthena
-{
-
-class ItemHandler final : public Ea::ItemHandler
-{
- public:
- ItemHandler();
-
- A_DELETE_COPY(ItemHandler)
-};
-
-} // namespace TmwAthena
-
-#endif // NET_TMWA_ITEMHANDLER_H
diff --git a/src/net/tmwa/itemrecv.cpp b/src/net/tmwa/itemrecv.cpp
deleted file mode 100644
index 53d3a19bc..000000000
--- a/src/net/tmwa/itemrecv.cpp
+++ /dev/null
@@ -1,89 +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 "net/tmwa/itemrecv.h"
-
-#include "actormanager.h"
-
-#include "net/messagein.h"
-
-#include "debug.h"
-
-namespace TmwAthena
-{
-
-void ItemRecv::processItemDropped(Net::MessageIn &msg)
-{
- const BeingId id = msg.readBeingId("item object id");
- const int itemId = msg.readInt16("item id");
- const Identified identify = fromInt(msg.readUInt8("identify"), Identified);
- const int x = msg.readInt16("x");
- const int y = msg.readInt16("y");
- const int subX = CAST_S32(msg.readInt8("sub x"));
- const int subY = CAST_S32(msg.readInt8("sub y"));
- const int amount = msg.readInt16("amount");
-
- if (actorManager != nullptr)
- {
- actorManager->createItem(id,
- itemId,
- x, y,
- ItemType::Unknown,
- amount,
- 0,
- ItemColor_one,
- identify,
- Damaged_false,
- subX, subY,
- nullptr);
- }
-}
-
-void ItemRecv::processItemVisible(Net::MessageIn &msg)
-{
- const BeingId id = msg.readBeingId("item object id");
- const int itemId = msg.readInt16("item id");
- const Identified identified = fromInt(
- msg.readUInt8("identify"), Identified);
- const int x = msg.readInt16("x");
- const int y = msg.readInt16("y");
- const int amount = msg.readInt16("amount");
- const int subX = CAST_S32(msg.readInt8("sub x"));
- const int subY = CAST_S32(msg.readInt8("sub y"));
-
- if (actorManager != nullptr)
- {
- actorManager->createItem(id,
- itemId,
- x, y,
- ItemType::Unknown,
- amount,
- 0,
- ItemColor_one,
- identified,
- Damaged_false,
- subX, subY,
- nullptr);
- }
-}
-
-} // namespace TmwAthena
diff --git a/src/net/tmwa/itemrecv.h b/src/net/tmwa/itemrecv.h
deleted file mode 100644
index 8fc24b579..000000000
--- a/src/net/tmwa/itemrecv.h
+++ /dev/null
@@ -1,40 +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 NET_TMWA_ITEMRECV_H
-#define NET_TMWA_ITEMRECV_H
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-namespace TmwAthena
-{
- namespace ItemRecv
- {
- void processItemDropped(Net::MessageIn &msg);
- void processItemVisible(Net::MessageIn &msg);
- } // namespace ItemRecv
-} // namespace TmwAthena
-
-#endif // NET_TMWA_ITEMRECV_H
diff --git a/src/net/tmwa/loginhandler.cpp b/src/net/tmwa/loginhandler.cpp
deleted file mode 100644
index 566cc5b09..000000000
--- a/src/net/tmwa/loginhandler.cpp
+++ /dev/null
@@ -1,142 +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 "net/tmwa/loginhandler.h"
-
-#include "net/serverfeatures.h"
-
-#include "net/ea/loginrecv.h"
-
-#include "net/tmwa/messageout.h"
-#include "net/tmwa/network.h"
-#include "net/tmwa/protocolout.h"
-
-#include "debug.h"
-
-extern unsigned int tmwServerVersion;
-
-namespace TmwAthena
-{
-
-extern ServerInfo charServer;
-
-LoginHandler::LoginHandler() :
- Ea::LoginHandler()
-{
- loginHandler = this;
-}
-
-LoginHandler::~LoginHandler()
-{
- loginHandler = nullptr;
-}
-
-void LoginHandler::connect() const
-{
- if (Network::mInstance == nullptr)
- return;
-
- Network::mInstance->connect(mServer);
- if (serverFeatures->haveServerVersion())
- {
- createOutPacket(CMSG_SERVER_VERSION_REQUEST);
- }
-}
-
-bool LoginHandler::isConnected() const
-{
- if (Network::mInstance == nullptr)
- return false;
-
- return Ea::LoginRecv::mVersionResponse &&
- Network::mInstance->isConnected();
-}
-
-void LoginHandler::disconnect() const
-{
- if (Network::mInstance != nullptr &&
- Network::mInstance->getServer() == mServer)
- {
- Network::mInstance->disconnect();
- }
-}
-
-void LoginHandler::changePassword(const std::string &restrict oldPassword,
- const std::string &restrict newPassword)
- const
-{
- createOutPacket(CMSG_CHAR_PASSWORD_CHANGE);
- outMsg.writeStringNoLog(oldPassword, 24, "old password");
- outMsg.writeStringNoLog(newPassword, 24, "new password");
-}
-
-void LoginHandler::sendLoginRegister(const std::string &restrict username,
- const std::string &restrict password,
- const std::string &restrict email
- A_UNUSED) const
-{
- createOutPacket(CMSG_LOGIN_REGISTER);
- if (tmwServerVersion < 0x100408)
- {
- // hack to avoid bug in tmwa...
- outMsg.writeInt32(5,
- "client protocol version");
- }
- else
- {
- outMsg.writeInt32(CLIENT_PROTOCOL_VERSION,
- "client protocol version");
- }
- outMsg.writeString(username, 24, "login");
- outMsg.writeStringNoLog(password, 24, "password");
-
- /*
- * eAthena calls the last byte "client version 2", but it isn't used at
- * at all. We're retasking it, as a bit mask:
- * 0 - can handle the 0x63 "update host" packet
- * 1 - defaults to the first char-server (instead of the last)
- */
- outMsg.writeInt8(0x03, "flags");
-}
-
-ServerInfo *LoginHandler::getCharServer() const
-{
- return &charServer;
-}
-
-void LoginHandler::requestUpdateHosts()
-{
-}
-
-void LoginHandler::sendVersion() const
-{
-}
-
-void LoginHandler::ping() const
-{
-}
-
-void LoginHandler::updatePacketVersion() const
-{
-}
-
-} // namespace TmwAthena
diff --git a/src/net/tmwa/loginhandler.h b/src/net/tmwa/loginhandler.h
deleted file mode 100644
index dddbd88e9..000000000
--- a/src/net/tmwa/loginhandler.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 NET_TMWA_LOGINHANDLER_H
-#define NET_TMWA_LOGINHANDLER_H
-
-#include "net/ea/loginhandler.h"
-
-namespace TmwAthena
-{
-
-class LoginHandler final : public Ea::LoginHandler
-{
- public:
- LoginHandler();
-
- A_DELETE_COPY(LoginHandler)
-
- ~LoginHandler();
-
- void connect() const override final;
-
- bool isConnected() const override final A_WARN_UNUSED;
-
- void disconnect() const override final;
-
- unsigned int getMaxPasswordLength() const override final A_WARN_UNUSED
- { return 24; }
-
- void changePassword(const std::string &restrict oldPassword,
- const std::string &restrict newPassword)
- const override final;
-
- ServerInfo *getCharServer() const override final A_CONST A_WARN_UNUSED;
-
- void sendVersion() const override final A_CONST;
-
- void ping() const override final A_CONST;
-
- void updatePacketVersion() const override final A_CONST;
-
- static void requestUpdateHosts() A_CONST;
-
- private:
- void sendLoginRegister(const std::string &restrict username,
- const std::string &restrict password,
- const std::string &restrict email)
- const override final;
-};
-
-} // namespace TmwAthena
-
-#endif // NET_TMWA_LOGINHANDLER_H
diff --git a/src/net/tmwa/loginrecv.cpp b/src/net/tmwa/loginrecv.cpp
deleted file mode 100644
index 05b4aaba3..000000000
--- a/src/net/tmwa/loginrecv.cpp
+++ /dev/null
@@ -1,175 +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 "net/tmwa/loginrecv.h"
-
-#include "client.h"
-#include "configuration.h"
-#include "logger.h"
-
-#include "being/being.h"
-
-#include "net/logindata.h"
-#include "net/loginhandler.h"
-#include "net/messagein.h"
-
-#include "net/ea/loginrecv.h"
-
-#include "net/tmwa/updateprotocol.h"
-
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-extern int packetVersion;
-
-namespace TmwAthena
-{
-
-extern ServerInfo charServer;
-
-enum ServerFlags
-{
- FLAG_REGISTRATION = 1
-};
-
-void LoginRecv::processServerVersion(Net::MessageIn &msg)
-{
- packetVersion = 0;
- const uint8_t b1 = msg.readUInt8("b1"); // -1
- const uint8_t b2 = msg.readUInt8("b2");
- const uint8_t b3 = msg.readUInt8("b3");
- msg.readUInt8("b4");
- if (b1 == 255)
- { // old TMWA
- const unsigned int options = msg.readInt32("options");
- Ea::LoginRecv::mRegistrationEnabled =
- ((options & FLAG_REGISTRATION) != 0u);
- serverVersion = 0;
- tmwServerVersion = 0;
- }
- else if (b1 >= 0x0d)
- { // new TMWA
- const unsigned int options = msg.readInt32("options");
- Ea::LoginRecv::mRegistrationEnabled =
- ((options & FLAG_REGISTRATION) != 0u);
- serverVersion = 0;
- tmwServerVersion = (b1 << 16) | (b2 << 8) | b3;
- }
- else
- { // eAthena
- const unsigned int options = msg.readInt32("options");
- Ea::LoginRecv::mRegistrationEnabled =
- ((options & FLAG_REGISTRATION) != 0u);
- serverVersion = 0;
- tmwServerVersion = 0;
- }
- if (tmwServerVersion > 0)
- logger->log("Tmw server version: x%06x", tmwServerVersion);
- else
- logger->log("Server without version");
- updateProtocol();
-
- if (client->getState() != State::LOGIN)
- client->setState(State::LOGIN);
-
- // Leave this last
- Ea::LoginRecv::mVersionResponse = true;
-}
-
-void LoginRecv::processCharPasswordResponse(Net::MessageIn &msg)
-{
- // 0: acc not found, 1: success, 2: password mismatch, 3: pass too short
- const uint8_t errMsg = msg.readUInt8("result code");
- // Successful pass change
- if (errMsg == 1)
- {
- client->setState(State::CHANGEPASSWORD_SUCCESS);
- }
- // pass change failed
- else
- {
- switch (errMsg)
- {
- case 0:
- errorMessage =
- // TRANSLATORS: error message
- _("Account was not found. Please re-login.");
- break;
- case 2:
- // TRANSLATORS: error message
- errorMessage = _("Old password incorrect.");
- break;
- case 3:
- // TRANSLATORS: error message
- errorMessage = _("New password too short.");
- break;
- default:
- // TRANSLATORS: error message
- errorMessage = _("Unknown error.");
- break;
- }
- client->setState(State::ACCOUNTCHANGE_ERROR);
- }
-}
-
-void LoginRecv::processLoginData(Net::MessageIn &msg)
-{
- msg.readInt16("len");
-
- loginHandler->clearWorlds();
-
- const int worldCount = (msg.getLength() - 47) / 32;
-
- Ea::LoginRecv::mToken.session_ID1 = msg.readInt32("session id1");
- Ea::LoginRecv::mToken.account_ID = msg.readBeingId("accound id");
- Ea::LoginRecv::mToken.session_ID2 = msg.readInt32("session id2");
- msg.readInt32("old ip");
- loginData.lastLogin = msg.readString(24, "last login");
- msg.readInt16("unused");
-
- // reserve bits for future usage
- Ea::LoginRecv::mToken.sex = Being::intToGender(CAST_U8(
- msg.readUInt8("gender") & 3U));
-
- for (int i = 0; i < worldCount; i++)
- {
- WorldInfo *const world = new WorldInfo;
-
- world->address = msg.readInt32("ip address");
- world->port = msg.readInt16("port");
- world->name = msg.readString(20, "name");
- world->online_users = msg.readInt16("online number");
- config.setValue("updatehost", Ea::LoginRecv::mUpdateHost);
- world->updateHost = Ea::LoginRecv::mUpdateHost;
- msg.readInt16("maintenance");
- msg.readInt16("new");
-
- logger->log("Network: Server: %s (%s:%d)", world->name.c_str(),
- ipToString(world->address), world->port);
-
- Ea::LoginRecv::mWorlds.push_back(world);
- }
- client->setState(State::WORLD_SELECT);
-}
-
-} // namespace TmwAthena
diff --git a/src/net/tmwa/loginrecv.h b/src/net/tmwa/loginrecv.h
deleted file mode 100644
index fb038da55..000000000
--- a/src/net/tmwa/loginrecv.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 NET_TMWA_LOGINRECV_H
-#define NET_TMWA_LOGINRECV_H
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-namespace TmwAthena
-{
- namespace LoginRecv
- {
- void processServerVersion(Net::MessageIn &msg);
- void processCharPasswordResponse(Net::MessageIn &msg);
- void processLoginData(Net::MessageIn &msg);
- } // namespace LoginRecv
-} // namespace TmwAthena
-
-#endif // NET_TMWA_LOGINRECV_H
diff --git a/src/net/tmwa/mail2handler.cpp b/src/net/tmwa/mail2handler.cpp
deleted file mode 100644
index 786a31a6f..000000000
--- a/src/net/tmwa/mail2handler.cpp
+++ /dev/null
@@ -1,118 +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 "net/tmwa/mail2handler.h"
-
-#include "debug.h"
-
-namespace TmwAthena
-{
-
-Mail2Handler::Mail2Handler()
-{
- mail2Handler = this;
-}
-
-Mail2Handler::~Mail2Handler()
-{
- mail2Handler = nullptr;
-}
-
-void Mail2Handler::openWriteMail(const std::string &receiver A_UNUSED) const
-{
-}
-
-void Mail2Handler::addItem(const Item *const item A_UNUSED,
- const int amount A_UNUSED) const
-{
-}
-
-void Mail2Handler::removeItem(const int index A_UNUSED,
- const int amount A_UNUSED) const
-{
-}
-
-void Mail2Handler::sendMail(const std::string &to A_UNUSED,
- const std::string &title A_UNUSED,
- const std::string &body A_UNUSED,
- const int64_t &money A_UNUSED) const
-{
-}
-
-void Mail2Handler::queueCheckName(const MailQueueTypeT type A_UNUSED,
- const std::string &to A_UNUSED,
- const std::string &title A_UNUSED,
- const std::string &body A_UNUSED,
- const int64_t &money A_UNUSED) const
-{
-}
-
-void Mail2Handler::nextPage(const MailOpenTypeT openType A_UNUSED,
- const int64_t mailId A_UNUSED) const
-{
-}
-
-void Mail2Handler::readMail(const MailOpenTypeT openType A_UNUSED,
- const int64_t mailId A_UNUSED) const
-{
-}
-
-void Mail2Handler::deleteMail(const MailOpenTypeT openType A_UNUSED,
- const int64_t mailId A_UNUSED) const
-{
-}
-
-void Mail2Handler::requestMoney(const MailOpenTypeT openType A_UNUSED,
- const int64_t mailId A_UNUSED) const
-{
-}
-
-void Mail2Handler::requestItems(const MailOpenTypeT openType A_UNUSED,
- const int64_t mailId A_UNUSED) const
-{
-}
-
-void Mail2Handler::refreshMailList(const MailOpenTypeT openType A_UNUSED,
- const int64_t mailId A_UNUSED) const
-{
-}
-
-void Mail2Handler::openMailBox(const MailOpenTypeT openType A_UNUSED) const
-{
-}
-
-void Mail2Handler::closeMailBox() const
-{
-}
-
-void Mail2Handler::cancelWriteMail() const
-{
-}
-
-void Mail2Handler::requestCheckName(const std::string &name A_UNUSED) const
-{
-}
-
-std::string Mail2Handler::getCheckedName() const
-{
- return std::string();
-}
-
-} // namespace TmwAthena
diff --git a/src/net/tmwa/mail2handler.h b/src/net/tmwa/mail2handler.h
deleted file mode 100644
index 003a29b89..000000000
--- a/src/net/tmwa/mail2handler.h
+++ /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/>.
- */
-
-#ifndef NET_TMWA_MAIL2HANDLER_H
-#define NET_TMWA_MAIL2HANDLER_H
-
-#include "net/mail2handler.h"
-
-namespace TmwAthena
-{
-
-class Mail2Handler final : public Net::Mail2Handler
-{
- public:
- Mail2Handler();
-
- A_DELETE_COPY(Mail2Handler)
-
- ~Mail2Handler();
-
- void openWriteMail(const std::string &receiver) const override final;
-
- void addItem(const Item *const item,
- const int amount) const override final;
-
- void removeItem(const int index,
- const int amount) const override final;
-
- void sendMail(const std::string &to,
- const std::string &title,
- const std::string &body,
- const int64_t &money) const override final;
-
- void queueCheckName(const MailQueueTypeT type,
- const std::string &to,
- const std::string &title,
- const std::string &body,
- const int64_t &money) const override final;
-
- void nextPage(const MailOpenTypeT openType,
- const int64_t mailId) const override final;
-
- void readMail(const MailOpenTypeT openType,
- const int64_t mailId) const override final;
-
- void deleteMail(const MailOpenTypeT openType,
- const int64_t mailId) const override final;
-
- void requestMoney(const MailOpenTypeT openType,
- const int64_t mailId) const override final;
-
- void requestItems(const MailOpenTypeT openType,
- const int64_t mailId) const override final;
-
- void refreshMailList(const MailOpenTypeT openType,
- const int64_t mailId) const override final;
-
- void openMailBox(const MailOpenTypeT openType) const override final;
-
- void closeMailBox() const override final;
-
- void cancelWriteMail() const override final;
-
- void requestCheckName(const std::string &name) const override final;
-
- std::string getCheckedName() const override final;
-};
-
-} // namespace TmwAthena
-
-#endif // NET_TMWA_MAIL2HANDLER_H
diff --git a/src/net/tmwa/mailhandler.cpp b/src/net/tmwa/mailhandler.cpp
deleted file mode 100644
index 2a124e504..000000000
--- a/src/net/tmwa/mailhandler.cpp
+++ /dev/null
@@ -1,77 +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 "net/tmwa/mailhandler.h"
-
-#include "debug.h"
-
-namespace TmwAthena
-{
-
-MailHandler::MailHandler()
-{
- mailHandler = this;
-}
-
-MailHandler::~MailHandler()
-{
- mailHandler = nullptr;
-}
-
-void MailHandler::refresh() const
-{
-}
-
-void MailHandler::readMessage(const int msgId A_UNUSED) const
-{
-}
-
-void MailHandler::getAttach(const int msgId A_UNUSED) const
-{
-}
-
-void MailHandler::deleteMessage(const int msgId A_UNUSED) const
-{
-}
-
-void MailHandler::returnMessage(const int msgId A_UNUSED) const
-{
-}
-
-void MailHandler::setAttach(const int index A_UNUSED,
- const int amount A_UNUSED) const
-{
-}
-
-void MailHandler::setAttachMoney(const int money A_UNUSED) const
-{
-}
-
-void MailHandler::resetAttach(const int flag A_UNUSED) const
-{
-}
-
-void MailHandler::send(const std::string &name A_UNUSED,
- const std::string &title A_UNUSED,
- std::string message A_UNUSED) const
-{
-}
-
-} // namespace TmwAthena
diff --git a/src/net/tmwa/mailhandler.h b/src/net/tmwa/mailhandler.h
deleted file mode 100644
index 94867a7a7..000000000
--- a/src/net/tmwa/mailhandler.h
+++ /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/>.
- */
-
-#ifndef NET_TMWA_MAILHANDLER_H
-#define NET_TMWA_MAILHANDLER_H
-
-#include "net/mailhandler.h"
-
-namespace TmwAthena
-{
-
-class MailHandler final : public Net::MailHandler
-{
- public:
- MailHandler();
-
- A_DELETE_COPY(MailHandler)
-
- ~MailHandler();
-
- void refresh() const override final A_CONST;
-
- void readMessage(const int msgId) const override final A_CONST;
-
- void getAttach(const int msgId) const override final A_CONST;
-
- void deleteMessage(const int msgId) const override final A_CONST;
-
- void returnMessage(const int msgId) const override final A_CONST;
-
- void setAttach(const int index,
- const int amount) const override final A_CONST;
-
- void setAttachMoney(const int money) const override final A_CONST;
-
- void resetAttach(const int flag) const override final A_CONST;
-
- void send(const std::string &name,
- const std::string &title,
- std::string message) const override final A_CONST;
-};
-
-} // namespace TmwAthena
-
-#endif // NET_TMWA_MAILHANDLER_H
diff --git a/src/net/tmwa/maphandler.cpp b/src/net/tmwa/maphandler.cpp
deleted file mode 100644
index 642480a4d..000000000
--- a/src/net/tmwa/maphandler.cpp
+++ /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/>.
- */
-
-#include "net/tmwa/maphandler.h"
-
-#include "debug.h"
-
-namespace TmwAthena
-{
-
-MapHandler::MapHandler() :
- Net::MapHandler()
-{
- mapHandler = this;
-}
-
-MapHandler::~MapHandler()
-{
- mapHandler = nullptr;
-}
-
-} // namespace TmwAthena
diff --git a/src/net/tmwa/maphandler.h b/src/net/tmwa/maphandler.h
deleted file mode 100644
index 10382222d..000000000
--- a/src/net/tmwa/maphandler.h
+++ /dev/null
@@ -1,41 +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 NET_TMWA_MAPHANDLER_H
-#define NET_TMWA_MAPHANDLER_H
-
-#include "net/maphandler.h"
-
-namespace TmwAthena
-{
-
-class MapHandler final : public Net::MapHandler
-{
- public:
- MapHandler();
-
- A_DELETE_COPY(MapHandler)
-
- ~MapHandler();
-};
-
-} // namespace TmwAthena
-
-#endif // NET_TMWA_MAPHANDLER_H
diff --git a/src/net/tmwa/markethandler.cpp b/src/net/tmwa/markethandler.cpp
deleted file mode 100644
index 1a2f6b548..000000000
--- a/src/net/tmwa/markethandler.cpp
+++ /dev/null
@@ -1,55 +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 "net/tmwa/markethandler.h"
-
-#include "debug.h"
-
-namespace TmwAthena
-{
-
-MarketHandler::MarketHandler() :
- Net::MarketHandler()
-{
- marketHandler = this;
-}
-
-MarketHandler::~MarketHandler()
-{
- marketHandler = nullptr;
-}
-
-void MarketHandler::close() const
-{
-}
-
-void MarketHandler::buyItem(const int itemId A_UNUSED,
- const ItemTypeT type A_UNUSED,
- const ItemColor color A_UNUSED,
- const int amount A_UNUSED) const
-{
-}
-
-void MarketHandler::buyItems(const STD_VECTOR<ShopItem*> &items A_UNUSED)
- const
-{
-}
-
-} // namespace TmwAthena
diff --git a/src/net/tmwa/markethandler.h b/src/net/tmwa/markethandler.h
deleted file mode 100644
index 923b697c0..000000000
--- a/src/net/tmwa/markethandler.h
+++ /dev/null
@@ -1,50 +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 NET_TMWA_MARKETHANDLER_H
-#define NET_TMWA_MARKETHANDLER_H
-
-#include "net/markethandler.h"
-
-namespace TmwAthena
-{
-class MarketHandler final : public Net::MarketHandler
-{
- public:
- MarketHandler();
-
- A_DELETE_COPY(MarketHandler)
-
- ~MarketHandler();
-
- void close() const override final A_CONST;
-
- void buyItem(const int itemId,
- const ItemTypeT type,
- const ItemColor color,
- const int amount) const override final A_CONST;
-
- void buyItems(const STD_VECTOR<ShopItem*> &items) const override final
- A_CONST;
-};
-
-} // namespace TmwAthena
-
-#endif // NET_TMWA_MARKETHANDLER_H
diff --git a/src/net/tmwa/mercenaryhandler.cpp b/src/net/tmwa/mercenaryhandler.cpp
deleted file mode 100644
index 7f824180a..000000000
--- a/src/net/tmwa/mercenaryhandler.cpp
+++ /dev/null
@@ -1,67 +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 "net/tmwa/mercenaryhandler.h"
-
-#include "debug.h"
-
-namespace TmwAthena
-{
-
-MercenaryHandler::MercenaryHandler()
-{
- mercenaryHandler = this;
-}
-
-MercenaryHandler::~MercenaryHandler()
-{
- mercenaryHandler = nullptr;
-}
-
-void MercenaryHandler::fire() const
-{
-}
-
-void MercenaryHandler::moveToMaster() const
-{
-}
-
-void MercenaryHandler::move(const int x A_UNUSED, const int y A_UNUSED) const
-{
-}
-
-void MercenaryHandler::attack(const BeingId targetId A_UNUSED,
- const Keep keep A_UNUSED) const
-{
-}
-
-void MercenaryHandler::talk(const std::string &restrict text A_UNUSED) const
-{
-}
-
-void MercenaryHandler::emote(const uint8_t emoteId A_UNUSED) const
-{
-}
-
-void MercenaryHandler::setDirection(const unsigned char type A_UNUSED) const
-{
-}
-
-} // namespace TmwAthena
diff --git a/src/net/tmwa/mercenaryhandler.h b/src/net/tmwa/mercenaryhandler.h
deleted file mode 100644
index eaba1f2fd..000000000
--- a/src/net/tmwa/mercenaryhandler.h
+++ /dev/null
@@ -1,58 +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 NET_TMWA_MERCENARYHANDLER_H
-#define NET_TMWA_MERCENARYHANDLER_H
-
-#include "net/mercenaryhandler.h"
-
-namespace TmwAthena
-{
-
-class MercenaryHandler final : public Net::MercenaryHandler
-{
- public:
- MercenaryHandler();
-
- A_DELETE_COPY(MercenaryHandler)
-
- ~MercenaryHandler();
-
- void fire() const override final A_CONST;
-
- void moveToMaster() const override final A_CONST;
-
- void move(const int x, const int y) const override final A_CONST;
-
- void attack(const BeingId targetId,
- const Keep keep) const override final A_CONST;
-
- void talk(const std::string &restrict text) const override final
- A_CONST;
-
- void emote(const uint8_t emoteId) const override final A_CONST;
-
- void setDirection(const unsigned char type) const override final
- A_CONST;
-};
-
-} // namespace TmwAthena
-
-#endif // NET_TMWA_MERCENARYHANDLER_H
diff --git a/src/net/tmwa/messagein.cpp b/src/net/tmwa/messagein.cpp
deleted file mode 100644
index 792f88743..000000000
--- a/src/net/tmwa/messagein.cpp
+++ /dev/null
@@ -1,168 +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 "net/tmwa/messagein.h"
-
-#include "logger.h"
-
-#include "net/net.h"
-#include "net/packetcounters.h"
-
-#include "utils/cast.h"
-#include "utils/stringutils.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"
-
-namespace TmwAthena
-{
-
-MessageIn::MessageIn(const char *const data,
- const unsigned int length) :
- Net::MessageIn(data, length)
-{
-}
-
-void MessageIn::postInit(const char *const str)
-{
- // Read the message ID
- mId = readId();
- IGNOREDEBUGLOG;
- DEBUGLOG2("Receive packet", 0, "MessageIn");
- readInt16(str);
-}
-
-uint16_t MessageIn::readId() const
-{
- int16_t value = -1;
- if (mPos + 2 <= mLength)
- {
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- int16_t swap;
- memcpy(&swap, mData + CAST_SIZE(mPos), sizeof(int16_t));
- value = SDL_Swap16(swap);
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- memcpy(&value, mData + CAST_SIZE(mPos), sizeof(int16_t));
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
- }
- return value;
-}
-
-int16_t MessageIn::readInt16(const char *const str)
-{
- int16_t value = -1;
- if (mPos + 2 <= mLength)
- {
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- int16_t swap;
- memcpy(&swap, mData + CAST_SIZE(mPos), sizeof(int16_t));
- value = SDL_Swap16(swap);
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- memcpy(&value, mData + CAST_SIZE(mPos), sizeof(int16_t));
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
- }
- DEBUGLOG2("readInt16: " + toStringPrint(CAST_U32(
- CAST_U16(value))),
- mPos, str);
- mPos += 2;
- PacketCounters::incInBytes(2);
- return value;
-}
-
-uint16_t MessageIn::readUInt16(const char *const str)
-{
- uint16_t value = 0xffU;
- if (mPos + 2 <= mLength)
- {
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- uint16_t swap;
- memcpy(&swap, mData + CAST_SIZE(mPos), sizeof(uint16_t));
- value = SDL_Swap16(swap);
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- memcpy(&value, mData + CAST_SIZE(mPos), sizeof(uint16_t));
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
- }
- DEBUGLOG2("readUInt16: " + toStringPrint(CAST_U32(
- CAST_U16(value))),
- mPos, str);
- mPos += 2;
- PacketCounters::incInBytes(2);
- return value;
-}
-
-int32_t MessageIn::readInt32(const char *const str)
-{
- int32_t value = -1;
- if (mPos + 4 <= mLength)
- {
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- int32_t swap;
- memcpy(&swap, mData + CAST_SIZE(mPos), sizeof(int32_t));
- value = SDL_Swap32(swap);
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- memcpy(&value, mData + CAST_SIZE(mPos), sizeof(int32_t));
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
- }
- DEBUGLOG2("readInt32: " + toStringPrint(CAST_U32(value)),
- mPos, str);
- mPos += 4;
- PacketCounters::incInBytes(4);
- return value;
-}
-
-BeingId MessageIn::readBeingId(const char *const str)
-{
- return fromInt(readInt32(str), BeingId);
-}
-
-int64_t MessageIn::readInt64(const char *const str)
-{
- int64_t value = -1;
- if (mPos + 8 <= mLength)
- {
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- int64_t swap;
- memcpy(&swap, mData + CAST_SIZE(mPos), sizeof(int64_t));
- value = SDL_Swap64(swap);
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- memcpy(&value, mData + CAST_SIZE(mPos), sizeof(int64_t));
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
- }
- DEBUGLOG2("readInt64: " + toStringPrint(CAST_U32(value)),
- mPos, str);
- mPos += 8;
- PacketCounters::incInBytes(8);
- return value;
-}
-
-} // namespace TmwAthena
diff --git a/src/net/tmwa/messagein.h b/src/net/tmwa/messagein.h
deleted file mode 100644
index aca246cd6..000000000
--- a/src/net/tmwa/messagein.h
+++ /dev/null
@@ -1,68 +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 NET_TMWA_MESSAGEIN_H
-#define NET_TMWA_MESSAGEIN_H
-
-#include "net/messagein.h"
-
-#include "localconsts.h"
-
-namespace TmwAthena
-{
-
-/**
- * Used for parsing an incoming message.
- *
- * \ingroup Network
- */
-class MessageIn final : public Net::MessageIn
-{
- public:
- /**
- * Constructor.
- */
- MessageIn(const char *const data,
- const unsigned int length);
-
- A_DELETE_COPY(MessageIn)
-
- void postInit(const char *const str);
-
- /**< Reads a short. */
- int16_t readInt16(const char *const str) override final;
-
- uint16_t readUInt16(const char *const str) override final;
-
- /**< Reads a long. */
- int32_t readInt32(const char *const str) override final;
-
- int64_t readInt64(const char *const str) override final;
-
- BeingId readBeingId(const char *const str) override final;
-
- uint16_t readId() const;
-};
-
-} // namespace TmwAthena
-
-#endif // NET_TMWA_MESSAGEIN_H
diff --git a/src/net/tmwa/messageout.cpp b/src/net/tmwa/messageout.cpp
deleted file mode 100644
index 64951642d..000000000
--- a/src/net/tmwa/messageout.cpp
+++ /dev/null
@@ -1,132 +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 "net/tmwa/messageout.h"
-
-#include "net/packetcounters.h"
-
-#include "net/tmwa/network.h"
-
-#include "logger.h"
-
-#include "debug.h"
-
-#ifndef SDL_BIG_ENDIAN
-#error missing SDL_endian.h
-#endif // SDL_BYTEORDER
-
-namespace TmwAthena
-{
-
-MessageOut::MessageOut(const int16_t id) :
- Net::MessageOut(id),
- mNetwork(TmwAthena::Network::instance())
-{
- mNetwork->fixSendBuffer();
- mData = mNetwork->mOutBuffer + CAST_SIZE(mNetwork->mOutSize);
-}
-
-MessageOut::~MessageOut()
-{
- DEBUGLOG2("writeEnd: ", mPos, "position after end of packet");
-}
-
-void MessageOut::expand(const size_t bytes) const
-{
- mNetwork->mOutSize += CAST_U32(bytes);
- PacketCounters::incOutBytes(CAST_S32(bytes));
-}
-
-void MessageOut::writeInt16(const int16_t value, const char *const str)
-{
- DEBUGLOG2("writeInt16: " + toStringPrint(CAST_U32(
- CAST_U16(value))),
- mPos, str);
- expand(2);
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- int16_t swap = SDL_Swap16(value);
- memcpy(mData + CAST_SIZE(mPos), &swap, sizeof(int16_t));
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- memcpy(mData + CAST_SIZE(mPos), &value, sizeof(int16_t));
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- mPos += 2;
- PacketCounters::incOutBytes(2);
-}
-
-void MessageOut::writeInt32(const int32_t value, const char *const str)
-{
- DEBUGLOG2("writeInt32: " + toStringPrint(CAST_U32(value)),
- mPos, str);
- expand(4);
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- int32_t swap = SDL_Swap32(value);
- memcpy(mData + CAST_SIZE(mPos), &swap, sizeof(int32_t));
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- memcpy(mData + CAST_SIZE(mPos), &value, sizeof(int32_t));
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- mPos += 4;
- PacketCounters::incOutBytes(4);
-}
-
-void MessageOut::writeBeingId(const BeingId value, const char *const str)
-{
- writeInt32(toInt(value, int32_t), str);
-}
-
-#define LOBYTE(w) (CAST_U8(w))
-#define HIBYTE(w) (CAST_U8(( \
-CAST_U16(w)) >> 8U))
-
-void MessageOut::writeCoordinates(const uint16_t x,
- const uint16_t y,
- unsigned char direction,
- const char *const str)
-{
- DEBUGLOG2(strprintf("writeCoordinates: %u,%u %u",
- CAST_U32(x), static_cast<unsigned>(y),
- CAST_U32(direction)), mPos, str);
- unsigned char *const data = reinterpret_cast<unsigned char*>(mData)
- + CAST_SIZE(mPos);
- mNetwork->mOutSize += 3;
- mPos += 3;
-
- uint16_t temp = x;
- temp <<= 6;
- data[0] = 0;
- data[1] = 1;
- data[2] = 2;
- data[0] = HIBYTE(temp);
- data[1] = CAST_U8(temp);
- temp = y;
- temp <<= 4;
- data[1] |= HIBYTE(temp);
- data[2] = LOBYTE(temp);
- direction = toServerDirection(direction);
- data[2] |= direction;
- PacketCounters::incOutBytes(3);
-}
-
-} // namespace TmwAthena
diff --git a/src/net/tmwa/messageout.h b/src/net/tmwa/messageout.h
deleted file mode 100644
index 18346b690..000000000
--- a/src/net/tmwa/messageout.h
+++ /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/>.
- */
-
-#ifndef NET_TMWA_MESSAGEOUT_H
-#define NET_TMWA_MESSAGEOUT_H
-
-#include "net/messageout.h"
-
-#include "localconsts.h"
-
-namespace TmwAthena
-{
-
-class Network;
-
-/**
- * Used for building an outgoing message.
- *
- * \ingroup Network
- */
-class MessageOut final : public Net::MessageOut
-{
- public:
- /**
- * Constructor.
- */
- explicit MessageOut(const int16_t id);
-
- A_DELETE_COPY(MessageOut)
-
- virtual ~MessageOut();
-
- /**< Writes a short. */
- void writeInt16(const int16_t value,
- const char *const str) override final;
-
- /**< Writes a long. */
- void writeInt32(const int32_t value,
- const char *const str) override final;
-
- void writeBeingId(const BeingId value,
- const char *const str) override final;
-
- /**
- * Encodes coordinates and direction in 3 bytes.
- */
- void writeCoordinates(const uint16_t x,
- const uint16_t y,
- unsigned char direction,
- const char *const str);
-
- void resetPos()
- { mPos = 0; }
-
- private:
- void expand(const size_t size) const override final;
-
- Network *mNetwork;
-};
-
-} // namespace TmwAthena
-
-#endif // NET_TMWA_MESSAGEOUT_H
diff --git a/src/net/tmwa/network.cpp b/src/net/tmwa/network.cpp
deleted file mode 100644
index ebc4db9e6..000000000
--- a/src/net/tmwa/network.cpp
+++ /dev/null
@@ -1,183 +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 "net/tmwa/network.h"
-
-#include "logger.h"
-
-#include "net/packetinfo.h"
-
-#include "net/ea/adminrecv.h"
-#include "net/ea/beingrecv.h"
-#include "net/ea/buysellrecv.h"
-#include "net/ea/charserverrecv.h"
-#include "net/ea/chatrecv.h"
-#include "net/ea/gamerecv.h"
-#include "net/ea/inventoryrecv.h"
-#include "net/ea/itemrecv.h"
-#include "net/ea/loginrecv.h"
-#include "net/ea/maprecv.h"
-#include "net/ea/npcrecv.h"
-#include "net/ea/partyrecv.h"
-#include "net/ea/playerrecv.h"
-#include "net/ea/skillrecv.h"
-#include "net/ea/traderecv.h"
-
-#include "net/tmwa/beingrecv.h"
-#include "net/tmwa/buysellrecv.h"
-#include "net/tmwa/charserverrecv.h"
-#include "net/tmwa/chatrecv.h"
-#include "net/tmwa/gamerecv.h"
-#include "net/tmwa/generalrecv.h"
-#include "net/tmwa/inventoryrecv.h"
-#include "net/tmwa/itemrecv.h"
-#include "net/tmwa/loginrecv.h"
-#include "net/tmwa/partyrecv.h"
-#include "net/tmwa/playerrecv.h"
-#include "net/tmwa/questrecv.h"
-#include "net/tmwa/skillrecv.h"
-#include "net/tmwa/traderecv.h"
-
-#include "net/tmwa/messagein.h"
-
-#include "utils/cast.h"
-
-#include "debug.h"
-
-namespace TmwAthena
-{
-
-static const unsigned int packet_lengths_size = 0xFFFFU;
-static const unsigned int messagesSize = 0xFFFFU;
-Network *Network::mInstance = nullptr;
-
-Network::Network() :
- Ea::Network()
-{
- mInstance = this;
- mPackets = new PacketInfo[messagesSize];
-}
-
-Network::~Network()
-{
- clearHandlers();
- mInstance = nullptr;
-}
-
-void Network::registerHandlers()
-{
-#include "net/tmwa/recvpackets.inc"
- RECVPACKETS_VOID
-}
-
-void Network::clearHandlers()
-{
- for (size_t f = 0; f < packet_lengths_size; f ++)
- {
- mPackets[f].name = "";
- mPackets[f].len = 0;
- mPackets[f].func = nullptr;
- mPackets[f].version = 0;
- }
-}
-
-void Network::dispatchMessages()
-{
- BLOCK_START("Network::dispatchMessages 1")
- mPauseDispatch = false;
- while (messageReady())
- {
- SDL_mutexP(mMutexIn);
- BLOCK_START("Network::dispatchMessages 2")
- const unsigned int msgId = readWord(0);
- int len = -1;
- if (msgId < packet_lengths_size)
- len = mPackets[msgId].len;
-
- if (len == -1)
- len = readWord(2);
-
- MessageIn msg(mInBuffer, len);
- msg.postInit(mPackets[msgId].name);
- SDL_mutexV(mMutexIn);
- BLOCK_END("Network::dispatchMessages 2")
- BLOCK_START("Network::dispatchMessages 3")
-
- if (len == 0)
- {
- // need copy data for safty
- std::string str = strprintf(
- "Wrong packet %u 0x%x received. Exiting.",
- msgId, msgId);
- logger->safeError(str);
- }
-
- if (msgId < messagesSize)
- {
- const PacketFuncPtr func = mPackets[msgId].func;
- if (func != nullptr)
- func(msg);
- else
- logger->log("Unhandled packet: %u 0x%x", msgId, msgId);
- }
-
- skip(len);
- if (mPauseDispatch)
- {
- BLOCK_END("Network::dispatchMessages 3")
- break;
- }
- BLOCK_END("Network::dispatchMessages 3")
- }
- BLOCK_END("Network::dispatchMessages 1")
-}
-
-bool Network::messageReady()
-{
- int len = -1;
-
- SDL_mutexP(mMutexIn);
- if (mInSize >= 2)
- {
- const int msgId = readWord(0);
- if (msgId >= 0 && CAST_U32(msgId)
- < packet_lengths_size)
- {
- len = mPackets[msgId].len;
- }
-
- if (len == -1 && mInSize > 4)
- len = readWord(2);
- }
-
- const bool ret = (mInSize >= CAST_U32(len));
- SDL_mutexV(mMutexIn);
-
- return ret;
-}
-
-Network *Network::instance()
-{
- return mInstance;
-}
-
-} // namespace TmwAthena
diff --git a/src/net/tmwa/network.h b/src/net/tmwa/network.h
deleted file mode 100644
index 26a2a1650..000000000
--- a/src/net/tmwa/network.h
+++ /dev/null
@@ -1,63 +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 NET_TMWA_NETWORK_H
-#define NET_TMWA_NETWORK_H
-
-#include "net/ea/network.h"
-
-/**
- * Protocol version, reported to the tmwa char and mapserver who can adjust
- * the protocol accordingly.
- */
-#define CLIENT_PROTOCOL_VERSION 7
-
-namespace TmwAthena
-{
-class Network final : public Ea::Network
-{
- public:
- Network();
-
- A_DELETE_COPY(Network)
-
- ~Network();
-
- void clearHandlers();
-
- bool messageReady();
-
- void dispatchMessages();
-
- void registerHandlers();
-
- static Network *mInstance;
-
- protected:
- friend class MessageOut;
-
- static Network *instance() A_WARN_UNUSED;
-};
-
-} // namespace TmwAthena
-
-#endif // NET_TMWA_NETWORK_H
diff --git a/src/net/tmwa/npchandler.cpp b/src/net/tmwa/npchandler.cpp
deleted file mode 100644
index e4a9296fc..000000000
--- a/src/net/tmwa/npchandler.cpp
+++ /dev/null
@@ -1,246 +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 "net/tmwa/npchandler.h"
-
-#include "being/localplayer.h"
-
-#include "const/net/inventory.h"
-
-#include "gui/windows/npcdialog.h"
-
-#include "gui/widgets/createwidget.h"
-
-#include "net/messagein.h"
-
-#include "net/tmwa/messageout.h"
-#include "net/tmwa/protocolout.h"
-
-#include "net/ea/npcrecv.h"
-
-#include "debug.h"
-
-namespace TmwAthena
-{
-
-NpcHandler::NpcHandler() :
- Ea::NpcHandler()
-{
- npcHandler = this;
-}
-
-NpcHandler::~NpcHandler()
-{
- npcHandler = nullptr;
-}
-
-void NpcHandler::talk(const Being *const being) const
-{
- if (being == nullptr)
- return;
- createOutPacket(CMSG_NPC_TALK);
- outMsg.writeBeingId(being->getId(), "npc id");
- outMsg.writeInt8(0, "unused");
-}
-
-void NpcHandler::nextDialog(const BeingId npcId) const
-{
- createOutPacket(CMSG_NPC_NEXT_REQUEST);
- outMsg.writeBeingId(npcId, "npc id");
-}
-
-void NpcHandler::closeDialog(const BeingId npcId)
-{
- createOutPacket(CMSG_NPC_CLOSE);
- outMsg.writeBeingId(npcId, "npc id");
-
- const NpcDialogs::iterator it = NpcDialog::mNpcDialogs.find(npcId);
- if (it != NpcDialog::mNpcDialogs.end())
- {
- NpcDialog *const dialog = (*it).second;
- if (dialog != nullptr)
- dialog->close();
- if (dialog == Ea::NpcRecv::mDialog)
- Ea::NpcRecv::mDialog = nullptr;
- NpcDialog::mNpcDialogs.erase(it);
- }
-}
-
-void NpcHandler::listInput(const BeingId npcId,
- const unsigned char value) const
-{
- createOutPacket(CMSG_NPC_LIST_CHOICE);
- outMsg.writeBeingId(npcId, "npc id");
- outMsg.writeInt8(value, "value");
-}
-
-void NpcHandler::integerInput(const BeingId npcId,
- const int value) const
-{
- createOutPacket(CMSG_NPC_INT_RESPONSE);
- outMsg.writeBeingId(npcId, "npc id");
- outMsg.writeInt32(value, "value");
-}
-
-void NpcHandler::stringInput(const BeingId npcId,
- const std::string &value) const
-{
- createOutPacket(CMSG_NPC_STR_RESPONSE);
- outMsg.writeInt16(CAST_S16(value.length() + 9), "len");
- outMsg.writeBeingId(npcId, "npc id");
- outMsg.writeString(value, CAST_S32(value.length()), "value");
- outMsg.writeInt8(0, "null byte");
-}
-
-void NpcHandler::buy(const Being *const being) const
-{
- if (being == nullptr)
- return;
- createOutPacket(CMSG_NPC_BUY_SELL_REQUEST);
- outMsg.writeBeingId(being->getId(), "npc id");
- outMsg.writeInt8(0, "action");
-}
-
-void NpcHandler::buy(const BeingId beingId) const
-{
- createOutPacket(CMSG_NPC_BUY_SELL_REQUEST);
- outMsg.writeBeingId(beingId, "npc id");
- outMsg.writeInt8(0, "action");
-}
-
-void NpcHandler::sell(const BeingId beingId) const
-{
- createOutPacket(CMSG_NPC_BUY_SELL_REQUEST);
- outMsg.writeBeingId(beingId, "npc id");
- outMsg.writeInt8(1, "action");
-}
-
-void NpcHandler::buyItem(const BeingId beingId A_UNUSED,
- const int itemId,
- const ItemColor color A_UNUSED,
- const int amount) const
-{
- createOutPacket(CMSG_NPC_BUY_REQUEST);
- outMsg.writeInt16(8, "len");
- outMsg.writeInt16(CAST_S16(amount), "amount");
- outMsg.writeInt16(CAST_S16(itemId), "item id");
-}
-
-void NpcHandler::buyItems(STD_VECTOR<ShopItem*> &items A_UNUSED) const
-{
-}
-
-void NpcHandler::sellItem(const BeingId beingId A_UNUSED,
- const int itemId,
- const int amount) const
-{
- createOutPacket(CMSG_NPC_SELL_REQUEST);
- outMsg.writeInt16(8, "len");
- outMsg.writeInt16(CAST_S16(
- itemId + INVENTORY_OFFSET), "index");
- outMsg.writeInt16(CAST_S16(amount), "amount");
-}
-
-void NpcHandler::sellItems(STD_VECTOR<ShopItem*> &items A_UNUSED) const
-{
-}
-
-void NpcHandler::completeProgressBar() const
-{
-}
-
-void NpcHandler::produceMix(const int nameId A_UNUSED,
- const int materialId1 A_UNUSED,
- const int materialId2 A_UNUSED,
- const int materialId3 A_UNUSED) const
-{
-}
-
-void NpcHandler::cooking(const CookingTypeT type A_UNUSED,
- const int nameId A_UNUSED) const
-{
-}
-
-void NpcHandler::repair(const int index A_UNUSED) const
-{
-}
-
-void NpcHandler::refine(const int index A_UNUSED) const
-{
-}
-
-void NpcHandler::identify(const int index A_UNUSED) const
-{
-}
-
-void NpcHandler::selectArrow(const int nameId A_UNUSED) const
-{
-}
-
-void NpcHandler::selectAutoSpell(const int skillId A_UNUSED) const
-{
-}
-
-BeingId NpcHandler::getNpc(Net::MessageIn &msg,
- const NpcActionT action)
-{
- const BeingId npcId = msg.readBeingId("npc id");
-
- const NpcDialogs::const_iterator diag = NpcDialog::mNpcDialogs.find(npcId);
- Ea::NpcRecv::mDialog = nullptr;
-
- if (diag == NpcDialog::mNpcDialogs.end())
- {
- // +++ must be removed packet id checks from here
- // Empty dialogs don't help
- if (action == NpcAction::Close)
- {
- closeDialog(npcId);
- return npcId;
- }
- else if (action == NpcAction::Next)
- {
- nextDialog(npcId);
- return npcId;
- }
- else
- {
- CREATEWIDGETV(Ea::NpcRecv::mDialog, NpcDialog, npcId);
- Ea::NpcRecv::mDialog->saveCamera();
- if (localPlayer != nullptr)
- localPlayer->stopWalking(false);
- NpcDialog::mNpcDialogs[npcId] = Ea::NpcRecv::mDialog;
- }
- }
- else
- {
- NpcDialog *const dialog = diag->second;
- if (Ea::NpcRecv::mDialog != nullptr && Ea::NpcRecv::mDialog != dialog)
- Ea::NpcRecv::mDialog->restoreCamera();
- Ea::NpcRecv::mDialog = dialog;
- if (Ea::NpcRecv::mDialog != nullptr)
- Ea::NpcRecv::mDialog->saveCamera();
- }
- return npcId;
-}
-
-} // namespace TmwAthena
diff --git a/src/net/tmwa/npchandler.h b/src/net/tmwa/npchandler.h
deleted file mode 100644
index 14bfefb66..000000000
--- a/src/net/tmwa/npchandler.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 NET_TMWA_NPCHANDLER_H
-#define NET_TMWA_NPCHANDLER_H
-
-#include "net/ea/npchandler.h"
-
-namespace TmwAthena
-{
-
-class NpcHandler final : public Ea::NpcHandler
-{
- public:
- NpcHandler();
-
- A_DELETE_COPY(NpcHandler)
-
- ~NpcHandler();
-
- void talk(const Being *const being) const override final;
-
- void nextDialog(const BeingId npcId) const override final;
-
- void closeDialog(const BeingId npcId) override final;
-
- void listInput(const BeingId npcId,
- const unsigned char value) const override final;
-
- void integerInput(const BeingId npcId,
- const int value) const override final;
-
- void stringInput(const BeingId npcId,
- const std::string &value) const override final;
-
- void buy(const Being *const being) const override final;
-
- void buy(const BeingId beingId) const override final;
-
- void sell(const BeingId beingId) const override final;
-
- void buyItem(const BeingId beingId,
- const int itemId,
- const ItemColor color,
- const int amount) const override final;
-
- void buyItems(STD_VECTOR<ShopItem*> &items) const override final
- A_CONST;
-
- void sellItem(const BeingId beingId,
- const int itemId,
- const int amount) const override final;
-
- void sellItems(STD_VECTOR<ShopItem*> &items) const override final
- A_CONST;
-
- void completeProgressBar() const override final A_CONST;
-
- BeingId getNpc(Net::MessageIn &msg,
- const NpcActionT action) override final;
-
- void produceMix(const int nameId,
- const int materialId1,
- const int materialId2,
- const int materialId3) const override final A_CONST;
-
- void cooking(const CookingTypeT type,
- const int nameId) const override final A_CONST;
-
- void repair(const int index) const override final A_CONST;
-
- void refine(const int index) const override final A_CONST;
-
- void identify(const int index) const override final A_CONST;
-
- void selectArrow(const int nameId) const override final A_CONST;
-
- void selectAutoSpell(const int skillId) const override final A_CONST;
-};
-
-} // namespace TmwAthena
-
-#endif // NET_TMWA_NPCHANDLER_H
diff --git a/src/net/tmwa/packetsin.inc b/src/net/tmwa/packetsin.inc
deleted file mode 100644
index 633c2b1ad..000000000
--- a/src/net/tmwa/packetsin.inc
+++ /dev/null
@@ -1,147 +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/>.
- */
-
-packet(SMSG_ADMIN_KICK_ACK, 0x00cd, 6, &Ea::AdminRecv::processKickAck, 0);
-packet(SMSG_BEING_ACTION, 0x008a, 29, &Ea::BeingRecv::processBeingAction, 0);
-packet(SMSG_BEING_CHANGE_DIRECTION, 0x009c, 9, &BeingRecv::processBeingChangeDirection, 0);
-packet(SMSG_BEING_CHANGE_LOOKS, 0x00c3, 8, &BeingRecv::processBeingChangeLook, 0);
-packet(SMSG_BEING_CHANGE_LOOKS2, 0x01d7, 11, &BeingRecv::processBeingChangeLook2, 0);
-packet(SMSG_BEING_CHAT, 0x008d, -1, &ChatRecv::processBeingChat, 0);
-packet(SMSG_BEING_EMOTION, 0x00c0, 7, &Ea::BeingRecv::processBeingEmotion, 0);
-packet(SMSG_BEING_IP_RESPONSE, 0x020c, 10, &BeingRecv::processIpResponse, 0);
-packet(SMSG_BEING_MOVE, 0x007b, 60, &BeingRecv::processBeingMove, 0);
-packet(SMSG_BEING_MOVE2, 0x0086, 16, &BeingRecv::processBeingMove2, 0);
-packet(SMSG_BEING_MOVE3, 0x0225, -1, &Ea::BeingRecv::processBeingMove3, 0);
-packet(SMSG_BEING_NAME_RESPONSE, 0x0095, 30, &Ea::BeingRecv::processNameResponse, 0);
-packet(SMSG_BEING_REMOVE, 0x0080, 7, &Ea::BeingRecv::processBeingRemove, 0);
-packet(SMSG_BEING_RESURRECT, 0x0148, 8, &BeingRecv::processBeingResurrect, 0);
-packet(SMSG_BEING_SELFEFFECT, 0x019b, 10, &BeingRecv::processBeingSelfEffect, 0);
-packet(SMSG_BEING_SPAWN, 0x007c, 41, &BeingRecv::processBeingSpawn, 0);
-packet(SMSG_BEING_STATUS_CHANGE, 0x0196, 9, &BeingRecv::processBeingStatusChange, 0);
-packet(SMSG_BEING_VISIBLE, 0x0078, 54, &BeingRecv::processBeingVisible, 0);
-packet(SMSG_CHANGE_MAP_SERVER, 0x0092, 28, &CharServerRecv::processChangeMapServer, 0);
-packet(SMSG_CHAR_CREATE_FAILED, 0x006e, 3, &Ea::CharServerRecv::processCharCreateFailed, 0);
-packet(SMSG_CHAR_CREATE_SUCCEEDED, 0x006d, 108, &CharServerRecv::processCharCreate, 0);
-packet(SMSG_CHAR_DELETE_FAILED, 0x0070, 3, &CharServerRecv::processCharDeleteFailed, 0);
-packet(SMSG_CHAR_DELETE_SUCCEEDED, 0x006f, 2, &Ea::CharServerRecv::processCharDelete, 0);
-packet(SMSG_CHAR_LOGIN, 0x006b, -1, &CharServerRecv::processCharLogin, 0);
-packet(SMSG_CHAR_LOGIN_ERROR, 0x006c, 3, &Ea::CharServerRecv::processCharLoginError, 0);
-packet(SMSG_CHAR_MAP_INFO, 0x0071, 28, &CharServerRecv::processCharMapInfo, 0);
-packet(SMSG_CHAR_PASSWORD_RESPONSE, 0x0062, 3, &LoginRecv::processCharPasswordResponse, 0);
-packet(SMSG_CHAR_SWITCH_RESPONSE, 0x00b3, 3, &Ea::GameRecv::processCharSwitchResponse, 0);
-packet(SMSG_CONNECTION_PROBLEM, 0x0081, 3, &GeneralRecv::processConnectionProblem, 0);
-packet(SMSG_GM_CHAT, 0x009a, -1, &ChatRecv::processGmChat, 0);
-packet(SMSG_IGNORE_ALL_RESPONSE, 0x00d2, 4, &Ea::ChatRecv::processIgnoreAllResponse, 0);
-packet(SMSG_ITEM_DROPPED, 0x009e, 17, &ItemRecv::processItemDropped, 0);
-packet(SMSG_ITEM_REMOVE, 0x00a1, 6, &Ea::ItemRecv::processItemRemove, 0);
-packet(SMSG_ITEM_USE_RESPONSE, 0x00a8, 7, &Ea::InventoryRecv::processItemUseResponse, 0);
-packet(SMSG_ITEM_VISIBLE, 0x009d, 17, &ItemRecv::processItemVisible, 0);
-packet(SMSG_LOGIN_DATA, 0x0069, -1, &LoginRecv::processLoginData, 0);
-packet(SMSG_LOGIN_ERROR, 0x006a, 23, &Ea::LoginRecv::processLoginError, 0);
-packet(SMSG_MAP_LOGIN_SUCCESS, 0x0073, 11, &GameRecv::processMapLogin, 0);
-packet(SMSG_MAP_MUSIC, 0x0227, -1, &Ea::PlayerRecv::processMapMusic, 0);
-packet(SMSG_MAP_QUIT_RESPONSE, 0x018b, 4, &Ea::GameRecv::processMapQuitResponse, 0);
-packet(SMSG_MVP_EFFECT, 0x010c, 6, &Ea::ChatRecv::processMVPEffect, 0);
-packet(SMSG_NPC_BUY, 0x00c6, -1, &BuySellRecv::processNpcBuy, 0);
-packet(SMSG_NPC_BUY_RESPONSE, 0x00ca, 3, &BuySellRecv::processNpcBuyResponse, 0);
-packet(SMSG_NPC_BUY_SELL_CHOICE, 0x00c4, 6, &Ea::BuySellRecv::processNpcBuySellChoice, 0);
-packet(SMSG_NPC_CHANGETITLE, 0x0228, -1, &Ea::NpcRecv::processChangeTitle, 0);
-packet(SMSG_NPC_CHOICE, 0x00b7, -1, &Ea::NpcRecv::processNpcChoice, 0);
-packet(SMSG_NPC_CLOSE, 0x00b6, 6, &Ea::NpcRecv::processNpcClose, 0);
-packet(SMSG_NPC_COMMAND, 0x0212, 16, &Ea::NpcRecv::processNpcCommand, 0);
-packet(SMSG_NPC_INT_INPUT, 0x0142, 6, &Ea::NpcRecv::processNpcIntInput, 0);
-packet(SMSG_NPC_MESSAGE, 0x00b4, -1, &Ea::NpcRecv::processNpcMessage, 0);
-packet(SMSG_NPC_NEXT, 0x00b5, 6, &Ea::NpcRecv::processNpcNext, 0);
-packet(SMSG_NPC_SELL, 0x00c7, -1, &Ea::BuySellRecv::processNpcSell, 0);
-packet(SMSG_NPC_SELL_RESPONSE, 0x00cb, 3, &BuySellRecv::processNpcSellResponse, 0);
-packet(SMSG_NPC_STR_INPUT, 0x01d4, 6, &Ea::NpcRecv::processNpcStrInput, 0);
-packet(SMSG_PARTY_CREATE, 0x00fa, 3, &Ea::PartyRecv::processPartyCreate, 0);
-packet(SMSG_PARTY_INFO, 0x00fb, -1, &PartyRecv::processPartyInfo, 0);
-packet(SMSG_PARTY_INVITED, 0x00fe, 30, &PartyRecv::processPartyInvited, 0);
-packet(SMSG_PARTY_INVITE_RESPONSE, 0x00fd, 27, &PartyRecv::processPartyInviteResponse, 0);
-packet(SMSG_PARTY_LEAVE, 0x0105, 31, &Ea::PartyRecv::processPartyLeave, 0);
-packet(SMSG_PARTY_MESSAGE, 0x0109, -1, &PartyRecv::processPartyMessage, 0);
-packet(SMSG_PARTY_MOVE, 0x0104, 79, &PartyRecv::processPartyMove, 0);
-packet(SMSG_PARTY_SETTINGS, 0x0101, 6, &PartyRecv::processPartySettings, 0);
-packet(SMSG_PARTY_UPDATE_COORDS, 0x0107, 10, &Ea::PartyRecv::processPartyUpdateCoords, 0);
-packet(SMSG_PARTY_UPDATE_HP, 0x0106, 10, &PartyRecv::processPartyUpdateHp, 0);
-packet(SMSG_PLAYER_ARROW_EQUIP, 0x013c, 4, &Ea::InventoryRecv::processPlayerArrowEquip, 0);
-packet(SMSG_PLAYER_ARROW_MESSAGE, 0x013b, 4, &Ea::PlayerRecv::processPlayerArrowMessage, 0);
-packet(SMSG_PLAYER_ATTACK_RANGE, 0x013a, 4, &Ea::InventoryRecv::processPlayerAttackRange, 0);
-packet(SMSG_PLAYER_CHAT, 0x008e, -1, &ChatRecv::processChat, 0);
-packet(SMSG_PLAYER_EQUIP, 0x00aa, 7, &InventoryRecv::processPlayerEquip, 0);
-packet(SMSG_PLAYER_EQUIPMENT, 0x00a4, -1, &InventoryRecv::processPlayerEquipment, 0);
-packet(SMSG_PLAYER_GUILD_PARTY_INFO, 0x0195, 102, &BeingRecv::processPlayerGuilPartyInfo, 0);
-packet(SMSG_PLAYER_INVENTORY, 0x01ee, -1, &InventoryRecv::processPlayerInventory, 0);
-packet(SMSG_PLAYER_INVENTORY_ADD, 0x00a0, 23, &InventoryRecv::processPlayerInventoryAdd, 0);
-packet(SMSG_PLAYER_INVENTORY_REMOVE, 0x00af, 6, &InventoryRecv::processPlayerInventoryRemove, 0);
-packet(SMSG_PLAYER_INVENTORY_USE, 0x01c8, 13, &Ea::InventoryRecv::processPlayerInventoryUse, 0);
-packet(SMSG_PLAYER_MOVE, 0x01da, 60, &BeingRecv::processPlayerMove, 0);
-packet(SMSG_PLAYER_MOVE_TO_ATTACK, 0x0139, 16, &Ea::BeingRecv::processPlayerMoveToAttack, 0);
-packet(SMSG_PLAYER_SKILLS, 0x010f, -1, &SkillRecv::processPlayerSkills, 0);
-packet(SMSG_PLAYER_SKILL_UP, 0x010e, 11, &Ea::SkillRecv::processPlayerSkillUp, 0);
-packet(SMSG_PLAYER_STATUS_CHANGE, 0x0119, 13, &BeingRecv::processPlayerStatusChange, 0);
-packet(SMSG_PLAYER_STAT_UPDATE_1, 0x00b0, 8, &Ea::PlayerRecv::processPlayerStatUpdate1, 0);
-packet(SMSG_PLAYER_STAT_UPDATE_2, 0x00b1, 8, &Ea::PlayerRecv::processPlayerStatUpdate2, 0);
-packet(SMSG_PLAYER_STAT_UPDATE_3, 0x0141, 14, &Ea::PlayerRecv::processPlayerStatUpdate3, 0);
-packet(SMSG_PLAYER_STAT_UPDATE_4, 0x00bc, 6, &Ea::PlayerRecv::processPlayerStatUpdate4, 0);
-packet(SMSG_PLAYER_STAT_UPDATE_5, 0x00bd, 44, &PlayerRecv::processPlayerStatUpdate5, 0);
-packet(SMSG_PLAYER_STAT_UPDATE_6, 0x00be, 5, &Ea::PlayerRecv::processPlayerStatUpdate6, 0);
-packet(SMSG_PLAYER_STOP, 0x0088, 10, &Ea::BeingRecv::processPlayerStop, 0);
-packet(SMSG_PLAYER_STORAGE_ADD, 0x00f4, 21, &InventoryRecv::processPlayerStorageAdd, 0);
-packet(SMSG_PLAYER_STORAGE_CLOSE, 0x00f8, 2, &Ea::InventoryRecv::processPlayerStorageClose, 0);
-packet(SMSG_PLAYER_STORAGE_EQUIP, 0x00a6, -1, &InventoryRecv::processPlayerStorageEquip, 0);
-packet(SMSG_PLAYER_STORAGE_ITEMS, 0x01f0, -1, &InventoryRecv::processPlayerStorage, 0);
-packet(SMSG_PLAYER_STORAGE_REMOVE, 0x00f6, 8, &InventoryRecv::processPlayerStorageRemove, 0);
-packet(SMSG_PLAYER_STORAGE_STATUS, 0x00f2, 6, &Ea::InventoryRecv::processPlayerStorageStatus, 0);
-packet(SMSG_PLAYER_UNEQUIP, 0x00ac, 7, &InventoryRecv::processPlayerUnEquip, 0);
-packet(SMSG_PLAYER_UPDATE_1, 0x01d8, 54, &BeingRecv::processPlayerUpdate1, 0);
-packet(SMSG_PLAYER_UPDATE_2, 0x01d9, 53, &BeingRecv::processPlayerUpdate2, 0);
-packet(SMSG_PLAYER_WARP, 0x0091, 22, &Ea::PlayerRecv::processPlayerWarp, 0);
-packet(SMSG_PVP_MAP_MODE, 0x0199, 4, &Ea::BeingRecv::processPvpMapMode, 0);
-packet(SMSG_PVP_SET, 0x019a, 14, &BeingRecv::processPvpSet, 0);
-packet(SMSG_QUEST_PLAYER_VARS, 0x0215, -1, &QuestRecv::processPlayerQuests, 0);
-packet(SMSG_QUEST_SET_VAR, 0x0214, 8, &QuestRecv::processSetQuestVar, 0);
-packet(SMSG_SCRIPT_MESSAGE, 0x0229, -1, &ChatRecv::processScriptMessage, 0);
-packet(SMSG_SERVER_PING, 0x007f, 6, nullptr, 0);
-packet(SMSG_SERVER_VERSION_RESPONSE, 0x7531, 10, &LoginRecv::processServerVersion, 0);
-packet(SMSG_SKILL_CASTING, 0x013e, 24, &BeingRecv::processSkillCasting, 0);
-packet(SMSG_SKILL_CAST_CANCEL, 0x01b9, 6, &BeingRecv::processSkillCastCancel, 0);
-packet(SMSG_SKILL_DAMAGE, 0x01de, 33, &BeingRecv::processSkillDamage, 0);
-packet(SMSG_SKILL_FAILED, 0x0110, 10, &SkillRecv::processSkillFailed, 0);
-packet(SMSG_SKILL_NO_DAMAGE, 0x011a, 15, &Ea::BeingRecv::processSkillNoDamage, 0);
-packet(SMSG_SOLVE_CHAR_NAME, 0x0194, 30, nullptr, 0);
-packet(SMSG_TRADE_CANCEL, 0x00ee, 2, &Ea::TradeRecv::processTradeCancel, 0);
-packet(SMSG_TRADE_COMPLETE, 0x00f0, 3, &Ea::TradeRecv::processTradeComplete, 0);
-packet(SMSG_TRADE_ITEM_ADD, 0x00e9, 19, &TradeRecv::processTradeItemAdd, 0);
-packet(SMSG_TRADE_ITEM_ADD_RESPONSE, 0x01b1, 7, &TradeRecv::processTradeItemAddResponse, 0);
-packet(SMSG_TRADE_OK, 0x00ec, 3, &Ea::TradeRecv::processTradeOk, 0);
-packet(SMSG_TRADE_REQUEST, 0x00e5, 26, &TradeRecv::processTradeRequest, 0);
-packet(SMSG_TRADE_RESPONSE, 0x00e7, 3, &TradeRecv::processTradeResponse, 0);
-packet(SMSG_UPDATE_HOST, 0x0063, -1, &Ea::LoginRecv::processUpdateHost, 0);
-packet(SMSG_WALK_RESPONSE, 0x0087, 12, &PlayerRecv::processWalkResponse, 0);
-packet(SMSG_WHISPER, 0x0097, -1, &ChatRecv::processWhisper, 0);
-packet(SMSG_WHISPER_RESPONSE, 0x0098, 3, &ChatRecv::processWhisperResponse, 0);
-packet(SMSG_WHO_ANSWER, 0x00c2, 6, &Ea::GameRecv::processWhoAnswer, 0);
-packet(SMSG_MAP_MASK, 0x0226, 10, &Ea::PlayerRecv::processMapMask, 0);
-packet(SMSG_PLAYER_CLIENT_COMMAND, 0x0230, -1, &Ea::PlayerRecv::processPlayerClientCommand, 0);
-packet(SMSG_MAP_SET_TILES_TYPE, 0x0231, 34, &Ea::MapRecv::processSetTilesType, 0);
diff --git a/src/net/tmwa/packetsout.inc b/src/net/tmwa/packetsout.inc
deleted file mode 100644
index 4b93150ed..000000000
--- a/src/net/tmwa/packetsout.inc
+++ /dev/null
@@ -1,110 +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/>.
- */
-
-#define PACKETSOUT_VOID
-
-packet(CMSG_SERVER_VERSION_REQUEST, 0x7530, 0, nullptr);
-
-packet(CMSG_LOGIN_REGISTER, 0x0064, 0, nullptr);
-
-packet(CMSG_NAME_REQUEST, 0x0094, 0, nullptr);
-
-packet(CMSG_CHAR_PASSWORD_CHANGE, 0x0061, 0, nullptr);
-packet(CMSG_CHAR_SERVER_CONNECT, 0x0065, 0, nullptr);
-packet(CMSG_CHAR_SELECT, 0x0066, 0, nullptr);
-packet(CMSG_CHAR_CREATE, 0x0067, 0, nullptr);
-packet(CMSG_CHAR_DELETE, 0x0068, 0, nullptr);
-
-packet(CMSG_MAP_SERVER_CONNECT, 0x0072, 0, nullptr);
-packet(CMSG_MAP_PING, 0x007e, 0, nullptr);
-packet(CMSG_MAP_LOADED, 0x007d, 0, nullptr);
-packet(CMSG_CLIENT_QUIT, 0x018A, 0, nullptr);
-
-packet(CMSG_CHAT_MESSAGE, 0x008c, 0, nullptr);
-packet(CMSG_CHAT_WHISPER, 0x0096, 0, nullptr);
-packet(CMSG_CHAT_WHO, 0x00c1, 0, nullptr);
-
-packet(CMSG_SKILL_LEVELUP_REQUEST, 0x0112, 0, nullptr);
-packet(CMSG_STAT_UPDATE_REQUEST, 0x00bb, 0, nullptr);
-packet(CMSG_SKILL_USE_BEING, 0x0113, 0, nullptr);
-packet(CMSG_SKILL_USE_POSITION, 0x0116, 0, nullptr);
-packet(CMSG_SKILL_USE_POSITION_MORE, 0x0190, 0, nullptr);
-packet(CMSG_SKILL_USE_MAP, 0x011b, 0, nullptr);
-
-packet(CMSG_PLAYER_INVENTORY_USE, 0x00a7, 0, nullptr);
-packet(CMSG_PLAYER_INVENTORY_DROP, 0x00a2, 0, nullptr);
-packet(CMSG_PLAYER_EQUIP, 0x00a9, 0, nullptr);
-packet(CMSG_PLAYER_UNEQUIP, 0x00ab, 0, nullptr);
-
-packet(CMSG_ITEM_PICKUP, 0x009f, 0, nullptr);
-packet(CMSG_PLAYER_CHANGE_DIR, 0x009b, 0, nullptr);
-packet(CMSG_PLAYER_CHANGE_DEST, 0x0085, 0, nullptr);
-packet(CMSG_PLAYER_CHANGE_ACT, 0x0089, 0, nullptr);
-packet(CMSG_PLAYER_RESTART, 0x00b2, 0, nullptr);
-packet(CMSG_PLAYER_EMOTE, 0x00bf, 0, nullptr);
-packet(CMSG_PLAYER_STOP_ATTACK, 0x0118, 0, nullptr);
-packet(CMSG_WHO_REQUEST, 0x00c1, 0, nullptr);
-
-packet(CMSG_NPC_TALK, 0x0090, 0, nullptr);
-packet(CMSG_NPC_NEXT_REQUEST, 0x00b9, 0, nullptr);
-packet(CMSG_NPC_CLOSE, 0x0146, 0, nullptr);
-packet(CMSG_NPC_LIST_CHOICE, 0x00b8, 0, nullptr);
-packet(CMSG_NPC_INT_RESPONSE, 0x0143, 0, nullptr);
-packet(CMSG_NPC_STR_RESPONSE, 0x01d5, 0, nullptr);
-packet(CMSG_NPC_BUY_SELL_REQUEST, 0x00c5, 0, nullptr);
-packet(CMSG_NPC_BUY_REQUEST, 0x00c8, 0, nullptr);
-packet(CMSG_NPC_SELL_REQUEST, 0x00c9, 0, nullptr);
-
-packet(CMSG_TRADE_REQUEST, 0x00e4, 0, nullptr);
-packet(CMSG_TRADE_RESPONSE, 0x00e6, 0, nullptr);
-packet(CMSG_TRADE_ITEM_ADD_REQUEST, 0x00e8, 0, nullptr);
-packet(CMSG_TRADE_CANCEL_REQUEST, 0x00ed, 0, nullptr);
-packet(CMSG_TRADE_ADD_COMPLETE, 0x00eb, 0, nullptr);
-packet(CMSG_TRADE_OK, 0x00ef, 0, nullptr);
-
-packet(CMSG_PARTY_CREATE, 0x00f9, 0, nullptr);
-packet(CMSG_PARTY_INVITE, 0x00fc, 0, nullptr);
-packet(CMSG_PARTY_INVITED, 0x00ff, 0, nullptr);
-packet(CMSG_PARTY_LEAVE, 0x0100, 0, nullptr);
-packet(CMSG_PARTY_SETTINGS, 0x0102, 0, nullptr);
-packet(CMSG_PARTY_KICK, 0x0103, 0, nullptr);
-packet(CMSG_PARTY_MESSAGE, 0x0108, 0, nullptr);
-
-packet(CMSG_MOVE_TO_STORAGE, 0x00f3, 0, nullptr);
-packet(CMSG_MOVE_FROM_STORAGE, 0x00f5, 0, nullptr);
-packet(CMSG_CLOSE_STORAGE, 0x00f7, 0, nullptr);
-
-packet(CMSG_ADMIN_ANNOUNCE, 0x0099, 0, nullptr);
-packet(CMSG_ADMIN_LOCAL_ANNOUNCE, 0x019C, 0, nullptr);
-packet(CMSG_ADMIN_HIDE, 0x019D, 0, nullptr);
-packet(CMSG_ADMIN_KICK, 0x00CC, 0, nullptr);
-packet(CMSG_ADMIN_MUTE, 0x0149, 0, nullptr);
-
-packet(CMSG_SOLVE_CHAR_NAME, 0x0193, 0, nullptr);
-packet(CMSG_IGNORE_NICK, 0x00cf, 0, nullptr);
-
-packet(CMSG_CLIENT_DISCONNECT, 0x7532, 0, nullptr);
-packet(CMSG_IGNORE_ALL, 0x00d0, 0, nullptr);
-
-#ifdef PACKETS_UPDATE
-// condition code here
-#endif
diff --git a/src/net/tmwa/partyhandler.cpp b/src/net/tmwa/partyhandler.cpp
deleted file mode 100644
index cef9588f7..000000000
--- a/src/net/tmwa/partyhandler.cpp
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 Lloyd Bryant <lloyd_bryant@netzero.net>
- * 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 "net/tmwa/partyhandler.h"
-
-#include "actormanager.h"
-#include "notifymanager.h"
-#include "party.h"
-
-#include "being/localplayer.h"
-
-#include "enums/resources/notifytypes.h"
-
-#include "net/ea/partyrecv.h"
-
-#include "net/tmwa/messageout.h"
-#include "net/tmwa/protocolout.h"
-
-#include "debug.h"
-
-namespace TmwAthena
-{
-
-PartyHandler::PartyHandler() :
- Ea::PartyHandler()
-{
- partyHandler = this;
-}
-
-PartyHandler::~PartyHandler()
-{
- partyHandler = nullptr;
-}
-
-void PartyHandler::create(const std::string &name) const
-{
- createOutPacket(CMSG_PARTY_CREATE);
- outMsg.writeString(name.substr(0, 23), 24, "party name");
-}
-
-void PartyHandler::invite(const std::string &name) const
-{
- if (actorManager == nullptr)
- return;
-
- const Being *const being = actorManager->findBeingByName(
- name, ActorType::Player);
- if (being != nullptr)
- {
- createOutPacket(CMSG_PARTY_INVITE);
- outMsg.writeBeingId(being->getId(), "account id");
- }
-}
-
-void PartyHandler::inviteResponse(const int partyId A_UNUSED,
- const bool accept) const
-{
- if (localPlayer != nullptr)
- {
- createOutPacket(CMSG_PARTY_INVITED);
- outMsg.writeBeingId(localPlayer->getId(), "account id");
- outMsg.writeInt32(accept ? 1 : 0, "accept");
- }
-}
-
-void PartyHandler::leave() const
-{
- createOutPacket(CMSG_PARTY_LEAVE);
-}
-
-void PartyHandler::kick(const Being *const being) const
-{
- if (being != nullptr)
- {
- createOutPacket(CMSG_PARTY_KICK);
- outMsg.writeBeingId(being->getId(), "account id");
- outMsg.writeString("", 24, "unused");
- }
-}
-
-void PartyHandler::kick(const std::string &name) const
-{
- if (Ea::taParty == nullptr)
- return;
-
- const PartyMember *const m = Ea::taParty->getMember(name);
- if (m == nullptr)
- {
- NotifyManager::notify(NotifyTypes::PARTY_USER_NOT_IN_PARTY, name);
- return;
- }
-
- createOutPacket(CMSG_PARTY_KICK);
- outMsg.writeBeingId(m->getID(), "member id");
- outMsg.writeString(name, 24, "unused");
-}
-
-void PartyHandler::chat(const std::string &text) const
-{
- createOutPacket(CMSG_PARTY_MESSAGE);
- outMsg.writeInt16(CAST_S16(text.length() + 4), "len");
- outMsg.writeString(text, CAST_S32(text.length()), "text");
-}
-
-void PartyHandler::setShareExperience(const PartyShareT share) const
-{
- if (share == PartyShare::NOT_POSSIBLE)
- return;
-
- createOutPacket(CMSG_PARTY_SETTINGS);
- outMsg.writeInt16(CAST_S16(share), "share exp");
- outMsg.writeInt16(CAST_S16(Ea::PartyRecv::mShareItems),
- "share items");
-}
-
-void PartyHandler::setShareItems(const PartyShareT share) const
-{
- if (share == PartyShare::NOT_POSSIBLE)
- return;
-
- createOutPacket(CMSG_PARTY_SETTINGS);
- outMsg.writeInt16(CAST_S16(Ea::PartyRecv::mShareExp),
- "share exp");
- outMsg.writeInt16(CAST_S16(share), "share items");
-}
-
-void PartyHandler::changeLeader(const std::string &name A_UNUSED) const
-{
-}
-
-void PartyHandler::allowInvite(const bool allow A_UNUSED) const
-{
-}
-
-PartyShareT PartyHandler::getShareAutoItems() const
-{
- return PartyShare::NOT_POSSIBLE;
-}
-
-void PartyHandler::setShareAutoItems(const PartyShareT share A_UNUSED) const
-{
-}
-
-} // namespace TmwAthena
diff --git a/src/net/tmwa/partyhandler.h b/src/net/tmwa/partyhandler.h
deleted file mode 100644
index 4942bfc86..000000000
--- a/src/net/tmwa/partyhandler.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 Lloyd Bryant <lloyd_bryant@netzero.net>
- * 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 NET_TMWA_PARTYHANDLER_H
-#define NET_TMWA_PARTYHANDLER_H
-
-#include "net/ea/partyhandler.h"
-
-namespace TmwAthena
-{
-
-class PartyHandler final : public Ea::PartyHandler
-{
- public:
- PartyHandler();
-
- A_DELETE_COPY(PartyHandler)
-
- ~PartyHandler();
-
- void create(const std::string &name) const override final;
-
- void invite(const std::string &name) const override final;
-
- void inviteResponse(const int partyId,
- const bool accept) const override final;
-
- void leave() const override final;
-
- void kick(const Being *const being) const override final;
-
- void kick(const std::string &name) const override final;
-
- void chat(const std::string &text) const override final;
-
- void setShareExperience(const PartyShareT share) const override final;
-
- void setShareItems(const PartyShareT share) const override final;
-
- void changeLeader(const std::string &name) const override final
- A_CONST;
-
- void allowInvite(const bool allow) const override final A_CONST;
-
- void setShareAutoItems(const PartyShareT share) const override final;
-
- PartyShareT getShareAutoItems() const override final A_WARN_UNUSED;
-};
-
-} // namespace TmwAthena
-
-#endif // NET_TMWA_PARTYHANDLER_H
diff --git a/src/net/tmwa/partyrecv.cpp b/src/net/tmwa/partyrecv.cpp
deleted file mode 100644
index b25a501c8..000000000
--- a/src/net/tmwa/partyrecv.cpp
+++ /dev/null
@@ -1,304 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 Lloyd Bryant <lloyd_bryant@netzero.net>
- * 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 "net/tmwa/partyrecv.h"
-
-#include "actormanager.h"
-#include "notifymanager.h"
-#include "party.h"
-
-#include "being/localplayer.h"
-
-#include "enums/resources/notifytypes.h"
-
-#include "gui/windows/chatwindow.h"
-#include "gui/windows/socialwindow.h"
-
-#include "gui/widgets/tabs/chat/partytab.h"
-
-#include "net/messagein.h"
-
-#include "net/ea/partyrecv.h"
-
-#include "utils/foreach.h"
-
-#include "debug.h"
-
-namespace TmwAthena
-{
-
-void PartyRecv::processPartySettings(Net::MessageIn &msg)
-{
- if (partyTab == nullptr)
- {
- if (chatWindow == nullptr)
- return;
-
- Ea::PartyRecv::createTab();
- }
-
- // These seem to indicate the sharing mode for exp and items
- const PartyShareT exp = static_cast<PartyShareT>(
- msg.readInt16("share exp"));
- const PartyShareT item = static_cast<PartyShareT>(
- msg.readInt16("share items"));
- Ea::PartyRecv::processPartyExpSettingsContinue(msg, exp);
- Ea::PartyRecv::processPartyItemSettingsContinue(msg, item);
-}
-
-void PartyRecv::processPartyInfo(Net::MessageIn &msg)
-{
- bool isOldParty = false;
- std::set<std::string> names;
- std::set<std::string> onlineNames;
- if (Ea::taParty == nullptr)
- {
- logger->log1("error: party empty in SMSG_PARTY_INFO");
- Ea::taParty = Party::getParty(1);
- }
- if (Ea::taParty != nullptr)
- {
- if (Ea::taParty->getNumberOfElements() > 1)
- {
- isOldParty = true;
- Ea::taParty->getNamesSet(names);
- const Party::MemberList *const members = Ea::taParty->getMembers();
- FOR_EACHP (Party::MemberList::const_iterator, it, members)
- {
- if ((*it)->getOnline())
- onlineNames.insert((*it)->getName());
- }
- if (localPlayer != nullptr)
- onlineNames.insert(localPlayer->getName());
- }
- }
-
- if (localPlayer == nullptr)
- logger->log1("error: localPlayer==0 in SMSG_PARTY_INFO");
-
- if (Ea::taParty != nullptr)
- Ea::taParty->clearMembers();
-
- const int length = msg.readInt16("len");
- if (Ea::taParty != nullptr)
- Ea::taParty->setName(msg.readString(24, "party name"));
-
- const int count = (length - 28) / 46;
- if ((localPlayer != nullptr) && (Ea::taParty != nullptr))
- {
- localPlayer->setParty(Ea::taParty);
- localPlayer->setPartyName(Ea::taParty->getName());
- }
-
- for (int i = 0; i < count; i++)
- {
- const BeingId id = msg.readBeingId("id");
- std::string nick = msg.readString(24, "nick");
- std::string map = msg.readString(16, "map");
- const bool leader = msg.readUInt8("leader") == 0U;
- const bool online = msg.readUInt8("online") == 0U;
-
- if (Ea::taParty != nullptr)
- {
- bool joined(false);
-
- if (isOldParty)
- {
- if (names.find(nick) == names.end())
- {
- NotifyManager::notify(NotifyTypes::PARTY_USER_JOINED,
- nick);
- joined = true;
- }
- }
- PartyMember *const member = Ea::taParty->addMember(id, nick);
- if (member != nullptr)
- {
- if (!joined && (partyTab != nullptr))
- {
- if (!names.empty() && ((onlineNames.find(nick)
- == onlineNames.end() && online)
- || (onlineNames.find(nick) != onlineNames.end()
- && !online)))
- {
- partyTab->showOnline(nick, fromBool(online, Online));
- }
-
- member->setLeader(leader);
- member->setOnline(online);
- member->setMap(map);
- }
- else
- {
- member->setLeader(leader);
- member->setOnline(online);
- member->setMap(map);
- }
- }
- }
- }
-
- if (Ea::taParty != nullptr)
- Ea::taParty->sort();
-
- if ((localPlayer != nullptr) && (Ea::taParty != nullptr))
- {
- localPlayer->setParty(Ea::taParty);
- localPlayer->setPartyName(Ea::taParty->getName());
- if (socialWindow != nullptr)
- socialWindow->updateParty();
- }
-}
-
-void PartyRecv::processPartyMessage(Net::MessageIn &msg)
-{
- const int msgLength = msg.readInt16("len") - 8;
- if (msgLength <= 0)
- return;
-
- const BeingId id = msg.readBeingId("id");
- const std::string chatMsg = msg.readString(msgLength, "message");
-
- if ((Ea::taParty != nullptr) && (partyTab != nullptr))
- {
- const PartyMember *const member = Ea::taParty->getMember(id);
- if (member != nullptr)
- {
- partyTab->chatLog(member->getName(), chatMsg);
- }
- else
- {
- NotifyManager::notify(NotifyTypes::PARTY_UNKNOWN_USER_MSG,
- chatMsg);
- }
- }
-}
-
-void PartyRecv::processPartyInviteResponse(Net::MessageIn &msg)
-{
- if (partyTab == nullptr)
- return;
-
- const std::string nick = msg.readString(24, "nick");
-
- switch (msg.readUInt8("status"))
- {
- case 0:
- NotifyManager::notify(NotifyTypes::PARTY_INVITE_ALREADY_MEMBER,
- nick);
- break;
- case 1:
- NotifyManager::notify(NotifyTypes::PARTY_INVITE_REFUSED, nick);
- break;
- case 2:
- NotifyManager::notify(NotifyTypes::PARTY_INVITE_DONE, nick);
- break;
- case 3:
- NotifyManager::notify(NotifyTypes::PARTY_INVITE_PARTY_FULL,
- nick);
- break;
- default:
- NotifyManager::notify(NotifyTypes::PARTY_INVITE_ERROR, nick);
- break;
- }
-}
-
-void PartyRecv::processPartyInvited(Net::MessageIn &msg)
-{
- const BeingId id = msg.readBeingId("account id");
- std::string nick;
-
- if (actorManager != nullptr)
- {
- const Being *const being = actorManager->findBeing(id);
- if (being != nullptr)
- {
- if (being->getType() == ActorType::Player)
- nick = being->getName();
- }
- }
-
- if (socialWindow != nullptr)
- {
- const std::string partyName = msg.readString(24, "party name");
- socialWindow->showPartyInvite(partyName, nick, 0);
- }
- else
- {
- msg.readString(24, "party name");
- }
-}
-
-void PartyRecv::processPartyMove(Net::MessageIn &msg)
-{
- const BeingId id = msg.readBeingId("id");
- PartyMember *m = nullptr;
- if (Ea::taParty != nullptr)
- m = Ea::taParty->getMember(id);
- if (m != nullptr)
- {
- msg.readInt32("unused");
- m->setX(msg.readInt16("x"));
- m->setY(msg.readInt16("y"));
- const bool online = msg.readUInt8("online") != 0;
- if (m->getOnline() != online)
- partyTab->showOnline(m->getName(), fromBool(online, Online));
- m->setOnline(online);
- msg.readString(24, "party");
- msg.readString(24, "nick");
- m->setMap(msg.readString(16, "map"));
- }
- else
- {
- msg.readInt32("unused");
- msg.readInt16("x");
- msg.readInt16("y");
- msg.readUInt8("online");
- msg.readString(24, "party");
- msg.readString(24, "nick");
- msg.readString(16, "map");
- }
-}
-
-void PartyRecv::processPartyUpdateHp(Net::MessageIn &msg)
-{
- const BeingId id = msg.readBeingId("id");
- const int hp = msg.readInt16("hp");
- const int maxhp = msg.readInt16("max hp");
- PartyMember *m = nullptr;
- if (Ea::taParty != nullptr)
- m = Ea::taParty->getMember(id);
- if (m != nullptr)
- {
- m->setHp(hp);
- m->setMaxHp(maxhp);
- }
-
- // The server only sends this when the member is in range, so
- // lets make sure they get the party hilight.
- if ((actorManager != nullptr) && (Ea::taParty != nullptr))
- {
- if (Being *const b = actorManager->findBeing(id))
- b->setParty(Ea::taParty);
- }
-}
-
-} // namespace TmwAthena
diff --git a/src/net/tmwa/partyrecv.h b/src/net/tmwa/partyrecv.h
deleted file mode 100644
index 8665df3e8..000000000
--- a/src/net/tmwa/partyrecv.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 Lloyd Bryant <lloyd_bryant@netzero.net>
- * 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 NET_TMWA_PARTYRECV_H
-#define NET_TMWA_PARTYRECV_H
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-namespace TmwAthena
-{
- namespace PartyRecv
- {
- void processPartySettings(Net::MessageIn &msg);
- void processPartyInfo(Net::MessageIn &msg);
- void processPartyMessage(Net::MessageIn &msg);
- void processPartyInviteResponse(Net::MessageIn &msg);
- void processPartyInvited(Net::MessageIn &msg);
- void processPartyMove(Net::MessageIn &msg);
- void processPartyUpdateHp(Net::MessageIn &msg);
- } // namespace PartyRecv
-} // namespace TmwAthena
-
-#endif // NET_TMWA_PARTYRECV_H
diff --git a/src/net/tmwa/pethandler.cpp b/src/net/tmwa/pethandler.cpp
deleted file mode 100644
index c10fd5882..000000000
--- a/src/net/tmwa/pethandler.cpp
+++ /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/>.
- */
-
-#include "net/tmwa/pethandler.h"
-
-#include "debug.h"
-
-namespace TmwAthena
-{
-
-PetHandler::PetHandler() :
- mRandCounter(1000)
-{
- petHandler = this;
-}
-
-PetHandler::~PetHandler()
-{
- petHandler = nullptr;
-}
-
-void PetHandler::move(const int x A_UNUSED,
- const int y A_UNUSED) const
-{
-}
-
-void PetHandler::emote(const uint8_t emoteId A_UNUSED)
-{
-}
-
-void PetHandler::catchPet(const Being *const being A_UNUSED) const
-{
-}
-
-void PetHandler::sendPetMessage(const int data A_UNUSED) const
-{
-}
-
-void PetHandler::setName(const std::string &name A_UNUSED) const
-{
-}
-
-void PetHandler::requestStatus() const
-{
-}
-
-void PetHandler::feed() const
-{
-}
-
-void PetHandler::dropLoot() const
-{
-}
-
-void PetHandler::returnToEgg() const
-{
-}
-
-void PetHandler::unequip() const
-{
-}
-
-void PetHandler::setDirection(const unsigned char type A_UNUSED) const
-{
-}
-
-} // namespace TmwAthena
diff --git a/src/net/tmwa/pethandler.h b/src/net/tmwa/pethandler.h
deleted file mode 100644
index e7a816d21..000000000
--- a/src/net/tmwa/pethandler.h
+++ /dev/null
@@ -1,67 +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 NET_TMWA_PETHANDLER_H
-#define NET_TMWA_PETHANDLER_H
-
-#include "net/pethandler.h"
-
-namespace TmwAthena
-{
-
-class PetHandler final : public Net::PetHandler
-{
- public:
- PetHandler();
-
- A_DELETE_COPY(PetHandler)
-
- ~PetHandler();
-
- void move(const int x,
- const int y) const override final;
-
- void emote(const uint8_t emoteId) override final;
-
- void catchPet(const Being *const being) const override final A_CONST;
-
- void sendPetMessage(const int data) const override final A_CONST;
-
- void setName(const std::string &name) const override final A_CONST;
-
- void requestStatus() const override final A_CONST;
-
- void feed() const override final A_CONST;
-
- void dropLoot() const override final A_CONST;
-
- void returnToEgg() const override final A_CONST;
-
- void unequip() const override final A_CONST;
-
- void setDirection(const unsigned char type) const override final;
-
- protected:
- int mRandCounter;
-};
-
-} // namespace TmwAthena
-
-#endif // NET_TMWA_PETHANDLER_H
diff --git a/src/net/tmwa/playerhandler.cpp b/src/net/tmwa/playerhandler.cpp
deleted file mode 100644
index 4d2e5cc33..000000000
--- a/src/net/tmwa/playerhandler.cpp
+++ /dev/null
@@ -1,422 +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 "net/tmwa/playerhandler.h"
-
-#include "notifymanager.h"
-#include "party.h"
-
-#include "being/localplayer.h"
-#include "being/playerinfo.h"
-
-#include "const/net/nostat.h"
-
-#include "enums/resources/notifytypes.h"
-
-#include "gui/windows/skilldialog.h"
-#include "gui/windows/statuswindow.h"
-
-#include "net/ea/inventoryhandler.h"
-
-#include "net/tmwa/messageout.h"
-#include "net/tmwa/protocolout.h"
-#include "net/tmwa/sp.h"
-
-#include "resources/db/unitsdb.h"
-
-#include "debug.h"
-
-namespace TmwAthena
-{
-
-PlayerHandler::PlayerHandler() :
- Ea::PlayerHandler()
-{
- playerHandler = this;
-}
-
-PlayerHandler::~PlayerHandler()
-{
- playerHandler = nullptr;
-}
-
-void PlayerHandler::attack(const BeingId id,
- const Keep keep) const
-{
- createOutPacket(CMSG_PLAYER_CHANGE_ACT);
- outMsg.writeBeingId(id, "target id");
- if (keep == Keep_true)
- outMsg.writeInt8(7, "action");
- else
- outMsg.writeInt8(0, "action");
-}
-
-void PlayerHandler::stopAttack() const
-{
- createOutPacket(CMSG_PLAYER_STOP_ATTACK);
-}
-
-void PlayerHandler::emote(const uint8_t emoteId) const
-{
- createOutPacket(CMSG_PLAYER_EMOTE);
- outMsg.writeInt8(emoteId, "emote id");
-}
-
-void PlayerHandler::increaseAttribute(const AttributesT attr,
- const int amount A_UNUSED) const
-{
- if (attr >= Attributes::PLAYER_STR && attr <= Attributes::PLAYER_LUK)
- {
- createOutPacket(CMSG_STAT_UPDATE_REQUEST);
- outMsg.writeInt16(CAST_S16(attr), "attribute id");
- outMsg.writeInt8(1, "increment");
- }
-}
-
-void PlayerHandler::increaseSkill(const uint16_t skillId) const
-{
- if (PlayerInfo::getAttribute(Attributes::PLAYER_SKILL_POINTS) <= 0)
- return;
-
- createOutPacket(CMSG_SKILL_LEVELUP_REQUEST);
- outMsg.writeInt16(skillId, "skill id");
-}
-
-void PlayerHandler::pickUp(const FloorItem *const floorItem) const
-{
- if (floorItem == nullptr)
- return;
-
- createOutPacket(CMSG_ITEM_PICKUP);
- outMsg.writeBeingId(floorItem->getId(), "object id");
- Ea::InventoryHandler::pushPickup(floorItem->getId());
-}
-
-void PlayerHandler::setDirection(const unsigned char direction) const
-{
- createOutPacket(CMSG_PLAYER_CHANGE_DIR);
- outMsg.writeInt16(0, "unused");
- outMsg.writeInt8(direction, "direction");
-}
-
-void PlayerHandler::setDestination(const int x, const int y,
- const int direction) const
-{
- createOutPacket(CMSG_PLAYER_CHANGE_DEST);
- outMsg.writeCoordinates(CAST_U16(x),
- CAST_U16(y),
- CAST_U8(direction), "destination");
-}
-
-void PlayerHandler::changeAction(const BeingActionT &action) const
-{
- char type;
- switch (action)
- {
- case BeingAction::SIT:
- type = 2;
- break;
- case BeingAction::STAND:
- case BeingAction::PRESTAND:
- type = 3;
- break;
- default:
- case BeingAction::MOVE:
- case BeingAction::ATTACK:
- case BeingAction::DEAD:
- case BeingAction::HURT:
- case BeingAction::SPAWN:
- case BeingAction::CAST:
- return;
- }
-
- createOutPacket(CMSG_PLAYER_CHANGE_ACT);
- outMsg.writeInt32(0, "unused");
- outMsg.writeInt8(type, "action");
-}
-
-void PlayerHandler::respawn() const
-{
- createOutPacket(CMSG_PLAYER_RESTART);
- outMsg.writeInt8(0, "action");
-}
-
-void PlayerHandler::requestOnlineList() const
-{
-}
-
-void PlayerHandler::removeOption() const
-{
-}
-
-void PlayerHandler::changeCart(const int type A_UNUSED) const
-{
-}
-
-void PlayerHandler::setMemo() const
-{
-}
-
-void PlayerHandler::updateStatus(const uint8_t status A_UNUSED) const
-{
-}
-
-void PlayerHandler::setShortcut(const int idx A_UNUSED,
- const uint8_t type A_UNUSED,
- const int id A_UNUSED,
- const int level A_UNUSED) const
-{
-}
-
-void PlayerHandler::doriDori() const
-{
-}
-
-void PlayerHandler::explosionSpirits() const
-{
-}
-
-void PlayerHandler::requestPvpInfo() const
-{
-}
-
-void PlayerHandler::revive() const
-{
-}
-
-void PlayerHandler::shortcutShiftRow(const int row A_UNUSED) const
-{
-}
-
-void PlayerHandler::setViewEquipment(const bool allow A_UNUSED) const
-{
-}
-
-#define setStatComplex(stat) \
- PlayerInfo::setStatBase(stat, base, notify); \
- if (mod != NoStat) \
- PlayerInfo::setStatMod(stat, mod)
-
-void PlayerHandler::setStat(Net::MessageIn &msg,
- const int type,
- const int base,
- const int mod,
- const Notify notify) const
-{
- switch (type)
- {
- case Sp::SPEED:
- localPlayer->setWalkSpeed(base);
- PlayerInfo::setStatBase(Attributes::PLAYER_WALK_SPEED, base);
- PlayerInfo::setStatMod(Attributes::PLAYER_WALK_SPEED, 0);
- break;
- case Sp::BASEEXP:
- PlayerInfo::setAttribute(Attributes::PLAYER_EXP, base);
- break;
- case Sp::JOBEXP:
- PlayerInfo::setAttribute(Attributes::PLAYER_JOB_EXP, base);
- break;
- case Sp::KARMA:
- PlayerInfo::setStatBase(Attributes::PLAYER_KARMA, base);
- PlayerInfo::setStatMod(Attributes::PLAYER_KARMA, 0);
- break;
- case Sp::MANNER:
- PlayerInfo::setStatBase(Attributes::PLAYER_MANNER, base);
- PlayerInfo::setStatMod(Attributes::PLAYER_MANNER, 0);
- break;
- case Sp::HP:
- PlayerInfo::setAttribute(Attributes::PLAYER_HP, base);
- if (localPlayer->isInParty() && (Party::getParty(1) != nullptr))
- {
- PartyMember *const m = Party::getParty(1)
- ->getMember(localPlayer->getId());
- if (m != nullptr)
- {
- m->setHp(base);
- m->setMaxHp(PlayerInfo::getAttribute(
- Attributes::PLAYER_MAX_HP));
- }
- }
- break;
- case Sp::MAXHP:
- PlayerInfo::setAttribute(Attributes::PLAYER_MAX_HP, base);
-
- if (localPlayer->isInParty() && (Party::getParty(1) != nullptr))
- {
- PartyMember *const m = Party::getParty(1)->getMember(
- localPlayer->getId());
- if (m != nullptr)
- {
- m->setHp(PlayerInfo::getAttribute(Attributes::PLAYER_HP));
- m->setMaxHp(base);
- }
- }
- break;
- case Sp::SP:
- PlayerInfo::setAttribute(Attributes::PLAYER_MP, base);
- break;
- case Sp::MAXSP:
- PlayerInfo::setAttribute(Attributes::PLAYER_MAX_MP, base);
- break;
- case Sp::STATUSPOINT:
- PlayerInfo::setAttribute(Attributes::PLAYER_CHAR_POINTS, base);
- break;
- case Sp::BASELEVEL:
- PlayerInfo::setAttribute(Attributes::PLAYER_BASE_LEVEL, base);
- if (localPlayer != nullptr)
- {
- localPlayer->setLevel(base);
- localPlayer->updateName();
- }
- break;
- case Sp::SKILLPOINT:
- PlayerInfo::setAttribute(Attributes::PLAYER_SKILL_POINTS, base);
- if (skillDialog != nullptr)
- skillDialog->update();
- break;
- case Sp::STR:
- setStatComplex(Attributes::PLAYER_STR);
- break;
- case Sp::AGI:
- setStatComplex(Attributes::PLAYER_AGI);
- break;
- case Sp::VIT:
- setStatComplex(Attributes::PLAYER_VIT);
- break;
- case Sp::INT:
- setStatComplex(Attributes::PLAYER_INT);
- break;
- case Sp::DEX:
- setStatComplex(Attributes::PLAYER_DEX);
- break;
- case Sp::LUK:
- setStatComplex(Attributes::PLAYER_LUK);
- break;
- case Sp::ZENY:
- {
- const int oldMoney = PlayerInfo::getAttribute(Attributes::MONEY);
- const int newMoney = base;
- if (newMoney > oldMoney)
- {
- NotifyManager::notify(NotifyTypes::MONEY_GET,
- UnitsDb::formatCurrency(newMoney - oldMoney));
- }
- else if (newMoney < oldMoney)
- {
- NotifyManager::notify(NotifyTypes::MONEY_SPENT,
- UnitsDb::formatCurrency(oldMoney - newMoney).c_str());
- }
-
- PlayerInfo::setAttribute(Attributes::MONEY, newMoney);
- break;
- }
- case Sp::NEXTBASEEXP:
- PlayerInfo::setAttribute(Attributes::PLAYER_EXP_NEEDED, base);
- break;
- case Sp::JOB_MOD:
- PlayerInfo::setAttribute(Attributes::PLAYER_JOB_EXP_NEEDED, base);
- break;
- case Sp::WEIGHT:
- PlayerInfo::setAttribute(Attributes::TOTAL_WEIGHT, base);
- break;
- case Sp::MAXWEIGHT:
- PlayerInfo::setAttribute(Attributes::MAX_WEIGHT, base);
- break;
- case Sp::USTR:
- statusWindow->setPointsNeeded(Attributes::PLAYER_STR, base);
- break;
- case Sp::UAGI:
- statusWindow->setPointsNeeded(Attributes::PLAYER_AGI, base);
- break;
- case Sp::UVIT:
- statusWindow->setPointsNeeded(Attributes::PLAYER_VIT, base);
- break;
- case Sp::UINT:
- statusWindow->setPointsNeeded(Attributes::PLAYER_INT, base);
- break;
- case Sp::UDEX:
- statusWindow->setPointsNeeded(Attributes::PLAYER_DEX, base);
- break;
- case Sp::ULUK:
- statusWindow->setPointsNeeded(Attributes::PLAYER_LUK, base);
- break;
-
- case Sp::ATK1:
- PlayerInfo::setStatBase(Attributes::PLAYER_ATK, base);
- PlayerInfo::updateAttrs();
- break;
- case Sp::ATK2:
- PlayerInfo::setStatMod(Attributes::PLAYER_ATK, base);
- PlayerInfo::updateAttrs();
- break;
- case Sp::MATK1:
- PlayerInfo::setStatBase(Attributes::PLAYER_MATK, base);
- break;
- case Sp::MATK2:
- PlayerInfo::setStatMod(Attributes::PLAYER_MATK, base);
- break;
- case Sp::DEF1:
- PlayerInfo::setStatBase(Attributes::PLAYER_DEF, base);
- break;
- case Sp::DEF2:
- PlayerInfo::setStatMod(Attributes::PLAYER_DEF, base);
- break;
- case Sp::MDEF1:
- PlayerInfo::setStatBase(Attributes::PLAYER_MDEF, base);
- break;
- case Sp::MDEF2:
- PlayerInfo::setStatMod(Attributes::PLAYER_MDEF, base);
- break;
- case Sp::HIT:
- PlayerInfo::setStatBase(Attributes::PLAYER_HIT, base);
- break;
- case Sp::FLEE1:
- PlayerInfo::setStatBase(Attributes::PLAYER_FLEE, base);
- break;
- case Sp::FLEE2:
- PlayerInfo::setStatMod(Attributes::PLAYER_FLEE, base);
- break;
- case Sp::CRITICAL:
- PlayerInfo::setStatBase(Attributes::PLAYER_CRIT, base);
- break;
- case Sp::ASPD:
- localPlayer->setAttackSpeed(base);
- PlayerInfo::setStatBase(Attributes::PLAYER_ATTACK_DELAY, base);
- PlayerInfo::setStatMod(Attributes::PLAYER_ATTACK_DELAY, 0);
- PlayerInfo::updateAttrs();
- break;
- case Sp::JOBLEVEL:
- PlayerInfo::setAttribute(Attributes::PLAYER_JOB_LEVEL, base);
- break;
- case Sp::GM_LEVEL:
- localPlayer->setGroupId(base);
- break;
-
- default:
- UNIMPLEMENTEDPACKETFIELD(type);
- break;
- }
-}
-
-#undef setStatComplex
-
-} // namespace TmwAthena
diff --git a/src/net/tmwa/playerhandler.h b/src/net/tmwa/playerhandler.h
deleted file mode 100644
index 898a03057..000000000
--- a/src/net/tmwa/playerhandler.h
+++ /dev/null
@@ -1,92 +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 NET_TMWA_PLAYERHANDLER_H
-#define NET_TMWA_PLAYERHANDLER_H
-
-#include "net/ea/playerhandler.h"
-
-namespace TmwAthena
-{
-
-class PlayerHandler final : public Ea::PlayerHandler
-{
- public:
- PlayerHandler();
-
- A_DELETE_COPY(PlayerHandler)
-
- ~PlayerHandler();
-
- void attack(const BeingId id,
- const Keep keep) const override final;
- void stopAttack() const override final;
- void emote(const uint8_t emoteId) const override final;
-
- void increaseAttribute(const AttributesT attr,
- const int amount) const override final;
- void increaseSkill(const uint16_t skillId) const override final;
-
- void pickUp(const FloorItem *const floorItem) const override final;
- void setDirection(const unsigned char direction) const override final;
- void setDestination(const int x, const int y,
- const int direction) const override final;
- void changeAction(const BeingActionT &action)
- const override final;
- void requestOnlineList() const override final A_CONST;
- void updateStatus(const uint8_t status) const override final A_CONST;
-
- void respawn() const override final;
-
- void setShortcut(const int idx,
- const uint8_t type,
- const int id,
- const int level) const override final A_CONST;
-
- void shortcutShiftRow(const int row) const override final;
-
- void removeOption() const override final A_CONST;
-
- void changeCart(const int type) const override final A_CONST;
-
- void setMemo() const override final A_CONST;
-
- void doriDori() const override final A_CONST;
-
- void explosionSpirits() const override final A_CONST;
-
- void requestPvpInfo() const override final A_CONST;
-
- void revive() const override final A_CONST;
-
- void setViewEquipment(const bool allow) const override final A_CONST;
-
- void setStat(Net::MessageIn &msg,
- const int type,
- const int base,
- const int mod,
- const Notify notify) const override final;
-};
-
-} // namespace TmwAthena
-
-#endif // NET_TMWA_PLAYERHANDLER_H
diff --git a/src/net/tmwa/playerrecv.cpp b/src/net/tmwa/playerrecv.cpp
deleted file mode 100644
index b6b23403f..000000000
--- a/src/net/tmwa/playerrecv.cpp
+++ /dev/null
@@ -1,165 +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 "net/tmwa/playerrecv.h"
-
-#include "being/localplayer.h"
-#include "being/playerinfo.h"
-
-#include "gui/windows/statuswindow.h"
-
-#include "net/messagein.h"
-
-#include "debug.h"
-
-namespace TmwAthena
-{
-
-void PlayerRecv::processPlayerStatUpdate5(Net::MessageIn &msg)
-{
- BLOCK_START("PlayerRecv::processPlayerStatUpdate5")
- PlayerInfo::setAttribute(Attributes::PLAYER_CHAR_POINTS,
- msg.readInt16("char points"));
-
- unsigned int val = msg.readUInt8("str");
- PlayerInfo::setStatBase(Attributes::PLAYER_STR, val);
- if (statusWindow != nullptr)
- {
- statusWindow->setPointsNeeded(Attributes::PLAYER_STR,
- msg.readUInt8("str cost"));
- }
- else
- {
- msg.readUInt8("str cost");
- }
-
- val = msg.readUInt8("agi");
- PlayerInfo::setStatBase(Attributes::PLAYER_AGI, val);
- if (statusWindow != nullptr)
- {
- statusWindow->setPointsNeeded(Attributes::PLAYER_AGI,
- msg.readUInt8("agi cost"));
- }
- else
- {
- msg.readUInt8("agi cost");
- }
-
- val = msg.readUInt8("vit");
- PlayerInfo::setStatBase(Attributes::PLAYER_VIT, val);
- if (statusWindow != nullptr)
- {
- statusWindow->setPointsNeeded(Attributes::PLAYER_VIT,
- msg.readUInt8("vit cost"));
- }
- else
- {
- msg.readUInt8("vit cost");
- }
-
- val = msg.readUInt8("int");
- PlayerInfo::setStatBase(Attributes::PLAYER_INT, val);
- if (statusWindow != nullptr)
- {
- statusWindow->setPointsNeeded(Attributes::PLAYER_INT,
- msg.readUInt8("int cost"));
- }
- else
- {
- msg.readUInt8("int cost");
- }
-
- val = msg.readUInt8("dex");
- PlayerInfo::setStatBase(Attributes::PLAYER_DEX, val);
- if (statusWindow != nullptr)
- {
- statusWindow->setPointsNeeded(Attributes::PLAYER_DEX,
- msg.readUInt8("dex cost"));
- }
- else
- {
- msg.readUInt8("dex cost");
- }
-
- val = msg.readUInt8("luk");
- PlayerInfo::setStatBase(Attributes::PLAYER_LUK, val);
- if (statusWindow != nullptr)
- {
- statusWindow->setPointsNeeded(Attributes::PLAYER_LUK,
- msg.readUInt8("luk cost"));
- }
- else
- {
- msg.readUInt8("luk cost");
- }
-
- PlayerInfo::setStatBase(Attributes::PLAYER_ATK,
- msg.readInt16("atk"), Notify_false);
- PlayerInfo::setStatMod(Attributes::PLAYER_ATK, msg.readInt16("atk+"));
- PlayerInfo::updateAttrs();
-
- val = msg.readInt16("matk");
- PlayerInfo::setStatBase(Attributes::PLAYER_MATK, val, Notify_false);
-
- val = msg.readInt16("matk+");
- PlayerInfo::setStatMod(Attributes::PLAYER_MATK, val);
-
- PlayerInfo::setStatBase(Attributes::PLAYER_DEF,
- msg.readInt16("def"), Notify_false);
- PlayerInfo::setStatMod(Attributes::PLAYER_DEF, msg.readInt16("def+"));
-
- PlayerInfo::setStatBase(Attributes::PLAYER_MDEF,
- msg.readInt16("mdef"), Notify_false);
- PlayerInfo::setStatMod(Attributes::PLAYER_MDEF, msg.readInt16("mdef+"));
-
- PlayerInfo::setStatBase(Attributes::PLAYER_HIT, msg.readInt16("hit"));
-
- PlayerInfo::setStatBase(Attributes::PLAYER_FLEE,
- msg.readInt16("flee"), Notify_false);
- PlayerInfo::setStatMod(Attributes::PLAYER_FLEE, msg.readInt16("flee+"));
-
- PlayerInfo::setStatBase(Attributes::PLAYER_CRIT, msg.readInt16("crit"));
-
- PlayerInfo::setStatBase(Attributes::PLAYER_MANNER,
- msg.readInt16("manner"));
- msg.readInt16("unused?");
- BLOCK_END("PlayerRecv::processPlayerStatUpdate5")
-}
-
-void PlayerRecv::processWalkResponse(Net::MessageIn &msg)
-{
- BLOCK_START("PlayerRecv::processWalkResponse")
- /*
- * This client assumes that all walk messages succeed,
- * and that the server will send a correction notice
- * otherwise.
- */
- uint16_t srcX, srcY, dstX, dstY;
- msg.readInt32("tick");
- msg.readCoordinatePair(srcX, srcY, dstX, dstY, "move path");
- msg.readUInt8("unused");
- if (localPlayer != nullptr)
- localPlayer->setRealPos(dstX, dstY);
- BLOCK_END("PlayerRecv::processWalkResponse")
-}
-
-} // namespace TmwAthena
diff --git a/src/net/tmwa/playerrecv.h b/src/net/tmwa/playerrecv.h
deleted file mode 100644
index 626114640..000000000
--- a/src/net/tmwa/playerrecv.h
+++ /dev/null
@@ -1,40 +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 NET_TMWA_PLAYERRECV_H
-#define NET_TMWA_PLAYERRECV_H
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-namespace TmwAthena
-{
- namespace PlayerRecv
- {
- void processPlayerStatUpdate5(Net::MessageIn &msg);
- void processWalkResponse(Net::MessageIn &msg);
- } // namespace PlayerRecv
-} // namespace TmwAthena
-
-#endif // NET_TMWA_PLAYERRECV_H
diff --git a/src/net/tmwa/protocolout.cpp b/src/net/tmwa/protocolout.cpp
deleted file mode 100644
index 38cee1227..000000000
--- a/src/net/tmwa/protocolout.cpp
+++ /dev/null
@@ -1,30 +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/>.
- */
-
-namespace TmwAthena
-{
-#include "net/protocoloutdefine.h"
-#include "net/tmwa/packetsout.inc"
-#undef packet
-PROTOCOLOUT_VOID
-PACKETSOUT_VOID
-} // namespace TmwAthena
-
-#include "debug.h"
diff --git a/src/net/tmwa/protocolout.h b/src/net/tmwa/protocolout.h
deleted file mode 100644
index 08ce043fc..000000000
--- a/src/net/tmwa/protocolout.h
+++ /dev/null
@@ -1,40 +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 NET_TMWA_PROTOCOLOUT_H
-#define NET_TMWA_PROTOCOLOUT_H
-
-#include "net/protocoloutinclude.h"
-
-#define PROTOCOLOUT_VOID
-
-namespace TmwAthena
-{
-#include "net/tmwa/packetsout.inc"
-PACKETSOUT_VOID
-} // namespace TmwAthena
-
-#undef packet
-#undef packet2
-#undef startCondition
-#undef endCondition
-#undef PACKETSOUT_VOID
-
-#endif // NET_TMWA_PROTOCOLOUT_H
diff --git a/src/net/tmwa/questhandler.cpp b/src/net/tmwa/questhandler.cpp
deleted file mode 100644
index 1acc60740..000000000
--- a/src/net/tmwa/questhandler.cpp
+++ /dev/null
@@ -1,44 +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 "net/tmwa/questhandler.h"
-
-#include "debug.h"
-
-namespace TmwAthena
-{
-
-QuestHandler::QuestHandler() :
- Net::QuestHandler()
-{
- questHandler = this;
-}
-
-QuestHandler::~QuestHandler()
-{
- questHandler = nullptr;
-}
-
-void QuestHandler::setQeustActiveState(const int questId A_UNUSED,
- const bool active A_UNUSED) const
-{
-}
-
-} // namespace TmwAthena
diff --git a/src/net/tmwa/questhandler.h b/src/net/tmwa/questhandler.h
deleted file mode 100644
index 4c56ef0c9..000000000
--- a/src/net/tmwa/questhandler.h
+++ /dev/null
@@ -1,45 +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 NET_TMWA_QUESTHANDLER_H
-#define NET_TMWA_QUESTHANDLER_H
-
-#include "net/questhandler.h"
-
-namespace TmwAthena
-{
-
-class QuestHandler final : public Net::QuestHandler
-{
- public:
- QuestHandler();
-
- A_DELETE_COPY(QuestHandler)
-
- ~QuestHandler();
-
- void setQeustActiveState(const int questId,
- const bool active) const override final
- A_CONST;
-};
-
-} // namespace TmwAthena
-
-#endif // NET_TMWA_QUESTHANDLER_H
diff --git a/src/net/tmwa/questrecv.cpp b/src/net/tmwa/questrecv.cpp
deleted file mode 100644
index d38012a69..000000000
--- a/src/net/tmwa/questrecv.cpp
+++ /dev/null
@@ -1,67 +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 "net/tmwa/questrecv.h"
-
-#include "gui/windows/skilldialog.h"
-#include "gui/windows/questswindow.h"
-
-#include "net/messagein.h"
-
-#include "const/resources/skill.h"
-
-#include "debug.h"
-
-namespace TmwAthena
-{
-
-void QuestRecv::processSetQuestVar(Net::MessageIn &msg)
-{
- const int var = msg.readInt16("variable");
- const int val = msg.readInt32("value");
- if (questsWindow != nullptr)
- {
- questsWindow->updateQuest(var, val, 0, 0, 0);
- questsWindow->rebuild(true);
- }
- if (skillDialog != nullptr)
- {
- skillDialog->updateQuest(var, val, 0, 0, 0);
- skillDialog->playUpdateEffect(var + SKILL_VAR_MIN_ID);
- }
-}
-
-void QuestRecv::processPlayerQuests(Net::MessageIn &msg)
-{
- const int count = (msg.readInt16("len") - 4) / 6;
- for (int f = 0; f < count; f ++)
- {
- const int var = msg.readInt16("variable");
- const int val = msg.readInt32("value");
- if (questsWindow != nullptr)
- questsWindow->updateQuest(var, val, 0, 0, 0);
- if (skillDialog != nullptr)
- skillDialog->updateQuest(var, val, 0, 0, 0);
- }
- if (questsWindow != nullptr)
- questsWindow->rebuild(false);
-}
-
-} // namespace TmwAthena
diff --git a/src/net/tmwa/questrecv.h b/src/net/tmwa/questrecv.h
deleted file mode 100644
index 3e9d958ea..000000000
--- a/src/net/tmwa/questrecv.h
+++ /dev/null
@@ -1,38 +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 NET_TMWA_QUESTRECV_H
-#define NET_TMWA_QUESTRECV_H
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-namespace TmwAthena
-{
- namespace QuestRecv
- {
- void processSetQuestVar(Net::MessageIn &msg);
- void processPlayerQuests(Net::MessageIn &msg);
- } // namespace QuestRecv
-} // namespace TmwAthena
-
-#endif // NET_TMWA_QUESTRECV_H
diff --git a/src/net/tmwa/recvpackets.inc b/src/net/tmwa/recvpackets.inc
deleted file mode 100644
index 808019018..000000000
--- a/src/net/tmwa/recvpackets.inc
+++ /dev/null
@@ -1,32 +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 NET_TMWA_RECVPACKETS_H
-#define NET_TMWA_RECVPACKETS_H
-
-#define RECVPACKETS_VOID
-
-#include "net/recvpacketdefine.h"
-
-#include "net/tmwa/packetsin.inc"
-
-#undef packet
-
-#endif // NET_TMWA_RECVPACKETS_H
diff --git a/src/net/tmwa/roulettehandler.cpp b/src/net/tmwa/roulettehandler.cpp
deleted file mode 100644
index 03b1afd8a..000000000
--- a/src/net/tmwa/roulettehandler.cpp
+++ /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/>.
- */
-
-#include "net/tmwa/roulettehandler.h"
-
-#include "debug.h"
-
-namespace TmwAthena
-{
-
-RouletteHandler::RouletteHandler() :
- Net::RouletteHandler()
-{
- rouletteHandler = this;
-}
-
-RouletteHandler::~RouletteHandler()
-{
- rouletteHandler = nullptr;
-}
-
-} // namespace TmwAthena
diff --git a/src/net/tmwa/roulettehandler.h b/src/net/tmwa/roulettehandler.h
deleted file mode 100644
index b575d3ca3..000000000
--- a/src/net/tmwa/roulettehandler.h
+++ /dev/null
@@ -1,40 +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 NET_TMWA_ROULETTEHANDLER_H
-#define NET_TMWA_ROULETTEHANDLER_H
-
-#include "net/roulettehandler.h"
-
-namespace TmwAthena
-{
-class RouletteHandler final : public Net::RouletteHandler
-{
- public:
- RouletteHandler();
-
- A_DELETE_COPY(RouletteHandler)
-
- ~RouletteHandler();
-};
-
-} // namespace TmwAthena
-
-#endif // NET_TMWA_ROULETTEHANDLER_H
diff --git a/src/net/tmwa/searchstorehandler.cpp b/src/net/tmwa/searchstorehandler.cpp
deleted file mode 100644
index 34f41fb8a..000000000
--- a/src/net/tmwa/searchstorehandler.cpp
+++ /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/>.
- */
-
-#include "net/tmwa/searchstorehandler.h"
-
-#include "debug.h"
-
-namespace TmwAthena
-{
-
-SearchStoreHandler::SearchStoreHandler() :
- Net::SearchStoreHandler()
-{
- searchStoreHandler = this;
-}
-
-SearchStoreHandler::~SearchStoreHandler()
-{
- searchStoreHandler = nullptr;
-}
-
-void SearchStoreHandler::search(const StoreSearchTypeT type A_UNUSED,
- const int minPrice A_UNUSED,
- const int maxPrice A_UNUSED,
- const int itemId A_UNUSED) const
-{
-}
-
-void SearchStoreHandler::nextPage() const
-{
-}
-
-void SearchStoreHandler::close() const
-{
-}
-
-void SearchStoreHandler::select(const int accountId A_UNUSED,
- const int storeId A_UNUSED,
- const int itemId A_UNUSED) const
-{
-}
-
-} // namespace TmwAthena
diff --git a/src/net/tmwa/searchstorehandler.h b/src/net/tmwa/searchstorehandler.h
deleted file mode 100644
index 20112fcb1..000000000
--- a/src/net/tmwa/searchstorehandler.h
+++ /dev/null
@@ -1,53 +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 NET_TMWA_SEARCHSTOREHANDLER_H
-#define NET_TMWA_SEARCHSTOREHANDLER_H
-
-#include "net/searchstorehandler.h"
-
-namespace TmwAthena
-{
-class SearchStoreHandler final : public Net::SearchStoreHandler
-{
- public:
- SearchStoreHandler();
-
- A_DELETE_COPY(SearchStoreHandler)
-
- ~SearchStoreHandler();
-
- void search(const StoreSearchTypeT type,
- const int minPrice,
- const int maxPrice,
- const int itemId) const override final A_CONST;
-
- void nextPage() const override final A_CONST;
-
- void close() const override final A_CONST;
-
- void select(const int accountId,
- const int storeId,
- const int itemId) const override final A_CONST;
-};
-
-} // namespace TmwAthena
-
-#endif // NET_TMWA_SEARCHSTOREHANDLER_H
diff --git a/src/net/tmwa/serverfeatures.cpp b/src/net/tmwa/serverfeatures.cpp
deleted file mode 100644
index 5af454314..000000000
--- a/src/net/tmwa/serverfeatures.cpp
+++ /dev/null
@@ -1,151 +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 "net/tmwa/serverfeatures.h"
-
-#include "debug.h"
-
-extern unsigned int tmwServerVersion;
-
-namespace TmwAthena
-{
-
-ServerFeatures::ServerFeatures() :
- Net::ServerFeatures()
-{
- serverFeatures = this;
-}
-
-bool ServerFeatures::haveServerOnlineList() const
-{
- return false;
-}
-
-bool ServerFeatures::haveServerHp() const
-{
- return tmwServerVersion > 0x0f0513;
-}
-
-bool ServerFeatures::havePlayerStatusUpdate() const
-{
- return false;
-}
-
-bool ServerFeatures::haveIncompleteChatMessages() const
-{
- return tmwServerVersion <= 0x100209;
-}
-
-bool ServerFeatures::haveRaceSelection() const
-{
- return false;
-}
-
-bool ServerFeatures::haveLookSelection() const
-{
- return false;
-}
-
-bool ServerFeatures::haveMove3() const
-{
- return tmwServerVersion >= 0x0f0512 && tmwServerVersion <= 0xf0706;
-}
-
-bool ServerFeatures::haveCharOtherGender() const
-{
- return tmwServerVersion > 0x0f0b17;
-}
-
-bool ServerFeatures::haveMonsterAttackRange() const
-{
- return tmwServerVersion >= 0x0f0513;
-}
-
-bool ServerFeatures::haveEmailOnRegister() const
-{
- return false;
-}
-
-bool ServerFeatures::haveEmailOnDelete() const
-{
- return false;
-}
-
-bool ServerFeatures::haveServerVersion() const
-{
- return true;
-}
-
-bool ServerFeatures::haveMapServerVersion() const
-{
- return false;
-}
-
-bool ServerFeatures::haveNpcGender() const
-{
- return tmwServerVersion >= 0x0f0513;
-}
-
-bool ServerFeatures::haveJoinChannel() const
-{
- return false;
-}
-
-bool ServerFeatures::haveCreateCharGender() const
-{
- return tmwServerVersion > 0x0f0b17;
-}
-
-bool ServerFeatures::haveTalkPet() const
-{
- return true;
-}
-
-bool ServerFeatures::haveMovePet() const
-{
- return true;
-}
-
-bool ServerFeatures::haveServerWarpNames() const
-{
- return false;
-}
-
-bool ServerFeatures::haveExtendedRiding() const
-{
- return false;
-}
-
-bool ServerFeatures::haveExtendedDropsPosition() const
-{
- return false;
-}
-
-bool ServerFeatures::haveMoveWhileSit() const
-{
- return true;
-}
-
-bool ServerFeatures::haveKillerId() const
-{
- return false;
-}
-
-} // namespace TmwAthena
diff --git a/src/net/tmwa/serverfeatures.h b/src/net/tmwa/serverfeatures.h
deleted file mode 100644
index 95371c1b3..000000000
--- a/src/net/tmwa/serverfeatures.h
+++ /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/>.
- */
-
-#ifndef NET_TMWA_SERVERFEATURES_H
-#define NET_TMWA_SERVERFEATURES_H
-
-#include "net/serverfeatures.h"
-
-#include "localconsts.h"
-
-namespace TmwAthena
-{
-class ServerFeatures final : public Net::ServerFeatures
-{
- public:
- ServerFeatures();
-
- A_DELETE_COPY(ServerFeatures)
-
- bool haveServerOnlineList() const override final A_CONST;
-
- bool haveServerHp() const override final;
-
- bool havePlayerStatusUpdate() const override final A_CONST;
-
- bool haveIncompleteChatMessages() const override final;
-
- bool haveRaceSelection() const override final A_CONST;
-
- bool haveLookSelection() const override final A_CONST;
-
- bool haveMove3() const override final;
-
- bool haveCharOtherGender() const override final;
-
- bool haveMonsterAttackRange() const override final;
-
- bool haveEmailOnRegister() const override final A_CONST;
-
- bool haveEmailOnDelete() const override final A_CONST;
-
- bool haveServerVersion() const override final A_CONST;
-
- bool haveMapServerVersion() const override final A_CONST;
-
- bool haveNpcGender() const override final;
-
- bool haveJoinChannel() const override final A_CONST;
-
- bool haveCreateCharGender() const override final;
-
- bool haveTalkPet() const override final A_CONST;
-
- bool haveMovePet() const override final A_CONST;
-
- bool haveServerWarpNames() const override final A_CONST;
-
- bool haveExtendedRiding() const override final A_CONST;
-
- bool haveExtendedDropsPosition() const override final A_CONST;
-
- bool haveMoveWhileSit() const override final A_CONST;
-
- bool haveKillerId() const override final A_CONST;
-};
-
-} // namespace TmwAthena
-
-#endif // NET_TMWA_SERVERFEATURES_H
diff --git a/src/net/tmwa/skillhandler.cpp b/src/net/tmwa/skillhandler.cpp
deleted file mode 100644
index 9f8de7b2f..000000000
--- a/src/net/tmwa/skillhandler.cpp
+++ /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/>.
- */
-
-#include "net/tmwa/skillhandler.h"
-
-#include "net/tmwa/messageout.h"
-#include "net/tmwa/protocolout.h"
-
-#include "debug.h"
-
-namespace TmwAthena
-{
-
-SkillHandler::SkillHandler() :
- Ea::SkillHandler()
-{
- skillHandler = this;
-}
-
-SkillHandler::~SkillHandler()
-{
- skillHandler = nullptr;
-}
-
-void SkillHandler::useBeing(const int id, const int level,
- const BeingId beingId) const
-{
- createOutPacket(CMSG_SKILL_USE_BEING);
- outMsg.writeInt16(CAST_S16(id), "skill id");
- outMsg.writeInt16(CAST_S16(level), "level");
- outMsg.writeBeingId(beingId, "target id");
-}
-
-void SkillHandler::usePos(const int id, const int level,
- const int x, const int y) const
-{
- createOutPacket(CMSG_SKILL_USE_POSITION);
- outMsg.writeInt16(CAST_S16(level), "skill level");
- outMsg.writeInt16(CAST_S16(id), "skill id");
- outMsg.writeInt16(CAST_S16(x), "x");
- outMsg.writeInt16(CAST_S16(y), "y");
-}
-
-void SkillHandler::usePos(const int id, const int level,
- const int x, const int y,
- const std::string &text) const
-{
- createOutPacket(CMSG_SKILL_USE_POSITION_MORE);
- outMsg.writeInt16(CAST_S16(level), "skill level");
- outMsg.writeInt16(CAST_S16(id), "skill id");
- outMsg.writeInt16(CAST_S16(x), "x");
- outMsg.writeInt16(CAST_S16(y), "y");
- outMsg.writeString(text, 80, "text");
-}
-
-void SkillHandler::useMap(const int id, const std::string &map) const
-{
- createOutPacket(CMSG_SKILL_USE_MAP);
- outMsg.writeInt16(CAST_S16(id), "skill id");
- outMsg.writeString(map, 16, "map name");
-}
-
-void SkillHandler::getAlchemistRanks() const
-{
-}
-
-void SkillHandler::getBlacksmithRanks() const
-{
-}
-
-void SkillHandler::getPkRanks() const
-{
-}
-
-void SkillHandler::getTaekwonRanks() const
-{
-}
-
-void SkillHandler::feelSaveOk(const int which A_UNUSED) const
-{
-}
-
-void SkillHandler::lessEffects(const bool isLess A_UNUSED) const
-{
-}
-
-} // namespace TmwAthena
diff --git a/src/net/tmwa/skillhandler.h b/src/net/tmwa/skillhandler.h
deleted file mode 100644
index 324774bea..000000000
--- a/src/net/tmwa/skillhandler.h
+++ /dev/null
@@ -1,70 +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 NET_TMWA_SKILLHANDLER_H
-#define NET_TMWA_SKILLHANDLER_H
-
-#include "net/ea/skillhandler.h"
-
-namespace TmwAthena
-{
-
-class SkillHandler final : public Ea::SkillHandler
-{
- public:
- SkillHandler();
-
- A_DELETE_COPY(SkillHandler)
-
- ~SkillHandler();
-
- void useBeing(const int id,
- const int level,
- const BeingId beingId) const override final;
-
- void usePos(const int id,
- const int level,
- const int x, const int y) const override final;
-
- void usePos(const int id,
- const int level,
- const int x, const int y,
- const std::string &text) const override final;
-
- void useMap(const int id, const std::string &map) const override final;
-
- void getAlchemistRanks() const override final;
-
- void getBlacksmithRanks() const override final;
-
- void getPkRanks() const override final;
-
- void getTaekwonRanks() const override final;
-
- void feelSaveOk(const int which) const override final;
-
- void lessEffects(const bool isLess) const override final;
-};
-
-} // namespace TmwAthena
-
-#endif // NET_TMWA_SKILLHANDLER_H
diff --git a/src/net/tmwa/skillrecv.cpp b/src/net/tmwa/skillrecv.cpp
deleted file mode 100644
index faea79059..000000000
--- a/src/net/tmwa/skillrecv.cpp
+++ /dev/null
@@ -1,217 +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 "net/tmwa/skillrecv.h"
-
-#include "notifymanager.h"
-
-#include "being/localplayer.h"
-#include "being/playerinfo.h"
-
-#include "const/net/skill.h"
-
-#include "enums/resources/notifytypes.h"
-
-#include "gui/windows/skilldialog.h"
-
-#include "net/messagein.h"
-
-#include "utils/gettext.h"
-
-#include "debug.h"
-
-namespace TmwAthena
-{
-
-void SkillRecv::processPlayerSkills(Net::MessageIn &msg)
-{
- msg.readInt16("len");
- const int skillCount = (msg.getLength() - 4) / 37;
- int updateSkill = 0;
-
- for (int k = 0; k < skillCount; k++)
- {
- const int skillId = msg.readInt16("skill id");
- const SkillType::SkillType inf = static_cast<SkillType::SkillType>(
- msg.readInt16("inf"));
- msg.readInt16("skill pool flags");
- const int level = msg.readInt16("skill level");
- const int sp = msg.readInt16("sp");
- const int range = msg.readInt16("range");
- msg.skip(24, "unused");
- const Modifiable up = fromBool(msg.readUInt8("up flag"), Modifiable);
- const int oldLevel = PlayerInfo::getSkillLevel(skillId);
- if ((oldLevel != 0) && oldLevel != level)
- updateSkill = skillId;
- PlayerInfo::setSkillLevel(skillId, level);
- if (skillDialog != nullptr)
- {
- if (!skillDialog->updateSkill(skillId, range, up, inf, sp))
- {
- skillDialog->addSkill(SkillOwner::Player,
- skillId, "", level, range, up, inf, sp);
- }
- }
- }
- if (skillDialog != nullptr)
- {
- skillDialog->update();
- if (updateSkill != 0)
- skillDialog->playUpdateEffect(updateSkill);
- }
-}
-
-void SkillRecv::processSkillFailed(Net::MessageIn &msg)
-{
- // Action failed (ex. sit because you have not reached the
- // right level)
- const int skillId = msg.readInt16("skill id");
- const int16_t bskill = msg.readInt16("bskill");
- msg.readInt16("btype");
- const signed char success = msg.readUInt8("success");
- const signed char reason = msg.readUInt8("reason");
- if (success != CAST_S32(SKILL_FAILED)
- && bskill == CAST_S32(BSKILL_EMOTE))
- {
- logger->log("Action: %d/%d", bskill, success);
- }
-
- std::string txt;
- if (success == CAST_S32(SKILL_FAILED)
- && skillId == CAST_S32(SKILL_BASIC))
- {
- if ((localPlayer != nullptr) &&
- bskill == CAST_S32(BSKILL_EMOTE) &&
- reason == CAST_S32(RFAIL_SKILLDEP))
- {
- localPlayer->stopAdvert();
- }
-
- switch (bskill)
- {
- case BSKILL_TRADE:
- // TRANSLATORS: error message
- txt = _("Trade failed!");
- break;
- case BSKILL_EMOTE:
- // TRANSLATORS: error message
- txt = _("Emote failed!");
- break;
- case BSKILL_SIT:
- // TRANSLATORS: error message
- txt = _("Sit failed!");
- break;
- case BSKILL_CREATECHAT:
- // TRANSLATORS: error message
- txt = _("Chat creating failed!");
- break;
- case BSKILL_JOINPARTY:
- // TRANSLATORS: error message
- txt = _("Could not join party!");
- break;
- case BSKILL_SHOUT:
- // TRANSLATORS: error message
- txt = _("Cannot shout!");
- break;
- default:
- UNIMPLEMENTEDPACKETFIELD(bskill);
- break;
- }
-
- txt.append(" ");
-
- switch (reason)
- {
- case RFAIL_SKILLDEP:
- // TRANSLATORS: error message
- txt.append(_("You have not yet reached a high enough lvl!"));
- break;
- case RFAIL_INSUFHP:
- // TRANSLATORS: error message
- txt.append(_("Insufficient HP!"));
- break;
- case RFAIL_INSUFSP:
- // TRANSLATORS: error message
- txt.append(_("Insufficient SP!"));
- break;
- case RFAIL_NOMEMO:
- // TRANSLATORS: error message
- txt.append(_("You have no memos!"));
- break;
- case RFAIL_SKILLDELAY:
- // TRANSLATORS: error message
- txt.append(_("You cannot do that right now!"));
- break;
- case RFAIL_ZENY:
- // TRANSLATORS: error message
- txt.append(_("Seems you need more money... ;-)"));
- break;
- case RFAIL_WEAPON:
- // TRANSLATORS: error message
- txt.append(_("You cannot use this skill with that "
- "kind of weapon!"));
- break;
- case RFAIL_REDGEM:
- // TRANSLATORS: error message
- txt.append(_("You need another red gem!"));
- break;
- case RFAIL_BLUEGEM:
- // TRANSLATORS: error message
- txt.append(_("You need another blue gem!"));
- break;
- case RFAIL_OVERWEIGHT:
- // TRANSLATORS: error message
- txt.append(_("You're carrying to much to do this!"));
- break;
- default:
- // TRANSLATORS: error message
- txt.append(_("Huh? What's that?"));
- UNIMPLEMENTEDPACKETFIELD(reason);
- break;
- }
- }
- else
- {
- switch (skillId)
- {
- case SKILL_WARP :
- // TRANSLATORS: error message
- txt = _("Warp failed...");
- break;
- case SKILL_STEAL :
- // TRANSLATORS: error message
- txt = _("Could not steal anything...");
- break;
- case SKILL_ENVENOM :
- // TRANSLATORS: error message
- txt = _("Poison had no effect...");
- break;
- default:
- UNIMPLEMENTEDPACKETFIELD(skillId);
- break;
- }
- }
-
- NotifyManager::notify(NotifyTypes::SKILL_FAIL_MESSAGE, txt);
-}
-
-} // namespace TmwAthena
diff --git a/src/net/tmwa/skillrecv.h b/src/net/tmwa/skillrecv.h
deleted file mode 100644
index f63d883c2..000000000
--- a/src/net/tmwa/skillrecv.h
+++ /dev/null
@@ -1,40 +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 NET_TMWA_SKILLRECV_H
-#define NET_TMWA_SKILLRECV_H
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-namespace TmwAthena
-{
- namespace SkillRecv
- {
- void processSkillFailed(Net::MessageIn &msg);
- void processPlayerSkills(Net::MessageIn &msg);
- } // namespace SkillRecv
-} // namespace TmwAthena
-
-#endif // NET_TMWA_SKILLRECV_H
diff --git a/src/net/tmwa/sp.h b/src/net/tmwa/sp.h
deleted file mode 100644
index 10711bfce..000000000
--- a/src/net/tmwa/sp.h
+++ /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/>.
- */
-
-#ifndef NET_TMWA_SP_H
-#define NET_TMWA_SP_H
-
-namespace Sp
-{
- enum
- {
- SPEED = 0,
- BASEEXP = 1,
- JOBEXP = 2,
- KARMA = 3,
- MANNER = 4,
- HP = 5,
- MAXHP = 6,
- SP = 7,
- MAXSP = 8,
- STATUSPOINT = 9,
- BASELEVEL = 11,
- SKILLPOINT = 12,
- STR = 13,
- AGI = 14,
- VIT = 15,
- INT = 16,
- DEX = 17,
- LUK = 18,
- CLASS = 19,
- ZENY = 20,
- SEX = 21,
- NEXTBASEEXP = 22,
- JOB_MOD = 23, // SP_NEXTJOBEXP
- WEIGHT = 24,
- MAXWEIGHT = 25,
- USTR = 32,
- UAGI = 33,
- UVIT = 34,
- UINT = 35,
- UDEX = 36,
- ULUK = 37,
- ATK1 = 41,
- ATK2 = 42,
- MATK1 = 43,
- MATK2 = 44,
- DEF1 = 45,
- DEF2 = 46,
- MDEF1 = 47,
- MDEF2 = 48,
- HIT = 49,
- FLEE1 = 50,
- FLEE2 = 51,
- CRITICAL = 52,
- ASPD = 53,
- JOBLEVEL = 55,
-
- GM_LEVEL = 500
- };
-} // namespace Sp
-
-#endif // NET_TMWA_SP_H
diff --git a/src/net/tmwa/sprite.h b/src/net/tmwa/sprite.h
deleted file mode 100644
index 97cdada4c..000000000
--- a/src/net/tmwa/sprite.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 NET_TMWA_SPRITE_H
-#define NET_TMWA_SPRITE_H
-
-enum
-{
- SPRITE_BASE = 0,
- SPRITE_HAIR,
- SPRITE_WEAPON,
- SPRITE_HEAD_BOTTOM,
- SPRITE_HEAD_TOP,
- SPRITE_HEAD_MID,
- SPRITE_HAIR_COLOR,
- SPRITE_CLOTHES_COLOR,
- SPRITE_SHIELD,
- SPRITE_SHOES,
- SPRITE_BODY,
- SPRITE_FLOOR,
- SPRITE_ROBE,
- SPRITE_EVOL2,
- SPRITE_VECTOREND
-};
-
-#endif // NET_TMWA_SPRITE_H
diff --git a/src/net/tmwa/tradehandler.cpp b/src/net/tmwa/tradehandler.cpp
deleted file mode 100644
index f82612bd0..000000000
--- a/src/net/tmwa/tradehandler.cpp
+++ /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/>.
- */
-
-#include "net/tmwa/tradehandler.h"
-
-#include "being/playerinfo.h"
-
-#include "const/net/inventory.h"
-
-#include "net/tmwa/messageout.h"
-#include "net/tmwa/protocolout.h"
-
-#include "resources/item/item.h"
-
-#include "debug.h"
-
-extern std::string tradePartnerName;
-
-namespace TmwAthena
-{
-
-TradeHandler::TradeHandler() :
- Ea::TradeHandler()
-{
- tradeHandler = this;
-}
-
-TradeHandler::~TradeHandler()
-{
- tradeHandler = nullptr;
-}
-
-void TradeHandler::request(const Being *const being) const
-{
- if (being == nullptr)
- return;
-
- createOutPacket(CMSG_TRADE_REQUEST);
- outMsg.writeBeingId(being->getId(), "player id");
-}
-
-void TradeHandler::respond(const bool accept) const
-{
- if (!accept)
- PlayerInfo::setTrading(Trading_false);
-
- createOutPacket(CMSG_TRADE_RESPONSE);
- outMsg.writeInt8(CAST_S8(accept ? 3 : 4), "accept");
-}
-
-void TradeHandler::addItem(const Item *const item, const int amount) const
-{
- if (item == nullptr)
- return;
-
- createOutPacket(CMSG_TRADE_ITEM_ADD_REQUEST);
- outMsg.writeInt16(CAST_S16(
- item->getInvIndex() + INVENTORY_OFFSET), "index");
- outMsg.writeInt32(amount, "amount");
-}
-
-void TradeHandler::setMoney(const int amount) const
-{
- createOutPacket(CMSG_TRADE_ITEM_ADD_REQUEST);
- outMsg.writeInt16(0, "index");
- outMsg.writeInt32(amount, "amount");
-}
-
-void TradeHandler::confirm() const
-{
- createOutPacket(CMSG_TRADE_ADD_COMPLETE);
-}
-
-void TradeHandler::finish() const
-{
- createOutPacket(CMSG_TRADE_OK);
-}
-
-void TradeHandler::cancel() const
-{
- createOutPacket(CMSG_TRADE_CANCEL_REQUEST);
-}
-
-} // namespace TmwAthena
diff --git a/src/net/tmwa/tradehandler.h b/src/net/tmwa/tradehandler.h
deleted file mode 100644
index b8538f1bc..000000000
--- a/src/net/tmwa/tradehandler.h
+++ /dev/null
@@ -1,58 +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 NET_TMWA_TRADEHANDLER_H
-#define NET_TMWA_TRADEHANDLER_H
-
-#include "net/ea/tradehandler.h"
-
-namespace TmwAthena
-{
-
-class TradeHandler final : public Ea::TradeHandler
-{
- public:
- TradeHandler();
-
- A_DELETE_COPY(TradeHandler)
-
- ~TradeHandler();
-
- void request(const Being *const being) const override final;
-
- void respond(const bool accept) const override final;
-
- void addItem(const Item *const item,
- const int amount) const override final;
-
- void setMoney(const int amount) const override final;
-
- void confirm() const override final;
-
- void finish() const override final;
-
- void cancel() const override final;
-};
-
-} // namespace TmwAthena
-
-#endif // NET_TMWA_TRADEHANDLER_H
diff --git a/src/net/tmwa/traderecv.cpp b/src/net/tmwa/traderecv.cpp
deleted file mode 100644
index d799d9f91..000000000
--- a/src/net/tmwa/traderecv.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 "net/tmwa/traderecv.h"
-
-#include "notifymanager.h"
-
-#include "being/playerinfo.h"
-#include "being/playerrelation.h"
-#include "being/playerrelations.h"
-
-#include "const/net/inventory.h"
-
-#include "enums/resources/notifytypes.h"
-
-#include "gui/windows/tradewindow.h"
-
-#include "net/messagein.h"
-#include "net/tradehandler.h"
-
-#include "net/ea/traderecv.h"
-
-#include "resources/inventory/inventory.h"
-
-#include "resources/item/item.h"
-
-#include "utils/stringutils.h"
-
-#include "debug.h"
-
-extern std::string tradePartnerName;
-
-namespace TmwAthena
-{
-
-void TradeRecv::processTradeRequest(Net::MessageIn &msg)
-{
- Ea::TradeRecv::processTradeRequestContinue(msg.readString(24, "name"));
-}
-
-void TradeRecv::processTradeItemAdd(Net::MessageIn &msg)
-{
- const int amount = msg.readInt32("amount");
- const int type = msg.readInt16("type");
- const uint8_t identify = msg.readUInt8("identify");
- msg.readUInt8("attribute");
- const uint8_t refine = msg.readUInt8("refine");
- int cards[maxCards];
- for (int f = 0; f < maxCards; f++)
- cards[f] = msg.readUInt16("card");
-
- if (tradeWindow != nullptr)
- {
- if (type == 0)
- {
- tradeWindow->setMoney(amount);
- }
- else
- {
- tradeWindow->addItem2(type,
- ItemType::Unknown,
- cards,
- nullptr,
- 4,
- false,
- amount,
- refine,
- ItemColor_one,
- fromBool(identify, Identified),
- Damaged_false,
- Favorite_false,
- Equipm_false);
- }
- }
-}
-
-void TradeRecv::processTradeItemAddResponse(Net::MessageIn &msg)
-{
- // Trade: New Item add response (was 0x00ea, now 01b1)
- const int index = msg.readInt16("index") - INVENTORY_OFFSET;
- Item *item = nullptr;
- if (PlayerInfo::getInventory() != nullptr)
- item = PlayerInfo::getInventory()->getItem(index);
-
- if (item == nullptr)
- {
- if (tradeWindow != nullptr)
- tradeWindow->receivedOk(true);
- return;
- }
- const int quantity = msg.readInt16("amount");
-
- const uint8_t res = msg.readUInt8("status");
- switch (res)
- {
- case 0:
- // Successfully added item
- if (tradeWindow != nullptr)
- {
- tradeWindow->addItem2(item->getId(),
- item->getType(),
- item->getCards(),
- nullptr,
- 4,
- true,
- quantity,
- item->getRefine(),
- item->getColor(),
- item->getIdentified(),
- item->getDamaged(),
- item->getFavorite(),
- item->isEquipment());
- }
- item->increaseQuantity(-quantity);
- break;
- case 1:
- // Add item failed - player overweighted
- NotifyManager::notify(NotifyTypes::
- TRADE_ADD_PARTNER_OVER_WEIGHT);
- break;
- case 2:
- // Add item failed - player has no free slot
- NotifyManager::notify(NotifyTypes::TRADE_ADD_PARTNER_NO_SLOTS);
- break;
- case 3:
- // Add item failed - non tradable item
- NotifyManager::notify(NotifyTypes::TRADE_ADD_UNTRADABLE_ITEM);
- break;
- default:
- NotifyManager::notify(NotifyTypes::TRADE_ADD_ERROR);
- UNIMPLEMENTEDPACKETFIELD(res);
- logger->log("QQQ SMSG_TRADE_ITEM_ADD_RESPONSE: "
- + toString(res));
- break;
- }
-}
-
-void TradeRecv::processTradeResponse(Net::MessageIn &msg)
-{
- if (tradePartnerName.empty() ||
- !playerRelations.hasPermission(tradePartnerName,
- PlayerRelation::TRADE))
- {
- tradeHandler->respond(false);
- return;
- }
- const uint8_t type = msg.readUInt8("type");
- Ea::TradeRecv::processTradeResponseContinue(type);
-}
-
-} // namespace TmwAthena
diff --git a/src/net/tmwa/traderecv.h b/src/net/tmwa/traderecv.h
deleted file mode 100644
index 253348dab..000000000
--- a/src/net/tmwa/traderecv.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 NET_TMWA_TRADERECV_H
-#define NET_TMWA_TRADERECV_H
-
-namespace Net
-{
- class MessageIn;
-} // namespace Net
-
-namespace TmwAthena
-{
- namespace TradeRecv
- {
- void processTradeRequest(Net::MessageIn &msg);
- void processTradeItemAdd(Net::MessageIn &msg);
- void processTradeItemAddResponse(Net::MessageIn &msg);
- void processTradeResponse(Net::MessageIn &msg);
- } // namespace TradeRecv
-} // namespace TmwAthena
-
-#endif // NET_TMWA_TRADERECV_H
diff --git a/src/net/tmwa/updateprotocol.cpp b/src/net/tmwa/updateprotocol.cpp
deleted file mode 100644
index 3928cc101..000000000
--- a/src/net/tmwa/updateprotocol.cpp
+++ /dev/null
@@ -1,49 +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/>.
- */
-
-#include "net/tmwa/updateprotocol.h"
-
-#include "net/tmwa/network.h"
-#include "net/tmwa/protocolout.h"
-
-#include "debug.h"
-
-namespace TmwAthena
-{
-
-void updateProtocol()
-{
-#define PACKETS_UPDATE
-#include "net/protocoloutupdate.h"
-#include "net/tmwa/packetsout.inc"
-#undef packet
- Network *const network = Network::mInstance;
- if (network != nullptr)
- {
- network->clearHandlers();
- network->registerHandlers();
- }
-}
-
-PACKETSOUT_VOID
-PROTOCOLOUTUPDATE_VOID
-PROTOCOLOUT_VOID
-
-} // namespace TmwAthena
diff --git a/src/net/tmwa/updateprotocol.h b/src/net/tmwa/updateprotocol.h
deleted file mode 100644
index f460f2c7c..000000000
--- a/src/net/tmwa/updateprotocol.h
+++ /dev/null
@@ -1,29 +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 NET_TMWA_UPDATEPROTOCOL_H
-#define NET_TMWA_UPDATEPROTOCOL_H
-
-namespace TmwAthena
-{
- void updateProtocol();
-} // namespace TmwAthena
-
-#endif // NET_TMWA_UPDATEPROTOCOL_H
diff --git a/src/net/tmwa/vendinghandler.cpp b/src/net/tmwa/vendinghandler.cpp
deleted file mode 100644
index 30237cb0e..000000000
--- a/src/net/tmwa/vendinghandler.cpp
+++ /dev/null
@@ -1,72 +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 "net/tmwa/vendinghandler.h"
-
-#include "debug.h"
-
-namespace TmwAthena
-{
-
-VendingHandler::VendingHandler()
-{
- vendingHandler = this;
-}
-
-VendingHandler::~VendingHandler()
-{
- vendingHandler = nullptr;
-}
-
-void VendingHandler::close() const
-{
-}
-
-void VendingHandler::open(const Being *const being A_UNUSED) const
-{
-}
-
-void VendingHandler::buy(const Being *const being A_UNUSED,
- const int index A_UNUSED,
- const int amount A_UNUSED) const
-{
-}
-
-void VendingHandler::buyItems(const Being *const being A_UNUSED,
- const STD_VECTOR<ShopItem*> &items A_UNUSED)
- const
-{
-}
-
-void VendingHandler::buy2(const Being *const being A_UNUSED,
- const int vendId A_UNUSED,
- const int index A_UNUSED,
- const int amount A_UNUSED) const
-{
-}
-
-void VendingHandler::createShop(const std::string &name A_UNUSED,
- const bool flag A_UNUSED,
- const STD_VECTOR<ShopItem*> &items A_UNUSED)
- const
-{
-}
-
-} // namespace TmwAthena
diff --git a/src/net/tmwa/vendinghandler.h b/src/net/tmwa/vendinghandler.h
deleted file mode 100644
index 3af4a110b..000000000
--- a/src/net/tmwa/vendinghandler.h
+++ /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/>.
- */
-
-#ifndef NET_TMWA_VENDINGHANDLER_H
-#define NET_TMWA_VENDINGHANDLER_H
-
-#include "net/vendinghandler.h"
-
-namespace TmwAthena
-{
-
-class VendingHandler final : public Net::VendingHandler
-{
- public:
- VendingHandler();
-
- A_DELETE_COPY(VendingHandler)
-
- ~VendingHandler();
-
- void close() const override final A_CONST;
-
- void open(const Being *const being) const override final A_CONST;
-
- void buy(const Being *const being,
- const int index,
- const int amount) const override final A_CONST;
-
- void buyItems(const Being *const being,
- const STD_VECTOR<ShopItem*> &items) const
- override final A_CONST;
-
- void buy2(const Being *const being,
- const int vendId,
- const int index,
- const int amount) const override final A_CONST;
-
- void createShop(const std::string &name,
- const bool flag,
- const STD_VECTOR<ShopItem*> &items) const
- override final A_CONST;
-};
-
-} // namespace TmwAthena
-
-#endif // NET_TMWA_VENDINGHANDLER_H
diff --git a/src/net/tradehandler.h b/src/net/tradehandler.h
deleted file mode 100644
index ca125da53..000000000
--- a/src/net/tradehandler.h
+++ /dev/null
@@ -1,76 +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 NET_TRADEHANDLER_H
-#define NET_TRADEHANDLER_H
-
-#include "being/being.h"
-
-#include "localconsts.h"
-
-class Item;
-
-namespace Net
-{
-class TradeHandler notfinal
-{
- public:
- TradeHandler()
- { }
-
- A_DELETE_COPY(TradeHandler)
-
- virtual ~TradeHandler()
- { }
-
- virtual void request(const Being *const being A_UNUSED) const
- { }
-
- virtual void respond(const bool accept A_UNUSED) const
- { }
-
- virtual void addItem(const Item *const item A_UNUSED,
- const int amount A_UNUSED) const
- { }
-
- virtual void removeItem(const int slotNum A_UNUSED,
- const int amount A_UNUSED) const
- { }
-
- virtual void setMoney(const int amount A_UNUSED) const
- { }
-
- virtual void confirm() const
- { }
-
- virtual void finish() const
- { }
-
- virtual void cancel() const
- { }
-};
-
-} // namespace Net
-
-extern Net::TradeHandler *tradeHandler;
-
-#endif // NET_TRADEHANDLER_H
diff --git a/src/net/updatetypeoperators.cpp b/src/net/updatetypeoperators.cpp
deleted file mode 100644
index 1ee52455c..000000000
--- a/src/net/updatetypeoperators.cpp
+++ /dev/null
@@ -1,40 +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/>.
- */
-
-#include "net/updatetypeoperators.h"
-
-#include "utils/cast.h"
-
-#include "debug.h"
-
-int operator&(const UpdateTypeT &a, const UpdateTypeT &b)
-{
- return CAST_S32(a) & CAST_S32(b);
-}
-
-int operator|(const UpdateTypeT &a, const UpdateTypeT &b)
-{
- return CAST_S32(a) | CAST_S32(b);
-}
-
-int operator|(const int &a, const UpdateTypeT &b)
-{
- return a | CAST_S32(b);
-}
diff --git a/src/net/updatetypeoperators.h b/src/net/updatetypeoperators.h
deleted file mode 100644
index 93a062088..000000000
--- a/src/net/updatetypeoperators.h
+++ /dev/null
@@ -1,30 +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 NET_UPDATETYPEOPERATORS_H
-#define NET_UPDATETYPEOPERATORS_H
-
-#include "enums/net/updatetype.h"
-
-int operator&(const UpdateTypeT &a, const UpdateTypeT &b);
-int operator|(const UpdateTypeT &a, const UpdateTypeT &b);
-int operator|(const int &a, const UpdateTypeT &b);
-
-#endif // NET_UPDATETYPEOPERATORS_H
diff --git a/src/net/uploadcharinfo.h b/src/net/uploadcharinfo.h
deleted file mode 100644
index 7a11de0a8..000000000
--- a/src/net/uploadcharinfo.h
+++ /dev/null
@@ -1,52 +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 NET_UPLOADCHARINFO_H
-#define NET_UPLOADCHARINFO_H
-
-#include <string>
-
-#include "localconsts.h"
-
-class ChatTab;
-
-namespace Net
-{
- class Download;
-} // namespace Net
-
-struct UploadChatInfo final
-{
- UploadChatInfo() :
- tab(nullptr),
- upload(nullptr),
- text(),
- addStr()
- { }
-
- A_DELETE_COPY(UploadChatInfo)
-
- ChatTab *tab;
- Net::Download *upload;
- std::string text;
- std::string addStr;
-};
-
-#endif // NET_UPLOADCHARINFO_H
diff --git a/src/net/useragent.cpp b/src/net/useragent.cpp
deleted file mode 100644
index c08c68cda..000000000
--- a/src/net/useragent.cpp
+++ /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/>.
- */
-
-#include "net/useragent.h"
-
-#include "configuration.h"
-#include "settings.h"
-#include "main.h"
-
-#include "render/graphics.h"
-
-#include "debug.h"
-
-void UserAgent::update()
-{
- std::string renderName;
- if (mainGraphics != nullptr)
- renderName = mainGraphics->getName();
- else
- renderName = "unknown";
-
- settings.userAgent = strprintf(PACKAGE_EXTENDED_VERSION,
- branding.getStringValue("appName").c_str(),
- renderName.c_str());
-}
diff --git a/src/net/useragent.h b/src/net/useragent.h
deleted file mode 100644
index f6c5aea32..000000000
--- a/src/net/useragent.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 NET_USERAGENT_H
-#define NET_USERAGENT_H
-
-#include "localconsts.h"
-
-namespace UserAgent
-{
- void update();
-} // namespace UserAgent
-
-#endif // NET_USERAGENT_H
diff --git a/src/net/vendinghandler.h b/src/net/vendinghandler.h
deleted file mode 100644
index b5653163b..000000000
--- a/src/net/vendinghandler.h
+++ /dev/null
@@ -1,72 +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 NET_VENDINGHANDLER_H
-#define NET_VENDINGHANDLER_H
-
-#include "utils/vector.h"
-
-#include <string>
-
-#include "localconsts.h"
-
-class Being;
-class ShopItem;
-
-namespace Net
-{
-
-class VendingHandler notfinal
-{
- public:
- VendingHandler()
- { }
-
- A_DELETE_COPY(VendingHandler)
-
- virtual ~VendingHandler()
- { }
-
- virtual void close() const = 0;
-
- virtual void open(const Being *const being) const = 0;
-
- virtual void buy(const Being *const being,
- const int index,
- const int amount) const = 0;
-
- virtual void buyItems(const Being *const being,
- const STD_VECTOR<ShopItem*> &items) const = 0;
-
- virtual void buy2(const Being *const being,
- const int vendId,
- const int index,
- const int amount) const = 0;
-
- virtual void createShop(const std::string &name,
- const bool flag,
- const STD_VECTOR<ShopItem*> &items) const = 0;
-};
-
-} // namespace Net
-
-extern Net::VendingHandler *vendingHandler;
-
-#endif // NET_VENDINGHANDLER_H
diff --git a/src/net/worldinfo.h b/src/net/worldinfo.h
deleted file mode 100644
index 8ba2615e7..000000000
--- a/src/net/worldinfo.h
+++ /dev/null
@@ -1,60 +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 NET_WORLDINFO_H
-#define NET_WORLDINFO_H
-
-#include "utils/vector.h"
-
-#if defined(__GXX_EXPERIMENTAL_CXX0X__)
-#if defined(__APPLE__)
-#include <tr1/cstdint>
-#endif // defined(__APPLE__)
-#endif // defined(__GXX_EXPERIMENTAL_CXX0X__)
-
-#include <string>
-
-#include "localconsts.h"
-
-struct WorldInfo final
-{
- WorldInfo() :
- address(0),
- name(),
- port(0),
- online_users(0),
- updateHost()
- {
- }
-
- A_DELETE_COPY(WorldInfo)
-
- int address;
- std::string name;
- uint16_t port;
- int online_users;
- std::string updateHost;
-};
-
-typedef STD_VECTOR<WorldInfo*> Worlds;
-
-#endif // NET_WORLDINFO_H
diff --git a/src/notifymanager.cpp b/src/notifymanager.cpp
deleted file mode 100644
index 738ebda8c..000000000
--- a/src/notifymanager.cpp
+++ /dev/null
@@ -1,195 +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 "notifymanager.h"
-
-#include "soundmanager.h"
-
-#include "being/localplayer.h"
-
-#include "net/guildhandler.h"
-#include "net/partyhandler.h"
-
-#ifdef TMWA_SUPPORT
-#include "net/tmwa/guildmanager.h"
-#endif // TMWA_SUPPORT
-
-#include "resources/notifications.h"
-
-#include "resources/db/sounddb.h"
-
-#include "utils/stringutils.h"
-
-#include "debug.h"
-
-namespace NotifyManager
-{
- static ChatTab *getGuildTab()
- {
- const Guild *const guild = localPlayer->getGuild();
- if (guild != nullptr)
- {
-#ifdef TMWA_SUPPORT
- if (guild->getServerGuild())
- return guildHandler->getTab();
- else if (guildManager != nullptr)
- return guildManager->getTab();
-#else // TMWA_SUPPORT
- return guildHandler->getTab();
-#endif // TMWA_SUPPORT
- }
- return nullptr;
- }
-
- static void chatLog(ChatTab *const tab, const std::string &str)
- {
- if (str.empty())
- return;
- if (tab != nullptr)
- tab->chatLog(str, ChatMsgType::BY_SERVER);
- else if (debugChatTab != nullptr)
- debugChatTab->chatLog(str, ChatMsgType::BY_SERVER);
- }
-
- void notify(const unsigned int message)
- {
- if (message >= NotifyTypes::TYPE_END ||
- localChatTab == nullptr)
- {
- return;
- }
- const NotificationInfo &info = notifications[message];
- if (*info.text == 0)
- {
- soundManager.playSfx(SoundDB::getSound(message));
- return;
- }
-
- switch (info.flags)
- {
- case NotifyFlags::EMPTY:
- localChatTab->chatLog(gettext(info.text),
- ChatMsgType::BY_SERVER);
- break;
-
- case NotifyFlags::GUILD:
- {
- if (localPlayer == nullptr)
- return;
- ChatTab *const tab = getGuildTab();
- chatLog(tab, gettext(info.text));
- break;
- }
-
- case NotifyFlags::PARTY:
- {
- ChatTab *const tab = partyHandler->getTab();
- chatLog(tab, gettext(info.text));
- break;
- }
-
- case NotifyFlags::SPEECH:
- {
- if (localPlayer != nullptr)
- localPlayer->setSpeech(gettext(info.text));
- break;
- }
-
- case NotifyFlags::INT:
- case NotifyFlags::STRING:
- case NotifyFlags::GUILD_STRING:
- case NotifyFlags::PARTY_STRING:
- default:
- break;
- }
- soundManager.playSfx(SoundDB::getSound(message));
- }
-
- void notify(const unsigned int message, const int num)
- {
- if (message >= NotifyTypes::TYPE_END ||
- localChatTab == nullptr)
- {
- return;
- }
- const NotificationInfo &info = notifications[message];
- if (info.flags == NotifyFlags::INT &&
- *info.text != 0)
- {
- localChatTab->chatLog(strprintf(gettext(info.text),
- num), ChatMsgType::BY_SERVER);
- }
- soundManager.playSfx(SoundDB::getSound(message));
- }
-
- void notify(const unsigned int message, const std::string &str)
- {
- if (message >= NotifyTypes::TYPE_END ||
- localChatTab == nullptr)
- {
- return;
- }
- const NotificationInfo &info = notifications[message];
- if (*info.text == 0)
- {
- soundManager.playSfx(SoundDB::getSound(message));
- return;
- }
- switch (info.flags)
- {
- case NotifyFlags::STRING:
- {
- localChatTab->chatLog(strprintf(gettext(info.text),
- str.c_str()), ChatMsgType::BY_SERVER);
- break;
- }
- case NotifyFlags::GUILD_STRING:
- {
- ChatTab *const tab = getGuildTab();
- chatLog(tab, strprintf(gettext(info.text), str.c_str()));
- break;
- }
- case NotifyFlags::PARTY_STRING:
- {
- ChatTab *const tab = partyHandler->getTab();
- chatLog(tab, strprintf(gettext(info.text), str.c_str()));
- break;
- }
- case NotifyFlags::EMPTY:
- case NotifyFlags::INT:
- case NotifyFlags::GUILD:
- case NotifyFlags::PARTY:
- case NotifyFlags::SPEECH:
- default:
- break;
- }
- soundManager.playSfx(SoundDB::getSound(message));
- }
-
- int getIndexBySound(const std::string &sound)
- {
- for (int f = 0; f < NotifyTypes::TYPE_END; f ++)
- {
- if (notifications[f].sound == sound)
- return f;
- }
- return 0;
- }
-} // namespace NotifyManager
diff --git a/src/notifymanager.h b/src/notifymanager.h
deleted file mode 100644
index 41cba0e6e..000000000
--- a/src/notifymanager.h
+++ /dev/null
@@ -1,34 +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 NOTIFYMANAGER_H
-#define NOTIFYMANAGER_H
-
-#include <string>
-
-namespace NotifyManager
-{
- void notify(const unsigned int message);
- void notify(const unsigned int message, const int num);
- void notify(const unsigned int message, const std::string &str);
- int getIndexBySound(const std::string &sound);
-} // namespace NotifyManager
-
-#endif // NOTIFYMANAGER_H
diff --git a/src/options.h b/src/options.h
deleted file mode 100644
index 9bfd405ac..000000000
--- a/src/options.h
+++ /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/>.
- */
-
-#ifndef OPTIONS_H
-#define OPTIONS_H
-
-#include <string>
-
-#if defined(__GXX_EXPERIMENTAL_CXX0X__)
-#if defined(__APPLE__)
-#include <tr1/cstdint>
-#endif // defined(__APPLE__)
-#endif // defined(__GXX_EXPERIMENTAL_CXX0X__)
-
-#include "localconsts.h"
-
-/**
- * A structure holding the values of various options that can be passed
- * from the command line.
- */
-struct Options final
-{
- Options() :
- username(),
- password(),
- character(),
- brandingPath(),
- updateHost(),
- dataPath(),
- homeDir(),
- logFileName(),
- chatLogDir(),
- configDir(),
- localDataDir(),
- screenshotDir(),
- test(),
- serverName(),
- serverType(),
- renderer(-1),
- serverPort(0),
- printHelp(false),
- printVersion(false),
- skipUpdate(false),
- chooseDefault(false),
- noOpenGL(false),
- safeMode(false),
- testMode(false),
- ipc(false),
- hideCursor(false),
- error(false),
- validate(false)
- {}
-
- A_DELETE_COPY(Options)
-
- std::string username;
- std::string password;
- std::string character;
- std::string brandingPath;
- std::string updateHost;
- std::string dataPath;
- std::string homeDir;
- std::string logFileName;
- std::string chatLogDir;
- std::string configDir;
- std::string localDataDir;
- std::string screenshotDir;
- std::string test;
- std::string serverName;
- std::string serverType;
- int renderer;
- uint16_t serverPort;
- bool printHelp;
- bool printVersion;
- bool skipUpdate;
- bool chooseDefault;
- bool noOpenGL;
- bool safeMode;
- bool testMode;
- bool ipc;
- bool hideCursor;
- bool error;
- bool validate;
-};
-
-#endif // OPTIONS_H
diff --git a/src/particle/animationparticle.cpp b/src/particle/animationparticle.cpp
deleted file mode 100644
index baeb0701e..000000000
--- a/src/particle/animationparticle.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2006-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 "particle/animationparticle.h"
-
-#include "resources/animation/simpleanimation.h"
-
-#include "debug.h"
-
-AnimationParticle::AnimationParticle(Animation *restrict const animation) :
- ImageParticle(nullptr)
-{
- mType = ParticleType::Animation;
- mAnimation = new SimpleAnimation(animation);
-}
-
-AnimationParticle::AnimationParticle(XmlNodePtrConst animationNode,
- const std::string &restrict dyePalettes) :
- ImageParticle(nullptr)
-{
- mType = ParticleType::Animation;
- mAnimation = new SimpleAnimation(animationNode, dyePalettes);
-}
diff --git a/src/particle/animationparticle.h b/src/particle/animationparticle.h
deleted file mode 100644
index 9c5e6af5d..000000000
--- a/src/particle/animationparticle.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2006-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 PARTICLE_ANIMATIONPARTICLE_H
-#define PARTICLE_ANIMATIONPARTICLE_H
-
-#include "particle/imageparticle.h"
-
-#include "utils/xml.h"
-
-class Animation;
-
-class AnimationParticle final : public ImageParticle
-{
- public:
- explicit AnimationParticle(Animation *restrict const animation)
- A_NONNULL(2);
-
- explicit AnimationParticle(XmlNodePtrConst animationNode,
- const std::string &restrict dyePalettes
- = std::string());
-
- A_DELETE_COPY(AnimationParticle)
-};
-
-#endif // PARTICLE_ANIMATIONPARTICLE_H
diff --git a/src/particle/imageparticle.cpp b/src/particle/imageparticle.cpp
deleted file mode 100644
index 859fc6a15..000000000
--- a/src/particle/imageparticle.cpp
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2006-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 "particle/imageparticle.h"
-
-#include "render/graphics.h"
-
-#include "resources/image/image.h"
-
-#include "debug.h"
-
-StringIntMap ImageParticle::imageParticleCountByName;
-
-ImageParticle::ImageParticle(Image *restrict const image) :
- Particle()
-{
- mType = ParticleType::Image;
- mImage = image;
- if (mImage != nullptr)
- {
- mImage->incRef();
-
- const std::string &restrict name = mImage->mIdPath;
- StringIntMapIter it
- = ImageParticle::imageParticleCountByName.find(name);
- if (it == ImageParticle::imageParticleCountByName.end())
- ImageParticle::imageParticleCountByName[name] = 1;
- else
- (*it).second ++;
- }
-}
-
-void ImageParticle::draw(Graphics *restrict const graphics,
- const int offsetX,
- const int offsetY) const restrict2
-{
- FUNC_BLOCK("ImageParticle::draw", 1)
- if (mAlive != AliveStatus::ALIVE || (mImage == nullptr))
- return;
-
- const int w = mImage->mBounds.w;
- const int h = mImage->mBounds.h;
- const int screenX = CAST_S32(mPos.x)
- + offsetX - w / 2;
- const int screenY = CAST_S32(mPos.y) - CAST_S32(mPos.z)
- + offsetY - h / 2;
-
- // Check if on screen
- if (screenX + w < 0 ||
- screenX > graphics->mWidth ||
- screenY + h < 0 ||
- screenY > graphics->mHeight)
- {
- return;
- }
-
- float alphafactor = mAlpha;
-
- if ((mFadeOut != 0) && mLifetimeLeft > -1 && mLifetimeLeft < mFadeOut)
- {
- alphafactor *= static_cast<float>(mLifetimeLeft)
- / static_cast<float>(mFadeOut);
- }
-
- if ((mFadeIn != 0) && mLifetimePast < mFadeIn)
- {
- alphafactor *= static_cast<float>(mLifetimePast)
- / static_cast<float>(mFadeIn);
- }
-
- mImage->setAlpha(alphafactor);
- graphics->drawImage(mImage, screenX, screenY);
-}
diff --git a/src/particle/imageparticle.h b/src/particle/imageparticle.h
deleted file mode 100644
index 9e2f03904..000000000
--- a/src/particle/imageparticle.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2006-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 PARTICLE_IMAGEPARTICLE_H
-#define PARTICLE_IMAGEPARTICLE_H
-
-#include "particle/particle.h"
-
-#include "utils/stringmap.h"
-
-class Image;
-
-/**
- * A particle that uses an image for its visualization.
- */
-class ImageParticle notfinal : public Particle
-{
- public:
- /**
- * Constructor. The image is reference counted by this particle.
- *
- * @param image an Image instance, may not be NULL
- */
- explicit ImageParticle(Image *restrict const image);
-
- A_DELETE_COPY(ImageParticle)
-
- /**
- * Draws the particle image
- */
- void draw(Graphics *restrict const graphics,
- const int offsetX,
- const int offsetY) const
- restrict2 override final A_NONNULL(2);
-
- void setAlpha(const float alpha) restrict2 override final
- { mAlpha = alpha; }
-
- static StringIntMap imageParticleCountByName;
-};
-
-#endif // PARTICLE_IMAGEPARTICLE_H
diff --git a/src/particle/particle.cpp b/src/particle/particle.cpp
deleted file mode 100644
index 40b1b7a5a..000000000
--- a/src/particle/particle.cpp
+++ /dev/null
@@ -1,590 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2006-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 "particle/particle.h"
-
-#include "actormanager.h"
-#include "logger.h"
-
-#include "being/actorsprite.h"
-
-#include "particle/animationparticle.h"
-#include "particle/particleemitter.h"
-#include "particle/rotationalparticle.h"
-
-#include "resources/animation/simpleanimation.h"
-
-#include "resources/dye/dye.h"
-
-#include "resources/image/image.h"
-
-#include "resources/loaders/imageloader.h"
-#include "resources/loaders/xmlloader.h"
-
-#include "utils/delete2.h"
-#include "utils/dtor.h"
-#include "utils/foreach.h"
-#include "utils/likely.h"
-#include "utils/mathutils.h"
-#include "utils/mrand.h"
-
-#include "debug.h"
-
-static const float SIN45 = 0.707106781F;
-static const double PI = M_PI;
-static const float PI2 = 2 * M_PI;
-
-class Graphics;
-
-Particle::Particle() :
- Actor(),
- mAlpha(1.0F),
- mLifetimeLeft(-1),
- mLifetimePast(0),
- mFadeOut(0),
- mFadeIn(0),
- mVelocity(),
- mAlive(AliveStatus::ALIVE),
- mType(ParticleType::Normal),
- mAnimation(nullptr),
- mImage(nullptr),
- mActor(BeingId_zero),
- mChildEmitters(),
- mChildParticles(),
- mChildMoveParticles(),
- mDeathEffect(),
- mGravity(0.0F),
- mBounce(0.0F),
- mAcceleration(0.0F),
- mInvDieDistance(-1.0F),
- mMomentum(1.0F),
- mTarget(nullptr),
- mRandomness(0),
- mDeathEffectConditions(0x00),
- mAutoDelete(true),
- mAllowSizeAdjust(false),
- mFollow(false)
-{
- ParticleEngine::particleCount++;
-}
-
-Particle::~Particle()
-{
- if (mActor != BeingId_zero &&
- (actorManager != nullptr))
- {
- ActorSprite *const actor = actorManager->findActor(mActor);
- if (actor != nullptr)
- actor->controlParticleDeleted(this);
- }
- // Delete child emitters and child particles
- clear();
- delete2(mAnimation);
- if (mImage != nullptr)
- {
- if (mType == ParticleType::Image)
- {
- const std::string &restrict name = mImage->mIdPath;
- StringIntMapIter it
- = ImageParticle::imageParticleCountByName.find(name);
- if (it != ImageParticle::imageParticleCountByName.end())
- {
- int &cnt = (*it).second;
- if (cnt > 0)
- cnt --;
- }
- mImage->decRef();
- }
- mImage = nullptr;
- }
-
- ParticleEngine::particleCount--;
-}
-
-void Particle::draw(Graphics *restrict const graphics A_UNUSED,
- const int offsetX A_UNUSED,
- const int offsetY A_UNUSED) const restrict2
-{
-}
-
-void Particle::updateSelf() restrict2
-{
- // calculate particle movement
- if (A_LIKELY(mMomentum != 1.0F))
- mVelocity *= mMomentum;
-
- if ((mTarget != nullptr) && mAcceleration != 0.0F)
- {
- Vector dist = mPos - mTarget->mPos;
- dist.x *= SIN45;
- float invHypotenuse;
-
- switch (ParticleEngine::fastPhysics)
- {
- case ParticlePhysics::Normal:
- invHypotenuse = fastInvSqrt(
- dist.x * dist.x + dist.y * dist.y + dist.z * dist.z);
- break;
- case ParticlePhysics::Fast:
- if (dist.x == 0.0f)
- {
- invHypotenuse = 0;
- break;
- }
-
- invHypotenuse = 2.0F / (static_cast<float>(fabs(dist.x))
- + static_cast<float>(fabs(dist.y))
- + static_cast<float>(fabs(dist.z)));
- break;
- case ParticlePhysics::Best:
- default:
- invHypotenuse = 1.0F / static_cast<float>(sqrt(
- dist.x * dist.x + dist.y * dist.y + dist.z * dist.z));
- break;
- }
-
- if (invHypotenuse != 0.0f)
- {
- if (mInvDieDistance > 0.0F && invHypotenuse > mInvDieDistance)
- mAlive = AliveStatus::DEAD_IMPACT;
- const float accFactor = invHypotenuse * mAcceleration;
- mVelocity -= dist * accFactor;
- }
- }
-
- if (A_LIKELY(mRandomness >= 10)) // reduce useless calculations
- {
- const int rand2 = mRandomness * 2;
- mVelocity.x += static_cast<float>(mrand() % rand2 - mRandomness)
- / 1000.0F;
- mVelocity.y += static_cast<float>(mrand() % rand2 - mRandomness)
- / 1000.0F;
- mVelocity.z += static_cast<float>(mrand() % rand2 - mRandomness)
- / 1000.0F;
- }
-
- mVelocity.z -= mGravity;
-
- // Update position
- mPos.x += mVelocity.x;
- mPos.y += mVelocity.y * SIN45;
- mPos.z += mVelocity.z * SIN45;
-
- // Update other stuff
- if (A_LIKELY(mLifetimeLeft > 0))
- mLifetimeLeft--;
-
- mLifetimePast++;
-
- if (mPos.z < 0.0F)
- {
- if (mBounce > 0.0F)
- {
- mPos.z *= -mBounce;
- mVelocity *= mBounce;
- mVelocity.z = -mVelocity.z;
- }
- else
- {
- mAlive = AliveStatus::DEAD_FLOOR;
- }
- }
- else if (mPos.z > ParticleEngine::PARTICLE_SKY)
- {
- mAlive = AliveStatus::DEAD_SKY;
- }
-
- // Update child emitters
- if ((ParticleEngine::emitterSkip != 0) &&
- (mLifetimePast - 1) % ParticleEngine::emitterSkip == 0)
- {
- FOR_EACH (EmitterConstIterator, e, mChildEmitters)
- {
- STD_VECTOR<Particle*> newParticles;
- (*e)->createParticles(mLifetimePast, newParticles);
- FOR_EACH (STD_VECTOR<Particle*>::const_iterator,
- it,
- newParticles)
- {
- Particle *const p = *it;
- p->moveBy(mPos);
- mChildParticles.push_back(p);
- if (p->mFollow)
- mChildMoveParticles.push_back(p);
- }
- }
- }
-
- // create death effect when the particle died
- if (A_UNLIKELY(mAlive != AliveStatus::ALIVE &&
- mAlive != AliveStatus::DEAD_LONG_AGO))
- {
- if ((CAST_U32(mAlive) & mDeathEffectConditions)
- > 0x00 && !mDeathEffect.empty())
- {
- Particle *restrict const deathEffect = particleEngine->addEffect(
- mDeathEffect, 0, 0);
- if (deathEffect != nullptr)
- deathEffect->moveBy(mPos);
- }
- mAlive = AliveStatus::DEAD_LONG_AGO;
- }
-}
-
-bool Particle::update() restrict2
-{
- if (A_LIKELY(mAlive == AliveStatus::ALIVE))
- {
- if (A_UNLIKELY(mLifetimeLeft == 0))
- {
- mAlive = AliveStatus::DEAD_TIMEOUT;
- if (mChildParticles.empty())
- {
- if (mAutoDelete)
- return false;
- return true;
- }
- }
- else
- {
- if (mAnimation != nullptr)
- {
- if (mType == ParticleType::Animation)
- {
- // particle engine is updated every 10ms
- mAnimation->update(10);
- }
- else // ParticleType::Rotational
- {
- // TODO: cache velocities to avoid spamming atan2()
- const int size = mAnimation->getLength();
- if (size == 0)
- return false;
-
- float rad = static_cast<float>(atan2(mVelocity.x,
- mVelocity.y));
- if (rad < 0)
- rad = PI2 + rad;
-
- const float range = static_cast<float>(PI / size);
-
- // Determines which frame the particle should play
- if (A_UNLIKELY(rad < range || rad > PI2 - range))
- {
- mAnimation->setFrame(0);
- }
- else
- {
- const float range2 = 2 * range;
- // +++ need move condition outside of for
- for (int c = 1; c < size; c++)
- {
- const float cRange = static_cast<float>(c) *
- range2;
- if (cRange - range < rad &&
- rad < cRange + range)
- {
- mAnimation->setFrame(c);
- break;
- }
- }
- }
- }
- mImage = mAnimation->getCurrentImage();
- }
- const Vector oldPos = mPos;
-
- updateSelf();
-
- const Vector change = mPos - oldPos;
- if (mChildParticles.empty())
- {
- if (mAlive != AliveStatus::ALIVE &&
- mAutoDelete)
- {
- return false;
- }
- return true;
- }
- for (ParticleIterator p = mChildMoveParticles.begin(),
- fp2 = mChildMoveParticles.end(); p != fp2; )
- {
- // move particle with its parent if desired
- (*p)->moveBy(change);
- ++p;
- }
- }
-
- // Update child particles
- for (ParticleIterator p = mChildParticles.begin(),
- fp2 = mChildParticles.end(); p != fp2; )
- {
- Particle *restrict const particle = *p;
- // update particle
- if (A_LIKELY(particle->update()))
- {
- ++p;
- }
- else
- {
- mChildMoveParticles.remove(*p);
- delete particle;
- p = mChildParticles.erase(p);
- }
- }
- if (A_UNLIKELY(mAlive != AliveStatus::ALIVE &&
- mChildParticles.empty() &&
- mAutoDelete))
- {
- return false;
- }
- }
- else
- {
- if (mChildParticles.empty())
- {
- if (mAutoDelete)
- return false;
- return true;
- }
- // Update child particles
- for (ParticleIterator p = mChildParticles.begin(),
- fp2 = mChildParticles.end(); p != fp2; )
- {
- Particle *restrict const particle = *p;
- // update particle
- if (A_LIKELY(particle->update()))
- {
- ++p;
- }
- else
- {
- mChildMoveParticles.remove(*p);
- delete particle;
- p = mChildParticles.erase(p);
- }
- }
- if (A_UNLIKELY(mChildParticles.empty() &&
- mAutoDelete))
- {
- return false;
- }
- }
-
- return true;
-}
-
-void Particle::moveBy(const Vector &restrict change) restrict2
-{
- mPos += change;
- FOR_EACH (ParticleConstIterator, p, mChildMoveParticles)
- {
- (*p)->moveBy(change);
- }
-}
-
-void Particle::moveTo(const float x, const float y) restrict2
-{
- moveTo(Vector(x, y, mPos.z));
-}
-
-Particle *Particle::addEffect(const std::string &restrict particleEffectFile,
- const int pixelX, const int pixelY,
- const int rotation) restrict2
-{
- Particle *newParticle = nullptr;
-
- const size_t pos = particleEffectFile.find('|');
- const std::string dyePalettes = (pos != std::string::npos)
- ? particleEffectFile.substr(pos + 1) : "";
- XML::Document *doc = Loader::getXml(particleEffectFile.substr(0, pos),
- UseVirtFs_true,
- SkipError_false);
- if (doc == nullptr)
- return nullptr;
- XmlNodeConstPtrConst rootNode = doc->rootNode();
-
- if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "effect"))
- {
- logger->log("Error loading particle: %s", particleEffectFile.c_str());
- doc->decRef();
- return nullptr;
- }
-
- // Parse particles
- for_each_xml_child_node(effectChildNode, rootNode)
- {
- // We're only interested in particles
- if (!xmlNameEqual(effectChildNode, "particle"))
- continue;
-
- // Determine the exact particle type
- XmlNodePtr node;
-
- // Animation
- if ((node = XML::findFirstChildByName(effectChildNode, "animation")) !=
- nullptr)
- {
- newParticle = new AnimationParticle(node, dyePalettes);
- newParticle->setMap(mMap);
- }
- // Rotational
- else if ((node = XML::findFirstChildByName(
- effectChildNode, "rotation")) != nullptr)
- {
- newParticle = new RotationalParticle(node, dyePalettes);
- newParticle->setMap(mMap);
- }
- // Image
- else if ((node = XML::findFirstChildByName(effectChildNode,
- "image")) != nullptr)
- {
- std::string imageSrc;
- if (XmlHaveChildContent(node))
- imageSrc = XmlChildContent(node);
- if (!imageSrc.empty() && !dyePalettes.empty())
- Dye::instantiate(imageSrc, dyePalettes);
- Image *const img = Loader::getImage(imageSrc);
-
- newParticle = new ImageParticle(img);
- newParticle->setMap(mMap);
- }
- // Other
- else
- {
- newParticle = new Particle;
- newParticle->setMap(mMap);
- }
-
- // Read and set the basic properties of the particle
- const float offsetX = XML::getFloatProperty(
- effectChildNode, "position-x", 0);
- const float offsetY = XML::getFloatProperty(
- effectChildNode, "position-y", 0);
- const float offsetZ = XML::getFloatProperty(
- effectChildNode, "position-z", 0);
- const Vector position(mPos.x + static_cast<float>(pixelX) + offsetX,
- mPos.y + static_cast<float>(pixelY) + offsetY,
- mPos.z + offsetZ);
- newParticle->moveTo(position);
-
- const int lifetime = XML::getProperty(effectChildNode, "lifetime", -1);
- newParticle->setLifetime(lifetime);
- const bool resizeable = "false" != XML::getProperty(effectChildNode,
- "size-adjustable", "false");
-
- newParticle->setAllowSizeAdjust(resizeable);
-
- // Look for additional emitters for this particle
- for_each_xml_child_node(emitterNode, effectChildNode)
- {
- if (xmlNameEqual(emitterNode, "emitter"))
- {
- ParticleEmitter *restrict const newEmitter =
- new ParticleEmitter(
- emitterNode,
- newParticle,
- mMap,
- rotation,
- dyePalettes);
- newParticle->addEmitter(newEmitter);
- }
- else if (xmlNameEqual(emitterNode, "deatheffect"))
- {
- std::string deathEffect;
- if ((node != nullptr) && XmlHaveChildContent(node))
- deathEffect = XmlChildContent(emitterNode);
-
- char deathEffectConditions = 0x00;
- if (XML::getBoolProperty(emitterNode, "on-floor", true))
- {
- deathEffectConditions += CAST_S8(
- AliveStatus::DEAD_FLOOR);
- }
- if (XML::getBoolProperty(emitterNode, "on-sky", true))
- {
- deathEffectConditions += CAST_S8(
- AliveStatus::DEAD_SKY);
- }
- if (XML::getBoolProperty(emitterNode, "on-other", false))
- {
- deathEffectConditions += CAST_S8(
- AliveStatus::DEAD_OTHER);
- }
- if (XML::getBoolProperty(emitterNode, "on-impact", true))
- {
- deathEffectConditions += CAST_S8(
- AliveStatus::DEAD_IMPACT);
- }
- if (XML::getBoolProperty(emitterNode, "on-timeout", true))
- {
- deathEffectConditions += CAST_S8(
- AliveStatus::DEAD_TIMEOUT);
- }
- newParticle->setDeathEffect(
- deathEffect, deathEffectConditions);
- }
- }
-
- mChildParticles.push_back(newParticle);
- }
-
- doc->decRef();
- return newParticle;
-}
-
-void Particle::adjustEmitterSize(const int w, const int h) restrict2
-{
- if (mAllowSizeAdjust)
- {
- FOR_EACH (EmitterConstIterator, e, mChildEmitters)
- (*e)->adjustSize(w, h);
- }
-}
-
-void Particle::prepareToDie() restrict2
-{
- FOR_EACH (ParticleIterator, p, mChildParticles)
- {
- Particle *restrict const particle = *p;
- if (particle == nullptr)
- continue;
- particle->prepareToDie();
- if (particle->isAlive() &&
- particle->mLifetimeLeft == -1 &&
- particle->mAutoDelete)
- {
- particle->kill();
- }
- }
-}
-
-void Particle::clear() restrict2
-{
- delete_all(mChildEmitters);
- mChildEmitters.clear();
-
- delete_all(mChildParticles);
- mChildParticles.clear();
-
- mChildMoveParticles.clear();
-}
diff --git a/src/particle/particle.h b/src/particle/particle.h
deleted file mode 100644
index 7004af0e6..000000000
--- a/src/particle/particle.h
+++ /dev/null
@@ -1,329 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2006-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 PARTICLE_PARTICLE_H
-#define PARTICLE_PARTICLE_H
-
-#include "being/actor.h"
-
-#include "enums/particle/alivestatus.h"
-#include "enums/particle/particletype.h"
-
-#include "enums/simpletypes/beingid.h"
-
-#include "particle/particleengine.h"
-
-#include "localconsts.h"
-
-class Image;
-class ParticleEmitter;
-class SimpleAnimation;
-
-/**
- * A particle spawned by a ParticleEmitter.
- */
-class Particle notfinal : public Actor
-{
- public:
- friend class ParticleEngine;
-
- Particle();
-
- A_DELETE_COPY(Particle)
-
- /**
- * Destructor.
- */
- virtual ~Particle();
-
- /**
- * Deletes all child particles and emitters.
- */
- void clear() restrict2;
-
- /**
- * Updates particle position, returns false when the particle should
- * be deleted.
- */
- bool update() restrict2;
-
- /**
- * Draws the particle image.
- */
- void draw(Graphics *restrict const graphics,
- const int offsetX,
- const int offsetY) const restrict2 override
- A_CONST A_NONNULL(2);
-
- /**
- * Necessary for sorting with the other sprites.
- */
- int getPixelY() const restrict2 override A_WARN_UNUSED
- { return CAST_S32(mPos.y) - 16; }
-
- /**
- * Necessary for sorting with the other sprites for sorting only.
- */
- int getSortPixelY() const restrict2 override A_WARN_UNUSED
- { return CAST_S32(mPos.y) - 16; }
-
- /**
- * Creates a child particle that hosts some emitters described in the
- * particleEffectFile.
- */
- Particle *addEffect(const std::string &restrict particleEffectFile,
- const int pixelX, const int pixelY,
- const int rotation = 0) restrict2;
-
- /**
- * Adds an emitter to the particle.
- */
- void addEmitter(ParticleEmitter *const emitter) restrict2 A_NONNULL(2)
- { mChildEmitters.push_back(emitter); }
-
- /**
- * Sets the position in 3 dimensional space in pixels relative to map.
- */
- void moveTo(const Vector &restrict pos) restrict2
- { moveBy(pos - mPos); }
-
- /**
- * Sets the position in 2 dimensional space in pixels relative to map.
- */
- void moveTo(const float x, const float y) restrict2;
-
- /**
- * Changes the particle position relative
- */
- void moveBy(const Vector &restrict change) restrict2;
-
- /**
- * Sets the time in game ticks until the particle is destroyed.
- */
- void setLifetime(const int lifetime) restrict2 noexcept2
- { mLifetimeLeft = lifetime; mLifetimePast = 0; }
-
- /**
- * Sets the age of the pixel in game ticks where the particle has
- * faded in completely.
- */
- void setFadeOut(const int fadeOut) restrict2 noexcept2
- { mFadeOut = fadeOut; }
-
- /**
- * Sets the remaining particle lifetime where the particle starts to
- * fade out.
- */
- void setFadeIn(const int fadeIn) restrict2 noexcept2
- { mFadeIn = fadeIn; }
-
- /**
- * Sets the current velocity in 3 dimensional space.
- */
- void setVelocity(const float x,
- const float y,
- const float z) restrict2 noexcept2
- { mVelocity.x = x; mVelocity.y = y; mVelocity.z = z; }
-
- /**
- * Sets the downward acceleration.
- */
- void setGravity(const float gravity) restrict2 noexcept2
- { mGravity = gravity; }
-
- /**
- * Sets the ammount of random vector changes
- */
- void setRandomness(const int r) restrict2 noexcept2
- { mRandomness = r; }
-
- /**
- * Sets the ammount of velocity particles retain after
- * hitting the ground.
- */
- void setBounce(const float bouncieness) restrict2 noexcept2
- { mBounce = bouncieness; }
-
- /**
- * Sets the flag if the particle is supposed to be moved by its parent
- */
- void setFollow(const bool follow) restrict2 noexcept2
- { mFollow = follow; }
-
- /**
- * Gets the flag if the particle is supposed to be moved by its parent
- */
- bool doesFollow() const restrict2 noexcept2 A_WARN_UNUSED
- { return mFollow; }
-
- /**
- * Makes the particle move toward another particle with a
- * given acceleration and momentum
- */
- void setDestination(Particle *restrict const target,
- const float accel,
- const float moment) restrict2 noexcept2
- A_NONNULL(2)
- { mTarget = target; mAcceleration = accel; mMomentum = moment; }
-
- /**
- * Sets the distance in pixel the particle can come near the target
- * particle before it is destroyed. Does only make sense after a target
- * particle has been set using setDestination.
- */
- void setDieDistance(const float dist) restrict2
- { mInvDieDistance = 1.0F / dist; }
-
- /**
- * Changes the size of the emitters so that the effect fills a
- * rectangle of this size
- */
- void adjustEmitterSize(const int w, const int h) restrict2;
-
- void setAllowSizeAdjust(const bool adjust) restrict2 noexcept2
- { mAllowSizeAdjust = adjust; }
-
- bool isAlive() const restrict2 noexcept2 A_WARN_UNUSED
- { return mAlive == AliveStatus::ALIVE; }
-
- void prepareToDie() restrict2;
-
- /**
- * Determines whether the particle and its children are all dead
- */
- bool isExtinct() const restrict2 noexcept2 A_WARN_UNUSED
- { return !isAlive() && mChildParticles.empty(); }
-
- /**
- * Manually marks the particle for deletion.
- */
- void kill() restrict2 noexcept2
- { mAlive = AliveStatus::DEAD_OTHER; mAutoDelete = true; }
-
- /**
- * After calling this function the particle will only request
- * deletion when kill() is called
- */
- void disableAutoDelete() restrict2 noexcept2
- { mAutoDelete = false; }
-
- /** We consider particles (at least for now) to be one layer-sprites */
- int getNumberOfLayers() const restrict2 override final
- { return 1; }
-
- float getAlpha() const restrict2 override final
- { return 1.0F; }
-
- void setAlpha(const float alpha A_UNUSED) restrict2 override
- { }
-
- virtual void setDeathEffect(const std::string &restrict effectFile,
- const signed char conditions) restrict2
- { mDeathEffect = effectFile; mDeathEffectConditions = conditions; }
-
- void setActor(const BeingId actor)
- { mActor = actor; }
-
- protected:
- void updateSelf() restrict2;
-
- // Opacity of the graphical representation of the particle
- float mAlpha;
-
- // Lifetime left in game ticks
- int mLifetimeLeft;
-
- // Age of the particle in game ticks
- int mLifetimePast;
-
- // Lifetime in game ticks left where fading out begins
- int mFadeOut;
-
- // Age in game ticks where fading in is finished
- int mFadeIn;
-
- // Speed in pixels per game-tick.
- Vector mVelocity;
-
- // Is the particle supposed to be drawn and updated?
- AliveStatusT mAlive;
-
- ParticleTypeT mType;
-
- /**< Used animation for this particle */
- SimpleAnimation *restrict mAnimation;
-
- /**< The image used for this particle. */
- Image *restrict mImage;
-
- BeingId mActor;
-
- private:
- // List of child emitters.
- Emitters mChildEmitters;
-
- // List of particles controlled by this particle
- Particles mChildParticles;
-
- Particles mChildMoveParticles;
-
- // Particle effect file to be spawned when the particle dies
- std::string mDeathEffect;
-
- // dynamic particle
- // Downward acceleration in pixels per game-tick.
- float mGravity;
-
- // How much the particle bounces off when hitting the ground
- float mBounce;
-
- // Acceleration towards the target particle in pixels per game-tick
- float mAcceleration;
-
- // Distance in pixels from the target particle that causes
- // the destruction of the particle
- float mInvDieDistance;
-
- // How much speed the particle retains after each game tick
- float mMomentum;
-
- // The particle that attracts this particle
- Particle *restrict mTarget;
-
- // Ammount of random vector change
- int mRandomness;
-
- // Bitfield of death conditions which trigger spawning
- // of the death particle
- signed char mDeathEffectConditions;
-
- // May the particle request its deletion by the parent particle?
- bool mAutoDelete;
-
- // Can the effect size be adjusted by the object props in the map file?
- bool mAllowSizeAdjust;
-
- // is this particle moved when its parent particle moves?
- bool mFollow;
-};
-
-#endif // PARTICLE_PARTICLE_H
diff --git a/src/particle/particlecontainer.cpp b/src/particle/particlecontainer.cpp
deleted file mode 100644
index b69cd091d..000000000
--- a/src/particle/particlecontainer.cpp
+++ /dev/null
@@ -1,55 +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 "particle/particlecontainer.h"
-
-#include "utils/delete2.h"
-
-#include "debug.h"
-
-ParticleContainer::ParticleContainer(ParticleContainer *const parent,
- const bool delParent) :
- mNext(parent),
- mDelParent(delParent)
-{
-}
-
-ParticleContainer::~ParticleContainer()
-{
- // +++ call virtul method in destructor
- clearLocally();
- if (mDelParent)
- delete2(mNext)
-}
-
-void ParticleContainer::clear()
-{
- clearLocally();
- if (mNext != nullptr)
- mNext->clear();
-}
-
-void ParticleContainer::moveTo(const float x, const float y)
-{
- if (mNext != nullptr)
- mNext->moveTo(x, y);
-}
diff --git a/src/particle/particlecontainer.h b/src/particle/particlecontainer.h
deleted file mode 100644
index 7b8f9f83f..000000000
--- a/src/particle/particlecontainer.h
+++ /dev/null
@@ -1,71 +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 PARTICLE_PARTICLECONTAINER_H
-#define PARTICLE_PARTICLECONTAINER_H
-
-#include "localconsts.h"
-
-/**
- * Set of particle effects. May be stacked with other ParticleContainers. All
- * operations herein affect such stacked containers, unless the operations end
- * in `Locally'.
- */
-class ParticleContainer notfinal
-{
- public:
- /**
- * Constructs a new particle container and assumes responsibility for
- * its parent (for all operations defined herein,
- * except when ending in `Locally')
- *
- * delParent means that the destructor should also free the parent.
- */
- explicit ParticleContainer(ParticleContainer *const parent = nullptr,
- const bool delParent = true);
-
- A_DELETE_COPY(ParticleContainer)
-
- virtual ~ParticleContainer();
-
- /**
- * Kills and removes all particle effects
- */
- void clear();
-
- /**
- * Kills and removes all particle effects (only in this container)
- */
- virtual void clearLocally()
- { }
-
- /**
- * Sets the positions of all elements
- */
- virtual void moveTo(const float x, const float y);
-
- protected:
- ParticleContainer *mNext; /**< Contained container, if any */
- bool mDelParent; /**< Delete mNext in destructor */
-};
-
-#endif // PARTICLE_PARTICLECONTAINER_H
diff --git a/src/particle/particleemitter.cpp b/src/particle/particleemitter.cpp
deleted file mode 100644
index 642acd851..000000000
--- a/src/particle/particleemitter.cpp
+++ /dev/null
@@ -1,632 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2006-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 "particle/particleemitter.h"
-
-#include "logger.h"
-
-#include "const/resources/map/map.h"
-
-#include "particle/animationparticle.h"
-#include "particle/rotationalparticle.h"
-
-#include "utils/foreach.h"
-
-#include "resources/imageset.h"
-
-#include "resources/dye/dye.h"
-
-#include "resources/image/image.h"
-
-#include "resources/loaders/imageloader.h"
-#include "resources/loaders/imagesetloader.h"
-#include "resources/loaders/subimageloader.h"
-#include "resources/loaders/subimagesetloader.h"
-
-#include "debug.h"
-
-static const float SIN45 = 0.707106781F;
-static const float DEG_RAD_FACTOR = 0.017453293F;
-
-typedef STD_VECTOR<ImageSet*>::const_iterator ImageSetVectorCIter;
-typedef std::list<ParticleEmitter>::const_iterator ParticleEmitterListCIter;
-
-ParticleEmitter::ParticleEmitter(XmlNodeConstPtrConst emitterNode,
- Particle *const target,
- Map *const map, const int rotation,
- const std::string& dyePalettes) :
- mParticleTarget(target),
- mMap(map),
- mOutput(),
- mOutputPause(),
- mParticleImage(nullptr),
- mParticleAnimation("particle animation"),
- mParticleRotation("particle rotation"),
- mParticleAlpha(),
- mDeathEffect(),
- mParticleChildEmitters(),
- mTempSets(),
- mOutputPauseLeft(0),
- mDeathEffectConditions(0),
- mParticleFollow(false)
-{
- // Initializing default values
- mParticlePosX.set(0.0F);
- mParticlePosY.set(0.0F);
- mParticlePosZ.set(0.0F);
- mParticleAngleHorizontal.set(0.0F);
- mParticleAngleVertical.set(0.0F);
- mParticlePower.set(0.0F);
- mParticleGravity.set(0.0F);
- mParticleRandomness.set(0);
- mParticleBounce.set(0.0F);
- mParticleAcceleration.set(0.0F);
- mParticleDieDistance.set(-1.0F);
- mParticleMomentum.set(1.0F);
- mParticleLifetime.set(-1);
- mParticleFadeOut.set(0);
- mParticleFadeIn.set(0);
- mOutput.set(1);
- mOutputPause.set(0);
- mParticleAlpha.set(1.0F);
-
- if (emitterNode == nullptr)
- return;
- for_each_xml_child_node(propertyNode, emitterNode)
- {
- if (xmlNameEqual(propertyNode, "property"))
- {
- const std::string name = XML::getProperty(
- propertyNode, "name", "");
-
- if (name == "position-x")
- {
- mParticlePosX = readParticleEmitterProp(propertyNode, 0.0F);
- }
- else if (name == "position-y")
- {
- mParticlePosY = readParticleEmitterProp(propertyNode, 0.0F);
- mParticlePosY.minVal *= SIN45;
- mParticlePosY.maxVal *= SIN45;
- mParticlePosY.changeAmplitude *= SIN45;
- }
- else if (name == "position-z")
- {
- mParticlePosZ = readParticleEmitterProp(propertyNode, 0.0F);
- mParticlePosZ.minVal *= SIN45;
- mParticlePosZ.maxVal *= SIN45;
- mParticlePosZ.changeAmplitude *= SIN45;
- }
- else if (name == "image")
- {
- std::string image = XML::getProperty(
- propertyNode, "value", "");
- // Don't leak when multiple images are defined
- if (!image.empty() && (mParticleImage == nullptr))
- {
- if (!dyePalettes.empty())
- Dye::instantiate(image, dyePalettes);
- mParticleImage = Loader::getImage(image);
- }
- }
- else if (name == "subimage")
- {
- std::string image = XML::getProperty(
- propertyNode, "value", "");
- // Don't leak when multiple images are defined
- if (!image.empty() && (mParticleImage == nullptr))
- {
- if (!dyePalettes.empty())
- Dye::instantiate(image, dyePalettes);
- Image *img = Loader::getImage(image);
- if (img != nullptr)
- {
- mParticleImage = Loader::getSubImage(img,
- XML::getProperty(propertyNode, "x", 0),
- XML::getProperty(propertyNode, "y", 0),
- XML::getProperty(propertyNode, "width", 0),
- XML::getProperty(propertyNode, "height", 0));
- img->decRef();
- }
- else
- {
- mParticleImage = nullptr;
- }
- }
- }
- else if (name == "horizontal-angle")
- {
- mParticleAngleHorizontal =
- readParticleEmitterProp(propertyNode, 0.0F);
- mParticleAngleHorizontal.minVal
- += static_cast<float>(rotation);
- mParticleAngleHorizontal.minVal *= DEG_RAD_FACTOR;
- mParticleAngleHorizontal.maxVal
- += static_cast<float>(rotation);
- mParticleAngleHorizontal.maxVal *= DEG_RAD_FACTOR;
- mParticleAngleHorizontal.changeAmplitude *= DEG_RAD_FACTOR;
- }
- else if (name == "vertical-angle")
- {
- mParticleAngleVertical =
- readParticleEmitterProp(propertyNode, 0.0F);
- mParticleAngleVertical.minVal *= DEG_RAD_FACTOR;
- mParticleAngleVertical.maxVal *= DEG_RAD_FACTOR;
- mParticleAngleVertical.changeAmplitude *= DEG_RAD_FACTOR;
- }
- else if (name == "power")
- {
- mParticlePower = readParticleEmitterProp(propertyNode, 0.0F);
- }
- else if (name == "gravity")
- {
- mParticleGravity = readParticleEmitterProp(propertyNode, 0.0F);
- }
- else if (name == "randomnes"
- || name == "randomness") // legacy bug
- {
- mParticleRandomness = readParticleEmitterProp(propertyNode, 0);
- }
- else if (name == "bounce")
- {
- mParticleBounce = readParticleEmitterProp(propertyNode, 0.0F);
- }
- else if (name == "lifetime")
- {
- mParticleLifetime = readParticleEmitterProp(propertyNode, 0);
- mParticleLifetime.minVal += 1;
- }
- else if (name == "output")
- {
- mOutput = readParticleEmitterProp(propertyNode, 0);
- mOutput.maxVal += 1;
- }
- else if (name == "output-pause")
- {
- mOutputPause = readParticleEmitterProp(propertyNode, 0);
- mOutputPauseLeft = mOutputPause.value(0);
- }
- else if (name == "acceleration")
- {
- mParticleAcceleration = readParticleEmitterProp(
- propertyNode, 0.0F);
- }
- else if (name == "die-distance")
- {
- mParticleDieDistance = readParticleEmitterProp(
- propertyNode, 0.0F);
- }
- else if (name == "momentum")
- {
- mParticleMomentum = readParticleEmitterProp(
- propertyNode, 1.0F);
- }
- else if (name == "fade-out")
- {
- mParticleFadeOut = readParticleEmitterProp(propertyNode, 0);
- }
- else if (name == "fade-in")
- {
- mParticleFadeIn = readParticleEmitterProp(propertyNode, 0);
- }
- else if (name == "alpha")
- {
- mParticleAlpha = readParticleEmitterProp(propertyNode, 1.0F);
- }
- else if (name == "follow-parent")
- {
- const std::string value = XML::getProperty(propertyNode,
- "value", "0");
- if (value == "1" || value == "true")
- mParticleFollow = true;
- }
- else
- {
- logger->log("Particle Engine: Warning, "
- "unknown emitter property \"%s\"",
- name.c_str());
- }
- }
- else if (xmlNameEqual(propertyNode, "emitter"))
- {
- ParticleEmitter newEmitter(propertyNode, mParticleTarget, map,
- rotation, dyePalettes);
- mParticleChildEmitters.push_back(newEmitter);
- }
- else if (xmlNameEqual(propertyNode, "rotation")
- || xmlNameEqual(propertyNode, "animation"))
- {
- ImageSet *const imageset = getImageSet(propertyNode);
- if (imageset == nullptr)
- {
- logger->log1("Error: no valid imageset");
- continue;
- }
- mTempSets.push_back(imageset);
-
- Animation &animation = (xmlNameEqual(propertyNode, "rotation")) !=
- 0 ? mParticleRotation : mParticleAnimation;
-
- // Get animation frames
- for_each_xml_child_node(frameNode, propertyNode)
- {
- const int delay = XML::getIntProperty(
- frameNode, "delay", 0, 0, 100000);
- const int offsetX = XML::getProperty(frameNode, "offsetX", 0)
- - imageset->getWidth() / 2 + mapTileSize / 2;
- const int offsetY = XML::getProperty(frameNode, "offsetY", 0)
- - 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)
- {
- logger->log1("No valid value for 'index'");
- continue;
- }
-
- Image *const img = imageset->get(index);
-
- if (img == nullptr)
- {
- logger->log("No image at index %d", index);
- continue;
- }
-
- animation.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)
- {
- logger->log1("No valid value for 'start' or 'end'");
- continue;
- }
-
- while (end >= start)
- {
- Image *const img = imageset->get(start);
- if (img == nullptr)
- {
- logger->log("No image at index %d", start);
- continue;
- }
-
- animation.addFrame(img, delay,
- offsetX, offsetY, rand);
- start ++;
- }
- }
- else if (xmlNameEqual(frameNode, "end"))
- {
- animation.addTerminator(rand);
- }
- } // for frameNode
- }
- else if (xmlNameEqual(propertyNode, "deatheffect"))
- {
- if (!XmlHaveChildContent(propertyNode))
- continue;
- mDeathEffect = XmlChildContent(propertyNode);
- mDeathEffectConditions = 0x00;
- if (XML::getBoolProperty(propertyNode, "on-floor", true))
- {
- mDeathEffectConditions += CAST_S8(
- AliveStatus::DEAD_FLOOR);
- }
- if (XML::getBoolProperty(propertyNode, "on-sky", true))
- {
- mDeathEffectConditions += CAST_S8(
- AliveStatus::DEAD_SKY);
- }
- if (XML::getBoolProperty(propertyNode, "on-other", false))
- {
- mDeathEffectConditions += CAST_S8(
- AliveStatus::DEAD_OTHER);
- }
- if (XML::getBoolProperty(propertyNode, "on-impact", true))
- {
- mDeathEffectConditions += CAST_S8(
- AliveStatus::DEAD_IMPACT);
- }
- if (XML::getBoolProperty(propertyNode, "on-timeout", true))
- {
- mDeathEffectConditions += CAST_S8(
- AliveStatus::DEAD_TIMEOUT);
- }
- }
- }
-}
-
-ParticleEmitter::ParticleEmitter(const ParticleEmitter &o)
-{
- *this = o;
-}
-
-ImageSet *ParticleEmitter::getImageSet(XmlNodePtrConst node)
-{
- ImageSet *imageset = nullptr;
- const int subX = XML::getProperty(node, "subX", -1);
- if (subX != -1)
- {
- Image *const img = Loader::getImage(XML::getProperty(
- node, "imageset", ""));
- if (img == nullptr)
- return nullptr;
-
- Image *const img2 = Loader::getSubImage(img, subX,
- XML::getProperty(node, "subY", 0),
- XML::getProperty(node, "subWidth", 0),
- XML::getProperty(node, "subHeight", 0));
- if (img2 == nullptr)
- {
- img->decRef();
- return nullptr;
- }
-
- imageset = Loader::getSubImageSet(img2,
- XML::getProperty(node, "width", 0),
- XML::getProperty(node, "height", 0));
- img2->decRef();
- img->decRef();
- }
- else
- {
- imageset = Loader::getImageSet(
- XML::getProperty(node, "imageset", ""),
- XML::getProperty(node, "width", 0),
- XML::getProperty(node, "height", 0));
- }
- return imageset;
-}
-
-ParticleEmitter & ParticleEmitter::operator=(const ParticleEmitter &o)
-{
- mParticlePosX = o.mParticlePosX;
- mParticlePosY = o.mParticlePosY;
- mParticlePosZ = o.mParticlePosZ;
- mParticleAngleHorizontal = o.mParticleAngleHorizontal;
- mParticleAngleVertical = o.mParticleAngleVertical;
- mParticlePower = o.mParticlePower;
- mParticleGravity = o.mParticleGravity;
- mParticleRandomness = o.mParticleRandomness;
- mParticleBounce = o.mParticleBounce;
- mParticleFollow = o.mParticleFollow;
- mParticleTarget = o.mParticleTarget;
- mParticleAcceleration = o.mParticleAcceleration;
- mParticleDieDistance = o.mParticleDieDistance;
- mParticleMomentum = o.mParticleMomentum;
- mParticleLifetime = o.mParticleLifetime;
- mParticleFadeOut = o.mParticleFadeOut;
- mParticleFadeIn = o.mParticleFadeIn;
- mParticleAlpha = o.mParticleAlpha;
- mMap = o.mMap;
- mOutput = o.mOutput;
- mOutputPause = o.mOutputPause;
- mParticleImage = o.mParticleImage;
- mParticleAnimation = o.mParticleAnimation;
- mParticleRotation = o.mParticleRotation;
- mParticleChildEmitters = o.mParticleChildEmitters;
- mDeathEffectConditions = o.mDeathEffectConditions;
- mDeathEffect = o.mDeathEffect;
- mTempSets = o.mTempSets;
-
- FOR_EACH (ImageSetVectorCIter, i, mTempSets)
- {
- if (*i != nullptr)
- (*i)->incRef();
- }
-
- mOutputPauseLeft = 0;
-
- if (mParticleImage != nullptr)
- mParticleImage->incRef();
-
- return *this;
-}
-
-ParticleEmitter::~ParticleEmitter()
-{
- FOR_EACH (ImageSetVectorCIter, i, mTempSets)
- {
- if (*i != nullptr)
- (*i)->decRef();
- }
- mTempSets.clear();
-
- if (mParticleImage != nullptr)
- {
- mParticleImage->decRef();
- mParticleImage = nullptr;
- }
-}
-
-template <typename T> ParticleEmitterProp<T>
-ParticleEmitter::readParticleEmitterProp(XmlNodePtrConst propertyNode, T def)
-{
- ParticleEmitterProp<T> retval;
-
- def = static_cast<T>(XML::getDoubleProperty(propertyNode, "value",
- static_cast<double>(def)));
- retval.set(static_cast<T>(XML::getDoubleProperty(propertyNode, "min",
- static_cast<double>(def))), static_cast<T>(XML::getDoubleProperty(
- propertyNode, "max", static_cast<double>(def))));
-
- const std::string change = XML::getProperty(
- propertyNode, "change-func", "none");
- T amplitude = static_cast<T>(XML::getDoubleProperty(propertyNode,
- "change-amplitude", 0.0));
-
- const int period = XML::getProperty(propertyNode, "change-period", 0);
- const int phase = XML::getProperty(propertyNode, "change-phase", 0);
- if (change == "saw" || change == "sawtooth")
- {
- retval.setFunction(ParticleChangeFunc::FUNC_SAW,
- amplitude, period, phase);
- }
- else if (change == "sine" || change == "sinewave")
- {
- retval.setFunction(ParticleChangeFunc::FUNC_SINE,
- amplitude, period, phase);
- }
- else if (change == "triangle")
- {
- retval.setFunction(ParticleChangeFunc::FUNC_TRIANGLE,
- amplitude, period, phase);
- }
- else if (change == "square")
- {
- retval.setFunction(ParticleChangeFunc::FUNC_SQUARE,
- amplitude, period, phase);
- }
-
- return retval;
-}
-
-void ParticleEmitter::createParticles(const int tick,
- STD_VECTOR<Particle*> &newParticles)
-{
- if (mOutputPauseLeft > 0)
- {
- mOutputPauseLeft --;
- return;
- }
- mOutputPauseLeft = mOutputPause.value(tick);
-
- for (int i = mOutput.value(tick); i > 0; i--)
- {
- // Limit maximum particles
- if (ParticleEngine::particleCount > ParticleEngine::maxCount)
- break;
-
- Particle *newParticle = nullptr;
- if (mParticleImage != nullptr)
- {
- const std::string &name = mParticleImage->mIdPath;
- if (ImageParticle::imageParticleCountByName.find(name) ==
- ImageParticle::imageParticleCountByName.end())
- {
- ImageParticle::imageParticleCountByName[name] = 0;
- }
-
- if (ImageParticle::imageParticleCountByName[name] > 200)
- break;
-
- newParticle = new ImageParticle(mParticleImage);
- newParticle->setMap(mMap);
- }
- else if (!mParticleRotation.mFrames.empty())
- {
- Animation *const newAnimation = new Animation(mParticleRotation);
- newParticle = new RotationalParticle(newAnimation);
- newParticle->setMap(mMap);
- }
- else if (!mParticleAnimation.mFrames.empty())
- {
- Animation *const newAnimation = new Animation(mParticleAnimation);
- newParticle = new AnimationParticle(newAnimation);
- newParticle->setMap(mMap);
- }
- else
- {
- newParticle = new Particle;
- newParticle->setMap(mMap);
- }
-
- const Vector position(mParticlePosX.value(tick),
- mParticlePosY.value(tick),
- mParticlePosZ.value(tick));
- newParticle->moveTo(position);
-
- const float angleH = mParticleAngleHorizontal.value(tick);
- const float cosAngleH = static_cast<float>(cos(angleH));
- const float sinAngleH = static_cast<float>(sin(angleH));
- const float angleV = mParticleAngleVertical.value(tick);
- const float cosAngleV = static_cast<float>(cos(angleV));
- const float sinAngleV = static_cast<float>(sin(angleV));
- const float power = mParticlePower.value(tick);
- newParticle->setVelocity(cosAngleH * cosAngleV * power,
- sinAngleH * cosAngleV * power,
- sinAngleV * power);
-
- newParticle->setRandomness(mParticleRandomness.value(tick));
- newParticle->setGravity(mParticleGravity.value(tick));
- newParticle->setBounce(mParticleBounce.value(tick));
- newParticle->setFollow(mParticleFollow);
-
- newParticle->setDestination(mParticleTarget,
- mParticleAcceleration.value(tick),
- mParticleMomentum.value(tick));
-
- newParticle->setDieDistance(mParticleDieDistance.value(tick));
-
- newParticle->setLifetime(mParticleLifetime.value(tick));
- newParticle->setFadeOut(mParticleFadeOut.value(tick));
- newParticle->setFadeIn(mParticleFadeIn.value(tick));
- newParticle->setAlpha(mParticleAlpha.value(tick));
-
- FOR_EACH (ParticleEmitterListCIter, it, mParticleChildEmitters)
- newParticle->addEmitter(new ParticleEmitter(*it));
-
- if (!mDeathEffect.empty())
- newParticle->setDeathEffect(mDeathEffect, mDeathEffectConditions);
-
- newParticles.push_back(newParticle);
- }
-}
-
-void ParticleEmitter::adjustSize(const int w, const int h)
-{
- if (w == 0 || h == 0)
- return; // new dimensions are illegal
-
- // calculate the old rectangle
- const int oldArea = CAST_S32(
- mParticlePosX.maxVal - mParticlePosX.minVal) * CAST_S32(
- mParticlePosX.maxVal - mParticlePosY.minVal);
- if (oldArea == 0)
- {
- // when the effect has no dimension it is
- // not designed to be resizeable
- return;
- }
-
- // set the new dimensions
- mParticlePosX.set(0, static_cast<float>(w));
- mParticlePosY.set(0, static_cast<float>(h));
- const int newArea = w * h;
- // adjust the output so that the particle density stays the same
- const float outputFactor = static_cast<float>(newArea)
- / static_cast<float>(oldArea);
- mOutput.minVal = CAST_S32(static_cast<float>(
- mOutput.minVal) * outputFactor);
- mOutput.maxVal = CAST_S32(static_cast<float>(
- mOutput.maxVal) * outputFactor);
-}
diff --git a/src/particle/particleemitter.h b/src/particle/particleemitter.h
deleted file mode 100644
index ec01b88df..000000000
--- a/src/particle/particleemitter.h
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2006-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 PARTICLE_PARTICLEEMITTER_H
-#define PARTICLE_PARTICLEEMITTER_H
-
-#include "particle/particleemitterprop.h"
-
-#include "resources/animation/animation.h"
-
-#include "utils/xml.h"
-
-#include <list>
-
-class Image;
-class ImageSet;
-class Map;
-class Particle;
-
-/**
- * Every Particle can have one or more particle emitters that create new
- * particles when they are updated
- */
-class ParticleEmitter final
-{
- public:
- ParticleEmitter(XmlNodeConstPtrConst emitterNode,
- Particle *const target,
- Map *const map,
- const int rotation = 0,
- const std::string& dyePalettes = std::string())
- A_NONNULL(3);
-
- /**
- * Copy Constructor (necessary for reference counting of particle images)
- */
- ParticleEmitter(const ParticleEmitter &o);
-
- A_DEFAULT_COPY(ParticleEmitter)
-
- /**
- * Assignment operator that calls the copy constructor
- */
- ParticleEmitter & operator=(const ParticleEmitter &o);
-
- /**
- * Destructor.
- */
- ~ParticleEmitter();
-
- /**
- * Spawns new particles
- */
- void createParticles(const int tick,
- STD_VECTOR<Particle*> &newParticles);
-
- /**
- * Sets the target of the particles that are created
- */
- void setTarget(Particle *const target)
- { mParticleTarget = target; }
-
- /**
- * Changes the size of the emitter so that the effect fills a
- * rectangle of this size
- */
- void adjustSize(const int w, const int h);
-
- private:
- template <typename T> static ParticleEmitterProp<T>
- readParticleEmitterProp(XmlNodePtrConst propertyNode, T def);
-
- ImageSet *getImageSet(XmlNodePtrConst node);
-
- /**
- * initial position of particles:
- */
- ParticleEmitterProp<float> mParticlePosX, mParticlePosY, mParticlePosZ;
-
- /**
- * initial vector of particles:
- */
- ParticleEmitterProp<float> mParticleAngleHorizontal,
- mParticleAngleVertical;
-
- /**
- * Initial velocity of particles
- */
- ParticleEmitterProp<float> mParticlePower;
-
- /*
- * Vector changing of particles:
- */
- ParticleEmitterProp<float> mParticleGravity;
- ParticleEmitterProp<int> mParticleRandomness;
- ParticleEmitterProp<float> mParticleBounce;
-
- /*
- * Properties of targeting particles:
- */
- Particle *mParticleTarget;
- ParticleEmitterProp<float> mParticleAcceleration;
- ParticleEmitterProp<float> mParticleDieDistance;
- ParticleEmitterProp<float> mParticleMomentum;
-
- /*
- * Behavior over time of the particles:
- */
- ParticleEmitterProp<int> mParticleLifetime;
- ParticleEmitterProp<int> mParticleFadeOut;
- ParticleEmitterProp<int> mParticleFadeIn;
-
- // Map the particles are spawned on
- Map *mMap;
-
- // Number of particles spawned per update
- ParticleEmitterProp<int> mOutput;
-
- // Pause in frames between two spawns
- ParticleEmitterProp<int> mOutputPause;
-
- /*
- * Graphical representation of the particles
- */
- // Particle image, if used
- Image *mParticleImage;
-
- // Filename of particle animation file
- Animation mParticleAnimation;
-
- // Filename of particle rotation file
- Animation mParticleRotation;
-
- // Opacity of the graphical representation of the particles
- ParticleEmitterProp<float> mParticleAlpha;
-
- /*
- * Death effect of the particles
- */
- std::string mDeathEffect;
-
- // List of emitters the spawned particles are equipped with
- std::list<ParticleEmitter> mParticleChildEmitters;
-
- STD_VECTOR<ImageSet*> mTempSets;
-
- int mOutputPauseLeft;
-
- signed char mDeathEffectConditions;
-
- bool mParticleFollow;
-};
-#endif // PARTICLE_PARTICLEEMITTER_H
diff --git a/src/particle/particleemitterprop.h b/src/particle/particleemitterprop.h
deleted file mode 100644
index da7d0ac5b..000000000
--- a/src/particle/particleemitterprop.h
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2006-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 PARTICLE_PARTICLEEMITTERPROP_H
-#define PARTICLE_PARTICLEEMITTERPROP_H
-
-#include <cmath>
-
-#include "enums/particle/particlechangefunc.h"
-
-#include "localconsts.h"
-
-template <typename T> struct ParticleEmitterProp final
-{
- ParticleEmitterProp() :
- minVal(0),
- maxVal(0),
- changeFunc(ParticleChangeFunc::FUNC_NONE),
- changeAmplitude(0),
- changePeriod(0),
- changePhase(0)
- {
- }
-
- A_DEFAULT_COPY(ParticleEmitterProp)
-
- void set(const T min, const T max)
- {
- minVal = min;
- maxVal = max;
- }
-
- void set(const T val)
- {
- set(val, val);
- }
-
- void setFunction(ParticleChangeFuncT func,
- T amplitude,
- const int period,
- const int phase)
- {
- changeFunc = func;
- changeAmplitude = amplitude;
- changePeriod = period;
- if (changePeriod == 0)
- changePeriod = 1;
- changePhase = phase;
- }
-
- T value(int tick) const
- {
- tick += changePhase;
- T val = static_cast<T>(minVal + (maxVal - minVal)
- * (rand() / (static_cast<double>(RAND_MAX) + 1)));
-
- switch (changeFunc)
- {
- case ParticleChangeFunc::FUNC_SINE:
- val += static_cast<T>(std::sin(M_PI * 2 * (static_cast<double>(
- tick % changePeriod) / static_cast<double>(
- changePeriod)))) * changeAmplitude;
- break;
- case ParticleChangeFunc::FUNC_SAW:
- val += static_cast<T>(changeAmplitude * (static_cast<double>(
- tick % changePeriod) / static_cast<double>(
- changePeriod))) * 2 - changeAmplitude;
- break;
- case ParticleChangeFunc::FUNC_TRIANGLE:
- if ((tick % changePeriod) * 2 < changePeriod)
- {
- val += changeAmplitude - static_cast<T>((
- tick % changePeriod) / static_cast<double>(
- changePeriod)) * changeAmplitude * 4;
- }
- else
- {
- val += changeAmplitude * -3 + static_cast<T>((
- tick % changePeriod) / static_cast<double>(
- changePeriod)) * changeAmplitude * 4;
- // I have no idea why this works but it does
- }
- break;
- case ParticleChangeFunc::FUNC_SQUARE:
- if ((tick % changePeriod) * 2 < changePeriod)
- val += changeAmplitude;
- else
- val -= changeAmplitude;
- break;
- case ParticleChangeFunc::FUNC_NONE:
- default:
- // nothing
- break;
- }
-
- return val;
- }
-
- T minVal;
- T maxVal;
-
- ParticleChangeFuncT changeFunc;
- T changeAmplitude;
- int changePeriod;
- int changePhase;
-};
-
-#endif // PARTICLE_PARTICLEEMITTERPROP_H
diff --git a/src/particle/particleengine.cpp b/src/particle/particleengine.cpp
deleted file mode 100644
index 25e85fe94..000000000
--- a/src/particle/particleengine.cpp
+++ /dev/null
@@ -1,343 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2006-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 "configuration.h"
-
-#include "gui/viewport.h"
-
-#include "particle/animationparticle.h"
-#include "particle/particleemitter.h"
-#include "particle/rotationalparticle.h"
-#include "particle/textparticle.h"
-
-#include "resources/dye/dye.h"
-
-#include "resources/loaders/imageloader.h"
-#include "resources/loaders/xmlloader.h"
-
-#include "utils/dtor.h"
-
-#include "debug.h"
-
-ParticleEngine *particleEngine = nullptr;
-
-class Image;
-
-int ParticleEngine::particleCount = 0;
-int ParticleEngine::maxCount = 0;
-ParticlePhysicsT ParticleEngine::fastPhysics = ParticlePhysics::Best;
-int ParticleEngine::emitterSkip = 1;
-bool ParticleEngine::enabled = true;
-const float ParticleEngine::PARTICLE_SKY = 800.0F;
-
-ParticleEngine::ParticleEngine() :
- mChildParticles(),
- mChildMoveParticles(),
- mMap(nullptr)
-{
- ParticleEngine::particleCount++;
-}
-
-ParticleEngine::~ParticleEngine()
-{
- // Delete child emitters and child particles
- clear();
- ParticleEngine::particleCount--;
-}
-
-void ParticleEngine::setupEngine() restrict2
-{
- ParticleEngine::maxCount = config.getIntValue("particleMaxCount");
- ParticleEngine::fastPhysics = fromInt(config.getIntValue(
- "particleFastPhysics"),
- ParticlePhysicsT);
- ParticleEngine::emitterSkip =
- config.getIntValue("particleEmitterSkip") + 1;
- if (ParticleEngine::emitterSkip == 0)
- ParticleEngine::emitterSkip = 1;
- ParticleEngine::enabled = config.getBoolValue("particleeffects");
- logger->log1("Particle engine set up");
-}
-
-bool ParticleEngine::update() restrict2
-{
- if (mChildParticles.empty() || (mMap == nullptr))
- return true;
-
- // Update child particles
-
- const int cameraX = viewport->getCameraX();
- const int cameraY = viewport->getCameraY();
- const float x1 = static_cast<float>(cameraX - 3000);
- const float y1 = static_cast<float>(cameraY - 2000);
- const float x2 = static_cast<float>(cameraX + 3000);
- const float y2 = static_cast<float>(cameraY + 2000);
-
- for (ParticleIterator p = mChildParticles.begin(),
- fp2 = mChildParticles.end(); p != fp2; )
- {
- Particle *restrict const particle = *p;
- const float posX = particle->mPos.x;
- const float posY = particle->mPos.y;
- if (posX < x1 || posX > x2 || posY < y1 || posY > y2)
- {
- ++p;
- continue;
- }
- // update particle
- if (particle->update())
- {
- ++p;
- }
- else
- {
- mChildMoveParticles.remove(*p);
- delete particle;
- p = mChildParticles.erase(p);
- }
- }
- return true;
-}
-
-Particle *ParticleEngine::createChild() restrict2
-{
- Particle *const newParticle = new Particle;
- newParticle->setMap(mMap);
- mChildParticles.push_back(newParticle);
- return newParticle;
-}
-
-Particle *ParticleEngine::addEffect(const std::string &restrict
- particleEffectFile,
- const int pixelX,
- const int pixelY,
- const int rotation) restrict2
-{
- Particle *newParticle = nullptr;
-
- const size_t pos = particleEffectFile.find('|');
- const std::string dyePalettes = (pos != std::string::npos)
- ? particleEffectFile.substr(pos + 1) : "";
- XML::Document *doc = Loader::getXml(
- particleEffectFile.substr(0, pos),
- UseVirtFs_true,
- SkipError_false);
- if (doc == nullptr)
- return nullptr;
-
- XmlNodeConstPtrConst rootNode = doc->rootNode();
-
- if ((rootNode == nullptr) || !xmlNameEqual(rootNode, "effect"))
- {
- logger->log("Error loading particle: %s", particleEffectFile.c_str());
- doc->decRef();
- return nullptr;
- }
-
- // Parse particles
- for_each_xml_child_node(effectChildNode, rootNode)
- {
- // We're only interested in particles
- if (!xmlNameEqual(effectChildNode, "particle"))
- continue;
-
- // Determine the exact particle type
- XmlNodePtr node;
-
- // Animation
- if ((node = XML::findFirstChildByName(effectChildNode, "animation")) !=
- nullptr)
- {
- newParticle = new AnimationParticle(node, dyePalettes);
- newParticle->setMap(mMap);
- }
- // Rotational
- else if ((node = XML::findFirstChildByName(
- effectChildNode, "rotation")) != nullptr)
- {
- newParticle = new RotationalParticle(node, dyePalettes);
- newParticle->setMap(mMap);
- }
- // Image
- else if ((node = XML::findFirstChildByName(effectChildNode,
- "image")) != nullptr)
- {
- std::string imageSrc;
- if (XmlHaveChildContent(node))
- imageSrc = XmlChildContent(node);
- if (!imageSrc.empty() && !dyePalettes.empty())
- Dye::instantiate(imageSrc, dyePalettes);
- Image *const img = Loader::getImage(imageSrc);
-
- newParticle = new ImageParticle(img);
- newParticle->setMap(mMap);
- }
- // Other
- else
- {
- newParticle = new Particle;
- newParticle->setMap(mMap);
- }
-
- // Read and set the basic properties of the particle
- const float offsetX = XML::getFloatProperty(
- effectChildNode, "position-x", 0);
- const float offsetY = XML::getFloatProperty(
- effectChildNode, "position-y", 0);
- const float offsetZ = XML::getFloatProperty(
- effectChildNode, "position-z", 0);
- const Vector position(static_cast<float>(pixelX) + offsetX,
- static_cast<float>(pixelY) + offsetY,
- offsetZ);
- newParticle->moveTo(position);
-
- const int lifetime = XML::getProperty(effectChildNode, "lifetime", -1);
- newParticle->setLifetime(lifetime);
- const bool resizeable = "false" != XML::getProperty(effectChildNode,
- "size-adjustable", "false");
-
- newParticle->setAllowSizeAdjust(resizeable);
-
- // Look for additional emitters for this particle
- for_each_xml_child_node(emitterNode, effectChildNode)
- {
- if (xmlNameEqual(emitterNode, "emitter"))
- {
- ParticleEmitter *restrict const newEmitter =
- new ParticleEmitter(
- emitterNode,
- newParticle,
- mMap,
- rotation,
- dyePalettes);
- newParticle->addEmitter(newEmitter);
- }
- else if (xmlNameEqual(emitterNode, "deatheffect"))
- {
- std::string deathEffect;
- if ((node != nullptr) && XmlHaveChildContent(node))
- deathEffect = XmlChildContent(emitterNode);
-
- char deathEffectConditions = 0x00;
- if (XML::getBoolProperty(emitterNode, "on-floor", true))
- {
- deathEffectConditions += CAST_S8(
- AliveStatus::DEAD_FLOOR);
- }
- if (XML::getBoolProperty(emitterNode, "on-sky", true))
- {
- deathEffectConditions += CAST_S8(
- AliveStatus::DEAD_SKY);
- }
- if (XML::getBoolProperty(emitterNode, "on-other", false))
- {
- deathEffectConditions += CAST_S8(
- AliveStatus::DEAD_OTHER);
- }
- if (XML::getBoolProperty(emitterNode, "on-impact", true))
- {
- deathEffectConditions += CAST_S8(
- AliveStatus::DEAD_IMPACT);
- }
- if (XML::getBoolProperty(emitterNode, "on-timeout", true))
- {
- deathEffectConditions += CAST_S8(
- AliveStatus::DEAD_TIMEOUT);
- }
- newParticle->setDeathEffect(
- deathEffect, deathEffectConditions);
- }
- }
-
- mChildParticles.push_back(newParticle);
- }
-
- doc->decRef();
- return newParticle;
-}
-
-Particle *ParticleEngine::addTextSplashEffect(const std::string &restrict text,
- const int x,
- const int y,
- const Color *restrict const
- color,
- Font *restrict const font,
- const bool outline) restrict2
-{
- Particle *const newParticle = new TextParticle(
- text,
- color,
- font,
- outline);
- newParticle->setMap(mMap);
- newParticle->moveTo(static_cast<float>(x),
- static_cast<float>(y));
- newParticle->setVelocity(
- static_cast<float>((rand() % 100) - 50) / 200.0F, // X
- static_cast<float>((rand() % 100) - 50) / 200.0F, // Y
- (static_cast<float>((rand() % 100)) / 200.0F) + 4.0F); // Z
-
- newParticle->setGravity(0.1F);
- newParticle->setBounce(0.5F);
- newParticle->setLifetime(200);
- newParticle->setFadeOut(100);
-
- mChildParticles.push_back(newParticle);
-
- return newParticle;
-}
-
-Particle *ParticleEngine::addTextRiseFadeOutEffect(const std::string &restrict
- text,
- const int x,
- const int y,
- const Color *restrict const
- color,
- Font *restrict const font,
- const bool outline)
- restrict2
-{
- Particle *const newParticle = new TextParticle(
- text,
- color,
- font,
- outline);
- newParticle->setMap(mMap);
- newParticle->moveTo(static_cast<float>(x),
- static_cast<float>(y));
- newParticle->setVelocity(0.0F, 0.0F, 0.5F);
- newParticle->setGravity(0.0015F);
- newParticle->setLifetime(300);
- newParticle->setFadeOut(100);
- newParticle->setFadeIn(0);
-
- mChildParticles.push_back(newParticle);
-
- return newParticle;
-}
-
-void ParticleEngine::clear() restrict2
-{
- delete_all(mChildParticles);
- mChildParticles.clear();
- mChildMoveParticles.clear();
-}
diff --git a/src/particle/particleengine.h b/src/particle/particleengine.h
deleted file mode 100644
index 19a9c4e9f..000000000
--- a/src/particle/particleengine.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2006-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 PARTICLE_PARTICLEENGINE_H
-#define PARTICLE_PARTICLEENGINE_H
-
-#include "enums/particle/particlephysics.h"
-
-#include <list>
-#include <string>
-
-#include "localconsts.h"
-
-class Color;
-class Font;
-class Map;
-class Particle;
-class ParticleEmitter;
-
-typedef std::list<Particle *> Particles;
-typedef Particles::iterator ParticleIterator;
-typedef Particles::const_iterator ParticleConstIterator;
-typedef std::list<ParticleEmitter *> Emitters;
-typedef Emitters::iterator EmitterIterator;
-typedef Emitters::const_iterator EmitterConstIterator;
-
-class ParticleEngine final
-{
- public:
- static const float PARTICLE_SKY; // Maximum Z position of particles
- static ParticlePhysicsT fastPhysics; // Mode of squareroot calculation
- static int particleCount; // Current number of particles
- static int maxCount; // Maximum number of particles
- static int emitterSkip; // Duration of pause between two
- // emitter updates in ticks
- static bool enabled; // true when non-crucial particle effects
- // are disabled
-
- ParticleEngine();
-
- A_DELETE_COPY(ParticleEngine)
-
- /**
- * Destructor.
- */
- ~ParticleEngine();
-
- /**
- * Deletes all child particles and emitters.
- */
- void clear() restrict2;
-
- /**
- * Gives a particle the properties of an engine root particle and loads
- * the particle-related config settings.
- */
- void setupEngine() restrict2;
-
- /**
- * Updates particle position, returns false when the particle should
- * be deleted.
- */
- bool update() restrict2;
-
- /**
- * Creates a blank particle as a child of the current particle
- * Useful for creating target particles
- */
- Particle *createChild() restrict2;
-
- /**
- * Creates a child particle that hosts some emitters described in the
- * particleEffectFile.
- */
- Particle *addEffect(const std::string &restrict particleEffectFile,
- const int pixelX, const int pixelY,
- const int rotation = 0) restrict2;
-
- /**
- * Creates a standalone text particle.
- */
- Particle *addTextSplashEffect(const std::string &restrict text,
- const int x, const int y,
- const Color *restrict const color,
- Font *restrict const font,
- const bool outline = false)
- restrict2 A_NONNULL(5, 6);
-
- /**
- * Creates a standalone text particle.
- */
- Particle *addTextRiseFadeOutEffect(const std::string &restrict text,
- const int x, const int y,
- const Color *restrict const color,
- Font *restrict const font,
- const bool outline = false)
- restrict2 A_NONNULL(5, 6);
-
- void setMap(Map *const map)
- { mMap = map; }
-
- private:
- // List of particles controlled by this particle
- Particles mChildParticles;
- Particles mChildMoveParticles;
- Map *mMap;
-};
-
-extern ParticleEngine *particleEngine;
-
-#endif // PARTICLE_PARTICLEENGINE_H
diff --git a/src/particle/particleinfo.h b/src/particle/particleinfo.h
deleted file mode 100644
index 48129f553..000000000
--- a/src/particle/particleinfo.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 PARTICLE_PARTICLEINFO_H
-#define PARTICLE_PARTICLEINFO_H
-
-#include "particle/particle.h"
-
-#include "utils/vector.h"
-
-struct ParticleInfo final
-{
- ParticleInfo() :
- files(),
- particles()
- {
- }
-
- A_DELETE_COPY(ParticleInfo)
-
- STD_VECTOR<std::string> files;
- STD_VECTOR<Particle*> particles;
-};
-
-#endif // PARTICLE_PARTICLEINFO_H
diff --git a/src/particle/particlelist.cpp b/src/particle/particlelist.cpp
deleted file mode 100644
index 26194453b..000000000
--- a/src/particle/particlelist.cpp
+++ /dev/null
@@ -1,106 +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 "particle/particlelist.h"
-
-#include "utils/foreach.h"
-
-#include "particle/particle.h"
-
-#include "debug.h"
-
-typedef std::list<Particle *>::iterator ParticleListIter;
-typedef std::list<Particle *>::const_iterator ParticleListCIter;
-
-ParticleList::ParticleList(ParticleContainer *const parent,
- const bool delParent) :
- ParticleContainer(parent, delParent),
- mElements(),
- mSize(0U)
-{}
-
-ParticleList::~ParticleList()
-{
-}
-
-void ParticleList::addLocally(Particle *const particle)
-{
- if (particle != nullptr)
- {
- mElements.push_back(particle);
- mSize ++;
- }
-}
-
-void ParticleList::removeLocally(const Particle *const particle)
-{
- for (std::list<Particle *>::iterator it = mElements.begin();
- it != mElements.end(); )
- {
- Particle *const p = *it;
- if (p == particle)
- {
- p->kill();
- p->prepareToDie();
- it = mElements.erase(it);
- mSize --;
- }
- else
- {
- ++it;
- }
- }
-}
-
-void ParticleList::clearLocally()
-{
- FOR_EACH (ParticleListCIter, it, mElements)
- {
- (*it)->kill();
- (*it)->prepareToDie();
- }
-
- mElements.clear();
- mSize = 0U;
-}
-
-void ParticleList::moveTo(const float x, const float y)
-{
- ParticleContainer::moveTo(x, y);
-
- for (std::list<Particle *>::iterator it = mElements.begin();
- it != mElements.end(); )
- {
- Particle *const p = *it;
- p->moveTo(x, y);
- if (p->isExtinct())
- {
- p->kill();
- it = mElements.erase(it);
- mSize --;
- }
- else
- {
- ++it;
- }
- }
-}
diff --git a/src/particle/particlelist.h b/src/particle/particlelist.h
deleted file mode 100644
index 83c23a454..000000000
--- a/src/particle/particlelist.h
+++ /dev/null
@@ -1,69 +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 PARTICLE_PARTICLELIST_H
-#define PARTICLE_PARTICLELIST_H
-
-#include "particle/particlecontainer.h"
-
-#include <list>
-
-#include "localconsts.h"
-
-class Particle;
-
-/**
- * Linked list of particle effects.
- */
-class ParticleList final : public ParticleContainer
-{
- public:
- explicit ParticleList(ParticleContainer *const parent = nullptr,
- const bool delParent = true);
-
- A_DELETE_COPY(ParticleList)
-
- ~ParticleList();
-
- /**
- * Takes control of and adds a particle
- */
- void addLocally(Particle *const particle);
-
- /**
- * `kills' and removes a particle
- */
- void removeLocally(const Particle *const particle);
-
- void clearLocally() override final;
-
- void moveTo(const float x, const float y) override final;
-
- size_t size() const
- { return mSize; }
-
- protected:
- std::list<Particle *> mElements; /**< Contained particle effects */
- size_t mSize;
-};
-
-#endif // PARTICLE_PARTICLELIST_H
diff --git a/src/particle/particletimer.h b/src/particle/particletimer.h
deleted file mode 100644
index 5a4e5045a..000000000
--- a/src/particle/particletimer.h
+++ /dev/null
@@ -1,43 +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 PARTICLE_PARTICLETIMER_H
-#define PARTICLE_PARTICLETIMER_H
-
-#include "localconsts.h"
-
-class Particle;
-
-struct ParticleTimer final
-{
- ParticleTimer(Particle *const particle0,
- const time_t endTime0) A_NONNULL(2) :
- particle(particle0),
- endTime(endTime0)
- {
- }
-
- A_DEFAULT_COPY(ParticleTimer)
-
- Particle *const particle;
- const time_t endTime;
-};
-
-#endif // PARTICLE_PARTICLETIMER_H
diff --git a/src/particle/particlevector.cpp b/src/particle/particlevector.cpp
deleted file mode 100644
index 8fba56244..000000000
--- a/src/particle/particlevector.cpp
+++ /dev/null
@@ -1,109 +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 "particle/particle.h"
-#include "particle/particlevector.h"
-
-#include "debug.h"
-
-ParticleVector::ParticleVector(ParticleContainer *const parent,
- const bool delParent) :
- ParticleContainer(parent, delParent),
- mIndexedElements()
-{}
-
-ParticleVector::~ParticleVector()
-{}
-
-void ParticleVector::setLocally(const int index, Particle *const particle)
-{
- if (index < 0)
- return;
-
- delLocally(index);
-
- if (mIndexedElements.size() <= CAST_SIZE(index))
- mIndexedElements.resize(index + 1, nullptr);
-
- if (particle != nullptr)
- particle->disableAutoDelete();
- mIndexedElements[index] = particle;
-}
-
-void ParticleVector::delLocally(const int index)
-{
- if (index < 0)
- return;
-
- if (mIndexedElements.size() <= CAST_SIZE(index))
- return;
-
- Particle *const p = mIndexedElements[index];
- if (p != nullptr)
- {
- mIndexedElements[index] = nullptr;
- p->kill();
- }
-}
-
-void ParticleVector::clearLocally()
-{
- for (unsigned int i = 0;
- i < CAST_U32(mIndexedElements.size());
- i++)
- {
- delLocally(i);
- }
-}
-
-void ParticleVector::moveTo(const float x, const float y)
-{
- ParticleContainer::moveTo(x, y);
-
- for (STD_VECTOR<Particle *>::iterator it = mIndexedElements.begin();
- it != mIndexedElements.end(); ++it)
- {
- Particle *const p = *it;
- if (p != nullptr)
- {
- p->moveTo(x, y);
-
- if (p->isExtinct())
- {
- p->kill();
- *it = nullptr;
- }
- }
- }
-}
-
-size_t ParticleVector::usedSize() const
-{
- size_t cnt = 0;
- for (STD_VECTOR<Particle *>::const_iterator it = mIndexedElements.begin();
- it != mIndexedElements.end(); ++it)
- {
- if (*it != nullptr)
- cnt ++;
- }
- return cnt;
-}
diff --git a/src/particle/particlevector.h b/src/particle/particlevector.h
deleted file mode 100644
index dce4ae156..000000000
--- a/src/particle/particlevector.h
+++ /dev/null
@@ -1,71 +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 PARTICLE_PARTICLEVECTOR_H
-#define PARTICLE_PARTICLEVECTOR_H
-
-#include "particle/particlecontainer.h"
-
-#include "utils/vector.h"
-
-#include "localconsts.h"
-
-class Particle;
-
-/**
- * Particle container with indexing facilities
- */
-class ParticleVector final : public ParticleContainer
-{
- public:
- explicit ParticleVector(ParticleContainer *const parent = nullptr,
- const bool delParent = true);
-
- A_DELETE_COPY(ParticleVector)
-
- ~ParticleVector();
-
- /**
- * Sets a particle at a specified index. Kills the previous particle
- * there, if needed.
- */
- void setLocally(const int index, Particle *const particle);
-
- /**
- * Removes a particle at a specified index
- */
- void delLocally(const int index);
-
- void clearLocally() override final;
-
- void moveTo(const float x, const float y) override final;
-
- size_t size() const
- { return mIndexedElements.size(); }
-
- size_t usedSize() const;
-
- protected:
- STD_VECTOR<Particle *> mIndexedElements;
-};
-
-#endif // PARTICLE_PARTICLEVECTOR_H
diff --git a/src/particle/rotationalparticle.cpp b/src/particle/rotationalparticle.cpp
deleted file mode 100644
index 0693530d6..000000000
--- a/src/particle/rotationalparticle.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2006-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 "particle/rotationalparticle.h"
-
-#include "resources/animation/simpleanimation.h"
-
-#include "debug.h"
-
-RotationalParticle::RotationalParticle(Animation *restrict const animation) :
- ImageParticle(nullptr)
-{
- mType = ParticleType::Rotational;
- mAnimation = new SimpleAnimation(animation);
-}
-
-RotationalParticle::RotationalParticle(XmlNodeConstPtr animationNode,
- const std::string &restrict
- dyePalettes) :
- ImageParticle(nullptr)
-{
- mType = ParticleType::Rotational;
- mAnimation = new SimpleAnimation(animationNode, dyePalettes);
-}
diff --git a/src/particle/rotationalparticle.h b/src/particle/rotationalparticle.h
deleted file mode 100644
index 60c8461b1..000000000
--- a/src/particle/rotationalparticle.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2006-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 PARTICLE_ROTATIONALPARTICLE_H
-#define PARTICLE_ROTATIONALPARTICLE_H
-
-#include "particle/imageparticle.h"
-
-#include "utils/xml.h"
-
-class Animation;
-
-class RotationalParticle final : public ImageParticle
-{
- public:
- explicit RotationalParticle(Animation *restrict const animation);
-
- explicit RotationalParticle(XmlNodeConstPtr animationNode,
- const std::string &restrict dyePalettes
- = std::string());
-
- A_DELETE_COPY(RotationalParticle)
-};
-
-#endif // PARTICLE_ROTATIONALPARTICLE_H
diff --git a/src/particle/textparticle.cpp b/src/particle/textparticle.cpp
deleted file mode 100644
index dd25e5945..000000000
--- a/src/particle/textparticle.cpp
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2006-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 "particle/textparticle.h"
-
-#include "gui/theme.h"
-
-#include "gui/fonts/font.h"
-
-#include "render/graphics.h"
-
-#include "debug.h"
-
-TextParticle::TextParticle(const std::string &restrict text,
- const Color *restrict const color,
- Font *restrict const font,
- const bool outline) :
- Particle(),
- mText(text),
- mTextFont(font),
- mColor(color),
- mTextWidth(mTextFont != nullptr ? mTextFont->getWidth(mText) / 2 : 1),
- mOutline(outline)
-{
- mType = ParticleType::Text;
-}
-
-void TextParticle::draw(Graphics *restrict const graphics,
- const int offsetX,
- const int offsetY) const restrict2
-{
- BLOCK_START("TextParticle::draw")
- if (!isAlive())
- {
- BLOCK_END("TextParticle::draw")
- return;
- }
-
- const int screenX = CAST_S32(mPos.x) + offsetX;
- const int screenY = CAST_S32(mPos.y) - CAST_S32(mPos.z)
- + offsetY;
-
- float alpha = mAlpha * 255.0F;
-
- if ((mFadeOut != 0) && mLifetimeLeft > -1 && mLifetimeLeft < mFadeOut)
- {
- alpha *= static_cast<float>(mLifetimeLeft)
- / static_cast<float>(mFadeOut);
- }
-
- if ((mFadeIn != 0) && mLifetimePast < mFadeIn)
- {
- alpha *= static_cast<float>(mLifetimePast)
- / static_cast<float>(mFadeIn);
- }
-
- Color color = *mColor;
- color.a = CAST_U32(alpha);
-
- graphics->setColor(color);
- if (mOutline)
- {
- const Color &restrict color2 = theme->getColor(ThemeColorId::OUTLINE,
- CAST_S32(alpha));
- mTextFont->drawString(graphics,
- color, color2,
- mText,
- screenX - mTextWidth, screenY);
- }
- else
- {
- mTextFont->drawString(graphics,
- color, color,
- mText, screenX - mTextWidth, screenY);
- }
- BLOCK_END("TextParticle::draw")
-}
diff --git a/src/particle/textparticle.h b/src/particle/textparticle.h
deleted file mode 100644
index e67120688..000000000
--- a/src/particle/textparticle.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2006-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 PARTICLE_TEXTPARTICLE_H
-#define PARTICLE_TEXTPARTICLE_H
-
-#include "particle/particle.h"
-
-class TextParticle final : public Particle
-{
- public:
- /**
- * Constructor.
- */
- TextParticle(const std::string &text,
- const Color *restrict const color,
- Font *restrict const font,
- const bool outline = false) A_NONNULL(3, 4);
-
- A_DELETE_COPY(TextParticle)
-
- /**
- * Draws the particle image.
- */
- void draw(Graphics *restrict const graphics,
- const int offsetX,
- const int offsetY) const
- restrict2 override final A_NONNULL(2);
-
- // hack to improve text visibility
- int getPixelY() const restrict2 override final A_WARN_UNUSED
- { return CAST_S32(mPos.y + mPos.z); }
-
- // hack to improve text visibility (for sorting only)
- int getSortPixelY() const restrict2 override final A_WARN_UNUSED
- { return CAST_S32(mPos.y + mPos.z); }
-
- private:
- /**< Text of the particle. */
- std::string mText;
- /**< Font used for drawing the text. */
- Font *restrict mTextFont A_NONNULLPOINTER;
- /**< Color used for drawing the text. */
- const Color *restrict mColor A_NONNULLPOINTER;
- int mTextWidth;
- /**< Make the text better readable */
- bool mOutline;
-};
-
-#endif // PARTICLE_TEXTPARTICLE_H
diff --git a/src/party.cpp b/src/party.cpp
deleted file mode 100644
index f28236e34..000000000
--- a/src/party.cpp
+++ /dev/null
@@ -1,337 +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 "party.h"
-
-#include "actormanager.h"
-
-#include "being/being.h"
-
-#include "utils/stringutils.h"
-
-#include "debug.h"
-
-static class SortPartyFunctor final
-{
- public:
- A_DEFAULT_COPY(SortPartyFunctor)
-
- bool operator() (const PartyMember *const p1,
- const PartyMember *const p2) const
- {
- if ((p1 == nullptr) || (p2 == nullptr))
- return false;
- if (p1->getLeader())
- return true;
- if (p2->getLeader())
- return false;
-
- if (p1->getName() != p2->getName())
- {
- std::string s1 = p1->getName();
- std::string s2 = p2->getName();
- toLower(s1);
- toLower(s2);
- return s1 < s2;
- }
- return false;
- }
-} partySorter;
-
-PartyMember::PartyMember(Party *const party,
- const BeingId id,
- const std::string &name) :
- Avatar(name),
- mParty(party),
- mLeader(false)
-{
- mId = id;
-}
-
-Party::PartyMap Party::parties;
-
-Party::Party(const int16_t id) :
- mMembers(),
- mName(),
- mId(id),
- mCanInviteUsers(false)
-{
- parties[id] = this;
-}
-
-Party::~Party()
-{
- clearMembers();
-}
-
-PartyMember *Party::addMember(const BeingId id,
- const std::string &name)
-{
- PartyMember *m = getMember(id);
- if (m != nullptr)
- return m;
-
- m = new PartyMember(this, id, name);
-
- mMembers.push_back(m);
-
- return m;
-}
-
-PartyMember *Party::getMember(const BeingId id) const
-{
- MemberList::const_iterator itr = mMembers.begin();
- const MemberList::const_iterator itr_end = mMembers.end();
- while (itr != itr_end)
- {
- if ((*itr)->mId == id)
- return (*itr);
- ++itr;
- }
-
- return nullptr;
-}
-
-PartyMember *Party::getMember(const std::string &name) const
-{
- MemberList::const_iterator itr = mMembers.begin();
- const MemberList::const_iterator itr_end = mMembers.end();
- while (itr != itr_end)
- {
- if (((*itr) != nullptr) && (*itr)->getName() == name)
- return (*itr);
-
- ++itr;
- }
-
- return nullptr;
-}
-
-void Party::removeMember(const PartyMember *const member)
-{
- if (member == nullptr)
- return;
-
- bool deleted = true;
- while (deleted)
- {
- deleted = false;
- MemberList::iterator itr = mMembers.begin();
- const MemberList::iterator itr_end = mMembers.end();
- while (itr != itr_end)
- {
- PartyMember *const m = *itr;
- if ((m != nullptr) && m->mId == member->mId
- && m->getName() == member->getName())
- {
- mMembers.erase(itr);
- delete m;
- deleted = true;
- break;
- }
- ++itr;
- }
- }
-}
-
-void Party::removeMember(const BeingId id)
-{
- bool deleted = true;
- while (deleted)
- {
- deleted = false;
- MemberList::iterator itr = mMembers.begin();
- const MemberList::iterator itr_end = mMembers.end();
- while (itr != itr_end)
- {
- PartyMember *const member = *itr;
- if ((member != nullptr) && member->mId == id)
- {
- mMembers.erase(itr);
- delete member;
- deleted = true;
- break;
- }
- ++itr;
- }
- }
-}
-
-void Party::removeMember(const std::string &name)
-{
- bool deleted = true;
- while (deleted)
- {
- deleted = false;
- MemberList::iterator itr = mMembers.begin();
- const MemberList::iterator itr_end = mMembers.end();
- while (itr != itr_end)
- {
- PartyMember *const member = *itr;
- if ((member != nullptr) && member->getName() == name)
- {
- mMembers.erase(itr);
- delete member;
- deleted = true;
- break;
- }
- ++itr;
- }
- }
-}
-
-void Party::removeFromMembers()
-{
- if (actorManager == nullptr)
- return;
-
- MemberList::const_iterator itr = mMembers.begin();
- const MemberList::const_iterator itr_end = mMembers.end();
-
- while (itr != itr_end)
- {
- Being *const b = actorManager->findBeing((*itr)->getID());
- if (b != nullptr)
- b->setParty(nullptr);
- ++itr;
- }
-}
-
-Avatar *Party::getAvatarAt(const int index)
-{
- return mMembers[index];
-}
-
-void Party::setRights(const int16_t rights)
-{
- // to invite, rights must be greater than 0
- if (rights > 0)
- mCanInviteUsers = true;
-}
-
-bool Party::isMember(const PartyMember *const member) const
-{
- if (member == nullptr)
- return false;
-
- if ((member->mParty != nullptr) && member->mParty != this)
- return false;
-
- MemberList::const_iterator itr = mMembers.begin();
- const MemberList::const_iterator itr_end = mMembers.end();
- while (itr != itr_end)
- {
- const PartyMember *const m = *itr;
- if (m != nullptr &&
- m->mId == member->mId &&
- m->getName() == member->getName())
- {
- return true;
- }
- ++itr;
- }
-
- return false;
-}
-
-bool Party::isMember(const BeingId id) const
-{
- MemberList::const_iterator itr = mMembers.begin();
- const MemberList::const_iterator itr_end = mMembers.end();
- while (itr != itr_end)
- {
- const PartyMember *const m = *itr;
- if ((m != nullptr) && m->mId == id)
- return true;
- ++itr;
- }
-
- return false;
-}
-
-bool Party::isMember(const std::string &name) const
-{
- MemberList::const_iterator itr = mMembers.begin();
- const MemberList::const_iterator itr_end = mMembers.end();
- while (itr != itr_end)
- {
- const PartyMember *const m = *itr;
- if ((m != nullptr) && m->getName() == name)
- return true;
- ++itr;
- }
-
- return false;
-}
-
-void Party::getNames(StringVect &names) const
-{
- names.clear();
- MemberList::const_iterator it = mMembers.begin();
- const MemberList::const_iterator it_end = mMembers.end();
- while (it != it_end)
- {
- const PartyMember *const m = *it;
- if (m != nullptr)
- names.push_back(m->getName());
- ++it;
- }
-}
-
-void Party::getNamesSet(std::set<std::string> &names) const
-{
- names.clear();
- MemberList::const_iterator it = mMembers.begin();
- const MemberList::const_iterator it_end = mMembers.end();
- while (it != it_end)
- {
- const PartyMember *const m = *it;
- if (m != nullptr)
- names.insert(m->getName());
- ++it;
- }
-}
-
-Party *Party::getParty(const int16_t id)
-{
- const PartyMap::const_iterator it = parties.find(id);
- if (it != parties.end())
- return it->second;
- Party *const party = new Party(id);
- parties[id] = party;
- return party;
-}
-
-void Party::sort()
-{
- std::sort(mMembers.begin(), mMembers.end(), partySorter);
-}
-
-void Party::clearParties()
-{
- PartyMap::iterator it = parties.begin();
- while (it != parties.end())
- {
- delete (*it).second;
- ++ it;
- }
- parties.clear();
-}
diff --git a/src/party.h b/src/party.h
deleted file mode 100644
index 932cf426b..000000000
--- a/src/party.h
+++ /dev/null
@@ -1,182 +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 PARTY_H
-#define PARTY_H
-
-#include "gui/models/avatarlistmodel.h"
-
-#include "utils/cast.h"
-#include "utils/dtor.h"
-#include "utils/stringvector.h"
-
-#include <map>
-#include <set>
-
-class Party;
-
-class PartyMember final : public Avatar
-{
- public:
- A_DELETE_COPY(PartyMember)
-
- const Party *getParty() const noexcept2 A_WARN_UNUSED
- { return mParty; }
-
- bool getLeader() const noexcept2 A_WARN_UNUSED
- { return mLeader; }
-
- void setLeader(const bool leader)
- { mLeader = leader; setDisplayBold(leader); }
-
- protected:
- friend class Party;
-
- PartyMember(Party *const party,
- const BeingId id,
- const std::string &name);
-
- Party *mParty;
- bool mLeader;
-};
-
-class Party final : public AvatarListModel
-{
- public:
- A_DELETE_COPY(Party)
-
- /**
- * Set the party's name.
- */
- void setName(const std::string &name)
- { mName = name; }
-
- /**
- * Adds member to the list.
- */
- PartyMember *addMember(const BeingId id,
- const std::string &name);
-
- /**
- * Find a member by ID.
- *
- * @return the member with the given ID, or NULL if they don't exist.
- */
- PartyMember *getMember(const BeingId id) const A_WARN_UNUSED;
-
- /**
- * Find a member by name.
- *
- * @return the member with the given name, or NULL if they don't exist.
- */
- PartyMember *getMember(const std::string &name) const A_WARN_UNUSED;
-
- /**
- * Get the name of the party.
- * @return returns name of the party
- */
- const std::string &getName() const noexcept2 A_WARN_UNUSED
- { return mName; }
-
- /**
- * Get the id of the party.
- * @return Returns the id of the party
- */
- int16_t getId() const noexcept2 A_WARN_UNUSED
- { return mId; }
-
- /**
- * Removes a member from the party.
- */
- void removeMember(const PartyMember *const member);
-
- /**
- * Removes a member from the party.
- */
- void removeMember(const BeingId id);
-
- /**
- * Removes a member from the party.
- */
- void removeMember(const std::string &name);
-
- void clearMembers()
- { delete_all(mMembers); mMembers.clear(); }
-
- void removeFromMembers();
-
- /**
- * Get size of members list.
- * @return Returns the number of members in the party.
- */
- int getNumberOfElements() override final A_WARN_UNUSED
- { return CAST_S32(mMembers.size()); }
-
- Avatar *getAvatarAt(const int index) override final A_WARN_UNUSED;
-
- /**
- * Get whether user can invite users to this party.
- * @return Returns true if user can invite users
- */
- bool getInviteRights() const noexcept2 A_WARN_UNUSED
- { return mCanInviteUsers; }
-
- void setRights(const int16_t rights);
-
- bool isMember(const PartyMember *const member) const A_WARN_UNUSED;
-
- bool isMember(const BeingId id) const A_WARN_UNUSED;
-
- bool isMember(const std::string &name) const A_WARN_UNUSED;
-
- void getNames(StringVect &names) const;
-
- void getNamesSet(std::set<std::string> &names) const;
-
- void sort();
-
- typedef STD_VECTOR<PartyMember*> MemberList;
-
- const MemberList *getMembers() const RETURNS_NONNULL A_WARN_UNUSED
- { return &mMembers; }
-
- static Party *getParty(const int16_t id) A_WARN_UNUSED;
-
- static void clearParties();
-
- private:
- typedef std::map<int, Party*> PartyMap;
- static PartyMap parties;
-
- /**
- * Constructor with party id passed to it.
- */
- explicit Party(const int16_t id);
-
- ~Party();
-
- MemberList mMembers;
- std::string mName;
- int16_t mId;
- bool mCanInviteUsers;
-};
-
-#endif // PARTY_H
diff --git a/src/position.cpp b/src/position.cpp
deleted file mode 100644
index 1bb5c0618..000000000
--- a/src/position.cpp
+++ /dev/null
@@ -1,49 +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 "position.h"
-
-#include "debug.h"
-
-std::ostream& operator <<(std::ostream &os, const Position &p)
-{
- os << "(" << p.x << ", " << p.y << ")";
- return os;
-}
-
-std::ostream& operator <<(std::ostream &os, const Path &path)
-{
- Path::const_iterator i = path.begin();
- const Path::const_iterator i_end = path.end();
-
- os << "(";
- while (i != i_end)
- {
- os << *i;
- ++i;
- if (i != i_end)
- os << ", ";
- }
- os << ")";
-
- return os;
-}
diff --git a/src/position.h b/src/position.h
deleted file mode 100644
index 513448021..000000000
--- a/src/position.h
+++ /dev/null
@@ -1,63 +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 POSITION_H
-#define POSITION_H
-
-#include <iostream>
-#include <list>
-
-#include "localconsts.h"
-
-/**
- * A position along a being's path.
- */
-struct Position final
-{
- Position(const int x0,
- const int y0) :
- x(x0),
- y(y0)
- { }
-
- A_DEFAULT_COPY(Position)
-
- int x;
- int y;
-};
-
-typedef std::list<Position> Path;
-typedef Path::iterator PathIterator;
-typedef Path::reverse_iterator PathRIterator;
-
-/**
- * Appends a string representation of a position to the output stream.
- */
-std::ostream& operator <<(std::ostream &os, const Position &p);
-
-/**
- * Appends a string representation of a path (sequence of positions) to the
- * output stream.
- */
-std::ostream& operator <<(std::ostream &os, const Path &path);
-
-#endif // POSITION_H
diff --git a/src/progs/dyecmd/actions/actions.cpp b/src/progs/dyecmd/actions/actions.cpp
deleted file mode 100644
index 58353b699..000000000
--- a/src/progs/dyecmd/actions/actions.cpp
+++ /dev/null
@@ -1,120 +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 "actions/actions.h"
-
-#include "actions/actiondef.h"
-
-#include "debug.h"
-
-namespace Actions
-{
-
-impHandlerVoid(emote)
-impHandlerVoid(outfit)
-impHandlerVoid(mouseClick)
-impHandlerVoid(ok)
-impHandlerVoid(shortcut)
-impHandlerVoid(quit)
-impHandlerVoid(dropItem0)
-impHandlerVoid(dropItem)
-impHandlerVoid(dropItemId)
-impHandlerVoid(dropItemInv)
-impHandlerVoid(dropItemIdAll)
-impHandlerVoid(dropItemInvAll)
-impHandlerVoid(heal)
-impHandlerVoid(healmd)
-impHandlerVoid(itenplz)
-impHandlerVoid(setHome)
-impHandlerVoid(magicAttack)
-impHandlerVoid(copyEquippedToOutfit)
-impHandlerVoid(pickup)
-impHandlerVoid(sit)
-impHandlerVoid(screenshot)
-impHandlerVoid(ignoreInput)
-impHandlerVoid(buy)
-impHandlerVoid(sell)
-impHandlerVoid(talk)
-impHandlerVoid(stopAttack)
-impHandlerVoid(untarget)
-impHandlerVoid(attack)
-impHandlerVoid(targetAttack)
-impHandlerVoid(attackHuman)
-impHandlerVoid(safeVideoMode)
-impHandlerVoid(stopSit)
-impHandlerVoid(showKeyboard)
-impHandlerVoid(showWindows)
-impHandlerVoid(openTrade)
-impHandlerVoid(ipcToggle)
-impHandlerVoid(where)
-impHandlerVoid(who)
-impHandlerVoid(cleanGraphics)
-impHandlerVoid(cleanFonts)
-impHandlerVoid(trade)
-impHandlerVoid(priceLoad)
-impHandlerVoid(priceSave)
-impHandlerVoid(cacheInfo)
-impHandlerVoid(disconnect)
-impHandlerVoid(undress)
-impHandlerVoid(dirs)
-impHandlerVoid(uptime)
-impHandlerVoid(dump)
-impHandlerVoid(serverIgnoreAll)
-impHandlerVoid(serverUnIgnoreAll)
-impHandler0(error)
-{
- exit(0);
-}
-impHandlerVoid(dumpGraphics)
-impHandlerVoid(dumpEnvironment)
-impHandlerVoid(dumpTests)
-impHandlerVoid(dumpOGL)
-impHandlerVoid(dumpGL)
-impHandlerVoid(dumpMods)
-#if defined USE_OPENGL && defined DEBUG_SDLFONT
-impHandlerVoid(testSdlFont)
-#endif // defined USE_OPENGL && defined DEBUG_SDLFONT
-impHandlerVoid(createItems)
-impHandlerVoid(createItem)
-impHandlerVoid(uploadConfig)
-impHandlerVoid(uploadServerConfig)
-impHandlerVoid(uploadLog)
-impHandlerVoid(mercenaryFire)
-impHandlerVoid(mercenaryToMaster)
-impHandlerVoid(homunculusToMaster)
-impHandlerVoid(homunculusFeed)
-impHandlerVoid(useItem)
-impHandlerVoid(useItemInv)
-impHandlerVoid(invToStorage)
-impHandlerVoid(tradeAdd)
-impHandlerVoid(storageToInv)
-impHandlerVoid(protectItem)
-impHandlerVoid(unprotectItem)
-impHandlerVoid(kick)
-impHandlerVoid(clearDrop)
-impHandlerVoid(testInfo)
-impHandlerVoid(craftKey)
-impHandlerVoid(resetGameModifiers)
-impHandlerVoid(barToChat)
-impHandlerVoid(seen)
-impHandlerVoid(dumpMemoryUsage)
-impHandlerVoid(setEmoteType)
-
-} // namespace Actions
diff --git a/src/progs/dyecmd/actions/chat.cpp b/src/progs/dyecmd/actions/chat.cpp
deleted file mode 100644
index ece0e42b9..000000000
--- a/src/progs/dyecmd/actions/chat.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 "actions/chat.h"
-
-#include "actions/actiondef.h"
-
-#include "debug.h"
-
-namespace Actions
-{
-
-impHandlerVoid(toggleChat)
-impHandlerVoid(prevChatTab)
-impHandlerVoid(nextChatTab)
-impHandlerVoid(closeChatTab)
-impHandlerVoid(closeAllChatTabs)
-impHandlerVoid(ignoreAllWhispers)
-impHandlerVoid(scrollChatUp)
-impHandlerVoid(scrollChatDown)
-impHandlerVoid(msg)
-impHandlerVoid(msgText)
-impHandlerVoid(msg2)
-impHandlerVoid(query)
-impHandlerVoid(clearChatTab)
-impHandlerVoid(createParty)
-impHandlerVoid(createGuild)
-impHandlerVoid(party)
-impHandlerVoid(guild)
-impHandlerVoid(me)
-impHandlerVoid(toggle)
-impHandlerVoid(kickParty)
-impHandlerVoid(kickGuild)
-impHandlerVoid(addText)
-impHandlerVoid(clearChat)
-impHandlerVoid(chatGeneralTab)
-impHandlerVoid(chatDebugTab)
-impHandlerVoid(chatBattleTab)
-impHandlerVoid(chatTradeTab)
-impHandlerVoid(chatLangTab)
-impHandlerVoid(chatGmTab)
-impHandlerVoid(chatPartyTab)
-impHandlerVoid(chatGuildTab)
-impHandlerVoid(hat)
-impHandlerVoid(chatClipboard)
-impHandlerVoid(guildNotice)
-impHandlerVoid(translate)
-impHandlerVoid(sendGuiKey)
-impHandlerVoid(sendMouseKey)
-impHandlerVoid(sendChars)
-
-} // namespace Actions
diff --git a/src/progs/dyecmd/actions/commands.cpp b/src/progs/dyecmd/actions/commands.cpp
deleted file mode 100644
index 7f50ab20c..000000000
--- a/src/progs/dyecmd/actions/commands.cpp
+++ /dev/null
@@ -1,167 +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 "actions/commands.h"
-
-#include "actions/actiondef.h"
-
-#include "debug.h"
-
-namespace Actions
-{
-
-impHandlerVoid(chatAnnounce)
-impHandlerVoid(chatIgnore)
-impHandlerVoid(chatUnignore)
-impHandlerVoid(chatErase)
-impHandlerVoid(chatFriend)
-impHandlerVoid(chatDisregard)
-impHandlerVoid(chatNeutral)
-impHandlerVoid(chatBlackList)
-impHandlerVoid(chatEnemy)
-impHandlerVoid(chatNuke)
-impHandlerVoid(chatAdd)
-impHandlerVoid(present)
-impHandlerVoid(printAll)
-impHandlerVoid(move)
-impHandlerVoid(setTarget)
-impHandlerVoid(commandOutfit)
-impHandlerVoid(commandEmote)
-impHandlerVoid(awayMessage)
-impHandlerVoid(pseudoAway)
-impHandlerVoid(follow)
-impHandlerVoid(navigate)
-impHandlerVoid(navigateTo)
-impHandlerVoid(moveCamera)
-impHandlerVoid(restoreCamera)
-impHandlerVoid(imitation)
-impHandlerVoid(sendMail)
-impHandlerVoid(info)
-impHandlerVoid(wait)
-impHandlerVoid(addPriorityAttack)
-impHandlerVoid(addAttack)
-impHandlerVoid(removeAttack)
-impHandlerVoid(addIgnoreAttack)
-impHandlerVoid(setDrop)
-impHandlerVoid(url)
-impHandlerVoid(openUrl)
-impHandlerVoid(execute)
-impHandlerVoid(enableHighlight)
-impHandlerVoid(disableHighlight)
-impHandlerVoid(dontRemoveName)
-impHandlerVoid(removeName)
-impHandlerVoid(disableAway)
-impHandlerVoid(enableAway)
-impHandlerVoid(testParticle)
-impHandlerVoid(talkRaw)
-impHandlerVoid(gm)
-impHandlerVoid(hack)
-impHandlerVoid(debugSpawn)
-impHandlerVoid(serverIgnoreWhisper)
-impHandlerVoid(serverUnIgnoreWhisper)
-impHandlerVoid(setHomunculusName)
-impHandlerVoid(fireHomunculus)
-impHandlerVoid(leaveParty)
-impHandlerVoid(leaveGuild)
-impHandlerVoid(warp)
-impHandlerVoid(homunTalk)
-impHandlerVoid(homunEmote)
-impHandlerVoid(commandHomunEmote)
-impHandlerVoid(createPublicChatRoom)
-impHandlerVoid(joinChatRoom)
-impHandlerVoid(leaveChatRoom)
-impHandlerVoid(confSet)
-impHandlerVoid(serverConfSet)
-impHandlerVoid(confGet)
-impHandlerVoid(serverConfGet)
-impHandlerVoid(slide)
-impHandlerVoid(selectSkillLevel)
-impHandlerVoid(skill)
-impHandlerVoid(craft)
-impHandlerVoid(npcClipboard)
-impHandlerVoid(clipboardCopy)
-impHandlerVoid(addPickup)
-impHandlerVoid(removePickup)
-impHandlerVoid(ignorePickup)
-impHandlerVoid(monsterInfo)
-impHandlerVoid(itemInfo)
-impHandlerVoid(whoDrops)
-impHandlerVoid(mobSearch)
-impHandlerVoid(mobSpawnSearch)
-impHandlerVoid(playerGmCommands)
-impHandlerVoid(playerCharGmCommands)
-impHandlerVoid(commandShowLevel)
-impHandlerVoid(commandShowStats)
-impHandlerVoid(commandShowStorage)
-impHandlerVoid(commandShowCart)
-impHandlerVoid(commandShowInventory)
-impHandlerVoid(locatePlayer)
-impHandlerVoid(commandShowAccountInfo)
-impHandlerVoid(commandSpawn)
-impHandlerVoid(commandSpawnSlave)
-impHandlerVoid(commandSpawnClone)
-impHandlerVoid(commandSpawnSlaveClone)
-impHandlerVoid(commandSpawnEvilClone)
-impHandlerVoid(commandSavePosition)
-impHandlerVoid(commandLoadPosition)
-impHandlerVoid(commandRandomWarp)
-impHandlerVoid(commandGotoNpc)
-impHandlerVoid(commandGotoPc)
-impHandlerVoid(commandRecallPc)
-impHandlerVoid(commandIpCheck)
-impHandlerVoid(commandKiller)
-impHandlerVoid(commandKillable)
-impHandlerVoid(commandHeal)
-impHandlerVoid(commandAlive)
-impHandlerVoid(commandDisguise)
-impHandlerVoid(commandImmortal)
-impHandlerVoid(commandHide)
-impHandlerVoid(commandNuke)
-impHandlerVoid(commandKill)
-impHandlerVoid(commandJail)
-impHandlerVoid(commandUnjail)
-impHandlerVoid(commandNpcMove)
-impHandlerVoid(commandNpcHide)
-impHandlerVoid(commandNpcShow)
-impHandlerVoid(commandChangePartyLeader)
-impHandlerVoid(commandPartyRecall)
-impHandlerVoid(commandBreakGuild)
-impHandlerVoid(commandGuildRecall)
-impHandlerVoid(mailTo)
-impHandlerVoid(adoptChild)
-impHandlerVoid(showSkillLevels)
-impHandlerVoid(showSkillType)
-impHandlerVoid(selectSkillType)
-impHandlerVoid(showSkillOffsetX)
-impHandlerVoid(showSkillOffsetY)
-impHandlerVoid(setSkillOffsetX)
-impHandlerVoid(setSkillOffsetY)
-impHandlerVoid(partyItemShare)
-impHandlerVoid(partyExpShare)
-impHandlerVoid(partyAutoItemShare)
-impHandlerVoid(outfitToChat)
-impHandlerVoid(outfitClear)
-impHandlerVoid(moveAttackUp)
-impHandlerVoid(moveAttackDown)
-impHandlerVoid(movePriorityAttackUp)
-impHandlerVoid(movePriorityAttackDown)
-impHandlerVoid(addSkillShortcut)
-
-} // namespace Actions
diff --git a/src/progs/dyecmd/actions/move.cpp b/src/progs/dyecmd/actions/move.cpp
deleted file mode 100644
index c3f82cd3a..000000000
--- a/src/progs/dyecmd/actions/move.cpp
+++ /dev/null
@@ -1,44 +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 "actions/move.h"
-
-#include "actions/actiondef.h"
-
-#include "debug.h"
-
-namespace Actions
-{
-
-impHandlerVoid(moveUp)
-impHandlerVoid(moveDown)
-impHandlerVoid(moveLeft)
-impHandlerVoid(moveRight)
-impHandlerVoid(moveForward)
-impHandlerVoid(moveToPoint)
-impHandlerVoid(crazyMoves)
-impHandlerVoid(moveToTarget)
-impHandlerVoid(moveToHome)
-impHandlerVoid(directUp)
-impHandlerVoid(directDown)
-impHandlerVoid(directLeft)
-impHandlerVoid(directRight)
-
-} // namespace Actions
diff --git a/src/progs/dyecmd/actions/pets.cpp b/src/progs/dyecmd/actions/pets.cpp
deleted file mode 100644
index 96a7e5393..000000000
--- a/src/progs/dyecmd/actions/pets.cpp
+++ /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/>.
- */
-
-#include "actions/pets.h"
-
-#include "actions/actiondef.h"
-
-#include "debug.h"
-
-namespace Actions
-{
-
-impHandlerVoid(commandEmotePet)
-impHandlerVoid(talkPet)
-impHandlerVoid(setPetName)
-impHandlerVoid(petEmote)
-impHandlerVoid(catchPet)
-impHandlerVoid(petMoveUp)
-impHandlerVoid(petMoveDown)
-impHandlerVoid(petMoveLeft)
-impHandlerVoid(petMoveRight)
-impHandlerVoid(petDirectUp)
-impHandlerVoid(petDirectDown)
-impHandlerVoid(petDirectLeft)
-impHandlerVoid(petDirectRight)
-impHandlerVoid(petMove)
-impHandlerVoid(petFeed)
-impHandlerVoid(petDropLoot)
-impHandlerVoid(petReturnToEgg)
-impHandlerVoid(petUnequip)
-
-} // namespace Actions
diff --git a/src/progs/dyecmd/actions/statusbar.cpp b/src/progs/dyecmd/actions/statusbar.cpp
deleted file mode 100644
index ed53ef8b0..000000000
--- a/src/progs/dyecmd/actions/statusbar.cpp
+++ /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/>.
- */
-
-#include "actions/statusbar.h"
-
-#include "actions/actiondef.h"
-
-#include "debug.h"
-
-namespace Actions
-{
-
-impHandlerVoid(switchQuickDrop)
-impHandlerVoid(changeCrazyMove)
-impHandlerVoid(changePickupType)
-impHandlerVoid(changeMoveType)
-impHandlerVoid(changeAttackWeaponType)
-impHandlerVoid(changeAttackType)
-impHandlerVoid(changeTargetingType)
-impHandlerVoid(changeFollowMode)
-impHandlerVoid(changeImitationMode)
-impHandlerVoid(changeMagicAttackType)
-impHandlerVoid(changePvpMode)
-impHandlerVoid(changeMoveToTarget)
-impHandlerVoid(changeGameModifier)
-impHandlerVoid(changeAudio)
-impHandlerVoid(away)
-impHandlerVoid(camera)
-impHandlerVoid(changeMapMode)
-impHandlerVoid(changeTrade)
-
-} // namespace Actions
diff --git a/src/progs/dyecmd/actions/tabs.cpp b/src/progs/dyecmd/actions/tabs.cpp
deleted file mode 100644
index 3c795c2ab..000000000
--- a/src/progs/dyecmd/actions/tabs.cpp
+++ /dev/null
@@ -1,39 +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 "actions/tabs.h"
-
-#include "actions/actiondef.h"
-
-#include "debug.h"
-
-namespace Actions
-{
-
-impHandlerVoid(prevSocialTab)
-impHandlerVoid(nextSocialTab)
-impHandlerVoid(nextShortcutsTab)
-impHandlerVoid(prevShortcutsTab)
-impHandlerVoid(nextCommandsTab)
-impHandlerVoid(prevCommandsTab)
-impHandlerVoid(nextInvTab)
-impHandlerVoid(prevInvTab)
-
-} // namespace Actions
diff --git a/src/progs/dyecmd/actions/target.cpp b/src/progs/dyecmd/actions/target.cpp
deleted file mode 100644
index 80b34a7fb..000000000
--- a/src/progs/dyecmd/actions/target.cpp
+++ /dev/null
@@ -1,39 +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 "actions/target.h"
-
-#include "actions/actiondef.h"
-
-#include "debug.h"
-
-namespace Actions
-{
-
-impHandlerVoid(targetPlayer)
-impHandlerVoid(targetMonster)
-impHandlerVoid(targetClosestMonster)
-impHandlerVoid(targetNPC)
-impHandlerVoid(targetMercenary)
-impHandlerVoid(targetPet)
-impHandlerVoid(targetSkillUnit)
-impHandlerVoid(contextMenu)
-
-} // namespace Actions
diff --git a/src/progs/dyecmd/actions/windows.cpp b/src/progs/dyecmd/actions/windows.cpp
deleted file mode 100644
index ce5c72ce2..000000000
--- a/src/progs/dyecmd/actions/windows.cpp
+++ /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/>.
- */
-
-#include "actions/windows.h"
-
-#include "actions/actiondef.h"
-
-#include "debug.h"
-
-namespace Actions
-{
-
-impHandlerVoid(setupWindowShow)
-impHandlerVoid(hideWindows)
-impHandlerVoid(helpWindowShow)
-impHandlerVoid(aboutWindowShow)
-impHandlerVoid(statusWindowShow)
-impHandlerVoid(inventoryWindowShow)
-impHandlerVoid(equipmentWindowShow)
-impHandlerVoid(skillDialogShow)
-impHandlerVoid(minimapWindowShow)
-impHandlerVoid(chatWindowShow)
-impHandlerVoid(shortcutWindowShow)
-impHandlerVoid(debugWindowShow)
-impHandlerVoid(socialWindowShow)
-impHandlerVoid(emoteShortcutWindowShow)
-impHandlerVoid(outfitWindowShow)
-impHandlerVoid(shopWindowShow)
-impHandlerVoid(dropShortcutWindowShow)
-impHandlerVoid(killStatsWindowShow)
-impHandlerVoid(spellShortcutWindowShow)
-impHandlerVoid(whoIsOnlineWindowShow)
-impHandlerVoid(didYouKnowWindowShow)
-impHandlerVoid(questsWindowShow)
-impHandlerVoid(bankWindowShow)
-impHandlerVoid(cartWindowShow)
-impHandlerVoid(updaterWindowShow)
-impHandlerVoid(quickWindowShow)
-impHandlerVoid(mailWindowShow)
-impHandlerVoid(serverInfoWindowShow)
-impHandlerVoid(showItems)
-
-} // namespace Actions
diff --git a/src/progs/dyecmd/client.cpp b/src/progs/dyecmd/client.cpp
deleted file mode 100644
index 631469f2b..000000000
--- a/src/progs/dyecmd/client.cpp
+++ /dev/null
@@ -1,818 +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 "progs/dyecmd/client.h"
-
-#include "configmanager.h"
-#include "dirs.h"
-#include "eventsmanager.h"
-#include "graphicsmanager.h"
-#include "main.h"
-#include "settings.h"
-#include "soundmanager.h"
-
-#include "fs/virtfs/fs.h"
-#include "fs/virtfs/tools.h"
-
-#include "gui/dialogsmanager.h"
-#include "gui/gui.h"
-#include "gui/skin.h"
-#include "gui/popupmanager.h"
-#include "gui/windowmanager.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/createwidget.h"
-#include "gui/widgets/desktop.h"
-#include "gui/widgets/window.h"
-#include "gui/widgets/windowcontainer.h"
-
-#include "input/inputmanager.h"
-#include "input/joystick.h"
-#include "input/keyboardconfig.h"
-
-#include "input/touch/touchmanager.h"
-
-#include "resources/imagehelper.h"
-
-#include "resources/dye/dyepalette.h"
-
-#include "resources/resourcemanager/resourcemanager.h"
-
-#include "utils/cpu.h"
-#include "utils/delete2.h"
-#include "utils/env.h"
-#include "utils/fuzzer.h"
-#include "utils/gettext.h"
-#include "utils/gettexthelper.h"
-#include "utils/mrand.h"
-#ifdef ANDROID
-#include "fs/paths.h"
-#endif // ANDROID
-#include "utils/sdlcheckutils.h"
-#include "utils/sdlhelper.h"
-#include "utils/timer.h"
-
-#include "utils/translation/translationmanager.h"
-
-#include "configuration.h"
-
-#include "net/ipc.h"
-
-#ifdef WIN32
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_syswm.h>
-PRAGMA48(GCC diagnostic pop)
-#include <sys/time.h>
-#include "fs/specialfolder.h"
-#undef ERROR
-#endif // WIN32
-
-#ifdef ANDROID
-#ifndef USE_SDL2
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_screenkeyboard.h>
-PRAGMA48(GCC diagnostic pop)
-#include <fstream>
-#endif // USE_SDL2
-#endif // ANDROID
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#ifdef USE_SDL2
-#include <SDL2_framerate.h>
-#else // USE_SDL2
-#include <SDL_framerate.h>
-#endif // USE_SDL2
-PRAGMA48(GCC diagnostic pop)
-
-#include "debug.h"
-
-std::string errorMessage;
-
-Client *client = nullptr;
-
-extern FPSmanager fpsManager;
-
-volatile bool runCounters;
-bool isSafeMode = false;
-int serverVersion = 0;
-int packetVersion = 0;
-unsigned int tmwServerVersion = 0;
-time_t start_time;
-unsigned int mLastHost = 0;
-unsigned long mSearchHash = 0;
-int textures_count = 0;
-
-Client::Client() :
- ActionListener(),
- mCurrentDialog(nullptr),
- mSetupButton(nullptr),
- mVideoButton(nullptr),
- mHelpButton(nullptr),
- mAboutButton(nullptr),
- mThemesButton(nullptr),
- mPerfomanceButton(nullptr),
-#ifdef ANDROID
- mCloseButton(nullptr),
-#endif // ANDROID
- mState(State::GAME),
- mOldState(State::START),
- mSkin(nullptr),
- mButtonPadding(1),
- mButtonSpacing(3)
-{
- WindowManager::init();
-}
-
-void Client::testsInit()
-{
-}
-
-void Client::testsClear()
-{
-}
-
-// +++ need remove duplicate from here
-void Client::gameInit()
-{
- logger = new Logger;
- SDL::initLogger();
-
- initRand();
-
- // Load branding information
- if (!settings.options.brandingPath.empty())
- branding.init(settings.options.brandingPath);
- setBrandingDefaults(branding);
-
- Dirs::initRootDir();
- Dirs::initHomeDir();
-
- // Configure logger
- if (!settings.options.logFileName.empty())
- {
- settings.logFileName = settings.options.logFileName;
- }
- else
- {
- settings.logFileName = pathJoin(settings.localDataDir,
- "manaplus.log");
- }
- logger->setLogFile(settings.logFileName);
-
-#ifdef USE_FUZZER
- Fuzzer::init();
-#endif // USE_FUZZER
-
- if (settings.options.test.empty())
- ConfigManager::backupConfig("config.xml");
- ConfigManager::initConfiguration();
- SDL::setLogLevel(config.getIntValue("sdlLogLevel"));
- setPathsDefaults(paths);
- initPaths();
- logger->log("init 4");
- logger->setDebugLog(config.getBoolValue("debugLog"));
- logger->setReportUnimplemented(config.getBoolValue("unimplimentedLog"));
-
- config.incValue("runcount");
-
-#ifndef ANDROID
- if (settings.options.test.empty())
- ConfigManager::storeSafeParameters();
-#endif // ANDROID
-
- if (!VirtFs::setWriteDir(settings.localDataDir))
- {
- logger->error(strprintf("%s couldn't be set as home directory! "
- "Exiting.", settings.localDataDir.c_str()));
- }
-
- GettextHelper::initLang();
-
-/*
- chatLogger = new ChatLogger;
- if (settings.options.chatLogDir.empty())
- {
- chatLogger->setBaseLogDir(settings.localDataDir
- + std::string("/logs/"));
- }
- else
- {
- chatLogger->setBaseLogDir(settings.options.chatLogDir);
- }
-*/
- // Log the client version
- logger->log1(FULL_VERSION);
- logger->log("Start configPath: " + config.getConfigPath());
-
- Dirs::initScreenshotDir();
-
- // Initialize SDL
- logger->log1("Initializing SDL...");
- if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) < 0)
- {
- logger->safeError(strprintf("Could not initialize SDL: %s",
- SDL_GetError()));
- }
- atexit(SDL_Quit);
-
-#ifndef USE_SDL2
- SDL_EnableUNICODE(1);
-#endif // USE_SDL2
-
- WindowManager::applyKeyRepeat();
- eventsManager.init();
- eventsManager.enableEvents();
-
-#ifdef WIN32
- Dirs::mountDataDir();
-#endif // WIN32
-#ifndef USE_SDL2
- WindowManager::setIcon();
-#endif // USE_SDL2
-
- ConfigManager::checkConfigVersion();
- logVars();
- Cpu::detect();
- DyePalette::initFunctions();
-#if defined(USE_OPENGL)
-#if !defined(ANDROID) && !defined(__APPLE__) && !defined(__native_client__)
- if (!settings.options.safeMode && settings.options.test.empty()
- && !config.getBoolValue("videodetected"))
- {
- graphicsManager.detectVideoSettings();
- }
-#endif // !defined(ANDROID) && !defined(__APPLE__) &&
- // !defined(__native_client__)
-#endif // defined(USE_OPENGL)
-
- updateEnv();
- SDL::allowScreenSaver(config.getBoolValue("allowscreensaver"));
- initGraphics();
-
-#ifndef WIN32
- Dirs::extractDataDir();
- Dirs::mountDataDir();
-#endif // WIN32
-
- Dirs::updateDataPath();
-
- // Add the main data directories to our VirtFs search path
- if (!settings.options.dataPath.empty())
- {
- VirtFs::mountDir(settings.options.dataPath,
- Append_false);
- }
-
- // Add the local data directory to VirtFs search path
- VirtFs::mountDir(settings.localDataDir,
- Append_false);
- TranslationManager::loadCurrentLang();
- TranslationManager::loadDictionaryLang();
-#ifdef ENABLE_CUSTOMNLS
- TranslationManager::loadGettextLang();
-#endif // ENABLE_CUSTOMNLS
-
-#ifdef USE_SDL2
- WindowManager::setIcon();
-#endif // USE_SDL2
- WindowManager::initTitle();
-
- mainGraphics->postInit();
-
- theme = new Theme;
- Theme::selectSkin();
- touchManager.init();
-
- // Initialize the item and emote shortcuts.
-// for (size_t f = 0; f < SHORTCUT_TABS; f ++)
-// itemShortcut[f] = new ItemShortcut(f);
-// emoteShortcut = new EmoteShortcut;
-// dropShortcut = new DropShortcut;
-
- gui = new Gui;
- gui->postInit(mainGraphics);
- dialogsManager = new DialogsManager;
- popupManager = new PopupManager;
-
- initSoundManager();
-
- // Initialize keyboard
- keyboard.init();
- inputManager.init();
-
- // Initialise player relations
- Joystick::init();
- WindowManager::createWindows();
-
- keyboard.update();
- if (joystick != nullptr)
- joystick->update();
-
-// if (mState != State::ERROR)
-// mState = State::CHOOSE_SERVER;
-
- startTimers();
-
- const int fpsLimit = config.getIntValue("fpslimit");
- settings.limitFps = fpsLimit > 0;
-
- SDL_initFramerate(&fpsManager);
- WindowManager::setFramerate(fpsLimit);
-
- start_time = time(nullptr);
-
-// PlayerInfo::init();
-
-#ifdef ANDROID
-#ifndef USE_SDL2
- WindowManager::updateScreenKeyboard(SDL_GetScreenKeyboardHeight(nullptr));
-#endif // USE_SDL2
-#endif // ANDROID
-
- mSkin = theme->load("windowmenu.xml", "");
- if (mSkin != nullptr)
- {
- mButtonPadding = mSkin->getPadding();
- mButtonSpacing = mSkin->getOption("spacing", 3);
- }
-}
-
-Client::~Client()
-{
- if (!settings.options.testMode)
- gameClear();
- else
- testsClear();
-}
-
-void Client::initSoundManager()
-{
- // Initialize sound engine
- try
- {
- if (config.getBoolValue("sound"))
- soundManager.init();
-
- soundManager.setSfxVolume(config.getIntValue("sfxVolume"));
- soundManager.setMusicVolume(config.getIntValue("musicVolume"));
- }
- catch (const char *const err)
- {
- mState = State::ERROR;
- errorMessage = err;
- logger->log("Warning: %s", err);
- }
- soundManager.playMusic(branding.getValue(
- "loginMusic",
- "Magick - Real.ogg"),
- SkipError_true);
-}
-
-void Client::initGraphics()
-{
-#ifndef USE_SDL2
- WindowManager::applyVSync();
-#endif // USE_SDL2
-
- runCounters = config.getBoolValue("packetcounters");
-
- graphicsManager.initGraphics();
-
-#ifdef USE_SDL2
- WindowManager::applyVSync();
-#endif // USE_SDL2
-
- imageHelper->postInit();
- setConfigDefaults2(config);
- WindowManager::applyGrabMode();
- WindowManager::applyGamma();
-
- mainGraphics->beginDraw();
-}
-
-void Client::gameClear()
-{
- if (logger != nullptr)
- logger->log1("Quitting1");
-
- eventsManager.shutdown();
- WindowManager::deleteWindows();
- if (windowContainer != nullptr)
- windowContainer->slowLogic();
-
- stopTimers();
-
- delete2(ipc);
-
- if (logger != nullptr)
- logger->log1("Quitting2");
-
- delete2(mCurrentDialog);
- delete2(popupManager);
- delete2(dialogsManager);
- delete2(gui);
-
- if (logger != nullptr)
- logger->log1("Quitting3");
-
- GraphicsManager::deleteRenderers();
-
- if (logger != nullptr)
- logger->log1("Quitting4");
-
- XML::cleanupXML();
-
- if (logger != nullptr)
- logger->log1("Quitting5");
-
- soundManager.close();
-
- if (logger != nullptr)
- logger->log1("Quitting6");
-
- touchManager.clear();
- ResourceManager::deleteInstance();
-
- soundManager.shutdown();
-
- if (logger != nullptr)
- logger->log1("Quitting8");
-
- WindowManager::deleteIcon();
-
- if (logger != nullptr)
- logger->log1("Quitting9");
-
- delete2(joystick);
-
- keyboard.deinit();
-
- if (logger != nullptr)
- logger->log1("Quitting10");
-
- touchManager.shutdown();
-
-#ifdef DEBUG_CONFIG
- config.enableKeyLogging();
-#endif // DEBUG_CONFIG
-
- config.removeOldKeys();
- config.write();
- serverConfig.write();
-
- config.clear();
- serverConfig.clear();
-
- if (logger != nullptr)
- logger->log1("Quitting11");
-
-#ifdef USE_PROFILER
- Perfomance::clear();
-#endif // USE_PROFILER
-
-#ifdef DEBUG_OPENGL_LEAKS
- if (logger)
- logger->log("textures left: %d", textures_count);
-#endif // DEBUG_OPENGL_LEAKS
-
- Graphics::cleanUp();
-
- if (logger != nullptr)
- logger->log1("Quitting12");
-
-// delete2(chatLogger);
- TranslationManager::close();
- VirtFs::deinit();
-}
-
-#define ADDBUTTON(var, object) var = object; \
- x -= var->getWidth() + mButtonSpacing; \
- var->setPosition(x, mButtonPadding); \
- top->add(var);
-
-void Client::stateGame()
-{
- if (gui == nullptr)
- return;
-
- BasicContainer2 *const top = static_cast<BasicContainer2*>(
- gui->getTop());
-
- if (top == nullptr)
- return;
-
- CREATEWIDGETV(desktop, Desktop, nullptr);
- top->add(desktop);
- int x = top->getWidth() - mButtonPadding;
- ADDBUTTON(mSetupButton, new Button(desktop,
- // TRANSLATORS: setup tab quick button
- _("Setup"), "Setup", this))
- ADDBUTTON(mPerfomanceButton, new Button(desktop,
- // TRANSLATORS: perfoamance tab quick button
- _("Performance"), "Perfomance", this))
- ADDBUTTON(mVideoButton, new Button(desktop,
- // TRANSLATORS: video tab quick button
- _("Video"), "Video", this))
- ADDBUTTON(mThemesButton, new Button(desktop,
- // TRANSLATORS: theme tab quick button
- _("Theme"), "Themes", this))
- ADDBUTTON(mAboutButton, new Button(desktop,
- // TRANSLATORS: theme tab quick button
- _("About"), "about", this))
- ADDBUTTON(mHelpButton, new Button(desktop,
- // TRANSLATORS: theme tab quick button
- _("Help"), "help", this))
-#ifdef ANDROID
- ADDBUTTON(mCloseButton, new Button(desktop,
- // TRANSLATORS: close quick button
- _("Close"), "close", this))
-#endif // ANDROID
-
- desktop->setSize(mainGraphics->getWidth(),
- mainGraphics->getHeight());
-}
-
-int Client::gameExec()
-{
- int lastTickTime = tick_time;
-
- while (mState != State::EXIT)
- {
- PROFILER_START();
- if (eventsManager.handleEvents())
- continue;
-
- BLOCK_START("Client::gameExec 4")
- if (gui != nullptr)
- gui->logic();
- cur_time = time(nullptr);
- int k = 0;
- while (lastTickTime != tick_time && k < 40)
- {
-// if (mGame)
-// mGame->logic();
-// else
- if (gui != nullptr)
- gui->handleInput();
-
- ++lastTickTime;
- k ++;
- }
- soundManager.logic();
-
- logic_count += k;
- if (gui != nullptr)
- gui->slowLogic();
-// if (mGame)
-// mGame->slowLogic();
- slowLogic();
- BLOCK_END("Client::gameExec 4")
-
- // This is done because at some point tick_time will wrap.
- lastTickTime = tick_time;
-
- // Update the screen when application is visible, delay otherwise.
- if (!WindowManager::getIsMinimized())
- {
- frame_count++;
- if (gui != nullptr)
- gui->draw();
- mainGraphics->updateScreen();
- }
- else
- {
- SDL_Delay(100);
- }
-
- BLOCK_START("~Client::SDL_framerateDelay")
- if (settings.limitFps)
- SDL_framerateDelay(&fpsManager);
- BLOCK_END("~Client::SDL_framerateDelay")
-
- BLOCK_START("Client::gameExec 6")
-/*
- if (mState == State::CONNECT_GAME)
- {
- stateConnectGame1();
- }
-*/
- BLOCK_END("Client::gameExec 6")
-
- if (mState != mOldState)
- {
- BLOCK_START("Client::gameExec 7")
-
- mOldState = mState;
-
- // Get rid of the dialog of the previous state
- delete2(mCurrentDialog);
-
- // State has changed, while the quitDialog was active, it might
- // not be correct anymore
-/*
- if (mQuitDialog)
- {
- mQuitDialog->scheduleDelete();
- mQuitDialog = nullptr;
- }
-*/
- BLOCK_END("Client::gameExec 7")
-
- BLOCK_START("Client::gameExec 8")
- PRAGMA45(GCC diagnostic push)
- PRAGMA45(GCC diagnostic ignored "-Wswitch-enum")
- switch (mState)
- {
- case State::GAME:
- stateGame();
- break;
-
- case State::LOAD_DATA:
- {
- BLOCK_START("Client::gameExec State::LOAD_DATA")
- logger->log1("State: LOAD DATA");
-
- // If another data path has been set,
- // we don't load any other files...
- if (settings.options.dataPath.empty())
- {
- // Add customdata directory
- VirtFs::searchAndAddArchives(
- "customdata/",
- "zip",
- Append_false);
- }
-
- if (!settings.options.skipUpdate)
- {
- VirtFs::searchAndAddArchives(pathJoin(
- settings.updatesDir, "local/"),
- "zip",
- Append_false);
-
- VirtFs::mountDir(pathJoin(
- settings.localDataDir,
- settings.updatesDir,
- "local/"),
- Append_false);
- }
-
- logger->log("Init paths");
- paths.init("paths.xml", UseVirtFs_true);
- setPathsDefaults(paths);
- initPaths();
- TranslationManager::loadCurrentLang();
- TranslationManager::loadDictionaryLang();
-
- if (desktop != nullptr)
- desktop->reloadWallpaper();
-
- mState = State::GET_CHARACTERS;
- BLOCK_END("Client::gameExec State::LOAD_DATA")
- break;
- }
- case State::START:
- default:
- mState = State::FORCE_QUIT;
- break;
- }
- PRAGMA45(GCC diagnostic pop)
- BLOCK_END("Client::gameExec 8")
- }
- PROFILER_END();
- }
-
- return 0;
-}
-
-void Client::action(const ActionEvent &event)
-{
- std::string tab;
- const std::string &eventId = event.getId();
-
- if (eventId == "close")
- {
- setState(State::FORCE_QUIT);
- return;
- }
- if (eventId == "Setup")
- {
- tab.clear();
- }
- else if (eventId == "help")
- {
- inputManager.executeAction(InputAction::WINDOW_HELP);
- return;
- }
- else if (eventId == "about")
- {
- inputManager.executeAction(InputAction::WINDOW_ABOUT);
- return;
- }
- else if (eventId == "Video")
- {
- tab = "Video";
- }
- else if (eventId == "Themes")
- {
- tab = "Theme";
- }
- else if (eventId == "Perfomance")
- {
- tab = "Perfomance";
- }
- else
- {
- return;
- }
-}
-
-void Client::moveButtons(const int width)
-{
- if (mSetupButton != nullptr)
- {
- int x = width - mSetupButton->getWidth() - mButtonPadding;
- mSetupButton->setPosition(x, mButtonPadding);
-#ifndef WIN32
- x -= mPerfomanceButton->getWidth() + mButtonSpacing;
- mPerfomanceButton->setPosition(x, mButtonPadding);
-
- x -= mVideoButton->getWidth() + mButtonSpacing;
- mVideoButton->setPosition(x, mButtonPadding);
-
- x -= mThemesButton->getWidth() + mButtonSpacing;
- mThemesButton->setPosition(x, mButtonPadding);
-
- x -= mAboutButton->getWidth() + mButtonSpacing;
- mAboutButton->setPosition(x, mButtonPadding);
-
- x -= mHelpButton->getWidth() + mButtonSpacing;
- mHelpButton->setPosition(x, mButtonPadding);
-#ifdef ANDROID
- x -= mCloseButton->getWidth() + mButtonSpacing;
- mCloseButton->setPosition(x, mButtonPadding);
-#endif // ANDROID
-#endif // WIN32
- }
-}
-
-void Client::windowRemoved(const Window *const window)
-{
- if (mCurrentDialog == window)
- mCurrentDialog = nullptr;
-}
-
-void Client::logVars()
-{
-#ifdef ANDROID
- logger->log("APPDIR: %s", getenv("APPDIR"));
- logger->log("DATADIR2: %s", getSdStoragePath().c_str());
-#endif // ANDROID
-}
-
-void Client::slowLogic()
-{
-}
-
-int Client::testsExec()
-{
- return 0;
-}
-
-bool Client::isTmw()
-{
- const std::string &name = settings.serverName;
- if (name == "server.themanaworld.org"
- || name == "themanaworld.org"
- || name == "167.114.185.71")
- {
- return true;
- }
- return false;
-}
-
-void Client::initPaths()
-{
-}
diff --git a/src/progs/dyecmd/client.h b/src/progs/dyecmd/client.h
deleted file mode 100644
index 96d230c60..000000000
--- a/src/progs/dyecmd/client.h
+++ /dev/null
@@ -1,119 +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 PROGS_DYECMD_CLIENT_H
-#define PROGS_DYECMD_CLIENT_H
-
-#include "enums/state.h"
-
-#include "listeners/actionlistener.h"
-
-#include "localconsts.h"
-
-class Button;
-class Skin;
-class Window;
-
-extern bool isSafeMode;
-extern int serverVersion;
-extern unsigned int tmwServerVersion;
-extern time_t start_time;
-extern int textures_count;
-
-extern std::string errorMessage;
-
-/**
- * The core part of the client. This class initializes all subsystems, runs
- * the event loop, and shuts everything down again.
- */
-class Client final : public ActionListener
-{
- public:
- Client();
-
- A_DELETE_COPY(Client)
-
- ~Client();
-
- void gameInit();
-
- void testsInit();
-
- int gameExec();
-
- static int testsExec();
-
- void setState(const StateT state)
- { mState = state; }
-
- StateT getState() const noexcept2 A_WARN_UNUSED
- { return mState; }
-
- void action(const ActionEvent &event) override final;
-
- void moveButtons(const int width);
-
- void windowRemoved(const Window *const window);
-
- void slowLogic();
-
- static bool isTmw();
-
- private:
- void stateGame();
-
- void initSoundManager();
-
- static void initGraphics();
-
- static void initPaths();
-
- void gameClear();
-
- void testsClear();
-
- static void logVars();
-
- Window *mCurrentDialog;
- Button *mSetupButton;
- Button *mVideoButton;
- Button *mHelpButton;
- Button *mAboutButton;
- Button *mThemesButton;
- Button *mPerfomanceButton;
-#ifdef ANDROID
- Button *mCloseButton;
-#endif // ANDROID
-
- StateT mState;
- StateT mOldState;
-
- Skin *mSkin;
- int mButtonPadding;
- int mButtonSpacing;
-};
-
-extern Client *client;
-extern unsigned int mLastHost;
-extern unsigned long mSearchHash;
-
-#endif // PROGS_DYECMD_CLIENT_H
diff --git a/src/progs/dyecmd/dyemain.cpp b/src/progs/dyecmd/dyemain.cpp
deleted file mode 100644
index 915d0e580..000000000
--- a/src/progs/dyecmd/dyemain.cpp
+++ /dev/null
@@ -1,119 +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 "logger.h"
-
-#include "graphicsmanager.h"
-#include "maingui.h"
-#include "sdlshared.h"
-
-#include "fs/virtfs/fs.h"
-
-#include "resources/image/image.h"
-
-#ifdef USE_SDL2
-#include "resources/surfaceimagehelper.h"
-#endif // USE_SDL2
-
-#include "resources/loaders/imageloader.h"
-
-#include "utils/gettext.h"
-#include "utils/pnglib.h"
-#include "utils/sdlhelper.h"
-
-#include <iostream>
-
-#ifndef USE_SDL2
-#include "resources/sdlimagehelper.h"
-#endif // USE_SDL2
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL.h>
-PRAGMA48(GCC diagnostic pop)
-
-#include "debug.h"
-
-static void printHelp()
-{
- // TRANSLATORS: command line help
- std::cout << _("dyecmd srcfile dyestring dstfile") << std::endl;
- // TRANSLATORS: command line help
- std::cout << _("or") << std::endl;
- // TRANSLATORS: command line help
- std::cout << _("dyecmd srcdyestring dstfile") << std::endl;
-}
-
-int main(int argc, char **argv)
-{
- if (argc == 2 && (strcmp(argv[1], "--help") != 0))
- {
- return mainGui(argc, argv);
- }
- if (argc < 3 || argc > 4)
- {
- printHelp();
- return 1;
- }
-
- logger = new Logger;
- SDL::initLogger();
-
- VirtFs::init(argv[0]);
- SDL_Init(SDL_INIT_VIDEO);
-
- graphicsManager.createWindow(10, 10, 0, SDL_ANYFORMAT);
-
-#ifdef USE_SDL2
- imageHelper = new SurfaceImageHelper;
-#else // USE_SDL2
-
- imageHelper = new SDLImageHelper;
-#endif // USE_SDL2
-
- VirtFs::setWriteDir(".");
- VirtFs::mountDir(".", Append_false);
- VirtFs::mountDir("/", Append_false);
- std::string src = argv[1];
- std::string dst;
- if (argc == 4)
- {
- src.append("|").append(argv[2]);
- dst = argv[3];
- }
- else
- {
- dst = argv[2];
- }
-
- Image *image = Loader::getImage(src);
- if (image == nullptr)
- {
- printf("Error loading image\n");
- VirtFs::deinit();
- return 1;
- }
- SDL_Surface *const surface = ImageHelper::convertTo32Bit(
- image->getSDLSurface());
- PngLib::writePNG(surface, dst);
- SDL_FreeSurface(surface);
- VirtFs::deinit();
- return 0;
-}
diff --git a/src/progs/dyecmd/gui/viewport.cpp b/src/progs/dyecmd/gui/viewport.cpp
deleted file mode 100644
index 30e89518e..000000000
--- a/src/progs/dyecmd/gui/viewport.cpp
+++ /dev/null
@@ -1,272 +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 "progs/dyecmd/gui/viewport.h"
-
-#include "configuration.h"
-#include "sdlshared.h"
-
-#include "gui/gui.h"
-#include "gui/popupmanager.h"
-
-#include "render/graphics.h"
-
-#include "debug.h"
-
-Viewport *viewport = nullptr;
-
-extern volatile int tick_time;
-
-Viewport::Viewport() :
- WindowContainer(nullptr),
- MouseListener(),
- ConfigListener(),
- mMouseX(0),
- mMouseY(0),
- mMap(nullptr),
- mHoverBeing(nullptr),
- mHoverItem(nullptr),
- mHoverSign(nullptr),
- mScrollRadius(config.getIntValue("ScrollRadius")),
- mScrollLaziness(config.getIntValue("ScrollLaziness")),
- mScrollCenterOffsetX(config.getIntValue("ScrollCenterOffsetX")),
- mScrollCenterOffsetY(config.getIntValue("ScrollCenterOffsetY")),
- mMousePressX(0),
- mMousePressY(0),
- mPixelViewX(0),
- mPixelViewY(0),
- mLocalWalkTime(-1),
- mCameraRelativeX(0),
- mCameraRelativeY(0),
- mShowBeingPopup(config.getBoolValue("showBeingPopup")),
- mSelfMouseHeal(config.getBoolValue("selfMouseHeal")),
- mEnableLazyScrolling(config.getBoolValue("enableLazyScrolling")),
- mMouseDirectionMove(config.getBoolValue("mouseDirectionMove")),
- mLongMouseClick(config.getBoolValue("longmouseclick")),
- mMouseClicked(false),
- mPlayerFollowMouse(false)
-{
- setOpaque(Opaque_false);
- addMouseListener(this);
-
- config.addListener("ScrollLaziness", this);
- config.addListener("ScrollRadius", this);
- config.addListener("showBeingPopup", this);
- config.addListener("selfMouseHeal", this);
- config.addListener("enableLazyScrolling", this);
- config.addListener("mouseDirectionMove", this);
- config.addListener("longmouseclick", this);
-
- setFocusable(true);
-}
-
-Viewport::~Viewport()
-{
- config.removeListeners(this);
- CHECKLISTENERS
-}
-
-void Viewport::setMap(Map *const map A_UNUSED)
-{
-}
-
-void Viewport::draw(Graphics *const graphics)
-{
- BLOCK_START("Viewport::draw 1")
- static int lastTick = tick_time;
-
- graphics->setColor(Color(64, 64, 64));
- graphics->fillRectangle(
- Rect(0, 0, getWidth(), getHeight()));
-
- // Avoid freaking out when tick_time overflows
- if (tick_time < lastTick)
- lastTick = tick_time;
-
- // Draw contained widgets
- WindowContainer::draw(graphics);
- BLOCK_END("Viewport::draw 1")
-}
-
-void Viewport::safeDraw(Graphics *const graphics)
-{
- Viewport::draw(graphics);
-}
-
-void Viewport::logic()
-{
- BLOCK_START("Viewport::logic")
- // Make the player follow the mouse position
- // if the mouse is dragged elsewhere than in a window.
- Gui::getMouseState(mMouseX, mMouseY);
- BLOCK_END("Viewport::logic")
-}
-
-void Viewport::followMouse()
-{
-}
-
-void Viewport::drawDebugPath(Graphics *const graphics A_UNUSED)
-{
-}
-
-bool Viewport::openContextMenu(const MouseEvent &event A_UNUSED)
-{
- return false;
-}
-
-void Viewport::mousePressed(MouseEvent &event)
-{
- if (event.getSource() != this || event.isConsumed())
- return;
-
- mMouseClicked = true;
-
- mMousePressX = event.getX();
- mMousePressY = event.getY();
- const MouseButtonT eventButton = event.getButton();
-
- // Right click might open a popup
- if (eventButton == MouseButton::RIGHT)
- {
- if (openContextMenu(event))
- return;
- }
-
- // If a popup is active, just remove it
- if (PopupManager::isPopupMenuVisible())
- {
- mPlayerFollowMouse = false;
- PopupManager::hidePopupMenu();
- return;
- }
-
- // Left click can cause different actions
- if (!mLongMouseClick && eventButton == MouseButton::LEFT)
- {
- if (leftMouseAction())
- {
- mPlayerFollowMouse = false;
- return;
- }
- }
-}
-
-void Viewport::walkByMouse(const MouseEvent &event A_UNUSED)
-{
-}
-
-void Viewport::mouseDragged(MouseEvent &event)
-{
- if (event.getSource() != this || event.isConsumed())
- {
- mPlayerFollowMouse = false;
- return;
- }
- if (mMouseClicked)
- {
- if (abs(event.getX() - mMousePressX) > 32
- || abs(event.getY() - mMousePressY) > 32)
- {
- mPlayerFollowMouse = true;
- }
- }
-
- walkByMouse(event);
-}
-
-void Viewport::mouseReleased(MouseEvent &event)
-{
- mPlayerFollowMouse = false;
- mLocalWalkTime = -1;
- if (mLongMouseClick && mMouseClicked)
- {
- mMouseClicked = false;
- if (event.getSource() != this || event.isConsumed())
- return;
- const MouseButtonT eventButton = event.getButton();
- if (eventButton == MouseButton::LEFT)
- {
- // long button press
- if ((gui != nullptr) && gui->isLongPress())
- {
- if (openContextMenu(event))
- {
- gui->resetClickCount();
- return;
- }
- }
- else
- {
- if (leftMouseAction())
- return;
- }
- walkByMouse(event);
- }
- }
-}
-
-void Viewport::optionChanged(const std::string &name)
-{
- if (name == "ScrollLaziness")
- mScrollLaziness = config.getIntValue("ScrollLaziness");
- else if (name == "ScrollRadius")
- mScrollRadius = config.getIntValue("ScrollRadius");
- else if (name == "showBeingPopup")
- mShowBeingPopup = config.getBoolValue("showBeingPopup");
- else if (name == "selfMouseHeal")
- mSelfMouseHeal = config.getBoolValue("selfMouseHeal");
- else if (name == "enableLazyScrolling")
- mEnableLazyScrolling = config.getBoolValue("enableLazyScrolling");
- else if (name == "mouseDirectionMove")
- mMouseDirectionMove = config.getBoolValue("mouseDirectionMove");
- else if (name == "longmouseclick")
- mLongMouseClick = config.getBoolValue("longmouseclick");
-}
-
-void Viewport::mouseMoved(MouseEvent &event A_UNUSED)
-{
-}
-
-void Viewport::toggleMapDrawType()
-{
-}
-
-void Viewport::toggleCameraMode()
-{
-}
-
-void Viewport::cleanHoverItems()
-{
- mHoverBeing = nullptr;
- mHoverItem = nullptr;
- mHoverSign = nullptr;
-}
-
-bool Viewport::leftMouseAction()
-{
- return false;
-}
-
-void Viewport::videoResized()
-{
-}
diff --git a/src/progs/dyecmd/gui/viewport.h b/src/progs/dyecmd/gui/viewport.h
deleted file mode 100644
index 4b69a607c..000000000
--- a/src/progs/dyecmd/gui/viewport.h
+++ /dev/null
@@ -1,213 +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 PROGS_DYECMD_GUI_VIEWPORT_H
-#define PROGS_DYECMD_GUI_VIEWPORT_H
-
-#include "position.h"
-
-#include "gui/widgets/windowcontainer.h"
-
-#include "listeners/mouselistener.h"
-
-class ActorSprite;
-class Being;
-class FloorItem;
-class Graphics;
-class Map;
-class MapItem;
-
-/**
- * The viewport on the map. Displays the current map and handles mouse input
- * and the popup menu.
- */
-class Viewport final : public WindowContainer,
- public MouseListener,
- public ConfigListener
-{
- public:
- /**
- * Constructor.
- */
- Viewport();
-
- A_DELETE_COPY(Viewport)
-
- /**
- * Destructor.
- */
- ~Viewport();
-
- /**
- * Sets the map displayed by the viewport.
- */
- void setMap(Map *const map);
-
- /**
- * Draws the viewport.
- */
- void draw(Graphics *const graphics) override final A_NONNULL(2);
-
- void safeDraw(Graphics *const graphics) override final A_NONNULL(2);
-
- /**
- * Implements player to keep following mouse.
- */
- void logic() override final;
-
- /**
- * Toggles whether the path debug graphics are shown. normal,
- * debug with all images and grid, debug with out big images
- * and with out grid.
- */
- void toggleMapDrawType();
-
- void toggleCameraMode();
-
- /**
- * Handles mouse press on map.
- */
- void mousePressed(MouseEvent &event) override final;
-
- /**
- * Handles mouse move on map
- */
- void mouseDragged(MouseEvent &event) override final;
-
- /**
- * Handles mouse button release on map.
- */
- void mouseReleased(MouseEvent &event) override final;
-
- /**
- * Handles mouse move on map.
- */
- void mouseMoved(MouseEvent &event) override final;
-
- /**
- * A relevant config option changed.
- */
- void optionChanged(const std::string &name) override final;
-
- /**
- * Returns camera x offset in pixels.
- */
- int getCameraX() const noexcept2 A_WARN_UNUSED
- { return mPixelViewX; }
-
- /**
- * Returns camera y offset in pixels.
- */
- int getCameraY() const noexcept2 A_WARN_UNUSED
- { return mPixelViewY; }
-
- /**
- * Changes viewpoint by relative pixel coordinates.
- */
- void scrollBy(const int x, const int y)
- { mPixelViewX += x; mPixelViewY += y; }
-
- /**
- * Clear all hover item, being etc
- */
- void cleanHoverItems();
-
- Map *getMap() const noexcept2 A_WARN_UNUSED
- { return mMap; }
-
- void moveCamera(const int dx, const int dy);
-
- int getCameraRelativeX() const noexcept2 A_WARN_UNUSED
- { return mCameraRelativeX; }
-
- int getCameraRelativeY() const noexcept2 A_WARN_UNUSED
- { return mCameraRelativeY; }
-
- void setCameraRelativeX(const int n) noexcept2
- { mCameraRelativeX = n; }
-
- void setCameraRelativeY(const int n) noexcept2
- { mCameraRelativeY = n; }
-
- void videoResized();
-
- int mMouseX; /**< Current mouse position in pixels. */
- int mMouseY; /**< Current mouse position in pixels. */
-
- private:
- /**
- * Finds a path from the player to the mouse, and draws it. This is for
- * debug purposes.
- */
- void drawDebugPath(Graphics *const graphics) A_NONNULL(2);
-
- /**
- * Draws the given path.
- */
- void drawPath(Graphics *const graphics,
- const Path &path,
- const Color &color = Color(255, 0, 0))
- const A_NONNULL(2);
-
- bool leftMouseAction();
-
- bool openContextMenu(const MouseEvent &event);
-
- void walkByMouse(const MouseEvent &event);
-
- /**
- * Make the player go to the mouse position.
- */
- void followMouse();
-
- Map *mMap; /**< The current map. */
-
- Being *mHoverBeing; /**< Being mouse is currently over. */
- FloorItem *mHoverItem; /**< FloorItem mouse is currently over. */
- MapItem *mHoverSign; /**< Map sign mouse is currently over. */
-
- int mScrollRadius;
- int mScrollLaziness;
- int mScrollCenterOffsetX;
- int mScrollCenterOffsetY;
- int mMousePressX;
- int mMousePressY;
- int mPixelViewX; /**< Current viewpoint in pixels. */
- int mPixelViewY; /**< Current viewpoint in pixels. */
-
- int mLocalWalkTime; /**< Timestamp before the next walk can be sent. */
-
- int mCameraRelativeX;
- int mCameraRelativeY;
-
- bool mShowBeingPopup;
- bool mSelfMouseHeal;
- bool mEnableLazyScrolling;
- bool mMouseDirectionMove;
- bool mLongMouseClick;
- bool mMouseClicked;
- bool mPlayerFollowMouse;
-};
-
-extern Viewport *viewport; /**< The viewport. */
-
-#endif // PROGS_DYECMD_GUI_VIEWPORT_H
diff --git a/src/progs/manaplus/actions/actions.cpp b/src/progs/manaplus/actions/actions.cpp
deleted file mode 100644
index aa30257b7..000000000
--- a/src/progs/manaplus/actions/actions.cpp
+++ /dev/null
@@ -1,1918 +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 "actions/actions.h"
-
-#include "actormanager.h"
-#include "configuration.h"
-#include "game.h"
-#ifdef USE_OPENGL
-#include "graphicsmanager.h"
-#endif // USE_OPENGL
-#include "main.h"
-#include "spellmanager.h"
-
-#include "actions/actiondef.h"
-
-#include "being/localplayer.h"
-#include "being/playerinfo.h"
-
-#include "const/spells.h"
-
-#include "const/resources/skill.h"
-
-#include "fs/files.h"
-
-#include "gui/gui.h"
-#include "gui/popupmanager.h"
-#include "gui/sdlinput.h"
-#include "gui/windowmanager.h"
-
-#include "gui/shortcut/dropshortcut.h"
-#include "gui/shortcut/emoteshortcut.h"
-#include "gui/shortcut/itemshortcut.h"
-
-#include "gui/popups/popupmenu.h"
-
-#include "gui/windows/buydialog.h"
-#include "gui/windows/okdialog.h"
-#include "gui/windows/tradewindow.h"
-#include "gui/windows/quitdialog.h"
-#include "gui/windows/buyselldialog.h"
-#include "gui/windows/chatwindow.h"
-#include "gui/windows/helpwindow.h"
-#include "gui/windows/inventorywindow.h"
-#include "gui/windows/itemamountwindow.h"
-#include "gui/windows/npcdialog.h"
-#include "gui/windows/outfitwindow.h"
-#include "gui/windows/setupwindow.h"
-#include "gui/windows/shopwindow.h"
-#include "gui/windows/shortcutwindow.h"
-#include "gui/windows/skilldialog.h"
-#include "gui/windows/whoisonline.h"
-
-#include "gui/widgets/createwidget.h"
-
-#include "gui/widgets/tabs/chat/chattab.h"
-
-#include "input/inputactionoperators.h"
-
-#if defined USE_OPENGL
-#include "render/normalopenglgraphics.h"
-#endif // USE_OPENGL
-
-#include "net/adminhandler.h"
-#include "net/beinghandler.h"
-#include "net/buyingstorehandler.h"
-#include "net/buysellhandler.h"
-#include "net/chathandler.h"
-#include "net/download.h"
-#include "net/homunculushandler.h"
-#include "net/gamehandler.h"
-#include "net/inventoryhandler.h"
-#include "net/ipc.h"
-#include "net/mercenaryhandler.h"
-#include "net/net.h"
-#include "net/npchandler.h"
-#include "net/serverfeatures.h"
-#include "net/uploadcharinfo.h"
-#include "net/tradehandler.h"
-#include "net/vendinghandler.h"
-
-#include "resources/iteminfo.h"
-#include "resources/memorymanager.h"
-
-#include "resources/resourcemanager/resourcemanager.h"
-
-#include "utils/chatutils.h"
-#include "utils/delete2.h"
-#include "utils/foreach.h"
-#include "utils/gettext.h"
-#include "utils/parameters.h"
-#include "utils/timer.h"
-
-#ifdef TMWA_SUPPORT
-#include "net/playerhandler.h"
-
-#include "utils/mathutils.h"
-#endif // TMWA_SUPPORT
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#ifdef ANDROID
-#ifndef USE_SDL2
-#include <SDL_screenkeyboard.h>
-#endif // USE_OPENGL
-#endif // ANDROID
-PRAGMA48(GCC diagnostic pop)
-
-#include <sstream>
-
-#include "debug.h"
-
-extern std::string tradePartnerName;
-extern QuitDialog *quitDialog;
-extern time_t start_time;
-extern char **environ;
-
-namespace Actions
-{
-
-static int uploadUpdate(void *ptr,
- const DownloadStatusT status,
- size_t total A_UNUSED,
- const size_t remaining A_UNUSED) A_NONNULL(1);
-
-static int uploadUpdate(void *ptr,
- const DownloadStatusT status,
- size_t total A_UNUSED,
- const size_t remaining A_UNUSED)
-{
- if (status == DownloadStatus::Idle || status == DownloadStatus::Starting)
- return 0;
-
- UploadChatInfo *const info = reinterpret_cast<UploadChatInfo*>(ptr);
- if (info == nullptr)
- return 0;
-
- if (status == DownloadStatus::Complete)
- {
- std::string str = Net::Download::getUploadResponse();
- const size_t sz = str.size();
- if (sz > 0)
- {
- if (str[sz - 1] == '\n')
- str = str.substr(0, sz - 1);
- str.append(info->addStr);
- ChatTab *const tab = info->tab;
- if (chatWindow != nullptr &&
- (tab == nullptr || chatWindow->isTabPresent(tab)))
- {
- str = strprintf("%s [@@%s |%s@@]",
- info->text.c_str(), str.c_str(), str.c_str());
- outStringNormal(tab, str, str);
- }
- else
- {
- CREATEWIDGET(OkDialog,
- // TRANSLATORS: file uploaded message
- _("File uploaded"),
- str,
- // TRANSLATORS: ok dialog button
- _("OK"),
- DialogType::OK,
- Modal_true,
- ShowCenter_false,
- nullptr,
- 260);
- }
- }
- }
- delete2(info->upload);
- delete info;
- return 0;
-}
-
-static void uploadFile(const std::string &str,
- const std::string &fileName,
- const std::string &addStr,
- ChatTab *const tab)
-{
- UploadChatInfo *const info = new UploadChatInfo;
- Net::Download *const upload = new Net::Download(info,
- "http://sprunge.us",
- &uploadUpdate,
- false, true, false);
- info->upload = upload;
- info->text = str;
- info->addStr = addStr;
- info->tab = tab;
- upload->setFile(fileName);
- upload->start();
-}
-
-static Being *findBeing(const std::string &name, const bool npc)
-{
- if ((localPlayer == nullptr) || (actorManager == nullptr))
- return nullptr;
-
- Being *being = nullptr;
-
- if (name.empty())
- {
- being = localPlayer->getTarget();
- }
- else
- {
- being = actorManager->findBeingByName(
- name, ActorType::Unknown);
- }
- if ((being == nullptr) && npc)
- {
- being = actorManager->findNearestLivingBeing(
- localPlayer, 1, ActorType::Npc, AllowSort_true);
- if (being != nullptr)
- {
- if (abs(being->getTileX() - localPlayer->getTileX()) > 1
- || abs(being->getTileY() - localPlayer->getTileY()) > 1)
- {
- being = nullptr;
- }
- }
- }
- if ((being == nullptr) && npc)
- {
- being = actorManager->findNearestLivingBeing(
- localPlayer, 1, ActorType::Player, AllowSort_true);
- if (being != nullptr)
- {
- if (abs(being->getTileX() - localPlayer->getTileX()) > 1
- || abs(being->getTileY() - localPlayer->getTileY()) > 1)
- {
- being = nullptr;
- }
- }
- }
- return being;
-}
-
-static Item *getItemByInvIndex(const int index,
- const InventoryTypeT invType)
-{
- const Inventory *inv = nullptr;
- switch (invType)
- {
- case InventoryType::Storage:
- inv = PlayerInfo::getStorageInventory();
- break;
-
- case InventoryType::Inventory:
- inv = PlayerInfo::getInventory();
- break;
- case InventoryType::Trade:
- case InventoryType::Npc:
- case InventoryType::Cart:
- case InventoryType::Vending:
- case InventoryType::MailEdit:
- case InventoryType::MailView:
- case InventoryType::Craft:
- case InventoryType::TypeEnd:
- default:
- break;
- }
- if (inv != nullptr)
- return inv->getItem(index);
- return nullptr;
-}
-
-static int getAmountFromEvent(const InputEvent &event,
- Item *&item0,
- const InventoryTypeT invType)
-{
- Item *const item = getItemByInvIndex(atoi(event.args.c_str()),
- invType);
- item0 = item;
- if (item == nullptr)
- return 0;
-
- std::string str = event.args;
- removeToken(str, " ");
-
- if (str.empty())
- return 0;
-
- int amount = 0;
- if (str[0] == '-')
- {
- if (str.size() > 1)
- {
- amount = item->getQuantity() - atoi(str.substr(1).c_str());
- if (amount <= 0 || amount > item->getQuantity())
- amount = item->getQuantity();
- }
- }
- else if (str == "/")
- {
- amount = item->getQuantity() / 2;
- }
- else if (str == "all")
- {
- amount = item->getQuantity();
- }
- else
- {
- amount = atoi(str.c_str());
- }
- return amount;
-}
-
-impHandler(emote)
-{
- const int emotion = 1 + (event.action - InputAction::EMOTE_1);
- if (emotion > 0)
- {
- if (emoteShortcut != nullptr)
- emoteShortcut->useEmotePlayer(emotion);
- if (Game::instance() != nullptr)
- Game::instance()->setValidSpeed();
- return true;
- }
-
- return false;
-}
-
-impHandler(outfit)
-{
- if (inputManager.isActionActive(InputAction::WEAR_OUTFIT))
- {
- const int num = event.action - InputAction::OUTFIT_1;
- if ((outfitWindow != nullptr) && num >= 0)
- {
- outfitWindow->wearOutfit(num);
- if (Game::instance() != nullptr)
- Game::instance()->setValidSpeed();
- return true;
- }
- }
- else if (inputManager.isActionActive(InputAction::COPY_OUTFIT))
- {
- const int num = event.action - InputAction::OUTFIT_1;
- if ((outfitWindow != nullptr) && num >= 0)
- {
- outfitWindow->copyOutfit(num);
- if (Game::instance() != nullptr)
- Game::instance()->setValidSpeed();
- return true;
- }
- }
-
- return false;
-}
-
-impHandler0(mouseClick)
-{
- if ((guiInput == nullptr) || (gui == nullptr))
- return false;
-
- int mouseX, mouseY;
- Gui::getMouseState(mouseX, mouseY);
- guiInput->simulateMouseClick(mouseX, mouseY, MouseButton::RIGHT);
- return true;
-}
-
-impHandler0(ok)
-{
- // Close the Browser if opened
- if ((helpWindow != nullptr) && helpWindow->isWindowVisible())
- {
- helpWindow->setVisible(Visible_false);
- return true;
- }
- // Close the config window, cancelling changes if opened
- else if ((setupWindow != nullptr) && setupWindow->isWindowVisible())
- {
- setupWindow->action(ActionEvent(nullptr, "cancel"));
- return true;
- }
- else if (NpcDialog *const dialog = NpcDialog::getActive())
- {
- dialog->action(ActionEvent(nullptr, "ok"));
- return true;
- }
- else if (popupMenu->isPopupVisible())
- {
- popupMenu->select();
- }
- return false;
-}
-
-impHandler(shortcut)
-{
- if (itemShortcutWindow != nullptr)
- {
- const int num = itemShortcutWindow->getTabIndex();
- if (num >= 0 && num < CAST_S32(SHORTCUT_TABS))
- {
- if (itemShortcut[num] != nullptr)
- {
- itemShortcut[num]->useItem(event.action
- - InputAction::SHORTCUT_1);
- }
- }
- return true;
- }
- return false;
-}
-
-impHandler0(quit)
-{
- if (Game::instance() == nullptr)
- return false;
- if (PopupManager::isPopupMenuVisible())
- {
- PopupManager::closePopupMenu();
- return true;
- }
- else if (quitDialog == nullptr)
- {
- CREATEWIDGETV(quitDialog, QuitDialog,
- &quitDialog);
- quitDialog->requestMoveToTop();
- return true;
- }
- return false;
-}
-
-impHandler0(dropItem0)
-{
- if (dropShortcut != nullptr)
- {
- dropShortcut->dropFirst();
- return true;
- }
- return false;
-}
-
-impHandler0(dropItem)
-{
- if (dropShortcut != nullptr)
- {
- dropShortcut->dropItems();
- return true;
- }
- return false;
-}
-
-impHandler(dropItemId)
-{
- const Inventory *const inv = PlayerInfo::getInventory();
- if (inv == nullptr)
- return false;
-
- // +++ ignoring item color for now
- Item *const item = inv->findItem(atoi(event.args.c_str()),
- ItemColor_one);
-
- if ((item != nullptr) && !PlayerInfo::isItemProtected(item->getId()))
- {
- ItemAmountWindow::showWindow(ItemAmountWindowUsage::ItemDrop,
- inventoryWindow, item);
- }
- return true;
-}
-
-impHandler(dropItemInv)
-{
- Item *const item = getItemByInvIndex(atoi(event.args.c_str()),
- InventoryType::Inventory);
- if ((item != nullptr) && !PlayerInfo::isItemProtected(item->getId()))
- {
- ItemAmountWindow::showWindow(ItemAmountWindowUsage::ItemDrop,
- inventoryWindow, item);
- }
- return true;
-}
-
-impHandler(dropItemIdAll)
-{
- const Inventory *const inv = PlayerInfo::getInventory();
- if (inv == nullptr)
- return false;
-
- // +++ ignoring item color for now
- Item *const item = inv->findItem(atoi(event.args.c_str()),
- ItemColor_one);
-
- if ((item != nullptr) && !PlayerInfo::isItemProtected(item->getId()))
- PlayerInfo::dropItem(item, item->getQuantity(), Sfx_true);
- return true;
-}
-
-impHandler(dropItemInvAll)
-{
- Item *const item = getItemByInvIndex(atoi(event.args.c_str()),
- InventoryType::Inventory);
- if ((item != nullptr) && !PlayerInfo::isItemProtected(item->getId()))
- PlayerInfo::dropItem(item, item->getQuantity(), Sfx_true);
- return true;
-}
-
-#ifdef TMWA_SUPPORT
-impHandler(heal)
-{
- if (Net::getNetworkType() != ServerType::TMWATHENA)
- return false;
- if (actorManager != nullptr &&
- localPlayer != nullptr)
- {
- std::string args = event.args;
-
- if (!args.empty())
- {
- const Being *being = nullptr;
- if (args[0] == ':')
- {
- being = actorManager->findBeing(fromInt(atoi(
- args.substr(1).c_str()), BeingId));
- if (being != nullptr && being->getType() == ActorType::Monster)
- being = nullptr;
- }
- else
- {
- being = actorManager->findBeingByName(args, ActorType::Player);
- }
- if (being != nullptr)
- actorManager->heal(being);
- }
- else
- {
- Being *target = localPlayer->getTarget();
- if (inputManager.isActionActive(InputAction::STOP_ATTACK))
- {
- if (target == nullptr ||
- target->getType() != ActorType::Player)
- {
- target = actorManager->findNearestLivingBeing(
- localPlayer, 10, ActorType::Player, AllowSort_true);
- }
- }
- else
- {
- if (target == nullptr)
- target = localPlayer;
- }
- actorManager->heal(target);
- }
-
- if (Game::instance() != nullptr)
- Game::instance()->setValidSpeed();
- return true;
- }
- return false;
-}
-#else // TMWA_SUPPORT
-
-impHandler0(heal)
-{
- return false;
-}
-#endif // TMWA_SUPPORT
-
-impHandler0(healmd)
-{
-#ifdef TMWA_SUPPORT
- if (Net::getNetworkType() != ServerType::TMWATHENA)
- return false;
- if (actorManager != nullptr)
- {
- const int matk = PlayerInfo::getStatEffective(Attributes::PLAYER_MATK);
- int maxHealingRadius;
-
- // magic levels < 2
- if (PlayerInfo::getSkillLevel(340) < 2
- || PlayerInfo::getSkillLevel(341) < 2)
- {
- maxHealingRadius = matk / 100 + 1;
- }
- else
- {
- maxHealingRadius = (12 * fastSqrtInt(matk) + matk) / 100 + 1;
- }
-
- Being *target = actorManager->findMostDamagedPlayer(maxHealingRadius);
- if (target != nullptr)
- actorManager->heal(target);
-
- if (Game::instance() != nullptr)
- Game::instance()->setValidSpeed();
- return true;
- }
-#endif // TMWA_SUPPORT
-
- return false;
-}
-
-impHandler0(itenplz)
-{
-#ifdef TMWA_SUPPORT
- if (Net::getNetworkType() != ServerType::TMWATHENA)
- return false;
- if (actorManager != nullptr)
- {
- if (playerHandler != nullptr &&
- playerHandler->canUseMagic() &&
- PlayerInfo::getAttribute(Attributes::PLAYER_MP) >= 3)
- {
- actorManager->itenplz();
- }
- return true;
- }
-#endif // TMWA_SUPPORT
-
- return false;
-}
-
-impHandler0(setHome)
-{
- if (localPlayer != nullptr)
- {
- localPlayer->setHome();
- return true;
- }
- return false;
-}
-
-impHandler0(magicAttack)
-{
-#ifdef TMWA_SUPPORT
- if (Net::getNetworkType() != ServerType::TMWATHENA)
- return false;
- if (localPlayer != nullptr)
- {
- localPlayer->magicAttack();
- return true;
- }
-#endif // TMWA_SUPPORT
-
- return false;
-}
-
-impHandler0(copyEquippedToOutfit)
-{
- if (outfitWindow != nullptr)
- {
- outfitWindow->copyFromEquiped();
- return true;
- }
- return false;
-}
-
-impHandler(pickup)
-{
- if (localPlayer == nullptr)
- return false;
-
- const std::string args = event.args;
- if (args.empty())
- {
- localPlayer->pickUpItems();
- }
- else
- {
- FloorItem *const item = actorManager->findItem(fromInt(
- atoi(args.c_str()), BeingId));
- if (item != nullptr)
- localPlayer->pickUp(item);
- }
- return true;
-}
-
-static void doSit()
-{
- if (inputManager.isActionActive(InputAction::EMOTE))
- localPlayer->updateSit();
- else
- localPlayer->toggleSit();
-}
-
-impHandler0(sit)
-{
- if (localPlayer != nullptr)
- {
- doSit();
- return true;
- }
- return false;
-}
-
-impHandler(screenshot)
-{
- Game::createScreenshot(event.args);
- return true;
-}
-
-impHandler0(ignoreInput)
-{
- return true;
-}
-
-impHandler(buy)
-{
- if (serverFeatures == nullptr)
- return false;
- const std::string args = event.args;
- Being *being = findBeing(args, false);
- if ((being == nullptr) && Net::getNetworkType() == ServerType::TMWATHENA)
- {
- if (whoIsOnline != nullptr)
- {
- const std::set<std::string> &players =
- whoIsOnline->getOnlineNicks();
- if (players.find(args) != players.end())
- {
- if (buySellHandler != nullptr)
- buySellHandler->requestSellList(args);
- return true;
- }
- }
- return false;
- }
-
- if (being == nullptr)
- being = findBeing(args, true);
-
- if (being == nullptr)
- return false;
-
- if (being->getType() == ActorType::Npc)
- {
- if (npcHandler != nullptr)
- npcHandler->buy(being);
- return true;
- }
- else if (being->getType() == ActorType::Player)
- {
- if (vendingHandler != nullptr &&
- Net::getNetworkType() != ServerType::TMWATHENA)
- {
- vendingHandler->open(being);
- }
- else if (buySellHandler != nullptr)
- {
- buySellHandler->requestSellList(being->getName());
- }
- return true;
- }
- return false;
-}
-
-impHandler(sell)
-{
- if (serverFeatures == nullptr)
- return false;
-
- const std::string args = event.args;
- Being *being = findBeing(args, false);
- if (being == nullptr &&
- Net::getNetworkType() == ServerType::TMWATHENA)
- {
- if (whoIsOnline != nullptr)
- {
- const std::set<std::string> &players =
- whoIsOnline->getOnlineNicks();
- if (players.find(args) != players.end())
- {
- if (buySellHandler != nullptr)
- buySellHandler->requestBuyList(args);
- return true;
- }
- }
- return false;
- }
-
- if (being == nullptr)
- being = findBeing(args, true);
-
- if (being == nullptr)
- return false;
-
- if (being->getType() == ActorType::Npc)
- {
- if (npcHandler != nullptr)
- npcHandler->sell(being->getId());
- return true;
- }
- else if (being->getType() == ActorType::Player)
- {
- if ((buyingStoreHandler != nullptr) &&
- Net::getNetworkType() != ServerType::TMWATHENA)
- {
- buyingStoreHandler->open(being);
- }
- else if (buySellHandler != nullptr)
- {
- buySellHandler->requestBuyList(being->getName());
- }
- return true;
- }
- return false;
-}
-
-impHandler(talk)
-{
- Being *being = findBeing(event.args, true);
- if (being == nullptr)
- return false;
-
- if (being->canTalk())
- {
- being->talkTo();
- }
- else if (being->getType() == ActorType::Player)
- {
- CREATEWIDGET(BuySellDialog,
- being->getName());
- }
- return true;
-}
-
-impHandler0(stopAttack)
-{
- if (localPlayer != nullptr)
- {
- localPlayer->stopAttack();
- // not consume if target attack key pressed
- if (inputManager.isActionActive(InputAction::TARGET_ATTACK))
- return false;
- return true;
- }
- return false;
-}
-
-impHandler0(untarget)
-{
- if (localPlayer != nullptr)
- {
- localPlayer->untarget();
- return true;
- }
- return false;
-}
-
-impHandler(attack)
-{
- if ((localPlayer == nullptr) || (actorManager == nullptr))
- return false;
-
- Being *target = nullptr;
- std::string args = event.args;
- if (!args.empty())
- {
- if (args[0] != ':')
- {
- target = actorManager->findNearestByName(args);
- }
- else
- {
- target = actorManager->findBeing(fromInt(atoi(
- args.substr(1).c_str()), BeingId));
- if (target != nullptr &&
- target->getType() != ActorType::Monster)
- {
- target = nullptr;
- }
- }
- }
- if (target == nullptr)
- target = localPlayer->getTarget();
- else
- localPlayer->setTarget(target);
- if (target != nullptr)
- localPlayer->attack(target, true);
- return true;
-}
-
-impHandler(targetAttack)
-{
- if ((localPlayer != nullptr) && (actorManager != nullptr))
- {
- Being *target = nullptr;
- std::string args = event.args;
- const bool newTarget = !inputManager.isActionActive(
- InputAction::STOP_ATTACK);
-
- if (!args.empty())
- {
- if (args[0] != ':')
- {
- target = actorManager->findNearestByName(args);
- }
- else
- {
- target = actorManager->findBeing(fromInt(atoi(
- args.substr(1).c_str()), BeingId));
- if (target != nullptr &&
- target->getType() != ActorType::Monster)
- {
- target = nullptr;
- }
- }
- }
-
- if ((target == nullptr) && (settings.targetingType == 0u))
- target = localPlayer->getTarget();
-
- if (target == nullptr)
- {
- target = actorManager->findNearestLivingBeing(
- localPlayer, 90, ActorType::Monster, AllowSort_true);
- }
-
- localPlayer->attack2(target, newTarget);
- return true;
- }
- return false;
-}
-
-impHandler0(attackHuman)
-{
- if ((actorManager == nullptr) || (localPlayer == nullptr))
- return false;
-
- Being *const target = actorManager->findNearestPvpPlayer();
- if (target != nullptr)
- {
- localPlayer->setTarget(target);
- localPlayer->attack2(target, true);
- }
- return true;
-}
-
-impHandler0(safeVideoMode)
-{
- WindowManager::setFullScreen(false);
-
- return true;
-}
-
-impHandler0(stopSit)
-{
- if (localPlayer != nullptr)
- {
- localPlayer->stopAttack();
- // not consume if target attack key pressed
- if (inputManager.isActionActive(InputAction::TARGET_ATTACK))
- return false;
- if (localPlayer->getTarget() == nullptr)
- {
- doSit();
- return true;
- }
- return true;
- }
- return false;
-}
-
-impHandler0(showKeyboard)
-{
-#ifdef ANDROID
-#ifdef USE_SDL2
- if (SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE)
- SDL_StopTextInput();
- else
- SDL_StartTextInput();
-#else // USE_SDL2
-
- SDL_ANDROID_ToggleScreenKeyboardTextInput(nullptr);
-#endif // USE_SDL2
-
- return true;
-#else // ANDROID
-
- return false;
-#endif // ANDROID
-}
-
-impHandler0(showWindows)
-{
- if (popupMenu != nullptr)
- {
- popupMenu->showWindowsPopup();
- return true;
- }
- return false;
-}
-
-impHandler0(openTrade)
-{
- const Being *const being = localPlayer->getTarget();
- if ((being != nullptr) && being->getType() == ActorType::Player)
- {
- if (tradeHandler != nullptr)
- tradeHandler->request(being);
- tradePartnerName = being->getName();
- if (tradeWindow != nullptr)
- tradeWindow->clear();
- return true;
- }
- return false;
-}
-
-impHandler0(ipcToggle)
-{
- if (ipc != nullptr)
- {
- IPC::stop();
- if (ipc == nullptr)
- {
- debugChatTab->chatLog("IPC service stopped.",
- ChatMsgType::BY_SERVER);
- }
- else
- {
- debugChatTab->chatLog("Unable to stop IPC service.",
- ChatMsgType::BY_SERVER);
- }
- }
- else
- {
- IPC::start();
- if (ipc != nullptr)
- {
- debugChatTab->chatLog(
- strprintf("IPC service available on port %d", ipc->getPort()),
- ChatMsgType::BY_SERVER);
- }
- else
- {
- debugChatTab->chatLog("Unable to start IPC service",
- ChatMsgType::BY_SERVER);
- }
- }
- return true;
-}
-
-impHandler(where)
-{
- ChatTab *const tab = event.tab != nullptr ? event.tab : debugChatTab;
- if (tab == nullptr)
- return false;
- std::ostringstream where;
- where << Game::instance()->getCurrentMapName() << ", coordinates: "
- << ((localPlayer->getPixelX() - mapTileSize / 2) / mapTileSize)
- << ", " << ((localPlayer->getPixelY() - mapTileSize) / mapTileSize);
- tab->chatLog(where.str(), ChatMsgType::BY_SERVER);
- return true;
-}
-
-impHandler0(who)
-{
- if (chatHandler != nullptr)
- chatHandler->who();
- return true;
-}
-
-impHandler0(cleanGraphics)
-{
- ResourceManager::clearCache();
-
- if (debugChatTab != nullptr)
- {
- // TRANSLATORS: clear graphics command message
- debugChatTab->chatLog(_("Cache cleaned"),
- ChatMsgType::BY_SERVER);
- }
- return true;
-}
-
-impHandler0(cleanFonts)
-{
- if (gui != nullptr)
- gui->clearFonts();
- if (debugChatTab != nullptr)
- {
- // TRANSLATORS: clear fonts cache message
- debugChatTab->chatLog(_("Cache cleaned"),
- ChatMsgType::BY_SERVER);
- }
- return true;
-}
-
-impHandler(trade)
-{
- if (actorManager == nullptr)
- return false;
-
- const Being *being = actorManager->findBeingByName(
- event.args, ActorType::Player);
- if (being == nullptr)
- being = localPlayer->getTarget();
- if (being != nullptr)
- {
- if (tradeHandler != nullptr)
- tradeHandler->request(being);
- tradePartnerName = being->getName();
- if (tradeWindow != nullptr)
- tradeWindow->clear();
- }
- return true;
-}
-
-impHandler0(priceLoad)
-{
- if (shopWindow != nullptr)
- {
- shopWindow->loadList();
- return true;
- }
- return false;
-}
-
-impHandler0(priceSave)
-{
- if (shopWindow != nullptr)
- {
- shopWindow->saveList();
- return true;
- }
- return false;
-}
-
-impHandler0(cacheInfo)
-{
- if ((chatWindow == nullptr) || (debugChatTab == nullptr))
- return false;
-
-/*
- Font *const font = chatWindow->getFont();
- if (!font)
- return;
-
- const TextChunkList *const cache = font->getCache();
- if (!cache)
- return;
-
- unsigned int all = 0;
- // TRANSLATORS: chat fonts message
- debugChatTab->chatLog(_("font cache size"), ChatMsgType::BY_SERVER);
- std::string str;
- for (int f = 0; f < 256; f ++)
- {
- if (!cache[f].size)
- {
- const unsigned int sz = CAST_S32(cache[f].size);
- all += sz;
- str.append(strprintf("%d: %u, ", f, sz));
- }
- }
- debugChatTab->chatLog(str, ChatMsgType::BY_SERVER);
- // TRANSLATORS: chat fonts message
- debugChatTab->chatLog(strprintf("%s %d", _("Cache size:"), all),
- ChatMsgType::BY_SERVER);
-#ifdef DEBUG_FONT_COUNTERS
- debugChatTab->chatLog("", ChatMsgType::BY_SERVER);
- debugChatTab->chatLog(strprintf("%s %d",
- // TRANSLATORS: chat fonts message
- _("Created:"), font->getCreateCounter()),
- ChatMsgType::BY_SERVER);
- debugChatTab->chatLog(strprintf("%s %d",
- // TRANSLATORS: chat fonts message
- _("Deleted:"), font->getDeleteCounter()),
- ChatMsgType::BY_SERVER);
-#endif
-*/
- return true;
-}
-
-impHandler0(disconnect)
-{
- if (gameHandler != nullptr)
- gameHandler->disconnect2();
- return true;
-}
-
-impHandler(undress)
-{
- if ((actorManager == nullptr) || (localPlayer == nullptr))
- return false;
-
- const std::string args = event.args;
- StringVect pars;
- if (!splitParameters(pars, args, " ,", '\"'))
- return false;
- Being *target = nullptr;
- const size_t sz = pars.size();
- if (sz == 0)
- {
- target = localPlayer->getTarget();
- }
- else
- {
- if (pars[0][0] == ':')
- {
- target = actorManager->findBeing(fromInt(atoi(
- pars[0].substr(1).c_str()), BeingId));
- if ((target != nullptr) && target->getType() == ActorType::Monster)
- target = nullptr;
- }
- else
- {
- target = actorManager->findNearestByName(args);
- }
- }
-
- if (sz == 2)
- {
- const int itemId = atoi(pars[1].c_str());
- if (target != nullptr)
- target->undressItemById(itemId);
- }
- else
- {
- if ((target != nullptr) && (beingHandler != nullptr))
- beingHandler->undress(target);
- }
-
- return true;
-}
-
-impHandler0(dirs)
-{
- if (debugChatTab == nullptr)
- return false;
-
- debugChatTab->chatLog("config directory: "
- + settings.configDir,
- ChatMsgType::BY_SERVER);
- debugChatTab->chatLog("logs directory: "
- + settings.localDataDir,
- ChatMsgType::BY_SERVER);
- debugChatTab->chatLog("screenshots directory: "
- + settings.screenshotDir,
- ChatMsgType::BY_SERVER);
- debugChatTab->chatLog("temp directory: "
- + settings.tempDir,
- ChatMsgType::BY_SERVER);
- return true;
-}
-
-impHandler0(uptime)
-{
- if (debugChatTab == nullptr)
- return false;
-
- if (cur_time < start_time)
- {
- // TRANSLATORS: uptime command
- debugChatTab->chatLog(strprintf(_("Client uptime: %s"), "unknown"),
- ChatMsgType::BY_SERVER);
- }
- else
- {
- // TRANSLATORS: uptime command
- debugChatTab->chatLog(strprintf(_("Client uptime: %s"),
- timeDiffToString(CAST_S32(cur_time - start_time)).c_str()),
- ChatMsgType::BY_SERVER);
- }
- return true;
-}
-
-#ifdef DEBUG_DUMP_LEAKS1
-static void showRes(std::string str, ResourceManager::Resources *res)
-{
- if (!res)
- return;
-
- str.append(toString(res->size()));
- if (debugChatTab)
- debugChatTab->chatLog(str, ChatMsgType::BY_SERVER);
- logger->log(str);
- ResourceManager::ResourceIterator iter = res->begin();
- const ResourceManager::ResourceIterator iter_end = res->end();
- while (iter != iter_end)
- {
- if (iter->second && iter->second->mRefCount)
- {
- char type = ' ';
- char isNew = 'N';
- if (iter->second->getDumped())
- isNew = 'O';
- else
- iter->second->setDumped(true);
-
- SubImage *const subImage = dynamic_cast<SubImage *>(
- iter->second);
- Image *const image = dynamic_cast<Image *>(iter->second);
- int id = 0;
- if (subImage)
- type = 'S';
- else if (image)
- type = 'I';
- if (image)
- id = image->getGLImage();
- logger->log("Resource %c%c: %s (%d) id=%d", type,
- isNew, iter->second->getIdPath().c_str(),
- iter->second->mRefCount, id);
- }
- ++ iter;
- }
-}
-
-impHandler(dump)
-{
- if (!debugChatTab)
- return false;
-
- if (!event.args.empty())
- {
- ResourceManager::Resources *res = ResourceManager::getResources();
- // TRANSLATORS: dump command
- showRes(_("Resource images:"), res);
- res = ResourceManager::getOrphanedResources();
- // TRANSLATORS: dump command
- showRes(_("Resource orphaned images:"), res);
- }
- else
- {
- ResourceManager::Resources *res = ResourceManager::getResources();
- // TRANSLATORS: dump command
- debugChatTab->chatLog(_("Resource images:") + toString(res->size()),
- ChatMsgType::BY_SERVER);
- res = ResourceManager::getOrphanedResources();
- // TRANSLATORS: dump command
- debugChatTab->chatLog(_("Resource orphaned images:")
- + toString(res->size()),
- ChatMsgType::BY_SERVER);
- }
- return true;
-}
-
-#elif defined ENABLE_MEM_DEBUG
-impHandler0(dump)
-{
- nvwa::check_leaks();
- return true;
-}
-#else // DEBUG_DUMP_LEAKS1
-
-impHandler0(dump)
-{
- return true;
-}
-#endif // DEBUG_DUMP_LEAKS1
-
-impHandler0(serverIgnoreAll)
-{
- if (chatHandler != nullptr)
- chatHandler->ignoreAll();
- return true;
-}
-
-impHandler0(serverUnIgnoreAll)
-{
- if (chatHandler != nullptr)
- chatHandler->unIgnoreAll();
- return true;
-}
-
-PRAGMA6(GCC diagnostic push)
-PRAGMA6(GCC diagnostic ignored "-Wnull-dereference")
-impHandler0(error)
-{
- int *const ptr = nullptr;
- *(ptr + 1) = 20;
-// logger->log("test %d", *ptr);
- exit(1);
-}
-PRAGMA6(GCC diagnostic pop)
-
-impHandler(dumpGraphics)
-{
- std::string str = strprintf("%s,%s,%dX%dX%d,", PACKAGE_OS, SMALL_VERSION,
- mainGraphics->getWidth(), mainGraphics->getHeight(),
- mainGraphics->getBpp());
-
- if (mainGraphics->getFullScreen())
- str.append("F");
- else
- str.append("W");
- if (mainGraphics->getHWAccel())
- str.append("H");
- else
- str.append("S");
-
- if (mainGraphics->getDoubleBuffer())
- str.append("D");
- else
- str.append("_");
-
-#if defined USE_OPENGL
- str.append(strprintf(",%d", mainGraphics->getOpenGL()));
-#else // defined USE_OPENGL
-
- str.append(",0");
-#endif // defined USE_OPENGL
-
- str.append(strprintf(",%f,", static_cast<double>(settings.guiAlpha)))
- .append(config.getBoolValue("adjustPerfomance") ? "1" : "0")
- .append(config.getBoolValue("alphaCache") ? "1" : "0")
- .append(config.getBoolValue("enableMapReduce") ? "1" : "0")
- .append(config.getBoolValue("beingopacity") ? "1" : "0")
- .append(",")
- .append(config.getBoolValue("enableAlphaFix") ? "1" : "0")
- .append(config.getBoolValue("disableAdvBeingCaching") ? "1" : "0")
- .append(config.getBoolValue("disableBeingCaching") ? "1" : "0")
- .append(config.getBoolValue("particleeffects") ? "1" : "0")
- .append(strprintf(",%d-%d", fps, config.getIntValue("fpslimit")));
- outStringNormal(event.tab, str, str);
- return true;
-}
-
-impHandler0(dumpEnvironment)
-{
- logger->log1("Start environment variables");
- for (char **env = environ; *env != nullptr; ++ env)
- logger->log1(*env);
- logger->log1("End environment variables");
- if (debugChatTab != nullptr)
- {
- // TRANSLATORS: dump environment command
- debugChatTab->chatLog(_("Environment variables dumped"),
- ChatMsgType::BY_SERVER);
- }
- return true;
-}
-
-impHandler(dumpTests)
-{
- const std::string str = config.getStringValue("testInfo");
- outStringNormal(event.tab, str, str);
- return true;
-}
-
-impHandler0(dumpOGL)
-{
-#if defined(USE_OPENGL) && !defined(ANDROID) && !defined(__native_client__)
- NormalOpenGLGraphics::dumpSettings();
-#endif // defined(USE_OPENGL) && !defined(ANDROID) &&
- // !defined(__native_client__)
-
- return true;
-}
-
-#ifdef USE_OPENGL
-impHandler(dumpGL)
-{
- std::string str = graphicsManager.getGLVersion();
- outStringNormal(event.tab, str, str);
- return true;
-}
-#else // USE_OPENGL
-
-impHandler0(dumpGL)
-{
- return true;
-}
-#endif // USE_OPENGL
-
-impHandler(dumpMods)
-{
- std::string str = "enabled mods: " + serverConfig.getValue("mods", "");
- outStringNormal(event.tab, str, str);
- return true;
-}
-
-#if defined USE_OPENGL && defined DEBUG_SDLFONT
-impHandler0(testSdlFont)
-{
- Font *font = new Font("fonts/dejavusans.ttf", 18, TTF_STYLE_NORMAL);
- timespec time1;
- timespec time2;
- NullOpenGLGraphics *nullGraphics = new NullOpenGLGraphics;
- STD_VECTOR<std::string> data;
- volatile int width = 0;
-
- for (int f = 0; f < 300; f ++)
- data.push_back("test " + toString(f) + "string");
- nullGraphics->beginDraw();
-
- clock_gettime(CLOCK_MONOTONIC, &time1);
- Color color(0, 0, 0, 255);
-
- for (int f = 0; f < 500; f ++)
- {
- FOR_EACH (STD_VECTOR<std::string>::const_iterator, it, data)
- {
- width += font->getWidth(*it);
- font->drawString(nullGraphics, color, color, *it, 10, 10);
- }
- FOR_EACH (STD_VECTOR<std::string>::const_iterator, it, data)
- font->drawString(nullGraphics, color, color, *it, 10, 10);
-
- font->doClean();
- }
-
- clock_gettime(CLOCK_MONOTONIC, &time2);
-
- delete nullGraphics;
- delete font;
-
- int64_t diff = (static_cast<long long int>(
- time2.tv_sec) * 1000000000LL + static_cast<long long int>(
- time2.tv_nsec)) / 100000 - (static_cast<long long int>(
- time1.tv_sec) * 1000000000LL + static_cast<long long int>(
- time1.tv_nsec)) / 100000;
- if (debugChatTab)
- {
- debugChatTab->chatLog("sdlfont time: " + toString(diff),
- ChatMsgType::BY_SERVER);
- }
- return true;
-}
-#endif // defined USE_OPENGL && defined DEBUG_SDLFONT
-
-impHandler0(createItems)
-{
- BuyDialog *const dialog = CREATEWIDGETR0(BuyDialog);
- const ItemDB::ItemInfos &items = ItemDB::getItemInfos();
- FOR_EACH (ItemDB::ItemInfos::const_iterator, it, items)
- {
- const ItemInfo *const info = (*it).second;
- if (info == nullptr)
- continue;
- const int id = info->getId();
- if (id <= 500)
- continue;
-
- dialog->addItem(id,
- ItemType::Unknown,
- ItemColor_one,
- 100,
- 0);
- }
- dialog->sort();
- return true;
-}
-
-impHandler(createItem)
-{
- int id = 0;
- int amount = 0;
-
- if (adminHandler == nullptr)
- return false;
-
- if (parse2Int(event.args, id, amount))
- adminHandler->createItems(id, ItemColor_one, amount);
- else
- adminHandler->createItems(atoi(event.args.c_str()), ItemColor_one, 1);
- return true;
-}
-
-impHandler(uploadConfig)
-{
- // TRANSLATORS: upload config chat message
- uploadFile(_("Uploaded config into:"),
- config.getFileName(),
- "?xml",
- event.tab);
- return true;
-}
-
-impHandler(uploadServerConfig)
-{
- // TRANSLATORS: upload config chat message
- uploadFile(_("Uploaded server config into:"),
- serverConfig.getFileName(),
- "?xml",
- event.tab);
- return true;
-}
-
-impHandler(uploadLog)
-{
- // TRANSLATORS: upload log chat message
- uploadFile(_("Uploaded log into:"),
- settings.logFileName,
- "?txt",
- event.tab);
- return true;
-}
-
-impHandler0(mercenaryFire)
-{
- if (mercenaryHandler != nullptr)
- mercenaryHandler->fire();
- return true;
-}
-
-impHandler0(mercenaryToMaster)
-{
- if (mercenaryHandler != nullptr)
- mercenaryHandler->moveToMaster();
- return true;
-}
-
-impHandler0(homunculusToMaster)
-{
- if (homunculusHandler != nullptr)
- homunculusHandler->moveToMaster();
- return true;
-}
-
-impHandler0(homunculusFeed)
-{
- if (homunculusHandler != nullptr)
- homunculusHandler->feed();
- return true;
-}
-
-impHandler(useItem)
-{
- const int itemId = atoi(event.args.c_str());
-
- if (itemId < SPELL_MIN_ID)
- {
- const Inventory *const inv = PlayerInfo::getInventory();
- if (inv != nullptr)
- {
- // +++ ignoring item color for now
- const Item *const item = inv->findItem(itemId,
- ItemColor_one);
- PlayerInfo::useEquipItem(item, 0, Sfx_true);
- }
- }
- else if (itemId < SKILL_MIN_ID && (spellManager != nullptr))
- {
- spellManager->useItem(itemId);
- }
- else if (skillDialog != nullptr)
- {
- // +++ probably need get data parameter from args
- skillDialog->useItem(itemId,
- fromBool(config.getBoolValue("skillAutotarget"), AutoTarget),
- 0,
- std::string());
- }
- return true;
-}
-
-impHandler(useItemInv)
-{
- int param1 = 0;
- int param2 = 0;
- const std::string args = event.args;
- if (parse2Int(args, param1, param2))
- {
- Item *const item = getItemByInvIndex(param1,
- InventoryType::Inventory);
- PlayerInfo::useEquipItem(item, CAST_S16(param2), Sfx_true);
- }
- else
- {
- Item *const item = getItemByInvIndex(atoi(event.args.c_str()),
- InventoryType::Inventory);
- PlayerInfo::useEquipItem(item, 0, Sfx_true);
- }
- return true;
-}
-
-impHandler(invToStorage)
-{
- Item *item = nullptr;
- const int amount = getAmountFromEvent(event, item,
- InventoryType::Inventory);
- if (item == nullptr)
- return true;
- if (amount != 0)
- {
- if (inventoryHandler != nullptr)
- {
- inventoryHandler->moveItem2(InventoryType::Inventory,
- item->getInvIndex(),
- amount,
- InventoryType::Storage);
- }
- }
- else
- {
- ItemAmountWindow::showWindow(ItemAmountWindowUsage::StoreAdd,
- inventoryWindow, item);
- }
- return true;
-}
-
-impHandler(tradeAdd)
-{
- Item *item = nullptr;
- const int amount = getAmountFromEvent(event, item,
- InventoryType::Inventory);
- if ((item == nullptr) || PlayerInfo::isItemProtected(item->getId()))
- return true;
-
- if (amount != 0)
- {
- if (tradeWindow != nullptr)
- tradeWindow->tradeItem(item, amount, true);
- }
- else
- {
- ItemAmountWindow::showWindow(ItemAmountWindowUsage::TradeAdd,
- tradeWindow, item);
- }
- return true;
-}
-
-impHandler(storageToInv)
-{
- Item *item = nullptr;
- const int amount = getAmountFromEvent(event, item, InventoryType::Storage);
- if (amount != 0)
- {
- if ((inventoryHandler != nullptr) && (item != nullptr))
- {
- inventoryHandler->moveItem2(InventoryType::Storage,
- item->getInvIndex(),
- amount,
- InventoryType::Inventory);
- }
- }
- else
- {
- ItemAmountWindow::showWindow(ItemAmountWindowUsage::StoreRemove,
- storageWindow, item);
- }
- return true;
-}
-
-impHandler(protectItem)
-{
- const int id = atoi(event.args.c_str());
- if (id > 0)
- PlayerInfo::protectItem(id);
- return true;
-}
-
-impHandler(unprotectItem)
-{
- const int id = atoi(event.args.c_str());
- if (id > 0)
- PlayerInfo::unprotectItem(id);
- return true;
-}
-
-impHandler(kick)
-{
- if ((localPlayer == nullptr) || (actorManager == nullptr))
- return false;
-
- Being *target = nullptr;
- std::string args = event.args;
- if (!args.empty())
- {
- if (args[0] != ':')
- {
- target = actorManager->findNearestByName(args);
- }
- else
- {
- target = actorManager->findBeing(fromInt(atoi(
- args.substr(1).c_str()), BeingId));
- }
- }
- if (target == nullptr)
- target = localPlayer->getTarget();
- if ((target != nullptr) && (adminHandler != nullptr))
- adminHandler->kick(target->getId());
- return true;
-}
-
-impHandler0(clearDrop)
-{
- if (dropShortcut != nullptr)
- dropShortcut->clear();
- return true;
-}
-
-impHandler0(testInfo)
-{
- if (actorManager != nullptr)
- {
- logger->log("actors count: %d", CAST_S32(
- actorManager->size()));
- return true;
- }
- return false;
-}
-
-impHandler(craftKey)
-{
- const int slot = (event.action - InputAction::CRAFT_1);
- if (slot >= 0 && slot < 9)
- {
- if (inventoryWindow != nullptr)
- inventoryWindow->moveItemToCraft(slot);
- return true;
- }
- return false;
-}
-
-impHandler0(resetGameModifiers)
-{
- GameModifiers::resetModifiers();
- return true;
-}
-
-impHandler(barToChat)
-{
- if (chatWindow != nullptr)
- {
- chatWindow->addInputText(event.args);
- return true;
- }
- return false;
-}
-
-impHandler(seen)
-{
- if (actorManager == nullptr)
- return false;
-
- ChatTab *tab = event.tab;
- if (tab == nullptr)
- tab = localChatTab;
- if (tab == nullptr)
- return false;
-
- if (config.getBoolValue("enableIdCollecting") == false)
- {
- // TRANSLATORS: last seen disabled warning
- tab->chatLog(_("Last seen disabled. "
- "Enable in players / collect players id and seen log."),
- ChatMsgType::BY_SERVER);
- return true;
- }
-
- const std::string name = event.args;
- if (name.empty())
- return false;
-
- std::string dir = settings.usersDir;
- dir.append(stringToHexPath(name)).append("/seen.txt");
- if (Files::existsLocal(dir))
- {
- StringVect lines;
- Files::loadTextFileLocal(dir, lines);
- if (lines.size() < 3)
- {
- // TRANSLATORS: last seen error
- tab->chatLog(_("You not saw this nick."),
- ChatMsgType::BY_SERVER);
- return true;
- }
- const std::string message = strprintf(
- // TRANSLATORS: last seen message
- _("Last seen for %s: %s"),
- name.c_str(),
- lines[2].c_str());
- tab->chatLog(message, ChatMsgType::BY_SERVER);
- }
- else
- {
- // TRANSLATORS: last seen error
- tab->chatLog(_("You not saw this nick."),
- ChatMsgType::BY_SERVER);
- }
-
- return true;
-}
-
-impHandler(dumpMemoryUsage)
-{
- if (event.tab != nullptr)
- memoryManager.printAllMemory(event.tab);
- else
- memoryManager.printAllMemory(localChatTab);
- return true;
-}
-
-impHandler(setEmoteType)
-{
- const std::string &args = event.args;
- if (args == "player" || args.empty())
- {
- settings.emoteType = EmoteType::Player;
- }
- else if (args == "pet")
- {
- settings.emoteType = EmoteType::Pet;
- }
- else if (args == "homun" || args == "homunculus")
- {
- settings.emoteType = EmoteType::Homunculus;
- }
- else if (args == "merc" || args == "mercenary")
- {
- settings.emoteType = EmoteType::Mercenary;
- }
- return true;
-}
-
-} // namespace Actions
diff --git a/src/progs/manaplus/actions/chat.cpp b/src/progs/manaplus/actions/chat.cpp
deleted file mode 100644
index 307e4556e..000000000
--- a/src/progs/manaplus/actions/chat.cpp
+++ /dev/null
@@ -1,808 +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 "actions/chat.h"
-
-#include "configuration.h"
-
-#include "actions/actiondef.h"
-
-#include "const/gui/chat.h"
-
-#include "being/localplayer.h"
-
-#include "gui/sdlinput.h"
-
-#include "gui/windows/chatwindow.h"
-
-#include "listeners/inputactionreplaylistener.h"
-
-#include "net/charserverhandler.h"
-#include "net/chathandler.h"
-#include "net/guildhandler.h"
-#include "net/net.h"
-#include "net/partyhandler.h"
-
-#ifdef TMWA_SUPPORT
-#include "net/tmwa/guildmanager.h"
-#endif // TMWA_SUPPORT
-
-#include "resources/iteminfo.h"
-
-#include "resources/db/itemdb.h"
-
-#include "utils/booleanoptions.h"
-#include "utils/chatutils.h"
-#include "utils/parameters.h"
-
-#include "utils/translation/podict.h"
-
-#include "debug.h"
-
-const int DEFAULT_CHAT_WINDOW_SCROLL = 7;
-
-namespace Actions
-{
-
-static void outString(ChatTab *const tab,
- const std::string &str,
- const std::string &def)
-{
- if (tab == nullptr)
- {
- if (chatHandler != nullptr)
- chatHandler->talk(def, GENERAL_CHANNEL);
- return;
- }
-
- switch (tab->getType())
- {
- case ChatTabType::PARTY:
- {
- if (partyHandler != nullptr)
- partyHandler->chat(str);
- break;
- }
- case ChatTabType::GUILD:
- {
- if ((guildHandler == nullptr) || (localPlayer == nullptr))
- return;
- const Guild *const guild = localPlayer->getGuild();
- if (guild != nullptr)
- {
-#ifdef TMWA_SUPPORT
- if (guild->getServerGuild())
- {
- if (Net::getNetworkType() == ServerType::TMWATHENA)
- return;
- guildHandler->chat(str);
- }
- else if (guildManager != nullptr)
- {
- guildManager->chat(str);
- }
-#else // TMWA_SUPPORT
-
- if (guild->getServerGuild())
- guildHandler->chat(str);
-#endif // TMWA_SUPPORT
- }
- break;
- }
- case ChatTabType::CHANNEL:
- case ChatTabType::GM:
- case ChatTabType::TRADE:
- tab->chatInput(str);
- break;
- default:
- case ChatTabType::UNKNOWN:
- case ChatTabType::INPUT:
- case ChatTabType::WHISPER:
- case ChatTabType::DEBUG:
- case ChatTabType::BATTLE:
- case ChatTabType::LANG:
- if (chatHandler != nullptr)
- chatHandler->talk(str, GENERAL_CHANNEL);
- break;
- }
-}
-
-impHandler0(toggleChat)
-{
- return chatWindow != nullptr ? chatWindow->requestChatFocus() : false;
-}
-
-impHandler0(prevChatTab)
-{
- if (chatWindow != nullptr)
- {
- chatWindow->prevTab();
- return true;
- }
- return false;
-}
-
-impHandler0(nextChatTab)
-{
- if (chatWindow != nullptr)
- {
- chatWindow->nextTab();
- return true;
- }
- return false;
-}
-
-impHandler0(closeChatTab)
-{
- if (chatWindow != nullptr)
- {
- chatWindow->closeTab();
- return true;
- }
- return false;
-}
-
-impHandler0(closeAllChatTabs)
-{
- if (chatWindow != nullptr)
- {
- chatWindow->removeAllWhispers();
- chatWindow->saveState();
- return true;
- }
- return false;
-}
-
-impHandler0(ignoreAllWhispers)
-{
- if (chatWindow != nullptr)
- {
- chatWindow->ignoreAllWhispers();
- chatWindow->saveState();
- return true;
- }
- return false;
-}
-
-impHandler0(scrollChatUp)
-{
- if ((chatWindow != nullptr) && chatWindow->isWindowVisible())
- {
- chatWindow->scroll(-DEFAULT_CHAT_WINDOW_SCROLL);
- return true;
- }
- return false;
-}
-
-impHandler0(scrollChatDown)
-{
- if ((chatWindow != nullptr) && chatWindow->isWindowVisible())
- {
- chatWindow->scroll(DEFAULT_CHAT_WINDOW_SCROLL);
- return true;
- }
- return false;
-}
-
-static bool splitWhisper(const std::string &args,
- std::string &recvnick,
- std::string &message)
-{
- if (args.substr(0, 1) == "\"")
- {
- const size_t pos = args.find('"', 1);
- if (pos != std::string::npos)
- {
- recvnick = args.substr(1, pos - 1);
- if (pos + 2 < args.length())
- message = args.substr(pos + 2, args.length());
- }
- }
- else
- {
- const size_t pos = args.find(' ');
- if (pos != std::string::npos)
- {
- recvnick = args.substr(0, pos);
- if (pos + 1 < args.length())
- message = args.substr(pos + 1, args.length());
- }
- else
- {
- recvnick = std::string(args);
- message.clear();
- }
- }
-
- trim(message);
-
- if (message.length() > 0)
- {
- std::string playerName = localPlayer->getName();
- std::string tempNick = recvnick;
-
- toLower(playerName);
- toLower(tempNick);
-
- if (tempNick == playerName || args.empty())
- return false;
-
- return true;
- }
- return false;
-}
-
-impHandler(msg)
-{
- std::string recvnick;
- std::string message;
-
- if (splitWhisper(event.args, recvnick, message))
- {
- if (chatWindow == nullptr)
- return false;
- ChatTab *const tab = chatWindow->addChatTab(recvnick, false, true);
- if (tab != nullptr)
- {
- chatWindow->saveState();
- tab->chatInput(message);
- }
- }
- else
- {
- if (event.tab != nullptr)
- {
- event.tab->chatLog(
- // TRANSLATORS: whisper send
- _("Cannot send empty whisper or channel message!"),
- ChatMsgType::BY_SERVER);
- }
- }
- return true;
-}
-
-impHandler(msgText)
-{
- if (chatWindow == nullptr)
- return false;
-
- if (config.getBoolValue("whispertab"))
- {
- chatWindow->localChatInput("/q " + event.args);
- }
- else
- {
- chatWindow->addInputText(std::string("/w \"").append(
- event.args).append("\" "));
- }
- return true;
-}
-
-impHandler(msg2)
-{
- std::string recvnick;
- std::string message;
-
- if (chatHandler != nullptr &&
- splitWhisper(event.args, recvnick, message))
- {
- chatHandler->privateMessage(recvnick, message);
- }
- return true;
-}
-
-impHandler(query)
-{
- const std::string &args = event.args;
- if (chatWindow != nullptr)
- {
- if (chatWindow->addChatTab(args, true, true) != nullptr)
- {
- chatWindow->saveState();
- return true;
- }
- }
-
- if (event.tab != nullptr)
- {
- // TRANSLATORS: new whisper or channel query
- event.tab->chatLog(strprintf(_("Cannot create a whisper tab "
- "\"%s\"! It probably already exists."),
- args.c_str()), ChatMsgType::BY_SERVER);
- }
- return true;
-}
-
-impHandler0(clearChatTab)
-{
- if (chatWindow != nullptr)
- {
- chatWindow->clearTab();
- return true;
- }
- return false;
-}
-
-impHandler(createParty)
-{
- if (partyHandler == nullptr)
- return false;
-
- if (event.args.empty())
- {
- // TRANSLATORS: dialog header
- inputActionReplayListener.openDialog(_("Create party"),
- "",
- InputAction::CREATE_PARTY);
- }
- else
- {
- partyHandler->create(event.args);
- }
- return true;
-}
-
-impHandler(createGuild)
-{
- if ((guildHandler == nullptr) ||
- Net::getNetworkType() == ServerType::TMWATHENA)
- {
- return false;
- }
-
- if (event.args.empty())
- {
- // TRANSLATORS: dialog header
- inputActionReplayListener.openDialog(_("Create guild"),
- "",
- InputAction::CREATE_GUILD);
- }
- else
- {
- guildHandler->create(event.args);
- }
- return true;
-}
-
-impHandler(party)
-{
- if (!event.args.empty())
- {
- if (partyHandler != nullptr)
- partyHandler->invite(event.args);
- }
- else
- {
- if (event.tab != nullptr)
- {
- // TRANSLATORS: party invite message
- event.tab->chatLog(_("Please specify a name."),
- ChatMsgType::BY_SERVER);
- }
- }
- return true;
-}
-
-impHandler(guild)
-{
- if ((guildHandler == nullptr) || (localPlayer == nullptr))
- return false;
-
- const std::string args = event.args;
- if (!args.empty())
- {
- const Guild *const guild = localPlayer->getGuild();
- if (guild != nullptr)
- {
-#ifdef TMWA_SUPPORT
- if (guild->getServerGuild())
- guildHandler->invite(args);
- else if (guildManager != nullptr)
- GuildManager::invite(args);
-#else // TMWA_SUPPORT
-
- guildHandler->invite(args);
-#endif // TMWA_SUPPORT
- }
- }
- else
- {
- if (event.tab != nullptr)
- {
- // TRANSLATORS: guild invite message
- event.tab->chatLog(_("Please specify a name."),
- ChatMsgType::BY_SERVER);
- }
- else if (localChatTab != nullptr)
- {
- // TRANSLATORS: guild invite message
- localChatTab->chatLog(_("Please specify a name."),
- ChatMsgType::BY_SERVER);
- }
- }
- return true;
-}
-
-impHandler(me)
-{
- outString(event.tab, textToMe(event.args), event.args);
- return true;
-}
-
-impHandler(toggle)
-{
- if (event.args.empty())
- {
- if ((chatWindow != nullptr) && (event.tab != nullptr))
- {
- event.tab->chatLog(chatWindow->getReturnTogglesChat() ?
- // TRANSLATORS: message from toggle chat command
- _("Return toggles chat.") : _("Message closes chat."),
- ChatMsgType::BY_SERVER);
- }
- return true;
- }
-
- switch (parseBoolean(event.args))
- {
- case 1:
- if (event.tab != nullptr)
- {
- // TRANSLATORS: message from toggle chat command
- event.tab->chatLog(_("Return now toggles chat."),
- ChatMsgType::BY_SERVER);
- }
- if (chatWindow != nullptr)
- chatWindow->setReturnTogglesChat(true);
- return true;
- case 0:
- if (event.tab != nullptr)
- {
- // TRANSLATORS: message from toggle chat command
- event.tab->chatLog(_("Message now closes chat."),
- ChatMsgType::BY_SERVER);
- }
- if (chatWindow != nullptr)
- chatWindow->setReturnTogglesChat(false);
- return true;
- case -1:
- if (event.tab != nullptr)
- {
- event.tab->chatLog(strprintf(BOOLEAN_OPTIONS, "toggle"),
- ChatMsgType::BY_SERVER);
- }
- return true;
- default:
- return true;
- }
-}
-
-impHandler(kickParty)
-{
- if (!event.args.empty())
- {
- if (partyHandler != nullptr)
- partyHandler->kick(event.args);
- }
- else
- {
- if (event.tab != nullptr)
- {
- // TRANSLATORS: party kick message
- event.tab->chatLog(_("Please specify a name."),
- ChatMsgType::BY_SERVER);
- }
- }
- return true;
-}
-
-impHandler(kickGuild)
-{
- if (!event.args.empty())
- {
- if (localPlayer != nullptr)
- {
- const Guild *const guild = localPlayer->getGuild();
- if (guild != nullptr)
- {
- if (guild->getServerGuild())
- {
- if (guildHandler != nullptr)
- guildHandler->kick(guild->getMember(event.args), "");
- }
-#ifdef TMWA_SUPPORT
- else if (guildManager != nullptr)
- {
- GuildManager::kick(event.args);
- }
-#endif // TMWA_SUPPORT
- }
- }
- }
- else
- {
- if (event.tab != nullptr)
- {
- // TRANSLATORS: party kick message
- event.tab->chatLog(_("Please specify a name."),
- ChatMsgType::BY_SERVER);
- }
- }
- return true;
-}
-
-impHandler(addText)
-{
- if (chatWindow != nullptr)
- chatWindow->addInputText(event.args);
- return true;
-}
-
-impHandler0(clearChat)
-{
- if (chatWindow != nullptr)
- chatWindow->clearTab();
- return true;
-}
-
-impHandler0(chatGeneralTab)
-{
- if (chatWindow != nullptr)
- chatWindow->selectTabByType(ChatTabType::INPUT);
- return true;
-}
-
-impHandler0(chatDebugTab)
-{
- if (chatWindow != nullptr)
- chatWindow->selectTabByType(ChatTabType::DEBUG);
- return true;
-}
-
-impHandler0(chatBattleTab)
-{
- if (chatWindow != nullptr)
- chatWindow->selectTabByType(ChatTabType::BATTLE);
- return true;
-}
-
-impHandler0(chatTradeTab)
-{
- if (chatWindow != nullptr)
- chatWindow->selectTabByType(ChatTabType::TRADE);
- return true;
-}
-
-impHandler0(chatLangTab)
-{
- if (chatWindow != nullptr)
- chatWindow->selectTabByType(ChatTabType::LANG);
- return true;
-}
-
-impHandler0(chatGmTab)
-{
- if (chatWindow != nullptr)
- chatWindow->selectTabByType(ChatTabType::GM);
- return true;
-}
-
-impHandler0(chatPartyTab)
-{
- if (chatWindow != nullptr)
- chatWindow->selectTabByType(ChatTabType::PARTY);
- return true;
-}
-
-impHandler0(chatGuildTab)
-{
- if (chatWindow != nullptr)
- chatWindow->selectTabByType(ChatTabType::GUILD);
- return true;
-}
-
-impHandler(hat)
-{
- if ((localPlayer == nullptr) || (charServerHandler == nullptr))
- return false;
-
- const int sprite = localPlayer->getSpriteID(
- charServerHandler->hatSprite());
- std::string str;
- if (sprite == 0)
- {
- // TRANSLATORS: equipped hat chat message
- str = strprintf(_("no hat equipped."));
- }
- else
- {
- const ItemInfo &info = ItemDB::get(sprite);
- // TRANSLATORS: equipped hat chat message
- str = strprintf(_("equipped hat %s."),
- info.getName().c_str());
- }
- outString(event.tab, str, str);
- return true;
-}
-
-impHandler(chatClipboard)
-{
- int x = 0;
- int y = 0;
-
- if ((chatWindow != nullptr) && parse2Int(event.args, x, y))
- {
- chatWindow->copyToClipboard(x, y);
- return true;
- }
- return false;
-}
-
-impHandler(guildNotice)
-{
- if (localPlayer == nullptr)
- return false;
- const std::string args = event.args;
- if (args.empty())
- {
- // TRANSLATORS: dialog header
- inputActionReplayListener.openDialog(_("Guild notice"),
- "",
- InputAction::GUILD_NOTICE);
- return true;
- }
-
- std::string str2;
- if (args.size() > 60)
- str2 = args.substr(60);
- const Guild *const guild = localPlayer->getGuild();
- if (guild != nullptr)
- {
- guildHandler->changeNotice(guild->getId(),
- args.substr(0, 60),
- str2);
- }
- return true;
-}
-
-impHandler(translate)
-{
- if (reverseDictionary == nullptr ||
- localPlayer == nullptr ||
- event.args.empty())
- {
- return false;
- }
-
- ChatTab *const tab = event.tab;
- if (tab == nullptr)
- return false;
-
- std::string srcStr = event.args;
- std::string enStr;
- toLower(srcStr);
- if (localPlayer->getLanguageId() > 0)
- {
- if (reverseDictionary->haveStr(srcStr))
- enStr = reverseDictionary->getStr(srcStr);
- else if (dictionary->haveStr(srcStr))
- enStr = srcStr;
- }
- else
- {
- if (dictionary->haveStr(srcStr))
- enStr = srcStr;
- }
-
- if (enStr.empty())
- {
- tab->chatLog(
- // TRANSLATORS: translation error message
- strprintf(_("No translation found for string: %s"),
- srcStr.c_str()),
- ChatMsgType::BY_SERVER);
- return true;
- }
-
- tab->chatInput(enStr);
- return true;
-}
-
-impHandler(sendGuiKey)
-{
- if (guiInput == nullptr)
- return false;
-
- const std::string args = event.args;
- if (args.empty())
- return false;
- StringVect pars;
- if (!splitParameters(pars, args, " ,", '\"'))
- return false;
- const int sz = CAST_S32(pars.size());
- if (sz < 1)
- return false;
-
- int keyValue = atoi(pars[0].c_str());
- if (keyValue == 0 &&
- pars[0].size() == 1)
- {
- keyValue = CAST_S32(pars[0][0]);
- }
- if (sz == 2)
- {
- const InputActionT actionId = inputManager.getActionByConfigField(
- pars[1]);
- guiInput->simulateKey(keyValue, actionId);
- }
- else
- {
- guiInput->simulateKey(keyValue, InputAction::NO_VALUE);
- }
- return true;
-}
-
-impHandler(sendMouseKey)
-{
- if (guiInput == nullptr)
- return false;
- const std::string args = event.args;
- if (args.empty())
- return false;
- StringVect pars;
- if (!splitParameters(pars, args, " ,", '\"'))
- return false;
- const int sz = CAST_S32(pars.size());
- if (sz != 3)
- return false;
-
- const int x = atoi(pars[0].c_str());
- const int y = atoi(pars[1].c_str());
- const int key1 = CAST_S32(MouseButton::LEFT);
- const int key2 = CAST_S32(MouseButton::MIDDLE);
- const int key = atoi(pars[2].c_str());
- if (key < key1 || key > key2)
- return false;
- guiInput->simulateMouseClick(x,
- y,
- static_cast<MouseButtonT>(key));
- return true;
-}
-
-impHandler(sendChars)
-{
- if (guiInput == nullptr)
- return false;
-
- const std::string args = event.args;
- if (args.empty())
- return false;
-
- const size_t sz = args.size();
- for (size_t f = 0; f < sz; f ++)
- {
- guiInput->simulateKey(CAST_S32(args[f]),
- InputAction::NO_VALUE);
- }
-
- return true;
-}
-
-} // namespace Actions
diff --git a/src/progs/manaplus/actions/commands.cpp b/src/progs/manaplus/actions/commands.cpp
deleted file mode 100644
index f2d49b13b..000000000
--- a/src/progs/manaplus/actions/commands.cpp
+++ /dev/null
@@ -1,2156 +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 "actions/commands.h"
-
-#include "actormanager.h"
-#include "configuration.h"
-#include "game.h"
-#include "party.h"
-
-#include "actions/actiondef.h"
-
-#include "being/flooritem.h"
-#include "being/localplayer.h"
-#include "being/playerrelations.h"
-#include "being/homunculusinfo.h"
-#include "being/playerinfo.h"
-
-#include "const/resources/skill.h"
-
-#include "gui/viewport.h"
-
-#include "gui/popups/popupmenu.h"
-
-#include "gui/shortcut/emoteshortcut.h"
-#include "gui/shortcut/itemshortcut.h"
-
-#include "gui/windows/mailwindow.h"
-
-#include "gui/windows/chatwindow.h"
-#include "gui/windows/inventorywindow.h"
-#include "gui/windows/npcdialog.h"
-#include "gui/windows/outfitwindow.h"
-#include "gui/windows/shortcutwindow.h"
-#include "gui/windows/skilldialog.h"
-#include "gui/windows/socialwindow.h"
-
-#include "gui/widgets/tabs/chat/whispertab.h"
-
-#include "input/inputactionoperators.h"
-
-#include "listeners/inputactionreplaylistener.h"
-
-#include "net/adminhandler.h"
-#include "net/chathandler.h"
-#include "net/guildhandler.h"
-#include "net/familyhandler.h"
-#include "net/homunculushandler.h"
-#include "net/mail2handler.h"
-#include "net/mailhandler.h"
-#include "net/net.h"
-#include "net/npchandler.h"
-#include "net/partyhandler.h"
-#include "net/serverfeatures.h"
-
-#include "resources/chatobject.h"
-
-#include "resources/db/itemdb.h"
-
-#include "resources/map/map.h"
-
-#include "resources/skill/skillinfo.h"
-
-#include "utils/booleanoptions.h"
-#include "utils/chatutils.h"
-#include "utils/copynpaste.h"
-#include "utils/gmfunctions.h"
-#include "utils/parameters.h"
-#include "utils/process.h"
-
-#include "debug.h"
-
-namespace Actions
-{
-
-static std::string getNick(const InputEvent &event)
-{
- std::string args = event.args;
- if (args.empty())
- {
- if (event.tab == nullptr ||
- event.tab->getType() != ChatTabType::WHISPER)
- {
- return std::string();
- }
-
- WhisperTab *const whisper = static_cast<WhisperTab *>(event.tab);
- if (whisper->getNick().empty())
- {
- // TRANSLATORS: change relation
- event.tab->chatLog(_("Please specify a name."),
- ChatMsgType::BY_SERVER);
- return std::string();
- }
- args = whisper->getNick();
- }
- return args;
-}
-
-static void reportRelation(const InputEvent &event,
- const RelationT &rel,
- const std::string &str1,
- const std::string &str2)
-{
- if (event.tab != nullptr)
- {
- if (playerRelations.getRelation(event.args) == rel)
- {
- // TRANSLATORS: unignore command
- event.tab->chatLog(str1, ChatMsgType::BY_SERVER);
- }
- else
- {
- // TRANSLATORS: unignore command
- event.tab->chatLog(str2, ChatMsgType::BY_SERVER);
- }
- }
-}
-
-static void changeRelation(const InputEvent &event,
- const RelationT relation,
- const std::string &relationText)
-{
- std::string args = getNick(event);
- if (args.empty())
- return;
-
- if (playerRelations.getRelation(args) == relation)
- {
- if (event.tab != nullptr)
- {
- // TRANSLATORS: change relation
- event.tab->chatLog(strprintf(_("Player already %s!"),
- relationText.c_str()), ChatMsgType::BY_SERVER);
- return;
- }
- }
- else
- {
- playerRelations.setRelation(args, relation);
- }
-
- reportRelation(event,
- relation,
- // TRANSLATORS: change relation
- strprintf(_("Player successfully %s!"), relationText.c_str()),
- // TRANSLATORS: change relation
- strprintf(_("Player could not be %s!"), relationText.c_str()));
-}
-
-impHandler(chatAnnounce)
-{
- if (adminHandler != nullptr)
- {
- adminHandler->announce(event.args);
- return true;
- }
- return false;
-}
-
-impHandler(chatIgnore)
-{
- changeRelation(event, Relation::IGNORED, "ignored");
- return true;
-}
-
-impHandler(chatUnignore)
-{
- std::string args = getNick(event);
- if (args.empty())
- return false;
-
- const RelationT rel = playerRelations.getRelation(args);
- if (rel != Relation::NEUTRAL && rel != Relation::FRIEND)
- {
- playerRelations.setRelation(args, Relation::NEUTRAL);
- }
- else
- {
- if (event.tab != nullptr)
- {
- // TRANSLATORS: unignore command
- event.tab->chatLog(_("Player wasn't ignored!"),
- ChatMsgType::BY_SERVER);
- }
- return true;
- }
-
- reportRelation(event,
- Relation::NEUTRAL,
- // TRANSLATORS: unignore command
- _("Player no longer ignored!"),
- // TRANSLATORS: unignore command
- _("Player could not be unignored!"));
- return true;
-}
-
-impHandler(chatErase)
-{
- std::string args = getNick(event);
- if (args.empty())
- return false;
-
- if (playerRelations.getRelation(args) == Relation::ERASED)
- {
- if (event.tab != nullptr)
- {
- // TRANSLATORS: erase command
- event.tab->chatLog(_("Player already erased!"),
- ChatMsgType::BY_SERVER);
- }
- return true;
- }
- playerRelations.setRelation(args, Relation::ERASED);
-
- reportRelation(event,
- Relation::ERASED,
- // TRANSLATORS: erase command
- _("Player no longer erased!"),
- // TRANSLATORS: erase command
- _("Player could not be erased!"));
- return true;
-}
-
-impHandler(chatFriend)
-{
- // TRANSLATORS: adding friend command
- changeRelation(event, Relation::FRIEND, _("friend"));
- return true;
-}
-
-impHandler(chatDisregard)
-{
- // TRANSLATORS: disregard command
- changeRelation(event, Relation::DISREGARDED, _("disregarded"));
- return true;
-}
-
-impHandler(chatNeutral)
-{
- // TRANSLATORS: neutral command
- changeRelation(event, Relation::NEUTRAL, _("neutral"));
- return true;
-}
-
-impHandler(chatBlackList)
-{
- // TRANSLATORS: blacklist command
- changeRelation(event, Relation::BLACKLISTED, _("blacklisted"));
- return true;
-}
-
-impHandler(chatEnemy)
-{
- // TRANSLATORS: enemy command
- changeRelation(event, Relation::ENEMY2, _("enemy"));
- return true;
-}
-
-impHandler(chatNuke)
-{
- if (actorManager == nullptr)
- return false;
-
- const std::string nick = getNick(event);
- Being *const being = actorManager->findBeingByName(
- nick, ActorType::Player);
- if (being == nullptr)
- return true;
-
- actorManager->addBlock(being->getId());
- actorManager->destroy(being);
- return true;
-}
-
-impHandler(chatAdd)
-{
- if (chatWindow == nullptr)
- return false;
-
- if (event.args.empty())
- return true;
-
- STD_VECTOR<int> str;
- splitToIntVector(str, event.args, ',');
- if (str.empty())
- return true;
-
- int id = str[0];
- if (id == 0)
- return true;
-
- if (ItemDB::exists(id))
- {
- const std::string names = ItemDB::getNamesStr(str);
- if (!names.empty())
- chatWindow->addItemText(names);
- return true;
- }
-
- const FloorItem *const floorItem = actorManager->findItem(
- fromInt(id, BeingId));
-
- if (floorItem != nullptr)
- {
- str[0] = floorItem->getItemId();
- const std::string names = ItemDB::getNamesStr(str);
- chatWindow->addItemText(names);
- }
- return true;
-}
-
-impHandler0(present)
-{
- if (chatWindow != nullptr)
- {
- chatWindow->doPresent();
- return true;
- }
- return false;
-}
-
-impHandler0(printAll)
-{
- if (actorManager != nullptr)
- {
- actorManager->printAllToChat();
- return true;
- }
- return false;
-}
-
-impHandler(move)
-{
- int x = 0;
- int y = 0;
-
- if ((localPlayer != nullptr) && parse2Int(event.args, x, y))
- {
- localPlayer->setDestination(x, y);
- return true;
- }
- return false;
-}
-
-impHandler(setTarget)
-{
- if ((actorManager == nullptr) || (localPlayer == nullptr))
- return false;
-
- Being *const target = actorManager->findNearestByName(event.args);
- if (target != nullptr)
- localPlayer->setTarget(target);
- return true;
-}
-
-impHandler(commandOutfit)
-{
- if (outfitWindow != nullptr)
- {
- if (!event.args.empty())
- {
- const std::string op = event.args.substr(0, 1);
- if (op == "n")
- {
- outfitWindow->wearNextOutfit(true);
- }
- else if (op == "p")
- {
- outfitWindow->wearPreviousOutfit(true);
- }
- else
- {
- outfitWindow->wearOutfit(atoi(event.args.c_str()) - 1,
- false, true);
- }
- }
- else
- {
- outfitWindow->wearOutfit(atoi(event.args.c_str()) - 1,
- false, true);
- }
- return true;
- }
- return false;
-}
-
-impHandler(commandEmote)
-{
- LocalPlayer::emote(CAST_U8(atoi(event.args.c_str())));
- return true;
-}
-
-impHandler(awayMessage)
-{
- if (localPlayer != nullptr)
- {
- localPlayer->setAway(event.args);
- return true;
- }
- return false;
-}
-
-impHandler(pseudoAway)
-{
- if (localPlayer != nullptr)
- {
- LocalPlayer::setPseudoAway(event.args);
- localPlayer->updateStatus();
- return true;
- }
- return false;
-}
-
-impHandler(follow)
-{
- if (localPlayer == nullptr)
- return false;
-
- if (!features.getBoolValue("allowFollow"))
- return false;
-
- if (!event.args.empty())
- {
- localPlayer->setFollow(event.args);
- }
- else if (event.tab != nullptr &&
- event.tab->getType() == ChatTabType::WHISPER)
- {
- localPlayer->setFollow(static_cast<WhisperTab*>(event.tab)->getNick());
- }
- else
- {
- const Being *const being = localPlayer->getTarget();
- if (being != nullptr)
- localPlayer->setFollow(being->getName());
- }
- return true;
-}
-
-impHandler(navigate)
-{
- if ((localPlayer == nullptr) ||
- !localPlayer->canMove())
- {
- return false;
- }
-
- int x = 0;
- int y = 0;
-
- if (parse2Int(event.args, x, y))
- localPlayer->navigateTo(x, y);
- else
- localPlayer->navigateClean();
- return true;
-}
-
-impHandler(navigateTo)
-{
- if ((localPlayer == nullptr) ||
- !localPlayer->canMove())
- {
- return false;
- }
-
- const std::string args = event.args;
- if (args.empty())
- return true;
-
- Being *const being = actorManager->findBeingByName(args);
- if (being != nullptr)
- {
- localPlayer->navigateTo(being->getTileX(), being->getTileY());
- }
- else if (localPlayer->isInParty())
- {
- const Party *const party = localPlayer->getParty();
- if (party != nullptr)
- {
- const PartyMember *const m = party->getMember(args);
- const PartyMember *const o = party->getMember(
- localPlayer->getName());
- if (m != nullptr &&
- o != nullptr &&
- m->getMap() == o->getMap())
- {
- localPlayer->navigateTo(m->getX(), m->getY());
- }
- }
- }
- return true;
-}
-
-impHandler(moveCamera)
-{
- int x = 0;
- int y = 0;
-
- if (viewport == nullptr)
- return false;
-
- if (parse2Int(event.args, x, y))
- viewport->moveCameraToPosition(x * mapTileSize, y * mapTileSize);
- return true;
-}
-
-impHandler0(restoreCamera)
-{
- if (viewport == nullptr)
- return false;
-
- viewport->returnCamera();
- return true;
-}
-
-impHandler(imitation)
-{
- if (localPlayer == nullptr)
- return false;
-
- if (!event.args.empty())
- {
- localPlayer->setImitate(event.args);
- }
- else if (event.tab != nullptr &&
- event.tab->getType() == ChatTabType::WHISPER)
- {
- localPlayer->setImitate(static_cast<WhisperTab*>(
- event.tab)->getNick());
- }
- else
- {
- localPlayer->setImitate("");
- }
- return true;
-}
-
-impHandler(sendMail)
-{
-#ifdef TMWA_SUPPORT
- const ServerTypeT type = Net::getNetworkType();
- if (type == ServerType::EATHENA || type == ServerType::EVOL2)
-#endif // TMWA_SUPPORT
- {
- std::string name;
- std::string text;
-
- if (parse2Str(event.args, name, text))
- {
- if (settings.enableNewMailSystem)
- {
- mail2Handler->queueCheckName(MailQueueType::SendMail,
- name,
- // TRANSLATORS: quick mail message caption
- _("Quick message"),
- text,
- 0);
- }
- else
- {
- // TRANSLATORS: quick mail message caption
- mailHandler->send(name, _("Quick message"), text);
- }
- }
- }
-#ifdef TMWA_SUPPORT
- else if (serverConfig.getBoolValue("enableManaMarketBot"))
- {
- chatHandler->privateMessage("ManaMarket", "!mail " + event.args);
- return true;
- }
-#endif // TMWA_SUPPORT
-
- return false;
-}
-
-impHandler(info)
-{
- if (event.tab == nullptr ||
- localPlayer == nullptr ||
- Net::getNetworkType() == ServerType::TMWATHENA)
- {
- return false;
- }
-
- if (guildHandler != nullptr &&
- event.tab->getType() == ChatTabType::GUILD)
- {
- const Guild *const guild = localPlayer->getGuild();
- if (guild != nullptr)
- guildHandler->info();
- }
- return true;
-}
-
-impHandler(wait)
-{
- if (localPlayer != nullptr)
- {
- localPlayer->waitFor(event.args);
- return true;
- }
- return false;
-}
-
-impHandler(addPriorityAttack)
-{
- if ((actorManager == nullptr) ||
- actorManager->isInPriorityAttackList(event.args))
- {
- return false;
- }
-
- actorManager->removeAttackMob(event.args);
- actorManager->addPriorityAttackMob(event.args);
-
- if (socialWindow != nullptr)
- socialWindow->updateAttackFilter();
- return true;
-}
-
-impHandler(addAttack)
-{
- if (actorManager == nullptr)
- return false;
-
- actorManager->removeAttackMob(event.args);
- actorManager->addAttackMob(event.args);
-
- if (socialWindow != nullptr)
- socialWindow->updateAttackFilter();
- return true;
-}
-
-impHandler(removeAttack)
-{
- if (actorManager == nullptr)
- return false;
-
- if (event.args.empty())
- {
- if (actorManager->isInAttackList(event.args))
- {
- actorManager->removeAttackMob(event.args);
- actorManager->addIgnoreAttackMob(event.args);
- }
- else
- {
- actorManager->removeAttackMob(event.args);
- actorManager->addAttackMob(event.args);
- }
- }
- else
- {
- actorManager->removeAttackMob(event.args);
- }
-
-
- if (socialWindow != nullptr)
- socialWindow->updateAttackFilter();
- return true;
-}
-
-impHandler(addIgnoreAttack)
-{
- if (actorManager == nullptr)
- return false;
-
- actorManager->removeAttackMob(event.args);
- actorManager->addIgnoreAttackMob(event.args);
-
- if (socialWindow != nullptr)
- socialWindow->updateAttackFilter();
- return true;
-}
-
-impHandler(setDrop)
-{
- GameModifiers::setQuickDropCounter(atoi(event.args.c_str()));
- return true;
-}
-
-impHandler(url)
-{
- if (event.tab != nullptr)
- {
- std::string url1 = event.args;
- if (!strStartWith(url1, "http") && !strStartWith(url1, "?"))
- url1 = "http://" + url1;
- std::string str(strprintf("[@@%s |%s@@]",
- url1.c_str(), event.args.c_str()));
- outStringNormal(event.tab, str, str);
- return true;
- }
- return false;
-}
-
-impHandler(openUrl)
-{
- std::string url = event.args;
- if (!strStartWith(url, "http"))
- url = "http://" + url;
- openBrowser(url);
- return true;
-}
-
-impHandler(execute)
-{
- const size_t idx = event.args.find(' ');
- std::string name;
- std::string params;
- if (idx == std::string::npos)
- {
- name = event.args;
- }
- else
- {
- name = event.args.substr(0, idx);
- params = event.args.substr(idx + 1);
- }
- execFile(name, name, params, "");
- return true;
-}
-
-impHandler(enableHighlight)
-{
- if (event.tab != nullptr)
- {
- event.tab->setAllowHighlight(true);
- if (chatWindow != nullptr)
- {
- chatWindow->saveState();
- return true;
- }
- }
- return false;
-}
-
-impHandler(disableHighlight)
-{
- if (event.tab != nullptr)
- {
- event.tab->setAllowHighlight(false);
- if (chatWindow != nullptr)
- {
- chatWindow->saveState();
- return true;
- }
- }
- return false;
-}
-
-impHandler(dontRemoveName)
-{
- if (event.tab != nullptr)
- {
- event.tab->setRemoveNames(false);
- if (chatWindow != nullptr)
- {
- chatWindow->saveState();
- return true;
- }
- }
- return false;
-}
-
-impHandler(removeName)
-{
- if (event.tab != nullptr)
- {
- event.tab->setRemoveNames(true);
- if (chatWindow != nullptr)
- {
- chatWindow->saveState();
- return true;
- }
- }
- return false;
-}
-
-impHandler(disableAway)
-{
- if (event.tab != nullptr)
- {
- event.tab->setNoAway(true);
- if (chatWindow != nullptr)
- {
- chatWindow->saveState();
- return true;
- }
- }
- return false;
-}
-
-impHandler(enableAway)
-{
- if (event.tab != nullptr)
- {
- event.tab->setNoAway(false);
- if (chatWindow != nullptr)
- {
- chatWindow->saveState();
- return true;
- }
- }
- return false;
-}
-
-impHandler(testParticle)
-{
- if (localPlayer != nullptr)
- {
- localPlayer->setTestParticle(event.args);
- return true;
- }
- return false;
-}
-
-impHandler(talkRaw)
-{
- if (chatHandler != nullptr)
- {
- chatHandler->talkRaw(event.args);
- return true;
- }
- return false;
-}
-
-impHandler(gm)
-{
- if (chatHandler != nullptr)
- {
- Gm::runCommand("wgm", event.args);
- return true;
- }
- return false;
-}
-
-impHandler(hack)
-{
- if (chatHandler != nullptr)
- {
- chatHandler->sendRaw(event.args);
- return true;
- }
- return false;
-}
-
-impHandler(debugSpawn)
-{
- if (localPlayer == nullptr)
- return false;
- int cnt = atoi(event.args.c_str());
- if (cnt < 1)
- cnt = 1;
- const int half = cnt / 2;
- const Map *const map = localPlayer->getMap();
- int x1 = -half;
- if (x1 < 0)
- x1 = 0;
- int y1 = x1;
- int x2 = cnt - half;
- if (x2 > map->getWidth())
- x2 = map->getWidth();
- int y2 = x2;
-
- for (int x = x1; x < x2; x ++)
- {
- for (int y = y1; y < y2; y ++)
- ActorManager::cloneBeing(localPlayer, x, y, cnt);
- }
- return true;
-}
-
-impHandler(serverIgnoreWhisper)
-{
- std::string args = getNick(event);
- if (args.empty())
- return false;
-
- if (chatHandler != nullptr)
- {
- chatHandler->ignore(args);
- return true;
- }
- return false;
-}
-
-impHandler(serverUnIgnoreWhisper)
-{
- std::string args = getNick(event);
- if (args.empty())
- return false;
-
- if (chatHandler != nullptr)
- {
- chatHandler->unIgnore(args);
- return true;
- }
- return false;
-}
-
-impHandler(setHomunculusName)
-{
- const std::string args = event.args;
- if (args.empty())
- {
- const HomunculusInfo *const info = PlayerInfo::getHomunculus();
- if (info != nullptr)
- {
- // TRANSLATORS: dialog header
- inputActionReplayListener.openDialog(_("Rename your homun"),
- info->name,
- InputAction::HOMUNCULUS_SET_NAME);
- }
- return false;
- }
-
- if (homunculusHandler != nullptr)
- {
- homunculusHandler->setName(args);
- return true;
- }
- return false;
-}
-
-impHandler0(fireHomunculus)
-{
- if (homunculusHandler != nullptr)
- {
- homunculusHandler->fire();
- return true;
- }
- return false;
-}
-
-impHandler0(leaveParty)
-{
- if (partyHandler != nullptr)
- {
- partyHandler->leave();
- return true;
- }
- return false;
-}
-
-impHandler0(leaveGuild)
-{
- if ((guildHandler != nullptr) && (localPlayer != nullptr))
- {
- const Guild *const guild = localPlayer->getGuild();
- if (guild != nullptr)
- guildHandler->leave(guild->getId());
- return true;
- }
- return false;
-}
-
-impHandler(warp)
-{
- int x = 0;
- int y = 0;
-
- if ((adminHandler != nullptr) &&
- (Game::instance() != nullptr) &&
- parse2Int(event.args, x, y))
- {
- adminHandler->warp(Game::instance()->getCurrentMapName(),
- x, y);
- return true;
- }
- return false;
-}
-
-impHandler(homunTalk)
-{
- if ((serverFeatures == nullptr) || !serverFeatures->haveTalkPet())
- return false;
-
- std::string args = event.args;
- if (findCutFirst(args, "/me "))
- args = textToMe(args);
- if (homunculusHandler != nullptr)
- {
- homunculusHandler->talk(args);
- return true;
- }
- return false;
-}
-
-impHandler(homunEmote)
-{
- if ((serverFeatures == nullptr) || !serverFeatures->haveTalkPet())
- return false;
-
- if ((homunculusHandler != nullptr) &&
- event.action >= InputAction::HOMUN_EMOTE_1 &&
- event.action <= InputAction::HOMUN_EMOTE_48)
- {
- const int emotion = event.action - InputAction::HOMUN_EMOTE_1;
- if (emoteShortcut != nullptr)
- homunculusHandler->emote(emoteShortcut->getEmote(emotion));
- if (Game::instance() != nullptr)
- Game::instance()->setValidSpeed();
- return true;
- }
-
- return false;
-}
-
-impHandler(commandHomunEmote)
-{
- if ((serverFeatures == nullptr) || !serverFeatures->haveTalkPet())
- return false;
-
- if (homunculusHandler != nullptr)
- {
- homunculusHandler->emote(CAST_U8(
- atoi(event.args.c_str())));
- return true;
- }
- return false;
-}
-
-impHandler(createPublicChatRoom)
-{
- if ((chatHandler == nullptr) || event.args.empty())
- return false;
- chatHandler->createChatRoom(event.args, "", 100, true);
- return true;
-}
-
-impHandler(joinChatRoom)
-{
- if (chatHandler == nullptr)
- return false;
- const std::string args = event.args;
- if (args.empty())
- return false;
- ChatObject *const chat = ChatObject::findByName(args);
- if (chat == nullptr)
- return false;
- chatHandler->joinChat(chat, "");
- return true;
-}
-
-impHandler0(leaveChatRoom)
-{
- if (chatHandler != nullptr)
- {
- chatHandler->leaveChatRoom();
- return true;
- }
- return false;
-}
-
-impHandler(confSet)
-{
- std::string name;
- std::string val;
-
- if (parse2Str(event.args, name, val))
- {
- config.setValue(name, val);
- return true;
- }
- return false;
-}
-
-impHandler(serverConfSet)
-{
- std::string name;
- std::string val;
-
- if (parse2Str(event.args, name, val))
- {
- serverConfig.setValue(name, val);
- return true;
- }
- return false;
-}
-
-impHandler(confGet)
-{
- const std::string args = event.args;
- if (args.empty())
- return false;
-
- // TRANSLATORS: result from command /confget
- const std::string str = strprintf(_("Config value: %s"),
- config.getStringValue(args).c_str());
- outStringNormal(event.tab, str, str);
- return true;
-}
-
-impHandler(serverConfGet)
-{
- const std::string args = event.args;
- if (args.empty())
- return false;
-
- // TRANSLATORS: result from command /serverconfget
- const std::string str = strprintf(_("Server config value: %s"),
- serverConfig.getStringValue(args).c_str());
- outStringNormal(event.tab, str, str);
- return true;
-}
-
-impHandler(slide)
-{
- int x = 0;
- int y = 0;
-
- if ((adminHandler != nullptr) && parse2Int(event.args, x, y))
- {
- adminHandler->slide(x, y);
- return true;
- }
- return false;
-}
-
-impHandler(selectSkillLevel)
-{
- int skill = 0;
- int level = 0;
-
- if ((skillDialog != nullptr) && parse2Int(event.args, skill, level))
- {
- skillDialog->selectSkillLevel(skill, level);
- return true;
- }
- return false;
-}
-
-impHandler(skill)
-{
- StringVect vect;
- splitToStringVector(vect, event.args, ' ');
- const int sz = CAST_S32(vect.size());
- if (sz < 1)
- return true;
- const int skillId = atoi(vect[0].c_str());
- int level = 0;
- std::string text;
- if (sz > 1)
- {
- level = atoi(vect[1].c_str());
- if (sz > 2)
- text = vect[2];
- }
- // +++ add here also cast type and offsets
- if (text.empty())
- {
- SkillDialog::useSkill(skillId,
- AutoTarget_true,
- level,
- false,
- "",
- CastType::Default,
- 0,
- 0);
- }
- else
- {
- SkillDialog::useSkill(skillId,
- AutoTarget_true,
- level,
- true,
- text,
- CastType::Default,
- 0,
- 0);
- }
- return true;
-}
-
-impHandler(craft)
-{
- const std::string args = event.args;
- if (args.empty() || (inventoryWindow == nullptr))
- return false;
-
- inventoryWindow->moveItemToCraft(atoi(args.c_str()));
- return true;
-}
-
-impHandler(npcClipboard)
-{
- if (npcHandler != nullptr)
- {
- int x = 0;
- int y = 0;
-
- NpcDialog *const dialog = npcHandler->getCurrentNpcDialog();
-
- if ((dialog != nullptr) && parse2Int(event.args, x, y))
- {
- dialog->copyToClipboard(x, y);
- return true;
- }
- }
- return false;
-}
-
-impHandler(clipboardCopy)
-{
- const std::string args = event.args;
- if (args.empty())
- return false;
- sendBuffer(args);
- return true;
-}
-
-impHandler(addPickup)
-{
- if (actorManager != nullptr)
- {
- actorManager->removePickupItem(event.args);
- actorManager->addPickupItem(event.args);
- if (socialWindow != nullptr)
- socialWindow->updatePickupFilter();
- return true;
- }
- return false;
-}
-
-impHandler(removePickup)
-{
- if (actorManager != nullptr)
- {
- if (event.args.empty())
- { // default pickup manipulation
- if (actorManager->checkDefaultPickup())
- {
- actorManager->removePickupItem(event.args);
- actorManager->addIgnorePickupItem(event.args);
- }
- else
- {
- actorManager->removePickupItem(event.args);
- actorManager->addPickupItem(event.args);
- }
- }
- else
- { // any other pickups
- actorManager->removePickupItem(event.args);
- }
- if (socialWindow != nullptr)
- socialWindow->updatePickupFilter();
- return true;
- }
- return false;
-}
-
-impHandler(ignorePickup)
-{
- if (actorManager != nullptr)
- {
- actorManager->removePickupItem(event.args);
- actorManager->addIgnorePickupItem(event.args);
- if (socialWindow != nullptr)
- socialWindow->updatePickupFilter();
- return true;
- }
- return false;
-}
-
-impHandler(monsterInfo)
-{
- const std::string args = event.args;
- if (args.empty())
- return false;
- adminHandler->monsterInfo(args);
- return true;
-}
-
-impHandler(itemInfo)
-{
- const std::string args = event.args;
- if (args.empty())
- return false;
- adminHandler->itemInfo(args);
- return true;
-}
-
-impHandler(whoDrops)
-{
- const std::string args = event.args;
- if (args.empty())
- return false;
- adminHandler->whoDrops(args);
- return true;
-}
-
-impHandler(mobSearch)
-{
- const std::string args = event.args;
- if (args.empty())
- return false;
- adminHandler->mobSearch(args);
- return true;
-}
-
-impHandler(mobSpawnSearch)
-{
- const std::string args = event.args;
- if (args.empty())
- return false;
- adminHandler->mobSpawnSearch(args);
- return true;
-}
-
-impHandler(playerGmCommands)
-{
- adminHandler->playerGmCommands(event.args);
- return true;
-}
-
-impHandler(playerCharGmCommands)
-{
- adminHandler->playerCharGmCommands(event.args);
- return true;
-}
-
-impHandler(commandShowLevel)
-{
- adminHandler->showLevel(event.args);
- return true;
-}
-
-impHandler(commandShowStats)
-{
- adminHandler->showStats(event.args);
- return true;
-}
-
-impHandler(commandShowStorage)
-{
- adminHandler->showStorageList(event.args);
- return true;
-}
-
-impHandler(commandShowCart)
-{
- adminHandler->showCartList(event.args);
- return true;
-}
-
-impHandler(commandShowInventory)
-{
- adminHandler->showInventoryList(event.args);
- return true;
-}
-
-impHandler(locatePlayer)
-{
- const std::string args = event.args;
- if (args.empty())
- return false;
- adminHandler->locatePlayer(args);
- return true;
-}
-
-impHandler(commandShowAccountInfo)
-{
- const std::string args = event.args;
- if (args.empty())
- return false;
- adminHandler->showAccountInfo(args);
- return true;
-}
-
-impHandler(commandSpawn)
-{
- const std::string args = event.args;
- if (args.empty())
- return false;
- adminHandler->spawn(args);
- return true;
-}
-
-impHandler(commandSpawnSlave)
-{
- const std::string args = event.args;
- if (args.empty())
- return false;
- adminHandler->spawnSlave(args);
- return true;
-}
-
-impHandler(commandSpawnClone)
-{
- const std::string args = event.args;
- if (args.empty())
- return false;
- adminHandler->spawnClone(args);
- return true;
-}
-
-impHandler(commandSpawnSlaveClone)
-{
- const std::string args = event.args;
- if (args.empty())
- return false;
- adminHandler->spawnSlaveClone(args);
- return true;
-}
-
-impHandler(commandSpawnEvilClone)
-{
- const std::string args = event.args;
- if (args.empty())
- return false;
- adminHandler->spawnEvilClone(args);
- return true;
-}
-
-impHandler(commandSavePosition)
-{
- adminHandler->savePosition(event.args);
- return true;
-}
-
-impHandler(commandLoadPosition)
-{
- adminHandler->loadPosition(event.args);
- return true;
-}
-
-impHandler(commandRandomWarp)
-{
- adminHandler->randomWarp(event.args);
- return true;
-}
-
-impHandler(commandGotoNpc)
-{
- const std::string args = event.args;
- if (args.empty())
- return false;
- adminHandler->gotoNpc(args);
- return true;
-}
-
-impHandler(commandGotoPc)
-{
- const std::string args = event.args;
- if (args.empty())
- return false;
- adminHandler->gotoName(args);
- return true;
-}
-
-impHandler(commandRecallPc)
-{
- const std::string args = event.args;
- if (args.empty())
- return false;
- adminHandler->recallName(args);
- return true;
-}
-
-impHandler(commandIpCheck)
-{
- const std::string args = event.args;
- if (args.empty())
- return false;
- adminHandler->ipcheckName(args);
- return true;
-}
-
-impHandler(commandKiller)
-{
- adminHandler->killer(event.args);
- return true;
-}
-
-impHandler(commandKillable)
-{
- adminHandler->killable(event.args);
- return true;
-}
-
-impHandler(commandHeal)
-{
- adminHandler->heal(event.args);
- return true;
-}
-
-impHandler(commandAlive)
-{
- adminHandler->alive(event.args);
- return true;
-}
-
-impHandler(commandDisguise)
-{
- const std::string args = event.args;
- if (args.empty())
- return false;
- adminHandler->disguise(args);
- return true;
-}
-
-impHandler(commandImmortal)
-{
- adminHandler->immortal(event.args);
- return true;
-}
-
-impHandler(commandHide)
-{
- adminHandler->hide(event.args);
- return true;
-}
-
-impHandler(commandNuke)
-{
- const std::string args = event.args;
- if (args.empty())
- return false;
- adminHandler->nuke(args);
- return true;
-}
-
-impHandler(commandKill)
-{
- adminHandler->kill(event.args);
- return true;
-}
-
-impHandler(commandJail)
-{
- const std::string args = event.args;
- if (args.empty())
- return false;
- adminHandler->jail(args);
- return true;
-}
-
-impHandler(commandUnjail)
-{
- const std::string args = event.args;
- if (args.empty())
- return false;
- adminHandler->unjail(args);
- return true;
-}
-
-impHandler(commandNpcMove)
-{
- const std::string args = event.args;
- if (args.empty())
- return false;
- StringVect pars;
- if (!splitParameters(pars, args, " ,", '\"'))
- return false;
-
- if (pars.size() != 3)
- return false;
-
- adminHandler->npcMove(pars[0],
- atoi(pars[1].c_str()),
- atoi(pars[2].c_str()));
- return true;
-}
-
-impHandler(commandNpcHide)
-{
- const std::string args = event.args;
- if (args.empty())
- return false;
- adminHandler->hideNpc(args);
- return true;
-}
-
-impHandler(commandNpcShow)
-{
- const std::string args = event.args;
- if (args.empty())
- return false;
- adminHandler->showNpc(args);
- return true;
-}
-
-impHandler(commandChangePartyLeader)
-{
- const std::string args = event.args;
- if (args.empty())
- return false;
- adminHandler->changePartyLeader(args);
- return true;
-}
-
-impHandler(commandPartyRecall)
-{
- const std::string args = event.args;
- if (args.empty())
- return false;
- adminHandler->partyRecall(args);
- return true;
-}
-
-impHandler(commandBreakGuild)
-{
- adminHandler->breakGuild(event.args);
- return true;
-}
-
-impHandler(commandGuildRecall)
-{
- const std::string args = event.args;
- if (args.empty())
- return false;
- adminHandler->guildRecall(args);
- return true;
-}
-
-impHandler(mailTo)
-{
- if (mailWindow == nullptr)
- return false;
- const std::string args = event.args;
- if (settings.enableNewMailSystem)
- {
- mail2Handler->queueCheckName(MailQueueType::EditMail,
- args,
- std::string(),
- std::string(),
- 0);
- }
- else
- {
- mailWindow->createMail(args);
- }
- return true;
-}
-
-impHandler(adoptChild)
-{
- const std::string nick = getNick(event);
- Being *const being = actorManager->findBeingByName(
- nick, ActorType::Player);
- if (being == nullptr)
- return true;
- familyHandler->askForChild(being);
- return true;
-}
-
-impHandler(showSkillLevels)
-{
- const std::string args = event.args;
- if (args.empty())
- return false;
- const SkillInfo *restrict const skill = skillDialog->getSkill(
- atoi(args.c_str()));
- if (skill == nullptr)
- return false;
- popupMenu->showSkillLevelPopup(skill);
- return true;
-}
-
-impHandler(showSkillType)
-{
- const std::string args = event.args;
- if (args.empty())
- return false;
- const SkillInfo *restrict const skill = skillDialog->getSkill(
- atoi(args.c_str()));
- if (skill == nullptr)
- return false;
- popupMenu->showSkillTypePopup(skill);
- return true;
-}
-
-impHandler(selectSkillType)
-{
- int skill = 0;
- int type = 0;
-
- if ((skillDialog != nullptr) && parse2Int(event.args, skill, type))
- {
- skillDialog->selectSkillCastType(skill,
- static_cast<CastTypeT>(type));
- return true;
- }
- return false;
-}
-
-impHandler(showSkillOffsetX)
-{
- const std::string args = event.args;
- if (args.empty())
- return false;
- const SkillInfo *restrict const skill = skillDialog->getSkill(
- atoi(args.c_str()));
- if (skill == nullptr)
- return false;
- popupMenu->showSkillOffsetPopup(skill, true);
- return true;
-}
-
-impHandler(showSkillOffsetY)
-{
- const std::string args = event.args;
- if (args.empty())
- return false;
- const SkillInfo *restrict const skill = skillDialog->getSkill(
- atoi(args.c_str()));
- if (skill == nullptr)
- return false;
- popupMenu->showSkillOffsetPopup(skill, false);
- return true;
-}
-
-impHandler(setSkillOffsetX)
-{
- int skill = 0;
- int offset = 0;
-
- if ((skillDialog != nullptr) && parse2Int(event.args, skill, offset))
- {
- skillDialog->setSkillOffsetX(skill, offset);
- return true;
- }
- return false;
-}
-
-impHandler(setSkillOffsetY)
-{
- int skill = 0;
- int offset = 0;
-
- if ((skillDialog != nullptr) && parse2Int(event.args, skill, offset))
- {
- skillDialog->setSkillOffsetY(skill, offset);
- return true;
- }
- return false;
-}
-
-impHandler(partyItemShare)
-{
- if (localPlayer == nullptr)
- return false;
-
- if (localPlayer->isInParty() == false)
- return true;
-
- ChatTab *tab = event.tab;
- if (tab == nullptr)
- tab = localChatTab;
- if (tab == nullptr)
- return true;
-
- const std::string args = event.args;
- if (args.empty())
- {
- switch (partyHandler->getShareItems())
- {
- case PartyShare::YES:
- // TRANSLATORS: chat message
- tab->chatLog(_("Item sharing enabled."),
- ChatMsgType::BY_SERVER);
- return true;
- case PartyShare::NO:
- // TRANSLATORS: chat message
- tab->chatLog(_("Item sharing disabled."),
- ChatMsgType::BY_SERVER);
- return true;
- case PartyShare::NOT_POSSIBLE:
- // TRANSLATORS: chat message
- tab->chatLog(_("Item sharing not possible."),
- ChatMsgType::BY_SERVER);
- return true;
- case PartyShare::UNKNOWN:
- // TRANSLATORS: chat message
- tab->chatLog(_("Item sharing unknown."),
- ChatMsgType::BY_SERVER);
- return true;
- default:
- break;
- }
- }
-
- const signed char opt = parseBoolean(args);
-
- switch (opt)
- {
- case 1:
- partyHandler->setShareItems(
- PartyShare::YES);
- break;
- case 0:
- partyHandler->setShareItems(
- PartyShare::NO);
- break;
- case -1:
- tab->chatLog(strprintf(BOOLEAN_OPTIONS, "item"),
- ChatMsgType::BY_SERVER);
- break;
- default:
- break;
- }
- return true;
-}
-
-impHandler(partyExpShare)
-{
- if (localPlayer == nullptr)
- return false;
-
- if (localPlayer->isInParty() == false)
- return true;
-
- ChatTab *tab = event.tab;
- if (tab == nullptr)
- tab = localChatTab;
- if (tab == nullptr)
- return true;
-
- const std::string args = event.args;
- if (args.empty())
- {
- switch (partyHandler->getShareExperience())
- {
- case PartyShare::YES:
- // TRANSLATORS: chat message
- tab->chatLog(_("Experience sharing enabled."),
- ChatMsgType::BY_SERVER);
- return true;
- case PartyShare::NO:
- // TRANSLATORS: chat message
- tab->chatLog(_("Experience sharing disabled."),
- ChatMsgType::BY_SERVER);
- return true;
- case PartyShare::NOT_POSSIBLE:
- // TRANSLATORS: chat message
- tab->chatLog(_("Experience sharing not possible."),
- ChatMsgType::BY_SERVER);
- return true;
- case PartyShare::UNKNOWN:
- // TRANSLATORS: chat message
- tab->chatLog(_("Experience sharing unknown."),
- ChatMsgType::BY_SERVER);
- return true;
- default:
- break;
- }
- }
-
- const signed char opt = parseBoolean(args);
-
- switch (opt)
- {
- case 1:
- partyHandler->setShareExperience(
- PartyShare::YES);
- break;
- case 0:
- partyHandler->setShareExperience(
- PartyShare::NO);
- break;
- case -1:
- tab->chatLog(strprintf(BOOLEAN_OPTIONS, "exp"),
- ChatMsgType::BY_SERVER);
- break;
- default:
- break;
- }
- return true;
-}
-
-impHandler(partyAutoItemShare)
-{
- if (localPlayer == nullptr)
- return false;
-
- if (localPlayer->isInParty() == false)
- return true;
-
- ChatTab *tab = event.tab;
- if (tab == nullptr)
- tab = localChatTab;
- if (tab == nullptr)
- return true;
-
- const std::string args = event.args;
- if (args.empty())
- {
- switch (partyHandler->getShareAutoItems())
- {
- case PartyShare::YES:
- // TRANSLATORS: chat message
- tab->chatLog(_("Auto item sharing enabled."),
- ChatMsgType::BY_SERVER);
- return true;
- case PartyShare::NO:
- // TRANSLATORS: chat message
- tab->chatLog(_("Auto item sharing disabled."),
- ChatMsgType::BY_SERVER);
- return true;
- case PartyShare::NOT_POSSIBLE:
- // TRANSLATORS: chat message
- tab->chatLog(_("Auto item sharing not possible."),
- ChatMsgType::BY_SERVER);
- return true;
- case PartyShare::UNKNOWN:
- // TRANSLATORS: chat message
- tab->chatLog(_("Auto item sharing unknown."),
- ChatMsgType::BY_SERVER);
- return true;
- default:
- break;
- }
- }
-
- const signed char opt = parseBoolean(args);
-
- switch (opt)
- {
- case 1:
- partyHandler->setShareAutoItems(
- PartyShare::YES);
- break;
- case 0:
- partyHandler->setShareAutoItems(
- PartyShare::NO);
- break;
- case -1:
- tab->chatLog(strprintf(BOOLEAN_OPTIONS, "item"),
- ChatMsgType::BY_SERVER);
- break;
- default:
- break;
- }
- return true;
-}
-
-impHandler0(outfitToChat)
-{
- if ((outfitWindow == nullptr) || (chatWindow == nullptr))
- return false;
-
- const std::string str = outfitWindow->getOutfitString();
- if (!str.empty())
- chatWindow->addInputText(str);
- return true;
-}
-
-impHandler0(outfitClear)
-{
- if (outfitWindow == nullptr)
- return false;
-
- outfitWindow->clearCurrentOutfit();
- return true;
-}
-
-impHandler(moveAttackUp)
-{
- if (actorManager == nullptr)
- return false;
- const std::string args = event.args;
- const int idx = actorManager->getAttackMobIndex(args);
- if (idx > 0)
- {
- std::list<std::string> mobs
- = actorManager->getAttackMobs();
- std::list<std::string>::iterator it = mobs.begin();
- std::list<std::string>::iterator it2 = it;
- while (it != mobs.end())
- {
- if (*it == args)
- {
- -- it2;
- mobs.splice(it2, mobs, it);
- actorManager->setAttackMobs(mobs);
- actorManager->rebuildAttackMobs();
- break;
- }
- ++ it;
- ++ it2;
- }
-
- if (socialWindow != nullptr)
- socialWindow->updateAttackFilter();
- return true;
- }
- return false;
-}
-
-impHandler(moveAttackDown)
-{
- if (actorManager == nullptr)
- return false;
- const std::string args = event.args;
- const int idx = actorManager->getAttackMobIndex(args);
- const int size = actorManager->getAttackMobsSize();
- if (idx + 1 < size)
- {
- std::list<std::string> mobs
- = actorManager->getAttackMobs();
- std::list<std::string>::iterator it = mobs.begin();
- std::list<std::string>::iterator it2 = it;
- while (it != mobs.end())
- {
- if (*it == args)
- {
- ++ it2;
- if (it2 == mobs.end())
- break;
-
- mobs.splice(it, mobs, it2);
- actorManager->setAttackMobs(mobs);
- actorManager->rebuildAttackMobs();
- break;
- }
- ++ it;
- ++ it2;
- }
-
- if (socialWindow != nullptr)
- socialWindow->updateAttackFilter();
- return true;
- }
- return false;
-}
-
-impHandler(movePriorityAttackUp)
-{
- if (actorManager == nullptr)
- return false;
- const std::string args = event.args;
- const int idx = actorManager->
- getPriorityAttackMobIndex(args);
- if (idx > 0)
- {
- std::list<std::string> mobs
- = actorManager->getPriorityAttackMobs();
- std::list<std::string>::iterator it = mobs.begin();
- std::list<std::string>::iterator it2 = it;
- while (it != mobs.end())
- {
- if (*it == args)
- {
- -- it2;
- mobs.splice(it2, mobs, it);
- actorManager->setPriorityAttackMobs(mobs);
- actorManager->rebuildPriorityAttackMobs();
- break;
- }
- ++ it;
- ++ it2;
- }
-
- if (socialWindow != nullptr)
- socialWindow->updateAttackFilter();
- return true;
- }
- return false;
-}
-
-impHandler(movePriorityAttackDown)
-{
- if (actorManager == nullptr)
- return false;
- const std::string args = event.args;
- const int idx = actorManager
- ->getPriorityAttackMobIndex(args);
- const int size = actorManager->getPriorityAttackMobsSize();
- if (idx + 1 < size)
- {
- std::list<std::string> mobs
- = actorManager->getPriorityAttackMobs();
- std::list<std::string>::iterator it = mobs.begin();
- std::list<std::string>::iterator it2 = it;
- while (it != mobs.end())
- {
- if (*it == args)
- {
- ++ it2;
- if (it2 == mobs.end())
- break;
-
- mobs.splice(it, mobs, it2);
- actorManager->setPriorityAttackMobs(mobs);
- actorManager->rebuildPriorityAttackMobs();
- break;
- }
- ++ it;
- ++ it2;
- }
-
- if (socialWindow != nullptr)
- socialWindow->updateAttackFilter();
- return true;
- }
- return false;
-}
-
-impHandler(addSkillShortcut)
-{
- const std::string args = event.args;
- if (args.empty() ||
- itemShortcutWindow == nullptr)
- {
- return false;
- }
- const SkillInfo *restrict const skill = skillDialog->getSkill(
- atoi(args.c_str()));
- if (skill == nullptr)
- return false;
-
- const int num = itemShortcutWindow->getTabIndex();
- if (num < 0 ||
- num >= CAST_S32(SHORTCUT_TABS) ||
- num == CAST_S32(SHORTCUT_AUTO_TAB))
- {
- return false;
- }
-
- ItemShortcut *const selShortcut = itemShortcut[num];
- const size_t index = selShortcut->getFreeIndex();
- if (index == SHORTCUT_ITEMS)
- return true;
-
- selShortcut->setItem(index,
- skill->id + SKILL_MIN_ID,
- fromInt(skill->customSelectedLevel, ItemColor));
- selShortcut->setItemData(index,
- skill->toDataStr());
-
-// popupMenu->showSkillLevelPopup(skill);
- return true;
-}
-
-} // namespace Actions
diff --git a/src/progs/manaplus/actions/move.cpp b/src/progs/manaplus/actions/move.cpp
deleted file mode 100644
index d2be4de7e..000000000
--- a/src/progs/manaplus/actions/move.cpp
+++ /dev/null
@@ -1,280 +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 "actions/move.h"
-
-#include "game.h"
-
-#include "actions/actiondef.h"
-#include "actions/pets.h"
-
-#include "being/crazymoves.h"
-#include "being/localplayer.h"
-
-#include "enums/being/beingdirection.h"
-
-#include "gui/windows/socialwindow.h"
-#include "gui/windows/npcdialog.h"
-#include "gui/windows/outfitwindow.h"
-
-#include "gui/popups/popupmenu.h"
-
-#include "input/inputactionoperators.h"
-
-#include "net/playerhandler.h"
-
-#include "debug.h"
-
-namespace Actions
-{
-
-static bool closeMoveNpcDialog(bool focus)
-{
- NpcDialog *const dialog = NpcDialog::getActive();
- if (dialog != nullptr)
- {
- if (dialog->isCloseState() != 0)
- {
- dialog->closeDialog();
- return true;
- }
- else if (focus)
- {
- dialog->refocus();
- }
- }
- return false;
-}
-
-impHandler(moveUp)
-{
- if (inputManager.isActionActive(InputAction::EMOTE))
- return directUp(event);
- else if (inputManager.isActionActive(InputAction::PET_EMOTE))
- return petDirectUp(event);
- else if (inputManager.isActionActive(InputAction::STOP_ATTACK))
- return petMoveUp(event);
- else if (!localPlayer->canMove())
- return directUp(event);
- if (popupMenu->isPopupVisible())
- {
- popupMenu->moveUp();
- return true;
- }
- return closeMoveNpcDialog(false);
-}
-
-impHandler(moveDown)
-{
- if (inputManager.isActionActive(InputAction::EMOTE))
- return directDown(event);
- else if (inputManager.isActionActive(InputAction::PET_EMOTE))
- return petDirectDown(event);
- else if (inputManager.isActionActive(InputAction::STOP_ATTACK))
- return petMoveDown(event);
- else if (!localPlayer->canMove())
- return directDown(event);
- if (popupMenu->isPopupVisible())
- {
- popupMenu->moveDown();
- return true;
- }
- return closeMoveNpcDialog(false);
-}
-
-impHandler(moveLeft)
-{
- if (outfitWindow != nullptr &&
- inputManager.isActionActive(InputAction::WEAR_OUTFIT))
- {
- outfitWindow->wearPreviousOutfit();
- if (Game::instance() != nullptr)
- Game::instance()->setValidSpeed();
- return true;
- }
- if (inputManager.isActionActive(InputAction::EMOTE))
- return directLeft(event);
- else if (inputManager.isActionActive(InputAction::PET_EMOTE))
- return petDirectLeft(event);
- else if (inputManager.isActionActive(InputAction::STOP_ATTACK))
- return petMoveLeft(event);
- else if (!localPlayer->canMove())
- return directLeft(event);
- return closeMoveNpcDialog(false);
-}
-
-impHandler(moveRight)
-{
- if (outfitWindow != nullptr &&
- inputManager.isActionActive(InputAction::WEAR_OUTFIT))
- {
- outfitWindow->wearNextOutfit();
- if (Game::instance() != nullptr)
- Game::instance()->setValidSpeed();
- return true;
- }
- if (inputManager.isActionActive(InputAction::EMOTE))
- return directRight(event);
- else if (inputManager.isActionActive(InputAction::PET_EMOTE))
- return petDirectRight(event);
- else if (inputManager.isActionActive(InputAction::STOP_ATTACK))
- return petMoveRight(event);
- else if (!localPlayer->canMove())
- return directRight(event);
- return closeMoveNpcDialog(false);
-}
-
-impHandler(moveForward)
-{
- if (inputManager.isActionActive(InputAction::EMOTE))
- return directRight(event);
- return closeMoveNpcDialog(false);
-}
-
-impHandler(moveToPoint)
-{
- const int num = event.action - InputAction::MOVE_TO_POINT_1;
- if ((socialWindow != nullptr) && num >= 0)
- {
- socialWindow->selectPortal(num);
- return true;
- }
-
- return false;
-}
-
-impHandler0(crazyMoves)
-{
- if (localPlayer != nullptr)
- {
- ::crazyMoves->crazyMove();
- return true;
- }
- return false;
-}
-
-impHandler0(moveToTarget)
-{
- if (localPlayer != nullptr &&
- !inputManager.isActionActive(InputAction::TARGET_ATTACK) &&
- !inputManager.isActionActive(InputAction::ATTACK))
- {
- localPlayer->moveToTarget();
- return true;
- }
- return false;
-}
-
-impHandler0(moveToHome)
-{
- if (localPlayer != nullptr &&
- !inputManager.isActionActive(InputAction::TARGET_ATTACK) &&
- !inputManager.isActionActive(InputAction::ATTACK))
- {
- localPlayer->moveToHome();
- if (Game::instance() != nullptr)
- Game::instance()->setValidSpeed();
- return true;
- }
- return false;
-}
-
-impHandler0(directUp)
-{
- if (localPlayer != nullptr)
- {
- if (localPlayer->getDirection() != BeingDirection::UP)
- {
-// if (PacketLimiter::limitPackets(PacketType::PACKET_DIRECTION))
- {
- localPlayer->setDirection(BeingDirection::UP);
- if (playerHandler != nullptr)
- playerHandler->setDirection(BeingDirection::UP);
- }
- }
- return true;
- }
- return false;
-}
-
-impHandler0(directDown)
-{
- if (localPlayer != nullptr)
- {
- if (localPlayer->getDirection() != BeingDirection::DOWN)
- {
-// if (PacketLimiter::limitPackets(PacketType::PACKET_DIRECTION))
- {
- localPlayer->setDirection(BeingDirection::DOWN);
- if (playerHandler != nullptr)
- {
- playerHandler->setDirection(
- BeingDirection::DOWN);
- }
- }
- }
- return true;
- }
- return false;
-}
-
-impHandler0(directLeft)
-{
- if (localPlayer != nullptr)
- {
- if (localPlayer->getDirection() != BeingDirection::LEFT)
- {
-// if (PacketLimiter::limitPackets(PacketType::PACKET_DIRECTION))
- {
- localPlayer->setDirection(BeingDirection::LEFT);
- if (playerHandler != nullptr)
- {
- playerHandler->setDirection(
- BeingDirection::LEFT);
- }
- }
- }
- return true;
- }
- return false;
-}
-
-impHandler0(directRight)
-{
- if (localPlayer != nullptr)
- {
- if (localPlayer->getDirection() != BeingDirection::RIGHT)
- {
-// if (PacketLimiter::limitPackets(PacketType::PACKET_DIRECTION))
- {
- localPlayer->setDirection(BeingDirection::RIGHT);
- if (playerHandler != nullptr)
- {
- playerHandler->setDirection(
- BeingDirection::RIGHT);
- }
- }
- }
- return true;
- }
- return false;
-}
-
-} // namespace Actions
diff --git a/src/progs/manaplus/actions/pets.cpp b/src/progs/manaplus/actions/pets.cpp
deleted file mode 100644
index 25c5f1411..000000000
--- a/src/progs/manaplus/actions/pets.cpp
+++ /dev/null
@@ -1,248 +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 "actions/pets.h"
-
-#include "actormanager.h"
-#include "game.h"
-
-#include "actions/actiondef.h"
-
-#include "being/localplayer.h"
-#include "being/playerinfo.h"
-
-#include "enums/being/beingdirection.h"
-
-#include "const/gui/chat.h"
-
-#include "input/inputactionoperators.h"
-
-#include "listeners/inputactionreplaylistener.h"
-
-#include "gui/shortcut/emoteshortcut.h"
-
-#include "net/chathandler.h"
-#include "net/pethandler.h"
-#include "net/serverfeatures.h"
-
-#include "utils/chatutils.h"
-#include "utils/gettext.h"
-#include "utils/stringutils.h"
-
-#include "debug.h"
-
-namespace Actions
-{
-
-static const Being *getPet()
-{
- const BeingId id = PlayerInfo::getPetBeingId();
- if (id == BeingId_zero)
- return nullptr;
- return actorManager->findBeing(id);
-}
-
-impHandler(commandEmotePet)
-{
- petHandler->emote(CAST_U8(atoi(event.args.c_str())));
- return true;
-}
-
-impHandler(talkPet)
-{
- if (!serverFeatures->haveTalkPet())
- return false;
-
- std::string args = event.args;
- if (findCutFirst(args, "/me "))
- args = textToMe(args);
- chatHandler->talkPet(args, GENERAL_CHANNEL);
- return true;
-}
-
-impHandler(setPetName)
-{
- const std::string args = event.args;
- if (args.empty())
- {
- const Being *const pet = getPet();
- if (pet == nullptr)
- return false;
- // TRANSLATORS: dialog header
- inputActionReplayListener.openDialog(_("Rename your pet"),
- pet->getName(),
- InputAction::PET_SET_NAME);
- return false;
- }
-
- petHandler->setName(args);
- return true;
-}
-
-impHandler(petEmote)
-{
- if (!serverFeatures->haveTalkPet())
- return false;
-
- if (event.action >= InputAction::PET_EMOTE_1
- && event.action <= InputAction::PET_EMOTE_48)
- {
- const int emotion = event.action - InputAction::PET_EMOTE_1;
- if (emoteShortcut != nullptr)
- petHandler->emote(emoteShortcut->getEmote(emotion));
- if (Game::instance() != nullptr)
- Game::instance()->setValidSpeed();
- return true;
- }
-
- return false;
-}
-
-impHandler(catchPet)
-{
- if ((localPlayer == nullptr) || (actorManager == nullptr))
- return false;
-
- Being *target = nullptr;
- const std::string args = event.args;
- if (!args.empty())
- {
- if (args[0] == ':')
- {
- target = actorManager->findBeing(fromInt(atoi(
- args.substr(1).c_str()), BeingId));
- }
- else
- {
- target = actorManager->findNearestByName(args);
- }
- }
-
- if (target == nullptr)
- target = localPlayer->getTarget();
- else
- localPlayer->setTarget(target);
- if (target != nullptr)
- petHandler->catchPet(target);
- return true;
-}
-
-impHandler0(petMoveUp)
-{
- const Being *const pet = getPet();
- if (pet == nullptr)
- return false;
- petHandler->move(pet->getTileX(), pet->getTileY() - 1);
- return true;
-}
-
-impHandler0(petMoveDown)
-{
- const Being *const pet = getPet();
- if (pet == nullptr)
- return false;
- petHandler->move(pet->getTileX(), pet->getTileY() + 1);
- return true;
-}
-
-impHandler0(petMoveLeft)
-{
- const Being *const pet = getPet();
- if (pet == nullptr)
- return false;
- petHandler->move(pet->getTileX() - 1, pet->getTileY());
- return true;
-}
-
-impHandler0(petMoveRight)
-{
- const Being *const pet = getPet();
- if (pet == nullptr)
- return false;
- petHandler->move(pet->getTileX() + 1, pet->getTileY());
- return true;
-}
-
-impHandler0(petDirectUp)
-{
- petHandler->setDirection(BeingDirection::UP);
- return true;
-}
-
-impHandler0(petDirectDown)
-{
- petHandler->setDirection(BeingDirection::DOWN);
- return true;
-}
-
-impHandler0(petDirectLeft)
-{
- petHandler->setDirection(BeingDirection::LEFT);
- return true;
-}
-
-impHandler0(petDirectRight)
-{
- petHandler->setDirection(BeingDirection::RIGHT);
- return true;
-}
-
-impHandler(petMove)
-{
- int x = 0;
- int y = 0;
-
- if (parse2Int(event.args, x, y))
- {
- petHandler->move(x, y);
- return true;
- }
- return false;
-}
-
-impHandler0(petFeed)
-{
- if (petHandler != nullptr)
- petHandler->feed();
- return true;
-}
-
-impHandler0(petDropLoot)
-{
- if (petHandler != nullptr)
- petHandler->dropLoot();
- return true;
-}
-
-impHandler0(petReturnToEgg)
-{
- if (petHandler != nullptr)
- petHandler->returnToEgg();
- return true;
-}
-
-impHandler0(petUnequip)
-{
- if (petHandler != nullptr)
- petHandler->unequip();
- return true;
-}
-
-} // namespace Actions
diff --git a/src/progs/manaplus/actions/statusbar.cpp b/src/progs/manaplus/actions/statusbar.cpp
deleted file mode 100644
index 0d5ba68cd..000000000
--- a/src/progs/manaplus/actions/statusbar.cpp
+++ /dev/null
@@ -1,200 +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 "actions/statusbar.h"
-
-#include "game.h"
-#include "soundmanager.h"
-
-#include "actions/actiondef.h"
-
-#include "being/localplayer.h"
-#include "being/playerrelation.h"
-#include "being/playerrelations.h"
-
-#include "gui/viewport.h"
-
-#include "gui/widgets/tabs/chat/chattab.h"
-
-#include "listeners/updatestatuslistener.h"
-
-#include "resources/map/map.h"
-
-#include "utils/gettext.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#ifdef ANDROID
-#ifndef USE_SDL2
-#include <SDL_screenkeyboard.h>
-#endif // USE_SDL2
-#endif // ANDROID
-PRAGMA48(GCC diagnostic pop)
-
-#include "debug.h"
-
-namespace Actions
-{
-
-impHandler0(switchQuickDrop)
-{
- callYellowBarCond(changeQuickDropCounter)
-}
-
-impHandler0(changeCrazyMove)
-{
- callYellowBar(changeCrazyMoveType);
-}
-
-impHandler0(changePickupType)
-{
- callYellowBar(changePickUpType);
-}
-
-impHandler0(changeMoveType)
-{
- callYellowBar(changeMoveType);
-}
-
-impHandler0(changeAttackWeaponType)
-{
- callYellowBar(changeAttackWeaponType);
-}
-
-impHandler0(changeAttackType)
-{
- callYellowBar(changeAttackType);
-}
-
-impHandler0(changeTargetingType)
-{
- callYellowBar(changeTargetingType);
-}
-
-impHandler0(changeFollowMode)
-{
- callYellowBar(changeFollowMode);
-}
-
-impHandler0(changeImitationMode)
-{
- callYellowBar(changeImitationMode);
-}
-
-impHandler0(changeMagicAttackType)
-{
- callYellowBar(changeMagicAttackType);
-}
-
-impHandler0(changePvpMode)
-{
- callYellowBar(changePvpAttackType);
-}
-
-impHandler0(changeMoveToTarget)
-{
- callYellowBar(changeMoveToTargetType);
-}
-
-impHandler0(changeGameModifier)
-{
- if (localPlayer != nullptr)
- {
- GameModifiers::changeGameModifiers(false);
- return true;
- }
- return false;
-}
-
-impHandler0(changeAudio)
-{
- soundManager.changeAudio();
- if (localPlayer != nullptr)
- localPlayer->updateMusic();
- return true;
-}
-
-impHandler0(away)
-{
- GameModifiers::changeAwayMode(true);
- if (localPlayer != nullptr)
- {
- localPlayer->updateStatus();
- if (Game::instance() != nullptr)
- Game::instance()->setValidSpeed();
- return true;
- }
- return false;
-}
-
-impHandler0(camera)
-{
- if (viewport != nullptr)
- {
- viewport->toggleCameraMode();
- if (Game::instance() != nullptr)
- Game::instance()->setValidSpeed();
- return true;
- }
- return false;
-}
-
-impHandler0(changeMapMode)
-{
- if (viewport != nullptr)
- viewport->toggleMapDrawType();
- UpdateStatusListener::distributeEvent();
- if (Game::instance() != nullptr)
- {
- if (Map *const map = Game::instance()->getCurrentMap())
- map->redrawMap();
- }
- return true;
-}
-
-impHandler0(changeTrade)
-{
- unsigned int deflt = playerRelations.getDefault();
- if ((deflt & PlayerRelation::TRADE) != 0u)
- {
- if (localChatTab != nullptr)
- {
- // TRANSLATORS: disable trades message
- localChatTab->chatLog(_("Ignoring incoming trade requests"),
- ChatMsgType::BY_SERVER);
- }
- deflt &= ~PlayerRelation::TRADE;
- }
- else
- {
- if (localChatTab != nullptr)
- {
- // TRANSLATORS: enable trades message
- localChatTab->chatLog(_("Accepting incoming trade requests"),
- ChatMsgType::BY_SERVER);
- }
- deflt |= PlayerRelation::TRADE;
- }
-
- playerRelations.setDefault(deflt);
- return true;
-}
-
-} // namespace Actions
diff --git a/src/progs/manaplus/actions/tabs.cpp b/src/progs/manaplus/actions/tabs.cpp
deleted file mode 100644
index 99d964b40..000000000
--- a/src/progs/manaplus/actions/tabs.cpp
+++ /dev/null
@@ -1,106 +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 "actions/tabs.h"
-
-#include "actions/actiondef.h"
-
-#include "gui/windows/inventorywindow.h"
-#include "gui/windows/socialwindow.h"
-#include "gui/windows/shortcutwindow.h"
-
-#include "debug.h"
-
-namespace Actions
-{
-
-impHandler0(prevSocialTab)
-{
- if (socialWindow != nullptr)
- {
- socialWindow->prevTab();
- return true;
- }
- return false;
-}
-
-impHandler0(nextSocialTab)
-{
- if (socialWindow != nullptr)
- {
- socialWindow->nextTab();
- return true;
- }
- return false;
-}
-
-impHandler0(nextShortcutsTab)
-{
- if (itemShortcutWindow != nullptr)
- {
- itemShortcutWindow->nextTab();
- return true;
- }
- return false;
-}
-
-impHandler0(prevShortcutsTab)
-{
- if (itemShortcutWindow != nullptr)
- {
- itemShortcutWindow->prevTab();
- return true;
- }
- return false;
-}
-
-impHandler0(nextCommandsTab)
-{
- if (spellShortcutWindow != nullptr)
- {
- spellShortcutWindow->nextTab();
- return true;
- }
- return false;
-}
-
-impHandler0(prevCommandsTab)
-{
- if (spellShortcutWindow != nullptr)
- {
- spellShortcutWindow->prevTab();
- return true;
- }
- return false;
-}
-
-impHandler0(nextInvTab)
-{
- InventoryWindow::nextTab();
- return true;
-}
-
-impHandler0(prevInvTab)
-{
- InventoryWindow::prevTab();
- return true;
-}
-
-} // namespace Actions
diff --git a/src/progs/manaplus/actions/target.cpp b/src/progs/manaplus/actions/target.cpp
deleted file mode 100644
index a72cbe502..000000000
--- a/src/progs/manaplus/actions/target.cpp
+++ /dev/null
@@ -1,90 +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 "actions/target.h"
-
-#include "actions/actiondef.h"
-
-#include "being/localplayer.h"
-
-#include "gui/popups/popupmenu.h"
-
-#include "debug.h"
-
-namespace Actions
-{
-
-static bool setTarget(const ActorTypeT type, const AllowSort allowSort)
-{
- if (localPlayer != nullptr)
- return localPlayer->setNewTarget(type, allowSort) != nullptr;
- return false;
-}
-
-impHandler0(targetPlayer)
-{
- return setTarget(ActorType::Player, AllowSort_true);
-}
-
-impHandler0(targetMonster)
-{
- return setTarget(ActorType::Monster, AllowSort_true);
-}
-
-impHandler0(targetClosestMonster)
-{
- return setTarget(ActorType::Monster, AllowSort_false);
-}
-
-impHandler0(targetNPC)
-{
- return setTarget(ActorType::Npc, AllowSort_true);
-}
-
-impHandler0(targetMercenary)
-{
- return setTarget(ActorType::Mercenary, AllowSort_true);
-}
-
-impHandler0(targetSkillUnit)
-{
- return setTarget(ActorType::SkillUnit, AllowSort_true);
-}
-
-impHandler0(targetPet)
-{
- return setTarget(ActorType::Pet, AllowSort_true);
-}
-
-impHandler0(contextMenu)
-{
- if (localPlayer == nullptr)
- return false;
- const Being *const target = localPlayer->getTarget();
- if (target == nullptr)
- return true;
-
- popupMenu->showPopup(target->getPixelX(),
- target->getPixelY(),
- target);
- return true;
-}
-
-} // namespace Actions
diff --git a/src/progs/manaplus/actions/windows.cpp b/src/progs/manaplus/actions/windows.cpp
deleted file mode 100644
index 7c9b57d0a..000000000
--- a/src/progs/manaplus/actions/windows.cpp
+++ /dev/null
@@ -1,383 +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 "actions/windows.h"
-
-#include "actormanager.h"
-#include "client.h"
-
-#include "actions/actiondef.h"
-
-#include "being/localplayer.h"
-
-#include "gui/dialogsmanager.h"
-
-#include "gui/windows/bankwindow.h"
-#include "gui/windows/skilldialog.h"
-#include "gui/windows/socialwindow.h"
-#include "gui/windows/statuswindow.h"
-#include "gui/windows/questswindow.h"
-#include "gui/windows/whoisonline.h"
-#include "gui/windows/chatwindow.h"
-#include "gui/windows/debugwindow.h"
-#include "gui/windows/didyouknowwindow.h"
-#include "gui/windows/equipmentwindow.h"
-#include "gui/windows/helpwindow.h"
-#include "gui/windows/inventorywindow.h"
-#include "gui/windows/killstats.h"
-#include "gui/windows/mailwindow.h"
-#include "gui/windows/minimap.h"
-#include "gui/windows/outfitwindow.h"
-#include "gui/windows/setupwindow.h"
-#include "gui/windows/serverinfowindow.h"
-#include "gui/windows/shopwindow.h"
-#include "gui/windows/shortcutwindow.h"
-#include "gui/windows/updaterwindow.h"
-
-#include "gui/widgets/createwidget.h"
-
-#include "gui/widgets/tabs/chat/chattab.h"
-
-#include "utils/gettext.h"
-
-#include "net/net.h"
-
-#include "debug.h"
-
-namespace Actions
-{
-
-impHandler0(setupWindowShow)
-{
- if (setupWindow != nullptr)
- {
- if (setupWindow->isWindowVisible())
- {
- setupWindow->doCancel();
- }
- else
- {
- setupWindow->setVisible(Visible_true);
- setupWindow->requestMoveToTop();
- }
- return true;
- }
- return false;
-}
-
-impHandler0(hideWindows)
-{
- if (setupWindow != nullptr)
- setupWindow->hideWindows();
- return true;
-}
-
-static bool showHelpPage(const std::string &page, const bool showHide)
-{
- if (helpWindow != nullptr)
- {
- if (showHide && helpWindow->isWindowVisible())
- {
- helpWindow->setVisible(Visible_false);
- }
- else
- {
- helpWindow->loadHelp(page);
- helpWindow->requestMoveToTop();
- }
- return true;
- }
- return false;
-}
-
-impHandler(helpWindowShow)
-{
- if ((chatWindow == nullptr) || !chatWindow->isInputFocused())
- return showHelpPage("index", true);
- if (event.tab == nullptr)
- return showHelpPage("chatcommands", true);
- switch (event.tab->getType())
- {
- case ChatTabType::PARTY:
- return showHelpPage("chatparty", true);
- case ChatTabType::GUILD:
- return showHelpPage("chatguild", true);
- case ChatTabType::WHISPER:
- return showHelpPage("chatwhisper", true);
- case ChatTabType::DEBUG:
- return showHelpPage("chatdebug", true);
- case ChatTabType::TRADE:
- return showHelpPage("chattrade", true);
- case ChatTabType::BATTLE:
- return showHelpPage("chatbattle", true);
- case ChatTabType::LANG:
- return showHelpPage("chatlang", true);
- case ChatTabType::GM:
- return showHelpPage("chatgm", true);
- case ChatTabType::CHANNEL:
- return showHelpPage("chatchannel", true);
- default:
- case ChatTabType::UNKNOWN:
- case ChatTabType::INPUT:
- return showHelpPage("chatcommands", true);
- }
-}
-
-impHandler0(aboutWindowShow)
-{
- return showHelpPage("about", false);
-}
-
-static void showHideWindow(Window *const window)
-{
- if (window != nullptr)
- {
- window->setVisible(fromBool(
- !window->isWindowVisible(), Visible));
- if (window->isWindowVisible())
- window->requestMoveToTop();
- }
-}
-
-impHandler0(statusWindowShow)
-{
- showHideWindow(statusWindow);
- return true;
-}
-
-impHandler0(inventoryWindowShow)
-{
- showHideWindow(inventoryWindow);
- return true;
-}
-
-impHandler0(equipmentWindowShow)
-{
- showHideWindow(equipmentWindow);
- return true;
-}
-
-impHandler0(skillDialogShow)
-{
- showHideWindow(skillDialog);
- return true;
-}
-
-impHandler0(minimapWindowShow)
-{
- if (minimap != nullptr)
- {
- minimap->toggle();
- return true;
- }
- return false;
-}
-
-impHandler0(chatWindowShow)
-{
- showHideWindow(chatWindow);
- return true;
-}
-
-impHandler0(shortcutWindowShow)
-{
- showHideWindow(itemShortcutWindow);
- return true;
-}
-
-impHandler0(debugWindowShow)
-{
- showHideWindow(debugWindow);
- return true;
-}
-
-impHandler0(socialWindowShow)
-{
- showHideWindow(socialWindow);
- return true;
-}
-
-impHandler0(emoteShortcutWindowShow)
-{
- showHideWindow(emoteShortcutWindow);
- return true;
-}
-
-impHandler0(outfitWindowShow)
-{
- showHideWindow(outfitWindow);
- return true;
-}
-
-impHandler0(shopWindowShow)
-{
- showHideWindow(shopWindow);
- return true;
-}
-
-impHandler0(dropShortcutWindowShow)
-{
- showHideWindow(dropShortcutWindow);
- return true;
-}
-
-impHandler0(killStatsWindowShow)
-{
- showHideWindow(killStats);
- return true;
-}
-
-impHandler0(spellShortcutWindowShow)
-{
- showHideWindow(spellShortcutWindow);
- return true;
-}
-
-impHandler0(whoIsOnlineWindowShow)
-{
- showHideWindow(whoIsOnline);
- return true;
-}
-
-impHandler0(didYouKnowWindowShow)
-{
- showHideWindow(didYouKnowWindow);
- return true;
-}
-
-impHandler0(questsWindowShow)
-{
- showHideWindow(questsWindow);
- return true;
-}
-
-impHandler0(bankWindowShow)
-{
-#ifdef TMWA_SUPPORT
- if (Net::getNetworkType() == ServerType::TMWATHENA)
- return false;
-#endif // TMWA_SUPPORT
-
- showHideWindow(bankWindow);
- return true;
-}
-
-impHandler0(cartWindowShow)
-{
- if (Net::getNetworkType() == ServerType::TMWATHENA ||
- (localPlayer == nullptr) ||
- !localPlayer->getHaveCart())
- {
- return false;
- }
-
- showHideWindow(cartWindow);
- if (inventoryWindow != nullptr)
- inventoryWindow->updateDropButton();
- return true;
-}
-
-impHandler0(updaterWindowShow)
-{
- if (updaterWindow != nullptr)
- updaterWindow->deleteSelf();
- else
- DialogsManager::createUpdaterWindow();
- return true;
-}
-
-impHandler0(quickWindowShow)
-{
- if (setupWindow != nullptr)
- {
- if (setupWindow->isWindowVisible())
- setupWindow->doCancel();
- setupWindow->setVisible(Visible_true);
- // TRANSLATORS: settings tab name
- setupWindow->activateTab(_("Quick"));
- setupWindow->requestMoveToTop();
- return true;
- }
- return false;
-}
-
-impHandler0(mailWindowShow)
-{
- showHideWindow(mailWindow);
- return true;
-}
-
-impHandler0(serverInfoWindowShow)
-{
- if (serverInfoWindow != nullptr &&
- serverInfoWindow->isWindowVisible())
- {
- serverInfoWindow->close();
- serverInfoWindow = nullptr;
- }
- else
- {
- serverInfoWindow = CREATEWIDGETR(ServerInfoWindow,
- client->getCurrentServer());
- serverInfoWindow->requestMoveToTop();
- }
- return true;
-}
-
-impHandler(showItems)
-{
- const std::string args = event.args;
- if (args.empty())
- return false;
-
- Being *being = nullptr;
- if (args[0] == ':')
- {
- being = actorManager->findBeing(fromInt(atoi(
- args.substr(1).c_str()), BeingId));
- if ((being != nullptr) && being->getType() == ActorType::Monster)
- being = nullptr;
- }
- else
- {
- being = actorManager->findBeingByName(args, ActorType::Player);
- }
- if (being == nullptr)
- return true;
- if (being == localPlayer)
- {
- if (equipmentWindow != nullptr &&
- !equipmentWindow->isWindowVisible())
- {
- equipmentWindow->setVisible(Visible_true);
- }
- }
- else
- {
- if (beingEquipmentWindow != nullptr)
- {
- beingEquipmentWindow->setBeing(being);
- beingEquipmentWindow->setVisible(Visible_true);
- }
- }
- return true;
-}
-
-} // namespace Actions
diff --git a/src/progs/manaplus/client.cpp b/src/progs/manaplus/client.cpp
deleted file mode 100644
index 9bc4b03cb..000000000
--- a/src/progs/manaplus/client.cpp
+++ /dev/null
@@ -1,1991 +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 "progs/manaplus/client.h"
-
-#include "chatlogger.h"
-#include "configmanager.h"
-#include "dirs.h"
-#include "eventsmanager.h"
-#include "game.h"
-#include "graphicsmanager.h"
-#include "main.h"
-#include "party.h"
-#include "settings.h"
-#include "soundmanager.h"
-#include "spellmanager.h"
-
-#include "being/localplayer.h"
-#include "being/playerinfo.h"
-#include "being/playerrelations.h"
-
-#include "const/net/net.h"
-
-#include "enums/being/attributesstrings.h"
-
-#include "fs/virtfs/fs.h"
-#include "fs/virtfs/tools.h"
-
-#include "gui/dialogsmanager.h"
-#include "gui/gui.h"
-#include "gui/skin.h"
-#include "gui/popupmanager.h"
-#include "gui/windowmanager.h"
-
-#include "gui/shortcut/dropshortcut.h"
-#include "gui/shortcut/emoteshortcut.h"
-#include "gui/shortcut/itemshortcut.h"
-#include "gui/shortcut/spellshortcut.h"
-
-#include "gui/windows/changeemaildialog.h"
-#include "gui/windows/changepassworddialog.h"
-#include "gui/windows/charselectdialog.h"
-#include "gui/windows/connectiondialog.h"
-#include "gui/windows/equipmentwindow.h"
-#include "gui/windows/logindialog.h"
-#include "gui/windows/npcdialog.h"
-#include "gui/windows/okdialog.h"
-#include "gui/windows/registerdialog.h"
-#include "gui/windows/serverdialog.h"
-#include "gui/windows/setupwindow.h"
-#include "gui/windows/updaterwindow.h"
-#include "gui/windows/quitdialog.h"
-#include "gui/windows/worldselectdialog.h"
-
-#include "gui/widgets/button.h"
-#include "gui/widgets/createwidget.h"
-#include "gui/widgets/desktop.h"
-#include "gui/widgets/windowcontainer.h"
-
-#include "input/inputmanager.h"
-#include "input/joystick.h"
-#include "input/keyboardconfig.h"
-
-#include "input/touch/touchmanager.h"
-
-#include "net/charserverhandler.h"
-#include "net/chathandler.h"
-#include "net/download.h"
-#include "net/gamehandler.h"
-#include "net/generalhandler.h"
-#include "net/guildhandler.h"
-#include "net/inventoryhandler.h"
-#include "net/ipc.h"
-#include "net/loginhandler.h"
-#include "net/net.h"
-#include "net/updatetypeoperators.h"
-#include "net/useragent.h"
-#include "net/packetlimiter.h"
-#include "net/partyhandler.h"
-
-#ifdef TMWA_SUPPORT
-#include "net/tmwa/guildmanager.h"
-#endif // TMWA_SUPPORT
-
-#include "particle/particleengine.h"
-
-#include "resources/dbmanager.h"
-#include "resources/imagehelper.h"
-
-#include "resources/dye/dyepalette.h"
-
-#include "resources/resourcemanager/resourcemanager.h"
-
-#include "resources/sprite/spritereference.h"
-
-#include "utils/checkutils.h"
-#include "utils/cpu.h"
-#include "utils/delete2.h"
-#include "utils/dumplibs.h"
-#include "utils/dumpsizes.h"
-#include "utils/env.h"
-#include "utils/fuzzer.h"
-#include "utils/gettext.h"
-#include "utils/gettexthelper.h"
-#include "utils/mrand.h"
-#ifdef ANDROID
-#include "fs/paths.h"
-#endif // ANDROID
-#include "utils/sdlcheckutils.h"
-#include "utils/sdlhelper.h"
-#include "utils/timer.h"
-
-#include "utils/translation/translationmanager.h"
-
-#include "listeners/assertlistener.h"
-#include "listeners/errorlistener.h"
-
-#ifdef USE_OPENGL
-#include "test/testlauncher.h"
-#include "test/testmain.h"
-#else // USE_OPENGL
-#include "configuration.h"
-#endif // USE_OPENGL
-
-#ifdef WIN32
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_syswm.h>
-PRAGMA48(GCC diagnostic pop)
-#include "fs/specialfolder.h"
-#undef ERROR
-#endif // WIN32
-
-#ifdef ANDROID
-#ifndef USE_SDL2
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_screenkeyboard.h>
-PRAGMA48(GCC diagnostic pop)
-#include <fstream>
-#endif // USE_SDL2
-#endif // ANDROID
-
-#include <sys/stat.h>
-
-#ifdef USE_MUMBLE
-#include "mumblemanager.h"
-#endif // USE_MUMBLE
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#ifdef USE_SDL2
-#include <SDL2_framerate.h>
-#else // USE_SDL2
-#include <SDL_framerate.h>
-#endif // USE_SDL2
-PRAGMA48(GCC diagnostic pop)
-
-#include "debug.h"
-
-std::string errorMessage;
-LoginData loginData;
-
-Client *client = nullptr;
-
-extern FPSmanager fpsManager;
-extern int evolPacketOffset;
-
-volatile bool runCounters;
-bool isSafeMode = false;
-int serverVersion = 0;
-int packetVersion = 0;
-unsigned int tmwServerVersion = 0;
-time_t start_time;
-unsigned int mLastHost = 0;
-unsigned long mSearchHash = 0;
-int textures_count = 0;
-volatile bool isTerminate = false;
-
-namespace
-{
- class AccountListener final : public ActionListener
- {
- public:
- AccountListener()
- { }
-
- A_DELETE_COPY(AccountListener)
-
- void action(const ActionEvent &event A_UNUSED) override final
- {
- client->setState(State::CHAR_SELECT);
- }
- } accountListener;
-
- class LoginListener final : public ActionListener
- {
- public:
- LoginListener()
- { }
-
- A_DELETE_COPY(LoginListener)
-
- void action(const ActionEvent &event A_UNUSED) override final
- {
- client->setState(State::PRE_LOGIN);
- }
- } loginListener;
-} // namespace
-
-Client::Client() :
- ActionListener(),
- mCurrentServer(),
- mGame(nullptr),
- mCurrentDialog(nullptr),
- mQuitDialog(nullptr),
- mSetupButton(nullptr),
- mVideoButton(nullptr),
- mHelpButton(nullptr),
- mAboutButton(nullptr),
- mThemesButton(nullptr),
- mPerfomanceButton(nullptr),
-#ifdef ANDROID
- mCloseButton(nullptr),
-#endif // ANDROID
- mState(State::CHOOSE_SERVER),
- mOldState(State::START),
- mSkin(nullptr),
- mButtonPadding(1),
- mButtonSpacing(3),
- mPing(0),
- mConfigAutoSaved(false)
-{
- WindowManager::init();
-}
-
-void Client::testsInit()
-{
- if (!settings.options.test.empty() &&
- settings.options.test != "99")
- {
- gameInit();
- }
- else
- {
- initRand();
- logger = new Logger;
- SDL::initLogger();
- Dirs::initLocalDataDir();
- Dirs::initTempDir();
- Dirs::initConfigDir();
- GettextHelper::initLang();
- }
-}
-
-void Client::gameInit()
-{
- logger = new Logger;
- SDL::initLogger();
-
- initRand();
-
- assertListener = new AssertListener;
- // Load branding information
- if (!settings.options.brandingPath.empty())
- branding.init(settings.options.brandingPath);
- setBrandingDefaults(branding);
-
- Dirs::initRootDir();
- Dirs::initHomeDir();
-
- // Configure logger
- if (!settings.options.logFileName.empty())
- {
- settings.logFileName = settings.options.logFileName;
- }
- else
- {
- settings.logFileName = pathJoin(settings.localDataDir,
- "manaplus.log");
- }
- logger->log("Log file: " + settings.logFileName);
- logger->setLogFile(settings.logFileName);
-
-#ifdef USE_FUZZER
- Fuzzer::init();
-#endif // USE_FUZZER
-
- if (settings.options.ipc == true)
- IPC::start();
- if (settings.options.test.empty())
- ConfigManager::backupConfig("config.xml");
- ConfigManager::initConfiguration();
- SDL::setLogLevel(config.getIntValue("sdlLogLevel"));
- settings.init();
- Net::loadIgnorePackets();
- setPathsDefaults(paths);
- initFeatures();
- initPaths();
- logger->log("init 4");
- logger->setDebugLog(config.getBoolValue("debugLog"));
- logger->setReportUnimplemented(config.getBoolValue("unimplimentedLog"));
-
- config.incValue("runcount");
-
-#ifndef ANDROID
- if (settings.options.test.empty())
- ConfigManager::storeSafeParameters();
-#endif // ANDROID
-
- if (!VirtFs::setWriteDir(settings.localDataDir))
- {
- logger->error(strprintf("%s couldn't be set as home directory! "
- "Exiting.", settings.localDataDir.c_str()));
- }
-
- GettextHelper::initLang();
-
- chatLogger = new ChatLogger;
- if (settings.options.chatLogDir.empty())
- {
- chatLogger->setBaseLogDir(settings.localDataDir
- + std::string("/logs/"));
- }
- else
- {
- chatLogger->setBaseLogDir(settings.options.chatLogDir);
- }
-
- // Log the client version
- logger->log1(FULL_VERSION);
- logger->log("Start configPath: " + config.getConfigPath());
-
- Dirs::initScreenshotDir();
-
- updateEnv();
- SDL::allowScreenSaver(config.getBoolValue("allowscreensaver"));
- dumpLibs();
- dumpSizes();
-
- // Initialize SDL
- logger->log1("Initializing SDL...");
- if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) < 0)
- {
- logger->safeError(strprintf("Could not initialize SDL: %s",
- SDL_GetError()));
- }
- atexit(SDL_Quit);
-
- PacketLimiter::initPacketLimiter();
-#ifndef USE_SDL2
- SDL_EnableUNICODE(1);
-#endif // USE_SDL2
-
- WindowManager::applyKeyRepeat();
- eventsManager.init();
- eventsManager.enableEvents();
-
-#ifdef WIN32
- Dirs::mountDataDir();
-#endif // WIN32
-#ifndef USE_SDL2
- WindowManager::setIcon();
-#endif // USE_SDL2
-
- ConfigManager::checkConfigVersion();
- logVars();
- Cpu::detect();
- DyePalette::initFunctions();
-#if defined(USE_OPENGL)
-#if !defined(ANDROID) && !defined(__APPLE__) && \
- !defined(__native_client__) && !defined(UNITTESTS)
- if (!settings.options.safeMode &&
- settings.options.renderer < 0 &&
- settings.options.test.empty() &&
- !settings.options.validate &&
- !config.getBoolValue("videodetected"))
- {
- graphicsManager.detectVideoSettings();
- }
-#endif // !defined(ANDROID) && !defined(__APPLE__) &&
- // !defined(__native_client__) && !defined(UNITTESTS)
-#endif // defined(USE_OPENGL)
-
- initGraphics();
- UserAgent::update();
-
- touchManager.init();
-
-#ifndef WIN32
- Dirs::extractDataDir();
- Dirs::mountDataDir();
-#endif // WIN32
-
- Dirs::updateDataPath();
-
- // Add the main data directories to our VirtFs search path
- if (!settings.options.dataPath.empty())
- {
- VirtFs::mountDir(settings.options.dataPath,
- Append_false);
- }
-
- // Add the local data directory to VirtFs search path
- VirtFs::mountDir(settings.localDataDir,
- Append_false);
- TranslationManager::loadCurrentLang();
- TranslationManager::loadDictionaryLang();
-#ifdef ENABLE_CUSTOMNLS
- TranslationManager::loadGettextLang();
-#endif // ENABLE_CUSTOMNLS
-
-#ifdef USE_SDL2
- WindowManager::setIcon();
-#endif // USE_SDL2
- WindowManager::initTitle();
-
- mainGraphics->postInit();
-
- theme = new Theme;
- Theme::selectSkin();
- ActorSprite::load();
- touchManager.init();
-
- // Initialize the item and emote shortcuts.
- for (size_t f = 0; f < SHORTCUT_TABS; f ++)
- itemShortcut[f] = new ItemShortcut(f);
- emoteShortcut = new EmoteShortcut;
- dropShortcut = new DropShortcut;
-
- gui = new Gui;
- gui->postInit(mainGraphics);
- dialogsManager = new DialogsManager;
- popupManager = new PopupManager;
-
- initSoundManager();
-
- // Initialize keyboard
- keyboard.init();
- inputManager.init();
-
- // Initialise player relations
- playerRelations.init();
- Joystick::init();
- WindowManager::createWindows();
-
- keyboard.update();
- if (joystick != nullptr)
- joystick->update();
-
- // Initialize default server
- mCurrentServer.hostname = settings.options.serverName;
- mCurrentServer.port = settings.options.serverPort;
- if (!settings.options.serverType.empty())
- {
- mCurrentServer.type = ServerInfo::parseType(
- settings.options.serverType);
- }
-
- loginData.username = settings.options.username;
- loginData.password = settings.options.password;
- LoginDialog::savedPassword = settings.options.password;
- loginData.remember = (serverConfig.getValue("remember", 1) != 0);
- loginData.registerLogin = false;
-
- if (mCurrentServer.hostname.empty())
- {
- mCurrentServer.hostname = branding.getValue("defaultServer", "");
- settings.options.serverName = mCurrentServer.hostname;
- }
-
- if (mCurrentServer.port == 0)
- {
- mCurrentServer.port = CAST_U16(branding.getValue(
- "defaultPort", CAST_S32(DEFAULT_PORT)));
- mCurrentServer.type = ServerInfo::parseType(
- branding.getValue("defaultServerType", "tmwathena"));
- }
-
- chatLogger->setServerName(mCurrentServer.hostname);
-
- if (loginData.username.empty() && loginData.remember)
- loginData.username = serverConfig.getValue("username", "");
-
- if (mState != State::ERROR)
- mState = State::CHOOSE_SERVER;
-
- startTimers();
-
- const int fpsLimit = config.getIntValue("fpslimit");
- settings.limitFps = fpsLimit > 0;
-
- SDL_initFramerate(&fpsManager);
- WindowManager::setFramerate(fpsLimit);
- initConfigListeners();
-
- settings.guiAlpha = config.getFloatValue("guialpha");
- optionChanged("fpslimit");
-
- start_time = time(nullptr);
-
- PlayerInfo::init();
-
-#ifdef ANDROID
-#ifndef USE_SDL2
- WindowManager::updateScreenKeyboard(SDL_GetScreenKeyboardHeight(nullptr));
-#endif // USE_SDL2
-#endif // ANDROID
-
-#ifdef USE_MUMBLE
- if (!mumbleManager)
- mumbleManager = new MumbleManager;
-#endif // USE_MUMBLE
-
- mSkin = theme->load("windowmenu.xml", "");
- if (mSkin != nullptr)
- {
- mButtonPadding = mSkin->getPadding();
- mButtonSpacing = mSkin->getOption("spacing", 3);
- }
- if (settings.options.error)
- inputManager.executeAction(InputAction::ERROR);
-
- if (settings.options.validate == true)
- runValidate();
-}
-
-Client::~Client()
-{
- if (!settings.options.testMode)
- gameClear();
- else
- testsClear();
- CHECKLISTENERS
-}
-
-void Client::initConfigListeners()
-{
- config.addListener("fpslimit", this);
- config.addListener("guialpha", this);
- config.addListener("gamma", this);
- config.addListener("enableGamma", this);
- config.addListener("particleEmitterSkip", this);
- config.addListener("vsync", this);
- config.addListener("repeateDelay", this);
- config.addListener("repeateInterval", this);
- config.addListener("logInput", this);
-}
-
-void Client::initSoundManager()
-{
- // Initialize sound engine
- try
- {
- if (config.getBoolValue("sound"))
- soundManager.init();
-
- soundManager.setSfxVolume(config.getIntValue("sfxVolume"));
- soundManager.setMusicVolume(config.getIntValue("musicVolume"));
- }
- catch (const char *const err)
- {
- mState = State::ERROR;
- errorMessage = err;
- logger->log("Warning: %s", err);
- }
- soundManager.playMusic(branding.getValue(
- "loginMusic",
- "keprohm.ogg"),
- SkipError_true);
-}
-
-void Client::initGraphics()
-{
-#ifndef USE_SDL2
- WindowManager::applyVSync();
-#endif // USE_SDL2
-
- runCounters = config.getBoolValue("packetcounters");
-
- graphicsManager.initGraphics();
-#ifdef USE_SDL2
- WindowManager::applyVSync();
-#endif // USE_SDL2
-
- imageHelper->postInit();
- setConfigDefaults2(config);
- WindowManager::applyGrabMode();
- WindowManager::applyGamma();
-
- mainGraphics->beginDraw();
-}
-
-void Client::testsClear()
-{
- if (!settings.options.test.empty())
- gameClear();
- else
- BeingInfo::clear();
-}
-
-void Client::gameClear()
-{
- if (logger != nullptr)
- logger->log1("Quitting1");
- isTerminate = true;
- config.removeListeners(this);
-
- delete2(assertListener);
-
- IPC::stop();
- eventsManager.shutdown();
- WindowManager::deleteWindows();
- if (windowContainer != nullptr)
- windowContainer->slowLogic();
-
- stopTimers();
- DbManager::unloadDb();
-
- if (loginHandler != nullptr)
- loginHandler->clearWorlds();
-
- if (chatHandler != nullptr)
- chatHandler->clear();
-
- if (charServerHandler != nullptr)
- charServerHandler->clear();
-
- delete2(ipc);
-
-#ifdef USE_MUMBLE
- delete2(mumbleManager);
-#endif // USE_MUMBLE
-
- PlayerInfo::deinit();
-
- // Before config.write() since it writes the shortcuts to the config
- for (unsigned f = 0; f < SHORTCUT_TABS; f ++)
- delete2(itemShortcut[f])
- delete2(emoteShortcut);
- delete2(dropShortcut);
-
- playerRelations.store();
-
- if (logger != nullptr)
- logger->log1("Quitting2");
-
- delete2(mCurrentDialog);
- delete2(popupManager);
- delete2(dialogsManager);
- delete2(gui);
-
- if (inventoryHandler != nullptr)
- inventoryHandler->clear();
-
- if (logger != nullptr)
- logger->log1("Quitting3");
-
- touchManager.clear();
-
- GraphicsManager::deleteRenderers();
-
- if (logger != nullptr)
- logger->log1("Quitting4");
-
- XML::cleanupXML();
-
- if (logger != nullptr)
- logger->log1("Quitting5");
-
- BeingInfo::clear();
-
- // Shutdown sound
- soundManager.close();
-
- if (logger != nullptr)
- logger->log1("Quitting6");
-
- ActorSprite::unload();
-
- ResourceManager::deleteInstance();
-
- soundManager.shutdown();
-
- if (logger != nullptr)
- logger->log1("Quitting8");
-
- WindowManager::deleteIcon();
-
- if (logger != nullptr)
- logger->log1("Quitting9");
-
- delete2(joystick);
-
- keyboard.deinit();
-
- if (logger != nullptr)
- logger->log1("Quitting10");
-
- touchManager.shutdown();
-
-#ifdef DEBUG_CONFIG
- config.enableKeyLogging();
-#endif // DEBUG_CONFIG
-
- config.removeOldKeys();
- config.write();
- serverConfig.write();
-
- config.clear();
- serverConfig.clear();
-
- if (logger != nullptr)
- logger->log1("Quitting11");
-
-#ifdef USE_PROFILER
- Perfomance::clear();
-#endif // USE_PROFILER
-
-#ifdef DEBUG_OPENGL_LEAKS
- if (logger)
- logger->log("textures left: %d", textures_count);
-#endif // DEBUG_OPENGL_LEAKS
-
- Graphics::cleanUp();
-
- if (logger != nullptr)
- logger->log1("Quitting12");
-
- delete2(chatLogger);
- TranslationManager::close();
-}
-
-int Client::testsExec()
-{
-#ifdef USE_OPENGL
- if (settings.options.test.empty())
- {
- TestMain test;
- return test.exec();
- }
- else
- {
- TestLauncher launcher(settings.options.test);
- return launcher.exec();
- }
-#else // USE_OPENGL
-
- return 0;
-#endif // USE_OPENGL
-}
-
-#define ADDBUTTON(var, object) var = object; \
- x -= var->getWidth() + mButtonSpacing; \
- var->setPosition(x, mButtonPadding); \
- top->add(var);
-
-void Client::stateConnectGame1()
-{
- if ((gameHandler != nullptr) &&
- (loginHandler != nullptr) &&
- gameHandler->isConnected())
- {
- loginHandler->disconnect();
- }
-}
-
-void Client::stateConnectServer1()
-{
- if (mOldState == State::CHOOSE_SERVER)
- {
- settings.serverName = mCurrentServer.hostname;
- ConfigManager::initServerConfig(mCurrentServer.hostname);
- PacketLimiter::initPacketLimiter();
- initTradeFilter();
- Dirs::initUsersDir();
- playerRelations.init();
-
- // Initialize the item and emote shortcuts.
- for (unsigned f = 0; f < SHORTCUT_TABS; f ++)
- {
- delete itemShortcut[f];
- itemShortcut[f] = new ItemShortcut(f);
- }
- delete emoteShortcut;
- emoteShortcut = new EmoteShortcut;
-
- // Initialize the drop shortcuts.
- delete dropShortcut;
- dropShortcut = new DropShortcut;
-
- initFeatures();
- PlayerInfo::loadData();
- loginData.registerUrl = mCurrentServer.registerUrl;
- loginData.packetVersion = mCurrentServer.packetVersion;
- if (!mCurrentServer.onlineListUrl.empty())
- settings.onlineListUrl = mCurrentServer.onlineListUrl;
- else
- settings.onlineListUrl = settings.serverName;
- settings.persistentIp = mCurrentServer.persistentIp;
- settings.supportUrl = mCurrentServer.supportUrl;
- settings.updateMirrors = mCurrentServer.updateMirrors;
- settings.enableRemoteCommands = (serverConfig.getValue(
- "enableRemoteCommands", 1) != 0);
-
- if (settings.options.username.empty())
- {
- if (loginData.remember)
- loginData.username = serverConfig.getValue("username", "");
- else
- loginData.username.clear();
- }
- else
- {
- loginData.username = settings.options.username;
- }
- settings.login = loginData.username;
- WindowManager::updateTitle();
-
- loginData.remember = (serverConfig.getValue("remember", 1) != 0);
- Net::connectToServer(mCurrentServer);
-
-#ifdef USE_MUMBLE
- if (mumbleManager)
- mumbleManager->setServer(mCurrentServer.hostname);
-#endif // USE_MUMBLE
-
-#ifdef TMWA_SUPPORT
- GuildManager::init();
-#endif // TMWA_SUPPORT
-
- if (!mConfigAutoSaved)
- {
- mConfigAutoSaved = true;
- config.write();
- }
- }
- else if (mOldState != State::CHOOSE_SERVER &&
- (loginHandler != nullptr) &&
- loginHandler->isConnected())
- {
- mState = State::PRE_LOGIN;
- }
-}
-
-void Client::stateWorldSelect1()
-{
- if (mOldState == State::UPDATE &&
- (loginHandler != nullptr))
- {
- if (loginHandler->getWorlds().size() < 2)
- mState = State::PRE_LOGIN;
- }
-}
-
-void Client::stateGame1()
-{
- if (gui == nullptr)
- return;
-
- BasicContainer2 *const top = static_cast<BasicContainer2*>(
- gui->getTop());
-
- if (top == nullptr)
- return;
-
- CREATEWIDGETV(desktop, Desktop, nullptr);
- top->add(desktop);
- int x = top->getWidth() - mButtonPadding;
- ADDBUTTON(mSetupButton, new Button(desktop,
- // TRANSLATORS: setup tab quick button
- _("Setup"), "Setup", this))
- ADDBUTTON(mPerfomanceButton, new Button(desktop,
- // TRANSLATORS: perfoamance tab quick button
- _("Performance"), "Perfomance", this))
- ADDBUTTON(mVideoButton, new Button(desktop,
- // TRANSLATORS: video tab quick button
- _("Video"), "Video", this))
- ADDBUTTON(mThemesButton, new Button(desktop,
- // TRANSLATORS: theme tab quick button
- _("Theme"), "Themes", this))
- ADDBUTTON(mAboutButton, new Button(desktop,
- // TRANSLATORS: theme tab quick button
- _("About"), "about", this))
- ADDBUTTON(mHelpButton, new Button(desktop,
- // TRANSLATORS: theme tab quick button
- _("Help"), "help", this))
-#ifdef ANDROID
- ADDBUTTON(mCloseButton, new Button(desktop,
- // TRANSLATORS: close quick button
- _("Close"), "close", this))
-#endif // ANDROID
-
- desktop->setSize(mainGraphics->getWidth(),
- mainGraphics->getHeight());
-}
-
-void Client::stateSwitchLogin1()
-{
- if (mOldState == State::GAME &&
- (gameHandler != nullptr))
- {
- gameHandler->disconnect();
- }
-}
-
-int Client::gameExec()
-{
- int lastTickTime = tick_time;
-
- while (mState != State::EXIT)
- {
- PROFILER_START();
- if (eventsManager.handleEvents())
- continue;
-
- BLOCK_START("Client::gameExec 3")
- if (generalHandler != nullptr)
- generalHandler->flushNetwork();
- BLOCK_END("Client::gameExec 3")
-
- BLOCK_START("Client::gameExec 4")
- if (gui != nullptr)
- gui->logic();
- cur_time = time(nullptr);
- int k = 0;
- while (lastTickTime != tick_time &&
- k < 40)
- {
- if (mGame != nullptr)
- mGame->logic();
- else if (gui != nullptr)
- gui->handleInput();
-
- ++lastTickTime;
- k ++;
- }
- soundManager.logic();
-
- logic_count += k;
- if (gui != nullptr)
- gui->slowLogic();
- if (mGame != nullptr)
- mGame->slowLogic();
- slowLogic();
- BLOCK_END("Client::gameExec 4")
-
- // This is done because at some point tick_time will wrap.
- lastTickTime = tick_time;
-
- // Update the screen when application is visible, delay otherwise.
- if (!WindowManager::getIsMinimized())
- {
- frame_count++;
- if (gui != nullptr)
- gui->draw();
- mainGraphics->updateScreen();
- }
- else
- {
- SDL_Delay(100);
- }
-
- BLOCK_START("~Client::SDL_framerateDelay")
- if (settings.limitFps)
- SDL_framerateDelay(&fpsManager);
- BLOCK_END("~Client::SDL_framerateDelay")
-
- BLOCK_START("Client::gameExec 6")
- if (mState == State::CONNECT_GAME)
- {
- stateConnectGame1();
- }
- else if (mState == State::CONNECT_SERVER)
- {
- stateConnectServer1();
- }
- else if (mState == State::WORLD_SELECT)
- {
- stateWorldSelect1();
- }
- else if (mOldState == State::START ||
- (mOldState == State::GAME && mState != State::GAME))
- {
- stateGame1();
- }
- else if (mState == State::SWITCH_LOGIN)
- {
- stateSwitchLogin1();
- }
- BLOCK_END("Client::gameExec 6")
-
- if (mState != mOldState)
- {
- BLOCK_START("Client::gameExec 7")
- PlayerInfo::stateChange(mState);
-
- if (mOldState == State::GAME)
- {
- delete2(mGame);
- assertListener = new AssertListener;
- Game::clearInstance();
- ResourceManager::cleanOrphans();
- Party::clearParties();
- Guild::clearGuilds();
- NpcDialog::clearDialogs();
- if (guildHandler != nullptr)
- guildHandler->clear();
- if (partyHandler != nullptr)
- partyHandler->clear();
- if (chatLogger != nullptr)
- chatLogger->clear();
- if (!settings.options.dataPath.empty())
- UpdaterWindow::unloadMods(settings.options.dataPath);
- else
- UpdaterWindow::unloadMods(settings.oldUpdates);
- if (!settings.options.skipUpdate)
- UpdaterWindow::unloadMods(settings.oldUpdates + "/fix/");
- }
- else if (mOldState == State::CHAR_SELECT)
- {
- if (mState != State::CHANGEPASSWORD &&
- charServerHandler != nullptr)
- {
- charServerHandler->clear();
- }
- }
-
- mOldState = mState;
-
- // Get rid of the dialog of the previous state
- delete2(mCurrentDialog);
-
- // State has changed, while the quitDialog was active, it might
- // not be correct anymore
- if (mQuitDialog != nullptr)
- {
- mQuitDialog->scheduleDelete();
- mQuitDialog = nullptr;
- }
- BLOCK_END("Client::gameExec 7")
-
- BLOCK_START("Client::gameExec 8")
- switch (mState)
- {
- case State::CHOOSE_SERVER:
- {
- BLOCK_START("Client::gameExec STATE_CHOOSE_SERVER")
- logger->log1("State: CHOOSE SERVER");
- unloadData();
-
- // Allow changing this using a server choice dialog
- // We show the dialog box only if the command-line
- // options weren't set.
- if (settings.options.serverName.empty() &&
- settings.options.serverPort == 0 &&
- !branding.getValue("onlineServerList", "a").empty())
- {
- // Don't allow an alpha opacity
- // lower than the default value
- theme->setMinimumOpacity(0.8F);
-
- CREATEWIDGETV(mCurrentDialog, ServerDialog,
- &mCurrentServer,
- settings.configDir);
- }
- else
- {
- mState = State::CONNECT_SERVER;
-
- // Reset options so that cancelling or connect
- // timeout will show the server dialog.
- settings.options.serverName.clear();
- settings.options.serverPort = 0;
- }
- BLOCK_END("Client::gameExec STATE_CHOOSE_SERVER")
- break;
- }
-
- case State::CONNECT_SERVER:
- BLOCK_START("Client::gameExec State::CONNECT_SERVER")
- logger->log1("State: CONNECT SERVER");
- loginData.updateHosts.clear();
- CREATEWIDGETV(mCurrentDialog, ConnectionDialog,
- // TRANSLATORS: connection dialog header
- _("Connecting to server"),
- State::SWITCH_SERVER);
- TranslationManager::loadCurrentLang();
- TranslationManager::loadDictionaryLang();
- BLOCK_END("Client::gameExec State::CONNECT_SERVER")
- break;
-
- case State::PRE_LOGIN:
- logger->log1("State: PRE_LOGIN");
- break;
-
- case State::LOGIN:
- BLOCK_START("Client::gameExec State::LOGIN")
- logger->log1("State: LOGIN");
- // Don't allow an alpha opacity
- // lower than the default value
- theme->setMinimumOpacity(0.8F);
-
- if (packetVersion == 0)
- {
- packetVersion = loginData.packetVersion;
- if (packetVersion != 0)
- {
- loginHandler->updatePacketVersion();
- logger->log("Preconfigured packet version: %d",
- packetVersion);
- }
- }
-
- loginData.updateType = static_cast<UpdateTypeT>(
- serverConfig.getValue("updateType", 0));
-
- mSearchHash = Net::Download::adlerBuffer(
- const_cast<char*>(mCurrentServer.hostname.c_str()),
- CAST_S32(mCurrentServer.hostname.size()));
- if (settings.options.username.empty() ||
- settings.options.password.empty())
- {
- CREATEWIDGETV(mCurrentDialog, LoginDialog,
- loginData,
- &mCurrentServer,
- &settings.options.updateHost);
- }
- else
- {
- mState = State::LOGIN_ATTEMPT;
- // Clear the password so that when login fails, the
- // dialog will show up next time.
- settings.options.password.clear();
- }
- BLOCK_END("Client::gameExec State::LOGIN")
- break;
-
- case State::LOGIN_ATTEMPT:
- BLOCK_START("Client::gameExec State::LOGIN_ATTEMPT")
- logger->log1("State: LOGIN ATTEMPT");
- CREATEWIDGETV(mCurrentDialog, ConnectionDialog,
- // TRANSLATORS: connection dialog header
- _("Logging in"),
- State::SWITCH_SERVER);
- if (loginHandler != nullptr)
- loginHandler->loginOrRegister(&loginData);
- BLOCK_END("Client::gameExec State::LOGIN_ATTEMPT")
- break;
-
- case State::WORLD_SELECT:
- BLOCK_START("Client::gameExec State::WORLD_SELECT")
- logger->log1("State: WORLD SELECT");
- {
- TranslationManager::loadCurrentLang();
- TranslationManager::loadDictionaryLang();
- if (loginHandler == nullptr)
- {
- BLOCK_END("Client::gameExec State::WORLD_SELECT")
- break;
- }
- Worlds worlds = loginHandler->getWorlds();
-
- if (worlds.empty())
- {
- // Trust that the netcode knows what it's doing
- mState = State::UPDATE;
- }
- else if (worlds.size() == 1)
- {
- loginHandler->chooseServer(
- 0, mCurrentServer.persistentIp);
- mState = State::UPDATE;
- }
- else
- {
- CREATEWIDGETV(mCurrentDialog, WorldSelectDialog,
- worlds);
- if (settings.options.chooseDefault)
- {
- static_cast<WorldSelectDialog*>(mCurrentDialog)
- ->action(ActionEvent(nullptr, "ok"));
- }
- }
- }
- BLOCK_END("Client::gameExec State::WORLD_SELECT")
- break;
-
- case State::WORLD_SELECT_ATTEMPT:
- BLOCK_START("Client::gameExec State::WORLD_SELECT_ATTEMPT")
- logger->log1("State: WORLD SELECT ATTEMPT");
- CREATEWIDGETV(mCurrentDialog, ConnectionDialog,
- // TRANSLATORS: connection dialog header
- _("Entering game world"),
- State::WORLD_SELECT);
- BLOCK_END("Client::gameExec State::WORLD_SELECT_ATTEMPT")
- break;
-
- case State::UPDATE:
- BLOCK_START("Client::gameExec State::UPDATE")
- logger->log1("State: UPDATE");
-
- // Determine which source to use for the update host
- if (!settings.options.updateHost.empty())
- settings.updateHost = settings.options.updateHost;
- else
- settings.updateHost = loginData.updateHost;
- Dirs::initUpdatesDir();
-
- if (!settings.oldUpdates.empty())
- UpdaterWindow::unloadUpdates(settings.oldUpdates);
-
- if (settings.options.skipUpdate)
- {
- mState = State::LOAD_DATA;
- settings.oldUpdates.clear();
- UpdaterWindow::loadDirMods(settings.options.dataPath);
- }
- else if ((loginData.updateType & UpdateType::Skip) != 0)
- {
- settings.oldUpdates = pathJoin(settings.localDataDir,
- settings.updatesDir);
- UpdaterWindow::loadLocalUpdates(settings.oldUpdates);
- mState = State::LOAD_DATA;
- }
- else
- {
- settings.oldUpdates = pathJoin(settings.localDataDir,
- settings.updatesDir);
- CREATEWIDGETV(mCurrentDialog, UpdaterWindow,
- settings.updateHost,
- settings.oldUpdates,
- settings.options.dataPath.empty(),
- loginData.updateType);
- }
- BLOCK_END("Client::gameExec State::UPDATE")
- break;
-
- case State::LOAD_DATA:
- {
- BLOCK_START("Client::gameExec State::LOAD_DATA")
- logger->log1("State: LOAD DATA");
-
- loadData();
-
- mState = State::GET_CHARACTERS;
- BLOCK_END("Client::gameExec State::LOAD_DATA")
- break;
- }
- case State::GET_CHARACTERS:
- BLOCK_START("Client::gameExec State::GET_CHARACTERS")
- logger->log1("State: GET CHARACTERS");
- CREATEWIDGETV(mCurrentDialog, ConnectionDialog,
- // TRANSLATORS: connection dialog header
- _("Requesting characters"),
- State::SWITCH_SERVER);
- if (charServerHandler != nullptr)
- charServerHandler->requestCharacters();
- BLOCK_END("Client::gameExec State::GET_CHARACTERS")
- break;
-
- case State::CHAR_SELECT:
- BLOCK_START("Client::gameExec State::CHAR_SELECT")
- logger->log1("State: CHAR SELECT");
- // Don't allow an alpha opacity
- // lower than the default value
- theme->setMinimumOpacity(0.8F);
-
- settings.login = loginData.username;
- WindowManager::updateTitle();
-
- CREATEWIDGETV(mCurrentDialog, CharSelectDialog,
- loginData);
-
- if (!(static_cast<CharSelectDialog*>(mCurrentDialog))
- ->selectByName(settings.options.character,
- CharSelectDialog::Choose))
- {
- (static_cast<CharSelectDialog*>(mCurrentDialog))
- ->selectByName(
- serverConfig.getValue("lastCharacter", ""),
- settings.options.chooseDefault ?
- CharSelectDialog::Choose :
- CharSelectDialog::Focus);
- }
-
- // Choosing character on the command line should work only
- // once, clear it so that 'switch character' works.
- settings.options.character.clear();
- BLOCK_END("Client::gameExec State::CHAR_SELECT")
- break;
-
- case State::CONNECT_GAME:
- BLOCK_START("Client::gameExec State::CONNECT_GAME")
- logger->log1("State: CONNECT GAME");
- CREATEWIDGETV(mCurrentDialog, ConnectionDialog,
- // TRANSLATORS: connection dialog header
- _("Connecting to the game server"),
- State::CHOOSE_SERVER);
- if (gameHandler != nullptr)
- gameHandler->connect();
- BLOCK_END("Client::gameExec State::CONNECT_GAME")
- break;
-
- case State::CHANGE_MAP:
- BLOCK_START("Client::gameExec State::CHANGE_MAP")
- logger->log1("State: CHANGE_MAP");
- CREATEWIDGETV(mCurrentDialog, ConnectionDialog,
- // TRANSLATORS: connection dialog header
- _("Changing game servers"),
- State::SWITCH_CHARACTER);
- if (gameHandler != nullptr)
- gameHandler->connect();
- BLOCK_END("Client::gameExec State::CHANGE_MAP")
- break;
-
- case State::GAME:
- BLOCK_START("Client::gameExec State::GAME")
- if (localPlayer != nullptr)
- {
- logger->log("Memorizing selected character %s",
- localPlayer->getName().c_str());
- serverConfig.setValue("lastCharacter",
- localPlayer->getName());
-#ifdef USE_MUMBLE
- if (mumbleManager)
- mumbleManager->setPlayer(localPlayer->getName());
-#endif // USE_MUMBLE
- }
-
- // Fade out logon-music here too to give the desired effect
- // of "flowing" into the game.
- soundManager.fadeOutMusic(1000);
-
- // Allow any alpha opacity
- theme->setMinimumOpacity(-1.0F);
-
- if (chatLogger != nullptr)
- chatLogger->setServerName(settings.serverName);
-
-#ifdef ANDROID
- delete2(mCloseButton);
-#endif // ANDROID
-
- delete2(mSetupButton);
- delete2(mVideoButton);
- delete2(mThemesButton);
- delete2(mAboutButton);
- delete2(mHelpButton);
- delete2(mPerfomanceButton);
- delete2(desktop);
-
- mCurrentDialog = nullptr;
-
- logger->log1("State: GAME");
- if (generalHandler != nullptr)
- generalHandler->reloadPartially();
- mGame = new Game;
- BLOCK_END("Client::gameExec State::GAME")
- break;
-
- case State::LOGIN_ERROR:
- BLOCK_START("Client::gameExec State::LOGIN_ERROR")
- logger->log1("State: LOGIN ERROR");
- CREATEWIDGETV(mCurrentDialog, OkDialog,
- // TRANSLATORS: error dialog header
- _("Error"),
- errorMessage,
- // TRANSLATORS: ok dialog button
- _("Close"),
- DialogType::ERROR,
- Modal_true,
- ShowCenter_true,
- nullptr,
- 260);
- mCurrentDialog->addActionListener(&loginListener);
- mCurrentDialog = nullptr; // OkDialog deletes itself
- BLOCK_END("Client::gameExec State::LOGIN_ERROR")
- break;
-
- case State::ACCOUNTCHANGE_ERROR:
- BLOCK_START("Client::gameExec State::ACCOUNTCHANGE_ERROR")
- logger->log1("State: ACCOUNT CHANGE ERROR");
- CREATEWIDGETV(mCurrentDialog, OkDialog,
- // TRANSLATORS: error dialog header
- _("Error"),
- errorMessage,
- // TRANSLATORS: ok dialog button
- _("Close"),
- DialogType::ERROR,
- Modal_true,
- ShowCenter_true,
- nullptr,
- 260);
- mCurrentDialog->addActionListener(&accountListener);
- mCurrentDialog = nullptr; // OkDialog deletes itself
- BLOCK_END("Client::gameExec State::ACCOUNTCHANGE_ERROR")
- break;
-
- case State::REGISTER_PREP:
- BLOCK_START("Client::gameExec State::REGISTER_PREP")
- logger->log1("State: REGISTER_PREP");
- CREATEWIDGETV(mCurrentDialog, ConnectionDialog,
- // TRANSLATORS: connection dialog header
- _("Requesting registration details"),
- State::LOGIN);
- loginHandler->getRegistrationDetails();
- BLOCK_END("Client::gameExec State::REGISTER_PREP")
- break;
-
- case State::REGISTER:
- logger->log1("State: REGISTER");
- CREATEWIDGETV(mCurrentDialog, RegisterDialog,
- loginData);
- break;
-
- case State::REGISTER_ATTEMPT:
- BLOCK_START("Client::gameExec State::REGISTER_ATTEMPT")
- logger->log("Username is %s", loginData.username.c_str());
- if (loginHandler != nullptr)
- loginHandler->registerAccount(&loginData);
- BLOCK_END("Client::gameExec State::REGISTER_ATTEMPT")
- break;
-
- case State::CHANGEPASSWORD:
- BLOCK_START("Client::gameExec State::CHANGEPASSWORD")
- logger->log1("State: CHANGE PASSWORD");
- CREATEWIDGETV(mCurrentDialog, ChangePasswordDialog,
- loginData);
- mCurrentDialog->setVisible(Visible_true);
- BLOCK_END("Client::gameExec State::CHANGEPASSWORD")
- break;
-
- case State::CHANGEPASSWORD_ATTEMPT:
- BLOCK_START("Client::gameExec "
- "State::CHANGEPASSWORD_ATTEMPT")
- logger->log1("State: CHANGE PASSWORD ATTEMPT");
- if (loginHandler != nullptr)
- {
- loginHandler->changePassword(loginData.password,
- loginData.newPassword);
- }
- BLOCK_END("Client::gameExec State::CHANGEPASSWORD_ATTEMPT")
- break;
-
- case State::CHANGEPASSWORD_SUCCESS:
- BLOCK_START("Client::gameExec "
- "State::CHANGEPASSWORD_SUCCESS")
- logger->log1("State: CHANGE PASSWORD SUCCESS");
- CREATEWIDGETV(mCurrentDialog, OkDialog,
- // TRANSLATORS: password change message header
- _("Password Change"),
- // TRANSLATORS: password change message text
- _("Password changed successfully!"),
- // TRANSLATORS: ok dialog button
- _("OK"),
- DialogType::ERROR,
- Modal_true,
- ShowCenter_true,
- nullptr,
- 260);
- mCurrentDialog->addActionListener(&accountListener);
- mCurrentDialog = nullptr; // OkDialog deletes itself
- loginData.password = loginData.newPassword;
- loginData.newPassword.clear();
- BLOCK_END("Client::gameExec State::CHANGEPASSWORD_SUCCESS")
- break;
-
- case State::CHANGEEMAIL:
- logger->log1("State: CHANGE EMAIL");
- CREATEWIDGETV(mCurrentDialog,
- ChangeEmailDialog,
- loginData);
- mCurrentDialog->setVisible(Visible_true);
- break;
-
- case State::CHANGEEMAIL_ATTEMPT:
- logger->log1("State: CHANGE EMAIL ATTEMPT");
- if (loginHandler != nullptr)
- loginHandler->changeEmail(loginData.email);
- break;
-
- case State::CHANGEEMAIL_SUCCESS:
- logger->log1("State: CHANGE EMAIL SUCCESS");
- CREATEWIDGETV(mCurrentDialog, OkDialog,
- // TRANSLATORS: email change message header
- _("Email Change"),
- // TRANSLATORS: email change message text
- _("Email changed successfully!"),
- // TRANSLATORS: ok dialog button
- _("OK"),
- DialogType::ERROR,
- Modal_true,
- ShowCenter_true,
- nullptr,
- 260);
- mCurrentDialog->addActionListener(&accountListener);
- mCurrentDialog = nullptr; // OkDialog deletes itself
- break;
-
- case State::SWITCH_SERVER:
- BLOCK_START("Client::gameExec State::SWITCH_SERVER")
- logger->log1("State: SWITCH SERVER");
-
- if (loginHandler != nullptr)
- loginHandler->disconnect();
- if (gameHandler != nullptr)
- {
- gameHandler->disconnect();
- gameHandler->clear();
- }
- settings.serverName.clear();
- settings.login.clear();
- WindowManager::updateTitle();
- serverConfig.write();
- serverConfig.unload();
- if (setupWindow != nullptr)
- setupWindow->externalUnload();
-
- mState = State::CHOOSE_SERVER;
- BLOCK_END("Client::gameExec State::SWITCH_SERVER")
- break;
-
- case State::SWITCH_LOGIN:
- BLOCK_START("Client::gameExec State::SWITCH_LOGIN")
- logger->log1("State: SWITCH LOGIN");
-
- if (loginHandler != nullptr)
- {
- loginHandler->logout();
- loginHandler->disconnect();
- }
- if (gameHandler != nullptr)
- gameHandler->disconnect();
- if (loginHandler != nullptr)
- loginHandler->connect();
-
- settings.login.clear();
- WindowManager::updateTitle();
- mState = State::LOGIN;
- BLOCK_END("Client::gameExec State::SWITCH_LOGIN")
- break;
-
- case State::SWITCH_CHARACTER:
- BLOCK_START("Client::gameExec State::SWITCH_CHARACTER")
- logger->log1("State: SWITCH CHARACTER");
-
- // Done with game
- if (gameHandler != nullptr)
- gameHandler->disconnect();
-
- settings.login.clear();
- WindowManager::updateTitle();
- mState = State::GET_CHARACTERS;
- BLOCK_END("Client::gameExec State::SWITCH_CHARACTER")
- break;
-
- case State::LOGOUT_ATTEMPT:
- logger->log1("State: LOGOUT ATTEMPT");
- break;
-
- case State::WAIT:
- logger->log1("State: WAIT");
- break;
-
- case State::EXIT:
- BLOCK_START("Client::gameExec State::EXIT")
- logger->log1("State: EXIT");
- Net::unload();
- BLOCK_END("Client::gameExec State::EXIT")
- break;
-
- case State::FORCE_QUIT:
- BLOCK_START("Client::gameExec State::FORCE_QUIT")
- logger->log1("State: FORCE QUIT");
- if (generalHandler != nullptr)
- generalHandler->unload();
- mState = State::EXIT;
- BLOCK_END("Client::gameExec State::FORCE_QUIT")
- break;
-
- case State::ERROR:
- BLOCK_START("Client::gameExec State::ERROR")
- config.write();
- if (mOldState == State::GAME)
- serverConfig.write();
- logger->log1("State: ERROR");
- logger->log("Error: %s\n", errorMessage.c_str());
- mCurrentDialog = DialogsManager::openErrorDialog(
- // TRANSLATORS: error message header
- _("Error"),
- errorMessage,
- Modal_true);
- mCurrentDialog->addActionListener(&errorListener);
- mCurrentDialog = nullptr; // OkDialog deletes itself
- gameHandler->disconnect();
- BLOCK_END("Client::gameExec State::ERROR")
- break;
-
- case State::AUTORECONNECT_SERVER:
- // ++++++
- break;
-
- case State::START:
- default:
- mState = State::FORCE_QUIT;
- break;
- }
- BLOCK_END("Client::gameExec 8")
- }
- PROFILER_END();
- }
-
- return 0;
-}
-
-void Client::optionChanged(const std::string &name)
-{
- if (name == "fpslimit")
- {
- const int fpsLimit = config.getIntValue("fpslimit");
- settings.limitFps = fpsLimit > 0;
- WindowManager::setFramerate(fpsLimit);
- }
- else if (name == "guialpha" ||
- name == "enableGuiOpacity")
- {
- const float alpha = config.getFloatValue("guialpha");
- settings.guiAlpha = alpha;
- ImageHelper::setEnableAlpha(alpha != 1.0F &&
- config.getBoolValue("enableGuiOpacity"));
- }
- else if (name == "gamma" ||
- name == "enableGamma")
- {
- WindowManager::applyGamma();
- }
- else if (name == "particleEmitterSkip")
- {
- ParticleEngine::emitterSkip =
- config.getIntValue("particleEmitterSkip") + 1;
- }
- else if (name == "vsync")
- {
- WindowManager::applyVSync();
- }
- else if (name == "repeateInterval" ||
- name == "repeateDelay")
- {
- WindowManager::applyKeyRepeat();
- }
-}
-
-void Client::action(const ActionEvent &event)
-{
- std::string tab;
- const std::string &eventId = event.getId();
-
- if (eventId == "close")
- {
- setState(State::FORCE_QUIT);
- return;
- }
- if (eventId == "Setup")
- {
- tab.clear();
- }
- else if (eventId == "help")
- {
- inputManager.executeAction(InputAction::WINDOW_HELP);
- return;
- }
- else if (eventId == "about")
- {
- inputManager.executeAction(InputAction::WINDOW_ABOUT);
- return;
- }
- else if (eventId == "Video")
- {
- tab = "Video";
- }
- else if (eventId == "Themes")
- {
- tab = "Theme";
- }
- else if (eventId == "Perfomance")
- {
- tab = "Perfomance";
- }
- else
- {
- return;
- }
-
- if (setupWindow != nullptr)
- {
- setupWindow->setVisible(fromBool(
- !setupWindow->isWindowVisible(), Visible));
- if (setupWindow->isWindowVisible())
- {
- if (!tab.empty())
- setupWindow->activateTab(tab);
- setupWindow->requestMoveToTop();
- }
- }
-}
-
-void Client::initFeatures()
-{
- features.init(paths.getStringValue("featuresFile"),
- UseVirtFs_true,
- SkipError_true);
- setFeaturesDefaults(features);
- settings.fixDeadAnimation = features.getBoolValue("fixDeadAnimation");
-}
-
-void Client::initPaths()
-{
- settings.gmCommandSymbol = paths.getStringValue("gmCommandSymbol");
- settings.gmCharCommandSymbol = paths.getStringValue("gmCharCommandSymbol");
- settings.linkCommandSymbol = paths.getStringValue("linkCommandSymbol");
- if (settings.linkCommandSymbol.empty())
- settings.linkCommandSymbol = "=";
- settings.overweightPercent = paths.getIntValue("overweightPercent");
- settings.playerNameOffset = paths.getIntValue(
- "playerNameOffset");
- settings.playerBadgeAtRightOffset = paths.getIntValue(
- "playerBadgeAtRightOffset");
- settings.unknownSkillsAutoTab = paths.getBoolValue("unknownSkillsAutoTab");
- settings.enableNewMailSystem = paths.getBoolValue("enableNewMailSystem");
-}
-
-void Client::initTradeFilter()
-{
- const std::string tradeListName =
- settings.serverConfigDir + "/tradefilter.txt";
-
- std::ofstream tradeFile;
- struct stat statbuf;
-
- if ((stat(tradeListName.c_str(), &statbuf) != 0) ||
- !S_ISREG(statbuf.st_mode))
- {
- tradeFile.open(tradeListName.c_str(),
- std::ios::out);
- if (tradeFile.is_open())
- {
- tradeFile << ": sell" << std::endl;
- tradeFile << ": buy" << std::endl;
- tradeFile << ": trade" << std::endl;
- tradeFile << "i sell" << std::endl;
- tradeFile << "i buy" << std::endl;
- tradeFile << "i trade" << std::endl;
- tradeFile << "i trading" << std::endl;
- tradeFile << "i am buy" << std::endl;
- tradeFile << "i am sell" << std::endl;
- tradeFile << "i am trade" << std::endl;
- tradeFile << "i am trading" << std::endl;
- tradeFile << "i'm buy" << std::endl;
- tradeFile << "i'm sell" << std::endl;
- tradeFile << "i'm trade" << std::endl;
- tradeFile << "i'm trading" << std::endl;
- }
- else
- {
- reportAlways("Error opening file for writing: %s",
- tradeListName.c_str());
- }
- tradeFile.close();
- }
-}
-
-bool Client::isTmw()
-{
- const std::string &name = settings.serverName;
- if (name == "server.themanaworld.org" ||
- name == "themanaworld.org" ||
- name == "167.114.129.72")
- {
- return true;
- }
- return false;
-}
-
-void Client::moveButtons(const int width)
-{
- if (mSetupButton != nullptr)
- {
- int x = width - mSetupButton->getWidth() - mButtonPadding;
- mSetupButton->setPosition(x, mButtonPadding);
-#ifndef WIN32
- x -= mPerfomanceButton->getWidth() + mButtonSpacing;
- mPerfomanceButton->setPosition(x, mButtonPadding);
-
- x -= mVideoButton->getWidth() + mButtonSpacing;
- mVideoButton->setPosition(x, mButtonPadding);
-
- x -= mThemesButton->getWidth() + mButtonSpacing;
- mThemesButton->setPosition(x, mButtonPadding);
-
- x -= mAboutButton->getWidth() + mButtonSpacing;
- mAboutButton->setPosition(x, mButtonPadding);
-
- x -= mHelpButton->getWidth() + mButtonSpacing;
- mHelpButton->setPosition(x, mButtonPadding);
-#ifdef ANDROID
- x -= mCloseButton->getWidth() + mButtonSpacing;
- mCloseButton->setPosition(x, mButtonPadding);
-#endif // ANDROID
-#endif // WIN32
- }
-}
-
-void Client::windowRemoved(const Window *const window)
-{
- if (mCurrentDialog == window)
- mCurrentDialog = nullptr;
-}
-
-void Client::logVars()
-{
-#ifdef ANDROID
- logger->log("APPDIR: %s", getenv("APPDIR"));
- logger->log("DATADIR2: %s", getSdStoragePath().c_str());
-#endif // ANDROID
-}
-
-void Client::slowLogic()
-{
- if ((gameHandler == nullptr) ||
- !gameHandler->mustPing())
- {
- return;
- }
-
- if (get_elapsed_time1(mPing) > 1500)
- {
- mPing = tick_time;
- if (mState == State::UPDATE ||
- mState == State::LOGIN ||
- mState == State::LOGIN_ATTEMPT ||
- mState == State::REGISTER ||
- mState == State::REGISTER_ATTEMPT)
- {
- if (loginHandler != nullptr)
- loginHandler->ping();
- if (generalHandler != nullptr)
- generalHandler->flushSend();
- }
- else if (mState == State::CHAR_SELECT)
- {
- if (charServerHandler != nullptr)
- charServerHandler->ping();
- if (generalHandler != nullptr)
- generalHandler->flushSend();
- }
- }
-}
-
-void Client::loadData()
-{
- // If another data path has been set,
- // we don't load any other files...
- if (settings.options.dataPath.empty())
- {
- // Add customdata directory
- VirtFs::searchAndAddArchives(
- "customdata/",
- "zip",
- Append_false);
- }
-
- if (!settings.options.skipUpdate)
- {
- VirtFs::searchAndAddArchives(
- settings.updatesDir + "/local/",
- "zip",
- Append_false);
-
- VirtFs::mountDir(pathJoin(
- settings.localDataDir,
- settings.updatesDir,
- "local/"),
- Append_false);
- }
-
- logger->log("Init paths");
- paths.init("paths.xml", UseVirtFs_true);
- setPathsDefaults(paths);
- initPaths();
- if (SpriteReference::Empty == nullptr)
- {
- SpriteReference::Empty = new SpriteReference(
- paths.getStringValue("spriteErrorFile"),
- 0);
- }
-
- if (BeingInfo::unknown == nullptr)
- BeingInfo::unknown = new BeingInfo;
-
- initFeatures();
- TranslationManager::loadCurrentLang();
- TranslationManager::loadDictionaryLang();
- PlayerInfo::stateChange(mState);
-
- AttributesEnum::init();
- DbManager::loadDb();
-
- delete spellManager;
- spellManager = new SpellManager;
- delete spellShortcut;
- spellShortcut = new SpellShortcut;
-
- EquipmentWindow::prepareSlotNames();
-
- ActorSprite::load();
-
- if (desktop != nullptr)
- desktop->reloadWallpaper();
-}
-
-void Client::unloadData()
-{
- DbManager::unloadDb();
- mCurrentServer.supportUrl.clear();
- settings.supportUrl.clear();
- if (settings.options.dataPath.empty())
- {
- // Add customdata directory
- VirtFs::searchAndRemoveArchives(
- "customdata/",
- "zip");
- }
-
- if (!settings.oldUpdates.empty())
- {
- UpdaterWindow::unloadUpdates(settings.oldUpdates);
- settings.oldUpdates.clear();
- }
-
- if (!settings.options.skipUpdate)
- {
- VirtFs::searchAndRemoveArchives(
- pathJoin(settings.updatesDir, "local/"),
- "zip");
-
- VirtFs::unmountDirSilent(pathJoin(
- settings.localDataDir,
- settings.updatesDir,
- "local/"));
- }
-
- ResourceManager::clearCache();
-
- loginData.clearUpdateHost();
- serverVersion = 0;
- packetVersion = 0;
- tmwServerVersion = 0;
- evolPacketOffset = 0;
-}
-
-void Client::runValidate()
-{
- loadData();
- WindowManager::createValidateWindows();
-
- WindowManager::deleteValidateWindows();
- unloadData();
- delete2(client);
- VirtFs::deinit();
- exit(0);
-}
diff --git a/src/progs/manaplus/client.h b/src/progs/manaplus/client.h
deleted file mode 100644
index af537bb68..000000000
--- a/src/progs/manaplus/client.h
+++ /dev/null
@@ -1,167 +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 PROGS_MANAPLUS_CLIENT_H
-#define PROGS_MANAPLUS_CLIENT_H
-
-#include "enums/state.h"
-
-#include "listeners/actionlistener.h"
-#include "listeners/configlistener.h"
-
-#include "net/serverinfo.h"
-
-#include "localconsts.h"
-
-class Button;
-class Game;
-class LoginData;
-class Skin;
-class Window;
-class QuitDialog;
-
-extern bool isSafeMode;
-extern int serverVersion;
-extern unsigned int tmwServerVersion;
-extern time_t start_time;
-extern int textures_count;
-
-extern std::string errorMessage;
-extern LoginData loginData;
-
-/**
- * The core part of the client. This class initializes all subsystems, runs
- * the event loop, and shuts everything down again.
- */
-class Client final : public ConfigListener,
- public ActionListener
-{
- public:
- Client();
-
- A_DELETE_COPY(Client)
-
- ~Client();
-
- void gameInit();
-
- void testsInit();
-
- int gameExec();
-
- static int testsExec();
-
- void setState(const StateT state)
- { mState = state; }
-
- StateT getState() const noexcept2 A_WARN_UNUSED
- { return mState; }
-
- static bool isTmw() A_WARN_UNUSED;
-
- void optionChanged(const std::string &name) override final;
-
- void action(const ActionEvent &event) override final;
-
- static void initTradeFilter();
-
- void moveButtons(const int width);
-
- void windowRemoved(const Window *const window);
-
- void slowLogic();
-
- ServerInfo &getCurrentServer()
- { return mCurrentServer; }
-
- private:
- void initSoundManager();
-
- void initConfigListeners();
-
- static void initGraphics();
-
- static void initFeatures();
-
- static void initPaths();
-
- void gameClear();
-
- void testsClear();
-
-#ifdef ANDROID
- static void logVars();
-#else // ANDROID
-
- static void logVars() A_CONST;
-#endif // ANDROID
-
- void stateConnectGame1();
-
- void stateConnectServer1();
-
- void stateWorldSelect1();
-
- void stateGame1();
-
- void stateSwitchLogin1();
-
- void loadData();
-
- void unloadData();
-
- void runValidate()
-#ifndef BAD_CILKPLUS
- __attribute__ ((noreturn))
-#endif // BAD_CILKPLUS
-;
-
- ServerInfo mCurrentServer;
-
- Game *mGame;
- Window *mCurrentDialog;
- QuitDialog *mQuitDialog;
- Button *mSetupButton;
- Button *mVideoButton;
- Button *mHelpButton;
- Button *mAboutButton;
- Button *mThemesButton;
- Button *mPerfomanceButton;
-#ifdef ANDROID
- Button *mCloseButton;
-#endif // ANDROID
-
- StateT mState;
- StateT mOldState;
-
- Skin *mSkin;
- int mButtonPadding;
- int mButtonSpacing;
- int mPing;
- bool mConfigAutoSaved;
-};
-
-extern Client *client;
-extern unsigned int mLastHost;
-extern unsigned long mSearchHash;
-
-#endif // PROGS_MANAPLUS_CLIENT_H
diff --git a/src/progs/manaplus/gui/viewport.cpp b/src/progs/manaplus/gui/viewport.cpp
deleted file mode 100644
index de7571c7c..000000000
--- a/src/progs/manaplus/gui/viewport.cpp
+++ /dev/null
@@ -1,1148 +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 "progs/manaplus/gui/viewport.h"
-
-#include "actormanager.h"
-#include "configuration.h"
-#include "game.h"
-#include "settings.h"
-#include "sdlshared.h"
-#include "textmanager.h"
-
-#include "being/flooritem.h"
-#include "being/localplayer.h"
-#include "being/playerinfo.h"
-
-#include "enums/resources/map/blockmask.h"
-#include "enums/resources/map/mapitemtype.h"
-
-#include "gui/gui.h"
-#include "gui/popupmanager.h"
-#include "gui/userpalette.h"
-
-#include "gui/fonts/font.h"
-
-#include "gui/popups/beingpopup.h"
-#include "gui/popups/popupmenu.h"
-#include "gui/popups/textpopup.h"
-
-#include "gui/windows/ministatuswindow.h"
-
-#include "input/inputmanager.h"
-
-#include "utils/checkutils.h"
-#include "utils/foreach.h"
-
-#include "resources/map/map.h"
-#include "resources/map/mapitem.h"
-#include "resources/map/speciallayer.h"
-
-#include "debug.h"
-
-Viewport *viewport = nullptr;
-
-extern volatile int tick_time;
-
-Viewport::Viewport() :
- WindowContainer(nullptr),
- MouseListener(),
- ConfigListener(),
- mMouseX(0),
- mMouseY(0),
- mMap(nullptr),
- mHoverBeing(nullptr),
- mHoverItem(nullptr),
- mHoverSign(nullptr),
- mScrollRadius(config.getIntValue("ScrollRadius")),
- mScrollLaziness(config.getIntValue("ScrollLaziness")),
- mScrollCenterOffsetX(config.getIntValue("ScrollCenterOffsetX")),
- mScrollCenterOffsetY(config.getIntValue("ScrollCenterOffsetY")),
- mMousePressX(0),
- mMousePressY(0),
- mPixelViewX(0),
- mPixelViewY(0),
- mMidTileX(0),
- mMidTileY(0),
- mViewXmax(0),
- mViewYmax(0),
- mLocalWalkTime(-1),
- mCameraRelativeX(0),
- mCameraRelativeY(0),
- mShowBeingPopup(config.getBoolValue("showBeingPopup")),
- mSelfMouseHeal(config.getBoolValue("selfMouseHeal")),
- mEnableLazyScrolling(config.getBoolValue("enableLazyScrolling")),
- mMouseDirectionMove(config.getBoolValue("mouseDirectionMove")),
- mLongMouseClick(config.getBoolValue("longmouseclick")),
- mAllowMoveByMouse(config.getBoolValue("allowMoveByMouse")),
- mMouseClicked(false),
- mPlayerFollowMouse(false)
-{
- setOpaque(Opaque_false);
- addMouseListener(this);
-
- config.addListener("ScrollLaziness", this);
- config.addListener("ScrollRadius", this);
- config.addListener("showBeingPopup", this);
- config.addListener("selfMouseHeal", this);
- config.addListener("enableLazyScrolling", this);
- config.addListener("mouseDirectionMove", this);
- config.addListener("longmouseclick", this);
- config.addListener("allowMoveByMouse", this);
-
- setFocusable(true);
- updateMidVars();
-}
-
-Viewport::~Viewport()
-{
- config.removeListeners(this);
- CHECKLISTENERS
-}
-
-void Viewport::setMap(Map *const map)
-{
- if ((mMap != nullptr) && (map != nullptr))
- map->setDrawLayersFlags(mMap->getDrawLayersFlags());
- mMap = map;
- updateMaxVars();
-}
-
-void Viewport::draw(Graphics *const graphics)
-{
- BLOCK_START("Viewport::draw 1")
- static int lastTick = tick_time;
-
- if ((mMap == nullptr) || (localPlayer == nullptr))
- {
- graphics->setColor(Color(64, 64, 64));
- graphics->fillRectangle(
- Rect(0, 0, getWidth(), getHeight()));
- BLOCK_END("Viewport::draw 1")
- return;
- }
-
- // Avoid freaking out when tick_time overflows
- if (tick_time < lastTick)
- lastTick = tick_time;
-
- // Calculate viewpoint
-
- const int player_x = localPlayer->mPixelX - mMidTileX;
- const int player_y = localPlayer->mPixelY - mMidTileY;
-
- if (mScrollLaziness < 1)
- mScrollLaziness = 1; // Avoids division by zero
-
- if (mEnableLazyScrolling)
- {
- int cnt = 0;
-
- // Apply lazy scrolling
- while (lastTick < tick_time && cnt < mapTileSize)
- {
- if (player_x > mPixelViewX + mScrollRadius)
- {
- mPixelViewX += CAST_S32(
- static_cast<float>(player_x
- - mPixelViewX - mScrollRadius) /
- static_cast<float>(mScrollLaziness));
- }
- if (player_x < mPixelViewX - mScrollRadius)
- {
- mPixelViewX += CAST_S32(
- static_cast<float>(player_x
- - mPixelViewX + mScrollRadius) /
- static_cast<float>(mScrollLaziness));
- }
- if (player_y > mPixelViewY + mScrollRadius)
- {
- mPixelViewY += CAST_S32(
- static_cast<float>(player_y
- - mPixelViewY - mScrollRadius) /
- static_cast<float>(mScrollLaziness));
- }
- if (player_y < mPixelViewY - mScrollRadius)
- {
- mPixelViewY += CAST_S32(
- static_cast<float>(player_y
- - mPixelViewY + mScrollRadius) /
- static_cast<float>(mScrollLaziness));
- }
- lastTick ++;
- cnt ++;
- }
-
- // Auto center when player is off screen
- if (cnt > 30 || player_x - mPixelViewX
- > graphics->mWidth / 2 || mPixelViewX
- - player_x > graphics->mWidth / 2 || mPixelViewY
- - player_y > graphics->getHeight() / 2 || player_y
- - mPixelViewY > graphics->getHeight() / 2)
- {
- if (player_x <= 0 || player_y <= 0)
- {
- logger->log("incorrect player position: %d, %d, %d, %d",
- player_x, player_y, mPixelViewX, mPixelViewY);
- logger->log("tile position: %d, %d",
- localPlayer->getTileX(), localPlayer->getTileY());
- }
- mPixelViewX = player_x;
- mPixelViewY = player_y;
- }
- }
- else
- {
- mPixelViewX = player_x;
- mPixelViewY = player_y;
- }
-
- if (mPixelViewX < 0)
- mPixelViewX = 0;
- if (mPixelViewY < 0)
- mPixelViewY = 0;
- if (mPixelViewX > mViewXmax)
- mPixelViewX = mViewXmax;
- if (mPixelViewY > mViewYmax)
- mPixelViewY = mViewYmax;
-
- // Draw tiles and sprites
- mMap->draw(graphics, mPixelViewX, mPixelViewY);
-
- const MapTypeT drawType = settings.mapDrawType;
- if (drawType != MapType::NORMAL)
- {
- if (drawType != MapType::SPECIAL4)
- {
- mMap->drawCollision(graphics, mPixelViewX,
- mPixelViewY, drawType);
- }
- if (drawType == MapType::DEBUGTYPE)
- drawDebugPath(graphics);
- }
-
- if (localPlayer->getCheckNameSetting())
- {
- localPlayer->setCheckNameSetting(false);
- localPlayer->setName(localPlayer->getName());
- }
-
- // Draw text
- if (textManager != nullptr)
- textManager->draw(graphics, mPixelViewX, mPixelViewY);
-
- // Draw player names, speech, and emotion sprite as needed
- const ActorSprites &actors = actorManager->getAll();
- FOR_EACH (ActorSpritesIterator, it, actors)
- {
- if ((*it)->getType() == ActorType::FloorItem)
- continue;
- Being *const b = static_cast<Being*>(*it);
- b->drawEmotion(graphics, mPixelViewX, mPixelViewY);
- b->drawSpeech(mPixelViewX, mPixelViewY);
- }
-
- if (miniStatusWindow != nullptr)
- miniStatusWindow->drawIcons(graphics);
-
- // Draw contained widgets
- WindowContainer::draw(graphics);
- BLOCK_END("Viewport::draw 1")
-}
-
-void Viewport::safeDraw(Graphics *const graphics)
-{
- Viewport::draw(graphics);
-}
-
-void Viewport::logic()
-{
- BLOCK_START("Viewport::logic")
- // Make the player follow the mouse position
- // if the mouse is dragged elsewhere than in a window.
- Gui::getMouseState(mMouseX, mMouseY);
- BLOCK_END("Viewport::logic")
-}
-
-void Viewport::followMouse()
-{
- if (gui == nullptr)
- return;
- const MouseStateType button = Gui::getMouseState(mMouseX, mMouseY);
- // If the left button is dragged
- if (mPlayerFollowMouse && ((button & SDL_BUTTON(1)) != 0))
- {
- // We create a mouse event and send it to mouseDragged.
- const MouseEvent event(nullptr,
- MouseEventType::DRAGGED,
- MouseButton::LEFT,
- mMouseX,
- mMouseY,
- 0);
-
- walkByMouse(event);
- }
-}
-
-void Viewport::drawDebugPath(Graphics *const graphics)
-{
- if (localPlayer == nullptr ||
- userPalette == nullptr ||
- actorManager == nullptr ||
- mMap == nullptr ||
- gui == nullptr)
- {
- return;
- }
-
- Gui::getMouseState(mMouseX, mMouseY);
-
- static Path debugPath;
- static Vector lastMouseDestination = Vector(0.0F, 0.0F);
- const int mousePosX = mMouseX + mPixelViewX;
- const int mousePosY = mMouseY + mPixelViewY;
- Vector mouseDestination(mousePosX, mousePosY);
-
- if (mouseDestination.x != lastMouseDestination.x
- || mouseDestination.y != lastMouseDestination.y)
- {
- debugPath = mMap->findPath(
- CAST_S32(localPlayer->mPixelX - mapTileSize / 2) / mapTileSize,
- CAST_S32(localPlayer->mPixelY - mapTileSize) / mapTileSize,
- mousePosX / mapTileSize,
- mousePosY / mapTileSize,
- localPlayer->getBlockWalkMask(),
- 500);
- lastMouseDestination = mouseDestination;
- }
- drawPath(graphics, debugPath, userPalette->getColorWithAlpha(
- UserColorId::ROAD_POINT));
-
- const ActorSprites &actors = actorManager->getAll();
- FOR_EACH (ActorSpritesConstIterator, it, actors)
- {
- const Being *const being = dynamic_cast<const Being*>(*it);
- if ((being != nullptr) && being != localPlayer)
- {
- const Path &beingPath = being->getPath();
- drawPath(graphics, beingPath, userPalette->getColorWithAlpha(
- UserColorId::ROAD_POINT));
- }
- }
-}
-
-void Viewport::drawPath(Graphics *const graphics,
- const Path &path,
- const Color &color) const
-{
- graphics->setColor(color);
- Font *const font = getFont();
-
- int cnt = 1;
- FOR_EACH (Path::const_iterator, i, path)
- {
- const int squareX = i->x * mapTileSize - mPixelViewX + 12;
- const int squareY = i->y * mapTileSize - mPixelViewY + 12;
-
- graphics->fillRectangle(Rect(squareX, squareY, 8, 8));
- if (mMap != nullptr)
- {
- const std::string str = toString(cnt);
- font->drawString(graphics,
- color, color,
- str,
- squareX + 4 - font->getWidth(str) / 2,
- squareY + 12);
- }
- cnt ++;
- }
-}
-
-bool Viewport::openContextMenu(const MouseEvent &event)
-{
- mPlayerFollowMouse = false;
- const int eventX = event.getX();
- const int eventY = event.getY();
- if (popupMenu == nullptr)
- return false;
- if (mHoverBeing != nullptr)
- {
- validateSpeed();
- if (actorManager != nullptr)
- {
- STD_VECTOR<ActorSprite*> beings;
- const int x = mMouseX + mPixelViewX;
- const int y = mMouseY + mPixelViewY;
- actorManager->findBeingsByPixel(beings, x, y, AllPlayers_true);
- if (beings.size() > 1)
- popupMenu->showPopup(eventX, eventY, beings);
- else
- popupMenu->showPopup(eventX, eventY, mHoverBeing);
- return true;
- }
- }
- else if (mHoverItem != nullptr)
- {
- validateSpeed();
- popupMenu->showPopup(eventX, eventY, mHoverItem);
- return true;
- }
- else if (mHoverSign != nullptr)
- {
- validateSpeed();
- popupMenu->showPopup(eventX, eventY, mHoverSign);
- return true;
- }
- else if (settings.cameraMode != 0u)
- {
- if (mMap == nullptr)
- return false;
- popupMenu->showMapPopup(eventX, eventY,
- (mMouseX + mPixelViewX) / mMap->getTileWidth(),
- (mMouseY + mPixelViewY) / mMap->getTileHeight(),
- false);
- return true;
- }
- return false;
-}
-
-bool Viewport::leftMouseAction()
-{
- const bool stopAttack = inputManager.isActionActive(
- InputAction::STOP_ATTACK);
- // Interact with some being
- if (mHoverBeing != nullptr)
- {
- if (!mHoverBeing->isAlive())
- return true;
-
- if (mHoverBeing->canTalk())
- {
- validateSpeed();
- mHoverBeing->talkTo();
- return true;
- }
-
- const ActorTypeT type = mHoverBeing->getType();
- switch (type)
- {
- case ActorType::Player:
- validateSpeed();
- if (actorManager != nullptr)
- {
-#ifdef TMWA_SUPPORT
- if (localPlayer != mHoverBeing || mSelfMouseHeal)
- actorManager->heal(mHoverBeing);
-#endif // TMWA_SUPPORT
-
- if (localPlayer == mHoverBeing &&
- mHoverItem != nullptr)
- {
- localPlayer->pickUp(mHoverItem);
- }
- return true;
- }
- break;
- case ActorType::Monster:
- case ActorType::Npc:
- case ActorType::SkillUnit:
- if (!stopAttack)
- {
- if (localPlayer->withinAttackRange(mHoverBeing) ||
- inputManager.isActionActive(InputAction::ATTACK))
- {
- validateSpeed();
- if (!mStatsReUpdated && localPlayer != mHoverBeing)
- {
- localPlayer->attack(mHoverBeing,
- !inputManager.isActionActive(
- InputAction::STOP_ATTACK));
- return true;
- }
- }
- else if (!inputManager.isActionActive(
- InputAction::ATTACK))
- {
- validateSpeed();
- if (!mStatsReUpdated && localPlayer != mHoverBeing)
- {
- localPlayer->setGotoTarget(mHoverBeing);
- return true;
- }
- }
- }
- break;
- case ActorType::FloorItem:
- case ActorType::Portal:
- case ActorType::Pet:
- case ActorType::Mercenary:
- case ActorType::Homunculus:
- case ActorType::Elemental:
- break;
- case ActorType::Unknown:
- case ActorType::Avatar:
- default:
- reportAlways("Left click on unknown actor type: %d",
- CAST_S32(type));
- break;
- }
- }
- // Picks up a item if we clicked on one
- if (mHoverItem != nullptr)
- {
- validateSpeed();
- localPlayer->pickUp(mHoverItem);
- }
- else if (stopAttack)
- {
- if (mMap != nullptr)
- {
- const int mouseTileX = (mMouseX + mPixelViewX)
- / mMap->getTileWidth();
- const int mouseTileY = (mMouseY + mPixelViewY)
- / mMap->getTileHeight();
- inputManager.executeChatCommand(InputAction::PET_MOVE,
- strprintf("%d %d", mouseTileX, mouseTileY),
- nullptr);
- }
- return true;
- }
- // Just walk around
- else if (!inputManager.isActionActive(InputAction::ATTACK) &&
- localPlayer->canMove())
- {
- validateSpeed();
- localPlayer->stopAttack();
- localPlayer->cancelFollow();
- mPlayerFollowMouse = mAllowMoveByMouse;
- if (mPlayerFollowMouse)
- {
- // Make the player go to the mouse position
- followMouse();
- }
- }
- return false;
-}
-
-void Viewport::mousePressed(MouseEvent &event)
-{
- if (event.getSource() != this || event.isConsumed())
- return;
-
- // Check if we are alive and kickin'
- if ((mMap == nullptr) || (localPlayer == nullptr))
- return;
-
- // Check if we are busy
- // if commented, allow context menu if npc dialog open
- if (PlayerInfo::isTalking())
- {
- mMouseClicked = false;
- return;
- }
-
- mMouseClicked = true;
-
- mMousePressX = event.getX();
- mMousePressY = event.getY();
- const MouseButtonT eventButton = event.getButton();
- const int pixelX = mMousePressX + mPixelViewX;
- const int pixelY = mMousePressY + mPixelViewY;
-
- // Right click might open a popup
- if (eventButton == MouseButton::RIGHT)
- {
- if (openContextMenu(event))
- return;
- }
-
- // If a popup is active, just remove it
- if (PopupManager::isPopupMenuVisible())
- {
- mPlayerFollowMouse = false;
- PopupManager::hidePopupMenu();
- return;
- }
-
- // Left click can cause different actions
- if (!mLongMouseClick && eventButton == MouseButton::LEFT)
- {
- if (leftMouseAction())
- {
- mPlayerFollowMouse = false;
- return;
- }
- }
- else if (eventButton == MouseButton::MIDDLE)
- {
- mPlayerFollowMouse = false;
- validateSpeed();
- // Find the being nearest to the clicked position
- if (actorManager != nullptr)
- {
- Being *const target = actorManager->findNearestLivingBeing(
- pixelX, pixelY, 20, ActorType::Monster, nullptr);
-
- if (target != nullptr)
- localPlayer->setTarget(target);
- }
- }
-}
-
-void Viewport::getMouseTile(int &destX, int &destY) const
-{
- getMouseTile(mMouseX, mMouseY, destX, destY);
-}
-
-void Viewport::getMouseTile(const int x, const int y,
- int &destX, int &destY) const
-{
- if (mMap == nullptr)
- return;
- const int tw = mMap->getTileWidth();
- const int th = mMap->getTileHeight();
- destX = CAST_S32(x + mPixelViewX)
- / static_cast<float>(tw);
-
- if (mMap->isHeightsPresent())
- {
- const int th2 = th / 2;
- const int clickY = y + mPixelViewY - th2;
- destY = y + mPixelViewY;
- int newDiffY = 1000000;
- const int heightTiles = mainGraphics->mHeight / th;
- const int tileViewY = mPixelViewY / th;
- for (int f = tileViewY; f < tileViewY + heightTiles; f ++)
- {
- if (!mMap->getWalk(destX,
- f,
- BlockMask::WALL |
- BlockMask::AIR |
- BlockMask::WATER |
- BlockMask::PLAYERWALL))
- {
- continue;
- }
-
- const int offset = mMap->getHeightOffset(
- destX, f) * th2;
- const int pixelF = f * th;
- const int diff = abs(clickY + offset - pixelF);
- if (diff < newDiffY)
- {
- destY = pixelF;
- newDiffY = diff;
- }
- }
- destY /= 32;
- }
- else
- {
- destY = CAST_S32((y + mPixelViewY) / static_cast<float>(th));
- }
-}
-
-void Viewport::walkByMouse(const MouseEvent &event)
-{
- if ((mMap == nullptr) || (localPlayer == nullptr))
- return;
- if (mPlayerFollowMouse
- && !inputManager.isActionActive(InputAction::STOP_ATTACK)
- && !inputManager.isActionActive(InputAction::UNTARGET))
- {
- if (!mMouseDirectionMove)
- mPlayerFollowMouse = false;
- if (mLocalWalkTime != localPlayer->getActionTime())
- {
- mLocalWalkTime = cur_time;
- localPlayer->unSetPickUpTarget();
- int playerX = localPlayer->getTileX();
- int playerY = localPlayer->getTileY();
- if (mMouseDirectionMove)
- {
- const int width = mainGraphics->mWidth / 2;
- const int height = mainGraphics->mHeight / 2;
- const float wh = static_cast<float>(width)
- / static_cast<float>(height);
- int x = event.getX() - width;
- int y = event.getY() - height;
- if ((x == 0) && (y == 0))
- return;
- const int x2 = abs(x);
- const int y2 = abs(y);
- const float diff = 2;
- int dx = 0;
- int dy = 0;
- if (x2 > y2)
- {
- if (y2 != 0 &&
- static_cast<float>(x2) / static_cast<float>(y2) /
- wh > diff)
- {
- y = 0;
- }
- }
- else
- {
- if ((x2 != 0) && y2 * wh / x2 > diff)
- x = 0;
- }
- if (x > 0)
- dx = 1;
- else if (x < 0)
- dx = -1;
- if (y > 0)
- dy = 1;
- else if (y < 0)
- dy = -1;
-
- if (mMap->getWalk(playerX + dx,
- playerY + dy,
- BlockMask::WALL |
- BlockMask::AIR |
- BlockMask::WATER |
- BlockMask::PLAYERWALL))
- {
- localPlayer->navigateTo(playerX + dx, playerY + dy);
- }
- else
- {
- if ((dx != 0) && (dy != 0))
- {
- // try avoid diagonal collision
- if (x2 > y2)
- {
- if (mMap->getWalk(playerX + dx,
- playerY,
- BlockMask::WALL |
- BlockMask::AIR |
- BlockMask::WATER |
- BlockMask::PLAYERWALL))
- {
- dy = 0;
- }
- else
- {
- dx = 0;
- }
- }
- else
- {
- if (mMap->getWalk(playerX,
- playerY + dy,
- BlockMask::WALL |
- BlockMask::AIR |
- BlockMask::WATER |
- BlockMask::PLAYERWALL))
- {
- dx = 0;
- }
- else
- {
- dy = 0;
- }
- }
- }
- else
- {
- // try avoid vertical or horisontal collision
- if (dx == 0)
- {
- if (mMap->getWalk(playerX + 1,
- playerY + dy,
- BlockMask::WALL |
- BlockMask::AIR |
- BlockMask::WATER |
- BlockMask::PLAYERWALL))
- {
- dx = 1;
- }
- if (mMap->getWalk(playerX - 1,
- playerY + dy,
- BlockMask::WALL |
- BlockMask::AIR |
- BlockMask::WATER |
- BlockMask::PLAYERWALL))
- {
- dx = -1;
- }
- }
- if (dy == 0)
- {
- if (mMap->getWalk(playerX + dx,
- playerY + 1,
- BlockMask::WALL |
- BlockMask::AIR |
- BlockMask::WATER |
- BlockMask::PLAYERWALL))
- {
- dy = 1;
- }
- if (mMap->getWalk(playerX + dx,
- playerY - 1,
- BlockMask::WALL |
- BlockMask::AIR |
- BlockMask::WATER |
- BlockMask::PLAYERWALL))
- {
- dy = -1;
- }
- }
- }
- localPlayer->navigateTo(playerX + dx, playerY + dy);
- }
- }
- else
- {
- int destX;
- int destY;
- getMouseTile(event.getX(), event.getY(),
- destX, destY);
- if (playerX != destX || playerY != destY)
- {
- if (!localPlayer->navigateTo(destX, destY))
- {
- if (playerX > destX)
- playerX --;
- else if (playerX < destX)
- playerX ++;
- if (playerY > destY)
- playerY --;
- else if (playerY < destY)
- playerY ++;
- if (mMap->getWalk(playerX, playerY, 0))
- localPlayer->navigateTo(playerX, playerY);
- }
- }
- }
- }
- }
-}
-
-void Viewport::mouseDragged(MouseEvent &event)
-{
- if (event.getSource() != this || event.isConsumed())
- {
- mPlayerFollowMouse = false;
- return;
- }
- if (mAllowMoveByMouse &&
- mMouseClicked &&
- (localPlayer != nullptr) &&
- localPlayer->canMove())
- {
- if (abs(event.getX() - mMousePressX) > 32
- || abs(event.getY() - mMousePressY) > 32)
- {
- mPlayerFollowMouse = true;
- }
-
- walkByMouse(event);
- }
-}
-
-void Viewport::mouseReleased(MouseEvent &event)
-{
- mPlayerFollowMouse = false;
- mLocalWalkTime = -1;
- if (mLongMouseClick && mMouseClicked)
- {
- mMouseClicked = false;
- if (event.getSource() != this || event.isConsumed())
- return;
- const MouseButtonT eventButton = event.getButton();
- if (eventButton == MouseButton::LEFT)
- {
- // long button press
- if ((gui != nullptr) && gui->isLongPress())
- {
- if (openContextMenu(event))
- {
- gui->resetClickCount();
- return;
- }
- }
- else
- {
- if (leftMouseAction())
- return;
- }
- walkByMouse(event);
- }
- }
-}
-
-void Viewport::optionChanged(const std::string &name)
-{
- if (name == "ScrollLaziness")
- mScrollLaziness = config.getIntValue("ScrollLaziness");
- else if (name == "ScrollRadius")
- mScrollRadius = config.getIntValue("ScrollRadius");
- else if (name == "showBeingPopup")
- mShowBeingPopup = config.getBoolValue("showBeingPopup");
- else if (name == "selfMouseHeal")
- mSelfMouseHeal = config.getBoolValue("selfMouseHeal");
- else if (name == "enableLazyScrolling")
- mEnableLazyScrolling = config.getBoolValue("enableLazyScrolling");
- else if (name == "mouseDirectionMove")
- mMouseDirectionMove = config.getBoolValue("mouseDirectionMove");
- else if (name == "longmouseclick")
- mLongMouseClick = config.getBoolValue("longmouseclick");
- else if (name == "allowMoveByMouse")
- mAllowMoveByMouse = config.getBoolValue("allowMoveByMouse");
-}
-
-void Viewport::mouseMoved(MouseEvent &event)
-{
- // Check if we are on the map
- if (mMap == nullptr ||
- localPlayer == nullptr ||
- actorManager == nullptr)
- {
- return;
- }
-
- if (mMouseDirectionMove)
- mPlayerFollowMouse = false;
-
- const int x = mMouseX + mPixelViewX;
- const int y = mMouseY + mPixelViewY;
-
- ActorTypeT type = ActorType::Unknown;
- mHoverBeing = actorManager->findBeingByPixel(x, y, AllPlayers_true);
- if (mHoverBeing != nullptr)
- type = mHoverBeing->getType();
- if ((mHoverBeing != nullptr)
- && (type == ActorType::Player
- || type == ActorType::Npc
- || type == ActorType::Homunculus
- || type == ActorType::Mercenary
- || type == ActorType::Pet))
- {
- PopupManager::hideTextPopup();
- if (mShowBeingPopup && (beingPopup != nullptr))
- beingPopup->show(mMouseX, mMouseY, mHoverBeing);
- }
- else
- {
- PopupManager::hideBeingPopup();
- }
-
- mHoverItem = actorManager->findItem(x / mMap->getTileWidth(),
- y / mMap->getTileHeight());
-
- if ((mHoverBeing == nullptr) && (mHoverItem == nullptr))
- {
- const SpecialLayer *const specialLayer = mMap->getSpecialLayer();
- if (specialLayer != nullptr)
- {
- const int mouseTileX = (mMouseX + mPixelViewX)
- / mMap->getTileWidth();
- const int mouseTileY = (mMouseY + mPixelViewY)
- / mMap->getTileHeight();
-
- mHoverSign = specialLayer->getTile(mouseTileX, mouseTileY);
- if (mHoverSign != nullptr &&
- mHoverSign->getType() != MapItemType::EMPTY)
- {
- if (!mHoverSign->getComment().empty())
- {
- PopupManager::hideBeingPopup();
- if (textPopup != nullptr)
- {
- textPopup->show(mMouseX, mMouseY,
- mHoverSign->getComment());
- }
- }
- else
- {
- if (PopupManager::isTextPopupVisible())
- PopupManager::hideTextPopup();
- }
- gui->setCursorType(Cursor::CURSOR_UP);
- return;
- }
- }
- }
- if (!event.isConsumed() &&
- PopupManager::isTextPopupVisible())
- {
- PopupManager::hideTextPopup();
- }
-
- if (mHoverBeing != nullptr)
- {
- switch (type)
- {
- case ActorType::Npc:
- case ActorType::Monster:
- case ActorType::Portal:
- case ActorType::Pet:
- case ActorType::Mercenary:
- case ActorType::Homunculus:
- case ActorType::SkillUnit:
- case ActorType::Elemental:
- gui->setCursorType(mHoverBeing->getHoverCursor());
- break;
-
- case ActorType::Avatar:
- case ActorType::FloorItem:
- case ActorType::Unknown:
- case ActorType::Player:
- default:
- gui->setCursorType(Cursor::CURSOR_POINTER);
- break;
- }
- }
- // Item mouseover
- else if (mHoverItem != nullptr)
- {
- gui->setCursorType(mHoverItem->getHoverCursor());
- }
- else
- {
- gui->setCursorType(Cursor::CURSOR_POINTER);
- }
-}
-
-void Viewport::toggleMapDrawType()
-{
- settings.mapDrawType = static_cast<MapTypeT>(
- CAST_S32(settings.mapDrawType) + 1);
- if (settings.mapDrawType > MapType::BLACKWHITE)
- settings.mapDrawType = MapType::NORMAL;
- if (mMap != nullptr)
- mMap->setDrawLayersFlags(settings.mapDrawType);
-}
-
-void Viewport::toggleCameraMode()
-{
- settings.cameraMode ++;
- if (settings.cameraMode > 1)
- settings.cameraMode = 0;
- if (settings.cameraMode == 0u)
- {
- mCameraRelativeX = 0;
- mCameraRelativeY = 0;
- updateMidVars();
- }
- UpdateStatusListener::distributeEvent();
-}
-
-void Viewport::clearHover(const ActorSprite *const actor)
-{
- if (mHoverBeing == actor)
- mHoverBeing = nullptr;
-
- if (mHoverItem == actor)
- mHoverItem = nullptr;
-}
-
-void Viewport::cleanHoverItems()
-{
- mHoverBeing = nullptr;
- mHoverItem = nullptr;
- mHoverSign = nullptr;
-}
-
-void Viewport::moveCamera(const int dx, const int dy)
-{
- mCameraRelativeX += dx;
- mCameraRelativeY += dy;
- updateMidVars();
-}
-
-void Viewport::moveCameraToActor(const BeingId actorId,
- const int x, const int y)
-{
- if ((localPlayer == nullptr) || (actorManager == nullptr))
- return;
-
- const Actor *const actor = actorManager->findBeing(actorId);
- if (actor == nullptr)
- return;
- settings.cameraMode = 1;
- mCameraRelativeX = actor->mPixelX - localPlayer->mPixelX + x;
- mCameraRelativeY = actor->mPixelY - localPlayer->mPixelY + y;
- updateMidVars();
-}
-
-void Viewport::moveCameraToPosition(const int x, const int y)
-{
- if (localPlayer == nullptr)
- return;
-
- settings.cameraMode = 1;
- mCameraRelativeX = x - localPlayer->mPixelX;
- mCameraRelativeY = y - localPlayer->mPixelY;
- updateMidVars();
-}
-
-void Viewport::moveCameraRelative(const int x, const int y)
-{
- settings.cameraMode = 1;
- mCameraRelativeX += x;
- mCameraRelativeY += y;
- updateMidVars();
-}
-
-void Viewport::returnCamera()
-{
- settings.cameraMode = 0;
- mCameraRelativeX = 0;
- mCameraRelativeY = 0;
- updateMidVars();
-}
-
-void Viewport::validateSpeed()
-{
- if (!inputManager.isActionActive(InputAction::TARGET_ATTACK) &&
- !inputManager.isActionActive(InputAction::ATTACK))
- {
- if (Game::instance() != nullptr)
- Game::instance()->setValidSpeed();
- }
-}
-
-void Viewport::updateMidVars()
-{
- mMidTileX = (mainGraphics->mWidth + mScrollCenterOffsetX) / 2
- - mCameraRelativeX;
- mMidTileY = (mainGraphics->mHeight + mScrollCenterOffsetY) / 2
- - mCameraRelativeY;
-}
-
-void Viewport::updateMaxVars()
-{
- if (mMap == nullptr)
- return;
- mViewXmax = mMap->getWidth() * mMap->getTileWidth()
- - mainGraphics->mWidth;
- mViewYmax = mMap->getHeight() * mMap->getTileHeight()
- - mainGraphics->mHeight;
-}
-
-void Viewport::videoResized()
-{
- updateMidVars();
- updateMaxVars();
-}
diff --git a/src/progs/manaplus/gui/viewport.h b/src/progs/manaplus/gui/viewport.h
deleted file mode 100644
index 62982fc89..000000000
--- a/src/progs/manaplus/gui/viewport.h
+++ /dev/null
@@ -1,249 +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 PROGS_MANAPLUS_GUI_VIEWPORT_H
-#define PROGS_MANAPLUS_GUI_VIEWPORT_H
-
-#include "position.h"
-
-#include "enums/simpletypes/beingid.h"
-
-#include "gui/widgets/windowcontainer.h"
-
-#include "listeners/mouselistener.h"
-
-class ActorSprite;
-class Being;
-class FloorItem;
-class Graphics;
-class Map;
-class MapItem;
-
-/**
- * The viewport on the map. Displays the current map and handles mouse input
- * and the popup menu.
- */
-class Viewport final : public WindowContainer,
- public MouseListener,
- public ConfigListener
-{
- public:
- /**
- * Constructor.
- */
- Viewport();
-
- A_DELETE_COPY(Viewport)
-
- /**
- * Destructor.
- */
- ~Viewport();
-
- /**
- * Sets the map displayed by the viewport.
- */
- void setMap(Map *const map);
-
- /**
- * Draws the viewport.
- */
- void draw(Graphics *const graphics) override final A_NONNULL(2);
-
- void safeDraw(Graphics *const graphics) override final A_NONNULL(2);
-
- /**
- * Implements player to keep following mouse.
- */
- void logic() override final;
-
- /**
- * Toggles whether the path debug graphics are shown. normal,
- * debug with all images and grid, debug with out big images
- * and with out grid.
- */
- void toggleMapDrawType();
-
- void toggleCameraMode();
-
- /**
- * Handles mouse press on map.
- */
- void mousePressed(MouseEvent &event) override final;
-
- /**
- * Handles mouse move on map
- */
- void mouseDragged(MouseEvent &event) override final;
-
- /**
- * Handles mouse button release on map.
- */
- void mouseReleased(MouseEvent &event) override final;
-
- /**
- * Handles mouse move on map.
- */
- void mouseMoved(MouseEvent &event) override final;
-
- /**
- * A relevant config option changed.
- */
- void optionChanged(const std::string &name) override final;
-
- /**
- * Returns camera x offset in pixels.
- */
- int getCameraX() const noexcept2 A_WARN_UNUSED
- { return mPixelViewX; }
-
- /**
- * Returns camera y offset in pixels.
- */
- int getCameraY() const noexcept2 A_WARN_UNUSED
- { return mPixelViewY; }
-
- /**
- * Changes viewpoint by relative pixel coordinates.
- */
- void scrollBy(const int x, const int y)
- { mPixelViewX += x; mPixelViewY += y; }
-
- /**
- * Clear all hover item, being etc
- */
- void cleanHoverItems();
-
- Map *getMap() const noexcept2 A_WARN_UNUSED
- { return mMap; }
-
- void moveCamera(const int dx, const int dy);
-
- int getCameraRelativeX() const noexcept2 A_WARN_UNUSED
- { return mCameraRelativeX; }
-
- int getCameraRelativeY() const noexcept2 A_WARN_UNUSED
- { return mCameraRelativeY; }
-
- void setCameraRelativeX(const int n)
- { mCameraRelativeX = n; updateMidVars(); }
-
- void setCameraRelativeY(const int n)
- { mCameraRelativeY = n; updateMidVars(); }
-
- void moveCameraToActor(const BeingId actorId,
- const int x = 0,
- const int y = 0);
-
- void moveCameraToPosition(const int x, const int y);
-
- void moveCameraRelative(const int x, const int y);
-
- void returnCamera();
-
- void getMouseTile(int &destX, int &destY) const;
-
- void videoResized();
-
- int mMouseX; /**< Current mouse position in pixels. */
- int mMouseY; /**< Current mouse position in pixels. */
-
- protected:
- friend class ActorManager;
-
- /// Clears any matching hovers
- void clearHover(const ActorSprite *const actor);
-
- void updateMidVars();
-
- void updateMaxVars();
-
- static void validateSpeed();
-
- private:
- /**
- * Finds a path from the player to the mouse, and draws it. This is for
- * debug purposes.
- */
- void drawDebugPath(Graphics *const graphics) A_NONNULL(2);
-
- /**
- * Draws the given path.
- */
- void drawPath(Graphics *const graphics,
- const Path &path,
- const Color &color = Color(255, 0, 0))
- const A_NONNULL(2);
-
- bool leftMouseAction();
-
- bool openContextMenu(const MouseEvent &event);
-
- void walkByMouse(const MouseEvent &event);
-
- void getMouseTile(const int x,
- const int y,
- int &destX,
- int &destY) const;
-
- /**
- * Make the player go to the mouse position.
- */
- void followMouse();
-
- Map *mMap; /**< The current map. */
-
- Being *mHoverBeing; /**< Being mouse is currently over. */
- FloorItem *mHoverItem; /**< FloorItem mouse is currently over. */
- MapItem *mHoverSign; /**< Map sign mouse is currently over. */
-
- int mScrollRadius;
- int mScrollLaziness;
- int mScrollCenterOffsetX;
- int mScrollCenterOffsetY;
- int mMousePressX;
- int mMousePressY;
- int mPixelViewX; /**< Current viewpoint in pixels. */
- int mPixelViewY; /**< Current viewpoint in pixels. */
- int mMidTileX;
- int mMidTileY;
- int mViewXmax;
- int mViewYmax;
-
- time_t mLocalWalkTime;
-
- int mCameraRelativeX;
- int mCameraRelativeY;
-
- bool mShowBeingPopup;
- bool mSelfMouseHeal;
- bool mEnableLazyScrolling;
- bool mMouseDirectionMove;
- bool mLongMouseClick;
- bool mAllowMoveByMouse;
- bool mMouseClicked;
- bool mPlayerFollowMouse;
-};
-
-extern Viewport *viewport; /**< The viewport. */
-
-#endif // PROGS_MANAPLUS_GUI_VIEWPORT_H
diff --git a/src/render/graphics.cpp b/src/render/graphics.cpp
deleted file mode 100644
index 09a21fff1..000000000
--- a/src/render/graphics.cpp
+++ /dev/null
@@ -1,775 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "render/graphics.h"
-
-#ifdef USE_OPENGL
-#include "configuration.h"
-#include "graphicsmanager.h"
-#endif // USE_OPENGL
-
-#if defined(USE_OPENGL) && defined(USE_X11)
-#include "render/openglx/mglxinit.h"
-#endif // defined(USE_OPENGL) && defined(USE_X11)
-
-#ifdef USE_OPENGL
-#include "resources/openglimagehelper.h"
-#ifndef ANDROID
-#include "resources/safeopenglimagehelper.h"
-#endif // ANDROID
-#ifdef __native_client__
-#include "render/nacl/naclfunctions.h"
-#include "render/nacl/naclgles.h"
-#endif // __native_client__
-#else // USE_OPENGL
-#ifndef USE_SDL2
-#include "resources/imagehelper.h"
-#endif // USE_SDL2
-#endif // USE_OPENGL
-
-#ifdef USE_OPENGL
-#ifdef __APPLE__
-#include <OpenGL/OpenGL.h>
-#endif // __APPLE__
-#include "render/opengl/mgldefines.h"
-RENDER_OPENGL_MGLDEFINES_H
-#endif // USE_OPENGL
-
-#include "debug.h"
-
-#ifdef USE_OPENGL
-#ifndef GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX
-#define GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX 0x9049
-#endif // GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX
-#endif // USE_OPENGL
-
-Graphics *mainGraphics A_NONNULLPOINTER = nullptr;
-
-#ifdef USE_SDL2
-SDL_Renderer *restrict Graphics::mRenderer = nullptr;
-#endif // USE_SDL2
-#ifdef USE_OPENGL
-#ifdef USE_SDL2
-SDL_GLContext Graphics::mGLContext = nullptr;
-#else // USE_SDL2
-
-void *restrict Graphics::mGLContext = nullptr;
-#endif // USE_SDL2
-#endif // USE_OPENGL
-
-Graphics::Graphics() :
- mWidth(0),
- mHeight(0),
- mActualWidth(0),
- mActualHeight(0),
- mClipStack(1000),
- mWindow(nullptr),
- mBpp(0),
- mAlpha(false),
- mFullscreen(false),
- mHWAccel(false),
- mRedraw(false),
- mDoubleBuffer(false),
- mRect(),
- mSecure(false),
- mOpenGL(RENDER_SOFTWARE),
- mEnableResize(false),
- mNoFrame(false),
- mAllowHighDPI(false),
- mName("Unknown"),
- mStartFreeMem(0),
- mSync(false),
- mScale(1),
- mColor()
-{
- mRect.x = 0;
- mRect.y = 0;
- mRect.w = 0;
- mRect.h = 0;
-}
-
-Graphics::~Graphics()
-{
- endDraw();
-}
-
-void Graphics::cleanUp()
-{
-#ifdef USE_SDL2
- if (mRenderer)
- {
- SDL_DestroyRenderer(mRenderer);
- mRenderer = nullptr;
- }
-#ifdef USE_OPENGL
- if (mGLContext)
- {
- SDL_GL_DeleteContext(mGLContext);
- mGLContext = nullptr;
- }
-#endif // USE_OPENGL
-#endif // USE_SDL2
-}
-
-void Graphics::setSync(const bool sync) restrict2
-{
- mSync = sync;
-}
-
-void Graphics::setMainFlags(const int w, const int h,
- const int scale,
- const int bpp,
- const bool fs,
- const bool hwaccel,
- const bool resize,
- const bool noFrame,
- const bool allowHighDPI) restrict2
-{
- logger->log("graphics backend: %s", getName().c_str());
- logger->log("Setting video mode %dx%d %s",
- w, h, fs ? "fullscreen" : "windowed");
-
- mBpp = bpp;
- mFullscreen = fs;
- mHWAccel = hwaccel;
- mEnableResize = resize;
- mNoFrame = noFrame;
- mAllowHighDPI = allowHighDPI;
- mActualWidth = w;
- mActualHeight = h;
- setScale(scale);
-}
-
-void Graphics::setScale(int scale) restrict2
-{
- if (isAllowScale())
- {
- if (scale == 0)
- scale = 1;
- int scaleW = mActualWidth / scale;
- int scaleH = mActualHeight / scale;
- if (scaleW < 470)
- {
- scale = mActualWidth / 470;
- if (scale < 1)
- scale = 1;
- scaleH = mActualHeight / scale;
- }
- if (scaleH < 320)
- {
- scale = mActualHeight / 320;
- if (scale < 1)
- scale = 1;
- }
- logger->log("set scale: %d", scale);
- mScale = scale;
- mWidth = mActualWidth / mScale;
- mHeight = mActualHeight / mScale;
- }
- else
- {
- mScale = 1;
- mWidth = mActualWidth;
- mHeight = mActualHeight;
- }
- mRect.w = static_cast<RectSize>(mWidth);
- mRect.h = static_cast<RectSize>(mHeight);
-}
-
-int Graphics::getOpenGLFlags() const restrict2
-{
-#ifdef USE_OPENGL
-
-#ifdef USE_SDL2
- int displayFlags = SDL_WINDOW_OPENGL;
- if (mFullscreen)
- displayFlags |= SDL_WINDOW_FULLSCREEN;
-#if SDL_VERSION_ATLEAST(2, 0, 1)
- if (mAllowHighDPI)
- displayFlags |= SDL_WINDOW_ALLOW_HIGHDPI;
-#endif // SDL_VERSION_ATLEAST(2, 0, 1)
-#else // USE_SDL2
-
- int displayFlags = SDL_ANYFORMAT | SDL_OPENGL;
-#endif // USE_SDL2
-
- if (mFullscreen)
- {
- displayFlags |= SDL_FULLSCREEN;
- }
- else
- {
- // Resizing currently not supported on Windows, where it would require
- // reuploading all textures.
-#if !defined(_WIN32)
- if (mEnableResize)
- displayFlags |= SDL_RESIZABLE;
-#endif // !defined(_WIN32)
- }
-
- if (mNoFrame)
- displayFlags |= SDL_NOFRAME;
-
- return displayFlags;
-#else // USE_OPENGL
-
- return 0;
-#endif // USE_OPENGL
-}
-
-bool Graphics::setOpenGLMode() restrict2
-{
-#ifdef USE_OPENGL
- SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
- if ((mWindow = graphicsManager.createWindow(
- mActualWidth, mActualHeight,
- mBpp, getOpenGLFlags())) == nullptr)
- {
- logger->log("Window/context creation failed");
- mRect.w = 0;
- mRect.h = 0;
- return false;
- }
-
-#if defined(USE_X11)
- Glx::initFunctions();
-#endif // defined(USE_X11)
-#ifdef __native_client__
- NaclGles::initGles();
-#endif // __native_client__
-
-#ifdef USE_SDL2
- int w1 = 0;
- int h1 = 0;
- SDL_GetWindowSize(mWindow, &w1, &h1);
- mRect.w = CAST_S32(w1 / mScale);
- mRect.h = CAST_S32(h1 / mScale);
-
- createGLContext(config.getBoolValue("openglContext"));
-#else // USE_SDL2
-
- createGLContext(config.getBoolValue("openglContext"));
- mRect.w = CAST_U16(mWindow->w / mScale);
- mRect.h = CAST_U16(mWindow->h / mScale);
-
-#endif // USE_SDL2
-
-#ifdef __APPLE__
- if (mSync)
- {
- const GLint VBL = 1;
- CGLSetParameter(CGLGetCurrentContext(), kCGLCPSwapInterval, &VBL);
- }
-#endif // __APPLE__
-
- graphicsManager.setGLVersion();
- graphicsManager.logVersion();
-
- // Setup OpenGL
- glViewport(0, 0, mActualWidth, mActualHeight);
- int gotDoubleBuffer = 0;
- SDL_GL_GetAttribute(SDL_GL_DOUBLEBUFFER, &gotDoubleBuffer);
- logger->log("Using OpenGL %s double buffering.",
- (gotDoubleBuffer != 0 ? "with" : "without"));
-
- graphicsManager.initOpenGL();
- initArrays(graphicsManager.getMaxVertices());
- graphicsManager.updateTextureCompressionFormat();
- graphicsManager.updateTextureFormat();
- updateMemoryInfo();
-
- GLint texSize;
- bool rectTex = graphicsManager.supportExtension(
- "GL_ARB_texture_rectangle") ||
- graphicsManager.supportExtension("GL_EXT_texture_rectangle");
-
- if (rectTex
- && OpenGLImageHelper::getInternalTextureType() == 4
- && getOpenGL() != RENDER_GLES_OPENGL
- && getOpenGL() != RENDER_GLES2_OPENGL
- && getOpenGL() != RENDER_MODERN_OPENGL
- && config.getBoolValue("rectangulartextures")
- && !graphicsManager.isUseTextureSampler())
- {
- logger->log1("using GL_ARB_texture_rectangle");
- OpenGLImageHelper::mTextureType = GL_TEXTURE_RECTANGLE_ARB;
- glEnable(GL_TEXTURE_RECTANGLE_ARB);
- glGetIntegerv(GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB, &texSize);
- OpenGLImageHelper::mTextureSize = texSize;
- logger->log("OpenGL texture size: %d pixels (rectangle textures)",
- OpenGLImageHelper::mTextureSize);
-#ifndef ANDROID
- SafeOpenGLImageHelper::mTextureType = GL_TEXTURE_RECTANGLE_ARB;
- SafeOpenGLImageHelper::mTextureSize = texSize;
-#endif // ANDROID
- }
- else
- {
- glGetIntegerv(GL_MAX_TEXTURE_SIZE, &texSize);
- OpenGLImageHelper::mTextureType = GL_TEXTURE_2D;
- OpenGLImageHelper::mTextureSize = texSize;
-#ifndef ANDROID
- SafeOpenGLImageHelper::mTextureType = GL_TEXTURE_2D;
- SafeOpenGLImageHelper::mTextureSize = texSize;
-#endif // ANDROID
-
- logger->log("OpenGL texture size: %d pixels",
- OpenGLImageHelper::mTextureSize);
- }
- return videoInfo();
-#else // USE_OPENGL
-
- return false;
-#endif // USE_OPENGL
-}
-
-int Graphics::getSoftwareFlags() const restrict2
-{
-#ifdef USE_SDL2
- int displayFlags = SDL_WINDOW_SHOWN;
-#if SDL_VERSION_ATLEAST(2, 0, 1)
- if (mAllowHighDPI)
- displayFlags |= SDL_WINDOW_ALLOW_HIGHDPI;
-#endif // SDL_VERSION_ATLEAST(2, 0, 1)
-#else // USE_SDL2
-
- int displayFlags = SDL_ANYFORMAT;
-
- if (mHWAccel)
- displayFlags |= SDL_HWSURFACE | SDL_DOUBLEBUF;
- else
- displayFlags |= SDL_SWSURFACE;
-#endif // USE_SDL2
-
- if (mFullscreen)
- displayFlags |= SDL_FULLSCREEN;
- else if (mEnableResize)
- displayFlags |= SDL_RESIZABLE;
-
- if (mNoFrame)
- displayFlags |= SDL_NOFRAME;
- return displayFlags;
-}
-
-#ifdef USE_OPENGL
-void Graphics::createGLContext(const bool custom A_UNUSED) restrict2
-{
-#ifdef USE_SDL2
- mGLContext = SDL_GL_CreateContext(mWindow);
-#endif // USE_SDL2
-}
-#endif // USE_OPENGL
-
-void Graphics::updateMemoryInfo() restrict2
-{
-#ifdef USE_OPENGL
- if (mStartFreeMem != 0)
- return;
-
- if (graphicsManager.supportExtension("GL_NVX_gpu_memory_info"))
- {
- glGetIntegerv(GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX,
- &mStartFreeMem);
- logger->log("free video memory: %d", mStartFreeMem);
- }
-#endif // USE_OPENGL
-}
-
-int Graphics::getMemoryUsage() const restrict2
-{
-#ifdef USE_OPENGL
- if (mStartFreeMem == 0)
- return 0;
-
- if (graphicsManager.supportExtension("GL_NVX_gpu_memory_info"))
- {
- GLint val;
- glGetIntegerv(GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX,
- &val);
- return mStartFreeMem - val;
- }
-#endif // USE_OPENGL
- return 0;
-}
-
-#ifdef USE_SDL2
-void Graphics::dumpRendererInfo(const char *restrict const str,
- const SDL_RendererInfo &restrict info)
- restrict2
-{
- logger->log(str, info.name);
- logger->log("flags:");
- if (info.flags & SDL_RENDERER_SOFTWARE)
- logger->log(" software");
- if (info.flags & SDL_RENDERER_ACCELERATED)
- logger->log(" accelerated");
- if (info.flags & SDL_RENDERER_PRESENTVSYNC)
- logger->log(" vsync");
- if (info.flags & SDL_RENDERER_TARGETTEXTURE)
- logger->log(" texture target");
- logger->log("max texture size: %d,%d",
- info.max_texture_width,
- info.max_texture_height);
- const size_t sz = CAST_SIZE(info.num_texture_formats);
- logger->log("texture formats:");
- for (size_t f = 0; f < sz; f ++)
- logger->log(" %u", info.texture_formats[f]);
-}
-#endif // USE_SDL2
-
-bool Graphics::videoInfo() restrict2
-{
- logger->log("SDL video info");
-#ifdef USE_SDL2
- logger->log("Using video driver: %s", SDL_GetCurrentVideoDriver());
-
- if (mRenderer)
- {
- SDL_RendererInfo info;
- SDL_GetRendererInfo(mRenderer, &info);
- dumpRendererInfo("Current SDL renderer name: %s", info);
-
- const int num = SDL_GetNumRenderDrivers();
- logger->log("Known renderers");
- for (int f = 0; f < num; f ++)
- {
- if (!SDL_GetRenderDriverInfo(f, &info))
- dumpRendererInfo("renderer name: %s", info);
- }
- }
-#else // USE_SDL2
-
- char videoDriverName[65];
- if (SDL_VideoDriverName(videoDriverName, 64) != nullptr)
- logger->log("Using video driver: %s", videoDriverName);
- else
- logger->log1("Using video driver: unknown");
- mDoubleBuffer = ((mWindow->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF);
- logger->log("Double buffer mode: %s", mDoubleBuffer ? "yes" : "no");
-
- ImageHelper::dumpSurfaceFormat(mWindow);
-
- const SDL_VideoInfo *restrict const vi = SDL_GetVideoInfo();
- if (vi == nullptr)
- return false;
-
- logger->log("Possible to create hardware surfaces: %s",
- ((vi->hw_available) != 0u ? "yes" : "no"));
- logger->log("Window manager available: %s",
- ((vi->wm_available) != 0u ? "yes" : "no"));
- logger->log("Accelerated hardware to hardware blits: %s",
- ((vi->blit_hw) != 0u ? "yes" : "no"));
- logger->log("Accelerated hardware to hardware colorkey blits: %s",
- ((vi->blit_hw_CC) != 0u ? "yes" : "no"));
- logger->log("Accelerated hardware to hardware alpha blits: %s",
- ((vi->blit_hw_A) != 0u ? "yes" : "no"));
- logger->log("Accelerated software to hardware blits: %s",
- ((vi->blit_sw) != 0u ? "yes" : "no"));
- logger->log("Accelerated software to hardware colorkey blits: %s",
- ((vi->blit_sw_CC) != 0u ? "yes" : "no"));
- logger->log("Accelerated software to hardware alpha blits: %s",
- ((vi->blit_sw_A) != 0u ? "yes" : "no"));
- logger->log("Accelerated color fills: %s",
- ((vi->blit_fill) != 0u ? "yes" : "no"));
-#endif // USE_SDL2
-
- return true;
-}
-
-bool Graphics::setFullscreen(const bool fs) restrict2
-{
- if (mFullscreen == fs)
- return true;
-
- return setVideoMode(mActualWidth,
- mActualHeight,
- mScale,
- mBpp,
- fs,
- mHWAccel,
- mEnableResize,
- mNoFrame,
- mAllowHighDPI);
-}
-
-bool Graphics::resizeScreen(const int width,
- const int height) restrict2
-{
-#ifdef USE_SDL2
- endDraw();
-
- mRect.w = CAST_S32(width / mScale);
- mRect.h = CAST_S32(height / mScale);
- mWidth = width / mScale;
- mHeight = height / mScale;
- mActualWidth = width;
- mActualHeight = height;
-
-#ifdef USE_OPENGL
- // +++ probably this way will not work in windows/mac
- // Setup OpenGL
- glViewport(0, 0, mActualWidth, mActualHeight);
- glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
-#else // USE_OPENGL
- // +++ need impliment resize in soft mode
-#endif // USE_OPENGL
-
- screenResized();
- beginDraw();
- return true;
-
-#else // USE_SDL2
-
- const int prevWidth = mWidth;
- const int prevHeight = mHeight;
-
- endDraw();
-
- bool success = true;
-#ifdef __native_client__
- if (mOpenGL != RENDER_SOFTWARE)
- {
- mRect.w = CAST_S32(width / mScale);
- mRect.h = CAST_S32(height / mScale);
- mWidth = width / mScale;
- mHeight = height / mScale;
- mActualWidth = width;
- mActualHeight = height;
-#ifdef USE_OPENGL
- naclResizeBuffers(mActualWidth, mActualHeight);
- glViewport(0, 0, mActualWidth, mActualHeight);
-#endif // USE_OPENGL
- }
- else
-#endif // __native_client__
- {
- success = setVideoMode(width, height,
- mScale,
- mBpp,
- mFullscreen,
- mHWAccel,
- mEnableResize,
- mNoFrame,
- mAllowHighDPI);
-
- // If it didn't work, try to restore the previous size. If that didn't
- // work either, bail out (but then we're in deep trouble).
- if (!success)
- {
- if (!setVideoMode(prevWidth, prevHeight,
- mScale,
- mBpp,
- mFullscreen,
- mHWAccel,
- mEnableResize,
- mNoFrame,
- mAllowHighDPI))
- {
- return false;
- }
- }
- }
-
- screenResized();
- beginDraw();
-
- return success;
-#endif // USE_SDL2
-}
-
-int Graphics::getWidth() const restrict2
-{
- return mWidth;
-}
-
-int Graphics::getHeight() const restrict2
-{
- return mHeight;
-}
-
-void Graphics::drawNet(const int x1, const int y1,
- const int x2, const int y2,
- const int width, const int height) restrict2
-{
- for (int y = y1; y < y2; y += height)
- drawLine(x1, y, x2, y);
-
- for (int x = x1; x < x2; x += width)
- drawLine(x, y1, x, y2);
-}
-
-#ifdef USE_SDL2
-void Graphics::setWindowSize(const int width,
- const int height) restrict2
-{
- SDL_SetWindowSize(mWindow, width, height);
-}
-#else // USE_SDL2
-void Graphics::setWindowSize(const int width A_UNUSED,
- const int height A_UNUSED) restrict2
-{
-}
-#endif // USE_SDL2
-
-void Graphics::pushClipArea(const Rect &restrict area) restrict2
-{
- // Ignore area with a negate width or height
- // by simple pushing an empty clip area
- // to the stack.
- if (area.width < 0 || area.height < 0)
- {
- ClipRect &carea = mClipStack.push();
- carea.x = 0;
- carea.y = 0;
- carea.width = 0;
- carea.height = 0;
- carea.xOffset = 0;
- carea.yOffset = 0;
- return;
- }
-
- if (mClipStack.empty())
- {
- ClipRect &carea = mClipStack.push();
- carea.x = area.x;
- carea.y = area.y;
- carea.width = area.width;
- carea.height = area.height;
- carea.xOffset = area.x;
- carea.yOffset = area.y;
- return;
- }
-
- const ClipRect &top = mClipStack.top();
- ClipRect &carea = mClipStack.push();
- carea.x = area.x + top.xOffset;
- carea.y = area.y + top.yOffset;
- carea.width = area.width;
- carea.height = area.height;
- carea.xOffset = top.xOffset + area.x;
- carea.yOffset = top.yOffset + area.y;
-
- // Clamp the pushed clip rectangle.
- if (carea.x < top.x)
- carea.x = top.x;
-
- if (carea.y < top.y)
- carea.y = top.y;
-
- if (carea.x + carea.width > top.x + top.width)
- {
- carea.width = top.x + top.width - carea.x;
-
- if (carea.width < 0)
- carea.width = 0;
- }
-
- if (carea.y + carea.height > top.y + top.height)
- {
- carea.height = top.y + top.height - carea.y;
-
- if (carea.height < 0)
- carea.height = 0;
- }
-}
-
-void Graphics::popClipArea() restrict2
-{
- if (mClipStack.empty())
- return;
-
- mClipStack.pop();
-}
-
-#ifdef USE_OPENGL
-void Graphics::setOpenGLFlags() restrict2
-{
- // here disable/enable probably need convert to mgl
-
- glEnable(GL_SCISSOR_TEST);
-
- glDisable(GL_MULTISAMPLE);
- glDisable(GL_DITHER);
- glDisable(GL_DEPTH_TEST);
- glDisable(GL_LINE_SMOOTH);
- glDisable(GL_POLYGON_SMOOTH);
- glDisable(GL_STENCIL_TEST);
- glDisable(GL_COLOR_LOGIC_OP);
- glDisable(GL_DEPTH_BOUNDS_TEST_EXT);
- glDisable(GL_DEPTH_CLAMP);
- glDisable(GL_RASTERIZER_DISCARD);
- glDisable(GL_SAMPLE_MASK);
-
-#ifndef ANDROID
-#ifndef __MINGW32__
- glHint(GL_TEXTURE_COMPRESSION_HINT, GL_FASTEST);
-#endif // __MINGW32__
-#endif // ANDROID
-
- glHint(GL_TEXTURE_COMPRESSION_HINT_ARB, GL_FASTEST);
-
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-}
-#endif // USE_OPENGL
diff --git a/src/render/graphics.h b/src/render/graphics.h
deleted file mode 100644
index 87f2f1429..000000000
--- a/src/render/graphics.h
+++ /dev/null
@@ -1,557 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef RENDER_GRAPHICS_H
-#define RENDER_GRAPHICS_H
-
-#include "sdlshared.h"
-
-#include "enums/render/rendertype.h"
-
-#include "gui/color.h"
-#include "gui/cliprect.h"
-
-#include "resources/mstack.h"
-
-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 "localconsts.h"
-
-#ifdef USE_SDL2
-#define RectPos int32_t
-#define RectSize int32_t
-#else // USE_SDL2
-#define RectPos int16_t
-#define RectSize uint16_t
-#endif // USE_SDL2
-
-class Image;
-class ImageCollection;
-class ImageRect;
-class ImageVertexes;
-
-struct SDL_Window;
-
-/**
- * A central point of control for graphics.
- */
-class Graphics notfinal
-{
- public:
-#ifdef USE_OPENGL
- friend class OpenGLScreenshotHelper;
-#endif // USE_SDL2
-
- friend class SdlScreenshotHelper;
-
- A_DELETE_COPY(Graphics)
-
- /**
- * Destructor.
- */
- virtual ~Graphics();
-
- static void cleanUp();
-
- /**
- * Alignments for text drawing.
- */
- enum Alignment
- {
- LEFT = 0,
- CENTER,
- RIGHT
- };
-
- void setWindow(SDL_Window *restrict const window,
- const int width, const int height) restrict2 noexcept2
- {
- mWindow = window;
- mRect.w = static_cast<RectSize>(width);
- mRect.h = static_cast<RectSize>(height);
- }
-
- SDL_Window *getWindow() const restrict2 noexcept2
- { return mWindow; }
-
- /**
- * Sets whether vertical refresh syncing is enabled. Takes effect after
- * the next call to setVideoMode(). Only implemented on MacOS for now.
- */
- void setSync(const bool sync) restrict2;
-
- bool getSync() const restrict2 noexcept2 A_WARN_UNUSED
- { return mSync; }
-
- /**
- * Try to create a window with the given settings.
- */
- virtual bool setVideoMode(const int w, const int h,
- const int scale,
- const int bpp,
- const bool fs,
- const bool hwaccel,
- const bool resize,
- const bool noFrame,
- const bool allowHighDPI) restrict2 = 0;
-
- /**
- * Set fullscreen mode.
- */
- bool setFullscreen(const bool fs) restrict2;
-
- /**
- * Resize the window to the specified size.
- */
- virtual bool resizeScreen(const int width,
- const int height) restrict2;
-
- virtual void restoreContext() restrict2
- { }
-
- /**
- * Draws a resclaled version of the image
- */
- virtual void drawRescaledImage(const Image *restrict const image,
- int dstX, int dstY,
- const int desiredWidth,
- const int desiredHeight) restrict2 = 0;
-
- virtual void drawPattern(const Image *restrict const image,
- const int x, const int y,
- const int w, const int h) restrict2 = 0;
-
- /**
- * Draw a pattern based on a rescaled version of the given image...
- */
- virtual void drawRescaledPattern(const Image *restrict const image,
- const int x, const int y,
- const int w, const int h,
- const int scaledWidth,
- const int scaledHeight) restrict2 = 0;
-
- virtual void drawImageRect(const int x, const int y,
- const int w, const int h,
- const ImageRect &restrict imgRect)
- restrict2 = 0;
-
- virtual void calcPattern(ImageVertexes *restrict const vert,
- const Image *restrict const image,
- const int x, const int y,
- const int w, const int h) const restrict2 = 0;
-
- virtual void calcPattern(ImageCollection *restrict const vert,
- const Image *restrict const image,
- const int x, const int y,
- const int w, const int h) const restrict2 = 0;
-
- virtual void calcTileVertexes(ImageVertexes *restrict const vert,
- const Image *restrict const image,
- int x,
- int y) const restrict2 A_NONNULL(2, 3)
- = 0;
-
- virtual void calcTileSDL(ImageVertexes *restrict const vert A_UNUSED,
- int x A_UNUSED,
- int y A_UNUSED) const restrict2
- {
- }
-
- virtual void drawTileVertexes(const ImageVertexes *restrict const vert)
- restrict2 = 0;
-
- virtual void drawTileCollection(const ImageCollection
- *restrict const vertCol) restrict2
- A_NONNULL(2) = 0;
-
- virtual void calcTileCollection(ImageCollection *restrict const
- vertCol,
- const Image *restrict const image,
- int x,
- int y) restrict2 = 0;
-
- virtual void calcWindow(ImageCollection *restrict const vertCol,
- const int x, const int y,
- const int w, const int h,
- const ImageRect &restrict imgRect)
- restrict2 A_NONNULL(2) = 0;
-
- virtual void fillRectangle(const Rect &restrict rectangle)
- restrict2 = 0;
-
- /**
- * Updates the screen. This is done by either copying the buffer to the
- * screen or swapping pages.
- */
- virtual void updateScreen() restrict2 = 0;
-
- void setWindowSize(const int width,
-#ifdef USE_SDL2
- const int height) restrict2;
-#else // USE_SDL2
- const int height) restrict2 A_CONST;
-#endif // USE_SDL2
-
- /**
- * Returns the width of the screen.
- */
- int getWidth() const restrict2 A_WARN_UNUSED;
-
- /**
- * Returns the height of the screen.
- */
- int getHeight() const restrict2 A_WARN_UNUSED;
-
- int getMemoryUsage() const restrict2 A_WARN_UNUSED;
-
- virtual void drawNet(const int x1, const int y1,
- const int x2, const int y2,
- const int width, const int height) restrict2;
-
- ClipRect &getTopClip() const restrict2 A_WARN_UNUSED
- { return mClipStack.top(); }
-
- void setRedraw(const bool n) restrict2 noexcept2
- { mRedraw = n; }
-
- bool getRedraw() const restrict2 noexcept2 A_WARN_UNUSED
- { return mRedraw; }
-
- void setSecure(const bool n) restrict2 noexcept2
- { mSecure = n; }
-
- bool getSecure() const restrict2 noexcept2 A_WARN_UNUSED
- { return mSecure; }
-
- int getBpp() const restrict2 noexcept2 A_WARN_UNUSED
- { return mBpp; }
-
- bool getFullScreen() const restrict2 noexcept2 A_WARN_UNUSED
- { return mFullscreen; }
-
- bool getHWAccel() const restrict2 noexcept2 A_WARN_UNUSED
- { return mHWAccel; }
-
- bool getDoubleBuffer() const restrict2 noexcept2 A_WARN_UNUSED
- { return mDoubleBuffer; }
-
- RenderType getOpenGL() const restrict2 noexcept2 A_WARN_UNUSED
- { return mOpenGL; }
-
- void setNoFrame(const bool n) restrict2 noexcept2
- { mNoFrame = n; }
-
- const std::string &getName() const restrict2 noexcept2 A_WARN_UNUSED
- { return mName; }
-
- virtual void initArrays(const int vertCount A_UNUSED) restrict2
- { }
-
- virtual void setColor(const Color &restrict color) restrict2
- {
- mColor = color;
- mAlpha = (color.a != 255);
- }
-
- const Color &getColor() const restrict2 noexcept2
- { return mColor; }
-
-#ifdef DEBUG_DRAW_CALLS
- virtual unsigned int getDrawCalls() const restrict2
- { return 0; }
-#endif // DEBUG_DRAW_CALLS
-#ifdef DEBUG_BIND_TEXTURE
- virtual unsigned int getBinds() const restrict2
- { return 0; }
-#endif // DEBUG_BIND_TEXTURE
-#ifdef USE_SDL2
- void dumpRendererInfo(const char *restrict const str,
- const SDL_RendererInfo &restrict info) restrict2;
-
- virtual void setRendererFlags(const uint32_t flags A_UNUSED) restrict2
- { }
-#endif // USE_SDL2
-
- /**
- * Blits an image onto the screen.
- *
- * @return <code>true</code> if the image was blitted properly
- * <code>false</code> otherwise.
- */
- virtual void drawImage(const Image *restrict const image,
- int dstX, int dstY) restrict2 = 0;
-
- virtual void copyImage(const Image *restrict const image,
- int dstX, int dstY) restrict2 = 0;
-
- virtual void drawImageCached(const Image *restrict const image,
- int srcX, int srcY) restrict2 = 0;
-
- virtual void drawPatternCached(const Image *restrict const image,
- const int x, const int y,
- const int w, const int h) restrict2 = 0;
-
- virtual void completeCache() restrict2 = 0;
-
- int getScale() const restrict2 noexcept2
- { return mScale; }
-
- virtual bool isAllowScale() const restrict2 noexcept2
- { return false; }
-
- void setScale(int scale) restrict2;
-
- /**
- * Pushes a clip area onto the stack. The x and y coordinates in the
- * rectangle is relative to the last pushed clip area.
- * If the new area falls outside the current clip area, it will be
- * clipped as necessary.
- *
- * If a clip area is outside of the top clip area a clip area with
- * zero width and height will be pushed.
- *
- * @param area The clip area to be pushed onto the stack.
- */
- virtual void pushClipArea(const Rect &restrict area) restrict2;
-
- /**
- * Removes the top most clip area from the stack.
- *
- * @throws Exception if the stack is empty.
- */
- virtual void popClipArea() restrict2;
-
- /**
- * Ddraws a line.
- *
- * @param x1 The first x coordinate.
- * @param y1 The first y coordinate.
- * @param x2 The second x coordinate.
- * @param y2 The second y coordinate.
- */
- virtual void drawLine(int x1, int y1,
- int x2, int y2) restrict2 = 0;
-
- /**
- * Draws a simple, non-filled, rectangle with a one pixel width.
- *
- * @param rectangle The rectangle to draw.
- */
- virtual void drawRectangle(const Rect &restrict rectangle)
- restrict2 = 0;
-
-#ifdef USE_OPENGL
-#ifdef USE_SDL2
- virtual void createGLContext(const bool custom) restrict2;
-#else // USE_SDL2
-
- virtual void createGLContext(const bool custom) restrict2 A_CONST;
-#endif // USE_SDL2
-#endif // USE_OPENGL
-
- /**
- * Draws a single point/pixel.
- *
- * @param x The x coordinate.
- * @param y The y coordinate.
- */
- virtual void drawPoint(int x, int y) restrict2 = 0;
-
- /**
- * Initializes drawing. Called by the Gui when Gui::draw() is called.
- * It is needed by some implementations of Graphics to perform
- * preparations before drawing. An example of such an implementation
- * is the OpenGLGraphics.
- *
- * NOTE: You will never need to call this function yourself, unless
- * you use a Graphics object outside of Guichan.
- *
- * @see endDraw, Gui::draw
- */
- virtual void beginDraw() restrict2
- { }
-
- /**
- * Deinitializes drawing. Called by the Gui when a Gui::draw() is done.
- * done. It should reset any state changes made by beginDraw().
- *
- * NOTE: You will never need to call this function yourself, unless
- * you use a Graphics object outside of Guichan.
- *
- * @see beginDraw, Gui::draw
- */
- virtual void endDraw() restrict2
- { }
-
- virtual void clearScreen() const restrict2
- { }
-
- virtual void deleteArrays() restrict2
- { }
-
- virtual void postInit() restrict2
- { }
-
- virtual void finalize(ImageCollection *restrict const col A_UNUSED)
- restrict2
- { }
-
- virtual void finalize(ImageVertexes *restrict const vert A_UNUSED)
- restrict2
- { }
-
- virtual void testDraw() restrict2
- { }
-
- virtual void removeArray(const uint32_t sz A_UNUSED,
- uint32_t *restrict const arr A_UNUSED)
- restrict2
- { }
-
- virtual void screenResized() restrict2
- { }
-
- int mWidth;
- int mHeight;
- int mActualWidth;
- int mActualHeight;
-
- protected:
- /**
- * Constructor.
- */
- Graphics();
-
- void setMainFlags(const int w, const int h,
- const int scale,
- const int bpp,
- const bool fs,
- const bool hwaccel,
- const bool resize,
- const bool noFrame,
- const bool allowHighDPI) restrict2;
-
- int getOpenGLFlags() const restrict2 A_WARN_UNUSED;
-
- int getSoftwareFlags() const restrict2 A_WARN_UNUSED;
-
- bool setOpenGLMode() restrict2;
-
- void updateMemoryInfo() restrict2;
-
- bool videoInfo() restrict2;
-
-#ifdef USE_OPENGL
- void setOpenGLFlags() restrict2;
-#endif // USE_OPENGL
-
- /**
- * Holds the clip area stack.
- */
- MStack<ClipRect> mClipStack;
-
- SDL_Window *restrict mWindow;
-
-#ifdef USE_SDL2
- static SDL_Renderer *restrict mRenderer;
-#endif // USE_SDL2
-#ifdef USE_OPENGL
-#ifdef USE_SDL2
- static SDL_GLContext mGLContext;
-#else // USE_SDL2
-
- static void *restrict mGLContext;
-#endif // USE_SDL2
-#endif // USE_OPENGL
-
- int mBpp;
- bool mAlpha;
- bool mFullscreen;
- bool mHWAccel;
- bool mRedraw;
- bool mDoubleBuffer;
- SDL_Rect mRect;
- bool mSecure;
- RenderType mOpenGL;
- bool mEnableResize;
- bool mNoFrame;
- bool mAllowHighDPI;
- std::string mName;
- int mStartFreeMem;
- bool mSync;
- int mScale;
- Color mColor;
-};
-
-extern Graphics *mainGraphics A_NONNULLPOINTER;
-
-#endif // RENDER_GRAPHICS_H
diff --git a/src/render/graphics_calcImageRect.hpp b/src/render/graphics_calcImageRect.hpp
deleted file mode 100644
index ea04a95cc..000000000
--- a/src/render/graphics_calcImageRect.hpp
+++ /dev/null
@@ -1,94 +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/>.
- */
-
-
-// bool GraphicsX::calcImageRect(ImageVertexes *const vert,
-// const int x, const int y,
-// const int w, const int h,
-// const ImageRect &imgRect)
-
-if (!vert)
- return;
-
-BLOCK_START("Graphics::calcImageRect")
-
-const Image *restrict const *restrict const grid = imgRect.grid;
-const Image *restrict const topLeft = grid[0];
-const Image *restrict const topRight = grid[2];
-const Image *restrict const bottomLeft = grid[6];
-const Image *restrict const bottomRight = grid[8];
-const Image *restrict const top = grid[1];
-const Image *restrict const right = grid[5];
-const Image *restrict const bottom = grid[7];
-const Image *restrict const left = grid[3];
-const Image *restrict const center = grid[4];
-
-const bool drawMain = center && topLeft && topRight
- && bottomLeft && bottomRight;
-
-// Draw the center area
-if (center && drawMain)
-{
- const int tlw = topLeft->getWidth();
- const int tlh = topLeft->getHeight();
- calcPatternInline(vert, center, tlw + x, tlh + y,
- w - tlw - topRight->getWidth(),
- h - tlh - bottomLeft->getHeight());
-}
-// Draw the sides
-if (top && left && bottom && right)
-{
- const int lw = left->getWidth();
- const int rw = right->getWidth();
- const int th = top->getHeight();
- const int bh = bottom->getHeight();
- calcPatternInline(vert, top, x + lw, y, w - lw - rw, th);
- calcPatternInline(vert, bottom, x + lw, y + h - bh, w - lw - rw, bh);
- calcPatternInline(vert, left, x, y + th, lw, h - th - bh);
- if (w > rw)
- calcPatternInline(vert, right, x + w - rw, y + th, rw, h - th - bh);
-}
-
-if (topLeft)
- calcTileVertexesInline(vert, topLeft, x, y);
-if (topRight)
-{
- const int trw = topRight->getWidth();
- if (w > trw)
- calcTileVertexesInline(vert, topRight, x + w - trw, y);
-}
-if (bottomLeft)
-{
- calcTileVertexesInline(vert, bottomLeft,
- x, y + h - bottomLeft->getHeight());
-}
-if (bottomRight)
-{
- const int brw = bottomRight->getWidth();
- if (w > brw)
- {
- calcTileVertexesInline(vert, bottomRight, x + w - brw,
- y + h - bottomRight->getHeight());
- }
-}
-
-BLOCK_END("Graphics::calcImageRect")
diff --git a/src/render/graphics_drawImageRect.hpp b/src/render/graphics_drawImageRect.hpp
deleted file mode 100644
index 1f3c5a38d..000000000
--- a/src/render/graphics_drawImageRect.hpp
+++ /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/>.
- */
-
-
-// void GraphicsX::drawImageRect(const int x, const int y,
-// const int w, const int h,
-// const ImageRect &imgRect)
-
-BLOCK_START("Graphics::drawImageRect")
-
-const Image *restrict const *restrict const grid = imgRect.grid;
-const Image *restrict const topLeft = grid[0];
-const Image *restrict const topRight = grid[2];
-const Image *restrict const bottomLeft = grid[6];
-const Image *restrict const bottomRight = grid[8];
-const Image *restrict const top = grid[1];
-const Image *restrict const right = grid[5];
-const Image *restrict const bottom = grid[7];
-const Image *restrict const left = grid[3];
-const Image *restrict const center = grid[4];
-
-const bool drawMain = center && topLeft && topRight
- && bottomLeft && bottomRight;
-
-// Draw the center area
-if (center && drawMain)
-{
- const int tlw = topLeft->getWidth();
- const int tlh = topLeft->getHeight();
- drawPatternInline(center, tlw + x, tlh + y,
- w - tlw - topRight->getWidth(),
- h - tlh - bottomLeft->getHeight());
-}
-
-// Draw the sides
-if (top && left && bottom && right)
-{
- const int lw = left->getWidth();
- const int rw = right->getWidth();
- const int th = top->getHeight();
- const int bh = bottom->getHeight();
- drawPatternInline(top, x + lw, y, w - lw - rw, th);
- drawPatternInline(bottom, x + lw, h - bh + y, w - lw - rw, bh);
- drawPatternInline(left, x, y + th, lw, h - th - bh);
- if (w > rw)
- drawPatternInline(right, x + w - rw, th + y, rw, h - th - bh);
-}
-// Draw the corners
-if (drawMain)
-{
- drawImageInline(topLeft, x, y);
- const int trw = topRight->getWidth();
- if (w > trw)
- drawImageInline(topRight, x + w - trw, y);
- drawImageInline(bottomLeft, x, h - bottomLeft->getHeight() + y);
- const int brw = bottomRight->getWidth();
- if (w > brw)
- {
- drawImageInline(bottomRight,
- x + w - brw,
- y + h - bottomRight->getHeight());
- }
-}
-BLOCK_END("Graphics::drawImageRect")
diff --git a/src/render/graphicsdef.hpp b/src/render/graphicsdef.hpp
deleted file mode 100644
index 8f8cf93ed..000000000
--- a/src/render/graphicsdef.hpp
+++ /dev/null
@@ -1,154 +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/>.
- */
-
-#define RENDER_GRAPHICSDEF_HPP
-
-public:
- /**
- * Draws a rectangle using images. 4 corner images, 4 side images and 1
- * image for the inside.
- */
- void drawImageRect(int x, int y,
- int w, int h,
- const ImageRect &restrict imgRect)
- restrict2 override final;
-
- void beginDraw() restrict2 override final;
-
- void endDraw() restrict2 override final;
-
- void pushClipArea(const Rect &restrict area) restrict2 override final;
-
- void popClipArea() restrict2 override final;
-
- /**
- * Draws a resclaled version of the image
- */
- void drawRescaledImage(const Image *restrict const image,
- int dstX, int dstY,
- const int desiredWidth,
- const int desiredHeight) restrict2 override final;
-
- void drawPattern(const Image *restrict const image,
- const int x, const int y,
- const int w, const int h) restrict2 override final;
-
- void inline drawPatternInline(const Image *restrict const image,
- const int x, const int y,
- const int w, const int h) restrict2 A_INLINE;
-
- void drawRescaledPattern(const Image *restrict const image,
- const int x, const int y,
- const int w, const int h,
- const int scaledWidth,
- const int scaledHeight) restrict2 override final;
-
- void calcPattern(ImageVertexes *restrict const vert,
- const Image *restrict const image,
- const int x, const int y,
- const int w, const int h) const restrict2 override final;
-
- void calcPattern(ImageCollection *restrict const vert,
- const Image *restrict const image,
- const int x, const int y,
- const int w, const int h) const restrict2 override final;
-
- void calcTileVertexes(ImageVertexes *restrict const vert,
- const Image *restrict const image,
- int x, int y) const restrict2 override final
- A_NONNULL(2, 3);
-
- void calcTileCollection(ImageCollection *restrict const vertCol,
- const Image *restrict const image,
- int x, int y) restrict2 override final;
-
- void drawTileVertexes(const ImageVertexes *restrict const vert)
- restrict2 override final;
-
- void drawTileCollection(const ImageCollection
- *restrict const vertCol) restrict2 override final
- A_NONNULL(2);
-
- void updateScreen() restrict2 override final;
-
- void calcWindow(ImageCollection *restrict const vertCol,
- const int x, const int y,
- const int w, const int h,
- const ImageRect &restrict imgRect)
- restrict2 override final A_NONNULL(2);
-
- void drawRectangle(const Rect &restrict rect) restrict2 override final;
-
- void fillRectangle(const Rect &restrict rect) restrict2 override final;
-
- void drawPoint(int x, int y) restrict2 override final;
-
- void drawLine(int x1, int y1,
- int x2, int y2) restrict2 override final;
-
- bool setVideoMode(const int w, const int h,
- const int scalle,
- const int bpp,
- const bool fs,
- const bool hwaccel,
- const bool resize,
- const bool noFrame,
- const bool allowHighDPI) restrict2 override final;
-
- void drawImage(const Image *restrict const image,
- int dstX, int dstY) restrict2 override final;
-
- void copyImage(const Image *restrict const image,
- int dstX, int dstY) restrict2 override final;
-
- void drawImageCached(const Image *restrict const image,
- int x, int y) restrict2 override final;
-
- void drawPatternCached(const Image *restrict const image,
- const int x, const int y,
- const int w, const int h) restrict2 override final;
-
- void completeCache() restrict2 override final;
-
-private:
- void inline calcImageRect(ImageVertexes *restrict const vert,
- int x, int y,
- int w, int h,
- const ImageRect &restrict imgRect)
- restrict2 A_INLINE;
-
- void inline calcPatternInline(ImageVertexes *restrict const vert,
- const Image *restrict const image,
- const int x,
- const int y,
- const int w,
- const int h) const restrict2 A_INLINE;
-
- void inline calcTileVertexesInline(ImageVertexes *restrict const vert,
- const Image *restrict const image,
- int x,
- int y) const restrict2
- A_INLINE A_NONNULL(2, 3);
-
- void inline drawImageInline(const Image *restrict const image,
- int dstX,
- int dstY) restrict2 A_INLINE;
diff --git a/src/render/imagegraphics.cpp b/src/render/imagegraphics.cpp
deleted file mode 100644
index 02a1f460d..000000000
--- a/src/render/imagegraphics.cpp
+++ /dev/null
@@ -1,64 +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 "render/imagegraphics.h"
-
-#include "debug.h"
-
-ImegeGraphics::ImegeGraphics() :
- Graphics(),
- mTarget(nullptr)
-{
- mOpenGL = RENDER_SOFTWARE;
- mName = "Image";
-}
-
-ImegeGraphics::~ImegeGraphics()
-{
-}
-
-void ImegeGraphics::drawImage(const Image *restrict const image A_UNUSED,
- int dstX A_UNUSED, int dstY A_UNUSED) restrict2
-{
- // for now not implemented
-}
-
-void ImegeGraphics::copyImage(const Image *restrict const image,
- int dstX A_UNUSED, int dstY A_UNUSED) restrict2
-{
- if ((mTarget == nullptr) || (image == nullptr))
- return;
-}
-
-void ImegeGraphics::drawImageCached(const Image *restrict const image,
- int x, int y) restrict2
-{
- drawImage(image, x, y);
-}
-
-void ImegeGraphics::completeCache() restrict2
-{
-}
-
-#endif // USE_OPENGL
diff --git a/src/render/imagegraphics.h b/src/render/imagegraphics.h
deleted file mode 100644
index 2b3e5bd71..000000000
--- a/src/render/imagegraphics.h
+++ /dev/null
@@ -1,208 +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 RENDER_IMAGEGRAPHICS_H
-#define RENDER_IMAGEGRAPHICS_H
-
-#ifdef USE_OPENGL
-
-#include "render/graphics.h"
-
-#include "localconsts.h"
-
-class Image;
-class ImageCollection;
-class ImageVertexes;
-
-/**
- * A central point of control for graphics.
- */
-class ImegeGraphics final : public Graphics
-{
- public:
- ImegeGraphics();
-
- A_DELETE_COPY(ImegeGraphics)
-
- ~ImegeGraphics();
-
- void setTarget(Image *const target) restrict2 noexcept2
- { mTarget = target; }
-
- Image *getTarget() const restrict2 noexcept2
- { return mTarget; }
-
- void beginDraw() restrict2 override final
- { }
-
- void endDraw() restrict2 override final
- { }
-
- void pushClipArea(const Rect &restrict rect A_UNUSED)
- restrict2 override final
- { }
-
- void popClipArea() restrict2 override final
- { }
-
- void drawRescaledImage(const Image *restrict const image A_UNUSED,
- int dstX A_UNUSED, int dstY A_UNUSED,
- const int desiredWidth A_UNUSED,
- const int desiredHeight A_UNUSED)
- restrict2 override final
- { }
-
- void drawPattern(const Image *restrict const image A_UNUSED,
- const int x A_UNUSED,
- const int y A_UNUSED,
- const int w A_UNUSED,
- const int h A_UNUSED) restrict2 override final
- { }
-
- void drawRescaledPattern(const Image *const image A_UNUSED,
- const int x A_UNUSED,
- const int y A_UNUSED,
- const int w A_UNUSED,
- const int h A_UNUSED,
- const int scaledWidth A_UNUSED,
- const int scaledHeight A_UNUSED)
- override final
- { }
-
- void calcPattern(ImageVertexes *restrict const vert A_UNUSED,
- const Image *restrict const image A_UNUSED,
- const int x A_UNUSED,
- const int y A_UNUSED,
- const int w A_UNUSED,
- const int h A_UNUSED) const restrict2 override final
- { }
-
- void calcPattern(ImageCollection *restrict const vert A_UNUSED,
- const Image *restrict const image A_UNUSED,
- const int x A_UNUSED,
- const int y A_UNUSED,
- const int w A_UNUSED,
- const int h A_UNUSED) const restrict2 override final
- { }
-
- void calcTileVertexes(ImageVertexes *restrict const vert A_UNUSED,
- const Image *restrict const image A_UNUSED,
- int x A_UNUSED,
- int y A_UNUSED) const restrict2 override final
- A_NONNULL(2, 3)
- { }
-
- void calcTileSDL(ImageVertexes *restrict const vert A_UNUSED,
- int x A_UNUSED,
- int y A_UNUSED) const restrict2 override final
- { }
-
- void calcTileCollection(ImageCollection *restrict const
- vertCol A_UNUSED,
- const Image *restrict const image A_UNUSED,
- int x A_UNUSED,
- int y A_UNUSED) restrict2 override final
- { }
-
- void drawTileVertexes(const ImageVertexes *const
- vert A_UNUSED) override final
- { }
-
- void drawTileCollection(const ImageCollection *const vertCol A_UNUSED)
- override final A_NONNULL(2)
- { }
-
- void updateScreen() override final
- { }
-
- void drawNet(const int x1 A_UNUSED,
- const int y1 A_UNUSED,
- const int x2 A_UNUSED,
- const int y2 A_UNUSED,
- const int width A_UNUSED,
- const int height A_UNUSED) override final
- { }
-
- void calcWindow(ImageCollection *restrict const vertCol A_UNUSED,
- const int x A_UNUSED, const int y A_UNUSED,
- const int w A_UNUSED, const int h A_UNUSED,
- const ImageRect &restrict imgRect A_UNUSED)
- restrict2 override final A_NONNULL(2)
- { }
-
- void fillRectangle(const Rect &rect A_UNUSED) override final
- { }
-
- void drawRectangle(const Rect &rect A_UNUSED) restrict2 override final
- { }
-
- void drawPoint(int x A_UNUSED, int y A_UNUSED) override final
- { }
-
- void drawLine(int x1 A_UNUSED, int y1 A_UNUSED,
- int x2 A_UNUSED, int y2 A_UNUSED)
- restrict2 override final
- { }
-
- bool setVideoMode(const int w A_UNUSED, const int h A_UNUSED,
- const int scale A_UNUSED,
- const int bpp A_UNUSED,
- const bool fs A_UNUSED, const bool hwaccel A_UNUSED,
- const bool resize A_UNUSED,
- const bool noFrame A_UNUSED,
- const bool allowHighDPI A_UNUSED)
- restrict2 override final
- { return false; }
-
- void drawImage(const Image *const image,
- int dstX, int dstY) override final;
-
- void copyImage(const Image *const image,
- int dstX, int dstY) restrict2 override final;
-
- void drawImageCached(const Image *const image,
- int x, int y) override final;
-
- void drawPatternCached(const Image *restrict const image A_UNUSED,
- const int x A_UNUSED,
- const int y A_UNUSED,
- const int w A_UNUSED,
- const int h A_UNUSED) restrict2 override final
- { }
-
- void completeCache() restrict2 override final;
-
- /**
- * Draws a rectangle using images. 4 corner images, 4 side images and 1
- * image for the inside.
- */
- void drawImageRect(const int x A_UNUSED, const int y A_UNUSED,
- const int w A_UNUSED, const int h A_UNUSED,
- const ImageRect &imgRect A_UNUSED) override final
- { }
-
- protected:
- Image *mTarget;
-};
-
-#endif // USE_OPENGL
-#endif // RENDER_IMAGEGRAPHICS_H
diff --git a/src/render/mobileopengl2graphics.cpp b/src/render/mobileopengl2graphics.cpp
deleted file mode 100644
index 03fe5d016..000000000
--- a/src/render/mobileopengl2graphics.cpp
+++ /dev/null
@@ -1,1389 +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 "render/mobileopengl2graphics.h"
-
-#include "graphicsmanager.h"
-
-#include "render/opengl/mgl.h"
-#ifdef __native_client__
-#include "render/opengl/naclglfunctions.h"
-#endif // __native_client__
-
-#include "render/shaders/shaderprogram.h"
-#include "render/shaders/shadersmanager.h"
-
-#include "render/vertexes/imagecollection.h"
-
-#include "resources/imagerect.h"
-
-#include "resources/image/image.h"
-
-#include "utils/delete2.h"
-#include "utils/foreach.h"
-#include "utils/sdlcheckutils.h"
-
-#include "debug.h"
-
-#define vertFill2D(var, x1, y1, x2, y2, dstX, dstY, w, h) \
- var[vp + 0] = dstX; \
- var[vp + 1] = dstY; \
- var[vp + 2] = x1; \
- var[vp + 3] = y1; \
- \
- var[vp + 4] = dstX + w; \
- var[vp + 5] = dstY; \
- var[vp + 6] = x2; \
- var[vp + 7] = y1; \
- \
- var[vp + 8] = dstX + w; \
- var[vp + 9] = dstY + h; \
- var[vp + 10] = x2; \
- var[vp + 11] = y2; \
- \
- var[vp + 12] = dstX; \
- var[vp + 13] = dstY; \
- var[vp + 14] = x1; \
- var[vp + 15] = y1; \
- \
- var[vp + 16] = dstX; \
- var[vp + 17] = dstY + h; \
- var[vp + 18] = x1; \
- var[vp + 19] = y2; \
- \
- var[vp + 20] = dstX + w; \
- var[vp + 21] = dstY + h; \
- var[vp + 22] = x2; \
- var[vp + 23] = y2;
-
-#define toGL static_cast<GLfloat>
-
-GLuint MobileOpenGL2Graphics::mTextureBinded = 0U;
-GLuint MobileOpenGL2Graphics::mTextureSizeUniform = 0U;
-int MobileOpenGL2Graphics::mTextureWidth = 1;
-int MobileOpenGL2Graphics::mTextureHeight = 1;
-#ifdef DEBUG_DRAW_CALLS
-unsigned int MobileOpenGL2Graphics::mDrawCalls = 0U;
-unsigned int MobileOpenGL2Graphics::mLastDrawCalls = 0U;
-#endif // DEBUG_DRAW_CALLS
-
-MobileOpenGL2Graphics::MobileOpenGL2Graphics() :
- mFloatArray(nullptr),
- mFloatArrayCached(nullptr),
- mProgram(nullptr),
- mAlphaCached(1.0F),
- mVpCached(0),
- mFloatColor(1.0F),
- mMaxVertices(500),
- mProgramId(0U),
- mSimpleColorUniform(0U),
- mPosAttrib(0),
- mTextureColorUniform(0U),
- mScreenUniform(0U),
- mDrawTypeUniform(0U),
-#ifndef __native_client__
- mVao(0U),
-#endif // __native_client__
- mVbo(0U),
- mVboBinded(0U),
- mAttributesBinded(0U),
- mColorAlpha(false),
- mTextureDraw(false),
-#ifdef DEBUG_BIND_TEXTURE
- mOldTexture(),
- mOldTextureId(0),
-#endif // DEBUG_BIND_TEXTURE
- mFbo()
-{
- mOpenGL = RENDER_GLES2_OPENGL;
- mName = "mobile OpenGL ES 2";
-}
-
-MobileOpenGL2Graphics::~MobileOpenGL2Graphics()
-{
- deleteArraysInternal();
- deleteGLObjects();
-}
-
-void MobileOpenGL2Graphics::deleteGLObjects() restrict2
-{
- delete2(mProgram);
- if (mVbo != 0u)
- mglDeleteBuffers(1, &mVbo);
-#ifndef __native_client__
- if (mVao != 0u)
- mglDeleteVertexArrays(1, &mVao);
-#endif // __native_client__
-}
-
-void MobileOpenGL2Graphics::initArrays(const int vertCount) restrict2
-{
- mMaxVertices = vertCount;
- if (mMaxVertices < 500)
- mMaxVertices = 500;
- else if (mMaxVertices > 1024)
- mMaxVertices = 1024;
-
- // need alocate small size, after if limit reached reallocate to double size
- const size_t sz = mMaxVertices * 4 + 30;
- vertexBufSize = mMaxVertices;
- if (mFloatArray == nullptr)
- mFloatArray = new GLfloat[sz];
- if (mFloatArrayCached == nullptr)
- mFloatArrayCached = new GLfloat[sz];
-}
-
-void MobileOpenGL2Graphics::postInit() restrict2
-{
-#ifndef __native_client__
- mglGenVertexArrays(1, &mVao);
- mglBindVertexArray(mVao);
-#endif // __native_client__
- mglGenBuffers(1, &mVbo);
-// logger->log("gen vbo buffer: %u", mVbo);
- bindArrayBuffer(mVbo);
-
- logger->log("Compiling shaders");
- mProgram = shaders.getGles2Program();
- if (mProgram == nullptr)
- {
- graphicsManager.logError();
- logger->safeError("Shader creation error. See manaplus.log.");
- }
- mProgramId = mProgram->getProgramId();
- if (mProgramId == 0u)
- logger->safeError("Shaders compilation error.");
-
- logger->log("Shaders compilation done.");
- mglUseProgram(mProgramId);
-
- mPosAttrib = 0;
-
- mSimpleColorUniform = mglGetUniformLocation(mProgramId, "color");
- mScreenUniform = mglGetUniformLocation(mProgramId, "screen");
- mDrawTypeUniform = mglGetUniformLocation(mProgramId, "drawType");
- mTextureColorUniform = mglGetUniformLocation(mProgramId, "alpha");
- mTextureSizeUniform = mglGetUniformLocation(mProgramId, "textureSize");
-
- mglUniform1f(mTextureColorUniform, 1.0f);
-
- mglVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, nullptr);
- mglEnableVertexAttribArray(0);
- mAttributesBinded = mVbo;
-
- mglUniform2f(mScreenUniform,
- static_cast<float>(mWidth) / 2.0f,
- static_cast<float>(mHeight) / 2.0f);
- // for safty init texture size to 1x1
- mglUniform2f(mTextureSizeUniform,
- 1.0f,
- 1.0f);
- mglUniform4f(mSimpleColorUniform,
- 0.0F,
- 0.0F,
- 0.0F,
- 0.0F);
-
- mglActiveTexture(GL_TEXTURE0);
-}
-
-void MobileOpenGL2Graphics::screenResized() restrict2
-{
- deleteGLObjects();
- mVboBinded = 0U;
- mAttributesBinded = 0U;
- mColor = Color(0, 0, 0, 0);
- postInit();
-}
-
-void MobileOpenGL2Graphics::deleteArrays() restrict2
-{
- deleteArraysInternal();
-}
-
-void MobileOpenGL2Graphics::deleteArraysInternal() restrict2
-{
- delete [] mFloatArray;
- mFloatArray = nullptr;
- delete [] mFloatArrayCached;
- mFloatArrayCached = nullptr;
-}
-
-bool MobileOpenGL2Graphics::setVideoMode(const int w, const int h,
- const int scale,
- const int bpp,
- const bool fs,
- const bool hwaccel,
- const bool resize,
- const bool noFrame,
- const bool allowHighDPI) restrict2
-{
- setMainFlags(w, h,
- scale,
- bpp,
- fs,
- hwaccel,
- resize,
- noFrame,
- allowHighDPI);
-
- return setOpenGLMode();
-}
-
-void MobileOpenGL2Graphics::setColor(const Color &restrict color) restrict2
-{
- mColorAlpha = (color.a != 255);
- if (mColor != color)
- {
- mColor = color;
- mglUniform4f(mSimpleColorUniform,
- static_cast<float>(color.r) / 255.0F,
- static_cast<float>(color.g) / 255.0F,
- static_cast<float>(color.b) / 255.0F,
- static_cast<float>(color.a) / 255.0F);
- }
-}
-
-void MobileOpenGL2Graphics::setColorAlpha(const float alpha) restrict2
-{
- if (mAlphaCached != alpha)
- {
- mAlphaCached = alpha;
- mglUniform1f(mTextureColorUniform, alpha);
- }
-}
-
-void MobileOpenGL2Graphics::drawQuad(const int srcX,
- const int srcY,
- const int dstX,
- const int dstY,
- const int width,
- const int height) restrict2
-{
- const GLfloat texX2 = static_cast<GLfloat>(srcX + width);
- const GLfloat texY2 = static_cast<GLfloat>(srcY + height);
- const GLfloat x2 = static_cast<GLfloat>(dstX + width);
- const GLfloat y2 = static_cast<GLfloat>(dstY + height);
- const GLfloat srcX2 = toGL(srcX);
- const GLfloat srcY2 = toGL(srcY);
- const GLfloat dstX2 = toGL(dstX);
- const GLfloat dstY2 = toGL(dstY);
-
- GLfloat vertices[] =
- {
- dstX2, dstY2, srcX2, srcY2,
- x2, dstY2, texX2, srcY2,
- dstX2, y2, srcX2, texY2,
- x2, y2, texX2, texY2
- };
-
- mglBufferData(GL_ARRAY_BUFFER, sizeof(vertices),
- vertices, GL_STREAM_DRAW);
-#ifdef DEBUG_DRAW_CALLS
- mDrawCalls ++;
-#endif // DEBUG_DRAW_CALLS
- mglDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
-#ifdef OPENGLERRORS
- graphicsManager.logError();
-#endif // OPENGLERRORS
-}
-
-void MobileOpenGL2Graphics::drawRescaledQuad(const int srcX, const int srcY,
- const int dstX, const int dstY,
- const int width, const int height,
- const int desiredWidth,
- const int desiredHeight) restrict2
-{
- const GLfloat texX2 = static_cast<GLfloat>(srcX + width);
- const GLfloat texY2 = static_cast<GLfloat>(srcY + height);
- const GLfloat x2 = static_cast<GLfloat>(dstX + desiredWidth);
- const GLfloat y2 = static_cast<GLfloat>(dstY + desiredHeight);
- const GLfloat srcX2 = toGL(srcX);
- const GLfloat srcY2 = toGL(srcY);
- const GLfloat dstX2 = toGL(dstX);
- const GLfloat dstY2 = toGL(dstY);
-
- GLfloat vertices[] =
- {
- dstX2, dstY2, srcX2, srcY2,
- x2, dstY2, texX2, srcY2,
- dstX2, y2, srcX2, texY2,
- x2, y2, texX2, texY2
- };
-
- mglBufferData(GL_ARRAY_BUFFER, sizeof(vertices),
- vertices, GL_STREAM_DRAW);
-#ifdef DEBUG_DRAW_CALLS
- mDrawCalls ++;
-#endif // DEBUG_DRAW_CALLS
- mglDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
-#ifdef OPENGLERRORS
- graphicsManager.logError();
-#endif // OPENGLERRORS
-}
-
-void MobileOpenGL2Graphics::drawImage(const Image *restrict const image,
- int dstX, int dstY) restrict2
-{
- drawImageInline(image, dstX, dstY);
-}
-
-void MobileOpenGL2Graphics::drawImageInline(const Image *restrict const image,
- int dstX, int dstY) restrict2
-{
- FUNC_BLOCK("Graphics::drawImage", 1)
- if (image == nullptr)
- return;
-
-#ifdef DEBUG_BIND_TEXTURE
- debugBindTexture(image);
-#endif // DEBUG_BIND_TEXTURE
- bindTexture2(GL_TEXTURE_2D, image);
- enableTexturingAndBlending();
- bindArrayBufferAndAttributes(mVbo);
- setColorAlpha(image->mAlpha);
-
- const ClipRect &clipArea = mClipStack.top();
- const SDL_Rect &imageRect = image->mBounds;
- drawQuad(imageRect.x,
- imageRect.y,
- dstX + clipArea.xOffset,
- dstY + clipArea.yOffset,
- imageRect.w,
- imageRect.h);
-}
-
-void MobileOpenGL2Graphics::copyImage(const Image *restrict const image,
- int dstX, int dstY) restrict2
-{
- drawImageInline(image, dstX, dstY);
-}
-
-void MobileOpenGL2Graphics::testDraw() restrict2
-{
-/*
- GLfloat vertices[] =
- {
- 0, 0, 0, 0,
- 800, 0, 800, 0,
- 0, 600, 0, 600,
- 800, 600, 800, 600
- };
-*/
-// logger->log("allocate: %d, %ld", mVboBinded, sizeof(vertices));
-// mglBufferData(GL_ARRAY_BUFFER, sizeof(vertices),
-// vertices, GL_STREAM_DRAW);
-#ifdef DEBUG_DRAW_CALLS
- mDrawCalls ++;
-#endif // DEBUG_DRAW_CALLS
- mglDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
-// glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_INT, 0);
-#ifdef OPENGLERRORS
- graphicsManager.logError();
-#endif // OPENGLERRORS
-}
-
-void MobileOpenGL2Graphics::drawImageCached(const Image *restrict const image
- A_UNUSED,
- int A_UNUSED x,
- int y A_UNUSED) restrict2
-{
-}
-
-void MobileOpenGL2Graphics::drawPatternCached(const Image *restrict const image
- A_UNUSED,
- const int x A_UNUSED,
- const int y A_UNUSED,
- const int w A_UNUSED,
- const int h A_UNUSED) restrict2
-{
-}
-
-void MobileOpenGL2Graphics::completeCache() restrict2
-{
-}
-
-void MobileOpenGL2Graphics::drawRescaledImage(const Image *
- restrict const image,
- int dstX, int dstY,
- const int desiredWidth,
- const int desiredHeight)
- restrict2
-{
- if (image == nullptr)
- return;
-
- const SDL_Rect &imageRect = image->mBounds;
-
- // Just draw the image normally when no resizing is necessary,
- if (imageRect.w == desiredWidth && imageRect.h == desiredHeight)
- {
- drawImageInline(image, dstX, dstY);
- return;
- }
-
- setColorAlpha(image->mAlpha);
-#ifdef DEBUG_BIND_TEXTURE
- debugBindTexture(image);
-#endif // DEBUG_BIND_TEXTURE
- bindTexture2(GL_TEXTURE_2D, image);
- enableTexturingAndBlending();
- bindArrayBufferAndAttributes(mVbo);
-
- const ClipRect &clipArea = mClipStack.top();
- // Draw a textured quad.
- drawRescaledQuad(imageRect.x,
- imageRect.y,
- dstX + clipArea.xOffset,
- dstY + clipArea.yOffset,
- imageRect.w,
- imageRect.h,
- desiredWidth,
- desiredHeight);
-}
-
-void MobileOpenGL2Graphics::drawPattern(const Image *restrict const image,
- const int x, const int y,
- const int w, const int h) restrict2
-{
- drawPatternInline(image, x, y, w, h);
-}
-
-void MobileOpenGL2Graphics::drawPatternInline(const Image *
- restrict const image,
- const int x, const int y,
- const int w, const int h)
- restrict2
-{
- if (image == nullptr)
- return;
-
- const SDL_Rect &imageRect = image->mBounds;
- const int iw = imageRect.w;
- const int ih = imageRect.h;
-
- if (iw == 0 || ih == 0)
- return;
-
- const int srcX = imageRect.x;
- const int srcY = imageRect.y;
- const GLfloat srcX2 = toGL(srcX);
- const GLfloat srcY2 = toGL(srcY);
- const ClipRect &clipArea = mClipStack.top();
- const int x2 = x + clipArea.xOffset;
- const int y2 = y + clipArea.yOffset;
-
-#ifdef DEBUG_BIND_TEXTURE
- debugBindTexture(image);
-#endif // DEBUG_BIND_TEXTURE
- bindTexture2(GL_TEXTURE_2D, image);
-
- enableTexturingAndBlending();
- bindArrayBufferAndAttributes(mVbo);
- setColorAlpha(image->mAlpha);
-
- unsigned int vp = 0;
- const unsigned int vLimit = mMaxVertices * 4;
-
- for (int py = 0; py < h; py += ih)
- {
- const int height = (py + ih >= h) ? h - py : ih;
- const GLfloat texY2 = static_cast<GLfloat>(srcY + height);
- const GLfloat dstY = static_cast<GLfloat>(y2 + py);
- for (int px = 0; px < w; px += iw)
- {
- const int width = (px + iw >= w) ? w - px : iw;
- const GLfloat dstX = static_cast<GLfloat>(x2 + px);
- const GLfloat texX2 = static_cast<GLfloat>(srcX + width);
-
- vertFill2D(mFloatArray,
- srcX2, srcY2, texX2, texY2,
- dstX, dstY, width, height);
-
- vp += 24;
- if (vp >= vLimit)
- {
- drawTriangleArray(vp);
- vp = 0;
- }
- }
- }
- if (vp > 0)
- drawTriangleArray(vp);
-}
-
-void MobileOpenGL2Graphics::drawRescaledPattern(const Image *
- restrict const image,
- const int x, const int y,
- const int w, const int h,
- const int scaledWidth,
- const int scaledHeight)
- restrict2
-{
- if (image == nullptr)
- return;
-
- if (scaledWidth == 0 || scaledHeight == 0)
- return;
-
- const SDL_Rect &imageRect = image->mBounds;
- const int iw = imageRect.w;
- const int ih = imageRect.h;
- if (iw == 0 || ih == 0)
- return;
-
- const int srcX = imageRect.x;
- const int srcY = imageRect.y;
- const GLfloat srcX2 = toGL(srcX);
- const GLfloat srcY2 = toGL(srcY);
-
-#ifdef DEBUG_BIND_TEXTURE
- debugBindTexture(image);
-#endif // DEBUG_BIND_TEXTURE
- bindTexture2(GL_TEXTURE_2D, image);
-
- enableTexturingAndBlending();
- bindArrayBufferAndAttributes(mVbo);
- setColorAlpha(image->mAlpha);
-
- unsigned int vp = 0;
- const unsigned int vLimit = mMaxVertices * 4;
-
- const ClipRect &clipArea = mClipStack.top();
- const int x2 = x + clipArea.xOffset;
- const int y2 = y + clipArea.yOffset;
-
- const float scaleFactorW = static_cast<float>(scaledWidth) / iw;
- const float scaleFactorH = static_cast<float>(scaledHeight) / ih;
-
- for (int py = 0; py < h; py += scaledHeight)
- {
- const int height = (py + scaledHeight >= h)
- ? h - py : scaledHeight;
- const GLfloat dstY = static_cast<GLfloat>(y2 + py);
- const GLfloat scaledY = srcY + height / scaleFactorH;
- for (int px = 0; px < w; px += scaledWidth)
- {
- const int width = (px + scaledWidth >= w)
- ? w - px : scaledWidth;
- const GLfloat dstX = static_cast<GLfloat>(x2 + px);
- const GLfloat scaledX = srcX + width / scaleFactorW;
-
- vertFill2D(mFloatArray,
- srcX2, srcY2,
- scaledX, scaledY,
- dstX, dstY,
- static_cast<GLfloat>(width), static_cast<GLfloat>(height));
-
- vp += 24;
- if (vp >= vLimit)
- {
- drawTriangleArray(vp);
- vp = 0;
- }
- }
- }
- if (vp > 0)
- drawTriangleArray(vp);
-}
-
-inline void MobileOpenGL2Graphics::drawVertexes(const
- OpenGLGraphicsVertexes &
- restrict ogl) restrict2
-{
- const STD_VECTOR<int> &vp = ogl.mVp;
- const STD_VECTOR<GLuint> &vbos = ogl.mVbo;
- STD_VECTOR<int>::const_iterator ivp;
- STD_VECTOR<GLuint>::const_iterator ivbo;
- const STD_VECTOR<int>::const_iterator ivp_end = vp.end();
-
- for (ivp = vp.begin(), ivbo = vbos.begin();
- ivp != ivp_end;
- ++ ivp, ++ ivbo)
- {
- bindArrayBufferAndAttributes(*ivbo);
-#ifdef DEBUG_DRAW_CALLS
- mDrawCalls ++;
-#endif // DEBUG_DRAW_CALLS
- mglDrawArrays(GL_TRIANGLES, 0, *ivp / 4);
-#ifdef OPENGLERRORS
- graphicsManager.logError();
-#endif // OPENGLERRORS
- }
-}
-
-void MobileOpenGL2Graphics::calcPattern(ImageVertexes *restrict const vert,
- const Image *restrict const image,
- const int x,
- const int y,
- const int w,
- const int h) const restrict2
-{
- calcPatternInline(vert, image, x, y, w, h);
-}
-
-void MobileOpenGL2Graphics::calcPatternInline(ImageVertexes *
- restrict const vert,
- const Image *
- restrict const image,
- const int x,
- const int y,
- const int w,
- const int h) const restrict2
-{
- if (image == nullptr || vert == nullptr)
- return;
-
- const SDL_Rect &imageRect = image->mBounds;
- const int iw = imageRect.w;
- const int ih = imageRect.h;
-
- if (iw == 0 || ih == 0)
- return;
-
- const int srcX = imageRect.x;
- const int srcY = imageRect.y;
- const GLfloat srcX2 = toGL(srcX);
- const GLfloat srcY2 = toGL(srcY);
-
- const ClipRect &clipArea = mClipStack.top();
- const int x2 = x + clipArea.xOffset;
- const int y2 = y + clipArea.yOffset;
-
- const unsigned int vLimit = mMaxVertices * 4;
-
- OpenGLGraphicsVertexes &ogl = vert->ogl;
- unsigned int vp = ogl.continueVp();
-
- GLfloat *floatArray = ogl.continueFloatTexArray();
-
- for (int py = 0; py < h; py += ih)
- {
- const GLfloat height = static_cast<GLfloat>(
- (py + ih >= h) ? h - py : ih);
- const GLfloat dstY = static_cast<GLfloat>(y2 + py);
- const GLfloat texY2 = srcY + height;
- for (int px = 0; px < w; px += iw)
- {
- const GLfloat width = static_cast<GLfloat>(
- (px + iw >= w) ? w - px : iw);
- const GLfloat dstX = static_cast<GLfloat>(x2 + px);
- const GLfloat texX2 = srcX2 + width;
-
- vertFill2D(floatArray,
- srcX2, srcY2, texX2, texY2,
- dstX, dstY, width, height);
-
- vp += 24;
- if (vp >= vLimit)
- {
- floatArray = ogl.switchFloatTexArray();
- ogl.switchVp(vp);
- vp = 0;
- }
- }
- }
- ogl.switchVp(vp);
-}
-
-void MobileOpenGL2Graphics::calcTileCollection(ImageCollection *
- restrict const vertCol,
- const Image *
- restrict const image,
- int x, int y) restrict2
-{
- if (vertCol == nullptr || image == nullptr)
- return;
- if (vertCol->currentGLImage != image->mGLImage)
- {
- ImageVertexes *const vert = new ImageVertexes;
- vertCol->currentGLImage = image->mGLImage;
- vertCol->currentVert = vert;
- vert->image = image;
- vertCol->draws.push_back(vert);
- calcTileVertexesInline(vert, image, x, y);
- }
- else
- {
- calcTileVertexesInline(vertCol->currentVert, image, x, y);
- }
-}
-
-void MobileOpenGL2Graphics::drawTileCollection(const ImageCollection
- *restrict const vertCol)
- restrict2
-{
- enableTexturingAndBlending();
- const ImageVertexesVector &draws = vertCol->draws;
- const ImageCollectionCIter it_end = draws.end();
- for (ImageCollectionCIter it = draws.begin(); it != it_end; ++ it)
- {
- const ImageVertexes *const vert = *it;
- const Image *const image = vert->image;
-
- setColorAlpha(image->mAlpha);
-#ifdef DEBUG_BIND_TEXTURE
- debugBindTexture(image);
-#endif // DEBUG_BIND_TEXTURE
- bindTexture2(GL_TEXTURE_2D, image);
- drawVertexes(vert->ogl);
- }
-}
-
-void MobileOpenGL2Graphics::calcPattern(ImageCollection *restrict const
- vertCol,
- const Image *restrict const image,
- const int x,
- const int y,
- const int w,
- const int h) const restrict2
-{
- if (vertCol == nullptr || image == nullptr)
- return;
- ImageVertexes *vert = nullptr;
- if (vertCol->currentGLImage != image->mGLImage)
- {
- vert = new ImageVertexes;
- vertCol->currentGLImage = image->mGLImage;
- vertCol->currentVert = vert;
- vert->image = image;
- vertCol->draws.push_back(vert);
- }
- else
- {
- vert = vertCol->currentVert;
- }
-
- calcPatternInline(vert, image, x, y, w, h);
-}
-
-void MobileOpenGL2Graphics::calcTileVertexes(ImageVertexes *
- restrict const vert,
- const Image *restrict const image,
- int dstX,
- int dstY) const restrict2
-{
- calcTileVertexesInline(vert, image, dstX, dstY);
-}
-
-void MobileOpenGL2Graphics::calcTileVertexesInline(ImageVertexes *
- restrict const vert,
- const Image *
- restrict const image,
- int dstX,
- int dstY) const restrict2
-{
- const SDL_Rect &imageRect = image->mBounds;
- const int w = imageRect.w;
- const int h = imageRect.h;
-
- if (w == 0 || h == 0)
- return;
-
- const int srcX = imageRect.x;
- const int srcY = imageRect.y;
- const GLfloat srcX2 = toGL(srcX);
- const GLfloat srcY2 = toGL(srcY);
-
- const ClipRect &clipArea = mClipStack.top();
- const GLfloat x2 = static_cast<GLfloat>(dstX + clipArea.xOffset);
- const GLfloat y2 = static_cast<GLfloat>(dstY + clipArea.yOffset);
-
- const unsigned int vLimit = mMaxVertices * 4;
-
- OpenGLGraphicsVertexes &ogl = vert->ogl;
-
- unsigned int vp = ogl.continueVp();
-
- GLfloat texX2 = static_cast<GLfloat>(srcX + w);
- GLfloat texY2 = static_cast<GLfloat>(srcY + h);
-
- GLfloat *const floatArray = ogl.continueFloatTexArray();
-
- vertFill2D(floatArray,
- srcX2, srcY2, texX2, texY2,
- x2, y2, w, h);
-
- vp += 24;
- if (vp >= vLimit)
- {
- ogl.switchFloatTexArray();
- ogl.switchVp(vp);
- vp = 0;
- }
-
- ogl.switchVp(vp);
-}
-
-void MobileOpenGL2Graphics::drawTileVertexes(const ImageVertexes *
- restrict const vert) restrict2
-{
- if (vert == nullptr)
- return;
- const Image *const image = vert->image;
-
- setColorAlpha(image->mAlpha);
-#ifdef DEBUG_BIND_TEXTURE
- debugBindTexture(image);
-#endif // DEBUG_BIND_TEXTURE
- bindTexture2(GL_TEXTURE_2D, image);
- enableTexturingAndBlending();
- bindArrayBufferAndAttributes(mVbo);
-
- drawVertexes(vert->ogl);
-}
-
-void MobileOpenGL2Graphics::calcWindow(ImageCollection *restrict const vertCol,
- const int x, const int y,
- const int w, const int h,
- const ImageRect &restrict imgRect)
- restrict2
-{
- ImageVertexes *vert = nullptr;
- const Image *const image = imgRect.grid[4];
- if (image == nullptr)
- return;
- if (vertCol->currentGLImage != image->mGLImage)
- {
- vert = new ImageVertexes;
- vertCol->currentGLImage = image->mGLImage;
- vertCol->currentVert = vert;
- vert->image = image;
- vertCol->draws.push_back(vert);
- }
- else
- {
- vert = vertCol->currentVert;
- }
- calcImageRect(vert, x, y, w, h, imgRect);
-}
-
-void MobileOpenGL2Graphics::updateScreen() restrict2
-{
- BLOCK_START("Graphics::updateScreen")
-#ifdef DEBUG_DRAW_CALLS
- mLastDrawCalls = mDrawCalls;
- mDrawCalls = 0;
-#endif // DEBUG_DRAW_CALLS
-#ifdef USE_SDL2
- SDL_GL_SwapWindow(mWindow);
-#else // USE_SDL2
- SDL_GL_SwapBuffers();
-#endif // USE_SDL2
-#ifdef DEBUG_OPENGL
- if (isGLNotNull(mglFrameTerminator))
- mglFrameTerminator();
-#endif // DEBUG_OPENGL
- BLOCK_END("Graphics::updateScreen")
-}
-
-void MobileOpenGL2Graphics::beginDraw() restrict2
-{
- setOpenGLFlags();
-#ifndef __native_client__
- mglDisable(GL_VERTEX_PROGRAM_POINT_SIZE_ARB);
- mglHint(GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB, GL_FASTEST);
-#endif // __native_client__
- pushClipArea(Rect(0, 0, mRect.w, mRect.h));
-}
-
-void MobileOpenGL2Graphics::endDraw() restrict2
-{
- popClipArea();
-}
-
-void MobileOpenGL2Graphics::pushClipArea(const Rect &restrict area) restrict2
-{
- Graphics::pushClipArea(area);
- const ClipRect &clipArea = mClipStack.top();
-
- mglScissor(clipArea.x * mScale,
- (mRect.h - clipArea.y - clipArea.height) * mScale,
- clipArea.width * mScale,
- clipArea.height * mScale);
-}
-
-void MobileOpenGL2Graphics::popClipArea() restrict2
-{
- if (mClipStack.empty())
- return;
- Graphics::popClipArea();
- if (mClipStack.empty())
- return;
-
- const ClipRect &clipArea = mClipStack.top();
- mglScissor(clipArea.x * mScale,
- (mRect.h - clipArea.y - clipArea.height) * mScale,
- clipArea.width * mScale,
- clipArea.height * mScale);
-}
-
-void MobileOpenGL2Graphics::drawPoint(int x, int y) restrict2
-{
- disableTexturingAndBlending();
- bindArrayBufferAndAttributes(mVbo);
- const ClipRect &clipArea = mClipStack.top();
- GLfloat vertices[] =
- {
- toGL(x + clipArea.xOffset), toGL(y + clipArea.yOffset), 0.0f, 0.0f
- };
- mglBufferData(GL_ARRAY_BUFFER, sizeof(vertices),
- vertices, GL_STREAM_DRAW);
-#ifdef DEBUG_DRAW_CALLS
- mDrawCalls ++;
-#endif // DEBUG_DRAW_CALLS
- mglDrawArrays(GL_POINTS, 0, 1);
-#ifdef OPENGLERRORS
- graphicsManager.logError();
-#endif // OPENGLERRORS
-}
-
-void MobileOpenGL2Graphics::drawLine(int x1, int y1,
- int x2, int y2) restrict2
-{
- disableTexturingAndBlending();
- bindArrayBufferAndAttributes(mVbo);
- const ClipRect &clipArea = mClipStack.top();
- GLfloat vertices[] =
- {
- toGL(x1 + clipArea.xOffset), toGL(y1 + clipArea.yOffset), 0.0f, 0.0f,
- toGL(x2 + clipArea.xOffset), toGL(y2 + clipArea.yOffset), 0.0f, 0.0f
- };
- mglBufferData(GL_ARRAY_BUFFER, sizeof(vertices),
- vertices, GL_STREAM_DRAW);
-#ifdef DEBUG_DRAW_CALLS
- mDrawCalls ++;
-#endif // DEBUG_DRAW_CALLS
- mglDrawArrays(GL_LINES, 0, 2);
-#ifdef OPENGLERRORS
- graphicsManager.logError();
-#endif // OPENGLERRORS
-}
-
-void MobileOpenGL2Graphics::drawRectangle(const Rect &restrict rect) restrict2
-{
- disableTexturingAndBlending();
- bindArrayBufferAndAttributes(mVbo);
- const ClipRect &clipArea = mClipStack.top();
- const GLfloat x1 = static_cast<GLfloat>(rect.x + clipArea.xOffset);
- const GLfloat y1 = static_cast<GLfloat>(rect.y + clipArea.yOffset);
- const GLfloat x2 = x1 + static_cast<GLfloat>(rect.width);
- const GLfloat y2 = y1 + static_cast<GLfloat>(rect.height);
- GLfloat vertices[] =
- {
- x1, y1, 0.0f, 0.0f,
- x1, y2, 0.0f, 0.0f,
- x2, y2, 0.0f, 0.0f,
- x2, y1, 0.0f, 0.0f
- };
-
- mglBufferData(GL_ARRAY_BUFFER, sizeof(vertices),
- vertices, GL_STREAM_DRAW);
-#ifdef DEBUG_DRAW_CALLS
- mDrawCalls ++;
-#endif // DEBUG_DRAW_CALLS
- mglDrawArrays(GL_LINE_LOOP, 0, 4);
-#ifdef OPENGLERRORS
- graphicsManager.logError();
-#endif // OPENGLERRORS
-}
-
-void MobileOpenGL2Graphics::fillRectangle(const Rect &restrict rect) restrict2
-{
- disableTexturingAndBlending();
- bindArrayBufferAndAttributes(mVbo);
- const ClipRect &clipArea = mClipStack.top();
- const GLfloat x1 = static_cast<GLfloat>(rect.x + clipArea.xOffset);
- const GLfloat y1 = static_cast<GLfloat>(rect.y + clipArea.yOffset);
- const GLfloat x2 = x1 + static_cast<GLfloat>(rect.width);
- const GLfloat y2 = y1 + static_cast<GLfloat>(rect.height);
- GLfloat vertices[] =
- {
- x1, y1, 0.0f, 0.0f,
- x2, y1, 0.0f, 0.0f,
- x1, y2, 0.0f, 0.0f,
- x2, y2, 0.0f, 0.0f
- };
-
- mglBufferData(GL_ARRAY_BUFFER, sizeof(vertices),
- vertices, GL_STREAM_DRAW);
-#ifdef DEBUG_DRAW_CALLS
- mDrawCalls ++;
-#endif // DEBUG_DRAW_CALLS
- mglDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
-#ifdef OPENGLERRORS
- graphicsManager.logError();
-#endif // OPENGLERRORS
-}
-
-void MobileOpenGL2Graphics::enableTexturingAndBlending() restrict2
-{
- if (!mTextureDraw)
- {
- mTextureDraw = true;
- mglUniform1f(mDrawTypeUniform, 1.0f);
- }
- if (!mAlpha)
- {
- mglEnable(GL_BLEND);
- mAlpha = true;
- }
-}
-
-void MobileOpenGL2Graphics::disableTexturingAndBlending() restrict2
-{
- if (mTextureDraw)
- {
- mTextureDraw = false;
- mglUniform1f(mDrawTypeUniform, 0.0f);
- }
- if (mAlpha && !mColorAlpha)
- {
- mglDisable(GL_BLEND);
- mAlpha = false;
- }
- else if (!mAlpha && mColorAlpha)
- {
- mglEnable(GL_BLEND);
- mAlpha = true;
- }
-}
-
-void MobileOpenGL2Graphics::drawRectangle(const Rect &restrict rect A_UNUSED,
- const bool filled A_UNUSED) restrict2
-{
-}
-
-void MobileOpenGL2Graphics::drawNet(const int x1,
- const int y1,
- const int x2,
- const int y2,
- const int width,
- const int height) restrict2
-{
- unsigned int vp = 0;
- const unsigned int vLimit = mMaxVertices * 4;
-
- disableTexturingAndBlending();
- bindArrayBufferAndAttributes(mVbo);
- const ClipRect &clipArea = mClipStack.top();
- const GLfloat dx = static_cast<GLfloat>(clipArea.xOffset);
- const GLfloat dy = static_cast<GLfloat>(clipArea.yOffset);
-
- const GLfloat xs1 = x1 + dx;
- const GLfloat xs2 = x2 + dx;
- const GLfloat ys1 = y1 + dy;
- const GLfloat ys2 = y2 + dy;
-
- for (int y = y1; y < y2; y += height)
- {
- mFloatArray[vp + 0] = xs1;
- mFloatArray[vp + 1] = toGL(y);
- mFloatArray[vp + 2] = 0.0f;
- mFloatArray[vp + 3] = 0.0f;
-
- mFloatArray[vp + 4] = xs2;
- mFloatArray[vp + 5] = toGL(y);
- mFloatArray[vp + 6] = 0.0f;
- mFloatArray[vp + 7] = 0.0f;
-
- vp += 8;
- if (vp >= vLimit)
- {
- drawLineArrays(vp);
- vp = 0;
- }
- }
-
- for (int x = x1; x < x2; x += width)
- {
- mFloatArray[vp + 0] = toGL(x);
- mFloatArray[vp + 1] = ys1;
- mFloatArray[vp + 2] = 0.0f;
- mFloatArray[vp + 3] = 0.0f;
-
- mFloatArray[vp + 4] = toGL(x);
- mFloatArray[vp + 5] = ys2;
- mFloatArray[vp + 6] = 0.0f;
- mFloatArray[vp + 7] = 0.0f;
-
- vp += 8;
- if (vp >= vLimit)
- {
- drawLineArrays(vp);
- vp = 0;
- }
- }
-
- if (vp > 0)
- drawLineArrays(vp);
-}
-
-void MobileOpenGL2Graphics::bindTexture2(const GLenum target,
- const Image *restrict const image)
-{
- const GLuint texture = image->mGLImage;
- if (mTextureBinded != texture)
- {
- mTextureBinded = texture;
- mglBindTexture(target, texture);
- if (mTextureWidth != image->mTexWidth ||
- mTextureHeight != image->mTexHeight)
- {
- mTextureWidth = image->mTexWidth;
- mTextureHeight = image->mTexHeight;
- mglUniform2f(mTextureSizeUniform,
- static_cast<GLfloat>(image->mTexWidth),
- static_cast<GLfloat>(image->mTexHeight));
- }
- }
-}
-
-void MobileOpenGL2Graphics::bindTexture(const GLenum target,
- const GLuint texture)
-{
- if (mTextureBinded != texture)
- {
- // for safty not storing textures because cant update size uniform
- mTextureBinded = 0;
- mglBindTexture(target, texture);
- }
-}
-
-void MobileOpenGL2Graphics::removeArray(const uint32_t sz,
- uint32_t *restrict const arr) restrict2
-{
- mglDeleteBuffers(sz, arr);
- for (size_t f = 0; f < sz; f ++)
- {
- if (arr[f] == mVboBinded)
- mVboBinded = 0;
- }
-}
-
-void MobileOpenGL2Graphics::bindArrayBuffer(const GLuint vbo) restrict2
-{
- if (mVboBinded != vbo)
- {
- mVboBinded = vbo;
- mglBindBuffer(GL_ARRAY_BUFFER, vbo);
- mAttributesBinded = 0U;
- }
-}
-
-void MobileOpenGL2Graphics::bindArrayBufferAndAttributes(const GLuint vbo)
- restrict2
-{
- if (mVboBinded != vbo)
- {
- mVboBinded = vbo;
- mglBindBuffer(GL_ARRAY_BUFFER, vbo);
-
- mAttributesBinded = mVboBinded;
- mglVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, nullptr);
- }
- else if (mAttributesBinded != mVboBinded)
- {
- mAttributesBinded = mVboBinded;
- mglVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, nullptr);
- }
-}
-
-void MobileOpenGL2Graphics::bindAttributes() restrict2
-{
- if (mAttributesBinded != mVboBinded)
- {
- mAttributesBinded = mVboBinded;
- mglVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, nullptr);
- }
-}
-
-void MobileOpenGL2Graphics::dumpSettings()
-{
- GLint test[1000];
- logger->log("\n\n");
- logger->log("start opengl dump");
- for (int f = 0; f < 65535; f ++)
- {
- test[0] = 0;
- test[1] = 0;
- test[2] = 0;
- test[3] = 0;
- mglGetIntegerv(f, &test[0]);
- if (test[0] != 0 || test[1] != 0 || test[2] != 0 || test[3] != 0)
- {
- logger->log("\n%d = %d, %d, %d, %d", f,
- test[0], test[1], test[2], test[3]);
- }
- }
-}
-
-void MobileOpenGL2Graphics::drawImageRect(const int x, const int y,
- const int w, const int h,
- const ImageRect &restrict imgRect)
- restrict2
-{
- #include "render/graphics_drawImageRect.hpp"
-}
-
-void MobileOpenGL2Graphics::calcImageRect(ImageVertexes *restrict const vert,
- const int x, const int y,
- const int w, const int h,
- const ImageRect &restrict imgRect)
- restrict2
-{
- #include "render/graphics_calcImageRect.hpp"
-}
-
-void MobileOpenGL2Graphics::clearScreen() const restrict2
-{
- mglClear(GL_COLOR_BUFFER_BIT |
- GL_DEPTH_BUFFER_BIT |
- GL_STENCIL_BUFFER_BIT);
-}
-
-void MobileOpenGL2Graphics::createGLContext(const bool custom) restrict2
-{
- Graphics::createGLContext(custom);
-/*
- if (mGLContext)
- SDL::makeCurrentContext(mGLContext);
- else
- mGLContext = SDL::createGLContext(mWindow, 2, 0, 0x04);
-*/
-}
-
-void MobileOpenGL2Graphics::finalize(ImageCollection *restrict const col)
- restrict2
-{
- if (col == nullptr)
- return;
- FOR_EACH (ImageCollectionIter, it, col->draws)
- finalize(*it);
-}
-
-void MobileOpenGL2Graphics::finalize(ImageVertexes *restrict const vert)
- restrict2
-{
- // in future need convert in each switchVp/continueVp
-
- if (vert == nullptr)
- return;
- OpenGLGraphicsVertexes &ogl = vert->ogl;
- const STD_VECTOR<int> &vp = ogl.mVp;
- STD_VECTOR<int>::const_iterator ivp;
- const STD_VECTOR<int>::const_iterator ivp_end = vp.end();
- STD_VECTOR<GLfloat*> &floatTexPool = ogl.mFloatTexPool;
- STD_VECTOR<GLfloat*>::const_iterator ft;
- const STD_VECTOR<GLfloat*>::const_iterator ft_end = floatTexPool.end();
- STD_VECTOR<GLuint> &vbos = ogl.mVbo;
- STD_VECTOR<GLuint>::const_iterator ivbo;
-
- const int sz = CAST_S32(floatTexPool.size());
- vbos.resize(sz);
- mglGenBuffers(sz, &vbos[0]);
-
- for (ft = floatTexPool.begin(), ivp = vp.begin(), ivbo = vbos.begin();
- ft != ft_end && ivp != ivp_end;
- ++ ft, ++ ivp, ++ ivbo)
- {
- bindArrayBuffer(*ivbo);
- mglBufferData(GL_ARRAY_BUFFER, (*ivp) * sizeof(GLfloat),
- *ft, GL_STATIC_DRAW);
- }
-
- for (STD_VECTOR<GLfloat*>::iterator it = floatTexPool.begin();
- it != floatTexPool.end(); ++ it)
- {
- delete [] (*it);
- }
- floatTexPool.clear();
-}
-
-void MobileOpenGL2Graphics::drawTriangleArray(const int size) restrict2
-{
- mglBufferData(GL_ARRAY_BUFFER, size * sizeof(GLfloat),
- mFloatArray, GL_STREAM_DRAW);
-#ifdef DEBUG_DRAW_CALLS
- mDrawCalls ++;
-#endif // DEBUG_DRAW_CALLS
- mglDrawArrays(GL_TRIANGLES, 0, size / 4);
-#ifdef OPENGLERRORS
- graphicsManager.logError();
-#endif // OPENGLERRORS
-}
-
-void MobileOpenGL2Graphics::drawTriangleArray(const GLfloat *restrict const
- array,
- const int size) restrict2
-{
- mglBufferData(GL_ARRAY_BUFFER, size * sizeof(GLfloat),
- array, GL_STREAM_DRAW);
-#ifdef DEBUG_DRAW_CALLS
- mDrawCalls ++;
-#endif // DEBUG_DRAW_CALLS
- mglDrawArrays(GL_TRIANGLES, 0, size / 4);
-#ifdef OPENGLERRORS
- graphicsManager.logError();
-#endif // OPENGLERRORS
-}
-
-void MobileOpenGL2Graphics::drawLineArrays(const int size) restrict2
-{
- mglBufferData(GL_ARRAY_BUFFER, size * sizeof(GLfloat),
- mFloatArray, GL_STREAM_DRAW);
-#ifdef DEBUG_DRAW_CALLS
- mDrawCalls ++;
-#endif // DEBUG_DRAW_CALLS
- mglDrawArrays(GL_LINES, 0, size / 4);
-#ifdef OPENGLERRORS
- graphicsManager.logError();
-#endif // OPENGLERRORS
-}
-
-#ifdef DEBUG_BIND_TEXTURE
-void MobileOpenGL2Graphics::debugBindTexture(const Image *restrict const image)
- restrict2
-{
- const std::string texture = image->mIdPath;
- if (mOldTexture != texture)
- {
- if ((!mOldTexture.empty() || !texture.empty())
- && mOldTextureId != image->mGLImage)
- {
- logger->log("bind: %s (%d) to %s (%d)", mOldTexture.c_str(),
- mOldTextureId, texture.c_str(), image->mGLImage);
- }
- mOldTextureId = image->mGLImage;
- mOldTexture = texture;
- }
-}
-#else // DEBUG_BIND_TEXTURE
-void MobileOpenGL2Graphics::debugBindTexture(const Image *restrict const
- image A_UNUSED) restrict2
-{
-}
-#endif // DEBUG_BIND_TEXTURE
-
-#endif // USE_OPENGL
diff --git a/src/render/mobileopengl2graphics.h b/src/render/mobileopengl2graphics.h
deleted file mode 100644
index 3148c5fd7..000000000
--- a/src/render/mobileopengl2graphics.h
+++ /dev/null
@@ -1,164 +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 RENDER_MOBILEOPENGL2GRAPHICS_H
-#define RENDER_MOBILEOPENGL2GRAPHICS_H
-
-#if defined(USE_OPENGL) && !defined(ANDROID)
-
-#include "localconsts.h"
-
-#include "render/graphics.h"
-
-#include "resources/fboinfo.h"
-
-#ifdef ANDROID
-#include <GLES/gl.h>
-#include <GLES/glext.h>
-#include <GLES2/gl2.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)
-#if defined(__APPLE__)
-#include <OpenGL/glext.h>
-#elif !defined(__native_client__)
-#include <GL/glext.h>
-#endif // defined(__APPLE__)
-#endif // ANDROID
-
-class OpenGLGraphicsVertexes;
-class ShaderProgram;
-
-class MobileOpenGL2Graphics final : public Graphics
-{
- public:
- MobileOpenGL2Graphics();
-
- A_DELETE_COPY(MobileOpenGL2Graphics)
-
- ~MobileOpenGL2Graphics();
-
- void postInit() restrict2 override final;
-
- void setColor(const Color &restrict color) restrict2 override final;
-
- void screenResized() restrict2 override final;
-
- void finalize(ImageCollection *restrict const col)
- restrict2 override final;
-
- void finalize(ImageVertexes *restrict const vert)
- restrict2 override final;
-
- void testDraw() restrict2 override final;
-
- void removeArray(const uint32_t id,
- uint32_t *restrict const arr)
- restrict2 override final A_NONNULL(3);
-
- void createGLContext(const bool custom) restrict2 override final;
-
- #include "render/graphicsdef.hpp"
- RENDER_GRAPHICSDEF_HPP
-
- #include "render/openglgraphicsdef.hpp"
- RENDER_OPENGLGRAPHICSDEF_HPP
-
- #include "render/openglgraphicsdefadvanced.hpp"
- RENDER_OPENGLGRAPHICSDEFADVANCED_HPP
-
- private:
- void deleteGLObjects() restrict2;
-
- inline void drawQuad(const int srcX,
- const int srcY,
- const int dstX,
- const int dstY,
- const int width,
- const int height) restrict2 A_INLINE;
-
- inline void drawRescaledQuad(const int srcX, const int srcY,
- const int dstX, const int dstY,
- const int width, const int height,
- const int desiredWidth,
- const int desiredHeight)
- restrict2 A_INLINE;
-
- inline void drawTriangleArray(const int size) restrict2 A_INLINE;
-
- inline void drawTriangleArray(const GLfloat *restrict const array,
- const int size) restrict2 A_INLINE;
-
- inline void drawLineArrays(const int size) restrict2 A_INLINE;
-
- inline void bindArrayBuffer(const GLuint vbo) restrict2 A_INLINE;
-
- inline void bindArrayBufferAndAttributes(const GLuint vbo)
- restrict2 A_INLINE;
-
- inline void bindAttributes() restrict2 A_INLINE;
-
- static void bindTexture2(const GLenum target,
- const Image *restrict const image);
-
- static GLuint mTextureSizeUniform;
- static int mTextureWidth;
- static int mTextureHeight;
-
- GLfloat *mFloatArray A_NONNULLPOINTER;
- GLfloat *mFloatArrayCached A_NONNULLPOINTER;
- ShaderProgram *mProgram;
- float mAlphaCached;
- int mVpCached;
-
- float mFloatColor;
- int mMaxVertices;
- GLuint mProgramId;
- GLuint mSimpleColorUniform;
- GLint mPosAttrib;
- GLint mTextureColorUniform;
- GLuint mScreenUniform;
- GLuint mDrawTypeUniform;
-#ifndef __native_client__
- GLuint mVao;
-#endif // __native_client__
-
- GLuint mVbo;
- GLuint mVboBinded;
- GLuint mAttributesBinded;
- bool mColorAlpha;
- bool mTextureDraw;
-#ifdef DEBUG_BIND_TEXTURE
- std::string mOldTexture;
- unsigned mOldTextureId;
-#endif // DEBUG_BIND_TEXTURE
-
- FBOInfo mFbo;
-};
-#endif // defined(USE_OPENGL) && !defined(ANDROID)
-
-#endif // RENDER_MOBILEOPENGL2GRAPHICS_H
diff --git a/src/render/mobileopenglgraphics.cpp b/src/render/mobileopenglgraphics.cpp
deleted file mode 100644
index 0f3ce09ea..000000000
--- a/src/render/mobileopenglgraphics.cpp
+++ /dev/null
@@ -1,1385 +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(__native_client__)
-
-#include "render/mobileopenglgraphics.h"
-
-#ifdef OPENGLERRORS
-#include "graphicsmanager.h"
-#endif // OPENGLERRORS
-
-#include "render/opengl/mgl.h"
-#ifdef __native_client__
-#include "render/opengl/naclglfunctions.h"
-#endif // __native_client__
-
-#include "render/vertexes/imagecollection.h"
-
-#include "resources/imagerect.h"
-#include "resources/openglimagehelper.h"
-
-#include "resources/image/image.h"
-
-#include "utils/sdlcheckutils.h"
-
-#include "debug.h"
-
-#define vertFill2D(tVar, vVar, x1, y1, x2, y2, dstX, dstY, w, h) \
- tVar[vp + 0] = x1; \
- tVar[vp + 1] = y1; \
- tVar[vp + 2] = x2; \
- tVar[vp + 3] = y1; \
- tVar[vp + 4] = x2; \
- tVar[vp + 5] = y2; \
- tVar[vp + 6] = x1; \
- tVar[vp + 7] = y1; \
- tVar[vp + 8] = x1; \
- tVar[vp + 9] = y2; \
- tVar[vp + 10] = x2; \
- tVar[vp + 11] = y2; \
- vVar[vp + 0] = static_cast<GLshort>(dstX); \
- vVar[vp + 1] = static_cast<GLshort>(dstY); \
- vVar[vp + 2] = static_cast<GLshort>(dstX + w); \
- vVar[vp + 3] = static_cast<GLshort>(dstY); \
- vVar[vp + 4] = static_cast<GLshort>(dstX + w); \
- vVar[vp + 5] = static_cast<GLshort>(dstY + h); \
- vVar[vp + 6] = static_cast<GLshort>(dstX); \
- vVar[vp + 7] = static_cast<GLshort>(dstY); \
- vVar[vp + 8] = static_cast<GLshort>(dstX); \
- vVar[vp + 9] = static_cast<GLshort>(dstY + h); \
- vVar[vp + 10] = static_cast<GLshort>(dstX + w); \
- vVar[vp + 11] = static_cast<GLshort>(dstY + h);
-
-GLuint MobileOpenGLGraphics::mTextureBinded = 0;
-#ifdef DEBUG_DRAW_CALLS
-unsigned int MobileOpenGLGraphics::mDrawCalls = 0;
-unsigned int MobileOpenGLGraphics::mLastDrawCalls = 0;
-#endif // DEBUG_DRAW_CALLS
-
-MobileOpenGLGraphics::MobileOpenGLGraphics() :
- mFloatTexArray(nullptr),
- mShortVertArray(nullptr),
- mFloatTexArrayCached(nullptr),
- mShortVertArrayCached(nullptr),
- mAlphaCached(1.0F),
- mVpCached(0),
- mTexture(false),
- mIsByteColor(false),
- mByteColor(),
- mImageCached(0),
- mFloatColor(1.0F),
- mMaxVertices(500),
- mColorAlpha(false),
-#ifdef DEBUG_BIND_TEXTURE
- mOldTexture(),
- mOldTextureId(0),
-#endif // DEBUG_BIND_TEXTURE
- mFbo()
-{
- mOpenGL = RENDER_GLES_OPENGL;
- mName = "mobile OpenGL ES";
-}
-
-MobileOpenGLGraphics::~MobileOpenGLGraphics()
-{
- deleteArraysInternal();
-}
-
-void MobileOpenGLGraphics::postInit() restrict2
-{
-// glesTest();
-}
-
-void MobileOpenGLGraphics::initArrays(const int vertCount) restrict2
-{
- mMaxVertices = vertCount;
- if (mMaxVertices < 500)
- mMaxVertices = 500;
- else if (mMaxVertices > 1024)
- mMaxVertices = 1024;
-
- // need alocate small size, after if limit reached reallocate to double size
- const size_t sz = mMaxVertices * 4 + 30;
- vertexBufSize = mMaxVertices;
- if (mFloatTexArray == nullptr)
- mFloatTexArray = new GLfloat[sz];
- if (mShortVertArray == nullptr)
- mShortVertArray = new GLshort[sz];
- if (mFloatTexArrayCached == nullptr)
- mFloatTexArrayCached = new GLfloat[sz];
- if (mShortVertArrayCached == nullptr)
- mShortVertArrayCached = new GLshort[sz];
-}
-
-void MobileOpenGLGraphics::deleteArrays() restrict2
-{
- deleteArraysInternal();
-}
-
-void MobileOpenGLGraphics::deleteArraysInternal() restrict2
-{
- delete [] mFloatTexArray;
- mFloatTexArray = nullptr;
- delete [] mShortVertArray;
- mShortVertArray = nullptr;
- delete [] mFloatTexArrayCached;
- mFloatTexArrayCached = nullptr;
- delete [] mShortVertArrayCached;
- mShortVertArrayCached = nullptr;
-}
-
-bool MobileOpenGLGraphics::setVideoMode(const int w, const int h,
- const int scale,
- const int bpp,
- const bool fs,
- const bool hwaccel,
- const bool resize,
- const bool noFrame,
- const bool allowHighDPI) restrict2
-{
- setMainFlags(w, h,
- scale,
- bpp,
- fs,
- hwaccel,
- resize,
- noFrame,
- allowHighDPI);
-
- return setOpenGLMode();
-}
-
-static inline void drawQuad(const Image *restrict const image,
- const int srcX,
- const int srcY,
- const int dstX,
- const int dstY,
- const int width,
- const int height) A_NONNULL(1) A_INLINE;
-
-static inline void drawQuad(const Image *restrict const image,
- const int srcX,
- const int srcY,
- const int dstX,
- const int dstY,
- const int width,
- const int height)
-{
-// if (OpenGLImageHelper::mTextureType == GL_TEXTURE_2D)
- {
- const float tw = static_cast<float>(image->mTexWidth);
- const float th = static_cast<float>(image->mTexHeight);
- // Find OpenGL normalized texture coordinates.
- const float texX1 = static_cast<float>(srcX) / tw;
- const float texY1 = static_cast<float>(srcY) / th;
- const float texX2 = static_cast<float>(srcX + width) / tw;
- const float texY2 = static_cast<float>(srcY + height) / th;
-
- GLfloat tex[] =
- {
- texX1, texY1,
- texX2, texY1,
- texX1, texY2,
- texX2, texY2
- };
-
- GLshort vert[] =
- {
- static_cast<GLshort>(dstX), static_cast<GLshort>(dstY),
- static_cast<GLshort>(dstX + width), static_cast<GLshort>(dstY),
- static_cast<GLshort>(dstX), static_cast<GLshort>(dstY + height),
- static_cast<GLshort>(dstX + width),
- static_cast<GLshort>(dstY + height)
- };
-
- glVertexPointer(2, GL_SHORT, 0, &vert);
- glTexCoordPointer(2, GL_FLOAT, 0, &tex);
-
-#ifdef DEBUG_DRAW_CALLS
- MobileOpenGLGraphics::mDrawCalls ++;
-#endif // DEBUG_DRAW_CALLS
- mglDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
-#ifdef OPENGLERRORS
- graphicsManager.logError();
-#endif // OPENGLERRORS
- }
-}
-
-static inline void drawRescaledQuad(const Image *restrict const image,
- const int srcX, const int srcY,
- const int dstX, const int dstY,
- const int width, const int height,
- const int desiredWidth,
- const int desiredHeight)
- A_NONNULL(1) A_INLINE;
-
-static inline void drawRescaledQuad(const Image *restrict const image,
- const int srcX, const int srcY,
- const int dstX, const int dstY,
- const int width, const int height,
- const int desiredWidth,
- const int desiredHeight)
-{
-// if (OpenGLImageHelper::mTextureType == GL_TEXTURE_2D)
- {
- const float tw = static_cast<float>(image->mTexWidth);
- const float th = static_cast<float>(image->mTexHeight);
- // Find OpenGL normalized texture coordinates.
- const float texX1 = static_cast<float>(srcX) / tw;
- const float texY1 = static_cast<float>(srcY) / th;
- const float texX2 = static_cast<float>(srcX + width) / tw;
- const float texY2 = static_cast<float>(srcY + height) / th;
-
- GLfloat tex[] =
- {
- texX1, texY1,
- texX2, texY1,
- texX1, texY2,
- texX2, texY2
- };
-
- GLshort vert[] =
- {
- static_cast<GLshort>(dstX), static_cast<GLshort>(dstY),
- static_cast<GLshort>(dstX + desiredWidth),
- static_cast<GLshort>(dstY),
- static_cast<GLshort>(dstX), static_cast<GLshort>(
- dstY + desiredHeight),
- static_cast<GLshort>(dstX + desiredWidth),
- static_cast<GLshort>(dstY + desiredHeight)
- };
- glVertexPointer(2, GL_SHORT, 0, &vert);
- glTexCoordPointer(2, GL_FLOAT, 0, &tex);
-
-#ifdef DEBUG_DRAW_CALLS
- MobileOpenGLGraphics::mDrawCalls ++;
-#endif // DEBUG_DRAW_CALLS
- mglDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
-#ifdef OPENGLERRORS
- graphicsManager.logError();
-#endif // OPENGLERRORS
- }
-}
-
-void MobileOpenGLGraphics::drawImage(const Image *restrict const image,
- int dstX, int dstY) restrict2
-{
- drawImageInline(image, dstX, dstY);
-}
-
-void MobileOpenGLGraphics::drawImageInline(const Image *restrict const image,
- int dstX, int dstY) restrict2
-{
- FUNC_BLOCK("Graphics::drawImage", 1)
- if (image == nullptr)
- return;
-
- setColorAlpha(image->mAlpha);
-#ifdef DEBUG_BIND_TEXTURE
- debugBindTexture(image);
-#endif // DEBUG_BIND_TEXTURE
- bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
- enableTexturingAndBlending();
-
- const SDL_Rect &imageRect = image->mBounds;
- drawQuad(image, imageRect.x, imageRect.y,
- dstX, dstY, imageRect.w, imageRect.h);
-}
-
-void MobileOpenGLGraphics::copyImage(const Image *restrict const image,
- int dstX, int dstY) restrict2
-{
- drawImageInline(image, dstX, dstY);
-}
-
-void MobileOpenGLGraphics::drawImageCached(const Image *restrict const image,
- int x, int y) restrict2
-{
- if (image == nullptr)
- return;
-
- if (image->mGLImage != mImageCached)
- {
- completeCache();
- mImageCached = image->mGLImage;
- mAlphaCached = image->mAlpha;
- }
-
- const SDL_Rect &imageRect = image->mBounds;
- const int srcX = imageRect.x;
- const int srcY = imageRect.y;
- const int w = imageRect.w;
- const int h = imageRect.h;
-
- if (w == 0 || h == 0)
- return;
-
- const float tw = static_cast<float>(image->mTexWidth);
- const float th = static_cast<float>(image->mTexHeight);
-
- const unsigned int vLimit = mMaxVertices * 4;
-
- unsigned int vp = mVpCached;
-
- // Draw a set of textured rectangles
-// if (OpenGLImageHelper::mTextureType == GL_TEXTURE_2D)
- {
- float texX1 = static_cast<float>(srcX) / tw;
- float texY1 = static_cast<float>(srcY) / th;
- float texX2 = static_cast<float>(srcX + w) / tw;
- float texY2 = static_cast<float>(srcY + h) / th;
-
- vertFill2D(mFloatTexArrayCached, mShortVertArrayCached,
- texX1, texY1, texX2, texY2,
- x, y, w, h);
-
- vp += 12;
- if (vp >= vLimit)
- {
- completeCache();
- vp = 0;
- }
- else
- {
- mVpCached = vp;
- }
- }
-}
-
-void MobileOpenGLGraphics::drawPatternCached(const Image *restrict const image,
- const int x,
- const int y,
- const int w,
- const int h) restrict2
-{
- if (image == nullptr)
- return;
-
- if (image->mGLImage != mImageCached)
- {
- completeCache();
- mImageCached = image->mGLImage;
- }
-
- const SDL_Rect &imageRect = image->mBounds;
- const int srcX = imageRect.x;
- const int srcY = imageRect.y;
- const int iw = imageRect.w;
- const int ih = imageRect.h;
-
- if (iw == 0 || ih == 0)
- return;
-
- const float tw = static_cast<float>(image->mTexWidth);
- const float th = static_cast<float>(image->mTexHeight);
-
- unsigned int vp = mVpCached;
- const unsigned int vLimit = mMaxVertices * 4;
- const float texX1 = static_cast<float>(srcX) / tw;
- const float texY1 = static_cast<float>(srcY) / th;
-
- for (int py = 0; py < h; py += ih)
- {
- const int height = (py + ih >= h) ? h - py : ih;
- const float texY2 = static_cast<float>(srcY + height) / th;
- const int dstY = y + py;
- for (int px = 0; px < w; px += iw)
- {
- const int width = (px + iw >= w) ? w - px : iw;
- const int dstX = x + px;
-
- const float texX2 = static_cast<float>(srcX + width) / tw;
-
- vertFill2D(mFloatTexArrayCached, mShortVertArrayCached,
- texX1, texY1, texX2, texY2,
- dstX, dstY, width, height);
-
- vp += 12;
- if (vp >= vLimit)
- {
- completeCache();
- vp = 0;
- }
- }
- }
- mVpCached = vp;
-}
-
-void MobileOpenGLGraphics::completeCache() restrict2
-{
- if (mImageCached == 0u)
- return;
-
- setColorAlpha(mAlphaCached);
-#ifdef DEBUG_BIND_TEXTURE
-// debugBindTexture(image);
-#endif // DEBUG_BIND_TEXTURE
- bindTexture(OpenGLImageHelper::mTextureType, mImageCached);
- enableTexturingAndBlending();
-
- drawTriangleArrayfsCached(mVpCached);
- mImageCached = 0;
- mVpCached = 0;
-}
-
-void MobileOpenGLGraphics::drawRescaledImage(const Image *restrict const image,
- int dstX, int dstY,
- const int desiredWidth,
- const int desiredHeight) restrict2
-{
- FUNC_BLOCK("Graphics::drawRescaledImage", 1)
- if (image == nullptr)
- return;
-
- const SDL_Rect &imageRect = image->mBounds;
-
- // Just draw the image normally when no resizing is necessary,
- if (imageRect.w == desiredWidth && imageRect.h == desiredHeight)
- {
- drawImageInline(image, dstX, dstY);
- return;
- }
-
- setColorAlpha(image->mAlpha);
-#ifdef DEBUG_BIND_TEXTURE
- debugBindTexture(image);
-#endif // DEBUG_BIND_TEXTURE
- bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
- enableTexturingAndBlending();
-
- // Draw a textured quad.
- drawRescaledQuad(image, imageRect.x, imageRect.y, dstX, dstY,
- imageRect.w, imageRect.h, desiredWidth, desiredHeight);
-}
-
-void MobileOpenGLGraphics::drawPattern(const Image *restrict const image,
- const int x, const int y,
- const int w, const int h) restrict2
-{
- drawPatternInline(image, x, y, w, h);
-}
-
-void MobileOpenGLGraphics::drawPatternInline(const Image *restrict const image,
- const int x,
- const int y,
- const int w,
- const int h) restrict2
-{
- FUNC_BLOCK("Graphics::drawPattern", 1)
- if (image == nullptr)
- return;
-
- const SDL_Rect &imageRect = image->mBounds;
- const int srcX = imageRect.x;
- const int srcY = imageRect.y;
- const int iw = imageRect.w;
- const int ih = imageRect.h;
-
- if (iw == 0 || ih == 0)
- return;
-
- const float tw = static_cast<float>(image->mTexWidth);
- const float th = static_cast<float>(image->mTexHeight);
-
- setColorAlpha(image->mAlpha);
-
-#ifdef DEBUG_BIND_TEXTURE
- debugBindTexture(image);
-#endif // DEBUG_BIND_TEXTURE
- bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
-
- enableTexturingAndBlending();
-
- unsigned int vp = 0;
- const unsigned int vLimit = mMaxVertices * 4;
- // Draw a set of textured rectangles
- const float texX1 = static_cast<float>(srcX) / tw;
- const float texY1 = static_cast<float>(srcY) / th;
-
- for (int py = 0; py < h; py += ih)
- {
- const int height = (py + ih >= h) ? h - py : ih;
- const float texY2 = static_cast<float>(srcY + height) / th;
- const int dstY = y + py;
- for (int px = 0; px < w; px += iw)
- {
- const int width = (px + iw >= w) ? w - px : iw;
- const int dstX = x + px;
-
- const float texX2 = static_cast<float>(srcX + width) / tw;
-
- vertFill2D(mFloatTexArray, mShortVertArray,
- texX1, texY1, texX2, texY2,
- dstX, dstY, width, height);
-
- vp += 12;
- if (vp >= vLimit)
- {
- drawTriangleArrayfs(vp);
- vp = 0;
- }
- }
- }
- if (vp > 0)
- drawTriangleArrayfs(vp);
-}
-
-void MobileOpenGLGraphics::drawRescaledPattern(const Image *
- restrict const image,
- const int x, const int y,
- const int w, const int h,
- const int scaledWidth,
- const int scaledHeight)
- restrict2
-{
- if (image == nullptr)
- return;
-
- if (scaledWidth == 0 || scaledHeight == 0)
- return;
-
- const SDL_Rect &imageRect = image->mBounds;
- const int srcX = imageRect.x;
- const int srcY = imageRect.y;
- const int iw = imageRect.w;
- const int ih = imageRect.h;
- if (iw == 0 || ih == 0)
- return;
-
- setColorAlpha(image->mAlpha);
-
-#ifdef DEBUG_BIND_TEXTURE
- debugBindTexture(image);
-#endif // DEBUG_BIND_TEXTURE
- bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
-
- enableTexturingAndBlending();
-
- unsigned int vp = 0;
- const unsigned int vLimit = mMaxVertices * 4;
-
- // Draw a set of textured rectangles
- const float tw = static_cast<float>(image->mTexWidth);
- const float th = static_cast<float>(image->mTexHeight);
-
- const float texX1 = static_cast<float>(srcX) / tw;
- const float texY1 = static_cast<float>(srcY) / th;
-
- const float tFractionW = iw / tw;
- const float tFractionH = ih / th;
-
- for (int py = 0; py < h; py += scaledHeight)
- {
- const int height = (py + scaledHeight >= h)
- ? h - py : scaledHeight;
- const int dstY = y + py;
- const float visibleFractionH = static_cast<float>(height)
- / scaledHeight;
- const float texY2 = texY1 + tFractionH * visibleFractionH;
- for (int px = 0; px < w; px += scaledWidth)
- {
- const int width = (px + scaledWidth >= w)
- ? w - px : scaledWidth;
- const int dstX = x + px;
- const float visibleFractionW = static_cast<float>(width)
- / scaledWidth;
- const float texX2 = texX1 + tFractionW * visibleFractionW;
-
- vertFill2D(mFloatTexArray, mShortVertArray,
- texX1, texY1, texX2, texY2,
- dstX, dstY, width, height);
-
- vp += 12;
- if (vp >= vLimit)
- {
- drawTriangleArrayfs(vp);
- vp = 0;
- }
- }
- }
- if (vp > 0)
- drawTriangleArrayfs(vp);
-}
-
-inline void MobileOpenGLGraphics::drawVertexes(const
- OpenGLGraphicsVertexes
- &restrict ogl) restrict2
-{
- const STD_VECTOR<GLshort*> &shortVertPool = ogl.mShortVertPool;
- STD_VECTOR<GLshort*>::const_iterator iv;
- const STD_VECTOR<GLshort*>::const_iterator iv_end = shortVertPool.end();
- const STD_VECTOR<int> &vp = ogl.mVp;
- STD_VECTOR<int>::const_iterator ivp;
- const STD_VECTOR<int>::const_iterator ivp_end = vp.end();
-
- // Draw a set of textured rectangles
-// if (OpenGLImageHelper::mTextureType == GL_TEXTURE_2D)
- {
- const STD_VECTOR<GLfloat*> &floatTexPool = ogl.mFloatTexPool;
- STD_VECTOR<GLfloat*>::const_iterator ft;
- const STD_VECTOR<GLfloat*>::const_iterator
- ft_end = floatTexPool.end();
-
- for (iv = shortVertPool.begin(), ft = floatTexPool.begin(),
- ivp = vp.begin();
- iv != iv_end && ft != ft_end && ivp != ivp_end;
- ++ iv, ++ ft, ++ ivp)
- {
- drawTriangleArrayfs(*iv, *ft, *ivp);
- }
- }
-}
-
-void MobileOpenGLGraphics::calcPattern(ImageVertexes *restrict const vert,
- const Image *restrict const image,
- const int x,
- const int y,
- const int w,
- const int h) const restrict2
-{
- calcPatternInline(vert, image, x, y, w, h);
-}
-
-void MobileOpenGLGraphics::calcPatternInline(ImageVertexes *
- restrict const vert,
- const Image *restrict const image,
- const int x,
- const int y,
- const int w,
- const int h) const restrict2
-{
- if (image == nullptr || vert == nullptr)
- return;
-
- const SDL_Rect &imageRect = image->mBounds;
- const int srcX = imageRect.x;
- const int srcY = imageRect.y;
- const int iw = imageRect.w;
- const int ih = imageRect.h;
-
- if (iw == 0 || ih == 0)
- return;
-
- const float tw = static_cast<float>(image->mTexWidth);
- const float th = static_cast<float>(image->mTexHeight);
-
- const unsigned int vLimit = mMaxVertices * 4;
-
- OpenGLGraphicsVertexes &ogl = vert->ogl;
- unsigned int vp = ogl.continueVp();
-
- // Draw a set of textured rectangles
-// if (OpenGLImageHelper::mTextureType == GL_TEXTURE_2D)
- {
- const float texX1 = static_cast<float>(srcX) / tw;
- const float texY1 = static_cast<float>(srcY) / th;
-
- GLfloat *floatTexArray = ogl.continueFloatTexArray();
- GLshort *shortVertArray = ogl.continueShortVertArray();
-
- for (int py = 0; py < h; py += ih)
- {
- const int height = (py + ih >= h) ? h - py : ih;
- const int dstY = y + py;
- const float texY2 = static_cast<float>(srcY + height) / th;
- for (int px = 0; px < w; px += iw)
- {
- const int width = (px + iw >= w) ? w - px : iw;
- const int dstX = x + px;
- const float texX2 = static_cast<float>(srcX + width) / tw;
-
- vertFill2D(floatTexArray, shortVertArray,
- texX1, texY1, texX2, texY2,
- dstX, dstY, width, height);
-
- vp += 12;
- if (vp >= vLimit)
- {
- floatTexArray = ogl.switchFloatTexArray();
- shortVertArray = ogl.switchShortVertArray();
- ogl.switchVp(vp);
- vp = 0;
- }
- }
- }
- }
- ogl.switchVp(vp);
-}
-
-void MobileOpenGLGraphics::calcTileCollection(ImageCollection *
- restrict const vertCol,
- const Image *
- restrict const image,
- int x, int y) restrict2
-{
- if (vertCol == nullptr || image == nullptr)
- return;
- if (vertCol->currentGLImage != image->mGLImage)
- {
- ImageVertexes *const vert = new ImageVertexes;
- vertCol->currentGLImage = image->mGLImage;
- vertCol->currentVert = vert;
- vert->image = image;
- vertCol->draws.push_back(vert);
- calcTileVertexesInline(vert, image, x, y);
- }
- else
- {
- calcTileVertexesInline(vertCol->currentVert, image, x, y);
- }
-}
-
-void MobileOpenGLGraphics::drawTileCollection(const ImageCollection *
- restrict const vertCol)
- restrict2
-{
- const ImageVertexesVector &draws = vertCol->draws;
- const ImageCollectionCIter it_end = draws.end();
- for (ImageCollectionCIter it = draws.begin(); it != it_end; ++ it)
- {
- const ImageVertexes *const vert = *it;
- const Image *const image = vert->image;
-
- setColorAlpha(image->mAlpha);
-#ifdef DEBUG_BIND_TEXTURE
- debugBindTexture(image);
-#endif // DEBUG_BIND_TEXTURE
- bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
- enableTexturingAndBlending();
- drawVertexes(vert->ogl);
- }
-}
-
-void MobileOpenGLGraphics::calcPattern(ImageCollection *restrict const vertCol,
- const Image *restrict const image,
- const int x,
- const int y,
- const int w,
- const int h) const restrict2
-{
- if (vertCol == nullptr || image == nullptr)
- return;
- ImageVertexes *vert = nullptr;
- if (vertCol->currentGLImage != image->mGLImage)
- {
- vert = new ImageVertexes;
- vertCol->currentGLImage = image->mGLImage;
- vertCol->currentVert = vert;
- vert->image = image;
- vertCol->draws.push_back(vert);
- }
- else
- {
- vert = vertCol->currentVert;
- }
-
- calcPatternInline(vert, image, x, y, w, h);
-}
-
-void MobileOpenGLGraphics::calcTileVertexes(ImageVertexes *restrict const vert,
- const Image *restrict const image,
- int dstX, int dstY) const restrict2
-{
- calcTileVertexesInline(vert, image, dstX, dstY);
-}
-
-void MobileOpenGLGraphics::calcTileVertexesInline(ImageVertexes *
- restrict const vert,
- const Image *
- restrict const image,
- int dstX,
- int dstY) const restrict2
-{
- const SDL_Rect &imageRect = image->mBounds;
- const int srcX = imageRect.x;
- const int srcY = imageRect.y;
- const int w = imageRect.w;
- const int h = imageRect.h;
-
- if (w == 0 || h == 0)
- return;
-
- const float tw = static_cast<float>(image->mTexWidth);
- const float th = static_cast<float>(image->mTexHeight);
-
- const unsigned int vLimit = mMaxVertices * 4;
-
- OpenGLGraphicsVertexes &ogl = vert->ogl;
-
-// STD_VECTOR<int> *vps = ogl.getVp();
- unsigned int vp = ogl.continueVp();
-
- // Draw a set of textured rectangles
-// if (OpenGLImageHelper::mTextureType == GL_TEXTURE_2D)
- {
- float texX1 = static_cast<float>(srcX) / tw;
- float texY1 = static_cast<float>(srcY) / th;
- float texX2 = static_cast<float>(srcX + w) / tw;
- float texY2 = static_cast<float>(srcY + h) / th;
-
- GLfloat *const floatTexArray = ogl.continueFloatTexArray();
- GLshort *const shortVertArray = ogl.continueShortVertArray();
-
- vertFill2D(floatTexArray, shortVertArray,
- texX1, texY1, texX2, texY2,
- dstX, dstY, w, h);
-
- vp += 12;
- if (vp >= vLimit)
- {
- ogl.switchFloatTexArray();
- ogl.switchShortVertArray();
- ogl.switchVp(vp);
- vp = 0;
- }
- }
- ogl.switchVp(vp);
-}
-
-void MobileOpenGLGraphics::drawTileVertexes(const ImageVertexes *
- restrict const vert) restrict2
-{
- if (vert == nullptr)
- return;
- const Image *const image = vert->image;
-
- setColorAlpha(image->mAlpha);
-#ifdef DEBUG_BIND_TEXTURE
- debugBindTexture(image);
-#endif // DEBUG_BIND_TEXTURE
- bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
- enableTexturingAndBlending();
- drawVertexes(vert->ogl);
-}
-
-void MobileOpenGLGraphics::calcWindow(ImageCollection *restrict const vertCol,
- const int x, const int y,
- const int w, const int h,
- const ImageRect &restrict imgRect)
- restrict2
-{
- ImageVertexes *vert = nullptr;
- const Image *const image = imgRect.grid[4];
- if (image == nullptr)
- return;
- if (vertCol->currentGLImage != image->mGLImage)
- {
- vert = new ImageVertexes;
- vertCol->currentGLImage = image->mGLImage;
- vertCol->currentVert = vert;
- vert->image = image;
- vertCol->draws.push_back(vert);
- }
- else
- {
- vert = vertCol->currentVert;
- }
- calcImageRect(vert, x, y, w, h, imgRect);
-}
-
-
-void MobileOpenGLGraphics::updateScreen() restrict2
-{
- BLOCK_START("Graphics::updateScreen")
-// glFlush();
-// glFinish();
-#ifdef DEBUG_DRAW_CALLS
- mLastDrawCalls = mDrawCalls;
- mDrawCalls = 0;
-#endif // DEBUG_DRAW_CALLS
-#ifdef USE_SDL2
- SDL_GL_SwapWindow(mWindow);
-#else // USE_SDL2
-
- SDL_GL_SwapBuffers();
-#endif // USE_SDL2
-#ifdef DEBUG_OPENGL
- if (isGLNotNull(mglFrameTerminator))
- mglFrameTerminator();
-#endif // DEBUG_OPENGL
-
- BLOCK_END("Graphics::updateScreen")
-}
-
-void MobileOpenGLGraphics::beginDraw() restrict2
-{
- glMatrixMode(GL_TEXTURE);
- glLoadIdentity();
-
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
-
-#ifdef ANDROID
- glOrthof(0.0, static_cast<float>(mRect.w),
- static_cast<float>(mRect.h),
- 0.0, -1.0, 1.0);
-#else // ANDROID
-
- glOrtho(0.0, static_cast<double>(mRect.w),
- static_cast<double>(mRect.h),
- 0.0, -1.0, 1.0);
-#endif // ANDROID
-
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
-
- setOpenGLFlags();
- mglDisable(GL_LIGHTING);
- mglDisable(GL_FOG);
- mglDisable(GL_COLOR_MATERIAL);
-
- glShadeModel(GL_FLAT);
-
- glEnableClientState(GL_VERTEX_ARRAY);
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
-
-#ifndef ANDROID
- mglHint(GL_LINE_SMOOTH_HINT, GL_FASTEST);
- mglHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
- mglHint(GL_POINT_SMOOTH_HINT, GL_FASTEST);
- mglHint(GL_POLYGON_SMOOTH_HINT, GL_FASTEST);
-#endif // ANDROID
-
- pushClipArea(Rect(0, 0, mRect.w, mRect.h));
-}
-
-void MobileOpenGLGraphics::endDraw() restrict2
-{
- popClipArea();
-}
-
-void MobileOpenGLGraphics::pushClipArea(const Rect &restrict area) restrict2
-{
- int transX = 0;
- int transY = 0;
-
- if (!mClipStack.empty())
- {
- const ClipRect &clipArea = mClipStack.top();
- transX = -clipArea.xOffset;
- transY = -clipArea.yOffset;
- }
-
- Graphics::pushClipArea(area);
-
- const ClipRect &clipArea = mClipStack.top();
- transX += clipArea.xOffset;
- transY += clipArea.yOffset;
-
- if (transX != 0 || transY != 0)
- {
- glTranslatef(static_cast<GLfloat>(transX),
- static_cast<GLfloat>(transY), 0);
- }
- mglScissor(clipArea.x * mScale,
- (mRect.h - clipArea.y - clipArea.height) * mScale,
- clipArea.width * mScale,
- clipArea.height * mScale);
-}
-
-void MobileOpenGLGraphics::popClipArea() restrict2
-{
- if (mClipStack.empty())
- return;
-
- const ClipRect &clipArea1 = mClipStack.top();
- int transX = -clipArea1.xOffset;
- int transY = -clipArea1.yOffset;
-
- Graphics::popClipArea();
-
- if (mClipStack.empty())
- return;
-
- const ClipRect &clipArea = mClipStack.top();
- transX += clipArea.xOffset;
- transY += clipArea.yOffset;
- if (transX != 0 || transY != 0)
- {
- glTranslatef(static_cast<GLfloat>(transX),
- static_cast<GLfloat>(transY), 0);
- }
- mglScissor(clipArea.x * mScale,
- (mRect.h - clipArea.y - clipArea.height) * mScale,
- clipArea.width * mScale,
- clipArea.height * mScale);
-}
-
-#ifdef ANDROID
-void MobileOpenGLGraphics::drawPoint(int x A_UNUSED, int y A_UNUSED) restrict2
-#else // ANDROID
-void MobileOpenGLGraphics::drawPoint(int x, int y) restrict2
-#endif // ANDROID
-{
- disableTexturingAndBlending();
- restoreColor();
-
-#ifdef ANDROID
- // TODO need fix
-#else // ANDROID
-
- glBegin(GL_POINTS);
- glVertex2i(x, y);
- glEnd();
-#endif // ANDROID
-}
-
-void MobileOpenGLGraphics::drawLine(int x1, int y1,
- int x2, int y2) restrict2
-{
- disableTexturingAndBlending();
- restoreColor();
-
- mShortVertArray[0] = static_cast<GLshort>(x1);
- mShortVertArray[1] = static_cast<GLshort>(y1);
- mShortVertArray[2] = static_cast<GLshort>(x2);
- mShortVertArray[3] = static_cast<GLshort>(y2);
-
- drawLineArrays(4);
-}
-
-void MobileOpenGLGraphics::drawRectangle(const Rect &restrict rect) restrict2
-{
- drawRectangle(rect, false);
-}
-
-void MobileOpenGLGraphics::fillRectangle(const Rect &restrict rect) restrict2
-{
- drawRectangle(rect, true);
-}
-
-void MobileOpenGLGraphics::enableTexturingAndBlending() restrict2
-{
- if (!mTexture)
- {
- mglEnable(OpenGLImageHelper::mTextureType);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- mTexture = true;
- }
-
- if (!mAlpha)
- {
- mglEnable(GL_BLEND);
- mAlpha = true;
- }
-}
-
-void MobileOpenGLGraphics::disableTexturingAndBlending() restrict2
-{
- mTextureBinded = 0;
- if (mAlpha && !mColorAlpha)
- {
- mglDisable(GL_BLEND);
- mAlpha = false;
- }
- else if (!mAlpha && mColorAlpha)
- {
- mglEnable(GL_BLEND);
- mAlpha = true;
- }
-
- if (mTexture)
- {
- mglDisable(OpenGLImageHelper::mTextureType);
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
- mTexture = false;
- }
-}
-
-void MobileOpenGLGraphics::drawRectangle(const Rect &restrict rect,
- const bool filled) restrict2
-{
- BLOCK_START("Graphics::drawRectangle")
- disableTexturingAndBlending();
- restoreColor();
-
- const GLshort x = static_cast<GLshort>(rect.x);
- const GLshort y = static_cast<GLshort>(rect.y);
- const GLshort width = static_cast<GLshort>(rect.width);
- const GLshort height = static_cast<GLshort>(rect.height);
- const GLshort xw = static_cast<GLshort>(rect.x + width);
- const GLshort yh = static_cast<GLshort>(rect.y + height);
-
- if (filled)
- {
- GLshort vert[] =
- {
- x, y,
- xw, y,
- x, yh,
- xw, yh
- };
-
- glVertexPointer(2, GL_SHORT, 0, &vert);
-#ifdef DEBUG_DRAW_CALLS
- mDrawCalls ++;
-#endif // DEBUG_DRAW_CALLS
-
- mglDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
-#ifdef OPENGLERRORS
- graphicsManager.logError();
-#endif // OPENGLERRORS
- }
- else
- {
- GLshort vert[] =
- {
- x, y,
- xw, y,
- xw, yh,
- x, yh
- };
-
- glVertexPointer(2, GL_SHORT, 0, &vert);
-#ifdef DEBUG_DRAW_CALLS
- mDrawCalls ++;
-#endif // DEBUG_DRAW_CALLS
-
- mglDrawArrays(GL_LINE_LOOP, 0, 4);
-#ifdef OPENGLERRORS
- graphicsManager.logError();
-#endif // OPENGLERRORS
- }
- BLOCK_END("Graphics::drawRectangle")
-}
-
-void MobileOpenGLGraphics::drawNet(const int x1, const int y1,
- const int x2, const int y2,
- const int width, const int height) restrict2
-{
- unsigned int vp = 0;
- const unsigned int vLimit = mMaxVertices * 4;
-
- disableTexturingAndBlending();
- restoreColor();
-
- const GLshort xs1 = static_cast<GLshort>(x1);
- const GLshort xs2 = static_cast<GLshort>(x2);
- const GLshort ys1 = static_cast<GLshort>(y1);
- const GLshort ys2 = static_cast<GLshort>(y2);
- const int16_t width1 = CAST_S16(width);
- const int16_t height1 = CAST_S16(height);
-
- for (int16_t y = CAST_S16(y1); y < y2; y += height1)
- {
- mShortVertArray[vp + 0] = xs1;
- mShortVertArray[vp + 1] = y;
-
- mShortVertArray[vp + 2] = xs2;
- mShortVertArray[vp + 3] = y;
-
- vp += 4;
- if (vp >= vLimit)
- {
- drawLineArrays(vp);
- vp = 0;
- }
- }
-
- for (int16_t x = CAST_S16(x1); x < x2; x += width1)
- {
- mShortVertArray[vp + 0] = x;
- mShortVertArray[vp + 1] = ys1;
-
- mShortVertArray[vp + 2] = x;
- mShortVertArray[vp + 3] = ys2;
-
- vp += 4;
- if (vp >= vLimit)
- {
- drawLineArrays(vp);
- vp = 0;
- }
- }
-
- if (vp > 0)
- drawLineArrays(vp);
-}
-
-void MobileOpenGLGraphics::bindTexture(const GLenum target,
- const GLuint texture)
-{
- if (mTextureBinded != texture)
- {
- mTextureBinded = texture;
- mglBindTexture(target, texture);
- }
-}
-
-inline void MobileOpenGLGraphics::drawTriangleArrayfs(const int size) restrict2
-{
- glVertexPointer(2, GL_SHORT, 0, mShortVertArray);
- glTexCoordPointer(2, GL_FLOAT, 0, mFloatTexArray);
-
-#ifdef DEBUG_DRAW_CALLS
- mDrawCalls ++;
-#endif // DEBUG_DRAW_CALLS
-
- mglDrawArrays(GL_TRIANGLES, 0, size / 2);
-#ifdef OPENGLERRORS
- graphicsManager.logError();
-#endif // OPENGLERRORS
-}
-
-inline void MobileOpenGLGraphics::drawTriangleArrayfsCached(const int size)
- restrict2
-{
- glVertexPointer(2, GL_SHORT, 0, mShortVertArrayCached);
- glTexCoordPointer(2, GL_FLOAT, 0, mFloatTexArrayCached);
-
-#ifdef DEBUG_DRAW_CALLS
- mDrawCalls ++;
-#endif // DEBUG_DRAW_CALLS
-
- mglDrawArrays(GL_TRIANGLES, 0, size / 2);
-#ifdef OPENGLERRORS
- graphicsManager.logError();
-#endif // OPENGLERRORS
-}
-
-inline void MobileOpenGLGraphics::drawTriangleArrayfs(const GLshort *restrict
- const shortVertArray,
- const GLfloat *restrict
- const floatTexArray,
- const int size) restrict2
-{
- glVertexPointer(2, GL_SHORT, 0, shortVertArray);
- glTexCoordPointer(2, GL_FLOAT, 0, floatTexArray);
-
-#ifdef DEBUG_DRAW_CALLS
- mDrawCalls ++;
-#endif // DEBUG_DRAW_CALLS
-
- mglDrawArrays(GL_TRIANGLES, 0, size / 2);
-#ifdef OPENGLERRORS
- graphicsManager.logError();
-#endif // OPENGLERRORS
-}
-
-inline void MobileOpenGLGraphics::drawLineArrays(const int size) restrict2
-{
- glVertexPointer(2, GL_SHORT, 0, mShortVertArray);
-
-#ifdef DEBUG_DRAW_CALLS
- mDrawCalls ++;
-#endif // DEBUG_DRAW_CALLS
-
- mglDrawArrays(GL_LINES, 0, size / 2);
-#ifdef OPENGLERRORS
- graphicsManager.logError();
-#endif // OPENGLERRORS
-}
-
-void MobileOpenGLGraphics::dumpSettings()
-{
- GLint test[1000];
- logger->log("\n\n");
- logger->log("start opengl dump");
- for (int f = 0; f < 65535; f ++)
- {
- test[0] = 0;
- test[1] = 0;
- test[2] = 0;
- test[3] = 0;
- mglGetIntegerv(f, &test[0]);
- if (test[0] != 0 || test[1] != 0 || test[2] != 0 || test[3] != 0)
- {
- logger->log("\n%d = %d, %d, %d, %d", f,
- test[0], test[1], test[2], test[3]);
- }
- }
-}
-
-void MobileOpenGLGraphics::setColorAlpha(const float alpha) restrict2
-{
- if (!mIsByteColor && mFloatColor == alpha)
- return;
-
- glColor4f(1.0F, 1.0F, 1.0F, alpha);
- mIsByteColor = false;
- mFloatColor = alpha;
-}
-
-void MobileOpenGLGraphics::restoreColor() restrict2
-{
- if (mIsByteColor && mByteColor == mColor)
- return;
-
- glColor4ub(static_cast<GLubyte>(mColor.r),
- static_cast<GLubyte>(mColor.g),
- static_cast<GLubyte>(mColor.b),
- static_cast<GLubyte>(mColor.a));
- mIsByteColor = true;
- mByteColor = mColor;
-}
-
-void MobileOpenGLGraphics::drawImageRect(const int x, const int y,
- const int w, const int h,
- const ImageRect &restrict imgRect)
- restrict2
-{
- #include "render/graphics_drawImageRect.hpp"
-}
-
-void MobileOpenGLGraphics::calcImageRect(ImageVertexes *restrict const vert,
- const int x, const int y,
- const int w, const int h,
- const ImageRect &restrict imgRect)
- restrict2
-{
- #include "render/graphics_calcImageRect.hpp"
-}
-
-void MobileOpenGLGraphics::clearScreen() const restrict2
-{
- mglClear(GL_COLOR_BUFFER_BIT |
- GL_DEPTH_BUFFER_BIT |
- GL_STENCIL_BUFFER_BIT);
-}
-
-#ifdef DEBUG_BIND_TEXTURE
-void MobileOpenGLGraphics::debugBindTexture(const Image *restrict const image)
- restrict2
-{
- const std::string texture = image->mIdPath;
- if (mOldTexture != texture)
- {
- if ((!mOldTexture.empty() || !texture.empty())
- && mOldTextureId != image->mGLImage)
- {
- logger->log("bind: %s (%d) to %s (%d)", mOldTexture.c_str(),
- mOldTextureId, texture.c_str(), image->mGLImage);
- }
- mOldTextureId = image->mGLImage;
- mOldTexture = texture;
- }
-}
-#else // DEBUG_BIND_TEXTURE
-
-void MobileOpenGLGraphics::debugBindTexture(const Image *restrict const
- image A_UNUSED) restrict2
-{
-}
-#endif // DEBUG_BIND_TEXTURE
-
-#endif // defined(USE_OPENGL) && !defined(__native_client__)
diff --git a/src/render/mobileopenglgraphics.h b/src/render/mobileopenglgraphics.h
deleted file mode 100644
index 7f4da86da..000000000
--- a/src/render/mobileopenglgraphics.h
+++ /dev/null
@@ -1,115 +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 RENDER_MOBILEOPENGLGRAPHICS_H
-#define RENDER_MOBILEOPENGLGRAPHICS_H
-
-#if defined(USE_OPENGL) && !defined(__native_client__)
-
-#include "localconsts.h"
-
-#include "render/graphics.h"
-
-#include "resources/fboinfo.h"
-
-#ifdef ANDROID
-#include <GLES/gl.h>
-#include <GLES/glext.h>
-#include <GLES2/gl2.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)
-#if defined(__APPLE__)
-#include <OpenGL/glext.h>
-#elif !defined(__native_client__)
-#include <GL/glext.h>
-#endif // defined(__APPLE__)
-#endif // ANDROID
-
-class OpenGLGraphicsVertexes;
-
-class MobileOpenGLGraphics final : public Graphics
-{
- public:
- MobileOpenGLGraphics();
-
- A_DELETE_COPY(MobileOpenGLGraphics)
-
- ~MobileOpenGLGraphics();
-
- void postInit() restrict2 override final;
-
- inline void drawTriangleArrayfs(const GLshort *restrict const
- shortVertArray,
- const GLfloat *restrict const
- floatTexArray,
- const int size) restrict2 A_INLINE;
-
- inline void drawTriangleArrayfs(const int size) restrict2 A_INLINE;
-
- inline void drawTriangleArrayfsCached(const int size)
- restrict2 A_INLINE;
-
- inline void drawLineArrays(const int size) restrict2 A_INLINE;
-
- #include "render/graphicsdef.hpp"
- RENDER_GRAPHICSDEF_HPP
-
- #include "render/openglgraphicsdef1.hpp"
- RENDER_OPENGLGRAPHICSDEF1_HPP
-
- #include "render/openglgraphicsdef.hpp"
- RENDER_OPENGLGRAPHICSDEF_HPP
-
- #include "render/openglgraphicsdefadvanced.hpp"
- RENDER_OPENGLGRAPHICSDEFADVANCED_HPP
-
- private:
- GLfloat *mFloatTexArray;
- GLshort *mShortVertArray;
- GLfloat *mFloatTexArrayCached;
- GLshort *mShortVertArrayCached;
- float mAlphaCached;
- int mVpCached;
- bool mTexture;
-
- bool mIsByteColor;
- Color mByteColor;
- GLuint mImageCached;
- float mFloatColor;
- int mMaxVertices;
- bool mColorAlpha;
-#ifdef DEBUG_BIND_TEXTURE
- std::string mOldTexture;
- unsigned mOldTextureId;
-#endif // DEBUG_BIND_TEXTURE
-
- FBOInfo mFbo;
-};
-#endif // defined(USE_OPENGL) && !defined(__native_client__)
-
-#endif // RENDER_MOBILEOPENGLGRAPHICS_H
diff --git a/src/render/modernopenglgraphics.cpp b/src/render/modernopenglgraphics.cpp
deleted file mode 100644
index be1ec4f73..000000000
--- a/src/render/modernopenglgraphics.cpp
+++ /dev/null
@@ -1,1403 +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) && !defined(__native_client__)
-
-#include "render/modernopenglgraphics.h"
-
-#include "graphicsmanager.h"
-
-#include "render/opengl/mgl.h"
-#ifdef __native_client__
-#include "render/opengl/naclglfunctions.h"
-#endif // __native_client__
-
-#include "render/shaders/shaderprogram.h"
-#include "render/shaders/shadersmanager.h"
-
-#include "render/vertexes/imagecollection.h"
-
-#include "resources/imagerect.h"
-#include "resources/openglimagehelper.h"
-
-#include "resources/image/image.h"
-
-#include "utils/delete2.h"
-#include "utils/foreach.h"
-#include "utils/sdlcheckutils.h"
-#include "utils/sdlhelper.h"
-
-#include "debug.h"
-
-#define vertFill2D(var, x1, y1, x2, y2, dstX, dstY, w, h) \
- var[vp + 0] = dstX; \
- var[vp + 1] = dstY; \
- var[vp + 2] = x1; \
- var[vp + 3] = y1; \
- \
- var[vp + 4] = dstX + w; \
- var[vp + 5] = dstY; \
- var[vp + 6] = x2; \
- var[vp + 7] = y1; \
- \
- var[vp + 8] = dstX + w; \
- var[vp + 9] = dstY + h; \
- var[vp + 10] = x2; \
- var[vp + 11] = y2; \
- \
- var[vp + 12] = dstX; \
- var[vp + 13] = dstY; \
- var[vp + 14] = x1; \
- var[vp + 15] = y1; \
- \
- var[vp + 16] = dstX; \
- var[vp + 17] = dstY + h; \
- var[vp + 18] = x1; \
- var[vp + 19] = y2; \
- \
- var[vp + 20] = dstX + w; \
- var[vp + 21] = dstY + h; \
- var[vp + 22] = x2; \
- var[vp + 23] = y2;
-
-GLuint ModernOpenGLGraphics::mTextureBinded = 0;
-#ifdef DEBUG_DRAW_CALLS
-unsigned int ModernOpenGLGraphics::mDrawCalls = 0;
-unsigned int ModernOpenGLGraphics::mLastDrawCalls = 0;
-#endif // DEBUG_DRAW_CALLS
-
-ModernOpenGLGraphics::ModernOpenGLGraphics() :
- mIntArray(nullptr),
- mIntArrayCached(nullptr),
- mProgram(nullptr),
- mAlphaCached(1.0F),
- mVpCached(0),
- mFloatColor(1.0F),
- mMaxVertices(500),
- mProgramId(0U),
- mSimpleColorUniform(0U),
- mPosAttrib(0),
- mTextureColorUniform(0U),
- mScreenUniform(0U),
- mDrawTypeUniform(0U),
- mVao(0U),
- mVbo(0U),
- mEbo(0U),
- mVboBinded(0U),
- mEboBinded(0U),
- mAttributesBinded(0U),
- mColorAlpha(false),
- mTextureDraw(false),
-#ifdef DEBUG_BIND_TEXTURE
- mOldTexture(),
- mOldTextureId(0),
-#endif // DEBUG_BIND_TEXTURE
- mFbo()
-{
- mOpenGL = RENDER_MODERN_OPENGL;
- mName = "modern OpenGL";
-}
-
-ModernOpenGLGraphics::~ModernOpenGLGraphics()
-{
- deleteArraysInternal();
- deleteGLObjects();
-}
-
-void ModernOpenGLGraphics::deleteGLObjects() restrict2
-{
- delete2(mProgram);
- if (mVbo != 0u)
- {
-// logger->log("delete buffer vbo: %u", mVbo);
- mglDeleteBuffers(1, &mVbo);
- }
- if (mEbo != 0u)
- {
-// logger->log("delete buffer ebo: %u", mEbo);
- mglDeleteBuffers(1, &mEbo);
- }
- if (mVao != 0u)
- mglDeleteVertexArrays(1, &mVao);
-}
-
-void ModernOpenGLGraphics::initArrays(const int vertCount) restrict2
-{
- mMaxVertices = vertCount;
- if (mMaxVertices < 500)
- mMaxVertices = 500;
- else if (mMaxVertices > 1024)
- mMaxVertices = 1024;
-
- // need alocate small size, after if limit reached reallocate to double size
- const size_t sz = mMaxVertices * 4 + 30;
- vertexBufSize = mMaxVertices;
- if (mIntArray == nullptr)
- mIntArray = new GLint[sz];
- if (mIntArrayCached == nullptr)
- mIntArrayCached = new GLint[sz];
-}
-
-void ModernOpenGLGraphics::postInit() restrict2
-{
- mglGenVertexArrays(1, &mVao);
- mglBindVertexArray(mVao);
- mglGenBuffers(1, &mVbo);
-// logger->log("gen vbo buffer: %u", mVbo);
- bindArrayBuffer(mVbo);
- mglGenBuffers(1, &mEbo);
-// logger->log("gen ebo buffer: %u", mEbo);
- bindElementBuffer(mEbo);
-
- logger->log("Compiling shaders");
- mProgram = shaders.getSimpleProgram();
- if (mProgram == nullptr)
- {
- graphicsManager.logError();
- logger->safeError("Shader creation error. See manaplus.log.");
- }
- mProgramId = mProgram->getProgramId();
- if (mProgramId == 0u)
- logger->error("Shaders compilation error.");
-
- logger->log("Shaders compilation done.");
- mglUseProgram(mProgramId);
-
- mPosAttrib = mglGetAttribLocation(mProgramId, "position");
- mglEnableVertexAttribArray(mPosAttrib);
- mglVertexAttribIFormat(mPosAttrib, 4, GL_INT, 0);
-
- mSimpleColorUniform = mglGetUniformLocation(mProgramId, "color");
- mScreenUniform = mglGetUniformLocation(mProgramId, "screen");
- mDrawTypeUniform = mglGetUniformLocation(mProgramId, "drawType");
- mTextureColorUniform = mglGetUniformLocation(mProgramId, "alpha");
-
- mglUniform1f(mTextureColorUniform, 1.0f);
-
- mglBindVertexBuffer(0, mVbo, 0, 4 * sizeof(GLint));
- mglVertexAttribBinding(mPosAttrib, 0);
-// mglVertexAttribIPointer(mPosAttrib, 4, GL_INT, 4 * sizeof(GLint), 0);
- mAttributesBinded = mVbo;
-
- mglUniform2f(mScreenUniform,
- static_cast<float>(mWidth) / 2.0f,
- static_cast<float>(mHeight) / 2.0f);
- mglUniform4f(mSimpleColorUniform,
- 0.0F,
- 0.0F,
- 0.0F,
- 0.0F);
-}
-
-void ModernOpenGLGraphics::screenResized() restrict2
-{
- deleteGLObjects();
- mVboBinded = 0U;
- mEboBinded = 0U;
- mAttributesBinded = 0U;
- mColor = Color(0, 0, 0, 0);
- postInit();
-}
-
-void ModernOpenGLGraphics::deleteArrays() restrict2
-{
- deleteArraysInternal();
-}
-
-void ModernOpenGLGraphics::deleteArraysInternal() restrict2
-{
- delete [] mIntArray;
- mIntArray = nullptr;
- delete [] mIntArrayCached;
- mIntArrayCached = nullptr;
-}
-
-bool ModernOpenGLGraphics::setVideoMode(const int w, const int h,
- const int scale,
- const int bpp,
- const bool fs,
- const bool hwaccel,
- const bool resize,
- const bool noFrame,
- const bool allowHighDPI) restrict2
-{
- setMainFlags(w, h,
- scale,
- bpp,
- fs,
- hwaccel,
- resize,
- noFrame,
- allowHighDPI);
-
- return setOpenGLMode();
-}
-
-void ModernOpenGLGraphics::setColor(const Color &restrict color) restrict2
-{
- mColorAlpha = (color.a != 255);
- if (mColor != color)
- {
- mColor = color;
- mglUniform4f(mSimpleColorUniform,
- static_cast<float>(color.r) / 255.0F,
- static_cast<float>(color.g) / 255.0F,
- static_cast<float>(color.b) / 255.0F,
- static_cast<float>(color.a) / 255.0F);
- }
-}
-
-void ModernOpenGLGraphics::setColorAlpha(const float alpha) restrict2
-{
- if (mAlphaCached != alpha)
- {
- mAlphaCached = alpha;
- mglUniform1f(mTextureColorUniform, alpha);
- }
-}
-
-void ModernOpenGLGraphics::drawQuad(const int srcX,
- const int srcY,
- const int dstX,
- const int dstY,
- const int width,
- const int height) restrict2
-{
- const int texX2 = srcX + width;
- const int texY2 = srcY + height;
- const int x2 = dstX + width;
- const int y2 = dstY + height;
-
- GLint vertices[] =
- {
- dstX, dstY, srcX, srcY,
- x2, dstY, texX2, srcY,
- dstX, y2, srcX, texY2,
- x2, y2, texX2, texY2
- };
-
-// logger->log("allocate: %d, %ld", mVboBinded, sizeof(vertices));
- mglBufferData(GL_ARRAY_BUFFER, sizeof(vertices),
- vertices, GL_STREAM_DRAW);
-#ifdef DEBUG_DRAW_CALLS
- mDrawCalls ++;
-#endif // DEBUG_DRAW_CALLS
- mglDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
-#ifdef OPENGLERRORS
- graphicsManager.logError();
-#endif // OPENGLERRORS
-}
-
-void ModernOpenGLGraphics::drawRescaledQuad(const int srcX, const int srcY,
- const int dstX, const int dstY,
- const int width, const int height,
- const int desiredWidth,
- const int desiredHeight) restrict2
-{
- const int texX2 = srcX + width;
- const int texY2 = srcY + height;
- const int x2 = dstX + desiredWidth;
- const int y2 = dstY + desiredHeight;
-
- GLint vertices[] =
- {
- dstX, dstY, srcX, srcY,
- x2, dstY, texX2, srcY,
- dstX, y2, srcX, texY2,
- x2, y2, texX2, texY2
- };
-
-// logger->log("allocate: %d, %ld", mVboBinded, sizeof(vertices));
- mglBufferData(GL_ARRAY_BUFFER, sizeof(vertices),
- vertices, GL_STREAM_DRAW);
-#ifdef DEBUG_DRAW_CALLS
- mDrawCalls ++;
-#endif // DEBUG_DRAW_CALLS
- mglDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
-#ifdef OPENGLERRORS
- graphicsManager.logError();
-#endif // OPENGLERRORS
-}
-
-void ModernOpenGLGraphics::drawImage(const Image *restrict const image,
- int dstX, int dstY) restrict2
-{
- drawImageInline(image, dstX, dstY);
-}
-
-void ModernOpenGLGraphics::drawImageInline(const Image *restrict const image,
- int dstX, int dstY) restrict2
-{
- FUNC_BLOCK("Graphics::drawImage", 1)
- if (image == nullptr)
- return;
-
-#ifdef DEBUG_BIND_TEXTURE
- debugBindTexture(image);
-#endif // DEBUG_BIND_TEXTURE
- bindTexture(GL_TEXTURE_2D, image->mGLImage);
- enableTexturingAndBlending();
- bindArrayBufferAndAttributes(mVbo);
- setColorAlpha(image->mAlpha);
-
- const ClipRect &clipArea = mClipStack.top();
- const SDL_Rect &imageRect = image->mBounds;
- drawQuad(imageRect.x, imageRect.y,
- dstX + clipArea.xOffset, dstY + clipArea.yOffset,
- imageRect.w, imageRect.h);
-}
-
-void ModernOpenGLGraphics::copyImage(const Image *restrict const image,
- int dstX, int dstY) restrict2
-{
- drawImageInline(image, dstX, dstY);
-}
-
-void ModernOpenGLGraphics::testDraw() restrict2
-{
-/*
- GLint vertices[] =
- {
- 0, 0, 0, 0,
- 800, 0, 800, 0,
- 0, 600, 0, 600,
- 800, 600, 800, 600
- };
-*/
-// logger->log("allocate: %d, %ld", mVboBinded, sizeof(vertices));
-// logger->log("allocate ebo: %d, %ld", mEboBinded, sizeof(elements));
-// mglBufferData(GL_ARRAY_BUFFER, sizeof(vertices),
-// vertices, GL_STREAM_DRAW);
-// mglBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(elements),
-// elements, GL_STREAM_DRAW);
-#ifdef DEBUG_DRAW_CALLS
- mDrawCalls ++;
-#endif // DEBUG_DRAW_CALLS
- mglDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
-// glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_INT, 0);
-#ifdef OPENGLERRORS
- graphicsManager.logError();
-#endif // OPENGLERRORS
-}
-
-void ModernOpenGLGraphics::drawImageCached(const Image *restrict const image
- A_UNUSED,
- int A_UNUSED x,
- int y A_UNUSED) restrict2
-{
-}
-
-void ModernOpenGLGraphics::drawPatternCached(const Image *restrict const image
- A_UNUSED,
- const int x A_UNUSED,
- const int y A_UNUSED,
- const int w A_UNUSED,
- const int h A_UNUSED) restrict2
-{
-}
-
-void ModernOpenGLGraphics::completeCache() restrict2
-{
-}
-
-void ModernOpenGLGraphics::drawRescaledImage(const Image *restrict const image,
- int dstX, int dstY,
- const int desiredWidth,
- const int desiredHeight) restrict2
-{
- if (image == nullptr)
- return;
-
- const SDL_Rect &imageRect = image->mBounds;
-
- // Just draw the image normally when no resizing is necessary,
- if (imageRect.w == desiredWidth && imageRect.h == desiredHeight)
- {
- drawImageInline(image, dstX, dstY);
- return;
- }
-
- setColorAlpha(image->mAlpha);
-#ifdef DEBUG_BIND_TEXTURE
- debugBindTexture(image);
-#endif // DEBUG_BIND_TEXTURE
- bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
- enableTexturingAndBlending();
- bindArrayBufferAndAttributes(mVbo);
-
- const ClipRect &clipArea = mClipStack.top();
- // Draw a textured quad.
- drawRescaledQuad(imageRect.x, imageRect.y,
- dstX + clipArea.xOffset, dstY + clipArea.yOffset,
- imageRect.w, imageRect.h,
- desiredWidth, desiredHeight);
-}
-
-void ModernOpenGLGraphics::drawPattern(const Image *restrict const image,
- const int x, const int y,
- const int w, const int h) restrict2
-{
- drawPatternInline(image, x, y, w, h);
-}
-
-void ModernOpenGLGraphics::drawPatternInline(const Image *restrict const image,
- const int x,
- const int y,
- const int w,
- const int h) restrict2
-{
- if (image == nullptr)
- return;
-
- const SDL_Rect &imageRect = image->mBounds;
- const int srcX = imageRect.x;
- const int srcY = imageRect.y;
- const int iw = imageRect.w;
- const int ih = imageRect.h;
-
- if (iw == 0 || ih == 0)
- return;
-
- const ClipRect &clipArea = mClipStack.top();
- const int x2 = x + clipArea.xOffset;
- const int y2 = y + clipArea.yOffset;
-
-#ifdef DEBUG_BIND_TEXTURE
- debugBindTexture(image);
-#endif // DEBUG_BIND_TEXTURE
-
- bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
-
- enableTexturingAndBlending();
- bindArrayBufferAndAttributes(mVbo);
- setColorAlpha(image->mAlpha);
-
- unsigned int vp = 0;
- const unsigned int vLimit = mMaxVertices * 4;
-
- for (int py = 0; py < h; py += ih)
- {
- const int height = (py + ih >= h) ? h - py : ih;
- const int texY2 = srcY + height;
- const int dstY = y2 + py;
- for (int px = 0; px < w; px += iw)
- {
- const int width = (px + iw >= w) ? w - px : iw;
- const int dstX = x2 + px;
-
- const int texX2 = srcX + width;
-
- vertFill2D(mIntArray,
- srcX, srcY, texX2, texY2,
- dstX, dstY, width, height);
-
- vp += 24;
- if (vp >= vLimit)
- {
- drawTriangleArray(vp);
- vp = 0;
- }
- }
- }
- if (vp > 0)
- drawTriangleArray(vp);
-}
-
-void ModernOpenGLGraphics::drawRescaledPattern(const Image *
- restrict const image,
- const int x, const int y,
- const int w, const int h,
- const int scaledWidth,
- const int scaledHeight)
- restrict2
-{
- if (image == nullptr)
- return;
-
- if (scaledWidth == 0 || scaledHeight == 0)
- return;
-
- const SDL_Rect &imageRect = image->mBounds;
- const int srcX = imageRect.x;
- const int srcY = imageRect.y;
- const int iw = imageRect.w;
- const int ih = imageRect.h;
- if (iw == 0 || ih == 0)
- return;
-
-#ifdef DEBUG_BIND_TEXTURE
- debugBindTexture(image);
-#endif // DEBUG_BIND_TEXTURE
-
- bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
-
- enableTexturingAndBlending();
- bindArrayBufferAndAttributes(mVbo);
- setColorAlpha(image->mAlpha);
-
- unsigned int vp = 0;
- const unsigned int vLimit = mMaxVertices * 4;
-
- const ClipRect &clipArea = mClipStack.top();
- const int x2 = x + clipArea.xOffset;
- const int y2 = y + clipArea.yOffset;
-
- const float scaleFactorW = static_cast<float>(scaledWidth) / iw;
- const float scaleFactorH = static_cast<float>(scaledHeight) / ih;
-
- for (int py = 0; py < h; py += scaledHeight)
- {
- const int height = (py + scaledHeight >= h)
- ? h - py : scaledHeight;
- const int dstY = y2 + py;
- const int scaledY = srcY + height / scaleFactorH;
- for (int px = 0; px < w; px += scaledWidth)
- {
- const int width = (px + scaledWidth >= w)
- ? w - px : scaledWidth;
- const int dstX = x2 + px;
- const int scaledX = srcX + width / scaleFactorW;
-
- vertFill2D(mIntArray,
- srcX, srcY, scaledX, scaledY,
- dstX, dstY, width, height);
-
- vp += 24;
- if (vp >= vLimit)
- {
- drawTriangleArray(vp);
- vp = 0;
- }
- }
- }
- if (vp > 0)
- drawTriangleArray(vp);
-}
-
-inline void ModernOpenGLGraphics::drawVertexes(const
- OpenGLGraphicsVertexes &
- restrict ogl) restrict2
-{
- const STD_VECTOR<int> &vp = ogl.mVp;
- const STD_VECTOR<GLuint> &vbos = ogl.mVbo;
- STD_VECTOR<int>::const_iterator ivp;
- STD_VECTOR<GLuint>::const_iterator ivbo;
- const STD_VECTOR<int>::const_iterator ivp_end = vp.end();
-
-/*
- if (vp.size() != vbos.size())
- logger->log("different size in vp and vbos");
-*/
-
- for (ivp = vp.begin(), ivbo = vbos.begin();
- ivp != ivp_end;
- ++ ivp, ++ ivbo)
- {
- bindArrayBufferAndAttributes(*ivbo);
-#ifdef DEBUG_DRAW_CALLS
- mDrawCalls ++;
-#endif // DEBUG_DRAW_CALLS
-// logger->log("draw from array: %u", *ivbo);
- mglDrawArrays(GL_TRIANGLES, 0, *ivp / 4);
-#ifdef OPENGLERRORS
- graphicsManager.logError();
-#endif // OPENGLERRORS
- }
-}
-
-void ModernOpenGLGraphics::calcPattern(ImageVertexes *restrict const vert,
- const Image *restrict const image,
- const int x,
- const int y,
- const int w,
- const int h) const restrict2
-{
- calcPatternInline(vert, image, x, y, w, h);
-}
-
-void ModernOpenGLGraphics::calcPatternInline(ImageVertexes *
- restrict const vert,
- const Image *restrict const image,
- const int x,
- const int y,
- const int w,
- const int h) const restrict2
-{
- if (image == nullptr || vert == nullptr)
- return;
-
- const SDL_Rect &imageRect = image->mBounds;
- const int srcX = imageRect.x;
- const int srcY = imageRect.y;
- const int iw = imageRect.w;
- const int ih = imageRect.h;
-
- if (iw == 0 || ih == 0)
- return;
-
- const ClipRect &clipArea = mClipStack.top();
- const int x2 = x + clipArea.xOffset;
- const int y2 = y + clipArea.yOffset;
-
- const unsigned int vLimit = mMaxVertices * 4;
-
- OpenGLGraphicsVertexes &ogl = vert->ogl;
- unsigned int vp = ogl.continueVp();
-
- GLint *intArray = ogl.continueIntTexArray();
-
- for (int py = 0; py < h; py += ih)
- {
- const int height = (py + ih >= h) ? h - py : ih;
- const int dstY = y2 + py;
- const int texY2 = srcY + height;
- for (int px = 0; px < w; px += iw)
- {
- const int width = (px + iw >= w) ? w - px : iw;
- const int dstX = x2 + px;
- const int texX2 = srcX + width;
-
- vertFill2D(intArray,
- srcX, srcY, texX2, texY2,
- dstX, dstY, width, height);
-
- vp += 24;
- if (vp >= vLimit)
- {
- intArray = ogl.switchIntTexArray();
- ogl.switchVp(vp);
- vp = 0;
- }
- }
- }
- ogl.switchVp(vp);
-}
-
-void ModernOpenGLGraphics::calcTileCollection(ImageCollection *
- restrict const vertCol,
- const Image *
- restrict const image,
- int x, int y) restrict2
-{
- if (vertCol == nullptr || image == nullptr)
- return;
- if (vertCol->currentGLImage != image->mGLImage)
- {
- ImageVertexes *const vert = new ImageVertexes;
- vertCol->currentGLImage = image->mGLImage;
- vertCol->currentVert = vert;
- vert->image = image;
- vertCol->draws.push_back(vert);
- calcTileVertexesInline(vert, image, x, y);
- }
- else
- {
- calcTileVertexesInline(vertCol->currentVert, image, x, y);
- }
-}
-
-void ModernOpenGLGraphics::drawTileCollection(const ImageCollection
- *restrict const vertCol)
- restrict2
-{
- enableTexturingAndBlending();
-/*
- if (!vertCol)
- {
- logger->log("ModernOpenGLGraphics::drawTileCollection"
- " vertCol is nullptr");
- }
-*/
- const ImageVertexesVector &draws = vertCol->draws;
- const ImageCollectionCIter it_end = draws.end();
- for (ImageCollectionCIter it = draws.begin(); it != it_end; ++ it)
- {
- const ImageVertexes *const vert = *it;
- const Image *const image = vert->image;
-
- setColorAlpha(image->mAlpha);
-#ifdef DEBUG_BIND_TEXTURE
- debugBindTexture(image);
-#endif // DEBUG_BIND_TEXTURE
-
- bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
- drawVertexes(vert->ogl);
- }
-}
-
-void ModernOpenGLGraphics::calcPattern(ImageCollection *restrict const vertCol,
- const Image *restrict const image,
- const int x,
- const int y,
- const int w,
- const int h) const restrict2
-{
- if (vertCol == nullptr || image == nullptr)
- return;
- ImageVertexes *vert = nullptr;
- if (vertCol->currentGLImage != image->mGLImage)
- {
- vert = new ImageVertexes;
- vertCol->currentGLImage = image->mGLImage;
- vertCol->currentVert = vert;
- vert->image = image;
- vertCol->draws.push_back(vert);
- }
- else
- {
- vert = vertCol->currentVert;
- }
-
- calcPatternInline(vert, image, x, y, w, h);
-}
-
-void ModernOpenGLGraphics::calcTileVertexes(ImageVertexes *restrict const vert,
- const Image *restrict const image,
- int dstX, int dstY) const restrict2
-{
- calcTileVertexesInline(vert, image, dstX, dstY);
-}
-
-void ModernOpenGLGraphics::calcTileVertexesInline(ImageVertexes *
- restrict const vert,
- const Image *
- restrict const image,
- int dstX,
- int dstY) const restrict2
-{
- const SDL_Rect &imageRect = image->mBounds;
- const int srcX = imageRect.x;
- const int srcY = imageRect.y;
- const int w = imageRect.w;
- const int h = imageRect.h;
-
- if (w == 0 || h == 0)
- return;
-
- const ClipRect &clipArea = mClipStack.top();
- const int x2 = dstX + clipArea.xOffset;
- const int y2 = dstY + clipArea.yOffset;
-
- const unsigned int vLimit = mMaxVertices * 4;
-
- OpenGLGraphicsVertexes &ogl = vert->ogl;
-
- unsigned int vp = ogl.continueVp();
-
- int texX2 = srcX + w;
- int texY2 = srcY + h;
-
- GLint *const intArray = ogl.continueIntTexArray();
-
- vertFill2D(intArray,
- srcX, srcY, texX2, texY2,
- x2, y2, w, h);
-
- vp += 24;
- if (vp >= vLimit)
- {
- ogl.switchIntTexArray();
- ogl.switchVp(vp);
- vp = 0;
- }
-
- ogl.switchVp(vp);
-}
-
-void ModernOpenGLGraphics::drawTileVertexes(const ImageVertexes *
- restrict const vert) restrict2
-{
- if (vert == nullptr)
- return;
- const Image *const image = vert->image;
-
- setColorAlpha(image->mAlpha);
-#ifdef DEBUG_BIND_TEXTURE
- debugBindTexture(image);
-#endif // DEBUG_BIND_TEXTURE
-
- bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
- enableTexturingAndBlending();
- bindArrayBufferAndAttributes(mVbo);
-
- drawVertexes(vert->ogl);
-}
-
-void ModernOpenGLGraphics::calcWindow(ImageCollection *restrict const vertCol,
- const int x, const int y,
- const int w, const int h,
- const ImageRect &restrict imgRect)
- restrict2
-{
- ImageVertexes *vert = nullptr;
- const Image *const image = imgRect.grid[4];
- if (image == nullptr)
- return;
- if (vertCol->currentGLImage != image->mGLImage)
- {
- vert = new ImageVertexes;
- vertCol->currentGLImage = image->mGLImage;
- vertCol->currentVert = vert;
- vert->image = image;
- vertCol->draws.push_back(vert);
- }
- else
- {
- vert = vertCol->currentVert;
- }
- calcImageRect(vert, x, y, w, h, imgRect);
-}
-
-void ModernOpenGLGraphics::updateScreen() restrict2
-{
- BLOCK_START("Graphics::updateScreen")
-#ifdef DEBUG_DRAW_CALLS
- mLastDrawCalls = mDrawCalls;
- mDrawCalls = 0;
-#endif // DEBUG_DRAW_CALLS
-#ifdef USE_SDL2
- SDL_GL_SwapWindow(mWindow);
-#else // USE_SDL2
- SDL_GL_SwapBuffers();
-#endif // USE_SDL2
-#ifdef DEBUG_OPENGL
- if (isGLNotNull(mglFrameTerminator))
- mglFrameTerminator();
-#endif // DEBUG_OPENGL
- BLOCK_END("Graphics::updateScreen")
-}
-
-void ModernOpenGLGraphics::beginDraw() restrict2
-{
- setOpenGLFlags();
- mglDisable(GL_VERTEX_PROGRAM_POINT_SIZE_ARB);
- mglHint(GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB, GL_FASTEST);
- pushClipArea(Rect(0, 0, mRect.w, mRect.h));
-}
-
-void ModernOpenGLGraphics::endDraw() restrict2
-{
- popClipArea();
-}
-
-void ModernOpenGLGraphics::pushClipArea(const Rect &restrict area) restrict2
-{
- Graphics::pushClipArea(area);
- const ClipRect &clipArea = mClipStack.top();
-
- mglScissor(clipArea.x * mScale,
- (mRect.h - clipArea.y - clipArea.height) * mScale,
- clipArea.width * mScale,
- clipArea.height * mScale);
-}
-
-void ModernOpenGLGraphics::popClipArea() restrict2
-{
- if (mClipStack.empty())
- return;
- Graphics::popClipArea();
- if (mClipStack.empty())
- return;
-
- const ClipRect &clipArea = mClipStack.top();
- mglScissor(clipArea.x * mScale,
- (mRect.h - clipArea.y - clipArea.height) * mScale,
- clipArea.width * mScale,
- clipArea.height * mScale);
-}
-
-void ModernOpenGLGraphics::drawPoint(int x, int y) restrict2
-{
- disableTexturingAndBlending();
- bindArrayBufferAndAttributes(mVbo);
- const ClipRect &clipArea = mClipStack.top();
- GLint vertices[] =
- {
- x + clipArea.xOffset, y + clipArea.yOffset, 0, 0
- };
-// logger->log("allocate: %d, %ld", mVboBinded, sizeof(vertices));
- mglBufferData(GL_ARRAY_BUFFER, sizeof(vertices),
- vertices, GL_STREAM_DRAW);
-#ifdef DEBUG_DRAW_CALLS
- mDrawCalls ++;
-#endif // DEBUG_DRAW_CALLS
- mglDrawArrays(GL_POINTS, 0, 1);
-#ifdef OPENGLERRORS
- graphicsManager.logError();
-#endif // OPENGLERRORS
-}
-
-void ModernOpenGLGraphics::drawLine(int x1, int y1,
- int x2, int y2) restrict2
-{
- disableTexturingAndBlending();
- bindArrayBufferAndAttributes(mVbo);
- const ClipRect &clipArea = mClipStack.top();
- GLint vertices[] =
- {
- x1 + clipArea.xOffset, y1 + clipArea.yOffset, 0, 0,
- x2 + clipArea.xOffset, y2 + clipArea.yOffset, 0, 0
- };
-// logger->log("allocate: %d, %ld", mVboBinded, sizeof(vertices));
- mglBufferData(GL_ARRAY_BUFFER, sizeof(vertices),
- vertices, GL_STREAM_DRAW);
-#ifdef DEBUG_DRAW_CALLS
- mDrawCalls ++;
-#endif // DEBUG_DRAW_CALLS
- mglDrawArrays(GL_LINES, 0, 2);
-#ifdef OPENGLERRORS
- graphicsManager.logError();
-#endif // OPENGLERRORS
-}
-
-void ModernOpenGLGraphics::drawRectangle(const Rect &restrict rect) restrict2
-{
- disableTexturingAndBlending();
- bindArrayBufferAndAttributes(mVbo);
- const ClipRect &clipArea = mClipStack.top();
- const int x1 = rect.x + clipArea.xOffset;
- const int y1 = rect.y + clipArea.yOffset;
- const int x2 = x1 + rect.width;
- const int y2 = y1 + rect.height;
- GLint vertices[] =
- {
- x1, y1, 0, 0,
- x1, y2, 0, 0,
- x2, y2, 0, 0,
- x2, y1, 0, 0
- };
-
-// logger->log("allocate: %d, %ld", mVboBinded, sizeof(vertices));
- mglBufferData(GL_ARRAY_BUFFER, sizeof(vertices),
- vertices, GL_STREAM_DRAW);
-#ifdef DEBUG_DRAW_CALLS
- mDrawCalls ++;
-#endif // DEBUG_DRAW_CALLS
- mglDrawArrays(GL_LINE_LOOP, 0, 4);
-#ifdef OPENGLERRORS
- graphicsManager.logError();
-#endif // OPENGLERRORS
-}
-
-void ModernOpenGLGraphics::fillRectangle(const Rect &restrict rect) restrict2
-{
- disableTexturingAndBlending();
- bindArrayBufferAndAttributes(mVbo);
- const ClipRect &clipArea = mClipStack.top();
- const int x1 = rect.x + clipArea.xOffset;
- const int y1 = rect.y + clipArea.yOffset;
- const int x2 = x1 + rect.width;
- const int y2 = y1 + rect.height;
- GLint vertices[] =
- {
- x1, y1, 0, 0,
- x2, y1, 0, 0,
- x1, y2, 0, 0,
- x2, y2, 0, 0
- };
-
-// logger->log("allocate: %d, %ld", mVboBinded, sizeof(vertices));
- mglBufferData(GL_ARRAY_BUFFER, sizeof(vertices),
- vertices, GL_STREAM_DRAW);
-#ifdef DEBUG_DRAW_CALLS
- mDrawCalls ++;
-#endif // DEBUG_DRAW_CALLS
- mglDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
-#ifdef OPENGLERRORS
- graphicsManager.logError();
-#endif // OPENGLERRORS
-}
-
-void ModernOpenGLGraphics::enableTexturingAndBlending() restrict2
-{
- if (!mTextureDraw)
- {
- mTextureDraw = true;
- mglUniform1f(mDrawTypeUniform, 1.0f);
- }
- if (!mAlpha)
- {
- mglEnable(GL_BLEND);
- mAlpha = true;
- }
-}
-
-void ModernOpenGLGraphics::disableTexturingAndBlending() restrict2
-{
- if (mTextureDraw)
- {
- mTextureDraw = false;
- mglUniform1f(mDrawTypeUniform, 0.0f);
- }
- if (mAlpha && !mColorAlpha)
- {
- mglDisable(GL_BLEND);
- mAlpha = false;
- }
- else if (!mAlpha && mColorAlpha)
- {
- mglEnable(GL_BLEND);
- mAlpha = true;
- }
-}
-
-void ModernOpenGLGraphics::drawRectangle(const Rect &restrict rect A_UNUSED,
- const bool filled A_UNUSED) restrict2
-{
-}
-
-void ModernOpenGLGraphics::drawNet(const int x1, const int y1,
- const int x2, const int y2,
- const int width, const int height) restrict2
-{
- unsigned int vp = 0;
- const unsigned int vLimit = mMaxVertices * 4;
-
- disableTexturingAndBlending();
- bindArrayBufferAndAttributes(mVbo);
- const ClipRect &clipArea = mClipStack.top();
- const GLint dx = clipArea.xOffset;
- const GLint dy = clipArea.yOffset;
-
- const GLint xs1 = x1 + dx;
- const GLint xs2 = x2 + dx;
- const GLint ys1 = y1 + dy;
- const GLint ys2 = y2 + dy;
-
- for (int y = y1; y < y2; y += height)
- {
- mIntArray[vp + 0] = xs1;
- mIntArray[vp + 1] = y;
- mIntArray[vp + 2] = 0;
- mIntArray[vp + 3] = 0;
-
- mIntArray[vp + 4] = xs2;
- mIntArray[vp + 5] = y;
- mIntArray[vp + 6] = 0;
- mIntArray[vp + 7] = 0;
-
- vp += 8;
- if (vp >= vLimit)
- {
- drawLineArrays(vp);
- vp = 0;
- }
- }
-
- for (int x = x1; x < x2; x += width)
- {
- mIntArray[vp + 0] = x;
- mIntArray[vp + 1] = ys1;
- mIntArray[vp + 2] = 0.0f;
- mIntArray[vp + 3] = 0.0f;
-
- mIntArray[vp + 4] = x;
- mIntArray[vp + 5] = ys2;
- mIntArray[vp + 6] = 0.0f;
- mIntArray[vp + 7] = 0.0f;
-
- vp += 8;
- if (vp >= vLimit)
- {
- drawLineArrays(vp);
- vp = 0;
- }
- }
-
- if (vp > 0)
- drawLineArrays(vp);
-}
-
-void ModernOpenGLGraphics::bindTexture(const GLenum target,
- const GLuint texture)
-{
- if (mTextureBinded != texture)
- {
- mTextureBinded = texture;
- mglBindTexture(target, texture);
- }
-}
-
-void ModernOpenGLGraphics::removeArray(const uint32_t sz,
- uint32_t *restrict const arr) restrict2
-{
- mglDeleteBuffers(sz, arr);
- for (size_t f = 0; f < sz; f ++)
- {
- if (arr[f] == mVboBinded)
- mVboBinded = 0;
-// logger->log("delete buffers: %u", arr[f]);
- }
-}
-
-void ModernOpenGLGraphics::bindArrayBuffer(const GLuint vbo) restrict2
-{
- if (mVboBinded != vbo)
- {
- mVboBinded = vbo;
-// logger->log("bind array: %u", vbo);
- mglBindBuffer(GL_ARRAY_BUFFER, vbo);
-/*
- if (mglIsBuffer(vbo) != GL_TRUE)
- logger->log("bind wrong buffer: %u", vbo);
-*/
- mAttributesBinded = 0U;
- }
-}
-
-void ModernOpenGLGraphics::bindElementBuffer(const GLuint ebo) restrict2
-{
- if (mEboBinded != ebo)
- {
- mEboBinded = ebo;
- logger->log("bind element: %u", ebo);
- mglBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ebo);
-/*
- if (mglIsBuffer(ebo) != GL_TRUE)
- logger->log("bind wrong buffer: %u", vbo);
-*/
- }
-}
-
-void ModernOpenGLGraphics::bindArrayBufferAndAttributes(const GLuint vbo)
- restrict2
-{
- if (mVboBinded != vbo)
- {
- mVboBinded = vbo;
-// logger->log("bind array: %u", vbo);
- mglBindBuffer(GL_ARRAY_BUFFER, vbo);
-/*
- if (mglIsBuffer(vbo) != GL_TRUE)
- logger->log("bind wrong buffer: %u", vbo);
-*/
-
- mAttributesBinded = mVboBinded;
-// logger->log("bind vertex buffer: %u", mVboBinded);
- mglBindVertexBuffer(0, mVboBinded, 0, 4 * sizeof(GLint));
-// mglVertexAttribIPointer(mPosAttrib, 4, GL_INT, 4 * sizeof(GLint), 0);
-// mglVertexAttribBinding(mPosAttrib, 0);
- }
- else if (mAttributesBinded != mVboBinded)
- {
- mAttributesBinded = mVboBinded;
-// logger->log("bind vertex buffer: %u", mVboBinded);
- mglBindVertexBuffer(0, mVboBinded, 0, 4 * sizeof(GLint));
-// mglVertexAttribIPointer(mPosAttrib, 4, GL_INT, 4 * sizeof(GLint), 0);
-// mglVertexAttribBinding(mPosAttrib, 0);
- }
-}
-
-void ModernOpenGLGraphics::bindAttributes() restrict2
-{
- if (mAttributesBinded != mVboBinded)
- {
- mAttributesBinded = mVboBinded;
- mglBindVertexBuffer(0, mVboBinded, 0, 4 * sizeof(GLint));
-// mglVertexAttribIPointer(mPosAttrib, 4, GL_INT, 4 * sizeof(GLint), 0);
-// mglVertexAttribBinding(mPosAttrib, 0);
- }
-}
-
-void ModernOpenGLGraphics::dumpSettings()
-{
- GLint test[1000];
- logger->log("\n\n");
- logger->log("start opengl dump");
- for (int f = 0; f < 65535; f ++)
- {
- test[0] = 0;
- test[1] = 0;
- test[2] = 0;
- test[3] = 0;
- mglGetIntegerv(f, &test[0]);
- if (test[0] != 0 || test[1] != 0 || test[2] != 0 || test[3] != 0)
- {
- logger->log("\n%d = %d, %d, %d, %d", f,
- test[0], test[1], test[2], test[3]);
- }
- }
-}
-
-void ModernOpenGLGraphics::drawImageRect(const int x, const int y,
- const int w, const int h,
- const ImageRect &restrict imgRect)
- restrict2
-{
- #include "render/graphics_drawImageRect.hpp"
-}
-
-void ModernOpenGLGraphics::calcImageRect(ImageVertexes *restrict const vert,
- const int x, const int y,
- const int w, const int h,
- const ImageRect &restrict imgRect)
- restrict2
-{
- #include "render/graphics_calcImageRect.hpp"
-}
-
-void ModernOpenGLGraphics::clearScreen() const restrict2
-{
- mglClear(GL_COLOR_BUFFER_BIT |
- GL_DEPTH_BUFFER_BIT |
- GL_STENCIL_BUFFER_BIT);
-}
-
-void ModernOpenGLGraphics::createGLContext(const bool custom) restrict2
-{
- if (custom)
- {
- if (mGLContext != nullptr)
- SDL::makeCurrentContext(mGLContext);
- else
- mGLContext = SDL::createGLContext(mWindow, 3, 3, 0x01);
- }
- else
- {
- Graphics::createGLContext(false);
- }
-}
-
-void ModernOpenGLGraphics::finalize(ImageCollection *restrict const col)
- restrict2
-{
- if (col == nullptr)
- return;
- FOR_EACH (ImageCollectionIter, it, col->draws)
- finalize(*it);
-}
-
-void ModernOpenGLGraphics::finalize(ImageVertexes *restrict const vert)
- restrict2
-{
- // in future need convert in each switchVp/continueVp
-
- if (vert == nullptr)
- return;
- OpenGLGraphicsVertexes &ogl = vert->ogl;
- const STD_VECTOR<int> &vp = ogl.mVp;
- STD_VECTOR<int>::const_iterator ivp;
- const STD_VECTOR<int>::const_iterator ivp_end = vp.end();
- STD_VECTOR<GLint*> &intTexPool = ogl.mIntTexPool;
- STD_VECTOR<GLint*>::const_iterator ft;
- const STD_VECTOR<GLint*>::const_iterator ft_end = intTexPool.end();
- STD_VECTOR<GLuint> &vbos = ogl.mVbo;
- STD_VECTOR<GLuint>::const_iterator ivbo;
-
- const int sz = CAST_S32(intTexPool.size());
- vbos.resize(sz);
- mglGenBuffers(sz, &vbos[0]);
-/*
- for (int f = 0; f < sz; f ++)
- logger->log("gen buffers: %u", vbos[f]);
-*/
-
- for (ft = intTexPool.begin(), ivp = vp.begin(), ivbo = vbos.begin();
- ft != ft_end && ivp != ivp_end;
- ++ ft, ++ ivp, ++ ivbo)
- {
- bindArrayBuffer(*ivbo);
-/*
- logger->log("allocate: %d, %ld", mVboBinded,
- (*ivp) * sizeof(GLint));
-*/
- mglBufferData(GL_ARRAY_BUFFER, (*ivp) * sizeof(GLint),
- *ft, GL_STATIC_DRAW);
- }
-
- for (STD_VECTOR<GLint*>::iterator it = intTexPool.begin();
- it != intTexPool.end(); ++ it)
- {
- delete [] (*it);
- }
- intTexPool.clear();
-}
-
-void ModernOpenGLGraphics::drawTriangleArray(const int size) restrict2
-{
-// logger->log("allocate: %d, %ld", mVboBinded, size * sizeof(GLint));
- mglBufferData(GL_ARRAY_BUFFER, size * sizeof(GLint),
- mIntArray, GL_STREAM_DRAW);
-#ifdef DEBUG_DRAW_CALLS
- mDrawCalls ++;
-#endif // DEBUG_DRAW_CALLS
- mglDrawArrays(GL_TRIANGLES, 0, size / 4);
-#ifdef OPENGLERRORS
- graphicsManager.logError();
-#endif // OPENGLERRORS
-}
-
-void ModernOpenGLGraphics::drawTriangleArray(const GLint *restrict const array,
- const int size) restrict2
-{
-// logger->log("allocate: %d, %ld", mVboBinded, size * sizeof(GLint));
- mglBufferData(GL_ARRAY_BUFFER, size * sizeof(GLint),
- array, GL_STREAM_DRAW);
-#ifdef DEBUG_DRAW_CALLS
- mDrawCalls ++;
-#endif // DEBUG_DRAW_CALLS
- mglDrawArrays(GL_TRIANGLES, 0, size / 4);
-#ifdef OPENGLERRORS
- graphicsManager.logError();
-#endif // OPENGLERRORS
-}
-
-void ModernOpenGLGraphics::drawLineArrays(const int size)
-{
-// logger->log("allocate: %d, %ld", mVboBinded, size * sizeof(GLint));
- mglBufferData(GL_ARRAY_BUFFER, size * sizeof(GLint),
- mIntArray, GL_STREAM_DRAW);
-#ifdef DEBUG_DRAW_CALLS
- mDrawCalls ++;
-#endif // DEBUG_DRAW_CALLS
- mglDrawArrays(GL_LINES, 0, size / 4);
-#ifdef OPENGLERRORS
- graphicsManager.logError();
-#endif // OPENGLERRORS
-}
-
-#ifdef DEBUG_BIND_TEXTURE
-void ModernOpenGLGraphics::debugBindTexture(const Image *restrict const image)
- restrict2
-{
- const std::string texture = image->mIdPath;
- if (mOldTexture != texture)
- {
- if ((!mOldTexture.empty() || !texture.empty())
- && mOldTextureId != image->mGLImage)
- {
- logger->log("bind: %s (%d) to %s (%d)", mOldTexture.c_str(),
- mOldTextureId, texture.c_str(), image->mGLImage);
- }
- mOldTextureId = image->mGLImage;
- mOldTexture = texture;
- }
-}
-#else // DEBUG_BIND_TEXTURE
-void ModernOpenGLGraphics::debugBindTexture(const Image *restrict const
- image A_UNUSED) restrict2
-{
-}
-#endif // DEBUG_BIND_TEXTURE
-
-#endif // defined(USE_OPENGL) && !defined(ANDROID) &&
- // !defined(__native_client__)
diff --git a/src/render/modernopenglgraphics.h b/src/render/modernopenglgraphics.h
deleted file mode 100644
index f20acab1b..000000000
--- a/src/render/modernopenglgraphics.h
+++ /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/>.
- */
-
-#ifndef RENDER_MODERNOPENGLGRAPHICS_H
-#define RENDER_MODERNOPENGLGRAPHICS_H
-
-#if defined(USE_OPENGL) && !defined(ANDROID) && !defined(__native_client__)
-
-#include "localconsts.h"
-
-#include "render/graphics.h"
-
-#include "resources/fboinfo.h"
-
-#ifdef ANDROID
-#include <GLES/gl.h>
-#include <GLES/glext.h>
-#include <GLES2/gl2.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)
-#if defined(__APPLE__)
-#include <OpenGL/glext.h>
-#elif !defined(__native_client__)
-#include <GL/glext.h>
-#endif // defined(__APPLE__)
-#endif // ANDROID
-
-class OpenGLGraphicsVertexes;
-class ShaderProgram;
-
-class ModernOpenGLGraphics final : public Graphics
-{
- public:
- ModernOpenGLGraphics();
-
- A_DELETE_COPY(ModernOpenGLGraphics)
-
- ~ModernOpenGLGraphics();
-
- void postInit() restrict2 override final;
-
- void setColor(const Color &restrict color) restrict2 override final;
-
- void screenResized() restrict2 override final;
-
- void finalize(ImageCollection *restrict const col)
- restrict2 override final;
-
- void finalize(ImageVertexes *restrict const vert)
- restrict2 override final;
-
- void testDraw() restrict2 override final;
-
- void removeArray(const uint32_t id,
- uint32_t *restrict const arr)
- restrict2 override final A_NONNULL(3);
-
- void createGLContext(const bool custom) restrict2 override final;
-
- #include "render/graphicsdef.hpp"
- RENDER_GRAPHICSDEF_HPP
-
- #include "render/openglgraphicsdef.hpp"
- RENDER_OPENGLGRAPHICSDEF_HPP
-
- #include "render/openglgraphicsdefadvanced.hpp"
- RENDER_OPENGLGRAPHICSDEFADVANCED_HPP
-
- private:
- void deleteGLObjects() restrict2;
-
- inline void drawQuad(const int srcX,
- const int srcY,
- const int dstX,
- const int dstY,
- const int width,
- const int height) restrict2 A_INLINE;
-
- inline void drawRescaledQuad(const int srcX, const int srcY,
- const int dstX, const int dstY,
- const int width, const int height,
- const int desiredWidth,
- const int desiredHeight)
- restrict2 A_INLINE;
-
- inline void drawTriangleArray(const int size) restrict2 A_INLINE;
-
- inline void drawTriangleArray(const GLint *restrict const array,
- const int size) restrict2 A_INLINE;
-
- inline void drawLineArrays(const int size) restrict2 A_INLINE;
-
- inline void bindArrayBuffer(const GLuint vbo) restrict2 A_INLINE;
-
- inline void bindArrayBufferAndAttributes(const GLuint vbo)
- restrict2 A_INLINE;
-
- inline void bindAttributes() restrict2 A_INLINE;
-
- inline void bindElementBuffer(const GLuint ebo) restrict2 A_INLINE;
-
- GLint *mIntArray A_NONNULLPOINTER;
- GLint *mIntArrayCached A_NONNULLPOINTER;
- ShaderProgram *mProgram;
- float mAlphaCached;
- int mVpCached;
-
- float mFloatColor;
- int mMaxVertices;
- GLuint mProgramId;
- GLuint mSimpleColorUniform;
- GLint mPosAttrib;
- GLint mTextureColorUniform;
- GLuint mScreenUniform;
- GLuint mDrawTypeUniform;
- GLuint mVao;
- GLuint mVbo;
- GLuint mEbo;
- GLuint mVboBinded;
- GLuint mEboBinded;
- GLuint mAttributesBinded;
- bool mColorAlpha;
- bool mTextureDraw;
-#ifdef DEBUG_BIND_TEXTURE
- std::string mOldTexture;
- unsigned mOldTextureId;
-#endif // DEBUG_BIND_TEXTURE
-
- FBOInfo mFbo;
-};
-#endif // defined(USE_OPENGL) && !defined(ANDROID) &&
- // !defined(__native_client__)
-
-#endif // RENDER_MODERNOPENGLGRAPHICS_H
diff --git a/src/render/nacl/naclfunctions.h b/src/render/nacl/naclfunctions.h
deleted file mode 100644
index c7b24f10d..000000000
--- a/src/render/nacl/naclfunctions.h
+++ /dev/null
@@ -1,35 +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 RENDER_NACL_NACLFUNCTIONS_H
-#define RENDER_NACL_NACLFUNCTIONS_H
-
-#if defined(__native_client__) && defined(USE_OPENGL)
-
-#include <ppapi/c/ppb_graphics_3d.h>
-
-extern const struct PPB_Graphics3D_1_0 *graphics3dInterface;
-extern PP_Resource gles2Context;
-
-#define naclResizeBuffers(...) \
- graphics3dInterface->ResizeBuffers(gles2Context, __VA_ARGS__)
-
-#endif // defined(__native_client__) && defined(USE_OPENGL)
-#endif // RENDER_NACL_NACLFUNCTIONS_H
diff --git a/src/render/nacl/naclgles.cpp b/src/render/nacl/naclgles.cpp
deleted file mode 100644
index 98e863594..000000000
--- a/src/render/nacl/naclgles.cpp
+++ /dev/null
@@ -1,55 +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/>.
- */
-
-#if defined(__native_client__) && defined(USE_OPENGL)
-
-#include "render/nacl/naclgles.h"
-
-#include "logger.h"
-
-#include "render/opengl/mglfunctions.h"
-
-#include <ppapi_simple/ps.h>
-
-#include <ppapi/c/ppb_graphics_3d.h>
-#include <ppapi/c/ppb_opengles2.h>
-
-#include <ppapi/gles2/gl2ext_ppapi.h>
-
-#include "debug.h"
-
-const struct PPB_OpenGLES2* gles2Interface = nullptr;
-PP_Resource gles2Context = 0;
-const struct PPB_Graphics3D_1_0 *graphics3dInterface = nullptr;
-
-void NaclGles::initGles()
-{
- gles2Interface = static_cast<const PPB_OpenGLES2*>(
- PSGetInterface(PPB_OPENGLES2_INTERFACE));
- graphics3dInterface = static_cast<const PPB_Graphics3D_1_0*>(
- PSGetInterface(PPB_GRAPHICS_3D_INTERFACE_1_0));
- gles2Context = glGetCurrentContextPPAPI();
-
- logger->log("InitGles: %p, %d",
- reinterpret_cast<const void*>(gles2Interface),
- gles2Context);
-}
-
-#endif // defined(__native_client__) && defined(USE_OPENGL)
diff --git a/src/render/nacl/naclgles.h b/src/render/nacl/naclgles.h
deleted file mode 100644
index 6d7683190..000000000
--- a/src/render/nacl/naclgles.h
+++ /dev/null
@@ -1,32 +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 RENDER_NACL_NACLGLES_H
-#define RENDER_NACL_NACLGLES_H
-
-#if defined(__native_client__) && defined(USE_OPENGL)
-
-namespace NaclGles
-{
- void initGles();
-} // namespace NaclGles
-
-#endif // defined(__native_client__) && defined(USE_OPENGL)
-#endif // RENDER_NACL_NACLGLES_H
diff --git a/src/render/normalopenglgraphics.cpp b/src/render/normalopenglgraphics.cpp
deleted file mode 100644
index 96aca6f15..000000000
--- a/src/render/normalopenglgraphics.cpp
+++ /dev/null
@@ -1,1782 +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) && !defined(__native_client__)
-
-#include "render/normalopenglgraphics.h"
-
-#ifdef OPENGLERRORS
-#include "graphicsmanager.h"
-#endif // OPENGLERRORS
-
-#ifdef DEBUG_OPENGL
-#include "render/opengl/mgl.h"
-#endif // DEBUG_OPENGL
-
-#include "render/vertexes/imagecollection.h"
-
-#include "resources/imagerect.h"
-#include "resources/openglimagehelper.h"
-
-#include "resources/image/image.h"
-
-#include "utils/sdlcheckutils.h"
-
-#include "debug.h"
-
-#define vertFill2D(tVar, vVar, x1, y1, x2, y2, dstX, dstY, w, h) \
- tVar[vp + 0] = x1; \
- tVar[vp + 1] = y1; \
- tVar[vp + 2] = x2; \
- tVar[vp + 3] = y1; \
- tVar[vp + 4] = x2; \
- tVar[vp + 5] = y2; \
- tVar[vp + 6] = x1; \
- tVar[vp + 7] = y2; \
- vVar[vp + 0] = dstX; \
- vVar[vp + 1] = dstY; \
- vVar[vp + 2] = dstX + w; \
- vVar[vp + 3] = dstY; \
- vVar[vp + 4] = dstX + w; \
- vVar[vp + 5] = dstY + h; \
- vVar[vp + 6] = dstX; \
- vVar[vp + 7] = dstY + h;
-
-
-#define vertFillNv(tVar, vVar, srcX, srcY, dstX, dstY, w, h) \
- tVar[vp + 0] = srcX; \
- tVar[vp + 1] = srcY; \
- tVar[vp + 2] = srcX + w; \
- tVar[vp + 3] = srcY; \
- tVar[vp + 4] = srcX + w; \
- tVar[vp + 5] = srcY + h; \
- tVar[vp + 6] = srcX; \
- tVar[vp + 7] = srcY + h; \
- vVar[vp + 0] = dstX; \
- vVar[vp + 1] = dstY; \
- vVar[vp + 2] = dstX + w; \
- vVar[vp + 3] = dstY; \
- vVar[vp + 4] = dstX + w; \
- vVar[vp + 5] = dstY + h; \
- vVar[vp + 6] = dstX; \
- vVar[vp + 7] = dstY + h;
-
-namespace
-{
- const void *vertPtr = nullptr;
-} // namespace
-
-GLuint NormalOpenGLGraphics::mTextureBinded = 0;
-#ifdef DEBUG_DRAW_CALLS
-unsigned int NormalOpenGLGraphics::mDrawCalls = 0;
-unsigned int NormalOpenGLGraphics::mLastDrawCalls = 0;
-#endif // DEBUG_DRAW_CALLS
-#ifdef DEBUG_BIND_TEXTURE
-unsigned int NormalOpenGLGraphics::mBinds = 0;
-unsigned int NormalOpenGLGraphics::mLastBinds = 0;
-#endif // DEBUG_BIND_TEXTURE
-
-NormalOpenGLGraphics::NormalOpenGLGraphics() :
- mFloatTexArray(nullptr),
- mIntTexArray(nullptr),
- mIntVertArray(nullptr),
- mFloatTexArrayCached(nullptr),
- mIntTexArrayCached(nullptr),
- mIntVertArrayCached(nullptr),
- mAlphaCached(1.0F),
- mVpCached(0),
- mTexture(false),
- mIsByteColor(false),
- mByteColor(),
- mImageCached(0),
- mFloatColor(1.0F),
- mMaxVertices(500),
- mColorAlpha(false),
-#ifdef DEBUG_BIND_TEXTURE
- mOldTexture(),
- mOldTextureId(0),
-#endif // DEBUG_BIND_TEXTURE
- mFbo()
-{
- mOpenGL = RENDER_NORMAL_OPENGL;
- mName = "normal OpenGL";
-}
-
-NormalOpenGLGraphics::~NormalOpenGLGraphics()
-{
- deleteArraysInternal();
-}
-
-void NormalOpenGLGraphics::initArrays(const int vertCount) restrict2
-{
- mMaxVertices = vertCount;
- if (mMaxVertices < 500)
- mMaxVertices = 500;
- else if (mMaxVertices > 1024)
- mMaxVertices = 1024;
-
- // need alocate small size, after if limit reached reallocate to double size
- vertexBufSize = mMaxVertices;
- const size_t sz = mMaxVertices * 4 + 30;
- if (mFloatTexArray == nullptr)
- mFloatTexArray = new GLfloat[sz];
- if (mIntTexArray == nullptr)
- mIntTexArray = new GLint[sz];
- if (mIntVertArray == nullptr)
- mIntVertArray = new GLint[sz];
- if (mFloatTexArrayCached == nullptr)
- mFloatTexArrayCached = new GLfloat[sz];
- if (mIntTexArrayCached == nullptr)
- mIntTexArrayCached = new GLint[sz];
- if (mIntVertArrayCached == nullptr)
- mIntVertArrayCached = new GLint[sz];
-}
-
-void NormalOpenGLGraphics::deleteArrays() restrict2
-{
- deleteArraysInternal();
-}
-
-void NormalOpenGLGraphics::deleteArraysInternal() restrict2
-{
- delete [] mFloatTexArray;
- mFloatTexArray = nullptr;
- delete [] mIntTexArray;
- mIntTexArray = nullptr;
- delete [] mIntVertArray;
- mIntVertArray = nullptr;
- delete [] mFloatTexArrayCached;
- mFloatTexArrayCached = nullptr;
- delete [] mIntTexArrayCached;
- mIntTexArrayCached = nullptr;
- delete [] mIntVertArrayCached;
- mIntVertArrayCached = nullptr;
-}
-
-bool NormalOpenGLGraphics::setVideoMode(const int w, const int h,
- const int scale,
- const int bpp,
- const bool fs,
- const bool hwaccel,
- const bool resize,
- const bool noFrame,
- const bool allowHighDPI) restrict2
-{
- setMainFlags(w, h,
- scale,
- bpp,
- fs,
- hwaccel,
- resize,
- noFrame,
- allowHighDPI);
-
- return setOpenGLMode();
-}
-
-static inline void bindPointerIntFloat(const GLint *restrict const vert,
- const GLfloat *restrict const tex)
- A_INLINE;
-
-static inline void bindPointerIntFloat(const GLint *restrict const vert,
- const GLfloat *restrict const tex)
-{
- if (vertPtr != vert)
- {
- vertPtr = vert;
- glVertexPointer(2, GL_INT, 0, vert);
- glTexCoordPointer(2, GL_FLOAT, 0, tex);
- }
-}
-
-static inline void bindPointerInt(const GLint *restrict const vert,
- const GLint *restrict const tex) A_INLINE;
-
-static inline void bindPointerInt(const GLint *restrict const vert,
- const GLint *restrict const tex)
-{
- if (vertPtr != vert)
- {
- vertPtr = vert;
- glVertexPointer(2, GL_INT, 0, vert);
- glTexCoordPointer(2, GL_INT, 0, tex);
- }
-}
-
-static inline void drawQuad(const Image *restrict const image,
- const int srcX, const int srcY,
- const int dstX, const int dstY,
- const int width, const int height)
- A_NONNULL(1) A_INLINE;
-
-static inline void drawQuad(const Image *restrict const image,
- const int srcX, const int srcY,
- const int dstX, const int dstY,
- const int width, const int height)
-{
- if (OpenGLImageHelper::mTextureType == GL_TEXTURE_2D)
- {
- const float tw = static_cast<float>(image->mTexWidth);
- const float th = static_cast<float>(image->mTexHeight);
- // Find OpenGL normalized texture coordinates.
- const float texX1 = static_cast<float>(srcX) / tw;
- const float texY1 = static_cast<float>(srcY) / th;
- const float texX2 = static_cast<float>(srcX + width) / tw;
- const float texY2 = static_cast<float>(srcY + height) / th;
-
- GLfloat tex[] =
- {
- texX1, texY1,
- texX2, texY1,
- texX2, texY2,
- texX1, texY2
- };
-
- GLint vert[] =
- {
- dstX, dstY,
- dstX + width, dstY,
- dstX + width, dstY + height,
- dstX, dstY + height
- };
-
- bindPointerIntFloat(&vert[0], &tex[0]);
-#ifdef DEBUG_DRAW_CALLS
- NormalOpenGLGraphics::mDrawCalls ++;
-#endif // DEBUG_DRAW_CALLS
-
- glDrawArrays(GL_QUADS, 0, 4);
-#ifdef OPENGLERRORS
- graphicsManager.logError();
-#endif // OPENGLERRORS
- }
- else
- {
- GLint tex[] =
- {
- srcX, srcY,
- srcX + width, srcY,
- srcX + width, srcY + height,
- srcX, srcY + height
- };
- GLint vert[] =
- {
- dstX, dstY,
- dstX + width, dstY,
- dstX + width, dstY + height,
- dstX, dstY + height
- };
-
- bindPointerInt(&vert[0], &tex[0]);
-#ifdef DEBUG_DRAW_CALLS
- NormalOpenGLGraphics::mDrawCalls ++;
-#endif // DEBUG_DRAW_CALLS
-
- glDrawArrays(GL_QUADS, 0, 4);
-#ifdef OPENGLERRORS
- graphicsManager.logError();
-#endif // OPENGLERRORS
- }
-}
-
-static inline void drawRescaledQuad(const Image *restrict const image,
- const int srcX, const int srcY,
- const int dstX, const int dstY,
- const int width, const int height,
- const int desiredWidth,
- const int desiredHeight)
- A_NONNULL(1) A_INLINE;
-
-static inline void drawRescaledQuad(const Image *restrict const image,
- const int srcX, const int srcY,
- const int dstX, const int dstY,
- const int width, const int height,
- const int desiredWidth,
- const int desiredHeight)
-{
- if (OpenGLImageHelper::mTextureType == GL_TEXTURE_2D)
- {
- const float tw = static_cast<float>(image->mTexWidth);
- const float th = static_cast<float>(image->mTexHeight);
- // Find OpenGL normalized texture coordinates.
- const float texX1 = static_cast<float>(srcX) / tw;
- const float texY1 = static_cast<float>(srcY) / th;
- const float texX2 = static_cast<float>(srcX + width) / tw;
- const float texY2 = static_cast<float>(srcY + height) / th;
-
- GLfloat tex[] =
- {
- texX1, texY1,
- texX2, texY1,
- texX2, texY2,
- texX1, texY2
- };
-
- GLint vert[] =
- {
- dstX, dstY,
- dstX + desiredWidth, dstY,
- dstX + desiredWidth, dstY + desiredHeight,
- dstX, dstY + desiredHeight
- };
-
- bindPointerIntFloat(&vert[0], &tex[0]);
-#ifdef DEBUG_DRAW_CALLS
- NormalOpenGLGraphics::mDrawCalls ++;
-#endif // DEBUG_DRAW_CALLS
-
- glDrawArrays(GL_QUADS, 0, 4);
-#ifdef OPENGLERRORS
- graphicsManager.logError();
-#endif // OPENGLERRORS
- }
- else
- {
- GLint tex[] =
- {
- srcX, srcY,
- srcX + width, srcY,
- srcX + width, srcY + height,
- srcX, srcY + height
- };
- GLint vert[] =
- {
- dstX, dstY,
- dstX + desiredWidth, dstY,
- dstX + desiredWidth, dstY + desiredHeight,
- dstX, dstY + desiredHeight
- };
-
- bindPointerInt(&vert[0], &tex[0]);
-#ifdef DEBUG_DRAW_CALLS
- NormalOpenGLGraphics::mDrawCalls ++;
-#endif // DEBUG_DRAW_CALLS
-
- glDrawArrays(GL_QUADS, 0, 4);
-#ifdef OPENGLERRORS
- graphicsManager.logError();
-#endif // OPENGLERRORS
- }
-}
-
-void NormalOpenGLGraphics::drawImage(const Image *restrict const image,
- int dstX, int dstY) restrict2
-{
- drawImageInline(image, dstX, dstY);
-}
-
-void NormalOpenGLGraphics::drawImageInline(const Image *restrict const image,
- int dstX, int dstY) restrict2
-{
- FUNC_BLOCK("Graphics::drawImage", 1)
- if (image == nullptr)
- return;
-
- setColorAlpha(image->mAlpha);
-#ifdef DEBUG_BIND_TEXTURE
- debugBindTexture(image);
-#endif // DEBUG_BIND_TEXTURE
-
- bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
- enableTexturingAndBlending();
-
- const SDL_Rect &imageRect = image->mBounds;
- drawQuad(image, imageRect.x, imageRect.y,
- dstX, dstY, imageRect.w, imageRect.h);
-}
-
-void NormalOpenGLGraphics::copyImage(const Image *restrict const image,
- int dstX, int dstY) restrict2
-{
- drawImageInline(image, dstX, dstY);
-}
-
-void NormalOpenGLGraphics::testDraw() restrict2
-{
- if (OpenGLImageHelper::mTextureType == GL_TEXTURE_2D)
- {
- GLfloat tex[] =
- {
- 0.0f, 0.781250f,
- 0.0f, 0.781250f,
- 0.0f, 0.585938f,
- 0.0f, 0.585938f
- };
-
- GLint vert[] =
- {
- 0, 0,
- 800, 0,
- 800, 600,
- 0, 600
- };
-
- bindPointerIntFloat(&vert[0], &tex[0]);
-#ifdef DEBUG_DRAW_CALLS
- NormalOpenGLGraphics::mDrawCalls ++;
-#endif // DEBUG_DRAW_CALLS
-
- glDrawArrays(GL_QUADS, 0, 4);
-#ifdef OPENGLERRORS
- graphicsManager.logError();
-#endif // OPENGLERRORS
- }
- else
- {
- GLint tex[] =
- {
- 0, 0,
- 800, 0,
- 800, 600,
- 0, 600
- };
-
- GLint vert[] =
- {
- 0, 0,
- 800, 0,
- 800, 600,
- 0, 600
- };
-
- bindPointerInt(&vert[0], &tex[0]);
-#ifdef DEBUG_DRAW_CALLS
- NormalOpenGLGraphics::mDrawCalls ++;
-#endif // DEBUG_DRAW_CALLS
-
- glDrawArrays(GL_QUADS, 0, 4);
-#ifdef OPENGLERRORS
- graphicsManager.logError();
-#endif // OPENGLERRORS
- }
-}
-
-void NormalOpenGLGraphics::drawImageCached(const Image *restrict const image,
- int x, int y) restrict2
-{
- if (image == nullptr)
- return;
-
- if (image->mGLImage != mImageCached)
- {
- completeCache();
- mImageCached = image->mGLImage;
- mAlphaCached = image->mAlpha;
- }
-
- const SDL_Rect &imageRect = image->mBounds;
- const int w = imageRect.w;
- const int h = imageRect.h;
-
- if (w == 0 || h == 0)
- return;
-
- const int srcX = imageRect.x;
- const int srcY = imageRect.y;
-
- const float tw = static_cast<float>(image->mTexWidth);
- const float th = static_cast<float>(image->mTexHeight);
-
- const unsigned int vLimit = mMaxVertices * 4;
-
- unsigned int vp = mVpCached;
-
- // Draw a set of textured rectangles
- if (OpenGLImageHelper::mTextureType == GL_TEXTURE_2D)
- {
- const float texX1 = static_cast<float>(srcX) / tw;
- const float texY1 = static_cast<float>(srcY) / th;
-
- const float texX2 = static_cast<float>(srcX + w) / tw;
- const float texY2 = static_cast<float>(srcY + h) / th;
-
- vertFill2D(mFloatTexArrayCached, mIntVertArrayCached,
- texX1, texY1, texX2, texY2,
- x, y, w, h);
-
- vp += 8;
- if (vp >= vLimit)
- {
- completeCache();
- vp = 0;
- }
- else
- {
- mVpCached = vp;
- }
- }
- else
- {
- vertFillNv(mIntTexArrayCached, mIntVertArrayCached,
- srcX, srcY, x, y, w, h);
-
- vp += 8;
- if (vp >= vLimit)
- {
- completeCache();
- vp = 0;
- }
- else
- {
- mVpCached = vp;
- }
- }
-}
-
-void NormalOpenGLGraphics::drawPatternCached(const Image *restrict const image,
- const int x,
- const int y,
- const int w,
- const int h) restrict2
-{
- FUNC_BLOCK("Graphics::drawPatternCached", 1)
- if (image == nullptr)
- return;
-
- if (image->mGLImage != mImageCached)
- {
- completeCache();
- mImageCached = image->mGLImage;
- }
-
- const SDL_Rect &imageRect = image->mBounds;
- const int srcX = imageRect.x;
- const int srcY = imageRect.y;
- const int iw = imageRect.w;
- const int ih = imageRect.h;
-
- if (iw == 0 || ih == 0)
- return;
-
- const float tw = static_cast<float>(image->mTexWidth);
- const float th = static_cast<float>(image->mTexHeight);
-
- unsigned int vp = mVpCached;
- const unsigned int vLimit = mMaxVertices * 4;
- // Draw a set of textured rectangles
- if (OpenGLImageHelper::mTextureType == GL_TEXTURE_2D)
- {
- const float texX1 = static_cast<float>(srcX) / tw;
- const float texY1 = static_cast<float>(srcY) / th;
-
- for (int py = 0; py < h; py += ih)
- {
- const int height = (py + ih >= h) ? h - py : ih;
- const int dstY = y + py;
- const float texY2 = static_cast<float>(srcY + height) / th;
- for (int px = 0; px < w; px += iw)
- {
- const int width = (px + iw >= w) ? w - px : iw;
- const int dstX = x + px;
-
- const float texX2 = static_cast<float>(srcX + width) / tw;
-
- vertFill2D(mFloatTexArrayCached, mIntVertArrayCached,
- texX1, texY1, texX2, texY2,
- dstX, dstY, width, height);
-
- vp += 8;
- if (vp >= vLimit)
- {
- completeCache();
- vp = 0;
- }
- }
- }
- }
- else
- {
- for (int py = 0; py < h; py += ih)
- {
- const int height = (py + ih >= h) ? h - py : ih;
- const int dstY = y + py;
- for (int px = 0; px < w; px += iw)
- {
- const int width = (px + iw >= w) ? w - px : iw;
- const int dstX = x + px;
-
- vertFillNv(mIntTexArrayCached, mIntVertArrayCached,
- srcX, srcY, dstX, dstY, width, height);
-
- vp += 8;
- if (vp >= vLimit)
- {
- completeCache();
- vp = 0;
- }
- }
- }
- }
- mVpCached = vp;
-}
-
-void NormalOpenGLGraphics::completeCache() restrict2
-{
- if (mImageCached == 0u)
- return;
-
- setColorAlpha(mAlphaCached);
-#ifdef DEBUG_BIND_TEXTURE
- debugBindTexture(image);
-#endif // DEBUG_BIND_TEXTURE
-
- bindTexture(OpenGLImageHelper::mTextureType, mImageCached);
- enableTexturingAndBlending();
-
- if (OpenGLImageHelper::mTextureType == GL_TEXTURE_2D)
- drawQuadArrayfiCached(mVpCached);
- else
- drawQuadArrayiiCached(mVpCached);
-
- mImageCached = 0;
- mVpCached = 0;
-}
-
-void NormalOpenGLGraphics::drawRescaledImage(const Image *restrict const image,
- int dstX, int dstY,
- const int desiredWidth,
- const int desiredHeight) restrict2
-{
- FUNC_BLOCK("Graphics::drawRescaledImage", 1)
- if (image == nullptr)
- return;
-
- const SDL_Rect &imageRect = image->mBounds;
-
- // Just draw the image normally when no resizing is necessary,
- if (imageRect.w == desiredWidth && imageRect.h == desiredHeight)
- {
- drawImageInline(image, dstX, dstY);
- return;
- }
-
- setColorAlpha(image->mAlpha);
-#ifdef DEBUG_BIND_TEXTURE
- debugBindTexture(image);
-#endif // DEBUG_BIND_TEXTURE
-
- bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
- enableTexturingAndBlending();
-
- // Draw a textured quad.
- drawRescaledQuad(image, imageRect.x, imageRect.y, dstX, dstY,
- imageRect.w, imageRect.h, desiredWidth, desiredHeight);
-}
-
-void NormalOpenGLGraphics::drawPattern(const Image *restrict const image,
- const int x, const int y,
- const int w, const int h) restrict2
-{
- drawPatternInline(image, x, y, w, h);
-}
-
-void NormalOpenGLGraphics::drawPatternInline(const Image *restrict const image,
- const int x,
- const int y,
- const int w,
- const int h) restrict2
-{
- FUNC_BLOCK("Graphics::drawPattern", 1)
- if (image == nullptr)
- return;
-
- const SDL_Rect &imageRect = image->mBounds;
- const int srcX = imageRect.x;
- const int srcY = imageRect.y;
- const int iw = imageRect.w;
- const int ih = imageRect.h;
-
- if (iw == 0 || ih == 0)
- return;
-
- const float tw = static_cast<float>(image->mTexWidth);
- const float th = static_cast<float>(image->mTexHeight);
-
- setColorAlpha(image->mAlpha);
-
-#ifdef DEBUG_BIND_TEXTURE
- debugBindTexture(image);
-#endif // DEBUG_BIND_TEXTURE
-
- bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
-
- enableTexturingAndBlending();
-
- unsigned int vp = 0;
- const unsigned int vLimit = mMaxVertices * 4;
- // Draw a set of textured rectangles
- if (OpenGLImageHelper::mTextureType == GL_TEXTURE_2D)
- {
- const float texX1 = static_cast<float>(srcX) / tw;
- const float texY1 = static_cast<float>(srcY) / th;
-
- for (int py = 0; py < h; py += ih)
- {
- const int height = (py + ih >= h) ? h - py : ih;
- const int dstY = y + py;
- const float texY2 = static_cast<float>(srcY + height) / th;
- for (int px = 0; px < w; px += iw)
- {
- const int width = (px + iw >= w) ? w - px : iw;
- const int dstX = x + px;
- const float texX2 = static_cast<float>(srcX + width) / tw;
-
- vertFill2D(mFloatTexArray, mIntVertArray,
- texX1, texY1, texX2, texY2,
- dstX, dstY, width, height);
-
- vp += 8;
- if (vp >= vLimit)
- {
- drawQuadArrayfi(vp);
- vp = 0;
- }
- }
- }
- if (vp > 0)
- drawQuadArrayfi(vp);
- }
- else
- {
- for (int py = 0; py < h; py += ih)
- {
- const int height = (py + ih >= h) ? h - py : ih;
- const int dstY = y + py;
- for (int px = 0; px < w; px += iw)
- {
- const int width = (px + iw >= w) ? w - px : iw;
- const int dstX = x + px;
-
- vertFillNv(mIntTexArray, mIntVertArray,
- srcX, srcY, dstX, dstY, width, height);
-
- vp += 8;
- if (vp >= vLimit)
- {
- drawQuadArrayii(vp);
- vp = 0;
- }
- }
- }
- if (vp > 0)
- drawQuadArrayii(vp);
- }
-}
-
-void NormalOpenGLGraphics::drawRescaledPattern(const Image *
- restrict const image,
- const int x, const int y,
- const int w, const int h,
- const int scaledWidth,
- const int scaledHeight)
- restrict2
-{
- if (image == nullptr)
- return;
-
- if (scaledWidth == 0 || scaledHeight == 0)
- return;
-
- const SDL_Rect &imageRect = image->mBounds;
- const int iw = imageRect.w;
- const int ih = imageRect.h;
- if (iw == 0 || ih == 0)
- return;
-
- const int srcX = imageRect.x;
- const int srcY = imageRect.y;
-
- setColorAlpha(image->mAlpha);
-
-#ifdef DEBUG_BIND_TEXTURE
- debugBindTexture(image);
-#endif // DEBUG_BIND_TEXTURE
-
- bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
-
- enableTexturingAndBlending();
-
- unsigned int vp = 0;
- const unsigned int vLimit = mMaxVertices * 4;
-
- // Draw a set of textured rectangles
- if (OpenGLImageHelper::mTextureType == GL_TEXTURE_2D)
- {
- const float tw = static_cast<float>(image->mTexWidth);
- const float th = static_cast<float>(image->mTexHeight);
-
- const float texX1 = static_cast<float>(srcX) / tw;
- const float texY1 = static_cast<float>(srcY) / th;
-
- const float tFractionW = iw / tw;
- const float tFractionH = ih / th;
-
- for (int py = 0; py < h; py += scaledHeight)
- {
- const int height = (py + scaledHeight >= h)
- ? h - py : scaledHeight;
- const int dstY = y + py;
- const float visibleFractionH = static_cast<float>(height)
- / scaledHeight;
- const float texY2 = texY1 + tFractionH * visibleFractionH;
- for (int px = 0; px < w; px += scaledWidth)
- {
- const int width = (px + scaledWidth >= w)
- ? w - px : scaledWidth;
- const int dstX = x + px;
- const float visibleFractionW = static_cast<float>(width)
- / scaledWidth;
- const float texX2 = texX1 + tFractionW * visibleFractionW;
-
- vertFill2D(mFloatTexArray, mIntVertArray,
- texX1, texY1, texX2, texY2,
- dstX, dstY, width, height);
-
- vp += 8;
- if (vp >= vLimit)
- {
- drawQuadArrayfi(vp);
- vp = 0;
- }
- }
- }
- if (vp > 0)
- drawQuadArrayfi(vp);
- }
- else
- {
- const float scaleFactorW = static_cast<float>(scaledWidth) / iw;
- const float scaleFactorH = static_cast<float>(scaledHeight) / ih;
-
- for (int py = 0; py < h; py += scaledHeight)
- {
- const int height = (py + scaledHeight >= h)
- ? h - py : scaledHeight;
- const int dstY = y + py;
- const int scaledY = srcY + height / scaleFactorH;
- for (int px = 0; px < w; px += scaledWidth)
- {
- const int width = (px + scaledWidth >= w)
- ? w - px : scaledWidth;
- const int dstX = x + px;
- const int scaledX = srcX + width / scaleFactorW;
-
- mIntTexArray[vp + 0] = srcX;
- mIntTexArray[vp + 1] = srcY;
-
- mIntTexArray[vp + 2] = scaledX;
- mIntTexArray[vp + 3] = srcY;
-
- mIntTexArray[vp + 4] = scaledX;
- mIntTexArray[vp + 5] = scaledY;
-
- mIntTexArray[vp + 6] = srcX;
- mIntTexArray[vp + 7] = scaledY;
-
- mIntVertArray[vp + 0] = dstX;
- mIntVertArray[vp + 1] = dstY;
-
- mIntVertArray[vp + 2] = dstX + width;
- mIntVertArray[vp + 3] = dstY;
-
- mIntVertArray[vp + 4] = dstX + width;
- mIntVertArray[vp + 5] = dstY + height;
-
- mIntVertArray[vp + 6] = dstX;
- mIntVertArray[vp + 7] = dstY + height;
-
- vp += 8;
- if (vp >= vLimit)
- {
- drawQuadArrayii(vp);
- vp = 0;
- }
- }
- }
- if (vp > 0)
- drawQuadArrayii(vp);
- }
-}
-
-inline void NormalOpenGLGraphics::drawVertexes(const
- OpenGLGraphicsVertexes
- &restrict ogl) restrict2
-{
- const STD_VECTOR<GLint*> &intVertPool = ogl.mIntVertPool;
- STD_VECTOR<GLint*>::const_iterator iv;
- const STD_VECTOR<GLint*>::const_iterator iv_end = intVertPool.end();
- const STD_VECTOR<int> &vp = ogl.mVp;
- STD_VECTOR<int>::const_iterator ivp;
- const STD_VECTOR<int>::const_iterator ivp_end = vp.end();
-
- // Draw a set of textured rectangles
- if (OpenGLImageHelper::mTextureType == GL_TEXTURE_2D)
- {
- const STD_VECTOR<GLfloat*> &floatTexPool = ogl.mFloatTexPool;
- STD_VECTOR<GLfloat*>::const_iterator ft;
- const STD_VECTOR<GLfloat*>::const_iterator
- ft_end = floatTexPool.end();
-
- for (iv = intVertPool.begin(), ft = floatTexPool.begin(),
- ivp = vp.begin();
- iv != iv_end && ft != ft_end && ivp != ivp_end;
- ++ iv, ++ ft, ++ ivp)
- {
- drawQuadArrayfi(*iv, *ft, *ivp);
- }
- }
- else
- {
- const STD_VECTOR<GLint*> &intTexPool = ogl.mIntTexPool;
- STD_VECTOR<GLint*>::const_iterator it;
- const STD_VECTOR<GLint*>::const_iterator it_end = intTexPool.end();
-
- for (iv = intVertPool.begin(), it = intTexPool.begin(),
- ivp = vp.begin();
- iv != iv_end && it != it_end && ivp != ivp_end;
- ++ iv, ++ it, ++ ivp)
- {
- drawQuadArrayii(*iv, *it, *ivp);
- }
- }
-}
-
-void NormalOpenGLGraphics::calcPattern(ImageVertexes *restrict const vert,
- const Image *restrict const image,
- const int x,
- const int y,
- const int w,
- const int h) const restrict2
-{
- calcPatternInline(vert, image, x, y, w, h);
-}
-
-void NormalOpenGLGraphics::calcPatternInline(ImageVertexes *
- restrict const vert,
- const Image *restrict const image,
- const int x,
- const int y,
- const int w,
- const int h) const restrict2
-{
- if (image == nullptr || vert == nullptr)
- return;
-
- const SDL_Rect &imageRect = image->mBounds;
- const int iw = imageRect.w;
- const int ih = imageRect.h;
-
- if (iw == 0 || ih == 0)
- return;
-
- const int srcX = imageRect.x;
- const int srcY = imageRect.y;
- const float tw = static_cast<float>(image->mTexWidth);
- const float th = static_cast<float>(image->mTexHeight);
-
- const unsigned int vLimit = mMaxVertices * 4;
-
- OpenGLGraphicsVertexes &ogl = vert->ogl;
- unsigned int vp = ogl.continueVp();
-
- // Draw a set of textured rectangles
- if (OpenGLImageHelper::mTextureType == GL_TEXTURE_2D)
- {
- const float texX1 = static_cast<float>(srcX) / tw;
- const float texY1 = static_cast<float>(srcY) / th;
-
- GLfloat *floatTexArray = ogl.continueFloatTexArray();
- GLint *intVertArray = ogl.continueIntVertArray();
-
- for (int py = 0; py < h; py += ih)
- {
- const int height = (py + ih >= h) ? h - py : ih;
- const int dstY = y + py;
- const float texY2 = static_cast<float>(srcY + height) / th;
- for (int px = 0; px < w; px += iw)
- {
- const int width = (px + iw >= w) ? w - px : iw;
- const int dstX = x + px;
- const float texX2 = static_cast<float>(srcX + width) / tw;
-
- vertFill2D(floatTexArray, intVertArray,
- texX1, texY1, texX2, texY2,
- dstX, dstY, width, height);
-
- vp += 8;
- if (vp >= vLimit)
- {
- floatTexArray = ogl.switchFloatTexArray();
- intVertArray = ogl.switchIntVertArray();
- ogl.switchVp(vp);
- vp = 0;
- }
- }
- }
- }
- else
- {
- GLint *intTexArray = ogl.continueIntTexArray();
- GLint *intVertArray = ogl.continueIntVertArray();
-
- for (int py = 0; py < h; py += ih)
- {
- const int height = (py + ih >= h) ? h - py : ih;
- const int dstY = y + py;
- for (int px = 0; px < w; px += iw)
- {
- const int width = (px + iw >= w) ? w - px : iw;
- const int dstX = x + px;
-
- vertFillNv(intTexArray, intVertArray,
- srcX, srcY, dstX, dstY, width, height);
-
- vp += 8;
- if (vp >= vLimit)
- {
- intTexArray = ogl.switchIntTexArray();
- intVertArray = ogl.switchIntVertArray();
- ogl.switchVp(vp);
- vp = 0;
- }
- }
- }
- }
- ogl.switchVp(vp);
-}
-
-void NormalOpenGLGraphics::calcTileCollection(ImageCollection *
- restrict const vertCol,
- const Image *
- restrict const image,
- int x, int y) restrict2
-{
- if (vertCol == nullptr || image == nullptr)
- return;
- if (vertCol->currentGLImage != image->mGLImage)
- {
- ImageVertexes *const vert = new ImageVertexes;
- vertCol->currentGLImage = image->mGLImage;
- vertCol->currentVert = vert;
- vert->image = image;
- vertCol->draws.push_back(vert);
- calcTileVertexesInline(vert, image, x, y);
- }
- else
- {
- calcTileVertexesInline(vertCol->currentVert, image, x, y);
- }
-}
-
-void NormalOpenGLGraphics::drawTileCollection(const ImageCollection
- *restrict const vertCol)
- restrict2
-{
- const ImageVertexesVector &draws = vertCol->draws;
- const ImageCollectionCIter it_end = draws.end();
- for (ImageCollectionCIter it = draws.begin(); it != it_end; ++ it)
- {
- const ImageVertexes *const vert = *it;
- const Image *const image = vert->image;
-
- setColorAlpha(image->mAlpha);
-#ifdef DEBUG_BIND_TEXTURE
- debugBindTexture(image);
-#endif // DEBUG_BIND_TEXTURE
-
- bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
- enableTexturingAndBlending();
- drawVertexes(vert->ogl);
- }
-}
-
-void NormalOpenGLGraphics::calcPattern(ImageCollection *restrict const vertCol,
- const Image *restrict const image,
- const int x,
- const int y,
- const int w,
- const int h) const restrict2
-{
- if (vertCol == nullptr || image == nullptr)
- return;
- ImageVertexes *vert = nullptr;
- if (vertCol->currentGLImage != image->mGLImage)
- {
- vert = new ImageVertexes;
- vertCol->currentGLImage = image->mGLImage;
- vertCol->currentVert = vert;
- vert->image = image;
- vertCol->draws.push_back(vert);
- }
- else
- {
- vert = vertCol->currentVert;
- }
-
- calcPatternInline(vert, image, x, y, w, h);
-}
-
-void NormalOpenGLGraphics::calcTileVertexes(ImageVertexes *restrict const vert,
- const Image *restrict const image,
- int dstX, int dstY) const restrict2
-{
- calcTileVertexesInline(vert, image, dstX, dstY);
-}
-
-void NormalOpenGLGraphics::calcTileVertexesInline(ImageVertexes *
- restrict const vert,
- const Image *
- restrict const image,
- int dstX,
- int dstY) const restrict2
-{
- const SDL_Rect &imageRect = image->mBounds;
- const int w = imageRect.w;
- const int h = imageRect.h;
-
- if (w == 0 || h == 0)
- return;
-
- const int srcX = imageRect.x;
- const int srcY = imageRect.y;
-
- const float tw = static_cast<float>(image->mTexWidth);
- const float th = static_cast<float>(image->mTexHeight);
-
- const unsigned int vLimit = mMaxVertices * 4;
-
- OpenGLGraphicsVertexes &ogl = vert->ogl;
-
-// STD_VECTOR<int> *vps = ogl.getVp();
- unsigned int vp = ogl.continueVp();
-
- // Draw a set of textured rectangles
- if (OpenGLImageHelper::mTextureType == GL_TEXTURE_2D)
- {
- const float texX1 = static_cast<float>(srcX) / tw;
- const float texY1 = static_cast<float>(srcY) / th;
-
- const float texX2 = static_cast<float>(srcX + w) / tw;
- const float texY2 = static_cast<float>(srcY + h) / th;
-
- GLfloat *const floatTexArray = ogl.continueFloatTexArray();
- GLint *const intVertArray = ogl.continueIntVertArray();
-
- vertFill2D(floatTexArray, intVertArray,
- texX1, texY1, texX2, texY2,
- dstX, dstY, w, h);
-
- vp += 8;
- if (vp >= vLimit)
- {
- ogl.switchFloatTexArray();
- ogl.switchIntVertArray();
- ogl.switchVp(vp);
- vp = 0;
- }
- }
- else
- {
- GLint *const intTexArray = ogl.continueIntTexArray();
- GLint *const intVertArray = ogl.continueIntVertArray();
-
- vertFillNv(intTexArray, intVertArray,
- srcX, srcY, dstX, dstY, w, h);
-
- vp += 8;
- if (vp >= vLimit)
- {
- ogl.switchIntTexArray();
- ogl.switchIntVertArray();
- ogl.switchVp(vp);
- vp = 0;
- }
- }
- ogl.switchVp(vp);
-}
-
-void NormalOpenGLGraphics::drawTileVertexes(const ImageVertexes *
- restrict const vert) restrict2
-{
- if (vert == nullptr)
- return;
- const Image *const image = vert->image;
-
- setColorAlpha(image->mAlpha);
-#ifdef DEBUG_BIND_TEXTURE
- debugBindTexture(image);
-#endif // DEBUG_BIND_TEXTURE
-
- bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
- enableTexturingAndBlending();
- drawVertexes(vert->ogl);
-}
-
-void NormalOpenGLGraphics::calcWindow(ImageCollection *restrict const vertCol,
- const int x, const int y,
- const int w, const int h,
- const ImageRect &restrict imgRect)
- restrict2
-{
- ImageVertexes *vert = nullptr;
- Image *const image = imgRect.grid[4];
- if (image == nullptr)
- return;
- if (vertCol->currentGLImage != image->mGLImage)
- {
- vert = new ImageVertexes;
- vertCol->currentGLImage = image->mGLImage;
- vertCol->currentVert = vert;
- vert->image = image;
- vertCol->draws.push_back(vert);
- }
- else
- {
- vert = vertCol->currentVert;
- }
- calcImageRect(vert, x, y, w, h, imgRect);
-}
-
-void NormalOpenGLGraphics::updateScreen() restrict2
-{
- BLOCK_START("Graphics::updateScreen")
-// glFlush();
-// glFinish();
-#ifdef DEBUG_DRAW_CALLS
- mLastDrawCalls = mDrawCalls;
- mDrawCalls = 0;
-#endif // DEBUG_DRAW_CALLS
-#ifdef DEBUG_BIND_TEXTURE
- mLastBinds = mBinds;
- mBinds = 0;
-#endif // DEBUG_BIND_TEXTURE
-#ifdef USE_SDL2
- SDL_GL_SwapWindow(mWindow);
-#else // USE_SDL2
- SDL_GL_SwapBuffers();
-#endif // USE_SDL2
-#ifdef DEBUG_OPENGL
- if (isGLNotNull(mglFrameTerminator))
- mglFrameTerminator();
-#endif // DEBUG_OPENGL
-
-// may be need clear?
-// glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
- BLOCK_END("Graphics::updateScreen")
-}
-
-void NormalOpenGLGraphics::beginDraw() restrict2
-{
- glMatrixMode(GL_TEXTURE);
- glLoadIdentity();
-
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
-
- const int w = mRect.w;
- const int h = mRect.h;
-
-#ifdef ANDROID
- glOrthof(0.0, static_cast<float>(w),
- static_cast<float>(h),
- 0.0, -1.0, 1.0);
-#else // ANDROID
-
- glOrtho(0.0, static_cast<double>(w),
- static_cast<double>(h),
- 0.0, -1.0, 1.0);
-#endif // ANDROID
-
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
-
- setOpenGLFlags();
- glDisable(GL_LIGHTING);
- glDisable(GL_FOG);
- glDisable(GL_COLOR_MATERIAL);
-
- glEnableClientState(GL_VERTEX_ARRAY);
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
-
- glShadeModel(GL_FLAT);
- glDepthMask(GL_FALSE);
-
- glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
-#ifndef ANDROID
- glHint(GL_LINE_SMOOTH_HINT, GL_FASTEST);
- glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
- glHint(GL_POINT_SMOOTH_HINT, GL_FASTEST);
- glHint(GL_POLYGON_SMOOTH_HINT, GL_FASTEST);
-#endif // ANDROID
-
- pushClipArea(Rect(0, 0, w, h));
-}
-
-void NormalOpenGLGraphics::endDraw() restrict2
-{
- popClipArea();
-}
-
-void NormalOpenGLGraphics::pushClipArea(const Rect &restrict area) restrict2
-{
- int transX = 0;
- int transY = 0;
-
- if (!mClipStack.empty())
- {
- const ClipRect &clipArea = mClipStack.top();
- transX = -clipArea.xOffset;
- transY = -clipArea.yOffset;
- }
-
- Graphics::pushClipArea(area);
-
- const ClipRect &clipArea = mClipStack.top();
- transX += clipArea.xOffset;
- transY += clipArea.yOffset;
-
- if (transX != 0 || transY != 0)
- {
- glTranslatef(static_cast<GLfloat>(transX),
- static_cast<GLfloat>(transY), 0);
- }
- glScissor(clipArea.x * mScale,
- (mRect.h - clipArea.y - clipArea.height) * mScale,
- clipArea.width * mScale,
- clipArea.height * mScale);
-}
-
-void NormalOpenGLGraphics::popClipArea() restrict2
-{
- if (mClipStack.empty())
- return;
-
- const ClipRect &clipArea1 = mClipStack.top();
- int transX = -clipArea1.xOffset;
- int transY = -clipArea1.yOffset;
-
- Graphics::popClipArea();
-
- if (mClipStack.empty())
- return;
-
- const ClipRect &clipArea = mClipStack.top();
- transX += clipArea.xOffset;
- transY += clipArea.yOffset;
- if (transX != 0 || transY != 0)
- {
- glTranslatef(static_cast<GLfloat>(transX),
- static_cast<GLfloat>(transY), 0);
- }
- glScissor(clipArea.x * mScale,
- (mRect.h - clipArea.y - clipArea.height) * mScale,
- clipArea.width * mScale,
- clipArea.height * mScale);
-}
-
-void NormalOpenGLGraphics::drawPoint(int x, int y) restrict2
-{
- disableTexturingAndBlending();
- restoreColor();
-
-#ifdef ANDROID
- // TODO need fix
-#else // ANDROID
-
- glBegin(GL_POINTS);
- glVertex2i(x, y);
- glEnd();
-#endif // ANDROID
-}
-
-void NormalOpenGLGraphics::drawLine(int x1, int y1,
- int x2, int y2) restrict2
-{
- disableTexturingAndBlending();
- restoreColor();
-
- mFloatTexArray[0] = static_cast<float>(x1) + 0.5F;
- mFloatTexArray[1] = static_cast<float>(y1) + 0.5F;
- mFloatTexArray[2] = static_cast<float>(x2) + 0.5F;
- mFloatTexArray[3] = static_cast<float>(y2) + 0.5F;
-
- drawLineArrayf(4);
-}
-
-void NormalOpenGLGraphics::drawRectangle(const Rect &restrict rect) restrict2
-{
- drawRectangle(rect, false);
-}
-
-void NormalOpenGLGraphics::fillRectangle(const Rect &restrict rect) restrict2
-{
- drawRectangle(rect, true);
-}
-
-void NormalOpenGLGraphics::enableTexturingAndBlending() restrict2
-{
- if (!mTexture)
- {
- glEnable(OpenGLImageHelper::mTextureType);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- mTexture = true;
- }
-
- if (!mAlpha)
- {
- glEnable(GL_BLEND);
- mAlpha = true;
- }
-}
-
-void NormalOpenGLGraphics::disableTexturingAndBlending() restrict2
-{
- mTextureBinded = 0;
- if (mAlpha && !mColorAlpha)
- {
- glDisable(GL_BLEND);
- mAlpha = false;
- }
- else if (!mAlpha && mColorAlpha)
- {
- glEnable(GL_BLEND);
- mAlpha = true;
- }
-
- if (mTexture)
- {
- glDisable(OpenGLImageHelper::mTextureType);
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
- mTexture = false;
- }
-}
-
-void NormalOpenGLGraphics::drawRectangle(const Rect &restrict rect,
- const bool filled) restrict2
-{
- BLOCK_START("Graphics::drawRectangle")
- const float offset = filled ? 0 : 0.5F;
- const float x = static_cast<float>(rect.x);
- const float y = static_cast<float>(rect.y);
- const float width = static_cast<float>(rect.width);
- const float height = static_cast<float>(rect.height);
-
- disableTexturingAndBlending();
- restoreColor();
-
- GLfloat vert[] =
- {
- x + offset, y + offset,
- x + width - offset, y + offset,
- x + width - offset, y + height - offset,
- x + offset, y + height - offset
- };
-
- glVertexPointer(2, GL_FLOAT, 0, &vert);
- vertPtr = nullptr;
-#ifdef DEBUG_DRAW_CALLS
- mDrawCalls ++;
-#endif // DEBUG_DRAW_CALLS
-
- glDrawArrays(filled ? GL_QUADS : GL_LINE_LOOP, 0, 4);
-#ifdef OPENGLERRORS
- graphicsManager.logError();
-#endif // OPENGLERRORS
- BLOCK_END("Graphics::drawRectangle")
-}
-
-void NormalOpenGLGraphics::drawNet(const int x1, const int y1,
- const int x2, const int y2,
- const int width, const int height) restrict2
-{
- unsigned int vp = 0;
- const unsigned int vLimit = mMaxVertices * 4;
-
- disableTexturingAndBlending();
- restoreColor();
-
- const float xf1 = static_cast<float>(x1);
- const float xf2 = static_cast<float>(x2);
- const float yf1 = static_cast<float>(y1);
- const float yf2 = static_cast<float>(y2);
-
- for (int y = y1; y < y2; y += height)
- {
- mFloatTexArray[vp + 0] = xf1;
- mFloatTexArray[vp + 1] = static_cast<float>(y);
-
- mFloatTexArray[vp + 2] = xf2;
- mFloatTexArray[vp + 3] = static_cast<float>(y);
-
- vp += 4;
- if (vp >= vLimit)
- {
- drawLineArrayf(vp);
- vp = 0;
- }
- }
-
- for (int x = x1; x < x2; x += width)
- {
- mFloatTexArray[vp + 0] = static_cast<float>(x);
- mFloatTexArray[vp + 1] = yf1;
-
- mFloatTexArray[vp + 2] = static_cast<float>(x);
- mFloatTexArray[vp + 3] = yf2;
-
- vp += 4;
- if (vp >= vLimit)
- {
- drawLineArrayf(vp);
- vp = 0;
- }
- }
-
- if (vp > 0)
- drawLineArrayf(vp);
-}
-
-void NormalOpenGLGraphics::bindTexture(const GLenum target,
- const GLuint texture)
-{
- if (mTextureBinded != texture)
- {
- mTextureBinded = texture;
- glBindTexture(target, texture);
-#ifdef DEBUG_BIND_TEXTURE
- mBinds ++;
-#endif // DEBUG_BIND_TEXTURE
- }
-}
-
-inline void NormalOpenGLGraphics::drawQuadArrayfi(const int size) restrict2
-{
- bindPointerIntFloat(&mIntVertArray[0], &mFloatTexArray[0]);
-#ifdef DEBUG_DRAW_CALLS
- mDrawCalls ++;
-#endif // DEBUG_DRAW_CALLS
-
- glDrawArrays(GL_QUADS, 0, size / 2);
-#ifdef OPENGLERRORS
- graphicsManager.logError();
-#endif // OPENGLERRORS
-}
-
-inline void NormalOpenGLGraphics::drawQuadArrayfiCached(const int size)
- restrict2
-{
- bindPointerIntFloat(&mIntVertArrayCached[0], &mFloatTexArrayCached[0]);
-#ifdef DEBUG_DRAW_CALLS
- mDrawCalls ++;
-#endif // DEBUG_DRAW_CALLS
-
- glDrawArrays(GL_QUADS, 0, size / 2);
-#ifdef OPENGLERRORS
- graphicsManager.logError();
-#endif // OPENGLERRORS
-}
-
-inline void NormalOpenGLGraphics::drawQuadArrayfi(const GLint *restrict const
- intVertArray,
- const GLfloat *restrict const
- floatTexArray,
- const int size) restrict2
-{
- vertPtr = intVertArray;
- glVertexPointer(2, GL_INT, 0, intVertArray);
- glTexCoordPointer(2, GL_FLOAT, 0, floatTexArray);
-#ifdef DEBUG_DRAW_CALLS
- mDrawCalls ++;
-#endif // DEBUG_DRAW_CALLS
-
- glDrawArrays(GL_QUADS, 0, size / 2);
-#ifdef OPENGLERRORS
- graphicsManager.logError();
-#endif // OPENGLERRORS
-}
-
-inline void NormalOpenGLGraphics::drawQuadArrayii(const int size) restrict2
-{
- bindPointerInt(&mIntVertArray[0], &mIntTexArray[0]);
-#ifdef DEBUG_DRAW_CALLS
- mDrawCalls ++;
-#endif // DEBUG_DRAW_CALLS
-
- glDrawArrays(GL_QUADS, 0, size / 2);
-#ifdef OPENGLERRORS
- graphicsManager.logError();
-#endif // OPENGLERRORS
-}
-
-inline void NormalOpenGLGraphics::drawQuadArrayiiCached(const int size)
- restrict2
-{
- bindPointerInt(&mIntVertArrayCached[0], &mIntTexArrayCached[0]);
-#ifdef DEBUG_DRAW_CALLS
- mDrawCalls ++;
-#endif // DEBUG_DRAW_CALLS
-
- glDrawArrays(GL_QUADS, 0, size / 2);
-#ifdef OPENGLERRORS
- graphicsManager.logError();
-#endif // OPENGLERRORS
-}
-
-inline void NormalOpenGLGraphics::drawQuadArrayii(const GLint *restrict const
- intVertArray,
- const GLint *restrict const
- intTexArray,
- const int size) restrict2
-{
- vertPtr = intVertArray;
- glVertexPointer(2, GL_INT, 0, intVertArray);
- glTexCoordPointer(2, GL_INT, 0, intTexArray);
-#ifdef DEBUG_DRAW_CALLS
- mDrawCalls ++;
-#endif // DEBUG_DRAW_CALLS
-
- glDrawArrays(GL_QUADS, 0, size / 2);
-#ifdef OPENGLERRORS
- graphicsManager.logError();
-#endif // OPENGLERRORS
-}
-
-inline void NormalOpenGLGraphics::drawLineArrayi(const int size) restrict2
-{
- glVertexPointer(2, GL_INT, 0, mIntVertArray);
- vertPtr = nullptr;
-#ifdef DEBUG_DRAW_CALLS
- mDrawCalls ++;
-#endif // DEBUG_DRAW_CALLS
-
- glDrawArrays(GL_LINES, 0, size / 2);
-#ifdef OPENGLERRORS
- graphicsManager.logError();
-#endif // OPENGLERRORS
-}
-
-inline void NormalOpenGLGraphics::drawLineArrayf(const int size) restrict2
-{
- glVertexPointer(2, GL_FLOAT, 0, mFloatTexArray);
- vertPtr = nullptr;
-#ifdef DEBUG_DRAW_CALLS
- mDrawCalls ++;
-#endif // DEBUG_DRAW_CALLS
-
- glDrawArrays(GL_LINES, 0, size / 2);
-#ifdef OPENGLERRORS
- graphicsManager.logError();
-#endif // OPENGLERRORS
-}
-
-void NormalOpenGLGraphics::dumpSettings()
-{
- GLint test[1000];
- logger->log("\n\n");
- logger->log("start opengl dump");
- for (int f = 0; f < 65535; f ++)
- {
- test[0] = 0;
- test[1] = 0;
- test[2] = 0;
- test[3] = 0;
- glGetIntegerv(f, &test[0]);
- if (test[0] != 0 || test[1] != 0 || test[2] != 0 || test[3] != 0)
- {
- logger->log("\n%d = %d, %d, %d, %d", f,
- test[0], test[1], test[2], test[3]);
- }
- }
-}
-
-void NormalOpenGLGraphics::setColorAlpha(const float alpha) restrict2
-{
- if (!mIsByteColor && mFloatColor == alpha)
- return;
-
- glColor4f(1.0F, 1.0F, 1.0F, alpha);
- mIsByteColor = false;
- mFloatColor = alpha;
-}
-
-void NormalOpenGLGraphics::restoreColor() restrict2
-{
- if (mIsByteColor && mByteColor == mColor)
- return;
-
- glColor4ub(static_cast<GLubyte>(mColor.r),
- static_cast<GLubyte>(mColor.g),
- static_cast<GLubyte>(mColor.b),
- static_cast<GLubyte>(mColor.a));
- mIsByteColor = true;
- mByteColor = mColor;
-}
-
-void NormalOpenGLGraphics::drawImageRect(const int x, const int y,
- const int w, const int h,
- const ImageRect &restrict imgRect)
- restrict2
-{
- #include "render/graphics_drawImageRect.hpp"
-}
-
-void NormalOpenGLGraphics::calcImageRect(ImageVertexes *restrict const vert,
- const int x, const int y,
- const int w, const int h,
- const ImageRect &restrict imgRect)
- restrict2
-{
- #include "render/graphics_calcImageRect.hpp"
-}
-
-void NormalOpenGLGraphics::clearScreen() const restrict2
-{
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
-}
-
-#ifdef DEBUG_BIND_TEXTURE
-void NormalOpenGLGraphics::debugBindTexture(const Image *restrict const image)
- restrict2
-{
- const std::string texture = image->mIdPath;
- if (mOldTexture != texture)
- {
- if ((!mOldTexture.empty() || !texture.empty())
- && mOldTextureId != image->mGLImage)
- {
- logger->log("bind: %s (%d) to %s (%d)", mOldTexture.c_str(),
- mOldTextureId, texture.c_str(), image->mGLImage);
- }
- mOldTextureId = image->mGLImage;
- mOldTexture = texture;
- }
-}
-#else // DEBUG_BIND_TEXTURE
-
-void NormalOpenGLGraphics::debugBindTexture(const Image *restrict const
- image A_UNUSED) restrict2
-{
-}
-#endif // DEBUG_BIND_TEXTURE
-
-#endif // defined(USE_OPENGL) && !defined(ANDROID) &&
- // !defined(__native_client__)
diff --git a/src/render/normalopenglgraphics.h b/src/render/normalopenglgraphics.h
deleted file mode 100644
index ee7ecd9ce..000000000
--- a/src/render/normalopenglgraphics.h
+++ /dev/null
@@ -1,133 +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 RENDER_NORMALOPENGLGRAPHICS_H
-#define RENDER_NORMALOPENGLGRAPHICS_H
-
-#if defined USE_OPENGL && !defined ANDROID && !defined(__native_client__)
-
-#include "localconsts.h"
-
-#include "render/graphics.h"
-
-#include "resources/fboinfo.h"
-
-#ifdef ANDROID
-#include <GLES/gl.h>
-#include <GLES/glext.h>
-#include <GLES2/gl2.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)
-#if defined(__APPLE__)
-#include <OpenGL/glext.h>
-#elif !defined(__native_client__)
-#include <GL/glext.h>
-#endif // defined(__APPLE__)
-#endif // ANDROID
-
-class OpenGLGraphicsVertexes;
-
-class NormalOpenGLGraphics final : public Graphics
-{
- public:
- NormalOpenGLGraphics();
-
- A_DELETE_COPY(NormalOpenGLGraphics)
-
- ~NormalOpenGLGraphics();
-
- inline void drawQuadArrayfi(const int size) restrict2 A_INLINE;
-
- inline void drawQuadArrayfiCached(const int size) restrict2 A_INLINE;
-
- inline void drawQuadArrayfi(const GLint *restrict const intVertArray,
- const GLfloat *restrict const
- floatTexArray,
- const int size) restrict2 A_INLINE;
-
- inline void drawQuadArrayii(const int size) restrict2 A_INLINE;
-
- inline void drawQuadArrayiiCached(const int size) restrict2 A_INLINE;
-
- inline void drawQuadArrayii(const GLint *restrict const intVertArray,
- const GLint *restrict const intTexArray,
- const int size) restrict2 A_INLINE;
-
- inline void drawLineArrayi(const int size) restrict2 A_INLINE;
-
- inline void drawLineArrayf(const int size) restrict2 A_INLINE;
-
- void testDraw() restrict2 override final;
-
- #include "render/graphicsdef.hpp"
- RENDER_GRAPHICSDEF_HPP
-
- #include "render/openglgraphicsdef.hpp"
- RENDER_OPENGLGRAPHICSDEF_HPP
-
- #include "render/openglgraphicsdef1.hpp"
- RENDER_OPENGLGRAPHICSDEF1_HPP
-
- #include "render/openglgraphicsdefadvanced.hpp"
- RENDER_OPENGLGRAPHICSDEFADVANCED_HPP
-
-#ifdef DEBUG_BIND_TEXTURE
- unsigned int getBinds() const restrict2 noexcept2
- { return mLastBinds; }
-#endif // DEBUG_BIND_TEXTURE
-
- private:
- GLfloat *mFloatTexArray A_NONNULLPOINTER;
- GLint *mIntTexArray A_NONNULLPOINTER;
- GLint *mIntVertArray A_NONNULLPOINTER;
- GLfloat *mFloatTexArrayCached A_NONNULLPOINTER;
- GLint *mIntTexArrayCached A_NONNULLPOINTER;
- GLint *mIntVertArrayCached A_NONNULLPOINTER;
- float mAlphaCached;
- int mVpCached;
- bool mTexture;
-
- bool mIsByteColor;
- Color mByteColor;
- GLuint mImageCached;
- float mFloatColor;
- int mMaxVertices;
- bool mColorAlpha;
-#ifdef DEBUG_BIND_TEXTURE
- std::string mOldTexture;
- unsigned int mOldTextureId;
- static unsigned int mBinds;
- static unsigned int mLastBinds;
-#endif // DEBUG_BIND_TEXTURE
-
- FBOInfo mFbo;
-};
-#endif // defined USE_OPENGL && !defined ANDROID &&
- // !defined(__native_client__)
-
-#endif // RENDER_NORMALOPENGLGRAPHICS_H
diff --git a/src/render/nullopenglgraphics.cpp b/src/render/nullopenglgraphics.cpp
deleted file mode 100644
index 265ac92f1..000000000
--- a/src/render/nullopenglgraphics.cpp
+++ /dev/null
@@ -1,1251 +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
-
-#include "render/nullopenglgraphics.h"
-
-#ifdef DEBUG_BIND_TEXTURE
-#include "logger.h"
-#endif // DEBUG_BIND_TEXTURE
-
-#include "render/vertexes/imagecollection.h"
-
-#include "resources/imagerect.h"
-#include "resources/openglimagehelper.h"
-
-#include "resources/image/image.h"
-
-#include "debug.h"
-
-GLuint NullOpenGLGraphics::mTextureBinded = 0;
-#ifdef DEBUG_DRAW_CALLS
-unsigned int NullOpenGLGraphics::mDrawCalls = 0;
-unsigned int NullOpenGLGraphics::mLastDrawCalls = 0;
-#endif // DEBUG_DRAW_CALLS
-
-NullOpenGLGraphics::NullOpenGLGraphics() :
- mFloatTexArray(nullptr),
- mIntTexArray(nullptr),
- mIntVertArray(nullptr),
- mTexture(false),
- mIsByteColor(false),
- mByteColor(),
- mFloatColor(1.0F),
- mMaxVertices(500),
- mColorAlpha(false),
-#ifdef DEBUG_BIND_TEXTURE
- mOldTexture(),
- mOldTextureId(0),
-#endif // DEBUG_BIND_TEXTURE
- mFbo()
-{
- mOpenGL = RENDER_NULL;
- mName = "null OpenGL";
-}
-
-NullOpenGLGraphics::~NullOpenGLGraphics()
-{
- delete [] mFloatTexArray;
- delete [] mIntTexArray;
- delete [] mIntVertArray;
-}
-
-void NullOpenGLGraphics::initArrays(const int vertCount) restrict2
-{
- mMaxVertices = vertCount;
- if (mMaxVertices < 500)
- mMaxVertices = 500;
- else if (mMaxVertices > 1024)
- mMaxVertices = 1024;
-
- // need alocate small size, after if limit reached reallocate to double size
- vertexBufSize = mMaxVertices;
- const size_t sz = mMaxVertices * 4 + 30;
- if (mFloatTexArray == nullptr)
- mFloatTexArray = new GLfloat[sz];
- if (mIntTexArray == nullptr)
- mIntTexArray = new GLint[sz];
- if (mIntVertArray == nullptr)
- mIntVertArray = new GLint[sz];
-}
-
-void NullOpenGLGraphics::deleteArrays() restrict2
-{
-}
-
-bool NullOpenGLGraphics::setVideoMode(const int w, const int h,
- const int scale,
- const int bpp,
- const bool fs,
- const bool hwaccel,
- const bool resize,
- const bool noFrame,
- const bool allowHighDPI) restrict2
-{
- setMainFlags(w, h,
- scale,
- bpp,
- fs,
- hwaccel,
- resize,
- noFrame,
- allowHighDPI);
-
- return setOpenGLMode();
-}
-
-static inline void drawQuad(const Image *restrict const image A_UNUSED,
- const int srcX A_UNUSED, const int srcY A_UNUSED,
- const int dstX A_UNUSED, const int dstY A_UNUSED,
- const int width A_UNUSED,
- const int height A_UNUSED) A_NONNULL(1);
-
-static inline void drawQuad(const Image *restrict const image A_UNUSED,
- const int srcX A_UNUSED, const int srcY A_UNUSED,
- const int dstX A_UNUSED, const int dstY A_UNUSED,
- const int width A_UNUSED,
- const int height A_UNUSED)
-{
- if (OpenGLImageHelper::mTextureType == GL_TEXTURE_2D)
- {
-#ifdef DEBUG_DRAW_CALLS
- NullOpenGLGraphics::mDrawCalls ++;
-#endif // DEBUG_DRAW_CALLS
- }
- else
- {
-#ifdef DEBUG_DRAW_CALLS
- NullOpenGLGraphics::mDrawCalls ++;
-#endif // DEBUG_DRAW_CALLS
- }
-}
-
-static inline void drawRescaledQuad(const Image *restrict const image A_UNUSED,
- const int srcX A_UNUSED,
- const int srcY A_UNUSED,
- const int dstX A_UNUSED,
- const int dstY A_UNUSED,
- const int width A_UNUSED,
- const int height A_UNUSED,
- const int desiredWidth A_UNUSED,
- const int desiredHeight A_UNUSED)
-{
- if (OpenGLImageHelper::mTextureType == GL_TEXTURE_2D)
- {
-#ifdef DEBUG_DRAW_CALLS
- NullOpenGLGraphics::mDrawCalls ++;
-#endif // DEBUG_DRAW_CALLS
- }
- else
- {
-#ifdef DEBUG_DRAW_CALLS
- NullOpenGLGraphics::mDrawCalls ++;
-#endif // DEBUG_DRAW_CALLS
- }
-}
-
-void NullOpenGLGraphics::drawImage(const Image *restrict const image,
- int dstX, int dstY) restrict2
-{
- drawImageInline(image, dstX, dstY);
-}
-
-void NullOpenGLGraphics::copyImage(const Image *restrict const image,
- int dstX, int dstY) restrict2
-{
- drawImageInline(image, dstX, dstY);
-}
-
-void NullOpenGLGraphics::drawImageInline(const Image *restrict const image,
- int dstX, int dstY) restrict2
-{
- FUNC_BLOCK("Graphics::drawImage", 1)
- if (image == nullptr)
- return;
-
- setColorAlpha(image->mAlpha);
-#ifdef DEBUG_BIND_TEXTURE
- debugBindTexture(image);
-#endif // DEBUG_BIND_TEXTURE
-
- bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
- enableTexturingAndBlending();
-
- const SDL_Rect &imageRect = image->mBounds;
- drawQuad(image, imageRect.x, imageRect.y, dstX, dstY,
- imageRect.w, imageRect.h);
-}
-
-void NullOpenGLGraphics::drawImageCached(const Image *restrict const image
- A_UNUSED,
- int x A_UNUSED,
- int y A_UNUSED) restrict2
-{
-}
-
-void NullOpenGLGraphics::drawPatternCached(const Image *restrict const image
- A_UNUSED,
- const int x A_UNUSED,
- const int y A_UNUSED,
- const int w A_UNUSED,
- const int h A_UNUSED) restrict2
-{
-}
-
-void NullOpenGLGraphics::completeCache() restrict2
-{
-}
-
-void NullOpenGLGraphics::drawRescaledImage(const Image *restrict const image,
- int dstX, int dstY,
- const int desiredWidth,
- const int desiredHeight) restrict2
-{
- FUNC_BLOCK("Graphics::drawRescaledImage", 1)
- if (image == nullptr)
- return;
-
- const SDL_Rect &imageRect = image->mBounds;
-
- // Just draw the image normally when no resizing is necessary,
- if (imageRect.w == desiredWidth && imageRect.h == desiredHeight)
- {
- drawImageInline(image, dstX, dstY);
- return;
- }
-
- setColorAlpha(image->mAlpha);
-#ifdef DEBUG_BIND_TEXTURE
- debugBindTexture(image);
-#endif // DEBUG_BIND_TEXTURE
-
- bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
- enableTexturingAndBlending();
-
- // Draw a textured quad.
- drawRescaledQuad(image, imageRect.x, imageRect.y, dstX, dstY,
- imageRect.w, imageRect.h, desiredWidth, desiredHeight);
-}
-
-void NullOpenGLGraphics::drawPattern(const Image *restrict const image,
- const int x, const int y,
- const int w, const int h) restrict2
-{
- drawPatternInline(image, x, y, w, h);
-}
-
-void NullOpenGLGraphics::drawPatternInline(const Image *restrict const image,
- const int x, const int y,
- const int w, const int h) restrict2
-{
- FUNC_BLOCK("Graphics::drawPattern", 1)
- if (image == nullptr)
- return;
-
- const SDL_Rect &imageRect = image->mBounds;
- const int srcX = imageRect.x;
- const int srcY = imageRect.y;
- const int iw = imageRect.w;
- const int ih = imageRect.h;
-
- if (iw == 0 || ih == 0)
- return;
-
- const float tw = static_cast<float>(image->mTexWidth);
- const float th = static_cast<float>(image->mTexHeight);
-
- setColorAlpha(image->mAlpha);
-
-#ifdef DEBUG_BIND_TEXTURE
- debugBindTexture(image);
-#endif // DEBUG_BIND_TEXTURE
-
- bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
-
- enableTexturingAndBlending();
-
- unsigned int vp = 0;
- const unsigned int vLimit = mMaxVertices * 4;
- // Draw a set of textured rectangles
- if (OpenGLImageHelper::mTextureType == GL_TEXTURE_2D)
- {
- const float texX1 = static_cast<float>(srcX) / tw;
- const float texY1 = static_cast<float>(srcY) / th;
-
- for (int py = 0; py < h; py += ih)
- {
- const int height = (py + ih >= h) ? h - py : ih;
- const int dstY = y + py;
- const float texY2 = static_cast<float>(srcY + height) / th;
- for (int px = 0; px < w; px += iw)
- {
- const int width = (px + iw >= w) ? w - px : iw;
- const int dstX = x + px;
-
- const float texX2 = static_cast<float>(srcX + width) / tw;
-
- mFloatTexArray[vp + 0] = texX1;
- mFloatTexArray[vp + 1] = texY1;
-
- mFloatTexArray[vp + 2] = texX2;
- mFloatTexArray[vp + 3] = texY1;
-
- mFloatTexArray[vp + 4] = texX2;
- mFloatTexArray[vp + 5] = texY2;
-
- mFloatTexArray[vp + 6] = texX1;
- mFloatTexArray[vp + 7] = texY2;
-
- mIntVertArray[vp + 0] = dstX;
- mIntVertArray[vp + 1] = dstY;
-
- mIntVertArray[vp + 2] = dstX + width;
- mIntVertArray[vp + 3] = dstY;
-
- mIntVertArray[vp + 4] = dstX + width;
- mIntVertArray[vp + 5] = dstY + height;
-
- mIntVertArray[vp + 6] = dstX;
- mIntVertArray[vp + 7] = dstY + height;
-
- vp += 8;
- if (vp >= vLimit)
- {
- drawQuadArrayfi(vp);
- vp = 0;
- }
- }
- }
- if (vp > 0)
- drawQuadArrayfi(vp);
- }
- else
- {
- for (int py = 0; py < h; py += ih)
- {
- const int height = (py + ih >= h) ? h - py : ih;
- const int dstY = y + py;
- for (int px = 0; px < w; px += iw)
- {
- const int width = (px + iw >= w) ? w - px : iw;
- const int dstX = x + px;
-
- mIntTexArray[vp + 0] = srcX;
- mIntTexArray[vp + 1] = srcY;
-
- mIntTexArray[vp + 2] = srcX + width;
- mIntTexArray[vp + 3] = srcY;
-
- mIntTexArray[vp + 4] = srcX + width;
- mIntTexArray[vp + 5] = srcY + height;
-
- mIntTexArray[vp + 6] = srcX;
- mIntTexArray[vp + 7] = srcY + height;
-
- mIntVertArray[vp + 0] = dstX;
- mIntVertArray[vp + 1] = dstY;
-
- mIntVertArray[vp + 2] = dstX + width;
- mIntVertArray[vp + 3] = dstY;
-
- mIntVertArray[vp + 4] = dstX + width;
- mIntVertArray[vp + 5] = dstY + height;
-
- mIntVertArray[vp + 6] = dstX;
- mIntVertArray[vp + 7] = dstY + height;
-
- vp += 8;
- if (vp >= vLimit)
- {
- drawQuadArrayii(vp);
- vp = 0;
- }
- }
- }
- if (vp > 0)
- drawQuadArrayii(vp);
- }
-}
-
-void NullOpenGLGraphics::drawRescaledPattern(const Image *restrict const image,
- const int x, const int y,
- const int w, const int h,
- const int scaledWidth,
- const int scaledHeight) restrict2
-{
- if (image == nullptr)
- return;
-
- if (scaledWidth == 0 || scaledHeight == 0)
- return;
-
- const SDL_Rect &imageRect = image->mBounds;
- const int iw = imageRect.w;
- const int ih = imageRect.h;
- if (iw == 0 || ih == 0)
- return;
-
- const int srcX = imageRect.x;
- const int srcY = imageRect.y;
-
- setColorAlpha(image->mAlpha);
-
-#ifdef DEBUG_BIND_TEXTURE
- debugBindTexture(image);
-#endif // DEBUG_BIND_TEXTURE
-
- bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
-
- enableTexturingAndBlending();
-
- unsigned int vp = 0;
- const unsigned int vLimit = mMaxVertices * 4;
-
- // Draw a set of textured rectangles
- if (OpenGLImageHelper::mTextureType == GL_TEXTURE_2D)
- {
- const float tw = static_cast<float>(image->mTexWidth);
- const float th = static_cast<float>(image->mTexHeight);
-
- const float texX1 = static_cast<float>(srcX) / tw;
- const float texY1 = static_cast<float>(srcY) / th;
-
- const float tFractionW = iw / tw;
- const float tFractionH = ih / th;
-
- for (int py = 0; py < h; py += scaledHeight)
- {
- const int height = (py + scaledHeight >= h)
- ? h - py : scaledHeight;
- const int dstY = y + py;
- const float visibleFractionH = static_cast<float>(height)
- / scaledHeight;
- const float texY2 = texY1 + tFractionH * visibleFractionH;
- for (int px = 0; px < w; px += scaledWidth)
- {
- const int width = (px + scaledWidth >= w)
- ? w - px : scaledWidth;
- const int dstX = x + px;
- const float visibleFractionW = static_cast<float>(width)
- / scaledWidth;
- const float texX2 = texX1 + tFractionW * visibleFractionW;
-
- mFloatTexArray[vp + 0] = texX1;
- mFloatTexArray[vp + 1] = texY1;
-
- mFloatTexArray[vp + 2] = texX2;
- mFloatTexArray[vp + 3] = texY1;
-
- mFloatTexArray[vp + 4] = texX2;
- mFloatTexArray[vp + 5] = texY2;
-
- mFloatTexArray[vp + 6] = texX1;
- mFloatTexArray[vp + 7] = texY2;
-
- mIntVertArray[vp + 0] = dstX;
- mIntVertArray[vp + 1] = dstY;
-
- mIntVertArray[vp + 2] = dstX + width;
- mIntVertArray[vp + 3] = dstY;
-
- mIntVertArray[vp + 4] = dstX + width;
- mIntVertArray[vp + 5] = dstY + height;
-
- mIntVertArray[vp + 6] = dstX;
- mIntVertArray[vp + 7] = dstY + height;
-
- vp += 8;
- if (vp >= vLimit)
- {
- drawQuadArrayfi(vp);
- vp = 0;
- }
- }
- }
- if (vp > 0)
- drawQuadArrayfi(vp);
- }
- else
- {
- const float scaleFactorW = static_cast<float>(scaledWidth) / iw;
- const float scaleFactorH = static_cast<float>(scaledHeight) / ih;
-
- for (int py = 0; py < h; py += scaledHeight)
- {
- const int height = (py + scaledHeight >= h)
- ? h - py : scaledHeight;
- const int dstY = y + py;
- const int scaledY = srcY + height / scaleFactorH;
- for (int px = 0; px < w; px += scaledWidth)
- {
- const int width = (px + scaledWidth >= w)
- ? w - px : scaledWidth;
- const int dstX = x + px;
- const int scaledX = srcX + width / scaleFactorW;
-
- mIntTexArray[vp + 0] = srcX;
- mIntTexArray[vp + 1] = srcY;
-
- mIntTexArray[vp + 2] = scaledX;
- mIntTexArray[vp + 3] = srcY;
-
- mIntTexArray[vp + 4] = scaledX;
- mIntTexArray[vp + 5] = scaledY;
-
- mIntTexArray[vp + 6] = srcX;
- mIntTexArray[vp + 7] = scaledY;
-
- mIntVertArray[vp + 0] = dstX;
- mIntVertArray[vp + 1] = dstY;
-
- mIntVertArray[vp + 2] = dstX + width;
- mIntVertArray[vp + 3] = dstY;
-
- mIntVertArray[vp + 4] = dstX + width;
- mIntVertArray[vp + 5] = dstY + height;
-
- mIntVertArray[vp + 6] = dstX;
- mIntVertArray[vp + 7] = dstY + height;
-
- vp += 8;
- if (vp >= vLimit)
- {
- drawQuadArrayii(vp);
- vp = 0;
- }
- }
- }
- if (vp > 0)
- drawQuadArrayii(vp);
- }
-}
-
-inline void NullOpenGLGraphics::drawVertexes(const
- OpenGLGraphicsVertexes
- &restrict ogl) restrict2
-{
- const STD_VECTOR<GLint*> &intVertPool = ogl.mIntVertPool;
- STD_VECTOR<GLint*>::const_iterator iv;
- const STD_VECTOR<GLint*>::const_iterator iv_end = intVertPool.end();
- const STD_VECTOR<int> &vp = ogl.mVp;
- STD_VECTOR<int>::const_iterator ivp;
- const STD_VECTOR<int>::const_iterator ivp_end = vp.end();
-
- // Draw a set of textured rectangles
- if (OpenGLImageHelper::mTextureType == GL_TEXTURE_2D)
- {
- const STD_VECTOR<GLfloat*> &floatTexPool = ogl.mFloatTexPool;
- STD_VECTOR<GLfloat*>::const_iterator ft;
- const STD_VECTOR<GLfloat*>::const_iterator
- ft_end = floatTexPool.end();
-
- for (iv = intVertPool.begin(), ft = floatTexPool.begin(),
- ivp = vp.begin();
- iv != iv_end && ft != ft_end && ivp != ivp_end;
- ++ iv, ++ ft, ++ ivp)
- {
- drawQuadArrayfi(*iv, *ft, *ivp);
- }
- }
- else
- {
- const STD_VECTOR<GLint*> &intTexPool = ogl.mIntTexPool;
- STD_VECTOR<GLint*>::const_iterator it;
- const STD_VECTOR<GLint*>::const_iterator it_end = intTexPool.end();
-
- for (iv = intVertPool.begin(), it = intTexPool.begin(),
- ivp = vp.begin();
- iv != iv_end && it != it_end && ivp != ivp_end;
- ++ iv, ++ it, ++ ivp)
- {
- drawQuadArrayii(*iv, *it, *ivp);
- }
- }
-}
-
-void NullOpenGLGraphics::calcPattern(ImageVertexes *restrict const vert,
- const Image *restrict const image,
- const int x, const int y,
- const int w, const int h) const restrict2
-{
- calcPatternInline(vert, image, x, y, w, h);
-}
-
-void NullOpenGLGraphics::calcPatternInline(ImageVertexes *restrict const vert,
- const Image *restrict const image,
- const int x,
- const int y,
- const int w,
- const int h) const restrict2
-{
- if (image == nullptr || vert == nullptr)
- return;
-
- const SDL_Rect &imageRect = image->mBounds;
- const int iw = imageRect.w;
- const int ih = imageRect.h;
-
- if (iw == 0 || ih == 0)
- return;
-
- const int srcX = imageRect.x;
- const int srcY = imageRect.y;
- const float tw = static_cast<float>(image->mTexWidth);
- const float th = static_cast<float>(image->mTexHeight);
-
- const unsigned int vLimit = mMaxVertices * 4;
-
- OpenGLGraphicsVertexes &ogl = vert->ogl;
- unsigned int vp = ogl.continueVp();
-
- // Draw a set of textured rectangles
- if (OpenGLImageHelper::mTextureType == GL_TEXTURE_2D)
- {
- const float texX1 = static_cast<float>(srcX) / tw;
- const float texY1 = static_cast<float>(srcY) / th;
-
- GLfloat *floatTexArray = ogl.continueFloatTexArray();
- GLint *intVertArray = ogl.continueIntVertArray();
-
- for (int py = 0; py < h; py += ih)
- {
- const int height = (py + ih >= h) ? h - py : ih;
- const int dstY = y + py;
- const float texY2 = static_cast<float>(srcY + height) / th;
- for (int px = 0; px < w; px += iw)
- {
- const int width = (px + iw >= w) ? w - px : iw;
- const int dstX = x + px;
- const float texX2 = static_cast<float>(srcX + width) / tw;
-
- floatTexArray[vp + 0] = texX1;
- floatTexArray[vp + 1] = texY1;
-
- floatTexArray[vp + 2] = texX2;
- floatTexArray[vp + 3] = texY1;
-
- floatTexArray[vp + 4] = texX2;
- floatTexArray[vp + 5] = texY2;
-
- floatTexArray[vp + 6] = texX1;
- floatTexArray[vp + 7] = texY2;
-
- intVertArray[vp + 0] = dstX;
- intVertArray[vp + 1] = dstY;
-
- intVertArray[vp + 2] = dstX + width;
- intVertArray[vp + 3] = dstY;
-
- intVertArray[vp + 4] = dstX + width;
- intVertArray[vp + 5] = dstY + height;
-
- intVertArray[vp + 6] = dstX;
- intVertArray[vp + 7] = dstY + height;
-
- vp += 8;
- if (vp >= vLimit)
- {
- floatTexArray = ogl.switchFloatTexArray();
- intVertArray = ogl.switchIntVertArray();
- ogl.switchVp(vp);
- vp = 0;
- }
- }
- }
- }
- else
- {
- GLint *intTexArray = ogl.continueIntTexArray();
- GLint *intVertArray = ogl.continueIntVertArray();
-
- for (int py = 0; py < h; py += ih)
- {
- const int height = (py + ih >= h) ? h - py : ih;
- const int dstY = y + py;
- for (int px = 0; px < w; px += iw)
- {
- const int width = (px + iw >= w) ? w - px : iw;
- const int dstX = x + px;
-
- intTexArray[vp + 0] = srcX;
- intTexArray[vp + 1] = srcY;
-
- intTexArray[vp + 2] = srcX + width;
- intTexArray[vp + 3] = srcY;
-
- intTexArray[vp + 4] = srcX + width;
- intTexArray[vp + 5] = srcY + height;
-
- intTexArray[vp + 6] = srcX;
- intTexArray[vp + 7] = srcY + height;
-
- intVertArray[vp + 0] = dstX;
- intVertArray[vp + 1] = dstY;
-
- intVertArray[vp + 2] = dstX + width;
- intVertArray[vp + 3] = dstY;
-
- intVertArray[vp + 4] = dstX + width;
- intVertArray[vp + 5] = dstY + height;
-
- intVertArray[vp + 6] = dstX;
- intVertArray[vp + 7] = dstY + height;
-
- vp += 8;
- if (vp >= vLimit)
- {
- intTexArray = ogl.switchIntTexArray();
- intVertArray = ogl.switchIntVertArray();
- ogl.switchVp(vp);
- vp = 0;
- }
- }
- }
- }
- ogl.switchVp(vp);
-}
-
-void NullOpenGLGraphics::calcTileCollection(ImageCollection *
- restrict const vertCol,
- const Image *restrict const image,
- int x, int y) restrict2
-{
- if (vertCol == nullptr || image == nullptr)
- return;
- if (vertCol->currentGLImage != image->mGLImage)
- {
- ImageVertexes *const vert = new ImageVertexes;
- vertCol->currentGLImage = image->mGLImage;
- vertCol->currentVert = vert;
- vert->image = image;
- vertCol->draws.push_back(vert);
- calcTileVertexesInline(vert, image, x, y);
- }
- else
- {
- calcTileVertexesInline(vertCol->currentVert, image, x, y);
- }
-}
-
-void NullOpenGLGraphics::drawTileCollection(const ImageCollection
- *restrict const vertCol) restrict2
-{
- const ImageVertexesVector &draws = vertCol->draws;
- const ImageCollectionCIter it_end = draws.end();
- for (ImageCollectionCIter it = draws.begin(); it != it_end; ++ it)
- {
- const ImageVertexes *const vert = *it;
- const Image *const image = vert->image;
-
- setColorAlpha(image->mAlpha);
-#ifdef DEBUG_BIND_TEXTURE
- debugBindTexture(image);
-#endif // DEBUG_BIND_TEXTURE
-
- bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
- enableTexturingAndBlending();
- drawVertexes(vert->ogl);
- }
-}
-
-void NullOpenGLGraphics::calcPattern(ImageCollection *restrict const vertCol,
- const Image *restrict const image,
- const int x, const int y,
- const int w, const int h) const restrict2
-{
- if (vertCol == nullptr || image == nullptr)
- return;
- ImageVertexes *vert = nullptr;
- if (vertCol->currentGLImage != image->mGLImage)
- {
- vert = new ImageVertexes;
- vertCol->currentGLImage = image->mGLImage;
- vertCol->currentVert = vert;
- vert->image = image;
- vertCol->draws.push_back(vert);
- }
- else
- {
- vert = vertCol->currentVert;
- }
-
- calcPatternInline(vert, image, x, y, w, h);
-}
-
-void NullOpenGLGraphics::calcTileVertexes(ImageVertexes *restrict const vert,
- const Image *restrict const image,
- int dstX, int dstY) const restrict2
-{
- calcTileVertexesInline(vert, image, dstX, dstY);
-}
-
-void NullOpenGLGraphics::calcTileVertexesInline(ImageVertexes *
- restrict const vert,
- const Image *
- restrict const image,
- int dstX,
- int dstY) const restrict2
-{
- const SDL_Rect &imageRect = image->mBounds;
- const int w = imageRect.w;
- const int h = imageRect.h;
-
- if (w == 0 || h == 0)
- return;
-
- const int srcX = imageRect.x;
- const int srcY = imageRect.y;
-
- const float tw = static_cast<float>(image->mTexWidth);
- const float th = static_cast<float>(image->mTexHeight);
-
- const unsigned int vLimit = mMaxVertices * 4;
-
- OpenGLGraphicsVertexes &ogl = vert->ogl;
-
-// STD_VECTOR<int> *vps = ogl.getVp();
- unsigned int vp = ogl.continueVp();
-
- // Draw a set of textured rectangles
- if (OpenGLImageHelper::mTextureType == GL_TEXTURE_2D)
- {
- const float texX1 = static_cast<float>(srcX) / tw;
- const float texY1 = static_cast<float>(srcY) / th;
-
- const float texX2 = static_cast<float>(srcX + w) / tw;
- const float texY2 = static_cast<float>(srcY + h) / th;
-
- GLfloat *const floatTexArray = ogl.continueFloatTexArray();
- GLint *const intVertArray = ogl.continueIntVertArray();
-
- floatTexArray[vp + 0] = texX1;
- floatTexArray[vp + 1] = texY1;
-
- floatTexArray[vp + 2] = texX2;
- floatTexArray[vp + 3] = texY1;
-
- floatTexArray[vp + 4] = texX2;
- floatTexArray[vp + 5] = texY2;
-
- floatTexArray[vp + 6] = texX1;
- floatTexArray[vp + 7] = texY2;
-
- intVertArray[vp + 0] = dstX;
- intVertArray[vp + 1] = dstY;
-
- intVertArray[vp + 2] = dstX + w;
- intVertArray[vp + 3] = dstY;
-
- intVertArray[vp + 4] = dstX + w;
- intVertArray[vp + 5] = dstY + h;
-
- intVertArray[vp + 6] = dstX;
- intVertArray[vp + 7] = dstY + h;
-
- vp += 8;
- if (vp >= vLimit)
- {
- ogl.switchFloatTexArray();
- ogl.switchIntVertArray();
- ogl.switchVp(vp);
- vp = 0;
- }
- }
- else
- {
- GLint *const intTexArray = ogl.continueIntTexArray();
- GLint *const intVertArray = ogl.continueIntVertArray();
-
- intTexArray[vp + 0] = srcX;
- intTexArray[vp + 1] = srcY;
-
- intTexArray[vp + 2] = srcX + w;
- intTexArray[vp + 3] = srcY;
-
- intTexArray[vp + 4] = srcX + w;
- intTexArray[vp + 5] = srcY + h;
-
- intTexArray[vp + 6] = srcX;
- intTexArray[vp + 7] = srcY + h;
-
- intVertArray[vp + 0] = dstX;
- intVertArray[vp + 1] = dstY;
-
- intVertArray[vp + 2] = dstX + w;
- intVertArray[vp + 3] = dstY;
-
- intVertArray[vp + 4] = dstX + w;
- intVertArray[vp + 5] = dstY + h;
-
- intVertArray[vp + 6] = dstX;
- intVertArray[vp + 7] = dstY + h;
-
- vp += 8;
- if (vp >= vLimit)
- {
- ogl.switchIntTexArray();
- ogl.switchIntVertArray();
- ogl.switchVp(vp);
- vp = 0;
- }
- }
- ogl.switchVp(vp);
-}
-
-void NullOpenGLGraphics::drawTileVertexes(const ImageVertexes *
- restrict const vert) restrict2
-{
- if (vert == nullptr)
- return;
- const Image *const image = vert->image;
-
- setColorAlpha(image->mAlpha);
-#ifdef DEBUG_BIND_TEXTURE
- debugBindTexture(image);
-#endif // DEBUG_BIND_TEXTURE
-
- bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
- enableTexturingAndBlending();
- drawVertexes(vert->ogl);
-}
-
-void NullOpenGLGraphics::calcWindow(ImageCollection *restrict const vertCol,
- const int x, const int y,
- const int w, const int h,
- const ImageRect &restrict imgRect)
- restrict2
-{
- ImageVertexes *vert = nullptr;
- Image *const image = imgRect.grid[4];
- if (image == nullptr)
- return;
- if (vertCol->currentGLImage != image->mGLImage)
- {
- vert = new ImageVertexes;
- vertCol->currentGLImage = image->mGLImage;
- vertCol->currentVert = vert;
- vert->image = image;
- vertCol->draws.push_back(vert);
- }
- else
- {
- vert = vertCol->currentVert;
- }
- calcImageRect(vert, x, y, w, h, imgRect);
-}
-
-void NullOpenGLGraphics::updateScreen() restrict2
-{
- BLOCK_START("Graphics::updateScreen")
-#ifdef DEBUG_DRAW_CALLS
- mLastDrawCalls = mDrawCalls;
- mDrawCalls = 0;
-#endif // DEBUG_DRAW_CALLS
-
- BLOCK_END("Graphics::updateScreen")
-}
-
-void NullOpenGLGraphics::beginDraw() restrict2
-{
- pushClipArea(Rect(0, 0, 640, 480));
-}
-
-void NullOpenGLGraphics::endDraw() restrict2
-{
- popClipArea();
-}
-
-void NullOpenGLGraphics::pushClipArea(const Rect &restrict area) restrict2
-{
- int transX = 0;
- int transY = 0;
-
- if (!mClipStack.empty())
- {
- const ClipRect &clipArea = mClipStack.top();
- transX = -clipArea.xOffset;
- transY = -clipArea.yOffset;
- }
-
- Graphics::pushClipArea(area);
-
- const ClipRect &clipArea = mClipStack.top();
- transX += clipArea.xOffset;
- transY += clipArea.yOffset;
-}
-
-void NullOpenGLGraphics::popClipArea() restrict2
-{
- Graphics::popClipArea();
-
- if (mClipStack.empty())
- return;
-}
-
-void NullOpenGLGraphics::drawPoint(int x A_UNUSED, int y A_UNUSED) restrict2
-{
- disableTexturingAndBlending();
- restoreColor();
-}
-
-void NullOpenGLGraphics::drawLine(int x1, int y1,
- int x2, int y2) restrict2
-{
- disableTexturingAndBlending();
- restoreColor();
-
- mFloatTexArray[0] = static_cast<float>(x1) + 0.5F;
- mFloatTexArray[1] = static_cast<float>(y1) + 0.5F;
- mFloatTexArray[2] = static_cast<float>(x2) + 0.5F;
- mFloatTexArray[3] = static_cast<float>(y2) + 0.5F;
-
- drawLineArrayf(4);
-}
-
-void NullOpenGLGraphics::drawRectangle(const Rect &restrict rect) restrict2
-{
- drawRectangle(rect, false);
-}
-
-void NullOpenGLGraphics::fillRectangle(const Rect &restrict rect) restrict2
-{
- drawRectangle(rect, true);
-}
-
-void NullOpenGLGraphics::enableTexturingAndBlending() restrict2
-{
- if (!mTexture)
- mTexture = true;
-
- if (!mAlpha)
- mAlpha = true;
-}
-
-void NullOpenGLGraphics::disableTexturingAndBlending() restrict2
-{
- mTextureBinded = 0;
- if (mAlpha && !mColorAlpha)
- mAlpha = false;
- else if (!mAlpha && mColorAlpha)
- mAlpha = true;
-
- if (mTexture)
- mTexture = false;
-}
-
-void NullOpenGLGraphics::drawRectangle(const Rect &restrict rect A_UNUSED,
- const bool filled A_UNUSED) restrict2
-{
- BLOCK_START("Graphics::drawRectangle")
- disableTexturingAndBlending();
- restoreColor();
-
-#ifdef DEBUG_DRAW_CALLS
- mDrawCalls ++;
-#endif // DEBUG_DRAW_CALLS
-
- BLOCK_END("Graphics::drawRectangle")
-}
-
-void NullOpenGLGraphics::drawNet(const int x1, const int y1,
- const int x2, const int y2,
- const int width, const int height) restrict2
-{
- unsigned int vp = 0;
- const unsigned int vLimit = mMaxVertices * 4;
-
- disableTexturingAndBlending();
- restoreColor();
-
- const float xf1 = static_cast<float>(x1);
- const float xf2 = static_cast<float>(x2);
- const float yf1 = static_cast<float>(y1);
- const float yf2 = static_cast<float>(y2);
-
- for (int y = y1; y < y2; y += height)
- {
- mFloatTexArray[vp + 0] = xf1;
- mFloatTexArray[vp + 1] = static_cast<float>(y);
-
- mFloatTexArray[vp + 2] = xf2;
- mFloatTexArray[vp + 3] = static_cast<float>(y);
-
- vp += 4;
- if (vp >= vLimit)
- {
- drawLineArrayf(vp);
- vp = 0;
- }
- }
-
- for (int x = x1; x < x2; x += width)
- {
- mFloatTexArray[vp + 0] = static_cast<float>(x);
- mFloatTexArray[vp + 1] = yf1;
-
- mFloatTexArray[vp + 2] = static_cast<float>(x);
- mFloatTexArray[vp + 3] = yf2;
-
- vp += 4;
- if (vp >= vLimit)
- {
- drawLineArrayf(vp);
- vp = 0;
- }
- }
-
- if (vp > 0)
- drawLineArrayf(vp);
-}
-
-void NullOpenGLGraphics::bindTexture(const GLenum target A_UNUSED,
- const GLuint texture)
-{
- if (mTextureBinded != texture)
- mTextureBinded = texture;
-}
-
-inline void NullOpenGLGraphics::drawQuadArrayfi(const int size A_UNUSED)
- restrict2
-{
-#ifdef DEBUG_DRAW_CALLS
- mDrawCalls ++;
-#endif // DEBUG_DRAW_CALLS
-}
-
-inline void NullOpenGLGraphics::drawQuadArrayfi(const GLint *restrict const
- intVertArray A_UNUSED,
- const GLfloat *restrict const
- floatTexArray A_UNUSED,
- const int size A_UNUSED)
- restrict2
-{
-#ifdef DEBUG_DRAW_CALLS
- mDrawCalls ++;
-#endif // DEBUG_DRAW_CALLS
-}
-
-inline void NullOpenGLGraphics::drawQuadArrayii(const int size A_UNUSED)
- restrict2
-{
-#ifdef DEBUG_DRAW_CALLS
- mDrawCalls ++;
-#endif // DEBUG_DRAW_CALLS
-}
-
-inline void NullOpenGLGraphics::drawQuadArrayii(const GLint *restrict const
- intVertArray A_UNUSED,
- const GLint *restrict const
- intTexArray A_UNUSED,
- const int size A_UNUSED)
- restrict2
-{
-#ifdef DEBUG_DRAW_CALLS
- mDrawCalls ++;
-#endif // DEBUG_DRAW_CALLS
-}
-
-inline void NullOpenGLGraphics::drawLineArrayi(const int size A_UNUSED)
- restrict2
-{
-#ifdef DEBUG_DRAW_CALLS
- mDrawCalls ++;
-#endif // DEBUG_DRAW_CALLS
-}
-
-inline void NullOpenGLGraphics::drawLineArrayf(const int size A_UNUSED)
- restrict2
-{
-#ifdef DEBUG_DRAW_CALLS
- mDrawCalls ++;
-#endif // DEBUG_DRAW_CALLS
-}
-
-void NullOpenGLGraphics::dumpSettings()
-{
-}
-
-void NullOpenGLGraphics::setColorAlpha(const float alpha) restrict2
-{
- if (!mIsByteColor && mFloatColor == alpha)
- return;
-
- mIsByteColor = false;
- mFloatColor = alpha;
-}
-
-void NullOpenGLGraphics::restoreColor() restrict2
-{
- if (mIsByteColor && mByteColor == mColor)
- return;
-
- mIsByteColor = true;
- mByteColor = mColor;
-}
-
-void NullOpenGLGraphics::drawImageRect(const int x, const int y,
- const int w, const int h,
- const ImageRect &restrict imgRect)
- restrict2
-{
- #include "render/graphics_drawImageRect.hpp"
-}
-
-void NullOpenGLGraphics::calcImageRect(ImageVertexes *restrict const vert,
- const int x, const int y,
- const int w, const int h,
- const ImageRect &restrict imgRect)
- restrict2
-{
- #include "render/graphics_calcImageRect.hpp"
-}
-
-void NullOpenGLGraphics::clearScreen() const restrict2
-{
-}
-
-#ifdef DEBUG_BIND_TEXTURE
-void NullOpenGLGraphics::debugBindTexture(const Image *restrict const image)
- restrict2
-{
- const std::string texture = image->mIdPath;
- if (mOldTexture != texture)
- {
- if ((!mOldTexture.empty() || !texture.empty())
- && mOldTextureId != image->mGLImage)
- {
- logger->log("bind: %s (%d) to %s (%d)", mOldTexture.c_str(),
- mOldTextureId, texture.c_str(), image->mGLImage);
- }
- mOldTextureId = image->mGLImage;
- mOldTexture = texture;
- }
-}
-#else // DEBUG_BIND_TEXTURE
-
-void NullOpenGLGraphics::debugBindTexture(const Image *restrict const
- image A_UNUSED) restrict2
-{
-}
-#endif // DEBUG_BIND_TEXTURE
-#endif // USE_OPENGL
diff --git a/src/render/nullopenglgraphics.h b/src/render/nullopenglgraphics.h
deleted file mode 100644
index f496c0a35..000000000
--- a/src/render/nullopenglgraphics.h
+++ /dev/null
@@ -1,111 +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 RENDER_NULLOPENGLGRAPHICS_H
-#define RENDER_NULLOPENGLGRAPHICS_H
-
-#if defined USE_OPENGL
-
-#include "localconsts.h"
-
-#include "render/graphics.h"
-
-#include "resources/fboinfo.h"
-
-#ifdef ANDROID
-#include <GLES/gl.h>
-#include <GLES/glext.h>
-#include <GLES2/gl2.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)
-#if defined(__APPLE__)
-#include <OpenGL/glext.h>
-#elif !defined(__native_client__)
-#include <GL/glext.h>
-#endif // defined(__APPLE__)
-#endif // ANDROID
-
-class OpenGLGraphicsVertexes;
-
-class NullOpenGLGraphics final : public Graphics
-{
- public:
- NullOpenGLGraphics();
-
- A_DELETE_COPY(NullOpenGLGraphics)
-
- ~NullOpenGLGraphics();
-
- inline void drawQuadArrayfi(const int size) restrict2 A_INLINE;
-
- inline void drawQuadArrayfi(const GLint *restrict const intVertArray,
- const GLfloat *restrict const
- floatTexArray,
- const int size) restrict2 A_INLINE;
-
- inline void drawQuadArrayii(const int size) restrict2 A_INLINE;
-
- inline void drawQuadArrayii(const GLint *restrict const intVertArray,
- const GLint *restrict const intTexArray,
- const int size) restrict2 A_INLINE;
-
- inline void drawLineArrayi(const int size) restrict2 A_INLINE;
-
- inline void drawLineArrayf(const int size) restrict2 A_INLINE;
-
- #include "render/graphicsdef.hpp"
- RENDER_GRAPHICSDEF_HPP
-
- #include "render/openglgraphicsdef.hpp"
- RENDER_OPENGLGRAPHICSDEF_HPP
-
- #include "render/openglgraphicsdef1.hpp"
- RENDER_OPENGLGRAPHICSDEF1_HPP
-
- #include "render/openglgraphicsdefadvanced.hpp"
- RENDER_OPENGLGRAPHICSDEFADVANCED_HPP
-
- private:
- GLfloat *mFloatTexArray A_NONNULLPOINTER;
- GLint *mIntTexArray A_NONNULLPOINTER;
- GLint *mIntVertArray A_NONNULLPOINTER;
- bool mTexture;
-
- bool mIsByteColor;
- Color mByteColor;
- float mFloatColor;
- int mMaxVertices;
- bool mColorAlpha;
-#ifdef DEBUG_BIND_TEXTURE
- std::string mOldTexture;
- unsigned mOldTextureId;
-#endif // DEBUG_BIND_TEXTURE
- FBOInfo mFbo;
-};
-#endif // defined USE_OPENGL
-#endif // RENDER_NULLOPENGLGRAPHICS_H
diff --git a/src/render/opengl/mgl.cpp b/src/render/opengl/mgl.cpp
deleted file mode 100644
index b2fd24c83..000000000
--- a/src/render/opengl/mgl.cpp
+++ /dev/null
@@ -1,34 +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 "render/opengl/mgl.h"
-
-#include "debug.h"
-
-#define defName(name) name##_t m##name = nullptr
-
-// include function defines
-#include "render/opengl/mgl.hpp"
-
-MGL_DEFINE
-
-#endif // USE_OPENGL
diff --git a/src/render/opengl/mgl.h b/src/render/opengl/mgl.h
deleted file mode 100644
index c761c2131..000000000
--- a/src/render/opengl/mgl.h
+++ /dev/null
@@ -1,38 +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 RENDER_OPENGL_MGL_H
-#define RENDER_OPENGL_MGL_H
-
-#ifdef USE_OPENGL
-
-#include "render/opengl/mgltypes.h"
-
-#define defName(name) extern name##_t m##name
-
-#include "render/opengl/mgl.hpp"
-
-MGL_DEFINE
-
-#undef defName
-#undef MGL_DEFINE
-
-#endif // USE_OPENGL
-#endif // RENDER_OPENGL_MGL_H
diff --git a/src/render/opengl/mgl.hpp b/src/render/opengl/mgl.hpp
deleted file mode 100644
index 980746edd..000000000
--- a/src/render/opengl/mgl.hpp
+++ /dev/null
@@ -1,144 +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/>.
- */
-
-#define MGL_DEFINE
-
-defName(glGenRenderbuffers);
-defName(glBindRenderbuffer);
-defName(glRenderbufferStorage);
-defName(glGenFramebuffers);
-defName(glBindFramebuffer);
-defName(glFramebufferTexture2D);
-defName(glFramebufferRenderbuffer);
-defName(glDeleteFramebuffers);
-defName(glDeleteRenderbuffers);
-defName(glGetStringi);
-defName(glGenSamplers);
-defName(glDeleteSamplers);
-defName(glBindSampler);
-defName(glSamplerParameteri);
-defName(glDebugMessageControl);
-defName(glDebugMessageCallback);
-defName(glFrameTerminator);
-defName(glLabelObject);
-defName(glGetObjectLabel);
-defName(glInsertEventMarker);
-defName(glPushGroupMarker);
-defName(glPopGroupMarker);
-defName(glGenVertexArrays);
-defName(glBindVertexArray);
-defName(glDeleteVertexArrays);
-defName(glDisableVertexAttribArray);
-defName(glDeleteShader);
-defName(glGetShaderInfoLog);
-defName(glGetShaderSource);
-defName(glDetachShader);
-defName(glGetAttachedShaders);
-defName(glGetActiveUniform);
-defName(glBindFragDataLocation);
-#ifndef __native_client__
-defName(glDeleteProgram);
-defName(glCreateProgram);
-defName(glGetProgramiv);
-defName(glLinkProgram);
-defName(glAttachShader);
-defName(glGetShaderiv);
-defName(glCompileShader);
-defName(glShaderSource);
-defName(glCreateShader);
-defName(glGetUniformLocation);
-defName(glGenBuffers);
-defName(glDeleteBuffers);
-defName(glBindBuffer);
-defName(glBufferData);
-defName(glEnableVertexAttribArray);
-defName(glVertexAttribPointer);
-defName(glUseProgram);
-defName(glUniform1f);
-defName(glUniform2f);
-defName(glUniform4f);
-defName(glValidateProgram);
-defName(glGetProgramInfoLog);
-defName(glBindAttribLocation);
-defName(glActiveTexture);
-
-#define mglDrawArrays(...) \
- glDrawArrays(__VA_ARGS__)
-#define mglDisable(...) \
- glDisable(__VA_ARGS__)
-#define mglHint(...) \
- glHint(__VA_ARGS__)
-#define mglScissor(...) \
- glScissor(__VA_ARGS__)
-#define mglEnable(...) \
- glEnable(__VA_ARGS__)
-#define mglBindTexture(...) \
- glBindTexture(__VA_ARGS__)
-#define mglGetIntegerv(...) \
- glGetIntegerv(__VA_ARGS__)
-#define mglClear(...) \
- glClear(__VA_ARGS__)
-#define mglGetString(...) \
- glGetString(__VA_ARGS__)
-#define mglTexParameteri(...) \
- glTexParameteri(__VA_ARGS__)
-#define mglTexImage2D(...) \
- glTexImage2D(__VA_ARGS__)
-#define mglGenTextures(...) \
- glGenTextures(__VA_ARGS__)
-#define mglPixelStorei(...) \
- glPixelStorei(__VA_ARGS__)
-#define mglReadPixels(...) \
- glReadPixels(__VA_ARGS__)
-
-#endif
-defName(glGetAttribLocation);
-defName(glUniform3f);
-defName(glCheckFramebufferStatus);
-defName(glProgramUniform1f);
-defName(glProgramUniform2f);
-defName(glProgramUniform3f);
-defName(glProgramUniform4f);
-defName(glBindVertexBuffer);
-defName(glVertexAttribBinding);
-defName(glVertexAttribFormat);
-defName(glBindVertexBuffers);
-defName(glIsBuffer);
-defName(glVertexAttribIFormat);
-defName(glVertexAttribIPointer);
-defName(glInvalidateTexImage);
-defName(glCopyImageSubData);
-defName(glPushDebugGroup);
-defName(glPopDebugGroup);
-defName(glObjectLabel);
-defName(glTexStorage2D);
-defName(glGenQueries);
-defName(glBeginQuery);
-defName(glEndQuery);
-defName(glDeleteQueries);
-defName(glGetQueryObjectiv);
-defName(glGetQueryObjectui64v);
-defName(glTextureSubImage2D);
-defName(glTextureSubImage2DEXT);
-defName(glClearTexImage);
-defName(glClearTexSubImage);
-#ifdef WIN32
-defName(wglGetExtensionsString);
-#endif
diff --git a/src/render/opengl/mglcheck.h b/src/render/opengl/mglcheck.h
deleted file mode 100644
index 0fa2e4ba6..000000000
--- a/src/render/opengl/mglcheck.h
+++ /dev/null
@@ -1,30 +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 RENDER_OPENGL_MGLCHECK_H
-#define RENDER_OPENGL_MGLCHECK_H
-
-#ifdef USE_OPENGL
-
-#define isGLNull(func) (!(func))
-#define isGLNotNull(func) ((func) != nullptr)
-
-#endif // USE_OPENGL
-#endif // RENDER_OPENGL_MGLCHECK_H
diff --git a/src/render/opengl/mgldefines.h b/src/render/opengl/mgldefines.h
deleted file mode 100644
index 7f3a09334..000000000
--- a/src/render/opengl/mgldefines.h
+++ /dev/null
@@ -1,136 +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 RENDER_OPENGL_MGLDEFINES_H
-#define RENDER_OPENGL_MGLDEFINES_H
-
-#ifdef USE_OPENGL
-
-#ifndef GL_NUM_EXTENSIONS
-#define GL_NUM_EXTENSIONS 0x821D
-#define GL_DEPTH_ATTACHMENT 0x8D00
-#define GL_COLOR_ATTACHMENT0 0x8CE0
-#define GL_FRAMEBUFFER 0x8D40
-#define GL_RENDERBUFFER 0x8D41
-#endif // GL_NUM_EXTENSIONS
-
-#ifndef GL_COMPRESSED_RGBA_ARB
-#define GL_COMPRESSED_RGBA_ARB 0x84EE
-#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3
-#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1
-#endif // GL_COMPRESSED_RGBA_ARB
-#ifndef GL_MAX_ELEMENTS_VERTICES
-#define GL_MAX_ELEMENTS_VERTICES 0x80E8
-#define GL_MAX_ELEMENTS_INDICES 0x80E9
-#endif // GL_MAX_ELEMENTS_VERTICES
-
-#ifndef GL_DEBUG_OUTPUT
-#define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242
-#define GL_DEBUG_OUTPUT 0x92E0
-#define GL_DEBUG_SOURCE_API 0x8246
-#define GL_DEBUG_SOURCE_WINDOW_SYSTEM 0x8247
-#define GL_DEBUG_SOURCE_SHADER_COMPILER 0x8248
-#define GL_DEBUG_SOURCE_THIRD_PARTY 0x8249
-#define GL_DEBUG_SOURCE_APPLICATION 0x824A
-#define GL_DEBUG_SOURCE_OTHER 0x824B
-#define GL_DEBUG_TYPE_ERROR 0x824C
-#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR 0x824D
-#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR 0x824E
-#define GL_DEBUG_TYPE_PORTABILITY 0x824F
-#define GL_DEBUG_TYPE_PERFORMANCE 0x8250
-#define GL_DEBUG_TYPE_OTHER 0x8251
-#define GL_DEBUG_TYPE_MARKER 0x8268
-#define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B
-#define GL_DEBUG_SEVERITY_HIGH 0x9146
-#define GL_DEBUG_SEVERITY_MEDIUM 0x9147
-#define GL_DEBUG_SEVERITY_LOW 0x9148
-#endif // GL_DEBUG_OUTPUT
-
-#ifndef GL_DEBUG_TYPE_PUSH_GROUP
-#define GL_DEBUG_TYPE_PUSH_GROUP 0x8269
-#endif // GL_DEBUG_TYPE_PUSH_GROUP
-#ifndef GL_DEBUG_TYPE_POP_GROUP
-#define GL_DEBUG_TYPE_POP_GROUP 0x826a
-#endif // GL_DEBUG_TYPE_POP_GROUP
-
-#ifndef GL_EXT_debug_label
-#define GL_PROGRAM_PIPELINE_OBJECT_EXT 0x8A4F
-#define GL_PROGRAM_OBJECT_EXT 0x8B40
-#define GL_SHADER_OBJECT_EXT 0x8B48
-#define GL_BUFFER_OBJECT_EXT 0x9151
-#define GL_QUERY_OBJECT_EXT 0x9153
-#define GL_VERTEX_ARRAY_OBJECT_EXT 0x9154
-#endif // GL_EXT_debug_label
-
-#ifndef GL_ARRAY_BUFFER
-#define GL_ARRAY_BUFFER 0x8892
-#define GL_ELEMENT_ARRAY_BUFFER 0x8893
-#endif // GL_ARRAY_BUFFER
-
-#ifndef GL_STREAM_DRAW
-#define GL_STREAM_DRAW 0x88E0
-#define GL_STATIC_DRAW 0x88E4
-#define GL_DYNAMIC_DRAW 0x88E8
-#endif // GL_STREAM_DRAW
-
-#ifndef GL_COMPILE_STATUS
-#define GL_FRAGMENT_SHADER 0x8B30
-#define GL_VERTEX_SHADER 0x8B31
-#define GL_COMPILE_STATUS 0x8B81
-#define GL_LINK_STATUS 0x8B82
-#define GL_VALIDATE_STATUS 0x8B83
-#define GL_INFO_LOG_LENGTH 0x8B84
-#endif // GL_COMPILE_STATUS
-
-#ifndef GL_DEPTH_CLAMP
-#define GL_DEPTH_CLAMP 0x864F
-#define GL_RASTERIZER_DISCARD 0x8C89
-#define GL_SAMPLE_MASK 0x8E51
-#endif // GL_DEPTH_CLAMP
-
-#ifndef GL_POLYGON_SMOOTH
-#define GL_POLYGON_SMOOTH 0x0B41
-#endif // GL_POLYGON_SMOOTH
-
-#ifndef GL_DEPTH_BOUNDS_TEST_EXT
-#define GL_DEPTH_BOUNDS_TEST_EXT 0x8890
-#endif // GL_DEPTH_BOUNDS_TEST_EXT
-
-#ifndef GL_TEXTURE_COMPRESSION_HINT_ARB
-#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF
-#endif // GL_TEXTURE_COMPRESSION_HINT_ARB
-
-#ifndef GLX_CONTEXT_PROFILE_MASK_ARB
-#define GLX_CONTEXT_PROFILE_MASK_ARB 0x9126
-#endif // GLX_CONTEXT_PROFILE_MASK_ARB
-
-#ifndef GLX_CONTEXT_MAJOR_VERSION_ARB
-#define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091
-#define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092
-#define GLX_CONTEXT_FLAGS_ARB 0x2094
-#endif // GLX_CONTEXT_MAJOR_VERSION_ARB
-
-#ifndef GL_COMPRESSED_RGBA_BPTC_UNORM_ARB
-#define GL_COMPRESSED_RGBA_BPTC_UNORM_ARB 0x8E8C
-#endif // GL_COMPRESSED_RGBA_BPTC_UNORM_ARB
-
-#endif // USE_OPENGL
-
-#endif // RENDER_OPENGL_MGLDEFINES_H
diff --git a/src/render/opengl/mglemu.cpp b/src/render/opengl/mglemu.cpp
deleted file mode 100644
index 864b130ef..000000000
--- a/src/render/opengl/mglemu.cpp
+++ /dev/null
@@ -1,54 +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/>.
- */
-
-#ifdef USE_OPENGL
-
-#include "render/opengl/mglemu.h"
-
-#ifdef OPENGLERRORS
-#include "graphicsmanager.h"
-#endif // OPENGLERRORS
-
-#include "resources/openglimagehelper.h"
-
-#include "debug.h"
-
-void APIENTRY emuglTextureSubImage2DEXT(GLuint texture, GLenum target,
- GLint level,
- GLint xoffset, GLint yoffset,
- GLsizei width, GLsizei height,
- GLenum format, GLenum type,
- const void *pixels)
-{
- OpenGLImageHelper::bindTexture(texture);
- glTexSubImage2D(target, level,
- xoffset, yoffset,
- width, height,
- format, type, pixels);
-#ifdef OPENGLERRORS
- graphicsManager.logError();
-#endif // OPENGLERRORS
-}
-
-void APIENTRY emuglActiveTexture(GLenum texture A_UNUSED)
-{
-}
-
-#endif // USE_OPENGL
diff --git a/src/render/opengl/mglemu.h b/src/render/opengl/mglemu.h
deleted file mode 100644
index cb31eaef2..000000000
--- a/src/render/opengl/mglemu.h
+++ /dev/null
@@ -1,41 +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 RENDER_OPENGL_MGLEMU_H
-#define RENDER_OPENGL_MGLEMU_H
-#ifdef USE_OPENGL
-
-#include "render/opengl/mgltypes.h"
-
-void APIENTRY emuglTextureSubImage2DEXT(GLuint texture,
- GLenum target,
- GLint level,
- GLint xoffset,
- GLint yoffset,
- GLsizei width,
- GLsizei height,
- GLenum format,
- GLenum type,
- const void *pixels);
-
-void APIENTRY emuglActiveTexture(GLenum texture);
-
-#endif // USE_OPENGL
-#endif // RENDER_OPENGL_MGLEMU_H
diff --git a/src/render/opengl/mglfunctions.h b/src/render/opengl/mglfunctions.h
deleted file mode 100644
index 2323283d2..000000000
--- a/src/render/opengl/mglfunctions.h
+++ /dev/null
@@ -1,101 +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 RENDER_OPENGL_MGLFUNCTIONS_H
-#define RENDER_OPENGL_MGLFUNCTIONS_H
-
-#ifdef USE_OPENGL
-
-#include "logger.h"
-
-LOGGER_H
-
-#ifdef WIN32
-#define getFunction(name) wglGetProcAddress(name)
-#elif defined ANDROID
-#define getFunction(name) eglGetProcAddress(name)
-#elif defined __APPLE__
-#define getFunction(name) nullptr
-#elif defined __native_client__
-#define getFunction(name) glGetProcAddressREGAL(name)
-#else // WIN32
-#define getFunction(name) glXGetProcAddress(\
- reinterpret_cast<const GLubyte*>(name))
-#endif // WIN32
-
-#define assignFunction(func) \
- { \
- m##func = reinterpret_cast<func##_t>(getFunction(#func)); \
- if (m##func == nullptr) \
- logger->log("function not found: " #func); \
- else \
- logger->log("assigned function: " #func); \
- }
-
-#define assignFunction3(func, ext) \
- { \
- m##func = reinterpret_cast<func##_t>(getFunction(#func#ext)); \
- if (m##func == nullptr) \
- { \
- logger->log("function not found: " #func#ext); \
- m##func = reinterpret_cast<func##_t>(getFunction(#func)); \
- if (m##func == nullptr) \
- logger->log("function not found: " #func); \
- else \
- logger->log("assigned function: " #func); \
- } \
- else \
- { \
- logger->log("assigned function: " #func#ext); \
- } \
- }
-
-#define assignFunctionARB(func) assignFunction3(func, ARB)
-
-#define assignFunctionEXT(func) assignFunction3(func, EXT)
-
-#define assignFunction2(func, name) \
- { \
- m##func = reinterpret_cast<func##_t>(getFunction(name)); \
- if (m##func == nullptr) \
- logger->log(std::string("function not found: ") + name); \
- else \
- logger->log(std::string("assigned function: ") + name); \
- }
-
-#define assignFunctionEmu2(func, name) \
- { \
- m##func = reinterpret_cast<func##_t>(getFunction(name)); \
- if (m##func == nullptr) \
- { \
- m##func = emu##func; \
- logger->log(std::string("emulated function: ") + name); \
- } \
- else \
- { \
- logger->log(std::string("assigned function: ") + name); \
- } \
- }
-
-#define emulateFunction(func) m##func = emu##func; \
- logger->log("emulated function: " #func)
-
-#endif // USE_OPENGL
-#endif // RENDER_OPENGL_MGLFUNCTIONS_H
diff --git a/src/render/opengl/mgltypes.h b/src/render/opengl/mgltypes.h
deleted file mode 100644
index d6ad9fee5..000000000
--- a/src/render/opengl/mgltypes.h
+++ /dev/null
@@ -1,226 +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 RENDER_OPENGL_MGLTYPES_H
-#define RENDER_OPENGL_MGLTYPES_H
-
-#ifdef USE_OPENGL
-
-#ifdef ANDROID
-#include <GLES/gl.h>
-#include <GLES/glext.h>
-#define APIENTRY GL_APIENTRY
-#else // ANDROID
-#include "localconsts.h"
-#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)
-#ifdef __native_client__
-#include <GL/Regal.h>
-#else // __native_client__
-#if defined(__APPLE__)
-#include <OpenGL/glext.h>
-#else // defined(__APPLE__)
-// probably this include need for some os / libs
-// #include <GL/glext.h>
-#ifndef __glext_h_
-#error missing include <GL/glext.h>
-#endif // __glext_h_
-#endif // defined(__APPLE__)
-#endif // __native_client__
-#endif // ANDROID
-
-#include "render/opengl/mgldefines.h"
-RENDER_OPENGL_MGLDEFINES_H
-
-#ifndef USE_SDL2
-#if defined(__GXX_EXPERIMENTAL_CXX0X__)
-#include <cstdint>
-#endif // defined(__GXX_EXPERIMENTAL_CXX0X__)
-#endif // USE_SDL2
-
-typedef void (APIENTRY *glGenRenderbuffers_t)(GLsizei, GLuint *);
-typedef void (APIENTRY *glBindRenderbuffer_t)(GLenum target,
- GLuint renderbuffer);
-typedef void (APIENTRY *glRenderbufferStorage_t)(GLenum target,
- GLenum internalformat, GLsizei width, GLsizei height);
-typedef void (APIENTRY *glGenFramebuffers_t)(GLsizei n, GLuint *framebuffers);
-typedef void (APIENTRY *glBindFramebuffer_t)(GLenum target,
- GLuint framebuffer);
-typedef void (APIENTRY *glFramebufferTexture2D_t)(GLenum target,
- GLenum attachment, GLenum textarget, GLuint texture, GLint level);
-typedef void (APIENTRY *glFramebufferRenderbuffer_t)(GLenum target,
- GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
-typedef void (APIENTRY *glDeleteFramebuffers_t) (GLsizei, const GLuint *);
-typedef void (APIENTRY *glDeleteRenderbuffers_t) (GLsizei, const GLuint *);
-typedef const GLubyte *(APIENTRY *glGetStringi_t) (GLenum, GLuint);
-typedef void (APIENTRY *glGenSamplers_t) (GLsizei count, GLuint *samplers);
-typedef void (APIENTRY *glDeleteSamplers_t)
- (GLsizei count, const GLuint * samplers);
-typedef void (APIENTRY *glBindSampler_t) (GLuint unit, GLuint sampler);
-typedef void (APIENTRY *glSamplerParameteri_t)
- (GLuint sampler, GLenum pname, GLint param);
-typedef void (APIENTRY *glDebugMessageControl_t) (GLenum source, GLenum type,
- GLenum severity, GLsizei count, const GLuint* ids, GLboolean enabled);
-typedef void (APIENTRY *glFrameTerminator_t) (void);
-typedef void (APIENTRY *glLabelObject_t) (GLenum type, GLuint object,
- GLsizei length, const GLchar *label);
-typedef void (APIENTRY *glGetObjectLabel_t) (GLenum type, GLuint object,
- GLsizei bufSize, GLsizei *length, GLchar *label);
-typedef void (APIENTRY *glInsertEventMarker_t)
- (GLsizei length, const char *marker);
-typedef void (APIENTRY *glPushGroupMarker_t)
- (GLsizei length, const char *marker);
-typedef void (APIENTRY *glPopGroupMarker_t) (void);
-typedef void (APIENTRY *glGenVertexArrays_t) (GLsizei n, GLuint *arrays);
-typedef void (APIENTRY *glBindVertexArray_t) (GLuint array);
-typedef void (APIENTRY *glDeleteVertexArrays_t) (GLsizei n, GLuint *arrays);
-typedef void (APIENTRY *glDisableVertexAttribArray_t) (GLuint index);
-typedef void (APIENTRY *glDeleteShader_t) (GLenum shader);
-typedef void (APIENTRY *glGetShaderInfoLog_t) (GLuint shader,
- GLsizei maxLength, GLsizei *length, GLchar *infoLog);
-typedef void (APIENTRY *glGetShaderSource_t) (GLuint shader,
- GLsizei bufSize, GLsizei *length, GLchar *source);
-typedef void (APIENTRY *glDetachShader_t) (GLuint program, GLuint shader);
-typedef void (APIENTRY *glGetAttachedShaders_t) (GLuint program,
- GLsizei maxCount, GLsizei *count, GLuint *shaders);
-typedef void (APIENTRY *glGetActiveUniform_t) (GLuint program, GLuint index,
- GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);
-typedef GLint (APIENTRY *glBindFragDataLocation_t) (GLuint program,
- GLuint colorNumber, const char *name);
-#ifndef __native_client__
-typedef void (APIENTRY *glDeleteProgram_t) (GLuint program);
-typedef GLuint (APIENTRY *glCreateProgram_t) (void);
-typedef void (APIENTRY *glGetProgramiv_t) (GLuint program,
- GLenum pname, GLint *params);
-typedef void (APIENTRY *glLinkProgram_t) (GLuint program);
-typedef void (APIENTRY *glAttachShader_t) (GLuint program, GLuint shader);
-typedef void (APIENTRY *glGetShaderiv_t) (GLuint shader,
- GLenum pname, GLint *params);
-typedef void (APIENTRY *glCompileShader_t) (GLuint shader);
-typedef void (APIENTRY *glShaderSource_t) (GLuint shader,
- GLsizei count, const GLchar **string, const GLint *length);
-typedef GLuint (APIENTRY *glCreateShader_t) (GLenum shaderType);
-typedef GLint (APIENTRY *glGetUniformLocation_t) (GLuint program,
- const GLchar *name);
-typedef void (APIENTRY *glGenBuffers_t) (GLsizei n, GLuint *buffers);
-typedef void (APIENTRY *glDeleteBuffers_t) (GLsizei n, GLuint *buffers);
-typedef void (APIENTRY *glBindBuffer_t) (GLenum target, GLuint buffer);
-typedef void (APIENTRY *glBufferData_t) (GLenum target, GLsizeiptr size,
- const GLvoid *data, GLenum usage);
-typedef void (APIENTRY *glEnableVertexAttribArray_t) (GLuint index);
-typedef void (APIENTRY *glVertexAttribPointer_t) (GLuint index, GLint size,
- GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer);
-typedef void (APIENTRY *glUseProgram_t) (GLuint program);
-typedef void (APIENTRY *glUniform1f_t) (GLint location, GLfloat v0);
-typedef void (APIENTRY *glUniform2f_t) (GLint location,
- GLfloat v0, GLfloat v1);
-typedef void (APIENTRY *glUniform4f_t) (GLint location,
- GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
-typedef void (APIENTRY *glValidateProgram_t) (GLuint program);
-typedef void (APIENTRY *glGetProgramInfoLog_t) (GLuint program,
- GLsizei maxLength, GLsizei *length, GLchar *infoLog);
-typedef void (APIENTRY *glBindAttribLocation_t) (GLuint program,
- GLuint index, const GLchar *name);
-typedef void (APIENTRY *glActiveTexture_t) (GLenum texture);
-#endif // __native_client__
-
-typedef GLint (APIENTRY *glGetAttribLocation_t) (GLuint program,
- const GLchar *name);
-typedef void (APIENTRY *glUniform3f_t) (GLint location,
- GLfloat v0, GLfloat v1, GLfloat v2);
-typedef GLenum (APIENTRY *glCheckFramebufferStatus_t) (GLenum target);
-typedef void (APIENTRY *glProgramUniform1f_t) (GLuint program,
- GLint location, GLfloat v0);
-typedef void (APIENTRY *glProgramUniform2f_t) (GLuint program,
- GLint location, GLfloat v0, GLfloat v1);
-typedef void (APIENTRY *glProgramUniform3f_t) (GLuint program,
- GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
-typedef void (APIENTRY *glProgramUniform4f_t) (GLuint program,
- GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
-typedef void (APIENTRY *glBindVertexBuffer_t) (GLuint bindingindex,
- GLuint buffer, GLintptr offset, GLintptr stride);
-typedef void (APIENTRY *glVertexAttribBinding_t) (GLuint attribindex,
- GLuint bindingindex);
-typedef void (APIENTRY *glVertexAttribFormat_t) (GLuint attribindex,
- GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset);
-typedef void (APIENTRY *glBindVertexBuffers_t) (GLuint first, GLsizei count,
- const GLuint *buffers, const GLuint *offsets, const GLsizei *strides);
-typedef GLboolean (APIENTRY *glIsBuffer_t) (GLuint buffer);
-typedef void (APIENTRY *glVertexAttribIFormat_t) (GLuint attribindex,
- GLint size, GLenum type, GLuint relativeoffset);
-typedef void (APIENTRY *glVertexAttribIPointer_t) (GLuint index, GLint size,
- GLenum type, GLsizei stride, const GLvoid * pointer);
-typedef void (APIENTRY *glInvalidateTexImage_t) (GLuint texture, GLint level);
-typedef void (APIENTRY *glCopyImageSubData_t) (GLuint srcName,
- GLenum srcTarget, GLint srcLevel,
- GLint srcX, GLint srcY, GLint srcZ,
- GLuint dstName, GLenum dstTarget, GLint dstLevel,
- GLint dstX, GLint dstY, GLint dstZ,
- GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth);
-typedef void (APIENTRY *glPushDebugGroup_t) (GLenum source, GLuint id,
- GLsizei length, const GLchar * message);
-typedef void (APIENTRY *glPopDebugGroup_t) (void);
-typedef void (APIENTRY *glObjectLabel_t) (GLenum identifier, GLuint name,
- GLsizei length, const GLchar *label);
-typedef void (APIENTRY *glTexStorage2D_t) (GLenum target, GLsizei levels,
- GLenum internalformat, GLsizei width, GLsizei height);
-typedef void (APIENTRY *glGenQueries_t) (GLsizei n, GLuint *ids);
-typedef void (APIENTRY *glBeginQuery_t) (GLenum target, GLuint id);
-typedef void (APIENTRY *glEndQuery_t) (GLenum target);
-typedef void (APIENTRY *glDeleteQueries_t) (GLsizei n, const GLuint *ids);
-typedef void (APIENTRY *glGetQueryObjectiv_t) (GLuint id,
- GLenum pname, GLint *params);
-typedef void (APIENTRY *glGetQueryObjectui64v_t) (GLuint id,
- GLenum pname, uint64_t *params);
-typedef void (APIENTRY *glTextureSubImage2DEXT_t) (GLuint texture,
- GLenum target, GLint level, GLint xoffset, GLint yoffset,
- GLsizei width, GLsizei height, GLenum format, GLenum type,
- const void *pixels);
-typedef void (APIENTRY *glTextureSubImage2D_t) (GLuint texture,
- GLint level, GLint xoffset, GLint yoffset,
- GLsizei width, GLsizei height, GLenum format, GLenum type,
- const void *pixels);
-typedef void (APIENTRY *glClearTexImage_t) (GLuint texture, GLint level,
- GLenum format, GLenum type, const void * data);
-typedef void (APIENTRY *glClearTexSubImage_t) (GLuint texture, GLint level,
- GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height,
- GLsizei depth, GLenum format, GLenum type, const void * data);
-
-// callback
-typedef void (APIENTRY *GLDEBUGPROC_t) (GLenum source, GLenum type, GLuint id,
- GLenum severity, GLsizei length, const GLchar *message, GLvoid *userParam);
-
-typedef void (APIENTRY *glDebugMessageCallback_t) (GLDEBUGPROC_t callback,
- const void *userParam);
-
-
-#ifdef WIN32
-typedef const char* (APIENTRY * wglGetExtensionsString_t) (HDC hdc);
-#else // WIN32
-#define CALLBACK
-#endif // WIN32
-
-#endif // USE_OPENGL
-#endif // RENDER_OPENGL_MGLTYPES_H
diff --git a/src/render/opengl/naclglfunctions.h b/src/render/opengl/naclglfunctions.h
deleted file mode 100644
index 4dc8424eb..000000000
--- a/src/render/opengl/naclglfunctions.h
+++ /dev/null
@@ -1,322 +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 RENDER_OPENGL_NACLGLFUNCTIONS_H
-#define RENDER_OPENGL_NACLGLFUNCTIONS_H
-
-#if defined(__native_client__) && defined(USE_OPENGL)
-
-#include <ppapi/c/ppb_opengles2.h>
-
-extern const struct PPB_OpenGLES2* gles2Interface;
-extern PP_Resource gles2Context;
-
-#define mglDrawArrays(...) \
- gles2Interface->DrawArrays(gles2Context, __VA_ARGS__)
-#define mglEnableVertexAttribArray(...) \
- gles2Interface->EnableVertexAttribArray(gles2Context, __VA_ARGS__)
-#define mglVertexAttribPointer(...) \
- gles2Interface->VertexAttribPointer(gles2Context, __VA_ARGS__)
-#define mglUseProgram(...) \
- gles2Interface->UseProgram(gles2Context, __VA_ARGS__)
-#define mglViewport(...) \
- gles2Interface->Viewport(gles2Context, __VA_ARGS__)
-#define mglGenBuffers(...) \
- gles2Interface->GenBuffers(gles2Context, __VA_ARGS__)
-#define mglBindBuffer(...) \
- gles2Interface->BindBuffer(gles2Context, __VA_ARGS__)
-#define mglBufferData(...) \
- gles2Interface->BufferData(gles2Context, __VA_ARGS__)
-#define mglDeleteBuffers(...) \
- gles2Interface->DeleteBuffers(gles2Context, __VA_ARGS__)
-#define mglGetUniformLocation(...) \
- gles2Interface->GetUniformLocation(gles2Context, __VA_ARGS__)
-#define mglCreateShader(...) \
- gles2Interface->CreateShader(gles2Context, __VA_ARGS__)
-#define mglShaderSource(...) \
- gles2Interface->ShaderSource(gles2Context, __VA_ARGS__)
-#define mglCompileShader(...) \
- gles2Interface->CompileShader(gles2Context, __VA_ARGS__)
-#define mglGetShaderiv(...) \
- gles2Interface->GetShaderiv(gles2Context, __VA_ARGS__)
-#define mglAttachShader(...) \
- gles2Interface->AttachShader(gles2Context, __VA_ARGS__)
-#define mglBindAttribLocation(...) \
- gles2Interface->BindAttribLocation(gles2Context, __VA_ARGS__)
-#define mglLinkProgram(...) \
- gles2Interface->LinkProgram(gles2Context, __VA_ARGS__)
-#define mglGetProgramiv(...) \
- gles2Interface->GetProgramiv(gles2Context, __VA_ARGS__)
-#define mglClearColor(...) \
- gles2Interface->ClearColor(gles2Context, __VA_ARGS__)
-#define mglUniform1f(...) \
- gles2Interface->Uniform1f(gles2Context, __VA_ARGS__)
-#define mglUniform2f(...) \
- gles2Interface->Uniform2f(gles2Context, __VA_ARGS__)
-#define mglUniform3f(...) \
- gles2Interface->Uniform3f(gles2Context, __VA_ARGS__)
-#define mglUniform4f(...) \
- gles2Interface->Uniform4f(gles2Context, __VA_ARGS__)
-#define mglUniform1i(...) \
- gles2Interface->Uniform1i(gles2Context, __VA_ARGS__)
-#define mglUniform2i(...) \
- gles2Interface->Uniform2i(gles2Context, __VA_ARGS__)
-#define mglUniform3i(...) \
- gles2Interface->Uniform3i(gles2Context, __VA_ARGS__)
-#define mglUniform4i(...) \
- gles2Interface->Uniform4i(gles2Context, __VA_ARGS__)
-#define mglUniform1fv(...) \
- gles2Interface->Uniform1fv(gles2Context, __VA_ARGS__)
-#define mglUniform2fv(...) \
- gles2Interface->Uniform2fv(gles2Context, __VA_ARGS__)
-#define mglUniform3fv(...) \
- gles2Interface->Uniform3fv(gles2Context, __VA_ARGS__)
-#define mglUniform4fv(...) \
- gles2Interface->Uniform4fv(gles2Context, __VA_ARGS__)
-#define mglUniform1iv(...) \
- gles2Interface->Uniform1iv(gles2Context, __VA_ARGS__)
-#define mglUniform2iv(...) \
- gles2Interface->Uniform2iv(gles2Context, __VA_ARGS__)
-#define mglUniform3iv(...) \
- gles2Interface->Uniform3iv(gles2Context, __VA_ARGS__)
-#define mglUniform4iv(...) \
- gles2Interface->Uniform4iv(gles2Context, __VA_ARGS__)
-#define mglActiveTexture(...) \
- gles2Interface->ActiveTexture(gles2Context, __VA_ARGS__)
-#define mglBindTexture(...) \
- gles2Interface->BindTexture(gles2Context, __VA_ARGS__)
-#define mglEnable(...) \
- gles2Interface->Enable(gles2Context, __VA_ARGS__)
-#define mglClear(...) \
- gles2Interface->Clear(gles2Context, __VA_ARGS__)
-#define mglValidateProgram(...) \
- gles2Interface->ValidateProgram(gles2Context, __VA_ARGS__)
-#define mglDeleteProgram(...) \
- gles2Interface->DeleteProgram(gles2Context, __VA_ARGS__)
-#define mglCreateProgram() \
- gles2Interface->CreateProgram(gles2Context)
-#define mglGetProgramInfoLog(...) \
- gles2Interface->GetProgramInfoLog(gles2Context, __VA_ARGS__)
-#define mglDisable(...) \
- gles2Interface->Disable(gles2Context, __VA_ARGS__)
-#define mglHint(...) \
- gles2Interface->Hint(gles2Context, __VA_ARGS__)
-#define mglScissor(...) \
- gles2Interface->Scissor(gles2Context, __VA_ARGS__)
-#define mglEnable(...) \
- gles2Interface->Enable(gles2Context, __VA_ARGS__)
-#define mglGetIntegerv(...) \
- gles2Interface->GetIntegerv(gles2Context, __VA_ARGS__)
-#define mglGetString(...) \
- gles2Interface->GetString(gles2Context, __VA_ARGS__)
-#define mglBindFramebuffer(...) \
- gles2Interface->BindFramebuffer(gles2Context, __VA_ARGS__)
-#define mglBindRenderbuffer(...) \
- gles2Interface->BindRenderbuffer(gles2Context, __VA_ARGS__)
-#define mglBlendColor(...) \
- gles2Interface->BlendColor(gles2Context, __VA_ARGS__)
-#define mglBlendEquation(...) \
- gles2Interface->BlendEquation(gles2Context, __VA_ARGS__)
-#define mglBlendEquationSeparate(...) \
- gles2Interface->BlendEquationSeparate(gles2Context, __VA_ARGS__)
-#define mglBlendFunc(...) \
- gles2Interface->BlendFunc(gles2Context, __VA_ARGS__)
-#define mglBlendFuncSeparate(...) \
- gles2Interface->BlendFuncSeparate(gles2Context, __VA_ARGS__)
-#define mglBufferSubData(...) \
- gles2Interface->BufferSubData(gles2Context, __VA_ARGS__)
-#define mglCheckFramebufferStatus(...) \
- gles2Interface->CheckFramebufferStatus(gles2Context, __VA_ARGS__)
-#define mglClearDepthf(...) \
- gles2Interface->ClearDepthf(gles2Context, __VA_ARGS__)
-#define mglClearStencil(...) \
- gles2Interface->ClearStencil(gles2Context, __VA_ARGS__)
-#define mglColorMask(...) \
- gles2Interface->ColorMask(gles2Context, __VA_ARGS__)
-#define mglCompressedTexImage2D(...) \
- gles2Interface->CompressedTexImage2D(gles2Context, __VA_ARGS__)
-#define mglCompressedTexSubImage2D(...) \
- gles2Interface->CompressedTexSubImage2D(gles2Context, __VA_ARGS__)
-#define mglCopyTexImage2D(...) \
- gles2Interface->CopyTexImage2D(gles2Context, __VA_ARGS__)
-#define mglCopyTexSubImage2D(...) \
- gles2Interface->CopyTexSubImage2D(gles2Context, __VA_ARGS__)
-#define mglCullFace(...) \
- gles2Interface->CullFace(gles2Context, __VA_ARGS__)
-#define mglDeleteFramebuffers(...) \
- gles2Interface->DeleteFramebuffers(gles2Context, __VA_ARGS__)
-#define mglDeleteRenderbuffers(...) \
- gles2Interface->DeleteRenderbuffers(gles2Context, __VA_ARGS__)
-#define mglDeleteShader(...) \
- gles2Interface->DeleteShader(gles2Context, __VA_ARGS__)
-#define mglDeleteTextures(...) \
- gles2Interface->DeleteTextures(gles2Context, __VA_ARGS__)
-#define mglDepthFunc(...) \
- gles2Interface->DepthFunc(gles2Context, __VA_ARGS__)
-#define mglDepthMask(...) \
- gles2Interface->DepthMask(gles2Context, __VA_ARGS__)
-#define mglDepthRangef(...) \
- gles2Interface->DepthRangef(gles2Context, __VA_ARGS__)
-#define mglDetachShader(...) \
- gles2Interface->DetachShader(gles2Context, __VA_ARGS__)
-#define mglDisableVertexAttribArray(...) \
- gles2Interface->DisableVertexAttribArray(gles2Context, __VA_ARGS__)
-#define mglDrawElements(...) \
- gles2Interface->DrawElements(gles2Context, __VA_ARGS__)
-#define mglFinish(...) \
- gles2Interface->Finish(gles2Context, __VA_ARGS__)
-#define mglFlush(...) \
- gles2Interface->Flush(gles2Context, __VA_ARGS__)
-#define mglFramebufferRenderbuffer(...) \
- gles2Interface->FramebufferRenderbuffer(gles2Context, __VA_ARGS__)
-#define mglFramebufferTexture2D(...) \
- gles2Interface->FramebufferTexture2D(gles2Context, __VA_ARGS__)
-#define mglFrontFace(...) \
- gles2Interface->FrontFace(gles2Context, __VA_ARGS__)
-#define mglGenerateMipmap(...) \
- gles2Interface->GenerateMipmap(gles2Context, __VA_ARGS__)
-#define mglGenFramebuffers(...) \
- gles2Interface->GenFramebuffers(gles2Context, __VA_ARGS__)
-#define mglGenRenderbuffers(...) \
- gles2Interface->GenRenderbuffers(gles2Context, __VA_ARGS__)
-#define mglGenTextures(...) \
- gles2Interface->GenTextures(gles2Context, __VA_ARGS__)
-#define mglGetActiveAttrib(...) \
- gles2Interface->GetActiveAttrib(gles2Context, __VA_ARGS__)
-#define mglGetActiveUniform(...) \
- gles2Interface->GetActiveUniform(gles2Context, __VA_ARGS__)
-#define mglGetAttachedShaders(...) \
- gles2Interface->GetAttachedShaders(gles2Context, __VA_ARGS__)
-#define mglGetAttribLocation(...) \
- gles2Interface->GetAttribLocation(gles2Context, __VA_ARGS__)
-#define mglGetBooleanv(...) \
- gles2Interface->GetBooleanv(gles2Context, __VA_ARGS__)
-#define mglGetBufferParameteriv(...) \
- gles2Interface->GetBufferParameteriv(gles2Context, __VA_ARGS__)
-#define mglGetError(...) \
- gles2Interface->GetError(gles2Context, __VA_ARGS__)
-#define mglGetFloatv(...) \
- gles2Interface->GetFloatv(gles2Context, __VA_ARGS__)
-#define mglGetFramebufferAttachmentParameteriv(...) \
- gles2Interface->GetFramebufferAttachmentParameteriv(gles2Context, \
- __VA_ARGS__)
-#define mglGetIntegerv(...) \
- gles2Interface->GetIntegerv(gles2Context, __VA_ARGS__)
-#define mglGetRenderbufferParameteriv(...) \
- gles2Interface->GetRenderbufferParameteriv(gles2Context, __VA_ARGS__)
-#define mglGetShaderInfoLog(...) \
- gles2Interface->GetShaderInfoLog(gles2Context, __VA_ARGS__)
-#define mglGetShaderPrecisionFormat(...) \
- gles2Interface->GetShaderPrecisionFormat(gles2Context, __VA_ARGS__)
-#define mglGetShaderSource(...) \
- gles2Interface->GetShaderSource(gles2Context, __VA_ARGS__)
-#define mglGetTexParameterfv(...) \
- gles2Interface->GetTexParameterfv(gles2Context, __VA_ARGS__)
-#define mglGetTexParameteriv(...) \
- gles2Interface->GetTexParameteriv(gles2Context, __VA_ARGS__)
-#define mglGetUniformfv(...) \
- gles2Interface->GetUniformfv(gles2Context, __VA_ARGS__)
-#define mglGetUniformiv(...) \
- gles2Interface->GetUniformiv(gles2Context, __VA_ARGS__)
-#define mglGetVertexAttribfv(...) \
- gles2Interface->GetVertexAttribfv(gles2Context, __VA_ARGS__)
-#define mglGetVertexAttribiv(...) \
- gles2Interface->GetVertexAttribiv(gles2Context, __VA_ARGS__)
-#define mglGetVertexAttribPointerv(...) \
- gles2Interface->GetVertexAttribPointerv(gles2Context, __VA_ARGS__)
-#define mglIsBuffer(...) \
- gles2Interface->IsBuffer(gles2Context, __VA_ARGS__)
-#define mglIsEnabled(...) \
- gles2Interface->IsEnabled(gles2Context, __VA_ARGS__)
-#define mglIsFramebuffer(...) \
- gles2Interface->IsFramebuffer(gles2Context, __VA_ARGS__)
-#define mglIsProgram(...) \
- gles2Interface->IsProgram(gles2Context, __VA_ARGS__)
-#define mglIsRenderbuffer(...) \
- gles2Interface->IsRenderbuffer(gles2Context, __VA_ARGS__)
-#define mglIsShader(...) \
- gles2Interface->IsShader(gles2Context, __VA_ARGS__)
-#define mglIsTexture(...) \
- gles2Interface->IsTexture(gles2Context, __VA_ARGS__)
-#define mglLineWidth(...) \
- gles2Interface->LineWidth(gles2Context, __VA_ARGS__)
-#define mglPixelStorei(...) \
- gles2Interface->PixelStorei(gles2Context, __VA_ARGS__)
-#define mglPolygonOffset(...) \
- gles2Interface->PolygonOffset(gles2Context, __VA_ARGS__)
-#define mglReadPixels(...) \
- gles2Interface->ReadPixels(gles2Context, __VA_ARGS__)
-#define mglReleaseShaderCompiler(...) \
- gles2Interface->ReleaseShaderCompiler(gles2Context, __VA_ARGS__)
-#define mglRenderbufferStorage(...) \
- gles2Interface->RenderbufferStorage(gles2Context, __VA_ARGS__)
-#define mglSampleCoverage(...) \
- gles2Interface->SampleCoverage(gles2Context, __VA_ARGS__)
-#define mglShaderBinary(...) \
- gles2Interface->ShaderBinary(gles2Context, __VA_ARGS__)
-#define mglStencilFunc(...) \
- gles2Interface->StencilFunc(gles2Context, __VA_ARGS__)
-#define mglStencilFuncSeparate(...) \
- gles2Interface->StencilFuncSeparate(gles2Context, __VA_ARGS__)
-#define mglStencilMask(...) \
- gles2Interface->StencilMask(gles2Context, __VA_ARGS__)
-#define mglStencilMaskSeparate(...) \
- gles2Interface->StencilMaskSeparate(gles2Context, __VA_ARGS__)
-#define mglStencilOp(...) \
- gles2Interface->StencilOp(gles2Context, __VA_ARGS__)
-#define mglStencilOpSeparate(...) \
- gles2Interface->StencilOpSeparate(gles2Context, __VA_ARGS__)
-#define mglTexImage2D(...) \
- gles2Interface->TexImage2D(gles2Context, __VA_ARGS__)
-#define mglTexParameterf(...) \
- gles2Interface->TexParameterf(gles2Context, __VA_ARGS__)
-#define mglTexParameterfv(...) \
- gles2Interface->TexParameterfv(gles2Context, __VA_ARGS__)
-#define mglTexParameteri(...) \
- gles2Interface->TexParameteri(gles2Context, __VA_ARGS__)
-#define mglTexParameteriv(...) \
- gles2Interface->TexParameteriv(gles2Context, __VA_ARGS__)
-#define mglTexSubImage2D(...) \
- gles2Interface->TexSubImage2D(gles2Context, __VA_ARGS__)
-#define mglUniformMatrix2fv(...) \
- gles2Interface->UniformMatrix2fv(gles2Context, __VA_ARGS__)
-#define mglUniformMatrix3fv(...) \
- gles2Interface->UniformMatrix3fv(gles2Context, __VA_ARGS__)
-#define mglUniformMatrix4fv(...) \
- gles2Interface->UniformMatrix4fv(gles2Context, __VA_ARGS__)
-#define mglVertexAttrib1f(...) \
- gles2Interface->VertexAttrib1f(gles2Context, __VA_ARGS__)
-#define mglVertexAttrib2f(...) \
- gles2Interface->VertexAttrib2f(gles2Context, __VA_ARGS__)
-#define mglVertexAttrib3f(...) \
- gles2Interface->VertexAttrib3f(gles2Context, __VA_ARGS__)
-#define mglVertexAttrib4f(...) \
- gles2Interface->VertexAttrib4f(gles2Context, __VA_ARGS__)
-#define mglVertexAttrib1fv(...) \
- gles2Interface->VertexAttrib1fv(gles2Context, __VA_ARGS__)
-#define mglVertexAttrib2fv(...) \
- gles2Interface->VertexAttrib2fv(gles2Context, __VA_ARGS__)
-#define mglVertexAttrib3fv(...) \
- gles2Interface->VertexAttrib3fv(gles2Context, __VA_ARGS__)
-#define mglVertexAttrib4fv(...) \
- gles2Interface->VertexAttrib4fv(gles2Context, __VA_ARGS__)
-
-#endif // defined(__native_client__) && defined(USE_OPENGL)
-#endif // RENDER_OPENGL_NACLGLFUNCTIONS_H
diff --git a/src/render/opengl/opengldebug.h b/src/render/opengl/opengldebug.h
deleted file mode 100644
index 4afe25491..000000000
--- a/src/render/opengl/opengldebug.h
+++ /dev/null
@@ -1,38 +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 RENDER_OPENGL_OPENGLDEBUG_H
-#define RENDER_OPENGL_OPENGLDEBUG_H
-
-#include "render/opengl/mgl.h"
-
-RENDER_OPENGL_MGL_H
-
-#if defined(DEBUG_OPENGL) && defined(USE_OPENGL)
-#define GLDEBUG_START(text) if (mglPushGroupMarker) \
- mglPushGroupMarker(sizeof(text), text);
-#define GLDEBUG_END() if (mglPopGroupMarker) \
- mglPopGroupMarker();
-#else // defined(DEBUG_OPENGL) && defined(USE_OPENGL)
-#define GLDEBUG_START(text)
-#define GLDEBUG_END()
-#endif // defined(DEBUG_OPENGL) && defined(USE_OPENGL)
-
-#endif // RENDER_OPENGL_OPENGLDEBUG_H
diff --git a/src/render/openglgraphicsdef.hpp b/src/render/openglgraphicsdef.hpp
deleted file mode 100644
index 7a4fd4e1e..000000000
--- a/src/render/openglgraphicsdef.hpp
+++ /dev/null
@@ -1,58 +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/>.
- */
-
-#define RENDER_OPENGLGRAPHICSDEF_HPP
-
-public:
- void drawRectangle(const Rect &restrict rect,
- const bool filled) restrict2;
-
- void drawNet(const int x1, const int y1,
- const int x2, const int y2,
- const int width, const int height) restrict2 override final;
-
- static void dumpSettings();
-
- int getMemoryUsage() restrict2 A_WARN_UNUSED;
-
- void updateTextureFormat() restrict2;
-
- bool isAllowScale() const restrict2 noexcept2 override final
- { return true; }
-
- void clearScreen() const restrict2 override final;
-
- void deleteArrays() restrict2 override final;
-
- static void bindTexture(const GLenum target, const GLuint texture);
-
- static GLuint mTextureBinded;
-
-protected:
- void enableTexturingAndBlending() restrict2;
-
- void disableTexturingAndBlending() restrict2;
-
-private:
- void inline setColorAlpha(const float alpha) restrict2 A_INLINE;
-
- void inline restoreColor() restrict2 A_INLINE;
diff --git a/src/render/openglgraphicsdef1.hpp b/src/render/openglgraphicsdef1.hpp
deleted file mode 100644
index ba921494d..000000000
--- a/src/render/openglgraphicsdef1.hpp
+++ /dev/null
@@ -1,30 +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/>.
- */
-
-#define RENDER_OPENGLGRAPHICSDEF1_HPP
-
-public:
- void setColor(const Color &restrict color) override final
- {
- mColor = color;
- mColorAlpha = (color.a != 255);
- }
diff --git a/src/render/openglgraphicsdefadvanced.hpp b/src/render/openglgraphicsdefadvanced.hpp
deleted file mode 100644
index 4205b525f..000000000
--- a/src/render/openglgraphicsdefadvanced.hpp
+++ /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/>.
- */
-
-#define RENDER_OPENGLGRAPHICSDEFADVANCED_HPP
-
-public:
- inline void drawVertexes(const OpenGLGraphicsVertexes &restrict ogl)
- restrict2 A_INLINE;
-
- void initArrays(const int vertCount) restrict2 override final;
-
-#ifdef DEBUG_DRAW_CALLS
- unsigned int getDrawCalls() restrict2 const noexcept2
- { return mLastDrawCalls; }
-
- static unsigned int mDrawCalls;
-
- static unsigned int mLastDrawCalls;
-#endif
-
-protected:
- void debugBindTexture(const Image *restrict const image) restrict2;
-
- void deleteArraysInternal() restrict2;
diff --git a/src/render/openglx/mglx.cpp b/src/render/openglx/mglx.cpp
deleted file mode 100644
index a02c8e326..000000000
--- a/src/render/openglx/mglx.cpp
+++ /dev/null
@@ -1,34 +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/>.
- */
-
-#if defined(USE_OPENGL) && defined(USE_X11)
-
-#include "render/openglx/mglx.h"
-
-#include "debug.h"
-
-#define defName(name) name##_t m##name = nullptr
-
-// include function defines
-#include "render/openglx/mglx.hpp"
-
-MGLX_DEFINE
-
-#endif // defined(USE_OPENGL) && defined(USE_X11)
diff --git a/src/render/openglx/mglx.h b/src/render/openglx/mglx.h
deleted file mode 100644
index 3f591f26f..000000000
--- a/src/render/openglx/mglx.h
+++ /dev/null
@@ -1,35 +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 RENDER_OPENGLX_MGLX_H
-#define RENDER_OPENGLX_MGLX_H
-
-#if defined(USE_OPENGL) && defined(USE_X11)
-
-#include "render/openglx/mglxtypes.h"
-
-#define defName(name) extern name##_t m##name
-#include "render/openglx/mglx.hpp"
-MGLX_DEFINE
-#undef defName
-#undef MGLX_DEFINE
-
-#endif // defined(USE_OPENGL) && defined(USE_X11)
-#endif // RENDER_OPENGLX_MGLX_H
diff --git a/src/render/openglx/mglx.hpp b/src/render/openglx/mglx.hpp
deleted file mode 100644
index 0e3e2b9ac..000000000
--- a/src/render/openglx/mglx.hpp
+++ /dev/null
@@ -1,29 +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/>.
- */
-
-#define MGLX_DEFINE
-
-defName(glXCreateContext);
-defName(glXGetCurrentContext);
-defName(glXCreateContextAttribs);
-defName(glXChooseFBConfig);
-defName(glXDestroyContext);
-defName(glXMakeCurrent);
-defName(glXSwapBuffers);
diff --git a/src/render/openglx/mglxinit.cpp b/src/render/openglx/mglxinit.cpp
deleted file mode 100644
index 10eb93567..000000000
--- a/src/render/openglx/mglxinit.cpp
+++ /dev/null
@@ -1,42 +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/>.
- */
-
-#if defined(USE_OPENGL) && defined(USE_X11)
-
-#include "render/openglx/mglxinit.h"
-
-#include "render/opengl/mglfunctions.h"
-
-#include "render/openglx/mglx.h"
-
-#include "debug.h"
-
-void Glx::initFunctions()
-{
- assignFunction(glXCreateContext);
- assignFunction(glXGetCurrentContext);
- assignFunctionARB(glXCreateContextAttribs);
- assignFunction(glXChooseFBConfig);
- assignFunction(glXDestroyContext);
- assignFunction(glXMakeCurrent);
- assignFunction(glXSwapBuffers);
-}
-
-#endif // defined(USE_OPENGL) && defined(USE_X11)
diff --git a/src/render/openglx/mglxinit.h b/src/render/openglx/mglxinit.h
deleted file mode 100644
index 96704821e..000000000
--- a/src/render/openglx/mglxinit.h
+++ /dev/null
@@ -1,32 +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 RENDER_OPENGLX_MGLXINIT_H
-#define RENDER_OPENGLX_MGLXINIT_H
-
-#if defined(USE_OPENGL) && defined(USE_X11)
-
-namespace Glx
-{
- void initFunctions();
-} // namespace Glx
-
-#endif // defined(USE_OPENGL) && defined(USE_X11)
-#endif // RENDER_OPENGLX_MGLXINIT_H
diff --git a/src/render/openglx/mglxtypes.h b/src/render/openglx/mglxtypes.h
deleted file mode 100644
index b9aa0a55d..000000000
--- a/src/render/openglx/mglxtypes.h
+++ /dev/null
@@ -1,41 +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 RENDER_OPENGLX_MGLXTYPES_H
-#define RENDER_OPENGLX_MGLXTYPES_H
-
-#if defined(USE_OPENGL) && defined(USE_X11)
-
-#include <GL/glx.h>
-
-typedef void *(*glXCreateContext_t) (Display *dpy, XVisualInfo *vis,
- void *shareList, bool direct);
-typedef void *(*glXGetCurrentContext_t) (void);
-typedef void *(*glXCreateContextAttribs_t) (Display *dpy, GLXFBConfig config,
- void *share_context, bool direct, const int *attrib_list);
-typedef GLXFBConfig *(*glXChooseFBConfig_t) (Display *dpy, int screen,
- const int *attrib_list, int *nelements);
-typedef void (*glXDestroyContext_t) (Display *dpy, void *ctx);
-typedef bool (*glXMakeCurrent_t) (Display *dpy,
- GLXDrawable drawable, void *ctx);
-typedef void (*glXSwapBuffers_t) (Display *dpy, GLXDrawable drawable);
-
-#endif // USE_OPENGL
-#endif // RENDER_OPENGLX_MGLXTYPES_H
diff --git a/src/render/renderers.cpp b/src/render/renderers.cpp
deleted file mode 100644
index 0f8baf6e4..000000000
--- a/src/render/renderers.cpp
+++ /dev/null
@@ -1,117 +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 "render/renderers.h"
-
-#include "debug.h"
-
-static RenderType getDefault() noexcept2 A_CONST;
-
-static RenderType getDefault() noexcept2
-{
-#ifdef USE_OPENGL
-#ifdef ANDROID
- return RENDER_GLES_OPENGL;
-#else // ANDROID
-
- return RENDER_NORMAL_OPENGL;
-#endif // ANDROID
-#else // USE_OPENGL
-
- return RENDER_SOFTWARE;
-#endif // USE_OPENGL
-}
-
-RenderType intToRenderType(const int mode) noexcept2
-{
- if (mode < 0 || mode >= RENDER_LAST)
- return getDefault();
-
- if (mode != RENDER_SOFTWARE
-#if defined(USE_OPENGL)
-
-// with OpenGL start
-#if defined(ANDROID)
-
-// with OpenGL + with ANDROID start
-#if defined(USE_SDL2)
- && mode != RENDER_GLES_OPENGL
- && mode != RENDER_SDL2_DEFAULT)
-#else // defined(USE_SDL2)
-
- && mode != RENDER_GLES_OPENGL)
-#endif // defined(USE_SDL2)
-// with OpenGL + with ANDROID end
-
-#elif defined(__native_client__)
-
-// with OpenGL + with nacl start
-#if defined(USE_SDL2)
- && mode != RENDER_SAFE_OPENGL
- && mode != RENDER_GLES2_OPENGL
- && mode != RENDER_SDL2_DEFAULT)
-#else // defined(USE_SDL2)
-
- && mode != RENDER_SAFE_OPENGL
- && mode != RENDER_GLES2_OPENGL)
-#endif // defined(USE_SDL2)
-// with OpenGL + with nacl end
-
-#else // defined(ANDROID)
-
-// with OpenGL + without ANDROID start
-#if defined(USE_SDL2)
- && mode != RENDER_NORMAL_OPENGL
- && mode != RENDER_MODERN_OPENGL
- && mode != RENDER_SAFE_OPENGL
- && mode != RENDER_GLES_OPENGL
- && mode != RENDER_GLES2_OPENGL
- && mode != RENDER_SDL2_DEFAULT)
-#else // defined(USE_SDL2)
-
- && mode != RENDER_NORMAL_OPENGL
- && mode != RENDER_MODERN_OPENGL
- && mode != RENDER_SAFE_OPENGL
- && mode != RENDER_GLES_OPENGL
- && mode != RENDER_GLES2_OPENGL)
-#endif // defined(USE_SDL2)
-// with OpenGL + without ANDROID end
-
-#endif // defined(ANDROID)
-// with OpenGL end
-
-#else // defined(USE_OPENGL)
-
-// without OpenGL start
-#if defined(USE_SDL2)
- && mode != RENDER_SDL2_DEFAULT)
-#elif !defined(USE_SDL2)
- )
-#endif // defined(USE_SDL2)
-// without OpenGL end
-
-#endif // defined(USE_OPENGL)
-
- {
- return getDefault();
- }
-
- return static_cast<RenderType>(mode);
-}
diff --git a/src/render/renderers.h b/src/render/renderers.h
deleted file mode 100644
index f2f5d3928..000000000
--- a/src/render/renderers.h
+++ /dev/null
@@ -1,32 +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 RENDER_RENDERERS_H
-#define RENDER_RENDERERS_H
-
-#include "enums/render/rendertype.h"
-
-#include "localconsts.h"
-
-RenderType intToRenderType(const int mode) noexcept2 A_CONST;
-
-#define isBatchDrawRenders(val) ((val) != RENDER_SAFE_OPENGL)
-
-#endif // RENDER_RENDERERS_H
diff --git a/src/render/rendererslistsdl.h b/src/render/rendererslistsdl.h
deleted file mode 100644
index 8fc833247..000000000
--- a/src/render/rendererslistsdl.h
+++ /dev/null
@@ -1,176 +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 RENDER_RENDERERSLISTSDL_H
-#define RENDER_RENDERERSLISTSDL_H
-
-#ifdef USE_SDL2
-#include "render/rendererslistsdl2.h"
-RENDER_RENDERERSLISTSDL2_H
-
-#else // USE_SDL2
-
-#include "utils/gettext.h"
-
-#include "render/renderers.h"
-
-#ifdef USE_OPENGL
-#ifdef ANDROID
-// defined OPENGL ANDROID
-
-// map for index to RenderType
-const RenderType indexToRender[] =
-{
- RENDER_SOFTWARE,
- RENDER_GLES_OPENGL
-};
-
-const char *OPENGL_NAME[] =
-{
- // TRANSLATORS: draw backend
- N_("Software"),
- // TRANSLATORS: draw backend
- N_("Mobile OpenGL ES")
-};
-
-const int renderModesListSize = 2;
-
-const int renderToIndex[] =
-{
- 0, // RENDER_SOFTWARE
- 1, // RENDER_NORMAL_OPENGL
- 1, // RENDER_SAFE_OPENGL
- 1, // RENDER_GLES_OPENGL
- 1, // RENDER_SDL2_DEFAULT
- 1, // RENDER_MODERN_OPENGL
- 1 // RENDER_GLES2_OPENGL
-};
-
-#elif defined(__native_client__)
-// defined OPENGL nacl
-
-// map for index to RenderType
-const RenderType indexToRender[] =
-{
- RENDER_SOFTWARE,
- RENDER_SAFE_OPENGL,
- RENDER_GLES2_OPENGL
-};
-
-const char *OPENGL_NAME[] =
-{
- // TRANSLATORS: draw backend
- N_("Software"),
- // TRANSLATORS: draw backend
- N_("Safe OpenGL"),
- // TRANSLATORS: draw backend
- N_("Mobile OpenGL ES 2"),
-};
-
-const int renderModesListSize = 3;
-
-const int renderToIndex[] =
-{
- 0, // RENDER_SOFTWARE
- 2, // RENDER_NORMAL_OPENGL
- 1, // RENDER_SAFE_OPENGL
- 2, // RENDER_GLES_OPENGL
- 0, // RENDER_SDL2_DEFAULT
- 2, // RENDER_MODERN_OPENGL
- 2 // RENDER_GLES2_OPENGL
-};
-
-#else // ANDROID or nacl
-// defined OPENGL
-
-// map for index to RenderType
-const RenderType indexToRender[] =
-{
- RENDER_SOFTWARE,
- RENDER_NORMAL_OPENGL,
- RENDER_SAFE_OPENGL,
- RENDER_GLES_OPENGL,
- RENDER_MODERN_OPENGL,
- RENDER_GLES2_OPENGL
-};
-
-const char *OPENGL_NAME[] =
-{
- // TRANSLATORS: draw backend
- N_("Software"),
- // TRANSLATORS: draw backend
- N_("Normal OpenGL"),
- // TRANSLATORS: draw backend
- N_("Safe OpenGL"),
- // TRANSLATORS: draw backend
- N_("Mobile OpenGL ES"),
- // TRANSLATORS: draw backend
- N_("Modern OpenGL"),
- // TRANSLATORS: draw backend
- N_("Mobile OpenGL ES 2"),
-};
-
-const int renderModesListSize = 6;
-
-const int renderToIndex[] =
-{
- 0, // RENDER_SOFTWARE
- 1, // RENDER_NORMAL_OPENGL
- 2, // RENDER_SAFE_OPENGL
- 3, // RENDER_GLES_OPENGL
- 0, // RENDER_SDL2_DEFAULT
- 4, // RENDER_MODERN_OPENGL
- 5 // RENDER_GLES2_OPENGL
-};
-
-#endif // ANDROID
-
-#else // USE_OPENGL
-// no defines
-
-// map for index to RenderType
-const RenderType indexToRender[] =
-{
- RENDER_SOFTWARE
-};
-
-const char *OPENGL_NAME[] =
-{
- // TRANSLATORS: draw backend
- N_("Software")
-};
-
-const int renderModesListSize = 1;
-
-const int renderToIndex[] =
-{
- 0, // RENDER_SOFTWARE
- 0, // RENDER_NORMAL_OPENGL
- 0, // RENDER_SAFE_OPENGL
- 0, // RENDER_GLES_OPENGL
- 0, // RENDER_SDL2_DEFAULT
- 0, // RENDER_MODERN_OPENGL
- 0 // RENDER_GLES2_OPENGL
-};
-
-#endif // USE_OPENGL
-
-#endif // USE_SDL2
-#endif // RENDER_RENDERERSLISTSDL_H
diff --git a/src/render/rendererslistsdl2.h b/src/render/rendererslistsdl2.h
deleted file mode 100644
index 22a975cfa..000000000
--- a/src/render/rendererslistsdl2.h
+++ /dev/null
@@ -1,184 +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 RENDER_RENDERERSLISTSDL2_H
-#define RENDER_RENDERERSLISTSDL2_H
-
-#ifdef USE_SDL2
-
-#include "utils/gettext.h"
-
-#include "render/renderers.h"
-
-#ifdef USE_OPENGL
-#ifdef ANDROID
-// defined OPENGL ANDROID
-
-// map for index to RenderType
-const RenderType indexToRender[] =
-{
- RENDER_SOFTWARE,
- RENDER_SDL2_DEFAULT,
- RENDER_GLES_OPENGL
-};
-
-const char *OPENGL_NAME[] =
-{
- // TRANSLATORS: draw backend
- N_("Software"),
- // TRANSLATORS: draw backend
- N_("SDL2 default"),
- // TRANSLATORS: draw backend
- N_("Mobile OpenGL ES")
-};
-
-const int renderModesListSize = 3;
-
-const int renderToIndex[] =
-{
- 0, // RENDER_SOFTWARE
- 2, // RENDER_NORMAL_OPENGL
- 2, // RENDER_SAFE_OPENGL
- 2, // RENDER_GLES_OPENGL
- 1, // RENDER_SDL2_DEFAULT
- 2, // RENDER_MODERN_OPENGL
- 2 // RENDER_GLES_OPENGL
-};
-
-#elif defined(__native_client__)
-// defined OPENGL nacl
-
-// map for index to RenderType
-const RenderType indexToRender[] =
-{
- RENDER_SOFTWARE,
- RENDER_SDL2_DEFAULT,
- RENDER_SAFE_OPENGL,
- RENDER_GLES2_OPENGL
-};
-
-const char *OPENGL_NAME[] =
-{
- // TRANSLATORS: draw backend
- N_("Software"),
- // TRANSLATORS: draw backend
- N_("SDL2 default"),
- // TRANSLATORS: draw backend
- N_("Safe OpenGL"),
- // TRANSLATORS: draw backend
- N_("Mobile OpenGL ES 2")
-};
-
-const int renderModesListSize = 4;
-
-const int renderToIndex[] =
-{
- 0, // RENDER_SOFTWARE
- 3, // RENDER_NORMAL_OPENGL
- 2, // RENDER_SAFE_OPENGL
- 3, // RENDER_GLES_OPENGL
- 1, // RENDER_SDL2_DEFAULT
- 3, // RENDER_MODERN_OPENGL
- 3 // RENDER_GLES2_OPENGL
-};
-
-#else // ANDROID or nacl
-// defined OPENGL
-
-// map for index to RenderType
-const RenderType indexToRender[] =
-{
- RENDER_SOFTWARE,
- RENDER_SDL2_DEFAULT,
- RENDER_NORMAL_OPENGL,
- RENDER_SAFE_OPENGL,
- RENDER_GLES_OPENGL,
- RENDER_MODERN_OPENGL,
- RENDER_GLES2_OPENGL
-};
-
-const char *OPENGL_NAME[] =
-{
- // TRANSLATORS: draw backend
- N_("Software"),
- // TRANSLATORS: draw backend
- N_("SDL2 default"),
- // TRANSLATORS: draw backend
- N_("Normal OpenGL"),
- // TRANSLATORS: draw backend
- N_("Safe OpenGL"),
- // TRANSLATORS: draw backend
- N_("Mobile OpenGL ES"),
- // TRANSLATORS: draw backend
- N_("Modern OpenGL"),
- // TRANSLATORS: draw backend
- N_("Mobile OpenGL ES 2")
-};
-
-const int renderModesListSize = 7;
-
-const int renderToIndex[] =
-{
- 0, // RENDER_SOFTWARE
- 2, // RENDER_NORMAL_OPENGL
- 3, // RENDER_SAFE_OPENGL
- 4, // RENDER_GLES_OPENGL
- 1, // RENDER_SDL2_DEFAULT
- 5, // RENDER_MODERN_OPENGL
- 6 // RENDER_GLES2_OPENGL
-};
-
-#endif // ANDROID
-
-#else // USE_OPENGL
-// no defines
-
-// map for index to RenderType
-const RenderType indexToRender[] =
-{
- RENDER_SOFTWARE,
- RENDER_SDL2_DEFAULT
-};
-
-const char *OPENGL_NAME[] =
-{
- // TRANSLATORS: draw backend
- N_("Software"),
- // TRANSLATORS: draw backend
- N_("SDL2 default")
-};
-
-const int renderModesListSize = 2;
-
-const int renderToIndex[] =
-{
- 0, // RENDER_SOFTWARE
- 0, // RENDER_NORMAL_OPENGL
- 0, // RENDER_SAFE_OPENGL
- 0, // RENDER_GLES_OPENGL
- 1, // RENDER_SDL2_DEFAULT
- 0, // RENDER_MODERN_OPENGL
- 0 // RENDER_GLES2_OPENGL
-};
-
-#endif // USE_OPENGL
-
-#endif // USE_SDL2
-#endif // RENDER_RENDERERSLISTSDL2_H
diff --git a/src/render/safeopenglgraphics.cpp b/src/render/safeopenglgraphics.cpp
deleted file mode 100644
index e65ff94b0..000000000
--- a/src/render/safeopenglgraphics.cpp
+++ /dev/null
@@ -1,763 +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 "render/safeopenglgraphics.h"
-
-#ifdef DEBUG_OPENGL
-#include "render/opengl/mgl.h"
-#endif // DEBUG_OPENGL
-
-#include "resources/imagerect.h"
-#include "resources/safeopenglimagehelper.h"
-
-#include "resources/image/image.h"
-
-#include "utils/sdlcheckutils.h"
-
-#include "debug.h"
-
-GLuint SafeOpenGLGraphics::mTextureBinded = 0;
-
-SafeOpenGLGraphics::SafeOpenGLGraphics() :
- mTexture(false),
- mIsByteColor(false),
- mByteColor(),
- mFloatColor(1.0F),
- mColorAlpha(false),
- mFbo()
-{
- mOpenGL = RENDER_SAFE_OPENGL;
- mName = "safe OpenGL";
-}
-
-SafeOpenGLGraphics::~SafeOpenGLGraphics()
-{
-}
-
-void SafeOpenGLGraphics::deleteArrays() restrict2
-{
-}
-
-bool SafeOpenGLGraphics::setVideoMode(const int w, const int h,
- const int scale,
- const int bpp,
- const bool fs,
- const bool hwaccel,
- const bool resize,
- const bool noFrame,
- const bool allowHighDPI) restrict2
-{
- setMainFlags(w, h,
- scale,
- bpp,
- fs,
- hwaccel,
- resize,
- noFrame,
- allowHighDPI);
-
- return setOpenGLMode();
-}
-
-static inline void drawQuad(const Image *restrict image,
- const int srcX,
- const int srcY,
- const int dstX,
- const int dstY,
- const int width,
- const int height) A_NONNULL(1) A_INLINE;
-
-static inline void drawQuad(const Image *restrict image,
- const int srcX,
- const int srcY,
- const int dstX,
- const int dstY,
- const int width,
- const int height)
-{
- if (SafeOpenGLImageHelper::mTextureType == GL_TEXTURE_2D)
- {
- const float tw = static_cast<float>(image->mTexWidth);
- const float th = static_cast<float>(image->mTexHeight);
- // Find OpenGL normalized texture coordinates.
- const float texX1 = static_cast<float>(srcX) / tw;
- const float texY1 = static_cast<float>(srcY) / th;
- const float texX2 = static_cast<float>(srcX + width) / tw;
- const float texY2 = static_cast<float>(srcY + height) / th;
-
- glTexCoord2f(texX1, texY1);
- glVertex2i(dstX, dstY);
- glTexCoord2f(texX2, texY1);
- glVertex2i(dstX + width, dstY);
- glTexCoord2f(texX2, texY2);
- glVertex2i(dstX + width, dstY + height);
- glTexCoord2f(texX1, texY2);
- glVertex2i(dstX, dstY + height);
- }
- else
- {
- glTexCoord2i(srcX, srcY);
- glVertex2i(dstX, dstY);
- glTexCoord2i(srcX + width, srcY);
- glVertex2i(dstX + width, dstY);
- glTexCoord2i(srcX + width, srcY + height);
- glVertex2i(dstX + width, dstY + height);
- glTexCoord2i(srcX, srcY + height);
- glVertex2i(dstX, dstY + height);
- }
-}
-
-static inline void drawRescaledQuad(const Image *restrict const image,
- const int srcX, const int srcY,
- const int dstX, const int dstY,
- const int width, const int height,
- const int desiredWidth,
- const int desiredHeight)
- A_NONNULL(1) A_INLINE;
-
-static inline void drawRescaledQuad(const Image *restrict const image,
- const int srcX, const int srcY,
- const int dstX, const int dstY,
- const int width, const int height,
- const int desiredWidth,
- const int desiredHeight)
-{
- if (SafeOpenGLImageHelper::mTextureType == GL_TEXTURE_2D)
- {
- const float tw = static_cast<float>(image->mTexWidth);
- const float th = static_cast<float>(image->mTexHeight);
- // Find OpenGL normalized texture coordinates.
- const float texX1 = static_cast<float>(srcX) / tw;
- const float texY1 = static_cast<float>(srcY) / th;
- const float texX2 = static_cast<float>(srcX + width) / tw;
- const float texY2 = static_cast<float>(srcY + height) / th;
-
- glTexCoord2f(texX1, texY1);
- glVertex2i(dstX, dstY);
- glTexCoord2f(texX2, texY1);
- glVertex2i(dstX + desiredWidth, dstY);
- glTexCoord2f(texX2, texY2);
- glVertex2i(dstX + desiredWidth, dstY + desiredHeight);
- glTexCoord2f(texX1, texY2);
- glVertex2i(dstX, dstY + desiredHeight);
- }
- else
- {
- glTexCoord2i(srcX, srcY);
- glVertex2i(dstX, dstY);
- glTexCoord2i(srcX + width, srcY);
- glVertex2i(dstX + desiredWidth, dstY);
- glTexCoord2i(srcX + width, srcY + height);
- glVertex2i(dstX + desiredWidth, dstY + desiredHeight);
- glTexCoord2i(srcX, srcY + height);
- glVertex2i(dstX, dstY + desiredHeight);
- }
-}
-
-void SafeOpenGLGraphics::drawImage(const Image *restrict const image,
- int dstX, int dstY) restrict2
-{
- drawImageInline(image, dstX, dstY);
-}
-
-void SafeOpenGLGraphics::drawImageInline(const Image *restrict const image,
- int dstX, int dstY) restrict2
-{
- FUNC_BLOCK("Graphics::drawImage", 1)
- if (image == nullptr)
- return;
-
- setColorAlpha(image->mAlpha);
- bindTexture(SafeOpenGLImageHelper::mTextureType, image->mGLImage);
- enableTexturingAndBlending();
-
- const SDL_Rect &bounds = image->mBounds;
- // Draw a textured quad.
- glBegin(GL_QUADS);
- drawQuad(image, bounds.x, bounds.y,
- dstX, dstY, bounds.w, bounds.h);
- glEnd();
-}
-
-void SafeOpenGLGraphics::copyImage(const Image *restrict const image,
- int dstX, int dstY) restrict2
-{
- drawImageInline(image, dstX, dstY);
-}
-
-void SafeOpenGLGraphics::testDraw() restrict2
-{
- if (SafeOpenGLImageHelper::mTextureType == GL_TEXTURE_2D)
- {
- glBegin(GL_QUADS);
- glTexCoord2f(0.0f, 0.781250f);
- glVertex2i(0, 0);
- glTexCoord2f(0.0f, 0.781250f);
- glVertex2i(800, 0);
- glTexCoord2f(0.0f, 0.585938f);
- glVertex2i(800, 600);
- glTexCoord2f(0.0f, 0.585938f);
- glVertex2i(0, 600);
- glEnd();
- }
- else
- {
- glBegin(GL_QUADS);
- glTexCoord2i(0, 0);
- glVertex2i(0, 0);
- glTexCoord2i(800, 0);
- glVertex2i(800, 0);
- glTexCoord2i(800, 600);
- glVertex2i(800, 600);
- glTexCoord2i(0, 600);
- glVertex2i(0, 600);
- glEnd();
- }
-}
-
-void SafeOpenGLGraphics::drawImageCached(const Image *restrict const image,
- int x, int y) restrict2
-{
- FUNC_BLOCK("Graphics::drawImageCached", 1)
- if (image == nullptr)
- return;
-
- setColorAlpha(image->mAlpha);
- bindTexture(SafeOpenGLImageHelper::mTextureType, image->mGLImage);
- enableTexturingAndBlending();
-
- const SDL_Rect &bounds = image->mBounds;
- // Draw a textured quad.
- glBegin(GL_QUADS);
- drawQuad(image, bounds.x, bounds.y, x, y, bounds.w, bounds.h);
- glEnd();
-}
-
-void SafeOpenGLGraphics::drawPatternCached(const Image *restrict const image,
- const int x, const int y,
- const int w, const int h) restrict2
-{
- FUNC_BLOCK("Graphics::drawPatternCached", 1)
- if (image == nullptr)
- return;
-
- const SDL_Rect &imageRect = image->mBounds;
- const int iw = imageRect.w;
- const int ih = imageRect.h;
- if (iw == 0 || ih == 0)
- return;
-
- const int srcX = imageRect.x;
- const int srcY = imageRect.y;
-
- setColorAlpha(image->mAlpha);
- bindTexture(SafeOpenGLImageHelper::mTextureType, image->mGLImage);
- enableTexturingAndBlending();
-
- // Draw a set of textured rectangles
- glBegin(GL_QUADS);
-
- for (int py = 0; py < h; py += ih)
- {
- const int height = (py + ih >= h) ? h - py : ih;
- const int dstY = y + py;
- for (int px = 0; px < w; px += iw)
- {
- int width = (px + iw >= w) ? w - px : iw;
- int dstX = x + px;
- drawQuad(image, srcX, srcY, dstX, dstY, width, height);
- }
- }
-
- glEnd();
-}
-
-void SafeOpenGLGraphics::completeCache() restrict2
-{
-}
-
-void SafeOpenGLGraphics::drawRescaledImage(const Image *restrict const image,
- int dstX, int dstY,
- const int desiredWidth,
- const int desiredHeight) restrict2
-{
- FUNC_BLOCK("Graphics::drawRescaledImage", 1)
- if (image == nullptr)
- return;
-
- const SDL_Rect &imageRect = image->mBounds;
-
- // Just draw the image normally when no resizing is necessary,
- if (imageRect.w == desiredWidth && imageRect.h == desiredHeight)
- {
- drawImageInline(image, dstX, dstY);
- return;
- }
-
- setColorAlpha(image->mAlpha);
- bindTexture(SafeOpenGLImageHelper::mTextureType, image->mGLImage);
- enableTexturingAndBlending();
-
- // Draw a textured quad.
- glBegin(GL_QUADS);
- drawRescaledQuad(image, imageRect.x, imageRect.y, dstX, dstY,
- imageRect.w, imageRect.h, desiredWidth, desiredHeight);
- glEnd();
-}
-
-void SafeOpenGLGraphics::drawPattern(const Image *restrict const image,
- const int x, const int y,
- const int w, const int h) restrict2
-{
- drawPatternInline(image, x, y, w, h);
-}
-
-void SafeOpenGLGraphics::drawPatternInline(const Image *restrict const image,
- const int x, const int y,
- const int w, const int h) restrict2
-{
- FUNC_BLOCK("Graphics::drawPattern", 1)
- if (image == nullptr)
- return;
-
- const SDL_Rect &imageRect = image->mBounds;
- const int iw = imageRect.w;
- const int ih = imageRect.h;
- if (iw == 0 || ih == 0)
- return;
-
- const int srcX = imageRect.x;
- const int srcY = imageRect.y;
-
- setColorAlpha(image->mAlpha);
- bindTexture(SafeOpenGLImageHelper::mTextureType, image->mGLImage);
- enableTexturingAndBlending();
-
- // Draw a set of textured rectangles
- glBegin(GL_QUADS);
-
- for (int py = 0; py < h; py += ih)
- {
- const int height = (py + ih >= h) ? h - py : ih;
- const int dstY = y + py;
- for (int px = 0; px < w; px += iw)
- {
- int width = (px + iw >= w) ? w - px : iw;
- int dstX = x + px;
- drawQuad(image, srcX, srcY, dstX, dstY, width, height);
- }
- }
-
- glEnd();
-}
-
-void SafeOpenGLGraphics::drawRescaledPattern(const Image *restrict const image,
- const int x, const int y,
- const int w, const int h,
- const int scaledWidth,
- const int scaledHeight) restrict2
-{
- if (image == nullptr)
- return;
-
- const int iw = scaledWidth;
- const int ih = scaledHeight;
- if (iw == 0 || ih == 0)
- return;
-
- const SDL_Rect &imageRect = image->mBounds;
- const int srcX = imageRect.x;
- const int srcY = imageRect.y;
-
- setColorAlpha(image->mAlpha);
- bindTexture(SafeOpenGLImageHelper::mTextureType, image->mGLImage);
- enableTexturingAndBlending();
-
- // Draw a set of textured rectangles
- glBegin(GL_QUADS);
-
- const float scaleFactorW = static_cast<float>(scaledWidth)
- / image->getWidth();
- const float scaleFactorH = static_cast<float>(scaledHeight)
- / image->getHeight();
-
- for (int py = 0; py < h; py += ih)
- {
- const int height = (py + ih >= h) ? h - py : ih;
- const int dstY = y + py;
- for (int px = 0; px < w; px += iw)
- {
- int width = (px + iw >= w) ? w - px : iw;
- int dstX = x + px;
-
- drawRescaledQuad(image, srcX, srcY, dstX, dstY,
- width / scaleFactorW, height / scaleFactorH,
- scaledWidth, scaledHeight);
- }
- }
-
- glEnd();
-}
-
-void SafeOpenGLGraphics::calcTileCollection(ImageCollection *restrict const
- vertCol A_UNUSED,
- const Image *restrict const image
- A_UNUSED,
- int x A_UNUSED,
- int y A_UNUSED) restrict2
-{
-}
-
-void SafeOpenGLGraphics::calcTileVertexes(ImageVertexes *restrict const vert
- A_UNUSED,
- const Image *restrict const image
- A_UNUSED,
- int x A_UNUSED,
- int y A_UNUSED) const restrict2
-{
-}
-
-void SafeOpenGLGraphics::calcTileVertexesInline(ImageVertexes *restrict const
- vert A_UNUSED,
- const Image *restrict const
- image A_UNUSED,
- int x A_UNUSED,
- int y A_UNUSED) const restrict2
-{
-}
-
-void SafeOpenGLGraphics::calcPattern(ImageVertexes *restrict const vert
- A_UNUSED,
- const Image *restrict const image
- A_UNUSED,
- const int x A_UNUSED,
- const int y A_UNUSED,
- const int w A_UNUSED,
- const int h A_UNUSED) const restrict2
-{
-}
-
-void SafeOpenGLGraphics::calcPatternInline(ImageVertexes *restrict const vert
- A_UNUSED,
- const Image *restrict const image
- A_UNUSED,
- const int x A_UNUSED,
- const int y A_UNUSED,
- const int w A_UNUSED,
- const int h A_UNUSED)
- const restrict2
-{
-}
-
-void SafeOpenGLGraphics::calcPattern(ImageCollection *restrict const vert
- A_UNUSED,
- const Image *restrict const image
- A_UNUSED,
- const int x A_UNUSED,
- const int y A_UNUSED,
- const int w A_UNUSED,
- const int h A_UNUSED) const restrict2
-{
-}
-
-void SafeOpenGLGraphics::drawTileVertexes(const ImageVertexes
- *restrict const vert A_UNUSED)
- restrict2
-{
-}
-
-void SafeOpenGLGraphics::drawTileCollection(const ImageCollection *
- restrict const vertCol A_UNUSED)
- restrict2
-{
-}
-
-void SafeOpenGLGraphics::updateScreen() restrict2
-{
- BLOCK_START("Graphics::updateScreen")
- glFlush();
- glFinish();
-#ifdef USE_SDL2
- SDL_GL_SwapWindow(mWindow);
-#else
- SDL_GL_SwapBuffers();
-#endif // USE_SDL2
-#ifdef DEBUG_OPENGL
- if (isGLNotNull(mglFrameTerminator))
- mglFrameTerminator();
-#endif // DEBUG_OPENGL
-
- BLOCK_END("Graphics::updateScreen")
-}
-
-void SafeOpenGLGraphics::calcWindow(ImageCollection *restrict const vertCol
- A_UNUSED,
- const int x A_UNUSED, const int y A_UNUSED,
- const int w A_UNUSED, const int h A_UNUSED,
- const ImageRect &restrict imgRect A_UNUSED)
- restrict2
-{
-}
-
-void SafeOpenGLGraphics::beginDraw() restrict2
-{
- glMatrixMode(GL_TEXTURE);
- glLoadIdentity();
-
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
-
- glOrtho(0.0, static_cast<double>(mRect.w),
- static_cast<double>(mRect.h),
- 0.0, -1.0, 1.0);
-
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
-
- setOpenGLFlags();
- glDisable(GL_LIGHTING);
- glDisable(GL_FOG);
- glDisable(GL_COLOR_MATERIAL);
-
- glShadeModel(GL_FLAT);
-
- pushClipArea(Rect(0, 0, mRect.w, mRect.h));
-}
-
-void SafeOpenGLGraphics::endDraw() restrict2
-{
- popClipArea();
-}
-
-void SafeOpenGLGraphics::pushClipArea(const Rect &restrict area) restrict2
-{
- int transX = 0;
- int transY = 0;
-
- if (!mClipStack.empty())
- {
- const ClipRect &clipArea = mClipStack.top();
- transX = -clipArea.xOffset;
- transY = -clipArea.yOffset;
- }
-
- Graphics::pushClipArea(area);
-
- const ClipRect &clipArea = mClipStack.top();
-
- glPushMatrix();
- glTranslatef(static_cast<GLfloat>(transX + clipArea.xOffset),
- static_cast<GLfloat>(transY + clipArea.yOffset), 0);
- glScissor(clipArea.x * mScale,
- (mRect.h - clipArea.y - clipArea.height) * mScale,
- clipArea.width * mScale,
- clipArea.height * mScale);
-}
-
-void SafeOpenGLGraphics::popClipArea() restrict2
-{
- Graphics::popClipArea();
-
- if (mClipStack.empty())
- return;
-
- glPopMatrix();
- const ClipRect &clipArea = mClipStack.top();
- glScissor(clipArea.x * mScale,
- (mRect.h - clipArea.y - clipArea.height) * mScale,
- clipArea.width * mScale,
- clipArea.height * mScale);
-}
-
-void SafeOpenGLGraphics::drawPoint(int x, int y) restrict2
-{
- disableTexturingAndBlending();
- restoreColor();
-
- glBegin(GL_POINTS);
- glVertex2i(x, y);
- glEnd();
-}
-
-void SafeOpenGLGraphics::drawNet(const int x1, const int y1,
- const int x2, const int y2,
- const int width, const int height) restrict2
-{
- disableTexturingAndBlending();
- restoreColor();
-
- glBegin(GL_LINES);
- for (int y = y1; y < y2; y += height)
- {
- glVertex2f(static_cast<float>(x1) + 0.5F,
- static_cast<float>(y) + 0.5F);
- glVertex2f(static_cast<float>(x2) + 0.5F,
- static_cast<float>(y) + 0.5F);
- }
-
- for (int x = x1; x < x2; x += width)
- {
- glVertex2f(static_cast<float>(x) + 0.5F,
- static_cast<float>(y1) + 0.5F);
- glVertex2f(static_cast<float>(x) + 0.5F,
- static_cast<float>(y2) + 0.5F);
- }
- glEnd();
-}
-
-void SafeOpenGLGraphics::drawLine(int x1, int y1,
- int x2, int y2) restrict2
-{
- disableTexturingAndBlending();
- restoreColor();
-
- glBegin(GL_LINES);
- glVertex2f(static_cast<float>(x1) + 0.5F, static_cast<float>(y1) + 0.5F);
- glVertex2f(static_cast<float>(x2) + 0.5F, static_cast<float>(y2) + 0.5F);
- glEnd();
-}
-
-void SafeOpenGLGraphics::drawRectangle(const Rect &restrict rect) restrict2
-{
- drawRectangle(rect, false);
-}
-
-void SafeOpenGLGraphics::fillRectangle(const Rect &restrict rect) restrict2
-{
- drawRectangle(rect, true);
-}
-
-void SafeOpenGLGraphics::enableTexturingAndBlending() restrict2
-{
- if (!mTexture)
- {
- glEnable(SafeOpenGLImageHelper::mTextureType);
- mTexture = true;
- }
-
- if (!mAlpha)
- {
- glEnable(GL_BLEND);
- mAlpha = true;
- }
-}
-
-void SafeOpenGLGraphics::disableTexturingAndBlending() restrict2
-{
- mTextureBinded = 0;
- if (mAlpha && !mColorAlpha)
- {
- glDisable(GL_BLEND);
- mAlpha = false;
- }
- else if (!mAlpha && mColorAlpha)
- {
- glEnable(GL_BLEND);
- mAlpha = true;
- }
-
- if (mTexture)
- {
- glDisable(SafeOpenGLImageHelper::mTextureType);
- mTexture = false;
- }
-}
-
-void SafeOpenGLGraphics::drawRectangle(const Rect &restrict rect,
- const bool filled) restrict2
-{
- BLOCK_START("Graphics::drawRectangle")
- const float offset = filled ? 0 : 0.5F;
-
- disableTexturingAndBlending();
- restoreColor();
-
- glBegin(filled ? GL_QUADS : GL_LINE_LOOP);
- glVertex2f(static_cast<float>(rect.x) + offset,
- static_cast<float>(rect.y) + offset);
- glVertex2f(static_cast<float>(rect.x + rect.width) - offset,
- static_cast<float>(rect.y) + offset);
- glVertex2f(static_cast<float>(rect.x + rect.width) - offset,
- static_cast<float>(rect.y + rect.height) - offset);
- glVertex2f(static_cast<float>(rect.x) + offset,
- static_cast<float>(rect.y + rect.height) - offset);
- glEnd();
- BLOCK_END("Graphics::drawRectangle")
-}
-
-void SafeOpenGLGraphics::bindTexture(const GLenum target,
- const GLuint texture)
-{
- if (mTextureBinded != texture)
- {
- mTextureBinded = texture;
- glBindTexture(target, texture);
- }
-}
-
-void SafeOpenGLGraphics::setColorAlpha(const float alpha) restrict2
-{
- if (!mIsByteColor && mFloatColor == alpha)
- return;
-
- glColor4f(1.0F, 1.0F, 1.0F, alpha);
- mIsByteColor = false;
- mFloatColor = alpha;
-}
-
-void SafeOpenGLGraphics::restoreColor() restrict2
-{
- if (mIsByteColor && mByteColor == mColor)
- return;
-
- glColor4ub(static_cast<GLubyte>(mColor.r),
- static_cast<GLubyte>(mColor.g),
- static_cast<GLubyte>(mColor.b),
- static_cast<GLubyte>(mColor.a));
- mIsByteColor = true;
- mByteColor = mColor;
-}
-
-void SafeOpenGLGraphics::clearScreen() const restrict2
-{
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
-}
-
-void SafeOpenGLGraphics::drawImageRect(const int x, const int y,
- const int w, const int h,
- const ImageRect &restrict imgRect)
- restrict2
-{
- #include "render/graphics_drawImageRect.hpp"
-}
-
-void SafeOpenGLGraphics::calcImageRect(ImageVertexes *restrict const vert,
- const int x, const int y,
- const int w, const int h,
- const ImageRect &restrict imgRect)
- restrict2
-{
- #include "render/graphics_calcImageRect.hpp"
-}
-
-#endif // USE_OPENGL
diff --git a/src/render/safeopenglgraphics.h b/src/render/safeopenglgraphics.h
deleted file mode 100644
index 5c85ee058..000000000
--- a/src/render/safeopenglgraphics.h
+++ /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/>.
- */
-
-#ifndef RENDER_SAFEOPENGLGRAPHICS_H
-#define RENDER_SAFEOPENGLGRAPHICS_H
-
-#if defined USE_OPENGL && !defined ANDROID
-
-#include "render/graphics.h"
-
-#include "resources/fboinfo.h"
-
-#ifdef ANDROID
-#include <GLES/gl.h>
-#include <GLES/glext.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)
-#if defined(__APPLE__)
-#include <OpenGL/glext.h>
-#elif !defined(__native_client__)
-#include <GL/glext.h>
-#endif // defined(__APPLE__)
-#endif // ANDROID
-
-class SafeOpenGLGraphics final : public Graphics
-{
- public:
- SafeOpenGLGraphics();
-
- A_DELETE_COPY(SafeOpenGLGraphics)
-
- ~SafeOpenGLGraphics();
-
- void testDraw() restrict2 override final;
-
- #include "render/graphicsdef.hpp"
- RENDER_GRAPHICSDEF_HPP
-
- #include "render/openglgraphicsdef.hpp"
- RENDER_OPENGLGRAPHICSDEF_HPP
-
- #include "render/openglgraphicsdef1.hpp"
- RENDER_OPENGLGRAPHICSDEF1_HPP
-
- private:
- bool mTexture;
- bool mIsByteColor;
- Color mByteColor;
- float mFloatColor;
- bool mColorAlpha;
- FBOInfo mFbo;
-};
-
-#endif // defined USE_OPENGL && !defined ANDROID
-#endif // RENDER_SAFEOPENGLGRAPHICS_H
diff --git a/src/render/sdl2graphics.cpp b/src/render/sdl2graphics.cpp
deleted file mode 100644
index baa69ca69..000000000
--- a/src/render/sdl2graphics.cpp
+++ /dev/null
@@ -1,789 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifdef USE_SDL2
-
-#include "render/sdl2graphics.h"
-
-#include "graphicsmanager.h"
-
-#include "render/vertexes/imagecollection.h"
-
-#include "resources/imagerect.h"
-#include "resources/sdl2imagehelper.h"
-
-#include "resources/image/image.h"
-
-#include "utils/sdlcheckutils.h"
-
-#include "debug.h"
-
-#ifdef DEBUG_SDL_SURFACES
-
-#define MSDL_RenderCopy(render, texture, src, dst) \
- FakeSDL_RenderCopy(render, texture, src, dst)
-
-static int FakeSDL_RenderCopy(SDL_Renderer *restrict const renderer,
- SDL_Texture *restrict const texture,
- const SDL_Rect *restrict const srcrect,
- const SDL_Rect *restrict const dstrect)
-{
- int ret = SDL_RenderCopy(renderer, texture, srcrect, dstrect);
- if (ret)
- {
- logger->log("rendering error in texture %p: %s",
- static_cast<void*>(texture), SDL_GetError());
- }
- return ret;
-}
-
-#else // DEBUG_SDL_SURFACES
-
-#define MSDL_RenderCopy(render, texture, src, dst) \
- SDL_RenderCopy(render, texture, src, dst)
-
-#endif // DEBUG_SDL_SURFACES
-
-#define setRenderDrawColor(mColor) \
- SDL_SetRenderDrawColor(mRenderer, \
- CAST_U8(mColor.r), \
- CAST_U8(mColor.g), \
- CAST_U8(mColor.b), \
- CAST_U8(mColor.a))
-
-#define defRectFromArea(rect, area) \
- const SDL_Rect rect = \
- { \
- CAST_S32(area.x), \
- CAST_S32(area.y), \
- CAST_S32(area.width), \
- CAST_S32(area.height) \
- }
-
-SDLGraphics::SDLGraphics() :
- Graphics(),
- mRendererFlags(SDL_RENDERER_SOFTWARE),
- mOldPixel(0),
- mOldAlpha(0)
-{
- mOpenGL = RENDER_SDL2_DEFAULT;
- mName = "SDL2 default";
-}
-
-SDLGraphics::~SDLGraphics()
-{
-}
-
-void SDLGraphics::drawRescaledImage(const Image *restrict const image,
- int dstX, int dstY,
- const int desiredWidth,
- const int desiredHeight) restrict2
-{
- FUNC_BLOCK("Graphics::drawRescaledImage", 1)
- // Check that preconditions for blitting are met.
- if (!mWindow || !image || !image->mTexture)
- return;
-
- const ClipRect &top = mClipStack.top();
- const SDL_Rect &bounds = image->mBounds;
- const SDL_Rect srcRect =
- {
- CAST_S32(bounds.x),
- CAST_S32(bounds.y),
- CAST_S32(bounds.w),
- CAST_S32(bounds.h)
- };
- const SDL_Rect dstRect =
- {
- CAST_S32(dstX + top.xOffset),
- CAST_S32(dstY + top.yOffset),
- CAST_S32(desiredWidth),
- CAST_S32(desiredHeight)
- };
-
- MSDL_RenderCopy(mRenderer, image->mTexture, &srcRect, &dstRect);
-}
-
-void SDLGraphics::drawImage(const Image *restrict const image,
- int dstX, int dstY) restrict2
-{
- drawImageInline(image, dstX, dstY);
-}
-
-void SDLGraphics::drawImageInline(const Image *restrict const image,
- int dstX, int dstY) restrict2
-{
- FUNC_BLOCK("Graphics::drawImage", 1)
- // Check that preconditions for blitting are met.
- if (!mWindow || !image || !image->mTexture)
- return;
-
- const ClipRect &top = mClipStack.top();
- if (!top.width || !top.height)
- return;
-
- const SDL_Rect &bounds = image->mBounds;
- const SDL_Rect srcRect =
- {
- CAST_S32(bounds.x),
- CAST_S32(bounds.y),
- CAST_S32(bounds.w),
- CAST_S32(bounds.h)
- };
-
- const SDL_Rect dstRect =
- {
- CAST_S32(dstX + top.xOffset),
- CAST_S32(dstY + top.yOffset),
- CAST_S32(bounds.w),
- CAST_S32(bounds.h)
- };
-
- MSDL_RenderCopy(mRenderer, image->mTexture, &srcRect, &dstRect);
-}
-
-void SDLGraphics::copyImage(const Image *restrict const image,
- int dstX, int dstY) restrict2
-{
- drawImageInline(image, dstX, dstY);
-}
-
-void SDLGraphics::drawImageCached(const Image *restrict const image,
- int x, int y) restrict2
-{
- FUNC_BLOCK("Graphics::drawImageCached", 1)
- // Check that preconditions for blitting are met.
- if (!mWindow || !image || !image->mTexture)
- return;
-
- const ClipRect &top = mClipStack.top();
- if (!top.width || !top.height)
- return;
-
- const SDL_Rect &bounds = image->mBounds;
- const SDL_Rect srcRect =
- {
- CAST_S32(bounds.x),
- CAST_S32(bounds.y),
- CAST_S32(bounds.w),
- CAST_S32(bounds.h)
- };
-
- const SDL_Rect dstRect =
- {
- CAST_S32(x + top.xOffset),
- CAST_S32(y + top.yOffset),
- CAST_S32(bounds.w),
- CAST_S32(bounds.h)
- };
-
- MSDL_RenderCopy(mRenderer, image->mTexture, &srcRect, &dstRect);
-}
-
-void SDLGraphics::drawPatternCached(const Image *restrict const image,
- const int x, const int y,
- const int w, const int h) restrict2
-{
- FUNC_BLOCK("Graphics::drawPatternCached", 1)
- // Check that preconditions for blitting are met.
- if (!mWindow || !image)
- return;
- if (!image->mTexture)
- return;
-
- const ClipRect &top = mClipStack.top();
- if (!top.width || !top.height)
- return;
-
- const SDL_Rect &bounds = image->mBounds;
- const int iw = bounds.w;
- const int ih = bounds.h;
- if (iw == 0 || ih == 0)
- return;
-
- const int xOffset = top.xOffset + x;
- const int yOffset = top.yOffset + y;
-
- SDL_Rect dstRect;
- SDL_Rect srcRect;
- srcRect.x = CAST_S32(bounds.x);
- srcRect.y = CAST_S32(bounds.y);
- for (int py = 0; py < h; py += ih)
- {
- const int dh = (py + ih >= h) ? h - py : ih;
- dstRect.y = CAST_S32(py + yOffset);
- srcRect.h = CAST_S32(dh);
- dstRect.h = CAST_S32(dh);
-
- for (int px = 0; px < w; px += iw)
- {
- const int dw = (px + iw >= w) ? w - px : iw;
- dstRect.x = CAST_S32(px + xOffset);
- srcRect.w = CAST_S32(dw);
- dstRect.w = CAST_S32(dw);
-
- MSDL_RenderCopy(mRenderer, image->mTexture, &srcRect, &dstRect);
- }
- }
-}
-
-void SDLGraphics::completeCache() restrict2
-{
-}
-
-void SDLGraphics::drawPattern(const Image *restrict const image,
- const int x, const int y,
- const int w, const int h) restrict2
-{
- drawPatternInline(image, x, y, w, h);
-}
-
-void SDLGraphics::drawPatternInline(const Image *restrict const image,
- const int x, const int y,
- const int w, const int h) restrict2
-{
- FUNC_BLOCK("Graphics::drawPattern", 1)
- // Check that preconditions for blitting are met.
- if (!mWindow || !image)
- return;
- if (!image->mTexture)
- return;
-
- const ClipRect &top = mClipStack.top();
- if (!top.width || !top.height)
- return;
-
- const SDL_Rect &bounds = image->mBounds;
- const int iw = bounds.w;
- const int ih = bounds.h;
- if (iw == 0 || ih == 0)
- return;
-
- const int xOffset = top.xOffset + x;
- const int yOffset = top.yOffset + y;
-
- SDL_Rect dstRect;
- SDL_Rect srcRect;
- srcRect.x = CAST_S32(bounds.x);
- srcRect.y = CAST_S32(bounds.y);
- for (int py = 0; py < h; py += ih)
- {
- const int dh = (py + ih >= h) ? h - py : ih;
- dstRect.y = CAST_S32(py + yOffset);
- srcRect.h = CAST_S32(dh);
- dstRect.h = CAST_S32(dh);
-
- for (int px = 0; px < w; px += iw)
- {
- const int dw = (px + iw >= w) ? w - px : iw;
- dstRect.x = CAST_S32(px + xOffset);
- srcRect.w = CAST_S32(dw);
- dstRect.w = CAST_S32(dw);
-
- MSDL_RenderCopy(mRenderer, image->mTexture, &srcRect, &dstRect);
- }
- }
-}
-
-void SDLGraphics::drawRescaledPattern(const Image *restrict const image,
- const int x, const int y,
- const int w, const int h,
- const int scaledWidth,
- const int scaledHeight) restrict2
-{
- // Check that preconditions for blitting are met.
- if (!mWindow || !image)
- return;
- if (!image->mTexture)
- return;
-
- if (scaledHeight == 0 || scaledWidth == 0)
- return;
-
- const ClipRect &top = mClipStack.top();
- if (!top.width || !top.height)
- return;
-
- Image *const tmpImage = image->SDLgetScaledImage(
- scaledWidth, scaledHeight);
- if (!tmpImage)
- return;
-
- const SDL_Rect &bounds = tmpImage->mBounds;
- const int iw = bounds.w;
- const int ih = bounds.h;
- if (iw == 0 || ih == 0)
- return;
-
- const int xOffset = top.xOffset + x;
- const int yOffset = top.yOffset + y;
-
- SDL_Rect dstRect;
- SDL_Rect srcRect;
- srcRect.x = CAST_S32(bounds.x);
- srcRect.y = CAST_S32(bounds.y);
- for (int py = 0; py < h; py += ih)
- {
- const int dh = (py + ih >= h) ? h - py : ih;
- dstRect.y = CAST_S32(py + yOffset);
- srcRect.h = CAST_S32(dh);
- dstRect.h = CAST_S32(dh);
-
- for (int px = 0; px < w; px += iw)
- {
- const int dw = (px + iw >= w) ? w - px : iw;
- dstRect.x = CAST_S32(px + xOffset);
- srcRect.w = CAST_S32(dw);
- dstRect.w = CAST_S32(dw);
-
- MSDL_RenderCopy(mRenderer, image->mTexture, &srcRect, &dstRect);
- }
- }
-
- delete tmpImage;
-}
-
-void SDLGraphics::calcPattern(ImageVertexes *restrict const vert,
- const Image *restrict const image,
- const int x, const int y,
- const int w, const int h) const restrict2
-{
- calcPatternInline(vert, image, x, y, w, h);
-}
-
-void SDLGraphics::calcPatternInline(ImageVertexes *restrict const vert,
- const Image *restrict const image,
- const int x, const int y,
- const int w, const int h) const restrict2
-{
- // Check that preconditions for blitting are met.
- if (!vert || !mWindow || !image || !image->mTexture)
- return;
-
- const ClipRect &top = mClipStack.top();
- if (!top.width || !top.height)
- return;
-
- const SDL_Rect &bounds = image->mBounds;
- const int iw = bounds.w;
- const int ih = bounds.h;
- if (iw == 0 || ih == 0)
- return;
-
- const int xOffset = top.xOffset + x;
- const int yOffset = top.yOffset + y;
- const int srcX = bounds.x;
- const int srcY = bounds.y;
- for (int py = 0; py < h; py += ih)
- {
- const int dh = (py + ih >= h) ? h - py : ih;
- const int dstY = py + yOffset;
-
- for (int px = 0; px < w; px += iw)
- {
- const int dw = (px + iw >= w) ? w - px : iw;
- const int dstX = px + xOffset;
-
- DoubleRect *const r = new DoubleRect;
- SDL_Rect &dstRect = r->dst;
- SDL_Rect &srcRect = r->src;
- srcRect.x = CAST_S32(srcX);
- srcRect.y = CAST_S32(srcY);
- srcRect.w = CAST_S32(dw);
- srcRect.h = CAST_S32(dh);
- dstRect.x = CAST_S32(dstX);
- dstRect.y = CAST_S32(dstY);
- dstRect.w = CAST_S32(dw);
- dstRect.h = CAST_S32(dh);
-
- vert->sdl.push_back(r);
- }
- }
-}
-
-void SDLGraphics::calcPattern(ImageCollection *restrict const vertCol,
- const Image *restrict const image,
- const int x, const int y,
- const int w, const int h) const restrict2
-{
- ImageVertexes *vert = nullptr;
- if (vertCol->currentImage != image)
- {
- vert = new ImageVertexes;
- vertCol->currentImage = image;
- vertCol->currentVert = vert;
- vert->image = image;
- vertCol->draws.push_back(vert);
- }
- else
- {
- vert = vertCol->currentVert;
- }
-
- calcPatternInline(vert, image, x, y, w, h);
-}
-
-void SDLGraphics::calcTileVertexes(ImageVertexes *restrict const vert,
- const Image *restrict const image,
- int x, int y) const restrict2
-{
- vert->image = image;
- calcTileSDL(vert, x, y);
-}
-
-void SDLGraphics::calcTileVertexesInline(ImageVertexes *restrict const vert,
- const Image *restrict const image,
- int x, int y) const restrict2
-{
- vert->image = image;
- calcTileSDL(vert, x, y);
-}
-
-void SDLGraphics::calcTileSDL(ImageVertexes *restrict const vert,
- int x, int y) const restrict2
-{
- // Check that preconditions for blitting are met.
- if (!vert || !vert->image || !vert->image->mTexture)
- return;
-
- const ClipRect &top = mClipStack.top();
- if (!top.width || !top.height)
- return;
-
- const Image *const image = vert->image;
- const SDL_Rect &bounds = image->mBounds;
-
- x += top.xOffset;
- y += top.yOffset;
-
- DoubleRect *rect = new DoubleRect;
- SDL_Rect &dstRect = rect->dst;
- SDL_Rect &srcRect = rect->src;
-
- srcRect.x = CAST_S32(bounds.x);
- srcRect.y = CAST_S32(bounds.y);
- srcRect.w = CAST_S32(bounds.w);
- srcRect.h = CAST_S32(bounds.h);
- dstRect.x = CAST_S32(x);
- dstRect.y = CAST_S32(y);
- dstRect.w = CAST_S32(bounds.w);
- dstRect.h = CAST_S32(bounds.h);
-
- vert->sdl.push_back(rect);
-}
-
-void SDLGraphics::calcTileCollection(ImageCollection *restrict const vertCol,
- const Image *restrict const image,
- int x, int y) restrict2
-{
- if (!vertCol)
- return;
- if (vertCol->currentImage != image)
- {
- ImageVertexes *const vert = new ImageVertexes;
- vertCol->currentImage = image;
- vertCol->currentVert = vert;
- vert->image = image;
- vertCol->draws.push_back(vert);
- calcTileSDL(vert, x, y);
- }
- else
- {
- calcTileSDL(vertCol->currentVert, x, y);
- }
-}
-
-void SDLGraphics::drawTileCollection(const ImageCollection
- *restrict const vertCol) restrict2
-{
- const ImageVertexesVector &draws = vertCol->draws;
- const ImageCollectionCIter it_end = draws.end();
- for (ImageCollectionCIter it = draws.begin(); it != it_end; ++ it)
- {
- const ImageVertexes *const vert = *it;
- const Image *const img = vert->image;
- const DoubleRects *const rects = &vert->sdl;
- DoubleRects::const_iterator it2 = rects->begin();
- const DoubleRects::const_iterator it2_end = rects->end();
- while (it2 != it2_end)
- {
- MSDL_RenderCopy(mRenderer, img->mTexture,
- &(*it2)->src, &(*it2)->dst);
- ++ it2;
- }
- }
-}
-
-void SDLGraphics::drawTileVertexes(const ImageVertexes *restrict const vert)
- restrict2
-{
- if (!vert)
- return;
- // vert and img must be != 0
- const Image *const img = vert->image;
- const DoubleRects *const rects = &vert->sdl;
- DoubleRects::const_iterator it = rects->begin();
- const DoubleRects::const_iterator it_end = rects->end();
- while (it != it_end)
- {
- MSDL_RenderCopy(mRenderer, img->mTexture, &(*it)->src, &(*it)->dst);
- ++ it;
- }
-}
-
-void SDLGraphics::updateScreen() restrict2
-{
- BLOCK_START("Graphics::updateScreen")
- SDL_RenderPresent(mRenderer);
-// SDL_RenderClear(mRenderer);
- BLOCK_END("Graphics::updateScreen")
-}
-
-void SDLGraphics::calcWindow(ImageCollection *restrict const vertCol,
- const int x, const int y,
- const int w, const int h,
- const ImageRect &restrict imgRect) restrict2
-{
- ImageVertexes *vert = nullptr;
- Image *const image = imgRect.grid[4];
- if (!image)
- return;
- if (vertCol->currentImage != image)
- {
- vert = new ImageVertexes;
- vertCol->currentImage = image;
- vertCol->currentVert = vert;
- vert->image = image;
- vertCol->draws.push_back(vert);
- }
- else
- {
- vert = vertCol->currentVert;
- }
- calcImageRect(vert, x, y, w, h, imgRect);
-}
-
-void SDLGraphics::fillRectangle(const Rect &restrict rectangle) restrict2
-{
- const ClipRect &top = mClipStack.top();
- const SDL_Rect rect =
- {
- CAST_S32(rectangle.x + top.xOffset),
- CAST_S32(rectangle.y + top.yOffset),
- CAST_S32(rectangle.width),
- CAST_S32(rectangle.height)
- };
-
- setRenderDrawColor(mColor);
- SDL_RenderFillRects(mRenderer, &rect, 1);
-}
-
-void SDLGraphics::beginDraw() restrict2
-{
- pushClipArea(Rect(0, 0, mRect.w, mRect.h));
-}
-
-void SDLGraphics::endDraw() restrict2
-{
- popClipArea();
-}
-
-void SDLGraphics::pushClipArea(const Rect &restrict area) restrict2
-{
- Graphics::pushClipArea(area);
-
- const ClipRect &carea = mClipStack.top();
- defRectFromArea(rect, carea);
- SDL_RenderSetClipRect(mRenderer, &rect);
-}
-
-void SDLGraphics::popClipArea() restrict2
-{
- Graphics::popClipArea();
-
- if (mClipStack.empty())
- return;
-
- const ClipRect &carea = mClipStack.top();
- defRectFromArea(rect, carea);
- SDL_RenderSetClipRect(mRenderer, &rect);
-}
-
-void SDLGraphics::drawPoint(int x, int y) restrict2
-{
- if (mClipStack.empty())
- return;
-
- const ClipRect &top = mClipStack.top();
-
- x += top.xOffset;
- y += top.yOffset;
-
- if (!top.isPointInRect(x, y))
- return;
-
- setRenderDrawColor(mColor);
- const SDL_Point point =
- {
- x,
- y
- };
-
- SDL_RenderDrawPoints(mRenderer, &point, 1);
-}
-
-
-void SDLGraphics::drawRectangle(const Rect &restrict rectangle) restrict2
-{
- const ClipRect &top = mClipStack.top();
- setRenderDrawColor(mColor);
-
- const int x1 = rectangle.x + top.xOffset;
- const int y1 = rectangle.y + top.yOffset;
- const int x2 = x1 + rectangle.width - 1;
- const int y2 = y1 + rectangle.height - 1;
- SDL_Point points[] =
- {
- {x1, y1},
- {x2, y1},
- {x2, y2},
- {x1, y2},
- {x1, y1}
- };
-
- SDL_RenderDrawLines(mRenderer, points, 5);
-}
-
-void SDLGraphics::drawLine(int x1, int y1,
- int x2, int y2) restrict2
-{
- const ClipRect &top = mClipStack.top();
- setRenderDrawColor(mColor);
-
- const int x0 = top.xOffset;
- const int y0 = top.yOffset;
-
- SDL_Point points[] =
- {
- {x1 + x0, y1 + y0},
- {x2 + x0, y2 + y0}
- };
-
- SDL_RenderDrawLines(mRenderer, points, 2);
-}
-
-bool SDLGraphics::setVideoMode(const int w, const int h,
- const int scale,
- const int bpp,
- const bool fs,
- const bool hwaccel,
- const bool resize,
- const bool noFrame,
- const bool allowHighDPI) restrict2
-{
- setMainFlags(w, h,
- scale,
- bpp,
- fs,
- hwaccel,
- resize,
- noFrame,
- allowHighDPI);
-
- if (!(mWindow = graphicsManager.createWindow(w, h, bpp,
- getSoftwareFlags())))
- {
- mRect.w = 0;
- mRect.h = 0;
- return false;
- }
-
- int w1 = 0;
- int h1 = 0;
- SDL_GetWindowSize(mWindow, &w1, &h1);
- mRect.w = w1;
- mRect.h = h1;
-
- mRenderer = graphicsManager.createRenderer(mWindow, mRendererFlags);
- SDLImageHelper::setRenderer(mRenderer);
- return videoInfo();
-}
-
-void SDLGraphics::drawImageRect(const int x, const int y,
- const int w, const int h,
- const ImageRect &restrict imgRect) restrict2
-{
- #include "render/graphics_drawImageRect.hpp"
-}
-
-void SDLGraphics::calcImageRect(ImageVertexes *restrict const vert,
- const int x, const int y,
- const int w, const int h,
- const ImageRect &restrict imgRect) restrict2
-{
- #include "render/graphics_calcImageRect.hpp"
-}
-
-#endif // USE_SDL2
diff --git a/src/render/sdl2graphics.h b/src/render/sdl2graphics.h
deleted file mode 100644
index 5db1cf179..000000000
--- a/src/render/sdl2graphics.h
+++ /dev/null
@@ -1,116 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef RENDER_SDL2GRAPHICS_H
-#define RENDER_SDL2GRAPHICS_H
-
-#ifdef USE_SDL2
-
-#include "render/graphics.h"
-
-#include "localconsts.h"
-
-class Image;
-class ImageCollection;
-class ImageVertexes;
-class MapLayer;
-
-struct SDL_Surface;
-
-/**
- * A central point of control for graphics.
- */
-class SDLGraphics final : public Graphics
-{
- public:
- /**
- * Constructor.
- */
- SDLGraphics();
-
- A_DELETE_COPY(SDLGraphics)
-
- /**
- * Destructor.
- */
- ~SDLGraphics();
-
- void setRendererFlags(const uint32_t flags) restrict noexcept2 override
- { mRendererFlags = flags; }
-
- #include "render/graphicsdef.hpp"
- RENDER_GRAPHICSDEF_HPP
-
- #include "render/softwaregraphicsdef.hpp"
- RENDER_SOFTWAREGRAPHICSDEF_HPP
-
- protected:
- uint32_t mRendererFlags;
- uint32_t mOldPixel;
- unsigned int mOldAlpha;
-};
-
-#endif // USE_SDL2
-#endif // RENDER_SDL2GRAPHICS_H
diff --git a/src/render/sdl2softwaregraphics.cpp b/src/render/sdl2softwaregraphics.cpp
deleted file mode 100644
index 808f7c601..000000000
--- a/src/render/sdl2softwaregraphics.cpp
+++ /dev/null
@@ -1,1530 +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 "render/sdl2softwaregraphics.h"
-
-#include "graphicsmanager.h"
-
-#include "render/vertexes/imagecollection.h"
-
-#include "resources/imagerect.h"
-#include "resources/sdl2softwareimagehelper.h"
-
-#include "resources/image/image.h"
-
-#include "utils/sdlcheckutils.h"
-
-#include "utils/sdlpixel.h"
-
-#include "debug.h"
-
-#ifndef SDL_BIG_ENDIAN
-#error missing SDL_endian.h
-#endif // SDL_BYTEORDER
-
-#if SDL_BYTEORDER == SDL_LIL_ENDIAN
-static unsigned int *cR = nullptr;
-static unsigned int *cG = nullptr;
-static unsigned int *cB = nullptr;
-#endif // SDL_BYTEORDER == SDL_LIL_ENDIAN
-
-#define defRectFromArea(rect, area) \
- const SDL_Rect rect = \
- { \
- CAST_S32(area.x), \
- CAST_S32(area.y), \
- CAST_S32(area.width), \
- CAST_S32(area.height) \
- }
-
-SDL2SoftwareGraphics::SDL2SoftwareGraphics() :
- Graphics(),
- mRendererFlags(SDL_RENDERER_SOFTWARE),
- mSurface(nullptr),
- mOldPixel(0),
- mOldAlpha(0)
-{
- mOpenGL = RENDER_SOFTWARE;
- mName = "Software";
-}
-
-SDL2SoftwareGraphics::~SDL2SoftwareGraphics()
-{
-}
-
-void SDL2SoftwareGraphics::drawRescaledImage(const Image *restrict const image,
- int dstX, int dstY,
- const int desiredWidth,
- const int desiredHeight) restrict2
-{
- FUNC_BLOCK("Graphics::drawRescaledImage", 1)
- // Check that preconditions for blitting are met.
- if (!mSurface || !image || !image->mSDLSurface)
- return;
-
- Image *const tmpImage = image->SDLgetScaledImage(
- desiredWidth, desiredHeight);
-
- if (!tmpImage || !tmpImage->mSDLSurface)
- return;
-
- const ClipRect &top = mClipStack.top();
- const SDL_Rect &bounds = image->mBounds;
-
- SDL_Rect srcRect =
- {
- CAST_S16(bounds.x),
- CAST_S16(bounds.y),
- CAST_U16(bounds.w),
- CAST_U16(bounds.h)
- };
-
- SDL_Rect dstRect =
- {
- CAST_S16(dstX + top.xOffset),
- CAST_S16(dstY + top.yOffset),
- 0,
- 0
- };
-
- SDL_BlitSurface(tmpImage->mSDLSurface, &srcRect, mSurface, &dstRect);
- delete tmpImage;
-}
-
-void SDL2SoftwareGraphics::drawImage(const Image *restrict const image,
- int dstX, int dstY) restrict2
-{
- drawImageInline(image, dstX, dstY);
-}
-
-void SDL2SoftwareGraphics::drawImageInline(const Image *restrict const image,
- int dstX, int dstY) restrict2
-{
- FUNC_BLOCK("Graphics::drawImage", 1)
- // Check that preconditions for blitting are met.
- if (!mSurface || !image || !image->mSDLSurface)
- return;
-
- const ClipRect &top = mClipStack.top();
- const SDL_Rect &bounds = image->mBounds;
-
- SDL_Surface *const src = image->mSDLSurface;
-
- int srcX = bounds.x;
- int srcY = bounds.y;
- dstX += top.xOffset;
- dstY += top.yOffset;
-
- int w = bounds.w;
- int h = bounds.h;
- if (srcX < 0)
- {
- w += srcX;
- dstX -= CAST_S16(srcX);
- srcX = 0;
- }
- const int maxw = src->w - srcX;
- if (maxw < w)
- w = maxw;
-
- if (srcY < 0)
- {
- h += srcY;
- dstY -= CAST_S16(srcY);
- srcY = 0;
- }
- const int maxh = src->h - srcY;
- if (maxh < h)
- h = maxh;
-
- const SDL_Rect *const clip = &mSurface->clip_rect;
- const int clipX = clip->x;
- const int clipY = clip->y;
- int dx = clipX - dstX;
- if (dx > 0)
- {
- w -= dx;
- dstX += CAST_S16(dx);
- srcX += dx;
- }
- dx = dstX + w - clipX - clip->w;
- if (dx > 0)
- w -= dx;
-
- int dy = clipY - dstY;
- if (dy > 0)
- {
- h -= dy;
- dstY += CAST_S16(dy);
- srcY += dy;
- }
- dy = dstY + h - clipY - clip->h;
- if (dy > 0)
- h -= dy;
-
- if (w > 0 && h > 0)
- {
- SDL_Rect srcRect =
- {
- CAST_S16(srcX),
- CAST_S16(srcY),
- CAST_U16(w),
- CAST_U16(h)
- };
-
- SDL_Rect dstRect =
- {
- CAST_S16(dstX),
- CAST_S16(dstY),
- CAST_U16(w),
- CAST_U16(h)
- };
-
- SDL_LowerBlit(src, &srcRect, mSurface, &dstRect);
- }
-}
-
-void SDL2SoftwareGraphics::copyImage(const Image *restrict const image,
- int dstX, int dstY) restrict2
-{
- drawImageInline(image, dstX, dstY);
-}
-
-void SDL2SoftwareGraphics::drawImageCached(const Image *restrict const image,
- int x, int y) restrict2
-{
- FUNC_BLOCK("Graphics::drawImageCached", 1)
- // Check that preconditions for blitting are met.
- if (!mSurface || !image || !image->mSDLSurface)
- return;
-
- const ClipRect &top = mClipStack.top();
- const SDL_Rect &bounds = image->mBounds;
-
- SDL_Surface *const src = image->mSDLSurface;
-
- int srcX = bounds.x;
- int srcY = bounds.y;
- x += top.xOffset;
- y += top.yOffset;
-
- int w = bounds.w;
- int h = bounds.h;
- if (srcX < 0)
- {
- w += srcX;
- x -= CAST_S16(srcX);
- srcX = 0;
- }
- const int maxw = src->w - srcX;
- if (maxw < w)
- w = maxw;
-
- if (srcY < 0)
- {
- h += srcY;
- y -= CAST_S16(srcY);
- srcY = 0;
- }
- const int maxh = src->h - srcY;
- if (maxh < h)
- h = maxh;
-
- const SDL_Rect *const clip = &mSurface->clip_rect;
- const int clipX = clip->x;
- const int clipY = clip->y;
- int dx = clipX - x;
- if (dx > 0)
- {
- w -= dx;
- x += CAST_S16(dx);
- srcX += dx;
- }
- dx = x + w - clipX - clip->w;
- if (dx > 0)
- w -= dx;
-
- int dy = clipY - y;
- if (dy > 0)
- {
- h -= dy;
- y += CAST_S16(dy);
- srcY += dy;
- }
- dy = y + h - clipY - clip->h;
- if (dy > 0)
- h -= dy;
-
- if (w > 0 && h > 0)
- {
- SDL_Rect srcRect =
- {
- CAST_S16(srcX),
- CAST_S16(srcY),
- CAST_U16(w),
- CAST_U16(h)
- };
-
- SDL_Rect dstRect =
- {
- CAST_S16(x),
- CAST_S16(y),
- CAST_U16(w),
- CAST_U16(h)
- };
-
- SDL_LowerBlit(src, &srcRect, mSurface, &dstRect);
- }
-}
-
-void SDL2SoftwareGraphics::drawPatternCached(const Image *restrict const image,
- const int x,
- const int y,
- const int w,
- const int h) restrict2
-{
- FUNC_BLOCK("Graphics::drawPatternCached", 1)
- // Check that preconditions for blitting are met.
- if (!mSurface || !image)
- return;
- if (!image->mSDLSurface)
- return;
-
- const SDL_Rect &bounds = image->mBounds;
- const int iw = bounds.w;
- const int ih = bounds.h;
- if (iw == 0 || ih == 0)
- return;
-
- const ClipRect &top = mClipStack.top();
- const int xOffset = top.xOffset + x;
- const int yOffset = top.yOffset + y;
- const int srcX = bounds.x;
- const int srcY = bounds.y;
- SDL_Surface *const src = image->mSDLSurface;
- const SDL_Rect *const clip = &mSurface->clip_rect;
- const int clipX = clip->x;
- const int clipY = clip->y;
-
- for (int py = 0; py < h; py += ih)
- {
- const int dh = (py + ih >= h) ? h - py : ih;
- int dstY = py + yOffset;
- int y2 = srcY;
- int h2 = dh;
- if (y2 < 0)
- {
- h2 += y2;
- dstY -= CAST_S16(y2);
- y2 = 0;
- }
- const int maxh = src->h - y2;
- if (maxh < h2)
- h2 = maxh;
-
- int dy = clipY - dstY;
- if (dy > 0)
- {
- h2 -= dy;
- dstY += CAST_S16(dy);
- y2 += dy;
- }
- dy = dstY + h2 - clipY - clip->h;
- if (dy > 0)
- h2 -= dy;
-
- if (h2 > 0)
- {
- for (int px = 0; px < w; px += iw)
- {
- const int dw = (px + iw >= w) ? w - px : iw;
- int dstX = px + xOffset;
- int x2 = srcX;
- int w2 = dw;
- if (x2 < 0)
- {
- w2 += x2;
- dstX -= CAST_S16(x2);
- x2 = 0;
- }
- const int maxw = src->w - x2;
- if (maxw < w2)
- w2 = maxw;
-
- int dx = clipX - dstX;
- if (dx > 0)
- {
- w2 -= dx;
- dstX += CAST_S16(dx);
- x2 += dx;
- }
- dx = dstX + w2 - clipX - clip->w;
- if (dx > 0)
- w2 -= dx;
-
- if (w2 > 0)
- {
- SDL_Rect srcRect =
- {
- CAST_S16(x2),
- CAST_S16(y2),
- CAST_U16(w2),
- CAST_U16(h2)
- };
-
- SDL_Rect dstRect =
- {
- CAST_S16(dstX),
- CAST_S16(dstY),
- CAST_U16(w2),
- CAST_U16(h2)
- };
-
- SDL_LowerBlit(src, &srcRect, mSurface, &dstRect);
- }
-
-// SDL_BlitSurface(image->mSDLSurface, &srcRect, mWindow, &dstRect);
- }
- }
- }
-}
-
-void SDL2SoftwareGraphics::completeCache() restrict2
-{
-}
-
-void SDL2SoftwareGraphics::drawPattern(const Image *restrict const image,
- const int x, const int y,
- const int w, const int h) restrict2
-{
- drawPatternInline(image, x, y, w, h);
-}
-
-void SDL2SoftwareGraphics::drawPatternInline(const Image *restrict const image,
- const int x,
- const int y,
- const int w,
- const int h) restrict2
-{
- FUNC_BLOCK("Graphics::drawPattern", 1)
- // Check that preconditions for blitting are met.
- if (!mSurface || !image)
- return;
- if (!image->mSDLSurface)
- return;
-
- const SDL_Rect &bounds = image->mBounds;
- const int iw = bounds.w;
- const int ih = bounds.h;
- if (iw == 0 || ih == 0)
- return;
-
- const ClipRect &top = mClipStack.top();
- const int xOffset = top.xOffset + x;
- const int yOffset = top.yOffset + y;
- const int srcX = bounds.x;
- const int srcY = bounds.y;
- SDL_Surface *const src = image->mSDLSurface;
- const SDL_Rect *const clip = &mSurface->clip_rect;
- const int clipX = clip->x;
- const int clipY = clip->y;
-
- for (int py = 0; py < h; py += ih)
- {
- const int dh = (py + ih >= h) ? h - py : ih;
- int dstY = py + yOffset;
- int y2 = srcY;
- int h2 = dh;
- if (y2 < 0)
- {
- h2 += y2;
- dstY -= CAST_S16(y2);
- y2 = 0;
- }
- const int maxh = src->h - y2;
- if (maxh < h2)
- h2 = maxh;
-
- int dy = clipY - dstY;
- if (dy > 0)
- {
- h2 -= dy;
- dstY += CAST_S16(dy);
- y2 += dy;
- }
- dy = dstY + h2 - clipY - clip->h;
- if (dy > 0)
- h2 -= dy;
-
- if (h2 > 0)
- {
- for (int px = 0; px < w; px += iw)
- {
- const int dw = (px + iw >= w) ? w - px : iw;
- int dstX = px + xOffset;
- int x2 = srcX;
- int w2 = dw;
- if (x2 < 0)
- {
- w2 += x2;
- dstX -= CAST_S16(x2);
- x2 = 0;
- }
- const int maxw = src->w - x2;
- if (maxw < w2)
- w2 = maxw;
-
- int dx = clipX - dstX;
- if (dx > 0)
- {
- w2 -= dx;
- dstX += CAST_S16(dx);
- x2 += dx;
- }
- dx = dstX + w2 - clipX - clip->w;
- if (dx > 0)
- w2 -= dx;
-
- if (w2 > 0)
- {
- SDL_Rect srcRect =
- {
- CAST_S16(x2),
- CAST_S16(y2),
- CAST_U16(w2),
- CAST_U16(h2)
- };
-
- SDL_Rect dstRect =
- {
- CAST_S16(dstX),
- CAST_S16(dstY),
- CAST_U16(w2),
- CAST_U16(h2)
- };
-
- SDL_LowerBlit(src, &srcRect, mSurface, &dstRect);
- }
-
-// SDL_BlitSurface(image->mSDLSurface, &srcRect, mWindow, &dstRect);
- }
- }
- }
-}
-
-void SDL2SoftwareGraphics::drawRescaledPattern(const Image *
- restrict const image,
- const int x, const int y,
- const int w, const int h,
- const int scaledWidth,
- const int scaledHeight)
- restrict2
-{
- // Check that preconditions for blitting are met.
- if (!mSurface || !image)
- return;
- if (!image->mSDLSurface)
- return;
-
- if (scaledHeight == 0 || scaledWidth == 0)
- return;
-
- Image *const tmpImage = image->SDLgetScaledImage(
- scaledWidth, scaledHeight);
- if (!tmpImage)
- return;
-
- const SDL_Rect &bounds = tmpImage->mBounds;
- const int iw = bounds.w;
- const int ih = bounds.h;
- if (iw == 0 || ih == 0)
- return;
-
- const ClipRect &top = mClipStack.top();
- const int xOffset = top.xOffset + x;
- const int yOffset = top.yOffset + y;
- const int srcX = bounds.x;
- const int srcY = bounds.y;
-
- for (int py = 0; py < h; py += ih) // Y position on pattern plane
- {
- const int dh = (py + ih >= h) ? h - py : ih;
- const int dstY = py + yOffset;
-
- for (int px = 0; px < w; px += iw) // X position on pattern plane
- {
- const int dw = (px + iw >= w) ? w - px : iw;
- const int dstX = px + xOffset;
-
- SDL_Rect srcRect =
- {
- CAST_S16(srcX),
- CAST_S16(srcY),
- CAST_U16(dw),
- CAST_U16(dh)
- };
-
- SDL_Rect dstRect =
- {
- CAST_S16(dstX),
- CAST_S16(dstY),
- 0,
- 0
- };
-
- SDL_BlitSurface(tmpImage->mSDLSurface, &srcRect,
- mSurface, &dstRect);
- }
- }
-
- delete tmpImage;
-}
-
-void SDL2SoftwareGraphics::calcPattern(ImageVertexes *restrict const vert,
- const Image *restrict const image,
- const int x,
- const int y,
- const int w,
- const int h) const restrict2
-{
- calcPatternInline(vert, image, x, y, w, h);
-}
-
-void SDL2SoftwareGraphics::calcPatternInline(ImageVertexes *
- restrict const vert,
- const Image *restrict const image,
- const int x,
- const int y,
- const int w,
- const int h) const restrict2
-{
- // Check that preconditions for blitting are met.
- if (!vert || !mSurface || !image || !image->mSDLSurface)
- return;
-
- const SDL_Rect &bounds = image->mBounds;
- const int iw = bounds.w;
- const int ih = bounds.h;
- if (iw == 0 || ih == 0)
- return;
-
- const ClipRect &top = mClipStack.top();
- const int xOffset = top.xOffset + x;
- const int yOffset = top.yOffset + y;
- const int srcX = bounds.x;
- const int srcY = bounds.y;
-
- for (int py = 0; py < h; py += ih) // Y position on pattern plane
- {
- const int dh = (py + ih >= h) ? h - py : ih;
- const int dstY = py + yOffset;
-
- for (int px = 0; px < w; px += iw) // X position on pattern plane
- {
- const int dw = (px + iw >= w) ? w - px : iw;
- const int dstX = px + xOffset;
-
- DoubleRect *const r = new DoubleRect;
- SDL_Rect &srcRect = r->src;
- srcRect.x = CAST_S16(srcX);
- srcRect.y = CAST_S16(srcY);
- srcRect.w = CAST_U16(dw);
- srcRect.h = CAST_U16(dh);
- SDL_Rect &dstRect = r->dst;
- dstRect.x = CAST_S16(dstX);
- dstRect.y = CAST_S16(dstY);
-
- if (SDL_FakeUpperBlit(image->mSDLSurface, &srcRect,
- mSurface, &dstRect) == 1)
- {
- vert->sdl.push_back(r);
- }
- else
- {
- delete r;
- }
- }
- }
-}
-
-void SDL2SoftwareGraphics::calcPattern(ImageCollection *restrict const vertCol,
- const Image *restrict const image,
- const int x,
- const int y,
- const int w,
- const int h) const restrict2
-{
- ImageVertexes *vert = nullptr;
- if (vertCol->currentImage != image)
- {
- vert = new ImageVertexes;
- vertCol->currentImage = image;
- vertCol->currentVert = vert;
- vert->image = image;
- vertCol->draws.push_back(vert);
- }
- else
- {
- vert = vertCol->currentVert;
- }
-
- calcPatternInline(vert, image, x, y, w, h);
-}
-
-void SDL2SoftwareGraphics::calcTileVertexes(ImageVertexes *restrict const vert,
- const Image *restrict const image,
- int x, int y) const restrict2
-{
- vert->image = image;
- calcTileSDL(vert, x, y);
-}
-
-void SDL2SoftwareGraphics::calcTileVertexesInline(ImageVertexes *
- restrict const vert,
- const Image *
- restrict const image,
- int x, int y) const restrict2
-{
- vert->image = image;
- calcTileSDL(vert, x, y);
-}
-
-void SDL2SoftwareGraphics::calcTileSDL(ImageVertexes *restrict const vert,
- int x, int y) const restrict2
-{
- // Check that preconditions for blitting are met.
- if (!vert || !vert->image || !vert->image->mSDLSurface)
- return;
-
- const Image *const image = vert->image;
- const ClipRect &top = mClipStack.top();
- const SDL_Rect &bounds = image->mBounds;
-
- DoubleRect *rect = new DoubleRect;
- rect->src.x = CAST_S16(bounds.x);
- rect->src.y = CAST_S16(bounds.y);
- rect->src.w = CAST_U16(bounds.w);
- rect->src.h = CAST_U16(bounds.h);
- rect->dst.x = CAST_S16(x + top.xOffset);
- rect->dst.y = CAST_S16(y + top.yOffset);
- if (SDL_FakeUpperBlit(image->mSDLSurface, &rect->src,
- mSurface, &rect->dst) == 1)
- {
- vert->sdl.push_back(rect);
- }
- else
- {
- delete rect;
- }
-}
-
-void SDL2SoftwareGraphics::calcTileCollection(ImageCollection *
- restrict const vertCol,
- const Image *
- restrict const image,
- int x, int y) restrict2
-{
- if (!vertCol)
- return;
- if (vertCol->currentImage != image)
- {
- ImageVertexes *const vert = new ImageVertexes;
- vertCol->currentImage = image;
- vertCol->currentVert = vert;
- vert->image = image;
- vertCol->draws.push_back(vert);
- calcTileSDL(vert, x, y);
- }
- else
- {
- calcTileSDL(vertCol->currentVert, x, y);
- }
-}
-
-void SDL2SoftwareGraphics::drawTileCollection(const ImageCollection
- *restrict const vertCol)
- restrict2
-{
- const ImageVertexesVector &draws = vertCol->draws;
- const ImageCollectionCIter it_end = draws.end();
- for (ImageCollectionCIter it = draws.begin(); it != it_end; ++ it)
- {
- const ImageVertexes *const vert = *it;
- const Image *const img = vert->image;
- const DoubleRects *const rects = &vert->sdl;
- DoubleRects::const_iterator it2 = rects->begin();
- const DoubleRects::const_iterator it2_end = rects->end();
- while (it2 != it2_end)
- {
- SDL_LowerBlit(img->mSDLSurface, &(*it2)->src,
- mSurface, &(*it2)->dst);
- ++ it2;
- }
- }
-}
-
-void SDL2SoftwareGraphics::drawTileVertexes(const ImageVertexes *
- restrict const vert) restrict2
-{
- if (!vert)
- return;
- // vert and img must be != 0
- const Image *const img = vert->image;
- const DoubleRects *const rects = &vert->sdl;
- DoubleRects::const_iterator it = rects->begin();
- const DoubleRects::const_iterator it_end = rects->end();
- while (it != it_end)
- {
- SDL_LowerBlit(img->mSDLSurface, &(*it)->src, mSurface, &(*it)->dst);
- ++ it;
- }
-}
-
-void SDL2SoftwareGraphics::updateScreen() restrict2
-{
- BLOCK_START("Graphics::updateScreen")
- SDL_UpdateWindowSurfaceRects(mWindow, &mRect, 1);
- BLOCK_END("Graphics::updateScreen")
-}
-
-void SDL2SoftwareGraphics::calcWindow(ImageCollection *restrict const vertCol,
- const int x, const int y,
- const int w, const int h,
- const ImageRect &restrict imgRect)
- restrict2
-{
- ImageVertexes *vert = nullptr;
- Image *const image = imgRect.grid[4];
- if (!image)
- return;
- if (vertCol->currentImage != image)
- {
- vert = new ImageVertexes;
- vertCol->currentImage = image;
- vertCol->currentVert = vert;
- vert->image = image;
- vertCol->draws.push_back(vert);
- }
- else
- {
- vert = vertCol->currentVert;
- }
- calcImageRect(vert, x, y, w, h, imgRect);
-}
-
-int SDL2SoftwareGraphics::SDL_FakeUpperBlit(const SDL_Surface *restrict const
- src,
- SDL_Rect *restrict const srcrect,
- const SDL_Surface *restrict const
- dst,
- SDL_Rect *restrict dstrect)
- const restrict2
-{
- int srcx, srcy, w, h;
-
- // Make sure the surfaces aren't locked
- if (!src || !dst)
- return -1;
-
- if (!srcrect || !dstrect)
- return -1;
-
- srcx = srcrect->x;
- w = srcrect->w;
- if (srcx < 0)
- {
- w += srcx;
- dstrect->x -= CAST_S16(srcx);
- srcx = 0;
- }
- int maxw = src->w - srcx;
- if (maxw < w)
- w = maxw;
-
- srcy = srcrect->y;
- h = srcrect->h;
- if (srcy < 0)
- {
- h += srcy;
- dstrect->y -= CAST_S16(srcy);
- srcy = 0;
- }
- int maxh = src->h - srcy;
- if (maxh < h)
- h = maxh;
-
- const SDL_Rect *const clip = &dst->clip_rect;
- const int clipX = clip->x;
- const int clipY = clip->y;
- int dx = clipX - dstrect->x;
- if (dx > 0)
- {
- w -= dx;
- dstrect->x += CAST_S16(dx);
- srcx += dx;
- }
- dx = dstrect->x + w - clipX - clip->w;
- if (dx > 0)
- w -= dx;
-
- int dy = clipY - dstrect->y;
- if (dy > 0)
- {
- h -= dy;
- dstrect->y += CAST_S16(dy);
- srcy += dy;
- }
- dy = dstrect->y + h - clipY - clip->h;
- if (dy > 0)
- h -= dy;
-
- if (w > 0 && h > 0)
- {
- if (srcrect)
- {
- srcrect->x = CAST_S16(srcx);
- srcrect->y = CAST_S16(srcy);
- srcrect->w = CAST_S16(w);
- srcrect->h = CAST_S16(h);
- }
- dstrect->w = CAST_S16(w);
- dstrect->h = CAST_S16(h);
-
- return 1;
-// return SDL_LowerBlit(src, &sr, dst, dstrect);
- }
- dstrect->w = dstrect->h = 0;
- return 0;
-}
-
-void SDL2SoftwareGraphics::fillRectangle(const Rect &restrict rectangle)
- restrict2
-{
- FUNC_BLOCK("Graphics::fillRectangle", 1)
- if (mClipStack.empty())
- return;
-
- const ClipRect& top = mClipStack.top();
-
- Rect area = rectangle;
- area.x += top.xOffset;
- area.y += top.yOffset;
-
- if (!area.isIntersecting(top))
- return;
-
- if (mAlpha)
- {
- const int x1 = area.x > top.x ? area.x : top.x;
- const int y1 = area.y > top.y ? area.y : top.y;
- const int x2 = area.x + area.width < top.x + top.width ?
- area.x + area.width : top.x + top.width;
- const int y2 = area.y + area.height < top.y + top.height ?
- area.y + area.height : top.y + top.height;
- int x, y;
-
- SDL_LockSurface(mSurface);
-
- const int bpp = mSurface->format->BytesPerPixel;
- const uint32_t pixel = SDL_MapRGB(mSurface->format,
- CAST_U8(mColor.r), CAST_U8(mColor.g),
- CAST_U8(mColor.b));
-
- switch (bpp)
- {
- case 1:
- for (y = y1; y < y2; y++)
- {
- uint8_t *const p = static_cast<uint8_t *>(mSurface->pixels)
- + y * mSurface->pitch;
- for (x = x1; x < x2; x++)
- *(p + x) = CAST_U8(pixel);
- }
- break;
- case 2:
- for (y = y1; y < y2; y++)
- {
- uint8_t *const p0 = static_cast<uint8_t *>(
- mSurface->pixels) + y * mSurface->pitch;
- for (x = x1; x < x2; x++)
- {
- uint8_t *const p = p0 + x * 2;
- *reinterpret_cast<uint16_t *>(p) = SDLAlpha16(
- CAST_U16(pixel),
- *reinterpret_cast<uint16_t *>(p),
- CAST_U8(mColor.a), mSurface->format);
- }
- }
- break;
- case 3:
- {
- const int ca = 255 - mColor.a;
- const int cr = mColor.r * mColor.a;
- const int cg = mColor.g * mColor.a;
- const int cb = mColor.b * mColor.a;
-
- for (y = y1; y < y2; y++)
- {
- uint8_t *const p0 = static_cast<uint8_t *>(
- mSurface->pixels) + y * mSurface->pitch;
- for (x = x1; x < x2; x++)
- {
- uint8_t *const p = p0 + x * 3;
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- p[2] = CAST_U8((p[2] * ca + cb) >> 8);
- p[1] = CAST_U8((p[1] * ca + cg) >> 8);
- p[0] = CAST_U8((p[0] * ca + cr) >> 8);
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- p[0] = CAST_U8((p[0] * ca + cb) >> 8);
- p[1] = CAST_U8((p[1] * ca + cg) >> 8);
- p[2] = CAST_U8((p[2] * ca + cr) >> 8);
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
- }
- }
- break;
- }
- case 4:
- {
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- const unsigned pb = (pixel & 0xff) * mColor.a;
- const unsigned pg = (pixel & 0xff00) * mColor.a;
- const unsigned pr = (pixel & 0xff0000) * mColor.a;
- const unsigned a1 = (255 - mColor.a);
-
- for (y = y1; y < y2; y++)
- {
- uint8_t *const p0 = static_cast<uint8_t *>(
- mSurface->pixels) + y * mSurface->pitch;
- for (x = x1; x < x2; x++)
- {
- uint8_t *p = p0 + x * 4;
- uint32_t dst = *reinterpret_cast<uint32_t *>(p);
- const unsigned int b = (pb + (dst & 0xff) * a1) >> 8;
- const unsigned int g = (pg + (dst & 0xff00) * a1) >> 8;
- const unsigned int r = (pr
- + (dst & 0xff0000) * a1) >> 8;
-
- *reinterpret_cast<uint32_t *>(p) = ((b & 0xff)
- | (g & 0xff00) | (r & 0xff0000));
- }
- }
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- if (!cR)
- {
- cR = new unsigned int[0x100];
- cG = new unsigned int[0x100];
- cB = new unsigned int[0x100];
- mOldPixel = 0;
- mOldAlpha = mColor.a;
- }
-
- const SDL_PixelFormat * const format = mSurface->format;
- const unsigned rMask = format->Rmask;
- const unsigned gMask = format->Gmask;
- const unsigned bMask = format->Bmask;
-// const unsigned aMask = format->Amask;
- unsigned rShift = rMask / 0xff;
- unsigned gShift = gMask / 0xff;
- unsigned bShift = bMask / 0xff;
- if (!rShift)
- rShift = 1;
- if (!gShift)
- gShift = 1;
- if (!bShift)
- bShift = 1;
- if (pixel != mOldPixel || mColor.a != mOldAlpha)
- {
- const unsigned pb = (pixel & bMask) * mColor.a;
- const unsigned pg = (pixel & gMask) * mColor.a;
- const unsigned pr = (pixel & rMask) * mColor.a;
- const unsigned a0 = (255 - mColor.a);
-
- const unsigned int a1 = a0 * bShift;
- const unsigned int a2 = a0 * gShift;
- const unsigned int a3 = a0 * rShift;
-
- for (int f = 0; f <= 0xff; f ++)
- {
- cB[f] = ((pb + f * a1) >> 8) & bMask;
- cG[f] = ((pg + f * a2) >> 8) & gMask;
- cR[f] = ((pr + f * a3) >> 8) & rMask;
- }
-
- mOldPixel = pixel;
- mOldAlpha = mColor.a;
- }
-
- for (y = y1; y < y2; y++)
- {
- uint32_t *const p0 = reinterpret_cast<uint32_t*>(
- static_cast<uint8_t*>(mSurface->pixels)
- + y * mSurface->pitch);
- for (x = x1; x < x2; x++)
- {
- uint32_t *const p = p0 + x;
- const uint32_t dst = *p;
- *p = cB[dst & bMask / bShift]
- | cG[(dst & gMask) / gShift]
- | cR[(dst & rMask) / rShift];
- }
- }
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- break;
- }
- default:
- break;
- }
-
- SDL_UnlockSurface(mSurface);
- }
- else
- {
- defRectFromArea(rect, area);
- const uint32_t color = SDL_MapRGBA(mSurface->format,
- CAST_S8(mColor.r),
- CAST_S8(mColor.g),
- CAST_S8(mColor.b),
- CAST_S8(mColor.a));
- SDL_FillRect(mSurface, &rect, color);
- }
-}
-
-void SDL2SoftwareGraphics::beginDraw() restrict2
-{
- pushClipArea(Rect(0, 0, mRect.w, mRect.h));
-}
-
-void SDL2SoftwareGraphics::endDraw() restrict2
-{
- popClipArea();
-}
-
-void SDL2SoftwareGraphics::pushClipArea(const Rect &restrict area) restrict2
-{
- Graphics::pushClipArea(area);
-
- const ClipRect &carea = mClipStack.top();
- defRectFromArea(rect, carea);
- SDL_SetClipRect(mSurface, &rect);
-}
-
-void SDL2SoftwareGraphics::popClipArea() restrict2
-{
- Graphics::popClipArea();
-
- if (mClipStack.empty())
- return;
-
- const ClipRect &carea = mClipStack.top();
- defRectFromArea(rect, carea);
- SDL_SetClipRect(mSurface, &rect);
-}
-
-void SDL2SoftwareGraphics::drawPoint(int x, int y) restrict2
-{
- if (mClipStack.empty())
- return;
-
- const ClipRect& top = mClipStack.top();
-
- x += top.xOffset;
- y += top.yOffset;
-
- if (!top.isPointInRect(x, y))
- return;
-
- if (mAlpha)
- SDLputPixelAlpha(mSurface, x, y, mColor);
- else
- SDLputPixel(mSurface, x, y, mColor);
-}
-
-void SDL2SoftwareGraphics::drawHLine(int x1, int y, int x2) restrict2
-{
- if (mClipStack.empty())
- return;
-
- const ClipRect& top = mClipStack.top();
-
- const int xOffset = top.xOffset;
- x1 += xOffset;
- y += top.yOffset;
- x2 += xOffset;
-
- const int topY = top.y;
- if (y < topY || y >= topY + top.height)
- return;
-
- if (x1 > x2)
- {
- x1 ^= x2;
- x2 ^= x1;
- x1 ^= x2;
- }
-
- const int topX = top.x;
- if (topX > x1)
- {
- if (topX > x2)
- return;
-
- x1 = topX;
- }
-
- const int sumX = topX + top.width;
- if (sumX <= x2)
- {
- if (sumX <= x1)
- return;
-
- x2 = sumX -1;
- }
-
- const int bpp = mSurface->format->BytesPerPixel;
-
- SDL_LockSurface(mSurface);
-
- uint8_t *p = static_cast<uint8_t*>(mSurface->pixels)
- + y * mSurface->pitch + x1 * bpp;
-
- const uint32_t pixel = SDL_MapRGB(mSurface->format,
- CAST_U8(mColor.r),
- CAST_U8(mColor.g),
- CAST_U8(mColor.b));
- switch (bpp)
- {
- case 1:
- for (; x1 <= x2; ++x1)
- *(p++) = CAST_U8(pixel);
- break;
-
- case 2:
- {
- uint16_t* q = reinterpret_cast<uint16_t*>(p);
- const uint16_t pixel1 = CAST_U16(pixel);
- for (; x1 <= x2; ++x1)
- *(q++) = pixel1;
- break;
- }
-
- case 3:
- {
- const uint8_t b0 = CAST_U8((pixel >> 16) & 0xff);
- const uint8_t b1 = CAST_U8((pixel >> 8) & 0xff);
- const uint8_t b2 = CAST_U8(pixel & 0xff);
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- for (; x1 <= x2; ++x1)
- {
- p[0] = b0;
- p[1] = b1;
- p[2] = b2;
- p += 3;
- }
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- for (; x1 <= x2; ++x1)
- {
- p[0] = b2;
- p[1] = b1;
- p[2] = b0;
- p += 3;
- }
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- break;
- }
-
- case 4:
- {
- uint32_t *q = reinterpret_cast<uint32_t*>(p);
- if (mAlpha)
- {
- unsigned char a = CAST_U8(mColor.a);
- unsigned char a1 = CAST_U8(255U - a);
- const int b0 = (pixel & 0xff) * a;
- const int g0 = (pixel & 0xff00) * a;
- const int r0 = (pixel & 0xff0000) * a;
- for (; x1 <= x2; ++x1)
- {
- const unsigned int b = (b0 + (*q & 0xff) * a1) >> 8;
- const unsigned int g = (g0 + (*q & 0xff00) * a1) >> 8;
- const unsigned int r = (r0 + (*q & 0xff0000) * a1) >> 8;
- *q = (b & 0xff) | (g & 0xff00) | (r & 0xff0000);
-
- q++;
- }
- }
- else
- {
- for (; x1 <= x2; ++x1)
- *(q++) = pixel;
- }
- break;
- }
- default:
- break;
- } // end switch
-
- SDL_UnlockSurface(mSurface);
-}
-
-void SDL2SoftwareGraphics::drawVLine(int x, int y1, int y2) restrict2
-{
- if (mClipStack.empty())
- return;
-
- const ClipRect& top = mClipStack.top();
-
- const int yOffset = top.yOffset;
- x += top.xOffset;
- y1 += yOffset;
- y2 += yOffset;
-
- if (x < top.x || x >= top.x + top.width)
- return;
-
- if (y1 > y2)
- {
- y1 ^= y2;
- y2 ^= y1;
- y1 ^= y2;
- }
-
- if (top.y > y1)
- {
- if (top.y > y2)
- return;
-
- y1 = top.y;
- }
-
- const int sumY = top.y + top.height;
- if (sumY <= y2)
- {
- if (sumY <= y1)
- return;
-
- y2 = sumY - 1;
- }
-
- const int bpp = mSurface->format->BytesPerPixel;
-
- SDL_LockSurface(mSurface);
-
- uint8_t *p = static_cast<uint8_t*>(mSurface->pixels)
- + y1 * mSurface->pitch + x * bpp;
-
- const uint32_t pixel = SDL_MapRGB(mSurface->format,
- CAST_U8(mColor.r),
- CAST_U8(mColor.g),
- CAST_U8(mColor.b));
-
- const int pitch = mSurface->pitch;
- switch (bpp)
- {
- case 1:
- for (; y1 <= y2; ++y1)
- {
- *p = CAST_U8(pixel);
- p += pitch;
- }
- break;
-
- case 2:
- for (; y1 <= y2; ++ y1)
- {
- *reinterpret_cast<uint16_t*>(p)
- = CAST_U16(pixel);
- p += pitch;
- }
- break;
-
- case 3:
- {
- const uint8_t b0 = CAST_U8((pixel >> 16) & 0xff);
- const uint8_t b1 = CAST_U8((pixel >> 8) & 0xff);
- const uint8_t b2 = CAST_U8(pixel & 0xff);
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- for (; y1 <= y2; ++y1)
- {
- p[0] = b0;
- p[1] = b1;
- p[2] = b2;
- p += pitch;
- }
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- for (; y1 <= y2; ++y1)
- {
- p[0] = b2;
- p[1] = b1;
- p[2] = b0;
- p += pitch;
- }
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- break;
- }
-
- case 4:
- {
- if (mAlpha)
- {
- unsigned char a = CAST_U8(mColor.a);
- unsigned char a1 = CAST_U8(255U - a);
- const int b0 = (pixel & 0xff) * a;
- const int g0 = (pixel & 0xff00) * a;
- const int r0 = (pixel & 0xff0000) * a;
- for (; y1 <= y2; ++y1)
- {
- const unsigned int dst = *reinterpret_cast<uint32_t*>(p);
- const unsigned int b = (b0 + (dst & 0xff) * a1) >> 8;
- const unsigned int g = (g0 + (dst & 0xff00) * a1) >> 8;
- const unsigned int r = (r0 + (dst & 0xff0000) * a1) >> 8;
- *reinterpret_cast<uint32_t*>(p) =
- (b & 0xff) | (g & 0xff00) | (r & 0xff0000);
-
- p += pitch;
- }
- }
- else
- {
- for (; y1 <= y2; ++y1)
- {
- *reinterpret_cast<uint32_t*>(p) = pixel;
- p += pitch;
- }
- }
- break;
- }
-
- default:
- break;
- } // end switch
-
- SDL_UnlockSurface(mSurface);
-}
-
-void SDL2SoftwareGraphics::drawRectangle(const Rect &restrict rectangle)
- restrict2
-{
- const int x1 = rectangle.x;
- const int x2 = x1 + rectangle.width - 1;
- const int y1 = rectangle.y;
- const int y2 = y1 + rectangle.height - 1;
-
- drawHLine(x1, y1, x2);
- drawHLine(x1, y2, x2);
-
- drawVLine(x1, y1, y2);
- drawVLine(x2, y1, y2);
-}
-
-void SDL2SoftwareGraphics::drawLine(int x1, int y1,
- int x2, int y2) restrict2
-{
- if (x1 == x2)
- {
- drawVLine(x1, y1, y2);
- return;
- }
- if (y1 == y2)
- {
- drawHLine(x1, y1, x2);
- return;
- }
-}
-
-bool SDL2SoftwareGraphics::setVideoMode(const int w, const int h,
- const int scale,
- const int bpp,
- const bool fs,
- const bool hwaccel,
- const bool resize,
- const bool noFrame,
- const bool allowHighDPI) restrict2
-{
- setMainFlags(w, h,
- scale,
- bpp,
- fs,
- hwaccel,
- resize,
- noFrame,
- allowHighDPI);
-
- if (!(mWindow = graphicsManager.createWindow(w, h, bpp,
- getSoftwareFlags())))
- {
- mRect.w = 0;
- mRect.h = 0;
- mSurface = nullptr;
- return false;
- }
-
- mSurface = SDL_GetWindowSurface(mWindow);
- ImageHelper::dumpSurfaceFormat(mSurface);
- SDL2SoftwareImageHelper::setFormat(mSurface->format);
-
- int w1 = 0;
- int h1 = 0;
- SDL_GetWindowSize(mWindow, &w1, &h1);
- mRect.w = w1;
- mRect.h = h1;
-
- mRenderer = graphicsManager.createRenderer(mWindow, mRendererFlags);
- return videoInfo();
-}
-
-bool SDL2SoftwareGraphics::resizeScreen(const int width,
- const int height) restrict2
-{
- const bool ret = Graphics::resizeScreen(width, height);
-
- mSurface = SDL_GetWindowSurface(mWindow);
- SDL2SoftwareImageHelper::setFormat(mSurface->format);
- return ret;
-}
-
-void SDL2SoftwareGraphics::drawImageRect(const int x, const int y,
- const int w, const int h,
- const ImageRect &restrict imgRect)
- restrict2
-{
- #include "render/graphics_drawImageRect.hpp"
-}
-
-void SDL2SoftwareGraphics::calcImageRect(ImageVertexes *restrict const vert,
- const int x, const int y,
- const int w, const int h,
- const ImageRect &restrict imgRect)
- restrict2
-{
- #include "render/graphics_calcImageRect.hpp"
-}
-
-#endif // USE_SDL2
diff --git a/src/render/sdl2softwaregraphics.h b/src/render/sdl2softwaregraphics.h
deleted file mode 100644
index 438b02674..000000000
--- a/src/render/sdl2softwaregraphics.h
+++ /dev/null
@@ -1,89 +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 RENDER_SDL2SOFTWAREGRAPHICS_H
-#define RENDER_SDL2SOFTWAREGRAPHICS_H
-
-#ifdef USE_SDL2
-
-#include "render/graphics.h"
-
-#include "localconsts.h"
-
-class Image;
-class ImageCollection;
-class ImageVertexes;
-class MapLayer;
-
-struct SDL_Surface;
-
-/**
- * A central point of control for graphics.
- */
-class SDL2SoftwareGraphics final : public Graphics
-{
- public:
- friend class Sdl2SoftwareScreenshotHelper;
-
- /**
- * Constructor.
- */
- SDL2SoftwareGraphics();
-
- A_DELETE_COPY(SDL2SoftwareGraphics)
-
- /**
- * Destructor.
- */
- ~SDL2SoftwareGraphics();
-
- void setRendererFlags(const uint32_t flags)
- restrict2 noexcept2 override final
- { mRendererFlags = flags; }
-
- #include "render/graphicsdef.hpp"
- RENDER_GRAPHICSDEF_HPP
-
- #include "render/softwaregraphicsdef.hpp"
- RENDER_SOFTWAREGRAPHICSDEF_HPP
-
- bool resizeScreen(const int width,
- const int height) restrict2 override final;
-
- protected:
- int SDL_FakeUpperBlit(const SDL_Surface *restrict const src,
- SDL_Rect *restrict const srcrect,
- const SDL_Surface *restrict const dst,
- SDL_Rect *restrict dstrect) const restrict2;
-
- void drawHLine(int x1, int y, int x2) restrict2;
-
- void drawVLine(int x, int y1, int y2) restrict2;
-
- uint32_t mRendererFlags;
- SDL_Surface *mSurface;
- uint32_t mOldPixel;
- unsigned int mOldAlpha;
-};
-
-#endif // USE_SDL2
-#endif // RENDER_SDL2SOFTWAREGRAPHICS_H
diff --git a/src/render/sdlgraphics.cpp b/src/render/sdlgraphics.cpp
deleted file mode 100644
index b67e23d8e..000000000
--- a/src/render/sdlgraphics.cpp
+++ /dev/null
@@ -1,1518 +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 "render/sdlgraphics.h"
-
-#include "graphicsmanager.h"
-
-#include "utils/sdlcheckutils.h"
-
-#include "utils/sdlpixel.h"
-
-#include "render/vertexes/imagecollection.h"
-
-#include "resources/imagerect.h"
-
-#include "resources/image/image.h"
-
-#include "debug.h"
-
-#ifndef SDL_BIG_ENDIAN
-#error missing SDL_endian.h
-#endif // SDL_BYTEORDER
-
-#if SDL_BYTEORDER == SDL_LIL_ENDIAN
-static unsigned int *cR = nullptr;
-static unsigned int *cG = nullptr;
-static unsigned int *cB = nullptr;
-#endif // SDL_BYTEORDER == SDL_LIL_ENDIAN
-
-SDLGraphics::SDLGraphics() :
- Graphics(),
- mOldPixel(0),
- mOldAlpha(0)
-{
- mOpenGL = RENDER_SOFTWARE;
- mName = "Software";
-}
-
-SDLGraphics::~SDLGraphics()
-{
-}
-
-void SDLGraphics::drawRescaledImage(const Image *restrict const image,
- int dstX, int dstY,
- const int desiredWidth,
- const int desiredHeight) restrict2
-{
- FUNC_BLOCK("Graphics::drawRescaledImage", 1)
- // Check that preconditions for blitting are met.
- if (mWindow == nullptr ||
- image == nullptr ||
- image->mSDLSurface == nullptr)
- {
- return;
- }
-
- Image *const tmpImage = image->SDLgetScaledImage(
- desiredWidth, desiredHeight);
-
- if ((tmpImage == nullptr) || (tmpImage->mSDLSurface == nullptr))
- return;
-
- const ClipRect &top = mClipStack.top();
- const SDL_Rect &bounds = image->mBounds;
-
- SDL_Rect srcRect =
- {
- CAST_S16(bounds.x),
- CAST_S16(bounds.y),
- CAST_U16(bounds.w),
- CAST_U16(bounds.h)
- };
-
- SDL_Rect dstRect =
- {
- CAST_S16(dstX + top.xOffset),
- CAST_S16(dstY + top.yOffset),
- 0,
- 0
- };
-
- SDL_BlitSurface(tmpImage->mSDLSurface, &srcRect, mWindow, &dstRect);
- delete tmpImage;
-}
-
-void SDLGraphics::drawImage(const Image *restrict const image,
- int dstX, int dstY) restrict2
-{
- drawImageInline(image, dstX, dstY);
-}
-
-void SDLGraphics::drawImageInline(const Image *restrict const image,
- int dstX, int dstY) restrict2
-{
- FUNC_BLOCK("Graphics::drawImage", 1)
- // Check that preconditions for blitting are met.
- if (mWindow == nullptr ||
- image == nullptr ||
- image->mSDLSurface == nullptr)
- {
- return;
- }
-
- const ClipRect &top = mClipStack.top();
- const SDL_Rect &bounds = image->mBounds;
-
- SDL_Surface *const src = image->mSDLSurface;
-
- int srcX = bounds.x;
- int srcY = bounds.y;
- dstX += top.xOffset;
- dstY += top.yOffset;
-
- int w = bounds.w;
- int h = bounds.h;
- if (srcX < 0)
- {
- w += srcX;
- dstX -= CAST_S16(srcX);
- srcX = 0;
- }
- const int maxw = src->w - srcX;
- if (maxw < w)
- w = maxw;
-
- if (srcY < 0)
- {
- h += srcY;
- dstY -= CAST_S16(srcY);
- srcY = 0;
- }
- const int maxh = src->h - srcY;
- if (maxh < h)
- h = maxh;
-
- const SDL_Rect *const clip = &mWindow->clip_rect;
- const int clipX = clip->x;
- const int clipY = clip->y;
- int dx = clipX - dstX;
- if (dx > 0)
- {
- w -= dx;
- dstX += CAST_S16(dx);
- srcX += dx;
- }
- dx = dstX + w - clipX - clip->w;
- if (dx > 0)
- w -= dx;
-
- int dy = clipY - dstY;
- if (dy > 0)
- {
- h -= dy;
- dstY += CAST_S16(dy);
- srcY += dy;
- }
- dy = dstY + h - clipY - clip->h;
- if (dy > 0)
- h -= dy;
-
- if (w > 0 && h > 0)
- {
- SDL_Rect srcRect =
- {
- CAST_S16(srcX),
- CAST_S16(srcY),
- CAST_U16(w),
- CAST_U16(h)
- };
-
- SDL_Rect dstRect =
- {
- CAST_S16(dstX),
- CAST_S16(dstY),
- CAST_U16(w),
- CAST_U16(h)
- };
-
- SDL_LowerBlit(src, &srcRect, mWindow, &dstRect);
- }
-}
-
-void SDLGraphics::copyImage(const Image *restrict const image,
- int dstX, int dstY) restrict2
-{
- drawImageInline(image, dstX, dstY);
-}
-
-void SDLGraphics::drawImageCached(const Image *restrict const image,
- int x, int y) restrict2
-{
- FUNC_BLOCK("Graphics::drawImageCached", 1)
- // Check that preconditions for blitting are met.
- if (mWindow == nullptr ||
- image == nullptr ||
- image->mSDLSurface == nullptr)
- {
- return;
- }
-
- const ClipRect &top = mClipStack.top();
- const SDL_Rect &bounds = image->mBounds;
-
- SDL_Surface *const src = image->mSDLSurface;
-
- int srcX = bounds.x;
- int srcY = bounds.y;
- x += top.xOffset;
- y += top.yOffset;
-
- int w = bounds.w;
- int h = bounds.h;
- if (srcX < 0)
- {
- w += srcX;
- x -= CAST_S16(srcX);
- srcX = 0;
- }
- const int maxw = src->w - srcX;
- if (maxw < w)
- w = maxw;
-
- if (srcY < 0)
- {
- h += srcY;
- y -= CAST_S16(srcY);
- srcY = 0;
- }
- const int maxh = src->h - srcY;
- if (maxh < h)
- h = maxh;
-
- const SDL_Rect *const clip = &mWindow->clip_rect;
- const int clipX = clip->x;
- const int clipY = clip->y;
- int dx = clipX - x;
- if (dx > 0)
- {
- w -= dx;
- x += CAST_S16(dx);
- srcX += dx;
- }
- dx = x + w - clipX - clip->w;
- if (dx > 0)
- w -= dx;
-
- int dy = clipY - y;
- if (dy > 0)
- {
- h -= dy;
- y += CAST_S16(dy);
- srcY += dy;
- }
- dy = y + h - clipY - clip->h;
- if (dy > 0)
- h -= dy;
-
- if (w > 0 && h > 0)
- {
- SDL_Rect srcRect =
- {
- CAST_S16(srcX),
- CAST_S16(srcY),
- CAST_U16(w),
- CAST_U16(h)
- };
-
- SDL_Rect dstRect =
- {
- CAST_S16(x),
- CAST_S16(y),
- CAST_U16(w),
- CAST_U16(h)
- };
-
- SDL_LowerBlit(src, &srcRect, mWindow, &dstRect);
- }
-}
-
-void SDLGraphics::drawPatternCached(const Image *restrict const image,
- const int x, const int y,
- const int w, const int h) restrict2
-{
- FUNC_BLOCK("Graphics::drawPatternCached", 1)
- // Check that preconditions for blitting are met.
- if ((mWindow == nullptr) || (image == nullptr))
- return;
- if (image->mSDLSurface == nullptr)
- return;
-
- const SDL_Rect &bounds = image->mBounds;
- const int iw = bounds.w;
- const int ih = bounds.h;
- if (iw == 0 || ih == 0)
- return;
-
- const ClipRect &top = mClipStack.top();
- const int xOffset = top.xOffset + x;
- const int yOffset = top.yOffset + y;
- const int srcX = bounds.x;
- const int srcY = bounds.y;
- SDL_Surface *const src = image->mSDLSurface;
- const SDL_Rect *const clip = &mWindow->clip_rect;
- const int clipX = clip->x;
- const int clipY = clip->y;
-
- for (int py = 0; py < h; py += ih)
- {
- const int dh = (py + ih >= h) ? h - py : ih;
- int dstY = py + yOffset;
- int y2 = srcY;
- int h2 = dh;
- if (y2 < 0)
- {
- h2 += y2;
- dstY -= CAST_S16(y2);
- y2 = 0;
- }
- const int maxh = src->h - y2;
- if (maxh < h2)
- h2 = maxh;
-
- int dy = clipY - dstY;
- if (dy > 0)
- {
- h2 -= dy;
- dstY += CAST_S16(dy);
- y2 += dy;
- }
- dy = dstY + h2 - clipY - clip->h;
- if (dy > 0)
- h2 -= dy;
-
- if (h2 > 0)
- {
- for (int px = 0; px < w; px += iw)
- {
- const int dw = (px + iw >= w) ? w - px : iw;
- int dstX = px + xOffset;
- int x2 = srcX;
- int w2 = dw;
- if (x2 < 0)
- {
- w2 += x2;
- dstX -= CAST_S16(x2);
- x2 = 0;
- }
- const int maxw = src->w - x2;
- if (maxw < w2)
- w2 = maxw;
-
- int dx = clipX - dstX;
- if (dx > 0)
- {
- w2 -= dx;
- dstX += CAST_S16(dx);
- x2 += dx;
- }
- dx = dstX + w2 - clipX - clip->w;
- if (dx > 0)
- w2 -= dx;
-
- if (w2 > 0)
- {
- SDL_Rect srcRect =
- {
- CAST_S16(x2),
- CAST_S16(y2),
- CAST_U16(w2),
- CAST_U16(h2)
- };
-
- SDL_Rect dstRect =
- {
- CAST_S16(dstX),
- CAST_S16(dstY),
- CAST_U16(w2),
- CAST_U16(h2)
- };
-
- SDL_LowerBlit(src, &srcRect, mWindow, &dstRect);
- }
-
-// SDL_BlitSurface(image->mSDLSurface, &srcRect, mWindow, &dstRect);
- }
- }
- }
-}
-
-void SDLGraphics::completeCache() restrict2
-{
-}
-
-void SDLGraphics::drawPattern(const Image *restrict const image,
- const int x, const int y,
- const int w, const int h) restrict2
-{
- drawPatternInline(image, x, y, w, h);
-}
-
-void SDLGraphics::drawPatternInline(const Image *restrict const image,
- const int x, const int y,
- const int w, const int h) restrict2
-{
- FUNC_BLOCK("Graphics::drawPattern", 1)
- // Check that preconditions for blitting are met.
- if ((mWindow == nullptr) || (image == nullptr))
- return;
- if (image->mSDLSurface == nullptr)
- return;
-
- const SDL_Rect &bounds = image->mBounds;
- const int iw = bounds.w;
- const int ih = bounds.h;
- if (iw == 0 || ih == 0)
- return;
-
- const ClipRect &top = mClipStack.top();
- const int xOffset = top.xOffset + x;
- const int yOffset = top.yOffset + y;
- const int srcX = bounds.x;
- const int srcY = bounds.y;
- SDL_Surface *const src = image->mSDLSurface;
- const SDL_Rect *const clip = &mWindow->clip_rect;
- const int clipX = clip->x;
- const int clipY = clip->y;
-
- for (int py = 0; py < h; py += ih)
- {
- const int dh = (py + ih >= h) ? h - py : ih;
- int dstY = py + yOffset;
- int y2 = srcY;
- int h2 = dh;
- if (y2 < 0)
- {
- h2 += y2;
- dstY -= CAST_S16(y2);
- y2 = 0;
- }
- const int maxh = src->h - y2;
- if (maxh < h2)
- h2 = maxh;
-
- int dy = clipY - dstY;
- if (dy > 0)
- {
- h2 -= dy;
- dstY += CAST_S16(dy);
- y2 += dy;
- }
- dy = dstY + h2 - clipY - clip->h;
- if (dy > 0)
- h2 -= dy;
-
- if (h2 > 0)
- {
- for (int px = 0; px < w; px += iw)
- {
- const int dw = (px + iw >= w) ? w - px : iw;
- int dstX = px + xOffset;
- int x2 = srcX;
- int w2 = dw;
- if (x2 < 0)
- {
- w2 += x2;
- dstX -= CAST_S16(x2);
- x2 = 0;
- }
- const int maxw = src->w - x2;
- if (maxw < w2)
- w2 = maxw;
-
- int dx = clipX - dstX;
- if (dx > 0)
- {
- w2 -= dx;
- dstX += CAST_S16(dx);
- x2 += dx;
- }
- dx = dstX + w2 - clipX - clip->w;
- if (dx > 0)
- w2 -= dx;
-
- if (w2 > 0)
- {
- SDL_Rect srcRect =
- {
- CAST_S16(x2),
- CAST_S16(y2),
- CAST_U16(w2),
- CAST_U16(h2)
- };
-
- SDL_Rect dstRect =
- {
- CAST_S16(dstX),
- CAST_S16(dstY),
- CAST_U16(w2),
- CAST_U16(h2)
- };
-
- SDL_LowerBlit(src, &srcRect, mWindow, &dstRect);
- }
-
-// SDL_BlitSurface(image->mSDLSurface, &srcRect, mWindow, &dstRect);
- }
- }
- }
-}
-
-void SDLGraphics::drawRescaledPattern(const Image *restrict const image,
- const int x, const int y,
- const int w, const int h,
- const int scaledWidth,
- const int scaledHeight) restrict2
-{
- // Check that preconditions for blitting are met.
- if ((mWindow == nullptr) || (image == nullptr))
- return;
- if (image->mSDLSurface == nullptr)
- return;
-
- if (scaledHeight == 0 || scaledWidth == 0)
- return;
-
- Image *const tmpImage = image->SDLgetScaledImage(
- scaledWidth, scaledHeight);
- if (tmpImage == nullptr)
- return;
-
- const SDL_Rect &bounds = tmpImage->mBounds;
- const int iw = bounds.w;
- const int ih = bounds.h;
- if (iw == 0 || ih == 0)
- return;
-
- const ClipRect &top = mClipStack.top();
- const int xOffset = top.xOffset + x;
- const int yOffset = top.yOffset + y;
- const int srcX = bounds.x;
- const int srcY = bounds.y;
-
- for (int py = 0; py < h; py += ih) // Y position on pattern plane
- {
- const int dh = (py + ih >= h) ? h - py : ih;
- const int dstY = py + yOffset;
-
- for (int px = 0; px < w; px += iw) // X position on pattern plane
- {
- const int dw = (px + iw >= w) ? w - px : iw;
- const int dstX = px + xOffset;
-
- SDL_Rect srcRect =
- {
- CAST_S16(srcX),
- CAST_S16(srcY),
- CAST_U16(dw),
- CAST_U16(dh)
- };
-
- SDL_Rect dstRect =
- {
- CAST_S16(dstX),
- CAST_S16(dstY),
- 0,
- 0
- };
-
- SDL_BlitSurface(tmpImage->mSDLSurface, &srcRect,
- mWindow, &dstRect);
- }
- }
-
- delete tmpImage;
-}
-
-void SDLGraphics::calcPattern(ImageVertexes *restrict const vert,
- const Image *restrict const image,
- const int x, const int y,
- const int w, const int h) const restrict2
-{
- calcPatternInline(vert, image, x, y, w, h);
-}
-
-void SDLGraphics::calcPatternInline(ImageVertexes *restrict const vert,
- const Image *restrict const image,
- const int x, const int y,
- const int w, const int h) const restrict2
-{
- // Check that preconditions for blitting are met.
- if (vert == nullptr ||
- mWindow == nullptr ||
- image == nullptr ||
- image->mSDLSurface == nullptr)
- {
- return;
- }
-
- const SDL_Rect &bounds = image->mBounds;
- const int iw = bounds.w;
- const int ih = bounds.h;
- if (iw == 0 || ih == 0)
- return;
-
- const ClipRect &top = mClipStack.top();
- const int xOffset = top.xOffset + x;
- const int yOffset = top.yOffset + y;
- const int srcX = bounds.x;
- const int srcY = bounds.y;
-
- for (int py = 0; py < h; py += ih) // Y position on pattern plane
- {
- const int dh = (py + ih >= h) ? h - py : ih;
- const int dstY = py + yOffset;
-
- for (int px = 0; px < w; px += iw) // X position on pattern plane
- {
- const int dw = (px + iw >= w) ? w - px : iw;
- const int dstX = px + xOffset;
-
- DoubleRect *const r = new DoubleRect;
- SDL_Rect &srcRect = r->src;
- srcRect.x = CAST_S16(srcX);
- srcRect.y = CAST_S16(srcY);
- srcRect.w = CAST_U16(dw);
- srcRect.h = CAST_U16(dh);
- SDL_Rect &dstRect = r->dst;
- dstRect.x = CAST_S16(dstX);
- dstRect.y = CAST_S16(dstY);
-
- if (SDL_FakeUpperBlit(image->mSDLSurface, &srcRect,
- mWindow, &dstRect) == 1)
- {
- vert->sdl.push_back(r);
- }
- else
- {
- delete r;
- }
- }
- }
-}
-
-void SDLGraphics::calcPattern(ImageCollection *restrict const vertCol,
- const Image *restrict const image,
- const int x, const int y,
- const int w, const int h) const restrict2
-{
- if (vertCol == nullptr || image == nullptr)
- return;
-
- ImageVertexes *vert = nullptr;
- if (vertCol->currentImage != image)
- {
- vert = new ImageVertexes;
- vertCol->currentImage = image;
- vertCol->currentVert = vert;
- vert->image = image;
- vertCol->draws.push_back(vert);
- }
- else
- {
- vert = vertCol->currentVert;
- }
-
- calcPatternInline(vert, image, x, y, w, h);
-}
-
-void SDLGraphics::calcTileVertexes(ImageVertexes *restrict const vert,
- const Image *restrict const image,
- int x, int y) const restrict2
-{
- vert->image = image;
- calcTileSDL(vert, x, y);
-}
-
-void SDLGraphics::calcTileVertexesInline(ImageVertexes *restrict const vert,
- const Image *restrict const image,
- int x, int y) const restrict2
-{
- vert->image = image;
- calcTileSDL(vert, x, y);
-}
-
-void SDLGraphics::calcTileSDL(ImageVertexes *restrict const vert,
- int x, int y) const restrict2
-{
- // Check that preconditions for blitting are met.
- if (vert == nullptr ||
- vert->image == nullptr ||
- vert->image->mSDLSurface == nullptr)
- {
- return;
- }
-
- const Image *const image = vert->image;
- const ClipRect &top = mClipStack.top();
- const SDL_Rect &bounds = image->mBounds;
-
- DoubleRect *rect = new DoubleRect;
- rect->src.x = CAST_S16(bounds.x);
- rect->src.y = CAST_S16(bounds.y);
- rect->src.w = CAST_U16(bounds.w);
- rect->src.h = CAST_U16(bounds.h);
- rect->dst.x = CAST_S16(x + top.xOffset);
- rect->dst.y = CAST_S16(y + top.yOffset);
- if (SDL_FakeUpperBlit(image->mSDLSurface, &rect->src,
- mWindow, &rect->dst) == 1)
- {
- vert->sdl.push_back(rect);
- }
- else
- {
- delete rect;
- }
-}
-
-void SDLGraphics::calcTileCollection(ImageCollection *restrict const vertCol,
- const Image *restrict const image,
- int x, int y) restrict2
-{
- if (vertCol == nullptr)
- return;
- if (vertCol->currentImage != image)
- {
- ImageVertexes *const vert = new ImageVertexes;
- vertCol->currentImage = image;
- vertCol->currentVert = vert;
- vert->image = image;
- vertCol->draws.push_back(vert);
- calcTileSDL(vert, x, y);
- }
- else
- {
- calcTileSDL(vertCol->currentVert, x, y);
- }
-}
-
-void SDLGraphics::drawTileCollection(const ImageCollection
- *restrict const vertCol) restrict2
-{
- const ImageVertexesVector &draws = vertCol->draws;
- const ImageCollectionCIter it_end = draws.end();
- for (ImageCollectionCIter it = draws.begin(); it != it_end; ++ it)
- {
- const ImageVertexes *const vert = *it;
- const Image *const img = vert->image;
- const DoubleRects *const rects = &vert->sdl;
- DoubleRects::const_iterator it2 = rects->begin();
- const DoubleRects::const_iterator it2_end = rects->end();
- while (it2 != it2_end)
- {
- SDL_LowerBlit(img->mSDLSurface, &(*it2)->src,
- mWindow, &(*it2)->dst);
- ++ it2;
- }
- }
-}
-
-void SDLGraphics::drawTileVertexes(const ImageVertexes *
- restrict const vert) restrict2
-{
- if (vert == nullptr)
- return;
- // vert and img must be != 0
- const Image *const img = vert->image;
- const DoubleRects *const rects = &vert->sdl;
- DoubleRects::const_iterator it = rects->begin();
- const DoubleRects::const_iterator it_end = rects->end();
- while (it != it_end)
- {
- SDL_LowerBlit(img->mSDLSurface, &(*it)->src, mWindow, &(*it)->dst);
- ++ it;
- }
-}
-
-void SDLGraphics::updateScreen() restrict2
-{
- BLOCK_START("Graphics::updateScreen")
- if (mDoubleBuffer)
- {
- SDL_Flip(mWindow);
- }
- else
- {
- SDL_UpdateRects(mWindow, 1, &mRect);
-// SDL_UpdateRect(mWindow, 0, 0, 0, 0);
- }
- BLOCK_END("Graphics::updateScreen")
-}
-
-void SDLGraphics::calcWindow(ImageCollection *restrict const vertCol,
- const int x, const int y,
- const int w, const int h,
- const ImageRect &restrict imgRect) restrict2
-{
- ImageVertexes *vert = nullptr;
- Image *const image = imgRect.grid[4];
- if (image == nullptr)
- return;
- if (vertCol->currentImage != image)
- {
- vert = new ImageVertexes;
- vertCol->currentImage = image;
- vertCol->currentVert = vert;
- vert->image = image;
- vertCol->draws.push_back(vert);
- }
- else
- {
- vert = vertCol->currentVert;
- }
- calcImageRect(vert, x, y, w, h, imgRect);
-}
-
-int SDLGraphics::SDL_FakeUpperBlit(const SDL_Surface *restrict const src,
- SDL_Rect *restrict const srcrect,
- const SDL_Surface *restrict const dst,
- SDL_Rect *restrict dstrect) const restrict2
-{
- int srcx, srcy, w, h;
-
- // Make sure the surfaces aren't locked
- if ((src == nullptr) || (dst == nullptr))
- return -1;
-
- if ((srcrect == nullptr) || (dstrect == nullptr))
- return -1;
-
- srcx = srcrect->x;
- w = srcrect->w;
- if (srcx < 0)
- {
- w += srcx;
- dstrect->x -= CAST_S16(srcx);
- srcx = 0;
- }
- int maxw = src->w - srcx;
- if (maxw < w)
- w = maxw;
-
- srcy = srcrect->y;
- h = srcrect->h;
- if (srcy < 0)
- {
- h += srcy;
- dstrect->y -= CAST_S16(srcy);
- srcy = 0;
- }
- int maxh = src->h - srcy;
- if (maxh < h)
- h = maxh;
-
- const SDL_Rect *const clip = &dst->clip_rect;
- const int clipX = clip->x;
- const int clipY = clip->y;
- int dx = clipX - dstrect->x;
- if (dx > 0)
- {
- w -= dx;
- dstrect->x += CAST_S16(dx);
- srcx += dx;
- }
- dx = dstrect->x + w - clipX - clip->w;
- if (dx > 0)
- w -= dx;
-
- int dy = clipY - dstrect->y;
- if (dy > 0)
- {
- h -= dy;
- dstrect->y += CAST_S16(dy);
- srcy += dy;
- }
- dy = dstrect->y + h - clipY - clip->h;
- if (dy > 0)
- h -= dy;
-
- if (w > 0 && h > 0)
- {
- srcrect->x = CAST_S16(srcx);
- srcrect->y = CAST_S16(srcy);
- srcrect->w = CAST_S16(w);
- srcrect->h = CAST_S16(h);
- dstrect->w = CAST_S16(w);
- dstrect->h = CAST_S16(h);
-
- return 1;
-// return SDL_LowerBlit(src, &sr, dst, dstrect);
- }
- dstrect->w = dstrect->h = 0;
- return 0;
-}
-
-void SDLGraphics::fillRectangle(const Rect &restrict rectangle) restrict2
-{
- FUNC_BLOCK("Graphics::fillRectangle", 1)
- if (mClipStack.empty())
- return;
-
- const ClipRect &restrict top = mClipStack.top();
-
- Rect area = rectangle;
- area.x += top.xOffset;
- area.y += top.yOffset;
-
- if (!area.isIntersecting(top))
- return;
-
- if (mAlpha)
- {
- const int x1 = area.x > top.x ? area.x : top.x;
- const int y1 = area.y > top.y ? area.y : top.y;
- const int x2 = area.x + area.width < top.x + top.width ?
- area.x + area.width : top.x + top.width;
- const int y2 = area.y + area.height < top.y + top.height ?
- area.y + area.height : top.y + top.height;
-
- SDL_LockSurface(mWindow);
-
- const int bpp = mWindow->format->BytesPerPixel;
- const uint32_t pixel = SDL_MapRGB(mWindow->format,
- CAST_U8(mColor.r), CAST_U8(mColor.g),
- CAST_U8(mColor.b));
-
- switch (bpp)
- {
- case 1:
- cilk_for (int y = y1; y < y2; y++)
- {
- uint8_t *const p = static_cast<uint8_t *>(mWindow->pixels)
- + CAST_SIZE(y * mWindow->pitch);
- for (int x = x1; x < x2; x++)
- {
- *(p + CAST_SIZE(x))
- = CAST_U8(pixel);
- }
- }
- break;
- case 2:
- cilk_for (int y = y1; y < y2; y++)
- {
- uint8_t *const p0 = static_cast<uint8_t *>(mWindow->pixels)
- + CAST_SIZE(y * mWindow->pitch);
- for (int x = x1; x < x2; x++)
- {
- uint8_t *const p = p0 + CAST_SIZE(x * 2);
- *reinterpret_cast<uint16_t *>(p) = SDLAlpha16(
- CAST_U16(pixel),
- *reinterpret_cast<uint16_t *>(p),
- CAST_U8(mColor.a), mWindow->format);
- }
- }
- break;
- case 3:
- {
- const int ca = 255 - mColor.a;
- const int cr = mColor.r * mColor.a;
- const int cg = mColor.g * mColor.a;
- const int cb = mColor.b * mColor.a;
-
- cilk_for (int y = y1; y < y2; y++)
- {
- uint8_t *const p0 = static_cast<uint8_t *>(mWindow->pixels)
- + CAST_SIZE(y * mWindow->pitch);
- for (int x = x1; x < x2; x++)
- {
- uint8_t *const p = p0 + CAST_SIZE(x * 3);
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- p[2] = CAST_U8((p[2] * ca + cb) >> 8);
- p[1] = CAST_U8((p[1] * ca + cg) >> 8);
- p[0] = CAST_U8((p[0] * ca + cr) >> 8);
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
- p[0] = CAST_U8((p[0] * ca + cb) >> 8);
- p[1] = CAST_U8((p[1] * ca + cg) >> 8);
- p[2] = CAST_U8((p[2] * ca + cr) >> 8);
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
- }
- }
- break;
- }
- case 4:
- {
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- const unsigned pb = (pixel & 0xff) * mColor.a;
- const unsigned pg = (pixel & 0xff00) * mColor.a;
- const unsigned pr = (pixel & 0xff0000) * mColor.a;
- const unsigned a1 = (255 - mColor.a);
-
- cilk_for (int y = y1; y < y2; y++)
- {
- uint8_t *const p0 = static_cast<uint8_t *>(mWindow->pixels)
- + y * mWindow->pitch;
- for (int x = x1; x < x2; x++)
- {
- uint8_t *p = p0 + x * 4;
- uint32_t dst = *reinterpret_cast<uint32_t *>(p);
- const unsigned int b = (pb + (dst & 0xff) * a1) >> 8;
- const unsigned int g = (pg + (dst & 0xff00) * a1) >> 8;
- const unsigned int r = (pr
- + (dst & 0xff0000) * a1) >> 8;
-
- *reinterpret_cast<uint32_t *>(p) = ((b & 0xff)
- | (g & 0xff00) | (r & 0xff0000));
- }
- }
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
- if (cR == nullptr)
- {
- cR = new unsigned int[0x100];
- cG = new unsigned int[0x100];
- cB = new unsigned int[0x100];
- mOldPixel = 0;
- mOldAlpha = mColor.a;
- }
-
- const SDL_PixelFormat * const format = mWindow->format;
- const unsigned rMask = format->Rmask;
- const unsigned gMask = format->Gmask;
- const unsigned bMask = format->Bmask;
-// const unsigned aMask = format->Amask;
- unsigned rShift = rMask / 0xff;
- unsigned gShift = gMask / 0xff;
- unsigned bShift = bMask / 0xff;
- if (rShift == 0u)
- rShift = 1;
- if (gShift == 0u)
- gShift = 1;
- if (bShift == 0u)
- bShift = 1;
- if (pixel != mOldPixel || mColor.a != mOldAlpha)
- {
- const unsigned pb = (pixel & bMask) * mColor.a;
- const unsigned pg = (pixel & gMask) * mColor.a;
- const unsigned pr = (pixel & rMask) * mColor.a;
- const unsigned a0 = 255 - mColor.a;
-
- const unsigned int a1 = a0 * bShift;
- const unsigned int a2 = a0 * gShift;
- const unsigned int a3 = a0 * rShift;
-
- for (int f = 0; f <= 0xff; f ++)
- {
- cB[f] = ((pb + f * a1) >> 8) & bMask;
- cG[f] = ((pg + f * a2) >> 8) & gMask;
- cR[f] = ((pr + f * a3) >> 8) & rMask;
- }
-
- mOldPixel = pixel;
- mOldAlpha = mColor.a;
- }
-
- cilk_for (int y = y1; y < y2; y++)
- {
- uint32_t *const p0 = reinterpret_cast<uint32_t*>(
- static_cast<uint8_t*>(mWindow->pixels)
- + CAST_SIZE(y * mWindow->pitch));
- for (int x = x1; x < x2; x++)
- {
- uint32_t *const p = p0 + CAST_SIZE(x);
- const uint32_t dst = *p;
- *p = cB[dst & bMask / bShift]
- | cG[(dst & gMask) / gShift]
- | cR[(dst & rMask) / rShift];
- }
- }
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
- break;
- }
- default:
- break;
- }
-
- SDL_UnlockSurface(mWindow);
- }
- else
- {
- SDL_Rect rect =
- {
- CAST_S16(area.x),
- CAST_S16(area.y),
- CAST_U16(area.width),
- CAST_U16(area.height)
- };
-
- const uint32_t color = SDL_MapRGBA(mWindow->format,
- CAST_S8(mColor.r),
- CAST_S8(mColor.g),
- CAST_S8(mColor.b),
- CAST_S8(mColor.a));
- SDL_FillRect(mWindow, &rect, color);
- }
-}
-
-void SDLGraphics::beginDraw() restrict2
-{
- pushClipArea(Rect(0, 0, mRect.w, mRect.h));
-}
-
-void SDLGraphics::endDraw() restrict2
-{
- popClipArea();
-}
-
-void SDLGraphics::pushClipArea(const Rect &restrict area) restrict2
-{
- Graphics::pushClipArea(area);
- const ClipRect &restrict carea = mClipStack.top();
- const SDL_Rect rect =
- {
- CAST_S16(carea.x),
- CAST_S16(carea.y),
- CAST_U16(carea.width),
- CAST_U16(carea.height)
- };
- SDL_SetClipRect(mWindow, &rect);
-}
-
-void SDLGraphics::popClipArea() restrict2
-{
- Graphics::popClipArea();
-
- if (mClipStack.empty())
- return;
-
- const ClipRect &restrict carea = mClipStack.top();
- const SDL_Rect rect =
- {
- CAST_S16(carea.x),
- CAST_S16(carea.y),
- CAST_U16(carea.width),
- CAST_U16(carea.height)
- };
-
- SDL_SetClipRect(mWindow, &rect);
-}
-
-void SDLGraphics::drawPoint(int x, int y) restrict2
-{
- if (mClipStack.empty())
- return;
-
- const ClipRect& top = mClipStack.top();
-
- x += top.xOffset;
- y += top.yOffset;
-
- if (!top.isPointInRect(x, y))
- return;
-
- if (mAlpha)
- SDLputPixelAlpha(mWindow, x, y, mColor);
- else
- SDLputPixel(mWindow, x, y, mColor);
-}
-
-void SDLGraphics::drawHLine(int x1, int y, int x2) restrict2
-{
- if (mClipStack.empty())
- return;
-
- const ClipRect& top = mClipStack.top();
-
- const int xOffset = top.xOffset;
- x1 += xOffset;
- y += top.yOffset;
- x2 += xOffset;
-
- const int topY = top.y;
- if (y < topY || y >= topY + top.height)
- return;
-
- if (x1 > x2)
- {
- x1 ^= x2;
- x2 ^= x1;
- x1 ^= x2;
- }
-
- const int topX = top.x;
- if (topX > x1)
- {
- if (topX > x2)
- return;
-
- x1 = topX;
- }
-
- const int sumX = topX + top.width;
- if (sumX <= x2)
- {
- if (sumX <= x1)
- return;
-
- x2 = sumX -1;
- }
-
- const int bpp = mWindow->format->BytesPerPixel;
-
- SDL_LockSurface(mWindow);
-
- uint8_t *p = static_cast<uint8_t*>(mWindow->pixels)
- + CAST_SIZE(y * mWindow->pitch + x1 * bpp);
-
- const uint32_t pixel = SDL_MapRGB(mWindow->format,
- CAST_U8(mColor.r),
- CAST_U8(mColor.g),
- CAST_U8(mColor.b));
- switch (bpp)
- {
- case 1:
- for (; x1 <= x2; ++x1)
- *(p++) = CAST_U8(pixel);
- break;
-
- case 2:
- {
- uint16_t* q = reinterpret_cast<uint16_t*>(p);
- const uint16_t pixel1 = CAST_U16(pixel);
- for (; x1 <= x2; ++x1)
- *(q++) = pixel1;
- break;
- }
-
- case 3:
- {
- const uint8_t b0 = CAST_U8((pixel >> 16) & 0xff);
- const uint8_t b1 = CAST_U8((pixel >> 8) & 0xff);
- const uint8_t b2 = CAST_U8(pixel & 0xff);
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- for (; x1 <= x2; ++x1)
- {
- p[0] = b0;
- p[1] = b1;
- p[2] = b2;
- p += 3;
- }
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
- for (; x1 <= x2; ++x1)
- {
- p[0] = b2;
- p[1] = b1;
- p[2] = b0;
- p += 3;
- }
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
- break;
- }
-
- case 4:
- {
- uint32_t *q = reinterpret_cast<uint32_t*>(p);
- if (mAlpha)
- {
- unsigned char a = CAST_U8(mColor.a);
- unsigned char a1 = CAST_U8(255U - a);
- const int b0 = (pixel & 0xff) * a;
- const int g0 = (pixel & 0xff00) * a;
- const int r0 = (pixel & 0xff0000) * a;
- for (; x1 <= x2; ++x1)
- {
- const unsigned int b = (b0 + (*q & 0xff) * a1) >> 8;
- const unsigned int g = (g0 + (*q & 0xff00) * a1) >> 8;
- const unsigned int r = (r0 + (*q & 0xff0000) * a1) >> 8;
- *q = (b & 0xff) | (g & 0xff00) | (r & 0xff0000);
-
- q++;
- }
- }
- else
- {
- for (; x1 <= x2; ++x1)
- *(q++) = pixel;
- }
- break;
- }
- default:
- break;
- } // end switch
-
- SDL_UnlockSurface(mWindow);
-}
-
-void SDLGraphics::drawVLine(int x, int y1, int y2) restrict2
-{
- if (mClipStack.empty())
- return;
-
- const ClipRect &restrict top = mClipStack.top();
-
- const int yOffset = top.yOffset;
- x += top.xOffset;
- y1 += yOffset;
- y2 += yOffset;
-
- if (x < top.x || x >= top.x + top.width)
- return;
-
- if (y1 > y2)
- {
- y1 ^= y2;
- y2 ^= y1;
- y1 ^= y2;
- }
-
- if (top.y > y1)
- {
- if (top.y > y2)
- return;
-
- y1 = top.y;
- }
-
- const int sumY = top.y + top.height;
- if (sumY <= y2)
- {
- if (sumY <= y1)
- return;
-
- y2 = sumY - 1;
- }
-
- const int bpp = mWindow->format->BytesPerPixel;
-
- SDL_LockSurface(mWindow);
-
- uint8_t *p = static_cast<uint8_t*>(mWindow->pixels)
- + CAST_SIZE(y1 * mWindow->pitch + x * bpp);
-
- const uint32_t pixel = SDL_MapRGB(mWindow->format,
- CAST_U8(mColor.r),
- CAST_U8(mColor.g),
- CAST_U8(mColor.b));
-
- const int pitch = mWindow->pitch;
- switch (bpp)
- {
- case 1:
- for (; y1 <= y2; ++y1)
- {
- *p = CAST_U8(pixel);
- p += pitch;
- }
- break;
-
- case 2:
- for (; y1 <= y2; ++ y1)
- {
- *reinterpret_cast<uint16_t*>(p)
- = CAST_U16(pixel);
- p += pitch;
- }
- break;
-
- case 3:
- {
- const uint8_t b0 = CAST_U8((pixel >> 16) & 0xff);
- const uint8_t b1 = CAST_U8((pixel >> 8) & 0xff);
- const uint8_t b2 = CAST_U8(pixel & 0xff);
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- for (; y1 <= y2; ++y1)
- {
- p[0] = b0;
- p[1] = b1;
- p[2] = b2;
- p += pitch;
- }
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
- for (; y1 <= y2; ++y1)
- {
- p[0] = b2;
- p[1] = b1;
- p[2] = b0;
- p += pitch;
- }
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
- break;
- }
-
- case 4:
- {
- if (mAlpha)
- {
- unsigned char a = CAST_U8(mColor.a);
- unsigned char a1 = CAST_U8(255U - a);
- const int b0 = (pixel & 0xff) * a;
- const int g0 = (pixel & 0xff00) * a;
- const int r0 = (pixel & 0xff0000) * a;
- for (; y1 <= y2; ++y1)
- {
- const unsigned int dst = *reinterpret_cast<uint32_t*>(p);
- const unsigned int b = (b0 + (dst & 0xff) * a1) >> 8;
- const unsigned int g = (g0 + (dst & 0xff00) * a1) >> 8;
- const unsigned int r = (r0 + (dst & 0xff0000) * a1) >> 8;
- *reinterpret_cast<uint32_t*>(p) =
- (b & 0xff) | (g & 0xff00) | (r & 0xff0000);
-
- p += pitch;
- }
- }
- else
- {
- for (; y1 <= y2; ++y1)
- {
- *reinterpret_cast<uint32_t*>(p) = pixel;
- p += pitch;
- }
- }
- break;
- }
-
- default:
- break;
- } // end switch
-
- SDL_UnlockSurface(mWindow);
-}
-
-void SDLGraphics::drawRectangle(const Rect &restrict rectangle) restrict2
-{
- const int x1 = rectangle.x;
- const int x2 = x1 + rectangle.width - 1;
- const int y1 = rectangle.y;
- const int y2 = y1 + rectangle.height - 1;
-
- drawHLine(x1, y1, x2);
- drawHLine(x1, y2, x2);
-
- drawVLine(x1, y1, y2);
- drawVLine(x2, y1, y2);
-}
-
-void SDLGraphics::drawLine(int x1, int y1,
- int x2, int y2) restrict2
-{
- if (x1 == x2)
- {
- drawVLine(x1, y1, y2);
- return;
- }
- if (y1 == y2)
- {
- drawHLine(x1, y1, x2);
- return;
- }
-
- // other cases not implemented
-}
-
-bool SDLGraphics::setVideoMode(const int w, const int h,
- const int scale,
- const int bpp,
- const bool fs,
- const bool hwaccel,
- const bool resize,
- const bool noFrame,
- const bool allowHighDPI) restrict2
-{
- setMainFlags(w, h,
- scale,
- bpp,
- fs,
- hwaccel,
- resize,
- noFrame,
- allowHighDPI);
-
- if ((mWindow = graphicsManager.createWindow(w, h, bpp,
- getSoftwareFlags())) == nullptr)
- {
- mRect.w = 0;
- mRect.h = 0;
- return false;
- }
-
- mRect.w = CAST_U16(mWindow->w);
- mRect.h = CAST_U16(mWindow->h);
-
- return videoInfo();
-}
-
-void SDLGraphics::drawImageRect(const int x, const int y,
- const int w, const int h,
- const ImageRect &restrict imgRect) restrict2
-{
- #include "render/graphics_drawImageRect.hpp"
-}
-
-void SDLGraphics::calcImageRect(ImageVertexes *restrict const vert,
- const int x, const int y,
- const int w, const int h,
- const ImageRect &restrict imgRect) restrict2
-{
- #include "render/graphics_calcImageRect.hpp"
-}
-
-#endif // USE_SDL2
diff --git a/src/render/sdlgraphics.h b/src/render/sdlgraphics.h
deleted file mode 100644
index e93c5df06..000000000
--- a/src/render/sdlgraphics.h
+++ /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/>.
- */
-
-#ifndef RENDER_SDLGRAPHICS_H
-#define RENDER_SDLGRAPHICS_H
-
-#ifdef USE_SDL2
-#include "render/sdl2graphics.h"
-RENDER_SDL2GRAPHICS_H
-
-#else
-
-#include "render/graphics.h"
-
-#include "localconsts.h"
-
-/**
- * A central point of control for graphics.
- */
-class SDLGraphics final : public Graphics
-{
- public:
- /**
- * Constructor.
- */
- SDLGraphics();
-
- A_DELETE_COPY(SDLGraphics)
-
- /**
- * Destructor.
- */
- ~SDLGraphics();
-
- #include "render/graphicsdef.hpp"
- RENDER_GRAPHICSDEF_HPP
-
- #include "render/softwaregraphicsdef.hpp"
- RENDER_SOFTWAREGRAPHICSDEF_HPP
-
- protected:
- int SDL_FakeUpperBlit(const SDL_Surface *restrict const src,
- SDL_Rect *restrict const srcrect,
- const SDL_Surface *restrict const dst,
- SDL_Rect *restrict dstrect) const restrict2;
-
- void drawHLine(int x1, int y, int x2) restrict2;
-
- void drawVLine(int x, int y1, int y2) restrict2;
-
- uint32_t mOldPixel;
- unsigned int mOldAlpha;
-};
-
-#endif // USE_SDL2
-#endif // RENDER_SDLGRAPHICS_H
diff --git a/src/render/shaders/shader.cpp b/src/render/shaders/shader.cpp
deleted file mode 100644
index f3cb54833..000000000
--- a/src/render/shaders/shader.cpp
+++ /dev/null
@@ -1,41 +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/>.
- */
-
-#ifdef USE_OPENGL
-
-#include "render/shaders/shader.h"
-
-#include "render/opengl/mgl.h"
-
-#include "debug.h"
-
-Shader::Shader(const unsigned int id) :
- Resource(),
- mShaderId(id)
-{
-}
-
-Shader::~Shader()
-{
- if (mShaderId != 0u)
- mglDeleteShader(mShaderId);
-}
-
-#endif // USE_OPENGL
diff --git a/src/render/shaders/shader.h b/src/render/shaders/shader.h
deleted file mode 100644
index f11d9d44e..000000000
--- a/src/render/shaders/shader.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 RENDER_SHADERS_SHADER_H
-#define RENDER_SHADERS_SHADER_H
-
-#ifdef USE_OPENGL
-
-#include "resources/resource.h"
-
-class Shader final : public Resource
-{
- public:
- explicit Shader(const unsigned int id);
-
- ~Shader();
-
- A_DELETE_COPY(Shader)
-
- unsigned int getShaderId() const noexcept2
- { return mShaderId; }
-
- protected:
- unsigned int mShaderId;
-};
-
-#endif // USE_OPENGL
-#endif // RENDER_SHADERS_SHADER_H
diff --git a/src/render/shaders/shaderprogram.cpp b/src/render/shaders/shaderprogram.cpp
deleted file mode 100644
index 52cb025d7..000000000
--- a/src/render/shaders/shaderprogram.cpp
+++ /dev/null
@@ -1,54 +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/>.
- */
-
-#ifdef USE_OPENGL
-
-#include "render/shaders/shaderprogram.h"
-
-#include "render/opengl/mgl.h"
-#ifdef __native_client__
-#include "render/opengl/naclglfunctions.h"
-#endif // __native_client__
-
-#include "render/shaders/shader.h"
-
-#include "debug.h"
-
-ShaderProgram::ShaderProgram(const unsigned int id,
- Shader *const vertex,
- Shader *const fragment) :
- Resource(),
- mProgramId(id),
- mVertex(vertex),
- mFragment(fragment)
-{
-}
-
-ShaderProgram::~ShaderProgram()
-{
- if (mProgramId != 0u)
- mglDeleteProgram(mProgramId);
- if (mVertex != nullptr)
- mVertex->decRef();
- if (mFragment != nullptr)
- mFragment->decRef();
-}
-
-#endif // USE_OPENGL
diff --git a/src/render/shaders/shaderprogram.h b/src/render/shaders/shaderprogram.h
deleted file mode 100644
index b8d8e4bc3..000000000
--- a/src/render/shaders/shaderprogram.h
+++ /dev/null
@@ -1,51 +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 RENDER_SHADERS_SHADERPROGRAM_H
-#define RENDER_SHADERS_SHADERPROGRAM_H
-
-#ifdef USE_OPENGL
-
-#include "resources/resource.h"
-
-class Shader;
-
-class ShaderProgram final : public Resource
-{
- public:
- ShaderProgram(const unsigned int id,
- Shader *const vertex,
- Shader *const fragment);
-
- ~ShaderProgram();
-
- A_DELETE_COPY(ShaderProgram)
-
- unsigned int getProgramId() const noexcept2
- { return mProgramId; }
-
- protected:
- unsigned int mProgramId;
- Shader *mVertex;
- Shader *mFragment;
-};
-
-#endif // USE_OPENGL
-#endif // RENDER_SHADERS_SHADERPROGRAM_H
diff --git a/src/render/shaders/shadersmanager.cpp b/src/render/shaders/shadersmanager.cpp
deleted file mode 100644
index 8c4cd79e6..000000000
--- a/src/render/shaders/shadersmanager.cpp
+++ /dev/null
@@ -1,146 +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 "render/shaders/shadersmanager.h"
-
-#ifdef USE_OPENGL
-
-#include "configuration.h"
-#include "logger.h"
-
-#include "fs/virtfs/tools.h"
-
-#include "utils/cast.h"
-
-#include "render/opengl/mgl.h"
-#ifdef __native_client__
-#include "render/opengl/naclglfunctions.h"
-#endif // __native_client__
-
-#include "render/shaders/shader.h"
-#include "render/shaders/shaderprogram.h"
-
-#include "resources/loaders/shaderloader.h"
-
-#include "debug.h"
-
-ShadersManager shaders;
-
-Shader *ShadersManager::createShader(const unsigned int type,
- const std::string &fileName)
-{
- const std::string str = VirtFs::loadTextFileString(fileName);
- const char *ptrStr = str.c_str();
- GLuint shaderId = mglCreateShader(type);
- mglShaderSource(shaderId, 1, &ptrStr, nullptr);
- mglCompileShader(shaderId);
-
- GLint isCompiled = 0;
- mglGetShaderiv(shaderId, GL_COMPILE_STATUS, &isCompiled);
- if (isCompiled == GL_TRUE)
- return new Shader(shaderId);
- GLint len = 0;
- mglGetShaderiv(shaderId, GL_INFO_LOG_LENGTH, &len);
- char *buf = new char[CAST_SIZE(len) + 1];
- mglGetShaderInfoLog(shaderId, len, &len, buf);
- buf[len] = 0;
- logger->log("Shader '%s' compilation error: %s", fileName.c_str(), buf);
- delete [] buf;
- mglDeleteShader(shaderId);
- return nullptr;
-}
-
-ShaderProgram *ShadersManager::createProgram(const std::string &vertex,
- const std::string &fragment,
- const bool isNewShader)
-{
- Shader *const vertexShader = static_cast<Shader*>(
- Loader::getShader(GL_VERTEX_SHADER, vertex));
- if (vertexShader == nullptr)
- return nullptr;
-
- Shader *const fragmentShader = static_cast<Shader*>(
- Loader::getShader(GL_FRAGMENT_SHADER, fragment));
-
- if (fragmentShader == nullptr)
- {
- vertexShader->decRef();
- return nullptr;
- }
-
- GLuint programId = mglCreateProgram();
- if (programId == 0u)
- {
- vertexShader->decRef();
- fragmentShader->decRef();
- return nullptr;
- }
-
- mglAttachShader(programId, vertexShader->getShaderId());
- mglAttachShader(programId, fragmentShader->getShaderId());
- if (isNewShader)
- mglBindFragDataLocation(programId, 0, "outColor");
- else
- mglBindAttribLocation(programId, 0, "position");
- mglLinkProgram(programId);
- GLint isLinked = 0;
- mglGetProgramiv(programId, GL_LINK_STATUS, &isLinked);
- if (isLinked == GL_TRUE)
- {
- mglValidateProgram(programId);
- GLint isValidated = 0;
- mglGetProgramiv(programId, GL_VALIDATE_STATUS, &isValidated);
- if (isValidated == GL_TRUE)
- return new ShaderProgram(programId, vertexShader, fragmentShader);
- mglDeleteProgram(programId);
- return nullptr;
- }
-
- GLint len = 0;
- mglGetProgramiv(programId, GL_INFO_LOG_LENGTH, &len);
- char *buf = new char[CAST_SIZE(len) + 1];
- mglGetProgramInfoLog(programId, len, &len, buf);
- buf[len] = 0;
- logger->log("Program '%s, %s' compilation error: %s",
- vertexShader->mIdPath.c_str(),
- fragmentShader->mIdPath.c_str(),
- buf);
- delete [] buf;
- mglDeleteProgram(programId);
- return nullptr;
-}
-
-ShaderProgram *ShadersManager::getSimpleProgram()
-{
- const std::string dir = paths.getStringValue("shaders");
- return createProgram(dir + paths.getStringValue("simpleVertexShader"),
- dir + paths.getStringValue("simpleFragmentShader"),
- true);
-}
-
-ShaderProgram *ShadersManager::getGles2Program()
-{
- const std::string dir = paths.getStringValue("shaders");
- return createProgram(dir + paths.getStringValue("gles2VertexShader"),
- dir + paths.getStringValue("gles2FragmentShader"),
- false);
-}
-
-#endif // USE_OPENGL
diff --git a/src/render/shaders/shadersmanager.h b/src/render/shaders/shadersmanager.h
deleted file mode 100644
index 8e45290c4..000000000
--- a/src/render/shaders/shadersmanager.h
+++ /dev/null
@@ -1,57 +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 RENDER_SHADERS_SHADERSMANAGER_H
-#define RENDER_SHADERS_SHADERSMANAGER_H
-
-#ifdef USE_OPENGL
-
-#include <string>
-
-#include "localconsts.h"
-
-class Shader;
-class ShaderProgram;
-
-class ShadersManager final
-{
- public:
- ShadersManager()
- { }
-
- A_DELETE_COPY(ShadersManager)
-
- Shader *createShader(const unsigned int type,
- const std::string &fileName) A_WARN_UNUSED;
-
- ShaderProgram *createProgram(const std::string &vertex,
- const std::string &fragment,
- const bool isNewShader)
- A_WARN_UNUSED;
-
- ShaderProgram *getSimpleProgram();
-
- ShaderProgram *getGles2Program();
-};
-
-extern ShadersManager shaders;
-
-#endif // USE_OPENGL
-#endif // RENDER_SHADERS_SHADERSMANAGER_H
diff --git a/src/render/softwaregraphicsdef.hpp b/src/render/softwaregraphicsdef.hpp
deleted file mode 100644
index b630a0657..000000000
--- a/src/render/softwaregraphicsdef.hpp
+++ /dev/null
@@ -1,27 +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/>.
- */
-
-#define RENDER_SOFTWAREGRAPHICSDEF_HPP
-
-public:
- void calcTileSDL(ImageVertexes *restrict const vert,
- int x, int y) const restrict2 override final;
diff --git a/src/render/surfacegraphics.cpp b/src/render/surfacegraphics.cpp
deleted file mode 100644
index 52d0db57f..000000000
--- a/src/render/surfacegraphics.cpp
+++ /dev/null
@@ -1,156 +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 "render/surfacegraphics.h"
-
-#ifndef USE_SDL2
-#include "resources/surfaceimagehelper.h"
-#endif // USE_SDL2
-
-#include "resources/image/image.h"
-
-#include "debug.h"
-
-SurfaceGraphics::SurfaceGraphics() :
- Graphics(),
- mBlitMode(BlitMode::BLIT_NORMAL),
- mTarget(nullptr)
-{
- mOpenGL = RENDER_SOFTWARE;
- mName = "Surface";
-}
-
-SurfaceGraphics::~SurfaceGraphics()
-{
-}
-
-void SurfaceGraphics::drawImage(const Image *restrict const image,
- int dstX, int dstY) restrict2
-{
- FUNC_BLOCK("Graphics::drawImage", 1)
- // Check that preconditions for blitting are met.
- if (mTarget == nullptr ||
- image == nullptr ||
- image->mSDLSurface == nullptr)
- {
- return;
- }
-
- const SDL_Rect &imageRect = image->mBounds;
- SDL_Rect dstRect;
- SDL_Rect srcRect;
- dstRect.x = CAST_S16(dstX);
- dstRect.y = CAST_S16(dstY);
- srcRect.x = CAST_S16(imageRect.x);
- srcRect.y = CAST_S16(imageRect.y);
- srcRect.w = CAST_U16(imageRect.w);
- srcRect.h = CAST_U16(imageRect.h);
-
-#ifdef USE_SDL2
- SDL_BlitSurface(image->mSDLSurface, &srcRect, mTarget, &dstRect);
-#else // USE_SDL2
-
- if (mBlitMode == BlitMode::BLIT_NORMAL)
- {
- SDL_BlitSurface(image->mSDLSurface, &srcRect, mTarget, &dstRect);
- }
- else
- {
- SurfaceImageHelper::combineSurface(image->mSDLSurface,
- &srcRect, mTarget, &dstRect);
- }
-#endif // USE_SDL2
-}
-
-void SurfaceGraphics::copyImage(const Image *restrict const image,
- int dstX, int dstY) restrict2
-{
- FUNC_BLOCK("Graphics::drawImage", 1)
- // Check that preconditions for blitting are met.
- if (mTarget == nullptr ||
- image == nullptr ||
- image->mSDLSurface == nullptr)
- {
- return;
- }
-
- const SDL_Rect &imageRect = image->mBounds;
- SDL_Rect dstRect;
- SDL_Rect srcRect;
- dstRect.x = CAST_S16(dstX);
- dstRect.y = CAST_S16(dstY);
- srcRect.x = CAST_S16(imageRect.x);
- srcRect.y = CAST_S16(imageRect.y);
- srcRect.w = CAST_U16(imageRect.w);
- srcRect.h = CAST_U16(imageRect.h);
-
-#ifdef USE_SDL2
- // probably need change some flags
- SDL_BlitSurface(image->mSDLSurface, &srcRect, mTarget, &dstRect);
-#else // USE_SDL2
-
- SDL_BlitSurface(image->mSDLSurface, &srcRect, mTarget, &dstRect);
-#endif // USE_SDL2
-}
-
-void SurfaceGraphics::drawImageCached(const Image *restrict const image,
- int x, int y) restrict2
-{
- FUNC_BLOCK("Graphics::drawImageCached", 1)
- // Check that preconditions for blitting are met.
- if (mTarget == nullptr ||
- image == nullptr ||
- image->mSDLSurface == nullptr)
- {
- return;
- }
-
- const SDL_Rect &rect = image->mBounds;
-
- SDL_Rect dstRect;
- SDL_Rect srcRect;
- dstRect.x = CAST_S16(x);
- dstRect.y = CAST_S16(y);
- srcRect.x = CAST_S16(rect.x);
- srcRect.y = CAST_S16(rect.y);
- srcRect.w = CAST_U16(rect.w);
- srcRect.h = CAST_U16(rect.h);
-
-#ifdef USE_SDL2
- SDL_BlitSurface(image->mSDLSurface, &srcRect, mTarget, &dstRect);
-#else // USE_SDL2
-
- if (mBlitMode == BlitMode::BLIT_NORMAL)
- {
- SDL_BlitSurface(image->mSDLSurface, &srcRect, mTarget, &dstRect);
- }
- else
- {
- SurfaceImageHelper::combineSurface(image->mSDLSurface, &srcRect,
- mTarget, &dstRect);
- }
-#endif // USE_SDL2
-}
-
-void SurfaceGraphics::completeCache() restrict2
-{
-}
diff --git a/src/render/surfacegraphics.h b/src/render/surfacegraphics.h
deleted file mode 100644
index 2e46c9f1e..000000000
--- a/src/render/surfacegraphics.h
+++ /dev/null
@@ -1,218 +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 RENDER_SURFACEGRAPHICS_H
-#define RENDER_SURFACEGRAPHICS_H
-
-#include "enums/render/blitmode.h"
-
-#include "render/graphics.h"
-
-#include "localconsts.h"
-
-class Image;
-class ImageCollection;
-class ImageVertexes;
-
-/**
- * A central point of control for graphics.
- */
-class SurfaceGraphics final : public Graphics
-{
- public:
- SurfaceGraphics();
-
- A_DELETE_COPY(SurfaceGraphics)
-
- ~SurfaceGraphics();
-
- void setTarget(SDL_Surface *restrict const target) restrict2 noexcept2
- { mTarget = target; }
-
- SDL_Surface *getTarget() const restrict2 noexcept2
- { return mTarget; }
-
- void beginDraw() restrict2 override final
- { }
-
- void endDraw() restrict2 override final
- { }
-
- void pushClipArea(const Rect &restrict rect A_UNUSED)
- restrict2 override final
- { }
-
- void popClipArea() restrict2 override final
- { }
-
- void drawRescaledImage(const Image *restrict const image A_UNUSED,
- int dstX A_UNUSED, int dstY A_UNUSED,
- const int desiredWidth A_UNUSED,
- const int desiredHeight A_UNUSED)
- restrict2 override final
- { }
-
- void drawPattern(const Image *restrict const image A_UNUSED,
- const int x A_UNUSED,
- const int y A_UNUSED,
- const int w A_UNUSED,
- const int h A_UNUSED) restrict2 override final
- { }
-
- void drawRescaledPattern(const Image *const image A_UNUSED,
- const int x A_UNUSED,
- const int y A_UNUSED,
- const int w A_UNUSED,
- const int h A_UNUSED,
- const int scaledWidth A_UNUSED,
- const int scaledHeight A_UNUSED)
- override final
- { }
-
- void calcPattern(ImageVertexes *restrict const vert A_UNUSED,
- const Image *restrict const image A_UNUSED,
- const int x A_UNUSED,
- const int y A_UNUSED,
- const int w A_UNUSED,
- const int h A_UNUSED) const restrict2 override final
- { }
-
- void calcPattern(ImageCollection *restrict const vert A_UNUSED,
- const Image *restrict const image A_UNUSED,
- const int x A_UNUSED,
- const int y A_UNUSED,
- const int w A_UNUSED,
- const int h A_UNUSED) const restrict2 override final
- { }
-
- void calcTileVertexes(ImageVertexes *restrict const vert A_UNUSED,
- const Image *restrict const image A_UNUSED,
- int x A_UNUSED,
- int y A_UNUSED) const restrict2 override final
- A_NONNULL(2, 3)
- { }
-
- void calcTileSDL(ImageVertexes *restrict const vert A_UNUSED,
- int x A_UNUSED,
- int y A_UNUSED) const restrict2 override final
- { }
-
- void calcTileCollection(ImageCollection *restrict const
- vertCol A_UNUSED,
- const Image *restrict const image A_UNUSED,
- int x A_UNUSED,
- int y A_UNUSED) restrict2 override final
- { }
-
- void drawTileVertexes(const ImageVertexes *restrict const
- vert A_UNUSED) restrict2 override final
- { }
-
- void drawTileCollection(const ImageCollection *restrict const
- vertCol A_UNUSED)
- restrict2 override final A_NONNULL(2)
- { }
-
- void updateScreen() override final
- { }
-
- void drawNet(const int x1 A_UNUSED,
- const int y1 A_UNUSED,
- const int x2 A_UNUSED,
- const int y2 A_UNUSED,
- const int width A_UNUSED,
- const int height A_UNUSED) restrict2 override final
- { }
-
- void calcWindow(ImageCollection *restrict const vertCol A_UNUSED,
- const int x A_UNUSED, const int y A_UNUSED,
- const int w A_UNUSED, const int h A_UNUSED,
- const ImageRect &restrict imgRect A_UNUSED)
- restrict2 override final A_NONNULL(2)
- { }
-
- void setBlitMode(const BlitModeT mode) restrict2 noexcept2
- { mBlitMode = mode; }
-
- BlitModeT getBlitMode() const restrict2 noexcept2 A_WARN_UNUSED
- { return mBlitMode; }
-
- void fillRectangle(const Rect &restrict rect A_UNUSED)
- restrict2 override final
- { }
-
- void drawRectangle(const Rect &restrict rect A_UNUSED)
- restrict2 override final
- { }
-
- void drawPoint(int x A_UNUSED, int y A_UNUSED) restrict2 override final
- { }
-
- void drawLine(int x1 A_UNUSED, int y1 A_UNUSED,
- int x2 A_UNUSED, int y2 A_UNUSED)
- restrict2 override final
- { }
-
- bool setVideoMode(const int w A_UNUSED, const int h A_UNUSED,
- const int scale A_UNUSED,
- const int bpp A_UNUSED,
- const bool fs A_UNUSED, const bool hwaccel A_UNUSED,
- const bool resize A_UNUSED,
- const bool noFrame A_UNUSED,
- const bool allowHighDPI A_UNUSED)
- restrict2 override final
- { return false; }
-
- void drawImage(const Image *restrict const image,
- int dstX, int dstY) restrict2 override final;
-
- void copyImage(const Image *restrict const image,
- int dstX, int dstY) restrict2 override final;
-
- void drawImageCached(const Image *restrict const image,
- int x, int y) restrict2 override final;
-
- void drawPatternCached(const Image *restrict const image A_UNUSED,
- const int x A_UNUSED,
- const int y A_UNUSED,
- const int w A_UNUSED,
- const int h A_UNUSED) restrict2 override final
- { }
-
- void completeCache() restrict2 override final;
-
- /**
- * Draws a rectangle using images. 4 corner images, 4 side images and 1
- * image for the inside.
- */
- void drawImageRect(const int x A_UNUSED, const int y A_UNUSED,
- const int w A_UNUSED, const int h A_UNUSED,
- const ImageRect &restrict imgRect A_UNUSED)
- restrict2 override final
- { }
-
- protected:
- BlitModeT mBlitMode;
- SDL_Surface *mTarget;
-};
-
-#endif // RENDER_SURFACEGRAPHICS_H
diff --git a/src/render/vertexes/imagecollection.cpp b/src/render/vertexes/imagecollection.cpp
deleted file mode 100644
index 2c626e03d..000000000
--- a/src/render/vertexes/imagecollection.cpp
+++ /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/>.
- */
-
-#include "render/vertexes/imagecollection.h"
-
-#include "utils/dtor.h"
-
-#include "debug.h"
-
-ImageCollection::ImageCollection() :
-#ifdef USE_OPENGL
- currentGLImage(0),
-#endif // USE_OPENGL
- currentImage(nullptr),
- currentVert(nullptr),
- draws()
-{
-}
-
-ImageCollection::~ImageCollection()
-{
- clear();
-}
-
-void ImageCollection::clear() restrict2
-{
-#ifdef USE_OPENGL
- currentGLImage = 0;
-#endif // USE_OPENGL
- currentImage = nullptr;
- currentVert = nullptr;
-
- delete_all(draws);
- draws.clear();
-}
diff --git a/src/render/vertexes/imagecollection.h b/src/render/vertexes/imagecollection.h
deleted file mode 100644
index c5b9dfe55..000000000
--- a/src/render/vertexes/imagecollection.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 RENDER_VERTEXES_IMAGECOLLECTION_H
-#define RENDER_VERTEXES_IMAGECOLLECTION_H
-
-#include "render/vertexes/imagevertexes.h"
-
-#include "localconsts.h"
-
-class Image;
-
-class ImageCollection final
-{
- public:
- ImageCollection();
-
- A_DELETE_COPY(ImageCollection)
-
- ~ImageCollection();
-
- void clear() restrict2;
-
-#ifdef USE_OPENGL
- GLuint currentGLImage;
-#endif // USE_OPENGL
-
- const Image *restrict currentImage;
-
- ImageVertexes *restrict currentVert;
-
- ImageVertexesVector draws;
-};
-
-#endif // RENDER_VERTEXES_IMAGECOLLECTION_H
diff --git a/src/render/vertexes/imagevertexes.cpp b/src/render/vertexes/imagevertexes.cpp
deleted file mode 100644
index 3aff57636..000000000
--- a/src/render/vertexes/imagevertexes.cpp
+++ /dev/null
@@ -1,41 +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 "render/vertexes/imagevertexes.h"
-
-#include "utils/dtor.h"
-
-#include "debug.h"
-
-ImageVertexes::ImageVertexes() :
- image(nullptr),
-#ifdef USE_OPENGL
- ogl(),
-#endif // USE_OPENGL
- sdl()
-{
- sdl.reserve(30);
-}
-
-ImageVertexes::~ImageVertexes()
-{
- delete_all(sdl);
- sdl.clear();
-}
diff --git a/src/render/vertexes/imagevertexes.h b/src/render/vertexes/imagevertexes.h
deleted file mode 100644
index 01390c450..000000000
--- a/src/render/vertexes/imagevertexes.h
+++ /dev/null
@@ -1,59 +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 RENDER_VERTEXES_IMAGEVERTEXES_H
-#define RENDER_VERTEXES_IMAGEVERTEXES_H
-
-#include "resources/rect/doublerect.h"
-
-#ifdef USE_OPENGL
-#include "render/vertexes/openglgraphicsvertexes.h"
-#else // USE_OPENGL
-#include "utils/vector.h"
-#endif // USE_OPENGL
-
-#include "localconsts.h"
-
-class Image;
-
-typedef STD_VECTOR<DoubleRect*> DoubleRects;
-
-class ImageVertexes final
-{
- public:
- ImageVertexes();
-
- A_DELETE_COPY(ImageVertexes)
-
- ~ImageVertexes();
-
- const Image *restrict image;
-#ifdef USE_OPENGL
- OpenGLGraphicsVertexes ogl;
-#endif // USE_OPENGL
-
- DoubleRects sdl;
-};
-
-typedef STD_VECTOR<ImageVertexes*> ImageVertexesVector;
-typedef ImageVertexesVector::iterator ImageCollectionIter;
-typedef ImageVertexesVector::const_iterator ImageCollectionCIter;
-
-#endif // RENDER_VERTEXES_IMAGEVERTEXES_H
diff --git a/src/render/vertexes/openglgraphicsvertexes.cpp b/src/render/vertexes/openglgraphicsvertexes.cpp
deleted file mode 100644
index a65f0e2b9..000000000
--- a/src/render/vertexes/openglgraphicsvertexes.cpp
+++ /dev/null
@@ -1,225 +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 "render/vertexes/openglgraphicsvertexes.h"
-
-#include "render/graphics.h"
-
-#include "debug.h"
-
-unsigned int vertexBufSize = 500;
-
-OpenGLGraphicsVertexes::OpenGLGraphicsVertexes() :
- ptr(0),
- mFloatTexArray(nullptr),
- mIntTexArray(nullptr),
- mIntVertArray(nullptr),
- mShortVertArray(nullptr),
- mVp(),
- mFloatTexPool(),
- mIntVertPool(),
- mShortVertPool(),
- mIntTexPool(),
- mVbo()
-{
- mFloatTexPool.reserve(30);
- mIntVertPool.reserve(30);
- mShortVertPool.reserve(30);
- mIntTexPool.reserve(30);
- mVp.reserve(30);
- mVbo.reserve(30);
-}
-
-OpenGLGraphicsVertexes::~OpenGLGraphicsVertexes()
-{
- clear();
-}
-
-void OpenGLGraphicsVertexes::clear() restrict2
-{
- for (STD_VECTOR<GLfloat*>::iterator it = mFloatTexPool.begin();
- it != mFloatTexPool.end(); ++ it)
- {
- delete [] (*it);
- }
- mFloatTexPool.clear();
-
- for (STD_VECTOR<GLint*>::iterator it = mIntVertPool.begin();
- it != mIntVertPool.end(); ++ it)
- {
- delete [] (*it);
- }
- mIntVertPool.clear();
-
- for (STD_VECTOR<GLshort*>::iterator it = mShortVertPool.begin();
- it != mShortVertPool.end(); ++ it)
- {
- delete [] (*it);
- }
- mShortVertPool.clear();
-
- for (STD_VECTOR<GLint*>::iterator it = mIntTexPool.begin();
- it != mIntTexPool.end(); ++ it)
- {
- delete [] (*it);
- }
- mIntTexPool.clear();
-
- const int sz = CAST_S32(mVbo.size());
- if (sz > 0)
- {
- mainGraphics->removeArray(sz, &mVbo[0]);
- mVbo.clear();
- }
-
- mVp.clear();
- if (ptr != 0)
- {
- ptr = 0;
- delete []mFloatTexArray;
- mFloatTexArray = nullptr;
- delete []mIntTexArray;
- mIntTexArray = nullptr;
- delete []mIntVertArray;
- mIntVertArray = nullptr;
- delete []mShortVertArray;
- mShortVertArray = nullptr;
- }
-}
-
-void OpenGLGraphicsVertexes::init() restrict2
-{
- clear();
-}
-
-GLfloat *OpenGLGraphicsVertexes::switchFloatTexArray() restrict2
-{
- mFloatTexArray = new GLfloat[CAST_SIZE(vertexBufSize * 4 + 30)];
- mFloatTexPool.push_back(mFloatTexArray);
- return mFloatTexArray;
-}
-
-GLint *OpenGLGraphicsVertexes::switchIntVertArray() restrict2
-{
- mIntVertArray = new GLint[CAST_SIZE(vertexBufSize * 4 + 30)];
- mIntVertPool.push_back(mIntVertArray);
- return mIntVertArray;
-}
-
-GLshort *OpenGLGraphicsVertexes::switchShortVertArray() restrict2
-{
- mShortVertArray = new GLshort[CAST_SIZE(vertexBufSize * 4 + 30)];
- mShortVertPool.push_back(mShortVertArray);
- return mShortVertArray;
-}
-
-GLint *OpenGLGraphicsVertexes::switchIntTexArray() restrict2
-{
- mIntTexArray = new GLint[CAST_SIZE(vertexBufSize * 4 + 30)];
- mIntTexPool.push_back(mIntTexArray);
- return mIntTexArray;
-}
-
-void OpenGLGraphicsVertexes::switchVp(const int n) restrict2
-{
- mVp.push_back(n);
-}
-
-int OpenGLGraphicsVertexes::continueVp() restrict2
-{
- if (mVp.empty())
- {
- return 0;
- }
- else
- {
- const int val = mVp.back();
- mVp.pop_back();
- return val;
- }
-}
-
-void OpenGLGraphicsVertexes::updateVp(const int n) restrict2
-{
- if (!mVp.empty())
- mVp.pop_back();
- mVp.push_back(n);
-}
-
-GLfloat *OpenGLGraphicsVertexes::continueFloatTexArray() restrict2
-{
- if (mFloatTexPool.empty())
- {
- mFloatTexArray = new GLfloat[CAST_SIZE(
- vertexBufSize * 4 + 30)];
- mFloatTexPool.push_back(mFloatTexArray);
- }
- else
- {
- mFloatTexArray = mFloatTexPool.back();
- }
- return mFloatTexArray;
-}
-
-GLint *OpenGLGraphicsVertexes::continueIntVertArray() restrict2
-{
- if (mIntVertPool.empty())
- {
- mIntVertArray = new GLint[CAST_SIZE(vertexBufSize * 4 + 30)];
- mIntVertPool.push_back(mIntVertArray);
- }
- else
- {
- mIntVertArray = mIntVertPool.back();
- }
- return mIntVertArray;
-}
-
-GLshort *OpenGLGraphicsVertexes::continueShortVertArray() restrict2
-{
- if (mShortVertPool.empty())
- {
- mShortVertArray = new GLshort[CAST_SIZE(
- vertexBufSize * 4 + 30)];
- mShortVertPool.push_back(mShortVertArray);
- }
- else
- {
- mShortVertArray = mShortVertPool.back();
- }
- return mShortVertArray;
-}
-
-GLint *OpenGLGraphicsVertexes::continueIntTexArray() restrict2
-{
- if (mIntTexPool.empty())
- {
- mIntTexArray = new GLint[CAST_SIZE(vertexBufSize * 4 + 30)];
- mIntTexPool.push_back(mIntTexArray);
- }
- else
- {
- mIntTexArray = mIntTexPool.back();
- }
- return mIntTexArray;
-}
-#endif // USE_OPENGL
diff --git a/src/render/vertexes/openglgraphicsvertexes.h b/src/render/vertexes/openglgraphicsvertexes.h
deleted file mode 100644
index 023abf139..000000000
--- a/src/render/vertexes/openglgraphicsvertexes.h
+++ /dev/null
@@ -1,109 +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 RENDER_VERTEXES_OPENGLGRAPHICSVERTEXES_H
-#define RENDER_VERTEXES_OPENGLGRAPHICSVERTEXES_H
-
-#ifdef USE_OPENGL
-
-#include "localconsts.h"
-
-#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
-
-#include "utils/vector.h"
-
-class OpenGLGraphicsVertexes final
-{
- public:
- OpenGLGraphicsVertexes();
-
- A_DELETE_COPY(OpenGLGraphicsVertexes)
-
- ~OpenGLGraphicsVertexes();
-
- GLfloat *switchFloatTexArray() restrict2;
-
- GLint *switchIntVertArray() restrict2;
-
- GLint *switchIntTexArray() restrict2;
-
- GLshort *switchShortVertArray() restrict2;
-
- STD_VECTOR<GLfloat*> *getFloatTexPool() restrict2 A_WARN_UNUSED
- { return &mFloatTexPool; }
-
- STD_VECTOR<GLint*> *getIntVertPool() restrict2 A_WARN_UNUSED
- { return &mIntVertPool; }
-
- STD_VECTOR<GLshort*> *getShortVertPool() restrict2 A_WARN_UNUSED
- { return &mShortVertPool; }
-
- STD_VECTOR<GLint*> *getIntTexPool() restrict2 A_WARN_UNUSED
- { return &mIntTexPool; }
-
- void switchVp(const int n) restrict2;
-
- GLfloat *continueFloatTexArray() restrict2 RETURNS_NONNULL;
-
- GLint *continueIntVertArray() restrict2 RETURNS_NONNULL;
-
- GLshort *continueShortVertArray() restrict2 RETURNS_NONNULL;
-
- GLint *continueIntTexArray() restrict2 RETURNS_NONNULL;
-
- int continueVp() restrict2;
-
- void updateVp(const int n) restrict2;
-
- STD_VECTOR<int> *getVp() restrict2 A_WARN_UNUSED
- { return &mVp; }
-
- void init() restrict2;
-
- void clear() restrict2;
-
- int ptr;
-
- GLfloat *mFloatTexArray;
- GLint *mIntTexArray;
- GLint *mIntVertArray;
- GLshort *mShortVertArray;
- STD_VECTOR<int> mVp;
- STD_VECTOR<GLfloat*> mFloatTexPool;
- STD_VECTOR<GLint*> mIntVertPool;
- STD_VECTOR<GLshort*> mShortVertPool;
- STD_VECTOR<GLint*> mIntTexPool;
- STD_VECTOR<GLuint> mVbo;
-};
-
-extern unsigned int vertexBufSize;
-#endif // USE_OPENGL
-
-#endif // RENDER_VERTEXES_OPENGLGRAPHICSVERTEXES_H
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
diff --git a/src/sdl2gfx/SDL2_framerate.cpp b/src/sdl2gfx/SDL2_framerate.cpp
deleted file mode 100644
index e03a8ba7c..000000000
--- a/src/sdl2gfx/SDL2_framerate.cpp
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
-
-SDL2_framerate.c: framerate manager
-
-Copyright (C) 2012-2014 Andreas Schiffler
-
-This software is provided 'as-is', without any express or implied
-warranty. In no event will the authors be held liable for any damages
-arising from the use of this software.
-
-Permission is granted to anyone to use this software for any purpose,
-including commercial applications, and to alter it and redistribute it
-freely, subject to the following restrictions:
-
-1. The origin of this software must not be misrepresented; you must not
-claim that you wrote the original software. If you use this software
-in a product, an acknowledgment in the product documentation would be
-appreciated but is not required.
-
-2. Altered source versions must be plainly marked as such, and must not be
-misrepresented as being the original software.
-
-3. This notice may not be removed or altered from any source
-distribution.
-
-Andreas Schiffler -- aschiffler at ferzkopp dot net
-
-Changed for ManaPlus (C) 2013-2017 ManaPlus developers
-
-*/
-
-#include "sdl2gfx/SDL2_framerate.h"
-
-#include "debug.h"
-
-/*!
-\brief Internal wrapper to SDL_GetTicks that ensures a non-zero return value.
-
-\return The tick count.
-*/
-static Uint32 _getTicks()
-{
- Uint32 ticks = SDL_GetTicks();
-
- /*
- * Since baseticks!=0 is used to track initialization
- * we need to ensure that the tick count is always >0
- * since SDL_GetTicks may not have incremented yet and
- * return 0 depending on the timing of the calls.
- */
- if (ticks == 0)
- {
- return 1;
- }
- else
- {
- return ticks;
- }
-}
-
-/*!
-\brief Initialize the framerate manager.
-
-Initialize the framerate manager, set default framerate of 30Hz and
-reset delay interpolation.
-
-\param manager Pointer to the framerate manager.
-*/
-void SDL_initFramerate(FPSmanager * manager)
-{
- /*
- * Store some sane values
- */
- manager->framecount = 0;
- manager->rate = FPS_DEFAULT;
- manager->rateticks = (1000.0f / static_cast<float>(FPS_DEFAULT));
- manager->baseticks = _getTicks();
- manager->lastticks = manager->baseticks;
-
-}
-
-/*!
-\brief Set the framerate in Hz
-
-Sets a new framerate for the manager and reset delay interpolation.
-Rate values must be between FPS_LOWER_LIMIT and FPS_UPPER_LIMIT inclusive to be accepted.
-
-\param manager Pointer to the framerate manager.
-\param rate The new framerate in Hz (frames per second).
-
-\return 0 for sucess and -1 for error.
-*/
-int SDL_setFramerate(FPSmanager * manager, Uint32 rate)
-{
- if ((rate >= FPS_LOWER_LIMIT) && (rate <= FPS_UPPER_LIMIT))
- {
- manager->framecount = 0;
- manager->rate = rate;
- manager->rateticks = (1000.0f / static_cast<float>(rate));
- return (0);
- }
- else
- {
- return (-1);
- }
-}
-
-/*!
-\brief Return the current target framerate in Hz
-
-Get the currently set framerate of the manager.
-
-\param manager Pointer to the framerate manager.
-
-\return Current framerate in Hz or -1 for error.
-*/
-int SDL_getFramerate(FPSmanager * manager)
-{
- if (manager == nullptr)
- {
- return (-1);
- }
- else
- {
- return (static_cast<int>(manager->rate));
- }
-}
-
-/*!
-\brief Return the current framecount.
-
-Get the current framecount from the framerate manager.
-A frame is counted each time SDL_framerateDelay is called.
-
-\param manager Pointer to the framerate manager.
-
-\return Current frame count or -1 for error.
-*/
-int SDL_getFramecount(FPSmanager * manager)
-{
- if (manager == nullptr)
- {
- return (-1);
- }
- else
- {
- return (static_cast<int>(manager->framecount));
- }
-}
-
-/*!
-\brief Delay execution to maintain a constant framerate and calculate fps.
-
-Generate a delay to accomodate currently set framerate. Call once in the
-graphics/rendering loop. If the computer cannot keep up with the rate (i.e.
-drawing too slow), the delay is zero and the delay interpolation is reset.
-
-\param manager Pointer to the framerate manager.
-
-\return The time that passed since the last call to the function in ms. May return 0.
-*/
-Uint32 SDL_framerateDelay(FPSmanager * manager)
-{
- Uint32 current_ticks;
- Uint32 target_ticks;
- Uint32 the_delay;
- Uint32 time_passed = 0;
-
- /*
- * No manager, no delay
- */
- if (manager == nullptr)
- {
- return 0;
- }
-
- /*
- * Initialize uninitialized manager
- */
- if (manager->baseticks == 0)
- {
- SDL_initFramerate(manager);
- }
-
- /*
- * Next frame
- */
- manager->framecount++;
-
- /*
- * Get/calc ticks
- */
- current_ticks = _getTicks();
- time_passed = current_ticks - manager->lastticks;
- manager->lastticks = current_ticks;
- target_ticks = manager->baseticks + static_cast<Uint32>(static_cast<float>(
- manager->framecount) * manager->rateticks);
-
- if (current_ticks <= target_ticks)
- {
- the_delay = target_ticks - current_ticks;
- SDL_Delay(the_delay);
- }
- else
- {
- manager->framecount = 0;
- manager->baseticks = _getTicks();
- }
-
- return time_passed;
-}
diff --git a/src/sdl2gfx/SDL2_framerate.h b/src/sdl2gfx/SDL2_framerate.h
deleted file mode 100644
index add1b28c9..000000000
--- a/src/sdl2gfx/SDL2_framerate.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
-
-SDL2_framerate.h: framerate manager
-
-Copyright (C) 2012-2014 Andreas Schiffler
-
-This software is provided 'as-is', without any express or implied
-warranty. In no event will the authors be held liable for any damages
-arising from the use of this software.
-
-Permission is granted to anyone to use this software for any purpose,
-including commercial applications, and to alter it and redistribute it
-freely, subject to the following restrictions:
-
-1. The origin of this software must not be misrepresented; you must not
-claim that you wrote the original software. If you use this software
-in a product, an acknowledgment in the product documentation would be
-appreciated but is not required.
-
-2. Altered source versions must be plainly marked as such, and must not be
-misrepresented as being the original software.
-
-3. This notice may not be removed or altered from any source
-distribution.
-
-Andreas Schiffler -- aschiffler at ferzkopp dot net
-
-Changed for ManaPlus (C) 2013-2017 ManaPlus developers
-
-*/
-
-#ifndef _SDL2_framerate_h
-#define _SDL2_framerate_h
-
-/* Set up for C function definitions, even when using C++ */
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- /* --- */
-
-#include "localconsts.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL.h>
-PRAGMA48(GCC diagnostic pop)
-
- /* --------- Definitions */
-
- /*!
- \brief Highest possible rate supported by framerate controller in Hz (1/s).
- */
-#define FPS_UPPER_LIMIT 200
-
- /*!
- \brief Lowest possible rate supported by framerate controller in Hz (1/s).
- */
-#define FPS_LOWER_LIMIT 1
-
- /*!
- \brief Default rate of framerate controller in Hz (1/s).
- */
-#define FPS_DEFAULT 30
-
- /*!
- \brief Structure holding the state and timing information of the framerate controller.
- */
- typedef struct
- {
- Uint32 framecount;
- float rateticks;
- Uint32 baseticks;
- Uint32 lastticks;
- Uint32 rate;
- } FPSmanager;
-
- /* ---- Function Prototypes */
-
-#ifdef _MSC_VER
-# if defined(DLL_EXPORT) && !defined(LIBSDL2_GFX_DLL_IMPORT)
-# define SDL2_FRAMERATE_SCOPE __declspec(dllexport)
-# else
-# ifdef LIBSDL2_GFX_DLL_IMPORT
-# define SDL2_FRAMERATE_SCOPE __declspec(dllimport)
-# endif
-# endif
-#endif
-#ifndef SDL2_FRAMERATE_SCOPE
-# define SDL2_FRAMERATE_SCOPE extern
-#endif
-
- /* Functions return 0 or value for sucess and -1 for error */
-
- SDL2_FRAMERATE_SCOPE void SDL_initFramerate(FPSmanager * manager);
- SDL2_FRAMERATE_SCOPE int SDL_setFramerate(FPSmanager * manager,
- Uint32 rate);
- SDL2_FRAMERATE_SCOPE int SDL_getFramerate(FPSmanager * manager);
- SDL2_FRAMERATE_SCOPE int SDL_getFramecount(FPSmanager * manager);
- SDL2_FRAMERATE_SCOPE Uint32 SDL_framerateDelay(FPSmanager * manager);
-
- /* --- */
-
- /* Ends C function definitions when using C++ */
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _SDL2_framerate_h */
diff --git a/src/sdl2gfx/SDL2_rotozoom.cpp b/src/sdl2gfx/SDL2_rotozoom.cpp
deleted file mode 100644
index a37e1c51e..000000000
--- a/src/sdl2gfx/SDL2_rotozoom.cpp
+++ /dev/null
@@ -1,1944 +0,0 @@
-/*
-
-SDL2_rotozoom.c: rotozoomer, zoomer and shrinker for 32bit or 8bit surfaces
-
-Copyright (C) 2012-2014 Andreas Schiffler
-
-This software is provided 'as-is', without any express or implied
-warranty. In no event will the authors be held liable for any damages
-arising from the use of this software.
-
-Permission is granted to anyone to use this software for any purpose,
-including commercial applications, and to alter it and redistribute it
-freely, subject to the following restrictions:
-
-1. The origin of this software must not be misrepresented; you must not
-claim that you wrote the original software. If you use this software
-in a product, an acknowledgment in the product documentation would be
-appreciated but is not required.
-
-2. Altered source versions must be plainly marked as such, and must not be
-misrepresented as being the original software.
-
-3. This notice may not be removed or altered from any source
-distribution.
-
-Andreas Schiffler -- aschiffler at ferzkopp dot net
-
-Changed for ManaPlus (C) 2013-2017 ManaPlus developers
-
-*/
-
-#ifdef WIN32
-#include <windows.h>
-#endif
-
-#include <stdlib.h>
-#include <string.h>
-
-#include "sdl2gfx/SDL2_rotozoom.h"
-
-#include "debug.h"
-
-/* ---- Internally used structures */
-
-/*!
-\brief A 32 bit RGBA pixel.
-*/
-typedef struct tColorRGBA
-{
- Uint8 r;
- Uint8 g;
- Uint8 b;
- Uint8 a;
-} tColorRGBA;
-
-/*!
-\brief A 8bit Y/palette pixel.
-*/
-typedef struct tColorY
-{
- Uint8 y;
-} tColorY;
-
-/*!
-\brief Returns maximum of two numbers a and b.
-*/
-#define MAX(a,b) (((a) > (b)) ? (a) : (b))
-
-/*!
-\brief Number of guard rows added to destination surfaces.
-
-This is a simple but effective workaround for observed issues.
-These rows allocate extra memory and are then hidden from the surface.
-Rows are added to the end of destination surfaces when they are allocated.
-This catches any potential overflows which seem to happen with
-just the right src image dimensions and scale/rotation and can lead
-to a situation where the program can segfault.
-*/
-#define GUARD_ROWS (2)
-
-/*!
-\brief Lower limit of absolute zoom factor or rotation degrees.
-*/
-#define VALUE_LIMIT 0.001
-
-/*!
-\brief Returns colorkey info for a surface
-*/
-static Uint32 _colorkey(SDL_Surface *src)
-{
- Uint32 key = 0;
- SDL_GetColorKey(src, &key);
- return key;
-}
-
-
-/*!
-\brief Internal 32 bit integer-factor averaging Shrinker.
-
-Shrinks 32 bit RGBA/ABGR 'src' surface to 'dst' surface.
-Averages color and alpha values values of src pixels to calculate dst pixels.
-Assumes src and dst surfaces are of 32 bit depth.
-Assumes dst surface was allocated with the correct dimensions.
-
-\param src The surface to shrink (input).
-\param dst The shrunken surface (output).
-\param factorx The horizontal shrinking ratio.
-\param factory The vertical shrinking ratio.
-
-\return 0 for success or -1 for error.
-*/
-static int _shrinkSurfaceRGBA(SDL_Surface *src,
- SDL_Surface *dst,
- int factorx,
- int factory)
-{
- int x, y, dx, dy, dgap, ra, ga, ba, aa;
- int n_average;
- tColorRGBA *sp, *osp, *oosp;
- tColorRGBA *dp;
-
- /*
- * Averaging integer shrink
- */
-
- /* Precalculate division factor */
- n_average = factorx*factory;
-
- /*
- * Scan destination
- */
- sp = static_cast<tColorRGBA *>(src->pixels);
-
- dp = static_cast<tColorRGBA *>(dst->pixels);
- dgap = dst->pitch - dst->w * 4;
-
- for (y = 0; y < dst->h; y++)
- {
- osp=sp;
- for (x = 0; x < dst->w; x++)
- {
- /* Trace out source box and accumulate */
- oosp=sp;
- ra=ga=ba=aa=0;
- for (dy=0; dy < factory; dy++)
- {
- for (dx=0; dx < factorx; dx++)
- {
- ra += sp->r;
- ga += sp->g;
- ba += sp->b;
- aa += sp->a;
-
- sp++;
- }
- /* src dx loop */
- sp = reinterpret_cast<tColorRGBA *>(
- reinterpret_cast<Uint8*>(sp) +
- (src->pitch - 4*factorx)); // next y
- }
- /* src dy loop */
-
- /* next box-x */
- sp = reinterpret_cast<tColorRGBA *>(
- reinterpret_cast<Uint8*>(oosp) + 4*factorx);
-
- /* Store result in destination */
- dp->r = ra/n_average;
- dp->g = ga/n_average;
- dp->b = ba/n_average;
- dp->a = aa/n_average;
-
- /*
- * Advance destination pointer
- */
- dp++;
- }
- /* dst x loop */
-
- /* next box-y */
- sp = reinterpret_cast<tColorRGBA *>(reinterpret_cast<Uint8*>(osp) +
- src->pitch*factory);
-
- /*
- * Advance destination pointers
- */
- dp = reinterpret_cast<tColorRGBA *>(reinterpret_cast<Uint8*>(dp) +
- dgap);
- }
- /* dst y loop */
-
- return (0);
-}
-
-/*!
-\brief Internal 8 bit integer-factor averaging shrinker.
-
-Shrinks 8bit Y 'src' surface to 'dst' surface.
-Averages color (brightness) values values of src pixels to calculate dst pixels.
-Assumes src and dst surfaces are of 8 bit depth.
-Assumes dst surface was allocated with the correct dimensions.
-
-\param src The surface to shrink (input).
-\param dst The shrunken surface (output).
-\param factorx The horizontal shrinking ratio.
-\param factory The vertical shrinking ratio.
-
-\return 0 for success or -1 for error.
-*/
-static int _shrinkSurfaceY(SDL_Surface *src,
- SDL_Surface *dst,
- int factorx,
- int factory)
-{
- int x, y, dx, dy, dgap, a;
- int n_average;
- Uint8 *sp, *osp, *oosp;
- Uint8 *dp;
-
- /*
- * Averaging integer shrink
- */
-
- /* Precalculate division factor */
- n_average = factorx*factory;
-
- /*
- * Scan destination
- */
- sp = static_cast<Uint8*>(src->pixels);
-
- dp = static_cast<Uint8*>(dst->pixels);
- dgap = dst->pitch - dst->w;
-
- for (y = 0; y < dst->h; y++)
- {
- osp=sp;
- for (x = 0; x < dst->w; x++)
- {
- /* Trace out source box and accumulate */
- oosp=sp;
- a=0;
- for (dy=0; dy < factory; dy++)
- {
- for (dx=0; dx < factorx; dx++)
- {
- a += (*sp);
- /* next x */
- sp++;
- }
- /* end src dx loop */
- /* next y */
- sp = static_cast<Uint8*>(static_cast<Uint8*>(sp) +
- (src->pitch - factorx));
- }
- /* end src dy loop */
-
- /* next box-x */
- sp = static_cast<Uint8*>(static_cast<Uint8*>(oosp) + factorx);
-
- /* Store result in destination */
- *dp = a/n_average;
-
- /*
- * Advance destination pointer
- */
- dp++;
- }
- /* end dst x loop */
-
- /* next box-y */
- sp = static_cast<Uint8*>(static_cast<Uint8*>(osp) +
- src->pitch*factory);
-
- /*
- * Advance destination pointers
- */
- dp = static_cast<Uint8*>(static_cast<Uint8*>(dp) + dgap);
- }
- /* end dst y loop */
-
- return (0);
-}
-
-/*!
-\brief Internal 32 bit Zoomer with optional anti-aliasing by bilinear interpolation.
-
-Zooms 32 bit RGBA/ABGR 'src' surface to 'dst' surface.
-Assumes src and dst surfaces are of 32 bit depth.
-Assumes dst surface was allocated with the correct dimensions.
-
-\param src The surface to zoom (input).
-\param dst The zoomed surface (output).
-\param flipx Flag indicating if the image should be horizontally flipped.
-\param flipy Flag indicating if the image should be vertically flipped.
-\param smooth Antialiasing flag; set to SMOOTHING_ON to enable.
-
-\return 0 for success or -1 for error.
-*/
-static int _zoomSurfaceRGBA(SDL_Surface *src,
- SDL_Surface *dst,
- int flipx,
- int flipy,
- int smooth)
-{
- int x, y, sx, sy, ssx, ssy;
- int *sax, *say, *csax, *csay, *salast;
- int csx, csy, ex, ey, cx, cy, sstep, sstepx, sstepy;
- tColorRGBA *c00, *c01, *c10, *c11;
- tColorRGBA *sp, *csp, *dp;
- int spixelgap, spixelw, spixelh, dgap, t1, t2;
-
- /*
- * Allocate memory for row/column increments
- */
- if ((sax = static_cast<int *>(malloc((dst->w + 1) * sizeof(Uint32)))) == nullptr)
- {
- return (-1);
- }
- if ((say = static_cast<int *>(malloc((dst->h + 1) * sizeof(Uint32)))) == nullptr)
- {
- free(sax);
- return (-1);
- }
-
- /*
- * Precalculate row increments
- */
- spixelw = (src->w - 1);
- spixelh = (src->h - 1);
- if (smooth)
- {
- sx = static_cast<int>(65536.0 * static_cast<float>(spixelw) /
- static_cast<float>(dst->w - 1));
- sy = static_cast<int>(65536.0 * static_cast<float>(spixelh) /
- static_cast<float>(dst->h - 1));
- }
- else
- {
- sx = static_cast<int>(65536.0 * static_cast<float>(src->w) /
- static_cast<float>(dst->w));
- sy = static_cast<int>(65536.0 * static_cast<float>(src->h) /
- static_cast<float>(dst->h));
- }
-
- /* Maximum scaled source size */
- ssx = (src->w << 16) - 1;
- ssy = (src->h << 16) - 1;
-
- /* Precalculate horizontal row increments */
- csx = 0;
- csax = sax;
- for (x = 0; x <= dst->w; x++)
- {
- *csax = csx;
- csax++;
- csx += sx;
-
- /* Guard from overflows */
- if (csx > ssx)
- {
- csx = ssx;
- }
- }
-
- /* Precalculate vertical row increments */
- csy = 0;
- csay = say;
- for (y = 0; y <= dst->h; y++)
- {
- *csay = csy;
- csay++;
- csy += sy;
-
- /* Guard from overflows */
- if (csy > ssy)
- {
- csy = ssy;
- }
- }
-
- sp = static_cast<tColorRGBA *>(src->pixels);
- dp = static_cast<tColorRGBA *>(dst->pixels);
- dgap = dst->pitch - dst->w * 4;
- spixelgap = src->pitch/4;
-
- if (flipx) sp += spixelw;
- if (flipy) sp += (spixelgap * spixelh);
-
- /*
- * Switch between interpolating and non-interpolating code
- */
- if (smooth)
- {
- /*
- * Interpolating Zoom
- */
- csay = say;
- for (y = 0; y < dst->h; y++)
- {
- csp = sp;
- csax = sax;
- for (x = 0; x < dst->w; x++)
- {
- /*
- * Setup color source pointers
- */
- ex = (*csax & 0xffff);
- ey = (*csay & 0xffff);
- cx = (*csax >> 16);
- cy = (*csay >> 16);
- sstepx = cx < spixelw;
- sstepy = cy < spixelh;
- c00 = sp;
- c01 = sp;
- c10 = sp;
- if (sstepy)
- {
- if (flipy)
- {
- c10 -= spixelgap;
- }
- else
- {
- c10 += spixelgap;
- }
- }
- c11 = c10;
- if (sstepx)
- {
- if (flipx)
- {
- c01--;
- c11--;
- }
- else
- {
- c01++;
- c11++;
- }
- }
-
- /*
- * Draw and interpolate colors
- */
- t1 = ((((c01->r - c00->r) * ex) >> 16) + c00->r) & 0xff;
- t2 = ((((c11->r - c10->r) * ex) >> 16) + c10->r) & 0xff;
- dp->r = (((t2 - t1) * ey) >> 16) + t1;
- t1 = ((((c01->g - c00->g) * ex) >> 16) + c00->g) & 0xff;
- t2 = ((((c11->g - c10->g) * ex) >> 16) + c10->g) & 0xff;
- dp->g = (((t2 - t1) * ey) >> 16) + t1;
- t1 = ((((c01->b - c00->b) * ex) >> 16) + c00->b) & 0xff;
- t2 = ((((c11->b - c10->b) * ex) >> 16) + c10->b) & 0xff;
- dp->b = (((t2 - t1) * ey) >> 16) + t1;
- t1 = ((((c01->a - c00->a) * ex) >> 16) + c00->a) & 0xff;
- t2 = ((((c11->a - c10->a) * ex) >> 16) + c10->a) & 0xff;
- dp->a = (((t2 - t1) * ey) >> 16) + t1;
- /*
- * Advance source pointer x
- */
- salast = csax;
- csax++;
- sstep = (*csax >> 16) - (*salast >> 16);
- if (flipx)
- {
- sp -= sstep;
- }
- else
- {
- sp += sstep;
- }
-
- /*
- * Advance destination pointer x
- */
- dp++;
- }
- /*
- * Advance source pointer y
- */
- salast = csay;
- csay++;
- sstep = (*csay >> 16) - (*salast >> 16);
- sstep *= spixelgap;
- if (flipy)
- {
- sp = csp - sstep;
- }
- else
- {
- sp = csp + sstep;
- }
-
- /*
- * Advance destination pointer y
- */
- dp = reinterpret_cast<tColorRGBA *>(
- reinterpret_cast<Uint8*>(dp) + dgap);
- }
- }
- else
- {
- /*
- * Non-Interpolating Zoom
- */
- csay = say;
- for (y = 0; y < dst->h; y++)
- {
- csp = sp;
- csax = sax;
- for (x = 0; x < dst->w; x++)
- {
- /*
- * Draw
- */
- *dp = *sp;
-
- /*
- * Advance source pointer x
- */
- salast = csax;
- csax++;
- sstep = (*csax >> 16) - (*salast >> 16);
- if (flipx) sstep = -sstep;
- sp += sstep;
-
- /*
- * Advance destination pointer x
- */
- dp++;
- }
- /*
- * Advance source pointer y
- */
- salast = csay;
- csay++;
- sstep = (*csay >> 16) - (*salast >> 16);
- sstep *= spixelgap;
- if (flipy) sstep = -sstep;
- sp = csp + sstep;
-
- /*
- * Advance destination pointer y
- */
- dp = reinterpret_cast<tColorRGBA *>(
- reinterpret_cast<Uint8*>(dp) + dgap);
- }
- }
-
- /*
- * Remove temp arrays
- */
- free(sax);
- free(say);
-
- return (0);
-}
-
-/*!
-
-\brief Internal 8 bit Zoomer without smoothing.
-
-Zooms 8bit palette/Y 'src' surface to 'dst' surface.
-Assumes src and dst surfaces are of 8 bit depth.
-Assumes dst surface was allocated with the correct dimensions.
-
-\param src The surface to zoom (input).
-\param dst The zoomed surface (output).
-\param flipx Flag indicating if the image should be horizontally flipped.
-\param flipy Flag indicating if the image should be vertically flipped.
-
-\return 0 for success or -1 for error.
-*/
-static int _zoomSurfaceY(SDL_Surface *src,
- SDL_Surface *dst,
- int flipx,
- int flipy)
-{
- int x, y;
- Uint32 *sax, *say, *csax, *csay;
- int csx, csy;
- Uint8 *sp, *dp, *csp;
- int dgap;
-
- /*
- * Allocate memory for row increments
- */
- if ((sax = static_cast<Uint32 *>(malloc((dst->w + 1) *
- sizeof(Uint32)))) == nullptr)
- {
- return (-1);
- }
- if ((say = static_cast<Uint32 *>(malloc((dst->h + 1) *
- sizeof(Uint32)))) == nullptr)
- {
- free(sax);
- return (-1);
- }
-
- /*
- * Pointer setup
- */
- sp = csp = static_cast<Uint8*>(src->pixels);
- dp = static_cast<Uint8*>(dst->pixels);
- dgap = dst->pitch - dst->w;
-
- if (flipx) csp += (src->w-1);
- if (flipy) csp = (static_cast<Uint8*>(csp) + src->pitch*(src->h-1));
-
- /*
- * Precalculate row increments
- */
- csx = 0;
- csax = sax;
- for (x = 0; x < dst->w; x++)
- {
- csx += src->w;
- *csax = 0;
- while (csx >= dst->w)
- {
- csx -= dst->w;
- (*csax)++;
- }
- (*csax) = (*csax) * (flipx ? -1 : 1);
- csax++;
- }
- csy = 0;
- csay = say;
- for (y = 0; y < dst->h; y++)
- {
- csy += src->h;
- *csay = 0;
- while (csy >= dst->h)
- {
- csy -= dst->h;
- (*csay)++;
- }
- (*csay) = (*csay) * (flipy ? -1 : 1);
- csay++;
- }
-
- /*
- * Draw
- */
- csay = say;
- for (y = 0; y < dst->h; y++)
- {
- csax = sax;
- sp = csp;
- for (x = 0; x < dst->w; x++)
- {
- /*
- * Draw
- */
- *dp = *sp;
- /*
- * Advance source pointers
- */
- sp += (*csax);
- csax++;
- /*
- * Advance destination pointer
- */
- dp++;
- }
- /*
- * Advance source pointer (for row)
- */
- csp += ((*csay) * src->pitch);
- csay++;
-
- /*
- * Advance destination pointers
- */
- dp += dgap;
- }
-
- /*
- * Remove temp arrays
- */
- free(sax);
- free(say);
-
- return (0);
-}
-
-/*!
-\brief Internal 32 bit rotozoomer with optional anti-aliasing.
-
-Rotates and zooms 32 bit RGBA/ABGR 'src' surface to 'dst' surface based on the control
-parameters by scanning the destination surface and applying optionally anti-aliasing
-by bilinear interpolation.
-Assumes src and dst surfaces are of 32 bit depth.
-Assumes dst surface was allocated with the correct dimensions.
-
-\param src Source surface.
-\param dst Destination surface.
-\param cx Horizontal center coordinate.
-\param cy Vertical center coordinate.
-\param isin Integer version of sine of angle.
-\param icos Integer version of cosine of angle.
-\param flipx Flag indicating horizontal mirroring should be applied.
-\param flipy Flag indicating vertical mirroring should be applied.
-\param smooth Flag indicating anti-aliasing should be used.
-*/
-static void _transformSurfaceRGBA(SDL_Surface *src,
- SDL_Surface *dst,
- int cx,
- int cy,
- int isin,
- int icos,
- int flipx,
- int flipy,
- int smooth)
-{
- int x, y, t1, t2, dx, dy, xd, yd, sdx, sdy, ax, ay, ex, ey, sw, sh;
- tColorRGBA c00, c01, c10, c11, cswap;
- tColorRGBA *pc, *sp;
- int gap;
-
- /*
- * Variable setup
- */
- xd = ((src->w - dst->w) << 15);
- yd = ((src->h - dst->h) << 15);
- ax = (cx << 16) - (icos * cx);
- ay = (cy << 16) - (isin * cx);
- sw = src->w - 1;
- sh = src->h - 1;
- pc = static_cast<tColorRGBA*>(dst->pixels);
- gap = dst->pitch - dst->w * 4;
-
- /*
- * Switch between interpolating and non-interpolating code
- */
- if (smooth)
- {
- for (y = 0; y < dst->h; y++)
- {
- dy = cy - y;
- sdx = (ax + (isin * dy)) + xd;
- sdy = (ay - (icos * dy)) + yd;
- for (x = 0; x < dst->w; x++)
- {
- dx = (sdx >> 16);
- dy = (sdy >> 16);
- if (flipx) dx = sw - dx;
- if (flipy) dy = sh - dy;
- if ((dx > -1) && (dy > -1) &&
- (dx < (src->w-1)) && (dy < (src->h-1)))
- {
- sp = static_cast<tColorRGBA *>(src->pixels);
- sp += ((src->pitch/4) * dy);
- sp += dx;
- c00 = *sp;
- sp += 1;
- c01 = *sp;
- sp += (src->pitch/4);
- c11 = *sp;
- sp -= 1;
- c10 = *sp;
- if (flipx)
- {
- cswap = c00; c00=c01; c01=cswap;
- cswap = c10; c10=c11; c11=cswap;
- }
- if (flipy)
- {
- cswap = c00; c00=c10; c10=cswap;
- cswap = c01; c01=c11; c11=cswap;
- }
- /*
- * Interpolate colors
- */
- ex = (sdx & 0xffff);
- ey = (sdy & 0xffff);
- t1 = ((((c01.r - c00.r) * ex) >> 16) + c00.r) & 0xff;
- t2 = ((((c11.r - c10.r) * ex) >> 16) + c10.r) & 0xff;
- pc->r = (((t2 - t1) * ey) >> 16) + t1;
- t1 = ((((c01.g - c00.g) * ex) >> 16) + c00.g) & 0xff;
- t2 = ((((c11.g - c10.g) * ex) >> 16) + c10.g) & 0xff;
- pc->g = (((t2 - t1) * ey) >> 16) + t1;
- t1 = ((((c01.b - c00.b) * ex) >> 16) + c00.b) & 0xff;
- t2 = ((((c11.b - c10.b) * ex) >> 16) + c10.b) & 0xff;
- pc->b = (((t2 - t1) * ey) >> 16) + t1;
- t1 = ((((c01.a - c00.a) * ex) >> 16) + c00.a) & 0xff;
- t2 = ((((c11.a - c10.a) * ex) >> 16) + c10.a) & 0xff;
- pc->a = (((t2 - t1) * ey) >> 16) + t1;
- }
- sdx += icos;
- sdy += isin;
- pc++;
- }
- pc = reinterpret_cast<tColorRGBA *>(
- reinterpret_cast<Uint8*>(pc) + gap);
- }
- }
- else
- {
- for (y = 0; y < dst->h; y++)
- {
- dy = cy - y;
- sdx = (ax + (isin * dy)) + xd;
- sdy = (ay - (icos * dy)) + yd;
- for (x = 0; x < dst->w; x++)
- {
- dx = static_cast<short>(sdx >> 16);
- dy = static_cast<short>(sdy >> 16);
- if (flipx) dx = (src->w-1)-dx;
- if (flipy) dy = (src->h-1)-dy;
- if ((dx >= 0) && (dy >= 0) && (dx < src->w) && (dy < src->h))
- {
- sp = reinterpret_cast<tColorRGBA *>(
- reinterpret_cast<Uint8*>(src->pixels) +
- src->pitch * dy);
- sp += dx;
- *pc = *sp;
- }
- sdx += icos;
- sdy += isin;
- pc++;
- }
- pc = reinterpret_cast<tColorRGBA *>(
- reinterpret_cast<Uint8*>(pc) + gap);
- }
- }
-}
-
-/*!
-
-\brief Rotates and zooms 8 bit palette/Y 'src' surface to 'dst' surface without smoothing.
-
-Rotates and zooms 8 bit RGBA/ABGR 'src' surface to 'dst' surface based on the control
-parameters by scanning the destination surface.
-Assumes src and dst surfaces are of 8 bit depth.
-Assumes dst surface was allocated with the correct dimensions.
-
-\param src Source surface.
-\param dst Destination surface.
-\param cx Horizontal center coordinate.
-\param cy Vertical center coordinate.
-\param isin Integer version of sine of angle.
-\param icos Integer version of cosine of angle.
-\param flipx Flag indicating horizontal mirroring should be applied.
-\param flipy Flag indicating vertical mirroring should be applied.
-*/
-static void transformSurfaceY(SDL_Surface *src,
- SDL_Surface *dst,
- int cx,
- int cy,
- int isin,
- int icos,
- int flipx,
- int flipy)
-{
- int x, y, dx, dy, xd, yd, sdx, sdy, ax, ay;
- tColorY *pc, *sp;
- int gap;
-
- /*
- * Variable setup
- */
- xd = ((src->w - dst->w) << 15);
- yd = ((src->h - dst->h) << 15);
- ax = (cx << 16) - (icos * cx);
- ay = (cy << 16) - (isin * cx);
- pc = static_cast<tColorY*>(dst->pixels);
- gap = dst->pitch - dst->w;
- /*
- * Clear surface to colorkey
- */
- memset(pc, static_cast<int>(_colorkey(src) & 0xff), dst->pitch * dst->h);
- /*
- * Iterate through destination surface
- */
- for (y = 0; y < dst->h; y++)
- {
- dy = cy - y;
- sdx = (ax + (isin * dy)) + xd;
- sdy = (ay - (icos * dy)) + yd;
- for (x = 0; x < dst->w; x++)
- {
- dx = static_cast<short>(sdx >> 16);
- dy = static_cast<short>(sdy >> 16);
- if (flipx) dx = (src->w-1)-dx;
- if (flipy) dy = (src->h-1)-dy;
- if ((dx >= 0) && (dy >= 0) && (dx < src->w) && (dy < src->h))
- {
- sp = static_cast<tColorY *>(src->pixels);
- sp += (src->pitch * dy + dx);
- *pc = *sp;
- }
- sdx += icos;
- sdy += isin;
- pc++;
- }
- pc += gap;
- }
-}
-
-/*!
-\brief Rotates a 8/16/24/32 bit surface in increments of 90 degrees.
-
-Specialized 90 degree rotator which rotates a 'src' surface in 90 degree
-increments clockwise returning a new surface. Faster than rotozoomer since
-no scanning or interpolation takes place. Input surface must be 8/16/24/32 bit.
-(code contributed by J. Schiller, improved by C. Allport and A. Schiffler)
-
-\param src Source surface to rotate.
-\param numClockwiseTurns Number of clockwise 90 degree turns to apply to the source.
-
-\returns The new, rotated surface; or nullptr for surfaces with incorrect input format.
-*/
-SDL_Surface* rotateSurface90Degrees(SDL_Surface *src,
- int numClockwiseTurns)
-{
- int row, col, newWidth, newHeight;
- int bpp, bpr;
- SDL_Surface* dst;
- Uint8* srcBuf;
- Uint8* dstBuf;
- int normalizedClockwiseTurns;
-
- /* Has to be a valid surface pointer and be a Nbit surface where n is divisible by 8 */
- if (!src ||
- !src->format)
- {
- SDL_SetError("NULL source surface or source surface format");
- return nullptr;
- }
-
- if ((src->format->BitsPerPixel % 8) != 0)
- {
- SDL_SetError("Invalid source surface bit depth");
- return nullptr;
- }
-
- /* normalize numClockwiseTurns */
- normalizedClockwiseTurns = (numClockwiseTurns % 4);
- if (normalizedClockwiseTurns < 0)
- {
- normalizedClockwiseTurns += 4;
- }
-
- /* If turns are even, our new width/height will be the same as the source surface */
- if (normalizedClockwiseTurns % 2)
- {
- newWidth = src->h;
- newHeight = src->w;
- }
- else
- {
- newWidth = src->w;
- newHeight = src->h;
- }
-
- dst = SDL_CreateRGBSurface(src->flags,
- newWidth,
- newHeight,
- src->format->BitsPerPixel,
- src->format->Rmask,
- src->format->Gmask,
- src->format->Bmask,
- src->format->Amask);
- if (!dst)
- {
- SDL_SetError("Could not create destination surface");
- return nullptr;
- }
-
- if (SDL_MUSTLOCK(src))
- {
- SDL_LockSurface(src);
- }
- if (SDL_MUSTLOCK(dst))
- {
- SDL_LockSurface(dst);
- }
-
- /* Calculate byte-per-pixel */
- bpp = src->format->BitsPerPixel / 8;
-
- switch (normalizedClockwiseTurns)
- {
- case 0: /* Make a copy of the surface */
- {
- /* Unfortunately SDL_BlitSurface cannot be used to
- make a copy of the surface
- since it does not preserve alpha. */
-
- if (src->pitch == dst->pitch)
- {
- /* If the pitch is the same for both surfaces,
- the memory can be copied all at once. */
- memcpy(dst->pixels, src->pixels, (src->h * src->pitch));
- }
- else
- {
- /* If the pitch differs, copy each row separately */
- srcBuf = static_cast<Uint8*>(src->pixels);
- dstBuf = static_cast<Uint8*>(dst->pixels);
- bpr = src->w * bpp;
- for (row = 0; row < src->h; row++)
- {
- memcpy(dstBuf, srcBuf, bpr);
- srcBuf += src->pitch;
- dstBuf += dst->pitch;
- }
- }
- }
- break;
-
- /* rotate clockwise */
- case 1: /* rotated 90 degrees clockwise */
- {
- for (row = 0; row < src->h; ++row)
- {
- srcBuf = static_cast<Uint8*>(src->pixels) +
- (row * src->pitch);
- dstBuf = static_cast<Uint8*>(dst->pixels) +
- (dst->w - row - 1) * bpp;
- for (col = 0; col < src->w; ++col)
- {
- memcpy (dstBuf, srcBuf, bpp);
- srcBuf += bpp;
- dstBuf += dst->pitch;
- }
- }
- }
- break;
-
- case 2: /* rotated 180 degrees clockwise */
- {
- for (row = 0; row < src->h; ++row)
- {
- srcBuf = static_cast<Uint8*>(src->pixels) +
- (row * src->pitch);
- dstBuf = static_cast<Uint8*>(dst->pixels) +
- ((dst->h - row - 1) * dst->pitch) + (dst->w - 1) * bpp;
- for (col = 0; col < src->w; ++col)
- {
- memcpy (dstBuf, srcBuf, bpp);
- srcBuf += bpp;
- dstBuf -= bpp;
- }
- }
- }
- break;
-
- case 3: /* rotated 270 degrees clockwise */
- {
- for (row = 0; row < src->h; ++row)
- {
- srcBuf = static_cast<Uint8*>(src->pixels) + (row * src->pitch);
- dstBuf = static_cast<Uint8*>(dst->pixels) +
- (row * bpp) + (dst->h * dst->pitch);
- for (col = 0; col < src->w; ++col)
- {
- memcpy (dstBuf, srcBuf, bpp);
- srcBuf += bpp;
- dstBuf -= dst->pitch;
- }
- }
- }
- break;
- default:
- break;
- }
- /* end switch */
-
- if (SDL_MUSTLOCK(src))
- {
- SDL_UnlockSurface(src);
- }
- if (SDL_MUSTLOCK(dst))
- {
- SDL_UnlockSurface(dst);
- }
-
- return dst;
-}
-
-
-/*!
-\brief Internal target surface sizing function for rotozooms
-with trig result return.
-
-\param width The source surface width.
-\param height The source surface height.
-\param angle The angle to rotate in degrees.
-\param zoomx The horizontal scaling factor.
-\param zoomy The vertical scaling factor.
-\param dstwidth The calculated width of the destination surface.
-\param dstheight The calculated height of the destination surface.
-\param canglezoom The sine of the angle adjusted by the zoom factor.
-\param sanglezoom The cosine of the angle adjusted by the zoom factor.
-
-*/
-static void _rotozoomSurfaceSizeTrig(int width,
- int height,
- double angle,
- double zoomx,
- double zoomy,
- int *dstwidth,
- int *dstheight,
- double *canglezoom,
- double *sanglezoom)
-{
- double x, y, cx, cy, sx, sy;
- double radangle;
- int dstwidthhalf, dstheighthalf;
-
- /*
- * Determine destination width and height by rotating a centered source box
- */
- radangle = angle * (M_PI / 180.0);
- *sanglezoom = sin(radangle);
- *canglezoom = cos(radangle);
- *sanglezoom *= zoomx;
- *canglezoom *= zoomy;
- x = static_cast<double>(width / 2);
- y = static_cast<double>(height / 2);
- cx = *canglezoom * x;
- cy = *canglezoom * y;
- sx = *sanglezoom * x;
- sy = *sanglezoom * y;
-
- dstwidthhalf = MAX(static_cast<int>(
- ceil(MAX(MAX(MAX(fabs(cx + sy), fabs(cx - sy)),
- fabs(-cx + sy)), fabs(-cx - sy)))), 1);
- dstheighthalf = MAX(static_cast<int>(
- ceil(MAX(MAX(MAX(fabs(sx + cy), fabs(sx - cy)),
- fabs(-sx + cy)), fabs(-sx - cy)))), 1);
- *dstwidth = 2 * dstwidthhalf;
- *dstheight = 2 * dstheighthalf;
-}
-
-/*!
-\brief Returns the size of the resulting target surface for a
-rotozoomSurfaceXY() call.
-
-\param width The source surface width.
-\param height The source surface height.
-\param angle The angle to rotate in degrees.
-\param zoomx The horizontal scaling factor.
-\param zoomy The vertical scaling factor.
-\param dstwidth The calculated width of the rotozoomed destination surface.
-\param dstheight The calculated height of the rotozoomed destination surface.
-*/
-void rotozoomSurfaceSizeXY(int width,
- int height,
- double angle,
- double zoomx,
- double zoomy,
- int *dstwidth,
- int *dstheight)
-{
- double dummy_sanglezoom, dummy_canglezoom;
-
- _rotozoomSurfaceSizeTrig(width, height, angle, zoomx, zoomy,
- dstwidth, dstheight, &dummy_sanglezoom, &dummy_canglezoom);
-}
-
-/*!
-\brief Returns the size of the resulting target surface for a rotozoomSurface()
-call.
-
-\param width The source surface width.
-\param height The source surface height.
-\param angle The angle to rotate in degrees.
-\param zoom The scaling factor.
-\param dstwidth The calculated width of the rotozoomed destination surface.
-\param dstheight The calculated height of the rotozoomed destination surface.
-*/
-void rotozoomSurfaceSize(int width,
- int height,
- double angle,
- double zoom,
- int *dstwidth,
- int *dstheight)
-{
- double dummy_sanglezoom, dummy_canglezoom;
-
- _rotozoomSurfaceSizeTrig(width, height, angle, zoom, zoom,
- dstwidth, dstheight, &dummy_sanglezoom, &dummy_canglezoom);
-}
-
-/*!
-\brief Rotates and zooms a surface and optional anti-aliasing.
-
-Rotates and zoomes a 32bit or 8bit 'src' surface to newly created 'dst'
-surface. 'angle' is the rotation in degrees and 'zoom' a scaling factor.
-If 'smooth' is set then the destination 32bit surface is anti-aliased.
-If the surface is not 8bit or 32bit RGBA/ABGR it will be converted into
-a 32bit RGBA format on the fly.
-
-\param src The surface to rotozoom.
-\param angle The angle to rotate in degrees.
-\param zoom The scaling factor.
-\param smooth Antialiasing flag; set to SMOOTHING_ON to enable.
-
-\return The new rotozoomed surface.
-*/
-SDL_Surface *rotozoomSurface(SDL_Surface *src,
- double angle,
- double zoom,
- int smooth)
-{
- return rotozoomSurfaceXY(src, angle, zoom, zoom, smooth);
-}
-
-/*!
-\brief Rotates and zooms a surface with different horizontal and
-vertival scaling factors and optional anti-aliasing.
-
-Rotates and zooms a 32bit or 8bit 'src' surface to newly created 'dst' surface.
-'angle' is the rotation in degrees, 'zoomx and 'zoomy' scaling factors.
-If 'smooth' is set then the destination 32bit surface is anti-aliased.
-If the surface is not 8bit or 32bit RGBA/ABGR it will be converted into
-a 32bit RGBA format on the fly.
-
-\param src The surface to rotozoom.
-\param angle The angle to rotate in degrees.
-\param zoomx The horizontal scaling factor.
-\param zoomy The vertical scaling factor.
-\param smooth Antialiasing flag; set to SMOOTHING_ON to enable.
-
-\return The new rotozoomed surface.
-*/
-SDL_Surface *rotozoomSurfaceXY(SDL_Surface *src,
- double angle,
- double zoomx,
- double zoomy,
- int smooth)
-{
- SDL_Surface *rz_src;
- SDL_Surface *rz_dst;
- double zoominv;
- double sanglezoom, canglezoom, sanglezoominv, canglezoominv;
- int dstwidthhalf, dstwidth, dstheighthalf, dstheight;
- int is32bit;
- int i, src_converted;
- int flipx,flipy;
-
- /*
- * Sanity check
- */
- if (src == nullptr)
- {
- return (nullptr);
- }
-
- /*
- * Determine if source surface is 32bit or 8bit
- */
- is32bit = (src->format->BitsPerPixel == 32);
- if ((is32bit) || (src->format->BitsPerPixel == 8))
- {
- /*
- * Use source surface 'as is'
- */
- rz_src = src;
- src_converted = 0;
- }
- else
- {
- /*
- * New source surface is 32bit with a defined RGBA ordering
- */
- rz_src =
- SDL_CreateRGBSurface(SDL_SWSURFACE, src->w, src->h, 32,
-#if SDL_BYTEORDER == SDL_LIL_ENDIAN
- 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000
-#else
- 0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff
-#endif
- );
-
- SDL_BlitSurface(src, nullptr, rz_src, nullptr);
-
- src_converted = 1;
- is32bit = 1;
- }
-
- /*
- * Sanity check zoom factor
- */
- flipx = (zoomx<0.0);
- if (flipx) zoomx=-zoomx;
- flipy = (zoomy<0.0);
- if (flipy) zoomy=-zoomy;
- if (zoomx < VALUE_LIMIT) zoomx = VALUE_LIMIT;
- if (zoomy < VALUE_LIMIT) zoomy = VALUE_LIMIT;
- zoominv = 65536.0 / (zoomx * zoomx);
-
- /*
- * Check if we have a rotozoom or just a zoom
- */
- if (fabs(angle) > VALUE_LIMIT)
- {
-
- /*
- * Angle!=0: full rotozoom
- */
- /*
- * -----------------------
- */
-
- /* Determine target size */
- _rotozoomSurfaceSizeTrig(rz_src->w, rz_src->h, angle, zoomx, zoomy,
- &dstwidth, &dstheight, &canglezoom, &sanglezoom);
-
- /*
- * Calculate target factors from sin/cos and zoom
- */
- sanglezoominv = sanglezoom;
- canglezoominv = canglezoom;
- sanglezoominv *= zoominv;
- canglezoominv *= zoominv;
-
- /* Calculate half size */
- dstwidthhalf = dstwidth / 2;
- dstheighthalf = dstheight / 2;
-
- /*
- * Alloc space to completely contain the rotated surface
- */
- rz_dst = nullptr;
- if (is32bit)
- {
- /*
- * Target surface is 32bit with source RGBA/ABGR ordering
- */
- rz_dst =
- SDL_CreateRGBSurface(SDL_SWSURFACE,
- dstwidth, dstheight + GUARD_ROWS, 32,
- rz_src->format->Rmask, rz_src->format->Gmask,
- rz_src->format->Bmask, rz_src->format->Amask);
- }
- else
- {
- /*
- * Target surface is 8bit
- */
- rz_dst = SDL_CreateRGBSurface(SDL_SWSURFACE, dstwidth,
- dstheight + GUARD_ROWS, 8, 0, 0, 0, 0);
- }
-
- /* Check target */
- if (rz_dst == nullptr)
- return nullptr;
-
- /* Adjust for guard rows */
- rz_dst->h = dstheight;
-
- /*
- * Lock source surface
- */
- if (SDL_MUSTLOCK(rz_src))
- {
- SDL_LockSurface(rz_src);
- }
-
- /*
- * Check which kind of surface we have
- */
- if (is32bit)
- {
- /*
- * Call the 32bit transformation routine to do the rotation
- * (using alpha)
- */
- _transformSurfaceRGBA(rz_src, rz_dst, dstwidthhalf, dstheighthalf,
- static_cast<int>(sanglezoominv),
- static_cast<int>(canglezoominv),
- flipx, flipy,
- smooth);
- }
- else
- {
- /*
- * Copy palette and colorkey info
- */
- for (i = 0; i < rz_src->format->palette->ncolors; i++)
- {
- rz_dst->format->palette->colors[i] =
- rz_src->format->palette->colors[i];
- }
- rz_dst->format->palette->ncolors =
- rz_src->format->palette->ncolors;
- /*
- * Call the 8bit transformation routine to do the rotation
- */
- transformSurfaceY(rz_src, rz_dst, dstwidthhalf, dstheighthalf,
- static_cast<int>(sanglezoominv),
- static_cast<int>(canglezoominv),
- flipx, flipy);
- }
- /*
- * Unlock source surface
- */
- if (SDL_MUSTLOCK(rz_src))
- {
- SDL_UnlockSurface(rz_src);
- }
-
- }
- else
- {
- /*
- * Angle=0: Just a zoom
- */
- /*
- * --------------------
- */
-
- /*
- * Calculate target size
- */
- zoomSurfaceSize(rz_src->w, rz_src->h, zoomx, zoomy,
- &dstwidth, &dstheight);
-
- /*
- * Alloc space to completely contain the zoomed surface
- */
- rz_dst = nullptr;
- if (is32bit)
- {
- /*
- * Target surface is 32bit with source RGBA/ABGR ordering
- */
- rz_dst =
- SDL_CreateRGBSurface(SDL_SWSURFACE,
- dstwidth, dstheight + GUARD_ROWS, 32,
- rz_src->format->Rmask, rz_src->format->Gmask,
- rz_src->format->Bmask, rz_src->format->Amask);
- }
- else
- {
- /*
- * Target surface is 8bit
- */
- rz_dst = SDL_CreateRGBSurface(SDL_SWSURFACE,
- dstwidth, dstheight + GUARD_ROWS, 8, 0, 0, 0, 0);
- }
-
- /* Check target */
- if (rz_dst == nullptr)
- return nullptr;
-
- /* Adjust for guard rows */
- rz_dst->h = dstheight;
-
- /*
- * Lock source surface
- */
- if (SDL_MUSTLOCK(rz_src))
- {
- SDL_LockSurface(rz_src);
- }
-
- /*
- * Check which kind of surface we have
- */
- if (is32bit)
- {
- /*
- * Call the 32bit transformation routine to do the zooming
- * (using alpha)
- */
- _zoomSurfaceRGBA(rz_src, rz_dst, flipx, flipy, smooth);
-
- }
- else
- {
- /*
- * Copy palette and colorkey info
- */
- for (i = 0; i < rz_src->format->palette->ncolors; i++)
- {
- rz_dst->format->palette->colors[i] =
- rz_src->format->palette->colors[i];
- }
- rz_dst->format->palette->ncolors =
- rz_src->format->palette->ncolors;
-
- /*
- * Call the 8bit transformation routine to do the zooming
- */
- _zoomSurfaceY(rz_src, rz_dst, flipx, flipy);
- }
-
- /*
- * Unlock source surface
- */
- if (SDL_MUSTLOCK(rz_src))
- {
- SDL_UnlockSurface(rz_src);
- }
- }
-
- /*
- * Cleanup temp surface
- */
- if (src_converted)
- {
- SDL_FreeSurface(rz_src);
- }
-
- /*
- * Return destination surface
- */
- return (rz_dst);
-}
-
-/*!
-\brief Calculates the size of the target surface for a zoomSurface() call.
-
-The minimum size of the target surface is 1. The input factors
-can be positive or negative.
-
-\param width The width of the source surface to zoom.
-\param height The height of the source surface to zoom.
-\param zoomx The horizontal zoom factor.
-\param zoomy The vertical zoom factor.
-\param dstwidth Pointer to an integer to store the calculated
-width of the zoomed target surface.
-\param dstheight Pointer to an integer to store the calculated
-height of the zoomed target surface.
-*/
-void zoomSurfaceSize(int width, int height,
- double zoomx, double zoomy,
- int *dstwidth, int *dstheight)
-{
- /*
- * Make zoom factors positive
- */
- int flipx, flipy;
- flipx = (zoomx<0.0);
- if (flipx) zoomx = -zoomx;
- flipy = (zoomy<0.0);
- if (flipy) zoomy = -zoomy;
-
- /*
- * Sanity check zoom factors
- */
- if (zoomx < VALUE_LIMIT)
- {
- zoomx = VALUE_LIMIT;
- }
- if (zoomy < VALUE_LIMIT)
- {
- zoomy = VALUE_LIMIT;
- }
-
- /*
- * Calculate target size
- */
- *dstwidth = static_cast<int>(floor((static_cast<double>(
- width) * zoomx) + 0.5));
- *dstheight = static_cast<int>(floor((static_cast<double>(
- height) * zoomy) + 0.5));
- if (*dstwidth < 1)
- {
- *dstwidth = 1;
- }
- if (*dstheight < 1)
- {
- *dstheight = 1;
- }
-}
-
-/*!
-\brief Zoom a surface by independent horizontal and vertical
-factors with optional smoothing.
-
-Zooms a 32bit or 8bit 'src' surface to newly created 'dst' surface.
-'zoomx' and 'zoomy' are scaling factors for width and height. If 'smooth' is on
-then the destination 32bit surface is anti-aliased. If the surface is not 8bit
-or 32bit RGBA/ABGR it will be converted into a 32bit RGBA format on the fly.
-If zoom factors are negative, the image is flipped on the axes.
-
-\param src The surface to zoom.
-\param zoomx The horizontal zoom factor.
-\param zoomy The vertical zoom factor.
-\param smooth Antialiasing flag; set to SMOOTHING_ON to enable.
-
-\return The new, zoomed surface.
-*/
-SDL_Surface *zoomSurface(SDL_Surface *src,
- double zoomx,
- double zoomy,
- int smooth)
-{
- SDL_Surface *rz_src;
- SDL_Surface *rz_dst;
- int dstwidth, dstheight;
- int is32bit;
- int i, src_converted;
- int flipx, flipy;
-
- /*
- * Sanity check
- */
- if (src == nullptr)
- return (nullptr);
-
- /*
- * Determine if source surface is 32bit or 8bit
- */
- is32bit = (src->format->BitsPerPixel == 32);
- if ((is32bit) || (src->format->BitsPerPixel == 8))
- {
- /*
- * Use source surface 'as is'
- */
- rz_src = src;
- src_converted = 0;
- }
- else
- {
- /*
- * New source surface is 32bit with a defined RGBA ordering
- */
- rz_src =
- SDL_CreateRGBSurface(SDL_SWSURFACE, src->w, src->h, 32,
-#if SDL_BYTEORDER == SDL_LIL_ENDIAN
- 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000
-#else
- 0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff
-#endif
- );
- if (rz_src == nullptr)
- {
- return nullptr;
- }
- SDL_BlitSurface(src, nullptr, rz_src, nullptr);
- src_converted = 1;
- is32bit = 1;
- }
-
- flipx = (zoomx<0.0);
- if (flipx) zoomx = -zoomx;
- flipy = (zoomy<0.0);
- if (flipy) zoomy = -zoomy;
-
- /* Get size if target */
- zoomSurfaceSize(rz_src->w, rz_src->h, zoomx, zoomy, &dstwidth, &dstheight);
-
- /*
- * Alloc space to completely contain the zoomed surface
- */
- rz_dst = nullptr;
- if (is32bit)
- {
- /*
- * Target surface is 32bit with source RGBA/ABGR ordering
- */
- rz_dst = SDL_CreateRGBSurface(SDL_SWSURFACE,
- dstwidth, dstheight + GUARD_ROWS, 32,
- rz_src->format->Rmask, rz_src->format->Gmask,
- rz_src->format->Bmask, rz_src->format->Amask);
- }
- else
- {
- /*
- * Target surface is 8bit
- */
- rz_dst = SDL_CreateRGBSurface(SDL_SWSURFACE,
- dstwidth, dstheight + GUARD_ROWS, 8, 0, 0, 0, 0);
- }
-
- /* Check target */
- if (rz_dst == nullptr)
- {
- /*
- * Cleanup temp surface
- */
- if (src_converted)
- {
- SDL_FreeSurface(rz_src);
- }
- return nullptr;
- }
-
- /* Adjust for guard rows */
- rz_dst->h = dstheight;
-
- /*
- * Lock source surface
- */
- if (SDL_MUSTLOCK(rz_src))
- {
- SDL_LockSurface(rz_src);
- }
-
- /*
- * Check which kind of surface we have
- */
- if (is32bit)
- {
- /*
- * Call the 32bit transformation routine to do the zooming (using alpha)
- */
- _zoomSurfaceRGBA(rz_src, rz_dst, flipx, flipy, smooth);
- }
- else
- {
- /*
- * Copy palette and colorkey info
- */
- for (i = 0; i < rz_src->format->palette->ncolors; i++)
- {
- rz_dst->format->palette->colors[i] =
- rz_src->format->palette->colors[i];
- }
- rz_dst->format->palette->ncolors = rz_src->format->palette->ncolors;
- /*
- * Call the 8bit transformation routine to do the zooming
- */
- _zoomSurfaceY(rz_src, rz_dst, flipx, flipy);
- }
- /*
- * Unlock source surface
- */
- if (SDL_MUSTLOCK(rz_src))
- {
- SDL_UnlockSurface(rz_src);
- }
-
- /*
- * Cleanup temp surface
- */
- if (src_converted)
- {
- SDL_FreeSurface(rz_src);
- }
-
- /*
- * Return destination surface
- */
- return (rz_dst);
-}
-
-/*!
-\brief Shrink a surface by an integer ratio using averaging.
-
-Shrinks a 32bit or 8bit 'src' surface to a newly created 'dst' surface.
-'factorx' and 'factory' are the shrinking ratios (i.e. 2=1/2 the size,
-3=1/3 the size, etc.) The destination surface is antialiased by averaging
-the source box RGBA or Y information. If the surface is not 8bit
-or 32bit RGBA/ABGR it will be converted into a 32bit RGBA format on the fly.
-The input surface is not modified. The output surface is newly allocated.
-
-\param src The surface to shrink.
-\param factorx The horizontal shrinking ratio.
-\param factory The vertical shrinking ratio.
-
-\return The new, shrunken surface.
-*/
-/*@nullptr@*/
-SDL_Surface *shrinkSurface(SDL_Surface *src,
- int factorx,
- int factory)
-{
- int result;
- SDL_Surface *rz_src;
- SDL_Surface *rz_dst = nullptr;
- int dstwidth, dstheight;
- int is32bit;
- int i, src_converted = 0;
- int haveError = 0;
-
- /*
- * Sanity check
- */
- if (src == nullptr)
- {
- return (nullptr);
- }
-
- /*
- * Determine if source surface is 32bit or 8bit
- */
- is32bit = (src->format->BitsPerPixel == 32);
- if ((is32bit) || (src->format->BitsPerPixel == 8))
- {
- /*
- * Use source surface 'as is'
- */
- rz_src = src;
- src_converted = 0;
- }
- else
- {
- /*
- * New source surface is 32bit with a defined RGBA ordering
- */
- rz_src = SDL_CreateRGBSurface(SDL_SWSURFACE, src->w, src->h, 32,
-#if SDL_BYTEORDER == SDL_LIL_ENDIAN
- 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000
-#else
- 0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff
-#endif
- );
- if (rz_src==nullptr)
- {
- haveError = 1;
- goto exitShrinkSurface;
- }
-
- SDL_BlitSurface(src, nullptr, rz_src, nullptr);
- src_converted = 1;
- is32bit = 1;
- }
-
- /*
- * Lock the surface
- */
- if (SDL_MUSTLOCK(rz_src))
- {
- if (SDL_LockSurface(rz_src) < 0)
- {
- haveError = 1;
- goto exitShrinkSurface;
- }
- }
-
- /* Get size for target */
- dstwidth=rz_src->w/factorx;
- while (dstwidth*factorx>rz_src->w)
- {
- dstwidth--;
- }
- dstheight=rz_src->h/factory;
- while (dstheight*factory>rz_src->h)
- {
- dstheight--;
- }
-
- /*
- * Alloc space to completely contain the shrunken surface
- * (with added guard rows)
- */
- if (is32bit==1)
- {
- /*
- * Target surface is 32bit with source RGBA/ABGR ordering
- */
- rz_dst = SDL_CreateRGBSurface(
- SDL_SWSURFACE, dstwidth, dstheight + GUARD_ROWS, 32,
- rz_src->format->Rmask, rz_src->format->Gmask,
- rz_src->format->Bmask, rz_src->format->Amask);
- }
- else
- {
- /*
- * Target surface is 8bit
- */
- rz_dst = SDL_CreateRGBSurface(SDL_SWSURFACE,
- dstwidth, dstheight + GUARD_ROWS, 8, 0, 0, 0, 0);
- }
-
- /* Check target */
- if (rz_dst == nullptr)
- {
- haveError = 1;
- goto exitShrinkSurface;
- }
-
- /* Adjust for guard rows */
- rz_dst->h = dstheight;
-
- /*
- * Check which kind of surface we have
- */
- if (is32bit==1)
- {
- /*
- * Call the 32bit transformation routine to do the shrinking (using alpha)
- */
- result = _shrinkSurfaceRGBA(rz_src, rz_dst, factorx, factory);
- if ((result!=0) || (rz_dst==nullptr))
- {
- haveError = 1;
- goto exitShrinkSurface;
- }
- }
- else
- {
- /*
- * Copy palette and colorkey info
- */
- for (i = 0; i < rz_src->format->palette->ncolors; i++)
- {
- rz_dst->format->palette->colors[i] = rz_src->format->palette->colors[i];
- }
- rz_dst->format->palette->ncolors = rz_src->format->palette->ncolors;
- /*
- * Call the 8bit transformation routine to do the shrinking
- */
- result = _shrinkSurfaceY(rz_src, rz_dst, factorx, factory);
- if (result!=0)
- {
- haveError = 1;
- goto exitShrinkSurface;
- }
- }
-
-exitShrinkSurface:
- if (rz_src!=nullptr)
- {
- /*
- * Unlock source surface
- */
- if (SDL_MUSTLOCK(rz_src))
- {
- SDL_UnlockSurface(rz_src);
- }
-
- /*
- * Cleanup temp surface
- */
- if (src_converted==1)
- {
- SDL_FreeSurface(rz_src);
- }
- }
-
- /* Check error state; maybe need to cleanup destination */
- if (haveError==1)
- {
- if (rz_dst!=nullptr)
- {
- SDL_FreeSurface(rz_dst);
- }
- rz_dst=nullptr;
- }
-
- /*
- * Return destination surface
- */
- return (rz_dst);
-}
diff --git a/src/sdl2gfx/SDL2_rotozoom.h b/src/sdl2gfx/SDL2_rotozoom.h
deleted file mode 100644
index ffab24fbc..000000000
--- a/src/sdl2gfx/SDL2_rotozoom.h
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
-
-SDL2_rotozoom.c: rotozoomer, zoomer and shrinker for 32bit or 8bit surfaces
-
-Copyright (C) 2012-2014 Andreas Schiffler
-
-This software is provided 'as-is', without any express or implied
-warranty. In no event will the authors be held liable for any damages
-arising from the use of this software.
-
-Permission is granted to anyone to use this software for any purpose,
-including commercial applications, and to alter it and redistribute it
-freely, subject to the following restrictions:
-
-1. The origin of this software must not be misrepresented; you must not
-claim that you wrote the original software. If you use this software
-in a product, an acknowledgment in the product documentation would be
-appreciated but is not required.
-
-2. Altered source versions must be plainly marked as such, and must not be
-misrepresented as being the original software.
-
-3. This notice may not be removed or altered from any source
-distribution.
-
-Andreas Schiffler -- aschiffler at ferzkopp dot net
-
-Changed for ManaPlus (C) 2013-2017 ManaPlus developers
-
-*/
-
-#ifndef _SDL2_rotozoom_h
-#define _SDL2_rotozoom_h
-
-#include <math.h>
-
-/* Set up for C function definitions, even when using C++ */
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-#ifndef M_PI
-#define M_PI 3.1415926535897932384626433832795
-#endif
-
-#include "localconsts.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL.h>
-PRAGMA48(GCC diagnostic pop)
-
- /* ---- Defines */
-
- /*!
- \brief Disable anti-aliasing (no smoothing).
- */
-#define SMOOTHING_OFF 0
-
- /*!
- \brief Enable anti-aliasing (smoothing).
- */
-#define SMOOTHING_ON 1
-
- /* ---- Function Prototypes */
-
-#ifdef _MSC_VER
-# if defined(DLL_EXPORT) && !defined(LIBSDL2_GFX_DLL_IMPORT)
-# define SDL2_ROTOZOOM_SCOPE __declspec(dllexport)
-# else
-# ifdef LIBSDL2_GFX_DLL_IMPORT
-# define SDL2_ROTOZOOM_SCOPE __declspec(dllimport)
-# endif
-# endif
-#endif
-#ifndef SDL2_ROTOZOOM_SCOPE
-# define SDL2_ROTOZOOM_SCOPE extern
-#endif
-
- /*
-
- Rotozoom functions
-
- */
-
- SDL2_ROTOZOOM_SCOPE SDL_Surface *rotozoomSurface(SDL_Surface * src, double angle, double zoom, int smooth);
-
- SDL2_ROTOZOOM_SCOPE SDL_Surface *rotozoomSurfaceXY
- (SDL_Surface * src, double angle, double zoomx, double zoomy, int smooth);
-
-
- SDL2_ROTOZOOM_SCOPE void rotozoomSurfaceSize(int width, int height, double angle, double zoom, int *dstwidth,
- int *dstheight);
-
- SDL2_ROTOZOOM_SCOPE void rotozoomSurfaceSizeXY
- (int width, int height, double angle, double zoomx, double zoomy,
- int *dstwidth, int *dstheight);
-
- /*
-
- Zooming functions
-
- */
-
- SDL2_ROTOZOOM_SCOPE SDL_Surface *zoomSurface(SDL_Surface * src, double zoomx, double zoomy, int smooth);
-
- SDL2_ROTOZOOM_SCOPE void zoomSurfaceSize(int width, int height, double zoomx, double zoomy, int *dstwidth, int *dstheight);
-
- /*
-
- Shrinking functions
-
- */
-
- SDL2_ROTOZOOM_SCOPE SDL_Surface *shrinkSurface(SDL_Surface * src, int factorx, int factory);
-
- /*
-
- Specialized rotation functions
-
- */
-
- SDL2_ROTOZOOM_SCOPE SDL_Surface* rotateSurface90Degrees(SDL_Surface* src, int numClockwiseTurns);
-
- /* Ends C function definitions when using C++ */
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _SDL2_rotozoom_h */
diff --git a/src/sdlshared.h b/src/sdlshared.h
deleted file mode 100644
index 71273d82f..000000000
--- a/src/sdlshared.h
+++ /dev/null
@@ -1,66 +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 SDLSHARED_H
-#define SDLSHARED_H
-
-#ifdef USE_SDL2
-
-#define SDL_GetKeyState SDL_GetKeyboardState
-#define SDLKey SDL_Scancode
-#define SDL_keysym SDL_Keysym
-
-#define SDL_ANYFORMAT 0
-#define SDL_HWSURFACE 0
-#define SDL_NOFRAME SDL_WINDOW_BORDERLESS
-#define SDL_RESIZABLE SDL_WINDOW_RESIZABLE
-#define SDL_FULLSCREEN SDL_WINDOW_FULLSCREEN
-#define SDL_OPENGL SDL_WINDOW_OPENGL
-
-#define KMOD_META KMOD_GUI
-#define SDLK_RMETA SDLK_RGUI
-#define SDLK_LMETA SDLK_LGUI
-#define SDLK_KP0 SDLK_KP_0
-#define SDLK_KP1 SDLK_KP_1
-#define SDLK_KP2 SDLK_KP_2
-#define SDLK_KP3 SDLK_KP_3
-#define SDLK_KP4 SDLK_KP_4
-#define SDLK_KP5 SDLK_KP_5
-#define SDLK_KP6 SDLK_KP_6
-#define SDLK_KP7 SDLK_KP_7
-#define SDLK_KP8 SDLK_KP_8
-#define SDLK_KP9 SDLK_KP_9
-#define SDLK_PRINT SDLK_PRINTSCREEN
-#define SDLK_NUMLOCK SDLK_NUMLOCKCLEAR
-#define SDLK_SCROLLOCK SDLK_SCROLLLOCK
-#define SDLK_LAST SDL_NUM_SCANCODES
-
-#define SDL_DEFAULT_REPEAT_DELAY 500
-
-#else // USE_SDL2
-
-#define SDL_Window SDL_Surface
-#define SDL_JoystickNameForIndex SDL_JoystickName
-#define SurfaceImageHelper SDLImageHelper
-#define SDL_GLContext (void*)
-
-#endif // USE_SDL2
-
-#endif // SDLSHARED_H
diff --git a/src/settings.cpp b/src/settings.cpp
deleted file mode 100644
index f620237d3..000000000
--- a/src/settings.cpp
+++ /dev/null
@@ -1,39 +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 "settings.h"
-
-#include "configuration.h"
-
-#ifndef DYECMD
-#include "net/useragent.h"
-#endif // DYECMD
-
-#include "debug.h"
-
-Settings settings;
-
-void Settings::init()
-{
- uselonglivesprites = config.getBoolValue("uselonglivesprites");
-#ifndef DYECMD
- UserAgent::update();
-#endif // DYECMD
-}
diff --git a/src/settings.h b/src/settings.h
deleted file mode 100644
index 1a165ad99..000000000
--- a/src/settings.h
+++ /dev/null
@@ -1,168 +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 SETTINGS_H
-#define SETTINGS_H
-
-#include "options.h"
-
-#include "enums/emotetype.h"
-
-#include "enums/input/keyboardfocus.h"
-
-#include "enums/resources/map/maptype.h"
-
-#include "utils/vector.h"
-
-#include "localconsts.h"
-
-class Settings final
-{
- public:
- Settings() :
- updateHost(),
- login(),
- oldUpdates(),
- updatesDir(),
- configDir(),
- localDataDir(),
- tempDir(),
- serverName(),
- screenshotDir(),
- onlineListUrl(),
- serverConfigDir(),
- usersDir(),
- usersIdDir(),
- npcsDir(),
- supportUrl(),
- logFileName(),
- rootDir(),
- windowCaption(),
- gmCommandSymbol("@"),
- gmCharCommandSymbol("#"),
- linkCommandSymbol("="),
- userAgent(),
- updateMirrors(),
- options(),
- guiAlpha(1.0F),
- textureSize(1024),
- moveType(0U),
- crazyMoveType(0U),
- moveToTargetType(0U),
- followMode(0U),
- attackWeaponType(0U),
- attackType(0U),
- quickDropCounter(0U),
- pickUpType(0U),
- magicAttackType(0U),
- pvpAttackType(0U),
- imitationMode(0U),
- cameraMode(0U),
- crazyMoveState(0U),
- targetingType(0U),
- overweightPercent(50U),
- playerNameOffset(64),
- playerBadgeAtRightOffset(32),
- mapDrawType(MapType::NORMAL),
- emoteType(EmoteType::Player),
- persistentIp(true),
- limitFps(false),
- inputFocused(KeyboardFocus::Focused),
- mouseFocused(true),
- disableGameModifiers(false),
- awayMode(false),
- pseudoAwayMode(false),
- fixDeadAnimation(true),
- disableLoggingInGame(false),
- legacyEffects(true),
- enableRemoteCommands(true),
- uselonglivesprites(false),
- unknownSkillsAutoTab(true),
- enableNewMailSystem(true)
- { }
-
- A_DELETE_COPY(Settings)
-
- void init();
-
- std::string updateHost;
- std::string login;
- std::string oldUpdates;
- std::string updatesDir;
- std::string configDir;
- std::string localDataDir;
- std::string tempDir;
- std::string serverName;
- std::string screenshotDir;
- std::string onlineListUrl;
- std::string serverConfigDir;
- std::string usersDir;
- std::string usersIdDir;
- std::string npcsDir;
- std::string supportUrl;
- std::string logFileName;
- std::string rootDir;
- std::string windowCaption;
- std::string gmCommandSymbol;
- std::string gmCharCommandSymbol;
- std::string linkCommandSymbol;
- std::string userAgent;
- STD_VECTOR<std::string> updateMirrors;
- Options options;
- float guiAlpha;
- unsigned int textureSize;
- unsigned int moveType;
- unsigned int crazyMoveType;
- unsigned int moveToTargetType;
- unsigned int followMode;
- unsigned int attackWeaponType;
- unsigned int attackType;
- unsigned int quickDropCounter;
- unsigned int pickUpType;
- unsigned int magicAttackType;
- unsigned int pvpAttackType;
- unsigned int imitationMode;
- unsigned int cameraMode;
- unsigned int crazyMoveState;
- unsigned int targetingType;
- unsigned int overweightPercent;
- int playerNameOffset;
- int playerBadgeAtRightOffset;
- MapTypeT mapDrawType;
- EmoteTypeT emoteType;
- bool persistentIp;
- bool limitFps;
- KeyboardFocusT inputFocused;
- bool mouseFocused;
- bool disableGameModifiers;
- bool awayMode;
- bool pseudoAwayMode;
- bool fixDeadAnimation;
- bool disableLoggingInGame;
- bool legacyEffects;
- bool enableRemoteCommands;
- bool uselonglivesprites;
- bool unknownSkillsAutoTab;
- bool enableNewMailSystem;
-};
-
-extern Settings settings;
-
-#endif // SETTINGS_H
diff --git a/src/soundmanager.cpp b/src/soundmanager.cpp
deleted file mode 100644
index d08b58c1f..000000000
--- a/src/soundmanager.cpp
+++ /dev/null
@@ -1,589 +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 "soundmanager.h"
-
-#include "configuration.h"
-
-#ifndef DYECMD
-#include "being/localplayer.h"
-#endif // DYECMD
-
-#include "fs/virtfs/fs.h"
-
-#include "resources/sdlmusic.h"
-#include "resources/soundeffect.h"
-
-#include "resources/loaders/musicloader.h"
-#include "resources/loaders/soundloader.h"
-
-#include "resources/resourcemanager/resourcemanager.h"
-
-#ifdef DYECMD
-#include "utils/cast.h"
-#endif
-#include "utils/checkutils.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL.h>
-PRAGMA48(GCC diagnostic pop)
-
-#include "debug.h"
-
-SoundManager soundManager;
-
-/**
- * This will be set to true, when a music can be freed after a fade out
- * Currently used by fadeOutCallBack()
- */
-static bool sFadingOutEnded = false;
-
-/**
- * Callback used at end of fadeout.
- * It is called by Mix_MusicFadeFinished().
- */
-static void fadeOutCallBack()
-{
- sFadingOutEnded = true;
-}
-
-SoundManager::SoundManager() :
- ConfigListener(),
- mNextMusicFile(),
- mInstalled(false),
- mSfxVolume(100),
- mMusicVolume(60),
- mCurrentMusicFile(),
- mMusic(nullptr),
- mGuiChannel(-1),
- mPlayBattle(false),
- mPlayGui(false),
- mPlayMusic(false),
- mFadeoutMusic(true),
- mCacheSounds(true)
-{
- // This set up our callback function used to
- // handle fade outs endings.
- sFadingOutEnded = false;
- Mix_HookMusicFinished(&fadeOutCallBack);
-}
-
-SoundManager::~SoundManager()
-{
-}
-
-void SoundManager::shutdown()
-{
- config.removeListeners(this);
-
- // Unlink the callback function.
- Mix_HookMusicFinished(nullptr);
-
- CHECKLISTENERS
-}
-
-void SoundManager::optionChanged(const std::string &value)
-{
- if (value == "playBattleSound")
- mPlayBattle = config.getBoolValue("playBattleSound");
- else if (value == "playGuiSound")
- mPlayGui = config.getBoolValue("playGuiSound");
- else if (value == "playMusic")
- mPlayMusic = config.getBoolValue("playMusic");
- else if (value == "sfxVolume")
- setSfxVolume(config.getIntValue("sfxVolume"));
- else if (value == "musicVolume")
- setMusicVolume(config.getIntValue("musicVolume"));
- else if (value == "fadeoutmusic")
- mFadeoutMusic = (config.getIntValue("fadeoutmusic") != 0);
- else if (value == "uselonglivesounds")
- mCacheSounds = (config.getIntValue("uselonglivesounds") != 0);
- else if (value == "parallelAudioChannels")
- setChannels(config.getIntValue("parallelAudioChannels"));
-}
-
-void SoundManager::init()
-{
- // Don't initialize sound engine twice
- if (mInstalled)
- return;
-
- logger->log1("SoundManager::init() Initializing sound...");
-
- mPlayBattle = config.getBoolValue("playBattleSound");
- mPlayGui = config.getBoolValue("playGuiSound");
- mPlayMusic = config.getBoolValue("playMusic");
- mFadeoutMusic = config.getBoolValue("fadeoutmusic");
- mMusicVolume = config.getIntValue("musicVolume");
- mSfxVolume = config.getIntValue("sfxVolume");
- mCacheSounds = (config.getIntValue("uselonglivesounds") != 0);
-
- config.addListener("playBattleSound", this);
- config.addListener("playGuiSound", this);
- config.addListener("playMusic", this);
- config.addListener("sfxVolume", this);
- config.addListener("musicVolume", this);
- config.addListener("fadeoutmusic", this);
- config.addListener("uselonglivesounds", this);
- config.addListener("parallelAudioChannels", this);
-
- if (SDL_InitSubSystem(SDL_INIT_AUDIO) == -1)
- {
- logger->log1("SoundManager::init() Failed to "
- "initialize audio subsystem");
- return;
- }
-
- const size_t audioBuffer = 4096;
- int channels = config.getIntValue("audioChannels");
- switch (channels)
- {
- case 3:
- channels = 4;
- break;
- case 4:
- channels = 6;
- break;
- default:
- break;
- }
-
- const int res = Mix_OpenAudio(config.getIntValue("audioFrequency"),
- MIX_DEFAULT_FORMAT, channels, audioBuffer);
-
- if (res < 0)
- {
- logger->log("SoundManager::init Could not initialize audio: %s",
- SDL_GetError());
- if (Mix_OpenAudio(22010, MIX_DEFAULT_FORMAT, 2, audioBuffer) < 0)
- return;
- logger->log("Fallback to stereo audio");
- }
-
- Mix_AllocateChannels(config.getIntValue("parallelAudioChannels"));
- Mix_VolumeMusic(mMusicVolume);
- Mix_Volume(-1, mSfxVolume);
-
- info();
-
- mInstalled = true;
-
- if (!mCurrentMusicFile.empty() && mPlayMusic)
- playMusic(mCurrentMusicFile, SkipError_true);
-}
-
-void SoundManager::testAudio()
-{
- mPlayBattle = config.getBoolValue("playBattleSound");
- mPlayGui = config.getBoolValue("playGuiSound");
- mPlayMusic = config.getBoolValue("playMusic");
- mFadeoutMusic = config.getBoolValue("fadeoutmusic");
- mMusicVolume = config.getIntValue("musicVolume");
- mSfxVolume = config.getIntValue("sfxVolume");
- mCacheSounds = (config.getIntValue("uselonglivesounds") != 0);
-
- const size_t audioBuffer = 4096;
- int channels = config.getIntValue("audioChannels");
- switch (channels)
- {
- case 3:
- channels = 4;
- break;
- case 4:
- channels = 6;
- break;
- default:
- break;
- }
-
- SDL_AudioSpec desired;
- SDL_AudioSpec actual;
-
- desired.freq = config.getIntValue("audioFrequency");
- desired.format = MIX_DEFAULT_FORMAT;
- desired.channels = CAST_U8(channels);
- desired.samples = audioBuffer;
- desired.callback = nullptr;
- desired.userdata = nullptr;
-
- if (SDL_OpenAudio(&desired, &actual) < 0)
- {
- logger->log("SoundManager::testAudio error: %s",
- SDL_GetError());
- return;
- }
- if (desired.freq != actual.freq)
- {
- logger->log("SoundManager::testAudio frequence: %d -> %d",
- actual.freq, desired.freq);
- }
- if (desired.format != actual.format)
- {
- logger->log("SoundManager::testAudio format: %d -> %d",
- actual.format, desired.format);
- }
- if (desired.channels != actual.channels)
- {
- logger->log("SoundManager::testAudio channels: %d -> %d",
- actual.channels, desired.channels);
- }
- if (desired.samples != actual.samples)
- {
- logger->log("SoundManager::testAudio samples: %d -> %d",
- actual.samples, desired.samples);
- }
- SDL_CloseAudio();
-}
-
-void SoundManager::info()
-{
- SDL_version compiledVersion;
- const char *format = "Unknown";
- int rate = 0;
- uint16_t audioFormat = 0;
- int channels = 0;
-
- MIX_VERSION(&compiledVersion);
- const SDL_version *const linkedVersion = Mix_Linked_Version();
-
-#ifdef USE_SDL2
- const char *driver = SDL_GetCurrentAudioDriver();
-#else // USE_SDL2
- char driver[40] = "Unknown";
- SDL_AudioDriverName(driver, 40);
-#endif // USE_SDL2
-
- Mix_QuerySpec(&rate, &audioFormat, &channels);
- switch (audioFormat)
- {
- case AUDIO_U8:
- format = "U8";
- break;
- case AUDIO_S8:
- format = "S8"; break;
- case AUDIO_U16LSB:
- format = "U16LSB";
- break;
- case AUDIO_S16LSB:
- format = "S16LSB";
- break;
- case AUDIO_U16MSB:
- format = "U16MSB";
- break;
- case AUDIO_S16MSB:
- format = "S16MSB";
- break;
- default: break;
- }
-
- logger->log("SoundManager::info() SDL_mixer: %i.%i.%i (compiled)",
- compiledVersion.major,
- compiledVersion.minor,
- compiledVersion.patch);
- if (linkedVersion != nullptr)
- {
- logger->log("SoundManager::info() SDL_mixer: %i.%i.%i (linked)",
- linkedVersion->major,
- linkedVersion->minor,
- linkedVersion->patch);
- }
- else
- {
- logger->log1("SoundManager::info() SDL_mixer: unknown");
- }
- logger->log("SoundManager::info() Driver: %s", driver);
- logger->log("SoundManager::info() Format: %s", format);
- logger->log("SoundManager::info() Rate: %i", rate);
- logger->log("SoundManager::info() Channels: %i", channels);
-}
-
-void SoundManager::setMusicVolume(const int volume)
-{
- mMusicVolume = volume;
-
- if (mInstalled)
- Mix_VolumeMusic(mMusicVolume);
-}
-
-void SoundManager::setSfxVolume(const int volume)
-{
- mSfxVolume = volume;
-
- if (mInstalled)
- Mix_Volume(-1, mSfxVolume);
-}
-
-static SDLMusic *loadMusic(const std::string &fileName,
- const SkipError skipError)
-{
- const std::string path = pathJoin(paths.getStringValue("music"),
- fileName);
- if (!VirtFs::exists(path))
- {
- if (skipError == SkipError_false)
- reportAlways("Music file not found: %s", fileName.c_str());
- return nullptr;
- }
- return Loader::getMusic(path);
-}
-
-void SoundManager::playMusic(const std::string &fileName,
- const SkipError skipError)
-{
- if (!mInstalled || !mPlayMusic)
- return;
-
- if (mCurrentMusicFile == fileName)
- return;
-
- mCurrentMusicFile = fileName;
-
- haltMusic();
-
- if (!fileName.empty())
- {
- mMusic = loadMusic(fileName,
- skipError);
- if (mMusic != nullptr)
- mMusic->play();
- }
-}
-
-void SoundManager::stopMusic()
-{
- haltMusic();
-}
-
-/*
-void SoundManager::fadeInMusic(const std::string &fileName, const int ms)
-{
- mCurrentMusicFile = fileName;
-
- if (!mInstalled || !mPlayMusic)
- return;
-
- haltMusic();
-
- if (!fileName.empty())
- {
- mMusic = loadMusic(fileName);
- if (mMusic)
- mMusic->play(-1, ms);
- }
-}
-*/
-
-void SoundManager::fadeOutMusic(const int ms)
-{
- if (!mPlayMusic)
- return;
-
- mCurrentMusicFile.clear();
-
- if (!mInstalled)
- return;
-
- logger->log("SoundManager::fadeOutMusic() Fading-out (%i ms)", ms);
-
- if ((mMusic != nullptr) && mFadeoutMusic)
- {
- Mix_FadeOutMusic(ms);
- // Note: The fadeOutCallBack handler will take care about freeing
- // the music file at fade out ending.
- }
- else
- {
- sFadingOutEnded = true;
- if (!mFadeoutMusic)
- haltMusic();
- }
-}
-
-void SoundManager::fadeOutAndPlayMusic(const std::string &fileName,
- const int ms)
-{
- if (!mPlayMusic)
- return;
-
- mNextMusicFile = fileName;
- fadeOutMusic(ms);
-}
-
-void SoundManager::logic()
-{
- BLOCK_START("SoundManager::logic")
- if (sFadingOutEnded)
- {
- if (mMusic != nullptr)
- {
- mMusic->decRef();
- mMusic = nullptr;
- }
- sFadingOutEnded = false;
-
- if (!mNextMusicFile.empty())
- {
- playMusic(mNextMusicFile,
- SkipError_false);
- mNextMusicFile.clear();
- }
- }
- BLOCK_END("SoundManager::logic")
-}
-
-#ifdef DYECMD
-void SoundManager::playSfx(const std::string &path A_UNUSED,
- const int x A_UNUSED,
- const int y A_UNUSED) const
-{
-}
-#else // DYECMD
-void SoundManager::playSfx(const std::string &path,
- const int x, const int y) const
-{
- if (!mInstalled || path.empty() || !mPlayBattle)
- return;
-
- std::string tmpPath = pathJoin(paths.getStringValue("sfx"), path);
- SoundEffect *const sample = Loader::getSoundEffect(tmpPath);
- if (sample != nullptr)
- {
- logger->log("SoundManager::playSfx() Playing: %s", path.c_str());
- int vol = 120;
- if ((localPlayer != nullptr) && (x > 0 || y > 0))
- {
- int dx = localPlayer->getTileX() - x;
- int dy = localPlayer->getTileY() - y;
- if (dx < 0)
- dx = -dx;
- if (dy < 0)
- dy = -dy;
- const int dist = dx > dy ? dx : dy;
- if (dist * 8 > vol)
- return;
-
- vol -= dist * 8;
- }
- sample->play(0, vol);
- if (!mCacheSounds)
- sample->decRef();
- }
-}
-#endif // DYECMD
-
-void SoundManager::playGuiSound(const std::string &name)
-{
- const std::string sound = config.getStringValue(name);
- if (sound == "(no sound)")
- return;
- playGuiSfx(pathJoin(branding.getStringValue("systemsounds"),
- std::string(sound).append(".ogg")));
-}
-
-void SoundManager::playGuiSfx(const std::string &path)
-{
- if (!mInstalled ||
- !mPlayGui ||
- path.empty())
- {
- return;
- }
-
- std::string tmpPath;
- if (path.compare(0, 4, "sfx/") == 0)
- tmpPath = path;
- else
- tmpPath = pathJoin(paths.getValue("sfx", "sfx"), path);
- SoundEffect *const sample = Loader::getSoundEffect(tmpPath);
- if (sample != nullptr)
- {
- logger->log("SoundManager::playGuiSfx() Playing: %s", path.c_str());
- const int ret = static_cast<int>(sample->play(0, 120, mGuiChannel));
- if (ret != -1)
- mGuiChannel = ret;
- if (!mCacheSounds)
- sample->decRef();
- }
-}
-
-void SoundManager::close()
-{
- if (!mInstalled)
- return;
-
- if (mMusic != nullptr)
- {
- Mix_HaltMusic();
- ResourceManager::decRefDelete(mMusic);
- mMusic = nullptr;
- mCurrentMusicFile.clear();
- }
-
- logger->log1("SoundManager::close() Shutting down sound...");
- Mix_CloseAudio();
-
- mInstalled = false;
-}
-
-void SoundManager::haltMusic()
-{
- if (mMusic == nullptr)
- return;
-
- Mix_HaltMusic();
- mMusic->decRef();
- mMusic = nullptr;
- mCurrentMusicFile.clear();
-}
-
-void SoundManager::changeAudio()
-{
- if (mInstalled)
- close();
- else
- init();
-}
-
-void SoundManager::volumeOff() const
-{
- if (mInstalled)
- {
- Mix_VolumeMusic(0);
- Mix_Volume(-1, 0);
- }
-}
-
-void SoundManager::volumeRestore() const
-{
- if (mInstalled)
- {
- Mix_VolumeMusic(mMusicVolume);
- Mix_Volume(-1, mSfxVolume);
- }
-}
-
-void SoundManager::setChannels(const int channels) const
-{
- if (mInstalled)
- Mix_AllocateChannels(channels);
-}
diff --git a/src/soundmanager.h b/src/soundmanager.h
deleted file mode 100644
index f4dca4cd1..000000000
--- a/src/soundmanager.h
+++ /dev/null
@@ -1,177 +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 SOUNDMANAGER_H
-#define SOUNDMANAGER_H
-
-#include "enums/simpletypes/skiperror.h"
-
-#include "listeners/configlistener.h"
-
-#include "localconsts.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_mixer.h>
-PRAGMA48(GCC diagnostic pop)
-
-class SDLMusic;
-
-/** SoundManager
- *
- * \ingroup CORE
- */
-class SoundManager final : public ConfigListener
-{
- public:
- SoundManager();
-
- A_DELETE_COPY(SoundManager)
-
- ~SoundManager();
-
- void optionChanged(const std::string &value) override final;
-
- /**
- * Installs the sound engine.
- */
- void init();
-
- void testAudio();
-
- /**
- * Removes all sound functionalities.
- */
- void close();
-
- /**
- * Starts background music.
- *
- * @param fileName The name of the music file.
- */
- void playMusic(const std::string &fileName,
- const SkipError skipError);
-
- /**
- * Stops currently running background music track.
- */
- void stopMusic();
-
- /**
- * Fades in background music.
- *
- * @param fileName The name of the music file.
- * @param ms Duration of fade-in effect (ms)
- */
-// void fadeInMusic(const std::string &fileName, const int ms = 1000);
-
- /**
- * Fades out currently running background music track.
- *
- * @param ms Duration of fade-out effect (ms)
- */
- void fadeOutMusic(const int ms = 1000);
-
- /**
- * Fades out a background music and play a new one.
- *
- * @param fileName The name of the music file.
- * @param ms Duration of fade-out effect (ms)
- */
- void fadeOutAndPlayMusic(const std::string &fileName,
- const int ms = 1000);
-
- constexpr static int getMaxVolume() A_WARN_UNUSED
- { return MIX_MAX_VOLUME; }
-
- void setMusicVolume(const int volume);
-
- void setSfxVolume(const int volume);
-
- /**
- * Plays an item.
- *
- * @param path The resource path to the sound file.
- */
- void playSfx(const std::string &path, const int x = 0,
- const int y = 0) const;
-
- /**
- * Plays an item for gui.
- *
- * @param path The resource path to the sound file.
- */
- void playGuiSfx(const std::string &path);
-
- void playGuiSound(const std::string &name);
-
- void changeAudio();
-
- void volumeOff() const;
-
- void volumeRestore() const;
-
- std::string getCurrentMusicFile() const noexcept2 A_WARN_UNUSED
- { return mCurrentMusicFile; }
-
- /**
- * The sound logic.
- * Currently used to check whether the music file can be freed after
- * a fade out, and whether new music has to be played.
- */
- void logic();
-
- void shutdown();
-
- void setChannels(const int channels) const;
-
- private:
- /** Logs various info about sound device. */
- static void info();
-
- /** Halts and frees currently playing music. */
- void haltMusic();
-
- /**
- * When calling fadeOutAndPlayMusic(),
- * the music file below will then be played
- */
- std::string mNextMusicFile;
-
- bool mInstalled;
-
- int mSfxVolume;
- int mMusicVolume;
-
- std::string mCurrentMusicFile;
- SDLMusic *mMusic;
- int mGuiChannel;
- bool mPlayBattle;
- bool mPlayGui;
- bool mPlayMusic;
- bool mFadeoutMusic;
- bool mCacheSounds;
-};
-
-extern SoundManager soundManager;
-
-#endif // SOUNDMANAGER_H
diff --git a/src/spellmanager.cpp b/src/spellmanager.cpp
deleted file mode 100644
index f24adb777..000000000
--- a/src/spellmanager.cpp
+++ /dev/null
@@ -1,449 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 Andrei Karas
- * 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 "spellmanager.h"
-
-#include "configuration.h"
-#include "textcommand.h"
-
-#include "being/localplayer.h"
-#ifdef TMWA_SUPPORT
-#include "being/playerinfo.h"
-#endif // TMWA_SUPPORT
-
-#include "const/spells.h"
-
-#include "gui/windows/chatwindow.h"
-
-#include "net/playerhandler.h"
-
-#include "resources/db/commandsdb.h"
-
-#include "utils/dtor.h"
-#include "utils/foreach.h"
-
-#include <sstream>
-
-#include "debug.h"
-
-SpellManager *spellManager = nullptr;
-
-SpellManager::SpellManager() :
- mSpells(),
- mSpellsVector()
-{
- load();
-}
-
-SpellManager::~SpellManager()
-{
- delete_all(mSpells);
- mSpells.clear();
- mSpellsVector.clear();
-}
-
-TextCommand* SpellManager::getSpell(const int spellId) const
-{
- if (spellId < 0 || CAST_SIZE(spellId) >= mSpells.size())
- return nullptr;
-
- const std::map<unsigned int, TextCommand*>::const_iterator
- it = mSpells.find(spellId);
-
- return it != mSpells.end() ? (*it).second : nullptr;
-}
-
-const TextCommand* SpellManager::getSpellByItem(const int itemId) const
-{
- return getSpell(itemId - SPELL_MIN_ID);
-}
-
-void SpellManager::fillSpells()
-{
- CommandsDB::load();
-
- CommandsMap &commands = CommandsDB::getAll();
- FOR_EACH (CommandsMapIter, it, commands)
- addSpell((*it).second);
-
- for (unsigned f = 0; f < SPELL_SHORTCUT_ITEMS * SPELL_SHORTCUT_TABS; f++)
- {
- const std::map<unsigned int, TextCommand*>::const_iterator
- it = mSpells.find(f);
- if (it == mSpells.end())
- addSpell(new TextCommand(f));
- }
- CommandsDB::unload();
-}
-
-bool SpellManager::addSpell(TextCommand *const spell)
-{
- if (spell == nullptr)
- return false;
-
- const int id = spell->getId();
- if (id < 0 || id >= CAST_S32(SPELL_SHORTCUT_ITEMS
- * SPELL_SHORTCUT_TABS))
- {
- delete spell;
- return false;
- }
- const std::map<unsigned int, TextCommand*>::const_iterator
- i = mSpells.find(spell->getId());
- if (i == mSpells.end())
- {
- mSpells[spell->getId()] = spell;
- mSpellsVector.push_back(spell);
- return true;
- }
- return false;
-}
-
-const STD_VECTOR<TextCommand*> &SpellManager::getAll() const
-{
- return mSpellsVector;
-}
-
-void SpellManager::useItem(const int itemId) const
-{
- invoke(itemId - SPELL_MIN_ID);
-}
-
-void SpellManager::invoke(const int spellId) const
-{
- if (localPlayer == nullptr)
- return;
-
- const TextCommand *const spell = getSpell(spellId);
- if (spell == nullptr)
- return;
-
- if ((playerHandler == nullptr) || spell->getCommand().empty())
- return;
-
-#ifdef TMWA_SUPPORT
- if (spell->getCommandType() == TextCommandType::Text ||
- (playerHandler->canUseMagic() &&
- PlayerInfo::getSkillLevel(CAST_S32(MagicSchool::SkillMagic))
- >= CAST_S32(spell->getBaseLvl()) &&
- PlayerInfo::getSkillLevel(CAST_S32(
- spell->getSchool())) >= CAST_S32(spell->getSchoolLvl())
- && PlayerInfo::getAttribute(Attributes::PLAYER_MP)
- >= CAST_S32(spell->getMana()))
- )
-#endif // TMWA_SUPPORT
- {
- const Being *const target = localPlayer->getTarget();
- if (spell->getTargetType() == CommandTarget::NoTarget)
- {
- invokeSpell(spell);
- }
-#ifdef TMWA_SUPPORT
- if ((target != nullptr &&
- (target->getType() != ActorType::Monster ||
- spell->getCommandType() == TextCommandType::Text)) &&
- (spell->getTargetType() == CommandTarget::AllowTarget ||
- spell->getTargetType() == CommandTarget::NeedTarget))
-#else // TMWA_SUPPORT
-
- if (target != nullptr &&
- (spell->getTargetType() == CommandTarget::AllowTarget ||
- spell->getTargetType() == CommandTarget::NeedTarget))
-#endif // TMWA_SUPPORT
- {
- invokeSpell(spell, target);
- }
- else if (spell->getTargetType() == CommandTarget::AllowTarget)
- {
- invokeSpell(spell);
- }
- }
-}
-
-void SpellManager::invokeSpell(const TextCommand *const spell)
-{
- if ((chatWindow == nullptr) || (spell == nullptr))
- return;
- chatWindow->localChatInput(parseCommand(spell->getCommand(), nullptr));
-}
-
-void SpellManager::invokeSpell(const TextCommand *const spell,
- const Being *const target)
-{
- if (chatWindow == nullptr ||
- spell == nullptr ||
- target == nullptr)
- {
- return;
- }
- chatWindow->localChatInput(parseCommand(spell->getCommand(), target));
-}
-
-void SpellManager::invokeCommand(const std::string &command,
- const Being *const target)
-{
- if (chatWindow == nullptr)
- return;
- chatWindow->localChatInput(parseCommand(command, target));
-}
-
-std::string SpellManager::parseCommand(std::string command,
- const Being *const target)
-{
- if (localPlayer == nullptr)
- return command;
-
- std::string name;
- std::string id;
- std::string name2;
-
- if (target != nullptr)
- {
- name = target->getName();
- name2 = name;
- id = toString(toInt(target->getId(), int));
- }
- else
- {
- name2 = localPlayer->getName();
- }
-
- bool found = false;
-
- size_t idx = command.find("<TARGET>");
- if (idx != std::string::npos)
- {
- found = true;
- command = replaceAll(command, "<TARGET>", name);
- }
- idx = command.find("<TARGETID>");
- if (idx != std::string::npos)
- {
- found = true;
- command = replaceAll(command, "<TARGETID>", id);
- }
- idx = command.find("<TARGETORSELF>");
- if (idx != std::string::npos)
- {
- found = true;
- command = replaceAll(command, "<TARGETORSELF>", name2);
- }
-
- if (!found && !name.empty())
- command.append(" ").append(name);
-
- return command;
-}
-
-TextCommand *SpellManager::createNewSpell() const
-{
- return new TextCommand(CAST_U32(mSpellsVector.size()));
-}
-
-void SpellManager::load()
-{
- const Configuration *cfg = &serverConfig;
-
- delete_all(mSpells);
- mSpells.clear();
- mSpellsVector.clear();
-
- if (cfg->getValue("commandShortcutFlags0", "").empty())
- {
- fillSpells();
- save();
- return;
- }
-
- for (unsigned i = 0; i < SPELL_SHORTCUT_ITEMS * SPELL_SHORTCUT_TABS; i++)
- {
- unsigned int targetType;
- unsigned int basicLvl;
- unsigned int school;
- unsigned int schoolLvl;
- unsigned int mana;
- unsigned int commandType;
-
- std::string flags =
- cfg->getValue("commandShortcutFlags" + toString(i), "");
- std::stringstream ss(flags);
- ss >> commandType;
- ss >> targetType;
- ss >> basicLvl;
- ss >> school;
- ss >> schoolLvl;
- ss >> mana;
-
- std::string cmd = cfg->getValue("commandShortcutCmd"
- + toString(i), "");
- std::string comment = cfg->getValue("commandShortcutComment"
- + toString(i), "");
- std::string symbol = cfg->getValue("commandShortcutSymbol"
- + toString(i), "");
- std::string icon = cfg->getValue("commandShortcutIcon"
- + toString(i), "");
-
-#ifdef TMWA_SUPPORT
- if (static_cast<TextCommandTypeT>(commandType) ==
- TextCommandType::Magic)
- {
- addSpell(new TextCommand(i, symbol, cmd, comment,
- static_cast<CommandTargetT>(targetType), icon, basicLvl,
- static_cast<MagicSchoolT>(school), schoolLvl, mana));
- }
- else
-#endif // TMWA_SUPPORT
- {
- addSpell(new TextCommand(i, symbol, cmd, comment,
- static_cast<CommandTargetT>(targetType), icon));
- }
- }
-}
-
-#define setOrDel(str, method) \
- const std::string var##method = spell->method(); \
- if (!var##method.empty()) \
- serverConfig.setValue(str + toString(i), var##method); \
- else \
- serverConfig.deleteKey(str + toString(i));
-
-void SpellManager::save() const
-{
- for (unsigned i = 0; i < SPELL_SHORTCUT_ITEMS * SPELL_SHORTCUT_TABS; i++)
- {
- const TextCommand *const spell = mSpellsVector[i];
- if (spell != nullptr)
- {
- setOrDel("commandShortcutCmd", getCommand);
- setOrDel("commandShortcutComment", getComment);
- setOrDel("commandShortcutSymbol", getSymbol);
- setOrDel("commandShortcutIcon", getIcon);
- if (!spell->getCommand().empty() &&
- !spell->getSymbol().empty())
- {
-#ifdef TMWA_SUPPORT
- serverConfig.setValue("commandShortcutFlags" + toString(i),
- strprintf("%u %u %u %u %u %u",
- CAST_U32(spell->getCommandType()),
- CAST_U32(spell->getTargetType()),
- spell->getBaseLvl(),
- CAST_U32(spell->getSchool()),
- spell->getSchoolLvl(),
- CAST_U32(spell->getMana())));
-#else // TMWA_SUPPORT
-
- serverConfig.setValue("commandShortcutFlags" + toString(i),
- strprintf("%u %u %u %u %u %u", 1U,
- CAST_U32(spell->getTargetType()),
- 0U,
- 0U,
- 0U,
- 0U));
-#endif // TMWA_SUPPORT
- }
- else
- {
- serverConfig.deleteKey("commandShortcutFlags" + toString(i));
- }
- }
- }
-}
-
-#undef setOrDel
-
-std::string SpellManager::autoComplete(const std::string &partName) const
-{
- STD_VECTOR<TextCommand*>::const_iterator i = mSpellsVector.begin();
- const STD_VECTOR<TextCommand*>::const_iterator
- i_end = mSpellsVector.end();
- std::string newName;
- const TextCommand *newCommand = nullptr;
-
- while (i != i_end)
- {
- const TextCommand *const cmd = *i;
- const std::string line = cmd->getCommand();
-
- if (!line.empty())
- {
- const size_t pos = line.find(partName, 0);
- if (pos == 0)
- {
- if (!newName.empty())
- {
- newName = findSameSubstring(line, newName);
- newCommand = nullptr;
- }
- else
- {
- newName = line;
- newCommand = cmd;
- }
- }
- }
- ++i;
- }
- if (!newName.empty() &&
- (newCommand != nullptr) &&
- newCommand->getTargetType() == CommandTarget::NeedTarget)
- {
- return newName.append(" ");
- }
- return newName;
-}
-
-void SpellManager::swap(const int id1, const int id2)
-{
- TextCommand *const spell1 = mSpells[id1];
- TextCommand *const spell2 = mSpells[id2];
- if ((spell1 == nullptr) || (spell2 == nullptr))
- return;
-
- // swap in map
- mSpells[id1] = spell2;
- mSpells[id2] = spell1;
-
- // swap id
- const int tmp = spell1->getId();
- spell1->setId(spell2->getId());
- spell2->setId(tmp);
-
- // swap in vector
- const size_t sz = SPELL_SHORTCUT_ITEMS * SPELL_SHORTCUT_TABS;
- for (size_t f = 0; f < sz; f++)
- {
- const TextCommand *const spellA = mSpellsVector[f];
- if (spellA == spell1)
- {
- for (size_t d = 0; d < sz; d++)
- {
- const TextCommand *const spellB = mSpellsVector[d];
- if (spellB == spell2)
- {
- mSpellsVector[f] = spell2;
- mSpellsVector[d] = spell1;
- return;
- }
- }
- }
- }
-}
diff --git a/src/spellmanager.h b/src/spellmanager.h
deleted file mode 100644
index 1b3316b36..000000000
--- a/src/spellmanager.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 Andrei Karas
- * 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 SPELLMANAGER_H
-#define SPELLMANAGER_H
-
-#include "utils/vector.h"
-
-#include <string>
-#include <map>
-
-#include "localconsts.h"
-
-class Being;
-class TextCommand;
-
-class SpellManager final
-{
- public:
- SpellManager();
-
- A_DELETE_COPY(SpellManager)
-
- ~SpellManager();
-
- TextCommand *getSpell(const int spellId) const A_WARN_UNUSED;
-
- const TextCommand* getSpellByItem(const int itemId)
- const A_WARN_UNUSED;
-
- bool addSpell(TextCommand *const spell);
-
- TextCommand *createNewSpell() const A_WARN_UNUSED;
-
- const STD_VECTOR<TextCommand*> &getAll() const A_CONST A_WARN_UNUSED;
-
- void useItem(const int itemId) const;
-
- void invoke(const int spellId) const;
-
- void load();
-
- void save() const;
-
- std::string autoComplete(const std::string &partName)
- const A_WARN_UNUSED;
-
- void swap(const int id1, const int id2);
-
- static void invokeCommand(const std::string &command,
- const Being *const target);
-
- private:
- void fillSpells();
-
- static void invokeSpell(const TextCommand *const spell,
- const Being *const target);
-
- static void invokeSpell(const TextCommand *const spell);
-
- static std::string parseCommand(std::string command,
- const Being *const target)
- A_WARN_UNUSED;
-
- std::map<unsigned int, TextCommand*> mSpells;
- STD_VECTOR<TextCommand*> mSpellsVector;
-};
-
-extern SpellManager *spellManager;
-
-#endif // SPELLMANAGER_H
diff --git a/src/statuseffect.cpp b/src/statuseffect.cpp
deleted file mode 100644
index 7cd71a5d7..000000000
--- a/src/statuseffect.cpp
+++ /dev/null
@@ -1,100 +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 "statuseffect.h"
-
-#include "configuration.h"
-#include "soundmanager.h"
-
-#include "const/resources/spriteaction.h"
-
-#include "gui/widgets/tabs/chat/chattab.h"
-
-#include "particle/particleengine.h"
-
-#include "resources/sprite/animatedsprite.h"
-
-#include "debug.h"
-
-StatusEffect::StatusEffect() :
- mMessage(),
- mSFXEffect(),
- mStartParticleEffect(),
- mParticleEffect(),
- mIcon(),
- mAction(),
- mName(),
- mIsPersistent(false),
- mIsPoison(false),
- mIsCart(false),
- mIsRiding(false),
- mIsTrickDead(false),
- mIsPostDelay(false)
-{
-}
-
-StatusEffect::~StatusEffect()
-{
-}
-
-void StatusEffect::playSFX() const
-{
- if (!mSFXEffect.empty())
- soundManager.playSfx(mSFXEffect);
-}
-
-void StatusEffect::deliverMessage() const
-{
- if (!mMessage.empty() && (localChatTab != nullptr))
- localChatTab->chatLog(mMessage, ChatMsgType::BY_SERVER);
-}
-
-Particle *StatusEffect::getStartParticle() const
-{
- if (particleEngine == nullptr || mStartParticleEffect.empty())
- return nullptr;
- return particleEngine->addEffect(mStartParticleEffect, 0, 0);
-}
-
-Particle *StatusEffect::getParticle() const
-{
- if (particleEngine == nullptr || mParticleEffect.empty())
- return nullptr;
- return particleEngine->addEffect(mParticleEffect, 0, 0);
-}
-
-AnimatedSprite *StatusEffect::getIcon() const
-{
- if (mIcon.empty())
- {
- return nullptr;
- }
- return AnimatedSprite::load(pathJoin(paths.getStringValue("sprites"),
- mIcon));
-}
-
-std::string StatusEffect::getAction() const
-{
- if (mAction.empty())
- return SpriteAction::INVALID;
- return mAction;
-}
diff --git a/src/statuseffect.h b/src/statuseffect.h
deleted file mode 100644
index 1e02efa94..000000000
--- a/src/statuseffect.h
+++ /dev/null
@@ -1,91 +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 STATUSEFFECT_H
-#define STATUSEFFECT_H
-
-#include <string>
-
-#include "localconsts.h"
-
-class AnimatedSprite;
-class Particle;
-
-class StatusEffect final
-{
- public:
- StatusEffect();
-
- A_DELETE_COPY(StatusEffect)
-
- ~StatusEffect();
-
- /**
- * Plays the sound effect associated with this status effect, if
- * possible.
- */
- void playSFX() const;
-
- /**
- * Delivers the chat message associated with this status effect, if
- * possible.
- */
- void deliverMessage() const;
-
- /**
- * Creates the particle effect associated with this status effect, if
- * possible.
- */
- Particle *getStartParticle() const A_WARN_UNUSED;
-
- /**
- * Creates the particle effect associated with this status effect, if
- * possible.
- */
- Particle *getParticle() const A_WARN_UNUSED;
-
- /**
- * Retrieves the status icon for this effect, if applicable
- */
- AnimatedSprite *getIcon() const A_WARN_UNUSED;
-
- /**
- * Retrieves an action to perform, or SpriteAction::INVALID
- */
- std::string getAction() const A_WARN_UNUSED;
-
- std::string mMessage;
- std::string mSFXEffect;
- std::string mStartParticleEffect;
- std::string mParticleEffect;
- std::string mIcon;
- std::string mAction;
- std::string mName;
- bool mIsPersistent;
- bool mIsPoison;
- bool mIsCart;
- bool mIsRiding;
- bool mIsTrickDead;
- bool mIsPostDelay;
-};
-
-#endif // STATUSEFFECT_H
diff --git a/src/test/testlauncher.cpp b/src/test/testlauncher.cpp
deleted file mode 100644
index d5df688a7..000000000
--- a/src/test/testlauncher.cpp
+++ /dev/null
@@ -1,835 +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 "test/testlauncher.h"
-
-#ifdef USE_OPENGL
-
-#include "graphicsmanager.h"
-#include "settings.h"
-#include "soundmanager.h"
-
-#include "fs/virtfs/rwops.h"
-
-#include "gui/skin.h"
-#include "gui/theme.h"
-
-#include "gui/fonts/font.h"
-
-#include "utils/pnglib.h"
-#include "utils/stringutils.h"
-
-#include "render/graphics.h"
-
-#include "render/vertexes/imagecollection.h"
-
-#include "resources/openglimagehelper.h"
-#include "resources/screenshothelper.h"
-#include "resources/surfaceimagehelper.h"
-#include "resources/wallpaper.h"
-
-#include "resources/dye/dye.h"
-#if defined __linux__ || defined __linux
-#ifdef SIMD_SUPPORTED
-#include "resources/dye/dyepalette.h"
-#endif // SIMD_SUPPORTED
-#endif // defined __linux__ || defined __linux
-
-#include "resources/image/image.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#ifndef USE_SDL2
-#include <SDL_gfxBlitFunc.h>
-#endif // USE_SDL2
-PRAGMA48(GCC diagnostic pop)
-
-#include <unistd.h>
-
-#ifdef WIN32
-#include <windows.h>
-#define sleep(seconds) Sleep((seconds) * 1000)
-#endif // WIN32
-
-#include <sys/time.h>
-
-#include "localconsts.h"
-
-#ifndef SDL_BIG_ENDIAN
-#error missing SDL_endian.h
-#endif // SDL_BYTEORDER
-
-#if SDL_BYTEORDER == SDL_LIL_ENDIAN
-#ifndef USE_SDL2
-#include "resources/sdlgfxblitfunc.h"
-#endif // USE_SDL2
-#endif // SDL_BYTEORDER == SDL_LIL_ENDIAN
-
-#include "debug.h"
-
-extern Font *boldFont;
-
-TestLauncher::TestLauncher(std::string test) :
- mTest(test),
- file()
-{
- file.open(pathJoin(settings.localDataDir, "test.log").c_str(),
- std::ios::out);
-}
-
-TestLauncher::~TestLauncher()
-{
- file.close();
-}
-
-int TestLauncher::exec()
-{
- if (mTest == "1" || mTest == "2" || mTest == "3" || mTest == "19")
- return testBackend();
- else if (mTest == "4")
- return testSound();
- else if (mTest == "5" || mTest == "6" || mTest == "7" || mTest == "18")
- return testRescale();
- else if (mTest == "8" || mTest == "9" || mTest == "10" || mTest == "17")
- return testFps();
- else if (mTest == "11")
- return testBatches();
- else if (mTest == "14" || mTest == "15" || mTest == "16" || mTest == "20")
- return testTextures();
- else if (mTest == "99")
- return testVideoDetection();
- else if (mTest == "100")
- return testInternal();
- else if (mTest == "101")
- return testDye();
- else if (mTest == "102")
- return testDraw();
- else if (mTest == "103")
- return testFps2();
- else if (mTest == "104")
- return testFps3();
- else if (mTest == "105")
- return testDyeSSpeed();
- else if (mTest == "106")
- return testStackSpeed();
- else if (mTest == "107")
- return testDyeASpeed();
- else if (mTest == "108")
- return testBlitSpeed();
-
- return -1;
-}
-
-int TestLauncher::testBackend() const
-{
- const Image *const img = Theme::getImageFromTheme(
- "graphics/sprites/arrow_up.png");
- if (img == nullptr)
- return 1;
- const int cnt = 100;
-
- for (int f = 0; f < cnt; f ++)
- {
- mainGraphics->drawImage(img, cnt * 7, cnt * 5);
- mainGraphics->updateScreen();
- }
-
- sleep(1);
- return 0;
-}
-
-int TestLauncher::testSound() const
-{
- soundManager.playGuiSfx("system/newmessage.ogg");
- sleep(1);
- soundManager.playSfx("system/newmessage.ogg", 0, 0);
- soundManager.playMusic("sfx/system/newmessage.ogg", SkipError_false);
- sleep(3);
- soundManager.stopMusic();
- return 0;
-}
-
-int TestLauncher::testRescale() const
-{
- Wallpaper::loadWallpapers();
- const std::string wallpaperName = Wallpaper::getWallpaper(800, 600);
- const volatile Image *const img = Theme::getImageFromTheme(wallpaperName);
- if (img == nullptr)
- return 1;
-
- sleep(1);
- return 0;
-}
-
-PRAGMA45(GCC diagnostic push)
-PRAGMA45(GCC diagnostic ignored "-Wunused-result")
-
-int TestLauncher::testFps()
-{
- timeval start;
- timeval end;
-
- Wallpaper::loadWallpapers();
- Wallpaper::getWallpaper(800, 600);
- Image *img[5];
- const int sz = 4;
-
- img[0] = Theme::getImageFromTheme("graphics/sprites/arrow_up.png");
- img[1] = Theme::getImageFromTheme(
- "graphics/gui/target-cursor-normal-l.png");
- img[2] = Theme::getImageFromTheme("themes/wood/window.png");
- img[3] = Theme::getImageFromTheme("themes/pink/window.png");
- img[4] = Theme::getImageFromTheme("graphics/images/login_wallpaper.png");
- int idx = 0;
-
- const int cnt = 50;
-
- gettimeofday(&start, nullptr);
- for (int k = 0; k < cnt; k ++)
- {
- for (int x = 0; x < 800; x += 30)
- {
- for (int y = 0; y < 600; y += 50)
- {
- mainGraphics->drawImage(img[idx], x, y);
- idx ++;
- if (idx > sz)
- idx = 0;
- mainGraphics->drawImage(img[idx], x, y);
- idx ++;
- if (idx > sz)
- idx = 0;
- }
- }
- mainGraphics->updateScreen();
- }
-
- gettimeofday(&end, nullptr);
- const int tFps = calcFps(start, end, cnt);
- file << mTest << std::endl;
- file << tFps << std::endl;
-
- printf("fps: %d\n", tFps / 10);
- sleep(1);
- return 0;
-}
-
-int TestLauncher::testFps2()
-{
- timeval start;
- timeval end;
-
- Wallpaper::loadWallpapers();
- Wallpaper::getWallpaper(800, 600);
- Image *img[1];
-
- img[0] = Theme::getImageFromTheme("graphics/images/login_wallpaper.png");
- mainGraphics->drawImage(img[0], 0, 0);
-
- const int cnt = 500;
-
- gettimeofday(&start, nullptr);
- for (int k = 0; k < cnt; k ++)
- {
- for (int f = 0; f < 300; f ++)
- mainGraphics->testDraw();
- mainGraphics->updateScreen();
- }
-
- gettimeofday(&end, nullptr);
- const int tFps = calcFps(start, end, cnt);
- file << mTest << std::endl;
- file << tFps << std::endl;
-
- printf("fps: %d\n", tFps / 10);
- sleep(1);
- return 0;
-}
-
-int TestLauncher::testFps3()
-{
- timeval start;
- timeval end;
-
- Wallpaper::loadWallpapers();
- Wallpaper::getWallpaper(800, 600);
- Image *img[2];
-
- img[0] = Theme::getImageFromTheme("graphics/sprites/arrow_up.png");
- img[1] = Theme::getImageFromTheme("graphics/sprites/arrow_left.png");
- ImageVertexes *const vert1 = new ImageVertexes;
- vert1->image = img[0];
- ImageVertexes *const vert2 = new ImageVertexes;
- vert2->image = img[1];
-
- for (int f = 0; f < 50; f ++)
- {
- for (int d = 0; d < 50; d ++)
- {
- mainGraphics->calcTileVertexes(vert1, img[0], f * 16, d * 12);
- mainGraphics->calcTileVertexes(vert1, img[1], f * 16 + 5, d * 12);
- }
- }
- mainGraphics->finalize(vert1);
- mainGraphics->finalize(vert2);
-
- const int cnt = 2000;
-
- gettimeofday(&start, nullptr);
- for (int k = 0; k < cnt; k ++)
- {
- mainGraphics->drawTileVertexes(vert1);
- mainGraphics->drawTileVertexes(vert2);
- mainGraphics->updateScreen();
- }
-
- gettimeofday(&end, nullptr);
- const int tFps = calcFps(start, end, cnt);
- file << mTest << std::endl;
- file << tFps << std::endl;
-
- printf("fps: %d\n", tFps / 10);
- sleep(1);
- return 0;
-}
-PRAGMA45(GCC diagnostic pop)
-
-int TestLauncher::testBatches()
-{
- int batches = 512;
-
- file << mTest << std::endl;
- file << batches << std::endl;
- return 0;
-}
-
-int TestLauncher::testTextures()
-{
- int maxSize = 512;
- int nextSize = 512;
- int sz = OpenGLImageHelper::getTextureSize() + 1;
- if (sz > 16500)
- sz = 16500;
-
- const uint32_t bytes1[] =
- {
- 0xFFFF0000U, 0xFFFFFF00U, 0xFF00FFFFU, 0xFF0000FFU,
- 0xFF000000U, 0xFFFF00FFU
- };
-
- const uint32_t bytes2[] =
- {
- 0xFF0000FFU, 0xFF00FFFFU, 0xFFFFFF00U, 0xFFFF0000U,
- 0xFF000000U, 0xFFFF00FFU
- };
-
- for (nextSize = 512; nextSize < sz; nextSize *= 2)
- {
- mainGraphics->clearScreen();
- SDL_Surface *const surface = imageHelper->create32BitSurface(
- nextSize, nextSize);
- if (surface == nullptr)
- break;
- uint32_t *pixels = static_cast<uint32_t*>(surface->pixels);
- for (int f = 0; f < 6; f ++)
- pixels[f] = bytes1[f];
- graphicsManager.getLastError();
- graphicsManager.resetCachedError();
- Image *const image = imageHelper->loadSurface(surface);
- SDL_FreeSurface(surface);
- if (image == nullptr)
- break;
-
- if (graphicsManager.getLastErrorCached() != GL_NO_ERROR)
- {
- delete image;
- break;
- }
- Image *const subImage = image->getSubImage(0, 0, 10, 10);
- if (subImage == nullptr)
- {
- delete image;
- break;
- }
- mainGraphics->drawImage(subImage, 0, 0);
- mainGraphics->updateScreen();
- mainGraphics->drawImage(subImage, 0, 0);
- delete subImage;
- SDL_Surface *const screen1 = screenshortHelper->getScreenshot();
- SDL_Surface *const screen2 = ImageHelper::convertTo32Bit(screen1);
- SDL_FreeSurface(screen1);
- if (screen2 == nullptr)
- break;
- pixels = static_cast<uint32_t*>(screen2->pixels);
- bool fail(false);
- for (int f = 0; f < 6; f ++)
- {
- if (pixels[f] != bytes2[f])
- {
- fail = true;
- break;
- }
- }
-
- SDL_FreeSurface(screen2);
- if (fail)
- break;
-
- maxSize = nextSize;
- }
-
- file << mTest << std::endl;
- file << maxSize << std::endl;
- printf("OpenGL max size: %d\n", sz);
- printf("actual max size: %d\n", maxSize);
- return 0;
-}
-
-PRAGMA45(GCC diagnostic push)
-PRAGMA45(GCC diagnostic ignored "-Wunused-result")
-
-int TestLauncher::testInternal()
-{
- timeval start;
- timeval end;
-
- Wallpaper::loadWallpapers();
- Wallpaper::getWallpaper(800, 600);
- Image *img[4];
-
- img[0] = Theme::getImageFromTheme(
- "graphics/sprites/manaplus_emotions.png");
- img[1] = Theme::getImageFromTheme(
- "graphics/sprites/manaplus_emotions.png");
- img[2] = Theme::getImageFromTheme("graphics/sprites/arrow_left.png");
- img[3] = Theme::getImageFromTheme("graphics/sprites/arrow_right.png");
- int idx = 0;
- const int mem = mainGraphics->getMemoryUsage();
-
-// int cnt = 5;
- const int cnt = 5000;
-
- gettimeofday(&start, nullptr);
- for (int k = 0; k < cnt; k ++)
- {
- for (int x = 0; x < 800; x += 20)
- {
- for (int y = 0; y < 600; y += 25)
- {
- mainGraphics->drawImage(img[idx], x, y);
- mainGraphics->drawImage(img[idx], x + 1, y);
- mainGraphics->drawImage(img[idx], x, y + 5);
-
- idx ++;
- if (idx > 3)
- idx = 0;
- }
- }
- mainGraphics->updateScreen();
- }
-
- gettimeofday(&end, nullptr);
- const int tFps = calcFps(start, end, cnt);
- file << mTest << std::endl;
- file << tFps << std::endl;
- file << mem << std::endl;
-
- sleep(1);
- return 0;
-}
-
-PRAGMA45(GCC diagnostic pop)
-
-int TestLauncher::testDye()
-{
- SDL_RWops *rw = VirtFs::rwopsOpenRead(
- "graphics/sprites/arrow_up.png");
- Dye *d = nullptr;
-
- if (rw != nullptr)
- {
- Image *image = d != nullptr ? surfaceImageHelper->load(rw, *d)
- : surfaceImageHelper->load(rw);
- if (image != nullptr)
- {
- const SDL_Rect &rect = image->mBounds;
- SDL_Surface *surface = surfaceImageHelper->create32BitSurface(
- rect.w, rect.h);
- if (surface != nullptr)
- {
- SurfaceImageHelper::combineSurface(image->mSDLSurface, nullptr,
- surface, nullptr);
- PngLib::writePNG(image->mSDLSurface,
- settings.tempDir + "/testimage1.png");
- PngLib::writePNG(surface,
- settings.tempDir + "/testimage2.png");
- }
-
- rw = VirtFs::rwopsOpenRead(
- "graphics/sprites/arrow_up.png");
- d = new Dye("S:#0000ff,00ff00,5c5cff,ff0000");
- image = surfaceImageHelper->load(rw, *d);
- if (image != nullptr)
- {
- surface = surfaceImageHelper->create32BitSurface(
- rect.w, rect.h);
- if (surface != nullptr)
- {
- SurfaceImageHelper::combineSurface(image->mSDLSurface,
- nullptr, surface, nullptr);
- PngLib::writePNG(image->mSDLSurface,
- settings.tempDir + "/testimage3.png");
- PngLib::writePNG(surface,
- settings.tempDir + "/testimage4.png");
- }
- }
- }
- }
- return 0;
-}
-
-#if defined __linux__ || defined __linux
-#if defined(SIMD_SUPPORTED) || (SDL_BYTEORDER == SDL_LIL_ENDIAN \
-&& !defined(USE_SDL2))
-static void calcTime(const char *const msg1,
- const char *const msg2,
- const timespec &time1,
- timespec &time2,
- const uint32_t *const buf)
-{
- clock_gettime(CLOCK_MONOTONIC, &time2);
- long diff = ((static_cast<long int>(time2.tv_sec) * 1000000000L
- + static_cast<long int>(time2.tv_nsec)) / 1) -
- ((static_cast<long int>(time1.tv_sec) * 1000000000L
- + static_cast<long int>(time1.tv_nsec)) / 1);
- printf("%s: %u\n", msg1, buf[0]);
- printf("%s: %011ld\n", msg2, diff);
-}
-#endif // defined(SIMD_SUPPORTED) || (SDL_BYTEORDER == SDL_LIL_ENDIAN
-
-#ifdef SIMD_SUPPORTED
-static void initBuffer(uint32_t *const buf,
- const int sz)
-{
- for (int f = 0; f < sz; f ++)
- buf[f] = f;
-}
-
-#define runDyeTest(msg1, msg2, func) \
- initBuffer(buf, sz); \
- pal.func(buf, sz); \
- clock_gettime(CLOCK_MONOTONIC, &time1); \
- for (int f = 0; f < 50000; f ++) \
- pal.func(buf, sz); \
- calcTime(msg1, \
- msg2, \
- time1, \
- time2, \
- buf)
-#endif // SIMD_SUPPORTED
-#endif // defined __linux__ || defined __linux
-
-int TestLauncher::testDyeSSpeed()
-{
-#if defined __linux__ || defined __linux
-#ifdef SIMD_SUPPORTED
- const int sz = 100000;
- uint32_t buf[sz];
- timespec time1;
- timespec time2;
-
- DyePalette pal("#0000ff,000000,000020,706050", 6);
-
- runDyeTest("dye s salt", "default time", replaceSColorDefault);
- runDyeTest("dye s salt", "sse2 time ", replaceSColorSse2);
- runDyeTest("dye s salt", "avx2 time ", replaceSColorAvx2);
-#endif // SIMD_SUPPORTED
-#endif // defined __linux__ || defined __linux
- return 0;
-}
-
-int TestLauncher::testDyeASpeed()
-{
-#if defined __linux__ || defined __linux
-#ifdef SIMD_SUPPORTED
- const int sz = 100000;
- uint32_t buf[sz];
- timespec time1;
- timespec time2;
-
- DyePalette pal("#0000ffff,00000000,000020ff,70605040", 8);
-
- runDyeTest("dye a salt", "default time", replaceAColorDefault);
- runDyeTest("dye a salt", "sse2 time ", replaceAColorSse2);
- runDyeTest("dye a salt", "avx2 time ", replaceAColorAvx2);
-#endif // SIMD_SUPPORTED
-#endif // defined __linux__ || defined __linux
- return 0;
-}
-
-int TestLauncher::testBlitSpeed()
-{
-#if defined __linux__ || defined __linux
-#if SDL_BYTEORDER == SDL_LIL_ENDIAN
-#ifndef USE_SDL2
-
- timespec time1;
- timespec time2;
- const int cnt1 = 10000;
- const int cnt2 = 10;
-
- SDL_Surface *const srcSurface = imageHelper->create32BitSurface(
- 64, 64);
- SDL_Surface *const dstSurface = imageHelper->create32BitSurface(
- 512, 512);
- for (int f = 0; f < 64 * 64; f ++)
- static_cast<uint32_t*>(srcSurface->pixels)[f] = 0x11223344;
- clock_gettime(CLOCK_MONOTONIC, &time1);
- for (int d = 0; d < cnt2; d ++)
- {
- for (int f = 0; f < 512 * 512; f ++)
- static_cast<uint32_t*>(dstSurface->pixels)[f] = 0x55667788;
- for (int f = 0; f < cnt1; f ++)
- {
- SDLgfxBlitRGBA(srcSurface,
- nullptr,
- dstSurface,
- nullptr);
- }
- }
- calcTime("blit test",
- "custom time",
- time1,
- time2,
- static_cast<uint32_t*>(dstSurface->pixels));
-
- clock_gettime(CLOCK_MONOTONIC, &time1);
- for (int d = 0; d < cnt2; d ++)
- {
- for (int f = 0; f < 512 * 512; f ++)
- static_cast<uint32_t*>(dstSurface->pixels)[f] = 0x55667788;
- for (int f = 0; f < cnt1; f ++)
- {
- SDL_gfxBlitRGBA(srcSurface,
- nullptr,
- dstSurface,
- nullptr);
- }
- }
- calcTime("blit test",
- "SDL_gfx time",
- time1,
- time2,
- static_cast<uint32_t*>(dstSurface->pixels));
-
-#endif // USE_SDL2
-#endif // SDL_BYTEORDER == SDL_LIL_ENDIAN
-#endif // defined __linux__ || defined __linux
- return 0;
-}
-
-int TestLauncher::testStackSpeed()
-{
-/*
- const int sz = 100000;
- const int k = 100;
- const int sz2 = sz * k;
-
- std::stack<ClipRect> stack1;
- MStack<ClipRect> stack2(sz2);
- timespec time1;
- timespec time2;
-
-#if defined __linux__ || defined __linux
- for (int d = 0; d < 100; d ++)
- {
- for (int f = 0; f < sz; f ++)
- {
- ClipRect rect;
- rect.xOffset = f;
- rect.yOffset = f;
- stack1.push(rect);
- }
- }
- while (!stack1.empty())
- stack1.pop();
-
- clock_gettime(CLOCK_MONOTONIC, &time1);
-
- for (int d = 0; d < 100; d ++)
- {
- for (int f = 0; f < sz; f ++)
- {
- ClipRect rect;
- rect.xOffset = f;
- rect.yOffset = f;
- stack1.push(rect);
- }
- }
-
- clock_gettime(CLOCK_MONOTONIC, &time2);
- long diff = ((static_cast<long int>(time2.tv_sec) * 1000000000L
- + static_cast<long int>(time2.tv_nsec)) / 1) -
- ((static_cast<long int>(time1.tv_sec) * 1000000000L
- + static_cast<long int>(time1.tv_nsec)) / 1);
- printf("debug: %d\n", stack1.top().xOffset);
- printf("stl time: %ld\n", diff);
-
- for (int d = 0; d < 100; d ++)
- {
- for (int f = 0; f < sz; f ++)
- {
- ClipRect &rect = stack2.push();
- rect.xOffset = f;
- rect.yOffset = f;
- }
- }
- stack2.clear();
-
- clock_gettime(CLOCK_MONOTONIC, &time1);
-
- for (int d = 0; d < 100; d ++)
- {
- for (int f = 0; f < sz; f ++)
- {
- ClipRect &rect = stack2.push();
- rect.xOffset = f;
- rect.yOffset = f;
- }
- }
-
- clock_gettime(CLOCK_MONOTONIC, &time2);
- diff = ((static_cast<long int>(time2.tv_sec) * 1000000000L
- + static_cast<long int>(time2.tv_nsec)) / 1) -
- ((static_cast<long int>(time1.tv_sec) * 1000000000L
- + static_cast<long int>(time1.tv_nsec)) / 1);
- printf("debug: %d\n", stack2.top().xOffset);
- printf("my time: %ld\n", diff);
-
-#endif
-*/
- return 0;
-}
-
-int TestLauncher::testDraw()
-{
- Image *img[3];
- img[0] = Theme::getImageFromTheme("graphics/sprites/arrow_left.png");
- img[1] = Theme::getImageFromTheme("graphics/sprites/arrow_right.png");
- img[2] = Theme::getImageFromTheme("graphics/sprites/arrow_up.png");
- Skin *skin = theme->load("button.xml", "button.xml");
- if (skin == nullptr)
- return 0;
-
- ImageCollection *const col = new ImageCollection;
- ImageCollection *const col2 = new ImageCollection;
- ImageVertexes *const vert = new ImageVertexes;
- vert->image = img[2];
-
- mainGraphics->pushClipArea(Rect(10, 20, 790, 580));
- mainGraphics->setColor(Color(0xFFU, 0xFFU, 0x00U, 0xFFU));
- mainGraphics->drawRectangle(Rect(0, 0, 400, 200));
-
- mainGraphics->setColor(Color(0xFFU, 0x00U, 0x00U, 0xB0U));
- img[0]->setAlpha(0.5f);
- mainGraphics->drawImage(img[0], 190, 383);
- img[0]->setAlpha(1.0f);
-
- mainGraphics->calcWindow(col2,
- 5, 40,
- 500, 40,
- skin->getBorder());
- mainGraphics->finalize(col2);
-
- mainGraphics->calcTileVertexes(vert, img[2], 10, 10);
- mainGraphics->calcTileVertexes(vert, img[2], 40, 10);
- mainGraphics->finalize(vert);
-
- mainGraphics->setColor(Color(0x80U, 0x00U, 0xA0U, 0x90U));
- mainGraphics->fillRectangle(Rect(200, 100, 300, 300));
- mainGraphics->popClipArea();
-
- Color color(0xFFU, 0x00U, 0x00U, 0xB0U);
- Color color2(0x00U, 0xFFU, 0x00U, 0xB0U);
- boldFont->drawString(mainGraphics,
- color, color2,
- "test test test test test test test test ", 300, 100);
-
- mainGraphics->drawTileCollection(col2);
-
- mainGraphics->drawPattern(img[0], 10, 400, 300, 180);
-
- mainGraphics->calcPattern(col, img[1], 500, 400, 150, 100);
- mainGraphics->finalize(col);
-
- mainGraphics->drawTileVertexes(vert);
-
- mainGraphics->drawRescaledImage(img[0], 250, 350, 35, 90);
-
- mainGraphics->setColor(Color(0x00U, 0xFFU, 0x00U, 0x90U));
- mainGraphics->drawNet(450, 10, 600, 300, 32, 20);
-
- mainGraphics->drawTileCollection(col);
-
- img[0]->setAlpha(0.3f);
- mainGraphics->drawRescaledPattern(img[0], 250, 150, 250, 300, 30, 100);
-
- for (int f = 0; f < 255; f ++)
- {
- mainGraphics->setColor(Color(0x20U, 0x60U, f, 0x90U));
- mainGraphics->drawLine(300 + f, 490, 300 + f, 480);
- for (int d = 0; d < 10; d ++)
- mainGraphics->drawPoint(300 + f, 500 + d);
- }
- mainGraphics->updateScreen();
- sleep(10);
-
- delete col;
- delete col2;
- delete vert;
- return 0;
-}
-
-int TestLauncher::testVideoDetection()
-{
- file << mTest << std::endl;
- file << graphicsManager.detectGraphics() << std::endl;
- return 0;
-}
-
-int TestLauncher::calcFps(const timeval &start,
- const timeval &end,
- const int calls) const
-{
- long mtime;
- long seconds;
- long useconds;
-
- seconds = end.tv_sec - start.tv_sec;
- useconds = end.tv_usec - start.tv_usec;
-
- mtime = (seconds * 1000 + useconds / 1000.0) + 0.5;
- if (mtime == 0)
- return 100000;
-
- return CAST_S32(static_cast<long>(calls) * 10000 / mtime);
-}
-
-#endif // USE_OPENGL
diff --git a/src/test/testlauncher.h b/src/test/testlauncher.h
deleted file mode 100644
index efd0eea2b..000000000
--- a/src/test/testlauncher.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 TEST_TESTLAUNCHER_H
-#define TEST_TESTLAUNCHER_H
-
-#ifdef USE_OPENGL
-
-#include <fstream>
-
-#ifdef WIN32
-#include <sys/time.h>
-#endif // WIN32
-
-#ifdef __native_client__
-#include <sys/time.h>
-#endif // __native_client__
-
-#include "localconsts.h"
-
-class TestLauncher final
-{
- public:
- explicit TestLauncher(std::string test);
-
- A_DELETE_COPY(TestLauncher)
-
- ~TestLauncher();
-
- int exec();
-
- int calcFps(const timeval &start,
- const timeval &end,
- const int calls) const;
-
- int testBackend() const;
-
- int testSound() const;
-
- int testRescale() const;
-
- int testFps();
-
- int testFps2();
-
- int testFps3();
-
- int testInternal();
-
- int testDye();
-
- int testVideoDetection();
-
- int testBatches();
-
- int testTextures();
-
- int testDraw();
-
- int testDyeSSpeed();
-
- int testDyeASpeed();
-
- int testStackSpeed();
-
- int testBlitSpeed();
-
- private:
- std::string mTest;
-
- std::ofstream file;
-};
-
-#endif // USE_OPENGL
-#endif // TEST_TESTLAUNCHER_H
diff --git a/src/test/testmain.cpp b/src/test/testmain.cpp
deleted file mode 100644
index 0d75cae7b..000000000
--- a/src/test/testmain.cpp
+++ /dev/null
@@ -1,431 +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 "test/testmain.h"
-
-#ifdef USE_OPENGL
-
-#include "logger.h"
-#include "settings.h"
-
-#include "fs/paths.h"
-
-#include "utils/cast.h"
-#include "utils/delete2.h"
-#include "utils/process.h"
-
-#include "debug.h"
-
-std::string fileName;
-extern char *selfName;
-
-TestMain::TestMain() :
- log(new Logger),
- mConfig()
-{
- fileName = getSelfName();
- log->setLogFile(pathJoin(settings.localDataDir, "manaplustest.log"));
-}
-
-TestMain::~TestMain()
-{
- delete2(log);
-}
-
-void TestMain::initConfig()
-{
- mConfig.init(settings.configDir + "/test.xml");
- mConfig.clear();
-// setConfigDefaults(mConfig);
-
- mConfig.setValue("hwaccel", false);
- mConfig.setValue("screen", false);
- mConfig.setValue("sound", false);
- mConfig.setValue("guialpha", 0.8F);
-// mConfig.setValue("remember", true);
- mConfig.setValue("sfxVolume", 50);
- mConfig.setValue("musicVolume", 60);
- mConfig.setValue("fpslimit", 0);
- mConfig.setValue("customcursor", true);
- mConfig.setValue("useScreenshotDirectorySuffix", true);
- mConfig.setValue("ChatLogLength", 128);
- mConfig.setValue("screenwidth", 800);
- mConfig.setValue("screenheight", 600);
-}
-
-int TestMain::exec(const bool testAudio)
-{
- initConfig();
- int softwareTest = invokeSoftwareRenderTest("1");
- int soundTest = -1;
- int rescaleTest[6];
- int softFps = 0;
- int normalOpenGLFps = 0;
- int safeOpenGLFps = 0;
- int modernOpenGLFps = 0;
- int textureSize[6];
- std::string textureSizeStr;
-
- RenderType openGLMode = RENDER_SOFTWARE;
- int detectMode = 0;
- for (int f = 0; f < 6; f ++)
- {
- rescaleTest[f] = -1;
- textureSize[f] = 1024;
- }
- std::string info;
-
- const int videoDetectTest = invokeTest("99");
- if (videoDetectTest == 0)
- detectMode = readValue2(99);
-
- int normalOpenGLTest = invokeNormalOpenGLRenderTest("2");
- int safeOpenGLTest = invokeSafeOpenGLRenderTest("3");
- int modernOpenGLTest = invokeModernOpenGLRenderTest("19");
- if (testAudio)
- soundTest = invokeTest4();
- else
- soundTest = 0;
-
- info.append(strprintf("%d.%d,%d,%d,%d.", soundTest, softwareTest,
- normalOpenGLTest, safeOpenGLTest, modernOpenGLTest));
-
- if (softwareTest == 0)
- {
- int softFpsTest = invokeSoftwareRenderTest("8");
- info.append(strprintf("%d", softFpsTest));
- if (softFpsTest == 0)
- {
- softFps = readValue2(8);
- info.append(strprintf(",%d", softFps));
- if (softFps == 0)
- {
- softwareTest = -1;
- softFpsTest = -1;
- }
- else
- {
- rescaleTest[0] = invokeSoftwareRenderTest("5");
- info.append(strprintf(",%d", rescaleTest[0]));
- }
- }
- else
- {
- softwareTest = -1;
- }
- }
- info.append(".");
- if (modernOpenGLTest == 0)
- {
- int modernOpenGLFpsTest = invokeModernOpenGLRenderTest("17");
- info.append(strprintf("%d", modernOpenGLFpsTest));
- if (modernOpenGLFpsTest == 0)
- {
- modernOpenGLFps = readValue2(17);
- info.append(strprintf(",%d", modernOpenGLFps));
- if (modernOpenGLFps == 0)
- {
- modernOpenGLTest = -1;
- modernOpenGLFpsTest = -1;
- }
- else
- {
- rescaleTest[3] = invokeModernOpenGLRenderTest("18");
- info.append(strprintf(",%d", rescaleTest[3]));
- }
- }
- else
- {
- modernOpenGLTest = -1;
- }
- }
- info.append(".");
- if (normalOpenGLTest == 0)
- {
- int normalOpenGLFpsTest = invokeNormalOpenGLRenderTest("9");
- info.append(strprintf("%d", normalOpenGLFpsTest));
- if (normalOpenGLFpsTest == 0)
- {
- normalOpenGLFps = readValue2(9);
- info.append(strprintf(",%d", normalOpenGLFps));
- if (normalOpenGLFps == 0)
- {
- normalOpenGLTest = -1;
- normalOpenGLFpsTest = -1;
- }
- else
- {
- rescaleTest[1] = invokeNormalOpenGLRenderTest("6");
- info.append(strprintf(",%d", rescaleTest[1]));
- }
- }
- else
- {
- normalOpenGLTest = -1;
- }
- }
- info.append(".");
- if (safeOpenGLTest == 0)
- {
- int safeOpenGLFpsTest = invokeSafeOpenGLRenderTest("10");
- info.append(strprintf("%d", safeOpenGLFpsTest));
- if (safeOpenGLFpsTest == 0)
- {
- safeOpenGLFps = readValue2(10);
- info.append(strprintf(",%d", safeOpenGLFps));
- if (safeOpenGLFps == 0)
- {
- safeOpenGLTest = -1;
- safeOpenGLFpsTest = -1;
- }
- else
- {
- rescaleTest[2] = invokeSafeOpenGLRenderTest("7");
- info.append(strprintf(",%d", rescaleTest[2]));
- }
- }
- else
- {
- safeOpenGLTest = -1;
- }
- }
- info.append(".");
-
- int maxFps = softFps;
- if (maxFps < normalOpenGLFps)
- {
- openGLMode = RENDER_NORMAL_OPENGL;
- maxFps = normalOpenGLFps;
- }
- if (maxFps < modernOpenGLFps)
- {
- openGLMode = RENDER_MODERN_OPENGL;
- maxFps = modernOpenGLFps;
- }
- if (maxFps < safeOpenGLFps)
- {
- openGLMode = RENDER_SAFE_OPENGL;
- maxFps = safeOpenGLFps;
- }
-
- int batchSize = 256;
-
- if (invokeNormalOpenBatchTest("11") == 0)
- batchSize = readValue2(11);
- if (batchSize < 256)
- batchSize = 256;
-
- if (invokeNormalOpenBatchTest("14") == 0)
- {
- textureSize[CAST_SIZE(RENDER_NORMAL_OPENGL)]
- = readValue2(14);
- }
- if (invokeModernOpenBatchTest("15") == 0)
- {
- textureSize[CAST_SIZE(RENDER_MODERN_OPENGL)]
- = readValue2(15);
- }
- if (invokeSafeOpenBatchTest("16") == 0)
- {
- textureSize[CAST_SIZE(RENDER_SAFE_OPENGL)]
- = readValue2(16);
- }
- if (invokeMobileOpenBatchTest("20") == 0)
- {
- textureSize[CAST_SIZE(RENDER_GLES_OPENGL)]
- = readValue2(20);
- }
- for (int f = 0; f < 6; f ++)
- info.append(strprintf(",%d", textureSize[f]));
- info.append(",-");
-
- textureSizeStr = toString(textureSize[0]);
- for (int f = 1; f < 6; f ++)
- textureSizeStr.append(strprintf(",%d", textureSize[f]));
-
- // if OpenGL implimentation is not good, disable it.
- if ((detectMode & 15) == 0)
- openGLMode = RENDER_SOFTWARE;
-
- writeConfig(openGLMode, rescaleTest[CAST_SIZE(openGLMode)],
- soundTest, info, batchSize, textureSizeStr, detectMode);
- return 0;
-}
-
-void TestMain::writeConfig(const RenderType openGLMode,
- const int rescale,
- const int sound,
- const std::string &info,
- const int batchSize A_UNUSED,
- const std::string &textureSize,
- const int detectMode)
-{
- mConfig.init(settings.configDir + "/config.xml");
-
- log->log("set mode to %d", CAST_S32(openGLMode));
-
- // searched values
- mConfig.setValue("opengl", CAST_S32(openGLMode));
- mConfig.setValue("showBackground", rescale == 0);
- mConfig.setValue("sound", sound == 0);
-
- // better performance
- mConfig.setValue("hwaccel", true);
- mConfig.setValue("fpslimit", 60);
- mConfig.setValue("altfpslimit", 2);
- mConfig.setValue("safemode", false);
- mConfig.setValue("enableMapReduce", true);
- mConfig.setValue("textureSize", textureSize);
-
- // max batch size
-// mConfig.setValue("batchsize", batchSize);
-
- // additional modes
- mConfig.setValue("useTextureSampler",
- static_cast<bool>(detectMode & 1024));
- mConfig.setValue("compresstextures",
- static_cast<bool>(detectMode & 2048));
-
- // stats
- mConfig.setValue("testInfo", info);
-
- mConfig.write();
-}
-
-int TestMain::readValue2(const int ver)
-{
- const int def = readValue(ver, 0);
- log->log("value for %d = %d", ver, def);
- return def;
-}
-
-int TestMain::readValue(const int ver, int def)
-{
- std::string tmp;
- int var;
- std::ifstream file;
- file.open(pathJoin(settings.localDataDir, "test.log").c_str(),
- std::ios::in);
- if (!getline(file, tmp))
- {
- file.close();
- return def;
- }
- var = atoi(tmp.c_str());
- if (ver != var || !getline(file, tmp))
- {
- file.close();
- return def;
- }
- def = atoi(tmp.c_str());
- file.close();
- return def;
-}
-
-int TestMain::invokeTest(const std::string &test)
-{
- mConfig.setValue("opengl", CAST_S32(RENDER_SOFTWARE));
-
- mConfig.write();
- const int ret = execFileWait(fileName, fileName, "-t", test);
- return ret;
-}
-
-int TestMain::invokeTest4()
-{
- mConfig.setValue("sound", true);
- const int ret = invokeTest("4");
-
- log->log("4: %d", ret);
- return ret;
-}
-
-int TestMain::invokeSoftwareRenderTest(const std::string &test)
-{
- mConfig.setValue("opengl", CAST_S32(RENDER_SOFTWARE));
- mConfig.write();
- const int ret = execFileWait(fileName, fileName, "-t", test, 30);
- log->log("%s: %d", test.c_str(), ret);
- return ret;
-}
-
-int TestMain::invokeNormalOpenGLRenderTest(const std::string &test)
-{
- mConfig.setValue("opengl", CAST_S32(RENDER_NORMAL_OPENGL));
- mConfig.write();
- const int ret = execFileWait(fileName, fileName, "-t", test, 30);
- log->log("%s: %d", test.c_str(), ret);
- return ret;
-}
-
-int TestMain::invokeModernOpenGLRenderTest(const std::string &test)
-{
- mConfig.setValue("opengl", CAST_S32(RENDER_MODERN_OPENGL));
- mConfig.write();
- const int ret = execFileWait(fileName, fileName, "-t", test, 30);
- log->log("%s: %d", test.c_str(), ret);
- return ret;
-}
-
-int TestMain::invokeNormalOpenBatchTest(const std::string &test)
-{
- mConfig.setValue("opengl", CAST_S32(RENDER_NORMAL_OPENGL));
- mConfig.write();
- const int ret = execFileWait(fileName, fileName, "-t", test, 30);
-// log->log("%s: %d", test.c_str(), ret);
- return ret;
-}
-
-int TestMain::invokeModernOpenBatchTest(const std::string &test)
-{
- mConfig.setValue("opengl", CAST_S32(RENDER_MODERN_OPENGL));
- mConfig.write();
- const int ret = execFileWait(fileName, fileName, "-t", test, 30);
-// log->log("%s: %d", test.c_str(), ret);
- return ret;
-}
-
-int TestMain::invokeMobileOpenBatchTest(const std::string &test)
-{
- mConfig.setValue("opengl", CAST_S32(RENDER_GLES_OPENGL));
- mConfig.write();
- const int ret = execFileWait(fileName, fileName, "-t", test, 30);
-// log->log("%s: %d", test.c_str(), ret);
- return ret;
-}
-
-int TestMain::invokeSafeOpenBatchTest(const std::string &test)
-{
- mConfig.setValue("opengl", CAST_S32(RENDER_SAFE_OPENGL));
- mConfig.write();
- const int ret = execFileWait(fileName, fileName, "-t", test, 30);
-// log->log("%s: %d", test.c_str(), ret);
- return ret;
-}
-
-int TestMain::invokeSafeOpenGLRenderTest(const std::string &test)
-{
- mConfig.setValue("opengl", CAST_S32(RENDER_SAFE_OPENGL));
- mConfig.write();
- const int ret = execFileWait(fileName, fileName, "-t", test, 30);
- log->log("%s: %d", test.c_str(), ret);
- return ret;
-}
-#endif // USE_OPENGL
diff --git a/src/test/testmain.h b/src/test/testmain.h
deleted file mode 100644
index 6d087b445..000000000
--- a/src/test/testmain.h
+++ /dev/null
@@ -1,93 +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 TEST_TESTMAIN_H
-#define TEST_TESTMAIN_H
-
-#ifdef USE_OPENGL
-
-#include "configuration.h"
-
-#include "render/renderers.h"
-
-class Logger;
-
-class TestMain final
-{
- public:
- TestMain();
-
- A_DELETE_COPY(TestMain)
-
- ~TestMain();
-
- int exec(const bool testAudio = true);
-
- static int readValue(const int ver, int def);
-
- Configuration &getConfig()
- { return mConfig; }
-
- private:
- void initConfig();
-
- int invokeTest(const std::string &test);
-
- int invokeTest3();
-
- int invokeTest4();
-
- int invokeTest7();
-
- int invokeSoftwareRenderTest(const std::string &test);
-
- int invokeNormalOpenGLRenderTest(const std::string &test);
-
- int invokeNormalOpenBatchTest(const std::string &test);
-
- int invokeModernOpenGLRenderTest(const std::string &test);
-
- int invokeModernOpenBatchTest(const std::string &test);
-
- int invokeMobileOpenBatchTest(const std::string &test);
-
- int invokeSafeOpenBatchTest(const std::string &test);
-
- int invokeSafeOpenGLRenderTest(const std::string &test);
-
- void testsMain();
-
- void writeConfig(const RenderType openGLMode,
- const int rescale,
- const int sound,
- const std::string &info,
- const int batchSize,
- const std::string &textureSize,
- const int detectMode);
-
- int readValue2(const int ver);
-
- Logger *log;
-
- Configuration mConfig;
-};
-
-#endif // USE_OPENGL
-#endif // TEST_TESTMAIN_H
diff --git a/src/text.cpp b/src/text.cpp
deleted file mode 100644
index 671139a05..000000000
--- a/src/text.cpp
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 Douglas Boffey <DougABoffey@netscape.net>
- * 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 "text.h"
-
-#include "configuration.h"
-#include "textmanager.h"
-
-#include "gui/gui.h"
-#include "gui/theme.h"
-
-#include "gui/fonts/font.h"
-
-#include "resources/imagerect.h"
-
-#include "resources/image/image.h"
-
-#include "utils/delete2.h"
-
-#include "debug.h"
-
-int Text::mInstances = 0;
-ImageRect Text::mBubble;
-
-Text::Text(const std::string &text,
- const int x, const int y,
- const Graphics::Alignment alignment,
- const Color *const color,
- const Speech isSpeech,
- Font *const font) :
- mFont(font != nullptr ?
- font : (gui != nullptr ? gui->getFont() : nullptr)),
- mTextChunk(),
- mX(x),
- mY(y),
- mWidth(mFont != nullptr ? mFont->getWidth(text) : 1),
- mHeight(mFont != nullptr ? mFont->getHeight() : 1),
- mXOffset(0),
- mText(text),
- mColor(color),
- mOutlineColor(color != nullptr ? (isSpeech == Speech_true ?
- *color : theme->getColor(ThemeColorId::OUTLINE, 255)) : Color()),
- mIsSpeech(isSpeech),
- mTextChanged(true)
-{
- if (textManager == nullptr)
- {
- textManager = new TextManager;
- if (theme != nullptr)
- {
- theme->loadRect(mBubble, "bubble.xml", "");
- }
- else
- {
- for (int f = 0; f < 9; f ++)
- mBubble.grid[f] = nullptr;
- }
-
- const float bubbleAlpha = config.getFloatValue("speechBubbleAlpha");
- for (int i = 0; i < 9; i++)
- {
- if (mBubble.grid[i] != nullptr)
- mBubble.grid[i]->setAlpha(bubbleAlpha);
- }
- }
- ++mInstances;
-
- switch (alignment)
- {
- case Graphics::LEFT:
- mXOffset = 0;
- break;
- case Graphics::CENTER:
- mXOffset = mWidth / 2;
- break;
- case Graphics::RIGHT:
- mXOffset = mWidth;
- break;
- default:
- break;
- }
- mX = x - mXOffset;
- if (textManager != nullptr)
- textManager->addText(this);
-}
-
-Text::~Text()
-{
- if (textManager != nullptr)
- textManager->removeText(this);
- if (--mInstances == 0)
- {
- delete2(textManager);
- for (int f = 0; f < 9; f ++)
- {
- if (mBubble.grid[f] != nullptr)
- {
- mBubble.grid[f]->decRef();
- mBubble.grid[f] = nullptr;
- }
- }
- }
-}
-
-void Text::setColor(const Color *const color)
-{
- mTextChanged = true;
- if (mIsSpeech == Speech_true)
- {
- mColor = color;
- mOutlineColor = *color;
- }
- else
- {
- mColor = color;
- }
-}
-
-void Text::adviseXY(const int x, const int y,
- const Move move)
-{
- if ((textManager != nullptr) && move == Move_true)
- {
- textManager->moveText(this, x - mXOffset, y);
- }
- else
- {
- mX = x - mXOffset;
- mY = y;
- }
-}
-
-void Text::draw(Graphics *const graphics, const int xOff, const int yOff)
-{
- BLOCK_START("Text::draw")
- if (mIsSpeech == Speech_true)
- {
- graphics->drawImageRect(mX - xOff - 5,
- mY - yOff - 5,
- mWidth + 10,
- mHeight + 10,
- mBubble);
- }
-
- if (mTextChanged)
- {
- mTextChunk.textFont = mFont;
- mTextChunk.deleteImage();
- mTextChunk.text = mText;
- mTextChunk.color = *mColor;
- mTextChunk.color2 = mOutlineColor;
- mFont->generate(mTextChunk);
- mTextChanged = false;
- }
-
- const Image *const image = mTextChunk.img;
- if (image != nullptr)
- graphics->drawImage(image, mX - xOff, mY - yOff);
-
- BLOCK_END("Text::draw")
-}
-
-FlashText::FlashText(const std::string &text,
- const int x, const int y,
- const Graphics::Alignment alignment,
- const Color *const color,
- Font *const font) :
- Text(text, x, y, alignment, color, Speech_false, font),
- mTime(0)
-{
-}
-
-void FlashText::draw(Graphics *const graphics, const int xOff, const int yOff)
-{
- BLOCK_START("FlashText::draw")
- if (mTime != 0)
- {
- if ((--mTime & 4) == 0)
- {
- BLOCK_END("FlashText::draw")
- return;
- }
- }
- Text::draw(graphics, xOff, yOff);
- BLOCK_END("FlashText::draw")
-}
diff --git a/src/text.h b/src/text.h
deleted file mode 100644
index e2bdfaae4..000000000
--- a/src/text.h
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 Douglas Boffey <DougABoffey@netscape.net>
- * 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 TEXT_H
-#define TEXT_H
-
-#include "enums/simpletypes/move.h"
-#include "enums/simpletypes/speech.h"
-
-#include "gui/fonts/textchunk.h"
-
-#include "render/graphics.h"
-
-#include "localconsts.h"
-
-class Font;
-
-class Text notfinal
-{
- friend class TextManager;
-
- public:
- /**
- * Constructor creates a text object to display on the screen.
- */
- Text(const std::string &text,
- const int x, const int y,
- const Graphics::Alignment alignment,
- const Color *const color,
- const Speech isSpeech = Speech_false,
- Font *const font = nullptr);
-
- A_DELETE_COPY(Text)
-
- /**
- * Destructor. The text is removed from the screen.
- */
- virtual ~Text();
-
- void setColor(const Color *const color);
-
- int getWidth() const noexcept2 A_WARN_UNUSED
- { return mWidth; }
-
- int getHeight() const noexcept2 A_WARN_UNUSED
- { return mHeight; }
-
- /**
- * Allows the originator of the text to specify the ideal coordinates.
- */
- void adviseXY(const int x, const int y, const Move move);
-
- /**
- * Draws the text.
- */
- virtual void draw(Graphics *const graphics,
- const int xOff, const int yOff) A_NONNULL(2);
-
-// int getWidth() A_WARN_UNUSED;
-
- int getX() const noexcept2 A_WARN_UNUSED
- { return mX; }
-
- int getY() const noexcept2 A_WARN_UNUSED
- { return mY; }
-
- private:
- Font *mFont; /**< The font of the text */
- TextChunk mTextChunk;
- int mX; /**< Actual x-value of left of text written. */
- int mY; /**< Actual y-value of top of text written. */
- int mWidth; /**< The width of the text. */
- int mHeight; /**< The height of the text. */
- int mXOffset; /**< The offset of mX from the desired x. */
- static int mInstances; /**< Instances of text. */
- std::string mText; /**< The text to display. */
- const Color *mColor; /**< The color of the text. */
- Color mOutlineColor;
- Speech mIsSpeech; /**< Is this text a speech bubble? */
- bool mTextChanged;
-
- protected:
- static ImageRect mBubble; /**< Speech bubble graphic */
-};
-
-class FlashText final : public Text
-{
- public:
- FlashText(const std::string &text, const int x, const int y,
- const Graphics::Alignment alignment,
- const Color *const color,
- Font *const font = nullptr);
-
- A_DELETE_COPY(FlashText)
-
- /**
- * Remove the text from the screen
- */
- ~FlashText()
- { }
-
- /**
- * Flash the text for so many refreshes.
- */
- void flash(const int time)
- { mTime = time; }
-
- /**
- * Draws the text.
- */
- void draw(Graphics *const graphics,
- const int xOff, const int yOff) override final A_NONNULL(2);
-
- private:
- int mTime; /**< Time left for flashing */
-};
-
-#endif // TEXT_H
diff --git a/src/textcommand.cpp b/src/textcommand.cpp
deleted file mode 100644
index 5c0a2b071..000000000
--- a/src/textcommand.cpp
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 Andrei Karas
- * 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 "textcommand.h"
-
-#include "configuration.h"
-
-#include "gui/theme.h"
-
-#include "resources/iteminfo.h"
-
-#include "resources/db/itemdb.h"
-
-#include "resources/image/image.h"
-
-#include "resources/loaders/imageloader.h"
-
-#include "debug.h"
-
-#ifdef TMWA_SUPPORT
-TextCommand::TextCommand(const int id,
- const std::string &symbol,
- const std::string &command,
- const std::string &comment,
- const CommandTargetT type,
- const std::string &icon,
- const unsigned int basicLvl,
- const MagicSchoolT school,
- const unsigned int schoolLvl,
- const unsigned int mana) :
- mCommand(command),
- mComment(comment),
- mSymbol(symbol),
- mTargetType(type),
- mIcon(icon),
- mId(id),
- mMana(mana),
- mSchool(school),
- mBaseLvl(basicLvl),
- mSchoolLvl(schoolLvl),
- mCommandType(TextCommandType::Magic),
- mImage(nullptr)
-{
- loadImage();
-}
-#endif // TMWA_SUPPORT
-
-TextCommand::TextCommand(const int id,
- const std::string &symbol,
- const std::string &command,
- const std::string &comment,
- const CommandTargetT type,
- const std::string &icon) :
- mCommand(command),
- mComment(comment),
- mSymbol(symbol),
- mTargetType(type),
- mIcon(icon),
- mId(id),
-#ifdef TMWA_SUPPORT
- mMana(0U),
- mSchool(MagicSchool::SkillMagic),
- mBaseLvl(0),
- mSchoolLvl(0),
- mCommandType(TextCommandType::Text),
-#endif // TMWA_SUPPORT
- mImage(nullptr)
-{
- loadImage();
-}
-
-TextCommand::TextCommand(const int id) :
- mCommand(""),
- mComment(""),
- mSymbol(""),
- mTargetType(CommandTarget::NoTarget),
- mIcon(""),
- mId(id),
-#ifdef TMWA_SUPPORT
- mMana(0U),
- mSchool(MagicSchool::SkillMagic),
- mBaseLvl(0),
- mSchoolLvl(0),
- mCommandType(TextCommandType::Text),
-#endif // TMWA_SUPPORT
- mImage(nullptr)
-{
- loadImage();
-}
-
-
-TextCommand::~TextCommand()
-{
- if (mImage != nullptr)
- {
- mImage->decRef();
- mImage = nullptr;
- }
-}
-
-void TextCommand::loadImage()
-{
- if (mImage != nullptr)
- {
- mImage->decRef();
- mImage = nullptr;
- }
-
- if (mIcon.empty() ||
- !ItemDB::exists(mIcon))
- {
- return;
- }
-
- const ItemInfo &info = ItemDB::get(mIcon);
- const SpriteDisplay &display = info.getDisplay();
- mImage = Loader::getImage(pathJoin(paths.getStringValue("itemIcons"),
- display.image));
-
- if (mImage == nullptr)
- mImage = Theme::getImageFromTheme("unknown-item.png");
-}
diff --git a/src/textcommand.h b/src/textcommand.h
deleted file mode 100644
index 91c0f9ba5..000000000
--- a/src/textcommand.h
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 Andrei Karas
- * 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 TEXTCOMMAND_H
-#define TEXTCOMMAND_H
-
-#include "enums/commandtarget.h"
-#ifdef TMWA_SUPPORT
-#include "enums/magicschool.h"
-#include "enums/textcommandtype.h"
-#endif
-
-#include <string>
-
-#include "localconsts.h"
-
-class Image;
-
-/**
- * Represents one or more instances of a certain item type.
- */
-class TextCommand final
-{
- public:
-#ifdef TMWA_SUPPORT
- /**
- * Constructor.
- */
- TextCommand(const int id,
- const std::string &symbol,
- const std::string &command,
- const std::string &comment,
- const CommandTargetT type,
- const std::string &icon,
- const unsigned int basicLvl,
- const MagicSchoolT school = MagicSchool::SkillMagic,
- const unsigned int schoolLvl = 0U,
- const unsigned int mana = 0U);
-#endif // TMWA_SUPPORT
-
- /**
- * Constructor.
- */
- TextCommand(const int id,
- const std::string &symbol,
- const std::string &command,
- const std::string &comment,
- const CommandTargetT type,
- const std::string &icon);
-
- /**
- * Constructor.
- */
- explicit TextCommand(const int id);
-
- A_DELETE_COPY(TextCommand)
-
- /**
- * Destructor.
- */
- ~TextCommand();
-
- std::string getName() const noexcept2 A_WARN_UNUSED
- { return mCommand; }
-
- std::string getCommand() const noexcept2 A_WARN_UNUSED
- { return mCommand; }
-
- std::string getComment() const noexcept2 A_WARN_UNUSED
- { return mComment; }
-
- std::string getSymbol() const noexcept2 A_WARN_UNUSED
- { return mSymbol; }
-
- int getId() const noexcept2 A_WARN_UNUSED
- { return mId; }
-
- CommandTargetT getTargetType() const noexcept2 A_WARN_UNUSED
- { return mTargetType; }
-
- std::string getIcon() const noexcept2 A_WARN_UNUSED
- { return mIcon; }
-
-#ifdef TMWA_SUPPORT
- unsigned int getMana() const noexcept2 A_WARN_UNUSED
- { return mMana; }
-
- MagicSchoolT getSchool() const noexcept2 A_WARN_UNUSED
- { return mSchool; }
-
- unsigned getBaseLvl() const noexcept2 A_WARN_UNUSED
- { return mBaseLvl; }
-
- unsigned getSchoolLvl() const noexcept2 A_WARN_UNUSED
- { return mSchoolLvl; }
-
- void setMana(const unsigned int mana)
- { mMana = mana; }
-
- void setSchool(const MagicSchoolT school)
- { mSchool = school; }
-
- void setBaseLvl(const unsigned int baseLvl)
- { mBaseLvl = baseLvl; }
-
- void setSchoolLvl(const unsigned int schoolLvl)
- { mSchoolLvl = schoolLvl; }
-
- TextCommandTypeT getCommandType() const noexcept2 A_WARN_UNUSED
- { return mCommandType; }
-
- void setCommandType(const TextCommandTypeT commandType)
- { mCommandType = commandType; }
-#endif // TMWA_SUPPORT
-
- void setCommand(const std::string &command)
- { mCommand = command; }
-
- void setComment(const std::string &comment)
- { mComment = comment; }
-
- void setSymbol(const std::string &symbol)
- { mSymbol = symbol; }
-
- void setId(const int id)
- { mId = id; }
-
- void setTargetType(const CommandTargetT targetType)
- { mTargetType = targetType; }
-
- void setIcon(const std::string &icon)
- { mIcon = icon; loadImage(); }
-
- bool isEmpty() const noexcept2 A_WARN_UNUSED
- { return mCommand.empty() && mSymbol.empty(); }
-
- Image *getImage() const noexcept2 A_WARN_UNUSED
- { return mImage; }
-
- private:
- void loadImage();
-
- protected:
- std::string mCommand;
- std::string mComment;
- std::string mSymbol;
- CommandTargetT mTargetType;
- std::string mIcon;
- int mId;
-#ifdef TMWA_SUPPORT
- unsigned int mMana;
- MagicSchoolT mSchool;
- unsigned mBaseLvl;
- unsigned mSchoolLvl;
- TextCommandTypeT mCommandType;
-#endif // TMWA_SUPPORT
-
- Image *mImage;
-};
-
-#endif // TEXTCOMMAND_H
diff --git a/src/textmanager.cpp b/src/textmanager.cpp
deleted file mode 100644
index 24d55b412..000000000
--- a/src/textmanager.cpp
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 Douglas Boffey <DougABoffey@netscape.net>
- * 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 "textmanager.h"
-
-#include "text.h"
-
-#include "utils/foreach.h"
-
-#include <cstring>
-
-#include "debug.h"
-
-TextManager *textManager = nullptr;
-
-TextManager::TextManager() :
- mTextList()
-{
-}
-
-void TextManager::addText(Text *const text)
-{
- if (text == nullptr)
- return;
- place(text, nullptr, text->mX, text->mY, text->mHeight);
- mTextList.push_back(text);
-}
-
-void TextManager::moveText(Text *const text,
- const int x, const int y) const
-{
- if (text == nullptr)
- return;
- text->mX = x;
- text->mY = y;
- place(text, text, text->mX, text->mY, text->mHeight);
-}
-
-void TextManager::removeText(const Text *const text)
-{
- FOR_EACH (TextList::iterator, ptr, mTextList)
- {
- if (*ptr == text)
- {
- mTextList.erase(ptr);
- return;
- }
- }
-}
-
-TextManager::~TextManager()
-{
-}
-
-void TextManager::draw(Graphics *const graphics,
- const int xOff, const int yOff)
-{
- BLOCK_START("TextManager::draw")
- FOR_EACH (TextList::const_iterator, bPtr, mTextList)
- (*bPtr)->draw(graphics, xOff, yOff);
- BLOCK_END("TextManager::draw")
-}
-
-void TextManager::place(const Text *const textObj,
- const Text *const omit,
- const int &x A_UNUSED,
- int &y,
- const int h) const
-{
- if (textObj == nullptr)
- return;
- const int xLeft = textObj->mX;
- const int xRight1 = xLeft + textObj->mWidth;
- const int TEST = 50; // Number of lines to test for text
- const int nBeings = 30;
- bool occupied[TEST]; // is some other text obscuring this line?
- std::memset(&occupied, 0, sizeof(occupied)); // set all to false
- const int wantedTop = (TEST - h) / 2; // Entry in occupied at top of text
- const int occupiedTop = y - wantedTop; // Line in map representing
- // to of occupied
- int cnt = 0;
-
- for (TextList::const_iterator ptr = mTextList.begin(),
- pfEnd = mTextList.end();
- ptr != pfEnd && cnt < nBeings;
- ++ptr, cnt ++)
- {
- const Text *const text = *ptr;
-
- if (text != omit && text->mX + 1 <= xRight1
- && text->mX + text->mWidth > xLeft)
- {
- int from = text->mY - occupiedTop;
- int to = from + text->mHeight - 1;
- if (to < 0 || from >= TEST) // out of range considered
- continue;
- if (from < 0)
- from = 0;
- if (to >= TEST)
- to = TEST - 1;
- for (int i = from; i <= to; ++i)
- occupied[i] = true;
- }
- }
- bool ok = true;
- const int sz = wantedTop + h;
- for (int i = wantedTop; i < sz; i ++)
- {
- if (occupied[i])
- {
- ok = false;
- break;
- }
- }
-
- if (ok)
- return;
-
- // Have to move it up or down, so find nearest spaces either side
- int consec = 0;
- int upSlot = -1; // means not found
- const int sz2 = wantedTop + h - 2;
- for (int seek = sz2; seek >= 0; --seek)
- {
- if (occupied[seek])
- {
- consec = 0;
- }
- else
- {
- if (++consec == h)
- {
- upSlot = seek;
- break;
- }
- }
- }
- int downSlot = -1;
- consec = 0;
- for (int seek = wantedTop + 1; seek < TEST; ++seek)
- {
- if (occupied[seek])
- {
- consec = 0;
- }
- else
- {
- if (++consec == h)
- {
- downSlot = seek - h + 1;
- break;
- }
- }
- }
- if (upSlot == -1 && downSlot == -1) // no good solution, so leave as is
- {
- return;
- }
- if (upSlot == -1) // must go down
- {
- y += downSlot - wantedTop;
- return;
- }
- if (downSlot == -1) // must go up
- {
- y -= wantedTop - upSlot;
- return;
- }
- if (wantedTop - upSlot > downSlot - wantedTop) // down is better
- {
- y += downSlot - wantedTop;
- }
- else
- {
- y -= wantedTop - upSlot;
- }
-}
diff --git a/src/textmanager.h b/src/textmanager.h
deleted file mode 100644
index efd126ecd..000000000
--- a/src/textmanager.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2008 Douglas Boffey <DougABoffey@netscape.net>
- * 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 TEXTMANAGER_H
-#define TEXTMANAGER_H
-
-#include <list>
-
-#include "localconsts.h"
-
-class Graphics;
-class Text;
-
-class TextManager final
-{
- public:
- /**
- * Constructor
- */
- TextManager();
-
- A_DELETE_COPY(TextManager)
-
- /**
- * Destroy the manager
- */
- ~TextManager();
-
- /**
- * Add text to the manager
- */
- void addText(Text *const text);
-
- /**
- * Move the text around the screen
- */
- void moveText(Text *const text, const int x, const int y) const;
-
- /**
- * Remove the text from the manager
- */
- void removeText(const Text *const text);
-
- /**
- * Draw the text
- */
- void draw(Graphics *const graphics,
- const int xOff,
- const int yOff) A_NONNULL(2);
-
- private:
- /**
- * Position the text so as to avoid conflict
- */
- void place(const Text *const textObj, const Text *const omit,
- const int &x, int &y, const int h) const;
-
- typedef std::list<Text *> TextList; /**< The container type */
- TextList mTextList; /**< The container */
-};
-
-extern TextManager *textManager;
-
-#endif // TEXTMANAGER_H
diff --git a/src/unittests/catch.hpp b/src/unittests/catch.hpp
deleted file mode 100644
index 64d1cafc4..000000000
--- a/src/unittests/catch.hpp
+++ /dev/null
@@ -1,10502 +0,0 @@
-/*
- * Catch v1.5.1
- * Generated: 2016-04-28 08:12:37.387488
- * ----------------------------------------------------------
- * This file has been merged from multiple headers. Please don't edit it directly
- * Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.
- *
- * Distributed under the Boost Software License, Version 1.0. (See accompanying
- * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
- */
-#ifndef TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED
-#define TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED
-
-#define TWOBLUECUBES_CATCH_HPP_INCLUDED
-
-#ifdef __clang__
-# pragma clang system_header
-#elif defined __GNUC__
-# pragma GCC system_header
-#endif
-
-// #included from: internal/catch_suppress_warnings.h
-
-#ifdef __clang__
-# ifdef __ICC // icpc defines the __clang__ macro
-# pragma warning(push)
-# pragma warning(disable: 161 1682)
-# else // __ICC
-# pragma clang diagnostic ignored "-Wglobal-constructors"
-# pragma clang diagnostic ignored "-Wvariadic-macros"
-# pragma clang diagnostic ignored "-Wc99-extensions"
-# pragma clang diagnostic ignored "-Wunused-variable"
-# pragma clang diagnostic push
-# pragma clang diagnostic ignored "-Wpadded"
-# pragma clang diagnostic ignored "-Wc++98-compat"
-# pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
-# pragma clang diagnostic ignored "-Wswitch-enum"
-# pragma clang diagnostic ignored "-Wcovered-switch-default"
-# endif
-#elif defined __GNUC__
-# pragma GCC diagnostic ignored "-Wvariadic-macros"
-# pragma GCC diagnostic ignored "-Wunused-variable"
-# pragma GCC diagnostic push
-# pragma GCC diagnostic ignored "-Wpadded"
-#endif
-#if defined(CATCH_CONFIG_MAIN) || defined(CATCH_CONFIG_RUNNER)
-# define CATCH_IMPL
-#endif
-
-#ifdef CATCH_IMPL
-# ifndef CLARA_CONFIG_MAIN
-# define CLARA_CONFIG_MAIN_NOT_DEFINED
-# define CLARA_CONFIG_MAIN
-# endif
-#endif
-
-// #included from: internal/catch_notimplemented_exception.h
-#define TWOBLUECUBES_CATCH_NOTIMPLEMENTED_EXCEPTION_H_INCLUDED
-
-// #included from: catch_common.h
-#define TWOBLUECUBES_CATCH_COMMON_H_INCLUDED
-
-#define INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) name##line
-#define INTERNAL_CATCH_UNIQUE_NAME_LINE( name, line ) INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line )
-#ifdef CATCH_CONFIG_COUNTER
-# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __COUNTER__ )
-#else
-# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __LINE__ )
-#endif
-
-#define INTERNAL_CATCH_STRINGIFY2( expr ) #expr
-#define INTERNAL_CATCH_STRINGIFY( expr ) INTERNAL_CATCH_STRINGIFY2( expr )
-
-#include <sstream>
-#include <stdexcept>
-#include <algorithm>
-
-// stack
-#ifdef HAVE_EXECINFO
-#include <execinfo.h>
-#endif // HAVE_EXECINFO
-// stack
-
-// #included from: catch_compiler_capabilities.h
-#define TWOBLUECUBES_CATCH_COMPILER_CAPABILITIES_HPP_INCLUDED
-
-// Detect a number of compiler features - mostly C++11/14 conformance - by compiler
-// The following features are defined:
-//
-// CATCH_CONFIG_CPP11_NULLPTR : is nullptr supported?
-// CATCH_CONFIG_CPP11_NOEXCEPT : is noexcept supported?
-// CATCH_CONFIG_CPP11_GENERATED_METHODS : The delete and default keywords for compiler generated methods
-// CATCH_CONFIG_CPP11_IS_ENUM : std::is_enum is supported?
-// CATCH_CONFIG_CPP11_TUPLE : std::tuple is supported
-// CATCH_CONFIG_CPP11_LONG_LONG : is long long supported?
-// CATCH_CONFIG_CPP11_OVERRIDE : is override supported?
-// CATCH_CONFIG_CPP11_UNIQUE_PTR : is unique_ptr supported (otherwise use auto_ptr)
-
-// CATCH_CONFIG_CPP11_OR_GREATER : Is C++11 supported?
-
-// CATCH_CONFIG_VARIADIC_MACROS : are variadic macros supported?
-// CATCH_CONFIG_COUNTER : is the __COUNTER__ macro supported?
-// ****************
-// Note to maintainers: if new toggles are added please document them
-// in configuration.md, too
-// ****************
-
-// In general each macro has a _NO_<feature name> form
-// (e.g. CATCH_CONFIG_CPP11_NO_NULLPTR) which disables the feature.
-// Many features, at point of detection, define an _INTERNAL_ macro, so they
-// can be combined, en-mass, with the _NO_ forms later.
-
-// All the C++11 features can be disabled with CATCH_CONFIG_NO_CPP11
-
-#if defined(__cplusplus) && __cplusplus >= 201103L
-# define CATCH_CPP11_OR_GREATER
-#endif
-
-#ifdef __clang__
-
-# if __has_feature(cxx_nullptr)
-# define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR
-# endif
-
-# if __has_feature(cxx_noexcept)
-# define CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT
-# endif
-
-# if defined(CATCH_CPP11_OR_GREATER)
-# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS _Pragma( "clang diagnostic ignored \"-Wparentheses\"" )
-# endif
-
-#endif // __clang__
-
-////////////////////////////////////////////////////////////////////////////////
-// Borland
-#ifdef __BORLANDC__
-
-#endif // __BORLANDC__
-
-////////////////////////////////////////////////////////////////////////////////
-// EDG
-#ifdef __EDG_VERSION__
-
-#endif // __EDG_VERSION__
-
-////////////////////////////////////////////////////////////////////////////////
-// Digital Mars
-#ifdef __DMC__
-
-#endif // __DMC__
-
-////////////////////////////////////////////////////////////////////////////////
-// GCC
-#ifdef __GNUC__
-
-# if __GNUC__ == 4 && __GNUC_MINOR__ >= 6 && defined(__GXX_EXPERIMENTAL_CXX0X__)
-# define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR
-# endif
-
-# if !defined(CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS) && defined(CATCH_CPP11_OR_GREATER)
-# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS _Pragma( "GCC diagnostic ignored \"-Wparentheses\"" )
-# endif
-
-// - otherwise more recent versions define __cplusplus >= 201103L
-// and will get picked up below
-
-#endif // __GNUC__
-
-////////////////////////////////////////////////////////////////////////////////
-// Visual C++
-#ifdef _MSC_VER
-
-#if (_MSC_VER >= 1600)
-# define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR
-# define CATCH_INTERNAL_CONFIG_CPP11_UNIQUE_PTR
-#endif
-
-#if (_MSC_VER >= 1900 ) // (VC++ 13 (VS2015))
-#define CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT
-#define CATCH_INTERNAL_CONFIG_CPP11_GENERATED_METHODS
-#endif
-
-#endif // _MSC_VER
-
-////////////////////////////////////////////////////////////////////////////////
-
-// Use variadic macros if the compiler supports them
-#if ( defined _MSC_VER && _MSC_VER > 1400 && !defined __EDGE__) || \
- ( defined __WAVE__ && __WAVE_HAS_VARIADICS ) || \
- ( defined __GNUC__ && __GNUC__ >= 3 ) || \
- ( !defined __cplusplus && __STDC_VERSION__ >= 199901L || __cplusplus >= 201103L )
-
-#define CATCH_INTERNAL_CONFIG_VARIADIC_MACROS
-
-#endif
-
-// Use __COUNTER__ if the compiler supports it
-#if ( defined _MSC_VER && _MSC_VER >= 1300 ) || \
- ( defined __GNUC__ && __GNUC__ >= 4 && __GNUC_MINOR__ >= 3 ) || \
- ( defined __clang__ && __clang_major__ >= 3 )
-
-#define CATCH_INTERNAL_CONFIG_COUNTER
-
-#endif
-
-////////////////////////////////////////////////////////////////////////////////
-// C++ language feature support
-
-// catch all support for C++11
-#if defined(CATCH_CPP11_OR_GREATER)
-
-# if !defined(CATCH_INTERNAL_CONFIG_CPP11_NULLPTR)
-# define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR
-# endif
-
-# ifndef CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT
-# define CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT
-# endif
-
-# ifndef CATCH_INTERNAL_CONFIG_CPP11_GENERATED_METHODS
-# define CATCH_INTERNAL_CONFIG_CPP11_GENERATED_METHODS
-# endif
-
-# ifndef CATCH_INTERNAL_CONFIG_CPP11_IS_ENUM
-# define CATCH_INTERNAL_CONFIG_CPP11_IS_ENUM
-# endif
-
-# ifndef CATCH_INTERNAL_CONFIG_CPP11_TUPLE
-# define CATCH_INTERNAL_CONFIG_CPP11_TUPLE
-# endif
-
-# ifndef CATCH_INTERNAL_CONFIG_VARIADIC_MACROS
-# define CATCH_INTERNAL_CONFIG_VARIADIC_MACROS
-# endif
-
-# if !defined(CATCH_INTERNAL_CONFIG_CPP11_LONG_LONG)
-# define CATCH_INTERNAL_CONFIG_CPP11_LONG_LONG
-# endif
-
-# if !defined(CATCH_INTERNAL_CONFIG_CPP11_OVERRIDE)
-# define CATCH_INTERNAL_CONFIG_CPP11_OVERRIDE
-# endif
-# if !defined(CATCH_INTERNAL_CONFIG_CPP11_UNIQUE_PTR)
-# define CATCH_INTERNAL_CONFIG_CPP11_UNIQUE_PTR
-# endif
-
-#endif // __cplusplus >= 201103L
-
-// Now set the actual defines based on the above + anything the user has configured
-#if defined(CATCH_INTERNAL_CONFIG_CPP11_NULLPTR) && !defined(CATCH_CONFIG_CPP11_NO_NULLPTR) && !defined(CATCH_CONFIG_CPP11_NULLPTR) && !defined(CATCH_CONFIG_NO_CPP11)
-# define CATCH_CONFIG_CPP11_NULLPTR
-#endif
-#if defined(CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT) && !defined(CATCH_CONFIG_CPP11_NO_NOEXCEPT) && !defined(CATCH_CONFIG_CPP11_NOEXCEPT) && !defined(CATCH_CONFIG_NO_CPP11)
-# define CATCH_CONFIG_CPP11_NOEXCEPT
-#endif
-#if defined(CATCH_INTERNAL_CONFIG_CPP11_GENERATED_METHODS) && !defined(CATCH_CONFIG_CPP11_NO_GENERATED_METHODS) && !defined(CATCH_CONFIG_CPP11_GENERATED_METHODS) && !defined(CATCH_CONFIG_NO_CPP11)
-# define CATCH_CONFIG_CPP11_GENERATED_METHODS
-#endif
-#if defined(CATCH_INTERNAL_CONFIG_CPP11_IS_ENUM) && !defined(CATCH_CONFIG_CPP11_NO_IS_ENUM) && !defined(CATCH_CONFIG_CPP11_IS_ENUM) && !defined(CATCH_CONFIG_NO_CPP11)
-# define CATCH_CONFIG_CPP11_IS_ENUM
-#endif
-#if defined(CATCH_INTERNAL_CONFIG_CPP11_TUPLE) && !defined(CATCH_CONFIG_CPP11_NO_TUPLE) && !defined(CATCH_CONFIG_CPP11_TUPLE) && !defined(CATCH_CONFIG_NO_CPP11)
-# define CATCH_CONFIG_CPP11_TUPLE
-#endif
-#if defined(CATCH_INTERNAL_CONFIG_VARIADIC_MACROS) && !defined(CATCH_CONFIG_NO_VARIADIC_MACROS) && !defined(CATCH_CONFIG_VARIADIC_MACROS)
-# define CATCH_CONFIG_VARIADIC_MACROS
-#endif
-#if defined(CATCH_INTERNAL_CONFIG_CPP11_LONG_LONG) && !defined(CATCH_CONFIG_NO_LONG_LONG) && !defined(CATCH_CONFIG_CPP11_LONG_LONG) && !defined(CATCH_CONFIG_NO_CPP11)
-# define CATCH_CONFIG_CPP11_LONG_LONG
-#endif
-#if defined(CATCH_INTERNAL_CONFIG_CPP11_OVERRIDE) && !defined(CATCH_CONFIG_NO_OVERRIDE) && !defined(CATCH_CONFIG_CPP11_OVERRIDE) && !defined(CATCH_CONFIG_NO_CPP11)
-# define CATCH_CONFIG_CPP11_OVERRIDE
-#endif
-#if defined(CATCH_INTERNAL_CONFIG_CPP11_UNIQUE_PTR) && !defined(CATCH_CONFIG_NO_UNIQUE_PTR) && !defined(CATCH_CONFIG_CPP11_UNIQUE_PTR) && !defined(CATCH_CONFIG_NO_CPP11)
-# define CATCH_CONFIG_CPP11_UNIQUE_PTR
-#endif
-#if defined(CATCH_INTERNAL_CONFIG_COUNTER) && !defined(CATCH_CONFIG_NO_COUNTER) && !defined(CATCH_CONFIG_COUNTER)
-# define CATCH_CONFIG_COUNTER
-#endif
-
-#if !defined(CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS)
-# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS
-#endif
-
-// noexcept support:
-#if defined(CATCH_CONFIG_CPP11_NOEXCEPT) && !defined(CATCH_NOEXCEPT)
-# define CATCH_NOEXCEPT noexcept
-# define CATCH_NOEXCEPT_IS(x) noexcept(x)
-#else
-# define CATCH_NOEXCEPT throw()
-# define CATCH_NOEXCEPT_IS(x)
-#endif
-
-// nullptr support
-#ifdef CATCH_CONFIG_CPP11_NULLPTR
-# define CATCH_NULL nullptr
-#else
-# define CATCH_NULL NULL
-#endif
-
-// override support
-#ifdef CATCH_CONFIG_CPP11_OVERRIDE
-# define CATCH_OVERRIDE override
-#else
-# define CATCH_OVERRIDE
-#endif
-
-// unique_ptr support
-#ifdef CATCH_CONFIG_CPP11_UNIQUE_PTR
-# define CATCH_AUTO_PTR( T ) std::unique_ptr<T>
-#else
-# define CATCH_AUTO_PTR( T ) std::auto_ptr<T>
-#endif
-
-namespace Catch {
-
- struct IConfig;
-
- struct CaseSensitive { enum Choice {
- Yes,
- No
- }; };
-
- class NonCopyable {
-#ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS
- NonCopyable( NonCopyable const& ) = delete;
- NonCopyable( NonCopyable && ) = delete;
- NonCopyable& operator = ( NonCopyable const& ) = delete;
- NonCopyable& operator = ( NonCopyable && ) = delete;
-#else
- NonCopyable( NonCopyable const& info );
- NonCopyable& operator = ( NonCopyable const& );
-#endif
-
- protected:
- NonCopyable() {}
- virtual ~NonCopyable();
- };
-
- class SafeBool {
- public:
- typedef void (SafeBool::*type)() const;
-
- static type makeSafe( bool value ) {
- return value ? &SafeBool::trueValue : 0;
- }
- private:
- void trueValue() const {}
- };
-
- template<typename ContainerT>
- inline void deleteAll( ContainerT& container ) {
- typename ContainerT::const_iterator it = container.begin();
- typename ContainerT::const_iterator itEnd = container.end();
- for(; it != itEnd; ++it )
- delete *it;
- }
- template<typename AssociativeContainerT>
- inline void deleteAllValues( AssociativeContainerT& container ) {
- typename AssociativeContainerT::const_iterator it = container.begin();
- typename AssociativeContainerT::const_iterator itEnd = container.end();
- for(; it != itEnd; ++it )
- delete it->second;
- }
-
- bool startsWith( std::string const& s, std::string const& prefix );
- bool endsWith( std::string const& s, std::string const& suffix );
- bool contains( std::string const& s, std::string const& infix );
- void toLowerInPlace( std::string& s );
- std::string toLower( std::string const& s );
- std::string trim( std::string const& str );
- bool replaceInPlace( std::string& str, std::string const& replaceThis, std::string const& withThis );
-
- struct pluralise {
- pluralise( std::size_t count, std::string const& label );
-
- friend std::ostream& operator << ( std::ostream& os, pluralise const& pluraliser );
-
- std::size_t m_count;
- std::string m_label;
- };
-
- struct SourceLineInfo {
-
- SourceLineInfo();
- SourceLineInfo( char const* _file, std::size_t _line );
- SourceLineInfo( SourceLineInfo const& other );
-# ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS
- SourceLineInfo( SourceLineInfo && ) = default;
- SourceLineInfo& operator = ( SourceLineInfo const& ) = default;
- SourceLineInfo& operator = ( SourceLineInfo && ) = default;
-# endif
- bool empty() const;
- bool operator == ( SourceLineInfo const& other ) const;
- bool operator < ( SourceLineInfo const& other ) const;
-
- std::string file;
- std::size_t line;
- };
-
- std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info );
-
- // This is just here to avoid compiler warnings with macro constants and boolean literals
- inline bool isTrue( bool value ){ return value; }
- inline bool alwaysTrue() { return true; }
- inline bool alwaysFalse() { return false; }
-
- void throwLogicError( std::string const& message, SourceLineInfo const& locationInfo );
-
- void seedRng( IConfig const& config );
- unsigned int rngSeed();
-
- // Use this in variadic streaming macros to allow
- // >> +StreamEndStop
- // as well as
- // >> stuff +StreamEndStop
- struct StreamEndStop {
- std::string operator+() {
- return std::string();
- }
- };
- template<typename T>
- T const& operator + ( T const& value, StreamEndStop ) {
- return value;
- }
-}
-
-#define CATCH_INTERNAL_LINEINFO ::Catch::SourceLineInfo( __FILE__, static_cast<std::size_t>( __LINE__ ) )
-#define CATCH_INTERNAL_ERROR( msg ) ::Catch::throwLogicError( msg, CATCH_INTERNAL_LINEINFO );
-
-#include <ostream>
-
-namespace Catch {
-
- class NotImplementedException : public std::exception
- {
- public:
- NotImplementedException( SourceLineInfo const& lineInfo );
- NotImplementedException( NotImplementedException const& ) {}
-
- virtual ~NotImplementedException() CATCH_NOEXCEPT {}
-
- virtual const char* what() const CATCH_NOEXCEPT;
-
- private:
- std::string m_what;
- SourceLineInfo m_lineInfo;
- };
-
-} // end namespace Catch
-
-///////////////////////////////////////////////////////////////////////////////
-#define CATCH_NOT_IMPLEMENTED throw Catch::NotImplementedException( CATCH_INTERNAL_LINEINFO )
-
-// #included from: internal/catch_context.h
-#define TWOBLUECUBES_CATCH_CONTEXT_H_INCLUDED
-
-// #included from: catch_interfaces_generators.h
-#define TWOBLUECUBES_CATCH_INTERFACES_GENERATORS_H_INCLUDED
-
-#include <string>
-
-namespace Catch {
-
- struct IGeneratorInfo {
- virtual ~IGeneratorInfo();
- virtual bool moveNext() = 0;
- virtual std::size_t getCurrentIndex() const = 0;
- };
-
- struct IGeneratorsForTest {
- virtual ~IGeneratorsForTest();
-
- virtual IGeneratorInfo& getGeneratorInfo( std::string const& fileInfo, std::size_t size ) = 0;
- virtual bool moveNext() = 0;
- };
-
- IGeneratorsForTest* createGeneratorsForTest();
-
-} // end namespace Catch
-
-// #included from: catch_ptr.hpp
-#define TWOBLUECUBES_CATCH_PTR_HPP_INCLUDED
-
-#ifdef __clang__
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wpadded"
-#endif
-
-namespace Catch {
-
- // An intrusive reference counting smart pointer.
- // T must implement addRef() and release() methods
- // typically implementing the IShared interface
- template<typename T>
- class Ptr {
- public:
- Ptr() : m_p( CATCH_NULL ){}
- Ptr( T* p ) : m_p( p ){
- if( m_p )
- m_p->addRef();
- }
- Ptr( Ptr const& other ) : m_p( other.m_p ){
- if( m_p )
- m_p->addRef();
- }
- ~Ptr(){
- if( m_p )
- m_p->release();
- }
- void reset() {
- if( m_p )
- m_p->release();
- m_p = CATCH_NULL;
- }
- Ptr& operator = ( T* p ){
- Ptr temp( p );
- swap( temp );
- return *this;
- }
- Ptr& operator = ( Ptr const& other ){
- Ptr temp( other );
- swap( temp );
- return *this;
- }
- void swap( Ptr& other ) { std::swap( m_p, other.m_p ); }
- T* get() const{ return m_p; }
- T& operator*() const { return *m_p; }
- T* operator->() const { return m_p; }
- bool operator !() const { return m_p == CATCH_NULL; }
- operator SafeBool::type() const { return SafeBool::makeSafe( m_p != CATCH_NULL ); }
-
- private:
- T* m_p;
- };
-
- struct IShared : NonCopyable {
- virtual ~IShared();
- virtual void addRef() const = 0;
- virtual void release() const = 0;
- };
-
- template<typename T = IShared>
- struct SharedImpl : T {
-
- SharedImpl() : m_rc( 0 ){}
-
- virtual void addRef() const {
- ++m_rc;
- }
- virtual void release() const {
- if( --m_rc == 0 )
- delete this;
- }
-
- mutable unsigned int m_rc;
- };
-
-} // end namespace Catch
-
-#ifdef __clang__
-#pragma clang diagnostic pop
-#endif
-
-#include <memory>
-#include <vector>
-#include <stdlib.h>
-
-namespace Catch {
-
- class TestCase;
- class Stream;
- struct IResultCapture;
- struct IRunner;
- struct IGeneratorsForTest;
- struct IConfig;
-
- struct IContext
- {
- virtual ~IContext();
-
- virtual IResultCapture* getResultCapture() = 0;
- virtual IRunner* getRunner() = 0;
- virtual size_t getGeneratorIndex( std::string const& fileInfo, size_t totalSize ) = 0;
- virtual bool advanceGeneratorsForCurrentTest() = 0;
- virtual Ptr<IConfig const> getConfig() const = 0;
- };
-
- struct IMutableContext : IContext
- {
- virtual ~IMutableContext();
- virtual void setResultCapture( IResultCapture* resultCapture ) = 0;
- virtual void setRunner( IRunner* runner ) = 0;
- virtual void setConfig( Ptr<IConfig const> const& config ) = 0;
- };
-
- IContext& getCurrentContext();
- IMutableContext& getCurrentMutableContext();
- void cleanUpContext();
- Stream createStream( std::string const& streamName );
-
-}
-
-// #included from: internal/catch_test_registry.hpp
-#define TWOBLUECUBES_CATCH_TEST_REGISTRY_HPP_INCLUDED
-
-// #included from: catch_interfaces_testcase.h
-#define TWOBLUECUBES_CATCH_INTERFACES_TESTCASE_H_INCLUDED
-
-#include <vector>
-
-namespace Catch {
-
- class TestSpec;
-
- struct ITestCase : IShared {
- virtual void invoke () const = 0;
- protected:
- virtual ~ITestCase();
- };
-
- class TestCase;
- struct IConfig;
-
- struct ITestCaseRegistry {
- virtual ~ITestCaseRegistry();
- virtual std::vector<TestCase> const& getAllTests() const = 0;
- virtual std::vector<TestCase> const& getAllTestsSorted( IConfig const& config ) const = 0;
- };
-
- bool matchTest( TestCase const& testCase, TestSpec const& testSpec, IConfig const& config );
- std::vector<TestCase> filterTests( std::vector<TestCase> const& testCases, TestSpec const& testSpec, IConfig const& config );
- std::vector<TestCase> const& getAllTestCasesSorted( IConfig const& config );
-
-}
-
-namespace Catch {
-
-template<typename C>
-class MethodTestCase : public SharedImpl<ITestCase> {
-
-public:
- MethodTestCase( void (C::*method)() ) : m_method( method ) {}
-
- virtual void invoke() const {
- C obj;
- (obj.*m_method)();
- }
-
-private:
- virtual ~MethodTestCase() {}
-
- void (C::*m_method)();
-};
-
-typedef void(*TestFunction)();
-
-struct NameAndDesc {
- NameAndDesc( const char* _name = "", const char* _description= "" )
- : name( _name ), description( _description )
- {}
-
- const char* name;
- const char* description;
-};
-
-void registerTestCase
- ( ITestCase* testCase,
- char const* className,
- NameAndDesc const& nameAndDesc,
- SourceLineInfo const& lineInfo );
-
-struct AutoReg {
-
- AutoReg
- ( TestFunction function,
- SourceLineInfo const& lineInfo,
- NameAndDesc const& nameAndDesc );
-
- template<typename C>
- AutoReg
- ( void (C::*method)(),
- char const* className,
- NameAndDesc const& nameAndDesc,
- SourceLineInfo const& lineInfo ) {
-
- registerTestCase
- ( new MethodTestCase<C>( method ),
- className,
- nameAndDesc,
- lineInfo );
- }
-
- ~AutoReg();
-
-private:
- AutoReg( AutoReg const& );
- void operator= ( AutoReg const& );
-};
-
-void registerTestCaseFunction
- ( TestFunction function,
- SourceLineInfo const& lineInfo,
- NameAndDesc const& nameAndDesc );
-
-} // end namespace Catch
-
-#ifdef CATCH_CONFIG_VARIADIC_MACROS
- ///////////////////////////////////////////////////////////////////////////////
- #define INTERNAL_CATCH_TESTCASE2( TestName, ... ) \
- static void TestName(); \
- namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &TestName, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( __VA_ARGS__ ) ); }\
- static void TestName()
- #define INTERNAL_CATCH_TESTCASE( ... ) \
- INTERNAL_CATCH_TESTCASE2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), __VA_ARGS__ )
-
- ///////////////////////////////////////////////////////////////////////////////
- #define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, ... ) \
- namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &QualifiedMethod, "&" #QualifiedMethod, Catch::NameAndDesc( __VA_ARGS__ ), CATCH_INTERNAL_LINEINFO ); }
-
- ///////////////////////////////////////////////////////////////////////////////
- #define INTERNAL_CATCH_TEST_CASE_METHOD2( TestName, ClassName, ... )\
- namespace{ \
- struct TestName : ClassName{ \
- void test(); \
- }; \
- Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( &TestName::test, #ClassName, Catch::NameAndDesc( __VA_ARGS__ ), CATCH_INTERNAL_LINEINFO ); \
- } \
- void TestName::test()
- #define INTERNAL_CATCH_TEST_CASE_METHOD( ClassName, ... ) \
- INTERNAL_CATCH_TEST_CASE_METHOD2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), ClassName, __VA_ARGS__ )
-
- ///////////////////////////////////////////////////////////////////////////////
- #define INTERNAL_CATCH_REGISTER_TESTCASE( Function, ... ) \
- Catch::AutoReg( Function, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( __VA_ARGS__ ) );
-
-#else
- ///////////////////////////////////////////////////////////////////////////////
- #define INTERNAL_CATCH_TESTCASE2( TestName, Name, Desc ) \
- static void TestName(); \
- namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &TestName, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( Name, Desc ) ); }\
- static void TestName()
- #define INTERNAL_CATCH_TESTCASE( Name, Desc ) \
- INTERNAL_CATCH_TESTCASE2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), Name, Desc )
-
- ///////////////////////////////////////////////////////////////////////////////
- #define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, Name, Desc ) \
- namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &QualifiedMethod, "&" #QualifiedMethod, Catch::NameAndDesc( Name, Desc ), CATCH_INTERNAL_LINEINFO ); }
-
- ///////////////////////////////////////////////////////////////////////////////
- #define INTERNAL_CATCH_TEST_CASE_METHOD2( TestCaseName, ClassName, TestName, Desc )\
- namespace{ \
- struct TestCaseName : ClassName{ \
- void test(); \
- }; \
- Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( &TestCaseName::test, #ClassName, Catch::NameAndDesc( TestName, Desc ), CATCH_INTERNAL_LINEINFO ); \
- } \
- void TestCaseName::test()
- #define INTERNAL_CATCH_TEST_CASE_METHOD( ClassName, TestName, Desc )\
- INTERNAL_CATCH_TEST_CASE_METHOD2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), ClassName, TestName, Desc )
-
- ///////////////////////////////////////////////////////////////////////////////
- #define INTERNAL_CATCH_REGISTER_TESTCASE( Function, Name, Desc ) \
- Catch::AutoReg( Function, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( Name, Desc ) );
-#endif
-
-// #included from: internal/catch_capture.hpp
-#define TWOBLUECUBES_CATCH_CAPTURE_HPP_INCLUDED
-
-// #included from: catch_result_builder.h
-#define TWOBLUECUBES_CATCH_RESULT_BUILDER_H_INCLUDED
-
-// #included from: catch_result_type.h
-#define TWOBLUECUBES_CATCH_RESULT_TYPE_H_INCLUDED
-
-namespace Catch {
-
- // ResultWas::OfType enum
- struct ResultWas { enum OfType {
- Unknown = -1,
- Ok = 0,
- Info = 1,
- Warning = 2,
-
- FailureBit = 0x10,
-
- ExpressionFailed = FailureBit | 1,
- ExplicitFailure = FailureBit | 2,
-
- Exception = 0x100 | FailureBit,
-
- ThrewException = Exception | 1,
- DidntThrowException = Exception | 2,
-
- FatalErrorCondition = 0x200 | FailureBit
-
- }; };
-
- inline bool isOk( ResultWas::OfType resultType ) {
- return ( resultType & ResultWas::FailureBit ) == 0;
- }
- inline bool isJustInfo( int flags ) {
- return flags == ResultWas::Info;
- }
-
- // ResultDisposition::Flags enum
- struct ResultDisposition { enum Flags {
- Normal = 0x01,
-
- ContinueOnFailure = 0x02, // Failures fail test, but execution continues
- FalseTest = 0x04, // Prefix expression with !
- SuppressFail = 0x08 // Failures are reported but do not fail the test
- }; };
-
- inline ResultDisposition::Flags operator | ( ResultDisposition::Flags lhs, ResultDisposition::Flags rhs ) {
- return static_cast<ResultDisposition::Flags>( static_cast<int>( lhs ) | static_cast<int>( rhs ) );
- }
-
- inline bool shouldContinueOnFailure( int flags ) { return ( flags & ResultDisposition::ContinueOnFailure ) != 0; }
- inline bool isFalseTest( int flags ) { return ( flags & ResultDisposition::FalseTest ) != 0; }
- inline bool shouldSuppressFailure( int flags ) { return ( flags & ResultDisposition::SuppressFail ) != 0; }
-
-} // end namespace Catch
-
-// #included from: catch_assertionresult.h
-#define TWOBLUECUBES_CATCH_ASSERTIONRESULT_H_INCLUDED
-
-#include <string>
-
-namespace Catch {
-
- struct AssertionInfo
- {
- AssertionInfo() {}
- AssertionInfo( std::string const& _macroName,
- SourceLineInfo const& _lineInfo,
- std::string const& _capturedExpression,
- ResultDisposition::Flags _resultDisposition );
-
- std::string macroName;
- SourceLineInfo lineInfo;
- std::string capturedExpression;
- ResultDisposition::Flags resultDisposition;
- };
-
- struct AssertionResultData
- {
- AssertionResultData() : resultType( ResultWas::Unknown ) {}
-
- std::string reconstructedExpression;
- std::string message;
- ResultWas::OfType resultType;
- };
-
- class AssertionResult {
- public:
- AssertionResult();
- AssertionResult( AssertionInfo const& info, AssertionResultData const& data );
- ~AssertionResult();
-# ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS
- AssertionResult( AssertionResult const& ) = default;
- AssertionResult( AssertionResult && ) = default;
- AssertionResult& operator = ( AssertionResult const& ) = default;
- AssertionResult& operator = ( AssertionResult && ) = default;
-# endif
-
- bool isOk() const;
- bool succeeded() const;
- ResultWas::OfType getResultType() const;
- bool hasExpression() const;
- bool hasMessage() const;
- std::string getExpression() const;
- std::string getExpressionInMacro() const;
- bool hasExpandedExpression() const;
- std::string getExpandedExpression() const;
- std::string getMessage() const;
- SourceLineInfo getSourceInfo() const;
- std::string getTestMacroName() const;
-
- protected:
- AssertionInfo m_info;
- AssertionResultData m_resultData;
- };
-
-} // end namespace Catch
-
-// #included from: catch_matchers.hpp
-#define TWOBLUECUBES_CATCH_MATCHERS_HPP_INCLUDED
-
-namespace Catch {
-namespace Matchers {
- namespace Impl {
-
- namespace Generic {
- template<typename ExpressionT> class AllOf;
- template<typename ExpressionT> class AnyOf;
- template<typename ExpressionT> class Not;
- }
-
- template<typename ExpressionT>
- struct Matcher : SharedImpl<IShared>
- {
- typedef ExpressionT ExpressionType;
-
- virtual ~Matcher() {}
- virtual Ptr<Matcher> clone() const = 0;
- virtual bool match( ExpressionT const& expr ) const = 0;
- virtual std::string toString() const = 0;
-
- Generic::AllOf<ExpressionT> operator && ( Matcher<ExpressionT> const& other ) const;
- Generic::AnyOf<ExpressionT> operator || ( Matcher<ExpressionT> const& other ) const;
- Generic::Not<ExpressionT> operator ! () const;
- };
-
- template<typename DerivedT, typename ExpressionT>
- struct MatcherImpl : Matcher<ExpressionT> {
-
- virtual Ptr<Matcher<ExpressionT> > clone() const {
- return Ptr<Matcher<ExpressionT> >( new DerivedT( static_cast<DerivedT const&>( *this ) ) );
- }
- };
-
- namespace Generic {
- template<typename ExpressionT>
- class Not : public MatcherImpl<Not<ExpressionT>, ExpressionT> {
- public:
- explicit Not( Matcher<ExpressionT> const& matcher ) : m_matcher(matcher.clone()) {}
- Not( Not const& other ) : m_matcher( other.m_matcher ) {}
-
- virtual bool match( ExpressionT const& expr ) const CATCH_OVERRIDE {
- return !m_matcher->match( expr );
- }
-
- virtual std::string toString() const CATCH_OVERRIDE {
- return "not " + m_matcher->toString();
- }
- private:
- Ptr< Matcher<ExpressionT> > m_matcher;
- };
-
- template<typename ExpressionT>
- class AllOf : public MatcherImpl<AllOf<ExpressionT>, ExpressionT> {
- public:
-
- AllOf() {}
- AllOf( AllOf const& other ) : m_matchers( other.m_matchers ) {}
-
- AllOf& add( Matcher<ExpressionT> const& matcher ) {
- m_matchers.push_back( matcher.clone() );
- return *this;
- }
- virtual bool match( ExpressionT const& expr ) const
- {
- for( std::size_t i = 0; i < m_matchers.size(); ++i )
- if( !m_matchers[i]->match( expr ) )
- return false;
- return true;
- }
- virtual std::string toString() const {
- std::ostringstream oss;
- oss << "( ";
- for( std::size_t i = 0; i < m_matchers.size(); ++i ) {
- if( i != 0 )
- oss << " and ";
- oss << m_matchers[i]->toString();
- }
- oss << " )";
- return oss.str();
- }
-
- AllOf operator && ( Matcher<ExpressionT> const& other ) const {
- AllOf allOfExpr( *this );
- allOfExpr.add( other );
- return allOfExpr;
- }
-
- private:
- std::vector<Ptr<Matcher<ExpressionT> > > m_matchers;
- };
-
- template<typename ExpressionT>
- class AnyOf : public MatcherImpl<AnyOf<ExpressionT>, ExpressionT> {
- public:
-
- AnyOf() {}
- AnyOf( AnyOf const& other ) : m_matchers( other.m_matchers ) {}
-
- AnyOf& add( Matcher<ExpressionT> const& matcher ) {
- m_matchers.push_back( matcher.clone() );
- return *this;
- }
- virtual bool match( ExpressionT const& expr ) const
- {
- for( std::size_t i = 0; i < m_matchers.size(); ++i )
- if( m_matchers[i]->match( expr ) )
- return true;
- return false;
- }
- virtual std::string toString() const {
- std::ostringstream oss;
- oss << "( ";
- for( std::size_t i = 0; i < m_matchers.size(); ++i ) {
- if( i != 0 )
- oss << " or ";
- oss << m_matchers[i]->toString();
- }
- oss << " )";
- return oss.str();
- }
-
- AnyOf operator || ( Matcher<ExpressionT> const& other ) const {
- AnyOf anyOfExpr( *this );
- anyOfExpr.add( other );
- return anyOfExpr;
- }
-
- private:
- std::vector<Ptr<Matcher<ExpressionT> > > m_matchers;
- };
-
- } // namespace Generic
-
- template<typename ExpressionT>
- Generic::AllOf<ExpressionT> Matcher<ExpressionT>::operator && ( Matcher<ExpressionT> const& other ) const {
- Generic::AllOf<ExpressionT> allOfExpr;
- allOfExpr.add( *this );
- allOfExpr.add( other );
- return allOfExpr;
- }
-
- template<typename ExpressionT>
- Generic::AnyOf<ExpressionT> Matcher<ExpressionT>::operator || ( Matcher<ExpressionT> const& other ) const {
- Generic::AnyOf<ExpressionT> anyOfExpr;
- anyOfExpr.add( *this );
- anyOfExpr.add( other );
- return anyOfExpr;
- }
-
- template<typename ExpressionT>
- Generic::Not<ExpressionT> Matcher<ExpressionT>::operator ! () const {
- return Generic::Not<ExpressionT>( *this );
- }
-
- namespace StdString {
-
- inline std::string makeString( std::string const& str ) { return str; }
- inline std::string makeString( const char* str ) { return str ? std::string( str ) : std::string(); }
-
- struct CasedString
- {
- CasedString( std::string const& str, CaseSensitive::Choice caseSensitivity )
- : m_caseSensitivity( caseSensitivity ),
- m_str( adjustString( str ) )
- {}
- std::string adjustString( std::string const& str ) const {
- return m_caseSensitivity == CaseSensitive::No
- ? toLower( str )
- : str;
-
- }
- std::string toStringSuffix() const
- {
- return m_caseSensitivity == CaseSensitive::No
- ? " (case insensitive)"
- : "";
- }
- CaseSensitive::Choice m_caseSensitivity;
- std::string m_str;
- };
-
- struct Equals : MatcherImpl<Equals, std::string> {
- Equals( std::string const& str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes )
- : m_data( str, caseSensitivity )
- {}
- Equals( Equals const& other ) : m_data( other.m_data ){}
-
- virtual ~Equals();
-
- virtual bool match( std::string const& expr ) const {
- return m_data.m_str == m_data.adjustString( expr );;
- }
- virtual std::string toString() const {
- return "equals: \"" + m_data.m_str + "\"" + m_data.toStringSuffix();
- }
-
- CasedString m_data;
- };
-
- struct Contains : MatcherImpl<Contains, std::string> {
- Contains( std::string const& substr, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes )
- : m_data( substr, caseSensitivity ){}
- Contains( Contains const& other ) : m_data( other.m_data ){}
-
- virtual ~Contains();
-
- virtual bool match( std::string const& expr ) const {
- return m_data.adjustString( expr ).find( m_data.m_str ) != std::string::npos;
- }
- virtual std::string toString() const {
- return "contains: \"" + m_data.m_str + "\"" + m_data.toStringSuffix();
- }
-
- CasedString m_data;
- };
-
- struct StartsWith : MatcherImpl<StartsWith, std::string> {
- StartsWith( std::string const& substr, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes )
- : m_data( substr, caseSensitivity ){}
-
- StartsWith( StartsWith const& other ) : m_data( other.m_data ){}
-
- virtual ~StartsWith();
-
- virtual bool match( std::string const& expr ) const {
- return startsWith( m_data.adjustString( expr ), m_data.m_str );
- }
- virtual std::string toString() const {
- return "starts with: \"" + m_data.m_str + "\"" + m_data.toStringSuffix();
- }
-
- CasedString m_data;
- };
-
- struct EndsWith : MatcherImpl<EndsWith, std::string> {
- EndsWith( std::string const& substr, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes )
- : m_data( substr, caseSensitivity ){}
- EndsWith( EndsWith const& other ) : m_data( other.m_data ){}
-
- virtual ~EndsWith();
-
- virtual bool match( std::string const& expr ) const {
- return endsWith( m_data.adjustString( expr ), m_data.m_str );
- }
- virtual std::string toString() const {
- return "ends with: \"" + m_data.m_str + "\"" + m_data.toStringSuffix();
- }
-
- CasedString m_data;
- };
- } // namespace StdString
- } // namespace Impl
-
- // The following functions create the actual matcher objects.
- // This allows the types to be inferred
- template<typename ExpressionT>
- inline Impl::Generic::Not<ExpressionT> Not( Impl::Matcher<ExpressionT> const& m ) {
- return Impl::Generic::Not<ExpressionT>( m );
- }
-
- template<typename ExpressionT>
- inline Impl::Generic::AllOf<ExpressionT> AllOf( Impl::Matcher<ExpressionT> const& m1,
- Impl::Matcher<ExpressionT> const& m2 ) {
- return Impl::Generic::AllOf<ExpressionT>().add( m1 ).add( m2 );
- }
- template<typename ExpressionT>
- inline Impl::Generic::AllOf<ExpressionT> AllOf( Impl::Matcher<ExpressionT> const& m1,
- Impl::Matcher<ExpressionT> const& m2,
- Impl::Matcher<ExpressionT> const& m3 ) {
- return Impl::Generic::AllOf<ExpressionT>().add( m1 ).add( m2 ).add( m3 );
- }
- template<typename ExpressionT>
- inline Impl::Generic::AnyOf<ExpressionT> AnyOf( Impl::Matcher<ExpressionT> const& m1,
- Impl::Matcher<ExpressionT> const& m2 ) {
- return Impl::Generic::AnyOf<ExpressionT>().add( m1 ).add( m2 );
- }
- template<typename ExpressionT>
- inline Impl::Generic::AnyOf<ExpressionT> AnyOf( Impl::Matcher<ExpressionT> const& m1,
- Impl::Matcher<ExpressionT> const& m2,
- Impl::Matcher<ExpressionT> const& m3 ) {
- return Impl::Generic::AnyOf<ExpressionT>().add( m1 ).add( m2 ).add( m3 );
- }
-
- inline Impl::StdString::Equals Equals( std::string const& str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ) {
- return Impl::StdString::Equals( str, caseSensitivity );
- }
- inline Impl::StdString::Equals Equals( const char* str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ) {
- return Impl::StdString::Equals( Impl::StdString::makeString( str ), caseSensitivity );
- }
- inline Impl::StdString::Contains Contains( std::string const& substr, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ) {
- return Impl::StdString::Contains( substr, caseSensitivity );
- }
- inline Impl::StdString::Contains Contains( const char* substr, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ) {
- return Impl::StdString::Contains( Impl::StdString::makeString( substr ), caseSensitivity );
- }
- inline Impl::StdString::StartsWith StartsWith( std::string const& substr ) {
- return Impl::StdString::StartsWith( substr );
- }
- inline Impl::StdString::StartsWith StartsWith( const char* substr ) {
- return Impl::StdString::StartsWith( Impl::StdString::makeString( substr ) );
- }
- inline Impl::StdString::EndsWith EndsWith( std::string const& substr ) {
- return Impl::StdString::EndsWith( substr );
- }
- inline Impl::StdString::EndsWith EndsWith( const char* substr ) {
- return Impl::StdString::EndsWith( Impl::StdString::makeString( substr ) );
- }
-
-} // namespace Matchers
-
-using namespace Matchers;
-
-} // namespace Catch
-
-namespace Catch {
-
- struct TestFailureException{};
-
- template<typename T> class ExpressionLhs;
-
- struct STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison;
-
- struct CopyableStream {
- CopyableStream() {}
- CopyableStream( CopyableStream const& other ) {
- oss << other.oss.str();
- }
- CopyableStream& operator=( CopyableStream const& other ) {
- oss.str("");
- oss << other.oss.str();
- return *this;
- }
- std::ostringstream oss;
- };
-
- class ResultBuilder {
- public:
- ResultBuilder( char const* macroName,
- SourceLineInfo const& lineInfo,
- char const* capturedExpression,
- ResultDisposition::Flags resultDisposition,
- char const* secondArg = "" );
-
- template<typename T>
- ExpressionLhs<T const&> operator <= ( T const& operand );
- ExpressionLhs<bool> operator <= ( bool value );
-
- template<typename T>
- ResultBuilder& operator << ( T const& value ) {
- m_stream.oss << value;
- return *this;
- }
-
- template<typename RhsT> STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator && ( RhsT const& );
- template<typename RhsT> STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator || ( RhsT const& );
-
- ResultBuilder& setResultType( ResultWas::OfType result );
- ResultBuilder& setResultType( bool result );
- ResultBuilder& setLhs( std::string const& lhs );
- ResultBuilder& setRhs( std::string const& rhs );
- ResultBuilder& setOp( std::string const& op );
-
- void endExpression();
-
- std::string reconstructExpression() const;
- AssertionResult build() const;
-
- void useActiveException( ResultDisposition::Flags resultDisposition = ResultDisposition::Normal );
- void captureResult( ResultWas::OfType resultType );
- void captureExpression();
- void captureExpectedException( std::string const& expectedMessage );
- void captureExpectedException( Matchers::Impl::Matcher<std::string> const& matcher );
- void handleResult( AssertionResult const& result );
- void react();
- bool shouldDebugBreak() const;
- bool allowThrows() const;
-
- private:
- AssertionInfo m_assertionInfo;
- AssertionResultData m_data;
- struct ExprComponents {
- ExprComponents() : testFalse( false ) {}
- bool testFalse;
- std::string lhs, rhs, op;
- } m_exprComponents;
- CopyableStream m_stream;
-
- bool m_shouldDebugBreak;
- bool m_shouldThrow;
- };
-
-} // namespace Catch
-
-// Include after due to circular dependency:
-// #included from: catch_expression_lhs.hpp
-#define TWOBLUECUBES_CATCH_EXPRESSION_LHS_HPP_INCLUDED
-
-// #included from: catch_evaluate.hpp
-#define TWOBLUECUBES_CATCH_EVALUATE_HPP_INCLUDED
-
-#ifdef _MSC_VER
-#pragma warning(push)
-#pragma warning(disable:4389) // '==' : signed/unsigned mismatch
-#endif
-
-#include <cstddef>
-
-namespace Catch {
-namespace Internal {
-
- enum Operator {
- IsEqualTo,
- IsNotEqualTo,
- IsLessThan,
- IsGreaterThan,
- IsLessThanOrEqualTo,
- IsGreaterThanOrEqualTo
- };
-
- template<Operator Op> struct OperatorTraits { static const char* getName(){ return "*error*"; } };
- template<> struct OperatorTraits<IsEqualTo> { static const char* getName(){ return "=="; } };
- template<> struct OperatorTraits<IsNotEqualTo> { static const char* getName(){ return "!="; } };
- template<> struct OperatorTraits<IsLessThan> { static const char* getName(){ return "<"; } };
- template<> struct OperatorTraits<IsGreaterThan> { static const char* getName(){ return ">"; } };
- template<> struct OperatorTraits<IsLessThanOrEqualTo> { static const char* getName(){ return "<="; } };
- template<> struct OperatorTraits<IsGreaterThanOrEqualTo>{ static const char* getName(){ return ">="; } };
-
- template<typename T>
- inline T& opCast(T const& t) { return const_cast<T&>(t); }
-
-// nullptr_t support based on pull request #154 from Konstantin Baumann
-#ifdef CATCH_CONFIG_CPP11_NULLPTR
- inline std::nullptr_t opCast(std::nullptr_t) { return nullptr; }
-#endif // CATCH_CONFIG_CPP11_NULLPTR
-
- // So the compare overloads can be operator agnostic we convey the operator as a template
- // enum, which is used to specialise an Evaluator for doing the comparison.
- template<typename T1, typename T2, Operator Op>
- class Evaluator{};
-
- template<typename T1, typename T2>
- struct Evaluator<T1, T2, IsEqualTo> {
- static bool evaluate( T1 const& lhs, T2 const& rhs) {
- return bool( opCast( lhs ) == opCast( rhs ) );
- }
- };
- template<typename T1, typename T2>
- struct Evaluator<T1, T2, IsNotEqualTo> {
- static bool evaluate( T1 const& lhs, T2 const& rhs ) {
- return bool( opCast( lhs ) != opCast( rhs ) );
- }
- };
- template<typename T1, typename T2>
- struct Evaluator<T1, T2, IsLessThan> {
- static bool evaluate( T1 const& lhs, T2 const& rhs ) {
- return bool( opCast( lhs ) < opCast( rhs ) );
- }
- };
- template<typename T1, typename T2>
- struct Evaluator<T1, T2, IsGreaterThan> {
- static bool evaluate( T1 const& lhs, T2 const& rhs ) {
- return bool( opCast( lhs ) > opCast( rhs ) );
- }
- };
- template<typename T1, typename T2>
- struct Evaluator<T1, T2, IsGreaterThanOrEqualTo> {
- static bool evaluate( T1 const& lhs, T2 const& rhs ) {
- return bool( opCast( lhs ) >= opCast( rhs ) );
- }
- };
- template<typename T1, typename T2>
- struct Evaluator<T1, T2, IsLessThanOrEqualTo> {
- static bool evaluate( T1 const& lhs, T2 const& rhs ) {
- return bool( opCast( lhs ) <= opCast( rhs ) );
- }
- };
-
- template<Operator Op, typename T1, typename T2>
- bool applyEvaluator( T1 const& lhs, T2 const& rhs ) {
- return Evaluator<T1, T2, Op>::evaluate( lhs, rhs );
- }
-
- // This level of indirection allows us to specialise for integer types
- // to avoid signed/ unsigned warnings
-
- // "base" overload
- template<Operator Op, typename T1, typename T2>
- bool compare( T1 const& lhs, T2 const& rhs ) {
- return Evaluator<T1, T2, Op>::evaluate( lhs, rhs );
- }
-
- // unsigned X to int
- template<Operator Op> bool compare( unsigned int lhs, int rhs ) {
- return applyEvaluator<Op>( lhs, static_cast<unsigned int>( rhs ) );
- }
- template<Operator Op> bool compare( unsigned long lhs, int rhs ) {
- return applyEvaluator<Op>( lhs, static_cast<unsigned int>( rhs ) );
- }
- template<Operator Op> bool compare( unsigned char lhs, int rhs ) {
- return applyEvaluator<Op>( lhs, static_cast<unsigned int>( rhs ) );
- }
-
- // unsigned X to long
- template<Operator Op> bool compare( unsigned int lhs, long rhs ) {
- return applyEvaluator<Op>( lhs, static_cast<unsigned long>( rhs ) );
- }
- template<Operator Op> bool compare( unsigned long lhs, long rhs ) {
- return applyEvaluator<Op>( lhs, static_cast<unsigned long>( rhs ) );
- }
- template<Operator Op> bool compare( unsigned char lhs, long rhs ) {
- return applyEvaluator<Op>( lhs, static_cast<unsigned long>( rhs ) );
- }
-
- // int to unsigned X
- template<Operator Op> bool compare( int lhs, unsigned int rhs ) {
- return applyEvaluator<Op>( static_cast<unsigned int>( lhs ), rhs );
- }
- template<Operator Op> bool compare( int lhs, unsigned long rhs ) {
- return applyEvaluator<Op>( static_cast<unsigned int>( lhs ), rhs );
- }
- template<Operator Op> bool compare( int lhs, unsigned char rhs ) {
- return applyEvaluator<Op>( static_cast<unsigned int>( lhs ), rhs );
- }
-
- // long to unsigned X
- template<Operator Op> bool compare( long lhs, unsigned int rhs ) {
- return applyEvaluator<Op>( static_cast<unsigned long>( lhs ), rhs );
- }
- template<Operator Op> bool compare( long lhs, unsigned long rhs ) {
- return applyEvaluator<Op>( static_cast<unsigned long>( lhs ), rhs );
- }
- template<Operator Op> bool compare( long lhs, unsigned char rhs ) {
- return applyEvaluator<Op>( static_cast<unsigned long>( lhs ), rhs );
- }
-
- // pointer to long (when comparing against NULL)
- template<Operator Op, typename T> bool compare( long lhs, T* rhs ) {
- return Evaluator<T*, T*, Op>::evaluate( reinterpret_cast<T*>( lhs ), rhs );
- }
- template<Operator Op, typename T> bool compare( T* lhs, long rhs ) {
- return Evaluator<T*, T*, Op>::evaluate( lhs, reinterpret_cast<T*>( rhs ) );
- }
-
- // pointer to int (when comparing against NULL)
- template<Operator Op, typename T> bool compare( int lhs, T* rhs ) {
- return Evaluator<T*, T*, Op>::evaluate( reinterpret_cast<T*>( lhs ), rhs );
- }
- template<Operator Op, typename T> bool compare( T* lhs, int rhs ) {
- return Evaluator<T*, T*, Op>::evaluate( lhs, reinterpret_cast<T*>( rhs ) );
- }
-
-#ifdef CATCH_CONFIG_CPP11_LONG_LONG
- // long long to unsigned X
- template<Operator Op> bool compare( long long lhs, unsigned int rhs ) {
- return applyEvaluator<Op>( static_cast<unsigned long>( lhs ), rhs );
- }
- template<Operator Op> bool compare( long long lhs, unsigned long rhs ) {
- return applyEvaluator<Op>( static_cast<unsigned long>( lhs ), rhs );
- }
- template<Operator Op> bool compare( long long lhs, unsigned long long rhs ) {
- return applyEvaluator<Op>( static_cast<unsigned long>( lhs ), rhs );
- }
- template<Operator Op> bool compare( long long lhs, unsigned char rhs ) {
- return applyEvaluator<Op>( static_cast<unsigned long>( lhs ), rhs );
- }
-
- // unsigned long long to X
- template<Operator Op> bool compare( unsigned long long lhs, int rhs ) {
- return applyEvaluator<Op>( static_cast<long>( lhs ), rhs );
- }
- template<Operator Op> bool compare( unsigned long long lhs, long rhs ) {
- return applyEvaluator<Op>( static_cast<long>( lhs ), rhs );
- }
- template<Operator Op> bool compare( unsigned long long lhs, long long rhs ) {
- return applyEvaluator<Op>( static_cast<long>( lhs ), rhs );
- }
- template<Operator Op> bool compare( unsigned long long lhs, char rhs ) {
- return applyEvaluator<Op>( static_cast<long>( lhs ), rhs );
- }
-
- // pointer to long long (when comparing against NULL)
- template<Operator Op, typename T> bool compare( long long lhs, T* rhs ) {
- return Evaluator<T*, T*, Op>::evaluate( reinterpret_cast<T*>( lhs ), rhs );
- }
- template<Operator Op, typename T> bool compare( T* lhs, long long rhs ) {
- return Evaluator<T*, T*, Op>::evaluate( lhs, reinterpret_cast<T*>( rhs ) );
- }
-#endif // CATCH_CONFIG_CPP11_LONG_LONG
-
-#ifdef CATCH_CONFIG_CPP11_NULLPTR
- // pointer to nullptr_t (when comparing against nullptr)
- template<Operator Op, typename T> bool compare( std::nullptr_t, T* rhs ) {
- return Evaluator<T*, T*, Op>::evaluate( nullptr, rhs );
- }
- template<Operator Op, typename T> bool compare( T* lhs, std::nullptr_t ) {
- return Evaluator<T*, T*, Op>::evaluate( lhs, nullptr );
- }
-#endif // CATCH_CONFIG_CPP11_NULLPTR
-
-} // end of namespace Internal
-} // end of namespace Catch
-
-#ifdef _MSC_VER
-#pragma warning(pop)
-#endif
-
-// #included from: catch_tostring.h
-#define TWOBLUECUBES_CATCH_TOSTRING_H_INCLUDED
-
-#include <sstream>
-#include <iomanip>
-#include <limits>
-#include <vector>
-#include <cstddef>
-
-#ifdef __OBJC__
-// #included from: catch_objc_arc.hpp
-#define TWOBLUECUBES_CATCH_OBJC_ARC_HPP_INCLUDED
-
-#import <Foundation/Foundation.h>
-
-#ifdef __has_feature
-#define CATCH_ARC_ENABLED __has_feature(objc_arc)
-#else
-#define CATCH_ARC_ENABLED 0
-#endif
-
-void arcSafeRelease( NSObject* obj );
-id performOptionalSelector( id obj, SEL sel );
-
-#if !CATCH_ARC_ENABLED
-inline void arcSafeRelease( NSObject* obj ) {
- [obj release];
-}
-inline id performOptionalSelector( id obj, SEL sel ) {
- if( [obj respondsToSelector: sel] )
- return [obj performSelector: sel];
- return nil;
-}
-#define CATCH_UNSAFE_UNRETAINED
-#define CATCH_ARC_STRONG
-#else
-inline void arcSafeRelease( NSObject* ){}
-inline id performOptionalSelector( id obj, SEL sel ) {
-#ifdef __clang__
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
-#endif
- if( [obj respondsToSelector: sel] )
- return [obj performSelector: sel];
-#ifdef __clang__
-#pragma clang diagnostic pop
-#endif
- return nil;
-}
-#define CATCH_UNSAFE_UNRETAINED __unsafe_unretained
-#define CATCH_ARC_STRONG __strong
-#endif
-
-#endif
-
-#ifdef CATCH_CONFIG_CPP11_TUPLE
-#include <tuple>
-#endif
-
-#ifdef CATCH_CONFIG_CPP11_IS_ENUM
-#include <type_traits>
-#endif
-
-namespace Catch {
-
-// Why we're here.
-template<typename T>
-std::string toString( T const& value );
-
-// Built in overloads
-
-std::string toString( std::string const& value );
-std::string toString( std::wstring const& value );
-std::string toString( const char* const value );
-std::string toString( char* const value );
-std::string toString( const wchar_t* const value );
-std::string toString( wchar_t* const value );
-std::string toString( int value );
-std::string toString( unsigned long value );
-std::string toString( unsigned int value );
-std::string toString( const double value );
-std::string toString( const float value );
-std::string toString( bool value );
-std::string toString( char value );
-std::string toString( signed char value );
-std::string toString( unsigned char value );
-
-#ifdef CATCH_CONFIG_CPP11_LONG_LONG
-std::string toString( long long value );
-std::string toString( unsigned long long value );
-#endif
-
-#ifdef CATCH_CONFIG_CPP11_NULLPTR
-std::string toString( std::nullptr_t );
-#endif
-
-#ifdef __OBJC__
- std::string toString( NSString const * const& nsstring );
- std::string toString( NSString * CATCH_ARC_STRONG const& nsstring );
- std::string toString( NSObject* const& nsObject );
-#endif
-
-namespace Detail {
-
- extern const std::string unprintableString;
-
- struct BorgType {
- template<typename T> BorgType( T const& );
- };
-
- struct TrueType { char sizer[1]; };
- struct FalseType { char sizer[2]; };
-
- TrueType& testStreamable( std::ostream& );
- FalseType testStreamable( FalseType );
-
- FalseType operator<<( std::ostream const&, BorgType const& );
-
- template<typename T>
- struct IsStreamInsertable {
- static std::ostream &s;
- static T const&t;
- enum { value = sizeof( testStreamable(s << t) ) == sizeof( TrueType ) };
- };
-
-#if defined(CATCH_CONFIG_CPP11_IS_ENUM)
- template<typename T,
- bool IsEnum = std::is_enum<T>::value
- >
- struct EnumStringMaker
- {
- static std::string convert( T const& ) { return unprintableString; }
- };
-
- template<typename T>
- struct EnumStringMaker<T,true>
- {
- static std::string convert( T const& v )
- {
- return ::Catch::toString(
- static_cast<typename std::underlying_type<T>::type>(v)
- );
- }
- };
-#endif
- template<bool C>
- struct StringMakerBase {
-#if defined(CATCH_CONFIG_CPP11_IS_ENUM)
- template<typename T>
- static std::string convert( T const& v )
- {
- return EnumStringMaker<T>::convert( v );
- }
-#else
- template<typename T>
- static std::string convert( T const& ) { return unprintableString; }
-#endif
- };
-
- template<>
- struct StringMakerBase<true> {
- template<typename T>
- static std::string convert( T const& _value ) {
- std::ostringstream oss;
- oss << _value;
- return oss.str();
- }
- };
-
- std::string rawMemoryToString( const void *object, std::size_t size );
-
- template<typename T>
- inline std::string rawMemoryToString( const T& object ) {
- return rawMemoryToString( &object, sizeof(object) );
- }
-
-} // end namespace Detail
-
-template<typename T>
-struct StringMaker :
- Detail::StringMakerBase<Detail::IsStreamInsertable<T>::value> {};
-
-template<typename T>
-struct StringMaker<T*> {
- template<typename U>
- static std::string convert( U* p ) {
- if( !p )
- return "NULL";
- else
- return Detail::rawMemoryToString( p );
- }
-};
-
-template<typename R, typename C>
-struct StringMaker<R C::*> {
- static std::string convert( R C::* p ) {
- if( !p )
- return "NULL";
- else
- return Detail::rawMemoryToString( p );
- }
-};
-
-namespace Detail {
- template<typename InputIterator>
- std::string rangeToString( InputIterator first, InputIterator last );
-}
-
-//template<typename T, typename Allocator>
-//struct StringMaker<std::vector<T, Allocator> > {
-// static std::string convert( std::vector<T,Allocator> const& v ) {
-// return Detail::rangeToString( v.begin(), v.end() );
-// }
-//};
-
-template<typename T, typename Allocator>
-std::string toString( std::vector<T,Allocator> const& v ) {
- return Detail::rangeToString( v.begin(), v.end() );
-}
-
-#ifdef CATCH_CONFIG_CPP11_TUPLE
-
-// toString for tuples
-namespace TupleDetail {
- template<
- typename Tuple,
- std::size_t N = 0,
- bool = (N < std::tuple_size<Tuple>::value)
- >
- struct ElementPrinter {
- static void print( const Tuple& tuple, std::ostream& os )
- {
- os << ( N ? ", " : " " )
- << Catch::toString(std::get<N>(tuple));
- ElementPrinter<Tuple,N+1>::print(tuple,os);
- }
- };
-
- template<
- typename Tuple,
- std::size_t N
- >
- struct ElementPrinter<Tuple,N,false> {
- static void print( const Tuple&, std::ostream& ) {}
- };
-
-}
-
-template<typename ...Types>
-struct StringMaker<std::tuple<Types...>> {
-
- static std::string convert( const std::tuple<Types...>& tuple )
- {
- std::ostringstream os;
- os << '{';
- TupleDetail::ElementPrinter<std::tuple<Types...>>::print( tuple, os );
- os << " }";
- return os.str();
- }
-};
-#endif // CATCH_CONFIG_CPP11_TUPLE
-
-namespace Detail {
- template<typename T>
- std::string makeString( T const& value ) {
- return StringMaker<T>::convert( value );
- }
-} // end namespace Detail
-
-/// \brief converts any type to a string
-///
-/// The default template forwards on to ostringstream - except when an
-/// ostringstream overload does not exist - in which case it attempts to detect
-/// that and writes {?}.
-/// Overload (not specialise) this template for custom typs that you don't want
-/// to provide an ostream overload for.
-template<typename T>
-std::string toString( T const& value ) {
- return StringMaker<T>::convert( value );
-}
-
- namespace Detail {
- template<typename InputIterator>
- std::string rangeToString( InputIterator first, InputIterator last ) {
- std::ostringstream oss;
- oss << "{ ";
- if( first != last ) {
- oss << Catch::toString( *first );
- for( ++first ; first != last ; ++first )
- oss << ", " << Catch::toString( *first );
- }
- oss << " }";
- return oss.str();
- }
-}
-
-} // end namespace Catch
-
-namespace Catch {
-
-// Wraps the LHS of an expression and captures the operator and RHS (if any) -
-// wrapping them all in a ResultBuilder object
-template<typename T>
-class ExpressionLhs {
- ExpressionLhs& operator = ( ExpressionLhs const& );
-# ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS
- ExpressionLhs& operator = ( ExpressionLhs && ) = delete;
-# endif
-
-public:
- ExpressionLhs( ResultBuilder& rb, T lhs ) : m_rb( rb ), m_lhs( lhs ) {}
-# ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS
- ExpressionLhs( ExpressionLhs const& ) = default;
- ExpressionLhs( ExpressionLhs && ) = default;
-# endif
-
- template<typename RhsT>
- ResultBuilder& operator == ( RhsT const& rhs ) {
- return captureExpression<Internal::IsEqualTo>( rhs );
- }
-
- template<typename RhsT>
- ResultBuilder& operator != ( RhsT const& rhs ) {
- return captureExpression<Internal::IsNotEqualTo>( rhs );
- }
-
- template<typename RhsT>
- ResultBuilder& operator < ( RhsT const& rhs ) {
- return captureExpression<Internal::IsLessThan>( rhs );
- }
-
- template<typename RhsT>
- ResultBuilder& operator > ( RhsT const& rhs ) {
- return captureExpression<Internal::IsGreaterThan>( rhs );
- }
-
- template<typename RhsT>
- ResultBuilder& operator <= ( RhsT const& rhs ) {
- return captureExpression<Internal::IsLessThanOrEqualTo>( rhs );
- }
-
- template<typename RhsT>
- ResultBuilder& operator >= ( RhsT const& rhs ) {
- return captureExpression<Internal::IsGreaterThanOrEqualTo>( rhs );
- }
-
- ResultBuilder& operator == ( bool rhs ) {
- return captureExpression<Internal::IsEqualTo>( rhs );
- }
-
- ResultBuilder& operator != ( bool rhs ) {
- return captureExpression<Internal::IsNotEqualTo>( rhs );
- }
-
- void endExpression() {
- bool value = m_lhs ? true : false;
- m_rb
- .setLhs( Catch::toString( value ) )
- .setResultType( value )
- .endExpression();
- }
-
- // Only simple binary expressions are allowed on the LHS.
- // If more complex compositions are required then place the sub expression in parentheses
- template<typename RhsT> STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator + ( RhsT const& );
- template<typename RhsT> STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator - ( RhsT const& );
- template<typename RhsT> STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator / ( RhsT const& );
- template<typename RhsT> STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator * ( RhsT const& );
- template<typename RhsT> STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator && ( RhsT const& );
- template<typename RhsT> STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator || ( RhsT const& );
-
-private:
- template<Internal::Operator Op, typename RhsT>
- ResultBuilder& captureExpression( RhsT const& rhs ) {
- return m_rb
- .setResultType( Internal::compare<Op>( m_lhs, rhs ) )
- .setLhs( Catch::toString( m_lhs ) )
- .setRhs( Catch::toString( rhs ) )
- .setOp( Internal::OperatorTraits<Op>::getName() );
- }
-
-private:
- ResultBuilder& m_rb;
- T m_lhs;
-};
-
-} // end namespace Catch
-
-
-namespace Catch {
-
- template<typename T>
- inline ExpressionLhs<T const&> ResultBuilder::operator <= ( T const& operand ) {
- return ExpressionLhs<T const&>( *this, operand );
- }
-
- inline ExpressionLhs<bool> ResultBuilder::operator <= ( bool value ) {
- return ExpressionLhs<bool>( *this, value );
- }
-
-} // namespace Catch
-
-// #included from: catch_message.h
-#define TWOBLUECUBES_CATCH_MESSAGE_H_INCLUDED
-
-#include <string>
-
-namespace Catch {
-
- struct MessageInfo {
- MessageInfo( std::string const& _macroName,
- SourceLineInfo const& _lineInfo,
- ResultWas::OfType _type );
-
- std::string macroName;
- SourceLineInfo lineInfo;
- ResultWas::OfType type;
- std::string message;
- unsigned int sequence;
-
- bool operator == ( MessageInfo const& other ) const {
- return sequence == other.sequence;
- }
- bool operator < ( MessageInfo const& other ) const {
- return sequence < other.sequence;
- }
- private:
- static unsigned int globalCount;
- };
-
- struct MessageBuilder {
- MessageBuilder( std::string const& macroName,
- SourceLineInfo const& lineInfo,
- ResultWas::OfType type )
- : m_info( macroName, lineInfo, type )
- {}
-
- template<typename T>
- MessageBuilder& operator << ( T const& value ) {
- m_stream << value;
- return *this;
- }
-
- MessageInfo m_info;
- std::ostringstream m_stream;
- };
-
- class ScopedMessage {
- public:
- ScopedMessage( MessageBuilder const& builder );
- ScopedMessage( ScopedMessage const& other );
- ~ScopedMessage();
-
- MessageInfo m_info;
- };
-
-} // end namespace Catch
-
-// #included from: catch_interfaces_capture.h
-#define TWOBLUECUBES_CATCH_INTERFACES_CAPTURE_H_INCLUDED
-
-#include <string>
-
-namespace Catch {
-
- class TestCase;
- class AssertionResult;
- struct AssertionInfo;
- struct SectionInfo;
- struct SectionEndInfo;
- struct MessageInfo;
- class ScopedMessageBuilder;
- struct Counts;
-
- struct IResultCapture {
-
- virtual ~IResultCapture();
-
- virtual void assertionEnded( AssertionResult const& result ) = 0;
- virtual bool sectionStarted( SectionInfo const& sectionInfo,
- Counts& assertions ) = 0;
- virtual void sectionEnded( SectionEndInfo const& endInfo ) = 0;
- virtual void sectionEndedEarly( SectionEndInfo const& endInfo ) = 0;
- virtual void pushScopedMessage( MessageInfo const& message ) = 0;
- virtual void popScopedMessage( MessageInfo const& message ) = 0;
-
- virtual std::string getCurrentTestName() const = 0;
- virtual const AssertionResult* getLastResult() const = 0;
-
- virtual void handleFatalErrorCondition( std::string const& message ) = 0;
- };
-
- IResultCapture& getResultCapture();
-}
-
-// #included from: catch_debugger.h
-#define TWOBLUECUBES_CATCH_DEBUGGER_H_INCLUDED
-
-// #included from: catch_platform.h
-#define TWOBLUECUBES_CATCH_PLATFORM_H_INCLUDED
-
-#if defined(__MAC_OS_X_VERSION_MIN_REQUIRED)
-#define CATCH_PLATFORM_MAC
-#elif defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
-#define CATCH_PLATFORM_IPHONE
-#elif defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER)
-#define CATCH_PLATFORM_WINDOWS
-#endif
-
-#include <string>
-
-namespace Catch{
-
- bool isDebuggerActive();
- void writeToDebugConsole( std::string const& text );
-}
-
-#ifdef CATCH_PLATFORM_MAC
-
- // The following code snippet based on:
- // http://cocoawithlove.com/2008/03/break-into-debugger.html
- #ifdef DEBUG
- #if defined(__ppc64__) || defined(__ppc__)
- #define CATCH_BREAK_INTO_DEBUGGER() \
- if( Catch::isDebuggerActive() ) { \
- __asm__("li r0, 20\nsc\nnop\nli r0, 37\nli r4, 2\nsc\nnop\n" \
- : : : "memory","r0","r3","r4" ); \
- }
- #else
- #define CATCH_BREAK_INTO_DEBUGGER() if( Catch::isDebuggerActive() ) {__asm__("int $3\n" : : );}
- #endif
- #endif
-
-#elif defined(_MSC_VER)
- #define CATCH_BREAK_INTO_DEBUGGER() if( Catch::isDebuggerActive() ) { __debugbreak(); }
-#elif defined(__MINGW32__)
- extern "C" __declspec(dllimport) void __stdcall DebugBreak();
- #define CATCH_BREAK_INTO_DEBUGGER() if( Catch::isDebuggerActive() ) { DebugBreak(); }
-#endif
-
-#ifndef CATCH_BREAK_INTO_DEBUGGER
-#define CATCH_BREAK_INTO_DEBUGGER() Catch::alwaysTrue();
-#endif
-
-// #included from: catch_interfaces_runner.h
-#define TWOBLUECUBES_CATCH_INTERFACES_RUNNER_H_INCLUDED
-
-namespace Catch {
- class TestCase;
-
- struct IRunner {
- virtual ~IRunner();
- virtual bool aborting() const = 0;
- };
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// In the event of a failure works out if the debugger needs to be invoked
-// and/or an exception thrown and takes appropriate action.
-// This needs to be done as a macro so the debugger will stop in the user
-// source code rather than in Catch library code
-#define INTERNAL_CATCH_REACT( resultBuilder ) \
- if( resultBuilder.shouldDebugBreak() ) CATCH_BREAK_INTO_DEBUGGER(); \
- resultBuilder.react();
-
-///////////////////////////////////////////////////////////////////////////////
-#define INTERNAL_CATCH_TEST( expr, resultDisposition, macroName ) \
- do { \
- Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition ); \
- try { \
- CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \
- ( __catchResult <= expr ).endExpression(); \
- } \
- catch( ... ) { \
- __catchResult.useActiveException( Catch::ResultDisposition::Normal ); \
- } \
- INTERNAL_CATCH_REACT( __catchResult ) \
- } while( Catch::isTrue( false && static_cast<bool>(expr) ) ) // expr here is never evaluated at runtime but it forces the compiler to give it a look
-
-///////////////////////////////////////////////////////////////////////////////
-#define INTERNAL_CATCH_IF( expr, resultDisposition, macroName ) \
- INTERNAL_CATCH_TEST( expr, resultDisposition, macroName ); \
- if( Catch::getResultCapture().getLastResult()->succeeded() )
-
-///////////////////////////////////////////////////////////////////////////////
-#define INTERNAL_CATCH_ELSE( expr, resultDisposition, macroName ) \
- INTERNAL_CATCH_TEST( expr, resultDisposition, macroName ); \
- if( !Catch::getResultCapture().getLastResult()->succeeded() )
-
-///////////////////////////////////////////////////////////////////////////////
-#define INTERNAL_CATCH_NO_THROW( expr, resultDisposition, macroName ) \
- do { \
- Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition ); \
- try { \
- expr; \
- __catchResult.captureResult( Catch::ResultWas::Ok ); \
- } \
- catch( ... ) { \
- __catchResult.useActiveException( resultDisposition ); \
- } \
- INTERNAL_CATCH_REACT( __catchResult ) \
- } while( Catch::alwaysFalse() )
-
-///////////////////////////////////////////////////////////////////////////////
-#define INTERNAL_CATCH_THROWS( expr, resultDisposition, matcher, macroName ) \
- do { \
- Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition, #matcher ); \
- if( __catchResult.allowThrows() ) \
- try { \
- expr; \
- __catchResult.captureResult( Catch::ResultWas::DidntThrowException ); \
- } \
- catch( ... ) { \
- __catchResult.captureExpectedException( matcher ); \
- } \
- else \
- __catchResult.captureResult( Catch::ResultWas::Ok ); \
- INTERNAL_CATCH_REACT( __catchResult ) \
- } while( Catch::alwaysFalse() )
-
-///////////////////////////////////////////////////////////////////////////////
-#define INTERNAL_CATCH_THROWS_AS( expr, exceptionType, resultDisposition, macroName ) \
- do { \
- Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition ); \
- if( __catchResult.allowThrows() ) \
- try { \
- expr; \
- __catchResult.captureResult( Catch::ResultWas::DidntThrowException ); \
- } \
- catch( exceptionType ) { \
- __catchResult.captureResult( Catch::ResultWas::Ok ); \
- } \
- catch( ... ) { \
- __catchResult.useActiveException( resultDisposition ); \
- } \
- else \
- __catchResult.captureResult( Catch::ResultWas::Ok ); \
- INTERNAL_CATCH_REACT( __catchResult ) \
- } while( Catch::alwaysFalse() )
-
-///////////////////////////////////////////////////////////////////////////////
-#ifdef CATCH_CONFIG_VARIADIC_MACROS
- #define INTERNAL_CATCH_MSG( messageType, resultDisposition, macroName, ... ) \
- do { \
- Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, "", resultDisposition ); \
- __catchResult << __VA_ARGS__ + ::Catch::StreamEndStop(); \
- __catchResult.captureResult( messageType ); \
- INTERNAL_CATCH_REACT( __catchResult ) \
- } while( Catch::alwaysFalse() )
-#else
- #define INTERNAL_CATCH_MSG( messageType, resultDisposition, macroName, log ) \
- do { \
- Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, "", resultDisposition ); \
- __catchResult << log + ::Catch::StreamEndStop(); \
- __catchResult.captureResult( messageType ); \
- INTERNAL_CATCH_REACT( __catchResult ) \
- } while( Catch::alwaysFalse() )
-#endif
-
-///////////////////////////////////////////////////////////////////////////////
-#define INTERNAL_CATCH_INFO( log, macroName ) \
- Catch::ScopedMessage INTERNAL_CATCH_UNIQUE_NAME( scopedMessage ) = Catch::MessageBuilder( macroName, CATCH_INTERNAL_LINEINFO, Catch::ResultWas::Info ) << log;
-
-///////////////////////////////////////////////////////////////////////////////
-#define INTERNAL_CHECK_THAT( arg, matcher, resultDisposition, macroName ) \
- do { \
- Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #arg ", " #matcher, resultDisposition ); \
- try { \
- std::string matcherAsString = (matcher).toString(); \
- __catchResult \
- .setLhs( Catch::toString( arg ) ) \
- .setRhs( matcherAsString == Catch::Detail::unprintableString ? #matcher : matcherAsString ) \
- .setOp( "matches" ) \
- .setResultType( (matcher).match( arg ) ); \
- __catchResult.captureExpression(); \
- } catch( ... ) { \
- __catchResult.useActiveException( resultDisposition | Catch::ResultDisposition::ContinueOnFailure ); \
- } \
- INTERNAL_CATCH_REACT( __catchResult ) \
- } while( Catch::alwaysFalse() )
-
-// #included from: internal/catch_section.h
-#define TWOBLUECUBES_CATCH_SECTION_H_INCLUDED
-
-// #included from: catch_section_info.h
-#define TWOBLUECUBES_CATCH_SECTION_INFO_H_INCLUDED
-
-// #included from: catch_totals.hpp
-#define TWOBLUECUBES_CATCH_TOTALS_HPP_INCLUDED
-
-#include <cstddef>
-
-namespace Catch {
-
- struct Counts {
- Counts() : passed( 0 ), failed( 0 ), failedButOk( 0 ) {}
-
- Counts operator - ( Counts const& other ) const {
- Counts diff;
- diff.passed = passed - other.passed;
- diff.failed = failed - other.failed;
- diff.failedButOk = failedButOk - other.failedButOk;
- return diff;
- }
- Counts& operator += ( Counts const& other ) {
- passed += other.passed;
- failed += other.failed;
- failedButOk += other.failedButOk;
- return *this;
- }
-
- std::size_t total() const {
- return passed + failed + failedButOk;
- }
- bool allPassed() const {
- return failed == 0 && failedButOk == 0;
- }
- bool allOk() const {
- return failed == 0;
- }
-
- std::size_t passed;
- std::size_t failed;
- std::size_t failedButOk;
- };
-
- struct Totals {
-
- Totals operator - ( Totals const& other ) const {
- Totals diff;
- diff.assertions = assertions - other.assertions;
- diff.testCases = testCases - other.testCases;
- return diff;
- }
-
- Totals delta( Totals const& prevTotals ) const {
- Totals diff = *this - prevTotals;
- if( diff.assertions.failed > 0 )
- ++diff.testCases.failed;
- else if( diff.assertions.failedButOk > 0 )
- ++diff.testCases.failedButOk;
- else
- ++diff.testCases.passed;
- return diff;
- }
-
- Totals& operator += ( Totals const& other ) {
- assertions += other.assertions;
- testCases += other.testCases;
- return *this;
- }
-
- Counts assertions;
- Counts testCases;
- };
-}
-
-namespace Catch {
-
- struct SectionInfo {
- SectionInfo
- ( SourceLineInfo const& _lineInfo,
- std::string const& _name,
- std::string const& _description = std::string() );
-
- std::string name;
- std::string description;
- SourceLineInfo lineInfo;
- };
-
- struct SectionEndInfo {
- SectionEndInfo( SectionInfo const& _sectionInfo, Counts const& _prevAssertions, double _durationInSeconds )
- : sectionInfo( _sectionInfo ), prevAssertions( _prevAssertions ), durationInSeconds( _durationInSeconds )
- {}
-
- SectionInfo sectionInfo;
- Counts prevAssertions;
- double durationInSeconds;
- };
-
-} // end namespace Catch
-
-// #included from: catch_timer.h
-#define TWOBLUECUBES_CATCH_TIMER_H_INCLUDED
-
-#ifdef CATCH_PLATFORM_WINDOWS
-typedef unsigned long long uint64_t;
-#else
-#include <stdint.h>
-#endif
-
-namespace Catch {
-
- class Timer {
- public:
- Timer() : m_ticks( 0 ) {}
- void start();
- unsigned int getElapsedMicroseconds() const;
- unsigned int getElapsedMilliseconds() const;
- double getElapsedSeconds() const;
-
- private:
- uint64_t m_ticks;
- };
-
-} // namespace Catch
-
-#include <string>
-
-namespace Catch {
-
- class Section : NonCopyable {
- public:
- Section( SectionInfo const& info );
- ~Section();
-
- // This indicates whether the section should be executed or not
- operator bool() const;
-
- private:
- SectionInfo m_info;
-
- std::string m_name;
- Counts m_assertions;
- bool m_sectionIncluded;
- Timer m_timer;
- };
-
-} // end namespace Catch
-
-#ifdef CATCH_CONFIG_VARIADIC_MACROS
- #define INTERNAL_CATCH_SECTION( ... ) \
- if( Catch::Section const& INTERNAL_CATCH_UNIQUE_NAME( catch_internal_Section ) = Catch::SectionInfo( CATCH_INTERNAL_LINEINFO, __VA_ARGS__ ) )
-#else
- #define INTERNAL_CATCH_SECTION( name, desc ) \
- if( Catch::Section const& INTERNAL_CATCH_UNIQUE_NAME( catch_internal_Section ) = Catch::SectionInfo( CATCH_INTERNAL_LINEINFO, name, desc ) )
-#endif
-
-// #included from: internal/catch_generators.hpp
-#define TWOBLUECUBES_CATCH_GENERATORS_HPP_INCLUDED
-
-#include <iterator>
-#include <vector>
-#include <string>
-#include <stdlib.h>
-
-namespace Catch {
-
-template<typename T>
-struct IGenerator {
- virtual ~IGenerator() {}
- virtual T getValue( std::size_t index ) const = 0;
- virtual std::size_t size () const = 0;
-};
-
-template<typename T>
-class BetweenGenerator : public IGenerator<T> {
-public:
- BetweenGenerator( T from, T to ) : m_from( from ), m_to( to ){}
-
- virtual T getValue( std::size_t index ) const {
- return m_from+static_cast<int>( index );
- }
-
- virtual std::size_t size() const {
- return static_cast<std::size_t>( 1+m_to-m_from );
- }
-
-private:
-
- T m_from;
- T m_to;
-};
-
-template<typename T>
-class ValuesGenerator : public IGenerator<T> {
-public:
- ValuesGenerator(){}
-
- void add( T value ) {
- m_values.push_back( value );
- }
-
- virtual T getValue( std::size_t index ) const {
- return m_values[index];
- }
-
- virtual std::size_t size() const {
- return m_values.size();
- }
-
-private:
- std::vector<T> m_values;
-};
-
-template<typename T>
-class CompositeGenerator {
-public:
- CompositeGenerator() : m_totalSize( 0 ) {}
-
- // *** Move semantics, similar to auto_ptr ***
- CompositeGenerator( CompositeGenerator& other )
- : m_fileInfo( other.m_fileInfo ),
- m_totalSize( 0 )
- {
- move( other );
- }
-
- CompositeGenerator& setFileInfo( const char* fileInfo ) {
- m_fileInfo = fileInfo;
- return *this;
- }
-
- ~CompositeGenerator() {
- deleteAll( m_composed );
- }
-
- operator T () const {
- size_t overallIndex = getCurrentContext().getGeneratorIndex( m_fileInfo, m_totalSize );
-
- typename std::vector<const IGenerator<T>*>::const_iterator it = m_composed.begin();
- typename std::vector<const IGenerator<T>*>::const_iterator itEnd = m_composed.end();
- for( size_t index = 0; it != itEnd; ++it )
- {
- const IGenerator<T>* generator = *it;
- if( overallIndex >= index && overallIndex < index + generator->size() )
- {
- return generator->getValue( overallIndex-index );
- }
- index += generator->size();
- }
- CATCH_INTERNAL_ERROR( "Indexed past end of generated range" );
- return T(); // Suppress spurious "not all control paths return a value" warning in Visual Studio - if you know how to fix this please do so
- }
-
- void add( const IGenerator<T>* generator ) {
- m_totalSize += generator->size();
- m_composed.push_back( generator );
- }
-
- CompositeGenerator& then( CompositeGenerator& other ) {
- move( other );
- return *this;
- }
-
- CompositeGenerator& then( T value ) {
- ValuesGenerator<T>* valuesGen = new ValuesGenerator<T>();
- valuesGen->add( value );
- add( valuesGen );
- return *this;
- }
-
-private:
-
- void move( CompositeGenerator& other ) {
- std::copy( other.m_composed.begin(), other.m_composed.end(), std::back_inserter( m_composed ) );
- m_totalSize += other.m_totalSize;
- other.m_composed.clear();
- }
-
- std::vector<const IGenerator<T>*> m_composed;
- std::string m_fileInfo;
- size_t m_totalSize;
-};
-
-namespace Generators
-{
- template<typename T>
- CompositeGenerator<T> between( T from, T to ) {
- CompositeGenerator<T> generators;
- generators.add( new BetweenGenerator<T>( from, to ) );
- return generators;
- }
-
- template<typename T>
- CompositeGenerator<T> values( T val1, T val2 ) {
- CompositeGenerator<T> generators;
- ValuesGenerator<T>* valuesGen = new ValuesGenerator<T>();
- valuesGen->add( val1 );
- valuesGen->add( val2 );
- generators.add( valuesGen );
- return generators;
- }
-
- template<typename T>
- CompositeGenerator<T> values( T val1, T val2, T val3 ){
- CompositeGenerator<T> generators;
- ValuesGenerator<T>* valuesGen = new ValuesGenerator<T>();
- valuesGen->add( val1 );
- valuesGen->add( val2 );
- valuesGen->add( val3 );
- generators.add( valuesGen );
- return generators;
- }
-
- template<typename T>
- CompositeGenerator<T> values( T val1, T val2, T val3, T val4 ) {
- CompositeGenerator<T> generators;
- ValuesGenerator<T>* valuesGen = new ValuesGenerator<T>();
- valuesGen->add( val1 );
- valuesGen->add( val2 );
- valuesGen->add( val3 );
- valuesGen->add( val4 );
- generators.add( valuesGen );
- return generators;
- }
-
-} // end namespace Generators
-
-using namespace Generators;
-
-} // end namespace Catch
-
-#define INTERNAL_CATCH_LINESTR2( line ) #line
-#define INTERNAL_CATCH_LINESTR( line ) INTERNAL_CATCH_LINESTR2( line )
-
-#define INTERNAL_CATCH_GENERATE( expr ) expr.setFileInfo( __FILE__ "(" INTERNAL_CATCH_LINESTR( __LINE__ ) ")" )
-
-// #included from: internal/catch_interfaces_exception.h
-#define TWOBLUECUBES_CATCH_INTERFACES_EXCEPTION_H_INCLUDED
-
-#include <string>
-#include <vector>
-
-// #included from: catch_interfaces_registry_hub.h
-#define TWOBLUECUBES_CATCH_INTERFACES_REGISTRY_HUB_H_INCLUDED
-
-#include <string>
-
-namespace Catch {
-
- class TestCase;
- struct ITestCaseRegistry;
- struct IExceptionTranslatorRegistry;
- struct IExceptionTranslator;
- struct IReporterRegistry;
- struct IReporterFactory;
-
- struct IRegistryHub {
- virtual ~IRegistryHub();
-
- virtual IReporterRegistry const& getReporterRegistry() const = 0;
- virtual ITestCaseRegistry const& getTestCaseRegistry() const = 0;
- virtual IExceptionTranslatorRegistry& getExceptionTranslatorRegistry() = 0;
- };
-
- struct IMutableRegistryHub {
- virtual ~IMutableRegistryHub();
- virtual void registerReporter( std::string const& name, Ptr<IReporterFactory> const& factory ) = 0;
- virtual void registerListener( Ptr<IReporterFactory> const& factory ) = 0;
- virtual void registerTest( TestCase const& testInfo ) = 0;
- virtual void registerTranslator( const IExceptionTranslator* translator ) = 0;
- };
-
- IRegistryHub& getRegistryHub();
- IMutableRegistryHub& getMutableRegistryHub();
- void cleanUp();
- std::string translateActiveException();
-
-}
-
-namespace Catch {
-
- typedef std::string(*exceptionTranslateFunction)();
-
- struct IExceptionTranslator;
- typedef std::vector<const IExceptionTranslator*> ExceptionTranslators;
-
- struct IExceptionTranslator {
- virtual ~IExceptionTranslator();
- virtual std::string translate( ExceptionTranslators::const_iterator it, ExceptionTranslators::const_iterator itEnd ) const = 0;
- };
-
- struct IExceptionTranslatorRegistry {
- virtual ~IExceptionTranslatorRegistry();
-
- virtual std::string translateActiveException() const = 0;
- };
-
- class ExceptionTranslatorRegistrar {
- template<typename T>
- class ExceptionTranslator : public IExceptionTranslator {
- public:
-
- ExceptionTranslator( std::string(*translateFunction)( T& ) )
- : m_translateFunction( translateFunction )
- {}
-
- virtual std::string translate( ExceptionTranslators::const_iterator it, ExceptionTranslators::const_iterator itEnd ) const CATCH_OVERRIDE {
- try {
- if( it == itEnd )
- throw;
- else
- return (*it)->translate( it+1, itEnd );
- }
- catch( T& ex ) {
- return m_translateFunction( ex );
- }
- }
-
- protected:
- std::string(*m_translateFunction)( T& );
- };
-
- public:
- template<typename T>
- ExceptionTranslatorRegistrar( std::string(*translateFunction)( T& ) ) {
- getMutableRegistryHub().registerTranslator
- ( new ExceptionTranslator<T>( translateFunction ) );
- }
- };
-}
-
-///////////////////////////////////////////////////////////////////////////////
-#define INTERNAL_CATCH_TRANSLATE_EXCEPTION2( translatorName, signature ) \
- static std::string translatorName( signature ); \
- namespace{ Catch::ExceptionTranslatorRegistrar INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionRegistrar )( &translatorName ); }\
- static std::string translatorName( signature )
-
-#define INTERNAL_CATCH_TRANSLATE_EXCEPTION( signature ) INTERNAL_CATCH_TRANSLATE_EXCEPTION2( INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionTranslator ), signature )
-
-// #included from: internal/catch_approx.hpp
-#define TWOBLUECUBES_CATCH_APPROX_HPP_INCLUDED
-
-#include <cmath>
-#include <limits>
-
-namespace Catch {
-namespace Detail {
-
- class Approx {
- public:
- explicit Approx ( double value )
- : m_epsilon( std::numeric_limits<float>::epsilon()*100 ),
- m_scale( 1.0 ),
- m_value( value )
- {}
-
- Approx( Approx const& other )
- : m_epsilon( other.m_epsilon ),
- m_scale( other.m_scale ),
- m_value( other.m_value )
- {}
-
- static Approx custom() {
- return Approx( 0 );
- }
-
- Approx operator()( double value ) {
- Approx approx( value );
- approx.epsilon( m_epsilon );
- approx.scale( m_scale );
- return approx;
- }
-
- friend bool operator == ( double lhs, Approx const& rhs ) {
- // Thanks to Richard Harris for his help refining this formula
- return fabs( lhs - rhs.m_value ) < rhs.m_epsilon * (rhs.m_scale + (std::max)( fabs(lhs), fabs(rhs.m_value) ) );
- }
-
- friend bool operator == ( Approx const& lhs, double rhs ) {
- return operator==( rhs, lhs );
- }
-
- friend bool operator != ( double lhs, Approx const& rhs ) {
- return !operator==( lhs, rhs );
- }
-
- friend bool operator != ( Approx const& lhs, double rhs ) {
- return !operator==( rhs, lhs );
- }
-
- Approx& epsilon( double newEpsilon ) {
- m_epsilon = newEpsilon;
- return *this;
- }
-
- Approx& scale( double newScale ) {
- m_scale = newScale;
- return *this;
- }
-
- std::string toString() const {
- std::ostringstream oss;
- oss << "Approx( " << Catch::toString( m_value ) << " )";
- return oss.str();
- }
-
- private:
- double m_epsilon;
- double m_scale;
- double m_value;
- };
-}
-
-template<>
-inline std::string toString<Detail::Approx>( Detail::Approx const& value ) {
- return value.toString();
-}
-
-} // end namespace Catch
-
-// #included from: internal/catch_interfaces_tag_alias_registry.h
-#define TWOBLUECUBES_CATCH_INTERFACES_TAG_ALIAS_REGISTRY_H_INCLUDED
-
-// #included from: catch_tag_alias.h
-#define TWOBLUECUBES_CATCH_TAG_ALIAS_H_INCLUDED
-
-#include <string>
-
-namespace Catch {
-
- struct TagAlias {
- TagAlias( std::string _tag, SourceLineInfo _lineInfo ) : tag( _tag ), lineInfo( _lineInfo ) {}
-
- std::string tag;
- SourceLineInfo lineInfo;
- };
-
- struct RegistrarForTagAliases {
- RegistrarForTagAliases( char const* alias, char const* tag, SourceLineInfo const& lineInfo );
- };
-
-} // end namespace Catch
-
-#define CATCH_REGISTER_TAG_ALIAS( alias, spec ) namespace{ Catch::RegistrarForTagAliases INTERNAL_CATCH_UNIQUE_NAME( AutoRegisterTagAlias )( alias, spec, CATCH_INTERNAL_LINEINFO ); }
-// #included from: catch_option.hpp
-#define TWOBLUECUBES_CATCH_OPTION_HPP_INCLUDED
-
-namespace Catch {
-
- // An optional type
- template<typename T>
- class Option {
- public:
- Option() : nullableValue( CATCH_NULL ) {}
- Option( T const& _value )
- : nullableValue( new( storage ) T( _value ) )
- {}
- Option( Option const& _other )
- : nullableValue( _other ? new( storage ) T( *_other ) : CATCH_NULL )
- {}
-
- ~Option() {
- reset();
- }
-
- Option& operator= ( Option const& _other ) {
- if( &_other != this ) {
- reset();
- if( _other )
- nullableValue = new( storage ) T( *_other );
- }
- return *this;
- }
- Option& operator = ( T const& _value ) {
- reset();
- nullableValue = new( storage ) T( _value );
- return *this;
- }
-
- void reset() {
- if( nullableValue )
- nullableValue->~T();
- nullableValue = CATCH_NULL;
- }
-
- T& operator*() { return *nullableValue; }
- T const& operator*() const { return *nullableValue; }
- T* operator->() { return nullableValue; }
- const T* operator->() const { return nullableValue; }
-
- T valueOr( T const& defaultValue ) const {
- return nullableValue ? *nullableValue : defaultValue;
- }
-
- bool some() const { return nullableValue != CATCH_NULL; }
- bool none() const { return nullableValue == CATCH_NULL; }
-
- bool operator !() const { return nullableValue == CATCH_NULL; }
- operator SafeBool::type() const {
- return SafeBool::makeSafe( some() );
- }
-
- private:
- T* nullableValue;
- char storage[sizeof(T)];
- };
-
-} // end namespace Catch
-
-namespace Catch {
-
- struct ITagAliasRegistry {
- virtual ~ITagAliasRegistry();
- virtual Option<TagAlias> find( std::string const& alias ) const = 0;
- virtual std::string expandAliases( std::string const& unexpandedTestSpec ) const = 0;
-
- static ITagAliasRegistry const& get();
- };
-
-} // end namespace Catch
-
-// These files are included here so the single_include script doesn't put them
-// in the conditionally compiled sections
-// #included from: internal/catch_test_case_info.h
-#define TWOBLUECUBES_CATCH_TEST_CASE_INFO_H_INCLUDED
-
-#include <string>
-#include <set>
-
-#ifdef __clang__
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wpadded"
-#endif
-
-namespace Catch {
-
- struct ITestCase;
-
- struct TestCaseInfo {
- enum SpecialProperties{
- None = 0,
- IsHidden = 1 << 1,
- ShouldFail = 1 << 2,
- MayFail = 1 << 3,
- Throws = 1 << 4
- };
-
- TestCaseInfo( std::string const& _name,
- std::string const& _className,
- std::string const& _description,
- std::set<std::string> const& _tags,
- SourceLineInfo const& _lineInfo );
-
- TestCaseInfo( TestCaseInfo const& other );
-
- friend void setTags( TestCaseInfo& testCaseInfo, std::set<std::string> const& tags );
-
- bool isHidden() const;
- bool throws() const;
- bool okToFail() const;
- bool expectedToFail() const;
-
- std::string name;
- std::string className;
- std::string description;
- std::set<std::string> tags;
- std::set<std::string> lcaseTags;
- std::string tagsAsString;
- SourceLineInfo lineInfo;
- SpecialProperties properties;
- };
-
- class TestCase : public TestCaseInfo {
- public:
-
- TestCase( ITestCase* testCase, TestCaseInfo const& info );
- TestCase( TestCase const& other );
-
- TestCase withName( std::string const& _newName ) const;
-
- void invoke() const;
-
- TestCaseInfo const& getTestCaseInfo() const;
-
- void swap( TestCase& other );
- bool operator == ( TestCase const& other ) const;
- bool operator < ( TestCase const& other ) const;
- TestCase& operator = ( TestCase const& other );
-
- private:
- Ptr<ITestCase> test;
- };
-
- TestCase makeTestCase( ITestCase* testCase,
- std::string const& className,
- std::string const& name,
- std::string const& description,
- SourceLineInfo const& lineInfo );
-}
-
-#ifdef __clang__
-#pragma clang diagnostic pop
-#endif
-
-
-#ifdef __OBJC__
-// #included from: internal/catch_objc.hpp
-#define TWOBLUECUBES_CATCH_OBJC_HPP_INCLUDED
-
-#import <objc/runtime.h>
-
-#include <string>
-
-// NB. Any general catch headers included here must be included
-// in catch.hpp first to make sure they are included by the single
-// header for non obj-usage
-
-///////////////////////////////////////////////////////////////////////////////
-// This protocol is really only here for (self) documenting purposes, since
-// all its methods are optional.
-@protocol OcFixture
-
-@optional
-
--(void) setUp;
--(void) tearDown;
-
-@end
-
-namespace Catch {
-
- class OcMethod : public SharedImpl<ITestCase> {
-
- public:
- OcMethod( Class cls, SEL sel ) : m_cls( cls ), m_sel( sel ) {}
-
- virtual void invoke() const {
- id obj = [[m_cls alloc] init];
-
- performOptionalSelector( obj, @selector(setUp) );
- performOptionalSelector( obj, m_sel );
- performOptionalSelector( obj, @selector(tearDown) );
-
- arcSafeRelease( obj );
- }
- private:
- virtual ~OcMethod() {}
-
- Class m_cls;
- SEL m_sel;
- };
-
- namespace Detail{
-
- inline std::string getAnnotation( Class cls,
- std::string const& annotationName,
- std::string const& testCaseName ) {
- NSString* selStr = [[NSString alloc] initWithFormat:@"Catch_%s_%s", annotationName.c_str(), testCaseName.c_str()];
- SEL sel = NSSelectorFromString( selStr );
- arcSafeRelease( selStr );
- id value = performOptionalSelector( cls, sel );
- if( value )
- return [(NSString*)value UTF8String];
- return "";
- }
- }
-
- inline size_t registerTestMethods() {
- size_t noTestMethods = 0;
- int noClasses = objc_getClassList( CATCH_NULL, 0 );
-
- Class* classes = (CATCH_UNSAFE_UNRETAINED Class *)malloc( sizeof(Class) * noClasses);
- objc_getClassList( classes, noClasses );
-
- for( int c = 0; c < noClasses; c++ ) {
- Class cls = classes[c];
- {
- u_int count;
- Method* methods = class_copyMethodList( cls, &count );
- for( u_int m = 0; m < count ; m++ ) {
- SEL selector = method_getName(methods[m]);
- std::string methodName = sel_getName(selector);
- if( startsWith( methodName, "Catch_TestCase_" ) ) {
- std::string testCaseName = methodName.substr( 15 );
- std::string name = Detail::getAnnotation( cls, "Name", testCaseName );
- std::string desc = Detail::getAnnotation( cls, "Description", testCaseName );
- const char* className = class_getName( cls );
-
- getMutableRegistryHub().registerTest( makeTestCase( new OcMethod( cls, selector ), className, name.c_str(), desc.c_str(), SourceLineInfo() ) );
- noTestMethods++;
- }
- }
- free(methods);
- }
- }
- return noTestMethods;
- }
-
- namespace Matchers {
- namespace Impl {
- namespace NSStringMatchers {
-
- template<typename MatcherT>
- struct StringHolder : MatcherImpl<MatcherT, NSString*>{
- StringHolder( NSString* substr ) : m_substr( [substr copy] ){}
- StringHolder( StringHolder const& other ) : m_substr( [other.m_substr copy] ){}
- StringHolder() {
- arcSafeRelease( m_substr );
- }
-
- NSString* m_substr;
- };
-
- struct Equals : StringHolder<Equals> {
- Equals( NSString* substr ) : StringHolder( substr ){}
-
- virtual bool match( ExpressionType const& str ) const {
- return (str != nil || m_substr == nil ) &&
- [str isEqualToString:m_substr];
- }
-
- virtual std::string toString() const {
- return "equals string: " + Catch::toString( m_substr );
- }
- };
-
- struct Contains : StringHolder<Contains> {
- Contains( NSString* substr ) : StringHolder( substr ){}
-
- virtual bool match( ExpressionType const& str ) const {
- return (str != nil || m_substr == nil ) &&
- [str rangeOfString:m_substr].location != NSNotFound;
- }
-
- virtual std::string toString() const {
- return "contains string: " + Catch::toString( m_substr );
- }
- };
-
- struct StartsWith : StringHolder<StartsWith> {
- StartsWith( NSString* substr ) : StringHolder( substr ){}
-
- virtual bool match( ExpressionType const& str ) const {
- return (str != nil || m_substr == nil ) &&
- [str rangeOfString:m_substr].location == 0;
- }
-
- virtual std::string toString() const {
- return "starts with: " + Catch::toString( m_substr );
- }
- };
- struct EndsWith : StringHolder<EndsWith> {
- EndsWith( NSString* substr ) : StringHolder( substr ){}
-
- virtual bool match( ExpressionType const& str ) const {
- return (str != nil || m_substr == nil ) &&
- [str rangeOfString:m_substr].location == [str length] - [m_substr length];
- }
-
- virtual std::string toString() const {
- return "ends with: " + Catch::toString( m_substr );
- }
- };
-
- } // namespace NSStringMatchers
- } // namespace Impl
-
- inline Impl::NSStringMatchers::Equals
- Equals( NSString* substr ){ return Impl::NSStringMatchers::Equals( substr ); }
-
- inline Impl::NSStringMatchers::Contains
- Contains( NSString* substr ){ return Impl::NSStringMatchers::Contains( substr ); }
-
- inline Impl::NSStringMatchers::StartsWith
- StartsWith( NSString* substr ){ return Impl::NSStringMatchers::StartsWith( substr ); }
-
- inline Impl::NSStringMatchers::EndsWith
- EndsWith( NSString* substr ){ return Impl::NSStringMatchers::EndsWith( substr ); }
-
- } // namespace Matchers
-
- using namespace Matchers;
-
-} // namespace Catch
-
-///////////////////////////////////////////////////////////////////////////////
-#define OC_TEST_CASE( name, desc )\
-+(NSString*) INTERNAL_CATCH_UNIQUE_NAME( Catch_Name_test ) \
-{\
-return @ name; \
-}\
-+(NSString*) INTERNAL_CATCH_UNIQUE_NAME( Catch_Description_test ) \
-{ \
-return @ desc; \
-} \
--(void) INTERNAL_CATCH_UNIQUE_NAME( Catch_TestCase_test )
-
-#endif
-
-#ifdef CATCH_IMPL
-// #included from: internal/catch_impl.hpp
-#define TWOBLUECUBES_CATCH_IMPL_HPP_INCLUDED
-
-// Collect all the implementation files together here
-// These are the equivalent of what would usually be cpp files
-
-#ifdef __clang__
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wweak-vtables"
-#endif
-
-// #included from: ../catch_session.hpp
-#define TWOBLUECUBES_CATCH_RUNNER_HPP_INCLUDED
-
-// #included from: internal/catch_commandline.hpp
-#define TWOBLUECUBES_CATCH_COMMANDLINE_HPP_INCLUDED
-
-// #included from: catch_config.hpp
-#define TWOBLUECUBES_CATCH_CONFIG_HPP_INCLUDED
-
-// #included from: catch_test_spec_parser.hpp
-#define TWOBLUECUBES_CATCH_TEST_SPEC_PARSER_HPP_INCLUDED
-
-#ifdef __clang__
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wpadded"
-#endif
-
-// #included from: catch_test_spec.hpp
-#define TWOBLUECUBES_CATCH_TEST_SPEC_HPP_INCLUDED
-
-#ifdef __clang__
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wpadded"
-#endif
-
-// #included from: catch_wildcard_pattern.hpp
-#define TWOBLUECUBES_CATCH_WILDCARD_PATTERN_HPP_INCLUDED
-
-namespace Catch
-{
- class WildcardPattern {
- enum WildcardPosition {
- NoWildcard = 0,
- WildcardAtStart = 1,
- WildcardAtEnd = 2,
- WildcardAtBothEnds = WildcardAtStart | WildcardAtEnd
- };
-
- public:
-
- WildcardPattern( std::string const& pattern, CaseSensitive::Choice caseSensitivity )
- : m_caseSensitivity( caseSensitivity ),
- m_wildcard( NoWildcard ),
- m_pattern( adjustCase( pattern ) )
- {
- if( startsWith( m_pattern, "*" ) ) {
- m_pattern = m_pattern.substr( 1 );
- m_wildcard = WildcardAtStart;
- }
- if( endsWith( m_pattern, "*" ) ) {
- m_pattern = m_pattern.substr( 0, m_pattern.size()-1 );
- m_wildcard = static_cast<WildcardPosition>( m_wildcard | WildcardAtEnd );
- }
- }
- virtual ~WildcardPattern();
- virtual bool matches( std::string const& str ) const {
- switch( m_wildcard ) {
- case NoWildcard:
- return m_pattern == adjustCase( str );
- case WildcardAtStart:
- return endsWith( adjustCase( str ), m_pattern );
- case WildcardAtEnd:
- return startsWith( adjustCase( str ), m_pattern );
- case WildcardAtBothEnds:
- return contains( adjustCase( str ), m_pattern );
- }
-
-#ifdef __clang__
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wunreachable-code"
-#endif
- throw std::logic_error( "Unknown enum" );
-#ifdef __clang__
-#pragma clang diagnostic pop
-#endif
- }
- private:
- std::string adjustCase( std::string const& str ) const {
- return m_caseSensitivity == CaseSensitive::No ? toLower( str ) : str;
- }
- CaseSensitive::Choice m_caseSensitivity;
- WildcardPosition m_wildcard;
- std::string m_pattern;
- };
-}
-
-#include <string>
-#include <vector>
-
-namespace Catch {
-
- class TestSpec {
- struct Pattern : SharedImpl<> {
- virtual ~Pattern();
- virtual bool matches( TestCaseInfo const& testCase ) const = 0;
- };
- class NamePattern : public Pattern {
- public:
- NamePattern( std::string const& name )
- : m_wildcardPattern( toLower( name ), CaseSensitive::No )
- {}
- virtual ~NamePattern();
- virtual bool matches( TestCaseInfo const& testCase ) const {
- return m_wildcardPattern.matches( toLower( testCase.name ) );
- }
- private:
- WildcardPattern m_wildcardPattern;
- };
-
- class TagPattern : public Pattern {
- public:
- TagPattern( std::string const& tag ) : m_tag( toLower( tag ) ) {}
- virtual ~TagPattern();
- virtual bool matches( TestCaseInfo const& testCase ) const {
- return testCase.lcaseTags.find( m_tag ) != testCase.lcaseTags.end();
- }
- private:
- std::string m_tag;
- };
-
- class ExcludedPattern : public Pattern {
- public:
- ExcludedPattern( Ptr<Pattern> const& underlyingPattern ) : m_underlyingPattern( underlyingPattern ) {}
- virtual ~ExcludedPattern();
- virtual bool matches( TestCaseInfo const& testCase ) const { return !m_underlyingPattern->matches( testCase ); }
- private:
- Ptr<Pattern> m_underlyingPattern;
- };
-
- struct Filter {
- std::vector<Ptr<Pattern> > m_patterns;
-
- bool matches( TestCaseInfo const& testCase ) const {
- // All patterns in a filter must match for the filter to be a match
- for( std::vector<Ptr<Pattern> >::const_iterator it = m_patterns.begin(), itEnd = m_patterns.end(); it != itEnd; ++it )
- if( !(*it)->matches( testCase ) )
- return false;
- return true;
- }
- };
-
- public:
- bool hasFilters() const {
- return !m_filters.empty();
- }
- bool matches( TestCaseInfo const& testCase ) const {
- // A TestSpec matches if any filter matches
- for( std::vector<Filter>::const_iterator it = m_filters.begin(), itEnd = m_filters.end(); it != itEnd; ++it )
- if( it->matches( testCase ) )
- return true;
- return false;
- }
-
- private:
- std::vector<Filter> m_filters;
-
- friend class TestSpecParser;
- };
-}
-
-#ifdef __clang__
-#pragma clang diagnostic pop
-#endif
-
-namespace Catch {
-
- class TestSpecParser {
- enum Mode{ None, Name, QuotedName, Tag };
- Mode m_mode;
- bool m_exclusion;
- std::size_t m_start, m_pos;
- std::string m_arg;
- TestSpec::Filter m_currentFilter;
- TestSpec m_testSpec;
- ITagAliasRegistry const* m_tagAliases;
-
- public:
- TestSpecParser( ITagAliasRegistry const& tagAliases ) : m_tagAliases( &tagAliases ) {}
-
- TestSpecParser& parse( std::string const& arg ) {
- m_mode = None;
- m_exclusion = false;
- m_start = std::string::npos;
- m_arg = m_tagAliases->expandAliases( arg );
- for( m_pos = 0; m_pos < m_arg.size(); ++m_pos )
- visitChar( m_arg[m_pos] );
- if( m_mode == Name )
- addPattern<TestSpec::NamePattern>();
- return *this;
- }
- TestSpec testSpec() {
- addFilter();
- return m_testSpec;
- }
- private:
- void visitChar( char c ) {
- if( m_mode == None ) {
- switch( c ) {
- case ' ': return;
- case '~': m_exclusion = true; return;
- case '[': return startNewMode( Tag, ++m_pos );
- case '"': return startNewMode( QuotedName, ++m_pos );
- default: startNewMode( Name, m_pos ); break;
- }
- }
- if( m_mode == Name ) {
- if( c == ',' ) {
- addPattern<TestSpec::NamePattern>();
- addFilter();
- }
- else if( c == '[' ) {
- if( subString() == "exclude:" )
- m_exclusion = true;
- else
- addPattern<TestSpec::NamePattern>();
- startNewMode( Tag, ++m_pos );
- }
- }
- else if( m_mode == QuotedName && c == '"' )
- addPattern<TestSpec::NamePattern>();
- else if( m_mode == Tag && c == ']' )
- addPattern<TestSpec::TagPattern>();
- }
- void startNewMode( Mode mode, std::size_t start ) {
- m_mode = mode;
- m_start = start;
- }
- std::string subString() const { return m_arg.substr( m_start, m_pos - m_start ); }
- template<typename T>
- void addPattern() {
- std::string token = subString();
- if( startsWith( token, "exclude:" ) ) {
- m_exclusion = true;
- token = token.substr( 8 );
- }
- if( !token.empty() ) {
- Ptr<TestSpec::Pattern> pattern = new T( token );
- if( m_exclusion )
- pattern = new TestSpec::ExcludedPattern( pattern );
- m_currentFilter.m_patterns.push_back( pattern );
- }
- m_exclusion = false;
- m_mode = None;
- }
- void addFilter() {
- if( !m_currentFilter.m_patterns.empty() ) {
- m_testSpec.m_filters.push_back( m_currentFilter );
- m_currentFilter = TestSpec::Filter();
- }
- }
- };
- inline TestSpec parseTestSpec( std::string const& arg ) {
- return TestSpecParser( ITagAliasRegistry::get() ).parse( arg ).testSpec();
- }
-
-} // namespace Catch
-
-#ifdef __clang__
-#pragma clang diagnostic pop
-#endif
-
-// #included from: catch_interfaces_config.h
-#define TWOBLUECUBES_CATCH_INTERFACES_CONFIG_H_INCLUDED
-
-#include <iostream>
-#include <string>
-#include <vector>
-
-namespace Catch {
-
- struct Verbosity { enum Level {
- NoOutput = 0,
- Quiet,
- Normal
- }; };
-
- struct WarnAbout { enum What {
- Nothing = 0x00,
- NoAssertions = 0x01
- }; };
-
- struct ShowDurations { enum OrNot {
- DefaultForReporter,
- Always,
- Never
- }; };
- struct RunTests { enum InWhatOrder {
- InDeclarationOrder,
- InLexicographicalOrder,
- InRandomOrder
- }; };
- struct UseColour { enum YesOrNo {
- Auto,
- Yes,
- No
- }; };
-
- class TestSpec;
-
- struct IConfig : IShared {
-
- virtual ~IConfig();
-
- virtual bool allowThrows() const = 0;
- virtual std::ostream& stream() const = 0;
- virtual std::string name() const = 0;
- virtual bool includeSuccessfulResults() const = 0;
- virtual bool shouldDebugBreak() const = 0;
- virtual bool warnAboutMissingAssertions() const = 0;
- virtual int abortAfter() const = 0;
- virtual bool showInvisibles() const = 0;
- virtual ShowDurations::OrNot showDurations() const = 0;
- virtual TestSpec const& testSpec() const = 0;
- virtual RunTests::InWhatOrder runOrder() const = 0;
- virtual unsigned int rngSeed() const = 0;
- virtual UseColour::YesOrNo useColour() const = 0;
- };
-}
-
-// #included from: catch_stream.h
-#define TWOBLUECUBES_CATCH_STREAM_H_INCLUDED
-
-// #included from: catch_streambuf.h
-#define TWOBLUECUBES_CATCH_STREAMBUF_H_INCLUDED
-
-#include <streambuf>
-
-namespace Catch {
-
- class StreamBufBase : public std::streambuf {
- public:
- virtual ~StreamBufBase() CATCH_NOEXCEPT;
- };
-}
-
-#include <streambuf>
-#include <ostream>
-#include <fstream>
-
-namespace Catch {
-
- std::ostream& cout();
- std::ostream& cerr();
-
- struct IStream {
- virtual ~IStream() CATCH_NOEXCEPT;
- virtual std::ostream& stream() const = 0;
- };
-
- class FileStream : public IStream {
- mutable std::ofstream m_ofs;
- public:
- FileStream( std::string const& filename );
- virtual ~FileStream() CATCH_NOEXCEPT;
- public: // IStream
- virtual std::ostream& stream() const CATCH_OVERRIDE;
- };
-
- class CoutStream : public IStream {
- mutable std::ostream m_os;
- public:
- CoutStream();
- virtual ~CoutStream() CATCH_NOEXCEPT;
-
- public: // IStream
- virtual std::ostream& stream() const CATCH_OVERRIDE;
- };
-
- class DebugOutStream : public IStream {
- std::auto_ptr<StreamBufBase> m_streamBuf;
- mutable std::ostream m_os;
- public:
- DebugOutStream();
- virtual ~DebugOutStream() CATCH_NOEXCEPT;
-
- public: // IStream
- virtual std::ostream& stream() const CATCH_OVERRIDE;
- };
-}
-
-#include <memory>
-#include <vector>
-#include <string>
-#include <iostream>
-#include <ctime>
-
-#ifndef CATCH_CONFIG_CONSOLE_WIDTH
-#define CATCH_CONFIG_CONSOLE_WIDTH 80
-#endif
-
-namespace Catch {
-
- struct ConfigData {
-
- ConfigData()
- : listTests( false ),
- listTags( false ),
- listReporters( false ),
- listTestNamesOnly( false ),
- showSuccessfulTests( false ),
- shouldDebugBreak( false ),
- noThrow( false ),
- showHelp( false ),
- showInvisibles( false ),
- filenamesAsTags( false ),
- abortAfter( -1 ),
- rngSeed( 0 ),
- verbosity( Verbosity::Normal ),
- warnings( WarnAbout::Nothing ),
- showDurations( ShowDurations::DefaultForReporter ),
- runOrder( RunTests::InDeclarationOrder ),
- useColour( UseColour::Auto )
- {}
-
- bool listTests;
- bool listTags;
- bool listReporters;
- bool listTestNamesOnly;
-
- bool showSuccessfulTests;
- bool shouldDebugBreak;
- bool noThrow;
- bool showHelp;
- bool showInvisibles;
- bool filenamesAsTags;
-
- int abortAfter;
- unsigned int rngSeed;
-
- Verbosity::Level verbosity;
- WarnAbout::What warnings;
- ShowDurations::OrNot showDurations;
- RunTests::InWhatOrder runOrder;
- UseColour::YesOrNo useColour;
-
- std::string outputFilename;
- std::string name;
- std::string processName;
-
- std::vector<std::string> reporterNames;
- std::vector<std::string> testsOrTags;
- };
-
- class Config : public SharedImpl<IConfig> {
- private:
- Config( Config const& other );
- Config& operator = ( Config const& other );
- virtual void dummy();
- public:
-
- Config()
- {}
-
- Config( ConfigData const& data )
- : m_data( data ),
- m_stream( openStream() )
- {
- if( !data.testsOrTags.empty() ) {
- TestSpecParser parser( ITagAliasRegistry::get() );
- for( std::size_t i = 0; i < data.testsOrTags.size(); ++i )
- parser.parse( data.testsOrTags[i] );
- m_testSpec = parser.testSpec();
- }
- }
-
- virtual ~Config() {
- }
-
- std::string const& getFilename() const {
- return m_data.outputFilename ;
- }
-
- bool listTests() const { return m_data.listTests; }
- bool listTestNamesOnly() const { return m_data.listTestNamesOnly; }
- bool listTags() const { return m_data.listTags; }
- bool listReporters() const { return m_data.listReporters; }
-
- std::string getProcessName() const { return m_data.processName; }
-
- bool shouldDebugBreak() const { return m_data.shouldDebugBreak; }
-
- std::vector<std::string> getReporterNames() const { return m_data.reporterNames; }
-
- int abortAfter() const { return m_data.abortAfter; }
-
- TestSpec const& testSpec() const { return m_testSpec; }
-
- bool showHelp() const { return m_data.showHelp; }
- bool showInvisibles() const { return m_data.showInvisibles; }
-
- // IConfig interface
- virtual bool allowThrows() const { return !m_data.noThrow; }
- virtual std::ostream& stream() const { return m_stream->stream(); }
- virtual std::string name() const { return m_data.name.empty() ? m_data.processName : m_data.name; }
- virtual bool includeSuccessfulResults() const { return m_data.showSuccessfulTests; }
- virtual bool warnAboutMissingAssertions() const { return m_data.warnings & WarnAbout::NoAssertions; }
- virtual ShowDurations::OrNot showDurations() const { return m_data.showDurations; }
- virtual RunTests::InWhatOrder runOrder() const { return m_data.runOrder; }
- virtual unsigned int rngSeed() const { return m_data.rngSeed; }
- virtual UseColour::YesOrNo useColour() const { return m_data.useColour; }
-
- private:
-
- IStream const* openStream() {
- if( m_data.outputFilename.empty() )
- return new CoutStream();
- else if( m_data.outputFilename[0] == '%' ) {
- if( m_data.outputFilename == "%debug" )
- return new DebugOutStream();
- else
- throw std::domain_error( "Unrecognised stream: " + m_data.outputFilename );
- }
- else
- return new FileStream( m_data.outputFilename );
- }
- ConfigData m_data;
-
- std::auto_ptr<IStream const> m_stream;
- TestSpec m_testSpec;
- };
-
-} // end namespace Catch
-
-// #included from: catch_clara.h
-#define TWOBLUECUBES_CATCH_CLARA_H_INCLUDED
-
-// Use Catch's value for console width (store Clara's off to the side, if present)
-#ifdef CLARA_CONFIG_CONSOLE_WIDTH
-#define CATCH_TEMP_CLARA_CONFIG_CONSOLE_WIDTH CLARA_CONFIG_CONSOLE_WIDTH
-#undef CLARA_CONFIG_CONSOLE_WIDTH
-#endif
-#define CLARA_CONFIG_CONSOLE_WIDTH CATCH_CONFIG_CONSOLE_WIDTH
-
-// Declare Clara inside the Catch namespace
-#define STITCH_CLARA_OPEN_NAMESPACE namespace Catch {
-// #included from: ../external/clara.h
-
-// Version 0.0.2.3
-
-// Only use header guard if we are not using an outer namespace
-#if !defined(TWOBLUECUBES_CLARA_H_INCLUDED) || defined(STITCH_CLARA_OPEN_NAMESPACE)
-
-#ifndef STITCH_CLARA_OPEN_NAMESPACE
-#define TWOBLUECUBES_CLARA_H_INCLUDED
-#define STITCH_CLARA_OPEN_NAMESPACE
-#define STITCH_CLARA_CLOSE_NAMESPACE
-#else
-#define STITCH_CLARA_CLOSE_NAMESPACE }
-#endif
-
-#define STITCH_TBC_TEXT_FORMAT_OPEN_NAMESPACE STITCH_CLARA_OPEN_NAMESPACE
-
-// ----------- #included from tbc_text_format.h -----------
-
-// Only use header guard if we are not using an outer namespace
-#if !defined(TBC_TEXT_FORMAT_H_INCLUDED) || defined(STITCH_TBC_TEXT_FORMAT_OUTER_NAMESPACE)
-#ifndef STITCH_TBC_TEXT_FORMAT_OUTER_NAMESPACE
-#define TBC_TEXT_FORMAT_H_INCLUDED
-#endif
-
-#include <string>
-#include <vector>
-#include <sstream>
-#include <algorithm>
-
-// Use optional outer namespace
-#ifdef STITCH_TBC_TEXT_FORMAT_OUTER_NAMESPACE
-namespace STITCH_TBC_TEXT_FORMAT_OUTER_NAMESPACE {
-#endif
-
-namespace Tbc {
-
-#ifdef TBC_TEXT_FORMAT_CONSOLE_WIDTH
- const unsigned int consoleWidth = TBC_TEXT_FORMAT_CONSOLE_WIDTH;
-#else
- const unsigned int consoleWidth = 80;
-#endif
-
- struct TextAttributes {
- TextAttributes()
- : initialIndent( std::string::npos ),
- indent( 0 ),
- width( consoleWidth-1 ),
- tabChar( '\t' )
- {}
-
- TextAttributes& setInitialIndent( std::size_t _value ) { initialIndent = _value; return *this; }
- TextAttributes& setIndent( std::size_t _value ) { indent = _value; return *this; }
- TextAttributes& setWidth( std::size_t _value ) { width = _value; return *this; }
- TextAttributes& setTabChar( char _value ) { tabChar = _value; return *this; }
-
- std::size_t initialIndent; // indent of first line, or npos
- std::size_t indent; // indent of subsequent lines, or all if initialIndent is npos
- std::size_t width; // maximum width of text, including indent. Longer text will wrap
- char tabChar; // If this char is seen the indent is changed to current pos
- };
-
- class Text {
- public:
- Text( std::string const& _str, TextAttributes const& _attr = TextAttributes() )
- : attr( _attr )
- {
- std::string wrappableChars = " [({.,/|\\-";
- std::size_t indent = _attr.initialIndent != std::string::npos
- ? _attr.initialIndent
- : _attr.indent;
- std::string remainder = _str;
-
- while( !remainder.empty() ) {
- if( lines.size() >= 1000 ) {
- lines.push_back( "... message truncated due to excessive size" );
- return;
- }
- std::size_t tabPos = std::string::npos;
- std::size_t width = (std::min)( remainder.size(), _attr.width - indent );
- std::size_t pos = remainder.find_first_of( '\n' );
- if( pos <= width ) {
- width = pos;
- }
- pos = remainder.find_last_of( _attr.tabChar, width );
- if( pos != std::string::npos ) {
- tabPos = pos;
- if( remainder[width] == '\n' )
- width--;
- remainder = remainder.substr( 0, tabPos ) + remainder.substr( tabPos+1 );
- }
-
- if( width == remainder.size() ) {
- spliceLine( indent, remainder, width );
- }
- else if( remainder[width] == '\n' ) {
- spliceLine( indent, remainder, width );
- if( width <= 1 || remainder.size() != 1 )
- remainder = remainder.substr( 1 );
- indent = _attr.indent;
- }
- else {
- pos = remainder.find_last_of( wrappableChars, width );
- if( pos != std::string::npos && pos > 0 ) {
- spliceLine( indent, remainder, pos );
- if( remainder[0] == ' ' )
- remainder = remainder.substr( 1 );
- }
- else {
- spliceLine( indent, remainder, width-1 );
- lines.back() += "-";
- }
- if( lines.size() == 1 )
- indent = _attr.indent;
- if( tabPos != std::string::npos )
- indent += tabPos;
- }
- }
- }
-
- void spliceLine( std::size_t _indent, std::string& _remainder, std::size_t _pos ) {
- lines.push_back( std::string( _indent, ' ' ) + _remainder.substr( 0, _pos ) );
- _remainder = _remainder.substr( _pos );
- }
-
- typedef std::vector<std::string>::const_iterator const_iterator;
-
- const_iterator begin() const { return lines.begin(); }
- const_iterator end() const { return lines.end(); }
- std::string const& last() const { return lines.back(); }
- std::size_t size() const { return lines.size(); }
- std::string const& operator[]( std::size_t _index ) const { return lines[_index]; }
- std::string toString() const {
- std::ostringstream oss;
- oss << *this;
- return oss.str();
- }
-
- inline friend std::ostream& operator << ( std::ostream& _stream, Text const& _text ) {
- for( Text::const_iterator it = _text.begin(), itEnd = _text.end();
- it != itEnd; ++it ) {
- if( it != _text.begin() )
- _stream << "\n";
- _stream << *it;
- }
- return _stream;
- }
-
- private:
- std::string str;
- TextAttributes attr;
- std::vector<std::string> lines;
- };
-
-} // end namespace Tbc
-
-#ifdef STITCH_TBC_TEXT_FORMAT_OUTER_NAMESPACE
-} // end outer namespace
-#endif
-
-#endif // TBC_TEXT_FORMAT_H_INCLUDED
-
-// ----------- end of #include from tbc_text_format.h -----------
-// ........... back in clara.h
-
-#undef STITCH_TBC_TEXT_FORMAT_OPEN_NAMESPACE
-
-// ----------- #included from clara_compilers.h -----------
-
-#ifndef TWOBLUECUBES_CLARA_COMPILERS_H_INCLUDED
-#define TWOBLUECUBES_CLARA_COMPILERS_H_INCLUDED
-
-// Detect a number of compiler features - mostly C++11/14 conformance - by compiler
-// The following features are defined:
-//
-// CLARA_CONFIG_CPP11_NULLPTR : is nullptr supported?
-// CLARA_CONFIG_CPP11_NOEXCEPT : is noexcept supported?
-// CLARA_CONFIG_CPP11_GENERATED_METHODS : The delete and default keywords for compiler generated methods
-// CLARA_CONFIG_CPP11_OVERRIDE : is override supported?
-// CLARA_CONFIG_CPP11_UNIQUE_PTR : is unique_ptr supported (otherwise use auto_ptr)
-
-// CLARA_CONFIG_CPP11_OR_GREATER : Is C++11 supported?
-
-// CLARA_CONFIG_VARIADIC_MACROS : are variadic macros supported?
-
-// In general each macro has a _NO_<feature name> form
-// (e.g. CLARA_CONFIG_CPP11_NO_NULLPTR) which disables the feature.
-// Many features, at point of detection, define an _INTERNAL_ macro, so they
-// can be combined, en-mass, with the _NO_ forms later.
-
-// All the C++11 features can be disabled with CLARA_CONFIG_NO_CPP11
-
-#ifdef __clang__
-
-#if __has_feature(cxx_nullptr)
-#define CLARA_INTERNAL_CONFIG_CPP11_NULLPTR
-#endif
-
-#if __has_feature(cxx_noexcept)
-#define CLARA_INTERNAL_CONFIG_CPP11_NOEXCEPT
-#endif
-
-#endif // __clang__
-
-////////////////////////////////////////////////////////////////////////////////
-// GCC
-#ifdef __GNUC__
-
-#if __GNUC__ == 4 && __GNUC_MINOR__ >= 6 && defined(__GXX_EXPERIMENTAL_CXX0X__)
-#define CLARA_INTERNAL_CONFIG_CPP11_NULLPTR
-#endif
-
-// - otherwise more recent versions define __cplusplus >= 201103L
-// and will get picked up below
-
-#endif // __GNUC__
-
-////////////////////////////////////////////////////////////////////////////////
-// Visual C++
-#ifdef _MSC_VER
-
-#if (_MSC_VER >= 1600)
-#define CLARA_INTERNAL_CONFIG_CPP11_NULLPTR
-#define CLARA_INTERNAL_CONFIG_CPP11_UNIQUE_PTR
-#endif
-
-#if (_MSC_VER >= 1900 ) // (VC++ 13 (VS2015))
-#define CLARA_INTERNAL_CONFIG_CPP11_NOEXCEPT
-#define CLARA_INTERNAL_CONFIG_CPP11_GENERATED_METHODS
-#endif
-
-#endif // _MSC_VER
-
-////////////////////////////////////////////////////////////////////////////////
-// C++ language feature support
-
-// catch all support for C++11
-#if defined(__cplusplus) && __cplusplus >= 201103L
-
-#define CLARA_CPP11_OR_GREATER
-
-#if !defined(CLARA_INTERNAL_CONFIG_CPP11_NULLPTR)
-#define CLARA_INTERNAL_CONFIG_CPP11_NULLPTR
-#endif
-
-#ifndef CLARA_INTERNAL_CONFIG_CPP11_NOEXCEPT
-#define CLARA_INTERNAL_CONFIG_CPP11_NOEXCEPT
-#endif
-
-#ifndef CLARA_INTERNAL_CONFIG_CPP11_GENERATED_METHODS
-#define CLARA_INTERNAL_CONFIG_CPP11_GENERATED_METHODS
-#endif
-
-#if !defined(CLARA_INTERNAL_CONFIG_CPP11_OVERRIDE)
-#define CLARA_INTERNAL_CONFIG_CPP11_OVERRIDE
-#endif
-#if !defined(CLARA_INTERNAL_CONFIG_CPP11_UNIQUE_PTR)
-#define CLARA_INTERNAL_CONFIG_CPP11_UNIQUE_PTR
-#endif
-
-#endif // __cplusplus >= 201103L
-
-// Now set the actual defines based on the above + anything the user has configured
-#if defined(CLARA_INTERNAL_CONFIG_CPP11_NULLPTR) && !defined(CLARA_CONFIG_CPP11_NO_NULLPTR) && !defined(CLARA_CONFIG_CPP11_NULLPTR) && !defined(CLARA_CONFIG_NO_CPP11)
-#define CLARA_CONFIG_CPP11_NULLPTR
-#endif
-#if defined(CLARA_INTERNAL_CONFIG_CPP11_NOEXCEPT) && !defined(CLARA_CONFIG_CPP11_NO_NOEXCEPT) && !defined(CLARA_CONFIG_CPP11_NOEXCEPT) && !defined(CLARA_CONFIG_NO_CPP11)
-#define CLARA_CONFIG_CPP11_NOEXCEPT
-#endif
-#if defined(CLARA_INTERNAL_CONFIG_CPP11_GENERATED_METHODS) && !defined(CLARA_CONFIG_CPP11_NO_GENERATED_METHODS) && !defined(CLARA_CONFIG_CPP11_GENERATED_METHODS) && !defined(CLARA_CONFIG_NO_CPP11)
-#define CLARA_CONFIG_CPP11_GENERATED_METHODS
-#endif
-#if defined(CLARA_INTERNAL_CONFIG_CPP11_OVERRIDE) && !defined(CLARA_CONFIG_NO_OVERRIDE) && !defined(CLARA_CONFIG_CPP11_OVERRIDE) && !defined(CLARA_CONFIG_NO_CPP11)
-#define CLARA_CONFIG_CPP11_OVERRIDE
-#endif
-#if defined(CLARA_INTERNAL_CONFIG_CPP11_UNIQUE_PTR) && !defined(CLARA_CONFIG_NO_UNIQUE_PTR) && !defined(CLARA_CONFIG_CPP11_UNIQUE_PTR) && !defined(CLARA_CONFIG_NO_CPP11)
-#define CLARA_CONFIG_CPP11_UNIQUE_PTR
-#endif
-
-// noexcept support:
-#if defined(CLARA_CONFIG_CPP11_NOEXCEPT) && !defined(CLARA_NOEXCEPT)
-#define CLARA_NOEXCEPT noexcept
-# define CLARA_NOEXCEPT_IS(x) noexcept(x)
-#else
-#define CLARA_NOEXCEPT throw()
-# define CLARA_NOEXCEPT_IS(x)
-#endif
-
-// nullptr support
-#ifdef CLARA_CONFIG_CPP11_NULLPTR
-#define CLARA_NULL nullptr
-#else
-#define CLARA_NULL NULL
-#endif
-
-// override support
-#ifdef CLARA_CONFIG_CPP11_OVERRIDE
-#define CLARA_OVERRIDE override
-#else
-#define CLARA_OVERRIDE
-#endif
-
-// unique_ptr support
-#ifdef CLARA_CONFIG_CPP11_UNIQUE_PTR
-# define CLARA_AUTO_PTR( T ) std::unique_ptr<T>
-#else
-# define CLARA_AUTO_PTR( T ) std::auto_ptr<T>
-#endif
-
-#endif // TWOBLUECUBES_CLARA_COMPILERS_H_INCLUDED
-
-// ----------- end of #include from clara_compilers.h -----------
-// ........... back in clara.h
-
-#include <map>
-#include <stdexcept>
-#include <memory>
-
-#if defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER)
-#define CLARA_PLATFORM_WINDOWS
-#endif
-
-// Use optional outer namespace
-#ifdef STITCH_CLARA_OPEN_NAMESPACE
-STITCH_CLARA_OPEN_NAMESPACE
-#endif
-
-namespace Clara {
-
- struct UnpositionalTag {};
-
- extern UnpositionalTag _;
-
-#ifdef CLARA_CONFIG_MAIN
- UnpositionalTag _;
-#endif
-
- namespace Detail {
-
-#ifdef CLARA_CONSOLE_WIDTH
- const unsigned int consoleWidth = CLARA_CONFIG_CONSOLE_WIDTH;
-#else
- const unsigned int consoleWidth = 80;
-#endif
-
- using namespace Tbc;
-
- inline bool startsWith( std::string const& str, std::string const& prefix ) {
- return str.size() >= prefix.size() && str.substr( 0, prefix.size() ) == prefix;
- }
-
- template<typename T> struct RemoveConstRef{ typedef T type; };
- template<typename T> struct RemoveConstRef<T&>{ typedef T type; };
- template<typename T> struct RemoveConstRef<T const&>{ typedef T type; };
- template<typename T> struct RemoveConstRef<T const>{ typedef T type; };
-
- template<typename T> struct IsBool { static const bool value = false; };
- template<> struct IsBool<bool> { static const bool value = true; };
-
- template<typename T>
- void convertInto( std::string const& _source, T& _dest ) {
- std::stringstream ss;
- ss << _source;
- ss >> _dest;
- if( ss.fail() )
- throw std::runtime_error( "Unable to convert " + _source + " to destination type" );
- }
- inline void convertInto( std::string const& _source, std::string& _dest ) {
- _dest = _source;
- }
- inline void convertInto( std::string const& _source, bool& _dest ) {
- std::string sourceLC = _source;
- std::transform( sourceLC.begin(), sourceLC.end(), sourceLC.begin(), ::tolower );
- if( sourceLC == "y" || sourceLC == "1" || sourceLC == "true" || sourceLC == "yes" || sourceLC == "on" )
- _dest = true;
- else if( sourceLC == "n" || sourceLC == "0" || sourceLC == "false" || sourceLC == "no" || sourceLC == "off" )
- _dest = false;
- else
- throw std::runtime_error( "Expected a boolean value but did not recognise:\n '" + _source + "'" );
- }
-
- template<typename ConfigT>
- struct IArgFunction {
- virtual ~IArgFunction() {}
-#ifdef CLARA_CONFIG_CPP11_GENERATED_METHODS
- IArgFunction() = default;
- IArgFunction( IArgFunction const& ) = default;
-#endif
- virtual void set( ConfigT& config, std::string const& value ) const = 0;
- virtual bool takesArg() const = 0;
- virtual IArgFunction* clone() const = 0;
- };
-
- template<typename ConfigT>
- class BoundArgFunction {
- public:
- BoundArgFunction() : functionObj( CLARA_NULL ) {}
- BoundArgFunction( IArgFunction<ConfigT>* _functionObj ) : functionObj( _functionObj ) {}
- BoundArgFunction( BoundArgFunction const& other ) : functionObj( other.functionObj ? other.functionObj->clone() : CLARA_NULL ) {}
- BoundArgFunction& operator = ( BoundArgFunction const& other ) {
- IArgFunction<ConfigT>* newFunctionObj = other.functionObj ? other.functionObj->clone() : CLARA_NULL;
- delete functionObj;
- functionObj = newFunctionObj;
- return *this;
- }
- ~BoundArgFunction() { delete functionObj; }
-
- void set( ConfigT& config, std::string const& value ) const {
- functionObj->set( config, value );
- }
- bool takesArg() const { return functionObj->takesArg(); }
-
- bool isSet() const {
- return functionObj != CLARA_NULL;
- }
- private:
- IArgFunction<ConfigT>* functionObj;
- };
-
- template<typename C>
- struct NullBinder : IArgFunction<C>{
- virtual void set( C&, std::string const& ) const {}
- virtual bool takesArg() const { return true; }
- virtual IArgFunction<C>* clone() const { return new NullBinder( *this ); }
- };
-
- template<typename C, typename M>
- struct BoundDataMember : IArgFunction<C>{
- BoundDataMember( M C::* _member ) : member( _member ) {}
- virtual void set( C& p, std::string const& stringValue ) const {
- convertInto( stringValue, p.*member );
- }
- virtual bool takesArg() const { return !IsBool<M>::value; }
- virtual IArgFunction<C>* clone() const { return new BoundDataMember( *this ); }
- M C::* member;
- };
- template<typename C, typename M>
- struct BoundUnaryMethod : IArgFunction<C>{
- BoundUnaryMethod( void (C::*_member)( M ) ) : member( _member ) {}
- virtual void set( C& p, std::string const& stringValue ) const {
- typename RemoveConstRef<M>::type value;
- convertInto( stringValue, value );
- (p.*member)( value );
- }
- virtual bool takesArg() const { return !IsBool<M>::value; }
- virtual IArgFunction<C>* clone() const { return new BoundUnaryMethod( *this ); }
- void (C::*member)( M );
- };
- template<typename C>
- struct BoundNullaryMethod : IArgFunction<C>{
- BoundNullaryMethod( void (C::*_member)() ) : member( _member ) {}
- virtual void set( C& p, std::string const& stringValue ) const {
- bool value;
- convertInto( stringValue, value );
- if( value )
- (p.*member)();
- }
- virtual bool takesArg() const { return false; }
- virtual IArgFunction<C>* clone() const { return new BoundNullaryMethod( *this ); }
- void (C::*member)();
- };
-
- template<typename C>
- struct BoundUnaryFunction : IArgFunction<C>{
- BoundUnaryFunction( void (*_function)( C& ) ) : function( _function ) {}
- virtual void set( C& obj, std::string const& stringValue ) const {
- bool value;
- convertInto( stringValue, value );
- if( value )
- function( obj );
- }
- virtual bool takesArg() const { return false; }
- virtual IArgFunction<C>* clone() const { return new BoundUnaryFunction( *this ); }
- void (*function)( C& );
- };
-
- template<typename C, typename T>
- struct BoundBinaryFunction : IArgFunction<C>{
- BoundBinaryFunction( void (*_function)( C&, T ) ) : function( _function ) {}
- virtual void set( C& obj, std::string const& stringValue ) const {
- typename RemoveConstRef<T>::type value;
- convertInto( stringValue, value );
- function( obj, value );
- }
- virtual bool takesArg() const { return !IsBool<T>::value; }
- virtual IArgFunction<C>* clone() const { return new BoundBinaryFunction( *this ); }
- void (*function)( C&, T );
- };
-
- } // namespace Detail
-
- inline std::vector<std::string> argsToVector( int argc, char const* const* const argv ) {
- std::vector<std::string> args( static_cast<std::size_t>( argc ) );
- for( std::size_t i = 0; i < static_cast<std::size_t>( argc ); ++i )
- args[i] = argv[i];
-
- return args;
- }
-
- class Parser {
- enum Mode { None, MaybeShortOpt, SlashOpt, ShortOpt, LongOpt, Positional };
- Mode mode;
- std::size_t from;
- bool inQuotes;
- public:
-
- struct Token {
- enum Type { Positional, ShortOpt, LongOpt };
- Token( Type _type, std::string const& _data ) : type( _type ), data( _data ) {}
- Type type;
- std::string data;
- };
-
- Parser() : mode( None ), from( 0 ), inQuotes( false ){}
-
- void parseIntoTokens( std::vector<std::string> const& args, std::vector<Token>& tokens ) {
- const std::string doubleDash = "--";
- for( std::size_t i = 1; i < args.size() && args[i] != doubleDash; ++i )
- parseIntoTokens( args[i], tokens);
- }
-
- void parseIntoTokens( std::string const& arg, std::vector<Token>& tokens ) {
- for( std::size_t i = 0; i <= arg.size(); ++i ) {
- char c = arg[i];
- if( c == '"' )
- inQuotes = !inQuotes;
- mode = handleMode( i, c, arg, tokens );
- }
- }
- Mode handleMode( std::size_t i, char c, std::string const& arg, std::vector<Token>& tokens ) {
- switch( mode ) {
- case None: return handleNone( i, c );
- case MaybeShortOpt: return handleMaybeShortOpt( i, c );
- case ShortOpt:
- case LongOpt:
- case SlashOpt: return handleOpt( i, c, arg, tokens );
- case Positional: return handlePositional( i, c, arg, tokens );
- default: throw std::logic_error( "Unknown mode" );
- }
- }
-
- Mode handleNone( std::size_t i, char c ) {
- if( inQuotes ) {
- from = i;
- return Positional;
- }
- switch( c ) {
- case '-': return MaybeShortOpt;
-#ifdef CLARA_PLATFORM_WINDOWS
- case '/': from = i+1; return SlashOpt;
-#endif
- default: from = i; return Positional;
- }
- }
- Mode handleMaybeShortOpt( std::size_t i, char c ) {
- switch( c ) {
- case '-': from = i+1; return LongOpt;
- default: from = i; return ShortOpt;
- }
- }
- Mode handleOpt( std::size_t i, char c, std::string const& arg, std::vector<Token>& tokens ) {
- if( std::string( " \t:=\0", 5 ).find( c ) == std::string::npos )
- return mode;
-
- std::string optName = arg.substr( from, i-from );
- if( mode == ShortOpt )
- for( std::size_t j = 0; j < optName.size(); ++j )
- tokens.push_back( Token( Token::ShortOpt, optName.substr( j, 1 ) ) );
- else if( mode == SlashOpt && optName.size() == 1 )
- tokens.push_back( Token( Token::ShortOpt, optName ) );
- else
- tokens.push_back( Token( Token::LongOpt, optName ) );
- return None;
- }
- Mode handlePositional( std::size_t i, char c, std::string const& arg, std::vector<Token>& tokens ) {
- if( inQuotes || std::string( " \t\0", 3 ).find( c ) == std::string::npos )
- return mode;
-
- std::string data = arg.substr( from, i-from );
- tokens.push_back( Token( Token::Positional, data ) );
- return None;
- }
- };
-
- template<typename ConfigT>
- struct CommonArgProperties {
- CommonArgProperties() {}
- CommonArgProperties( Detail::BoundArgFunction<ConfigT> const& _boundField ) : boundField( _boundField ) {}
-
- Detail::BoundArgFunction<ConfigT> boundField;
- std::string description;
- std::string detail;
- std::string placeholder; // Only value if boundField takes an arg
-
- bool takesArg() const {
- return !placeholder.empty();
- }
- void validate() const {
- if( !boundField.isSet() )
- throw std::logic_error( "option not bound" );
- }
- };
- struct OptionArgProperties {
- std::vector<std::string> shortNames;
- std::string longName;
-
- bool hasShortName( std::string const& shortName ) const {
- return std::find( shortNames.begin(), shortNames.end(), shortName ) != shortNames.end();
- }
- bool hasLongName( std::string const& _longName ) const {
- return _longName == longName;
- }
- };
- struct PositionalArgProperties {
- PositionalArgProperties() : position( -1 ) {}
- int position; // -1 means non-positional (floating)
-
- bool isFixedPositional() const {
- return position != -1;
- }
- };
-
- template<typename ConfigT>
- class CommandLine {
-
- struct Arg : CommonArgProperties<ConfigT>, OptionArgProperties, PositionalArgProperties {
- Arg() {}
- Arg( Detail::BoundArgFunction<ConfigT> const& _boundField ) : CommonArgProperties<ConfigT>( _boundField ) {}
-
- using CommonArgProperties<ConfigT>::placeholder; // !TBD
-
- std::string dbgName() const {
- if( !longName.empty() )
- return "--" + longName;
- if( !shortNames.empty() )
- return "-" + shortNames[0];
- return "positional args";
- }
- std::string commands() const {
- std::ostringstream oss;
- bool first = true;
- std::vector<std::string>::const_iterator it = shortNames.begin(), itEnd = shortNames.end();
- for(; it != itEnd; ++it ) {
- if( first )
- first = false;
- else
- oss << ", ";
- oss << "-" << *it;
- }
- if( !longName.empty() ) {
- if( !first )
- oss << ", ";
- oss << "--" << longName;
- }
- if( !placeholder.empty() )
- oss << " <" << placeholder << ">";
- return oss.str();
- }
- };
-
- typedef CLARA_AUTO_PTR( Arg ) ArgAutoPtr;
-
- friend void addOptName( Arg& arg, std::string const& optName )
- {
- if( optName.empty() )
- return;
- if( Detail::startsWith( optName, "--" ) ) {
- if( !arg.longName.empty() )
- throw std::logic_error( "Only one long opt may be specified. '"
- + arg.longName
- + "' already specified, now attempting to add '"
- + optName + "'" );
- arg.longName = optName.substr( 2 );
- }
- else if( Detail::startsWith( optName, "-" ) )
- arg.shortNames.push_back( optName.substr( 1 ) );
- else
- throw std::logic_error( "option must begin with - or --. Option was: '" + optName + "'" );
- }
- friend void setPositionalArg( Arg& arg, int position )
- {
- arg.position = position;
- }
-
- class ArgBuilder {
- public:
- ArgBuilder( Arg* arg ) : m_arg( arg ) {}
-
- // Bind a non-boolean data member (requires placeholder string)
- template<typename C, typename M>
- void bind( M C::* field, std::string const& placeholder ) {
- m_arg->boundField = new Detail::BoundDataMember<C,M>( field );
- m_arg->placeholder = placeholder;
- }
- // Bind a boolean data member (no placeholder required)
- template<typename C>
- void bind( bool C::* field ) {
- m_arg->boundField = new Detail::BoundDataMember<C,bool>( field );
- }
-
- // Bind a method taking a single, non-boolean argument (requires a placeholder string)
- template<typename C, typename M>
- void bind( void (C::* unaryMethod)( M ), std::string const& placeholder ) {
- m_arg->boundField = new Detail::BoundUnaryMethod<C,M>( unaryMethod );
- m_arg->placeholder = placeholder;
- }
-
- // Bind a method taking a single, boolean argument (no placeholder string required)
- template<typename C>
- void bind( void (C::* unaryMethod)( bool ) ) {
- m_arg->boundField = new Detail::BoundUnaryMethod<C,bool>( unaryMethod );
- }
-
- // Bind a method that takes no arguments (will be called if opt is present)
- template<typename C>
- void bind( void (C::* nullaryMethod)() ) {
- m_arg->boundField = new Detail::BoundNullaryMethod<C>( nullaryMethod );
- }
-
- // Bind a free function taking a single argument - the object to operate on (no placeholder string required)
- template<typename C>
- void bind( void (* unaryFunction)( C& ) ) {
- m_arg->boundField = new Detail::BoundUnaryFunction<C>( unaryFunction );
- }
-
- // Bind a free function taking a single argument - the object to operate on (requires a placeholder string)
- template<typename C, typename T>
- void bind( void (* binaryFunction)( C&, T ), std::string const& placeholder ) {
- m_arg->boundField = new Detail::BoundBinaryFunction<C, T>( binaryFunction );
- m_arg->placeholder = placeholder;
- }
-
- ArgBuilder& describe( std::string const& description ) {
- m_arg->description = description;
- return *this;
- }
- ArgBuilder& detail( std::string const& detail ) {
- m_arg->detail = detail;
- return *this;
- }
-
- protected:
- Arg* m_arg;
- };
-
- class OptBuilder : public ArgBuilder {
- public:
- OptBuilder( Arg* arg ) : ArgBuilder( arg ) {}
- OptBuilder( OptBuilder& other ) : ArgBuilder( other ) {}
-
- OptBuilder& operator[]( std::string const& optName ) {
- addOptName( *ArgBuilder::m_arg, optName );
- return *this;
- }
- };
-
- public:
-
- CommandLine()
- : m_boundProcessName( new Detail::NullBinder<ConfigT>() ),
- m_highestSpecifiedArgPosition( 0 ),
- m_throwOnUnrecognisedTokens( false )
- {}
- CommandLine( CommandLine const& other )
- : m_boundProcessName( other.m_boundProcessName ),
- m_options ( other.m_options ),
- m_positionalArgs( other.m_positionalArgs ),
- m_highestSpecifiedArgPosition( other.m_highestSpecifiedArgPosition ),
- m_throwOnUnrecognisedTokens( other.m_throwOnUnrecognisedTokens )
- {
- if( other.m_floatingArg.get() )
- m_floatingArg.reset( new Arg( *other.m_floatingArg ) );
- }
-
- CommandLine& setThrowOnUnrecognisedTokens( bool shouldThrow = true ) {
- m_throwOnUnrecognisedTokens = shouldThrow;
- return *this;
- }
-
- OptBuilder operator[]( std::string const& optName ) {
- m_options.push_back( Arg() );
- addOptName( m_options.back(), optName );
- OptBuilder builder( &m_options.back() );
- return builder;
- }
-
- ArgBuilder operator[]( int position ) {
- m_positionalArgs.insert( std::make_pair( position, Arg() ) );
- if( position > m_highestSpecifiedArgPosition )
- m_highestSpecifiedArgPosition = position;
- setPositionalArg( m_positionalArgs[position], position );
- ArgBuilder builder( &m_positionalArgs[position] );
- return builder;
- }
-
- // Invoke this with the _ instance
- ArgBuilder operator[]( UnpositionalTag ) {
- if( m_floatingArg.get() )
- throw std::logic_error( "Only one unpositional argument can be added" );
- m_floatingArg.reset( new Arg() );
- ArgBuilder builder( m_floatingArg.get() );
- return builder;
- }
-
- template<typename C, typename M>
- void bindProcessName( M C::* field ) {
- m_boundProcessName = new Detail::BoundDataMember<C,M>( field );
- }
- template<typename C, typename M>
- void bindProcessName( void (C::*_unaryMethod)( M ) ) {
- m_boundProcessName = new Detail::BoundUnaryMethod<C,M>( _unaryMethod );
- }
-
- void optUsage( std::ostream& os, std::size_t indent = 0, std::size_t width = Detail::consoleWidth ) const {
- typename std::vector<Arg>::const_iterator itBegin = m_options.begin(), itEnd = m_options.end(), it;
- std::size_t maxWidth = 0;
- for( it = itBegin; it != itEnd; ++it )
- maxWidth = (std::max)( maxWidth, it->commands().size() );
-
- for( it = itBegin; it != itEnd; ++it ) {
- Detail::Text usage( it->commands(), Detail::TextAttributes()
- .setWidth( maxWidth+indent )
- .setIndent( indent ) );
- Detail::Text desc( it->description, Detail::TextAttributes()
- .setWidth( width - maxWidth - 3 ) );
-
- for( std::size_t i = 0; i < (std::max)( usage.size(), desc.size() ); ++i ) {
- std::string usageCol = i < usage.size() ? usage[i] : "";
- os << usageCol;
-
- if( i < desc.size() && !desc[i].empty() )
- os << std::string( indent + 2 + maxWidth - usageCol.size(), ' ' )
- << desc[i];
- os << "\n";
- }
- }
- }
- std::string optUsage() const {
- std::ostringstream oss;
- optUsage( oss );
- return oss.str();
- }
-
- void argSynopsis( std::ostream& os ) const {
- for( int i = 1; i <= m_highestSpecifiedArgPosition; ++i ) {
- if( i > 1 )
- os << " ";
- typename std::map<int, Arg>::const_iterator it = m_positionalArgs.find( i );
- if( it != m_positionalArgs.end() )
- os << "<" << it->second.placeholder << ">";
- else if( m_floatingArg.get() )
- os << "<" << m_floatingArg->placeholder << ">";
- else
- throw std::logic_error( "non consecutive positional arguments with no floating args" );
- }
- // !TBD No indication of mandatory args
- if( m_floatingArg.get() ) {
- if( m_highestSpecifiedArgPosition > 1 )
- os << " ";
- os << "[<" << m_floatingArg->placeholder << "> ...]";
- }
- }
- std::string argSynopsis() const {
- std::ostringstream oss;
- argSynopsis( oss );
- return oss.str();
- }
-
- void usage( std::ostream& os, std::string const& procName ) const {
- validate();
- os << "usage:\n " << procName << " ";
- argSynopsis( os );
- if( !m_options.empty() ) {
- os << " [options]\n\nwhere options are: \n";
- optUsage( os, 2 );
- }
- os << "\n";
- }
- std::string usage( std::string const& procName ) const {
- std::ostringstream oss;
- usage( oss, procName );
- return oss.str();
- }
-
- ConfigT parse( std::vector<std::string> const& args ) const {
- ConfigT config;
- parseInto( args, config );
- return config;
- }
-
- std::vector<Parser::Token> parseInto( std::vector<std::string> const& args, ConfigT& config ) const {
- std::string processName = args[0];
- std::size_t lastSlash = processName.find_last_of( "/\\" );
- if( lastSlash != std::string::npos )
- processName = processName.substr( lastSlash+1 );
- m_boundProcessName.set( config, processName );
- std::vector<Parser::Token> tokens;
- Parser parser;
- parser.parseIntoTokens( args, tokens );
- return populate( tokens, config );
- }
-
- std::vector<Parser::Token> populate( std::vector<Parser::Token> const& tokens, ConfigT& config ) const {
- validate();
- std::vector<Parser::Token> unusedTokens = populateOptions( tokens, config );
- unusedTokens = populateFixedArgs( unusedTokens, config );
- unusedTokens = populateFloatingArgs( unusedTokens, config );
- return unusedTokens;
- }
-
- std::vector<Parser::Token> populateOptions( std::vector<Parser::Token> const& tokens, ConfigT& config ) const {
- std::vector<Parser::Token> unusedTokens;
- std::vector<std::string> errors;
- for( std::size_t i = 0; i < tokens.size(); ++i ) {
- Parser::Token const& token = tokens[i];
- typename std::vector<Arg>::const_iterator it = m_options.begin(), itEnd = m_options.end();
- for(; it != itEnd; ++it ) {
- Arg const& arg = *it;
-
- try {
- if( ( token.type == Parser::Token::ShortOpt && arg.hasShortName( token.data ) ) ||
- ( token.type == Parser::Token::LongOpt && arg.hasLongName( token.data ) ) ) {
- if( arg.takesArg() ) {
- if( i == tokens.size()-1 || tokens[i+1].type != Parser::Token::Positional )
- errors.push_back( "Expected argument to option: " + token.data );
- else
- arg.boundField.set( config, tokens[++i].data );
- }
- else {
- arg.boundField.set( config, "true" );
- }
- break;
- }
- }
- catch( std::exception& ex ) {
- errors.push_back( std::string( ex.what() ) + "\n- while parsing: (" + arg.commands() + ")" );
- }
- }
- if( it == itEnd ) {
- if( token.type == Parser::Token::Positional || !m_throwOnUnrecognisedTokens )
- unusedTokens.push_back( token );
- else if( errors.empty() && m_throwOnUnrecognisedTokens )
- errors.push_back( "unrecognised option: " + token.data );
- }
- }
- if( !errors.empty() ) {
- std::ostringstream oss;
- for( std::vector<std::string>::const_iterator it = errors.begin(), itEnd = errors.end();
- it != itEnd;
- ++it ) {
- if( it != errors.begin() )
- oss << "\n";
- oss << *it;
- }
- throw std::runtime_error( oss.str() );
- }
- return unusedTokens;
- }
- std::vector<Parser::Token> populateFixedArgs( std::vector<Parser::Token> const& tokens, ConfigT& config ) const {
- std::vector<Parser::Token> unusedTokens;
- int position = 1;
- for( std::size_t i = 0; i < tokens.size(); ++i ) {
- Parser::Token const& token = tokens[i];
- typename std::map<int, Arg>::const_iterator it = m_positionalArgs.find( position );
- if( it != m_positionalArgs.end() )
- it->second.boundField.set( config, token.data );
- else
- unusedTokens.push_back( token );
- if( token.type == Parser::Token::Positional )
- position++;
- }
- return unusedTokens;
- }
- std::vector<Parser::Token> populateFloatingArgs( std::vector<Parser::Token> const& tokens, ConfigT& config ) const {
- if( !m_floatingArg.get() )
- return tokens;
- std::vector<Parser::Token> unusedTokens;
- for( std::size_t i = 0; i < tokens.size(); ++i ) {
- Parser::Token const& token = tokens[i];
- if( token.type == Parser::Token::Positional )
- m_floatingArg->boundField.set( config, token.data );
- else
- unusedTokens.push_back( token );
- }
- return unusedTokens;
- }
-
- void validate() const
- {
- if( m_options.empty() && m_positionalArgs.empty() && !m_floatingArg.get() )
- throw std::logic_error( "No options or arguments specified" );
-
- for( typename std::vector<Arg>::const_iterator it = m_options.begin(),
- itEnd = m_options.end();
- it != itEnd; ++it )
- it->validate();
- }
-
- private:
- Detail::BoundArgFunction<ConfigT> m_boundProcessName;
- std::vector<Arg> m_options;
- std::map<int, Arg> m_positionalArgs;
- ArgAutoPtr m_floatingArg;
- int m_highestSpecifiedArgPosition;
- bool m_throwOnUnrecognisedTokens;
- };
-
-} // end namespace Clara
-
-STITCH_CLARA_CLOSE_NAMESPACE
-#undef STITCH_CLARA_OPEN_NAMESPACE
-#undef STITCH_CLARA_CLOSE_NAMESPACE
-
-#endif // TWOBLUECUBES_CLARA_H_INCLUDED
-#undef STITCH_CLARA_OPEN_NAMESPACE
-
-// Restore Clara's value for console width, if present
-#ifdef CATCH_TEMP_CLARA_CONFIG_CONSOLE_WIDTH
-#define CLARA_CONFIG_CONSOLE_WIDTH CATCH_TEMP_CLARA_CONFIG_CONSOLE_WIDTH
-#undef CATCH_TEMP_CLARA_CONFIG_CONSOLE_WIDTH
-#endif
-
-#include <fstream>
-
-namespace Catch {
-
- inline void abortAfterFirst( ConfigData& config ) { config.abortAfter = 1; }
- inline void abortAfterX( ConfigData& config, int x ) {
- if( x < 1 )
- throw std::runtime_error( "Value after -x or --abortAfter must be greater than zero" );
- config.abortAfter = x;
- }
- inline void addTestOrTags( ConfigData& config, std::string const& _testSpec ) { config.testsOrTags.push_back( _testSpec ); }
- inline void addReporterName( ConfigData& config, std::string const& _reporterName ) { config.reporterNames.push_back( _reporterName ); }
-
- inline void addWarning( ConfigData& config, std::string const& _warning ) {
- if( _warning == "NoAssertions" )
- config.warnings = static_cast<WarnAbout::What>( config.warnings | WarnAbout::NoAssertions );
- else
- throw std::runtime_error( "Unrecognised warning: '" + _warning + "'" );
- }
- inline void setOrder( ConfigData& config, std::string const& order ) {
- if( startsWith( "declared", order ) )
- config.runOrder = RunTests::InDeclarationOrder;
- else if( startsWith( "lexical", order ) )
- config.runOrder = RunTests::InLexicographicalOrder;
- else if( startsWith( "random", order ) )
- config.runOrder = RunTests::InRandomOrder;
- else
- throw std::runtime_error( "Unrecognised ordering: '" + order + "'" );
- }
- inline void setRngSeed( ConfigData& config, std::string const& seed ) {
- if( seed == "time" ) {
- config.rngSeed = static_cast<unsigned int>( std::time(0) );
- }
- else {
- std::stringstream ss;
- ss << seed;
- ss >> config.rngSeed;
- if( ss.fail() )
- throw std::runtime_error( "Argment to --rng-seed should be the word 'time' or a number" );
- }
- }
- inline void setVerbosity( ConfigData& config, int level ) {
- // !TBD: accept strings?
- config.verbosity = static_cast<Verbosity::Level>( level );
- }
- inline void setShowDurations( ConfigData& config, bool _showDurations ) {
- config.showDurations = _showDurations
- ? ShowDurations::Always
- : ShowDurations::Never;
- }
- inline void setUseColour( ConfigData& config, std::string const& value ) {
- std::string mode = toLower( value );
-
- if( mode == "yes" )
- config.useColour = UseColour::Yes;
- else if( mode == "no" )
- config.useColour = UseColour::No;
- else if( mode == "auto" )
- config.useColour = UseColour::Auto;
- else
- throw std::runtime_error( "colour mode must be one of: auto, yes or no" );
- }
- inline void forceColour( ConfigData& config ) {
- config.useColour = UseColour::Yes;
- }
- inline void loadTestNamesFromFile( ConfigData& config, std::string const& _filename ) {
- std::ifstream f( _filename.c_str() );
- if( !f.is_open() )
- throw std::domain_error( "Unable to load input file: " + _filename );
-
- std::string line;
- while( std::getline( f, line ) ) {
- line = trim(line);
- if( !line.empty() && !startsWith( line, "#" ) )
- addTestOrTags( config, "\"" + line + "\"," );
- }
- }
-
- inline Clara::CommandLine<ConfigData> makeCommandLineParser() {
-
- using namespace Clara;
- CommandLine<ConfigData> cli;
-
- cli.bindProcessName( &ConfigData::processName );
-
- cli["-?"]["-h"]["--help"]
- .describe( "display usage information" )
- .bind( &ConfigData::showHelp );
-
- cli["-l"]["--list-tests"]
- .describe( "list all/matching test cases" )
- .bind( &ConfigData::listTests );
-
- cli["-t"]["--list-tags"]
- .describe( "list all/matching tags" )
- .bind( &ConfigData::listTags );
-
- cli["-s"]["--success"]
- .describe( "include successful tests in output" )
- .bind( &ConfigData::showSuccessfulTests );
-
- cli["-b"]["--break"]
- .describe( "break into debugger on failure" )
- .bind( &ConfigData::shouldDebugBreak );
-
- cli["-e"]["--nothrow"]
- .describe( "skip exception tests" )
- .bind( &ConfigData::noThrow );
-
- cli["-i"]["--invisibles"]
- .describe( "show invisibles (tabs, newlines)" )
- .bind( &ConfigData::showInvisibles );
-
- cli["-o"]["--out"]
- .describe( "output filename" )
- .bind( &ConfigData::outputFilename, "filename" );
-
- cli["-r"]["--reporter"]
-// .placeholder( "name[:filename]" )
- .describe( "reporter to use (defaults to console)" )
- .bind( &addReporterName, "name" );
-
- cli["-n"]["--name"]
- .describe( "suite name" )
- .bind( &ConfigData::name, "name" );
-
- cli["-a"]["--abort"]
- .describe( "abort at first failure" )
- .bind( &abortAfterFirst );
-
- cli["-x"]["--abortx"]
- .describe( "abort after x failures" )
- .bind( &abortAfterX, "no. failures" );
-
- cli["-w"]["--warn"]
- .describe( "enable warnings" )
- .bind( &addWarning, "warning name" );
-
-// - needs updating if reinstated
-// cli.into( &setVerbosity )
-// .describe( "level of verbosity (0=no output)" )
-// .shortOpt( "v")
-// .longOpt( "verbosity" )
-// .placeholder( "level" );
-
- cli[_]
- .describe( "which test or tests to use" )
- .bind( &addTestOrTags, "test name, pattern or tags" );
-
- cli["-d"]["--durations"]
- .describe( "show test durations" )
- .bind( &setShowDurations, "yes|no" );
-
- cli["-f"]["--input-file"]
- .describe( "load test names to run from a file" )
- .bind( &loadTestNamesFromFile, "filename" );
-
- cli["-#"]["--filenames-as-tags"]
- .describe( "adds a tag for the filename" )
- .bind( &ConfigData::filenamesAsTags );
-
- // Less common commands which don't have a short form
- cli["--list-test-names-only"]
- .describe( "list all/matching test cases names only" )
- .bind( &ConfigData::listTestNamesOnly );
-
- cli["--list-reporters"]
- .describe( "list all reporters" )
- .bind( &ConfigData::listReporters );
-
- cli["--order"]
- .describe( "test case order (defaults to decl)" )
- .bind( &setOrder, "decl|lex|rand" );
-
- cli["--rng-seed"]
- .describe( "set a specific seed for random numbers" )
- .bind( &setRngSeed, "'time'|number" );
-
- cli["--force-colour"]
- .describe( "force colourised output (deprecated)" )
- .bind( &forceColour );
-
- cli["--use-colour"]
- .describe( "should output be colourised" )
- .bind( &setUseColour, "yes|no" );
-
- return cli;
- }
-
-} // end namespace Catch
-
-// #included from: internal/catch_list.hpp
-#define TWOBLUECUBES_CATCH_LIST_HPP_INCLUDED
-
-// #included from: catch_text.h
-#define TWOBLUECUBES_CATCH_TEXT_H_INCLUDED
-
-#define TBC_TEXT_FORMAT_CONSOLE_WIDTH CATCH_CONFIG_CONSOLE_WIDTH
-
-#define CLICHE_TBC_TEXT_FORMAT_OUTER_NAMESPACE Catch
-// #included from: ../external/tbc_text_format.h
-// Only use header guard if we are not using an outer namespace
-#ifndef CLICHE_TBC_TEXT_FORMAT_OUTER_NAMESPACE
-# ifdef TWOBLUECUBES_TEXT_FORMAT_H_INCLUDED
-# ifndef TWOBLUECUBES_TEXT_FORMAT_H_ALREADY_INCLUDED
-# define TWOBLUECUBES_TEXT_FORMAT_H_ALREADY_INCLUDED
-# endif
-# else
-# define TWOBLUECUBES_TEXT_FORMAT_H_INCLUDED
-# endif
-#endif
-#ifndef TWOBLUECUBES_TEXT_FORMAT_H_ALREADY_INCLUDED
-#include <string>
-#include <vector>
-#include <sstream>
-
-// Use optional outer namespace
-#ifdef CLICHE_TBC_TEXT_FORMAT_OUTER_NAMESPACE
-namespace CLICHE_TBC_TEXT_FORMAT_OUTER_NAMESPACE {
-#endif
-
-namespace Tbc {
-
-#ifdef TBC_TEXT_FORMAT_CONSOLE_WIDTH
- const unsigned int consoleWidth = TBC_TEXT_FORMAT_CONSOLE_WIDTH;
-#else
- const unsigned int consoleWidth = 80;
-#endif
-
- struct TextAttributes {
- TextAttributes()
- : initialIndent( std::string::npos ),
- indent( 0 ),
- width( consoleWidth-1 ),
- tabChar( '\t' )
- {}
-
- TextAttributes& setInitialIndent( std::size_t _value ) { initialIndent = _value; return *this; }
- TextAttributes& setIndent( std::size_t _value ) { indent = _value; return *this; }
- TextAttributes& setWidth( std::size_t _value ) { width = _value; return *this; }
- TextAttributes& setTabChar( char _value ) { tabChar = _value; return *this; }
-
- std::size_t initialIndent; // indent of first line, or npos
- std::size_t indent; // indent of subsequent lines, or all if initialIndent is npos
- std::size_t width; // maximum width of text, including indent. Longer text will wrap
- char tabChar; // If this char is seen the indent is changed to current pos
- };
-
- class Text {
- public:
- Text( std::string const& _str, TextAttributes const& _attr = TextAttributes() )
- : attr( _attr )
- {
- std::string wrappableChars = " [({.,/|\\-";
- std::size_t indent = _attr.initialIndent != std::string::npos
- ? _attr.initialIndent
- : _attr.indent;
- std::string remainder = _str;
-
- while( !remainder.empty() ) {
- if( lines.size() >= 1000 ) {
- lines.push_back( "... message truncated due to excessive size" );
- return;
- }
- std::size_t tabPos = std::string::npos;
- std::size_t width = (std::min)( remainder.size(), _attr.width - indent );
- std::size_t pos = remainder.find_first_of( '\n' );
- if( pos <= width ) {
- width = pos;
- }
- pos = remainder.find_last_of( _attr.tabChar, width );
- if( pos != std::string::npos ) {
- tabPos = pos;
- if( remainder[width] == '\n' )
- width--;
- remainder = remainder.substr( 0, tabPos ) + remainder.substr( tabPos+1 );
- }
-
- if( width == remainder.size() ) {
- spliceLine( indent, remainder, width );
- }
- else if( remainder[width] == '\n' ) {
- spliceLine( indent, remainder, width );
- if( width <= 1 || remainder.size() != 1 )
- remainder = remainder.substr( 1 );
- indent = _attr.indent;
- }
- else {
- pos = remainder.find_last_of( wrappableChars, width );
- if( pos != std::string::npos && pos > 0 ) {
- spliceLine( indent, remainder, pos );
- if( remainder[0] == ' ' )
- remainder = remainder.substr( 1 );
- }
- else {
- spliceLine( indent, remainder, width-1 );
- lines.back() += "-";
- }
- if( lines.size() == 1 )
- indent = _attr.indent;
- if( tabPos != std::string::npos )
- indent += tabPos;
- }
- }
- }
-
- void spliceLine( std::size_t _indent, std::string& _remainder, std::size_t _pos ) {
- lines.push_back( std::string( _indent, ' ' ) + _remainder.substr( 0, _pos ) );
- _remainder = _remainder.substr( _pos );
- }
-
- typedef std::vector<std::string>::const_iterator const_iterator;
-
- const_iterator begin() const { return lines.begin(); }
- const_iterator end() const { return lines.end(); }
- std::string const& last() const { return lines.back(); }
- std::size_t size() const { return lines.size(); }
- std::string const& operator[]( std::size_t _index ) const { return lines[_index]; }
- std::string toString() const {
- std::ostringstream oss;
- oss << *this;
- return oss.str();
- }
-
- inline friend std::ostream& operator << ( std::ostream& _stream, Text const& _text ) {
- for( Text::const_iterator it = _text.begin(), itEnd = _text.end();
- it != itEnd; ++it ) {
- if( it != _text.begin() )
- _stream << "\n";
- _stream << *it;
- }
- return _stream;
- }
-
- private:
- std::string str;
- TextAttributes attr;
- std::vector<std::string> lines;
- };
-
-} // end namespace Tbc
-
-#ifdef CLICHE_TBC_TEXT_FORMAT_OUTER_NAMESPACE
-} // end outer namespace
-#endif
-
-#endif // TWOBLUECUBES_TEXT_FORMAT_H_ALREADY_INCLUDED
-#undef CLICHE_TBC_TEXT_FORMAT_OUTER_NAMESPACE
-
-namespace Catch {
- using Tbc::Text;
- using Tbc::TextAttributes;
-}
-
-// #included from: catch_console_colour.hpp
-#define TWOBLUECUBES_CATCH_CONSOLE_COLOUR_HPP_INCLUDED
-
-namespace Catch {
-
- struct Colour {
- enum Code {
- None = 0,
-
- White,
- Red,
- Green,
- Blue,
- Cyan,
- Yellow,
- Grey,
-
- Bright = 0x10,
-
- BrightRed = Bright | Red,
- BrightGreen = Bright | Green,
- LightGrey = Bright | Grey,
- BrightWhite = Bright | White,
-
- // By intention
- FileName = LightGrey,
- Warning = Yellow,
- ResultError = BrightRed,
- ResultSuccess = BrightGreen,
- ResultExpectedFailure = Warning,
-
- Error = BrightRed,
- Success = Green,
-
- OriginalExpression = Cyan,
- ReconstructedExpression = Yellow,
-
- SecondaryText = LightGrey,
- Headers = White
- };
-
- // Use constructed object for RAII guard
- Colour( Code _colourCode );
- Colour( Colour const& other );
- ~Colour();
-
- // Use static method for one-shot changes
- static void use( Code _colourCode );
-
- private:
- bool m_moved;
- };
-
- inline std::ostream& operator << ( std::ostream& os, Colour const& ) { return os; }
-
-} // end namespace Catch
-
-// #included from: catch_interfaces_reporter.h
-#define TWOBLUECUBES_CATCH_INTERFACES_REPORTER_H_INCLUDED
-
-#include <string>
-#include <ostream>
-#include <map>
-#include <assert.h>
-
-namespace Catch
-{
- struct ReporterConfig {
- explicit ReporterConfig( Ptr<IConfig const> const& _fullConfig )
- : m_stream( &_fullConfig->stream() ), m_fullConfig( _fullConfig ) {}
-
- ReporterConfig( Ptr<IConfig const> const& _fullConfig, std::ostream& _stream )
- : m_stream( &_stream ), m_fullConfig( _fullConfig ) {}
-
- std::ostream& stream() const { return *m_stream; }
- Ptr<IConfig const> fullConfig() const { return m_fullConfig; }
-
- private:
- std::ostream* m_stream;
- Ptr<IConfig const> m_fullConfig;
- };
-
- struct ReporterPreferences {
- ReporterPreferences()
- : shouldRedirectStdOut( false )
- {}
-
- bool shouldRedirectStdOut;
- };
-
- template<typename T>
- struct LazyStat : Option<T> {
- LazyStat() : used( false ) {}
- LazyStat& operator=( T const& _value ) {
- Option<T>::operator=( _value );
- used = false;
- return *this;
- }
- void reset() {
- Option<T>::reset();
- used = false;
- }
- bool used;
- };
-
- struct TestRunInfo {
- TestRunInfo( std::string const& _name ) : name( _name ) {}
- std::string name;
- };
- struct GroupInfo {
- GroupInfo( std::string const& _name,
- std::size_t _groupIndex,
- std::size_t _groupsCount )
- : name( _name ),
- groupIndex( _groupIndex ),
- groupsCounts( _groupsCount )
- {}
-
- std::string name;
- std::size_t groupIndex;
- std::size_t groupsCounts;
- };
-
- struct AssertionStats {
- AssertionStats( AssertionResult const& _assertionResult,
- std::vector<MessageInfo> const& _infoMessages,
- Totals const& _totals )
- : assertionResult( _assertionResult ),
- infoMessages( _infoMessages ),
- totals( _totals )
- {
- if( assertionResult.hasMessage() ) {
- // Copy message into messages list.
- // !TBD This should have been done earlier, somewhere
- MessageBuilder builder( assertionResult.getTestMacroName(), assertionResult.getSourceInfo(), assertionResult.getResultType() );
- builder << assertionResult.getMessage();
- builder.m_info.message = builder.m_stream.str();
-
- infoMessages.push_back( builder.m_info );
- }
- }
- virtual ~AssertionStats();
-
-# ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS
- AssertionStats( AssertionStats const& ) = default;
- AssertionStats( AssertionStats && ) = default;
- AssertionStats& operator = ( AssertionStats const& ) = default;
- AssertionStats& operator = ( AssertionStats && ) = default;
-# endif
-
- AssertionResult assertionResult;
- std::vector<MessageInfo> infoMessages;
- Totals totals;
- };
-
- struct SectionStats {
- SectionStats( SectionInfo const& _sectionInfo,
- Counts const& _assertions,
- double _durationInSeconds,
- bool _missingAssertions )
- : sectionInfo( _sectionInfo ),
- assertions( _assertions ),
- durationInSeconds( _durationInSeconds ),
- missingAssertions( _missingAssertions )
- {}
- virtual ~SectionStats();
-# ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS
- SectionStats( SectionStats const& ) = default;
- SectionStats( SectionStats && ) = default;
- SectionStats& operator = ( SectionStats const& ) = default;
- SectionStats& operator = ( SectionStats && ) = default;
-# endif
-
- SectionInfo sectionInfo;
- Counts assertions;
- double durationInSeconds;
- bool missingAssertions;
- };
-
- struct TestCaseStats {
- TestCaseStats( TestCaseInfo const& _testInfo,
- Totals const& _totals,
- std::string const& _stdOut,
- std::string const& _stdErr,
- bool _aborting )
- : testInfo( _testInfo ),
- totals( _totals ),
- stdOut( _stdOut ),
- stdErr( _stdErr ),
- aborting( _aborting )
- {}
- virtual ~TestCaseStats();
-
-# ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS
- TestCaseStats( TestCaseStats const& ) = default;
- TestCaseStats( TestCaseStats && ) = default;
- TestCaseStats& operator = ( TestCaseStats const& ) = default;
- TestCaseStats& operator = ( TestCaseStats && ) = default;
-# endif
-
- TestCaseInfo testInfo;
- Totals totals;
- std::string stdOut;
- std::string stdErr;
- bool aborting;
- };
-
- struct TestGroupStats {
- TestGroupStats( GroupInfo const& _groupInfo,
- Totals const& _totals,
- bool _aborting )
- : groupInfo( _groupInfo ),
- totals( _totals ),
- aborting( _aborting )
- {}
- TestGroupStats( GroupInfo const& _groupInfo )
- : groupInfo( _groupInfo ),
- aborting( false )
- {}
- virtual ~TestGroupStats();
-
-# ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS
- TestGroupStats( TestGroupStats const& ) = default;
- TestGroupStats( TestGroupStats && ) = default;
- TestGroupStats& operator = ( TestGroupStats const& ) = default;
- TestGroupStats& operator = ( TestGroupStats && ) = default;
-# endif
-
- GroupInfo groupInfo;
- Totals totals;
- bool aborting;
- };
-
- struct TestRunStats {
- TestRunStats( TestRunInfo const& _runInfo,
- Totals const& _totals,
- bool _aborting )
- : runInfo( _runInfo ),
- totals( _totals ),
- aborting( _aborting )
- {}
- virtual ~TestRunStats();
-
-# ifndef CATCH_CONFIG_CPP11_GENERATED_METHODS
- TestRunStats( TestRunStats const& _other )
- : runInfo( _other.runInfo ),
- totals( _other.totals ),
- aborting( _other.aborting )
- {}
-# else
- TestRunStats( TestRunStats const& ) = default;
- TestRunStats( TestRunStats && ) = default;
- TestRunStats& operator = ( TestRunStats const& ) = default;
- TestRunStats& operator = ( TestRunStats && ) = default;
-# endif
-
- TestRunInfo runInfo;
- Totals totals;
- bool aborting;
- };
-
- class MultipleReporters;
-
- struct IStreamingReporter : IShared {
- virtual ~IStreamingReporter();
-
- // Implementing class must also provide the following static method:
- // static std::string getDescription();
-
- virtual ReporterPreferences getPreferences() const = 0;
-
- virtual void noMatchingTestCases( std::string const& spec ) = 0;
-
- virtual void testRunStarting( TestRunInfo const& testRunInfo ) = 0;
- virtual void testGroupStarting( GroupInfo const& groupInfo ) = 0;
-
- virtual void testCaseStarting( TestCaseInfo const& testInfo ) = 0;
- virtual void sectionStarting( SectionInfo const& sectionInfo ) = 0;
-
- virtual void assertionStarting( AssertionInfo const& assertionInfo ) = 0;
-
- // The return value indicates if the messages buffer should be cleared:
- virtual bool assertionEnded( AssertionStats const& assertionStats ) = 0;
-
- virtual void sectionEnded( SectionStats const& sectionStats ) = 0;
- virtual void testCaseEnded( TestCaseStats const& testCaseStats ) = 0;
- virtual void testGroupEnded( TestGroupStats const& testGroupStats ) = 0;
- virtual void testRunEnded( TestRunStats const& testRunStats ) = 0;
-
- virtual void skipTest( TestCaseInfo const& testInfo ) = 0;
-
- virtual MultipleReporters* tryAsMulti() { return CATCH_NULL; }
- };
-
- struct IReporterFactory : IShared {
- virtual ~IReporterFactory();
- virtual IStreamingReporter* create( ReporterConfig const& config ) const = 0;
- virtual std::string getDescription() const = 0;
- };
-
- struct IReporterRegistry {
- typedef std::map<std::string, Ptr<IReporterFactory> > FactoryMap;
- typedef std::vector<Ptr<IReporterFactory> > Listeners;
-
- virtual ~IReporterRegistry();
- virtual IStreamingReporter* create( std::string const& name, Ptr<IConfig const> const& config ) const = 0;
- virtual FactoryMap const& getFactories() const = 0;
- virtual Listeners const& getListeners() const = 0;
- };
-
- Ptr<IStreamingReporter> addReporter( Ptr<IStreamingReporter> const& existingReporter, Ptr<IStreamingReporter> const& additionalReporter );
-
-}
-
-#include <limits>
-#include <algorithm>
-
-namespace Catch {
-
- inline std::size_t listTests( Config const& config ) {
-
- TestSpec testSpec = config.testSpec();
- if( config.testSpec().hasFilters() )
- Catch::cout() << "Matching test cases:\n";
- else {
- Catch::cout() << "All available test cases:\n";
- testSpec = TestSpecParser( ITagAliasRegistry::get() ).parse( "*" ).testSpec();
- }
-
- std::size_t matchedTests = 0;
- TextAttributes nameAttr, tagsAttr;
- nameAttr.setInitialIndent( 2 ).setIndent( 4 );
- tagsAttr.setIndent( 6 );
-
- std::vector<TestCase> matchedTestCases = filterTests( getAllTestCasesSorted( config ), testSpec, config );
- for( std::vector<TestCase>::const_iterator it = matchedTestCases.begin(), itEnd = matchedTestCases.end();
- it != itEnd;
- ++it ) {
- matchedTests++;
- TestCaseInfo const& testCaseInfo = it->getTestCaseInfo();
- Colour::Code colour = testCaseInfo.isHidden()
- ? Colour::SecondaryText
- : Colour::None;
- Colour colourGuard( colour );
-
- Catch::cout() << Text( testCaseInfo.name, nameAttr ) << std::endl;
- if( !testCaseInfo.tags.empty() )
- Catch::cout() << Text( testCaseInfo.tagsAsString, tagsAttr ) << std::endl;
- }
-
- if( !config.testSpec().hasFilters() )
- Catch::cout() << pluralise( matchedTests, "test case" ) << "\n" << std::endl;
- else
- Catch::cout() << pluralise( matchedTests, "matching test case" ) << "\n" << std::endl;
- return matchedTests;
- }
-
- inline std::size_t listTestsNamesOnly( Config const& config ) {
- TestSpec testSpec = config.testSpec();
- if( !config.testSpec().hasFilters() )
- testSpec = TestSpecParser( ITagAliasRegistry::get() ).parse( "*" ).testSpec();
- std::size_t matchedTests = 0;
- std::vector<TestCase> matchedTestCases = filterTests( getAllTestCasesSorted( config ), testSpec, config );
- for( std::vector<TestCase>::const_iterator it = matchedTestCases.begin(), itEnd = matchedTestCases.end();
- it != itEnd;
- ++it ) {
- matchedTests++;
- TestCaseInfo const& testCaseInfo = it->getTestCaseInfo();
- Catch::cout() << testCaseInfo.name << std::endl;
- }
- return matchedTests;
- }
-
- struct TagInfo {
- TagInfo() : count ( 0 ) {}
- void add( std::string const& spelling ) {
- ++count;
- spellings.insert( spelling );
- }
- std::string all() const {
- std::string out;
- for( std::set<std::string>::const_iterator it = spellings.begin(), itEnd = spellings.end();
- it != itEnd;
- ++it )
- out += "[" + *it + "]";
- return out;
- }
- std::set<std::string> spellings;
- std::size_t count;
- };
-
- inline std::size_t listTags( Config const& config ) {
- TestSpec testSpec = config.testSpec();
- if( config.testSpec().hasFilters() )
- Catch::cout() << "Tags for matching test cases:\n";
- else {
- Catch::cout() << "All available tags:\n";
- testSpec = TestSpecParser( ITagAliasRegistry::get() ).parse( "*" ).testSpec();
- }
-
- std::map<std::string, TagInfo> tagCounts;
-
- std::vector<TestCase> matchedTestCases = filterTests( getAllTestCasesSorted( config ), testSpec, config );
- for( std::vector<TestCase>::const_iterator it = matchedTestCases.begin(), itEnd = matchedTestCases.end();
- it != itEnd;
- ++it ) {
- for( std::set<std::string>::const_iterator tagIt = it->getTestCaseInfo().tags.begin(),
- tagItEnd = it->getTestCaseInfo().tags.end();
- tagIt != tagItEnd;
- ++tagIt ) {
- std::string tagName = *tagIt;
- std::string lcaseTagName = toLower( tagName );
- std::map<std::string, TagInfo>::iterator countIt = tagCounts.find( lcaseTagName );
- if( countIt == tagCounts.end() )
- countIt = tagCounts.insert( std::make_pair( lcaseTagName, TagInfo() ) ).first;
- countIt->second.add( tagName );
- }
- }
-
- for( std::map<std::string, TagInfo>::const_iterator countIt = tagCounts.begin(),
- countItEnd = tagCounts.end();
- countIt != countItEnd;
- ++countIt ) {
- std::ostringstream oss;
- oss << " " << std::setw(2) << countIt->second.count << " ";
- Text wrapper( countIt->second.all(), TextAttributes()
- .setInitialIndent( 0 )
- .setIndent( oss.str().size() )
- .setWidth( CATCH_CONFIG_CONSOLE_WIDTH-10 ) );
- Catch::cout() << oss.str() << wrapper << "\n";
- }
- Catch::cout() << pluralise( tagCounts.size(), "tag" ) << "\n" << std::endl;
- return tagCounts.size();
- }
-
- inline std::size_t listReporters( Config const& /*config*/ ) {
- Catch::cout() << "Available reporters:\n";
- IReporterRegistry::FactoryMap const& factories = getRegistryHub().getReporterRegistry().getFactories();
- IReporterRegistry::FactoryMap::const_iterator itBegin = factories.begin(), itEnd = factories.end(), it;
- std::size_t maxNameLen = 0;
- for(it = itBegin; it != itEnd; ++it )
- maxNameLen = (std::max)( maxNameLen, it->first.size() );
-
- for(it = itBegin; it != itEnd; ++it ) {
- Text wrapper( it->second->getDescription(), TextAttributes()
- .setInitialIndent( 0 )
- .setIndent( 7+maxNameLen )
- .setWidth( CATCH_CONFIG_CONSOLE_WIDTH - maxNameLen-8 ) );
- Catch::cout() << " "
- << it->first
- << ":"
- << std::string( maxNameLen - it->first.size() + 2, ' ' )
- << wrapper << "\n";
- }
- Catch::cout() << std::endl;
- return factories.size();
- }
-
- inline Option<std::size_t> list( Config const& config ) {
- Option<std::size_t> listedCount;
- if( config.listTests() )
- listedCount = listedCount.valueOr(0) + listTests( config );
- if( config.listTestNamesOnly() )
- listedCount = listedCount.valueOr(0) + listTestsNamesOnly( config );
- if( config.listTags() )
- listedCount = listedCount.valueOr(0) + listTags( config );
- if( config.listReporters() )
- listedCount = listedCount.valueOr(0) + listReporters( config );
- return listedCount;
- }
-
-} // end namespace Catch
-
-// #included from: internal/catch_run_context.hpp
-#define TWOBLUECUBES_CATCH_RUNNER_IMPL_HPP_INCLUDED
-
-// #included from: catch_test_case_tracker.hpp
-#define TWOBLUECUBES_CATCH_TEST_CASE_TRACKER_HPP_INCLUDED
-
-#include <map>
-#include <string>
-#include <assert.h>
-#include <vector>
-
-namespace Catch {
-namespace TestCaseTracking {
-
- struct ITracker : SharedImpl<> {
- virtual ~ITracker();
-
- // static queries
- virtual std::string name() const = 0;
-
- // dynamic queries
- virtual bool isComplete() const = 0; // Successfully completed or failed
- virtual bool isSuccessfullyCompleted() const = 0;
- virtual bool isOpen() const = 0; // Started but not complete
- virtual bool hasChildren() const = 0;
-
- virtual ITracker& parent() = 0;
-
- // actions
- virtual void close() = 0; // Successfully complete
- virtual void fail() = 0;
- virtual void markAsNeedingAnotherRun() = 0;
-
- virtual void addChild( Ptr<ITracker> const& child ) = 0;
- virtual ITracker* findChild( std::string const& name ) = 0;
- virtual void openChild() = 0;
-
- // Debug/ checking
- virtual bool isSectionTracker() const = 0;
- virtual bool isIndexTracker() const = 0;
- };
-
- class TrackerContext {
-
- enum RunState {
- NotStarted,
- Executing,
- CompletedCycle
- };
-
- Ptr<ITracker> m_rootTracker;
- ITracker* m_currentTracker;
- RunState m_runState;
-
- public:
-
- static TrackerContext& instance() {
- static TrackerContext s_instance;
- return s_instance;
- }
-
- TrackerContext()
- : m_currentTracker( CATCH_NULL ),
- m_runState( NotStarted )
- {}
-
- ITracker& startRun();
-
- void endRun() {
- m_rootTracker.reset();
- m_currentTracker = CATCH_NULL;
- m_runState = NotStarted;
- }
-
- void startCycle() {
- m_currentTracker = m_rootTracker.get();
- m_runState = Executing;
- }
- void completeCycle() {
- m_runState = CompletedCycle;
- }
-
- bool completedCycle() const {
- return m_runState == CompletedCycle;
- }
- ITracker& currentTracker() {
- return *m_currentTracker;
- }
- void setCurrentTracker( ITracker* tracker ) {
- m_currentTracker = tracker;
- }
- };
-
- class TrackerBase : public ITracker {
- protected:
- enum CycleState {
- NotStarted,
- Executing,
- ExecutingChildren,
- NeedsAnotherRun,
- CompletedSuccessfully,
- Failed
- };
- class TrackerHasName {
- std::string m_name;
- public:
- TrackerHasName( std::string const& name ) : m_name( name ) {}
- bool operator ()( Ptr<ITracker> const& tracker ) {
- return tracker->name() == m_name;
- }
- };
- typedef std::vector<Ptr<ITracker> > Children;
- std::string m_name;
- TrackerContext& m_ctx;
- ITracker* m_parent;
- Children m_children;
- CycleState m_runState;
- public:
- TrackerBase( std::string const& name, TrackerContext& ctx, ITracker* parent )
- : m_name( name ),
- m_ctx( ctx ),
- m_parent( parent ),
- m_runState( NotStarted )
- {}
- virtual ~TrackerBase();
-
- virtual std::string name() const CATCH_OVERRIDE {
- return m_name;
- }
- virtual bool isComplete() const CATCH_OVERRIDE {
- return m_runState == CompletedSuccessfully || m_runState == Failed;
- }
- virtual bool isSuccessfullyCompleted() const CATCH_OVERRIDE {
- return m_runState == CompletedSuccessfully;
- }
- virtual bool isOpen() const CATCH_OVERRIDE {
- return m_runState != NotStarted && !isComplete();
- }
- virtual bool hasChildren() const CATCH_OVERRIDE {
- return !m_children.empty();
- }
-
- virtual void addChild( Ptr<ITracker> const& child ) CATCH_OVERRIDE {
- m_children.push_back( child );
- }
-
- virtual ITracker* findChild( std::string const& name ) CATCH_OVERRIDE {
- Children::const_iterator it = std::find_if( m_children.begin(), m_children.end(), TrackerHasName( name ) );
- return( it != m_children.end() )
- ? it->get()
- : CATCH_NULL;
- }
- virtual ITracker& parent() CATCH_OVERRIDE {
- assert( m_parent ); // Should always be non-null except for root
- return *m_parent;
- }
-
- virtual void openChild() CATCH_OVERRIDE {
- if( m_runState != ExecutingChildren ) {
- m_runState = ExecutingChildren;
- if( m_parent )
- m_parent->openChild();
- }
- }
-
- virtual bool isSectionTracker() const CATCH_OVERRIDE { return false; }
- virtual bool isIndexTracker() const CATCH_OVERRIDE { return false; }
-
- void open() {
- m_runState = Executing;
- moveToThis();
- if( m_parent )
- m_parent->openChild();
- }
-
- virtual void close() CATCH_OVERRIDE {
-
- // Close any still open children (e.g. generators)
- while( &m_ctx.currentTracker() != this )
- m_ctx.currentTracker().close();
-
- switch( m_runState ) {
- case NotStarted:
- case CompletedSuccessfully:
- case Failed:
- throw std::logic_error( "Illogical state" );
-
- case NeedsAnotherRun:
- break;;
-
- case Executing:
- m_runState = CompletedSuccessfully;
- break;
- case ExecutingChildren:
- if( m_children.empty() || m_children.back()->isComplete() )
- m_runState = CompletedSuccessfully;
- break;
-
- default:
- throw std::logic_error( "Unexpected state" );
- }
- moveToParent();
- m_ctx.completeCycle();
- }
- virtual void fail() CATCH_OVERRIDE {
- m_runState = Failed;
- if( m_parent )
- m_parent->markAsNeedingAnotherRun();
- moveToParent();
- m_ctx.completeCycle();
- }
- virtual void markAsNeedingAnotherRun() CATCH_OVERRIDE {
- m_runState = NeedsAnotherRun;
- }
- private:
- void moveToParent() {
- assert( m_parent );
- m_ctx.setCurrentTracker( m_parent );
- }
- void moveToThis() {
- m_ctx.setCurrentTracker( this );
- }
- };
-
- class SectionTracker : public TrackerBase {
- public:
- SectionTracker( std::string const& name, TrackerContext& ctx, ITracker* parent )
- : TrackerBase( name, ctx, parent )
- {}
- virtual ~SectionTracker();
-
- virtual bool isSectionTracker() const CATCH_OVERRIDE { return true; }
-
- static SectionTracker& acquire( TrackerContext& ctx, std::string const& name ) {
- SectionTracker* section = CATCH_NULL;
-
- ITracker& currentTracker = ctx.currentTracker();
- if( ITracker* childTracker = currentTracker.findChild( name ) ) {
- assert( childTracker );
- assert( childTracker->isSectionTracker() );
- section = static_cast<SectionTracker*>( childTracker );
- }
- else {
- section = new SectionTracker( name, ctx, &currentTracker );
- currentTracker.addChild( section );
- }
- if( !ctx.completedCycle() && !section->isComplete() ) {
-
- section->open();
- }
- return *section;
- }
- };
-
- class IndexTracker : public TrackerBase {
- int m_size;
- int m_index;
- public:
- IndexTracker( std::string const& name, TrackerContext& ctx, ITracker* parent, int size )
- : TrackerBase( name, ctx, parent ),
- m_size( size ),
- m_index( -1 )
- {}
- virtual ~IndexTracker();
-
- virtual bool isIndexTracker() const CATCH_OVERRIDE { return true; }
-
- static IndexTracker& acquire( TrackerContext& ctx, std::string const& name, int size ) {
- IndexTracker* tracker = CATCH_NULL;
-
- ITracker& currentTracker = ctx.currentTracker();
- if( ITracker* childTracker = currentTracker.findChild( name ) ) {
- assert( childTracker );
- assert( childTracker->isIndexTracker() );
- tracker = static_cast<IndexTracker*>( childTracker );
- }
- else {
- tracker = new IndexTracker( name, ctx, &currentTracker, size );
- currentTracker.addChild( tracker );
- }
-
- if( !ctx.completedCycle() && !tracker->isComplete() ) {
- if( tracker->m_runState != ExecutingChildren && tracker->m_runState != NeedsAnotherRun )
- tracker->moveNext();
- tracker->open();
- }
-
- return *tracker;
- }
-
- int index() const { return m_index; }
-
- void moveNext() {
- m_index++;
- m_children.clear();
- }
-
- virtual void close() CATCH_OVERRIDE {
- TrackerBase::close();
- if( m_runState == CompletedSuccessfully && m_index < m_size-1 )
- m_runState = Executing;
- }
- };
-
- inline ITracker& TrackerContext::startRun() {
- m_rootTracker = new SectionTracker( "{root}", *this, CATCH_NULL );
- m_currentTracker = CATCH_NULL;
- m_runState = Executing;
- return *m_rootTracker;
- }
-
-} // namespace TestCaseTracking
-
-using TestCaseTracking::ITracker;
-using TestCaseTracking::TrackerContext;
-using TestCaseTracking::SectionTracker;
-using TestCaseTracking::IndexTracker;
-
-} // namespace Catch
-
-// #included from: catch_fatal_condition.hpp
-#define TWOBLUECUBES_CATCH_FATAL_CONDITION_H_INCLUDED
-
-namespace Catch {
-
- // Report the error condition then exit the process
- inline void fatal( std::string const& message, int exitCode ) {
- IContext& context = Catch::getCurrentContext();
- IResultCapture* resultCapture = context.getResultCapture();
- resultCapture->handleFatalErrorCondition( message );
-
- if( Catch::alwaysTrue() ) // avoids "no return" warnings
- exit( exitCode );
- }
-
-} // namespace Catch
-
-#if defined ( CATCH_PLATFORM_WINDOWS ) /////////////////////////////////////////
-
-namespace Catch {
-
- struct FatalConditionHandler {
- void reset() {}
- };
-
-} // namespace Catch
-
-#else // Not Windows - assumed to be POSIX compatible //////////////////////////
-
-#include <signal.h>
-
-namespace Catch {
-
- struct SignalDefs { int id; const char* name; };
- extern SignalDefs signalDefs[];
- SignalDefs signalDefs[] = {
- { SIGINT, "SIGINT - Terminal interrupt signal" },
- { SIGILL, "SIGILL - Illegal instruction signal" },
- { SIGFPE, "SIGFPE - Floating point error signal" },
- { SIGSEGV, "SIGSEGV - Segmentation violation signal" },
- { SIGTERM, "SIGTERM - Termination request signal" },
- { SIGABRT, "SIGABRT - Abort (abnormal termination) signal" }
- };
-
- struct FatalConditionHandler {
-
- static void handleSignal( int sig ) {
- for( std::size_t i = 0; i < sizeof(signalDefs)/sizeof(SignalDefs); ++i )
- if( sig == signalDefs[i].id )
- fatal( signalDefs[i].name, -sig );
- fatal( "<unknown signal>", -sig );
- }
-
- FatalConditionHandler() : m_isSet( true ) {
- for( std::size_t i = 0; i < sizeof(signalDefs)/sizeof(SignalDefs); ++i )
- signal( signalDefs[i].id, handleSignal );
- }
- ~FatalConditionHandler() {
- reset();
- }
- void reset() {
- if( m_isSet ) {
- for( std::size_t i = 0; i < sizeof(signalDefs)/sizeof(SignalDefs); ++i )
- signal( signalDefs[i].id, SIG_DFL );
- m_isSet = false;
- }
- }
-
- bool m_isSet;
- };
-
-} // namespace Catch
-
-#endif // not Windows
-
-#include <set>
-#include <string>
-
-namespace Catch {
-
- class StreamRedirect {
-
- public:
- StreamRedirect( std::ostream& stream, std::string& targetString )
- : m_stream( stream ),
- m_prevBuf( stream.rdbuf() ),
- m_targetString( targetString )
- {
- stream.rdbuf( m_oss.rdbuf() );
- }
-
- ~StreamRedirect() {
- m_targetString += m_oss.str();
- m_stream.rdbuf( m_prevBuf );
- }
-
- private:
- std::ostream& m_stream;
- std::streambuf* m_prevBuf;
- std::ostringstream m_oss;
- std::string& m_targetString;
- };
-
- ///////////////////////////////////////////////////////////////////////////
-
- class RunContext : public IResultCapture, public IRunner {
-
- RunContext( RunContext const& );
- void operator =( RunContext const& );
-
- public:
-
- explicit RunContext( Ptr<IConfig const> const& _config, Ptr<IStreamingReporter> const& reporter )
- : m_runInfo( _config->name() ),
- m_context( getCurrentMutableContext() ),
- m_activeTestCase( CATCH_NULL ),
- m_config( _config ),
- m_reporter( reporter )
- {
- m_context.setRunner( this );
- m_context.setConfig( m_config );
- m_context.setResultCapture( this );
- m_reporter->testRunStarting( m_runInfo );
- }
-
- virtual ~RunContext() {
- m_reporter->testRunEnded( TestRunStats( m_runInfo, m_totals, aborting() ) );
- }
-
- void testGroupStarting( std::string const& testSpec, std::size_t groupIndex, std::size_t groupsCount ) {
- m_reporter->testGroupStarting( GroupInfo( testSpec, groupIndex, groupsCount ) );
- }
- void testGroupEnded( std::string const& testSpec, Totals const& totals, std::size_t groupIndex, std::size_t groupsCount ) {
- m_reporter->testGroupEnded( TestGroupStats( GroupInfo( testSpec, groupIndex, groupsCount ), totals, aborting() ) );
- }
-
- Totals runTest( TestCase const& testCase ) {
- Totals prevTotals = m_totals;
-
- std::string redirectedCout;
- std::string redirectedCerr;
-
- TestCaseInfo testInfo = testCase.getTestCaseInfo();
-
- m_reporter->testCaseStarting( testInfo );
-
- m_activeTestCase = &testCase;
-
- do {
- m_trackerContext.startRun();
- do {
- m_trackerContext.startCycle();
- m_testCaseTracker = &SectionTracker::acquire( m_trackerContext, testInfo.name );
- runCurrentTest( redirectedCout, redirectedCerr );
- }
- while( !m_testCaseTracker->isSuccessfullyCompleted() && !aborting() );
- }
- // !TBD: deprecated - this will be replaced by indexed trackers
- while( getCurrentContext().advanceGeneratorsForCurrentTest() && !aborting() );
-
- Totals deltaTotals = m_totals.delta( prevTotals );
- if( testInfo.expectedToFail() && deltaTotals.testCases.passed > 0 ) {
- deltaTotals.assertions.failed++;
- deltaTotals.testCases.passed--;
- deltaTotals.testCases.failed++;
- }
- m_totals.testCases += deltaTotals.testCases;
- m_reporter->testCaseEnded( TestCaseStats( testInfo,
- deltaTotals,
- redirectedCout,
- redirectedCerr,
- aborting() ) );
-
- m_activeTestCase = CATCH_NULL;
- m_testCaseTracker = CATCH_NULL;
-
- return deltaTotals;
- }
-
- Ptr<IConfig const> config() const {
- return m_config;
- }
-
- private: // IResultCapture
-
- virtual void assertionEnded( AssertionResult const& result ) {
- if( result.getResultType() == ResultWas::Ok ) {
- m_totals.assertions.passed++;
- }
- else if( !result.isOk() ) {
- m_totals.assertions.failed++;
- }
-
- if( m_reporter->assertionEnded( AssertionStats( result, m_messages, m_totals ) ) )
- m_messages.clear();
-
- // Reset working state
- m_lastAssertionInfo = AssertionInfo( "", m_lastAssertionInfo.lineInfo, "{Unknown expression after the reported line}" , m_lastAssertionInfo.resultDisposition );
- m_lastResult = result;
- }
-
- virtual bool sectionStarted (
- SectionInfo const& sectionInfo,
- Counts& assertions
- )
- {
- std::ostringstream oss;
- oss << sectionInfo.name << "@" << sectionInfo.lineInfo;
-
- ITracker& sectionTracker = SectionTracker::acquire( m_trackerContext, oss.str() );
- if( !sectionTracker.isOpen() )
- return false;
- m_activeSections.push_back( &sectionTracker );
-
- m_lastAssertionInfo.lineInfo = sectionInfo.lineInfo;
-
- m_reporter->sectionStarting( sectionInfo );
-
- assertions = m_totals.assertions;
-
- return true;
- }
- bool testForMissingAssertions( Counts& assertions ) {
- if( assertions.total() != 0 )
- return false;
- if( !m_config->warnAboutMissingAssertions() )
- return false;
- if( m_trackerContext.currentTracker().hasChildren() )
- return false;
- m_totals.assertions.failed++;
- assertions.failed++;
- return true;
- }
-
- virtual void sectionEnded( SectionEndInfo const& endInfo ) {
- Counts assertions = m_totals.assertions - endInfo.prevAssertions;
- bool missingAssertions = testForMissingAssertions( assertions );
-
- if( !m_activeSections.empty() ) {
- m_activeSections.back()->close();
- m_activeSections.pop_back();
- }
-
- m_reporter->sectionEnded( SectionStats( endInfo.sectionInfo, assertions, endInfo.durationInSeconds, missingAssertions ) );
- m_messages.clear();
- }
-
- virtual void sectionEndedEarly( SectionEndInfo const& endInfo ) {
- if( m_unfinishedSections.empty() )
- m_activeSections.back()->fail();
- else
- m_activeSections.back()->close();
- m_activeSections.pop_back();
-
- m_unfinishedSections.push_back( endInfo );
- }
-
- virtual void pushScopedMessage( MessageInfo const& message ) {
- m_messages.push_back( message );
- }
-
- virtual void popScopedMessage( MessageInfo const& message ) {
- m_messages.erase( std::remove( m_messages.begin(), m_messages.end(), message ), m_messages.end() );
- }
-
- virtual std::string getCurrentTestName() const {
- return m_activeTestCase
- ? m_activeTestCase->getTestCaseInfo().name
- : "";
- }
-
- virtual const AssertionResult* getLastResult() const {
- return &m_lastResult;
- }
-
- virtual void handleFatalErrorCondition( std::string const& message ) {
- ResultBuilder resultBuilder = makeUnexpectedResultBuilder();
- resultBuilder.setResultType( ResultWas::FatalErrorCondition );
- resultBuilder << message;
-// stack
-#ifdef HAVE_EXECINFO
- {
- void *array[15];
- const int size = static_cast<int>(backtrace(array, 15));
- char **strings = backtrace_symbols(array, size);
- for (int i = 0; i < size; i++)
- resultBuilder << strings[i];
- free(strings);
- }
-#endif // HAVE_EXECINFO
-// stack
-
- resultBuilder.captureExpression();
-
- handleUnfinishedSections();
-
- // Recreate section for test case (as we will lose the one that was in scope)
- TestCaseInfo const& testCaseInfo = m_activeTestCase->getTestCaseInfo();
- SectionInfo testCaseSection( testCaseInfo.lineInfo, testCaseInfo.name, testCaseInfo.description );
-
- Counts assertions;
- assertions.failed = 1;
- SectionStats testCaseSectionStats( testCaseSection, assertions, 0, false );
- m_reporter->sectionEnded( testCaseSectionStats );
-
- TestCaseInfo testInfo = m_activeTestCase->getTestCaseInfo();
-
- Totals deltaTotals;
- deltaTotals.testCases.failed = 1;
- m_reporter->testCaseEnded( TestCaseStats( testInfo,
- deltaTotals,
- "",
- "",
- false ) );
- m_totals.testCases.failed++;
- testGroupEnded( "", m_totals, 1, 1 );
- m_reporter->testRunEnded( TestRunStats( m_runInfo, m_totals, false ) );
- }
-
- public:
- // !TBD We need to do this another way!
- bool aborting() const {
- return m_totals.assertions.failed == static_cast<std::size_t>( m_config->abortAfter() );
- }
-
- private:
-
- void runCurrentTest( std::string& redirectedCout, std::string& redirectedCerr ) {
- TestCaseInfo const& testCaseInfo = m_activeTestCase->getTestCaseInfo();
- SectionInfo testCaseSection( testCaseInfo.lineInfo, testCaseInfo.name, testCaseInfo.description );
- m_reporter->sectionStarting( testCaseSection );
- Counts prevAssertions = m_totals.assertions;
- double duration = 0;
- try {
- m_lastAssertionInfo = AssertionInfo( "TEST_CASE", testCaseInfo.lineInfo, "", ResultDisposition::Normal );
-
- seedRng( *m_config );
-
- Timer timer;
- timer.start();
- if( m_reporter->getPreferences().shouldRedirectStdOut ) {
- StreamRedirect coutRedir( Catch::cout(), redirectedCout );
- StreamRedirect cerrRedir( Catch::cerr(), redirectedCerr );
- invokeActiveTestCase();
- }
- else {
- invokeActiveTestCase();
- }
- duration = timer.getElapsedSeconds();
- }
- catch( TestFailureException& ) {
- // This just means the test was aborted due to failure
- }
- catch(...) {
- makeUnexpectedResultBuilder().useActiveException();
- }
- m_testCaseTracker->close();
- handleUnfinishedSections();
- m_messages.clear();
-
- Counts assertions = m_totals.assertions - prevAssertions;
- bool missingAssertions = testForMissingAssertions( assertions );
-
- if( testCaseInfo.okToFail() ) {
- std::swap( assertions.failedButOk, assertions.failed );
- m_totals.assertions.failed -= assertions.failedButOk;
- m_totals.assertions.failedButOk += assertions.failedButOk;
- }
-
- SectionStats testCaseSectionStats( testCaseSection, assertions, duration, missingAssertions );
- m_reporter->sectionEnded( testCaseSectionStats );
- }
-
- void invokeActiveTestCase() {
- FatalConditionHandler fatalConditionHandler; // Handle signals
- m_activeTestCase->invoke();
- fatalConditionHandler.reset();
- }
-
- private:
-
- ResultBuilder makeUnexpectedResultBuilder() const {
- return ResultBuilder( m_lastAssertionInfo.macroName.c_str(),
- m_lastAssertionInfo.lineInfo,
- m_lastAssertionInfo.capturedExpression.c_str(),
- m_lastAssertionInfo.resultDisposition );
- }
-
- void handleUnfinishedSections() {
- // If sections ended prematurely due to an exception we stored their
- // infos here so we can tear them down outside the unwind process.
- for( std::vector<SectionEndInfo>::const_reverse_iterator it = m_unfinishedSections.rbegin(),
- itEnd = m_unfinishedSections.rend();
- it != itEnd;
- ++it )
- sectionEnded( *it );
- m_unfinishedSections.clear();
- }
-
- TestRunInfo m_runInfo;
- IMutableContext& m_context;
- TestCase const* m_activeTestCase;
- ITracker* m_testCaseTracker;
- ITracker* m_currentSectionTracker;
- AssertionResult m_lastResult;
-
- Ptr<IConfig const> m_config;
- Totals m_totals;
- Ptr<IStreamingReporter> m_reporter;
- std::vector<MessageInfo> m_messages;
- AssertionInfo m_lastAssertionInfo;
- std::vector<SectionEndInfo> m_unfinishedSections;
- std::vector<ITracker*> m_activeSections;
- TrackerContext m_trackerContext;
- };
-
- IResultCapture& getResultCapture() {
- if( IResultCapture* capture = getCurrentContext().getResultCapture() )
- return *capture;
- else
- throw std::logic_error( "No result capture instance" );
- }
-
-} // end namespace Catch
-
-// #included from: internal/catch_version.h
-#define TWOBLUECUBES_CATCH_VERSION_H_INCLUDED
-
-namespace Catch {
-
- // Versioning information
- struct Version {
- Version( unsigned int _majorVersion,
- unsigned int _minorVersion,
- unsigned int _patchNumber,
- std::string const& _branchName,
- unsigned int _buildNumber );
-
- unsigned int const majorVersion;
- unsigned int const minorVersion;
- unsigned int const patchNumber;
-
- // buildNumber is only used if branchName is not null
- std::string const branchName;
- unsigned int const buildNumber;
-
- friend std::ostream& operator << ( std::ostream& os, Version const& version );
-
- private:
- void operator=( Version const& );
- };
-
- extern Version libraryVersion;
-}
-
-#include <fstream>
-#include <stdlib.h>
-#include <limits>
-
-namespace Catch {
-
- Ptr<IStreamingReporter> createReporter( std::string const& reporterName, Ptr<Config> const& config ) {
- Ptr<IStreamingReporter> reporter = getRegistryHub().getReporterRegistry().create( reporterName, config.get() );
- if( !reporter ) {
- std::ostringstream oss;
- oss << "No reporter registered with name: '" << reporterName << "'";
- throw std::domain_error( oss.str() );
- }
- return reporter;
- }
-
- Ptr<IStreamingReporter> makeReporter( Ptr<Config> const& config ) {
- std::vector<std::string> reporters = config->getReporterNames();
- if( reporters.empty() )
- reporters.push_back( "console" );
-
- Ptr<IStreamingReporter> reporter;
- for( std::vector<std::string>::const_iterator it = reporters.begin(), itEnd = reporters.end();
- it != itEnd;
- ++it )
- reporter = addReporter( reporter, createReporter( *it, config ) );
- return reporter;
- }
- Ptr<IStreamingReporter> addListeners( Ptr<IConfig const> const& config, Ptr<IStreamingReporter> reporters ) {
- IReporterRegistry::Listeners listeners = getRegistryHub().getReporterRegistry().getListeners();
- for( IReporterRegistry::Listeners::const_iterator it = listeners.begin(), itEnd = listeners.end();
- it != itEnd;
- ++it )
- reporters = addReporter(reporters, (*it)->create( ReporterConfig( config ) ) );
- return reporters;
- }
-
- Totals runTests( Ptr<Config> const& config ) {
-
- Ptr<IConfig const> iconfig = config.get();
-
- Ptr<IStreamingReporter> reporter = makeReporter( config );
- reporter = addListeners( iconfig, reporter );
-
- RunContext context( iconfig, reporter );
-
- Totals totals;
-
- context.testGroupStarting( config->name(), 1, 1 );
-
- TestSpec testSpec = config->testSpec();
- if( !testSpec.hasFilters() )
- testSpec = TestSpecParser( ITagAliasRegistry::get() ).parse( "~[.]" ).testSpec(); // All not hidden tests
-
- std::vector<TestCase> const& allTestCases = getAllTestCasesSorted( *iconfig );
- for( std::vector<TestCase>::const_iterator it = allTestCases.begin(), itEnd = allTestCases.end();
- it != itEnd;
- ++it ) {
- if( !context.aborting() && matchTest( *it, testSpec, *iconfig ) )
- totals += context.runTest( *it );
- else
- reporter->skipTest( *it );
- }
-
- context.testGroupEnded( iconfig->name(), totals, 1, 1 );
- return totals;
- }
-
- void applyFilenamesAsTags( IConfig const& config ) {
- std::vector<TestCase> const& tests = getAllTestCasesSorted( config );
- for(std::size_t i = 0; i < tests.size(); ++i ) {
- TestCase& test = const_cast<TestCase&>( tests[i] );
- std::set<std::string> tags = test.tags;
-
- std::string filename = test.lineInfo.file;
- std::string::size_type lastSlash = filename.find_last_of( "\\/" );
- if( lastSlash != std::string::npos )
- filename = filename.substr( lastSlash+1 );
-
- std::string::size_type lastDot = filename.find_last_of( "." );
- if( lastDot != std::string::npos )
- filename = filename.substr( 0, lastDot );
-
- tags.insert( "#" + filename );
- setTags( test, tags );
- }
- }
-
- class Session : NonCopyable {
- static bool alreadyInstantiated;
-
- public:
-
- struct OnUnusedOptions { enum DoWhat { Ignore, Fail }; };
-
- Session()
- : m_cli( makeCommandLineParser() ) {
- if( alreadyInstantiated ) {
- std::string msg = "Only one instance of Catch::Session can ever be used";
- Catch::cerr() << msg << std::endl;
- throw std::logic_error( msg );
- }
- alreadyInstantiated = true;
- }
- ~Session() {
- Catch::cleanUp();
- }
-
- void showHelp( std::string const& processName ) {
- Catch::cout() << "\nCatch v" << libraryVersion << "\n";
-
- m_cli.usage( Catch::cout(), processName );
- Catch::cout() << "For more detail usage please see the project docs\n" << std::endl;
- }
-
- int applyCommandLine( int argc, char const* const* const argv, OnUnusedOptions::DoWhat unusedOptionBehaviour = OnUnusedOptions::Fail ) {
- try {
- m_cli.setThrowOnUnrecognisedTokens( unusedOptionBehaviour == OnUnusedOptions::Fail );
- m_unusedTokens = m_cli.parseInto( Clara::argsToVector( argc, argv ), m_configData );
- if( m_configData.showHelp )
- showHelp( m_configData.processName );
- m_config.reset();
- }
- catch( std::exception& ex ) {
- {
- Colour colourGuard( Colour::Red );
- Catch::cerr()
- << "\nError(s) in input:\n"
- << Text( ex.what(), TextAttributes().setIndent(2) )
- << "\n\n";
- }
- m_cli.usage( Catch::cout(), m_configData.processName );
- return (std::numeric_limits<int>::max)();
- }
- return 0;
- }
-
- void useConfigData( ConfigData const& _configData ) {
- m_configData = _configData;
- m_config.reset();
- }
-
- int run( int argc, char const* const* const argv ) {
-
- int returnCode = applyCommandLine( argc, argv );
- if( returnCode == 0 )
- returnCode = run();
- return returnCode;
- }
-
- int run() {
- if( m_configData.showHelp )
- return 0;
-
- try
- {
- config(); // Force config to be constructed
-
- seedRng( *m_config );
-
- if( m_configData.filenamesAsTags )
- applyFilenamesAsTags( *m_config );
-
- // Handle list request
- if( Option<std::size_t> listed = list( config() ) )
- return static_cast<int>( *listed );
-
- return static_cast<int>( runTests( m_config ).assertions.failed );
- }
- catch( std::exception& ex ) {
- Catch::cerr() << ex.what() << std::endl;
- return (std::numeric_limits<int>::max)();
- }
- }
-
- Clara::CommandLine<ConfigData> const& cli() const {
- return m_cli;
- }
- std::vector<Clara::Parser::Token> const& unusedTokens() const {
- return m_unusedTokens;
- }
- ConfigData& configData() {
- return m_configData;
- }
- Config& config() {
- if( !m_config )
- m_config = new Config( m_configData );
- return *m_config;
- }
- private:
- Clara::CommandLine<ConfigData> m_cli;
- std::vector<Clara::Parser::Token> m_unusedTokens;
- ConfigData m_configData;
- Ptr<Config> m_config;
- };
-
- bool Session::alreadyInstantiated = false;
-
-} // end namespace Catch
-
-// #included from: catch_registry_hub.hpp
-#define TWOBLUECUBES_CATCH_REGISTRY_HUB_HPP_INCLUDED
-
-// #included from: catch_test_case_registry_impl.hpp
-#define TWOBLUECUBES_CATCH_TEST_CASE_REGISTRY_IMPL_HPP_INCLUDED
-
-#include <vector>
-#include <set>
-#include <sstream>
-#include <iostream>
-#include <algorithm>
-
-namespace Catch {
-
- struct LexSort {
- bool operator() (TestCase i,TestCase j) const { return (i<j);}
- };
- struct RandomNumberGenerator {
- int operator()( int n ) const { return std::rand() % n; }
- };
-
- inline std::vector<TestCase> sortTests( IConfig const& config, std::vector<TestCase> const& unsortedTestCases ) {
-
- std::vector<TestCase> sorted = unsortedTestCases;
-
- switch( config.runOrder() ) {
- case RunTests::InLexicographicalOrder:
- std::sort( sorted.begin(), sorted.end(), LexSort() );
- break;
- case RunTests::InRandomOrder:
- {
- seedRng( config );
-
- RandomNumberGenerator rng;
- std::random_shuffle( sorted.begin(), sorted.end(), rng );
- }
- break;
- case RunTests::InDeclarationOrder:
- // already in declaration order
- break;
- }
- return sorted;
- }
- bool matchTest( TestCase const& testCase, TestSpec const& testSpec, IConfig const& config ) {
- return testSpec.matches( testCase ) && ( config.allowThrows() || !testCase.throws() );
- }
-
- void enforceNoDuplicateTestCases( std::vector<TestCase> const& functions ) {
- std::set<TestCase> seenFunctions;
- for( std::vector<TestCase>::const_iterator it = functions.begin(), itEnd = functions.end();
- it != itEnd;
- ++it ) {
- std::pair<std::set<TestCase>::const_iterator, bool> prev = seenFunctions.insert( *it );
- if( !prev.second ){
- Catch::cerr()
- << Colour( Colour::Red )
- << "error: TEST_CASE( \"" << it->name << "\" ) already defined.\n"
- << "\tFirst seen at " << prev.first->getTestCaseInfo().lineInfo << "\n"
- << "\tRedefined at " << it->getTestCaseInfo().lineInfo << std::endl;
- exit(1);
- }
- }
- }
-
- std::vector<TestCase> filterTests( std::vector<TestCase> const& testCases, TestSpec const& testSpec, IConfig const& config ) {
- std::vector<TestCase> filtered;
- filtered.reserve( testCases.size() );
- for( std::vector<TestCase>::const_iterator it = testCases.begin(), itEnd = testCases.end();
- it != itEnd;
- ++it )
- if( matchTest( *it, testSpec, config ) )
- filtered.push_back( *it );
- return filtered;
- }
- std::vector<TestCase> const& getAllTestCasesSorted( IConfig const& config ) {
- return getRegistryHub().getTestCaseRegistry().getAllTestsSorted( config );
- }
-
- class TestRegistry : public ITestCaseRegistry {
- public:
- TestRegistry()
- : m_currentSortOrder( RunTests::InDeclarationOrder ),
- m_unnamedCount( 0 )
- {}
- virtual ~TestRegistry();
-
- virtual void registerTest( TestCase const& testCase ) {
- std::string name = testCase.getTestCaseInfo().name;
- if( name == "" ) {
- std::ostringstream oss;
- oss << "Anonymous test case " << ++m_unnamedCount;
- return registerTest( testCase.withName( oss.str() ) );
- }
- m_functions.push_back( testCase );
- }
-
- virtual std::vector<TestCase> const& getAllTests() const {
- return m_functions;
- }
- virtual std::vector<TestCase> const& getAllTestsSorted( IConfig const& config ) const {
- if( m_sortedFunctions.empty() )
- enforceNoDuplicateTestCases( m_functions );
-
- if( m_currentSortOrder != config.runOrder() || m_sortedFunctions.empty() ) {
- m_sortedFunctions = sortTests( config, m_functions );
- m_currentSortOrder = config.runOrder();
- }
- return m_sortedFunctions;
- }
-
- private:
- std::vector<TestCase> m_functions;
- mutable RunTests::InWhatOrder m_currentSortOrder;
- mutable std::vector<TestCase> m_sortedFunctions;
- size_t m_unnamedCount;
- std::ios_base::Init m_ostreamInit; // Forces cout/ cerr to be initialised
- };
-
- ///////////////////////////////////////////////////////////////////////////
-
- class FreeFunctionTestCase : public SharedImpl<ITestCase> {
- public:
-
- FreeFunctionTestCase( TestFunction fun ) : m_fun( fun ) {}
-
- virtual void invoke() const {
- m_fun();
- }
-
- private:
- virtual ~FreeFunctionTestCase();
-
- TestFunction m_fun;
- };
-
- inline std::string extractClassName( std::string const& classOrQualifiedMethodName ) {
- std::string className = classOrQualifiedMethodName;
- if( startsWith( className, "&" ) )
- {
- std::size_t lastColons = className.rfind( "::" );
- std::size_t penultimateColons = className.rfind( "::", lastColons-1 );
- if( penultimateColons == std::string::npos )
- penultimateColons = 1;
- className = className.substr( penultimateColons, lastColons-penultimateColons );
- }
- return className;
- }
-
- void registerTestCase
- ( ITestCase* testCase,
- char const* classOrQualifiedMethodName,
- NameAndDesc const& nameAndDesc,
- SourceLineInfo const& lineInfo ) {
-
- getMutableRegistryHub().registerTest
- ( makeTestCase
- ( testCase,
- extractClassName( classOrQualifiedMethodName ),
- nameAndDesc.name,
- nameAndDesc.description,
- lineInfo ) );
- }
- void registerTestCaseFunction
- ( TestFunction function,
- SourceLineInfo const& lineInfo,
- NameAndDesc const& nameAndDesc ) {
- registerTestCase( new FreeFunctionTestCase( function ), "", nameAndDesc, lineInfo );
- }
-
- ///////////////////////////////////////////////////////////////////////////
-
- AutoReg::AutoReg
- ( TestFunction function,
- SourceLineInfo const& lineInfo,
- NameAndDesc const& nameAndDesc ) {
- registerTestCaseFunction( function, lineInfo, nameAndDesc );
- }
-
- AutoReg::~AutoReg() {}
-
-} // end namespace Catch
-
-// #included from: catch_reporter_registry.hpp
-#define TWOBLUECUBES_CATCH_REPORTER_REGISTRY_HPP_INCLUDED
-
-#include <map>
-
-namespace Catch {
-
- class ReporterRegistry : public IReporterRegistry {
-
- public:
-
- virtual ~ReporterRegistry() CATCH_OVERRIDE {}
-
- virtual IStreamingReporter* create( std::string const& name, Ptr<IConfig const> const& config ) const CATCH_OVERRIDE {
- FactoryMap::const_iterator it = m_factories.find( name );
- if( it == m_factories.end() )
- return CATCH_NULL;
- return it->second->create( ReporterConfig( config ) );
- }
-
- void registerReporter( std::string const& name, Ptr<IReporterFactory> const& factory ) {
- m_factories.insert( std::make_pair( name, factory ) );
- }
- void registerListener( Ptr<IReporterFactory> const& factory ) {
- m_listeners.push_back( factory );
- }
-
- virtual FactoryMap const& getFactories() const CATCH_OVERRIDE {
- return m_factories;
- }
- virtual Listeners const& getListeners() const CATCH_OVERRIDE {
- return m_listeners;
- }
-
- private:
- FactoryMap m_factories;
- Listeners m_listeners;
- };
-}
-
-// #included from: catch_exception_translator_registry.hpp
-#define TWOBLUECUBES_CATCH_EXCEPTION_TRANSLATOR_REGISTRY_HPP_INCLUDED
-
-#ifdef __OBJC__
-#import "Foundation/Foundation.h"
-#endif
-
-namespace Catch {
-
- class ExceptionTranslatorRegistry : public IExceptionTranslatorRegistry {
- public:
- ~ExceptionTranslatorRegistry() {
- deleteAll( m_translators );
- }
-
- virtual void registerTranslator( const IExceptionTranslator* translator ) {
- m_translators.push_back( translator );
- }
-
- virtual std::string translateActiveException() const {
- try {
-#ifdef __OBJC__
- // In Objective-C try objective-c exceptions first
- @try {
- return tryTranslators();
- }
- @catch (NSException *exception) {
- return Catch::toString( [exception description] );
- }
-#else
- return tryTranslators();
-#endif
- }
- catch( TestFailureException& ) {
- throw;
- }
- catch( std::exception& ex ) {
- return ex.what();
- }
- catch( std::string& msg ) {
- return msg;
- }
- catch( const char* msg ) {
- return msg;
- }
- catch(...) {
- return "Unknown exception";
- }
- }
-
- std::string tryTranslators() const {
- if( m_translators.empty() )
- throw;
- else
- return m_translators[0]->translate( m_translators.begin()+1, m_translators.end() );
- }
-
- private:
- std::vector<const IExceptionTranslator*> m_translators;
- };
-}
-
-namespace Catch {
-
- namespace {
-
- class RegistryHub : public IRegistryHub, public IMutableRegistryHub {
-
- RegistryHub( RegistryHub const& );
- void operator=( RegistryHub const& );
-
- public: // IRegistryHub
- RegistryHub() {
- }
- virtual IReporterRegistry const& getReporterRegistry() const CATCH_OVERRIDE {
- return m_reporterRegistry;
- }
- virtual ITestCaseRegistry const& getTestCaseRegistry() const CATCH_OVERRIDE {
- return m_testCaseRegistry;
- }
- virtual IExceptionTranslatorRegistry& getExceptionTranslatorRegistry() CATCH_OVERRIDE {
- return m_exceptionTranslatorRegistry;
- }
-
- public: // IMutableRegistryHub
- virtual void registerReporter( std::string const& name, Ptr<IReporterFactory> const& factory ) CATCH_OVERRIDE {
- m_reporterRegistry.registerReporter( name, factory );
- }
- virtual void registerListener( Ptr<IReporterFactory> const& factory ) CATCH_OVERRIDE {
- m_reporterRegistry.registerListener( factory );
- }
- virtual void registerTest( TestCase const& testInfo ) CATCH_OVERRIDE {
- m_testCaseRegistry.registerTest( testInfo );
- }
- virtual void registerTranslator( const IExceptionTranslator* translator ) CATCH_OVERRIDE {
- m_exceptionTranslatorRegistry.registerTranslator( translator );
- }
-
- private:
- TestRegistry m_testCaseRegistry;
- ReporterRegistry m_reporterRegistry;
- ExceptionTranslatorRegistry m_exceptionTranslatorRegistry;
- };
-
- // Single, global, instance
- inline RegistryHub*& getTheRegistryHub() {
- static RegistryHub* theRegistryHub = CATCH_NULL;
- if( !theRegistryHub )
- theRegistryHub = new RegistryHub();
- return theRegistryHub;
- }
- }
-
- IRegistryHub& getRegistryHub() {
- return *getTheRegistryHub();
- }
- IMutableRegistryHub& getMutableRegistryHub() {
- return *getTheRegistryHub();
- }
- void cleanUp() {
- delete getTheRegistryHub();
- getTheRegistryHub() = CATCH_NULL;
- cleanUpContext();
- }
- std::string translateActiveException() {
- return getRegistryHub().getExceptionTranslatorRegistry().translateActiveException();
- }
-
-} // end namespace Catch
-
-// #included from: catch_notimplemented_exception.hpp
-#define TWOBLUECUBES_CATCH_NOTIMPLEMENTED_EXCEPTION_HPP_INCLUDED
-
-#include <ostream>
-
-namespace Catch {
-
- NotImplementedException::NotImplementedException( SourceLineInfo const& lineInfo )
- : m_lineInfo( lineInfo ) {
- std::ostringstream oss;
- oss << lineInfo << ": function ";
- oss << "not implemented";
- m_what = oss.str();
- }
-
- const char* NotImplementedException::what() const CATCH_NOEXCEPT {
- return m_what.c_str();
- }
-
-} // end namespace Catch
-
-// #included from: catch_context_impl.hpp
-#define TWOBLUECUBES_CATCH_CONTEXT_IMPL_HPP_INCLUDED
-
-// #included from: catch_stream.hpp
-#define TWOBLUECUBES_CATCH_STREAM_HPP_INCLUDED
-
-#include <stdexcept>
-#include <cstdio>
-#include <iostream>
-
-namespace Catch {
-
- template<typename WriterF, size_t bufferSize=256>
- class StreamBufImpl : public StreamBufBase {
- char data[bufferSize];
- WriterF m_writer;
-
- public:
- StreamBufImpl() {
- setp( data, data + sizeof(data) );
- }
-
- ~StreamBufImpl() CATCH_NOEXCEPT {
- sync();
- }
-
- private:
- int overflow( int c ) {
- sync();
-
- if( c != EOF ) {
- if( pbase() == epptr() )
- m_writer( std::string( 1, static_cast<char>( c ) ) );
- else
- sputc( static_cast<char>( c ) );
- }
- return 0;
- }
-
- int sync() {
- if( pbase() != pptr() ) {
- m_writer( std::string( pbase(), static_cast<std::string::size_type>( pptr() - pbase() ) ) );
- setp( pbase(), epptr() );
- }
- return 0;
- }
- };
-
- ///////////////////////////////////////////////////////////////////////////
-
- FileStream::FileStream( std::string const& filename ) {
- m_ofs.open( filename.c_str() );
- if( m_ofs.fail() ) {
- std::ostringstream oss;
- oss << "Unable to open file: '" << filename << "'";
- throw std::domain_error( oss.str() );
- }
- }
-
- std::ostream& FileStream::stream() const {
- return m_ofs;
- }
-
- struct OutputDebugWriter {
-
- void operator()( std::string const&str ) {
- writeToDebugConsole( str );
- }
- };
-
- DebugOutStream::DebugOutStream()
- : m_streamBuf( new StreamBufImpl<OutputDebugWriter>() ),
- m_os( m_streamBuf.get() )
- {}
-
- std::ostream& DebugOutStream::stream() const {
- return m_os;
- }
-
- // Store the streambuf from cout up-front because
- // cout may get redirected when running tests
- CoutStream::CoutStream()
- : m_os( Catch::cout().rdbuf() )
- {}
-
- std::ostream& CoutStream::stream() const {
- return m_os;
- }
-
-#ifndef CATCH_CONFIG_NOSTDOUT // If you #define this you must implement these functions
- std::ostream& cout() {
- return std::cout;
- }
- std::ostream& cerr() {
- return std::cerr;
- }
-#endif
-}
-
-namespace Catch {
-
- class Context : public IMutableContext {
-
- Context() : m_config( CATCH_NULL ), m_runner( CATCH_NULL ), m_resultCapture( CATCH_NULL ) {}
- Context( Context const& );
- void operator=( Context const& );
-
- public: // IContext
- virtual IResultCapture* getResultCapture() {
- return m_resultCapture;
- }
- virtual IRunner* getRunner() {
- return m_runner;
- }
- virtual size_t getGeneratorIndex( std::string const& fileInfo, size_t totalSize ) {
- return getGeneratorsForCurrentTest()
- .getGeneratorInfo( fileInfo, totalSize )
- .getCurrentIndex();
- }
- virtual bool advanceGeneratorsForCurrentTest() {
- IGeneratorsForTest* generators = findGeneratorsForCurrentTest();
- return generators && generators->moveNext();
- }
-
- virtual Ptr<IConfig const> getConfig() const {
- return m_config;
- }
-
- public: // IMutableContext
- virtual void setResultCapture( IResultCapture* resultCapture ) {
- m_resultCapture = resultCapture;
- }
- virtual void setRunner( IRunner* runner ) {
- m_runner = runner;
- }
- virtual void setConfig( Ptr<IConfig const> const& config ) {
- m_config = config;
- }
-
- friend IMutableContext& getCurrentMutableContext();
-
- private:
- IGeneratorsForTest* findGeneratorsForCurrentTest() {
- std::string testName = getResultCapture()->getCurrentTestName();
-
- std::map<std::string, IGeneratorsForTest*>::const_iterator it =
- m_generatorsByTestName.find( testName );
- return it != m_generatorsByTestName.end()
- ? it->second
- : CATCH_NULL;
- }
-
- IGeneratorsForTest& getGeneratorsForCurrentTest() {
- IGeneratorsForTest* generators = findGeneratorsForCurrentTest();
- if( !generators ) {
- std::string testName = getResultCapture()->getCurrentTestName();
- generators = createGeneratorsForTest();
- m_generatorsByTestName.insert( std::make_pair( testName, generators ) );
- }
- return *generators;
- }
-
- private:
- Ptr<IConfig const> m_config;
- IRunner* m_runner;
- IResultCapture* m_resultCapture;
- std::map<std::string, IGeneratorsForTest*> m_generatorsByTestName;
- };
-
- namespace {
- Context* currentContext = CATCH_NULL;
- }
- IMutableContext& getCurrentMutableContext() {
- if( !currentContext )
- currentContext = new Context();
- return *currentContext;
- }
- IContext& getCurrentContext() {
- return getCurrentMutableContext();
- }
-
- void cleanUpContext() {
- delete currentContext;
- currentContext = CATCH_NULL;
- }
-}
-
-// #included from: catch_console_colour_impl.hpp
-#define TWOBLUECUBES_CATCH_CONSOLE_COLOUR_IMPL_HPP_INCLUDED
-
-namespace Catch {
- namespace {
-
- struct IColourImpl {
- virtual ~IColourImpl() {}
- virtual void use( Colour::Code _colourCode ) = 0;
- };
-
- struct NoColourImpl : IColourImpl {
- void use( Colour::Code ) {}
-
- static IColourImpl* instance() {
- static NoColourImpl s_instance;
- return &s_instance;
- }
- };
-
- } // anon namespace
-} // namespace Catch
-
-#if !defined( CATCH_CONFIG_COLOUR_NONE ) && !defined( CATCH_CONFIG_COLOUR_WINDOWS ) && !defined( CATCH_CONFIG_COLOUR_ANSI )
-# ifdef CATCH_PLATFORM_WINDOWS
-# define CATCH_CONFIG_COLOUR_WINDOWS
-# else
-# define CATCH_CONFIG_COLOUR_ANSI
-# endif
-#endif
-
-#if defined ( CATCH_CONFIG_COLOUR_WINDOWS ) /////////////////////////////////////////
-
-#ifndef NOMINMAX
-#define NOMINMAX
-#endif
-
-#ifdef __AFXDLL
-#include <AfxWin.h>
-#else
-#include <windows.h>
-#endif
-
-namespace Catch {
-namespace {
-
- class Win32ColourImpl : public IColourImpl {
- public:
- Win32ColourImpl() : stdoutHandle( GetStdHandle(STD_OUTPUT_HANDLE) )
- {
- CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
- GetConsoleScreenBufferInfo( stdoutHandle, &csbiInfo );
- originalForegroundAttributes = csbiInfo.wAttributes & ~( BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_BLUE | BACKGROUND_INTENSITY );
- originalBackgroundAttributes = csbiInfo.wAttributes & ~( FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_INTENSITY );
- }
-
- virtual void use( Colour::Code _colourCode ) {
- switch( _colourCode ) {
- case Colour::None: return setTextAttribute( originalForegroundAttributes );
- case Colour::White: return setTextAttribute( FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE );
- case Colour::Red: return setTextAttribute( FOREGROUND_RED );
- case Colour::Green: return setTextAttribute( FOREGROUND_GREEN );
- case Colour::Blue: return setTextAttribute( FOREGROUND_BLUE );
- case Colour::Cyan: return setTextAttribute( FOREGROUND_BLUE | FOREGROUND_GREEN );
- case Colour::Yellow: return setTextAttribute( FOREGROUND_RED | FOREGROUND_GREEN );
- case Colour::Grey: return setTextAttribute( 0 );
-
- case Colour::LightGrey: return setTextAttribute( FOREGROUND_INTENSITY );
- case Colour::BrightRed: return setTextAttribute( FOREGROUND_INTENSITY | FOREGROUND_RED );
- case Colour::BrightGreen: return setTextAttribute( FOREGROUND_INTENSITY | FOREGROUND_GREEN );
- case Colour::BrightWhite: return setTextAttribute( FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE );
-
- case Colour::Bright: throw std::logic_error( "not a colour" );
- }
- }
-
- private:
- void setTextAttribute( WORD _textAttribute ) {
- SetConsoleTextAttribute( stdoutHandle, _textAttribute | originalBackgroundAttributes );
- }
- HANDLE stdoutHandle;
- WORD originalForegroundAttributes;
- WORD originalBackgroundAttributes;
- };
-
- IColourImpl* platformColourInstance() {
- static Win32ColourImpl s_instance;
-
- Ptr<IConfig const> config = getCurrentContext().getConfig();
- UseColour::YesOrNo colourMode = config
- ? config->useColour()
- : UseColour::Auto;
- if( colourMode == UseColour::Auto )
- colourMode = !isDebuggerActive()
- ? UseColour::Yes
- : UseColour::No;
- return colourMode == UseColour::Yes
- ? &s_instance
- : NoColourImpl::instance();
- }
-
-} // end anon namespace
-} // end namespace Catch
-
-#elif defined( CATCH_CONFIG_COLOUR_ANSI ) //////////////////////////////////////
-
-#include <unistd.h>
-
-namespace Catch {
-namespace {
-
- // use POSIX/ ANSI console terminal codes
- // Thanks to Adam Strzelecki for original contribution
- // (http://github.com/nanoant)
- // https://github.com/philsquared/Catch/pull/131
- class PosixColourImpl : public IColourImpl {
- public:
- virtual void use( Colour::Code _colourCode ) {
- switch( _colourCode ) {
- case Colour::None:
- case Colour::White: return setColour( "[0m" );
- case Colour::Red: return setColour( "[0;31m" );
- case Colour::Green: return setColour( "[0;32m" );
- case Colour::Blue: return setColour( "[0:34m" );
- case Colour::Cyan: return setColour( "[0;36m" );
- case Colour::Yellow: return setColour( "[0;33m" );
- case Colour::Grey: return setColour( "[1;30m" );
-
- case Colour::LightGrey: return setColour( "[0;37m" );
- case Colour::BrightRed: return setColour( "[1;31m" );
- case Colour::BrightGreen: return setColour( "[1;32m" );
- case Colour::BrightWhite: return setColour( "[1;37m" );
-
- case Colour::Bright: throw std::logic_error( "not a colour" );
- }
- }
- static IColourImpl* instance() {
- static PosixColourImpl s_instance;
- return &s_instance;
- }
-
- private:
- void setColour( const char* _escapeCode ) {
- Catch::cout() << '\033' << _escapeCode;
- }
- };
-
- IColourImpl* platformColourInstance() {
- Ptr<IConfig const> config = getCurrentContext().getConfig();
- UseColour::YesOrNo colourMode = config
- ? config->useColour()
- : UseColour::Auto;
- if( colourMode == UseColour::Auto )
- colourMode = (!isDebuggerActive() && isatty(STDOUT_FILENO) )
- ? UseColour::Yes
- : UseColour::No;
- return colourMode == UseColour::Yes
- ? PosixColourImpl::instance()
- : NoColourImpl::instance();
- }
-
-} // end anon namespace
-} // end namespace Catch
-
-#else // not Windows or ANSI ///////////////////////////////////////////////
-
-namespace Catch {
-
- static IColourImpl* platformColourInstance() { return NoColourImpl::instance(); }
-
-} // end namespace Catch
-
-#endif // Windows/ ANSI/ None
-
-namespace Catch {
-
- Colour::Colour( Code _colourCode ) : m_moved( false ) { use( _colourCode ); }
- Colour::Colour( Colour const& _other ) : m_moved( false ) { const_cast<Colour&>( _other ).m_moved = true; }
- Colour::~Colour(){ if( !m_moved ) use( None ); }
-
- void Colour::use( Code _colourCode ) {
- static IColourImpl* impl = platformColourInstance();
- impl->use( _colourCode );
- }
-
-} // end namespace Catch
-
-// #included from: catch_generators_impl.hpp
-#define TWOBLUECUBES_CATCH_GENERATORS_IMPL_HPP_INCLUDED
-
-#include <vector>
-#include <string>
-#include <map>
-
-namespace Catch {
-
- struct GeneratorInfo : IGeneratorInfo {
-
- GeneratorInfo( std::size_t size )
- : m_size( size ),
- m_currentIndex( 0 )
- {}
-
- bool moveNext() {
- if( ++m_currentIndex == m_size ) {
- m_currentIndex = 0;
- return false;
- }
- return true;
- }
-
- std::size_t getCurrentIndex() const {
- return m_currentIndex;
- }
-
- std::size_t m_size;
- std::size_t m_currentIndex;
- };
-
- ///////////////////////////////////////////////////////////////////////////
-
- class GeneratorsForTest : public IGeneratorsForTest {
-
- public:
- ~GeneratorsForTest() {
- deleteAll( m_generatorsInOrder );
- }
-
- IGeneratorInfo& getGeneratorInfo( std::string const& fileInfo, std::size_t size ) {
- std::map<std::string, IGeneratorInfo*>::const_iterator it = m_generatorsByName.find( fileInfo );
- if( it == m_generatorsByName.end() ) {
- IGeneratorInfo* info = new GeneratorInfo( size );
- m_generatorsByName.insert( std::make_pair( fileInfo, info ) );
- m_generatorsInOrder.push_back( info );
- return *info;
- }
- return *it->second;
- }
-
- bool moveNext() {
- std::vector<IGeneratorInfo*>::const_iterator it = m_generatorsInOrder.begin();
- std::vector<IGeneratorInfo*>::const_iterator itEnd = m_generatorsInOrder.end();
- for(; it != itEnd; ++it ) {
- if( (*it)->moveNext() )
- return true;
- }
- return false;
- }
-
- private:
- std::map<std::string, IGeneratorInfo*> m_generatorsByName;
- std::vector<IGeneratorInfo*> m_generatorsInOrder;
- };
-
- IGeneratorsForTest* createGeneratorsForTest()
- {
- return new GeneratorsForTest();
- }
-
-} // end namespace Catch
-
-// #included from: catch_assertionresult.hpp
-#define TWOBLUECUBES_CATCH_ASSERTIONRESULT_HPP_INCLUDED
-
-namespace Catch {
-
- AssertionInfo::AssertionInfo( std::string const& _macroName,
- SourceLineInfo const& _lineInfo,
- std::string const& _capturedExpression,
- ResultDisposition::Flags _resultDisposition )
- : macroName( _macroName ),
- lineInfo( _lineInfo ),
- capturedExpression( _capturedExpression ),
- resultDisposition( _resultDisposition )
- {}
-
- AssertionResult::AssertionResult() {}
-
- AssertionResult::AssertionResult( AssertionInfo const& info, AssertionResultData const& data )
- : m_info( info ),
- m_resultData( data )
- {}
-
- AssertionResult::~AssertionResult() {}
-
- // Result was a success
- bool AssertionResult::succeeded() const {
- return Catch::isOk( m_resultData.resultType );
- }
-
- // Result was a success, or failure is suppressed
- bool AssertionResult::isOk() const {
- return Catch::isOk( m_resultData.resultType ) || shouldSuppressFailure( m_info.resultDisposition );
- }
-
- ResultWas::OfType AssertionResult::getResultType() const {
- return m_resultData.resultType;
- }
-
- bool AssertionResult::hasExpression() const {
- return !m_info.capturedExpression.empty();
- }
-
- bool AssertionResult::hasMessage() const {
- return !m_resultData.message.empty();
- }
-
- std::string AssertionResult::getExpression() const {
- if( isFalseTest( m_info.resultDisposition ) )
- return "!" + m_info.capturedExpression;
- else
- return m_info.capturedExpression;
- }
- std::string AssertionResult::getExpressionInMacro() const {
- if( m_info.macroName.empty() )
- return m_info.capturedExpression;
- else
- return m_info.macroName + "( " + m_info.capturedExpression + " )";
- }
-
- bool AssertionResult::hasExpandedExpression() const {
- return hasExpression() && getExpandedExpression() != getExpression();
- }
-
- std::string AssertionResult::getExpandedExpression() const {
- return m_resultData.reconstructedExpression;
- }
-
- std::string AssertionResult::getMessage() const {
- return m_resultData.message;
- }
- SourceLineInfo AssertionResult::getSourceInfo() const {
- return m_info.lineInfo;
- }
-
- std::string AssertionResult::getTestMacroName() const {
- return m_info.macroName;
- }
-
-} // end namespace Catch
-
-// #included from: catch_test_case_info.hpp
-#define TWOBLUECUBES_CATCH_TEST_CASE_INFO_HPP_INCLUDED
-
-namespace Catch {
-
- inline TestCaseInfo::SpecialProperties parseSpecialTag( std::string const& tag ) {
- if( startsWith( tag, "." ) ||
- tag == "hide" ||
- tag == "!hide" )
- return TestCaseInfo::IsHidden;
- else if( tag == "!throws" )
- return TestCaseInfo::Throws;
- else if( tag == "!shouldfail" )
- return TestCaseInfo::ShouldFail;
- else if( tag == "!mayfail" )
- return TestCaseInfo::MayFail;
- else
- return TestCaseInfo::None;
- }
- inline bool isReservedTag( std::string const& tag ) {
- return parseSpecialTag( tag ) == TestCaseInfo::None && tag.size() > 0 && !isalnum( tag[0] );
- }
- inline void enforceNotReservedTag( std::string const& tag, SourceLineInfo const& _lineInfo ) {
- if( isReservedTag( tag ) ) {
- {
- Colour colourGuard( Colour::Red );
- Catch::cerr()
- << "Tag name [" << tag << "] not allowed.\n"
- << "Tag names starting with non alpha-numeric characters are reserved\n";
- }
- {
- Colour colourGuard( Colour::FileName );
- Catch::cerr() << _lineInfo << std::endl;
- }
- exit(1);
- }
- }
-
- TestCase makeTestCase( ITestCase* _testCase,
- std::string const& _className,
- std::string const& _name,
- std::string const& _descOrTags,
- SourceLineInfo const& _lineInfo )
- {
- bool isHidden( startsWith( _name, "./" ) ); // Legacy support
-
- // Parse out tags
- std::set<std::string> tags;
- std::string desc, tag;
- bool inTag = false;
- for( std::size_t i = 0; i < _descOrTags.size(); ++i ) {
- char c = _descOrTags[i];
- if( !inTag ) {
- if( c == '[' )
- inTag = true;
- else
- desc += c;
- }
- else {
- if( c == ']' ) {
- TestCaseInfo::SpecialProperties prop = parseSpecialTag( tag );
- if( prop == TestCaseInfo::IsHidden )
- isHidden = true;
- else if( prop == TestCaseInfo::None )
- enforceNotReservedTag( tag, _lineInfo );
-
- tags.insert( tag );
- tag.clear();
- inTag = false;
- }
- else
- tag += c;
- }
- }
- if( isHidden ) {
- tags.insert( "hide" );
- tags.insert( "." );
- }
-
- TestCaseInfo info( _name, _className, desc, tags, _lineInfo );
- return TestCase( _testCase, info );
- }
-
- void setTags( TestCaseInfo& testCaseInfo, std::set<std::string> const& tags )
- {
- testCaseInfo.tags = tags;
- testCaseInfo.lcaseTags.clear();
-
- std::ostringstream oss;
- for( std::set<std::string>::const_iterator it = tags.begin(), itEnd = tags.end(); it != itEnd; ++it ) {
- oss << "[" << *it << "]";
- std::string lcaseTag = toLower( *it );
- testCaseInfo.properties = static_cast<TestCaseInfo::SpecialProperties>( testCaseInfo.properties | parseSpecialTag( lcaseTag ) );
- testCaseInfo.lcaseTags.insert( lcaseTag );
- }
- testCaseInfo.tagsAsString = oss.str();
- }
-
- TestCaseInfo::TestCaseInfo( std::string const& _name,
- std::string const& _className,
- std::string const& _description,
- std::set<std::string> const& _tags,
- SourceLineInfo const& _lineInfo )
- : name( _name ),
- className( _className ),
- description( _description ),
- lineInfo( _lineInfo ),
- properties( None )
- {
- setTags( *this, _tags );
- }
-
- TestCaseInfo::TestCaseInfo( TestCaseInfo const& other )
- : name( other.name ),
- className( other.className ),
- description( other.description ),
- tags( other.tags ),
- lcaseTags( other.lcaseTags ),
- tagsAsString( other.tagsAsString ),
- lineInfo( other.lineInfo ),
- properties( other.properties )
- {}
-
- bool TestCaseInfo::isHidden() const {
- return ( properties & IsHidden ) != 0;
- }
- bool TestCaseInfo::throws() const {
- return ( properties & Throws ) != 0;
- }
- bool TestCaseInfo::okToFail() const {
- return ( properties & (ShouldFail | MayFail ) ) != 0;
- }
- bool TestCaseInfo::expectedToFail() const {
- return ( properties & (ShouldFail ) ) != 0;
- }
-
- TestCase::TestCase( ITestCase* testCase, TestCaseInfo const& info ) : TestCaseInfo( info ), test( testCase ) {}
-
- TestCase::TestCase( TestCase const& other )
- : TestCaseInfo( other ),
- test( other.test )
- {}
-
- TestCase TestCase::withName( std::string const& _newName ) const {
- TestCase other( *this );
- other.name = _newName;
- return other;
- }
-
- void TestCase::swap( TestCase& other ) {
- test.swap( other.test );
- name.swap( other.name );
- className.swap( other.className );
- description.swap( other.description );
- tags.swap( other.tags );
- lcaseTags.swap( other.lcaseTags );
- tagsAsString.swap( other.tagsAsString );
- std::swap( TestCaseInfo::properties, static_cast<TestCaseInfo&>( other ).properties );
- std::swap( lineInfo, other.lineInfo );
- }
-
- void TestCase::invoke() const {
- test->invoke();
- }
-
- bool TestCase::operator == ( TestCase const& other ) const {
- return test.get() == other.test.get() &&
- name == other.name &&
- className == other.className;
- }
-
- bool TestCase::operator < ( TestCase const& other ) const {
- return name < other.name;
- }
- TestCase& TestCase::operator = ( TestCase const& other ) {
- TestCase temp( other );
- swap( temp );
- return *this;
- }
-
- TestCaseInfo const& TestCase::getTestCaseInfo() const
- {
- return *this;
- }
-
-} // end namespace Catch
-
-// #included from: catch_version.hpp
-#define TWOBLUECUBES_CATCH_VERSION_HPP_INCLUDED
-
-namespace Catch {
-
- Version::Version
- ( unsigned int _majorVersion,
- unsigned int _minorVersion,
- unsigned int _patchNumber,
- std::string const& _branchName,
- unsigned int _buildNumber )
- : majorVersion( _majorVersion ),
- minorVersion( _minorVersion ),
- patchNumber( _patchNumber ),
- branchName( _branchName ),
- buildNumber( _buildNumber )
- {}
-
- std::ostream& operator << ( std::ostream& os, Version const& version ) {
- os << version.majorVersion << "."
- << version.minorVersion << "."
- << version.patchNumber;
-
- if( !version.branchName.empty() ) {
- os << "-" << version.branchName
- << "." << version.buildNumber;
- }
- return os;
- }
-
- Version libraryVersion( 1, 5, 1, "", 0 );
-
-}
-
-// #included from: catch_message.hpp
-#define TWOBLUECUBES_CATCH_MESSAGE_HPP_INCLUDED
-
-namespace Catch {
-
- MessageInfo::MessageInfo( std::string const& _macroName,
- SourceLineInfo const& _lineInfo,
- ResultWas::OfType _type )
- : macroName( _macroName ),
- lineInfo( _lineInfo ),
- type( _type ),
- sequence( ++globalCount )
- {}
-
- // This may need protecting if threading support is added
- unsigned int MessageInfo::globalCount = 0;
-
- ////////////////////////////////////////////////////////////////////////////
-
- ScopedMessage::ScopedMessage( MessageBuilder const& builder )
- : m_info( builder.m_info )
- {
- m_info.message = builder.m_stream.str();
- getResultCapture().pushScopedMessage( m_info );
- }
- ScopedMessage::ScopedMessage( ScopedMessage const& other )
- : m_info( other.m_info )
- {}
-
- ScopedMessage::~ScopedMessage() {
- getResultCapture().popScopedMessage( m_info );
- }
-
-} // end namespace Catch
-
-// #included from: catch_legacy_reporter_adapter.hpp
-#define TWOBLUECUBES_CATCH_LEGACY_REPORTER_ADAPTER_HPP_INCLUDED
-
-// #included from: catch_legacy_reporter_adapter.h
-#define TWOBLUECUBES_CATCH_LEGACY_REPORTER_ADAPTER_H_INCLUDED
-
-namespace Catch
-{
- // Deprecated
- struct IReporter : IShared {
- virtual ~IReporter();
-
- virtual bool shouldRedirectStdout() const = 0;
-
- virtual void StartTesting() = 0;
- virtual void EndTesting( Totals const& totals ) = 0;
- virtual void StartGroup( std::string const& groupName ) = 0;
- virtual void EndGroup( std::string const& groupName, Totals const& totals ) = 0;
- virtual void StartTestCase( TestCaseInfo const& testInfo ) = 0;
- virtual void EndTestCase( TestCaseInfo const& testInfo, Totals const& totals, std::string const& stdOut, std::string const& stdErr ) = 0;
- virtual void StartSection( std::string const& sectionName, std::string const& description ) = 0;
- virtual void EndSection( std::string const& sectionName, Counts const& assertions ) = 0;
- virtual void NoAssertionsInSection( std::string const& sectionName ) = 0;
- virtual void NoAssertionsInTestCase( std::string const& testName ) = 0;
- virtual void Aborted() = 0;
- virtual void Result( AssertionResult const& result ) = 0;
- };
-
- class LegacyReporterAdapter : public SharedImpl<IStreamingReporter>
- {
- public:
- LegacyReporterAdapter( Ptr<IReporter> const& legacyReporter );
- virtual ~LegacyReporterAdapter();
-
- virtual ReporterPreferences getPreferences() const;
- virtual void noMatchingTestCases( std::string const& );
- virtual void testRunStarting( TestRunInfo const& );
- virtual void testGroupStarting( GroupInfo const& groupInfo );
- virtual void testCaseStarting( TestCaseInfo const& testInfo );
- virtual void sectionStarting( SectionInfo const& sectionInfo );
- virtual void assertionStarting( AssertionInfo const& );
- virtual bool assertionEnded( AssertionStats const& assertionStats );
- virtual void sectionEnded( SectionStats const& sectionStats );
- virtual void testCaseEnded( TestCaseStats const& testCaseStats );
- virtual void testGroupEnded( TestGroupStats const& testGroupStats );
- virtual void testRunEnded( TestRunStats const& testRunStats );
- virtual void skipTest( TestCaseInfo const& );
-
- private:
- Ptr<IReporter> m_legacyReporter;
- };
-}
-
-namespace Catch
-{
- LegacyReporterAdapter::LegacyReporterAdapter( Ptr<IReporter> const& legacyReporter )
- : m_legacyReporter( legacyReporter )
- {}
- LegacyReporterAdapter::~LegacyReporterAdapter() {}
-
- ReporterPreferences LegacyReporterAdapter::getPreferences() const {
- ReporterPreferences prefs;
- prefs.shouldRedirectStdOut = m_legacyReporter->shouldRedirectStdout();
- return prefs;
- }
-
- void LegacyReporterAdapter::noMatchingTestCases( std::string const& ) {}
- void LegacyReporterAdapter::testRunStarting( TestRunInfo const& ) {
- m_legacyReporter->StartTesting();
- }
- void LegacyReporterAdapter::testGroupStarting( GroupInfo const& groupInfo ) {
- m_legacyReporter->StartGroup( groupInfo.name );
- }
- void LegacyReporterAdapter::testCaseStarting( TestCaseInfo const& testInfo ) {
- m_legacyReporter->StartTestCase( testInfo );
- }
- void LegacyReporterAdapter::sectionStarting( SectionInfo const& sectionInfo ) {
- m_legacyReporter->StartSection( sectionInfo.name, sectionInfo.description );
- }
- void LegacyReporterAdapter::assertionStarting( AssertionInfo const& ) {
- // Not on legacy interface
- }
-
- bool LegacyReporterAdapter::assertionEnded( AssertionStats const& assertionStats ) {
- if( assertionStats.assertionResult.getResultType() != ResultWas::Ok ) {
- for( std::vector<MessageInfo>::const_iterator it = assertionStats.infoMessages.begin(), itEnd = assertionStats.infoMessages.end();
- it != itEnd;
- ++it ) {
- if( it->type == ResultWas::Info ) {
- ResultBuilder rb( it->macroName.c_str(), it->lineInfo, "", ResultDisposition::Normal );
- rb << it->message;
- rb.setResultType( ResultWas::Info );
- AssertionResult result = rb.build();
- m_legacyReporter->Result( result );
- }
- }
- }
- m_legacyReporter->Result( assertionStats.assertionResult );
- return true;
- }
- void LegacyReporterAdapter::sectionEnded( SectionStats const& sectionStats ) {
- if( sectionStats.missingAssertions )
- m_legacyReporter->NoAssertionsInSection( sectionStats.sectionInfo.name );
- m_legacyReporter->EndSection( sectionStats.sectionInfo.name, sectionStats.assertions );
- }
- void LegacyReporterAdapter::testCaseEnded( TestCaseStats const& testCaseStats ) {
- m_legacyReporter->EndTestCase
- ( testCaseStats.testInfo,
- testCaseStats.totals,
- testCaseStats.stdOut,
- testCaseStats.stdErr );
- }
- void LegacyReporterAdapter::testGroupEnded( TestGroupStats const& testGroupStats ) {
- if( testGroupStats.aborting )
- m_legacyReporter->Aborted();
- m_legacyReporter->EndGroup( testGroupStats.groupInfo.name, testGroupStats.totals );
- }
- void LegacyReporterAdapter::testRunEnded( TestRunStats const& testRunStats ) {
- m_legacyReporter->EndTesting( testRunStats.totals );
- }
- void LegacyReporterAdapter::skipTest( TestCaseInfo const& ) {
- }
-}
-
-// #included from: catch_timer.hpp
-
-#ifdef __clang__
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wc++11-long-long"
-#endif
-
-#ifdef CATCH_PLATFORM_WINDOWS
-#include <windows.h>
-#else
-#include <sys/time.h>
-#endif
-
-namespace Catch {
-
- namespace {
-#ifdef CATCH_PLATFORM_WINDOWS
- uint64_t getCurrentTicks() {
- static uint64_t hz=0, hzo=0;
- if (!hz) {
- QueryPerformanceFrequency( reinterpret_cast<LARGE_INTEGER*>( &hz ) );
- QueryPerformanceCounter( reinterpret_cast<LARGE_INTEGER*>( &hzo ) );
- }
- uint64_t t;
- QueryPerformanceCounter( reinterpret_cast<LARGE_INTEGER*>( &t ) );
- return ((t-hzo)*1000000)/hz;
- }
-#else
- uint64_t getCurrentTicks() {
- timeval t;
- gettimeofday(&t,CATCH_NULL);
- return static_cast<uint64_t>( t.tv_sec ) * 1000000ull + static_cast<uint64_t>( t.tv_usec );
- }
-#endif
- }
-
- void Timer::start() {
- m_ticks = getCurrentTicks();
- }
- unsigned int Timer::getElapsedMicroseconds() const {
- return static_cast<unsigned int>(getCurrentTicks() - m_ticks);
- }
- unsigned int Timer::getElapsedMilliseconds() const {
- return static_cast<unsigned int>(getElapsedMicroseconds()/1000);
- }
- double Timer::getElapsedSeconds() const {
- return getElapsedMicroseconds()/1000000.0;
- }
-
-} // namespace Catch
-
-#ifdef __clang__
-#pragma clang diagnostic pop
-#endif
-// #included from: catch_common.hpp
-#define TWOBLUECUBES_CATCH_COMMON_HPP_INCLUDED
-
-namespace Catch {
-
- bool startsWith( std::string const& s, std::string const& prefix ) {
- return s.size() >= prefix.size() && s.substr( 0, prefix.size() ) == prefix;
- }
- bool endsWith( std::string const& s, std::string const& suffix ) {
- return s.size() >= suffix.size() && s.substr( s.size()-suffix.size(), suffix.size() ) == suffix;
- }
- bool contains( std::string const& s, std::string const& infix ) {
- return s.find( infix ) != std::string::npos;
- }
- void toLowerInPlace( std::string& s ) {
- std::transform( s.begin(), s.end(), s.begin(), ::tolower );
- }
- std::string toLower( std::string const& s ) {
- std::string lc = s;
- toLowerInPlace( lc );
- return lc;
- }
- std::string trim( std::string const& str ) {
- static char const* whitespaceChars = "\n\r\t ";
- std::string::size_type start = str.find_first_not_of( whitespaceChars );
- std::string::size_type end = str.find_last_not_of( whitespaceChars );
-
- return start != std::string::npos ? str.substr( start, 1+end-start ) : "";
- }
-
- bool replaceInPlace( std::string& str, std::string const& replaceThis, std::string const& withThis ) {
- bool replaced = false;
- std::size_t i = str.find( replaceThis );
- while( i != std::string::npos ) {
- replaced = true;
- str = str.substr( 0, i ) + withThis + str.substr( i+replaceThis.size() );
- if( i < str.size()-withThis.size() )
- i = str.find( replaceThis, i+withThis.size() );
- else
- i = std::string::npos;
- }
- return replaced;
- }
-
- pluralise::pluralise( std::size_t count, std::string const& label )
- : m_count( count ),
- m_label( label )
- {}
-
- std::ostream& operator << ( std::ostream& os, pluralise const& pluraliser ) {
- os << pluraliser.m_count << " " << pluraliser.m_label;
- if( pluraliser.m_count != 1 )
- os << "s";
- return os;
- }
-
- SourceLineInfo::SourceLineInfo() : line( 0 ){}
- SourceLineInfo::SourceLineInfo( char const* _file, std::size_t _line )
- : file( _file ),
- line( _line )
- {}
- SourceLineInfo::SourceLineInfo( SourceLineInfo const& other )
- : file( other.file ),
- line( other.line )
- {}
- bool SourceLineInfo::empty() const {
- return file.empty();
- }
- bool SourceLineInfo::operator == ( SourceLineInfo const& other ) const {
- return line == other.line && file == other.file;
- }
- bool SourceLineInfo::operator < ( SourceLineInfo const& other ) const {
- return line < other.line || ( line == other.line && file < other.file );
- }
-
- void seedRng( IConfig const& config ) {
- if( config.rngSeed() != 0 )
- std::srand( config.rngSeed() );
- }
- unsigned int rngSeed() {
- return getCurrentContext().getConfig()->rngSeed();
- }
-
- std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info ) {
-#ifndef __GNUG__
- os << info.file << "(" << info.line << ")";
-#else
- os << info.file << ":" << info.line;
-#endif
- return os;
- }
-
- void throwLogicError( std::string const& message, SourceLineInfo const& locationInfo ) {
- std::ostringstream oss;
- oss << locationInfo << ": Internal Catch error: '" << message << "'";
- if( alwaysTrue() )
- throw std::logic_error( oss.str() );
- }
-}
-
-// #included from: catch_section.hpp
-#define TWOBLUECUBES_CATCH_SECTION_HPP_INCLUDED
-
-namespace Catch {
-
- SectionInfo::SectionInfo
- ( SourceLineInfo const& _lineInfo,
- std::string const& _name,
- std::string const& _description )
- : name( _name ),
- description( _description ),
- lineInfo( _lineInfo )
- {}
-
- Section::Section( SectionInfo const& info )
- : m_info( info ),
- m_sectionIncluded( getResultCapture().sectionStarted( m_info, m_assertions ) )
- {
- m_timer.start();
- }
-
- Section::~Section() {
- if( m_sectionIncluded ) {
- SectionEndInfo endInfo( m_info, m_assertions, m_timer.getElapsedSeconds() );
- if( std::uncaught_exception() )
- getResultCapture().sectionEndedEarly( endInfo );
- else
- getResultCapture().sectionEnded( endInfo );
- }
- }
-
- // This indicates whether the section should be executed or not
- Section::operator bool() const {
- return m_sectionIncluded;
- }
-
-} // end namespace Catch
-
-// #included from: catch_debugger.hpp
-#define TWOBLUECUBES_CATCH_DEBUGGER_HPP_INCLUDED
-
-#include <iostream>
-
-#ifdef CATCH_PLATFORM_MAC
-
- #include <assert.h>
- #include <stdbool.h>
- #include <sys/types.h>
- #include <unistd.h>
- #include <sys/sysctl.h>
-
- namespace Catch{
-
- // The following function is taken directly from the following technical note:
- // http://developer.apple.com/library/mac/#qa/qa2004/qa1361.html
-
- // Returns true if the current process is being debugged (either
- // running under the debugger or has a debugger attached post facto).
- bool isDebuggerActive(){
-
- int mib[4];
- struct kinfo_proc info;
- size_t size;
-
- // Initialize the flags so that, if sysctl fails for some bizarre
- // reason, we get a predictable result.
-
- info.kp_proc.p_flag = 0;
-
- // Initialize mib, which tells sysctl the info we want, in this case
- // we're looking for information about a specific process ID.
-
- mib[0] = CTL_KERN;
- mib[1] = KERN_PROC;
- mib[2] = KERN_PROC_PID;
- mib[3] = getpid();
-
- // Call sysctl.
-
- size = sizeof(info);
- if( sysctl(mib, sizeof(mib) / sizeof(*mib), &info, &size, CATCH_NULL, 0) != 0 ) {
- Catch::cerr() << "\n** Call to sysctl failed - unable to determine if debugger is active **\n" << std::endl;
- return false;
- }
-
- // We're being debugged if the P_TRACED flag is set.
-
- return ( (info.kp_proc.p_flag & P_TRACED) != 0 );
- }
- } // namespace Catch
-
-#elif defined(_MSC_VER)
- extern "C" __declspec(dllimport) int __stdcall IsDebuggerPresent();
- namespace Catch {
- bool isDebuggerActive() {
- return IsDebuggerPresent() != 0;
- }
- }
-#elif defined(__MINGW32__)
- extern "C" __declspec(dllimport) int __stdcall IsDebuggerPresent();
- namespace Catch {
- bool isDebuggerActive() {
- return IsDebuggerPresent() != 0;
- }
- }
-#else
- namespace Catch {
- inline bool isDebuggerActive() { return false; }
- }
-#endif // Platform
-
-#ifdef CATCH_PLATFORM_WINDOWS
- extern "C" __declspec(dllimport) void __stdcall OutputDebugStringA( const char* );
- namespace Catch {
- void writeToDebugConsole( std::string const& text ) {
- ::OutputDebugStringA( text.c_str() );
- }
- }
-#else
- namespace Catch {
- void writeToDebugConsole( std::string const& text ) {
- // !TBD: Need a version for Mac/ XCode and other IDEs
- Catch::cout() << text;
- }
- }
-#endif // Platform
-
-// #included from: catch_tostring.hpp
-#define TWOBLUECUBES_CATCH_TOSTRING_HPP_INCLUDED
-
-namespace Catch {
-
-namespace Detail {
-
- const std::string unprintableString = "{?}";
-
- namespace {
- const int hexThreshold = 255;
-
- struct Endianness {
- enum Arch { Big, Little };
-
- static Arch which() {
- union _{
- int asInt;
- char asChar[sizeof (int)];
- } u;
-
- u.asInt = 1;
- return ( u.asChar[sizeof(int)-1] == 1 ) ? Big : Little;
- }
- };
- }
-
- std::string rawMemoryToString( const void *object, std::size_t size )
- {
- // Reverse order for little endian architectures
- int i = 0, end = static_cast<int>( size ), inc = 1;
- if( Endianness::which() == Endianness::Little ) {
- i = end-1;
- end = inc = -1;
- }
-
- unsigned char const *bytes = static_cast<unsigned char const *>(object);
- std::ostringstream os;
- os << "0x" << std::setfill('0') << std::hex;
- for( ; i != end; i += inc )
- os << std::setw(2) << static_cast<unsigned>(bytes[i]);
- return os.str();
- }
-}
-
-std::string toString( std::string const& value ) {
- std::string s = value;
- if( getCurrentContext().getConfig()->showInvisibles() ) {
- for(size_t i = 0; i < s.size(); ++i ) {
- std::string subs;
- switch( s[i] ) {
- case '\n': subs = "\\n"; break;
- case '\t': subs = "\\t"; break;
- default: break;
- }
- if( !subs.empty() ) {
- s = s.substr( 0, i ) + subs + s.substr( i+1 );
- ++i;
- }
- }
- }
- return "\"" + s + "\"";
-}
-std::string toString( std::wstring const& value ) {
-
- std::string s;
- s.reserve( value.size() );
- for(size_t i = 0; i < value.size(); ++i )
- s += value[i] <= 0xff ? static_cast<char>( value[i] ) : '?';
- return Catch::toString( s );
-}
-
-std::string toString( const char* const value ) {
- return value ? Catch::toString( std::string( value ) ) : std::string( "{null string}" );
-}
-
-std::string toString( char* const value ) {
- return Catch::toString( static_cast<const char*>( value ) );
-}
-
-std::string toString( const wchar_t* const value )
-{
- return value ? Catch::toString( std::wstring(value) ) : std::string( "{null string}" );
-}
-
-std::string toString( wchar_t* const value )
-{
- return Catch::toString( static_cast<const wchar_t*>( value ) );
-}
-
-std::string toString( int value ) {
- std::ostringstream oss;
- oss << value;
- if( value > Detail::hexThreshold )
- oss << " (0x" << std::hex << value << ")";
- return oss.str();
-}
-
-std::string toString( unsigned long value ) {
- std::ostringstream oss;
- oss << value;
- if( value > Detail::hexThreshold )
- oss << " (0x" << std::hex << value << ")";
- return oss.str();
-}
-
-std::string toString( unsigned int value ) {
- return Catch::toString( static_cast<unsigned long>( value ) );
-}
-
-template<typename T>
-std::string fpToString( T value, int precision ) {
- std::ostringstream oss;
- oss << std::setprecision( precision )
- << std::fixed
- << value;
- std::string d = oss.str();
- std::size_t i = d.find_last_not_of( '0' );
- if( i != std::string::npos && i != d.size()-1 ) {
- if( d[i] == '.' )
- i++;
- d = d.substr( 0, i+1 );
- }
- return d;
-}
-
-std::string toString( const double value ) {
- return fpToString( value, 10 );
-}
-std::string toString( const float value ) {
- return fpToString( value, 5 ) + "f";
-}
-
-std::string toString( bool value ) {
- return value ? "true" : "false";
-}
-
-std::string toString( char value ) {
- return value < ' '
- ? toString( static_cast<unsigned int>( value ) )
- : Detail::makeString( value );
-}
-
-std::string toString( signed char value ) {
- return toString( static_cast<char>( value ) );
-}
-
-std::string toString( unsigned char value ) {
- return toString( static_cast<char>( value ) );
-}
-
-#ifdef CATCH_CONFIG_CPP11_LONG_LONG
-std::string toString( long long value ) {
- std::ostringstream oss;
- oss << value;
- if( value > Detail::hexThreshold )
- oss << " (0x" << std::hex << value << ")";
- return oss.str();
-}
-std::string toString( unsigned long long value ) {
- std::ostringstream oss;
- oss << value;
- if( value > Detail::hexThreshold )
- oss << " (0x" << std::hex << value << ")";
- return oss.str();
-}
-#endif
-
-#ifdef CATCH_CONFIG_CPP11_NULLPTR
-std::string toString( std::nullptr_t ) {
- return "nullptr";
-}
-#endif
-
-#ifdef __OBJC__
- std::string toString( NSString const * const& nsstring ) {
- if( !nsstring )
- return "nil";
- return "@" + toString([nsstring UTF8String]);
- }
- std::string toString( NSString * CATCH_ARC_STRONG const& nsstring ) {
- if( !nsstring )
- return "nil";
- return "@" + toString([nsstring UTF8String]);
- }
- std::string toString( NSObject* const& nsObject ) {
- return toString( [nsObject description] );
- }
-#endif
-
-} // end namespace Catch
-
-// #included from: catch_result_builder.hpp
-#define TWOBLUECUBES_CATCH_RESULT_BUILDER_HPP_INCLUDED
-
-namespace Catch {
-
- std::string capturedExpressionWithSecondArgument( std::string const& capturedExpression, std::string const& secondArg ) {
- return secondArg.empty() || secondArg == "\"\""
- ? capturedExpression
- : capturedExpression + ", " + secondArg;
- }
- ResultBuilder::ResultBuilder( char const* macroName,
- SourceLineInfo const& lineInfo,
- char const* capturedExpression,
- ResultDisposition::Flags resultDisposition,
- char const* secondArg )
- : m_assertionInfo( macroName, lineInfo, capturedExpressionWithSecondArgument( capturedExpression, secondArg ), resultDisposition ),
- m_shouldDebugBreak( false ),
- m_shouldThrow( false )
- {}
-
- ResultBuilder& ResultBuilder::setResultType( ResultWas::OfType result ) {
- m_data.resultType = result;
- return *this;
- }
- ResultBuilder& ResultBuilder::setResultType( bool result ) {
- m_data.resultType = result ? ResultWas::Ok : ResultWas::ExpressionFailed;
- return *this;
- }
- ResultBuilder& ResultBuilder::setLhs( std::string const& lhs ) {
- m_exprComponents.lhs = lhs;
- return *this;
- }
- ResultBuilder& ResultBuilder::setRhs( std::string const& rhs ) {
- m_exprComponents.rhs = rhs;
- return *this;
- }
- ResultBuilder& ResultBuilder::setOp( std::string const& op ) {
- m_exprComponents.op = op;
- return *this;
- }
-
- void ResultBuilder::endExpression() {
- m_exprComponents.testFalse = isFalseTest( m_assertionInfo.resultDisposition );
- captureExpression();
- }
-
- void ResultBuilder::useActiveException( ResultDisposition::Flags resultDisposition ) {
- m_assertionInfo.resultDisposition = resultDisposition;
- m_stream.oss << Catch::translateActiveException();
- captureResult( ResultWas::ThrewException );
- }
-
- void ResultBuilder::captureResult( ResultWas::OfType resultType ) {
- setResultType( resultType );
- captureExpression();
- }
- void ResultBuilder::captureExpectedException( std::string const& expectedMessage ) {
- if( expectedMessage.empty() )
- captureExpectedException( Matchers::Impl::Generic::AllOf<std::string>() );
- else
- captureExpectedException( Matchers::Equals( expectedMessage ) );
- }
-
- void ResultBuilder::captureExpectedException( Matchers::Impl::Matcher<std::string> const& matcher ) {
-
- assert( m_exprComponents.testFalse == false );
- AssertionResultData data = m_data;
- data.resultType = ResultWas::Ok;
- data.reconstructedExpression = m_assertionInfo.capturedExpression;
-
- std::string actualMessage = Catch::translateActiveException();
- if( !matcher.match( actualMessage ) ) {
- data.resultType = ResultWas::ExpressionFailed;
- data.reconstructedExpression = actualMessage;
- }
- AssertionResult result( m_assertionInfo, data );
- handleResult( result );
- }
-
- void ResultBuilder::captureExpression() {
- AssertionResult result = build();
- handleResult( result );
- }
- void ResultBuilder::handleResult( AssertionResult const& result )
- {
- getResultCapture().assertionEnded( result );
-
- if( !result.isOk() ) {
- if( getCurrentContext().getConfig()->shouldDebugBreak() )
- m_shouldDebugBreak = true;
- if( getCurrentContext().getRunner()->aborting() || (m_assertionInfo.resultDisposition & ResultDisposition::Normal) )
- m_shouldThrow = true;
- }
- }
- void ResultBuilder::react() {
- if( m_shouldThrow )
- throw Catch::TestFailureException();
- }
-
- bool ResultBuilder::shouldDebugBreak() const { return m_shouldDebugBreak; }
- bool ResultBuilder::allowThrows() const { return getCurrentContext().getConfig()->allowThrows(); }
-
- AssertionResult ResultBuilder::build() const
- {
- assert( m_data.resultType != ResultWas::Unknown );
-
- AssertionResultData data = m_data;
-
- // Flip bool results if testFalse is set
- if( m_exprComponents.testFalse ) {
- if( data.resultType == ResultWas::Ok )
- data.resultType = ResultWas::ExpressionFailed;
- else if( data.resultType == ResultWas::ExpressionFailed )
- data.resultType = ResultWas::Ok;
- }
-
- data.message = m_stream.oss.str();
- data.reconstructedExpression = reconstructExpression();
- if( m_exprComponents.testFalse ) {
- if( m_exprComponents.op == "" )
- data.reconstructedExpression = "!" + data.reconstructedExpression;
- else
- data.reconstructedExpression = "!(" + data.reconstructedExpression + ")";
- }
- return AssertionResult( m_assertionInfo, data );
- }
- std::string ResultBuilder::reconstructExpression() const {
- if( m_exprComponents.op == "" )
- return m_exprComponents.lhs.empty() ? m_assertionInfo.capturedExpression : m_exprComponents.op + m_exprComponents.lhs;
- else if( m_exprComponents.op == "matches" )
- return m_exprComponents.lhs + " " + m_exprComponents.rhs;
- else if( m_exprComponents.op != "!" ) {
- if( m_exprComponents.lhs.size() + m_exprComponents.rhs.size() < 40 &&
- m_exprComponents.lhs.find("\n") == std::string::npos &&
- m_exprComponents.rhs.find("\n") == std::string::npos )
- return m_exprComponents.lhs + " " + m_exprComponents.op + " " + m_exprComponents.rhs;
- else
- return m_exprComponents.lhs + "\n" + m_exprComponents.op + "\n" + m_exprComponents.rhs;
- }
- else
- return "{can't expand - use " + m_assertionInfo.macroName + "_FALSE( " + m_assertionInfo.capturedExpression.substr(1) + " ) instead of " + m_assertionInfo.macroName + "( " + m_assertionInfo.capturedExpression + " ) for better diagnostics}";
- }
-
-} // end namespace Catch
-
-// #included from: catch_tag_alias_registry.hpp
-#define TWOBLUECUBES_CATCH_TAG_ALIAS_REGISTRY_HPP_INCLUDED
-
-// #included from: catch_tag_alias_registry.h
-#define TWOBLUECUBES_CATCH_TAG_ALIAS_REGISTRY_H_INCLUDED
-
-#include <map>
-
-namespace Catch {
-
- class TagAliasRegistry : public ITagAliasRegistry {
- public:
- virtual ~TagAliasRegistry();
- virtual Option<TagAlias> find( std::string const& alias ) const;
- virtual std::string expandAliases( std::string const& unexpandedTestSpec ) const;
- void add( char const* alias, char const* tag, SourceLineInfo const& lineInfo );
- static TagAliasRegistry& get();
-
- private:
- std::map<std::string, TagAlias> m_registry;
- };
-
-} // end namespace Catch
-
-#include <map>
-#include <iostream>
-
-namespace Catch {
-
- TagAliasRegistry::~TagAliasRegistry() {}
-
- Option<TagAlias> TagAliasRegistry::find( std::string const& alias ) const {
- std::map<std::string, TagAlias>::const_iterator it = m_registry.find( alias );
- if( it != m_registry.end() )
- return it->second;
- else
- return Option<TagAlias>();
- }
-
- std::string TagAliasRegistry::expandAliases( std::string const& unexpandedTestSpec ) const {
- std::string expandedTestSpec = unexpandedTestSpec;
- for( std::map<std::string, TagAlias>::const_iterator it = m_registry.begin(), itEnd = m_registry.end();
- it != itEnd;
- ++it ) {
- std::size_t pos = expandedTestSpec.find( it->first );
- if( pos != std::string::npos ) {
- expandedTestSpec = expandedTestSpec.substr( 0, pos ) +
- it->second.tag +
- expandedTestSpec.substr( pos + it->first.size() );
- }
- }
- return expandedTestSpec;
- }
-
- void TagAliasRegistry::add( char const* alias, char const* tag, SourceLineInfo const& lineInfo ) {
-
- if( !startsWith( alias, "[@" ) || !endsWith( alias, "]" ) ) {
- std::ostringstream oss;
- oss << "error: tag alias, \"" << alias << "\" is not of the form [@alias name].\n" << lineInfo;
- throw std::domain_error( oss.str().c_str() );
- }
- if( !m_registry.insert( std::make_pair( alias, TagAlias( tag, lineInfo ) ) ).second ) {
- std::ostringstream oss;
- oss << "error: tag alias, \"" << alias << "\" already registered.\n"
- << "\tFirst seen at " << find(alias)->lineInfo << "\n"
- << "\tRedefined at " << lineInfo;
- throw std::domain_error( oss.str().c_str() );
- }
- }
-
- TagAliasRegistry& TagAliasRegistry::get() {
- static TagAliasRegistry instance;
- return instance;
-
- }
-
- ITagAliasRegistry::~ITagAliasRegistry() {}
- ITagAliasRegistry const& ITagAliasRegistry::get() { return TagAliasRegistry::get(); }
-
- RegistrarForTagAliases::RegistrarForTagAliases( char const* alias, char const* tag, SourceLineInfo const& lineInfo ) {
- try {
- TagAliasRegistry::get().add( alias, tag, lineInfo );
- }
- catch( std::exception& ex ) {
- Colour colourGuard( Colour::Red );
- Catch::cerr() << ex.what() << std::endl;
- exit(1);
- }
- }
-
-} // end namespace Catch
-
-// #included from: ../reporters/catch_reporter_multi.hpp
-#define TWOBLUECUBES_CATCH_REPORTER_MULTI_HPP_INCLUDED
-
-namespace Catch {
-
-class MultipleReporters : public SharedImpl<IStreamingReporter> {
- typedef std::vector<Ptr<IStreamingReporter> > Reporters;
- Reporters m_reporters;
-
-public:
- void add( Ptr<IStreamingReporter> const& reporter ) {
- m_reporters.push_back( reporter );
- }
-
-public: // IStreamingReporter
-
- virtual ReporterPreferences getPreferences() const CATCH_OVERRIDE {
- return m_reporters[0]->getPreferences();
- }
-
- virtual void noMatchingTestCases( std::string const& spec ) CATCH_OVERRIDE {
- for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end();
- it != itEnd;
- ++it )
- (*it)->noMatchingTestCases( spec );
- }
-
- virtual void testRunStarting( TestRunInfo const& testRunInfo ) CATCH_OVERRIDE {
- for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end();
- it != itEnd;
- ++it )
- (*it)->testRunStarting( testRunInfo );
- }
-
- virtual void testGroupStarting( GroupInfo const& groupInfo ) CATCH_OVERRIDE {
- for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end();
- it != itEnd;
- ++it )
- (*it)->testGroupStarting( groupInfo );
- }
-
- virtual void testCaseStarting( TestCaseInfo const& testInfo ) CATCH_OVERRIDE {
- for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end();
- it != itEnd;
- ++it )
- (*it)->testCaseStarting( testInfo );
- }
-
- virtual void sectionStarting( SectionInfo const& sectionInfo ) CATCH_OVERRIDE {
- for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end();
- it != itEnd;
- ++it )
- (*it)->sectionStarting( sectionInfo );
- }
-
- virtual void assertionStarting( AssertionInfo const& assertionInfo ) CATCH_OVERRIDE {
- for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end();
- it != itEnd;
- ++it )
- (*it)->assertionStarting( assertionInfo );
- }
-
- // The return value indicates if the messages buffer should be cleared:
- virtual bool assertionEnded( AssertionStats const& assertionStats ) CATCH_OVERRIDE {
- bool clearBuffer = false;
- for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end();
- it != itEnd;
- ++it )
- clearBuffer |= (*it)->assertionEnded( assertionStats );
- return clearBuffer;
- }
-
- virtual void sectionEnded( SectionStats const& sectionStats ) CATCH_OVERRIDE {
- for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end();
- it != itEnd;
- ++it )
- (*it)->sectionEnded( sectionStats );
- }
-
- virtual void testCaseEnded( TestCaseStats const& testCaseStats ) CATCH_OVERRIDE {
- for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end();
- it != itEnd;
- ++it )
- (*it)->testCaseEnded( testCaseStats );
- }
-
- virtual void testGroupEnded( TestGroupStats const& testGroupStats ) CATCH_OVERRIDE {
- for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end();
- it != itEnd;
- ++it )
- (*it)->testGroupEnded( testGroupStats );
- }
-
- virtual void testRunEnded( TestRunStats const& testRunStats ) CATCH_OVERRIDE {
- for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end();
- it != itEnd;
- ++it )
- (*it)->testRunEnded( testRunStats );
- }
-
- virtual void skipTest( TestCaseInfo const& testInfo ) CATCH_OVERRIDE {
- for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end();
- it != itEnd;
- ++it )
- (*it)->skipTest( testInfo );
- }
-
- virtual MultipleReporters* tryAsMulti() CATCH_OVERRIDE {
- return this;
- }
-
-};
-
-Ptr<IStreamingReporter> addReporter( Ptr<IStreamingReporter> const& existingReporter, Ptr<IStreamingReporter> const& additionalReporter ) {
- Ptr<IStreamingReporter> resultingReporter;
-
- if( existingReporter ) {
- MultipleReporters* multi = existingReporter->tryAsMulti();
- if( !multi ) {
- multi = new MultipleReporters;
- resultingReporter = Ptr<IStreamingReporter>( multi );
- if( existingReporter )
- multi->add( existingReporter );
- }
- else
- resultingReporter = existingReporter;
- multi->add( additionalReporter );
- }
- else
- resultingReporter = additionalReporter;
-
- return resultingReporter;
-}
-
-} // end namespace Catch
-
-// #included from: ../reporters/catch_reporter_xml.hpp
-#define TWOBLUECUBES_CATCH_REPORTER_XML_HPP_INCLUDED
-
-// #included from: catch_reporter_bases.hpp
-#define TWOBLUECUBES_CATCH_REPORTER_BASES_HPP_INCLUDED
-
-#include <cstring>
-
-namespace Catch {
-
- struct StreamingReporterBase : SharedImpl<IStreamingReporter> {
-
- StreamingReporterBase( ReporterConfig const& _config )
- : m_config( _config.fullConfig() ),
- stream( _config.stream() )
- {
- m_reporterPrefs.shouldRedirectStdOut = false;
- }
-
- virtual ReporterPreferences getPreferences() const CATCH_OVERRIDE {
- return m_reporterPrefs;
- }
-
- virtual ~StreamingReporterBase() CATCH_OVERRIDE;
-
- virtual void noMatchingTestCases( std::string const& ) CATCH_OVERRIDE {}
-
- virtual void testRunStarting( TestRunInfo const& _testRunInfo ) CATCH_OVERRIDE {
- currentTestRunInfo = _testRunInfo;
- }
- virtual void testGroupStarting( GroupInfo const& _groupInfo ) CATCH_OVERRIDE {
- currentGroupInfo = _groupInfo;
- }
-
- virtual void testCaseStarting( TestCaseInfo const& _testInfo ) CATCH_OVERRIDE {
- currentTestCaseInfo = _testInfo;
- }
- virtual void sectionStarting( SectionInfo const& _sectionInfo ) CATCH_OVERRIDE {
- m_sectionStack.push_back( _sectionInfo );
- }
-
- virtual void sectionEnded( SectionStats const& /* _sectionStats */ ) CATCH_OVERRIDE {
- m_sectionStack.pop_back();
- }
- virtual void testCaseEnded( TestCaseStats const& /* _testCaseStats */ ) CATCH_OVERRIDE {
- currentTestCaseInfo.reset();
- }
- virtual void testGroupEnded( TestGroupStats const& /* _testGroupStats */ ) CATCH_OVERRIDE {
- currentGroupInfo.reset();
- }
- virtual void testRunEnded( TestRunStats const& /* _testRunStats */ ) CATCH_OVERRIDE {
- currentTestCaseInfo.reset();
- currentGroupInfo.reset();
- currentTestRunInfo.reset();
- }
-
- virtual void skipTest( TestCaseInfo const& ) CATCH_OVERRIDE {
- // Don't do anything with this by default.
- // It can optionally be overridden in the derived class.
- }
-
- Ptr<IConfig const> m_config;
- std::ostream& stream;
-
- LazyStat<TestRunInfo> currentTestRunInfo;
- LazyStat<GroupInfo> currentGroupInfo;
- LazyStat<TestCaseInfo> currentTestCaseInfo;
-
- std::vector<SectionInfo> m_sectionStack;
- ReporterPreferences m_reporterPrefs;
- };
-
- struct CumulativeReporterBase : SharedImpl<IStreamingReporter> {
- template<typename T, typename ChildNodeT>
- struct Node : SharedImpl<> {
- explicit Node( T const& _value ) : value( _value ) {}
- virtual ~Node() {}
-
- typedef std::vector<Ptr<ChildNodeT> > ChildNodes;
- T value;
- ChildNodes children;
- };
- struct SectionNode : SharedImpl<> {
- explicit SectionNode( SectionStats const& _stats ) : stats( _stats ) {}
- virtual ~SectionNode();
-
- bool operator == ( SectionNode const& other ) const {
- return stats.sectionInfo.lineInfo == other.stats.sectionInfo.lineInfo;
- }
- bool operator == ( Ptr<SectionNode> const& other ) const {
- return operator==( *other );
- }
-
- SectionStats stats;
- typedef std::vector<Ptr<SectionNode> > ChildSections;
- typedef std::vector<AssertionStats> Assertions;
- ChildSections childSections;
- Assertions assertions;
- std::string stdOut;
- std::string stdErr;
- };
-
- struct BySectionInfo {
- BySectionInfo( SectionInfo const& other ) : m_other( other ) {}
- BySectionInfo( BySectionInfo const& other ) : m_other( other.m_other ) {}
- bool operator() ( Ptr<SectionNode> const& node ) const {
- return node->stats.sectionInfo.lineInfo == m_other.lineInfo;
- }
- private:
- void operator=( BySectionInfo const& );
- SectionInfo const& m_other;
- };
-
- typedef Node<TestCaseStats, SectionNode> TestCaseNode;
- typedef Node<TestGroupStats, TestCaseNode> TestGroupNode;
- typedef Node<TestRunStats, TestGroupNode> TestRunNode;
-
- CumulativeReporterBase( ReporterConfig const& _config )
- : m_config( _config.fullConfig() ),
- stream( _config.stream() )
- {
- m_reporterPrefs.shouldRedirectStdOut = false;
- }
- ~CumulativeReporterBase();
-
- virtual ReporterPreferences getPreferences() const CATCH_OVERRIDE {
- return m_reporterPrefs;
- }
-
- virtual void testRunStarting( TestRunInfo const& ) CATCH_OVERRIDE {}
- virtual void testGroupStarting( GroupInfo const& ) CATCH_OVERRIDE {}
-
- virtual void testCaseStarting( TestCaseInfo const& ) CATCH_OVERRIDE {}
-
- virtual void sectionStarting( SectionInfo const& sectionInfo ) CATCH_OVERRIDE {
- SectionStats incompleteStats( sectionInfo, Counts(), 0, false );
- Ptr<SectionNode> node;
- if( m_sectionStack.empty() ) {
- if( !m_rootSection )
- m_rootSection = new SectionNode( incompleteStats );
- node = m_rootSection;
- }
- else {
- SectionNode& parentNode = *m_sectionStack.back();
- SectionNode::ChildSections::const_iterator it =
- std::find_if( parentNode.childSections.begin(),
- parentNode.childSections.end(),
- BySectionInfo( sectionInfo ) );
- if( it == parentNode.childSections.end() ) {
- node = new SectionNode( incompleteStats );
- parentNode.childSections.push_back( node );
- }
- else
- node = *it;
- }
- m_sectionStack.push_back( node );
- m_deepestSection = node;
- }
-
- virtual void assertionStarting( AssertionInfo const& ) CATCH_OVERRIDE {}
-
- virtual bool assertionEnded( AssertionStats const& assertionStats ) CATCH_OVERRIDE {
- assert( !m_sectionStack.empty() );
- SectionNode& sectionNode = *m_sectionStack.back();
- sectionNode.assertions.push_back( assertionStats );
- return true;
- }
- virtual void sectionEnded( SectionStats const& sectionStats ) CATCH_OVERRIDE {
- assert( !m_sectionStack.empty() );
- SectionNode& node = *m_sectionStack.back();
- node.stats = sectionStats;
- m_sectionStack.pop_back();
- }
- virtual void testCaseEnded( TestCaseStats const& testCaseStats ) CATCH_OVERRIDE {
- Ptr<TestCaseNode> node = new TestCaseNode( testCaseStats );
- assert( m_sectionStack.size() == 0 );
- node->children.push_back( m_rootSection );
- m_testCases.push_back( node );
- m_rootSection.reset();
-
- assert( m_deepestSection );
- m_deepestSection->stdOut = testCaseStats.stdOut;
- m_deepestSection->stdErr = testCaseStats.stdErr;
- }
- virtual void testGroupEnded( TestGroupStats const& testGroupStats ) CATCH_OVERRIDE {
- Ptr<TestGroupNode> node = new TestGroupNode( testGroupStats );
- node->children.swap( m_testCases );
- m_testGroups.push_back( node );
- }
- virtual void testRunEnded( TestRunStats const& testRunStats ) CATCH_OVERRIDE {
- Ptr<TestRunNode> node = new TestRunNode( testRunStats );
- node->children.swap( m_testGroups );
- m_testRuns.push_back( node );
- testRunEndedCumulative();
- }
- virtual void testRunEndedCumulative() = 0;
-
- virtual void skipTest( TestCaseInfo const& ) CATCH_OVERRIDE {}
-
- Ptr<IConfig const> m_config;
- std::ostream& stream;
- std::vector<AssertionStats> m_assertions;
- std::vector<std::vector<Ptr<SectionNode> > > m_sections;
- std::vector<Ptr<TestCaseNode> > m_testCases;
- std::vector<Ptr<TestGroupNode> > m_testGroups;
-
- std::vector<Ptr<TestRunNode> > m_testRuns;
-
- Ptr<SectionNode> m_rootSection;
- Ptr<SectionNode> m_deepestSection;
- std::vector<Ptr<SectionNode> > m_sectionStack;
- ReporterPreferences m_reporterPrefs;
-
- };
-
- template<char C>
- char const* getLineOfChars() {
- static char line[CATCH_CONFIG_CONSOLE_WIDTH] = {0};
- if( !*line ) {
- memset( line, C, CATCH_CONFIG_CONSOLE_WIDTH-1 );
- line[CATCH_CONFIG_CONSOLE_WIDTH-1] = 0;
- }
- return line;
- }
-
- struct TestEventListenerBase : StreamingReporterBase {
- TestEventListenerBase( ReporterConfig const& _config )
- : StreamingReporterBase( _config )
- {}
-
- virtual void assertionStarting( AssertionInfo const& ) CATCH_OVERRIDE {}
- virtual bool assertionEnded( AssertionStats const& ) CATCH_OVERRIDE {
- return false;
- }
- };
-
-} // end namespace Catch
-
-// #included from: ../internal/catch_reporter_registrars.hpp
-#define TWOBLUECUBES_CATCH_REPORTER_REGISTRARS_HPP_INCLUDED
-
-namespace Catch {
-
- template<typename T>
- class LegacyReporterRegistrar {
-
- class ReporterFactory : public IReporterFactory {
- virtual IStreamingReporter* create( ReporterConfig const& config ) const {
- return new LegacyReporterAdapter( new T( config ) );
- }
-
- virtual std::string getDescription() const {
- return T::getDescription();
- }
- };
-
- public:
-
- LegacyReporterRegistrar( std::string const& name ) {
- getMutableRegistryHub().registerReporter( name, new ReporterFactory() );
- }
- };
-
- template<typename T>
- class ReporterRegistrar {
-
- class ReporterFactory : public SharedImpl<IReporterFactory> {
-
- // *** Please Note ***:
- // - If you end up here looking at a compiler error because it's trying to register
- // your custom reporter class be aware that the native reporter interface has changed
- // to IStreamingReporter. The "legacy" interface, IReporter, is still supported via
- // an adapter. Just use REGISTER_LEGACY_REPORTER to take advantage of the adapter.
- // However please consider updating to the new interface as the old one is now
- // deprecated and will probably be removed quite soon!
- // Please contact me via github if you have any questions at all about this.
- // In fact, ideally, please contact me anyway to let me know you've hit this - as I have
- // no idea who is actually using custom reporters at all (possibly no-one!).
- // The new interface is designed to minimise exposure to interface changes in the future.
- virtual IStreamingReporter* create( ReporterConfig const& config ) const {
- return new T( config );
- }
-
- virtual std::string getDescription() const {
- return T::getDescription();
- }
- };
-
- public:
-
- ReporterRegistrar( std::string const& name ) {
- getMutableRegistryHub().registerReporter( name, new ReporterFactory() );
- }
- };
-
- template<typename T>
- class ListenerRegistrar {
-
- class ListenerFactory : public SharedImpl<IReporterFactory> {
-
- virtual IStreamingReporter* create( ReporterConfig const& config ) const {
- return new T( config );
- }
- virtual std::string getDescription() const {
- return "";
- }
- };
-
- public:
-
- ListenerRegistrar() {
- getMutableRegistryHub().registerListener( new ListenerFactory() );
- }
- };
-}
-
-#define INTERNAL_CATCH_REGISTER_LEGACY_REPORTER( name, reporterType ) \
- namespace{ Catch::LegacyReporterRegistrar<reporterType> catch_internal_RegistrarFor##reporterType( name ); }
-
-#define INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType ) \
- namespace{ Catch::ReporterRegistrar<reporterType> catch_internal_RegistrarFor##reporterType( name ); }
-
-#define INTERNAL_CATCH_REGISTER_LISTENER( listenerType ) \
- namespace{ Catch::ListenerRegistrar<listenerType> catch_internal_RegistrarFor##listenerType; }
-
-// #included from: ../internal/catch_xmlwriter.hpp
-#define TWOBLUECUBES_CATCH_XMLWRITER_HPP_INCLUDED
-
-#include <sstream>
-#include <string>
-#include <vector>
-#include <iomanip>
-
-namespace Catch {
-
- class XmlEncode {
- public:
- enum ForWhat { ForTextNodes, ForAttributes };
-
- XmlEncode( std::string const& str, ForWhat forWhat = ForTextNodes )
- : m_str( str ),
- m_forWhat( forWhat )
- {}
-
- void encodeTo( std::ostream& os ) const {
-
- // Apostrophe escaping not necessary if we always use " to write attributes
- // (see: http://www.w3.org/TR/xml/#syntax)
-
- for( std::size_t i = 0; i < m_str.size(); ++ i ) {
- char c = m_str[i];
- switch( c ) {
- case '<': os << "&lt;"; break;
- case '&': os << "&amp;"; break;
-
- case '>':
- // See: http://www.w3.org/TR/xml/#syntax
- if( i > 2 && m_str[i-1] == ']' && m_str[i-2] == ']' )
- os << "&gt;";
- else
- os << c;
- break;
-
- case '\"':
- if( m_forWhat == ForAttributes )
- os << "&quot;";
- else
- os << c;
- break;
-
- default:
- // Escape control chars - based on contribution by @espenalb in PR #465
- if ( ( c < '\x09' ) || ( c > '\x0D' && c < '\x20') || c=='\x7F' )
- os << "&#x" << std::uppercase << std::hex << static_cast<int>( c );
- else
- os << c;
- }
- }
- }
-
- friend std::ostream& operator << ( std::ostream& os, XmlEncode const& xmlEncode ) {
- xmlEncode.encodeTo( os );
- return os;
- }
-
- private:
- std::string m_str;
- ForWhat m_forWhat;
- };
-
- class XmlWriter {
- public:
-
- class ScopedElement {
- public:
- ScopedElement( XmlWriter* writer )
- : m_writer( writer )
- {}
-
- ScopedElement( ScopedElement const& other )
- : m_writer( other.m_writer ){
- other.m_writer = CATCH_NULL;
- }
-
- ~ScopedElement() {
- if( m_writer )
- m_writer->endElement();
- }
-
- ScopedElement& writeText( std::string const& text, bool indent = true ) {
- m_writer->writeText( text, indent );
- return *this;
- }
-
- template<typename T>
- ScopedElement& writeAttribute( std::string const& name, T const& attribute ) {
- m_writer->writeAttribute( name, attribute );
- return *this;
- }
-
- private:
- mutable XmlWriter* m_writer;
- };
-
- XmlWriter()
- : m_tagIsOpen( false ),
- m_needsNewline( false ),
- m_os( &Catch::cout() )
- {}
-
- XmlWriter( std::ostream& os )
- : m_tagIsOpen( false ),
- m_needsNewline( false ),
- m_os( &os )
- {}
-
- ~XmlWriter() {
- while( !m_tags.empty() )
- endElement();
- }
-
- XmlWriter& startElement( std::string const& name ) {
- ensureTagClosed();
- newlineIfNecessary();
- stream() << m_indent << "<" << name;
- m_tags.push_back( name );
- m_indent += " ";
- m_tagIsOpen = true;
- return *this;
- }
-
- ScopedElement scopedElement( std::string const& name ) {
- ScopedElement scoped( this );
- startElement( name );
- return scoped;
- }
-
- XmlWriter& endElement() {
- newlineIfNecessary();
- m_indent = m_indent.substr( 0, m_indent.size()-2 );
- if( m_tagIsOpen ) {
- stream() << "/>\n";
- m_tagIsOpen = false;
- }
- else {
- stream() << m_indent << "</" << m_tags.back() << ">\n";
- }
- m_tags.pop_back();
- return *this;
- }
-
- XmlWriter& writeAttribute( std::string const& name, std::string const& attribute ) {
- if( !name.empty() && !attribute.empty() )
- stream() << " " << name << "=\"" << XmlEncode( attribute, XmlEncode::ForAttributes ) << "\"";
- return *this;
- }
-
- XmlWriter& writeAttribute( std::string const& name, bool attribute ) {
- stream() << " " << name << "=\"" << ( attribute ? "true" : "false" ) << "\"";
- return *this;
- }
-
- template<typename T>
- XmlWriter& writeAttribute( std::string const& name, T const& attribute ) {
- std::ostringstream oss;
- oss << attribute;
- return writeAttribute( name, oss.str() );
- }
-
- XmlWriter& writeText( std::string const& text, bool indent = true ) {
- if( !text.empty() ){
- bool tagWasOpen = m_tagIsOpen;
- ensureTagClosed();
- if( tagWasOpen && indent )
- stream() << m_indent;
- stream() << XmlEncode( text );
- m_needsNewline = true;
- }
- return *this;
- }
-
- XmlWriter& writeComment( std::string const& text ) {
- ensureTagClosed();
- stream() << m_indent << "<!--" << text << "-->";
- m_needsNewline = true;
- return *this;
- }
-
- XmlWriter& writeBlankLine() {
- ensureTagClosed();
- stream() << "\n";
- return *this;
- }
-
- void setStream( std::ostream& os ) {
- m_os = &os;
- }
-
- private:
- XmlWriter( XmlWriter const& );
- void operator=( XmlWriter const& );
-
- std::ostream& stream() {
- return *m_os;
- }
-
- void ensureTagClosed() {
- if( m_tagIsOpen ) {
- stream() << ">\n";
- m_tagIsOpen = false;
- }
- }
-
- void newlineIfNecessary() {
- if( m_needsNewline ) {
- stream() << "\n";
- m_needsNewline = false;
- }
- }
-
- bool m_tagIsOpen;
- bool m_needsNewline;
- std::vector<std::string> m_tags;
- std::string m_indent;
- std::ostream* m_os;
- };
-
-}
-// #included from: catch_reenable_warnings.h
-
-#define TWOBLUECUBES_CATCH_REENABLE_WARNINGS_H_INCLUDED
-
-#ifdef __clang__
-# ifdef __ICC // icpc defines the __clang__ macro
-# pragma warning(pop)
-# else
-# pragma clang diagnostic pop
-# endif
-#elif defined __GNUC__
-# pragma GCC diagnostic pop
-#endif
-
-
-namespace Catch {
- class XmlReporter : public StreamingReporterBase {
- public:
- XmlReporter( ReporterConfig const& _config )
- : StreamingReporterBase( _config ),
- m_sectionDepth( 0 )
- {
- m_reporterPrefs.shouldRedirectStdOut = true;
- }
-
- virtual ~XmlReporter() CATCH_OVERRIDE;
-
- static std::string getDescription() {
- return "Reports test results as an XML document";
- }
-
- public: // StreamingReporterBase
-
- virtual void noMatchingTestCases( std::string const& s ) CATCH_OVERRIDE {
- StreamingReporterBase::noMatchingTestCases( s );
- }
-
- virtual void testRunStarting( TestRunInfo const& testInfo ) CATCH_OVERRIDE {
- StreamingReporterBase::testRunStarting( testInfo );
- m_xml.setStream( stream );
- m_xml.startElement( "Catch" );
- if( !m_config->name().empty() )
- m_xml.writeAttribute( "name", m_config->name() );
- }
-
- virtual void testGroupStarting( GroupInfo const& groupInfo ) CATCH_OVERRIDE {
- StreamingReporterBase::testGroupStarting( groupInfo );
- m_xml.startElement( "Group" )
- .writeAttribute( "name", groupInfo.name );
- }
-
- virtual void testCaseStarting( TestCaseInfo const& testInfo ) CATCH_OVERRIDE {
- StreamingReporterBase::testCaseStarting(testInfo);
- m_xml.startElement( "TestCase" ).writeAttribute( "name", trim( testInfo.name ) );
-
- if ( m_config->showDurations() == ShowDurations::Always )
- m_testCaseTimer.start();
- }
-
- virtual void sectionStarting( SectionInfo const& sectionInfo ) CATCH_OVERRIDE {
- StreamingReporterBase::sectionStarting( sectionInfo );
- if( m_sectionDepth++ > 0 ) {
- m_xml.startElement( "Section" )
- .writeAttribute( "name", trim( sectionInfo.name ) )
- .writeAttribute( "description", sectionInfo.description );
- }
- }
-
- virtual void assertionStarting( AssertionInfo const& ) CATCH_OVERRIDE { }
-
- virtual bool assertionEnded( AssertionStats const& assertionStats ) CATCH_OVERRIDE {
- const AssertionResult& assertionResult = assertionStats.assertionResult;
-
- // Print any info messages in <Info> tags.
- if( assertionStats.assertionResult.getResultType() != ResultWas::Ok ) {
- for( std::vector<MessageInfo>::const_iterator it = assertionStats.infoMessages.begin(), itEnd = assertionStats.infoMessages.end();
- it != itEnd;
- ++it ) {
- if( it->type == ResultWas::Info ) {
- m_xml.scopedElement( "Info" )
- .writeText( it->message );
- } else if ( it->type == ResultWas::Warning ) {
- m_xml.scopedElement( "Warning" )
- .writeText( it->message );
- }
- }
- }
-
- // Drop out if result was successful but we're not printing them.
- if( !m_config->includeSuccessfulResults() && isOk(assertionResult.getResultType()) )
- return true;
-
- // Print the expression if there is one.
- if( assertionResult.hasExpression() ) {
- m_xml.startElement( "Expression" )
- .writeAttribute( "success", assertionResult.succeeded() )
- .writeAttribute( "type", assertionResult.getTestMacroName() )
- .writeAttribute( "filename", assertionResult.getSourceInfo().file )
- .writeAttribute( "line", assertionResult.getSourceInfo().line );
-
- m_xml.scopedElement( "Original" )
- .writeText( assertionResult.getExpression() );
- m_xml.scopedElement( "Expanded" )
- .writeText( assertionResult.getExpandedExpression() );
- }
-
- // And... Print a result applicable to each result type.
- switch( assertionResult.getResultType() ) {
- case ResultWas::ThrewException:
- m_xml.scopedElement( "Exception" )
- .writeAttribute( "filename", assertionResult.getSourceInfo().file )
- .writeAttribute( "line", assertionResult.getSourceInfo().line )
- .writeText( assertionResult.getMessage() );
- break;
- case ResultWas::FatalErrorCondition:
- m_xml.scopedElement( "Fatal Error Condition" )
- .writeAttribute( "filename", assertionResult.getSourceInfo().file )
- .writeAttribute( "line", assertionResult.getSourceInfo().line )
- .writeText( assertionResult.getMessage() );
- break;
- case ResultWas::Info:
- m_xml.scopedElement( "Info" )
- .writeText( assertionResult.getMessage() );
- break;
- case ResultWas::Warning:
- // Warning will already have been written
- break;
- case ResultWas::ExplicitFailure:
- m_xml.scopedElement( "Failure" )
- .writeText( assertionResult.getMessage() );
- break;
- default:
- break;
- }
-
- if( assertionResult.hasExpression() )
- m_xml.endElement();
-
- return true;
- }
-
- virtual void sectionEnded( SectionStats const& sectionStats ) CATCH_OVERRIDE {
- StreamingReporterBase::sectionEnded( sectionStats );
- if( --m_sectionDepth > 0 ) {
- XmlWriter::ScopedElement e = m_xml.scopedElement( "OverallResults" );
- e.writeAttribute( "successes", sectionStats.assertions.passed );
- e.writeAttribute( "failures", sectionStats.assertions.failed );
- e.writeAttribute( "expectedFailures", sectionStats.assertions.failedButOk );
-
- if ( m_config->showDurations() == ShowDurations::Always )
- e.writeAttribute( "durationInSeconds", sectionStats.durationInSeconds );
-
- m_xml.endElement();
- }
- }
-
- virtual void testCaseEnded( TestCaseStats const& testCaseStats ) CATCH_OVERRIDE {
- StreamingReporterBase::testCaseEnded( testCaseStats );
- XmlWriter::ScopedElement e = m_xml.scopedElement( "OverallResult" );
- e.writeAttribute( "success", testCaseStats.totals.assertions.allOk() );
-
- if ( m_config->showDurations() == ShowDurations::Always )
- e.writeAttribute( "durationInSeconds", m_testCaseTimer.getElapsedSeconds() );
-
- m_xml.endElement();
- }
-
- virtual void testGroupEnded( TestGroupStats const& testGroupStats ) CATCH_OVERRIDE {
- StreamingReporterBase::testGroupEnded( testGroupStats );
- // TODO: Check testGroupStats.aborting and act accordingly.
- m_xml.scopedElement( "OverallResults" )
- .writeAttribute( "successes", testGroupStats.totals.assertions.passed )
- .writeAttribute( "failures", testGroupStats.totals.assertions.failed )
- .writeAttribute( "expectedFailures", testGroupStats.totals.assertions.failedButOk );
- m_xml.endElement();
- }
-
- virtual void testRunEnded( TestRunStats const& testRunStats ) CATCH_OVERRIDE {
- StreamingReporterBase::testRunEnded( testRunStats );
- m_xml.scopedElement( "OverallResults" )
- .writeAttribute( "successes", testRunStats.totals.assertions.passed )
- .writeAttribute( "failures", testRunStats.totals.assertions.failed )
- .writeAttribute( "expectedFailures", testRunStats.totals.assertions.failedButOk );
- m_xml.endElement();
- }
-
- private:
- Timer m_testCaseTimer;
- XmlWriter m_xml;
- int m_sectionDepth;
- };
-
- INTERNAL_CATCH_REGISTER_REPORTER( "xml", XmlReporter )
-
-} // end namespace Catch
-
-// #included from: ../reporters/catch_reporter_junit.hpp
-#define TWOBLUECUBES_CATCH_REPORTER_JUNIT_HPP_INCLUDED
-
-#include <assert.h>
-
-namespace Catch {
-
- class JunitReporter : public CumulativeReporterBase {
- public:
- JunitReporter( ReporterConfig const& _config )
- : CumulativeReporterBase( _config ),
- xml( _config.stream() )
- {
- m_reporterPrefs.shouldRedirectStdOut = true;
- }
-
- virtual ~JunitReporter() CATCH_OVERRIDE;
-
- static std::string getDescription() {
- return "Reports test results in an XML format that looks like Ant's junitreport target";
- }
-
- virtual void noMatchingTestCases( std::string const& /*spec*/ ) CATCH_OVERRIDE {}
-
- virtual void testRunStarting( TestRunInfo const& runInfo ) CATCH_OVERRIDE {
- CumulativeReporterBase::testRunStarting( runInfo );
- xml.startElement( "testsuites" );
- }
-
- virtual void testGroupStarting( GroupInfo const& groupInfo ) CATCH_OVERRIDE {
- suiteTimer.start();
- stdOutForSuite.str("");
- stdErrForSuite.str("");
- unexpectedExceptions = 0;
- CumulativeReporterBase::testGroupStarting( groupInfo );
- }
-
- virtual bool assertionEnded( AssertionStats const& assertionStats ) CATCH_OVERRIDE {
- if( assertionStats.assertionResult.getResultType() == ResultWas::ThrewException )
- unexpectedExceptions++;
- return CumulativeReporterBase::assertionEnded( assertionStats );
- }
-
- virtual void testCaseEnded( TestCaseStats const& testCaseStats ) CATCH_OVERRIDE {
- stdOutForSuite << testCaseStats.stdOut;
- stdErrForSuite << testCaseStats.stdErr;
- CumulativeReporterBase::testCaseEnded( testCaseStats );
- }
-
- virtual void testGroupEnded( TestGroupStats const& testGroupStats ) CATCH_OVERRIDE {
- double suiteTime = suiteTimer.getElapsedSeconds();
- CumulativeReporterBase::testGroupEnded( testGroupStats );
- writeGroup( *m_testGroups.back(), suiteTime );
- }
-
- virtual void testRunEndedCumulative() CATCH_OVERRIDE {
- xml.endElement();
- }
-
- void writeGroup( TestGroupNode const& groupNode, double suiteTime ) {
- XmlWriter::ScopedElement e = xml.scopedElement( "testsuite" );
- TestGroupStats const& stats = groupNode.value;
- xml.writeAttribute( "name", stats.groupInfo.name );
- xml.writeAttribute( "errors", unexpectedExceptions );
- xml.writeAttribute( "failures", stats.totals.assertions.failed-unexpectedExceptions );
- xml.writeAttribute( "tests", stats.totals.assertions.total() );
- xml.writeAttribute( "hostname", "tbd" ); // !TBD
- if( m_config->showDurations() == ShowDurations::Never )
- xml.writeAttribute( "time", "" );
- else
- xml.writeAttribute( "time", suiteTime );
- xml.writeAttribute( "timestamp", "tbd" ); // !TBD
-
- // Write test cases
- for( TestGroupNode::ChildNodes::const_iterator
- it = groupNode.children.begin(), itEnd = groupNode.children.end();
- it != itEnd;
- ++it )
- writeTestCase( **it );
-
- xml.scopedElement( "system-out" ).writeText( trim( stdOutForSuite.str() ), false );
- xml.scopedElement( "system-err" ).writeText( trim( stdErrForSuite.str() ), false );
- }
-
- void writeTestCase( TestCaseNode const& testCaseNode ) {
- TestCaseStats const& stats = testCaseNode.value;
-
- // All test cases have exactly one section - which represents the
- // test case itself. That section may have 0-n nested sections
- assert( testCaseNode.children.size() == 1 );
- SectionNode const& rootSection = *testCaseNode.children.front();
-
- std::string className = stats.testInfo.className;
-
- if( className.empty() ) {
- if( rootSection.childSections.empty() )
- className = "global";
- }
- writeSection( className, "", rootSection );
- }
-
- void writeSection( std::string const& className,
- std::string const& rootName,
- SectionNode const& sectionNode ) {
- std::string name = trim( sectionNode.stats.sectionInfo.name );
- if( !rootName.empty() )
- name = rootName + "/" + name;
-
- if( !sectionNode.assertions.empty() ||
- !sectionNode.stdOut.empty() ||
- !sectionNode.stdErr.empty() ) {
- XmlWriter::ScopedElement e = xml.scopedElement( "testcase" );
- if( className.empty() ) {
- xml.writeAttribute( "classname", name );
- xml.writeAttribute( "name", "root" );
- }
- else {
- xml.writeAttribute( "classname", className );
- xml.writeAttribute( "name", name );
- }
- xml.writeAttribute( "time", Catch::toString( sectionNode.stats.durationInSeconds ) );
-
- writeAssertions( sectionNode );
-
- if( !sectionNode.stdOut.empty() )
- xml.scopedElement( "system-out" ).writeText( trim( sectionNode.stdOut ), false );
- if( !sectionNode.stdErr.empty() )
- xml.scopedElement( "system-err" ).writeText( trim( sectionNode.stdErr ), false );
- }
- for( SectionNode::ChildSections::const_iterator
- it = sectionNode.childSections.begin(),
- itEnd = sectionNode.childSections.end();
- it != itEnd;
- ++it )
- if( className.empty() )
- writeSection( name, "", **it );
- else
- writeSection( className, name, **it );
- }
-
- void writeAssertions( SectionNode const& sectionNode ) {
- for( SectionNode::Assertions::const_iterator
- it = sectionNode.assertions.begin(), itEnd = sectionNode.assertions.end();
- it != itEnd;
- ++it )
- writeAssertion( *it );
- }
- void writeAssertion( AssertionStats const& stats ) {
- AssertionResult const& result = stats.assertionResult;
- if( !result.isOk() ) {
- std::string elementName;
- switch( result.getResultType() ) {
- case ResultWas::ThrewException:
- case ResultWas::FatalErrorCondition:
- elementName = "error";
- break;
- case ResultWas::ExplicitFailure:
- elementName = "failure";
- break;
- case ResultWas::ExpressionFailed:
- elementName = "failure";
- break;
- case ResultWas::DidntThrowException:
- elementName = "failure";
- break;
-
- // We should never see these here:
- case ResultWas::Info:
- case ResultWas::Warning:
- case ResultWas::Ok:
- case ResultWas::Unknown:
- case ResultWas::FailureBit:
- case ResultWas::Exception:
- elementName = "internalError";
- break;
- }
-
- XmlWriter::ScopedElement e = xml.scopedElement( elementName );
-
- xml.writeAttribute( "message", result.getExpandedExpression() );
- xml.writeAttribute( "type", result.getTestMacroName() );
-
- std::ostringstream oss;
- if( !result.getMessage().empty() )
- oss << result.getMessage() << "\n";
- for( std::vector<MessageInfo>::const_iterator
- it = stats.infoMessages.begin(),
- itEnd = stats.infoMessages.end();
- it != itEnd;
- ++it )
- if( it->type == ResultWas::Info )
- oss << it->message << "\n";
-
- oss << "at " << result.getSourceInfo();
- xml.writeText( oss.str(), false );
- }
- }
-
- XmlWriter xml;
- Timer suiteTimer;
- std::ostringstream stdOutForSuite;
- std::ostringstream stdErrForSuite;
- unsigned int unexpectedExceptions;
- };
-
- INTERNAL_CATCH_REGISTER_REPORTER( "junit", JunitReporter )
-
-} // end namespace Catch
-
-// #included from: ../reporters/catch_reporter_console.hpp
-#define TWOBLUECUBES_CATCH_REPORTER_CONSOLE_HPP_INCLUDED
-
-namespace Catch {
-
- struct ConsoleReporter : StreamingReporterBase {
- ConsoleReporter( ReporterConfig const& _config )
- : StreamingReporterBase( _config ),
- m_headerPrinted( false )
- {}
-
- virtual ~ConsoleReporter() CATCH_OVERRIDE;
- static std::string getDescription() {
- return "Reports test results as plain lines of text";
- }
-
- virtual void noMatchingTestCases( std::string const& spec ) CATCH_OVERRIDE {
- stream << "No test cases matched '" << spec << "'" << std::endl;
- }
-
- virtual void assertionStarting( AssertionInfo const& ) CATCH_OVERRIDE {
- }
-
- virtual bool assertionEnded( AssertionStats const& _assertionStats ) CATCH_OVERRIDE {
- AssertionResult const& result = _assertionStats.assertionResult;
-
- bool printInfoMessages = true;
-
- // Drop out if result was successful and we're not printing those
- if( !m_config->includeSuccessfulResults() && result.isOk() ) {
- if( result.getResultType() != ResultWas::Warning )
- return false;
- printInfoMessages = false;
- }
-
- lazyPrint();
-
- AssertionPrinter printer( stream, _assertionStats, printInfoMessages );
- printer.print();
- stream << std::endl;
- return true;
- }
-
- virtual void sectionStarting( SectionInfo const& _sectionInfo ) CATCH_OVERRIDE {
- m_headerPrinted = false;
- StreamingReporterBase::sectionStarting( _sectionInfo );
- }
- virtual void sectionEnded( SectionStats const& _sectionStats ) CATCH_OVERRIDE {
- if( _sectionStats.missingAssertions ) {
- lazyPrint();
- Colour colour( Colour::ResultError );
- if( m_sectionStack.size() > 1 )
- stream << "\nNo assertions in section";
- else
- stream << "\nNo assertions in test case";
- stream << " '" << _sectionStats.sectionInfo.name << "'\n" << std::endl;
- }
- if( m_headerPrinted ) {
- if( m_config->showDurations() == ShowDurations::Always )
- stream << "Completed in " << _sectionStats.durationInSeconds << "s" << std::endl;
- m_headerPrinted = false;
- }
- else {
- if( m_config->showDurations() == ShowDurations::Always )
- stream << _sectionStats.sectionInfo.name << " completed in " << _sectionStats.durationInSeconds << "s" << std::endl;
- }
- StreamingReporterBase::sectionEnded( _sectionStats );
- }
-
- virtual void testCaseEnded( TestCaseStats const& _testCaseStats ) CATCH_OVERRIDE {
- StreamingReporterBase::testCaseEnded( _testCaseStats );
- m_headerPrinted = false;
- }
- virtual void testGroupEnded( TestGroupStats const& _testGroupStats ) CATCH_OVERRIDE {
- if( currentGroupInfo.used ) {
- printSummaryDivider();
- stream << "Summary for group '" << _testGroupStats.groupInfo.name << "':\n";
- printTotals( _testGroupStats.totals );
- stream << "\n" << std::endl;
- }
- StreamingReporterBase::testGroupEnded( _testGroupStats );
- }
- virtual void testRunEnded( TestRunStats const& _testRunStats ) CATCH_OVERRIDE {
- printTotalsDivider( _testRunStats.totals );
- printTotals( _testRunStats.totals );
- stream << std::endl;
- StreamingReporterBase::testRunEnded( _testRunStats );
- }
-
- private:
-
- class AssertionPrinter {
- void operator= ( AssertionPrinter const& );
- public:
- AssertionPrinter( std::ostream& _stream, AssertionStats const& _stats, bool _printInfoMessages )
- : stream( _stream ),
- stats( _stats ),
- result( _stats.assertionResult ),
- colour( Colour::None ),
- message( result.getMessage() ),
- messages( _stats.infoMessages ),
- printInfoMessages( _printInfoMessages )
- {
- switch( result.getResultType() ) {
- case ResultWas::Ok:
- colour = Colour::Success;
- passOrFail = "PASSED";
- //if( result.hasMessage() )
- if( _stats.infoMessages.size() == 1 )
- messageLabel = "with message";
- if( _stats.infoMessages.size() > 1 )
- messageLabel = "with messages";
- break;
- case ResultWas::ExpressionFailed:
- if( result.isOk() ) {
- colour = Colour::Success;
- passOrFail = "FAILED - but was ok";
- }
- else {
- colour = Colour::Error;
- passOrFail = "FAILED";
- }
- if( _stats.infoMessages.size() == 1 )
- messageLabel = "with message";
- if( _stats.infoMessages.size() > 1 )
- messageLabel = "with messages";
- break;
- case ResultWas::ThrewException:
- colour = Colour::Error;
- passOrFail = "FAILED";
- messageLabel = "due to unexpected exception with message";
- break;
- case ResultWas::FatalErrorCondition:
- colour = Colour::Error;
- passOrFail = "FAILED";
- messageLabel = "due to a fatal error condition";
- break;
- case ResultWas::DidntThrowException:
- colour = Colour::Error;
- passOrFail = "FAILED";
- messageLabel = "because no exception was thrown where one was expected";
- break;
- case ResultWas::Info:
- messageLabel = "info";
- break;
- case ResultWas::Warning:
- messageLabel = "warning";
- break;
- case ResultWas::ExplicitFailure:
- passOrFail = "FAILED";
- colour = Colour::Error;
- if( _stats.infoMessages.size() == 1 )
- messageLabel = "explicitly with message";
- if( _stats.infoMessages.size() > 1 )
- messageLabel = "explicitly with messages";
- break;
- // These cases are here to prevent compiler warnings
- case ResultWas::Unknown:
- case ResultWas::FailureBit:
- case ResultWas::Exception:
- passOrFail = "** internal error **";
- colour = Colour::Error;
- break;
- }
- }
-
- void print() const {
- printSourceInfo();
- if( stats.totals.assertions.total() > 0 ) {
- if( result.isOk() )
- stream << "\n";
- printResultType();
- printOriginalExpression();
- printReconstructedExpression();
- }
- else {
- stream << "\n";
- }
- printMessage();
- }
-
- private:
- void printResultType() const {
- if( !passOrFail.empty() ) {
- Colour colourGuard( colour );
- stream << passOrFail << ":\n";
- }
- }
- void printOriginalExpression() const {
- if( result.hasExpression() ) {
- Colour colourGuard( Colour::OriginalExpression );
- stream << " ";
- stream << result.getExpressionInMacro();
- stream << "\n";
- }
- }
- void printReconstructedExpression() const {
- if( result.hasExpandedExpression() ) {
- stream << "with expansion:\n";
- Colour colourGuard( Colour::ReconstructedExpression );
- stream << Text( result.getExpandedExpression(), TextAttributes().setIndent(2) ) << "\n";
- }
- }
- void printMessage() const {
- if( !messageLabel.empty() )
- stream << messageLabel << ":" << "\n";
- for( std::vector<MessageInfo>::const_iterator it = messages.begin(), itEnd = messages.end();
- it != itEnd;
- ++it ) {
- // If this assertion is a warning ignore any INFO messages
- if( printInfoMessages || it->type != ResultWas::Info )
- stream << Text( it->message, TextAttributes().setIndent(2) ) << "\n";
- }
- }
- void printSourceInfo() const {
- Colour colourGuard( Colour::FileName );
- stream << result.getSourceInfo() << ": ";
- }
-
- std::ostream& stream;
- AssertionStats const& stats;
- AssertionResult const& result;
- Colour::Code colour;
- std::string passOrFail;
- std::string messageLabel;
- std::string message;
- std::vector<MessageInfo> messages;
- bool printInfoMessages;
- };
-
- void lazyPrint() {
-
- if( !currentTestRunInfo.used )
- lazyPrintRunInfo();
- if( !currentGroupInfo.used )
- lazyPrintGroupInfo();
-
- if( !m_headerPrinted ) {
- printTestCaseAndSectionHeader();
- m_headerPrinted = true;
- }
- }
- void lazyPrintRunInfo() {
- stream << "\n" << getLineOfChars<'~'>() << "\n";
- Colour colour( Colour::SecondaryText );
- stream << currentTestRunInfo->name
- << " is a Catch v" << libraryVersion << " host application.\n"
- << "Run with -? for options\n\n";
-
- if( m_config->rngSeed() != 0 )
- stream << "Randomness seeded to: " << m_config->rngSeed() << "\n\n";
-
- currentTestRunInfo.used = true;
- }
- void lazyPrintGroupInfo() {
- if( !currentGroupInfo->name.empty() && currentGroupInfo->groupsCounts > 1 ) {
- printClosedHeader( "Group: " + currentGroupInfo->name );
- currentGroupInfo.used = true;
- }
- }
- void printTestCaseAndSectionHeader() {
- assert( !m_sectionStack.empty() );
- printOpenHeader( currentTestCaseInfo->name );
-
- if( m_sectionStack.size() > 1 ) {
- Colour colourGuard( Colour::Headers );
-
- std::vector<SectionInfo>::const_iterator
- it = m_sectionStack.begin()+1, // Skip first section (test case)
- itEnd = m_sectionStack.end();
- for( ; it != itEnd; ++it )
- printHeaderString( it->name, 2 );
- }
-
- SourceLineInfo lineInfo = m_sectionStack.front().lineInfo;
-
- if( !lineInfo.empty() ){
- stream << getLineOfChars<'-'>() << "\n";
- Colour colourGuard( Colour::FileName );
- stream << lineInfo << "\n";
- }
- stream << getLineOfChars<'.'>() << "\n" << std::endl;
- }
-
- void printClosedHeader( std::string const& _name ) {
- printOpenHeader( _name );
- stream << getLineOfChars<'.'>() << "\n";
- }
- void printOpenHeader( std::string const& _name ) {
- stream << getLineOfChars<'-'>() << "\n";
- {
- Colour colourGuard( Colour::Headers );
- printHeaderString( _name );
- }
- }
-
- // if string has a : in first line will set indent to follow it on
- // subsequent lines
- void printHeaderString( std::string const& _string, std::size_t indent = 0 ) {
- std::size_t i = _string.find( ": " );
- if( i != std::string::npos )
- i+=2;
- else
- i = 0;
- stream << Text( _string, TextAttributes()
- .setIndent( indent+i)
- .setInitialIndent( indent ) ) << "\n";
- }
-
- struct SummaryColumn {
-
- SummaryColumn( std::string const& _label, Colour::Code _colour )
- : label( _label ),
- colour( _colour )
- {}
- SummaryColumn addRow( std::size_t count ) {
- std::ostringstream oss;
- oss << count;
- std::string row = oss.str();
- for( std::vector<std::string>::iterator it = rows.begin(); it != rows.end(); ++it ) {
- while( it->size() < row.size() )
- *it = " " + *it;
- while( it->size() > row.size() )
- row = " " + row;
- }
- rows.push_back( row );
- return *this;
- }
-
- std::string label;
- Colour::Code colour;
- std::vector<std::string> rows;
-
- };
-
- void printTotals( Totals const& totals ) {
- if( totals.testCases.total() == 0 ) {
- stream << Colour( Colour::Warning ) << "No tests ran\n";
- }
- else if( totals.assertions.total() > 0 && totals.testCases.allPassed() ) {
- stream << Colour( Colour::ResultSuccess ) << "All tests passed";
- stream << " ("
- << pluralise( totals.assertions.passed, "assertion" ) << " in "
- << pluralise( totals.testCases.passed, "test case" ) << ")"
- << "\n";
- }
- else {
-
- std::vector<SummaryColumn> columns;
- columns.push_back( SummaryColumn( "", Colour::None )
- .addRow( totals.testCases.total() )
- .addRow( totals.assertions.total() ) );
- columns.push_back( SummaryColumn( "passed", Colour::Success )
- .addRow( totals.testCases.passed )
- .addRow( totals.assertions.passed ) );
- columns.push_back( SummaryColumn( "failed", Colour::ResultError )
- .addRow( totals.testCases.failed )
- .addRow( totals.assertions.failed ) );
- columns.push_back( SummaryColumn( "failed as expected", Colour::ResultExpectedFailure )
- .addRow( totals.testCases.failedButOk )
- .addRow( totals.assertions.failedButOk ) );
-
- printSummaryRow( "test cases", columns, 0 );
- printSummaryRow( "assertions", columns, 1 );
- }
- }
- void printSummaryRow( std::string const& label, std::vector<SummaryColumn> const& cols, std::size_t row ) {
- for( std::vector<SummaryColumn>::const_iterator it = cols.begin(); it != cols.end(); ++it ) {
- std::string value = it->rows[row];
- if( it->label.empty() ) {
- stream << label << ": ";
- if( value != "0" )
- stream << value;
- else
- stream << Colour( Colour::Warning ) << "- none -";
- }
- else if( value != "0" ) {
- stream << Colour( Colour::LightGrey ) << " | ";
- stream << Colour( it->colour )
- << value << " " << it->label;
- }
- }
- stream << "\n";
- }
-
- static std::size_t makeRatio( std::size_t number, std::size_t total ) {
- std::size_t ratio = total > 0 ? CATCH_CONFIG_CONSOLE_WIDTH * number/ total : 0;
- return ( ratio == 0 && number > 0 ) ? 1 : ratio;
- }
- static std::size_t& findMax( std::size_t& i, std::size_t& j, std::size_t& k ) {
- if( i > j && i > k )
- return i;
- else if( j > k )
- return j;
- else
- return k;
- }
-
- void printTotalsDivider( Totals const& totals ) {
- if( totals.testCases.total() > 0 ) {
- std::size_t failedRatio = makeRatio( totals.testCases.failed, totals.testCases.total() );
- std::size_t failedButOkRatio = makeRatio( totals.testCases.failedButOk, totals.testCases.total() );
- std::size_t passedRatio = makeRatio( totals.testCases.passed, totals.testCases.total() );
- while( failedRatio + failedButOkRatio + passedRatio < CATCH_CONFIG_CONSOLE_WIDTH-1 )
- findMax( failedRatio, failedButOkRatio, passedRatio )++;
- while( failedRatio + failedButOkRatio + passedRatio > CATCH_CONFIG_CONSOLE_WIDTH-1 )
- findMax( failedRatio, failedButOkRatio, passedRatio )--;
-
- stream << Colour( Colour::Error ) << std::string( failedRatio, '=' );
- stream << Colour( Colour::ResultExpectedFailure ) << std::string( failedButOkRatio, '=' );
- if( totals.testCases.allPassed() )
- stream << Colour( Colour::ResultSuccess ) << std::string( passedRatio, '=' );
- else
- stream << Colour( Colour::Success ) << std::string( passedRatio, '=' );
- }
- else {
- stream << Colour( Colour::Warning ) << std::string( CATCH_CONFIG_CONSOLE_WIDTH-1, '=' );
- }
- stream << "\n";
- }
- void printSummaryDivider() {
- stream << getLineOfChars<'-'>() << "\n";
- }
-
- private:
- bool m_headerPrinted;
- };
-
- INTERNAL_CATCH_REGISTER_REPORTER( "console", ConsoleReporter )
-
-} // end namespace Catch
-
-// #included from: ../reporters/catch_reporter_compact.hpp
-#define TWOBLUECUBES_CATCH_REPORTER_COMPACT_HPP_INCLUDED
-
-namespace Catch {
-
- struct CompactReporter : StreamingReporterBase {
-
- CompactReporter( ReporterConfig const& _config )
- : StreamingReporterBase( _config )
- {}
-
- virtual ~CompactReporter();
-
- static std::string getDescription() {
- return "Reports test results on a single line, suitable for IDEs";
- }
-
- virtual ReporterPreferences getPreferences() const {
- ReporterPreferences prefs;
- prefs.shouldRedirectStdOut = false;
- return prefs;
- }
-
- virtual void noMatchingTestCases( std::string const& spec ) {
- stream << "No test cases matched '" << spec << "'" << std::endl;
- }
-
- virtual void assertionStarting( AssertionInfo const& ) {
- }
-
- virtual bool assertionEnded( AssertionStats const& _assertionStats ) {
- AssertionResult const& result = _assertionStats.assertionResult;
-
- bool printInfoMessages = true;
-
- // Drop out if result was successful and we're not printing those
- if( !m_config->includeSuccessfulResults() && result.isOk() ) {
- if( result.getResultType() != ResultWas::Warning )
- return false;
- printInfoMessages = false;
- }
-
- AssertionPrinter printer( stream, _assertionStats, printInfoMessages );
- printer.print();
-
- stream << std::endl;
- return true;
- }
-
- virtual void testRunEnded( TestRunStats const& _testRunStats ) {
- printTotals( _testRunStats.totals );
- stream << "\n" << std::endl;
- StreamingReporterBase::testRunEnded( _testRunStats );
- }
-
- private:
- class AssertionPrinter {
- void operator= ( AssertionPrinter const& );
- public:
- AssertionPrinter( std::ostream& _stream, AssertionStats const& _stats, bool _printInfoMessages )
- : stream( _stream )
- , stats( _stats )
- , result( _stats.assertionResult )
- , messages( _stats.infoMessages )
- , itMessage( _stats.infoMessages.begin() )
- , printInfoMessages( _printInfoMessages )
- {}
-
- void print() {
- printSourceInfo();
-
- itMessage = messages.begin();
-
- switch( result.getResultType() ) {
- case ResultWas::Ok:
- printResultType( Colour::ResultSuccess, passedString() );
- printOriginalExpression();
- printReconstructedExpression();
- if ( ! result.hasExpression() )
- printRemainingMessages( Colour::None );
- else
- printRemainingMessages();
- break;
- case ResultWas::ExpressionFailed:
- if( result.isOk() )
- printResultType( Colour::ResultSuccess, failedString() + std::string( " - but was ok" ) );
- else
- printResultType( Colour::Error, failedString() );
- printOriginalExpression();
- printReconstructedExpression();
- printRemainingMessages();
- break;
- case ResultWas::ThrewException:
- printResultType( Colour::Error, failedString() );
- printIssue( "unexpected exception with message:" );
- printMessage();
- printExpressionWas();
- printRemainingMessages();
- break;
- case ResultWas::FatalErrorCondition:
- printResultType( Colour::Error, failedString() );
- printIssue( "fatal error condition with message:" );
- printMessage();
- printExpressionWas();
- printRemainingMessages();
- break;
- case ResultWas::DidntThrowException:
- printResultType( Colour::Error, failedString() );
- printIssue( "expected exception, got none" );
- printExpressionWas();
- printRemainingMessages();
- break;
- case ResultWas::Info:
- printResultType( Colour::None, "info" );
- printMessage();
- printRemainingMessages();
- break;
- case ResultWas::Warning:
- printResultType( Colour::None, "warning" );
- printMessage();
- printRemainingMessages();
- break;
- case ResultWas::ExplicitFailure:
- printResultType( Colour::Error, failedString() );
- printIssue( "explicitly" );
- printRemainingMessages( Colour::None );
- break;
- // These cases are here to prevent compiler warnings
- case ResultWas::Unknown:
- case ResultWas::FailureBit:
- case ResultWas::Exception:
- printResultType( Colour::Error, "** internal error **" );
- break;
- }
- }
-
- private:
- // Colour::LightGrey
-
- static Colour::Code dimColour() { return Colour::FileName; }
-
-#ifdef CATCH_PLATFORM_MAC
- static const char* failedString() { return "FAILED"; }
- static const char* passedString() { return "PASSED"; }
-#else
- static const char* failedString() { return "failed"; }
- static const char* passedString() { return "passed"; }
-#endif
-
- void printSourceInfo() const {
- Colour colourGuard( Colour::FileName );
- stream << result.getSourceInfo() << ":";
- }
-
- void printResultType( Colour::Code colour, std::string passOrFail ) const {
- if( !passOrFail.empty() ) {
- {
- Colour colourGuard( colour );
- stream << " " << passOrFail;
- }
- stream << ":";
- }
- }
-
- void printIssue( std::string issue ) const {
- stream << " " << issue;
- }
-
- void printExpressionWas() {
- if( result.hasExpression() ) {
- stream << ";";
- {
- Colour colour( dimColour() );
- stream << " expression was:";
- }
- printOriginalExpression();
- }
- }
-
- void printOriginalExpression() const {
- if( result.hasExpression() ) {
- stream << " " << result.getExpression();
- }
- }
-
- void printReconstructedExpression() const {
- if( result.hasExpandedExpression() ) {
- {
- Colour colour( dimColour() );
- stream << " for: ";
- }
- stream << result.getExpandedExpression();
- }
- }
-
- void printMessage() {
- if ( itMessage != messages.end() ) {
- stream << " '" << itMessage->message << "'";
- ++itMessage;
- }
- }
-
- void printRemainingMessages( Colour::Code colour = dimColour() ) {
- if ( itMessage == messages.end() )
- return;
-
- // using messages.end() directly yields compilation error:
- std::vector<MessageInfo>::const_iterator itEnd = messages.end();
- const std::size_t N = static_cast<std::size_t>( std::distance( itMessage, itEnd ) );
-
- {
- Colour colourGuard( colour );
- stream << " with " << pluralise( N, "message" ) << ":";
- }
-
- for(; itMessage != itEnd; ) {
- // If this assertion is a warning ignore any INFO messages
- if( printInfoMessages || itMessage->type != ResultWas::Info ) {
- stream << " '" << itMessage->message << "'";
- if ( ++itMessage != itEnd ) {
- Colour colourGuard( dimColour() );
- stream << " and";
- }
- }
- }
- }
-
- private:
- std::ostream& stream;
- AssertionStats const& stats;
- AssertionResult const& result;
- std::vector<MessageInfo> messages;
- std::vector<MessageInfo>::const_iterator itMessage;
- bool printInfoMessages;
- };
-
- // Colour, message variants:
- // - white: No tests ran.
- // - red: Failed [both/all] N test cases, failed [both/all] M assertions.
- // - white: Passed [both/all] N test cases (no assertions).
- // - red: Failed N tests cases, failed M assertions.
- // - green: Passed [both/all] N tests cases with M assertions.
-
- std::string bothOrAll( std::size_t count ) const {
- return count == 1 ? "" : count == 2 ? "both " : "all " ;
- }
-
- void printTotals( const Totals& totals ) const {
- if( totals.testCases.total() == 0 ) {
- stream << "No tests ran.";
- }
- else if( totals.testCases.failed == totals.testCases.total() ) {
- Colour colour( Colour::ResultError );
- const std::string qualify_assertions_failed =
- totals.assertions.failed == totals.assertions.total() ?
- bothOrAll( totals.assertions.failed ) : "";
- stream <<
- "Failed " << bothOrAll( totals.testCases.failed )
- << pluralise( totals.testCases.failed, "test case" ) << ", "
- "failed " << qualify_assertions_failed <<
- pluralise( totals.assertions.failed, "assertion" ) << ".";
- }
- else if( totals.assertions.total() == 0 ) {
- stream <<
- "Passed " << bothOrAll( totals.testCases.total() )
- << pluralise( totals.testCases.total(), "test case" )
- << " (no assertions).";
- }
- else if( totals.assertions.failed ) {
- Colour colour( Colour::ResultError );
- stream <<
- "Failed " << pluralise( totals.testCases.failed, "test case" ) << ", "
- "failed " << pluralise( totals.assertions.failed, "assertion" ) << ".";
- }
- else {
- Colour colour( Colour::ResultSuccess );
- stream <<
- "Passed " << bothOrAll( totals.testCases.passed )
- << pluralise( totals.testCases.passed, "test case" ) <<
- " with " << pluralise( totals.assertions.passed, "assertion" ) << ".";
- }
- }
- };
-
- INTERNAL_CATCH_REGISTER_REPORTER( "compact", CompactReporter )
-
-} // end namespace Catch
-
-namespace Catch {
- // These are all here to avoid warnings about not having any out of line
- // virtual methods
- NonCopyable::~NonCopyable() {}
- IShared::~IShared() {}
- IStream::~IStream() CATCH_NOEXCEPT {}
- FileStream::~FileStream() CATCH_NOEXCEPT {}
- CoutStream::~CoutStream() CATCH_NOEXCEPT {}
- DebugOutStream::~DebugOutStream() CATCH_NOEXCEPT {}
- StreamBufBase::~StreamBufBase() CATCH_NOEXCEPT {}
- IContext::~IContext() {}
- IResultCapture::~IResultCapture() {}
- ITestCase::~ITestCase() {}
- ITestCaseRegistry::~ITestCaseRegistry() {}
- IRegistryHub::~IRegistryHub() {}
- IMutableRegistryHub::~IMutableRegistryHub() {}
- IExceptionTranslator::~IExceptionTranslator() {}
- IExceptionTranslatorRegistry::~IExceptionTranslatorRegistry() {}
- IReporter::~IReporter() {}
- IReporterFactory::~IReporterFactory() {}
- IReporterRegistry::~IReporterRegistry() {}
- IStreamingReporter::~IStreamingReporter() {}
- AssertionStats::~AssertionStats() {}
- SectionStats::~SectionStats() {}
- TestCaseStats::~TestCaseStats() {}
- TestGroupStats::~TestGroupStats() {}
- TestRunStats::~TestRunStats() {}
- CumulativeReporterBase::SectionNode::~SectionNode() {}
- CumulativeReporterBase::~CumulativeReporterBase() {}
-
- StreamingReporterBase::~StreamingReporterBase() {}
- ConsoleReporter::~ConsoleReporter() {}
- CompactReporter::~CompactReporter() {}
- IRunner::~IRunner() {}
- IMutableContext::~IMutableContext() {}
- IConfig::~IConfig() {}
- XmlReporter::~XmlReporter() {}
- JunitReporter::~JunitReporter() {}
- TestRegistry::~TestRegistry() {}
- FreeFunctionTestCase::~FreeFunctionTestCase() {}
- IGeneratorInfo::~IGeneratorInfo() {}
- IGeneratorsForTest::~IGeneratorsForTest() {}
- WildcardPattern::~WildcardPattern() {}
- TestSpec::Pattern::~Pattern() {}
- TestSpec::NamePattern::~NamePattern() {}
- TestSpec::TagPattern::~TagPattern() {}
- TestSpec::ExcludedPattern::~ExcludedPattern() {}
-
- Matchers::Impl::StdString::Equals::~Equals() {}
- Matchers::Impl::StdString::Contains::~Contains() {}
- Matchers::Impl::StdString::StartsWith::~StartsWith() {}
- Matchers::Impl::StdString::EndsWith::~EndsWith() {}
-
- void Config::dummy() {}
-
- namespace TestCaseTracking {
- ITracker::~ITracker() {}
- TrackerBase::~TrackerBase() {}
- SectionTracker::~SectionTracker() {}
- IndexTracker::~IndexTracker() {}
- }
-}
-
-#ifdef __clang__
-#pragma clang diagnostic pop
-#endif
-
-#endif
-
-#ifdef CATCH_CONFIG_MAIN
-// #included from: internal/catch_default_main.hpp
-#define TWOBLUECUBES_CATCH_DEFAULT_MAIN_HPP_INCLUDED
-
-#ifndef __OBJC__
-
-// Standard C/C++ main entry point
-int main (int argc, char * argv[]) {
- return Catch::Session().run( argc, argv );
-}
-
-#else // __OBJC__
-
-// Objective-C entry point
-int main (int argc, char * const argv[]) {
-#if !CATCH_ARC_ENABLED
- NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
-#endif
-
- Catch::registerTestMethods();
- int result = Catch::Session().run( argc, (char* const*)argv );
-
-#if !CATCH_ARC_ENABLED
- [pool drain];
-#endif
-
- return result;
-}
-
-#endif // __OBJC__
-
-#endif
-
-#ifdef CLARA_CONFIG_MAIN_NOT_DEFINED
-# undef CLARA_CONFIG_MAIN
-#endif
-
-//////
-
-// If this config identifier is defined then all CATCH macros are prefixed with CATCH_
-#ifdef CATCH_CONFIG_PREFIX_ALL
-
-#define CATCH_REQUIRE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal, "CATCH_REQUIRE" )
-#define CATCH_REQUIRE_FALSE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, "CATCH_REQUIRE_FALSE" )
-
-#define CATCH_REQUIRE_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::Normal, "", "CATCH_REQUIRE_THROWS" )
-#define CATCH_REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, Catch::ResultDisposition::Normal, "CATCH_REQUIRE_THROWS_AS" )
-#define CATCH_REQUIRE_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::Normal, matcher, "CATCH_REQUIRE_THROWS_WITH" )
-#define CATCH_REQUIRE_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, Catch::ResultDisposition::Normal, "CATCH_REQUIRE_NOTHROW" )
-
-#define CATCH_CHECK( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK" )
-#define CATCH_CHECK_FALSE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::FalseTest, "CATCH_CHECK_FALSE" )
-#define CATCH_CHECKED_IF( expr ) INTERNAL_CATCH_IF( expr, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECKED_IF" )
-#define CATCH_CHECKED_ELSE( expr ) INTERNAL_CATCH_ELSE( expr, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECKED_ELSE" )
-#define CATCH_CHECK_NOFAIL( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, "CATCH_CHECK_NOFAIL" )
-
-#define CATCH_CHECK_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK_THROWS" )
-#define CATCH_CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK_THROWS_AS" )
-#define CATCH_CHECK_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::ContinueOnFailure, matcher, "CATCH_CHECK_THROWS_WITH" )
-#define CATCH_CHECK_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK_NOTHROW" )
-
-#define CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK_THAT" )
-#define CATCH_REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, Catch::ResultDisposition::Normal, "CATCH_REQUIRE_THAT" )
-
-#define CATCH_INFO( msg ) INTERNAL_CATCH_INFO( msg, "CATCH_INFO" )
-#define CATCH_WARN( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::Warning, Catch::ResultDisposition::ContinueOnFailure, "CATCH_WARN", msg )
-#define CATCH_SCOPED_INFO( msg ) INTERNAL_CATCH_INFO( msg, "CATCH_INFO" )
-#define CATCH_CAPTURE( msg ) INTERNAL_CATCH_INFO( #msg " := " << msg, "CATCH_CAPTURE" )
-#define CATCH_SCOPED_CAPTURE( msg ) INTERNAL_CATCH_INFO( #msg " := " << msg, "CATCH_CAPTURE" )
-
-#ifdef CATCH_CONFIG_VARIADIC_MACROS
- #define CATCH_TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ )
- #define CATCH_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, __VA_ARGS__ )
- #define CATCH_METHOD_AS_TEST_CASE( method, ... ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, __VA_ARGS__ )
- #define CATCH_REGISTER_TEST_CASE( Function, ... ) INTERNAL_CATCH_REGISTER_TESTCASE( Function, __VA_ARGS__ )
- #define CATCH_SECTION( ... ) INTERNAL_CATCH_SECTION( __VA_ARGS__ )
- #define CATCH_FAIL( ... ) INTERNAL_CATCH_MSG( Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, "CATCH_FAIL", __VA_ARGS__ )
- #define CATCH_SUCCEED( ... ) INTERNAL_CATCH_MSG( Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, "CATCH_SUCCEED", __VA_ARGS__ )
-#else
- #define CATCH_TEST_CASE( name, description ) INTERNAL_CATCH_TESTCASE( name, description )
- #define CATCH_TEST_CASE_METHOD( className, name, description ) INTERNAL_CATCH_TEST_CASE_METHOD( className, name, description )
- #define CATCH_METHOD_AS_TEST_CASE( method, name, description ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, name, description )
- #define CATCH_REGISTER_TEST_CASE( function, name, description ) INTERNAL_CATCH_REGISTER_TESTCASE( function, name, description )
- #define CATCH_SECTION( name, description ) INTERNAL_CATCH_SECTION( name, description )
- #define CATCH_FAIL( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, "CATCH_FAIL", msg )
- #define CATCH_SUCCEED( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, "CATCH_SUCCEED", msg )
-#endif
-#define CATCH_ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE( "", "" )
-
-#define CATCH_REGISTER_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType )
-#define CATCH_REGISTER_LEGACY_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_LEGACY_REPORTER( name, reporterType )
-
-#define CATCH_GENERATE( expr) INTERNAL_CATCH_GENERATE( expr )
-
-// "BDD-style" convenience wrappers
-#ifdef CATCH_CONFIG_VARIADIC_MACROS
-#define CATCH_SCENARIO( ... ) CATCH_TEST_CASE( "Scenario: " __VA_ARGS__ )
-#define CATCH_SCENARIO_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " __VA_ARGS__ )
-#else
-#define CATCH_SCENARIO( name, tags ) CATCH_TEST_CASE( "Scenario: " name, tags )
-#define CATCH_SCENARIO_METHOD( className, name, tags ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " name, tags )
-#endif
-#define CATCH_GIVEN( desc ) CATCH_SECTION( std::string( "Given: ") + desc, "" )
-#define CATCH_WHEN( desc ) CATCH_SECTION( std::string( " When: ") + desc, "" )
-#define CATCH_AND_WHEN( desc ) CATCH_SECTION( std::string( " And: ") + desc, "" )
-#define CATCH_THEN( desc ) CATCH_SECTION( std::string( " Then: ") + desc, "" )
-#define CATCH_AND_THEN( desc ) CATCH_SECTION( std::string( " And: ") + desc, "" )
-
-// If CATCH_CONFIG_PREFIX_ALL is not defined then the CATCH_ prefix is not required
-#else
-
-#define REQUIRE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal, "REQUIRE" )
-#define REQUIRE_FALSE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, "REQUIRE_FALSE" )
-
-#define REQUIRE_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::Normal, "", "REQUIRE_THROWS" )
-#define REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, Catch::ResultDisposition::Normal, "REQUIRE_THROWS_AS" )
-#define REQUIRE_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::Normal, matcher, "REQUIRE_THROWS_WITH" )
-#define REQUIRE_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, Catch::ResultDisposition::Normal, "REQUIRE_NOTHROW" )
-
-#define CHECK( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECK" )
-#define CHECK_FALSE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::FalseTest, "CHECK_FALSE" )
-#define CHECKED_IF( expr ) INTERNAL_CATCH_IF( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECKED_IF" )
-#define CHECKED_ELSE( expr ) INTERNAL_CATCH_ELSE( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECKED_ELSE" )
-#define CHECK_NOFAIL( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, "CHECK_NOFAIL" )
-
-#define CHECK_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::ContinueOnFailure, "", "CHECK_THROWS" )
-#define CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, Catch::ResultDisposition::ContinueOnFailure, "CHECK_THROWS_AS" )
-#define CHECK_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::ContinueOnFailure, matcher, "CHECK_THROWS_WITH" )
-#define CHECK_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECK_NOTHROW" )
-
-#define CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, Catch::ResultDisposition::ContinueOnFailure, "CHECK_THAT" )
-#define REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, Catch::ResultDisposition::Normal, "REQUIRE_THAT" )
-
-#define INFO( msg ) INTERNAL_CATCH_INFO( msg, "INFO" )
-#define WARN( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::Warning, Catch::ResultDisposition::ContinueOnFailure, "WARN", msg )
-#define SCOPED_INFO( msg ) INTERNAL_CATCH_INFO( msg, "INFO" )
-#define CAPTURE( msg ) INTERNAL_CATCH_INFO( #msg " := " << msg, "CAPTURE" )
-#define SCOPED_CAPTURE( msg ) INTERNAL_CATCH_INFO( #msg " := " << msg, "CAPTURE" )
-
-#ifdef CATCH_CONFIG_VARIADIC_MACROS
- #define TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ )
- #define TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, __VA_ARGS__ )
- #define METHOD_AS_TEST_CASE( method, ... ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, __VA_ARGS__ )
- #define REGISTER_TEST_CASE( Function, ... ) INTERNAL_CATCH_REGISTER_TESTCASE( Function, __VA_ARGS__ )
- #define SECTION( ... ) INTERNAL_CATCH_SECTION( __VA_ARGS__ )
- #define FAIL( ... ) INTERNAL_CATCH_MSG( Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, "FAIL", __VA_ARGS__ )
- #define SUCCEED( ... ) INTERNAL_CATCH_MSG( Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, "SUCCEED", __VA_ARGS__ )
-#else
- #define TEST_CASE( name, description ) INTERNAL_CATCH_TESTCASE( name, description )
- #define TEST_CASE_METHOD( className, name, description ) INTERNAL_CATCH_TEST_CASE_METHOD( className, name, description )
- #define METHOD_AS_TEST_CASE( method, name, description ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, name, description )
- #define REGISTER_TEST_CASE( method, name, description ) INTERNAL_CATCH_REGISTER_TESTCASE( method, name, description )
- #define SECTION( name, description ) INTERNAL_CATCH_SECTION( name, description )
- #define FAIL( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, "FAIL", msg )
- #define SUCCEED( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, "SUCCEED", msg )
-#endif
-#define ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE( "", "" )
-
-#define REGISTER_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType )
-#define REGISTER_LEGACY_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_LEGACY_REPORTER( name, reporterType )
-
-#define GENERATE( expr) INTERNAL_CATCH_GENERATE( expr )
-
-#endif
-
-#define CATCH_TRANSLATE_EXCEPTION( signature ) INTERNAL_CATCH_TRANSLATE_EXCEPTION( signature )
-
-// "BDD-style" convenience wrappers
-#ifdef CATCH_CONFIG_VARIADIC_MACROS
-#define SCENARIO( ... ) TEST_CASE( "Scenario: " __VA_ARGS__ )
-#define SCENARIO_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " __VA_ARGS__ )
-#else
-#define SCENARIO( name, tags ) TEST_CASE( "Scenario: " name, tags )
-#define SCENARIO_METHOD( className, name, tags ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " name, tags )
-#endif
-#define GIVEN( desc ) SECTION( std::string(" Given: ") + desc, "" )
-#define WHEN( desc ) SECTION( std::string(" When: ") + desc, "" )
-#define AND_WHEN( desc ) SECTION( std::string("And when: ") + desc, "" )
-#define THEN( desc ) SECTION( std::string(" Then: ") + desc, "" )
-#define AND_THEN( desc ) SECTION( std::string(" And: ") + desc, "" )
-
-using Catch::Detail::Approx;
-
-#endif // TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED
-
diff --git a/src/unittests/configuration.cc b/src/unittests/configuration.cc
deleted file mode 100644
index 03561ed42..000000000
--- a/src/unittests/configuration.cc
+++ /dev/null
@@ -1,293 +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 "unittests/unittests.h"
-
-#include "configuration.h"
-#include "configmanager.h"
-#include "dirs.h"
-
-#include "listeners/configlistener.h"
-
-#include "debug.h"
-
-namespace
-{
- int mCalled = 0;
-
- class TestConfigListener : public ConfigListener
- {
- public:
- void optionChanged(const std::string &name) override final
- {
- if (name == "testkey123")
- mCalled ++;
- }
- } testListener;
-} // namespace
-
-TEST_CASE("configuration tests", "configuration")
-{
- Dirs::initRootDir();
- Dirs::initHomeDir();
-
- ConfigManager::initConfiguration();
-
- SECTION("configuration undefined")
- {
- const char *const key = "nonsetvalue";
- REQUIRE(config.getValue(key, "not set") == "not set");
- REQUIRE(config.getValue(key, 12345) == 12345);
- REQUIRE(config.getValue(key, 12345U) == 12345U);
- REQUIRE(config.getValueInt(key, 12345) == 12345);
- REQUIRE(config.getValueBool(key, false) == false);
- REQUIRE(config.getValueBool(key, true) == true);
- REQUIRE(config.getValue(key, -12345) == -12345);
- REQUIRE(config.getValue(key, 12.345) > 12.3);
- }
-
- SECTION("configuration getint default")
- {
- const char *const key = "sfxVolume";
- REQUIRE(config.getIntValue(key) == 100);
- REQUIRE(config.getFloatValue(key) >= 100.0f);
- REQUIRE(config.getStringValue(key) == "100");
- REQUIRE(config.getBoolValue(key) == true);
- }
-
- SECTION("configuration getfloat default")
- {
- const char *const key = "guialpha";
- REQUIRE(config.getIntValue(key) == 0);
- REQUIRE(config.getFloatValue(key) >= 0.8f);
- REQUIRE(config.getStringValue(key).substr(0, 3) == "0.8");
- REQUIRE(config.getBoolValue(key) == false);
- }
-
- SECTION("configuration getstring default")
- {
- const char *const key = "soundwhisper";
- REQUIRE(config.getIntValue(key) == 0);
- REQUIRE(config.getFloatValue(key) >= 0.0f);
- REQUIRE(config.getStringValue(key) == "newmessage");
- REQUIRE(config.getBoolValue(key) == true);
- }
-
- SECTION("configuration getbool default1")
- {
- const char *const key = "showgender";
- REQUIRE(config.getIntValue(key) == 1);
- REQUIRE(config.getFloatValue(key) >= 1.0f);
- REQUIRE(config.getStringValue(key) == "1");
- REQUIRE(config.getBoolValue(key) == true);
- }
-
- SECTION("configuration getbool default2")
- {
- const char *const key = "showlevel";
- REQUIRE(config.getIntValue(key) == 0);
- REQUIRE(config.getFloatValue(key) >= 0.0f);
- REQUIRE(config.getStringValue(key) == "0");
- REQUIRE(config.getBoolValue(key) == false);
- }
-
- SECTION("configuration getint set")
- {
- const char *const key = "sfxVolume";
- config.setValue(key, 50);
- REQUIRE(config.getIntValue(key) == 50);
- REQUIRE(config.getFloatValue(key) >= 50.0f);
- REQUIRE(config.getStringValue(key) == "50");
- REQUIRE(config.getBoolValue(key) == true);
-
- REQUIRE(config.getValue(key, "not set") == "50");
- REQUIRE(config.getValue(key, 12345) == 50);
- REQUIRE(config.getValue(key, 12345U) == 50U);
- REQUIRE(config.getValueInt(key, 12345) == 50);
- REQUIRE(config.getValueBool(key, false) == true);
- REQUIRE(config.getValueBool(key, true) == true);
- REQUIRE(config.getValue(key, -12345) == 50);
- REQUIRE(config.getValue(key, 12.345) >= 50.0);
- }
-
- SECTION("configuration getfloat set")
- {
- const char *const key = "guialpha";
- config.setValue(key, 50.5);
- REQUIRE(config.getIntValue(key) == 50);
- REQUIRE(config.getFloatValue(key) >= 50.4f);
- REQUIRE(config.getStringValue(key).substr(0, 2) == "50");
- REQUIRE(config.getBoolValue(key) == true);
-
- REQUIRE(config.getValue(key, "not set").substr(0, 2) == "50");
- REQUIRE(config.getValue(key, 12345) == 50);
- REQUIRE(config.getValue(key, 12345U) == 50U);
- REQUIRE(config.getValueInt(key, 12345) == 50);
- REQUIRE(config.getValueBool(key, false) == true);
- REQUIRE(config.getValueBool(key, true) == true);
- REQUIRE(config.getValue(key, -12345) == 50);
- REQUIRE(config.getValue(key, 12.345) >= 50.4);
- }
-
- SECTION("configuration getstring set")
- {
- const char *const key = "soundwhisper";
- config.setValue(key, "test line");
- REQUIRE(config.getIntValue(key) == 0);
- REQUIRE(config.getFloatValue(key) >= 0.0f);
- REQUIRE(config.getStringValue(key) == "test line");
- REQUIRE(config.getBoolValue(key) == false);
-
- REQUIRE(config.getValue(key, "not set") == "test line");
- REQUIRE(config.getValue(key, 12345) == 0);
- REQUIRE(config.getValue(key, 12345U) == 0U);
- REQUIRE(config.getValueInt(key, 12345) == 0);
- REQUIRE(config.getValueBool(key, false) == false);
- REQUIRE(config.getValueBool(key, true) == false);
- REQUIRE(config.getValue(key, -12345) == 0);
- REQUIRE(config.getValue(key, 12.345) >= 0.0);
- }
-
- SECTION("configuration getbool set1")
- {
- const char *const key = "showgender";
- config.setValue(key, true);
- REQUIRE(config.getIntValue(key) == 1);
- REQUIRE(config.getFloatValue(key) >= 1.0f);
- REQUIRE(config.getStringValue(key) == "1");
- REQUIRE(config.getBoolValue(key) == true);
-
- REQUIRE(config.getValue(key, "not set") == "1");
- REQUIRE(config.getValue(key, 12345) == 1);
- REQUIRE(config.getValue(key, 12345U) == 1U);
- REQUIRE(config.getValueInt(key, 12345) == 1);
- REQUIRE(config.getValueBool(key, false) == true);
- REQUIRE(config.getValueBool(key, true) == true);
- REQUIRE(config.getValue(key, -12345) == 1);
- REQUIRE(config.getValue(key, 12.345) >= 1.0);
- }
-
- SECTION("configuration getbool set2")
- {
- const char *const key = "showgender";
- config.setValue(key, false);
- REQUIRE(config.getIntValue(key) == 0);
- REQUIRE(config.getFloatValue(key) >= 0.0f);
- REQUIRE(config.getStringValue(key) == "0");
- REQUIRE(config.getBoolValue(key) == false);
-
- REQUIRE(config.getValue(key, "not set") == "0");
- REQUIRE(config.getValue(key, 12345) == 0);
- REQUIRE(config.getValue(key, 12345U) == 0U);
- REQUIRE(config.getValueInt(key, 12345) == 0);
- REQUIRE(config.getValueBool(key, false) == false);
- REQUIRE(config.getValueBool(key, true) == false);
- REQUIRE(config.getValue(key, -12345) == 0);
- REQUIRE(config.getValue(key, 12.345) >= 0.0);
- }
-
- SECTION("configuration deletekey")
- {
- const char *const key = "testkey123";
- config.setValue(key, 123);
- REQUIRE(config.getValueInt(key, 12345) == 123);
- config.deleteKey(key);
- REQUIRE(config.getValueInt(key, 12345) == 12345);
- }
-
- SECTION("configuration addlistener")
- {
- const char *const key = "testkey123";
- REQUIRE(mCalled == 0);
- config.addListener(key, &testListener);
- REQUIRE(mCalled == 0);
- config.setValue(key, 123);
- REQUIRE(mCalled == 1);
- REQUIRE(config.getValueInt(key, 12345) == 123);
- REQUIRE(mCalled == 1);
- config.setValue(key, 123);
- REQUIRE(mCalled == 2);
- config.setSilent(key, true);
- REQUIRE(mCalled == 2);
- REQUIRE(config.getBoolValue(key) == true);
- REQUIRE(mCalled == 2);
- config.setSilent(key, false);
- REQUIRE(mCalled == 2);
- REQUIRE(config.getBoolValue(key) == false);
- REQUIRE(mCalled == 2);
- config.removeListener(key, &testListener);
- }
-
- SECTION("configuration incvalue")
- {
- const char *const key = "testkey123";
- config.setValue(key, 10);
- REQUIRE(config.getValueInt(key, 12345) == 10);
- config.incValue(key);
- REQUIRE(config.getValueInt(key, 12345) == 11);
- }
-
- SECTION("configuration resetintvalue")
- {
- const char *const key = "sfxVolume";
- config.setValue(key, 20);
- REQUIRE(config.getIntValue(key) == 20);
- REQUIRE(config.getFloatValue(key) >= 20.0f);
- REQUIRE(config.getStringValue(key) == "20");
- REQUIRE(config.getBoolValue(key) == true);
- config.resetIntValue(key);
- REQUIRE(config.getIntValue(key) == 100);
- REQUIRE(config.getFloatValue(key) >= 100.0f);
- REQUIRE(config.getStringValue(key) == "100");
- REQUIRE(config.getBoolValue(key) == true);
- }
-
- SECTION("configuration resetboolvalue1")
- {
- const char *const key = "showgender";
- config.setValue(key, false);
- REQUIRE(config.getIntValue(key) == 0);
- REQUIRE(config.getFloatValue(key) >= 0.0f);
- REQUIRE(config.getStringValue(key) == "0");
- REQUIRE(config.getBoolValue(key) == false);
-
- config.resetBoolValue(key);
- REQUIRE(config.getIntValue(key) == 1);
- REQUIRE(config.getFloatValue(key) >= 1.0f);
- REQUIRE(config.getStringValue(key) == "1");
- REQUIRE(config.getBoolValue(key) == true);
- }
-
- SECTION("configuration resetboolvalue2")
- {
- const char *const key = "showlevel";
- config.setValue(key, true);
- REQUIRE(config.getIntValue(key) == 1);
- REQUIRE(config.getFloatValue(key) >= 1.0f);
- REQUIRE(config.getStringValue(key) == "1");
- REQUIRE(config.getBoolValue(key) == true);
-
- config.resetBoolValue(key);
- REQUIRE(config.getIntValue(key) == 0);
- REQUIRE(config.getFloatValue(key) >= 0.0f);
- REQUIRE(config.getStringValue(key) == "0");
- REQUIRE(config.getBoolValue(key) == false);
- }
-}
diff --git a/src/unittests/doctest.h b/src/unittests/doctest.h
deleted file mode 100644
index 10ecf5158..000000000
--- a/src/unittests/doctest.h
+++ /dev/null
@@ -1,5613 +0,0 @@
-// ======================================================================
-// == DO NOT MODIFY THIS FILE BY HAND - IT IS AUTO GENERATED BY CMAKE! ==
-// ======================================================================
-//
-// doctest.h - the lightest feature-rich C++ single-header testing framework for unit tests and TDD
-//
-// Copyright (c) 2016-2017 Viktor Kirilov
-//
-// Distributed under the MIT Software License
-// See accompanying file LICENSE.txt or copy at
-// https://opensource.org/licenses/MIT
-//
-// The documentation can be found at the library's page:
-// https://github.com/onqtam/doctest/blob/master/doc/markdown/readme.md
-//
-// =================================================================================================
-// =================================================================================================
-// =================================================================================================
-//
-// The library is heavily influenced by Catch - https://github.com/philsquared/Catch
-// which uses the Boost Software License - Version 1.0
-// see here - https://github.com/philsquared/Catch/blob/master/LICENSE_1_0.txt
-//
-// The concept of subcases (sections in Catch) and expression decomposition are from there.
-// Some parts of the code are taken directly:
-// - stringification - the detection of "ostream& operator<<(ostream&, const T&)" and StringMaker<>
-// - the Approx() helper class for floating point comparison
-// - colors in the console
-// - breaking into a debugger
-// - signal / SEH handling
-// - timer
-//
-// The expression decomposing templates are taken from lest - https://github.com/martinmoene/lest
-// which uses the Boost Software License - Version 1.0
-// see here - https://github.com/martinmoene/lest/blob/master/LICENSE_1_0.txt
-//
-// The type list and the foreach algorithm on it for C++98 are taken from Loki
-// - http://loki-lib.sourceforge.net/
-// - https://en.wikipedia.org/wiki/Loki_%28C%2B%2B%29
-// - https://github.com/snaewe/loki-lib
-// which uses the MIT Software License
-//
-// =================================================================================================
-// =================================================================================================
-// =================================================================================================
-
-// Suppress this globally (without push/pop) - there is no way to silence it in the
-// expression decomposition macros _Pragma() in macros doesn't work for the c++ front-end of g++
-// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55578
-// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69543
-// Also the warning is completely worthless nowadays - http://stackoverflow.com/questions/14016993
-#if defined(__GNUC__) && !defined(__clang__)
-#pragma GCC diagnostic ignored "-Waggregate-return"
-#endif
-
-#if defined(__clang__)
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wunknown-pragmas"
-#pragma clang diagnostic ignored "-Wnon-virtual-dtor"
-#pragma clang diagnostic ignored "-Wweak-vtables"
-#pragma clang diagnostic ignored "-Wpadded"
-#pragma clang diagnostic ignored "-Wdeprecated"
-#pragma clang diagnostic ignored "-Wmissing-prototypes"
-#pragma clang diagnostic ignored "-Wunused-local-typedef"
-#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant"
-#pragma clang diagnostic ignored "-Wc++11-long-long"
-#endif // __clang__
-
-#if defined(__GNUC__) && !defined(__clang__)
-#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 6)
-#pragma GCC diagnostic push
-#endif // > gcc 4.6
-#pragma GCC diagnostic ignored "-Wunknown-pragmas"
-#pragma GCC diagnostic ignored "-Weffc++"
-#pragma GCC diagnostic ignored "-Wstrict-overflow"
-#pragma GCC diagnostic ignored "-Wstrict-aliasing"
-#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
-#pragma GCC diagnostic ignored "-Wmissing-declarations"
-#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
-#pragma GCC diagnostic ignored "-Winline"
-#pragma GCC diagnostic ignored "-Wlong-long"
-#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 6)
-#pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
-#endif // > gcc 4.6
-#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 7)
-#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
-#endif // > gcc 4.7
-#if __GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ > 3)
-#pragma GCC diagnostic ignored "-Wuseless-cast"
-#endif // > gcc 5.3
-#endif // __GNUC__
-
-#ifdef _MSC_VER
-#pragma warning(push)
-#pragma warning(disable : 4996) // The compiler encountered a deprecated declaration
-#pragma warning(disable : 4706) // assignment within conditional expression
-#pragma warning(disable : 4512) // 'class' : assignment operator could not be generated
-#pragma warning(disable : 4127) // conditional expression is constant
-#endif // _MSC_VER
-
-#ifndef DOCTEST_LIBRARY_INCLUDED
-#define DOCTEST_LIBRARY_INCLUDED
-
-#define DOCTEST_VERSION_MAJOR 1
-#define DOCTEST_VERSION_MINOR 2
-#define DOCTEST_VERSION_PATCH 1
-#define DOCTEST_VERSION_STR "1.2.1"
-
-#define DOCTEST_VERSION \
- (DOCTEST_VERSION_MAJOR * 10000 + DOCTEST_VERSION_MINOR * 100 + DOCTEST_VERSION_PATCH)
-
-// =================================================================================================
-// == FEATURE DETECTION ============================================================================
-// =================================================================================================
-
-#if __cplusplus >= 201103L
-#ifndef DOCTEST_CONFIG_WITH_DELETED_FUNCTIONS
-#define DOCTEST_CONFIG_WITH_DELETED_FUNCTIONS
-#endif // DOCTEST_CONFIG_WITH_DELETED_FUNCTIONS
-#ifndef DOCTEST_CONFIG_WITH_RVALUE_REFERENCES
-#define DOCTEST_CONFIG_WITH_RVALUE_REFERENCES
-#endif // DOCTEST_CONFIG_WITH_RVALUE_REFERENCES
-#ifndef DOCTEST_CONFIG_WITH_NULLPTR
-#define DOCTEST_CONFIG_WITH_NULLPTR
-#endif // DOCTEST_CONFIG_WITH_NULLPTR
-#ifndef DOCTEST_CONFIG_WITH_LONG_LONG
-#define DOCTEST_CONFIG_WITH_LONG_LONG
-#endif // DOCTEST_CONFIG_WITH_LONG_LONG
-#ifndef DOCTEST_CONFIG_WITH_STATIC_ASSERT
-#define DOCTEST_CONFIG_WITH_STATIC_ASSERT
-#endif // DOCTEST_CONFIG_WITH_STATIC_ASSERT
-#ifndef DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-#define DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-#endif // DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-#endif // __cplusplus >= 201103L
-
-#ifndef __has_feature
-#define __has_feature(x) 0
-#endif // __has_feature
-
-// MSVC C++11 feature support table: https://msdn.microsoft.com/en-us/library/hh567368.aspx
-// GCC C++11 feature support table: https://gcc.gnu.org/projects/cxx-status.html
-// MSVC version table:
-// MSVC++ 15.0 _MSC_VER == 1910 (Visual Studio 2017)
-// MSVC++ 14.0 _MSC_VER == 1900 (Visual Studio 2015)
-// MSVC++ 12.0 _MSC_VER == 1800 (Visual Studio 2013)
-// MSVC++ 11.0 _MSC_VER == 1700 (Visual Studio 2012)
-// MSVC++ 10.0 _MSC_VER == 1600 (Visual Studio 2010)
-// MSVC++ 9.0 _MSC_VER == 1500 (Visual Studio 2008)
-// MSVC++ 8.0 _MSC_VER == 1400 (Visual Studio 2005)
-
-// deleted functions
-
-#ifndef DOCTEST_CONFIG_WITH_DELETED_FUNCTIONS
-#if defined(_MSC_VER) && (_MSC_VER >= 1800)
-#define DOCTEST_CONFIG_WITH_DELETED_FUNCTIONS
-#endif // _MSC_VER
-#if defined(__clang__) && __has_feature(cxx_deleted_functions)
-#define DOCTEST_CONFIG_WITH_DELETED_FUNCTIONS
-#endif // __clang__
-#if defined(__GNUC__) && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 4) || __GNUC__ > 4) && \
- defined(__GXX_EXPERIMENTAL_CXX0X__)
-#define DOCTEST_CONFIG_WITH_DELETED_FUNCTIONS
-#endif // __GNUC__
-#endif // DOCTEST_CONFIG_WITH_DELETED_FUNCTIONS
-
-#if defined(DOCTEST_CONFIG_NO_DELETED_FUNCTIONS) && defined(DOCTEST_CONFIG_WITH_DELETED_FUNCTIONS)
-#undef DOCTEST_CONFIG_WITH_DELETED_FUNCTIONS
-#endif // DOCTEST_CONFIG_NO_DELETED_FUNCTIONS
-
-// rvalue references
-
-#ifndef DOCTEST_CONFIG_WITH_RVALUE_REFERENCES
-#if defined(_MSC_VER) && (_MSC_VER >= 1600)
-#define DOCTEST_CONFIG_WITH_RVALUE_REFERENCES
-#endif // _MSC_VER
-#if defined(__clang__) && __has_feature(cxx_rvalue_references)
-#define DOCTEST_CONFIG_WITH_RVALUE_REFERENCES
-#endif // __clang__
-#if defined(__GNUC__) && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 3) || __GNUC__ > 4) && \
- defined(__GXX_EXPERIMENTAL_CXX0X__)
-#define DOCTEST_CONFIG_WITH_RVALUE_REFERENCES
-#endif // __GNUC__
-#endif // DOCTEST_CONFIG_WITH_RVALUE_REFERENCES
-
-#if defined(DOCTEST_CONFIG_NO_RVALUE_REFERENCES) && defined(DOCTEST_CONFIG_WITH_RVALUE_REFERENCES)
-#undef DOCTEST_CONFIG_WITH_RVALUE_REFERENCES
-#endif // DOCTEST_CONFIG_NO_RVALUE_REFERENCES
-
-// nullptr
-
-#ifndef DOCTEST_CONFIG_WITH_NULLPTR
-#if defined(__clang__) && __has_feature(cxx_nullptr)
-#define DOCTEST_CONFIG_WITH_NULLPTR
-#endif // __clang__
-#if defined(__GNUC__) && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4) && \
- defined(__GXX_EXPERIMENTAL_CXX0X__)
-#define DOCTEST_CONFIG_WITH_NULLPTR
-#endif // __GNUC__
-#if defined(_MSC_VER) && (_MSC_VER >= 1600) // MSVC 2010
-#define DOCTEST_CONFIG_WITH_NULLPTR
-#endif // _MSC_VER
-#endif // DOCTEST_CONFIG_WITH_NULLPTR
-
-#if defined(DOCTEST_CONFIG_NO_NULLPTR) && defined(DOCTEST_CONFIG_WITH_NULLPTR)
-#undef DOCTEST_CONFIG_WITH_NULLPTR
-#endif // DOCTEST_CONFIG_NO_NULLPTR
-
-// variadic macros
-
-#ifndef DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-#if defined(_MSC_VER) && _MSC_VER > 1400 && !defined(__EDGE__)
-#define DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-#endif // _MSC_VER
-#if defined(__GNUC__) && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || __GNUC__ > 4) && \
- defined(__GXX_EXPERIMENTAL_CXX0X__)
-#define DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-#endif // __GNUC__ and clang
-#endif // DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-
-#if defined(DOCTEST_CONFIG_NO_VARIADIC_MACROS) && defined(DOCTEST_CONFIG_WITH_VARIADIC_MACROS)
-#undef DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-#endif // DOCTEST_CONFIG_NO_VARIADIC_MACROS
-
-// long long
-
-#ifndef DOCTEST_CONFIG_WITH_LONG_LONG
-#if defined(_MSC_VER) && (_MSC_VER >= 1400)
-#define DOCTEST_CONFIG_WITH_LONG_LONG
-#endif // _MSC_VER
-#if(defined(__clang__) || \
- (defined(__GNUC__) && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 5) || __GNUC__ > 4))) && \
- defined(__GXX_EXPERIMENTAL_CXX0X__)
-#define DOCTEST_CONFIG_WITH_LONG_LONG
-#endif // __GNUC__ and clang
-#endif // DOCTEST_CONFIG_WITH_LONG_LONG
-
-#if defined(DOCTEST_CONFIG_NO_LONG_LONG) && defined(DOCTEST_CONFIG_WITH_LONG_LONG)
-#undef DOCTEST_CONFIG_WITH_LONG_LONG
-#endif // DOCTEST_CONFIG_NO_LONG_LONG
-
-// static_assert
-
-#ifndef DOCTEST_CONFIG_WITH_STATIC_ASSERT
-#if defined(__clang__) && __has_feature(cxx_static_assert)
-#define DOCTEST_CONFIG_WITH_STATIC_ASSERT
-#endif // __clang__
-#if defined(__GNUC__) && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 3) || __GNUC__ > 4) && \
- defined(__GXX_EXPERIMENTAL_CXX0X__)
-#define DOCTEST_CONFIG_WITH_STATIC_ASSERT
-#endif // __GNUC__
-#if defined(_MSC_VER) && (_MSC_VER >= 1600) // MSVC 2010
-#define DOCTEST_CONFIG_WITH_STATIC_ASSERT
-#endif // _MSC_VER
-#endif // DOCTEST_CONFIG_WITH_STATIC_ASSERT
-
-#if defined(DOCTEST_CONFIG_NO_STATIC_ASSERT) && defined(DOCTEST_CONFIG_WITH_STATIC_ASSERT)
-#undef DOCTEST_CONFIG_WITH_STATIC_ASSERT
-#endif // DOCTEST_CONFIG_NO_STATIC_ASSERT
-
-// other stuff...
-
-#if defined(DOCTEST_CONFIG_WITH_RVALUE_REFERENCES) || defined(DOCTEST_CONFIG_WITH_LONG_LONG) || \
- defined(DOCTEST_CONFIG_WITH_DELETED_FUNCTIONS) || defined(DOCTEST_CONFIG_WITH_NULLPTR) || \
- defined(DOCTEST_CONFIG_WITH_VARIADIC_MACROS) || defined(DOCTEST_CONFIG_WITH_STATIC_ASSERT)
-#define DOCTEST_NO_CPP11_COMPAT
-#endif // c++11 stuff
-
-#if defined(__clang__) && defined(DOCTEST_NO_CPP11_COMPAT)
-#pragma clang diagnostic ignored "-Wc++98-compat"
-#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
-#endif // __clang__ && DOCTEST_NO_CPP11_COMPAT
-
-#if defined(_MSC_VER) && !defined(DOCTEST_CONFIG_WINDOWS_SEH)
-#define DOCTEST_CONFIG_WINDOWS_SEH
-#endif // _MSC_VER
-#if defined(DOCTEST_CONFIG_NO_WINDOWS_SEH) && defined(DOCTEST_CONFIG_WINDOWS_SEH)
-#undef DOCTEST_CONFIG_WINDOWS_SEH
-#endif // DOCTEST_CONFIG_NO_WINDOWS_SEH
-
-#if !defined(_WIN32) && !defined(__QNX__) && !defined(DOCTEST_CONFIG_POSIX_SIGNALS)
-#define DOCTEST_CONFIG_POSIX_SIGNALS
-#endif // _WIN32
-#if defined(DOCTEST_CONFIG_NO_POSIX_SIGNALS) && defined(DOCTEST_CONFIG_POSIX_SIGNALS)
-#undef DOCTEST_CONFIG_POSIX_SIGNALS
-#endif // DOCTEST_CONFIG_NO_POSIX_SIGNALS
-
-#ifndef DOCTEST_CONFIG_NO_EXCEPTIONS
-#if defined(__GNUC__) && !defined(__EXCEPTIONS)
-#define DOCTEST_CONFIG_NO_EXCEPTIONS
-#endif // clang and gcc
-// in MSVC _HAS_EXCEPTIONS is defined in a header instead of as a project define
-// so we can't do the automatic detection for MSVC without including some header
-#endif // DOCTEST_CONFIG_NO_EXCEPTIONS
-
-#ifdef DOCTEST_CONFIG_NO_EXCEPTIONS_BUT_WITH_ALL_ASSERTS
-#ifndef DOCTEST_CONFIG_NO_EXCEPTIONS
-#define DOCTEST_CONFIG_NO_EXCEPTIONS
-#endif // DOCTEST_CONFIG_NO_EXCEPTIONS
-#endif // DOCTEST_CONFIG_NO_EXCEPTIONS_BUT_WITH_ALL_ASSERTS
-
-#if defined(DOCTEST_CONFIG_NO_EXCEPTIONS) && !defined(DOCTEST_CONFIG_NO_TRY_CATCH_IN_ASSERTS)
-#define DOCTEST_CONFIG_NO_TRY_CATCH_IN_ASSERTS
-#endif // DOCTEST_CONFIG_NO_EXCEPTIONS && !DOCTEST_CONFIG_NO_TRY_CATCH_IN_ASSERTS
-
-#if defined(DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN) && !defined(DOCTEST_CONFIG_IMPLEMENT)
-#define DOCTEST_CONFIG_IMPLEMENT
-#endif // DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
-
-#if defined _WIN32 || defined __CYGWIN__
-#ifdef __GNUC__
-#define DOCTEST_SYMBOL_EXPORT __attribute__((dllexport))
-#define DOCTEST_SYMBOL_IMPORT __attribute__((dllimport))
-#else // __GNUC__
-#define DOCTEST_SYMBOL_EXPORT __declspec(dllexport)
-#define DOCTEST_SYMBOL_IMPORT __declspec(dllimport)
-#endif // __GNUC__
-#else // _WIN32
-#define DOCTEST_SYMBOL_EXPORT __attribute__((visibility("default")))
-#define DOCTEST_SYMBOL_IMPORT
-#endif // _WIN32
-
-#ifdef DOCTEST_CONFIG_IMPLEMENTATION_IN_DLL
-#ifdef DOCTEST_CONFIG_IMPLEMENT
-#define DOCTEST_INTERFACE DOCTEST_SYMBOL_EXPORT
-#else // DOCTEST_CONFIG_IMPLEMENT
-#define DOCTEST_INTERFACE DOCTEST_SYMBOL_IMPORT
-#endif // DOCTEST_CONFIG_IMPLEMENT
-#else // DOCTEST_CONFIG_IMPLEMENTATION_IN_DLL
-#define DOCTEST_INTERFACE
-#endif // DOCTEST_CONFIG_IMPLEMENTATION_IN_DLL
-
-#ifdef _MSC_VER
-#define DOCTEST_NOINLINE __declspec(noinline)
-#else // _MSC_VER
-#define DOCTEST_NOINLINE __attribute__((noinline))
-#endif // _MSC_VER
-
-#ifndef DOCTEST_CONFIG_NUM_CAPTURES_ON_STACK
-#define DOCTEST_CONFIG_NUM_CAPTURES_ON_STACK 5
-#endif // DOCTEST_CONFIG_NUM_CAPTURES_ON_STACK
-
-// =================================================================================================
-// == FEATURE DETECTION END ========================================================================
-// =================================================================================================
-
-// internal macros for string concatenation and anonymous variable name generation
-#define DOCTEST_CAT_IMPL(s1, s2) s1##s2
-#define DOCTEST_CAT(s1, s2) DOCTEST_CAT_IMPL(s1, s2)
-#ifdef __COUNTER__ // not standard and may be missing for some compilers
-#define DOCTEST_ANONYMOUS(x) DOCTEST_CAT(x, __COUNTER__)
-#else // __COUNTER__
-#define DOCTEST_ANONYMOUS(x) DOCTEST_CAT(x, __LINE__)
-#endif // __COUNTER__
-
-// macro for making a string out of an identifier
-#ifdef DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-#define DOCTEST_TOSTR_IMPL(...) #__VA_ARGS__
-#define DOCTEST_TOSTR(...) DOCTEST_TOSTR_IMPL(__VA_ARGS__)
-#else // DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-#define DOCTEST_TOSTR_IMPL(x) #x
-#define DOCTEST_TOSTR(x) DOCTEST_TOSTR_IMPL(x)
-#endif // DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-
-// for concatenating literals and making the result a string
-#define DOCTEST_STR_CONCAT_TOSTR(s1, s2) DOCTEST_TOSTR(s1) DOCTEST_TOSTR(s2)
-
-// counts the number of elements in a C string
-#define DOCTEST_COUNTOF(x) (sizeof(x) / sizeof(x[0]))
-
-#ifndef DOCTEST_CONFIG_ASSERTION_PARAMETERS_BY_VALUE
-#define DOCTEST_REF_WRAP(x) x&
-#else // DOCTEST_CONFIG_ASSERTION_PARAMETERS_BY_VALUE
-#define DOCTEST_REF_WRAP(x) x
-#endif // DOCTEST_CONFIG_ASSERTION_PARAMETERS_BY_VALUE
-
-// not using __APPLE__ because... this is how Catch does it
-#if defined(__MAC_OS_X_VERSION_MIN_REQUIRED)
-#define DOCTEST_PLATFORM_MAC
-#elif defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
-#define DOCTEST_PLATFORM_IPHONE
-#elif defined(_WIN32) || defined(_MSC_VER)
-#define DOCTEST_PLATFORM_WINDOWS
-#else
-#define DOCTEST_PLATFORM_LINUX
-#endif
-
-#if defined(__clang__)
-#define DOCTEST_GLOBAL_NO_WARNINGS(var) \
- _Pragma("clang diagnostic push") \
- _Pragma("clang diagnostic ignored \"-Wglobal-constructors\"") static int var
-#define DOCTEST_GLOBAL_NO_WARNINGS_END() _Pragma("clang diagnostic pop")
-#elif defined(__GNUC__)
-#define DOCTEST_GLOBAL_NO_WARNINGS(var) static int var __attribute__((unused))
-#define DOCTEST_GLOBAL_NO_WARNINGS_END()
-#else // MSVC / other
-#define DOCTEST_GLOBAL_NO_WARNINGS(var) static int var
-#define DOCTEST_GLOBAL_NO_WARNINGS_END()
-#endif // MSVC / other
-
-// should probably take a look at https://github.com/scottt/debugbreak
-#ifdef DOCTEST_PLATFORM_MAC
-#define DOCTEST_BREAK_INTO_DEBUGGER() __asm__("int $3\n" : :)
-#elif defined(_MSC_VER)
-#define DOCTEST_BREAK_INTO_DEBUGGER() __debugbreak()
-#elif defined(__MINGW32__)
-extern "C" __declspec(dllimport) void __stdcall DebugBreak();
-#define DOCTEST_BREAK_INTO_DEBUGGER() ::DebugBreak()
-#else // linux
-#define DOCTEST_BREAK_INTO_DEBUGGER() ((void)0)
-#endif // linux
-
-#ifdef __clang__
-// to detect if libc++ is being used with clang (the _LIBCPP_VERSION identifier)
-#include <ciso646>
-#endif // __clang__
-
-#ifdef _LIBCPP_VERSION
-// not forward declaring ostream for libc++ because I had some problems (inline namespaces vs c++98)
-// so the <iosfwd> header is used - also it is very light and doesn't drag a ton of stuff
-#include <iosfwd>
-#else // _LIBCPP_VERSION
-#ifndef DOCTEST_CONFIG_USE_IOSFWD
-namespace std
-{
-template <class charT>
-struct char_traits;
-template <>
-struct char_traits<char>;
-template <class charT, class traits>
-class basic_ostream;
-typedef basic_ostream<char, char_traits<char> > ostream;
-} // namespace std
-#else // DOCTEST_CONFIG_USE_IOSFWD
-#include <iosfwd>
-#endif // DOCTEST_CONFIG_USE_IOSFWD
-#endif // _LIBCPP_VERSION
-
-// static assert macro - because of the c++98 support requires that the message is an
-// identifier (no spaces and not a C string) - example without quotes: I_am_a_message
-// taken from here: http://stackoverflow.com/a/1980156/3162383
-#ifdef DOCTEST_CONFIG_WITH_STATIC_ASSERT
-#define DOCTEST_STATIC_ASSERT(expression, message) static_assert(expression, #message)
-#else // DOCTEST_CONFIG_WITH_STATIC_ASSERT
-#define DOCTEST_STATIC_ASSERT(expression, message) \
- struct DOCTEST_CAT(__static_assertion_at_line_, __LINE__) \
- { \
- doctest::detail::static_assert_impl::StaticAssertion<static_cast<bool>((expression))> \
- DOCTEST_CAT(DOCTEST_CAT(DOCTEST_CAT(STATIC_ASSERTION_FAILED_AT_LINE_, __LINE__), \
- _), \
- message); \
- }; \
- typedef doctest::detail::static_assert_impl::StaticAssertionTest<static_cast<int>( \
- sizeof(DOCTEST_CAT(__static_assertion_at_line_, __LINE__)))> \
- DOCTEST_CAT(__static_assertion_test_at_line_, __LINE__)
-#endif // DOCTEST_CONFIG_WITH_STATIC_ASSERT
-
-#ifdef DOCTEST_CONFIG_WITH_NULLPTR
-#ifdef _LIBCPP_VERSION
-#include <cstddef>
-#else // _LIBCPP_VERSION
-namespace std
-{ typedef decltype(nullptr) nullptr_t; }
-#endif // _LIBCPP_VERSION
-#endif // DOCTEST_CONFIG_WITH_NULLPTR
-
-#ifndef DOCTEST_CONFIG_DISABLE
-
-#ifdef DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS
-#include <type_traits>
-#endif // DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS
-
-namespace doctest
-{
-namespace detail
-{
- struct TestSuite
- {
- const char* m_test_suite;
- const char* m_description;
- bool m_skip;
- bool m_may_fail;
- bool m_should_fail;
- int m_expected_failures;
- double m_timeout;
-
- TestSuite& operator*(const char* in) {
- m_test_suite = in;
- // clear state
- m_description = 0;
- m_skip = false;
- m_may_fail = false;
- m_should_fail = false;
- m_expected_failures = 0;
- m_timeout = 0;
- return *this;
- }
-
- template <typename T>
- TestSuite& operator*(const T& in) {
- in.fill(*this);
- return *this;
- }
- };
-} // namespace detail
-} // namespace doctest
-
-// in a separate namespace outside of doctest because the DOCTEST_TEST_SUITE macro
-// introduces an anonymous namespace in which getCurrentTestSuite gets overridden
-namespace doctest_detail_test_suite_ns
-{
-DOCTEST_INTERFACE doctest::detail::TestSuite& getCurrentTestSuite();
-} // namespace doctest_detail_test_suite_ns
-
-#endif // DOCTEST_CONFIG_DISABLE
-
-namespace doctest
-{
-// A 24 byte string class (can be as small as 17 for x64 and 13 for x86) that can hold strings with length
-// of up to 23 chars on the stack before going on the heap - the last byte of the buffer is used for:
-// - "is small" bit - the highest bit - if "0" then it is small - otherwise its "1" (128)
-// - if small - capacity left before going on the heap - using the lowest 5 bits
-// - if small - 2 bits are left unused - the second and third highest ones
-// - if small - acts as a null terminator if strlen() is 23 (24 including the null terminator)
-// and the "is small" bit remains "0" ("as well as the capacity left") so its OK
-// Idea taken from this lecture about the string implementation of facebook/folly - fbstring
-// https://www.youtube.com/watch?v=kPR8h4-qZdk
-// TODO:
-// - optimizations - like not deleting memory unnecessarily in operator= and etc.
-// - resize/reserve/clear
-// - substr
-// - replace
-// - back/front
-// - iterator stuff
-// - find & friends
-// - push_back/pop_back
-// - assign/insert/erase
-// - relational operators as free functions - taking const char* as one of the params
-class DOCTEST_INTERFACE String
-{
- static const unsigned len = 24; //!OCLINT avoid private static members
- static const unsigned last = len - 1; //!OCLINT avoid private static members
-
- struct view // len should be more than sizeof(view) - because of the final byte for flags
- {
- char* ptr;
- unsigned size;
- unsigned capacity;
- };
-
- union
- {
- char buf[len];
- view data;
- };
-
- void copy(const String& other);
-
- void setOnHeap() { *reinterpret_cast<unsigned char*>(&buf[last]) = 128; }
- void setLast(unsigned in = last) { buf[last] = char(in); }
-
-public:
- String() {
- buf[0] = '\0';
- setLast();
- }
-
- String(const char* in);
-
- String(const String& other) { copy(other); }
-
- ~String() {
- if(!isOnStack())
- delete[] data.ptr;
- }
-
- // GCC 4.9/5/6 report Wstrict-overflow when optimizations are ON and it got inlined in the vector class somewhere...
- // see commit 574ef95f0cd379118be5011704664e4b5351f1e0 and build https://travis-ci.org/onqtam/doctest/builds/230671611
- DOCTEST_NOINLINE String& operator=(const String& other) {
- if(this != &other) {
- if(!isOnStack())
- delete[] data.ptr;
-
- copy(other);
- }
-
- return *this;
- }
- String& operator+=(const String& other);
-
- String operator+(const String& other) const { return String(*this) += other; }
-
-#ifdef DOCTEST_CONFIG_WITH_RVALUE_REFERENCES
- String(String&& other);
- String& operator=(String&& other);
-#endif // DOCTEST_CONFIG_WITH_RVALUE_REFERENCES
-
- bool isOnStack() const { return (buf[last] & 128) == 0; }
-
- char operator[](unsigned i) const { return const_cast<String*>(this)->operator[](i); } // NOLINT
- char& operator[](unsigned i) {
- if(isOnStack())
- return reinterpret_cast<char*>(buf)[i];
- return data.ptr[i];
- }
-
- const char* c_str() const { return const_cast<String*>(this)->c_str(); } // NOLINT
- char* c_str() {
- if(isOnStack())
- return reinterpret_cast<char*>(buf);
- return data.ptr;
- }
-
- unsigned size() const {
- if(isOnStack())
- return last - (unsigned(buf[last]) & 31); // using "last" would work only if "len" is 32
- return data.size;
- }
-
- unsigned capacity() const {
- if(isOnStack())
- return len;
- return data.capacity;
- }
-
- int compare(const char* other, bool no_case = false) const;
- int compare(const String& other, bool no_case = false) const;
-};
-
-// clang-format off
-inline bool operator==(const String& lhs, const String& rhs) { return lhs.compare(rhs) == 0; }
-inline bool operator!=(const String& lhs, const String& rhs) { return lhs.compare(rhs) != 0; }
-inline bool operator< (const String& lhs, const String& rhs) { return lhs.compare(rhs) < 0; }
-inline bool operator> (const String& lhs, const String& rhs) { return lhs.compare(rhs) > 0; }
-inline bool operator<=(const String& lhs, const String& rhs) { return (lhs != rhs) ? lhs.compare(rhs) < 0 : true; }
-inline bool operator>=(const String& lhs, const String& rhs) { return (lhs != rhs) ? lhs.compare(rhs) > 0 : true; }
-// clang-format on
-
-DOCTEST_INTERFACE std::ostream& operator<<(std::ostream& stream, const String& in);
-
-namespace detail
-{
-#ifndef DOCTEST_CONFIG_WITH_STATIC_ASSERT
- namespace static_assert_impl
- {
- template <bool>
- struct StaticAssertion;
-
- template <>
- struct StaticAssertion<true>
- {};
-
- template <int i>
- struct StaticAssertionTest
- {};
- } // namespace static_assert_impl
-#endif // DOCTEST_CONFIG_WITH_STATIC_ASSERT
-
- template <bool CONDITION, typename TYPE = void>
- struct enable_if
- {};
-
- template <typename TYPE>
- struct enable_if<true, TYPE>
- { typedef TYPE type; };
-
- template <typename T>
- struct deferred_false
- // cppcheck-suppress unusedStructMember
- { static const bool value = false; };
-
- // to silence the warning "-Wzero-as-null-pointer-constant" only for gcc 5 for the Approx template ctor - pragmas don't work for it...
- inline void* getNull() { return 0; }
-
- namespace has_insertion_operator_impl
- {
- typedef char no;
- typedef char yes[2];
-
- struct any_t
- {
- template <typename T>
- // cppcheck-suppress noExplicitConstructor
- any_t(const DOCTEST_REF_WRAP(T));
- };
-
- yes& testStreamable(std::ostream&);
- no testStreamable(no);
-
- no operator<<(const std::ostream&, const any_t&);
-
- template <typename T>
- struct has_insertion_operator
- {
- static std::ostream& s;
- static const DOCTEST_REF_WRAP(T) t;
- static const bool value = sizeof(testStreamable(s << t)) == sizeof(yes);
- };
- } // namespace has_insertion_operator_impl
-
- template <typename T>
- struct has_insertion_operator : has_insertion_operator_impl::has_insertion_operator<T>
- {};
-
- DOCTEST_INTERFACE void my_memcpy(void* dest, const void* src, unsigned num);
- DOCTEST_INTERFACE unsigned my_strlen(const char* in);
-
- DOCTEST_INTERFACE std::ostream* createStream();
- DOCTEST_INTERFACE String getStreamResult(std::ostream*);
- DOCTEST_INTERFACE void freeStream(std::ostream*);
-
- template <bool C>
- struct StringMakerBase
- {
- template <typename T>
- static String convert(const DOCTEST_REF_WRAP(T)) {
- return "{?}";
- }
- };
-
- template <>
- struct StringMakerBase<true>
- {
- template <typename T>
- static String convert(const DOCTEST_REF_WRAP(T) in) {
- std::ostream* stream = createStream();
- *stream << in;
- String result = getStreamResult(stream);
- freeStream(stream);
- return result;
- }
- };
-
- DOCTEST_INTERFACE String rawMemoryToString(const void* object, unsigned size);
-
- template <typename T>
- String rawMemoryToString(const DOCTEST_REF_WRAP(T) object) {
- return rawMemoryToString(&object, sizeof(object));
- }
-
- class NullType
- {};
-
- template <class T, class U>
- struct Typelist
- {
- typedef T Head;
- typedef U Tail;
- };
-
- // type of recursive function
- template <class TList, class Callable>
- struct ForEachType;
-
- // Recursion rule
- template <class Head, class Tail, class Callable>
- struct ForEachType<Typelist<Head, Tail>, Callable> : public ForEachType<Tail, Callable>
- {
- enum
- {
- value = 1 + ForEachType<Tail, Callable>::value
- };
-
- explicit ForEachType(Callable& callable)
- : ForEachType<Tail, Callable>(callable) {
-#if defined(_MSC_VER) && _MSC_VER <= 1900
- callable.operator()<value, Head>();
-#else // _MSC_VER
- callable.template operator()<value, Head>();
-#endif // _MSC_VER
- }
- };
-
- // Recursion end
- template <class Head, class Callable>
- struct ForEachType<Typelist<Head, NullType>, Callable>
- {
- public:
- enum
- {
- value = 0
- };
-
- explicit ForEachType(Callable& callable) {
-#if defined(_MSC_VER) && _MSC_VER <= 1900
- callable.operator()<value, Head>();
-#else // _MSC_VER
- callable.template operator()<value, Head>();
-#endif // _MSC_VER
- }
- };
-
- template <typename T>
- const char* type_to_string() {
- return "<>";
- }
-} // namespace detail
-
-template <typename T1 = detail::NullType, typename T2 = detail::NullType,
- typename T3 = detail::NullType, typename T4 = detail::NullType,
- typename T5 = detail::NullType, typename T6 = detail::NullType,
- typename T7 = detail::NullType, typename T8 = detail::NullType,
- typename T9 = detail::NullType, typename T10 = detail::NullType,
- typename T11 = detail::NullType, typename T12 = detail::NullType,
- typename T13 = detail::NullType, typename T14 = detail::NullType,
- typename T15 = detail::NullType, typename T16 = detail::NullType,
- typename T17 = detail::NullType, typename T18 = detail::NullType,
- typename T19 = detail::NullType, typename T20 = detail::NullType,
- typename T21 = detail::NullType, typename T22 = detail::NullType,
- typename T23 = detail::NullType, typename T24 = detail::NullType,
- typename T25 = detail::NullType, typename T26 = detail::NullType,
- typename T27 = detail::NullType, typename T28 = detail::NullType,
- typename T29 = detail::NullType, typename T30 = detail::NullType,
- typename T31 = detail::NullType, typename T32 = detail::NullType,
- typename T33 = detail::NullType, typename T34 = detail::NullType,
- typename T35 = detail::NullType, typename T36 = detail::NullType,
- typename T37 = detail::NullType, typename T38 = detail::NullType,
- typename T39 = detail::NullType, typename T40 = detail::NullType,
- typename T41 = detail::NullType, typename T42 = detail::NullType,
- typename T43 = detail::NullType, typename T44 = detail::NullType,
- typename T45 = detail::NullType, typename T46 = detail::NullType,
- typename T47 = detail::NullType, typename T48 = detail::NullType,
- typename T49 = detail::NullType, typename T50 = detail::NullType,
- typename T51 = detail::NullType, typename T52 = detail::NullType,
- typename T53 = detail::NullType, typename T54 = detail::NullType,
- typename T55 = detail::NullType, typename T56 = detail::NullType,
- typename T57 = detail::NullType, typename T58 = detail::NullType,
- typename T59 = detail::NullType, typename T60 = detail::NullType>
-struct Types
-{
-private:
- typedef typename Types<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17,
- T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, T31,
- T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44, T45,
- T46, T47, T48, T49, T50, T51, T52, T53, T54, T55, T56, T57, T58, T59,
- T60>::Result TailResult;
-
-public:
- typedef detail::Typelist<T1, TailResult> Result;
-};
-
-template <>
-struct Types<>
-{ typedef detail::NullType Result; };
-
-template <typename T>
-struct StringMaker : detail::StringMakerBase<detail::has_insertion_operator<T>::value>
-{};
-
-template <typename T>
-struct StringMaker<T*>
-{
- template <typename U>
- static String convert(U* p) {
- if(p)
- return detail::rawMemoryToString(p);
- return "NULL";
- }
-};
-
-template <typename R, typename C>
-struct StringMaker<R C::*>
-{
- static String convert(R C::*p) {
- if(p)
- return detail::rawMemoryToString(p);
- return "NULL";
- }
-};
-
-template <typename T>
-String toString(const DOCTEST_REF_WRAP(T) value) {
- return StringMaker<T>::convert(value);
-}
-
-#ifdef DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING
-DOCTEST_INTERFACE String toString(char* in);
-DOCTEST_INTERFACE String toString(const char* in);
-#endif // DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING
-DOCTEST_INTERFACE String toString(bool in);
-DOCTEST_INTERFACE String toString(float in);
-DOCTEST_INTERFACE String toString(double in);
-DOCTEST_INTERFACE String toString(double long in);
-
-DOCTEST_INTERFACE String toString(char in);
-DOCTEST_INTERFACE String toString(char signed in);
-DOCTEST_INTERFACE String toString(char unsigned in);
-DOCTEST_INTERFACE String toString(int short in);
-DOCTEST_INTERFACE String toString(int short unsigned in);
-DOCTEST_INTERFACE String toString(int in);
-DOCTEST_INTERFACE String toString(int unsigned in);
-DOCTEST_INTERFACE String toString(int long in);
-DOCTEST_INTERFACE String toString(int long unsigned in);
-
-#ifdef DOCTEST_CONFIG_WITH_LONG_LONG
-DOCTEST_INTERFACE String toString(int long long in);
-DOCTEST_INTERFACE String toString(int long long unsigned in);
-#endif // DOCTEST_CONFIG_WITH_LONG_LONG
-
-#ifdef DOCTEST_CONFIG_WITH_NULLPTR
-DOCTEST_INTERFACE String toString(std::nullptr_t in);
-#endif // DOCTEST_CONFIG_WITH_NULLPTR
-
-class DOCTEST_INTERFACE Approx
-{
-public:
- explicit Approx(double value);
-
- Approx operator()(double value) const {
- Approx approx(value);
- approx.epsilon(m_epsilon);
- approx.scale(m_scale);
- return approx;
- }
-
-#ifdef DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS
- template <typename T>
- explicit Approx(const T& value,
- typename detail::enable_if<std::is_constructible<double, T>::value>::type* =
- static_cast<T*>(detail::getNull())) {
- *this = Approx(static_cast<double>(value));
- }
-#endif // DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS
-
- // clang-format off
- // overloads for double - the first one is necessary as it is in the implementation part of doctest
- // as for the others - keeping them for potentially faster compile times
- DOCTEST_INTERFACE friend bool operator==(double lhs, Approx const& rhs);
- friend bool operator==(Approx const& lhs, double rhs) { return operator==(rhs, lhs); }
- friend bool operator!=(double lhs, Approx const& rhs) { return !operator==(lhs, rhs); }
- friend bool operator!=(Approx const& lhs, double rhs) { return !operator==(rhs, lhs); }
- friend bool operator<=(double lhs, Approx const& rhs) { return lhs < rhs.m_value || lhs == rhs; }
- friend bool operator<=(Approx const& lhs, double rhs) { return lhs.m_value < rhs || lhs == rhs; }
- friend bool operator>=(double lhs, Approx const& rhs) { return lhs > rhs.m_value || lhs == rhs; }
- friend bool operator>=(Approx const& lhs, double rhs) { return lhs.m_value > rhs || lhs == rhs; }
- friend bool operator< (double lhs, Approx const& rhs) { return lhs < rhs.m_value && lhs != rhs; }
- friend bool operator< (Approx const& lhs, double rhs) { return lhs.m_value < rhs && lhs != rhs; }
- friend bool operator> (double lhs, Approx const& rhs) { return lhs > rhs.m_value && lhs != rhs; }
- friend bool operator> (Approx const& lhs, double rhs) { return lhs.m_value > rhs && lhs != rhs; }
-
-#ifdef DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS
-#define DOCTEST_APPROX_PREFIX \
- template <typename T> friend typename detail::enable_if<std::is_constructible<double, T>::value, bool>::type
-
- DOCTEST_APPROX_PREFIX operator==(const T& lhs, const Approx& rhs) { return operator==(double(lhs), rhs); }
- DOCTEST_APPROX_PREFIX operator==(const Approx& lhs, const T& rhs) { return operator==(rhs, lhs); }
- DOCTEST_APPROX_PREFIX operator!=(const T& lhs, const Approx& rhs) { return !operator==(lhs, rhs); }
- DOCTEST_APPROX_PREFIX operator!=(const Approx& lhs, const T& rhs) { return !operator==(rhs, lhs); }
- DOCTEST_APPROX_PREFIX operator<=(const T& lhs, const Approx& rhs) { return double(lhs) < rhs.m_value || lhs == rhs; }
- DOCTEST_APPROX_PREFIX operator<=(const Approx& lhs, const T& rhs) { return lhs.m_value < double(rhs) || lhs == rhs; }
- DOCTEST_APPROX_PREFIX operator>=(const T& lhs, const Approx& rhs) { return double(lhs) > rhs.m_value || lhs == rhs; }
- DOCTEST_APPROX_PREFIX operator>=(const Approx& lhs, const T& rhs) { return lhs.m_value > double(rhs) || lhs == rhs; }
- DOCTEST_APPROX_PREFIX operator< (const T& lhs, const Approx& rhs) { return double(lhs) < rhs.m_value && lhs != rhs; }
- DOCTEST_APPROX_PREFIX operator< (const Approx& lhs, const T& rhs) { return lhs.m_value < double(rhs) && lhs != rhs; }
- DOCTEST_APPROX_PREFIX operator> (const T& lhs, const Approx& rhs) { return double(lhs) > rhs.m_value && lhs != rhs; }
- DOCTEST_APPROX_PREFIX operator> (const Approx& lhs, const T& rhs) { return lhs.m_value > double(rhs) && lhs != rhs; }
-#undef DOCTEST_APPROX_PREFIX
-#endif // DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS
-
- // clang-format on
-
- Approx& epsilon(double newEpsilon) {
- m_epsilon = newEpsilon;
- return *this;
- }
-
-#ifdef DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS
- template <typename T>
- typename detail::enable_if<std::is_constructible<double, T>::value, Approx&>::type epsilon(
- const T& newEpsilon) {
- m_epsilon = static_cast<double>(newEpsilon);
- return *this;
- }
-#endif // DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS
-
- Approx& scale(double newScale) {
- m_scale = newScale;
- return *this;
- }
-
-#ifdef DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS
- template <typename T>
- typename detail::enable_if<std::is_constructible<double, T>::value, Approx&>::type scale(
- const T& newScale) {
- m_scale = static_cast<double>(newScale);
- return *this;
- }
-#endif // DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS
-
- String toString() const;
-
-private:
- double m_epsilon;
- double m_scale;
- double m_value;
-};
-
-template <>
-inline String toString<Approx>(const DOCTEST_REF_WRAP(Approx) value) {
- return value.toString();
-}
-
-#if !defined(DOCTEST_CONFIG_DISABLE)
-
-namespace detail
-{
- // the function type this library works with
- typedef void (*funcType)();
-
- namespace assertType
- {
- enum Enum
- {
- // macro traits
-
- is_warn = 1,
- is_check = 2,
- is_require = 4,
-
- is_throws = 8,
- is_throws_as = 16,
- is_nothrow = 32,
-
- is_fast = 64, // not checked anywhere - used just to distinguish the types
- is_false = 128,
- is_unary = 256,
-
- is_eq = 512,
- is_ne = 1024,
-
- is_lt = 2048,
- is_gt = 4096,
-
- is_ge = 8192,
- is_le = 16384,
-
- // macro types
-
- DT_WARN = is_warn,
- DT_CHECK = is_check,
- DT_REQUIRE = is_require,
-
- DT_WARN_FALSE = is_false | is_warn,
- DT_CHECK_FALSE = is_false | is_check,
- DT_REQUIRE_FALSE = is_false | is_require,
-
- DT_WARN_THROWS = is_throws | is_warn,
- DT_CHECK_THROWS = is_throws | is_check,
- DT_REQUIRE_THROWS = is_throws | is_require,
-
- DT_WARN_THROWS_AS = is_throws_as | is_warn,
- DT_CHECK_THROWS_AS = is_throws_as | is_check,
- DT_REQUIRE_THROWS_AS = is_throws_as | is_require,
-
- DT_WARN_NOTHROW = is_nothrow | is_warn,
- DT_CHECK_NOTHROW = is_nothrow | is_check,
- DT_REQUIRE_NOTHROW = is_nothrow | is_require,
-
- DT_WARN_EQ = is_eq | is_warn,
- DT_CHECK_EQ = is_eq | is_check,
- DT_REQUIRE_EQ = is_eq | is_require,
-
- DT_WARN_NE = is_ne | is_warn,
- DT_CHECK_NE = is_ne | is_check,
- DT_REQUIRE_NE = is_ne | is_require,
-
- DT_WARN_GT = is_gt | is_warn,
- DT_CHECK_GT = is_gt | is_check,
- DT_REQUIRE_GT = is_gt | is_require,
-
- DT_WARN_LT = is_lt | is_warn,
- DT_CHECK_LT = is_lt | is_check,
- DT_REQUIRE_LT = is_lt | is_require,
-
- DT_WARN_GE = is_ge | is_warn,
- DT_CHECK_GE = is_ge | is_check,
- DT_REQUIRE_GE = is_ge | is_require,
-
- DT_WARN_LE = is_le | is_warn,
- DT_CHECK_LE = is_le | is_check,
- DT_REQUIRE_LE = is_le | is_require,
-
- DT_WARN_UNARY = is_unary | is_warn,
- DT_CHECK_UNARY = is_unary | is_check,
- DT_REQUIRE_UNARY = is_unary | is_require,
-
- DT_WARN_UNARY_FALSE = is_false | is_unary | is_warn,
- DT_CHECK_UNARY_FALSE = is_false | is_unary | is_check,
- DT_REQUIRE_UNARY_FALSE = is_false | is_unary | is_require,
-
- DT_FAST_WARN_EQ = is_fast | is_eq | is_warn,
- DT_FAST_CHECK_EQ = is_fast | is_eq | is_check,
- DT_FAST_REQUIRE_EQ = is_fast | is_eq | is_require,
-
- DT_FAST_WARN_NE = is_fast | is_ne | is_warn,
- DT_FAST_CHECK_NE = is_fast | is_ne | is_check,
- DT_FAST_REQUIRE_NE = is_fast | is_ne | is_require,
-
- DT_FAST_WARN_GT = is_fast | is_gt | is_warn,
- DT_FAST_CHECK_GT = is_fast | is_gt | is_check,
- DT_FAST_REQUIRE_GT = is_fast | is_gt | is_require,
-
- DT_FAST_WARN_LT = is_fast | is_lt | is_warn,
- DT_FAST_CHECK_LT = is_fast | is_lt | is_check,
- DT_FAST_REQUIRE_LT = is_fast | is_lt | is_require,
-
- DT_FAST_WARN_GE = is_fast | is_ge | is_warn,
- DT_FAST_CHECK_GE = is_fast | is_ge | is_check,
- DT_FAST_REQUIRE_GE = is_fast | is_ge | is_require,
-
- DT_FAST_WARN_LE = is_fast | is_le | is_warn,
- DT_FAST_CHECK_LE = is_fast | is_le | is_check,
- DT_FAST_REQUIRE_LE = is_fast | is_le | is_require,
-
- DT_FAST_WARN_UNARY = is_fast | is_unary | is_warn,
- DT_FAST_CHECK_UNARY = is_fast | is_unary | is_check,
- DT_FAST_REQUIRE_UNARY = is_fast | is_unary | is_require,
-
- DT_FAST_WARN_UNARY_FALSE = is_fast | is_false | is_unary | is_warn,
- DT_FAST_CHECK_UNARY_FALSE = is_fast | is_false | is_unary | is_check,
- DT_FAST_REQUIRE_UNARY_FALSE = is_fast | is_false | is_unary | is_require
- };
- } // namespace assertType
-
- DOCTEST_INTERFACE const char* getAssertString(assertType::Enum val);
-
- // clang-format off
- template<class T> struct decay_array { typedef T type; };
- template<class T, unsigned N> struct decay_array<T[N]> { typedef T* type; };
- template<class T> struct decay_array<T[]> { typedef T* type; };
-
- template<class T> struct not_char_pointer { enum { value = 1 }; };
- template<> struct not_char_pointer<char*> { enum { value = 0 }; };
- template<> struct not_char_pointer<const char*> { enum { value = 0 }; };
-
- template<class T> struct can_use_op : not_char_pointer<typename decay_array<T>::type> {};
- // clang-format on
-
- struct TestFailureException
- {};
-
- DOCTEST_INTERFACE bool checkIfShouldThrow(assertType::Enum assert_type);
- DOCTEST_INTERFACE void fastAssertThrowIfFlagSet(int flags);
- DOCTEST_INTERFACE void throwException();
-
- struct TestAccessibleContextState
- {
- bool no_throw; // to skip exceptions-related assertion macros
- bool success; // include successful assertions in output
- };
-
- struct ContextState;
-
- DOCTEST_INTERFACE TestAccessibleContextState* getTestsContextState();
-
- struct DOCTEST_INTERFACE SubcaseSignature
- {
- const char* m_name;
- const char* m_file;
- int m_line;
-
- SubcaseSignature(const char* name, const char* file, int line)
- : m_name(name)
- , m_file(file)
- , m_line(line) {}
-
- bool operator<(const SubcaseSignature& other) const;
- };
-
- // cppcheck-suppress copyCtorAndEqOperator
- struct DOCTEST_INTERFACE Subcase
- {
- SubcaseSignature m_signature;
- bool m_entered;
-
- Subcase(const char* name, const char* file, int line);
- Subcase(const Subcase& other);
- ~Subcase();
-
- operator bool() const { return m_entered; }
- };
-
- template <typename L, typename R>
- String stringifyBinaryExpr(const DOCTEST_REF_WRAP(L) lhs, const char* op,
- const DOCTEST_REF_WRAP(R) rhs) {
- return toString(lhs) + op + toString(rhs);
- }
-
- struct DOCTEST_INTERFACE Result
- {
- bool m_passed;
- String m_decomposition;
-
- ~Result();
-
- DOCTEST_NOINLINE Result(bool passed = false, const String& decomposition = String())
- : m_passed(passed)
- , m_decomposition(decomposition) {}
-
- DOCTEST_NOINLINE Result(const Result& other)
- : m_passed(other.m_passed)
- , m_decomposition(other.m_decomposition) {}
-
- Result& operator=(const Result& other);
-
- operator bool() { return !m_passed; }
-
- // clang-format off
- // forbidding some expressions based on this table: http://en.cppreference.com/w/cpp/language/operator_precedence
- template <typename R> Result& operator& (const R&) { DOCTEST_STATIC_ASSERT(deferred_false<R>::value, Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison); return *this; }
- template <typename R> Result& operator^ (const R&) { DOCTEST_STATIC_ASSERT(deferred_false<R>::value, Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison); return *this; }
- template <typename R> Result& operator| (const R&) { DOCTEST_STATIC_ASSERT(deferred_false<R>::value, Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison); return *this; }
- template <typename R> Result& operator&& (const R&) { DOCTEST_STATIC_ASSERT(deferred_false<R>::value, Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison); return *this; }
- template <typename R> Result& operator|| (const R&) { DOCTEST_STATIC_ASSERT(deferred_false<R>::value, Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison); return *this; }
- template <typename R> Result& operator== (const R&) { DOCTEST_STATIC_ASSERT(deferred_false<R>::value, Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison); return *this; }
- template <typename R> Result& operator!= (const R&) { DOCTEST_STATIC_ASSERT(deferred_false<R>::value, Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison); return *this; }
- template <typename R> Result& operator< (const R&) { DOCTEST_STATIC_ASSERT(deferred_false<R>::value, Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison); return *this; }
- template <typename R> Result& operator> (const R&) { DOCTEST_STATIC_ASSERT(deferred_false<R>::value, Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison); return *this; }
- template <typename R> Result& operator<= (const R&) { DOCTEST_STATIC_ASSERT(deferred_false<R>::value, Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison); return *this; }
- template <typename R> Result& operator>= (const R&) { DOCTEST_STATIC_ASSERT(deferred_false<R>::value, Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison); return *this; }
- template <typename R> Result& operator= (const R&) { DOCTEST_STATIC_ASSERT(deferred_false<R>::value, Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison); return *this; }
- template <typename R> Result& operator+= (const R&) { DOCTEST_STATIC_ASSERT(deferred_false<R>::value, Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison); return *this; }
- template <typename R> Result& operator-= (const R&) { DOCTEST_STATIC_ASSERT(deferred_false<R>::value, Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison); return *this; }
- template <typename R> Result& operator*= (const R&) { DOCTEST_STATIC_ASSERT(deferred_false<R>::value, Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison); return *this; }
- template <typename R> Result& operator/= (const R&) { DOCTEST_STATIC_ASSERT(deferred_false<R>::value, Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison); return *this; }
- template <typename R> Result& operator%= (const R&) { DOCTEST_STATIC_ASSERT(deferred_false<R>::value, Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison); return *this; }
- template <typename R> Result& operator<<=(const R&) { DOCTEST_STATIC_ASSERT(deferred_false<R>::value, Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison); return *this; }
- template <typename R> Result& operator>>=(const R&) { DOCTEST_STATIC_ASSERT(deferred_false<R>::value, Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison); return *this; }
- template <typename R> Result& operator&= (const R&) { DOCTEST_STATIC_ASSERT(deferred_false<R>::value, Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison); return *this; }
- template <typename R> Result& operator^= (const R&) { DOCTEST_STATIC_ASSERT(deferred_false<R>::value, Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison); return *this; }
- template <typename R> Result& operator|= (const R&) { DOCTEST_STATIC_ASSERT(deferred_false<R>::value, Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison); return *this; }
- // clang-format on
- };
-
-#ifndef DOCTEST_CONFIG_NO_COMPARISON_WARNING_SUPPRESSION
-
-#if defined(__clang__)
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wsign-conversion"
-#pragma clang diagnostic ignored "-Wsign-compare"
-//#pragma clang diagnostic ignored "-Wdouble-promotion"
-//#pragma clang diagnostic ignored "-Wconversion"
-//#pragma clang diagnostic ignored "-Wfloat-equal"
-#endif // __clang__
-
-#if defined(__GNUC__) && !defined(__clang__)
-#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 6)
-#pragma GCC diagnostic push
-#endif // > gcc 4.6
-#pragma GCC diagnostic ignored "-Wsign-conversion"
-#pragma GCC diagnostic ignored "-Wsign-compare"
-#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 5)
-//#pragma GCC diagnostic ignored "-Wdouble-promotion"
-#endif // > gcc 4.5
-//#pragma GCC diagnostic ignored "-Wconversion"
-//#pragma GCC diagnostic ignored "-Wfloat-equal"
-#endif // __GNUC__
-
-#ifdef _MSC_VER
-#pragma warning(push)
-// http://stackoverflow.com/questions/39479163 what's the difference between C4018 and C4389
-#pragma warning(disable : 4389) // 'operator' : signed/unsigned mismatch
-#pragma warning(disable : 4018) // 'expression' : signed/unsigned mismatch
-//#pragma warning(disable : 4805) // 'operation' : unsafe mix of type 'type' and type 'type' in operation
-#endif // _MSC_VER
-
-#endif // DOCTEST_CONFIG_NO_COMPARISON_WARNING_SUPPRESSION
-
-// clang-format off
-#ifndef DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING
-#define DOCTEST_COMPARISON_RETURN_TYPE bool
-#else // DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING
-#define DOCTEST_COMPARISON_RETURN_TYPE typename enable_if<can_use_op<L>::value || can_use_op<R>::value, bool>::type
- inline bool eq(const char* lhs, const char* rhs) { return String(lhs) == String(rhs); }
- inline bool ne(const char* lhs, const char* rhs) { return String(lhs) != String(rhs); }
- inline bool lt(const char* lhs, const char* rhs) { return String(lhs) < String(rhs); }
- inline bool gt(const char* lhs, const char* rhs) { return String(lhs) > String(rhs); }
- inline bool le(const char* lhs, const char* rhs) { return String(lhs) <= String(rhs); }
- inline bool ge(const char* lhs, const char* rhs) { return String(lhs) >= String(rhs); }
-#endif // DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING
-
- template <typename L, typename R> DOCTEST_COMPARISON_RETURN_TYPE eq(const DOCTEST_REF_WRAP(L) lhs, const DOCTEST_REF_WRAP(R) rhs) { return lhs == rhs; }
- template <typename L, typename R> DOCTEST_COMPARISON_RETURN_TYPE ne(const DOCTEST_REF_WRAP(L) lhs, const DOCTEST_REF_WRAP(R) rhs) { return lhs != rhs; }
- template <typename L, typename R> DOCTEST_COMPARISON_RETURN_TYPE lt(const DOCTEST_REF_WRAP(L) lhs, const DOCTEST_REF_WRAP(R) rhs) { return lhs < rhs; }
- template <typename L, typename R> DOCTEST_COMPARISON_RETURN_TYPE gt(const DOCTEST_REF_WRAP(L) lhs, const DOCTEST_REF_WRAP(R) rhs) { return lhs > rhs; }
- template <typename L, typename R> DOCTEST_COMPARISON_RETURN_TYPE le(const DOCTEST_REF_WRAP(L) lhs, const DOCTEST_REF_WRAP(R) rhs) { return lhs <= rhs; }
- template <typename L, typename R> DOCTEST_COMPARISON_RETURN_TYPE ge(const DOCTEST_REF_WRAP(L) lhs, const DOCTEST_REF_WRAP(R) rhs) { return lhs >= rhs; }
-// clang-format on
-
-#ifndef DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING
-#define DOCTEST_CMP_EQ(l, r) l == r
-#define DOCTEST_CMP_NE(l, r) l != r
-#define DOCTEST_CMP_GT(l, r) l > r
-#define DOCTEST_CMP_LT(l, r) l < r
-#define DOCTEST_CMP_GE(l, r) l >= r
-#define DOCTEST_CMP_LE(l, r) l <= r
-#else // DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING
-#define DOCTEST_CMP_EQ(l, r) eq(l, r)
-#define DOCTEST_CMP_NE(l, r) ne(l, r)
-#define DOCTEST_CMP_GT(l, r) gt(l, r)
-#define DOCTEST_CMP_LT(l, r) lt(l, r)
-#define DOCTEST_CMP_GE(l, r) ge(l, r)
-#define DOCTEST_CMP_LE(l, r) le(l, r)
-#endif // DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING
-
-#define DOCTEST_DO_BINARY_EXPRESSION_COMPARISON(op, op_str, op_macro) \
- template <typename R> \
- DOCTEST_NOINLINE Result operator op(const DOCTEST_REF_WRAP(R) rhs) { \
- bool res = op_macro(lhs, rhs); \
- if(m_assert_type & assertType::is_false) \
- res = !res; \
- if(!res || doctest::detail::getTestsContextState()->success) \
- return Result(res, stringifyBinaryExpr(lhs, op_str, rhs)); \
- return Result(res); \
- }
-
-#define DOCTEST_FORBIT_EXPRESSION(op) \
- template <typename R> \
- Expression_lhs& operator op(const R&) { \
- DOCTEST_STATIC_ASSERT(deferred_false<R>::value, \
- Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison); \
- return *this; \
- }
-
- template <typename L>
- // cppcheck-suppress copyCtorAndEqOperator
- struct Expression_lhs
- {
- L lhs;
- assertType::Enum m_assert_type;
-
- explicit Expression_lhs(L in, assertType::Enum assert_type)
- : lhs(in)
- , m_assert_type(assert_type) {}
-
- Expression_lhs(const Expression_lhs& other)
- : lhs(other.lhs) {}
-
- DOCTEST_NOINLINE operator Result() {
- bool res = !!lhs;
- if(m_assert_type & assertType::is_false) //!OCLINT bitwise operator in conditional
- res = !res;
-
- if(!res || getTestsContextState()->success)
- return Result(res, toString(lhs));
- return Result(res);
- }
-
- // clang-format off
- DOCTEST_DO_BINARY_EXPRESSION_COMPARISON(==, " == ", DOCTEST_CMP_EQ) //!OCLINT bitwise operator in conditional
- DOCTEST_DO_BINARY_EXPRESSION_COMPARISON(!=, " != ", DOCTEST_CMP_NE) //!OCLINT bitwise operator in conditional
- DOCTEST_DO_BINARY_EXPRESSION_COMPARISON(>, " > ", DOCTEST_CMP_GT) //!OCLINT bitwise operator in conditional
- DOCTEST_DO_BINARY_EXPRESSION_COMPARISON(<, " < ", DOCTEST_CMP_LT) //!OCLINT bitwise operator in conditional
- DOCTEST_DO_BINARY_EXPRESSION_COMPARISON(>=, " >= ", DOCTEST_CMP_GE) //!OCLINT bitwise operator in conditional
- DOCTEST_DO_BINARY_EXPRESSION_COMPARISON(<=, " <= ", DOCTEST_CMP_LE) //!OCLINT bitwise operator in conditional
- // clang-format on
-
- // forbidding some expressions based on this table: http://en.cppreference.com/w/cpp/language/operator_precedence
- DOCTEST_FORBIT_EXPRESSION(&)
- DOCTEST_FORBIT_EXPRESSION (^)
- DOCTEST_FORBIT_EXPRESSION(|)
- DOCTEST_FORBIT_EXPRESSION(&&)
- DOCTEST_FORBIT_EXPRESSION(||)
- DOCTEST_FORBIT_EXPRESSION(=)
- DOCTEST_FORBIT_EXPRESSION(+=)
- DOCTEST_FORBIT_EXPRESSION(-=)
- DOCTEST_FORBIT_EXPRESSION(*=)
- DOCTEST_FORBIT_EXPRESSION(/=)
- DOCTEST_FORBIT_EXPRESSION(%=)
- DOCTEST_FORBIT_EXPRESSION(<<=)
- DOCTEST_FORBIT_EXPRESSION(>>=)
- DOCTEST_FORBIT_EXPRESSION(&=)
- DOCTEST_FORBIT_EXPRESSION(^=)
- DOCTEST_FORBIT_EXPRESSION(|=)
- // these 2 are unfortunate because they should be allowed - they have higher precedence over the comparisons, but the
- // ExpressionDecomposer class uses the left shift operator to capture the left operand of the binary expression...
- DOCTEST_FORBIT_EXPRESSION(<<)
- DOCTEST_FORBIT_EXPRESSION(>>)
- };
-
-#ifndef DOCTEST_CONFIG_NO_COMPARISON_WARNING_SUPPRESSION
-
-#if defined(__clang__)
-#pragma clang diagnostic pop
-#endif // __clang__
-
-#if defined(__GNUC__) && !defined(__clang__)
-#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 6)
-#pragma GCC diagnostic pop
-#endif // > gcc 4.6
-#endif // __GNUC__
-
-#ifdef _MSC_VER
-#pragma warning(pop)
-#endif // _MSC_VER
-
-#endif // DOCTEST_CONFIG_NO_COMPARISON_WARNING_SUPPRESSION
-
- struct ExpressionDecomposer
- {
- assertType::Enum m_assert_type;
-
- ExpressionDecomposer(assertType::Enum assert_type)
- : m_assert_type(assert_type) {}
-
- // The right operator for capturing expressions is "<=" instead of "<<" (based on the operator precedence table)
- // but then there will be warnings from GCC about "-Wparentheses" and since "_Pragma()" is problematic this will stay for now...
- // https://github.com/philsquared/Catch/issues/870
- // https://github.com/philsquared/Catch/issues/565
- template <typename L>
- Expression_lhs<const DOCTEST_REF_WRAP(L)> operator<<(const DOCTEST_REF_WRAP(L) operand) {
- return Expression_lhs<const DOCTEST_REF_WRAP(L)>(operand, m_assert_type);
- }
- };
-
- struct DOCTEST_INTERFACE TestCase
- {
- // not used for determining uniqueness
- funcType m_test; // a function pointer to the test case
- String m_full_name; // contains the name (only for templated test cases!) + the template type
- const char* m_name; // name of the test case
- const char* m_type; // for templated test cases - gets appended to the real name
- const char* m_test_suite; // the test suite in which the test was added
- const char* m_description;
- bool m_skip;
- bool m_may_fail;
- bool m_should_fail;
- int m_expected_failures;
- double m_timeout;
-
- // fields by which uniqueness of test cases shall be determined
- const char* m_file; // the file in which the test was registered
- unsigned m_line; // the line where the test was registered
- int m_template_id; // an ID used to distinguish between the different versions of a templated test case
-
- TestCase(funcType test, const char* file, unsigned line, const TestSuite& test_suite,
- const char* type = "", int template_id = -1);
-
- // for gcc 4.7
- DOCTEST_NOINLINE ~TestCase() {}
-
- TestCase& operator*(const char* in);
-
- template <typename T>
- TestCase& operator*(const T& in) {
- in.fill(*this);
- return *this;
- }
-
- TestCase(const TestCase& other) { *this = other; }
-
- TestCase& operator=(const TestCase& other);
-
- bool operator<(const TestCase& other) const;
- };
-
- // forward declarations of functions used by the macros
- DOCTEST_INTERFACE int regTest(const TestCase& tc);
- DOCTEST_INTERFACE int setTestSuite(const TestSuite& ts);
-
- DOCTEST_INTERFACE void addFailedAssert(assertType::Enum assert_type);
-
- DOCTEST_INTERFACE void logTestStart(const TestCase& tc);
- DOCTEST_INTERFACE void logTestEnd();
-
- DOCTEST_INTERFACE void logTestException(const String& what, bool crash = false);
-
- DOCTEST_INTERFACE void logAssert(bool passed, const char* decomposition, bool threw,
- const String& exception, const char* expr,
- assertType::Enum assert_type, const char* file, int line);
-
- DOCTEST_INTERFACE void logAssertThrows(bool threw, const char* expr,
- assertType::Enum assert_type, const char* file,
- int line);
-
- DOCTEST_INTERFACE void logAssertThrowsAs(bool threw, bool threw_as, const char* as,
- const String& exception, const char* expr,
- assertType::Enum assert_type, const char* file,
- int line);
-
- DOCTEST_INTERFACE void logAssertNothrow(bool threw, const String& exception, const char* expr,
- assertType::Enum assert_type, const char* file,
- int line);
-
- DOCTEST_INTERFACE bool isDebuggerActive();
- DOCTEST_INTERFACE void writeToDebugConsole(const String&);
-
- namespace binaryAssertComparison
- {
- enum Enum
- {
- eq = 0,
- ne,
- gt,
- lt,
- ge,
- le
- };
- } // namespace binaryAssertComparison
-
- // clang-format off
- template <int, class L, class R> struct RelationalComparator { bool operator()(const DOCTEST_REF_WRAP(L), const DOCTEST_REF_WRAP(R) ) const { return false; } };
- template <class L, class R> struct RelationalComparator<0, L, R> { bool operator()(const DOCTEST_REF_WRAP(L) lhs, const DOCTEST_REF_WRAP(R) rhs) const { return eq(lhs, rhs); } };
- template <class L, class R> struct RelationalComparator<1, L, R> { bool operator()(const DOCTEST_REF_WRAP(L) lhs, const DOCTEST_REF_WRAP(R) rhs) const { return ne(lhs, rhs); } };
- template <class L, class R> struct RelationalComparator<2, L, R> { bool operator()(const DOCTEST_REF_WRAP(L) lhs, const DOCTEST_REF_WRAP(R) rhs) const { return gt(lhs, rhs); } };
- template <class L, class R> struct RelationalComparator<3, L, R> { bool operator()(const DOCTEST_REF_WRAP(L) lhs, const DOCTEST_REF_WRAP(R) rhs) const { return lt(lhs, rhs); } };
- template <class L, class R> struct RelationalComparator<4, L, R> { bool operator()(const DOCTEST_REF_WRAP(L) lhs, const DOCTEST_REF_WRAP(R) rhs) const { return ge(lhs, rhs); } };
- template <class L, class R> struct RelationalComparator<5, L, R> { bool operator()(const DOCTEST_REF_WRAP(L) lhs, const DOCTEST_REF_WRAP(R) rhs) const { return le(lhs, rhs); } };
- // clang-format on
-
- struct DOCTEST_INTERFACE ResultBuilder
- {
- assertType::Enum m_assert_type;
- const char* m_file;
- int m_line;
- const char* m_expr;
- const char* m_exception_type;
-
- Result m_result;
- bool m_threw;
- bool m_threw_as;
- bool m_failed;
- String m_exception;
-
- ResultBuilder(assertType::Enum assert_type, const char* file, int line, const char* expr,
- const char* exception_type = "");
-
- ~ResultBuilder();
-
- void setResult(const Result& res) { m_result = res; }
-
- template <int comparison, typename L, typename R>
- DOCTEST_NOINLINE void binary_assert(const DOCTEST_REF_WRAP(L) lhs,
- const DOCTEST_REF_WRAP(R) rhs) {
- m_result.m_passed = RelationalComparator<comparison, L, R>()(lhs, rhs);
- if(!m_result.m_passed || getTestsContextState()->success)
- m_result.m_decomposition = stringifyBinaryExpr(lhs, ", ", rhs);
- }
-
- template <typename L>
- DOCTEST_NOINLINE void unary_assert(const DOCTEST_REF_WRAP(L) val) {
- m_result.m_passed = !!val;
-
- if(m_assert_type & assertType::is_false) //!OCLINT bitwise operator in conditional
- m_result.m_passed = !m_result.m_passed;
-
- if(!m_result.m_passed || getTestsContextState()->success)
- m_result.m_decomposition = toString(val);
- }
-
- void unexpectedExceptionOccurred();
-
- bool log();
- void react() const;
- };
-
- namespace assertAction
- {
- enum Enum
- {
- nothing = 0,
- dbgbreak = 1,
- shouldthrow = 2
- };
- } // namespace assertAction
-
- template <int comparison, typename L, typename R>
- DOCTEST_NOINLINE int fast_binary_assert(assertType::Enum assert_type, const char* file,
- int line, const char* expr,
- const DOCTEST_REF_WRAP(L) lhs,
- const DOCTEST_REF_WRAP(R) rhs) {
- ResultBuilder rb(assert_type, file, line, expr);
-
- rb.m_result.m_passed = RelationalComparator<comparison, L, R>()(lhs, rhs);
-
- if(!rb.m_result.m_passed || getTestsContextState()->success)
- rb.m_result.m_decomposition = stringifyBinaryExpr(lhs, ", ", rhs);
-
- int res = 0;
-
- if(rb.log())
- res |= assertAction::dbgbreak;
-
- if(rb.m_failed && checkIfShouldThrow(assert_type))
- res |= assertAction::shouldthrow;
-
-#ifdef DOCTEST_CONFIG_SUPER_FAST_ASSERTS
- // #########################################################################################
- // IF THE DEBUGGER BREAKS HERE - GO 1 LEVEL UP IN THE CALLSTACK TO SEE THE FAILING ASSERTION
- // THIS IS THE EFFECT OF HAVING 'DOCTEST_CONFIG_SUPER_FAST_ASSERTS' DEFINED
- // #########################################################################################
- if(res & assertAction::dbgbreak)
- DOCTEST_BREAK_INTO_DEBUGGER();
- fastAssertThrowIfFlagSet(res);
-#endif // DOCTEST_CONFIG_SUPER_FAST_ASSERTS
-
- return res;
- }
-
- template <typename L>
- DOCTEST_NOINLINE int fast_unary_assert(assertType::Enum assert_type, const char* file, int line,
- const char* val_str, const DOCTEST_REF_WRAP(L) val) {
- ResultBuilder rb(assert_type, file, line, val_str);
-
- rb.m_result.m_passed = !!val;
-
- if(assert_type & assertType::is_false) //!OCLINT bitwise operator in conditional
- rb.m_result.m_passed = !rb.m_result.m_passed;
-
- if(!rb.m_result.m_passed || getTestsContextState()->success)
- rb.m_result.m_decomposition = toString(val);
-
- int res = 0;
-
- if(rb.log())
- res |= assertAction::dbgbreak;
-
- if(rb.m_failed && checkIfShouldThrow(assert_type))
- res |= assertAction::shouldthrow;
-
-#ifdef DOCTEST_CONFIG_SUPER_FAST_ASSERTS
- // #########################################################################################
- // IF THE DEBUGGER BREAKS HERE - GO 1 LEVEL UP IN THE CALLSTACK TO SEE THE FAILING ASSERTION
- // THIS IS THE EFFECT OF HAVING 'DOCTEST_CONFIG_SUPER_FAST_ASSERTS' DEFINED
- // #########################################################################################
- if(res & assertAction::dbgbreak)
- DOCTEST_BREAK_INTO_DEBUGGER();
- fastAssertThrowIfFlagSet(res);
-#endif // DOCTEST_CONFIG_SUPER_FAST_ASSERTS
-
- return res;
- }
-
- struct DOCTEST_INTERFACE IExceptionTranslator
- {
- virtual ~IExceptionTranslator() {}
- virtual bool translate(String&) const = 0;
- };
-
- template <typename T>
- class ExceptionTranslator : public IExceptionTranslator //!OCLINT destructor of virtual class
- {
- public:
- explicit ExceptionTranslator(String (*translateFunction)(T))
- : m_translateFunction(translateFunction) {}
-
- bool translate(String& res) const {
-#ifndef DOCTEST_CONFIG_NO_EXCEPTIONS
- try {
- throw;
- // cppcheck-suppress catchExceptionByValue
- } catch(T ex) { // NOLINT
- res = m_translateFunction(ex); //!OCLINT parameter reassignment
- return true;
- } catch(...) {} //!OCLINT - empty catch statement
-#endif // DOCTEST_CONFIG_NO_EXCEPTIONS
- ((void)res); // to silence -Wunused-parameter
- return false;
- }
-
- protected:
- String (*m_translateFunction)(T);
- };
-
- DOCTEST_INTERFACE void registerExceptionTranslatorImpl(
- const IExceptionTranslator* translateFunction);
-
- // FIX FOR VISUAL STUDIO VERSIONS PRIOR TO 2015 - they failed to compile the call to operator<< with
- // std::ostream passed as a reference noting that there is a use of an undefined type (which there isn't)
- DOCTEST_INTERFACE void writeStringToStream(std::ostream* stream, const String& str);
-
- template <bool C>
- struct StringStreamBase
- {
- template <typename T>
- static void convert(std::ostream* stream, const T& in) {
- writeStringToStream(stream, toString(in));
- }
-
- // always treat char* as a string in this context - no matter
- // if DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING is defined
- static void convert(std::ostream* stream, const char* in) {
- writeStringToStream(stream, String(in));
- }
- };
-
- template <>
- struct StringStreamBase<true>
- {
- template <typename T>
- static void convert(std::ostream* stream, const T& in) {
- *stream << in;
- }
- };
-
- template <typename T>
- struct StringStream : StringStreamBase<has_insertion_operator<T>::value>
- {};
-
- template <typename T>
- void toStream(std::ostream* stream, const T& value) {
- StringStream<T>::convert(stream, value);
- }
-
-#ifdef DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING
- DOCTEST_INTERFACE void toStream(std::ostream* stream, char* in);
- DOCTEST_INTERFACE void toStream(std::ostream* stream, const char* in);
-#endif // DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING
- DOCTEST_INTERFACE void toStream(std::ostream* stream, bool in);
- DOCTEST_INTERFACE void toStream(std::ostream* stream, float in);
- DOCTEST_INTERFACE void toStream(std::ostream* stream, double in);
- DOCTEST_INTERFACE void toStream(std::ostream* stream, double long in);
-
- DOCTEST_INTERFACE void toStream(std::ostream* stream, char in);
- DOCTEST_INTERFACE void toStream(std::ostream* stream, char signed in);
- DOCTEST_INTERFACE void toStream(std::ostream* stream, char unsigned in);
- DOCTEST_INTERFACE void toStream(std::ostream* stream, int short in);
- DOCTEST_INTERFACE void toStream(std::ostream* stream, int short unsigned in);
- DOCTEST_INTERFACE void toStream(std::ostream* stream, int in);
- DOCTEST_INTERFACE void toStream(std::ostream* stream, int unsigned in);
- DOCTEST_INTERFACE void toStream(std::ostream* stream, int long in);
- DOCTEST_INTERFACE void toStream(std::ostream* stream, int long unsigned in);
-
-#ifdef DOCTEST_CONFIG_WITH_LONG_LONG
- DOCTEST_INTERFACE void toStream(std::ostream* stream, int long long in);
- DOCTEST_INTERFACE void toStream(std::ostream* stream, int long long unsigned in);
-#endif // DOCTEST_CONFIG_WITH_LONG_LONG
-
- struct IContextScope
- {
- virtual ~IContextScope() {}
- virtual void build(std::ostream*) = 0;
- };
-
- DOCTEST_INTERFACE void addToContexts(IContextScope* ptr);
- DOCTEST_INTERFACE void popFromContexts();
- DOCTEST_INTERFACE void useContextIfExceptionOccurred(IContextScope* ptr);
-
- // cppcheck-suppress copyCtorAndEqOperator
- class ContextBuilder
- {
- friend class ContextScope;
-
- struct ICapture
- {
- virtual ~ICapture() {}
- virtual void toStream(std::ostream*) const = 0;
- };
-
- template <typename T>
- struct Capture : ICapture //!OCLINT destructor of virtual class
- {
- const T* capture;
-
- explicit Capture(const T* in)
- : capture(in) {}
- virtual void toStream(std::ostream* stream) const { // override
- detail::toStream(stream, *capture);
- }
- };
-
- struct Chunk
- {
- char buf[sizeof(Capture<char>)]; // place to construct a Capture<T>
- };
-
- struct Node
- {
- Chunk chunk;
- Node* next;
- };
-
- Chunk stackChunks[DOCTEST_CONFIG_NUM_CAPTURES_ON_STACK];
- int numCaptures;
- Node* head;
- Node* tail;
-
- void build(std::ostream* stream) const {
- int curr = 0;
- // iterate over small buffer
- while(curr < numCaptures && curr < DOCTEST_CONFIG_NUM_CAPTURES_ON_STACK)
- reinterpret_cast<const ICapture*>(stackChunks[curr++].buf)->toStream(stream);
- // iterate over list
- Node* curr_elem = head;
- while(curr < numCaptures) {
- reinterpret_cast<const ICapture*>(curr_elem->chunk.buf)->toStream(stream);
- curr_elem = curr_elem->next;
- ++curr;
- }
- }
-
- // steal the contents of the other - acting as a move constructor...
- DOCTEST_NOINLINE ContextBuilder(ContextBuilder& other)
- : numCaptures(other.numCaptures)
- , head(other.head)
- , tail(other.tail) {
- other.numCaptures = 0;
- other.head = 0;
- other.tail = 0;
- my_memcpy(stackChunks, other.stackChunks,
- unsigned(int(sizeof(Chunk)) * DOCTEST_CONFIG_NUM_CAPTURES_ON_STACK));
- }
-
- ContextBuilder& operator=(const ContextBuilder&); // NOLINT
-
- public:
- // cppcheck-suppress uninitMemberVar
- DOCTEST_NOINLINE ContextBuilder() // NOLINT
- : numCaptures(0)
- , head(0)
- , tail(0) {}
-
- template <typename T>
- DOCTEST_NOINLINE ContextBuilder& operator<<(T& in) {
- Capture<T> temp(&in);
-
- // construct either on stack or on heap
- // copy the bytes for the whole object - including the vtable because we cant construct
- // the object directly in the buffer using placement new - need the <new> header...
- if(numCaptures < DOCTEST_CONFIG_NUM_CAPTURES_ON_STACK) {
- my_memcpy(stackChunks[numCaptures].buf, &temp, sizeof(Chunk));
- } else {
- Node* curr = new Node;
- curr->next = 0;
- if(tail) {
- tail->next = curr;
- tail = curr;
- } else {
- head = tail = curr;
- }
-
- my_memcpy(tail->chunk.buf, &temp, sizeof(Chunk));
- }
- ++numCaptures;
- return *this;
- }
-
- DOCTEST_NOINLINE ~ContextBuilder() {
- // free the linked list - the ones on the stack are left as-is
- // no destructors are called at all - there is no need
- while(head) {
- Node* next = head->next;
- delete head;
- head = next;
- }
- }
-
-#ifdef DOCTEST_CONFIG_WITH_RVALUE_REFERENCES
- template <typename T>
- ContextBuilder& operator<<(const T&&) {
- DOCTEST_STATIC_ASSERT(
- deferred_false<T>::value,
- Cannot_pass_temporaries_or_rvalues_to_the_streaming_operator_because_it_caches_pointers_to_the_passed_objects_for_lazy_evaluation);
- return *this;
- }
-#endif // DOCTEST_CONFIG_WITH_RVALUE_REFERENCES
- };
-
- class ContextScope : public IContextScope
- {
- ContextBuilder contextBuilder;
- bool built;
-
- public:
- DOCTEST_NOINLINE explicit ContextScope(ContextBuilder& temp)
- : contextBuilder(temp)
- , built(false) {
- addToContexts(this);
- }
-
- DOCTEST_NOINLINE ~ContextScope() {
- if(!built)
- useContextIfExceptionOccurred(this);
- popFromContexts();
- }
-
- void build(std::ostream* stream) {
- built = true;
- contextBuilder.build(stream);
- }
- };
-
- class DOCTEST_INTERFACE MessageBuilder
- {
- std::ostream* m_stream;
- const char* m_file;
- int m_line;
- assertType::Enum m_severity;
-
- public:
- MessageBuilder(const char* file, int line, assertType::Enum severity);
- ~MessageBuilder();
-
- template <typename T>
- MessageBuilder& operator<<(const T& in) {
- toStream(m_stream, in);
- return *this;
- }
-
- bool log();
- void react();
- };
-} // namespace detail
-
-struct test_suite
-{
- const char* data;
- test_suite(const char* in)
- : data(in) {}
- void fill(detail::TestCase& state) const { state.m_test_suite = data; }
- void fill(detail::TestSuite& state) const { state.m_test_suite = data; }
-};
-
-struct description
-{
- const char* data;
- description(const char* in)
- : data(in) {}
- void fill(detail::TestCase& state) const { state.m_description = data; }
- void fill(detail::TestSuite& state) const { state.m_description = data; }
-};
-
-struct skip
-{
- bool data;
- skip(bool in = true)
- : data(in) {}
- void fill(detail::TestCase& state) const { state.m_skip = data; }
- void fill(detail::TestSuite& state) const { state.m_skip = data; }
-};
-
-struct timeout
-{
- double data;
- timeout(double in)
- : data(in) {}
- void fill(detail::TestCase& state) const { state.m_timeout = data; }
- void fill(detail::TestSuite& state) const { state.m_timeout = data; }
-};
-
-struct may_fail
-{
- bool data;
- may_fail(bool in = true)
- : data(in) {}
- void fill(detail::TestCase& state) const { state.m_may_fail = data; }
- void fill(detail::TestSuite& state) const { state.m_may_fail = data; }
-};
-
-struct should_fail
-{
- bool data;
- should_fail(bool in = true)
- : data(in) {}
- void fill(detail::TestCase& state) const { state.m_should_fail = data; }
- void fill(detail::TestSuite& state) const { state.m_should_fail = data; }
-};
-
-struct expected_failures
-{
- int data;
- expected_failures(int in)
- : data(in) {}
- void fill(detail::TestCase& state) const { state.m_expected_failures = data; }
- void fill(detail::TestSuite& state) const { state.m_expected_failures = data; }
-};
-
-#endif // DOCTEST_CONFIG_DISABLE
-
-#ifndef DOCTEST_CONFIG_DISABLE
-template <typename T>
-int registerExceptionTranslator(String (*translateFunction)(T)) {
-#if defined(__clang__)
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wexit-time-destructors"
-#endif // __clang__
- static detail::ExceptionTranslator<T> exceptionTranslator(translateFunction);
-#if defined(__clang__)
-#pragma clang diagnostic pop
-#endif // __clang__
- detail::registerExceptionTranslatorImpl(&exceptionTranslator);
- return 0;
-}
-
-#else // DOCTEST_CONFIG_DISABLE
-template <typename T>
-int registerExceptionTranslator(String (*)(T)) {
- return 0;
-}
-#endif // DOCTEST_CONFIG_DISABLE
-
-DOCTEST_INTERFACE bool isRunningInTest();
-
-// cppcheck-suppress noCopyConstructor
-class DOCTEST_INTERFACE Context
-{
-#if !defined(DOCTEST_CONFIG_DISABLE)
- detail::ContextState* p;
-
- void parseArgs(int argc, const char* const* argv, bool withDefaults = false);
-
-#endif // DOCTEST_CONFIG_DISABLE
-
-public:
- explicit Context(int argc = 0, const char* const* argv = 0);
-
- ~Context();
-
- void applyCommandLine(int argc, const char* const* argv);
-
- void addFilter(const char* filter, const char* value);
- void clearFilters();
- void setOption(const char* option, int value);
- void setOption(const char* option, const char* value);
-
- bool shouldExit();
-
- int run();
-};
-
-} // namespace doctest
-
-// if registering is not disabled
-#if !defined(DOCTEST_CONFIG_DISABLE)
-
-#ifdef DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-#define DOCTEST_EXPAND_VA_ARGS(...) __VA_ARGS__
-#else // DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-#define DOCTEST_EXPAND_VA_ARGS
-#endif // DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-
-#define DOCTEST_STRIP_PARENS(x) x
-#define DOCTEST_HANDLE_BRACED_VA_ARGS(expr) DOCTEST_STRIP_PARENS(DOCTEST_EXPAND_VA_ARGS expr)
-
-// registers the test by initializing a dummy var with a function
-#define DOCTEST_REGISTER_FUNCTION(f, decorators) \
- DOCTEST_GLOBAL_NO_WARNINGS(DOCTEST_ANONYMOUS(_DOCTEST_ANON_VAR_)) = doctest::detail::regTest( \
- doctest::detail::TestCase(f, __FILE__, __LINE__, \
- doctest_detail_test_suite_ns::getCurrentTestSuite()) * \
- decorators); \
- DOCTEST_GLOBAL_NO_WARNINGS_END()
-
-#define DOCTEST_IMPLEMENT_FIXTURE(der, base, func, decorators) \
- namespace \
- { \
- struct der : base \
- { void f(); }; \
- static void func() { \
- der v; \
- v.f(); \
- } \
- DOCTEST_REGISTER_FUNCTION(func, decorators) \
- } \
- inline DOCTEST_NOINLINE void der::f()
-
-#define DOCTEST_CREATE_AND_REGISTER_FUNCTION(f, decorators) \
- static void f(); \
- DOCTEST_REGISTER_FUNCTION(f, decorators) \
- static void f()
-
-// for registering tests
-#define DOCTEST_TEST_CASE(decorators) \
- DOCTEST_CREATE_AND_REGISTER_FUNCTION(DOCTEST_ANONYMOUS(_DOCTEST_ANON_FUNC_), decorators)
-
-// for registering tests with a fixture
-#define DOCTEST_TEST_CASE_FIXTURE(c, decorators) \
- DOCTEST_IMPLEMENT_FIXTURE(DOCTEST_ANONYMOUS(_DOCTEST_ANON_CLASS_), c, \
- DOCTEST_ANONYMOUS(_DOCTEST_ANON_FUNC_), decorators)
-
-// for converting types to strings without the <typeinfo> header and demangling
-#ifdef DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-#define DOCTEST_TYPE_TO_STRING_IMPL(...) \
- template <> \
- inline const char* type_to_string<__VA_ARGS__>() { \
- return "<" #__VA_ARGS__ ">"; \
- }
-#define DOCTEST_TYPE_TO_STRING(...) \
- namespace doctest \
- { \
- namespace detail \
- { DOCTEST_TYPE_TO_STRING_IMPL(__VA_ARGS__) } \
- } \
- typedef int DOCTEST_ANONYMOUS(_DOCTEST_ANON_FOR_SEMICOLON_)
-#else // DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-#define DOCTEST_TYPE_TO_STRING_IMPL(x) \
- template <> \
- inline const char* type_to_string<x>() { \
- return "<" #x ">"; \
- }
-#define DOCTEST_TYPE_TO_STRING(x) \
- namespace doctest \
- { \
- namespace detail \
- { DOCTEST_TYPE_TO_STRING_IMPL(x) } \
- } \
- typedef int DOCTEST_ANONYMOUS(_DOCTEST_ANON_FOR_SEMICOLON_)
-#endif // DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-
-// for typed tests
-#define DOCTEST_TEST_CASE_TEMPLATE_IMPL(decorators, T, types, anon) \
- template <typename T> \
- inline void anon(); \
- struct DOCTEST_CAT(anon, FUNCTOR) \
- { \
- template <int Index, typename Type> \
- void operator()() { \
- doctest::detail::regTest( \
- doctest::detail::TestCase(anon<Type>, __FILE__, __LINE__, \
- doctest_detail_test_suite_ns::getCurrentTestSuite(), \
- doctest::detail::type_to_string<Type>(), Index) * \
- decorators); \
- } \
- }; \
- inline int DOCTEST_CAT(anon, REG_FUNC)() { \
- DOCTEST_CAT(anon, FUNCTOR) registrar; \
- doctest::detail::ForEachType<DOCTEST_HANDLE_BRACED_VA_ARGS(types)::Result, \
- DOCTEST_CAT(anon, FUNCTOR)> \
- doIt(registrar); \
- return 0; \
- } \
- DOCTEST_GLOBAL_NO_WARNINGS(DOCTEST_CAT(anon, DUMMY)) = DOCTEST_CAT(anon, REG_FUNC)(); \
- DOCTEST_GLOBAL_NO_WARNINGS_END() \
- template <typename T> \
- inline void anon()
-
-#ifdef DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-#define DOCTEST_TEST_CASE_TEMPLATE(decorators, T, ...) \
- DOCTEST_TEST_CASE_TEMPLATE_IMPL(decorators, T, (__VA_ARGS__), \
- DOCTEST_ANONYMOUS(_DOCTEST_ANON_TMP_))
-#else // DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-#define DOCTEST_TEST_CASE_TEMPLATE(decorators, T, types) \
- DOCTEST_TEST_CASE_TEMPLATE_IMPL(decorators, T, types, DOCTEST_ANONYMOUS(_DOCTEST_ANON_TMP_))
-#endif // DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-
-#define DOCTEST_TEST_CASE_TEMPLATE_DEFINE_IMPL(decorators, T, id, anon) \
- template <typename T> \
- inline void anon(); \
- struct DOCTEST_CAT(id, _FUNCTOR) \
- { \
- int m_line; \
- DOCTEST_CAT(id, _FUNCTOR) \
- (int line) \
- : m_line(line) {} \
- template <int Index, typename Type> \
- void operator()() { \
- doctest::detail::regTest( \
- doctest::detail::TestCase(anon<Type>, __FILE__, __LINE__, \
- doctest_detail_test_suite_ns::getCurrentTestSuite(), \
- doctest::detail::type_to_string<Type>(), \
- m_line * 1000 + Index) * \
- decorators); \
- } \
- }; \
- template <typename T> \
- inline void anon()
-
-#define DOCTEST_TEST_CASE_TEMPLATE_DEFINE(decorators, T, id) \
- DOCTEST_TEST_CASE_TEMPLATE_DEFINE_IMPL(decorators, T, id, DOCTEST_ANONYMOUS(_DOCTEST_ANON_TMP_))
-
-#define DOCTEST_TEST_CASE_TEMPLATE_INSTANTIATE_IMPL(id, types, anon) \
- static int DOCTEST_CAT(anon, REG_FUNC)() { \
- DOCTEST_CAT(id, _FUNCTOR) registrar(__LINE__); \
- doctest::detail::ForEachType<DOCTEST_HANDLE_BRACED_VA_ARGS(types)::Result, \
- DOCTEST_CAT(id, _FUNCTOR)> \
- doIt(registrar); \
- return 0; \
- } \
- DOCTEST_GLOBAL_NO_WARNINGS(DOCTEST_CAT(anon, DUMMY)) = DOCTEST_CAT(anon, REG_FUNC)(); \
- DOCTEST_GLOBAL_NO_WARNINGS_END() typedef int DOCTEST_ANONYMOUS(_DOCTEST_ANON_FOR_SEMICOLON_)
-
-#ifdef DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-#define DOCTEST_TEST_CASE_TEMPLATE_INSTANTIATE(id, ...) \
- DOCTEST_TEST_CASE_TEMPLATE_INSTANTIATE_IMPL(id, (__VA_ARGS__), \
- DOCTEST_ANONYMOUS(_DOCTEST_ANON_TMP_))
-#else // DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-#define DOCTEST_TEST_CASE_TEMPLATE_INSTANTIATE(id, types) \
- DOCTEST_TEST_CASE_TEMPLATE_INSTANTIATE_IMPL(id, types, DOCTEST_ANONYMOUS(_DOCTEST_ANON_TMP_))
-#endif // DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-
-// for subcases
-#if defined(__GNUC__)
-#define DOCTEST_SUBCASE(name) \
- if(const doctest::detail::Subcase & DOCTEST_ANONYMOUS(_DOCTEST_ANON_SUBCASE_) \
- __attribute__((unused)) = \
- doctest::detail::Subcase(name, __FILE__, __LINE__))
-#else // __GNUC__
-#define DOCTEST_SUBCASE(name) \
- if(const doctest::detail::Subcase & DOCTEST_ANONYMOUS(_DOCTEST_ANON_SUBCASE_) = \
- doctest::detail::Subcase(name, __FILE__, __LINE__))
-#endif // __GNUC__
-
-// for grouping tests in test suites by using code blocks
-#define DOCTEST_TEST_SUITE_IMPL(decorators, ns_name) \
- namespace ns_name \
- { \
- namespace doctest_detail_test_suite_ns \
- { \
- inline DOCTEST_NOINLINE doctest::detail::TestSuite& getCurrentTestSuite() { \
- static doctest::detail::TestSuite data; \
- static bool inited = false; \
- if(!inited) { \
- data* decorators; \
- inited = true; \
- } \
- return data; \
- } \
- } \
- } \
- namespace ns_name
-
-#define DOCTEST_TEST_SUITE(decorators) \
- DOCTEST_TEST_SUITE_IMPL(decorators, DOCTEST_ANONYMOUS(_DOCTEST_ANON_SUITE_))
-
-// for starting a testsuite block
-#define DOCTEST_TEST_SUITE_BEGIN(decorators) \
- DOCTEST_GLOBAL_NO_WARNINGS(DOCTEST_ANONYMOUS(_DOCTEST_ANON_VAR_)) = \
- doctest::detail::setTestSuite(doctest::detail::TestSuite() * decorators); \
- DOCTEST_GLOBAL_NO_WARNINGS_END() \
- typedef int DOCTEST_ANONYMOUS(_DOCTEST_ANON_FOR_SEMICOLON_)
-
-// for ending a testsuite block
-#define DOCTEST_TEST_SUITE_END \
- DOCTEST_GLOBAL_NO_WARNINGS(DOCTEST_ANONYMOUS(_DOCTEST_ANON_VAR_)) = \
- doctest::detail::setTestSuite(doctest::detail::TestSuite() * ""); \
- DOCTEST_GLOBAL_NO_WARNINGS_END() \
- typedef int DOCTEST_ANONYMOUS(_DOCTEST_ANON_FOR_SEMICOLON_)
-
-// for registering exception translators
-#define DOCTEST_REGISTER_EXCEPTION_TRANSLATOR_IMPL(translatorName, signature) \
- static doctest::String translatorName(signature); \
- DOCTEST_GLOBAL_NO_WARNINGS(DOCTEST_ANONYMOUS(_DOCTEST_ANON_TRANSLATOR_)) = \
- doctest::registerExceptionTranslator(translatorName); \
- DOCTEST_GLOBAL_NO_WARNINGS_END() \
- static doctest::String translatorName(signature)
-
-#define DOCTEST_REGISTER_EXCEPTION_TRANSLATOR(signature) \
- DOCTEST_REGISTER_EXCEPTION_TRANSLATOR_IMPL(DOCTEST_ANONYMOUS(_DOCTEST_ANON_TRANSLATOR_), \
- signature)
-
-// for logging
-#define DOCTEST_INFO(x) \
- doctest::detail::ContextScope DOCTEST_ANONYMOUS(_DOCTEST_CAPTURE_)( \
- doctest::detail::ContextBuilder() << x)
-#define DOCTEST_CAPTURE(x) DOCTEST_INFO(#x " := " << x)
-
-#define DOCTEST_ADD_AT_IMPL(type, file, line, mb, x) \
- do { \
- doctest::detail::MessageBuilder mb(file, line, doctest::detail::assertType::type); \
- mb << x; \
- if(mb.log()) \
- DOCTEST_BREAK_INTO_DEBUGGER(); \
- mb.react(); \
- } while((void)0, 0)
-
-// clang-format off
-#define DOCTEST_ADD_MESSAGE_AT(file, line, x) DOCTEST_ADD_AT_IMPL(is_warn, file, line, DOCTEST_ANONYMOUS(_DOCTEST_MESSAGE_), x)
-#define DOCTEST_ADD_FAIL_CHECK_AT(file, line, x) DOCTEST_ADD_AT_IMPL(is_check, file, line, DOCTEST_ANONYMOUS(_DOCTEST_MESSAGE_), x)
-#define DOCTEST_ADD_FAIL_AT(file, line, x) DOCTEST_ADD_AT_IMPL(is_require, file, line, DOCTEST_ANONYMOUS(_DOCTEST_MESSAGE_), x)
-// clang-format on
-
-#define DOCTEST_MESSAGE(x) DOCTEST_ADD_MESSAGE_AT(__FILE__, __LINE__, x)
-#define DOCTEST_FAIL_CHECK(x) DOCTEST_ADD_FAIL_CHECK_AT(__FILE__, __LINE__, x)
-#define DOCTEST_FAIL(x) DOCTEST_ADD_FAIL_AT(__FILE__, __LINE__, x)
-
-#if __cplusplus >= 201402L || (defined(_MSC_VER) && _MSC_VER >= 1910)
-template <class T, T x>
-constexpr T to_lvalue = x;
-#define DOCTEST_TO_LVALUE(...) to_lvalue<decltype(__VA_ARGS__), __VA_ARGS__>
-#else
-#ifdef DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-#define DOCTEST_TO_LVALUE(...) TO_LVALUE_CAN_BE_USED_ONLY_IN_CPP14_MODE_OR_WITH_VS_2017_OR_NEWER
-#else // DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-#define DOCTEST_TO_LVALUE(x) TO_LVALUE_CAN_BE_USED_ONLY_IN_CPP14_MODE_OR_WITH_VS_2017_OR_NEWER
-#endif // DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-#endif // TO_LVALUE hack for logging macros like INFO()
-
-// common code in asserts - for convenience
-#define DOCTEST_ASSERT_LOG_AND_REACT(rb) \
- if(rb.log()) \
- DOCTEST_BREAK_INTO_DEBUGGER(); \
- rb.react()
-
-#ifdef DOCTEST_CONFIG_NO_TRY_CATCH_IN_ASSERTS
-#define DOCTEST_WRAP_IN_TRY(x) x;
-#else // DOCTEST_CONFIG_NO_TRY_CATCH_IN_ASSERTS
-#define DOCTEST_WRAP_IN_TRY(x) \
- try { \
- x; \
- } catch(...) { _DOCTEST_RB.unexpectedExceptionOccurred(); }
-#endif // DOCTEST_CONFIG_NO_TRY_CATCH_IN_ASSERTS
-
-#define DOCTEST_ASSERT_IMPLEMENT_3(expr, assert_type) \
- doctest::detail::ResultBuilder _DOCTEST_RB( \
- doctest::detail::assertType::assert_type, __FILE__, __LINE__, \
- DOCTEST_TOSTR(DOCTEST_HANDLE_BRACED_VA_ARGS(expr))); \
- DOCTEST_WRAP_IN_TRY(_DOCTEST_RB.setResult( \
- doctest::detail::ExpressionDecomposer(doctest::detail::assertType::assert_type) \
- << DOCTEST_HANDLE_BRACED_VA_ARGS(expr))) \
- DOCTEST_ASSERT_LOG_AND_REACT(_DOCTEST_RB)
-
-#if defined(__clang__)
-#define DOCTEST_ASSERT_IMPLEMENT_2(expr, assert_type) \
- _Pragma("clang diagnostic push") \
- _Pragma("clang diagnostic ignored \"-Woverloaded-shift-op-parentheses\"") \
- DOCTEST_ASSERT_IMPLEMENT_3(expr, assert_type); \
- _Pragma("clang diagnostic pop")
-#else // __clang__
-#define DOCTEST_ASSERT_IMPLEMENT_2(expr, assert_type) DOCTEST_ASSERT_IMPLEMENT_3(expr, assert_type);
-#endif // __clang__
-
-#define DOCTEST_ASSERT_IMPLEMENT_1(expr, assert_type) \
- do { \
- DOCTEST_ASSERT_IMPLEMENT_2(expr, assert_type); \
- } while((void)0, 0)
-
-#ifdef DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-#define DOCTEST_WARN(...) DOCTEST_ASSERT_IMPLEMENT_1((__VA_ARGS__), DT_WARN)
-#define DOCTEST_CHECK(...) DOCTEST_ASSERT_IMPLEMENT_1((__VA_ARGS__), DT_CHECK)
-#define DOCTEST_REQUIRE(...) DOCTEST_ASSERT_IMPLEMENT_1((__VA_ARGS__), DT_REQUIRE)
-#define DOCTEST_WARN_FALSE(...) DOCTEST_ASSERT_IMPLEMENT_1((__VA_ARGS__), DT_WARN_FALSE)
-#define DOCTEST_CHECK_FALSE(...) DOCTEST_ASSERT_IMPLEMENT_1((__VA_ARGS__), DT_CHECK_FALSE)
-#define DOCTEST_REQUIRE_FALSE(...) DOCTEST_ASSERT_IMPLEMENT_1((__VA_ARGS__), DT_REQUIRE_FALSE)
-#else // DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-#define DOCTEST_WARN(expr) DOCTEST_ASSERT_IMPLEMENT_1(expr, DT_WARN)
-#define DOCTEST_CHECK(expr) DOCTEST_ASSERT_IMPLEMENT_1(expr, DT_CHECK)
-#define DOCTEST_REQUIRE(expr) DOCTEST_ASSERT_IMPLEMENT_1(expr, DT_REQUIRE)
-#define DOCTEST_WARN_FALSE(expr) DOCTEST_ASSERT_IMPLEMENT_1(expr, DT_WARN_FALSE)
-#define DOCTEST_CHECK_FALSE(expr) DOCTEST_ASSERT_IMPLEMENT_1(expr, DT_CHECK_FALSE)
-#define DOCTEST_REQUIRE_FALSE(expr) DOCTEST_ASSERT_IMPLEMENT_1(expr, DT_REQUIRE_FALSE)
-#endif // DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-
-// clang-format off
-#ifdef DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-#define DOCTEST_WARN_MESSAGE(cond, msg) do { DOCTEST_INFO(msg); DOCTEST_ASSERT_IMPLEMENT_2((cond), DT_WARN); } while((void)0, 0)
-#define DOCTEST_CHECK_MESSAGE(cond, msg) do { DOCTEST_INFO(msg); DOCTEST_ASSERT_IMPLEMENT_2((cond), DT_CHECK); } while((void)0, 0)
-#define DOCTEST_REQUIRE_MESSAGE(cond, msg) do { DOCTEST_INFO(msg); DOCTEST_ASSERT_IMPLEMENT_2((cond), DT_REQUIRE); } while((void)0, 0)
-#define DOCTEST_WARN_FALSE_MESSAGE(cond, msg) do { DOCTEST_INFO(msg); DOCTEST_ASSERT_IMPLEMENT_2((cond), DT_WARN_FALSE); } while((void)0, 0)
-#define DOCTEST_CHECK_FALSE_MESSAGE(cond, msg) do { DOCTEST_INFO(msg); DOCTEST_ASSERT_IMPLEMENT_2((cond), DT_CHECK_FALSE); } while((void)0, 0)
-#define DOCTEST_REQUIRE_FALSE_MESSAGE(cond, msg) do { DOCTEST_INFO(msg); DOCTEST_ASSERT_IMPLEMENT_2((cond), DT_REQUIRE_FALSE); } while((void)0, 0)
-#else // DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-#define DOCTEST_WARN_MESSAGE(cond, msg) do { DOCTEST_INFO(msg); DOCTEST_ASSERT_IMPLEMENT_2(cond, DT_WARN); } while((void)0, 0)
-#define DOCTEST_CHECK_MESSAGE(cond, msg) do { DOCTEST_INFO(msg); DOCTEST_ASSERT_IMPLEMENT_2(cond, DT_CHECK); } while((void)0, 0)
-#define DOCTEST_REQUIRE_MESSAGE(cond, msg) do { DOCTEST_INFO(msg); DOCTEST_ASSERT_IMPLEMENT_2(cond, DT_REQUIRE); } while((void)0, 0)
-#define DOCTEST_WARN_FALSE_MESSAGE(cond, msg) do { DOCTEST_INFO(msg); DOCTEST_ASSERT_IMPLEMENT_2(cond, DT_WARN_FALSE); } while((void)0, 0)
-#define DOCTEST_CHECK_FALSE_MESSAGE(cond, msg) do { DOCTEST_INFO(msg); DOCTEST_ASSERT_IMPLEMENT_2(cond, DT_CHECK_FALSE); } while((void)0, 0)
-#define DOCTEST_REQUIRE_FALSE_MESSAGE(cond, msg) do { DOCTEST_INFO(msg); DOCTEST_ASSERT_IMPLEMENT_2(cond, DT_REQUIRE_FALSE); } while((void)0, 0)
-#endif // DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-// clang-format on
-
-#define DOCTEST_ASSERT_THROWS(expr, assert_type) \
- do { \
- if(!doctest::detail::getTestsContextState()->no_throw) { \
- doctest::detail::ResultBuilder _DOCTEST_RB(doctest::detail::assertType::assert_type, \
- __FILE__, __LINE__, #expr); \
- try { \
- expr; \
- } catch(...) { _DOCTEST_RB.m_threw = true; } \
- DOCTEST_ASSERT_LOG_AND_REACT(_DOCTEST_RB); \
- } \
- } while((void)0, 0)
-
-#define DOCTEST_ASSERT_THROWS_AS(expr, as, assert_type) \
- do { \
- if(!doctest::detail::getTestsContextState()->no_throw) { \
- doctest::detail::ResultBuilder _DOCTEST_RB( \
- doctest::detail::assertType::assert_type, __FILE__, __LINE__, #expr, \
- DOCTEST_TOSTR(DOCTEST_HANDLE_BRACED_VA_ARGS(as))); \
- try { \
- expr; \
- } catch(const DOCTEST_HANDLE_BRACED_VA_ARGS(as)&) { \
- _DOCTEST_RB.m_threw = true; \
- _DOCTEST_RB.m_threw_as = true; \
- } catch(...) { _DOCTEST_RB.unexpectedExceptionOccurred(); } \
- DOCTEST_ASSERT_LOG_AND_REACT(_DOCTEST_RB); \
- } \
- } while((void)0, 0)
-
-#define DOCTEST_ASSERT_NOTHROW(expr, assert_type) \
- do { \
- if(!doctest::detail::getTestsContextState()->no_throw) { \
- doctest::detail::ResultBuilder _DOCTEST_RB(doctest::detail::assertType::assert_type, \
- __FILE__, __LINE__, #expr); \
- try { \
- expr; \
- } catch(...) { _DOCTEST_RB.unexpectedExceptionOccurred(); } \
- DOCTEST_ASSERT_LOG_AND_REACT(_DOCTEST_RB); \
- } \
- } while((void)0, 0)
-
-#define DOCTEST_WARN_THROWS(expr) DOCTEST_ASSERT_THROWS(expr, DT_WARN_THROWS)
-#define DOCTEST_CHECK_THROWS(expr) DOCTEST_ASSERT_THROWS(expr, DT_CHECK_THROWS)
-#define DOCTEST_REQUIRE_THROWS(expr) DOCTEST_ASSERT_THROWS(expr, DT_REQUIRE_THROWS)
-
-// clang-format off
-#ifdef DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-#define DOCTEST_WARN_THROWS_AS(expr, ...) DOCTEST_ASSERT_THROWS_AS(expr, (__VA_ARGS__), DT_WARN_THROWS_AS)
-#define DOCTEST_CHECK_THROWS_AS(expr, ...) DOCTEST_ASSERT_THROWS_AS(expr, (__VA_ARGS__), DT_CHECK_THROWS_AS)
-#define DOCTEST_REQUIRE_THROWS_AS(expr, ...) DOCTEST_ASSERT_THROWS_AS(expr, (__VA_ARGS__), DT_REQUIRE_THROWS_AS)
-#else // DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-#define DOCTEST_WARN_THROWS_AS(expr, ex) DOCTEST_ASSERT_THROWS_AS(expr, ex, DT_WARN_THROWS_AS)
-#define DOCTEST_CHECK_THROWS_AS(expr, ex) DOCTEST_ASSERT_THROWS_AS(expr, ex, DT_CHECK_THROWS_AS)
-#define DOCTEST_REQUIRE_THROWS_AS(expr, ex) DOCTEST_ASSERT_THROWS_AS(expr, ex, DT_REQUIRE_THROWS_AS)
-#endif // DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-// clang-format on
-
-#define DOCTEST_WARN_NOTHROW(expr) DOCTEST_ASSERT_NOTHROW(expr, DT_WARN_NOTHROW)
-#define DOCTEST_CHECK_NOTHROW(expr) DOCTEST_ASSERT_NOTHROW(expr, DT_CHECK_NOTHROW)
-#define DOCTEST_REQUIRE_NOTHROW(expr) DOCTEST_ASSERT_NOTHROW(expr, DT_REQUIRE_NOTHROW)
-
-// clang-format off
-#define DOCTEST_WARN_THROWS_MESSAGE(expr, msg) do { DOCTEST_INFO(msg); DOCTEST_WARN_THROWS(expr); } while((void)0, 0)
-#define DOCTEST_CHECK_THROWS_MESSAGE(expr, msg) do { DOCTEST_INFO(msg); DOCTEST_CHECK_THROWS(expr); } while((void)0, 0)
-#define DOCTEST_REQUIRE_THROWS_MESSAGE(expr, msg) do { DOCTEST_INFO(msg); DOCTEST_REQUIRE_THROWS(expr); } while((void)0, 0)
-#define DOCTEST_WARN_THROWS_AS_MESSAGE(expr, ex, msg) do { DOCTEST_INFO(msg); DOCTEST_WARN_THROWS_AS(expr, ex); } while((void)0, 0)
-#define DOCTEST_CHECK_THROWS_AS_MESSAGE(expr, ex, msg) do { DOCTEST_INFO(msg); DOCTEST_CHECK_THROWS_AS(expr, ex); } while((void)0, 0)
-#define DOCTEST_REQUIRE_THROWS_AS_MESSAGE(expr, ex, msg) do { DOCTEST_INFO(msg); DOCTEST_REQUIRE_THROWS_AS(expr, ex); } while((void)0, 0)
-#define DOCTEST_WARN_NOTHROW_MESSAGE(expr, msg) do { DOCTEST_INFO(msg); DOCTEST_WARN_NOTHROW(expr); } while((void)0, 0)
-#define DOCTEST_CHECK_NOTHROW_MESSAGE(expr, msg) do { DOCTEST_INFO(msg); DOCTEST_CHECK_NOTHROW(expr); } while((void)0, 0)
-#define DOCTEST_REQUIRE_NOTHROW_MESSAGE(expr, msg) do { DOCTEST_INFO(msg); DOCTEST_REQUIRE_NOTHROW(expr); } while((void)0, 0)
-// clang-format on
-
-#ifdef DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-#define DOCTEST_BINARY_ASSERT(assert_type, expr, comp) \
- do { \
- doctest::detail::ResultBuilder _DOCTEST_RB( \
- doctest::detail::assertType::assert_type, __FILE__, __LINE__, \
- DOCTEST_TOSTR(DOCTEST_HANDLE_BRACED_VA_ARGS(expr))); \
- DOCTEST_WRAP_IN_TRY( \
- _DOCTEST_RB.binary_assert<doctest::detail::binaryAssertComparison::comp>( \
- DOCTEST_HANDLE_BRACED_VA_ARGS(expr))) \
- DOCTEST_ASSERT_LOG_AND_REACT(_DOCTEST_RB); \
- } while((void)0, 0)
-#else // DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-#define DOCTEST_BINARY_ASSERT(assert_type, lhs, rhs, comp) \
- do { \
- doctest::detail::ResultBuilder _DOCTEST_RB(doctest::detail::assertType::assert_type, \
- __FILE__, __LINE__, #lhs ", " #rhs); \
- DOCTEST_WRAP_IN_TRY( \
- _DOCTEST_RB.binary_assert<doctest::detail::binaryAssertComparison::comp>(lhs, \
- rhs)) \
- DOCTEST_ASSERT_LOG_AND_REACT(_DOCTEST_RB); \
- } while((void)0, 0)
-#endif // DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-
-#define DOCTEST_UNARY_ASSERT(assert_type, expr) \
- do { \
- doctest::detail::ResultBuilder _DOCTEST_RB( \
- doctest::detail::assertType::assert_type, __FILE__, __LINE__, \
- DOCTEST_TOSTR(DOCTEST_HANDLE_BRACED_VA_ARGS(expr))); \
- DOCTEST_WRAP_IN_TRY(_DOCTEST_RB.unary_assert(DOCTEST_HANDLE_BRACED_VA_ARGS(expr))) \
- DOCTEST_ASSERT_LOG_AND_REACT(_DOCTEST_RB); \
- } while((void)0, 0)
-
-#ifdef DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-#define DOCTEST_WARN_EQ(...) DOCTEST_BINARY_ASSERT(DT_WARN_EQ, (__VA_ARGS__), eq)
-#define DOCTEST_CHECK_EQ(...) DOCTEST_BINARY_ASSERT(DT_CHECK_EQ, (__VA_ARGS__), eq)
-#define DOCTEST_REQUIRE_EQ(...) DOCTEST_BINARY_ASSERT(DT_REQUIRE_EQ, (__VA_ARGS__), eq)
-#define DOCTEST_WARN_NE(...) DOCTEST_BINARY_ASSERT(DT_WARN_NE, (__VA_ARGS__), ne)
-#define DOCTEST_CHECK_NE(...) DOCTEST_BINARY_ASSERT(DT_CHECK_NE, (__VA_ARGS__), ne)
-#define DOCTEST_REQUIRE_NE(...) DOCTEST_BINARY_ASSERT(DT_REQUIRE_NE, (__VA_ARGS__), ne)
-#define DOCTEST_WARN_GT(...) DOCTEST_BINARY_ASSERT(DT_WARN_GT, (__VA_ARGS__), gt)
-#define DOCTEST_CHECK_GT(...) DOCTEST_BINARY_ASSERT(DT_CHECK_GT, (__VA_ARGS__), gt)
-#define DOCTEST_REQUIRE_GT(...) DOCTEST_BINARY_ASSERT(DT_REQUIRE_GT, (__VA_ARGS__), gt)
-#define DOCTEST_WARN_LT(...) DOCTEST_BINARY_ASSERT(DT_WARN_LT, (__VA_ARGS__), lt)
-#define DOCTEST_CHECK_LT(...) DOCTEST_BINARY_ASSERT(DT_CHECK_LT, (__VA_ARGS__), lt)
-#define DOCTEST_REQUIRE_LT(...) DOCTEST_BINARY_ASSERT(DT_REQUIRE_LT, (__VA_ARGS__), lt)
-#define DOCTEST_WARN_GE(...) DOCTEST_BINARY_ASSERT(DT_WARN_GE, (__VA_ARGS__), ge)
-#define DOCTEST_CHECK_GE(...) DOCTEST_BINARY_ASSERT(DT_CHECK_GE, (__VA_ARGS__), ge)
-#define DOCTEST_REQUIRE_GE(...) DOCTEST_BINARY_ASSERT(DT_REQUIRE_GE, (__VA_ARGS__), ge)
-#define DOCTEST_WARN_LE(...) DOCTEST_BINARY_ASSERT(DT_WARN_LE, (__VA_ARGS__), le)
-#define DOCTEST_CHECK_LE(...) DOCTEST_BINARY_ASSERT(DT_CHECK_LE, (__VA_ARGS__), le)
-#define DOCTEST_REQUIRE_LE(...) DOCTEST_BINARY_ASSERT(DT_REQUIRE_LE, (__VA_ARGS__), le)
-
-#define DOCTEST_WARN_UNARY(...) DOCTEST_UNARY_ASSERT(DT_WARN_UNARY, (__VA_ARGS__))
-#define DOCTEST_CHECK_UNARY(...) DOCTEST_UNARY_ASSERT(DT_CHECK_UNARY, (__VA_ARGS__))
-#define DOCTEST_REQUIRE_UNARY(...) DOCTEST_UNARY_ASSERT(DT_REQUIRE_UNARY, (__VA_ARGS__))
-#define DOCTEST_WARN_UNARY_FALSE(...) DOCTEST_UNARY_ASSERT(DT_WARN_UNARY_FALSE, (__VA_ARGS__))
-#define DOCTEST_CHECK_UNARY_FALSE(...) DOCTEST_UNARY_ASSERT(DT_CHECK_UNARY_FALSE, (__VA_ARGS__))
-#define DOCTEST_REQUIRE_UNARY_FALSE(...) DOCTEST_UNARY_ASSERT(DT_REQUIRE_UNARY_FALSE, (__VA_ARGS__))
-#else // DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-#define DOCTEST_WARN_EQ(lhs, rhs) DOCTEST_BINARY_ASSERT(DT_WARN_EQ, lhs, rhs, eq)
-#define DOCTEST_CHECK_EQ(lhs, rhs) DOCTEST_BINARY_ASSERT(DT_CHECK_EQ, lhs, rhs, eq)
-#define DOCTEST_REQUIRE_EQ(lhs, rhs) DOCTEST_BINARY_ASSERT(DT_REQUIRE_EQ, lhs, rhs, eq)
-#define DOCTEST_WARN_NE(lhs, rhs) DOCTEST_BINARY_ASSERT(DT_WARN_NE, lhs, rhs, ne)
-#define DOCTEST_CHECK_NE(lhs, rhs) DOCTEST_BINARY_ASSERT(DT_CHECK_NE, lhs, rhs, ne)
-#define DOCTEST_REQUIRE_NE(lhs, rhs) DOCTEST_BINARY_ASSERT(DT_REQUIRE_NE, lhs, rhs, ne)
-#define DOCTEST_WARN_GT(lhs, rhs) DOCTEST_BINARY_ASSERT(DT_WARN_GT, lhs, rhs, gt)
-#define DOCTEST_CHECK_GT(lhs, rhs) DOCTEST_BINARY_ASSERT(DT_CHECK_GT, lhs, rhs, gt)
-#define DOCTEST_REQUIRE_GT(lhs, rhs) DOCTEST_BINARY_ASSERT(DT_REQUIRE_GT, lhs, rhs, gt)
-#define DOCTEST_WARN_LT(lhs, rhs) DOCTEST_BINARY_ASSERT(DT_WARN_LT, lhs, rhs, lt)
-#define DOCTEST_CHECK_LT(lhs, rhs) DOCTEST_BINARY_ASSERT(DT_CHECK_LT, lhs, rhs, lt)
-#define DOCTEST_REQUIRE_LT(lhs, rhs) DOCTEST_BINARY_ASSERT(DT_REQUIRE_LT, lhs, rhs, lt)
-#define DOCTEST_WARN_GE(lhs, rhs) DOCTEST_BINARY_ASSERT(DT_WARN_GE, lhs, rhs, ge)
-#define DOCTEST_CHECK_GE(lhs, rhs) DOCTEST_BINARY_ASSERT(DT_CHECK_GE, lhs, rhs, ge)
-#define DOCTEST_REQUIRE_GE(lhs, rhs) DOCTEST_BINARY_ASSERT(DT_REQUIRE_GE, lhs, rhs, ge)
-#define DOCTEST_WARN_LE(lhs, rhs) DOCTEST_BINARY_ASSERT(DT_WARN_LE, lhs, rhs, le)
-#define DOCTEST_CHECK_LE(lhs, rhs) DOCTEST_BINARY_ASSERT(DT_CHECK_LE, lhs, rhs, le)
-#define DOCTEST_REQUIRE_LE(lhs, rhs) DOCTEST_BINARY_ASSERT(DT_REQUIRE_LE, lhs, rhs, le)
-
-#define DOCTEST_WARN_UNARY(v) DOCTEST_UNARY_ASSERT(DT_WARN_UNARY, v)
-#define DOCTEST_CHECK_UNARY(v) DOCTEST_UNARY_ASSERT(DT_CHECK_UNARY, v)
-#define DOCTEST_REQUIRE_UNARY(v) DOCTEST_UNARY_ASSERT(DT_REQUIRE_UNARY, v)
-#define DOCTEST_WARN_UNARY_FALSE(v) DOCTEST_UNARY_ASSERT(DT_WARN_UNARY_FALSE, v)
-#define DOCTEST_CHECK_UNARY_FALSE(v) DOCTEST_UNARY_ASSERT(DT_CHECK_UNARY_FALSE, v)
-#define DOCTEST_REQUIRE_UNARY_FALSE(v) DOCTEST_UNARY_ASSERT(DT_REQUIRE_UNARY_FALSE, v)
-#endif // DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-
-#ifndef DOCTEST_CONFIG_SUPER_FAST_ASSERTS
-
-#ifdef DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-#define DOCTEST_FAST_BINARY_ASSERT(assert_type, expr, comparison) \
- do { \
- int _DOCTEST_FAST_RES = doctest::detail::fast_binary_assert< \
- doctest::detail::binaryAssertComparison::comparison>( \
- doctest::detail::assertType::assert_type, __FILE__, __LINE__, \
- DOCTEST_TOSTR(DOCTEST_HANDLE_BRACED_VA_ARGS(expr)), \
- DOCTEST_HANDLE_BRACED_VA_ARGS(expr)); \
- if(_DOCTEST_FAST_RES & doctest::detail::assertAction::dbgbreak) \
- DOCTEST_BREAK_INTO_DEBUGGER(); \
- doctest::detail::fastAssertThrowIfFlagSet(_DOCTEST_FAST_RES); \
- } while((void)0, 0)
-#else // DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-#define DOCTEST_FAST_BINARY_ASSERT(assert_type, lhs, rhs, comparison) \
- do { \
- int _DOCTEST_FAST_RES = doctest::detail::fast_binary_assert< \
- doctest::detail::binaryAssertComparison::comparison>( \
- doctest::detail::assertType::assert_type, __FILE__, __LINE__, #lhs ", " #rhs, lhs, \
- rhs); \
- if(_DOCTEST_FAST_RES & doctest::detail::assertAction::dbgbreak) \
- DOCTEST_BREAK_INTO_DEBUGGER(); \
- doctest::detail::fastAssertThrowIfFlagSet(_DOCTEST_FAST_RES); \
- } while((void)0, 0)
-#endif // DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-
-#define DOCTEST_FAST_UNARY_ASSERT(assert_type, expr) \
- do { \
- int _DOCTEST_FAST_RES = doctest::detail::fast_unary_assert( \
- doctest::detail::assertType::assert_type, __FILE__, __LINE__, \
- DOCTEST_TOSTR(DOCTEST_HANDLE_BRACED_VA_ARGS(expr)), \
- DOCTEST_HANDLE_BRACED_VA_ARGS(expr)); \
- if(_DOCTEST_FAST_RES & doctest::detail::assertAction::dbgbreak) \
- DOCTEST_BREAK_INTO_DEBUGGER(); \
- doctest::detail::fastAssertThrowIfFlagSet(_DOCTEST_FAST_RES); \
- } while((void)0, 0)
-
-#else // DOCTEST_CONFIG_SUPER_FAST_ASSERTS
-
-#ifdef DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-#define DOCTEST_FAST_BINARY_ASSERT(assert_type, expr, comparison) \
- doctest::detail::fast_binary_assert<doctest::detail::binaryAssertComparison::comparison>( \
- doctest::detail::assertType::assert_type, __FILE__, __LINE__, \
- DOCTEST_TOSTR(DOCTEST_HANDLE_BRACED_VA_ARGS(expr)), \
- DOCTEST_HANDLE_BRACED_VA_ARGS(expr))
-#else // DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-#define DOCTEST_FAST_BINARY_ASSERT(assert_type, lhs, rhs, comparison) \
- doctest::detail::fast_binary_assert<doctest::detail::binaryAssertComparison::comparison>( \
- doctest::detail::assertType::assert_type, __FILE__, __LINE__, #lhs ", " #rhs, lhs, \
- rhs)
-#endif // DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-
-#define DOCTEST_FAST_UNARY_ASSERT(assert_type, expr) \
- doctest::detail::fast_unary_assert(doctest::detail::assertType::assert_type, __FILE__, \
- __LINE__, \
- DOCTEST_TOSTR(DOCTEST_HANDLE_BRACED_VA_ARGS(expr)), \
- DOCTEST_HANDLE_BRACED_VA_ARGS(expr))
-
-#endif // DOCTEST_CONFIG_SUPER_FAST_ASSERTS
-
-// clang-format off
-#ifdef DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-#define DOCTEST_FAST_WARN_EQ(...) DOCTEST_FAST_BINARY_ASSERT(DT_FAST_WARN_EQ, (__VA_ARGS__), eq)
-#define DOCTEST_FAST_CHECK_EQ(...) DOCTEST_FAST_BINARY_ASSERT(DT_FAST_CHECK_EQ, (__VA_ARGS__), eq)
-#define DOCTEST_FAST_REQUIRE_EQ(...) DOCTEST_FAST_BINARY_ASSERT(DT_FAST_REQUIRE_EQ, (__VA_ARGS__), eq)
-#define DOCTEST_FAST_WARN_NE(...) DOCTEST_FAST_BINARY_ASSERT(DT_FAST_WARN_NE, (__VA_ARGS__), ne)
-#define DOCTEST_FAST_CHECK_NE(...) DOCTEST_FAST_BINARY_ASSERT(DT_FAST_CHECK_NE, (__VA_ARGS__), ne)
-#define DOCTEST_FAST_REQUIRE_NE(...) DOCTEST_FAST_BINARY_ASSERT(DT_FAST_REQUIRE_NE, (__VA_ARGS__), ne)
-#define DOCTEST_FAST_WARN_GT(...) DOCTEST_FAST_BINARY_ASSERT(DT_FAST_WARN_GT, (__VA_ARGS__), gt)
-#define DOCTEST_FAST_CHECK_GT(...) DOCTEST_FAST_BINARY_ASSERT(DT_FAST_CHECK_GT, (__VA_ARGS__), gt)
-#define DOCTEST_FAST_REQUIRE_GT(...) DOCTEST_FAST_BINARY_ASSERT(DT_FAST_REQUIRE_GT, (__VA_ARGS__), gt)
-#define DOCTEST_FAST_WARN_LT(...) DOCTEST_FAST_BINARY_ASSERT(DT_FAST_WARN_LT, (__VA_ARGS__), lt)
-#define DOCTEST_FAST_CHECK_LT(...) DOCTEST_FAST_BINARY_ASSERT(DT_FAST_CHECK_LT, (__VA_ARGS__), lt)
-#define DOCTEST_FAST_REQUIRE_LT(...) DOCTEST_FAST_BINARY_ASSERT(DT_FAST_REQUIRE_LT, (__VA_ARGS__), lt)
-#define DOCTEST_FAST_WARN_GE(...) DOCTEST_FAST_BINARY_ASSERT(DT_FAST_WARN_GE, (__VA_ARGS__), ge)
-#define DOCTEST_FAST_CHECK_GE(...) DOCTEST_FAST_BINARY_ASSERT(DT_FAST_CHECK_GE, (__VA_ARGS__), ge)
-#define DOCTEST_FAST_REQUIRE_GE(...) DOCTEST_FAST_BINARY_ASSERT(DT_FAST_REQUIRE_GE, (__VA_ARGS__), ge)
-#define DOCTEST_FAST_WARN_LE(...) DOCTEST_FAST_BINARY_ASSERT(DT_FAST_WARN_LE, (__VA_ARGS__), le)
-#define DOCTEST_FAST_CHECK_LE(...) DOCTEST_FAST_BINARY_ASSERT(DT_FAST_CHECK_LE, (__VA_ARGS__), le)
-#define DOCTEST_FAST_REQUIRE_LE(...) DOCTEST_FAST_BINARY_ASSERT(DT_FAST_REQUIRE_LE, (__VA_ARGS__), le)
-
-#define DOCTEST_FAST_WARN_UNARY(...) DOCTEST_FAST_UNARY_ASSERT(DT_FAST_WARN_UNARY, (__VA_ARGS__))
-#define DOCTEST_FAST_CHECK_UNARY(...) DOCTEST_FAST_UNARY_ASSERT(DT_FAST_CHECK_UNARY, (__VA_ARGS__))
-#define DOCTEST_FAST_REQUIRE_UNARY(...) DOCTEST_FAST_UNARY_ASSERT(DT_FAST_REQUIRE_UNARY, (__VA_ARGS__))
-#define DOCTEST_FAST_WARN_UNARY_FALSE(...) DOCTEST_FAST_UNARY_ASSERT(DT_FAST_WARN_UNARY_FALSE, (__VA_ARGS__))
-#define DOCTEST_FAST_CHECK_UNARY_FALSE(...) DOCTEST_FAST_UNARY_ASSERT(DT_FAST_CHECK_UNARY_FALSE, (__VA_ARGS__))
-#define DOCTEST_FAST_REQUIRE_UNARY_FALSE(...) DOCTEST_FAST_UNARY_ASSERT(DT_FAST_REQUIRE_UNARY_FALSE, (__VA_ARGS__))
-#else // DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-#define DOCTEST_FAST_WARN_EQ(l, r) DOCTEST_FAST_BINARY_ASSERT(DT_FAST_WARN_EQ, l, r, eq)
-#define DOCTEST_FAST_CHECK_EQ(l, r) DOCTEST_FAST_BINARY_ASSERT(DT_FAST_CHECK_EQ, l, r, eq)
-#define DOCTEST_FAST_REQUIRE_EQ(l, r) DOCTEST_FAST_BINARY_ASSERT(DT_FAST_REQUIRE_EQ, l, r, eq)
-#define DOCTEST_FAST_WARN_NE(l, r) DOCTEST_FAST_BINARY_ASSERT(DT_FAST_WARN_NE, l, r, ne)
-#define DOCTEST_FAST_CHECK_NE(l, r) DOCTEST_FAST_BINARY_ASSERT(DT_FAST_CHECK_NE, l, r, ne)
-#define DOCTEST_FAST_REQUIRE_NE(l, r) DOCTEST_FAST_BINARY_ASSERT(DT_FAST_REQUIRE_NE, l, r, ne)
-#define DOCTEST_FAST_WARN_GT(l, r) DOCTEST_FAST_BINARY_ASSERT(DT_FAST_WARN_GT, l, r, gt)
-#define DOCTEST_FAST_CHECK_GT(l, r) DOCTEST_FAST_BINARY_ASSERT(DT_FAST_CHECK_GT, l, r, gt)
-#define DOCTEST_FAST_REQUIRE_GT(l, r) DOCTEST_FAST_BINARY_ASSERT(DT_FAST_REQUIRE_GT, l, r, gt)
-#define DOCTEST_FAST_WARN_LT(l, r) DOCTEST_FAST_BINARY_ASSERT(DT_FAST_WARN_LT, l, r, lt)
-#define DOCTEST_FAST_CHECK_LT(l, r) DOCTEST_FAST_BINARY_ASSERT(DT_FAST_CHECK_LT, l, r, lt)
-#define DOCTEST_FAST_REQUIRE_LT(l, r) DOCTEST_FAST_BINARY_ASSERT(DT_FAST_REQUIRE_LT, l, r, lt)
-#define DOCTEST_FAST_WARN_GE(l, r) DOCTEST_FAST_BINARY_ASSERT(DT_FAST_WARN_GE, l, r, ge)
-#define DOCTEST_FAST_CHECK_GE(l, r) DOCTEST_FAST_BINARY_ASSERT(DT_FAST_CHECK_GE, l, r, ge)
-#define DOCTEST_FAST_REQUIRE_GE(l, r) DOCTEST_FAST_BINARY_ASSERT(DT_FAST_REQUIRE_GE, l, r, ge)
-#define DOCTEST_FAST_WARN_LE(l, r) DOCTEST_FAST_BINARY_ASSERT(DT_FAST_WARN_LE, l, r, le)
-#define DOCTEST_FAST_CHECK_LE(l, r) DOCTEST_FAST_BINARY_ASSERT(DT_FAST_CHECK_LE, l, r, le)
-#define DOCTEST_FAST_REQUIRE_LE(l, r) DOCTEST_FAST_BINARY_ASSERT(DT_FAST_REQUIRE_LE, l, r, le)
-
-#define DOCTEST_FAST_WARN_UNARY(v) DOCTEST_FAST_UNARY_ASSERT(DT_FAST_WARN_UNARY, v)
-#define DOCTEST_FAST_CHECK_UNARY(v) DOCTEST_FAST_UNARY_ASSERT(DT_FAST_CHECK_UNARY, v)
-#define DOCTEST_FAST_REQUIRE_UNARY(v) DOCTEST_FAST_UNARY_ASSERT(DT_FAST_REQUIRE_UNARY, v)
-#define DOCTEST_FAST_WARN_UNARY_FALSE(v) DOCTEST_FAST_UNARY_ASSERT(DT_FAST_WARN_UNARY_FALSE, v)
-#define DOCTEST_FAST_CHECK_UNARY_FALSE(v) DOCTEST_FAST_UNARY_ASSERT(DT_FAST_CHECK_UNARY_FALSE, v)
-#define DOCTEST_FAST_REQUIRE_UNARY_FALSE(v) DOCTEST_FAST_UNARY_ASSERT(DT_FAST_REQUIRE_UNARY_FALSE, v)
-#endif // DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-// clang-format on
-
-#ifdef DOCTEST_CONFIG_NO_EXCEPTIONS
-
-#undef DOCTEST_WARN_THROWS
-#undef DOCTEST_CHECK_THROWS
-#undef DOCTEST_REQUIRE_THROWS
-#undef DOCTEST_WARN_THROWS_AS
-#undef DOCTEST_CHECK_THROWS_AS
-#undef DOCTEST_REQUIRE_THROWS_AS
-#undef DOCTEST_WARN_NOTHROW
-#undef DOCTEST_CHECK_NOTHROW
-#undef DOCTEST_REQUIRE_NOTHROW
-
-#undef DOCTEST_WARN_THROWS_MESSAGE
-#undef DOCTEST_CHECK_THROWS_MESSAGE
-#undef DOCTEST_REQUIRE_THROWS_MESSAGE
-#undef DOCTEST_WARN_THROWS_AS_MESSAGE
-#undef DOCTEST_CHECK_THROWS_AS_MESSAGE
-#undef DOCTEST_REQUIRE_THROWS_AS_MESSAGE
-#undef DOCTEST_WARN_NOTHROW_MESSAGE
-#undef DOCTEST_CHECK_NOTHROW_MESSAGE
-#undef DOCTEST_REQUIRE_NOTHROW_MESSAGE
-
-#ifdef DOCTEST_CONFIG_NO_EXCEPTIONS_BUT_WITH_ALL_ASSERTS
-
-#define DOCTEST_WARN_THROWS(expr) ((void)0)
-#define DOCTEST_CHECK_THROWS(expr) ((void)0)
-#define DOCTEST_REQUIRE_THROWS(expr) ((void)0)
-#ifdef DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-#define DOCTEST_WARN_THROWS_AS(expr, ...) ((void)0)
-#define DOCTEST_CHECK_THROWS_AS(expr, ...) ((void)0)
-#define DOCTEST_REQUIRE_THROWS_AS(expr, ...) ((void)0)
-#else // DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-#define DOCTEST_WARN_THROWS_AS(expr, ex) ((void)0)
-#define DOCTEST_CHECK_THROWS_AS(expr, ex) ((void)0)
-#define DOCTEST_REQUIRE_THROWS_AS(expr, ex) ((void)0)
-#endif // DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-#define DOCTEST_WARN_NOTHROW(expr) ((void)0)
-#define DOCTEST_CHECK_NOTHROW(expr) ((void)0)
-#define DOCTEST_REQUIRE_NOTHROW(expr) ((void)0)
-
-#define DOCTEST_WARN_THROWS_MESSAGE(expr, msg) ((void)0)
-#define DOCTEST_CHECK_THROWS_MESSAGE(expr, msg) ((void)0)
-#define DOCTEST_REQUIRE_THROWS_MESSAGE(expr, msg) ((void)0)
-#define DOCTEST_WARN_THROWS_AS_MESSAGE(expr, ex, msg) ((void)0)
-#define DOCTEST_CHECK_THROWS_AS_MESSAGE(expr, ex, msg) ((void)0)
-#define DOCTEST_REQUIRE_THROWS_AS_MESSAGE(expr, ex, msg) ((void)0)
-#define DOCTEST_WARN_NOTHROW_MESSAGE(expr, msg) ((void)0)
-#define DOCTEST_CHECK_NOTHROW_MESSAGE(expr, msg) ((void)0)
-#define DOCTEST_REQUIRE_NOTHROW_MESSAGE(expr, msg) ((void)0)
-
-#else // DOCTEST_CONFIG_NO_EXCEPTIONS_BUT_WITH_ALL_ASSERTS
-
-#undef DOCTEST_REQUIRE
-#undef DOCTEST_REQUIRE_FALSE
-#undef DOCTEST_REQUIRE_MESSAGE
-#undef DOCTEST_REQUIRE_FALSE_MESSAGE
-#undef DOCTEST_REQUIRE_EQ
-#undef DOCTEST_REQUIRE_NE
-#undef DOCTEST_REQUIRE_GT
-#undef DOCTEST_REQUIRE_LT
-#undef DOCTEST_REQUIRE_GE
-#undef DOCTEST_REQUIRE_LE
-#undef DOCTEST_REQUIRE_UNARY
-#undef DOCTEST_REQUIRE_UNARY_FALSE
-#undef DOCTEST_FAST_REQUIRE_EQ
-#undef DOCTEST_FAST_REQUIRE_NE
-#undef DOCTEST_FAST_REQUIRE_GT
-#undef DOCTEST_FAST_REQUIRE_LT
-#undef DOCTEST_FAST_REQUIRE_GE
-#undef DOCTEST_FAST_REQUIRE_LE
-#undef DOCTEST_FAST_REQUIRE_UNARY
-#undef DOCTEST_FAST_REQUIRE_UNARY_FALSE
-
-#endif // DOCTEST_CONFIG_NO_EXCEPTIONS_BUT_WITH_ALL_ASSERTS
-
-#endif // DOCTEST_CONFIG_NO_EXCEPTIONS
-
-// =================================================================================================
-// == WHAT FOLLOWS IS VERSIONS OF THE MACROS THAT DO NOT DO ANY REGISTERING! ==
-// == THIS CAN BE ENABLED BY DEFINING DOCTEST_CONFIG_DISABLE GLOBALLY! ==
-// =================================================================================================
-#else // DOCTEST_CONFIG_DISABLE
-
-#define DOCTEST_IMPLEMENT_FIXTURE(der, base, func, name) \
- namespace \
- { \
- template <typename T> \
- struct der : base \
- { void f(); }; \
- } \
- template <typename T> \
- inline void der<T>::f()
-
-#define DOCTEST_CREATE_AND_REGISTER_FUNCTION(f, name) \
- template <typename T> \
- static inline void f()
-
-// for registering tests
-#define DOCTEST_TEST_CASE(name) \
- DOCTEST_CREATE_AND_REGISTER_FUNCTION(DOCTEST_ANONYMOUS(_DOCTEST_ANON_FUNC_), name)
-
-// for registering tests with a fixture
-#define DOCTEST_TEST_CASE_FIXTURE(x, name) \
- DOCTEST_IMPLEMENT_FIXTURE(DOCTEST_ANONYMOUS(_DOCTEST_ANON_CLASS_), x, \
- DOCTEST_ANONYMOUS(_DOCTEST_ANON_FUNC_), name)
-
-// for converting types to strings without the <typeinfo> header and demangling
-#ifdef DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-#define DOCTEST_TYPE_TO_STRING(...) typedef int DOCTEST_ANONYMOUS(_DOCTEST_ANON_FOR_SEMICOLON_)
-#define DOCTEST_TYPE_TO_STRING_IMPL(...)
-#else // DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-#define DOCTEST_TYPE_TO_STRING(x) typedef int DOCTEST_ANONYMOUS(_DOCTEST_ANON_FOR_SEMICOLON_)
-#define DOCTEST_TYPE_TO_STRING_IMPL(x)
-#endif // DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-
-// for typed tests
-#define DOCTEST_TEST_CASE_TEMPLATE(name, type, types) \
- template <typename type> \
- inline void DOCTEST_ANONYMOUS(_DOCTEST_ANON_TMP_)()
-
-#define DOCTEST_TEST_CASE_TEMPLATE_DEFINE(name, type, id) \
- template <typename type> \
- inline void DOCTEST_ANONYMOUS(_DOCTEST_ANON_TMP_)()
-
-#define DOCTEST_TEST_CASE_TEMPLATE_INSTANTIATE(id, types) \
- typedef int DOCTEST_ANONYMOUS(_DOCTEST_ANON_FOR_SEMICOLON_)
-
-// for subcases
-#define DOCTEST_SUBCASE(name)
-
-// for a testsuite block
-#define DOCTEST_TEST_SUITE(name) namespace
-
-// for starting a testsuite block
-#define DOCTEST_TEST_SUITE_BEGIN(name) typedef int DOCTEST_ANONYMOUS(_DOCTEST_ANON_FOR_SEMICOLON_)
-
-// for ending a testsuite block
-#define DOCTEST_TEST_SUITE_END typedef int DOCTEST_ANONYMOUS(_DOCTEST_ANON_FOR_SEMICOLON_)
-
-#define DOCTEST_REGISTER_EXCEPTION_TRANSLATOR(signature) \
- template <typename T> \
- static inline doctest::String DOCTEST_ANONYMOUS(_DOCTEST_ANON_TRANSLATOR_)(signature)
-
-#define DOCTEST_INFO(x) ((void)0)
-#define DOCTEST_CAPTURE(x) ((void)0)
-#define DOCTEST_ADD_MESSAGE_AT(file, line, x) ((void)0)
-#define DOCTEST_ADD_FAIL_CHECK_AT(file, line, x) ((void)0)
-#define DOCTEST_ADD_FAIL_AT(file, line, x) ((void)0)
-#define DOCTEST_MESSAGE(x) ((void)0)
-#define DOCTEST_FAIL_CHECK(x) ((void)0)
-#define DOCTEST_FAIL(x) ((void)0)
-
-#ifdef DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-#define DOCTEST_WARN(...) ((void)0)
-#define DOCTEST_CHECK(...) ((void)0)
-#define DOCTEST_REQUIRE(...) ((void)0)
-#define DOCTEST_WARN_FALSE(...) ((void)0)
-#define DOCTEST_CHECK_FALSE(...) ((void)0)
-#define DOCTEST_REQUIRE_FALSE(...) ((void)0)
-#else // DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-#define DOCTEST_WARN(expr) ((void)0)
-#define DOCTEST_CHECK(expr) ((void)0)
-#define DOCTEST_REQUIRE(expr) ((void)0)
-#define DOCTEST_WARN_FALSE(expr) ((void)0)
-#define DOCTEST_CHECK_FALSE(expr) ((void)0)
-#define DOCTEST_REQUIRE_FALSE(expr) ((void)0)
-#endif // DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-
-#define DOCTEST_WARN_MESSAGE(cond, msg) ((void)0)
-#define DOCTEST_CHECK_MESSAGE(cond, msg) ((void)0)
-#define DOCTEST_REQUIRE_MESSAGE(cond, msg) ((void)0)
-#define DOCTEST_WARN_FALSE_MESSAGE(cond, msg) ((void)0)
-#define DOCTEST_CHECK_FALSE_MESSAGE(cond, msg) ((void)0)
-#define DOCTEST_REQUIRE_FALSE_MESSAGE(cond, msg) ((void)0)
-
-#define DOCTEST_WARN_THROWS(expr) ((void)0)
-#define DOCTEST_CHECK_THROWS(expr) ((void)0)
-#define DOCTEST_REQUIRE_THROWS(expr) ((void)0)
-#ifdef DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-#define DOCTEST_WARN_THROWS_AS(expr, ...) ((void)0)
-#define DOCTEST_CHECK_THROWS_AS(expr, ...) ((void)0)
-#define DOCTEST_REQUIRE_THROWS_AS(expr, ...) ((void)0)
-#else // DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-#define DOCTEST_WARN_THROWS_AS(expr, ex) ((void)0)
-#define DOCTEST_CHECK_THROWS_AS(expr, ex) ((void)0)
-#define DOCTEST_REQUIRE_THROWS_AS(expr, ex) ((void)0)
-#endif // DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-#define DOCTEST_WARN_NOTHROW(expr) ((void)0)
-#define DOCTEST_CHECK_NOTHROW(expr) ((void)0)
-#define DOCTEST_REQUIRE_NOTHROW(expr) ((void)0)
-
-#define DOCTEST_WARN_THROWS_MESSAGE(expr, msg) ((void)0)
-#define DOCTEST_CHECK_THROWS_MESSAGE(expr, msg) ((void)0)
-#define DOCTEST_REQUIRE_THROWS_MESSAGE(expr, msg) ((void)0)
-#define DOCTEST_WARN_THROWS_AS_MESSAGE(expr, ex, msg) ((void)0)
-#define DOCTEST_CHECK_THROWS_AS_MESSAGE(expr, ex, msg) ((void)0)
-#define DOCTEST_REQUIRE_THROWS_AS_MESSAGE(expr, ex, msg) ((void)0)
-#define DOCTEST_WARN_NOTHROW_MESSAGE(expr, msg) ((void)0)
-#define DOCTEST_CHECK_NOTHROW_MESSAGE(expr, msg) ((void)0)
-#define DOCTEST_REQUIRE_NOTHROW_MESSAGE(expr, msg) ((void)0)
-
-#ifdef DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-
-#define DOCTEST_WARN_EQ(...) ((void)0)
-#define DOCTEST_CHECK_EQ(...) ((void)0)
-#define DOCTEST_REQUIRE_EQ(...) ((void)0)
-#define DOCTEST_WARN_NE(...) ((void)0)
-#define DOCTEST_CHECK_NE(...) ((void)0)
-#define DOCTEST_REQUIRE_NE(...) ((void)0)
-#define DOCTEST_WARN_GT(...) ((void)0)
-#define DOCTEST_CHECK_GT(...) ((void)0)
-#define DOCTEST_REQUIRE_GT(...) ((void)0)
-#define DOCTEST_WARN_LT(...) ((void)0)
-#define DOCTEST_CHECK_LT(...) ((void)0)
-#define DOCTEST_REQUIRE_LT(...) ((void)0)
-#define DOCTEST_WARN_GE(...) ((void)0)
-#define DOCTEST_CHECK_GE(...) ((void)0)
-#define DOCTEST_REQUIRE_GE(...) ((void)0)
-#define DOCTEST_WARN_LE(...) ((void)0)
-#define DOCTEST_CHECK_LE(...) ((void)0)
-#define DOCTEST_REQUIRE_LE(...) ((void)0)
-
-#define DOCTEST_WARN_UNARY(...) ((void)0)
-#define DOCTEST_CHECK_UNARY(...) ((void)0)
-#define DOCTEST_REQUIRE_UNARY(...) ((void)0)
-#define DOCTEST_WARN_UNARY_FALSE(...) ((void)0)
-#define DOCTEST_CHECK_UNARY_FALSE(...) ((void)0)
-#define DOCTEST_REQUIRE_UNARY_FALSE(...) ((void)0)
-
-#define DOCTEST_FAST_WARN_EQ(...) ((void)0)
-#define DOCTEST_FAST_CHECK_EQ(...) ((void)0)
-#define DOCTEST_FAST_REQUIRE_EQ(...) ((void)0)
-#define DOCTEST_FAST_WARN_NE(...) ((void)0)
-#define DOCTEST_FAST_CHECK_NE(...) ((void)0)
-#define DOCTEST_FAST_REQUIRE_NE(...) ((void)0)
-#define DOCTEST_FAST_WARN_GT(...) ((void)0)
-#define DOCTEST_FAST_CHECK_GT(...) ((void)0)
-#define DOCTEST_FAST_REQUIRE_GT(...) ((void)0)
-#define DOCTEST_FAST_WARN_LT(...) ((void)0)
-#define DOCTEST_FAST_CHECK_LT(...) ((void)0)
-#define DOCTEST_FAST_REQUIRE_LT(...) ((void)0)
-#define DOCTEST_FAST_WARN_GE(...) ((void)0)
-#define DOCTEST_FAST_CHECK_GE(...) ((void)0)
-#define DOCTEST_FAST_REQUIRE_GE(...) ((void)0)
-#define DOCTEST_FAST_WARN_LE(...) ((void)0)
-#define DOCTEST_FAST_CHECK_LE(...) ((void)0)
-#define DOCTEST_FAST_REQUIRE_LE(...) ((void)0)
-
-#define DOCTEST_FAST_WARN_UNARY(...) ((void)0)
-#define DOCTEST_FAST_CHECK_UNARY(...) ((void)0)
-#define DOCTEST_FAST_REQUIRE_UNARY(...) ((void)0)
-#define DOCTEST_FAST_WARN_UNARY_FALSE(...) ((void)0)
-#define DOCTEST_FAST_CHECK_UNARY_FALSE(...) ((void)0)
-#define DOCTEST_FAST_REQUIRE_UNARY_FALSE(...) ((void)0)
-
-#else // DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-
-#define DOCTEST_WARN_EQ(lhs, rhs) ((void)0)
-#define DOCTEST_CHECK_EQ(lhs, rhs) ((void)0)
-#define DOCTEST_REQUIRE_EQ(lhs, rhs) ((void)0)
-#define DOCTEST_WARN_NE(lhs, rhs) ((void)0)
-#define DOCTEST_CHECK_NE(lhs, rhs) ((void)0)
-#define DOCTEST_REQUIRE_NE(lhs, rhs) ((void)0)
-#define DOCTEST_WARN_GT(lhs, rhs) ((void)0)
-#define DOCTEST_CHECK_GT(lhs, rhs) ((void)0)
-#define DOCTEST_REQUIRE_GT(lhs, rhs) ((void)0)
-#define DOCTEST_WARN_LT(lhs, rhs) ((void)0)
-#define DOCTEST_CHECK_LT(lhs, rhs) ((void)0)
-#define DOCTEST_REQUIRE_LT(lhs, rhs) ((void)0)
-#define DOCTEST_WARN_GE(lhs, rhs) ((void)0)
-#define DOCTEST_CHECK_GE(lhs, rhs) ((void)0)
-#define DOCTEST_REQUIRE_GE(lhs, rhs) ((void)0)
-#define DOCTEST_WARN_LE(lhs, rhs) ((void)0)
-#define DOCTEST_CHECK_LE(lhs, rhs) ((void)0)
-#define DOCTEST_REQUIRE_LE(lhs, rhs) ((void)0)
-
-#define DOCTEST_WARN_UNARY(val) ((void)0)
-#define DOCTEST_CHECK_UNARY(val) ((void)0)
-#define DOCTEST_REQUIRE_UNARY(val) ((void)0)
-#define DOCTEST_WARN_UNARY_FALSE(val) ((void)0)
-#define DOCTEST_CHECK_UNARY_FALSE(val) ((void)0)
-#define DOCTEST_REQUIRE_UNARY_FALSE(val) ((void)0)
-
-#define DOCTEST_FAST_WARN_EQ(lhs, rhs) ((void)0)
-#define DOCTEST_FAST_CHECK_EQ(lhs, rhs) ((void)0)
-#define DOCTEST_FAST_REQUIRE_EQ(lhs, rhs) ((void)0)
-#define DOCTEST_FAST_WARN_NE(lhs, rhs) ((void)0)
-#define DOCTEST_FAST_CHECK_NE(lhs, rhs) ((void)0)
-#define DOCTEST_FAST_REQUIRE_NE(lhs, rhs) ((void)0)
-#define DOCTEST_FAST_WARN_GT(lhs, rhs) ((void)0)
-#define DOCTEST_FAST_CHECK_GT(lhs, rhs) ((void)0)
-#define DOCTEST_FAST_REQUIRE_GT(lhs, rhs) ((void)0)
-#define DOCTEST_FAST_WARN_LT(lhs, rhs) ((void)0)
-#define DOCTEST_FAST_CHECK_LT(lhs, rhs) ((void)0)
-#define DOCTEST_FAST_REQUIRE_LT(lhs, rhs) ((void)0)
-#define DOCTEST_FAST_WARN_GE(lhs, rhs) ((void)0)
-#define DOCTEST_FAST_CHECK_GE(lhs, rhs) ((void)0)
-#define DOCTEST_FAST_REQUIRE_GE(lhs, rhs) ((void)0)
-#define DOCTEST_FAST_WARN_LE(lhs, rhs) ((void)0)
-#define DOCTEST_FAST_CHECK_LE(lhs, rhs) ((void)0)
-#define DOCTEST_FAST_REQUIRE_LE(lhs, rhs) ((void)0)
-
-#define DOCTEST_FAST_WARN_UNARY(val) ((void)0)
-#define DOCTEST_FAST_CHECK_UNARY(val) ((void)0)
-#define DOCTEST_FAST_REQUIRE_UNARY(val) ((void)0)
-#define DOCTEST_FAST_WARN_UNARY_FALSE(val) ((void)0)
-#define DOCTEST_FAST_CHECK_UNARY_FALSE(val) ((void)0)
-#define DOCTEST_FAST_REQUIRE_UNARY_FALSE(val) ((void)0)
-
-#endif // DOCTEST_CONFIG_WITH_VARIADIC_MACROS
-
-#endif // DOCTEST_CONFIG_DISABLE
-
-// BDD style macros
-// clang-format off
-#define DOCTEST_SCENARIO(name) TEST_CASE(" Scenario: " name)
-#define DOCTEST_GIVEN(name) SUBCASE(" Given: " name)
-#define DOCTEST_WHEN(name) SUBCASE(" When: " name)
-#define DOCTEST_AND_WHEN(name) SUBCASE("And when: " name)
-#define DOCTEST_THEN(name) SUBCASE(" Then: " name)
-#define DOCTEST_AND_THEN(name) SUBCASE(" And: " name)
-// clang-format on
-
-// == SHORT VERSIONS OF THE MACROS
-#if !defined(DOCTEST_CONFIG_NO_SHORT_MACRO_NAMES)
-
-#define TEST_CASE DOCTEST_TEST_CASE
-#define TEST_CASE_FIXTURE DOCTEST_TEST_CASE_FIXTURE
-#define TYPE_TO_STRING DOCTEST_TYPE_TO_STRING
-#define TEST_CASE_TEMPLATE DOCTEST_TEST_CASE_TEMPLATE
-#define TEST_CASE_TEMPLATE_DEFINE DOCTEST_TEST_CASE_TEMPLATE_DEFINE
-#define TEST_CASE_TEMPLATE_INSTANTIATE DOCTEST_TEST_CASE_TEMPLATE_INSTANTIATE
-#define SUBCASE DOCTEST_SUBCASE
-#define TEST_SUITE DOCTEST_TEST_SUITE
-#define TEST_SUITE_BEGIN DOCTEST_TEST_SUITE_BEGIN
-#define TEST_SUITE_END DOCTEST_TEST_SUITE_END
-#define REGISTER_EXCEPTION_TRANSLATOR DOCTEST_REGISTER_EXCEPTION_TRANSLATOR
-#define INFO DOCTEST_INFO
-#define CAPTURE DOCTEST_CAPTURE
-#define ADD_MESSAGE_AT DOCTEST_ADD_MESSAGE_AT
-#define ADD_FAIL_CHECK_AT DOCTEST_ADD_FAIL_CHECK_AT
-#define ADD_FAIL_AT DOCTEST_ADD_FAIL_AT
-#define MESSAGE DOCTEST_MESSAGE
-#define FAIL_CHECK DOCTEST_FAIL_CHECK
-#define FAIL DOCTEST_FAIL
-#define TO_LVALUE DOCTEST_TO_LVALUE
-
-#define WARN DOCTEST_WARN
-#define WARN_FALSE DOCTEST_WARN_FALSE
-#define WARN_THROWS DOCTEST_WARN_THROWS
-#define WARN_THROWS_AS DOCTEST_WARN_THROWS_AS
-#define WARN_NOTHROW DOCTEST_WARN_NOTHROW
-#define CHECK DOCTEST_CHECK
-#define CHECK_FALSE DOCTEST_CHECK_FALSE
-#define CHECK_THROWS DOCTEST_CHECK_THROWS
-#define CHECK_THROWS_AS DOCTEST_CHECK_THROWS_AS
-#define CHECK_NOTHROW DOCTEST_CHECK_NOTHROW
-#define REQUIRE DOCTEST_REQUIRE
-#define REQUIRE_FALSE DOCTEST_REQUIRE_FALSE
-#define REQUIRE_THROWS DOCTEST_REQUIRE_THROWS
-#define REQUIRE_THROWS_AS DOCTEST_REQUIRE_THROWS_AS
-#define REQUIRE_NOTHROW DOCTEST_REQUIRE_NOTHROW
-
-#define WARN_MESSAGE DOCTEST_WARN_MESSAGE
-#define WARN_FALSE_MESSAGE DOCTEST_WARN_FALSE_MESSAGE
-#define WARN_THROWS_MESSAGE DOCTEST_WARN_THROWS_MESSAGE
-#define WARN_THROWS_AS_MESSAGE DOCTEST_WARN_THROWS_AS_MESSAGE
-#define WARN_NOTHROW_MESSAGE DOCTEST_WARN_NOTHROW_MESSAGE
-#define CHECK_MESSAGE DOCTEST_CHECK_MESSAGE
-#define CHECK_FALSE_MESSAGE DOCTEST_CHECK_FALSE_MESSAGE
-#define CHECK_THROWS_MESSAGE DOCTEST_CHECK_THROWS_MESSAGE
-#define CHECK_THROWS_AS_MESSAGE DOCTEST_CHECK_THROWS_AS_MESSAGE
-#define CHECK_NOTHROW_MESSAGE DOCTEST_CHECK_NOTHROW_MESSAGE
-#define REQUIRE_MESSAGE DOCTEST_REQUIRE_MESSAGE
-#define REQUIRE_FALSE_MESSAGE DOCTEST_REQUIRE_FALSE_MESSAGE
-#define REQUIRE_THROWS_MESSAGE DOCTEST_REQUIRE_THROWS_MESSAGE
-#define REQUIRE_THROWS_AS_MESSAGE DOCTEST_REQUIRE_THROWS_AS_MESSAGE
-#define REQUIRE_NOTHROW_MESSAGE DOCTEST_REQUIRE_NOTHROW_MESSAGE
-
-#define SCENARIO DOCTEST_SCENARIO
-#define GIVEN DOCTEST_GIVEN
-#define WHEN DOCTEST_WHEN
-#define AND_WHEN DOCTEST_AND_WHEN
-#define THEN DOCTEST_THEN
-#define AND_THEN DOCTEST_AND_THEN
-
-#define WARN_EQ DOCTEST_WARN_EQ
-#define CHECK_EQ DOCTEST_CHECK_EQ
-#define REQUIRE_EQ DOCTEST_REQUIRE_EQ
-#define WARN_NE DOCTEST_WARN_NE
-#define CHECK_NE DOCTEST_CHECK_NE
-#define REQUIRE_NE DOCTEST_REQUIRE_NE
-#define WARN_GT DOCTEST_WARN_GT
-#define CHECK_GT DOCTEST_CHECK_GT
-#define REQUIRE_GT DOCTEST_REQUIRE_GT
-#define WARN_LT DOCTEST_WARN_LT
-#define CHECK_LT DOCTEST_CHECK_LT
-#define REQUIRE_LT DOCTEST_REQUIRE_LT
-#define WARN_GE DOCTEST_WARN_GE
-#define CHECK_GE DOCTEST_CHECK_GE
-#define REQUIRE_GE DOCTEST_REQUIRE_GE
-#define WARN_LE DOCTEST_WARN_LE
-#define CHECK_LE DOCTEST_CHECK_LE
-#define REQUIRE_LE DOCTEST_REQUIRE_LE
-#define WARN_UNARY DOCTEST_WARN_UNARY
-#define CHECK_UNARY DOCTEST_CHECK_UNARY
-#define REQUIRE_UNARY DOCTEST_REQUIRE_UNARY
-#define WARN_UNARY_FALSE DOCTEST_WARN_UNARY_FALSE
-#define CHECK_UNARY_FALSE DOCTEST_CHECK_UNARY_FALSE
-#define REQUIRE_UNARY_FALSE DOCTEST_REQUIRE_UNARY_FALSE
-
-#define FAST_WARN_EQ DOCTEST_FAST_WARN_EQ
-#define FAST_CHECK_EQ DOCTEST_FAST_CHECK_EQ
-#define FAST_REQUIRE_EQ DOCTEST_FAST_REQUIRE_EQ
-#define FAST_WARN_NE DOCTEST_FAST_WARN_NE
-#define FAST_CHECK_NE DOCTEST_FAST_CHECK_NE
-#define FAST_REQUIRE_NE DOCTEST_FAST_REQUIRE_NE
-#define FAST_WARN_GT DOCTEST_FAST_WARN_GT
-#define FAST_CHECK_GT DOCTEST_FAST_CHECK_GT
-#define FAST_REQUIRE_GT DOCTEST_FAST_REQUIRE_GT
-#define FAST_WARN_LT DOCTEST_FAST_WARN_LT
-#define FAST_CHECK_LT DOCTEST_FAST_CHECK_LT
-#define FAST_REQUIRE_LT DOCTEST_FAST_REQUIRE_LT
-#define FAST_WARN_GE DOCTEST_FAST_WARN_GE
-#define FAST_CHECK_GE DOCTEST_FAST_CHECK_GE
-#define FAST_REQUIRE_GE DOCTEST_FAST_REQUIRE_GE
-#define FAST_WARN_LE DOCTEST_FAST_WARN_LE
-#define FAST_CHECK_LE DOCTEST_FAST_CHECK_LE
-#define FAST_REQUIRE_LE DOCTEST_FAST_REQUIRE_LE
-#define FAST_WARN_UNARY DOCTEST_FAST_WARN_UNARY
-#define FAST_CHECK_UNARY DOCTEST_FAST_CHECK_UNARY
-#define FAST_REQUIRE_UNARY DOCTEST_FAST_REQUIRE_UNARY
-#define FAST_WARN_UNARY_FALSE DOCTEST_FAST_WARN_UNARY_FALSE
-#define FAST_CHECK_UNARY_FALSE DOCTEST_FAST_CHECK_UNARY_FALSE
-#define FAST_REQUIRE_UNARY_FALSE DOCTEST_FAST_REQUIRE_UNARY_FALSE
-
-#endif // DOCTEST_CONFIG_NO_SHORT_MACRO_NAMES
-
-// this is here to clear the 'current test suite' for the current translation unit - at the top
-DOCTEST_TEST_SUITE_END();
-
-// add stringification for primitive/fundamental types
-namespace doctest
-{
-namespace detail
-{
- DOCTEST_TYPE_TO_STRING_IMPL(bool)
- DOCTEST_TYPE_TO_STRING_IMPL(float)
- DOCTEST_TYPE_TO_STRING_IMPL(double)
- DOCTEST_TYPE_TO_STRING_IMPL(long double)
- DOCTEST_TYPE_TO_STRING_IMPL(char)
- DOCTEST_TYPE_TO_STRING_IMPL(signed char)
- DOCTEST_TYPE_TO_STRING_IMPL(unsigned char)
- DOCTEST_TYPE_TO_STRING_IMPL(wchar_t)
- DOCTEST_TYPE_TO_STRING_IMPL(short int)
- DOCTEST_TYPE_TO_STRING_IMPL(unsigned short int)
- DOCTEST_TYPE_TO_STRING_IMPL(int)
- DOCTEST_TYPE_TO_STRING_IMPL(unsigned int)
- DOCTEST_TYPE_TO_STRING_IMPL(long int)
- DOCTEST_TYPE_TO_STRING_IMPL(unsigned long int)
-#ifdef DOCTEST_CONFIG_WITH_LONG_LONG
- DOCTEST_TYPE_TO_STRING_IMPL(long long int)
- DOCTEST_TYPE_TO_STRING_IMPL(unsigned long long int)
-#endif // DOCTEST_CONFIG_WITH_LONG_LONG
-} // namespace detail
-} // namespace doctest
-
-#endif // DOCTEST_LIBRARY_INCLUDED
-
-#if defined(__clang__)
-#pragma clang diagnostic pop
-#endif // __clang__
-
-#if defined(__GNUC__) && !defined(__clang__)
-#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 6)
-#pragma GCC diagnostic pop
-#endif // > gcc 4.6
-#endif // __GNUC__
-
-#ifdef _MSC_VER
-#pragma warning(pop)
-#endif // _MSC_VER
-
-#ifndef DOCTEST_SINGLE_HEADER
-#define DOCTEST_SINGLE_HEADER
-#endif // DOCTEST_SINGLE_HEADER
-
-#if defined(__clang__)
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wunknown-pragmas"
-#pragma clang diagnostic ignored "-Wpadded"
-#pragma clang diagnostic ignored "-Wglobal-constructors"
-#pragma clang diagnostic ignored "-Wexit-time-destructors"
-#pragma clang diagnostic ignored "-Wmissing-prototypes"
-#pragma clang diagnostic ignored "-Wsign-conversion"
-#pragma clang diagnostic ignored "-Wshorten-64-to-32"
-#pragma clang diagnostic ignored "-Wmissing-variable-declarations"
-#pragma clang diagnostic ignored "-Wswitch"
-#pragma clang diagnostic ignored "-Wswitch-enum"
-#pragma clang diagnostic ignored "-Wcovered-switch-default"
-#pragma clang diagnostic ignored "-Wmissing-noreturn"
-#pragma clang diagnostic ignored "-Wunused-local-typedef"
-#pragma clang diagnostic ignored "-Wdisabled-macro-expansion"
-#pragma clang diagnostic ignored "-Wmissing-braces"
-#pragma clang diagnostic ignored "-Wmissing-field-initializers"
-#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant"
-#pragma clang diagnostic ignored "-Wc++11-long-long"
-#endif // __clang__
-
-#if defined(__GNUC__) && !defined(__clang__)
-#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 6)
-#pragma GCC diagnostic push
-#endif // > gcc 4.6
-#pragma GCC diagnostic ignored "-Wunknown-pragmas"
-#pragma GCC diagnostic ignored "-Wconversion"
-#pragma GCC diagnostic ignored "-Weffc++"
-#pragma GCC diagnostic ignored "-Wsign-conversion"
-#pragma GCC diagnostic ignored "-Wstrict-overflow"
-#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
-#pragma GCC diagnostic ignored "-Wmissing-braces"
-#pragma GCC diagnostic ignored "-Wmissing-declarations"
-#pragma GCC diagnostic ignored "-Winline"
-#pragma GCC diagnostic ignored "-Wswitch"
-#pragma GCC diagnostic ignored "-Wswitch-enum"
-#pragma GCC diagnostic ignored "-Wswitch-default"
-#pragma GCC diagnostic ignored "-Wunsafe-loop-optimizations"
-#pragma GCC diagnostic ignored "-Wlong-long"
-#pragma GCC diagnostic ignored "-Wold-style-cast"
-#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 6)
-#pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
-#endif // > gcc 4.6
-#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 7)
-#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
-#endif // > gcc 4.7
-#if __GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ > 3)
-#pragma GCC diagnostic ignored "-Wuseless-cast"
-#endif // > gcc 5.3
-#endif // __GNUC__
-
-#ifdef _MSC_VER
-#pragma warning(push)
-#pragma warning(disable : 4996) // The compiler encountered a deprecated declaration
-#pragma warning(disable : 4267) // 'var' : conversion from 'size_t' to 'type', possible loss of data
-#pragma warning(disable : 4706) // assignment within conditional expression
-#pragma warning(disable : 4512) // 'class' : assignment operator could not be generated
-#pragma warning(disable : 4127) // conditional expression is constant
-#pragma warning(disable : 4530) // C++ exception handler used, but unwind semantics are not enabled
-#pragma warning(disable : 4577) // 'noexcept' used with no exception handling mode specified
-#endif // _MSC_VER
-
-#if defined(DOCTEST_CONFIG_IMPLEMENT) || !defined(DOCTEST_SINGLE_HEADER)
-#ifndef DOCTEST_LIBRARY_IMPLEMENTATION
-#define DOCTEST_LIBRARY_IMPLEMENTATION
-
-#ifndef DOCTEST_SINGLE_HEADER
-#include "doctest_fwd.h"
-#endif // DOCTEST_SINGLE_HEADER
-
-#if defined(__clang__) && defined(DOCTEST_NO_CPP11_COMPAT)
-#pragma clang diagnostic ignored "-Wc++98-compat"
-#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
-#endif // __clang__ && DOCTEST_NO_CPP11_COMPAT
-
-// snprintf() not in the C++98 standard
-#ifdef _MSC_VER
-#define DOCTEST_SNPRINTF _snprintf
-#else
-#define DOCTEST_SNPRINTF std::snprintf
-#endif
-
-#define DOCTEST_LOG_START() \
- do { \
- if(!contextState->hasLoggedCurrentTestStart) { \
- logTestStart(*contextState->currentTest); \
- contextState->hasLoggedCurrentTestStart = true; \
- } \
- } while(false)
-
-// required includes - will go only in one translation unit!
-#include <ctime>
-#include <cmath>
-// borland (Embarcadero) compiler requires math.h and not cmath - https://github.com/onqtam/doctest/pull/37
-#ifdef __BORLANDC__
-#include <math.h>
-#endif // __BORLANDC__
-#include <new>
-#include <cstdio>
-#include <cstdlib>
-#include <cstring>
-#include <limits>
-#include <utility>
-#include <sstream>
-#include <iomanip>
-#include <vector>
-#include <set>
-#include <exception>
-#include <stdexcept>
-#include <csignal>
-#include <cfloat>
-#ifndef _MSC_VER
-#include <stdint.h>
-#endif // _MSC_VER
-
-namespace doctest
-{
-namespace detail
-{
- // lowers ascii letters
- char tolower(const char c) { return (c >= 'A' && c <= 'Z') ? static_cast<char>(c + 32) : c; }
-
- template <typename T>
- T my_max(const T& lhs, const T& rhs) {
- return lhs > rhs ? lhs : rhs;
- }
-
- // case insensitive strcmp
- int stricmp(char const* a, char const* b) {
- for(;; a++, b++) {
- const int d = tolower(*a) - tolower(*b);
- if(d != 0 || !*a)
- return d;
- }
- }
-
- void my_memcpy(void* dest, const void* src, unsigned num) {
- const char* csrc = static_cast<const char*>(src);
- char* cdest = static_cast<char*>(dest);
- for(unsigned i = 0; i < num; ++i)
- cdest[i] = csrc[i];
- }
-
- // not using std::strlen() because of valgrind errors when optimizations are turned on
- // 'Invalid read of size 4' when the test suite len (with '\0') is not a multiple of 4
- // for details see http://stackoverflow.com/questions/35671155
- unsigned my_strlen(const char* in) {
- const char* temp = in;
- while(temp && *temp)
- ++temp;
- return unsigned(temp - in);
- }
-
- template <typename T>
- String fpToString(T value, int precision) {
- std::ostringstream oss;
- oss << std::setprecision(precision) << std::fixed << value;
- std::string d = oss.str();
- size_t i = d.find_last_not_of('0');
- if(i != std::string::npos && i != d.size() - 1) {
- if(d[i] == '.')
- i++;
- d = d.substr(0, i + 1);
- }
- return d.c_str();
- }
-
- struct Endianness
- {
- enum Arch
- {
- Big,
- Little
- };
-
- static Arch which() {
- union _
- {
- int asInt;
- char asChar[sizeof(int)];
- } u;
-
- u.asInt = 1; // NOLINT
- return (u.asChar[sizeof(int) - 1] == 1) ? Big : Little; // NOLINT
- }
- };
-
- String rawMemoryToString(const void* object, unsigned size) {
- // Reverse order for little endian architectures
- int i = 0, end = static_cast<int>(size), inc = 1;
- if(Endianness::which() == Endianness::Little) {
- i = end - 1;
- end = inc = -1;
- }
-
- unsigned char const* bytes = static_cast<unsigned char const*>(object);
- std::ostringstream os;
- os << "0x" << std::setfill('0') << std::hex;
- for(; i != end; i += inc)
- os << std::setw(2) << static_cast<unsigned>(bytes[i]);
- return os.str().c_str();
- }
-
- std::ostream* createStream() { return new std::ostringstream(); }
- String getStreamResult(std::ostream* in) {
- return static_cast<std::ostringstream*>(in)->str().c_str(); // NOLINT
- }
- void freeStream(std::ostream* in) { delete in; }
-
-#ifndef DOCTEST_CONFIG_DISABLE
-
- // this holds both parameters for the command line and runtime data for tests
- struct ContextState : TestAccessibleContextState //!OCLINT too many fields
- {
- // == parameters from the command line
-
- std::vector<std::vector<String> > filters;
-
- String order_by; // how tests should be ordered
- unsigned rand_seed; // the seed for rand ordering
-
- unsigned first; // the first (matching) test to be executed
- unsigned last; // the last (matching) test to be executed
-
- int abort_after; // stop tests after this many failed assertions
- int subcase_filter_levels; // apply the subcase filters for the first N levels
- bool case_sensitive; // if filtering should be case sensitive
- bool exit; // if the program should be exited after the tests are ran/whatever
- bool duration; // print the time duration of each test case
- bool no_exitcode; // if the framework should return 0 as the exitcode
- bool no_run; // to not run the tests at all (can be done with an "*" exclude)
- bool no_version; // to not print the version of the framework
- bool no_colors; // if output to the console should be colorized
- bool force_colors; // forces the use of colors even when a tty cannot be detected
- bool no_breaks; // to not break into the debugger
- bool no_skip; // don't skip test cases which are marked to be skipped
- bool no_path_in_filenames; // if the path to files should be removed from the output
- bool no_line_numbers; // if source code line numbers should be omitted from the output
- bool no_skipped_summary; // don't print "skipped" in the summary !!! UNDOCUMENTED !!!
-
- bool help; // to print the help
- bool version; // to print the version
- bool count; // if only the count of matching tests is to be retreived
- bool list_test_cases; // to list all tests matching the filters
- bool list_test_suites; // to list all suites matching the filters
-
- // == data for the tests being ran
-
- unsigned numTestsPassingFilters;
- unsigned numTestSuitesPassingFilters;
- unsigned numFailed;
- const TestCase* currentTest;
- bool hasLoggedCurrentTestStart;
- int numAssertionsForCurrentTestcase;
- int numAssertions;
- int numFailedAssertionsForCurrentTestcase;
- int numFailedAssertions;
- bool hasCurrentTestFailed;
-
- std::vector<IContextScope*> contexts; // for logging with INFO() and friends
- std::vector<std::string> exceptionalContexts; // logging from INFO() due to an exception
-
- // stuff for subcases
- std::set<SubcaseSignature> subcasesPassed;
- std::set<int> subcasesEnteredLevels;
- std::vector<Subcase> subcasesStack;
- int subcasesCurrentLevel;
- bool subcasesHasSkipped;
-
- void resetRunData() {
- numTestsPassingFilters = 0;
- numTestSuitesPassingFilters = 0;
- numFailed = 0;
- numAssertions = 0;
- numFailedAssertions = 0;
- numFailedAssertionsForCurrentTestcase = 0;
- }
-
- // cppcheck-suppress uninitMemberVar
- ContextState()
- : filters(8) // 8 different filters total
- {
- resetRunData();
- }
- };
-
- ContextState* contextState = 0;
-#endif // DOCTEST_CONFIG_DISABLE
-} // namespace detail
-
-void String::copy(const String& other) {
- if(other.isOnStack()) {
- detail::my_memcpy(buf, other.buf, len);
- } else {
- setOnHeap();
- data.size = other.data.size;
- data.capacity = data.size + 1;
- data.ptr = new char[data.capacity];
- detail::my_memcpy(data.ptr, other.data.ptr, data.size + 1);
- }
-}
-
-String::String(const char* in) {
- unsigned in_len = detail::my_strlen(in);
- if(in_len <= last) {
- detail::my_memcpy(buf, in, in_len + 1);
- setLast(last - in_len);
- } else {
- setOnHeap();
- data.size = in_len;
- data.capacity = data.size + 1;
- data.ptr = new char[data.capacity];
- detail::my_memcpy(data.ptr, in, in_len + 1);
- }
-}
-
-String& String::operator+=(const String& other) {
- const unsigned my_old_size = size();
- const unsigned other_size = other.size();
- const unsigned total_size = my_old_size + other_size;
- if(isOnStack()) {
- if(total_size < len) {
- // append to the current stack space
- detail::my_memcpy(buf + my_old_size, other.c_str(), other_size + 1);
- setLast(last - total_size);
- } else {
- // alloc new chunk
- char* temp = new char[total_size + 1];
- // copy current data to new location before writing in the union
- detail::my_memcpy(temp, buf, my_old_size); // skip the +1 ('\0') for speed
- // update data in union
- setOnHeap();
- data.size = total_size;
- data.capacity = data.size + 1;
- data.ptr = temp;
- // transfer the rest of the data
- detail::my_memcpy(data.ptr + my_old_size, other.c_str(), other_size + 1);
- }
- } else {
- if(data.capacity > total_size) {
- // append to the current heap block
- data.size = total_size;
- detail::my_memcpy(data.ptr + my_old_size, other.c_str(), other_size + 1);
- } else {
- // resize
- data.capacity *= 2;
- if(data.capacity <= total_size)
- data.capacity = total_size + 1;
- // alloc new chunk
- char* temp = new char[data.capacity];
- // copy current data to new location before releasing it
- detail::my_memcpy(temp, data.ptr, my_old_size); // skip the +1 ('\0') for speed
- // release old chunk
- delete[] data.ptr;
- // update the rest of the union members
- data.size = total_size;
- data.ptr = temp;
- // transfer the rest of the data
- detail::my_memcpy(data.ptr + my_old_size, other.c_str(), other_size + 1);
- }
- }
-
- return *this;
-}
-
-#ifdef DOCTEST_CONFIG_WITH_RVALUE_REFERENCES
-String::String(String&& other) {
- detail::my_memcpy(buf, other.buf, len);
- other.buf[0] = '\0';
- other.setLast();
-}
-
-String& String::operator=(String&& other) {
- if(this != &other) {
- if(!isOnStack())
- delete[] data.ptr;
- detail::my_memcpy(buf, other.buf, len);
- other.buf[0] = '\0';
- other.setLast();
- }
- return *this;
-}
-#endif // DOCTEST_CONFIG_WITH_RVALUE_REFERENCES
-
-int String::compare(const char* other, bool no_case) const {
- if(no_case)
- return detail::stricmp(c_str(), other);
- return std::strcmp(c_str(), other);
-}
-
-int String::compare(const String& other, bool no_case) const {
- return compare(other.c_str(), no_case);
-}
-
-std::ostream& operator<<(std::ostream& stream, const String& in) {
- stream << in.c_str();
- return stream;
-}
-
-Approx::Approx(double value)
- : m_epsilon(static_cast<double>(std::numeric_limits<float>::epsilon()) * 100)
- , m_scale(1.0)
- , m_value(value) {}
-
-bool operator==(double lhs, Approx const& rhs) {
- // Thanks to Richard Harris for his help refining this formula
- return std::fabs(lhs - rhs.m_value) <
- rhs.m_epsilon * (rhs.m_scale + detail::my_max(std::fabs(lhs), std::fabs(rhs.m_value)));
-}
-
-String Approx::toString() const { return String("Approx( ") + doctest::toString(m_value) + " )"; }
-
-#ifdef DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING
-String toString(char* in) { return toString(static_cast<const char*>(in)); }
-String toString(const char* in) { return String("\"") + (in ? in : "{null string}") + "\""; }
-#endif // DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING
-String toString(bool in) { return in ? "true" : "false"; }
-String toString(float in) { return detail::fpToString(in, 5) + "f"; }
-String toString(double in) { return detail::fpToString(in, 10); }
-String toString(double long in) { return detail::fpToString(in, 15); }
-
-String toString(char in) {
- char buf[64];
- std::sprintf(buf, "%d", in);
- return buf;
-}
-
-String toString(char signed in) {
- char buf[64];
- std::sprintf(buf, "%d", in);
- return buf;
-}
-
-String toString(char unsigned in) {
- char buf[64];
- std::sprintf(buf, "%ud", in);
- return buf;
-}
-
-String toString(int short in) {
- char buf[64];
- std::sprintf(buf, "%d", in);
- return buf;
-}
-
-String toString(int short unsigned in) {
- char buf[64];
- std::sprintf(buf, "%u", in);
- return buf;
-}
-
-String toString(int in) {
- char buf[64];
- std::sprintf(buf, "%d", in);
- return buf;
-}
-
-String toString(int unsigned in) {
- char buf[64];
- std::sprintf(buf, "%u", in);
- return buf;
-}
-
-String toString(int long in) {
- char buf[64];
- std::sprintf(buf, "%ld", in);
- return buf;
-}
-
-String toString(int long unsigned in) {
- char buf[64];
- std::sprintf(buf, "%lu", in);
- return buf;
-}
-
-#ifdef DOCTEST_CONFIG_WITH_LONG_LONG
-String toString(int long long in) {
- char buf[64];
- std::sprintf(buf, "%lld", in);
- return buf;
-}
-String toString(int long long unsigned in) {
- char buf[64];
- std::sprintf(buf, "%llu", in);
- return buf;
-}
-#endif // DOCTEST_CONFIG_WITH_LONG_LONG
-
-#ifdef DOCTEST_CONFIG_WITH_NULLPTR
-String toString(std::nullptr_t) { return "nullptr"; }
-#endif // DOCTEST_CONFIG_WITH_NULLPTR
-
-} // namespace doctest
-
-#ifdef DOCTEST_CONFIG_DISABLE
-namespace doctest
-{
-bool isRunningInTest() { return false; }
-Context::Context(int, const char* const*) {}
-Context::~Context() {}
-void Context::applyCommandLine(int, const char* const*) {}
-void Context::addFilter(const char*, const char*) {}
-void Context::clearFilters() {}
-void Context::setOption(const char*, int) {}
-void Context::setOption(const char*, const char*) {}
-bool Context::shouldExit() { return false; }
-int Context::run() { return 0; }
-} // namespace doctest
-#else // DOCTEST_CONFIG_DISABLE
-
-#if !defined(DOCTEST_CONFIG_COLORS_NONE)
-#if !defined(DOCTEST_CONFIG_COLORS_WINDOWS) && !defined(DOCTEST_CONFIG_COLORS_ANSI)
-#ifdef DOCTEST_PLATFORM_WINDOWS
-#define DOCTEST_CONFIG_COLORS_WINDOWS
-#else // linux
-#define DOCTEST_CONFIG_COLORS_ANSI
-#endif // platform
-#endif // DOCTEST_CONFIG_COLORS_WINDOWS && DOCTEST_CONFIG_COLORS_ANSI
-#endif // DOCTEST_CONFIG_COLORS_NONE
-
-#define DOCTEST_PRINTF_COLORED(buffer, color) \
- do { \
- Color col(color); \
- std::printf("%s", buffer); \
- } while((void)0, 0)
-
-// the buffer size used for snprintf() calls
-#if !defined(DOCTEST_SNPRINTF_BUFFER_LENGTH)
-#define DOCTEST_SNPRINTF_BUFFER_LENGTH 1024
-#endif // DOCTEST_SNPRINTF_BUFFER_LENGTH
-
-#if defined(_MSC_VER) || defined(__MINGW32__)
-#if defined(_MSC_VER) && _MSC_VER >= 1700
-#define DOCTEST_WINDOWS_SAL_IN_OPT _In_opt_
-#else // _MSC_VER
-#define DOCTEST_WINDOWS_SAL_IN_OPT
-#endif // _MSC_VER
-extern "C" __declspec(dllimport) void __stdcall OutputDebugStringA(
- DOCTEST_WINDOWS_SAL_IN_OPT const char*);
-extern "C" __declspec(dllimport) int __stdcall IsDebuggerPresent();
-#endif // _MSC_VER || __MINGW32__
-
-#ifdef DOCTEST_CONFIG_COLORS_ANSI
-#include <unistd.h>
-#endif // DOCTEST_CONFIG_COLORS_ANSI
-
-#ifdef _WIN32
-
-// defines for a leaner windows.h
-#ifndef WIN32_MEAN_AND_LEAN
-#define WIN32_MEAN_AND_LEAN
-#endif // WIN32_MEAN_AND_LEAN
-#ifndef VC_EXTRA_LEAN
-#define VC_EXTRA_LEAN
-#endif // VC_EXTRA_LEAN
-#ifndef NOMINMAX
-#define NOMINMAX
-#endif // NOMINMAX
-
-// not sure what AfxWin.h is for - here I do what Catch does
-#ifdef __AFXDLL
-#include <AfxWin.h>
-#else
-#include <windows.h>
-#endif
-#include <io.h>
-
-#else // _WIN32
-
-#include <sys/time.h>
-
-#endif // _WIN32
-
-namespace doctest_detail_test_suite_ns
-{
-// holds the current test suite
-doctest::detail::TestSuite& getCurrentTestSuite() {
- static doctest::detail::TestSuite data;
- return data;
-}
-} // namespace doctest_detail_test_suite_ns
-
-namespace doctest
-{
-namespace detail
-{
- TestCase::TestCase(funcType test, const char* file, unsigned line, const TestSuite& test_suite,
- const char* type, int template_id)
- : m_test(test)
- , m_name(0)
- , m_type(type)
- , m_test_suite(test_suite.m_test_suite)
- , m_description(test_suite.m_description)
- , m_skip(test_suite.m_skip)
- , m_may_fail(test_suite.m_may_fail)
- , m_should_fail(test_suite.m_should_fail)
- , m_expected_failures(test_suite.m_expected_failures)
- , m_timeout(test_suite.m_timeout)
- , m_file(file)
- , m_line(line)
- , m_template_id(template_id) {}
-
- TestCase& TestCase::operator*(const char* in) {
- m_name = in;
- // make a new name with an appended type for templated test case
- if(m_template_id != -1) {
- m_full_name = String(m_name) + m_type;
- // redirect the name to point to the newly constructed full name
- m_name = m_full_name.c_str();
- }
- return *this;
- }
-
- TestCase& TestCase::operator=(const TestCase& other) {
- m_test = other.m_test;
- m_full_name = other.m_full_name;
- m_name = other.m_name;
- m_type = other.m_type;
- m_test_suite = other.m_test_suite;
- m_description = other.m_description;
- m_skip = other.m_skip;
- m_may_fail = other.m_may_fail;
- m_should_fail = other.m_should_fail;
- m_expected_failures = other.m_expected_failures;
- m_timeout = other.m_timeout;
- m_file = other.m_file;
- m_line = other.m_line;
- m_template_id = other.m_template_id;
-
- if(m_template_id != -1)
- m_name = m_full_name.c_str();
- return *this;
- }
-
- bool TestCase::operator<(const TestCase& other) const {
- if(m_line != other.m_line)
- return m_line < other.m_line;
- const int file_cmp = std::strcmp(m_file, other.m_file);
- if(file_cmp != 0)
- return file_cmp < 0;
- return m_template_id < other.m_template_id;
- }
-
- const char* getAssertString(assertType::Enum val) {
- switch(val) { //!OCLINT missing default in switch statements
- // clang-format off
- case assertType::DT_WARN : return "WARN";
- case assertType::DT_CHECK : return "CHECK";
- case assertType::DT_REQUIRE : return "REQUIRE";
-
- case assertType::DT_WARN_FALSE : return "WARN_FALSE";
- case assertType::DT_CHECK_FALSE : return "CHECK_FALSE";
- case assertType::DT_REQUIRE_FALSE : return "REQUIRE_FALSE";
-
- case assertType::DT_WARN_THROWS : return "WARN_THROWS";
- case assertType::DT_CHECK_THROWS : return "CHECK_THROWS";
- case assertType::DT_REQUIRE_THROWS : return "REQUIRE_THROWS";
-
- case assertType::DT_WARN_THROWS_AS : return "WARN_THROWS_AS";
- case assertType::DT_CHECK_THROWS_AS : return "CHECK_THROWS_AS";
- case assertType::DT_REQUIRE_THROWS_AS : return "REQUIRE_THROWS_AS";
-
- case assertType::DT_WARN_NOTHROW : return "WARN_NOTHROW";
- case assertType::DT_CHECK_NOTHROW : return "CHECK_NOTHROW";
- case assertType::DT_REQUIRE_NOTHROW : return "REQUIRE_NOTHROW";
-
- case assertType::DT_WARN_EQ : return "WARN_EQ";
- case assertType::DT_CHECK_EQ : return "CHECK_EQ";
- case assertType::DT_REQUIRE_EQ : return "REQUIRE_EQ";
- case assertType::DT_WARN_NE : return "WARN_NE";
- case assertType::DT_CHECK_NE : return "CHECK_NE";
- case assertType::DT_REQUIRE_NE : return "REQUIRE_NE";
- case assertType::DT_WARN_GT : return "WARN_GT";
- case assertType::DT_CHECK_GT : return "CHECK_GT";
- case assertType::DT_REQUIRE_GT : return "REQUIRE_GT";
- case assertType::DT_WARN_LT : return "WARN_LT";
- case assertType::DT_CHECK_LT : return "CHECK_LT";
- case assertType::DT_REQUIRE_LT : return "REQUIRE_LT";
- case assertType::DT_WARN_GE : return "WARN_GE";
- case assertType::DT_CHECK_GE : return "CHECK_GE";
- case assertType::DT_REQUIRE_GE : return "REQUIRE_GE";
- case assertType::DT_WARN_LE : return "WARN_LE";
- case assertType::DT_CHECK_LE : return "CHECK_LE";
- case assertType::DT_REQUIRE_LE : return "REQUIRE_LE";
-
- case assertType::DT_WARN_UNARY : return "WARN_UNARY";
- case assertType::DT_CHECK_UNARY : return "CHECK_UNARY";
- case assertType::DT_REQUIRE_UNARY : return "REQUIRE_UNARY";
- case assertType::DT_WARN_UNARY_FALSE : return "WARN_UNARY_FALSE";
- case assertType::DT_CHECK_UNARY_FALSE : return "CHECK_UNARY_FALSE";
- case assertType::DT_REQUIRE_UNARY_FALSE : return "REQUIRE_UNARY_FALSE";
-
- case assertType::DT_FAST_WARN_EQ : return "FAST_WARN_EQ";
- case assertType::DT_FAST_CHECK_EQ : return "FAST_CHECK_EQ";
- case assertType::DT_FAST_REQUIRE_EQ : return "FAST_REQUIRE_EQ";
- case assertType::DT_FAST_WARN_NE : return "FAST_WARN_NE";
- case assertType::DT_FAST_CHECK_NE : return "FAST_CHECK_NE";
- case assertType::DT_FAST_REQUIRE_NE : return "FAST_REQUIRE_NE";
- case assertType::DT_FAST_WARN_GT : return "FAST_WARN_GT";
- case assertType::DT_FAST_CHECK_GT : return "FAST_CHECK_GT";
- case assertType::DT_FAST_REQUIRE_GT : return "FAST_REQUIRE_GT";
- case assertType::DT_FAST_WARN_LT : return "FAST_WARN_LT";
- case assertType::DT_FAST_CHECK_LT : return "FAST_CHECK_LT";
- case assertType::DT_FAST_REQUIRE_LT : return "FAST_REQUIRE_LT";
- case assertType::DT_FAST_WARN_GE : return "FAST_WARN_GE";
- case assertType::DT_FAST_CHECK_GE : return "FAST_CHECK_GE";
- case assertType::DT_FAST_REQUIRE_GE : return "FAST_REQUIRE_GE";
- case assertType::DT_FAST_WARN_LE : return "FAST_WARN_LE";
- case assertType::DT_FAST_CHECK_LE : return "FAST_CHECK_LE";
- case assertType::DT_FAST_REQUIRE_LE : return "FAST_REQUIRE_LE";
-
- case assertType::DT_FAST_WARN_UNARY : return "FAST_WARN_UNARY";
- case assertType::DT_FAST_CHECK_UNARY : return "FAST_CHECK_UNARY";
- case assertType::DT_FAST_REQUIRE_UNARY : return "FAST_REQUIRE_UNARY";
- case assertType::DT_FAST_WARN_UNARY_FALSE : return "FAST_WARN_UNARY_FALSE";
- case assertType::DT_FAST_CHECK_UNARY_FALSE : return "FAST_CHECK_UNARY_FALSE";
- case assertType::DT_FAST_REQUIRE_UNARY_FALSE: return "FAST_REQUIRE_UNARY_FALSE";
- // clang-format on
- }
- return "";
- }
-
- bool checkIfShouldThrow(assertType::Enum assert_type) {
- if(assert_type & assertType::is_require) //!OCLINT bitwise operator in conditional
- return true;
-
- if((assert_type & assertType::is_check) //!OCLINT bitwise operator in conditional
- && contextState->abort_after > 0 &&
- contextState->numFailedAssertions >= contextState->abort_after)
- return true;
-
- return false;
- }
- void fastAssertThrowIfFlagSet(int flags) {
- if(flags & assertAction::shouldthrow) //!OCLINT bitwise operator in conditional
- throwException();
- }
- void throwException() {
-#ifndef DOCTEST_CONFIG_NO_EXCEPTIONS
- throw TestFailureException();
-#endif // DOCTEST_CONFIG_NO_EXCEPTIONS
- }
-
- // matching of a string against a wildcard mask (case sensitivity configurable) taken from
- // http://www.emoticode.net/c/simple-wildcard-string-compare-globbing-function.html
- int wildcmp(const char* str, const char* wild, bool caseSensitive) {
- const char* cp = 0;
- const char* mp = 0;
-
- // rolled my own tolower() to not include more headers
- while((*str) && (*wild != '*')) {
- if((caseSensitive ? (*wild != *str) : (tolower(*wild) != tolower(*str))) &&
- (*wild != '?')) {
- return 0;
- }
- wild++;
- str++;
- }
-
- while(*str) {
- if(*wild == '*') {
- if(!*++wild) {
- return 1;
- }
- mp = wild;
- cp = str + 1;
- } else if((caseSensitive ? (*wild == *str) : (tolower(*wild) == tolower(*str))) ||
- (*wild == '?')) {
- wild++;
- str++;
- } else {
- wild = mp; //!OCLINT parameter reassignment
- str = cp++; //!OCLINT parameter reassignment
- }
- }
-
- while(*wild == '*') {
- wild++;
- }
- return !*wild;
- }
-
- //// C string hash function (djb2) - taken from http://www.cse.yorku.ca/~oz/hash.html
- //unsigned hashStr(unsigned const char* str) {
- // unsigned long hash = 5381;
- // char c;
- // while((c = *str++))
- // hash = ((hash << 5) + hash) + c; // hash * 33 + c
- // return hash;
- //}
-
- // checks if the name matches any of the filters (and can be configured what to do when empty)
- bool matchesAny(const char* name, const std::vector<String>& filters, int matchEmpty,
- bool caseSensitive) {
- if(filters.empty() && matchEmpty)
- return true;
- for(unsigned i = 0; i < filters.size(); ++i)
- if(wildcmp(name, filters[i].c_str(), caseSensitive))
- return true;
- return false;
- }
-
-#ifdef _WIN32
-
- typedef unsigned long long UInt64;
-
- UInt64 getCurrentTicks() {
- static UInt64 hz = 0, hzo = 0;
- if(!hz) {
- QueryPerformanceFrequency(reinterpret_cast<LARGE_INTEGER*>(&hz));
- QueryPerformanceCounter(reinterpret_cast<LARGE_INTEGER*>(&hzo));
- }
- UInt64 t;
- QueryPerformanceCounter(reinterpret_cast<LARGE_INTEGER*>(&t));
- return ((t - hzo) * 1000000) / hz;
- }
-#else // _WIN32
-
- typedef uint64_t UInt64;
-
- UInt64 getCurrentTicks() {
- timeval t;
- gettimeofday(&t, 0);
- return static_cast<UInt64>(t.tv_sec) * 1000000 + static_cast<UInt64>(t.tv_usec);
- }
-#endif // _WIN32
-
- class Timer
- {
- public:
- Timer()
- : m_ticks(0) {}
- void start() { m_ticks = getCurrentTicks(); }
- unsigned int getElapsedMicroseconds() const {
- return static_cast<unsigned int>(getCurrentTicks() - m_ticks);
- }
- unsigned int getElapsedMilliseconds() const {
- return static_cast<unsigned int>(getElapsedMicroseconds() / 1000);
- }
- double getElapsedSeconds() const { return getElapsedMicroseconds() / 1000000.0; }
-
- private:
- UInt64 m_ticks;
- };
-
- TestAccessibleContextState* getTestsContextState() { return contextState; }
-
- bool SubcaseSignature::operator<(const SubcaseSignature& other) const {
- if(m_line != other.m_line)
- return m_line < other.m_line;
- if(std::strcmp(m_file, other.m_file) != 0)
- return std::strcmp(m_file, other.m_file) < 0;
- return std::strcmp(m_name, other.m_name) < 0;
- }
-
- Subcase::Subcase(const char* name, const char* file, int line)
- : m_signature(name, file, line)
- , m_entered(false) {
- ContextState* s = contextState;
-
- // if we have already completed it
- if(s->subcasesPassed.count(m_signature) != 0)
- return;
-
- // check subcase filters
- if(s->subcasesCurrentLevel < s->subcase_filter_levels) {
- if(!matchesAny(m_signature.m_name, s->filters[6], 1, s->case_sensitive))
- return;
- if(matchesAny(m_signature.m_name, s->filters[7], 0, s->case_sensitive))
- return;
- }
-
- // if a Subcase on the same level has already been entered
- if(s->subcasesEnteredLevels.count(s->subcasesCurrentLevel) != 0) {
- s->subcasesHasSkipped = true;
- return;
- }
-
- s->subcasesStack.push_back(*this);
- if(s->hasLoggedCurrentTestStart)
- logTestEnd();
- s->hasLoggedCurrentTestStart = false;
-
- s->subcasesEnteredLevels.insert(s->subcasesCurrentLevel++);
- m_entered = true;
- }
-
- Subcase::Subcase(const Subcase& other)
- : m_signature(other.m_signature.m_name, other.m_signature.m_file,
- other.m_signature.m_line)
- , m_entered(other.m_entered) {}
-
- Subcase::~Subcase() {
- if(m_entered) {
- ContextState* s = contextState;
-
- s->subcasesCurrentLevel--;
- // only mark the subcase as passed if no subcases have been skipped
- if(s->subcasesHasSkipped == false)
- s->subcasesPassed.insert(m_signature);
-
- if(!s->subcasesStack.empty())
- s->subcasesStack.pop_back();
- if(s->hasLoggedCurrentTestStart)
- logTestEnd();
- s->hasLoggedCurrentTestStart = false;
- }
- }
-
- Result::~Result() {}
-
- Result& Result::operator=(const Result& other) {
- m_passed = other.m_passed;
- m_decomposition = other.m_decomposition;
-
- return *this;
- }
-
- // for sorting tests by file/line
- int fileOrderComparator(const void* a, const void* b) {
- const TestCase* lhs = *static_cast<TestCase* const*>(a);
- const TestCase* rhs = *static_cast<TestCase* const*>(b);
-#ifdef _MSC_VER
- // this is needed because MSVC gives different case for drive letters
- // for __FILE__ when evaluated in a header and a source file
- const int res = stricmp(lhs->m_file, rhs->m_file);
-#else // _MSC_VER
- const int res = std::strcmp(lhs->m_file, rhs->m_file);
-#endif // _MSC_VER
- if(res != 0)
- return res;
- return static_cast<int>(lhs->m_line - rhs->m_line);
- }
-
- // for sorting tests by suite/file/line
- int suiteOrderComparator(const void* a, const void* b) {
- const TestCase* lhs = *static_cast<TestCase* const*>(a);
- const TestCase* rhs = *static_cast<TestCase* const*>(b);
-
- const int res = std::strcmp(lhs->m_test_suite, rhs->m_test_suite);
- if(res != 0)
- return res;
- return fileOrderComparator(a, b);
- }
-
- // for sorting tests by name/suite/file/line
- int nameOrderComparator(const void* a, const void* b) {
- const TestCase* lhs = *static_cast<TestCase* const*>(a);
- const TestCase* rhs = *static_cast<TestCase* const*>(b);
-
- const int res_name = std::strcmp(lhs->m_name, rhs->m_name);
- if(res_name != 0)
- return res_name;
- return suiteOrderComparator(a, b);
- }
-
- // sets the current test suite
- int setTestSuite(const TestSuite& ts) {
- doctest_detail_test_suite_ns::getCurrentTestSuite() = ts;
- return 0;
- }
-
- // all the registered tests
- std::set<TestCase>& getRegisteredTests() {
- static std::set<TestCase> data;
- return data;
- }
-
- // used by the macros for registering tests
- int regTest(const TestCase& tc) {
- getRegisteredTests().insert(tc);
- return 0;
- }
-
- struct Color
- {
- enum Code
- {
- None = 0,
- White,
- Red,
- Green,
- Blue,
- Cyan,
- Yellow,
- Grey,
-
- Bright = 0x10,
-
- BrightRed = Bright | Red,
- BrightGreen = Bright | Green,
- LightGrey = Bright | Grey,
- BrightWhite = Bright | White
- };
- explicit Color(Code code) { use(code); }
- ~Color() { use(None); }
-
- static void use(Code code);
- static void init();
- };
-
-#ifdef DOCTEST_CONFIG_COLORS_WINDOWS
- HANDLE g_stdoutHandle;
- WORD g_originalForegroundAttributes;
- WORD g_originalBackgroundAttributes;
- bool g_attrsInitted = false;
-#endif // DOCTEST_CONFIG_COLORS_WINDOWS
-
- void Color::init() {
-#ifdef DOCTEST_CONFIG_COLORS_WINDOWS
- if(!g_attrsInitted) {
- g_stdoutHandle = GetStdHandle(STD_OUTPUT_HANDLE);
- g_attrsInitted = true;
- CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
- GetConsoleScreenBufferInfo(g_stdoutHandle, &csbiInfo);
- g_originalForegroundAttributes =
- csbiInfo.wAttributes &
- ~(BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_BLUE | BACKGROUND_INTENSITY);
- g_originalBackgroundAttributes =
- csbiInfo.wAttributes &
- ~(FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_INTENSITY);
- }
-#endif // DOCTEST_CONFIG_COLORS_WINDOWS
- }
-
- void Color::use(Code
-#ifndef DOCTEST_CONFIG_COLORS_NONE
- code
-#endif // DOCTEST_CONFIG_COLORS_NONE
- ) {
- const ContextState* p = contextState;
- if(p->no_colors)
- return;
-#ifdef DOCTEST_CONFIG_COLORS_ANSI
- if(isatty(STDOUT_FILENO) == false && p->force_colors == false)
- return;
-
- const char* col = "";
- // clang-format off
- switch(code) { //!OCLINT missing break in switch statement / unnecessary default statement in covered switch statement
- case Color::Red: col = "[0;31m"; break;
- case Color::Green: col = "[0;32m"; break;
- case Color::Blue: col = "[0;34m"; break;
- case Color::Cyan: col = "[0;36m"; break;
- case Color::Yellow: col = "[0;33m"; break;
- case Color::Grey: col = "[1;30m"; break;
- case Color::LightGrey: col = "[0;37m"; break;
- case Color::BrightRed: col = "[1;31m"; break;
- case Color::BrightGreen: col = "[1;32m"; break;
- case Color::BrightWhite: col = "[1;37m"; break;
- case Color::Bright: // invalid
- case Color::None:
- case Color::White:
- default: col = "[0m";
- }
- // clang-format on
- std::printf("\033%s", col);
-#endif // DOCTEST_CONFIG_COLORS_ANSI
-
-#ifdef DOCTEST_CONFIG_COLORS_WINDOWS
- if(isatty(fileno(stdout)) == false && p->force_colors == false)
- return;
-
-#define DOCTEST_SET_ATTR(x) \
- SetConsoleTextAttribute(g_stdoutHandle, x | g_originalBackgroundAttributes)
-
- // clang-format off
- switch (code) {
- case Color::White: DOCTEST_SET_ATTR(FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE); break;
- case Color::Red: DOCTEST_SET_ATTR(FOREGROUND_RED); break;
- case Color::Green: DOCTEST_SET_ATTR(FOREGROUND_GREEN); break;
- case Color::Blue: DOCTEST_SET_ATTR(FOREGROUND_BLUE); break;
- case Color::Cyan: DOCTEST_SET_ATTR(FOREGROUND_BLUE | FOREGROUND_GREEN); break;
- case Color::Yellow: DOCTEST_SET_ATTR(FOREGROUND_RED | FOREGROUND_GREEN); break;
- case Color::Grey: DOCTEST_SET_ATTR(0); break;
- case Color::LightGrey: DOCTEST_SET_ATTR(FOREGROUND_INTENSITY); break;
- case Color::BrightRed: DOCTEST_SET_ATTR(FOREGROUND_INTENSITY | FOREGROUND_RED); break;
- case Color::BrightGreen: DOCTEST_SET_ATTR(FOREGROUND_INTENSITY | FOREGROUND_GREEN); break;
- case Color::BrightWhite: DOCTEST_SET_ATTR(FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE); break;
- case Color::None:
- case Color::Bright: // invalid
- default: DOCTEST_SET_ATTR(g_originalForegroundAttributes);
- }
-// clang-format on
-#undef DOCTEST_SET_ATTR
-#endif // DOCTEST_CONFIG_COLORS_WINDOWS
- }
-
- std::vector<const IExceptionTranslator*>& getExceptionTranslators() {
- static std::vector<const IExceptionTranslator*> data;
- return data;
- }
-
- void registerExceptionTranslatorImpl(const IExceptionTranslator* translateFunction) {
- getExceptionTranslators().push_back(translateFunction);
- }
-
- String translateActiveException() {
-#ifndef DOCTEST_CONFIG_NO_EXCEPTIONS
- String res;
- std::vector<const IExceptionTranslator*>& translators = getExceptionTranslators();
- for(size_t i = 0; i < translators.size(); ++i)
- if(translators[i]->translate(res))
- return res;
- // clang-format off
- try {
- throw;
- } catch(std::exception& ex) {
- return ex.what();
- } catch(std::string& msg) {
- return msg.c_str();
- } catch(const char* msg) {
- return msg;
- } catch(...) {
- return "unknown exception";
- }
-// clang-format on
-#else // DOCTEST_CONFIG_NO_EXCEPTIONS
- return "";
-#endif // DOCTEST_CONFIG_NO_EXCEPTIONS
- }
-
- void writeStringToStream(std::ostream* stream, const String& str) { *stream << str; }
-
-#ifdef DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING
- void toStream(std::ostream* stream, char* in) { *stream << in; }
- void toStream(std::ostream* stream, const char* in) { *stream << in; }
-#endif // DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING
- void toStream(std::ostream* stream, bool in) {
- *stream << std::boolalpha << in << std::noboolalpha;
- }
- void toStream(std::ostream* stream, float in) { *stream << in; }
- void toStream(std::ostream* stream, double in) { *stream << in; }
- void toStream(std::ostream* stream, double long in) { *stream << in; }
-
- void toStream(std::ostream* stream, char in) { *stream << in; }
- void toStream(std::ostream* stream, char signed in) { *stream << in; }
- void toStream(std::ostream* stream, char unsigned in) { *stream << in; }
- void toStream(std::ostream* stream, int short in) { *stream << in; }
- void toStream(std::ostream* stream, int short unsigned in) { *stream << in; }
- void toStream(std::ostream* stream, int in) { *stream << in; }
- void toStream(std::ostream* stream, int unsigned in) { *stream << in; }
- void toStream(std::ostream* stream, int long in) { *stream << in; }
- void toStream(std::ostream* stream, int long unsigned in) { *stream << in; }
-
-#ifdef DOCTEST_CONFIG_WITH_LONG_LONG
- void toStream(std::ostream* stream, int long long in) { *stream << in; }
- void toStream(std::ostream* stream, int long long unsigned in) { *stream << in; }
-#endif // DOCTEST_CONFIG_WITH_LONG_LONG
-
- void addToContexts(IContextScope* ptr) { contextState->contexts.push_back(ptr); }
- void popFromContexts() { contextState->contexts.pop_back(); }
-#if defined(_MSC_VER)
-#pragma warning(push)
-#pragma warning(disable : 4996) // std::uncaught_exception is deprecated in C++17
-#endif
- void useContextIfExceptionOccurred(IContextScope* ptr) {
- if(std::uncaught_exception()) {
- std::ostringstream stream;
- ptr->build(&stream);
- contextState->exceptionalContexts.push_back(stream.str());
- }
- }
-#if defined(_MSC_VER)
-#pragma warning(pop)
-#endif
-
- void printSummary();
-
-#if !defined(DOCTEST_CONFIG_POSIX_SIGNALS) && !defined(DOCTEST_CONFIG_WINDOWS_SEH)
- void reportFatal(const std::string&) {}
- struct FatalConditionHandler
- {
- void reset() {}
- };
-#else // DOCTEST_CONFIG_POSIX_SIGNALS || DOCTEST_CONFIG_WINDOWS_SEH
-
- void reportFatal(const std::string& message) {
- DOCTEST_LOG_START();
-
- contextState->numAssertions += contextState->numAssertionsForCurrentTestcase;
- logTestException(message.c_str(), true);
- logTestEnd();
- contextState->numFailed++;
-
- printSummary();
- }
-
-#ifdef DOCTEST_PLATFORM_WINDOWS
-
- struct SignalDefs
- {
- DWORD id;
- const char* name;
- };
- // There is no 1-1 mapping between signals and windows exceptions.
- // Windows can easily distinguish between SO and SigSegV,
- // but SigInt, SigTerm, etc are handled differently.
- SignalDefs signalDefs[] = {
- {EXCEPTION_ILLEGAL_INSTRUCTION, "SIGILL - Illegal instruction signal"},
- {EXCEPTION_STACK_OVERFLOW, "SIGSEGV - Stack overflow"},
- {EXCEPTION_ACCESS_VIOLATION, "SIGSEGV - Segmentation violation signal"},
- {EXCEPTION_INT_DIVIDE_BY_ZERO, "Divide by zero error"},
- };
-
- struct FatalConditionHandler
- {
- static LONG CALLBACK handleVectoredException(PEXCEPTION_POINTERS ExceptionInfo) {
- for(size_t i = 0; i < sizeof(signalDefs) / sizeof(SignalDefs); ++i) {
- if(ExceptionInfo->ExceptionRecord->ExceptionCode == signalDefs[i].id) {
- reportFatal(signalDefs[i].name);
- }
- }
- // If its not an exception we care about, pass it along.
- // This stops us from eating debugger breaks etc.
- return EXCEPTION_CONTINUE_SEARCH;
- }
-
- FatalConditionHandler() {
- isSet = true;
- // 32k seems enough for doctest to handle stack overflow,
- // but the value was found experimentally, so there is no strong guarantee
- guaranteeSize = 32 * 1024;
- exceptionHandlerHandle = 0;
- // Register as first handler in current chain
- exceptionHandlerHandle = AddVectoredExceptionHandler(1, handleVectoredException);
- // Pass in guarantee size to be filled
- SetThreadStackGuarantee(&guaranteeSize);
- }
-
- static void reset() {
- if(isSet) {
- // Unregister handler and restore the old guarantee
- RemoveVectoredExceptionHandler(exceptionHandlerHandle);
- SetThreadStackGuarantee(&guaranteeSize);
- exceptionHandlerHandle = 0;
- isSet = false;
- }
- }
-
- ~FatalConditionHandler() { reset(); }
-
- private:
- static bool isSet;
- static ULONG guaranteeSize;
- static PVOID exceptionHandlerHandle;
- };
-
- bool FatalConditionHandler::isSet = false;
- ULONG FatalConditionHandler::guaranteeSize = 0;
- PVOID FatalConditionHandler::exceptionHandlerHandle = 0;
-
-#else // DOCTEST_PLATFORM_WINDOWS
-
- struct SignalDefs
- {
- int id;
- const char* name;
- };
- SignalDefs signalDefs[] = {{SIGINT, "SIGINT - Terminal interrupt signal"},
- {SIGILL, "SIGILL - Illegal instruction signal"},
- {SIGFPE, "SIGFPE - Floating point error signal"},
- {SIGSEGV, "SIGSEGV - Segmentation violation signal"},
- {SIGTERM, "SIGTERM - Termination request signal"},
- {SIGABRT, "SIGABRT - Abort (abnormal termination) signal"}};
-
- struct FatalConditionHandler
- {
- static bool isSet;
- static struct sigaction oldSigActions[sizeof(signalDefs) / sizeof(SignalDefs)];
- static stack_t oldSigStack;
- static char altStackMem[SIGSTKSZ];
-
- static void handleSignal(int sig) {
- std::string name = "<unknown signal>";
- for(std::size_t i = 0; i < sizeof(signalDefs) / sizeof(SignalDefs); ++i) {
- SignalDefs& def = signalDefs[i];
- if(sig == def.id) {
- name = def.name;
- break;
- }
- }
- reset();
- reportFatal(name);
- raise(sig);
- }
-
- FatalConditionHandler() {
- isSet = true;
- stack_t sigStack;
- sigStack.ss_sp = altStackMem;
- sigStack.ss_size = SIGSTKSZ;
- sigStack.ss_flags = 0;
- sigaltstack(&sigStack, &oldSigStack);
- struct sigaction sa = {0};
-
- sa.sa_handler = handleSignal; // NOLINT
- sa.sa_flags = SA_ONSTACK;
- for(std::size_t i = 0; i < sizeof(signalDefs) / sizeof(SignalDefs); ++i) {
- sigaction(signalDefs[i].id, &sa, &oldSigActions[i]);
- }
- }
-
- ~FatalConditionHandler() { reset(); }
- static void reset() {
- if(isSet) {
- // Set signals back to previous values -- hopefully nobody overwrote them in the meantime
- for(std::size_t i = 0; i < sizeof(signalDefs) / sizeof(SignalDefs); ++i) {
- sigaction(signalDefs[i].id, &oldSigActions[i], 0);
- }
- // Return the old stack
- sigaltstack(&oldSigStack, 0);
- isSet = false;
- }
- }
- };
-
- bool FatalConditionHandler::isSet = false;
- struct sigaction FatalConditionHandler::oldSigActions[sizeof(signalDefs) / sizeof(SignalDefs)] =
- {};
- stack_t FatalConditionHandler::oldSigStack = {};
- char FatalConditionHandler::altStackMem[SIGSTKSZ] = {};
-
-#endif // DOCTEST_PLATFORM_WINDOWS
-#endif // DOCTEST_CONFIG_POSIX_SIGNALS || DOCTEST_CONFIG_WINDOWS_SEH
-
- // depending on the current options this will remove the path of filenames
- const char* fileForOutput(const char* file) {
- if(contextState->no_path_in_filenames) {
- const char* back = std::strrchr(file, '\\');
- const char* forward = std::strrchr(file, '/');
- if(back || forward) {
- if(back > forward)
- forward = back;
- return forward + 1;
- }
- }
- return file;
- }
-
- // depending on the current options this will substitute the line numbers with 0
- int lineForOutput(int line) {
- if(contextState->no_line_numbers)
- return 0;
- return line;
- }
-
-#ifdef DOCTEST_PLATFORM_MAC
-#include <sys/types.h>
-#include <unistd.h>
-#include <sys/sysctl.h>
- // The following function is taken directly from the following technical note:
- // http://developer.apple.com/library/mac/#qa/qa2004/qa1361.html
- // Returns true if the current process is being debugged (either
- // running under the debugger or has a debugger attached post facto).
- bool isDebuggerActive() {
- int mib[4];
- kinfo_proc info;
- size_t size;
- // Initialize the flags so that, if sysctl fails for some bizarre
- // reason, we get a predictable result.
- info.kp_proc.p_flag = 0;
- // Initialize mib, which tells sysctl the info we want, in this case
- // we're looking for information about a specific process ID.
- mib[0] = CTL_KERN;
- mib[1] = KERN_PROC;
- mib[2] = KERN_PROC_PID;
- mib[3] = getpid();
- // Call sysctl.
- size = sizeof(info);
- if(sysctl(mib, sizeof(mib) / sizeof(*mib), &info, &size, 0, 0) != 0) {
- fprintf(stderr, "\n** Call to sysctl failed - unable to determine if debugger is "
- "active **\n\n");
- return false;
- }
- // We're being debugged if the P_TRACED flag is set.
- return ((info.kp_proc.p_flag & P_TRACED) != 0);
- }
-#elif defined(_MSC_VER) || defined(__MINGW32__)
- bool isDebuggerActive() { return ::IsDebuggerPresent() != 0; }
-#else
- bool isDebuggerActive() { return false; }
-#endif // Platform
-
-#ifdef DOCTEST_PLATFORM_WINDOWS
- void myOutputDebugString(const String& text) { ::OutputDebugStringA(text.c_str()); }
-#else
- // TODO: integration with XCode and other IDEs
- void myOutputDebugString(const String&) {}
-#endif // Platform
-
- const char* getSeparator() {
- return "===============================================================================\n";
- }
-
- void printToDebugConsole(const String& text) {
- if(isDebuggerActive())
- myOutputDebugString(text.c_str());
- }
-
- void addFailedAssert(assertType::Enum assert_type) {
- if((assert_type & assertType::is_warn) == 0) { //!OCLINT bitwise operator in conditional
- contextState->numFailedAssertions++;
- contextState->numFailedAssertionsForCurrentTestcase++;
- contextState->hasCurrentTestFailed = true;
- }
- }
-
- void logTestStart(const TestCase& tc) {
- char loc[DOCTEST_SNPRINTF_BUFFER_LENGTH];
- DOCTEST_SNPRINTF(loc, DOCTEST_COUNTOF(loc), "%s(%d)\n", fileForOutput(tc.m_file),
- lineForOutput(tc.m_line));
-
- char ts1[DOCTEST_SNPRINTF_BUFFER_LENGTH];
- DOCTEST_SNPRINTF(ts1, DOCTEST_COUNTOF(ts1), "TEST SUITE: ");
- char ts2[DOCTEST_SNPRINTF_BUFFER_LENGTH];
- DOCTEST_SNPRINTF(ts2, DOCTEST_COUNTOF(ts2), "%s\n", tc.m_test_suite);
- char n1[DOCTEST_SNPRINTF_BUFFER_LENGTH];
- DOCTEST_SNPRINTF(n1, DOCTEST_COUNTOF(n1), "TEST CASE: ");
- char n2[DOCTEST_SNPRINTF_BUFFER_LENGTH];
- DOCTEST_SNPRINTF(n2, DOCTEST_COUNTOF(n2), "%s\n", tc.m_name);
- char d1[DOCTEST_SNPRINTF_BUFFER_LENGTH];
- DOCTEST_SNPRINTF(d1, DOCTEST_COUNTOF(d1), "DESCRIPTION: ");
- char d2[DOCTEST_SNPRINTF_BUFFER_LENGTH];
- DOCTEST_SNPRINTF(d2, DOCTEST_COUNTOF(d2), "%s\n", tc.m_description);
-
- // hack for BDD style of macros - to not print "TEST CASE:"
- char scenario[] = " Scenario:";
- if(std::string(tc.m_name).substr(0, DOCTEST_COUNTOF(scenario) - 1) == scenario)
- n1[0] = '\0';
-
- DOCTEST_PRINTF_COLORED(getSeparator(), Color::Yellow);
- DOCTEST_PRINTF_COLORED(loc, Color::LightGrey);
-
- String forDebugConsole;
- if(tc.m_description) {
- DOCTEST_PRINTF_COLORED(d1, Color::Yellow);
- DOCTEST_PRINTF_COLORED(d2, Color::None);
- forDebugConsole += d1;
- forDebugConsole += d2;
- }
- if(tc.m_test_suite[0] != '\0') {
- DOCTEST_PRINTF_COLORED(ts1, Color::Yellow);
- DOCTEST_PRINTF_COLORED(ts2, Color::None);
- forDebugConsole += ts1;
- forDebugConsole += ts2;
- }
- DOCTEST_PRINTF_COLORED(n1, Color::Yellow);
- DOCTEST_PRINTF_COLORED(n2, Color::None);
-
- String subcaseStuff;
- std::vector<Subcase>& subcasesStack = contextState->subcasesStack;
- for(unsigned i = 0; i < subcasesStack.size(); ++i) {
- if(subcasesStack[i].m_signature.m_name[0] != '\0') {
- char subcase[DOCTEST_SNPRINTF_BUFFER_LENGTH];
- DOCTEST_SNPRINTF(subcase, DOCTEST_COUNTOF(loc), " %s\n",
- subcasesStack[i].m_signature.m_name);
- DOCTEST_PRINTF_COLORED(subcase, Color::None);
- subcaseStuff += subcase;
- }
- }
-
- DOCTEST_PRINTF_COLORED("\n", Color::None);
-
- printToDebugConsole(String(getSeparator()) + loc + forDebugConsole.c_str() + n1 + n2 +
- subcaseStuff.c_str() + "\n");
- }
-
- void logTestEnd() {}
-
- void logTestException(const String& what, bool crash) {
- char msg[DOCTEST_SNPRINTF_BUFFER_LENGTH];
-
- DOCTEST_SNPRINTF(msg, DOCTEST_COUNTOF(msg), "TEST CASE FAILED!\n");
-
- char info1[DOCTEST_SNPRINTF_BUFFER_LENGTH];
- char info2[DOCTEST_SNPRINTF_BUFFER_LENGTH];
- info1[0] = 0;
- info2[0] = 0;
- DOCTEST_SNPRINTF(info1, DOCTEST_COUNTOF(info1),
- crash ? "crashed:\n" : "threw exception:\n");
- DOCTEST_SNPRINTF(info2, DOCTEST_COUNTOF(info2), " %s\n", what.c_str());
-
- std::string contextStr;
-
- if(!contextState->exceptionalContexts.empty()) {
- contextStr += "with context:\n";
- for(size_t i = contextState->exceptionalContexts.size(); i > 0; --i) {
- contextStr += " ";
- contextStr += contextState->exceptionalContexts[i - 1];
- contextStr += "\n";
- }
- }
-
- DOCTEST_PRINTF_COLORED(msg, Color::Red);
- DOCTEST_PRINTF_COLORED(info1, Color::None);
- DOCTEST_PRINTF_COLORED(info2, Color::Cyan);
- DOCTEST_PRINTF_COLORED(contextStr.c_str(), Color::None);
- DOCTEST_PRINTF_COLORED("\n", Color::None);
-
- printToDebugConsole(String(msg) + info1 + info2 + contextStr.c_str() + "\n");
- }
-
- String logContext() {
- std::ostringstream stream;
- std::vector<IContextScope*>& contexts = contextState->contexts;
- if(!contexts.empty())
- stream << "with context:\n";
- for(size_t i = 0; i < contexts.size(); ++i) {
- stream << " ";
- contexts[i]->build(&stream);
- stream << "\n";
- }
- return stream.str().c_str();
- }
-
- const char* getFailString(assertType::Enum assert_type) {
- if(assert_type & assertType::is_warn) //!OCLINT bitwise operator in conditional
- return "WARNING";
- if(assert_type & assertType::is_check) //!OCLINT bitwise operator in conditional
- return "ERROR";
- if(assert_type & assertType::is_require) //!OCLINT bitwise operator in conditional
- return "FATAL ERROR";
- return "";
- }
-
- void logAssert(bool passed, const char* decomposition, bool threw, const String& exception,
- const char* expr, assertType::Enum assert_type, const char* file, int line) {
- char loc[DOCTEST_SNPRINTF_BUFFER_LENGTH];
- DOCTEST_SNPRINTF(loc, DOCTEST_COUNTOF(loc), "%s(%d)", fileForOutput(file),
- lineForOutput(line));
-
- char msg[DOCTEST_SNPRINTF_BUFFER_LENGTH];
- DOCTEST_SNPRINTF(msg, DOCTEST_COUNTOF(msg), " %s!\n",
- passed ? "PASSED" : getFailString(assert_type));
-
- char info1[DOCTEST_SNPRINTF_BUFFER_LENGTH];
- DOCTEST_SNPRINTF(info1, DOCTEST_COUNTOF(info1), " %s( %s )\n",
- getAssertString(assert_type), expr);
-
- char info2[DOCTEST_SNPRINTF_BUFFER_LENGTH];
- char info3[DOCTEST_SNPRINTF_BUFFER_LENGTH];
- info2[0] = 0;
- info3[0] = 0;
- if(threw) {
- DOCTEST_SNPRINTF(info2, DOCTEST_COUNTOF(info2), "threw exception:\n");
- DOCTEST_SNPRINTF(info3, DOCTEST_COUNTOF(info3), " %s\n", exception.c_str());
- } else {
- DOCTEST_SNPRINTF(info2, DOCTEST_COUNTOF(info2), "with expansion:\n");
- DOCTEST_SNPRINTF(info3, DOCTEST_COUNTOF(info3), " %s( %s )\n",
- getAssertString(assert_type), decomposition);
- }
-
- const bool isWarn = assert_type & assertType::is_warn;
- DOCTEST_PRINTF_COLORED(loc, Color::LightGrey);
- DOCTEST_PRINTF_COLORED(msg,
- passed ? Color::BrightGreen : isWarn ? Color::Yellow : Color::Red);
- DOCTEST_PRINTF_COLORED(info1, Color::Cyan);
- DOCTEST_PRINTF_COLORED(info2, Color::None);
- DOCTEST_PRINTF_COLORED(info3, Color::Cyan);
- String context = logContext();
- DOCTEST_PRINTF_COLORED(context.c_str(), Color::None);
- DOCTEST_PRINTF_COLORED("\n", Color::None);
-
- printToDebugConsole(String(loc) + msg + info1 + info2 + info3 + context.c_str() + "\n");
- }
-
- void logAssertThrows(bool threw, const char* expr, assertType::Enum assert_type,
- const char* file, int line) {
- char loc[DOCTEST_SNPRINTF_BUFFER_LENGTH];
- DOCTEST_SNPRINTF(loc, DOCTEST_COUNTOF(loc), "%s(%d)", fileForOutput(file),
- lineForOutput(line));
-
- char msg[DOCTEST_SNPRINTF_BUFFER_LENGTH];
- DOCTEST_SNPRINTF(msg, DOCTEST_COUNTOF(msg), " %s!\n",
- threw ? "PASSED" : getFailString(assert_type));
-
- char info1[DOCTEST_SNPRINTF_BUFFER_LENGTH];
- DOCTEST_SNPRINTF(info1, DOCTEST_COUNTOF(info1), " %s( %s )\n",
- getAssertString(assert_type), expr);
-
- char info2[DOCTEST_SNPRINTF_BUFFER_LENGTH];
- info2[0] = 0;
-
- if(!threw)
- DOCTEST_SNPRINTF(info2, DOCTEST_COUNTOF(info2), "didn't throw at all\n");
-
- const bool isWarn = assert_type & assertType::is_warn;
- DOCTEST_PRINTF_COLORED(loc, Color::LightGrey);
- DOCTEST_PRINTF_COLORED(msg,
- threw ? Color::BrightGreen : isWarn ? Color::Yellow : Color::Red);
- DOCTEST_PRINTF_COLORED(info1, Color::Cyan);
- DOCTEST_PRINTF_COLORED(info2, Color::None);
- String context = logContext();
- DOCTEST_PRINTF_COLORED(context.c_str(), Color::None);
- DOCTEST_PRINTF_COLORED("\n", Color::None);
-
- printToDebugConsole(String(loc) + msg + info1 + info2 + context.c_str() + "\n");
- }
-
- void logAssertThrowsAs(bool threw, bool threw_as, const char* as, const String& exception,
- const char* expr, assertType::Enum assert_type, const char* file,
- int line) {
- char loc[DOCTEST_SNPRINTF_BUFFER_LENGTH];
- DOCTEST_SNPRINTF(loc, DOCTEST_COUNTOF(loc), "%s(%d)", fileForOutput(file),
- lineForOutput(line));
-
- char msg[DOCTEST_SNPRINTF_BUFFER_LENGTH];
- DOCTEST_SNPRINTF(msg, DOCTEST_COUNTOF(msg), " %s!\n",
- threw_as ? "PASSED" : getFailString(assert_type));
-
- char info1[DOCTEST_SNPRINTF_BUFFER_LENGTH];
- DOCTEST_SNPRINTF(info1, DOCTEST_COUNTOF(info1), " %s( %s, %s )\n",
- getAssertString(assert_type), expr, as);
-
- char info2[DOCTEST_SNPRINTF_BUFFER_LENGTH];
- char info3[DOCTEST_SNPRINTF_BUFFER_LENGTH];
- info2[0] = 0;
- info3[0] = 0;
-
- if(!threw) { //!OCLINT inverted logic
- DOCTEST_SNPRINTF(info2, DOCTEST_COUNTOF(info2), "didn't throw at all\n");
- } else if(!threw_as) {
- DOCTEST_SNPRINTF(info2, DOCTEST_COUNTOF(info2), "threw a different exception:\n");
- DOCTEST_SNPRINTF(info3, DOCTEST_COUNTOF(info3), " %s\n", exception.c_str());
- }
-
- const bool isWarn = assert_type & assertType::is_warn;
- DOCTEST_PRINTF_COLORED(loc, Color::LightGrey);
- DOCTEST_PRINTF_COLORED(msg,
- threw_as ? Color::BrightGreen : isWarn ? Color::Yellow : Color::Red);
- DOCTEST_PRINTF_COLORED(info1, Color::Cyan);
- DOCTEST_PRINTF_COLORED(info2, Color::None);
- DOCTEST_PRINTF_COLORED(info3, Color::Cyan);
- String context = logContext();
- DOCTEST_PRINTF_COLORED(context.c_str(), Color::None);
- DOCTEST_PRINTF_COLORED("\n", Color::None);
-
- printToDebugConsole(String(loc) + msg + info1 + info2 + info3 + context.c_str() + "\n");
- }
-
- void logAssertNothrow(bool threw, const String& exception, const char* expr,
- assertType::Enum assert_type, const char* file, int line) {
- char loc[DOCTEST_SNPRINTF_BUFFER_LENGTH];
- DOCTEST_SNPRINTF(loc, DOCTEST_COUNTOF(loc), "%s(%d)", fileForOutput(file),
- lineForOutput(line));
-
- char msg[DOCTEST_SNPRINTF_BUFFER_LENGTH];
- DOCTEST_SNPRINTF(msg, DOCTEST_COUNTOF(msg), " %s!\n",
- threw ? getFailString(assert_type) : "PASSED");
-
- char info1[DOCTEST_SNPRINTF_BUFFER_LENGTH];
- DOCTEST_SNPRINTF(info1, DOCTEST_COUNTOF(info1), " %s( %s )\n",
- getAssertString(assert_type), expr);
-
- char info2[DOCTEST_SNPRINTF_BUFFER_LENGTH];
- char info3[DOCTEST_SNPRINTF_BUFFER_LENGTH];
- info2[0] = 0;
- info3[0] = 0;
- if(threw) {
- DOCTEST_SNPRINTF(info2, DOCTEST_COUNTOF(info2), "threw exception:\n");
- DOCTEST_SNPRINTF(info3, DOCTEST_COUNTOF(info3), " %s\n", exception.c_str());
- }
-
- const bool isWarn = assert_type & assertType::is_warn;
- DOCTEST_PRINTF_COLORED(loc, Color::LightGrey);
- DOCTEST_PRINTF_COLORED(msg,
- threw ? isWarn ? Color::Yellow : Color::Red : Color::BrightGreen);
- DOCTEST_PRINTF_COLORED(info1, Color::Cyan);
- DOCTEST_PRINTF_COLORED(info2, Color::None);
- DOCTEST_PRINTF_COLORED(info3, Color::Cyan);
- String context = logContext();
- DOCTEST_PRINTF_COLORED(context.c_str(), Color::None);
- DOCTEST_PRINTF_COLORED("\n", Color::None);
-
- printToDebugConsole(String(loc) + msg + info1 + info2 + info3 + context.c_str() + "\n");
- }
-
- ResultBuilder::ResultBuilder(assertType::Enum assert_type, const char* file, int line,
- const char* expr, const char* exception_type)
- : m_assert_type(assert_type)
- , m_file(file)
- , m_line(line)
- , m_expr(expr)
- , m_exception_type(exception_type)
- , m_threw(false)
- , m_threw_as(false)
- , m_failed(false) {
-#ifdef _MSC_VER
- if(m_expr[0] == ' ') // this happens when variadic macros are disabled under MSVC
- ++m_expr;
-#endif // _MSC_VER
- }
-
- ResultBuilder::~ResultBuilder() {}
-
- void ResultBuilder::unexpectedExceptionOccurred() {
- m_threw = true;
-
- m_exception = translateActiveException();
- }
-
- bool ResultBuilder::log() {
- if((m_assert_type & assertType::is_warn) == 0) //!OCLINT bitwise operator in conditional
- contextState->numAssertionsForCurrentTestcase++;
-
- if(m_assert_type & assertType::is_throws) { //!OCLINT bitwise operator in conditional
- m_failed = !m_threw;
- } else if(m_assert_type & //!OCLINT bitwise operator in conditional
- assertType::is_throws_as) {
- m_failed = !m_threw_as;
- } else if(m_assert_type & //!OCLINT bitwise operator in conditional
- assertType::is_nothrow) {
- m_failed = m_threw;
- } else {
- m_failed = m_result;
- }
-
- if(m_failed || contextState->success) {
- DOCTEST_LOG_START();
-
- if(m_assert_type & assertType::is_throws) { //!OCLINT bitwise operator in conditional
- logAssertThrows(m_threw, m_expr, m_assert_type, m_file, m_line);
- } else if(m_assert_type & //!OCLINT bitwise operator in conditional
- assertType::is_throws_as) {
- logAssertThrowsAs(m_threw, m_threw_as, m_exception_type, m_exception, m_expr,
- m_assert_type, m_file, m_line);
- } else if(m_assert_type & //!OCLINT bitwise operator in conditional
- assertType::is_nothrow) {
- logAssertNothrow(m_threw, m_exception, m_expr, m_assert_type, m_file, m_line);
- } else {
- logAssert(m_result.m_passed, m_result.m_decomposition.c_str(), m_threw, m_exception,
- m_expr, m_assert_type, m_file, m_line);
- }
- }
-
- if(m_failed)
- addFailedAssert(m_assert_type);
-
- return m_failed && isDebuggerActive() && !contextState->no_breaks; // break into debugger
- }
-
- void ResultBuilder::react() const {
- if(m_failed && checkIfShouldThrow(m_assert_type))
- throwException();
- }
-
- MessageBuilder::MessageBuilder(const char* file, int line, assertType::Enum severity)
- : m_stream(createStream())
- , m_file(file)
- , m_line(line)
- , m_severity(severity) {}
-
- bool MessageBuilder::log() {
- DOCTEST_LOG_START();
-
- const bool isWarn = m_severity & assertType::is_warn;
-
- // warn is just a message in this context so we dont treat it as an assert
- if(!isWarn) {
- contextState->numAssertionsForCurrentTestcase++;
- addFailedAssert(m_severity);
- }
-
- char loc[DOCTEST_SNPRINTF_BUFFER_LENGTH];
- DOCTEST_SNPRINTF(loc, DOCTEST_COUNTOF(loc), "%s(%d)", fileForOutput(m_file),
- lineForOutput(m_line));
- char msg[DOCTEST_SNPRINTF_BUFFER_LENGTH];
- DOCTEST_SNPRINTF(msg, DOCTEST_COUNTOF(msg), " %s!\n",
- isWarn ? "MESSAGE" : getFailString(m_severity));
-
- DOCTEST_PRINTF_COLORED(loc, Color::LightGrey);
- DOCTEST_PRINTF_COLORED(msg, isWarn ? Color::Yellow : Color::Red);
-
- String info = getStreamResult(m_stream);
- if(info.size()) {
- DOCTEST_PRINTF_COLORED(" ", Color::None);
- DOCTEST_PRINTF_COLORED(info.c_str(), Color::None);
- DOCTEST_PRINTF_COLORED("\n", Color::None);
- }
- String context = logContext();
- DOCTEST_PRINTF_COLORED(context.c_str(), Color::None);
- DOCTEST_PRINTF_COLORED("\n", Color::None);
-
- printToDebugConsole(String(loc) + msg + " " + info.c_str() + "\n" + context.c_str() +
- "\n");
-
- return isDebuggerActive() && !contextState->no_breaks && !isWarn; // break into debugger
- }
-
- void MessageBuilder::react() {
- if(m_severity & assertType::is_require) //!OCLINT bitwise operator in conditional
- throwException();
- }
-
- MessageBuilder::~MessageBuilder() { freeStream(m_stream); }
-
- // the implementation of parseFlag()
- bool parseFlagImpl(int argc, const char* const* argv, const char* pattern) {
- for(int i = argc - 1; i >= 0; --i) {
- const char* temp = std::strstr(argv[i], pattern);
- if(temp && my_strlen(temp) == my_strlen(pattern)) {
- // eliminate strings in which the chars before the option are not '-'
- bool noBadCharsFound = true; //!OCLINT prefer early exits and continue
- while(temp != argv[i]) {
- if(*--temp != '-') {
- noBadCharsFound = false;
- break;
- }
- }
- if(noBadCharsFound && argv[i][0] == '-')
- return true;
- }
- }
- return false;
- }
-
- // locates a flag on the command line
- bool parseFlag(int argc, const char* const* argv, const char* pattern) {
-#ifndef DOCTEST_CONFIG_NO_UNPREFIXED_OPTIONS
- if(!parseFlagImpl(argc, argv, pattern))
- return parseFlagImpl(argc, argv, pattern + 3); // 3 for "dt-"
- return true;
-#else // DOCTEST_CONFIG_NO_UNPREFIXED_OPTIONS
- return parseFlagImpl(argc, argv, pattern);
-#endif // DOCTEST_CONFIG_NO_UNPREFIXED_OPTIONS
- }
-
- // the implementation of parseOption()
- bool parseOptionImpl(int argc, const char* const* argv, const char* pattern, String& res) {
- for(int i = argc - 1; i >= 0; --i) {
- const char* temp = std::strstr(argv[i], pattern);
- if(temp) { //!OCLINT prefer early exits and continue
- // eliminate matches in which the chars before the option are not '-'
- bool noBadCharsFound = true;
- const char* curr = argv[i];
- while(curr != temp) {
- if(*curr++ != '-') {
- noBadCharsFound = false;
- break;
- }
- }
- if(noBadCharsFound && argv[i][0] == '-') {
- temp += my_strlen(pattern);
- const unsigned len = my_strlen(temp);
- if(len) {
- res = temp;
- return true;
- }
- }
- }
- }
- return false;
- }
-
- // parses an option and returns the string after the '=' character
- bool parseOption(int argc, const char* const* argv, const char* pattern, String& res,
- const String& defaultVal = String()) {
- res = defaultVal;
-#ifndef DOCTEST_CONFIG_NO_UNPREFIXED_OPTIONS
- if(!parseOptionImpl(argc, argv, pattern, res))
- return parseOptionImpl(argc, argv, pattern + 3, res); // 3 for "dt-"
- return true;
-#else // DOCTEST_CONFIG_NO_UNPREFIXED_OPTIONS
- return parseOptionImpl(argc, argv, pattern, res);
-#endif // DOCTEST_CONFIG_NO_UNPREFIXED_OPTIONS
- }
-
- // parses a comma separated list of words after a pattern in one of the arguments in argv
- bool parseCommaSepArgs(int argc, const char* const* argv, const char* pattern,
- std::vector<String>& res) {
- String filtersString;
- if(parseOption(argc, argv, pattern, filtersString)) {
- // tokenize with "," as a separator
- // cppcheck-suppress strtokCalled
- char* pch = std::strtok(filtersString.c_str(), ","); // modifies the string
- while(pch != 0) {
- if(my_strlen(pch))
- res.push_back(pch);
- // uses the strtok() internal state to go to the next token
- // cppcheck-suppress strtokCalled
- pch = std::strtok(0, ",");
- }
- return true;
- }
- return false;
- }
-
- enum optionType
- {
- option_bool,
- option_int
- };
-
- // parses an int/bool option from the command line
- bool parseIntOption(int argc, const char* const* argv, const char* pattern, optionType type,
- int& res) {
- String parsedValue;
- if(!parseOption(argc, argv, pattern, parsedValue))
- return false;
-
- if(type == 0) {
- // boolean
- const char positive[][5] = {"1", "true", "on", "yes"}; // 5 - strlen("true") + 1
- const char negative[][6] = {"0", "false", "off", "no"}; // 6 - strlen("false") + 1
-
- // if the value matches any of the positive/negative possibilities
- for(unsigned i = 0; i < 4; i++) {
- if(parsedValue.compare(positive[i], true) == 0) {
- res = 1; //!OCLINT parameter reassignment
- return true;
- }
- if(parsedValue.compare(negative[i], true) == 0) {
- res = 0; //!OCLINT parameter reassignment
- return true;
- }
- }
- } else {
- // integer
- int theInt = std::atoi(parsedValue.c_str()); // NOLINT
- if(theInt != 0) {
- res = theInt; //!OCLINT parameter reassignment
- return true;
- }
- }
- return false;
- }
-
- void printVersion() {
- if(contextState->no_version == false) {
- DOCTEST_PRINTF_COLORED("[doctest] ", Color::Cyan);
- std::printf("doctest version is \"%s\"\n", DOCTEST_VERSION_STR);
- }
- }
-
- void printHelp() {
- printVersion();
- // clang-format off
- DOCTEST_PRINTF_COLORED("[doctest]\n", Color::Cyan);
- DOCTEST_PRINTF_COLORED("[doctest] ", Color::Cyan);
- std::printf("boolean values: \"1/on/yes/true\" or \"0/off/no/false\"\n");
- DOCTEST_PRINTF_COLORED("[doctest] ", Color::Cyan);
- std::printf("filter values: \"str1,str2,str3\" (comma separated strings)\n");
- DOCTEST_PRINTF_COLORED("[doctest]\n", Color::Cyan);
- DOCTEST_PRINTF_COLORED("[doctest] ", Color::Cyan);
- std::printf("filters use wildcards for matching strings\n");
- DOCTEST_PRINTF_COLORED("[doctest] ", Color::Cyan);
- std::printf("something passes a filter if any of the strings in a filter matches\n");
- DOCTEST_PRINTF_COLORED("[doctest]\n", Color::Cyan);
- DOCTEST_PRINTF_COLORED("[doctest] ", Color::Cyan);
- std::printf("ALL FLAGS, OPTIONS AND FILTERS ALSO AVAILABLE WITH A \"dt-\" PREFIX!!!\n");
- DOCTEST_PRINTF_COLORED("[doctest]\n", Color::Cyan);
- DOCTEST_PRINTF_COLORED("[doctest] ", Color::Cyan);
- std::printf("Query flags - the program quits after them. Available:\n\n");
- std::printf(" -?, --help, -h prints this message\n");
- std::printf(" -v, --version prints the version\n");
- std::printf(" -c, --count prints the number of matching tests\n");
- std::printf(" -ltc, --list-test-cases lists all matching tests by name\n");
- std::printf(" -lts, --list-test-suites lists all matching test suites\n\n");
- // ========================================================================================= << 79
- DOCTEST_PRINTF_COLORED("[doctest] ", Color::Cyan);
- std::printf("The available <int>/<string> options/filters are:\n\n");
- std::printf(" -tc, --test-case=<filters> filters tests by their name\n");
- std::printf(" -tce, --test-case-exclude=<filters> filters OUT tests by their name\n");
- std::printf(" -sf, --source-file=<filters> filters tests by their file\n");
- std::printf(" -sfe, --source-file-exclude=<filters> filters OUT tests by their file\n");
- std::printf(" -ts, --test-suite=<filters> filters tests by their test suite\n");
- std::printf(" -tse, --test-suite-exclude=<filters> filters OUT tests by their test suite\n");
- std::printf(" -sc, --subcase=<filters> filters subcases by their name\n");
- std::printf(" -sce, --subcase-exclude=<filters> filters OUT subcases by their name\n");
- std::printf(" -ob, --order-by=<string> how the tests should be ordered\n");
- std::printf(" <string> - by [file/suite/name/rand]\n");
- std::printf(" -rs, --rand-seed=<int> seed for random ordering\n");
- std::printf(" -f, --first=<int> the first test passing the filters to\n");
- std::printf(" execute - for range-based execution\n");
- std::printf(" -l, --last=<int> the last test passing the filters to\n");
- std::printf(" execute - for range-based execution\n");
- std::printf(" -aa, --abort-after=<int> stop after <int> failed assertions\n");
- std::printf(" -scfl,--subcase-filter-levels=<int> apply filters for the first <int> levels\n");
- DOCTEST_PRINTF_COLORED("\n[doctest] ", Color::Cyan);
- std::printf("Bool options - can be used like flags and true is assumed. Available:\n\n");
- std::printf(" -s, --success=<bool> include successful assertions in output\n");
- std::printf(" -cs, --case-sensitive=<bool> filters being treated as case sensitive\n");
- std::printf(" -e, --exit=<bool> exits after the tests finish\n");
- std::printf(" -d, --duration=<bool> prints the time duration of each test\n");
- std::printf(" -nt, --no-throw=<bool> skips exceptions-related assert checks\n");
- std::printf(" -ne, --no-exitcode=<bool> returns (or exits) always with success\n");
- std::printf(" -nr, --no-run=<bool> skips all runtime doctest operations\n");
- std::printf(" -nv, --no-version=<bool> omit the framework version in the output\n");
- std::printf(" -nc, --no-colors=<bool> disables colors in output\n");
- std::printf(" -fc, --force-colors=<bool> use colors even when not in a tty\n");
- std::printf(" -nb, --no-breaks=<bool> disables breakpoints in debuggers\n");
- std::printf(" -ns, --no-skip=<bool> don't skip test cases marked as skip\n");
- std::printf(" -npf, --no-path-filenames=<bool> only filenames and no paths in output\n");
- std::printf(" -nln, --no-line-numbers=<bool> 0 instead of real line numbers in output\n");
- // ========================================================================================= << 79
- // clang-format on
-
- DOCTEST_PRINTF_COLORED("\n[doctest] ", Color::Cyan);
- std::printf("for more information visit the project documentation\n\n");
- }
-
- void printSummary() {
- const ContextState* p = contextState;
-
- DOCTEST_PRINTF_COLORED(getSeparator(), Color::Yellow);
- if(p->count || p->list_test_cases) {
- DOCTEST_PRINTF_COLORED("[doctest] ", Color::Cyan);
- std::printf("unskipped test cases passing the current filters: %u\n",
- p->numTestsPassingFilters);
- } else if(p->list_test_suites) {
- DOCTEST_PRINTF_COLORED("[doctest] ", Color::Cyan);
- std::printf("unskipped test cases passing the current filters: %u\n",
- p->numTestsPassingFilters);
- DOCTEST_PRINTF_COLORED("[doctest] ", Color::Cyan);
- std::printf("test suites with unskipped test cases passing the current filters: %u\n",
- p->numTestSuitesPassingFilters);
- } else {
- const bool anythingFailed = p->numFailed > 0 || p->numFailedAssertions > 0;
-
- char buff[DOCTEST_SNPRINTF_BUFFER_LENGTH];
-
- DOCTEST_PRINTF_COLORED("[doctest] ", Color::Cyan);
-
- DOCTEST_SNPRINTF(buff, DOCTEST_COUNTOF(buff), "test cases: %6u",
- p->numTestsPassingFilters);
- DOCTEST_PRINTF_COLORED(buff, Color::None);
- DOCTEST_SNPRINTF(buff, DOCTEST_COUNTOF(buff), " | ");
- DOCTEST_PRINTF_COLORED(buff, Color::None);
- DOCTEST_SNPRINTF(buff, DOCTEST_COUNTOF(buff), "%6d passed",
- p->numTestsPassingFilters - p->numFailed);
- DOCTEST_PRINTF_COLORED(buff,
- (p->numTestsPassingFilters == 0 || anythingFailed) ?
- Color::None :
- Color::Green);
- DOCTEST_SNPRINTF(buff, DOCTEST_COUNTOF(buff), " | ");
- DOCTEST_PRINTF_COLORED(buff, Color::None);
- DOCTEST_SNPRINTF(buff, DOCTEST_COUNTOF(buff), "%6u failed", p->numFailed);
- DOCTEST_PRINTF_COLORED(buff, p->numFailed > 0 ? Color::Red : Color::None);
-
- DOCTEST_SNPRINTF(buff, DOCTEST_COUNTOF(buff), " | ");
- DOCTEST_PRINTF_COLORED(buff, Color::None);
- if(p->no_skipped_summary == false) {
- const int numSkipped = static_cast<unsigned>(getRegisteredTests().size()) -
- p->numTestsPassingFilters;
- DOCTEST_SNPRINTF(buff, DOCTEST_COUNTOF(buff), "%6d skipped", numSkipped);
- DOCTEST_PRINTF_COLORED(buff, numSkipped == 0 ? Color::None : Color::Yellow);
- }
- DOCTEST_PRINTF_COLORED("\n", Color::None);
-
- DOCTEST_PRINTF_COLORED("[doctest] ", Color::Cyan);
-
- DOCTEST_SNPRINTF(buff, DOCTEST_COUNTOF(buff), "assertions: %6d", p->numAssertions);
- DOCTEST_PRINTF_COLORED(buff, Color::None);
- DOCTEST_SNPRINTF(buff, DOCTEST_COUNTOF(buff), " | ");
- DOCTEST_PRINTF_COLORED(buff, Color::None);
- DOCTEST_SNPRINTF(buff, DOCTEST_COUNTOF(buff), "%6d passed",
- p->numAssertions - p->numFailedAssertions);
- DOCTEST_PRINTF_COLORED(
- buff, (p->numAssertions == 0 || anythingFailed) ? Color::None : Color::Green);
- DOCTEST_SNPRINTF(buff, DOCTEST_COUNTOF(buff), " | ");
- DOCTEST_PRINTF_COLORED(buff, Color::None);
- DOCTEST_SNPRINTF(buff, DOCTEST_COUNTOF(buff), "%6d failed", p->numFailedAssertions);
- DOCTEST_PRINTF_COLORED(buff, p->numFailedAssertions > 0 ? Color::Red : Color::None);
-
- DOCTEST_SNPRINTF(buff, DOCTEST_COUNTOF(buff), " |\n");
- DOCTEST_PRINTF_COLORED(buff, Color::None);
-
- DOCTEST_PRINTF_COLORED("[doctest] ", Color::Cyan);
- DOCTEST_PRINTF_COLORED("Status: ", Color::None);
- const char* result = (p->numFailed > 0) ? "FAILURE!\n" : "SUCCESS!\n";
- DOCTEST_PRINTF_COLORED(result, p->numFailed > 0 ? Color::Red : Color::Green);
- }
-
- // remove any coloring
- DOCTEST_PRINTF_COLORED("", Color::None);
- }
-} // namespace detail
-
-bool isRunningInTest() { return detail::contextState != 0; }
-
-Context::Context(int argc, const char* const* argv)
- : p(new detail::ContextState) {
- parseArgs(argc, argv, true);
-}
-
-Context::~Context() { delete p; }
-
-void Context::applyCommandLine(int argc, const char* const* argv) { parseArgs(argc, argv); }
-
-// parses args
-void Context::parseArgs(int argc, const char* const* argv, bool withDefaults) {
- using namespace detail;
-
- // clang-format off
- parseCommaSepArgs(argc, argv, "dt-source-file=", p->filters[0]);
- parseCommaSepArgs(argc, argv, "dt-sf=", p->filters[0]);
- parseCommaSepArgs(argc, argv, "dt-source-file-exclude=",p->filters[1]);
- parseCommaSepArgs(argc, argv, "dt-sfe=", p->filters[1]);
- parseCommaSepArgs(argc, argv, "dt-test-suite=", p->filters[2]);
- parseCommaSepArgs(argc, argv, "dt-ts=", p->filters[2]);
- parseCommaSepArgs(argc, argv, "dt-test-suite-exclude=", p->filters[3]);
- parseCommaSepArgs(argc, argv, "dt-tse=", p->filters[3]);
- parseCommaSepArgs(argc, argv, "dt-test-case=", p->filters[4]);
- parseCommaSepArgs(argc, argv, "dt-tc=", p->filters[4]);
- parseCommaSepArgs(argc, argv, "dt-test-case-exclude=", p->filters[5]);
- parseCommaSepArgs(argc, argv, "dt-tce=", p->filters[5]);
- parseCommaSepArgs(argc, argv, "dt-subcase=", p->filters[6]);
- parseCommaSepArgs(argc, argv, "dt-sc=", p->filters[6]);
- parseCommaSepArgs(argc, argv, "dt-subcase-exclude=", p->filters[7]);
- parseCommaSepArgs(argc, argv, "dt-sce=", p->filters[7]);
- // clang-format on
-
- int intRes = 0;
- String strRes;
-
-#define DOCTEST_PARSE_AS_BOOL_OR_FLAG(name, sname, var, default) \
- if(parseIntOption(argc, argv, DOCTEST_STR_CONCAT_TOSTR(name, =), option_bool, intRes) || \
- parseIntOption(argc, argv, DOCTEST_STR_CONCAT_TOSTR(sname, =), option_bool, intRes)) \
- p->var = !!intRes; \
- else if(parseFlag(argc, argv, #name) || parseFlag(argc, argv, #sname)) \
- p->var = true; \
- else if(withDefaults) \
- p->var = default
-
-#define DOCTEST_PARSE_INT_OPTION(name, sname, var, default) \
- if(parseIntOption(argc, argv, DOCTEST_STR_CONCAT_TOSTR(name, =), option_int, intRes) || \
- parseIntOption(argc, argv, DOCTEST_STR_CONCAT_TOSTR(sname, =), option_int, intRes)) \
- p->var = intRes; \
- else if(withDefaults) \
- p->var = default
-
-#define DOCTEST_PARSE_STR_OPTION(name, sname, var, default) \
- if(parseOption(argc, argv, DOCTEST_STR_CONCAT_TOSTR(name, =), strRes, default) || \
- parseOption(argc, argv, DOCTEST_STR_CONCAT_TOSTR(sname, =), strRes, default) || \
- withDefaults) \
- p->var = strRes
-
- // clang-format off
- DOCTEST_PARSE_STR_OPTION(dt-order-by, dt-ob, order_by, "file");
- DOCTEST_PARSE_INT_OPTION(dt-rand-seed, dt-rs, rand_seed, 0);
-
- DOCTEST_PARSE_INT_OPTION(dt-first, dt-f, first, 1);
- DOCTEST_PARSE_INT_OPTION(dt-last, dt-l, last, 0);
-
- DOCTEST_PARSE_INT_OPTION(dt-abort-after, dt-aa, abort_after, 0);
- DOCTEST_PARSE_INT_OPTION(dt-subcase-filter-levels, dt-scfl, subcase_filter_levels, 2000000000);
-
- DOCTEST_PARSE_AS_BOOL_OR_FLAG(dt-success, dt-s, success, false);
- DOCTEST_PARSE_AS_BOOL_OR_FLAG(dt-case-sensitive, dt-cs, case_sensitive, false);
- DOCTEST_PARSE_AS_BOOL_OR_FLAG(dt-exit, dt-e, exit, false);
- DOCTEST_PARSE_AS_BOOL_OR_FLAG(dt-duration, dt-d, duration, false);
- DOCTEST_PARSE_AS_BOOL_OR_FLAG(dt-no-throw, dt-nt, no_throw, false);
- DOCTEST_PARSE_AS_BOOL_OR_FLAG(dt-no-exitcode, dt-ne, no_exitcode, false);
- DOCTEST_PARSE_AS_BOOL_OR_FLAG(dt-no-run, dt-nr, no_run, false);
- DOCTEST_PARSE_AS_BOOL_OR_FLAG(dt-no-version, dt-nv, no_version, false);
- DOCTEST_PARSE_AS_BOOL_OR_FLAG(dt-no-colors, dt-nc, no_colors, false);
- DOCTEST_PARSE_AS_BOOL_OR_FLAG(dt-force-colors, dt-fc, force_colors, false);
- DOCTEST_PARSE_AS_BOOL_OR_FLAG(dt-no-breaks, dt-nb, no_breaks, false);
- DOCTEST_PARSE_AS_BOOL_OR_FLAG(dt-no-skip, dt-ns, no_skip, false);
- DOCTEST_PARSE_AS_BOOL_OR_FLAG(dt-no-path-filenames, dt-npf, no_path_in_filenames, false);
- DOCTEST_PARSE_AS_BOOL_OR_FLAG(dt-no-line-numbers, dt-nln, no_line_numbers, false);
- DOCTEST_PARSE_AS_BOOL_OR_FLAG(dt-no-skipped-summary, dt-nss, no_skipped_summary, false);
-// clang-format on
-
-#undef DOCTEST_PARSE_STR_OPTION
-#undef DOCTEST_PARSE_INT_OPTION
-#undef DOCTEST_PARSE_AS_BOOL_OR_FLAG
-
- if(withDefaults) {
- p->help = false;
- p->version = false;
- p->count = false;
- p->list_test_cases = false;
- p->list_test_suites = false;
- }
- if(parseFlag(argc, argv, "dt-help") || parseFlag(argc, argv, "dt-h") ||
- parseFlag(argc, argv, "dt-?")) {
- p->help = true;
- p->exit = true;
- }
- if(parseFlag(argc, argv, "dt-version") || parseFlag(argc, argv, "dt-v")) {
- p->version = true;
- p->exit = true;
- }
- if(parseFlag(argc, argv, "dt-count") || parseFlag(argc, argv, "dt-c")) {
- p->count = true;
- p->exit = true;
- }
- if(parseFlag(argc, argv, "dt-list-test-cases") || parseFlag(argc, argv, "dt-ltc")) {
- p->list_test_cases = true;
- p->exit = true;
- }
- if(parseFlag(argc, argv, "dt-list-test-suites") || parseFlag(argc, argv, "dt-lts")) {
- p->list_test_suites = true;
- p->exit = true;
- }
-}
-
-// allows the user to add procedurally to the filters from the command line
-void Context::addFilter(const char* filter, const char* value) { setOption(filter, value); }
-
-// allows the user to clear all filters from the command line
-void Context::clearFilters() {
- for(unsigned i = 0; i < p->filters.size(); ++i)
- p->filters[i].clear();
-}
-
-// allows the user to override procedurally the int/bool options from the command line
-void Context::setOption(const char* option, int value) {
- setOption(option, toString(value).c_str());
-}
-
-// allows the user to override procedurally the string options from the command line
-void Context::setOption(const char* option, const char* value) {
- String argv = String("-") + option + "=" + value;
- const char* lvalue = argv.c_str();
- parseArgs(1, &lvalue);
-}
-
-// users should query this in their main() and exit the program if true
-bool Context::shouldExit() { return p->exit; }
-
-// the main function that does all the filtering and test running
-int Context::run() {
- using namespace detail;
-
- Color::init();
-
- contextState = p;
- p->resetRunData();
-
- // handle version, help and no_run
- if(p->no_run || p->version || p->help) {
- if(p->version)
- printVersion();
- if(p->help)
- printHelp();
-
- contextState = 0;
-
- return EXIT_SUCCESS;
- }
-
- printVersion();
- DOCTEST_PRINTF_COLORED("[doctest] ", Color::Cyan);
- std::printf("run with \"--help\" for options\n");
-
- unsigned i = 0; // counter used for loops - here for VC6
-
- std::set<TestCase>& registeredTests = getRegisteredTests();
-
- std::vector<const TestCase*> testArray;
- for(std::set<TestCase>::iterator it = registeredTests.begin(); it != registeredTests.end();
- ++it)
- testArray.push_back(&(*it));
-
- // sort the collected records
- if(!testArray.empty()) {
- if(p->order_by.compare("file", true) == 0) {
- std::qsort(&testArray[0], testArray.size(), sizeof(TestCase*), fileOrderComparator);
- } else if(p->order_by.compare("suite", true) == 0) {
- std::qsort(&testArray[0], testArray.size(), sizeof(TestCase*), suiteOrderComparator);
- } else if(p->order_by.compare("name", true) == 0) {
- std::qsort(&testArray[0], testArray.size(), sizeof(TestCase*), nameOrderComparator);
- } else if(p->order_by.compare("rand", true) == 0) {
- std::srand(p->rand_seed);
-
- // random_shuffle implementation
- const TestCase** first = &testArray[0];
- for(i = testArray.size() - 1; i > 0; --i) {
- int idxToSwap = std::rand() % (i + 1); // NOLINT
-
- const TestCase* temp = first[i];
-
- first[i] = first[idxToSwap];
- first[idxToSwap] = temp;
- }
- }
- }
-
- if(p->list_test_cases) {
- DOCTEST_PRINTF_COLORED("[doctest] ", Color::Cyan);
- std::printf("listing all test case names\n");
- DOCTEST_PRINTF_COLORED(getSeparator(), Color::Yellow);
- }
-
- std::set<String> testSuitesPassingFilters;
- if(p->list_test_suites) {
- DOCTEST_PRINTF_COLORED("[doctest] ", Color::Cyan);
- std::printf("listing all test suites\n");
- DOCTEST_PRINTF_COLORED(getSeparator(), Color::Yellow);
- }
-
- // invoke the registered functions if they match the filter criteria (or just count them)
- for(i = 0; i < testArray.size(); i++) {
- const TestCase& data = *testArray[i];
-
- if(data.m_skip && !p->no_skip)
- continue;
-
- if(!matchesAny(data.m_file, p->filters[0], 1, p->case_sensitive))
- continue;
- if(matchesAny(data.m_file, p->filters[1], 0, p->case_sensitive))
- continue;
- if(!matchesAny(data.m_test_suite, p->filters[2], 1, p->case_sensitive))
- continue;
- if(matchesAny(data.m_test_suite, p->filters[3], 0, p->case_sensitive))
- continue;
- if(!matchesAny(data.m_name, p->filters[4], 1, p->case_sensitive))
- continue;
- if(matchesAny(data.m_name, p->filters[5], 0, p->case_sensitive))
- continue;
-
- p->numTestsPassingFilters++;
-
- // do not execute the test if we are to only count the number of filter passing tests
- if(p->count)
- continue;
-
- // print the name of the test and don't execute it
- if(p->list_test_cases) {
- std::printf("%s\n", data.m_name);
- continue;
- }
-
- // print the name of the test suite if not done already and don't execute it
- if(p->list_test_suites) {
- if((testSuitesPassingFilters.count(data.m_test_suite) == 0) &&
- data.m_test_suite[0] != '\0') {
- std::printf("%s\n", data.m_test_suite);
- testSuitesPassingFilters.insert(data.m_test_suite);
- p->numTestSuitesPassingFilters++;
- }
- continue;
- }
-
- // skip the test if it is not in the execution range
- if((p->last < p->numTestsPassingFilters && p->first <= p->last) ||
- (p->first > p->numTestsPassingFilters))
- continue;
-
- // execute the test if it passes all the filtering
- {
- p->currentTest = &data;
-
- bool failed = false;
- p->hasLoggedCurrentTestStart = false;
- p->numFailedAssertionsForCurrentTestcase = 0;
- p->subcasesPassed.clear();
- double duration = 0;
- Timer timer;
- timer.start();
- do {
- // if the start has been logged from a previous iteration of this loop
- if(p->hasLoggedCurrentTestStart)
- logTestEnd();
- p->hasLoggedCurrentTestStart = false;
-
- // if logging successful tests - force the start log
- if(p->success)
- DOCTEST_LOG_START();
-
- // reset the assertion state
- p->numAssertionsForCurrentTestcase = 0;
- p->hasCurrentTestFailed = false;
-
- // reset some of the fields for subcases (except for the set of fully passed ones)
- p->subcasesHasSkipped = false;
- p->subcasesCurrentLevel = 0;
- p->subcasesEnteredLevels.clear();
-
- // reset stuff for logging with INFO()
- p->exceptionalContexts.clear();
-
-// execute the test
-#ifndef DOCTEST_CONFIG_NO_EXCEPTIONS
- try {
-#endif // DOCTEST_CONFIG_NO_EXCEPTIONS
- FatalConditionHandler fatalConditionHandler; // Handle signals
- data.m_test();
- fatalConditionHandler.reset();
- if(contextState->hasCurrentTestFailed)
- failed = true;
-#ifndef DOCTEST_CONFIG_NO_EXCEPTIONS
- } catch(const TestFailureException&) { failed = true; } catch(...) {
- DOCTEST_LOG_START();
- logTestException(translateActiveException());
- failed = true;
- }
-#endif // DOCTEST_CONFIG_NO_EXCEPTIONS
-
- p->numAssertions += p->numAssertionsForCurrentTestcase;
-
- // exit this loop if enough assertions have failed
- if(p->abort_after > 0 && p->numFailedAssertions >= p->abort_after) {
- p->subcasesHasSkipped = false;
- DOCTEST_PRINTF_COLORED("Aborting - too many failed asserts!\n", Color::Red);
- }
-
- } while(p->subcasesHasSkipped == true);
-
- duration = timer.getElapsedSeconds();
-
- if(Approx(p->currentTest->m_timeout).epsilon(DBL_EPSILON) != 0 &&
- Approx(duration).epsilon(DBL_EPSILON) > p->currentTest->m_timeout) {
- failed = true;
- DOCTEST_LOG_START();
- char msg[DOCTEST_SNPRINTF_BUFFER_LENGTH];
- DOCTEST_SNPRINTF(msg, DOCTEST_COUNTOF(msg),
- "Test case exceeded time limit of %.6f!\n",
- p->currentTest->m_timeout);
- DOCTEST_PRINTF_COLORED(msg, Color::Red);
- }
-
- if(p->duration) {
- char msg[DOCTEST_SNPRINTF_BUFFER_LENGTH];
- DOCTEST_SNPRINTF(msg, DOCTEST_COUNTOF(msg), "%.6f s: %s\n", duration,
- p->currentTest->m_name);
- DOCTEST_PRINTF_COLORED(msg, Color::None);
- }
-
- if(data.m_should_fail) {
- DOCTEST_LOG_START();
- if(failed) {
- failed = false;
- DOCTEST_PRINTF_COLORED("Failed as expected so marking it as not failed\n",
- Color::Yellow);
- } else {
- failed = true;
- DOCTEST_PRINTF_COLORED("Should have failed but didn't! Marking it as failed!\n",
- Color::Red);
- }
- } else if(failed && data.m_may_fail) {
- DOCTEST_LOG_START();
- failed = false;
- DOCTEST_PRINTF_COLORED("Allowed to fail so marking it as not failed\n",
- Color::Yellow);
- } else if(data.m_expected_failures > 0) {
- DOCTEST_LOG_START();
- char msg[DOCTEST_SNPRINTF_BUFFER_LENGTH];
- if(p->numFailedAssertionsForCurrentTestcase == data.m_expected_failures) {
- failed = false;
- DOCTEST_SNPRINTF(
- msg, DOCTEST_COUNTOF(msg),
- "Failed exactly %d times as expected so marking it as not failed!\n",
- data.m_expected_failures);
- DOCTEST_PRINTF_COLORED(msg, Color::Yellow);
- } else {
- failed = true;
- DOCTEST_SNPRINTF(msg, DOCTEST_COUNTOF(msg),
- "Didn't fail exactly %d times so marking it as failed!\n",
- data.m_expected_failures);
- DOCTEST_PRINTF_COLORED(msg, Color::Red);
- }
- }
-
- if(p->hasLoggedCurrentTestStart)
- logTestEnd();
-
- if(failed) // if any subcase has failed - the whole test case has failed
- p->numFailed++;
-
- // stop executing tests if enough assertions have failed
- if(p->abort_after > 0 && p->numFailedAssertions >= p->abort_after)
- break;
- }
- }
-
- printSummary();
-
- contextState = 0;
-
- if(p->numFailed && !p->no_exitcode)
- return EXIT_FAILURE;
- return EXIT_SUCCESS;
-}
-} // namespace doctest
-
-#endif // DOCTEST_CONFIG_DISABLE
-
-#ifdef DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
-int main(int argc, char** argv) { return doctest::Context(argc, argv).run(); }
-#endif // DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
-
-#endif // DOCTEST_LIBRARY_IMPLEMENTATION
-#endif // DOCTEST_CONFIG_IMPLEMENT
-
-#if defined(__clang__)
-#pragma clang diagnostic pop
-#endif // __clang__
-
-#if defined(__GNUC__) && !defined(__clang__)
-#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 6)
-#pragma GCC diagnostic pop
-#endif // > gcc 4.6
-#endif // __GNUC__
-
-#ifdef _MSC_VER
-#pragma warning(pop)
-#endif // _MSC_VER
diff --git a/src/unittests/endian.cc b/src/unittests/endian.cc
deleted file mode 100644
index ef03a1c2d..000000000
--- a/src/unittests/endian.cc
+++ /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/>.
- */
-
-#include "unittests/unittests.h"
-
-#include "logger.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_endian.h>
-PRAGMA48(GCC diagnostic pop)
-
-#include "debug.h"
-
-#ifndef SDL_BIG_ENDIAN
-#error missing SDL_endian.h
-#endif // SDL_BYTEORDER
-
-namespace
-{
- union ByteOrderData final
- {
- uint32_t dwordData;
- uint8_t byteData[4];
- } __attribute__((packed));
-} // namespace
-
-TEST_CASE("endian test", "")
-{
- ByteOrderData data;
- data.byteData[0] = 0x10;
- data.byteData[1] = 0x20;
- data.byteData[2] = 0x30;
- data.byteData[3] = 0x40;
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- REQUIRE(data.dwordData == 0x10203040);
- logger->log("big endian detected");
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- REQUIRE(data.dwordData == 0x40302010);
- logger->log("little endian detected");
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-}
diff --git a/src/unittests/enums/enums.cc b/src/unittests/enums/enums.cc
deleted file mode 100644
index ebff849d9..000000000
--- a/src/unittests/enums/enums.cc
+++ /dev/null
@@ -1,35 +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/>.
- */
-
-#include "unittests/unittests.h"
-
-#include "enums/being/gender.h"
-
-#include "utils/cast.h"
-
-#include "debug.h"
-
-TEST_CASE("Gender", "Enums")
-{
- REQUIRE(CAST_S32(Gender::FEMALE) == 1);
- REQUIRE(Gender::FEMALE == static_cast<GenderT>(1));
- REQUIRE(CAST_S32(Gender::MALE) == 0);
- REQUIRE(Gender::MALE == static_cast<GenderT>(0));
-}
diff --git a/src/unittests/enums/render/mockdrawtype.h b/src/unittests/enums/render/mockdrawtype.h
deleted file mode 100644
index 7477684d0..000000000
--- a/src/unittests/enums/render/mockdrawtype.h
+++ /dev/null
@@ -1,35 +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 ENUMS_RENDER_MOCKDRAWTYPE_H
-#define ENUMS_RENDER_MOCKDRAWTYPE_H
-#ifdef UNITTESTS
-
-#include "enums/simpletypes/enumdefines.h"
-
-enumStart(MockDrawType)
-{
- DrawImage = 0,
- DrawPattern = 1
-}
-enumEnd(MockDrawType);
-
-#endif // UNITTESTS
-#endif // ENUMS_RENDER_MOCKDRAWTYPE_H
diff --git a/src/unittests/fs/files.cc b/src/unittests/fs/files.cc
deleted file mode 100644
index 935a00f72..000000000
--- a/src/unittests/fs/files.cc
+++ /dev/null
@@ -1,207 +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 "unittests/unittests.h"
-
-
-#include "fs/files.h"
-
-#include "fs/virtfs/fs.h"
-#include "fs/virtfs/tools.h"
-
-#include "utils/stringutils.h"
-
-#include "resources/resourcemanager/resourcemanager.h"
-
-#include "debug.h"
-
-TEST_CASE("Files renameFile", "")
-{
- VirtFs::mountDirSilent("data", Append_false);
- VirtFs::mountDirSilent("../data", Append_false);
-
- const int sz = 1234567;
- char *buf = new char[sz];
- for (int f = 0; f < sz; f ++)
- buf[f] = f;
-
- const std::string name1 = "file1.test";
- const std::string name2 = "file2.test";
- FILE *file = fopen(name1.c_str(), "w+b");
- fwrite(buf, 1, sz, file);
- fclose(file);
-
- REQUIRE(0 == Files::renameFile(name1, name2));
- char *buf2 = new char[sz];
- FILE *file2 = fopen(name2.c_str(), "rb");
- REQUIRE_FALSE(nullptr == file2);
- fread(buf2, 1, sz, file2);
- fclose(file2);
- ::remove(name1.c_str());
- ::remove(name2.c_str());
-
- for (int f = 0; f < sz; f ++)
- REQUIRE(buf[f] == buf2[f]);
-
- delete [] buf;
- delete [] buf2;
- ResourceManager::deleteInstance();
- VirtFs::unmountDirSilent("data");
- VirtFs::unmountDirSilent("../data");
-}
-
-TEST_CASE("Files existsLocal", "")
-{
- VirtFs::mountDirSilent("data", Append_false);
- VirtFs::mountDirSilent("../data", Append_false);
- REQUIRE(Files::existsLocal(VirtFs::getPath("help/about.txt")) == true);
- REQUIRE_FALSE(Files::existsLocal(VirtFs::getPath("help/about1.txt")));
- REQUIRE_FALSE(Files::existsLocal(VirtFs::getPath("help1/about.txt")));
- ResourceManager::deleteInstance();
- VirtFs::unmountDirSilent("data");
- VirtFs::unmountDirSilent("../data");
-}
-
-TEST_CASE("Files loadTextFileString", "")
-{
- VirtFs::mountDirSilent("data", Append_false);
- VirtFs::mountDirSilent("../data", Append_false);
- REQUIRE(VirtFs::loadTextFileString("test/simplefile.txt") ==
- "this is test \nfile.");
- ResourceManager::deleteInstance();
- VirtFs::unmountDirSilent("data");
- VirtFs::unmountDirSilent("../data");
-}
-
-TEST_CASE("Files loadTextFile", "")
-{
- VirtFs::mountDirSilent("data", Append_false);
- VirtFs::mountDirSilent("../data", Append_false);
-
- StringVect lines;
- VirtFs::loadTextFile("test/simplefile.txt", lines);
- REQUIRE(lines.size() == 2);
- REQUIRE(lines[0] == "this is test ");
- REQUIRE(lines[1] == "file.");
- ResourceManager::deleteInstance();
- VirtFs::unmountDirSilent("data");
- VirtFs::unmountDirSilent("../data");
-}
-
-TEST_CASE("Files saveTextFile", "")
-{
- VirtFs::mountDirSilent("data", Append_false);
- VirtFs::mountDirSilent("../data", Append_false);
-
- const std::string dir = VirtFs::getPath("test");
- REQUIRE(!dir.empty());
- Files::saveTextFile(dir, "tempfile.txt", "test line\ntext line2");
- std::string data = VirtFs::loadTextFileString("test/tempfile.txt");
- ::remove((dir + "/tempfile.txt").c_str());
-#ifdef WIN32
- REQUIRE(data == "test line\r\ntext line2\r\n");
-#else // WIN32
-
- REQUIRE(data == "test line\ntext line2\n");
-#endif // WIN32
-
- ResourceManager::deleteInstance();
- VirtFs::unmountDirSilent("data");
- VirtFs::unmountDirSilent("../data");
-}
-
-TEST_CASE("Files copyFile1", "")
-{
- VirtFs::mountDirSilent("data", Append_false);
- VirtFs::mountDirSilent("../data", Append_false);
-
- const std::string dir = VirtFs::getPath("test");
- REQUIRE(!dir.empty());
- SECTION("copy")
- {
- REQUIRE(Files::copyFile(pathJoin(dir, "test.txt"),
- pathJoin(dir, "tempfile.txt")) == 0);
- std::string data = VirtFs::loadTextFileString("test/tempfile.txt");
- ::remove((dir + "/tempfile.txt").c_str());
- REQUIRE(data == "test line 1\ntest line 2");
- }
-
- SECTION("errors")
- {
- REQUIRE(Files::copyFile(pathJoin(dir, "test_not_exists.txt"),
- pathJoin(dir, "tempfile.txt")) == -1);
- REQUIRE(Files::copyFile(pathJoin(dir, "test.txt"),
- "/nonexist/root/dir123") == -1);
- }
-
- ResourceManager::deleteInstance();
- VirtFs::unmountDirSilent("data");
- VirtFs::unmountDirSilent("../data");
-}
-
-TEST_CASE("Files loadTextFileLocal", "")
-{
- VirtFs::mountDirSilent("data", Append_false);
- VirtFs::mountDirSilent("../data", Append_false);
-
- const std::string dir = VirtFs::getPath("test");
- REQUIRE(!dir.empty());
- Files::saveTextFile(dir, "tempfile.txt", "test line\ntext line2");
- StringVect lines;
- REQUIRE(Files::loadTextFileLocal(pathJoin(dir, "tempfile.txt"),
- lines));
- ::remove((dir + "/tempfile.txt").c_str());
- REQUIRE(lines.size() == 2);
- REQUIRE(lines[0] == "test line");
- REQUIRE(lines[1] == "text line2");
-
- ResourceManager::deleteInstance();
- VirtFs::unmountDirSilent("data");
- VirtFs::unmountDirSilent("../data");
-}
-
-TEST_CASE("Files getFilesInDir", "")
-{
- VirtFs::mountDirSilent("data", Append_false);
- VirtFs::mountDirSilent("../data", Append_false);
-
- StringVect list;
- VirtFs::getFilesInDir("test",
- list,
- ".gpl");
- REQUIRE(list.size() == 1);
- REQUIRE(list[0] == pathJoin("test", "palette.gpl"));
-
- list.clear();
- VirtFs::getFilesInDir("perserver/default",
- list,
- ".xml");
- REQUIRE(list.size() == 6);
- REQUIRE(list[0] == pathJoin("perserver", "default", "charcreation.xml"));
- REQUIRE(list[1] == pathJoin("perserver", "default", "deadmessages.xml"));
- REQUIRE(list[2] ==
- pathJoin("perserver", "default", "defaultcommands.xml"));
- REQUIRE(list[3] == pathJoin("perserver", "default", "features.xml"));
- REQUIRE(list[4] == pathJoin("perserver", "default", "groups.xml"));
- REQUIRE(list[5] == pathJoin("perserver", "default", "weapons.xml"));
- ResourceManager::deleteInstance();
- VirtFs::unmountDirSilent("data");
- VirtFs::unmountDirSilent("../data");
-}
diff --git a/src/unittests/fs/virtfs/throw.cc b/src/unittests/fs/virtfs/throw.cc
deleted file mode 100644
index 9f0a18f32..000000000
--- a/src/unittests/fs/virtfs/throw.cc
+++ /dev/null
@@ -1,225 +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 "unittests/unittests.h"
-
-#include "configmanager.h"
-#include "configuration.h"
-#include "dirs.h"
-
-#include "fs/virtfs/fs.h"
-#include "fs/virtfs/zipreader.h"
-
-#include "utils/checkutils.h"
-
-#ifndef UNITTESTS_CATCH
-#include <algorithm>
-#endif // UNITTESTS_CATCH
-
-#include "debug.h"
-
-TEST_CASE("throw VirtFs1 exists1", "")
-{
- VirtFs::init(".");
- const bool dir1 = VirtFs::mountDirSilent("data/",
- Append_false);
- VirtFs::mountDirSilent("..\\data",
- Append_false);
-
- if (dir1 == true)
- {
- VirtFs::mountDir("data//test",
- Append_false);
- }
- else
- {
- VirtFs::mountDirSilent("..//data\\test",
- Append_false);
- }
-
- if (dir1 == true)
- VirtFs::unmountDirSilent("data/test");
- else
- VirtFs::unmountDirSilent("../data/test");
-
- REQUIRE_THROWS(VirtFs::exists("test/../units.xml"));
-
- VirtFs::deinit();
-}
-
-TEST_CASE("throw VirtFs1 exists2", "")
-{
- VirtFs::init(".");
- const bool dir1 = VirtFs::mountDirSilent2("data/",
- "test",
- Append_false);
- VirtFs::mountDirSilent2("..\\data",
- "test",
- Append_false);
-
- if (dir1 == true)
- {
- VirtFs::mountDir2("data//test",
- "dir2",
- Append_false);
- }
- else
- {
- VirtFs::mountDirSilent2("..//data\\test",
- "dir2",
- Append_false);
- }
-
- if (dir1 == true)
- VirtFs::unmountDirSilent2("data/test", "dir2");
- else
- VirtFs::unmountDirSilent2("../data/test", "dir2");
-
- REQUIRE_THROWS(VirtFs::exists("test/../units.xml"));
-
- VirtFs::deinit();
-}
-
-TEST_CASE("throw Zip readCompressedFile", "")
-{
- SECTION("empty")
- {
- REQUIRE_THROWS(VirtFs::ZipReader::readCompressedFile(nullptr));
- }
-}
-
-TEST_CASE("throw Zip readFile", "")
-{
- SECTION("empty")
- {
- REQUIRE_THROWS(VirtFs::ZipReader::readFile(nullptr));
- }
-}
-
-TEST_CASE("throw VirtFs1 unmount", "")
-{
- VirtFs::init(".");
- const std::string sep = dirSeparator;
-
- SECTION("simple 1")
- {
- REQUIRE_THROWS(VirtFs::unmountDir("dir1"));
- REQUIRE_THROWS(VirtFs::unmountDir("dir1/"));
- }
-
- SECTION("simple 2")
- {
- REQUIRE(VirtFs::mountDirSilentTest("dir1",
- Append_true));
- REQUIRE_THROWS(VirtFs::unmountDir("dir2"));
- REQUIRE(VirtFs::unmountDir("dir1"));
- }
-
- SECTION("simple 3")
- {
- REQUIRE(VirtFs::mountDirSilentTest("dir1",
- Append_true));
- REQUIRE(VirtFs::mountDirSilentTest("dir2//dir3",
- Append_true));
- REQUIRE(VirtFs::mountDirSilentTest("dir3",
- Append_false));
- REQUIRE_THROWS(VirtFs::unmountDir("dir2"));
- REQUIRE(VirtFs::unmountDir("dir1"));
- REQUIRE_THROWS(VirtFs::unmountDir("dir1"));
- REQUIRE(VirtFs::unmountDir("dir2/dir3"));
- REQUIRE_THROWS(VirtFs::unmountDir("dir2/dir3" + sep));
- }
-
- SECTION("simple 4")
- {
- REQUIRE(VirtFs::mountDirSilentTest("dir1",
- Append_true));
- REQUIRE_THROWS(VirtFs::unmountDir("dir2"));
- REQUIRE(VirtFs::unmountDir("dir1"));
- REQUIRE(VirtFs::mountDirSilentTest("dir1",
- Append_true));
- }
-
- SECTION("subDir 1")
- {
- REQUIRE_THROWS(VirtFs::unmountDir2("dir1", "dir1"));
- REQUIRE_THROWS(VirtFs::unmountDir2("dir1/", "dir1/"));
- }
-
- SECTION("subDir 2")
- {
- REQUIRE(VirtFs::mountDirSilentTest2("dir1",
- "dir2",
- Append_true));
- REQUIRE_THROWS(VirtFs::unmountDir("dir1"));
- REQUIRE_THROWS(VirtFs::unmountDir("dir2"));
- REQUIRE(VirtFs::unmountDir2("dir1", "dir2"));
- }
-
- SECTION("subDir 3")
- {
- REQUIRE(VirtFs::mountDirSilentTest2("dir1",
- "dir2",
- Append_true));
- REQUIRE(VirtFs::mountDirSilentTest("dir2//dir3",
- Append_true));
- REQUIRE(VirtFs::mountDirSilentTest2("dir3",
- "dir4",
- Append_false));
- REQUIRE_THROWS(VirtFs::unmountDir("dir2"));
- REQUIRE_THROWS(VirtFs::unmountDir2("dir1", "dir1"));
- REQUIRE(VirtFs::unmountDir2("dir1", "dir2"));
- REQUIRE_THROWS(VirtFs::unmountDir("dir1"));
- REQUIRE(VirtFs::unmountDir("dir2/dir3"));
- REQUIRE_THROWS(VirtFs::unmountDir("dir2/dir3" + sep));
- }
-
- SECTION("subDir 4")
- {
- REQUIRE(VirtFs::mountDirSilentTest2("dir1",
- "dir2",
- Append_true));
- REQUIRE_THROWS(VirtFs::unmountDir("dir2"));
- REQUIRE_THROWS(VirtFs::unmountDir("dir1"));
- REQUIRE(VirtFs::unmountDir2("dir1", "dir2"));
- REQUIRE(VirtFs::mountDirSilentTest2("dir1",
- "dir3",
- Append_true));
- }
-
- VirtFs::deinit();
-}
-
-TEST_CASE("throw configuration tests", "configuration")
-{
- Dirs::initRootDir();
- Dirs::initHomeDir();
-
- ConfigManager::initConfiguration();
-
- SECTION("configuration undefined")
- {
- const char *const key = "nonsetvalue";
- REQUIRE_THROWS(config.getIntValue(key));
- REQUIRE_THROWS(config.getFloatValue(key));
- REQUIRE_THROWS(config.getStringValue(key));
- REQUIRE_THROWS(config.getBoolValue(key));
- }
-}
diff --git a/src/unittests/fs/virtfs/virtfs.cc b/src/unittests/fs/virtfs/virtfs.cc
deleted file mode 100644
index 64f93c8f4..000000000
--- a/src/unittests/fs/virtfs/virtfs.cc
+++ /dev/null
@@ -1,996 +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 "unittests/unittests.h"
-
-#include "fs/files.h"
-#include "fs/paths.h"
-
-#include "fs/virtfs/fs.h"
-#include "fs/virtfs/list.h"
-
-#include "utils/checkutils.h"
-#include "utils/foreach.h"
-
-#ifndef UNITTESTS_CATCH
-#include <algorithm>
-#endif // UNITTESTS_CATCH
-
-#include "debug.h"
-
-TEST_CASE("VirtFs dirSeparator", "")
-{
- REQUIRE(dirSeparator != nullptr);
- REQUIRE(VirtFs::getDirSeparator() == std::string(dirSeparator));
- VirtFs::updateDirSeparator();
- REQUIRE(dirSeparator != nullptr);
- REQUIRE(VirtFs::getDirSeparator() == std::string(dirSeparator));
-}
-
-TEST_CASE("VirtFs getBaseDir", "")
-{
- REQUIRE(VirtFs::getBaseDir() != nullptr);
-}
-
-TEST_CASE("VirtFs getUserDir", "")
-{
- REQUIRE(VirtFs::getUserDir() != nullptr);
-}
-
-TEST_CASE("VirtFs exists1", "")
-{
- VirtFs::mountDirSilent("data", Append_false);
- VirtFs::mountDirSilent("../data", Append_false);
-
- REQUIRE(VirtFs::exists("test") == true);
- REQUIRE(VirtFs::exists("test/dir1") == true);
- REQUIRE(VirtFs::exists("test/dir") == false);
- REQUIRE(VirtFs::exists("test/units.xml") == true);
- REQUIRE(VirtFs::exists("test/units123.xml") == false);
- REQUIRE(VirtFs::exists("tesQ/units.xml") == false);
- REQUIRE(VirtFs::exists("units.xml") == false);
-
- VirtFs::mountDirSilent("data/test", Append_false);
- VirtFs::mountDirSilent("../data/test", Append_false);
-
- REQUIRE(VirtFs::exists("test") == true);
- REQUIRE(VirtFs::exists("test/dir1") == true);
- REQUIRE(VirtFs::exists("test/dir") == false);
- REQUIRE(VirtFs::exists("test/units.xml") == true);
- REQUIRE(VirtFs::exists("test/units123.xml") == false);
- REQUIRE(VirtFs::exists("tesQ/units.xml") == false);
- REQUIRE(VirtFs::exists("units.xml") == true);
-
- VirtFs::unmountDirSilent("data/test");
- VirtFs::unmountDirSilent("../data/test");
-
- REQUIRE(VirtFs::exists("test") == true);
- REQUIRE(VirtFs::exists("test/dir1") == true);
- REQUIRE(VirtFs::exists("test/dir") == false);
- REQUIRE(VirtFs::exists("test/units.xml") == true);
- REQUIRE(VirtFs::exists("test/units123.xml") == false);
- REQUIRE(VirtFs::exists("tesQ/units.xml") == false);
- REQUIRE(VirtFs::exists("units.xml") == false);
-
- VirtFs::unmountDirSilent("data");
- VirtFs::unmountDirSilent("../data");
-}
-
-TEST_CASE("VirtFs exists2", "")
-{
- std::string name("data/test/test.zip");
- std::string prefix;
- if (Files::existsLocal(name) == false)
- prefix = "../" + prefix;
-
- VirtFs::mountZip(prefix + "data/test/test2.zip", Append_false);
-
- REQUIRE(VirtFs::exists("test") == false);
- REQUIRE(VirtFs::exists("test/units.xml") == false);
- REQUIRE(VirtFs::exists("test.txt") == true);
- REQUIRE(VirtFs::exists("dir/hide.png") == true);
- REQUIRE(VirtFs::exists("dir/gpl") == true);
- REQUIRE(VirtFs::exists("dir/gpl/zzz") == false);
- REQUIRE(VirtFs::exists("units.xml") == true);
- REQUIRE(VirtFs::exists("units.xml.") == false);
- REQUIRE(VirtFs::exists("units.xml2") == false);
-
- VirtFs::unmountZip(prefix + "data/test/test2.zip");
-}
-
-TEST_CASE("VirtFs exists3", "")
-{
- std::string name("data/test/test.zip");
- std::string prefix;
- if (Files::existsLocal(name) == false)
- prefix = "../" + prefix;
-
- VirtFs::mountZip(prefix + "data/test/test.zip", Append_false);
- VirtFs::mountZip(prefix + "data/test/test2.zip", Append_false);
-
- REQUIRE(VirtFs::exists("test") == false);
- REQUIRE(VirtFs::exists("test/units.xml") == false);
- REQUIRE(VirtFs::exists("dir/brimmedhat.png"));
- REQUIRE(VirtFs::exists("dir//brimmedhat.png"));
- REQUIRE(VirtFs::exists("dir//hide.png"));
- REQUIRE(VirtFs::exists("dir/1"));
- REQUIRE(VirtFs::exists("dir/gpl"));
- REQUIRE(VirtFs::exists("dir/dye.png"));
- REQUIRE(VirtFs::exists("dir/2") == false);
- REQUIRE(VirtFs::exists("dir2/2") == false);
- REQUIRE(VirtFs::exists("dir2/paths.xml"));
-
- VirtFs::unmountZip(prefix + "data/test/test.zip");
- VirtFs::unmountZip(prefix + "data/test/test2.zip");
-}
-
-TEST_CASE("VirtFs exists4", "")
-{
- std::string name("data/test/test.zip");
- std::string prefix;
- if (Files::existsLocal(name) == false)
- prefix = "../" + prefix;
-
- VirtFs::mountZip(prefix + "data/test/test.zip", Append_false);
- VirtFs::mountDirSilent(prefix + "data/test", Append_false);
-
- REQUIRE(VirtFs::exists("test") == false);
- REQUIRE(VirtFs::exists("test/units.xml") == false);
- REQUIRE(VirtFs::exists("dir/brimmedhat.png"));
- REQUIRE(VirtFs::exists("dir//brimmedhat.png"));
- REQUIRE(VirtFs::exists("dir//hide.png"));
- REQUIRE(VirtFs::exists("dir/1") == false);
- REQUIRE(VirtFs::exists("dir/gpl") == false);
- REQUIRE(VirtFs::exists("dir/dye.png") == false);
- REQUIRE(VirtFs::exists("dir/2") == false);
- REQUIRE(VirtFs::exists("dir2/2") == false);
- REQUIRE(VirtFs::exists("dir2/paths.xml") == false);
- REQUIRE(VirtFs::exists("units.xml"));
- REQUIRE(VirtFs::exists("dir1/file1.txt"));
- REQUIRE(VirtFs::exists("dir2/file2.txt"));
- REQUIRE(VirtFs::exists("dir2/file3.txt") == false);
-
- VirtFs::unmountZip(prefix + "data/test/test.zip");
- VirtFs::unmountDirSilent(prefix + "data/test");
-}
-
-TEST_CASE("VirtFs exists5", "")
-{
- std::string name("data/test/test.zip");
- std::string prefix;
- if (Files::existsLocal(name) == false)
- prefix = "../" + prefix;
-
- const std::string realDir = getRealPath(prefix + "data");
- logger->log("real dir: " + realDir);
- REQUIRE_FALSE(VirtFs::exists(realDir));
-}
-
-TEST_CASE("VirtFs exists6", "")
-{
- std::string name("data/test/test.zip");
- std::string prefix;
- if (Files::existsLocal(name) == false)
- prefix = "../" + prefix;
-
- VirtFs::mountZip2(prefix + "data/test/test2.zip",
- "dir",
- Append_false);
-
- REQUIRE(VirtFs::exists("test") == false);
- REQUIRE(VirtFs::exists("test/units.xml") == false);
- REQUIRE(VirtFs::exists("test.txt") == false);
- REQUIRE(VirtFs::exists("dir/hide.png") == false);
- REQUIRE(VirtFs::exists("dir/gpl") == false);
- REQUIRE(VirtFs::exists("dir/gpl/zzz") == false);
- REQUIRE(VirtFs::exists("units.xml") == false);
- REQUIRE(VirtFs::exists("units.xml.") == false);
- REQUIRE(VirtFs::exists("units.xml2") == false);
- REQUIRE(VirtFs::exists("hide.png"));
- REQUIRE(VirtFs::exists("dye.png"));
- REQUIRE(VirtFs::exists("gpl"));
- REQUIRE(VirtFs::exists("gpl/zzz") == false);
-
- VirtFs::unmountZip2(prefix + "data/test/test2.zip",
- "dir");
-}
-
-static void removeTemp(StringVect &restrict list)
-{
- int cnt = 0;
- std::sort(list.begin(), list.end());
-
- FOR_EACH (StringVectIter, it, list)
- {
- if (*it != "serverlistplus.xml.part")
- {
- logger->log("file: %d %s",
- cnt,
- (*it).c_str());
- cnt ++;
- }
- }
-
- FOR_EACH (StringVectIter, it, list)
- {
- if (*it == "serverlistplus.xml.part")
- {
- list.erase(it);
- return;
- }
- }
-}
-
-static bool inList(const VirtFs::List *const list,
- const std::string &name)
-{
- FOR_EACH (StringVectCIter, it, list->names)
- {
- if (*it == name)
- return true;
- }
- return false;
-}
-
-TEST_CASE("VirtFs enumerateFiles1", "")
-{
- VirtFs::mountDirSilent("data", Append_false);
- VirtFs::mountDirSilent("../data", Append_false);
-
- VirtFs::List *list = nullptr;
-
- const int cnt1 = VirtFs::exists("test/test2.txt") ? 28 : 27;
- const int cnt2 = 28;
-
- VirtFs::permitLinks(false);
- list = VirtFs::enumerateFiles("test");
- removeTemp(list->names);
- const size_t sz = list->names.size();
- REQUIRE(sz == cnt1);
- VirtFs::freeList(list);
-
- VirtFs::permitLinks(true);
- list = VirtFs::enumerateFiles("test");
- removeTemp(list->names);
- REQUIRE(list->names.size() == cnt2);
- VirtFs::freeList(list);
-
- VirtFs::permitLinks(false);
- list = VirtFs::enumerateFiles("test");
- removeTemp(list->names);
- REQUIRE(list->names.size() == cnt1);
- VirtFs::freeList(list);
-
- list = VirtFs::enumerateFiles("test/units.xml");
- removeTemp(list->names);
- REQUIRE(list->names.empty());
- VirtFs::freeList(list);
-
- VirtFs::unmountDirSilent("data");
- VirtFs::unmountDirSilent("../data");
-}
-
-TEST_CASE("VirtFs enumerateFiles2", "")
-{
- VirtFs::mountDirSilent("data/test/dir1",
- Append_false);
- VirtFs::mountDirSilent("../data/test/dir1",
- Append_false);
-
- VirtFs::List *list = nullptr;
-
- list = VirtFs::enumerateFiles("/");
- REQUIRE(list->names.size() == 5);
- VirtFs::freeList(list);
-
- VirtFs::unmountDirSilent("data/test/dir1");
- VirtFs::unmountDirSilent("../data/test/dir1");
-}
-
-TEST_CASE("VirtFs enumerateFiles3", "")
-{
- std::string name("data/test/test.zip");
- std::string prefix;
- if (Files::existsLocal(name) == false)
- prefix = "../" + prefix;
-
- VirtFs::mountZip(prefix + "data/test/test.zip",
- Append_false);
-
- VirtFs::List *list = nullptr;
-
- list = VirtFs::enumerateFiles("/");
- REQUIRE(list->names.size() == 1);
- REQUIRE(inList(list, "dir"));
- VirtFs::freeList(list);
-
- VirtFs::unmountZip(prefix + "data/test/test.zip");
-}
-
-TEST_CASE("VirtFs enumerateFiles4", "")
-{
- std::string name("data/test/test.zip");
- std::string prefix;
- if (Files::existsLocal(name) == false)
- prefix = "../" + prefix;
-
- VirtFs::mountZip(prefix + "data/test/test2.zip",
- Append_false);
-
- VirtFs::List *list = nullptr;
-
- list = VirtFs::enumerateFiles("/");
- REQUIRE(list->names.size() == 4);
- REQUIRE(inList(list, "dir"));
- REQUIRE(inList(list, "dir2"));
- REQUIRE(inList(list, "test.txt"));
- REQUIRE(inList(list, "units.xml"));
- VirtFs::freeList(list);
-
- VirtFs::unmountZip(prefix + "data/test/test2.zip");
-}
-
-TEST_CASE("VirtFs enumerateFiles5", "")
-{
- std::string name("data/test/test.zip");
- std::string prefix;
- if (Files::existsLocal(name) == false)
- prefix = "../" + prefix;
-
- VirtFs::mountZip(prefix + "data/test/test2.zip",
- Append_false);
- VirtFs::mountDirSilent(prefix + "data/test", Append_false);
-
- VirtFs::List *list = nullptr;
-
- list = VirtFs::enumerateFiles("dir2");
- REQUIRE(inList(list, "file1.txt"));
- REQUIRE(inList(list, "file2.txt"));
- REQUIRE(inList(list, "hide.png"));
- REQUIRE(inList(list, "paths.xml"));
- REQUIRE(inList(list, "test.txt"));
- REQUIRE(inList(list, "units.xml"));
- VirtFs::freeList(list);
-
- VirtFs::unmountZip(prefix + "data/test/test2.zip");
- VirtFs::unmountDirSilent(prefix + "data/test");
-}
-
-TEST_CASE("VirtFs isDirectory1", "")
-{
- VirtFs::mountDirSilent("data", Append_false);
- VirtFs::mountDirSilent("../data", Append_false);
-
- REQUIRE(VirtFs::isDirectory("test/units.xml") == false);
- REQUIRE(VirtFs::isDirectory("test/units.xml/") == false);
- REQUIRE(VirtFs::isDirectory("test//units.xml") == false);
- REQUIRE(VirtFs::isDirectory("test/units123.xml") == false);
- REQUIRE(VirtFs::isDirectory("test//units123.xml") == false);
- REQUIRE(VirtFs::isDirectory("tesQ/units.xml") == false);
- REQUIRE(VirtFs::isDirectory("tesQ//units.xml") == false);
- REQUIRE(VirtFs::isDirectory("units.xml") == false);
- REQUIRE(VirtFs::isDirectory("test") == true);
- REQUIRE(VirtFs::isDirectory("test/") == true);
- REQUIRE(VirtFs::isDirectory("test//") == true);
- REQUIRE(VirtFs::isDirectory("test/dir1") == true);
- REQUIRE(VirtFs::isDirectory("test//dir1") == true);
- REQUIRE(VirtFs::isDirectory("test//dir1/") == true);
- REQUIRE(VirtFs::isDirectory("test//dir1//") == true);
- REQUIRE(VirtFs::isDirectory("test/dir1/") == true);
- REQUIRE(VirtFs::isDirectory("test/dir1//") == true);
- REQUIRE(VirtFs::isDirectory("testQ") == false);
- REQUIRE(VirtFs::isDirectory("testQ/") == false);
- REQUIRE(VirtFs::isDirectory("testQ//") == false);
-
- VirtFs::mountDirSilent("data/test", Append_false);
- VirtFs::mountDirSilent("../data/test", Append_false);
-
- REQUIRE(VirtFs::isDirectory("test/units.xml") == false);
- REQUIRE(VirtFs::isDirectory("test/units.xml/") == false);
- REQUIRE(VirtFs::isDirectory("test//units.xml") == false);
- REQUIRE(VirtFs::isDirectory("test/units123.xml") == false);
- REQUIRE(VirtFs::isDirectory("tesQ/units.xml") == false);
- REQUIRE(VirtFs::isDirectory("units.xml") == false);
- REQUIRE(VirtFs::isDirectory("test") == true);
- REQUIRE(VirtFs::isDirectory("testQ") == false);
- REQUIRE(VirtFs::isDirectory("test/dir1") == true);
-
- VirtFs::unmountDirSilent("data/test");
- VirtFs::unmountDirSilent("../data/test");
-
- REQUIRE(VirtFs::isDirectory("test/units.xml") == false);
- REQUIRE(VirtFs::isDirectory("test/units123.xml") == false);
- REQUIRE(VirtFs::isDirectory("tesQ/units.xml") == false);
- REQUIRE(VirtFs::isDirectory("units.xml") == false);
- REQUIRE(VirtFs::isDirectory("units.xml/") == false);
- REQUIRE(VirtFs::isDirectory("test") == true);
- REQUIRE(VirtFs::isDirectory("test/") == true);
- REQUIRE(VirtFs::isDirectory("testQ") == false);
- REQUIRE(VirtFs::isDirectory("test/dir1") == true);
-
- VirtFs::unmountDirSilent("data");
- VirtFs::unmountDirSilent("../data");
-}
-
-TEST_CASE("VirtFs isDirectory2", "")
-{
- std::string name("data/test/test.zip");
- std::string prefix;
- if (Files::existsLocal(name) == false)
- prefix = "../" + prefix;
-
- VirtFs::mountZip(prefix + "data/test/test2.zip", Append_false);
-
- REQUIRE(VirtFs::isDirectory("test/units.xml") == false);
- REQUIRE(VirtFs::isDirectory("dir") == true);
- REQUIRE(VirtFs::isDirectory("dir/") == true);
- REQUIRE(VirtFs::isDirectory("dir//") == true);
- REQUIRE(VirtFs::isDirectory("dir2") == true);
- REQUIRE(VirtFs::isDirectory("dir3") == false);
- REQUIRE(VirtFs::isDirectory("test.txt") == false);
-
- VirtFs::unmountZip(prefix + "data/test/test2.zip");
-}
-
-TEST_CASE("VirtFs isDirectory3", "")
-{
- std::string name("data/test/test.zip");
- std::string prefix;
- if (Files::existsLocal(name) == false)
- prefix = "../" + prefix;
-
- VirtFs::mountDir(prefix + "data", Append_false);
- VirtFs::mountZip(prefix + "data/test/test2.zip", Append_false);
-
- REQUIRE(VirtFs::isDirectory("test/units.xml") == false);
- REQUIRE(VirtFs::isDirectory("test"));
- REQUIRE(VirtFs::isDirectory("test//dye.png") == false);
- REQUIRE(VirtFs::isDirectory("dir"));
- REQUIRE(VirtFs::isDirectory("dir/"));
- REQUIRE(VirtFs::isDirectory("dir//"));
- REQUIRE(VirtFs::isDirectory("dir2"));
- REQUIRE(VirtFs::isDirectory("dir3") == false);
- REQUIRE(VirtFs::isDirectory("test.txt") == false);
- REQUIRE(VirtFs::isDirectory("dir/hide.png") == false);
-
- VirtFs::unmountZip(prefix + "data/test/test2.zip");
- VirtFs::unmountDir(prefix + "data");
-}
-
-TEST_CASE("VirtFs openRead1", "")
-{
- VirtFs::mountDirSilent("data", Append_false);
- VirtFs::mountDirSilent("../data", Append_false);
-
- VirtFs::File *file = nullptr;
-
- file = VirtFs::openRead("test/units.xml");
- REQUIRE(file != nullptr);
- VirtFs::close(file);
- file = VirtFs::openRead("test/units123.xml");
- REQUIRE(file == nullptr);
- file = VirtFs::openRead("tesQ/units.xml");
- REQUIRE(file == nullptr);
- file = VirtFs::openRead("units.xml");
- REQUIRE(file == nullptr);
-// file = VirtFs::openRead("test");
-// REQUIRE(file == nullptr);
- file = VirtFs::openRead("testQ");
- REQUIRE(file == nullptr);
-
- VirtFs::mountDirSilent("data/test", Append_false);
- VirtFs::mountDirSilent("../data/test", Append_false);
-
- file = VirtFs::openRead("test/units.xml");
- REQUIRE(file != nullptr);
- VirtFs::close(file);
- file = VirtFs::openRead("test/units123.xml");
- REQUIRE(file == nullptr);
- file = VirtFs::openRead("tesQ/units.xml");
- REQUIRE(file == nullptr);
- file = VirtFs::openRead("units.xml");
- REQUIRE(file != nullptr);
- VirtFs::close(file);
-// file = VirtFs::openRead("test");
-// REQUIRE(file == nullptr);
- file = VirtFs::openRead("testQ");
- REQUIRE(file == nullptr);
-
- VirtFs::unmountDirSilent("data/test");
- VirtFs::unmountDirSilent("../data/test");
-
- file = VirtFs::openRead("test/units.xml");
- REQUIRE(file != nullptr);
- VirtFs::close(file);
- file = VirtFs::openRead("test/units123.xml");
- REQUIRE(file == nullptr);
- file = VirtFs::openRead("tesQ/units.xml");
- REQUIRE(file == nullptr);
- file = VirtFs::openRead("units.xml");
- REQUIRE(file == nullptr);
-// file = VirtFs::openRead("test");
-// REQUIRE(file == nullptr);
- file = VirtFs::openRead("testQ");
- REQUIRE(file == nullptr);
-
- VirtFs::unmountDirSilent("data");
- VirtFs::unmountDirSilent("../data");
-}
-
-TEST_CASE("VirtFs openRead2", "")
-{
- std::string name("data/test/test.zip");
- std::string prefix;
- if (Files::existsLocal(name) == false)
- prefix = "../" + prefix;
-
- VirtFs::mountZip(prefix + "data/test/test2.zip", Append_false);
-
- VirtFs::File *file = nullptr;
-
- file = VirtFs::openRead("test/units.xml");
- REQUIRE(file == nullptr);
- file = VirtFs::openRead("units.xml");
- REQUIRE(file != nullptr);
- VirtFs::close(file);
- file = VirtFs::openRead("dir/hide.png");
- REQUIRE(file != nullptr);
- VirtFs::close(file);
- file = VirtFs::openRead("dir//hide.png");
- REQUIRE(file != nullptr);
- VirtFs::close(file);
-
- VirtFs::unmountZip(prefix + "data/test/test2.zip");
-}
-
-TEST_CASE("VirtFs openRead3", "")
-{
- std::string name("data/test/test.zip");
- std::string prefix;
- if (Files::existsLocal(name) == false)
- prefix = "../" + prefix;
-
- VirtFs::mountZip(prefix + "data/test/test2.zip", Append_false);
- VirtFs::mountDir(prefix + "data/test", Append_false);
-
- VirtFs::File *file = nullptr;
-
- file = VirtFs::openRead("test/units.xml");
- REQUIRE(file == nullptr);
- file = VirtFs::openRead("units.xml");
- REQUIRE(file != nullptr);
- VirtFs::close(file);
- file = VirtFs::openRead("dir/hide.png");
- REQUIRE(file != nullptr);
- VirtFs::close(file);
- file = VirtFs::openRead("dir//hide.png");
- REQUIRE(file != nullptr);
- VirtFs::close(file);
- file = VirtFs::openRead("dir/dye.png");
- REQUIRE(file != nullptr);
- VirtFs::close(file);
- file = VirtFs::openRead("dir/dye.pn_");
- REQUIRE(file == nullptr);
-
- VirtFs::unmountZip(prefix + "data/test/test2.zip");
- VirtFs::unmountDir(prefix + "data/test");
-}
-
-TEST_CASE("VirtFs getRealDir1", "")
-{
- const std::string sep = dirSeparator;
- REQUIRE(VirtFs::getRealDir(".").empty());
- REQUIRE(VirtFs::getRealDir("..").empty());
- const bool dir1 = VirtFs::mountDirSilent("data", Append_false);
- REQUIRE((dir1 || VirtFs::mountDirSilent("../data", Append_false))
- == true);
- if (dir1 == true)
- {
- REQUIRE(VirtFs::getRealDir("test") == "data");
- REQUIRE(VirtFs::getRealDir("test/test.txt") ==
- "data");
- }
- else
- {
- REQUIRE(VirtFs::getRealDir("test") == "../data");
- REQUIRE(VirtFs::getRealDir("test/test.txt") ==
- "../data");
- }
- REQUIRE(VirtFs::getRealDir("zzz").empty());
-
- VirtFs::mountDirSilent("data/test", Append_false);
- VirtFs::mountDirSilent("../data/test", Append_false);
- if (dir1 == true)
- {
- REQUIRE(VirtFs::getRealDir("test") == "data");
- REQUIRE(VirtFs::getRealDir("test/test.txt") ==
- "data");
- REQUIRE(VirtFs::getRealDir("test.txt") ==
- "data" + sep + "test");
- }
- else
- {
- REQUIRE(VirtFs::getRealDir("test") == ".." + sep + "data");
- REQUIRE(VirtFs::getRealDir("test/test.txt") ==
- ".." + sep + "data");
- REQUIRE(VirtFs::getRealDir("test.txt") ==
- ".." + sep + "data" + sep + "test");
- }
- REQUIRE(VirtFs::getRealDir("zzz").empty());
-
- if (dir1 == true)
- {
- VirtFs::mountZip("data/test/test.zip", Append_false);
- REQUIRE(VirtFs::getRealDir("dir/brimmedhat.png") ==
- "data" + sep + "test" + sep + "test.zip");
- REQUIRE(VirtFs::getRealDir("hide.png") ==
- "data" + sep + "test");
- }
- else
- {
- VirtFs::mountZip("../data/test/test.zip", Append_false);
- REQUIRE(VirtFs::getRealDir("dir/brimmedhat.png") ==
- ".." + sep + "data" + sep + "test" + sep + "test.zip");
- REQUIRE(VirtFs::getRealDir("hide.png") ==
- ".." + sep + "data" + sep + "test");
- }
-
- VirtFs::unmountDirSilent("data/test");
- VirtFs::unmountDirSilent("../data/test");
-
- if (dir1 == true)
- {
- REQUIRE(VirtFs::getRealDir("test") == "data");
- REQUIRE(VirtFs::getRealDir("test/test.txt") ==
- "data");
- REQUIRE(VirtFs::getRealDir("dir/hide.png") ==
- "data" + sep + "test" + sep + "test.zip");
- }
- else
- {
- REQUIRE(VirtFs::getRealDir("test") == ".." + sep + "data");
- REQUIRE(VirtFs::getRealDir("test/test.txt") ==
- ".." + sep + "data");
- REQUIRE(VirtFs::getRealDir("dir/hide.png") ==
- ".." + sep + "data" + sep + "test" + sep + "test.zip");
- }
- REQUIRE(VirtFs::exists("dir/hide.png"));
- REQUIRE(VirtFs::getRealDir("zzz").empty());
-
- VirtFs::unmountDirSilent("data");
- VirtFs::unmountDirSilent("../data");
- if (dir1 == true)
- VirtFs::unmountZip("data/test/test.zip");
- else
- VirtFs::unmountZip("../data/test/test.zip");
-}
-
-TEST_CASE("VirtFs getrealDir2", "")
-{
- const std::string sep = dirSeparator;
- std::string name("data/test/test.zip");
- std::string prefix;
- if (Files::existsLocal(name) == false)
- prefix = "../" + prefix;
-
- VirtFs::mountZip(prefix + "data/test/test2.zip", Append_false);
- VirtFs::mountDir(prefix + "data/test", Append_false);
- VirtFs::mountDir(prefix + "data", Append_false);
-
- REQUIRE(VirtFs::getRealDir("zzz").empty());
-
- REQUIRE(VirtFs::getRealDir("dir1/file1.txt") ==
- prefix + "data" + sep + "test");
- REQUIRE(VirtFs::getRealDir("hide.png") ==
- prefix + "data" + sep + "test");
- REQUIRE(VirtFs::getRealDir("dir//hide.png") ==
- prefix + "data" + sep + "test" + sep + "test2.zip");
- REQUIRE(VirtFs::getRealDir("dir/1//test.txt") ==
- prefix + "data" + sep + "test" + sep + "test2.zip");
-
- VirtFs::unmountZip(prefix + "data/test/test2.zip");
- VirtFs::unmountDir(prefix + "data/test");
- VirtFs::unmountDir(prefix + "data");
-}
-
-TEST_CASE("VirtFs getrealDir3", "")
-{
- const std::string sep = dirSeparator;
- std::string name("data/test/test.zip");
- std::string prefix;
- if (Files::existsLocal(name) == false)
- prefix = "../" + prefix;
-
- VirtFs::mountZip2(prefix + "data/test/test2.zip",
- "dir",
- Append_false);
- VirtFs::mountDir(prefix + "data/test", Append_false);
-
- REQUIRE(VirtFs::getRealDir("zzz").empty());
-
- REQUIRE(VirtFs::getRealDir("dir1/file1.txt") ==
- prefix + "data" + sep + "test");
- REQUIRE(VirtFs::getRealDir("hide.png") ==
- prefix + "data" + sep + "test");
- REQUIRE(VirtFs::getRealDir("hide.png") ==
- prefix + "data" + sep + "test");
- REQUIRE(VirtFs::getRealDir("1//test.txt") ==
- prefix + "data" + sep + "test" + sep + "test2.zip");
-
- VirtFs::unmountZip2(prefix + "data/test/test2.zip",
- "dir");
- VirtFs::unmountDir(prefix + "data/test");
-}
-
-TEST_CASE("VirtFs permitLinks1", "")
-{
- VirtFs::mountDirSilent("data", Append_false);
- VirtFs::mountDirSilent("../data", Append_false);
-
- const int cnt1 = VirtFs::exists("test/test2.txt") ? 26 : 25;
- const int cnt2 = 26;
-
- StringVect list;
- VirtFs::permitLinks(false);
- VirtFs::getFiles("test", list);
- removeTemp(list);
- const size_t sz = list.size();
- REQUIRE(sz == cnt1);
-
- list.clear();
- VirtFs::permitLinks(true);
- VirtFs::getFiles("test", list);
- removeTemp(list);
- REQUIRE(list.size() == cnt2);
-
- list.clear();
- VirtFs::permitLinks(false);
- VirtFs::getFiles("test", list);
- removeTemp(list);
- REQUIRE(list.size() == cnt1);
-
- VirtFs::unmountDirSilent("data");
- VirtFs::unmountDirSilent("../data");
-}
-
-TEST_CASE("VirtFs permitLinks2", "")
-{
- VirtFs::mountDirSilent2("data",
- "test",
- Append_false);
- VirtFs::mountDirSilent2("../data",
- "test",
- Append_false);
-
- const int cnt1 = VirtFs::exists("test2.txt") ? 26 : 25;
- const int cnt2 = 26;
-
- StringVect list;
- VirtFs::permitLinks(false);
- VirtFs::getFiles(dirSeparator, list);
- removeTemp(list);
- const size_t sz = list.size();
- REQUIRE(sz == cnt1);
-
- list.clear();
- VirtFs::permitLinks(true);
- VirtFs::getFiles(dirSeparator, list);
- removeTemp(list);
- REQUIRE(list.size() == cnt2);
-
- list.clear();
- VirtFs::permitLinks(false);
- VirtFs::getFiles(dirSeparator, list);
- removeTemp(list);
- REQUIRE(list.size() == cnt1);
-
- VirtFs::unmountDirSilent2("data",
- "test");
- VirtFs::unmountDirSilent2("../data",
- "test");
-}
-
-TEST_CASE("VirtFs read1", "")
-{
- VirtFs::mountDirSilent("data", Append_false);
- VirtFs::mountDirSilent("../data", Append_false);
-
- VirtFs::File *file = VirtFs::openRead("test/test.txt");
- REQUIRE(file != nullptr);
- REQUIRE(VirtFs::fileLength(file) == 23);
- const int fileSize = VirtFs::fileLength(file);
-
- void *restrict buffer = calloc(fileSize + 1, 1);
- REQUIRE(VirtFs::read(file, buffer, 1, fileSize) == fileSize);
- REQUIRE(strcmp(static_cast<char*>(buffer),
- "test line 1\ntest line 2") == 0);
- REQUIRE(VirtFs::tell(file) == fileSize);
- REQUIRE(VirtFs::eof(file) == true);
-
- free(buffer);
- buffer = calloc(fileSize + 1, 1);
- REQUIRE(VirtFs::seek(file, 12) != 0);
- REQUIRE(VirtFs::eof(file) == false);
- REQUIRE(VirtFs::tell(file) == 12);
- REQUIRE(VirtFs::read(file, buffer, 1, 11) == 11);
- REQUIRE(strcmp(static_cast<char*>(buffer),
- "test line 2") == 0);
- REQUIRE(VirtFs::eof(file) == true);
-
- VirtFs::close(file);
- free(buffer);
-
- VirtFs::unmountDirSilent("data");
- VirtFs::unmountDirSilent("../data");
-}
-
-TEST_CASE("VirtFs read2", "")
-{
- std::string name("data/test/test.zip");
- std::string prefix;
- if (Files::existsLocal(name) == false)
- prefix = "../" + prefix;
-
- VirtFs::mountZip(prefix + "data/test/test2.zip", Append_false);
-
- VirtFs::File *file = VirtFs::openRead("dir2/test.txt");
- REQUIRE(file != nullptr);
- REQUIRE(VirtFs::fileLength(file) == 23);
- const int fileSize = VirtFs::fileLength(file);
-
- void *restrict buffer = calloc(fileSize + 1, 1);
- REQUIRE(VirtFs::read(file, buffer, 1, fileSize) == fileSize);
- REQUIRE(strcmp(static_cast<char*>(buffer),
- "test line 1\ntest line 2") == 0);
- REQUIRE(VirtFs::tell(file) == fileSize);
- REQUIRE(VirtFs::eof(file) == true);
-
- free(buffer);
- buffer = calloc(fileSize + 1, 1);
- REQUIRE(VirtFs::seek(file, 12) != 0);
- REQUIRE(VirtFs::eof(file) == false);
- REQUIRE(VirtFs::tell(file) == 12);
- REQUIRE(VirtFs::read(file, buffer, 1, 11) == 11);
- REQUIRE(strcmp(static_cast<char*>(buffer),
- "test line 2") == 0);
- REQUIRE(VirtFs::eof(file) == true);
-
- VirtFs::close(file);
- free(buffer);
-
- VirtFs::unmountZip(prefix + "data/test/test2.zip");
-}
-
-TEST_CASE("VirtFs read3", "")
-{
- std::string name("data/test/test.zip");
- std::string prefix;
- if (Files::existsLocal(name) == false)
- prefix = "../" + prefix;
-
- VirtFs::mountZip(prefix + "data/test/test2.zip", Append_false);
- VirtFs::mountDir(prefix + "data", Append_false);
-
- VirtFs::File *file = VirtFs::openRead("dir2/test.txt");
- REQUIRE(file != nullptr);
- REQUIRE(VirtFs::fileLength(file) == 23);
- const int fileSize = VirtFs::fileLength(file);
-
- void *restrict buffer = calloc(fileSize + 1, 1);
- REQUIRE(VirtFs::read(file, buffer, 1, fileSize) == fileSize);
- REQUIRE(strcmp(static_cast<char*>(buffer),
- "test line 1\ntest line 2") == 0);
- REQUIRE(VirtFs::tell(file) == fileSize);
- REQUIRE(VirtFs::eof(file) == true);
-
- free(buffer);
- buffer = calloc(fileSize + 1, 1);
- REQUIRE(VirtFs::seek(file, 12) != 0);
- REQUIRE(VirtFs::eof(file) == false);
- REQUIRE(VirtFs::tell(file) == 12);
- REQUIRE(VirtFs::read(file, buffer, 1, 11) == 11);
- REQUIRE(strcmp(static_cast<char*>(buffer),
- "test line 2") == 0);
- REQUIRE(VirtFs::eof(file) == true);
-
- VirtFs::close(file);
- free(buffer);
-
- VirtFs::unmountZip(prefix + "data/test/test2.zip");
- VirtFs::unmountDir(prefix + "data");
-}
-
-TEST_CASE("VirtFs read4", "")
-{
- std::string name("data/test/test.zip");
- std::string prefix;
- if (Files::existsLocal(name) == false)
- prefix = "../" + prefix;
-
- VirtFs::mountDir(prefix + "data/test", Append_true);
- VirtFs::mountZip(prefix + "data/test/test5.zip", Append_true);
-
- VirtFs::File *file = VirtFs::openRead("dir1/file1.txt");
- REQUIRE(file != nullptr);
- REQUIRE(VirtFs::fileLength(file) == 23);
- const int fileSize = VirtFs::fileLength(file);
-
- void *restrict buffer = calloc(fileSize + 1, 1);
- REQUIRE(VirtFs::read(file, buffer, 1, fileSize) == fileSize);
- REQUIRE(strcmp(static_cast<char*>(buffer),
- "test line 1\ntest line 2") == 0);
- REQUIRE(VirtFs::tell(file) == fileSize);
- REQUIRE(VirtFs::eof(file) == true);
-
- free(buffer);
- buffer = calloc(fileSize + 1, 1);
- REQUIRE(VirtFs::seek(file, 12) != 0);
- REQUIRE(VirtFs::eof(file) == false);
- REQUIRE(VirtFs::tell(file) == 12);
- REQUIRE(VirtFs::read(file, buffer, 1, 11) == 11);
- REQUIRE(strcmp(static_cast<char*>(buffer),
- "test line 2") == 0);
- REQUIRE(VirtFs::eof(file) == true);
-
- VirtFs::close(file);
- free(buffer);
-
- VirtFs::unmountZip(prefix + "data/test/test5.zip");
- VirtFs::unmountDir(prefix + "data/test");
-}
-
-TEST_CASE("VirtFs read5", "")
-{
- std::string name("data/test/test.zip");
- std::string prefix;
- if (Files::existsLocal(name) == false)
- prefix = "../" + prefix;
-
- VirtFs::mountZip(prefix + "data/test/test5.zip", Append_true);
- VirtFs::mountDir(prefix + "data/test", Append_true);
-
- VirtFs::File *file = VirtFs::openRead("dir1/file1.txt");
- REQUIRE(file != nullptr);
- REQUIRE(VirtFs::fileLength(file) == 23);
- const int fileSize = VirtFs::fileLength(file);
-
- void *restrict buffer = calloc(fileSize + 1, 1);
- REQUIRE(VirtFs::read(file, buffer, 1, fileSize) == fileSize);
- REQUIRE(strcmp(static_cast<char*>(buffer),
- "test line 3\ntest line 4") == 0);
- REQUIRE(VirtFs::tell(file) == fileSize);
- REQUIRE(VirtFs::eof(file) == true);
-
- free(buffer);
- buffer = calloc(fileSize + 1, 1);
- REQUIRE(VirtFs::seek(file, 12) != 0);
- REQUIRE(VirtFs::eof(file) == false);
- REQUIRE(VirtFs::tell(file) == 12);
- REQUIRE(VirtFs::read(file, buffer, 1, 11) == 11);
- REQUIRE(strcmp(static_cast<char*>(buffer),
- "test line 4") == 0);
- REQUIRE(VirtFs::eof(file) == true);
-
- VirtFs::close(file);
- free(buffer);
-
- VirtFs::unmountZip(prefix + "data/test/test5.zip");
- VirtFs::unmountDir(prefix + "data/test");
-}
diff --git a/src/unittests/fs/virtfs/virtfs1_basic.cc b/src/unittests/fs/virtfs/virtfs1_basic.cc
deleted file mode 100644
index 73153df37..000000000
--- a/src/unittests/fs/virtfs/virtfs1_basic.cc
+++ /dev/null
@@ -1,46 +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 "unittests/unittests.h"
-
-#include "fs/virtfs/fs.h"
-
-#include "utils/checkutils.h"
-
-#ifndef UNITTESTS_CATCH
-#include <algorithm>
-#endif // UNITTESTS_CATCH
-
-#include "debug.h"
-
-TEST_CASE("VirtFs1 getEntries", "")
-{
- VirtFs::init(".");
- REQUIRE(VirtFs::getEntries().empty());
- REQUIRE(VirtFs::searchByRootInternal("test", std::string()) == nullptr);
- VirtFs::deinit();
-}
-
-TEST_CASE("VirtFs1 getBaseDir", "")
-{
- VirtFs::init(".");
- REQUIRE(VirtFs::getBaseDir() != nullptr);
- VirtFs::deinit();
-}
diff --git a/src/unittests/fs/virtfs/virtfs1_enumerate.cc b/src/unittests/fs/virtfs/virtfs1_enumerate.cc
deleted file mode 100644
index 4eb79e673..000000000
--- a/src/unittests/fs/virtfs/virtfs1_enumerate.cc
+++ /dev/null
@@ -1,410 +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 "unittests/unittests.h"
-
-#include "fs/files.h"
-
-#include "fs/virtfs/fs.h"
-#include "fs/virtfs/list.h"
-
-#include "utils/checkutils.h"
-#include "utils/foreach.h"
-
-#ifndef UNITTESTS_CATCH
-#include <algorithm>
-#endif // UNITTESTS_CATCH
-
-#include "debug.h"
-
-static void removeTemp(StringVect &restrict list)
-{
- int cnt = 0;
- std::sort(list.begin(), list.end());
-
- FOR_EACH (StringVectIter, it, list)
- {
- if (*it != "serverlistplus.xml.part")
- {
- logger->log("file: %d %s",
- cnt,
- (*it).c_str());
- cnt ++;
- }
- }
-
- FOR_EACH (StringVectIter, it, list)
- {
- if (*it == "serverlistplus.xml.part")
- {
- list.erase(it);
- return;
- }
- }
-}
-
-static bool inList(const VirtFs::List *const list,
- const std::string &name)
-{
- FOR_EACH (StringVectCIter, it, list->names)
- {
- if (*it == name)
- return true;
- }
- return false;
-}
-
-TEST_CASE("VirtFs1 enumerateFiles1", "")
-{
- VirtFs::init(".");
-
- VirtFs::mountDirSilent("data",
- Append_false);
- VirtFs::mountDirSilent("../data",
- Append_false);
-
- VirtFs::List *list = nullptr;
-
- const int cnt1 = VirtFs::exists("test/test2.txt") ? 28 : 27;
- const int cnt2 = 28;
-
- VirtFs::permitLinks(false);
- list = VirtFs::enumerateFiles("test");
- removeTemp(list->names);
- const size_t sz = list->names.size();
- REQUIRE(sz == cnt1);
- VirtFs::freeList(list);
-
- VirtFs::permitLinks(true);
- list = VirtFs::enumerateFiles("test/");
- removeTemp(list->names);
- REQUIRE(list->names.size() == cnt2);
- VirtFs::freeList(list);
-
- VirtFs::permitLinks(true);
- list = VirtFs::enumerateFiles("test/units.xml");
- REQUIRE(list->names.empty());
- VirtFs::freeList(list);
-
- VirtFs::permitLinks(false);
- list = VirtFs::enumerateFiles("test\\");
- removeTemp(list->names);
- REQUIRE(list->names.size() == cnt1);
- VirtFs::freeList(list);
-
- VirtFs::unmountDirSilent("data");
- VirtFs::unmountDirSilent("../data");
- VirtFs::deinit();
-}
-
-TEST_CASE("VirtFs1 enumerateFiles2", "")
-{
- VirtFs::init(".");
-
- VirtFs::mountDirSilent("data/test/dir1",
- Append_false);
- VirtFs::mountDirSilent("../data/test/dir1",
- Append_false);
-
- VirtFs::List *list = nullptr;
-
- list = VirtFs::enumerateFiles("/");
- REQUIRE(list->names.size() == 5);
- REQUIRE(inList(list, "file1.txt"));
- REQUIRE_FALSE(inList(list, "file2.txt"));
- VirtFs::freeList(list);
- VirtFs::deinit();
-}
-
-TEST_CASE("VirtFs1 enumerateFiles3", "")
-{
- VirtFs::init(".");
-
- VirtFs::mountDirSilent("data/test/dir1",
- Append_false);
- VirtFs::mountDirSilent("../data/test/dir1",
- Append_false);
- VirtFs::mountDirSilent("data/test/dir2",
- Append_false);
- VirtFs::mountDirSilent("../data/test/dir2",
- Append_false);
-
- VirtFs::List *list = nullptr;
-
- list = VirtFs::enumerateFiles("/");
- REQUIRE(inList(list, "file1.txt"));
- REQUIRE(inList(list, "file2.txt"));
- VirtFs::freeList(list);
- VirtFs::deinit();
-}
-
-TEST_CASE("VirtFsZip enumerateFiles4", "")
-{
- VirtFs::init(".");
- std::string name("data/test/test.zip");
- std::string prefix("data\\test/");
- if (Files::existsLocal(name) == false)
- prefix = "../" + prefix;
-
- VirtFs::mountZip(prefix + "test.zip",
- Append_false);
-
- VirtFs::List *list = nullptr;
-
- list = VirtFs::enumerateFiles("dir");
- REQUIRE(list->names.size() == 2);
- REQUIRE(inList(list, "brimmedhat.png"));
- REQUIRE(inList(list, "hide.png"));
- VirtFs::freeList(list);
-
- VirtFs::unmountZip(prefix + "test.zip");
- VirtFs::deinit();
-}
-
-TEST_CASE("VirtFsZip enumerateFiles5", "")
-{
- VirtFs::init(".");
- std::string name("data/test/test.zip");
- std::string prefix("data//test/");
- if (Files::existsLocal(name) == false)
- prefix = "../" + prefix;
-
- VirtFs::mountZip(prefix + "test.zip",
- Append_true);
- VirtFs::mountZip(prefix + "test2.zip",
- Append_true);
-
- VirtFs::List *list = nullptr;
-
- list = VirtFs::enumerateFiles("dir");
- FOR_EACH (StringVectCIter, it, list->names)
- {
- logger->log("filename: " + *it);
- }
-
- REQUIRE(list->names.size() == 5);
- REQUIRE(inList(list, "brimmedhat.png"));
- REQUIRE(inList(list, "hide.png"));
- REQUIRE(inList(list, "1"));
- REQUIRE(inList(list, "gpl"));
- REQUIRE(inList(list, "dye.png"));
- VirtFs::freeList(list);
-
- VirtFs::unmountZip(prefix + "test.zip");
- VirtFs::unmountZip(prefix + "test2.zip");
- VirtFs::deinit();
-}
-
-TEST_CASE("VirtFsZip enumerateFiles6", "")
-{
- VirtFs::init(".");
- std::string name("data/test/test.zip");
- std::string prefix("data\\test/");
- if (Files::existsLocal(name) == false)
- prefix = "../" + prefix;
-
- VirtFs::mountZip(prefix + "test.zip",
- Append_false);
-
- VirtFs::List *list = nullptr;
-
- list = VirtFs::enumerateFiles("/");
- REQUIRE(list->names.size() == 1);
- REQUIRE(inList(list, "dir"));
- VirtFs::freeList(list);
-
- VirtFs::unmountZip(prefix + "test.zip");
- VirtFs::deinit();
-}
-
-TEST_CASE("VirtFsZip enumerateFiles7", "")
-{
- VirtFs::init(".");
- std::string name("data/test/test.zip");
- std::string prefix("data\\test/");
- if (Files::existsLocal(name) == false)
- prefix = "../" + prefix;
-
- VirtFs::mountZip(prefix + "test2.zip",
- Append_false);
-
- VirtFs::List *list = nullptr;
-
- list = VirtFs::enumerateFiles("/");
- REQUIRE(list->names.size() == 4);
- REQUIRE(inList(list, "dir"));
- REQUIRE(inList(list, "dir2"));
- REQUIRE(inList(list, "test.txt"));
- REQUIRE(inList(list, "units.xml"));
- VirtFs::freeList(list);
-
- VirtFs::unmountZip(prefix + "test2.zip");
- VirtFs::deinit();
-}
-
-TEST_CASE("VirtFsZip enumerateFiles8", "")
-{
- VirtFs::init(".");
- std::string name("data/test/test.zip");
- std::string prefix;
- if (Files::existsLocal(name) == false)
- prefix = "../" + prefix;
-
- VirtFs::mountZip(prefix + "data/test/test2.zip",
- Append_false);
- VirtFs::mountDirSilent(prefix + "data/test",
- Append_false);
-
- VirtFs::List *list = nullptr;
-
- list = VirtFs::enumerateFiles("dir2");
- REQUIRE(list->names.size() >= 6);
- REQUIRE(inList(list, "file1.txt"));
- REQUIRE(inList(list, "file2.txt"));
- REQUIRE(inList(list, "hide.png"));
- REQUIRE(inList(list, "paths.xml"));
- REQUIRE(inList(list, "test.txt"));
- REQUIRE(inList(list, "units.xml"));
- VirtFs::freeList(list);
-
- VirtFs::unmountZip(prefix + "data/test/test2.zip");
- VirtFs::unmountDir(prefix + "data/test");
- VirtFs::deinit();
-}
-
-TEST_CASE("VirtFsZip enumerateFiles9", "")
-{
- VirtFs::init(".");
- std::string name("data/test/test.zip");
- std::string prefix;
- if (Files::existsLocal(name) == false)
- prefix = "../" + prefix;
-
- VirtFs::mountZip(prefix + "data/test/test2.zip",
- Append_false);
- VirtFs::mountDirSilent(prefix + "data/test",
- Append_false);
-
- VirtFs::List *list = nullptr;
-
- list = VirtFs::enumerateFiles("dir");
- REQUIRE(list->names.size() == 4);
- REQUIRE(inList(list, "1"));
- REQUIRE(inList(list, "gpl"));
- REQUIRE(inList(list, "dye.png"));
- REQUIRE(inList(list, "hide.png"));
- VirtFs::freeList(list);
-
- VirtFs::unmountZip(prefix + "data/test/test2.zip");
- VirtFs::unmountDir(prefix + "data/test");
- VirtFs::deinit();
-}
-
-TEST_CASE("VirtFsZip enumerateFiles10", "")
-{
- VirtFs::init(".");
- std::string name("data/test/test.zip");
- std::string prefix("data\\test/");
- if (Files::existsLocal(name) == false)
- prefix = "../" + prefix;
-
- VirtFs::mountZip2(prefix + "test.zip",
- "dir",
- Append_false);
-
- VirtFs::List *list = nullptr;
-
- list = VirtFs::enumerateFiles("/");
- REQUIRE(list->names.size() == 2);
- REQUIRE(inList(list, "brimmedhat.png"));
- REQUIRE(inList(list, "hide.png"));
- VirtFs::freeList(list);
-
- VirtFs::unmountZip2(prefix + "test.zip",
- "dir");
- VirtFs::deinit();
-}
-
-TEST_CASE("VirtFsZip enumerateFiles11", "")
-{
- VirtFs::init(".");
- std::string name("data/test/test.zip");
- std::string prefix("data\\test/");
- if (Files::existsLocal(name) == false)
- prefix = "../" + prefix;
-
- VirtFs::mountZip2(prefix + "test2.zip",
- "dir",
- Append_false);
-
- VirtFs::List *list = nullptr;
-
- list = VirtFs::enumerateFiles("1");
- REQUIRE(list->names.size() == 2);
- REQUIRE(inList(list, "file1.txt"));
- REQUIRE(inList(list, "test.txt"));
- VirtFs::freeList(list);
-
- VirtFs::unmountZip2(prefix + "test2.zip",
- "dir");
- VirtFs::deinit();
-}
-
-TEST_CASE("VirtFs1 enumerateFiles12", "")
-{
- VirtFs::init(".");
-
- VirtFs::mountDirSilent2("data/test",
- "dir2",
- Append_false);
- VirtFs::mountDirSilent2("../data/test",
- "dir2",
- Append_false);
-
- VirtFs::List *list = nullptr;
-
- list = VirtFs::enumerateFiles("/");
- REQUIRE(inList(list, "file1.txt"));
- REQUIRE(inList(list, "file2.txt"));
- VirtFs::freeList(list);
-
- VirtFs::deinit();
-}
-
-TEST_CASE("VirtFs1 enumerateFiles13", "")
-{
- VirtFs::init(".");
-
- VirtFs::mountDirSilent2("data",
- "test",
- Append_false);
- VirtFs::mountDirSilent2("../data",
- "test",
- Append_false);
-
- VirtFs::List *list = nullptr;
-
- list = VirtFs::enumerateFiles("dir2");
- REQUIRE(inList(list, "file1.txt"));
- REQUIRE(inList(list, "file2.txt"));
- VirtFs::freeList(list);
-
- VirtFs::deinit();
-}
diff --git a/src/unittests/fs/virtfs/virtfs1_exists.cc b/src/unittests/fs/virtfs/virtfs1_exists.cc
deleted file mode 100644
index 24f3e19f2..000000000
--- a/src/unittests/fs/virtfs/virtfs1_exists.cc
+++ /dev/null
@@ -1,154 +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 "unittests/unittests.h"
-
-#include "fs/virtfs/fs.h"
-
-#include "utils/checkutils.h"
-
-#ifndef UNITTESTS_CATCH
-#include <algorithm>
-#endif // UNITTESTS_CATCH
-
-#include "debug.h"
-
-TEST_CASE("VirtFs1 exists1", "")
-{
- VirtFs::init(".");
- const bool dir1 = VirtFs::mountDirSilent("data/",
- Append_false);
- VirtFs::mountDirSilent("..\\data",
- Append_false);
-
- REQUIRE(VirtFs::exists("test"));
- REQUIRE(VirtFs::exists("test/"));
- REQUIRE(VirtFs::exists("test/dir1"));
- REQUIRE(VirtFs::exists("test/dir1/"));
- REQUIRE(VirtFs::exists("test/dir") == false);
- REQUIRE(VirtFs::exists("test//units.xml") == true);
- REQUIRE(VirtFs::exists("test/\\units123.xml") == false);
- REQUIRE(VirtFs::exists("tesQ/units.xml") == false);
- REQUIRE(VirtFs::exists("units.xml") == false);
-
- if (dir1 == true)
- {
- VirtFs::mountDir("data//test",
- Append_false);
- }
- else
- {
- VirtFs::mountDirSilent("..//data\\test",
- Append_false);
- }
-
- REQUIRE(VirtFs::exists("test") == true);
- REQUIRE(VirtFs::exists("test/dir1"));
- REQUIRE(VirtFs::exists("test/dir1\\"));
- REQUIRE(VirtFs::exists("test/dir") == false);
- REQUIRE(VirtFs::exists("test\\units.xml") == true);
- REQUIRE(VirtFs::exists("test/units123.xml") == false);
- REQUIRE(VirtFs::exists("tesQ/units.xml") == false);
- REQUIRE(VirtFs::exists("units.xml") == true);
- REQUIRE(VirtFs::exists("units.xml/") == false);
-
- if (dir1 == true)
- VirtFs::unmountDirSilent("data/test");
- else
- VirtFs::unmountDirSilent("../data/test");
-
- REQUIRE(VirtFs::exists("test") == true);
- REQUIRE(VirtFs::exists("test/dir1"));
- REQUIRE(VirtFs::exists("test/dir") == false);
- REQUIRE(VirtFs::exists("test\\units.xml") == true);
- REQUIRE(VirtFs::exists("test/units123.xml") == false);
- REQUIRE(VirtFs::exists("tesQ/units.xml") == false);
- REQUIRE(VirtFs::exists("units.xml") == false);
- REQUIRE(VirtFs::exists("units.xml/") == false);
-
- VirtFs::deinit();
-}
-
-TEST_CASE("VirtFs1 exists2", "")
-{
- VirtFs::init(".");
- const bool dir1 = VirtFs::mountDirSilent2("data/",
- "test",
- Append_false);
- VirtFs::mountDirSilent2("..\\data",
- "test",
- Append_false);
-
- REQUIRE(VirtFs::exists("test") == false);
- REQUIRE(VirtFs::exists("test/") == false);
- REQUIRE(VirtFs::exists("dir1"));
- REQUIRE(VirtFs::exists("dir1/"));
- REQUIRE(VirtFs::exists("dir") == false);
- REQUIRE(VirtFs::exists("units.xml") == true);
- REQUIRE(VirtFs::exists("units123.xml") == false);
- REQUIRE(VirtFs::exists("tesQ/units.xml") == false);
- REQUIRE(VirtFs::exists("units.xml"));
- REQUIRE(VirtFs::exists("file1.txt") == false);
- REQUIRE(VirtFs::exists("file2.txt") == false);
-
- if (dir1 == true)
- {
- VirtFs::mountDir2("data//test",
- "dir2",
- Append_false);
- }
- else
- {
- VirtFs::mountDirSilent2("..//data\\test",
- "dir2",
- Append_false);
- }
-
- REQUIRE(VirtFs::exists("test") == false);
- REQUIRE(VirtFs::exists("test/") == false);
- REQUIRE(VirtFs::exists("dir1"));
- REQUIRE(VirtFs::exists("dir1/"));
- REQUIRE(VirtFs::exists("dir") == false);
- REQUIRE(VirtFs::exists("units.xml") == true);
- REQUIRE(VirtFs::exists("units123.xml") == false);
- REQUIRE(VirtFs::exists("tesQ/units.xml") == false);
- REQUIRE(VirtFs::exists("units.xml"));
- REQUIRE(VirtFs::exists("file1.txt"));
- REQUIRE(VirtFs::exists("file2.txt"));
-
- if (dir1 == true)
- VirtFs::unmountDirSilent2("data/test", "dir2");
- else
- VirtFs::unmountDirSilent2("../data/test", "dir2");
-
- REQUIRE(VirtFs::exists("test") == false);
- REQUIRE(VirtFs::exists("test/") == false);
- REQUIRE(VirtFs::exists("dir1"));
- REQUIRE(VirtFs::exists("dir1/"));
- REQUIRE(VirtFs::exists("dir") == false);
- REQUIRE(VirtFs::exists("units.xml") == true);
- REQUIRE(VirtFs::exists("units123.xml") == false);
- REQUIRE(VirtFs::exists("tesQ/units.xml") == false);
- REQUIRE(VirtFs::exists("units.xml"));
- REQUIRE(VirtFs::exists("file1.txt") == false);
- REQUIRE(VirtFs::exists("file2.txt") == false);
-
- VirtFs::deinit();
-}
diff --git a/src/unittests/fs/virtfs/virtfs1_getrealdir.cc b/src/unittests/fs/virtfs/virtfs1_getrealdir.cc
deleted file mode 100644
index ca58a993e..000000000
--- a/src/unittests/fs/virtfs/virtfs1_getrealdir.cc
+++ /dev/null
@@ -1,202 +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 "unittests/unittests.h"
-
-#include "fs/files.h"
-
-#include "fs/virtfs/fs.h"
-
-#include "utils/checkutils.h"
-
-#ifndef UNITTESTS_CATCH
-#include <algorithm>
-#endif // UNITTESTS_CATCH
-
-#include "debug.h"
-
-TEST_CASE("VirtFs1 getRealDir1", "")
-{
- VirtFs::init(".");
- const std::string sep = dirSeparator;
- REQUIRE(VirtFs::getRealDir(".").empty());
- REQUIRE(VirtFs::getRealDir("..").empty());
- const bool dir1 = VirtFs::mountDirSilent("data",
- Append_false);
- REQUIRE((dir1 || VirtFs::mountDirSilent("../data",
- Append_false)) == true);
- if (dir1 == true)
- {
- REQUIRE(VirtFs::getRealDir("test") == "data");
- REQUIRE(VirtFs::getRealDir("test/test.txt") ==
- "data");
- REQUIRE(VirtFs::getRealDir("test\\test.txt") ==
- "data");
- REQUIRE(VirtFs::getRealDir("test//test.txt") ==
- "data");
- }
- else
- {
- REQUIRE(VirtFs::getRealDir("test") == "../data");
- REQUIRE(VirtFs::getRealDir("test/test.txt") ==
- "../data");
- REQUIRE(VirtFs::getRealDir("test\\test.txt") ==
- "../data");
- REQUIRE(VirtFs::getRealDir("test//test.txt") ==
- "../data");
- }
- REQUIRE(VirtFs::getRealDir("zzz").empty());
-
- VirtFs::mountDirSilent("data/test",
- Append_false);
- VirtFs::mountDirSilent("../data/test",
- Append_false);
- if (dir1 == true)
- {
- REQUIRE(VirtFs::getRealDir("test") == "data");
- REQUIRE(VirtFs::getRealDir("test/test.txt") ==
- "data");
- REQUIRE(VirtFs::getRealDir("test\\test.txt") ==
- "data");
- REQUIRE(VirtFs::getRealDir("test.txt") ==
- "data" + sep + "test");
- }
- else
- {
- REQUIRE(VirtFs::getRealDir("test") == ".." + sep + "data");
- REQUIRE(VirtFs::getRealDir("test/test.txt") ==
- ".." + sep + "data");
- REQUIRE(VirtFs::getRealDir("test\\test.txt") ==
- ".." + sep + "data");
- REQUIRE(VirtFs::getRealDir("test.txt") ==
- ".." + sep + "data" + sep + "test");
- }
- REQUIRE(VirtFs::getRealDir("zzz").empty());
-
- VirtFs::unmountDirSilent("data/test");
- VirtFs::unmountDirSilent("../data/test");
-
- if (dir1 == true)
- {
- REQUIRE(VirtFs::getRealDir("test") == "data");
- REQUIRE(VirtFs::getRealDir("test/test.txt") ==
- "data");
- }
- else
- {
- REQUIRE(VirtFs::getRealDir("test") == ".." + sep + "data");
- REQUIRE(VirtFs::getRealDir("test/test.txt") ==
- ".." + sep + "data");
- }
- REQUIRE(VirtFs::getRealDir("zzz").empty());
-
- VirtFs::unmountDirSilent("data");
- VirtFs::unmountDirSilent("../data");
- VirtFs::deinit();
-}
-
-TEST_CASE("VirtFs1 getRealDir2", "")
-{
- VirtFs::init(".");
- const std::string sep = dirSeparator;
- std::string name("data/test/test.zip");
- std::string prefix("data" + sep + "test" + sep);
- if (Files::existsLocal(name) == false)
- prefix = ".." + sep + prefix;
- VirtFs::mountZip(prefix + "test2.zip",
- Append_false);
-
- REQUIRE(VirtFs::getRealDir(".").empty());
- REQUIRE(VirtFs::getRealDir("..").empty());
- REQUIRE(VirtFs::getRealDir("test.txt") == prefix + "test2.zip");
- REQUIRE(VirtFs::getRealDir("dir/1") == prefix + "test2.zip");
- REQUIRE(VirtFs::getRealDir("dir\\dye.png") ==
- prefix + "test2.zip");
- REQUIRE(VirtFs::getRealDir("zzz").empty());
-
- VirtFs::mountZip(prefix + "test.zip",
- Append_false);
- REQUIRE(VirtFs::getRealDir("dir//dye.png") ==
- prefix + "test2.zip");
- REQUIRE(VirtFs::getRealDir("dir///hide.png") ==
- prefix + "test.zip");
- REQUIRE(VirtFs::getRealDir("dir\\\\brimmedhat.png") ==
- prefix + "test.zip");
- REQUIRE(VirtFs::getRealDir("zzz").empty());
-
- VirtFs::unmountZip(prefix + "test.zip");
-
- REQUIRE(VirtFs::getRealDir("dir/brimmedhat.png").empty());
- REQUIRE(VirtFs::getRealDir("test.txt") == prefix + "test2.zip");
- REQUIRE(VirtFs::getRealDir("dir//dye.png") ==
- prefix + "test2.zip");
- REQUIRE(VirtFs::getRealDir("zzz").empty());
-
- VirtFs::unmountZip(prefix + "test2.zip");
- VirtFs::deinit();
-}
-
-TEST_CASE("VirtFs1 getRealDir3", "")
-{
- VirtFs::init(".");
- const std::string sep = dirSeparator;
- REQUIRE(VirtFs::getRealDir(".").empty());
- REQUIRE(VirtFs::getRealDir("..").empty());
- const bool dir1 = VirtFs::mountDirSilent2("data",
- "test",
- Append_false);
- REQUIRE((dir1 || VirtFs::mountDirSilent2("../data",
- "test",
- Append_false)) == true);
- REQUIRE(VirtFs::getRealDir("file1.txt").empty());
- if (dir1 == true)
- {
- REQUIRE(VirtFs::getRealDir("dir1") == "data");
- REQUIRE(VirtFs::getRealDir("simplefile.txt") == "data");
- }
- else
- {
- REQUIRE(VirtFs::getRealDir("dir1") == ".." + sep + "data");
- REQUIRE(VirtFs::getRealDir("simplefile.txt") == ".." + sep + "data");
- }
- REQUIRE(VirtFs::getRealDir("zzz").empty());
-
- VirtFs::mountDirSilent2("data/test",
- "dir2",
- Append_false);
- VirtFs::mountDirSilent2("../data/test",
- "dir2",
- Append_false);
- REQUIRE(VirtFs::getRealDir("dir").empty());
- if (dir1 == true)
- {
- REQUIRE(VirtFs::getRealDir("file1.txt") == "data" + sep + "test");
- REQUIRE(VirtFs::getRealDir("simplefile.txt") == "data");
- }
- else
- {
- REQUIRE(VirtFs::getRealDir("file1.txt") ==
- ".." + sep + "data" + sep + "test");
- REQUIRE(VirtFs::getRealDir("simplefile.txt") == ".." + sep + "data");
- }
- REQUIRE(VirtFs::getRealDir("zzz").empty());
-
- VirtFs::deinit();
-}
diff --git a/src/unittests/fs/virtfs/virtfs1_mountdir1.cc b/src/unittests/fs/virtfs/virtfs1_mountdir1.cc
deleted file mode 100644
index 92d6d037d..000000000
--- a/src/unittests/fs/virtfs/virtfs1_mountdir1.cc
+++ /dev/null
@@ -1,195 +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 "unittests/unittests.h"
-
-#include "fs/virtfs/direntry.h"
-#include "fs/virtfs/fs.h"
-
-#include "utils/checkutils.h"
-
-#ifndef UNITTESTS_CATCH
-#include <algorithm>
-#endif // UNITTESTS_CATCH
-
-#include "debug.h"
-
-TEST_CASE("VirtFs1 mountDir1", "")
-{
- VirtFs::init(".");
- const std::string sep = dirSeparator;
- SECTION("simple 1")
- {
- REQUIRE(VirtFs::mountDirSilentTest("dir1",
- Append_false));
- REQUIRE(VirtFs::searchByRootInternal("dir1" + sep, std::string()) !=
- nullptr);
- REQUIRE(VirtFs::searchByRootInternal("dir1" + sep, "dir1") ==
- nullptr);
- REQUIRE(VirtFs::searchByRootInternal("test" + sep, std::string()) ==
- nullptr);
- REQUIRE(VirtFs::getEntries().size() == 1);
- REQUIRE(VirtFs::getEntries()[0]->root == "dir1" + sep);
- REQUIRE(VirtFs::getEntries()[0]->subDir.empty());
- REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
- REQUIRE(static_cast<VirtFs::DirEntry*>(
- VirtFs::getEntries()[0])->userDir == "dir1");
- }
-
- SECTION("simple 2")
- {
- REQUIRE(VirtFs::mountDirSilentTest("dir1/",
- Append_true));
- REQUIRE(VirtFs::searchByRootInternal("dir1" + sep, std::string()) !=
- nullptr);
- REQUIRE(VirtFs::searchByRootInternal("dir1" + sep, "dir1") ==
- nullptr);
- REQUIRE(VirtFs::searchByRootInternal("test" + sep, std::string()) ==
- nullptr);
- REQUIRE(VirtFs::getEntries().size() == 1);
- REQUIRE(VirtFs::getEntries()[0]->root == "dir1" + sep);
- REQUIRE(VirtFs::getEntries()[0]->subDir.empty());
- REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
- REQUIRE(static_cast<VirtFs::DirEntry*>(
- VirtFs::getEntries()[0])->userDir == "dir1" + sep);
- }
-
- SECTION("simple 3")
- {
- REQUIRE(VirtFs::mountDirSilentTest("dir1",
- Append_false));
- REQUIRE(VirtFs::mountDirSilentTest("dir2",
- Append_false));
- REQUIRE(VirtFs::searchByRootInternal("dir1" + sep, std::string()) !=
- nullptr);
- REQUIRE(VirtFs::searchByRootInternal("dir1" + sep, "dir1") ==
- nullptr);
- REQUIRE(VirtFs::searchByRootInternal("dir2" + sep, std::string()) !=
- nullptr);
- REQUIRE(VirtFs::searchByRootInternal("test" + sep, std::string()) ==
- nullptr);
- REQUIRE(VirtFs::getEntries().size() == 2);
- REQUIRE(VirtFs::getEntries()[0]->root == "dir2" + sep);
- REQUIRE(VirtFs::getEntries()[1]->root == "dir1" + sep);
- REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
- REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Dir);
- REQUIRE(VirtFs::getEntries()[0]->subDir.empty());
- REQUIRE(VirtFs::getEntries()[1]->subDir.empty());
- REQUIRE(static_cast<VirtFs::DirEntry*>(
- VirtFs::getEntries()[0])->userDir == "dir2");
- REQUIRE(static_cast<VirtFs::DirEntry*>(
- VirtFs::getEntries()[1])->userDir == "dir1");
- }
-
- SECTION("simple 4")
- {
- REQUIRE(VirtFs::mountDirSilentTest("dir1\\",
- Append_true));
- REQUIRE(VirtFs::mountDirSilentTest("dir2",
- Append_true));
- REQUIRE(VirtFs::searchByRootInternal("dir1" + sep, std::string()) !=
- nullptr);
- REQUIRE(VirtFs::searchByRootInternal("dir2" + sep, std::string()) !=
- nullptr);
- REQUIRE(VirtFs::searchByRootInternal("test" + sep, std::string()) ==
- nullptr);
- REQUIRE(VirtFs::getEntries().size() == 2);
- REQUIRE(VirtFs::getEntries()[0]->root == "dir1" + sep);
- REQUIRE(VirtFs::getEntries()[1]->root == "dir2" + sep);
- REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
- REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Dir);
- REQUIRE(VirtFs::getEntries()[0]->subDir.empty());
- REQUIRE(VirtFs::getEntries()[1]->subDir.empty());
- REQUIRE(static_cast<VirtFs::DirEntry*>(
- VirtFs::getEntries()[0])->userDir == "dir1" + sep);
- REQUIRE(static_cast<VirtFs::DirEntry*>(
- VirtFs::getEntries()[1])->userDir == "dir2");
- }
-
- SECTION("simple 5")
- {
- REQUIRE(VirtFs::mountDirSilentTest("dir1",
- Append_true));
- REQUIRE(VirtFs::mountDirSilentTest("dir2",
- Append_true));
- REQUIRE(VirtFs::mountDirSilentTest("dir3/test",
- Append_true));
- REQUIRE(VirtFs::searchByRootInternal("dir1" + sep, std::string()) !=
- nullptr);
- REQUIRE(VirtFs::searchByRootInternal("dir2" + sep, std::string()) !=
- nullptr);
- REQUIRE(VirtFs::searchByRootInternal(
- "dir3" + sep + "test" + sep, std::string()) != nullptr);
- REQUIRE(VirtFs::searchByRootInternal("test" + sep, std::string()) ==
- nullptr);
- REQUIRE(VirtFs::getEntries().size() == 3);
- REQUIRE(VirtFs::getEntries()[0]->root == "dir1" + sep);
- REQUIRE(VirtFs::getEntries()[1]->root == "dir2" + sep);
- REQUIRE(VirtFs::getEntries()[2]->root == "dir3" + sep + "test" + sep);
- REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
- REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Dir);
- REQUIRE(VirtFs::getEntries()[2]->type == FsEntryType::Dir);
- REQUIRE(VirtFs::getEntries()[0]->subDir.empty());
- REQUIRE(VirtFs::getEntries()[1]->subDir.empty());
- REQUIRE(VirtFs::getEntries()[2]->subDir.empty());
- REQUIRE(static_cast<VirtFs::DirEntry*>(
- VirtFs::getEntries()[0])->userDir == "dir1");
- REQUIRE(static_cast<VirtFs::DirEntry*>(
- VirtFs::getEntries()[1])->userDir == "dir2");
- REQUIRE(static_cast<VirtFs::DirEntry*>(
- VirtFs::getEntries()[2])->userDir == "dir3" + sep + "test");
- }
-
- SECTION("simple 6")
- {
- REQUIRE(VirtFs::mountDirSilentTest("dir1",
- Append_true));
- REQUIRE(VirtFs::mountDirSilentTest("dir2",
- Append_true));
- REQUIRE(VirtFs::mountDirSilentTest("dir3\\test",
- Append_false));
- REQUIRE(VirtFs::searchByRootInternal(
- "dir1" + sep + "", std::string()) != nullptr);
- REQUIRE(VirtFs::searchByRootInternal(
- "dir2" + sep + "", std::string()) != nullptr);
- REQUIRE(VirtFs::searchByRootInternal(
- "dir3" + sep + "test" + sep, std::string()) != nullptr);
- REQUIRE(VirtFs::searchByRootInternal(
- "test" + sep + "", std::string()) == nullptr);
- REQUIRE(VirtFs::getEntries().size() == 3);
- REQUIRE(VirtFs::getEntries()[0]->root == "dir3" + sep + "test" + sep);
- REQUIRE(VirtFs::getEntries()[1]->root == "dir1" + sep);
- REQUIRE(VirtFs::getEntries()[2]->root == "dir2" + sep);
- REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
- REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Dir);
- REQUIRE(VirtFs::getEntries()[2]->type == FsEntryType::Dir);
- REQUIRE(VirtFs::getEntries()[0]->subDir.empty());
- REQUIRE(VirtFs::getEntries()[1]->subDir.empty());
- REQUIRE(VirtFs::getEntries()[2]->subDir.empty());
- REQUIRE(static_cast<VirtFs::DirEntry*>(
- VirtFs::getEntries()[0])->userDir == "dir3" + sep + "test");
- REQUIRE(static_cast<VirtFs::DirEntry*>(
- VirtFs::getEntries()[1])->userDir == "dir1");
- REQUIRE(static_cast<VirtFs::DirEntry*>(
- VirtFs::getEntries()[2])->userDir == "dir2");
- }
-
- VirtFs::deinit();
-}
diff --git a/src/unittests/fs/virtfs/virtfs1_mountdir2.cc b/src/unittests/fs/virtfs/virtfs1_mountdir2.cc
deleted file mode 100644
index 35900389f..000000000
--- a/src/unittests/fs/virtfs/virtfs1_mountdir2.cc
+++ /dev/null
@@ -1,315 +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 "unittests/unittests.h"
-
-#include "fs/virtfs/direntry.h"
-#include "fs/virtfs/fs.h"
-
-#include "utils/checkutils.h"
-
-#ifndef UNITTESTS_CATCH
-#include <algorithm>
-#endif // UNITTESTS_CATCH
-
-#include "debug.h"
-
-TEST_CASE("VirtFs1 mountDir2", "")
-{
- VirtFs::init(".");
- const std::string sep = dirSeparator;
- SECTION("subDir 1")
- {
- REQUIRE(VirtFs::mountDirSilentTest2("dir1",
- dirSeparator,
- Append_false));
- REQUIRE(VirtFs::searchByRootInternal("dir1" + sep, std::string()) !=
- nullptr);
- REQUIRE(VirtFs::searchByRootInternal("test" + sep, std::string()) ==
- nullptr);
- REQUIRE(VirtFs::getEntries().size() == 1);
- REQUIRE(VirtFs::getEntries()[0]->root == "dir1" + sep);
- REQUIRE(VirtFs::getEntries()[0]->subDir.empty());
- REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
- REQUIRE(static_cast<VirtFs::DirEntry*>(
- VirtFs::getEntries()[0])->userDir == "dir1");
- }
-
- SECTION("subDir 1.2")
- {
- REQUIRE(VirtFs::mountDirSilentTest2("dir1",
- "dir2",
- Append_false));
- REQUIRE(VirtFs::searchByRootInternal("dir1" + sep, "dir2" + sep) !=
- nullptr);
- REQUIRE(VirtFs::searchByRootInternal("dir1" + sep, "dir1" + sep) ==
- nullptr);
- REQUIRE(VirtFs::searchByRootInternal("test" + sep, "dir2" + sep) ==
- nullptr);
- REQUIRE(VirtFs::getEntries().size() == 1);
- REQUIRE(VirtFs::getEntries()[0]->root == "dir1" + sep);
- REQUIRE(VirtFs::getEntries()[0]->subDir == "dir2" + sep);
- REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
- REQUIRE(static_cast<VirtFs::DirEntry*>(
- VirtFs::getEntries()[0])->userDir == "dir1");
- }
-
- SECTION("subDir 2")
- {
- REQUIRE(VirtFs::mountDirSilentTest2("dir1/",
- "dir2",
- Append_true));
- REQUIRE(VirtFs::searchByRootInternal("dir1" + sep, "dir2" + sep) !=
- nullptr);
- REQUIRE(VirtFs::searchByRootInternal("test" + sep, "dir2" + sep) ==
- nullptr);
- REQUIRE(VirtFs::searchByRootInternal("dir1" + sep, "dir1" + sep) ==
- nullptr);
- REQUIRE(VirtFs::getEntries().size() == 1);
- REQUIRE(VirtFs::getEntries()[0]->root == "dir1" + sep);
- REQUIRE(VirtFs::getEntries()[0]->subDir == "dir2" + sep);
- REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
- REQUIRE(static_cast<VirtFs::DirEntry*>(
- VirtFs::getEntries()[0])->userDir == "dir1" + sep);
- }
-
- SECTION("subDir 3")
- {
- REQUIRE(VirtFs::mountDirSilentTest2("dir1",
- "dir3",
- Append_false));
- REQUIRE(VirtFs::mountDirSilentTest2("dir2",
- "dir4",
- Append_false));
- REQUIRE(VirtFs::searchByRootInternal("dir1" + sep, "dir3" + sep) !=
- nullptr);
- REQUIRE(VirtFs::searchByRootInternal("dir1" + sep, "dir1" + sep) ==
- nullptr);
- REQUIRE(VirtFs::searchByRootInternal("dir2" + sep, "dir4" + sep) !=
- nullptr);
- REQUIRE(VirtFs::searchByRootInternal("test" + sep, "dir3" + sep) ==
- nullptr);
- REQUIRE(VirtFs::getEntries().size() == 2);
- REQUIRE(VirtFs::getEntries()[0]->root == "dir2" + sep);
- REQUIRE(VirtFs::getEntries()[1]->root == "dir1" + sep);
- REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
- REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Dir);
- REQUIRE(VirtFs::getEntries()[0]->subDir == "dir4" + sep);
- REQUIRE(VirtFs::getEntries()[1]->subDir == "dir3" + sep);
- REQUIRE(static_cast<VirtFs::DirEntry*>(
- VirtFs::getEntries()[0])->userDir == "dir2");
- REQUIRE(static_cast<VirtFs::DirEntry*>(
- VirtFs::getEntries()[1])->userDir == "dir1");
- }
-
- SECTION("subDir 4")
- {
- REQUIRE(VirtFs::mountDirSilentTest2("dir1\\",
- "dir3",
- Append_true));
- REQUIRE(VirtFs::mountDirSilentTest2("dir2",
- "dir4",
- Append_true));
- REQUIRE(VirtFs::searchByRootInternal("dir1" + sep, "dir3" + sep) !=
- nullptr);
- REQUIRE(VirtFs::searchByRootInternal("dir1" + sep, "dir1" + sep) ==
- nullptr);
- REQUIRE(VirtFs::searchByRootInternal("dir2" + sep, "dir4" + sep) !=
- nullptr);
- REQUIRE(VirtFs::searchByRootInternal("test" + sep, "dir3" + sep) ==
- nullptr);
- REQUIRE(VirtFs::getEntries().size() == 2);
- REQUIRE(VirtFs::getEntries()[0]->root == "dir1" + sep);
- REQUIRE(VirtFs::getEntries()[1]->root == "dir2" + sep);
- REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
- REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Dir);
- REQUIRE(VirtFs::getEntries()[0]->subDir == "dir3" + sep);
- REQUIRE(VirtFs::getEntries()[1]->subDir == "dir4" + sep);
- REQUIRE(static_cast<VirtFs::DirEntry*>(
- VirtFs::getEntries()[0])->userDir == "dir1" + sep);
- REQUIRE(static_cast<VirtFs::DirEntry*>(
- VirtFs::getEntries()[1])->userDir == "dir2");
- }
-
- SECTION("subDir 5")
- {
- REQUIRE(VirtFs::mountDirSilentTest2("dir1",
- "dir3",
- Append_true));
- REQUIRE(VirtFs::mountDirSilentTest2("dir2",
- "dir4",
- Append_true));
- REQUIRE(VirtFs::mountDirSilentTest2("dir3/test",
- "dir5",
- Append_true));
- REQUIRE(VirtFs::searchByRootInternal("dir1" + sep, "dir3" + sep) !=
- nullptr);
- REQUIRE(VirtFs::searchByRootInternal("dir2" + sep, "dir4" + sep) !=
- nullptr);
- REQUIRE(VirtFs::searchByRootInternal(
- "dir3" + sep + "test" + sep, "dir5" + sep) != nullptr);
- REQUIRE(VirtFs::searchByRootInternal("test" + sep, "dir3" + sep) ==
- nullptr);
- REQUIRE(VirtFs::getEntries().size() == 3);
- REQUIRE(VirtFs::getEntries()[0]->root == "dir1" + sep);
- REQUIRE(VirtFs::getEntries()[1]->root == "dir2" + sep);
- REQUIRE(VirtFs::getEntries()[2]->root == "dir3" + sep + "test" + sep);
- REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
- REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Dir);
- REQUIRE(VirtFs::getEntries()[2]->type == FsEntryType::Dir);
- REQUIRE(VirtFs::getEntries()[0]->subDir == "dir3" + sep);
- REQUIRE(VirtFs::getEntries()[1]->subDir == "dir4" + sep);
- REQUIRE(VirtFs::getEntries()[2]->subDir == "dir5" + sep);
- REQUIRE(static_cast<VirtFs::DirEntry*>(
- VirtFs::getEntries()[0])->userDir == "dir1");
- REQUIRE(static_cast<VirtFs::DirEntry*>(
- VirtFs::getEntries()[1])->userDir == "dir2");
- REQUIRE(static_cast<VirtFs::DirEntry*>(
- VirtFs::getEntries()[2])->userDir == "dir3" + sep + "test");
- }
-
- SECTION("subDir 6")
- {
- REQUIRE(VirtFs::mountDirSilentTest2("dir1",
- "dir1",
- Append_true));
- REQUIRE(VirtFs::mountDirSilentTest2("dir2",
- "dir2",
- Append_true));
- REQUIRE(VirtFs::mountDirSilentTest2("dir3\\test",
- "dir3\\test",
- Append_false));
- REQUIRE(VirtFs::searchByRootInternal(
- "dir1" + sep + "", "dir1" + sep) != nullptr);
- REQUIRE(VirtFs::searchByRootInternal(
- "dir2" + sep + "", "dir2" + sep) != nullptr);
- REQUIRE(VirtFs::searchByRootInternal(
- "dir3" + sep + "test" + sep,
- "dir3" + sep + "test" + sep) != nullptr);
- REQUIRE(VirtFs::searchByRootInternal(
- "test" + sep + "", "dir1" + sep) == nullptr);
- REQUIRE(VirtFs::getEntries().size() == 3);
- REQUIRE(VirtFs::getEntries()[0]->root == "dir3" + sep + "test" + sep);
- REQUIRE(VirtFs::getEntries()[1]->root == "dir1" + sep);
- REQUIRE(VirtFs::getEntries()[2]->root == "dir2" + sep);
- REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
- REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Dir);
- REQUIRE(VirtFs::getEntries()[2]->type == FsEntryType::Dir);
- REQUIRE(VirtFs::getEntries()[0]->subDir ==
- "dir3" + sep + "test" + sep);
- REQUIRE(VirtFs::getEntries()[1]->subDir == "dir1" + sep);
- REQUIRE(VirtFs::getEntries()[2]->subDir == "dir2" + sep);
- REQUIRE(static_cast<VirtFs::DirEntry*>(
- VirtFs::getEntries()[0])->userDir == "dir3" + sep + "test");
- REQUIRE(static_cast<VirtFs::DirEntry*>(
- VirtFs::getEntries()[1])->userDir == "dir1");
- REQUIRE(static_cast<VirtFs::DirEntry*>(
- VirtFs::getEntries()[2])->userDir == "dir2");
- }
-
- SECTION("subDir 7")
- {
- REQUIRE(VirtFs::mountDirSilentTest("dir1",
- Append_true));
- REQUIRE(VirtFs::mountDirSilentTest2("dir1",
- "dir2",
- Append_true));
- REQUIRE(VirtFs::searchByRootInternal("dir1" + sep, std::string()) !=
- nullptr);
- REQUIRE(VirtFs::searchByRootInternal("dir1" + sep, "dir2" + sep) !=
- nullptr);
- REQUIRE(VirtFs::searchByRootInternal("test" + sep, "dir2" + sep) ==
- nullptr);
- REQUIRE(VirtFs::getEntries().size() == 2);
- REQUIRE(VirtFs::getEntries()[0]->root == "dir1" + sep);
- REQUIRE(VirtFs::getEntries()[0]->subDir.empty());
- REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
- REQUIRE(VirtFs::getEntries()[1]->root == "dir1" + sep);
- REQUIRE(VirtFs::getEntries()[1]->subDir == "dir2" + sep);
- REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Dir);
- REQUIRE(static_cast<VirtFs::DirEntry*>(
- VirtFs::getEntries()[0])->userDir == "dir1");
- REQUIRE(static_cast<VirtFs::DirEntry*>(
- VirtFs::getEntries()[1])->userDir == "dir1");
-
- REQUIRE(VirtFs::unmountDirSilent("dir1"));
- REQUIRE(VirtFs::getEntries().size() == 1);
- REQUIRE(VirtFs::getEntries()[0]->root == "dir1" + sep);
- REQUIRE(VirtFs::getEntries()[0]->subDir == "dir2" + sep);
- REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
- REQUIRE(static_cast<VirtFs::DirEntry*>(
- VirtFs::getEntries()[0])->userDir == "dir1");
- }
-
- SECTION("subDir 8")
- {
- REQUIRE(VirtFs::mountDirSilentTest("dir1",
- Append_true));
- REQUIRE(VirtFs::mountDirSilentTest2("dir1",
- "dir2",
- Append_true));
- REQUIRE(VirtFs::searchByRootInternal("dir1" + sep, std::string()) !=
- nullptr);
- REQUIRE(VirtFs::searchByRootInternal("dir1" + sep, "dir2" + sep) !=
- nullptr);
- REQUIRE(VirtFs::searchByRootInternal("test" + sep, "dir2" + sep) ==
- nullptr);
- REQUIRE(VirtFs::getEntries().size() == 2);
- REQUIRE(VirtFs::getEntries()[0]->root == "dir1" + sep);
- REQUIRE(VirtFs::getEntries()[0]->subDir.empty());
- REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
- REQUIRE(VirtFs::getEntries()[1]->root == "dir1" + sep);
- REQUIRE(VirtFs::getEntries()[1]->subDir == "dir2" + sep);
- REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Dir);
- REQUIRE(static_cast<VirtFs::DirEntry*>(
- VirtFs::getEntries()[0])->userDir == "dir1");
- REQUIRE(static_cast<VirtFs::DirEntry*>(
- VirtFs::getEntries()[1])->userDir == "dir1");
-
- REQUIRE(VirtFs::unmountDirSilent2("dir1", "dir2"));
- REQUIRE(VirtFs::getEntries().size() == 1);
- REQUIRE(VirtFs::getEntries()[0]->root == "dir1" + sep);
- REQUIRE(VirtFs::getEntries()[0]->subDir.empty());
- REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
- REQUIRE(static_cast<VirtFs::DirEntry*>(
- VirtFs::getEntries()[0])->userDir == "dir1");
- }
-
- SECTION("subDir 9")
- {
- REQUIRE(VirtFs::mountDirSilentTest2("dir1",
- dirSeparator,
- Append_false));
- REQUIRE(VirtFs::searchByRootInternal("dir1" + sep, std::string()) !=
- nullptr);
- REQUIRE(VirtFs::searchByRootInternal("dir1" + sep, "dir1") ==
- nullptr);
- REQUIRE(VirtFs::searchByRootInternal("test" + sep, std::string()) ==
- nullptr);
- REQUIRE(VirtFs::getEntries().size() == 1);
- REQUIRE(VirtFs::getEntries()[0]->root == "dir1" + sep);
- REQUIRE(VirtFs::getEntries()[0]->subDir.empty());
- REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
- REQUIRE(static_cast<VirtFs::DirEntry*>(
- VirtFs::getEntries()[0])->userDir == "dir1");
- }
-
- VirtFs::deinit();
-}
diff --git a/src/unittests/fs/virtfs/virtfs1_mountzip1.cc b/src/unittests/fs/virtfs/virtfs1_mountzip1.cc
deleted file mode 100644
index 09932f0a6..000000000
--- a/src/unittests/fs/virtfs/virtfs1_mountzip1.cc
+++ /dev/null
@@ -1,173 +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 "unittests/unittests.h"
-
-#include "fs/files.h"
-
-#include "fs/virtfs/direntry.h"
-#include "fs/virtfs/fs.h"
-
-#include "utils/checkutils.h"
-
-#ifndef UNITTESTS_CATCH
-#include <algorithm>
-#endif // UNITTESTS_CATCH
-
-#include "debug.h"
-
-TEST_CASE("VirtFs1 mountZip1", "")
-{
- VirtFs::init(".");
- std::string name("data/test/test.zip");
- std::string prefix;
- const std::string sep = dirSeparator;
- if (Files::existsLocal(name) == false)
- prefix = "../";
-
- SECTION("simple 1")
- {
- REQUIRE(VirtFs::mountZip(prefix + "data/test/test.zip",
- Append_false));
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test.zip", std::string()) !=
- nullptr);
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test2.zip",
- std::string()) == nullptr);
- REQUIRE(VirtFs::getEntries().size() == 1);
- REQUIRE(VirtFs::getEntries()[0]->root ==
- prefix + "data" + sep + "test" + sep + "test.zip");
- REQUIRE(VirtFs::getEntries()[0]->subDir.empty());
- REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip);
- }
-
- SECTION("simple 2")
- {
- REQUIRE(VirtFs::mountZip(prefix + "data/test/test.zip",
- Append_false));
- REQUIRE(VirtFs::mountZip(prefix + "data/test/test2.zip",
- Append_false));
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test.zip",
- std::string()) != nullptr);
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test2.zip",
- std::string()) != nullptr);
- REQUIRE(VirtFs::getEntries().size() == 2);
- REQUIRE(VirtFs::getEntries()[0]->root ==
- prefix + "data" + sep + "test" + sep + "test2.zip");
- REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip);
- REQUIRE(VirtFs::getEntries()[0]->subDir.empty());
- REQUIRE(VirtFs::getEntries()[1]->root ==
- prefix + "data" + sep + "test" + sep + "test.zip");
- REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Zip);
- REQUIRE(VirtFs::getEntries()[1]->subDir.empty());
- }
-
- SECTION("simple 3")
- {
- REQUIRE(VirtFs::mountZip(prefix + "data/test/test.zip",
- Append_true));
- REQUIRE(VirtFs::mountZip(prefix + "data/test/test2.zip",
- Append_true));
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test.zip",
- std::string()) != nullptr);
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test2.zip",
- std::string()) != nullptr);
- REQUIRE(VirtFs::getEntries().size() == 2);
- REQUIRE(VirtFs::getEntries()[0]->root ==
- prefix + "data" + sep + "test" + sep + "test.zip");
- REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip);
- REQUIRE(VirtFs::getEntries()[0]->subDir.empty());
- REQUIRE(VirtFs::getEntries()[1]->root ==
- prefix + "data" + sep + "test" + sep + "test2.zip");
- REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Zip);
- REQUIRE(VirtFs::getEntries()[1]->subDir.empty());
- }
-
- SECTION("simple 4")
- {
- REQUIRE(VirtFs::mountZip(prefix + "data/test/test.zip",
- Append_false));
- REQUIRE(VirtFs::mountDir(prefix + "data/test",
- Append_false));
- REQUIRE(VirtFs::mountZip(prefix + "data/test/test2.zip",
- Append_false));
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test.zip",
- std::string()) != nullptr);
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test2.zip",
- std::string()) != nullptr);
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "",
- std::string()) != nullptr);
- REQUIRE(VirtFs::getEntries().size() == 3);
- REQUIRE(VirtFs::getEntries()[0]->root ==
- prefix + "data" + sep + "test" + sep + "test2.zip");
- REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip);
- REQUIRE(VirtFs::getEntries()[0]->subDir.empty());
- REQUIRE(VirtFs::getEntries()[1]->root ==
- prefix + "data" + sep + "test" + sep + "");
- REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Dir);
- REQUIRE(VirtFs::getEntries()[1]->subDir.empty());
- REQUIRE(VirtFs::getEntries()[2]->root ==
- prefix + "data" + sep + "test" + sep + "test.zip");
- REQUIRE(VirtFs::getEntries()[2]->type == FsEntryType::Zip);
- REQUIRE(VirtFs::getEntries()[2]->subDir.empty());
- }
-
- SECTION("simple 5")
- {
- REQUIRE(VirtFs::mountZip(prefix + "data/test/test.zip",
- Append_false));
- REQUIRE(VirtFs::mountDir(prefix + "data/test",
- Append_false));
- REQUIRE(VirtFs::mountZip(prefix + "data/test/test2.zip",
- Append_true));
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test.zip",
- std::string()) != nullptr);
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test2.zip",
- std::string()) != nullptr);
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "",
- std::string()) != nullptr);
- REQUIRE(VirtFs::getEntries().size() == 3);
- REQUIRE(VirtFs::getEntries()[0]->root ==
- prefix + "data" + sep + "test" + sep + "");
- REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
- REQUIRE(VirtFs::getEntries()[0]->subDir.empty());
- REQUIRE(VirtFs::getEntries()[1]->root ==
- prefix + "data" + sep + "test" + sep + "test.zip");
- REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Zip);
- REQUIRE(VirtFs::getEntries()[1]->subDir.empty());
- REQUIRE(VirtFs::getEntries()[2]->root ==
- prefix + "data" + sep + "test" + sep + "test2.zip");
- REQUIRE(VirtFs::getEntries()[2]->type == FsEntryType::Zip);
- REQUIRE(VirtFs::getEntries()[2]->subDir.empty());
- }
-
- VirtFs::deinit();
-}
diff --git a/src/unittests/fs/virtfs/virtfs1_mountzip2.cc b/src/unittests/fs/virtfs/virtfs1_mountzip2.cc
deleted file mode 100644
index c9415e007..000000000
--- a/src/unittests/fs/virtfs/virtfs1_mountzip2.cc
+++ /dev/null
@@ -1,202 +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 "unittests/unittests.h"
-
-#include "fs/files.h"
-
-#include "fs/virtfs/direntry.h"
-#include "fs/virtfs/fs.h"
-
-#include "utils/checkutils.h"
-
-#ifndef UNITTESTS_CATCH
-#include <algorithm>
-#endif // UNITTESTS_CATCH
-
-#include "debug.h"
-
-TEST_CASE("VirtFs1 mountZip2", "")
-{
- VirtFs::init(".");
- std::string name("data/test/test.zip");
- std::string prefix;
- const std::string sep = dirSeparator;
- if (Files::existsLocal(name) == false)
- prefix = "../";
-
- SECTION("subDir 1")
- {
- REQUIRE(VirtFs::mountZip2(prefix + "data/test/test.zip",
- "dir1",
- Append_false));
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test.zip", "dir1" + sep) !=
- nullptr);
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test2.zip",
- std::string()) == nullptr);
- REQUIRE(VirtFs::getEntries().size() == 1);
- REQUIRE(VirtFs::getEntries()[0]->root ==
- prefix + "data" + sep + "test" + sep + "test.zip");
- REQUIRE(VirtFs::getEntries()[0]->subDir == "dir1" + sep);
- REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip);
- }
-
- SECTION("subDir 2")
- {
- REQUIRE(VirtFs::mountZip2(prefix + "data/test/test.zip",
- "dir1",
- Append_false));
- REQUIRE(VirtFs::mountZip2(prefix + "data/test/test2.zip",
- "dir2",
- Append_false));
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test.zip", "dir1" + sep) !=
- nullptr);
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test2.zip",
- "dir2" + sep) != nullptr);
- REQUIRE(VirtFs::getEntries().size() == 2);
- REQUIRE(VirtFs::getEntries()[0]->root ==
- prefix + "data" + sep + "test" + sep + "test2.zip");
- REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip);
- REQUIRE(VirtFs::getEntries()[0]->subDir == "dir2" + sep);
- REQUIRE(VirtFs::getEntries()[1]->root ==
- prefix + "data" + sep + "test" + sep + "test.zip");
- REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Zip);
- REQUIRE(VirtFs::getEntries()[1]->subDir == "dir1" + sep);
- }
-
- SECTION("subDir 3")
- {
- REQUIRE(VirtFs::mountZip2(prefix + "data/test/test.zip",
- "dir1",
- Append_true));
- REQUIRE(VirtFs::mountZip2(prefix + "data/test/test2.zip",
- "dir2",
- Append_true));
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test.zip",
- "dir1" + sep) != nullptr);
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test2.zip",
- "dir2" + sep) != nullptr);
- REQUIRE(VirtFs::getEntries().size() == 2);
- REQUIRE(VirtFs::getEntries()[0]->root ==
- prefix + "data" + sep + "test" + sep + "test.zip");
- REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip);
- REQUIRE(VirtFs::getEntries()[0]->subDir == "dir1" + sep);
- REQUIRE(VirtFs::getEntries()[1]->root ==
- prefix + "data" + sep + "test" + sep + "test2.zip");
- REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Zip);
- REQUIRE(VirtFs::getEntries()[1]->subDir == "dir2" + sep);
- }
-
- SECTION("subDir 4")
- {
- REQUIRE(VirtFs::mountZip2(prefix + "data/test/test.zip",
- "dir1",
- Append_false));
- REQUIRE(VirtFs::mountDir2(prefix + "data/test",
- "dir2",
- Append_false));
- REQUIRE(VirtFs::mountZip2(prefix + "data/test/test2.zip",
- "dir3",
- Append_false));
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test.zip",
- "dir1" + sep) != nullptr);
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test2.zip",
- "dir3" + sep) != nullptr);
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "",
- "dir2" + sep) != nullptr);
- REQUIRE(VirtFs::getEntries().size() == 3);
- REQUIRE(VirtFs::getEntries()[0]->root ==
- prefix + "data" + sep + "test" + sep + "test2.zip");
- REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip);
- REQUIRE(VirtFs::getEntries()[0]->subDir == "dir3" + sep);
- REQUIRE(VirtFs::getEntries()[1]->root ==
- prefix + "data" + sep + "test" + sep + "");
- REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Dir);
- REQUIRE(VirtFs::getEntries()[1]->subDir == "dir2" + sep);
- REQUIRE(VirtFs::getEntries()[2]->root ==
- prefix + "data" + sep + "test" + sep + "test.zip");
- REQUIRE(VirtFs::getEntries()[2]->type == FsEntryType::Zip);
- REQUIRE(VirtFs::getEntries()[2]->subDir == "dir1" + sep);
- }
-
- SECTION("subDir 5")
- {
- REQUIRE(VirtFs::mountZip2(prefix + "data/test/test.zip",
- "dir1",
- Append_false));
- REQUIRE(VirtFs::mountDir2(prefix + "data/test",
- "dir2",
- Append_false));
- REQUIRE(VirtFs::mountZip2(prefix + "data/test/test2.zip",
- "dir3",
- Append_true));
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test.zip",
- "dir1" + sep) != nullptr);
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test2.zip",
- "dir3" + sep) != nullptr);
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "",
- "dir2" + sep) != nullptr);
- REQUIRE(VirtFs::getEntries().size() == 3);
- REQUIRE(VirtFs::getEntries()[0]->root ==
- prefix + "data" + sep + "test" + sep + "");
- REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
- REQUIRE(VirtFs::getEntries()[0]->subDir == "dir2" + sep);
- REQUIRE(VirtFs::getEntries()[1]->root ==
- prefix + "data" + sep + "test" + sep + "test.zip");
- REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Zip);
- REQUIRE(VirtFs::getEntries()[1]->subDir == "dir1" + sep);
- REQUIRE(VirtFs::getEntries()[2]->root ==
- prefix + "data" + sep + "test" + sep + "test2.zip");
- REQUIRE(VirtFs::getEntries()[2]->type == FsEntryType::Zip);
- REQUIRE(VirtFs::getEntries()[2]->subDir == "dir3" + sep);
- }
-
- SECTION("subDir 6")
- {
- REQUIRE(VirtFs::mountZip2(prefix + "data/test/test.zip",
- dirSeparator,
- Append_false));
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test.zip",
- std::string()) != nullptr);
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test2.zip",
- std::string()) == nullptr);
- REQUIRE(VirtFs::getEntries().size() == 1);
- REQUIRE(VirtFs::getEntries()[0]->root ==
- prefix + "data" + sep + "test" + sep + "test.zip");
- REQUIRE(VirtFs::getEntries()[0]->subDir.empty());
- REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip);
- }
-
- VirtFs::deinit();
-}
diff --git a/src/unittests/fs/virtfs/virtfs1_unmount.cc b/src/unittests/fs/virtfs/virtfs1_unmount.cc
deleted file mode 100644
index b1c7a1033..000000000
--- a/src/unittests/fs/virtfs/virtfs1_unmount.cc
+++ /dev/null
@@ -1,377 +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 "unittests/unittests.h"
-
-#include "fs/files.h"
-
-#include "fs/virtfs/direntry.h"
-#include "fs/virtfs/fs.h"
-
-#include "utils/checkutils.h"
-
-#ifndef UNITTESTS_CATCH
-#include <algorithm>
-#endif // UNITTESTS_CATCH
-
-#include "debug.h"
-
-TEST_CASE("VirtFs1 unmount", "")
-{
- VirtFs::init(".");
- std::string name("data/test/test.zip");
- std::string prefix;
- const std::string sep = dirSeparator;
- if (Files::existsLocal(name) == false)
- prefix = "../";
-
- SECTION("simple 2")
- {
- REQUIRE(VirtFs::mountDirSilentTest("dir1",
- Append_true));
- REQUIRE(VirtFs::unmountDir("dir1"));
- }
-
- SECTION("simple 3")
- {
- REQUIRE(VirtFs::mountDirSilentTest("dir1",
- Append_true));
- REQUIRE(VirtFs::mountDirSilentTest("dir2//dir3",
- Append_true));
- REQUIRE(VirtFs::mountDirSilentTest("dir3",
- Append_false));
- REQUIRE(VirtFs::getEntries().size() == 3);
- REQUIRE(VirtFs::unmountDir("dir1"));
- REQUIRE(VirtFs::getEntries().size() == 2);
- REQUIRE(VirtFs::getEntries()[0]->root == "dir3" + sep);
- REQUIRE(VirtFs::getEntries()[0]->subDir.empty());
- REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
- REQUIRE(static_cast<VirtFs::DirEntry*>(
- VirtFs::getEntries()[0])->userDir == "dir3");
- REQUIRE(VirtFs::getEntries()[1]->root == "dir2" + sep + "dir3" + sep);
- REQUIRE(VirtFs::getEntries()[0]->subDir.empty());
- REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
- REQUIRE(static_cast<VirtFs::DirEntry*>(
- VirtFs::getEntries()[1])->userDir == "dir2" + sep + "dir3");
- REQUIRE(VirtFs::getEntries().size() == 2);
- REQUIRE(VirtFs::getEntries()[0]->root == "dir3" + sep);
- REQUIRE(VirtFs::getEntries()[0]->subDir.empty());
- REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
- REQUIRE(static_cast<VirtFs::DirEntry*>(
- VirtFs::getEntries()[0])->userDir == "dir3");
- REQUIRE(VirtFs::getEntries()[1]->root == "dir2" + sep + "dir3" + sep);
- REQUIRE(VirtFs::getEntries()[0]->subDir.empty());
- REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
- REQUIRE(static_cast<VirtFs::DirEntry*>(
- VirtFs::getEntries()[1])->userDir == "dir2" + sep + "dir3");
- REQUIRE(VirtFs::unmountDir("dir2/dir3"));
- REQUIRE(VirtFs::getEntries().size() == 1);
- REQUIRE(VirtFs::getEntries()[0]->root == "dir3" + sep);
- REQUIRE(VirtFs::getEntries()[0]->subDir.empty());
- REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
- REQUIRE(static_cast<VirtFs::DirEntry*>(
- VirtFs::getEntries()[0])->userDir == "dir3");
- }
-
- SECTION("simple 4")
- {
- REQUIRE(VirtFs::mountDirSilentTest("dir1",
- Append_true));
- REQUIRE(VirtFs::getEntries().size() == 1);
- REQUIRE(VirtFs::getEntries()[0]->root == "dir1" + sep);
- REQUIRE(VirtFs::getEntries()[0]->subDir.empty());
- REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
- REQUIRE(static_cast<VirtFs::DirEntry*>(
- VirtFs::getEntries()[0])->userDir == "dir1");
- REQUIRE(VirtFs::unmountDir("dir1"));
- REQUIRE(VirtFs::getEntries().empty());
- REQUIRE(VirtFs::mountDirSilentTest("dir1",
- Append_true));
- REQUIRE(VirtFs::getEntries().size() == 1);
- REQUIRE(VirtFs::getEntries()[0]->root == "dir1" + sep);
- REQUIRE(VirtFs::getEntries()[0]->subDir.empty());
- REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
- REQUIRE(static_cast<VirtFs::DirEntry*>(
- VirtFs::getEntries()[0])->userDir == "dir1");
- }
-
- SECTION("simple 5")
- {
- REQUIRE(VirtFs::mountZip(prefix + "data/test/test.zip",
- Append_true));
- REQUIRE(VirtFs::mountZip(prefix + "data/test/test2.zip",
- Append_true));
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test.zip",
- std::string()) != nullptr);
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test2.zip",
- std::string()) != nullptr);
- REQUIRE(VirtFs::getEntries().size() == 2);
- REQUIRE(VirtFs::getEntries()[0]->root ==
- prefix + "data" + sep + "test" + sep + "test.zip");
- REQUIRE(VirtFs::getEntries()[0]->subDir.empty());
- REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip);
- REQUIRE(VirtFs::getEntries()[1]->root ==
- prefix + "data" + sep + "test" + sep + "test2.zip");
- REQUIRE(VirtFs::getEntries()[1]->subDir.empty());
- REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Zip);
-
- VirtFs::unmountZip(prefix + "data/test/test.zip");
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test.zip",
- std::string()) == nullptr);
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test2.zip",
- std::string()) != nullptr);
- REQUIRE(VirtFs::getEntries().size() == 1);
- REQUIRE(VirtFs::getEntries()[0]->root ==
- prefix + "data" + sep + "test" + sep + "test2.zip");
- REQUIRE(VirtFs::getEntries()[0]->subDir.empty());
- REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip);
- }
-
- SECTION("simple 6")
- {
- REQUIRE(VirtFs::mountZip(prefix + "data/test/test.zip",
- Append_false));
- REQUIRE(VirtFs::mountDir(prefix + "data/test",
- Append_false));
- REQUIRE(VirtFs::mountZip(prefix + "data\\test/test2.zip",
- Append_false));
-
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test.zip",
- std::string()) != nullptr);
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test2.zip",
- std::string()) != nullptr);
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "",
- std::string()) != nullptr);
- REQUIRE(VirtFs::getEntries().size() == 3);
- REQUIRE(VirtFs::getEntries()[0]->root ==
- prefix + "data" + sep + "test" + sep + "test2.zip");
- REQUIRE(VirtFs::getEntries()[0]->subDir.empty());
- REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip);
- REQUIRE(VirtFs::getEntries()[1]->root ==
- prefix + "data" + sep + "test" + sep);
- REQUIRE(VirtFs::getEntries()[1]->subDir.empty());
- REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Dir);
- REQUIRE(VirtFs::getEntries()[2]->root ==
- prefix + "data" + sep + "test" + sep + "test.zip");
- REQUIRE(VirtFs::getEntries()[2]->subDir.empty());
- REQUIRE(VirtFs::getEntries()[2]->type == FsEntryType::Zip);
-
- VirtFs::unmountZip(prefix + "data/test/test.zip");
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test.zip",
- std::string()) == nullptr);
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test2.zip",
- std::string()) != nullptr);
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "",
- std::string()) != nullptr);
- REQUIRE(VirtFs::getEntries().size() == 2);
- REQUIRE(VirtFs::getEntries()[0]->root ==
- prefix + "data" + sep + "test" + sep + "test2.zip");
- REQUIRE(VirtFs::getEntries()[0]->subDir.empty());
- REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip);
- REQUIRE(VirtFs::getEntries()[1]->root ==
- prefix + "data" + sep + "test" + sep);
- REQUIRE(VirtFs::getEntries()[1]->subDir.empty());
- REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Dir);
- }
-
- SECTION("subDir 2")
- {
- REQUIRE(VirtFs::mountDirSilentTest2("dir1",
- "dir2",
- Append_true));
- REQUIRE(VirtFs::unmountDir2("dir1", "dir2"));
- }
-
- SECTION("subDir 3")
- {
- REQUIRE(VirtFs::mountDirSilentTest2("dir1",
- "dir2",
- Append_true));
- REQUIRE(VirtFs::mountDirSilentTest("dir2//dir3",
- Append_true));
- REQUIRE(VirtFs::mountDirSilentTest2("dir3",
- "dir4",
- Append_false));
- REQUIRE(VirtFs::getEntries().size() == 3);
- REQUIRE(VirtFs::unmountDir2("dir1", "dir2"));
- REQUIRE(VirtFs::getEntries().size() == 2);
- REQUIRE(VirtFs::getEntries()[0]->root == "dir3" + sep);
- REQUIRE(VirtFs::getEntries()[0]->subDir == "dir4" + sep);
- REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
- REQUIRE(static_cast<VirtFs::DirEntry*>(
- VirtFs::getEntries()[0])->userDir == "dir3");
- REQUIRE(VirtFs::getEntries()[1]->root == "dir2" + sep + "dir3" + sep);
- REQUIRE(VirtFs::getEntries()[1]->subDir.empty());
- REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Dir);
- REQUIRE(static_cast<VirtFs::DirEntry*>(
- VirtFs::getEntries()[1])->userDir == "dir2" + sep + "dir3");
- REQUIRE(VirtFs::getEntries().size() == 2);
- REQUIRE(VirtFs::getEntries()[0]->root == "dir3" + sep);
- REQUIRE(VirtFs::getEntries()[0]->subDir == "dir4" + sep);
- REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
- REQUIRE(static_cast<VirtFs::DirEntry*>(
- VirtFs::getEntries()[0])->userDir == "dir3");
- REQUIRE(VirtFs::getEntries()[1]->root == "dir2" + sep + "dir3" + sep);
- REQUIRE(VirtFs::getEntries()[1]->subDir.empty());
- REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Dir);
- REQUIRE(static_cast<VirtFs::DirEntry*>(
- VirtFs::getEntries()[1])->userDir == "dir2" + sep + "dir3");
- REQUIRE(VirtFs::unmountDir("dir2/dir3"));
- REQUIRE(VirtFs::getEntries().size() == 1);
- REQUIRE(VirtFs::getEntries()[0]->root == "dir3" + sep);
- REQUIRE(VirtFs::getEntries()[0]->subDir == "dir4" + sep);
- REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
- REQUIRE(static_cast<VirtFs::DirEntry*>(
- VirtFs::getEntries()[0])->userDir == "dir3");
- }
-
- SECTION("subDir 4")
- {
- REQUIRE(VirtFs::mountDirSilentTest2("dir1",
- "dir2",
- Append_true));
- REQUIRE(VirtFs::getEntries().size() == 1);
- REQUIRE(VirtFs::getEntries()[0]->root == "dir1" + sep);
- REQUIRE(VirtFs::getEntries()[0]->subDir == "dir2" + sep);
- REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
- REQUIRE(static_cast<VirtFs::DirEntry*>(
- VirtFs::getEntries()[0])->userDir == "dir1");
- REQUIRE(VirtFs::unmountDir2("dir1", "dir2"));
- REQUIRE(VirtFs::getEntries().empty());
- REQUIRE(VirtFs::mountDirSilentTest2("dir1",
- "dir3",
- Append_true));
- REQUIRE(VirtFs::getEntries().size() == 1);
- REQUIRE(VirtFs::getEntries()[0]->root == "dir1" + sep);
- REQUIRE(VirtFs::getEntries()[0]->subDir == "dir3" + sep);
- REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
- REQUIRE(static_cast<VirtFs::DirEntry*>(
- VirtFs::getEntries()[0])->userDir == "dir1");
- }
-
- SECTION("subDir 5")
- {
- REQUIRE(VirtFs::mountZip2(prefix + "data/test/test.zip",
- "dir1",
- Append_true));
- REQUIRE(VirtFs::mountZip2(prefix + "data/test/test2.zip",
- "dir2",
- Append_true));
-
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test.zip",
- "dir1" + sep) != nullptr);
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test2.zip",
- "dir2" + sep) != nullptr);
- REQUIRE(VirtFs::getEntries().size() == 2);
- REQUIRE(VirtFs::getEntries()[0]->root ==
- prefix + "data" + sep + "test" + sep + "test.zip");
- REQUIRE(VirtFs::getEntries()[0]->subDir == "dir1" + sep);
- REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip);
- REQUIRE(VirtFs::getEntries()[1]->root ==
- prefix + "data" + sep + "test" + sep + "test2.zip");
- REQUIRE(VirtFs::getEntries()[1]->subDir == "dir2" + sep);
- REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Zip);
-
- VirtFs::unmountZip2(prefix + "data/test/test.zip",
- "dir1");
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test.zip",
- std::string()) == nullptr);
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test2.zip",
- "dir2" + sep) != nullptr);
- REQUIRE(VirtFs::getEntries().size() == 1);
- REQUIRE(VirtFs::getEntries()[0]->root ==
- prefix + "data" + sep + "test" + sep + "test2.zip");
- REQUIRE(VirtFs::getEntries()[0]->subDir == "dir2" + sep);
- REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip);
- }
-
- SECTION("subDir 6")
- {
- REQUIRE(VirtFs::mountZip2(prefix + "data/test/test.zip",
- "dir1",
- Append_false));
- REQUIRE(VirtFs::mountDir2(prefix + "data/test",
- "dir2",
- Append_false));
- REQUIRE(VirtFs::mountZip2(prefix + "data\\test/test2.zip",
- "dir3",
- Append_false));
-
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test.zip",
- "dir1" + sep) != nullptr);
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test2.zip",
- "dir3" + sep) != nullptr);
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "",
- "dir2" + sep) != nullptr);
- REQUIRE(VirtFs::getEntries().size() == 3);
- REQUIRE(VirtFs::getEntries()[0]->root ==
- prefix + "data" + sep + "test" + sep + "test2.zip");
- REQUIRE(VirtFs::getEntries()[0]->subDir == "dir3" + sep);
- REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip);
- REQUIRE(VirtFs::getEntries()[1]->root ==
- prefix + "data" + sep + "test" + sep);
- REQUIRE(VirtFs::getEntries()[1]->subDir == "dir2" + sep);
- REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Dir);
- REQUIRE(VirtFs::getEntries()[2]->root ==
- prefix + "data" + sep + "test" + sep + "test.zip");
- REQUIRE(VirtFs::getEntries()[2]->subDir == "dir1" + sep);
- REQUIRE(VirtFs::getEntries()[2]->type == FsEntryType::Zip);
-
- VirtFs::unmountZip2(prefix + "data/test/test.zip",
- "dir1");
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test.zip",
- "dir1" + sep) == nullptr);
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test2.zip",
- "dir3" + sep) != nullptr);
- REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "",
- "dir2" + sep) != nullptr);
- REQUIRE(VirtFs::getEntries().size() == 2);
- REQUIRE(VirtFs::getEntries()[0]->root ==
- prefix + "data" + sep + "test" + sep + "test2.zip");
- REQUIRE(VirtFs::getEntries()[0]->subDir == "dir3" + sep);
- REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip);
- REQUIRE(VirtFs::getEntries()[1]->root ==
- prefix + "data" + sep + "test" + sep);
- REQUIRE(VirtFs::getEntries()[1]->subDir == "dir2" + sep);
- REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Dir);
- }
-
- VirtFs::deinit();
-}
diff --git a/src/unittests/fs/virtfs/virtfs2.cc b/src/unittests/fs/virtfs/virtfs2.cc
deleted file mode 100644
index a1a1050aa..000000000
--- a/src/unittests/fs/virtfs/virtfs2.cc
+++ /dev/null
@@ -1,1643 +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 "unittests/unittests.h"
-
-#include "fs/files.h"
-
-#include "fs/virtfs/fs.h"
-#include "fs/virtfs/rwops.h"
-
-#include "utils/checkutils.h"
-#include "utils/foreach.h"
-#include "utils/stringutils.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_rwops.h>
-PRAGMA48(GCC diagnostic pop)
-
-#ifndef UNITTESTS_CATCH
-#include <algorithm>
-#endif // UNITTESTS_CATCH
-
-#include "debug.h"
-
-static bool inList(StringVect list,
- const std::string &name)
-{
- FOR_EACH (StringVectCIter, it, list)
- {
- if (*it == name)
- return true;
- }
- return false;
-}
-
-static bool inList(StringVect list,
- const std::string &dir,
- const std::string &name)
-{
- const std::string path = pathJoin(dir, name);
- FOR_EACH (StringVectCIter, it, list)
- {
- if (*it == path)
- return true;
- }
- return false;
-}
-
-static void removeTemp(StringVect &restrict list)
-{
- int cnt = 0;
- std::sort(list.begin(), list.end());
-
- FOR_EACH (StringVectIter, it, list)
- {
- if (*it != "serverlistplus.xml.part")
- {
- logger->log("file: %d %s",
- cnt,
- (*it).c_str());
- cnt ++;
- }
- }
-
- FOR_EACH (StringVectIter, it, list)
- {
- if (*it == "serverlistplus.xml.part")
- {
- list.erase(it);
- return;
- }
- }
-}
-
-TEST_CASE("VirtFs2 isDirectory1", "")
-{
- VirtFs::init(".");
- std::string name("data/test/test.zip");
- std::string prefix;
- if (Files::existsLocal(name) == false)
- prefix = "../" + prefix;
-
- VirtFs::mountDir(prefix + "data",
- Append_false);
-
- REQUIRE(VirtFs::isDirectory("test/units.xml") == false);
- REQUIRE(VirtFs::isDirectory("test/units.xml/") == false);
- REQUIRE(VirtFs::isDirectory("test//units.xml") == false);
- REQUIRE(VirtFs::isDirectory("test/units123.xml") == false);
- REQUIRE(VirtFs::isDirectory("test//units123.xml") == false);
- REQUIRE(VirtFs::isDirectory("tesQ/units.xml") == false);
- REQUIRE(VirtFs::isDirectory("tesQ//units.xml") == false);
- REQUIRE(VirtFs::isDirectory("units.xml") == false);
- REQUIRE(VirtFs::isDirectory("test") == true);
- REQUIRE(VirtFs::isDirectory("test/") == true);
- REQUIRE(VirtFs::isDirectory("test//") == true);
- REQUIRE(VirtFs::isDirectory("test/dir1") == true);
- REQUIRE(VirtFs::isDirectory("test//dir1") == true);
- REQUIRE(VirtFs::isDirectory("test//dir1/") == true);
- REQUIRE(VirtFs::isDirectory("test//dir1//") == true);
- REQUIRE(VirtFs::isDirectory("test\\dir1/") == true);
- REQUIRE(VirtFs::isDirectory("test/dir1//") == true);
- REQUIRE(VirtFs::isDirectory("testQ") == false);
- REQUIRE(VirtFs::isDirectory("testQ/") == false);
- REQUIRE(VirtFs::isDirectory("testQ//") == false);
-
- VirtFs::mountDir(prefix + "data/test",
- Append_false);
-
- REQUIRE(VirtFs::isDirectory("test/units.xml") == false);
- REQUIRE(VirtFs::isDirectory("test/units.xml/") == false);
- REQUIRE(VirtFs::isDirectory("test//units.xml") == false);
- REQUIRE(VirtFs::isDirectory("test/units123.xml") == false);
- REQUIRE(VirtFs::isDirectory("tesQ/units.xml") == false);
- REQUIRE(VirtFs::isDirectory("units.xml") == false);
- REQUIRE(VirtFs::isDirectory("test") == true);
- REQUIRE(VirtFs::isDirectory("testQ") == false);
- REQUIRE(VirtFs::isDirectory("test/dir1") == true);
- REQUIRE(VirtFs::isDirectory("test\\dir1") == true);
-
- VirtFs::unmountDir(prefix + "data/test");
-
- REQUIRE(VirtFs::isDirectory("test/units.xml") == false);
- REQUIRE(VirtFs::isDirectory("test/units123.xml") == false);
- REQUIRE(VirtFs::isDirectory("tesQ/units.xml") == false);
- REQUIRE(VirtFs::isDirectory("units.xml") == false);
- REQUIRE(VirtFs::isDirectory("units.xml/") == false);
- REQUIRE(VirtFs::isDirectory("test") == true);
- REQUIRE(VirtFs::isDirectory("test/") == true);
- REQUIRE(VirtFs::isDirectory("testQ") == false);
- REQUIRE(VirtFs::isDirectory("test/dir1") == true);
-
- VirtFs::unmountDirSilent(prefix + "data");
- VirtFs::deinit();
-}
-
-TEST_CASE("VirtFs2 isDirectory2", "")
-{
- VirtFs::init(".");
- std::string name("data/test/test.zip");
- std::string prefix;
- if (Files::existsLocal(name) == false)
- prefix = "../" + prefix;
-
- VirtFs::mountZip(prefix + "data/test/test2.zip",
- Append_false);
-
- REQUIRE(VirtFs::isDirectory("dir2/units.xml") == false);
- REQUIRE(VirtFs::isDirectory("dir2/units.xml/") == false);
- REQUIRE(VirtFs::isDirectory("dir2//units.xml") == false);
- REQUIRE(VirtFs::isDirectory("dir2/units123.xml") == false);
- REQUIRE(VirtFs::isDirectory("dir2//units123.xml") == false);
- REQUIRE(VirtFs::isDirectory("tesQ/units.xml") == false);
- REQUIRE(VirtFs::isDirectory("tesQ//units.xml") == false);
- REQUIRE(VirtFs::isDirectory("units.xml") == false);
- REQUIRE(VirtFs::isDirectory("dir") == true);
- REQUIRE(VirtFs::isDirectory("dir2/") == true);
- REQUIRE(VirtFs::isDirectory("dir2//") == true);
- REQUIRE(VirtFs::isDirectory("dir/1") == true);
- REQUIRE(VirtFs::isDirectory("dir//1") == true);
- REQUIRE(VirtFs::isDirectory("dir\\1/") == true);
- REQUIRE(VirtFs::isDirectory("dir/1") == true);
- REQUIRE(VirtFs::isDirectory("dir/1/zzz") == false);
- REQUIRE(VirtFs::isDirectory("test/dir1\\") == false);
- REQUIRE(VirtFs::isDirectory("testQ") == false);
- REQUIRE(VirtFs::isDirectory("testQ/") == false);
- REQUIRE(VirtFs::isDirectory("testQ//") == false);
-
- VirtFs::mountZip(prefix + "data/test/test.zip",
- Append_false);
-
- REQUIRE(VirtFs::isDirectory("dir2/units.xml") == false);
- REQUIRE(VirtFs::isDirectory("dir2/units.xml/") == false);
- REQUIRE(VirtFs::isDirectory("dir2\\units.xml") == false);
- REQUIRE(VirtFs::isDirectory("dir2/units123.xml") == false);
- REQUIRE(VirtFs::isDirectory("dir2//units123.xml") == false);
- REQUIRE(VirtFs::isDirectory("tesQ/units.xml") == false);
- REQUIRE(VirtFs::isDirectory("tesQ//units.xml") == false);
- REQUIRE(VirtFs::isDirectory("units.xml") == false);
- REQUIRE(VirtFs::isDirectory("dir") == true);
- REQUIRE(VirtFs::isDirectory("dir2/") == true);
- REQUIRE(VirtFs::isDirectory("dir2\\") == true);
- REQUIRE(VirtFs::isDirectory("dir/1") == true);
- REQUIRE(VirtFs::isDirectory("dir//1") == true);
- REQUIRE(VirtFs::isDirectory("dir//1/") == true);
- REQUIRE(VirtFs::isDirectory("dir/1") == true);
- REQUIRE(VirtFs::isDirectory("dir/1/zzz") == false);
- REQUIRE(VirtFs::isDirectory("test/dir1//") == false);
- REQUIRE(VirtFs::isDirectory("testQ") == false);
- REQUIRE(VirtFs::isDirectory("testQ/") == false);
- REQUIRE(VirtFs::isDirectory("testQ//") == false);
-
- VirtFs::unmountZip(prefix + "data/test/test2.zip");
-
- REQUIRE(VirtFs::isDirectory("dir2/units.xml") == false);
- REQUIRE(VirtFs::isDirectory("dir2/units.xml/") == false);
- REQUIRE(VirtFs::isDirectory("dir2//units.xml") == false);
- REQUIRE(VirtFs::isDirectory("dir2/units123.xml") == false);
- REQUIRE(VirtFs::isDirectory("dir2//units123.xml") == false);
- REQUIRE(VirtFs::isDirectory("tesQ/units.xml") == false);
- REQUIRE(VirtFs::isDirectory("tesQ//units.xml") == false);
- REQUIRE(VirtFs::isDirectory("units.xml") == false);
- REQUIRE(VirtFs::isDirectory("dir") == true);
- REQUIRE(VirtFs::isDirectory("dir2/") == false);
- REQUIRE(VirtFs::isDirectory("dir2//") == false);
- REQUIRE(VirtFs::isDirectory("dir/1") == false);
- REQUIRE(VirtFs::isDirectory("dir\\1") == false);
- REQUIRE(VirtFs::isDirectory("dir//1/") == false);
- REQUIRE(VirtFs::isDirectory("dir/1") == false);
- REQUIRE(VirtFs::isDirectory("dir/1/zzz") == false);
- REQUIRE(VirtFs::isDirectory("test/dir1//") == false);
- REQUIRE(VirtFs::isDirectory("testQ") == false);
- REQUIRE(VirtFs::isDirectory("testQ/") == false);
- REQUIRE(VirtFs::isDirectory("testQ//") == false);
-
- VirtFs::unmountZip(prefix + "data/test/test.zip");
- VirtFs::deinit();
-}
-
-TEST_CASE("VirtFs2 isDirectory3", "")
-{
- VirtFs::init(".");
- std::string name("data/test/test.zip");
- std::string prefix;
- if (Files::existsLocal(name) == false)
- prefix = "../" + prefix;
-
- VirtFs::mountDir2(prefix + "data",
- "test",
- Append_false);
-
- REQUIRE(VirtFs::isDirectory("units.xml") == false);
- REQUIRE(VirtFs::isDirectory("units.xml/") == false);
- REQUIRE(VirtFs::isDirectory("units123.xml") == false);
- REQUIRE(VirtFs::isDirectory("tesQ/units.xml") == false);
- REQUIRE(VirtFs::isDirectory("tesQ//units.xml") == false);
- REQUIRE(VirtFs::isDirectory("test") == false);
- REQUIRE(VirtFs::isDirectory("dir1") == true);
- REQUIRE(VirtFs::isDirectory("dir2//") == true);
- REQUIRE(VirtFs::isDirectory("test/dir1") == false);
- REQUIRE(VirtFs::isDirectory("testQ") == false);
- REQUIRE(VirtFs::isDirectory("testQ/") == false);
- REQUIRE(VirtFs::isDirectory("testQ//") == false);
-
- VirtFs::unmountDirSilent2(prefix + "data",
- "test");
- VirtFs::deinit();
-}
-
-TEST_CASE("VirtFs2 isDirectory4", "")
-{
- VirtFs::init(".");
- std::string name("data/test/test.zip");
- std::string prefix;
- if (Files::existsLocal(name) == false)
- prefix = "../" + prefix;
-
- VirtFs::mountZip2(prefix + "data/test/test2.zip",
- "dir",
- Append_false);
-
- REQUIRE(VirtFs::isDirectory("dir2/units.xml") == false);
- REQUIRE(VirtFs::isDirectory("dir2/units.xml/") == false);
- REQUIRE(VirtFs::isDirectory("dir2//units.xml") == false);
- REQUIRE(VirtFs::isDirectory("dir2/units123.xml") == false);
- REQUIRE(VirtFs::isDirectory("dir2//units123.xml") == false);
- REQUIRE(VirtFs::isDirectory("tesQ/units.xml") == false);
- REQUIRE(VirtFs::isDirectory("tesQ//units.xml") == false);
- REQUIRE(VirtFs::isDirectory("units.xml") == false);
- REQUIRE(VirtFs::isDirectory("1") == true);
- REQUIRE(VirtFs::isDirectory("gpl") == true);
- REQUIRE(VirtFs::isDirectory("dir2/") == false);
- REQUIRE(VirtFs::isDirectory("dir/1") == false);
- REQUIRE(VirtFs::isDirectory("dir/1/zzz") == false);
- REQUIRE(VirtFs::isDirectory("test/dir1\\") == false);
- REQUIRE(VirtFs::isDirectory("testQ") == false);
- REQUIRE(VirtFs::isDirectory("testQ/") == false);
- REQUIRE(VirtFs::isDirectory("testQ//") == false);
-
- VirtFs::unmountZip2(prefix + "data/test/test2.zip",
- "dir");
- VirtFs::deinit();
-}
-
-TEST_CASE("VirtFs2 openRead1", "")
-{
- VirtFs::init(".");
- std::string name("data/test/test.zip");
- std::string prefix;
- if (Files::existsLocal(name) == false)
- prefix = "../" + prefix;
-
- VirtFs::mountDir(prefix + "data",
- Append_false);
-
- VirtFs::File *file = nullptr;
-
- file = VirtFs::openRead("test/units.xml");
- REQUIRE(file != nullptr);
- VirtFs::close(file);
- file = VirtFs::openRead("test\\units.xml");
- REQUIRE(file != nullptr);
- VirtFs::close(file);
- file = VirtFs::openRead("test/units123.xml");
- REQUIRE(file == nullptr);
- file = VirtFs::openRead("tesQ/units.xml");
- REQUIRE(file == nullptr);
- file = VirtFs::openRead("units.xml");
- REQUIRE(file == nullptr);
- file = VirtFs::openRead("testQ");
- REQUIRE(file == nullptr);
-
- VirtFs::mountDir(prefix + "data/test",
- Append_false);
-
- file = VirtFs::openRead("test/units.xml");
- REQUIRE(file != nullptr);
- VirtFs::close(file);
- file = VirtFs::openRead("test/units123.xml");
- REQUIRE(file == nullptr);
- file = VirtFs::openRead("tesQ/units.xml");
- REQUIRE(file == nullptr);
- file = VirtFs::openRead("units.xml");
- REQUIRE(file != nullptr);
- VirtFs::close(file);
- file = VirtFs::openRead("testQ");
- REQUIRE(file == nullptr);
-
- VirtFs::unmountDir(prefix + "data/test");
-
- file = VirtFs::openRead("test/units.xml");
- REQUIRE(file != nullptr);
- VirtFs::close(file);
- file = VirtFs::openRead("test/units123.xml");
- REQUIRE(file == nullptr);
- file = VirtFs::openRead("tesQ/units.xml");
- REQUIRE(file == nullptr);
- file = VirtFs::openRead("units.xml");
- REQUIRE(file == nullptr);
- file = VirtFs::openRead("testQ");
- REQUIRE(file == nullptr);
-
- VirtFs::unmountDir(prefix + "data");
- VirtFs::deinit();
-}
-
-TEST_CASE("VirtFs2 openRead2", "")
-{
- VirtFs::init(".");
- std::string name("data/test/test.zip");
- std::string prefix("data/test/");
- if (Files::existsLocal(name) == false)
- prefix = "../" + prefix;
-
- VirtFs::mountZip(prefix + "test2.zip",
- Append_false);
-
- VirtFs::File *file = nullptr;
-
- file = VirtFs::openRead("dir2/units.xml");
- REQUIRE(file != nullptr);
- VirtFs::close(file);
- file = VirtFs::openRead("dir2\\units.xml");
- REQUIRE(file != nullptr);
- VirtFs::close(file);
- file = VirtFs::openRead("dir2/units123.xml");
- REQUIRE(file == nullptr);
- file = VirtFs::openRead("tesQ/units.xml");
- REQUIRE(file == nullptr);
- file = VirtFs::openRead("units.xml1");
- REQUIRE(file == nullptr);
- file = VirtFs::openRead("testQ");
- REQUIRE(file == nullptr);
- file = VirtFs::openRead("dir/brimmedhat.png");
- REQUIRE(file == nullptr);
- file = VirtFs::openRead("dir//brimmedhat.png");
- REQUIRE(file == nullptr);
-
- VirtFs::mountZip(prefix + "test.zip",
- Append_false);
-
- file = VirtFs::openRead("dir2/units.xml");
- REQUIRE(file != nullptr);
- VirtFs::close(file);
- file = VirtFs::openRead("dir2//units.xml");
- REQUIRE(file != nullptr);
- VirtFs::close(file);
- file = VirtFs::openRead("dir2/units123.xml");
- REQUIRE(file == nullptr);
- file = VirtFs::openRead("tesQ/units.xml");
- REQUIRE(file == nullptr);
- file = VirtFs::openRead("units.xml1");
- REQUIRE(file == nullptr);
- file = VirtFs::openRead("testQ");
- REQUIRE(file == nullptr);
- file = VirtFs::openRead("dir/brimmedhat.png");
- REQUIRE(file != nullptr);
- VirtFs::close(file);
-
- VirtFs::unmountZip(prefix + "test.zip");
-
- file = VirtFs::openRead("dir2/units.xml");
- REQUIRE(file != nullptr);
- VirtFs::close(file);
- file = VirtFs::openRead("dir2\\/\\units.xml");
- REQUIRE(file != nullptr);
- VirtFs::close(file);
- file = VirtFs::openRead("dir2/units123.xml");
- REQUIRE(file == nullptr);
- file = VirtFs::openRead("tesQ/units.xml");
- REQUIRE(file == nullptr);
- file = VirtFs::openRead("units.xml1");
- REQUIRE(file == nullptr);
- file = VirtFs::openRead("testQ");
- REQUIRE(file == nullptr);
- file = VirtFs::openRead("dir/brimmedhat.png");
- REQUIRE(file == nullptr);
-
- VirtFs::unmountZip(prefix + "test2.zip");
-
- VirtFs::deinit();
-}
-
-TEST_CASE("VirtFs2 openRead3", "")
-{
- VirtFs::init(".");
- std::string name("data/test/test.zip");
- std::string prefix;
- if (Files::existsLocal(name) == false)
- prefix = "../" + prefix;
-
- VirtFs::mountDir2(prefix + "data",
- "test",
- Append_false);
-
- VirtFs::File *file = nullptr;
-
- file = VirtFs::openRead("units.xml");
- REQUIRE(file != nullptr);
- VirtFs::close(file);
- file = VirtFs::openRead("test/units.xml");
- REQUIRE(file == nullptr);
- file = VirtFs::openRead("units123.xml");
- REQUIRE(file == nullptr);
- file = VirtFs::openRead("tesQ/units.xml");
- REQUIRE(file == nullptr);
- file = VirtFs::openRead("testQ");
- REQUIRE(file == nullptr);
- file = VirtFs::openRead("file1.txt");
- REQUIRE(file == nullptr);
- file = VirtFs::openRead("file2.txt");
- REQUIRE(file == nullptr);
-
- VirtFs::mountDir2(prefix + "data/test",
- "dir2",
- Append_false);
-
- file = VirtFs::openRead("units.xml");
- REQUIRE(file != nullptr);
- VirtFs::close(file);
- file = VirtFs::openRead("test/units.xml");
- REQUIRE(file == nullptr);
- file = VirtFs::openRead("units123.xml");
- REQUIRE(file == nullptr);
- file = VirtFs::openRead("tesQ/units.xml");
- REQUIRE(file == nullptr);
- file = VirtFs::openRead("testQ");
- REQUIRE(file == nullptr);
- file = VirtFs::openRead("file1.txt");
- REQUIRE(file != nullptr);
- VirtFs::close(file);
- file = VirtFs::openRead("file2.txt");
- REQUIRE(file != nullptr);
- VirtFs::close(file);
-
- VirtFs::unmountDir2(prefix + "data/test",
- "dir2");
-
- file = VirtFs::openRead("units.xml");
- REQUIRE(file != nullptr);
- VirtFs::close(file);
- file = VirtFs::openRead("test/units.xml");
- REQUIRE(file == nullptr);
- file = VirtFs::openRead("units123.xml");
- REQUIRE(file == nullptr);
- file = VirtFs::openRead("tesQ/units.xml");
- REQUIRE(file == nullptr);
- file = VirtFs::openRead("testQ");
- REQUIRE(file == nullptr);
- file = VirtFs::openRead("file1.txt");
- REQUIRE(file == nullptr);
- file = VirtFs::openRead("file2.txt");
- REQUIRE(file == nullptr);
-
- VirtFs::unmountDir2(prefix + "data",
- "test");
- VirtFs::deinit();
-}
-
-TEST_CASE("VirtFs2 openRead4", "")
-{
- VirtFs::init(".");
- std::string name("data/test/test.zip");
- std::string prefix("data/test/");
- if (Files::existsLocal(name) == false)
- prefix = "../" + prefix;
-
- VirtFs::mountZip2(prefix + "test2.zip",
- "dir",
- Append_false);
-
- VirtFs::File *file = nullptr;
-
- file = VirtFs::openRead("dye.png");
- REQUIRE(file != nullptr);
- VirtFs::close(file);
- file = VirtFs::openRead("1\\test.txt");
- REQUIRE(file != nullptr);
- VirtFs::close(file);
- file = VirtFs::openRead("dir/dye.png");
- REQUIRE(file == nullptr);
- file = VirtFs::openRead("tesQ/units.xml");
- REQUIRE(file == nullptr);
- file = VirtFs::openRead("dye.png1");
- REQUIRE(file == nullptr);
- file = VirtFs::openRead("testQ");
- REQUIRE(file == nullptr);
- file = VirtFs::openRead("brimmedhat.png");
- REQUIRE(file == nullptr);
-
- VirtFs::mountZip2(prefix + "test.zip",
- "dir",
- Append_false);
-
- file = VirtFs::openRead("dye.png");
- REQUIRE(file != nullptr);
- VirtFs::close(file);
- file = VirtFs::openRead("1\\test.txt");
- REQUIRE(file != nullptr);
- VirtFs::close(file);
- file = VirtFs::openRead("dir/dye.png");
- REQUIRE(file == nullptr);
- file = VirtFs::openRead("tesQ/units.xml");
- REQUIRE(file == nullptr);
- file = VirtFs::openRead("dye.png1");
- REQUIRE(file == nullptr);
- file = VirtFs::openRead("testQ");
- REQUIRE(file == nullptr);
- file = VirtFs::openRead("brimmedhat.png");
- REQUIRE(file != nullptr);
- VirtFs::close(file);
-
- VirtFs::unmountZip2(prefix + "test.zip",
- "dir");
-
- file = VirtFs::openRead("dye.png");
- REQUIRE(file != nullptr);
- VirtFs::close(file);
- file = VirtFs::openRead("1\\test.txt");
- REQUIRE(file != nullptr);
- VirtFs::close(file);
- file = VirtFs::openRead("dir/dye.png");
- REQUIRE(file == nullptr);
- file = VirtFs::openRead("tesQ/units.xml");
- REQUIRE(file == nullptr);
- file = VirtFs::openRead("dye.png1");
- REQUIRE(file == nullptr);
- file = VirtFs::openRead("testQ");
- REQUIRE(file == nullptr);
- file = VirtFs::openRead("brimmedhat.png");
- REQUIRE(file == nullptr);
-
- VirtFs::unmountZip2(prefix + "test2.zip",
- "dir");
-
- VirtFs::deinit();
-}
-
-TEST_CASE("VirtFs2 permitLinks", "")
-{
- VirtFs::init(".");
- std::string name("data/test/test.zip");
- std::string prefix;
- if (Files::existsLocal(name) == false)
- prefix = "../" + prefix;
-
- VirtFs::mountDir(prefix + "data",
- Append_false);
-
- const int cnt1 = VirtFs::exists("test/test2.txt") ? 26 : 25;
- const int cnt2 = 26;
-
- StringVect list;
- VirtFs::permitLinks(false);
- VirtFs::getFiles("test", list);
- removeTemp(list);
- const size_t sz = list.size();
- REQUIRE(sz == cnt1);
-
- list.clear();
- VirtFs::permitLinks(true);
- VirtFs::getFiles("test", list);
- removeTemp(list);
- REQUIRE(list.size() == cnt2);
-
- list.clear();
- VirtFs::permitLinks(false);
- VirtFs::getFiles("test", list);
- removeTemp(list);
- REQUIRE(list.size() == cnt1);
-
- VirtFs::unmountDirSilent(prefix + "data");
- VirtFs::deinit();
-}
-
-TEST_CASE("VirtFs2 read1", "")
-{
- VirtFs::init(".");
- std::string name("data/test/test.zip");
- std::string prefix;
- if (Files::existsLocal(name) == false)
- prefix = "../" + prefix;
-
- VirtFs::mountDir(prefix + "data",
- Append_false);
-
- VirtFs::File *file = VirtFs::openRead("test/test.txt");
- REQUIRE(file != nullptr);
- REQUIRE(VirtFs::fileLength(file) == 23);
- const int fileSize = VirtFs::fileLength(file);
-
- void *restrict buffer = calloc(fileSize + 1, 1);
- REQUIRE(VirtFs::read(file, buffer, 1, fileSize) == fileSize);
- REQUIRE(strcmp(static_cast<char*>(buffer),
- "test line 1\ntest line 2") == 0);
- REQUIRE(VirtFs::tell(file) == fileSize);
- REQUIRE(VirtFs::eof(file) != 0);
-
- free(buffer);
- buffer = calloc(fileSize + 1, 1);
- REQUIRE(VirtFs::seek(file, 12) != 0);
- REQUIRE(VirtFs::eof(file) == 0);
- REQUIRE(VirtFs::tell(file) == 12);
- REQUIRE(VirtFs::read(file, buffer, 1, 11) == 11);
- REQUIRE(strcmp(static_cast<char*>(buffer),
- "test line 2") == 0);
- REQUIRE(VirtFs::eof(file) != 0);
-
- VirtFs::close(file);
- free(buffer);
-
- VirtFs::unmountDir(prefix + "data");
- VirtFs::deinit();
-}
-
-TEST_CASE("VirtFs2 read2", "")
-{
- VirtFs::init(".");
- std::string name("data/test/test.zip");
- std::string prefix("data/test/");
- if (Files::existsLocal(name) == false)
- prefix = "../" + prefix;
-
- VirtFs::mountZip(prefix + "test2.zip",
- Append_false);
- VirtFs::File *file = nullptr;
- void *restrict buffer = nullptr;
-
- SECTION("test 1")
- {
- file = VirtFs::openRead("dir2//test.txt");
- REQUIRE(file != nullptr);
- REQUIRE(VirtFs::fileLength(file) == 23);
- const int fileSize = VirtFs::fileLength(file);
-
- buffer = calloc(fileSize + 1, 1);
- REQUIRE(VirtFs::read(file, buffer, 1, fileSize) == fileSize);
- REQUIRE(strcmp(static_cast<char*>(buffer),
- "test line 1\ntest line 2") == 0);
- REQUIRE(VirtFs::tell(file) == fileSize);
- REQUIRE(VirtFs::eof(file) != 0);
- }
-
- SECTION("test 2")
- {
- file = VirtFs::openRead("dir2\\/test.txt");
- REQUIRE(file != nullptr);
- REQUIRE(VirtFs::fileLength(file) == 23);
- const int fileSize = VirtFs::fileLength(file);
-
- buffer = calloc(fileSize + 1, 1);
- REQUIRE(VirtFs::seek(file, 12) != 0);
- REQUIRE(VirtFs::eof(file) == 0);
- REQUIRE(VirtFs::tell(file) == 12);
- REQUIRE(VirtFs::read(file, buffer, 1, 11) == 11);
- REQUIRE(strcmp(static_cast<char*>(buffer),
- "test line 2") == 0);
- REQUIRE(VirtFs::eof(file) != 0);
- }
-
- SECTION("test 3")
- {
- file = VirtFs::openRead("dir2//test.txt");
- REQUIRE(file != nullptr);
- const int fileSize = VirtFs::fileLength(file);
-
- buffer = calloc(fileSize + 1, 1);
- for (int f = 0; f < fileSize; f ++)
- {
- REQUIRE(VirtFs::seek(file, f) != 0);
- REQUIRE(VirtFs::eof(file) == 0);
- REQUIRE(VirtFs::tell(file) == f);
- }
- }
-
- SECTION("test 4")
- {
- file = VirtFs::openRead("dir2/test.txt");
- REQUIRE(file != nullptr);
- const int fileSize = VirtFs::fileLength(file);
- const char *restrict const str = "test line 1\ntest line 2";
- buffer = calloc(fileSize + 1, 1);
- for (int f = 0; f < fileSize - 1; f ++)
- {
- REQUIRE(VirtFs::read(file, buffer, 1, 1) == 1);
- REQUIRE(static_cast<char*>(buffer)[0] == str[f]);
- REQUIRE(VirtFs::eof(file) == 0);
- REQUIRE(VirtFs::tell(file) == f + 1);
- }
- REQUIRE(VirtFs::read(file, buffer, 1, 1) == 1);
- REQUIRE(static_cast<char*>(buffer)[0] == str[22]);
- REQUIRE(VirtFs::eof(file) != 0);
- REQUIRE(VirtFs::tell(file) == fileSize);
- }
-
- SECTION("test 5")
- {
- file = VirtFs::openRead("dir2\\\\test.txt");
- REQUIRE(file != nullptr);
- const int fileSize = VirtFs::fileLength(file);
- const char *restrict const str = "test line 1\ntest line 2";
- buffer = calloc(fileSize + 1, 1);
- for (int f = 0; f < fileSize - 1; f += 2)
- {
- REQUIRE(VirtFs::read(file, buffer, 2, 1) == 1);
- REQUIRE(static_cast<char*>(buffer)[0] == str[f]);
- REQUIRE(static_cast<char*>(buffer)[1] == str[f + 1]);
- REQUIRE(VirtFs::eof(file) == 0);
- REQUIRE(VirtFs::tell(file) == f + 2);
- }
- REQUIRE(VirtFs::eof(file) == 0);
- REQUIRE(VirtFs::tell(file) == 22);
- REQUIRE(VirtFs::read(file, buffer, 2, 1) == 0);
- REQUIRE(VirtFs::eof(file) == 0);
- }
-
- SECTION("test 6")
- {
- file = VirtFs::openRead("dir2//test.txt");
- REQUIRE(file != nullptr);
- const int fileSize = VirtFs::fileLength(file);
- const char *restrict const str = "test line 1\ntest line 2";
- buffer = calloc(fileSize + 1, 1);
- for (int f = 0; f < fileSize - 1; f += 2)
- {
- REQUIRE(VirtFs::read(file, buffer, 1, 2) == 2);
- REQUIRE(static_cast<char*>(buffer)[0] == str[f]);
- REQUIRE(static_cast<char*>(buffer)[1] == str[f + 1]);
- REQUIRE(VirtFs::eof(file) == 0);
- REQUIRE(VirtFs::tell(file) == f + 2);
- }
- REQUIRE(VirtFs::eof(file) == 0);
- REQUIRE(VirtFs::tell(file) == 22);
- REQUIRE(VirtFs::read(file, buffer, 1, 2) == 1);
- REQUIRE(static_cast<char*>(buffer)[0] == str[22]);
- REQUIRE(VirtFs::eof(file) != 0);
- }
-
- VirtFs::close(file);
- free(buffer);
- VirtFs::unmountZip(prefix + "test2.zip");
- VirtFs::deinit();
-}
-
-TEST_CASE("VirtFs2 loadFile1", "")
-{
- VirtFs::init(".");
- int fileSize = 0;
- std::string name("data/test/test.zip");
- std::string prefix;
- if (Files::existsLocal(name) == false)
- prefix = "../" + prefix;
-
- VirtFs::mountDir(prefix + "data",
- Append_false);
-
- const char *const buffer = VirtFs::loadFile("test/test.txt", fileSize);
- REQUIRE(static_cast<const void*>(buffer) != nullptr);
- REQUIRE(fileSize == 23);
- REQUIRE(strncmp(buffer, "test line 1\ntest line 2", 23) == 0);
- delete [] buffer;
-
- VirtFs::unmountDir(prefix + "data");
- VirtFs::deinit();
-}
-
-TEST_CASE("VirtFs2 loadFile2", "")
-{
- VirtFs::init(".");
- int fileSize = 0;
- std::string name("data/test/test.zip");
- std::string prefix;
- if (Files::existsLocal(name) == false)
- prefix = "../" + prefix;
-
- VirtFs::mountZip(prefix + "data/test/test2.zip",
- Append_false);
-
- SECTION("test 1")
- {
- const char *restrict buffer = VirtFs::loadFile("dir2//test.txt",
- fileSize);
- REQUIRE(static_cast<const void*>(buffer) != nullptr);
- REQUIRE(fileSize == 23);
- REQUIRE(strncmp(buffer, "test line 1\ntest line 2", 23) == 0);
- delete [] buffer;
- }
-
- SECTION("test 2")
- {
- const char *restrict buffer = VirtFs::loadFile("dir2\\/test.txt",
- fileSize);
- REQUIRE(static_cast<const void*>(buffer) != nullptr);
- REQUIRE(fileSize == 23);
- REQUIRE(strncmp(buffer, "test line 1\ntest line 2", 23) == 0);
- delete [] buffer;
- }
-
- VirtFs::unmountZip(prefix + "data/test/test2.zip");
- VirtFs::deinit();
-}
-
-TEST_CASE("VirtFs2 loadFile3", "")
-{
- VirtFs::init(".");
- int fileSize = 0;
- std::string name("data/test/test.zip");
- std::string prefix;
- if (Files::existsLocal(name) == false)
- prefix = "../" + prefix;
-
- VirtFs::mountDir2(prefix + "data",
- "test",
- Append_false);
-
- const char *const buffer = VirtFs::loadFile("test.txt", fileSize);
- REQUIRE(static_cast<const void*>(buffer) != nullptr);
- REQUIRE(fileSize == 23);
- REQUIRE(strncmp(buffer, "test line 1\ntest line 2", 23) == 0);
- delete [] buffer;
-
- VirtFs::unmountDir2(prefix + "data",
- "test");
- VirtFs::deinit();
-}
-
-TEST_CASE("VirtFs2 loadFile4", "")
-{
- VirtFs::init(".");
- int fileSize = 0;
- std::string name("data/test/test.zip");
- std::string prefix;
- if (Files::existsLocal(name) == false)
- prefix = "../" + prefix;
-
- VirtFs::mountZip2(prefix + "data/test/test2.zip",
- "dir2",
- Append_false);
-
- SECTION("test 1")
- {
- const char *restrict buffer = VirtFs::loadFile("test.txt",
- fileSize);
- REQUIRE(static_cast<const void*>(buffer) != nullptr);
- REQUIRE(fileSize == 23);
- REQUIRE(strncmp(buffer, "test line 1\ntest line 2", 23) == 0);
- delete [] buffer;
- }
-
- SECTION("test 2")
- {
- const char *restrict buffer = VirtFs::loadFile("test.txt",
- fileSize);
- REQUIRE(static_cast<const void*>(buffer) != nullptr);
- REQUIRE(fileSize == 23);
- REQUIRE(strncmp(buffer, "test line 1\ntest line 2", 23) == 0);
- delete [] buffer;
- }
-
- VirtFs::unmountZip2(prefix + "data/test/test2.zip",
- "dir2");
- VirtFs::deinit();
-}
-
-TEST_CASE("VirtFs2 rwops_read1", "")
-{
- VirtFs::init(".");
- std::string name("data/test/test.zip");
- std::string prefix;
- if (Files::existsLocal(name) == false)
- prefix = "../" + prefix;
-
- VirtFs::mountDir(prefix + "data",
- Append_false);
-
- SDL_RWops *file = VirtFs::rwopsOpenRead("test/test.txt");
- REQUIRE(file != nullptr);
-#ifdef USE_SDL2
- REQUIRE(file->size(file) == 23);
-#endif // USE_SDL2
-
- const int fileSize = 23;
-
- void *restrict buffer = calloc(fileSize + 1, 1);
- REQUIRE(file->read(file, buffer, 1, fileSize) == fileSize);
- REQUIRE(strcmp(static_cast<char*>(buffer),
- "test line 1\ntest line 2") == 0);
- REQUIRE(file->seek(file, 0, SEEK_CUR) == fileSize);
-
- free(buffer);
- buffer = calloc(fileSize + 1, 1);
- REQUIRE(file->seek(file, 12, SEEK_SET) != 0);
- REQUIRE(file->seek(file, 0, SEEK_CUR) == 12);
- REQUIRE(file->read(file, buffer, 1, 11) == 11);
- REQUIRE(strcmp(static_cast<char*>(buffer),
- "test line 2") == 0);
-
- file->close(file);
- free(buffer);
-
- VirtFs::unmountDir(prefix + "data");
- VirtFs::deinit();
-}
-
-TEST_CASE("VirtFs2 rwops_read2", "")
-{
- VirtFs::init(".");
- std::string name("data/test/test.zip");
- std::string prefix("data/test/");
- if (Files::existsLocal(name) == false)
- prefix = "../" + prefix;
-
- VirtFs::mountZip(prefix + "test2.zip",
- Append_false);
- SDL_RWops *file = nullptr;
- void *restrict buffer = nullptr;
-
- SECTION("test 1")
- {
- file = VirtFs::rwopsOpenRead("dir2//test.txt");
- REQUIRE(file != nullptr);
-#ifdef USE_SDL2
- REQUIRE(file->size(file) == 23);
-#endif // USE_SDL2
- const int fileSize = 23;
-
- buffer = calloc(fileSize + 1, 1);
- REQUIRE(file->read(file, buffer, 1, fileSize) == fileSize);
- REQUIRE(strcmp(static_cast<char*>(buffer),
- "test line 1\ntest line 2") == 0);
- REQUIRE(file->seek(file, 0, SEEK_CUR) == fileSize);
- }
-
- SECTION("test 2")
- {
- file = VirtFs::rwopsOpenRead("dir2\\/test.txt");
- REQUIRE(file != nullptr);
-#ifdef USE_SDL2
- REQUIRE(file->size(file) == 23);
-#endif // USE_SDL2
- const int fileSize = 23;
-
- buffer = calloc(fileSize + 1, 1);
- REQUIRE(file->seek(file, 12, SEEK_SET) != 0);
- REQUIRE(file->seek(file, 0, SEEK_CUR) == 12);
- REQUIRE(file->read(file, buffer, 1, 11) == 11);
- REQUIRE(strcmp(static_cast<char*>(buffer),
- "test line 2") == 0);
- }
-
- SECTION("test 3")
- {
- file = VirtFs::rwopsOpenRead("dir2//test.txt");
- REQUIRE(file != nullptr);
- const int fileSize = 23;
-
- buffer = calloc(fileSize + 1, 1);
- for (int f = 0; f < fileSize; f ++)
- {
- REQUIRE(file->seek(file, f, SEEK_SET) == f);
- REQUIRE(file->seek(file, 0, SEEK_CUR) == f);
- }
- }
-
- SECTION("test 4")
- {
- file = VirtFs::rwopsOpenRead("dir2/test.txt");
- REQUIRE(file != nullptr);
- const int fileSize = 23;
- const char *restrict const str = "test line 1\ntest line 2";
- buffer = calloc(fileSize + 1, 1);
- for (int f = 0; f < fileSize - 1; f ++)
- {
- REQUIRE(file->read(file, buffer, 1, 1) == 1);
- REQUIRE(static_cast<char*>(buffer)[0] == str[f]);
- REQUIRE(file->seek(file, 0, SEEK_CUR) == f + 1);
- }
- REQUIRE(file->read(file, buffer, 1, 1) == 1);
- REQUIRE(static_cast<char*>(buffer)[0] == str[22]);
- REQUIRE(file->seek(file, 0, SEEK_CUR) == fileSize);
- }
-
- SECTION("test 5")
- {
- file = VirtFs::rwopsOpenRead("dir2\\\\test.txt");
- REQUIRE(file != nullptr);
- const int fileSize = 23;
- const char *restrict const str = "test line 1\ntest line 2";
- buffer = calloc(fileSize + 1, 1);
- for (int f = 0; f < fileSize - 1; f += 2)
- {
- REQUIRE(file->read(file, buffer, 2, 1) == 1);
- REQUIRE(static_cast<char*>(buffer)[0] == str[f]);
- REQUIRE(static_cast<char*>(buffer)[1] == str[f + 1]);
- REQUIRE(file->seek(file, 0, SEEK_CUR) == f + 2);
- }
- REQUIRE(file->seek(file, 0, SEEK_CUR) == 22);
- REQUIRE(file->read(file, buffer, 2, 1) == 0);
- }
-
- SECTION("test 6")
- {
- file = VirtFs::rwopsOpenRead("dir2//test.txt");
- REQUIRE(file != nullptr);
- const int fileSize = 23;
- const char *restrict const str = "test line 1\ntest line 2";
- buffer = calloc(fileSize + 1, 1);
- for (int f = 0; f < fileSize - 1; f += 2)
- {
- REQUIRE(file->read(file, buffer, 1, 2) == 2);
- REQUIRE(static_cast<char*>(buffer)[0] == str[f]);
- REQUIRE(static_cast<char*>(buffer)[1] == str[f + 1]);
- REQUIRE(file->seek(file, 0, SEEK_CUR) == f + 2);
- }
- REQUIRE(file->seek(file, 0, SEEK_CUR) == 22);
- REQUIRE(file->read(file, buffer, 1, 2) == 1);
- REQUIRE(static_cast<char*>(buffer)[0] == str[22]);
- }
-
- SECTION("test 7")
- {
- file = VirtFs::rwopsOpenRead("dir2//test.txt");
- REQUIRE(file != nullptr);
- const int fileSize = 23;
- const char *restrict const str = "test line 1\ntest line 2";
- buffer = calloc(fileSize + 1, 1);
- for (int f = 0; f < fileSize - 1; f += 2)
- {
- REQUIRE(file->read(file, buffer, 1, 2) == 2);
- REQUIRE(file->seek(file, -2, SEEK_CUR) == f);
- REQUIRE(file->seek(file, 0, SEEK_CUR) == f);
- REQUIRE(file->seek(file, 2, SEEK_CUR) == f + 2);
- REQUIRE(static_cast<char*>(buffer)[0] == str[f]);
- REQUIRE(static_cast<char*>(buffer)[1] == str[f + 1]);
- REQUIRE(file->seek(file, 0, SEEK_CUR) == f + 2);
- }
- REQUIRE(file->seek(file, 0, SEEK_CUR) == 22);
- REQUIRE(file->read(file, buffer, 1, 2) == 1);
- REQUIRE(static_cast<char*>(buffer)[0] == str[22]);
- }
-
- SECTION("test 8")
- {
- file = VirtFs::rwopsOpenRead("dir2//test.txt");
- REQUIRE(file != nullptr);
- const int fileSize = 23;
- const char *restrict const str = "test line 1\ntest line 2";
- buffer = calloc(fileSize + 1, 1);
- for (int f = 0; f < fileSize - 1; f += 2)
- {
- REQUIRE(file->seek(file, -f - 2, SEEK_END) == 23 - f - 2);
- REQUIRE(file->read(file, buffer, 1, 2) == 2);
- REQUIRE(static_cast<char*>(buffer)[0] == str[23 - f - 2]);
- REQUIRE(static_cast<char*>(buffer)[1] == str[23 - f - 2 + 1]);
- REQUIRE(file->seek(file, 0, SEEK_CUR) == 23 - f);
- }
- // 3
- REQUIRE(file->seek(file, 1, SEEK_CUR) == 4);
- // 4
- REQUIRE(file->read(file, buffer, 1, 2) == 2);
- // 6
- REQUIRE(static_cast<char*>(buffer)[0] == str[4]);
- REQUIRE(static_cast<char*>(buffer)[1] == str[5]);
- REQUIRE(file->seek(file, -7, SEEK_CUR) == -1);
- REQUIRE(file->seek(file, 6, SEEK_SET) == 6);
- REQUIRE(file->seek(file, -6, SEEK_CUR) == 0);
- }
-
- if (file != nullptr)
- file->close(file);
- free(buffer);
- VirtFs::unmountZip(prefix + "test2.zip");
- VirtFs::deinit();
-}
-
-TEST_CASE("VirtFs2 rwops_read3", "")
-{
- VirtFs::init(".");
- std::string name("data/test/test.zip");
- std::string prefix;
- if (Files::existsLocal(name) == false)
- prefix = "../" + prefix;
-
- VirtFs::mountDir(prefix + "data",
- Append_false);
- SDL_RWops *file = nullptr;
- void *restrict buffer = nullptr;
-
- SECTION("test 1")
- {
- file = VirtFs::rwopsOpenRead("test/test.txt");
- REQUIRE(file != nullptr);
-#ifdef USE_SDL2
- REQUIRE(file->size(file) == 23);
-#endif // USE_SDL2
- const int fileSize = 23;
-
- buffer = calloc(fileSize + 1, 1);
- REQUIRE(file->read(file, buffer, 1, fileSize) == fileSize);
- REQUIRE(strcmp(static_cast<char*>(buffer),
- "test line 1\ntest line 2") == 0);
- REQUIRE(file->seek(file, 0, SEEK_CUR) == fileSize);
- }
-
- SECTION("test 2")
- {
- file = VirtFs::rwopsOpenRead("test\\test.txt");
- REQUIRE(file != nullptr);
-#ifdef USE_SDL2
- REQUIRE(file->size(file) == 23);
-#endif // USE_SDL2
- const int fileSize = 23;
-
- buffer = calloc(fileSize + 1, 1);
- REQUIRE(file->seek(file, 12, SEEK_SET) != 0);
- REQUIRE(file->seek(file, 0, SEEK_CUR) == 12);
- REQUIRE(file->read(file, buffer, 1, 11) == 11);
- REQUIRE(strcmp(static_cast<char*>(buffer),
- "test line 2") == 0);
- }
-
- SECTION("test 3")
- {
- file = VirtFs::rwopsOpenRead("test\\/test.txt");
- REQUIRE(file != nullptr);
- const int fileSize = 23;
-
- buffer = calloc(fileSize + 1, 1);
- for (int f = 0; f < fileSize; f ++)
- {
- REQUIRE(file->seek(file, f, SEEK_SET) == f);
- REQUIRE(file->seek(file, 0, SEEK_CUR) == f);
- }
- }
-
- SECTION("test 4")
- {
- file = VirtFs::rwopsOpenRead("test/test.txt");
- REQUIRE(file != nullptr);
- const int fileSize = 23;
- const char *restrict const str = "test line 1\ntest line 2";
- buffer = calloc(fileSize + 1, 1);
- for (int f = 0; f < fileSize - 1; f ++)
- {
- REQUIRE(file->read(file, buffer, 1, 1) == 1);
- REQUIRE(static_cast<char*>(buffer)[0] == str[f]);
- REQUIRE(file->seek(file, 0, SEEK_CUR) == f + 1);
- }
- REQUIRE(file->read(file, buffer, 1, 1) == 1);
- REQUIRE(static_cast<char*>(buffer)[0] == str[22]);
- REQUIRE(file->seek(file, 0, SEEK_CUR) == fileSize);
- }
-
- SECTION("test 5")
- {
- file = VirtFs::rwopsOpenRead("test///test.txt");
- REQUIRE(file != nullptr);
- const int fileSize = 23;
- const char *restrict const str = "test line 1\ntest line 2";
- buffer = calloc(fileSize + 1, 1);
- for (int f = 0; f < fileSize - 1; f += 2)
- {
- REQUIRE(file->read(file, buffer, 2, 1) == 1);
- REQUIRE(static_cast<char*>(buffer)[0] == str[f]);
- REQUIRE(static_cast<char*>(buffer)[1] == str[f + 1]);
- REQUIRE(file->seek(file, 0, SEEK_CUR) == f + 2);
- }
- REQUIRE(file->seek(file, 0, SEEK_CUR) == 22);
- REQUIRE(file->read(file, buffer, 2, 1) == 0);
- }
-
- SECTION("test 6")
- {
- file = VirtFs::rwopsOpenRead("test\\\\test.txt");
- REQUIRE(file != nullptr);
- const int fileSize = 23;
- const char *restrict const str = "test line 1\ntest line 2";
- buffer = calloc(fileSize + 1, 1);
- for (int f = 0; f < fileSize - 1; f += 2)
- {
- REQUIRE(file->read(file, buffer, 1, 2) == 2);
- REQUIRE(static_cast<char*>(buffer)[0] == str[f]);
- REQUIRE(static_cast<char*>(buffer)[1] == str[f + 1]);
- REQUIRE(file->seek(file, 0, SEEK_CUR) == f + 2);
- }
- REQUIRE(file->seek(file, 0, SEEK_CUR) == 22);
- REQUIRE(file->read(file, buffer, 1, 2) == 1);
- REQUIRE(static_cast<char*>(buffer)[0] == str[22]);
- }
-
- SECTION("test 7")
- {
- file = VirtFs::rwopsOpenRead("test//test.txt");
- REQUIRE(file != nullptr);
- const int fileSize = 23;
- const char *restrict const str = "test line 1\ntest line 2";
- buffer = calloc(fileSize + 1, 1);
- for (int f = 0; f < fileSize - 1; f += 2)
- {
- REQUIRE(file->read(file, buffer, 1, 2) == 2);
- REQUIRE(file->seek(file, -2, SEEK_CUR) == f);
- REQUIRE(file->seek(file, 0, SEEK_CUR) == f);
- REQUIRE(file->seek(file, 2, SEEK_CUR) == f + 2);
- REQUIRE(static_cast<char*>(buffer)[0] == str[f]);
- REQUIRE(static_cast<char*>(buffer)[1] == str[f + 1]);
- REQUIRE(file->seek(file, 0, SEEK_CUR) == f + 2);
- }
- REQUIRE(file->seek(file, 0, SEEK_CUR) == 22);
- REQUIRE(file->read(file, buffer, 1, 2) == 1);
- REQUIRE(static_cast<char*>(buffer)[0] == str[22]);
- }
-
- SECTION("test 8")
- {
- file = VirtFs::rwopsOpenRead("test/test.txt");
- REQUIRE(file != nullptr);
- const int fileSize = 23;
- const char *restrict const str = "test line 1\ntest line 2";
- buffer = calloc(fileSize + 1, 1);
- for (int f = 0; f < fileSize - 1; f += 2)
- {
- REQUIRE(file->seek(file, -f - 2, SEEK_END) == 23 - f - 2);
- REQUIRE(file->read(file, buffer, 1, 2) == 2);
- REQUIRE(static_cast<char*>(buffer)[0] == str[23 - f - 2]);
- REQUIRE(static_cast<char*>(buffer)[1] == str[23 - f - 2 + 1]);
- REQUIRE(file->seek(file, 0, SEEK_CUR) == 23 - f);
- }
- // 3
- REQUIRE(file->seek(file, 1, SEEK_CUR) == 4);
- // 4
- REQUIRE(file->read(file, buffer, 1, 2) == 2);
- // 6
- REQUIRE(static_cast<char*>(buffer)[0] == str[4]);
- REQUIRE(static_cast<char*>(buffer)[1] == str[5]);
- REQUIRE(file->seek(file, -7, SEEK_CUR) == -1);
- REQUIRE(file->seek(file, 6, SEEK_SET) == 6);
- REQUIRE(file->seek(file, -6, SEEK_CUR) == 0);
- }
-
- if (file != nullptr)
- file->close(file);
- free(buffer);
- VirtFs::unmountDir(prefix + "data");
- VirtFs::deinit();
-}
-
-TEST_CASE("VirtFs2 getFiles zip1", "")
-{
- VirtFs::init(".");
- std::string name("data/test/test.zip");
- std::string prefix;
- if (Files::existsLocal(name) == false)
- prefix = "../" + prefix;
-
- VirtFs::mountZip(prefix + "data/test/test2.zip",
- Append_false);
-
- StringVect list;
- VirtFs::getFiles("dir", list);
- REQUIRE(list.size() == 2);
- REQUIRE(inList(list, "dye.png"));
- REQUIRE(inList(list, "hide.png"));
-
- list.clear();
- VirtFs::getFiles("dir2", list);
- REQUIRE(list.size() == 4);
- REQUIRE(inList(list, "hide.png"));
- REQUIRE(inList(list, "paths.xml"));
- REQUIRE(inList(list, "test.txt"));
- REQUIRE(inList(list, "units.xml"));
-
- VirtFs::unmountZip(prefix + "data/test/test2.zip");
- VirtFs::deinit();
-}
-
-TEST_CASE("VirtFs2 getFiles zip2", "")
-{
- VirtFs::init(".");
- std::string name("data/test/test.zip");
- std::string prefix;
- if (Files::existsLocal(name) == false)
- prefix = "../" + prefix;
-
- VirtFs::mountZip2(prefix + "data/test/test2.zip",
- "dir",
- Append_false);
-
- StringVect list;
- VirtFs::getFiles(dirSeparator, list);
- REQUIRE(list.size() == 2);
- REQUIRE(inList(list, "dye.png"));
- REQUIRE(inList(list, "hide.png"));
-
- list.clear();
- VirtFs::getFiles("1", list);
- REQUIRE(list.size() == 2);
- REQUIRE(inList(list, "file1.txt"));
- REQUIRE(inList(list, "test.txt"));
-
- VirtFs::unmountZip2(prefix + "data/test/test2.zip",
- "dir");
- VirtFs::deinit();
-}
-
-TEST_CASE("VirtFs2 getDirs1", "")
-{
- VirtFs::init(".");
- std::string name("data/test/test.zip");
- std::string prefix;
- if (Files::existsLocal(name) == false)
- prefix = "../" + prefix;
-
- VirtFs::mountZip(prefix + "data/test/test2.zip",
- Append_false);
-
- StringVect list;
- VirtFs::getDirs("dir", list);
- REQUIRE(list.size() == 2);
- REQUIRE(inList(list, "1"));
- REQUIRE(inList(list, "gpl"));
- list.clear();
-
- VirtFs::getDirs("dir2", list);
- REQUIRE(list.empty());
-
- VirtFs::unmountZip(prefix + "data/test/test2.zip");
- VirtFs::deinit();
-}
-
-TEST_CASE("VirtFs2 getDirs2", "")
-{
- VirtFs::init(".");
- std::string name("data/test/test.zip");
- std::string prefix;
- if (Files::existsLocal(name) == false)
- prefix = "../" + prefix;
- StringVect list;
-
- SECTION("dir1")
- {
- VirtFs::mountDir(prefix + "data/test",
- Append_false);
-
- VirtFs::getDirs("/", list);
-// REQUIRE(list.size() == 2);
- REQUIRE(inList(list, "dir1"));
- REQUIRE(inList(list, "dir2"));
- list.clear();
-
- VirtFs::getDirs("dir1", list);
- REQUIRE(list.empty());
-
- VirtFs::unmountDir(prefix + "data/test");
- }
-
- SECTION("dir2")
- {
- VirtFs::mountDir(prefix + "data",
- Append_false);
-
- VirtFs::getDirs("sfx", list);
- REQUIRE(inList(list, "system"));
- list.clear();
-
- VirtFs::getDirs("evol", list);
- REQUIRE(list.size() == 2);
- REQUIRE(inList(list, "icons"));
- REQUIRE(inList(list, "images"));
-
- VirtFs::unmountDir(prefix + "data");
- }
-
- VirtFs::deinit();
-}
-
-TEST_CASE("VirtFs2 getDirs3", "")
-{
- VirtFs::init(".");
- std::string name("data/test/test.zip");
- std::string prefix;
- if (Files::existsLocal(name) == false)
- prefix = "../" + prefix;
-
- VirtFs::mountZip2(prefix + "data/test/test2.zip",
- "dir",
- Append_false);
-
- StringVect list;
- VirtFs::getDirs(dirSeparator, list);
- REQUIRE(list.size() == 2);
- REQUIRE(inList(list, "1"));
- REQUIRE(inList(list, "gpl"));
- list.clear();
-
- VirtFs::getDirs("1", list);
- REQUIRE(list.empty());
-
- VirtFs::unmountZip2(prefix + "data/test/test2.zip",
- "dir");
- VirtFs::deinit();
-}
-
-TEST_CASE("VirtFs2 getDirs4", "")
-{
- VirtFs::init(".");
- std::string name("data/test/test.zip");
- std::string prefix;
- if (Files::existsLocal(name) == false)
- prefix = "../" + prefix;
- StringVect list;
-
- SECTION("dir1")
- {
- VirtFs::mountDir2(prefix + "data",
- "test",
- Append_false);
-
- VirtFs::getDirs("/", list);
- REQUIRE(inList(list, "dir1"));
- REQUIRE(inList(list, "dir2"));
- list.clear();
-
- VirtFs::getDirs("dir1", list);
- REQUIRE(list.empty());
-
- VirtFs::unmountDir2(prefix + "data",
- "test");
- }
-
- VirtFs::deinit();
-}
-
-TEST_CASE("VirtFs2 getFilesWithDir1", "")
-{
- VirtFs::init(".");
- std::string name("data/test/test.zip");
- std::string prefix;
- if (Files::existsLocal(name) == false)
- prefix = "../" + prefix;
-
- VirtFs::mountZip(prefix + "data/test/test2.zip",
- Append_false);
-
- StringVect list;
- VirtFs::getFilesWithDir("dir", list);
- REQUIRE(list.size() == 2);
- REQUIRE(inList(list, "dir", "dye.png"));
- REQUIRE(inList(list, "dir", "hide.png"));
- list.clear();
-
- VirtFs::getFilesWithDir("dir2", list);
- REQUIRE(list.size() == 4);
- REQUIRE(inList(list, "dir2", "hide.png"));
- REQUIRE(inList(list, "dir2", "paths.xml"));
- REQUIRE(inList(list, "dir2", "test.txt"));
- REQUIRE(inList(list, "dir2", "units.xml"));
- list.clear();
-
- VirtFs::getFilesWithDir(dirSeparator, list);
- REQUIRE(list.size() > 2);
- REQUIRE(inList(list, dirSeparator, "test.txt"));
- REQUIRE(inList(list, dirSeparator, "units.xml"));
- list.clear();
-
- VirtFs::unmountZip(prefix + "data/test/test2.zip");
- VirtFs::deinit();
-}
-
-TEST_CASE("VirtFs2 getFilesWithDir2", "")
-{
- VirtFs::init(".");
- std::string name("data/test/test.zip");
- std::string prefix;
- if (Files::existsLocal(name) == false)
- prefix = "../" + prefix;
- StringVect list;
-
- SECTION("dir1")
- {
- VirtFs::mountDir(prefix + "data/graphics",
- Append_false);
-
- VirtFs::getFilesWithDir("/", list);
- REQUIRE(list.size() <= 5);
- VirtFs::unmountDir(prefix + "data/graphics");
- }
-
- SECTION("dir2")
- {
- VirtFs::mountDir(prefix + "data",
- Append_false);
-
- VirtFs::getFilesWithDir("music", list);
- REQUIRE(list.size() <= 5);
- REQUIRE(!list.empty());
- REQUIRE(inList(list, "music", "keprohm.ogg"));
- list.clear();
-
- VirtFs::getFilesWithDir(pathJoin("evol", "icons"), list);
-#ifdef WIN32
- REQUIRE(list.size() == 1);
- REQUIRE(inList(list, pathJoin("evol", "icons"), "evol-client.ico"));
-#else // WIN32
-
- REQUIRE(list.size() == 3);
- REQUIRE(inList(list, pathJoin("evol", "icons"), "evol-client.ico"));
- REQUIRE(inList(list, pathJoin("evol", "icons"), "evol-client.png"));
- REQUIRE(inList(list, pathJoin("evol", "icons"), "evol-client.xpm"));
-#endif // WIN32
-
- VirtFs::unmountDir(prefix + "data");
- }
-
- VirtFs::deinit();
-}
-
-TEST_CASE("VirtFs2 getFilesWithDir3", "")
-{
- VirtFs::init(".");
- std::string name("data/test/test.zip");
- std::string prefix;
- if (Files::existsLocal(name) == false)
- prefix = "../" + prefix;
-
- VirtFs::mountZip2(prefix + "data/test/test2.zip",
- "dir",
- Append_false);
-
- StringVect list;
- VirtFs::getFilesWithDir("1", list);
- REQUIRE(list.size() == 2);
- REQUIRE(inList(list, "1", "file1.txt"));
- REQUIRE(inList(list, "1", "test.txt"));
- list.clear();
-
- VirtFs::getFilesWithDir(dirSeparator, list);
- REQUIRE(list.size() == 2);
- REQUIRE(inList(list, dirSeparator, "dye.png"));
- REQUIRE(inList(list, dirSeparator, "hide.png"));
- list.clear();
-
- VirtFs::unmountZip2(prefix + "data/test/test2.zip",
- "dir");
- VirtFs::deinit();
-}
-
-TEST_CASE("VirtFs2 getFilesWithDir4", "")
-{
- VirtFs::init(".");
- std::string name("data/test/test.zip");
- std::string prefix;
- if (Files::existsLocal(name) == false)
- prefix = "../" + prefix;
- StringVect list;
-
- SECTION("dir1")
- {
- VirtFs::mountDir2(prefix + "data/graphics",
- "sprites",
- Append_false);
-
- VirtFs::getFilesWithDir("/", list);
- REQUIRE(list.size() <= 16);
- VirtFs::unmountDir2(prefix + "data/graphics",
- "sprites");
- }
-
- SECTION("dir2")
- {
- VirtFs::mountDir2(prefix + "data",
- "test",
- Append_false);
-
- VirtFs::getFilesWithDir("dir1", list);
- REQUIRE(list.size() <= 6);
- REQUIRE(!list.empty());
- REQUIRE(inList(list, "dir1", "file1.txt"));
- list.clear();
-
- VirtFs::unmountDir2(prefix + "data",
- "test");
- }
-
- VirtFs::deinit();
-}
diff --git a/src/unittests/fs/virtfs/zip.cc b/src/unittests/fs/virtfs/zip.cc
deleted file mode 100644
index 17491835e..000000000
--- a/src/unittests/fs/virtfs/zip.cc
+++ /dev/null
@@ -1,283 +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 "unittests/unittests.h"
-
-#include "logger.h"
-
-#include "fs/files.h"
-
-#include "fs/virtfs/fszip.h"
-#include "fs/virtfs/zipentry.h"
-#include "fs/virtfs/zipreader.h"
-#include "fs/virtfs/ziplocalheader.h"
-
-#include "debug.h"
-
-extern const char *dirSeparator;
-
-TEST_CASE("Zip readArchiveInfo", "")
-{
- std::string name("data/test/test.zip");
- std::string prefix;
- const std::string sep = dirSeparator;
- if (Files::existsLocal(name) == false)
- prefix = "../";
-
- SECTION("test.zip")
- {
- name = prefix + "data/test/test.zip";
-
- VirtFs::ZipEntry *const entry = new VirtFs::ZipEntry(name,
- dirSeparator,
- VirtFs::FsZip::getFuncs());
- STD_VECTOR<VirtFs::ZipLocalHeader*> &headers = entry->mHeaders;
-
- REQUIRE(VirtFs::ZipReader::readArchiveInfo(entry));
- REQUIRE(headers.size() == 2);
- REQUIRE(entry->root == name);
- REQUIRE(headers[0]->fileName == "dir" + sep + "hide.png");
- REQUIRE(headers[0]->compressSize == 365);
- REQUIRE(headers[0]->uncompressSize == 368);
- REQUIRE(headers[1]->fileName == "dir" + sep + "brimmedhat.png");
- REQUIRE(headers[1]->compressSize == 1959);
- REQUIRE(headers[1]->uncompressSize == 1959);
-
- delete entry;
- }
-
- SECTION("test2.zip")
- {
- name = prefix + "data/test/test2.zip";
-
- VirtFs::ZipEntry *const entry = new VirtFs::ZipEntry(name,
- dirSeparator,
- VirtFs::FsZip::getFuncs());
- STD_VECTOR<VirtFs::ZipLocalHeader*> &headers = entry->mHeaders;
-
- REQUIRE(VirtFs::ZipReader::readArchiveInfo(entry));
- REQUIRE(headers.size() == 11);
- REQUIRE(entry->root == name);
- REQUIRE(headers[0]->fileName == "test.txt");
- REQUIRE(headers[0]->compressSize == 17);
- REQUIRE(headers[0]->uncompressSize == 23);
-
- REQUIRE(headers[1]->fileName == "dir2" + sep + "hide.png");
- REQUIRE(headers[1]->compressSize == 365);
- REQUIRE(headers[1]->uncompressSize == 368);
-
- REQUIRE(headers[2]->fileName == "dir2" + sep + "test.txt");
- REQUIRE(headers[2]->compressSize == 17);
- REQUIRE(headers[2]->uncompressSize == 23);
-
- REQUIRE(headers[3]->fileName == "dir2" + sep + "paths.xml");
- REQUIRE(headers[3]->compressSize == 154);
- REQUIRE(headers[3]->uncompressSize == 185);
-
- REQUIRE(headers[4]->fileName == "dir2" + sep + "units.xml");
- REQUIRE(headers[4]->compressSize == 202);
- REQUIRE(headers[4]->uncompressSize == 306);
-
- REQUIRE(headers[5]->fileName == "dir" + sep + "hide.png");
- REQUIRE(headers[5]->compressSize == 365);
- REQUIRE(headers[5]->uncompressSize == 368);
-
- REQUIRE(headers[6]->fileName ==
- "dir" + sep + "1" + sep + "test.txt");
- REQUIRE(headers[6]->compressSize == 17);
- REQUIRE(headers[6]->uncompressSize == 23);
-
- REQUIRE(headers[7]->fileName ==
- "dir" + sep + "1" + sep + "file1.txt");
- REQUIRE(headers[7]->compressSize == 17);
- REQUIRE(headers[7]->uncompressSize == 23);
-
- REQUIRE(headers[8]->fileName ==
- "dir" + sep + "gpl" + sep + "palette.gpl");
- REQUIRE(headers[8]->compressSize == 128);
- REQUIRE(headers[8]->uncompressSize == 213);
-
- REQUIRE(headers[9]->fileName ==
- "dir" + sep + "dye.png");
- REQUIRE(headers[9]->compressSize == 794);
- REQUIRE(headers[9]->uncompressSize == 794);
-
- REQUIRE(headers[10]->fileName == "units.xml");
- REQUIRE(headers[10]->compressSize == 202);
- REQUIRE(headers[10]->uncompressSize == 306);
-
- delete entry;
- }
-
- SECTION("test3.zip")
- {
- name = prefix + "data/test/test3.zip";
-
- VirtFs::ZipEntry *const entry = new VirtFs::ZipEntry(name,
- dirSeparator,
- VirtFs::FsZip::getFuncs());
- STD_VECTOR<VirtFs::ZipLocalHeader*> &headers = entry->mHeaders;
-
- REQUIRE(VirtFs::ZipReader::readArchiveInfo(entry));
- REQUIRE(headers.size() == 2);
- REQUIRE(entry->root == name);
- REQUIRE(headers[0]->fileName == "test.txt");
- REQUIRE(headers[0]->compressSize == 17);
- REQUIRE(headers[0]->uncompressSize == 23);
- REQUIRE(headers[1]->fileName == "units.xml");
- REQUIRE(headers[1]->compressSize == 202);
- REQUIRE(headers[1]->uncompressSize == 306);
-
- delete entry;
- }
-
- SECTION("test4.zip")
- {
- name = prefix + "data/test/test4.zip";
-
- VirtFs::ZipEntry *const entry = new VirtFs::ZipEntry(name,
- dirSeparator,
- VirtFs::FsZip::getFuncs());
- STD_VECTOR<VirtFs::ZipLocalHeader*> &headers = entry->mHeaders;
-
- REQUIRE(VirtFs::ZipReader::readArchiveInfo(entry));
- REQUIRE(entry->root == name);
- REQUIRE(headers.empty());
-
- delete entry;
- }
-}
-
-TEST_CASE("Zip readCompressedFile", "")
-{
- std::string name("data/test/test.zip");
- std::string prefix;
- if (Files::existsLocal(name) == false)
- prefix = "../";
-
- SECTION("test2.zip")
- {
- name = prefix + "data/test/test2.zip";
-
- VirtFs::ZipEntry *const entry = new VirtFs::ZipEntry(name,
- dirSeparator,
- VirtFs::FsZip::getFuncs());
- STD_VECTOR<VirtFs::ZipLocalHeader*> &headers = entry->mHeaders;
-
- REQUIRE(VirtFs::ZipReader::readArchiveInfo(entry));
- REQUIRE(headers.size() == 11);
- REQUIRE(entry->root == name);
- // test.txt
- uint8_t *const buf = VirtFs::ZipReader::readCompressedFile(headers[0]);
- REQUIRE(buf != nullptr);
- delete [] buf;
- delete entry;
- }
-}
-
-TEST_CASE("Zip readFile", "")
-{
- std::string name("data/test/test.zip");
- std::string prefix;
- if (Files::existsLocal(name) == false)
- prefix = "../";
-
- SECTION("test.zip")
- {
- name = prefix + "data/test/test.zip";
-
- VirtFs::ZipEntry *const entry = new VirtFs::ZipEntry(name,
- dirSeparator,
- VirtFs::FsZip::getFuncs());
- STD_VECTOR<VirtFs::ZipLocalHeader*> &headers = entry->mHeaders;
-
- REQUIRE(VirtFs::ZipReader::readArchiveInfo(entry));
- REQUIRE(headers.size() == 2);
- REQUIRE(entry->root == name);
- for (int f = 0; f < 2; f ++)
- {
- logger->log("test header: %s, %u, %u",
- headers[f]->fileName.c_str(),
- headers[f]->compressSize,
- headers[f]->uncompressSize);
- const uint8_t *const buf = VirtFs::ZipReader::readFile(headers[f]);
- REQUIRE(buf != nullptr);
- delete [] buf;
- }
- delete entry;
- }
-
- SECTION("test2.zip")
- {
- name = prefix + "data/test/test2.zip";
-
- VirtFs::ZipEntry *const entry = new VirtFs::ZipEntry(name,
- dirSeparator,
- VirtFs::FsZip::getFuncs());
- STD_VECTOR<VirtFs::ZipLocalHeader*> &headers = entry->mHeaders;
-
- REQUIRE(VirtFs::ZipReader::readArchiveInfo(entry));
- REQUIRE(headers.size() == 11);
- REQUIRE(entry->root == name);
- // test.txt
- const uint8_t *buf = VirtFs::ZipReader::readFile(headers[0]);
- REQUIRE(buf != nullptr);
- const std::string str = std::string(reinterpret_cast<const char*>(buf),
- headers[0]->uncompressSize);
- REQUIRE(str == "test line 1\ntest line 2");
- delete [] buf;
- for (int f = 0; f < 11; f ++)
- {
- logger->log("test header: %s, %u, %u",
- headers[f]->fileName.c_str(),
- headers[f]->compressSize,
- headers[f]->uncompressSize);
- buf = VirtFs::ZipReader::readFile(headers[f]);
- REQUIRE(buf != nullptr);
- delete [] buf;
- }
- delete entry;
- }
-
- SECTION("test3.zip")
- {
- name = prefix + "data/test/test3.zip";
-
- VirtFs::ZipEntry *const entry = new VirtFs::ZipEntry(name,
- dirSeparator,
- VirtFs::FsZip::getFuncs());
- STD_VECTOR<VirtFs::ZipLocalHeader*> &headers = entry->mHeaders;
-
- REQUIRE(VirtFs::ZipReader::readArchiveInfo(entry));
- REQUIRE(headers.size() == 2);
- REQUIRE(entry->root == name);
- for (int f = 0; f < 2; f ++)
- {
- logger->log("test header: %s, %u, %u",
- headers[f]->fileName.c_str(),
- headers[f]->compressSize,
- headers[f]->uncompressSize);
- const uint8_t *const buf = VirtFs::ZipReader::readFile(headers[f]);
- REQUIRE(buf != nullptr);
- delete [] buf;
- }
- delete entry;
- }
-}
diff --git a/src/unittests/gui/fonts/textchunklist.cc b/src/unittests/gui/fonts/textchunklist.cc
deleted file mode 100644
index c8df87455..000000000
--- a/src/unittests/gui/fonts/textchunklist.cc
+++ /dev/null
@@ -1,548 +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 "unittests/unittests.h"
-
-#include "gui/fonts/font.h"
-#include "gui/fonts/textchunk.h"
-
-#include "debug.h"
-
-TEST_CASE("TextChunkList empty", "TextChunkList")
-{
- TextChunkList list;
-
- REQUIRE(0 == list.size);
- REQUIRE(nullptr == list.start);
- REQUIRE(nullptr == list.end);
- REQUIRE(list.search.empty());
- REQUIRE(list.searchWidth.empty());
-}
-
-TEST_CASE("TextChunkList add 1", "TextChunkList")
-{
- TextChunkList list;
-
- TextChunk *const chunk = new TextChunk("test",
- Color(1, 2, 3), Color(2, 3, 4), nullptr);
-
- list.insertFirst(chunk);
-
- REQUIRE(1 == list.size);
- REQUIRE(chunk == list.start);
- REQUIRE(chunk == list.end);
- REQUIRE(nullptr == chunk->prev);
- REQUIRE(nullptr == chunk->next);
-
- REQUIRE(1 == list.search.size());
- REQUIRE(chunk == (*list.search.find(TextChunkSmall(
- chunk->text, chunk->color, chunk->color2))).second);
-
- REQUIRE(1 == list.searchWidth.size());
- REQUIRE(chunk == (*list.searchWidth.find(chunk->text)).second);
- delete chunk;
-}
-
-TEST_CASE("TextChunkList add 2", "TextChunkList")
-{
- TextChunkList list;
-
- TextChunk *const chunk1 = new TextChunk("test",
- Color(1, 2, 3), Color(3, 4, 5), nullptr);
- TextChunk *const chunk2 = new TextChunk("test",
- Color(2, 3, 4), Color(4, 5, 6), nullptr);
-
- list.insertFirst(chunk2);
- list.insertFirst(chunk1);
-
- REQUIRE(2 == list.size);
- REQUIRE(chunk1 == list.start);
- REQUIRE(chunk2 == list.end);
- REQUIRE(nullptr == chunk1->prev);
- REQUIRE(chunk2 == chunk1->next);
- REQUIRE(chunk1 == chunk2->prev);
- REQUIRE(nullptr == chunk2->next);
-
- REQUIRE(2 == list.search.size());
- REQUIRE(chunk1 == (*list.search.find(TextChunkSmall(
- chunk1->text, chunk1->color, chunk1->color2))).second);
- REQUIRE(chunk2 == (*list.search.find(TextChunkSmall(
- chunk2->text, chunk2->color, chunk2->color2))).second);
-
- REQUIRE(1 == list.searchWidth.size());
- REQUIRE(chunk1 == (*list.searchWidth.find(chunk1->text)).second);
- delete chunk1;
- delete chunk2;
-}
-
-TEST_CASE("TextChunkList addRemoveBack 1", "TextChunkList")
-{
- TextChunkList list;
-
- TextChunk *const chunk = new TextChunk("test",
- Color(1, 2, 3), Color(1, 2, 3), nullptr);
-
- list.insertFirst(chunk);
- list.removeBack();
-
- REQUIRE(0 == list.size);
- REQUIRE(nullptr == list.start);
- REQUIRE(nullptr == list.end);
- REQUIRE(list.search.empty());
- REQUIRE(list.searchWidth.empty());
-}
-
-TEST_CASE("TextChunkList addRemoveBack 2", "TextChunkList")
-{
- TextChunkList list;
-
- TextChunk *const chunk1 = new TextChunk("test",
- Color(1, 2, 3), Color(1, 2, 3), nullptr);
- TextChunk *const chunk2 = new TextChunk("test2",
- Color(1, 2, 4), Color(1, 2, 5), nullptr);
-
- list.insertFirst(chunk2);
- list.insertFirst(chunk1);
- list.removeBack();
-
- REQUIRE(1 == list.size);
- REQUIRE(chunk1 == list.start);
- REQUIRE(chunk1 == list.end);
- REQUIRE(nullptr == chunk1->prev);
- REQUIRE(nullptr == chunk1->next);
-
- REQUIRE(1 == list.search.size());
- REQUIRE(chunk1 == (*list.search.find(TextChunkSmall(
- chunk1->text, chunk1->color, chunk1->color2))).second);
-
- REQUIRE(1 == list.searchWidth.size());
- REQUIRE(chunk1 == (*list.searchWidth.find(chunk1->text)).second);
- delete chunk1;
-}
-
-TEST_CASE("TextChunkList addRemoveBack 3", "TextChunkList")
-{
- TextChunkList list;
-
- TextChunk *const chunk1 = new TextChunk("test",
- Color(1, 2, 3), Color(1, 2, 3), nullptr);
- TextChunk *const chunk2 = new TextChunk("test2",
- Color(2, 3, 4), Color(2, 3, 4), nullptr);
-
- list.insertFirst(chunk2);
- list.insertFirst(chunk1);
- list.removeBack(2);
-
- REQUIRE(0 == list.size);
- REQUIRE(nullptr == list.start);
- REQUIRE(nullptr == list.end);
-
- REQUIRE(list.search.empty());
- REQUIRE(list.searchWidth.empty());
-}
-
-TEST_CASE("TextChunkList addRemoveBack 4", "TextChunkList")
-{
- TextChunkList list;
-
- TextChunk *const chunk1 = new TextChunk("test",
- Color(1, 2, 3), Color(1, 2, 3), nullptr);
- TextChunk *const chunk2 = new TextChunk("test2",
- Color(2, 3, 4), Color(2, 3, 4), nullptr);
- TextChunk *const chunk3 = new TextChunk("test",
- Color(3, 4, 5), Color(3, 4, 5), nullptr);
-
- list.insertFirst(chunk3);
- list.insertFirst(chunk2);
- list.insertFirst(chunk1);
- list.removeBack();
- list.removeBack();
-
- REQUIRE(1 == list.size);
- REQUIRE(chunk1 == list.start);
- REQUIRE(chunk1 == list.end);
- REQUIRE(nullptr == chunk1->prev);
- REQUIRE(nullptr == chunk1->next);
-
- REQUIRE(1 == list.search.size());
- REQUIRE(chunk1 == (*list.search.find(TextChunkSmall(
- chunk1->text, chunk1->color, chunk1->color2))).second);
-
- REQUIRE(list.searchWidth.empty());
- delete chunk1;
-}
-
-TEST_CASE("TextChunkList moveToFirst 1", "TextChunkList")
-{
- TextChunkList list;
-
- TextChunk *const chunk = new TextChunk("test",
- Color(1, 2, 3), Color(2, 3, 4), nullptr);
-
- list.insertFirst(chunk);
- list.moveToFirst(chunk);
-
- REQUIRE(1 == list.size);
- REQUIRE(chunk == list.start);
- REQUIRE(chunk == list.end);
- REQUIRE(nullptr == chunk->prev);
- REQUIRE(nullptr == chunk->next);
- delete chunk;
-}
-
-TEST_CASE("TextChunkList moveToFirst 2", "TextChunkList")
-{
- TextChunkList list;
-
- TextChunk *const chunk1 = new TextChunk("test",
- Color(1, 2, 3), Color(1, 2, 3), nullptr);
- TextChunk *const chunk2 = new TextChunk("test",
- Color(2, 3, 4), Color(1, 2, 3), nullptr);
-
- list.insertFirst(chunk1);
- list.insertFirst(chunk2);
- list.moveToFirst(chunk1);
-
- REQUIRE(2 == list.size);
- REQUIRE(chunk1 == list.start);
- REQUIRE(chunk2 == list.end);
- REQUIRE(nullptr == chunk1->prev);
- REQUIRE(chunk2 == chunk1->next);
- REQUIRE(chunk1 == chunk2->prev);
- REQUIRE(nullptr == chunk2->next);
- delete chunk1;
- delete chunk2;
-}
-
-TEST_CASE("TextChunkList moveToFirst 3", "TextChunkList")
-{
- TextChunkList list;
-
- TextChunk *const chunk1 = new TextChunk("test",
- Color(1, 2, 3), Color(1, 2, 3), nullptr);
- TextChunk *const chunk2 = new TextChunk("test",
- Color(1, 2, 4), Color(1, 2, 3), nullptr);
- TextChunk *const chunk3 = new TextChunk("test",
- Color(1, 2, 5), Color(1, 2, 3), nullptr);
-
- list.insertFirst(chunk3);
- list.insertFirst(chunk1);
- list.insertFirst(chunk2);
- list.moveToFirst(chunk1);
-
- REQUIRE(3 == list.size);
- REQUIRE(chunk1 == list.start);
- REQUIRE(chunk3 == list.end);
- REQUIRE(nullptr == chunk1->prev);
- REQUIRE(chunk2 == chunk1->next);
- REQUIRE(chunk1 == chunk2->prev);
- REQUIRE(chunk3 == chunk2->next);
- REQUIRE(chunk2 == chunk3->prev);
- REQUIRE(nullptr == chunk3->next);
- delete chunk1;
- delete chunk2;
- delete chunk3;
-}
-
-TEST_CASE("TextChunkList moveToFirst 4", "TextChunkList")
-{
- TextChunkList list;
-
- TextChunk *const chunk1 = new TextChunk("test",
- Color(), Color(), nullptr);
- TextChunk *const chunk2 = new TextChunk("test2",
- Color(), Color(), nullptr);
- TextChunk *const chunk3 = new TextChunk("test3",
- Color(), Color(), nullptr);
-
- list.insertFirst(chunk1);
- list.insertFirst(chunk3);
- list.insertFirst(chunk2);
- list.moveToFirst(chunk1);
-
- REQUIRE(3 == list.size);
- REQUIRE(chunk1 == list.start);
- REQUIRE(chunk3 == list.end);
- REQUIRE(nullptr == chunk1->prev);
- REQUIRE(chunk2 == chunk1->next);
- REQUIRE(chunk1 == chunk2->prev);
- REQUIRE(chunk3 == chunk2->next);
- REQUIRE(chunk2 == chunk3->prev);
- REQUIRE(nullptr == chunk3->next);
- delete chunk1;
- delete chunk2;
- delete chunk3;
-}
-
-TEST_CASE("TextChunkList clear 1", "TextChunkList")
-{
- TextChunkList list;
- const int chunksLeft = textChunkCnt;
-
- TextChunk *const chunk = new TextChunk("test",
- Color(), Color(), nullptr);
-
- list.insertFirst(chunk);
- list.clear();
-
- REQUIRE(0 == list.size);
- REQUIRE(nullptr == list.start);
- REQUIRE(nullptr == list.end);
- REQUIRE(chunksLeft == textChunkCnt);
- REQUIRE(list.search.empty());
- REQUIRE(list.searchWidth.empty());
-}
-
-TEST_CASE("TextChunkList clear 2", "TextChunkList")
-{
- TextChunkList list;
- const int chunksLeft = textChunkCnt;
-
- TextChunk *const chunk1 = new TextChunk("test",
- Color(1, 2, 3), Color(2, 0, 0), nullptr);
- TextChunk *const chunk2 = new TextChunk("test",
- Color(1, 2, 3), Color(2, 0, 1), nullptr);
- TextChunk *const chunk3 = new TextChunk("test",
- Color(1, 2, 3), Color(2, 0, 2), nullptr);
-
- list.insertFirst(chunk1);
- list.insertFirst(chunk2);
- list.insertFirst(chunk3);
- list.clear();
-
- REQUIRE(0 == list.size);
- REQUIRE(nullptr == list.start);
- REQUIRE(nullptr == list.end);
- REQUIRE(chunksLeft == textChunkCnt);
- REQUIRE(list.search.empty());
- REQUIRE(list.searchWidth.empty());
-}
-
-TEST_CASE("TextChunkList clear 3", "TextChunkList")
-{
- TextChunkList list;
- const int chunksLeft = textChunkCnt;
-
- TextChunk *const chunk1 = new TextChunk("test",
- Color(1, 2, 3), Color(2, 0, 0), nullptr);
- TextChunk *const chunk2 = new TextChunk("test",
- Color(1, 2, 3), Color(2, 0, 1), nullptr);
- TextChunk *const chunk3 = new TextChunk("test",
- Color(1, 2, 3), Color(2, 0, 2), nullptr);
-
- list.insertFirst(chunk1);
- list.insertFirst(chunk2);
- list.insertFirst(chunk3);
- list.moveToFirst(chunk1);
- REQUIRE((chunksLeft + 3) == textChunkCnt);
- REQUIRE(3 == list.search.size());
- REQUIRE(1 == list.searchWidth.size());
-
- list.removeBack();
- REQUIRE((chunksLeft + 2) == textChunkCnt);
- REQUIRE(2 == list.search.size());
- REQUIRE(list.searchWidth.empty());
-
- list.clear();
- REQUIRE(chunksLeft == textChunkCnt);
- REQUIRE(list.search.empty());
- REQUIRE(list.searchWidth.empty());
-}
-
-TEST_CASE("TextChunkList clear 4", "TextChunkList")
-{
- TextChunkList list;
- const int chunksLeft = textChunkCnt;
-
- TextChunk *const chunk1 = new TextChunk("test",
- Color(1, 2, 3), Color(2, 0, 0), nullptr);
- TextChunk *const chunk2 = new TextChunk("test",
- Color(1, 2, 3), Color(2, 0, 1), nullptr);
- TextChunk *const chunk3 = new TextChunk("test3",
- Color(1, 2, 3), Color(2, 0, 2), nullptr);
-
- list.insertFirst(chunk1);
- list.insertFirst(chunk2);
- list.insertFirst(chunk3);
- list.moveToFirst(chunk2);
- REQUIRE((chunksLeft + 3) == textChunkCnt);
- REQUIRE(3 == list.search.size());
- REQUIRE(2 == list.searchWidth.size());
-
- list.removeBack(2);
- REQUIRE((chunksLeft + 1) == textChunkCnt);
- REQUIRE(1 == list.search.size());
- REQUIRE(list.searchWidth.empty());
-
- list.clear();
- REQUIRE(chunksLeft == textChunkCnt);
- REQUIRE(list.search.empty());
- REQUIRE(list.searchWidth.empty());
-}
-
-TEST_CASE("TextChunkList remove 1", "TextChunkList")
-{
- TextChunkList list;
- const int chunksLeft = textChunkCnt;
-
- TextChunk *const chunk = new TextChunk("test",
- Color(), Color(), nullptr);
-
- list.insertFirst(chunk);
- list.remove(chunk);
- delete chunk;
-
- REQUIRE(0 == list.size);
- REQUIRE(nullptr == list.start);
- REQUIRE(nullptr == list.end);
- REQUIRE(chunksLeft == textChunkCnt);
- REQUIRE(list.search.empty());
- REQUIRE(list.searchWidth.empty());
-}
-
-TEST_CASE("TextChunkList remove 2", "TextChunkList")
-{
- TextChunkList list;
- const int chunksLeft = textChunkCnt;
-
- TextChunk *const chunk1 = new TextChunk("test1",
- Color(1, 2, 3), Color(2, 0, 0), nullptr);
- TextChunk *const chunk2 = new TextChunk("test2",
- Color(1, 2, 3), Color(2, 0, 1), nullptr);
- TextChunk *const chunk3 = new TextChunk("test3",
- Color(1, 2, 3), Color(2, 0, 2), nullptr);
-
- list.insertFirst(chunk1);
- list.insertFirst(chunk2);
- list.insertFirst(chunk3);
- list.remove(chunk1);
- delete chunk1;
-
- REQUIRE(2 == list.size);
- REQUIRE(chunk3 == list.start);
- REQUIRE(chunk2 == list.end);
- REQUIRE((chunksLeft + 2) == textChunkCnt);
- REQUIRE(2 == list.search.size());
- REQUIRE(2 == list.searchWidth.size());
- delete chunk2;
- delete chunk3;
-}
-
-TEST_CASE("TextChunkList remove 3", "TextChunkList")
-{
- TextChunkList list;
- const int chunksLeft = textChunkCnt;
-
- TextChunk *const chunk1 = new TextChunk("test1",
- Color(1, 2, 3), Color(2, 0, 0), nullptr);
- TextChunk *const chunk2 = new TextChunk("test2",
- Color(1, 2, 3), Color(2, 0, 1), nullptr);
- TextChunk *const chunk3 = new TextChunk("test3",
- Color(1, 2, 3), Color(2, 0, 2), nullptr);
-
- list.insertFirst(chunk1);
- list.insertFirst(chunk2);
- list.insertFirst(chunk3);
- list.remove(chunk2);
- delete chunk2;
-
- REQUIRE(2 == list.size);
- REQUIRE(chunk3 == list.start);
- REQUIRE(chunk1 == list.end);
- REQUIRE((chunksLeft + 2) == textChunkCnt);
- REQUIRE(2 == list.search.size());
- REQUIRE(2 == list.searchWidth.size());
- delete chunk1;
- delete chunk3;
-}
-
-TEST_CASE("TextChunkList sort 1", "TextChunkList")
-{
- TextChunkSmall item1("test line1",
- Color(1, 2, 3), Color(1, 2, 3));
- TextChunkSmall item2("test line1",
- Color(1, 2, 3), Color(1, 2, 3));
- TextChunkSmall item3("test line2",
- Color(1, 2, 3), Color(1, 2, 3));
- REQUIRE(false == (item1 < item2));
- REQUIRE(false == (item2 < item1));
- REQUIRE(item1 < item3);
- REQUIRE(false == (item3 < item1));
-}
-
-TEST_CASE("TextChunkList sort 2", "TextChunkList")
-{
- TextChunkSmall item1("test line1",
- Color(1, 2, 3), Color(1, 2, 3));
- TextChunkSmall item2("test line1",
- Color(2, 3, 4), Color(1, 2, 3));
- REQUIRE(item1 < item2);
- REQUIRE(false == (item2 < item1));
-}
-
-TEST_CASE("TextChunkList sort 3", "TextChunkList")
-{
- TextChunkSmall item1("test line1",
- Color(1, 2, 3), Color(1, 2, 3));
- TextChunkSmall item2("test line1",
- Color(1, 3, 4), Color(1, 2, 3));
- REQUIRE(item1 < item2);
- REQUIRE(false == (item2 < item1));
-}
-
-TEST_CASE("TextChunkList sort 4", "TextChunkList")
-{
- TextChunkSmall item1("test line1",
- Color(1, 2, 3), Color(1, 2, 3));
- TextChunkSmall item2("test line1",
- Color(1, 2, 4), Color(1, 2, 3));
- REQUIRE(item1 < item2);
- REQUIRE(false == (item2 < item1));
-}
-
-TEST_CASE("TextChunkList sort 5", "TextChunkList")
-{
- TextChunkSmall item1("test line1",
- Color(1, 2, 3), Color(1, 2, 3));
- TextChunkSmall item2("test line1",
- Color(1, 2, 3), Color(2, 2, 3));
- REQUIRE(item1 < item2);
- REQUIRE(false == (item2 < item1));
-}
-
-TEST_CASE("TextChunkList sort 6", "TextChunkList")
-{
- TextChunkSmall item1("test line1",
- Color(1, 2, 3), Color(1, 2, 3));
- TextChunkSmall item2("test line1",
- Color(1, 2, 3), Color(1, 3, 3));
- REQUIRE(item1 < item2);
- REQUIRE(false == (item2 < item1));
-}
-
-TEST_CASE("TextChunkList sort 7", "TextChunkList")
-{
- TextChunkSmall item1("test line1",
- Color(1, 2, 3), Color(1, 2, 3));
- TextChunkSmall item2("test line1",
- Color(1, 2, 3), Color(1, 2, 4));
- REQUIRE(item1 < item2);
- REQUIRE(false == (item2 < item1));
-}
diff --git a/src/unittests/gui/widgets/browserbox.cc b/src/unittests/gui/widgets/browserbox.cc
deleted file mode 100644
index 46a5f3b23..000000000
--- a/src/unittests/gui/widgets/browserbox.cc
+++ /dev/null
@@ -1,191 +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 "unittests/unittests.h"
-
-#include "client.h"
-#include "configuration.h"
-#include "configmanager.h"
-#include "dirs.h"
-#include "graphicsmanager.h"
-
-#include "being/actorsprite.h"
-
-#include "fs/virtfs/fs.h"
-
-#include "gui/gui.h"
-
-#include "gui/fonts/font.h"
-
-#include "gui/widgets/browserbox.h"
-
-#include "utils/delete2.h"
-#include "utils/env.h"
-
-#include "render/sdlgraphics.h"
-
-#include "resources/sdlimagehelper.h"
-
-#include "debug.h"
-
-TEST_CASE("BrowserBox tests", "browserbox")
-{
- setEnv("SDL_VIDEODRIVER", "dummy");
-
- client = new Client;
- VirtFs::mountDirSilent("data", Append_false);
- VirtFs::mountDirSilent("../data", Append_false);
-
- mainGraphics = new SDLGraphics;
- imageHelper = new SDLImageHelper;
-
- Dirs::initRootDir();
- Dirs::initHomeDir();
-
- ConfigManager::initConfiguration();
- setConfigDefaults2(config);
- setBrandingDefaults(branding);
-
-#ifdef USE_SDL2
- SDLImageHelper::setRenderer(graphicsManager.createRenderer(
- graphicsManager.createWindow(640, 480, 0,
- SDL_WINDOW_SHOWN | SDL_SWSURFACE), SDL_RENDERER_SOFTWARE));
-#else // USE_SDL2
-
- graphicsManager.createWindow(640, 480, 0, SDL_ANYFORMAT | SDL_SWSURFACE);
-#endif // USE_SDL2
-
- theme = new Theme;
- Theme::selectSkin();
-
- ActorSprite::load();
- gui = new Gui();
- gui->postInit(mainGraphics);
-
- Widget::setGlobalFont(new Font(
- "/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans-Oblique.ttf",
- 18,
- TTF_STYLE_NORMAL));
- BrowserBox *const box = new BrowserBox(nullptr,
- Opaque_true,
- "");
- box->setWidth(100);
- std::string row = "test";
- box->addRow(row);
- REQUIRE(box->hasRows() == true);
- box->clearRows();
- row = "@@";
- box->addRow(row);
- row = "@@|";
- box->addRow(row);
- row = "|@@";
- box->addRow(row);
- row = "@@|@@";
- box->addRow(row);
- row = "|@@@@";
- box->addRow(row);
- row = "@@11|22@@";
- box->addRow(row);
- row = "##@@11|22@@";
- box->addRow(row);
- row = "@@##|22@@";
- box->addRow(row);
- row = "@@11|##22@@";
- box->addRow(row);
- row = "@@11|22##@@";
- box->addRow(row);
- row = "@@11|22@@##";
- box->addRow(row);
- row = "<##@@11|22@@";
- box->addRow(row);
- row = "@@<##|22@@";
- box->addRow(row);
- row = "@@11|<##22@@";
- box->addRow(row);
- row = "@@11|22<##@@";
- box->addRow(row);
- row = "@@11|22@@<##";
- box->addRow(row);
- row = "<##11|22@@";
- box->addRow(row);
- row = "<##|22@@";
- box->addRow(row);
- row = "11|<##22@@";
- box->addRow(row);
- row = "11|22<##@@";
- box->addRow(row);
- row = "11|22@@<##";
- box->addRow(row);
- row = "##>@@11|22@@";
- box->addRow(row);
- row = "@@##>|22@@";
- box->addRow(row);
- row = "@@11|##>22@@";
- box->addRow(row);
- row = "@@11|22##>@@";
- box->addRow(row);
- row = "@@11|22@@##>";
- box->addRow(row);
- row = "<##11|22##>";
- box->addRow(row);
- row = "<##|22##>";
- box->addRow(row);
- row = "11|<##22##>";
- box->addRow(row);
- row = "11|22<####>";
- box->addRow(row);
- row = "11|22##><##";
- box->addRow(row);
- row = "%%@@11|22@@";
- box->addRow(row);
- row = "%%2@@11|22@@";
- box->addRow(row);
- row = "<%%11|22@@";
- box->addRow(row);
- row = "@@%%>|22@@";
- box->addRow(row);
- row = "<%%|22%%>";
- box->addRow(row);
- row = "11|22<%%%%>";
- box->addRow(row);
- row = "%%";
- box->addRow(row);
- row = "%%1";
- box->addRow(row);
- row = "%%##";
- box->addRow(row);
- row = "%%###";
- box->addRow(row);
- row = "##%%";
- box->addRow(row);
- row = "##1%%";
- box->addRow(row);
- row = "##%%2";
- box->addRow(row);
- row = "##1%%2";
- box->addRow(row);
-
- delete Widget::getGloablFont();
- Widget::setGlobalFont(nullptr);
- delete box;
- delete2(client);
- VirtFs::unmountDirSilent("data");
- VirtFs::unmountDirSilent("../data");
-}
diff --git a/src/unittests/gui/windowmanager.cc b/src/unittests/gui/windowmanager.cc
deleted file mode 100644
index b7f1eee43..000000000
--- a/src/unittests/gui/windowmanager.cc
+++ /dev/null
@@ -1,991 +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 "unittests/unittests.h"
-
-#include "client.h"
-#include "configmanager.h"
-#include "configuration.h"
-#include "dirs.h"
-#include "graphicsmanager.h"
-#include "main.h"
-#include "settings.h"
-#include "textcommand.h"
-
-#include "being/localplayer.h"
-
-#include "const/resources/currency.h"
-
-#include "fs/virtfs/fs.h"
-
-#include "gui/gui.h"
-#include "gui/mailmessage.h"
-#include "gui/userpalette.h"
-#include "gui/windowmanager.h"
-
-#include "gui/popups/beingpopup.h"
-#include "gui/popups/itempopup.h"
-#include "gui/popups/popupmenu.h"
-#include "gui/popups/skillpopup.h"
-#include "gui/popups/spellpopup.h"
-#include "gui/popups/speechbubble.h"
-#include "gui/popups/statuspopup.h"
-#include "gui/popups/textboxpopup.h"
-#include "gui/popups/textpopup.h"
-
-#include "gui/widgets/desktop.h"
-#include "gui/widgets/emoteshortcutcontainer.h"
-#include "gui/widgets/createwidget.h"
-
-#include "gui/windows/bankwindow.h"
-#include "gui/windows/buydialog.h"
-#include "gui/windows/buyingstoreselldialog.h"
-#include "gui/windows/buyselldialog.h"
-#include "gui/windows/charselectdialog.h"
-#include "gui/windows/changeemaildialog.h"
-#include "gui/windows/changepassworddialog.h"
-#include "gui/windows/chatwindow.h"
-#include "gui/windows/connectiondialog.h"
-#include "gui/windows/confirmdialog.h"
-#include "gui/windows/cutinwindow.h"
-#include "gui/windows/debugwindow.h"
-#include "gui/windows/didyouknowwindow.h"
-#include "gui/windows/editdialog.h"
-#include "gui/windows/editserverdialog.h"
-#include "gui/windows/eggselectiondialog.h"
-#include "gui/windows/emotewindow.h"
-#include "gui/windows/equipmentwindow.h"
-#include "gui/windows/helpwindow.h"
-#include "gui/windows/insertcarddialog.h"
-#include "gui/windows/inventorywindow.h"
-#include "gui/windows/itemamountwindow.h"
-#include "gui/windows/killstats.h"
-#include "gui/windows/logindialog.h"
-#include "gui/windows/maileditwindow.h"
-#include "gui/windows/mailviewwindow.h"
-#include "gui/windows/mailwindow.h"
-#include "gui/windows/minimap.h"
-#include "gui/windows/ministatuswindow.h"
-#include "gui/windows/npcdialog.h"
-#include "gui/windows/npcselldialog.h"
-#include "gui/windows/okdialog.h"
-#include "gui/windows/outfitwindow.h"
-#include "gui/windows/questswindow.h"
-#include "gui/windows/quitdialog.h"
-#include "gui/windows/registerdialog.h"
-#include "gui/windows/serverdialog.h"
-#include "gui/windows/serverinfowindow.h"
-#include "gui/windows/setupwindow.h"
-#include "gui/windows/shopwindow.h"
-#include "gui/windows/shortcutwindow.h"
-#include "gui/windows/skilldialog.h"
-#include "gui/windows/socialwindow.h"
-#include "gui/windows/statuswindow.h"
-#include "gui/windows/textcommandeditor.h"
-#include "gui/windows/textdialog.h"
-#include "gui/windows/textselectdialog.h"
-#include "gui/windows/tradewindow.h"
-#include "gui/windows/updaterwindow.h"
-#include "gui/windows/whoisonline.h"
-#include "gui/windows/worldselectdialog.h"
-
-#include "input/touch/touchmanager.h"
-
-#include "net/logindata.h"
-
-#include "net/eathena/charserverhandler.h"
-#include "net/eathena/inventoryhandler.h"
-#include "net/eathena/serverfeatures.h"
-#include "net/eathena/playerhandler.h"
-
-#include "render/sdlgraphics.h"
-
-#include "resources/groupinfo.h"
-#include "resources/sdlimagehelper.h"
-
-#include "resources/db/groupdb.h"
-#include "resources/db/unitsdb.h"
-
-#include "resources/item/item.h"
-
-#include "resources/map/map.h"
-
-#include "resources/resourcemanager/resourcemanager.h"
-
-#include "utils/delete2.h"
-#include "utils/env.h"
-#include "utils/gettext.h"
-
-#include "utils/translation/translationmanager.h"
-
-#include "debug.h"
-
-extern QuitDialog *quitDialog;
-
-TEST_CASE("Windows tests", "windowmanager")
-{
- setEnv("SDL_VIDEODRIVER", "dummy");
-
- client = new Client;
- XML::initXML();
- SDL_Init(SDL_INIT_VIDEO);
- ResourceManager::deleteInstance();
- ResourceManager::cleanOrphans(true);
- VirtFs::mountDirSilent("data", Append_false);
- VirtFs::mountDirSilent("../data", Append_false);
- VirtFs::mountDirSilent("data/test", Append_false);
- VirtFs::mountDirSilent("../data/test", Append_false);
- setPathsDefaults(paths);
- branding.setValue("onlineServerFile", "test/serverlistplus.xml");
- mainGraphics = new SDLGraphics;
- imageHelper = new SDLImageHelper;
-
- Dirs::initRootDir();
- Dirs::initHomeDir();
-
- const std::string cfgName = settings.configDir +
- "/nonexistserver/config.xml";
- ::remove(cfgName.c_str());
-
- ConfigManager::initConfiguration();
- setConfigDefaults2(config);
- setBrandingDefaults(branding);
- setFeaturesDefaults(features);
- ConfigManager::initServerConfig("nonexistserver");
-
-#ifdef USE_SDL2
- SDLImageHelper::setRenderer(graphicsManager.createRenderer(
- graphicsManager.createWindow(640, 480, 0,
- SDL_WINDOW_SHOWN | SDL_SWSURFACE), SDL_RENDERER_SOFTWARE));
-#else // USE_SDL2
-
- graphicsManager.createWindow(640, 480, 0, SDL_ANYFORMAT | SDL_SWSURFACE);
-#endif // USE_SDL2
-
- userPalette = new UserPalette;
- config.setValue("fontSize", 16);
-
- theme = new Theme;
- Theme::selectSkin();
-
- localPlayer = new LocalPlayer(static_cast<BeingId>(1),
- BeingTypeId_zero);
-
- ActorSprite::load();
- gui = new Gui();
- gui->postInit(mainGraphics);
- touchManager.init();
- UnitsDb::load();
- charServerHandler = new EAthena::CharServerHandler;
- serverFeatures = new EAthena::ServerFeatures;
- inventoryHandler = new EAthena::InventoryHandler;
- playerHandler = new EAthena::PlayerHandler;
- paths.setValue("itemIcons", "");
-
- TranslationManager::init();
-
- mainGraphics->setVideoMode(640, 480,
- 1,
- 8,
- false,
- false,
- false,
- false,
- false);
-
- SECTION("bankWindow")
- {
- CREATEWIDGETV0(bankWindow, BankWindow);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(bankWindow);
- }
- SECTION("buyDialog1")
- {
- BuyDialog *dialog;
- CREATEWIDGETV0(dialog, BuyDialog);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(dialog);
- }
- SECTION("buyDialog2")
- {
- BuyDialog *dialog;
- CREATEWIDGETV(dialog, BuyDialog,
- BeingId_zero,
- DEFAULT_CURRENCY);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(dialog);
- }
-#ifdef TMWA_SUPPORT
- SECTION("buyDialog3")
- {
- BuyDialog *dialog;
- CREATEWIDGETV(dialog, BuyDialog,
- "user",
- DEFAULT_CURRENCY);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(dialog);
- }
-#endif // TMWA_SUPPORT
- SECTION("buyDialog4")
- {
- BuyDialog *dialog;
- BeingTypeId id = static_cast<BeingTypeId>(1);
- Map *map = new Map("test map",
- 10, 10,
- 32, 32);
- Being *being = Being::createBeing(BeingId_zero,
- ActorType::Avatar,
- id,
- map);
- CREATEWIDGETV(dialog, BuyDialog,
- being,
- DEFAULT_CURRENCY);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(dialog);
- delete2(being);
- delete2(map);
- }
- SECTION("BuyingStoreSellDialog")
- {
- BuyingStoreSellDialog *dialog;
- CREATEWIDGETV(dialog, BuyingStoreSellDialog,
- BeingId_zero, 0);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(dialog);
- }
- SECTION("BuySellDialog1")
- {
- BuySellDialog *dialog;
- CREATEWIDGETV(dialog, BuySellDialog, BeingId_zero);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(dialog);
- }
- SECTION("BuySellDialog2")
- {
- BuySellDialog *dialog;
- CREATEWIDGETV(dialog, BuySellDialog, "user");
- gui->draw();
- mainGraphics->updateScreen();
- delete2(dialog);
- }
- SECTION("ChangeEmailDialog")
- {
- LoginData data;
- ChangeEmailDialog *dialog;
- CREATEWIDGETV(dialog, ChangeEmailDialog, data);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(dialog);
- }
- SECTION("ChangePasswordDialog")
- {
- LoginData data;
- ChangePasswordDialog *dialog;
- CREATEWIDGETV(dialog, ChangePasswordDialog, data);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(dialog);
- }
- SECTION("CharSelectDialog")
- {
- LoginData data;
- CharSelectDialog *dialog;
- CREATEWIDGETV(dialog, CharSelectDialog, data);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(dialog);
- }
- SECTION("CharCreateDialog")
- {
-// LoginData data;
-// CharSelectDialog *dialog2;
-// CREATEWIDGETV(dialog2, CharSelectDialog, data);
-// CharCreateDialog *dialog;
-// CREATEWIDGETV(dialog, CharCreateDialog, dialog2, 0);
-// gui->draw();
-// mainGraphics->updateScreen();
-// delete2(dialog);
-// delete2(dialog2);
- }
- SECTION("ChatWindow")
- {
- CREATEWIDGETV(chatWindow, ChatWindow,
- "Chat");
- gui->draw();
- mainGraphics->updateScreen();
- delete2(chatWindow);
- }
- SECTION("ConfirmDialog")
- {
- ConfirmDialog *dialog;
- CREATEWIDGETV(dialog, ConfirmDialog,
- "", "", SOUND_REQUEST, false, Modal_false, nullptr);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(dialog);
- }
- SECTION("CutinWindow")
- {
- CREATEWIDGETV0(cutInWindow, CutInWindow);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(cutInWindow);
- }
- SECTION("DebugWindow")
- {
- CREATEWIDGETV(debugWindow, DebugWindow,
- "Debug");
- gui->draw();
- mainGraphics->updateScreen();
- delete2(debugWindow);
- }
- SECTION("didYouKnowWindow")
- {
- CREATEWIDGETV0(didYouKnowWindow, DidYouKnowWindow);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(didYouKnowWindow);
- }
- SECTION("EditDialog")
- {
- EditDialog *dialog;
- CREATEWIDGETV(dialog, EditDialog,
- "", "", "", 100, nullptr, Modal_false);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(dialog);
- }
- SECTION("EditServerDialog")
- {
- ServerInfo mCurrentServer;
- settings.configDir = VirtFs::getRealDir("test/serverlistplus.xml");
- ServerDialog *serverDialog = CREATEWIDGETR(ServerDialog,
- &mCurrentServer,
- settings.configDir);
- EditServerDialog *editServerDialog = CREATEWIDGETR(EditServerDialog,
- serverDialog, mCurrentServer, 0);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(editServerDialog);
- delete2(serverDialog);
- }
- SECTION("EggSelectionDialog")
- {
- EggSelectionDialog *dialog = CREATEWIDGETR0(EggSelectionDialog);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(dialog);
- }
- SECTION("EmoteWindow")
- {
- EmoteWindow *dialog = CREATEWIDGETR0(EmoteWindow);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(dialog);
- }
- SECTION("EquipmentWindow")
- {
- Equipment *equipment = new Equipment;
- Map *map = new Map("test", 100, 100, 32, 32);
- Being *being = Being::createBeing(BeingId_zero,
- ActorType::Player,
- BeingTypeId_zero,
- map);
- EquipmentWindow *dialog = CREATEWIDGETR(EquipmentWindow,
- equipment, being, false);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(dialog);
- delete2(being);
- delete2(map);
- delete2(equipment);
- }
- SECTION("helpWindow")
- {
- CREATEWIDGETV0(helpWindow, HelpWindow);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(helpWindow);
- }
- SECTION("InsertCardDialog")
- {
- Item *item = new Item(5000,
- ItemType::Card,
- 1,
- 0,
- ItemColor_one,
- Identified_true,
- Damaged_false,
- Favorite_false,
- Equipm_true,
- Equipped_false);
- InsertCardDialog *dialog = CREATEWIDGETR(InsertCardDialog,
- 0, item);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(dialog);
- delete2(item);
- }
- SECTION("InventoryWindow")
- {
- Inventory *inventory = new Inventory(InventoryType::Inventory);
- InventoryWindow *dialog = CREATEWIDGETR(InventoryWindow,
- inventory);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(dialog);
- delete2(inventory);
- }
- SECTION("ItemAmountWindow")
- {
- Item *item = new Item(5000,
- ItemType::Card,
- 1,
- 0,
- ItemColor_one,
- Identified_true,
- Damaged_false,
- Favorite_false,
- Equipm_true,
- Equipped_false);
- ItemAmountWindow *dialog = CREATEWIDGETR(ItemAmountWindow,
- ItemAmountWindowUsage::ItemDrop, nullptr, item);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(dialog);
- delete2(item);
- }
- SECTION("KillStats")
- {
- CREATEWIDGETV0(killStats, KillStats);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(killStats);
- }
- SECTION("loginDialog")
- {
- ServerInfo mCurrentServer;
- LoginDialog *loginDialog = CREATEWIDGETR(LoginDialog,
- loginData,
- &mCurrentServer,
- &settings.options.updateHost);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(loginDialog);
- }
- SECTION("MailEditWindow")
- {
- CREATEWIDGETV0(mailEditWindow, MailEditWindow);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(mailEditWindow);
- }
- SECTION("MailViewWindow")
- {
- MailMessage *message = new MailMessage;
- CREATEWIDGETV(mailViewWindow, MailViewWindow,
- message,
- 1);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(mailViewWindow);
- delete message;
- }
- SECTION("MailWindow")
- {
- CREATEWIDGETV0(mailWindow, MailWindow);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(mailWindow);
- }
- SECTION("Minimap")
- {
- CREATEWIDGETV0(minimap, Minimap);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(minimap);
- }
- SECTION("MiniStatusWindow")
- {
- CREATEWIDGETV0(miniStatusWindow, MiniStatusWindow);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(miniStatusWindow);
- }
- SECTION("NpcDialog")
- {
- NpcDialog *dialog = CREATEWIDGETR(NpcDialog, BeingId_zero);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(dialog);
- }
- SECTION("NpcSellDialog")
- {
- NpcSellDialog *dialog = CREATEWIDGETR(NpcSellDialog, BeingId_zero);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(dialog);
- }
- SECTION("OkDialog")
- {
- OkDialog *dialog = CREATEWIDGETR(OkDialog,
- "", "", "", DialogType::SILENCE, Modal_false,
- ShowCenter_true, nullptr, 100);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(dialog);
- }
- SECTION("OutfitWindow")
- {
- CREATEWIDGETV0(outfitWindow, OutfitWindow);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(outfitWindow);
- }
- SECTION("QuestsWindow")
- {
- CREATEWIDGETV0(questsWindow, QuestsWindow);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(questsWindow);
- }
- SECTION("QuitDialog")
- {
- CREATEWIDGETV(quitDialog, QuitDialog,
- &quitDialog);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(quitDialog);
- }
- SECTION("RegisterDialog")
- {
- RegisterDialog *dialog = CREATEWIDGETR(RegisterDialog,
- loginData);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(dialog);
- }
- SECTION("serversDialog")
- {
- ServerInfo mCurrentServer;
- settings.configDir = VirtFs::getRealDir("test/serverlistplus.xml");
- ServerDialog *serverDialog = CREATEWIDGETR(ServerDialog,
- &mCurrentServer,
- settings.configDir);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(serverDialog);
- }
- SECTION("serversInfoWindow")
- {
- ServerInfo mCurrentServer;
- CREATEWIDGETV(serverInfoWindow, ServerInfoWindow,
- mCurrentServer);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(serverInfoWindow);
- }
- SECTION("setupWindow")
- {
- CREATEWIDGETV0(setupWindow, SetupWindow);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(setupWindow);
- }
- SECTION("ShopSellDialog")
- {
- // only tmwa skipping
- }
- SECTION("ShopWindow")
- {
- CREATEWIDGETV0(shopWindow, ShopWindow);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(shopWindow);
- }
- SECTION("ShortcutWindow1")
- {
- EmoteShortcutContainer *container =
- new EmoteShortcutContainer(nullptr);
- CREATEWIDGETV(itemShortcutWindow, ShortcutWindow,
- "name",
- container);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(itemShortcutWindow);
- }
- SECTION("ShortcutWindow2")
- {
- CREATEWIDGETV(itemShortcutWindow, ShortcutWindow, "");
- gui->draw();
- mainGraphics->updateScreen();
- delete2(itemShortcutWindow);
- }
- SECTION("SkillDialog")
- {
- CREATEWIDGETV0(skillDialog, SkillDialog);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(skillDialog);
- }
- SECTION("SocialWindow")
- {
- CREATEWIDGETV0(socialWindow, SocialWindow);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(socialWindow);
- }
- SECTION("StatusWindow")
- {
- GroupDb::GroupInfos &groups = GroupDb::getGroups();
- groups[0] = new GroupInfo;
- groups[0]->name = std::string();
- groups[0]->longName = std::string();
- CREATEWIDGETV0(statusWindow, StatusWindow);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(statusWindow);
- delete groups[0];
- groups.clear();
- }
- SECTION("TextCommandEditor")
- {
- TextCommand *textCommand = new TextCommand(1, "", "", "",
- CommandTarget::NoTarget, "");
- TextCommandEditor *dialog = CREATEWIDGETR(TextCommandEditor,
- textCommand);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(dialog);
- delete2(textCommand);
- }
-
- SECTION("TextDialog")
- {
- TextDialog *dialog = CREATEWIDGETR(TextDialog,
- "", "", nullptr, false);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(dialog);
- }
- SECTION("TextSelectDialog")
- {
- TextSelectDialog *dialog = CREATEWIDGETR(TextSelectDialog,
- "", "", AllowQuit_false);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(dialog);
- }
- SECTION("TradeWindow")
- {
- CREATEWIDGETV0(tradeWindow, TradeWindow);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(tradeWindow);
- }
- SECTION("UpdaterWindow")
- {
- CREATEWIDGETV(updaterWindow, UpdaterWindow,
- "", "", false, UpdateType::Skip);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(updaterWindow);
- }
- SECTION("WhoIsOnline")
- {
- CREATEWIDGETV0(whoIsOnline, WhoIsOnline);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(whoIsOnline);
- }
- SECTION("WorldSelectDialog")
- {
- Worlds worlds;
- WorldSelectDialog *dialog = CREATEWIDGETR(WorldSelectDialog,
- worlds);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(dialog);
- }
- SECTION("popupMenu")
- {
- CREATEWIDGETV0(popupMenu, PopupMenu);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(popupMenu);
- }
- SECTION("skillPopup")
- {
- CREATEWIDGETV0(skillPopup, SkillPopup);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(skillPopup);
- }
- SECTION("SpeechBubble")
- {
- SpeechBubble *bubble = CREATEWIDGETR0(SpeechBubble);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(bubble);
- }
- SECTION("beingPopup")
- {
- CREATEWIDGETV0(beingPopup, BeingPopup);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(beingPopup);
- }
- SECTION("textPopup")
- {
- CREATEWIDGETV0(textPopup, TextPopup);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(textPopup);
- }
- SECTION("textBoxPopup")
- {
- CREATEWIDGETV0(textBoxPopup, TextBoxPopup);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(textBoxPopup);
- }
- SECTION("itemPopup")
- {
- CREATEWIDGETV0(itemPopup, ItemPopup);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(itemPopup);
- }
- SECTION("spellPopup")
- {
- CREATEWIDGETV0(spellPopup, SpellPopup);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(spellPopup);
- }
- SECTION("StatusPopup")
- {
- StatusPopup *status = CREATEWIDGETR0(StatusPopup);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(status);
- }
- SECTION("desktop")
- {
- CREATEWIDGETV(desktop, Desktop, nullptr);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(desktop);
- }
- SECTION("connectionDialog")
- {
- ConnectionDialog *connectionDialog = CREATEWIDGETR(ConnectionDialog,
- // TRANSLATORS: connection dialog header
- _("Logging in"),
- State::SWITCH_SERVER);
- gui->draw();
- mainGraphics->updateScreen();
- delete2(connectionDialog);
- }
-
- UnitsDb::unload();
- delete2(localPlayer);
- delete2(userPalette);
- delete2(client);
- delete2(serverFeatures);
- delete2(inventoryHandler);
- delete2(charServerHandler);
- delete2(playerHandler);
- delete2(gui);
- ResourceManager::deleteInstance();
- VirtFs::unmountDirSilent("data");
- VirtFs::unmountDirSilent("../data");
- VirtFs::unmountDirSilent("data/test");
- VirtFs::unmountDirSilent("../data/test");
-}
-
-TEST_CASE("WindowManager", "create windows")
-{
- setEnv("SDL_VIDEODRIVER", "dummy");
-
- client = new Client;
- XML::initXML();
- SDL_Init(SDL_INIT_VIDEO);
- ResourceManager::deleteInstance();
- ResourceManager::cleanOrphans(true);
- VirtFs::mountDirSilent("data", Append_false);
- VirtFs::mountDirSilent("../data", Append_false);
- VirtFs::mountDirSilent("data/test", Append_false);
- VirtFs::mountDirSilent("../data/test", Append_false);
- setPathsDefaults(paths);
- branding.setValue("onlineServerFile", "test/serverlistplus.xml");
- mainGraphics = new SDLGraphics;
- imageHelper = new SDLImageHelper;
-
- Dirs::initRootDir();
- Dirs::initHomeDir();
-
- const std::string cfgName = settings.configDir +
- "/nonexistserver/config.xml";
- ::remove(cfgName.c_str());
-
- ConfigManager::initConfiguration();
- setConfigDefaults2(config);
- setBrandingDefaults(branding);
- ConfigManager::initServerConfig("nonexistserver");
-
-#ifdef USE_SDL2
- SDLImageHelper::setRenderer(graphicsManager.createRenderer(
- graphicsManager.createWindow(640, 480, 0,
- SDL_WINDOW_SHOWN | SDL_SWSURFACE), SDL_RENDERER_SOFTWARE));
-#else // USE_SDL2
-
- graphicsManager.createWindow(640, 480, 0, SDL_ANYFORMAT | SDL_SWSURFACE);
-#endif // USE_SDL2
-
- config.setValue("fontSize", 16);
-
- theme = new Theme;
- Theme::selectSkin();
-
- localPlayer = new LocalPlayer(static_cast<BeingId>(1),
- BeingTypeId_zero);
-
- ActorSprite::load();
- gui = new Gui();
- gui->postInit(mainGraphics);
- touchManager.init();
- UnitsDb::load();
- charServerHandler = new EAthena::CharServerHandler;
- serverFeatures = new EAthena::ServerFeatures;
- inventoryHandler = new EAthena::InventoryHandler;
- playerHandler = new EAthena::PlayerHandler;
- paths.setValue("itemIcons", "");
-
- TranslationManager::init();
-
- mainGraphics->setVideoMode(640, 480,
- 1,
- 8,
- false,
- false,
- false,
- false,
- false);
-
- SECTION("create windows")
- {
- WindowManager::createWindows();
- WindowManager::deleteWindows();
- }
-
- SECTION("init")
- {
- WindowManager::init();
- }
-
- SECTION("initTitle")
- {
- WindowManager::initTitle();
- REQUIRE(settings.windowCaption == strprintf("%s %s",
- branding.getStringValue("appName").c_str(),
- SMALL_VERSION));
- }
-
- SECTION("updateTitle1")
- {
- settings.serverName = std::string();
- settings.login = std::string();
- WindowManager::updateTitle();
- REQUIRE(settings.windowCaption == strprintf("%s %s",
- branding.getStringValue("appName").c_str(),
- SMALL_VERSION));
- }
-
- SECTION("updateTitle2")
- {
- settings.serverName = "server";
- settings.login = std::string();
- WindowManager::updateTitle();
- REQUIRE(settings.windowCaption == strprintf("%s %s - %s",
- branding.getStringValue("appName").c_str(),
- SMALL_VERSION,
- settings.serverName.c_str()));
- }
-
- SECTION("updateTitle3")
- {
- settings.serverName = "server";
- settings.login = "login";
- WindowManager::updateTitle();
- REQUIRE(settings.windowCaption == strprintf("%s %s - %s %s",
- branding.getStringValue("appName").c_str(),
- SMALL_VERSION,
- settings.login.c_str(),
- settings.serverName.c_str()));
- }
-
- SECTION("setFramerate1")
- {
- settings.limitFps = true;
- WindowManager::setFramerate(60);
- REQUIRE(WindowManager::getFramerate() == 60);
- WindowManager::setFramerate(10);
- REQUIRE(WindowManager::getFramerate() == 10);
- WindowManager::setFramerate(0);
- REQUIRE(WindowManager::getFramerate() == 10);
- }
-
- SECTION("setFramerate2")
- {
- settings.limitFps = false;
- WindowManager::setFramerate(60);
- REQUIRE(WindowManager::getFramerate() == 0);
- WindowManager::setFramerate(10);
- REQUIRE(WindowManager::getFramerate() == 0);
- WindowManager::setFramerate(0);
- REQUIRE(WindowManager::getFramerate() == 0);
- }
-
- settings.serverName = std::string();
- settings.login = std::string();
- settings.limitFps = true;
-
- UnitsDb::unload();
- delete2(localPlayer);
- delete2(client);
- delete2(serverFeatures);
- delete2(inventoryHandler);
- delete2(charServerHandler);
- delete2(playerHandler);
- delete2(gui);
- ResourceManager::deleteInstance();
- VirtFs::unmountDirSilent("data");
- VirtFs::unmountDirSilent("../data");
- VirtFs::unmountDirSilent("data/test");
- VirtFs::unmountDirSilent("../data/test");
-}
diff --git a/src/unittests/integrity.cc b/src/unittests/integrity.cc
deleted file mode 100644
index 3cb4f3dc5..000000000
--- a/src/unittests/integrity.cc
+++ /dev/null
@@ -1,360 +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 "unittests/unittests.h"
-
-#include "configmanager.h"
-#include "configuration.h"
-#include "client.h"
-#include "dirs.h"
-#include "graphicsmanager.h"
-
-#include "being/actorsprite.h"
-
-#include "fs/files.h"
-
-#include "fs/virtfs/fs.h"
-#include "fs/virtfs/rwops.h"
-
-#include "gui/userpalette.h"
-#include "gui/theme.h"
-
-#include "input/inputactionmap.h"
-
-#include "resources/image/image.h"
-
-#include "resources/loaders/imageloader.h"
-
-#include "resources/sdlimagehelper.h"
-#ifdef USE_SDL2
-#include "resources/surfaceimagehelper.h"
-#endif // USE_SDL2
-
-#include "resources/resourcemanager/resourcemanager.h"
-
-#include "utils/env.h"
-#include "utils/delete2.h"
-#include "utils/foreach.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_image.h>
-PRAGMA48(GCC diagnostic pop)
-
-#ifndef UNITTESTS_CATCH
-#include <algorithm>
-#endif // UNITTESTS_CATCH
-
-#include "debug.h"
-
-namespace
-{
- class InputActionSortFunctorTest final
- {
- public:
- bool operator() (const InputActionT key1,
- const InputActionT key2) const
- {
- REQUIRE(CAST_SIZE(key1) < CAST_SIZE(InputAction::TOTAL));
- REQUIRE(CAST_SIZE(key2) < CAST_SIZE(InputAction::TOTAL));
- REQUIRE(key1 < InputAction::TOTAL);
- REQUIRE(key2 < InputAction::TOTAL);
- return keys[CAST_SIZE(key1)].priority
- >= keys[CAST_SIZE(key2)].priority;
- }
-
- const InputActionData *keys A_NONNULLPOINTER;
- };
- InputActionSortFunctorTest inputActionDataSorterTest;
-} // namespace
-
-static bool compareBuffers(const unsigned char *const buf2)
-{
- bool isCorrect(true);
- int sz = 0;
- const unsigned char *buf1 = reinterpret_cast<const unsigned char*>(
- VirtFs::loadFile("hide.png", sz));
- REQUIRE(buf1 != nullptr);
- REQUIRE(sz == 368);
- for (int f = 0; f < sz; f ++)
- {
- if (buf1[f] != buf2[f])
- {
- isCorrect = false;
- logger->log("Wrong buffer chars: 0x%x vs 0x%x",
- buf1[f],
- buf2[f]);
- }
- }
- delete [] buf1;
- return isCorrect;
-}
-
-TEST_CASE("integrity tests", "integrity")
-{
- setEnv("SDL_VIDEODRIVER", "dummy");
-
- client = new Client;
- XML::initXML();
- SDL_Init(SDL_INIT_VIDEO);
- std::string name("data/test/test.zip");
- std::string prefix;
- if (Files::existsLocal(name) == false)
- prefix = "../" + prefix;
-
- VirtFs::mountDirSilent("data", Append_false);
- VirtFs::mountDirSilent("../data", Append_false);
-
- Dirs::initRootDir();
- Dirs::initHomeDir();
-
- setBrandingDefaults(branding);
- ConfigManager::initConfiguration();
-
-#ifdef USE_SDL2
- imageHelper = new SurfaceImageHelper;
-
- SDLImageHelper::setRenderer(graphicsManager.createRenderer(
- graphicsManager.createWindow(640, 480, 0,
- SDL_WINDOW_SHOWN | SDL_SWSURFACE), SDL_RENDERER_SOFTWARE));
-#else // USE_SDL2
-
- imageHelper = new SDLImageHelper();
-
- graphicsManager.createWindow(640, 480, 0, SDL_ANYFORMAT | SDL_SWSURFACE);
-#endif // USE_SDL2
-
- userPalette = new UserPalette;
-
- config.setValue("fontSize", 16);
- theme = new Theme;
- Theme::selectSkin();
-
- ActorSprite::load();
- const char *const name1 = "dir/hide.png";
- const int size1 = 368;
-
- SECTION("integrity test 1")
- {
- REQUIRE(sizeof(inputActionData) / sizeof(InputActionData) ==
- CAST_SIZE(InputAction::TOTAL));
- }
-
- SECTION("integrity test 2")
- {
- KeyToActionMap actionMap;
- const size_t sz = CAST_SIZE(InputAction::TOTAL);
- for (size_t i = 0; i < sz; i ++)
- {
- InputActionT val = static_cast<InputActionT>(i);
- REQUIRE(val < InputAction::TOTAL);
- REQUIRE(val > InputAction::NO_VALUE);
- REQUIRE(val > InputAction::UNDEFINED_VALUE);
- REQUIRE(CAST_SIZE(val) < CAST_SIZE(InputAction::TOTAL));
- REQUIRE(CAST_SIZE(val) < CAST_SIZE(InputAction::NO_VALUE));
- REQUIRE(CAST_SIZE(val) < CAST_SIZE(InputAction::UNDEFINED_VALUE));
- REQUIRE(CAST_S32(val) < CAST_S32(InputAction::TOTAL));
- REQUIRE(CAST_S32(val) > CAST_S32(InputAction::NO_VALUE));
- REQUIRE(CAST_S32(val) > CAST_S32(InputAction::UNDEFINED_VALUE));
- }
- }
-
- SECTION("integrity test 3")
- {
- KeyToActionMap actionMap;
- int cnt = 0;
- const size_t sz = CAST_SIZE(InputAction::TOTAL);
- for (size_t i = 0; i < sz; i ++)
- {
- actionMap[cnt++].push_back(static_cast<InputActionT>(i));
- if (cnt > 3)
- cnt = 0;
- }
- FOR_EACH (KeyToActionMapIter, it, actionMap)
- {
- KeysVector *const keys = &it->second;
- FOR_EACHP (KeysVectorIter, itk, keys)
- {
- const size_t val = CAST_SIZE(*itk);
- REQUIRE(val < sz);
- }
- }
- }
-
- SECTION("integrity test 4")
- {
- KeyToActionMap actionMap;
- KeyTimeMap keyTimeMap;
- actionMap.clear();
- keyTimeMap.clear();
-
- for (size_t i = 0; i < CAST_SIZE(InputAction::TOTAL); i ++)
- {
- actionMap[10].push_back(
- static_cast<InputActionT>(i));
- }
-
- KeysVector *const keys = &actionMap[0];
- inputActionDataSorterTest.keys = &inputActionData[0];
- std::sort(keys->begin(), keys->end(), inputActionDataSorterTest);
- }
-
- SECTION("integrity test 5")
- {
- KeyToActionMap mKeyToAction;
- KeyToIdMap mKeyToId;
- KeyTimeMap mKeyTimeMap;
- inputManager.updateKeyActionMap(mKeyToAction, mKeyToId,
- mKeyTimeMap, InputType::KEYBOARD);
- }
-
- SECTION("integrity Loader::getImage test 1")
- {
- Image *const image = Loader::getImage(
- "graphics/images/login_wallpaper.png");
- REQUIRE(image != nullptr);
- REQUIRE(image->getSDLSurface() != nullptr);
- image->decRef();
- }
-
- SECTION("integrity Loader::getImage test 2")
- {
- VirtFs::mountZip(prefix + "data/test/test.zip", Append_false);
- Image *const image = Loader::getImage(
- "dir/hide.png");
- VirtFs::unmountZip(prefix + "data/test/test.zip");
- REQUIRE(image != nullptr);
- REQUIRE(image->getSDLSurface() != nullptr);
- image->decRef();
- }
-
- SECTION("integrity Loader::getImage test 3")
- {
- VirtFs::mountZip(prefix + "data/test/test.zip", Append_false);
- Image *const image = Loader::getImage(
- "dir/brimmedhat.png");
- VirtFs::unmountZip(prefix + "data/test/test.zip");
- REQUIRE(image != nullptr);
- REQUIRE(image->getSDLSurface() != nullptr);
- image->decRef();
- }
-
- SECTION("integrity Loader::getImage test 4")
- {
- VirtFs::mountZip(prefix + "data/test/test.zip", Append_false);
-
- SDL_RWops *const rw = VirtFs::rwopsOpenRead(name1);
- REQUIRE(rw != nullptr);
- unsigned char buf[size1];
- const size_t sz = SDL_RWread(rw, buf, 1, size1);
- if (sz != size1)
- SDL_RWclose(rw);
- REQUIRE(sz == size1);
- SDL_RWclose(rw);
- VirtFs::unmountZip(prefix + "data/test/test.zip");
- VirtFs::mountDirSilent(prefix + "data/test", Append_true);
- REQUIRE(compareBuffers(buf));
- VirtFs::unmountDirSilent(prefix + "data/test");
- }
-
- SECTION("integrity Loader::getImage test 7")
- {
- VirtFs::mountZip(prefix + "data/test/test.zip", Append_false);
-
- SDL_RWops *const rw = VirtFs::rwopsOpenRead(name1);
- REQUIRE(rw != nullptr);
- int64_t seek = SDL_RWseek(rw, 0, RW_SEEK_END);
- if (seek == -1)
- SDL_RWclose(rw);
- REQUIRE(seek != -1);
- const int64_t pos = SDL_RWtell(rw);
- if (pos != size1)
- SDL_RWclose(rw);
- REQUIRE(pos == size1);
-
- seek = SDL_RWseek(rw, 0, RW_SEEK_SET);
- if (seek == -1)
- SDL_RWclose(rw);
- REQUIRE(seek != -1);
-
- unsigned char buf[size1];
- const size_t sz = SDL_RWread(rw, buf, 1, pos);
- if (sz != size1)
- SDL_RWclose(rw);
- REQUIRE(sz == size1);
-
- SDL_RWclose(rw);
- VirtFs::unmountZip(prefix + "data/test/test.zip");
- VirtFs::mountDirSilent("data/test", Append_true);
- VirtFs::mountDirSilent("../data/test", Append_true);
- REQUIRE(compareBuffers(buf));
- VirtFs::unmountDirSilent("data/test");
- VirtFs::unmountDirSilent("../data/test");
- }
-
- SECTION("integrity Loader::getImage test 8")
- {
- VirtFs::mountZip(prefix + "data/test/test.zip", Append_false);
-
- SDL_RWops *const rw = VirtFs::rwopsOpenRead(name1);
- REQUIRE(rw != nullptr);
- if (IMG_isPNG(rw) == 0)
- {
- SDL_RWclose(rw);
- REQUIRE(false);
- }
- SDL_Surface *const tmpImage = IMG_LoadPNG_RW(rw);
- SDL_RWclose(rw);
- VirtFs::unmountZip(prefix + "data/test/test.zip");
- REQUIRE(tmpImage != nullptr);
- SDL_FreeSurface(tmpImage);
- }
-
- SECTION("integrity Loader::getImage test 9")
- {
- VirtFs::mountZip(prefix + "data/test/test.zip", Append_false);
-
- SDL_RWops *const rw = VirtFs::rwopsOpenRead(name1);
- REQUIRE(rw != nullptr);
- Resource *const res = imageHelper->load(rw);
- VirtFs::unmountZip(prefix + "data/test/test.zip");
- REQUIRE(res != nullptr);
- delete res;
- }
-
- SECTION("integrity Loader::getImage test 10")
- {
- VirtFs::mountZip(prefix + "data/test/test.zip", Append_false);
- Image *const image = Loader::getImage(
- name1);
- VirtFs::unmountZip(prefix + "data/test/test.zip");
- REQUIRE(image != nullptr);
- REQUIRE(image->getSDLSurface() != nullptr);
- image->decRef();
- }
-
- ResourceManager::cleanOrphans(true);
-
- delete2(userPalette);
- delete2(client);
-
- VirtFs::unmountDirSilent("data");
- VirtFs::unmountDirSilent("../data");
-}
diff --git a/src/unittests/render/mockdrawitem.h b/src/unittests/render/mockdrawitem.h
deleted file mode 100644
index 75951123e..000000000
--- a/src/unittests/render/mockdrawitem.h
+++ /dev/null
@@ -1,60 +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 RENDER_MOCKDRAWITEM_H
-#define RENDER_MOCKDRAWITEM_H
-
-#ifdef UNITTESTS
-
-#include "unittests/enums/render/mockdrawtype.h"
-
-#include "localconsts.h"
-
-class Image;
-
-struct MockDrawItem final
-{
- MockDrawItem(const MockDrawTypeT type,
- const Image *const image0,
- const int x0,
- const int y0,
- const int width0,
- const int height0) :
- image(image0),
- drawType(type),
- x(x0),
- y(y0),
- width(width0),
- height(height0)
- {
- }
-
- A_DEFAULT_COPY(MockDrawItem)
-
- const Image *image;
- MockDrawTypeT drawType;
- int x;
- int y;
- int width;
- int height;
-};
-
-#endif // UNITTESTS
-#endif // RENDER_MOCKDRAWITEM_H
diff --git a/src/unittests/render/mockgraphics.cc b/src/unittests/render/mockgraphics.cc
deleted file mode 100644
index 29aa19af6..000000000
--- a/src/unittests/render/mockgraphics.cc
+++ /dev/null
@@ -1,302 +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 "unittests/render/mockgraphics.h"
-
-#include "graphicsmanager.h"
-
-#include "utils/sdlcheckutils.h"
-
-#include "render/vertexes/imagecollection.h"
-
-#include "debug.h"
-
-MockGraphics::MockGraphics() :
- Graphics()
-{
- mOpenGL = RENDER_SOFTWARE;
- mName = "Software";
-}
-
-MockGraphics::~MockGraphics()
-{
-}
-
-void MockGraphics::drawRescaledImage(const Image *restrict const image
- A_UNUSED,
- int dstX A_UNUSED,
- int dstY A_UNUSED,
- const int desiredWidth A_UNUSED,
- const int desiredHeight A_UNUSED)
- restrict2
-{
-}
-
-void MockGraphics::drawImage(const Image *restrict const image,
- int dstX,
- int dstY) restrict2
-{
- mDraws.push_back(MockDrawItem(MockDrawType::DrawImage,
- image,
- dstX,
- dstY,
- 0,
- 0));
-}
-
-void MockGraphics::drawImageInline(const Image *restrict const image A_UNUSED,
- int dstX A_UNUSED,
- int dstY A_UNUSED) restrict2
-{
-}
-
-void MockGraphics::copyImage(const Image *restrict const image A_UNUSED,
- int dstX A_UNUSED,
- int dstY A_UNUSED) restrict2
-{
-}
-
-void MockGraphics::drawImageCached(const Image *restrict const image A_UNUSED,
- int x A_UNUSED,
- int y A_UNUSED) restrict2
-{
-}
-
-void MockGraphics::drawPatternCached(const Image *restrict const image
- A_UNUSED,
- const int x A_UNUSED,
- const int y A_UNUSED,
- const int w A_UNUSED,
- const int h A_UNUSED) restrict2
-{
-}
-
-void MockGraphics::completeCache() restrict2
-{
-}
-
-void MockGraphics::drawPattern(const Image *restrict const image,
- const int x,
- const int y,
- const int w,
- const int h) restrict2
-{
- mDraws.push_back(MockDrawItem(MockDrawType::DrawPattern,
- image,
- x,
- y,
- w,
- h));
-}
-
-void MockGraphics::drawPatternInline(const Image *restrict const image
- A_UNUSED,
- const int x A_UNUSED,
- const int y A_UNUSED,
- const int w A_UNUSED,
- const int h A_UNUSED) restrict2
-{
-}
-
-void MockGraphics::drawRescaledPattern(const Image *restrict const image
- A_UNUSED,
- const int x A_UNUSED,
- const int y A_UNUSED,
- const int w A_UNUSED,
- const int h A_UNUSED,
- const int scaledWidth A_UNUSED,
- const int scaledHeight A_UNUSED)
- restrict2
-{
-}
-
-void MockGraphics::calcPattern(ImageVertexes *restrict const vert A_UNUSED,
- const Image *restrict const image A_UNUSED,
- const int x A_UNUSED,
- const int y A_UNUSED,
- const int w A_UNUSED,
- const int h A_UNUSED) const restrict2
-{
-}
-
-void MockGraphics::calcPatternInline(ImageVertexes *restrict const vert
- A_UNUSED,
- const Image *restrict const image
- A_UNUSED,
- const int x A_UNUSED,
- const int y A_UNUSED,
- const int w A_UNUSED,
- const int h A_UNUSED) const restrict2
-{
-}
-
-void MockGraphics::calcPattern(ImageCollection *restrict const vertCol
- A_UNUSED,
- const Image *restrict const image A_UNUSED,
- const int x A_UNUSED,
- const int y A_UNUSED,
- const int w A_UNUSED,
- const int h A_UNUSED) const restrict2
-{
-}
-
-void MockGraphics::calcTileVertexes(ImageVertexes *restrict const vert,
- const Image *restrict const image,
- int x, int y) const restrict2
-{
- vert->image = image;
- calcTileSDL(vert, x, y);
-}
-
-void MockGraphics::calcTileVertexesInline(ImageVertexes *restrict const vert
- A_UNUSED,
- const Image *restrict const image
- A_UNUSED,
- int x A_UNUSED,
- int y A_UNUSED) const restrict2
-{
-}
-
-void MockGraphics::calcTileSDL(ImageVertexes *restrict const vert A_UNUSED,
- int x A_UNUSED,
- int y A_UNUSED) const restrict2
-{
-}
-
-void MockGraphics::calcTileCollection(ImageCollection *restrict const vertCol
- A_UNUSED,
- const Image *restrict const image
- A_UNUSED,
- int x A_UNUSED,
- int y A_UNUSED) restrict2
-{
-}
-
-void MockGraphics::drawTileCollection(const ImageCollection *restrict const
- vertCol A_UNUSED) restrict2
-{
-}
-
-void MockGraphics::drawTileVertexes(const ImageVertexes *restrict const
- vert A_UNUSED) restrict2
-{
-}
-
-void MockGraphics::updateScreen() restrict2
-{
-}
-
-void MockGraphics::calcWindow(ImageCollection *restrict const vertCol A_UNUSED,
- const int x A_UNUSED,
- const int y A_UNUSED,
- const int w A_UNUSED,
- const int h A_UNUSED,
- const ImageRect &restrict imgRect A_UNUSED)
- restrict2
-{
-}
-
-void MockGraphics::fillRectangle(const Rect &restrict rectangle A_UNUSED)
- restrict2
-{
-}
-
-void MockGraphics::beginDraw() restrict2
-{
- pushClipArea(Rect(0, 0, mRect.w, mRect.h));
-}
-
-void MockGraphics::endDraw() restrict2
-{
- popClipArea();
-}
-
-void MockGraphics::pushClipArea(const Rect &restrict area) restrict2
-{
- Graphics::pushClipArea(area);
-}
-
-void MockGraphics::popClipArea() restrict2
-{
- Graphics::popClipArea();
-}
-
-void MockGraphics::drawPoint(int x A_UNUSED,
- int y A_UNUSED) restrict2
-{
-}
-
-void MockGraphics::drawRectangle(const Rect &restrict rectangle A_UNUSED)
- restrict2
-{
-}
-
-void MockGraphics::drawLine(int x1 A_UNUSED,
- int y1 A_UNUSED,
- int x2 A_UNUSED,
- int y2 A_UNUSED) restrict2
-{
-}
-
-bool MockGraphics::setVideoMode(const int w, const int h,
- const int scale,
- const int bpp,
- const bool fs,
- const bool hwaccel,
- const bool resize,
- const bool noFrame,
- const bool allowHighDPI) restrict2
-{
- setMainFlags(w, h, scale, bpp, fs, hwaccel, resize, noFrame, allowHighDPI);
-
- if ((mWindow = graphicsManager.createWindow(w, h, bpp,
- getSoftwareFlags())) == nullptr)
- {
- mRect.w = 0;
- mRect.h = 0;
- return false;
- }
-
- mRect.w = CAST_U16(mRect.w);
- mRect.h = CAST_U16(mRect.h);
-
- return videoInfo();
-}
-
-void MockGraphics::drawImageRect(const int x A_UNUSED,
- const int y A_UNUSED,
- const int w A_UNUSED,
- const int h A_UNUSED,
- const ImageRect &restrict imgRect A_UNUSED)
- restrict2
-{
-}
-
-void MockGraphics::calcImageRect(ImageVertexes *restrict const vert A_UNUSED,
- const int x A_UNUSED,
- const int y A_UNUSED,
- const int w A_UNUSED,
- const int h A_UNUSED,
- const ImageRect &restrict imgRect A_UNUSED)
- restrict2
-{
-}
diff --git a/src/unittests/render/mockgraphics.h b/src/unittests/render/mockgraphics.h
deleted file mode 100644
index e144cef02..000000000
--- a/src/unittests/render/mockgraphics.h
+++ /dev/null
@@ -1,55 +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 RENDER_MOCKGRAPHICS_H
-#define RENDER_MOCKGRAPHICS_H
-
-#ifdef UNITTESTS
-
-#include "render/graphics.h"
-
-#include "unittests/render/mockdrawitem.h"
-
-#include "utils/vector.h"
-
-#include "localconsts.h"
-
-class MockGraphics final : public Graphics
-{
- public:
- MockGraphics();
-
- A_DELETE_COPY(MockGraphics)
-
- ~MockGraphics();
-
- #include "render/graphicsdef.hpp"
- RENDER_GRAPHICSDEF_HPP
-
- #include "render/softwaregraphicsdef.hpp"
- RENDER_SOFTWAREGRAPHICSDEF_HPP
-
- STD_VECTOR<MockDrawItem> mDraws;
-};
-
-#endif // UNITTESTS
-#endif // RENDER_MOCKGRAPHICS_H
diff --git a/src/unittests/resources/dye/dye.cc b/src/unittests/resources/dye/dye.cc
deleted file mode 100644
index a0294a84f..000000000
--- a/src/unittests/resources/dye/dye.cc
+++ /dev/null
@@ -1,2014 +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 "unittests/unittests.h"
-
-#include "client.h"
-#include "configmanager.h"
-#include "configuration.h"
-#include "dirs.h"
-#include "graphicsmanager.h"
-
-#include "being/actorsprite.h"
-
-#include "fs/virtfs/fs.h"
-
-#include "gui/userpalette.h"
-#include "gui/theme.h"
-
-#include "resources/sdlimagehelper.h"
-#ifdef USE_SDL2
-#include "resources/surfaceimagehelper.h"
-#endif // USE_SDL2
-
-#include "resources/dye/dye.h"
-#include "resources/dye/dyepalette.h"
-
-#include "resources/image/image.h"
-
-#include "resources/loaders/imageloader.h"
-
-#include "utils/delete2.h"
-#include "utils/env.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#ifndef USE_SDL2
-#include <SDL.h>
-#endif // USE_SDL2
-PRAGMA48(GCC diagnostic pop)
-
-#include "debug.h"
-
-#ifdef USE_OPENGL
-
-TEST_CASE("Dye replaceSOGLColor 1 1", "")
-{
- DyePalette palette("#00ff00,000011", 6);
- uint32_t data[1];
- data[0] = buildHex(0x01, 0x02, 0x03, 0x10);
- DYEPALETTE(palette, SOGLColor)(&data[0], 1);
- REQUIRE(data[0] == buildHex(0x01, 0x02, 0x03, 0x10));
-}
-
-TEST_CASE("Dye replaceSOGLColor 1 2", "")
-{
- DyePalette palette("#01ff02,030411", 6);
- uint32_t data[1];
- data[0] = buildHex(0x20, 0x02, 0xff, 0x01);
- DYEPALETTE(palette, SOGLColor)(&data[0], 1);
- REQUIRE(data[0] == buildHex(0x20, 0x11, 0x04, 0x03));
-}
-
-TEST_CASE("Dye replaceSOGLColor 1 3", "")
-{
- DyePalette palette("#404040,200000,0100ee,102030", 6);
- uint32_t data[1];
- data[0] = buildHex(0x40, 0xee, 0x00, 0x01);
- DYEPALETTE(palette, SOGLColor)(&data[0], 1);
- REQUIRE(data[0] == buildHex(0x40, 0x30, 0x20, 0x10));
-}
-
-TEST_CASE("Dye replaceSOGLColor 2 1", "")
-{
- DyePalette palette("#01ff02,030411", 6);
- uint32_t data[2];
- data[0] = buildHex(0x20, 0x02, 0xff, 0x01);
- data[1] = buildHex(0x30, 0x02, 0xff, 0x01);
- DYEPALETTE(palette, SOGLColor)(&data[0], 2);
- REQUIRE(data[0] == buildHex(0x20, 0x11, 0x04, 0x03));
- REQUIRE(data[1] == buildHex(0x30, 0x11, 0x04, 0x03));
-}
-
-TEST_CASE("Dye replaceSOGLColor 4 1", "")
-{
- DyePalette palette("#01ff02,030411", 6);
- uint32_t data[4];
- data[0] = buildHex(0x20, 0x02, 0xff, 0x01);
- data[1] = buildHex(0x30, 0x02, 0xff, 0x01);
- data[2] = buildHex(0x40, 0x02, 0xff, 0x01);
- data[3] = buildHex(0x50, 0x02, 0xff, 0x02);
- DYEPALETTE(palette, SOGLColor)(&data[0], 4);
- REQUIRE(data[0] == buildHex(0x20, 0x11, 0x04, 0x03));
- REQUIRE(data[1] == buildHex(0x30, 0x11, 0x04, 0x03));
- REQUIRE(data[2] == buildHex(0x40, 0x11, 0x04, 0x03));
- REQUIRE(data[3] == buildHex(0x50, 0x02, 0xff, 0x02));
-}
-
-TEST_CASE("Dye replaceSOGLColor 8 1", "")
-{
- DyePalette palette("#01ff02,030411,01ee02,010203", 6);
- uint32_t data[8];
- data[0] = buildHex(0x20, 0x02, 0xff, 0x01);
- data[1] = buildHex(0x30, 0x02, 0xff, 0x01);
- data[2] = buildHex(0x40, 0x02, 0xff, 0x01);
- data[3] = buildHex(0x50, 0x02, 0xff, 0x02);
- data[4] = buildHex(0x20, 0x02, 0xff, 0x01);
- data[5] = buildHex(0x30, 0x02, 0xff, 0x01);
- data[6] = buildHex(0x40, 0x02, 0xff, 0x01);
- data[7] = buildHex(0x60, 0x02, 0xff, 0x02);
- DYEPALETTE(palette, SOGLColor)(&data[0], 8);
- REQUIRE(data[0] == buildHex(0x20, 0x11, 0x04, 0x03));
- REQUIRE(data[1] == buildHex(0x30, 0x11, 0x04, 0x03));
- REQUIRE(data[2] == buildHex(0x40, 0x11, 0x04, 0x03));
- REQUIRE(data[3] == buildHex(0x50, 0x02, 0xff, 0x02));
- REQUIRE(data[4] == buildHex(0x20, 0x11, 0x04, 0x03));
- REQUIRE(data[5] == buildHex(0x30, 0x11, 0x04, 0x03));
- REQUIRE(data[6] == buildHex(0x40, 0x11, 0x04, 0x03));
- REQUIRE(data[7] == buildHex(0x60, 0x02, 0xff, 0x02));
-}
-
-TEST_CASE("Dye replaceSOGLColor 1 1 default", "")
-{
- DyePalette palette("#00ff00,000011", 6);
- uint32_t data[1];
- data[0] = buildHex(0x01, 0x02, 0x03, 0x10);
- palette.replaceSOGLColorDefault(&data[0], 1);
- REQUIRE(data[0] == buildHex(0x01, 0x02, 0x03, 0x10));
-}
-
-TEST_CASE("Dye replaceSOGLColor 1 2 default", "")
-{
- DyePalette palette("#01ff02,030411", 6);
- uint32_t data[1];
- data[0] = buildHex(0x20, 0x02, 0xff, 0x01);
- palette.replaceSOGLColorDefault(&data[0], 1);
- REQUIRE(data[0] == buildHex(0x20, 0x11, 0x04, 0x03));
-}
-
-TEST_CASE("Dye replaceSOGLColor 1 3 default", "")
-{
- DyePalette palette("#404040,200000,0100ee,102030", 6);
- uint32_t data[1];
- data[0] = buildHex(0x40, 0xee, 0x00, 0x01);
- palette.replaceSOGLColorDefault(&data[0], 1);
- REQUIRE(data[0] == buildHex(0x40, 0x30, 0x20, 0x10));
-}
-
-TEST_CASE("Dye replaceSOGLColor 2 1 default", "")
-{
- DyePalette palette("#01ff02,030411", 6);
- uint32_t data[2];
- data[0] = buildHex(0x20, 0x02, 0xff, 0x01);
- data[1] = buildHex(0x30, 0x02, 0xff, 0x01);
- palette.replaceSOGLColorDefault(&data[0], 2);
- REQUIRE(data[0] == buildHex(0x20, 0x11, 0x04, 0x03));
- REQUIRE(data[1] == buildHex(0x30, 0x11, 0x04, 0x03));
-}
-
-TEST_CASE("Dye replaceSOGLColor 4 1 default", "")
-{
- DyePalette palette("#01ff02,030411", 6);
- uint32_t data[4];
- data[0] = buildHex(0x20, 0x02, 0xff, 0x01);
- data[1] = buildHex(0x30, 0x02, 0xff, 0x01);
- data[2] = buildHex(0x40, 0x02, 0xff, 0x01);
- data[3] = buildHex(0x50, 0x02, 0xff, 0x02);
- palette.replaceSOGLColorDefault(&data[0], 4);
- REQUIRE(data[0] == buildHex(0x20, 0x11, 0x04, 0x03));
- REQUIRE(data[1] == buildHex(0x30, 0x11, 0x04, 0x03));
- REQUIRE(data[2] == buildHex(0x40, 0x11, 0x04, 0x03));
- REQUIRE(data[3] == buildHex(0x50, 0x02, 0xff, 0x02));
-}
-
-TEST_CASE("Dye replaceSOGLColor 8 1 default", "")
-{
- DyePalette palette("#01ff02,030411,01ee02,010203", 6);
- uint32_t data[8];
- data[0] = buildHex(0x20, 0x02, 0xff, 0x01);
- data[1] = buildHex(0x30, 0x02, 0xff, 0x01);
- data[2] = buildHex(0x40, 0x02, 0xff, 0x01);
- data[3] = buildHex(0x50, 0x02, 0xff, 0x02);
- data[4] = buildHex(0x20, 0x02, 0xff, 0x01);
- data[5] = buildHex(0x30, 0x02, 0xff, 0x01);
- data[6] = buildHex(0x40, 0x02, 0xff, 0x01);
- data[7] = buildHex(0x60, 0x02, 0xff, 0x02);
- palette.replaceSOGLColorDefault(&data[0], 8);
- REQUIRE(data[0] == buildHex(0x20, 0x11, 0x04, 0x03));
- REQUIRE(data[1] == buildHex(0x30, 0x11, 0x04, 0x03));
- REQUIRE(data[2] == buildHex(0x40, 0x11, 0x04, 0x03));
- REQUIRE(data[3] == buildHex(0x50, 0x02, 0xff, 0x02));
- REQUIRE(data[4] == buildHex(0x20, 0x11, 0x04, 0x03));
- REQUIRE(data[5] == buildHex(0x30, 0x11, 0x04, 0x03));
- REQUIRE(data[6] == buildHex(0x40, 0x11, 0x04, 0x03));
- REQUIRE(data[7] == buildHex(0x60, 0x02, 0xff, 0x02));
-}
-
-TEST_CASE("Dye replaceSOGLColor 8 1 sse2", "")
-{
- DyePalette palette("#01ff02,030411,01ee02,010203", 6);
- uint32_t data[8];
- data[0] = buildHex(0x20, 0x02, 0xff, 0x01);
- data[1] = buildHex(0x30, 0x02, 0xff, 0x01);
- data[2] = buildHex(0x40, 0x02, 0xff, 0x01);
- data[3] = buildHex(0x50, 0x02, 0xff, 0x02);
- data[4] = buildHex(0x20, 0x02, 0xff, 0x01);
- data[5] = buildHex(0x30, 0x02, 0xff, 0x01);
- data[6] = buildHex(0x40, 0x02, 0xff, 0x01);
- data[7] = buildHex(0x60, 0x02, 0xff, 0x02);
- DYEPALETTE(palette, SOGLColorSse2)(&data[0], 8);
- REQUIRE(data[0] == buildHex(0x20, 0x11, 0x04, 0x03));
- REQUIRE(data[1] == buildHex(0x30, 0x11, 0x04, 0x03));
- REQUIRE(data[2] == buildHex(0x40, 0x11, 0x04, 0x03));
- REQUIRE(data[3] == buildHex(0x50, 0x02, 0xff, 0x02));
- REQUIRE(data[4] == buildHex(0x20, 0x11, 0x04, 0x03));
- REQUIRE(data[5] == buildHex(0x30, 0x11, 0x04, 0x03));
- REQUIRE(data[6] == buildHex(0x40, 0x11, 0x04, 0x03));
- REQUIRE(data[7] == buildHex(0x60, 0x02, 0xff, 0x02));
-}
-
-TEST_CASE("Dye replaceSOGLColor 8 1 avx2", "")
-{
- DyePalette palette("#01ff02,030411,01ee02,010203", 6);
- uint32_t data[8];
- data[0] = buildHex(0x20, 0x02, 0xff, 0x01);
- data[1] = buildHex(0x30, 0x02, 0xff, 0x01);
- data[2] = buildHex(0x40, 0x02, 0xff, 0x01);
- data[3] = buildHex(0x50, 0x02, 0xff, 0x02);
- data[4] = buildHex(0x20, 0x02, 0xff, 0x01);
- data[5] = buildHex(0x30, 0x02, 0xff, 0x01);
- data[6] = buildHex(0x40, 0x02, 0xff, 0x01);
- data[7] = buildHex(0x60, 0x02, 0xff, 0x02);
- DYEPALETTE(palette, SOGLColorAvx2)(&data[0], 8);
- REQUIRE(data[0] == buildHex(0x20, 0x11, 0x04, 0x03));
- REQUIRE(data[1] == buildHex(0x30, 0x11, 0x04, 0x03));
- REQUIRE(data[2] == buildHex(0x40, 0x11, 0x04, 0x03));
- REQUIRE(data[3] == buildHex(0x50, 0x02, 0xff, 0x02));
- REQUIRE(data[4] == buildHex(0x20, 0x11, 0x04, 0x03));
- REQUIRE(data[5] == buildHex(0x30, 0x11, 0x04, 0x03));
- REQUIRE(data[6] == buildHex(0x40, 0x11, 0x04, 0x03));
- REQUIRE(data[7] == buildHex(0x60, 0x02, 0xff, 0x02));
-}
-
-
-TEST_CASE("Dye replaceAOGLColor 1 1", "")
-{
- DyePalette palette("#00ff0010,00001120", 8);
- uint32_t data[1];
- data[0] = buildHex(0x10, 0x03, 0x02, 0x01);
- DYEPALETTE(palette, AOGLColor)(&data[0], 1);
- REQUIRE(data[0] == buildHex(0x10, 0x03, 0x02, 0x01));
-}
-
-TEST_CASE("Dye replaceAOGLColor 1 2", "")
-{
- DyePalette palette("#00ff0120,020311ff", 8);
- uint32_t data[1];
- data[0] = buildHex(0x20, 0x01, 0xff, 0x00);
- DYEPALETTE(palette, AOGLColor)(&data[0], 1);
- REQUIRE(data[0] == buildHex(0xff, 0x11, 0x03, 0x02));
-}
-
-TEST_CASE("Dye replaceAOGLColor 1 3", "")
-{
- DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
- uint32_t data[1];
- data[0] = buildHex(0x40, 0xee, 0x00, 0x01);
- DYEPALETTE(palette, AOGLColor)(&data[0], 1);
- REQUIRE(data[0] == buildHex(0xff, 0x30, 0x20, 0x10));
-}
-
-TEST_CASE("Dye replaceAOGLColor 2 1", "")
-{
- DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
- uint32_t data[2];
- data[0] = buildHex(0x40, 0xee, 0x00, 0x01);
- data[1] = buildHex(0x40, 0xee, 0x00, 0x01);
- DYEPALETTE(palette, AOGLColor)(&data[0], 2);
- REQUIRE(data[0] == buildHex(0xff, 0x30, 0x20, 0x10));
- REQUIRE(data[1] == buildHex(0xff, 0x30, 0x20, 0x10));
-}
-
-TEST_CASE("Dye replaceAOGLColor 4 1", "")
-{
- DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
- uint32_t data[4];
- data[0] = buildHex(0x40, 0xee, 0x00, 0x01);
- data[1] = buildHex(0x40, 0xee, 0x00, 0x01);
- data[2] = buildHex(0x41, 0xee, 0x00, 0x01);
- data[3] = buildHex(0x40, 0xee, 0x00, 0x01);
- DYEPALETTE(palette, AOGLColor)(&data[0], 4);
- REQUIRE(data[0] == buildHex(0xff, 0x30, 0x20, 0x10));
- REQUIRE(data[1] == buildHex(0xff, 0x30, 0x20, 0x10));
- REQUIRE(data[2] == buildHex(0x41, 0xee, 0x00, 0x01));
- REQUIRE(data[3] == buildHex(0xff, 0x30, 0x20, 0x10));
-}
-
-TEST_CASE("Dye replaceAOGLColor 8 1", "")
-{
- DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
- uint32_t data[8];
- data[0] = buildHex(0x40, 0xee, 0x00, 0x01);
- data[1] = buildHex(0x40, 0xee, 0x00, 0x01);
- data[2] = buildHex(0x41, 0xee, 0x00, 0x01);
- data[3] = buildHex(0x40, 0xee, 0x00, 0x01);
- data[4] = buildHex(0x40, 0xee, 0x00, 0x01);
- data[5] = buildHex(0x40, 0x40, 0x40, 0x40);
- data[6] = buildHex(0x41, 0xe0, 0x00, 0x01);
- data[7] = buildHex(0x40, 0xee, 0x00, 0x01);
- DYEPALETTE(palette, AOGLColor)(&data[0], 8);
- REQUIRE(data[0] == buildHex(0xff, 0x30, 0x20, 0x10));
- REQUIRE(data[1] == buildHex(0xff, 0x30, 0x20, 0x10));
- REQUIRE(data[2] == buildHex(0x41, 0xee, 0x00, 0x01));
- REQUIRE(data[3] == buildHex(0xff, 0x30, 0x20, 0x10));
- REQUIRE(data[4] == buildHex(0xff, 0x30, 0x20, 0x10));
- REQUIRE(data[5] == buildHex(0x00, 0x00, 0x00, 0x20));
- REQUIRE(data[6] == buildHex(0x41, 0xe0, 0x00, 0x01));
- REQUIRE(data[7] == buildHex(0xff, 0x30, 0x20, 0x10));
-}
-
-TEST_CASE("Dye replaceAOGLColor 1 1 default", "")
-{
- DyePalette palette("#00ff0010,00001120", 8);
- uint32_t data[1];
- data[0] = buildHex(0x10, 0x03, 0x02, 0x01);
- palette.replaceAOGLColorDefault(&data[0], 1);
- REQUIRE(data[0] == buildHex(0x10, 0x03, 0x02, 0x01));
-}
-
-TEST_CASE("Dye replaceAOGLColor 1 2 default", "")
-{
- DyePalette palette("#00ff0120,020311ff", 8);
- uint32_t data[1];
- data[0] = buildHex(0x20, 0x01, 0xff, 0x00);
- palette.replaceAOGLColorDefault(&data[0], 1);
- REQUIRE(data[0] == buildHex(0xff, 0x11, 0x03, 0x02));
-}
-
-TEST_CASE("Dye replaceAOGLColor 1 3 default", "")
-{
- DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
- uint32_t data[1];
- data[0] = buildHex(0x40, 0xee, 0x00, 0x01);
- palette.replaceAOGLColorDefault(&data[0], 1);
- REQUIRE(data[0] == buildHex(0xff, 0x30, 0x20, 0x10));
-}
-
-TEST_CASE("Dye replaceAOGLColor 2 1 default", "")
-{
- DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
- uint32_t data[2];
- data[0] = buildHex(0x40, 0xee, 0x00, 0x01);
- data[1] = buildHex(0x40, 0xee, 0x00, 0x01);
- palette.replaceAOGLColorDefault(&data[0], 2);
- REQUIRE(data[0] == buildHex(0xff, 0x30, 0x20, 0x10));
- REQUIRE(data[1] == buildHex(0xff, 0x30, 0x20, 0x10));
-}
-
-TEST_CASE("Dye replaceAOGLColor 4 1 default", "")
-{
- DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
- uint32_t data[4];
- data[0] = buildHex(0x40, 0xee, 0x00, 0x01);
- data[1] = buildHex(0x40, 0xee, 0x00, 0x01);
- data[2] = buildHex(0x41, 0xee, 0x00, 0x01);
- data[3] = buildHex(0x40, 0xee, 0x00, 0x01);
- palette.replaceAOGLColorDefault(&data[0], 4);
- REQUIRE(data[0] == buildHex(0xff, 0x30, 0x20, 0x10));
- REQUIRE(data[1] == buildHex(0xff, 0x30, 0x20, 0x10));
- REQUIRE(data[2] == buildHex(0x41, 0xee, 0x00, 0x01));
- REQUIRE(data[3] == buildHex(0xff, 0x30, 0x20, 0x10));
-}
-
-TEST_CASE("Dye replaceAOGLColor 8 1 default", "")
-{
- DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
- uint32_t data[8];
- data[0] = buildHex(0x40, 0xee, 0x00, 0x01);
- data[1] = buildHex(0x40, 0xee, 0x00, 0x01);
- data[2] = buildHex(0x41, 0xee, 0x00, 0x01);
- data[3] = buildHex(0x40, 0xee, 0x00, 0x01);
- data[4] = buildHex(0x40, 0xee, 0x00, 0x01);
- data[5] = buildHex(0x40, 0x40, 0x40, 0x40);
- data[6] = buildHex(0x41, 0xe0, 0x00, 0x01);
- data[7] = buildHex(0x40, 0xee, 0x00, 0x01);
- palette.replaceAOGLColorDefault(&data[0], 8);
- REQUIRE(data[0] == buildHex(0xff, 0x30, 0x20, 0x10));
- REQUIRE(data[1] == buildHex(0xff, 0x30, 0x20, 0x10));
- REQUIRE(data[2] == buildHex(0x41, 0xee, 0x00, 0x01));
- REQUIRE(data[3] == buildHex(0xff, 0x30, 0x20, 0x10));
- REQUIRE(data[4] == buildHex(0xff, 0x30, 0x20, 0x10));
- REQUIRE(data[5] == buildHex(0x00, 0x00, 0x00, 0x20));
- REQUIRE(data[6] == buildHex(0x41, 0xe0, 0x00, 0x01));
- REQUIRE(data[7] == buildHex(0xff, 0x30, 0x20, 0x10));
-}
-
-TEST_CASE("Dye replaceAOGLColor 8 1 sse2", "")
-{
- DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
- uint32_t data[8];
- data[0] = buildHex(0x40, 0xee, 0x00, 0x01);
- data[1] = buildHex(0x40, 0xee, 0x00, 0x01);
- data[2] = buildHex(0x41, 0xee, 0x00, 0x01);
- data[3] = buildHex(0x40, 0xee, 0x00, 0x01);
- data[4] = buildHex(0x40, 0xee, 0x00, 0x01);
- data[5] = buildHex(0x40, 0x40, 0x40, 0x40);
- data[6] = buildHex(0x41, 0xe0, 0x00, 0x01);
- data[7] = buildHex(0x40, 0xee, 0x00, 0x01);
- DYEPALETTE(palette, AOGLColorSse2)(&data[0], 8);
- REQUIRE(data[0] == buildHex(0xff, 0x30, 0x20, 0x10));
- REQUIRE(data[1] == buildHex(0xff, 0x30, 0x20, 0x10));
- REQUIRE(data[2] == buildHex(0x41, 0xee, 0x00, 0x01));
- REQUIRE(data[3] == buildHex(0xff, 0x30, 0x20, 0x10));
- REQUIRE(data[4] == buildHex(0xff, 0x30, 0x20, 0x10));
- REQUIRE(data[5] == buildHex(0x00, 0x00, 0x00, 0x20));
- REQUIRE(data[6] == buildHex(0x41, 0xe0, 0x00, 0x01));
- REQUIRE(data[7] == buildHex(0xff, 0x30, 0x20, 0x10));
-}
-
-TEST_CASE("Dye replaceAOGLColor 8 1 avx2", "")
-{
- DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
- uint32_t data[8];
- data[0] = buildHex(0x40, 0xee, 0x00, 0x01);
- data[1] = buildHex(0x40, 0xee, 0x00, 0x01);
- data[2] = buildHex(0x41, 0xee, 0x00, 0x01);
- data[3] = buildHex(0x40, 0xee, 0x00, 0x01);
- data[4] = buildHex(0x40, 0xee, 0x00, 0x01);
- data[5] = buildHex(0x40, 0x40, 0x40, 0x40);
- data[6] = buildHex(0x41, 0xe0, 0x00, 0x01);
- data[7] = buildHex(0x40, 0xee, 0x00, 0x01);
- DYEPALETTE(palette, AOGLColorAvx2)(&data[0], 8);
- REQUIRE(data[0] == buildHex(0xff, 0x30, 0x20, 0x10));
- REQUIRE(data[1] == buildHex(0xff, 0x30, 0x20, 0x10));
- REQUIRE(data[2] == buildHex(0x41, 0xee, 0x00, 0x01));
- REQUIRE(data[3] == buildHex(0xff, 0x30, 0x20, 0x10));
- REQUIRE(data[4] == buildHex(0xff, 0x30, 0x20, 0x10));
- REQUIRE(data[5] == buildHex(0x00, 0x00, 0x00, 0x20));
- REQUIRE(data[6] == buildHex(0x41, 0xe0, 0x00, 0x01));
- REQUIRE(data[7] == buildHex(0xff, 0x30, 0x20, 0x10));
-}
-#endif // USE_OPENGL
-
-
-TEST_CASE("Dye replaceSColor 1 1", "")
-{
- DyePalette palette("#00ff00,000011", 6);
- uint32_t data[1];
- data[0] = buildHex(0x10, 0x03, 0x02, 0x01);
- DYEPALETTE(palette, SColor)(&data[0], 1);
- REQUIRE(data[0] == buildHex(0x10, 0x03, 0x02, 0x01));
-}
-
-TEST_CASE("Dye replaceSColor 1 2", "")
-{
- DyePalette palette("#403020,706050", 6);
- uint32_t data[1];
- data[0] = buildHex(0x40, 0x30, 0x20, 0x10);
- DYEPALETTE(palette, SColor)(&data[0], 1);
- REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
-}
-
-TEST_CASE("Dye replaceSColor 1 3", "")
-{
- DyePalette palette("#123456,000000,ff3020,706050", 6);
- uint32_t data[1];
- data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
- DYEPALETTE(palette, SColor)(&data[0], 1);
- REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
-}
-
-TEST_CASE("Dye replaceSColor 2 1", "")
-{
- DyePalette palette("#123456,000000,ff3020,706050", 6);
- uint32_t data[2];
- data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
- data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
- DYEPALETTE(palette, SColor)(&data[0], 2);
- REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
- REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
-}
-
-TEST_CASE("Dye replaceSColor 3 1", "")
-{
- DyePalette palette("#123456,000000,ff3020,706050", 6);
- uint32_t data[3];
- data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
- data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
- data[2] = buildHex(0xff, 0x30, 0x20, 0x30);
- DYEPALETTE(palette, SColor)(&data[0], 3);
- REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
- REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
- REQUIRE(data[2] == buildHex(0x70, 0x60, 0x50, 0x30));
-}
-
-TEST_CASE("Dye replaceSColor 4 1", "")
-{
- DyePalette palette("#123456,000000,ff3020,706050", 6);
- uint32_t data[4];
- data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
- data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
- data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
- data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
- DYEPALETTE(palette, SColor)(&data[0], 4);
- REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
- REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
- REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
- REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
-}
-
-TEST_CASE("Dye replaceSColor 5 1", "")
-{
- DyePalette palette("#123456,000000,ff3020,706050", 6);
- uint32_t data[5];
- data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
- data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
- data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
- data[3] = buildHex(0xff, 0x30, 0x20, 0x30);
- data[4] = buildHex(0xff, 0x30, 0x20, 0x20);
- DYEPALETTE(palette, SColor)(&data[0], 5);
- REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
- REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
- REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
- REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x30));
- REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x20));
-}
-
-TEST_CASE("Dye replaceSColor 7 1", "")
-{
- DyePalette palette("#123456,000000,ff3020,706050", 6);
- uint32_t data[7];
- data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
- data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
- data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
- data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
- data[4] = buildHex(0xff, 0x30, 0x20, 0x10);
- data[5] = buildHex(0xff, 0x30, 0x20, 0x40);
- data[6] = buildHex(0xff, 0x40, 0x20, 0x50);
- DYEPALETTE(palette, SColor)(&data[0], 7);
- REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
- REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
- REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
- REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
- REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x10));
- REQUIRE(data[5] == buildHex(0x70, 0x60, 0x50, 0x40));
- REQUIRE(data[6] == buildHex(0xff, 0x40, 0x20, 0x50));
-}
-
-TEST_CASE("Dye replaceSColor 8 1", "")
-{
- DyePalette palette("#123456,000000,ff3020,706050", 6);
- uint32_t data[8];
- data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
- data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
- data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
- data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
- data[4] = buildHex(0xff, 0x30, 0x20, 0x10);
- data[5] = buildHex(0xff, 0x30, 0x20, 0x40);
- data[6] = buildHex(0xff, 0x40, 0x20, 0x50);
- data[7] = buildHex(0xff, 0x30, 0x20, 0x60);
- DYEPALETTE(palette, SColor)(&data[0], 8);
- REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
- REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
- REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
- REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
- REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x10));
- REQUIRE(data[5] == buildHex(0x70, 0x60, 0x50, 0x40));
- REQUIRE(data[6] == buildHex(0xff, 0x40, 0x20, 0x50));
- REQUIRE(data[7] == buildHex(0x70, 0x60, 0x50, 0x60));
-}
-
-TEST_CASE("Dye replaceSColor 9 1", "")
-{
- DyePalette palette("#123456,000000,ff3020,706050", 6);
- uint32_t data[9];
- data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
- data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
- data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
- data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
- data[4] = buildHex(0xff, 0x30, 0x20, 0x10);
- data[5] = buildHex(0xff, 0x30, 0x20, 0x40);
- data[6] = buildHex(0xff, 0x40, 0x20, 0x50);
- data[7] = buildHex(0xff, 0x30, 0x20, 0x60);
- data[8] = buildHex(0xff, 0x30, 0x20, 0x70);
- DYEPALETTE(palette, SColor)(&data[0], 9);
- REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
- REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
- REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
- REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
- REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x10));
- REQUIRE(data[5] == buildHex(0x70, 0x60, 0x50, 0x40));
- REQUIRE(data[6] == buildHex(0xff, 0x40, 0x20, 0x50));
- REQUIRE(data[7] == buildHex(0x70, 0x60, 0x50, 0x60));
- REQUIRE(data[8] == buildHex(0x70, 0x60, 0x50, 0x70));
-}
-
-TEST_CASE("Dye replaceSColor 10 1", "")
-{
- DyePalette palette("#123456,000000,ff3020,706050", 6);
- uint32_t data[10];
- data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
- data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
- data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
- data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
- data[4] = buildHex(0xff, 0x30, 0x20, 0x10);
- data[5] = buildHex(0xff, 0x30, 0x20, 0x40);
- data[6] = buildHex(0xff, 0x40, 0x20, 0x50);
- data[7] = buildHex(0xff, 0x30, 0x20, 0x60);
- data[8] = buildHex(0x12, 0x34, 0x56, 0x70);
- data[9] = buildHex(0xff, 0x30, 0x20, 0x80);
- DYEPALETTE(palette, SColor)(&data[0], 10);
- REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
- REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
- REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
- REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
- REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x10));
- REQUIRE(data[5] == buildHex(0x70, 0x60, 0x50, 0x40));
- REQUIRE(data[6] == buildHex(0xff, 0x40, 0x20, 0x50));
- REQUIRE(data[7] == buildHex(0x70, 0x60, 0x50, 0x60));
- REQUIRE(data[8] == buildHex(0x00, 0x00, 0x00, 0x70));
- REQUIRE(data[9] == buildHex(0x70, 0x60, 0x50, 0x80));
-}
-
-TEST_CASE("Dye replaceSColor 1 1 default", "")
-{
- DyePalette palette("#00ff00,000011", 6);
- uint32_t data[1];
- data[0] = buildHex(0x10, 0x03, 0x02, 0x01);
- palette.replaceSColorDefault(&data[0], 1);
- REQUIRE(data[0] == buildHex(0x10, 0x03, 0x02, 0x01));
-}
-
-TEST_CASE("Dye replaceSColor 1 2 default", "")
-{
- DyePalette palette("#403020,706050", 6);
- uint32_t data[1];
- data[0] = buildHex(0x40, 0x30, 0x20, 0x10);
- palette.replaceSColorDefault(&data[0], 1);
- REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
-}
-
-TEST_CASE("Dye replaceSColor 1 3 default", "")
-{
- DyePalette palette("#123456,000000,ff3020,706050", 6);
- uint32_t data[1];
- data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
- palette.replaceSColorDefault(&data[0], 1);
- REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
-}
-
-TEST_CASE("Dye replaceSColor 2 1 default", "")
-{
- DyePalette palette("#123456,000000,ff3020,706050", 6);
- uint32_t data[2];
- data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
- data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
- palette.replaceSColorDefault(&data[0], 2);
- REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
- REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
-}
-
-TEST_CASE("Dye replaceSColor 3 1 default", "")
-{
- DyePalette palette("#123456,000000,ff3020,706050", 6);
- uint32_t data[3];
- data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
- data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
- data[2] = buildHex(0xff, 0x30, 0x20, 0x30);
- palette.replaceSColorDefault(&data[0], 3);
- REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
- REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
- REQUIRE(data[2] == buildHex(0x70, 0x60, 0x50, 0x30));
-}
-
-TEST_CASE("Dye replaceSColor 4 1 default", "")
-{
- DyePalette palette("#123456,000000,ff3020,706050", 6);
- uint32_t data[4];
- data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
- data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
- data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
- data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
- palette.replaceSColorDefault(&data[0], 4);
- REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
- REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
- REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
- REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
-}
-
-TEST_CASE("Dye replaceSColor 5 1 default", "")
-{
- DyePalette palette("#123456,000000,ff3020,706050", 6);
- uint32_t data[5];
- data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
- data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
- data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
- data[3] = buildHex(0xff, 0x30, 0x20, 0x30);
- data[4] = buildHex(0xff, 0x30, 0x20, 0x20);
- palette.replaceSColorDefault(&data[0], 5);
- REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
- REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
- REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
- REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x30));
- REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x20));
-}
-
-TEST_CASE("Dye replaceSColor 7 1 default", "")
-{
- DyePalette palette("#123456,000000,ff3020,706050", 6);
- uint32_t data[7];
- data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
- data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
- data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
- data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
- data[4] = buildHex(0xff, 0x30, 0x20, 0x10);
- data[5] = buildHex(0xff, 0x30, 0x20, 0x40);
- data[6] = buildHex(0xff, 0x40, 0x20, 0x50);
- palette.replaceSColorDefault(&data[0], 7);
- REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
- REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
- REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
- REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
- REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x10));
- REQUIRE(data[5] == buildHex(0x70, 0x60, 0x50, 0x40));
- REQUIRE(data[6] == buildHex(0xff, 0x40, 0x20, 0x50));
-}
-
-TEST_CASE("Dye replaceSColor 8 1 default", "")
-{
- DyePalette palette("#123456,000000,ff3020,706050", 6);
- uint32_t data[8];
- data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
- data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
- data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
- data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
- data[4] = buildHex(0xff, 0x30, 0x20, 0x10);
- data[5] = buildHex(0xff, 0x30, 0x20, 0x40);
- data[6] = buildHex(0xff, 0x40, 0x20, 0x50);
- data[7] = buildHex(0xff, 0x30, 0x20, 0x60);
- palette.replaceSColorDefault(&data[0], 8);
- REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
- REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
- REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
- REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
- REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x10));
- REQUIRE(data[5] == buildHex(0x70, 0x60, 0x50, 0x40));
- REQUIRE(data[6] == buildHex(0xff, 0x40, 0x20, 0x50));
- REQUIRE(data[7] == buildHex(0x70, 0x60, 0x50, 0x60));
-}
-
-TEST_CASE("Dye replaceSColor 9 1 default", "")
-{
- DyePalette palette("#123456,000000,ff3020,706050", 6);
- uint32_t data[9];
- data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
- data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
- data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
- data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
- data[4] = buildHex(0xff, 0x30, 0x20, 0x10);
- data[5] = buildHex(0xff, 0x30, 0x20, 0x40);
- data[6] = buildHex(0xff, 0x40, 0x20, 0x50);
- data[7] = buildHex(0xff, 0x30, 0x20, 0x60);
- data[8] = buildHex(0xff, 0x30, 0x20, 0x70);
- palette.replaceSColorDefault(&data[0], 9);
- REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
- REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
- REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
- REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
- REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x10));
- REQUIRE(data[5] == buildHex(0x70, 0x60, 0x50, 0x40));
- REQUIRE(data[6] == buildHex(0xff, 0x40, 0x20, 0x50));
- REQUIRE(data[7] == buildHex(0x70, 0x60, 0x50, 0x60));
- REQUIRE(data[8] == buildHex(0x70, 0x60, 0x50, 0x70));
-}
-
-TEST_CASE("Dye replaceSColor 10 1 default", "")
-{
- DyePalette palette("#123456,000000,ff3020,706050", 6);
- uint32_t data[10];
- data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
- data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
- data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
- data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
- data[4] = buildHex(0xff, 0x30, 0x20, 0x10);
- data[5] = buildHex(0xff, 0x30, 0x20, 0x40);
- data[6] = buildHex(0xff, 0x40, 0x20, 0x50);
- data[7] = buildHex(0xff, 0x30, 0x20, 0x60);
- data[8] = buildHex(0x12, 0x34, 0x56, 0x70);
- data[9] = buildHex(0xff, 0x30, 0x20, 0x80);
- palette.replaceSColorDefault(&data[0], 10);
- REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
- REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
- REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
- REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
- REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x10));
- REQUIRE(data[5] == buildHex(0x70, 0x60, 0x50, 0x40));
- REQUIRE(data[6] == buildHex(0xff, 0x40, 0x20, 0x50));
- REQUIRE(data[7] == buildHex(0x70, 0x60, 0x50, 0x60));
- REQUIRE(data[8] == buildHex(0x00, 0x00, 0x00, 0x70));
- REQUIRE(data[9] == buildHex(0x70, 0x60, 0x50, 0x80));
-}
-
-TEST_CASE("Dye replaceSColor 1 1 sse2", "")
-{
- DyePalette palette("#00ff00,000011", 6);
- uint32_t data[1];
- data[0] = buildHex(0x10, 0x03, 0x02, 0x01);
- DYEPALETTE(palette, SColorSse2)(&data[0], 1);
- REQUIRE(data[0] == buildHex(0x10, 0x03, 0x02, 0x01));
-}
-
-TEST_CASE("Dye replaceSColor 1 2 sse2", "")
-{
- DyePalette palette("#403020,706050", 6);
- uint32_t data[1];
- data[0] = buildHex(0x40, 0x30, 0x20, 0x10);
- DYEPALETTE(palette, SColorSse2)(&data[0], 1);
- REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
-}
-
-TEST_CASE("Dye replaceSColor 1 3 sse2", "")
-{
- DyePalette palette("#123456,000000,ff3020,706050", 6);
- uint32_t data[1];
- data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
- DYEPALETTE(palette, SColorSse2)(&data[0], 1);
- REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
-}
-
-TEST_CASE("Dye replaceSColor 2 1 sse2", "")
-{
- DyePalette palette("#123456,000000,ff3020,706050", 6);
- uint32_t data[2];
- data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
- data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
- DYEPALETTE(palette, SColorSse2)(&data[0], 2);
- REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
- REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
-}
-
-TEST_CASE("Dye replaceSColor 3 1 sse2", "")
-{
- DyePalette palette("#123456,000000,ff3020,706050", 6);
- uint32_t data[3];
- data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
- data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
- data[2] = buildHex(0xff, 0x30, 0x20, 0x30);
- DYEPALETTE(palette, SColorSse2)(&data[0], 3);
- REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
- REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
- REQUIRE(data[2] == buildHex(0x70, 0x60, 0x50, 0x30));
-}
-
-TEST_CASE("Dye replaceSColor 4 1 sse2", "")
-{
- DyePalette palette("#123456,000000,ff3020,706050", 6);
- uint32_t data[4];
- data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
- data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
- data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
- data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
- DYEPALETTE(palette, SColorSse2)(&data[0], 4);
- REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
- REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
- REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
- REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
-}
-
-TEST_CASE("Dye replaceSColor 5 1 sse2", "")
-{
- DyePalette palette("#123456,000000,ff3020,706050", 6);
- uint32_t data[5];
- data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
- data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
- data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
- data[3] = buildHex(0xff, 0x30, 0x20, 0x30);
- data[4] = buildHex(0xff, 0x30, 0x20, 0x20);
- DYEPALETTE(palette, SColorSse2)(&data[0], 5);
- REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
- REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
- REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
- REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x30));
- REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x20));
-}
-
-TEST_CASE("Dye replaceSColor 7 1 sse2", "")
-{
- DyePalette palette("#123456,000000,ff3020,706050", 6);
- uint32_t data[7];
- data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
- data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
- data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
- data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
- data[4] = buildHex(0xff, 0x30, 0x20, 0x10);
- data[5] = buildHex(0xff, 0x30, 0x20, 0x40);
- data[6] = buildHex(0xff, 0x40, 0x20, 0x50);
- DYEPALETTE(palette, SColorSse2)(&data[0], 7);
- REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
- REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
- REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
- REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
- REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x10));
- REQUIRE(data[5] == buildHex(0x70, 0x60, 0x50, 0x40));
- REQUIRE(data[6] == buildHex(0xff, 0x40, 0x20, 0x50));
-}
-
-TEST_CASE("Dye replaceSColor 8 1 sse2", "")
-{
- DyePalette palette("#123456,000000,ff3020,706050", 6);
- uint32_t data[8];
- data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
- data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
- data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
- data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
- data[4] = buildHex(0xff, 0x30, 0x20, 0x10);
- data[5] = buildHex(0xff, 0x30, 0x20, 0x40);
- data[6] = buildHex(0xff, 0x40, 0x20, 0x50);
- data[7] = buildHex(0xff, 0x30, 0x20, 0x60);
- DYEPALETTE(palette, SColorSse2)(&data[0], 8);
- REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
- REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
- REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
- REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
- REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x10));
- REQUIRE(data[5] == buildHex(0x70, 0x60, 0x50, 0x40));
- REQUIRE(data[6] == buildHex(0xff, 0x40, 0x20, 0x50));
- REQUIRE(data[7] == buildHex(0x70, 0x60, 0x50, 0x60));
-}
-
-TEST_CASE("Dye replaceSColor 9 1 sse2", "")
-{
- DyePalette palette("#123456,000000,ff3020,706050", 6);
- uint32_t data[9];
- data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
- data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
- data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
- data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
- data[4] = buildHex(0xff, 0x30, 0x20, 0x10);
- data[5] = buildHex(0xff, 0x30, 0x20, 0x40);
- data[6] = buildHex(0xff, 0x40, 0x20, 0x50);
- data[7] = buildHex(0xff, 0x30, 0x20, 0x60);
- data[8] = buildHex(0xff, 0x30, 0x20, 0x70);
- DYEPALETTE(palette, SColorSse2)(&data[0], 9);
- REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
- REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
- REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
- REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
- REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x10));
- REQUIRE(data[5] == buildHex(0x70, 0x60, 0x50, 0x40));
- REQUIRE(data[6] == buildHex(0xff, 0x40, 0x20, 0x50));
- REQUIRE(data[7] == buildHex(0x70, 0x60, 0x50, 0x60));
- REQUIRE(data[8] == buildHex(0x70, 0x60, 0x50, 0x70));
-}
-
-TEST_CASE("Dye replaceSColor 10 1 sse2", "")
-{
- DyePalette palette("#123456,000000,ff3020,706050", 6);
- uint32_t data[10];
- data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
- data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
- data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
- data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
- data[4] = buildHex(0xff, 0x30, 0x20, 0x10);
- data[5] = buildHex(0xff, 0x30, 0x20, 0x40);
- data[6] = buildHex(0xff, 0x40, 0x20, 0x50);
- data[7] = buildHex(0xff, 0x30, 0x20, 0x60);
- data[8] = buildHex(0x12, 0x34, 0x56, 0x70);
- data[9] = buildHex(0xff, 0x30, 0x20, 0x80);
- DYEPALETTE(palette, SColorSse2)(&data[0], 10);
- REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
- REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
- REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
- REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
- REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x10));
- REQUIRE(data[5] == buildHex(0x70, 0x60, 0x50, 0x40));
- REQUIRE(data[6] == buildHex(0xff, 0x40, 0x20, 0x50));
- REQUIRE(data[7] == buildHex(0x70, 0x60, 0x50, 0x60));
- REQUIRE(data[8] == buildHex(0x00, 0x00, 0x00, 0x70));
- REQUIRE(data[9] == buildHex(0x70, 0x60, 0x50, 0x80));
-}
-
-TEST_CASE("Dye replaceSColor 1 1 avx2", "")
-{
- DyePalette palette("#00ff00,000011", 6);
- uint32_t data[1];
- data[0] = buildHex(0x10, 0x03, 0x02, 0x01);
- DYEPALETTE(palette, SColorAvx2)(&data[0], 1);
- REQUIRE(data[0] == buildHex(0x10, 0x03, 0x02, 0x01));
-}
-
-TEST_CASE("Dye replaceSColor 1 2 avx2", "")
-{
- DyePalette palette("#403020,706050", 6);
- uint32_t data[1];
- data[0] = buildHex(0x40, 0x30, 0x20, 0x10);
- DYEPALETTE(palette, SColorAvx2)(&data[0], 1);
- REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
-}
-
-TEST_CASE("Dye replaceSColor 1 3 avx2", "")
-{
- DyePalette palette("#123456,000000,ff3020,706050", 6);
- uint32_t data[1];
- data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
- DYEPALETTE(palette, SColorAvx2)(&data[0], 1);
- REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
-}
-
-TEST_CASE("Dye replaceSColor 2 1 avx2", "")
-{
- DyePalette palette("#123456,000000,ff3020,706050", 6);
- uint32_t data[2];
- data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
- data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
- DYEPALETTE(palette, SColorAvx2)(&data[0], 2);
- REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
- REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
-}
-
-TEST_CASE("Dye replaceSColor 3 1 avx2", "")
-{
- DyePalette palette("#123456,000000,ff3020,706050", 6);
- uint32_t data[3];
- data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
- data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
- data[2] = buildHex(0xff, 0x30, 0x20, 0x30);
- DYEPALETTE(palette, SColorAvx2)(&data[0], 3);
- REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
- REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
- REQUIRE(data[2] == buildHex(0x70, 0x60, 0x50, 0x30));
-}
-
-TEST_CASE("Dye replaceSColor 4 1 avx2", "")
-{
- DyePalette palette("#123456,000000,ff3020,706050", 6);
- uint32_t data[4];
- data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
- data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
- data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
- data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
- DYEPALETTE(palette, SColorAvx2)(&data[0], 4);
- REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
- REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
- REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
- REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
-}
-
-TEST_CASE("Dye replaceSColor 5 1 avx2", "")
-{
- DyePalette palette("#123456,000000,ff3020,706050", 6);
- uint32_t data[5];
- data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
- data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
- data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
- data[3] = buildHex(0xff, 0x30, 0x20, 0x30);
- data[4] = buildHex(0xff, 0x30, 0x20, 0x20);
- DYEPALETTE(palette, SColorAvx2)(&data[0], 5);
- REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
- REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
- REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
- REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x30));
- REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x20));
-}
-
-TEST_CASE("Dye replaceSColor 7 1 avx2", "")
-{
- DyePalette palette("#123456,000000,ff3020,706050", 6);
- uint32_t data[7];
- data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
- data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
- data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
- data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
- data[4] = buildHex(0xff, 0x30, 0x20, 0x10);
- data[5] = buildHex(0xff, 0x30, 0x20, 0x40);
- data[6] = buildHex(0xff, 0x40, 0x20, 0x50);
- DYEPALETTE(palette, SColorAvx2)(&data[0], 7);
- REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
- REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
- REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
- REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
- REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x10));
- REQUIRE(data[5] == buildHex(0x70, 0x60, 0x50, 0x40));
- REQUIRE(data[6] == buildHex(0xff, 0x40, 0x20, 0x50));
-}
-
-TEST_CASE("Dye replaceSColor 8 1 avx2", "")
-{
- DyePalette palette("#123456,000000,ff3020,706050", 6);
- uint32_t data[8];
- data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
- data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
- data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
- data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
- data[4] = buildHex(0xff, 0x30, 0x20, 0x10);
- data[5] = buildHex(0xff, 0x30, 0x20, 0x40);
- data[6] = buildHex(0xff, 0x40, 0x20, 0x50);
- data[7] = buildHex(0xff, 0x30, 0x20, 0x60);
- DYEPALETTE(palette, SColorAvx2)(&data[0], 8);
- REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
- REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
- REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
- REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
- REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x10));
- REQUIRE(data[5] == buildHex(0x70, 0x60, 0x50, 0x40));
- REQUIRE(data[6] == buildHex(0xff, 0x40, 0x20, 0x50));
- REQUIRE(data[7] == buildHex(0x70, 0x60, 0x50, 0x60));
-}
-
-TEST_CASE("Dye replaceSColor 9 1 avx2", "")
-{
- DyePalette palette("#123456,000000,ff3020,706050", 6);
- uint32_t data[9];
- data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
- data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
- data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
- data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
- data[4] = buildHex(0xff, 0x30, 0x20, 0x10);
- data[5] = buildHex(0xff, 0x30, 0x20, 0x40);
- data[6] = buildHex(0xff, 0x40, 0x20, 0x50);
- data[7] = buildHex(0xff, 0x30, 0x20, 0x60);
- data[8] = buildHex(0xff, 0x30, 0x20, 0x70);
- DYEPALETTE(palette, SColorAvx2)(&data[0], 9);
- REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
- REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
- REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
- REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
- REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x10));
- REQUIRE(data[5] == buildHex(0x70, 0x60, 0x50, 0x40));
- REQUIRE(data[6] == buildHex(0xff, 0x40, 0x20, 0x50));
- REQUIRE(data[7] == buildHex(0x70, 0x60, 0x50, 0x60));
- REQUIRE(data[8] == buildHex(0x70, 0x60, 0x50, 0x70));
-}
-
-TEST_CASE("Dye replaceSColor 10 1 avx2", "")
-{
- DyePalette palette("#123456,000000,ff3020,706050", 6);
- uint32_t data[10];
- data[0] = buildHex(0xff, 0x30, 0x20, 0x10);
- data[1] = buildHex(0xff, 0x30, 0x20, 0x20);
- data[2] = buildHex(0xff, 0x40, 0x20, 0x10);
- data[3] = buildHex(0xff, 0x30, 0x20, 0x20);
- data[4] = buildHex(0xff, 0x30, 0x20, 0x10);
- data[5] = buildHex(0xff, 0x30, 0x20, 0x40);
- data[6] = buildHex(0xff, 0x40, 0x20, 0x50);
- data[7] = buildHex(0xff, 0x30, 0x20, 0x60);
- data[8] = buildHex(0x12, 0x34, 0x56, 0x70);
- data[9] = buildHex(0xff, 0x30, 0x20, 0x80);
- DYEPALETTE(palette, SColorAvx2)(&data[0], 10);
- REQUIRE(data[0] == buildHex(0x70, 0x60, 0x50, 0x10));
- REQUIRE(data[1] == buildHex(0x70, 0x60, 0x50, 0x20));
- REQUIRE(data[2] == buildHex(0xff, 0x40, 0x20, 0x10));
- REQUIRE(data[3] == buildHex(0x70, 0x60, 0x50, 0x20));
- REQUIRE(data[4] == buildHex(0x70, 0x60, 0x50, 0x10));
- REQUIRE(data[5] == buildHex(0x70, 0x60, 0x50, 0x40));
- REQUIRE(data[6] == buildHex(0xff, 0x40, 0x20, 0x50));
- REQUIRE(data[7] == buildHex(0x70, 0x60, 0x50, 0x60));
- REQUIRE(data[8] == buildHex(0x00, 0x00, 0x00, 0x70));
- REQUIRE(data[9] == buildHex(0x70, 0x60, 0x50, 0x80));
-}
-
-
-TEST_CASE("Dye replaceAColor 1 1", "")
-{
- DyePalette palette("#00ff0010,00001120", 8);
- uint32_t data[1];
- data[0] = buildHex(0x10, 0x03, 0x02, 0x01);
- DYEPALETTE(palette, AColor)(&data[0], 1);
- REQUIRE(data[0] == buildHex(0x10, 0x03, 0x02, 0x01));
-}
-
-TEST_CASE("Dye replaceAColor 1 2", "")
-{
- DyePalette palette("#02ff0120,040311ff", 8);
- uint32_t data[1];
- data[0] = buildHex(0x02, 0xff, 0x01, 0x20);
- DYEPALETTE(palette, AColor)(&data[0], 1);
- REQUIRE(data[0] == buildHex(0x04, 0x03, 0x11, 0xff));
-}
-
-TEST_CASE("Dye replaceAColor 1 3", "")
-{
- DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
- uint32_t data[1];
- data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
- DYEPALETTE(palette, AColor)(&data[0], 1);
- REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
-}
-
-TEST_CASE("Dye replaceAColor 2 1", "")
-{
- DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
- uint32_t data[2];
- data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
- data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
- DYEPALETTE(palette, AColor)(&data[0], 2);
- REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
- REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
-}
-
-TEST_CASE("Dye replaceAColor 3 1", "")
-{
- DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
- uint32_t data[3];
- data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
- data[1] = buildHex(0x50, 0x40, 0x40, 0x30);
- data[2] = buildHex(0x40, 0x40, 0x40, 0x40);
- DYEPALETTE(palette, AColor)(&data[0], 3);
- REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
- REQUIRE(data[1] == buildHex(0x50, 0x40, 0x40, 0x30));
- REQUIRE(data[2] == buildHex(0x20, 0x00, 0x00, 0x00));
-}
-
-TEST_CASE("Dye replaceAColor 4 1", "")
-{
- DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
- uint32_t data[4];
- data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
- data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
- data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
- data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
- DYEPALETTE(palette, AColor)(&data[0], 4);
- REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
- REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
- REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
- REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
-}
-
-TEST_CASE("Dye replaceAColor 5 1", "")
-{
- DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
- uint32_t data[5];
- data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
- data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
- data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
- data[3] = buildHex(0x50, 0x40, 0x40, 0x60);
- data[4] = buildHex(0x40, 0x40, 0x40, 0x40);
- DYEPALETTE(palette, AColor)(&data[0], 5);
- REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
- REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
- REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
- REQUIRE(data[3] == buildHex(0x50, 0x40, 0x40, 0x60));
- REQUIRE(data[4] == buildHex(0x20, 0x00, 0x00, 0x00));
-}
-
-TEST_CASE("Dye replaceAColor 7 1", "")
-{
- DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
- uint32_t data[7];
- data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
- data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
- data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
- data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
- data[4] = buildHex(0x01, 0x00, 0xee, 0x40);
- data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
- data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
- DYEPALETTE(palette, AColor)(&data[0], 7);
- REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
- REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
- REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
- REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
- REQUIRE(data[4] == buildHex(0x10, 0x20, 0x30, 0xff));
- REQUIRE(data[5] == buildHex(0x40, 0x40, 0x41, 0x40));
- REQUIRE(data[6] == buildHex(0x01, 0x00, 0xee, 0x50));
-}
-
-TEST_CASE("Dye replaceAColor 8 1", "")
-{
- DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
- uint32_t data[8];
- data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
- data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
- data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
- data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
- data[4] = buildHex(0x01, 0x00, 0xee, 0x40);
- data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
- data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
- data[7] = buildHex(0x40, 0x40, 0x40, 0x40);
- DYEPALETTE(palette, AColor)(&data[0], 8);
- REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
- REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
- REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
- REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
- REQUIRE(data[4] == buildHex(0x10, 0x20, 0x30, 0xff));
- REQUIRE(data[5] == buildHex(0x40, 0x40, 0x41, 0x40));
- REQUIRE(data[6] == buildHex(0x01, 0x00, 0xee, 0x50));
- REQUIRE(data[7] == buildHex(0x20, 0x00, 0x00, 0x00));
-}
-
-TEST_CASE("Dye replaceAColor 9 1", "")
-{
- DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
- uint32_t data[9];
- data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
- data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
- data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
- data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
- data[4] = buildHex(0x01, 0x00, 0xee, 0x40);
- data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
- data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
- data[7] = buildHex(0x02, 0x40, 0x40, 0x40);
- data[8] = buildHex(0x40, 0x40, 0x40, 0x40);
- DYEPALETTE(palette, AColor)(&data[0], 9);
- REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
- REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
- REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
- REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
- REQUIRE(data[4] == buildHex(0x10, 0x20, 0x30, 0xff));
- REQUIRE(data[5] == buildHex(0x40, 0x40, 0x41, 0x40));
- REQUIRE(data[6] == buildHex(0x01, 0x00, 0xee, 0x50));
- REQUIRE(data[7] == buildHex(0x02, 0x40, 0x40, 0x40));
- REQUIRE(data[8] == buildHex(0x20, 0x00, 0x00, 0x00));
-}
-
-TEST_CASE("Dye replaceAColor 10 1", "")
-{
- DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
- uint32_t data[10];
- data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
- data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
- data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
- data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
- data[4] = buildHex(0x01, 0x00, 0xee, 0x40);
- data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
- data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
- data[7] = buildHex(0x02, 0x40, 0x40, 0x40);
- data[8] = buildHex(0x40, 0x40, 0x40, 0x40);
- data[9] = buildHex(0x01, 0x00, 0xee, 0x40);
- DYEPALETTE(palette, AColor)(&data[0], 10);
- REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
- REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
- REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
- REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
- REQUIRE(data[4] == buildHex(0x10, 0x20, 0x30, 0xff));
- REQUIRE(data[5] == buildHex(0x40, 0x40, 0x41, 0x40));
- REQUIRE(data[6] == buildHex(0x01, 0x00, 0xee, 0x50));
- REQUIRE(data[7] == buildHex(0x02, 0x40, 0x40, 0x40));
- REQUIRE(data[8] == buildHex(0x20, 0x00, 0x00, 0x00));
- REQUIRE(data[9] == buildHex(0x10, 0x20, 0x30, 0xff));
-}
-
-TEST_CASE("Dye replaceAColor 1 1 default", "")
-{
- DyePalette palette("#00ff0010,00001120", 8);
- uint32_t data[1];
- data[0] = buildHex(0x10, 0x03, 0x02, 0x01);
- palette.replaceAColorDefault(&data[0], 1);
- REQUIRE(data[0] == buildHex(0x10, 0x03, 0x02, 0x01));
-}
-
-TEST_CASE("Dye replaceAColor 1 2 default", "")
-{
- DyePalette palette("#02ff0120,040311ff", 8);
- uint32_t data[1];
- data[0] = buildHex(0x02, 0xff, 0x01, 0x20);
- palette.replaceAColorDefault(&data[0], 1);
- REQUIRE(data[0] == buildHex(0x04, 0x03, 0x11, 0xff));
-}
-
-TEST_CASE("Dye replaceAColor 1 3 default", "")
-{
- DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
- uint32_t data[1];
- data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
- palette.replaceAColorDefault(&data[0], 1);
- REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
-}
-
-TEST_CASE("Dye replaceAColor 2 1 default", "")
-{
- DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
- uint32_t data[2];
- data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
- data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
- palette.replaceAColorDefault(&data[0], 2);
- REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
- REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
-}
-
-TEST_CASE("Dye replaceAColor 3 1 default", "")
-{
- DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
- uint32_t data[3];
- data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
- data[1] = buildHex(0x50, 0x40, 0x40, 0x30);
- data[2] = buildHex(0x40, 0x40, 0x40, 0x40);
- palette.replaceAColorDefault(&data[0], 3);
- REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
- REQUIRE(data[1] == buildHex(0x50, 0x40, 0x40, 0x30));
- REQUIRE(data[2] == buildHex(0x20, 0x00, 0x00, 0x00));
-}
-
-TEST_CASE("Dye replaceAColor 4 1 default", "")
-{
- DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
- uint32_t data[4];
- data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
- data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
- data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
- data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
- palette.replaceAColorDefault(&data[0], 4);
- REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
- REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
- REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
- REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
-}
-
-TEST_CASE("Dye replaceAColor 5 1 default", "")
-{
- DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
- uint32_t data[5];
- data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
- data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
- data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
- data[3] = buildHex(0x50, 0x40, 0x40, 0x60);
- data[4] = buildHex(0x40, 0x40, 0x40, 0x40);
- palette.replaceAColorDefault(&data[0], 5);
- REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
- REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
- REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
- REQUIRE(data[3] == buildHex(0x50, 0x40, 0x40, 0x60));
- REQUIRE(data[4] == buildHex(0x20, 0x00, 0x00, 0x00));
-}
-
-TEST_CASE("Dye replaceAColor 7 1 default", "")
-{
- DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
- uint32_t data[7];
- data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
- data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
- data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
- data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
- data[4] = buildHex(0x01, 0x00, 0xee, 0x40);
- data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
- data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
- palette.replaceAColorDefault(&data[0], 7);
- REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
- REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
- REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
- REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
- REQUIRE(data[4] == buildHex(0x10, 0x20, 0x30, 0xff));
- REQUIRE(data[5] == buildHex(0x40, 0x40, 0x41, 0x40));
- REQUIRE(data[6] == buildHex(0x01, 0x00, 0xee, 0x50));
-}
-
-TEST_CASE("Dye replaceAColor 8 1 default", "")
-{
- DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
- uint32_t data[8];
- data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
- data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
- data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
- data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
- data[4] = buildHex(0x01, 0x00, 0xee, 0x40);
- data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
- data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
- data[7] = buildHex(0x40, 0x40, 0x40, 0x40);
- palette.replaceAColorDefault(&data[0], 8);
- REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
- REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
- REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
- REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
- REQUIRE(data[4] == buildHex(0x10, 0x20, 0x30, 0xff));
- REQUIRE(data[5] == buildHex(0x40, 0x40, 0x41, 0x40));
- REQUIRE(data[6] == buildHex(0x01, 0x00, 0xee, 0x50));
- REQUIRE(data[7] == buildHex(0x20, 0x00, 0x00, 0x00));
-}
-
-TEST_CASE("Dye replaceAColor 9 1 default", "")
-{
- DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
- uint32_t data[9];
- data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
- data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
- data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
- data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
- data[4] = buildHex(0x01, 0x00, 0xee, 0x40);
- data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
- data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
- data[7] = buildHex(0x02, 0x40, 0x40, 0x40);
- data[8] = buildHex(0x40, 0x40, 0x40, 0x40);
- palette.replaceAColorDefault(&data[0], 9);
- REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
- REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
- REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
- REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
- REQUIRE(data[4] == buildHex(0x10, 0x20, 0x30, 0xff));
- REQUIRE(data[5] == buildHex(0x40, 0x40, 0x41, 0x40));
- REQUIRE(data[6] == buildHex(0x01, 0x00, 0xee, 0x50));
- REQUIRE(data[7] == buildHex(0x02, 0x40, 0x40, 0x40));
- REQUIRE(data[8] == buildHex(0x20, 0x00, 0x00, 0x00));
-}
-
-TEST_CASE("Dye replaceAColor 10 1 default", "")
-{
- DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
- uint32_t data[10];
- data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
- data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
- data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
- data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
- data[4] = buildHex(0x01, 0x00, 0xee, 0x40);
- data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
- data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
- data[7] = buildHex(0x02, 0x40, 0x40, 0x40);
- data[8] = buildHex(0x40, 0x40, 0x40, 0x40);
- data[9] = buildHex(0x01, 0x00, 0xee, 0x40);
- palette.replaceAColorDefault(&data[0], 10);
- REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
- REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
- REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
- REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
- REQUIRE(data[4] == buildHex(0x10, 0x20, 0x30, 0xff));
- REQUIRE(data[5] == buildHex(0x40, 0x40, 0x41, 0x40));
- REQUIRE(data[6] == buildHex(0x01, 0x00, 0xee, 0x50));
- REQUIRE(data[7] == buildHex(0x02, 0x40, 0x40, 0x40));
- REQUIRE(data[8] == buildHex(0x20, 0x00, 0x00, 0x00));
- REQUIRE(data[9] == buildHex(0x10, 0x20, 0x30, 0xff));
-}
-
-TEST_CASE("Dye replaceAColor 1 1 sse2", "")
-{
- DyePalette palette("#00ff0010,00001120", 8);
- uint32_t data[1];
- data[0] = buildHex(0x10, 0x03, 0x02, 0x01);
- DYEPALETTE(palette, AColorSse2)(&data[0], 1);
- REQUIRE(data[0] == buildHex(0x10, 0x03, 0x02, 0x01));
-}
-
-TEST_CASE("Dye replaceAColor 1 2 sse2", "")
-{
- DyePalette palette("#02ff0120,040311ff", 8);
- uint32_t data[1];
- data[0] = buildHex(0x02, 0xff, 0x01, 0x20);
- DYEPALETTE(palette, AColorSse2)(&data[0], 1);
- REQUIRE(data[0] == buildHex(0x04, 0x03, 0x11, 0xff));
-}
-
-TEST_CASE("Dye replaceAColor 1 3 sse2", "")
-{
- DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
- uint32_t data[1];
- data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
- DYEPALETTE(palette, AColorSse2)(&data[0], 1);
- REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
-}
-
-TEST_CASE("Dye replaceAColor 2 1 sse2", "")
-{
- DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
- uint32_t data[2];
- data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
- data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
- DYEPALETTE(palette, AColorSse2)(&data[0], 2);
- REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
- REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
-}
-
-TEST_CASE("Dye replaceAColor 3 1 sse2", "")
-{
- DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
- uint32_t data[3];
- data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
- data[1] = buildHex(0x50, 0x40, 0x40, 0x30);
- data[2] = buildHex(0x40, 0x40, 0x40, 0x40);
- DYEPALETTE(palette, AColorSse2)(&data[0], 3);
- REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
- REQUIRE(data[1] == buildHex(0x50, 0x40, 0x40, 0x30));
- REQUIRE(data[2] == buildHex(0x20, 0x00, 0x00, 0x00));
-}
-
-TEST_CASE("Dye replaceAColor 4 1 sse2", "")
-{
- DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
- uint32_t data[4];
- data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
- data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
- data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
- data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
- DYEPALETTE(palette, AColorSse2)(&data[0], 4);
- REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
- REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
- REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
- REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
-}
-
-TEST_CASE("Dye replaceAColor 5 1 sse2", "")
-{
- DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
- uint32_t data[5];
- data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
- data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
- data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
- data[3] = buildHex(0x50, 0x40, 0x40, 0x60);
- data[4] = buildHex(0x40, 0x40, 0x40, 0x40);
- DYEPALETTE(palette, AColorSse2)(&data[0], 5);
- REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
- REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
- REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
- REQUIRE(data[3] == buildHex(0x50, 0x40, 0x40, 0x60));
- REQUIRE(data[4] == buildHex(0x20, 0x00, 0x00, 0x00));
-}
-
-TEST_CASE("Dye replaceAColor 7 1 sse2", "")
-{
- DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
- uint32_t data[7];
- data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
- data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
- data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
- data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
- data[4] = buildHex(0x01, 0x00, 0xee, 0x40);
- data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
- data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
- DYEPALETTE(palette, AColorSse2)(&data[0], 7);
- REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
- REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
- REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
- REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
- REQUIRE(data[4] == buildHex(0x10, 0x20, 0x30, 0xff));
- REQUIRE(data[5] == buildHex(0x40, 0x40, 0x41, 0x40));
- REQUIRE(data[6] == buildHex(0x01, 0x00, 0xee, 0x50));
-}
-
-TEST_CASE("Dye replaceAColor 8 1 sse2", "")
-{
- DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
- uint32_t data[8];
- data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
- data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
- data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
- data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
- data[4] = buildHex(0x01, 0x00, 0xee, 0x40);
- data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
- data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
- data[7] = buildHex(0x40, 0x40, 0x40, 0x40);
- DYEPALETTE(palette, AColorSse2)(&data[0], 8);
- REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
- REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
- REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
- REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
- REQUIRE(data[4] == buildHex(0x10, 0x20, 0x30, 0xff));
- REQUIRE(data[5] == buildHex(0x40, 0x40, 0x41, 0x40));
- REQUIRE(data[6] == buildHex(0x01, 0x00, 0xee, 0x50));
- REQUIRE(data[7] == buildHex(0x20, 0x00, 0x00, 0x00));
-}
-
-TEST_CASE("Dye replaceAColor 9 1 sse2", "")
-{
- DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
- uint32_t data[9];
- data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
- data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
- data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
- data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
- data[4] = buildHex(0x01, 0x00, 0xee, 0x40);
- data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
- data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
- data[7] = buildHex(0x02, 0x40, 0x40, 0x40);
- data[8] = buildHex(0x40, 0x40, 0x40, 0x40);
- DYEPALETTE(palette, AColorSse2)(&data[0], 9);
- REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
- REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
- REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
- REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
- REQUIRE(data[4] == buildHex(0x10, 0x20, 0x30, 0xff));
- REQUIRE(data[5] == buildHex(0x40, 0x40, 0x41, 0x40));
- REQUIRE(data[6] == buildHex(0x01, 0x00, 0xee, 0x50));
- REQUIRE(data[7] == buildHex(0x02, 0x40, 0x40, 0x40));
- REQUIRE(data[8] == buildHex(0x20, 0x00, 0x00, 0x00));
-}
-
-TEST_CASE("Dye replaceAColor 10 1 sse2", "")
-{
- DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
- uint32_t data[10];
- data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
- data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
- data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
- data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
- data[4] = buildHex(0x01, 0x00, 0xee, 0x40);
- data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
- data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
- data[7] = buildHex(0x02, 0x40, 0x40, 0x40);
- data[8] = buildHex(0x40, 0x40, 0x40, 0x40);
- data[9] = buildHex(0x01, 0x00, 0xee, 0x40);
- DYEPALETTE(palette, AColorSse2)(&data[0], 10);
- REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
- REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
- REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
- REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
- REQUIRE(data[4] == buildHex(0x10, 0x20, 0x30, 0xff));
- REQUIRE(data[5] == buildHex(0x40, 0x40, 0x41, 0x40));
- REQUIRE(data[6] == buildHex(0x01, 0x00, 0xee, 0x50));
- REQUIRE(data[7] == buildHex(0x02, 0x40, 0x40, 0x40));
- REQUIRE(data[8] == buildHex(0x20, 0x00, 0x00, 0x00));
- REQUIRE(data[9] == buildHex(0x10, 0x20, 0x30, 0xff));
-}
-
-TEST_CASE("Dye replaceAColor 1 1 avx2", "")
-{
- DyePalette palette("#00ff0010,00001120", 8);
- uint32_t data[1];
- data[0] = buildHex(0x10, 0x03, 0x02, 0x01);
- DYEPALETTE(palette, AColorAvx2)(&data[0], 1);
- REQUIRE(data[0] == buildHex(0x10, 0x03, 0x02, 0x01));
-}
-
-TEST_CASE("Dye replaceAColor 1 2 avx2", "")
-{
- DyePalette palette("#02ff0120,040311ff", 8);
- uint32_t data[1];
- data[0] = buildHex(0x02, 0xff, 0x01, 0x20);
- DYEPALETTE(palette, AColorAvx2)(&data[0], 1);
- REQUIRE(data[0] == buildHex(0x04, 0x03, 0x11, 0xff));
-}
-
-TEST_CASE("Dye replaceAColor 1 3 avx2", "")
-{
- DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
- uint32_t data[1];
- data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
- DYEPALETTE(palette, AColorAvx2)(&data[0], 1);
- REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
-}
-
-TEST_CASE("Dye replaceAColor 2 1 avx2", "")
-{
- DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
- uint32_t data[2];
- data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
- data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
- DYEPALETTE(palette, AColorAvx2)(&data[0], 2);
- REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
- REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
-}
-
-TEST_CASE("Dye replaceAColor 3 1 avx2", "")
-{
- DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
- uint32_t data[3];
- data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
- data[1] = buildHex(0x50, 0x40, 0x40, 0x30);
- data[2] = buildHex(0x40, 0x40, 0x40, 0x40);
- DYEPALETTE(palette, AColorAvx2)(&data[0], 3);
- REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
- REQUIRE(data[1] == buildHex(0x50, 0x40, 0x40, 0x30));
- REQUIRE(data[2] == buildHex(0x20, 0x00, 0x00, 0x00));
-}
-
-TEST_CASE("Dye replaceAColor 4 1 avx2", "")
-{
- DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
- uint32_t data[4];
- data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
- data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
- data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
- data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
- DYEPALETTE(palette, AColorAvx2)(&data[0], 4);
- REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
- REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
- REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
- REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
-}
-
-TEST_CASE("Dye replaceAColor 5 1 avx2", "")
-{
- DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
- uint32_t data[5];
- data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
- data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
- data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
- data[3] = buildHex(0x50, 0x40, 0x40, 0x60);
- data[4] = buildHex(0x40, 0x40, 0x40, 0x40);
- DYEPALETTE(palette, AColorAvx2)(&data[0], 5);
- REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
- REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
- REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
- REQUIRE(data[3] == buildHex(0x50, 0x40, 0x40, 0x60));
- REQUIRE(data[4] == buildHex(0x20, 0x00, 0x00, 0x00));
-}
-
-TEST_CASE("Dye replaceAColor 7 1 avx2", "")
-{
- DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
- uint32_t data[7];
- data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
- data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
- data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
- data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
- data[4] = buildHex(0x01, 0x00, 0xee, 0x40);
- data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
- data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
- DYEPALETTE(palette, AColorAvx2)(&data[0], 7);
- REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
- REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
- REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
- REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
- REQUIRE(data[4] == buildHex(0x10, 0x20, 0x30, 0xff));
- REQUIRE(data[5] == buildHex(0x40, 0x40, 0x41, 0x40));
- REQUIRE(data[6] == buildHex(0x01, 0x00, 0xee, 0x50));
-}
-
-TEST_CASE("Dye replaceAColor 8 1 avx2", "")
-{
- DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
- uint32_t data[8];
- data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
- data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
- data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
- data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
- data[4] = buildHex(0x01, 0x00, 0xee, 0x40);
- data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
- data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
- data[7] = buildHex(0x40, 0x40, 0x40, 0x40);
- DYEPALETTE(palette, AColorAvx2)(&data[0], 8);
- REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
- REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
- REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
- REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
- REQUIRE(data[4] == buildHex(0x10, 0x20, 0x30, 0xff));
- REQUIRE(data[5] == buildHex(0x40, 0x40, 0x41, 0x40));
- REQUIRE(data[6] == buildHex(0x01, 0x00, 0xee, 0x50));
- REQUIRE(data[7] == buildHex(0x20, 0x00, 0x00, 0x00));
-}
-
-TEST_CASE("Dye replaceAColor 9 1 avx2", "")
-{
- DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
- uint32_t data[9];
- data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
- data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
- data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
- data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
- data[4] = buildHex(0x01, 0x00, 0xee, 0x40);
- data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
- data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
- data[7] = buildHex(0x02, 0x40, 0x40, 0x40);
- data[8] = buildHex(0x40, 0x40, 0x40, 0x40);
- DYEPALETTE(palette, AColorAvx2)(&data[0], 9);
- REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
- REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
- REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
- REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
- REQUIRE(data[4] == buildHex(0x10, 0x20, 0x30, 0xff));
- REQUIRE(data[5] == buildHex(0x40, 0x40, 0x41, 0x40));
- REQUIRE(data[6] == buildHex(0x01, 0x00, 0xee, 0x50));
- REQUIRE(data[7] == buildHex(0x02, 0x40, 0x40, 0x40));
- REQUIRE(data[8] == buildHex(0x20, 0x00, 0x00, 0x00));
-}
-
-TEST_CASE("Dye replaceAColor 10 1 avx2", "")
-{
- DyePalette palette("#40404040,20000000,0100ee40,102030ff", 8);
- uint32_t data[10];
- data[0] = buildHex(0x01, 0x00, 0xee, 0x40);
- data[1] = buildHex(0x40, 0x40, 0x40, 0x40);
- data[2] = buildHex(0x01, 0x00, 0xee, 0x50);
- data[3] = buildHex(0x40, 0x40, 0x40, 0x40);
- data[4] = buildHex(0x01, 0x00, 0xee, 0x40);
- data[5] = buildHex(0x40, 0x40, 0x41, 0x40);
- data[6] = buildHex(0x01, 0x00, 0xee, 0x50);
- data[7] = buildHex(0x02, 0x40, 0x40, 0x40);
- data[8] = buildHex(0x40, 0x40, 0x40, 0x40);
- data[9] = buildHex(0x01, 0x00, 0xee, 0x40);
- DYEPALETTE(palette, AColorAvx2)(&data[0], 10);
- REQUIRE(data[0] == buildHex(0x10, 0x20, 0x30, 0xff));
- REQUIRE(data[1] == buildHex(0x20, 0x00, 0x00, 0x00));
- REQUIRE(data[2] == buildHex(0x01, 0x00, 0xee, 0x50));
- REQUIRE(data[3] == buildHex(0x20, 0x00, 0x00, 0x00));
- REQUIRE(data[4] == buildHex(0x10, 0x20, 0x30, 0xff));
- REQUIRE(data[5] == buildHex(0x40, 0x40, 0x41, 0x40));
- REQUIRE(data[6] == buildHex(0x01, 0x00, 0xee, 0x50));
- REQUIRE(data[7] == buildHex(0x02, 0x40, 0x40, 0x40));
- REQUIRE(data[8] == buildHex(0x20, 0x00, 0x00, 0x00));
- REQUIRE(data[9] == buildHex(0x10, 0x20, 0x30, 0xff));
-}
-
-
-TEST_CASE("Dye normalDye 1", "")
-{
- Dye dye("R:#203040,506070");
- uint32_t data[1];
- data[0] = buildHex(0x50, 0x00, 0x00, 0x55);
- dye.normalDye(&data[0], 1);
- REQUIRE(data[0] == buildHex(0x14, 0x1e, 0x28, 0x55));
-}
-
-TEST_CASE("Dye normalDye 2", "")
-{
- Dye dye("G:#203040,506070");
- uint32_t data[1];
- data[0] = buildHex(0x00, 0x50, 0x00, 0x60);
- dye.normalDye(&data[0], 1);
- REQUIRE(data[0] == buildHex(0x14, 0x1e, 0x28, 0x60));
-}
-
-
-#ifdef USE_OPENGL
-TEST_CASE("Dye normalOGLDye 1", "")
-{
- Dye dye("R:#203040,506070");
- uint32_t data[1];
- data[0] = buildHex(0x50, 0x00, 0x00, 0x55);
- dye.normalOGLDye(&data[0], 1);
- REQUIRE(data[0] == buildHex(0x50, 0x2a, 0x20, 0x15));
-}
-#endif // USE_OPENGL
-
-static void dyeCheck(const std::string &dyeString,
- const std::string &dstName)
-{
- const std::string srcName = "arrow_up.png";
-
- Image *const image1 = Loader::getImage(srcName + dyeString);
- Image *const image2 = Loader::getImage(dstName);
- REQUIRE(image1 != nullptr);
- REQUIRE(image2 != nullptr);
- SDL_Surface *const surface1 = image1->getSDLSurface();
- SDL_Surface *const surface2 = image2->getSDLSurface();
- REQUIRE(surface1 != nullptr);
- REQUIRE(surface2 != nullptr);
- REQUIRE(surface1->w == surface2->w);
- REQUIRE(surface1->h == surface2->h);
- REQUIRE(surface1->pixels != nullptr);
- REQUIRE(surface2->pixels != nullptr);
- const uint32_t *const ptr1 = static_cast<const uint32_t *>(
- surface1->pixels);
- const uint32_t *const ptr2 = static_cast<const uint32_t *>(
- surface2->pixels);
- const size_t sz = surface1->w * surface1->h;
- for (size_t idx = 0; idx < sz; idx ++)
- {
- REQUIRE(ptr1[idx] == ptr2[idx]);
- }
- image2->decRef();
- image1->decRef();
-}
-
-TEST_CASE("Dye real dye", "")
-{
- setEnv("SDL_VIDEODRIVER", "dummy");
-
- client = new Client;
- SDL_Init(SDL_INIT_VIDEO);
- VirtFs::mountDirSilent("data", Append_false);
- VirtFs::mountDirSilent("../data", Append_false);
- VirtFs::mountDirSilent("data/test", Append_false);
- VirtFs::mountDirSilent("../data/test", Append_false);
-
- Dirs::initRootDir();
- Dirs::initHomeDir();
-
- setBrandingDefaults(branding);
- ConfigManager::initConfiguration();
-
-#ifdef USE_SDL2
- imageHelper = new SurfaceImageHelper;
-
- SDLImageHelper::setRenderer(graphicsManager.createRenderer(
- graphicsManager.createWindow(640, 480, 0,
- SDL_WINDOW_SHOWN | SDL_SWSURFACE), SDL_RENDERER_SOFTWARE));
-#else // USE_SDL2
-
- imageHelper = new SDLImageHelper;
-
- graphicsManager.createWindow(640, 480, 0, SDL_ANYFORMAT | SDL_SWSURFACE);
-#endif // USE_SDL2
-
- userPalette = new UserPalette;
-
- theme = new Theme;
- Theme::selectSkin();
-
- ActorSprite::load();
-
- SECTION("B dye")
- {
- dyeCheck("|B:#FFC88A", "arrow_up_B.png");
- }
-
- SECTION("S dye")
- {
- dyeCheck("|S:#0000FF,FF0000", "arrow_up_S.png");
- }
-
- SECTION("A dye")
- {
- dyeCheck("|A:#0000FFFF,FF000050", "arrow_up_A.png");
- }
-
- delete2(userPalette);
- delete2(theme);
- delete2(client);
- VirtFs::unmountDirSilent("data");
- VirtFs::unmountDirSilent("../data");
- VirtFs::unmountDirSilent("data/test");
- VirtFs::unmountDirSilent("../data/test");
-}
diff --git a/src/unittests/resources/dye/dyepalette.cc b/src/unittests/resources/dye/dyepalette.cc
deleted file mode 100644
index e2632003a..000000000
--- a/src/unittests/resources/dye/dyepalette.cc
+++ /dev/null
@@ -1,400 +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 "unittests/unittests.h"
-
-#include "client.h"
-#include "configuration.h"
-#include "configmanager.h"
-#include "dirs.h"
-#include "graphicsmanager.h"
-
-#include "being/actorsprite.h"
-
-#include "fs/virtfs/fs.h"
-
-#include "gui/gui.h"
-#include "gui/theme.h"
-
-#include "render/sdlgraphics.h"
-
-#include "resources/sdlimagehelper.h"
-
-#include "resources/db/palettedb.h"
-
-#include "resources/dye/dyepalette.h"
-
-#include "utils/delete2.h"
-#include "utils/env.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#ifndef USE_SDL2
-#include <SDL.h>
-#endif // USE_SDL2
-PRAGMA48(GCC diagnostic pop)
-
-#include "debug.h"
-
-TEST_CASE("DyePalette tests", "")
-{
- setEnv("SDL_VIDEODRIVER", "dummy");
-
- client = new Client;
- XML::initXML();
- SDL_Init(SDL_INIT_VIDEO);
- VirtFs::mountDirSilent("data", Append_false);
- VirtFs::mountDirSilent("../data", Append_false);
- VirtFs::mountDirSilent("data/test", Append_false);
- VirtFs::mountDirSilent("../data/test", Append_false);
-
- mainGraphics = new SDLGraphics;
- imageHelper = new SDLImageHelper();
-
- Dirs::initRootDir();
- Dirs::initHomeDir();
-
- ConfigManager::initConfiguration();
- setConfigDefaults2(config);
- setBrandingDefaults(branding);
-
-#ifdef USE_SDL2
- SDLImageHelper::setRenderer(graphicsManager.createRenderer(
- graphicsManager.createWindow(640, 480, 0,
- SDL_WINDOW_SHOWN | SDL_SWSURFACE), SDL_RENDERER_SOFTWARE));
-#else // USE_SDL2
-
- graphicsManager.createWindow(640, 480, 0, SDL_ANYFORMAT | SDL_SWSURFACE);
-#endif // USE_SDL2
-
- theme = new Theme;
- Theme::selectSkin();
-
- ActorSprite::load();
- gui = new Gui();
- gui->postInit(mainGraphics);
- setPathsDefaults(paths);
- PaletteDB::load();
-
- SECTION("simple test 1")
- {
- DyePalette palette("#12ff34", 6);
- REQUIRE(palette.mColors.size() == 1);
- REQUIRE(palette.mColors[0].value[0] == 0x12);
- REQUIRE(palette.mColors[0].value[1] == 0xff);
- REQUIRE(palette.mColors[0].value[2] == 0x34);
- REQUIRE(palette.mColors[0].value[3] == 0x00);
- }
-
- SECTION("simple test 2")
- {
- DyePalette palette("#12ff3456", 8);
- REQUIRE(palette.mColors.size() == 1);
- REQUIRE(palette.mColors[0].value[0] == 0x12);
- REQUIRE(palette.mColors[0].value[1] == 0xff);
- REQUIRE(palette.mColors[0].value[2] == 0x34);
- REQUIRE(palette.mColors[0].value[3] == 0x56);
- }
-
- SECTION("simple test 3")
- {
- DyePalette palette("#12ff34,002211", 6);
- REQUIRE(palette.mColors.size() == 2);
- REQUIRE(palette.mColors[0].value[0] == 0x12);
- REQUIRE(palette.mColors[0].value[1] == 0xff);
- REQUIRE(palette.mColors[0].value[2] == 0x34);
- REQUIRE(palette.mColors[0].value[3] == 0x00);
-
- REQUIRE(palette.mColors[1].value[0] == 0x00);
- REQUIRE(palette.mColors[1].value[1] == 0x22);
- REQUIRE(palette.mColors[1].value[2] == 0x11);
- REQUIRE(palette.mColors[1].value[3] == 0x00);
- }
-
- SECTION("simple test 4")
- {
- DyePalette palette("#12ff3412,00221133", 8);
- REQUIRE(palette.mColors.size() == 2);
- REQUIRE(palette.mColors[0].value[0] == 0x12);
- REQUIRE(palette.mColors[0].value[1] == 0xff);
- REQUIRE(palette.mColors[0].value[2] == 0x34);
- REQUIRE(palette.mColors[0].value[3] == 0x12);
-
- REQUIRE(palette.mColors[1].value[0] == 0x00);
- REQUIRE(palette.mColors[1].value[1] == 0x22);
- REQUIRE(palette.mColors[1].value[2] == 0x11);
- REQUIRE(palette.mColors[1].value[3] == 0x33);
- }
-
- SECTION("simple test 5")
- {
- DyePalette palette("#12ff34,", 6);
- REQUIRE(palette.mColors.size() == 1);
- REQUIRE(palette.mColors[0].value[0] == 0x12);
- REQUIRE(palette.mColors[0].value[1] == 0xff);
- REQUIRE(palette.mColors[0].value[2] == 0x34);
- REQUIRE(palette.mColors[0].value[3] == 0x00);
- }
-
- SECTION("simple test 6")
- {
- DyePalette palette("#12ff3456,", 8);
- REQUIRE(palette.mColors.size() == 1);
- REQUIRE(palette.mColors[0].value[0] == 0x12);
- REQUIRE(palette.mColors[0].value[1] == 0xff);
- REQUIRE(palette.mColors[0].value[2] == 0x34);
- REQUIRE(palette.mColors[0].value[3] == 0x56);
- }
-
- SECTION("simple test 7")
- {
- DyePalette palette("#,,,12ff3412,,00221133", 8);
- REQUIRE(palette.mColors.size() == 2);
- REQUIRE(palette.mColors[0].value[0] == 0x12);
- REQUIRE(palette.mColors[0].value[1] == 0xff);
- REQUIRE(palette.mColors[0].value[2] == 0x34);
- REQUIRE(palette.mColors[0].value[3] == 0x12);
-
- REQUIRE(palette.mColors[1].value[0] == 0x00);
- REQUIRE(palette.mColors[1].value[1] == 0x22);
- REQUIRE(palette.mColors[1].value[2] == 0x11);
- REQUIRE(palette.mColors[1].value[3] == 0x33);
- }
-
- SECTION("palette test 1")
- {
- DyePalette palette("@Untitled1", 6);
- REQUIRE(palette.mColors.size() == 1);
- REQUIRE(palette.mColors[0].value[0] == 47);
- REQUIRE(palette.mColors[0].value[1] == 56);
- REQUIRE(palette.mColors[0].value[2] == 46);
- REQUIRE(palette.mColors[0].value[3] == 255);
- }
-
- SECTION("palette test 2")
- {
- DyePalette palette("@Untitled1,Untitled8", 6);
- REQUIRE(palette.mColors.size() == 2);
- REQUIRE(palette.mColors[0].value[0] == 47);
- REQUIRE(palette.mColors[0].value[1] == 56);
- REQUIRE(palette.mColors[0].value[2] == 46);
- REQUIRE(palette.mColors[0].value[3] == 255);
-
- REQUIRE(palette.mColors[1].value[0] == 0);
- REQUIRE(palette.mColors[1].value[1] == 0);
- REQUIRE(palette.mColors[1].value[2] == 255);
- REQUIRE(palette.mColors[1].value[3] == 255);
- }
-
- SECTION("palette test 3")
- {
- DyePalette palette("@Untitled1,", 6);
- REQUIRE(palette.mColors.size() == 1);
- REQUIRE(palette.mColors[0].value[0] == 47);
- REQUIRE(palette.mColors[0].value[1] == 56);
- REQUIRE(palette.mColors[0].value[2] == 46);
- REQUIRE(palette.mColors[0].value[3] == 255);
- }
-
- SECTION("palette test 4")
- {
- DyePalette palette("@,,,Untitled1,,Untitled8", 6);
- REQUIRE(palette.mColors.size() == 2);
- REQUIRE(palette.mColors[0].value[0] == 47);
- REQUIRE(palette.mColors[0].value[1] == 56);
- REQUIRE(palette.mColors[0].value[2] == 46);
- REQUIRE(palette.mColors[0].value[3] == 255);
-
- REQUIRE(palette.mColors[1].value[0] == 0);
- REQUIRE(palette.mColors[1].value[1] == 0);
- REQUIRE(palette.mColors[1].value[2] == 255);
- REQUIRE(palette.mColors[1].value[3] == 255);
- }
-
- SECTION("palette test 5")
- {
- DyePalette palette("@12ff34", 6);
- REQUIRE(palette.mColors.size() == 1);
- REQUIRE(palette.mColors[0].value[0] == 0x12);
- REQUIRE(palette.mColors[0].value[1] == 0xff);
- REQUIRE(palette.mColors[0].value[2] == 0x34);
- REQUIRE(palette.mColors[0].value[3] == 0x00);
- }
-
- SECTION("palette test 6")
- {
- DyePalette palette("@12ff3456", 8);
- REQUIRE(palette.mColors.size() == 1);
- REQUIRE(palette.mColors[0].value[0] == 0x12);
- REQUIRE(palette.mColors[0].value[1] == 0xff);
- REQUIRE(palette.mColors[0].value[2] == 0x34);
- REQUIRE(palette.mColors[0].value[3] == 0x56);
- }
-
- SECTION("palette test 7")
- {
- DyePalette palette("@12ff34,002211", 6);
- REQUIRE(palette.mColors.size() == 2);
- REQUIRE(palette.mColors[0].value[0] == 0x12);
- REQUIRE(palette.mColors[0].value[1] == 0xff);
- REQUIRE(palette.mColors[0].value[2] == 0x34);
- REQUIRE(palette.mColors[0].value[3] == 0x00);
-
- REQUIRE(palette.mColors[1].value[0] == 0x00);
- REQUIRE(palette.mColors[1].value[1] == 0x22);
- REQUIRE(palette.mColors[1].value[2] == 0x11);
- REQUIRE(palette.mColors[1].value[3] == 0x00);
- }
-
- SECTION("palette test 8")
- {
- DyePalette palette("@12ff3412,00221133", 8);
- REQUIRE(palette.mColors.size() == 2);
- REQUIRE(palette.mColors[0].value[0] == 0x12);
- REQUIRE(palette.mColors[0].value[1] == 0xff);
- REQUIRE(palette.mColors[0].value[2] == 0x34);
- REQUIRE(palette.mColors[0].value[3] == 0x12);
-
- REQUIRE(palette.mColors[1].value[0] == 0x00);
- REQUIRE(palette.mColors[1].value[1] == 0x22);
- REQUIRE(palette.mColors[1].value[2] == 0x11);
- REQUIRE(palette.mColors[1].value[3] == 0x33);
- }
-
- SECTION("palette test 9")
- {
- DyePalette palette("@12ff34,", 6);
- REQUIRE(palette.mColors.size() == 1);
- REQUIRE(palette.mColors[0].value[0] == 0x12);
- REQUIRE(palette.mColors[0].value[1] == 0xff);
- REQUIRE(palette.mColors[0].value[2] == 0x34);
- REQUIRE(palette.mColors[0].value[3] == 0x00);
- }
-
- SECTION("palette test 10")
- {
- DyePalette palette("@12ff3456,", 8);
- REQUIRE(palette.mColors.size() == 1);
- REQUIRE(palette.mColors[0].value[0] == 0x12);
- REQUIRE(palette.mColors[0].value[1] == 0xff);
- REQUIRE(palette.mColors[0].value[2] == 0x34);
- REQUIRE(palette.mColors[0].value[3] == 0x56);
- }
-
- SECTION("palette test 11")
- {
- DyePalette palette("@,,,12ff3412,,00221133", 8);
- REQUIRE(palette.mColors.size() == 2);
- REQUIRE(palette.mColors[0].value[0] == 0x12);
- REQUIRE(palette.mColors[0].value[1] == 0xff);
- REQUIRE(palette.mColors[0].value[2] == 0x34);
- REQUIRE(palette.mColors[0].value[3] == 0x12);
-
- REQUIRE(palette.mColors[1].value[0] == 0x00);
- REQUIRE(palette.mColors[1].value[1] == 0x22);
- REQUIRE(palette.mColors[1].value[2] == 0x11);
- REQUIRE(palette.mColors[1].value[3] == 0x33);
- }
-
- SECTION("palette test 12")
- {
- DyePalette palette("@Untitled1,334455", 6);
- REQUIRE(palette.mColors.size() == 2);
- REQUIRE(palette.mColors[0].value[0] == 47);
- REQUIRE(palette.mColors[0].value[1] == 56);
- REQUIRE(palette.mColors[0].value[2] == 46);
- REQUIRE(palette.mColors[0].value[3] == 255);
-
- REQUIRE(palette.mColors[1].value[0] == 0x33);
- REQUIRE(palette.mColors[1].value[1] == 0x44);
- REQUIRE(palette.mColors[1].value[2] == 0x55);
- REQUIRE(palette.mColors[1].value[3] == 0x00);
- }
-
- SECTION("palette test 13")
- {
- DyePalette palette("@Untitled1,33445566", 8);
- REQUIRE(palette.mColors.size() == 2);
- REQUIRE(palette.mColors[0].value[0] == 47);
- REQUIRE(palette.mColors[0].value[1] == 56);
- REQUIRE(palette.mColors[0].value[2] == 46);
- REQUIRE(palette.mColors[0].value[3] == 255);
-
- REQUIRE(palette.mColors[1].value[0] == 0x33);
- REQUIRE(palette.mColors[1].value[1] == 0x44);
- REQUIRE(palette.mColors[1].value[2] == 0x55);
- REQUIRE(palette.mColors[1].value[3] == 0x66);
- }
-
- SECTION("palette test 14")
- {
- DyePalette palette("@+77,Untitled1", 8);
- REQUIRE(palette.mColors.size() == 1);
- REQUIRE(palette.mColors[0].value[0] == 47);
- REQUIRE(palette.mColors[0].value[1] == 56);
- REQUIRE(palette.mColors[0].value[2] == 46);
- REQUIRE(palette.mColors[0].value[3] == 0x77);
- }
-
- SECTION("palette test 15")
- {
- DyePalette palette("@+87,Untitled1,Untitled8", 8);
- REQUIRE(palette.mColors.size() == 2);
- REQUIRE(palette.mColors[0].value[0] == 47);
- REQUIRE(palette.mColors[0].value[1] == 56);
- REQUIRE(palette.mColors[0].value[2] == 46);
- REQUIRE(palette.mColors[0].value[3] == 0x87);
-
- REQUIRE(palette.mColors[1].value[0] == 0);
- REQUIRE(palette.mColors[1].value[1] == 0);
- REQUIRE(palette.mColors[1].value[2] == 255);
- REQUIRE(palette.mColors[1].value[3] == 0x87);
- }
-
- SECTION("palette test 16")
- {
- DyePalette palette("@+87,Untitled1,+34,Untitled8", 8);
- REQUIRE(palette.mColors.size() == 2);
- REQUIRE(palette.mColors[0].value[0] == 47);
- REQUIRE(palette.mColors[0].value[1] == 56);
- REQUIRE(palette.mColors[0].value[2] == 46);
- REQUIRE(palette.mColors[0].value[3] == 0x87);
-
- REQUIRE(palette.mColors[1].value[0] == 0);
- REQUIRE(palette.mColors[1].value[1] == 0);
- REQUIRE(palette.mColors[1].value[2] == 255);
- REQUIRE(palette.mColors[1].value[3] == 0x34);
- }
-
- SECTION("palette test 17")
- {
- DyePalette palette("@+12,+23,+77,Untitled1", 8);
- REQUIRE(palette.mColors.size() == 1);
- REQUIRE(palette.mColors[0].value[0] == 47);
- REQUIRE(palette.mColors[0].value[1] == 56);
- REQUIRE(palette.mColors[0].value[2] == 46);
- REQUIRE(palette.mColors[0].value[3] == 0x77);
- }
- delete2(client);
- VirtFs::unmountDirSilent("data");
- VirtFs::unmountDirSilent("../data");
- VirtFs::unmountDirSilent("data/test");
- VirtFs::unmountDirSilent("../data/test");
-}
diff --git a/src/unittests/resources/map/maplayer/draw.cc b/src/unittests/resources/map/maplayer/draw.cc
deleted file mode 100644
index 9b946b0c9..000000000
--- a/src/unittests/resources/map/maplayer/draw.cc
+++ /dev/null
@@ -1,580 +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 "unittests/unittests.h"
-
-#include "configmanager.h"
-#include "dirs.h"
-
-#include "unittests/render/mockgraphics.h"
-
-#include "resources/image/image.h"
-
-#include "resources/map/map.h"
-#include "resources/map/maplayer.h"
-
-#include "debug.h"
-
-TEST_CASE("MapLayer draw", "")
-{
- Dirs::initRootDir();
- Dirs::initHomeDir();
-
- ConfigManager::initConfiguration();
-
- Image *const img1 = new Image(32, 32);
- Image *const img2 = new Image(32, 32);
- Image *const img3 = new Image(32, 32);
- Map *map = nullptr;
- MapLayer *layer = nullptr;
- MockGraphics *const mock = new MockGraphics;
-
- SECTION("simple 1")
- {
- map = new Map("map",
- 1, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 1, 1,
- false,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- map->addLayer(layer);
- layer->updateCache(1, 1);
-
- layer->draw(mock,
- 0, 0,
- 1, 1,
- 0, 0);
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 0);
- REQUIRE(mock->mDraws[0].y == 0);
- REQUIRE(mock->mDraws[0].image == img1);
-
- mock->mDraws.clear();
- layer->draw(mock,
- 0, 0,
- 1, 1,
- 10, 5);
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == -10);
- REQUIRE(mock->mDraws[0].y == -5);
- REQUIRE(mock->mDraws[0].image == img1);
-
- mock->mDraws.clear();
- layer->draw(mock,
- 0, 0,
- 1, 1,
- -10, -5);
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 10);
- REQUIRE(mock->mDraws[0].y == 5);
- REQUIRE(mock->mDraws[0].image == img1);
- }
-
- SECTION("simple 2")
- {
- map = new Map("map",
- 2, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 2, 1,
- false,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- map->addLayer(layer);
- layer->updateCache(2, 1);
-
- layer->draw(mock,
- 0, 0,
- 2, 1,
- 0, 0);
-
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 0);
- REQUIRE(mock->mDraws[0].y == 0);
- REQUIRE(mock->mDraws[0].image == img1);
-
- mock->mDraws.clear();
- layer->draw(mock,
- 0, 0,
- 2, 1,
- 10, 5);
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == -10);
- REQUIRE(mock->mDraws[0].y == -5);
- REQUIRE(mock->mDraws[0].image == img1);
-
- mock->mDraws.clear();
- layer->draw(mock,
- 0, 0,
- 2, 1,
- -10, -5);
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 10);
- REQUIRE(mock->mDraws[0].y == 5);
- REQUIRE(mock->mDraws[0].image == img1);
- }
-
- SECTION("simple 3")
- {
- map = new Map("map",
- 2, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 2, 1,
- false,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- layer->setTile(1, 0, img2);
- map->addLayer(layer);
- layer->updateCache(2, 1);
-
- layer->draw(mock,
- 0, 0,
- 2, 1,
- 0, 0);
- REQUIRE(mock->mDraws.size() == 2);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 0);
- REQUIRE(mock->mDraws[0].y == 0);
- REQUIRE(mock->mDraws[0].image == img1);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 32);
- REQUIRE(mock->mDraws[1].y == 0);
- REQUIRE(mock->mDraws[1].image == img2);
-
- mock->mDraws.clear();
- layer->draw(mock,
- 0, 0,
- 2, 1,
- -10, -20);
- REQUIRE(mock->mDraws.size() == 2);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 10);
- REQUIRE(mock->mDraws[0].y == 20);
- REQUIRE(mock->mDraws[0].image == img1);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 42);
- REQUIRE(mock->mDraws[1].y == 20);
- REQUIRE(mock->mDraws[1].image == img2);
- }
-
- SECTION("simple 4")
- {
- map = new Map("map",
- 2, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 2, 1,
- false,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- layer->setTile(1, 0, img1);
- map->addLayer(layer);
- layer->updateCache(2, 1);
-
- layer->draw(mock,
- 0, 0,
- 2, 1,
- 0, 0);
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[0].x == 0);
- REQUIRE(mock->mDraws[0].y == 0);
- REQUIRE(mock->mDraws[0].width == 64);
- REQUIRE(mock->mDraws[0].height == 32);
- REQUIRE(mock->mDraws[0].image == img1);
-
- mock->mDraws.clear();
- layer->draw(mock,
- 0, 0,
- 2, 1,
- -10, 20);
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[0].x == 10);
- REQUIRE(mock->mDraws[0].y == -20);
- REQUIRE(mock->mDraws[0].width == 64);
- REQUIRE(mock->mDraws[0].height == 32);
- REQUIRE(mock->mDraws[0].image == img1);
- }
-
- SECTION("simple 4.2")
- {
- map = new Map("map",
- 3, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 3, 1,
- false,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- layer->setTile(2, 0, img1);
- map->addLayer(layer);
- layer->updateCache(3, 1);
-
- layer->draw(mock,
- 0, 0,
- 3, 1,
- 0, 0);
- REQUIRE(mock->mDraws.size() == 2);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 0);
- REQUIRE(mock->mDraws[0].y == 0);
- REQUIRE(mock->mDraws[0].image == img1);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 64);
- REQUIRE(mock->mDraws[1].y == 0);
- REQUIRE(mock->mDraws[1].image == img1);
-
- mock->mDraws.clear();
- layer->draw(mock,
- 0, 0,
- 3, 1,
- 10, -20);
- REQUIRE(mock->mDraws.size() == 2);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == -10);
- REQUIRE(mock->mDraws[0].y == 20);
- REQUIRE(mock->mDraws[0].image == img1);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 54);
- REQUIRE(mock->mDraws[1].y == 20);
- REQUIRE(mock->mDraws[1].image == img1);
- }
-
- SECTION("simple 5")
- {
- map = new Map("map",
- 3, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 3, 1,
- false,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- layer->setTile(1, 0, img1);
- map->addLayer(layer);
- layer->updateCache(3, 1);
-
- layer->draw(mock,
- 0, 0,
- 3, 1,
- 0, 0);
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[0].x == 0);
- REQUIRE(mock->mDraws[0].y == 0);
- REQUIRE(mock->mDraws[0].width == 64);
- REQUIRE(mock->mDraws[0].height == 32);
- REQUIRE(mock->mDraws[0].image == img1);
-
- mock->mDraws.clear();
- layer->draw(mock,
- 0, 0,
- 3, 1,
- -10, 20);
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[0].x == 10);
- REQUIRE(mock->mDraws[0].y == -20);
- REQUIRE(mock->mDraws[0].width == 64);
- REQUIRE(mock->mDraws[0].height == 32);
- REQUIRE(mock->mDraws[0].image == img1);
- }
-
- SECTION("simple 6")
- {
- map = new Map("map",
- 3, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 3, 1,
- false,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- layer->setTile(1, 0, img1);
- layer->setTile(2, 0, img2);
- map->addLayer(layer);
- layer->updateCache(3, 1);
-
- layer->draw(mock,
- 0, 0,
- 3, 1,
- 0, 0);
- REQUIRE(mock->mDraws.size() == 2);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[0].x == 0);
- REQUIRE(mock->mDraws[0].y == 0);
- REQUIRE(mock->mDraws[0].width == 64);
- REQUIRE(mock->mDraws[0].height == 32);
- REQUIRE(mock->mDraws[0].image == img1);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 64);
- REQUIRE(mock->mDraws[1].y == 0);
- REQUIRE(mock->mDraws[1].image == img2);
-
- mock->mDraws.clear();
- layer->draw(mock,
- 0, 0,
- 3, 1,
- -10, 20);
- REQUIRE(mock->mDraws.size() == 2);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[0].x == 10);
- REQUIRE(mock->mDraws[0].y == -20);
- REQUIRE(mock->mDraws[0].width == 64);
- REQUIRE(mock->mDraws[0].height == 32);
- REQUIRE(mock->mDraws[0].image == img1);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 74);
- REQUIRE(mock->mDraws[1].y == -20);
- REQUIRE(mock->mDraws[1].image == img2);
- }
-
- SECTION("simple 7")
- {
- map = new Map("map",
- 3, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 3, 1,
- false,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- layer->setTile(1, 0, img1);
- layer->setTile(2, 0, img2);
- map->addLayer(layer);
- TileInfo *const tiles = layer->getTiles();
- tiles[0].isEnabled = false;
- layer->updateCache(3, 1);
-
- layer->draw(mock,
- 0, 0,
- 3, 1,
- 0, 0);
- REQUIRE(mock->mDraws.size() == 2);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 32);
- REQUIRE(mock->mDraws[0].y == 0);
- REQUIRE(mock->mDraws[0].image == img1);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 64);
- REQUIRE(mock->mDraws[1].y == 0);
- REQUIRE(mock->mDraws[1].image == img2);
-
- mock->mDraws.clear();
- layer->draw(mock,
- 0, 0,
- 3, 1,
- -10, 20);
- REQUIRE(mock->mDraws.size() == 2);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 42);
- REQUIRE(mock->mDraws[0].y == -20);
- REQUIRE(mock->mDraws[0].image == img1);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 74);
- REQUIRE(mock->mDraws[1].y == -20);
- REQUIRE(mock->mDraws[1].image == img2);
- }
-
- SECTION("normal 1")
- {
- const int maxX = 100;
- const int maxY = 100;
- map = new Map("map",
- maxX, maxY,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- maxX, maxY,
- false,
- 0,
- 0);
- layer->setTile(1, 10, img1);
- layer->setTile(2, 10, img1);
- layer->setTile(3, 10, img1);
- layer->setTile(4, 10, img2);
- layer->setTile(5, 10, nullptr);
- layer->setTile(6, 10, img2);
- layer->setTile(7, 10, nullptr);
- layer->setTile(8, 10, nullptr);
- layer->setTile(9, 10, img2);
- layer->setTile(10, 10, img2);
- layer->setTile(11, 10, img3);
- layer->setTile(12, 10, nullptr);
- layer->setTile(13, 10, nullptr);
- layer->setTile(14, 10, nullptr);
- layer->setTile(15, 10, img1);
- layer->setTile(16, 10, img1);
- layer->setTile(17, 10, img1);
- map->addLayer(layer);
- layer->updateCache(maxX, maxY);
-
- layer->draw(mock,
- 0, 0,
- maxX, maxY,
- 0, 0);
- REQUIRE(mock->mDraws.size() == 6);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[0].x == 32 * 1);
- REQUIRE(mock->mDraws[0].y == 32 * 10);
- REQUIRE(mock->mDraws[0].width == 96);
- REQUIRE(mock->mDraws[0].height == 32);
- REQUIRE(mock->mDraws[0].image == img1);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 32 * 4);
- REQUIRE(mock->mDraws[1].y == 32 * 10);
- REQUIRE(mock->mDraws[1].image == img2);
- REQUIRE(mock->mDraws[2].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[2].x == 32 * 6);
- REQUIRE(mock->mDraws[2].y == 32 * 10);
- REQUIRE(mock->mDraws[2].image == img2);
- REQUIRE(mock->mDraws[3].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[3].x == 32 * 9);
- REQUIRE(mock->mDraws[3].y == 32 * 10);
- REQUIRE(mock->mDraws[3].width == 64);
- REQUIRE(mock->mDraws[3].height == 32);
- REQUIRE(mock->mDraws[3].image == img2);
- REQUIRE(mock->mDraws[4].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[4].x == 32 * 11);
- REQUIRE(mock->mDraws[4].y == 32 * 10);
- REQUIRE(mock->mDraws[4].image == img3);
- REQUIRE(mock->mDraws[5].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[5].x == 32 * 15);
- REQUIRE(mock->mDraws[5].y == 32 * 10);
- REQUIRE(mock->mDraws[5].width == 96);
- REQUIRE(mock->mDraws[5].height == 32);
- REQUIRE(mock->mDraws[5].image == img1);
-
- mock->mDraws.clear();
- layer->draw(mock,
- 0, 0,
- maxX, maxY,
- -10, 20);
- REQUIRE(mock->mDraws.size() == 6);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[0].x == 32 * 1 + 10);
- REQUIRE(mock->mDraws[0].y == 32 * 10 - 20);
- REQUIRE(mock->mDraws[0].width == 96);
- REQUIRE(mock->mDraws[0].height == 32);
- REQUIRE(mock->mDraws[0].image == img1);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 32 * 4 + 10);
- REQUIRE(mock->mDraws[1].y == 32 * 10 - 20);
- REQUIRE(mock->mDraws[1].image == img2);
- REQUIRE(mock->mDraws[2].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[2].x == 32 * 6 + 10);
- REQUIRE(mock->mDraws[2].y == 32 * 10 - 20);
- REQUIRE(mock->mDraws[2].image == img2);
- REQUIRE(mock->mDraws[3].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[3].x == 32 * 9 + 10);
- REQUIRE(mock->mDraws[3].y == 32 * 10 - 20);
- REQUIRE(mock->mDraws[3].width == 64);
- REQUIRE(mock->mDraws[3].height == 32);
- REQUIRE(mock->mDraws[3].image == img2);
- REQUIRE(mock->mDraws[4].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[4].x == 32 * 11 + 10);
- REQUIRE(mock->mDraws[4].y == 32 * 10 - 20);
- REQUIRE(mock->mDraws[4].image == img3);
- REQUIRE(mock->mDraws[5].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[5].x == 32 * 15 + 10);
- REQUIRE(mock->mDraws[5].y == 32 * 10 - 20);
- REQUIRE(mock->mDraws[5].width == 96);
- REQUIRE(mock->mDraws[5].height == 32);
- REQUIRE(mock->mDraws[5].image == img1);
- }
-
- SECTION("normal2")
- {
- const int maxX = 100;
- const int maxY = 100;
- map = new Map("map",
- maxX, maxY,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- maxX, maxY,
- false,
- 0,
- 0);
- TileInfo *const tiles = layer->getTiles();
- map->addLayer(layer);
- for (int x = 0; x < maxX; x ++)
- {
- for (int y = 0; y < maxY; y ++)
- {
- layer->setTile(x, y, img1);
- tiles[y * maxX + x].isEnabled = false;
- }
- }
- tiles[10 * maxX + 41].isEnabled = true;
- layer->updateCache(maxX, maxY);
-
- layer->draw(mock,
- 0, 0,
- maxX, maxY,
- 0, 0);
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 32 * 41);
- REQUIRE(mock->mDraws[0].y == 32 * 10);
-
- mock->mDraws.clear();
- layer->draw(mock,
- 0, 0,
- maxX, maxY,
- -10, 20);
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 32 * 41 + 10);
- REQUIRE(mock->mDraws[0].y == 32 * 10 - 20);
- }
-
- delete map;
- delete img1;
- delete img2;
- delete img3;
- delete mock;
-}
diff --git a/src/unittests/resources/map/maplayer/drawfringenormal.cc b/src/unittests/resources/map/maplayer/drawfringenormal.cc
deleted file mode 100644
index 372f602b0..000000000
--- a/src/unittests/resources/map/maplayer/drawfringenormal.cc
+++ /dev/null
@@ -1,529 +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 "unittests/unittests.h"
-
-#include "configmanager.h"
-#include "configuration.h"
-#include "dirs.h"
-#include "graphicsmanager.h"
-
-#include "being/localplayer.h"
-
-#include "enums/resources/map/mapitemtype.h"
-
-#include "fs/virtfs/fs.h"
-
-#include "gui/theme.h"
-
-#include "unittests/render/mockgraphics.h"
-
-#include "utils/delete2.h"
-#include "utils/env.h"
-
-#include "resources/resourcemanager/resourcemanager.h"
-
-#include "resources/sdlimagehelper.h"
-
-#include "resources/image/image.h"
-
-#include "resources/map/map.h"
-#include "resources/map/maplayer.h"
-#include "resources/map/speciallayer.h"
-
-#include "debug.h"
-
-TEST_CASE("MapLayer drawFringe normal", "")
-{
- setEnv("SDL_VIDEODRIVER", "dummy");
-
- VirtFs::mountDirSilent("data", Append_false);
- VirtFs::mountDirSilent("../data", Append_false);
-
- imageHelper = new SDLImageHelper;
-
- Dirs::initRootDir();
- Dirs::initHomeDir();
-
- setBrandingDefaults(branding);
- ConfigManager::initConfiguration();
-
-#ifdef USE_SDL2
- SDLImageHelper::setRenderer(graphicsManager.createRenderer(
- graphicsManager.createWindow(640, 480, 0,
- SDL_WINDOW_SHOWN | SDL_SWSURFACE), SDL_RENDERER_SOFTWARE));
-#else // USE_SDL2
-
- graphicsManager.createWindow(640, 480, 0, SDL_ANYFORMAT | SDL_SWSURFACE);
-#endif // USE_SDL2
-
- theme = new Theme;
- Theme::selectSkin();
-
- localPlayer = new LocalPlayer(static_cast<BeingId>(1),
- BeingTypeId_zero);
-
- Image *const img1 = new Image(32, 32);
- Image *const img2 = new Image(32, 32);
- Image *const img3 = new Image(32, 32);
- Map *map = nullptr;
- MapLayer *layer = nullptr;
- MockGraphics *const mock = new MockGraphics;
- const Actors actors;
-
- SECTION("normal 1")
- {
- const int maxX = 100;
- const int maxY = 100;
- map = new Map("map",
- maxX, maxY,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- maxX, maxY,
- true,
- 0,
- 0);
- layer->setTile(1, 10, img1);
- layer->setTile(2, 10, img1);
- layer->setTile(3, 10, img1);
- layer->setTile(4, 10, img2);
- layer->setTile(5, 10, nullptr);
- layer->setTile(6, 10, img2);
- layer->setTile(7, 10, nullptr);
- layer->setTile(8, 10, nullptr);
- layer->setTile(9, 10, img2);
- layer->setTile(10, 10, img2);
- layer->setTile(11, 10, img3);
- layer->setTile(12, 10, nullptr);
- layer->setTile(13, 10, nullptr);
- layer->setTile(14, 10, nullptr);
- layer->setTile(15, 10, img1);
- layer->setTile(16, 10, img1);
- layer->setTile(17, 10, img1);
- map->addLayer(layer);
- layer->setSpecialLayer(map->getSpecialLayer());
- layer->setTempLayer(map->getTempLayer());
- layer->updateCache(maxX, maxY);
-
- layer->drawFringe(mock,
- 0, 0,
- maxX, maxY,
- 0, 0,
- actors);
- REQUIRE(mock->mDraws.size() == 6);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[0].x == 32 * 1);
- REQUIRE(mock->mDraws[0].y == 32 * 10);
- REQUIRE(mock->mDraws[0].width == 96);
- REQUIRE(mock->mDraws[0].height == 32);
- REQUIRE(mock->mDraws[0].image == img1);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 32 * 4);
- REQUIRE(mock->mDraws[1].y == 32 * 10);
- REQUIRE(mock->mDraws[1].image == img2);
- REQUIRE(mock->mDraws[2].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[2].x == 32 * 6);
- REQUIRE(mock->mDraws[2].y == 32 * 10);
- REQUIRE(mock->mDraws[2].image == img2);
- REQUIRE(mock->mDraws[3].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[3].x == 32 * 9);
- REQUIRE(mock->mDraws[3].y == 32 * 10);
- REQUIRE(mock->mDraws[3].width == 64);
- REQUIRE(mock->mDraws[3].height == 32);
- REQUIRE(mock->mDraws[3].image == img2);
- REQUIRE(mock->mDraws[4].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[4].x == 32 * 11);
- REQUIRE(mock->mDraws[4].y == 32 * 10);
- REQUIRE(mock->mDraws[4].image == img3);
- REQUIRE(mock->mDraws[5].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[5].x == 32 * 15);
- REQUIRE(mock->mDraws[5].y == 32 * 10);
- REQUIRE(mock->mDraws[5].width == 96);
- REQUIRE(mock->mDraws[5].height == 32);
- REQUIRE(mock->mDraws[5].image == img1);
-
- mock->mDraws.clear();
- layer->drawFringe(mock,
- 0, 0,
- maxX, maxY,
- -10, 20,
- actors);
- REQUIRE(mock->mDraws.size() == 6);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[0].x == 32 * 1 + 10);
- REQUIRE(mock->mDraws[0].y == 32 * 10 - 20);
- REQUIRE(mock->mDraws[0].width == 96);
- REQUIRE(mock->mDraws[0].height == 32);
- REQUIRE(mock->mDraws[0].image == img1);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 32 * 4 + 10);
- REQUIRE(mock->mDraws[1].y == 32 * 10 - 20);
- REQUIRE(mock->mDraws[1].image == img2);
- REQUIRE(mock->mDraws[2].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[2].x == 32 * 6 + 10);
- REQUIRE(mock->mDraws[2].y == 32 * 10 - 20);
- REQUIRE(mock->mDraws[2].image == img2);
- REQUIRE(mock->mDraws[3].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[3].x == 32 * 9 + 10);
- REQUIRE(mock->mDraws[3].y == 32 * 10 - 20);
- REQUIRE(mock->mDraws[3].width == 64);
- REQUIRE(mock->mDraws[3].height == 32);
- REQUIRE(mock->mDraws[3].image == img2);
- REQUIRE(mock->mDraws[4].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[4].x == 32 * 11 + 10);
- REQUIRE(mock->mDraws[4].y == 32 * 10 - 20);
- REQUIRE(mock->mDraws[4].image == img3);
- REQUIRE(mock->mDraws[5].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[5].x == 32 * 15 + 10);
- REQUIRE(mock->mDraws[5].y == 32 * 10 - 20);
- REQUIRE(mock->mDraws[5].width == 96);
- REQUIRE(mock->mDraws[5].height == 32);
- REQUIRE(mock->mDraws[5].image == img1);
- }
-
- SECTION("normal2")
- {
- const int maxX = 100;
- const int maxY = 100;
- map = new Map("map",
- maxX, maxY,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- maxX, maxY,
- true,
- 0,
- 0);
- TileInfo *const tiles = layer->getTiles();
- map->addLayer(layer);
- layer->setSpecialLayer(map->getSpecialLayer());
- layer->setTempLayer(map->getTempLayer());
- for (int x = 0; x < maxX; x ++)
- {
- for (int y = 0; y < maxY; y ++)
- {
- layer->setTile(x, y, img1);
- tiles[y * maxX + x].isEnabled = false;
- }
- }
- tiles[10 * maxX + 41].isEnabled = true;
- layer->updateCache(maxX, maxY);
-
- layer->drawFringe(mock,
- 0, 0,
- maxX, maxY,
- 0, 0,
- actors);
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 32 * 41);
- REQUIRE(mock->mDraws[0].y == 32 * 10);
-
- mock->mDraws.clear();
- layer->drawFringe(mock,
- 0, 0,
- maxX, maxY,
- -10, 20,
- actors);
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 32 * 41 + 10);
- REQUIRE(mock->mDraws[0].y == 32 * 10 - 20);
- }
-
- SECTION("normal 3")
- {
- const int maxX = 100;
- const int maxY = 100;
- map = new Map("map",
- maxX, maxY,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- maxX, maxY,
- true,
- 0,
- 0);
- layer->setTile(1, 10, img1);
- layer->setTile(2, 10, img1);
- layer->setTile(3, 10, img1);
- layer->setTile(4, 10, img2);
- layer->setTile(5, 10, nullptr);
- layer->setTile(6, 10, img2);
- layer->setTile(7, 10, nullptr);
- layer->setTile(8, 10, nullptr);
- layer->setTile(9, 10, img2);
- layer->setTile(10, 10, img2);
- layer->setTile(11, 10, img3);
- layer->setTile(12, 10, nullptr);
- layer->setTile(13, 10, nullptr);
- layer->setTile(14, 10, nullptr);
- layer->setTile(15, 10, img1);
- layer->setTile(16, 10, img1);
- layer->setTile(17, 10, img1);
- map->addLayer(layer);
- SpecialLayer *const specialLayer = map->getSpecialLayer();
- SpecialLayer *const tempLayer = map->getTempLayer();
- layer->setSpecialLayer(specialLayer);
- layer->setTempLayer(tempLayer);
- specialLayer->setTile(1, 10, MapItemType::ARROW_UP);
- specialLayer->setTile(10, 10, MapItemType::ARROW_DOWN);
- specialLayer->updateCache();
- layer->updateCache(maxX, maxY);
-
- layer->drawFringe(mock,
- 0, 0,
- maxX, maxY,
- 0, 0,
- actors);
- REQUIRE(mock->mDraws.size() == 8);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[0].x == 32 * 1);
- REQUIRE(mock->mDraws[0].y == 32 * 10);
- REQUIRE(mock->mDraws[0].width == 96);
- REQUIRE(mock->mDraws[0].height == 32);
- REQUIRE(mock->mDraws[0].image == img1);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 32 * 1);
- REQUIRE(mock->mDraws[1].y == 32 * 10);
-// REQUIRE(mock->mDraws[1].image == img2);
- REQUIRE(mock->mDraws[2].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[2].x == 32 * 4);
- REQUIRE(mock->mDraws[2].y == 32 * 10);
- REQUIRE(mock->mDraws[2].image == img2);
- REQUIRE(mock->mDraws[3].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[3].x == 32 * 6);
- REQUIRE(mock->mDraws[3].y == 32 * 10);
- REQUIRE(mock->mDraws[3].image == img2);
- REQUIRE(mock->mDraws[4].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[4].x == 32 * 9);
- REQUIRE(mock->mDraws[4].y == 32 * 10);
- REQUIRE(mock->mDraws[4].width == 64);
- REQUIRE(mock->mDraws[4].height == 32);
- REQUIRE(mock->mDraws[4].image == img2);
- REQUIRE(mock->mDraws[5].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[5].x == 32 * 10);
- REQUIRE(mock->mDraws[5].y == 32 * 10);
-// REQUIRE(mock->mDraws[5].image == img2);
- REQUIRE(mock->mDraws[6].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[6].x == 32 * 11);
- REQUIRE(mock->mDraws[6].y == 32 * 10);
- REQUIRE(mock->mDraws[6].image == img3);
- REQUIRE(mock->mDraws[7].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[7].x == 32 * 15);
- REQUIRE(mock->mDraws[7].y == 32 * 10);
- REQUIRE(mock->mDraws[7].width == 96);
- REQUIRE(mock->mDraws[7].height == 32);
- REQUIRE(mock->mDraws[7].image == img1);
-
- mock->mDraws.clear();
- layer->drawFringe(mock,
- 0, 0,
- maxX, maxY,
- -10, 20,
- actors);
- REQUIRE(mock->mDraws.size() == 8);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[0].x == 32 * 1 + 10);
- REQUIRE(mock->mDraws[0].y == 32 * 10 - 20);
- REQUIRE(mock->mDraws[0].width == 96);
- REQUIRE(mock->mDraws[0].height == 32);
- REQUIRE(mock->mDraws[0].image == img1);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 32 * 1 + 10);
- REQUIRE(mock->mDraws[1].y == 32 * 10 - 20);
-// REQUIRE(mock->mDraws[1].image == img2);
- REQUIRE(mock->mDraws[2].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[2].x == 32 * 4 + 10);
- REQUIRE(mock->mDraws[2].y == 32 * 10 - 20);
- REQUIRE(mock->mDraws[2].image == img2);
- REQUIRE(mock->mDraws[3].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[3].x == 32 * 6 + 10);
- REQUIRE(mock->mDraws[3].y == 32 * 10 - 20);
- REQUIRE(mock->mDraws[3].image == img2);
- REQUIRE(mock->mDraws[4].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[4].x == 32 * 9 + 10);
- REQUIRE(mock->mDraws[4].y == 32 * 10 - 20);
- REQUIRE(mock->mDraws[4].width == 64);
- REQUIRE(mock->mDraws[4].height == 32);
- REQUIRE(mock->mDraws[4].image == img2);
- REQUIRE(mock->mDraws[5].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[5].x == 32 * 10 + 10);
- REQUIRE(mock->mDraws[5].y == 32 * 10 - 20);
-// REQUIRE(mock->mDraws[5].image == img2);
- REQUIRE(mock->mDraws[6].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[6].x == 32 * 11 + 10);
- REQUIRE(mock->mDraws[6].y == 32 * 10 - 20);
- REQUIRE(mock->mDraws[6].image == img3);
- REQUIRE(mock->mDraws[7].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[7].x == 32 * 15 + 10);
- REQUIRE(mock->mDraws[7].y == 32 * 10 - 20);
- REQUIRE(mock->mDraws[7].width == 96);
- REQUIRE(mock->mDraws[7].height == 32);
- REQUIRE(mock->mDraws[7].image == img1);
- }
-
- SECTION("normal 4")
- {
- const int maxX = 100;
- const int maxY = 100;
- map = new Map("map",
- maxX, maxY,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- maxX, maxY,
- true,
- 0,
- 0);
- layer->setTile(1, 10, img1);
- layer->setTile(2, 10, img1);
- layer->setTile(3, 10, img1);
- layer->setTile(4, 10, img2);
- layer->setTile(5, 10, nullptr);
- layer->setTile(6, 10, img2);
- layer->setTile(7, 10, nullptr);
- layer->setTile(8, 10, nullptr);
- layer->setTile(9, 10, img2);
- layer->setTile(10, 10, img2);
- layer->setTile(11, 10, img3);
- layer->setTile(12, 10, nullptr);
- layer->setTile(13, 10, nullptr);
- layer->setTile(14, 10, nullptr);
- layer->setTile(15, 10, img1);
- layer->setTile(16, 10, img1);
- layer->setTile(17, 10, img1);
- map->addLayer(layer);
- SpecialLayer *const specialLayer = map->getSpecialLayer();
- SpecialLayer *const tempLayer = map->getTempLayer();
- layer->setSpecialLayer(specialLayer);
- layer->setTempLayer(tempLayer);
- specialLayer->setTile(0, 10, MapItemType::ARROW_UP);
- specialLayer->setTile(10, 10, MapItemType::ARROW_DOWN);
- specialLayer->setTile(90, 10, MapItemType::ARROW_DOWN);
- specialLayer->updateCache();
- layer->updateCache(maxX, maxY);
-
- layer->drawFringe(mock,
- 0, 0,
- maxX - 20, maxY,
- 0, 0,
- actors);
- REQUIRE(mock->mDraws.size() == 8);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 32 * 0);
- REQUIRE(mock->mDraws[0].y == 32 * 10);
-// REQUIRE(mock->mDraws[0].image == img2);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[1].x == 32 * 1);
- REQUIRE(mock->mDraws[1].y == 32 * 10);
- REQUIRE(mock->mDraws[1].width == 96);
- REQUIRE(mock->mDraws[1].height == 32);
- REQUIRE(mock->mDraws[1].image == img1);
- REQUIRE(mock->mDraws[2].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[2].x == 32 * 4);
- REQUIRE(mock->mDraws[2].y == 32 * 10);
- REQUIRE(mock->mDraws[2].image == img2);
- REQUIRE(mock->mDraws[3].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[3].x == 32 * 6);
- REQUIRE(mock->mDraws[3].y == 32 * 10);
- REQUIRE(mock->mDraws[3].image == img2);
- REQUIRE(mock->mDraws[4].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[4].x == 32 * 9);
- REQUIRE(mock->mDraws[4].y == 32 * 10);
- REQUIRE(mock->mDraws[4].width == 64);
- REQUIRE(mock->mDraws[4].height == 32);
- REQUIRE(mock->mDraws[4].image == img2);
- REQUIRE(mock->mDraws[5].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[5].x == 32 * 10);
- REQUIRE(mock->mDraws[5].y == 32 * 10);
-// REQUIRE(mock->mDraws[5].image == img2);
- REQUIRE(mock->mDraws[6].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[6].x == 32 * 11);
- REQUIRE(mock->mDraws[6].y == 32 * 10);
- REQUIRE(mock->mDraws[6].image == img3);
- REQUIRE(mock->mDraws[7].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[7].x == 32 * 15);
- REQUIRE(mock->mDraws[7].y == 32 * 10);
- REQUIRE(mock->mDraws[7].width == 96);
- REQUIRE(mock->mDraws[7].height == 32);
- REQUIRE(mock->mDraws[7].image == img1);
-
- mock->mDraws.clear();
- layer->drawFringe(mock,
- 0, 0,
- maxX - 20, maxY,
- -10, 20,
- actors);
- REQUIRE(mock->mDraws.size() == 8);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 32 * 0 + 10);
- REQUIRE(mock->mDraws[0].y == 32 * 10 - 20);
-// REQUIRE(mock->mDraws[0].image == img2);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[1].x == 32 * 1 + 10);
- REQUIRE(mock->mDraws[1].y == 32 * 10 - 20);
- REQUIRE(mock->mDraws[1].width == 96);
- REQUIRE(mock->mDraws[1].height == 32);
- REQUIRE(mock->mDraws[1].image == img1);
- REQUIRE(mock->mDraws[2].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[2].x == 32 * 4 + 10);
- REQUIRE(mock->mDraws[2].y == 32 * 10 - 20);
- REQUIRE(mock->mDraws[2].image == img2);
- REQUIRE(mock->mDraws[3].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[3].x == 32 * 6 + 10);
- REQUIRE(mock->mDraws[3].y == 32 * 10 - 20);
- REQUIRE(mock->mDraws[3].image == img2);
- REQUIRE(mock->mDraws[4].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[4].x == 32 * 9 + 10);
- REQUIRE(mock->mDraws[4].y == 32 * 10 - 20);
- REQUIRE(mock->mDraws[4].width == 64);
- REQUIRE(mock->mDraws[4].height == 32);
- REQUIRE(mock->mDraws[4].image == img2);
- REQUIRE(mock->mDraws[5].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[5].x == 32 * 10 + 10);
- REQUIRE(mock->mDraws[5].y == 32 * 10 - 20);
-// REQUIRE(mock->mDraws[5].image == img2);
- REQUIRE(mock->mDraws[6].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[6].x == 32 * 11 + 10);
- REQUIRE(mock->mDraws[6].y == 32 * 10 - 20);
- REQUIRE(mock->mDraws[6].image == img3);
- REQUIRE(mock->mDraws[7].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[7].x == 32 * 15 + 10);
- REQUIRE(mock->mDraws[7].y == 32 * 10 - 20);
- REQUIRE(mock->mDraws[7].width == 96);
- REQUIRE(mock->mDraws[7].height == 32);
- REQUIRE(mock->mDraws[7].image == img1);
- }
-
- delete2(localPlayer);
- delete map;
- delete img1;
- delete img2;
- delete img3;
- delete mock;
- delete2(theme);
- GraphicsManager::deleteRenderers();
- ResourceManager::cleanOrphans(true);
- ResourceManager::deleteInstance();
- VirtFs::unmountDirSilent("data");
- VirtFs::unmountDirSilent("../data");
-}
diff --git a/src/unittests/resources/map/maplayer/drawfringesimple.cc b/src/unittests/resources/map/maplayer/drawfringesimple.cc
deleted file mode 100644
index 8773790c7..000000000
--- a/src/unittests/resources/map/maplayer/drawfringesimple.cc
+++ /dev/null
@@ -1,507 +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 "unittests/unittests.h"
-
-#include "configmanager.h"
-#include "configuration.h"
-#include "dirs.h"
-#include "graphicsmanager.h"
-
-#include "being/localplayer.h"
-
-#include "fs/virtfs/fs.h"
-
-#include "gui/theme.h"
-
-#include "unittests/render/mockgraphics.h"
-
-#include "utils/delete2.h"
-#include "utils/env.h"
-
-#include "resources/resourcemanager/resourcemanager.h"
-
-#include "resources/sdlimagehelper.h"
-
-#include "resources/image/image.h"
-
-#include "resources/map/map.h"
-#include "resources/map/maplayer.h"
-
-#include "debug.h"
-
-TEST_CASE("MapLayer drawFringe simple", "")
-{
- setEnv("SDL_VIDEODRIVER", "dummy");
-
- VirtFs::mountDirSilent("data", Append_false);
- VirtFs::mountDirSilent("../data", Append_false);
-
- imageHelper = new SDLImageHelper;
-
- Dirs::initRootDir();
- Dirs::initHomeDir();
-
- setBrandingDefaults(branding);
- ConfigManager::initConfiguration();
-
-#ifdef USE_SDL2
- SDLImageHelper::setRenderer(graphicsManager.createRenderer(
- graphicsManager.createWindow(640, 480, 0,
- SDL_WINDOW_SHOWN | SDL_SWSURFACE), SDL_RENDERER_SOFTWARE));
-#else // USE_SDL2
-
- graphicsManager.createWindow(640, 480, 0, SDL_ANYFORMAT | SDL_SWSURFACE);
-#endif // USE_SDL2
-
- theme = new Theme;
- Theme::selectSkin();
-
- localPlayer = new LocalPlayer(static_cast<BeingId>(1),
- BeingTypeId_zero);
-
- Image *const img1 = new Image(32, 32);
- Image *const img2 = new Image(32, 32);
- Image *const img3 = new Image(32, 32);
- Map *map = nullptr;
- MapLayer *layer = nullptr;
- MockGraphics *const mock = new MockGraphics;
- const Actors actors;
-
- SECTION("simple 1")
- {
- map = new Map("map",
- 1, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 1, 1,
- true,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- map->addLayer(layer);
- layer->setSpecialLayer(map->getSpecialLayer());
- layer->setTempLayer(map->getTempLayer());
- layer->updateCache(1, 1);
-
- layer->drawFringe(mock,
- 0, 0,
- 1, 1,
- 0, 0,
- actors);
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 0);
- REQUIRE(mock->mDraws[0].y == 0);
- REQUIRE(mock->mDraws[0].image == img1);
-
- mock->mDraws.clear();
- layer->drawFringe(mock,
- 0, 0,
- 1, 1,
- 10, 5,
- actors);
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == -10);
- REQUIRE(mock->mDraws[0].y == -5);
- REQUIRE(mock->mDraws[0].image == img1);
-
- mock->mDraws.clear();
- layer->drawFringe(mock,
- 0, 0,
- 1, 1,
- -10, -5,
- actors);
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 10);
- REQUIRE(mock->mDraws[0].y == 5);
- REQUIRE(mock->mDraws[0].image == img1);
- }
-
- SECTION("simple 2")
- {
- map = new Map("map",
- 2, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 2, 1,
- true,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- map->addLayer(layer);
- layer->setSpecialLayer(map->getSpecialLayer());
- layer->setTempLayer(map->getTempLayer());
- layer->updateCache(2, 1);
-
- layer->drawFringe(mock,
- 0, 0,
- 2, 1,
- 0, 0,
- actors);
-
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 0);
- REQUIRE(mock->mDraws[0].y == 0);
- REQUIRE(mock->mDraws[0].image == img1);
-
- mock->mDraws.clear();
- layer->drawFringe(mock,
- 0, 0,
- 2, 1,
- 10, 5,
- actors);
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == -10);
- REQUIRE(mock->mDraws[0].y == -5);
- REQUIRE(mock->mDraws[0].image == img1);
-
- mock->mDraws.clear();
- layer->drawFringe(mock,
- 0, 0,
- 2, 1,
- -10, -5,
- actors);
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 10);
- REQUIRE(mock->mDraws[0].y == 5);
- REQUIRE(mock->mDraws[0].image == img1);
- }
-
- SECTION("simple 3")
- {
- map = new Map("map",
- 2, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 2, 1,
- true,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- layer->setTile(1, 0, img2);
- map->addLayer(layer);
- layer->setSpecialLayer(map->getSpecialLayer());
- layer->setTempLayer(map->getTempLayer());
- layer->updateCache(2, 1);
-
- layer->drawFringe(mock,
- 0, 0,
- 2, 1,
- 0, 0,
- actors);
- REQUIRE(mock->mDraws.size() == 2);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 0);
- REQUIRE(mock->mDraws[0].y == 0);
- REQUIRE(mock->mDraws[0].image == img1);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 32);
- REQUIRE(mock->mDraws[1].y == 0);
- REQUIRE(mock->mDraws[1].image == img2);
-
- mock->mDraws.clear();
- layer->drawFringe(mock,
- 0, 0,
- 2, 1,
- -10, -20,
- actors);
- REQUIRE(mock->mDraws.size() == 2);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 10);
- REQUIRE(mock->mDraws[0].y == 20);
- REQUIRE(mock->mDraws[0].image == img1);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 42);
- REQUIRE(mock->mDraws[1].y == 20);
- REQUIRE(mock->mDraws[1].image == img2);
- }
-
- SECTION("simple 4")
- {
- map = new Map("map",
- 2, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 2, 1,
- true,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- layer->setTile(1, 0, img1);
- map->addLayer(layer);
- layer->setSpecialLayer(map->getSpecialLayer());
- layer->setTempLayer(map->getTempLayer());
- layer->updateCache(2, 1);
-
- layer->drawFringe(mock,
- 0, 0,
- 2, 1,
- 0, 0,
- actors);
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[0].x == 0);
- REQUIRE(mock->mDraws[0].y == 0);
- REQUIRE(mock->mDraws[0].width == 64);
- REQUIRE(mock->mDraws[0].height == 32);
- REQUIRE(mock->mDraws[0].image == img1);
-
- mock->mDraws.clear();
- layer->drawFringe(mock,
- 0, 0,
- 2, 1,
- -10, 20,
- actors);
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[0].x == 10);
- REQUIRE(mock->mDraws[0].y == -20);
- REQUIRE(mock->mDraws[0].width == 64);
- REQUIRE(mock->mDraws[0].height == 32);
- REQUIRE(mock->mDraws[0].image == img1);
- }
-
- SECTION("simple 4.2")
- {
- map = new Map("map",
- 3, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 3, 1,
- true,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- layer->setTile(2, 0, img1);
- map->addLayer(layer);
- layer->setSpecialLayer(map->getSpecialLayer());
- layer->setTempLayer(map->getTempLayer());
- layer->updateCache(3, 1);
-
- layer->drawFringe(mock,
- 0, 0,
- 3, 1,
- 0, 0,
- actors);
- REQUIRE(mock->mDraws.size() == 2);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 0);
- REQUIRE(mock->mDraws[0].y == 0);
- REQUIRE(mock->mDraws[0].image == img1);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 64);
- REQUIRE(mock->mDraws[1].y == 0);
- REQUIRE(mock->mDraws[1].image == img1);
-
- mock->mDraws.clear();
- layer->drawFringe(mock,
- 0, 0,
- 3, 1,
- 10, -20,
- actors);
- REQUIRE(mock->mDraws.size() == 2);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == -10);
- REQUIRE(mock->mDraws[0].y == 20);
- REQUIRE(mock->mDraws[0].image == img1);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 54);
- REQUIRE(mock->mDraws[1].y == 20);
- REQUIRE(mock->mDraws[1].image == img1);
- }
-
- SECTION("simple 5")
- {
- map = new Map("map",
- 3, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 3, 1,
- true,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- layer->setTile(1, 0, img1);
- map->addLayer(layer);
- layer->setSpecialLayer(map->getSpecialLayer());
- layer->setTempLayer(map->getTempLayer());
- layer->updateCache(3, 1);
-
- layer->drawFringe(mock,
- 0, 0,
- 3, 1,
- 0, 0,
- actors);
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[0].x == 0);
- REQUIRE(mock->mDraws[0].y == 0);
- REQUIRE(mock->mDraws[0].width == 64);
- REQUIRE(mock->mDraws[0].height == 32);
- REQUIRE(mock->mDraws[0].image == img1);
-
- mock->mDraws.clear();
- layer->drawFringe(mock,
- 0, 0,
- 3, 1,
- -10, 20,
- actors);
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[0].x == 10);
- REQUIRE(mock->mDraws[0].y == -20);
- REQUIRE(mock->mDraws[0].width == 64);
- REQUIRE(mock->mDraws[0].height == 32);
- REQUIRE(mock->mDraws[0].image == img1);
- }
-
- SECTION("simple 6")
- {
- map = new Map("map",
- 3, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 3, 1,
- true,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- layer->setTile(1, 0, img1);
- layer->setTile(2, 0, img2);
- map->addLayer(layer);
- layer->setSpecialLayer(map->getSpecialLayer());
- layer->setTempLayer(map->getTempLayer());
- layer->updateCache(3, 1);
-
- layer->drawFringe(mock,
- 0, 0,
- 3, 1,
- 0, 0,
- actors);
- REQUIRE(mock->mDraws.size() == 2);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[0].x == 0);
- REQUIRE(mock->mDraws[0].y == 0);
- REQUIRE(mock->mDraws[0].width == 64);
- REQUIRE(mock->mDraws[0].height == 32);
- REQUIRE(mock->mDraws[0].image == img1);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 64);
- REQUIRE(mock->mDraws[1].y == 0);
- REQUIRE(mock->mDraws[1].image == img2);
-
- mock->mDraws.clear();
- layer->drawFringe(mock,
- 0, 0,
- 3, 1,
- -10, 20,
- actors);
- REQUIRE(mock->mDraws.size() == 2);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawPattern);
- REQUIRE(mock->mDraws[0].x == 10);
- REQUIRE(mock->mDraws[0].y == -20);
- REQUIRE(mock->mDraws[0].width == 64);
- REQUIRE(mock->mDraws[0].height == 32);
- REQUIRE(mock->mDraws[0].image == img1);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 74);
- REQUIRE(mock->mDraws[1].y == -20);
- REQUIRE(mock->mDraws[1].image == img2);
- }
-
- SECTION("simple 7")
- {
- map = new Map("map",
- 3, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 3, 1,
- true,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- layer->setTile(1, 0, img1);
- layer->setTile(2, 0, img2);
- map->addLayer(layer);
- layer->setSpecialLayer(map->getSpecialLayer());
- layer->setTempLayer(map->getTempLayer());
- TileInfo *const tiles = layer->getTiles();
- tiles[0].isEnabled = false;
- layer->updateCache(3, 1);
-
- layer->drawFringe(mock,
- 0, 0,
- 3, 1,
- 0, 0,
- actors);
- REQUIRE(mock->mDraws.size() == 2);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 32);
- REQUIRE(mock->mDraws[0].y == 0);
- REQUIRE(mock->mDraws[0].image == img1);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 64);
- REQUIRE(mock->mDraws[1].y == 0);
- REQUIRE(mock->mDraws[1].image == img2);
-
- mock->mDraws.clear();
- layer->drawFringe(mock,
- 0, 0,
- 3, 1,
- -10, 20,
- actors);
- REQUIRE(mock->mDraws.size() == 2);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 42);
- REQUIRE(mock->mDraws[0].y == -20);
- REQUIRE(mock->mDraws[0].image == img1);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 74);
- REQUIRE(mock->mDraws[1].y == -20);
- REQUIRE(mock->mDraws[1].image == img2);
- }
-
- delete2(localPlayer);
- delete map;
- delete img1;
- delete img2;
- delete img3;
- delete mock;
- delete2(theme);
- GraphicsManager::deleteRenderers();
- ResourceManager::cleanOrphans(true);
- ResourceManager::deleteInstance();
- VirtFs::unmountDirSilent("data");
- VirtFs::unmountDirSilent("../data");
-}
diff --git a/src/unittests/resources/map/maplayer/drawspeciallayer1.cc b/src/unittests/resources/map/maplayer/drawspeciallayer1.cc
deleted file mode 100644
index c9dd51f1d..000000000
--- a/src/unittests/resources/map/maplayer/drawspeciallayer1.cc
+++ /dev/null
@@ -1,396 +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 "unittests/unittests.h"
-
-#include "configmanager.h"
-#include "configuration.h"
-#include "dirs.h"
-#include "graphicsmanager.h"
-
-#include "enums/resources/map/mapitemtype.h"
-
-#include "fs/virtfs/fs.h"
-
-#include "unittests/render/mockgraphics.h"
-
-#include "utils/env.h"
-
-#include "resources/resourcemanager/resourcemanager.h"
-
-#include "resources/sdlimagehelper.h"
-
-#include "resources/map/map.h"
-#include "resources/map/maplayer.h"
-#include "resources/map/speciallayer.h"
-
-#include "debug.h"
-
-TEST_CASE("MapLayer drawSpecialLayer (specialLayer)", "")
-{
- setEnv("SDL_VIDEODRIVER", "dummy");
-
- VirtFs::mountDirSilent("data", Append_false);
- VirtFs::mountDirSilent("../data", Append_false);
-
- imageHelper = new SDLImageHelper;
-
- Dirs::initRootDir();
- Dirs::initHomeDir();
-
- setBrandingDefaults(branding);
- ConfigManager::initConfiguration();
-
-#ifdef USE_SDL2
- SDLImageHelper::setRenderer(graphicsManager.createRenderer(
- graphicsManager.createWindow(640, 480, 0,
- SDL_WINDOW_SHOWN | SDL_SWSURFACE), SDL_RENDERER_SOFTWARE));
-#else // USE_SDL2
-
- graphicsManager.createWindow(640, 480, 0, SDL_ANYFORMAT | SDL_SWSURFACE);
-#endif // USE_SDL2
-
- Map *map = nullptr;
- MapLayer *layer = nullptr;
- SpecialLayer *specialLayer = nullptr;
- MockGraphics *const mock = new MockGraphics;
- const Actors actors;
-
- SECTION("simple 1")
- {
- map = new Map("map",
- 1, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 1, 1,
- true,
- 0,
- 0);
- map->addLayer(layer);
- layer->setSpecialLayer(map->getSpecialLayer());
- layer->setTempLayer(map->getTempLayer());
- specialLayer = map->getSpecialLayer();
-
- layer->drawSpecialLayer(mock,
- 0,
- 0, 1,
- 0, 0);
- REQUIRE(mock->mDraws.empty());
-
- specialLayer->setTile(0, 0, MapItemType::ARROW_UP);
- layer->drawSpecialLayer(mock,
- 0,
- 0, 1,
- 0, 0);
-// REQUIRE(mock->mDraws.size() == 1);
- }
-
- SECTION("simple 2")
- {
- map = new Map("map",
- 1, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 1, 1,
- true,
- 0,
- 0);
- map->addLayer(layer);
- layer->setSpecialLayer(map->getSpecialLayer());
- layer->setTempLayer(map->getTempLayer());
- specialLayer = map->getSpecialLayer();
- specialLayer->setTile(0, 0, MapItemType::ARROW_UP);
- specialLayer->updateCache();
-
- layer->drawSpecialLayer(mock,
- 0,
- 0, 1,
- 0, 0);
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 0);
- REQUIRE(mock->mDraws[0].y == 0);
- }
-
- SECTION("simple 3")
- {
- map = new Map("map",
- 2, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 2, 1,
- true,
- 0,
- 0);
- map->addLayer(layer);
- layer->setSpecialLayer(map->getSpecialLayer());
- layer->setTempLayer(map->getTempLayer());
- specialLayer = map->getSpecialLayer();
- specialLayer->setTile(0, 0, MapItemType::ARROW_UP);
- specialLayer->updateCache();
-
- layer->drawSpecialLayer(mock,
- 0,
- 0, 2,
- 0, 0);
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 0);
- REQUIRE(mock->mDraws[0].y == 0);
- }
-
- SECTION("simple 4")
- {
- map = new Map("map",
- 2, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 2, 1,
- true,
- 0,
- 0);
- map->addLayer(layer);
- layer->setSpecialLayer(map->getSpecialLayer());
- layer->setTempLayer(map->getTempLayer());
- specialLayer = map->getSpecialLayer();
- specialLayer->setTile(1, 0, MapItemType::ARROW_UP);
- specialLayer->updateCache();
-
- layer->drawSpecialLayer(mock,
- 0,
- 0, 2,
- 0, 0);
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 32);
- REQUIRE(mock->mDraws[0].y == 0);
- }
-
- SECTION("simple 5")
- {
- map = new Map("map",
- 2, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 2, 1,
- true,
- 0,
- 0);
- map->addLayer(layer);
- layer->setSpecialLayer(map->getSpecialLayer());
- layer->setTempLayer(map->getTempLayer());
- specialLayer = map->getSpecialLayer();
- specialLayer->setTile(0, 0, MapItemType::ARROW_UP);
- specialLayer->setTile(1, 0, MapItemType::ARROW_UP);
- specialLayer->updateCache();
-
- layer->drawSpecialLayer(mock,
- 0,
- 0, 2,
- 0, 0);
- REQUIRE(mock->mDraws.size() == 2);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 0);
- REQUIRE(mock->mDraws[0].y == 0);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 32);
- REQUIRE(mock->mDraws[1].y == 0);
- }
-
- SECTION("simple 6")
- {
- map = new Map("map",
- 3, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 3, 1,
- true,
- 0,
- 0);
- map->addLayer(layer);
- layer->setSpecialLayer(map->getSpecialLayer());
- layer->setTempLayer(map->getTempLayer());
- specialLayer = map->getSpecialLayer();
- specialLayer->setTile(0, 0, MapItemType::ARROW_UP);
- specialLayer->setTile(2, 0, MapItemType::ARROW_UP);
- specialLayer->updateCache();
-
- layer->drawSpecialLayer(mock,
- 0,
- 0, 3,
- 0, 0);
- REQUIRE(mock->mDraws.size() == 2);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 0);
- REQUIRE(mock->mDraws[0].y == 0);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 64);
- REQUIRE(mock->mDraws[1].y == 0);
- }
-
- SECTION("simple 7")
- {
- map = new Map("map",
- 3, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 3, 1,
- true,
- 0,
- 0);
- map->addLayer(layer);
- layer->setSpecialLayer(map->getSpecialLayer());
- layer->setTempLayer(map->getTempLayer());
- specialLayer = map->getSpecialLayer();
- specialLayer->setTile(1, 0, MapItemType::ARROW_UP);
- specialLayer->setTile(2, 0, MapItemType::ARROW_UP);
- specialLayer->updateCache();
-
- layer->drawSpecialLayer(mock,
- 0,
- 0, 3,
- 0, 0);
- REQUIRE(mock->mDraws.size() == 2);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 32);
- REQUIRE(mock->mDraws[0].y == 0);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 64);
- REQUIRE(mock->mDraws[1].y == 0);
- }
-
- SECTION("simple 8")
- {
- map = new Map("map",
- 3, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 3, 1,
- true,
- 0,
- 0);
- map->addLayer(layer);
- layer->setSpecialLayer(map->getSpecialLayer());
- layer->setTempLayer(map->getTempLayer());
- specialLayer = map->getSpecialLayer();
- specialLayer->setTile(0, 0, MapItemType::ARROW_UP);
- specialLayer->setTile(1, 0, MapItemType::ARROW_DOWN);
- specialLayer->setTile(2, 0, MapItemType::ARROW_UP);
- specialLayer->updateCache();
-
- layer->drawSpecialLayer(mock,
- 0,
- 0, 3,
- 0, 0);
- REQUIRE(mock->mDraws.size() == 3);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 0);
- REQUIRE(mock->mDraws[0].y == 0);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 32);
- REQUIRE(mock->mDraws[1].y == 0);
- REQUIRE(mock->mDraws[2].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[2].x == 64);
- REQUIRE(mock->mDraws[2].y == 0);
- }
-
- SECTION("normal 1")
- {
- const int maxX = 100;
- const int maxY = 50;
- map = new Map("map",
- maxX, maxY,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- maxX, maxY,
- true,
- 0,
- 0);
- map->addLayer(layer);
- layer->setSpecialLayer(map->getSpecialLayer());
- layer->setTempLayer(map->getTempLayer());
- specialLayer = map->getSpecialLayer();
- specialLayer->setTile(0, 5, MapItemType::ARROW_UP);
- specialLayer->setTile(1, 5, MapItemType::ARROW_DOWN);
- specialLayer->setTile(2, 5, MapItemType::ARROW_UP);
- specialLayer->setTile(3, 5, MapItemType::EMPTY);
- specialLayer->setTile(4, 5, MapItemType::EMPTY);
- specialLayer->setTile(6, 5, MapItemType::ARROW_LEFT);
- specialLayer->setTile(10, 20, MapItemType::ARROW_LEFT);
- specialLayer->updateCache();
-
- layer->drawSpecialLayer(mock,
- 5,
- 0, maxX,
- 0, 0);
- REQUIRE(mock->mDraws.size() == 4);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 0 * 32);
- REQUIRE(mock->mDraws[0].y == 5 * 32);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 1 * 32);
- REQUIRE(mock->mDraws[1].y == 5 * 32);
- REQUIRE(mock->mDraws[2].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[2].x == 2 * 32);
- REQUIRE(mock->mDraws[2].y == 5 * 32);
- REQUIRE(mock->mDraws[3].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[3].x == 6 * 32);
- REQUIRE(mock->mDraws[3].y == 5 * 32);
-
- mock->mDraws.clear();
- layer->drawSpecialLayer(mock,
- 4,
- 0, maxX,
- 0, 0);
- REQUIRE(mock->mDraws.empty());
-
- layer->drawSpecialLayer(mock,
- 6,
- 0, maxX,
- 0, 0);
- REQUIRE(mock->mDraws.empty());
-
- layer->drawSpecialLayer(mock,
- 20,
- 0, maxX,
- 0, 0);
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 10 * 32);
- REQUIRE(mock->mDraws[0].y == 20 * 32);
- }
-
- delete map;
- delete mock;
- GraphicsManager::deleteRenderers();
- ResourceManager::cleanOrphans(true);
- ResourceManager::deleteInstance();
- VirtFs::unmountDirSilent("data");
- VirtFs::unmountDirSilent("../data");
-}
diff --git a/src/unittests/resources/map/maplayer/drawspeciallayer2.cc b/src/unittests/resources/map/maplayer/drawspeciallayer2.cc
deleted file mode 100644
index e4e414a0d..000000000
--- a/src/unittests/resources/map/maplayer/drawspeciallayer2.cc
+++ /dev/null
@@ -1,402 +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 "unittests/unittests.h"
-
-#include "configmanager.h"
-#include "configuration.h"
-#include "dirs.h"
-#include "graphicsmanager.h"
-
-#include "enums/resources/map/mapitemtype.h"
-
-#include "fs/virtfs/fs.h"
-
-#include "unittests/render/mockgraphics.h"
-
-#include "utils/env.h"
-
-#include "resources/resourcemanager/resourcemanager.h"
-
-#include "resources/sdlimagehelper.h"
-
-#include "resources/map/map.h"
-#include "resources/map/maplayer.h"
-#include "resources/map/speciallayer.h"
-
-#include "debug.h"
-
-TEST_CASE("MapLayer drawSpecialLayer (tempLayer)", "")
-{
- setEnv("SDL_VIDEODRIVER", "dummy");
-
- VirtFs::mountDirSilent("data", Append_false);
- VirtFs::mountDirSilent("../data", Append_false);
-
- imageHelper = new SDLImageHelper;
-
- Dirs::initRootDir();
- Dirs::initHomeDir();
-
- setBrandingDefaults(branding);
- ConfigManager::initConfiguration();
-
-#ifdef USE_SDL2
- SDLImageHelper::setRenderer(graphicsManager.createRenderer(
- graphicsManager.createWindow(640, 480, 0,
- SDL_WINDOW_SHOWN | SDL_SWSURFACE), SDL_RENDERER_SOFTWARE));
-#else // USE_SDL2
-
- graphicsManager.createWindow(640, 480, 0, SDL_ANYFORMAT | SDL_SWSURFACE);
-#endif // USE_SDL2
-
- Map *map = nullptr;
- MapLayer *layer = nullptr;
- SpecialLayer *specialLayer = nullptr;
- MockGraphics *const mock = new MockGraphics;
- const Actors actors;
-
- SECTION("simple 1")
- {
- map = new Map("map",
- 1, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 1, 1,
- true,
- 0,
- 0);
- map->addLayer(layer);
- layer->setSpecialLayer(map->getSpecialLayer());
- layer->setTempLayer(map->getTempLayer());
- specialLayer = map->getTempLayer();
-
- layer->drawSpecialLayer(mock,
- 0,
- 0, 1,
- 0, 0);
- REQUIRE(mock->mDraws.empty());
-
- specialLayer->setTile(0, 0, MapItemType::ARROW_UP);
- layer->drawSpecialLayer(mock,
- 0,
- 0, 1,
- 0, 0);
-// REQUIRE(mock->mDraws.size() == 1);
- }
-
- SECTION("simple 2")
- {
- map = new Map("map",
- 1, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 1, 1,
- true,
- 0,
- 0);
- map->addLayer(layer);
- layer->setSpecialLayer(map->getSpecialLayer());
- layer->setTempLayer(map->getTempLayer());
- specialLayer = map->getTempLayer();
- specialLayer->setTile(0, 0, MapItemType::ARROW_UP);
- specialLayer->updateCache();
-
- layer->drawSpecialLayer(mock,
- 0,
- 0, 1,
- 0, 0);
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 0);
- REQUIRE(mock->mDraws[0].y == 0);
- }
-
- SECTION("simple 3")
- {
- map = new Map("map",
- 2, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 2, 1,
- true,
- 0,
- 0);
- map->addLayer(layer);
- layer->setSpecialLayer(map->getSpecialLayer());
- layer->setTempLayer(map->getTempLayer());
- specialLayer = map->getTempLayer();
- specialLayer->setTile(0, 0, MapItemType::ARROW_UP);
- specialLayer->updateCache();
-
- layer->drawSpecialLayer(mock,
- 0,
- 0, 2,
- 0, 0);
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 0);
- REQUIRE(mock->mDraws[0].y == 0);
- }
-
- SECTION("simple 4")
- {
- map = new Map("map",
- 2, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 2, 1,
- true,
- 0,
- 0);
- map->addLayer(layer);
- layer->setSpecialLayer(map->getSpecialLayer());
- layer->setTempLayer(map->getTempLayer());
- specialLayer = map->getTempLayer();
- const int *const cache = specialLayer->getCache();
- REQUIRE(cache[0] == 10000);
- REQUIRE(cache[1] == 10000);
-
- specialLayer->setTile(1, 0, MapItemType::ARROW_UP);
- specialLayer->updateCache();
- REQUIRE(cache[0] == 0);
- REQUIRE(cache[1] == 10000);
-
- layer->drawSpecialLayer(mock,
- 0,
- 0, 2,
- 0, 0);
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 32);
- REQUIRE(mock->mDraws[0].y == 0);
- }
-
- SECTION("simple 5")
- {
- map = new Map("map",
- 2, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 2, 1,
- true,
- 0,
- 0);
- map->addLayer(layer);
- layer->setSpecialLayer(map->getSpecialLayer());
- layer->setTempLayer(map->getTempLayer());
- specialLayer = map->getTempLayer();
- specialLayer->setTile(0, 0, MapItemType::ARROW_UP);
- specialLayer->setTile(1, 0, MapItemType::ARROW_UP);
- specialLayer->updateCache();
-
- layer->drawSpecialLayer(mock,
- 0,
- 0, 2,
- 0, 0);
- REQUIRE(mock->mDraws.size() == 2);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 0);
- REQUIRE(mock->mDraws[0].y == 0);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 32);
- REQUIRE(mock->mDraws[1].y == 0);
- }
-
- SECTION("simple 6")
- {
- map = new Map("map",
- 3, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 3, 1,
- true,
- 0,
- 0);
- map->addLayer(layer);
- layer->setSpecialLayer(map->getSpecialLayer());
- layer->setTempLayer(map->getTempLayer());
- specialLayer = map->getTempLayer();
- specialLayer->setTile(0, 0, MapItemType::ARROW_UP);
- specialLayer->setTile(2, 0, MapItemType::ARROW_UP);
- specialLayer->updateCache();
-
- layer->drawSpecialLayer(mock,
- 0,
- 0, 3,
- 0, 0);
- REQUIRE(mock->mDraws.size() == 2);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 0);
- REQUIRE(mock->mDraws[0].y == 0);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 64);
- REQUIRE(mock->mDraws[1].y == 0);
- }
-
- SECTION("simple 7")
- {
- map = new Map("map",
- 3, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 3, 1,
- true,
- 0,
- 0);
- map->addLayer(layer);
- layer->setSpecialLayer(map->getSpecialLayer());
- layer->setTempLayer(map->getTempLayer());
- specialLayer = map->getTempLayer();
- specialLayer->setTile(1, 0, MapItemType::ARROW_UP);
- specialLayer->setTile(2, 0, MapItemType::ARROW_UP);
- specialLayer->updateCache();
-
- layer->drawSpecialLayer(mock,
- 0,
- 0, 3,
- 0, 0);
- REQUIRE(mock->mDraws.size() == 2);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 32);
- REQUIRE(mock->mDraws[0].y == 0);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 64);
- REQUIRE(mock->mDraws[1].y == 0);
- }
-
- SECTION("simple 8")
- {
- map = new Map("map",
- 3, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 3, 1,
- true,
- 0,
- 0);
- map->addLayer(layer);
- layer->setSpecialLayer(map->getSpecialLayer());
- layer->setTempLayer(map->getTempLayer());
- specialLayer = map->getTempLayer();
- specialLayer->setTile(0, 0, MapItemType::ARROW_UP);
- specialLayer->setTile(1, 0, MapItemType::ARROW_DOWN);
- specialLayer->setTile(2, 0, MapItemType::ARROW_UP);
- specialLayer->updateCache();
-
- layer->drawSpecialLayer(mock,
- 0,
- 0, 3,
- 0, 0);
- REQUIRE(mock->mDraws.size() == 3);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 0);
- REQUIRE(mock->mDraws[0].y == 0);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 32);
- REQUIRE(mock->mDraws[1].y == 0);
- REQUIRE(mock->mDraws[2].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[2].x == 64);
- REQUIRE(mock->mDraws[2].y == 0);
- }
-
- SECTION("normal 1")
- {
- const int maxX = 100;
- const int maxY = 50;
- map = new Map("map",
- maxX, maxY,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- maxX, maxY,
- true,
- 0,
- 0);
- map->addLayer(layer);
- layer->setSpecialLayer(map->getSpecialLayer());
- layer->setTempLayer(map->getTempLayer());
- specialLayer = map->getTempLayer();
- specialLayer->setTile(0, 5, MapItemType::ARROW_UP);
- specialLayer->setTile(1, 5, MapItemType::ARROW_DOWN);
- specialLayer->setTile(2, 5, MapItemType::ARROW_UP);
- specialLayer->setTile(3, 5, MapItemType::EMPTY);
- specialLayer->setTile(4, 5, MapItemType::EMPTY);
- specialLayer->setTile(6, 5, MapItemType::ARROW_LEFT);
- specialLayer->setTile(10, 20, MapItemType::ARROW_LEFT);
- specialLayer->updateCache();
-
- layer->drawSpecialLayer(mock,
- 5,
- 0, maxX,
- 0, 0);
- REQUIRE(mock->mDraws.size() == 4);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 0 * 32);
- REQUIRE(mock->mDraws[0].y == 5 * 32);
- REQUIRE(mock->mDraws[1].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[1].x == 1 * 32);
- REQUIRE(mock->mDraws[1].y == 5 * 32);
- REQUIRE(mock->mDraws[2].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[2].x == 2 * 32);
- REQUIRE(mock->mDraws[2].y == 5 * 32);
- REQUIRE(mock->mDraws[3].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[3].x == 6 * 32);
- REQUIRE(mock->mDraws[3].y == 5 * 32);
-
- mock->mDraws.clear();
- layer->drawSpecialLayer(mock,
- 4,
- 0, maxX,
- 0, 0);
- REQUIRE(mock->mDraws.empty());
-
- layer->drawSpecialLayer(mock,
- 6,
- 0, maxX,
- 0, 0);
- REQUIRE(mock->mDraws.empty());
-
- layer->drawSpecialLayer(mock,
- 20,
- 0, maxX,
- 0, 0);
- REQUIRE(mock->mDraws.size() == 1);
- REQUIRE(mock->mDraws[0].drawType == MockDrawType::DrawImage);
- REQUIRE(mock->mDraws[0].x == 10 * 32);
- REQUIRE(mock->mDraws[0].y == 20 * 32);
- }
-
- delete map;
- delete mock;
- GraphicsManager::deleteRenderers();
- ResourceManager::cleanOrphans(true);
- ResourceManager::deleteInstance();
- VirtFs::unmountDirSilent("data");
- VirtFs::unmountDirSilent("../data");
-}
diff --git a/src/unittests/resources/map/maplayer/getemptytiledrawwidth.cc b/src/unittests/resources/map/maplayer/getemptytiledrawwidth.cc
deleted file mode 100644
index a5378ce86..000000000
--- a/src/unittests/resources/map/maplayer/getemptytiledrawwidth.cc
+++ /dev/null
@@ -1,162 +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 "unittests/unittests.h"
-
-#include "configmanager.h"
-#include "dirs.h"
-
-#include "resources/image/image.h"
-
-#include "resources/map/maplayer.h"
-
-#include "debug.h"
-
-TEST_CASE("MapLayer getEmptyTileDrawWidth", "")
-{
- Dirs::initRootDir();
- Dirs::initHomeDir();
-
- ConfigManager::initConfiguration();
-
- Image *const img1 = new Image(32, 32);
- Image *const img2 = new Image(32, 32);
- Image *const img3 = new Image(32, 32);
- MapLayer *layer = nullptr;
- int nextTile;
-
- SECTION("simple 2")
- {
- layer = new MapLayer("test",
- 0, 0,
- 2, 1,
- false,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- TileInfo *const tiles = layer->getTiles();
- REQUIRE(layer->getEmptyTileDrawWidth(tiles + 1,
- 1,
- nextTile) == 0);
- REQUIRE(nextTile == 0);
- }
-
- SECTION("simple 4")
- {
- layer = new MapLayer("test",
- 0, 0,
- 3, 1,
- false,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- layer->setTile(2, 0, img1);
- TileInfo *const tiles = layer->getTiles();
- REQUIRE(layer->getEmptyTileDrawWidth(tiles + 1,
- 2,
- nextTile) == 0);
- REQUIRE(nextTile == 0);
- }
-
- SECTION("simple 5")
- {
- layer = new MapLayer("test",
- 0, 0,
- 3, 1,
- false,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- layer->setTile(1, 0, img1);
- TileInfo *const tiles = layer->getTiles();
- REQUIRE(layer->getEmptyTileDrawWidth(tiles + 2,
- 1,
- nextTile) == 0);
- REQUIRE(nextTile == 0);
- }
-
- SECTION("normal 1")
- {
- layer = new MapLayer("test",
- 0, 0,
- 100, 100,
- false,
- 0,
- 0);
- layer->setTile(1, 10, img1);
- layer->setTile(2, 10, img1);
- layer->setTile(3, 10, img1);
- layer->setTile(4, 10, img2);
- layer->setTile(5, 10, nullptr);
- layer->setTile(6, 10, img2);
- layer->setTile(7, 10, nullptr);
- layer->setTile(8, 10, nullptr);
- layer->setTile(9, 10, img2);
- layer->setTile(10, 10, img2);
- layer->setTile(11, 10, img3);
- layer->setTile(12, 10, nullptr);
- layer->setTile(13, 10, nullptr);
- layer->setTile(14, 10, nullptr);
- layer->setTile(15, 10, img1);
- layer->setTile(16, 10, img1);
- layer->setTile(17, 10, img1);
- TileInfo *const tiles = layer->getTiles();
-
- REQUIRE(layer->getEmptyTileDrawWidth(tiles + 10 * 100 + 0,
- 100 - 0,
- nextTile) == 0);
- REQUIRE(nextTile == 0);
-
- REQUIRE(layer->getEmptyTileDrawWidth(tiles + 10 * 100 + 5,
- 100 - 5,
- nextTile) == 0);
- REQUIRE(nextTile == 0);
-
- REQUIRE(layer->getEmptyTileDrawWidth(tiles + 10 * 100 + 7,
- 100 - 7,
- nextTile) == 1);
- REQUIRE(nextTile == 1);
-
- REQUIRE(layer->getEmptyTileDrawWidth(tiles + 10 * 100 + 8,
- 100 - 8,
- nextTile) == 0);
- REQUIRE(nextTile == 0);
-
- REQUIRE(layer->getEmptyTileDrawWidth(tiles + 10 * 100 + 12,
- 100 - 12,
- nextTile) == 2);
- REQUIRE(nextTile == 2);
-
- REQUIRE(layer->getEmptyTileDrawWidth(tiles + 10 * 100 + 13,
- 100 - 13,
- nextTile) == 1);
- REQUIRE(nextTile == 1);
-
- REQUIRE(layer->getEmptyTileDrawWidth(tiles + 10 * 100 + 14,
- 100 - 14,
- nextTile) == 0);
- REQUIRE(nextTile == 0);
- }
-
- delete layer;
- delete img1;
- delete img2;
- delete img3;
-}
diff --git a/src/unittests/resources/map/maplayer/gettiledrawwidth.cc b/src/unittests/resources/map/maplayer/gettiledrawwidth.cc
deleted file mode 100644
index 121e14530..000000000
--- a/src/unittests/resources/map/maplayer/gettiledrawwidth.cc
+++ /dev/null
@@ -1,399 +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 "unittests/unittests.h"
-
-#include "configmanager.h"
-#include "dirs.h"
-
-#include "resources/image/image.h"
-
-#include "resources/map/maplayer.h"
-
-#include "debug.h"
-
-TEST_CASE("MapLayer getTileDrawWidth", "")
-{
- Dirs::initRootDir();
- Dirs::initHomeDir();
-
- ConfigManager::initConfiguration();
-
- Image *const img1 = new Image(32, 32);
- Image *const img2 = new Image(32, 32);
- Image *const img3 = new Image(32, 32);
- MapLayer *layer = nullptr;
- int width;
- int nextTile;
-
- SECTION("simple 1")
- {
- layer = new MapLayer("test",
- 0, 0,
- 1, 1,
- false,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- TileInfo *const tiles = layer->getTiles();
- REQUIRE(layer->getTileDrawWidth(tiles,
- 1,
- width,
- nextTile) == 0);
- REQUIRE(width == 32);
- REQUIRE(nextTile == 0);
- }
-
- SECTION("simple 2")
- {
- layer = new MapLayer("test",
- 0, 0,
- 2, 1,
- false,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- TileInfo *const tiles = layer->getTiles();
- REQUIRE(layer->getTileDrawWidth(tiles,
- 2,
- width,
- nextTile) == 0);
- REQUIRE(width == 32);
- REQUIRE(nextTile == 1);
- }
-
- SECTION("simple 3")
- {
- layer = new MapLayer("test",
- 0, 0,
- 2, 1,
- false,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- layer->setTile(1, 0, img2);
- TileInfo *const tiles = layer->getTiles();
- REQUIRE(layer->getTileDrawWidth(tiles,
- 1,
- width,
- nextTile) == 0);
- REQUIRE(width == 32);
- REQUIRE(nextTile == 0);
-
- REQUIRE(layer->getTileDrawWidth(tiles + 1,
- 1,
- width,
- nextTile) == 0);
- REQUIRE(width == 32);
- REQUIRE(nextTile == 0);
- }
-
- SECTION("simple 4")
- {
- layer = new MapLayer("test",
- 0, 0,
- 2, 1,
- false,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- layer->setTile(1, 0, img1);
- TileInfo *const tiles = layer->getTiles();
- REQUIRE(layer->getTileDrawWidth(tiles,
- 2,
- width,
- nextTile) == 1);
- REQUIRE(width == 64);
- REQUIRE(nextTile == 1);
-
- REQUIRE(layer->getTileDrawWidth(tiles + 1,
- 1,
- width,
- nextTile) == 0);
- REQUIRE(width == 32);
- REQUIRE(nextTile == 0);
- }
-
- SECTION("simple 4.2")
- {
- layer = new MapLayer("test",
- 0, 0,
- 3, 1,
- false,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- layer->setTile(2, 0, img1);
- TileInfo *const tiles = layer->getTiles();
- REQUIRE(layer->getTileDrawWidth(tiles,
- 3,
- width,
- nextTile) == 0);
- REQUIRE(width == 32);
- REQUIRE(nextTile == 1);
-
- REQUIRE(layer->getTileDrawWidth(tiles + 2,
- 1,
- width,
- nextTile) == 0);
- REQUIRE(width == 32);
- REQUIRE(nextTile == 0);
- }
-
- SECTION("simple 5")
- {
- layer = new MapLayer("test",
- 0, 0,
- 3, 1,
- false,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- layer->setTile(1, 0, img1);
- TileInfo *const tiles = layer->getTiles();
- REQUIRE(layer->getTileDrawWidth(tiles,
- 3,
- width,
- nextTile) == 1);
- REQUIRE(width == 64);
- REQUIRE(nextTile == 2);
-
- REQUIRE(layer->getTileDrawWidth(tiles + 1,
- 2,
- width,
- nextTile) == 0);
- REQUIRE(width == 32);
- REQUIRE(nextTile == 1);
- }
-
- SECTION("simple 6")
- {
- layer = new MapLayer("test",
- 0, 0,
- 3, 1,
- false,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- layer->setTile(1, 0, img1);
- layer->setTile(2, 0, img2);
- TileInfo *const tiles = layer->getTiles();
- REQUIRE(layer->getTileDrawWidth(tiles,
- 3,
- width,
- nextTile) == 1);
- REQUIRE(width == 64);
- REQUIRE(nextTile == 1);
-
- REQUIRE(layer->getTileDrawWidth(tiles + 1,
- 2,
- width,
- nextTile) == 0);
- REQUIRE(width == 32);
- REQUIRE(nextTile == 0);
-
- REQUIRE(layer->getTileDrawWidth(tiles + 2,
- 1,
- width,
- nextTile) == 0);
- REQUIRE(width == 32);
- REQUIRE(nextTile == 0);
- }
-
- SECTION("simple 7")
- {
- layer = new MapLayer("test",
- 0, 0,
- 3, 1,
- false,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- layer->setTile(1, 0, img1);
- layer->setTile(2, 0, img2);
- TileInfo *const tiles = layer->getTiles();
- tiles[1].isEnabled = false;
- REQUIRE(layer->getTileDrawWidth(tiles,
- 3,
- width,
- nextTile) == 0);
- REQUIRE(width == 32);
- REQUIRE(nextTile == 1);
-
-// REQUIRE(layer->getTileDrawWidth(tiles + 1,
-// 2,
-// width,
-// nextTile) == 0);
-// REQUIRE(width == 32);
-// REQUIRE(nextTile == 0);
-
- REQUIRE(layer->getTileDrawWidth(tiles + 2,
- 1,
- width,
- nextTile) == 0);
- REQUIRE(width == 32);
- REQUIRE(nextTile == 0);
- }
-
- SECTION("simple 8")
- {
- layer = new MapLayer("test",
- 0, 0,
- 3, 1,
- false,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- layer->setTile(1, 0, img1);
- layer->setTile(2, 0, img2);
- TileInfo *const tiles = layer->getTiles();
- tiles[0].isEnabled = false;
-// REQUIRE(layer->getTileDrawWidth(tiles,
-// 3,
-// width,
-// nextTile) == 1);
-// REQUIRE(width == 0);
-// REQUIRE(nextTile == 1);
-
- REQUIRE(layer->getTileDrawWidth(tiles + 1,
- 2,
- width,
- nextTile) == 0);
- REQUIRE(width == 32);
- REQUIRE(nextTile == 0);
-
- REQUIRE(layer->getTileDrawWidth(tiles + 2,
- 1,
- width,
- nextTile) == 0);
- REQUIRE(width == 32);
- REQUIRE(nextTile == 0);
- }
-
- SECTION("normal 1")
- {
- layer = new MapLayer("test",
- 0, 0,
- 100, 100,
- false,
- 0,
- 0);
- layer->setTile(1, 10, img1);
- layer->setTile(2, 10, img1);
- layer->setTile(3, 10, img1);
- layer->setTile(4, 10, img2);
- layer->setTile(5, 10, nullptr);
- layer->setTile(6, 10, img2);
- layer->setTile(7, 10, nullptr);
- layer->setTile(8, 10, nullptr);
- layer->setTile(9, 10, img2);
- layer->setTile(10, 10, img2);
- layer->setTile(11, 10, img3);
- layer->setTile(12, 10, nullptr);
- layer->setTile(13, 10, nullptr);
- layer->setTile(14, 10, nullptr);
- layer->setTile(15, 10, img1);
- layer->setTile(16, 10, img1);
- layer->setTile(17, 10, img1);
- TileInfo *const tiles = layer->getTiles();
-
- REQUIRE(layer->getTileDrawWidth(tiles + 10 * 100 + 1,
- 100 - 1,
- width,
- nextTile) == 2);
- REQUIRE(width == 96);
- REQUIRE(nextTile == 2);
-
- REQUIRE(layer->getTileDrawWidth(tiles + 10 * 100 + 2,
- 100 - 2,
- width,
- nextTile) == 1);
- REQUIRE(width == 64);
- REQUIRE(nextTile == 1);
-
- REQUIRE(layer->getTileDrawWidth(tiles + 10 * 100 + 3,
- 100 - 3,
- width,
- nextTile) == 0);
- REQUIRE(width == 32);
- REQUIRE(nextTile == 0);
-
- REQUIRE(layer->getTileDrawWidth(tiles + 10 * 100 + 4,
- 100 - 4,
- width,
- nextTile) == 0);
- REQUIRE(width == 32);
- REQUIRE(nextTile == 1);
-
- REQUIRE(layer->getTileDrawWidth(tiles + 10 * 100 + 6,
- 100 - 6,
- width,
- nextTile) == 0);
- REQUIRE(width == 32);
- REQUIRE(nextTile == 2);
-
- REQUIRE(layer->getTileDrawWidth(tiles + 10 * 100 + 9,
- 100 - 9,
- width,
- nextTile) == 1);
- REQUIRE(width == 64);
- REQUIRE(nextTile == 1);
-
- REQUIRE(layer->getTileDrawWidth(tiles + 10 * 100 + 10,
- 100 - 10,
- width,
- nextTile) == 0);
- REQUIRE(width == 32);
- REQUIRE(nextTile == 0);
-
- REQUIRE(layer->getTileDrawWidth(tiles + 10 * 100 + 11,
- 100 - 11,
- width,
- nextTile) == 0);
- REQUIRE(width == 32);
- REQUIRE(nextTile == 3);
-
- REQUIRE(layer->getTileDrawWidth(tiles + 10 * 100 + 15,
- 100 - 15,
- width,
- nextTile) == 2);
- REQUIRE(width == 96);
- REQUIRE(nextTile == 84);
-
- REQUIRE(layer->getTileDrawWidth(tiles + 10 * 100 + 16,
- 100 - 16,
- width,
- nextTile) == 1);
- REQUIRE(width == 64);
- REQUIRE(nextTile == 83);
-
- REQUIRE(layer->getTileDrawWidth(tiles + 10 * 100 + 17,
- 100 - 17,
- width,
- nextTile) == 0);
- REQUIRE(width == 32);
- REQUIRE(nextTile == 82);
- }
-
- delete layer;
- delete img1;
- delete img2;
- delete img3;
-}
diff --git a/src/unittests/resources/map/maplayer/updatecache.cc b/src/unittests/resources/map/maplayer/updatecache.cc
deleted file mode 100644
index eaff5ac5d..000000000
--- a/src/unittests/resources/map/maplayer/updatecache.cc
+++ /dev/null
@@ -1,399 +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 "unittests/unittests.h"
-
-#include "configmanager.h"
-#include "dirs.h"
-
-#include "resources/image/image.h"
-
-#include "resources/map/maplayer.h"
-
-#include "debug.h"
-
-TEST_CASE("MapLayer updateCache", "")
-{
- Dirs::initRootDir();
- Dirs::initHomeDir();
-
- ConfigManager::initConfiguration();
-
- Image *const img1 = new Image(32, 32);
- Image *const img2 = new Image(32, 32);
- Image *const img3 = new Image(32, 32);
- MapLayer *layer = nullptr;
-
- SECTION("simple 1")
- {
- layer = new MapLayer("test",
- 0, 0,
- 1, 1,
- false,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- TileInfo *const tiles = layer->getTiles();
- layer->updateCache(1, 1);
- REQUIRE(tiles[0].isEnabled == true);
- REQUIRE(tiles[0].width == 32);
- REQUIRE(tiles[0].count == 0);
- REQUIRE(tiles[0].nextTile == 0);
- }
-
- SECTION("simple 2")
- {
- layer = new MapLayer("test",
- 0, 0,
- 2, 1,
- false,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- TileInfo *const tiles = layer->getTiles();
- layer->updateCache(2, 1);
- REQUIRE(tiles[0].isEnabled == true);
- REQUIRE(tiles[0].width == 32);
- REQUIRE(tiles[0].count == 0);
- REQUIRE(tiles[0].nextTile == 1);
- REQUIRE(tiles[1].isEnabled == false);
- REQUIRE(tiles[1].width == 0);
- REQUIRE(tiles[1].count == 0);
- REQUIRE(tiles[1].nextTile == 0);
- }
-
- SECTION("simple 3")
- {
- layer = new MapLayer("test",
- 0, 0,
- 2, 1,
- false,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- layer->setTile(1, 0, img2);
- TileInfo *const tiles = layer->getTiles();
- layer->updateCache(2, 1);
- REQUIRE(tiles[0].isEnabled == true);
- REQUIRE(tiles[0].width == 32);
- REQUIRE(tiles[0].count == 0);
- REQUIRE(tiles[0].nextTile == 0);
- REQUIRE(tiles[1].isEnabled == true);
- REQUIRE(tiles[1].width == 32);
- REQUIRE(tiles[1].count == 0);
- REQUIRE(tiles[1].nextTile == 0);
- }
-
- SECTION("simple 4")
- {
- layer = new MapLayer("test",
- 0, 0,
- 2, 1,
- false,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- layer->setTile(1, 0, img1);
- TileInfo *const tiles = layer->getTiles();
- layer->updateCache(2, 1);
- REQUIRE(tiles[0].isEnabled == true);
- REQUIRE(tiles[0].width == 64);
- REQUIRE(tiles[0].count == 1);
- REQUIRE(tiles[0].nextTile == 1);
- REQUIRE(tiles[1].isEnabled == true);
- REQUIRE(tiles[1].width == 32);
- REQUIRE(tiles[1].count == 0);
- REQUIRE(tiles[1].nextTile == 0);
- }
-
- SECTION("simple 4.2")
- {
- layer = new MapLayer("test",
- 0, 0,
- 3, 1,
- false,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- layer->setTile(2, 0, img1);
- TileInfo *const tiles = layer->getTiles();
- layer->updateCache(3, 1);
- REQUIRE(tiles[0].isEnabled == true);
- REQUIRE(tiles[0].width == 32);
- REQUIRE(tiles[0].count == 0);
- REQUIRE(tiles[0].nextTile == 1);
- REQUIRE(tiles[1].isEnabled == false);
- REQUIRE(tiles[1].width == 0);
- REQUIRE(tiles[1].count == 0);
- REQUIRE(tiles[1].nextTile == 0);
- REQUIRE(tiles[2].isEnabled == true);
- REQUIRE(tiles[2].width == 32);
- REQUIRE(tiles[2].count == 0);
- REQUIRE(tiles[2].nextTile == 0);
- }
-
- SECTION("simple 5")
- {
- layer = new MapLayer("test",
- 0, 0,
- 3, 1,
- false,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- layer->setTile(1, 0, img1);
- TileInfo *const tiles = layer->getTiles();
- layer->updateCache(3, 1);
- REQUIRE(tiles[0].isEnabled == true);
- REQUIRE(tiles[0].width == 64);
- REQUIRE(tiles[0].count == 1);
- REQUIRE(tiles[0].nextTile == 2);
- REQUIRE(tiles[1].isEnabled == true);
- REQUIRE(tiles[1].width == 32);
- REQUIRE(tiles[1].count == 0);
- REQUIRE(tiles[1].nextTile == 1);
- REQUIRE(tiles[2].isEnabled == false);
- REQUIRE(tiles[2].width == 0);
- REQUIRE(tiles[2].count == 0);
- REQUIRE(tiles[2].nextTile == 0);
- }
-
- SECTION("simple 6")
- {
- layer = new MapLayer("test",
- 0, 0,
- 3, 1,
- false,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- layer->setTile(1, 0, img1);
- layer->setTile(2, 0, img2);
- TileInfo *const tiles = layer->getTiles();
- layer->updateCache(3, 1);
- REQUIRE(tiles[0].isEnabled == true);
- REQUIRE(tiles[0].width == 64);
- REQUIRE(tiles[0].count == 1);
- REQUIRE(tiles[0].nextTile == 1);
- REQUIRE(tiles[1].isEnabled == true);
- REQUIRE(tiles[1].width == 32);
- REQUIRE(tiles[1].count == 0);
- REQUIRE(tiles[1].nextTile == 0);
- REQUIRE(tiles[2].isEnabled == true);
- REQUIRE(tiles[2].width == 32);
- REQUIRE(tiles[2].count == 0);
- REQUIRE(tiles[2].nextTile == 0);
- }
-
- SECTION("simple 7")
- {
- layer = new MapLayer("test",
- 0, 0,
- 3, 1,
- false,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- layer->setTile(1, 0, img1);
- layer->setTile(2, 0, img2);
- TileInfo *const tiles = layer->getTiles();
- tiles[0].isEnabled = false;
- layer->updateCache(3, 1);
- REQUIRE(tiles[0].isEnabled == false);
- REQUIRE(tiles[0].width == 0);
- REQUIRE(tiles[0].count == 0);
- REQUIRE(tiles[0].nextTile == 0);
- REQUIRE(tiles[1].isEnabled == true);
- REQUIRE(tiles[1].width == 32);
- REQUIRE(tiles[1].count == 0);
- REQUIRE(tiles[1].nextTile == 0);
- REQUIRE(tiles[2].isEnabled == true);
- REQUIRE(tiles[2].width == 32);
- REQUIRE(tiles[2].count == 0);
- REQUIRE(tiles[2].nextTile == 0);
- }
-
- SECTION("normal 1")
- {
- layer = new MapLayer("test",
- 0, 0,
- 100, 100,
- false,
- 0,
- 0);
- layer->setTile(1, 10, img1);
- layer->setTile(2, 10, img1);
- layer->setTile(3, 10, img1);
- layer->setTile(4, 10, img2);
- layer->setTile(5, 10, nullptr);
- layer->setTile(6, 10, img2);
- layer->setTile(7, 10, nullptr);
- layer->setTile(8, 10, nullptr);
- layer->setTile(9, 10, img2);
- layer->setTile(10, 10, img2);
- layer->setTile(11, 10, img3);
- layer->setTile(12, 10, nullptr);
- layer->setTile(13, 10, nullptr);
- layer->setTile(14, 10, nullptr);
- layer->setTile(15, 10, img1);
- layer->setTile(16, 10, img1);
- layer->setTile(17, 10, img1);
- TileInfo *const tiles = layer->getTiles();
- layer->updateCache(100, 100);
-
- REQUIRE(tiles[0 * 100 + 0].isEnabled == false);
- REQUIRE(tiles[0 * 100 + 0].width == 0);
- REQUIRE(tiles[0 * 100 + 0].count == 99);
- REQUIRE(tiles[0 * 100 + 0].nextTile == 99);
-
- REQUIRE(tiles[0 * 100 + 1].isEnabled == false);
- REQUIRE(tiles[0 * 100 + 1].width == 0);
- REQUIRE(tiles[0 * 100 + 1].count == 98);
- REQUIRE(tiles[0 * 100 + 1].nextTile == 98);
-
- REQUIRE(tiles[10 * 100 + 0].isEnabled == false);
- REQUIRE(tiles[10 * 100 + 0].width == 0);
- REQUIRE(tiles[10 * 100 + 0].count == 0);
- REQUIRE(tiles[10 * 100 + 0].nextTile == 0);
-
- REQUIRE(tiles[10 * 100 + 1].isEnabled == true);
- REQUIRE(tiles[10 * 100 + 1].width == 96);
- REQUIRE(tiles[10 * 100 + 1].count == 2);
- REQUIRE(tiles[10 * 100 + 1].nextTile == 2);
-
- REQUIRE(tiles[10 * 100 + 2].isEnabled == true);
- REQUIRE(tiles[10 * 100 + 2].width == 64);
- REQUIRE(tiles[10 * 100 + 2].count == 1);
- REQUIRE(tiles[10 * 100 + 2].nextTile == 1);
-
- REQUIRE(tiles[10 * 100 + 3].isEnabled == true);
- REQUIRE(tiles[10 * 100 + 3].width == 32);
- REQUIRE(tiles[10 * 100 + 3].count == 0);
- REQUIRE(tiles[10 * 100 + 3].nextTile == 0);
-
- REQUIRE(tiles[10 * 100 + 4].isEnabled == true);
- REQUIRE(tiles[10 * 100 + 4].width == 32);
- REQUIRE(tiles[10 * 100 + 4].count == 0);
- REQUIRE(tiles[10 * 100 + 4].nextTile == 1);
-
- REQUIRE(tiles[10 * 100 + 5].isEnabled == false);
- REQUIRE(tiles[10 * 100 + 5].width == 0);
- REQUIRE(tiles[10 * 100 + 5].count == 0);
- REQUIRE(tiles[10 * 100 + 5].nextTile == 0);
-
- REQUIRE(tiles[10 * 100 + 6].isEnabled == true);
- REQUIRE(tiles[10 * 100 + 6].width == 32);
- REQUIRE(tiles[10 * 100 + 6].count == 0);
- REQUIRE(tiles[10 * 100 + 6].nextTile == 2);
-
- REQUIRE(tiles[10 * 100 + 7].isEnabled == false);
- REQUIRE(tiles[10 * 100 + 7].width == 0);
- REQUIRE(tiles[10 * 100 + 7].count == 1);
- REQUIRE(tiles[10 * 100 + 7].nextTile == 1);
-
- REQUIRE(tiles[10 * 100 + 8].isEnabled == false);
- REQUIRE(tiles[10 * 100 + 8].width == 0);
- REQUIRE(tiles[10 * 100 + 8].count == 0);
- REQUIRE(tiles[10 * 100 + 8].nextTile == 0);
-
- REQUIRE(tiles[10 * 100 + 9].isEnabled == true);
- REQUIRE(tiles[10 * 100 + 9].width == 64);
- REQUIRE(tiles[10 * 100 + 9].count == 1);
- REQUIRE(tiles[10 * 100 + 9].nextTile == 1);
-
- REQUIRE(tiles[10 * 100 + 10].isEnabled == true);
- REQUIRE(tiles[10 * 100 + 10].width == 32);
- REQUIRE(tiles[10 * 100 + 10].count == 0);
- REQUIRE(tiles[10 * 100 + 10].nextTile == 0);
-
- REQUIRE(tiles[10 * 100 + 11].isEnabled == true);
- REQUIRE(tiles[10 * 100 + 11].width == 32);
- REQUIRE(tiles[10 * 100 + 11].count == 0);
- REQUIRE(tiles[10 * 100 + 11].nextTile == 3);
-
- REQUIRE(tiles[10 * 100 + 12].isEnabled == false);
- REQUIRE(tiles[10 * 100 + 12].width == 0);
- REQUIRE(tiles[10 * 100 + 12].count == 2);
- REQUIRE(tiles[10 * 100 + 12].nextTile == 2);
-
- REQUIRE(tiles[10 * 100 + 13].isEnabled == false);
- REQUIRE(tiles[10 * 100 + 13].width == 0);
- REQUIRE(tiles[10 * 100 + 13].count == 1);
- REQUIRE(tiles[10 * 100 + 13].nextTile == 1);
-
- REQUIRE(tiles[10 * 100 + 14].isEnabled == false);
- REQUIRE(tiles[10 * 100 + 14].width == 0);
- REQUIRE(tiles[10 * 100 + 14].count == 0);
- REQUIRE(tiles[10 * 100 + 14].nextTile == 0);
-
- REQUIRE(tiles[10 * 100 + 15].isEnabled == true);
- REQUIRE(tiles[10 * 100 + 15].width == 96);
- REQUIRE(tiles[10 * 100 + 15].count == 2);
- REQUIRE(tiles[10 * 100 + 15].nextTile == 84);
-
- REQUIRE(tiles[10 * 100 + 16].isEnabled == true);
- REQUIRE(tiles[10 * 100 + 16].width == 64);
- REQUIRE(tiles[10 * 100 + 16].count == 1);
- REQUIRE(tiles[10 * 100 + 16].nextTile == 83);
-
- REQUIRE(tiles[10 * 100 + 17].isEnabled == true);
- REQUIRE(tiles[10 * 100 + 17].width == 32);
- REQUIRE(tiles[10 * 100 + 17].count == 0);
- REQUIRE(tiles[10 * 100 + 17].nextTile == 82);
- }
-
- SECTION("normal2")
- {
- const int maxX = 100;
- const int maxY = 100;
- layer = new MapLayer("test",
- 0, 0,
- maxX, maxY,
- false,
- 0,
- 0);
- TileInfo *const tiles = layer->getTiles();
- for (int x = 0; x < maxX; x ++)
- {
- for (int y = 0; y < maxY; y ++)
- {
- layer->setTile(x, y, img1);
- tiles[y * maxX + x].isEnabled = false;
- }
- }
- tiles[10 * maxX + 41].isEnabled = true;
- layer->updateCache(maxX, maxY);
-
- REQUIRE(tiles[10 * maxX + 0].isEnabled == false);
- REQUIRE(tiles[10 * maxX + 0].width == 0);
- REQUIRE(tiles[10 * maxX + 0].count == 40);
- REQUIRE(tiles[10 * maxX + 0].nextTile == 40);
-
- REQUIRE(tiles[10 * maxX + 1].isEnabled == false);
- REQUIRE(tiles[10 * maxX + 1].width == 0);
- REQUIRE(tiles[10 * maxX + 1].count == 39);
- REQUIRE(tiles[10 * maxX + 1].nextTile == 39);
- }
-
- delete layer;
- delete img1;
- delete img2;
- delete img3;
-}
diff --git a/src/unittests/resources/map/maplayer/updateconditiontiles.cc b/src/unittests/resources/map/maplayer/updateconditiontiles.cc
deleted file mode 100644
index f9b7cffc2..000000000
--- a/src/unittests/resources/map/maplayer/updateconditiontiles.cc
+++ /dev/null
@@ -1,231 +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 "unittests/unittests.h"
-
-#include "configmanager.h"
-#include "dirs.h"
-
-#include "enums/resources/map/blockmask.h"
-
-#include "resources/image/image.h"
-
-#include "resources/map/map.h"
-#include "resources/map/maplayer.h"
-
-#include "debug.h"
-
-TEST_CASE("MapLayer updateConditionTiles", "")
-{
- Dirs::initRootDir();
- Dirs::initHomeDir();
-
- ConfigManager::initConfiguration();
-
- Image *const img1 = new Image(32, 32);
- Map *map = nullptr;
- MapLayer *layer = nullptr;
-
- SECTION("simple 1")
- {
- map = new Map("map",
- 1, 1,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 1, 1,
- false,
- 0,
- 0);
- layer->setTile(0, 0, img1);
- map->addLayer(layer);
- layer->setTileCondition(BlockMask::WATER);
- TileInfo *const tiles = layer->getTiles();
-
- map->addBlockMask(0, 0, BlockType::NONE);
- layer->updateConditionTiles(map->getMetaTiles(),
- 1, 1);
- REQUIRE(tiles[0].isEnabled == false);
-
- map->addBlockMask(0, 0, BlockType::WATER);
- layer->updateConditionTiles(map->getMetaTiles(),
- 1, 1);
- REQUIRE(tiles[0].isEnabled == true);
- }
-
- SECTION("normal 1")
- {
- map = new Map("map",
- 100, 200,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 100, 200,
- false,
- 0,
- 0);
- layer->setTile(10, 10, img1);
- layer->setTile(10, 20, img1);
- layer->setTile(10, 30, img1);
- map->addLayer(layer);
- layer->setTileCondition(BlockMask::WATER);
- TileInfo *const tiles = layer->getTiles();
-
- map->addBlockMask(10, 10, BlockType::NONE);
- map->addBlockMask(10, 20, BlockType::NONE);
- map->addBlockMask(20, 20, BlockType::NONE);
- layer->updateConditionTiles(map->getMetaTiles(),
- 100, 200);
- for (int x = 0; x < 100; x ++)
- {
- for (int y = 0; y < 200; y ++)
- {
- REQUIRE(tiles[y * 100 + x].isEnabled == false);
- }
- }
- }
-
- SECTION("normal 2")
- {
- map = new Map("map",
- 100, 200,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 100, 200,
- false,
- 0,
- 0);
- layer->setTile(10, 10, img1);
- layer->setTile(10, 20, img1);
- layer->setTile(10, 30, img1);
- map->addLayer(layer);
- layer->setTileCondition(BlockMask::WATER);
- TileInfo *const tiles = layer->getTiles();
-
- map->addBlockMask(10, 10, BlockType::WATER);
- map->addBlockMask(10, 20, BlockType::WATER);
- map->addBlockMask(20, 20, BlockType::WATER);
- layer->updateConditionTiles(map->getMetaTiles(),
- 100, 200);
- for (int x = 0; x < 100; x ++)
- {
- for (int y = 0; y < 200; y ++)
- {
- if ((x == 10 && y == 10) || (x == 10 && y == 20))
- {
- REQUIRE(tiles[y * 100 + x].isEnabled == true);
- }
- else
- {
- REQUIRE(tiles[y * 100 + x].isEnabled == false);
- }
- }
- }
- }
-
- SECTION("normal 3")
- {
- map = new Map("map",
- 100, 200,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 100, 200,
- false,
- 0,
- 0);
- for (int x = 0; x < 100; x ++)
- {
- for (int y = 0; y < 200; y ++)
- {
- layer->setTile(x, y, img1);
- }
- }
- map->addLayer(layer);
- layer->setTileCondition(BlockMask::WATER);
- TileInfo *const tiles = layer->getTiles();
-
- map->addBlockMask(10, 10, BlockType::WATER);
- map->addBlockMask(10, 20, BlockType::WATER);
- layer->updateConditionTiles(map->getMetaTiles(),
- 100, 200);
- for (int x = 0; x < 100; x ++)
- {
- for (int y = 0; y < 200; y ++)
- {
- if ((x == 10 && y == 10) || (x == 10 && y == 20))
- {
- REQUIRE(tiles[y * 100 + x].isEnabled == true);
- }
- else
- {
- REQUIRE(tiles[y * 100 + x].isEnabled == false);
- }
- }
- }
- }
-
- SECTION("normal 4")
- {
- map = new Map("map",
- 100, 200,
- 32, 32);
- layer = new MapLayer("test",
- 0, 0,
- 100, 200,
- false,
- 0,
- 0);
- layer->setTile(10, 10, img1);
- layer->setTile(10, 20, img1);
- map->addLayer(layer);
- layer->setTileCondition(BlockMask::WATER);
- TileInfo *const tiles = layer->getTiles();
-
- for (int x = 0; x < 100; x ++)
- {
- for (int y = 0; y < 200; y ++)
- {
- map->addBlockMask(x, y, BlockType::WATER);
- }
- }
-
- layer->updateConditionTiles(map->getMetaTiles(),
- 100, 200);
- for (int x = 0; x < 100; x ++)
- {
- for (int y = 0; y < 200; y ++)
- {
- if ((x == 10 && y == 10) || (x == 10 && y == 20))
- {
- REQUIRE(tiles[y * 100 + x].isEnabled == true);
- }
- else
- {
- REQUIRE(tiles[y * 100 + x].isEnabled == false);
- }
- }
- }
- }
-
- delete map;
- delete img1;
-}
diff --git a/src/unittests/resources/map/speciallayer.cc b/src/unittests/resources/map/speciallayer.cc
deleted file mode 100644
index 2e72d6e19..000000000
--- a/src/unittests/resources/map/speciallayer.cc
+++ /dev/null
@@ -1,288 +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 "unittests/unittests.h"
-
-#include "client.h"
-#include "configmanager.h"
-#include "configuration.h"
-#include "dirs.h"
-
-#include "graphicsmanager.h"
-
-#include "being/actorsprite.h"
-
-#include "gui/userpalette.h"
-#include "gui/theme.h"
-
-#include "enums/resources/map/mapitemtype.h"
-
-#include "fs/virtfs/fs.h"
-
-#include "utils/delete2.h"
-#include "utils/env.h"
-
-#include "resources/sdlimagehelper.h"
-
-#include "resources/map/speciallayer.h"
-
-#include "resources/resourcemanager/resourcemanager.h"
-
-#include "debug.h"
-
-TEST_CASE("SpecialLayer updateCache", "")
-{
- setEnv("SDL_VIDEODRIVER", "dummy");
-
- client = new Client;
- VirtFs::mountDirSilent("data", Append_false);
- VirtFs::mountDirSilent("../data", Append_false);
-
- imageHelper = new SDLImageHelper;
-
- Dirs::initRootDir();
- Dirs::initHomeDir();
-
- setBrandingDefaults(branding);
- ConfigManager::initConfiguration();
-
-#ifdef USE_SDL2
- SDLImageHelper::setRenderer(graphicsManager.createRenderer(
- graphicsManager.createWindow(640, 480, 0,
- SDL_WINDOW_SHOWN | SDL_SWSURFACE), SDL_RENDERER_SOFTWARE));
-#else // USE_SDL2
-
- graphicsManager.createWindow(640, 480, 0, SDL_ANYFORMAT | SDL_SWSURFACE);
-#endif // USE_SDL2
-
- userPalette = new UserPalette;
-
- theme = new Theme;
- Theme::selectSkin();
-
- ActorSprite::load();
-
- SpecialLayer *layer = nullptr;
-
- SECTION("simple 1")
- {
- layer = new SpecialLayer("test",
- 1, 1);
- const int *const cache = layer->getCache();
- REQUIRE(cache[0] == 10000);
- layer->setTile(0, 0, MapItemType::ARROW_UP);
- layer->updateCache();
- REQUIRE(cache[0] == 10000);
- }
-
- SECTION("simple 2")
- {
- layer = new SpecialLayer("test",
- 2, 1);
- const int *const cache = layer->getCache();
- REQUIRE(cache[0] == 10000);
- REQUIRE(cache[1] == 10000);
- layer->setTile(0, 0, MapItemType::ARROW_UP);
- layer->updateCache();
- REQUIRE(cache[0] == 10000);
- REQUIRE(cache[1] == 10000);
- }
-
- SECTION("simple 3")
- {
- layer = new SpecialLayer("test",
- 2, 1);
- layer->setTile(0, 0, MapItemType::ARROW_UP);
- layer->setTile(1, 0, MapItemType::ARROW_DOWN);
- const int *const cache = layer->getCache();
- layer->updateCache();
- REQUIRE(cache[0] == 0);
- REQUIRE(cache[1] == 10000);
- }
-
- SECTION("simple 4")
- {
- layer = new SpecialLayer("test",
- 2, 1);
- layer->setTile(0, 0, MapItemType::ARROW_UP);
- layer->setTile(1, 0, MapItemType::ARROW_UP);
- const int *const cache = layer->getCache();
- layer->updateCache();
- REQUIRE(cache[0] == 0);
- REQUIRE(cache[1] == 10000);
- }
-
- SECTION("simple 4.2")
- {
- layer = new SpecialLayer("test",
- 3, 1);
- layer->setTile(0, 0, MapItemType::ARROW_UP);
- layer->setTile(2, 0, MapItemType::ARROW_UP);
- const int *const cache = layer->getCache();
- layer->updateCache();
- REQUIRE(cache[0] == 1);
- REQUIRE(cache[1] == 0);
- REQUIRE(cache[2] == 10000);
- }
-
- SECTION("simple 5")
- {
- layer = new SpecialLayer("test",
- 3, 1);
- layer->setTile(0, 0, MapItemType::ARROW_UP);
- layer->setTile(1, 0, MapItemType::ARROW_UP);
- const int *const cache = layer->getCache();
- layer->updateCache();
- REQUIRE(cache[0] == 0);
- REQUIRE(cache[1] == 10000);
- REQUIRE(cache[2] == 10000);
- }
-
- SECTION("simple 6")
- {
- layer = new SpecialLayer("test",
- 3, 1);
- layer->setTile(0, 0, MapItemType::ARROW_UP);
- layer->setTile(1, 0, MapItemType::ARROW_UP);
- layer->setTile(2, 0, MapItemType::ARROW_DOWN);
- const int *const cache = layer->getCache();
- layer->updateCache();
- REQUIRE(cache[0] == 0);
- REQUIRE(cache[1] == 0);
- REQUIRE(cache[2] == 10000);
- }
-
- SECTION("simple 7")
- {
- layer = new SpecialLayer("test",
- 3, 1);
- const int *const cache = layer->getCache();
- layer->updateCache();
- REQUIRE(cache[0] == 10000);
- REQUIRE(cache[1] == 10000);
- REQUIRE(cache[2] == 10000);
- }
-
- SECTION("simple 8")
- {
- layer = new SpecialLayer("test",
- 3, 1);
- layer->setTile(0, 0, MapItemType::EMPTY);
- layer->setTile(1, 0, MapItemType::EMPTY);
- layer->setTile(2, 0, MapItemType::EMPTY);
- const int *const cache = layer->getCache();
- layer->updateCache();
- REQUIRE(cache[0] == 10000);
- REQUIRE(cache[1] == 10000);
- REQUIRE(cache[2] == 10000);
- }
-
- SECTION("simple 9")
- {
- layer = new SpecialLayer("test",
- 2, 1);
- const int *const cache = layer->getCache();
- REQUIRE(cache[0] == 10000);
- REQUIRE(cache[1] == 10000);
- layer->setTile(1, 0, MapItemType::ARROW_UP);
- layer->updateCache();
- REQUIRE(cache[0] == 0);
- REQUIRE(cache[1] == 10000);
- }
-
- SECTION("normal 1")
- {
- layer = new SpecialLayer("test",
- 100, 100);
- layer->setTile(1, 10, MapItemType::ARROW_UP);
- layer->setTile(2, 10, MapItemType::ARROW_UP);
- layer->setTile(3, 10, MapItemType::ARROW_UP);
- layer->setTile(4, 10, MapItemType::ARROW_DOWN);
- layer->setTile(5, 10, MapItemType::EMPTY);
- layer->setTile(6, 10, MapItemType::ARROW_DOWN);
- layer->setTile(7, 10, MapItemType::EMPTY);
- layer->setTile(8, 10, MapItemType::EMPTY);
- layer->setTile(9, 10, MapItemType::ARROW_DOWN);
- layer->setTile(10, 10, MapItemType::ARROW_DOWN);
- layer->setTile(11, 10, MapItemType::ARROW_LEFT);
- layer->setTile(12, 10, MapItemType::EMPTY);
- layer->setTile(13, 10, MapItemType::EMPTY);
- layer->setTile(14, 10, MapItemType::EMPTY);
- layer->setTile(15, 10, MapItemType::ARROW_UP);
- layer->setTile(16, 10, MapItemType::ARROW_UP);
- layer->setTile(17, 10, MapItemType::ARROW_UP);
- const int *const cache = layer->getCache();
- layer->updateCache();
-
- REQUIRE(cache[10 * 100 + 0] == 0);
- REQUIRE(cache[10 * 100 + 1] == 0);
- REQUIRE(cache[10 * 100 + 2] == 0);
- REQUIRE(cache[10 * 100 + 3] == 0);
- REQUIRE(cache[10 * 100 + 4] == 1);
- REQUIRE(cache[10 * 100 + 5] == 0);
- REQUIRE(cache[10 * 100 + 6] == 2);
- REQUIRE(cache[10 * 100 + 7] == 1);
- REQUIRE(cache[10 * 100 + 8] == 0);
- REQUIRE(cache[10 * 100 + 9] == 0);
- REQUIRE(cache[10 * 100 + 10] == 0);
- REQUIRE(cache[10 * 100 + 11] == 3);
- REQUIRE(cache[10 * 100 + 12] == 2);
- REQUIRE(cache[10 * 100 + 13] == 1);
- REQUIRE(cache[10 * 100 + 14] == 0);
- REQUIRE(cache[10 * 100 + 15] == 0);
- REQUIRE(cache[10 * 100 + 16] == 0);
- REQUIRE(cache[10 * 100 + 17] == 10000);
- }
-
- SECTION("normal2")
- {
- const int maxX = 100;
- const int maxY = 100;
- layer = new SpecialLayer("test",
- maxX, maxY);
- const int *const cache = layer->getCache();
- for (int x = 0; x < maxX; x ++)
- {
- for (int y = 0; y < maxY; y ++)
- {
- layer->setTile(x, y, MapItemType::ARROW_UP);
- REQUIRE(layer->getTiles()[x + y * maxX] != nullptr);
- }
- }
- layer->updateCache();
-
- for (int y = 0; y < maxY; y ++)
- {
- for (int x = 0; x < maxX - 1; x ++)
- {
- REQUIRE(cache[y * maxX + x] == 0);
- }
- REQUIRE(cache[y * maxX + maxX - 1] == 10000);
- }
- }
-
- delete layer;
- ResourceManager::cleanOrphans();
- delete2(userPalette);
- delete2(theme);
- delete2(client);
- VirtFs::unmountDirSilent("data");
- VirtFs::unmountDirSilent("../data");
-}
diff --git a/src/unittests/resources/mstack.cc b/src/unittests/resources/mstack.cc
deleted file mode 100644
index 1d2233803..000000000
--- a/src/unittests/resources/mstack.cc
+++ /dev/null
@@ -1,165 +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/>.
- */
-
-#include "unittests/unittests.h"
-
-#include "gui/cliprect.h"
-
-#include "resources/mstack.h"
-
-#include "debug.h"
-
-TEST_CASE("mstack push 1", "")
-{
- MStack<ClipRect> stack(10);
- REQUIRE(-1 == (stack.mPointer - stack.mStack));
- REQUIRE(0 == stack.mStack[0].xOffset);
-
- ClipRect &val1 = stack.push();
- val1.xOffset = 10;
- ClipRect &val2 = stack.top();
- REQUIRE(0 == stack.mPointer - stack.mStack);
- REQUIRE(10 == val2.xOffset);
- REQUIRE(10 == stack.mStack[0].xOffset);
- REQUIRE(0 == stack.mStack[1].xOffset);
-
- val2.yOffset = 2;
- REQUIRE(2 == val1.yOffset);
-}
-
-TEST_CASE("mstack push 2", "")
-{
- MStack<ClipRect> stack(10);
- ClipRect &val1 = stack.push();
- val1.xOffset = 10;
- const ClipRect &val2 = stack.top();
- REQUIRE(10 == val2.xOffset);
- REQUIRE(10 == stack.mStack[0].xOffset);
-
- val1.yOffset = 2;
- REQUIRE(2 == val2.yOffset);
- REQUIRE(2 == stack.mStack[0].yOffset);
-}
-
-TEST_CASE("mstack push 3", "")
-{
- MStack<ClipRect> stack(10);
- ClipRect &val1 = stack.push();
- val1.xOffset = 10;
- ClipRect &val2 = stack.top();
- REQUIRE(10 == val2.xOffset);
- REQUIRE(10 == stack.mStack[0].xOffset);
-}
-
-TEST_CASE("mstack push 4", "")
-{
- MStack<ClipRect> stack(10);
- ClipRect &val1 = stack.push();
- val1.xOffset = 10;
- REQUIRE(10 == val1.xOffset);
- REQUIRE(10 == stack.mStack[0].xOffset);
- REQUIRE(0 == stack.mStack[1].xOffset);
- REQUIRE(0 == stack.mStack[2].xOffset);
-
- ClipRect &val2 = stack.push();
- val2.xOffset = 20;
- REQUIRE(20 == val2.xOffset);
- REQUIRE(10 == stack.mStack[0].xOffset);
- REQUIRE(20 == stack.mStack[1].xOffset);
- REQUIRE(0 == stack.mStack[2].xOffset);
-
- ClipRect &val3 = stack.push();
- val3.xOffset = 30;
- REQUIRE(30 == val3.xOffset);
- REQUIRE(10 == stack.mStack[0].xOffset);
- REQUIRE(20 == stack.mStack[1].xOffset);
- REQUIRE(30 == stack.mStack[2].xOffset);
-}
-
-TEST_CASE("mstack pop 1", "")
-{
- MStack<ClipRect> stack(10);
- ClipRect &val1 = stack.push();
- val1.xOffset = 10;
- REQUIRE(10 == stack.mStack[0].xOffset);
-
- stack.pop();
- REQUIRE(-1 == stack.mPointer - stack.mStack);
-}
-
-TEST_CASE("mstack pop 2", "")
-{
- MStack<ClipRect> stack(10);
- ClipRect &val1 = stack.push();
- REQUIRE(0 == stack.mPointer - stack.mStack);
-
- val1.xOffset = 10;
- REQUIRE(10 == stack.mStack[0].xOffset);
-
- ClipRect &val2 = stack.push();
- REQUIRE(1 == stack.mPointer - stack.mStack);
-
- val2.xOffset = 20;
- REQUIRE(10 == stack.mStack[0].xOffset);
- REQUIRE(20 == stack.mStack[1].xOffset);
-
- stack.pop();
- REQUIRE(0 == stack.mPointer - stack.mStack);
- REQUIRE(10 == stack.mStack[0].xOffset);
- REQUIRE(20 == stack.mStack[1].xOffset);
-
- ClipRect &val3 = stack.top();
- REQUIRE(0 == stack.mPointer - stack.mStack);
- REQUIRE(10 == val1.xOffset);
- REQUIRE(20 == val2.xOffset);
- REQUIRE(10 == val3.xOffset);
- REQUIRE(10 == stack.mStack[0].xOffset);
- REQUIRE(20 == stack.mStack[1].xOffset);
- REQUIRE(0 == stack.mStack[2].xOffset);
-}
-
-TEST_CASE("mstack clear 1", "")
-{
- MStack<ClipRect> stack(10);
- REQUIRE(-1 == stack.mPointer - stack.mStack);
- REQUIRE(0 == stack.mStack[0].xOffset);
-
- ClipRect &val1 = stack.push();
- val1.xOffset = 10;
-
- stack.clear();
- REQUIRE(-1 == stack.mPointer - stack.mStack);
- REQUIRE(10 == stack.mStack[0].xOffset);
- REQUIRE(0 == stack.mStack[1].xOffset);
-}
-
-TEST_CASE("mstack getpop 1", "")
-{
- MStack<ClipRect> stack(10);
- ClipRect &val1 = stack.push();
- val1.xOffset = 10;
- REQUIRE(10 == stack.mStack[0].xOffset);
- REQUIRE(10 == val1.xOffset);
-
- ClipRect &val2 = stack.getPop();
- REQUIRE(-1 == stack.mPointer - stack.mStack);
- REQUIRE(10 == stack.mStack[0].xOffset);
- REQUIRE(10 == val2.xOffset);
-}
diff --git a/src/unittests/resources/resourcemanager/resourcemanager.cc b/src/unittests/resources/resourcemanager/resourcemanager.cc
deleted file mode 100644
index 4b67af82e..000000000
--- a/src/unittests/resources/resourcemanager/resourcemanager.cc
+++ /dev/null
@@ -1,693 +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 "unittests/unittests.h"
-
-#include "client.h"
-#include "configmanager.h"
-#include "configuration.h"
-#include "dirs.h"
-#include "graphicsmanager.h"
-
-#include "being/actorsprite.h"
-
-#include "fs/virtfs/fs.h"
-
-#include "gui/userpalette.h"
-#include "gui/theme.h"
-
-#include "resources/sdlimagehelper.h"
-
-#include "resources/resourcemanager/resourcemanager.h"
-
-#include "utils/env.h"
-#include "utils/delete2.h"
-
-#include <unistd.h>
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#ifndef USE_SDL2
-#include <SDL.h>
-#endif // USE_SDL2
-PRAGMA48(GCC diagnostic pop)
-
-#include "debug.h"
-
-namespace
-{
- int testResouceCounter = 0;
-
- class TestResource : public Resource
- {
- public:
- TestResource() :
- Resource()
- {
- testResouceCounter ++;
- }
-
- ~TestResource()
- {
- testResouceCounter --;
- }
- };
-
- struct TestLoader final
- {
- std::string path;
- static Resource *load(const void *const v)
- {
- BLOCK_START("TestLoader::load")
- if (v == nullptr)
- {
- BLOCK_END("TestLoader::load")
- return nullptr;
- }
-
- Resource *const res = new TestResource();
- BLOCK_END("TestLoader::load")
- return res;
- }
- };
-
-} // namespace
-
-TEST_CASE("resourcemanager", "resourcemanager")
-{
- setEnv("SDL_VIDEODRIVER", "dummy");
-
- client = new Client;
- XML::initXML();
- SDL_Init(SDL_INIT_VIDEO);
- VirtFs::mountDirSilent("data", Append_false);
- VirtFs::mountDirSilent("../data", Append_false);
-
- imageHelper = new SDLImageHelper();
-
- Dirs::initRootDir();
- Dirs::initHomeDir();
-
- setBrandingDefaults(branding);
- ConfigManager::initConfiguration();
-
-#ifdef USE_SDL2
- SDLImageHelper::setRenderer(graphicsManager.createRenderer(
- graphicsManager.createWindow(640, 480, 0,
- SDL_WINDOW_SHOWN | SDL_SWSURFACE), SDL_RENDERER_SOFTWARE));
-#else // USE_SDL2
-
- graphicsManager.createWindow(640, 480, 0, SDL_ANYFORMAT | SDL_SWSURFACE);
-#endif // USE_SDL2
-
- userPalette = new UserPalette;
-
- theme = new Theme;
- Theme::selectSkin();
-
- ActorSprite::load();
-
-// ConfigManager::initConfiguration();
-// setConfigDefaults2(config);
-
- while (ResourceManager::cleanOrphans(true))
- continue;
-
- testResouceCounter = 0;
- const size_t resSize = ResourceManager::getResources().size();
-
- SECTION("resourcemanager get 0")
- {
- REQUIRE(testResouceCounter == 0);
- REQUIRE(ResourceManager::getResources().size() == 0 + resSize);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- }
-
- SECTION("resourcemanager get 1")
- {
- REQUIRE(testResouceCounter == 0);
- TestLoader rl = { "test1" };
- Resource *res = ResourceManager::get("test1",
- TestLoader::load, &rl);
- REQUIRE(testResouceCounter == 1);
- REQUIRE(res != nullptr);
- REQUIRE(res->mRefCount == 1);
- REQUIRE(ResourceManager::getResources().size() == 1 + resSize);
- REQUIRE(ResourceManager::getResources()["test1"] == res);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- res->decRef();
- REQUIRE(res->mRefCount == 0);
- }
-
- SECTION("resourcemanager get 2")
- {
- TestLoader rl = { "test1" };
- Resource *const res = ResourceManager::get("test1",
- TestLoader::load, &rl);
- REQUIRE(res != nullptr);
- REQUIRE(testResouceCounter == 1);
- REQUIRE(res->mRefCount == 1);
- res->mSource = "source 1";
- REQUIRE(res->mSource == "source 1");
- REQUIRE(ResourceManager::getResources().size() == 1 + resSize);
- REQUIRE(ResourceManager::getResources()["test1"] == res);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- Resource *const res2 = ResourceManager::get("test1",
- TestLoader::load, &rl);
- REQUIRE(res2 != nullptr);
- REQUIRE(testResouceCounter == 1);
- REQUIRE(res->mRefCount == 2);
- REQUIRE(res2->mRefCount == 2);
- REQUIRE(res->mIdPath == res2->mIdPath);
- REQUIRE(res2->mSource == "source 1");
- REQUIRE(ResourceManager::getResources().size() == 1 + resSize);
- REQUIRE(ResourceManager::getResources()["test1"] == res2);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- res->decRef();
- res2->decRef();
- REQUIRE(res->mRefCount == 0);
- }
-
- SECTION("resourcemanager get 3")
- {
- TestLoader rl = { "test1" };
- Resource *res = ResourceManager::get("test1",
- TestLoader::load, &rl);
- REQUIRE(res != nullptr);
- REQUIRE(testResouceCounter == 1);
- REQUIRE(res->mRefCount == 1);
- REQUIRE(ResourceManager::getResources().size() == 1 + resSize);
- REQUIRE(ResourceManager::getResources()["test1"] == res);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- res->mSource = "source 1";
- res->decRef();
- REQUIRE(ResourceManager::getResources().size() == 0 + resSize);
- REQUIRE(ResourceManager::getOrphanedResources()["test1"] == res);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- REQUIRE(res->mRefCount == 0);
- }
-
- SECTION("resourcemanager get 4")
- {
- TestLoader rl = { "test1" };
- Resource *res = ResourceManager::get("test1",
- TestLoader::load, &rl);
- REQUIRE(res != nullptr);
- REQUIRE(testResouceCounter == 1);
- REQUIRE(res->mRefCount == 1);
- REQUIRE(ResourceManager::getResources().size() == 1 + resSize);
- REQUIRE(ResourceManager::getResources()["test1"] == res);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- res->mSource = "source 1";
- res->decRef();
- REQUIRE(res->mRefCount == 0);
- REQUIRE(ResourceManager::getResources().size() == 0 + resSize);
- REQUIRE(ResourceManager::getOrphanedResources()["test1"] == res);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
-
- Resource *const res2 = ResourceManager::get("test1",
- TestLoader::load, &rl);
- REQUIRE(res2 != nullptr);
- REQUIRE(testResouceCounter == 1);
- REQUIRE(res2->mRefCount == 1);
- REQUIRE(res->mIdPath == res2->mIdPath);
- REQUIRE(res2->mSource == "source 1");
- REQUIRE(ResourceManager::getResources().size() == 1 + resSize);
- REQUIRE(ResourceManager::getResources()["test1"] == res2);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- res2->decRef();
- REQUIRE(res->mRefCount == 0);
- }
-
- SECTION("resourcemanager get 5")
- {
- TestLoader rl = { "test1" };
- Resource *res = ResourceManager::get("test1",
- TestLoader::load, &rl);
- REQUIRE(ResourceManager::isInCache("test1") == true);
- REQUIRE(res != nullptr);
- REQUIRE(testResouceCounter == 1);
- REQUIRE(res->mRefCount == 1);
- REQUIRE(ResourceManager::getResources().size() == 1 + resSize);
- REQUIRE(ResourceManager::getResources()["test1"] == res);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- res->mSource = "source 1";
- res->decRef();
- REQUIRE(res->mRefCount == 0);
- REQUIRE(ResourceManager::getResources().size() == 0 + resSize);
- REQUIRE(ResourceManager::getOrphanedResources().size() == 1);
- REQUIRE(ResourceManager::getOrphanedResources()["test1"] == res);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
-
- sleep(33);
- ResourceManager::cleanOrphans();
- REQUIRE(ResourceManager::isInCache("test1") == false);
- REQUIRE(testResouceCounter == 0);
- REQUIRE(ResourceManager::getResources().size() == 0 + resSize);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
-
- Resource *const res2 = ResourceManager::get("test1",
- TestLoader::load, &rl);
- REQUIRE(ResourceManager::isInCache("test1") == true);
- REQUIRE(res2 != nullptr);
- REQUIRE(testResouceCounter == 1);
- REQUIRE(res2->mRefCount == 1);
- REQUIRE(res2->mSource.empty());
- REQUIRE(ResourceManager::getResources().size() == 1 + resSize);
- REQUIRE(ResourceManager::getResources()["test1"] == res2);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- res2->decRef();
- REQUIRE(res2->mRefCount == 0);
- }
-
- SECTION("resourcemanager get 6")
- {
- TestLoader rl = { "test1" };
- Resource *res = ResourceManager::get("test1",
- TestLoader::load, &rl);
- REQUIRE(res != nullptr);
- REQUIRE(testResouceCounter == 1);
- REQUIRE(res->mRefCount == 1);
- res->mSource = "source 1";
- REQUIRE(ResourceManager::getResources().size() == 1 + resSize);
- REQUIRE(ResourceManager::getResources()["test1"] == res);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
-
- Resource *const res2 = ResourceManager::get("test2",
- TestLoader::load, &rl);
- REQUIRE(res2 != nullptr);
- REQUIRE(testResouceCounter == 2);
- REQUIRE(res2->mRefCount == 1);
- REQUIRE(res2->mSource.empty());
- REQUIRE(ResourceManager::getResources().size() == 2 + resSize);
- REQUIRE(ResourceManager::getResources()["test1"] == res);
- REQUIRE(ResourceManager::getResources()["test2"] == res2);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- res->decRef();
- res2->decRef();
- REQUIRE(res->mRefCount == 0);
- REQUIRE(res2->mRefCount == 0);
- }
-
- SECTION("resourcemanager getFromCache 1")
- {
- TestLoader rl = { "test1" };
- Resource *res = ResourceManager::get("test1",
- TestLoader::load, &rl);
- REQUIRE(res != nullptr);
- REQUIRE(testResouceCounter == 1);
- REQUIRE(res->mRefCount == 1);
- REQUIRE(ResourceManager::getResources().size() == 1 + resSize);
- REQUIRE(ResourceManager::getResources()["test1"] == res);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- Resource *const res2 = ResourceManager::getFromCache("test1");
- REQUIRE(res2 != nullptr);
- REQUIRE(testResouceCounter == 1);
- REQUIRE(res2->mRefCount == 2);
- REQUIRE(res == res2);
- REQUIRE(res2->mSource.empty());
- REQUIRE(ResourceManager::getResources().size() == 1 + resSize);
- REQUIRE(ResourceManager::getResources()["test1"] == res2);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- res->decRef();
- res->decRef();
- REQUIRE(res->mRefCount == 0);
- }
-
- SECTION("resourcemanager getFromCache 2")
- {
- TestLoader rl = { "test1" };
- Resource *res = ResourceManager::get("test1",
- TestLoader::load, &rl);
- REQUIRE(res != nullptr);
- REQUIRE(testResouceCounter == 1);
- REQUIRE(res->mRefCount == 1);
- REQUIRE(ResourceManager::getResources().size() == 1 + resSize);
- REQUIRE(ResourceManager::getResources()["test1"] == res);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- res->decRef();
- REQUIRE(res->mRefCount == 0);
- Resource *const res2 = ResourceManager::getFromCache("test1");
- REQUIRE(res2 != nullptr);
- REQUIRE(testResouceCounter == 1);
- REQUIRE(res2->mRefCount == 1);
- REQUIRE(res == res2);
- REQUIRE(res2->mSource.empty());
- REQUIRE(ResourceManager::getResources().size() == 1 + resSize);
- REQUIRE(ResourceManager::getResources()["test1"] == res2);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- res->decRef();
- REQUIRE(res->mRefCount == 0);
- }
-
- SECTION("resourcemanager getFromCache 3")
- {
- TestLoader rl = { "test1" };
- Resource *res = ResourceManager::get("test1",
- TestLoader::load, &rl);
- REQUIRE(res != nullptr);
- REQUIRE(testResouceCounter == 1);
- REQUIRE(res->mRefCount == 1);
- res->mSource = "source 1";
- REQUIRE(ResourceManager::getResources().size() == 1 + resSize);
- REQUIRE(ResourceManager::getResources()["test1"] == res);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
-
- Resource *const res2 = ResourceManager::get("test2",
- TestLoader::load, &rl);
- REQUIRE(res2 != nullptr);
- REQUIRE(testResouceCounter == 2);
- REQUIRE(res2->mRefCount == 1);
- REQUIRE(res2->mSource.empty());
- REQUIRE(ResourceManager::getResources().size() == 2 + resSize);
- REQUIRE(ResourceManager::getResources()["test1"] == res);
- REQUIRE(ResourceManager::getResources()["test2"] == res2);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
-
- Resource *const resC = ResourceManager::getFromCache("test1");
- Resource *const res2C = ResourceManager::getFromCache("test2");
- REQUIRE(resC != nullptr);
- REQUIRE(res2C != nullptr);
- REQUIRE(testResouceCounter == 2);
- REQUIRE(res == resC);
- REQUIRE(res2 == res2C);
- REQUIRE(resC->mRefCount == 2);
- REQUIRE(res2C->mRefCount == 2);
- REQUIRE(ResourceManager::getResources().size() == 2 + resSize);
- REQUIRE(ResourceManager::getResources()["test1"] == resC);
- REQUIRE(ResourceManager::getResources()["test2"] == res2C);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
-
- res->decRef();
- res->decRef();
- res2->decRef();
- res2->decRef();
- REQUIRE(res->mRefCount == 0);
- REQUIRE(res2->mRefCount == 0);
- }
-
- SECTION("resourcemanager addResource 1")
- {
- REQUIRE(testResouceCounter == 0);
- Resource *res = new TestResource();
- REQUIRE(testResouceCounter == 1);
- ResourceManager::addResource("test1", res);
- REQUIRE(res != nullptr);
- REQUIRE(res->mRefCount == 1);
- REQUIRE(ResourceManager::getResources().size() == 1 + resSize);
- REQUIRE(ResourceManager::getResources()["test1"] == res);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- res->decRef();
- REQUIRE(res->mRefCount == 0);
- }
-
- SECTION("resourcemanager isInCache 1")
- {
- REQUIRE(testResouceCounter == 0);
- TestLoader rl = { "test1" };
- REQUIRE(ResourceManager::isInCache("test1") == false);
- Resource *res = ResourceManager::get("test1",
- TestLoader::load, &rl);
- REQUIRE(ResourceManager::isInCache("test1") == true);
- REQUIRE(ResourceManager::isInCache("test2") == false);
- REQUIRE(testResouceCounter == 1);
- REQUIRE(res != nullptr);
- REQUIRE(res->mRefCount == 1);
- REQUIRE(ResourceManager::getResources().size() == 1 + resSize);
- REQUIRE(ResourceManager::getResources()["test1"] == res);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- res->decRef();
- REQUIRE(res->mRefCount == 0);
- }
-
- SECTION("resourcemanager getTempResource 1")
- {
- TestLoader rl = { "test1" };
- REQUIRE(ResourceManager::getTempResource("test1") == nullptr);
- Resource *res = ResourceManager::get("test1",
- TestLoader::load, &rl);
- REQUIRE(res != nullptr);
- REQUIRE(testResouceCounter == 1);
- REQUIRE(res->mRefCount == 1);
- REQUIRE(ResourceManager::getResources().size() == 1 + resSize);
- REQUIRE(ResourceManager::getResources()["test1"] == res);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- Resource *const res2 = ResourceManager::getTempResource("test1");
- REQUIRE(ResourceManager::getTempResource("test2") == nullptr);
- REQUIRE(res2 != nullptr);
- REQUIRE(testResouceCounter == 1);
- REQUIRE(res2->mRefCount == 1);
- REQUIRE(res == res2);
- REQUIRE(res2->mSource.empty());
- REQUIRE(ResourceManager::getResources().size() == 1 + resSize);
- REQUIRE(ResourceManager::getResources()["test1"] == res2);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- res->decRef();
- REQUIRE(res->mRefCount == 0);
- }
-
- SECTION("resourcemanager moveToDeleted 1")
- {
- REQUIRE(testResouceCounter == 0);
- TestLoader rl = { "test1" };
- Resource *res = ResourceManager::get("test1",
- TestLoader::load, &rl);
- REQUIRE(testResouceCounter == 1);
- REQUIRE(res != nullptr);
- REQUIRE(res->mRefCount == 1);
- REQUIRE(ResourceManager::getResources().size() == 1 + resSize);
- REQUIRE(ResourceManager::getResources()["test1"] == res);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- ResourceManager::moveToDeleted(res);
- REQUIRE(testResouceCounter == 0);
- REQUIRE(ResourceManager::getResources().size() == 0 + resSize);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- }
-
- SECTION("resourcemanager moveToDeleted 2")
- {
- REQUIRE(testResouceCounter == 0);
- TestLoader rl = { "test1" };
- Resource *res = ResourceManager::get("test1",
- TestLoader::load, &rl);
- res->incRef();
- REQUIRE(testResouceCounter == 1);
- REQUIRE(res != nullptr);
- REQUIRE(res->mRefCount == 2);
- REQUIRE(ResourceManager::getResources().size() == 1 + resSize);
- REQUIRE(ResourceManager::getResources()["test1"] == res);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- ResourceManager::moveToDeleted(res);
- REQUIRE(testResouceCounter == 1);
- REQUIRE(res->mRefCount == 1);
- REQUIRE(ResourceManager::getResources().size() == 0 + resSize);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().size() == 1);
- res->decRef();
- }
-
- SECTION("resourcemanager moveToDeleted 3")
- {
- REQUIRE(testResouceCounter == 0);
- TestLoader rl = { "test1" };
- Resource *res = ResourceManager::get("test1",
- TestLoader::load, &rl);
- REQUIRE(testResouceCounter == 1);
- REQUIRE(res != nullptr);
- REQUIRE(res->mRefCount == 1);
- REQUIRE(ResourceManager::getResources().size() == 1 + resSize);
- REQUIRE(ResourceManager::getResources()["test1"] == res);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
-
- res->decRef();
- REQUIRE(testResouceCounter == 1);
- REQUIRE(res->mRefCount == 0);
- REQUIRE(ResourceManager::getResources().size() == 0 + resSize);
- REQUIRE(ResourceManager::getOrphanedResources().size() == 1);
- REQUIRE(ResourceManager::getOrphanedResources()["test1"] == res);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
-
- ResourceManager::moveToDeleted(res);
- REQUIRE(testResouceCounter == 0);
- REQUIRE(ResourceManager::getResources().size() == 0 + resSize);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- }
-
- SECTION("resourcemanager decRefDelete 1")
- {
- REQUIRE(testResouceCounter == 0);
- TestLoader rl = { "test1" };
- Resource *res = ResourceManager::get("test1",
- TestLoader::load, &rl);
- REQUIRE(testResouceCounter == 1);
- REQUIRE(res != nullptr);
- REQUIRE(res->mRefCount == 1);
- REQUIRE(ResourceManager::getResources().size() == 1 + resSize);
- REQUIRE(ResourceManager::getResources()["test1"] == res);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
-
- ResourceManager::decRefDelete(res);
- REQUIRE(testResouceCounter == 0);
- REQUIRE(ResourceManager::getResources().size() == 0 + resSize);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- }
-
- SECTION("resourcemanager cleanUp 1")
- {
- REQUIRE(testResouceCounter == 0);
- TestLoader rl = { "test1" };
- Resource *res = ResourceManager::get("test1",
- TestLoader::load, &rl);
- REQUIRE(testResouceCounter == 1);
- REQUIRE(res != nullptr);
- REQUIRE(res->mRefCount == 1);
- REQUIRE(ResourceManager::getResources().size() == 1 + resSize);
- REQUIRE(ResourceManager::getResources()["test1"] == res);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- res->decRef();
-
- ResourceManager::cleanUp(res);
- REQUIRE(testResouceCounter == 0);
- REQUIRE(ResourceManager::getResources().size() == 0 + resSize);
- REQUIRE(ResourceManager::getOrphanedResources().size() == 1);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- ResourceManager::getOrphanedResources().clear();
- }
-
- SECTION("resourcemanager cleanProtected 1")
- {
- REQUIRE(testResouceCounter == 0);
- TestLoader rl = { "test1" };
- Resource *res = ResourceManager::get("test1",
- TestLoader::load, &rl);
- REQUIRE(testResouceCounter == 1);
- REQUIRE(res != nullptr);
- REQUIRE(res->mRefCount == 1);
- REQUIRE(ResourceManager::getResources().size() == 1 + resSize);
- REQUIRE(ResourceManager::getResources()["test1"] == res);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- res->mProtected = true;
- ResourceManager::cleanProtected();
-
- REQUIRE(testResouceCounter == 1);
- REQUIRE(ResourceManager::getResources().size() == 0 + resSize);
- REQUIRE(ResourceManager::getOrphanedResources().size() == 1);
- REQUIRE(ResourceManager::getOrphanedResources()["test1"] == res);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- res->decRef();
- }
-
- SECTION("resourcemanager clearDeleted 1")
- {
- REQUIRE(testResouceCounter == 0);
- TestLoader rl = { "test1" };
- Resource *res = ResourceManager::get("test1",
- TestLoader::load, &rl);
- res->incRef();
- REQUIRE(testResouceCounter == 1);
- REQUIRE(res != nullptr);
- REQUIRE(res->mRefCount == 2);
- REQUIRE(ResourceManager::getResources().size() == 1 + resSize);
- REQUIRE(ResourceManager::getResources()["test1"] == res);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- ResourceManager::moveToDeleted(res);
- REQUIRE(testResouceCounter == 1);
- REQUIRE(res->mRefCount == 1);
- REQUIRE(ResourceManager::getResources().size() == 0 + resSize);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().size() == 1);
-
- ResourceManager::clearDeleted();
- REQUIRE(testResouceCounter == 1);
- REQUIRE(res->mRefCount == 1);
- REQUIRE(ResourceManager::getResources().size() == 0 + resSize);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().size() == 1);
- res->decRef();
- }
-
- SECTION("resourcemanager clearDeleted 2")
- {
- REQUIRE(testResouceCounter == 0);
- TestLoader rl = { "test1" };
- Resource *res = ResourceManager::get("test1",
- TestLoader::load, &rl);
- res->incRef();
- REQUIRE(testResouceCounter == 1);
- REQUIRE(res != nullptr);
- REQUIRE(res->mRefCount == 2);
- REQUIRE(ResourceManager::getResources().size() == 1 + resSize);
- REQUIRE(ResourceManager::getResources()["test1"] == res);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- ResourceManager::moveToDeleted(res);
- REQUIRE(testResouceCounter == 1);
- REQUIRE(res->mRefCount == 1);
- REQUIRE(ResourceManager::getResources().size() == 0 + resSize);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().size() == 1);
-
- res->decRef();
- ResourceManager::clearDeleted();
- REQUIRE(testResouceCounter == 0);
- REQUIRE(ResourceManager::getResources().size() == 0 + resSize);
- REQUIRE(ResourceManager::getOrphanedResources().empty() == true);
- REQUIRE(ResourceManager::getDeletedResources().empty() == true);
- }
-
- delete2(userPalette);
- delete2(theme);
- delete2(client);
- VirtFs::unmountDirSilent("data");
- VirtFs::unmountDirSilent("../data");
-}
diff --git a/src/unittests/resources/sdlimagehelper.cc b/src/unittests/resources/sdlimagehelper.cc
deleted file mode 100644
index 931acbb88..000000000
--- a/src/unittests/resources/sdlimagehelper.cc
+++ /dev/null
@@ -1,559 +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 USE_SDL2
-#include "localconsts.h"
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_endian.h>
-PRAGMA48(GCC diagnostic pop)
-#if SDL_BYTEORDER == SDL_LIL_ENDIAN
-
-#include "unittests/unittests.h"
-
-#include "client.h"
-#include "configmanager.h"
-#include "configuration.h"
-#include "dirs.h"
-#include "graphicsmanager.h"
-
-#include "being/actorsprite.h"
-
-#include "fs/virtfs/fs.h"
-
-#include "gui/userpalette.h"
-#include "gui/theme.h"
-
-#include "utils/delete2.h"
-#include "utils/env.h"
-
-#include "render/sdlgraphics.h"
-
-#include "resources/sdlimagehelper.h"
-
-#include "debug.h"
-
-static SDL_Surface *createSoftware32BitSurface(int width,
- int height)
-{
-#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);
-}
-
-TEST_CASE("sdlimagehelper combineSurface", "")
-{
- setEnv("SDL_VIDEODRIVER", "dummy");
-
- client = new Client;
- VirtFs::mountDirSilent("data", Append_false);
- VirtFs::mountDirSilent("../data", Append_false);
-
- mainGraphics = new SDLGraphics;
- imageHelper = new SDLImageHelper;
-
- Dirs::initRootDir();
- Dirs::initHomeDir();
-
- setBrandingDefaults(branding);
- ConfigManager::initConfiguration();
-
-#ifdef USE_SDL2
- SDLImageHelper::setRenderer(graphicsManager.createRenderer(
- graphicsManager.createWindow(640, 480, 0,
- SDL_WINDOW_SHOWN | SDL_SWSURFACE), SDL_RENDERER_SOFTWARE));
-#else // USE_SDL2
-
- graphicsManager.createWindow(640, 480, 0, SDL_ANYFORMAT | SDL_SWSURFACE);
-#endif // USE_SDL2
-
- userPalette = new UserPalette;
-
- theme = new Theme;
- Theme::selectSkin();
-
- ActorSprite::load();
-
- SECTION("empty copy1")
- {
- SDL_Surface *surface1 = createSoftware32BitSurface(2, 2);
- uint32_t *ptr1 = static_cast<uint32_t*>(surface1->pixels);
- for (int f = 0; f < 2 * 2; f ++)
- ptr1[f] = 0xff000000;
- SDL_Surface *surface2 = createSoftware32BitSurface(2, 2);
- uint32_t *ptr2 = static_cast<uint32_t*>(surface2->pixels);
-
- ptr2[0] = 0xff000000;
- ptr2[1] = 0x00ff0000;
- ptr2[2] = 0x0000ff00;
- ptr2[3] = 0x000000ff;
-
- SDLImageHelper::combineSurface(surface2,
- nullptr,
- surface1,
- nullptr);
-
- // src image test
- REQUIRE(ptr2[0] == 0xff000000);
- REQUIRE(ptr2[1] == 0x00ff0000);
- REQUIRE(ptr2[2] == 0x0000ff00);
- REQUIRE(ptr2[3] == 0x000000ff);
-
- REQUIRE(ptr1[0] == 0xff000000);
- REQUIRE(ptr1[1] == 0xff000000);
- REQUIRE(ptr1[2] == 0xff000000);
- REQUIRE(ptr1[3] == 0xff000000);
- MSDL_FreeSurface(surface1);
- MSDL_FreeSurface(surface2);
- }
-
- SECTION("empty copy2")
- {
- SDL_Surface *surface1 = createSoftware32BitSurface(2, 2);
- uint32_t *ptr1 = static_cast<uint32_t*>(surface1->pixels);
- for (int f = 0; f < 2 * 2; f ++)
- ptr1[f] = 0xff000000;
- SDL_Surface *surface2 = createSoftware32BitSurface(2, 2);
- uint32_t *ptr2 = static_cast<uint32_t*>(surface2->pixels);
-
- ptr2[0] = 0xff112233;
- ptr2[1] = 0xff003344;
- ptr2[2] = 0xff330055;
- ptr2[3] = 0xff445500;
-
- SDLImageHelper::combineSurface(surface2,
- nullptr,
- surface1,
- nullptr);
-
- REQUIRE(ptr1[0] == 0xff112233);
- REQUIRE(ptr1[1] == 0xff003344);
- REQUIRE(ptr1[2] == 0xff330055);
- REQUIRE(ptr1[3] == 0xff445500);
- MSDL_FreeSurface(surface1);
- MSDL_FreeSurface(surface2);
- }
-
- SECTION("empty copy3")
- {
- SDL_Surface *surface1 = createSoftware32BitSurface(2, 2);
- uint32_t *ptr1 = static_cast<uint32_t*>(surface1->pixels);
- for (int f = 0; f < 2 * 2; f ++)
- ptr1[f] = 0x00000000;
- SDL_Surface *surface2 = createSoftware32BitSurface(2, 2);
- uint32_t *ptr2 = static_cast<uint32_t*>(surface2->pixels);
-
- ptr2[0] = 0xff112233;
- ptr2[1] = 0xff003344;
- ptr2[2] = 0xff330055;
- ptr2[3] = 0xff445500;
-
- SDLImageHelper::combineSurface(surface2,
- nullptr,
- surface1,
- nullptr);
-
- REQUIRE(ptr1[0] == 0xff112233);
- REQUIRE(ptr1[1] == 0xff003344);
- REQUIRE(ptr1[2] == 0xff330055);
- REQUIRE(ptr1[3] == 0xff445500);
- MSDL_FreeSurface(surface1);
- MSDL_FreeSurface(surface2);
- }
-
- SECTION("empty copy4")
- {
- SDL_Surface *surface1 = createSoftware32BitSurface(2, 2);
- uint32_t *ptr1 = static_cast<uint32_t*>(surface1->pixels);
- for (int f = 0; f < 2 * 2; f ++)
- ptr1[f] = 0xff000000;
- SDL_Surface *surface2 = createSoftware32BitSurface(2, 2);
- uint32_t *ptr2 = static_cast<uint32_t*>(surface2->pixels);
-
- ptr2[0] = 0x50112233;
- ptr2[1] = 0x50003344;
- ptr2[2] = 0x50330055;
- ptr2[3] = 0x50445500;
-
- SDLImageHelper::combineSurface(surface2,
- nullptr,
- surface1,
- nullptr);
-
- REQUIRE(ptr1[0] == 0xff09121c);
- REQUIRE(ptr1[1] == 0xff001c25);
- REQUIRE(ptr1[2] == 0xff1c002f);
- REQUIRE(ptr1[3] == 0xff252f00);
- MSDL_FreeSurface(surface1);
- MSDL_FreeSurface(surface2);
- }
-
- SECTION("empty copy5")
- {
- SDL_Surface *surface1 = createSoftware32BitSurface(2, 2);
- uint32_t *ptr1 = static_cast<uint32_t*>(surface1->pixels);
- for (int f = 0; f < 2 * 2; f ++)
- ptr1[f] = 0x00000000;
- SDL_Surface *surface2 = createSoftware32BitSurface(2, 2);
- uint32_t *ptr2 = static_cast<uint32_t*>(surface2->pixels);
-
- ptr2[0] = 0x50112233;
- ptr2[1] = 0x50003344;
- ptr2[2] = 0x50330055;
- ptr2[3] = 0x50445500;
-
- SDLImageHelper::combineSurface(surface2,
- nullptr,
- surface1,
- nullptr);
-
- REQUIRE(ptr1[0] == 0x8e09121c);
- REQUIRE(ptr1[1] == 0x8e001c25);
- REQUIRE(ptr1[2] == 0x8e1c002f);
- REQUIRE(ptr1[3] == 0x8e252f00);
- MSDL_FreeSurface(surface1);
- MSDL_FreeSurface(surface2);
- }
-
- SECTION("empty copy6")
- {
- SDL_Surface *surface1 = createSoftware32BitSurface(2, 2);
- uint32_t *ptr1 = static_cast<uint32_t*>(surface1->pixels);
- ptr1[0] = 0x50112233;
- ptr1[1] = 0x50003344;
- ptr1[2] = 0x50330055;
- ptr1[3] = 0x50445500;
- SDL_Surface *surface2 = createSoftware32BitSurface(2, 2);
- uint32_t *ptr2 = static_cast<uint32_t*>(surface2->pixels);
-
- for (int f = 0; f < 2 * 2; f ++)
- ptr2[f] = 0x00000000;
-
- SDLImageHelper::combineSurface(surface2,
- nullptr,
- surface1,
- nullptr);
-
- REQUIRE(ptr1[0] == 0x50112233);
- REQUIRE(ptr1[1] == 0x50003344);
- REQUIRE(ptr1[2] == 0x50330055);
- REQUIRE(ptr1[3] == 0x50445500);
- MSDL_FreeSurface(surface1);
- MSDL_FreeSurface(surface2);
- }
-
- SECTION("mix 1")
- {
- SDL_Surface *surface1 = createSoftware32BitSurface(2, 2);
- uint32_t *ptr1 = static_cast<uint32_t*>(surface1->pixels);
- ptr1[0] = 0x50112233;
- ptr1[1] = 0x50003344;
- ptr1[2] = 0x50330055;
- ptr1[3] = 0x50445500;
- SDL_Surface *surface2 = createSoftware32BitSurface(2, 2);
- uint32_t *ptr2 = static_cast<uint32_t*>(surface2->pixels);
-
- ptr2[0] = 0x50003344;
- ptr2[1] = 0x50330055;
- ptr2[2] = 0x50445500;
- ptr2[3] = 0x50112233;
-
- SDLImageHelper::combineSurface(surface2,
- nullptr,
- surface1,
- nullptr);
-
- REQUIRE(ptr1[0] == 0xdf082b3c);
- REQUIRE(ptr1[1] == 0xdf1d174d);
- REQUIRE(ptr1[2] == 0xdf3d2f26);
- REQUIRE(ptr1[3] == 0xdf29391c);
- MSDL_FreeSurface(surface1);
- MSDL_FreeSurface(surface2);
- }
-
- SECTION("mix 2")
- {
- SDL_Surface *surface1 = createSoftware32BitSurface(2, 2);
- uint32_t *ptr1 = static_cast<uint32_t*>(surface1->pixels);
- ptr1[0] = 0x10112233;
- ptr1[1] = 0x20003344;
- ptr1[2] = 0x30330055;
- ptr1[3] = 0x40445500;
- SDL_Surface *surface2 = createSoftware32BitSurface(2, 2);
- uint32_t *ptr2 = static_cast<uint32_t*>(surface2->pixels);
-
- ptr2[0] = 0x50003344;
- ptr2[1] = 0x60330055;
- ptr2[2] = 0x70445500;
- ptr2[3] = 0x80112233;
-
- SDLImageHelper::combineSurface(surface2,
- nullptr,
- surface1,
- nullptr);
-
- REQUIRE(ptr1[0] == 0x9f082b3c);
- REQUIRE(ptr1[1] == 0xbd1f144e);
- REQUIRE(ptr1[2] == 0xb93f391e);
- REQUIRE(ptr1[3] == 0xf5213224);
- MSDL_FreeSurface(surface1);
- MSDL_FreeSurface(surface2);
- }
-
- SECTION("part mix 1")
- {
-// 11 11 00 00
-// 11 11 00 00
-// 00 00 00 00
-// 00 00 00 00
-
- SDL_Surface *surface1 = createSoftware32BitSurface(4, 4);
- uint32_t *ptr1 = static_cast<uint32_t*>(surface1->pixels);
- ptr1[0] = 0x10112233;
- ptr1[1] = 0x20003344;
- ptr1[2] = 0x10203040;
- ptr1[3] = 0x20304050;
- ptr1[4] = 0x30330055;
- ptr1[5] = 0x40445500;
- ptr1[6] = 0x30405060;
- ptr1[7] = 0x708090a0;
-
- ptr1[8] = 0x8090a0b0;
- ptr1[9] = 0x90a0b0c0;
- ptr1[10] = 0xa0b0c0d0;
- ptr1[11] = 0xb0c0d0e0;
- ptr1[12] = 0xc0d0e0f0;
- ptr1[13] = 0xd0e0f000;
- ptr1[14] = 0xe0f00010;
- ptr1[15] = 0xf0001020;
-
- SDL_Surface *surface2 = createSoftware32BitSurface(2, 2);
- uint32_t *ptr2 = static_cast<uint32_t*>(surface2->pixels);
-
- ptr2[0] = 0x50003344;
- ptr2[1] = 0x60330055;
- ptr2[2] = 0x70445500;
- ptr2[3] = 0x80112233;
-
- SDLImageHelper::combineSurface(surface2,
- nullptr,
- surface1,
- nullptr);
-
- REQUIRE(ptr1[0] == 0x9f082b3c);
- REQUIRE(ptr1[1] == 0xbd1f144e);
- REQUIRE(ptr1[2] == 0x10203040);
- REQUIRE(ptr1[3] == 0x20304050);
- REQUIRE(ptr1[4] == 0xb93f391e);
- REQUIRE(ptr1[5] == 0xf5213224);
- REQUIRE(ptr1[6] == 0x30405060);
- REQUIRE(ptr1[7] == 0x708090a0);
-
- REQUIRE(ptr1[8] == 0x8090a0b0);
- REQUIRE(ptr1[9] == 0x90a0b0c0);
- REQUIRE(ptr1[10] == 0xa0b0c0d0);
- REQUIRE(ptr1[11] == 0xb0c0d0e0);
- REQUIRE(ptr1[12] == 0xc0d0e0f0);
- REQUIRE(ptr1[13] == 0xd0e0f000);
- REQUIRE(ptr1[14] == 0xe0f00010);
- REQUIRE(ptr1[15] == 0xf0001020);
-
- MSDL_FreeSurface(surface1);
- MSDL_FreeSurface(surface2);
- }
-
- SECTION("part mix 2")
- {
-// 00 00 00 00
-// 00 11 11 00
-// 00 11 11 00
-// 00 00 00 00
-
- SDL_Surface *surface1 = createSoftware32BitSurface(4, 4);
- uint32_t *ptr1 = static_cast<uint32_t*>(surface1->pixels);
-
- ptr1[0] = 0x10203040;
- ptr1[1] = 0x20304050;
- ptr1[2] = 0x30405060;
- ptr1[3] = 0x708090a0;
- ptr1[4] = 0x8090a0b0;
-
- ptr1[5] = 0x10112233; // +
- ptr1[6] = 0x20003344; // +
-
- ptr1[7] = 0x90a0b0c0;
- ptr1[8] = 0xa0b0c0d0;
-
- ptr1[9] = 0x30330055; // +
- ptr1[10] = 0x40445500; // +
-
- ptr1[11] = 0xb0c0d0e0;
- ptr1[12] = 0xc0d0e0f0;
- ptr1[13] = 0xd0e0f000;
- ptr1[14] = 0xe0f00010;
- ptr1[15] = 0xf0001020;
-
- SDL_Surface *surface2 = createSoftware32BitSurface(2, 2);
- uint32_t *ptr2 = static_cast<uint32_t*>(surface2->pixels);
-
- ptr2[0] = 0x50003344;
- ptr2[1] = 0x60330055;
- ptr2[2] = 0x70445500;
- ptr2[3] = 0x80112233;
-
- SDL_Rect rect1;
- SDL_Rect rect2;
- rect1.x = 1;
- rect1.y = 1;
- rect1.w = 2;
- rect1.h = 2;
- rect2.x = 0;
- rect2.y = 0;
- rect2.w = 2;
- rect2.h = 2;
- SDLImageHelper::combineSurface(surface2,
- &rect2,
- surface1,
- &rect1);
-
- REQUIRE(ptr1[0] == 0x10203040);
- REQUIRE(ptr1[1] == 0x20304050);
- REQUIRE(ptr1[2] == 0x30405060);
- REQUIRE(ptr1[3] == 0x708090a0);
- REQUIRE(ptr1[4] == 0x8090a0b0);
-
- REQUIRE(ptr1[5] == 0x9f082b3c); // +
- REQUIRE(ptr1[6] == 0xbd1f144e); // +
-
- REQUIRE(ptr1[7] == 0x90a0b0c0);
- REQUIRE(ptr1[8] == 0xa0b0c0d0);
-
- REQUIRE(ptr1[9] == 0xb93f391e); // +
- REQUIRE(ptr1[10] == 0xf5213224); // +
-
- REQUIRE(ptr1[11] == 0xb0c0d0e0);
- REQUIRE(ptr1[12] == 0xc0d0e0f0);
- REQUIRE(ptr1[13] == 0xd0e0f000);
- REQUIRE(ptr1[14] == 0xe0f00010);
- REQUIRE(ptr1[15] == 0xf0001020);
-
- MSDL_FreeSurface(surface1);
- MSDL_FreeSurface(surface2);
- }
-
- SECTION("part mix 3")
- {
- SDL_Surface *surface1 = createSoftware32BitSurface(4, 4);
- uint32_t *ptr1 = static_cast<uint32_t*>(surface1->pixels);
-
- ptr1[0] = 0x10203040;
- ptr1[1] = 0x20304050;
- ptr1[2] = 0x30405060;
- ptr1[3] = 0x708090a0;
- ptr1[4] = 0x8090a0b0;
- ptr1[5] = 0x10112233;
- ptr1[6] = 0x20003344;
- ptr1[7] = 0x90a0b0c0;
- ptr1[8] = 0xa0b0c0d0;
- ptr1[9] = 0x30330055;
- ptr1[10] = 0x40445500;
- ptr1[11] = 0xb0c0d0e0;
- ptr1[12] = 0xc0d0e0f0;
- ptr1[13] = 0xd0e0f000;
- ptr1[14] = 0xe0f00010;
- ptr1[15] = 0xf0001020;
-
- SDL_Surface *surface2 = createSoftware32BitSurface(4, 4);
- uint32_t *ptr2 = static_cast<uint32_t*>(surface2->pixels);
-
- ptr2[0] = 0x50003344;
- ptr2[1] = 0x60330055;
- ptr2[2] = 0x70445500;
- ptr2[3] = 0x80112233;
- ptr2[4] = 0x90111111;
- ptr2[5] = 0x90111111;
- ptr2[6] = 0xff000000;
- ptr2[7] = 0xff000000;
- ptr2[8] = 0xff000000;
- ptr2[9] = 0xff000000;
- ptr2[10] = 0xff000000;
- ptr2[11] = 0xff000000;
- ptr2[12] = 0xff000000;
- ptr2[13] = 0xff000000;
- ptr2[14] = 0xff000000;
- ptr2[15] = 0xff000000;
-
- SDL_Rect rect1;
- SDL_Rect rect2;
- rect1.x = 1;
- rect1.y = 1;
- rect1.w = 2;
- rect1.h = 2;
- rect2.x = 0;
- rect2.y = 0;
- rect2.w = 2;
- rect2.h = 2;
- SDLImageHelper::combineSurface(surface2,
- &rect2,
- surface1,
- &rect1);
-
- REQUIRE(ptr1[0] == 0x10203040);
- REQUIRE(ptr1[1] == 0x20304050);
- REQUIRE(ptr1[2] == 0x30405060);
- REQUIRE(ptr1[3] == 0x708090a0);
- REQUIRE(ptr1[4] == 0x8090a0b0);
- REQUIRE(ptr1[5] == 0x9f082b3c);
- REQUIRE(ptr1[6] == 0xbd1f144e);
- REQUIRE(ptr1[7] == 0x90a0b0c0);
- REQUIRE(ptr1[8] == 0xa0b0c0d0);
- REQUIRE(ptr1[9] == 0xbf1b0d23);
- REQUIRE(ptr1[10] == 0xff1f230c);
- REQUIRE(ptr1[11] == 0xb0c0d0e0);
- REQUIRE(ptr1[12] == 0xc0d0e0f0);
- REQUIRE(ptr1[13] == 0xd0e0f000);
- REQUIRE(ptr1[14] == 0xe0f00010);
- REQUIRE(ptr1[15] == 0xf0001020);
-
- MSDL_FreeSurface(surface1);
- MSDL_FreeSurface(surface2);
- }
-
- delete2(userPalette);
- delete2(theme);
- delete2(client);
- VirtFs::unmountDirSilent("data");
- VirtFs::unmountDirSilent("../data");
-}
-
-#endif // SDL_BYTEORDER == SDL_LIL_ENDIAN
-#endif // USE_SDL2
diff --git a/src/unittests/resources/sprite/animatedsprite.cc b/src/unittests/resources/sprite/animatedsprite.cc
deleted file mode 100644
index c97afeeda..000000000
--- a/src/unittests/resources/sprite/animatedsprite.cc
+++ /dev/null
@@ -1,198 +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 "unittests/unittests.h"
-
-#include "configuration.h"
-#include "configmanager.h"
-#include "client.h"
-#include "dirs.h"
-#include "graphicsmanager.h"
-
-#include "const/resources/spriteaction.h"
-
-#include "being/actorsprite.h"
-
-#include "fs/virtfs/fs.h"
-
-#include "gui/gui.h"
-#include "gui/theme.h"
-
-#include "render/sdlgraphics.h"
-
-#include "resources/sdlimagehelper.h"
-
-#include "resources/animation/animation.h"
-
-#include "resources/sprite/animatedsprite.h"
-
-#include "utils/env.h"
-#include "utils/delete2.h"
-#include "utils/mrand.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#ifndef USE_SDL2
-#include <SDL.h>
-#endif // USE_SDL2
-PRAGMA48(GCC diagnostic pop)
-
-#include "debug.h"
-
-TEST_CASE("AnimatedSprite tests", "animatedsprite")
-{
- setEnv("SDL_VIDEODRIVER", "dummy");
-
- initRand();
- client = new Client;
- XML::initXML();
- SDL_Init(SDL_INIT_VIDEO);
- VirtFs::mountDirSilent("data", Append_false);
- VirtFs::mountDirSilent("../data", Append_false);
- mainGraphics = new SDLGraphics;
- imageHelper = new SDLImageHelper();
-
- Dirs::initRootDir();
- Dirs::initHomeDir();
-
- ConfigManager::initConfiguration();
- setConfigDefaults2(config);
- setBrandingDefaults(branding);
-
-#ifdef USE_SDL2
- SDLImageHelper::setRenderer(graphicsManager.createRenderer(
- graphicsManager.createWindow(640, 480, 0,
- SDL_WINDOW_SHOWN | SDL_SWSURFACE), SDL_RENDERER_SOFTWARE));
-#else // USE_SDL2
-
- graphicsManager.createWindow(640, 480, 0, SDL_ANYFORMAT | SDL_SWSURFACE);
-#endif // USE_SDL2
-
- theme = new Theme;
- Theme::selectSkin();
-
- ActorSprite::load();
- gui = new Gui();
- gui->postInit(mainGraphics);
-
- SECTION("basic test 1")
- {
- AnimatedSprite *sprite = AnimatedSprite::load(
- "graphics/sprites/error.xml", 0);
- sprite->play(SpriteAction::DEFAULT);
-
- REQUIRE_FALSE(sprite == nullptr);
- REQUIRE_FALSE(sprite->getSprite() == nullptr);
- REQUIRE_FALSE(sprite->getAnimation() == nullptr);
- REQUIRE_FALSE(sprite->getFrame() == nullptr);
- REQUIRE(0 == sprite->getFrameIndex());
- REQUIRE(0 == sprite->getFrameTime());
- REQUIRE(false == sprite->update(1));
- REQUIRE(0 == sprite->getFrameTime());
- REQUIRE(false == sprite->update(11));
- REQUIRE(10 == sprite->getFrameTime());
- REQUIRE(0 == sprite->getFrameIndex());
- delete sprite;
- logger->log("test4");
- }
-
- SECTION("basic test 2")
- {
- AnimatedSprite *sprite = AnimatedSprite::load(
- "graphics/sprites/test.xml", 0);
- sprite->play(SpriteAction::STAND);
-
- REQUIRE(10 == const_cast<Animation*>(sprite->getAnimation())
- ->getFrames().size());
-
- REQUIRE_FALSE(nullptr == sprite);
-
- REQUIRE(false == sprite->update(1));
- REQUIRE(0 == sprite->getFrameTime());
- REQUIRE(10 == sprite->getFrame()->delay);
-
- REQUIRE(false == sprite->update(1 + 10));
- REQUIRE(0 == sprite->getFrameIndex());
- REQUIRE(10 == sprite->getFrameTime());
-
- REQUIRE(true == sprite->update(1 + 10 + 5));
- REQUIRE(1 == sprite->getFrameIndex());
- REQUIRE(5 == sprite->getFrameTime());
-
- REQUIRE(false == sprite->update(1 + 10 + 5));
- REQUIRE(1 == sprite->getFrameIndex());
- REQUIRE(5 == sprite->getFrameTime());
-
- REQUIRE(false == sprite->update(1 + 10 + 20));
- REQUIRE(1 == sprite->getFrameIndex());
- REQUIRE(20 == sprite->getFrameTime());
-
- REQUIRE(true == sprite->update(1 + 10 + 20 + 1));
- REQUIRE(2 == sprite->getFrameIndex());
- REQUIRE(1 == sprite->getFrameTime());
-
- REQUIRE(false == sprite->update(1 + 10 + 20 + 10));
- REQUIRE(2 == sprite->getFrameIndex());
- REQUIRE(10 == sprite->getFrameTime());
-
- REQUIRE(true == sprite->update(1 + 10 + 20 + 10 + 1));
- REQUIRE(4 == sprite->getFrameIndex());
- REQUIRE(1 == sprite->getFrameTime());
-
- REQUIRE(false == sprite->update(1 + 10 + 20 + 10 + 25));
- REQUIRE(4 == sprite->getFrameIndex());
- REQUIRE(25 == sprite->getFrameTime());
-
- REQUIRE(true == sprite->update(1 + 10 + 20 + 10 + 25 + 1));
- REQUIRE(6 == sprite->getFrameIndex());
- REQUIRE(1 == sprite->getFrameTime());
-
- REQUIRE(true == sprite->update(1 + 10 + 20 + 10 + 25 + 10 + 1));
- REQUIRE(8 == sprite->getFrameIndex());
- REQUIRE(1 == sprite->getFrameTime());
-
- REQUIRE(true == sprite->update(1 + 10 + 20 + 10 + 25 + 10 + 10 + 1));
- REQUIRE(4 == sprite->getFrameIndex());
- REQUIRE(1 == sprite->getFrameTime());
- delete sprite;
- }
-
- SECTION("basic test 3")
- {
- AnimatedSprite *sprite2 = AnimatedSprite::load(
- "graphics/sprites/test.xml", 0);
- sprite2->play(SpriteAction::SIT);
-
- REQUIRE(false == sprite2->update(1));
- REQUIRE(2 == const_cast<Animation*>(sprite2->getAnimation())
- ->getFrames().size());
- REQUIRE(0 == sprite2->getFrameTime());
- REQUIRE(85 == sprite2->getFrame()->delay);
-
- REQUIRE(true == sprite2->update(1 + 10 + 20 + 10 + 25 + 10 + 10 + 1));
- REQUIRE(1 == sprite2->getFrameIndex());
- REQUIRE(1 == sprite2->getFrameTime());
- delete sprite2;
- }
-
- delete2(client);
- VirtFs::unmountDirSilent("data");
- VirtFs::unmountDirSilent("../data");
-}
diff --git a/src/unittests/sdl.cc b/src/unittests/sdl.cc
deleted file mode 100644
index 8502eeed6..000000000
--- a/src/unittests/sdl.cc
+++ /dev/null
@@ -1,405 +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 "unittests/unittests.h"
-
-#include "configmanager.h"
-#include "configuration.h"
-#include "client.h"
-#include "dirs.h"
-#include "graphicsmanager.h"
-
-#include "being/actorsprite.h"
-
-#include "fs/files.h"
-
-#include "fs/virtfs/fs.h"
-
-#include "gui/userpalette.h"
-#include "gui/theme.h"
-
-#include "resources/sdlimagehelper.h"
-#ifdef USE_SDL2
-#include "resources/surfaceimagehelper.h"
-#endif // USE_SDL2
-
-#include "resources/resourcemanager/resourcemanager.h"
-
-#include "utils/env.h"
-#include "utils/delete2.h"
-
-#ifndef USE_SDL2
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_image.h>
-PRAGMA48(GCC diagnostic pop)
-#endif // USE_SDL2
-
-#include "debug.h"
-
-TEST_CASE("sdl tests", "sdl")
-{
- setEnv("SDL_VIDEODRIVER", "dummy");
-
- client = new Client;
- XML::initXML();
- SDL_Init(SDL_INIT_VIDEO);
- std::string name("data/test/test.zip");
- std::string prefix;
- if (Files::existsLocal(name) == false)
- prefix = "../" + prefix;
-
- VirtFs::mountDirSilent("data", Append_false);
- VirtFs::mountDirSilent("../data", Append_false);
-
- Dirs::initRootDir();
- Dirs::initHomeDir();
-
- setBrandingDefaults(branding);
- ConfigManager::initConfiguration();
-
-#ifdef USE_SDL2
- imageHelper = new SurfaceImageHelper;
-
- SDLImageHelper::setRenderer(graphicsManager.createRenderer(
- graphicsManager.createWindow(640, 480, 0,
- SDL_WINDOW_SHOWN | SDL_SWSURFACE), SDL_RENDERER_SOFTWARE));
-#else // USE_SDL2
-
- imageHelper = new SDLImageHelper();
-
- graphicsManager.createWindow(640, 480, 0, SDL_ANYFORMAT | SDL_SWSURFACE);
-#endif // USE_SDL2
-
- userPalette = new UserPalette;
- config.setValue("fontSize", 16);
-
- theme = new Theme;
- Theme::selectSkin();
-
- ActorSprite::load();
-
- SECTION("sdl SDL DuplicateSurface1")
- {
-#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
-
- SDL_Surface *const surface = SDL_CreateRGBSurface(SDL_HWSURFACE,
- 10, 10, 32, rmask, gmask, bmask, amask);
- uint32_t *ptr = reinterpret_cast<uint32_t*>(surface->pixels);
- for (int f = 0; f < 100; f ++)
- {
- ptr[f] = 300 * f;
- }
-#ifdef USE_SDL2
- SDL_Surface *surface2 = SurfaceImageHelper::SDLDuplicateSurface(
- surface);
-#else // USE_SDL2
-
- SDL_Surface *surface2 = SDLImageHelper::SDLDuplicateSurface(
- surface);
-#endif // USE_SDL2
-
- uint32_t *ptr2 = reinterpret_cast<uint32_t*>(surface2->pixels);
- for (int f = 0; f < 100; f ++)
- {
- REQUIRE(ptr[f] == ptr2[f]);
- }
-
- SDL_FreeSurface(surface);
- SDL_FreeSurface(surface2);
- }
-
- SECTION("sdl SDL DuplicateSurface2")
- {
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- const int rmask = 0x000000ff;
- const int gmask = 0x0000ff00;
- const int bmask = 0x00ff0000;
- const int amask = 0xff000000;
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- const int rmask = 0xff000000;
- const int gmask = 0x00ff0000;
- const int bmask = 0x0000ff00;
- const int amask = 0x000000ff;
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- SDL_Surface *const surface = SDL_CreateRGBSurface(SDL_HWSURFACE,
- 10, 10, 32, rmask, gmask, bmask, amask);
- uint32_t *ptr = reinterpret_cast<uint32_t*>(surface->pixels);
- for (int f = 0; f < 100; f ++)
- {
- ptr[f] = 300 * f;
- }
-#ifdef USE_SDL2
- SDL_Surface *surface2 = SurfaceImageHelper::SDLDuplicateSurface(
- surface);
-#else // USE_SDL2
-
- SDL_Surface *surface2 = SDLImageHelper::SDLDuplicateSurface(
- surface);
-#endif // USE_SDL2
-
- uint32_t *ptr2 = reinterpret_cast<uint32_t*>(surface2->pixels);
- for (int f = 0; f < 100; f ++)
- {
- REQUIRE(ptr[f] == ptr2[f]);
- }
-
- SDL_FreeSurface(surface);
- SDL_FreeSurface(surface2);
- }
-
- SECTION("sdl SDL_ConvertSurface1")
- {
-#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
-
- SDL_Surface *const surface = SDL_CreateRGBSurface(SDL_HWSURFACE,
- 4, 4, 32, rmask, gmask, bmask, amask);
- uint32_t *ptr = reinterpret_cast<uint32_t*>(surface->pixels);
- ptr[0] = 0x11223344;
- ptr[1] = 0x22334455;
- ptr[2] = 0x33445566;
- ptr[3] = 0x44556677;
- ptr[4] = 0x55667788;
- ptr[5] = 0x66778899;
- ptr[6] = 0x778899aa;
- ptr[7] = 0x8899aabb;
- ptr[8] = 0x99aabbcc;
- ptr[9] = 0xaabbccdd;
- ptr[10] = 0xbbccddee;
- ptr[11] = 0xccddeeff;
- ptr[12] = 0xff000000;
- ptr[13] = 0x00ff0000;
- ptr[14] = 0x0000ff00;
- ptr[15] = 0x000000ff;
-
- 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 surface2 = MSDL_ConvertSurface(
- surface, &rgba, SDL_SWSURFACE);
-
- uint32_t *ptr2 = reinterpret_cast<uint32_t*>(surface2->pixels);
- REQUIRE(ptr2[0] == 0x44332211);
- REQUIRE(ptr2[1] == 0x55443322);
- REQUIRE(ptr2[2] == 0x66554433);
- REQUIRE(ptr2[3] == 0x77665544);
- REQUIRE(ptr2[4] == 0x88776655);
- REQUIRE(ptr2[5] == 0x99887766);
- REQUIRE(ptr2[6] == 0xaa998877);
- REQUIRE(ptr2[7] == 0xbbaa9988);
- REQUIRE(ptr2[8] == 0xccbbaa99);
- REQUIRE(ptr2[9] == 0xddccbbaa);
- REQUIRE(ptr2[10] == 0xeeddccbb);
- REQUIRE(ptr2[11] == 0xffeeddcc);
- REQUIRE(ptr2[12] == 0x000000ff);
- REQUIRE(ptr2[13] == 0x0000ff00);
- REQUIRE(ptr2[14] == 0x00ff0000);
- REQUIRE(ptr2[15] == 0xff000000);
-
- SDL_FreeSurface(surface);
- SDL_FreeSurface(surface2);
- }
-
- SECTION("sdl SDL_ConvertSurface2")
- {
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- const int rmask = 0x000000ff;
- const int gmask = 0x0000ff00;
- const int bmask = 0x00ff0000;
- const int amask = 0xff000000;
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- const int rmask = 0xff000000;
- const int gmask = 0x00ff0000;
- const int bmask = 0x0000ff00;
- const int amask = 0x000000ff;
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- SDL_Surface *const surface = SDL_CreateRGBSurface(SDL_HWSURFACE,
- 4, 4, 32, rmask, gmask, bmask, amask);
- uint32_t *ptr = reinterpret_cast<uint32_t*>(surface->pixels);
- ptr[0] = 0x11223344;
- ptr[1] = 0x22334455;
- ptr[2] = 0x33445566;
- ptr[3] = 0x44556677;
- ptr[4] = 0x55667788;
- ptr[5] = 0x66778899;
- ptr[6] = 0x778899aa;
- ptr[7] = 0x8899aabb;
- ptr[8] = 0x99aabbcc;
- ptr[9] = 0xaabbccdd;
- ptr[10] = 0xbbccddee;
- ptr[11] = 0xccddeeff;
- ptr[12] = 0xff000000;
- ptr[13] = 0x00ff0000;
- ptr[14] = 0x0000ff00;
- ptr[15] = 0x000000ff;
-
- SDL_PixelFormat rgba;
- rgba.palette = nullptr;
- rgba.BitsPerPixel = 32;
- rgba.BytesPerPixel = 4;
-
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- rgba.Rmask = 0xFF000000;
- rgba.Gmask = 0x00FF0000;
- rgba.Bmask = 0x0000FF00;
- rgba.Amask = 0x000000FF;
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- rgba.Rmask = 0x000000FF;
- rgba.Gmask = 0x0000FF00;
- rgba.Bmask = 0x00FF0000;
- rgba.Amask = 0xFF000000;
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- SDL_Surface *const surface2 = MSDL_ConvertSurface(
- surface, &rgba, SDL_SWSURFACE);
-
- uint32_t *ptr2 = reinterpret_cast<uint32_t*>(surface2->pixels);
- REQUIRE(ptr2[0] == 0x44332211);
- REQUIRE(ptr2[1] == 0x55443322);
- REQUIRE(ptr2[2] == 0x66554433);
- REQUIRE(ptr2[3] == 0x77665544);
- REQUIRE(ptr2[4] == 0x88776655);
- REQUIRE(ptr2[5] == 0x99887766);
- REQUIRE(ptr2[6] == 0xaa998877);
- REQUIRE(ptr2[7] == 0xbbaa9988);
- REQUIRE(ptr2[8] == 0xccbbaa99);
- REQUIRE(ptr2[9] == 0xddccbbaa);
- REQUIRE(ptr2[10] == 0xeeddccbb);
- REQUIRE(ptr2[11] == 0xffeeddcc);
- REQUIRE(ptr2[12] == 0x000000ff);
- REQUIRE(ptr2[13] == 0x0000ff00);
- REQUIRE(ptr2[14] == 0x00ff0000);
- REQUIRE(ptr2[15] == 0xff000000);
-
- SDL_FreeSurface(surface);
- SDL_FreeSurface(surface2);
- }
-
- SECTION("sdl SDL_ConvertSurface3")
- {
- const int rmask = 0x000000ff;
- const int gmask = 0x0000ff00;
- const int bmask = 0x00ff0000;
- const int amask = 0xff000000;
-
- SDL_Surface *const surface = SDL_CreateRGBSurface(SDL_HWSURFACE,
- 4, 4, 32, rmask, gmask, bmask, amask);
- uint32_t *ptr = reinterpret_cast<uint32_t*>(surface->pixels);
- ptr[0] = 0x11223344;
- ptr[1] = 0x22334455;
- ptr[2] = 0x33445566;
- ptr[3] = 0x44556677;
- ptr[4] = 0x55667788;
- ptr[5] = 0x66778899;
- ptr[6] = 0x778899aa;
- ptr[7] = 0x8899aabb;
- ptr[8] = 0x99aabbcc;
- ptr[9] = 0xaabbccdd;
- ptr[10] = 0xbbccddee;
- ptr[11] = 0xccddeeff;
- ptr[12] = 0xff000000;
- ptr[13] = 0x00ff0000;
- ptr[14] = 0x0000ff00;
- ptr[15] = 0x000000ff;
-
- SDL_PixelFormat rgba;
- rgba.palette = nullptr;
- rgba.BitsPerPixel = 32;
- rgba.BytesPerPixel = 4;
- rgba.Rmask = 0x000000FF;
- rgba.Gmask = 0x0000FF00;
- rgba.Bmask = 0x00FF0000;
- rgba.Amask = 0xFF000000;
-
- SDL_Surface *const surface2 = MSDL_ConvertSurface(
- surface, &rgba, SDL_SWSURFACE);
-
- uint32_t *ptr2 = reinterpret_cast<uint32_t*>(surface2->pixels);
- REQUIRE(ptr2[0] == 0x11223344);
- REQUIRE(ptr2[1] == 0x22334455);
- REQUIRE(ptr2[2] == 0x33445566);
- REQUIRE(ptr2[3] == 0x44556677);
- REQUIRE(ptr2[4] == 0x55667788);
- REQUIRE(ptr2[5] == 0x66778899);
- REQUIRE(ptr2[6] == 0x778899aa);
- REQUIRE(ptr2[7] == 0x8899aabb);
- REQUIRE(ptr2[8] == 0x99aabbcc);
- REQUIRE(ptr2[9] == 0xaabbccdd);
- REQUIRE(ptr2[10] == 0xbbccddee);
- REQUIRE(ptr2[11] == 0xccddeeff);
- REQUIRE(ptr2[12] == 0xff000000);
- REQUIRE(ptr2[13] == 0x00ff0000);
- REQUIRE(ptr2[14] == 0x0000ff00);
- REQUIRE(ptr2[15] == 0x000000ff);
-
- SDL_FreeSurface(surface);
- SDL_FreeSurface(surface2);
- }
-
- ResourceManager::cleanOrphans(true);
- delete2(userPalette);
- delete2(theme);
- delete2(client);
-
- VirtFs::unmountDirSilent("data");
- VirtFs::unmountDirSilent("../data");
-}
diff --git a/src/unittests/unittests.h b/src/unittests/unittests.h
deleted file mode 100644
index 672b2ca54..000000000
--- a/src/unittests/unittests.h
+++ /dev/null
@@ -1,52 +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 UNITTESTS_H
-#define UNITTESTS_H
-
-#include "localconsts.h"
-
-#ifdef UNITTESTS_CATCH
-#include "unittests/catch.hpp"
-#endif // UNITTESTS_CATCH
-
-#ifdef UNITTESTS_DOCTEST
-
-#ifdef __GNUC__
-#if GCC_VERSION >= 50000
-#define PRAGMA5(str) _Pragma(#str)
-#elif defined(__clang__)
-#define PRAGMA5(str) _Pragma(#str)
-#else // GCC_VERSION > 50000
-#define PRAGMA5(str)
-#endif // GCC_VERSION > 50000
-#endif // __GNUC__
-
-PRAGMA5(GCC diagnostic push)
-PRAGMA5(GCC diagnostic ignored "-Wsuggest-override")
-#include "unittests/doctest.h"
-PRAGMA5(GCC diagnostic pop)
-
-#undef TEST_CASE
-#define TEST_CASE(name, tags) DOCTEST_TEST_CASE(name " " tags)
-#define SECTION(name) DOCTEST_SUBCASE(name)
-#endif // UNITTESTS_DOCTEST
-
-#endif // UNITTESTS_H
diff --git a/src/unittests/utils/chatutils.cc b/src/unittests/utils/chatutils.cc
deleted file mode 100644
index 82e8379be..000000000
--- a/src/unittests/utils/chatutils.cc
+++ /dev/null
@@ -1,265 +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 "unittests/unittests.h"
-
-#include "client.h"
-#include "configuration.h"
-#include "configmanager.h"
-#include "dirs.h"
-
-#include "actormanager.h"
-#include "graphicsmanager.h"
-#include "party.h"
-
-#include "being/localplayer.h"
-
-#include "fs/virtfs/fs.h"
-
-#include "gui/gui.h"
-#include "gui/theme.h"
-
-#include "utils/chatutils.h"
-#include "utils/delete2.h"
-#include "utils/env.h"
-
-#include "render/sdlgraphics.h"
-
-#include "resources/sdlimagehelper.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#ifndef USE_SDL2
-#include <SDL.h>
-#endif // USE_SDL2
-PRAGMA48(GCC diagnostic pop)
-
-#include "debug.h"
-
-TEST_CASE("chatutils replaceVars", "")
-{
- setEnv("SDL_VIDEODRIVER", "dummy");
-
- client = new Client;
- XML::initXML();
- SDL_Init(SDL_INIT_VIDEO);
- VirtFs::mountDirSilent("data", Append_false);
- VirtFs::mountDirSilent("../data", Append_false);
- imageHelper = new SDLImageHelper();
- mainGraphics = new SDLGraphics;
-
- Dirs::initRootDir();
- Dirs::initHomeDir();
-
- ConfigManager::initConfiguration();
- setConfigDefaults2(config);
- setBrandingDefaults(branding);
-
-#ifdef USE_SDL2
- SDLImageHelper::setRenderer(graphicsManager.createRenderer(
- graphicsManager.createWindow(640, 480, 0,
- SDL_WINDOW_SHOWN | SDL_SWSURFACE), SDL_RENDERER_SOFTWARE));
-#else // USE_SDL2
-
- graphicsManager.createWindow(640, 480, 0, SDL_ANYFORMAT | SDL_SWSURFACE);
-#endif // USE_SDL2
-
- theme = new Theme;
- Theme::selectSkin();
-
- gui = new Gui();
- gui->postInit(mainGraphics);
-
- ActorSprite::load();
- localPlayer = new LocalPlayer(static_cast<BeingId>(1),
- BeingTypeId_zero);
- actorManager = new ActorManager;
- std::string str;
-
- SECTION("empty")
- {
- replaceVars(str);
- REQUIRE(str.empty());
-
- str = "test line";
- replaceVars(str);
- REQUIRE(str == "test line");
-
- str = "test <PLAYER>";
- replaceVars(str);
- REQUIRE(str == "test ");
-
- str = "test <MONSTER>";
- replaceVars(str);
- REQUIRE(str == "test ");
-
- str = "test <PEOPLE>";
- replaceVars(str);
- REQUIRE(str == "test ");
-
- str = "test <PARTY>";
- replaceVars(str);
- REQUIRE(str == "test ");
-
- str = "test <SOMETHING>";
- replaceVars(str);
- REQUIRE(str == "test <SOMETHING>");
- }
-
- SECTION("player")
- {
- Being *player1 = Being::createBeing(static_cast<BeingId>(2),
- ActorType::Player,
- BeingTypeId_zero,
- nullptr);
- player1->setName("player1");
- actorManager->mActors.insert(player1);
-
- localPlayer->setTarget(player1);
- str = "test <PLAYER>";
- replaceVars(str);
- REQUIRE(str == "test player1");
- }
-
- SECTION("monster")
- {
- Being *const monster = Being::createBeing(static_cast<BeingId>(3),
- ActorType::Monster,
- BeingTypeId_zero,
- nullptr);
- monster->setName("monster1");
- actorManager->mActors.insert(monster);
-
- localPlayer->setTarget(monster);
- str = "test <MONSTER>";
- replaceVars(str);
- REQUIRE(str == "test monster1");
- }
-
- SECTION("people")
- {
- actorManager->mActors.insert(localPlayer);
- str = "test <PEOPLE>";
- replaceVars(str);
- REQUIRE(str == "test ");
-
- Being *const player1 = Being::createBeing(static_cast<BeingId>(2),
- ActorType::Player,
- BeingTypeId_zero,
- nullptr);
- player1->setName("player1");
- actorManager->mActors.insert(player1);
-
- str = "test <PEOPLE>";
- replaceVars(str);
- REQUIRE(str == "test player1");
-
- Being *const player2 = Being::createBeing(static_cast<BeingId>(4),
- ActorType::Player,
- BeingTypeId_zero,
- nullptr);
- player2->setName("player2");
- actorManager->mActors.insert(player2);
-
- str = "test <PEOPLE>";
- replaceVars(str);
- const bool correct = str == "test player1,player2" ||
- str == "test player2,player1";
- REQUIRE(correct == true);
- }
-
- SECTION("party")
- {
- actorManager->mActors.insert(localPlayer);
-
- Party *const party1 = Party::getParty(1);
- localPlayer->setParty(party1);
-
- str = "test <PARTY>";
- replaceVars(str);
- REQUIRE(str == "test ");
-
- Being *const player1 = Being::createBeing(static_cast<BeingId>(2),
- ActorType::Player,
- BeingTypeId_zero,
- nullptr);
- player1->setName("player1");
- actorManager->mActors.insert(player1);
- player1->setParty(party1);
-
- str = "test <PARTY>";
- replaceVars(str);
- REQUIRE(str == "test player1");
-
- Being *const player2 = Being::createBeing(static_cast<BeingId>(4),
- ActorType::Player,
- BeingTypeId_zero,
- nullptr);
- player2->setName("player2");
- actorManager->mActors.insert(player2);
- player2->setParty(party1);
-
- str = "test <PARTY>";
- replaceVars(str);
- REQUIRE(str == "test player1,player2");
-
- Party *const party2 = Party::getParty(2);
-
- Being *const player3 = Being::createBeing(static_cast<BeingId>(5),
- ActorType::Player,
- BeingTypeId_zero,
- nullptr);
- player3->setName("player3");
- actorManager->mActors.insert(player3);
- player3->setParty(party2);
-
- str = "test <PARTY>";
- replaceVars(str);
- REQUIRE(str == "test player1,player2");
-
- player3->setParty(party1);
-
- str = "test <PARTY>";
- replaceVars(str);
- REQUIRE(str == "test player1,player2,player3");
-
- player2->setParty(party2);
-
- str = "test <PARTY>";
- replaceVars(str);
- REQUIRE(str == "test player1,player3");
-
- Party::clearParties();
- }
-
- delete2(actorManager);
- delete2(localPlayer);
- delete2(client);
- VirtFs::unmountDirSilent("data");
- VirtFs::unmountDirSilent("../data");
-}
-
-TEST_CASE("chatutils textToMe", "")
-{
- REQUIRE(textToMe("") == "**");
- REQUIRE(textToMe("123") == "*123*");
- REQUIRE(textToMe("*") == "***");
- REQUIRE(textToMe("test line") == "*test line*");
-}
diff --git a/src/unittests/utils/checkutils.cc b/src/unittests/utils/checkutils.cc
deleted file mode 100644
index 5cfec4e83..000000000
--- a/src/unittests/utils/checkutils.cc
+++ /dev/null
@@ -1,174 +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 "unittests/unittests.h"
-
-#include "utils/checkutils.h"
-
-#include "debug.h"
-
-namespace
-{
- bool flag = false;
-} // namespace
-
-static void testReturnFalseV(const bool val)
-{
- flag = false;
- returnFalseVReal(val);
- flag = true;
-}
-
-static void testReturnTrueV(const bool val)
-{
- flag = false;
- returnTrueVReal(val);
- flag = true;
-}
-
-static int testReturnFalse(const bool val)
-{
- returnFalseReal(0, val);
- return 1;
-}
-
-static int testReturnTrue(const bool val)
-{
- returnTrueReal(0, val);
- return 1;
-}
-
-static int testReturnNullptr(void *val)
-{
- returnNullptrReal(0, val);
- return 1;
-}
-
-static void testReturnNullptrV(void *val)
-{
- flag = false;
- returnNullptrVReal(val);
- flag = true;
-}
-
-static bool testFailAlways1()
-{
- failAlways("test fail");
- return false;
-}
-
-static bool testFailAlways2()
-{
- reportAlways("test fail");
- return false;
-}
-
-TEST_CASE("CheckUtils", "")
-{
- SECTION("reportFalse")
- {
- REQUIRE(reportFalseReal(false) == false);
- REQUIRE(reportFalseReal(true) == true);
- }
-
- SECTION("reportTrue")
- {
- REQUIRE(reportTrueReal(false) == false);
- REQUIRE(reportTrueReal(true) == true);
- }
-
- SECTION("reportAlways")
- {
- reportAlwaysReal("test report");
- }
-
- SECTION("failFalse")
- {
-PRAGMA4(GCC diagnostic push)
-PRAGMA4(GCC diagnostic ignored "-Wunused-value")
- REQUIRE_THROWS(failFalse(false));
- REQUIRE(failFalse(true) == true);
- REQUIRE_THROWS(reportFalse(false));
- REQUIRE(reportFalse(true) == true);
-PRAGMA4(GCC diagnostic pop)
- }
-
- SECTION("failTrue")
- {
-PRAGMA4(GCC diagnostic push)
-PRAGMA4(GCC diagnostic ignored "-Wunused-value")
- REQUIRE(failTrue(false) == false);
- REQUIRE_THROWS(failTrue(true));
- REQUIRE(reportTrue(false) == false);
- REQUIRE_THROWS(reportTrue(true));
-PRAGMA4(GCC diagnostic pop)
- }
-
- SECTION("failAlways")
- {
-PRAGMA4(GCC diagnostic push)
-PRAGMA4(GCC diagnostic ignored "-Wunused-value")
- REQUIRE_THROWS(testFailAlways1());
- REQUIRE_THROWS(testFailAlways2());
-PRAGMA4(GCC diagnostic pop)
- }
-
- SECTION("returnFalseV")
- {
- testReturnFalseV(false);
- REQUIRE(flag == false);
- testReturnFalseV(true);
- REQUIRE(flag == true);
- }
-
- SECTION("returnTrueV")
- {
- testReturnTrueV(false);
- REQUIRE(flag == true);
- testReturnTrueV(true);
- REQUIRE(flag == false);
- }
-
- SECTION("returnFalse")
- {
- REQUIRE(testReturnFalse(false) == 0);
- REQUIRE(testReturnFalse(true) == 1);
- }
-
- SECTION("returnTrue")
- {
- REQUIRE(testReturnTrue(false) == 1);
- REQUIRE(testReturnTrue(true) == 0);
- }
-
- SECTION("returnNullptr")
- {
- REQUIRE(testReturnNullptr(nullptr) == 0);
- REQUIRE(testReturnNullptr(reinterpret_cast<void*>(1)) == 1);
- }
-
- SECTION("returnNullptrV")
- {
- testReturnNullptrV(nullptr);
- REQUIRE(flag == false);
- testReturnNullptrV(reinterpret_cast<void*>(1));
- REQUIRE(flag == true);
- }
-}
diff --git a/src/unittests/utils/dumplibs.cc b/src/unittests/utils/dumplibs.cc
deleted file mode 100644
index e5797d45f..000000000
--- a/src/unittests/utils/dumplibs.cc
+++ /dev/null
@@ -1,138 +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 "unittests/unittests.h"
-
-#include "utils/stringutils.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_image.h>
-#include <SDL_mixer.h>
-PRAGMACLANG6GCC(GCC diagnostic push)
-PRAGMACLANG6GCC(GCC diagnostic ignored "-Wold-style-cast")
-#include <SDL_net.h>
-PRAGMACLANG6GCC(GCC diagnostic pop)
-#include <SDL_ttf.h>
-PRAGMA48(GCC diagnostic pop)
-
-#include <zlib.h>
-
-#include "debug.h"
-
-TEST_CASE("dumplibs tests", "")
-{
- SECTION("zlib")
- {
- const std::string build = ZLIB_VERSION;
- const std::string link = zlibVersion();
- REQUIRE(build == link);
- }
-
- SECTION("sdl")
- {
- const SDL_version *linkVersion = nullptr;
-#ifdef USE_SDL2
- SDL_version sdlVersion;
- sdlVersion.major = 0;
- sdlVersion.minor = 0;
- sdlVersion.patch = 0;
- SDL_GetVersion(&sdlVersion);
- linkVersion = &sdlVersion;
-#else // USE_SDL2
- linkVersion = SDL_Linked_Version();
-#endif // USE_SDL2
-
- const std::string build = strprintf("%d.%d.%d",
- SDL_MAJOR_VERSION,
- SDL_MINOR_VERSION,
- SDL_PATCHLEVEL);
- const std::string link = strprintf("%d.%d.%d",
- linkVersion->major,
- linkVersion->minor,
- linkVersion->patch);
-
- REQUIRE(build == link);
- }
-
- SECTION("sdl_net")
- {
- const SDL_version *const linkVersion = SDLNet_Linked_Version();
-
- const std::string build = strprintf("%d.%d.%d",
- SDL_NET_MAJOR_VERSION,
- SDL_NET_MINOR_VERSION,
- SDL_NET_PATCHLEVEL);
- const std::string link = strprintf("%d.%d.%d",
- linkVersion->major,
- linkVersion->minor,
- linkVersion->patch);
-
- REQUIRE(build == link);
- }
-
- SECTION("sdl_image")
- {
- const SDL_version *const linkVersion = IMG_Linked_Version();
-
- const std::string build = strprintf("%d.%d.%d",
- SDL_IMAGE_MAJOR_VERSION,
- SDL_IMAGE_MINOR_VERSION,
- SDL_IMAGE_PATCHLEVEL);
- const std::string link = strprintf("%d.%d.%d",
- linkVersion->major,
- linkVersion->minor,
- linkVersion->patch);
-
- REQUIRE(build == link);
- }
-
- SECTION("sdl_mixer")
- {
- const SDL_version *const linkVersion = Mix_Linked_Version();
-
- const std::string build = strprintf("%d.%d.%d",
- SDL_MIXER_MAJOR_VERSION,
- SDL_MIXER_MINOR_VERSION,
- SDL_MIXER_PATCHLEVEL);
- const std::string link = strprintf("%d.%d.%d",
- linkVersion->major,
- linkVersion->minor,
- linkVersion->patch);
-
- REQUIRE(build == link);
- }
-
- SECTION("sdl_ttf")
- {
- const SDL_version *const linkVersion = TTF_Linked_Version();
-
- const std::string build = strprintf("%d.%d.%d",
- SDL_TTF_MAJOR_VERSION,
- SDL_TTF_MINOR_VERSION,
- SDL_TTF_PATCHLEVEL);
- const std::string link = strprintf("%d.%d.%d",
- linkVersion->major,
- linkVersion->minor,
- linkVersion->patch);
-
- REQUIRE(build == link);
- }
-}
diff --git a/src/unittests/utils/langs.cc b/src/unittests/utils/langs.cc
deleted file mode 100644
index d9ff6eded..000000000
--- a/src/unittests/utils/langs.cc
+++ /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 "unittests/unittests.h"
-
-#include "configuration.h"
-
-#include "utils/env.h"
-#include "utils/langs.h"
-
-#include "debug.h"
-
-TEST_CASE("Langs getLang", "")
-{
- LangVect langs;
-
- config.setValue("lang", "C");
- langs = getLang();
- REQUIRE(langs.size() == 1);
- REQUIRE(langs[0] == "C");
-
- config.setValue("lang", "ru_RU");
- langs = getLang();
- REQUIRE(langs.size() == 2);
- REQUIRE(langs[0] == "ru_RU");
- REQUIRE(langs[1] == "ru");
-
- config.setValue("lang", "ru_RU.UTF-8");
- langs = getLang();
- REQUIRE(langs.size() == 2);
- REQUIRE(langs[0] == "ru_RU");
- REQUIRE(langs[1] == "ru");
-
- config.setValue("lang", "");
-
- setEnv("LANG", "C");
- langs = getLang();
- REQUIRE(langs.size() == 1);
- REQUIRE(langs[0] == "C");
-
- setEnv("LANG", "ru_RU");
- langs = getLang();
- REQUIRE(langs.size() == 2);
- REQUIRE(langs[0] == "ru_RU");
- REQUIRE(langs[1] == "ru");
-
- setEnv("LANG", "ru_RU.UTF-8");
- langs = getLang();
- REQUIRE(langs.size() == 2);
- REQUIRE(langs[0] == "ru_RU");
- REQUIRE(langs[1] == "ru");
-}
-
-TEST_CASE("Langs getLangSimple", "")
-{
- config.setValue("lang", "C");
- REQUIRE(getLangSimple() == "C");
-
- config.setValue("lang", "ru_RU");
- REQUIRE(getLangSimple() == "ru_RU");
-
- config.setValue("lang", "ru_RU.UTF-8");
- REQUIRE(getLangSimple() == "ru_RU.UTF-8");
-
- config.setValue("lang", "");
-
- setEnv("LANG", "C");
- REQUIRE(getLangSimple() == "C");
-
- setEnv("LANG", "ru_RU");
- REQUIRE(getLangSimple() == "ru_RU");
-
- setEnv("LANG", "ru_RU.UTF-8");
- REQUIRE(getLangSimple() == "ru_RU.UTF-8");
-}
-
-TEST_CASE("Langs getLangShort", "")
-{
- config.setValue("lang", "C");
- REQUIRE(getLangShort() == "C");
-
- config.setValue("lang", "ru_RU");
- REQUIRE(getLangShort() == "ru");
-
- config.setValue("lang", "ru_RU.UTF-8");
- REQUIRE(getLangShort() == "ru");
-
- config.setValue("lang", "");
-
- setEnv("LANG", "C");
- REQUIRE(getLangShort() == "C");
-
- setEnv("LANG", "ru_RU");
- REQUIRE(getLangShort() == "ru");
-
- setEnv("LANG", "ru_RU.UTF-8");
- REQUIRE(getLangShort() == "ru");
-}
diff --git a/src/unittests/utils/mathutils.cc b/src/unittests/utils/mathutils.cc
deleted file mode 100644
index 3eb0214ef..000000000
--- a/src/unittests/utils/mathutils.cc
+++ /dev/null
@@ -1,102 +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 "unittests/unittests.h"
-
-#include "utils/mathutils.h"
-
-#include "debug.h"
-
-TEST_CASE("MathUtils powerOfTwo", "")
-{
- REQUIRE(powerOfTwo(0) == 1);
- REQUIRE(powerOfTwo(1) == 1);
- REQUIRE(powerOfTwo(2) == 2);
- REQUIRE(powerOfTwo(3) == 4);
- REQUIRE(powerOfTwo(4) == 4);
- REQUIRE(powerOfTwo(5) == 8);
- REQUIRE(powerOfTwo(6) == 8);
- REQUIRE(powerOfTwo(7) == 8);
- REQUIRE(powerOfTwo(8) == 8);
- REQUIRE(powerOfTwo(9) == 16);
- REQUIRE(powerOfTwo(10) == 16);
- REQUIRE(powerOfTwo(11) == 16);
- REQUIRE(powerOfTwo(12) == 16);
- REQUIRE(powerOfTwo(13) == 16);
- REQUIRE(powerOfTwo(14) == 16);
- REQUIRE(powerOfTwo(15) == 16);
- REQUIRE(powerOfTwo(16) == 16);
- REQUIRE(powerOfTwo(17) == 32);
- REQUIRE(powerOfTwo(18) == 32);
- REQUIRE(powerOfTwo(19) == 32);
- REQUIRE(powerOfTwo(20) == 32);
- REQUIRE(powerOfTwo(21) == 32);
- REQUIRE(powerOfTwo(22) == 32);
- REQUIRE(powerOfTwo(23) == 32);
- REQUIRE(powerOfTwo(24) == 32);
- REQUIRE(powerOfTwo(25) == 32);
- REQUIRE(powerOfTwo(26) == 32);
- REQUIRE(powerOfTwo(27) == 32);
- REQUIRE(powerOfTwo(28) == 32);
- REQUIRE(powerOfTwo(29) == 32);
- REQUIRE(powerOfTwo(30) == 32);
- REQUIRE(powerOfTwo(31) == 32);
- REQUIRE(powerOfTwo(32) == 32);
- REQUIRE(powerOfTwo(33) == 64);
- REQUIRE(powerOfTwo(34) == 64);
- REQUIRE(powerOfTwo(35) == 64);
- REQUIRE(powerOfTwo(36) == 64);
- REQUIRE(powerOfTwo(37) == 64);
- REQUIRE(powerOfTwo(38) == 64);
- REQUIRE(powerOfTwo(39) == 64);
- REQUIRE(powerOfTwo(41) == 64);
- REQUIRE(powerOfTwo(42) == 64);
- REQUIRE(powerOfTwo(43) == 64);
- REQUIRE(powerOfTwo(44) == 64);
- REQUIRE(powerOfTwo(45) == 64);
- REQUIRE(powerOfTwo(46) == 64);
- REQUIRE(powerOfTwo(47) == 64);
- REQUIRE(powerOfTwo(48) == 64);
- REQUIRE(powerOfTwo(49) == 64);
- REQUIRE(powerOfTwo(50) == 64);
- REQUIRE(powerOfTwo(51) == 64);
- REQUIRE(powerOfTwo(52) == 64);
- REQUIRE(powerOfTwo(53) == 64);
- REQUIRE(powerOfTwo(54) == 64);
- REQUIRE(powerOfTwo(55) == 64);
- REQUIRE(powerOfTwo(56) == 64);
- REQUIRE(powerOfTwo(57) == 64);
- REQUIRE(powerOfTwo(58) == 64);
- REQUIRE(powerOfTwo(59) == 64);
- REQUIRE(powerOfTwo(60) == 64);
- REQUIRE(powerOfTwo(61) == 64);
- REQUIRE(powerOfTwo(62) == 64);
- REQUIRE(powerOfTwo(63) == 64);
- REQUIRE(powerOfTwo(64) == 64);
- REQUIRE(powerOfTwo(65) == 128);
-
- REQUIRE(powerOfTwo(1000000) == 1048576);
-}
-
-TEST_CASE("MathUtils tests fastSqrtInt", "")
-{
- for (int f = 0; f < 1005; f ++)
- REQUIRE(fastSqrtInt(f) == CAST_S32(sqrt(f)));
-}
diff --git a/src/unittests/utils/parameters.cc b/src/unittests/utils/parameters.cc
deleted file mode 100644
index 90d872d5a..000000000
--- a/src/unittests/utils/parameters.cc
+++ /dev/null
@@ -1,327 +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 "unittests/unittests.h"
-
-#include "utils/parameters.h"
-
-#include "debug.h"
-
-TEST_CASE("parameters basic 1", "")
-{
- StringVect pars;
- REQUIRE(splitParameters(pars, "", ",", '\"') == true);
- REQUIRE(pars.empty());
-}
-
-TEST_CASE("parameters basic 2", "")
-{
- StringVect pars;
- REQUIRE(splitParameters(pars, "one,two, tree", ",", '\"') == true);
- REQUIRE(pars.size() == 3);
- REQUIRE(pars[0] == "one");
- REQUIRE(pars[1] == "two");
- REQUIRE(pars[2] == "tree");
-}
-
-TEST_CASE("parameters basic 3", "")
-{
- StringVect pars;
- REQUIRE(splitParameters(pars, ", ,,,", ",", '\"') == true);
- REQUIRE(pars.empty());
-}
-
-TEST_CASE("parameters basic 4", "")
-{
- StringVect pars;
- REQUIRE(splitParameters(pars, "one,,two, tree", ",", '\"') == true);
- REQUIRE(pars.size() == 3);
- REQUIRE(pars[0] == "one");
- REQUIRE(pars[1] == "two");
- REQUIRE(pars[2] == "tree");
-}
-
-TEST_CASE("parameters escape 1", "")
-{
- StringVect pars;
- REQUIRE(splitParameters(pars, "\\\"", ",", '\"') == true);
- REQUIRE(pars.size() == 1);
- REQUIRE(pars[0] == "\"");
-}
-
-TEST_CASE("parameters escape 2", "")
-{
- StringVect pars;
- REQUIRE(splitParameters(pars, "\\\", test", ",", '\"') == true);
- REQUIRE(pars.size() == 2);
- REQUIRE(pars[0] == "\"");
- REQUIRE(pars[1] == "test");
-}
-
-TEST_CASE("parameters escape 3", "")
-{
- StringVect pars;
- REQUIRE(splitParameters(pars, "test,\\\"", ",", '\"') == true);
- REQUIRE(pars.size() == 2);
- REQUIRE(pars[0] == "test");
- REQUIRE(pars[1] == "\"");
-}
-
-TEST_CASE("parameters quote 1", "")
-{
- StringVect pars;
- REQUIRE(splitParameters(pars, "\"one\",,two, tree", ",", '\"') == true);
- REQUIRE(pars.size() == 3);
- REQUIRE(pars[0] == "one");
- REQUIRE(pars[1] == "two");
- REQUIRE(pars[2] == "tree");
-}
-
-TEST_CASE("parameters quote 2", "")
-{
- StringVect pars;
- REQUIRE(splitParameters(pars, "\"\",,two, tree", ",", '\"') == true);
- REQUIRE(pars.size() == 3);
- REQUIRE(pars[0].empty());
- REQUIRE(pars[1] == "two");
- REQUIRE(pars[2] == "tree");
-}
-
-TEST_CASE("parameters quote 3", "")
-{
- StringVect pars;
- REQUIRE(splitParameters(pars, "\"one test\",,two, tree", ",", '\"') ==
- true);
- REQUIRE(pars.size() == 3);
- REQUIRE(pars[0] == "one test");
- REQUIRE(pars[1] == "two");
- REQUIRE(pars[2] == "tree");
-}
-
-TEST_CASE("parameters quote 4", "")
-{
- StringVect pars;
- REQUIRE(splitParameters(pars, "\"\\\"one test\\\"\",,two, tree", ",", '\"')
- == true);
- REQUIRE(pars.size() == 3);
- REQUIRE(pars[0] == "\"one test\"");
- REQUIRE(pars[1] == "two");
- REQUIRE(pars[2] == "tree");
-}
-
-TEST_CASE("parameters quote 5", "")
-{
- StringVect pars;
- REQUIRE(splitParameters(pars, "\"\\\"one \\\"test\\\"\",,two, tree",
- ",", '\"') == true);
- REQUIRE(pars.size() == 3);
- REQUIRE(pars[0] == "\"one \"test\"");
- REQUIRE(pars[1] == "two");
- REQUIRE(pars[2] == "tree");
-}
-
-TEST_CASE("parameters quote 6", "")
-{
- StringVect pars;
- REQUIRE(splitParameters(pars, "\"one, test\",,two, tree", ",", '\"')
- == true);
- REQUIRE(pars.size() == 3);
- REQUIRE(pars[0] == "one, test");
- REQUIRE(pars[1] == "two");
- REQUIRE(pars[2] == "tree");
-}
-
-TEST_CASE("parameters quote 7", "")
-{
- StringVect pars;
- REQUIRE(splitParameters(pars, "\"\\\"one, test\\\"\",,two, tree",
- ",", '\"') == true);
- REQUIRE(pars.size() == 3);
- REQUIRE(pars[0] == "\"one, test\"");
- REQUIRE(pars[1] == "two");
- REQUIRE(pars[2] == "tree");
-}
-
-TEST_CASE("parameters quote 8", "")
-{
- StringVect pars;
- REQUIRE(splitParameters(pars, "\"\\\"\",,two, tree", ",", '\"')
- == true);
- REQUIRE(pars.size() == 3);
- REQUIRE(pars[0] == "\"");
- REQUIRE(pars[1] == "two");
- REQUIRE(pars[2] == "tree");
-}
-
-TEST_CASE("parameters quote 9", "")
-{
- StringVect pars;
- REQUIRE(splitParameters(pars, "\"\\\",,two, tree", ",", '\"')
- == true);
- REQUIRE(pars.size() == 1);
- REQUIRE(pars[0] == "\"\",,two, tree");
-}
-
-TEST_CASE("parameters quote 10", "")
-{
- StringVect pars;
- REQUIRE(splitParameters(pars, "\"", ",", '\"')
- == true);
- REQUIRE(pars.size() == 1);
- REQUIRE(pars[0] == "\"");
-}
-
-TEST_CASE("parameters quote 11", "")
-{
- StringVect pars;
- REQUIRE(splitParameters(pars, "\\\"", ",", '\"')
- == true);
- REQUIRE(pars.size() == 1);
- REQUIRE(pars[0] == "\"");
-}
-
-TEST_CASE("parameters quote 12", "")
-{
- StringVect pars;
- REQUIRE(splitParameters(pars, ",\"", ",", '\"')
- == true);
- REQUIRE(pars.size() == 1);
- REQUIRE(pars[0] == "\"");
-}
-
-TEST_CASE("parameters quote 13", "")
-{
- StringVect pars;
- REQUIRE(splitParameters(pars, "\",", ",", '\"')
- == true);
- REQUIRE(pars.size() == 1);
- REQUIRE(pars[0] == "\",");
-}
-
-TEST_CASE("parameters quote 14", "")
-{
- StringVect pars;
- REQUIRE(splitParameters(pars, "\\\",", ",", '\"')
- == true);
- REQUIRE(pars.size() == 1);
- REQUIRE(pars[0] == "\"");
-}
-
-TEST_CASE("parameters quote 15", "")
-{
- StringVect pars;
- REQUIRE(splitParameters(pars, ",\\\"", ",", '\"')
- == true);
- REQUIRE(pars.size() == 1);
- REQUIRE(pars[0] == "\"");
-}
-
-TEST_CASE("parameters quote 16", "")
-{
- StringVect pars;
- REQUIRE(splitParameters(pars, "\"one test\"", ",", '\"') ==
- true);
- REQUIRE(pars.size() == 1);
- REQUIRE(pars[0] == "one test");
-}
-
-TEST_CASE("parameters quote 17", "")
-{
- StringVect pars;
- REQUIRE(splitParameters(pars, "\"one, test\"", ",", '\"') ==
- true);
- REQUIRE(pars.size() == 1);
- REQUIRE(pars[0] == "one, test");
-}
-
-TEST_CASE("parameters quote 18", "")
-{
- StringVect pars;
- REQUIRE(splitParameters(pars, "\"one\\\" test\"", ",", '\"') ==
- true);
- REQUIRE(pars.size() == 1);
- REQUIRE(pars[0] == "one\" test");
-}
-
-TEST_CASE("parameters quote 19", "")
-{
- StringVect pars;
- REQUIRE(splitParameters(pars, "\"one\\\" ,test\"", ",", '\"') ==
- true);
- REQUIRE(pars.size() == 1);
- REQUIRE(pars[0] == "one\" ,test");
-}
-
-TEST_CASE("parameters quote 20", "")
-{
- StringVect pars;
- REQUIRE(splitParameters(pars, "\"one\\\" test,\"", ",", '\"') ==
- true);
- REQUIRE(pars.size() == 1);
- REQUIRE(pars[0] == "one\" test,");
-}
-
-TEST_CASE("parameters complex 1", "")
-{
- StringVect pars;
- REQUIRE(splitParameters(pars, "\"test\" \"line\"", ",", '\"') == true);
- REQUIRE(pars.size() == 1);
- REQUIRE(pars[0] == "test\" \"line");
-}
-
-TEST_CASE("parameters complex 2", "")
-{
- StringVect pars;
- REQUIRE(splitParameters(pars, "\"test\", \"line\"", ",", '\"') == true);
- REQUIRE(pars.size() == 2);
- REQUIRE(pars[0] == "test");
- REQUIRE(pars[1] == "line");
-}
-
-TEST_CASE("parameters complex 3", "")
-{
- StringVect pars;
- REQUIRE(splitParameters(pars, "\"test,\" \"line\"", ",", '\"') == true);
- REQUIRE(pars.size() == 1);
- REQUIRE(pars[0] == "test,\" \"line");
-}
-
-TEST_CASE("parameters broken 1", "")
-{
- StringVect pars;
- REQUIRE(splitParameters(pars, "\"", ",", '\"') == true);
- REQUIRE(pars.size() == 1);
- REQUIRE(pars[0] == "\"");
-}
-
-TEST_CASE("parameters broken 2", "")
-{
- StringVect pars;
- REQUIRE(splitParameters(pars, ",", ",", '\"') == true);
- REQUIRE(pars.empty());
-}
-
-TEST_CASE("parameters broken 3", "")
-{
- StringVect pars;
- REQUIRE(splitParameters(pars,
- ",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,", ",", '\"') == true);
- REQUIRE(pars.empty());
-}
diff --git a/src/unittests/utils/stringutils.cc b/src/unittests/utils/stringutils.cc
deleted file mode 100644
index e69ebecba..000000000
--- a/src/unittests/utils/stringutils.cc
+++ /dev/null
@@ -1,1715 +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 "unittests/unittests.h"
-
-#include "configuration.h"
-
-#include "const/utils/utf8.h"
-
-#include "fs/virtfs/fs.h"
-
-#include "utils/dtor.h"
-
-#include "resources/iteminfo.h"
-
-#include "resources/db/itemdb.h"
-
-#include "resources/resourcemanager/resourcemanager.h"
-
-#include "debug.h"
-
-TEST_CASE("stringuntils trim 1", "")
-{
- std::string str = "str";
- REQUIRE("str" == trim(str));
-
- str = " str";
- REQUIRE("str" == trim(str));
- REQUIRE("str" == trim(str));
-
- str = " str this IS Long Стринг "
- "~!@#$%^&*()_+`-=[]\\{}|;':\",./<>? ";
- REQUIRE("str this IS Long Стринг ~!@#$%^&*()_+`-=[]\\{}|;':\",./<>?" ==
- trim(str));
-
- str = "";
- REQUIRE(trim(str).empty());
-}
-
-TEST_CASE("stringuntils toLower 1", "")
-{
- std::string str = "str";
- REQUIRE("str" == toLower(str));
-
- str = " StR";
- REQUIRE(" str" == toLower(str));
-
- str = " str this IS Long "
- "~!@#$%^&*()_+`-=[]\\{}|;':\",./<>? ";
-
- REQUIRE(" str this is long ~!@#$%^&*()_+`-=[]\\{}|;':\",./<>? " ==
- toLower(str));
-
- str = "";
- REQUIRE(toLower(str).empty());
-}
-
-TEST_CASE("stringuntils toUpper 1", "")
-{
- std::string str = "str";
- REQUIRE("STR" == toUpper(str));
-
- str = " StR";
- REQUIRE(" STR" == toUpper(str));
-
- str = " str this IS Long "
- "~!@#$%^&*()_+`-=[]\\{}|;':,./<>? ";
-
- REQUIRE(" STR THIS IS LONG ~!@#$%^&*()_+`-=[]\\{}|;':,./<>? " ==
- toUpper(str));
-
- str = "";
- REQUIRE(toUpper(str).empty());
-}
-
-TEST_CASE("stringuntils atox 1", "")
-{
- std::string str = "0x10";
- REQUIRE(16 == atox(str));
-
- str = "0x0";
- REQUIRE(0 == atox(str));
-
- str = "0x1";
- REQUIRE(1 == atox(str));
-
- str = "0x0x0x0x0x0x0x0";
- REQUIRE(0 == atox(str));
-
- str = "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
- const int k = atox(str);
- printf("%d\n", k); // for avoid warning
-
- str = "";
- REQUIRE(0 == atox(str));
-
- str = "0";
- REQUIRE(0 == atox(str));
-
- str = "0x";
- REQUIRE(0 == atox(str));
-
- str = "zzz";
- REQUIRE(0 == atox(str));
-}
-
-TEST_CASE("stringuntils ipToString 1", "")
-{
- REQUIRE("0.0.0.0" == std::string(ipToString(0)));
- REQUIRE("219.255.210.73" == std::string(ipToString(1238564827)));
-}
-
-TEST_CASE("stringuntils toString 1", "")
-{
- REQUIRE(strprintf("%d", 0) == toString(0));
- REQUIRE(strprintf("%d", -1) == toString(-1));
- REQUIRE(strprintf("%d", 30000000) == toString(30000000));
- REQUIRE(strprintf("%d", -10000000) == toString(-10000000));
- REQUIRE(strprintf("%d", 30000000) == toString(
- static_cast<signed int>(30000000)));
- REQUIRE(strprintf("%d", 3000) == toString(CAST_U16(3000)));
- REQUIRE(strprintf("%d", 123) == toString(CAST_U8(123)));
- REQUIRE(strprintf("%u", static_cast<uint32_t>(30000000)) == toString(
- static_cast<uint32_t>(30000000)));
- REQUIRE(strprintf("%f", 3.1f) == toString(3.1f));
- REQUIRE(strprintf("%f", 3.1) == toString(3.1));
-}
-
-TEST_CASE("stringuntils toStringPrint 1", "")
-{
- REQUIRE(toStringPrint(0) == "0 0x0");
- REQUIRE(toStringPrint(10) == "10 0xa");
- REQUIRE(toStringPrint(255) == "255 0xff");
-}
-
-TEST_CASE("stringuntils parse2Int 1", "")
-{
- int a = -1;
- int b = -1;
-
- REQUIRE(parse2Int("", a, b) == false);
- REQUIRE(a == -1);
- REQUIRE(b == -1);
-
- a = -1;
- b = -1;
- REQUIRE(parse2Int(",", a, b) == false);
- REQUIRE(a == -1);
- REQUIRE(b == -1);
-
- a = -1;
- b = -1;
- REQUIRE(parse2Int("10,20", a, b) == true);
- REQUIRE(a == 10);
- REQUIRE(b == 20);
-
- a = -1;
- b = -1;
- REQUIRE(parse2Int("10 20", a, b) == true);
- REQUIRE(a == 10);
- REQUIRE(b == 20);
-
- a = -1;
- b = -1;
- REQUIRE(parse2Int("10 z20", a, b) == true);
- REQUIRE(a == 10);
- REQUIRE(b == 0);
-}
-
-TEST_CASE("stringuntils parse2Str 1", "")
-{
- std::string str1 = "-";
- std::string str2 = "-";
-
- REQUIRE(parse2Str("", str1, str2) == false);
- REQUIRE(str1 == "-");
- REQUIRE(str2 == "-");
-
- REQUIRE(parse2Str(",", str1, str2) == false);
- REQUIRE(str1 == "-");
- REQUIRE(str2 == "-");
-
- str1 = "-";
- str2 = "-";
- REQUIRE(parse2Str("test line", str1, str2) == true);
- REQUIRE(str1 == "test");
- REQUIRE(str2 == "line");
-
- str1 = "-";
- str2 = "-";
- REQUIRE(parse2Str("test,line", str1, str2) == true);
- REQUIRE(str1 == "test");
- REQUIRE(str2 == "line");
-}
-
-TEST_CASE("stringuntils parseNumber 1", "")
-{
- REQUIRE(parseNumber("") == 0);
- REQUIRE(parseNumber("0x") == 0);
- REQUIRE(parseNumber("10") == 10);
- REQUIRE(parseNumber("h10") == 16);
- REQUIRE(parseNumber("x100") == 256);
- REQUIRE(parseNumber("0x20") == 32);
-}
-
-TEST_CASE("stringuntils removeToken 1", "")
-{
- std::string str;
-
- REQUIRE(removeToken(str, " ").empty());
- REQUIRE(str.empty());
-
- str = "test";
- REQUIRE(removeToken(str, " ").empty());
- REQUIRE(str.empty());
-
- str = "test line";
- REQUIRE(removeToken(str, " ") == "line");
- REQUIRE(str == "line");
-
- str = "test,line";
- REQUIRE(removeToken(str, ",") == "line");
- REQUIRE(str == "line");
-
- str = "test line";
- REQUIRE(removeToken(str, ",").empty());
- REQUIRE(str.empty());
-
- str = ",line";
- REQUIRE(removeToken(str, ",").empty());
- REQUIRE(str.empty());
-}
-
-TEST_CASE("stringuntils strprintf 1", "")
-{
- REQUIRE(strprintf("%s very long string. 123456789012345678901234567890"
- "+++++++++++++++++++++++++++++++++++++++"
- "________________________________"
- "***********************************"
- "----------------------------------------"
- "|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| %s",
- "test", "end of test") ==
- "test very long string. 123456789012345678901234567890"
- "+++++++++++++++++++++++++++++++++++++++"
- "________________________________"
- "***********************************"
- "----------------------------------------"
- "|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| "
- "end of test");
-}
-
-TEST_CASE("stringuntils toString 2", "")
-{
- for (int f = 0; f < 10000000; f += 123)
- {
- REQUIRE(strprintf("%d", f) == toString(f));
- }
-}
-
-TEST_CASE("stringuntils removeColors 1", "")
-{
- REQUIRE(removeColors("").empty());
- REQUIRE("#" == removeColors("#"));
- REQUIRE("##" == removeColors("##"));
- REQUIRE(removeColors("##1").empty());
- REQUIRE("2" == removeColors("##12"));
- REQUIRE("1##" == removeColors("1##"));
- REQUIRE("1" == removeColors("1##2"));
- REQUIRE("13" == removeColors("1##23"));
- REQUIRE("#1#2" == removeColors("#1#2"));
- REQUIRE("#1" == removeColors("#1##2"));
-}
-
-TEST_CASE("stringuntils compareStrI 1", "")
-{
- std::string str1;
- std::string str2;
- REQUIRE(0 == compareStrI(str1, str2));
-
- str1 = "test";
- str2 = "test";
- REQUIRE(0 == compareStrI(str1, str2));
-
- str1 = "test";
- str2 = "test1";
- REQUIRE(0 > compareStrI(str1, str2));
-
- str1 = "test";
- str2 = "aest1aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
- REQUIRE(0 < compareStrI(str1, str2));
-
- str1 = "testaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
- str2 = "testaa";
- REQUIRE(0 < compareStrI(str1, str2));
-}
-
-TEST_CASE("stringuntils isWordSeparator 1", "")
-{
- REQUIRE(isWordSeparator(' '));
- REQUIRE(isWordSeparator(','));
- REQUIRE(isWordSeparator('.'));
- REQUIRE(isWordSeparator('\"'));
- REQUIRE(!isWordSeparator(0));
- REQUIRE(!isWordSeparator('a'));
- REQUIRE(!isWordSeparator('-'));
-}
-
-TEST_CASE("stringuntils findSameSubstring", "")
-{
- std::string str1;
- std::string str2;
-
- REQUIRE(findSameSubstring("", "").empty());
-
- str1 = "test line";
- str2 = "test line";
- REQUIRE("test line" == findSameSubstring(str1, str2));
-
- str1 = "test li";
- str2 = "test line";
- REQUIRE("test li" == findSameSubstring(str1, str2));
-
- str1 = "test li";
- str2 = "est li";
- REQUIRE(findSameSubstring(str1, str2).empty());
-}
-
-TEST_CASE("stringuntils findSameSubstringI", "")
-{
- std::string str1;
- std::string str2;
-
- REQUIRE(findSameSubstringI("", "").empty());
-
- str1 = "tEst line";
- str2 = "tesT line";
- REQUIRE("tEst line" == findSameSubstringI(str1, str2));
-
- str1 = "test Li";
- str2 = "test lINe";
- REQUIRE("test Li" == findSameSubstringI(str1, str2));
-
- str1 = "test lINe";
- str2 = "test Li";
- REQUIRE("test lI" == findSameSubstringI(str1, str2));
-
- str1 = "teSt li";
- str2 = "est li";
- REQUIRE(findSameSubstringI(str1, str2).empty());
-}
-
-TEST_CASE("stringuntils findI 1", "")
-{
- REQUIRE(0 == findI("", ""));
- REQUIRE(std::string::npos == findI("test", "line"));
- REQUIRE(0 == findI("test line", "t"));
- REQUIRE(0 == findI("test line", "te"));
- REQUIRE(3 == findI("test line", "t l"));
-}
-
-TEST_CASE("stringuntils findI 2", "")
-{
- STD_VECTOR <std::string> vect1;
- vect1.push_back("test");
- vect1.push_back("line");
- vect1.push_back("qwe");
-
- REQUIRE(std::string::npos == findI("", vect1));
- REQUIRE(0 == findI("test", vect1));
- REQUIRE(0 == findI("tesT lIne", vect1));
- REQUIRE(5 == findI("teoT line", vect1));
- REQUIRE(std::string::npos == findI("zzz", vect1));
-}
-
-TEST_CASE("stringuntils encodeStr 1", "")
-{
- std::string str = encodeStr(10, 1);
- REQUIRE(10 == decodeStr(str));
-
- str.clear();
- REQUIRE(0 == decodeStr(str));
-
- str = encodeStr(10, 2);
- REQUIRE(10 == decodeStr(str));
-
- str = encodeStr(100, 3);
- REQUIRE(100 == decodeStr(str));
-
- str = encodeStr(1000, 4);
- REQUIRE(1000 == decodeStr(str));
-}
-
-TEST_CASE("stringuntils extractNameFromSprite 1", "")
-{
- REQUIRE(extractNameFromSprite("").empty());
- REQUIRE("test" == extractNameFromSprite("test"));
- REQUIRE("test" == extractNameFromSprite("test.qwe"));
- REQUIRE("line" == extractNameFromSprite("test/line.zzz"));
- REQUIRE("line" == extractNameFromSprite("test\\line.zzz"));
- REQUIRE("line" == extractNameFromSprite("test/test2\\line.zzz"));
- REQUIRE("line" == extractNameFromSprite("test\\test2/line.zzz"));
-}
-
-TEST_CASE("stringuntils removeSpriteIndex 1", "")
-{
- REQUIRE(removeSpriteIndex("").empty());
- REQUIRE("test" == removeSpriteIndex("test"));
- REQUIRE("test" == removeSpriteIndex("test[1]"));
- REQUIRE("line" == removeSpriteIndex("test/line[12]"));
- REQUIRE("line" == removeSpriteIndex("test\\line[12]"));
- REQUIRE("line" == removeSpriteIndex("test/test2\\line[12]"));
- REQUIRE("line" == removeSpriteIndex("test\\test2/line[1]"));
-}
-
-TEST_CASE("stringutils getSafeUtf8String 1", "")
-{
- const char *str;
- str = getSafeUtf8String("");
- REQUIRE(str != nullptr);
- REQUIRE(strcmp("", str) == 0);
- REQUIRE(str[0] == '\0');
- REQUIRE(str[UTF8_MAX_SIZE - 1] == '\0');
- delete [] str;
-
- str = getSafeUtf8String("test line");
- REQUIRE(str != nullptr);
- REQUIRE(strcmp("test line", str) == 0);
- REQUIRE(str[strlen("test line")] == '\0');
- REQUIRE(str[UTF8_MAX_SIZE - 1] == '\0');
- delete [] str;
-
- str = getSafeUtf8String("1");
- REQUIRE(str != nullptr);
- REQUIRE(strcmp("1", str) == 0);
- REQUIRE(str[1] == '\0');
- REQUIRE(str[UTF8_MAX_SIZE - 1] == '\0');
- delete [] str;
-}
-
-TEST_CASE("stringutils getSafeUtf8String 2", "")
-{
- char *str;
-
- getSafeUtf8String("test", nullptr);
-
- str = new char[65535];
- getSafeUtf8String("", str);
- REQUIRE(str != nullptr);
- REQUIRE(strcmp("", str) == 0);
- REQUIRE(str[0] == '\0');
- REQUIRE(str[UTF8_MAX_SIZE - 1] == '\0');
- delete [] str;
-
- str = new char[65535];
- getSafeUtf8String("test line", str);
- REQUIRE(str != nullptr);
- REQUIRE(strcmp("test line", str) == 0);
- REQUIRE(str[strlen("test line")] == '\0');
- REQUIRE(str[UTF8_MAX_SIZE - 1] == '\0');
- delete [] str;
-
- str = new char[65535];
- getSafeUtf8String("1", str);
- REQUIRE(str != nullptr);
- REQUIRE(strcmp("1", str) == 0);
- REQUIRE(str[1] == '\0');
- REQUIRE(str[UTF8_MAX_SIZE - 1] == '\0');
- delete [] str;
-
- str = new char[65535];
- char *data1 = new char[65510];
- memset(data1, 'a', 65510);
- data1[65509] = '\0';
- char *data2 = new char[65510];
- memset(data2, 'a', 65500);
- data2[65500] = '\0';
- getSafeUtf8String(data1, str);
- REQUIRE(str != nullptr);
- REQUIRE(strcmp(data2, str) == 0);
- REQUIRE(str[65500] == '\0');
- delete [] data1;
- delete [] data2;
- delete [] str;
-}
-
-TEST_CASE("stringuntils getFileName 1", "")
-{
- REQUIRE(getFileName("").empty());
- REQUIRE("file" == getFileName("file"));
- REQUIRE("file" == getFileName("test/file1\\file"));
- REQUIRE("file" == getFileName("test\\file1/file"));
- REQUIRE(getFileName("file/").empty());
- REQUIRE("file" == getFileName("/file"));
-}
-
-TEST_CASE("stringuntils getFileDir 1", "")
-{
- REQUIRE(getFileDir("").empty());
- REQUIRE("file" == getFileDir("file"));
- REQUIRE("test/file1" == getFileDir("test/file1\\file"));
- REQUIRE("test\\file1" == getFileDir("test\\file1/file"));
- REQUIRE("file" == getFileDir("file/"));
- REQUIRE(getFileDir("/file").empty());
-}
-
-TEST_CASE("stringuntils replaceAll 1", "")
-{
- std::string str1;
- std::string str2;
- std::string str3;
-
- REQUIRE(replaceAll(str1, str2, str3).empty());
-
- str1 = "this is test line";
- str2 = "";
- str3 = "";
- REQUIRE("this is test line" == replaceAll(str1, str2, str3));
-
- str1 = "this is test line";
- str2 = "is ";
- str3 = "";
- REQUIRE("thtest line" == replaceAll(str1, str2, str3));
-
- str1 = "this is test line";
- str2 = "";
- str3 = "1";
- REQUIRE("this is test line" == replaceAll(str1, str2, str3));
-}
-
-TEST_CASE("stringuntils replaceRecursiveAll 1", "")
-{
- std::string str;
- str = "";
- replaceRecursiveAll(str, "line", '.');
- REQUIRE(str.empty());
- str = "test line";
- replaceRecursiveAll(str, "line", '.');
- REQUIRE(str == "test .");
- str = "11112222";
- replaceRecursiveAll(str, "11", '1');
- REQUIRE(str == "12222");
- str = "122221";
- replaceRecursiveAll(str, "11", '1');
- REQUIRE(str == "122221");
- str = "1222211";
- replaceRecursiveAll(str, "11", '1');
- REQUIRE(str == "122221");
- str = "11112222";
- replaceRecursiveAll(str, "112", '1');
- REQUIRE(str == "111222");
- str = "111122224";
- replaceRecursiveAll(str, "112", '1');
- REQUIRE(str == "1112224");
- str = "3111122224";
- replaceRecursiveAll(str, "112", '1');
- REQUIRE(str == "31112224");
- str = "121212";
- replaceRecursiveAll(str, "12", '1');
- REQUIRE(str == "111");
- str = "1121212";
- replaceRecursiveAll(str, "12", '1');
- REQUIRE(str == "1111");
- str = "11212122";
- replaceRecursiveAll(str, "12", '1');
- REQUIRE(str == "1111");
- str = "112121222";
- replaceRecursiveAll(str, "12", '1');
- REQUIRE(str == "1111");
- str = "112211221122";
- replaceRecursiveAll(str, "12", '1');
- REQUIRE(str == "111111");
-}
-
-TEST_CASE("stringuntils getBoolFromString 1", "")
-{
- REQUIRE(getBoolFromString("true"));
- REQUIRE(getBoolFromString("yes"));
- REQUIRE(getBoolFromString("on"));
- REQUIRE(!getBoolFromString("false"));
- REQUIRE(!getBoolFromString("no"));
- REQUIRE(!getBoolFromString("off"));
- REQUIRE(getBoolFromString("1"));
- REQUIRE(!getBoolFromString("0"));
- REQUIRE(getBoolFromString("2"));
-
- REQUIRE(getBoolFromString(" true"));
- REQUIRE(getBoolFromString("yes "));
- REQUIRE(getBoolFromString(" on"));
- REQUIRE(!getBoolFromString("false "));
- REQUIRE(!getBoolFromString(" no"));
- REQUIRE(!getBoolFromString("off "));
- REQUIRE(getBoolFromString(" 1"));
- REQUIRE(!getBoolFromString("0 "));
- REQUIRE(getBoolFromString(" 2"));
-
- REQUIRE(getBoolFromString("tRue "));
- REQUIRE(getBoolFromString(" Yes"));
- REQUIRE(getBoolFromString("ON "));
- REQUIRE(!getBoolFromString(" fALse"));
- REQUIRE(!getBoolFromString("nO "));
- REQUIRE(!getBoolFromString(" oFF"));
-}
-
-TEST_CASE("stringuntils parseBoolean 1", "")
-{
- REQUIRE(parseBoolean("true") == 1);
- REQUIRE(parseBoolean("yes") == 1);
- REQUIRE(parseBoolean("on") == 1);
- REQUIRE(parseBoolean("false") == 0);
- REQUIRE(parseBoolean("no") == 0);
- REQUIRE(parseBoolean("off") == 0);
- REQUIRE(parseBoolean("1") == 1);
- REQUIRE(parseBoolean("0") == 0);
- REQUIRE(parseBoolean("2") == -1);
- REQUIRE(parseBoolean("test") == -1);
- REQUIRE(parseBoolean("") == -1);
-
- REQUIRE(parseBoolean("true ") == 1);
- REQUIRE(parseBoolean(" yes") == 1);
- REQUIRE(parseBoolean("on ") == 1);
- REQUIRE(parseBoolean(" false") == 0);
- REQUIRE(parseBoolean("no ") == 0);
- REQUIRE(parseBoolean(" off") == 0);
- REQUIRE(parseBoolean("1 ") == 1);
- REQUIRE(parseBoolean(" 0") == 0);
- REQUIRE(parseBoolean("2 ") == -1);
- REQUIRE(parseBoolean(" test") == -1);
- REQUIRE(parseBoolean(" ") == -1);
-
- REQUIRE(parseBoolean(" tRue") == 1);
- REQUIRE(parseBoolean("Yes ") == 1);
- REQUIRE(parseBoolean(" ON") == 1);
- REQUIRE(parseBoolean("FaLse ") == 0);
- REQUIRE(parseBoolean(" nO") == 0);
- REQUIRE(parseBoolean("oFf ") == 0);
- REQUIRE(parseBoolean(" tEst") == -1);
-}
-
-TEST_CASE("stringuntils splitToIntSet 1", "")
-{
- std::set<int> tokens;
- splitToIntSet(tokens, "", ',');
- REQUIRE(tokens.empty() == true);
-
- tokens.clear();
- splitToIntSet(tokens, "10z,aa,-1", ',');
- REQUIRE(tokens.size() == 3);
- REQUIRE(tokens.find(10) != tokens.end());
- REQUIRE(tokens.find(0) != tokens.end());
- REQUIRE(tokens.find(-1) != tokens.end());
-
- tokens.clear();
- splitToIntSet(tokens, "10,2,30", ',');
- REQUIRE(tokens.size() == 3);
- REQUIRE(tokens.find(10) != tokens.end());
- REQUIRE(tokens.find(2) != tokens.end());
- REQUIRE(tokens.find(30) != tokens.end());
-
- tokens.clear();
- splitToIntSet(tokens, "10,2,30,", ',');
- REQUIRE(tokens.size() == 3);
- REQUIRE(tokens.find(10) != tokens.end());
- REQUIRE(tokens.find(2) != tokens.end());
- REQUIRE(tokens.find(30) != tokens.end());
-
- tokens.clear();
- splitToIntSet(tokens, "10,2;30", ',');
- REQUIRE(tokens.size() == 2);
- REQUIRE(tokens.find(10) != tokens.end());
- REQUIRE(tokens.find(2) != tokens.end());
-
- tokens.clear();
- splitToIntSet(tokens, "10;20;30", ';');
- REQUIRE(tokens.size() == 3);
- REQUIRE(tokens.find(10) != tokens.end());
- REQUIRE(tokens.find(20) != tokens.end());
- REQUIRE(tokens.find(30) != tokens.end());
-}
-
-TEST_CASE("stringuntils splitToIntList 1", "")
-{
- std::list<int> tokens;
- tokens = splitToIntList("", ',');
- REQUIRE(tokens.empty() == true);
-
- tokens.clear();
- tokens = splitToIntList("10z,a,-1", ',');
- REQUIRE(tokens.size() == 3);
- REQUIRE(tokens.front() == 10);
- tokens.pop_front();
- REQUIRE(tokens.front() == 0);
- tokens.pop_front();
- REQUIRE(tokens.front() == -1);
- tokens.pop_front();
-
- tokens.clear();
- tokens = splitToIntList("10,2,30", ',');
- REQUIRE(tokens.size() == 3);
- REQUIRE(tokens.front() == 10);
- tokens.pop_front();
- REQUIRE(tokens.front() == 2);
- tokens.pop_front();
- REQUIRE(tokens.front() == 30);
- tokens.pop_front();
-
- tokens.clear();
- tokens = splitToIntList("10,2,30,", ',');
- REQUIRE(tokens.size() == 3);
- REQUIRE(tokens.front() == 10);
- tokens.pop_front();
- REQUIRE(tokens.front() == 2);
- tokens.pop_front();
- REQUIRE(tokens.front() == 30);
- tokens.pop_front();
-
- tokens.clear();
- tokens = splitToIntList("10,2;30", ',');
- REQUIRE(tokens.size() == 2);
- REQUIRE(tokens.front() == 10);
- tokens.pop_front();
- REQUIRE(tokens.front() == 2);
- tokens.pop_front();
-
- tokens.clear();
- tokens = splitToIntList("10;20;30", ';');
- REQUIRE(tokens.size() == 3);
- REQUIRE(tokens.front() == 10);
- tokens.pop_front();
- REQUIRE(tokens.front() == 20);
- tokens.pop_front();
- REQUIRE(tokens.front() == 30);
- tokens.pop_front();
-}
-
-TEST_CASE("stringuntils splitToStringSet 1", "")
-{
- std::set<std::string> tokens;
- splitToStringSet(tokens, "", ',');
- REQUIRE(tokens.empty() == true);
-
- tokens.clear();
- splitToStringSet(tokens, "10q,2w,30e", ',');
- REQUIRE(tokens.size() == 3);
- REQUIRE(tokens.find("10q") != tokens.end());
- REQUIRE(tokens.find("2w") != tokens.end());
- REQUIRE(tokens.find("30e") != tokens.end());
-
- tokens.clear();
- splitToStringSet(tokens, "10q,2w,30e,", ',');
- REQUIRE(tokens.size() == 3);
- REQUIRE(tokens.find("10q") != tokens.end());
- REQUIRE(tokens.find("2w") != tokens.end());
- REQUIRE(tokens.find("30e") != tokens.end());
-
- tokens.clear();
- splitToStringSet(tokens, "10q,,30e", ',');
- REQUIRE(tokens.size() == 2);
- REQUIRE(tokens.find("10q") != tokens.end());
- REQUIRE(tokens.find("30e") != tokens.end());
-
- tokens.clear();
- splitToStringSet(tokens, "10q,2w,30e,", ',');
- REQUIRE(tokens.size() == 3);
- REQUIRE(tokens.find("10q") != tokens.end());
- REQUIRE(tokens.find("2w") != tokens.end());
- REQUIRE(tokens.find("30e") != tokens.end());
-
- tokens.clear();
- splitToStringSet(tokens, "10w,2w;30e", ',');
- REQUIRE(tokens.size() == 2);
- REQUIRE(tokens.find("10w") != tokens.end());
- REQUIRE(tokens.find("2w;30e") != tokens.end());
-
- tokens.clear();
- splitToStringSet(tokens, "10q;20w;30e", ';');
- REQUIRE(tokens.size() == 3);
- REQUIRE(tokens.find("10q") != tokens.end());
- REQUIRE(tokens.find("20w") != tokens.end());
- REQUIRE(tokens.find("30e") != tokens.end());
-}
-
-TEST_CASE("stringuntils splitToIntVector 1", "")
-{
- STD_VECTOR<int> tokens;
- splitToIntVector(tokens, "", ',');
- REQUIRE(tokens.empty() == true);
-
- tokens.clear();
- splitToIntVector(tokens, "10,2,30", ',');
- REQUIRE(tokens.size() == 3);
- REQUIRE(tokens[0] == 10);
- REQUIRE(tokens[1] == 2);
- REQUIRE(tokens[2] == 30);
-
- tokens.clear();
- splitToIntVector(tokens, "10,2a,z30", ',');
- REQUIRE(tokens.size() == 3);
- REQUIRE(tokens[0] == 10);
- REQUIRE(tokens[1] == 2);
- REQUIRE(tokens[2] == 0);
-
- tokens.clear();
- splitToIntVector(tokens, "10,2,30,", ',');
- REQUIRE(tokens.size() == 3);
- REQUIRE(tokens[0] == 10);
- REQUIRE(tokens[1] == 2);
- REQUIRE(tokens[2] == 30);
-
- tokens.clear();
- splitToIntVector(tokens, "10,,30", ',');
- REQUIRE(tokens.size() == 2);
- REQUIRE(tokens[0] == 10);
- REQUIRE(tokens[1] == 30);
-
- tokens.clear();
- splitToIntVector(tokens, "10,2;30", ',');
- REQUIRE(tokens.size() == 2);
- REQUIRE(tokens[0] == 10);
- REQUIRE(tokens[1] == 2);
-
- tokens.clear();
- splitToIntVector(tokens, "10;20;30", ';');
- REQUIRE(tokens.size() == 3);
- REQUIRE(tokens[0] == 10);
- REQUIRE(tokens[1] == 20);
- REQUIRE(tokens[2] == 30);
-}
-
-TEST_CASE("stringuntils splitToStringVector 1", "")
-{
- STD_VECTOR<std::string> tokens;
- splitToStringVector(tokens, "", ',');
- REQUIRE(tokens.empty() == true);
-
- tokens.clear();
- splitToStringVector(tokens, "t,line,zz", ',');
- REQUIRE(tokens.size() == 3);
- REQUIRE(tokens[0] == "t");
- REQUIRE(tokens[1] == "line");
- REQUIRE(tokens[2] == "zz");
-
- tokens.clear();
- splitToStringVector(tokens, "t,line,zz,", ',');
- REQUIRE(tokens.size() == 3);
- REQUIRE(tokens[0] == "t");
- REQUIRE(tokens[1] == "line");
- REQUIRE(tokens[2] == "zz");
-
- tokens.clear();
- splitToStringVector(tokens, "t,,zz", ',');
- REQUIRE(tokens.size() == 2);
- REQUIRE(tokens[0] == "t");
- REQUIRE(tokens[1] == "zz");
-
- tokens.clear();
- splitToStringVector(tokens, "10,a2;30", ',');
- REQUIRE(tokens.size() == 2);
- REQUIRE(tokens[0] == "10");
- REQUIRE(tokens[1] == "a2;30");
-
- tokens.clear();
- splitToStringVector(tokens, "a10;b;3line", ';');
- REQUIRE(tokens.size() == 3);
- REQUIRE(tokens[0] == "a10");
- REQUIRE(tokens[1] == "b");
- REQUIRE(tokens[2] == "3line");
-}
-
-TEST_CASE("stringuntils replaceSpecialChars 1", "")
-{
- std::string str;
-
- str = "";
- replaceSpecialChars(str);
- REQUIRE(str.empty());
-
- str = "test";
- replaceSpecialChars(str);
- REQUIRE("test" == str);
-
- str = "&";
- replaceSpecialChars(str);
- REQUIRE("&" == str);
-
- str = "&1";
- replaceSpecialChars(str);
- REQUIRE("&1" == str);
-
- str = "&33";
- replaceSpecialChars(str);
- REQUIRE("&33" == str);
-
- str = "&33;";
- replaceSpecialChars(str);
- REQUIRE("!" == str);
-
- str = "&33z;";
- replaceSpecialChars(str);
- REQUIRE("&33z;" == str);
-
- str = "1&33;";
- replaceSpecialChars(str);
- REQUIRE("1!" == str);
-
- str = "&33;2";
- replaceSpecialChars(str);
- REQUIRE("!2" == str);
-
- str = "&33;&";
- replaceSpecialChars(str);
- REQUIRE("!&" == str);
-
- str = "test line&33;";
- replaceSpecialChars(str);
- REQUIRE("test line!" == str);
-}
-
-TEST_CASE("stringuntils normalize 1", "")
-{
- REQUIRE(normalize("").empty());
- REQUIRE(normalize("test") == "test");
- REQUIRE(normalize("Test") == "test");
- REQUIRE(normalize(" test line") == "test line");
- REQUIRE(normalize("test line ") == "test line");
- REQUIRE(normalize(" tEst line") == "test line");
- REQUIRE(normalize("test lIne ") == "test line");
-}
-
-TEST_CASE("stringuntils combineDye 1", "")
-{
- REQUIRE(combineDye("", "").empty());
- REQUIRE("test" == combineDye("test", ""));
- REQUIRE("|line" == combineDye("", "line"));
- REQUIRE("test|line" == combineDye("test", "line"));
- REQUIRE("|line" == combineDye("|w", "line"));
- REQUIRE("aaa|line" == combineDye("aaa|w", "line"));
- REQUIRE("test|line" == combineDye("test|w", "line"));
-}
-
-TEST_CASE("stringuntils combineDye 2", "")
-{
- REQUIRE(combineDye2("", "").empty());
- REQUIRE("test" == combineDye2("test", ""));
- REQUIRE("test" == combineDye2("test", "W"));
- REQUIRE(combineDye2("", "line").empty());
- REQUIRE("test.xml" == combineDye2("test.xml", "123"));
- REQUIRE("test.xml|#43413d,59544f,7a706c" ==
- combineDye2("test.xml|#43413d,59544f,7a706c", ""));
- REQUIRE("test.xml|#43413d,59544f,7a706c:W;" ==
- combineDye2("test.xml|#43413d,59544f,7a706c", "W"));
- REQUIRE("test.xml|#43413d,59544f,7a706c:W;#123456:B;" ==
- combineDye2("test.xml|#43413d,59544f,7a706c;#123456", "W;B"));
-}
-
-TEST_CASE("stringuntils combineDye 3", "")
-{
- REQUIRE(combineDye3("", "").empty());
- REQUIRE("test" == combineDye3("test", ""));
- REQUIRE(combineDye3("", "line").empty());
- REQUIRE("test.xml|123" == combineDye3("test.xml", "123"));
- REQUIRE("test.xml|#43413d,59544f,7a706c" ==
- combineDye3("test.xml|#43413d,59544f,7a706c", ""));
- REQUIRE("test.xml|#43413d,59544f,7a706c:W;" ==
- combineDye3("test.xml|#43413d,59544f,7a706c", "W"));
- REQUIRE("test.xml|#43413d,59544f,7a706c:W;#123456:B;" ==
- combineDye3("test.xml|#43413d,59544f,7a706c;#123456", "W;B"));
-}
-
-TEST_CASE("stringuntils packList 1", "")
-{
- std::list <std::string> list;
- REQUIRE(packList(list).empty());
-
- list.push_back(std::string());
- REQUIRE("|" == packList(list));
-
- list.clear();
- list.push_back("test");
- REQUIRE("test" == packList(list));
-
- list.push_back("line");
- REQUIRE("test|line" == packList(list));
-
- list.push_back("2");
- REQUIRE("test|line|2" == packList(list));
-
- list.clear();
- list.push_back("|test");
- list.push_back("line");
- REQUIRE("|test|line" == packList(list));
-}
-
-TEST_CASE("stringuntils stringToHexPath 1", "")
-{
- std::string str;
-
- str = "";
- REQUIRE(stringToHexPath(str).empty());
-
- str = "a";
- REQUIRE("%61/" == stringToHexPath(str));
-
- str = "ab";
- REQUIRE("%61/%62" == stringToHexPath(str));
-
- str = "abc";
- REQUIRE("%61/%62%63" == stringToHexPath(str));
-
- str = "abcd";
- REQUIRE("%61/%62%63%64" == stringToHexPath(str));
-}
-
-TEST_CASE("stringuntils deleteCharLeft 1", "")
-{
- std::string str;
- unsigned int pos = 0;
-
- str = "";
- deleteCharLeft(str, nullptr);
- REQUIRE(str.empty());
-
- str = "test line";
- pos = 4;
- deleteCharLeft(str, &pos);
- REQUIRE("tes line" == str);
-
- str = "тест line";
- pos = 8;
- deleteCharLeft(str, &pos);
- REQUIRE("тес line" == str);
-
- str = "test line\x0";
- pos = 4;
- deleteCharLeft(str, &pos);
- REQUIRE("tes line\x0" == str);
-}
-
-TEST_CASE("stringuntils findLast 1", "")
-{
- std::string str;
-
- str = "";
- REQUIRE(findLast(str, ""));
-
- str = "test line";
- REQUIRE(findLast(str, "line"));
-
- str = "test line";
- REQUIRE(!findLast(str, "lin"));
-}
-
-TEST_CASE("stringuntils findFirst 1", "")
-{
- std::string str;
-
- str = "";
- REQUIRE(findFirst(str, ""));
-
- str = "test line";
- REQUIRE(findFirst(str, "test"));
-
- str = "test";
- REQUIRE(findFirst(str, "test line") == false);
-
- str = "test line";
- REQUIRE(findFirst(str, "est") == false);
-}
-
-TEST_CASE("stringuntils findCutLast 1", "")
-{
- std::string str;
-
- str = "";
- REQUIRE(findCutLast(str, ""));
- REQUIRE(str.empty());
-
- str = "test line";
- REQUIRE(findCutLast(str, "line"));
- REQUIRE("test " == str);
-
- str = "test line";
- REQUIRE(findCutLast(str, "lin") == false);
- REQUIRE("test line" == str);
-
- str = "test";
- REQUIRE(findCutLast(str, "test line") == false);
- REQUIRE("test" == str);
-}
-
-TEST_CASE("stringuntils CutLast 1", "")
-{
- std::string str;
-
- str = "";
- cutLast(str, "");
- REQUIRE(str.empty());
-
- str = "test line";
- cutLast(str, "line");
- REQUIRE("test " == str);
-
- str = "test line";
- cutLast(str, "lin");
- REQUIRE("test line" == str);
-
- str = "test";
- cutLast(str, "test line");
- REQUIRE("test" == str);
-}
-
-TEST_CASE("stringuntils findCutFirst 1", "")
-{
- std::string str;
-
- str = "";
- REQUIRE(findCutFirst(str, ""));
- REQUIRE(str.empty());
-
- str = "test line";
- REQUIRE(findCutFirst(str, "test"));
- REQUIRE(" line" == str);
-
- str = "test line";
- REQUIRE(findCutFirst(str, "est") == false);
- REQUIRE("test line" == str);
-
- str = "test";
- REQUIRE(findCutFirst(str, "test line") == false);
- REQUIRE("test" == str);
-}
-
-TEST_CASE("stringuntils cutFirst 1", "")
-{
- std::string str;
-
- str = "";
- cutFirst(str, "");
- REQUIRE(str.empty());
-
- str = "test line";
- cutFirst(str, "test");
- REQUIRE(" line" == str);
-
- str = "test line";
- cutFirst(str, "est");
- REQUIRE("test line" == str);
-
- str = "test";
- cutFirst(str, "test line");
- REQUIRE("test" == str);
-}
-
-TEST_CASE("stringuntils removeProtocol 1", "")
-{
- std::string str;
-
- str = "";
- REQUIRE(removeProtocol(str).empty());
-
- str = "http://";
- REQUIRE(removeProtocol(str).empty());
-
- str = "http://test";
- REQUIRE("test" == removeProtocol(str));
-}
-
-TEST_CASE("stringuntils strStartWith 1", "")
-{
- REQUIRE(strStartWith("", ""));
- REQUIRE(!strStartWith("", "1"));
- REQUIRE(strStartWith("test line", "test"));
- REQUIRE(strStartWith("test line", "test line"));
- REQUIRE(!strStartWith("test line", "est"));
-}
-
-TEST_CASE("stringuntils encodeLinkText", "")
-{
- std::string str;
-
- str = encodeLinkText("test line");
- REQUIRE(str == "test line");
- str = encodeLinkText("test|line");
- REQUIRE(str == "test\342\235\230line");
- str = encodeLinkText("test||line");
- REQUIRE(str == "test\342\235\230\342\235\230line");
-}
-
-TEST_CASE("stringuntils decodeLinkText", "")
-{
- std::string str;
-
- str = encodeLinkText("test|line");
- REQUIRE(str == "test\342\235\230line");
- str = decodeLinkText(str);
- REQUIRE(str == "test|line");
-}
-
-TEST_CASE("stringuntils isDigit", "")
-{
- REQUIRE_FALSE(isDigit(""));
- REQUIRE(isDigit("1"));
- REQUIRE(isDigit("123"));
- REQUIRE_FALSE(isDigit("+123"));
- REQUIRE_FALSE(isDigit("-123"));
- REQUIRE_FALSE(isDigit("1.23"));
- REQUIRE_FALSE(isDigit("12-34"));
-}
-
-TEST_CASE("stringuntils findAny", "")
-{
- REQUIRE(findAny("test line", ",", 0) == std::string::npos);
- REQUIRE(findAny("test line", " ", 0) == 4U);
- REQUIRE(findAny("test, line", ", ", 0) == 4U);
- REQUIRE(findAny("test ,line", ", ", 0) == 4U);
- REQUIRE(findAny("test, line", " ,", 2) == 4U);
- REQUIRE(findAny("test ,line", " ,", 3) == 4U);
- REQUIRE(findAny("\"one\",,two, tree", ",", 5) == 5U);
-}
-
-TEST_CASE("stringuntils escapeString", "")
-{
- REQUIRE(escapeString("") == "\"\"");
- REQUIRE(escapeString("1") == "\"1\"");
- REQUIRE(escapeString(" ") == "\" \"");
- REQUIRE(escapeString("\"") == "\"\\\"\"");
- REQUIRE(escapeString("123") == "\"123\"");
- REQUIRE(escapeString("12\"3") == "\"12\\\"3\"");
- REQUIRE(escapeString("12\"\"3") == "\"12\\\"\\\"3\"");
- REQUIRE(escapeString("\"123\"") == "\"\\\"123\\\"\"");
- REQUIRE(escapeString("\\") == "\"\\\"");
- REQUIRE(escapeString("12\\3") == "\"12\\3\"");
-}
-
-TEST_CASE("stringuntils sanitizePath", "")
-{
- std::string path;
- const std::string sep = dirSeparator;
- path = "";
- sanitizePath(path);
- REQUIRE(path.empty());
- path = "/";
- sanitizePath(path);
- REQUIRE(path == dirSeparator);
- path = "/\\";
- sanitizePath(path);
- REQUIRE(path == dirSeparator);
- path = "\\/";
- sanitizePath(path);
- REQUIRE(path == dirSeparator);
- path = "//";
- sanitizePath(path);
- REQUIRE(path == dirSeparator);
- path = "///";
- sanitizePath(path);
- REQUIRE(path == dirSeparator);
- path = "//\\/";
- sanitizePath(path);
- REQUIRE(path == dirSeparator);
- path = "///\\";
- sanitizePath(path);
- REQUIRE(path == dirSeparator);
- path = "\\";
- sanitizePath(path);
- REQUIRE(path == dirSeparator);
- path = "\\\\";
- sanitizePath(path);
- REQUIRE(path == dirSeparator);
- path = "\\/\\";
- sanitizePath(path);
- REQUIRE(path == dirSeparator);
- path = "\\\\/";
- sanitizePath(path);
- REQUIRE(path == dirSeparator);
- path = "test";
- sanitizePath(path);
- REQUIRE(path == "test");
- path = "./test";
- sanitizePath(path);
- REQUIRE(path == "." + sep + "test");
- path = "test line";
- sanitizePath(path);
- REQUIRE(path == "test line");
- path = "dir/test";
- sanitizePath(path);
- REQUIRE(path == "dir" + sep + "test");
- path = "/dir/test";
- sanitizePath(path);
- REQUIRE(path == sep + "dir" + sep + "test");
- path = "dir//test";
- sanitizePath(path);
- REQUIRE(path == "dir" + sep + "test");
- path = "dir///test";
- sanitizePath(path);
- REQUIRE(path == "dir" + sep + "test");
- path = "dir///\\test";
- sanitizePath(path);
- REQUIRE(path == "dir" + sep + "test");
- path = "dir/\\//test";
- sanitizePath(path);
- REQUIRE(path == "dir" + sep + "test");
- path = "dir\\test";
- sanitizePath(path);
- REQUIRE(path == "dir" + sep + "test");
- path = "dir/test/";
- sanitizePath(path);
- REQUIRE(path == "dir" + sep + "test" + sep);
- path = "dir/test\\";
- sanitizePath(path);
- REQUIRE(path == "dir" + sep + "test" + sep);
- path = "/very\\long/dir\\with\\sepa/ra/tors";
- sanitizePath(path);
- REQUIRE(path == sep + "very" + sep + "long" + sep + \
- "dir" + sep + "with" + sep + "sepa" + sep + "ra" + sep + "tors");
- path = "/very\\long/dir\\\\with\\sepa//ra/tors";
- sanitizePath(path);
- REQUIRE(path == sep + "very" + sep + "long" + sep + \
- "dir" + sep + "with" + sep + "sepa" + sep + "ra" + sep + "tors");
-}
-
-TEST_CASE("stringuntils pathJoin1", "")
-{
- const std::string sep = dirSeparator;
-
- REQUIRE(pathJoin("", "") == sep);
- REQUIRE(pathJoin(sep, "") == sep);
- REQUIRE(pathJoin("", sep) == sep);
- REQUIRE(pathJoin(sep, sep) == sep);
- REQUIRE(pathJoin("dir1", "dir2") == "dir1" + sep + "dir2");
- REQUIRE(pathJoin("dir1" + sep, "dir2") == "dir1" + sep + "dir2");
- REQUIRE(pathJoin("dir1", sep + "dir2") == "dir1" + sep + "dir2");
- REQUIRE(pathJoin("dir1" + sep, sep + "dir2") == "dir1" + sep + "dir2");
- REQUIRE(pathJoin("dir1" + sep + "dir2" + sep + "dir3", "dir4") ==
- "dir1" + sep + "dir2" + sep + "dir3" + sep + "dir4");
- REQUIRE(pathJoin("dir1" + sep + "dir2" + sep, "dir3" + sep + "dir4") ==
- "dir1" + sep + "dir2" + sep + "dir3" + sep + "dir4");
- REQUIRE(pathJoin("dir1" + sep + "dir2", "dir3" + sep + "dir4") ==
- "dir1" + sep + "dir2" + sep + "dir3" + sep + "dir4");
- REQUIRE(pathJoin("dir1" + sep + "dir2", sep + "dir3" + sep + "dir4") ==
- "dir1" + sep + "dir2" + sep + "dir3" + sep + "dir4");
-}
-
-TEST_CASE("stringuntils pathJoin2", "")
-{
- const std::string sep = dirSeparator;
-
- REQUIRE(pathJoin("", "", "") == sep);
- REQUIRE(pathJoin(sep, "", "") == sep);
- REQUIRE(pathJoin("", sep, "") == sep);
- REQUIRE(pathJoin("", "", sep) == sep);
- REQUIRE(pathJoin(sep, sep, "") == sep);
- REQUIRE(pathJoin(sep, "", sep) == sep);
- REQUIRE(pathJoin("", sep, sep) == sep);
- REQUIRE(pathJoin(sep, sep, sep) == sep);
-
- REQUIRE(pathJoin("dir1", "dir2", "dir3") ==
- "dir1" + sep + "dir2" + sep + "dir3");
- REQUIRE(pathJoin("dir1" + sep, "dir2", "dir3") ==
- "dir1" + sep + "dir2" + sep + "dir3");
- REQUIRE(pathJoin("dir1", sep + "dir2", "dir3") ==
- "dir1" + sep + "dir2" + sep + "dir3");
- REQUIRE(pathJoin("dir1", "dir2" + sep, "dir3") ==
- "dir1" + sep + "dir2" + sep + "dir3");
- REQUIRE(pathJoin("dir1", "dir2", sep + "dir3") ==
- "dir1" + sep + "dir2" + sep + "dir3");
- REQUIRE(pathJoin("dir1", "dir2", "dir3" + sep) ==
- "dir1" + sep + "dir2" + sep + "dir3" + sep);
- REQUIRE(pathJoin("dir1" + sep, sep + "dir2", "dir3") ==
- "dir1" + sep + "dir2" + sep + "dir3");
- REQUIRE(pathJoin("dir1" + sep, "dir2" + sep, "dir3") ==
- "dir1" + sep + "dir2" + sep + "dir3");
- REQUIRE(pathJoin("dir1" + sep, "dir2", sep + "dir3") ==
- "dir1" + sep + "dir2" + sep + "dir3");
- REQUIRE(pathJoin("dir1" + sep, sep + "dir2" + sep, "dir3") ==
- "dir1" + sep + "dir2" + sep + "dir3");
- REQUIRE(pathJoin("dir1" + sep, sep + "dir2", sep + "dir3") ==
- "dir1" + sep + "dir2" + sep + "dir3");
- REQUIRE(pathJoin("dir1" + sep, sep + "dir2" + sep, "dir3") ==
- "dir1" + sep + "dir2" + sep + "dir3");
- REQUIRE(pathJoin("dir1" + sep, sep + "dir2" + sep, sep + "dir3") ==
- "dir1" + sep + "dir2" + sep + "dir3");
- REQUIRE(pathJoin("dir1" + sep + "dir2" + sep + "dir3", "dir4", "dir5") ==
- "dir1" + sep + "dir2" + sep + "dir3" + sep + "dir4" + sep + "dir5");
- REQUIRE(pathJoin("dir1" + sep + "dir2" + sep,
- "dir3" + sep + "dir4",
- "dir5") ==
- "dir1" + sep + "dir2" + sep + "dir3" + sep + "dir4" + sep + "dir5");
- REQUIRE(pathJoin("dir1" + sep + "dir2",
- "dir3",
- sep + "dir4" + sep + "dir5") ==
- "dir1" + sep + "dir2" + sep + "dir3" + sep + "dir4" + sep + "dir5");
- REQUIRE(pathJoin("dir1" + sep + "dir2",
- sep + "dir3" + sep + "dir4",
- sep + "dir5") ==
- "dir1" + sep + "dir2" + sep + "dir3" + sep + "dir4" + sep + "dir5");
-}
-
-TEST_CASE("stringuntils urlJoin", "")
-{
- REQUIRE(urlJoin("", "") == "/");
- REQUIRE(urlJoin("/", "") == "/");
- REQUIRE(urlJoin("", "/") == "/");
- REQUIRE(urlJoin("/", "/") == "/");
- REQUIRE(urlJoin("dir1", "dir2") == "dir1/dir2");
- REQUIRE(urlJoin("dir1/", "dir2") == "dir1/dir2");
- REQUIRE(urlJoin("dir1", "/dir2") == "dir1/dir2");
- REQUIRE(urlJoin("dir1/", "/dir2") == "dir1/dir2");
- REQUIRE(urlJoin("dir1/dir2/dir3", "dir4") == "dir1/dir2/dir3/dir4");
- REQUIRE(urlJoin("dir1/dir2/", "dir3/dir4") == "dir1/dir2/dir3/dir4");
- REQUIRE(urlJoin("dir1/dir2", "dir3/dir4") == "dir1/dir2/dir3/dir4");
- REQUIRE(urlJoin("dir1/dir2", "/dir3/dir4") == "dir1/dir2/dir3/dir4");
-}
-
-TEST_CASE("stringuntils secureChatCommand", "")
-{
- std::string str;
- secureChatCommand(str);
- REQUIRE(str.empty());
- str = "test";
- secureChatCommand(str);
- REQUIRE(str == "test");
- str = "test line";
- secureChatCommand(str);
- REQUIRE(str == "test line");
- str = "/test";
- secureChatCommand(str);
- REQUIRE(str == "_/test");
- str = "@test";
- secureChatCommand(str);
- REQUIRE(str == "_@test");
- str = "#test";
- secureChatCommand(str);
- REQUIRE(str == "_#test");
-}
-
-#ifdef ENABLE_NLS
-TEST_CASE("stringuntils timeDiffToString", "")
-{
- REQUIRE(timeDiffToString(60 * 60 * 24 * 7) == "1 week");
- REQUIRE(timeDiffToString(60 * 60 * 24 * 7 * 2 +
- 60 * 60 * 24 * 3
- ) == "2 weeks, 3 days");
- REQUIRE(timeDiffToString(60 * 60 * 24 * 7 * 2 +
- 60 * 60 * 24 * 3 +
- 60 * 60 * 4
- ) == "2 weeks, 3 days, 4 hours");
- REQUIRE(timeDiffToString(60 * 60 * 24 * 7 * 2 +
- 60 * 60 * 24 * 3 +
- 60 * 60 * 4 +
- 60 * 7
- ) == "2 weeks, 3 days, 4 hours, 7 minutes");
- REQUIRE(timeDiffToString(60 * 60 * 24 * 7 * 2 +
- 60 * 60 * 24 * 3 +
- 60 * 60 * 4 +
- 60 * 7 +
- 10
- ) == "2 weeks, 3 days, 4 hours, 7 minutes, 10 seconds");
- REQUIRE(timeDiffToString(5) == "5 seconds");
- REQUIRE(timeDiffToString(0) == "0 seconds");
- REQUIRE(timeDiffToString(60 * 60 * 24 * 3
- ) == "3 days");
- REQUIRE(timeDiffToString(60 * 60 * 4
- ) == "4 hours");
- REQUIRE(timeDiffToString(60 * 7
- ) == "7 minutes");
-}
-#endif // ENABLE_NLS
-
-TEST_CASE("stringuntils replaceItemLinks", "")
-{
- VirtFs::mountDirSilent("data", Append_false);
- VirtFs::mountDirSilent("../data", Append_false);
- VirtFs::mountDirSilent("data/test", Append_false);
- VirtFs::mountDirSilent("../data/test", Append_false);
-
- ItemDB::NamedItemInfos &namedInfos = ItemDB::getNamedItemInfosTest();
- ItemDB::ItemInfos &infos = ItemDB::getItemInfosTest();
- setPathsDefaults(paths);
- ItemInfo *info = new ItemInfo;
- info->setId(123456);
- info->setName("test name 1");
- namedInfos["test name 1"] = info;
- infos[123456] = info;
-
- info = new ItemInfo;
- info->setId(123);
- info->setName("test name 2");
- namedInfos["test name 2"] = info;
- namedInfos["qqq"] = info;
- infos[123] = info;
-
- std::string str;
-
- SECTION("empty")
- {
- str = "test line";
- replaceItemLinks(str);
- REQUIRE(str == "test line");
-
- str = "";
- replaceItemLinks(str);
- REQUIRE(str.empty());
-
- str = "[]";
- replaceItemLinks(str);
- REQUIRE(str == "[]");
-
- str = "[qqq]";
- replaceItemLinks(str);
- REQUIRE(str == "[@@123|qqq@@]");
-
- str = "[,]";
- replaceItemLinks(str);
- REQUIRE(str == "[,]");
-
- str = "[, ]";
- replaceItemLinks(str);
- REQUIRE(str == "[, ]");
- }
-
- SECTION("simple")
- {
- str = "[test name 1]";
- replaceItemLinks(str);
- REQUIRE(str == "[@@123456|test name 1@@]");
-
- str = "text1 [test name 1] text2";
- replaceItemLinks(str);
- REQUIRE(str == "text1 [@@123456|test name 1@@] text2");
-
- str = "[test name 1][test name 1]";
- replaceItemLinks(str);
- REQUIRE(str == "[@@123456|test name 1@@][@@123456|test name 1@@]");
-
- str = "[test name 1] [test name 1]";
- replaceItemLinks(str);
- REQUIRE(str == "[@@123456|test name 1@@] [@@123456|test name 1@@]");
-
- str = "test1 [test name 1]test2[test name 1] test3";
- replaceItemLinks(str);
- REQUIRE(str == "test1 [@@123456|test name 1@@]test2"
- "[@@123456|test name 1@@] test3");
-
-// failing because assert
-// str = "[test name 1] [no link]";
-// replaceItemLinks(str);
-// REQUIRE(str == "[@@123456|test name 1@@] [no link]");
-
- str = "[test name 1,test name 2]";
- replaceItemLinks(str);
- REQUIRE(str == "[@@123456,123|@@]");
-
- str = "[test name 1, test name 2 ]";
- replaceItemLinks(str);
- REQUIRE(str == "[@@123456,123|@@]");
- }
-
- SECTION("broken")
- {
- str = "[";
- replaceItemLinks(str);
- REQUIRE(str == "[");
-
- str = "]";
- replaceItemLinks(str);
- REQUIRE(str == "]");
-
- str = "][";
- replaceItemLinks(str);
- REQUIRE(str == "][");
-
- str = "]]";
- replaceItemLinks(str);
- REQUIRE(str == "]]");
-
- str = "]t";
- replaceItemLinks(str);
- REQUIRE(str == "]t");
-
- str = "t[";
- replaceItemLinks(str);
- REQUIRE(str == "t[");
-
- str = "t]";
- replaceItemLinks(str);
- REQUIRE(str == "t]");
-
- str = "[[[";
- replaceItemLinks(str);
- REQUIRE(str == "[[[");
-
- str = "[[]";
- replaceItemLinks(str);
- REQUIRE(str == "[[]");
-
- str = "[[t";
- replaceItemLinks(str);
- REQUIRE(str == "[[t");
-
- str = "[][";
- replaceItemLinks(str);
- REQUIRE(str == "[][");
-
- str = "[]]";
- replaceItemLinks(str);
- REQUIRE(str == "[]]");
-
- str = "[]t";
- replaceItemLinks(str);
- REQUIRE(str == "[]t");
-
- str = "[t[";
- replaceItemLinks(str);
- REQUIRE(str == "[t[");
-
-// failing because assert
-// str = "[t]";
-// replaceItemLinks(str);
-// REQUIRE(str == "[t]");
-
- str = "t[[";
- replaceItemLinks(str);
- REQUIRE(str == "t[[");
-
- str = "t[]";
- replaceItemLinks(str);
- REQUIRE(str == "t[]");
-
- str = "t[[";
- replaceItemLinks(str);
- REQUIRE(str == "t[[");
-
- str = "]]]";
- replaceItemLinks(str);
- REQUIRE(str == "]]]");
- }
-
- SECTION("broken2")
- {
- str = "[][]";
- replaceItemLinks(str);
- REQUIRE(str == "[][]");
-
- str = "[[]]";
- replaceItemLinks(str);
- REQUIRE(str == "[[]]");
-
- str = "][[]";
- replaceItemLinks(str);
- REQUIRE(str == "][[]");
- }
-
- SECTION("broken3")
- {
- str = "[[test name 1]]";
- replaceItemLinks(str);
- REQUIRE(str == "[[@@123456|test name 1@@]]");
-
- str = "[[test name 1]";
- replaceItemLinks(str);
- REQUIRE(str == "[[@@123456|test name 1@@]");
-
- str = "[[qqq] name 1]";
- replaceItemLinks(str);
- REQUIRE(str == "[[@@123|qqq@@] name 1]");
-
- str = "[[test name 1]test name 1]";
- replaceItemLinks(str);
- REQUIRE(str == "[[@@123456|test name 1@@]test name 1]");
-
- str = "[[test name 1[]test name 1]";
- replaceItemLinks(str);
- REQUIRE(str == "[[test name 1[]test name 1]");
-
- str = "[[test name 1],test name2,test name 1]";
- replaceItemLinks(str);
- REQUIRE(str == "[[@@123456|test name 1@@],test name2,test name 1]");
-
- str = "[[ test name 1], test name2,test name 1 ]";
- replaceItemLinks(str);
- REQUIRE(str == "[[@@123456|test name 1@@], test name2,test name 1 ]");
-
- str = "[[test name 1,test name2[]test name 1]";
- replaceItemLinks(str);
- REQUIRE(str == "[[test name 1,test name2[]test name 1]");
-
- str = "[[test name 1 ,test name2[] test name 1]";
- replaceItemLinks(str);
- REQUIRE(str == "[[test name 1 ,test name2[] test name 1]");
- }
- ResourceManager::deleteInstance();
- delete_all(infos);
- infos.clear();
- namedInfos.clear();
- VirtFs::unmountDirSilent("data");
- VirtFs::unmountDirSilent("../data");
- VirtFs::unmountDirSilent("data/test");
- VirtFs::unmountDirSilent("../data/test");
-}
diff --git a/src/unittests/utils/timer.cc b/src/unittests/utils/timer.cc
deleted file mode 100644
index b5cfc692e..000000000
--- a/src/unittests/utils/timer.cc
+++ /dev/null
@@ -1,88 +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 "unittests/unittests.h"
-
-#include "const/utils/timer.h"
-
-#include "utils/timer.h"
-
-#include <climits>
-
-#include "debug.h"
-
-static const int MAX_TICK_VALUE = INT_MAX / 2;
-
-TEST_CASE("timer const", "")
-{
- REQUIRE(MILLISECONDS_IN_A_TICK != 0);
-}
-
-TEST_CASE("timer get_elapsed_time", "")
-{
- tick_time = 0;
- REQUIRE(get_elapsed_time(0) == 0);
- REQUIRE(get_elapsed_time(MAX_TICK_VALUE - 1) == 1 * MILLISECONDS_IN_A_TICK);
- REQUIRE(get_elapsed_time(MAX_TICK_VALUE - 2) == 2 * MILLISECONDS_IN_A_TICK);
-
- tick_time = 1;
- REQUIRE(get_elapsed_time(0) == 1 * MILLISECONDS_IN_A_TICK);
- REQUIRE(get_elapsed_time(1) == 0 * MILLISECONDS_IN_A_TICK);
- REQUIRE(get_elapsed_time(MAX_TICK_VALUE - 1) == 2 * MILLISECONDS_IN_A_TICK);
- REQUIRE(get_elapsed_time(MAX_TICK_VALUE - 2) == 3 * MILLISECONDS_IN_A_TICK);
-
- tick_time = 10;
- REQUIRE(get_elapsed_time(0) == 10 * MILLISECONDS_IN_A_TICK);
- REQUIRE(get_elapsed_time(10) == 0 * MILLISECONDS_IN_A_TICK);
- REQUIRE(get_elapsed_time(MAX_TICK_VALUE - 1) ==
- 11 * MILLISECONDS_IN_A_TICK);
-
- tick_time = 10000;
- REQUIRE(get_elapsed_time(0) == 10000 * MILLISECONDS_IN_A_TICK);
- REQUIRE(get_elapsed_time(10) == 9990 * MILLISECONDS_IN_A_TICK);
- REQUIRE(get_elapsed_time(10000) == 0 * MILLISECONDS_IN_A_TICK);
- REQUIRE(get_elapsed_time(MAX_TICK_VALUE - 1) ==
- 10001 * MILLISECONDS_IN_A_TICK);
-}
-
-TEST_CASE("timer get_elapsed_time1", "")
-{
- tick_time = 0;
- REQUIRE(get_elapsed_time1(0) == 0);
- REQUIRE(get_elapsed_time1(MAX_TICK_VALUE - 1) == 1);
- REQUIRE(get_elapsed_time1(MAX_TICK_VALUE - 2) == 2);
-
- tick_time = 1;
- REQUIRE(get_elapsed_time1(0) == 1);
- REQUIRE(get_elapsed_time1(1) == 0);
- REQUIRE(get_elapsed_time1(MAX_TICK_VALUE - 1) == 2);
- REQUIRE(get_elapsed_time1(MAX_TICK_VALUE - 2) == 3);
-
- tick_time = 10;
- REQUIRE(get_elapsed_time1(0) == 10);
- REQUIRE(get_elapsed_time1(10) == 0);
- REQUIRE(get_elapsed_time1(MAX_TICK_VALUE - 1) == 11);
-
- tick_time = 10000;
- REQUIRE(get_elapsed_time1(0) == 10000);
- REQUIRE(get_elapsed_time1(10) == 9990);
- REQUIRE(get_elapsed_time1(10000) == 0);
- REQUIRE(get_elapsed_time1(MAX_TICK_VALUE - 1) == 10001);
-}
diff --git a/src/unittests/utils/translation/poparser.cc b/src/unittests/utils/translation/poparser.cc
deleted file mode 100644
index 3e697582b..000000000
--- a/src/unittests/utils/translation/poparser.cc
+++ /dev/null
@@ -1,136 +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 "unittests/unittests.h"
-
-#include "client.h"
-#include "configuration.h"
-#include "configmanager.h"
-#include "dirs.h"
-#include "graphicsmanager.h"
-
-#include "being/actorsprite.h"
-
-#include "fs/virtfs/fs.h"
-
-#include "gui/gui.h"
-#include "gui/theme.h"
-
-#include "utils/delete2.h"
-#include "utils/env.h"
-
-#include "utils/translation/podict.h"
-#include "utils/translation/poparser.h"
-
-#include "render/sdlgraphics.h"
-
-#include "resources/sdlimagehelper.h"
-
-#include "debug.h"
-
-TEST_CASE("PoParser tests", "PoParser")
-{
- setEnv("SDL_VIDEODRIVER", "dummy");
-
- client = new Client;
- VirtFs::mountDirSilent("data", Append_false);
- VirtFs::mountDirSilent("../data", Append_false);
-
- mainGraphics = new SDLGraphics;
- imageHelper = new SDLImageHelper();
-
- Dirs::initRootDir();
- Dirs::initHomeDir();
-
- ConfigManager::initConfiguration();
- setConfigDefaults2(config);
- setBrandingDefaults(branding);
-
-#ifdef USE_SDL2
- SDLImageHelper::setRenderer(graphicsManager.createRenderer(
- graphicsManager.createWindow(640, 480, 0,
- SDL_WINDOW_SHOWN | SDL_SWSURFACE), SDL_RENDERER_SOFTWARE));
-#else // USE_SDL2
-
- graphicsManager.createWindow(640, 480, 0, SDL_ANYFORMAT | SDL_SWSURFACE);
-#endif // USE_SDL2
-
- theme = new Theme;
- Theme::selectSkin();
-
- ActorSprite::load();
- gui = new Gui();
- gui->postInit(mainGraphics);
-
- SECTION("PoParser empty")
- {
- PoParser *parser = new PoParser;
- PoDict *dict = parser->load("ru",
- "unknownfilename.po",
- nullptr);
-
- REQUIRE(dict != nullptr);
- REQUIRE(dict->getMap() != nullptr);
- REQUIRE(dict->getMap()->empty());
-
- delete parser;
- delete dict;
- }
-
- SECTION("PoParser normal")
- {
- PoParser *parser = new PoParser;
- PoDict *dict = parser->load("ru",
- "test/test1",
- nullptr);
-
- REQUIRE(dict != nullptr);
- REQUIRE(dict->getMap() != nullptr);
- REQUIRE(dict->getMap()->size() == 1786);
- REQUIRE(dict->getStr("Unknown skill message.") ==
- "Неизвестная ошибка скилов.");
- REQUIRE(dict->getStr("Full strip failed because of coating.") ==
- "Full strip failed because of coating.");
- REQUIRE(dict->getStr("You picked up %d [@@%d|%s@@].") ==
- "Вы подняли %d [@@%d|%s@@].");
-
- delete parser;
- delete dict;
- }
-
- SECTION("PoParser fuzzy")
- {
- PoParser *parser = new PoParser;
- PoDict *dict = parser->load("ru",
- "test/test1",
- nullptr);
-
- REQUIRE(dict != nullptr);
- REQUIRE(dict->getMap() != nullptr);
- REQUIRE(dict->getMap()->size() == 1786);
- REQUIRE(dict->getStr("Atk +100%.") == "Atk +100%.");
-
- delete parser;
- delete dict;
- }
- delete2(client);
- VirtFs::unmountDirSilent("data");
- VirtFs::unmountDirSilent("../data");
-}
diff --git a/src/unittests/utils/xml.cc b/src/unittests/utils/xml.cc
deleted file mode 100644
index 8605e0640..000000000
--- a/src/unittests/utils/xml.cc
+++ /dev/null
@@ -1,393 +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 "unittests/unittests.h"
-
-#include "client.h"
-#include "configuration.h"
-#include "configmanager.h"
-#include "dirs.h"
-#include "graphicsmanager.h"
-
-#include "being/actorsprite.h"
-
-#include "fs/virtfs/fs.h"
-
-#include "gui/gui.h"
-#include "gui/theme.h"
-
-#include "utils/delete2.h"
-#include "utils/env.h"
-#ifdef ENABLE_PUGIXML
-#include "utils/xmlwriter.h"
-#endif // ENABLE_PUGIXML
-
-#include "render/sdlgraphics.h"
-
-#include "resources/sdlimagehelper.h"
-
-#include "resources/resourcemanager/resourcemanager.h"
-
-#include "debug.h"
-
-TEST_CASE("xml test1", "")
-{
- REQUIRE(client == nullptr);
- REQUIRE(gui == nullptr);
- ResourceManager::cleanOrphans(true);
- ResourceManager::deleteInstance();
-}
-
-TEST_CASE("xml doc", "")
-{
- setEnv("SDL_VIDEODRIVER", "dummy");
-
- client = new Client;
- XML::initXML();
- VirtFs::mountDirSilent("data", Append_false);
- VirtFs::mountDirSilent("../data", Append_false);
- mainGraphics = new SDLGraphics;
- imageHelper = new SDLImageHelper();
-
- Dirs::initRootDir();
- Dirs::initHomeDir();
-
- ConfigManager::initConfiguration();
- setConfigDefaults2(config);
- setBrandingDefaults(branding);
-
-#ifdef USE_SDL2
- SDLImageHelper::setRenderer(graphicsManager.createRenderer(
- graphicsManager.createWindow(640, 480, 0,
- SDL_WINDOW_SHOWN | SDL_SWSURFACE), SDL_RENDERER_SOFTWARE));
-#else // USE_SDL2
-
- graphicsManager.createWindow(640, 480, 0, SDL_ANYFORMAT | SDL_SWSURFACE);
-#endif // USE_SDL2
-
- theme = new Theme;
- Theme::selectSkin();
-
- const char *const tempXmlName = "tempxml.xml";
- ActorSprite::load();
- gui = new Gui();
- gui->postInit(mainGraphics);
-
- SECTION("load1")
- {
- XML::Document doc("graphics/gui/browserbox.xml",
- UseVirtFs_true,
- SkipError_false);
- REQUIRE(doc.isLoaded() == true);
- REQUIRE(doc.isValid() == true);
- REQUIRE(doc.rootNode() != nullptr);
- REQUIRE(xmlNameEqual(doc.rootNode(), "skinset") == true);
- REQUIRE(xmlNameEqual(doc.rootNode(), "skinset123") == false);
- REQUIRE(xmlTypeEqual(doc.rootNode(), XML_ELEMENT_NODE) == true);
-// REQUIRE(XmlHaveChildContent(doc.rootNode()) == true);
- }
-
- SECTION("load2")
- {
- const char *const xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
- "<root><data option1=\"false\" option2=\"true\"/>"
- "<cont>this is test</cont></root>";
- XML::Document doc(xml, strlen(xml));
- REQUIRE(doc.isLoaded() == true);
- REQUIRE(doc.isValid() == true);
- REQUIRE(doc.rootNode() != nullptr);
- REQUIRE(xmlNameEqual(doc.rootNode(), "root") == true);
- REQUIRE(xmlNameEqual(doc.rootNode(), "root123") == false);
- REQUIRE(xmlTypeEqual(doc.rootNode(), XML_ELEMENT_NODE) == true);
- REQUIRE(XmlHasProp(doc.rootNode(), "option1") == false);
- REQUIRE(XmlHasProp(doc.rootNode(), "option123") == false);
- REQUIRE(XmlHaveChildContent(doc.rootNode()) == false);
- }
-
- SECTION("load3")
- {
- const std::string xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
- "<!-- comment here\nand here -->"
- "<root><data option1=\"false\" option2=\"true\"/></root>";
- XML::Document doc(xml.c_str(), xml.size());
- REQUIRE(doc.isLoaded() == true);
- REQUIRE(doc.isValid() == true);
- REQUIRE(doc.rootNode() != nullptr);
- REQUIRE(xmlNameEqual(doc.rootNode(), "root") == true);
- REQUIRE(xmlNameEqual(doc.rootNode(), "root123") == false);
- REQUIRE(xmlTypeEqual(doc.rootNode(), XML_ELEMENT_NODE) == true);
- REQUIRE(XmlHasProp(doc.rootNode(), "option1") == false);
- REQUIRE(XmlHasProp(doc.rootNode(), "option123") == false);
- REQUIRE(XmlHaveChildContent(doc.rootNode()) == false);
- }
-
- SECTION("load4")
- {
- const char *const xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
- "<root>this is test</root>";
- XML::Document doc(xml, strlen(xml));
- REQUIRE(doc.isLoaded() == true);
- REQUIRE(doc.isValid() == true);
- REQUIRE(doc.rootNode() != nullptr);
- REQUIRE(xmlNameEqual(doc.rootNode(), "root") == true);
- REQUIRE(xmlNameEqual(doc.rootNode(), "root123") == false);
- REQUIRE(xmlTypeEqual(doc.rootNode(), XML_ELEMENT_NODE) == true);
- REQUIRE(XmlHasProp(doc.rootNode(), "option1") == false);
- REQUIRE(XmlHasProp(doc.rootNode(), "option123") == false);
- REQUIRE(XmlHaveChildContent(doc.rootNode()) == true);
- REQUIRE(!strcmp(XmlChildContent(doc.rootNode()), "this is test"));
- }
-
- SECTION("properties")
- {
- XML::Document doc("graphics/gui/browserbox.xml",
- UseVirtFs_true,
- SkipError_false);
-
- XmlNodeConstPtr rootNode = doc.rootNode();
- REQUIRE(XML::getProperty(rootNode, "image", "") == "window.png");
- }
-
- SECTION("for each")
- {
- XML::Document doc("graphics/gui/browserbox.xml",
- UseVirtFs_true,
- SkipError_false);
-
- XmlNodeConstPtr rootNode = doc.rootNode();
-// REQUIRE(XmlHaveChildContent(rootNode) == true);
- XmlNodePtr node = XmlNodeDefault;
- for_each_xml_child_node(widgetNode, rootNode)
- {
- node = widgetNode;
- if (xmlNameEqual(node, "widget"))
- break;
- }
- REQUIRE(node != nullptr);
- REQUIRE(xmlTypeEqual(node, XML_ELEMENT_NODE) == true);
- REQUIRE(xmlNameEqual(node, "widget") == true);
-// REQUIRE(XmlHaveChildContent(node) == true);
- for_each_xml_child_node(optionNode, node)
- {
- node = optionNode;
- if (xmlNameEqual(node, "option"))
- break;
- }
- REQUIRE(node != nullptr);
- REQUIRE(xmlTypeEqual(node, XML_ELEMENT_NODE) == true);
- REQUIRE(xmlNameEqual(node, "option") == true);
- REQUIRE(XmlHaveChildContent(node) == false);
- REQUIRE(XmlHasProp(node, "name") == true);
- REQUIRE(XmlHasProp(node, "value") == true);
- REQUIRE(XmlHasProp(node, "option123") == false);
- REQUIRE(XML::getProperty(node, "name", "") == "padding");
- REQUIRE(XML::langProperty(node, "name", "") == "padding");
- REQUIRE(XML::getProperty(node, "value", 0) == 1);
- REQUIRE(XML::getBoolProperty(node, "value", true) == true);
- REQUIRE(XML::getBoolProperty(node, "value", false) == false);
- REQUIRE(XML::getIntProperty(node, "value", -1, -10, 100) == 1);
- }
-
- SECTION("child1")
- {
- XML::Document doc("graphics/gui/browserbox.xml",
- UseVirtFs_true,
- SkipError_false);
-
- XmlNodeConstPtr rootNode = doc.rootNode();
- XmlNodePtr node = XML::findFirstChildByName(rootNode, "widget");
- REQUIRE(node != nullptr);
- REQUIRE(xmlTypeEqual(node, XML_ELEMENT_NODE) == true);
- REQUIRE(xmlNameEqual(node, "widget") == true);
-// REQUIRE(XmlHaveChildContent(node) == true);
- node = XML::findFirstChildByName(node, "option");
- REQUIRE(node != nullptr);
- REQUIRE(xmlTypeEqual(node, XML_ELEMENT_NODE) == true);
- REQUIRE(xmlNameEqual(node, "option") == true);
- REQUIRE(XmlHaveChildContent(node) == false);
- REQUIRE(XmlHasProp(node, "name") == true);
- REQUIRE(XmlHasProp(node, "value") == true);
- REQUIRE(XmlHasProp(node, "option123") == false);
- REQUIRE(XML::getProperty(node, "name", "") == "padding");
- REQUIRE(XML::langProperty(node, "name", "") == "padding");
- REQUIRE(XML::langProperty(node, "name123", "").empty());
- REQUIRE(XML::getProperty(node, "value", 0) == 1);
- REQUIRE(XML::getProperty(node, "value123", -1) == -1);
- REQUIRE(XML::getBoolProperty(node, "value", true) == true);
- REQUIRE(XML::getBoolProperty(node, "value", false) == false);
- REQUIRE(XML::getBoolProperty(node, "value123", true) == true);
- REQUIRE(XML::getIntProperty(node, "value", -1, -10, 100) == 1);
- REQUIRE(XML::getIntProperty(node, "value123", -1, -10, 100) == -1);
- }
-
- SECTION("child2")
- {
- const char *const xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
- "<root><data option1=\"false\" option2=\"true\" "
- "option3=\"10.5\"/></root>";
- XML::Document doc(xml, strlen(xml));
- XmlNodeConstPtr rootNode = doc.rootNode();
- REQUIRE(XmlHaveChildContent(rootNode) == false);
- XmlNodePtr node = XML::findFirstChildByName(rootNode, "data");
- REQUIRE(node != nullptr);
- REQUIRE(xmlTypeEqual(node, XML_ELEMENT_NODE) == true);
- REQUIRE(xmlNameEqual(node, "data") == true);
- REQUIRE(XmlHaveChildContent(node) == false);
- REQUIRE(XmlHasProp(node, "option1") == true);
- REQUIRE(XmlHasProp(node, "option123") == false);
- REQUIRE(XML::getBoolProperty(node, "option1", true) == false);
- REQUIRE(XML::getBoolProperty(node, "option2", false) == true);
- const float opt3 = XML::getFloatProperty(node, "option3", 0.0);
- REQUIRE(opt3 > 10);
- REQUIRE(opt3 < 11);
- }
-
- SECTION("child3")
- {
- const std::string xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
- "<!-- comment --><root><!-- comment -->"
- "<data option1=\"false\" option2=\"true\" "
- "option3=\"10.5\"/><!-- comment --></root>";
- XML::Document doc(xml.c_str(), xml.size());
- XmlNodeConstPtr rootNode = doc.rootNode();
-// REQUIRE(XmlHaveChildContent(rootNode) == true);
- XmlNodePtr node = XML::findFirstChildByName(rootNode, "data");
- REQUIRE(node != nullptr);
- REQUIRE(xmlTypeEqual(node, XML_ELEMENT_NODE) == true);
- REQUIRE(xmlNameEqual(node, "data") == true);
- REQUIRE(XmlHaveChildContent(node) == false);
- REQUIRE(XmlHasProp(node, "option1") == true);
- REQUIRE(XmlHasProp(node, "option123") == false);
- REQUIRE(XML::getBoolProperty(node, "option1", true) == false);
- REQUIRE(XML::getBoolProperty(node, "option2", false) == true);
- const float opt3 = XML::getFloatProperty(node, "option3", 0.0);
- REQUIRE(opt3 > 10);
- REQUIRE(opt3 < 11);
- }
-
- SECTION("validate")
- {
-// REQUIRE(XML::Document::validateXml(
-// "graphics/gui/browserbox.xml") == true);
- REQUIRE(XML::Document::validateXml(
- "graphics/gui/bubble.png") == false);
- REQUIRE(XML::Document::validateXml(
- "graphics/gui/testfile123.xml") == false);
- }
-
- SECTION("save1")
- {
- // clean
- ::remove(tempXmlName);
-
- // save
- FILE *const testFile = fopen(tempXmlName, "w");
- REQUIRE(testFile);
- fclose(testFile);
- XmlTextWriterPtr writer = XmlNewTextWriterFilename(
- tempXmlName,
- 0);
- XmlTextWriterSetIndent(writer, 1);
- XmlTextWriterStartDocument(writer, nullptr, nullptr, nullptr);
- XmlTextWriterStartRootElement(writer, "root");
- XmlTextWriterEndDocument(writer);
- XmlSaveTextWriterFilename(writer, tempXmlName);
- XmlFreeTextWriter(writer);
-
- // load
- XML::Document doc(tempXmlName,
- UseVirtFs_false,
- SkipError_false);
- REQUIRE(doc.isLoaded() == true);
- REQUIRE(doc.isValid() == true);
- REQUIRE(doc.rootNode() != nullptr);
- REQUIRE(xmlNameEqual(doc.rootNode(), "root") == true);
- REQUIRE(xmlNameEqual(doc.rootNode(), "skinset123") == false);
- REQUIRE(xmlTypeEqual(doc.rootNode(), XML_ELEMENT_NODE) == true);
-// REQUIRE(XmlHaveChildContent(doc.rootNode()) == true);
-
- // clean again
- ::remove(tempXmlName);
- }
-
- SECTION("save2")
- {
- // clean
- ::remove(tempXmlName);
-
- // save
- FILE *const testFile = fopen(tempXmlName, "w");
- REQUIRE(testFile);
- fclose(testFile);
- XmlTextWriterPtr writer = XmlNewTextWriterFilename(
- tempXmlName,
- 0);
- XmlTextWriterSetIndent(writer, 1);
- XmlTextWriterStartDocument(writer, nullptr, nullptr, nullptr);
- XmlTextWriterStartRootElement(writer, "root");
-
- XmlTextWriterStartElement(writer, "option");
- XmlTextWriterWriteAttribute(writer, "name", "the name");
- XmlTextWriterWriteAttribute(writer, "value", "the value");
- XmlTextWriterEndElement(writer);
-
- XmlTextWriterEndDocument(writer);
- XmlSaveTextWriterFilename(writer, tempXmlName);
- XmlFreeTextWriter(writer);
-
- // load
- XML::Document doc(tempXmlName,
- UseVirtFs_false,
- SkipError_false);
- REQUIRE(doc.isLoaded() == true);
- REQUIRE(doc.isValid() == true);
- REQUIRE(doc.rootNode() != nullptr);
- REQUIRE(xmlNameEqual(doc.rootNode(), "root") == true);
- REQUIRE(xmlNameEqual(doc.rootNode(), "skinset123") == false);
- REQUIRE(xmlTypeEqual(doc.rootNode(), XML_ELEMENT_NODE) == true);
-// REQUIRE(XmlHaveChildContent(doc.rootNode()) == true);
- XmlNodePtr node = XML::findFirstChildByName(doc.rootNode(), "option");
- REQUIRE(node != nullptr);
- REQUIRE(xmlTypeEqual(node, XML_ELEMENT_NODE) == true);
- REQUIRE(xmlNameEqual(node, "option") == true);
- REQUIRE(XmlHaveChildContent(node) == false);
- REQUIRE(XmlHasProp(node, "name") == true);
- REQUIRE(XmlHasProp(node, "value") == true);
- REQUIRE(XmlHasProp(node, "option123") == false);
- REQUIRE(XML::getProperty(node, "name", "") == "the name");
- REQUIRE(XML::getProperty(node, "value", "") == "the value");
-
- // clean again
- ::remove(tempXmlName);
- }
-
- delete2(theme);
- delete2(client);
- ResourceManager::deleteInstance();
- VirtFs::unmountDirSilent("data");
- VirtFs::unmountDirSilent("../data");
-}
-
-TEST_CASE("xml test2", "")
-{
- REQUIRE(gui == nullptr);
- ResourceManager::cleanOrphans(true);
- ResourceManager::deleteInstance();
-}
diff --git a/src/unittests/utils/xmlutils.cc b/src/unittests/utils/xmlutils.cc
deleted file mode 100644
index 23df65a10..000000000
--- a/src/unittests/utils/xmlutils.cc
+++ /dev/null
@@ -1,225 +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 "unittests/unittests.h"
-
-#include "client.h"
-#include "configmanager.h"
-#include "configuration.h"
-#include "dirs.h"
-#include "graphicsmanager.h"
-
-#include "being/actorsprite.h"
-
-#include "fs/virtfs/fs.h"
-
-#include "gui/userpalette.h"
-#include "gui/theme.h"
-
-#include "utils/delete2.h"
-#include "utils/env.h"
-#include "utils/xmlutils.h"
-
-#include "render/sdlgraphics.h"
-
-#include "resources/resourcemanager/resourcemanager.h"
-
-#include "resources/sdlimagehelper.h"
-
-#include "debug.h"
-
-TEST_CASE("xmlutils readXmlIntVector 1", "")
-{
- setEnv("SDL_VIDEODRIVER", "dummy");
-
- client = new Client;
- XML::initXML();
- VirtFs::mountDirSilent("data", Append_false);
- VirtFs::mountDirSilent("../data", Append_false);
-
- mainGraphics = new SDLGraphics;
- imageHelper = new SDLImageHelper();
-
- Dirs::initHomeDir();
-
- setBrandingDefaults(branding);
- ConfigManager::initConfiguration();
-
-#ifdef USE_SDL2
- SDLImageHelper::setRenderer(graphicsManager.createRenderer(
- graphicsManager.createWindow(640, 480, 0,
- SDL_WINDOW_SHOWN | SDL_SWSURFACE), SDL_RENDERER_SOFTWARE));
-#else // USE_SDL2
-
- graphicsManager.createWindow(640, 480, 0, SDL_ANYFORMAT | SDL_SWSURFACE);
-#endif // USE_SDL2
-
- userPalette = new UserPalette;
-
- Dirs::initRootDir();
- theme = new Theme;
- Theme::selectSkin();
-
- ActorSprite::load();
-
- STD_VECTOR<int> arr;
-
- readXmlIntVector("graphics/gui/browserbox.xml",
- "skinset",
- "widget",
- "option",
- "value",
- arr,
- SkipError_false);
-
- REQUIRE(5 == arr.size());
- REQUIRE(1 == arr[0]);
- REQUIRE(15 == arr[1]);
- REQUIRE(0 == arr[2]);
- REQUIRE(1 == arr[3]);
- REQUIRE(1 == arr[4]);
-
- delete2(userPalette);
- delete2(theme);
- delete2(client);
- ResourceManager::deleteInstance();
- VirtFs::unmountDirSilent("data");
- VirtFs::unmountDirSilent("../data");
-}
-
-TEST_CASE("xmlutils readXmlStringMap 1", "")
-{
- setEnv("SDL_VIDEODRIVER", "dummy");
-
- client = new Client;
- XML::initXML();
- VirtFs::mountDirSilent("data", Append_false);
- VirtFs::mountDirSilent("../data", Append_false);
-
- mainGraphics = new SDLGraphics;
- imageHelper = new SDLImageHelper();
-
- Dirs::initRootDir();
- Dirs::initHomeDir();
-
- setBrandingDefaults(branding);
- ConfigManager::initConfiguration();
-
-#ifdef USE_SDL2
- SDLImageHelper::setRenderer(graphicsManager.createRenderer(
- graphicsManager.createWindow(640, 480, 0,
- SDL_WINDOW_SHOWN | SDL_SWSURFACE), SDL_RENDERER_SOFTWARE));
-#else // USE_SDL2
-
- graphicsManager.createWindow(640, 480, 0, SDL_ANYFORMAT | SDL_SWSURFACE);
-#endif // USE_SDL2
-
- userPalette = new UserPalette;
-
- theme = new Theme;
- Theme::selectSkin();
-
- ActorSprite::load();
-
- std::map<std::string, std::string> arr;
-
- readXmlStringMap("graphics/sprites/manaplus_emotes.xml",
- "emotes",
- "emote",
- "sprite",
- "name",
- "variant",
- arr,
- SkipError_false);
-
- REQUIRE(arr.size() == 27);
- REQUIRE(arr["Kitty"] == "0");
- REQUIRE(arr["xD"] == "1");
- REQUIRE(arr["Metal"] == "26");
-
- delete2(userPalette);
- delete2(theme);
- delete2(client);
- ResourceManager::deleteInstance();
- VirtFs::unmountDirSilent("data");
- VirtFs::unmountDirSilent("../data");
-}
-
-TEST_CASE("xmlutils readXmlIntMap 1", "")
-{
- setEnv("SDL_VIDEODRIVER", "dummy");
-
- client = new Client;
- XML::initXML();
- VirtFs::mountDirSilent("data", Append_false);
- VirtFs::mountDirSilent("../data", Append_false);
- VirtFs::mountDirSilent("data/test", Append_false);
- VirtFs::mountDirSilent("../data/test", Append_false);
-
- mainGraphics = new SDLGraphics;
- imageHelper = new SDLImageHelper();
-
- Dirs::initRootDir();
- Dirs::initHomeDir();
-
- setBrandingDefaults(branding);
- ConfigManager::initConfiguration();
-
-#ifdef USE_SDL2
- SDLImageHelper::setRenderer(graphicsManager.createRenderer(
- graphicsManager.createWindow(640, 480, 0,
- SDL_WINDOW_SHOWN | SDL_SWSURFACE), SDL_RENDERER_SOFTWARE));
-#else // USE_SDL2
-
- graphicsManager.createWindow(640, 480, 0, SDL_ANYFORMAT | SDL_SWSURFACE);
-#endif // USE_SDL2
-
- userPalette = new UserPalette;
-
- theme = new Theme;
- Theme::selectSkin();
-
- ActorSprite::load();
-
- std::map<int32_t, int32_t> arr;
-
- readXmlIntMap("testintmap.xml",
- "tests",
- "sub",
- "item",
- "id",
- "val",
- arr,
- SkipError_false);
-
- REQUIRE(arr.size() == 3);
- REQUIRE(arr[1] == 2);
- REQUIRE(arr[10] == 20);
- REQUIRE(arr[3] == 0);
-
- delete2(userPalette);
- delete2(theme);
- delete2(client);
- ResourceManager::deleteInstance();
- VirtFs::unmountDirSilent("data/test");
- VirtFs::unmountDirSilent("../data/test");
- VirtFs::unmountDirSilent("data");
- VirtFs::unmountDirSilent("../data");
-}
diff --git a/src/utils/base64.cpp b/src/utils/base64.cpp
deleted file mode 100644
index 62ba76f21..000000000
--- a/src/utils/base64.cpp
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2000 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | This program is distributed in the hope that it will be useful, |
- | but WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- | GNU General Public License for more details. |
- | |
- | You should have received a copy of both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Author: Jim Winstead (jimw@php.net) |
- +----------------------------------------------------------------------+
- */
-
-#include "utils/base64.h"
-
-#include "utils/cast.h"
-
-#include "debug.h"
-
-static char base64_table[] =
-{
- 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
- 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
- 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
- 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
- '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/', '\0'
-};
-static const char base64_pad = '=';
-
-unsigned char *php3_base64_encode(const unsigned char *restrict const string,
- int length,
- int *restrict const ret_length)
-{
- if (string == nullptr)
- return nullptr;
- const unsigned char *current = string;
- int i = 0;
- unsigned char *const result = static_cast<unsigned char *>(
- calloc(CAST_SIZE((length + 3 - length % 3) * 4 / 3 + 1)
- * sizeof(unsigned char), 1));
- if (result == nullptr)
- return nullptr;
-
- while (length > 2)
- { /* keep going until we have less than 24 bits */
- result[i++] = base64_table[current[0] >> 2];
- result[i++] = base64_table[((current[0] & 0x03)
- << 4) + (current[1] >> 4)];
- result[i++] = base64_table[((current[1] & 0x0f)
- << 2) + (current[2] >> 6)];
- result[i++] = base64_table[current[2] & 0x3f];
-
- current += 3;
- length -= 3; /* we just handle 3 octets of data */
- }
-
- /* now deal with the tail end of things */
- if (length != 0)
- {
- result[i++] = base64_table[current[0] >> 2];
- if (length > 1)
- {
- result[i++] = base64_table[((current[0] & 0x03) << 4)
- + (current[1] >> 4)];
- result[i++] = base64_table[(current[1] & 0x0f) << 2];
- result[i++] = base64_pad;
- }
- else
- {
- result[i++] = base64_table[(current[0] & 0x03) << 4];
- result[i++] = base64_pad;
- result[i++] = base64_pad;
- }
- }
- if (ret_length != nullptr)
- {
- *ret_length = i;
- }
- result[i] = '\0';
- return result;
-}
-
-/* as above, but backwards. :) */
-unsigned char *php3_base64_decode(const unsigned char *restrict const string,
- const int length,
- int *restrict const ret_length)
-{
- const unsigned char *current = string;
- int ch, i = 0, j = 0, k;
-
- unsigned char *result = static_cast<unsigned char *>(
- calloc(length + 1, 1));
-
- if (result == nullptr)
- return nullptr;
-
- /* run through the whole string, converting as we go */
- while ((ch = *current++) != '\0')
- {
- if (ch == base64_pad)
- break;
-
- /* When Base64 gets POSTed, all pluses are interpreted as spaces.
- This line changes them back. It's not exactly the Base64 spec,
- but it is completely compatible with it (the spec says that
- spaces are invalid). This will also save many people considerable
- headache. - Turadg Aleahmad <turadg@wise.berkeley.edu>
- */
-
- if (ch == ' ') ch = '+';
-
- const char *const chp = strchr(base64_table, ch);
- if (chp == nullptr)
- continue;
- ch = CAST_S32(chp - base64_table);
-
- switch (i % 4)
- {
- case 0:
- result[j] = CAST_U8(ch << 2U);
- break;
- case 1:
- result[j++] |= CAST_U8(ch >> 4U);
- result[j] = CAST_U8((ch & 0x0f) << 4U);
- break;
- case 2:
- result[j++] |= CAST_U8(ch >>2U);
- result[j] = CAST_U8((ch & 0x03) << 6U);
- break;
- case 3:
- result[j++] |= CAST_U8(ch);
- break;
- default:
- break;
- }
- i++;
- }
-
- k = j;
- /* mop things up if we ended on a boundary */
- if (ch == base64_pad)
- {
- switch (i % 4)
- {
- case 0:
- case 1:
- free(result);
- return nullptr;
- case 2:
- k++;
- // copy from 3. is it should be here?
- result[k++] = 0;
- break;
- case 3:
- result[k++] = 0;
- break;
- default:
- break;
- }
- }
- if (ret_length != nullptr)
- {
- *ret_length = j;
- }
- result[k] = '\0';
- return result;
-}
-
-std::string encodeBase64String(std::string value)
-{
- int sz = 0;
- const unsigned char *const str = reinterpret_cast<unsigned char*>(
- const_cast<char*>(value.c_str()));
- unsigned char *const buf = php3_base64_encode(
- str, CAST_S32(value.size()), &sz);
- if (buf == nullptr)
- return std::string();
-
- value = std::string(reinterpret_cast<char*>(buf), sz);
- free(buf);
- return value;
-}
-
-std::string decodeBase64String(std::string value)
-{
- int sz = 0;
- const unsigned char *const str = reinterpret_cast<unsigned char*>(
- const_cast<char*>(value.c_str()));
- unsigned char *const buf = php3_base64_decode(
- str, CAST_S32(value.size()), &sz);
-
- if (buf != nullptr)
- value = std::string(reinterpret_cast<char*>(buf), sz);
- else
- value.clear();
- free(buf);
- return value;
-}
diff --git a/src/utils/base64.h b/src/utils/base64.h
deleted file mode 100644
index 4518a3e5a..000000000
--- a/src/utils/base64.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
- +----------------------------------------------------------------------+
- | This program is free software; you can redistribute it and/or modify |
- | it under the terms of one of the following licenses: |
- | |
- | A) the GNU General Public License as published by the Free Software |
- | Foundation; either version 2 of the License, or (at your option) |
- | any later version. |
- | |
- | B) the PHP License as published by the PHP Development Team and |
- | included in the distribution in the file: LICENSE |
- | |
- | This program is distributed in the hope that it will be useful, |
- | but WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- | GNU General Public License for more details. |
- | |
- | You should have received a copy of both licenses referred to here. |
- | If you did not, or have any questions about PHP licensing, please |
- | contact core@php.net. |
- +----------------------------------------------------------------------+
- | Author: Jim Winstead (jimw@php.net) |
- +----------------------------------------------------------------------+
- */
-
-#ifndef UTILS_BASE64_H
-#define UTILS_BASE64_H
-
-#include <string>
-
-#include "localconsts.h"
-
-unsigned char *php3_base64_encode(const unsigned char *restrict,
- int, int *restrict) A_WARN_UNUSED;
-unsigned char *php3_base64_decode(const unsigned char *restrict,
- int, int *restrict ) A_WARN_UNUSED;
-
-std::string encodeBase64String(std::string value) A_WARN_UNUSED;
-
-std::string decodeBase64String(std::string value) A_WARN_UNUSED;
-
-#endif // UTILS_BASE64_H
diff --git a/src/utils/booleanoptions.h b/src/utils/booleanoptions.h
deleted file mode 100644
index cd9f97862..000000000
--- a/src/utils/booleanoptions.h
+++ /dev/null
@@ -1,32 +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 UTILS_BOOLEANOPTIONS_H
-#define UTILS_BOOLEANOPTIONS_H
-
-#include "utils/gettext.h"
-
-UTILS_GETTEXT_H
-
-// TRANSLATORS: chat option changed message
-#define BOOLEAN_OPTIONS _("Options to /%s are \"yes\", \"no\", \"true\", "\
-"\"false\", \"1\", \"0\".")
-
-#endif // UTILS_BOOLEANOPTIONS_H
diff --git a/src/utils/browserboxtools.cpp b/src/utils/browserboxtools.cpp
deleted file mode 100644
index 10113e220..000000000
--- a/src/utils/browserboxtools.cpp
+++ /dev/null
@@ -1,169 +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 "utils/browserboxtools.h"
-
-#include "itemcolormanager.h"
-#include "main.h"
-#include "settings.h"
-
-#include "input/inputmanager.h"
-
-#include "utils/stringutils.h"
-
-#ifndef DYECMD
-#include "const/resources/item/cards.h"
-
-#include "resources/beinginfo.h"
-#include "resources/iteminfo.h"
-
-#include "resources/db/homunculusdb.h"
-#include "resources/db/itemdb.h"
-#include "resources/db/mercenarydb.h"
-#include "resources/db/monsterdb.h"
-#include "resources/db/questdb.h"
-#include "resources/db/petdb.h"
-#endif // DYECMD
-
-#include "debug.h"
-
-void BrowserBoxTools::replaceVars(std::string &data)
-{
- data = replaceAll(data, "%VER%", SMALL_VERSION);
- data = replaceAll(data, "%SUPPORTURL%", settings.supportUrl);
-}
-
-void BrowserBoxTools::replaceKeys(std::string &data)
-{
- size_t idx1 = data.find("###");
- while (idx1 != std::string::npos)
- {
- const size_t idx2 = data.find(';', idx1);
- if (idx2 == std::string::npos)
- break;
-
- const std::string str = inputManager.getKeyValueByNameLong(
- data.substr(idx1 + 3, idx2 - idx1 - 3));
- data.replace(idx1, idx2 - idx1 + 1, str);
-
- idx1 = data.find("###");
- }
-}
-
-std::string BrowserBoxTools::replaceLinkCommands(const std::string &link)
-{
-#ifdef DYECMD
- return link;
-#else // DYECMD
-
- std::string data = link;
-
- if (strStartWith(data, "http://") ||
- strStartWith(data, "https://"))
- {
- return data;
- }
-
- if (!link.empty() && link[0] == 'm')
- { // monster link
- const BeingTypeId id = static_cast<BeingTypeId>(
- atoi(link.substr(1).c_str()));
- BeingInfo *const info = MonsterDB::get(id);
- if (info != nullptr)
- data = info->getName();
- }
- else if (!link.empty() && link[0] == 'p')
- { // pet link
- const BeingTypeId id = static_cast<BeingTypeId>(
- atoi(link.substr(1).c_str()));
- BeingInfo *const info = PETDB::get(id);
- if (info != nullptr)
- data = info->getName();
- }
- else if (!link.empty() && link[0] == 'h')
- { // homunculus link
- const BeingTypeId id = static_cast<BeingTypeId>(
- atoi(link.substr(1).c_str()));
- BeingInfo *const info = HomunculusDB::get(id);
- if (info != nullptr)
- data = info->getName();
- }
- else if (!link.empty() && link[0] == 'M')
- { // mercenary link
- const BeingTypeId id = static_cast<BeingTypeId>(
- atoi(link.substr(1).c_str()));
- BeingInfo *const info = MercenaryDB::get(id);
- if (info != nullptr)
- data = info->getName();
- }
- else if (!link.empty() && link[0] == 'q')
- { // quest link
- data = QuestDb::getName(
- atoi(link.substr(1).c_str()));
- }
- else
- { // item link
- size_t idx = link.find(',');
- if (idx != std::string::npos)
- {
- const int id = atoi(link.substr(0, idx).c_str());
- if (id != 0)
- {
- STD_VECTOR<int> parts;
- splitToIntVector(parts,
- link.substr(idx), ',');
- while (parts.size() < maxCards)
- parts.push_back(0);
- const ItemColor itemColor =
- ItemColorManager::getColorFromCards(&parts[0]);
- data = ItemDB::get(id).getName(itemColor);
- }
- }
- else
- {
- const int id = atoi(link.c_str());
- if (id != 0)
- data = ItemDB::get(id).getName();
- }
- }
- return data;
-#endif // DYECMD
-}
-
-void BrowserBoxTools::replaceTabs(std::string &data)
-{
- size_t idx1 = data.find("\\t");
- while (idx1 != std::string::npos)
- {
- const size_t idx2 = data.find(';', idx1);
- if (idx2 == std::string::npos)
- break;
-
- const unsigned int newSize = CAST_U32(
- atoi(data.substr(
- idx1 + 2, idx2 - idx1 - 2).c_str()));
- std::string str = data.substr(0, idx1);
- while (str.size() < newSize)
- str.append(" ");
- str.append(data.substr(idx2 + 1));
- data = str;
- idx1 = data.find("\\t");
- }
-}
diff --git a/src/utils/browserboxtools.h b/src/utils/browserboxtools.h
deleted file mode 100644
index 8caa0d89c..000000000
--- a/src/utils/browserboxtools.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 UTILS_BROWSERBOXTOOLS_H
-#define UTILS_BROWSERBOXTOOLS_H
-
-#include <string>
-
-#include "localconsts.h"
-
-namespace BrowserBoxTools
-{
- void replaceVars(std::string &data);
-
- void replaceKeys(std::string &data);
-
- std::string replaceLinkCommands(const std::string &link);
-
- void replaceTabs(std::string &data);
-} // namespace BrowserBoxTools
-
-#endif // UTILS_BROWSERBOXTOOLS_H
diff --git a/src/utils/buildhex.h b/src/utils/buildhex.h
deleted file mode 100644
index 6833e9528..000000000
--- a/src/utils/buildhex.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 UTILS_BUILDHEX_H
-#define UTILS_BUILDHEX_H
-
-#include "utils/cast.h"
-
-#include "localconsts.h"
-
-UTILS_CAST_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)
-
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
-#define buildHex(a, b, c, d) \
- (d) * 16777216U + (c) * 65536U + (b) * 256U + CAST_U32(a)
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-#define buildHex(a, b, c, d) \
- (a) * 16777216U + (b) * 65536U + (c) * 256U + CAST_U32(d)
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
-#define buildHexOgl(a, b, c, d) \
- (a) * 16777216U + (b) * 65536U + (c) * 256U + CAST_U32(d)
-
-#endif // UTILS_BUILDHEX_H
diff --git a/src/utils/cast.h b/src/utils/cast.h
deleted file mode 100644
index f12f1badb..000000000
--- a/src/utils/cast.h
+++ /dev/null
@@ -1,35 +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 UTILS_CAST_H
-#define UTILS_CAST_H
-
-#define CAST_8 static_cast<char>
-#define CAST_S8 static_cast<int8_t>
-#define CAST_U8 static_cast<uint8_t>
-#define CAST_S16 static_cast<int16_t>
-#define CAST_U16 static_cast<uint16_t>
-#define CAST_S32 static_cast<int32_t>
-#define CAST_U32 static_cast<uint32_t>
-#define CAST_S64 static_cast<int64_t>
-#define CAST_U64 static_cast<uint64_t>
-#define CAST_SIZE static_cast<size_t>
-
-#endif // UTILS_CAST_H
diff --git a/src/utils/chatutils.cpp b/src/utils/chatutils.cpp
deleted file mode 100644
index cb264dff1..000000000
--- a/src/utils/chatutils.cpp
+++ /dev/null
@@ -1,201 +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 "utils/chatutils.h"
-
-#include "actormanager.h"
-#include "party.h"
-
-#include "being/localplayer.h"
-
-#include "const/gui/chat.h"
-
-#include "gui/widgets/tabs/chat/whispertab.h"
-
-#include "net/chathandler.h"
-#include "net/guildhandler.h"
-#include "net/partyhandler.h"
-
-#ifdef TMWA_SUPPORT
-#include "net/net.h"
-
-#include "net/tmwa/guildmanager.h"
-#endif // TMWA_SUPPORT
-
-#include "utils/foreach.h"
-#include "utils/stringutils.h"
-
-#include "debug.h"
-
-void outStringNormal(ChatTab *const tab,
- const std::string &str,
- const std::string &def)
-{
- if (localPlayer == nullptr)
- return;
-
- if (tab == nullptr)
- {
- chatHandler->talk(str, GENERAL_CHANNEL);
- return;
- }
-
- switch (tab->getType())
- {
- case ChatTabType::PARTY:
- {
- partyHandler->chat(str);
- break;
- }
- case ChatTabType::GUILD:
- {
- const Guild *const guild = localPlayer->getGuild();
- if (guild != nullptr)
- {
-#ifdef TMWA_SUPPORT
- if (guild->getServerGuild())
- {
- if (Net::getNetworkType() == ServerType::TMWATHENA)
- return;
- guildHandler->chat(str);
- }
- else if (guildManager != nullptr)
- {
- guildManager->chat(str);
- }
-#else // TMWA_SUPPORT
-
- if (guild->getServerGuild())
- guildHandler->chat(str);
-#endif // TMWA_SUPPORT
- }
- break;
- }
- case ChatTabType::WHISPER:
- {
- const WhisperTab *const whisper
- = static_cast<const WhisperTab *>(tab);
- tab->chatLog(localPlayer->getName(), str);
- chatHandler->privateMessage(whisper->getNick(), str);
- break;
- }
- case ChatTabType::DEBUG:
- case ChatTabType::BATTLE:
- break;
- default:
- case ChatTabType::UNKNOWN:
- case ChatTabType::INPUT:
- case ChatTabType::TRADE:
- case ChatTabType::LANG:
- case ChatTabType::GM:
- case ChatTabType::CHANNEL:
- chatHandler->talk(def, GENERAL_CHANNEL);
- break;
- }
-}
-
-void replaceVars(std::string &str)
-{
- if ((localPlayer == nullptr) || (actorManager == nullptr))
- return;
-
- if (str.find("<PLAYER>") != std::string::npos)
- {
- const Being *target = localPlayer->getTarget();
- if ((target == nullptr) || target->getType() != ActorType::Player)
- {
- target = actorManager->findNearestLivingBeing(
- localPlayer, 20, ActorType::Player, AllowSort_true);
- }
- if (target != nullptr)
- replaceAll(str, "<PLAYER>", target->getName());
- else
- replaceAll(str, "<PLAYER>", "");
- }
- if (str.find("<MONSTER>") != std::string::npos)
- {
- const Being *target = localPlayer->getTarget();
- if ((target == nullptr) || target->getType() != ActorType::Monster)
- {
- target = actorManager->findNearestLivingBeing(
- localPlayer, 20, ActorType::Monster, AllowSort_true);
- }
- if (target != nullptr)
- replaceAll(str, "<MONSTER>", target->getName());
- else
- replaceAll(str, "<MONSTER>", "");
- }
- if (str.find("<PEOPLE>") != std::string::npos)
- {
- StringVect names;
- std::string newStr;
- actorManager->getPlayerNames(names, NpcNames_false);
- FOR_EACH (StringVectCIter, it, names)
- {
- if (*it != localPlayer->getName())
- newStr.append(*it).append(",");
- }
- if (!newStr.empty())
- {
- if (newStr[newStr.size() - 1] == ',')
- newStr = newStr.substr(0, newStr.size() - 1);
- replaceAll(str, "<PEOPLE>", newStr);
- }
- else
- {
- replaceAll(str, "<PEOPLE>", "");
- }
- }
- if (str.find("<PARTY>") != std::string::npos)
- {
- StringVect names;
- std::string newStr;
- const Party *party = nullptr;
- if (localPlayer->isInParty() &&
- ((party = localPlayer->getParty()) != nullptr))
- {
- party->getNames(names);
- FOR_EACH (StringVectCIter, it, names)
- {
- if (*it != localPlayer->getName())
- newStr.append(*it).append(",");
- }
- if (!newStr.empty())
- {
- if (newStr[newStr.size() - 1] == ',')
- newStr = newStr.substr(0, newStr.size() - 1);
- replaceAll(str, "<PARTY>", newStr);
- }
- else
- {
- replaceAll(str, "<PARTY>", "");
- }
- }
- else
- {
- replaceAll(str, "<PARTY>", "");
- }
- }
-}
-
-std::string textToMe(const std::string &str)
-{
- return strprintf("*%s*", str.c_str());
-}
diff --git a/src/utils/chatutils.h b/src/utils/chatutils.h
deleted file mode 100644
index dd2f81df1..000000000
--- a/src/utils/chatutils.h
+++ /dev/null
@@ -1,36 +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 UTILS_CHATUTILS_H
-#define UTILS_CHATUTILS_H
-
-#include <string>
-
-class ChatTab;
-
-void outStringNormal(ChatTab *const tab,
- const std::string &str,
- const std::string &def);
-
-void replaceVars(std::string &str);
-
-std::string textToMe(const std::string &str);
-
-#endif // UTILS_CHATUTILS_H
diff --git a/src/utils/checkutils.cpp b/src/utils/checkutils.cpp
deleted file mode 100644
index 8e72dbf7d..000000000
--- a/src/utils/checkutils.cpp
+++ /dev/null
@@ -1,76 +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 ENABLE_ASSERTS
-
-#include "utils/checkutils.h"
-
-#include "logger.h"
-
-#ifdef HAVE_EXECINFO
-#include <execinfo.h>
-#endif // HAVE_EXECINFO
-
-#include "debug.h"
-
-void reportAssertStack(const char *const file,
- const unsigned int line,
- const char *const func,
- const char *const name,
- const char *const text)
-{
- logger->log("--- Assert: %s --------------------------------------------",
- name);
- logger->assertLog("%s:%u: '%s' in function `%s'",
- file,
- line,
- text,
- func);
-#ifdef HAVE_EXECINFO
- reportStack();
-#endif // HAVE_EXECINFO
-}
-
-void reportLogStack(const char *const file,
- const unsigned int line,
- const char *const func)
-{
- logger->assertLog("%s:%u: in function `%s'",
- file,
- line,
- func);
-#ifdef HAVE_EXECINFO
- reportStack();
-#endif // HAVE_EXECINFO
-}
-
-void reportStack()
-{
-#ifdef HAVE_EXECINFO
- void *array[15];
- const int size = static_cast<int>(backtrace(array, 15));
- char **strings = backtrace_symbols(array, size);
- for (int i = 0; i < size; i++)
- logger->log1(strings[i]);
- free(strings);
-#endif // HAVE_EXECINFO
-}
-
-#endif // ENABLE_ASSERTS
diff --git a/src/utils/checkutils.h b/src/utils/checkutils.h
deleted file mode 100644
index dbac859e4..000000000
--- a/src/utils/checkutils.h
+++ /dev/null
@@ -1,261 +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 UTILS_CHECKUTILS_H
-#define UTILS_CHECKUTILS_H
-
-#include "logger.h"
-LOGGER_H
-
-#ifdef ENABLE_ASSERTS
-
-#define reportFalseReal(val) \
- (val ? true : (reportAssertStack(__FILE__, __LINE__, __func__, \
- "Detected false value", #val), false))
-
-#define reportTrueReal(val) \
- (val ? (reportAssertStack(__FILE__, __LINE__, __func__, \
- "Detected false value", #val), true) : false)
-
-#define reportAlwaysReal(...) \
- { \
- logger->log("Assert:"); \
- logger->assertLog( \
- __VA_ARGS__); \
- reportLogStack(__FILE__, __LINE__, __func__); \
- }
-
-#define returnFalseVReal(val) \
- if (!val) \
- { \
- reportAssertStack(__FILE__, __LINE__, __func__, \
- "Detected false value", #val); \
- return; \
- }
-
-#define returnTrueVReal(val) \
- if (val) \
- { \
- reportAssertStack(__FILE__, __LINE__, __func__, \
- "Detected true value", #val); \
- return; \
- }
-
-#define returnFalseReal(ret, val) \
- if (!val) \
- { \
- reportAssertStack(__FILE__, __LINE__, __func__, \
- "Detected false value", #val); \
- return ret; \
- }
-
-#define returnTrueReal(ret, val) \
- if (val) \
- { \
- reportAssertStack(__FILE__, __LINE__, __func__, \
- "Detected true value", #val); \
- return ret; \
- }
-
-#define returnNullptrVReal(val) \
- if ((val) == nullptr) \
- { \
- reportAssertStack(__FILE__, __LINE__, __func__, \
- "Detected null value", #val); \
- return; \
- }
-
-#define returnNullptrReal(ret, val) \
- if ((val) == nullptr) \
- { \
- reportAssertStack(__FILE__, __LINE__, __func__, \
- "Detected null value", #val); \
- return ret; \
- }
-
-#define failFalse(val) \
- (val ? true : (reportAssertStack(__FILE__, __LINE__, __func__, \
- "Detected false value", #val), \
- throw new std::exception(), false))
-
-#define failTrue(val) \
- (val ? (reportAssertStack(__FILE__, __LINE__, __func__, \
- "Detected false value", #val), \
- throw new std::exception(), true) : false)
-
-#define returnFailFalseV(val) \
- if (!val) \
- { \
- reportAssertStack(__FILE__, __LINE__, __func__, \
- "Detected false value", #val); \
- throw new std::exception(); \
- }
-
-#define returnFailTrueV(val) \
- if (val) \
- { \
- reportAssertStack(__FILE__, __LINE__, __func__, \
- "Detected true value", #val); \
- throw new std::exception(); \
- }
-
-#define returnFailFalse(ret, val) \
- if (!val) \
- { \
- reportAssertStack(__FILE__, __LINE__, __func__, \
- "Detected false value", #val); \
- throw new std::exception(); \
- }
-
-#define returnFailTrue(ret, val) \
- if (val) \
- { \
- reportAssertStack(__FILE__, __LINE__, __func__, \
- "Detected true value", #val); \
- throw new std::exception(); \
- }
-
-#define returnFailNullptrV(val) \
- if ((val) == nullptr) \
- { \
- reportAssertStack(__FILE__, __LINE__, __func__, \
- "Detected null value", #val); \
- throw new std::exception(); \
- }
-
-#define returnFailNullptr(ret, val) \
- if ((val) == nullptr) \
- { \
- reportAssertStack(__FILE__, __LINE__, __func__, \
- "Detected null value", #val); \
- throw new std::exception(); \
- }
-
-#define failAlways(...) \
- { \
- logger->log("Assert:"); \
- logger->assertLog( \
- __VA_ARGS__); \
- reportLogStack(__FILE__, __LINE__, __func__); \
- throw new std::exception(); \
- }
-
-void reportAssertStack(const char *const file,
- const unsigned int line,
- const char *const func,
- const char *const name,
- const char *const text);
-
-void reportLogStack(const char *const file,
- const unsigned int line,
- const char *const func);
-
-void reportStack();
-
-#else // ENABLE_ASSERTS
-
-#define reportFalseReal(val) (val)
-#define reportTrueReal(val) (val)
-
-#define reportAlwaysReal(...) \
- { \
- logger->log("Error:"); \
- logger->log( \
- __VA_ARGS__); \
- }
-
-#define returnFalseVReal(val) \
- if (!val) \
- return;
-
-#define returnTrueVReal(val) \
- if (val) \
- return;
-
-#define returnFalseReal(ret, val) \
- if (!val) \
- return ret;
-
-#define returnTrueReal(ret, val) \
- if (val) \
- return ret;
-
-#define returnNullptrVReal(val) \
- if ((val) == nullptr) \
- return;
-
-#define returnNullptrReal(ret, val) \
- if ((val) == nullptr) \
- return ret;
-
-#define failFalse(val) (val)
-#define failTrue(val) (val)
-
-#define returnFailFalseV(val) \
- if (!val) \
- return;
-
-#define returnFailTrueV(val) \
- if (val) \
- return;
-
-#define returnFailFalse(ret, val) \
- if (!val) \
- return ret;
-
-#define returnFailTrue(ret, val) \
- if (val) \
- return ret;
-
-#define returnFailNullptrV(val) \
- if ((val) == nullptr) \
- return;
-
-#define returnFailNullptr(ret, val) \
- if ((val) == nullptr) \
- return ret;
-
-#define failAlways(...) ;
-
-#endif // ENABLE_ASSERTS
-
-#ifdef UNITTESTS
-#define reportFalse(val) failFalse(val)
-#define reportTrue(val) failTrue(val)
-#define reportAlways(...) failAlways(__VA_ARGS__)
-#define returnFalseV(val) returnFailFalseV(val)
-#define returnTrueV(val) returnFailTrueV(val)
-#define returnFalse(ret, val) returnFailFalse(ret, val)
-#define returnTrue(ret, val) returnFailTrue(ret, val)
-#define returnNullptrV(val) returnFailNullptrV(val)
-#define returnNullptr(ret, val) returnFailNullptr(ret, val)
-#else // UNITTESTS
-#define reportFalse(val) reportFalseReal(val)
-#define reportTrue(val) reportTrueReal(val)
-#define reportAlways(...) reportAlwaysReal(__VA_ARGS__)
-#define returnFalseV(val) returnFalseVReal(val)
-#define returnTrueV(val) returnTrueVReal(val)
-#define returnFalse(ret, val) returnFalseReal(ret, val)
-#define returnTrue(ret, val) returnTrueReal(ret, val)
-#define returnNullptrV(val) returnNullptrVReal(val)
-#define returnNullptr(ret, val) returnNullptrReal(ret, val)
-#endif // UNITTESTS
-
-#endif // UTILS_CHECKUTILS_H
diff --git a/src/utils/copynpaste.cpp b/src/utils/copynpaste.cpp
deleted file mode 100644
index 3896c2b6b..000000000
--- a/src/utils/copynpaste.cpp
+++ /dev/null
@@ -1,522 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2001-2010 Wormux 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/>.
- */
-
-/*
- * IMPORTANT!
- *
- * This code was taken from Wormux svn trunk at Feb 25 2010. Please don't
- * make any unnecessary modifications, and try to sync up modifications
- * when possible.
- */
-
-#ifdef _MSC_VER
-# include "msvc/config.h"
-#elif defined(HAVE_CONFIG_H)
-#include "config.h"
-#endif // _MSC_VER
-
-#include "utils/copynpaste.h"
-
-#include "debug.h"
-
-#ifdef USE_SDL2
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_clipboard.h>
-PRAGMA48(GCC diagnostic pop)
-
-#else // USE_SDL2
-
-#if defined(__APPLE__)
-#ifdef Status
-#undef Status
-#endif // Status
-#include <Carbon/Carbon.h>
-#elif defined USE_X11
-#include "render/graphics.h"
-
-#include "utils/sdlhelper.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_syswm.h>
-PRAGMA48(GCC diagnostic pop)
-#include <unistd.h>
-#elif defined __native_client__
-#include "utils/naclmessages.h"
-#elif defined WIN32
-#include "utils/cast.h"
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_syswm.h>
-PRAGMA48(GCC diagnostic pop)
-#endif // defined(__APPLE__)
-
-#endif // USE_SDL2
-
-#ifdef USE_SDL2
-bool retrieveBuffer(std::string& text, size_t& pos)
-{
- char *buf = SDL_GetClipboardText();
- if (buf)
- {
- text.insert(pos, buf);
- pos += strlen(buf);
- SDL_free(buf);
- return true;
- }
- return false;
-}
-
-bool sendBuffer(const std::string &restrict text)
-{
- return !SDL_SetClipboardText(text.c_str());
-}
-
-#else // USE_SDL2
-
-#ifdef WIN32
-bool retrieveBuffer(std::string& text, size_t& pos)
-{
- bool ret = false;
-
- if (!OpenClipboard(nullptr))
- return false;
-
- HANDLE h = GetClipboardData(CF_UNICODETEXT);
- if (h)
- {
- LPCWSTR data = static_cast<LPCWSTR>(GlobalLock(h));
-
- if (data)
- {
- const size_t len = WideCharToMultiByte(CP_UTF8, 0, data, -1,
- nullptr, 0, nullptr, nullptr);
- if (len > 0)
- {
- // Convert from UTF-16 to UTF-8
- void *temp = calloc(len, 1);
- if (WideCharToMultiByte(CP_UTF8, 0, data, -1,
- static_cast<LPSTR>(temp), len, nullptr, nullptr))
- {
- text.insert(pos, static_cast<char*>(temp));
- pos += len - 1;
- }
- free(temp);
- ret = true;
- }
- }
- GlobalUnlock(h);
- }
- else
- {
- h = GetClipboardData(CF_TEXT);
-
- if (h)
- {
- const char *const data = static_cast<char*>(GlobalLock(h));
- if (data)
- {
- text.insert(pos, data);
- pos += strlen(data);
- ret = true;
- }
- GlobalUnlock(h);
- }
- }
-
- CloseClipboard();
- return ret;
-}
-
-bool sendBuffer(const std::string &restrict text)
-{
- const int wCharsLen = MultiByteToWideChar(CP_UTF8,
- 0, text.c_str(), -1, nullptr, 0);
- if (!wCharsLen)
- return false;
-
- HANDLE h = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE,
- CAST_SIZE(wCharsLen) * sizeof(WCHAR));
- WCHAR *const out = static_cast<WCHAR*>(GlobalLock(h));
-
- MultiByteToWideChar(CP_UTF8, 0, text.c_str(), -1, out, wCharsLen);
-
- if (!OpenClipboard(nullptr))
- {
- GlobalUnlock(h);
- GlobalFree(h);
- return false;
- }
- GlobalUnlock(h);
- EmptyClipboard();
- if (!SetClipboardData(CF_UNICODETEXT, out))
- {
- GlobalFree(h);
- CloseClipboard();
- return false;
- }
- GlobalFree(h);
- CloseClipboard();
-
- return true;
-}
-
-#elif defined(__APPLE__)
-
-// Sorry for the very long code, all nicer OS X APIs are coded in
-// Objective C and not C!
-// Also it does very thorough error handling
-bool getDataFromPasteboard(PasteboardRef inPasteboard,
- char* flavorText /* out */,
- const int bufSize)
-{
- ItemCount itemCount;
- PasteboardSyncFlags syncFlags = PasteboardSynchronize(inPasteboard);
- OSStatus err = PasteboardGetItemCount(inPasteboard, &itemCount);
- require_noerr(err, CantGetPasteboardItemCount);
-
- for (UInt32 itemIndex = 1; itemIndex <= itemCount; itemIndex ++)
- {
- PasteboardItemID itemID;
- CFArrayRef flavorTypeArray;
- CFIndex flavorCount;
-
- err = PasteboardGetItemIdentifier(inPasteboard, itemIndex, &itemID);
- require_noerr(err, CantGetPasteboardItemIdentifier);
-
- err = PasteboardCopyItemFlavors(inPasteboard,
- itemID, &flavorTypeArray);
- require_noerr(err, CantCopyPasteboardItemFlavors);
-
- flavorCount = CFArrayGetCount(flavorTypeArray);
-
- for (CFIndex flavorIndex = 0; flavorIndex < flavorCount;
- flavorIndex ++)
- {
- CFStringRef flavorType = (CFStringRef)CFArrayGetValueAtIndex(
- flavorTypeArray, flavorIndex);
-
- // we're only interested by text...
- if (UTTypeConformsTo(flavorType, CFSTR("public.utf8-plain-text")))
- {
- CFDataRef flavorData;
- err = PasteboardCopyItemFlavorData(inPasteboard, itemID,
- flavorType, &flavorData);
- require_noerr(err, CantCopyFlavorData);
- CFIndex flavorDataSize = CFDataGetLength(flavorData);
- flavorDataSize = (flavorDataSize<254) ? flavorDataSize : 254;
-
- if (flavorDataSize + 2 > bufSize)
- {
- fprintf(stderr,
- "Cannot copy clipboard, contents is too big!\n");
- return false;
- }
-
- for (short dataIndex = 0; dataIndex <= flavorDataSize;
- dataIndex ++)
- {
- signed char byte = *(CFDataGetBytePtr(
- flavorData) + dataIndex);
- flavorText[dataIndex] = byte;
- }
-
- flavorText[flavorDataSize] = '\0';
- flavorText[flavorDataSize + 1] = '\n';
-
- CFRelease(flavorData);
- return true;
- }
-
- continue;
-CantCopyFlavorData:
- fprintf(stderr, "Cannot copy clipboard, CantCopyFlavorData!\n");
- }
-
- CFRelease(flavorTypeArray);
- continue;
-
-CantCopyPasteboardItemFlavors:
- fprintf(stderr,
- "Cannot copy clipboard, CantCopyPasteboardItemFlavors!\n");
- continue;
-CantGetPasteboardItemIdentifier:
- fprintf(stderr,
- "Cannot copy clipboard, CantGetPasteboardItemIdentifier!\n");
- continue;
- }
- fprintf(stderr,
- "Cannot copy clipboard, found no acceptable flavour!\n");
- return false;
-
-CantGetPasteboardItemCount:
- fprintf(stderr, "Cannot copy clipboard, CantGetPasteboardItemCount!\n");
- return false;
-}
-
-bool getClipBoard(char* text /* out */, const int bufSize)
-{
- PasteboardRef theClipboard;
- OSStatus err = PasteboardCreate(kPasteboardClipboard, &theClipboard);
- require_noerr(err, PasteboardCreateFailed);
-
- if (!getDataFromPasteboard(theClipboard, text, bufSize))
- {
- fprintf(stderr,
- "Cannot copy clipboard, getDataFromPasteboardFailed!\n");
- return false;
- }
-
- CFRelease(theClipboard);
-
- return true;
-
- // ---- error handling
-PasteboardCreateFailed:
- fprintf(stderr, "Cannot copy clipboard, PasteboardCreateFailed!\n");
- CFRelease(theClipboard);
- return false;
-}
-
-bool retrieveBuffer(std::string& text, size_t& pos)
-{
- const int bufSize = 512;
- char buffer[bufSize + 1];
-
- if (getClipBoard(buffer, bufSize))
- {
- text = buffer;
- pos += strlen(buffer);
- return true;
- }
- else
- {
- return false;
- }
-}
-
-bool sendBuffer(const std::string &restrict text)
-{
- return false;
-}
-
-#elif defined USE_X11
-
-static char* getSelection2(Display *const dpy, Window us, Atom selection,
- Atom request_target)
-{
- int max_events = 50;
- Window owner = XGetSelectionOwner(dpy, selection);
-
- if (owner == None)
- return nullptr;
-
- XConvertSelection(dpy, selection, request_target,
- XA_PRIMARY, us, CurrentTime);
- XFlush(dpy);
-
- while (max_events --)
- {
- XEvent e;
-
- XNextEvent(dpy, &e);
- if (e.type == SelectionNotify)
- {
- if (e.xselection.property == None)
- return nullptr;
-
- long unsigned len, left, dummy;
- int format;
- Atom type;
- unsigned char *data = nullptr;
-
- int ret = XGetWindowProperty(dpy, us, e.xselection.property, 0, 0,
- False, AnyPropertyType, &type, &format, &len, &left, &data);
- if (left < 1)
- {
- if (ret == Success)
- XFree(data);
- return nullptr;
- }
-
- ret = XGetWindowProperty(dpy, us, e.xselection.property, 0,
- left, False, AnyPropertyType, &type, &format, &len,
- &dummy, &data);
-
- if (ret != Success)
- return nullptr;
-
- return reinterpret_cast<char*>(data);
- }
- }
- return nullptr;
-}
-
-static Atom requestAtom;
-
-static char* getSelection(Display *const dpy, Window us, Atom selection)
-{
- char *data = nullptr;
- if (requestAtom != None)
- data = getSelection2(dpy, us, selection, requestAtom);
- if (!data)
- data = getSelection2(dpy, us, selection, XA_STRING);
- return data;
-}
-
-bool retrieveBuffer(std::string& text, size_t& pos)
-{
- SDL_SysWMinfo info;
-
- SDL_VERSION(&info.version);
- if (SDL::getWindowWMInfo(mainGraphics->getWindow(), &info))
- {
- Display *const dpy = info.info.x11.display;
- Window us = info.info.x11.window;
-
- requestAtom = XInternAtom(dpy, "UTF8_STRING", true);
- char *data = getSelection(dpy, us, XA_PRIMARY);
- if (!data)
- data = getSelection(dpy, us, XA_SECONDARY);
- if (!data)
- {
- Atom XA_CLIPBOARD = XInternAtom(dpy, "CLIPBOARD", 0);
- if (XA_CLIPBOARD != None)
- data = getSelection(dpy, us, XA_CLIPBOARD);
- }
-
- if (data)
- {
- // check cursor position
- const size_t sz = text.size();
- if (pos > sz)
- pos = sz;
-
- text.insert(pos, data);
- pos += strlen(data);
- XFree(data);
-
- return true;
- }
- }
- return false;
-}
-
-static bool runxsel(const std::string &text, const char *p1,
- const char *p2 = nullptr);
-
-bool sendBuffer(const std::string &restrict text)
-{
- runxsel(text, "-i");
- runxsel(text, "-b", "-i");
- return true;
-}
-
-static bool runxsel(const std::string &text, const char *p1, const char *p2)
-{
- pid_t pid;
- int fd[2];
-
- if (pipe(fd))
- return false;
-
- if ((pid = fork()) == -1)
- { // fork error
- return false;
- }
- else if (!pid)
- { // child
- close(fd[1]);
-
- if (fd[0] != STDIN_FILENO)
- {
- if (dup2(fd[0], STDIN_FILENO) != STDIN_FILENO)
- {
- close(fd[0]);
- _exit(1);
- }
- close(fd[0]);
- }
-
- const char *const xselPath =
-#if defined __OpenBSD__ || defined __FreeBSD__ || defined __DragonFly__
- "/usr/local/bin/xsel";
-#else // defined __OpenBSD__ || defined __FreeBSD__ || defined __DragonFly__
- "/usr/bin/xsel";
-#endif // defined __OpenBSD__ || defined __FreeBSD__ || defined __DragonFly__
-
- if (p2)
- {
- execl(xselPath, "xsel", p1, p2,
- static_cast<char *>(nullptr));
- }
- else
- {
- execl(xselPath, "xsel", p1,
- static_cast<char *>(nullptr));
- }
-
- _exit(1);
- }
-
- // parent
- close(fd[0]);
- const size_t len = text.length();
- if (write(fd[1], text.c_str(), len) != static_cast<ssize_t>(len))
- {
- close(fd[1]);
- return false;
- }
- close(fd[1]);
- return true;
-}
-
-#elif defined __native_client__
-
-bool retrieveBuffer(std::string& text, size_t& pos)
-{
- NaclMessageHandle *handle = naclRegisterMessageHandler("clipboard-paste");
- naclPostMessage("clipboard-paste", "");
- std::string response = naclWaitForMessage(handle);
- text.insert(pos, response);
- pos += response.size();
- return true;
-}
-
-bool sendBuffer(const std::string &restrict text)
-{
- naclPostMessage("clipboard-copy", text);
- return true;
-}
-#else // WIN32
-
-bool retrieveBuffer(std::string &text A_UNUSED, size_t &pos A_UNUSED)
-{
- return false;
-}
-
-bool sendBuffer(const std::string &restrict text A_UNUSED)
-{
- return false;
-}
-#endif // WIN32
-#endif // USE_SDL2
diff --git a/src/utils/copynpaste.h b/src/utils/copynpaste.h
deleted file mode 100644
index 73e086160..000000000
--- a/src/utils/copynpaste.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2001-2010 Wormux 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 UTILS_COPYNPASTE_H
-#define UTILS_COPYNPASTE_H
-
-#include <string>
-
-#include "localconsts.h"
-
-/**
- * Attempts to retrieve text from the clipboard buffer and inserts it in
- * \a text at position. The characters are encoded in utf-8.
- *
- * Implemented for Windows, X11 and Mac OS X.
- *
- * @return <code>true</code> when successful or <code>false</code> when there
- * was a problem retrieving the clipboard buffer.
- */
-bool retrieveBuffer(std::string& text, size_t& pos) A_WARN_UNUSED;
-
-bool sendBuffer(const std::string &restrict text);
-
-#endif // UTILS_COPYNPASTE_H
diff --git a/src/utils/cpu.cpp b/src/utils/cpu.cpp
deleted file mode 100644
index ef6a419b6..000000000
--- a/src/utils/cpu.cpp
+++ /dev/null
@@ -1,178 +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 "utils/cpu.h"
-
-#include "logger.h"
-
-#if (defined(__amd64__) || defined(__i386__)) && defined(__GNUC__) \
- && (GCC_VERSION >= 40800) && !defined(ANDROID)
-// nothing
-#elif defined(__linux__) || defined(__linux)
-#include "utils/foreach.h"
-#include "utils/stringutils.h"
-#endif // (defined(__amd64__) || defined(__i386__)) && defined(__GNUC__)
- // && (GCC_VERSION >= 40800) && !defined(ANDROID)
-
-#ifdef USE_SDL2
-#include <SDL_cpuinfo.h>
-#endif // USE_SDL2
-
-#include "debug.h"
-
-namespace
-{
- uint32_t mCpuFlags;
-} // namespace
-
-void Cpu::detect()
-{
-#if (defined(__amd64__) || defined(__i386__)) && defined(__GNUC__) \
- && (GCC_VERSION >= 40800) && !defined(ANDROID)
- __builtin_cpu_init();
- if (__builtin_cpu_supports ("mmx"))
- mCpuFlags |= FEATURE_MMX;
- if (__builtin_cpu_supports ("sse"))
- mCpuFlags |= FEATURE_SSE;
- if (__builtin_cpu_supports ("sse2"))
- mCpuFlags |= FEATURE_SSE2;
- if (__builtin_cpu_supports ("ssse3"))
- mCpuFlags |= FEATURE_SSSE3;
- if (__builtin_cpu_supports ("sse4.1"))
- mCpuFlags |= FEATURE_SSE4;
- if (__builtin_cpu_supports ("sse4.2"))
- mCpuFlags |= FEATURE_SSE42;
- if (__builtin_cpu_supports ("avx"))
- mCpuFlags |= FEATURE_AVX;
- if (__builtin_cpu_supports ("avx2"))
- mCpuFlags |= FEATURE_AVX2;
- printFlags();
-#elif defined(__linux__) || defined(__linux)
- FILE *file = fopen("/proc/cpuinfo", "r");
- char buf[1001];
- if (file == nullptr)
- return;
- while (fgets(buf, 1000, file) != nullptr)
- {
- std::string str = buf;
- if (findFirst(str, "flags"))
- {
- size_t idx = str.find(':');
- if (idx == std::string::npos)
- continue;
- str = str.substr(idx + 1);
- trim(str);
- StringVect vect;
- splitToStringVector(vect, str, ' ');
- FOR_EACH (StringVectCIter, it, vect)
- {
- const std::string &flag = *it;
- if (flag == "mmx")
- mCpuFlags |= FEATURE_MMX;
- else if (flag == "sse")
- mCpuFlags |= FEATURE_SSE;
- else if (flag == "sse2")
- mCpuFlags |= FEATURE_SSE2;
- else if (flag == "ssse3")
- mCpuFlags |= FEATURE_SSSE3;
- else if (flag == "sse4_1")
- mCpuFlags |= FEATURE_SSE4;
- else if (flag == "sse4_2")
- mCpuFlags |= FEATURE_SSE42;
- else if (flag == "avx")
- mCpuFlags |= FEATURE_AVX;
- else if (flag == "avx2")
- mCpuFlags |= FEATURE_AVX2;
- }
- fclose(file);
- printFlags();
- return;
- }
- }
- fclose(file);
- if (logger != nullptr)
- logger->log("cpu features was not detected");
-#else // OTHER
-
-#ifdef USE_SDL2
- if (SDL_HasMMX())
- mCpuFlags |= FEATURE_MMX;
- if (SDL_HasSSE())
- mCpuFlags |= FEATURE_SSE;
- if (SDL_HasSSE2())
- mCpuFlags |= FEATURE_SSE2;
- if (SDL_HasSSE3())
- mCpuFlags |= FEATURE_SSSE3;
- if (SDL_HasSSE41())
- mCpuFlags |= FEATURE_SSE4;
- if (SDL_HasSSE42())
- mCpuFlags |= FEATURE_SSE42;
-
-#if SDL_VERSION_ATLEAST(2, 0, 2)
- if (SDL_HasAVX())
- mCpuFlags |= FEATURE_AVX;
-#endif // SDL_VERSION_ATLEAST(2, 0, 2)
-#if SDL_VERSION_ATLEAST(2, 0, 4)
- if (SDL_HasAVX2())
- mCpuFlags |= FEATURE_AVX2;
-#endif // SDL_VERSION_ATLEAST(2, 0, 4)
-
- printFlags();
-#else // USE_SDL2
-
- if (logger)
- logger->log("cpu features not supported");
-#endif // USE_SDL2
-#endif // (defined(__amd64__) || defined(__i386__)) && defined(__GNUC__)
- // && (GCC_VERSION >= 40800) && !defined(ANDROID)
-
-#if SDL_VERSION_ATLEAST(2, 0, 1)
- logger->log("System ram size: %d", SDL_GetSystemRAM());
-#endif // SDL_VERSION_ATLEAST(2, 0, 1)
-}
-
-void Cpu::printFlags()
-{
- if (logger == nullptr)
- return;
- std::string str("CPU features:");
- if ((mCpuFlags & FEATURE_MMX) != 0u)
- str.append(" mmx");
- if ((mCpuFlags & FEATURE_SSE) != 0u)
- str.append(" sse");
- if ((mCpuFlags & FEATURE_SSE2) != 0u)
- str.append(" sse2");
- if ((mCpuFlags & FEATURE_SSSE3) != 0u)
- str.append(" ssse3");
- if ((mCpuFlags & FEATURE_SSE4) != 0u)
- str.append(" sse4");
- if ((mCpuFlags & FEATURE_SSE42) != 0u)
- str.append(" sse4_2");
- if ((mCpuFlags & FEATURE_AVX) != 0u)
- str.append(" avx");
- if ((mCpuFlags & FEATURE_AVX2) != 0u)
- str.append(" avx2");
- logger->log(str);
-}
-
-uint32_t Cpu::getFlags()
-{
- return mCpuFlags;
-}
diff --git a/src/utils/cpu.h b/src/utils/cpu.h
deleted file mode 100644
index 8be6ccbc3..000000000
--- a/src/utils/cpu.h
+++ /dev/null
@@ -1,48 +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 UTILS_CPU_H
-#define UTILS_CPU_H
-
-#include "localconsts.h"
-
-namespace Cpu
-{
- enum
- {
- FEATURE_EMPTY = 0,
- FEATURE_MMX = 1,
- FEATURE_SSE = 2,
- FEATURE_SSE2 = 4,
- FEATURE_SSSE3 = 8,
- FEATURE_SSE4 = 16,
- FEATURE_SSE42 = 32,
- FEATURE_AVX = 64,
- FEATURE_AVX2 = 128
- };
-
- void detect();
-
- void printFlags();
-
- uint32_t getFlags();
-} // namespace Cpu
-
-#endif // UTILS_CPU_H
diff --git a/src/utils/delete2.h b/src/utils/delete2.h
deleted file mode 100644
index 4c6b4c6a6..000000000
--- a/src/utils/delete2.h
+++ /dev/null
@@ -1,36 +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 UTILS_DELETE2_H
-#define UTILS_DELETE2_H
-
-#define delete2(var) \
- {\
- delete var;\
- var = nullptr;\
- }
-
-#define delete2Arr(var) \
- {\
- delete []var;\
- var = nullptr;\
- }
-
-#endif // UTILS_DELETE2_H
diff --git a/src/utils/dtor.h b/src/utils/dtor.h
deleted file mode 100644
index 21d0429e9..000000000
--- a/src/utils/dtor.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 UTILS_DTOR_H
-#define UTILS_DTOR_H
-
-#include <algorithm>
-#include <functional>
-
-#include "localconsts.h"
-
-template<typename T>
-struct dtor final : public std::unary_function <T, void>
-{
- A_DEFAULT_COPY(dtor)
-
- void operator()(T &ptr)
- { delete ptr; }
-};
-
-template<typename T1, typename T2>
-struct dtor<std::pair<T1, T2> > :
-public std::unary_function <std::pair<T1, T2>, void>
-{
- void operator()(std::pair<T1, T2> &pair)
- { delete pair.second; }
-};
-
-template<class Cont>
-inline dtor<typename Cont::value_type> make_dtor(Cont const &d A_UNUSED)
-{
- return dtor<typename Cont::value_type>();
-}
-
-template<typename Container>
-inline void delete_all(Container &c)
-{
- std::for_each(c.begin(), c.end(), make_dtor(c));
-}
-
-#endif // UTILS_DTOR_H
diff --git a/src/utils/dumplibs.cpp b/src/utils/dumplibs.cpp
deleted file mode 100644
index 420ef62ce..000000000
--- a/src/utils/dumplibs.cpp
+++ /dev/null
@@ -1,169 +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 "utils/dumplibs.h"
-
-#include "logger.h"
-
-#include "utils/stringutils.h"
-
-#include <png.h>
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_image.h>
-#include <SDL_mixer.h>
-PRAGMACLANG6GCC(GCC diagnostic push)
-PRAGMACLANG6GCC(GCC diagnostic ignored "-Wold-style-cast")
-#include <SDL_net.h>
-PRAGMACLANG6GCC(GCC diagnostic pop)
-#include <SDL_ttf.h>
-PRAGMA48(GCC diagnostic pop)
-
-#include <zlib.h>
-
-#include <curl/curl.h>
-
-#ifdef ENABLE_LIBXML
-#include <libxml/xmlversion.h>
-#endif // ENABLE_LIBXML
-
-#include "debug.h"
-
-#define dumpCompiledSdlVersion(text, prefix) \
- logger->log(" " text ": %d.%d.%d", \
- prefix##_MAJOR_VERSION, \
- prefix##_MINOR_VERSION, \
- prefix##_PATCHLEVEL)
-
-#define sdlVersionJoin(prefix) \
- prefix##_MAJOR_VERSION, \
- prefix##_MINOR_VERSION, \
- prefix##_PATCHLEVEL
-
-static void dumpLinkedSdlVersion(const char *const text,
- const SDL_version *const version)
-{
- if (version != nullptr)
- {
- logger->log(" %s: %d.%d.%d",
- text,
- version->major,
- version->minor,
- version->patch);
- }
-}
-
-static void compareVersions(const char *const libName,
- const char *const buildVersion,
- const char *const linkedVersion)
-{
- if (strcmp(buildVersion, linkedVersion) != 0)
- {
- logger->assertLog(
- "%s: compiled and linked versions not same: %s vs %s",
- libName,
- buildVersion,
- linkedVersion);
- }
-}
-
-static void compareSDLVersions(const char *const libName,
- const int major,
- const int minor,
- const int patch,
- const SDL_version *const linkedVersion)
-{
- const std::string buildVersionStr = strprintf("%d.%d.%d",
- major,
- minor,
- patch);
- const std::string linkedVersionStr = strprintf("%d.%d.%d",
- linkedVersion->major,
- linkedVersion->minor,
- linkedVersion->patch);
- if (buildVersionStr != linkedVersionStr)
- {
- logger->assertLog(
- "%s: compiled and linked versions not same: %s vs %s",
- libName,
- buildVersionStr.c_str(),
- linkedVersionStr.c_str());
- }
-}
-
-void dumpLibs()
-{
- logger->log("Compiled with:");
- logger->log(" zLib: %s", ZLIB_VERSION);
-#ifdef ENABLE_LIBXML
- logger->log(" libxml2: %s", LIBXML_DOTTED_VERSION);
-#endif // ENABLE_LIBXML
-
- logger->log(" libcurl: %s", LIBCURL_VERSION);
- logger->log(" libpng: %s", PNG_LIBPNG_VER_STRING);
-
- dumpCompiledSdlVersion("SDL", SDL);
- dumpCompiledSdlVersion("SDL_net", SDL_NET);
- dumpCompiledSdlVersion("SDL_image", SDL_IMAGE);
- dumpCompiledSdlVersion("SDL_mixer", SDL_MIXER);
- dumpCompiledSdlVersion("SDL_ttf", SDL_TTF);
-
- logger->log("Linked with:");
-#if ZLIB_VERNUM >= 0x1020
- logger->log(" zLib: %s", zlibVersion());
-#endif // ZLIB_VERNUM >= 0x1020
-#ifdef LIBXML_TEST_VERSION
- LIBXML_TEST_VERSION
-#endif // LIBXML_TEST_VERSION
-#ifdef USE_SDL2
- SDL_version sdlVersion;
- sdlVersion.major = 0;
- sdlVersion.minor = 0;
- sdlVersion.patch = 0;
- SDL_GetVersion(&sdlVersion);
- dumpLinkedSdlVersion("SDL", &sdlVersion);
-#else // USE_SDL2
- dumpLinkedSdlVersion("SDL", SDL_Linked_Version());
-#endif // USE_SDL2
- dumpLinkedSdlVersion("SDL_net", SDLNet_Linked_Version());
- dumpLinkedSdlVersion("SDL_image", IMG_Linked_Version());
- dumpLinkedSdlVersion("SDL_mixer", Mix_Linked_Version());
- dumpLinkedSdlVersion("SDL_ttf", TTF_Linked_Version());
-
- compareVersions("zLib", ZLIB_VERSION, zlibVersion());
-#ifdef USE_SDL2
- compareSDLVersions("SDL", sdlVersionJoin(SDL), &sdlVersion);
-#else // USE_SDL2
- compareSDLVersions("SDL", sdlVersionJoin(SDL), SDL_Linked_Version());
-#endif // USE_SDL2
-
- compareSDLVersions("SDL_net",
- sdlVersionJoin(SDL_NET),
- SDLNet_Linked_Version());
- compareSDLVersions("SDL_image",
- sdlVersionJoin(SDL_IMAGE),
- IMG_Linked_Version());
- compareSDLVersions("SDL_mixer",
- sdlVersionJoin(SDL_MIXER),
- Mix_Linked_Version());
- compareSDLVersions("SDL_ttf",
- sdlVersionJoin(SDL_TTF),
- TTF_Linked_Version());
-}
diff --git a/src/utils/dumplibs.h b/src/utils/dumplibs.h
deleted file mode 100644
index 1013026f1..000000000
--- a/src/utils/dumplibs.h
+++ /dev/null
@@ -1,28 +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 UTILS_DUMPLIBS_H
-#define UTILS_DUMPLIBS_H
-
-#include "localconsts.h"
-
-void dumpLibs();
-
-#endif // UTILS_DUMPLIBS_H
diff --git a/src/utils/dumpsizes.cpp b/src/utils/dumpsizes.cpp
deleted file mode 100644
index 86f89b6cd..000000000
--- a/src/utils/dumpsizes.cpp
+++ /dev/null
@@ -1,40 +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 "utils/dumpsizes.h"
-
-#include "logger.h"
-
-#include "utils/cast.h"
-
-#include "debug.h"
-
-#define dumpSize(str) \
- logger->log(" sizeof("#str"): %d", CAST_S32(sizeof(str)));
-
-void dumpSizes()
-{
- logger->log("Type sizes:");
- dumpSize(char);
- dumpSize(short);
- dumpSize(int);
- dumpSize(long);
- dumpSize(size_t);
-}
diff --git a/src/utils/dumpsizes.h b/src/utils/dumpsizes.h
deleted file mode 100644
index c7729ac14..000000000
--- a/src/utils/dumpsizes.h
+++ /dev/null
@@ -1,28 +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 UTILS_DUMPSIZES_H
-#define UTILS_DUMPSIZES_H
-
-#include "localconsts.h"
-
-void dumpSizes();
-
-#endif // UTILS_DUMPSIZES_H
diff --git a/src/utils/env.cpp b/src/utils/env.cpp
deleted file mode 100644
index e8808e238..000000000
--- a/src/utils/env.cpp
+++ /dev/null
@@ -1,73 +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 "utils/env.h"
-
-#include "configuration.h"
-#include "logger.h"
-#include "settings.h"
-
-#include "debug.h"
-
-void updateEnv()
-{
-#if defined(WIN32) || defined(__APPLE__)
- if (config.getBoolValue("centerwindow"))
- setEnv("SDL_VIDEO_CENTERED", "1");
- else
- setEnv("SDL_VIDEO_CENTERED", "0");
-#endif // defined(WIN32) || defined(__APPLE__)
-
-#ifndef WIN32
- const int vsync = settings.options.test.empty()
- ? config.getIntValue("vsync") : 1;
- // __GL_SYNC_TO_VBLANK is nvidia variable.
- // vblank_mode is MESA variable.
- switch (vsync)
- {
- case 1:
- setEnv("__GL_SYNC_TO_VBLANK", "0");
- setEnv("vblank_mode", "0");
- break;
- case 2:
- setEnv("__GL_SYNC_TO_VBLANK", "1");
- setEnv("vblank_mode", "2");
- break;
- default:
- break;
- }
-#endif // WIN32
-}
-
-void setEnv(const char *const name, const char *const value)
-{
- if ((name == nullptr) || (value == nullptr))
- return;
-#ifdef WIN32
- if (putenv(const_cast<char*>((std::string(name)
- + "=" + value).c_str())))
-#else // WIN32
-
- if (setenv(name, value, 1) != 0)
-#endif // WIN32
- {
- logger->log("setenv failed: %s=%s", name, value);
- }
-}
diff --git a/src/utils/env.h b/src/utils/env.h
deleted file mode 100644
index 8f42448f8..000000000
--- a/src/utils/env.h
+++ /dev/null
@@ -1,30 +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 UTILS_ENV_H
-#define UTILS_ENV_H
-
-#include "localconsts.h"
-
-void setEnv(const char *const name, const char *const value);
-
-void updateEnv();
-
-#endif // UTILS_ENV_H
diff --git a/src/utils/foreach.h b/src/utils/foreach.h
deleted file mode 100644
index d3212795f..000000000
--- a/src/utils/foreach.h
+++ /dev/null
@@ -1,36 +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 UTILS_FOREACH_H
-#define UTILS_FOREACH_H
-
-#define FOR_EACH(type, iter, array) for (type iter = array.begin(), \
- iter##_fend = array.end(); iter != iter##_fend; ++ iter)
-
-#define FOR_EACHR(type, iter, array) for (type iter = array.rbegin(), \
- iter##_fend = array.rend(); iter != iter##_fend; ++ iter)
-
-#define FOR_EACHP(type, iter, array) for (type iter = array->begin(), \
- iter##_fend = array->end(); iter != iter##_fend; ++ iter)
-
-#define FOR_EACH_SAFE(type, iter, array) for (type iter = array.begin(); \
- iter != array.end(); ++ iter)
-
-#endif // UTILS_FOREACH_H
diff --git a/src/utils/fuzzer.cpp b/src/utils/fuzzer.cpp
deleted file mode 100644
index d11d61de3..000000000
--- a/src/utils/fuzzer.cpp
+++ /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/>.
- */
-
-#include "utils/fuzzer.h"
-
-#ifdef USE_FUZZER
-
-#include "client.h"
-#include "logger.h"
-#include "settings.h"
-
-#include "utils/stringutils.h"
-
-#include "debug.h"
-
-namespace
-{
- Logger *fuzz = nullptr;
- int fuzzRand = 50;
-} // namespace
-
-void Fuzzer::init()
-{
- fuzz = new Logger;
- fuzz->setLogFile(pathJoin(settings.localDataDir, "fuzzer.log"));
- unsigned int sr = time(nullptr);
-
- fuzz->log("Srand: %u", sr);
- srand(sr);
-}
-
-bool Fuzzer::conditionTerminate(const char *const name)
-{
- if ((rand() % 100) <= fuzzRand)
- {
- fuzz->log("deleted: %s", name);
- return true;
- }
- fuzz->log("passed: %s", name);
- return false;
-}
-
-#endif // USE_FUZZER
diff --git a/src/utils/fuzzer.h b/src/utils/fuzzer.h
deleted file mode 100644
index d43dcc294..000000000
--- a/src/utils/fuzzer.h
+++ /dev/null
@@ -1,34 +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 UTILS_FUZZER_H
-#define UTILS_FUZZER_H
-
-#include "localconsts.h"
-
-#ifdef USE_FUZZER
-namespace Fuzzer
-{
- void init();
- bool conditionTerminate(const char *const name);
-} // namespace Fuzzer
-
-#endif // USE_FUZZER
-#endif // UTILS_FUZZER_H
diff --git a/src/utils/gettext.h b/src/utils/gettext.h
deleted file mode 100644
index 2265da585..000000000
--- a/src/utils/gettext.h
+++ /dev/null
@@ -1,55 +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 UTILS_GETTEXT_H
-#define UTILS_GETTEXT_H
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif // HAVE_CONFIG_H
-
-#ifdef ENABLE_NLS
-
-#include <libintl.h>
-
-#define _(s) (const_cast <char*>(gettext(s)))
-#define N_(s) (const_cast <char*>(s))
-
-#elif defined(ENABLE_CUSTOMNLS) // ENABLE_NLS
-
-#include "utils/translation/podict.h"
-
-#define gettext(s) const_cast <char*>(mainTranslator->getChar(s))
-#define _(s) const_cast <char*>(mainTranslator->getChar(s))
-#define N_(s) (const_cast <char*>(s))
-#define ngettext(s1, s2, i1) const_cast <char*>(mainTranslator->getChar(s1))
-
-#else // ENABLE_NLS
-
-#define gettext(s) (const_cast <char*>(s))
-#define _(s) (const_cast <char*>(s))
-#define N_(s) (const_cast <char*>(s))
-#define ngettext(s1, s2, i1) (const_cast <char*>(s1))
-
-#endif // ENABLE_NLS
-
-#endif // UTILS_GETTEXT_H
diff --git a/src/utils/gettexthelper.cpp b/src/utils/gettexthelper.cpp
deleted file mode 100644
index f7f02ba32..000000000
--- a/src/utils/gettexthelper.cpp
+++ /dev/null
@@ -1,156 +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 "utils/gettexthelper.h"
-
-#if defined(ENABLE_NLS) || defined(ENABLE_CUSTOMNLS)
-#include "configuration.h"
-#endif // defined(ENABLE_NLS) || defined(ENABLE_CUSTOMNLS)
-
-#ifdef ENABLE_NLS
-#include "client.h"
-#include "logger.h"
-
-#include "fs/virtfs/fs.h"
-
-#include <libintl.h>
-
-#ifdef WIN32
-#include <string>
-extern "C" char const *_nl_locale_name_default(void);
-#endif // WIN32
-#elif defined(ENABLE_CUSTOMNLS)
-#include "utils/translation/podict.h"
-#ifdef __native_client__
-#include "utils/naclmessages.h"
-#endif // __native_client__
-#endif // ENABLE_NLS
-
-#if defined(ENABLE_NLS) || defined(ENABLE_CUSTOMNLS) && !defined(WIN32)
-#include "utils/env.h"
-#endif // defined(ENABLE_NLS) || defined(ENABLE_CUSTOMNLS) && !defined(WIN32)
-
-#include "debug.h"
-
-#if defined(ENABLE_NLS) || defined(ENABLE_CUSTOMNLS)
-static std::string setLangEnv()
-{
- std::string lang = config.getStringValue("lang");
-#if defined(ENABLE_NLS) && defined(WIN32)
- if (lang.empty())
- lang = std::string(_nl_locale_name_default());
-#elif defined(ENABLE_CUSTOMNLS) && defined(__native_client__)
- if (lang.empty())
- {
- NaclMessageHandle *handle = naclRegisterMessageHandler(
- "get-uilanguage");
- naclPostMessage("get-uilanguage", "");
- lang = naclWaitForMessage(handle);
- }
-#endif // defined(ENABLE_NLS) && defined(WIN32)
-
- if (!lang.empty())
- {
-#ifdef WIN32
- putenv(const_cast<char*>(("LANG=" + lang).c_str()));
- putenv(const_cast<char*>(("LANGUAGE=" + lang).c_str()));
-#else // WIN32
-
- if (!lang.empty())
- {
- setEnv("LANG", lang.c_str());
- setEnv("LANGUAGE", lang.c_str());
- }
-#endif // WIN32
- }
-
- return lang;
-}
-#endif // defined(ENABLE_NLS) || defined(ENABLE_CUSTOMNLS)
-
-void GettextHelper::initLang()
-{
-#ifdef ENABLE_NLS
- const std::string lang = setLangEnv();
-#ifdef WIN32
- // mingw doesn't like LOCALEDIR to be defined for some reason
- if (lang != "C")
- bindTextDomain("translations/");
-#else // WIN32
-#ifdef ANDROID
-#ifdef USE_SDL2
- bindTextDomain((std::string(getenv("APPDIR")).append("/locale")).c_str());
-#else // USE_SDL2
-
- bindTextDomain((std::string(VirtFs::getBaseDir()).append(
- "/locale")).c_str());
-#endif // USE_SDL2
-#else // ANDROID
-#ifdef ENABLE_PORTABLE
- bindTextDomain((std::string(VirtFs::getBaseDir()).append(
- "../locale/")).c_str());
-#else // ENABLE_PORTABLE
-#ifdef __APPLE__
- bindTextDomain((std::string(VirtFs::getBaseDir())
- .append("ManaPlus.app/Contents/Resources/locale/")).c_str());
-#else // __APPLE__
-
- bindTextDomain(LOCALEDIR);
-#endif // __APPLE__
-#endif // ENABLE_PORTABLE
-#endif // ANDROID
-#endif // WIN32
-
- char *locale = setlocale(LC_MESSAGES, lang.c_str());
- if (locale)
- {
- logger->log("locale: %s", locale);
- }
- else
- {
- locale = setlocale(LC_MESSAGES, (lang + ".utf8").c_str());
- if (locale)
- logger->log("locale: %s", locale);
- else
- logger->log("locale empty");
- }
- bind_textdomain_codeset("manaplus", "UTF-8");
- textdomain("manaplus");
-#elif defined(ENABLE_CUSTOMNLS)
- mainTranslator = new PoDict("en");
- setLangEnv();
-#endif // ENABLE_NLS
-}
-
-#ifdef ENABLE_NLS
-void GettextHelper::bindTextDomain(const char *const path)
-{
- const char *const dir = bindtextdomain("manaplus", path);
- if (dir)
- logger->log("bindtextdomain: %s", dir);
- else
- logger->log("bindtextdomain failed");
-}
-#else // ENABLE_NLS
-
-void GettextHelper::bindTextDomain(const char *const path A_UNUSED)
-{
-}
-#endif // ENABLE_NLS
diff --git a/src/utils/gettexthelper.h b/src/utils/gettexthelper.h
deleted file mode 100644
index d42266d45..000000000
--- a/src/utils/gettexthelper.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 UTILS_GETTEXTHELPER_H
-#define UTILS_GETTEXTHELPER_H
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif // HAVE_CONFIG_H
-
-#include "localconsts.h"
-
-class GettextHelper final
-{
- public:
- A_DELETE_COPY(GettextHelper)
-
- static void initLang();
-
- private:
-#ifdef ENABLE_NLS
- static void bindTextDomain(const char *const path);
-#else // ENABLE_NLS
- static void bindTextDomain(const char *const path A_UNUSED);
-#endif // ENABLE_NLS
-};
-
-#endif // UTILS_GETTEXTHELPER_H
diff --git a/src/utils/glxhelper.cpp b/src/utils/glxhelper.cpp
deleted file mode 100644
index 8525111dc..000000000
--- a/src/utils/glxhelper.cpp
+++ /dev/null
@@ -1,142 +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 "utils/glxhelper.h"
-
-#if defined(USE_OPENGL) && defined(USE_X11)
-
-#include "logger.h"
-
-#include "render/opengl/mglcheck.h"
-
-#include "render/openglx/mglx.h"
-
-#include "render/opengl/mgldefines.h"
-RENDER_OPENGL_MGLDEFINES_H
-
-#include "debug.h"
-
-static int ErrorHandler(Display *d A_UNUSED, XErrorEvent *e A_UNUSED)
-{
- return 0;
-}
-
-void *GlxHelper::createContext(const unsigned long window,
- void *const display0,
- const int major,
- const int minor,
- const int profile)
-{
- Display *const display = static_cast<Display*>(display0);
- XSync(display, false);
- int (*handler)(Display *, XErrorEvent *) = XSetErrorHandler(ErrorHandler);
- void *context = mglXGetCurrentContext();
- if (!display)
- return context;
- if (isGLNull(mglXGetCurrentContext)
- || isGLNull(mglXCreateContextAttribs)
- || isGLNull(mglXChooseFBConfig))
- {
- logger->log("Can't change context, functions in driver "
- "not implemented");
- XSetErrorHandler(handler);
- return context;
- }
- if (!context)
- {
- logger->log("Can't change context, because current "
- "context not created");
- XSetErrorHandler(handler);
- return context;
- }
- int glxAttribs[] =
- {
- GLX_RENDER_TYPE, GLX_RGBA_BIT,
- GLX_RED_SIZE, 3,
- GLX_GREEN_SIZE, 3,
- GLX_BLUE_SIZE, 2,
- GLX_DOUBLEBUFFER, 1,
- 0
- };
-
- int fbcount = 0;
- GLXFBConfig *framebuffer_config = mglXChooseFBConfig(display,
- DefaultScreen(display),
- glxAttribs,
- &fbcount);
-
- if (!framebuffer_config || !fbcount)
- {
- logger->log("No correct fb profile found");
- XSetErrorHandler(handler);
- return nullptr;
- }
- logger->log("Found %d frame buffer contexts.", fbcount);
-
- int attribs[] =
- {
- GLX_CONTEXT_MAJOR_VERSION_ARB, major,
- GLX_CONTEXT_MINOR_VERSION_ARB, minor,
- GLX_CONTEXT_PROFILE_MASK_ARB, profile,
- 0, 0
- };
-
- void *const context2 = mglXCreateContextAttribs(display,
- framebuffer_config[0], context, true, attribs);
- if (!context2)
- {
- logger->log("context %d.%d creation failed", major, minor);
- XSetErrorHandler(handler);
- return nullptr;
- }
-
- XSync(display, false);
- XSetErrorHandler(handler);
-
- if (!mglXMakeCurrent(display, window, context2))
- {
- mglXDestroyContext(display, context2);
- logger->log("make current context %d.%d failed", major, minor);
- return nullptr;
- }
-
- if (mglXGetCurrentContext() != context2)
- {
- mglXDestroyContext(display, context2);
- logger->log("context cant be changed to %d.%d.", major, minor);
- return nullptr;
- }
-
-// do not delete SDL context, because on exit it will crash
-// mglXDestroyContext(display, context);
- logger->log("Context for %d.%d created", major, minor);
- return context2;
-}
-
-bool GlxHelper::makeCurrent(const unsigned long window,
- void *const display,
- void *const context)
-{
- if (!display)
- return false;
- return mglXMakeCurrent(static_cast<Display*>(display), window, context);
-}
-
-#endif // defined(USE_OPENGL) && defined(USE_X11)
diff --git a/src/utils/glxhelper.h b/src/utils/glxhelper.h
deleted file mode 100644
index c3f1be142..000000000
--- a/src/utils/glxhelper.h
+++ /dev/null
@@ -1,42 +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 UTILS_GLXHELPER_H
-#define UTILS_GLXHELPER_H
-
-#if defined(USE_OPENGL) && defined(USE_X11)
-
-#include "localconsts.h"
-
-namespace GlxHelper
-{
- void *createContext(const unsigned long window,
- void *const display,
- const int major,
- const int minor,
- const int profile);
-
- bool makeCurrent(const unsigned long window,
- void *const display,
- void *const context);
-} // namespace GlxHelper
-
-#endif // defined(USE_OPENGL) && defined(USE_X11)
-#endif // UTILS_GLXHELPER_H
diff --git a/src/utils/gmfunctions.cpp b/src/utils/gmfunctions.cpp
deleted file mode 100644
index e6abc3e83..000000000
--- a/src/utils/gmfunctions.cpp
+++ /dev/null
@@ -1,122 +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 "utils/gmfunctions.h"
-
-#include "settings.h"
-
-#include "being/localplayer.h"
-
-#include "const/gui/chat.h"
-
-#include "net/chathandler.h"
-
-#include "debug.h"
-
-namespace Gm
-{
-
-void runCommand(const std::string &command,
- const std::string &params)
-{
- if (params.empty())
- {
- chatHandler->talk(std::string(
- settings.gmCommandSymbol).append(
- command),
- GENERAL_CHANNEL);
- }
- else
- {
- chatHandler->talk(std::string(
- settings.gmCommandSymbol).append(
- command).append(
- " ").append(
- params),
- GENERAL_CHANNEL);
- }
-}
-
-void runCommand(const std::string &command)
-{
- chatHandler->talk(std::string(
- settings.gmCommandSymbol).append(
- command),
- GENERAL_CHANNEL);
-}
-
-void runCharCommand(const std::string &command,
- const std::string &name,
- const std::string &params)
-{
- if ((localPlayer != nullptr) && name == localPlayer->getName())
- {
- if (params.empty())
- {
- chatHandler->talk(std::string(
- settings.gmCommandSymbol).append(
- command),
- GENERAL_CHANNEL);
- }
- else
- {
- chatHandler->talk(std::string(
- settings.gmCommandSymbol).append(
- command).append(
- " ").append(
- params),
- GENERAL_CHANNEL);
- }
- }
- else
- {
- chatHandler->talk(std::string(
- settings.gmCharCommandSymbol).append(
- command).append(
- " \"").append(
- name).append(
- "\" ").append(
- params),
- GENERAL_CHANNEL);
- }
-}
-
-void runCharCommand(const std::string &command,
- const std::string &name)
-{
- if ((localPlayer != nullptr) && name == localPlayer->getName())
- {
- chatHandler->talk(std::string(
- settings.gmCommandSymbol).append(
- command),
- GENERAL_CHANNEL);
- }
- else
- {
- chatHandler->talk(std::string(
- settings.gmCharCommandSymbol).append(
- command).append(
- " ").append(
- name),
- GENERAL_CHANNEL);
- }
-}
-
-} // namespace Gm
diff --git a/src/utils/gmfunctions.h b/src/utils/gmfunctions.h
deleted file mode 100644
index 3670b4b67..000000000
--- a/src/utils/gmfunctions.h
+++ /dev/null
@@ -1,43 +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 UTILS_GMFUNCTIONS_H
-#define UTILS_GMFUNCTIONS_H
-
-#include <string>
-
-#include "localconsts.h"
-
-namespace Gm
-{
- void runCommand(const std::string &command,
- const std::string &params);
-
- void runCommand(const std::string &command);
-
- void runCharCommand(const std::string &command,
- const std::string &name,
- const std::string &params);
-
- void runCharCommand(const std::string &command,
- const std::string &name);
-} // namespace Gm
-
-#endif // UTILS_GMFUNCTIONS_H
diff --git a/src/utils/intmap.h b/src/utils/intmap.h
deleted file mode 100644
index d2786aa77..000000000
--- a/src/utils/intmap.h
+++ /dev/null
@@ -1,30 +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 UTILS_INTMAP_H
-#define UTILS_INTMAP_H
-
-#include <map>
-
-typedef std::map<int, int> IntMap;
-typedef IntMap::iterator IntMapIter;
-typedef IntMap::const_iterator IntMapCIter;
-
-#endif // UTILS_INTMAP_H
diff --git a/src/utils/langs.cpp b/src/utils/langs.cpp
deleted file mode 100644
index b4672197a..000000000
--- a/src/utils/langs.cpp
+++ /dev/null
@@ -1,123 +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 "utils/langs.h"
-
-#include "configuration.h"
-
-#ifndef DYECMD
-#include "being/playerinfo.h"
-
-#include "resources/db/languagedb.h"
-#endif // DYECMD
-
-#include "debug.h"
-
-static const char *getLangName()
-{
- const char *const lang = getenv("LANG");
- if ((lang != nullptr) && strlen(lang) > 1000)
- return nullptr;
- return lang;
-}
-
-LangVect getLang()
-{
- LangVect langs;
- std::string lang = config.getStringValue("lang");
- if (lang.empty())
- {
- const char *const lng = getLangName();
- if (lng == nullptr)
- return langs;
- lang = lng;
- }
- else if (lang.size() > 1000)
- {
- return langs;
- }
-
- size_t dot = lang.find('.');
- if (dot != std::string::npos)
- lang = lang.substr(0, dot);
- langs.push_back(lang);
- dot = lang.find('_');
- if (dot != std::string::npos)
- langs.push_back(lang.substr(0, dot));
- return langs;
-}
-
-LangVect getServerLang()
-{
- LangVect langs;
-#ifndef DYECMD
- const int id = PlayerInfo::getServerLanguage();
- const std::string &lang = LanguageDb::getPo(id);
- if (lang.empty())
- return langs;
- langs.push_back(lang);
- const size_t idx = lang.find('_');
- if (idx != std::string::npos)
- langs.push_back(lang.substr(0, idx));
-#endif // DYECMD
-
- return langs;
-}
-
-std::string getLangSimple()
-{
- const std::string lang = config.getStringValue("lang");
- if (lang.empty())
- {
- const char *const lng = getLangName();
- if (lng == nullptr)
- return "";
- return lng;
- }
- else if (lang.size() > 1000)
- {
- return "";
- }
- return lang;
-}
-
-std::string getLangShort()
-{
- std::string lang = config.getStringValue("lang");
- if (lang.empty())
- {
- const char *const lng = getLangName();
- if (lng == nullptr)
- return "";
- lang = lng;
- }
- else if (lang.size() > 1000)
- {
- return "";
- }
-
- size_t dot = lang.find('.');
- if (dot != std::string::npos)
- lang = lang.substr(0, dot);
- dot = lang.find('_');
- if (dot != std::string::npos)
- return lang.substr(0, dot);
- return lang;
-}
diff --git a/src/utils/langs.h b/src/utils/langs.h
deleted file mode 100644
index 63a6f9674..000000000
--- a/src/utils/langs.h
+++ /dev/null
@@ -1,41 +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 UTILS_LANGS_H
-#define UTILS_LANGS_H
-
-#include "utils/vector.h"
-
-#include <string>
-
-#include "localconsts.h"
-
-typedef STD_VECTOR<std::string> LangVect;
-typedef LangVect::const_iterator LangIter;
-
-LangVect getLang() A_WARN_UNUSED;
-
-LangVect getServerLang() A_WARN_UNUSED;
-
-std::string getLangSimple() A_WARN_UNUSED;
-
-std::string getLangShort() A_WARN_UNUSED;
-
-#endif // UTILS_LANGS_H
diff --git a/src/utils/likely.h b/src/utils/likely.h
deleted file mode 100644
index 0df22a379..000000000
--- a/src/utils/likely.h
+++ /dev/null
@@ -1,32 +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 UTILS_LIKELY_H
-#define UTILS_LIKELY_H
-
-#ifdef __GNUC__
-#define A_LIKELY(x) __builtin_expect (!!(x), 1)
-#define A_UNLIKELY(x) __builtin_expect (!!(x), 0)
-#else // __GNUC__
-#define A_LIKELY(x) (x)
-#define A_UNLIKELY(x) (x)
-#endif // __GNUC__
-
-#endif // UTILS_LIKELY_H
diff --git a/src/utils/mathutils.h b/src/utils/mathutils.h
deleted file mode 100644
index 045feb10a..000000000
--- a/src/utils/mathutils.h
+++ /dev/null
@@ -1,251 +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 UTILS_MATHUTILS_H
-#define UTILS_MATHUTILS_H
-
-#include "utils/cast.h"
-
-#include <string>
-
-#ifndef USE_SDL2
-#include <cmath>
-#endif // USE_SDL2
-
-#include "localconsts.h"
-
-static constexpr const uint16_t crc_table[256] =
-{
- 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
- 0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef,
- 0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6,
- 0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de,
- 0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485,
- 0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d,
- 0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4,
- 0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc,
- 0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823,
- 0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b,
- 0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12,
- 0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a,
- 0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41,
- 0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49,
- 0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70,
- 0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78,
- 0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f,
- 0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067,
- 0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e,
- 0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256,
- 0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d,
- 0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,
- 0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c,
- 0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634,
- 0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab,
- 0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3,
- 0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a,
- 0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92,
- 0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9,
- 0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1,
- 0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8,
- 0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0
-};
-
-static constexpr const uint8_t square_roots[1000] =
-{
- 0, 1, 1, 1, 2, 2, 2, 2, 2, 3,
- 3, 3, 3, 3, 3, 3, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 5, 5, 5, 5, 5,
- 5, 5, 5, 5, 5, 5, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 8, 8, 8, 8, 8, 8,
- 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
- 8, 9, 9, 9, 9, 9, 9, 9, 9, 9,
- 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 17,
- 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 18, 18, 18, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
- 18, 19, 19, 19, 19, 19, 19, 19, 19, 19,
- 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
- 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
- 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
- 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- 20, 21, 21, 21, 21, 21, 21, 21, 21, 21,
- 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
- 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
- 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
- 21, 21, 21, 21, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 26, 26, 26, 26,
- 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
- 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
- 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
- 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
- 26, 26, 26, 26, 26, 26, 26, 26, 26, 27,
- 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
- 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
- 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
- 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
- 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
- 27, 27, 27, 27, 28, 28, 28, 28, 28, 28,
- 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
- 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
- 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
- 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
- 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
- 28, 29, 29, 29, 29, 29, 29, 29, 29, 29,
- 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
- 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
- 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
- 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
- 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
- 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
- 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
- 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
- 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
- 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
- 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
- 30, 31, 31, 31, 31, 31, 31, 31, 31, 31,
- 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
- 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
- 31, 31, 31, 31, 31, 31, 31, 31, 31, 31
-};
-
-inline uint16_t getCrc16(const std::string &str) A_WARN_UNUSED;
-constexpr2 inline float fastInvSqrt(float x) A_WARN_UNUSED;
-constexpr2 inline float fastSqrt(const float x) A_WARN_UNUSED;
-constexpr inline float weightedAverage(const float n1, const float n2,
- const float w) A_WARN_UNUSED;
-constexpr inline int roundDouble(const double v) A_WARN_UNUSED;
-constexpr2 inline int powerOfTwo(const unsigned int input) A_WARN_UNUSED;
-constexpr2 inline int fastSqrtInt(const unsigned int n) A_WARN_UNUSED;
-
-inline uint16_t getCrc16(const std::string &str)
-{
- size_t f = str.size();
- uint16_t crc16 = 0xffff;
-
- while (f != 0)
- {
- f --;
- crc16 = CAST_U16(
- crc_table[(crc16 ^ (str[f])) & 0xff] ^ (crc16 >> 8));
- }
-
- return crc16;
-}
-
-/* A very fast function to calculate the approximate inverse square root of a
- * floating point value and a helper function that uses it for getting the
- * normal squareroot. For an explanation of the inverse squareroot function
- * read:
- * http://www.math.purdue.edu/~clomont/Math/Papers/2003/InvSqrt.pdf
- *
- * Unfortunately the original creator of this function seems to be unknown.
- */
-
-constexpr2 inline float fastInvSqrt(float x)
-{
- union { int i; float x; } tmp = {0U};
- const float xhalf = 0.5F * x;
- tmp.x = x;
- tmp.i = 0x5f375a86 - (tmp.i >> 1);
- x = tmp.x;
- x = x * (1.5F - xhalf * x * x);
- return x;
-}
-
-constexpr2 inline float fastSqrt(const float x)
-{
- return 1.0F / fastInvSqrt(x);
-}
-
-constexpr inline float weightedAverage(const float n1, const float n2,
- const float w)
-{
- return w < 0.0F ? n1 : (w > 1.0F ? n2 : w * n2 + (1.0F - w) * n1);
-}
-
-constexpr inline int roundDouble(const double v)
-{
- return (v > 0.0) ? CAST_S32(v + 0.5) : CAST_S32(v - 0.5);
-}
-
-constexpr2 inline int powerOfTwo(const unsigned int input)
-{
- unsigned int value = 1;
- while (value < input)
- value <<= 1;
- return value;
-}
-
-constexpr2 inline int fastSqrtInt(const unsigned int n)
-{
- if (n < 1000)
- return CAST_S32(square_roots[n]);
- return CAST_S32(sqrt(n));
-}
-
-#endif // UTILS_MATHUTILS_H
diff --git a/src/utils/mrand.cpp b/src/utils/mrand.cpp
deleted file mode 100644
index 1e74e815a..000000000
--- a/src/utils/mrand.cpp
+++ /dev/null
@@ -1,45 +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 "utils/mrand.h"
-
-#include <cstdlib>
-
-#include "debug.h"
-
-namespace
-{
- constexpr const int randNumbers = 1024;
- int mPos = 0;
- int mRand[randNumbers];
-} // namespace
-
-void initRand()
-{
- for (int f = 0; f < randNumbers; f ++)
- mRand[f] = std::rand();
-}
-
-int mrand()
-{
- if (mPos >= randNumbers)
- mPos = 0;
- return mRand[mPos++];
-}
diff --git a/src/utils/mrand.h b/src/utils/mrand.h
deleted file mode 100644
index 8153554b7..000000000
--- a/src/utils/mrand.h
+++ /dev/null
@@ -1,30 +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 UTILS_MRAND_H
-#define UTILS_MRAND_H
-
-#include "localconsts.h"
-
-void initRand();
-
-int mrand();
-
-#endif // UTILS_MRAND_H
diff --git a/src/utils/mutex.h b/src/utils/mutex.h
deleted file mode 100644
index 3703d20ab..000000000
--- a/src/utils/mutex.h
+++ /dev/null
@@ -1,110 +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 UTILS_MUTEX_H
-#define UTILS_MUTEX_H
-
-#include "logger.h"
-
-/**
- * A mutex provides mutual exclusion of access to certain data that is
- * accessed by multiple threads.
- */
-class Mutex final
-{
- public:
- Mutex();
-
- A_DELETE_COPY(Mutex)
-
- ~Mutex();
-
- void lock();
-
- void unlock();
-
- private:
-// Mutex(const Mutex&); // prevent copying
-// Mutex& operator=(const Mutex&);
-
- SDL_mutex *mMutex;
-};
-
-/**
- * A convenience class for locking a mutex.
- */
-class MutexLocker final
-{
- public:
- explicit MutexLocker(Mutex *const mutex);
-
- MutexLocker(const MutexLocker &m) :
- mMutex(m.mMutex)
- {
- }
-
- A_DEFAULT_COPY(MutexLocker)
-
- ~MutexLocker();
-
- private:
- Mutex *mMutex;
-};
-
-
-inline Mutex::Mutex() :
- mMutex(SDL_CreateMutex())
-{
-}
-
-inline Mutex::~Mutex()
-{
- SDL_DestroyMutex(mMutex);
-}
-
-inline void Mutex::lock()
-{
- if (SDL_mutexP(mMutex) == -1)
- logger->log("Mutex locking failed: %s", SDL_GetError());
-}
-
-inline void Mutex::unlock()
-{
- if (SDL_mutexV(mMutex) == -1)
- logger->log("Mutex unlocking failed: %s", SDL_GetError());
-}
-
-
-inline MutexLocker::MutexLocker(Mutex *const mutex) :
- mMutex(mutex)
-{
- if (mMutex != nullptr)
- mMutex->lock();
-}
-
-inline MutexLocker::~MutexLocker()
-{
- if (mMutex != nullptr)
- mMutex->unlock();
-}
-
-#endif // UTILS_MUTEX_H
diff --git a/src/utils/naclmessages.cpp b/src/utils/naclmessages.cpp
deleted file mode 100644
index 44e6aba1b..000000000
--- a/src/utils/naclmessages.cpp
+++ /dev/null
@@ -1,109 +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/>.
- */
-
-#ifdef __native_client__
-
-#include "utils/naclmessages.h"
-
-#include <ppapi_simple/ps.h>
-#include <ppapi_simple/ps_event.h>
-#include <ppapi/cpp/instance.h>
-#include <ppapi/cpp/var.h>
-
-#include <mutex>
-#include <condition_variable>
-
-#include "debug.h"
-
-struct NaclMessageHandle final
-{
- NaclMessageHandle() :
- handled(false),
- type(),
- message(),
- condv()
- { }
-
- A_DELETE_COPY(NaclMessageHandle)
-
- bool handled;
- std::string type;
- std::string message;
- std::condition_variable condv;
-};
-
-void naclPostMessage(const std::string &type,
- const std::string &message)
-{
- pp::Var msgVar = pp::Var(std::string(type).append(":").append(message));
- pp::Instance(PSGetInstanceId()).PostMessage(msgVar);
-}
-
-static void naclMessageHandlerFunc(struct PP_Var key,
- struct PP_Var value,
- void* user_data)
-{
- NaclMessageHandle *handle = reinterpret_cast<NaclMessageHandle *>(
- user_data);
-
- if (key.type != PP_VARTYPE_STRING || value.type != PP_VARTYPE_STRING)
- return;
- if (pp::Var(key).AsString() != handle->type)
- return;
-
- handle->handled = true;
- handle->message = pp::Var(value).AsString();
-
- handle->condv.notify_one();
-}
-
-NaclMessageHandle *naclRegisterMessageHandler(const std::string &type)
-{
- NaclMessageHandle *handle = new NaclMessageHandle;
- handle->handled = false;
- handle->type = type;
-
- PSEventRegisterMessageHandler(type.c_str(),
- naclMessageHandlerFunc,
- reinterpret_cast<void *>(handle));
- return handle;
-}
-
-void naclUnregisterMessageHandler(NaclMessageHandle *handle)
-{
- PSEventRegisterMessageHandler(handle->type.c_str(),
- nullptr,
- nullptr);
- delete handle;
-}
-
-std::string naclWaitForMessage(NaclMessageHandle *handle)
-{
- std::mutex mtx;
- std::unique_lock <std::mutex> lck(mtx);
-
- while (!handle->handled)
- handle->condv.wait(lck);
-
- handle->handled = false;
- return handle->message;
-}
-
-#endif // __native_client__
diff --git a/src/utils/naclmessages.h b/src/utils/naclmessages.h
deleted file mode 100644
index 1165b973e..000000000
--- a/src/utils/naclmessages.h
+++ /dev/null
@@ -1,41 +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 UTILS_NACLMESSAGES_H
-#define UTILS_NACLMESSAGES_H
-
-#ifdef __native_client__
-
-#include <string>
-
-#include "localconsts.h"
-
-struct NaclMessageHandle;
-
-void naclPostMessage(const std::string &type, const std::string &message);
-
-NaclMessageHandle *naclRegisterMessageHandler(const std::string &type);
-
-void naclUnregisterMessageHandler(NaclMessageHandle *handle);
-
-std::string naclWaitForMessage(NaclMessageHandle *handle);
-
-#endif // __native_client__
-#endif // UTILS_NACLMESSAGES_H
diff --git a/src/utils/parameters.cpp b/src/utils/parameters.cpp
deleted file mode 100644
index 019f7c239..000000000
--- a/src/utils/parameters.cpp
+++ /dev/null
@@ -1,119 +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 "utils/parameters.h"
-
-#include "utils/stringutils.h"
-
-#include "debug.h"
-
-static inline void addToken(StringVect &tokens,
- std::string str) A_INLINE;
-static inline void addToken(StringVect &tokens,
- std::string str)
-{
- std::string item = trim(str);
- const size_t sz = item.size();
- if (sz > 1)
- {
- if (str[0] == '\"' &&
- str[sz - 1] == '\"' &&
- str[sz - 2] != '\\')
- {
- item = item.substr(1, sz - 2);
- replaceAll(item, "\\\"", "\"");
- tokens.push_back(item);
- return;
- }
- }
- replaceAll(item, "\\\"", "\"");
- if (!item.empty())
- tokens.push_back(item);
-}
-
-static inline size_t findNextQuote(const std::string &str,
- const char quote,
- const size_t pos) A_INLINE;
-static inline size_t findNextQuote(const std::string &str,
- const char quote,
- const size_t pos)
-{
- size_t idx = str.find(quote, pos);
- while (idx > 0 &&
- idx != std::string::npos &&
- str[idx - 1] == '\\')
- {
- idx = str.find(quote, idx + 1);
- }
- return idx;
-}
-
-static inline size_t findNextSplit(const std::string &str,
- const std::string &separator,
- const char quote) A_INLINE;
-static inline size_t findNextSplit(const std::string &str,
- const std::string &separator,
- const char quote)
-{
- size_t pos = 0;
- while (true)
- {
- // search for next separator
- size_t idx1 = findAny(str, separator, pos);
- // search for next open quote, skipping escaped quotes
- size_t idx2 = findNextQuote(str, quote, pos);
- if (idx2 == std::string::npos) // not quotes, return next separator
- return idx1;
- else if (idx1 == std::string::npos) // also no separators, return npos
- return std::string::npos;
-
- if (idx2 < idx1)
- { // first is quote and after separator: for example "test line", ...
- idx2 = findNextQuote(str, quote, idx2 + 1);
- if (idx2 == std::string::npos)
- return std::string::npos; // no close quote, here error
- // set position for next separator or quote
- pos = idx2 + 1;
- }
- else
- {
- return idx1;
- }
- }
-}
-
-bool splitParameters(StringVect &tokens,
- std::string text,
- const std::string &separator,
- const char quote)
-{
- size_t idx = findNextSplit(text, separator, quote);
-
- while (idx != std::string::npos)
- {
- std::string item = text.substr(0, idx);
- addToken(tokens, item);
- text = text.substr(idx + 1);
- idx = findNextSplit(text, separator, quote);
- }
-
- addToken(tokens, text);
- return true;
-}
diff --git a/src/utils/parameters.h b/src/utils/parameters.h
deleted file mode 100644
index 0f1827428..000000000
--- a/src/utils/parameters.h
+++ /dev/null
@@ -1,33 +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 UTILS_PARAMETERS_H
-#define UTILS_PARAMETERS_H
-
-#include "utils/stringvector.h"
-
-#include "localconsts.h"
-
-bool splitParameters(StringVect &tokens,
- std::string text,
- const std::string &separator,
- const char quote);
-
-#endif // UTILS_PARAMETERS_H
diff --git a/src/utils/perfomance.cpp b/src/utils/perfomance.cpp
deleted file mode 100644
index 226c3d244..000000000
--- a/src/utils/perfomance.cpp
+++ /dev/null
@@ -1,100 +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 "localconsts.h"
-
-#ifdef USE_PROFILER
-
-#include "utils/perfomance.h"
-
-#include "configuration.h"
-#include "game.h"
-
-#include "utils/timer.h"
-
-#include <algorithm>
-#include <cstdarg>
-#include <cstdio>
-#include <fcntl.h>
-#include <fstream>
-#include <iostream>
-
-#include "debug.h"
-
-static const clockid_t clockType = CLOCK_MONOTONIC;
-
-#define timeData ((static_cast<long long int>(time.tv_sec) * 1000000000LL \
- + static_cast<long long int>(time.tv_nsec)) / 1)
-
-namespace Perfomance
-{
- std::ofstream file;
- std::string temp;
- long long unsigned int startTime;
-
- void init(const std::string &path)
- {
- file.open(path.c_str(), std::ios_base::trunc);
- timespec time;
- clock_gettime(clockType, &time);
- temp.reserve(10000000U);
- startTime = timeData;
- }
-
- void clear()
- {
- if (file.is_open())
- file.close();
- }
-
- void start()
- {
- timespec time;
- clock_gettime(clockType, &time);
- temp.append(toString(timeData - startTime)).append(
- " __init__\n");
- }
-
- void blockStart(const std::string &name)
- {
- timespec time;
- clock_gettime(clockType, &time);
- temp.append(toString(timeData - startTime)).append(
- " start: ").append(name).append("\n");
- }
-
- void blockEnd(const std::string &name)
- {
- timespec time;
- clock_gettime(clockType, &time);
- temp.append(toString(timeData - startTime)).append(
- " end: ").append(name).append("\n");
- }
-
- void flush()
- {
- if (fps < 40)
- file << temp;
- temp.clear();
-// file.flush();
- }
-} // namespace Perfomance
-
-#endif // USE_PROFILER
diff --git a/src/utils/perfomance.h b/src/utils/perfomance.h
deleted file mode 100644
index 1e8688551..000000000
--- a/src/utils/perfomance.h
+++ /dev/null
@@ -1,83 +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 UTILS_PERFOMANCE_H
-#define UTILS_PERFOMANCE_H
-
-#ifdef USE_PROFILER
-#include "utils/vector.h"
-
-#include <string>
-#include <sstream>
-#include <list>
-#include <set>
-
-#include "localconsts.h"
-
-#define PROFILER_START() Perfomance::start();
-#define PROFILER_END() Perfomance::flush();
-#define BLOCK_START(name) Perfomance::blockStart(name);
-#define BLOCK_END(name) Perfomance::blockEnd(name);
-#define FUNC_BLOCK(name, id) Perfomance::Func PerfomanceFunc##id(name);
-
-namespace Perfomance
-{
- void start();
-
- void init(const std::string &path);
-
- void clear();
-
- void blockStart(const std::string &name);
-
- void blockEnd(const std::string &name);
-
- void flush();
-
- class Func final
- {
- public:
- explicit Func(const std::string &str) :
- name(str)
- {
- blockStart(str);
- }
-
- A_DELETE_COPY(Func)
-
- ~Func()
- {
- blockEnd(name);
- }
-
- std::string name;
- };
-} // namespace Perfomance
-
-#else // USE_PROFILER
-
-#define PROFILER_START()
-#define PROFILER_END()
-#define BLOCK_START(name)
-#define BLOCK_END(name)
-#define FUNC_BLOCK(name, id)
-
-#endif // USE_PROFILER
-#endif // UTILS_PERFOMANCE_H
diff --git a/src/utils/pnglib.cpp b/src/utils/pnglib.cpp
deleted file mode 100644
index d472bd565..000000000
--- a/src/utils/pnglib.cpp
+++ /dev/null
@@ -1,113 +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 "utils/pnglib.h"
-
-#include "utils/cast.h"
-#include "utils/checkutils.h"
-
-#include <png.h>
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_video.h>
-PRAGMA48(GCC diagnostic pop)
-
-#include "debug.h"
-
-bool PngLib::writePNG(SDL_Surface *const surface,
- const std::string &filename)
-{
- if (surface == nullptr)
- return false;
-
-
- if (SDL_MUSTLOCK(surface))
- SDL_LockSurface(surface);
-
- png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
- nullptr, nullptr, nullptr);
- if (png_ptr == nullptr)
- {
- reportAlways("Had trouble creating png_structp");
- return false;
- }
-
- png_infop info_ptr = png_create_info_struct(png_ptr);
- if (info_ptr == nullptr)
- {
- png_destroy_write_struct(&png_ptr, static_cast<png_infopp>(nullptr));
- reportAlways("Could not create png_info");
- return false;
- }
-
- if (setjmp(png_jmpbuf(png_ptr)))
- {
- png_destroy_write_struct(&png_ptr, &info_ptr);
- reportAlways("problem writing to %s", filename.c_str());
- return false;
- }
-
- FILE *const fp = fopen(filename.c_str(), "wb");
- if (fp == nullptr)
- {
- reportAlways("could not open file %s for writing",
- filename.c_str());
- return false;
- }
-
- png_init_io(png_ptr, fp);
-
- const int colortype = (surface->format->BitsPerPixel == 24) ?
- PNG_COLOR_TYPE_RGB : PNG_COLOR_TYPE_RGB_ALPHA;
-
- png_set_IHDR(png_ptr, info_ptr, surface->w, surface->h, 8, colortype,
- PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT,
- PNG_FILTER_TYPE_DEFAULT);
-
- png_write_info(png_ptr, info_ptr);
-
- png_set_packing(png_ptr);
-
- png_bytep *const row_pointers
- = new png_bytep[CAST_SIZE(surface->h)];
-
- for (int i = 0; i < surface->h; i++)
- {
- row_pointers[i] = static_cast<png_bytep>(static_cast<uint8_t *>(
- surface->pixels) + CAST_SIZE(i * surface->pitch));
- }
-
- png_write_image(png_ptr, row_pointers);
- png_write_end(png_ptr, info_ptr);
-
- fclose(fp);
-
- delete [] row_pointers;
-
- png_destroy_write_struct(&png_ptr,
- &info_ptr);
-
- if (SDL_MUSTLOCK(surface))
- SDL_UnlockSurface(surface);
-
- return true;
-}
diff --git a/src/utils/pnglib.h b/src/utils/pnglib.h
deleted file mode 100644
index 11f5c1581..000000000
--- a/src/utils/pnglib.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 UTILS_PNGLIB_H
-#define UTILS_PNGLIB_H
-
-#include <string>
-
-#include "localconsts.h"
-
-struct SDL_Surface;
-
-namespace PngLib
-{
- bool writePNG(SDL_Surface *const surface,
- const std::string &filename);
-} // namespace PngLib
-
-#endif // UTILS_PNGLIB_H
diff --git a/src/utils/process.cpp b/src/utils/process.cpp
deleted file mode 100644
index c4639e4db..000000000
--- a/src/utils/process.cpp
+++ /dev/null
@@ -1,328 +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 "utils/process.h"
-
-#include <unistd.h>
-
-#include "localconsts.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#ifdef USE_SDL2
-#ifdef ANDROID
-#include <SDL_system.h>
-#endif // ANDROID
-#endif // USE_SDL2
-PRAGMA48(GCC diagnostic pop)
-
-#include "debug.h"
-
-#ifndef __native_client__
-const int timeOut = 10;
-#endif // __native_client__
-
-#ifdef WIN32
-
-#include "utils/stringutils.h"
-
-#include <windows.h>
-
-int execFileWait(const std::string &pathName, const std::string &name A_UNUSED,
- const std::string &arg1, const std::string &arg2,
- const int waitTime A_UNUSED)
-{
-// if (!waitTime)
-// waitTime = timeOut;
-
- STARTUPINFO siStartupInfo;
- PROCESS_INFORMATION piProcessInfo;
- memset(&siStartupInfo, 0, sizeof(siStartupInfo));
- memset(&piProcessInfo, 0, sizeof(piProcessInfo));
- siStartupInfo.cb = sizeof(siStartupInfo);
- DWORD ret = -1;
- std::string args(std::string(pathName).append(" ").append(arg1));
- if (!arg2.empty())
- args.append(" ").append(arg2);
-
- if (CreateProcess(pathName.c_str(), const_cast<char*>(args.c_str()),
- nullptr, nullptr, false, CREATE_DEFAULT_ERROR_MODE, nullptr, nullptr,
- &siStartupInfo, &piProcessInfo) != false)
- {
- if (!WaitForSingleObject(piProcessInfo.hProcess, timeOut * 1000))
- {
- if (GetExitCodeProcess(piProcessInfo.hProcess, &ret))
- {
- CloseHandle(piProcessInfo.hProcess);
- CloseHandle(piProcessInfo.hThread);
- return ret;
- }
- }
- TerminateProcess(piProcessInfo.hProcess, -1);
- }
-
- CloseHandle(piProcessInfo.hProcess);
- CloseHandle(piProcessInfo.hThread);
- return -1;
-}
-
-bool execFile(const std::string &pathName, const std::string &name A_UNUSED,
- const std::string &arg1, const std::string &arg2)
-{
- STARTUPINFO siStartupInfo;
- PROCESS_INFORMATION piProcessInfo;
- memset(&siStartupInfo, 0, sizeof(siStartupInfo));
- memset(&piProcessInfo, 0, sizeof(piProcessInfo));
- siStartupInfo.cb = sizeof(siStartupInfo);
- std::string args(std::string(pathName).append(" ").append(arg1));
- if (!arg2.empty())
- args.append(" ").append(arg2);
-
- bool res = CreateProcess(pathName.c_str(), const_cast<char*>(
- args.c_str()), nullptr, nullptr, false,
- CREATE_DEFAULT_ERROR_MODE, nullptr, nullptr, &siStartupInfo,
- &piProcessInfo);
-
- CloseHandle(piProcessInfo.hProcess);
- CloseHandle(piProcessInfo.hThread);
- return res;
-}
-
-
-#elif defined __linux__ || defined __linux || defined __APPLE__
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
-#include <csignal>
-
-int execFileWait(const std::string &pathName, const std::string &name,
- const std::string &arg1, const std::string &arg2,
- int waitTime)
-{
- pid_t mon_pid;
- int status;
-
- if (waitTime == 0)
- waitTime = timeOut;
-
- if ((mon_pid = fork()) == -1)
- { // fork error
- return -1;
- }
- else if (mon_pid == 0)
- { // monitoring child
- pid_t pid;
- if ((pid = fork()) == -1)
- { // fork error
- return -1;
- }
- else if (pid == 0)
- { // work child
- if (arg2.empty())
- {
- execl(pathName.c_str(), name.c_str(),
- arg1.c_str(), static_cast<char *>(nullptr));
- }
- else
- {
- execl(pathName.c_str(), name.c_str(), arg1.c_str(),
- arg2.c_str(), static_cast<char *>(nullptr));
- }
- _exit(-1);
- }
-
- // monitoring process
- pid_t sleep_pid;
- if ((sleep_pid = fork()) == -1)
- { // fork error
- return -1;
- }
- else if (sleep_pid == 0)
- { // sleep pid
- sleep(waitTime);
- execl("/bin/true", "/bin/true", static_cast<char *>(nullptr));
- _exit(-1);
- }
-
- // monitoring process
- const pid_t exited_pid = wait(&status);
- int ret = -1;
- if (exited_pid == pid)
- {
- kill(sleep_pid, SIGKILL);
- if (WIFEXITED(status))
- ret = WEXITSTATUS(status);
- }
- else
- {
- kill(pid, SIGKILL);
- ret = -1;
- }
- wait(nullptr);
- execl("/bin/true", "/bin/true", static_cast<char *>(nullptr));
- _exit(ret);
- }
-
- // monitoring parent
- waitpid(mon_pid, &status, 0);
- if (WIFEXITED(status))
- return WEXITSTATUS(status);
-
- return -1;
-}
-
-bool execFile(const std::string &pathName, const std::string &name,
- const std::string &arg1, const std::string &arg2)
-{
- struct stat statbuf;
- // file not exists
- if (stat(pathName.c_str(), &statbuf) != 0)
- return false;
-
- pid_t pid;
- if ((pid = fork()) == -1)
- { // fork error
- return false;
- }
- else if (pid == 0)
- { // work child
- if (arg2.empty())
- {
- execl(pathName.c_str(), name.c_str(),
- arg1.c_str(), static_cast<char *>(nullptr));
- }
- else
- {
- execl(pathName.c_str(), name.c_str(), arg1.c_str(),
- arg2.c_str(), static_cast<char *>(nullptr));
- }
- _exit(-1);
- PRAGMACLANG6(GCC diagnostic push)
- PRAGMACLANG6(GCC diagnostic ignored "-Wunreachable-code-return")
- return false;
- PRAGMACLANG6(GCC diagnostic pop)
- }
- return true;
-}
-
-#else // OTHER
-
-int execFileWait(const std::string &pathName A_UNUSED,
- const std::string &name A_UNUSED,
- const std::string &arg1 A_UNUSED,
- const std::string &arg2 A_UNUSED,
- int waitTime A_UNUSED)
-{
- return -1;
-}
-
-bool execFile(const std::string &pathName A_UNUSED,
- const std::string &name A_UNUSED,
- const std::string &arg1 A_UNUSED,
- const std::string &arg2 A_UNUSED)
-{
- return false;
-}
-
-#endif // WIN32
-
-#if defined WIN64
-bool openBrowser(std::string url)
-{
- return reinterpret_cast<int64_t>(ShellExecute(nullptr, "open",
- replaceAll(url, " ", "").c_str(),
- nullptr, nullptr, SW_SHOWNORMAL)) > 32;
-}
-#elif defined WIN32
-bool openBrowser(std::string url)
-{
- return reinterpret_cast<int32_t>(ShellExecute(nullptr, "open",
- replaceAll(url, " ", "").c_str(),
- nullptr, nullptr, SW_SHOWNORMAL)) > 32;
-}
-#elif defined ANDROID
-#include "utils/stringutils.h"
-#ifndef USE_SDL2
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_screenkeyboard.h>
-PRAGMA48(GCC diagnostic pop)
-#endif // USE_SDL2
-
-bool openBrowser(std::string url)
-{
-#ifdef USE_SDL2
- SDL_OpenBrowser(replaceAll(url, " ", "").c_str());
-#else // USE_SDL2
-
- SDL_ANDROID_OpenBrowser(replaceAll(url, " ", "").c_str());
-#endif // USE_SDL2
-
- return true;
-}
-#elif defined __APPLE__
-bool openBrowser(std::string url)
-{
- return execFile("/usr/bin/open", "/usr/bin/open", url, "");
-}
-#elif defined __OpenBSD__ || defined __FreeBSD__ || defined __DragonFly__
-bool openBrowser(std::string url)
-{
- return execFile("/usr/local/bin/xdg-open",
- "/usr/local/bin/xdg-open", url, "");
-}
-#elif defined __linux__ || defined __linux
-bool openBrowser(std::string url)
-{
- return execFile("/usr/bin/xdg-open", "/usr/bin/xdg-open", url, "");
-}
-#elif defined __native_client__
-
-#include "utils/naclmessages.h"
-
-bool openBrowser(std::string url)
-{
- naclPostMessage("open-browser", url);
- return true;
-}
-#else // OTHER
-bool openBrowser(std::string url)
-{
- return false;
-}
-
-#endif // WIN32
-
-#ifdef WIN32
-void setPriority(const bool big)
-{
- HANDLE hCurrentProcess = GetCurrentProcess();
- if (big)
- SetPriorityClass(hCurrentProcess, ABOVE_NORMAL_PRIORITY_CLASS);
- else
- SetPriorityClass(hCurrentProcess, BELOW_NORMAL_PRIORITY_CLASS);
-}
-#else // WIN32
-
-void setPriority(const bool big A_UNUSED)
-{
-}
-#endif // WIN32
diff --git a/src/utils/process.h b/src/utils/process.h
deleted file mode 100644
index bf622c15b..000000000
--- a/src/utils/process.h
+++ /dev/null
@@ -1,37 +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 UTILS_PROCESS_H
-#define UTILS_PROCESS_H
-
-#include <string>
-
-int execFileWait(const std::string &pathName, const std::string &name,
- const std::string &arg1, const std::string &arg2,
- int waitTime = 0);
-
-bool execFile(const std::string &pathName, const std::string &name,
- const std::string &arg1, const std::string &arg2);
-
-bool openBrowser(std::string url);
-
-void setPriority(const bool big);
-
-#endif // UTILS_PROCESS_H
diff --git a/src/utils/sdl2helper.cpp b/src/utils/sdl2helper.cpp
deleted file mode 100644
index 68fb9cf4d..000000000
--- a/src/utils/sdl2helper.cpp
+++ /dev/null
@@ -1,271 +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/>.
- */
-
-#ifdef USE_SDL2
-
-#include "utils/sdl2helper.h"
-
-#include "logger.h"
-
-#include "utils/foreach.h"
-#include "utils/sdl2logger.h"
-#include "utils/stringutils.h"
-
-#include <algorithm>
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_events.h>
-#include <SDL_hints.h>
-#include <SDL_render.h>
-#include <SDL_syswm.h>
-PRAGMA48(GCC diagnostic pop)
-
-#include "debug.h"
-
-bool SDL::getAllVideoModes(StringVect &modeList)
-{
- std::set<std::string> modes;
- const int numDisplays = SDL_GetNumVideoDisplays();
- for (int display = 0; display < numDisplays; display ++)
- {
- const int numModes = SDL_GetNumDisplayModes(display);
- if (numModes > 0)
- {
- for (int f = 0; f < numModes; f ++)
- {
- SDL_DisplayMode mode;
- SDL_GetDisplayMode(display, f, &mode);
- const int w = mode.w;
- const int h = mode.h;
- logger->log("%dx%dx%d", w, h, mode.refresh_rate);
- modes.insert(strprintf("%dx%d", w, h));
- }
- }
- }
- FOR_EACH (std::set<std::string>::const_iterator, it, modes)
- modeList.push_back(*it);
- return true;
-}
-
-void SDL::SetWindowTitle(SDL_Window *const window, const char *const title)
-{
- SDL_SetWindowTitle(window, title);
-}
-
-void SDL::SetWindowIcon(SDL_Window *const window, SDL_Surface *const icon)
-{
- SDL_SetWindowIcon(window, icon);
-}
-
-void SDL::grabInput(SDL_Window *const window, const bool grab)
-{
- SDL_SetWindowGrab(window, grab ? SDL_TRUE : SDL_FALSE);
-}
-
-void SDL::setGamma(SDL_Window *const window, const float gamma)
-{
- SDL_SetWindowBrightness(window, gamma);
-}
-
-void SDL::setVsync(const int val)
-{
- SDL_GL_SetSwapInterval(val);
-}
-
-bool SDL::getWindowWMInfo(SDL_Window *const window, SDL_SysWMinfo *const info)
-{
- return SDL_GetWindowWMInfo(window, info);
-}
-
-SDL_Thread *SDL::createThread(SDL_ThreadFunction fn,
- const char *restrict const name,
- void *restrict const data)
-{
- return SDL_CreateThread(fn, name, data);
-}
-
-void *SDL::createGLContext(SDL_Window *const window,
- const int major,
- const int minor,
- const int profile)
-{
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, major);
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, minor);
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, profile);
-// SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG);
- SDL_ClearError();
- void *context = SDL_GL_CreateContext(window);
- if (context == nullptr)
- {
- logger->log("Error to switch to context %d.%d: %s",
- major,
- minor,
- SDL_GetError());
- }
- if (context == nullptr && (major > 3 || (major == 3 && minor > 3)))
- {
- logger->log("Try fallback to OpenGL 3.3 context");
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
- SDL_ClearError();
- context = SDL_GL_CreateContext(window);
- if (context == nullptr)
- {
- logger->log("Error to switch to context 3.3: %s",
- SDL_GetError());
- }
- if (context == nullptr && profile == 0x01)
- {
- logger->log("Try fallback to OpenGL 3.3 compatibility context");
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, 0x02);
- SDL_ClearError();
- context = SDL_GL_CreateContext(window);
- if (context == nullptr)
- {
- logger->log("Error to switch to compatibility context 3.3: %s",
- SDL_GetError());
- }
- }
- }
- if (context == nullptr && (major > 3 || (major == 3 && minor > 0)))
- {
- logger->log("Error to switch to core context %d.%d: %s",
- major,
- minor,
- SDL_GetError());
- logger->log("Try fallback to OpenGL 3.0 core context");
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, profile);
- context = SDL_GL_CreateContext(window);
- if (context == nullptr)
- {
- logger->log("Error to switch to core context 3.0: %s",
- SDL_GetError());
- }
- }
- if (context == nullptr && (major > 2 || (major == 2 && minor > 1)))
- {
- logger->log("Try fallback to OpenGL 2.1 compatibility context");
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, 0x02);
- context = SDL_GL_CreateContext(window);
- if (context == nullptr)
- {
- logger->log("Error to switch to compatibility context 2.1: %s",
- SDL_GetError());
- }
- }
- if (context == nullptr)
- {
- logger->log("Cant find working context.");
- }
- return context;
-}
-
-void SDL::makeCurrentContext(void *const context A_UNUSED)
-{
-}
-
-void SDL::initLogger()
-{
- SDL2Logger::init();
-}
-
-void SDL::setLogLevel(const int level)
-{
- SDL2Logger::setLogLevel(level);
-}
-
-void SDL::WaitThread(SDL_Thread *const thread)
-{
- if (thread != nullptr)
- SDL_WaitThread(thread, nullptr);
-}
-
-bool SDL::PollEvent(SDL_Event *event)
-{
- SDL_PumpEvents();
- return SDL_PeepEvents(event,
- 1,
- SDL_GETEVENT,
- SDL_FIRSTEVENT,
- SDL_LASTEVENT) > 0;
-}
-
-void SDL::allowScreenSaver(const bool allow)
-{
- if (allow)
- {
-#if SDL_VERSION_ATLEAST(2, 0, 2)
- SDL_SetHint(SDL_HINT_VIDEO_ALLOW_SCREENSAVER, "1");
-#endif // SDL_VERSION_ATLEAST(2, 0, 2)
- SDL_EnableScreenSaver();
- }
- else
- {
-#if SDL_VERSION_ATLEAST(2, 0, 2)
- SDL_SetHint(SDL_HINT_VIDEO_ALLOW_SCREENSAVER, "0");
-#endif // SDL_VERSION_ATLEAST(2, 0, 2)
- SDL_DisableScreenSaver();
- }
-}
-
-void SDL::getRenderers(StringVect &list,
- const std::string &currentRenderer)
-{
- SDL_RendererInfo info;
- const int num = SDL_GetNumRenderDrivers();
- for (int f = 0; f < num; f ++)
- {
- if (!SDL_GetRenderDriverInfo(f, &info))
- list.push_back(info.name);
- }
- if (!currentRenderer.empty())
- {
- bool found(false);
- FOR_EACH (StringVectCIter, it, list)
- {
- if (*it == currentRenderer)
- {
- found = true;
- break;
- }
- }
- if (!found)
- list.push_back(currentRenderer);
- }
- std::sort(list.begin(), list.end());
-}
-
-void SDL::setRendererHint(const std::string &driver)
-{
- if (!driver.empty())
- {
- SDL_SetHint(SDL_HINT_RENDER_DRIVER,
- driver.c_str());
- }
-}
-
-#endif // USE_SDL2
diff --git a/src/utils/sdl2helper.h b/src/utils/sdl2helper.h
deleted file mode 100644
index 6c50bb1be..000000000
--- a/src/utils/sdl2helper.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 UTILS_SDL2HELPER_H
-#define UTILS_SDL2HELPER_H
-
-#ifdef USE_SDL2
-#include "utils/stringvector.h"
-
-#include "localconsts.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_thread.h>
-PRAGMA48(GCC diagnostic pop)
-
-union SDL_Event;
-
-struct SDL_Surface;
-struct SDL_SysWMinfo;
-struct SDL_Window;
-
-namespace SDL
-{
- bool getAllVideoModes(StringVect &modeList);
-
- void SetWindowTitle(SDL_Window *const window, const char *const title);
-
- void SetWindowIcon(SDL_Window *const window, SDL_Surface *const icon);
-
- void grabInput(SDL_Window *const window, const bool grab);
-
- void setGamma(SDL_Window *const window, const float gamma);
-
- void setVsync(const int val);
-
- bool getWindowWMInfo(SDL_Window *const window, SDL_SysWMinfo *const info);
-
- SDL_Thread *createThread(SDL_ThreadFunction fn,
- const char *restrict const name,
- void *restrict const data);
-
- void *createGLContext(SDL_Window *const window,
- const int major,
- const int minor,
- const int profile);
-
- void makeCurrentContext(void *const context);
-
- void initLogger();
-
- void setLogLevel(const int level);
-
- void WaitThread(SDL_Thread *const thread);
-
- bool PollEvent(SDL_Event *event);
-
- void allowScreenSaver(const bool allow);
-
- void getRenderers(StringVect &list,
- const std::string &currentRenderer);
-
- void setRendererHint(const std::string &driver);
-} // namespace SDL
-
-#endif // USE_SDL2
-#endif // UTILS_SDL2HELPER_H
diff --git a/src/utils/sdl2logger.cpp b/src/utils/sdl2logger.cpp
deleted file mode 100644
index 9edac9a29..000000000
--- a/src/utils/sdl2logger.cpp
+++ /dev/null
@@ -1,161 +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/>.
- */
-
-#ifdef USE_SDL2
-
-#include "utils/sdl2logger.h"
-
-#include "utils/checkutils.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_assert.h>
-#include <SDL_log.h>
-PRAGMA48(GCC diagnostic pop)
-
-#include "debug.h"
-
-#define logStr(category, msg) \
- case category: \
- message.append(msg); \
- break
-
-// before 2.0.4 this names not exists
-#if !SDL_VERSION_ATLEAST(2, 0, 4)
-#define SDL_AssertState SDL_assert_state
-#define SDL_AssertData SDL_assert_data
-#endif // !SDL_VERSION_ATLEAST(2, 0, 4)
-
-static void logCallback(void *userData A_UNUSED,
- int category,
- SDL_LogPriority priority,
- const char *msg)
-{
- std::string message("SDL ERROR:");
- switch (priority)
- {
- logStr(SDL_LOG_PRIORITY_VERBOSE,
- " VERBOSE");
- logStr(SDL_LOG_PRIORITY_DEBUG,
- " DEBUG");
- logStr(SDL_LOG_PRIORITY_INFO,
- " INFO");
- logStr(SDL_LOG_PRIORITY_WARN,
- " WARN");
- logStr(SDL_LOG_PRIORITY_ERROR,
- " ERROR");
- logStr(SDL_LOG_PRIORITY_CRITICAL,
- " CRITICAL");
- case SDL_NUM_LOG_PRIORITIES:
- default:
- message.append(" ?");
- break;
- }
-
- switch (category)
- {
- logStr(SDL_LOG_CATEGORY_APPLICATION,
- " APPLICATION");
- logStr(SDL_LOG_CATEGORY_ERROR,
- " ERROR");
- logStr(SDL_LOG_CATEGORY_ASSERT,
- " ASSERT");
- logStr(SDL_LOG_CATEGORY_SYSTEM,
- " SYSTEM");
- logStr(SDL_LOG_CATEGORY_AUDIO,
- " AUDIO");
- logStr(SDL_LOG_CATEGORY_VIDEO,
- " VIDEO");
- logStr(SDL_LOG_CATEGORY_RENDER,
- " RENDER");
- logStr(SDL_LOG_CATEGORY_INPUT,
- " INPUT");
- logStr(SDL_LOG_CATEGORY_TEST,
- " TEST");
- logStr(SDL_LOG_CATEGORY_RESERVED1,
- " RESERVED1");
- logStr(SDL_LOG_CATEGORY_RESERVED2,
- " RESERVED2");
- logStr(SDL_LOG_CATEGORY_RESERVED3,
- " RESERVED3");
- logStr(SDL_LOG_CATEGORY_RESERVED4,
- " RESERVED4");
- logStr(SDL_LOG_CATEGORY_RESERVED5,
- " RESERVED5");
- logStr(SDL_LOG_CATEGORY_RESERVED6,
- " RESERVED6");
- logStr(SDL_LOG_CATEGORY_RESERVED7,
- " RESERVED7");
- logStr(SDL_LOG_CATEGORY_RESERVED8,
- " RESERVED8");
- logStr(SDL_LOG_CATEGORY_RESERVED9,
- " RESERVED9");
- logStr(SDL_LOG_CATEGORY_RESERVED10,
- " RESERVED10");
- logStr(SDL_LOG_CATEGORY_CUSTOM,
- " CUSTOM");
- default:
- message.append(" ?");
- break;
- }
- reportAlways("%s %s",
- message.c_str(),
- msg);
-}
-
-static SDL_AssertState assertCallback(const SDL_AssertData *data,
- void *userdata A_UNUSED)
-{
- reportAlways(
- "SDL assert at %s (%s:%d):\n%s",
- data->function,
- data->filename,
- data->linenum,
- data->condition);
- return SDL_ASSERTION_IGNORE;
-}
-
-void SDL2Logger::init()
-{
-#ifdef UNITTESTS
-#if SDL_VERSION_ATLEAST(2, 0, 4)
- SDL_LogSetAllPriority(SDL_LOG_PRIORITY_WARN);
-#else // SDL_VERSION_ATLEAST(2, 0, 4)
- // versions below 2.0.4 report OpenGL error even if OpenGL was not used
- SDL_LogSetAllPriority(SDL_LOG_PRIORITY_CRITICAL);
-#endif // SDL_VERSION_ATLEAST(2, 0, 4)
-#else // UNITTESTS
-
- SDL_LogSetAllPriority(SDL_LOG_PRIORITY_VERBOSE);
-#endif // UNITTESTS
-
- SDL_LogSetOutputFunction(&logCallback, nullptr);
- SDL_SetAssertionHandler(&assertCallback, nullptr);
-}
-
-void SDL2Logger::setLogLevel(const int level)
-{
- if (level > 0)
- SDL_LogSetAllPriority(static_cast<SDL_LogPriority>(level));
- else
- SDL_LogResetPriorities();
-}
-
-#endif // USE_SDL2
diff --git a/src/utils/sdl2logger.h b/src/utils/sdl2logger.h
deleted file mode 100644
index c3ecd1ada..000000000
--- a/src/utils/sdl2logger.h
+++ /dev/null
@@ -1,36 +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 UTILS_SDL2LOGGER_H
-#define UTILS_SDL2LOGGER_H
-
-#ifdef USE_SDL2
-
-#include "localconsts.h"
-
-namespace SDL2Logger
-{
- void init();
-
- void setLogLevel(const int level);
-} // namespace SDL2Logger
-
-#endif // USE_SDL2
-#endif // UTILS_SDL2LOGGER_H
diff --git a/src/utils/sdlcheckutils.cpp b/src/utils/sdlcheckutils.cpp
deleted file mode 100644
index 4ce07f2e5..000000000
--- a/src/utils/sdlcheckutils.cpp
+++ /dev/null
@@ -1,201 +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 "utils/sdlcheckutils.h"
-
-#ifdef DEBUG_SDL_SURFACES
-
-#include "logger.h"
-
-#include "utils/sdlmemoryobject.h"
-#include "utils/stringutils.h"
-
-#include <map>
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_image.h>
-#include <SDL_ttf.h>
-PRAGMA48(GCC diagnostic pop)
-
-#include "debug.h"
-
-#define DEBUG_SURFACE_ALLOCATION 1
-
-std::map<void*, SDLMemoryObject*> mSurfaces;
-
-static SDL_Surface *addSurface(const char *restrict const name,
- SDL_Surface *restrict const surface,
- const char *restrict const file,
- const unsigned line)
-{
-#ifdef DEBUG_SURFACE_ALLOCATION
- logger->log("add surface: %s %s:%u %p", name,
- file, line, static_cast<void*>(surface));
-#endif // DEBUG_SURFACE_ALLOCATION
-
- std::map<void*, SDLMemoryObject*>::iterator
- it = mSurfaces.find(surface);
- if (it != mSurfaces.end())
- {
- SDLMemoryObject *const obj = (*it).second;
- if (obj)
- { // found some time ago created surface
-#ifdef DEBUG_SURFACE_ALLOCATION
- logger->log("adding existing surface: %p, count:%d\n"
- "was add %s\nwas deleted %s", surface, obj->mCnt,
- obj->mAddFile.c_str(), obj->mRemoveFile.c_str());
-#endif // DEBUG_SURFACE_ALLOCATION
-
- obj->mCnt ++;
- }
- }
- else
- { // creating surface object
- mSurfaces[surface] = new SDLMemoryObject(name, file, line);
- }
- return surface;
-}
-
-static void deleteSurface(const char *restrict const name A_UNUSED,
- SDL_Surface *restrict const surface,
- const char *restrict const file,
- const unsigned line)
-{
-#ifdef DEBUG_SURFACE_ALLOCATION
- logger->log("delete surface: %s %s:%u %p", name, file, line, surface);
-#endif // DEBUG_SURFACE_ALLOCATION
-
- std::map<void*, SDLMemoryObject*>::iterator
- it = mSurfaces.find(surface);
- if (it == mSurfaces.end())
- {
- logger->log("bad surface delete: %p at %s:%d",
- static_cast<void*>(surface), file, line);
- }
- else
- {
- SDLMemoryObject *const obj = (*it).second;
- if (obj)
- {
- const int cnt = obj->mCnt;
-#ifdef DEBUG_SURFACE_ALLOCATION
- logger->log("debug deleting surface: %p, count:%d\n"
- "was add %s\nwas deleted %s", surface, cnt,
- obj->mAddFile.c_str(), obj->mRemoveFile.c_str());
-#endif // DEBUG_SURFACE_ALLOCATION
-
- if (cnt < 1)
- { // surface was here but was deleted
- logger->log("deleting already deleted surface: %p at %s:%d\n"
- "was add %s\nwas deleted %s", static_cast<void*>(surface),
- file, line, obj->mAddFile.c_str(),
- obj->mRemoveFile.c_str());
- }
- else if (cnt == 1)
- {
- mSurfaces.erase(surface);
- delete obj;
- }
- else
- {
- obj->mCnt --;
- obj->mRemoveFile = strprintf("%s:%u", file, line);
- }
- }
- }
-}
-
-SDL_Surface *FakeIMG_LoadPNG_RW(SDL_RWops *const src, const char *const file,
- const unsigned line)
-{
- return addSurface("IMG_LoadPNG_RW", IMG_LoadPNG_RW(src), file, line);
-}
-
-SDL_Surface *FakeIMG_LoadJPG_RW(SDL_RWops *const src, const char *const file,
- const unsigned line)
-{
- return addSurface("IMG_LoadJPG_RW", IMG_LoadJPG_RW(src), file, line);
-}
-
-SDL_Surface *FakeIMG_Load(const char *name, const char *const file,
- const unsigned line)
-{
- return addSurface("IMG_Load", IMG_Load(name), file, line);
-}
-
-void FakeSDL_FreeSurface(SDL_Surface *const surface, const char *const file,
- const unsigned line)
-{
- deleteSurface("SDL_FreeSurface", surface, file, line);
- SDL_FreeSurface(surface);
-}
-
-SDL_Surface *FakeSDL_CreateRGBSurface(const uint32_t flags,
- const int width, const int height,
- const int depth,
- const uint32_t rMask,
- const uint32_t gMask,
- const uint32_t bMask,
- const uint32_t aMask,
- const char *const file,
- const unsigned line)
-{
- return addSurface("SDL_CreateRGBSurface", SDL_CreateRGBSurface(flags,
- width, height, depth, rMask, gMask, bMask, aMask), file, line);
-}
-
-SDL_Surface *FakeSDL_ConvertSurface(SDL_Surface *const src,
- SDL_PixelFormat *const fmt,
- const uint32_t flags,
- const char *const file,
- const unsigned line)
-{
- return addSurface("SDL_ConvertSurface", SDL_ConvertSurface(
- src, fmt, flags), file, line);
-}
-
-SDL_Surface *FakeTTF_RenderUTF8_Blended(_TTF_Font *const font,
- const char *restrict const text,
- const SDL_Color &fg,
- const char *restrict const file,
- const unsigned line)
-{
- return addSurface("TTF_RenderUTF8_Blended", TTF_RenderUTF8_Blended(
- font, text, fg), file, line);
-}
-
-SDL_Surface *FakeSDL_DisplayFormat(SDL_Surface *const surface,
- const char *const file,
- const unsigned line)
-{
- return addSurface("SDL_DisplayFormat",
- SDL_DisplayFormat(surface), file, line);
-}
-
-SDL_Surface *FakeSDL_DisplayFormatAlpha(SDL_Surface *const surface,
- const char *const file,
- const unsigned line)
-{
- return addSurface("SDL_DisplayFormatAlpha",
- SDL_DisplayFormatAlpha(surface), file, line);
-}
-
-#endif // DEBUG_SDL_SURFACES
diff --git a/src/utils/sdlcheckutils.h b/src/utils/sdlcheckutils.h
deleted file mode 100644
index 29fd48a7b..000000000
--- a/src/utils/sdlcheckutils.h
+++ /dev/null
@@ -1,78 +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 UTILS_SDLCHECKUTILS_H
-#define UTILS_SDLCHECKUTILS_H
-
-#include "localconsts.h"
-#ifdef DEBUG_SDL_SURFACES
-
-#include <string>
-
-struct _TTF_Font;
-struct SDL_Color;
-struct SDL_PixelFormat;
-struct SDL_RWops;
-struct SDL_Surface;
-
-SDL_Surface *FakeIMG_LoadPNG_RW(SDL_RWops *const src, const char *const file,
- const unsigned line);
-
-SDL_Surface *FakeIMG_LoadJPG_RW(SDL_RWops *const src, const char *const file,
- const unsigned line);
-
-void FakeSDL_FreeSurface(SDL_Surface *const surface, const char *const file,
- const unsigned line);
-
-SDL_Surface *FakeSDL_CreateRGBSurface(const uint32_t flags,
- const int width, const int height,
- const int depth,
- const uint32_t rMask,
- const uint32_t gMask,
- const uint32_t bMask,
- const uint32_t aMask,
- const char *const file,
- const unsigned line);
-
-SDL_Surface *FakeSDL_ConvertSurface(SDL_Surface *const src,
- SDL_PixelFormat *const fmt,
- const uint32_t flags,
- const char *const file,
- const unsigned line);
-
-SDL_Surface *FakeTTF_RenderUTF8_Blended(_TTF_Font *restrict const font,
- const char *restrict const text,
- const SDL_Color &fg,
- const char *restrict const file,
- const unsigned line);
-
-SDL_Surface *FakeIMG_Load(const char *name, const char *const file,
- const unsigned line);
-
-SDL_Surface *FakeSDL_DisplayFormat(SDL_Surface *const surface,
- const char *const file,
- const unsigned line);
-
-SDL_Surface *FakeSDL_DisplayFormatAlpha(SDL_Surface *const surface,
- const char *const file,
- const unsigned line);
-
-#endif // DEBUG_SDL_SURFACES
-#endif // UTILS_SDLCHECKUTILS_H
diff --git a/src/utils/sdlhelper.cpp b/src/utils/sdlhelper.cpp
deleted file mode 100644
index e30bdebaa..000000000
--- a/src/utils/sdlhelper.cpp
+++ /dev/null
@@ -1,217 +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 USE_SDL2
-
-#include "utils/sdlhelper.h"
-
-#include "logger.h"
-
-#include "utils/cast.h"
-#include "utils/env.h"
-#include "utils/stringutils.h"
-
-#if defined(USE_X11) && defined(USE_OPENGL)
-#include "utils/glxhelper.h"
-#endif // defined(USE_X11) && defined(USE_OPENGL)
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_events.h>
-#include <SDL_syswm.h>
-PRAGMA48(GCC diagnostic pop)
-
-#include "debug.h"
-
-bool SDL::getAllVideoModes(StringVect &modeList)
-{
- /* Get available fullscreen/hardware modes */
- SDL_Rect *const *const modes = SDL_ListModes(nullptr,
- SDL_FULLSCREEN | SDL_HWSURFACE);
-
-#ifdef ANDROID
- const std::string modeString =
- toString(CAST_S32(modes[0]->w)).append("x")
- .append(toString(CAST_S32(modes[0]->h)));
- logger->log("support mode: " + modeString);
- modeList.push_back(modeString);
- return true;
-#else // ANDROID
-
- /* Check which modes are available */
- if (modes == static_cast<SDL_Rect **>(nullptr))
- {
- logger->log1("No modes available");
- return false;
- }
- else if (modes == reinterpret_cast<SDL_Rect **>(-1))
- {
- logger->log1("All resolutions available");
- return true;
- }
- else
- {
- for (int i = 0; modes[i] != nullptr; ++ i)
- {
- const std::string modeString =
- toString(CAST_S32(modes[i]->w)).append("x")
- .append(toString(CAST_S32(modes[i]->h)));
- logger->log("support mode: " + modeString);
- modeList.push_back(modeString);
- }
- return true;
- }
-#endif // ANDROID
-}
-
-void SDL::SetWindowTitle(const SDL_Surface *const window A_UNUSED,
- const char *const title)
-{
- SDL_WM_SetCaption(title, nullptr);
-}
-
-void SDL::SetWindowIcon(const SDL_Surface *const window A_UNUSED,
- SDL_Surface *const icon)
-{
- SDL_WM_SetIcon(icon, nullptr);
-}
-
-void SDL::grabInput(const SDL_Surface *const window A_UNUSED, const bool grab)
-{
- SDL_WM_GrabInput(grab ? SDL_GRAB_ON : SDL_GRAB_OFF);
-}
-
-void SDL::setGamma(const SDL_Surface *const window A_UNUSED, const float gamma)
-{
- SDL_SetGamma(gamma, gamma, gamma);
-}
-
-void SDL::setVsync(const int val)
-{
- SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, val);
-}
-
-bool SDL::getWindowWMInfo(const SDL_Surface *const window A_UNUSED,
- SDL_SysWMinfo *const info)
-{
- return SDL_GetWMInfo(info) != 0;
-}
-
-SDL_Thread *SDL::createThread(int (SDLCALL *fn)(void *),
- const char *const name A_UNUSED,
- void *const data)
-{
- return SDL_CreateThread(fn, data);
-}
-
-#if defined(USE_X11) && defined(USE_OPENGL)
-void *SDL::createGLContext(SDL_Surface *const window A_UNUSED,
- const int major,
- const int minor,
- const int profile)
-{
- SDL_SysWMinfo info;
- SDL_VERSION(&info.version);
- SDL_GetWMInfo(&info);
- void *context = GlxHelper::createContext(info.info.x11.window,
- info.info.x11.display, major, minor, profile);
- if (!context && (major > 3 || (major == 3 && minor > 3)))
- {
- logger->log("Try fallback to OpenGL 3.3 core context");
- context = GlxHelper::createContext(info.info.x11.window,
- info.info.x11.display, 3, 3, profile);
- if (!context && profile == 0x01)
- {
- logger->log("Try fallback to OpenGL 3.3 compatibility context");
- context = GlxHelper::createContext(info.info.x11.window,
- info.info.x11.display, 3, 3, 0x02);
- }
- }
- if (!context && (major > 3 || (major == 3 && minor > 0)))
- {
- logger->log("Try fallback to OpenGL 3.0 core context");
- context = GlxHelper::createContext(info.info.x11.window,
- info.info.x11.display, 3, 0, profile);
- }
- if (!context && (major > 2 || (major == 2 && minor > 1)))
- {
- logger->log("Try fallback to OpenGL 2.1 compatibility context");
- context = GlxHelper::createContext(info.info.x11.window,
- info.info.x11.display, 2, 1, 0x02);
- }
- return context;
-}
-
-void SDL::makeCurrentContext(void *const context)
-{
- SDL_SysWMinfo info;
- SDL_VERSION(&info.version);
- SDL_GetWMInfo(&info);
- GlxHelper::makeCurrent(info.info.x11.window,
- info.info.x11.display,
- context);
-}
-#else // defined(USE_X11) && defined(USE_OPENGL)
-
-void *SDL::createGLContext(SDL_Surface *const window A_UNUSED,
- const int major A_UNUSED,
- const int minor A_UNUSED,
- const int profile A_UNUSED)
-{
- return nullptr;
-}
-
-void SDL::makeCurrentContext(void *const context A_UNUSED)
-{
-}
-#endif // defined(USE_X11) && defined(USE_OPENGL)
-
-void SDL::initLogger()
-{
-}
-
-void SDL::setLogLevel(const int level A_UNUSED)
-{
-}
-
-void SDL::WaitThread(SDL_Thread *const thread)
-{
- if (thread != nullptr && SDL_GetThreadID(thread) != 0u)
- SDL_WaitThread(thread, nullptr);
-}
-
-bool SDL::PollEvent(SDL_Event *event)
-{
- SDL_PumpEvents();
- return SDL_PeepEvents(event,
- 1,
- SDL_GETEVENT,
- SDL_ALLEVENTS) > 0;
-}
-
-void SDL::allowScreenSaver(const bool allow)
-{
- if (allow)
- setEnv("SDL_VIDEO_ALLOW_SCREENSAVER", "1");
- else
- setEnv("SDL_VIDEO_ALLOW_SCREENSAVER", "0");
-}
-
-#endif // USE_SDL2
diff --git a/src/utils/sdlhelper.h b/src/utils/sdlhelper.h
deleted file mode 100644
index f304036aa..000000000
--- a/src/utils/sdlhelper.h
+++ /dev/null
@@ -1,85 +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 UTILS_SDLHELPER_H
-#define UTILS_SDLHELPER_H
-
-#ifdef USE_SDL2
-#include "utils/sdl2helper.h"
-UTILS_SDL2HELPER_H
-
-#else
-#include "utils/stringvector.h"
-
-#include "localconsts.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_thread.h>
-PRAGMA48(GCC diagnostic pop)
-
-union SDL_Event;
-
-struct SDL_Surface;
-struct SDL_SysWMinfo;
-
-namespace SDL
-{
- bool getAllVideoModes(StringVect &modeList);
-
- void SetWindowTitle(const SDL_Surface *const window,
- const char *const title);
-
- void SetWindowIcon(const SDL_Surface *const window A_UNUSED,
- SDL_Surface *const icon);
-
- void grabInput(const SDL_Surface *const window A_UNUSED, const bool grab);
-
- void setGamma(const SDL_Surface *const window A_UNUSED, const float gamma);
-
- void setVsync(const int val);
-
- bool getWindowWMInfo(const SDL_Surface *const window A_UNUSED,
- SDL_SysWMinfo *const info);
-
- SDL_Thread *createThread(int (SDLCALL *fn)(void *),
- const char *const name A_UNUSED,
- void *const data);
-
- void *createGLContext(SDL_Surface *const window A_UNUSED,
- const int major,
- const int minor,
- const int profile);
-
- void makeCurrentContext(void *const context);
-
- void initLogger();
-
- void setLogLevel(const int level);
-
- void WaitThread(SDL_Thread *const thread);
-
- bool PollEvent(SDL_Event *event);
-
- void allowScreenSaver(const bool allow);
-} // namespace SDL
-
-#endif // USE_SDL2
-#endif // UTILS_SDLHELPER_H
diff --git a/src/utils/sdlmemoryobject.h b/src/utils/sdlmemoryobject.h
deleted file mode 100644
index daab75088..000000000
--- a/src/utils/sdlmemoryobject.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 UTILS_SDLMEMORYOBJECT_H
-#define UTILS_SDLMEMORYOBJECT_H
-
-#ifdef DEBUG_SDL_SURFACES
-
-#include "logger.h"
-
-#include "utils/stringutils.h"
-
-#include <string>
-
-#include "localconsts.h"
-
-struct SDLMemoryObject final
-{
- SDLMemoryObject(const std::string &name,
- const char *const file,
- const unsigned int line) :
- mName(name),
- mAddFile(strprintf("%s:%u", file, line)),
- mRemoveFile(),
- mCnt(1)
- {
- }
-
- A_DELETE_COPY(SDLMemoryObject)
-
- std::string mName;
- std::string mAddFile;
- std::string mRemoveFile;
- int mCnt;
-};
-
-#endif // DEBUG_SDL_SURFACES
-#endif // UTILS_SDLMEMORYOBJECT_H
diff --git a/src/utils/sdlpixel.h b/src/utils/sdlpixel.h
deleted file mode 100644
index 920ad4164..000000000
--- a/src/utils/sdlpixel.h
+++ /dev/null
@@ -1,254 +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/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef UTILS_SDLPIXEL_H
-#define UTILS_SDLPIXEL_H
-
-#include "gui/color.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL.h>
-PRAGMA48(GCC diagnostic pop)
-
-#ifndef SDL_BYTEORDER
-#error missing SDL_endian.h
-#endif // SDL_BYTEORDER
-
-/**
- * Puts a pixel on an SDL_Surface.
- *
- * @param x the x coordinate on the surface.
- * @param y the y coordinate on the surface.
- * @param color the color the pixel should be in.
- */
-inline void SDLputPixel(SDL_Surface* surface, int x, int y,
- const Color& color)
-{
- if (surface == nullptr)
- return;
-
- const int bpp = surface->format->BytesPerPixel;
-
- SDL_LockSurface(surface);
-
- Uint8 *const p = static_cast<uint8_t*>(surface->pixels)
- + CAST_SIZE(y * surface->pitch + x * bpp);
-
- const Uint32 pixel = SDL_MapRGB(surface->format,
- CAST_U8(color.r), CAST_U8(color.g),
- CAST_U8(color.b));
-
- switch (bpp)
- {
- case 1:
- *p = CAST_U8(pixel);
- break;
-
- case 2:
- *reinterpret_cast<uint16_t*>(p) = CAST_U16(pixel);
- break;
-
- case 3:
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- p[0] = CAST_U8((pixel >> 16) & 0xff);
- p[1] = CAST_U8((pixel >> 8) & 0xff);
- p[2] = CAST_U8((pixel) & 0xff);
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- p[0] = CAST_U8((pixel) & 0xff);
- p[1] = CAST_U8((pixel >> 8) & 0xff);
- p[2] = CAST_U8((pixel >> 16) & 0xff);
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- break;
-
- case 4:
- *reinterpret_cast<Uint32*>(p) = pixel;
- break;
-
- default:
- break;
- }
-
- SDL_UnlockSurface(surface);
-}
-
-/**
- * Blends two 32 bit colors together.
- *
- * @param src the source color.
- * @param dst the destination color.
- * @param a alpha.
- */
-inline unsigned int SDLAlpha32(const unsigned int src,
- const unsigned int dst,
- const unsigned char a)
-{
- const unsigned int b = ((src & 0xff) * a + (dst & 0xff) * (255 - a)) >> 8;
- const unsigned int g = ((src & 0xff00) * a + (dst & 0xff00)
- * (255 - a)) >> 8;
- const unsigned int r = ((src & 0xff0000) * a + (dst & 0xff0000)
- * (255 - a)) >> 8;
-
- return (b & 0xff) | (g & 0xff00) | (r & 0xff0000);
-}
-
-inline unsigned short SDLAlpha16(const unsigned short src,
- const unsigned short dst,
- const unsigned char a,
- const SDL_PixelFormat *const f) A_NONNULL(4);
-
-/**
- * Blends two 16 bit colors together.
- *
- * @param src the source color.
- * @param dst the destination color.
- * @param a alpha.
- */
-inline unsigned short SDLAlpha16(const unsigned short src,
- const unsigned short dst,
- const unsigned char a,
- const SDL_PixelFormat *const f)
-{
- unsigned int b = ((src & f->Rmask) * a + (dst & f->Rmask)
- * (255 - a)) >> 8;
- unsigned int g = ((src & f->Gmask) * a + (dst & f->Gmask)
- * (255 - a)) >> 8;
- unsigned int r = ((src & f->Bmask) * a + (dst & f->Bmask)
- * (255 - a)) >> 8;
-
- return static_cast<unsigned short>((b & f->Rmask)
- | (g & f->Gmask) | (r & f->Bmask));
-}
-
-/**
- * Puts a pixel on an SDL_Surface with alpha
- *
- * @param x the x coordinate on the surface.
- * @param y the y coordinate on the surface.
- * @param color the color the pixel should be in.
- */
-inline void SDLputPixelAlpha(SDL_Surface* surface, int x, int y,
- const Color& color)
-{
- if (surface == nullptr)
- return;
- const int bpp = surface->format->BytesPerPixel;
-
- SDL_LockSurface(surface);
-
- Uint8 *const p = static_cast<uint8_t*>(surface->pixels)
- + CAST_SIZE(y * surface->pitch + x * bpp);
-
- const Uint32 pixel = SDL_MapRGB(surface->format,
- CAST_U8(color.r),
- CAST_U8(color.g),
- CAST_U8(color.b));
-
- switch (bpp)
- {
- case 1:
- *p = CAST_U8(pixel);
- break;
-
- case 2:
- *reinterpret_cast<Uint16*>(p) = SDLAlpha16(
- static_cast<unsigned short>(pixel),
- *reinterpret_cast<unsigned short*>(p),
- CAST_U8(color.a), surface->format);
- break;
-
- case 3:
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- p[2] = CAST_U8((p[2] * (255 - color.a)
- + color.b * color.a) >> 8);
- p[1] = CAST_U8((p[1] * (255 - color.a)
- + color.g * color.a) >> 8);
- p[0] = CAST_U8((p[0] * (255 - color.a)
- + color.r * color.a) >> 8);
-#else // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- p[0] = CAST_U8((p[0] * (255 - color.a)
- + color.b * color.a) >> 8);
- p[1] = CAST_U8((p[1] * (255 - color.a)
- + color.g * color.a) >> 8);
- p[2] = CAST_U8((p[2] * (255 - color.a)
- + color.r * color.a) >> 8);
-#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
-
- break;
-
- case 4:
- *reinterpret_cast<Uint32*>(p) = SDLAlpha32(pixel,
- *reinterpret_cast<Uint32*>(p),
- CAST_U8(color.a));
- break;
- default:
- break;
- }
-
- SDL_UnlockSurface(surface);
-}
-
-#endif // UTILS_SDLPIXEL_H
diff --git a/src/utils/sdlsharedhelper.cpp b/src/utils/sdlsharedhelper.cpp
deleted file mode 100644
index 1f2f04a85..000000000
--- a/src/utils/sdlsharedhelper.cpp
+++ /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/>.
- */
-
-#include "utils/sdlsharedhelper.h"
-
-#ifdef __native_client__
-#include <ppapi/c/ppb_mouse_cursor.h>
-#include <ppapi/cpp/instance.h>
-#include <ppapi/cpp/mouse_cursor.h>
-#include <ppapi_simple/ps.h>
-#endif // __native_client__
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_events.h>
-PRAGMA48(GCC diagnostic pop)
-
-#include "debug.h"
-
-void SDL::showCursor(const bool show)
-{
-#ifdef __native_client__
- PP_MouseCursor_Type cursor;
- if (show)
- cursor = PP_MOUSECURSOR_TYPE_POINTER; // show default cursor
- else
- cursor = PP_MOUSECURSOR_TYPE_NONE; // hide cursor
-
- pp::MouseCursor::SetCursor(
- pp::InstanceHandle(PSGetInstanceId()),
- cursor);
-#endif // __native_client__
-
- if (show)
- SDL_ShowCursor(SDL_ENABLE);
- else
- SDL_ShowCursor(SDL_DISABLE);
-}
diff --git a/src/utils/sdlsharedhelper.h b/src/utils/sdlsharedhelper.h
deleted file mode 100644
index 799bf5965..000000000
--- a/src/utils/sdlsharedhelper.h
+++ /dev/null
@@ -1,31 +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 UTILS_SDLSHAREDHELPER_H
-#define UTILS_SDLSHAREDHELPER_H
-
-#include "localconsts.h"
-
-namespace SDL
-{
- void showCursor(const bool show);
-} // namespace SDL
-
-#endif // UTILS_SDLSHAREDHELPER_H
diff --git a/src/utils/stdmove.h b/src/utils/stdmove.h
deleted file mode 100644
index b72b941aa..000000000
--- a/src/utils/stdmove.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 UTILS_STDMOVE_H
-#define UTILS_STDMOVE_H
-
-#ifdef __GXX_EXPERIMENTAL_CXX0X__
-#define STD_MOVE(var) std::move(var)
-#else // __GXX_EXPERIMENTAL_CXX0X__
-#define STD_MOVE(var) (var)
-#endif // __GXX_EXPERIMENTAL_CXX0X__
-
-#endif // UTILS_STDMOVE_H
diff --git a/src/utils/stringmap.h b/src/utils/stringmap.h
deleted file mode 100644
index 90200764a..000000000
--- a/src/utils/stringmap.h
+++ /dev/null
@@ -1,31 +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 UTILS_STRINGMAP_H
-#define UTILS_STRINGMAP_H
-
-#include <string>
-#include <map>
-
-typedef std::map<std::string, int> StringIntMap;
-typedef StringIntMap::iterator StringIntMapIter;
-typedef StringIntMap::const_iterator StringIntMapCIter;
-
-#endif // UTILS_STRINGMAP_H
diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp
deleted file mode 100644
index 4f3a156cc..000000000
--- a/src/utils/stringutils.cpp
+++ /dev/null
@@ -1,1238 +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 "utils/stringutils.h"
-
-#include "const/utils/utf8.h"
-
-#ifdef DYECMD
-#include "utils/cast.h"
-#else // DYECMD
-#include "resources/iteminfo.h"
-#include "resources/db/itemdb.h"
-#endif // DYECMD
-
-#include "utils/gettext.h"
-#include "utils/foreach.h"
-
-#include <algorithm>
-#include <sstream>
-
-#ifdef WIN32
-#include <sys/time.h>
-#endif // WIN32
-
-#include "debug.h"
-
-std::string &trim(std::string &str)
-{
- size_t pos = str.find_last_not_of(' ');
- if (pos != std::string::npos)
- {
- str.erase(pos + 1);
- pos = str.find_first_not_of(' ');
-
- if (pos != std::string::npos)
- str.erase(0, pos);
- }
- else
- {
- // There is nothing else but whitespace in the string
- str.clear();
- }
- return str;
-}
-
-std::string &toLower(std::string &str)
-{
- std::transform(str.begin(), str.end(), str.begin(), &tolower);
- return str;
-}
-
-std::string &toUpper(std::string &str)
-{
- std::transform(str.begin(), str.end(), str.begin(), &toupper);
- return str;
-}
-
-unsigned int atox(const std::string &str)
-{
- unsigned int value = 0;
- if (sscanf(str.c_str(), "0x%06x", &value) != 0)
- return value;
- return 0;
-}
-
-const char *ipToString(const uint32_t address)
-{
- static char asciiIP[18];
-
- snprintf(asciiIP, sizeof(asciiIP), "%i.%i.%i.%i",
- CAST_U8(address),
- CAST_U8(address >> 8),
- CAST_U8(address >> 16),
- CAST_U8(address >> 24));
- asciiIP[17] = 0;
-
- return asciiIP;
-}
-
-std::string strprintf(const char *const format, ...)
-{
- char buf[257];
- va_list(args);
- va_start(args, format);
- size_t nb = vsnprintf(buf, 256, format, args);
- buf[256] = 0;
- va_end(args);
- if (nb < 256)
- return buf;
-
- // The static size was not big enough, try again with a dynamic allocation.
- ++nb;
- char *buf2 = new char[nb];
- va_start(args, format);
- vsnprintf(buf2, nb, format, args);
- va_end(args);
- std::string res(buf2);
- delete [] buf2;
- return res;
-}
-
-std::string removeColors(std::string msg)
-{
- for (unsigned int f = 0; f < msg.length() - 2 && msg.length() > 2; f++)
- {
- while (msg.length() > f + 2 && msg.at(f) == '#'
- && msg.at(f + 1) == '#')
- {
- msg = msg.erase(f, 3);
- }
- }
- return msg;
-}
-
-int compareStrI(const std::string &a, const std::string &b)
-{
- std::string::const_iterator itA = a.begin();
- const std::string::const_iterator endA = a.end();
- std::string::const_iterator itB = b.begin();
- const std::string::const_iterator endB = b.end();
-
- for (; itA < endA && itB < endB; ++itA, ++itB)
- {
- const int comp = tolower(*itA) - tolower(*itB);
- if (comp != 0)
- return comp;
- }
-
- // Check string lengths
- if (itA == endA && itB == endB)
- return 0;
- else if (itA == endA)
- return -1;
- else
- return 1;
-}
-
-
-bool isWordSeparator(const signed char chr)
-{
- return chr == ' ' ||
- chr == ',' ||
- chr == '.' ||
- chr == '"';
-}
-
-const std::string findSameSubstring(const std::string &restrict str1,
- const std::string &restrict str2)
-{
- const int minLength = str1.length() > str2.length()
- ? CAST_S32(str2.length()) : CAST_S32(str1.length());
- for (int f = 0; f < minLength; f ++)
- {
- if (str1.at(f) != str2.at(f))
- return str1.substr(0, f);
- }
- return str1.substr(0, minLength);
-}
-
-const std::string findSameSubstringI(const std::string &restrict s1,
- const std::string &restrict s2)
-{
- std::string str1 = s1;
- std::string str2 = s2;
- toLower(str1);
- toLower(str2);
-
- const size_t minLength = str1.length() > str2.length()
- ? str2.length() : str1.length();
- for (size_t f = 0; f < minLength; f ++)
- {
- if (str1.at(f) != str2.at(f))
- return s1.substr(0, f);
- }
- return s1.substr(0, minLength);
-}
-
-size_t findI(std::string str, std::string subStr)
-{
- str = toLower(str);
- subStr = toLower(subStr);
- return str.find(subStr);
-}
-
-size_t findI(std::string text, const StringVect &list)
-{
- toLower(text);
- FOR_EACH (StringVectCIter, i, list)
- {
- std::string subStr = *i;
- subStr = toLower(subStr);
- const size_t idx = text.find(subStr);
- if (idx != std::string::npos)
- return idx;
- }
- return std::string::npos;
-}
-
-size_t findAny(const std::string &restrict text,
- const std::string &restrict chars,
- const size_t pos)
-{
- size_t idx = std::string::npos;
- const size_t sz = chars.size();
- for (size_t f = 0; f < sz; f ++)
- {
- const size_t idx2 = text.find(chars[f], pos);
- if (idx2 != std::string::npos && idx2 < idx)
- idx = idx2;
- }
- return idx;
-}
-
-namespace
-{
- unsigned int base = 94;
- unsigned int start = 33;
-} // namespace
-
-const std::string encodeStr(unsigned int value, const unsigned int size)
-{
- std::string buf;
-
- do
- {
- buf += CAST_S8(value % base + start);
- value /= base;
- }
- while (value != 0u);
-
- while (buf.length() < size)
- buf += CAST_S8(start);
- return buf;
-}
-
-
-unsigned int decodeStr(const std::string &str)
-{
- if (str.empty())
- return 0;
-
- int res = str[0] - start;
- int mult = 1;
- for (unsigned int f = 1; f < str.length(); f ++)
- {
- mult *= base;
- res = res + (str[f] - start) * mult;
- }
- return res;
-}
-
-std::string extractNameFromSprite(std::string str)
-{
- const size_t pos1 = str.rfind('.');
- if (pos1 != std::string::npos)
- {
- size_t pos2 = str.rfind('/');
- const size_t pos3 = str.rfind('\\');
- if (pos3 != std::string::npos)
- {
- if (pos2 == std::string::npos || pos3 > pos2)
- pos2 = pos3;
- }
- if (pos2 == std::string::npos)
- pos2 = CAST_SIZE(-1);
-
- const int size = CAST_S32(pos1) - CAST_S32(pos2) - 1;
- if (size > 0)
- str = str.substr(pos2 + 1, size);
- }
- return str;
-}
-
-std::string removeSpriteIndex(std::string str)
-{
- const size_t pos1 = str.rfind('[');
-
- if (pos1 != std::string::npos)
- {
- size_t pos2 = str.rfind('/');
- const size_t pos3 = str.rfind('\\');
- if (pos3 != std::string::npos)
- {
- if (pos2 == std::string::npos || pos3 > pos2)
- pos2 = pos3;
- }
- if (pos2 == std::string::npos)
- pos2 = CAST_SIZE(-1);
-
- const int size = CAST_S32(pos1) - CAST_S32(pos2) - 1;
- if (size > 0)
- str = str.substr(pos2 + 1, size);
- }
- return str;
-}
-
-const char* getSafeUtf8String(const std::string &text)
-{
- const size_t sz = text.size();
- const size_t size = sz + UTF8_MAX_SIZE;
- char *const buf = new char[size];
- memcpy(buf, text.c_str(), sz);
- memset(buf + sz, 0, UTF8_MAX_SIZE);
- return buf;
-}
-
-void getSafeUtf8String(std::string text, char *const buf)
-{
- if (buf == nullptr)
- return;
- const size_t sz = text.size();
- const size_t size = sz + UTF8_MAX_SIZE;
- if (size > 65500)
- {
- text = text.substr(0, 65500);
- const size_t sz1 = text.size();
- memcpy(buf, text.c_str(), sz1);
- memset(buf + sz1, 0, UTF8_MAX_SIZE);
- }
- else
- {
- memcpy(buf, text.c_str(), sz);
- memset(buf + sz, 0, UTF8_MAX_SIZE);
- }
-}
-
-std::string getFileName(const std::string &path)
-{
- size_t pos1 = path.rfind('/');
- const size_t pos2 = path.rfind('\\');
- if (pos1 == std::string::npos)
- pos1 = pos2;
- else if (pos2 != std::string::npos && pos2 > pos1)
- pos1 = pos2;
-
- if (pos1 == std::string::npos)
- return path;
- return path.substr(pos1 + 1);
-}
-
-std::string getFileDir(const std::string &path)
-{
- size_t pos1 = path.rfind('/');
- const size_t pos2 = path.rfind('\\');
- if (pos1 == std::string::npos)
- pos1 = pos2;
- else if (pos2 != std::string::npos && pos2 > pos1)
- pos1 = pos2;
-
- if (pos1 == std::string::npos)
- return path;
- return path.substr(0, pos1);
-}
-
-std::string& replaceAll(std::string& context,
- const std::string &restrict from,
- const std::string &restrict to)
-{
- if (from.empty())
- return context;
- size_t lookHere = 0;
- size_t foundHere;
- const size_t fromSize = from.size();
- const size_t toSize = to.size();
- while ((foundHere = context.find(from, lookHere)) != std::string::npos)
- {
- context.replace(foundHere, fromSize, to);
- lookHere = foundHere + toSize;
- }
- return context;
-}
-
-void replaceRecursiveAll(std::string& context,
- const std::string &restrict from,
- const char to)
-{
- size_t lookHere = 0;
- size_t foundHere;
- const size_t fromSize = from.size();
- while ((foundHere = context.find(from, lookHere)) != std::string::npos)
- {
- context.replace(foundHere, fromSize, 1, to);
- lookHere = foundHere;
- }
-}
-
-bool getBoolFromString(const std::string &text)
-{
- std::string txt = text;
- toLower(trim(txt));
- if (txt == "true" || txt == "yes" || txt == "on" || txt == "1")
- return true;
- else if (txt == "false" || txt == "no" || txt == "off" || txt == "0")
- return false;
- else
- return static_cast<bool>(atoi(txt.c_str()));
-}
-
-void replaceSpecialChars(std::string &text)
-{
- size_t pos1 = text.find('&');
- while (pos1 != std::string::npos)
- {
- const size_t idx = pos1 + 1;
- const size_t sz = text.size();
- if (idx >= sz)
- break;
-
- size_t f;
- for (f = idx; f < sz; f ++)
- {
- if (text[f] < '0' || text[f] > '9')
- break;
- }
- if (idx + 1 < f && text[f] == ';')
- {
- std::string str(" ");
- str[0] = CAST_S8(atoi(text.substr(
- idx, f - idx).c_str()));
- text = text.substr(0, pos1).append(str).append(text.substr(f + 1));
- pos1 += 1;
- }
- else
- {
- pos1 = f + 1;
- }
-
- pos1 = text.find('&', pos1);
- }
-}
-
-std::string normalize(const std::string &name)
-{
- std::string normalized = name;
- return toLower(trim(normalized));
-}
-
-void splitToIntSet(std::set<int> &tokens,
- const std::string &text,
- const char separator)
-{
- std::stringstream ss(text);
- std::string item;
- while (std::getline(ss, item, separator))
- tokens.insert(atoi(item.c_str()));
-}
-
-std::list<int> splitToIntList(const std::string &text,
- const char separator)
-{
- std::list<int> tokens;
- std::stringstream ss(text);
- std::string item;
- while (std::getline(ss, item, separator))
- tokens.push_back(atoi(item.c_str()));
-
- return tokens;
-}
-
-std::list<std::string> splitToStringList(const std::string &text,
- const char separator)
-{
- std::list<std::string> tokens;
- std::stringstream ss(text);
- std::string item;
- while (std::getline(ss, item, separator))
- tokens.push_back(item);
-
- return tokens;
-}
-
-void splitToStringVector(StringVect &tokens,
- const std::string &text,
- const char separator)
-{
- std::stringstream ss(text);
- std::string item;
- while (std::getline(ss, item, separator))
- {
- item = trim(item);
- if (!item.empty())
- tokens.push_back(item);
- }
-}
-
-void splitToStringSet(std::set<std::string> &tokens,
- const std::string &text,
- const char separator)
-{
- std::stringstream ss(text);
- std::string item;
- while (std::getline(ss, item, separator))
- {
- item = trim(item);
- if (!item.empty())
- tokens.insert(item);
- }
-}
-
-void splitToIntVector(STD_VECTOR<int> &tokens,
- const std::string &text,
- const char separator)
-{
- std::stringstream ss(text);
- std::string item;
- while (std::getline(ss, item, separator))
- {
- item = trim(item);
- if (!item.empty())
- tokens.push_back(atoi(item.c_str()));
- }
-}
-
-std::string combineDye(std::string file,
- const std::string &dye)
-{
- if (dye.empty())
- return file;
- const size_t pos = file.find_last_of('|');
- if (pos != std::string::npos)
- return file.substr(0, pos).append("|").append(dye);
- return file.append("|").append(dye);
-}
-
-std::string combineDye2(std::string file,
- const std::string &dye)
-{
- if (dye.empty())
- return file;
-
- const size_t pos = file.find_last_of('|');
- if (pos != std::string::npos)
- {
- const std::string dye1 = file.substr(pos + 1);
- std::string str;
- file = file.substr(0, pos);
- const std::list<std::string> list1 = splitToStringList(dye1, ';');
- const std::list<std::string> list2 = splitToStringList(dye, ';');
- for (std::list<std::string>::const_iterator it1 = list1.begin(),
- it2 = list2.begin(), it1_end = list1.end(), it2_end = list2.end();
- it1 != it1_end && it2 != it2_end; ++it1, ++it2)
- {
- str.append(*it1).append(":").append(*it2).append(";");
- }
- return file.append("|").append(str);
- }
- return file;
-}
-
-std::string combineDye3(std::string file,
- const std::string &dye)
-{
- if (dye.empty())
- return file;
-
- const size_t pos = file.find_last_of('|');
- if (pos != std::string::npos)
- {
- const std::string dye1 = file.substr(pos + 1);
- std::string str;
- file = file.substr(0, pos);
- const std::list<std::string> list1 = splitToStringList(dye1, ';');
- const std::list<std::string> list2 = splitToStringList(dye, ';');
- for (std::list<std::string>::const_iterator it1 = list1.begin(),
- it2 = list2.begin(), it1_end = list1.end(), it2_end = list2.end();
- it1 != it1_end && it2 != it2_end; ++it1, ++it2)
- {
- str.append(*it1).append(":").append(*it2).append(";");
- }
- return file.append("|").append(str);
- }
- if (dye.empty() || file.empty())
- return file;
- return file.append("|").append(dye);
-}
-
-std::string packList(const std::list<std::string> &list)
-{
- std::list<std::string>::const_iterator i = list.begin();
- std::string str;
- while (i != list.end())
- {
- str.append(*i).append("|");
- ++ i;
- }
- const size_t sz = str.size();
- if (sz > 1)
- str = str.substr(0, sz - 1);
- return str;
-}
-
-std::list<std::string> unpackList(const std::string &str)
-{
- return splitToStringList(str, '|');
-}
-
-std::string stringToHexPath(const std::string &str)
-{
- if (str.empty())
- return "";
-
- std::string hex = strprintf("%%%2x/", CAST_U32(str[0]));
- for (unsigned f = 1, fsz = CAST_U32(str.size());
- f < fsz; f ++)
- {
- hex.append(strprintf("%%%2x", CAST_U32(str[f])));
- }
- return hex;
-}
-
-void deleteCharLeft(std::string &str,
- unsigned *const pos)
-{
- if (pos == nullptr)
- return;
-
- while (*pos > 0)
- {
- (*pos)--;
- const int v = str[*pos];
- str.erase(*pos, 1);
- if ((v & 192) != 128)
- break;
- }
-}
-
-bool findLast(const std::string &restrict str1,
- const std::string &restrict str2)
-{
- const size_t s1 = str1.size();
- const size_t s2 = str2.size();
- if (s1 < s2)
- return false;
- if (str1.substr(s1 - s2) == str2)
- return true;
- return false;
-}
-
-bool findFirst(const std::string &restrict str1,
- const std::string &restrict str2)
-{
- const size_t s1 = str1.size();
- const size_t s2 = str2.size();
- if (s1 < s2)
- return false;
- if (str1.substr(0, s2) == str2)
- return true;
- return false;
-}
-
-bool findCutLast(std::string &restrict str1,
- const std::string &restrict str2)
-{
- const size_t s1 = str1.size();
- const size_t s2 = str2.size();
- if (s1 < s2)
- return false;
- if (str1.substr(s1 - s2) == str2)
- {
- str1 = str1.substr(0, s1 - s2);
- return true;
- }
- return false;
-}
-
-void cutLast(std::string &restrict str1,
- const std::string &restrict str2)
-{
- const size_t s1 = str1.size();
- const size_t s2 = str2.size();
- if (s1 < s2)
- return;
- if (str1.substr(s1 - s2) == str2)
- str1 = str1.substr(0, s1 - s2);
-}
-
-bool findCutFirst(std::string &restrict str1,
- const std::string &restrict str2)
-{
- const size_t s1 = str1.size();
- const size_t s2 = str2.size();
- if (s1 < s2)
- return false;
- if (str1.substr(0, s2) == str2)
- {
- str1 = str1.substr(s2);
- return true;
- }
- return false;
-}
-
-void cutFirst(std::string &restrict str1,
- const std::string &restrict str2)
-{
- const size_t s1 = str1.size();
- const size_t s2 = str2.size();
- if (s1 < s2)
- return;
- if (str1.substr(0, s2) == str2)
- str1 = str1.substr(s2);
-}
-
-std::string &removeProtocol(std::string &url)
-{
- const size_t i = url.find("://");
- if (i != std::string::npos)
- url = url.substr(i + 3);
- return url;
-}
-
-bool strStartWith(const std::string &restrict str1,
- const std::string &restrict str2)
-{
- const size_t sz2 = str2.size();
- if (str1.size() < sz2)
- return false;
- return str1.substr(0, sz2) == str2;
-}
-
-std::string getDateString()
-{
- char buffer[80];
- time_t rawtime;
- time(&rawtime);
- const tm *const timeinfo = localtime(&rawtime);
-
- strftime(buffer, 79, "%Y-%m-%d", timeinfo);
- return std::string(buffer);
-}
-
-std::string getDateTimeString()
-{
- char buffer[80];
- time_t rawtime;
- time(&rawtime);
- const tm *const timeinfo = localtime(&rawtime);
-
- strftime(buffer, 79, "%Y-%m-%d %H:%M:%S", timeinfo);
- return std::string(buffer);
-}
-
-signed char parseBoolean(const std::string &value)
-{
- std::string txt = value;
- toLower(trim(txt));
- if (txt == "true" || txt == "yes" || txt == "on" || txt == "1")
- return 1;
- else if (txt == "false" || txt == "no" || txt == "off" || txt == "0")
- return 0;
- else
- return -1;
-}
-
-std::string encodeLinkText(std::string data)
-{
- return replaceAll(data, "|", "\342\235\230");
-}
-
-std::string decodeLinkText(std::string data)
-{
- return replaceAll(data, "\342\235\230", "|");
-}
-
-std::string toStringPrint(const unsigned int val)
-{
- static char str[100];
- snprintf(str, sizeof(str), "%u 0x%x", val, val);
- str[99] = 0;
- return str;
-}
-
-std::string toString(uint32_t num)
-{
- char buf[30];
- buf[29] = '\0';
- size_t idx = 28;
- do
- buf[idx--] = CAST_8((num % 10) + '0');
- while ((num /= 10) != 0);
- return buf + idx + 1;
-}
-
-std::string toString(uint64_t num)
-{
- char buf[100];
- buf[99] = '\0';
- size_t idx = 98;
- do
- buf[idx--] = CAST_8((num % 10) + '0');
- while ((num /= 10) != 0);
- return buf + idx + 1;
-}
-
-std::string toString(uint16_t num)
-{
- char buf[10];
- buf[9] = '\0';
- size_t idx = 8;
- do
- buf[idx--] = CAST_8((num % 10) + '0');
- while ((num /= 10) != 0);
- return buf + idx + 1;
-}
-
-std::string toString(unsigned char num)
-{
- char buf[5];
- buf[4] = '\0';
- size_t idx = 3;
- do
- buf[idx--] = CAST_8((num % 10) + '0');
- while ((num /= 10) != 0);
- return buf + idx + 1;
-}
-
-std::string toString(int32_t num)
-{
- char buf[30];
- bool useSign(false);
- buf[29] = '\0';
- size_t idx = 28;
-
- if (num < 0)
- {
- useSign = true;
- num = -num;
- }
- do
- buf[idx--] = CAST_8((num % 10) + '0');
- while ((num /= 10) != 0);
- if (useSign)
- buf[idx--] = '-';
- return buf + idx + 1;
-}
-
-std::string toString(const float num)
-{
- return strprintf("%f", num);
-}
-
-std::string toString(const double num)
-{
- return strprintf("%f", static_cast<float>(num));
-}
-
-bool isDigit(const std::string &str)
-{
- if (str.empty())
- return false;
- const size_t sz = str.size();
- for (size_t f = 0; f < sz; f ++)
- {
- const char &chr = str[f];
- if (chr < '0' || chr > '9')
- return false;
- }
- return true;
-}
-
-void secureChatCommand(std::string &str)
-{
- if (str[0] == '/' || str[0] == '@' || str[0] == '#')
- str = "_" + str;
-}
-
-bool parse2Int(const std::string &args,
- int &x,
- int &y)
-{
- bool isValid = false;
- size_t pos = args.find(' ');
- if (pos == std::string::npos)
- pos = args.find(',');
- if (pos != std::string::npos)
- {
- if (pos + 1 < args.length())
- {
- x = atoi(args.substr(0, pos).c_str());
- y = atoi(args.substr(pos + 1, args.length()).c_str());
- isValid = true;
- }
- }
- return isValid;
-}
-
-bool parse2Str(const std::string &args,
- std::string &str1,
- std::string &str2)
-{
- bool isValid = false;
- size_t pos = args.find(' ');
- if (pos == std::string::npos)
- pos = args.find(',');
- if (pos != std::string::npos)
- {
- if (pos + 1 < args.length())
- {
- str1 = args.substr(0, pos);
- str2 = args.substr(pos + 1, args.length());
- isValid = true;
- }
- }
- return isValid;
-}
-
-uint32_t parseNumber(const std::string &str)
-{
- uint32_t i = 0;
- int idx = 0;
- if (strStartWith(str, "0x"))
- idx = 2;
- else if (str[0] == 'h' || str[0] == 'x')
- idx = 1;
- if (idx > 0)
- sscanf(str.substr(idx).c_str(), "%10x", &i);
- else
- i = atoi(str.c_str());
- return i;
-}
-
-std::string removeToken(std::string &str,
- const std::string &token)
-{
- const size_t idx = str.find(token);
- if (idx > 0 && idx != std::string::npos)
- str = str.substr(idx + 1);
- else
- str.clear();
- return str;
-}
-
-std::string timeToStr(const uint32_t time)
-{
- char buf[101];
- const time_t tempTime = time;
- tm *const timeInfo = localtime(&tempTime);
- if (strftime(&buf[0], 100, "%Y-%m-%d_%H-%M-%S", timeInfo) != 0u)
- return std::string(buf);
- return "unknown";
-}
-
-std::string timeDiffToString(int timeDiff)
-{
- std::string str;
-
- const int weeks = timeDiff / 60 / 60 / 24 / 7;
- if (weeks > 0)
- {
- // TRANSLATORS: uptime command
- str = strprintf(ngettext(N_("%d week"), N_("%d weeks"),
- weeks), weeks);
- timeDiff -= weeks * 60 * 60 * 24 * 7;
- }
-
- const int days = timeDiff / 60 / 60 / 24;
- if (days > 0)
- {
- if (!str.empty())
- str.append(", ");
- // TRANSLATORS: uptime command
- str.append(strprintf(ngettext(N_("%d day"), N_("%d days"),
- days), days));
- timeDiff -= days * 60 * 60 * 24;
- }
- const int hours = timeDiff / 60 / 60;
- if (hours > 0)
- {
- if (!str.empty())
- str.append(", ");
- // TRANSLATORS: uptime command
- str.append(strprintf(ngettext(N_("%d hour"), N_("%d hours"),
- hours), hours));
- timeDiff -= hours * 60 * 60;
- }
- const int min = timeDiff / 60;
- if (min > 0)
- {
- if (!str.empty())
- str.append(", ");
- // TRANSLATORS: uptime command
- str.append(strprintf(ngettext(N_("%d minute"), N_("%d minutes"),
- min), min));
- timeDiff -= min * 60;
- }
-
- if (timeDiff > 0)
- {
- if (!str.empty())
- str.append(", ");
- // TRANSLATORS: uptime command
- str.append(strprintf(ngettext(N_("%d second"), N_("%d seconds"),
- timeDiff), timeDiff));
- }
- if (str.empty())
- {
- // TRANSLATORS: uptime command
- str.append(strprintf(ngettext(N_("%d second"), N_("%d seconds"),
- 0), 0));
- }
- return str;
-}
-
-std::string escapeString(std::string str)
-{
- replaceAll(str, "\"", "\\\"");
- return "\"" + str + "\"";
-}
-
-void sanitizePath(std::string &path)
-{
-#ifdef WIN32
- const char sepStr = '\\';
- const std::string sep2Str = "\\\\";
- const std::string sepWrongStr = "/";
-#else
- const char sepStr = '/';
- const std::string sep2Str = "//";
- const std::string sepWrongStr = "\\";
-#endif
- replaceRecursiveAll(path, sepWrongStr, sepStr);
- replaceRecursiveAll(path, sep2Str, sepStr);
-}
-
-std::string pathJoin(std::string str1,
- const std::string &str2)
-{
-#ifdef WIN32
- const char sep = '\\';
- std::string sepStr = "\\";
-#else
- const char sep = '/';
- std::string sepStr = "/";
-#endif
-
- if (str1.empty())
- {
- if (str2[0] == sep)
- return str2;
- return sepStr.append(str2);
- }
- const size_t sz1 = str1.size();
- if (str2.empty())
- {
- if (str1[sz1 - 1] == sep)
- return str1;
- return str1.append(sepStr);
- }
- if (str1[sz1 - 1] == sep)
- {
- if (str2[0] == sep)
- return str1.append(str2.substr(1));
- return str1.append(str2);
- }
- else
- {
- if (str2[0] == sep)
- return str1.append(str2);
- return str1.append(sepStr).append(str2);
- }
-}
-
-std::string pathJoin(std::string str1,
- const std::string &str2,
- const std::string &str3)
-{
-#ifdef WIN32
- const char sep = '\\';
- std::string sepStr = "\\";
-#else
- const char sep = '/';
- std::string sepStr = "/";
-#endif
-
- if (str1.empty())
- {
- return pathJoin(str2, str3);
- }
- size_t sz1 = str1.size();
- if (str2.empty())
- {
- return pathJoin(str1, str3);
- }
- if (str3.empty())
- {
- return pathJoin(str1, str2);
- }
- if (str1[sz1 - 1] == sep)
- {
- if (str2[0] == sep)
- str1.append(str2.substr(1));
- else
- str1.append(str2);
- }
- else
- {
- if (str2[0] == sep)
- str1.append(str2);
- else
- str1.append(sepStr).append(str2);
- }
-
- sz1 = str1.size();
- if (str1[sz1 - 1] == sep)
- {
- if (str3[0] == sep)
- return str1.append(str3.substr(1));
- return str1.append(str3);
- }
- else
- {
- if (str3[0] == sep)
- return str1.append(str3);
- return str1.append(sepStr).append(str3);
- }
-}
-
-std::string urlJoin(std::string str1,
- const std::string &str2)
-{
- const char sep = '/';
- std::string sepStr = "/";
-
- if (str1.empty())
- {
- if (str2[0] == sep)
- return str2;
- return sepStr.append(str2);
- }
- const size_t sz1 = str1.size();
- if (str2.empty())
- {
- if (str1[sz1 - 1] == sep)
- return str1;
- return str1.append(sepStr);
- }
- if (str1[sz1 - 1] == sep)
- {
- if (str2[0] == sep)
- return str1.append(str2.substr(1));
- return str1.append(str2);
- }
- else
- {
- if (str2[0] == sep)
- return str1.append(str2);
- return str1.append(sepStr).append(str2);
- }
-}
-
-#ifndef DYECMD
-void replaceItemLinks(std::string &msg)
-{
- // Check for item link
- size_t start2 = msg.find('[');
- size_t sz = msg.size();
- while (start2 + 1 < sz &&
- start2 != std::string::npos &&
- msg[start2 + 1] != '@')
- {
- const size_t end = msg.find(']', start2);
- if (start2 + 1 != end &&
- end != std::string::npos)
- {
- // Catch multiple embeds and ignore them
- // so it doesn't crash the client.
- while ((msg.find('[', start2 + 1) != std::string::npos) &&
- (msg.find('[', start2 + 1) < end))
- {
- start2 = msg.find('[', start2 + 1);
- }
-
- if (start2 + 1 < sz &&
- end < sz &&
- end > start2 + 1)
- {
- std::string itemStr = msg.substr(start2 + 1, end - start2 - 1);
-
- StringVect parts;
- splitToStringVector(parts, itemStr, ',');
- if (parts.empty())
- return;
-
- const ItemInfo &itemInfo = ItemDB::get(parts[0]);
- const int itemId = itemInfo.getId();
- if (itemId != 0)
- {
- std::string temp = strprintf("@@%d", itemId);
- std::string name = parts[0];
- msg.erase(start2 + 1, end - start2 - 1);
- parts.erase(parts.begin());
- if (!parts.empty())
- name.clear();
-
- FOR_EACH (StringVectCIter, it, parts)
- {
- std:: string str = *it;
- trim(str);
- const ItemInfo &itemInfo2 = ItemDB::get(str);
- const int cardId = itemInfo2.getId();
- if (cardId != 0)
- temp.append(strprintf(",%d", cardId));
- }
- temp.append("|");
- temp.append(name);
- temp.append("@@");
- msg.insert(start2 + 1, temp);
- sz = msg.size();
- }
- }
- }
- start2 = msg.find('[', start2 + 1);
- }
-}
-#else // DYECMD
-
-void replaceItemLinks(std::string &msg A_UNUSED)
-{
-}
-#endif // DYECMD
diff --git a/src/utils/stringutils.h b/src/utils/stringutils.h
deleted file mode 100644
index 1b93c41d7..000000000
--- a/src/utils/stringutils.h
+++ /dev/null
@@ -1,288 +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 UTILS_STRINGUTILS_H
-#define UTILS_STRINGUTILS_H
-
-#include "utils/stringvector.h"
-
-#include <list>
-#include <set>
-
-#include "localconsts.h"
-
-/**
- * Trims spaces off the end and the beginning of the given string.
- *
- * @param str the string to trim spaces off
- * @return a reference to the trimmed string
- */
-std::string &trim(std::string &str);
-
-/**
- * Converts the given string to lower case.
- *
- * @param str the string to convert to lower case
- * @return a reference to the given string converted to lower case
- */
-std::string &toLower(std::string &str);
-
-/**
- * Converts the given string to upper case.
- *
- * @param str the string to convert to upper case
- * @return a reference to the given string converted to upper case
- */
-std::string &toUpper(std::string &str);
-
-
-/**
- * Converts an ascii hexidecimal string to an integer
- *
- * @param str the hex string to convert to an int
- * @return the integer representation of the hex string
- */
-unsigned int atox(const std::string &str) A_WARN_UNUSED;
-
-/**
- * Converts the given value to a string.
- *
- * @param num the value to convert to a string
- * @return the string representation of arg
- */
-std::string toString(uint32_t num);
-
-std::string toString(uint64_t num);
-
-std::string toString(unsigned char num);
-
-std::string toString(int32_t num);
-
-std::string toString(uint16_t num);
-
-std::string toString(const float num);
-
-std::string toString(const double num);
-
-std::string toStringPrint(const unsigned int val);
-
-/**
- * Converts the given IP address to a string.
- *
- * The returned string is statically allocated, and shouldn't be freed. It is
- * changed upon the next use of this method.
- *
- * @param address the address to convert to a string
- * @return the string representation of the address
- */
-const char *ipToString(const uint32_t address) A_WARN_UNUSED;
-
-/**
- * A safe version of sprintf that returns a std::string of the result.
- */
-std::string strprintf(const char *const format, ...) A_NONNULL(1) A_WARN_UNUSED
-#ifdef __GNUC__
-#ifdef __OpenBSD__
- __attribute__((__format__(printf, 1, 2)))
-#else // __OpenBSD__
- __attribute__((__format__(gnu_printf, 1, 2)))
-#endif // __OpenBSD__
-#endif // __GNUC__
-;
-
-/**
- * Removes colors from a string
- *
- * @param msg the string to remove the colors from
- * @return string without colors
- */
-std::string removeColors(std::string msg) A_WARN_UNUSED;
-
-const std::string findSameSubstring(const std::string &restrict str1,
- const std::string &restrict str2);
-
-const std::string findSameSubstringI(const std::string &restrict str1,
- const std::string &restrict str2);
-
-/**
- * Compares the two strings case-insensitively.
- *
- * @param a the first string in the comparison
- * @param b the second string in the comparison
- * @return 0 if the strings are equal, positive if the first is greater,
- * negative if the second is greater
- */
-int compareStrI(const std::string &a, const std::string &b) A_WARN_UNUSED;
-
-/**
- * Tells wether the character is a word separator.
- */
-bool isWordSeparator(const signed char chr) A_CONST A_WARN_UNUSED;
-
-size_t findI(std::string str, std::string subStr) A_WARN_UNUSED;
-
-size_t findI(std::string text, const StringVect &list) A_WARN_UNUSED;
-
-size_t findAny(const std::string &restrict text,
- const std::string &restrict chars,
- const size_t pos) A_WARN_UNUSED;
-
-const std::string encodeStr(unsigned int value,
- const unsigned int size = 0) A_WARN_UNUSED;
-
-unsigned int decodeStr(const std::string &str) A_WARN_UNUSED;
-
-std::string extractNameFromSprite(std::string str) A_WARN_UNUSED;
-
-std::string removeSpriteIndex(std::string str) A_WARN_UNUSED;
-
-const char* getSafeUtf8String(const std::string &text) A_WARN_UNUSED;
-
-void getSafeUtf8String(std::string text, char *const buf);
-
-std::string getFileName(const std::string &path) A_WARN_UNUSED;
-
-std::string getFileDir(const std::string &path) A_WARN_UNUSED;
-
-std::string& replaceAll(std::string& context,
- const std::string &restrict from,
- const std::string &restrict to);
-
-void replaceRecursiveAll(std::string& context,
- const std::string &restrict from,
- const char to);
-
-/**
- * Returns a bool value depending on the given string value.
- *
- * @param text the string used to get the bool value
- * @return a boolean value..
- */
-bool getBoolFromString(const std::string &text) A_WARN_UNUSED;
-
-void replaceSpecialChars(std::string &text);
-
-/**
- * Normalize a string, which means lowercase and trim it.
- */
-std::string normalize(const std::string &name) A_WARN_UNUSED;
-
-void splitToIntSet(std::set<int> &tokens, const std::string &text,
- const char separator);
-
-std::list<int> splitToIntList(const std::string &text,
- const char separator) A_WARN_UNUSED;
-
-std::list<std::string> splitToStringList(const std::string &text,
- const char separator) A_WARN_UNUSED;
-
-void splitToStringVector(StringVect &tokens,
- const std::string &text, const char separator);
-
-void splitToStringSet(std::set<std::string> &tokens,
- const std::string &text, const char separator);
-
-void splitToIntVector(STD_VECTOR<int> &tokens,
- const std::string &text, const char separator);
-
-std::string combineDye(std::string file, const std::string &dye) A_WARN_UNUSED;
-
-std::string combineDye2(std::string file,
- const std::string &dye) A_WARN_UNUSED;
-
-std::string combineDye3(std::string file,
- const std::string &dye) A_WARN_UNUSED;
-
-std::string packList(const std::list<std::string> &list) A_WARN_UNUSED;
-
-std::list<std::string> unpackList(const std::string &str) A_WARN_UNUSED;
-
-std::string stringToHexPath(const std::string &str) A_WARN_UNUSED;
-
-void deleteCharLeft(std::string &str, unsigned *const pos);
-
-bool findLast(const std::string &restrict str1,
- const std::string &restrict str2) A_WARN_UNUSED;
-
-bool findFirst(const std::string &restrict str1,
- const std::string &restrict str2) A_WARN_UNUSED;
-
-bool findCutLast(std::string &restrict str1,
- const std::string &restrict str2) A_WARN_UNUSED;
-
-void cutLast(std::string &restrict str1,
- const std::string &restrict str2);
-
-bool findCutFirst(std::string &restrict str1,
- const std::string &restrict str2);
-
-void cutFirst(std::string &restrict str1,
- const std::string &restrict str2);
-
-std::string &removeProtocol(std::string &url);
-
-bool strStartWith(const std::string &restrict str,
- const std::string &restrict start) A_WARN_UNUSED;
-
-std::string getDateString() A_WARN_UNUSED;
-
-std::string getDateTimeString() A_WARN_UNUSED;
-
-signed char parseBoolean(const std::string &value);
-
-std::string encodeLinkText(std::string data);
-
-std::string decodeLinkText(std::string data);
-
-bool isDigit(const std::string &str);
-
-void secureChatCommand(std::string &str);
-
-bool parse2Int(const std::string &args, int &x, int &y);
-
-bool parse2Str(const std::string &args, std::string &str1, std::string &str2);
-
-uint32_t parseNumber(const std::string &str);
-
-std::string removeToken(std::string &str, const std::string &token);
-
-std::string timeToStr(const uint32_t time);
-
-std::string timeDiffToString(int timeDiff);
-
-void replaceItemLinks(std::string &msg);
-
-std::string escapeString(std::string str);
-
-void sanitizePath(std::string &path);
-
-std::string pathJoin(std::string str1,
- const std::string &str2);
-
-std::string pathJoin(std::string str1,
- const std::string &str2,
- const std::string &str3);
-
-std::string urlJoin(std::string str1,
- const std::string &str2);
-
-#endif // UTILS_STRINGUTILS_H
diff --git a/src/utils/stringvector.h b/src/utils/stringvector.h
deleted file mode 100644
index 18a53881c..000000000
--- a/src/utils/stringvector.h
+++ /dev/null
@@ -1,32 +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 UTILS_STRINGVECTOR_H
-#define UTILS_STRINGVECTOR_H
-
-#include "utils/vector.h"
-
-#include <string>
-
-typedef STD_VECTOR<std::string> StringVect;
-typedef StringVect::iterator StringVectIter;
-typedef StringVect::const_iterator StringVectCIter;
-
-#endif // UTILS_STRINGVECTOR_H
diff --git a/src/utils/timer.cpp b/src/utils/timer.cpp
deleted file mode 100644
index 21ef307ba..000000000
--- a/src/utils/timer.cpp
+++ /dev/null
@@ -1,124 +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 "utils/timer.h"
-
-#include "const/utils/timer.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_timer.h>
-PRAGMA48(GCC diagnostic pop)
-
-#include <climits>
-
-#include "debug.h"
-
-namespace
-{
-#ifdef USE_SDL2
- SDL_TimerID mLogicCounterId(0);
- SDL_TimerID mSecondsCounterId(0);
-#else // USE_SDL2
-
- SDL_TimerID mLogicCounterId(nullptr);
- SDL_TimerID mSecondsCounterId(nullptr);
-#endif // USE_SDL2
-} // namespace
-
-/**
- * Tells the max tick value,
- * setting it back to zero (and start again).
- */
-static const int MAX_TICK_VALUE = INT_MAX / 2;
-
-volatile int tick_time; /**< Tick counter */
-volatile int fps = 0; /**< Frames counted in the last second */
-volatile int lps = 0; /**< Logic processed per second */
-volatile int frame_count = 0; /**< Counts the frames during one second */
-volatile int logic_count = 0; /**< Counts the logic during one second */
-volatile time_t cur_time = 0;
-
-static uint32_t nextTick(uint32_t interval, void *param A_UNUSED);
-static uint32_t nextSecond(uint32_t interval, void *param A_UNUSED);
-
-/**
- * Advances game logic counter.
- * Called every 10 milliseconds by SDL_AddTimer()
- * @see MILLISECONDS_IN_A_TICK value
- */
-static uint32_t nextTick(uint32_t interval, void *param A_UNUSED)
-{
- tick_time++;
- if (tick_time == MAX_TICK_VALUE)
- tick_time = 0;
- return interval;
-}
-
-/**
- * Updates fps.
- * Called every seconds by SDL_AddTimer()
- */
-static uint32_t nextSecond(uint32_t interval, void *param A_UNUSED)
-{
- fps = frame_count;
- lps = logic_count;
- frame_count = 0;
- logic_count = 0;
-
- return interval;
-}
-
-/**
- * @return the elapsed time in milliseconds
- * between two tick values.
- */
-int get_elapsed_time(const int startTime)
-{
- const int time = tick_time;
- if (startTime <= time)
- {
- return (time - startTime) * MILLISECONDS_IN_A_TICK;
- }
- return (time + (MAX_TICK_VALUE - startTime))
- * MILLISECONDS_IN_A_TICK;
-}
-
-int get_elapsed_time1(const int startTime)
-{
- const int time = tick_time;
- if (startTime <= time)
- return time - startTime;
- return time + (MAX_TICK_VALUE - startTime);
-}
-
-void startTimers()
-{
- // Initialize logic and seconds counters
- tick_time = 0;
- mLogicCounterId = SDL_AddTimer(MILLISECONDS_IN_A_TICK, nextTick, nullptr);
- mSecondsCounterId = SDL_AddTimer(1000, nextSecond, nullptr);
-}
-
-void stopTimers()
-{
- SDL_RemoveTimer(mLogicCounterId);
- SDL_RemoveTimer(mSecondsCounterId);
-}
diff --git a/src/utils/timer.h b/src/utils/timer.h
deleted file mode 100644
index ea1d21e31..000000000
--- a/src/utils/timer.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 UTILS_TIMER_H
-#define UTILS_TIMER_H
-
-#include "localconsts.h"
-
-extern volatile int fps;
-extern volatile int lps;
-extern volatile int tick_time;
-extern volatile time_t cur_time;
-extern volatile int frame_count;
-extern volatile int logic_count;
-
-void startTimers();
-
-void stopTimers();
-
-/**
- * Returns elapsed time. (Warning: supposes the delay is always < 100 seconds)
- */
-int get_elapsed_time(const int startTime) A_WARN_UNUSED;
-
-int get_elapsed_time1(const int startTime) A_WARN_UNUSED;
-
-#endif // UTILS_TIMER_H
diff --git a/src/utils/translation/podict.cpp b/src/utils/translation/podict.cpp
deleted file mode 100644
index cd374319f..000000000
--- a/src/utils/translation/podict.cpp
+++ /dev/null
@@ -1,61 +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 "utils/translation/podict.h"
-
-#include "debug.h"
-
-std::string empty;
-
-PoDict *translator = nullptr;
-PoDict *dictionary = nullptr;
-PoDict *reverseDictionary = nullptr;
-#ifdef ENABLE_CUSTOMNLS
-PoDict *mainTranslator = nullptr;
-#endif // ENABLE_CUSTOMNLS
-
-PoDict::PoDict(const std::string &lang) :
- mPoLines(),
- mLang(lang)
-{
-}
-
-PoDict::~PoDict()
-{
-}
-
-const std::string PoDict::getStr(const std::string &str)
-{
- if (mPoLines.find(str) == mPoLines.end())
- return str;
- return mPoLines[str];
-}
-
-const char *PoDict::getChar(const char *const str)
-{
- if (mPoLines.find(str) == mPoLines.end())
- return str;
- return mPoLines[str].c_str();
-}
-
-bool PoDict::haveStr(const std::string &str) const
-{
- return mPoLines.find(str) != mPoLines.end();
-}
diff --git a/src/utils/translation/podict.h b/src/utils/translation/podict.h
deleted file mode 100644
index d8f47b896..000000000
--- a/src/utils/translation/podict.h
+++ /dev/null
@@ -1,73 +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 UTILS_TRANSLATION_PODICT_H
-#define UTILS_TRANSLATION_PODICT_H
-
-#include <map>
-#include <string>
-
-#include "localconsts.h"
-
-typedef std::map <std::string, std::string> PoMap;
-
-class PoDict final
-{
- public:
- explicit PoDict(const std::string &lang);
-
- A_DELETE_COPY(PoDict)
-
- ~PoDict();
-
- const std::string getStr(const std::string &str);
-
- const char *getChar(const char *const str);
-
- bool haveStr(const std::string &str) const;
-
-#ifndef UNITTESTS
- protected:
-#endif // UNITTESTS
- friend class PoParser;
- friend class TranslationManager;
-
- PoMap *getMap()
- { return &mPoLines; }
-
- void set(const std::string &key, const std::string &value)
- { mPoLines[key] = value; }
-
- void setLang(const std::string &lang)
- { mLang = lang; }
-
- private:
- PoMap mPoLines;
- std::string mLang;
-};
-
-extern PoDict *translator;
-extern PoDict *dictionary;
-extern PoDict *reverseDictionary;
-#ifdef ENABLE_CUSTOMNLS
-extern PoDict *mainTranslator;
-#endif // ENABLE_CUSTOMNLS
-
-#endif // UTILS_TRANSLATION_PODICT_H
diff --git a/src/utils/translation/poparser.cpp b/src/utils/translation/poparser.cpp
deleted file mode 100644
index 399980a21..000000000
--- a/src/utils/translation/poparser.cpp
+++ /dev/null
@@ -1,286 +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 "utils/translation/poparser.h"
-
-#include "fs/virtfs/fs.h"
-
-#include "utils/stringutils.h"
-
-#include "utils/translation/podict.h"
-
-#include "logger.h"
-
-#include "debug.h"
-
-PoParser::PoParser() :
- mLang(),
- mFile(),
- mLine(),
- mMsgId(),
- mMsgStr(),
- mDict(nullptr),
- mReadingId(false),
- mReadingStr(false),
- mSkipId(false)
-{
-}
-
-void PoParser::openFile(const std::string &name)
-{
- int size;
- const char *buf = VirtFs::loadFile(getFileName(name), size);
-
- if (buf != nullptr)
- {
- mFile.str(std::string(buf, size));
- delete [] buf;
- }
- else
- {
- mFile.clear();
- }
-}
-
-PoDict *PoParser::load(const std::string &restrict lang,
- const std::string &restrict fileName,
- PoDict *restrict const dict)
-{
- logger->log("loading lang: %s, file: %s", lang.c_str(), fileName.c_str());
-
- setLang(lang);
- if (dict == nullptr)
- mDict = getDict();
- else
- mDict = dict;
-
- if (fileName.empty())
- openFile(mLang);
- else
- openFile(fileName);
-
- mMsgId.clear();
- mMsgStr.clear();
-
- // cycle by msgid+msgstr
- while (readLine())
- {
- // reading msgid
- while (readMsgId())
- {
- if (!readLine())
- break;
- }
-
- if (!mMsgId.empty())
- {
- // if we got msgid then reading msgstr
- while (readMsgStr())
- {
- if (!readLine())
- break;
- }
- }
-
- if (!mMsgId.empty() && !mMsgStr.empty())
- {
-// logger->log("add key: " + mMsgId);
-// logger->log("add value: " + mMsgStr);
-
- convertStr(mMsgId);
- convertStr(mMsgStr);
- // store key and value
- mDict->set(mMsgId, mMsgStr);
- }
-
- mMsgId.clear();
- mMsgStr.clear();
- }
-
- return mDict;
-}
-
-bool PoParser::readLine()
-{
- char line[1001];
- if (!mFile.getline(line, 1000))
- return false;
- // skip plurals msgid if present
- if (strStartWith(line, "msgid_plural \""))
- {
- if (!mFile.getline(line, 1000))
- return false;
- }
- mLine = line;
- return true;
-}
-
-bool PoParser::readMsgId()
-{
- // if we reading msgstr then stop here
- if (mReadingStr)
- return false;
-
- const std::string msgId1("msgid \"");
-
- // check if in reading process
- if (mReadingId)
- {
- // if we get empty line in file then stop reading
- if (mLine.empty())
- {
- mReadingId = false;
- return false;
- }
- else if (checkLine())
- {
- // reading text from: "text"
- mMsgId.append(mLine.substr(1, mLine.size() - 2));
- mLine.clear();
- return true;
- }
- // stop reading in other case
- mReadingId = false;
- return false;
- }
-
- // check line start from msgid "
- if (strStartWith(mLine, msgId1))
- {
- if (!mSkipId)
- { // translation not fuzzed and can be processed
- mReadingId = true;
- const size_t msgId1Size = msgId1.size();
- // reading text from: msgid "text"
- mMsgId.append(mLine.substr(msgId1Size,
- mLine.size() - 1 - msgId1Size));
- }
- else
- { // skipped fuzzed translation. reset skip flag
- mSkipId = false;
- }
- mLine.clear();
- return true;
- }
- else if (mLine == "#, fuzzy")
- { // check for fuzzy translation
- mSkipId = true;
- mLine.clear();
- return true;
- }
- // stop reading if we don't read msgid before
- return mMsgId.empty();
-}
-
-bool PoParser::readMsgStr()
-{
- // normal msgstr
- const std::string msgStr1("msgstr \"");
- // plurals first msgstr
- const std::string msgStr2("msgstr[0] \"");
-
- // check if in reading process
- if (mReadingStr)
- {
- // if we get empty line in file then stop reading
- if (mLine.empty())
- {
- mReadingStr = false;
- return false;
- }
- if (checkLine())
- {
- // reading text from: "text"
- mMsgStr.append(mLine.substr(1, mLine.size() - 2));
- mLine.clear();
- return true;
- }
- // stop reading in other case
- mReadingStr = false;
- }
- else
- {
- // check line start from msgstr "
- if (strStartWith(mLine, msgStr1))
- {
- mReadingStr = true;
- const size_t msgStr1Size = msgStr1.size();
- // reading text from: msgstr "text"
- mMsgStr.append(mLine.substr(msgStr1Size,
- mLine.size() - 1 - msgStr1Size));
- mLine.clear();
- return true;
- }
- // checl list start from msgstr[0] "
- else if (strStartWith(mLine, msgStr2))
- {
- mReadingStr = true;
- const size_t msgStr2Size = msgStr2.size();
- // reading text from: msgstr[0] "text"
- mMsgStr.append(mLine.substr(msgStr2Size,
- mLine.size() - 1 - msgStr2Size));
- mLine.clear();
- return true;
- }
- }
-
- // stop reading in other case
- return false;
-}
-
-bool PoParser::checkLine() const
-{
- const size_t sz = mLine.size();
- // check is line in format: "text"
- return sz > 2 && mLine[0] == '\"' && mLine[sz - 1] == '\"';
-}
-
-PoDict *PoParser::getEmptyDict()
-{
- return new PoDict("");
-}
-
-bool PoParser::checkLang(const std::string &lang)
-{
- // check is po file exists
- return VirtFs::exists(getFileName(lang));
-}
-
-std::string PoParser::getFileName(const std::string &lang)
-{
- // get po file name from lang name
-// logger->log("getFileName: translations/%s.po", lang.c_str());
- return strprintf("translations/%s.po", lang.c_str());
-}
-
-PoDict *PoParser::getDict() const
-{
- return new PoDict(mLang);
-}
-
-void PoParser::convertStr(std::string &str)
-{
- if (str.empty())
- return;
-
- replaceAll(str, "\\n", "\n");
- replaceAll(str, "\\\"", "\"");
- replaceAll(str, "\\\\", "\\");
-}
diff --git a/src/utils/translation/poparser.h b/src/utils/translation/poparser.h
deleted file mode 100644
index 9f6fd7d35..000000000
--- a/src/utils/translation/poparser.h
+++ /dev/null
@@ -1,87 +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 UTILS_TRANSLATION_POPARSER_H
-#define UTILS_TRANSLATION_POPARSER_H
-
-#include "localconsts.h"
-
-#include <sstream>
-
-class PoDict;
-
-class PoParser final
-{
- public:
- PoParser();
-
- A_DELETE_COPY(PoParser)
-
- PoDict *load(const std::string &restrict lang,
- const std::string &restrict fileName = "",
- PoDict *restrict const dict = nullptr);
-
- static bool checkLang(const std::string &lang);
-
- static PoDict *getEmptyDict();
-
- private:
- void setLang(const std::string &lang)
- { mLang = lang; }
-
- void openFile(const std::string &name);
-
- bool readLine();
-
- bool readMsgId();
-
- bool readMsgStr();
-
- bool checkLine() const;
-
- static std::string getFileName(const std::string &lang);
-
- PoDict *getDict() const RETURNS_NONNULL A_WARN_UNUSED;
-
- static void convertStr(std::string &str);
-
- // current lang
- std::string mLang;
-
- // po file object
- std::istringstream mFile;
-
- // current line from po file
- std::string mLine;
-
- std::string mMsgId;
-
- std::string mMsgStr;
-
- PoDict *mDict;
-
- bool mReadingId;
-
- bool mReadingStr;
-
- bool mSkipId;
-};
-
-#endif // UTILS_TRANSLATION_POPARSER_H
diff --git a/src/utils/translation/translationmanager.cpp b/src/utils/translation/translationmanager.cpp
deleted file mode 100644
index d02ff2c02..000000000
--- a/src/utils/translation/translationmanager.cpp
+++ /dev/null
@@ -1,154 +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 "utils/translation/translationmanager.h"
-
-#include "fs/virtfs/fs.h"
-
-#include "utils/delete2.h"
-#include "utils/stringutils.h"
-
-#include "utils/foreach.h"
-
-#include "utils/translation/podict.h"
-#include "utils/translation/poparser.h"
-
-#include "logger.h"
-
-#include "debug.h"
-
-void TranslationManager::init()
-{
- delete translator;
- translator = PoParser::getEmptyDict();
-}
-
-void TranslationManager::loadCurrentLang()
-{
- delete translator;
- translator = loadLang(getLang(), "");
- translator = loadLang(getLang(), "help/", translator);
-}
-
-void TranslationManager::loadDictionaryLang()
-{
- delete dictionary;
- delete reverseDictionary;
- dictionary = loadLang(getServerLang(), "dict/");
- reverseDictionary = reverseLang(dictionary);
-}
-
-#ifdef ENABLE_CUSTOMNLS
-void TranslationManager::loadGettextLang()
-{
- delete mainTranslator;
- mainTranslator = loadLang(getLang(), "manaplus/");
-}
-#endif // ENABLE_CUSTOMNLS
-
-void TranslationManager::close()
-{
- delete2(translator);
- delete2(dictionary);
- delete2(reverseDictionary);
-}
-
-PoDict *TranslationManager::loadLang(const LangVect &lang,
- const std::string &subName,
- PoDict *const dict)
-{
- std::string name;
- PoParser parser;
-
- FOR_EACH (LangIter, it, lang)
- {
- if (*it == "C")
- continue;
-
-// logger->log("check file: " + subName + *it);
- if (PoParser::checkLang(subName + *it))
- {
- name = *it;
- break;
- }
- }
- if (!name.empty())
- return parser.load(name, subName + name, dict);
- logger->log("can't find client data translation");
- if (dict != nullptr)
- return dict;
- return PoParser::getEmptyDict();
-}
-
-bool TranslationManager::translateFile(const std::string &fileName,
- PoDict *const dict,
- StringVect &lines)
-{
- if ((dict == nullptr) || fileName.empty())
- return false;
-
- int contentsLength;
- const char *fileContents = VirtFs::loadFile(fileName,
- contentsLength);
-
- if (fileContents == nullptr)
- {
- logger->log("Couldn't load file: %s", fileName.c_str());
- return false;
- }
- std::string str = std::string(fileContents, contentsLength);
-
- size_t oldPos1 = std::string::npos;
- size_t pos1;
-
- while ((pos1 = str.find("<<")) != std::string::npos)
- {
- if (pos1 == oldPos1)
- break; // detected infinite loop
- const size_t pos2 = str.find(">>", pos1 + 2);
- if (pos2 == std::string::npos)
- break;
- const std::string key(str.substr(pos1 + 2, pos2 - pos1 - 2));
- const std::string key2("<<" + str.substr(
- pos1 + 2, pos2 - pos1 - 2) + ">>");
- const std::string val(dict->getStr(key));
- replaceAll(str, key2, val);
- oldPos1 = pos1;
- }
-
- std::istringstream iss(str);
- std::string line;
-
- while (getline(iss, line))
- lines.push_back(line);
-
- delete [] fileContents;
- return true;
-}
-
-PoDict *TranslationManager::reverseLang(const PoDict *const dict)
-{
- PoDict *const revDict = new PoDict(dict->mLang);
- FOR_EACH (PoMap::const_iterator, it, dict->mPoLines)
- {
- revDict->set((*it).second, (*it).first);
- }
- return revDict;
-}
diff --git a/src/utils/translation/translationmanager.h b/src/utils/translation/translationmanager.h
deleted file mode 100644
index 088d97449..000000000
--- a/src/utils/translation/translationmanager.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 UTILS_TRANSLATION_TRANSLATIONMANAGER_H
-#define UTILS_TRANSLATION_TRANSLATIONMANAGER_H
-
-#include "localconsts.h"
-
-#include "utils/langs.h"
-#include "utils/stringvector.h"
-
-class PoDict;
-
-class TranslationManager final
-{
- public:
- A_DELETE_COPY(TranslationManager)
-
- static PoDict *loadLang(const LangVect &lang,
- const std::string &subName,
- PoDict *const dict = nullptr);
-
- static void init();
-
- static void close();
-
- static void loadCurrentLang();
-
- static void loadDictionaryLang();
-
-#ifdef ENABLE_CUSTOMNLS
- static void loadGettextLang();
-#endif // ENABLE_CUSTOMNLS
-
- static bool translateFile(const std::string &fileName,
- PoDict *const dict,
- StringVect &lines);
- static PoDict *reverseLang(const PoDict *const dict);
-};
-
-#endif // UTILS_TRANSLATION_TRANSLATIONMANAGER_H
diff --git a/src/utils/vector.h b/src/utils/vector.h
deleted file mode 100644
index 6ec054edf..000000000
--- a/src/utils/vector.h
+++ /dev/null
@@ -1,32 +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 UTILS_VECTOR_H
-#define UTILS_VECTOR_H
-
-#ifdef ENABLE_STLDEBUG
-#include "debug/mse/msemstdvector.h"
-#define STD_VECTOR mse::mstd::vector
-#else // ENABLE_STLDEBUG
-#include <vector>
-#define STD_VECTOR std::vector
-#endif // ENABLE_STLDEBUG
-
-#endif // UTILS_VECTOR_H
diff --git a/src/utils/x11logger.cpp b/src/utils/x11logger.cpp
deleted file mode 100644
index 5b83886fe..000000000
--- a/src/utils/x11logger.cpp
+++ /dev/null
@@ -1,213 +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/>.
- */
-
-#ifdef USE_X11
-
-#include "utils/x11logger.h"
-
-#include "logger.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL_events.h>
-#include <SDL_syswm.h>
-PRAGMA48(GCC diagnostic pop)
-
-#include "utils/cast.h"
-#include "utils/stringutils.h"
-
-#include "debug.h"
-
-#define logType(val, str) \
- case val: \
- typeStr = str; \
- break
-
-bool X11Logger::logEvent(const SDL_Event &event)
-{
- if (event.syswm.msg->subsystem != SDL_SYSWM_X11)
- return false;
- std::string typeStr;
-
-#ifdef USE_SDL2
- XEvent &xEvent = event.syswm.msg->msg.x11.event;
-#else // USE_SDL2
-
- XEvent &xEvent = event.syswm.msg->event.xevent;
-#endif // USE_SDL2
-
- const int type = xEvent.type;
-
- switch (type)
- {
- logType(2, strprintf("KeyPress: %u,%u %d,%d",
- xEvent.xkey.keycode,
- xEvent.xkey.state,
- xEvent.xkey.x,
- xEvent.xkey.y));
- logType(3, strprintf("KeyRelease: %u,%u %d,%d",
- xEvent.xkey.keycode,
- xEvent.xkey.state,
- xEvent.xkey.x,
- xEvent.xkey.y));
- logType(4, strprintf("ButtonPress: %u,%u %d,%d",
- xEvent.xbutton.button,
- xEvent.xbutton.state,
- xEvent.xbutton.x,
- xEvent.xbutton.y));
- logType(5, strprintf("ButtonRelease: %u,%u %d,%d",
- xEvent.xbutton.button,
- xEvent.xbutton.state,
- xEvent.xbutton.x,
- xEvent.xbutton.y));
- logType(6, strprintf("MotionNotify: %d,%u %d,%d",
- CAST_S32(xEvent.xmotion.is_hint),
- xEvent.xmotion.state,
- xEvent.xmotion.x,
- xEvent.xmotion.y));
- logType(7, strprintf("EnterNotify: %d,%d,%d,%u, %d,%d",
- xEvent.xcrossing.mode,
- xEvent.xcrossing.detail,
- xEvent.xcrossing.focus ? 1 : 0,
- xEvent.xcrossing.state,
- xEvent.xcrossing.x,
- xEvent.xcrossing.y));
- logType(8, strprintf("LeaveNotify: %d,%d,%d,%u, %d,%d",
- xEvent.xcrossing.mode,
- xEvent.xcrossing.detail,
- xEvent.xcrossing.focus ? 1 : 0,
- xEvent.xcrossing.state,
- xEvent.xcrossing.x,
- xEvent.xcrossing.y));
- logType(9, strprintf("FocusIn: %d,%d",
- xEvent.xfocus.mode,
- xEvent.xfocus.detail));
- logType(10, strprintf("FocusOut: %d,%d",
- xEvent.xfocus.mode,
- xEvent.xfocus.detail));
- case 11:
- typeStr = "KeymapNotify: ";
- for (int f = 0; f < 32; f ++)
- {
- typeStr.append(strprintf("%u ",
- CAST_U32(xEvent.xkeymap.key_vector[f])));
- }
- break;
- logType(12, strprintf("Expose: %d,%d,%d,%d %d",
- xEvent.xexpose.x,
- xEvent.xexpose.y,
- xEvent.xexpose.width,
- xEvent.xexpose.height,
- xEvent.xexpose.count));
- logType(13, strprintf("GraphicsExpose: %d,%d,%d,%d %d,%d,%d",
- xEvent.xgraphicsexpose.x,
- xEvent.xgraphicsexpose.y,
- xEvent.xgraphicsexpose.width,
- xEvent.xgraphicsexpose.height,
- xEvent.xgraphicsexpose.count,
- xEvent.xgraphicsexpose.major_code,
- xEvent.xgraphicsexpose.minor_code));
- logType(14, strprintf("NoExpose: %d,%d",
- xEvent.xnoexpose.major_code,
- xEvent.xnoexpose.minor_code));
- logType(15, strprintf("VisibilityNotify: %d",
- xEvent.xvisibility.state));
- logType(16, strprintf("CreateNotify: %d,%d,%d,%d %d,%d",
- xEvent.xcreatewindow.x,
- xEvent.xcreatewindow.y,
- xEvent.xcreatewindow.width,
- xEvent.xcreatewindow.height,
- xEvent.xcreatewindow.border_width,
- xEvent.xcreatewindow.override_redirect ? 1 : 0));
- logType(17, "DestroyNotify");
- logType(18, strprintf("UnmapNotify: %d",
- xEvent.xunmap.from_configure ? 1: 0));
- logType(19, strprintf("MapNotify: %d",
- xEvent.xmap.override_redirect ? 1 : 0));
- logType(20, "MapRequest");
- logType(21, strprintf("ReparentNotify: %d,%d, %d",
- xEvent.xreparent.x,
- xEvent.xreparent.y,
- xEvent.xreparent.override_redirect ? 1 : 0));
- logType(22, strprintf("ConfigureNotify: %d,%d %d,%d %d,%d",
- xEvent.xconfigure.x,
- xEvent.xconfigure.y,
- xEvent.xconfigure.width,
- xEvent.xconfigure.height,
- xEvent.xconfigure.border_width,
- xEvent.xconfigure.override_redirect ? 1 : 0));
- logType(23, strprintf("ConfigureRequest: %d,%d %d,%d %d,%d",
- xEvent.xconfigurerequest.x,
- xEvent.xconfigurerequest.y,
- xEvent.xconfigurerequest.width,
- xEvent.xconfigurerequest.height,
- xEvent.xconfigurerequest.border_width,
- xEvent.xconfigurerequest.detail));
- logType(24, strprintf("GravityNotify: %d,%d",
- xEvent.xgravity.x,
- xEvent.xgravity.y));
- logType(25, strprintf("ResizeRequest: %d,%d",
- xEvent.xresizerequest.width,
- xEvent.xresizerequest.height));
- logType(26, strprintf("CirculateNotify: %d",
- xEvent.xcirculate.place));
- logType(27, strprintf("CirculateRequest: %d",
- xEvent.xcirculaterequest.place));
- logType(28, strprintf("PropertyNotify: %u, %d",
- CAST_U32(xEvent.xproperty.atom),
- xEvent.xproperty.state));
- logType(29, strprintf("SelectionClear: %u",
- CAST_U32(xEvent.xselectionclear.selection)));
- logType(30, strprintf("SelectionRequest: %u,%u,%u",
- CAST_U32(xEvent.xselectionrequest.selection),
- CAST_U32(xEvent.xselectionrequest.target),
- CAST_U32(xEvent.xselectionrequest.property)));
- logType(31, strprintf("SelectionNotify: %u,%u,%u",
- CAST_U32(xEvent.xselection.selection),
- CAST_U32(xEvent.xselection.target),
- CAST_U32(xEvent.xselection.property)));
- logType(32, strprintf("ColormapNotify: %u,%d",
- CAST_U32(xEvent.xcolormap.colormap),
-// xEvent.xcolormap.new ? 1 : 0,
- xEvent.xcolormap.state));
- case 33:
- typeStr = strprintf("ClientMessage: %u,%d (",
- CAST_U32(xEvent.xclient.message_type),
- xEvent.xclient.format);
- for (int f = 0; f < 20; f ++)
- typeStr.append(strprintf("%c", xEvent.xclient.data.b[f]));
- typeStr.append(")");
- break;
- logType(34, strprintf("MappingNotify: %d,%d,%d",
- xEvent.xmapping.request,
- xEvent.xmapping.first_keycode,
- xEvent.xmapping.count));
- logType(35, "GenericEvent");
- default:
- typeStr = strprintf("Unknown: %d", type);
- break;
- }
-
- logger->log("event: SDL_SYSWMEVENT: X11: %s",
- typeStr.c_str());
- return true;
-}
-
-#endif // USE_X11
diff --git a/src/utils/x11logger.h b/src/utils/x11logger.h
deleted file mode 100644
index 6ba01e579..000000000
--- a/src/utils/x11logger.h
+++ /dev/null
@@ -1,36 +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 UTILS_X11LOGGER_H
-#define UTILS_X11LOGGER_H
-
-#ifdef USE_X11
-
-#include "localconsts.h"
-
-union SDL_Event;
-
-namespace X11Logger
-{
- bool logEvent(const SDL_Event &event);
-} // namespace X11Logger
-
-#endif // USE_X11
-#endif // UTILS_X11LOGGER_H
diff --git a/src/utils/xml.h b/src/utils/xml.h
deleted file mode 100644
index ac93231fc..000000000
--- a/src/utils/xml.h
+++ /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/>.
- */
-
-#ifndef UTILS_XML_H
-#define UTILS_XML_H
-
-#ifdef ENABLE_PUGIXML
-#include "utils/xml/pugixml.h"
-#elif defined(ENABLE_TINYXML2)
-#include "utils/xml/tinyxml2.h"
-#else // ENABLE_PUGIXML
-#include "utils/xml/libxml.h"
-#endif // ENABLE_PUGIXML
-
-XML_INCLUDE_DEFINE
-
-#endif // UTILS_XML_H
diff --git a/src/utils/xml.inc b/src/utils/xml.inc
deleted file mode 100644
index 1b6aea25a..000000000
--- a/src/utils/xml.inc
+++ /dev/null
@@ -1,30 +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 UTILS_XML_INC
-#define UTILS_XML_INC
-
-#ifdef ENABLE_PUGIXML
-#include "utils/xml/pugixml.inc"
-#else // ENABLE_PUGIXML
-#include "utils/xml/libxml.inc"
-#endif // ENABLE_PUGIXML
-
-#endif // UTILS_XML_INC
diff --git a/src/utils/xml/libxml.cpp b/src/utils/xml/libxml.cpp
deleted file mode 100644
index 6dd87b3f2..000000000
--- a/src/utils/xml/libxml.cpp
+++ /dev/null
@@ -1,346 +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 ENABLE_LIBXML
-
-#include "utils/xml/libxml.h"
-
-#include "fs/virtfs/fs.h"
-
-#include "utils/cast.h"
-#include "utils/checkutils.h"
-#include "utils/fuzzer.h"
-#include "utils/stringutils.h"
-
-#include "utils/translation/podict.h"
-
-#include "debug.h"
-
-namespace
-{
- bool valid = false;
-} // namespace
-
-static void xmlErrorLogger(void *ctx A_UNUSED, const char *msg A_UNUSED, ...)
-#ifdef __GNUC__
-#ifdef __OpenBSD__
- __attribute__((__format__(printf, 2, 3)))
-#else // __OpenBSD__
- __attribute__((__format__(gnu_printf, 2, 3)))
-#endif // __OpenBSD__
-#endif // __GNUC__
-;
-
-static void xmlErrorLogger(void *ctx A_UNUSED, const char *msg, ...)
-{
- if (msg == nullptr)
- return;
-
- size_t size = 1024;
- const size_t msgSize = strlen(msg);
- if (msgSize * 3 > size)
- size = msgSize * 3;
-
- char* buf = new char[size + 1];
- va_list ap;
-
- // Use a temporary buffer to fill in the variables
- va_start(ap, msg);
- vsnprintf(buf, size, msg, ap);
- buf[size] = 0;
- va_end(ap);
-
- if (logger != nullptr)
- logger->log_r("%s", buf);
- else
- puts(buf);
-
- // Delete temporary buffer
- delete [] buf;
- valid = false;
-}
-
-namespace XML
-{
- Document::Document(const std::string &filename,
- const UseVirtFs useResman,
- const SkipError skipError) :
- Resource(),
- mDoc(nullptr),
- mIsValid(false)
- {
-#ifdef USE_FUZZER
- if (Fuzzer::conditionTerminate(filename.c_str()))
- return;
-#endif // USE_FUZZER
-
- BLOCK_START("XML::Document::Document")
- int size = 0;
- char *data = nullptr;
- valid = true;
- if (useResman == UseVirtFs_true)
- {
- data = const_cast<char*>(VirtFs::loadFile(
- filename,
- size));
- }
- else
- {
- std::ifstream file;
- file.open(filename.c_str(), std::ios::in);
-
- if (file.is_open())
- {
- // Get length of file
- file.seekg(0, std::ios::end);
- size = CAST_S32(file.tellg());
- if (size < 0)
- {
- reportAlways("Error loading XML file %s",
- filename.c_str());
- }
- else
- {
- file.seekg(0, std::ios::beg);
- data = new char[size];
- file.read(data, size);
- }
- file.close();
- }
- else if (skipError == SkipError_false)
- {
- reportAlways("Error loading XML file %s",
- filename.c_str());
- }
- }
-
- if (data != nullptr)
- {
- mDoc = xmlParseMemory(data, size);
- delete [] data;
-
- if (mDoc == nullptr)
- {
- reportAlways("Error parsing XML file %s", filename.c_str());
- }
- }
- else if (skipError == SkipError_false)
- {
- reportAlways("Error loading XML file %s", filename.c_str());
- }
- mIsValid = valid;
- BLOCK_END("XML::Document::Document")
- }
-
- Document::Document(const char *const data, const int size) :
- mDoc(data != nullptr ? xmlParseMemory(data, size) : nullptr),
- mIsValid(true)
- {
- }
-
- Document::~Document()
- {
- if (mDoc != nullptr)
- xmlFreeDoc(mDoc);
- }
-
- XmlNodePtr Document::rootNode()
- {
- return mDoc != nullptr ? xmlDocGetRootElement(mDoc) : nullptr;
- }
-
- int getProperty(XmlNodeConstPtr node,
- const char *const name,
- int def)
- {
- int &ret = def;
-
- xmlChar *const prop = XmlGetProp(node, name);
- if (prop != nullptr)
- {
- ret = atoi(reinterpret_cast<const char*>(prop));
- xmlFree(prop);
- }
-
- return ret;
- }
-
- int getIntProperty(XmlNodeConstPtr node,
- const char *const name,
- int def,
- const int min,
- const int max)
- {
- int &ret = def;
-
- xmlChar *const prop = XmlGetProp(node, name);
- if (prop != nullptr)
- {
- ret = atoi(reinterpret_cast<char*>(prop));
- xmlFree(prop);
- }
- if (ret < min)
- ret = min;
- else if (ret > max)
- ret = max;
- return ret;
- }
-
- float getFloatProperty(XmlNodeConstPtr node,
- const char *const name,
- float def)
- {
- float &ret = def;
-
- xmlChar *const prop = XmlGetProp(node, name);
- if (prop != nullptr)
- {
- ret = static_cast<float>(atof(reinterpret_cast<char*>(prop)));
- xmlFree(prop);
- }
-
- return ret;
- }
-
- double getDoubleProperty(XmlNodeConstPtr node,
- const char *const name,
- double def)
- {
- double &ret = def;
-
- xmlChar *const prop = XmlGetProp(node, name);
- if (prop != nullptr)
- {
- ret = atof(reinterpret_cast<char*>(prop));
- xmlFree(prop);
- }
-
- return ret;
- }
-
- std::string getProperty(XmlNodeConstPtr node,
- const char *const name,
- const std::string &def)
- {
- xmlChar *const prop = XmlGetProp(node, name);
- if (prop != nullptr)
- {
- std::string val = reinterpret_cast<char*>(prop);
- xmlFree(prop);
- return val;
- }
-
- return def;
- }
-
- std::string langProperty(XmlNodeConstPtr node,
- const char *const name,
- const std::string &def)
- {
- std::string str = getProperty(node, name, def);
- if (translator == nullptr)
- return str;
-
- return translator->getStr(str);
- }
-
- bool getBoolProperty(XmlNodeConstPtr node,
- const char *const name,
- const bool def)
- {
- xmlChar *const prop = XmlGetProp(node, name);
-
- if (XmlStrEqual(prop, "true"))
- {
- XmlFree(prop);
- return true;
- }
- if (XmlStrEqual(prop, "false"))
- {
- XmlFree(prop);
- return false;
- }
- XmlFree(prop);
- return def;
- }
-
- XmlNodePtr findFirstChildByName(XmlNodeConstPtrConst parent,
- const char *const name)
- {
- if (parent == nullptr)
- return nullptr;
- for_each_xml_child_node(child, parent)
- {
- if (xmlNameEqual(child, name))
- return child;
- }
-
- return nullptr;
- }
-
- // Initialize libxml2 and check for potential ABI mismatches between
- // compiled version and the shared library actually used.
- void initXML()
- {
- xmlInitParser();
- LIBXML_TEST_VERSION;
-
- // Suppress libxml2 error messages
- xmlSetGenericErrorFunc(nullptr, &xmlErrorLogger);
- }
-
- // Shutdown libxml
- void cleanupXML()
- {
- xmlCleanupParser();
- }
-
- bool Document::validateXml(const std::string &fileName)
- {
- const xmlDocPtr doc = xmlReadFile(fileName.c_str(),
- nullptr, XML_PARSE_PEDANTIC);
- const bool valid1(doc != nullptr);
- xmlFreeDoc(doc);
- if (!valid1)
- return false;
-
- std::ifstream file;
- file.open(fileName.c_str(), std::ios::in);
- if (!file.is_open())
- {
- file.close();
- return false;
- }
- char line[101];
- if (!file.getline(line, 100))
- return false;
- file.close();
-
- const std::string str = line;
- if (!strStartWith(str, "<?xml "))
- return false;
-
- return true;
- }
-} // namespace XML
-
-#endif // ENABLE_LIBXML
diff --git a/src/utils/xml/libxml.h b/src/utils/xml/libxml.h
deleted file mode 100644
index 6ec0ce08d..000000000
--- a/src/utils/xml/libxml.h
+++ /dev/null
@@ -1,164 +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 UTILS_XML_LIBXML_H
-#define UTILS_XML_LIBXML_H
-
-#ifdef ENABLE_LIBXML
-
-#define XML_INCLUDE_DEFINE
-
-#include "enums/simpletypes/skiperror.h"
-#include "enums/simpletypes/usevirtfs.h"
-
-#include "utils/xml/libxml.inc"
-
-#include "resources/resource.h"
-
-#ifndef _GLIBCXX_STRING
-#include <string>
-#endif // _GLIBCXX_STRING
-
-#include "localconsts.h"
-
-/**
- * XML helper functions.
- */
-namespace XML
-{
- /**
- * A helper class for parsing an XML document, which also cleans it up
- * again (RAII).
- */
- class Document final : public Resource
- {
- public:
- /**
- * Constructor that attempts to load the given file through the
- * resource manager. Logs errors.
- */
- Document(const std::string &filename,
- const UseVirtFs useResman,
- const SkipError skipError);
-
- /**
- * Constructor that attempts to load an XML document from memory.
- * Does not log errors.
- *
- * @param data the string to parse as XML
- * @param size the length of the string in bytes
- */
- Document(const char *const data, const int size);
-
- A_DELETE_COPY(Document)
-
- /**
- * Destructor. Frees the loaded XML file.
- */
- ~Document();
-
- /**
- * Returns the root node of the document (or NULL if there was a
- * load error).
- */
- XmlNodePtr rootNode() A_WARN_UNUSED;
-
- bool isLoaded() const
- { return mDoc != nullptr; }
-
- bool isValid() const
- { return mIsValid; }
-
- static bool validateXml(const std::string &fileName);
-
- private:
- xmlDocPtr mDoc;
- bool mIsValid;
- };
-
- /**
- * Gets an floating point property from an XmlNodePtr.
- */
- float getFloatProperty(XmlNodeConstPtr node,
- const char *const name,
- float def) A_WARN_UNUSED;
-
- /**
- * Gets an double point property from an XmlNodePtr.
- */
- double getDoubleProperty(XmlNodeConstPtr node,
- const char *const name,
- double def) A_WARN_UNUSED;
-
- /**
- * Gets an integer property from an XmlNodePtr.
- */
- int getProperty(XmlNodeConstPtr node,
- const char *const name,
- int def) A_WARN_UNUSED;
-
- /**
- * Gets an integer property from an XmlNodePtr.
- */
- int getIntProperty(XmlNodeConstPtr node,
- const char *const name,
- int def,
- const int min,
- const int max) A_WARN_UNUSED;
-
- /**
- * Gets a string property from an XmlNodePtr.
- */
- std::string getProperty(XmlNodeConstPtr node,
- const char *const name,
- const std::string &def) A_WARN_UNUSED;
-
- /**
- * Gets a translated string property from an XmlNodePtr.
- */
- std::string langProperty(XmlNodeConstPtr node,
- const char *const name,
- const std::string &def) A_WARN_UNUSED;
-
- /**
- * Gets a boolean property from an XmlNodePtr.
- */
- bool getBoolProperty(XmlNodeConstPtr node,
- const char *const name,
- const bool def) A_WARN_UNUSED;
-
- /**
- * Finds the first child node with the given name
- */
- XmlNodePtr findFirstChildByName(XmlNodeConstPtrConst parent,
- const char *const name) A_WARN_UNUSED;
-
- void initXML();
-
- void cleanupXML();
-} // namespace XML
-
-#define for_each_xml_child_node(var, parent) \
- for (XmlNodePtr var = parent->xmlChildrenNode; var; var = var->next)
-
-#endif // ENABLE_LIBXML
-#endif // UTILS_XML_LIBXML_H
diff --git a/src/utils/xml/libxml.inc b/src/utils/xml/libxml.inc
deleted file mode 100644
index ec837f224..000000000
--- a/src/utils/xml/libxml.inc
+++ /dev/null
@@ -1,73 +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 UTILS_XML_LIBXML_INC
-#define UTILS_XML_LIBXML_INC
-
-#ifdef ENABLE_LIBXML
-
-#include <libxml/xmlwriter.h>
-
-__XML_XMLWRITER_H__
-
-#define XmlNodePtr xmlNodePtr
-#define XmlNodePtrConst xmlNode *const
-#define XmlNodeConstPtr const xmlNodePtr
-#define XmlNodeConstPtrConst const xmlNode *const
-#define XmlStrEqual(str1, str2) xmlStrEqual(str1, \
- reinterpret_cast<const xmlChar*>(str2))
-#define xmlNameEqual(node, str) xmlStrEqual((node)->name, \
- reinterpret_cast<const xmlChar*>(str))
-#define XmlTextWriterPtr const xmlTextWriterPtr
-#define xmlTypeEqual(node, typ) ((node)->type == (typ))
-#define XmlHasProp(node, name) (xmlHasProp(node, \
- reinterpret_cast<const xmlChar*>(name)) != nullptr)
-#define XmlGetProp(node, name) xmlGetProp(node, \
- reinterpret_cast<const xmlChar*>(name))
-#define XmlTextWriterStartRootElement(writer, name) \
- xmlTextWriterStartElement(writer, reinterpret_cast<const xmlChar*>(name))
-#define XmlTextWriterStartElement(writer, name) \
- xmlTextWriterStartElement(writer, reinterpret_cast<const xmlChar*>(name))
-#define XmlTextWriterEndElement(writer) xmlTextWriterEndElement(writer)
-#define XmlTextWriterWriteAttribute(writer, name, content) \
- xmlTextWriterWriteAttribute(writer, \
- reinterpret_cast<const xmlChar*>(name), \
- reinterpret_cast<const xmlChar*>(content))
-#define XmlNodeGetContent(node) xmlNodeGetContent(node)
-#define XmlNewTextWriterFilename(name, flags) \
- xmlNewTextWriterFilename(name, flags)
-#define XmlSaveTextWriterFilename(writer, name)
-#define XmlTextWriterSetIndent(writer, flags) \
- xmlTextWriterSetIndent(writer, flags)
-#define XmlTextWriterStartDocument(writer, p1, p2, p3) \
- xmlTextWriterStartDocument(writer, p1, p2, p3)
-#define XmlTextWriterEndDocument(writer) xmlTextWriterEndDocument(writer)
-#define XmlFreeTextWriter(writer) xmlFreeTextWriter(writer)
-#define XmlHaveChildContent(node) ((node)->xmlChildrenNode != nullptr && \
- (node)->xmlChildrenNode->content != nullptr)
-#define XmlChildContent(node) reinterpret_cast<const char*>(\
- (node)->xmlChildrenNode->content)
-#define XmlFree(ptr) xmlFree(ptr)
-#define XmlNodeDefault nullptr
-#define XmlChar char
-#define XmlConstChar const char
-
-#endif // ENABLE_LIBXML
-#endif // UTILS_XML_LIBXML_INC
diff --git a/src/utils/xml/pugixml.cpp b/src/utils/xml/pugixml.cpp
deleted file mode 100644
index 12d885a4f..000000000
--- a/src/utils/xml/pugixml.cpp
+++ /dev/null
@@ -1,352 +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 ENABLE_PUGIXML
-
-#include "utils/xml/pugixml.h"
-
-#include "fs/virtfs/fs.h"
-
-#include "utils/cast.h"
-#include "utils/checkutils.h"
-#include "utils/delete2.h"
-#include "utils/fuzzer.h"
-#include "utils/stringutils.h"
-
-#include "utils/translation/podict.h"
-
-#include "debug.h"
-
-namespace
-{
- bool valid = false;
-} // namespace
-
-namespace XML
-{
- static void showErrorStatus(pugi::xml_parse_result &result)
- {
-/*
- switch (result.status)
- {
- case pugi::status_ok:
- break;
- case pugi::status_file_not_found:
- logger->log("xml error: %s", result.description());
- break;
- }
-*/
- logger->log("xml error: %s", result.description());
- }
-
- Document::Document(const std::string &filename,
- const UseVirtFs useResman,
- const SkipError skipError) :
- Resource(),
- mDoc(),
- mData(nullptr),
- mIsValid(false)
- {
-#ifdef USE_FUZZER
- if (Fuzzer::conditionTerminate(filename.c_str()))
- return;
-#endif // USE_FUZZER
-
- BLOCK_START("XML::Document::Document")
- int size = 0;
- char *data = nullptr;
- valid = true;
- if (useResman == UseVirtFs_true)
- {
- data = const_cast<char*>(VirtFs::loadFile(
- filename.c_str(),
- size));
- }
- else
- {
- std::ifstream file;
- file.open(filename.c_str(), std::ios::in);
-
- if (file.is_open())
- {
- // Get length of file
- file.seekg(0, std::ios::end);
- size = CAST_S32(file.tellg());
- if (size < 0)
- {
- reportAlways("Error loading XML file %s",
- filename.c_str());
- }
- else
- {
- file.seekg(0, std::ios::beg);
- data = new char[size];
- file.read(data, size);
- }
- file.close();
- }
- else if (skipError == SkipError_false)
- {
- reportAlways("Error loading XML file %s",
- filename.c_str());
- }
- }
-
- if (data)
- {
- // +++ use other pugi::parse_* flags
- pugi::xml_parse_result result = mDoc.load_buffer_inplace(data,
- size,
- pugi::parse_default,
- pugi::encoding_utf8);
- if (result.status != pugi::status_ok)
- {
- showErrorStatus(result);
- delete [] data;
- }
- else
- {
- mData = data;
- }
-
-// if (!mDoc)
-// logger->log("Error parsing XML file %s", filename.c_str());
- }
- else if (skipError == SkipError_false)
- {
- reportAlways("Error loading %s", filename.c_str());
- }
- mIsValid = valid;
- BLOCK_END("XML::Document::Document")
- }
-
- Document::Document(const char *const data, const int size) :
- mDoc(),
- mData(nullptr),
- mIsValid(true)
- {
- if (!data)
- return;
-
- char *buf = new char[size + 1];
- strncpy(buf, data, size);
- buf[size] = 0;
- pugi::xml_parse_result result = mDoc.load_buffer_inplace(buf,
- size,
- pugi::parse_default,
- pugi::encoding_utf8);
- if (result.status != pugi::status_ok)
- {
- showErrorStatus(result);
- delete [] buf;
- }
- else
- {
- mData = buf;
- }
- }
-
- Document::~Document()
- {
- delete [] mData;
- mData = nullptr;
- }
-
- XmlNodePtr Document::rootNode()
- {
- return mDoc.first_child();
- }
-
- int getProperty(XmlNodeConstPtr node,
- const char *const name,
- int def)
- {
- int &ret = def;
-
- if (!node)
- return ret;
- const pugi::xml_attribute &attr = node.attribute(name);
- if (!attr.empty())
- ret = atoi(attr.value());
-
- return ret;
- }
-
- int getIntProperty(XmlNodeConstPtr node,
- const char *const name,
- int def,
- const int min,
- const int max)
- {
- int &ret = def;
-
- if (!node)
- return ret;
- const pugi::xml_attribute &attr = node.attribute(name);
- if (!attr.empty())
- ret = atoi(attr.value());
-
- if (ret < min)
- ret = min;
- else if (ret > max)
- ret = max;
- return ret;
- }
-
- float getFloatProperty(XmlNodeConstPtr node,
- const char *const name,
- float def)
- {
- float &ret = def;
-
- if (!node)
- return ret;
- const pugi::xml_attribute &attr = node.attribute(name);
- if (!attr.empty())
- ret = atof(attr.value());
-
- return ret;
- }
-
- double getDoubleProperty(XmlNodeConstPtr node,
- const char *const name,
- double def)
- {
- double &ret = def;
-
- if (!node)
- return ret;
- const pugi::xml_attribute &attr = node.attribute(name);
- if (!attr.empty())
- ret = atof(attr.value());
-
- return ret;
- }
-
- std::string getProperty(XmlNodeConstPtr node,
- const char *const name,
- const std::string &def)
- {
- if (!node)
- return def;
- const pugi::xml_attribute &attr = node.attribute(name);
- if (!attr.empty())
- return attr.value();
-
- return def;
- }
-
- std::string langProperty(XmlNodeConstPtr node,
- const char *const name,
- const std::string &def)
- {
- std::string str = getProperty(node, name, def);
- if (!translator)
- return str;
-
- return translator->getStr(str);
- }
-
- bool getBoolProperty(XmlNodeConstPtr node,
- const char *const name,
- const bool def)
- {
- if (!node)
- return def;
- const pugi::xml_attribute &attr = node.attribute(name);
- if (!attr.empty())
- {
- std::string val = attr.value();
- if (val == "true")
- return true;
- if (val == "false")
- return false;
- }
-
- return def;
- }
-
- XmlNodePtr findFirstChildByName(XmlNodeConstPtrConst parent,
- const char *const name)
- {
- if (!parent || !name)
- return pugi::xml_node();
- for_each_xml_child_node(child, parent)
- {
- if (!strcmp(child.name(), name))
- return child;
- }
-
- return pugi::xml_node();
- }
-
- // Initialize libxml2 and check for potential ABI mismatches between
- // compiled version and the shared library actually used.
- void initXML()
- {
-// xmlInitParser();
-// LIBXML_TEST_VERSION;
-
- // Suppress libxml2 error messages
-// xmlSetGenericErrorFunc(nullptr, &xmlErrorLogger);
- }
-
- // Shutdown libxml
- void cleanupXML()
- {
-// xmlCleanupParser();
- }
-
- bool Document::validateXml(const std::string &fileName)
- {
- pugi::xml_document doc;
- pugi::xml_parse_result result = doc.load_file(fileName.c_str(),
- pugi::parse_default,
- pugi::encoding_utf8);
-
- if (result.status != pugi::status_ok)
- {
- showErrorStatus(result);
- return false;
- }
-
- std::ifstream file;
- file.open(fileName.c_str(), std::ios::in);
- if (!file.is_open())
- {
- file.close();
- return false;
- }
- char line[101];
- if (!file.getline(line, 100))
- return false;
- file.close();
-
- const std::string str = line;
- if (!strStartWith(str, "<?xml "))
- return false;
-
- return true;
- }
-} // namespace XML
-
-#endif // ENABLE_PUGIXML
diff --git a/src/utils/xml/pugixml.h b/src/utils/xml/pugixml.h
deleted file mode 100644
index e4337140e..000000000
--- a/src/utils/xml/pugixml.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 UTILS_XML_PUGIXML_H
-#define UTILS_XML_PUGIXML_H
-
-#ifdef ENABLE_PUGIXML
-
-#define XML_INCLUDE_DEFINE
-
-#include "enums/simpletypes/skiperror.h"
-#include "enums/simpletypes/usevirtfs.h"
-
-#include "utils/xml/pugixml.inc"
-
-#include "resources/resource.h"
-
-#include <pugixml.hpp>
-
-#include <string>
-
-#include "localconsts.h"
-
-/**
- * XML helper functions.
- */
-namespace XML
-{
- /**
- * A helper class for parsing an XML document, which also cleans it up
- * again (RAII).
- */
- class Document final : public Resource
- {
- public:
- /**
- * Constructor that attempts to load the given file through the
- * resource manager. Logs errors.
- */
- Document(const std::string &filename,
- const UseVirtFs useResman,
- const SkipError skipError);
-
- /**
- * Constructor that attempts to load an XML document from memory.
- * Does not log errors.
- *
- * @param data the string to parse as XML
- * @param size the length of the string in bytes
- */
- Document(const char *const data, const int size);
-
- A_DELETE_COPY(Document)
-
- /**
- * Destructor. Frees the loaded XML file.
- */
- ~Document();
-
- /**
- * Returns the root node of the document (or NULL if there was a
- * load error).
- */
- XmlNodePtr rootNode() A_WARN_UNUSED;
-
- bool isLoaded() const
- { return !mDoc.empty(); }
-
- bool isValid() const
- { return mIsValid; }
-
- static bool validateXml(const std::string &fileName);
-
- private:
- pugi::xml_document mDoc;
- char *mData;
- bool mIsValid;
- };
-
- /**
- * Gets an floating point property from an XmlNodePtr.
- */
- float getFloatProperty(XmlNodeConstPtr node,
- const char *const name,
- float def) A_WARN_UNUSED;
-
- /**
- * Gets an double point property from an XmlNodePtr.
- */
- double getDoubleProperty(XmlNodeConstPtr node,
- const char *const name,
- double def) A_WARN_UNUSED;
-
- /**
- * Gets an integer property from an XmlNodePtr.
- */
- int getProperty(XmlNodeConstPtr node,
- const char *const name,
- int def) A_WARN_UNUSED;
-
- /**
- * Gets an integer property from an XmlNodePtr.
- */
- int getIntProperty(XmlNodeConstPtr node,
- const char *const name,
- int def,
- const int min,
- const int max) A_WARN_UNUSED;
-
- /**
- * Gets a string property from an XmlNodePtr.
- */
- std::string getProperty(XmlNodeConstPtr node,
- const char *const name,
- const std::string &def) A_WARN_UNUSED;
-
- /**
- * Gets a translated string property from an XmlNodePtr.
- */
- std::string langProperty(XmlNodeConstPtr node,
- const char *const name,
- const std::string &def) A_WARN_UNUSED;
-
- /**
- * Gets a boolean property from an XmlNodePtr.
- */
- bool getBoolProperty(XmlNodeConstPtr node,
- const char *const name,
- const bool def) A_WARN_UNUSED;
-
- /**
- * Finds the first child node with the given name
- */
- XmlNodePtr findFirstChildByName(XmlNodeConstPtrConst parent,
- const char *const name) A_WARN_UNUSED;
-
- void initXML();
-
- void cleanupXML();
-} // namespace XML
-
-#define for_each_xml_child_node(var, parent) \
- for (pugi::xml_node var = parent.first_child(); \
- var; var = var.next_sibling())
-
-#endif // ENABLE_PUGIXML
-#endif // UTILS_XML_PUGIXML_H
diff --git a/src/utils/xml/pugixml.inc b/src/utils/xml/pugixml.inc
deleted file mode 100644
index c8685f877..000000000
--- a/src/utils/xml/pugixml.inc
+++ /dev/null
@@ -1,58 +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 UTILS_XML_PUGIXML_INC
-#define UTILS_XML_PUGIXML_INC
-
-#ifdef ENABLE_PUGIXML
-
-#define XML_ELEMENT_NODE pugi::node_element
-
-#define XmlNodePtr pugi::xml_node
-#define XmlNodePtrConst pugi::xml_node
-#define XmlNodeConstPtr const pugi::xml_node
-#define XmlNodeConstPtrConst const pugi::xml_node
-#define xmlNameEqual(node, str) !strcmp((node).name(), str)
-#define xmlTypeEqual(node, typ) ((node).type() == (typ))
-#define XmlHasProp(node, name) (!((node).attribute(name).empty()))
-#define XmlHaveChildContent(node) ((node).child_value() != nullptr && \
- *(node).child_value())
-#define XmlChildContent(node) (node).child_value()
-#define xmlChar char
-#define XmlFree(ptr)
-#define XmlNodeDefault pugi::xml_node()
-#define XmlNodeGetContent(node) (node).child_value()
-#define XmlTextWriterPtr const XML::Writer *
-#define XmlTextWriterStartRootElement(writer, name) (writer)->startNode(name)
-#define XmlTextWriterStartElement(writer, name) (writer)->startNode(name)
-#define XmlTextWriterEndElement(writer) (writer)->endNode()
-#define XmlTextWriterWriteAttribute(writer, name, content) \
- (writer)->addAttribute(name, content)
-#define XmlNewTextWriterFilename(name, flags) new XML::Writer(name);
-#define XmlSaveTextWriterFilename(writer, name)
-#define XmlTextWriterSetIndent(writer, flags)
-#define XmlTextWriterStartDocument(writer, p1, p2, p3)
-#define XmlTextWriterEndDocument(writer) (writer)->endDocument()
-#define XmlFreeTextWriter(writer) delete writer
-#define XmlChar const char
-#define XmlConstChar const char
-
-#endif // ENABLE_PUGIXML
-#endif // UTILS_XML_PUGIXML_INC
diff --git a/src/utils/xml/pugixmlwriter.cpp b/src/utils/xml/pugixmlwriter.cpp
deleted file mode 100644
index b8c6aafec..000000000
--- a/src/utils/xml/pugixmlwriter.cpp
+++ /dev/null
@@ -1,74 +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 ENABLE_PUGIXML
-
-#include "utils/xml/pugixmlwriter.h"
-
-#include "logger.h"
-
-#include "fs/virtfs/fs.h"
-
-#include "utils/delete2.h"
-#include "utils/fuzzer.h"
-#include "utils/stringutils.h"
-
-#include "utils/translation/podict.h"
-
-#include "debug.h"
-
-namespace XML
-{
- Writer::Writer(const std::string &filename) :
- mDoc(),
- mNode(),
- mName(filename)
- {
- mNode = mDoc;
- }
-
- Writer::~Writer()
- {
- }
-
- void Writer::startNode(const std::string &name) const
- {
- mNode = mNode.append_child(name.c_str());
- }
-
- void Writer::endNode() const
- {
- mNode = mNode.parent();
- }
-
- void Writer::endDocument() const
- {
- mDoc.save_file(mName.c_str());
- }
-
- void Writer::addAttribute(const std::string &name,
- const std::string &value) const
- {
- mNode.append_attribute(name.c_str()) = value.c_str();
- }
-
-} // namespace XML
-
-#endif // ENABLE_PUGIXML
diff --git a/src/utils/xml/pugixmlwriter.h b/src/utils/xml/pugixmlwriter.h
deleted file mode 100644
index fe5977655..000000000
--- a/src/utils/xml/pugixmlwriter.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 UTILS_XML_PUGIXMLWRITER_H
-#define UTILS_XML_PUGIXMLWRITER_H
-
-#ifdef ENABLE_PUGIXML
-
-#include "enums/simpletypes/skiperror.h"
-#include "enums/simpletypes/usevirtfs.h"
-
-#include "utils/xml/pugixml.h"
-
-#include <pugixml.hpp>
-
-#include <string>
-
-#include "localconsts.h"
-
-namespace XML
-{
- class Writer final
- {
- public:
- explicit Writer(const std::string &filename);
-
- A_DELETE_COPY(Writer)
-
- ~Writer();
-
- void startNode(const std::string &name) const;
-
- void endNode() const;
-
- void endDocument() const;
-
- void addAttribute(const std::string &name,
- const std::string &value) const;
-
- private:
- mutable pugi::xml_document mDoc;
- mutable pugi::xml_node mNode;
- std::string mName;
- };
-} // namespace XML
-
-#endif // ENABLE_PUGIXML
-#endif // UTILS_XML_PUGIXMLWRITER_H
diff --git a/src/utils/xml/tinyxml2.cpp b/src/utils/xml/tinyxml2.cpp
deleted file mode 100644
index a7275b7f1..000000000
--- a/src/utils/xml/tinyxml2.cpp
+++ /dev/null
@@ -1,323 +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 ENABLE_TINYXML2
-
-#include "utils/xml/tinyxml2.h"
-
-#include "fs/virtfs/fs.h"
-
-#include "utils/cast.h"
-#include "utils/checkutils.h"
-#include "utils/fuzzer.h"
-#include "utils/stringutils.h"
-
-#include "utils/translation/podict.h"
-
-#include "debug.h"
-
-namespace
-{
- bool valid = false;
-} // namespace
-
-namespace XML
-{
- static void showErrorStatus(tinyxml2::XMLDocument &doc)
- {
- logger->log("xml error: %s, in lines: %s\n%s",
- doc.ErrorName(),
- doc.GetErrorStr1(),
- doc.GetErrorStr2());
- }
-
- Document::Document(const std::string &filename,
- const UseVirtFs useResman,
- const SkipError skipError) :
- Resource(),
- mDoc(),
- mData(nullptr),
- mIsValid(false)
- {
-#ifdef USE_FUZZER
- if (Fuzzer::conditionTerminate(filename.c_str()))
- return;
-#endif // USE_FUZZER
-
- BLOCK_START("XML::Document::Document")
- int size = 0;
- char *data = nullptr;
- valid = true;
- if (useResman == UseVirtFs_true)
- {
- data = const_cast<char*>(VirtFs::loadFile(
- filename.c_str(),
- size));
- }
- else
- {
- std::ifstream file;
- file.open(filename.c_str(), std::ios::in);
-
- if (file.is_open())
- {
- // Get length of file
- file.seekg(0, std::ios::end);
- size = CAST_S32(file.tellg());
- if (size < 0)
- {
- reportAlways("Error loading XML file %s",
- filename.c_str());
- }
- else
- {
- file.seekg(0, std::ios::beg);
- data = new char[size];
- file.read(data, size);
- }
- file.close();
- }
- else if (skipError == SkipError_false)
- {
- reportAlways("Error loading XML file %s",
- filename.c_str());
- }
- }
-
- if (data)
- {
- tinyxml2::XMLError result = mDoc.Parse(data,
- size);
- if (result != tinyxml2::XML_SUCCESS)
- {
- showErrorStatus(mDoc);
- delete [] data;
- }
- else
- {
- mData = data;
- }
- }
- else if (skipError == SkipError_false)
- {
- reportAlways("Error loading %s", filename.c_str());
- }
- mIsValid = valid;
- BLOCK_END("XML::Document::Document")
- }
-
- Document::Document(const char *const data, const int size) :
- Resource(),
- mDoc(),
- mData(nullptr),
- mIsValid(true)
- {
- if (!data)
- return;
-
- char *buf = new char[size + 1];
- strncpy(buf, data, size);
- buf[size] = 0;
-
- tinyxml2::XMLError result = mDoc.Parse(buf,
- size);
- if (result != tinyxml2::XML_SUCCESS)
- {
- showErrorStatus(mDoc);
- delete [] buf;
- }
- else
- {
- mData = buf;
- }
- }
-
- Document::~Document()
- {
- delete [] mData;
- mData = nullptr;
- }
-
- XmlNodeConstPtr Document::rootNode()
- {
- return mDoc.FirstChildElement();
- }
-
- int getProperty(XmlNodeConstPtr node,
- const char *const name,
- int def)
- {
- int &ret = def;
-
- if (!node)
- return ret;
- const char *attr = node->Attribute(name);
- if (attr != nullptr)
- ret = atoi(attr);
-
- return ret;
- }
-
- int getIntProperty(XmlNodeConstPtr node,
- const char *const name,
- int def,
- const int min,
- const int max)
- {
- int &ret = def;
-
- if (!node)
- return ret;
- const char *attr = node->Attribute(name);
- if (attr != nullptr)
- ret = atoi(attr);
-
- if (ret < min)
- ret = min;
- else if (ret > max)
- ret = max;
- return ret;
- }
-
- float getFloatProperty(XmlNodeConstPtr node,
- const char *const name,
- float def)
- {
- float &ret = def;
-
- if (!node)
- return ret;
- const char *attr = node->Attribute(name);
- if (attr != nullptr)
- ret = atof(attr);
-
- return ret;
- }
-
- double getDoubleProperty(XmlNodeConstPtr node,
- const char *const name,
- double def)
- {
- double &ret = def;
-
- if (!node)
- return ret;
- const char *attr = node->Attribute(name);
- if (attr != nullptr)
- ret = atof(attr);
-
- return ret;
- }
-
- std::string getProperty(XmlNodeConstPtr node,
- const char *const name,
- const std::string &def)
- {
- if (!node)
- return def;
- const char *attr = node->Attribute(name);
- if (attr != nullptr)
- return attr;
-
- return def;
- }
-
- std::string langProperty(XmlNodeConstPtr node,
- const char *const name,
- const std::string &def)
- {
- std::string str = getProperty(node, name, def);
- if (!translator)
- return str;
-
- return translator->getStr(str);
- }
-
- bool getBoolProperty(XmlNodeConstPtr node,
- const char *const name,
- const bool def)
- {
- if (!node)
- return def;
- const char *attr = node->Attribute(name);
- if (attr != nullptr)
- {
- std::string val = attr;
- if (val == "true")
- return true;
- if (val == "false")
- return false;
- }
-
- return def;
- }
-
- XmlNodeConstPtr findFirstChildByName(XmlNodeConstPtrConst parent,
- const char *const name)
- {
- if (!parent || !name)
- return nullptr;
- return parent->FirstChildElement(name);
- }
-
- // Initialize xml
- void initXML()
- {
- }
-
- // Shutdown xml
- void cleanupXML()
- {
- }
-
- bool Document::validateXml(const std::string &fileName)
- {
- tinyxml2::XMLDocument doc;
- tinyxml2::XMLError result = doc.LoadFile(fileName.c_str());
-
- if (result != tinyxml2::XML_SUCCESS)
- {
- showErrorStatus(doc);
- return false;
- }
-
- std::ifstream file;
- file.open(fileName.c_str(), std::ios::in);
- if (!file.is_open())
- {
- file.close();
- return false;
- }
- char line[101];
- if (!file.getline(line, 100))
- return false;
- file.close();
-
- const std::string str = line;
- if (!strStartWith(str, "<?xml "))
- return false;
-
- return true;
- }
-} // namespace XML
-
-#endif // ENABLE_TINYXML2
diff --git a/src/utils/xml/tinyxml2.h b/src/utils/xml/tinyxml2.h
deleted file mode 100644
index f056dc43a..000000000
--- a/src/utils/xml/tinyxml2.h
+++ /dev/null
@@ -1,168 +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 UTILS_XML_TINYXML2_H
-#define UTILS_XML_TINYXML2_H
-
-#ifdef ENABLE_TINYXML2
-
-#define XML_INCLUDE_DEFINE
-
-#include "enums/simpletypes/skiperror.h"
-#include "enums/simpletypes/usevirtfs.h"
-
-#include "utils/xml/tinyxml2.inc"
-
-#include "resources/resource.h"
-
-#ifndef _GLIBCXX_STRING
-#include <string>
-#endif // _GLIBCXX_STRING
-
-#include "localconsts.h"
-
-/**
- * XML helper functions.
- */
-namespace XML
-{
- /**
- * A helper class for parsing an XML document, which also cleans it up
- * again (RAII).
- */
- class Document final : public Resource
- {
- public:
- /**
- * Constructor that attempts to load the given file through the
- * resource manager. Logs errors.
- */
- Document(const std::string &filename,
- const UseVirtFs useResman,
- const SkipError skipError);
-
- /**
- * Constructor that attempts to load an XML document from memory.
- * Does not log errors.
- *
- * @param data the string to parse as XML
- * @param size the length of the string in bytes
- */
- Document(const char *const data, const int size);
-
- A_DELETE_COPY(Document)
-
- /**
- * Destructor. Frees the loaded XML file.
- */
- ~Document();
-
- /**
- * Returns the root node of the document (or NULL if there was a
- * load error).
- */
- XmlNodePtr rootNode() A_WARN_UNUSED;
-
- bool isLoaded() const
- { return mDoc.Error() == false; }
-
- bool isValid() const
- { return mIsValid; }
-
- static bool validateXml(const std::string &fileName);
-
- private:
- tinyxml2::XMLDocument mDoc;
- char *mData;
- bool mIsValid;
- };
-
- /**
- * Gets an floating point property from an XmlNodePtr.
- */
- float getFloatProperty(XmlNodeConstPtr node,
- const char *const name,
- float def) A_WARN_UNUSED;
-
- /**
- * Gets an double point property from an XmlNodePtr.
- */
- double getDoubleProperty(XmlNodeConstPtr node,
- const char *const name,
- double def) A_WARN_UNUSED;
-
- /**
- * Gets an integer property from an XmlNodePtr.
- */
- int getProperty(XmlNodeConstPtr node,
- const char *const name,
- int def) A_WARN_UNUSED;
-
- /**
- * Gets an integer property from an XmlNodePtr.
- */
- int getIntProperty(XmlNodeConstPtr node,
- const char *const name,
- int def,
- const int min,
- const int max) A_WARN_UNUSED;
-
- /**
- * Gets a string property from an XmlNodePtr.
- */
- std::string getProperty(XmlNodeConstPtr node,
- const char *const name,
- const std::string &def) A_WARN_UNUSED;
-
- /**
- * Gets a translated string property from an XmlNodePtr.
- */
- std::string langProperty(XmlNodeConstPtr node,
- const char *const name,
- const std::string &def) A_WARN_UNUSED;
-
- /**
- * Gets a boolean property from an XmlNodePtr.
- */
- bool getBoolProperty(XmlNodeConstPtr node,
- const char *const name,
- const bool def) A_WARN_UNUSED;
-
- /**
- * Finds the first child node with the given name
- */
- XmlNodeConstPtr findFirstChildByName(XmlNodeConstPtrConst parent,
- const char *const name)
- A_WARN_UNUSED;
-
- void initXML();
-
- void cleanupXML();
-} // namespace XML
-
-#define for_each_xml_child_node(var, parent) \
- for (const tinyxml2::XMLElement *var = parent->FirstChildElement(); \
- var != nullptr; \
- var = var->NextSiblingElement())
-
-#endif // ENABLE_TINYXML2
-#endif // UTILS_XML_TINYXML2_H
diff --git a/src/utils/xml/tinyxml2.inc b/src/utils/xml/tinyxml2.inc
deleted file mode 100644
index 408638184..000000000
--- a/src/utils/xml/tinyxml2.inc
+++ /dev/null
@@ -1,77 +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 UTILS_XML_TINYXML2_INC
-#define UTILS_XML_TINYXML2_INC
-
-#ifdef ENABLE_TINYXML2
-
-PRAGMA49(GCC diagnostic push)
-PRAGMA49(GCC diagnostic ignored "-Wzero-as-null-pointer-constant")
-PRAGMA49(GCC diagnostic ignored "-Wsuggest-override")
-PRAGMACLANG6GCC(GCC diagnostic push)
-PRAGMACLANG6GCC(GCC diagnostic ignored "-Wold-style-cast")
-#include <tinyxml2.h>
-PRAGMACLANG6GCC(GCC diagnostic pop)
-PRAGMA49(GCC diagnostic pop)
-
-TINYXML2_INCLUDED
-
-#define XML_ELEMENT_NODE tinyxml2::XMLElement
-
-#define XmlNodePtr const tinyxml2::XMLElement*
-#define XmlNodePtrConst const tinyxml2::XMLElement *const
-#define XmlNodeConstPtr const tinyxml2::XMLElement*
-#define XmlNodeConstPtrConst const tinyxml2::XMLElement *const
-#define xmlNameEqual(node, str) !strcmp((node)->Value(), str)
-#define XmlTextWriterPtr tinyxml2::XMLPrinter*
-// +++ need replace xmlTypeEqual to isXmlElementNode
-#define xmlTypeEqual(node, typ) true
-#define XmlHasProp(node, name) ((node)->Attribute(name) != nullptr)
-
-#define XmlNodeGetContent(node) (node)->GetText()
-#define XmlHaveChildContent(node) ((node)->GetText() != nullptr)
-#define XmlChildContent(node) ((node)->GetText())
-
-#define XmlFree(ptr)
-#define XmlNodeDefault nullptr
-#define XmlChar const char
-#define XmlConstChar const char
-
-#define XmlTextWriterStartElement(writer, name) (writer)->OpenElement(name)
-#define XmlTextWriterStartRootElement(writer, name) (writer)->OpenElement(name)
-#define XmlTextWriterEndElement(writer) (writer)->CloseElement()
-#define XmlTextWriterWriteAttribute(writer, name, content) \
- (writer)->PushAttribute(name, content)
-#define XmlNewTextWriterFilename(name, flags) new tinyxml2::XMLPrinter
-#define XmlSaveTextWriterFilename(writer, name) \
- { \
- FILE *const writer##File = fopen(name, "wb"); \
- fwrite((writer)->CStr(), 1, (writer)->CStrSize() - 1, writer##File); \
- fclose(writer##File); \
- }
-#define XmlTextWriterSetIndent(writer, flags)
-#define XmlTextWriterStartDocument(writer, p1, p2, p3) \
- (writer)->PushDeclaration("xml version=\"1.0\" encoding=\"utf-8\"")
-#define XmlTextWriterEndDocument(writer) (writer)->CloseElement()
-#define XmlFreeTextWriter(writer) delete writer
-
-#endif // ENABLE_TINYXML2
-#endif // UTILS_XML_TINYXML2_INC
diff --git a/src/utils/xmlutils.cpp b/src/utils/xmlutils.cpp
deleted file mode 100644
index 56510c316..000000000
--- a/src/utils/xmlutils.cpp
+++ /dev/null
@@ -1,185 +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 "utils/xmlutils.h"
-
-#include "logger.h"
-
-#include "utils/xml.h"
-
-#include "debug.h"
-
-void readXmlIntVector(const std::string &fileName,
- const std::string &rootName,
- const std::string &sectionName,
- const std::string &itemName,
- const std::string &attributeName,
- STD_VECTOR<int> &arr,
- const SkipError skipError)
-{
- XML::Document doc(fileName, UseVirtFs_true, skipError);
- XmlNodeConstPtrConst rootNode = doc.rootNode();
-
- if (rootNode == nullptr || !xmlNameEqual(rootNode, rootName.c_str()))
- {
- logger->log("Error while loading %s!", fileName.c_str());
- return;
- }
-
- for_each_xml_child_node(sectionNode, rootNode)
- {
- if (!xmlNameEqual(sectionNode, sectionName.c_str()))
- continue;
- for_each_xml_child_node(childNode, sectionNode)
- {
- if (xmlNameEqual(childNode, itemName.c_str()))
- {
- const int val = XML::getProperty(childNode,
- attributeName.c_str(), -1);
- if (val == -1)
- continue;
- arr.push_back(val);
- }
- else if (xmlNameEqual(childNode, "include"))
- {
- const std::string name = XML::getProperty(
- childNode, "name", "");
- if (!name.empty())
- {
- readXmlIntVector(name,
- rootName,
- sectionName,
- itemName,
- attributeName,
- arr,
- skipError);
- }
- }
- }
- }
-}
-
-void readXmlStringMap(const std::string &fileName,
- const std::string &rootName,
- const std::string &sectionName,
- const std::string &itemName,
- const std::string &attributeKeyName,
- const std::string &attributeValueName,
- std::map<std::string, std::string> &arr,
- const SkipError skipError)
-{
- XML::Document doc(fileName, UseVirtFs_true, skipError);
- XmlNodeConstPtrConst rootNode = doc.rootNode();
-
- if (rootNode == nullptr || !xmlNameEqual(rootNode, rootName.c_str()))
- {
- logger->log("Error while loading %s!", fileName.c_str());
- return;
- }
-
- for_each_xml_child_node(sectionNode, rootNode)
- {
- if (!xmlNameEqual(sectionNode, sectionName.c_str()))
- continue;
- for_each_xml_child_node(childNode, sectionNode)
- {
- if (xmlNameEqual(childNode, itemName.c_str()))
- {
- const std::string key = XML::getProperty(childNode,
- attributeKeyName.c_str(), "");
- if (key.empty())
- continue;
- const std::string val = XML::getProperty(childNode,
- attributeValueName.c_str(), "");
- arr[key] = val;
- }
- else if (xmlNameEqual(childNode, "include"))
- {
- const std::string name = XML::getProperty(
- childNode, "name", "");
- if (!name.empty())
- {
- readXmlStringMap(name,
- rootName,
- sectionName,
- itemName,
- attributeKeyName,
- attributeValueName,
- arr,
- skipError);
- }
- }
- }
- }
-}
-
-void readXmlIntMap(const std::string &fileName,
- const std::string &rootName,
- const std::string &sectionName,
- const std::string &itemName,
- const std::string &attributeKeyName,
- const std::string &attributeValueName,
- std::map<int32_t, int32_t> &arr,
- const SkipError skipError)
-{
- XML::Document doc(fileName, UseVirtFs_true, skipError);
- XmlNodeConstPtrConst rootNode = doc.rootNode();
-
- if (rootNode == nullptr || !xmlNameEqual(rootNode, rootName.c_str()))
- {
- logger->log("Error while loading %s!", fileName.c_str());
- return;
- }
-
- for_each_xml_child_node(sectionNode, rootNode)
- {
- if (!xmlNameEqual(sectionNode, sectionName.c_str()))
- continue;
- for_each_xml_child_node(childNode, sectionNode)
- {
- if (xmlNameEqual(childNode, itemName.c_str()))
- {
- const std::string key = XML::getProperty(childNode,
- attributeKeyName.c_str(), "");
- if (key.empty())
- continue;
- const int32_t val = XML::getProperty(childNode,
- attributeValueName.c_str(), 0);
- arr[atoi(key.c_str())] = val;
- }
- else if (xmlNameEqual(childNode, "include"))
- {
- const std::string name = XML::getProperty(
- childNode, "name", "");
- if (!name.empty())
- {
- readXmlIntMap(name,
- rootName,
- sectionName,
- itemName,
- attributeKeyName,
- attributeValueName,
- arr,
- skipError);
- }
- }
- }
- }
-}
diff --git a/src/utils/xmlutils.h b/src/utils/xmlutils.h
deleted file mode 100644
index daa0575a8..000000000
--- a/src/utils/xmlutils.h
+++ /dev/null
@@ -1,57 +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 UTILS_XMLUTILS_H
-#define UTILS_XMLUTILS_H
-
-#include "enums/simpletypes/skiperror.h"
-
-#include "utils/vector.h"
-
-#include <string>
-#include <map>
-
-void readXmlIntVector(const std::string &fileName,
- const std::string &rootName,
- const std::string &sectionName,
- const std::string &itemName,
- const std::string &attributeName,
- STD_VECTOR<int> &arr,
- const SkipError skipError);
-
-void readXmlStringMap(const std::string &fileName,
- const std::string &rootName,
- const std::string &sectionName,
- const std::string &itemName,
- const std::string &attributeKeyName,
- const std::string &attributeValueName,
- std::map<std::string, std::string> &arr,
- const SkipError skipError);
-
-void readXmlIntMap(const std::string &fileName,
- const std::string &rootName,
- const std::string &sectionName,
- const std::string &itemName,
- const std::string &attributeKeyName,
- const std::string &attributeValueName,
- std::map<int32_t, int32_t> &arr,
- const SkipError skipError);
-
-#endif // UTILS_XMLUTILS_H
diff --git a/src/utils/xmlwriter.h b/src/utils/xmlwriter.h
deleted file mode 100644
index 8e182d72a..000000000
--- a/src/utils/xmlwriter.h
+++ /dev/null
@@ -1,28 +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 UTILS_XMLWRITER_H
-#define UTILS_XMLWRITER_H
-
-#ifdef ENABLE_PUGIXML
-#include "utils/xml/pugixmlwriter.h"
-#endif // ENABLE_PUGIXML
-
-#endif // UTILS_XMLWRITER_H
diff --git a/src/variabledata.h b/src/variabledata.h
deleted file mode 100644
index 89b166482..000000000
--- a/src/variabledata.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 VARIABLEDATA_H
-#define VARIABLEDATA_H
-
-#include <string>
-
-#include "localconsts.h"
-
-class VariableData notfinal
-{
- public:
- enum DataType
- {
- DATA_NONE = 0,
- DATA_INT,
- DATA_STRING,
- DATA_FLOAT,
- DATA_BOOL
- };
-
- VariableData()
- { }
-
- A_DELETE_COPY(VariableData)
-
- virtual ~VariableData()
- {}
-
- virtual int getType() const A_WARN_UNUSED = 0;
-};
-
-class IntData final : public VariableData
-{
- public:
- explicit IntData(const int value) :
- VariableData(),
- mData(value)
- { }
-
- A_DELETE_COPY(IntData)
-
- int getData() const noexcept2 A_WARN_UNUSED
- { return mData; }
-
- int getType() const override final A_WARN_UNUSED
- { return DATA_INT; }
-
- private:
- int mData;
-};
-
-class StringData final : public VariableData
-{
- public:
- explicit StringData(const std::string &value) :
- VariableData(),
- mData(value)
- { }
-
- A_DELETE_COPY(StringData)
-
- const std::string &getData() const noexcept2 A_WARN_UNUSED
- { return mData; }
-
- int getType() const override final A_WARN_UNUSED
- { return DATA_STRING; }
-
- private:
- std::string mData;
-};
-
-class FloatData final : public VariableData
-{
- public:
- explicit FloatData(const double value) :
- VariableData(),
- mData(value)
- { }
-
- A_DELETE_COPY(FloatData)
-
- double getData() const noexcept2 A_WARN_UNUSED
- { return mData; }
-
- int getType() const override final A_WARN_UNUSED
- { return DATA_FLOAT; }
-
- private:
- double mData;
-};
-
-class BoolData final : public VariableData
-{
- public:
- explicit BoolData(const bool value) :
- VariableData(),
- mData(value)
- { }
-
- A_DELETE_COPY(BoolData)
-
- bool getData() const noexcept2 A_WARN_UNUSED
- { return mData; }
-
- int getType() const override final A_WARN_UNUSED
- { return DATA_BOOL; }
-
- private:
- bool mData;
-};
-
-#endif // VARIABLEDATA_H
diff --git a/src/vector.cpp b/src/vector.cpp
deleted file mode 100644
index 11ab5f5e0..000000000
--- a/src/vector.cpp
+++ /dev/null
@@ -1,31 +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 "vector.h"
-
-#include "debug.h"
-
-std::ostream& operator <<(std::ostream &os, const Vector &v)
-{
- os << "Vector(" << v.x << ", " << v.y << ", " << v.z << ")";
- return os;
-}
diff --git a/src/vector.h b/src/vector.h
deleted file mode 100644
index 6c06d90d9..000000000
--- a/src/vector.h
+++ /dev/null
@@ -1,216 +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 VECTOR_H
-#define VECTOR_H
-
-#ifndef USE_SDL2
-#include <cmath>
-#endif // USE_SDL2
-
-#include <iostream>
-
-#include "localconsts.h"
-
-/**
- * Vector class. Represents either a 3D point in space, a velocity or a force.
- * Provides several convenient operator overloads.
- */
-class Vector final
-{
- public:
- /**
- * Constructor.
- */
- Vector() :
- x(0.0F),
- y(0.0F),
- z(0.0F)
- {}
-
- /**
- * Constructor.
- */
- Vector(const float x0,
- const float y0,
- const float z0 = 0.0F) :
- x(x0),
- y(y0),
- z(z0)
- {}
-
- /**
- * Copy constructor.
- */
- Vector(const Vector &v) :
- x(v.x),
- y(v.y),
- z(v.z)
- {}
-
- A_DEFAULT_COPY(Vector)
-
- /**
- * Returns true if all coordinates are set to 0, otherwise returns
- * false.
- */
- bool isNull() const noexcept2 A_WARN_UNUSED
- {
- return x == 0.0F && y == 0.0F && z == 0.0F;
- }
-
- Vector &operator=(const Vector &v) noexcept2
- {
- x = v.x;
- y = v.y;
- z = v.z;
- return *this;
- }
-
- /**
- * Scale vector operator.
- */
- Vector operator*(const float c) const noexcept2 A_WARN_UNUSED
- {
- return Vector(x * c,
- y * c,
- z * c);
- }
-
- /**
- * In-place scale vector operator.
- */
- Vector &operator*=(const float c) noexcept2
- {
- x *= c;
- y *= c;
- z *= c;
- return *this;
- }
-
- /**
- * Scale vector operator.
- */
- Vector operator/(const float c) const noexcept2 A_WARN_UNUSED
- {
- return Vector(x / c,
- y / c,
- z / c);
- }
-
- /**
- * In-place scale vector operator.
- */
- Vector &operator/=(const float c) noexcept2 A_WARN_UNUSED
- {
- x /= c;
- y /= c;
- z /= c;
- return *this;
- }
-
- /**
- * Add vector operator.
- */
- Vector operator+(const Vector &v) const noexcept2 A_WARN_UNUSED
- {
- return Vector(x + v.x,
- y + v.y,
- z + v.z);
- }
-
- /**
- * In-place add vector operator.
- */
- Vector &operator+=(const Vector &v) noexcept2
- {
- x += v.x;
- y += v.y;
- z += v.z;
- return *this;
- }
-
- /**
- * Subtract vector operator.
- */
- Vector operator-(const Vector &v) const noexcept2 A_WARN_UNUSED
- {
- return Vector(x - v.x,
- y - v.y,
- z - v.z);
- }
-
- /**
- * In-place subtract vector operator.
- */
- Vector &operator-=(const Vector &v) noexcept2
- {
- x -= v.x;
- y -= v.y;
- z -= v.z;
- return *this;
- }
-
- /**
- * Returns the length of this vector. This method does a relatively
- * slow square root.
- */
- float length() const A_WARN_UNUSED
- {
- return sqrtf(x * x + y * y + z * z);
- }
-
- /**
- * Returns the squared length of this vector. Avoids the square root.
- */
- float squaredLength() const noexcept2 A_WARN_UNUSED
- {
- return x * x + y * y + z * z;
- }
-
- /**
- * Returns the manhattan length of this vector.
- */
- float manhattanLength() const A_WARN_UNUSED
- {
- return fabsf(x) + fabsf(y) + fabsf(z);
- }
-
- /**
- * Returns a normalized version of this vector. This is a unit vector
- * running parallel to it.
- */
- Vector normalized() const A_WARN_UNUSED
- {
- const float len = length();
- return Vector(x / len, y / len, z / len);
- }
-
- float x, y, z;
-};
-
-/**
- * Appends a string representation of a vector to the output stream.
- */
-std::ostream& operator <<(std::ostream &os, const Vector &v);
-
-#endif // VECTOR_H
diff --git a/src/winver.h b/src/winver.h
deleted file mode 100644
index 78f724bc0..000000000
--- a/src/winver.h
+++ /dev/null
@@ -1,26 +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/>.
- */
-
-/* VERSION DEFINITIONS */
-#define VER_MAJOR 1
-#define VER_MINOR 0
-#define VER_RELEASE 0
-#define VER_BUILD 0
-#define PACKAGE_VERSION "1.0.0"
diff --git a/src/winver.h.in b/src/winver.h.in
deleted file mode 100644
index 078b7a33f..000000000
--- a/src/winver.h.in
+++ /dev/null
@@ -1,26 +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/>.
- */
-
-/* VERSION DEFINITIONS */
-#define VER_MAJOR ${VER_MAJOR}
-#define VER_MINOR ${VER_MINOR}
-#define VER_RELEASE ${VER_RELEASE}
-#define VER_BUILD ${VER_BUILD}
-#define PACKAGE_VERSION "${VERSION}"